diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..052de9b --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,89 @@ +# Version 3.0.4 +=============== ++Balance cpu threads usage ++Activate diffplot + +# Version 3.0.3 +=============== ++Fixed wallet lagging ++Reduced cpu threads usage ++Show Masternode List & (Keep updating actived masternode) ++Fixed PoS 1.2SONO instead of 2SONO + +# Version 3.0.2 +=============== ++Restored wins qt wallet + +# Version 3.0.1 +=============== ++Fix for init_blockindex bug ++Updated bootstrap (15 nov) ++Windows version for first time users of SONO Wallet (fixes statup issue from version 3.0.0) ++For users of previous SONO Wallets this update is not required + + +# Version 3.0.0 +=============== ++Changed vNode.emty to vNode < 3 in miner.cpp ++Upgraded multisig-wallet ++Added IsInitialBlockDownload ++Added GetMNCollateral ++Improved MN functions ++Prepared to initilised SONOgate ++Fixed QT wallet CPU threads exhausted + +# Version 2.2.4 +=============== ++Updated SONO Logo ++Reduced masternode expiration second ++Reduced masternode removal second ++Changed payee = winner.payee to Tx ++Forced upgraded blockhash --> Added Masternode payment request sync ++Added Splited up masternode hash ++Added Moved masternode hash around, the closest masternode to that point wins ++Added Calculate distance between target point and masternode point ++Increased search existing masternode list, this is where we update existing with new dsee broadcasts ++Fixed seednode error + +# Version 2.2.3 +=============== ++Fixed Masternode payment error + +# Version 2.2.2 +=============== ++Fixed Masternode Pubkey ++Added Masternode Config + +# Version 2.2.1 +=============== ++Upgraded QT wallet UI ++Added PoS automate function ++Added client control function ++Added network statistics into block explorer ++Redesign dashboard tab +# Version 2.2.0 +=============== ++Fixed Sync error ++Fixed seednode ++Fixed network protocol ++Fixed some typo + +# Version 2.1.0 +=============== ++Fixed Typo ++Added new checkpoint ++Added Block brownser.cpp & blockbrownser.h ++Update QT wallet UI ++Added Block Explorer UI + +# Version 2.0.0 +============== ++Reduced outbounce connection to 12 ++Add more seednodes ++Inscreased faster peers ++Fixed qt version missmatch + + + + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..136523b --- /dev/null +++ b/Makefile @@ -0,0 +1,18715 @@ +############################################################################# +# Makefile for building: SONO-qt +# Generated by qmake (3.0) (Qt 5.2.1) +# Project: sono-qt.pro +# Template: app +# Command: /usr/lib/x86_64-linux-gnu/qt5/bin/qmake -o Makefile sono-qt.pro +############################################################################# + +MAKEFILE = Makefile + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DENABLE_WALLET -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_DISABLE_DEPRECATED_BEFORE=0 -DUSE_UPNP=1 -DSTATICLIB -DUSE_DBUS -DHAVE_BUILD_INFO -DLINUX -DQT_NO_DEBUG -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_DBUS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB +CFLAGS = -m64 -pipe -O2 -D_REENTRANT -Wall -W -fPIE $(DEFINES) +CXXFLAGS = -fpermissive -fstack-protector-all --param ssp-buffer-size=1 -O2 -D_REENTRANT -fdiagnostics-show-option -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector -fPIE $(DEFINES) +INCPATH = -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -Isrc -Isrc/json -Isrc/qt -Isrc/qt/plugins/mrichtexteditor -Isrc/leveldb/include -Isrc/leveldb/helpers -I/usr/include/qt5 -I/usr/include/qt5/QtPrintSupport -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtDBus -I/usr/include/qt5/QtNetwork -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -Ibuild -Ibuild +LINK = g++ +LFLAGS = -m64 -fstack-protector-all --param ssp-buffer-size=1 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/X11R6/lib64 -lminiupnpc /root/Sono-final-master/src/leveldb/libleveldb.a /root/Sono-final-master/src/leveldb/libmemenv.a -lssl -lcrypto -ldb_cxx -lboost_system -lboost_filesystem -lboost_program_options -lboost_thread -lrt -ldl -lQt5PrintSupport -L/usr/lib/x86_64-linux-gnu -lQt5Widgets -lQt5DBus -lQt5Network -lQt5Gui -lQt5Core -lpthread -lGL +AR = ar cqs +RANLIB = +QMAKE = /usr/lib/x86_64-linux-gnu/qt5/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = cp -f +COPY_DIR = cp -f -R +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = build/ + +####### Files + +SOURCES = src/txdb-leveldb.cpp \ + src/bloom.cpp \ + src/hash.cpp \ + src/qt/rpcexecutor.cpp \ + src/qt/forms/sidetoolbar.cpp \ + src/qt/bitcoin.cpp \ + src/qt/bitcoingui.cpp \ + src/obj/skunkhash/skein.c \ + src/obj/skunkhash/cubehash.c \ + src/obj/skunkhash/gost.c \ + src/obj/skunkhash/fugue.c \ + src/qt/transactiontablemodel.cpp \ + src/qt/addresstablemodel.cpp \ + src/qt/optionsdialog.cpp \ + src/qt/sendcoinsdialog.cpp \ + src/qt/coincontroldialog.cpp \ + src/qt/coincontroltreewidget.cpp \ + src/qt/addressbookpage.cpp \ + src/qt/signverifymessagedialog.cpp \ + src/qt/aboutdialog.cpp \ + src/qt/editaddressdialog.cpp \ + src/qt/bitcoinaddressvalidator.cpp \ + src/alert.cpp \ + src/chainparams.cpp \ + src/version.cpp \ + src/sync.cpp \ + src/txmempool.cpp \ + src/util.cpp \ + src/netbase.cpp \ + src/key.cpp \ + src/eckey.cpp \ + src/script.cpp \ + src/scrypt.cpp \ + src/core.cpp \ + src/main.cpp \ + src/miner.cpp \ + src/init.cpp \ + src/net.cpp \ + src/checkpoints.cpp \ + src/addrman.cpp \ + src/db.cpp \ + src/walletdb.cpp \ + src/qt/blockbrowser.cpp \ + src/qt/clientmodel.cpp \ + src/qt/clientcontrolpage.cpp \ + src/qt/guiutil.cpp \ + src/qt/transactionrecord.cpp \ + src/qt/optionsmodel.cpp \ + src/qt/monitoreddatamapper.cpp \ + src/qt/trafficgraphwidget.cpp \ + src/qt/transactiondesc.cpp \ + src/qt/transactiondescdialog.cpp \ + src/qt/bitcoinstrings.cpp \ + src/qt/bitcoinamountfield.cpp \ + src/wallet.cpp \ + src/keystore.cpp \ + src/qt/transactionfilterproxy.cpp \ + src/qt/transactionview.cpp \ + src/qt/walletmodel.cpp \ + src/rpcclient.cpp \ + src/rpcprotocol.cpp \ + src/rpcserver.cpp \ + src/rpcdump.cpp \ + src/rpcmisc.cpp \ + src/rpcnet.cpp \ + src/rpcmining.cpp \ + src/rpcwallet.cpp \ + src/rpcblockchain.cpp \ + src/rpcrawtransaction.cpp \ + src/timedata.cpp \ + src/qt/overviewpage.cpp \ + src/qt/csvmodelwriter.cpp \ + src/crypter.cpp \ + src/qt/sendcoinsentry.cpp \ + src/qt/qvalidatedlineedit.cpp \ + src/qt/bitcoinunits.cpp \ + src/qt/qvaluecombobox.cpp \ + src/qt/askpassphrasedialog.cpp \ + src/protocol.cpp \ + src/qt/notificator.cpp \ + src/qt/paymentserver.cpp \ + src/qt/rpcconsole.cpp \ + src/noui.cpp \ + src/kernel.cpp \ + src/pbkdf2.cpp \ + src/stealth.cpp \ + src/qt/flowlayout.cpp \ + src/qt/darksendconfig.cpp \ + src/masternode.cpp \ + src/darksend.cpp \ + src/rpcdarksend.cpp \ + src/instantx.cpp \ + src/activemasternode.cpp \ + src/spork.cpp \ + src/masternodeconfig.cpp \ + src/crypto/hmac_sha256.cpp \ + src/crypto/hmac_sha512.cpp \ + src/crypto/rfc6979_hmac_sha256.cpp \ + src/crypto/ripemd160.cpp \ + src/crypto/sha1.cpp \ + src/crypto/sha256.cpp \ + src/crypto/sha512.cpp \ + src/eccryptoverify.cpp \ + src/qt/masternodemanager.cpp \ + src/qt/addeditadrenalinenode.cpp \ + src/qt/adrenalinenodeconfigdialog.cpp \ + src/qt/qcustomplot.cpp \ + src/smessage.cpp \ + src/qt/messagepage.cpp \ + src/qt/messagemodel.cpp \ + src/qt/sendmessagesdialog.cpp \ + src/qt/sendmessagesentry.cpp \ + src/qt/qvalidatedtextedit.cpp \ + src/qt/plugins/mrichtexteditor/mrichtextedit.cpp \ + src/rpcsmessage.cpp qrc_bitcoin.cpp \ + build/moc_bitcoingui.cpp \ + build/moc_transactiontablemodel.cpp \ + build/moc_addresstablemodel.cpp \ + build/moc_optionsdialog.cpp \ + build/moc_coincontroldialog.cpp \ + build/moc_coincontroltreewidget.cpp \ + build/moc_sendcoinsdialog.cpp \ + build/moc_addressbookpage.cpp \ + build/moc_clientcontrolpage.cpp \ + build/moc_signverifymessagedialog.cpp \ + build/moc_aboutdialog.cpp \ + build/moc_editaddressdialog.cpp \ + build/moc_bitcoinaddressvalidator.cpp \ + build/moc_blockbrowser.cpp \ + build/moc_clientmodel.cpp \ + build/moc_guiutil.cpp \ + build/moc_optionsmodel.cpp \ + build/moc_monitoreddatamapper.cpp \ + build/moc_trafficgraphwidget.cpp \ + build/moc_transactiondesc.cpp \ + build/moc_transactiondescdialog.cpp \ + build/moc_bitcoinamountfield.cpp \ + build/moc_transactionfilterproxy.cpp \ + build/moc_transactionview.cpp \ + build/moc_walletmodel.cpp \ + build/moc_overviewpage.cpp \ + build/moc_csvmodelwriter.cpp \ + build/moc_sendcoinsentry.cpp \ + build/moc_qvalidatedlineedit.cpp \ + build/moc_bitcoinunits.cpp \ + build/moc_qvaluecombobox.cpp \ + build/moc_askpassphrasedialog.cpp \ + build/moc_notificator.cpp \ + build/moc_paymentserver.cpp \ + build/moc_rpcconsole.cpp \ + build/moc_darksendconfig.cpp \ + build/moc_masternodemanager.cpp \ + build/moc_addeditadrenalinenode.cpp \ + build/moc_adrenalinenodeconfigdialog.cpp \ + build/moc_qcustomplot.cpp \ + build/moc_messagepage.cpp \ + build/moc_messagemodel.cpp \ + build/moc_sendmessagesdialog.cpp \ + build/moc_sendmessagesentry.cpp \ + build/moc_mrichtextedit.cpp \ + build/moc_qvalidatedtextedit.cpp \ + build/moc_txviewdelegate.cpp \ + build/moc_rpcexecutor.cpp \ + build/moc_sidetoolbar.cpp +OBJECTS = build/txdb-leveldb.o \ + build/bloom.o \ + build/hash.o \ + build/rpcexecutor.o \ + build/sidetoolbar.o \ + build/bitcoin.o \ + build/bitcoingui.o \ + build/skein.o \ + build/cubehash.o \ + build/gost.o \ + build/fugue.o \ + build/transactiontablemodel.o \ + build/addresstablemodel.o \ + build/optionsdialog.o \ + build/sendcoinsdialog.o \ + build/coincontroldialog.o \ + build/coincontroltreewidget.o \ + build/addressbookpage.o \ + build/signverifymessagedialog.o \ + build/aboutdialog.o \ + build/editaddressdialog.o \ + build/bitcoinaddressvalidator.o \ + build/alert.o \ + build/chainparams.o \ + build/version.o \ + build/sync.o \ + build/txmempool.o \ + build/util.o \ + build/netbase.o \ + build/key.o \ + build/eckey.o \ + build/script.o \ + build/scrypt.o \ + build/core.o \ + build/main.o \ + build/miner.o \ + build/init.o \ + build/net.o \ + build/checkpoints.o \ + build/addrman.o \ + build/db.o \ + build/walletdb.o \ + build/blockbrowser.o \ + build/clientmodel.o \ + build/clientcontrolpage.o \ + build/guiutil.o \ + build/transactionrecord.o \ + build/optionsmodel.o \ + build/monitoreddatamapper.o \ + build/trafficgraphwidget.o \ + build/transactiondesc.o \ + build/transactiondescdialog.o \ + build/bitcoinstrings.o \ + build/bitcoinamountfield.o \ + build/wallet.o \ + build/keystore.o \ + build/transactionfilterproxy.o \ + build/transactionview.o \ + build/walletmodel.o \ + build/rpcclient.o \ + build/rpcprotocol.o \ + build/rpcserver.o \ + build/rpcdump.o \ + build/rpcmisc.o \ + build/rpcnet.o \ + build/rpcmining.o \ + build/rpcwallet.o \ + build/rpcblockchain.o \ + build/rpcrawtransaction.o \ + build/timedata.o \ + build/overviewpage.o \ + build/csvmodelwriter.o \ + build/crypter.o \ + build/sendcoinsentry.o \ + build/qvalidatedlineedit.o \ + build/bitcoinunits.o \ + build/qvaluecombobox.o \ + build/askpassphrasedialog.o \ + build/protocol.o \ + build/notificator.o \ + build/paymentserver.o \ + build/rpcconsole.o \ + build/noui.o \ + build/kernel.o \ + build/pbkdf2.o \ + build/stealth.o \ + build/flowlayout.o \ + build/darksendconfig.o \ + build/masternode.o \ + build/darksend.o \ + build/rpcdarksend.o \ + build/instantx.o \ + build/activemasternode.o \ + build/spork.o \ + build/masternodeconfig.o \ + build/hmac_sha256.o \ + build/hmac_sha512.o \ + build/rfc6979_hmac_sha256.o \ + build/ripemd160.o \ + build/sha1.o \ + build/sha256.o \ + build/sha512.o \ + build/eccryptoverify.o \ + build/masternodemanager.o \ + build/addeditadrenalinenode.o \ + build/adrenalinenodeconfigdialog.o \ + build/qcustomplot.o \ + build/smessage.o \ + build/messagepage.o \ + build/messagemodel.o \ + build/sendmessagesdialog.o \ + build/sendmessagesentry.o \ + build/qvalidatedtextedit.o \ + build/mrichtextedit.o \ + build/rpcsmessage.o \ + build/qrc_bitcoin.o \ + build/moc_bitcoingui.o \ + build/moc_transactiontablemodel.o \ + build/moc_addresstablemodel.o \ + build/moc_optionsdialog.o \ + build/moc_coincontroldialog.o \ + build/moc_coincontroltreewidget.o \ + build/moc_sendcoinsdialog.o \ + build/moc_addressbookpage.o \ + build/moc_clientcontrolpage.o \ + build/moc_signverifymessagedialog.o \ + build/moc_aboutdialog.o \ + build/moc_editaddressdialog.o \ + build/moc_bitcoinaddressvalidator.o \ + build/moc_blockbrowser.o \ + build/moc_clientmodel.o \ + build/moc_guiutil.o \ + build/moc_optionsmodel.o \ + build/moc_monitoreddatamapper.o \ + build/moc_trafficgraphwidget.o \ + build/moc_transactiondesc.o \ + build/moc_transactiondescdialog.o \ + build/moc_bitcoinamountfield.o \ + build/moc_transactionfilterproxy.o \ + build/moc_transactionview.o \ + build/moc_walletmodel.o \ + build/moc_overviewpage.o \ + build/moc_csvmodelwriter.o \ + build/moc_sendcoinsentry.o \ + build/moc_qvalidatedlineedit.o \ + build/moc_bitcoinunits.o \ + build/moc_qvaluecombobox.o \ + build/moc_askpassphrasedialog.o \ + build/moc_notificator.o \ + build/moc_paymentserver.o \ + build/moc_rpcconsole.o \ + build/moc_darksendconfig.o \ + build/moc_masternodemanager.o \ + build/moc_addeditadrenalinenode.o \ + build/moc_adrenalinenodeconfigdialog.o \ + build/moc_qcustomplot.o \ + build/moc_messagepage.o \ + build/moc_messagemodel.o \ + build/moc_sendmessagesdialog.o \ + build/moc_sendmessagesentry.o \ + build/moc_mrichtextedit.o \ + build/moc_qvalidatedtextedit.o \ + build/moc_txviewdelegate.o \ + build/moc_rpcexecutor.o \ + build/moc_sidetoolbar.o +DIST = /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/shell-unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/linux.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base-unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-base.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/qconfig.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_designer.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_help.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_platformsupport_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_uitools.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_functions.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_config.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64/qmake.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_post.prf \ + .qmake.stash \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exclusive_builds.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_pre.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resolve_config.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_post.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/thread.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/warn_on.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resources.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/moc.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/opengl.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/dbuscommon.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/dbusinterfaces.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/dbusadaptors.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/uic.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/testcase_targets.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exceptions.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/yacc.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/lex.prf \ + sono-qt.pro \ + src/qt/bitcoin.qrc \ + sono-qt.pro +QMAKE_TARGET = SONO-qt +DESTDIR = #avoid trailing-slash linebreak +TARGET = SONO-qt + + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): /root/Sono-final-master/src/leveldb/libleveldb.a /root/Sono-final-master/build/build.h build/ui_coincontroldialog.h build/ui_sendcoinsdialog.h build/ui_addressbookpage.h build/ui_signverifymessagedialog.h build/ui_aboutdialog.h build/ui_editaddressdialog.h build/ui_transactiondescdialog.h build/ui_overviewpage.h build/ui_clientcontrolpage.h build/ui_sendcoinsentry.h build/ui_askpassphrasedialog.h build/ui_blockbrowser.h build/ui_rpcconsole.h build/ui_optionsdialog.h build/ui_darksendconfig.h build/ui_masternodemanager.h build/ui_addeditadrenalinenode.h build/ui_adrenalinenodeconfigdialog.h build/ui_messagepage.h build/ui_sendmessagesentry.h build/ui_sendmessagesdialog.h build/ui_mrichtextedit.h build/ui_sidetoolbar.h $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: sono-qt.pro /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64/qmake.conf /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/shell-unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/linux.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base-unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-base.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-unix.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/qconfig.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_designer.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_help.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_platformsupport_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_uitools.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml_private.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_functions.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_config.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64/qmake.conf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_post.prf \ + .qmake.stash \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exclusive_builds.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_pre.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resolve_config.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_post.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/thread.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/warn_on.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resources.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/moc.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/opengl.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/dbuscommon.pri \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/dbusinterfaces.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/dbusadaptors.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/uic.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/testcase_targets.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exceptions.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/yacc.prf \ + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/lex.prf \ + sono-qt.pro \ + src/qt/bitcoin.qrc \ + /usr/lib/x86_64-linux-gnu/libQt5PrintSupport.prl \ + /usr/lib/x86_64-linux-gnu/libQt5Widgets.prl \ + /usr/lib/x86_64-linux-gnu/libQt5Gui.prl \ + /usr/lib/x86_64-linux-gnu/libQt5Core.prl \ + /usr/lib/x86_64-linux-gnu/libQt5DBus.prl \ + /usr/lib/x86_64-linux-gnu/libQt5Network.prl + $(QMAKE) -o Makefile sono-qt.pro +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/shell-unix.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/unix.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/linux.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/gcc-base-unix.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-base.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/g++-unix.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/qconfig.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_concurrent_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_core_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_designer.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_gui_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_help.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_network_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_opengl_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_platformsupport_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_printsupport_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_sql_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_testlib_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_uitools.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_widgets_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_xml_private.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_functions.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt_config.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64/qmake.conf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_post.prf: +.qmake.stash: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exclusive_builds.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_pre.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resolve_config.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/default_post.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/thread.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/warn_on.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/qt.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/resources.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/moc.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/unix/opengl.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/dbuscommon.pri: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/dbusinterfaces.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/dbusadaptors.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/uic.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/testcase_targets.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/exceptions.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/yacc.prf: +/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/lex.prf: +sono-qt.pro: +src/qt/bitcoin.qrc: +/usr/lib/x86_64-linux-gnu/libQt5PrintSupport.prl: +/usr/lib/x86_64-linux-gnu/libQt5Widgets.prl: +/usr/lib/x86_64-linux-gnu/libQt5Gui.prl: +/usr/lib/x86_64-linux-gnu/libQt5Core.prl: +/usr/lib/x86_64-linux-gnu/libQt5DBus.prl: +/usr/lib/x86_64-linux-gnu/libQt5Network.prl: +qmake: FORCE + @$(QMAKE) -o Makefile sono-qt.pro + +qmake_all: FORCE + +dist: + @test -d build/SONO-qt1.2.0.0 || mkdir -p build/SONO-qt1.2.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) build/SONO-qt1.2.0.0/ && $(COPY_FILE) --parents src/qt/locale/bitcoin_en.ts build/SONO-qt1.2.0.0/ && $(COPY_FILE) --parents src/qt/bitcoin.qrc build/SONO-qt1.2.0.0/ && $(COPY_FILE) --parents src/qt/bitcoingui.h src/qt/transactiontablemodel.h src/qt/addresstablemodel.h src/qt/optionsdialog.h src/qt/coincontroldialog.h src/qt/coincontroltreewidget.h src/qt/sendcoinsdialog.h src/qt/addressbookpage.h src/qt/clientcontrolpage.h src/qt/signverifymessagedialog.h src/qt/aboutdialog.h src/qt/editaddressdialog.h src/qt/bitcoinaddressvalidator.h src/alert.h src/addrman.h src/base58.h src/bignum.h src/chainparams.h src/chainparamsseeds.h src/checkpoints.h src/compat.h src/coincontrol.h src/sync.h src/util.h src/hash.h src/uint256.h src/kernel.h src/pbkdf2.h src/serialize.h src/core.h src/main.h src/miner.h src/net.h src/key.h src/eckey.h src/db.h src/txdb.h src/txmempool.h src/walletdb.h src/script.h src/scrypt.h src/init.h src/mruset.h src/json/json_spirit_writer_template.h src/json/json_spirit_writer.h src/json/json_spirit_value.h src/json/json_spirit_utils.h src/json/json_spirit_stream_reader.h src/json/json_spirit_reader_template.h src/json/json_spirit_reader.h src/json/json_spirit_error_position.h src/json/json_spirit.h src/qt/blockbrowser.h src/qt/clientmodel.h src/qt/guiutil.h src/qt/transactionrecord.h src/qt/guiconstants.h src/qt/optionsmodel.h src/qt/monitoreddatamapper.h src/qt/trafficgraphwidget.h src/qt/transactiondesc.h src/qt/transactiondescdialog.h src/qt/bitcoinamountfield.h src/wallet.h src/keystore.h src/qt/transactionfilterproxy.h src/qt/transactionview.h src/qt/walletmodel.h src/rpcclient.h src/rpcprotocol.h src/rpcserver.h src/timedata.h src/qt/overviewpage.h src/qt/csvmodelwriter.h src/crypter.h src/qt/sendcoinsentry.h src/qt/qvalidatedlineedit.h src/qt/bitcoinunits.h src/qt/qvaluecombobox.h src/qt/askpassphrasedialog.h src/protocol.h src/qt/notificator.h src/qt/paymentserver.h src/allocators.h src/ui_interface.h src/qt/rpcconsole.h src/version.h src/netbase.h src/clientversion.h src/threadsafety.h src/tinyformat.h src/stealth.h src/qt/flowlayout.h src/qt/darksendconfig.h src/masternode.h src/darksend.h src/instantx.h src/activemasternode.h src/spork.h src/crypto/common.h src/crypto/hmac_sha256.h src/crypto/hmac_sha512.h src/crypto/rfc6979_hmac_sha256.h src/crypto/ripemd160.h src/crypto/sha1.h src/crypto/sha256.h src/crypto/sha512.h src/eccryptoverify.h src/qt/masternodemanager.h src/qt/addeditadrenalinenode.h src/qt/adrenalinenodeconfigdialog.h src/qt/qcustomplot.h src/smessage.h src/qt/messagepage.h src/qt/messagemodel.h src/qt/sendmessagesdialog.h src/qt/sendmessagesentry.h src/qt/plugins/mrichtexteditor/mrichtextedit.h src/qt/qvalidatedtextedit.h src/bloom.h src/hashblock.h src/obj/skunkhash/sph_skein.h src/obj/skunkhash/sph_types.h src/obj/skunkhash/sph_cubehash.h src/obj/skunkhash/sph_fugue.h src/txdb-leveldb.h src/qt/txviewdelegate.h src/qt/rpcexecutor.h src/qt/forms/sidetoolbar.h build/SONO-qt1.2.0.0/ && $(COPY_FILE) --parents src/txdb-leveldb.cpp src/bloom.cpp src/hash.cpp src/qt/rpcexecutor.cpp src/qt/forms/sidetoolbar.cpp src/qt/bitcoin.cpp src/qt/bitcoingui.cpp src/obj/skunkhash/skein.c src/obj/skunkhash/cubehash.c src/obj/skunkhash/gost.c src/obj/skunkhash/fugue.c src/qt/transactiontablemodel.cpp src/qt/addresstablemodel.cpp src/qt/optionsdialog.cpp src/qt/sendcoinsdialog.cpp src/qt/coincontroldialog.cpp src/qt/coincontroltreewidget.cpp src/qt/addressbookpage.cpp src/qt/signverifymessagedialog.cpp src/qt/aboutdialog.cpp src/qt/editaddressdialog.cpp src/qt/bitcoinaddressvalidator.cpp src/alert.cpp src/chainparams.cpp src/version.cpp src/sync.cpp src/txmempool.cpp src/util.cpp src/netbase.cpp src/key.cpp src/eckey.cpp src/script.cpp src/scrypt.cpp src/core.cpp src/main.cpp src/miner.cpp src/init.cpp src/net.cpp src/checkpoints.cpp src/addrman.cpp src/db.cpp src/walletdb.cpp src/qt/blockbrowser.cpp src/qt/clientmodel.cpp src/qt/clientcontrolpage.cpp src/qt/guiutil.cpp src/qt/transactionrecord.cpp src/qt/optionsmodel.cpp src/qt/monitoreddatamapper.cpp src/qt/trafficgraphwidget.cpp src/qt/transactiondesc.cpp src/qt/transactiondescdialog.cpp src/qt/bitcoinstrings.cpp src/qt/bitcoinamountfield.cpp src/wallet.cpp src/keystore.cpp src/qt/transactionfilterproxy.cpp src/qt/transactionview.cpp src/qt/walletmodel.cpp src/rpcclient.cpp src/rpcprotocol.cpp src/rpcserver.cpp src/rpcdump.cpp src/rpcmisc.cpp src/rpcnet.cpp src/rpcmining.cpp src/rpcwallet.cpp src/rpcblockchain.cpp src/rpcrawtransaction.cpp src/timedata.cpp src/qt/overviewpage.cpp src/qt/csvmodelwriter.cpp src/crypter.cpp src/qt/sendcoinsentry.cpp src/qt/qvalidatedlineedit.cpp src/qt/bitcoinunits.cpp src/qt/qvaluecombobox.cpp src/qt/askpassphrasedialog.cpp src/protocol.cpp src/qt/notificator.cpp src/qt/paymentserver.cpp src/qt/rpcconsole.cpp src/noui.cpp src/kernel.cpp src/pbkdf2.cpp src/stealth.cpp src/qt/flowlayout.cpp src/qt/darksendconfig.cpp src/masternode.cpp src/darksend.cpp src/rpcdarksend.cpp src/instantx.cpp src/activemasternode.cpp src/spork.cpp src/masternodeconfig.cpp src/crypto/hmac_sha256.cpp src/crypto/hmac_sha512.cpp src/crypto/rfc6979_hmac_sha256.cpp src/crypto/ripemd160.cpp src/crypto/sha1.cpp src/crypto/sha256.cpp src/crypto/sha512.cpp src/eccryptoverify.cpp src/qt/masternodemanager.cpp src/qt/addeditadrenalinenode.cpp src/qt/adrenalinenodeconfigdialog.cpp src/qt/qcustomplot.cpp src/smessage.cpp src/qt/messagepage.cpp src/qt/messagemodel.cpp src/qt/sendmessagesdialog.cpp src/qt/sendmessagesentry.cpp src/qt/qvalidatedtextedit.cpp src/qt/plugins/mrichtexteditor/mrichtextedit.cpp src/rpcsmessage.cpp build/SONO-qt1.2.0.0/ && $(COPY_FILE) --parents src/qt/forms/coincontroldialog.ui src/qt/forms/sendcoinsdialog.ui src/qt/forms/addressbookpage.ui src/qt/forms/signverifymessagedialog.ui src/qt/forms/aboutdialog.ui src/qt/forms/editaddressdialog.ui src/qt/forms/transactiondescdialog.ui src/qt/forms/overviewpage.ui src/qt/forms/clientcontrolpage.ui src/qt/forms/sendcoinsentry.ui src/qt/forms/askpassphrasedialog.ui src/qt/forms/blockbrowser.ui src/qt/forms/rpcconsole.ui src/qt/forms/optionsdialog.ui src/qt/forms/darksendconfig.ui src/qt/forms/masternodemanager.ui src/qt/forms/addeditadrenalinenode.ui src/qt/forms/adrenalinenodeconfigdialog.ui src/qt/forms/messagepage.ui src/qt/forms/sendmessagesentry.ui src/qt/forms/sendmessagesdialog.ui src/qt/plugins/mrichtexteditor/mrichtextedit.ui src/qt/forms/sidetoolbar.ui build/SONO-qt1.2.0.0/ && $(COPY_FILE) --parents src/qt/locale/bitcoin_en.ts build/SONO-qt1.2.0.0/ && (cd `dirname build/SONO-qt1.2.0.0` && $(TAR) SONO-qt1.2.0.0.tar SONO-qt1.2.0.0 && $(COMPRESS) SONO-qt1.2.0.0.tar) && $(MOVE) `dirname build/SONO-qt1.2.0.0`/SONO-qt1.2.0.0.tar.gz . && $(DEL_FILE) -r build/SONO-qt1.2.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) /root/Sono-final-master/src/leveldb/libleveldb.a; cd /root/Sono-final-master/src/leveldb ; $(MAKE) clean + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +/root/Sono-final-master/src/leveldb/libleveldb.a: FORCE + cd /root/Sono-final-master/src/leveldb && CC=gcc CXX=g++ $(MAKE) OPT="-fpermissive -fstack-protector-all --param ssp-buffer-size=1 -O2" libleveldb.a libmemenv.a + +/root/Sono-final-master/build/build.h: FORCE + cd /root/Sono-final-master; /bin/sh share/genbuild.sh /root/Sono-final-master/build/build.h + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +check: first + +compiler_TSQM_make_all: src/qt/locale/bitcoin_en.qm +compiler_TSQM_clean: + -$(DEL_FILE) src/qt/locale/bitcoin_en.qm +src/qt/locale/bitcoin_en.qm: src/qt/locale/bitcoin_en.ts + /usr/lib/x86_64-linux-gnu/qt5/bin/lrelease src/qt/locale/bitcoin_en.ts -qm src/qt/locale/bitcoin_en.qm + +compiler_rcc_make_all: qrc_bitcoin.cpp +compiler_rcc_clean: + -$(DEL_FILE) qrc_bitcoin.cpp +qrc_bitcoin.cpp: src/qt/bitcoin.qrc \ + src/qt/locale/bitcoin_en.qm \ + src/qt/res/movies/update_spinner_black.mng \ + src/qt/res/movies/update_spinner.mng \ + src/qt/res/images/header.png \ + src/qt/res/images/splash.png \ + src/qt/res/images/about.png \ + src/qt/res/icons/export.png \ + src/qt/res/icons/overview.png \ + src/qt/res/icons/tx_mined.png \ + src/qt/res/icons/transaction0.png \ + src/qt/res/icons/clock1.png \ + src/qt/res/icons/clock2.png \ + src/qt/res/icons/clock3.png \ + src/qt/res/icons/clock4.png \ + src/qt/res/icons/transaction_conflicted.png \ + src/qt/res/icons/clock5.png \ + src/qt/res/icons/staking_off.png \ + src/qt/res/icons/editpaste.png \ + src/qt/res/icons/send.png \ + src/qt/res/icons/configure.png \ + src/qt/res/icons/update.png \ + src/qt/res/icons/history.png \ + src/qt/res/icons/quit.png \ + src/qt/res/icons/SONO-80.png \ + src/qt/res/icons/filesave.png \ + src/qt/res/icons/onion.png \ + src/qt/res/icons/staking_on.png \ + src/qt/res/icons/editcopy.png \ + src/qt/res/icons/worker.png \ + src/qt/res/icons/tx_output.png \ + src/qt/res/icons/SONO-16.png \ + src/qt/res/icons/add.png \ + src/qt/res/icons/transaction2.png \ + src/qt/res/icons/connect0_16.png \ + src/qt/res/icons/connect1_16.png \ + src/qt/res/icons/remove.png \ + src/qt/res/icons/lock_closed.png \ + src/qt/res/icons/connect2_16.png \ + src/qt/res/icons/debugwindow.png \ + src/qt/res/icons/connect3_16.png \ + src/qt/res/icons/connect4_16.png \ + src/qt/res/icons/tx_inout.png \ + src/qt/res/icons/qrcode.png \ + src/qt/res/icons/key.png \ + src/qt/res/icons/lock_open.png \ + src/qt/res/icons/edit.png \ + src/qt/res/icons/SONO-16.png \ + src/qt/res/icons/SONO-80.png \ + src/qt/res/icons/synced.png \ + src/qt/res/icons/address-book.png \ + src/qt/res/icons/onion-black.png \ + src/qt/res/icons/tx_input.png \ + src/qt/res/icons/receive.png \ + src/qt/res/icons/black/synced.png \ + src/qt/res/icons/black/tx_mined.png \ + src/qt/res/icons/black/tx_input.png \ + src/qt/res/icons/black/staking_on.png \ + src/qt/res/icons/black/connect0_16.png \ + src/qt/res/icons/black/connect1_16.png \ + src/qt/res/icons/black/tx_output.png \ + src/qt/res/icons/black/connect2_16.png \ + src/qt/res/icons/black/connect3_16.png \ + src/qt/res/icons/black/connect4_16.png \ + src/qt/res/icons/black/tx_inout.png \ + src/qt/res/icons/black/lock_closed.png \ + src/qt/res/icons/black/staking_off.png \ + src/qt/res/icons/black/lock_open.png + /usr/lib/x86_64-linux-gnu/qt5/bin/rcc -name bitcoin src/qt/bitcoin.qrc -o qrc_bitcoin.cpp + +compiler_moc_header_make_all: build/moc_bitcoingui.cpp build/moc_transactiontablemodel.cpp build/moc_addresstablemodel.cpp build/moc_optionsdialog.cpp build/moc_coincontroldialog.cpp build/moc_coincontroltreewidget.cpp build/moc_sendcoinsdialog.cpp build/moc_addressbookpage.cpp build/moc_clientcontrolpage.cpp build/moc_signverifymessagedialog.cpp build/moc_aboutdialog.cpp build/moc_editaddressdialog.cpp build/moc_bitcoinaddressvalidator.cpp build/moc_blockbrowser.cpp build/moc_clientmodel.cpp build/moc_guiutil.cpp build/moc_optionsmodel.cpp build/moc_monitoreddatamapper.cpp build/moc_trafficgraphwidget.cpp build/moc_transactiondesc.cpp build/moc_transactiondescdialog.cpp build/moc_bitcoinamountfield.cpp build/moc_transactionfilterproxy.cpp build/moc_transactionview.cpp build/moc_walletmodel.cpp build/moc_overviewpage.cpp build/moc_csvmodelwriter.cpp build/moc_sendcoinsentry.cpp build/moc_qvalidatedlineedit.cpp build/moc_bitcoinunits.cpp build/moc_qvaluecombobox.cpp build/moc_askpassphrasedialog.cpp build/moc_notificator.cpp build/moc_paymentserver.cpp build/moc_rpcconsole.cpp build/moc_darksendconfig.cpp build/moc_masternodemanager.cpp build/moc_addeditadrenalinenode.cpp build/moc_adrenalinenodeconfigdialog.cpp build/moc_qcustomplot.cpp build/moc_messagepage.cpp build/moc_messagemodel.cpp build/moc_sendmessagesdialog.cpp build/moc_sendmessagesentry.cpp build/moc_mrichtextedit.cpp build/moc_qvalidatedtextedit.cpp build/moc_txviewdelegate.cpp build/moc_rpcexecutor.cpp build/moc_sidetoolbar.cpp +compiler_moc_header_clean: + -$(DEL_FILE) build/moc_bitcoingui.cpp build/moc_transactiontablemodel.cpp build/moc_addresstablemodel.cpp build/moc_optionsdialog.cpp build/moc_coincontroldialog.cpp build/moc_coincontroltreewidget.cpp build/moc_sendcoinsdialog.cpp build/moc_addressbookpage.cpp build/moc_clientcontrolpage.cpp build/moc_signverifymessagedialog.cpp build/moc_aboutdialog.cpp build/moc_editaddressdialog.cpp build/moc_bitcoinaddressvalidator.cpp build/moc_blockbrowser.cpp build/moc_clientmodel.cpp build/moc_guiutil.cpp build/moc_optionsmodel.cpp build/moc_monitoreddatamapper.cpp build/moc_trafficgraphwidget.cpp build/moc_transactiondesc.cpp build/moc_transactiondescdialog.cpp build/moc_bitcoinamountfield.cpp build/moc_transactionfilterproxy.cpp build/moc_transactionview.cpp build/moc_walletmodel.cpp build/moc_overviewpage.cpp build/moc_csvmodelwriter.cpp build/moc_sendcoinsentry.cpp build/moc_qvalidatedlineedit.cpp build/moc_bitcoinunits.cpp build/moc_qvaluecombobox.cpp build/moc_askpassphrasedialog.cpp build/moc_notificator.cpp build/moc_paymentserver.cpp build/moc_rpcconsole.cpp build/moc_darksendconfig.cpp build/moc_masternodemanager.cpp build/moc_addeditadrenalinenode.cpp build/moc_adrenalinenodeconfigdialog.cpp build/moc_qcustomplot.cpp build/moc_messagepage.cpp build/moc_messagemodel.cpp build/moc_sendmessagesdialog.cpp build/moc_sendmessagesentry.cpp build/moc_mrichtextedit.cpp build/moc_qvalidatedtextedit.cpp build/moc_txviewdelegate.cpp build/moc_rpcexecutor.cpp build/moc_sidetoolbar.cpp +build/moc_bitcoingui.cpp: /usr/include/qt5/QtWidgets/QMainWindow \ + /usr/include/qt5/QtWidgets/qmainwindow.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/QSystemTrayIcon \ + /usr/include/qt5/QtWidgets/qsystemtrayicon.h \ + src/qt/bitcoingui.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/bitcoingui.h -o build/moc_bitcoingui.cpp + +build/moc_transactiontablemodel.cpp: /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/transactiontablemodel.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/transactiontablemodel.h -o build/moc_transactiontablemodel.cpp + +build/moc_addresstablemodel.cpp: /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/addresstablemodel.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/addresstablemodel.h -o build/moc_addresstablemodel.cpp + +build/moc_optionsdialog.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/optionsdialog.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/optionsdialog.h -o build/moc_optionsdialog.cpp + +build/moc_coincontroldialog.cpp: /usr/include/qt5/QtWidgets/QAbstractButton \ + /usr/include/qt5/QtWidgets/qabstractbutton.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtWidgets/QAction \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtWidgets/QMenu \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtCore/QPoint \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtWidgets/QTreeWidgetItem \ + /usr/include/qt5/QtWidgets/qtreewidget.h \ + /usr/include/qt5/QtWidgets/qtreeview.h \ + /usr/include/qt5/QtWidgets/qabstractitemview.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qtreewidgetitemiterator.h \ + src/qt/coincontroldialog.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/coincontroldialog.h -o build/moc_coincontroldialog.cpp + +build/moc_coincontroltreewidget.cpp: /usr/include/qt5/QtGui/QKeyEvent \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtWidgets/QTreeWidget \ + /usr/include/qt5/QtWidgets/qtreewidget.h \ + /usr/include/qt5/QtWidgets/qtreeview.h \ + /usr/include/qt5/QtWidgets/qabstractitemview.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qtreewidgetitemiterator.h \ + src/qt/coincontroltreewidget.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/coincontroltreewidget.h -o build/moc_coincontroltreewidget.cpp + +build/moc_sendcoinsdialog.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QString \ + src/qt/sendcoinsdialog.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/sendcoinsdialog.h -o build/moc_sendcoinsdialog.cpp + +build/moc_addressbookpage.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/addressbookpage.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/addressbookpage.h -o build/moc_addressbookpage.cpp + +build/moc_clientcontrolpage.cpp: /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/clientcontrolpage.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/clientcontrolpage.h -o build/moc_clientcontrolpage.cpp + +build/moc_signverifymessagedialog.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/signverifymessagedialog.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/signverifymessagedialog.h -o build/moc_signverifymessagedialog.cpp + +build/moc_aboutdialog.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/aboutdialog.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/aboutdialog.h -o build/moc_aboutdialog.cpp + +build/moc_editaddressdialog.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/editaddressdialog.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/editaddressdialog.h -o build/moc_editaddressdialog.cpp + +build/moc_bitcoinaddressvalidator.cpp: /usr/include/qt5/QtGui/QValidator \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + src/qt/bitcoinaddressvalidator.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/bitcoinaddressvalidator.h -o build/moc_bitcoinaddressvalidator.cpp + +build/moc_blockbrowser.cpp: src/qt/clientmodel.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + src/qt/walletmodel.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QDir \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtCore/QFile \ + /usr/include/qt5/QtCore/QProcess \ + /usr/include/qt5/QtCore/qprocess.h \ + /usr/include/qt5/QtCore/QTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/QMap \ + /usr/include/qt5/QtCore/QSettings \ + /usr/include/qt5/QtCore/qsettings.h \ + /usr/include/qt5/QtWidgets/QSlider \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + src/qt/blockbrowser.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/blockbrowser.h -o build/moc_blockbrowser.cpp + +build/moc_clientmodel.cpp: /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + src/qt/clientmodel.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/clientmodel.h -o build/moc_clientmodel.cpp + +build/moc_guiutil.cpp: /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/guiutil.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/guiutil.h -o build/moc_guiutil.cpp + +build/moc_optionsmodel.cpp: /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + src/qt/optionsmodel.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/optionsmodel.h -o build/moc_optionsmodel.cpp + +build/moc_monitoreddatamapper.cpp: /usr/include/qt5/QtWidgets/QDataWidgetMapper \ + /usr/include/qt5/QtWidgets/qdatawidgetmapper.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + src/qt/monitoreddatamapper.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/monitoreddatamapper.h -o build/moc_monitoreddatamapper.cpp + +build/moc_trafficgraphwidget.cpp: /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QQueue \ + /usr/include/qt5/QtCore/qqueue.h \ + src/qt/trafficgraphwidget.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/trafficgraphwidget.h -o build/moc_trafficgraphwidget.cpp + +build/moc_transactiondesc.cpp: /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + src/qt/transactiondesc.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/transactiondesc.h -o build/moc_transactiondesc.cpp + +build/moc_transactiondescdialog.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/transactiondescdialog.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/transactiondescdialog.h -o build/moc_transactiondescdialog.cpp + +build/moc_bitcoinamountfield.cpp: /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/bitcoinamountfield.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/bitcoinamountfield.h -o build/moc_bitcoinamountfield.cpp + +build/moc_transactionfilterproxy.cpp: /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + src/qt/transactionfilterproxy.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/transactionfilterproxy.h -o build/moc_transactionfilterproxy.cpp + +build/moc_transactionview.cpp: /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/transactionview.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/transactionview.h -o build/moc_transactionview.cpp + +build/moc_walletmodel.cpp: /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/walletmodel.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/walletmodel.h -o build/moc_walletmodel.cpp + +build/moc_overviewpage.cpp: /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + src/qt/overviewpage.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/overviewpage.h -o build/moc_overviewpage.cpp + +build/moc_csvmodelwriter.cpp: /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/QList \ + src/qt/csvmodelwriter.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/csvmodelwriter.h -o build/moc_csvmodelwriter.cpp + +build/moc_sendcoinsentry.cpp: /usr/include/qt5/QtWidgets/QFrame \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/sendcoinsentry.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/sendcoinsentry.h -o build/moc_sendcoinsentry.cpp + +build/moc_qvalidatedlineedit.cpp: /usr/include/qt5/QtWidgets/QLineEdit \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + src/qt/qvalidatedlineedit.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/qvalidatedlineedit.h -o build/moc_qvalidatedlineedit.cpp + +build/moc_bitcoinunits.cpp: /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + src/qt/bitcoinunits.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/bitcoinunits.h -o build/moc_bitcoinunits.cpp + +build/moc_qvaluecombobox.cpp: /usr/include/qt5/QtWidgets/QComboBox \ + /usr/include/qt5/QtWidgets/qcombobox.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QVariant \ + src/qt/qvaluecombobox.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/qvaluecombobox.h -o build/moc_qvaluecombobox.cpp + +build/moc_askpassphrasedialog.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/askpassphrasedialog.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/askpassphrasedialog.h -o build/moc_askpassphrasedialog.cpp + +build/moc_notificator.cpp: /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtGui/QIcon \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + src/qt/notificator.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/notificator.h -o build/moc_notificator.cpp + +build/moc_paymentserver.cpp: /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/QString \ + src/qt/paymentserver.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/paymentserver.h -o build/moc_paymentserver.cpp + +build/moc_rpcconsole.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/rpcconsole.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/rpcconsole.h -o build/moc_rpcconsole.cpp + +build/moc_darksendconfig.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/darksendconfig.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/darksendconfig.h -o build/moc_darksendconfig.cpp + +build/moc_masternodemanager.cpp: src/util.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/tinyformat.h \ + src/sync.h \ + src/threadsafety.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/QFuture \ + /usr/include/qt5/QtCore/qfuture.h \ + /usr/include/qt5/QtCore/qfutureinterface.h \ + /usr/include/qt5/QtCore/qrunnable.h \ + /usr/include/qt5/QtCore/qexception.h \ + /usr/include/qt5/QtCore/qresultstore.h \ + src/qt/masternodemanager.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/masternodemanager.h -o build/moc_masternodemanager.cpp + +build/moc_addeditadrenalinenode.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/addeditadrenalinenode.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/addeditadrenalinenode.h -o build/moc_addeditadrenalinenode.cpp + +build/moc_adrenalinenodeconfigdialog.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/adrenalinenodeconfigdialog.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/adrenalinenodeconfigdialog.h -o build/moc_adrenalinenodeconfigdialog.cpp + +build/moc_qcustomplot.cpp: /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/QPointer \ + /usr/include/qt5/QtCore/qpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/QPainter \ + /usr/include/qt5/QtGui/qpainter.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/QPaintEvent \ + /usr/include/qt5/QtGui/QMouseEvent \ + /usr/include/qt5/QtGui/QPixmap \ + /usr/include/qt5/QtCore/QVector \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/QMultiMap \ + /usr/include/qt5/QtCore/QFlags \ + /usr/include/qt5/QtCore/QDebug \ + /usr/include/qt5/QtGui/QVector2D \ + /usr/include/qt5/QtCore/QStack \ + /usr/include/qt5/QtCore/qstack.h \ + /usr/include/qt5/QtCore/QCache \ + /usr/include/qt5/QtCore/qcache.h \ + /usr/include/qt5/QtCore/QMargins \ + /usr/include/qt5/QtCore/qmath.h \ + /usr/include/qt5/QtCore/qnumeric.h \ + /usr/include/qt5/QtPrintSupport/QPrinter \ + /usr/include/qt5/QtPrintSupport/qprinter.h \ + /usr/include/qt5/QtGui/qpagedpaintdevice.h \ + /usr/include/qt5/QtPrintSupport/qtprintsupportglobal.h \ + /usr/include/qt5/QtPrintSupport/QPrintEngine \ + /usr/include/qt5/QtPrintSupport/qprintengine.h \ + /usr/include/qt5/QtCore/QtNumeric \ + /usr/include/qt5/QtPrintSupport/QtPrintSupport \ + /usr/include/qt5/QtPrintSupport/QtPrintSupportDepends \ + /usr/include/qt5/QtCore/QtCore \ + /usr/include/qt5/QtCore/QtCoreDepends \ + /usr/include/qt5/QtCore/qabstractanimation.h \ + /usr/include/qt5/QtCore/qanimationgroup.h \ + /usr/include/qt5/QtCore/qparallelanimationgroup.h \ + /usr/include/qt5/QtCore/qpauseanimation.h \ + /usr/include/qt5/QtCore/qpropertyanimation.h \ + /usr/include/qt5/QtCore/qvariantanimation.h \ + /usr/include/qt5/QtCore/qeasingcurve.h \ + /usr/include/qt5/QtCore/qsequentialanimationgroup.h \ + /usr/include/qt5/QtCore/qtextcodec.h \ + /usr/include/qt5/QtCore/qendian.h \ + /usr/include/qt5/QtCore/qlibraryinfo.h \ + /usr/include/qt5/QtCore/qbuffer.h \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtCore/qdiriterator.h \ + /usr/include/qt5/QtCore/qfileselector.h \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/qfilesystemwatcher.h \ + /usr/include/qt5/QtCore/qlockfile.h \ + /usr/include/qt5/QtCore/qloggingcategory.h \ + /usr/include/qt5/QtCore/qprocess.h \ + /usr/include/qt5/QtCore/qresource.h \ + /usr/include/qt5/QtCore/qsavefile.h \ + /usr/include/qt5/QtCore/qsettings.h \ + /usr/include/qt5/QtCore/qstandardpaths.h \ + /usr/include/qt5/QtCore/qtemporarydir.h \ + /usr/include/qt5/QtCore/QScopedPointer \ + /usr/include/qt5/QtCore/qtemporaryfile.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qidentityproxymodel.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qstringlistmodel.h \ + /usr/include/qt5/QtCore/qjsonarray.h \ + /usr/include/qt5/QtCore/qjsonvalue.h \ + /usr/include/qt5/QtCore/qjsondocument.h \ + /usr/include/qt5/QtCore/qjsonobject.h \ + /usr/include/qt5/QtCore/qabstracteventdispatcher.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtCore/qabstractnativeeventfilter.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qmetaobject.h \ + /usr/include/qt5/QtCore/qmimedata.h \ + /usr/include/qt5/QtCore/qobjectcleanuphandler.h \ + /usr/include/qt5/QtCore/qsharedmemory.h \ + /usr/include/qt5/QtCore/qsignalmapper.h \ + /usr/include/qt5/QtCore/qsocketnotifier.h \ + /usr/include/qt5/QtCore/qsystemsemaphore.h \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qtranslator.h \ + /usr/include/qt5/QtCore/qwineventnotifier.h \ + /usr/include/qt5/QtCore/qmimedatabase.h \ + /usr/include/qt5/QtCore/qmimetype.h \ + /usr/include/qt5/QtCore/qfactoryinterface.h \ + /usr/include/qt5/QtCore/qlibrary.h \ + /usr/include/qt5/QtCore/qplugin.h \ + /usr/include/qt5/QtCore/qpluginloader.h \ + /usr/include/qt5/QtCore/quuid.h \ + /usr/include/qt5/QtCore/qabstractstate.h \ + /usr/include/qt5/QtCore/qabstracttransition.h \ + /usr/include/qt5/QtCore/qeventtransition.h \ + /usr/include/qt5/QtCore/qfinalstate.h \ + /usr/include/qt5/QtCore/qhistorystate.h \ + /usr/include/qt5/QtCore/qsignaltransition.h \ + /usr/include/qt5/QtCore/qstate.h \ + /usr/include/qt5/QtCore/qstatemachine.h \ + /usr/include/qt5/QtCore/qexception.h \ + /usr/include/qt5/QtCore/qfuture.h \ + /usr/include/qt5/QtCore/qfutureinterface.h \ + /usr/include/qt5/QtCore/qrunnable.h \ + /usr/include/qt5/QtCore/qresultstore.h \ + /usr/include/qt5/QtCore/qfuturesynchronizer.h \ + /usr/include/qt5/QtCore/qfuturewatcher.h \ + /usr/include/qt5/QtCore/qreadwritelock.h \ + /usr/include/qt5/QtCore/qsemaphore.h \ + /usr/include/qt5/QtCore/qthread.h \ + /usr/include/qt5/QtCore/qthreadpool.h \ + /usr/include/qt5/QtCore/qthreadstorage.h \ + /usr/include/qt5/QtCore/qwaitcondition.h \ + /usr/include/qt5/QtCore/qarraydataops.h \ + /usr/include/qt5/QtCore/qarraydatapointer.h \ + /usr/include/qt5/QtCore/qbitarray.h \ + /usr/include/qt5/QtCore/qbytearraymatcher.h \ + /usr/include/qt5/QtCore/qcollator.h \ + /usr/include/qt5/QtCore/qcommandlineoption.h \ + /usr/include/qt5/QtCore/qcommandlineparser.h \ + /usr/include/qt5/QtCore/qcryptographichash.h \ + /usr/include/qt5/QtCore/qelapsedtimer.h \ + /usr/include/qt5/QtCore/qlinkedlist.h \ + /usr/include/qt5/QtCore/qmessageauthenticationcode.h \ + /usr/include/qt5/QtCore/qqueue.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtCore/qscopedvaluerollback.h \ + /usr/include/qt5/QtCore/qtextboundaryfinder.h \ + /usr/include/qt5/QtCore/qtimeline.h \ + /usr/include/qt5/QtCore/qtimezone.h \ + /usr/include/qt5/QtCore/qxmlstream.h \ + /usr/include/qt5/QtCore/qtcoreversion.h \ + /usr/include/qt5/QtGui/QtGui \ + /usr/include/qt5/QtGui/QtGuiDepends \ + /usr/include/qt5/QtGui/qaccessible.h \ + /usr/include/qt5/QtGui/qaccessiblebridge.h \ + /usr/include/qt5/QtGui/qaccessibleobject.h \ + /usr/include/qt5/QtGui/qaccessibleplugin.h \ + /usr/include/qt5/QtGui/qbitmap.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtGui/qiconengine.h \ + /usr/include/qt5/QtGui/qiconengineplugin.h \ + /usr/include/qt5/QtGui/qimageiohandler.h \ + /usr/include/qt5/QtGui/qimagereader.h \ + /usr/include/qt5/QtGui/qimagewriter.h \ + /usr/include/qt5/QtGui/qmovie.h \ + /usr/include/qt5/QtGui/qpicture.h \ + /usr/include/qt5/QtGui/qpictureformatplugin.h \ + /usr/include/qt5/QtGui/qpixmapcache.h \ + /usr/include/qt5/QtGui/qstandarditemmodel.h \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtGui/qdrag.h \ + /usr/include/qt5/QtGui/qgenericplugin.h \ + /usr/include/qt5/QtGui/qgenericpluginfactory.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + /usr/include/qt5/QtGui/qoffscreensurface.h \ + /usr/include/qt5/QtGui/qsurface.h \ + /usr/include/qt5/QtGui/qsurfaceformat.h \ + /usr/include/qt5/QtGui/qopenglcontext.h \ + /usr/include/qt5/QtGui/QSurfaceFormat \ + /usr/include/qt5/QtGui/qopengl.h \ + /usr/include/qt5/QtCore/qt_windows.h \ + /usr/include/qt5/QtGui/qopengles2ext.h \ + /usr/include/qt5/QtGui/qopenglext.h \ + /usr/include/qt5/QtGui/qopenglversionfunctions.h \ + /usr/include/qt5/QtGui/qscreen.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtCore/QRect \ + /usr/include/qt5/QtCore/QSize \ + /usr/include/qt5/QtCore/QSizeF \ + /usr/include/qt5/QtGui/QTransform \ + /usr/include/qt5/QtGui/qsessionmanager.h \ + /usr/include/qt5/QtGui/qstylehints.h \ + /usr/include/qt5/QtGui/qwindow.h \ + /usr/include/qt5/QtCore/QEvent \ + /usr/include/qt5/QtGui/qgenericmatrix.h \ + /usr/include/qt5/QtGui/qmatrix4x4.h \ + /usr/include/qt5/QtGui/qvector3d.h \ + /usr/include/qt5/QtGui/qvector4d.h \ + /usr/include/qt5/QtGui/qquaternion.h \ + /usr/include/qt5/QtGui/qopenglbuffer.h \ + /usr/include/qt5/QtGui/qopengldebug.h \ + /usr/include/qt5/QtGui/qopenglframebufferobject.h \ + /usr/include/qt5/QtGui/qopenglfunctions.h \ + /usr/include/qt5/QtGui/qopenglpaintdevice.h \ + /usr/include/qt5/QtGui/qopenglpixeltransferoptions.h \ + /usr/include/qt5/QtCore/QSharedDataPointer \ + /usr/include/qt5/QtGui/qopenglshaderprogram.h \ + /usr/include/qt5/QtGui/qopengltexture.h \ + /usr/include/qt5/QtGui/qopengltimerquery.h \ + /usr/include/qt5/QtGui/qopenglvertexarrayobject.h \ + /usr/include/qt5/QtGui/qbackingstore.h \ + /usr/include/qt5/QtGui/qpaintengine.h \ + /usr/include/qt5/QtGui/qpdfwriter.h \ + /usr/include/qt5/QtGui/qabstracttextdocumentlayout.h \ + /usr/include/qt5/QtGui/qtextlayout.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qglyphrun.h \ + /usr/include/qt5/QtGui/qrawfont.h \ + /usr/include/qt5/QtGui/qfontdatabase.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextdocument.h \ + /usr/include/qt5/QtGui/qstatictext.h \ + /usr/include/qt5/QtGui/qsyntaxhighlighter.h \ + /usr/include/qt5/QtGui/qtextobject.h \ + /usr/include/qt5/QtGui/qtextdocumentfragment.h \ + /usr/include/qt5/QtGui/qtextdocumentwriter.h \ + /usr/include/qt5/QtGui/qtextlist.h \ + /usr/include/qt5/QtGui/qtexttable.h \ + /usr/include/qt5/QtGui/qdesktopservices.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtGui/qtguiversion.h \ + /usr/include/qt5/QtWidgets/QtWidgets \ + /usr/include/qt5/QtWidgets/QtWidgetsDepends \ + /usr/include/qt5/QtWidgets/qaccessiblewidget.h \ + /usr/include/qt5/QtWidgets/qcolordialog.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qerrormessage.h \ + /usr/include/qt5/QtWidgets/qfiledialog.h \ + /usr/include/qt5/QtWidgets/qfilesystemmodel.h \ + /usr/include/qt5/QtWidgets/qfontdialog.h \ + /usr/include/qt5/QtWidgets/qinputdialog.h \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qprogressdialog.h \ + /usr/include/qt5/QtWidgets/qwizard.h \ + /usr/include/qt5/QtWidgets/qgraphicseffect.h \ + /usr/include/qt5/QtWidgets/qgraphicsanchorlayout.h \ + /usr/include/qt5/QtWidgets/qgraphicsitem.h \ + /usr/include/qt5/QtWidgets/qgraphicslayout.h \ + /usr/include/qt5/QtWidgets/qgraphicslayoutitem.h \ + /usr/include/qt5/QtWidgets/qgraphicsgridlayout.h \ + /usr/include/qt5/QtWidgets/qgraphicsitemanimation.h \ + /usr/include/qt5/QtWidgets/qgraphicslinearlayout.h \ + /usr/include/qt5/QtWidgets/qgraphicsproxywidget.h \ + /usr/include/qt5/QtWidgets/qgraphicswidget.h \ + /usr/include/qt5/QtWidgets/qgraphicsscene.h \ + /usr/include/qt5/QtWidgets/qgraphicssceneevent.h \ + /usr/include/qt5/QtWidgets/qgraphicstransform.h \ + /usr/include/qt5/QtGui/QVector3D \ + /usr/include/qt5/QtGui/QMatrix4x4 \ + /usr/include/qt5/QtWidgets/qgraphicsview.h \ + /usr/include/qt5/QtWidgets/qscrollarea.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qabstractitemview.h \ + /usr/include/qt5/QtWidgets/qcolumnview.h \ + /usr/include/qt5/QtWidgets/qdatawidgetmapper.h \ + /usr/include/qt5/QtWidgets/qdirmodel.h \ + /usr/include/qt5/QtWidgets/qfileiconprovider.h \ + /usr/include/qt5/QtWidgets/qheaderview.h \ + /usr/include/qt5/QtWidgets/qitemdelegate.h \ + /usr/include/qt5/QtWidgets/qitemeditorfactory.h \ + /usr/include/qt5/QtWidgets/qlistview.h \ + /usr/include/qt5/QtWidgets/qlistwidget.h \ + /usr/include/qt5/QtWidgets/qstyleditemdelegate.h \ + /usr/include/qt5/QtWidgets/qtableview.h \ + /usr/include/qt5/QtWidgets/qtablewidget.h \ + /usr/include/qt5/QtWidgets/qtreeview.h \ + /usr/include/qt5/QtWidgets/qtreewidget.h \ + /usr/include/qt5/QtWidgets/qtreewidgetitemiterator.h \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtWidgets/qboxlayout.h \ + /usr/include/qt5/QtWidgets/qlayout.h \ + /usr/include/qt5/QtWidgets/qlayoutitem.h \ + /usr/include/qt5/QtWidgets/qgridlayout.h \ + /usr/include/qt5/QtWidgets/qformlayout.h \ + /usr/include/qt5/QtWidgets/QLayout \ + /usr/include/qt5/QtWidgets/qgesture.h \ + /usr/include/qt5/QtWidgets/qgesturerecognizer.h \ + /usr/include/qt5/QtWidgets/qshortcut.h \ + /usr/include/qt5/QtWidgets/qstackedlayout.h \ + /usr/include/qt5/QtWidgets/qtooltip.h \ + /usr/include/qt5/QtWidgets/qwhatsthis.h \ + /usr/include/qt5/QtWidgets/qwidgetaction.h \ + /usr/include/qt5/QtWidgets/qkeyeventtransition.h \ + /usr/include/qt5/QtWidgets/qmouseeventtransition.h \ + /usr/include/qt5/QtWidgets/qcommonstyle.h \ + /usr/include/qt5/QtWidgets/qdrawutil.h \ + /usr/include/qt5/QtWidgets/qproxystyle.h \ + /usr/include/qt5/QtWidgets/QCommonStyle \ + /usr/include/qt5/QtWidgets/qstylefactory.h \ + /usr/include/qt5/QtWidgets/qstylepainter.h \ + /usr/include/qt5/QtWidgets/qstyleplugin.h \ + /usr/include/qt5/QtWidgets/qcolormap.h \ + /usr/include/qt5/QtWidgets/qcompleter.h \ + /usr/include/qt5/QtWidgets/qscroller.h \ + /usr/include/qt5/QtCore/QPointF \ + /usr/include/qt5/QtWidgets/QScrollerProperties \ + /usr/include/qt5/QtWidgets/qscrollerproperties.h \ + /usr/include/qt5/QtCore/QMetaType \ + /usr/include/qt5/QtCore/QVariant \ + /usr/include/qt5/QtWidgets/qsystemtrayicon.h \ + /usr/include/qt5/QtWidgets/qundogroup.h \ + /usr/include/qt5/QtWidgets/qundostack.h \ + /usr/include/qt5/QtWidgets/qundoview.h \ + /usr/include/qt5/QtWidgets/qabstractbutton.h \ + /usr/include/qt5/QtWidgets/qbuttongroup.h \ + /usr/include/qt5/QtWidgets/qcalendarwidget.h \ + /usr/include/qt5/QtWidgets/qcheckbox.h \ + /usr/include/qt5/QtWidgets/qcombobox.h \ + /usr/include/qt5/QtWidgets/qcommandlinkbutton.h \ + /usr/include/qt5/QtWidgets/qpushbutton.h \ + /usr/include/qt5/QtWidgets/qdatetimeedit.h \ + /usr/include/qt5/QtWidgets/qdial.h \ + /usr/include/qt5/QtWidgets/qdialogbuttonbox.h \ + /usr/include/qt5/QtWidgets/qdockwidget.h \ + /usr/include/qt5/QtWidgets/qfocusframe.h \ + /usr/include/qt5/QtWidgets/qfontcombobox.h \ + /usr/include/qt5/QtWidgets/qgroupbox.h \ + /usr/include/qt5/QtWidgets/qkeysequenceedit.h \ + /usr/include/qt5/QtWidgets/qlabel.h \ + /usr/include/qt5/QtWidgets/qlcdnumber.h \ + /usr/include/qt5/QtWidgets/qmainwindow.h \ + /usr/include/qt5/QtWidgets/qmdiarea.h \ + /usr/include/qt5/QtWidgets/qmdisubwindow.h \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtWidgets/qmenubar.h \ + /usr/include/qt5/QtWidgets/qplaintextedit.h \ + /usr/include/qt5/QtWidgets/qtextedit.h \ + /usr/include/qt5/QtWidgets/qprogressbar.h \ + /usr/include/qt5/QtWidgets/qradiobutton.h \ + /usr/include/qt5/QtWidgets/qscrollbar.h \ + /usr/include/qt5/QtWidgets/qsizegrip.h \ + /usr/include/qt5/QtWidgets/qspinbox.h \ + /usr/include/qt5/QtWidgets/qsplashscreen.h \ + /usr/include/qt5/QtWidgets/qsplitter.h \ + /usr/include/qt5/QtWidgets/qstackedwidget.h \ + /usr/include/qt5/QtWidgets/qstatusbar.h \ + /usr/include/qt5/QtWidgets/qtextbrowser.h \ + /usr/include/qt5/QtWidgets/qtoolbar.h \ + /usr/include/qt5/QtWidgets/qtoolbox.h \ + /usr/include/qt5/QtWidgets/qtoolbutton.h \ + /usr/include/qt5/QtWidgets/qtwidgetsversion.h \ + /usr/include/qt5/QtPrintSupport/qabstractprintdialog.h \ + /usr/include/qt5/QtPrintSupport/qpagesetupdialog.h \ + /usr/include/qt5/QtPrintSupport/qprintdialog.h \ + /usr/include/qt5/QtPrintSupport/qprintpreviewdialog.h \ + /usr/include/qt5/QtPrintSupport/qprinterinfo.h \ + /usr/include/qt5/QtCore/QPair \ + /usr/include/qt5/QtPrintSupport/qprintpreviewwidget.h \ + /usr/include/qt5/QtPrintSupport/qtprintsupportversion.h \ + src/qt/qcustomplot.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/qcustomplot.h -o build/moc_qcustomplot.cpp + +build/moc_messagepage.cpp: /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/messagepage.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/messagepage.h -o build/moc_messagepage.cpp + +build/moc_messagemodel.cpp: src/uint256.h \ + src/allocators.h \ + src/smessage.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/sync.h \ + src/threadsafety.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/db.h \ + src/wallet.h \ + src/walletdb.h \ + src/crypter.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/lz4/lz4.h \ + src/base58.h \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + src/qt/messagemodel.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/messagemodel.h -o build/moc_messagemodel.cpp + +build/moc_sendmessagesdialog.cpp: /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QString \ + src/qt/sendmessagesdialog.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/sendmessagesdialog.h -o build/moc_sendmessagesdialog.cpp + +build/moc_sendmessagesentry.cpp: /usr/include/qt5/QtWidgets/QFrame \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/sendmessagesentry.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/sendmessagesentry.h -o build/moc_sendmessagesentry.cpp + +build/moc_mrichtextedit.cpp: /usr/include/qt5/QtCore/QPointer \ + /usr/include/qt5/QtCore/qpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qpair.h \ + build/ui_mrichtextedit.h \ + src/qt/plugins/mrichtexteditor/mrichtextedit.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/plugins/mrichtexteditor/mrichtextedit.h -o build/moc_mrichtextedit.cpp + +build/moc_qvalidatedtextedit.cpp: /usr/include/qt5/QtWidgets/QPlainTextEdit \ + /usr/include/qt5/QtWidgets/qplaintextedit.h \ + /usr/include/qt5/QtWidgets/qtextedit.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qtextdocument.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qabstracttextdocumentlayout.h \ + /usr/include/qt5/QtGui/qtextlayout.h \ + /usr/include/qt5/QtGui/qglyphrun.h \ + /usr/include/qt5/QtGui/qrawfont.h \ + /usr/include/qt5/QtGui/qfontdatabase.h \ + src/qt/qvalidatedtextedit.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/qvalidatedtextedit.h -o build/moc_qvalidatedtextedit.cpp + +build/moc_txviewdelegate.cpp: src/qt/guiconstants.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + src/qt/transactiontablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtWidgets/QAbstractItemDelegate \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtGui/QPainter \ + /usr/include/qt5/QtGui/qpainter.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + src/qt/txviewdelegate.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/txviewdelegate.h -o build/moc_txviewdelegate.cpp + +build/moc_rpcexecutor.cpp: /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/QString \ + src/qt/rpcexecutor.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/rpcexecutor.h -o build/moc_rpcexecutor.cpp + +build/moc_sidetoolbar.cpp: /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/forms/sidetoolbar.h + /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/usr/include/c++/4.8/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include src/qt/forms/sidetoolbar.h -o build/moc_sidetoolbar.cpp + +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: build/ui_coincontroldialog.h build/ui_sendcoinsdialog.h build/ui_addressbookpage.h build/ui_signverifymessagedialog.h build/ui_aboutdialog.h build/ui_editaddressdialog.h build/ui_transactiondescdialog.h build/ui_overviewpage.h build/ui_clientcontrolpage.h build/ui_sendcoinsentry.h build/ui_askpassphrasedialog.h build/ui_blockbrowser.h build/ui_rpcconsole.h build/ui_optionsdialog.h build/ui_darksendconfig.h build/ui_masternodemanager.h build/ui_addeditadrenalinenode.h build/ui_adrenalinenodeconfigdialog.h build/ui_messagepage.h build/ui_sendmessagesentry.h build/ui_sendmessagesdialog.h build/ui_mrichtextedit.h build/ui_sidetoolbar.h +compiler_uic_clean: + -$(DEL_FILE) build/ui_coincontroldialog.h build/ui_sendcoinsdialog.h build/ui_addressbookpage.h build/ui_signverifymessagedialog.h build/ui_aboutdialog.h build/ui_editaddressdialog.h build/ui_transactiondescdialog.h build/ui_overviewpage.h build/ui_clientcontrolpage.h build/ui_sendcoinsentry.h build/ui_askpassphrasedialog.h build/ui_blockbrowser.h build/ui_rpcconsole.h build/ui_optionsdialog.h build/ui_darksendconfig.h build/ui_masternodemanager.h build/ui_addeditadrenalinenode.h build/ui_adrenalinenodeconfigdialog.h build/ui_messagepage.h build/ui_sendmessagesentry.h build/ui_sendmessagesdialog.h build/ui_mrichtextedit.h build/ui_sidetoolbar.h +build/ui_coincontroldialog.h: src/qt/forms/coincontroldialog.ui \ + src/qt/coincontroltreewidget.h \ + /usr/include/qt5/QtGui/QKeyEvent \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtWidgets/QTreeWidget \ + /usr/include/qt5/QtWidgets/qtreewidget.h \ + /usr/include/qt5/QtWidgets/qtreeview.h \ + /usr/include/qt5/QtWidgets/qabstractitemview.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qtreewidgetitemiterator.h + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/coincontroldialog.ui -o build/ui_coincontroldialog.h + +build/ui_sendcoinsdialog.h: src/qt/forms/sendcoinsdialog.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/sendcoinsdialog.ui -o build/ui_sendcoinsdialog.h + +build/ui_addressbookpage.h: src/qt/forms/addressbookpage.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/addressbookpage.ui -o build/ui_addressbookpage.h + +build/ui_signverifymessagedialog.h: src/qt/forms/signverifymessagedialog.ui \ + src/qt/qvalidatedlineedit.h \ + /usr/include/qt5/QtWidgets/QLineEdit \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qtextoption.h + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/signverifymessagedialog.ui -o build/ui_signverifymessagedialog.h + +build/ui_aboutdialog.h: src/qt/forms/aboutdialog.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/aboutdialog.ui -o build/ui_aboutdialog.h + +build/ui_editaddressdialog.h: src/qt/forms/editaddressdialog.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/editaddressdialog.ui -o build/ui_editaddressdialog.h + +build/ui_transactiondescdialog.h: src/qt/forms/transactiondescdialog.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/transactiondescdialog.ui -o build/ui_transactiondescdialog.h + +build/ui_overviewpage.h: src/qt/forms/overviewpage.ui \ + src/qt/qcustomplot.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/QPointer \ + /usr/include/qt5/QtCore/qpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/QPainter \ + /usr/include/qt5/QtGui/qpainter.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/QPaintEvent \ + /usr/include/qt5/QtGui/QMouseEvent \ + /usr/include/qt5/QtGui/QPixmap \ + /usr/include/qt5/QtCore/QVector \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/QMultiMap \ + /usr/include/qt5/QtCore/QFlags \ + /usr/include/qt5/QtCore/QDebug \ + /usr/include/qt5/QtGui/QVector2D \ + /usr/include/qt5/QtCore/QStack \ + /usr/include/qt5/QtCore/qstack.h \ + /usr/include/qt5/QtCore/QCache \ + /usr/include/qt5/QtCore/qcache.h \ + /usr/include/qt5/QtCore/QMargins \ + /usr/include/qt5/QtCore/qmath.h \ + /usr/include/qt5/QtCore/qnumeric.h \ + /usr/include/qt5/QtPrintSupport/QPrinter \ + /usr/include/qt5/QtPrintSupport/qprinter.h \ + /usr/include/qt5/QtGui/qpagedpaintdevice.h \ + /usr/include/qt5/QtPrintSupport/qtprintsupportglobal.h \ + /usr/include/qt5/QtPrintSupport/QPrintEngine \ + /usr/include/qt5/QtPrintSupport/qprintengine.h \ + /usr/include/qt5/QtCore/QtNumeric \ + /usr/include/qt5/QtPrintSupport/QtPrintSupport \ + /usr/include/qt5/QtPrintSupport/QtPrintSupportDepends \ + /usr/include/qt5/QtCore/QtCore \ + /usr/include/qt5/QtCore/QtCoreDepends \ + /usr/include/qt5/QtCore/qabstractanimation.h \ + /usr/include/qt5/QtCore/qanimationgroup.h \ + /usr/include/qt5/QtCore/qparallelanimationgroup.h \ + /usr/include/qt5/QtCore/qpauseanimation.h \ + /usr/include/qt5/QtCore/qpropertyanimation.h \ + /usr/include/qt5/QtCore/qvariantanimation.h \ + /usr/include/qt5/QtCore/qeasingcurve.h \ + /usr/include/qt5/QtCore/qsequentialanimationgroup.h \ + /usr/include/qt5/QtCore/qtextcodec.h \ + /usr/include/qt5/QtCore/qendian.h \ + /usr/include/qt5/QtCore/qlibraryinfo.h \ + /usr/include/qt5/QtCore/qbuffer.h \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtCore/qdiriterator.h \ + /usr/include/qt5/QtCore/qfileselector.h \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/qfilesystemwatcher.h \ + /usr/include/qt5/QtCore/qlockfile.h \ + /usr/include/qt5/QtCore/qloggingcategory.h \ + /usr/include/qt5/QtCore/qprocess.h \ + /usr/include/qt5/QtCore/qresource.h \ + /usr/include/qt5/QtCore/qsavefile.h \ + /usr/include/qt5/QtCore/qsettings.h \ + /usr/include/qt5/QtCore/qstandardpaths.h \ + /usr/include/qt5/QtCore/qtemporarydir.h \ + /usr/include/qt5/QtCore/QScopedPointer \ + /usr/include/qt5/QtCore/qtemporaryfile.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qidentityproxymodel.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qstringlistmodel.h \ + /usr/include/qt5/QtCore/qjsonarray.h \ + /usr/include/qt5/QtCore/qjsonvalue.h \ + /usr/include/qt5/QtCore/qjsondocument.h \ + /usr/include/qt5/QtCore/qjsonobject.h \ + /usr/include/qt5/QtCore/qabstracteventdispatcher.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtCore/qabstractnativeeventfilter.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qmetaobject.h \ + /usr/include/qt5/QtCore/qmimedata.h \ + /usr/include/qt5/QtCore/qobjectcleanuphandler.h \ + /usr/include/qt5/QtCore/qsharedmemory.h \ + /usr/include/qt5/QtCore/qsignalmapper.h \ + /usr/include/qt5/QtCore/qsocketnotifier.h \ + /usr/include/qt5/QtCore/qsystemsemaphore.h \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qtranslator.h \ + /usr/include/qt5/QtCore/qwineventnotifier.h \ + /usr/include/qt5/QtCore/qmimedatabase.h \ + /usr/include/qt5/QtCore/qmimetype.h \ + /usr/include/qt5/QtCore/qfactoryinterface.h \ + /usr/include/qt5/QtCore/qlibrary.h \ + /usr/include/qt5/QtCore/qplugin.h \ + /usr/include/qt5/QtCore/qpluginloader.h \ + /usr/include/qt5/QtCore/quuid.h \ + /usr/include/qt5/QtCore/qabstractstate.h \ + /usr/include/qt5/QtCore/qabstracttransition.h \ + /usr/include/qt5/QtCore/qeventtransition.h \ + /usr/include/qt5/QtCore/qfinalstate.h \ + /usr/include/qt5/QtCore/qhistorystate.h \ + /usr/include/qt5/QtCore/qsignaltransition.h \ + /usr/include/qt5/QtCore/qstate.h \ + /usr/include/qt5/QtCore/qstatemachine.h \ + /usr/include/qt5/QtCore/qexception.h \ + /usr/include/qt5/QtCore/qfuture.h \ + /usr/include/qt5/QtCore/qfutureinterface.h \ + /usr/include/qt5/QtCore/qrunnable.h \ + /usr/include/qt5/QtCore/qresultstore.h \ + /usr/include/qt5/QtCore/qfuturesynchronizer.h \ + /usr/include/qt5/QtCore/qfuturewatcher.h \ + /usr/include/qt5/QtCore/qreadwritelock.h \ + /usr/include/qt5/QtCore/qsemaphore.h \ + /usr/include/qt5/QtCore/qthread.h \ + /usr/include/qt5/QtCore/qthreadpool.h \ + /usr/include/qt5/QtCore/qthreadstorage.h \ + /usr/include/qt5/QtCore/qwaitcondition.h \ + /usr/include/qt5/QtCore/qarraydataops.h \ + /usr/include/qt5/QtCore/qarraydatapointer.h \ + /usr/include/qt5/QtCore/qbitarray.h \ + /usr/include/qt5/QtCore/qbytearraymatcher.h \ + /usr/include/qt5/QtCore/qcollator.h \ + /usr/include/qt5/QtCore/qcommandlineoption.h \ + /usr/include/qt5/QtCore/qcommandlineparser.h \ + /usr/include/qt5/QtCore/qcryptographichash.h \ + /usr/include/qt5/QtCore/qelapsedtimer.h \ + /usr/include/qt5/QtCore/qlinkedlist.h \ + /usr/include/qt5/QtCore/qmessageauthenticationcode.h \ + /usr/include/qt5/QtCore/qqueue.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtCore/qscopedvaluerollback.h \ + /usr/include/qt5/QtCore/qtextboundaryfinder.h \ + /usr/include/qt5/QtCore/qtimeline.h \ + /usr/include/qt5/QtCore/qtimezone.h \ + /usr/include/qt5/QtCore/qxmlstream.h \ + /usr/include/qt5/QtCore/qtcoreversion.h \ + /usr/include/qt5/QtGui/QtGui \ + /usr/include/qt5/QtGui/QtGuiDepends \ + /usr/include/qt5/QtGui/qaccessible.h \ + /usr/include/qt5/QtGui/qaccessiblebridge.h \ + /usr/include/qt5/QtGui/qaccessibleobject.h \ + /usr/include/qt5/QtGui/qaccessibleplugin.h \ + /usr/include/qt5/QtGui/qbitmap.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtGui/qiconengine.h \ + /usr/include/qt5/QtGui/qiconengineplugin.h \ + /usr/include/qt5/QtGui/qimageiohandler.h \ + /usr/include/qt5/QtGui/qimagereader.h \ + /usr/include/qt5/QtGui/qimagewriter.h \ + /usr/include/qt5/QtGui/qmovie.h \ + /usr/include/qt5/QtGui/qpicture.h \ + /usr/include/qt5/QtGui/qpictureformatplugin.h \ + /usr/include/qt5/QtGui/qpixmapcache.h \ + /usr/include/qt5/QtGui/qstandarditemmodel.h \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtGui/qdrag.h \ + /usr/include/qt5/QtGui/qgenericplugin.h \ + /usr/include/qt5/QtGui/qgenericpluginfactory.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + /usr/include/qt5/QtGui/qoffscreensurface.h \ + /usr/include/qt5/QtGui/qsurface.h \ + /usr/include/qt5/QtGui/qsurfaceformat.h \ + /usr/include/qt5/QtGui/qopenglcontext.h \ + /usr/include/qt5/QtGui/QSurfaceFormat \ + /usr/include/qt5/QtGui/qopengl.h \ + /usr/include/qt5/QtCore/qt_windows.h \ + /usr/include/qt5/QtGui/qopengles2ext.h \ + /usr/include/qt5/QtGui/qopenglext.h \ + /usr/include/qt5/QtGui/qopenglversionfunctions.h \ + /usr/include/qt5/QtGui/qscreen.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtCore/QRect \ + /usr/include/qt5/QtCore/QSize \ + /usr/include/qt5/QtCore/QSizeF \ + /usr/include/qt5/QtGui/QTransform \ + /usr/include/qt5/QtGui/qsessionmanager.h \ + /usr/include/qt5/QtGui/qstylehints.h \ + /usr/include/qt5/QtGui/qwindow.h \ + /usr/include/qt5/QtCore/QEvent \ + /usr/include/qt5/QtGui/qgenericmatrix.h \ + /usr/include/qt5/QtGui/qmatrix4x4.h \ + /usr/include/qt5/QtGui/qvector3d.h \ + /usr/include/qt5/QtGui/qvector4d.h \ + /usr/include/qt5/QtGui/qquaternion.h \ + /usr/include/qt5/QtGui/qopenglbuffer.h \ + /usr/include/qt5/QtGui/qopengldebug.h \ + /usr/include/qt5/QtGui/qopenglframebufferobject.h \ + /usr/include/qt5/QtGui/qopenglfunctions.h \ + /usr/include/qt5/QtGui/qopenglpaintdevice.h \ + /usr/include/qt5/QtGui/qopenglpixeltransferoptions.h \ + /usr/include/qt5/QtCore/QSharedDataPointer \ + /usr/include/qt5/QtGui/qopenglshaderprogram.h \ + /usr/include/qt5/QtGui/qopengltexture.h \ + /usr/include/qt5/QtGui/qopengltimerquery.h \ + /usr/include/qt5/QtGui/qopenglvertexarrayobject.h \ + /usr/include/qt5/QtGui/qbackingstore.h \ + /usr/include/qt5/QtGui/qpaintengine.h \ + /usr/include/qt5/QtGui/qpdfwriter.h \ + /usr/include/qt5/QtGui/qabstracttextdocumentlayout.h \ + /usr/include/qt5/QtGui/qtextlayout.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qglyphrun.h \ + /usr/include/qt5/QtGui/qrawfont.h \ + /usr/include/qt5/QtGui/qfontdatabase.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextdocument.h \ + /usr/include/qt5/QtGui/qstatictext.h \ + /usr/include/qt5/QtGui/qsyntaxhighlighter.h \ + /usr/include/qt5/QtGui/qtextobject.h \ + /usr/include/qt5/QtGui/qtextdocumentfragment.h \ + /usr/include/qt5/QtGui/qtextdocumentwriter.h \ + /usr/include/qt5/QtGui/qtextlist.h \ + /usr/include/qt5/QtGui/qtexttable.h \ + /usr/include/qt5/QtGui/qdesktopservices.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtGui/qtguiversion.h \ + /usr/include/qt5/QtWidgets/QtWidgets \ + /usr/include/qt5/QtWidgets/QtWidgetsDepends \ + /usr/include/qt5/QtWidgets/qaccessiblewidget.h \ + /usr/include/qt5/QtWidgets/qcolordialog.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qerrormessage.h \ + /usr/include/qt5/QtWidgets/qfiledialog.h \ + /usr/include/qt5/QtWidgets/qfilesystemmodel.h \ + /usr/include/qt5/QtWidgets/qfontdialog.h \ + /usr/include/qt5/QtWidgets/qinputdialog.h \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qprogressdialog.h \ + /usr/include/qt5/QtWidgets/qwizard.h \ + /usr/include/qt5/QtWidgets/qgraphicseffect.h \ + /usr/include/qt5/QtWidgets/qgraphicsanchorlayout.h \ + /usr/include/qt5/QtWidgets/qgraphicsitem.h \ + /usr/include/qt5/QtWidgets/qgraphicslayout.h \ + /usr/include/qt5/QtWidgets/qgraphicslayoutitem.h \ + /usr/include/qt5/QtWidgets/qgraphicsgridlayout.h \ + /usr/include/qt5/QtWidgets/qgraphicsitemanimation.h \ + /usr/include/qt5/QtWidgets/qgraphicslinearlayout.h \ + /usr/include/qt5/QtWidgets/qgraphicsproxywidget.h \ + /usr/include/qt5/QtWidgets/qgraphicswidget.h \ + /usr/include/qt5/QtWidgets/qgraphicsscene.h \ + /usr/include/qt5/QtWidgets/qgraphicssceneevent.h \ + /usr/include/qt5/QtWidgets/qgraphicstransform.h \ + /usr/include/qt5/QtGui/QVector3D \ + /usr/include/qt5/QtGui/QMatrix4x4 \ + /usr/include/qt5/QtWidgets/qgraphicsview.h \ + /usr/include/qt5/QtWidgets/qscrollarea.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qabstractitemview.h \ + /usr/include/qt5/QtWidgets/qcolumnview.h \ + /usr/include/qt5/QtWidgets/qdatawidgetmapper.h \ + /usr/include/qt5/QtWidgets/qdirmodel.h \ + /usr/include/qt5/QtWidgets/qfileiconprovider.h \ + /usr/include/qt5/QtWidgets/qheaderview.h \ + /usr/include/qt5/QtWidgets/qitemdelegate.h \ + /usr/include/qt5/QtWidgets/qitemeditorfactory.h \ + /usr/include/qt5/QtWidgets/qlistview.h \ + /usr/include/qt5/QtWidgets/qlistwidget.h \ + /usr/include/qt5/QtWidgets/qstyleditemdelegate.h \ + /usr/include/qt5/QtWidgets/qtableview.h \ + /usr/include/qt5/QtWidgets/qtablewidget.h \ + /usr/include/qt5/QtWidgets/qtreeview.h \ + /usr/include/qt5/QtWidgets/qtreewidget.h \ + /usr/include/qt5/QtWidgets/qtreewidgetitemiterator.h \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtWidgets/qboxlayout.h \ + /usr/include/qt5/QtWidgets/qlayout.h \ + /usr/include/qt5/QtWidgets/qlayoutitem.h \ + /usr/include/qt5/QtWidgets/qgridlayout.h \ + /usr/include/qt5/QtWidgets/qformlayout.h \ + /usr/include/qt5/QtWidgets/QLayout \ + /usr/include/qt5/QtWidgets/qgesture.h \ + /usr/include/qt5/QtWidgets/qgesturerecognizer.h \ + /usr/include/qt5/QtWidgets/qshortcut.h \ + /usr/include/qt5/QtWidgets/qstackedlayout.h \ + /usr/include/qt5/QtWidgets/qtooltip.h \ + /usr/include/qt5/QtWidgets/qwhatsthis.h \ + /usr/include/qt5/QtWidgets/qwidgetaction.h \ + /usr/include/qt5/QtWidgets/qkeyeventtransition.h \ + /usr/include/qt5/QtWidgets/qmouseeventtransition.h \ + /usr/include/qt5/QtWidgets/qcommonstyle.h \ + /usr/include/qt5/QtWidgets/qdrawutil.h \ + /usr/include/qt5/QtWidgets/qproxystyle.h \ + /usr/include/qt5/QtWidgets/QCommonStyle \ + /usr/include/qt5/QtWidgets/qstylefactory.h \ + /usr/include/qt5/QtWidgets/qstylepainter.h \ + /usr/include/qt5/QtWidgets/qstyleplugin.h \ + /usr/include/qt5/QtWidgets/qcolormap.h \ + /usr/include/qt5/QtWidgets/qcompleter.h \ + /usr/include/qt5/QtWidgets/qscroller.h \ + /usr/include/qt5/QtCore/QPointF \ + /usr/include/qt5/QtWidgets/QScrollerProperties \ + /usr/include/qt5/QtWidgets/qscrollerproperties.h \ + /usr/include/qt5/QtCore/QMetaType \ + /usr/include/qt5/QtCore/QVariant \ + /usr/include/qt5/QtWidgets/qsystemtrayicon.h \ + /usr/include/qt5/QtWidgets/qundogroup.h \ + /usr/include/qt5/QtWidgets/qundostack.h \ + /usr/include/qt5/QtWidgets/qundoview.h \ + /usr/include/qt5/QtWidgets/qabstractbutton.h \ + /usr/include/qt5/QtWidgets/qbuttongroup.h \ + /usr/include/qt5/QtWidgets/qcalendarwidget.h \ + /usr/include/qt5/QtWidgets/qcheckbox.h \ + /usr/include/qt5/QtWidgets/qcombobox.h \ + /usr/include/qt5/QtWidgets/qcommandlinkbutton.h \ + /usr/include/qt5/QtWidgets/qpushbutton.h \ + /usr/include/qt5/QtWidgets/qdatetimeedit.h \ + /usr/include/qt5/QtWidgets/qdial.h \ + /usr/include/qt5/QtWidgets/qdialogbuttonbox.h \ + /usr/include/qt5/QtWidgets/qdockwidget.h \ + /usr/include/qt5/QtWidgets/qfocusframe.h \ + /usr/include/qt5/QtWidgets/qfontcombobox.h \ + /usr/include/qt5/QtWidgets/qgroupbox.h \ + /usr/include/qt5/QtWidgets/qkeysequenceedit.h \ + /usr/include/qt5/QtWidgets/qlabel.h \ + /usr/include/qt5/QtWidgets/qlcdnumber.h \ + /usr/include/qt5/QtWidgets/qmainwindow.h \ + /usr/include/qt5/QtWidgets/qmdiarea.h \ + /usr/include/qt5/QtWidgets/qmdisubwindow.h \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtWidgets/qmenubar.h \ + /usr/include/qt5/QtWidgets/qplaintextedit.h \ + /usr/include/qt5/QtWidgets/qtextedit.h \ + /usr/include/qt5/QtWidgets/qprogressbar.h \ + /usr/include/qt5/QtWidgets/qradiobutton.h \ + /usr/include/qt5/QtWidgets/qscrollbar.h \ + /usr/include/qt5/QtWidgets/qsizegrip.h \ + /usr/include/qt5/QtWidgets/qspinbox.h \ + /usr/include/qt5/QtWidgets/qsplashscreen.h \ + /usr/include/qt5/QtWidgets/qsplitter.h \ + /usr/include/qt5/QtWidgets/qstackedwidget.h \ + /usr/include/qt5/QtWidgets/qstatusbar.h \ + /usr/include/qt5/QtWidgets/qtextbrowser.h \ + /usr/include/qt5/QtWidgets/qtoolbar.h \ + /usr/include/qt5/QtWidgets/qtoolbox.h \ + /usr/include/qt5/QtWidgets/qtoolbutton.h \ + /usr/include/qt5/QtWidgets/qtwidgetsversion.h \ + /usr/include/qt5/QtPrintSupport/qabstractprintdialog.h \ + /usr/include/qt5/QtPrintSupport/qpagesetupdialog.h \ + /usr/include/qt5/QtPrintSupport/qprintdialog.h \ + /usr/include/qt5/QtPrintSupport/qprintpreviewdialog.h \ + /usr/include/qt5/QtPrintSupport/qprinterinfo.h \ + /usr/include/qt5/QtCore/QPair \ + /usr/include/qt5/QtPrintSupport/qprintpreviewwidget.h \ + /usr/include/qt5/QtPrintSupport/qtprintsupportversion.h + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/overviewpage.ui -o build/ui_overviewpage.h + +build/ui_clientcontrolpage.h: src/qt/forms/clientcontrolpage.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/clientcontrolpage.ui -o build/ui_clientcontrolpage.h + +build/ui_sendcoinsentry.h: src/qt/forms/sendcoinsentry.ui \ + src/qt/qvalidatedlineedit.h \ + src/qt/bitcoinamountfield.h \ + /usr/include/qt5/QtWidgets/QLineEdit \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/sendcoinsentry.ui -o build/ui_sendcoinsentry.h + +build/ui_askpassphrasedialog.h: src/qt/forms/askpassphrasedialog.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/askpassphrasedialog.ui -o build/ui_askpassphrasedialog.h + +build/ui_blockbrowser.h: src/qt/forms/blockbrowser.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/blockbrowser.ui -o build/ui_blockbrowser.h + +build/ui_rpcconsole.h: src/qt/forms/rpcconsole.ui \ + src/qt/trafficgraphwidget.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QQueue \ + /usr/include/qt5/QtCore/qqueue.h + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/rpcconsole.ui -o build/ui_rpcconsole.h + +build/ui_optionsdialog.h: src/qt/forms/optionsdialog.ui \ + src/qt/bitcoinamountfield.h \ + src/qt/qvaluecombobox.h \ + src/qt/qvalidatedlineedit.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtWidgets/QComboBox \ + /usr/include/qt5/QtWidgets/qcombobox.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QVariant \ + /usr/include/qt5/QtWidgets/QLineEdit \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qtextoption.h + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/optionsdialog.ui -o build/ui_optionsdialog.h + +build/ui_darksendconfig.h: src/qt/forms/darksendconfig.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/darksendconfig.ui -o build/ui_darksendconfig.h + +build/ui_masternodemanager.h: src/qt/forms/masternodemanager.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/masternodemanager.ui -o build/ui_masternodemanager.h + +build/ui_addeditadrenalinenode.h: src/qt/forms/addeditadrenalinenode.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/addeditadrenalinenode.ui -o build/ui_addeditadrenalinenode.h + +build/ui_adrenalinenodeconfigdialog.h: src/qt/forms/adrenalinenodeconfigdialog.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/adrenalinenodeconfigdialog.ui -o build/ui_adrenalinenodeconfigdialog.h + +build/ui_messagepage.h: src/qt/forms/messagepage.ui \ + src/qt/plugins/mrichtexteditor/mrichtextedit.h \ + /usr/include/qt5/QtCore/QPointer \ + /usr/include/qt5/QtCore/qpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qpair.h \ + build/ui_mrichtextedit.h + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/messagepage.ui -o build/ui_messagepage.h + +build/ui_sendmessagesentry.h: src/qt/forms/sendmessagesentry.ui \ + src/qt/qvalidatedlineedit.h \ + src/qt/qvalidatedtextedit.h \ + /usr/include/qt5/QtWidgets/QLineEdit \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtWidgets/QPlainTextEdit \ + /usr/include/qt5/QtWidgets/qplaintextedit.h \ + /usr/include/qt5/QtWidgets/qtextedit.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qtextdocument.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qabstracttextdocumentlayout.h \ + /usr/include/qt5/QtGui/qtextlayout.h \ + /usr/include/qt5/QtGui/qglyphrun.h \ + /usr/include/qt5/QtGui/qrawfont.h \ + /usr/include/qt5/QtGui/qfontdatabase.h + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/sendmessagesentry.ui -o build/ui_sendmessagesentry.h + +build/ui_sendmessagesdialog.h: src/qt/forms/sendmessagesdialog.ui \ + src/qt/qvalidatedlineedit.h \ + /usr/include/qt5/QtWidgets/QLineEdit \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qtextoption.h + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/sendmessagesdialog.ui -o build/ui_sendmessagesdialog.h + +build/ui_mrichtextedit.h: src/qt/plugins/mrichtexteditor/mrichtextedit.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/plugins/mrichtexteditor/mrichtextedit.ui -o build/ui_mrichtextedit.h + +build/ui_sidetoolbar.h: src/qt/forms/sidetoolbar.ui + /usr/lib/x86_64-linux-gnu/qt5/bin/uic src/qt/forms/sidetoolbar.ui -o build/ui_sidetoolbar.h + +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_TSQM_clean compiler_rcc_clean compiler_moc_header_clean compiler_uic_clean + +####### Compile + +build/txdb-leveldb.o: src/txdb-leveldb.cpp src/leveldb/include/leveldb/env.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/cache.h \ + src/leveldb/include/leveldb/filter_policy.h \ + src/leveldb/helpers/memenv/memenv.h \ + src/kernel.h \ + src/main.h \ + src/core.h \ + src/uint256.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/checkpoints.h \ + src/txdb.h \ + src/txdb-leveldb.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/txdb-leveldb.o src/txdb-leveldb.cpp + +build/bloom.o: src/bloom.cpp src/bloom.h \ + src/uint256.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/main.h \ + src/core.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/bloom.o src/bloom.cpp + +build/hash.o: src/hash.cpp src/hash.h \ + src/uint256.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/hash.o src/hash.cpp + +build/rpcexecutor.o: src/qt/rpcexecutor.cpp src/qt/rpcexecutor.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/QString \ + src/qt/rpcconsole.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/rpcclient.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/rpcserver.h \ + src/uint256.h \ + src/rpcprotocol.h \ + src/compat.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcexecutor.o src/qt/rpcexecutor.cpp + +build/sidetoolbar.o: src/qt/forms/sidetoolbar.cpp src/qt/forms/sidetoolbar.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_sidetoolbar.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/sidetoolbar.o src/qt/forms/sidetoolbar.cpp + +build/bitcoin.o: src/qt/bitcoin.cpp /usr/include/qt5/QtWidgets/QApplication \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + src/masternodeconfig.h \ + src/qt/bitcoingui.h \ + /usr/include/qt5/QtWidgets/QMainWindow \ + /usr/include/qt5/QtWidgets/qmainwindow.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/QSystemTrayIcon \ + /usr/include/qt5/QtWidgets/qsystemtrayicon.h \ + src/qt/clientmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/qt/walletmodel.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + src/qt/messagemodel.h \ + src/smessage.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/lz4/lz4.h \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + src/qt/guiconstants.h \ + src/init.h \ + src/qt/paymentserver.h \ + src/qt/macdockiconhandler.h \ + /usr/include/qt5/QtCore/QTextCodec \ + /usr/include/qt5/QtCore/qtextcodec.h \ + /usr/include/qt5/QtCore/QLocale \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/QTranslator \ + /usr/include/qt5/QtCore/qtranslator.h \ + /usr/include/qt5/QtWidgets/QSplashScreen \ + /usr/include/qt5/QtWidgets/qsplashscreen.h \ + /usr/include/qt5/QtCore/QLibraryInfo \ + /usr/include/qt5/QtCore/qlibraryinfo.h \ + /usr/include/qt5/QtCore/QtPlugin \ + /usr/include/qt5/QtCore/qplugin.h \ + /usr/include/qt5/QtCore/qpointer.h \ + /usr/include/qt5/QtCore/qjsonobject.h \ + /usr/include/qt5/QtCore/qjsonvalue.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/bitcoin.o src/qt/bitcoin.cpp + +build/bitcoingui.o: src/qt/bitcoingui.cpp /usr/include/qt5/QtWidgets/QApplication \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + src/qt/bitcoingui.h \ + /usr/include/qt5/QtWidgets/QMainWindow \ + /usr/include/qt5/QtWidgets/qmainwindow.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/QSystemTrayIcon \ + /usr/include/qt5/QtWidgets/qsystemtrayicon.h \ + src/qt/transactiontablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/addressbookpage.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + src/qt/sendcoinsdialog.h \ + /usr/include/qt5/QtCore/QString \ + src/qt/signverifymessagedialog.h \ + src/qt/optionsdialog.h \ + src/qt/aboutdialog.h \ + src/qt/clientmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/qt/walletmodel.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/editaddressdialog.h \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + src/qt/transactiondescdialog.h \ + src/qt/addresstablemodel.h \ + src/qt/transactionview.h \ + /usr/include/qt5/QtWidgets/QWidget \ + src/qt/overviewpage.h \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + src/qt/bitcoinunits.h \ + src/qt/guiconstants.h \ + src/qt/askpassphrasedialog.h \ + src/qt/notificator.h \ + /usr/include/qt5/QtGui/QIcon \ + src/qt/guiutil.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + src/qt/rpcconsole.h \ + src/init.h \ + src/qt/masternodemanager.h \ + /usr/include/qt5/QtCore/QFuture \ + /usr/include/qt5/QtCore/qfuture.h \ + /usr/include/qt5/QtCore/qfutureinterface.h \ + /usr/include/qt5/QtCore/qrunnable.h \ + /usr/include/qt5/QtCore/qexception.h \ + /usr/include/qt5/QtCore/qresultstore.h \ + src/qt/messagemodel.h \ + src/smessage.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/lz4/lz4.h \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + src/qt/messagepage.h \ + src/qt/blockbrowser.h \ + /usr/include/qt5/QtCore/QDir \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtCore/QFile \ + /usr/include/qt5/QtCore/QProcess \ + /usr/include/qt5/QtCore/qprocess.h \ + /usr/include/qt5/QtCore/QTime \ + /usr/include/qt5/QtCore/QMap \ + /usr/include/qt5/QtCore/QSettings \ + /usr/include/qt5/QtCore/qsettings.h \ + /usr/include/qt5/QtWidgets/QSlider \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + src/qt/forms/sidetoolbar.h \ + src/qt/macdockiconhandler.h \ + /usr/include/qt5/QtWidgets/QMenuBar \ + /usr/include/qt5/QtWidgets/qmenubar.h \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtWidgets/QMenu \ + /usr/include/qt5/QtWidgets/QVBoxLayout \ + /usr/include/qt5/QtWidgets/qboxlayout.h \ + /usr/include/qt5/QtWidgets/qlayout.h \ + /usr/include/qt5/QtWidgets/qlayoutitem.h \ + /usr/include/qt5/QtWidgets/qgridlayout.h \ + /usr/include/qt5/QtWidgets/QToolBar \ + /usr/include/qt5/QtWidgets/qtoolbar.h \ + /usr/include/qt5/QtWidgets/QStatusBar \ + /usr/include/qt5/QtWidgets/qstatusbar.h \ + /usr/include/qt5/QtWidgets/QLabel \ + /usr/include/qt5/QtWidgets/qlabel.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtCore/QMimeData \ + /usr/include/qt5/QtCore/qmimedata.h \ + /usr/include/qt5/QtWidgets/QProgressBar \ + /usr/include/qt5/QtWidgets/qprogressbar.h \ + /usr/include/qt5/QtWidgets/QStackedWidget \ + /usr/include/qt5/QtWidgets/qstackedwidget.h \ + /usr/include/qt5/QtGui/QMovie \ + /usr/include/qt5/QtGui/qmovie.h \ + /usr/include/qt5/QtGui/qimagereader.h \ + /usr/include/qt5/QtGui/qimageiohandler.h \ + /usr/include/qt5/QtCore/qplugin.h \ + /usr/include/qt5/QtCore/qpointer.h \ + /usr/include/qt5/QtCore/qjsonobject.h \ + /usr/include/qt5/QtCore/qjsonvalue.h \ + /usr/include/qt5/QtCore/qfactoryinterface.h \ + /usr/include/qt5/QtWidgets/QFileDialog \ + /usr/include/qt5/QtWidgets/qfiledialog.h \ + /usr/include/qt5/QtGui/QDesktopServices \ + /usr/include/qt5/QtGui/qdesktopservices.h \ + /usr/include/qt5/QtCore/qstandardpaths.h \ + /usr/include/qt5/QtGui/QDragEnterEvent \ + /usr/include/qt5/QtCore/QUrl \ + /usr/include/qt5/QtWidgets/QStyle \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/QToolButton \ + /usr/include/qt5/QtWidgets/qtoolbutton.h \ + /usr/include/qt5/QtWidgets/qabstractbutton.h \ + /usr/include/qt5/QtWidgets/QScrollArea \ + /usr/include/qt5/QtWidgets/qscrollarea.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtGui/QTextDocument \ + /usr/include/qt5/QtGui/qtextdocument.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/bitcoingui.o src/qt/bitcoingui.cpp + +build/skein.o: src/obj/skunkhash/skein.c src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h + $(CC) -c $(CFLAGS) $(INCPATH) -o build/skein.o src/obj/skunkhash/skein.c + +build/cubehash.o: src/obj/skunkhash/cubehash.c src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_types.h + $(CC) -c $(CFLAGS) $(INCPATH) -o build/cubehash.o src/obj/skunkhash/cubehash.c + +build/gost.o: src/obj/skunkhash/gost.c src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/sph_types.h + $(CC) -c $(CFLAGS) $(INCPATH) -o build/gost.o src/obj/skunkhash/gost.c + +build/fugue.o: src/obj/skunkhash/fugue.c src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_types.h + $(CC) -c $(CFLAGS) $(INCPATH) -o build/fugue.o src/obj/skunkhash/fugue.c + +build/transactiontablemodel.o: src/qt/transactiontablemodel.cpp src/qt/transactiontablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/transactionrecord.h \ + src/uint256.h \ + /usr/include/qt5/QtCore/QList \ + src/qt/guiconstants.h \ + src/qt/transactiondesc.h \ + src/qt/walletmodel.h \ + src/allocators.h \ + src/instantx.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + src/qt/addresstablemodel.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtGui/QColor \ + /usr/include/qt5/QtGui/QIcon \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/QDebug + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/transactiontablemodel.o src/qt/transactiontablemodel.cpp + +build/addresstablemodel.o: src/qt/addresstablemodel.cpp src/qt/addresstablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/walletmodel.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + /usr/include/qt5/QtGui/QFont \ + /usr/include/qt5/QtCore/QDebug + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/addresstablemodel.o src/qt/addresstablemodel.cpp + +build/optionsdialog.o: src/qt/optionsdialog.cpp src/qt/optionsdialog.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_optionsdialog.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + src/qt/monitoreddatamapper.h \ + /usr/include/qt5/QtWidgets/QDataWidgetMapper \ + /usr/include/qt5/QtWidgets/qdatawidgetmapper.h \ + src/netbase.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QDir \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtGui/QIntValidator \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtCore/QLocale \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/optionsdialog.o src/qt/optionsdialog.cpp + +build/sendcoinsdialog.o: src/qt/sendcoinsdialog.cpp src/qt/sendcoinsdialog.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QString \ + build/ui_sendcoinsdialog.h \ + src/qt/walletmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/addresstablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/addressbookpage.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + src/qt/optionsmodel.h \ + src/qt/sendcoinsentry.h \ + /usr/include/qt5/QtWidgets/QFrame \ + /usr/include/qt5/QtWidgets/qframe.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + src/qt/askpassphrasedialog.h \ + src/coincontrol.h \ + src/qt/coincontroldialog.h \ + /usr/include/qt5/QtWidgets/QAbstractButton \ + /usr/include/qt5/QtWidgets/qabstractbutton.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/QAction \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtWidgets/QMenu \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtCore/QPoint \ + /usr/include/qt5/QtWidgets/QTreeWidgetItem \ + /usr/include/qt5/QtWidgets/qtreewidget.h \ + /usr/include/qt5/QtWidgets/qtreeview.h \ + /usr/include/qt5/QtWidgets/qabstractitemview.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qtreewidgetitemiterator.h \ + /usr/include/qt5/QtGui/QTextDocument \ + /usr/include/qt5/QtGui/qtextdocument.h \ + /usr/include/qt5/QtWidgets/QScrollBar \ + /usr/include/qt5/QtWidgets/qscrollbar.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/sendcoinsdialog.o src/qt/sendcoinsdialog.cpp + +build/coincontroldialog.o: src/qt/coincontroldialog.cpp src/qt/coincontroldialog.h \ + /usr/include/qt5/QtWidgets/QAbstractButton \ + /usr/include/qt5/QtWidgets/qabstractbutton.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtWidgets/QAction \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtWidgets/QMenu \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtCore/QPoint \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtWidgets/QTreeWidgetItem \ + /usr/include/qt5/QtWidgets/qtreewidget.h \ + /usr/include/qt5/QtWidgets/qtreeview.h \ + /usr/include/qt5/QtWidgets/qabstractitemview.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qtreewidgetitemiterator.h \ + build/ui_coincontroldialog.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/sync.h \ + src/threadsafety.h \ + src/key.h \ + src/uint256.h \ + src/hash.h \ + src/stealth.h \ + src/util.h \ + src/tinyformat.h \ + src/crypter.h \ + src/keystore.h \ + src/script.h \ + src/bignum.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/base58.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + src/qt/walletmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/instantx.h \ + src/qt/addresstablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/optionsmodel.h \ + src/coincontrol.h \ + /usr/include/qt5/QtWidgets/QApplication \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + /usr/include/qt5/QtWidgets/QCheckBox \ + /usr/include/qt5/QtWidgets/qcheckbox.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtGui/QColor \ + /usr/include/qt5/QtGui/QCursor \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtWidgets/QDialogButtonBox \ + /usr/include/qt5/QtWidgets/qdialogbuttonbox.h \ + /usr/include/qt5/QtCore/QFlags \ + /usr/include/qt5/QtGui/QIcon \ + /usr/include/qt5/QtWidgets/QTreeWidget + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/coincontroldialog.o src/qt/coincontroldialog.cpp + +build/coincontroltreewidget.o: src/qt/coincontroltreewidget.cpp src/qt/coincontroltreewidget.h \ + /usr/include/qt5/QtGui/QKeyEvent \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtWidgets/QTreeWidget \ + /usr/include/qt5/QtWidgets/qtreewidget.h \ + /usr/include/qt5/QtWidgets/qtreeview.h \ + /usr/include/qt5/QtWidgets/qabstractitemview.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qtreewidgetitemiterator.h \ + src/qt/coincontroldialog.h \ + /usr/include/qt5/QtWidgets/QAbstractButton \ + /usr/include/qt5/QtWidgets/qabstractbutton.h \ + /usr/include/qt5/QtWidgets/QAction \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtWidgets/QMenu \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtCore/QPoint \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtWidgets/QTreeWidgetItem + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/coincontroltreewidget.o src/qt/coincontroltreewidget.cpp + +build/addressbookpage.o: src/qt/addressbookpage.cpp src/qt/addressbookpage.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_addressbookpage.h \ + src/qt/addresstablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + src/qt/bitcoingui.h \ + /usr/include/qt5/QtWidgets/QMainWindow \ + /usr/include/qt5/QtWidgets/qmainwindow.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/QSystemTrayIcon \ + /usr/include/qt5/QtWidgets/qsystemtrayicon.h \ + src/qt/editaddressdialog.h \ + src/qt/csvmodelwriter.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/QList \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + src/qt/qrcodedialog.h \ + /usr/include/qt5/QtGui/QImage \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtWidgets/QMenu \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/addressbookpage.o src/qt/addressbookpage.cpp + +build/signverifymessagedialog.o: src/qt/signverifymessagedialog.cpp src/qt/signverifymessagedialog.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_signverifymessagedialog.h \ + src/qt/addressbookpage.h \ + src/base58.h \ + src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/key.h \ + src/hash.h \ + src/script.h \ + src/keystore.h \ + src/sync.h \ + src/threadsafety.h \ + src/stealth.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + src/qt/walletmodel.h \ + src/instantx.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/signverifymessagedialog.o src/qt/signverifymessagedialog.cpp + +build/aboutdialog.o: src/qt/aboutdialog.cpp src/qt/aboutdialog.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_aboutdialog.h \ + src/qt/clientmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/version.h \ + src/clientversion.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/aboutdialog.o src/qt/aboutdialog.cpp + +build/editaddressdialog.o: src/qt/editaddressdialog.cpp src/qt/editaddressdialog.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_editaddressdialog.h \ + src/qt/addresstablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/QDataWidgetMapper \ + /usr/include/qt5/QtWidgets/qdatawidgetmapper.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/editaddressdialog.o src/qt/editaddressdialog.cpp + +build/bitcoinaddressvalidator.o: src/qt/bitcoinaddressvalidator.cpp src/qt/bitcoinaddressvalidator.h \ + /usr/include/qt5/QtGui/QValidator \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/bitcoinaddressvalidator.o src/qt/bitcoinaddressvalidator.cpp + +build/alert.o: src/alert.cpp src/alert.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/chainparams.h \ + src/bignum.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/key.h \ + src/hash.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/addrman.h \ + src/sync.h \ + src/threadsafety.h \ + src/timedata.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/stealth.h \ + src/ui_interface.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/alert.o src/alert.cpp + +build/chainparams.o: src/chainparams.cpp src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/main.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/chainparamsseeds.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/chainparams.o src/chainparams.cpp + +build/version.o: src/version.cpp src/version.h \ + src/clientversion.h \ + build/build.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/version.o src/version.cpp + +build/sync.o: src/sync.cpp src/sync.h \ + src/threadsafety.h \ + src/util.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/tinyformat.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/sync.o src/sync.cpp + +build/txmempool.o: src/txmempool.cpp src/core.h \ + src/uint256.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h \ + src/txmempool.h \ + src/main.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/txmempool.o src/txmempool.cpp + +build/util.o: src/util.cpp src/util.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/tinyformat.h \ + src/chainparams.h \ + src/bignum.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/ui_interface.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/util.o src/util.cpp + +build/netbase.o: src/netbase.cpp src/netbase.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/util.h \ + src/tinyformat.h \ + src/sync.h \ + src/threadsafety.h \ + src/hash.h \ + src/uint256.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/netbase.o src/netbase.cpp + +build/key.o: src/key.cpp src/key.h \ + src/allocators.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/hash.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/key.o src/key.cpp + +build/eckey.o: src/eckey.cpp src/eckey.h \ + src/key.h \ + src/allocators.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/hash.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/eckey.o src/eckey.cpp + +build/script.o: src/script.cpp src/script.h \ + src/keystore.h \ + src/key.h \ + src/allocators.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/stealth.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/crypto/ripemd160.h \ + src/crypto/sha1.h \ + src/crypto/sha256.h \ + src/eccryptoverify.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/script.o src/script.cpp + +build/scrypt.o: src/scrypt.cpp src/scrypt.h \ + src/util.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/tinyformat.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/uint256.h \ + src/addrman.h \ + src/sync.h \ + src/threadsafety.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/pbkdf2.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/scrypt.o src/scrypt.cpp + +build/core.o: src/core.cpp src/core.h \ + src/uint256.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/core.o src/core.cpp + +build/main.o: src/main.cpp src/alert.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/chainparams.h \ + src/bignum.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/checkpoints.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/addrman.h \ + src/sync.h \ + src/threadsafety.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/db.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/crypter.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/kernel.h \ + src/txdb.h \ + src/txdb-leveldb.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/instantx.h \ + src/base58.h \ + src/darksend.h \ + src/masternode.h \ + src/activemasternode.h \ + src/spork.h \ + src/smessage.h \ + src/lz4/lz4.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/main.o src/main.cpp + +build/miner.o: src/miner.cpp src/txdb.h \ + src/txdb-leveldb.h \ + src/main.h \ + src/core.h \ + src/uint256.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/miner.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/kernel.h \ + src/masternode.h \ + src/base58.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/miner.o src/miner.cpp + +build/init.o: src/init.cpp src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/sync.h \ + src/threadsafety.h \ + src/key.h \ + src/uint256.h \ + src/hash.h \ + src/stealth.h \ + src/util.h \ + src/tinyformat.h \ + src/crypter.h \ + src/keystore.h \ + src/script.h \ + src/bignum.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/txdb.h \ + src/txdb-leveldb.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/rpcserver.h \ + src/rpcprotocol.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/checkpoints.h \ + src/activemasternode.h \ + src/darksend.h \ + src/masternode.h \ + src/base58.h \ + src/spork.h \ + src/smessage.h \ + src/lz4/lz4.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/init.o src/init.cpp + +build/net.o: src/net.cpp src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/sync.h \ + src/threadsafety.h \ + src/key.h \ + src/uint256.h \ + src/hash.h \ + src/stealth.h \ + src/util.h \ + src/tinyformat.h \ + src/crypter.h \ + src/keystore.h \ + src/script.h \ + src/bignum.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/darksend.h \ + src/masternode.h \ + src/base58.h \ + src/activemasternode.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/net.o src/net.cpp + +build/checkpoints.o: src/checkpoints.cpp src/checkpoints.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/sync.h \ + src/threadsafety.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/txdb.h \ + src/txdb-leveldb.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/checkpoints.o src/checkpoints.cpp + +build/addrman.o: src/addrman.cpp src/addrman.h \ + src/netbase.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/sync.h \ + src/threadsafety.h \ + src/timedata.h \ + src/hash.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/addrman.o src/addrman.cpp + +build/db.o: src/db.cpp src/db.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/sync.h \ + src/threadsafety.h \ + src/addrman.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/timedata.h \ + src/hash.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/db.o src/db.cpp + +build/walletdb.o: src/walletdb.cpp src/walletdb.h \ + src/db.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/sync.h \ + src/threadsafety.h \ + src/key.h \ + src/uint256.h \ + src/hash.h \ + src/stealth.h \ + src/util.h \ + src/tinyformat.h \ + src/base58.h \ + src/chainparams.h \ + src/bignum.h \ + src/script.h \ + src/keystore.h \ + src/protocol.h \ + src/netbase.h \ + src/compat.h \ + src/wallet.h \ + src/crypter.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/walletdb.o src/walletdb.cpp + +build/blockbrowser.o: src/qt/blockbrowser.cpp src/qt/blockbrowser.h \ + src/qt/clientmodel.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + src/qt/walletmodel.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QDir \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtCore/QFile \ + /usr/include/qt5/QtCore/QProcess \ + /usr/include/qt5/QtCore/qprocess.h \ + /usr/include/qt5/QtCore/QTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/QMap \ + /usr/include/qt5/QtCore/QSettings \ + /usr/include/qt5/QtCore/qsettings.h \ + /usr/include/qt5/QtWidgets/QSlider \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + build/ui_blockbrowser.h \ + src/qt/rpcconsole.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + src/qt/transactionrecord.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtCore/QString \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + src/qt/guiconstants.h \ + src/init.h \ + src/rpcserver.h \ + src/rpcprotocol.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + /usr/include/qt5/QtWidgets/QAbstractItemDelegate \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtGui/QPainter \ + /usr/include/qt5/QtGui/qpainter.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qpen.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/blockbrowser.o src/qt/blockbrowser.cpp + +build/clientmodel.o: src/qt/clientmodel.cpp src/qt/clientmodel.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + src/qt/guiconstants.h \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + src/qt/addresstablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/transactiontablemodel.h \ + src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/alert.h \ + src/main.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/QDebug + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/clientmodel.o src/qt/clientmodel.cpp + +build/clientcontrolpage.o: src/qt/clientcontrolpage.cpp src/qt/clientcontrolpage.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_clientcontrolpage.h \ + src/qt/clientmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/qt/walletmodel.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + src/qt/guiconstants.h \ + /usr/include/qt5/QtWidgets/QAbstractItemDelegate \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtGui/QPainter \ + /usr/include/qt5/QtGui/qpainter.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtWidgets/QMenu \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtCore/QDir \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtCore/QTextStream \ + /usr/include/qt5/QtCore/QProcess \ + /usr/include/qt5/QtCore/qprocess.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/clientcontrolpage.o src/qt/clientcontrolpage.cpp + +build/guiutil.o: src/qt/guiutil.cpp /usr/include/qt5/QtWidgets/QApplication \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + src/qt/bitcoinaddressvalidator.h \ + /usr/include/qt5/QtGui/QValidator \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + src/qt/walletmodel.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + src/init.h \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtGui/QDoubleValidator \ + /usr/include/qt5/QtGui/QFont \ + /usr/include/qt5/QtWidgets/QLineEdit \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtCore/QUrl \ + /usr/include/qt5/QtGui/QTextDocument \ + /usr/include/qt5/QtGui/qtextdocument.h \ + /usr/include/qt5/QtWidgets/QAbstractItemView \ + /usr/include/qt5/QtWidgets/qabstractitemview.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtWidgets/QFileDialog \ + /usr/include/qt5/QtWidgets/qfiledialog.h \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtGui/QDesktopServices \ + /usr/include/qt5/QtGui/qdesktopservices.h \ + /usr/include/qt5/QtCore/qstandardpaths.h \ + /usr/include/qt5/QtCore/QThread \ + /usr/include/qt5/QtCore/qthread.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/guiutil.o src/qt/guiutil.cpp + +build/transactionrecord.o: src/qt/transactionrecord.cpp src/qt/transactionrecord.h \ + src/uint256.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + src/base58.h \ + src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/key.h \ + src/hash.h \ + src/script.h \ + src/keystore.h \ + src/sync.h \ + src/threadsafety.h \ + src/stealth.h \ + src/timedata.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/addrman.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/transactionrecord.o src/qt/transactionrecord.cpp + +build/optionsmodel.o: src/qt/optionsmodel.cpp src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QString \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/sync.h \ + src/threadsafety.h \ + src/key.h \ + src/uint256.h \ + src/hash.h \ + src/stealth.h \ + src/util.h \ + src/tinyformat.h \ + src/crypter.h \ + src/keystore.h \ + src/script.h \ + src/bignum.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QSettings \ + /usr/include/qt5/QtCore/qsettings.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/optionsmodel.o src/qt/optionsmodel.cpp + +build/monitoreddatamapper.o: src/qt/monitoreddatamapper.cpp src/qt/monitoreddatamapper.h \ + /usr/include/qt5/QtWidgets/QDataWidgetMapper \ + /usr/include/qt5/QtWidgets/qdatawidgetmapper.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QMetaObject \ + /usr/include/qt5/QtCore/QMetaProperty \ + /usr/include/qt5/QtCore/qmetaobject.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/monitoreddatamapper.o src/qt/monitoreddatamapper.cpp + +build/trafficgraphwidget.o: src/qt/trafficgraphwidget.cpp src/qt/trafficgraphwidget.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QQueue \ + /usr/include/qt5/QtCore/qqueue.h \ + src/qt/clientmodel.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtGui/QPainter \ + /usr/include/qt5/QtGui/qpainter.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/QColor \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/trafficgraphwidget.o src/qt/trafficgraphwidget.cpp + +build/transactiondesc.o: src/qt/transactiondesc.cpp src/qt/transactiondesc.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/base58.h \ + src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/key.h \ + src/hash.h \ + src/script.h \ + src/keystore.h \ + src/sync.h \ + src/threadsafety.h \ + src/stealth.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/qt/paymentserver.h \ + src/qt/transactionrecord.h \ + /usr/include/qt5/QtCore/QList \ + src/ui_interface.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/txdb.h \ + src/txdb-leveldb.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/transactiondesc.o src/qt/transactiondesc.cpp + +build/transactiondescdialog.o: src/qt/transactiondescdialog.cpp src/qt/transactiondescdialog.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_transactiondescdialog.h \ + src/qt/transactiontablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/QModelIndex + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/transactiondescdialog.o src/qt/transactiondescdialog.cpp + +build/bitcoinstrings.o: src/qt/bitcoinstrings.cpp /usr/include/qt5/QtCore/QtGlobal \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/bitcoinstrings.o src/qt/bitcoinstrings.cpp + +build/bitcoinamountfield.o: src/qt/bitcoinamountfield.cpp src/qt/bitcoinamountfield.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/qvaluecombobox.h \ + /usr/include/qt5/QtWidgets/QComboBox \ + /usr/include/qt5/QtWidgets/qcombobox.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QVariant \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QAbstractListModel \ + src/qt/guiconstants.h \ + /usr/include/qt5/QtWidgets/QHBoxLayout \ + /usr/include/qt5/QtWidgets/qboxlayout.h \ + /usr/include/qt5/QtWidgets/qlayout.h \ + /usr/include/qt5/QtWidgets/qlayoutitem.h \ + /usr/include/qt5/QtWidgets/qgridlayout.h \ + /usr/include/qt5/QtGui/QKeyEvent \ + /usr/include/qt5/QtWidgets/QDoubleSpinBox \ + /usr/include/qt5/QtWidgets/qspinbox.h \ + /usr/include/qt5/QtWidgets/QApplication \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + /usr/include/qt5/QtCore/qmath.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/bitcoinamountfield.o src/qt/bitcoinamountfield.cpp + +build/wallet.o: src/wallet.cpp src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/sync.h \ + src/threadsafety.h \ + src/key.h \ + src/uint256.h \ + src/hash.h \ + src/stealth.h \ + src/util.h \ + src/tinyformat.h \ + src/crypter.h \ + src/keystore.h \ + src/script.h \ + src/bignum.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/base58.h \ + src/coincontrol.h \ + src/kernel.h \ + src/txdb.h \ + src/txdb-leveldb.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/spork.h \ + src/darksend.h \ + src/masternode.h \ + src/activemasternode.h \ + src/init.h \ + src/instantx.h \ + src/smessage.h \ + src/lz4/lz4.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/wallet.o src/wallet.cpp + +build/keystore.o: src/keystore.cpp src/keystore.h \ + src/key.h \ + src/allocators.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/script.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/stealth.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/keystore.o src/keystore.cpp + +build/transactionfilterproxy.o: src/qt/transactionfilterproxy.cpp src/qt/transactionfilterproxy.h \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + src/qt/transactiontablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/transactionrecord.h \ + src/uint256.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtCore/QString + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/transactionfilterproxy.o src/qt/transactionfilterproxy.cpp + +build/transactionview.o: src/qt/transactionview.cpp src/qt/transactionview.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/transactionfilterproxy.h \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + src/qt/transactionrecord.h \ + src/uint256.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtCore/QString \ + src/qt/walletmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/allocators.h \ + src/instantx.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/addresstablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/transactiontablemodel.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + src/qt/csvmodelwriter.h \ + src/qt/transactiondescdialog.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + src/qt/editaddressdialog.h \ + src/qt/optionsmodel.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/QScrollBar \ + /usr/include/qt5/QtWidgets/qscrollbar.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/QComboBox \ + /usr/include/qt5/QtWidgets/qcombobox.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtGui/QDoubleValidator \ + /usr/include/qt5/QtWidgets/QHBoxLayout \ + /usr/include/qt5/QtWidgets/qboxlayout.h \ + /usr/include/qt5/QtWidgets/qlayout.h \ + /usr/include/qt5/QtWidgets/qlayoutitem.h \ + /usr/include/qt5/QtWidgets/qgridlayout.h \ + /usr/include/qt5/QtWidgets/QVBoxLayout \ + /usr/include/qt5/QtWidgets/QLineEdit \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtWidgets/QTableView \ + /usr/include/qt5/QtWidgets/qtableview.h \ + /usr/include/qt5/QtWidgets/qabstractitemview.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtWidgets/QHeaderView \ + /usr/include/qt5/QtWidgets/qheaderview.h \ + /usr/include/qt5/QtCore/QPoint \ + /usr/include/qt5/QtWidgets/QMenu \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtWidgets/QLabel \ + /usr/include/qt5/QtWidgets/qlabel.h \ + /usr/include/qt5/QtWidgets/QDateTimeEdit \ + /usr/include/qt5/QtWidgets/qdatetimeedit.h \ + /usr/include/qt5/QtWidgets/QStyledItemDelegate \ + /usr/include/qt5/QtWidgets/qstyleditemdelegate.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/transactionview.o src/qt/transactionview.cpp + +build/walletmodel.o: src/qt/walletmodel.cpp src/qt/walletmodel.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/guiconstants.h \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + src/qt/addresstablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/transactiontablemodel.h \ + src/spork.h \ + src/darksend.h \ + src/masternode.h \ + src/activemasternode.h \ + src/init.h \ + src/smessage.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/lz4/lz4.h \ + /usr/include/qt5/QtCore/QSet \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/QDebug + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/walletmodel.o src/qt/walletmodel.cpp + +build/rpcclient.o: src/rpcclient.cpp src/rpcclient.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/rpcprotocol.h \ + src/compat.h \ + src/util.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/tinyformat.h \ + src/ui_interface.h \ + src/chainparams.h \ + src/bignum.h \ + src/uint256.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcclient.o src/rpcclient.cpp + +build/rpcprotocol.o: src/rpcprotocol.cpp src/rpcprotocol.h \ + src/compat.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/util.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/tinyformat.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcprotocol.o src/rpcprotocol.cpp + +build/rpcserver.o: src/rpcserver.cpp src/rpcserver.h \ + src/uint256.h \ + src/rpcprotocol.h \ + src/compat.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/base58.h \ + src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/key.h \ + src/hash.h \ + src/script.h \ + src/keystore.h \ + src/sync.h \ + src/threadsafety.h \ + src/stealth.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/protocol.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcserver.o src/rpcserver.cpp + +build/rpcdump.o: src/rpcdump.cpp src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/sync.h \ + src/threadsafety.h \ + src/key.h \ + src/uint256.h \ + src/hash.h \ + src/stealth.h \ + src/util.h \ + src/tinyformat.h \ + src/crypter.h \ + src/keystore.h \ + src/script.h \ + src/bignum.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/rpcserver.h \ + src/rpcprotocol.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/base58.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcdump.o src/rpcdump.cpp + +build/rpcmisc.o: src/rpcmisc.cpp src/base58.h \ + src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/key.h \ + src/hash.h \ + src/script.h \ + src/keystore.h \ + src/sync.h \ + src/threadsafety.h \ + src/stealth.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/rpcserver.h \ + src/rpcprotocol.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/spork.h \ + src/darksend.h \ + src/masternode.h \ + src/activemasternode.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcmisc.o src/rpcmisc.cpp + +build/rpcnet.o: src/rpcnet.cpp src/rpcserver.h \ + src/uint256.h \ + src/rpcprotocol.h \ + src/compat.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/alert.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/main.h \ + src/core.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcnet.o src/rpcnet.cpp + +build/rpcmining.o: src/rpcmining.cpp src/rpcserver.h \ + src/uint256.h \ + src/rpcprotocol.h \ + src/compat.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/main.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/protocol.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/db.h \ + src/txdb.h \ + src/txdb-leveldb.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/crypter.h \ + src/ui_interface.h \ + src/miner.h \ + src/kernel.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcmining.o src/rpcmining.cpp + +build/rpcwallet.o: src/rpcwallet.cpp src/base58.h \ + src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/key.h \ + src/hash.h \ + src/script.h \ + src/keystore.h \ + src/sync.h \ + src/threadsafety.h \ + src/stealth.h \ + src/rpcserver.h \ + src/rpcprotocol.h \ + src/compat.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/protocol.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcwallet.o src/rpcwallet.cpp + +build/rpcblockchain.o: src/rpcblockchain.cpp src/rpcserver.h \ + src/uint256.h \ + src/rpcprotocol.h \ + src/compat.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/main.h \ + src/core.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/kernel.h \ + src/checkpoints.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcblockchain.o src/rpcblockchain.cpp + +build/rpcrawtransaction.o: src/rpcrawtransaction.cpp src/base58.h \ + src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/key.h \ + src/hash.h \ + src/script.h \ + src/keystore.h \ + src/sync.h \ + src/threadsafety.h \ + src/stealth.h \ + src/rpcserver.h \ + src/rpcprotocol.h \ + src/compat.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/txdb.h \ + src/txdb-leveldb.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/protocol.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcrawtransaction.o src/rpcrawtransaction.cpp + +build/timedata.o: src/timedata.cpp src/timedata.h \ + src/netbase.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/sync.h \ + src/threadsafety.h \ + src/ui_interface.h \ + src/util.h \ + src/tinyformat.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/timedata.o src/timedata.cpp + +build/overviewpage.o: src/qt/overviewpage.cpp src/qt/overviewpage.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + build/ui_overviewpage.h \ + src/qt/clientmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/darksend.h \ + src/main.h \ + src/core.h \ + src/uint256.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/masternode.h \ + src/base58.h \ + src/activemasternode.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/darksendconfig.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + src/qt/walletmodel.h \ + src/instantx.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + src/qt/optionsmodel.h \ + src/qt/transactiontablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + src/qt/transactionfilterproxy.h \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + src/qt/txviewdelegate.h \ + src/qt/guiconstants.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/QAbstractItemDelegate \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtGui/QPainter \ + /usr/include/qt5/QtGui/qpainter.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qpen.h \ + src/rpcserver.h \ + src/rpcprotocol.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + /usr/include/qt5/QtCore/QDebug + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/overviewpage.o src/qt/overviewpage.cpp + +build/csvmodelwriter.o: src/qt/csvmodelwriter.cpp src/qt/csvmodelwriter.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtCore/QAbstractItemModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/QFile \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtCore/QTextStream + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/csvmodelwriter.o src/qt/csvmodelwriter.cpp + +build/crypter.o: src/crypter.cpp src/crypter.h \ + src/allocators.h \ + src/key.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/hash.h \ + src/keystore.h \ + src/sync.h \ + src/threadsafety.h \ + src/script.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/stealth.h \ + src/scrypt.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/core.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/crypter.o src/crypter.cpp + +build/sendcoinsentry.o: src/qt/sendcoinsentry.cpp src/qt/sendcoinsentry.h \ + /usr/include/qt5/QtWidgets/QFrame \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_sendcoinsentry.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + src/qt/addressbookpage.h \ + /usr/include/qt5/QtWidgets/QDialog \ + src/qt/walletmodel.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/optionsmodel.h \ + src/qt/addresstablemodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtWidgets/QApplication \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/sendcoinsentry.o src/qt/sendcoinsentry.cpp + +build/qvalidatedlineedit.o: src/qt/qvalidatedlineedit.cpp src/qt/qvalidatedlineedit.h \ + /usr/include/qt5/QtWidgets/QLineEdit \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + src/qt/guiconstants.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/qvalidatedlineedit.o src/qt/qvalidatedlineedit.cpp + +build/bitcoinunits.o: src/qt/bitcoinunits.cpp src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/QStringList + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/bitcoinunits.o src/qt/bitcoinunits.cpp + +build/qvaluecombobox.o: src/qt/qvaluecombobox.cpp src/qt/qvaluecombobox.h \ + /usr/include/qt5/QtWidgets/QComboBox \ + /usr/include/qt5/QtWidgets/qcombobox.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QVariant \ + /usr/include/qt5/QtWidgets/QStyledItemDelegate \ + /usr/include/qt5/QtWidgets/qstyleditemdelegate.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/qvaluecombobox.o src/qt/qvaluecombobox.cpp + +build/askpassphrasedialog.o: src/qt/askpassphrasedialog.cpp src/qt/askpassphrasedialog.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_askpassphrasedialog.h \ + src/qt/guiconstants.h \ + src/qt/walletmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/QPushButton \ + /usr/include/qt5/QtWidgets/qpushbutton.h \ + /usr/include/qt5/QtWidgets/qabstractbutton.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtGui/QKeyEvent + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/askpassphrasedialog.o src/qt/askpassphrasedialog.cpp + +build/protocol.o: src/protocol.cpp src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/netbase.h \ + src/compat.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/protocol.o src/protocol.cpp + +build/notificator.o: src/qt/notificator.cpp src/qt/notificator.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtGui/QIcon \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtCore/QMetaType \ + /usr/include/qt5/QtCore/QVariant \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtWidgets/QApplication \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + /usr/include/qt5/QtWidgets/QStyle \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtCore/QByteArray \ + /usr/include/qt5/QtWidgets/QSystemTrayIcon \ + /usr/include/qt5/QtWidgets/qsystemtrayicon.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtCore/QTemporaryFile \ + /usr/include/qt5/QtCore/qtemporaryfile.h \ + /usr/include/qt5/QtGui/QImageWriter \ + /usr/include/qt5/QtGui/qimagewriter.h \ + /usr/include/qt5/QtGui/qimageiohandler.h \ + /usr/include/qt5/QtCore/qplugin.h \ + /usr/include/qt5/QtCore/qpointer.h \ + /usr/include/qt5/QtCore/qjsonobject.h \ + /usr/include/qt5/QtCore/qjsonvalue.h \ + /usr/include/qt5/QtCore/qfactoryinterface.h \ + /usr/include/qt5/QtDBus/QtDBus \ + /usr/include/qt5/QtDBus/QtDBusDepends \ + /usr/include/qt5/QtCore/QtCore \ + /usr/include/qt5/QtCore/QtCoreDepends \ + /usr/include/qt5/QtCore/qabstractanimation.h \ + /usr/include/qt5/QtCore/qanimationgroup.h \ + /usr/include/qt5/QtCore/qparallelanimationgroup.h \ + /usr/include/qt5/QtCore/qpauseanimation.h \ + /usr/include/qt5/QtCore/qpropertyanimation.h \ + /usr/include/qt5/QtCore/qvariantanimation.h \ + /usr/include/qt5/QtCore/qeasingcurve.h \ + /usr/include/qt5/QtCore/qsequentialanimationgroup.h \ + /usr/include/qt5/QtCore/qtextcodec.h \ + /usr/include/qt5/QtCore/qendian.h \ + /usr/include/qt5/QtCore/qlibraryinfo.h \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/qnumeric.h \ + /usr/include/qt5/QtCore/qbuffer.h \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtCore/qdiriterator.h \ + /usr/include/qt5/QtCore/qfileselector.h \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/qfilesystemwatcher.h \ + /usr/include/qt5/QtCore/qlockfile.h \ + /usr/include/qt5/QtCore/qloggingcategory.h \ + /usr/include/qt5/QtCore/qprocess.h \ + /usr/include/qt5/QtCore/qresource.h \ + /usr/include/qt5/QtCore/qsavefile.h \ + /usr/include/qt5/QtCore/qsettings.h \ + /usr/include/qt5/QtCore/qstandardpaths.h \ + /usr/include/qt5/QtCore/qtemporarydir.h \ + /usr/include/qt5/QtCore/QScopedPointer \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qidentityproxymodel.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qstringlistmodel.h \ + /usr/include/qt5/QtCore/qjsonarray.h \ + /usr/include/qt5/QtCore/qjsondocument.h \ + /usr/include/qt5/QtCore/qabstracteventdispatcher.h \ + /usr/include/qt5/QtCore/qabstractnativeeventfilter.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/qmath.h \ + /usr/include/qt5/QtCore/qmetaobject.h \ + /usr/include/qt5/QtCore/qmimedata.h \ + /usr/include/qt5/QtCore/qobjectcleanuphandler.h \ + /usr/include/qt5/QtCore/qsharedmemory.h \ + /usr/include/qt5/QtCore/qsignalmapper.h \ + /usr/include/qt5/QtCore/qsocketnotifier.h \ + /usr/include/qt5/QtCore/qsystemsemaphore.h \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qtranslator.h \ + /usr/include/qt5/QtCore/qwineventnotifier.h \ + /usr/include/qt5/QtCore/qmimedatabase.h \ + /usr/include/qt5/QtCore/qmimetype.h \ + /usr/include/qt5/QtCore/qlibrary.h \ + /usr/include/qt5/QtCore/qpluginloader.h \ + /usr/include/qt5/QtCore/quuid.h \ + /usr/include/qt5/QtCore/qabstractstate.h \ + /usr/include/qt5/QtCore/qabstracttransition.h \ + /usr/include/qt5/QtCore/qeventtransition.h \ + /usr/include/qt5/QtCore/qfinalstate.h \ + /usr/include/qt5/QtCore/qhistorystate.h \ + /usr/include/qt5/QtCore/qsignaltransition.h \ + /usr/include/qt5/QtCore/qstate.h \ + /usr/include/qt5/QtCore/qstatemachine.h \ + /usr/include/qt5/QtCore/qexception.h \ + /usr/include/qt5/QtCore/qfuture.h \ + /usr/include/qt5/QtCore/qfutureinterface.h \ + /usr/include/qt5/QtCore/qrunnable.h \ + /usr/include/qt5/QtCore/qresultstore.h \ + /usr/include/qt5/QtCore/qfuturesynchronizer.h \ + /usr/include/qt5/QtCore/qfuturewatcher.h \ + /usr/include/qt5/QtCore/qreadwritelock.h \ + /usr/include/qt5/QtCore/qsemaphore.h \ + /usr/include/qt5/QtCore/qthread.h \ + /usr/include/qt5/QtCore/qthreadpool.h \ + /usr/include/qt5/QtCore/qthreadstorage.h \ + /usr/include/qt5/QtCore/qwaitcondition.h \ + /usr/include/qt5/QtCore/qarraydataops.h \ + /usr/include/qt5/QtCore/qarraydatapointer.h \ + /usr/include/qt5/QtCore/qbitarray.h \ + /usr/include/qt5/QtCore/qbytearraymatcher.h \ + /usr/include/qt5/QtCore/qcache.h \ + /usr/include/qt5/QtCore/qcollator.h \ + /usr/include/qt5/QtCore/qcommandlineoption.h \ + /usr/include/qt5/QtCore/qcommandlineparser.h \ + /usr/include/qt5/QtCore/qcryptographichash.h \ + /usr/include/qt5/QtCore/qelapsedtimer.h \ + /usr/include/qt5/QtCore/qlinkedlist.h \ + /usr/include/qt5/QtCore/qmessageauthenticationcode.h \ + /usr/include/qt5/QtCore/qqueue.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtCore/qscopedvaluerollback.h \ + /usr/include/qt5/QtCore/qstack.h \ + /usr/include/qt5/QtCore/qtextboundaryfinder.h \ + /usr/include/qt5/QtCore/qtimeline.h \ + /usr/include/qt5/QtCore/qtimezone.h \ + /usr/include/qt5/QtCore/qxmlstream.h \ + /usr/include/qt5/QtCore/qtcoreversion.h \ + /usr/include/qt5/QtDBus/qdbusabstractadaptor.h \ + /usr/include/qt5/QtDBus/qdbusmacros.h \ + /usr/include/qt5/QtDBus/qdbusabstractinterface.h \ + /usr/include/qt5/QtDBus/qdbusmessage.h \ + /usr/include/qt5/QtDBus/qdbuserror.h \ + /usr/include/qt5/QtDBus/qdbusextratypes.h \ + /usr/include/qt5/QtDBus/qdbusconnection.h \ + /usr/include/qt5/QtDBus/qdbusargument.h \ + /usr/include/qt5/QtDBus/qdbusconnectioninterface.h \ + /usr/include/qt5/QtDBus/qdbusreply.h \ + /usr/include/qt5/QtDBus/qdbuspendingreply.h \ + /usr/include/qt5/QtDBus/qdbuspendingcall.h \ + /usr/include/qt5/QtDBus/qdbuscontext.h \ + /usr/include/qt5/QtDBus/qdbusinterface.h \ + /usr/include/qt5/QtDBus/qdbusmetatype.h \ + /usr/include/qt5/QtDBus/qdbusserver.h \ + /usr/include/qt5/QtDBus/qdbusservicewatcher.h \ + /usr/include/qt5/QtDBus/qdbusunixfiledescriptor.h \ + /usr/include/qt5/QtDBus/qdbusvirtualobject.h \ + /usr/include/qt5/QtDBus/qtdbusversion.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/notificator.o src/qt/notificator.cpp + +build/paymentserver.o: src/qt/paymentserver.cpp /usr/include/qt5/QtWidgets/QApplication \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + src/qt/paymentserver.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/QString \ + src/qt/guiconstants.h \ + src/ui_interface.h \ + src/util.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/tinyformat.h \ + /usr/include/qt5/QtCore/QByteArray \ + /usr/include/qt5/QtCore/QDataStream \ + /usr/include/qt5/QtCore/QDebug \ + /usr/include/qt5/QtGui/QFileOpenEvent \ + /usr/include/qt5/QtCore/QHash \ + /usr/include/qt5/QtNetwork/QLocalServer \ + /usr/include/qt5/QtNetwork/qlocalserver.h \ + /usr/include/qt5/QtNetwork/qabstractsocket.h \ + /usr/include/qt5/QtNetwork/QLocalSocket \ + /usr/include/qt5/QtNetwork/qlocalsocket.h \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/QUrl + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/paymentserver.o src/qt/paymentserver.cpp + +build/rpcconsole.o: src/qt/rpcconsole.cpp src/qt/rpcconsole.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_rpcconsole.h \ + src/qt/clientmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + src/rpcserver.h \ + src/uint256.h \ + src/rpcprotocol.h \ + src/compat.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/rpcclient.h \ + src/qt/rpcexecutor.h \ + /usr/include/qt5/QtCore/QTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/QThread \ + /usr/include/qt5/QtCore/qthread.h \ + /usr/include/qt5/QtGui/QKeyEvent \ + /usr/include/qt5/QtCore/QUrl \ + /usr/include/qt5/QtWidgets/QScrollBar \ + /usr/include/qt5/QtWidgets/qscrollbar.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcconsole.o src/qt/rpcconsole.cpp + +build/noui.o: src/noui.cpp src/ui_interface.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/sync.h \ + src/threadsafety.h \ + src/key.h \ + src/uint256.h \ + src/hash.h \ + src/stealth.h \ + src/util.h \ + src/tinyformat.h \ + src/crypter.h \ + src/keystore.h \ + src/script.h \ + src/bignum.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/noui.o src/noui.cpp + +build/kernel.o: src/kernel.cpp src/kernel.h \ + src/main.h \ + src/core.h \ + src/uint256.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/txdb.h \ + src/txdb-leveldb.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/kernel.o src/kernel.cpp + +build/pbkdf2.o: src/pbkdf2.cpp src/pbkdf2.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/pbkdf2.o src/pbkdf2.cpp + +build/stealth.o: src/stealth.cpp src/stealth.h \ + src/util.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/tinyformat.h \ + src/base58.h \ + src/chainparams.h \ + src/bignum.h \ + src/uint256.h \ + src/key.h \ + src/hash.h \ + src/script.h \ + src/keystore.h \ + src/sync.h \ + src/threadsafety.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/stealth.o src/stealth.cpp + +build/flowlayout.o: src/qt/flowlayout.cpp /usr/include/qt5/QtGui/QtGui \ + /usr/include/qt5/QtGui/QtGuiDepends \ + /usr/include/qt5/QtCore/QtCore \ + /usr/include/qt5/QtCore/QtCoreDepends \ + /usr/include/qt5/QtCore/qabstractanimation.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qanimationgroup.h \ + /usr/include/qt5/QtCore/qparallelanimationgroup.h \ + /usr/include/qt5/QtCore/qpauseanimation.h \ + /usr/include/qt5/QtCore/qpropertyanimation.h \ + /usr/include/qt5/QtCore/qvariantanimation.h \ + /usr/include/qt5/QtCore/qeasingcurve.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtCore/qsequentialanimationgroup.h \ + /usr/include/qt5/QtCore/qtextcodec.h \ + /usr/include/qt5/QtCore/qendian.h \ + /usr/include/qt5/QtCore/qlibraryinfo.h \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qnumeric.h \ + /usr/include/qt5/QtCore/qbuffer.h \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtCore/qdiriterator.h \ + /usr/include/qt5/QtCore/qfileselector.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/qfilesystemwatcher.h \ + /usr/include/qt5/QtCore/qlockfile.h \ + /usr/include/qt5/QtCore/qloggingcategory.h \ + /usr/include/qt5/QtCore/qprocess.h \ + /usr/include/qt5/QtCore/qresource.h \ + /usr/include/qt5/QtCore/qsavefile.h \ + /usr/include/qt5/QtCore/qsettings.h \ + /usr/include/qt5/QtCore/qstandardpaths.h \ + /usr/include/qt5/QtCore/qtemporarydir.h \ + /usr/include/qt5/QtCore/QScopedPointer \ + /usr/include/qt5/QtCore/qtemporaryfile.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qidentityproxymodel.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qstringlistmodel.h \ + /usr/include/qt5/QtCore/qjsonarray.h \ + /usr/include/qt5/QtCore/qjsonvalue.h \ + /usr/include/qt5/QtCore/qjsondocument.h \ + /usr/include/qt5/QtCore/qjsonobject.h \ + /usr/include/qt5/QtCore/qabstracteventdispatcher.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtCore/qabstractnativeeventfilter.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qmath.h \ + /usr/include/qt5/QtCore/qmetaobject.h \ + /usr/include/qt5/QtCore/qmimedata.h \ + /usr/include/qt5/QtCore/qobjectcleanuphandler.h \ + /usr/include/qt5/QtCore/qpointer.h \ + /usr/include/qt5/QtCore/qsharedmemory.h \ + /usr/include/qt5/QtCore/qsignalmapper.h \ + /usr/include/qt5/QtCore/qsocketnotifier.h \ + /usr/include/qt5/QtCore/qsystemsemaphore.h \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qtranslator.h \ + /usr/include/qt5/QtCore/qwineventnotifier.h \ + /usr/include/qt5/QtCore/qmimedatabase.h \ + /usr/include/qt5/QtCore/qmimetype.h \ + /usr/include/qt5/QtCore/qfactoryinterface.h \ + /usr/include/qt5/QtCore/qlibrary.h \ + /usr/include/qt5/QtCore/qplugin.h \ + /usr/include/qt5/QtCore/qpluginloader.h \ + /usr/include/qt5/QtCore/quuid.h \ + /usr/include/qt5/QtCore/qabstractstate.h \ + /usr/include/qt5/QtCore/qabstracttransition.h \ + /usr/include/qt5/QtCore/qeventtransition.h \ + /usr/include/qt5/QtCore/qfinalstate.h \ + /usr/include/qt5/QtCore/qhistorystate.h \ + /usr/include/qt5/QtCore/qsignaltransition.h \ + /usr/include/qt5/QtCore/qstate.h \ + /usr/include/qt5/QtCore/qstatemachine.h \ + /usr/include/qt5/QtCore/qexception.h \ + /usr/include/qt5/QtCore/qfuture.h \ + /usr/include/qt5/QtCore/qfutureinterface.h \ + /usr/include/qt5/QtCore/qrunnable.h \ + /usr/include/qt5/QtCore/qresultstore.h \ + /usr/include/qt5/QtCore/qfuturesynchronizer.h \ + /usr/include/qt5/QtCore/qfuturewatcher.h \ + /usr/include/qt5/QtCore/qreadwritelock.h \ + /usr/include/qt5/QtCore/qsemaphore.h \ + /usr/include/qt5/QtCore/qthread.h \ + /usr/include/qt5/QtCore/qthreadpool.h \ + /usr/include/qt5/QtCore/qthreadstorage.h \ + /usr/include/qt5/QtCore/qwaitcondition.h \ + /usr/include/qt5/QtCore/qarraydataops.h \ + /usr/include/qt5/QtCore/qarraydatapointer.h \ + /usr/include/qt5/QtCore/qbitarray.h \ + /usr/include/qt5/QtCore/qbytearraymatcher.h \ + /usr/include/qt5/QtCore/qcache.h \ + /usr/include/qt5/QtCore/qcollator.h \ + /usr/include/qt5/QtCore/qcommandlineoption.h \ + /usr/include/qt5/QtCore/qcommandlineparser.h \ + /usr/include/qt5/QtCore/qcryptographichash.h \ + /usr/include/qt5/QtCore/qelapsedtimer.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtCore/qlinkedlist.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qmessageauthenticationcode.h \ + /usr/include/qt5/QtCore/qqueue.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtCore/qscopedvaluerollback.h \ + /usr/include/qt5/QtCore/qstack.h \ + /usr/include/qt5/QtCore/qtextboundaryfinder.h \ + /usr/include/qt5/QtCore/qtimeline.h \ + /usr/include/qt5/QtCore/qtimezone.h \ + /usr/include/qt5/QtCore/qxmlstream.h \ + /usr/include/qt5/QtCore/qtcoreversion.h \ + /usr/include/qt5/QtGui/qaccessible.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qaccessiblebridge.h \ + /usr/include/qt5/QtGui/qaccessibleobject.h \ + /usr/include/qt5/QtGui/qaccessibleplugin.h \ + /usr/include/qt5/QtGui/qbitmap.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtGui/qiconengine.h \ + /usr/include/qt5/QtGui/qiconengineplugin.h \ + /usr/include/qt5/QtGui/qimageiohandler.h \ + /usr/include/qt5/QtGui/qimagereader.h \ + /usr/include/qt5/QtGui/qimagewriter.h \ + /usr/include/qt5/QtGui/qmovie.h \ + /usr/include/qt5/QtGui/qpicture.h \ + /usr/include/qt5/QtGui/qpictureformatplugin.h \ + /usr/include/qt5/QtGui/qpixmapcache.h \ + /usr/include/qt5/QtGui/qstandarditemmodel.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qdrag.h \ + /usr/include/qt5/QtGui/qgenericplugin.h \ + /usr/include/qt5/QtGui/qgenericpluginfactory.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + /usr/include/qt5/QtGui/qoffscreensurface.h \ + /usr/include/qt5/QtGui/qsurface.h \ + /usr/include/qt5/QtGui/qsurfaceformat.h \ + /usr/include/qt5/QtGui/qopenglcontext.h \ + /usr/include/qt5/QtGui/QSurfaceFormat \ + /usr/include/qt5/QtGui/qopengl.h \ + /usr/include/qt5/QtCore/qt_windows.h \ + /usr/include/qt5/QtGui/qopengles2ext.h \ + /usr/include/qt5/QtGui/qopenglext.h \ + /usr/include/qt5/QtGui/qopenglversionfunctions.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qscreen.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtCore/QRect \ + /usr/include/qt5/QtCore/QSize \ + /usr/include/qt5/QtCore/QSizeF \ + /usr/include/qt5/QtGui/QTransform \ + /usr/include/qt5/QtGui/qsessionmanager.h \ + /usr/include/qt5/QtGui/qstylehints.h \ + /usr/include/qt5/QtGui/qwindow.h \ + /usr/include/qt5/QtCore/QEvent \ + /usr/include/qt5/QtCore/QMargins \ + /usr/include/qt5/QtGui/qgenericmatrix.h \ + /usr/include/qt5/QtGui/qmatrix4x4.h \ + /usr/include/qt5/QtGui/qvector3d.h \ + /usr/include/qt5/QtGui/qvector4d.h \ + /usr/include/qt5/QtGui/qquaternion.h \ + /usr/include/qt5/QtGui/qopenglbuffer.h \ + /usr/include/qt5/QtGui/qopengldebug.h \ + /usr/include/qt5/QtGui/qopenglframebufferobject.h \ + /usr/include/qt5/QtGui/qopenglfunctions.h \ + /usr/include/qt5/QtGui/qopenglpaintdevice.h \ + /usr/include/qt5/QtGui/qopenglpixeltransferoptions.h \ + /usr/include/qt5/QtCore/QSharedDataPointer \ + /usr/include/qt5/QtGui/qopenglshaderprogram.h \ + /usr/include/qt5/QtGui/qopengltexture.h \ + /usr/include/qt5/QtGui/qopengltimerquery.h \ + /usr/include/qt5/QtGui/qopenglvertexarrayobject.h \ + /usr/include/qt5/QtGui/qbackingstore.h \ + /usr/include/qt5/QtGui/qpagedpaintdevice.h \ + /usr/include/qt5/QtGui/qpaintengine.h \ + /usr/include/qt5/QtGui/qpainter.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qpdfwriter.h \ + /usr/include/qt5/QtGui/qabstracttextdocumentlayout.h \ + /usr/include/qt5/QtGui/qtextlayout.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qglyphrun.h \ + /usr/include/qt5/QtGui/qrawfont.h \ + /usr/include/qt5/QtGui/qfontdatabase.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextdocument.h \ + /usr/include/qt5/QtGui/qstatictext.h \ + /usr/include/qt5/QtGui/qsyntaxhighlighter.h \ + /usr/include/qt5/QtGui/qtextobject.h \ + /usr/include/qt5/QtGui/qtextdocumentfragment.h \ + /usr/include/qt5/QtGui/qtextdocumentwriter.h \ + /usr/include/qt5/QtGui/qtextlist.h \ + /usr/include/qt5/QtGui/qtexttable.h \ + /usr/include/qt5/QtGui/qdesktopservices.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtGui/qtguiversion.h \ + /usr/include/qt5/QtWidgets/QStyle \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + src/qt/flowlayout.h \ + /usr/include/qt5/QtWidgets/QLayout \ + /usr/include/qt5/QtWidgets/qlayout.h \ + /usr/include/qt5/QtWidgets/qlayoutitem.h \ + /usr/include/qt5/QtWidgets/qboxlayout.h \ + /usr/include/qt5/QtWidgets/qgridlayout.h \ + /usr/include/qt5/QtWidgets/QWidgetItem + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/flowlayout.o src/qt/flowlayout.cpp + +build/darksendconfig.o: src/qt/darksendconfig.cpp src/qt/darksendconfig.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_darksendconfig.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + src/qt/guiconstants.h \ + src/qt/optionsmodel.h \ + src/qt/walletmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/init.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/QPushButton \ + /usr/include/qt5/QtWidgets/qpushbutton.h \ + /usr/include/qt5/QtWidgets/qabstractbutton.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtGui/QKeyEvent \ + /usr/include/qt5/QtCore/QSettings \ + /usr/include/qt5/QtCore/qsettings.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/darksendconfig.o src/qt/darksendconfig.cpp + +build/masternode.o: src/masternode.cpp src/masternode.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/activemasternode.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/darksend.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/masternode.o src/masternode.cpp + +build/darksend.o: src/darksend.cpp src/darksend.h \ + src/main.h \ + src/core.h \ + src/uint256.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/masternode.h \ + src/base58.h \ + src/activemasternode.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/instantx.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/darksend.o src/darksend.cpp + +build/rpcdarksend.o: src/rpcdarksend.cpp src/main.h \ + src/core.h \ + src/uint256.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/db.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/crypter.h \ + src/ui_interface.h \ + src/masternode.h \ + src/base58.h \ + src/activemasternode.h \ + src/darksend.h \ + src/masternodeconfig.h \ + src/rpcserver.h \ + src/rpcprotocol.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcdarksend.o src/rpcdarksend.cpp + +build/instantx.o: src/instantx.cpp src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/instantx.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/masternode.h \ + src/activemasternode.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/darksend.h \ + src/spork.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/instantx.o src/instantx.cpp + +build/activemasternode.o: src/activemasternode.cpp src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/netbase.h \ + src/compat.h \ + src/activemasternode.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/darksend.h \ + src/masternode.h \ + src/base58.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/activemasternode.o src/activemasternode.cpp + +build/spork.o: src/spork.cpp src/bignum.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/spork.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/darksend.h \ + src/masternode.h \ + src/activemasternode.h \ + src/init.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/spork.o src/spork.cpp + +build/masternodeconfig.o: src/masternodeconfig.cpp src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/sync.h \ + src/threadsafety.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/masternodeconfig.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/masternodeconfig.o src/masternodeconfig.cpp + +build/hmac_sha256.o: src/crypto/hmac_sha256.cpp src/crypto/hmac_sha256.h \ + src/crypto/sha256.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/hmac_sha256.o src/crypto/hmac_sha256.cpp + +build/hmac_sha512.o: src/crypto/hmac_sha512.cpp src/crypto/hmac_sha512.h \ + src/crypto/sha512.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/hmac_sha512.o src/crypto/hmac_sha512.cpp + +build/rfc6979_hmac_sha256.o: src/crypto/rfc6979_hmac_sha256.cpp src/crypto/rfc6979_hmac_sha256.h \ + src/crypto/hmac_sha256.h \ + src/crypto/sha256.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rfc6979_hmac_sha256.o src/crypto/rfc6979_hmac_sha256.cpp + +build/ripemd160.o: src/crypto/ripemd160.cpp src/crypto/ripemd160.h \ + src/crypto/common.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/ripemd160.o src/crypto/ripemd160.cpp + +build/sha1.o: src/crypto/sha1.cpp src/crypto/sha1.h \ + src/crypto/common.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/sha1.o src/crypto/sha1.cpp + +build/sha256.o: src/crypto/sha256.cpp src/crypto/sha256.h \ + src/crypto/common.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/sha256.o src/crypto/sha256.cpp + +build/sha512.o: src/crypto/sha512.cpp src/crypto/sha512.h \ + src/crypto/common.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/sha512.o src/crypto/sha512.cpp + +build/eccryptoverify.o: src/eccryptoverify.cpp src/eccryptoverify.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/eccryptoverify.o src/eccryptoverify.cpp + +build/masternodemanager.o: src/qt/masternodemanager.cpp src/qt/masternodemanager.h \ + src/util.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/tinyformat.h \ + src/sync.h \ + src/threadsafety.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/QFuture \ + /usr/include/qt5/QtCore/qfuture.h \ + /usr/include/qt5/QtCore/qfutureinterface.h \ + /usr/include/qt5/QtCore/qrunnable.h \ + /usr/include/qt5/QtCore/qexception.h \ + /usr/include/qt5/QtCore/qresultstore.h \ + build/ui_masternodemanager.h \ + src/qt/addeditadrenalinenode.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + src/qt/adrenalinenodeconfigdialog.h \ + src/qt/clientmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/qt/walletmodel.h \ + src/instantx.h \ + src/uint256.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/activemasternode.h \ + src/init.h \ + src/darksend.h \ + src/masternode.h \ + src/masternodeconfig.h \ + src/rpcserver.h \ + src/rpcprotocol.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + /usr/include/qt5/QtWidgets/QAbstractItemDelegate \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtGui/QPainter \ + /usr/include/qt5/QtGui/qpainter.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtCore/QDebug \ + /usr/include/qt5/QtWidgets/QScrollArea \ + /usr/include/qt5/QtWidgets/qscrollarea.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtWidgets/QApplication \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtCore/QThread \ + /usr/include/qt5/QtCore/qthread.h \ + /usr/include/qt5/QtWidgets/QScrollBar \ + /usr/include/qt5/QtWidgets/qscrollbar.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/masternodemanager.o src/qt/masternodemanager.cpp + +build/addeditadrenalinenode.o: src/qt/addeditadrenalinenode.cpp src/qt/addeditadrenalinenode.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_addeditadrenalinenode.h \ + src/walletdb.h \ + src/db.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/sync.h \ + src/threadsafety.h \ + src/key.h \ + src/uint256.h \ + src/hash.h \ + src/stealth.h \ + src/util.h \ + src/tinyformat.h \ + src/wallet.h \ + src/crypter.h \ + src/keystore.h \ + src/script.h \ + src/bignum.h \ + src/main.h \ + src/core.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/init.h \ + src/base58.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/addeditadrenalinenode.o src/qt/addeditadrenalinenode.cpp + +build/adrenalinenodeconfigdialog.o: src/qt/adrenalinenodeconfigdialog.cpp src/qt/adrenalinenodeconfigdialog.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_adrenalinenodeconfigdialog.h \ + /usr/include/qt5/QtCore/QModelIndex \ + /usr/include/qt5/QtCore/qabstractitemmodel.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/adrenalinenodeconfigdialog.o src/qt/adrenalinenodeconfigdialog.cpp + +build/qcustomplot.o: src/qt/qcustomplot.cpp src/qt/qcustomplot.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/QPointer \ + /usr/include/qt5/QtCore/qpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/QPainter \ + /usr/include/qt5/QtGui/qpainter.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/QPaintEvent \ + /usr/include/qt5/QtGui/QMouseEvent \ + /usr/include/qt5/QtGui/QPixmap \ + /usr/include/qt5/QtCore/QVector \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + /usr/include/qt5/QtCore/QMultiMap \ + /usr/include/qt5/QtCore/QFlags \ + /usr/include/qt5/QtCore/QDebug \ + /usr/include/qt5/QtGui/QVector2D \ + /usr/include/qt5/QtCore/QStack \ + /usr/include/qt5/QtCore/qstack.h \ + /usr/include/qt5/QtCore/QCache \ + /usr/include/qt5/QtCore/qcache.h \ + /usr/include/qt5/QtCore/QMargins \ + /usr/include/qt5/QtCore/qmath.h \ + /usr/include/qt5/QtCore/qnumeric.h \ + /usr/include/qt5/QtPrintSupport/QPrinter \ + /usr/include/qt5/QtPrintSupport/qprinter.h \ + /usr/include/qt5/QtGui/qpagedpaintdevice.h \ + /usr/include/qt5/QtPrintSupport/qtprintsupportglobal.h \ + /usr/include/qt5/QtPrintSupport/QPrintEngine \ + /usr/include/qt5/QtPrintSupport/qprintengine.h \ + /usr/include/qt5/QtCore/QtNumeric \ + /usr/include/qt5/QtPrintSupport/QtPrintSupport \ + /usr/include/qt5/QtPrintSupport/QtPrintSupportDepends \ + /usr/include/qt5/QtCore/QtCore \ + /usr/include/qt5/QtCore/QtCoreDepends \ + /usr/include/qt5/QtCore/qabstractanimation.h \ + /usr/include/qt5/QtCore/qanimationgroup.h \ + /usr/include/qt5/QtCore/qparallelanimationgroup.h \ + /usr/include/qt5/QtCore/qpauseanimation.h \ + /usr/include/qt5/QtCore/qpropertyanimation.h \ + /usr/include/qt5/QtCore/qvariantanimation.h \ + /usr/include/qt5/QtCore/qeasingcurve.h \ + /usr/include/qt5/QtCore/qsequentialanimationgroup.h \ + /usr/include/qt5/QtCore/qtextcodec.h \ + /usr/include/qt5/QtCore/qendian.h \ + /usr/include/qt5/QtCore/qlibraryinfo.h \ + /usr/include/qt5/QtCore/qbuffer.h \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtCore/qdiriterator.h \ + /usr/include/qt5/QtCore/qfileselector.h \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/qfilesystemwatcher.h \ + /usr/include/qt5/QtCore/qlockfile.h \ + /usr/include/qt5/QtCore/qloggingcategory.h \ + /usr/include/qt5/QtCore/qprocess.h \ + /usr/include/qt5/QtCore/qresource.h \ + /usr/include/qt5/QtCore/qsavefile.h \ + /usr/include/qt5/QtCore/qsettings.h \ + /usr/include/qt5/QtCore/qstandardpaths.h \ + /usr/include/qt5/QtCore/qtemporarydir.h \ + /usr/include/qt5/QtCore/QScopedPointer \ + /usr/include/qt5/QtCore/qtemporaryfile.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qidentityproxymodel.h \ + /usr/include/qt5/QtCore/qitemselectionmodel.h \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qstringlistmodel.h \ + /usr/include/qt5/QtCore/qjsonarray.h \ + /usr/include/qt5/QtCore/qjsonvalue.h \ + /usr/include/qt5/QtCore/qjsondocument.h \ + /usr/include/qt5/QtCore/qjsonobject.h \ + /usr/include/qt5/QtCore/qabstracteventdispatcher.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtCore/qabstractnativeeventfilter.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qmetaobject.h \ + /usr/include/qt5/QtCore/qmimedata.h \ + /usr/include/qt5/QtCore/qobjectcleanuphandler.h \ + /usr/include/qt5/QtCore/qsharedmemory.h \ + /usr/include/qt5/QtCore/qsignalmapper.h \ + /usr/include/qt5/QtCore/qsocketnotifier.h \ + /usr/include/qt5/QtCore/qsystemsemaphore.h \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qtranslator.h \ + /usr/include/qt5/QtCore/qwineventnotifier.h \ + /usr/include/qt5/QtCore/qmimedatabase.h \ + /usr/include/qt5/QtCore/qmimetype.h \ + /usr/include/qt5/QtCore/qfactoryinterface.h \ + /usr/include/qt5/QtCore/qlibrary.h \ + /usr/include/qt5/QtCore/qplugin.h \ + /usr/include/qt5/QtCore/qpluginloader.h \ + /usr/include/qt5/QtCore/quuid.h \ + /usr/include/qt5/QtCore/qabstractstate.h \ + /usr/include/qt5/QtCore/qabstracttransition.h \ + /usr/include/qt5/QtCore/qeventtransition.h \ + /usr/include/qt5/QtCore/qfinalstate.h \ + /usr/include/qt5/QtCore/qhistorystate.h \ + /usr/include/qt5/QtCore/qsignaltransition.h \ + /usr/include/qt5/QtCore/qstate.h \ + /usr/include/qt5/QtCore/qstatemachine.h \ + /usr/include/qt5/QtCore/qexception.h \ + /usr/include/qt5/QtCore/qfuture.h \ + /usr/include/qt5/QtCore/qfutureinterface.h \ + /usr/include/qt5/QtCore/qrunnable.h \ + /usr/include/qt5/QtCore/qresultstore.h \ + /usr/include/qt5/QtCore/qfuturesynchronizer.h \ + /usr/include/qt5/QtCore/qfuturewatcher.h \ + /usr/include/qt5/QtCore/qreadwritelock.h \ + /usr/include/qt5/QtCore/qsemaphore.h \ + /usr/include/qt5/QtCore/qthread.h \ + /usr/include/qt5/QtCore/qthreadpool.h \ + /usr/include/qt5/QtCore/qthreadstorage.h \ + /usr/include/qt5/QtCore/qwaitcondition.h \ + /usr/include/qt5/QtCore/qarraydataops.h \ + /usr/include/qt5/QtCore/qarraydatapointer.h \ + /usr/include/qt5/QtCore/qbitarray.h \ + /usr/include/qt5/QtCore/qbytearraymatcher.h \ + /usr/include/qt5/QtCore/qcollator.h \ + /usr/include/qt5/QtCore/qcommandlineoption.h \ + /usr/include/qt5/QtCore/qcommandlineparser.h \ + /usr/include/qt5/QtCore/qcryptographichash.h \ + /usr/include/qt5/QtCore/qelapsedtimer.h \ + /usr/include/qt5/QtCore/qlinkedlist.h \ + /usr/include/qt5/QtCore/qmessageauthenticationcode.h \ + /usr/include/qt5/QtCore/qqueue.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtCore/qscopedvaluerollback.h \ + /usr/include/qt5/QtCore/qtextboundaryfinder.h \ + /usr/include/qt5/QtCore/qtimeline.h \ + /usr/include/qt5/QtCore/qtimezone.h \ + /usr/include/qt5/QtCore/qxmlstream.h \ + /usr/include/qt5/QtCore/qtcoreversion.h \ + /usr/include/qt5/QtGui/QtGui \ + /usr/include/qt5/QtGui/QtGuiDepends \ + /usr/include/qt5/QtGui/qaccessible.h \ + /usr/include/qt5/QtGui/qaccessiblebridge.h \ + /usr/include/qt5/QtGui/qaccessibleobject.h \ + /usr/include/qt5/QtGui/qaccessibleplugin.h \ + /usr/include/qt5/QtGui/qbitmap.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtGui/qiconengine.h \ + /usr/include/qt5/QtGui/qiconengineplugin.h \ + /usr/include/qt5/QtGui/qimageiohandler.h \ + /usr/include/qt5/QtGui/qimagereader.h \ + /usr/include/qt5/QtGui/qimagewriter.h \ + /usr/include/qt5/QtGui/qmovie.h \ + /usr/include/qt5/QtGui/qpicture.h \ + /usr/include/qt5/QtGui/qpictureformatplugin.h \ + /usr/include/qt5/QtGui/qpixmapcache.h \ + /usr/include/qt5/QtGui/qstandarditemmodel.h \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtGui/qdrag.h \ + /usr/include/qt5/QtGui/qgenericplugin.h \ + /usr/include/qt5/QtGui/qgenericpluginfactory.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + /usr/include/qt5/QtGui/qoffscreensurface.h \ + /usr/include/qt5/QtGui/qsurface.h \ + /usr/include/qt5/QtGui/qsurfaceformat.h \ + /usr/include/qt5/QtGui/qopenglcontext.h \ + /usr/include/qt5/QtGui/QSurfaceFormat \ + /usr/include/qt5/QtGui/qopengl.h \ + /usr/include/qt5/QtCore/qt_windows.h \ + /usr/include/qt5/QtGui/qopengles2ext.h \ + /usr/include/qt5/QtGui/qopenglext.h \ + /usr/include/qt5/QtGui/qopenglversionfunctions.h \ + /usr/include/qt5/QtGui/qscreen.h \ + /usr/include/qt5/QtCore/QList \ + /usr/include/qt5/QtCore/QRect \ + /usr/include/qt5/QtCore/QSize \ + /usr/include/qt5/QtCore/QSizeF \ + /usr/include/qt5/QtGui/QTransform \ + /usr/include/qt5/QtGui/qsessionmanager.h \ + /usr/include/qt5/QtGui/qstylehints.h \ + /usr/include/qt5/QtGui/qwindow.h \ + /usr/include/qt5/QtCore/QEvent \ + /usr/include/qt5/QtGui/qgenericmatrix.h \ + /usr/include/qt5/QtGui/qmatrix4x4.h \ + /usr/include/qt5/QtGui/qvector3d.h \ + /usr/include/qt5/QtGui/qvector4d.h \ + /usr/include/qt5/QtGui/qquaternion.h \ + /usr/include/qt5/QtGui/qopenglbuffer.h \ + /usr/include/qt5/QtGui/qopengldebug.h \ + /usr/include/qt5/QtGui/qopenglframebufferobject.h \ + /usr/include/qt5/QtGui/qopenglfunctions.h \ + /usr/include/qt5/QtGui/qopenglpaintdevice.h \ + /usr/include/qt5/QtGui/qopenglpixeltransferoptions.h \ + /usr/include/qt5/QtCore/QSharedDataPointer \ + /usr/include/qt5/QtGui/qopenglshaderprogram.h \ + /usr/include/qt5/QtGui/qopengltexture.h \ + /usr/include/qt5/QtGui/qopengltimerquery.h \ + /usr/include/qt5/QtGui/qopenglvertexarrayobject.h \ + /usr/include/qt5/QtGui/qbackingstore.h \ + /usr/include/qt5/QtGui/qpaintengine.h \ + /usr/include/qt5/QtGui/qpdfwriter.h \ + /usr/include/qt5/QtGui/qabstracttextdocumentlayout.h \ + /usr/include/qt5/QtGui/qtextlayout.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qglyphrun.h \ + /usr/include/qt5/QtGui/qrawfont.h \ + /usr/include/qt5/QtGui/qfontdatabase.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextdocument.h \ + /usr/include/qt5/QtGui/qstatictext.h \ + /usr/include/qt5/QtGui/qsyntaxhighlighter.h \ + /usr/include/qt5/QtGui/qtextobject.h \ + /usr/include/qt5/QtGui/qtextdocumentfragment.h \ + /usr/include/qt5/QtGui/qtextdocumentwriter.h \ + /usr/include/qt5/QtGui/qtextlist.h \ + /usr/include/qt5/QtGui/qtexttable.h \ + /usr/include/qt5/QtGui/qdesktopservices.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtGui/qtguiversion.h \ + /usr/include/qt5/QtWidgets/QtWidgets \ + /usr/include/qt5/QtWidgets/QtWidgetsDepends \ + /usr/include/qt5/QtWidgets/qaccessiblewidget.h \ + /usr/include/qt5/QtWidgets/qcolordialog.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qerrormessage.h \ + /usr/include/qt5/QtWidgets/qfiledialog.h \ + /usr/include/qt5/QtWidgets/qfilesystemmodel.h \ + /usr/include/qt5/QtWidgets/qfontdialog.h \ + /usr/include/qt5/QtWidgets/qinputdialog.h \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qprogressdialog.h \ + /usr/include/qt5/QtWidgets/qwizard.h \ + /usr/include/qt5/QtWidgets/qgraphicseffect.h \ + /usr/include/qt5/QtWidgets/qgraphicsanchorlayout.h \ + /usr/include/qt5/QtWidgets/qgraphicsitem.h \ + /usr/include/qt5/QtWidgets/qgraphicslayout.h \ + /usr/include/qt5/QtWidgets/qgraphicslayoutitem.h \ + /usr/include/qt5/QtWidgets/qgraphicsgridlayout.h \ + /usr/include/qt5/QtWidgets/qgraphicsitemanimation.h \ + /usr/include/qt5/QtWidgets/qgraphicslinearlayout.h \ + /usr/include/qt5/QtWidgets/qgraphicsproxywidget.h \ + /usr/include/qt5/QtWidgets/qgraphicswidget.h \ + /usr/include/qt5/QtWidgets/qgraphicsscene.h \ + /usr/include/qt5/QtWidgets/qgraphicssceneevent.h \ + /usr/include/qt5/QtWidgets/qgraphicstransform.h \ + /usr/include/qt5/QtGui/QVector3D \ + /usr/include/qt5/QtGui/QMatrix4x4 \ + /usr/include/qt5/QtWidgets/qgraphicsview.h \ + /usr/include/qt5/QtWidgets/qscrollarea.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qabstractitemview.h \ + /usr/include/qt5/QtWidgets/qcolumnview.h \ + /usr/include/qt5/QtWidgets/qdatawidgetmapper.h \ + /usr/include/qt5/QtWidgets/qdirmodel.h \ + /usr/include/qt5/QtWidgets/qfileiconprovider.h \ + /usr/include/qt5/QtWidgets/qheaderview.h \ + /usr/include/qt5/QtWidgets/qitemdelegate.h \ + /usr/include/qt5/QtWidgets/qitemeditorfactory.h \ + /usr/include/qt5/QtWidgets/qlistview.h \ + /usr/include/qt5/QtWidgets/qlistwidget.h \ + /usr/include/qt5/QtWidgets/qstyleditemdelegate.h \ + /usr/include/qt5/QtWidgets/qtableview.h \ + /usr/include/qt5/QtWidgets/qtablewidget.h \ + /usr/include/qt5/QtWidgets/qtreeview.h \ + /usr/include/qt5/QtWidgets/qtreewidget.h \ + /usr/include/qt5/QtWidgets/qtreewidgetitemiterator.h \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtWidgets/qboxlayout.h \ + /usr/include/qt5/QtWidgets/qlayout.h \ + /usr/include/qt5/QtWidgets/qlayoutitem.h \ + /usr/include/qt5/QtWidgets/qgridlayout.h \ + /usr/include/qt5/QtWidgets/qformlayout.h \ + /usr/include/qt5/QtWidgets/QLayout \ + /usr/include/qt5/QtWidgets/qgesture.h \ + /usr/include/qt5/QtWidgets/qgesturerecognizer.h \ + /usr/include/qt5/QtWidgets/qshortcut.h \ + /usr/include/qt5/QtWidgets/qstackedlayout.h \ + /usr/include/qt5/QtWidgets/qtooltip.h \ + /usr/include/qt5/QtWidgets/qwhatsthis.h \ + /usr/include/qt5/QtWidgets/qwidgetaction.h \ + /usr/include/qt5/QtWidgets/qkeyeventtransition.h \ + /usr/include/qt5/QtWidgets/qmouseeventtransition.h \ + /usr/include/qt5/QtWidgets/qcommonstyle.h \ + /usr/include/qt5/QtWidgets/qdrawutil.h \ + /usr/include/qt5/QtWidgets/qproxystyle.h \ + /usr/include/qt5/QtWidgets/QCommonStyle \ + /usr/include/qt5/QtWidgets/qstylefactory.h \ + /usr/include/qt5/QtWidgets/qstylepainter.h \ + /usr/include/qt5/QtWidgets/qstyleplugin.h \ + /usr/include/qt5/QtWidgets/qcolormap.h \ + /usr/include/qt5/QtWidgets/qcompleter.h \ + /usr/include/qt5/QtWidgets/qscroller.h \ + /usr/include/qt5/QtCore/QPointF \ + /usr/include/qt5/QtWidgets/QScrollerProperties \ + /usr/include/qt5/QtWidgets/qscrollerproperties.h \ + /usr/include/qt5/QtCore/QMetaType \ + /usr/include/qt5/QtCore/QVariant \ + /usr/include/qt5/QtWidgets/qsystemtrayicon.h \ + /usr/include/qt5/QtWidgets/qundogroup.h \ + /usr/include/qt5/QtWidgets/qundostack.h \ + /usr/include/qt5/QtWidgets/qundoview.h \ + /usr/include/qt5/QtWidgets/qabstractbutton.h \ + /usr/include/qt5/QtWidgets/qbuttongroup.h \ + /usr/include/qt5/QtWidgets/qcalendarwidget.h \ + /usr/include/qt5/QtWidgets/qcheckbox.h \ + /usr/include/qt5/QtWidgets/qcombobox.h \ + /usr/include/qt5/QtWidgets/qcommandlinkbutton.h \ + /usr/include/qt5/QtWidgets/qpushbutton.h \ + /usr/include/qt5/QtWidgets/qdatetimeedit.h \ + /usr/include/qt5/QtWidgets/qdial.h \ + /usr/include/qt5/QtWidgets/qdialogbuttonbox.h \ + /usr/include/qt5/QtWidgets/qdockwidget.h \ + /usr/include/qt5/QtWidgets/qfocusframe.h \ + /usr/include/qt5/QtWidgets/qfontcombobox.h \ + /usr/include/qt5/QtWidgets/qgroupbox.h \ + /usr/include/qt5/QtWidgets/qkeysequenceedit.h \ + /usr/include/qt5/QtWidgets/qlabel.h \ + /usr/include/qt5/QtWidgets/qlcdnumber.h \ + /usr/include/qt5/QtWidgets/qmainwindow.h \ + /usr/include/qt5/QtWidgets/qmdiarea.h \ + /usr/include/qt5/QtWidgets/qmdisubwindow.h \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtWidgets/qmenubar.h \ + /usr/include/qt5/QtWidgets/qplaintextedit.h \ + /usr/include/qt5/QtWidgets/qtextedit.h \ + /usr/include/qt5/QtWidgets/qprogressbar.h \ + /usr/include/qt5/QtWidgets/qradiobutton.h \ + /usr/include/qt5/QtWidgets/qscrollbar.h \ + /usr/include/qt5/QtWidgets/qsizegrip.h \ + /usr/include/qt5/QtWidgets/qspinbox.h \ + /usr/include/qt5/QtWidgets/qsplashscreen.h \ + /usr/include/qt5/QtWidgets/qsplitter.h \ + /usr/include/qt5/QtWidgets/qstackedwidget.h \ + /usr/include/qt5/QtWidgets/qstatusbar.h \ + /usr/include/qt5/QtWidgets/qtextbrowser.h \ + /usr/include/qt5/QtWidgets/qtoolbar.h \ + /usr/include/qt5/QtWidgets/qtoolbox.h \ + /usr/include/qt5/QtWidgets/qtoolbutton.h \ + /usr/include/qt5/QtWidgets/qtwidgetsversion.h \ + /usr/include/qt5/QtPrintSupport/qabstractprintdialog.h \ + /usr/include/qt5/QtPrintSupport/qpagesetupdialog.h \ + /usr/include/qt5/QtPrintSupport/qprintdialog.h \ + /usr/include/qt5/QtPrintSupport/qprintpreviewdialog.h \ + /usr/include/qt5/QtPrintSupport/qprinterinfo.h \ + /usr/include/qt5/QtCore/QPair \ + /usr/include/qt5/QtPrintSupport/qprintpreviewwidget.h \ + /usr/include/qt5/QtPrintSupport/qtprintsupportversion.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/qcustomplot.o src/qt/qcustomplot.cpp + +build/smessage.o: src/smessage.cpp src/smessage.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/uint256.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/sync.h \ + src/threadsafety.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/db.h \ + src/wallet.h \ + src/walletdb.h \ + src/crypter.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/lz4/lz4.h \ + src/base58.h \ + src/init.h \ + src/txdb.h \ + src/txdb-leveldb.h \ + src/eckey.h \ + src/lz4/lz4.c \ + src/xxhash/xxhash.h \ + src/xxhash/xxhash.c + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/smessage.o src/smessage.cpp + +build/messagepage.o: src/qt/messagepage.cpp src/qt/messagepage.h \ + /usr/include/qt5/QtWidgets/QWidget \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_messagepage.h \ + src/qt/sendmessagesdialog.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtCore/QString \ + src/qt/plugins/mrichtexteditor/mrichtextedit.h \ + /usr/include/qt5/QtCore/QPointer \ + /usr/include/qt5/QtCore/qpointer.h \ + build/ui_mrichtextedit.h \ + src/qt/messagemodel.h \ + src/uint256.h \ + src/allocators.h \ + src/smessage.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/sync.h \ + src/threadsafety.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/db.h \ + src/wallet.h \ + src/walletdb.h \ + src/crypter.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/ui_interface.h \ + src/lz4/lz4.h \ + src/base58.h \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + src/qt/bitcoingui.h \ + /usr/include/qt5/QtWidgets/QMainWindow \ + /usr/include/qt5/QtWidgets/qmainwindow.h \ + /usr/include/qt5/QtWidgets/qtabwidget.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/QSystemTrayIcon \ + /usr/include/qt5/QtWidgets/qsystemtrayicon.h \ + src/qt/csvmodelwriter.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/QList \ + src/qt/guiutil.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtWidgets/QMenu \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtWidgets/QStyledItemDelegate \ + /usr/include/qt5/QtWidgets/qstyleditemdelegate.h \ + /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ + /usr/include/qt5/QtWidgets/qstyleoption.h \ + /usr/include/qt5/QtWidgets/qabstractspinbox.h \ + /usr/include/qt5/QtGui/qvalidator.h \ + /usr/include/qt5/QtCore/qregularexpression.h \ + /usr/include/qt5/QtWidgets/qslider.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtWidgets/qstyle.h \ + /usr/include/qt5/QtWidgets/qtabbar.h \ + /usr/include/qt5/QtWidgets/qrubberband.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtGui/QAbstractTextDocumentLayout \ + /usr/include/qt5/QtGui/qabstracttextdocumentlayout.h \ + /usr/include/qt5/QtGui/qtextlayout.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qglyphrun.h \ + /usr/include/qt5/QtGui/qrawfont.h \ + /usr/include/qt5/QtGui/qfontdatabase.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextdocument.h \ + /usr/include/qt5/QtGui/QPainter \ + /usr/include/qt5/QtGui/qpainter.h \ + /usr/include/qt5/QtWidgets/QToolBar \ + /usr/include/qt5/QtWidgets/qtoolbar.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/messagepage.o src/qt/messagepage.cpp + +build/messagemodel.o: src/qt/messagemodel.cpp src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + src/qt/guiconstants.h \ + src/qt/bitcoinunits.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + src/qt/optionsmodel.h \ + src/qt/walletmodel.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/messagemodel.h \ + src/smessage.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/lz4/lz4.h \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + src/qt/addresstablemodel.h \ + src/json/json_spirit.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_reader.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_writer.h \ + src/json/json_spirit_utils.h \ + /usr/include/qt5/QtCore/QSet \ + /usr/include/qt5/QtCore/QTimer \ + /usr/include/qt5/QtCore/qtimer.h \ + /usr/include/qt5/QtCore/qbasictimer.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtWidgets/QMenu \ + /usr/include/qt5/QtWidgets/qmenu.h \ + /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtWidgets/qaction.h \ + /usr/include/qt5/QtWidgets/qactiongroup.h \ + /usr/include/qt5/QtGui/QFont \ + /usr/include/qt5/QtGui/QColor + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/messagemodel.o src/qt/messagemodel.cpp + +build/sendmessagesdialog.o: src/qt/sendmessagesdialog.cpp src/qt/sendmessagesdialog.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtCore/QString \ + build/ui_sendmessagesdialog.h \ + src/qt/walletmodel.h \ + /usr/include/qt5/QtCore/QObject \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/messagemodel.h \ + src/smessage.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/lz4/lz4.h \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + src/qt/addressbookpage.h \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + src/qt/sendmessagesentry.h \ + /usr/include/qt5/QtWidgets/QFrame \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtCore/QLocale \ + /usr/include/qt5/QtGui/QTextDocument \ + /usr/include/qt5/QtGui/qtextdocument.h \ + /usr/include/qt5/QtWidgets/QScrollBar \ + /usr/include/qt5/QtWidgets/qscrollbar.h \ + /usr/include/qt5/QtWidgets/qabstractslider.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtWidgets/QDataWidgetMapper \ + /usr/include/qt5/QtWidgets/qdatawidgetmapper.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/sendmessagesdialog.o src/qt/sendmessagesdialog.cpp + +build/sendmessagesentry.o: src/qt/sendmessagesentry.cpp src/qt/sendmessagesentry.h \ + /usr/include/qt5/QtWidgets/QFrame \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + build/ui_sendmessagesentry.h \ + src/qt/guiutil.h \ + /usr/include/qt5/QtCore/QString \ + /usr/include/qt5/QtCore/QObject \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + src/qt/addressbookpage.h \ + /usr/include/qt5/QtWidgets/QDialog \ + src/qt/walletmodel.h \ + src/allocators.h \ + src/instantx.h \ + src/uint256.h \ + src/sync.h \ + src/threadsafety.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/serialize.h \ + src/version.h \ + src/clientversion.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/bignum.h \ + src/util.h \ + src/tinyformat.h \ + src/addrman.h \ + src/timedata.h \ + src/hash.h \ + src/core.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/stealth.h \ + src/base58.h \ + src/main.h \ + src/txmempool.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/wallet.h \ + src/walletdb.h \ + src/db.h \ + src/crypter.h \ + src/ui_interface.h \ + src/qt/messagemodel.h \ + src/smessage.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/lz4/lz4.h \ + /usr/include/qt5/QtCore/QSortFilterProxyModel \ + /usr/include/qt5/QtCore/qsortfilterproxymodel.h \ + /usr/include/qt5/QtCore/qabstractproxymodel.h \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + /usr/include/qt5/QtCore/QAbstractTableModel \ + /usr/include/qt5/QtCore/QStringList \ + /usr/include/qt5/QtCore/QDateTime \ + /usr/include/qt5/QtCore/qdatetime.h \ + src/qt/optionsmodel.h \ + /usr/include/qt5/QtCore/QAbstractListModel \ + src/qt/addresstablemodel.h \ + /usr/include/qt5/QtWidgets/QApplication \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/sendmessagesentry.o src/qt/sendmessagesentry.cpp + +build/qvalidatedtextedit.o: src/qt/qvalidatedtextedit.cpp src/qt/qvalidatedtextedit.h \ + /usr/include/qt5/QtWidgets/QPlainTextEdit \ + /usr/include/qt5/QtWidgets/qplaintextedit.h \ + /usr/include/qt5/QtWidgets/qtextedit.h \ + /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qpair.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qtextdocument.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qabstracttextdocumentlayout.h \ + /usr/include/qt5/QtGui/qtextlayout.h \ + /usr/include/qt5/QtGui/qglyphrun.h \ + /usr/include/qt5/QtGui/qrawfont.h \ + /usr/include/qt5/QtGui/qfontdatabase.h \ + src/qt/guiconstants.h \ + /usr/include/qt5/QtWidgets/QMessageBox \ + /usr/include/qt5/QtWidgets/qmessagebox.h \ + /usr/include/qt5/QtWidgets/qdialog.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/qvalidatedtextedit.o src/qt/qvalidatedtextedit.cpp + +build/mrichtextedit.o: src/qt/plugins/mrichtexteditor/mrichtextedit.cpp src/qt/plugins/mrichtexteditor/mrichtextedit.h \ + /usr/include/qt5/QtCore/QPointer \ + /usr/include/qt5/QtCore/qpointer.h \ + /usr/include/qt5/QtCore/qsharedpointer.h \ + /usr/include/qt5/QtCore/qglobal.h \ + /usr/include/qt5/QtCore/qconfig.h \ + /usr/include/qt5/QtCore/qfeatures.h \ + /usr/include/qt5/QtCore/qsystemdetection.h \ + /usr/include/qt5/QtCore/qprocessordetection.h \ + /usr/include/qt5/QtCore/qcompilerdetection.h \ + /usr/include/qt5/QtCore/qglobalstatic.h \ + /usr/include/qt5/QtCore/qatomic.h \ + /usr/include/qt5/QtCore/qbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_bootstrap.h \ + /usr/include/qt5/QtCore/qgenericatomic.h \ + /usr/include/qt5/QtCore/qatomic_msvc.h \ + /usr/include/qt5/QtCore/qatomic_integrity.h \ + /usr/include/qt5/QtCore/qoldbasicatomic.h \ + /usr/include/qt5/QtCore/qatomic_vxworks.h \ + /usr/include/qt5/QtCore/qatomic_power.h \ + /usr/include/qt5/QtCore/qatomic_alpha.h \ + /usr/include/qt5/QtCore/qatomic_armv7.h \ + /usr/include/qt5/QtCore/qatomic_armv6.h \ + /usr/include/qt5/QtCore/qatomic_armv5.h \ + /usr/include/qt5/QtCore/qatomic_bfin.h \ + /usr/include/qt5/QtCore/qatomic_ia64.h \ + /usr/include/qt5/QtCore/qatomic_mips.h \ + /usr/include/qt5/QtCore/qatomic_s390.h \ + /usr/include/qt5/QtCore/qatomic_sh4a.h \ + /usr/include/qt5/QtCore/qatomic_sparc.h \ + /usr/include/qt5/QtCore/qatomic_gcc.h \ + /usr/include/qt5/QtCore/qatomic_x86.h \ + /usr/include/qt5/QtCore/qatomic_cxx11.h \ + /usr/include/qt5/QtCore/qatomic_unix.h \ + /usr/include/qt5/QtCore/qmutex.h \ + /usr/include/qt5/QtCore/qlogging.h \ + /usr/include/qt5/QtCore/qflags.h \ + /usr/include/qt5/QtCore/qtypeinfo.h \ + /usr/include/qt5/QtCore/qtypetraits.h \ + /usr/include/qt5/QtCore/qsysinfo.h \ + /usr/include/qt5/QtCore/qshareddata.h \ + /usr/include/qt5/QtCore/qsharedpointer_impl.h \ + /usr/include/qt5/QtCore/qobject.h \ + /usr/include/qt5/QtCore/qobjectdefs.h \ + /usr/include/qt5/QtCore/qnamespace.h \ + /usr/include/qt5/QtCore/qobjectdefs_impl.h \ + /usr/include/qt5/QtCore/qstring.h \ + /usr/include/qt5/QtCore/qchar.h \ + /usr/include/qt5/QtCore/qbytearray.h \ + /usr/include/qt5/QtCore/qrefcount.h \ + /usr/include/qt5/QtCore/qarraydata.h \ + /usr/include/qt5/QtCore/qstringbuilder.h \ + /usr/include/qt5/QtCore/qlist.h \ + /usr/include/qt5/QtCore/qalgorithms.h \ + /usr/include/qt5/QtCore/qiterator.h \ + /usr/include/qt5/QtCore/qcoreevent.h \ + /usr/include/qt5/QtCore/qscopedpointer.h \ + /usr/include/qt5/QtCore/qmetatype.h \ + /usr/include/qt5/QtCore/qvarlengtharray.h \ + /usr/include/qt5/QtCore/qcontainerfwd.h \ + /usr/include/qt5/QtCore/qisenum.h \ + /usr/include/qt5/QtCore/qobject_impl.h \ + /usr/include/qt5/QtCore/qhash.h \ + /usr/include/qt5/QtCore/qpair.h \ + build/ui_mrichtextedit.h \ + /usr/include/qt5/QtWidgets/QApplication \ + /usr/include/qt5/QtWidgets/qapplication.h \ + /usr/include/qt5/QtCore/qcoreapplication.h \ + /usr/include/qt5/QtCore/qeventloop.h \ + /usr/include/qt5/QtGui/qwindowdefs.h \ + /usr/include/qt5/QtGui/qwindowdefs_win.h \ + /usr/include/qt5/QtCore/qpoint.h \ + /usr/include/qt5/QtCore/qsize.h \ + /usr/include/qt5/QtGui/qcursor.h \ + /usr/include/qt5/QtWidgets/qdesktopwidget.h \ + /usr/include/qt5/QtWidgets/qwidget.h \ + /usr/include/qt5/QtCore/qmargins.h \ + /usr/include/qt5/QtCore/qrect.h \ + /usr/include/qt5/QtGui/qpaintdevice.h \ + /usr/include/qt5/QtGui/qpalette.h \ + /usr/include/qt5/QtGui/qcolor.h \ + /usr/include/qt5/QtGui/qrgb.h \ + /usr/include/qt5/QtCore/qstringlist.h \ + /usr/include/qt5/QtCore/qdatastream.h \ + /usr/include/qt5/QtCore/qiodevice.h \ + /usr/include/qt5/QtCore/qregexp.h \ + /usr/include/qt5/QtCore/qstringmatcher.h \ + /usr/include/qt5/QtGui/qbrush.h \ + /usr/include/qt5/QtCore/qvector.h \ + /usr/include/qt5/QtGui/qmatrix.h \ + /usr/include/qt5/QtGui/qpolygon.h \ + /usr/include/qt5/QtGui/qregion.h \ + /usr/include/qt5/QtCore/qline.h \ + /usr/include/qt5/QtGui/qtransform.h \ + /usr/include/qt5/QtGui/qpainterpath.h \ + /usr/include/qt5/QtGui/qimage.h \ + /usr/include/qt5/QtGui/qpixmap.h \ + /usr/include/qt5/QtGui/qfont.h \ + /usr/include/qt5/QtGui/qfontmetrics.h \ + /usr/include/qt5/QtGui/qfontinfo.h \ + /usr/include/qt5/QtWidgets/qsizepolicy.h \ + /usr/include/qt5/QtGui/qkeysequence.h \ + /usr/include/qt5/QtGui/qevent.h \ + /usr/include/qt5/QtCore/qvariant.h \ + /usr/include/qt5/QtCore/qmap.h \ + /usr/include/qt5/QtCore/qdebug.h \ + /usr/include/qt5/QtCore/qtextstream.h \ + /usr/include/qt5/QtCore/qlocale.h \ + /usr/include/qt5/QtCore/qset.h \ + /usr/include/qt5/QtCore/qcontiguouscache.h \ + /usr/include/qt5/QtCore/qurl.h \ + /usr/include/qt5/QtCore/qurlquery.h \ + /usr/include/qt5/QtCore/qfile.h \ + /usr/include/qt5/QtCore/qfiledevice.h \ + /usr/include/qt5/QtGui/qvector2d.h \ + /usr/include/qt5/QtGui/qtouchdevice.h \ + /usr/include/qt5/QtGui/qguiapplication.h \ + /usr/include/qt5/QtGui/qinputmethod.h \ + /usr/include/qt5/QtGui/QClipboard \ + /usr/include/qt5/QtGui/qclipboard.h \ + /usr/include/qt5/QtCore/QMimeData \ + /usr/include/qt5/QtCore/qmimedata.h \ + /usr/include/qt5/QtGui/QFontDatabase \ + /usr/include/qt5/QtGui/qfontdatabase.h \ + /usr/include/qt5/QtWidgets/QInputDialog \ + /usr/include/qt5/QtWidgets/qinputdialog.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtWidgets/qlineedit.h \ + /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtGui/qtextcursor.h \ + /usr/include/qt5/QtGui/qtextformat.h \ + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtGui/qtextoption.h \ + /usr/include/qt5/QtWidgets/QColorDialog \ + /usr/include/qt5/QtWidgets/qcolordialog.h \ + /usr/include/qt5/QtGui/QTextList \ + /usr/include/qt5/QtGui/qtextlist.h \ + /usr/include/qt5/QtGui/qtextobject.h \ + /usr/include/qt5/QtGui/qglyphrun.h \ + /usr/include/qt5/QtGui/qrawfont.h \ + /usr/include/qt5/QtCore/QtDebug \ + /usr/include/qt5/QtWidgets/QFileDialog \ + /usr/include/qt5/QtWidgets/qfiledialog.h \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtGui/QImageReader \ + /usr/include/qt5/QtGui/qimagereader.h \ + /usr/include/qt5/QtGui/qimageiohandler.h \ + /usr/include/qt5/QtCore/qplugin.h \ + /usr/include/qt5/QtCore/qjsonobject.h \ + /usr/include/qt5/QtCore/qjsonvalue.h \ + /usr/include/qt5/QtCore/qfactoryinterface.h \ + /usr/include/qt5/QtCore/QSettings \ + /usr/include/qt5/QtCore/qsettings.h \ + /usr/include/qt5/QtCore/QBuffer \ + /usr/include/qt5/QtCore/qbuffer.h \ + /usr/include/qt5/QtCore/QUrl + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/mrichtextedit.o src/qt/plugins/mrichtexteditor/mrichtextedit.cpp + +build/rpcsmessage.o: src/rpcsmessage.cpp src/main.h \ + src/core.h \ + src/uint256.h \ + src/serialize.h \ + src/allocators.h \ + src/version.h \ + src/clientversion.h \ + src/util.h \ + src/tinyformat.h \ + src/script.h \ + src/keystore.h \ + src/key.h \ + src/hash.h \ + src/sync.h \ + src/threadsafety.h \ + src/bignum.h \ + src/stealth.h \ + src/txmempool.h \ + src/net.h \ + src/mruset.h \ + src/netbase.h \ + src/compat.h \ + src/protocol.h \ + src/chainparams.h \ + src/addrman.h \ + src/timedata.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/obj/skunkhash/sph_gost.h \ + src/obj/skunkhash/raptor.h \ + src/rpcserver.h \ + src/rpcprotocol.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_writer_template.h \ + src/smessage.h \ + src/leveldb/include/leveldb/db.h \ + src/leveldb/include/leveldb/iterator.h \ + src/leveldb/include/leveldb/slice.h \ + src/leveldb/include/leveldb/status.h \ + src/leveldb/include/leveldb/options.h \ + src/leveldb/include/leveldb/write_batch.h \ + src/db.h \ + src/wallet.h \ + src/walletdb.h \ + src/crypter.h \ + src/ui_interface.h \ + src/lz4/lz4.h \ + src/base58.h \ + src/init.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/rpcsmessage.o src/rpcsmessage.cpp + +build/qrc_bitcoin.o: qrc_bitcoin.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/qrc_bitcoin.o qrc_bitcoin.cpp + +build/moc_bitcoingui.o: build/moc_bitcoingui.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_bitcoingui.o build/moc_bitcoingui.cpp + +build/moc_transactiontablemodel.o: build/moc_transactiontablemodel.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_transactiontablemodel.o build/moc_transactiontablemodel.cpp + +build/moc_addresstablemodel.o: build/moc_addresstablemodel.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_addresstablemodel.o build/moc_addresstablemodel.cpp + +build/moc_optionsdialog.o: build/moc_optionsdialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_optionsdialog.o build/moc_optionsdialog.cpp + +build/moc_coincontroldialog.o: build/moc_coincontroldialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_coincontroldialog.o build/moc_coincontroldialog.cpp + +build/moc_coincontroltreewidget.o: build/moc_coincontroltreewidget.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_coincontroltreewidget.o build/moc_coincontroltreewidget.cpp + +build/moc_sendcoinsdialog.o: build/moc_sendcoinsdialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_sendcoinsdialog.o build/moc_sendcoinsdialog.cpp + +build/moc_addressbookpage.o: build/moc_addressbookpage.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_addressbookpage.o build/moc_addressbookpage.cpp + +build/moc_clientcontrolpage.o: build/moc_clientcontrolpage.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_clientcontrolpage.o build/moc_clientcontrolpage.cpp + +build/moc_signverifymessagedialog.o: build/moc_signverifymessagedialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_signverifymessagedialog.o build/moc_signverifymessagedialog.cpp + +build/moc_aboutdialog.o: build/moc_aboutdialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_aboutdialog.o build/moc_aboutdialog.cpp + +build/moc_editaddressdialog.o: build/moc_editaddressdialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_editaddressdialog.o build/moc_editaddressdialog.cpp + +build/moc_bitcoinaddressvalidator.o: build/moc_bitcoinaddressvalidator.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_bitcoinaddressvalidator.o build/moc_bitcoinaddressvalidator.cpp + +build/moc_blockbrowser.o: build/moc_blockbrowser.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_blockbrowser.o build/moc_blockbrowser.cpp + +build/moc_clientmodel.o: build/moc_clientmodel.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_clientmodel.o build/moc_clientmodel.cpp + +build/moc_guiutil.o: build/moc_guiutil.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_guiutil.o build/moc_guiutil.cpp + +build/moc_optionsmodel.o: build/moc_optionsmodel.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_optionsmodel.o build/moc_optionsmodel.cpp + +build/moc_monitoreddatamapper.o: build/moc_monitoreddatamapper.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_monitoreddatamapper.o build/moc_monitoreddatamapper.cpp + +build/moc_trafficgraphwidget.o: build/moc_trafficgraphwidget.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_trafficgraphwidget.o build/moc_trafficgraphwidget.cpp + +build/moc_transactiondesc.o: build/moc_transactiondesc.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_transactiondesc.o build/moc_transactiondesc.cpp + +build/moc_transactiondescdialog.o: build/moc_transactiondescdialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_transactiondescdialog.o build/moc_transactiondescdialog.cpp + +build/moc_bitcoinamountfield.o: build/moc_bitcoinamountfield.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_bitcoinamountfield.o build/moc_bitcoinamountfield.cpp + +build/moc_transactionfilterproxy.o: build/moc_transactionfilterproxy.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_transactionfilterproxy.o build/moc_transactionfilterproxy.cpp + +build/moc_transactionview.o: build/moc_transactionview.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_transactionview.o build/moc_transactionview.cpp + +build/moc_walletmodel.o: build/moc_walletmodel.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_walletmodel.o build/moc_walletmodel.cpp + +build/moc_overviewpage.o: build/moc_overviewpage.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_overviewpage.o build/moc_overviewpage.cpp + +build/moc_csvmodelwriter.o: build/moc_csvmodelwriter.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_csvmodelwriter.o build/moc_csvmodelwriter.cpp + +build/moc_sendcoinsentry.o: build/moc_sendcoinsentry.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_sendcoinsentry.o build/moc_sendcoinsentry.cpp + +build/moc_qvalidatedlineedit.o: build/moc_qvalidatedlineedit.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_qvalidatedlineedit.o build/moc_qvalidatedlineedit.cpp + +build/moc_bitcoinunits.o: build/moc_bitcoinunits.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_bitcoinunits.o build/moc_bitcoinunits.cpp + +build/moc_qvaluecombobox.o: build/moc_qvaluecombobox.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_qvaluecombobox.o build/moc_qvaluecombobox.cpp + +build/moc_askpassphrasedialog.o: build/moc_askpassphrasedialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_askpassphrasedialog.o build/moc_askpassphrasedialog.cpp + +build/moc_notificator.o: build/moc_notificator.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_notificator.o build/moc_notificator.cpp + +build/moc_paymentserver.o: build/moc_paymentserver.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_paymentserver.o build/moc_paymentserver.cpp + +build/moc_rpcconsole.o: build/moc_rpcconsole.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_rpcconsole.o build/moc_rpcconsole.cpp + +build/moc_darksendconfig.o: build/moc_darksendconfig.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_darksendconfig.o build/moc_darksendconfig.cpp + +build/moc_masternodemanager.o: build/moc_masternodemanager.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_masternodemanager.o build/moc_masternodemanager.cpp + +build/moc_addeditadrenalinenode.o: build/moc_addeditadrenalinenode.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_addeditadrenalinenode.o build/moc_addeditadrenalinenode.cpp + +build/moc_adrenalinenodeconfigdialog.o: build/moc_adrenalinenodeconfigdialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_adrenalinenodeconfigdialog.o build/moc_adrenalinenodeconfigdialog.cpp + +build/moc_qcustomplot.o: build/moc_qcustomplot.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_qcustomplot.o build/moc_qcustomplot.cpp + +build/moc_messagepage.o: build/moc_messagepage.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_messagepage.o build/moc_messagepage.cpp + +build/moc_messagemodel.o: build/moc_messagemodel.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_messagemodel.o build/moc_messagemodel.cpp + +build/moc_sendmessagesdialog.o: build/moc_sendmessagesdialog.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_sendmessagesdialog.o build/moc_sendmessagesdialog.cpp + +build/moc_sendmessagesentry.o: build/moc_sendmessagesentry.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_sendmessagesentry.o build/moc_sendmessagesentry.cpp + +build/moc_mrichtextedit.o: build/moc_mrichtextedit.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_mrichtextedit.o build/moc_mrichtextedit.cpp + +build/moc_qvalidatedtextedit.o: build/moc_qvalidatedtextedit.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_qvalidatedtextedit.o build/moc_qvalidatedtextedit.cpp + +build/moc_txviewdelegate.o: build/moc_txviewdelegate.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_txviewdelegate.o build/moc_txviewdelegate.cpp + +build/moc_rpcexecutor.o: build/moc_rpcexecutor.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_rpcexecutor.o build/moc_rpcexecutor.cpp + +build/moc_sidetoolbar.o: build/moc_sidetoolbar.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o build/moc_sidetoolbar.o build/moc_sidetoolbar.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/contrib/bitrpc/bitrpc.py b/contrib/bitrpc/bitrpc.py new file mode 100644 index 0000000..843f7ae --- /dev/null +++ b/contrib/bitrpc/bitrpc.py @@ -0,0 +1,324 @@ +from jsonrpc import ServiceProxy +import sys +import string + +# ===== BEGIN USER SETTINGS ===== +# if you do not set these you will be prompted for a password for every command +rpcuser = "" +rpcpass = "" +# ====== END USER SETTINGS ====== + + +if rpcpass == "": + access = ServiceProxy("http://127.0.0.1:9898") +else: + access = ServiceProxy("http://"+rpcuser+":"+rpcpass+"@127.0.0.1:9898") +cmd = sys.argv[1].lower() + +if cmd == "backupwallet": + try: + path = raw_input("Enter destination path/filename: ") + print access.backupwallet(path) + except: + print "\n---An error occurred---\n" + +elif cmd == "getaccount": + try: + addr = raw_input("Enter a SONO address: ") + print access.getaccount(addr) + except: + print "\n---An error occurred---\n" + +elif cmd == "getaccountaddress": + try: + acct = raw_input("Enter an account name: ") + print access.getaccountaddress(acct) + except: + print "\n---An error occurred---\n" + +elif cmd == "getaddressesbyaccount": + try: + acct = raw_input("Enter an account name: ") + print access.getaddressesbyaccount(acct) + except: + print "\n---An error occurred---\n" + +elif cmd == "getbalance": + try: + acct = raw_input("Enter an account (optional): ") + mc = raw_input("Minimum confirmations (optional): ") + try: + print access.getbalance(acct, mc) + except: + print access.getbalance() + except: + print "\n---An error occurred---\n" + +elif cmd == "getblockbycount": + try: + height = raw_input("Height: ") + print access.getblockbycount(height) + except: + print "\n---An error occurred---\n" + +elif cmd == "getblockcount": + try: + print access.getblockcount() + except: + print "\n---An error occurred---\n" + +elif cmd == "getblocknumber": + try: + print access.getblocknumber() + except: + print "\n---An error occurred---\n" + +elif cmd == "getconnectioncount": + try: + print access.getconnectioncount() + except: + print "\n---An error occurred---\n" + +elif cmd == "getdifficulty": + try: + print access.getdifficulty() + except: + print "\n---An error occurred---\n" + +elif cmd == "getgenerate": + try: + print access.getgenerate() + except: + print "\n---An error occurred---\n" + +elif cmd == "gethashespersec": + try: + print access.gethashespersec() + except: + print "\n---An error occurred---\n" + +elif cmd == "getinfo": + try: + print access.getinfo() + except: + print "\n---An error occurred---\n" + +elif cmd == "getnewaddress": + try: + acct = raw_input("Enter an account name: ") + try: + print access.getnewaddress(acct) + except: + print access.getnewaddress() + except: + print "\n---An error occurred---\n" + +elif cmd == "getreceivedbyaccount": + try: + acct = raw_input("Enter an account (optional): ") + mc = raw_input("Minimum confirmations (optional): ") + try: + print access.getreceivedbyaccount(acct, mc) + except: + print access.getreceivedbyaccount() + except: + print "\n---An error occurred---\n" + +elif cmd == "getreceivedbyaddress": + try: + addr = raw_input("Enter a SONO address (optional): ") + mc = raw_input("Minimum confirmations (optional): ") + try: + print access.getreceivedbyaddress(addr, mc) + except: + print access.getreceivedbyaddress() + except: + print "\n---An error occurred---\n" + +elif cmd == "gettransaction": + try: + txid = raw_input("Enter a transaction ID: ") + print access.gettransaction(txid) + except: + print "\n---An error occurred---\n" + +elif cmd == "getwork": + try: + data = raw_input("Data (optional): ") + try: + print access.gettransaction(data) + except: + print access.gettransaction() + except: + print "\n---An error occurred---\n" + +elif cmd == "help": + try: + cmd = raw_input("Command (optional): ") + try: + print access.help(cmd) + except: + print access.help() + except: + print "\n---An error occurred---\n" + +elif cmd == "listaccounts": + try: + mc = raw_input("Minimum confirmations (optional): ") + try: + print access.listaccounts(mc) + except: + print access.listaccounts() + except: + print "\n---An error occurred---\n" + +elif cmd == "listreceivedbyaccount": + try: + mc = raw_input("Minimum confirmations (optional): ") + incemp = raw_input("Include empty? (true/false, optional): ") + try: + print access.listreceivedbyaccount(mc, incemp) + except: + print access.listreceivedbyaccount() + except: + print "\n---An error occurred---\n" + +elif cmd == "listreceivedbyaddress": + try: + mc = raw_input("Minimum confirmations (optional): ") + incemp = raw_input("Include empty? (true/false, optional): ") + try: + print access.listreceivedbyaddress(mc, incemp) + except: + print access.listreceivedbyaddress() + except: + print "\n---An error occurred---\n" + +elif cmd == "listtransactions": + try: + acct = raw_input("Account (optional): ") + count = raw_input("Number of transactions (optional): ") + frm = raw_input("Skip (optional):") + try: + print access.listtransactions(acct, count, frm) + except: + print access.listtransactions() + except: + print "\n---An error occurred---\n" + +elif cmd == "move": + try: + frm = raw_input("From: ") + to = raw_input("To: ") + amt = raw_input("Amount:") + mc = raw_input("Minimum confirmations (optional): ") + comment = raw_input("Comment (optional): ") + try: + print access.move(frm, to, amt, mc, comment) + except: + print access.move(frm, to, amt) + except: + print "\n---An error occurred---\n" + +elif cmd == "sendfrom": + try: + frm = raw_input("From: ") + to = raw_input("To: ") + amt = raw_input("Amount:") + mc = raw_input("Minimum confirmations (optional): ") + comment = raw_input("Comment (optional): ") + commentto = raw_input("Comment-to (optional): ") + try: + print access.sendfrom(frm, to, amt, mc, comment, commentto) + except: + print access.sendfrom(frm, to, amt) + except: + print "\n---An error occurred---\n" + +elif cmd == "sendmany": + try: + frm = raw_input("From: ") + to = raw_input("To (in format address1:amount1,address2:amount2,...): ") + mc = raw_input("Minimum confirmations (optional): ") + comment = raw_input("Comment (optional): ") + try: + print access.sendmany(frm,to,mc,comment) + except: + print access.sendmany(frm,to) + except: + print "\n---An error occurred---\n" + +elif cmd == "sendtoaddress": + try: + to = raw_input("To (in format address1:amount1,address2:amount2,...): ") + amt = raw_input("Amount:") + comment = raw_input("Comment (optional): ") + commentto = raw_input("Comment-to (optional): ") + try: + print access.sendtoaddress(to,amt,comment,commentto) + except: + print access.sendtoaddress(to,amt) + except: + print "\n---An error occurred---\n" + +elif cmd == "setaccount": + try: + addr = raw_input("Address: ") + acct = raw_input("Account:") + print access.setaccount(addr,acct) + except: + print "\n---An error occurred---\n" + +elif cmd == "setgenerate": + try: + gen= raw_input("Generate? (true/false): ") + cpus = raw_input("Max processors/cores (-1 for unlimited, optional):") + try: + print access.setgenerate(gen, cpus) + except: + print access.setgenerate(gen) + except: + print "\n---An error occurred---\n" + +elif cmd == "settxfee": + try: + amt = raw_input("Amount:") + print access.settxfee(amt) + except: + print "\n---An error occurred---\n" + +elif cmd == "stop": + try: + print access.stop() + except: + print "\n---An error occurred---\n" + +elif cmd == "validateaddress": + try: + addr = raw_input("Address: ") + print access.validateaddress(addr) + except: + print "\n---An error occurred---\n" + +elif cmd == "walletpassphrase": + try: + pwd = raw_input("Enter wallet passphrase: ") + access.walletpassphrase(pwd, 60) + print "\n---Wallet unlocked---\n" + except: + print "\n---An error occurred---\n" + +elif cmd == "walletpassphrasechange": + try: + pwd = raw_input("Enter old wallet passphrase: ") + pwd2 = raw_input("Enter new wallet passphrase: ") + access.walletpassphrasechange(pwd, pwd2) + print + print "\n---Passphrase changed---\n" + except: + print + print "\n---An error occurred---\n" + print + +else: + print "Command not found or not supported" diff --git a/contrib/gitian-descriptors/README b/contrib/gitian-descriptors/README new file mode 100644 index 0000000..513cb2f --- /dev/null +++ b/contrib/gitian-descriptors/README @@ -0,0 +1,265 @@ +/******************************************************************************* + + Resources: + +*******************************************************************************/ + +https://github.com/bitcoin/bitcoin/blob/master/doc/gitian-building.md#setting-up-debian-for-gitian-building + + + +/******************************************************************************* + + Part 1: Preparing the virtual machine + +*******************************************************************************/ + + +Download a 64bit debian netinstall iso from: +https://www.debian.org/CD/netinst/#netinst-stable + +$ wget http://cdimage.debian.org/debian-cd/8.2.0/amd64/iso-cd/debian-8.2.0-amd64-netinst.iso + + + +Create a new VirtualBox VM + +Name: gitianbuild +Type: Linux (64bit) +Version: Debian + +Memory: 1400MB or more +Hard Drive: Create a virtual hard drive now +Hard drive file type: VDI ( Virtualbox disk image ) +Storage on physical hard drive : Dynamically allocated +File location and size: 40GB (20GB should work) + + + +Click the Settings button, then go to the Network tab. +Adapter 1 should be attached to NAT + +Click Advanced, then Port Forwarding. +We want to set up a port through which we can reach the +VM to get files in and out. +Create a new rule by clicking the plus icon. + +Set up the new rule the following way: + Name: SSH + Protocol: TCP + Leave Host IP empty + Host Port: 22222 + Leave Guest IP empty + Guest Port: 22 + +Click Ok twice to save. + +Start the VM. +On the first launch you will be asked for a CD or DVD image. +Choose the downloaded iso. + +Choose the non-graphical installer. +Choose locale and keyboard settings +The VM should detect network settings using DHCP +Configure the network: + System name: debian. + Leave domain name empty. + +Choose a root password and enter it twice (remember it for later) + +Name the new user debian (the full name doesn't matter) +Choose a user password and enter it twice (remember it for later) + +The installer will set up the clock using a time server; +Set up the clock: choose a time zone +(depends on the locale settings that you picked earlier; +specifics don't matter) + +Disk setup +Partitioning method: Guided - Use the entire disk + +Select disk to partition: SCSI1 (0,0,0) +Partitioning scheme: All files in one partition +Finish partitioning and write changes to disk -> Yes + + +The base system will be installed, this will take a minute or so +Choose a mirror (any will do) + +Enter proxy information (unless you're on an intranet, you can leave this empty) + + +Wait a bit while 'Select and install software' runs +Participate in popularity contest -> No +Choose software to install. We need just the base system. +Make sure only 'SSH server' and 'Standard System Utilities' are checked. +Uncheck 'Debian Desktop Environment' and 'Print Server' + + +Install the GRUB boot loader to the master boot record? -> Yes +Select sda + + +Installation Complete -> Continue +After installation, the VM will reboot and you will have a working Debian +VM. + +Congratulations! + + +On your debian virtual machine log in as root and run the following commands +to get the show on the road. + +Install base packages: +# apt-get install git ruby sudo apt-cacher-ng qemu-utils debootstrap lxc python-cheetah parted kpartx bridge-utils + +Add the gitian user to the superusers list: +# adduser gitian sudo + + + +/******************************************************************************* + + Part 2: Gitian setup + +*******************************************************************************/ + + +From your host machine ssh into the virtual machine: + +$ ssh gitian@localhost -p 22222 + +Switch to root user: +$ sudo su + +Run the following commands, +Or add them to a script and execute it: + +# make sure the build script can execute it without providing a password +echo "gitian ALL=NOPASSWD: /usr/bin/lxc-start" > /etc/sudoers.d/gitian-lxc +# add cgroup for LXC +echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab +# make /etc/rc.local script that sets up bridge between guest and host +# For debian users (Ubuntu can ignore, check LXC_BRIDGE): +echo '#!/bin/sh -e' /etc/rc.local +echo 'brctl addbr br0' >> /etc/rc.local +echo 'ifconfig br0 10.0.3.2/24 up' >> /etc/rc.local +echo 'exit 0' >> /etc/rc.local + +# make sure that USE_LXC is always set when logging in as gitian, +# and configure LXC IP addresses +echo 'export USE_LXC=1' >> ~/.profile +echo 'export GITIAN_HOST_IP=10.0.3.1' >> ~/.profile +echo 'export LXC_GUEST_IP=10.0.3.5' >> ~/.profile +#echo 'export LXC_BRIDGE=lxcbr0' >> ~/.profile # Ubuntu users only +echo 'LXC_EXECUTE=lxc-execute' >> ~/.profile +echo 'PATH="$HOME/gitian-builder/libexec/:$PATH";' >> ~/.profile + +reboot + +login again: +$ ssh debian@localhost -p 22222 + +$ git clone https://github.com/devrandom/gitian-builder.git +$ git clone https://github.com/SONO/SONO.git SONO + +$ cd gitian-builder + +$ ./bin/make-base-vm --lxc --arch amd64 --suite trusty +$ ./bin/make-base-vm --lxc --arch i386 --suite trusty + +$ mkdir inputs; +$ cd inputs; +$ cp ../../SONO/libs/secp256k1-master.zip . +$ wget http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.9.20151008.tar.gz -Ominiupnpc-1.9.20151008.tar.gz; +$ wget http://download.icu-project.org/files/icu4c/55.1/icu4c-55_1-src.tgz; +$ wget http://download.oracle.com/berkeley-db/db-6.1.26.NC.tar.gz; +$ wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.18.tar.xz; +$ wget http://zlib.net/zlib-1.2.8.tar.gz; +$ wget https://fukuchi.org/works/qrencode/qrencode-3.4.4.tar.gz +$ wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.bz2/download -Oboost_1_59_0.tar.bz2; +$ wget https://svn.boost.org/trac/boost/raw-attachment/ticket/7262/boost-mingw.patch +$ wget http://www.openssl.org/source/openssl-1.0.2d.tar.gz +$ wget http://download.qt.io/archive/qt/5.5/5.5.0/single/qt-everywhere-opensource-src-5.5.0.tar.xz; + + + +/******************************************************************************* + + Part 3: Compile + +*******************************************************************************/ + +$ cd ~/gitian-builder; +$ LXC_EXECUTE=lxc-execute; PATH="$(pwd)/libexec/:$PATH"; + +$ ./bin/gbuild --commit SONO=HEAD ../SONO/contrib/gitian-descriptors/deps-linux.yml +$ mv build/out/SONO-deps-*.zip inputs/ + +$ ./bin/gbuild --commit SONO=HEAD ../SONO/contrib/gitian-descriptors/gitian-linux.yml +$ mkdir -p ../compiled/linux +$ mv build/out/* ../compiled/linux/ + +$ ./bin/gbuild --commit SONO=HEAD ../SONO/contrib/gitian-descriptors/deps-win.yml +$ mv build/out/SONO-deps-*.zip inputs/ + +$ ./bin/gbuild --commit SONO=HEAD ../SONO/contrib/gitian-descriptors/qt-win.yml +$ mv build/out/qt-win*.zip inputs/ + +$ ./bin/gbuild --commit SONO=HEAD ../SONO/contrib/gitian-descriptors/gitian-win.yml +$ mkdir -p ../compiled/win +$ mv build/out/* ../compiled/win/ + + + +/******************************************************************************* + + Notes: + +*******************************************************************************/ + +Check the progress of the script: + login to the vm on a new terminal (ssh debian@localhost -p 22222) + cd gitian-builder + tail -f ~/gitian-builder/var/install.log + or + tail -f ~/gitian-builder/var/build.log + +Reuse last container image: + use guild with -i + + + +Gavin's notes on getting gitian builds up and running: + +You need the right hardware: you need a 64-bit-capable CPU with hardware virtualization support (Intel VT-x or AMD-V). Not all modern CPUs support hardware virtualization. + +You probably need to enable hardware virtualization in your machine's BIOS. + +You need to be running a recent version of 64-bit-Ubuntu, and you need to install several prerequisites: + sudo apt-get install apache2 git apt-cacher-ng python-vm-builder qemu-kvm + +Sanity checks: + sudo service apt-cacher-ng status # Should return apt-cacher-ng is running + ls -l /dev/kvm # Should show a /dev/kvm device + +Once you've got the right hardware and software: + + git clone git://github.com/bitcoin/bitcoin.git + git clone git://github.com/devrandom/gitian-builder.git + mkdir gitian-builder/inputs + wget 'http://miniupnp.tuxfamily.org/files/download.php?file=miniupnpc-1.6.tar.gz' -O gitian-builder/inputs/miniupnpc-1.6.tar.gz + + cd gitian-builder + bin/make-base-vm --arch i386 + bin/make-base-vm --arch amd64 + cd .. + + # To build + cd bitcoin + git pull + cd ../gitian-builder + git pull + ./bin/gbuild --commit bitcoin=HEAD ../bitcoin/contrib/gitian.yml + + diff --git a/contrib/gitian-descriptors/deps-linux.yml b/contrib/gitian-descriptors/deps-linux.yml new file mode 100644 index 0000000..cb6c00e --- /dev/null +++ b/contrib/gitian-descriptors/deps-linux.yml @@ -0,0 +1,139 @@ +--- +name: "SONO-deps" +suites: +- "trusty" +architectures: +- "i386" +- "amd64" +packages: +- "g++" +- "unzip" +- "zip" +- "pkg-config" +- "libtool" +- "faketime" +- "bsdmainutils" +- "automake" +- "autoconf" +reference_datetime: "2013-06-01 00:00:00" +remotes: [] +files: +- "openssl-1.0.2d.tar.gz" +- "miniupnpc-1.9.20151008.tar.gz" +- "db-6.1.26.NC.tar.gz" +- "zlib-1.2.8.tar.gz" +- "libpng-1.6.18.tar.xz" +- "boost_1_59_0.tar.bz2" +- "secp256k1-master.zip" +- "qrencode-3.4.4.tar.gz" +script: | + STAGING="$HOME/install" + TEMPDIR="$HOME/tmp" + OPTFLAGS='-O2' + if [ "$GBUILD_BITS" == "32" ]; then + export LD_PRELOAD=/usr/lib/i386-linux-gnu/faketime/libfaketime.so.1; + else + export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1; + fi + export FAKETIME=$REFERENCE_DATETIME + export TZ=UTC + export LIBRARY_PATH="$STAGING/lib" + # Integrity Check + echo "3da5b3c572741fe2237bee1c3d36b11beef61172ac847132b045548b98d4df29 secp256k1-master.zip" | sha256sum -c + echo "e444ac3b587ce82709c4d0cfca1fe71f44f9fc433e9f946b12b9e1bfe667a633 miniupnpc-1.9.20151008.tar.gz" | sha256sum -c + echo "060105bda482fdfb109b88c05b69624e9d467d59fa30fd9a97225efcc38d1561 db-6.1.26.NC.tar.gz" | sha256sum -c + echo "36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d zlib-1.2.8.tar.gz" | sha256sum -c + echo "2e10c13b7949883ac961db6177c516d778184432d440317e9f0391305c360963 libpng-1.6.18.tar.xz" | sha256sum -c + echo "727a932322d94287b62abb1bd2d41723eec4356a7728909e38adb65ca25241ca boost_1_59_0.tar.bz2" | sha256sum -c + echo "671c36487785628a703374c652ad2cebea45fa920ae5681515df25d9f2c9a8c8 openssl-1.0.2d.tar.gz" | sha256sum -c + echo "e794e26a96019013c0e3665cb06b18992668f352c5553d0a553f5d144f7f2a72 qrencode-3.4.4.tar.gz" | sha256sum -c + mkdir -p "$STAGING" + # + tar xzf openssl-1.0.2d.tar.gz + cd openssl-1.0.2d + # need -fPIC to avoid relocation error in 64 bit builds + ./config no-shared no-zlib no-dso no-krb5 --openssldir=$STAGING -fPIC + # need to build OpenSSL with faketime because a timestamp is embedded into cversion.o + make + make install_sw + cd .. + # + + tar xzfm miniupnpc-1.9.20151008.tar.gz + cd miniupnpc-1.9.20151008 + # miniupnpc is always built with -fPIC + INSTALLPREFIX=$STAGING make $MAKEOPTS install + rm -f $STAGING/lib/libminiupnpc.so* # no way to skip shared lib build + cd .. + # + # + tar xzf db-6.1.26.NC.tar.gz + cd db-6.1.26.NC/build_unix + # need --with-pic to avoid relocation error in 64 bit builds + ../dist/configure --prefix=$STAGING --enable-cxx --disable-shared --with-pic + # Workaround to prevent re-configuring by make; make all files have a date in the past + find . -print0 | xargs -r0 touch -t 200001010000 + make $MAKEOPTS library_build + make install_lib install_include + cd ../.. + # + tar --warning=no-timestamp -xjf boost_1_59_0.tar.bz2 + cd boost_1_59_0 + GCCVERSION=$(g++ -E -dM $(mktemp --suffix=.h) | grep __VERSION__ | cut -d ' ' -f 3 | cut -d '"' -f 2) + # note: bjam with -d+2 reveals that -O3 is implied by default, no need to provide it in cxxflags + echo "using gcc : $GCCVERSION : g++ + : + \"-frandom-seed=boost1 -fPIC\" + ;" > user-config.jam + ./bootstrap.sh --without-icu + ./bjam toolset=gcc threadapi=pthread threading=multi variant=release link=static runtime-link=shared --user-config=user-config.jam --without-mpi --without-python -sNO_BZIP2=1 --layout=tagged --build-type=complete --prefix="$STAGING" $MAKEOPTS -d+2 install + cd .. + # + unzip -o secp256k1-master.zip + cd secp256k1-master + unset FAKETIME # unset fake time during configure, as it does some clock sanity tests + ./autogen.sh + ./configure --prefix=$STAGING + # Workaround to prevent re-configuring by make; make all files have a date in the past + find . -print0 | xargs -r0 touch -t 200001010000 + export FAKETIME=$REFERENCE_DATETIME + make install + cd .. + # + #tar xzf zlib-1.2.8.tar.gz + #cd zlib-1.2.8 + #touch configure -d $REFERENCE_DATETIME + #./configure --prefix=$STAGING + #make install + #cd .. + # + #tar xf libpng-1.6.18.tar.xz + #cd libpng-1.6.18 + #touch configure -d $REFERENCE_DATETIME + #./configure --prefix=$STAGING --with-zlib-prefix=$STAGING + #make install + #cd .. + # + tar xzf qrencode-3.4.4.tar.gz + cd qrencode-3.4.4 + unset FAKETIME # unset fake time during configure, as it does some clock sanity tests + ./configure --prefix=$STAGING --enable-static --disable-shared --with-pic --without-tools --disable-dependency-tracking + # Workaround to prevent re-configuring by make; make all files have a date in the past + find . -print0 | xargs -r0 touch -t 200001010000 + export FAKETIME=$REFERENCE_DATETIME + make $MAKEOPTS install + cd .. + # + # post-process all generated libraries to be deterministic + # extract them to a temporary directory then re-build them deterministically + for LIB in $(find $STAGING -name \*.a); do + rm -rf $TEMPDIR && mkdir $TEMPDIR && cd $TEMPDIR + ar xv $LIB | cut -b5- > /tmp/list.txt + rm $LIB + ar crsD $LIB $(cat /tmp/list.txt) + done + # + # + cd $STAGING + find include lib bin host | sort | zip -X@ $OUTDIR/SONO-deps-linux${GBUILD_BITS}-gitian.zip + diff --git a/contrib/gitian-descriptors/deps-osx.yml b/contrib/gitian-descriptors/deps-osx.yml new file mode 100644 index 0000000..2f92275 --- /dev/null +++ b/contrib/gitian-descriptors/deps-osx.yml @@ -0,0 +1,138 @@ +--- +name: "SONO-deps" +suites: +- "trusty" +architectures: +- "amd64" +packages: +- "git-core" +- "clang" +- "llvm-dev" +- "zip" +- "faketime" +- "psmisc" +reference_datetime: "2011-01-30 00:00:00" +remotes: [] +files: +- "openssl-1.0.2d.tar.gz" +- "miniupnpc-1.9.20151008.tar.gz" +- "db-6.1.26.NC.tar.gz" +- "zlib-1.2.8.tar.gz" +- "libpng-1.6.18.tar.xz" +- "boost_1_59_0.tar.bz2" +- "secp256k1-master.zip" +- "qrencode-3.4.4.tar.gz" +- "icu4c-55_1-src.tgz" +- "osxcross.tar.xz" +script: | + # + # Input Integrity Check + echo "3da5b3c572741fe2237bee1c3d36b11beef61172ac847132b045548b98d4df29 secp256k1-master.zip" | sha256sum -c + echo "e444ac3b587ce82709c4d0cfca1fe71f44f9fc433e9f946b12b9e1bfe667a633 miniupnpc-1.9.20151008.tar.gz" | sha256sum -c + echo "060105bda482fdfb109b88c05b69624e9d467d59fa30fd9a97225efcc38d1561 db-6.1.26.NC.tar.gz" | sha256sum -c + echo "36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d zlib-1.2.8.tar.gz" | sha256sum -c + echo "2e10c13b7949883ac961db6177c516d778184432d440317e9f0391305c360963 libpng-1.6.18.tar.xz" | sha256sum -c + echo "727a932322d94287b62abb1bd2d41723eec4356a7728909e38adb65ca25241ca boost_1_59_0.tar.bz2" | sha256sum -c + echo "671c36487785628a703374c652ad2cebea45fa920ae5681515df25d9f2c9a8c8 openssl-1.0.2d.tar.gz" | sha256sum -c + echo "e794e26a96019013c0e3665cb06b18992668f352c5553d0a553f5d144f7f2a72 qrencode-3.4.4.tar.gz" | sha256sum -c + # + export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1 + export FAKETIME=$REFERENCE_DATETIME + export TZ=UTC + BUILDDIR=$HOME/build + INSTALLPREFIX=$HOME/install + TEMPDIR=$HOME/tmp + DEPSDIR=$HOME/deps + SDK=$DEPSDIR/SDK/MacOSX10.9.sdk + HOST=x86_64-apple-darwin13 + MIN_VERSION=10.6 + # + mkdir -p $INSTALLPREFIX $BUILDDIR $DEPSDIR + cd $DEPSDIR + tar xf $BUILDDIR/osxcross.tar.xz + PATH=$PATH:$DEPSDIR/bin + # + cd $BUILDDIR + tar xzf openssl-1.0.2d.tar.gz + cd openssl-1.0.2d + CC=cc ./Configure --cross-compile-prefix=$HOST- darwin64-x86_64-cc no-shared no-dso --openssldir=$INSTALLPREFIX + make + make install_sw + # + cd $BUILDDIR + tar xzf db-6.1.26.NC.tar.gz + cd db-6.1.26.NC/build_unix + ../dist/configure --prefix=$INSTALLPREFIX --enable-cxx --host=$HOST --disable-shared --disable-replication + make $MAKEOPTS library_build + make install_lib install_include + # + cd $BUILDDIR + tar xzf miniupnpc-1.9.20151008.tar.gz + cd miniupnpc-1.9.20151008 + make -f Makefile OS=Darwin CC=$HOST-cc AR=$HOST-ar libminiupnpc.a + install -d $INSTALLPREFIX/include/miniupnpc + install *.h $INSTALLPREFIX/include/miniupnpc + install libminiupnpc.a $INSTALLPREFIX/lib + # + cd $BUILDDIR + tar xzf zlib-1.2.8.tar.gz + cd zlib-1.2.8 + CROSS_PREFIX=$HOST- ./configure --prefix=$INSTALLPREFIX --static + make + make install + # + cd $BUILDDIR + tar xf libpng-1.6.18.tar.xz + cd libpng-1.6.18 + CPPFLAGS="-I$INSTALLPREFIX/include" CFLAGS="-I$INSTALLPREFIX/include" LDFLAGS="-L$INSTALLPREFIX/lib" ./configure --disable-shared --prefix=$INSTALLPREFIX --host=$HOST + make $MAKEOPTS + make install + # + cd $BUILDDIR + tar xfz qrencode-3.4.4.tar.gz + cd qrencode-3.4.4 + CPPFLAGS="-I$INSTALLPREFIX/include" CFLAGS="-I$INSTALLPREFIX/include" LDFLAGS="-L$INSTALLPREFIX/lib" ./configure --enable-static --disable-shared --without-tools --prefix=$INSTALLPREFIX --host=$HOST + make $MAKEOPTS + make install + # + cd $BUILDDIR + mkdir -p icuCross + cd icuCross + tar xzf $BUILDDIR/icu4c-55_1-src.tgz + cd icu/source + mkdir -p $TEMPDIR/icu + ./runConfigureICU MacOSX --prefix=$TEMPDIR/icu --enable-static --disable-shared + make + make install + #rm -rf icu + cd $BUILDDIR + tar xzf icu4c-55_1-src.tgz + cd icu/source + ./runConfigureICU MacOSX --host=$HOST --with-cross-build=$BUILDDIR/icuCross/icu/source --prefix=$INSTALLPREFIX --enable-static --disable-shared + make + make install + # + cd $BUILDDIR + tar --warning=no-timestamp -xjf boost_1_55_0.tar.bz2 + cd boost_1_55_0 + ./bootstrap.sh --with-libraries=chrono,filesystem,program_options,system,thread,test + echo "using darwin : : ${HOST}-clang++ + : + \"-target ${HOST} -mmacosx-version-min=${MIN_VERSION} --sysroot ${SDK} -msse2 -Qunused-arguments -I${INSTALLPREFIX}/include -DBOOST_HAS_INT128=1\" + \"-L${INSTALLPREFIX}/lib -B${DEPSDIR}/bin\" + \"${HOST}-libtool\" + \"${HOST}-strip\" : + ;" > user-config.jam + ./b2 -d2 --layout=tagged --build-type=complete --prefix="${INSTALLPREFIX}" --toolset=darwin-4.2.1 --user-config=user-config.jam variant=release threading=multi link=static install + # + # post-process all generated libraries to be deterministic + # extract them to a temporary directory then re-build them deterministically + #for LIB in $(find $INSTALLPREFIX -name \*.a); do + # rm -rf $TEMPDIR && mkdir $TEMPDIR && cd $TEMPDIR + # $HOST-ar xv $LIB | cut -b5- > /tmp/list.txt + # rm $LIB + # $HOST-ar crs $LIB $(cat /tmp/list.txt) + #done + # + cd $INSTALLPREFIX + find include lib | sort | zip -X@ $OUTDIR/SONO-deps-osx-gitian.zip diff --git a/contrib/gitian-descriptors/deps-win.yml b/contrib/gitian-descriptors/deps-win.yml new file mode 100644 index 0000000..ffdc3db --- /dev/null +++ b/contrib/gitian-descriptors/deps-win.yml @@ -0,0 +1,208 @@ +--- +name: "SONO-deps" +suites: +- "trusty" +architectures: +- "amd64" +packages: +- "mingw-w64" +- "g++-mingw-w64" +- "git-core" +- "zip" +- "unzip" +- "faketime" +- "psmisc" +- "libtool" +- "automake" +- "autoconf" +reference_datetime: "2013-06-01 00:00:00" +remotes: [] +files: +- "openssl-1.0.2d.tar.gz" +- "miniupnpc-1.9.20151008.tar.gz" +- "db-6.1.26.NC.tar.gz" +- "zlib-1.2.8.tar.gz" +- "libpng-1.6.18.tar.xz" +- "boost_1_59_0.tar.bz2" +- "secp256k1-master.zip" +- "qrencode-3.4.4.tar.gz" +- "icu4c-55_1-src.tgz" +- "boost-mingw.patch" +#- "qt-everywhere-opensource-src-5.5.0.tar.xz" +script: | +script: | + # + export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1 + export FAKETIME=$REFERENCE_DATETIME + export TZ=UTC + INDIR=$HOME/build + TEMPDIR=$HOME/tmp + # Input Integrity Check + echo "3da5b3c572741fe2237bee1c3d36b11beef61172ac847132b045548b98d4df29 secp256k1-master.zip" | sha256sum -c + echo "e444ac3b587ce82709c4d0cfca1fe71f44f9fc433e9f946b12b9e1bfe667a633 miniupnpc-1.9.20151008.tar.gz" | sha256sum -c + echo "060105bda482fdfb109b88c05b69624e9d467d59fa30fd9a97225efcc38d1561 db-6.1.26.NC.tar.gz" | sha256sum -c + echo "36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d zlib-1.2.8.tar.gz" | sha256sum -c + echo "2e10c13b7949883ac961db6177c516d778184432d440317e9f0391305c360963 libpng-1.6.18.tar.xz" | sha256sum -c + echo "727a932322d94287b62abb1bd2d41723eec4356a7728909e38adb65ca25241ca boost_1_59_0.tar.bz2" | sha256sum -c + echo "671c36487785628a703374c652ad2cebea45fa920ae5681515df25d9f2c9a8c8 openssl-1.0.2d.tar.gz" | sha256sum -c + echo "e794e26a96019013c0e3665cb06b18992668f352c5553d0a553f5d144f7f2a72 qrencode-3.4.4.tar.gz" | sha256sum -c + # + for BITS in 32 64; do # for architectures + # + INSTALLPREFIX=$HOME/staging${BITS} + BUILDDIR=$HOME/build${BITS} + if [ "$BITS" == "32" ]; then + HOST=i686-w64-mingw32 + else + HOST=x86_64-w64-mingw32 + fi + # + mkdir -p $BUILDDIR $INSTALLPREFIX/lib + cd $BUILDDIR + # + tar xzf $INDIR/openssl-1.0.2d.tar.gz + cd openssl-1.0.2d + if [ "$BITS" == "32" ]; then + OPENSSL_TGT=mingw + else + OPENSSL_TGT=mingw64 + fi + ./Configure --cross-compile-prefix=$HOST- ${OPENSSL_TGT} --prefix=$INSTALLPREFIX + make install + #make install_sw + cd .. + # + tar xzf $INDIR/db-6.1.26.NC.tar.gz + cd db-6.1.26.NC/build_unix + ../dist/configure --prefix=$INSTALLPREFIX --enable-mingw --enable-cxx --host=$HOST -disable-shared --disable-replication + # Workaround to prevent re-configuring by make; make all files have a date in the past + sed -i 's/WinIoCtl.h/winioctl.h/' ../src/dbinc/win_db.h + find . -print0 | xargs -r0 touch -t 200001010000 + make $MAKEOPTS #library_build + make install_lib install_include + cd ../.. + # + tar xzf $INDIR/miniupnpc-1.9.20151008.tar.gz + cd miniupnpc-1.9.20151008 + echo " + --- miniupnpc-1.9/Makefile.mingw.orig 2013-09-29 18:52:51.014087958 -1000 + +++ miniupnpc-1.9/Makefile.mingw 2013-09-29 19:09:29.663318691 -1000 + @@ -67,8 +67,8 @@ + + wingenminiupnpcstrings.o: wingenminiupnpcstrings.c + + -miniupnpcstrings.h: miniupnpcstrings.h.in wingenminiupnpcstrings + - wingenminiupnpcstrings \$< \$@ + +miniupnpcstrings.h: miniupnpcstrings.h.in + + sed -e 's|OS/version|MSWindows/5.1.2600|' -e 's|MINIUPNPC_VERSION_STRING \"version\"|MINIUPNPC_VERSION_STRING \"VERSIONHERE\"|' \$< > \$@ + + minixml.o: minixml.c minixml.h miniupnpcstrings.h + + " | sed "s/VERSIONHERE/$(cat VERSION)/" | patch -p1 + mkdir -p dll + # Workaround to prevent re-configuring by make; make all files have a date in the past + find . -print0 | xargs -r0 touch -t 200001010000 + make -f Makefile.mingw CC=$HOST-gcc AR=$HOST-ar libminiupnpc.a + install -d $INSTALLPREFIX/include/miniupnpc + install *.h $INSTALLPREFIX/include/miniupnpc + install libminiupnpc.a $INSTALLPREFIX/lib + cd .. + # + tar xzf $INDIR/zlib-1.2.8.tar.gz + cd zlib-1.2.8 + CROSS_PREFIX=$HOST- ./configure --prefix=$INSTALLPREFIX --static + make + make install + cd .. + # + tar xf $INDIR/libpng-1.6.18.tar.xz + cd libpng-1.6.18 + OPT="-O2" + CPPFLAGS="${OPT} -I$INSTALLPREFIX/include" CFLAGS="${OPT} -I$INSTALLPREFIX/include" LDFLAGS="${OPT} -L$INSTALLPREFIX/lib" ./configure --disable-shared --prefix=$INSTALLPREFIX --host=$HOST + make $MAKEOPTS + make install + cd .. + # + tar xfz $INDIR/qrencode-3.4.4.tar.gz + cd qrencode-3.4.4 + CPPFLAGS="${OPT} -I$INSTALLPREFIX/include" CFLAGS="${OPT} -I$INSTALLPREFIX/include" LDFLAGS="${OPT} -L$INSTALLPREFIX/lib" ./configure --enable-static --disable-shared --without-tools --prefix=$INSTALLPREFIX --host=$HOST + make $MAKEOPTS + make install + cd .. + # + mkdir -p icuCross + cd icuCross + tar xzf $INDIR/icu4c-55_1-src.tgz + cd icu/source + mkdir -p $TEMPDIR/icu + ./runConfigureICU MinGW --prefix=$TEMPDIR/icu --enable-static --disable-shared + make + make install + cd ../../.. + #rm -rf icu + tar xzf $INDIR/icu4c-55_1-src.tgz + cd icu/source + ./runConfigureICU MinGW --host=$HOST --with-cross-build=$BUILDDIR/icuCross/icu/source --prefix=$INSTALLPREFIX --enable-static --disable-shared + make + make install + cd ../.. + # + tar --warning=no-timestamp -xjf $INDIR/boost_1_59_0.tar.bz2 + cd boost_1_59_0 + GCCVERSION=$($HOST-g++ -E -dM $(mktemp --suffix=.h) | grep __VERSION__ | cut -d ' ' -f 3 | cut -d '"' -f 2) + echo "using gcc : $GCCVERSION : $HOST-g++ + : + $HOST-windres + $HOST-ar + -frandom-seed=boost1 + $HOST-ranlib + ;" > user-config.jam + ./bootstrap.sh --without-icu + # Workaround: Upstream boost dev refuses to include patch that would allow Free Software cross-compile toolchain to work + # This patch was authored by the Fedora package developer and ships in Fedora's mingw32-boost. + # Please obtain the exact patch that matches the above sha256sum from one of the following mirrors. + # + # Read History: https://svn.boost.org/trac/boost/ticket/7262 + # History Mirror: http://rose.makesad.us/~paulproteus/mirrors/7262%20Boost.Context%20fails%20to%20build%20using%20MinGW.html + # + # Patch: https://svn.boost.org/trac/boost/raw-attachment/ticket/7262/boost-mingw.patch + # Patch Mirror: http://wtogami.fedorapeople.org/boost-mingw-gas-cross-compile-2013-03-03.patch + # Patch Mirror: http://mindstalk.net/host/boost-mingw-gas-cross-compile-2013-03-03.patch + # Patch Mirror: http://rose.makesad.us/~paulproteus/mirrors/boost-mingw-gas-cross-compile-2013-03-03.patch + #patch -p0 < $INDIR/boost-mingw.patch + # Bug Workaround: boost-1.54.0 broke the ability to disable zlib, still broken in 1.55 + # https://svn.boost.org/trac/boost/ticket/9156 + sed -i 's^\[ ac.check-library /zlib//zlib : /zlib//zlib^^' libs/iostreams/build/Jamfile.v2 + sed -i 's^zlib.cpp gzip.cpp \]^^' libs/iostreams/build/Jamfile.v2 + # http://statmt.org/~s0565741/software/boost_1_52_0/libs/context/doc/html/context/requirements.html + # Workaround: Upstream boost dev refuses to include patch that would allow Free Software cross-compile toolchain to work + # This patch was authored by the Fedora package developer and ships in Fedora's mingw32-boost. + # Please obtain the exact patch that matches the above sha256sum from one of the following mirrors. + # + # Read History: https://svn.boost.org/trac/boost/ticket/7262 + # History Mirror: http://rose.makesad.us/~paulproteus/mirrors/7262%20Boost.Context%20fails%20to%20build%20using%20MinGW.html + # + # Patch: https://svn.boost.org/trac/boost/raw-attachment/ticket/7262/boost-mingw.patch + # Patch Mirror: http://wtogami.fedorapeople.org/boost-mingw-gas-cross-compile-2013-03-03.patch + # Patch Mirror: http://mindstalk.net/host/boost-mingw-gas-cross-compile-2013-03-03.patch + # Patch Mirror: http://rose.makesad.us/~paulproteus/mirrors/boost-mingw-gas-cross-compile-2013-03-03.patch + patch -p0 < $INDIR/boost-mingw.patch + # "For cross-compiling the lib you must specify certain additional properties at bjam command line: target-os, abi, binary-format, architecture and address-model." + ./bjam toolset=gcc binary-format=pe target-os=windows threadapi=win32 address-model=$BITS threading=multi variant=release link=static runtime-link=static --user-config=user-config.jam --without-mpi --without-python -sNO_BZIP2=1 -sNO_ZLIB=1 --layout=tagged --build-type=complete --prefix="$INSTALLPREFIX" $MAKEOPTS install + cd .. + # + unzip -o $INDIR/secp256k1-master.zip + cd secp256k1-master + unset FAKETIME # unset fake time during configure, as it does some clock sanity tests + ./autogen.sh + #LDFLAGS="-no-undefined" + ./configure --prefix=$INSTALLPREFIX --host=$HOST + # Workaround to prevent re-configuring by make; make all files have a date in the past + find . -print0 | xargs -r0 touch -t 200001010000 + export FAKETIME=$REFERENCE_DATETIME + make install + # + cd $INSTALLPREFIX + find -print0 | xargs -r0 touch # fix up timestamps before packaging + find include lib | sort | zip -X@ $OUTDIR/SONO-deps-win$BITS-gitian.zip + done # for BITS in diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml new file mode 100644 index 0000000..ec4ba11 --- /dev/null +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -0,0 +1,63 @@ +--- +name: "SONO" +suites: +- "trusty" +architectures: +- "i386" +- "amd64" +packages: +- "g++" +- "qt5-qmake" +- "qt5-default" +- "qttools5-dev-tools" +- "git-core" +- "unzip" +- "pkg-config" +- "libtool" +- "automake" +- "faketime" +- "bsdmainutils" +reference_datetime: "2015-05-25 00:00:00" +remotes: +- "url": "https://github.com/SONO/SONO.git" + "dir": "SONO" +files: +- "SONO-deps-linux32-gitian.zip" +- "SONO-deps-linux64-gitian.zip" +script: | + echo "6324ba3b1d571dc833528bf13efd5534a28fb35b59885543533cc7ec018d969b SONO-deps-linux32-gitian.zip" | sha256sum -c + echo "713f164feb9fab5d200c8587e04a4ac53cbab78ddada6022d80895372e684ecd SONO-deps-linux64-gitian.zip" | sha256sum -c + STAGING="$HOME/install" + OPTFLAGS='-O2' + BINDIR="${OUTDIR}/bin/${GBUILD_BITS}" # 32/64 bit build specific output directory + TEMPDIR="$HOME/tempdir" + if [ "$GBUILD_BITS" == "32" ]; then + export LD_PRELOAD=/usr/lib/i386-linux-gnu/faketime/libfaketime.so.1; + else + export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1; + fi + export FAKETIME=$REFERENCE_DATETIME + export TZ=UTC + export LIBRARY_PATH="$STAGING/lib" + mkdir -p ${BINDIR} + # + mkdir -p $STAGING + cd $STAGING + unzip ../build/SONO-deps-linux${GBUILD_BITS}-gitian.zip + cd ../build + # + cd SONO + mkdir -p $OUTDIR/src + git archive HEAD | tar -x -C $OUTDIR/src + cp $OUTDIR/src/doc/README $OUTDIR + cp $OUTDIR/src/COPYING $OUTDIR + cd src + cp -r crypto obj + make -f makefile.unix STATIC=1 USE_NATIVE_I2P=1 OPENSSL_INCLUDE_PATH="$STAGING/include" OPENSSL_LIB_PATH="$STAGING/lib" $MAKEOPTS SONOd USE_UPNP=1 BOOST_LIB_SUFFIX="-mt" DEBUGFLAGS= + mkdir -p $STAGING/bin/$GBUILD_BITS + install -s SONOd $OUTDIR/bin/$GBUILD_BITS + # + cd .. + qmake INCLUDEPATH="$STAGING/include" LIBS="-L$STAGING/lib" BOOST_LIB_SUFFIX="-mt" RELEASE=1 USE_QRCODE=1 USE_NATIVE_I2P=1 + make $MAKEOPTS + install SONO $OUTDIR/bin/$GBUILD_BITS diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml new file mode 100644 index 0000000..59867fa --- /dev/null +++ b/contrib/gitian-descriptors/gitian-osx.yml @@ -0,0 +1,88 @@ +--- +name: "SONO" +suites: +- "trusty" +architectures: +- "amd64" +packages: +- "git-core" +- "clang" +- "llvm-dev" +- "unzip" +- "zip" +- "nsis" +- "faketime" +- "autoconf2.13" +- "libtool" +- "automake" +- "pkg-config" +- "bsdmainutils" +- "python" +- "genisoimage" +reference_datetime: "2013-06-01 00:00:00" +remotes: +- "url": "https://github.com/SONO/SONO.git" + "dir": "SONO" +files: +- "qt-osx-5.5.0-gitian.tar.xz" +- "SONO-deps-osx-gitian.zip" +- "osxcross.tar.xz" +script: | + # Defines + export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1 + export FAKETIME=$REFERENCE_DATETIME + export TZ=UTC + INDIR=$HOME/build + OPTFLAGS='-O2' + TEMPDIR="$HOME/tempdir" + BUILDDIR=$HOME/build + DEPSDIR=$HOME/deps + HOST=x86_64-apple-darwin13 + DISTNAME=x86_64-darwin + export PATH=$DEPSDIR/host/bin:$DEPSDIR:$DEPSDIR/bin:$PATH + NEEDDIST=1 + # Qt: workaround for determinism in resource ordering + # Qt5's rcc uses a QHash to store the files for the resource. + # A security fix in QHash makes the ordering of keys to be different on every run + # (https://qt.gitorious.org/qt/qtbase/commit/c01eaa438200edc9a3bbcd8ae1e8ded058bea268). + # This is good in general but qrc shouldn't be doing a traversal over a randomized container. + # The thorough solution would be to use QMap instead of QHash, but this requires patching Qt. + # For now luckily there is a test mode that forces a fixed seed. + export QT_RCC_TEST=1 + mkdir -p $BUILDDIR $BINDIR $DEPSDIR + cd $DEPSDIR + unzip -o $BUILDDIR/SONO-deps-osx-gitian.zip + tar xf $BUILDDIR/osxcross.tar.xz + mkdir -p $HOME/install + cd $HOME/install + tar xf $BUILDDIR/qt-osx-5.5.0-gitian.tar.xz + # + cd $BUILDDIR/SONO + mkdir -p $OUTDIR/src + git archive HEAD | tar -x -C $OUTDIR/src + cp $OUTDIR/src/doc/README $OUTDIR/readme.txt + cp $OUTDIR/src/COPYING $OUTDIR/COPYING.txt + # + #cd src + #make -f makefile.linux-mingw HOST="$HOST" DEPSDIR="$DEPSDIR" CURDIR="$BUILDDIR/SONO/src" STATIC=1 $MAKEOPTS USE_UPNP=1 BOOST_LIB_SUFFIX="-mt-s" DEBUGFLAGS= + #cp SONO $BINDIR/ + #cd .. + # + #$DEPSDIR/qt/host/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/lib BOOST_INCLUDE_PATH=$HOME/build/include BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.1h OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.1h/include INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=bitcoin USE_BUILD_INFO=1 + ~/install/host/bin/qmake -xplatform macx-clang-linux RELEASE=1 QMAKE_LRELEASE="~/install/host/bin/lrelease" MINIUPNPC_LIB_PATH="$DEPSDIR/lib" MINIUPNPC_INCLUDE_PATH="$DEPSDIR/include" BDB_LIB_PATH="$DEPSDIR/lib" BDB_INCLUDE_PATH="$DEPSDIR/include" BOOST_LIB_PATH="$DEPSDIR/lib" BOOST_INCLUDE_PATH="$DEPSDIR/include" BOOST_LIB_SUFFIX="-mt-s" BOOST_THREAD_LIB_SUFFIX="-mt-s" OPENSSL_LIB_PATH="$DEPSDIR/lib" OPENSSL_INCLUDE_PATH="$DEPSDIR/include" INCLUDEPATH="$DEPSDIR/include" DEFINES="BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 USE_BUILD_INFO=1" QMAKE_CXXFLAGS+=" -I/home/ubuntu/deps/SDK/MacOSX10.9.sdk/usr/include -DBOOST_HAS_INT128=1 -frandom-seed=SONO" + make $MAKEOPTS + # macdeploy: TODO: .dmg + export OTOOL=${HOST}-otool + export INSTALLNAMETOOL=${HOST}-install_name_tool + export STRIP=${HOST}-strip + chmod +x contrib/macdeploy/macdeployqtplus + OTOOL=${HOST}-otool INSTALLNAMETOOL=${HOST}-install_name_tool STRIP=${HOST}-strip contrib/macdeploy/macdeployqtplus SONO-Qt.app + mkdir -p dist/.background + install contrib/macdeploy/background.png dist/.background + install contrib/macdeploy/DS_Store dist/.DS_Store + cd dist + ln -sf /Applications Applications + cd .. + genisoimage -no-cache-inodes -l -probe -V "SONO-Qt" -no-pad -r -apple -o Shadow.tmp.dmg dist + dmg dmg SONO-Qt.tmp.dmg $OUTDIR/SONO.dmg + # diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml new file mode 100644 index 0000000..1065a21 --- /dev/null +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -0,0 +1,103 @@ +--- +name: "SONO" +suites: +- "trusty" +architectures: +- "amd64" +packages: +- "mingw-w64" +- "g++-mingw-w64" +- "git-core" +- "unzip" +- "zip" +- "nsis" +- "faketime" +- "autoconf2.13" +- "libtool" +- "automake" +- "pkg-config" +- "bsdmainutils" +reference_datetime: "2013-06-01 00:00:00" +remotes: +- "url": "https://github.com/rynomster/SONO.git" + "dir": "SONO" +files: +- "qt-win32-5.5.0-gitian.zip" +- "qt-win64-5.5.0-gitian.zip" +- "SONO-deps-win32-gitian.zip" +- "SONO-deps-win64-gitian.zip" +script: | + # Defines + export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1 + export FAKETIME=$REFERENCE_DATETIME + export TZ=UTC + INDIR=$HOME/build + OPTFLAGS='-O2' + TEMPDIR="$HOME/tempdir" + echo "2d4fafbd04d5e233416c83c618dda2f111891f995eba585cc0a2ea637d0b3be2 qt-win32-5.5.0-gitian.zip" | sha256sum -c + echo "130685a66c344e53b131aa7cfac77f7796c6e113563bfd37eeb3cfd7c7fb4f08 qt-win64-5.5.0-gitian.zip" | sha256sum -c + echo "1cf99b3e264725580fd0f22ef36afbf96d3da0d5f659057e7100089b96a18ece SONO-deps-win32-gitian.zip" | sha256sum -c + echo "76e769fc3147dc819c4495839b7a5270fd058658bf1ef1adba22394b4f465ccb SONO-deps-win64-gitian.zip" | sha256sum -c + NEEDDIST=1 + # Qt: workaround for determinism in resource ordering + # Qt5's rcc uses a QHash to store the files for the resource. + # A security fix in QHash makes the ordering of keys to be different on every run + # (https://qt.gitorious.org/qt/qtbase/commit/c01eaa438200edc9a3bbcd8ae1e8ded058bea268). + # This is good in general but qrc shouldn't be doing a traversal over a randomized container. + # The thorough solution would be to use QMap instead of QHash, but this requires patching Qt. + # For now luckily there is a test mode that forces a fixed seed. + export QT_RCC_TEST=1 + for BITS in 32 64; do # for architectures + # + STAGING=$HOME/staging${BITS} + BUILDDIR=$HOME/build${BITS} + BINDIR=$OUTDIR/$BITS + DEPSDIR=$HOME/deps${BITS} + if [ "$BITS" == "32" ]; then + HOST=i686-w64-mingw32 + DISTNAME=i686-win + else + HOST=x86_64-w64-mingw32 + DISTNAME=x86_64-win + fi + export PATH=$STAGING/host/bin:$PATH + rm -rf $DEPSDIR + rm -rf $BUILDDIR + rm -rf $STAGING + mkdir -p $STAGING $BUILDDIR $BINDIR $DEPSDIR + # + cd $STAGING + unzip -o $INDIR/qt-win${BITS}-5.5.0-gitian.zip + cd $DEPSDIR + unzip -o $INDIR/SONO-deps-win${BITS}-gitian.zip + # + cd $BUILDDIR + cp -r ../build/SONO . + cd SONO + mkdir -p $OUTDIR/src + git archive HEAD | tar -x -C $OUTDIR/src + cp $OUTDIR/src/doc/README_windows.txt $OUTDIR/readme.txt + cp $OUTDIR/src/COPYING $OUTDIR/COPYING.txt + # + cd src + make -f makefile.linux-mingw HOST="$HOST" DEPSDIR="$DEPSDIR" CURDIR="$BUILDDIR/SONO/src" STATIC=1 $MAKEOPTS USE_UPNP=1 BOOST_LIB_SUFFIX="-mt-s" USE_WALLET=1 DEBUGFLAGS= + cp SONOd.exe $BINDIR/ + cd .. + # + #$DEPSDIR/qt/host/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/lib BOOST_INCLUDE_PATH=$HOME/build/include BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.1h OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.1h/include INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=bitcoin USE_BUILD_INFO=1 + $STAGING/host/bin/qmake -xplatform win32-g++ RELEASE=1 QMAKE_LRELEASE="$STAGING/host/bin/lrelease" MINIUPNPC_LIB_PATH="$DEPSDIR/lib" MINIUPNPC_INCLUDE_PATH="$DEPSDIR/include" BDB_LIB_PATH="$DEPSDIR/lib" BDB_INCLUDE_PATH="$DEPSDIR/include" BOOST_LIB_PATH="$DEPSDIR/lib" BOOST_INCLUDE_PATH="$DEPSDIR/include" BOOST_LIB_SUFFIX="-mt-s" BOOST_THREAD_LIB_SUFFIX="_win32-mt-s" OPENSSL_LIB_PATH="$DEPSDIR/lib" OPENSSL_INCLUDE_PATH="$DEPSDIR/include" INCLUDEPATH="$DEPSDIR/include" DEFINES="BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 USE_BUILD_INFO=1 USE_NATIVE_I2P=1 USE_QRENCODE=1" QMAKE_CXXFLAGS=-frandom-seed=SONO + make $MAKEOPTS + cp release/SONO.exe $BINDIR/ + # + unset LD_PRELOAD + unset FAKETIME + done # for BITS in + # + # sort distribution tar file and normalize user/group/mtime information for deterministic output + mkdir -p $OUTDIR/src + rm -rf $TEMPDIR + mkdir -p $TEMPDIR + cd $TEMPDIR + cd $BINDIR + #tar -xvf $HOME/build/SONO/$DISTNAME | sort | tar --no-recursion -cT /dev/stdin --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 --mtime="$REFERENCE_DATETIME" | gzip -n > $OUTDIR/src/$DISTNAME + find | sort | zip -X@ $OUTDIR/SONO_$DISTNAME.zip diff --git a/contrib/gitian-descriptors/osxcross.yml b/contrib/gitian-descriptors/osxcross.yml new file mode 100644 index 0000000..7e7816a --- /dev/null +++ b/contrib/gitian-descriptors/osxcross.yml @@ -0,0 +1,61 @@ +--- +name: "osxcross" +suites: +- "trusty" +architectures: +- "amd64" +packages: +- "clang" +- "llvm-dev" +- "libxml2-dev" +- "uuid-dev" +- "libssl-dev" +- "bsdmainutils" +- "zip" +- "cmake" +reference_datetime: "2013-06-01 00:00:00" +remotes: +- "url": "https://github.com/tpoechtrager/osxcross.git" + "dir": "osxcross" +- "url": "https://github.com/planetbeing/libdmg-hfsplus" + "dir": "libdmg-hfsplus" +files: +- "MacOSX10.9.sdk.tar.xz" +script: | + # Defines + export TZ=UTC + export TAR_OPTIONS="-m --mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" + BUILDDIR=$HOME/build + PREFIX=$HOME/install + mkdir -p $BUILDDIR $PREFIX + cd $BUILDDIR + PATH=$PATH:$BUILDDIR + + # Build OSX Cross + cd osxcross + ln -s $HOME/build/MacOSX10.9.sdk.tar.xz tarballs/ + UNATTENDED=1 ./build.sh + cd target + mv * $PREFIX + # Fix broken symlinks + rm -f $PREFIX/bin/osxcross-macports $PREFIX/bin/osxcross-mp $PREFIX/bin/omp + mv ../tools/osxcross-macports $PREFIX/bin + cd $PREFIX/bin + ln -sf osxcross-macports osxcross-mp + ln -sf osxcross-macports omp + cd $PREFIX/SDK/MacOSX10.9.sdk/usr/include + rm stdarg.h + ln -sf ../../System/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdarg.h . + cd ../share + rm -rf man # No need for manuals... + # Build hdutil and .dmg dependencies + cd $BUILDDIR/libdmg-hfsplus + cmake CMakeLists.txt + make + mv dmg/dmg $PREFIX/bin + mv hfs/hfsplus $PREFIX/bin + mv hdutil/hdutil $PREFIX/bin + cd $PREFIX + # Adjust timestamps on files, for deterministic tar output + find . -print0 | xargs -r0 touch -t 200001010000 + find | sort | tar --no-recursion -cJf $OUTDIR/osxcross.tar.xz -T - diff --git a/contrib/gitian-descriptors/qt-osx.yml b/contrib/gitian-descriptors/qt-osx.yml new file mode 100644 index 0000000..9884d61 --- /dev/null +++ b/contrib/gitian-descriptors/qt-osx.yml @@ -0,0 +1,239 @@ +--- +name: "SONO-osx-qt" +suites: +- "trusty" +architectures: +- "amd64" +packages: +- "clang" +- "llvm-dev" +- "zip" +- "unzip" +- "faketime" +- "libz-dev" +- "ruby-full" +- "perl" +- "python" +- "m4" +- "bison" +- "gperf" +- "sharutils" +reference_datetime: "2011-01-30 00:00:00" +remotes: [] +files: +- "qt-everywhere-opensource-src-5.5.0.tar.xz" +- "SONO-deps-osx-gitian.zip" +- "flex-2.5.38.tar.gz" +- "osxcross.tar.xz" +script: | + # Integrity Check + #echo "8c6d070613b721452f8cffdea6bddc82ce4f32f96703e3af02abb91a59f1ea25 qt-everywhere-opensource-src-5.5.0.tar.xz" | sha256sum -c + echo "80f7c7188d7611e47e47d2a70c8ef65026c1cf71ddeb4ace9b1be5b8a76ffbd2 flex-2.5.38.tar.gz" | sha256sum -c + # + # Defines + export TZ=UTC + BUILDDIR=$HOME/build + TEMPDIR=$HOME/tmp + INSTALLPREFIX=$HOME/install + DEPSDIR=$HOME/deps + HOST=x86_64-apple-darwin13 + MIN_VERSION=10.6 + SDK_VERSION=10.9 + SDK=${DEPSDIR}/SDK/MacOSX${SDK_VERSION}.sdk + # + # Qt: workaround for determinism in resource ordering + # Qt5's rcc uses a QHash to store the files for the resource. + # A security fix in QHash makes the ordering of keys to be different on every run + # (https://qt.gitorious.org/qt/qtbase/commit/c01eaa438200edc9a3bbcd8ae1e8ded058bea268). + # This is good in general but qrc shouldn't be doing a traversal over a randomized container. + # The thorough solution would be to use QMap instead of QHash, but this requires patching Qt. + # For now luckily there is a test mode that forces a fixed seed. + export QT_RCC_TEST=1 + # + # Fix our paths + export PATH="$DEPSDIR/bin:$DEPSDIR/lib:$PATH" + export INCLUDE="$DEPSDIR/include:$INCLUDE" + export LIB="$DEPSDIR/lib:$LIB" + # + mkdir -p $INSTALLPREFIX $INSTALLPREFIX/host/bin $DEPSDIR $BUILDDIR + # + cd $BUILDDIR + # + tar xzf $BUILDDIR/flex-2.5.38.tar.gz + cd flex-2.5.38 + ./configure --prefix=$DEPSDIR + make + make install + cd .. + # + # Need mingw-compiled openssl from SONO-deps: + cd $DEPSDIR + unzip -o $BUILDDIR/SONO-deps-osx-gitian.zip + tar xf $BUILDDIR/osxcross.tar.xz + # + cd $BUILDDIR + tar xf qt-everywhere-opensource-src-5.5.0.tar.xz + # + QTDIR=$BUILDDIR/qt-everywhere-opensource-src-5.5.0 + cd $QTDIR + SPECDIR="qtbase/mkspecs" + SPECNAME="macx-clang-linux" + SPECFILE="${SPECDIR}/${SPECNAME}/qmake.conf" + rm -rf ${SPECDIR}/${SPECNAME} + cp -rp ${SPECDIR}/macx-clang ${SPECDIR}/${SPECNAME} + sed 's/qt_instdate=`date +%Y-%m-%d`/qt_instdate=2011-01-30/' -i qtbase/configure + sed 's/if \[ "$$$$XPLATFORM_MAC" = "yes" \]; then xspecvals=$$$$(macSDKify/if \[ "$$$$BUILD_ON_MAC" = "yes" \]; then xspecvals=$$$$(macSDKify/' -i qtbase/configure + # + sed 's/load(qt_config)//' -i $SPECFILE + cat > ${SPECFILE} < /tmp/list.txt + # rm $LIB + # $HOST-ar crsD $LIB $(cat /tmp/list.txt) + #done + # + cd $INSTALLPREFIX + # Remove unused non-deterministic stuff + rm host/bin/qtpaths lib/libQt5Bootstrap.a lib/libQt5Bootstrap.la + rm -f ${INSTALLPREFIX}/lib/Qt*.framework/Qt*.prl + cd include + ln -sf ../lib/QtNetwork.framework/Headers/ QtNetwork + ln -sf ../lib/QtWidgets.framework/Headers/ QtWidgets + ln -sf ../lib/QtGui.framework/Headers/ QtGui + ln -sf ../lib/QtCore.framework/Headers/ QtCore + ln -sf ../lib/QtTest.framework/Headers/ QtTest + ln -sf ../lib/QtWebKitWidgets.framework/Headers/ QtWebKitWidgets + cd .. + # as zip stores file timestamps, use faketime to intercept stat calls to set dates for all files to reference date + export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1 + export FAKETIME=$REFERENCE_DATETIME + find -print0 | xargs -r0 touch # fix up timestamps before packaging + find | sort | tar --no-recursion -cJf $OUTDIR/qt-osx-5.5.0-gitian.tar.xz -T - diff --git a/contrib/gitian-descriptors/qt-win.yml b/contrib/gitian-descriptors/qt-win.yml new file mode 100644 index 0000000..b04f5f4 --- /dev/null +++ b/contrib/gitian-descriptors/qt-win.yml @@ -0,0 +1,93 @@ +--- +name: "qt" +suites: +- "trusty" +architectures: +- "amd64" +packages: +- "mingw-w64" +- "g++-mingw-w64" +- "zip" +- "unzip" +- "faketime" +- "libz-dev" +reference_datetime: "2013-06-01 00:00:00" +remotes: [] +files: +- "qt-everywhere-opensource-src-5.5.0.tar.xz" +- "SONO-deps-win32-gitian.zip" +- "SONO-deps-win64-gitian.zip" +script: | + # Defines + export TZ=UTC + INDIR=$HOME/build + TEMPDIR=$HOME/tmp + # Qt: workaround for determinism in resource ordering + # Qt5's rcc uses a QHash to store the files for the resource. + # A security fix in QHash makes the ordering of keys to be different on every run + # (https://qt.gitorious.org/qt/qtbase/commit/c01eaa438200edc9a3bbcd8ae1e8ded058bea268). + # This is good in general but qrc shouldn't be doing a traversal over a randomized container. + # The thorough solution would be to use QMap instead of QHash, but this requires patching Qt. + # For now luckily there is a test mode that forces a fixed seed. + export QT_RCC_TEST=1 + # Integrity Check + echo "c603942b866f8a8ffff441c0d3e8c69d29a45e0bd3e48d386e7dc27d03237178 SONO-deps-win32-gitian.zip" | sha256sum -c + echo "1cb5e1b498e86917db690bc07ee73c9d6ffc23cf3509607d4f79aba53e87ecff SONO-deps-win64-gitian.zip" | sha256sum -c + echo "7ea2a16ecb8088e67db86b0835b887d5316121aeef9565d5d19be3d539a2c2af qt-everywhere-opensource-src-5.5.0.tar.xz" | sha256sum -c + for BITS in 32 64; do # for architectures + # + INSTALLPREFIX=$HOME/staging${BITS} + BUILDDIR=$HOME/build${BITS} + DEPSDIR=$HOME/deps${BITS} + if [ "$BITS" == "32" ]; then + HOST=i686-w64-mingw32 + else + HOST=x86_64-w64-mingw32 + fi + # + mkdir -p $INSTALLPREFIX $INSTALLPREFIX/host/bin $DEPSDIR $BUILDDIR + # + # Need mingw-compiled openssl from SONO-deps: + cd $DEPSDIR + unzip -o $INDIR/SONO-deps-win${BITS}-gitian.zip + # + cd $BUILDDIR + # + tar xf $INDIR/qt-everywhere-opensource-src-5.5.0.tar.xz + cd qt-everywhere-opensource-src-5.5.0 + SPECNAME="win32-g++" + SPECFILE="qtbase/mkspecs/${SPECNAME}/qmake.conf" + sed 's/qt_instdate=`date +%Y-%m-%d`/qt_instdate=2013-06-01/' -i qtbase/configure + sed --posix "s|QMAKE_CFLAGS = -pipe -fno-keep-inline-dllexport|QMAKE_CFLAGS\t\t= -pipe -fno-keep-inline-dllexport -isystem /usr/$HOST/include/ -frandom-seed=qtbuild -I$DEPSDIR/include|" -i ${SPECFILE} + sed --posix "s|QMAKE_LFLAGS =|QMAKE_LFLAGS\t\t= -L$DEPSDIR/lib|" -i ${SPECFILE} + # Before we tried to pass arguments to ar (static linking) in using QMAKE_LIB, however + # qt removes the arguments for ar and provides a script which makes it impossible to pass the determinism flag - + # so rather than try to replace ar, post-process all libraries and plugins at the end. + # + # Don't load faketime while compiling Qt, qmake will get stuck in nearly infinite loops + #export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 + #export FAKETIME=$REFERENCE_DATETIME + # + # Compile static libraries, and use statically linked openssl (-openssl-linked): + OPENSSL_LIBS="-L$DEPSDIR/lib -lssl -lcrypto -lgdi32" ./configure -prefix $INSTALLPREFIX -bindir $INSTALLPREFIX/host/bin -confirm-license -release -opensource -static -xplatform $SPECNAME -device-option CROSS_COMPILE="$HOST-" -no-audio-backend -no-sql-sqlite -no-sql-odbc -no-nis -no-cups -no-iconv -no-dbus -no-gif -no-opengl -no-compile-examples -no-feature-style-windowsce -no-feature-style-windowsmobile -no-qml-debug -openssl-linked -skip qtsvg -skip qtwebkit -skip qtwebkit-examples -skip qtserialport -skip qtdeclarative -skip qtmultimedia -skip qtimageformats -skip qtlocation -skip qtsensors -skip qtquick1 -skip qtquickcontrols -skip qtactiveqt -skip qtconnectivity -skip qtwinextras -skip qtxmlpatterns -skip qtscript -skip qtdoc -skip qtwebchannel -system-libpng -system-zlib + make $MAKEOPTS install + # post-process all generated libraries and plugins to be deterministic + # extract them to a temporary directory then re-build them deterministically + for LIB in $(find $INSTALLPREFIX -name *.a); do + rm -rf $TEMPDIR && mkdir $TEMPDIR && cd $TEMPDIR + $HOST-ar xv $LIB | cut -b5- > /tmp/list.txt + rm $LIB + $HOST-ar crsD $LIB $(cat /tmp/list.txt) + done + # + cd $INSTALLPREFIX + # Remove unused non-deterministic stuff + rm host/bin/qtpaths.exe lib/libQt5Bootstrap.a lib/libQt5Bootstrap.la + # as zip stores file timestamps, use faketime to intercept stat calls to set dates for all files to reference date + export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1 + export FAKETIME=$REFERENCE_DATETIME + find -print0 | xargs -r0 touch # fix up timestamps before packaging + find | sort | zip -X@ $OUTDIR/qt-win${BITS}-5.5.0-gitian.zip + unset LD_PRELOAD + unset FAKETIME + done # for BITS in diff --git a/contrib/gitian-downloader/bluematt-key.pgp b/contrib/gitian-downloader/bluematt-key.pgp new file mode 100644 index 0000000..fb6d9eb Binary files /dev/null and b/contrib/gitian-downloader/bluematt-key.pgp differ diff --git a/contrib/gitian-downloader/devrandom-key.pgp b/contrib/gitian-downloader/devrandom-key.pgp new file mode 100644 index 0000000..7189812 Binary files /dev/null and b/contrib/gitian-downloader/devrandom-key.pgp differ diff --git a/contrib/gitian-downloader/gavinandresen-key.pgp b/contrib/gitian-downloader/gavinandresen-key.pgp new file mode 100644 index 0000000..f81f44e Binary files /dev/null and b/contrib/gitian-downloader/gavinandresen-key.pgp differ diff --git a/contrib/gitian-downloader/laanwj-key.pgp b/contrib/gitian-downloader/laanwj-key.pgp new file mode 100644 index 0000000..5592951 --- /dev/null +++ b/contrib/gitian-downloader/laanwj-key.pgp @@ -0,0 +1,28 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: SKS 1.1.0 + +mQENBE5UtMEBCADOUz2i9l/D8xYINCmfUDnxi+DXvX5LmZ39ZdvsoE+ugO0SRRGdIHEFO2is +0xezX50wXu9aneb+tEqM0BuiLo6VxaXpxrkxHpr6c4jf37SkE/H0qsi/txEUp7337y3+4HMG +lUjiuh802I72p1qusjsKBnmnnR0rwNouTcoDmGUDh7jpKCtzFv+2TR2dRthJn7vmmjq3+bG6 +PYfqoFY1yHrAGT1lrDBULZsQ/NBLI2+J4oo2LYv3GCq8GNnzrovqvTvui50VSROhLrOe58o2 +shE+sjQShAy5wYkPt1R1fQnpfx+5vf+TPnkxVwRb3h5GhCp0YL8XC/BXsd5vM4KlVH2rABEB +AAG0K1dsYWRpbWlyIEouIHZhbiBkZXIgTGFhbiA8bGFhbndqQGdtYWlsLmNvbT6JATgEEwEC +ACIFAk5UtMECGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEHSBCwEjRsmmy6YIAK09 +buNXyYQrJBsX16sXxEhx5QPKyF3uHJDFJv66SdnpvIkNoznsaPiRJkbTANop93FZmaGa6wVn +zGDiz7jPA8Dpxx5aAYPhIT+zPJAdXWM3wJ/Gio9besRNzniai8Lwi5MZ9R/5yFGBobm6/AcN +4sUoqA3NSV2U3I29R0Vwlzo8GVtmyi9ENSi6Oo7AcXNTRt69cxW4nAHkB+amwwDJlcAb31ex +bogYXPhScwqQZixRr+JBkKxBjkTXXnQypT4KI5SegYwQVYfyiZmDP7UHKe/u6pSKKbVphLg8 +xLB5spcXse8/a2+onrbNlw6y8TXiJ++Z54PE7zztWTXf2huakeG5AQ0ETlS0wQEIAMNO3OkP +xoPRKWzBLcI7JRITAW+HNaLTq3uN2+4WxA57DEjbL9EDoAv+7wTkDAL40f0T+xiu6GJcLFjw +GJZu/tYu7+mErHjrdo+K4suCQt7w5EXCBvOLjhW4tyYMzNx8hP+oqzOW9iEC+6VV91+DYeqt +EkJuyVXOI4vzBlTw8uGow8aMMsCq8XVvKUZFTPsjGl197Q5B3A+ZOFCR8xqiqdPjuz6MglVV +oFdDNu3EZn8zkGsQlovXoE9ndVeVzx/XMNmsxFaMYsReUs253RIf1FEfgExID0fg2OnyLCjS +2iFW1RgajS+/saIkKl+N1iuMzJA7wMAM0plhRueOG0MtZSsAEQEAAYkBHwQYAQIACQUCTlS0 +wQIbDAAKCRB0gQsBI0bJpmsDB/4waenn2CvSHXyomykfpwf5lMte1V5LvH3z5R2LY+1NopRv +LSz3iC39x69XWiTbhywDfgafnGPW4pWBOff2/bu5/A6z1Hnan1vyrRRD/hx1uMJ7S6q+bIvZ +iVIg1p0jH6tdIIhwX3cydhdRZHo7e9oSMgOUWsr6Ar59NRo9CENwGPE4U61HXfOnxWdrFWoA +XdwZczBeLxmUy6Vo6sKqv+gE4bqrtAM0sY/MsQ9cU95x+52ox/sq44lQMwd3ZBYUP7B1qbHI +hZSZuch6MLi5scLPeau0ZvCaljiaMeivP5+x0gWPRs0kI+9sZxInbqvrsJ6oOBJM3xYGhtn1 +zZ7qmZR7 +=si/k +-----END PGP PUBLIC KEY BLOCK----- diff --git a/contrib/gitian-downloader/linux-download-config b/contrib/gitian-downloader/linux-download-config new file mode 100644 index 0000000..66eec8b --- /dev/null +++ b/contrib/gitian-downloader/linux-download-config @@ -0,0 +1,38 @@ +--- +name: SONO +urls: +- http://SONO.org/SONO-latest-linux-gitian.zip +rss: +- url: http://sourceforge.net/api/file/index/project-id/244765/mtime/desc/limit/100/rss + xpath: //item/link/text() + pattern: SONO-\d+.\d+.\d+-linux-gitian.zip +signers: + 0A82509767C7D4A5D14DA2301AE1D35043E08E54: + weight: 40 + name: BlueMatt + key: bluematt + BF6273FAEF7CC0BA1F562E50989F6B3048A116B5: + weight: 40 + name: Devrandom + key: devrandom + E463A93F5F3117EEDE6C7316BD02942421F4889F: + weight: 40 + name: Luke-Jr + key: luke-jr + D762373D24904A3E42F33B08B9A408E71DAAC974: + weight: 40 + name: "Pieter Wuille" + key: sipa + 77E72E69DA7EE0A148C06B21B34821D4944DE5F7: + weight: 40 + name: tcatm + key: tcatm + 01CDF4627A3B88AAE4A571C87588242FBE38D3A8: + weight: 40 + name: "Gavin Andresen" + key: gavinandresen + 71A3B16735405025D447E8F274810B012346C9A6: + weight: 40 + name: "Wladimir J. van der Laan" + key: laanwj +minimum_weight: 120 diff --git a/contrib/gitian-downloader/luke-jr-key.pgp b/contrib/gitian-downloader/luke-jr-key.pgp new file mode 100644 index 0000000..c40917d Binary files /dev/null and b/contrib/gitian-downloader/luke-jr-key.pgp differ diff --git a/contrib/gitian-downloader/richardsmith-key.gpg b/contrib/gitian-downloader/richardsmith-key.gpg new file mode 100644 index 0000000..04d1d53 --- /dev/null +++ b/contrib/gitian-downloader/richardsmith-key.gpg @@ -0,0 +1,52 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.10 (GNU/Linux) + +mQINBFAsDREBEADD88DdBoGu/rMpNYWyzXNWfHI5su/JX1tfzM/pb/iSrC4ywOtZ +P7wCqqAB1lhuT94j2m8kpv/VSb98Q7ZURxbwY/zEQnDuifiBCj5hO4lWTdSKgmLy +8xVR7WHEYCscKFl92mG6tqDewnD2oX5NyJrFeXPAM9R9jBIDc2oyUVznv5Rb2YUp +D4rdIHbEMoe524Ucw8ez5Kxtf0OW0Zbrraq1utbcL3B99FMnoSaXq5AiGTmcI3Xm +Mx8T8E6I2gd6ZLEtJbgzG7B8so/0tbpGIYExzatjWEzuDEPAgAB028nNWf8q+SE+ +G3Zo/ZrCenGYPmDKIaSlqmdhqHe22AGtn+k6gzvLVN9MHY2exIWhu2R8uw6cGCbG +piw7HPDR0epgf5im50rr/k9ZgELhURqDezeHCwRBFtBZd+1sLgzMocYybq7XM9e6 +dcHRZoXamlMibKoYMp30jfyb5mVYwnOJAQNUkFxwZOJXONOvwEyO+89ep0c7H/I5 +h/4F7UGTpRB84HpkZCK+rxOg90UpOQEAA1OKi2od5DNBtu9JnXOD8Ki9lXHaGgL2 +H6Q+ugntvsYmcJZ22IkymZ1DPaEPJa8Y/pwovl9rYac1A1v9PFkl2XsE2EZyipmF +QjTSimnmvCCIXFSG7yN4iP/H/+vP8kdV2HuPfLnq7i0uIe9q9s0ogtZEpwARAQAB +tCVyaWNoYXJkc21pdGggPGljZWVhdHNjcmVhbUBnbWFpbC5jb20+iQI+BBMBAgAo +BQJQLA0RAhsDBQkSzAMABgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRCiiuz9 +atLt+MecD/9qO/1ALT4EH5MewKG6mMT9hrbsIf07Cc0uKl4/hpbElK2iEclcXdj6 +fXyxVF0+1Vl8Bfkj47n4sL8aOmVjZ8YpFcW59GqE9Me9Sw7bPE5x8Ly2Am+NMkhz +myq3aJX54bzUGvBxCNwZYV46DxKjsOLrw2I/Tzt2zjzROlCW/r4IpEuFAQY5zzNv +YryzWuaJF27pVZH2od9X0nEfn7qBoDYWEtvlI5jfsL4HI0bd4Ws9xMrkjHKBaFaC +H5sxZS7mxicTRf4qeP/XKxdEI461sg28wYewnIBqYm8OEkwFS3YB51hlA1ufi3Za +m5sMmiut8H5jq0QXH+LWWQAADOnCbMrr3zbkaueMvLzjUsR1EtbYlpGPHXwk9eVk +9XckZ1hMjUl5VCBLzquuGuJonUfb5plxEDJ2MCkkkhBJ6DR3yMpjS//ogi52fwlI +0yltpyXUXcgURwvQ1pwpTkjbD09KqUmxViULFMLXT3e6vRc5pH9e7mja5LxSe/No +Kqm0RdFlM/2CMDQ0ByNUGWjAPozuxm5PeO0ypS3+tDBiLcgZnayWelsuHzR4BCmk +LkXiNTrIlXSJpBWsg5D99ni8VrFGLwn9PBaDrOsztfL8iDFgVUzPbizbEEAbKiYq +lo/qnq2nrxR7YtChJQwhKlc0NHOWmqJOp2+AIW+L1LfDiVo3wuH6XrkCDQRQLA0R +ARAA0e4sHZQDTZZ9DdmML1yhL9C0DqsBaDTiKQY+s9lanrjSs7HKgv8bK+gTNvng +/O0M1/xhSOsgepq5lpdl7h5QqGZ1oCSF3QYxCeGe85g9SKBsUFNbYwdS2JXBwO3V +1euBM2pNSmNL0PYiTsWylUQPymUZ4ww2n6giVYWmsEqSF/Ld/kkfODzJAP4AwBIJ +f+2GY+vWcvxNKES1JT98p/dlMMMXeDKqcXIIzoZbnpk5gd21oGXbMwaf9s8bK8ob +BMqZCORmSnG9npRSfFXDHSa2983nGPUoL8bMzeyDu/1PViclxTWtI012gYp99pRm +JXzGiGdBmuLItAQW5o8DWXfiiobYd5H0+PfAX62H5oXTWH1T5jblyxcyA+fYU71t +wCRZ93OEHv0Q/RafH6Fr+ltZVnpPmYpJ4gyWpyoP2j91N6KaVyrfbCaN0Cyv4bQG +JCg8Ss8UqOnsFj88KikYwRMVxJp5E6MpM0yEuIU+vrB+58yOmeNCQ+LwBNnltCmC +9v0YYibMbmUv4wRvScGHPAfJ3CWndRbIObXoMlLs9nayMCqpBTEDGhTKheocQdMo +aLt3OJsaTmFKE7iFGKImGgUdD94kbkzb7R+ZRlI9mNNiq+Kuj19CSAVdM9vttjyt +whPYPR6d4GNWZFS+Gg9k2Bv7O2cDYh78Go7ywuAtPkcTMv8AEQEAAYkCJQQYAQIA +DwUCUCwNEQIbDAUJEswDAAAKCRCiiuz9atLt+PAXEACLd967Sz06DpjMHqgHahCr +m1Kt13EM/mbrnoFJWePTp1JAtlzSMXKsWo7zOCC71dyI8PEfjylsZiuC3uL54DDl +JlQmlXa6/qi1KnqroJEkZ+YoDnIy/jiN1L3SqMVwUeQrd5N0koPZflpnoAq1np97 +wWDwK8NqALq5VsqXhVWvXeqjDM1q9+7fO7xDQLFZ0MNhqoMBdE4QRRkw55XWJKS9 +RI/hxDFuCJlK04eFTU/5pUSksEZZ0vl43YkXlN54qiyOvkVL2Aq9gVgvdaqGbG8x +kVSEtJK9XTwlo+BA/sFCMlR4NL1XCrrvv9/1SwiFAFSV4dz6Cg9ObAonNh0mbnwj +IaaBzS18pqRzqZg69aZzlKp6LxBYOmZTQuPiwdF0Cn/b5VNtgLKInmOvDvpHFWE2 +H4dU3Al/B+3o1Bm24mAgLQHGFh4GN4BV1ge+Lijiz+N0sUfPsqtHaP3RNZsm/4oL +zyVuoSMRL+NtkB03SID7CBzrVLGWRGgeWjLfLz+wnrDGlWz0N7dKJx76nayTvsM2 +xd81jat8FyHFFoB5D4xn+czbkCq1k3giyKqilz2NNXX0G7kUiU0D+tvIb76qP389 +9uiMAuC5q1Ibo+k3pOZrWWHX3c9HB1Qlry9Qw57Y4ncqjRcdMf884da5mTmCjl/d +EwL78xfzdw9iYRRwoeP+IQ== +=jMKy +-----END PGP PUBLIC KEY BLOCK----- diff --git a/contrib/gitian-downloader/scottnadal-key.gpg b/contrib/gitian-downloader/scottnadal-key.gpg new file mode 100644 index 0000000..8298dd6 --- /dev/null +++ b/contrib/gitian-downloader/scottnadal-key.gpg @@ -0,0 +1,52 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.10 (GNU/Linux) + +mQINBFAs/eYBEADJq87tlE9Lu4dtgzKcnLrY6m7Eab3fPL4aW+g1PC3O4rMn2jjT +vp4TU+DHBgt9r+DBpiK48v9fd3BNpg8mB25pDgdWtoBj64D1YxlU/NxbwnR4SGDD +nSCjp/Z+ZxTCjUHfAu384P9nsSvMFksVhhzgd9JXvxJzB61odjgPRVs5buJtLzrg +v7jJdBZPDC2R9kJIggdrrN4sWhE9o3VQ4kFMxEu3KGJSLZuGRdwr1Ni5jxpo1Hio +Xf1LDKJ5+kTb2YpHL9trxe9ELt3HLa5mryCVff1wwN+MBwsXdvxTjF2RXJUWbKlC +M78DjLCCyM5T1XPb4D0dp/olEhNqI6IrBhR9rEOVR5Rbsl49lfhQIUEDAVlogAoG +yzwQMO/NGOD0NUgQV/7ZIN1fpKPuipJsCId2UvzuxzjwtMf20VUI5OPKRk122OOv +9c91y9fI9H6rgHKcS96HLM840pkQmr00CpsEtCjtYxvOKCakCcbq4SHZSrB2gjcK +msY/DfEjO5An/LXh5IbEiSSgSXfCTSXMU7yB36yX4CniIDTEe044DlTwhSGUnw65 +alTp4taaswjB+yhAWI5IXOGifFyOAFW0BhGpDHuWoevUHKYXMla9czB0Jn1VIX/E +bAPxi5sZKHjhhjZY6ngZAO2HXliWHXIeLvwjUdE0+AAP5B+eh7kyMV7mlQARAQAB +tCJzY290dG5hZGFsIDxzY290dC5uYWRhbEBnbWFpbC5jb20+iQI+BBMBAgAoBQJQ +LP3mAhsDBQkSzAMABgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRAu6TbaW7w+ +y477EAC9yNgDSSdSmqUVQdrPdEn1RyZl4sjAznuRk+CKffi83/ZwjZJkT12GapPF +9/wW/YXGGbb2wUK17xIz8ZcKCjZeSf8w0HNwFfy8bOOkewpJ3QMp+PO61KTa1sfn +hJvPKQTxKAM49tiq1O/x5hppKCrJjPzlH41+4rfrFk7+v5ZHusIDqxIzepS+MyNy +fhmCq1Pd2w/R3zHIDH7R8uuuJKDDkZhhJgQjjxGo4Mqo6UaJOHsmLNGmQi+at/Eu +BssrO2OHSShCvA6/fvKXN4XEFxm7w3WUylw3h47j1hXhQClqBJrLA08N7+iNqKKg +DX2ePpWIptwjJyqn/6UtEfFyeIBQITpxyrVoWCtdnNdo03AQpraPV8DICyxQY3e9 +FFKkrod+XKeGqs7Lsk5mPUOQVl7KoCfmW+M1vcvEpK7wElSRUdy0Fw0s6BiYN1xH +baOsBIvc1KWN9x//ctJPcjxEONiPDKv1dyWUYIWieSTrFjP6aOLoe0uGkDXxxlEs +4X4ZAgSONOs4j62on9lsFH1pVAQOpbmVS06vmmHQTR3skG9D8s4jVn1dyJQ35I0ml +P0IH4DazTTld6laYptd4CqlohotME+yh9VqiQ0Tg1u6L4VwYsBN6AKGgOq+T8T0b +VPNK1+Si9Poq4J/wPPqUQRzxSgWbX5Ho/k+6t0R8dpne6oFGrbkCDQRQLP3mARAA +mIA7DN9DT1xN0uazTRXV4lqFTuG+86iPU35eUtReGcChYwq0V56bV+gywObo4fAP +QsynzCUvtk+8FSL++SLysIaD/VAu3YAqsI/shzA/KG77ZqgR3/E6pnkaN8aFVPRf +dFFbBYioXP2MkOMd2MqPSnUI5+dMKnJ4HBQvucG5yxdR7VKP9VxBwQcfZEcE+l8a +yRyaAr3NNDm69Qxb6TeiJlwSQvcY4FhnP9EpIW11DEIvCEKKr6X0UoWFTm7dSfLk +n2e1IsK1kk3Uy45KzrR/4dYB7PhEP0VjLZ4bueXMjvZW8YBUoC6emOU/3B+/j3GO +N+62XE9u0Vsh2uzRnOqjucn+i83Og7+1VaXVRh77giWTlDTAeJARRGa6ScmxI9Vk +MJgbe2oseDxTv9QF5guqLUNe0MlUZ/9SXXjou/D+L/S9Beo775sfn57gANDbaGRm +9795YyAHphl26Qp7es3uj99mlK7tGDHajb2JkJutMtaevGuVNN9QlUrhr7klPOAd +6jdAxsU9Sn/gnUBZJbCFoQlUveEjkSu24/tYoo6Oy7VgMxwt/CMhB5HzVOpY20Ym +BDTO9P9MBeD0/wSPyanHc+XVepXWwsp4EC5RVnJFLf+o3vmeQYqiF0qXuapLmLnK +XqSD+M+uIr15XxTLLx9vsjUVN/xkLu7DCgyVeRA3ytUAEQEAAYkCJQQYAQIADwUC +UCz95gIbDAUJEswDAAAKCRAu6TbaW7w+yxsEEACu+7g6trtjYQZ3FStCK8OZOAJl +jefUONgZX8woSSmyeVlg5Ex9cSvAgfOhiM2J2+K8aI53woOsiE3LihElaX+Qi+hE +GgjsFdd6lNn3i5gFydDHs6uLvtVAXxAOOOaXWT/ucsTgBRGcY4H1QYlkTGD8Xsf8 +qyUOzP/s8RQbvIrGrQtLN3O9r8wDBzDdZZjp/IZZaY6VT1r3AvF2mX+ip8/OqxNc +Yd3qxf8s7Kyn0eChSq1DAp83XMWxCje2EwXXzDA7Jd0pMAppWevFks4INGyCxz+9 +jOZ4Ris2a907ShWmIg8bw40r5L69j59qPk0fr44X6XVguN9zmKpLV5fyY88Qy9iq +8uy/3UVprZ0LnPbBXhbDsFkgiDOo2zCJfaVhPirMlpPJg/T5pFyAt+klrq6bD+tD +50Hh9gOpXXg58bELJhOtDUCV6Froc99LeqoBvlKJWqr58QguO2mn1cFJcP+nVzxz +DBpB/dWsmQst/NQ3YlgfVr6CcgqlCqVI4yNT91Q5Ns8/pdkcUBIVDUC+4oyKwA4n +XZMmydPJDdUiluwVSeIw0N/jiZhBJvMJHlOQ3xmb8In0WXcnE5JbibCITTN/T224 +jL14ObF+aMWlFanqRDUwllEQFv0Wa9dgTaHzxl+l9Ojw+YaYt/96UTtEJaMaxmww +JzdBFnCP7RoNHIQ20A== +=CQsQ +-----END PGP PUBLIC KEY BLOCK----- diff --git a/contrib/gitian-downloader/sipa-key.pgp b/contrib/gitian-downloader/sipa-key.pgp new file mode 100644 index 0000000..a52a5de Binary files /dev/null and b/contrib/gitian-downloader/sipa-key.pgp differ diff --git a/contrib/gitian-downloader/sunnyking-key.gpg b/contrib/gitian-downloader/sunnyking-key.gpg new file mode 100644 index 0000000..16b2a40 --- /dev/null +++ b/contrib/gitian-downloader/sunnyking-key.gpg @@ -0,0 +1,52 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.10 (GNU/Linux) + +mQINBFAsDOMBEACysMqtJfC7ikO2o+ioQZvHSSbL2R2zdgYxPjtQvLqbNMiJyV3q +vwXGWh0Z3eGu/cpHvfN6mguwHqgh319AtU6wiOHX/1yGMf2MUNFhoh8RlDWhZ+ba +gMTv7pcZKE2Ca7JgDtLNWd+NpjYrlGDSEEFl2vTohKKd+V7hRjyMc8iLkLjVdtdd +OTuFQeyNB8DUMUr3GuaPr52RgidZdMbJ0QSnEQeN9/ZTYjmYfREO+mal+2G/OKMk +6naUcGrhwHimc02WDddkqMhe5eZsU3XG+WqrD5NkN3my72XjkqSE1++k2+XgnOon +pUOciWfF3R3RBlOn0MlfKvNa/GXZ7PFxke3tkxdym8BV10l8spV++tPuhxovR7Gp +XG8Mt66uxlFc4S9wTg5FJilk2W75LK+FjFLAk9gJ24IHUawdSpLdCM+a4/JL1Ys+ +CQUuQA06Xdq3x8iuZSduRrnLeFEkM/F6JmyH22L8b5ptIm/wgjCaa+R/8P5ROO/E +FM1z7sw2RK12ZNPqwrNysePSVze2MGNdPnmb2KDcxSlxoK6Nzcef5xGkP/WwdBnd +WN2iA70I0S8DEywpY3hrJ4YIDg+SvCsoRIBH90PUORQ5Uhfj15QbmT2bZrqoFaDY +1+dWmijsPJ6+6MYjDWte/WVDSqTJEa22R/SAjGETGmUig7OqE7FFaQFLPwARAQAB +tCNzdW5ueWtpbmcgPHN1bm55a2luZzk5OTlAZ21haWwuY29tPokCPgQTAQIAKAUC +UCwM4wIbAwUJEswDAAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQGPNEBNK5 +Xmp4hg//f/rUs1ABrsd7ciHN0ByOH/WKdlUNNvf8jua86mHdPcHAFtZ3HC8ICVLe +7TAUMEgQ1Vsmk1QBILCaE50cD9iya4uCYCpBN6RZXUd09Te+ugb+VUYda4NmVbF+ +ZYidDjLwFZ3MV4uXZLWMGnxVDYVrBDHdfvFkZvi+/thtEME+Ea84diBZcAW/ncUb +AMNxNsmOTlTcPuB47UZVxg2vSJWkJe9O6IpuF782+49O14hsxidPMV+BKOaYWwoj +wGlJ+NDkobaQ/a0lI0aGHL1KXA58mNMB0i7SoYB8YJMfL2+lx0AZsvxaqFmuMcPf +zo7I9UCyf/gHorQaxsbz2/LUfpFL4T7IWt9IJkVe8TT9KQV8T0l9uUaQtX3iLwqQ +IRJWdQZMpnENhEgkSLRSkmCV/162ksYoboSpfI3Qhz1h0yqnwHAGBKSbE/2IGVo5 +3m/27xUFy5+7WeiON7DelYS6mx4UiAkhSWj4/u60YNnq5eTAYQFqawtSwIiO9pLH +C1gqOCoakESdFCQfABNsI6paIkfTylZhLd20qrr9qvBfvOgpMRXbO6xBPYp92/UK +9uRkFFCJORLBUl9saLfZa4Hw1CcY06IA3XXBx2/kp42aeAnWrfzqLvXwFZGtOJie +ajQsJUeDLFjbsYmw9FP8izK2H6plEa3PLFDz2gP+MSLZ5+13eES5Ag0EUCwM4wEQ +AMTFatCCzaUPwFpM9GyC7JwIWofDRpZBigXnzTC8RwHnb1ruWliFUkTEeSB8z7pC +3DaQ+owf0TUqj0c8Ui3SVfCcQqIJuWBycxxUnSaqWvz7wRaRN+WG4gaWgA2z7k4Q +CMmVhbxTaaZ67rfqtFOKM7EaIqOBE+AKg5BCCrxnja/xR0eZxRLwZKXqfakgqXy8 +HaWOzLPU6zMheTXu4YW5S6jvZOaMRkKI5xEUdQf/UPYkwYM6PaA/o70rTSGuQ/mc +zwFZp7FxKqKINPBSJLu1CjhnnrZM37y26I5O+nErDTinvYg5Rkq5wV3gMNbzpOdA +qPdw2qkVwKWDErNrA9amKuM0/fpvu/kXkGnfkugvt3Rokc3MQO2u5HI1eO571zaV +GoDt1oYjpKPuu6JMe2b5D1fLhyHicGaH8V2vpJi6+01Ww09srKemox54J4Z/Xjw6 +gyaWuPkCHO3roNjeGMtzbbJeOYEZC/AMTuqmnv3gHXENgrxKjCkkGddH8t7nZUNT +zmTMHrqOzhacRIp/6jpKCNXea2FaeRQECtDD2awNxUpmFFQeGpXJGsGc/GYHqvtV +HxWOiio1BpHhjCySHCYpqsq/GtGVdxNVz6o7H0/i4wipT7Q2dKVKbSuapaqI01jv +40019gtjOV7Gw8fX0MLt3ViCQVHpDxdMN/vkumw9YKA1ABEBAAGJAiUEGAECAA8F +AlAsDOMCGwwFCRLMAwAACgkQGPNEBNK5XmpymA//UXydFKX11RGloxzMfdgoFvjw +mNoZeS5Sv22hpsS2XswqAIbGdI/s2PbEzLv6nn0ck1PUFn9wL+TxB9GF2wWelpI4 +qe1mKsedJbj9PG6Wx2Invn6IcEInMrSLspBWiJJL2eP4y1hjAGG4v1wxPXQ4/FNe +OvXzAwShz79nVY35MDPBpL/dlhRJAIe/T7pYiI/HB8p4bI9MbtJcfp61oRPt17UC +vIQFnKKkwPT99i3PsOqAa8mVa2Ae4EElHG844Hr89ptHrGjudssfBf4kOaENMQqE +MFlyGaT9CLrD/2Qs/rXqFz3VAQykw/Cuw0kiRJjS5xKZZjVbz3Zd9suklk6YkSpI +jLzcPPON8nC6wvtUus5d0gtQeGx2DaX9n2+ubKlZgTSvT41PO/2Th9o3CgptHYJT +59ncrZP515yd0ZMknZ9bFt9BaE3V17hblOjFXoFqmAhwXyHQD9Ffd62AO1h2JNx5 +BAr4D7VyxJ3WX1yJFtdGsU7iD6ko4HahRepfp8UMtyVRLWVPGVmNq38Tozb4dhyh +fk3MxiatbEXQZbvFVr8WfGoNOIXB4Kg68NGxwZv6Jd5lobDOQjVYOykD2UpuOXmY +VRanFk5eIy0UWYAwUNP+XnjGHdwtX4ZYh+O4wDnWEZd4soVMXzOBuyWTSKahHhZi +KIjGheFAFTRFLgBmol4= +=Qxzm +-----END PGP PUBLIC KEY BLOCK----- diff --git a/contrib/gitian-downloader/tcatm-key.pgp b/contrib/gitian-downloader/tcatm-key.pgp new file mode 100644 index 0000000..baaec76 Binary files /dev/null and b/contrib/gitian-downloader/tcatm-key.pgp differ diff --git a/contrib/gitian-downloader/win32-download-config b/contrib/gitian-downloader/win32-download-config new file mode 100644 index 0000000..ac9f444 --- /dev/null +++ b/contrib/gitian-downloader/win32-download-config @@ -0,0 +1,38 @@ +--- +name: SONO +urls: +- http://SONO.org/SONO-latest-win32-gitian.zip +rss: +- url: http://sourceforge.net/api/file/index/project-id/244765/mtime/desc/limit/100/rss + xpath: //item/link/text() + pattern: SONO-\d+.\d+.\d+-win32-gitian.zip +signers: + 0A82509767C7D4A5D14DA2301AE1D35043E08E54: + weight: 40 + name: BlueMatt + key: bluematt + BF6273FAEF7CC0BA1F562E50989F6B3048A116B5: + weight: 40 + name: Devrandom + key: devrandom + E463A93F5F3117EEDE6C7316BD02942421F4889F: + weight: 40 + name: Luke-Jr + key: luke-jr + D762373D24904A3E42F33B08B9A408E71DAAC974: + weight: 40 + name: "Pieter Wuille" + key: sipa + 77E72E69DA7EE0A148C06B21B34821D4944DE5F7: + weight: 40 + name: tcatm + key: tcatm + 01CDF4627A3B88AAE4A571C87588242FBE38D3A8: + weight: 40 + name: "Gavin Andresen" + key: gavinandresen + 71A3B16735405025D447E8F274810B012346C9A6: + weight: 40 + name: "Wladimir J. van der Laan" + key: laanwj +minimum_weight: 120 diff --git a/contrib/linearize/README.md b/contrib/linearize/README.md new file mode 100644 index 0000000..79e5b41 --- /dev/null +++ b/contrib/linearize/README.md @@ -0,0 +1,33 @@ +# Linearize +Construct a linear, no-fork, best version of the blockchain. + +## Step 1: Download hash list + + $ ./linearize-hashes.py linearize.cfg > hashlist.txt + +Required configuration file settings for linearize-hashes: +* RPC: rpcuser, rpcpassword + +Optional config file setting for linearize-hashes: +* RPC: host, port +* Block chain: min_height, max_height + +## Step 2: Copy local block data + + $ ./linearize-data.py linearize.cfg + +Required configuration file settings: +* "input": SONOd blocks/ directory containing blkNNNNN.dat +* "hashlist": text file containing list of block hashes, linearized-hashes.py +output. +* "output_file": bootstrap.dat + or +* "output": output directory for linearized blocks/blkNNNNN.dat output + +Optional config file setting for linearize-data: +* "netmagic": network magic number +* "max_out_sz": maximum output file size (default 1000*1000*1000) +* "split_timestamp": Split files when a new month is first seen, in addition to +reaching a maximum file size. +* "file_timestamp": Set each file's last-modified time to that of the +most recent block in that file. diff --git a/contrib/linearize/example-linearize.cfg b/contrib/linearize/example-linearize.cfg new file mode 100644 index 0000000..72f086e --- /dev/null +++ b/contrib/linearize/example-linearize.cfg @@ -0,0 +1,19 @@ + +# SONOd RPC settings (linearize-hashes) +rpcuser=someuser +rpcpassword=somepassword +host=127.0.0.1 +port=31500 +background-color: rgb(0, 0, 0); +alternate-background-color: rgb(86, 0, 120); + +# bootstrap.dat hashlist settings (linearize-hashes) +max_height=390000 + +# bootstrap.dat input/output settings (linearize-data) +netmagic=70352205 +input=/home/example/.SONO +output_file=/home/example/Downloads/bootstrap.dat +hashlist=hashlist.txt +split_year=1 + diff --git a/contrib/linearize/linearize-data.py b/contrib/linearize/linearize-data.py new file mode 100644 index 0000000..054d1b5 --- /dev/null +++ b/contrib/linearize/linearize-data.py @@ -0,0 +1,250 @@ +#!/usr/bin/python +# +# linearize-data.py: Construct a linear, no-fork version of the chain. +# +# Copyright (c) 2013-2015 The Bitcoin developers +# Distributed under the MIT/X11 software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# + +import json +import struct +import re +import os +import base64 +import httplib +import sys +import hashlib +import datetime +import time +import ltc_scrypt + +settings = {} + + +def uint32(x): + return x & 0xffffffffL + +def bytereverse(x): + return uint32(( ((x) << 24) | (((x) << 8) & 0x00ff0000) | + (((x) >> 8) & 0x0000ff00) | ((x) >> 24) )) + +def bufreverse(in_buf): + out_words = [] + for i in range(0, len(in_buf), 4): + word = struct.unpack('@I', in_buf[i:i+4])[0] + out_words.append(struct.pack('@I', bytereverse(word))) + return ''.join(out_words) + +def wordreverse(in_buf): + out_words = [] + for i in range(0, len(in_buf), 4): + out_words.append(in_buf[i:i+4]) + out_words.reverse() + return ''.join(out_words) + +def calc_hdr_hash(blk_hdr): + hash1 = hashlib.sha256() + hash1.update(blk_hdr) + hash1_o = hash1.digest() + + hash2 = hashlib.sha256() + hash2.update(hash1_o) + hash2_o = hash2.digest() + + return hash2_o + +def calc_hash_str(blk_hdr): + hash = calc_hdr_hash(blk_hdr) + hash = bufreverse(hash) + hash = wordreverse(hash) + hash_str = hash.encode('hex') + return hash_str + +def calc_scrypt_hash_str(blk_hdr): + hash = ltc_scrypt.getPoWHash(blk_hdr) + hash = bufreverse(hash) + hash = wordreverse(hash) + hash_str = hash.encode('hex') + return hash_str + +def get_blk_dt(blk_hdr): + members = struct.unpack(" 319000: + hash_str = calc_hash_str(blk_hdr) + else: + hash_str = calc_scrypt_hash_str(blk_hdr) + + if not hash_str in blkset: + print("Skipping unknown block " + hash_str) + continue + + if blkindex[blkCount] != hash_str: + print("Out of order block.") + print("Expected " + blkindex[blkCount]) + print("Got " + hash_str) + sys.exit(1) + + if not fileOutput and ((outsz + inLen) > maxOutSz): + outF.close() + if setFileTime: + os.utime(outFname, (int(time.time()), highTS)) + outF = None + outFname = None + outFn = outFn + 1 + outsz = 0 + + (blkDate, blkTS) = get_blk_dt(blk_hdr) + if timestampSplit and (blkDate > lastDate): + print("New month " + blkDate.strftime("%Y-%m") + " @ " + hash_str) + lastDate = blkDate + if outF: + outF.close() + if setFileTime: + os.utime(outFname, (int(time.time()), highTS)) + outF = None + outFname = None + outFn = outFn + 1 + outsz = 0 + + if not outF: + if fileOutput: + outFname = settings['output_file'] + else: + outFname = "%s/blk%05d.dat" % (settings['output'], outFn) + print("Output file" + outFname) + outF = open(outFname, "wb") + + outF.write(inhdr) + outF.write(rawblock) + outsz = outsz + inLen + 8 + + blkCount = blkCount + 1 + if blkTS > highTS: + highTS = blkTS + + if (blkCount % 1000) == 0: + print("Wrote " + str(blkCount) + " blocks") + +if __name__ == '__main__': + if len(sys.argv) != 2: + print "Usage: linearize-data.py CONFIG-FILE" + sys.exit(1) + + f = open(sys.argv[1]) + for line in f: + # skip comment lines + m = re.search('^\s*#', line) + if m: + continue + + # parse key=value lines + m = re.search('^(\w+)\s*=\s*(\S.*)$', line) + if m is None: + continue + settings[m.group(1)] = m.group(2) + f.close() + + if 'netmagic' not in settings: + settings['netmagic'] = '70352205' + if 'input' not in settings: + settings['input'] = 'input' + if 'hashlist' not in settings: + settings['hashlist'] = 'hashlist.txt' + if 'file_timestamp' not in settings: + settings['file_timestamp'] = 0 + if 'split_timestamp' not in settings: + settings['split_timestamp'] = 0 + if 'max_out_sz' not in settings: + settings['max_out_sz'] = 1000L * 1000 * 1000 + + settings['max_out_sz'] = long(settings['max_out_sz']) + settings['split_timestamp'] = int(settings['split_timestamp']) + settings['file_timestamp'] = int(settings['file_timestamp']) + settings['netmagic'] = settings['netmagic'].decode('hex') + + if 'output_file' not in settings and 'output' not in settings: + print("Missing output file / directory") + sys.exit(1) + + blkindex = get_block_hashes(settings) + blkset = mkblockset(blkindex) + + if not "000001faef25dec4fbcf906e6242621df2c183bf232f263d0ba5b101911e4563" in blkset: + print("not found") + else: + copydata(settings, blkindex, blkset) + + diff --git a/contrib/linearize/linearize-hashes.py b/contrib/linearize/linearize-hashes.py new file mode 100644 index 0000000..c204855 --- /dev/null +++ b/contrib/linearize/linearize-hashes.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# +# linearize-hashes.py: List blocks in a linear, no-fork version of the chain. +# +# Copyright (c) 2013-2015 The Bitcoin developers +# Distributed under the MIT/X11 software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# + +import json +import struct +import re +import base64 +import httplib +import sys + +settings = {} + +class SONORPC: + OBJID = 1 + + def __init__(self, host, port, username, password): + authpair = "%s:%s" % (username, password) + self.authhdr = "Basic %s" % (base64.b64encode(authpair)) + self.conn = httplib.HTTPConnection(host, port, False, 30) + def rpc(self, method, params=None): + self.OBJID += 1 + obj = { 'version' : '1.1', + 'method' : method, + 'id' : self.OBJID } + if params is None: + obj['params'] = [] + else: + obj['params'] = params + self.conn.request('POST', '/', json.dumps(obj), + { 'Authorization' : self.authhdr, + 'Content-type' : 'application/json' }) + + resp = self.conn.getresponse() + if resp is None: + print "JSON-RPC: no response" + return None + + body = resp.read() + resp_obj = json.loads(body) + if resp_obj is None: + print "JSON-RPC: cannot JSON-decode body" + return None + if 'error' in resp_obj and resp_obj['error'] != None: + return resp_obj['error'] + if 'result' not in resp_obj: + print "JSON-RPC: no result in object" + return None + + return resp_obj['result'] + def getblock(self, hash, verbose=True): + return self.rpc('getblock', [hash, verbose]) + def getblockhash(self, index): + return self.rpc('getblockhash', [index]) + +def get_block_hashes(settings): + rpc = SONORPC(settings['host'], settings['port'], + settings['rpcuser'], settings['rpcpassword']) + + for height in xrange(settings['min_height'], settings['max_height']+1): + hash = rpc.getblockhash(height) + + print(hash) + +if __name__ == '__main__': + if len(sys.argv) != 2: + print "Usage: linearize-hashes.py CONFIG-FILE" + sys.exit(1) + + f = open(sys.argv[1]) + for line in f: + # skip comment lines + m = re.search('^\s*#', line) + if m: + continue + + # parse key=value lines + m = re.search('^(\w+)\s*=\s*(\S.*)$', line) + if m is None: + continue + settings[m.group(1)] = m.group(2) + f.close() + + if 'host' not in settings: + settings['host'] = '127.0.0.1' + if 'port' not in settings: + settings['port'] = 31500 +background-color: rgb(0, 0, 0); +alternate-background-color: rgb(86, 0, 120); + if 'min_height' not in settings: + settings['min_height'] = 0 + if 'max_height' not in settings: + settings['max_height'] = 319000 + if 'rpcuser' not in settings or 'rpcpassword' not in settings: + print "Missing username and/or password in cfg file" + sys.exit(1) + + settings['port'] = int(settings['port']) + settings['min_height'] = int(settings['min_height']) + settings['max_height'] = int(settings['max_height']) + + get_block_hashes(settings) + diff --git a/contrib/macdeploy/LICENSE b/contrib/macdeploy/LICENSE new file mode 100644 index 0000000..20e1338 --- /dev/null +++ b/contrib/macdeploy/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no SONO of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is SONOred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction SONOring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRSONO), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/contrib/macdeploy/background.png b/contrib/macdeploy/background.png new file mode 100644 index 0000000..0cac577 Binary files /dev/null and b/contrib/macdeploy/background.png differ diff --git a/contrib/macdeploy/background.psd b/contrib/macdeploy/background.psd new file mode 100644 index 0000000..de5732f Binary files /dev/null and b/contrib/macdeploy/background.psd differ diff --git a/contrib/macdeploy/fancy.plist b/contrib/macdeploy/fancy.plist new file mode 100644 index 0000000..54b38a7 --- /dev/null +++ b/contrib/macdeploy/fancy.plist @@ -0,0 +1,32 @@ + + + + + window_bounds + + 300 + 300 + 800 + 620 + + background_picture + background.png + icon_size + 96 + applications_symlink + + items_position + + Applications + + 370 + 156 + + SONO-Qt.app + + 128 + 156 + + + + diff --git a/contrib/macdeploy/macdeployqtplus b/contrib/macdeploy/macdeployqtplus new file mode 100644 index 0000000..7981eca --- /dev/null +++ b/contrib/macdeploy/macdeployqtplus @@ -0,0 +1,758 @@ +#!/usr/bin/env python + +# +# Copyright (C) 2011 Patrick "p2k" Schneider +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import subprocess, sys, re, os, shutil, stat, os.path +from string import Template +from time import sleep +from argparse import ArgumentParser + +# This is ported from the original macdeployqt with modifications + +class FrameworkInfo(object): + def __init__(self): + self.frameworkDirectory = "" + self.frameworkName = "" + self.frameworkPath = "" + self.binaryDirectory = "" + self.binaryName = "" + self.binaryPath = "" + self.version = "" + self.installName = "" + self.deployedInstallName = "" + self.sourceFilePath = "" + self.destinationDirectory = "" + self.sourceResourcesDirectory = "" + self.destinationResourcesDirectory = "" + + def __eq__(self, other): + if self.__class__ == other.__class__: + return self.__dict__ == other.__dict__ + else: + return False + + def __str__(self): + return """ Framework name: %s + Framework directory: %s + Framework path: %s + Binary name: %s + Binary directory: %s + Binary path: %s + Version: %s + Install name: %s + Deployed install name: %s + Source file Path: %s + Deployed Directory (relative to bundle): %s +""" % (self.frameworkName, + self.frameworkDirectory, + self.frameworkPath, + self.binaryName, + self.binaryDirectory, + self.binaryPath, + self.version, + self.installName, + self.deployedInstallName, + self.sourceFilePath, + self.destinationDirectory) + + def isDylib(self): + return self.frameworkName.endswith(".dylib") + + def isQtFramework(self): + if self.isDylib(): + return self.frameworkName.startswith("libQt") + else: + return self.frameworkName.startswith("Qt") + + reOLine = re.compile(r'^(.+) \(compatibility version [0-9.]+, current version [0-9.]+\)$') + bundleFrameworkDirectory = "Contents/Frameworks" + bundleBinaryDirectory = "Contents/MacOS" + + @classmethod + def fromOtoolLibraryLine(cls, line): + # Note: line must be trimmed + if line == "": + return None + + # Don't deploy system libraries (exception for libQtuitools and libQtlucene). + if line.startswith("/System/Library/") or line.startswith("@executable_path") or (line.startswith("/usr/lib/") and "libQt" not in line): + return None + + m = cls.reOLine.match(line) + if m is None: + raise RuntimeError("otool line could not be parsed: " + line) + + path = m.group(1) + + info = cls() + info.sourceFilePath = path + info.installName = path + + if path.endswith(".dylib"): + dirname, filename = os.path.split(path) + info.frameworkName = filename + info.frameworkDirectory = dirname + info.frameworkPath = path + + info.binaryDirectory = dirname + info.binaryName = filename + info.binaryPath = path + info.version = "-" + + info.installName = path + info.deployedInstallName = "@executable_path/../Frameworks/" + info.binaryName + info.sourceFilePath = path + info.destinationDirectory = cls.bundleFrameworkDirectory + else: + parts = path.split("/") + i = 0 + # Search for the .framework directory + for part in parts: + if part.endswith(".framework"): + break + i += 1 + if i == len(parts): + raise RuntimeError("Could not find .framework or .dylib in otool line: " + line) + + info.frameworkName = parts[i] + info.frameworkDirectory = "/".join(parts[:i]) + info.frameworkPath = os.path.join(info.frameworkDirectory, info.frameworkName) + + info.binaryName = parts[i+3] + info.binaryDirectory = "/".join(parts[i+1:i+3]) + info.binaryPath = os.path.join(info.binaryDirectory, info.binaryName) + info.version = parts[i+2] + + info.deployedInstallName = "@executable_path/../Frameworks/" + os.path.join(info.frameworkName, info.binaryPath) + info.destinationDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, info.binaryDirectory) + + info.sourceResourcesDirectory = os.path.join(info.frameworkPath, "Resources") + info.destinationResourcesDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Resources") + + return info + +class ApplicationBundleInfo(object): + def __init__(self, path): + self.path = path + appName = os.path.splitext(os.path.basename(path))[0] + self.binaryPath = os.path.join(path, "Contents", "MacOS", appName) + if not os.path.exists(self.binaryPath): + raise RuntimeError("Could not find bundle binary for " + path) + self.resourcesPath = os.path.join(path, "Contents", "Resources") + self.pluginPath = os.path.join(path, "Contents", "PlugIns") + +class DeploymentInfo(object): + def __init__(self): + self.qtPath = None + self.pluginPath = None + self.deployedFrameworks = [] + + def detectQtPath(self, frameworkDirectory): + parentDir = os.path.dirname(frameworkDirectory) + if os.path.exists(os.path.join(parentDir, "translations")): + # Classic layout, e.g. "/usr/local/Trolltech/Qt-4.x.x" + self.qtPath = parentDir + elif os.path.exists(os.path.join(parentDir, "share", "qt4", "translations")): + # MacPorts layout, e.g. "/opt/local/share/qt4" + self.qtPath = os.path.join(parentDir, "share", "qt4") + elif os.path.exists(os.path.join(os.path.dirname(parentDir), "share", "qt4", "translations")): + # Newer Macports layout + self.qtPath = os.path.join(os.path.dirname(parentDir), "share", "qt4") + else: + self.qtPath = os.getenv("QTDIR", None) + + if self.qtPath is not None: + pluginPath = os.path.join(self.qtPath, "plugins") + if os.path.exists(pluginPath): + self.pluginPath = pluginPath + + def usesFramework(self, name): + nameDot = "%s." % name + libNameDot = "lib%s." % name + for framework in self.deployedFrameworks: + if framework.endswith(".framework"): + if framework.startswith(nameDot): + return True + elif framework.endswith(".dylib"): + if framework.startswith(libNameDot): + return True + return False + +def getFrameworks(binaryPath, verbose): + if verbose >= 3: + print "Inspecting with otool: " + binaryPath + otool = subprocess.Popen(["otool", "-L", binaryPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + o_stdout, o_stderr = otool.communicate() + if otool.returncode != 0: + if verbose >= 1: + sys.stderr.write(o_stderr) + sys.stderr.flush() + raise RuntimeError("otool failed with return code %d" % otool.returncode) + + otoolLines = o_stdout.split("\n") + otoolLines.pop(0) # First line is the inspected binary + if ".framework" in binaryPath or binaryPath.endswith(".dylib"): + otoolLines.pop(0) # Frameworks and dylibs list themselves as a dependency. + + libraries = [] + for line in otoolLines: + info = FrameworkInfo.fromOtoolLibraryLine(line.strip()) + if info is not None: + if verbose >= 3: + print "Found framework:" + print info + libraries.append(info) + + return libraries + +def runInstallNameTool(action, *args): + subprocess.check_call(["install_name_tool", "-"+action] + list(args)) + +def changeInstallName(oldName, newName, binaryPath, verbose): + if verbose >= 3: + print "Using install_name_tool:" + print " in", binaryPath + print " change reference", oldName + print " to", newName + runInstallNameTool("change", oldName, newName, binaryPath) + +def changeIdentification(id, binaryPath, verbose): + if verbose >= 3: + print "Using install_name_tool:" + print " change identification in", binaryPath + print " to", id + runInstallNameTool("id", id, binaryPath) + +def runStrip(binaryPath, verbose): + if verbose >= 3: + print "Using strip:" + print " stripped", binaryPath + subprocess.check_call(["strip", "-x", binaryPath]) + +def copyFramework(framework, path, verbose): + if framework.sourceFilePath.startswith("Qt"): + #standard place for Nokia Qt installer's frameworks + fromPath = "/Library/Frameworks/" + framework.sourceFilePath + else: + fromPath = framework.sourceFilePath + + toDir = os.path.join(path, framework.destinationDirectory) + toPath = os.path.join(toDir, framework.binaryName) + + if not os.path.exists(fromPath): + raise RuntimeError("No file at " + fromPath) + + if os.path.exists(toPath): + return None # Already there + + if not os.path.exists(toDir): + os.makedirs(toDir) + + shutil.copy2(fromPath, toPath) + if verbose >= 3: + print "Copied:", fromPath + print " to:", toPath + + permissions = os.stat(toPath) + if not permissions.st_mode & stat.S_IWRITE: + os.chmod(toPath, permissions.st_mode | stat.S_IWRITE) + + if not framework.isDylib(): # Copy resources for real frameworks + fromResourcesDir = framework.sourceResourcesDirectory + if os.path.exists(fromResourcesDir): + toResourcesDir = os.path.join(path, framework.destinationResourcesDirectory) + shutil.copytree(fromResourcesDir, toResourcesDir) + if verbose >= 3: + print "Copied resources:", fromResourcesDir + print " to:", toResourcesDir + elif framework.frameworkName.startswith("libQtGui"): # Copy qt_menu.nib (applies to non-framework layout) + qtMenuNibSourcePath = os.path.join(framework.frameworkDirectory, "Resources", "qt_menu.nib") + qtMenuNibDestinationPath = os.path.join(path, "Contents", "Resources", "qt_menu.nib") + if os.path.exists(qtMenuNibSourcePath) and not os.path.exists(qtMenuNibDestinationPath): + shutil.copytree(qtMenuNibSourcePath, qtMenuNibDestinationPath) + if verbose >= 3: + print "Copied for libQtGui:", qtMenuNibSourcePath + print " to:", qtMenuNibDestinationPath + + return toPath + +def deployFrameworks(frameworks, bundlePath, binaryPath, strip, verbose, deploymentInfo=None): + if deploymentInfo is None: + deploymentInfo = DeploymentInfo() + + while len(frameworks) > 0: + framework = frameworks.pop(0) + deploymentInfo.deployedFrameworks.append(framework.frameworkName) + + if verbose >= 2: + print "Processing", framework.frameworkName, "..." + + # Get the Qt path from one of the Qt frameworks + if deploymentInfo.qtPath is None and framework.isQtFramework(): + deploymentInfo.detectQtPath(framework.frameworkDirectory) + + if framework.installName.startswith("@executable_path"): + if verbose >= 2: + print framework.frameworkName, "already deployed, skipping." + continue + + # install_name_tool the new id into the binary + changeInstallName(framework.installName, framework.deployedInstallName, binaryPath, verbose) + + # Copy farmework to app bundle. + deployedBinaryPath = copyFramework(framework, bundlePath, verbose) + # Skip the rest if already was deployed. + if deployedBinaryPath is None: + continue + + if strip: + runStrip(deployedBinaryPath, verbose) + + # install_name_tool it a new id. + changeIdentification(framework.deployedInstallName, deployedBinaryPath, verbose) + # Check for framework dependencies + dependencies = getFrameworks(deployedBinaryPath, verbose) + + for dependency in dependencies: + changeInstallName(dependency.installName, dependency.deployedInstallName, deployedBinaryPath, verbose) + + # Deploy framework if necessary. + if dependency.frameworkName not in deploymentInfo.deployedFrameworks and dependency not in frameworks: + frameworks.append(dependency) + + return deploymentInfo + +def deployFrameworksForAppBundle(applicationBundle, strip, verbose): + frameworks = getFrameworks(applicationBundle.binaryPath, verbose) + if len(frameworks) == 0 and verbose >= 1: + print "Warning: Could not find any external frameworks to deploy in %s." % (applicationBundle.path) + return DeploymentInfo() + else: + return deployFrameworks(frameworks, applicationBundle.path, applicationBundle.binaryPath, strip, verbose) + +def deployPlugins(appBundleInfo, deploymentInfo, strip, verbose): + # Lookup available plugins, exclude unneeded + plugins = [] + for dirpath, dirnames, filenames in os.walk(deploymentInfo.pluginPath): + pluginDirectory = os.path.relpath(dirpath, deploymentInfo.pluginPath) + if pluginDirectory == "designer": + # Skip designer plugins + continue + elif pluginDirectory == "phonon" or pluginDirectory == "phonon_backend": + # Deploy the phonon plugins only if phonon is in use + if not deploymentInfo.usesFramework("phonon"): + continue + elif pluginDirectory == "sqldrivers": + # Deploy the sql plugins only if QtSql is in use + if not deploymentInfo.usesFramework("QtSql"): + continue + elif pluginDirectory == "script": + # Deploy the script plugins only if QtScript is in use + if not deploymentInfo.usesFramework("QtScript"): + continue + elif pluginDirectory == "qmltooling": + # Deploy the qml plugins only if QtDeclarative is in use + if not deploymentInfo.usesFramework("QtDeclarative"): + continue + elif pluginDirectory == "bearer": + # Deploy the bearer plugins only if QtNetwork is in use + if not deploymentInfo.usesFramework("QtNetwork"): + continue + + for pluginName in filenames: + pluginPath = os.path.join(pluginDirectory, pluginName) + if pluginName.endswith("_debug.dylib"): + # Skip debug plugins + continue + elif pluginPath == "imageformats/libqsvg.dylib" or pluginPath == "iconengines/libqsvgicon.dylib": + # Deploy the svg plugins only if QtSvg is in use + if not deploymentInfo.usesFramework("QtSvg"): + continue + elif pluginPath == "accessible/libqtaccessiblecompatwidgets.dylib": + # Deploy accessibility for Qt3Support only if the Qt3Support is in use + if not deploymentInfo.usesFramework("Qt3Support"): + continue + elif pluginPath == "graphicssystems/libqglgraphicssystem.dylib": + # Deploy the opengl graphicssystem plugin only if QtOpenGL is in use + if not deploymentInfo.usesFramework("QtOpenGL"): + continue + + plugins.append((pluginDirectory, pluginName)) + + for pluginDirectory, pluginName in plugins: + if verbose >= 2: + print "Processing plugin", os.path.join(pluginDirectory, pluginName), "..." + + sourcePath = os.path.join(deploymentInfo.pluginPath, pluginDirectory, pluginName) + destinationDirectory = os.path.join(appBundleInfo.pluginPath, pluginDirectory) + if not os.path.exists(destinationDirectory): + os.makedirs(destinationDirectory) + + destinationPath = os.path.join(destinationDirectory, pluginName) + shutil.copy2(sourcePath, destinationPath) + if verbose >= 3: + print "Copied:", sourcePath + print " to:", destinationPath + + if strip: + runStrip(destinationPath, verbose) + + dependencies = getFrameworks(destinationPath, verbose) + + for dependency in dependencies: + changeInstallName(dependency.installName, dependency.deployedInstallName, destinationPath, verbose) + + # Deploy framework if necessary. + if dependency.frameworkName not in deploymentInfo.deployedFrameworks: + deployFrameworks([dependency], appBundleInfo.path, destinationPath, strip, verbose, deploymentInfo) + +qt_conf="""[Paths] +translations=Resources +plugins=PlugIns +""" + +ap = ArgumentParser(description="""Improved version of macdeployqt. + +Outputs a ready-to-deploy app in a folder "dist" and optionally wraps it in a .dmg file. +Note, that the "dist" folder will be deleted before deploying on each run. + +Optionally, Qt translation files (.qm) and additional resources can be added to the bundle.""") + +ap.add_argument("app_bundle", nargs=1, metavar="app-bundle", help="application bundle to be deployed") +ap.add_argument("-verbose", type=int, nargs=1, default=[1], metavar="<0-3>", help="0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug") +ap.add_argument("-no-plugins", dest="plugins", action="store_false", default=True, help="skip plugin deployment") +ap.add_argument("-no-strip", dest="strip", action="store_false", default=True, help="don't run 'strip' on the binaries") +ap.add_argument("-dmg", nargs="?", const="", metavar="basename", help="create a .dmg disk image; if basename is not specified, a camel-cased version of the app name is used") +ap.add_argument("-fancy", nargs=1, metavar="plist", default=[], help="make a fancy looking disk image using the given plist file with instructions; requires -dmg to work") +ap.add_argument("-add-qt-tr", nargs=1, metavar="languages", default=[], help="add Qt translation files to the bundle's ressources; the language list must be separated with commas, not with whitespace") +ap.add_argument("-add-resources", nargs="+", metavar="path", default=[], help="list of additional files or folders to be copied into the bundle's resources; must be the last argument") + +config = ap.parse_args() + +verbose = config.verbose[0] + +# ------------------------------------------------ + +app_bundle = config.app_bundle[0] + +if not os.path.exists(app_bundle): + if verbose >= 1: + sys.stderr.write("Error: Could not find app bundle \"%s\"\n" % (app_bundle)) + sys.exit(1) + +app_bundle_name = os.path.splitext(os.path.basename(app_bundle))[0] + +# ------------------------------------------------ + +for p in config.add_resources: + if verbose >= 3: + print "Checking for \"%s\"..." % p + if not os.path.exists(p): + if verbose >= 1: + sys.stderr.write("Error: Could not find additional resource file \"%s\"\n" % (p)) + sys.exit(1) + +# ------------------------------------------------ + +if len(config.fancy) == 1: + if verbose >= 3: + print "Fancy: Importing plistlib..." + try: + import plistlib + except ImportError: + if verbose >= 1: + sys.stderr.write("Error: Could not import plistlib which is required for fancy disk images.\n") + sys.exit(1) + + if verbose >= 3: + print "Fancy: Importing appscript..." + try: + import appscript + except ImportError: + if verbose >= 1: + sys.stderr.write("Error: Could not import appscript which is required for fancy disk images.\n") + sys.stderr.write("Please install it e.g. with \"sudo easy_install appscript\".\n") + sys.exit(1) + + p = config.fancy[0] + if verbose >= 3: + print "Fancy: Loading \"%s\"..." % p + if not os.path.exists(p): + if verbose >= 1: + sys.stderr.write("Error: Could not find fancy disk image plist at \"%s\"\n" % (p)) + sys.exit(1) + + try: + fancy = plistlib.readPlist(p) + except: + if verbose >= 1: + sys.stderr.write("Error: Could not parse fancy disk image plist at \"%s\"\n" % (p)) + sys.exit(1) + + try: + assert not fancy.has_key("window_bounds") or (isinstance(fancy["window_bounds"], list) and len(fancy["window_bounds"]) == 4) + assert not fancy.has_key("background_picture") or isinstance(fancy["background_picture"], str) + assert not fancy.has_key("icon_size") or isinstance(fancy["icon_size"], int) + assert not fancy.has_key("applications_symlink") or isinstance(fancy["applications_symlink"], bool) + if fancy.has_key("items_position"): + assert isinstance(fancy["items_position"], dict) + for key, value in fancy["items_position"].iteritems(): + assert isinstance(value, list) and len(value) == 2 and isinstance(value[0], int) and isinstance(value[1], int) + except: + if verbose >= 1: + sys.stderr.write("Error: Bad format of fancy disk image plist at \"%s\"\n" % (p)) + sys.exit(1) + + if fancy.has_key("background_picture"): + bp = fancy["background_picture"] + if verbose >= 3: + print "Fancy: Resolving background picture \"%s\"..." % bp + if not os.path.exists(bp): + bp = os.path.join(os.path.dirname(p), bp) + if not os.path.exists(bp): + if verbose >= 1: + sys.stderr.write("Error: Could not find background picture at \"%s\" or \"%s\"\n" % (fancy["background_picture"], bp)) + sys.exit(1) + else: + fancy["background_picture"] = bp +else: + fancy = None + +# ------------------------------------------------ + +if os.path.exists("dist"): + if verbose >= 2: + print "+ Removing old dist folder +" + + shutil.rmtree("dist") + +# ------------------------------------------------ + +target = os.path.join("dist", app_bundle) + +if verbose >= 2: + print "+ Copying source bundle +" +if verbose >= 3: + print app_bundle, "->", target + +os.mkdir("dist") +shutil.copytree(app_bundle, target) + +applicationBundle = ApplicationBundleInfo(target) + +# ------------------------------------------------ + +if verbose >= 2: + print "+ Deploying frameworks +" + +try: + deploymentInfo = deployFrameworksForAppBundle(applicationBundle, config.strip, verbose) + if deploymentInfo.qtPath is None: + deploymentInfo.qtPath = os.getenv("QTDIR", None) + if deploymentInfo.qtPath is None: + if verbose >= 1: + sys.stderr.write("Warning: Could not detect Qt's path, skipping plugin deployment!\n") + config.plugins = False +except RuntimeError as e: + if verbose >= 1: + sys.stderr.write("Error: %s\n" % str(e)) + sys.exit(ret) + +# ------------------------------------------------ + +if config.plugins: + if verbose >= 2: + print "+ Deploying plugins +" + + try: + deployPlugins(applicationBundle, deploymentInfo, config.strip, verbose) + except RuntimeError as e: + if verbose >= 1: + sys.stderr.write("Error: %s\n" % str(e)) + sys.exit(ret) + +# ------------------------------------------------ + +if len(config.add_qt_tr) == 0: + add_qt_tr = [] +else: + qt_tr_dir = os.path.join(deploymentInfo.qtPath, "translations") + add_qt_tr = ["qt_%s.qm" % lng for lng in config.add_qt_tr[0].split(",")] + for lng_file in add_qt_tr: + p = os.path.join(qt_tr_dir, lng_file) + if verbose >= 3: + print "Checking for \"%s\"..." % p + if not os.path.exists(p): + if verbose >= 1: + sys.stderr.write("Error: Could not find Qt translation file \"%s\"\n" % (lng_file)) + sys.exit(1) + +# ------------------------------------------------ + +if verbose >= 2: + print "+ Installing qt.conf +" + +f = open(os.path.join(applicationBundle.resourcesPath, "qt.conf"), "wb") +f.write(qt_conf) +f.close() + +# ------------------------------------------------ + +if len(add_qt_tr) > 0 and verbose >= 2: + print "+ Adding Qt translations +" + +for lng_file in add_qt_tr: + if verbose >= 3: + print os.path.join(qt_tr_dir, lng_file), "->", os.path.join(applicationBundle.resourcesPath, lng_file) + shutil.copy2(os.path.join(qt_tr_dir, lng_file), os.path.join(applicationBundle.resourcesPath, lng_file)) + +# ------------------------------------------------ + +if len(config.add_resources) > 0 and verbose >= 2: + print "+ Adding additional resources +" + +for p in config.add_resources: + t = os.path.join(applicationBundle.resourcesPath, os.path.basename(p)) + if verbose >= 3: + print p, "->", t + if os.path.isdir(p): + shutil.copytree(p, t) + else: + shutil.copy2(p, t) + +# ------------------------------------------------ + +if config.dmg is not None: + def runHDIUtil(verb, image_basename, **kwargs): + hdiutil_args = ["hdiutil", verb, image_basename + ".dmg"] + if kwargs.has_key("capture_stdout"): + del kwargs["capture_stdout"] + run = subprocess.check_output + else: + if verbose < 2: + hdiutil_args.append("-quiet") + elif verbose >= 3: + hdiutil_args.append("-verbose") + run = subprocess.check_call + + for key, value in kwargs.iteritems(): + hdiutil_args.append("-" + key) + if not value is True: + hdiutil_args.append(str(value)) + + return run(hdiutil_args) + + if verbose >= 2: + if fancy is None: + print "+ Creating .dmg disk image +" + else: + print "+ Preparing .dmg disk image +" + + if config.dmg != "": + dmg_name = config.dmg + else: + spl = app_bundle_name.split(" ") + dmg_name = spl[0] + "".join(p.capitalize() for p in spl[1:]) + + if fancy is None: + try: + runHDIUtil("create", dmg_name, srcfolder="dist", format="UDBZ", volname=app_bundle_name, ov=True) + except subprocess.CalledProcessError as e: + sys.exit(e.returncode) + else: + if verbose >= 3: + print "Determining size of \"dist\"..." + size = 0 + for path, dirs, files in os.walk("dist"): + for file in files: + size += os.path.getsize(os.path.join(path, file)) + size += int(size * 0.1) + + if verbose >= 3: + print "Creating temp image for modification..." + try: + runHDIUtil("create", dmg_name + ".temp", srcfolder="dist", format="UDRW", size=size, volname=app_bundle_name, ov=True) + except subprocess.CalledProcessError as e: + sys.exit(e.returncode) + + if verbose >= 3: + print "Attaching temp image..." + try: + output = runHDIUtil("attach", dmg_name + ".temp", readwrite=True, noverify=True, noautoopen=True, capture_stdout=True) + except subprocess.CalledProcessError as e: + sys.exit(e.returncode) + + m = re.search("/Volumes/(.+$)", output) + disk_root = m.group(0) + disk_name = m.group(1) + + if verbose >= 2: + print "+ Applying fancy settings +" + + if fancy.has_key("background_picture"): + bg_path = os.path.join(disk_root, os.path.basename(fancy["background_picture"])) + if verbose >= 3: + print fancy["background_picture"], "->", bg_path + shutil.copy2(fancy["background_picture"], bg_path) + else: + bg_path = None + + if fancy.get("applications_symlink", False): + os.symlink("/Applications", os.path.join(disk_root, "Applications")) + + finder = appscript.app("Finder") + disk = finder.disks[disk_name] + disk.open() + window = disk.container_window + window.current_view.set(appscript.k.icon_view) + window.toolbar_visible.set(False) + window.statusbar_visible.set(False) + if fancy.has_key("window_bounds"): + window.bounds.set(fancy["window_bounds"]) + view_options = window.icon_view_options + view_options.arrangement.set(appscript.k.not_arranged) + if fancy.has_key("icon_size"): + view_options.icon_size.set(fancy["icon_size"]) + if bg_path is not None: + view_options.background_picture.set(disk.files[os.path.basename(bg_path)]) + if fancy.has_key("items_position"): + for name, position in fancy["items_position"].iteritems(): + window.items[name].position.set(position) + disk.close() + if bg_path is not None: + subprocess.call(["SetFile", "-a", "V", bg_path]) + disk.update(registering_applications=False) + sleep(2) + disk.eject() + + if verbose >= 2: + print "+ Finalizing .dmg disk image +" + + try: + runHDIUtil("convert", dmg_name + ".temp", format="UDBZ", o=dmg_name + ".dmg", ov=True) + except subprocess.CalledProcessError as e: + sys.exit(e.returncode) + + os.unlink(dmg_name + ".temp.dmg") + +# ------------------------------------------------ + +if verbose >= 2: + print "+ Done +" + +sys.exit(0) diff --git a/contrib/macdeploy/notes.txt b/contrib/macdeploy/notes.txt new file mode 100644 index 0000000..2e23e78 --- /dev/null +++ b/contrib/macdeploy/notes.txt @@ -0,0 +1,26 @@ + +macdeployqtplus works best on OS X Lion, for Snow Leopard you'd need to install +Python 2.7 and make it your default Python installation. + +You will need the appscript package for the fancy disk image creation to work. +Install it by invoking "sudo easy_install appscript". + +Ths script should be invoked in the target directory like this: +$source_dir/contrib/macdeploy/macdeployqtplus SONO-Qt.app -add-qt-tr da,de,es,hu,ru,uk,zh_CN,zh_TW -dmg -fancy $source_dir/contrib/macdeploy/fancy.plist -verbose 2 + +During the process, the disk image window will pop up briefly where the fancy +settings are applied. This is normal, please do not interfere. + +You can also set up Qt Creator for invoking the script. For this, go to the +"Projects" tab on the left side, switch to "Run Settings" above and add a +deploy configuration. Next add a deploy step choosing "Custom Process Step". +Fill in the following. + +Enable custom process step: [x] +Command: %{sourceDir}/contrib/macdeploy/macdeployqtplus +Working directory: %{buildDir} +Command arguments: SONO-Qt.app -add-qt-tr da,de,es,hu,ru,uk,zh_CN,zh_TW -dmg -fancy %{sourceDir}/contrib/macdeploy/fancy.plist -verbose 2 + +After that you can start the deployment process through the menu with +Build -> Deploy Project "SONO-qt" + diff --git a/contrib/qt_translations.py b/contrib/qt_translations.py new file mode 100644 index 0000000..a43281f --- /dev/null +++ b/contrib/qt_translations.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +# Helpful little script that spits out a comma-separated list of +# language codes for Qt icons that should be included +# in binary SONO distributions + +import glob +import os +import re +import sys + +if len(sys.argv) != 3: + sys.exit("Usage: %s $QTDIR/translations $TRANSFERDIR/src/qt/locale"%sys.argv[0]) + +d1 = sys.argv[1] +d2 = sys.argv[2] + +l1 = set([ re.search(r'qt_(.*).qm', f).group(1) for f in glob.glob(os.path.join(d1, 'qt_*.qm')) ]) +l2 = set([ re.search(r'SONO_(.*).qm', f).group(1) for f in glob.glob(os.path.join(d2, 'SONO_*.qm')) ]) + +print ",".join(sorted(l1.intersection(l2))) + diff --git a/contrib/wallettools/walletchangepass.py b/contrib/wallettools/walletchangepass.py new file mode 100644 index 0000000..30f3f5b --- /dev/null +++ b/contrib/wallettools/walletchangepass.py @@ -0,0 +1,5 @@ +from jsonrpc import ServiceProxy +access = ServiceProxy("http://127.0.0.1:8332") +pwd = raw_input("Enter old wallet passphrase: ") +pwd2 = raw_input("Enter new wallet passphrase: ") +access.walletpassphrasechange(pwd, pwd2) \ No newline at end of file diff --git a/contrib/wallettools/walletunlock.py b/contrib/wallettools/walletunlock.py new file mode 100644 index 0000000..f847c6f --- /dev/null +++ b/contrib/wallettools/walletunlock.py @@ -0,0 +1,4 @@ +from jsonrpc import ServiceProxy +access = ServiceProxy("http://127.0.0.1:8332") +pwd = raw_input("Enter wallet passphrase: ") +access.walletpassphrase(pwd, 60) \ No newline at end of file diff --git a/doc/Doxyfile b/doc/Doxyfile new file mode 100644 index 0000000..db7ce61 --- /dev/null +++ b/doc/Doxyfile @@ -0,0 +1,1752 @@ +# Doxyfile 1.7.4 + +# !!! Invoke doxygen from project root using: +# doxygen doc/Doxyfile + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = Bitcoin + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 0.5.0 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "P2P Digital Currency" + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = doc/bitcoin_logo_doxygen.png + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc/doxygen + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = src + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is adviced to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the +# mathjax.org site, so you can quickly see the result without installing +# MathJax, but it is strongly recommended to install a local copy of MathJax +# before deployment. + +MATHJAX_RELPATH = http://www.mathjax.org/mathjax + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRSONO tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRSONO = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will write a font called Helvetica to the output +# directory and reference it in all dot files that doxygen generates. +# When you want a differently looking font you can specify the font name +# using DOT_FONTNAME. You need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRSONO tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/doc/README b/doc/README new file mode 100644 index 0000000..c96fda0 --- /dev/null +++ b/doc/README @@ -0,0 +1,18 @@ +SONO 0.4.4 BETA + +Copyright (c) 2013 NovaCoin Developers +Copyright (c) 2011-2012 PPCoin Developers +Distributed under the MIT/X11 software license, see the accompanying +file license.txt or http://www.opensource.org/licenses/mit-license.php. +This product includes software developed by the OpenSSL Project for use in +the OpenSSL Toolkit (http://www.openssl.org/). This product includes +cryptographic software written by Eric Young (eay@cryptsoft.com). + + +Intro +----- +SONO is a free open source project derived from Bitcoin, with +the goal of providing a long-term energy-efficient scrypt-based crypto-currency. +Built on the foundation of Bitcoin, PPCoin and NovaCoin, innovations such as proof-of-stake +help further advance the field of crypto-currency. + diff --git a/doc/README_windows.txt b/doc/README_windows.txt new file mode 100644 index 0000000..a96d10c --- /dev/null +++ b/doc/README_windows.txt @@ -0,0 +1,18 @@ +SONO 0.4.4 BETA + +Copyright (c) 2013 NovaCoin Developers +Copyright (c) 2011-2013 PPCoin Developers +Distributed under the MIT/X11 software license, see the accompanying +file license.txt or http://www.opensource.org/licenses/mit-license.php. +This product includes software developed by the OpenSSL Project for use in +the OpenSSL Toolkit (http://www.openssl.org/). This product includes +cryptographic software written by Eric Young (eay@cryptsoft.com). + + +Intro +----- +SONO is a free open source project derived from Bitcoin, with +the goal of providing a long-term energy-efficient scrypt-based crypto-currency. +Built on the foundation of Bitcoin, PPCoin and NovaCoin, innovations such as proof-of-stake and scrypt +help further advance the field of crypto-currency. + diff --git a/doc/bitcoin_logo_doxygen.png b/doc/bitcoin_logo_doxygen.png new file mode 100644 index 0000000..5b41b02 Binary files /dev/null and b/doc/bitcoin_logo_doxygen.png differ diff --git a/doc/build-msw.md b/doc/build-msw.md new file mode 100644 index 0000000..3220ab1 --- /dev/null +++ b/doc/build-msw.md @@ -0,0 +1,100 @@ +Copyright (c) 2009-2012 Bitcoin Developers +Distributed under the MIT/X11 software license, see the accompanying +file license.txt or http://www.opensource.org/licenses/mit-license.php. +This product includes software developed by the OpenSSL Project for use in +the OpenSSL Toolkit (http://www.openssl.org/). This product includes +cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP +software written by Thomas Bernard. + + +See readme-qt.rst for instructions on building SONO QT, the +graphical user interface. + +WINDOWS BUILD NOTES +=================== + +Compilers Supported +------------------- +TODO: What works? +Note: releases are cross-compiled using mingw running on Linux. + + +Dependencies +------------ +Libraries you need to download separately and build: + + default path download +OpenSSL \openssl-1.0.1p-mgw http://www.openssl.org/source/ +Berkeley DB \db-4.8.30.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html +Boost \boost-1.57.0-mgw http://www.boost.org/users/download/ +miniupnpc \miniupnpc-1.6-mgw http://miniupnp.tuxfamily.org/files/ +Secp256k1 \secp256k1 https://github.com/bitcoin/secp256k1 + +Their licenses: +OpenSSL Old BSD license with the problematic advertising requirement +Berkeley DB New BSD license with additional requirement that linked software must be free open source +Boost MIT-like license +miniupnpc New (3-clause) BSD license +Secp256k1 + +Versions used in this release: +OpenSSL 1.0.1p +Berkeley DB 4.8.30.NC +Boost 1.57.0 +miniupnpc 1.6 +Secp256k1 + + +OpenSSL +------- +MSYS SONO: +un-tar sources with MSYS 'tar xfz' to avoid issue with symlinks (OpenSSL ticket 2377) +change 'MAKE' env. variable from 'C:\MinGW32\bin\mingw32-make.exe' to '/c/MinGW32/bin/mingw32-make.exe' + +cd /c/dev/coindeps32/openssl-1.0.1p-mgw +./config +make + +Berkeley DB +----------- +MSYS SONO: + + cd /c/dev/coindeps32/db-4.8.30.NC-mgw/build_unix + sh ../dist/configure --enable-mingw --enable-cxx + make + +Boost +----- +DOS prompt: + + downloaded boost jam 3.1.18 + cd \dev\coindeps32\boost-1.57.0-mgw + bjam toolset=gcc --build-type=complete stage + +Secp256k1 +----------- +MSYS SONO: + + ./autogen.sh + ./configure --enable-module-recovery --prefix /c/dev/coindeps32/Secp256k1 + make + make install + +MiniUPnPc +--------- +UPnP support is optional, make with USE_UPNP= to disable it. + +MSYS SONO: + + cd /c/miniupnpc-1.6-mgw + make -f Makefile.mingw + mkdir miniupnpc + cp *.h miniupnpc/ + +Build SONOd +------- +DOS prompt: + + cd \SONO\src + mingw32-make -f makefile.mingw + strip SONOd.exe diff --git a/doc/build-msw.txt b/doc/build-msw.txt new file mode 100644 index 0000000..f926277 --- /dev/null +++ b/doc/build-msw.txt @@ -0,0 +1,84 @@ +Copyright (c) 2009-2012 Bitcoin Developers +Distributed under the MIT/X11 software license, see the accompanying +file license.txt or http://www.opensource.org/licenses/mit-license.php. +This product includes software developed by the OpenSSL Project for use in +the OpenSSL Toolkit (http://www.openssl.org/). This product includes +cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP +software written by Thomas Bernard. + + +See readme-qt.rst for instructions on building SONO QT, the +graphical user interface. + +WINDOWS BUILD NOTES +=================== + +Compilers Supported +------------------- +TODO: What works? +Note: releases are cross-compiled using mingw running on Linux. + + +Dependencies +------------ +Libraries you need to download separately and build: + + default path download +OpenSSL \openssl-1.0.1b-mgw http://www.openssl.org/source/ +Berkeley DB \db-4.8.30.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html +Boost \boost-1.47.0-mgw http://www.boost.org/users/download/ +miniupnpc \miniupnpc-1.6-mgw http://miniupnp.tuxfamily.org/files/ + +Their licenses: +OpenSSL Old BSD license with the problematic advertising requirement +Berkeley DB New BSD license with additional requirement that linked software must be free open source +Boost MIT-like license +miniupnpc New (3-clause) BSD license + +Versions used in this release: +OpenSSL 1.0.1b +Berkeley DB 4.8.30.NC +Boost 1.47.0 +miniupnpc 1.6 + + +OpenSSL +------- +MSYS SONO: +un-tar sources with MSYS 'tar xfz' to avoid issue with symlinks (OpenSSL ticket 2377) +change 'MAKE' env. variable from 'C:\MinGW32\bin\mingw32-make.exe' to '/c/MinGW32/bin/mingw32-make.exe' + +cd /c/openssl-1.0.1b-mgw +./config +make + +Berkeley DB +----------- +MSYS SONO: +cd /c/db-4.8.30.NC-mgw/build_unix +sh ../dist/configure --enable-mingw --enable-cxx +make + +Boost +----- +DOS prompt: +downloaded boost jam 3.1.18 +cd \boost-1.47.0-mgw +bjam toolset=gcc --build-type=complete stage + +MiniUPnPc +--------- +UPnP support is optional, make with USE_UPNP= to disable it. + +MSYS SONO: +cd /c/miniupnpc-1.6-mgw +make -f Makefile.mingw +mkdir miniupnpc +cp *.h miniupnpc/ + +SONO +------- +DOS prompt: +cd \SONO\src +mingw32-make -f makefile.mingw +strip SONOd.exe diff --git a/doc/build-osx.md b/doc/build-osx.md new file mode 100644 index 0000000..b909c77 --- /dev/null +++ b/doc/build-osx.md @@ -0,0 +1,54 @@ +Copyright (c) 2009-2012 Bitcoin Developers +Distributed under the MIT/X11 software license, see the accompanying file +license.txt or http://www.opensource.org/licenses/mit-license.php. This +product includes software developed by the OpenSSL Project for use in the +OpenSSL Toolkit (http://www.openssl.org/). This product includes cryptographic +software written by Eric Young (eay@cryptsoft.com) and UPnP software written by +Thomas Bernard. + + +Mac OS X SONOd build instructions +Laszlo Hanyecz +Douglas Huff + + +See readme-qt.rst for instructions on building SONO QT, the +graphical user interface. + +Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian. + +All of the commands should be executed in Terminal.app.. it's in +/Applications/Utilities + +You need to install XCode with all the options checked so that the compiler and +everything is available in /usr not just /Developer I think it comes on the DVD +but you can get the current version from http://developer.apple.com + + +1. Clone the github tree to get the source code: + +git clone http://github.com/SONOdev/SONO SONO + +2. Download and install MacPorts from http://www.macports.org/ + +2a. (for 10.7 Lion) + Edit /opt/local/etc/macports/macports.conf and uncomment "build_arch i386" + +3. Install dependencies from MacPorts + +sudo port install boost db48 openssl miniupnpc + +Optionally install qrencode (and set USE_QRCODE=1): +sudo port install qrencode + +4. Now you should be able to build SONOd: + +cd SONO/src +make -f makefile.osx + +Run: + ./SONOd --help # for a list of command-line options. +Run + ./SONOd -daemon # to start the SONO daemon. +Run + ./SONOd help # When the daemon is running, to get a list of RPC commands diff --git a/doc/build-osx.txt b/doc/build-osx.txt new file mode 100644 index 0000000..e4c13a1 --- /dev/null +++ b/doc/build-osx.txt @@ -0,0 +1,54 @@ +Copyright (c) 2009-2012 Bitcoin Developers +Distributed under the MIT/X11 software license, see the accompanying file +license.txt or http://www.opensource.org/licenses/mit-license.php. This +product includes software developed by the OpenSSL Project for use in the +OpenSSL Toolkit (http://www.openssl.org/). This product includes cryptographic +software written by Eric Young (eay@cryptsoft.com) and UPnP software written by +Thomas Bernard. + + +Mac OS X SONOd build instructions +Laszlo Hanyecz +Douglas Huff + + +See readme-qt.rst for instructions on building SONO QT, the +graphical user interface. + +Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian. + +All of the commands should be executed in Terminal.app.. it's in +/Applications/Utilities + +You need to install XCode with all the options checked so that the compiler and +everything is available in /usr not just /Developer I think it comes on the DVD +but you can get the current version from http://developer.apple.com + + +1. Clone the github tree to get the source code: + +git clone git@github.com:rat4/SONO.git SONO + +2. Download and install MacPorts from http://www.macports.org/ + +2a. (for 10.7 Lion) + Edit /opt/local/etc/macports/macports.conf and uncomment "build_arch i386" + +3. Install dependencies from MacPorts + +sudo port install boost db48 openssl miniupnpc + +Optionally install qrencode (and set USE_QRCODE=1): +sudo port install qrencode + +4. Now you should be able to build SONOd: + +cd SONO/src +make -f makefile.osx + +Run: + ./SONOd --help # for a list of command-line options. +Run + ./SONOd -daemon # to start the SONO daemon. +Run + ./SONOd help # When the daemon is running, to get a list of RPC commands diff --git a/doc/build-unix.md b/doc/build-unix.md new file mode 100644 index 0000000..4694dda --- /dev/null +++ b/doc/build-unix.md @@ -0,0 +1,215 @@ +Copyright (c) 2009-2012 Bitcoin Developers +Distributed under the MIT/X11 software license, see the accompanying +file license.txt or http://www.opensource.org/licenses/mit-license.php. +This product includes software developed by the OpenSSL Project for use in +the OpenSSL Toolkit (http://www.openssl.org/). This product includes +cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP +software written by Thomas Bernard. + + +UNIX BUILD NOTES +================ + +Dependencies +--------------------- + +These dependencies are required: + + Library | Purpose | Description + ------------|------------------|---------------------- + libssl | Crypto | Random Number Generation + libgmp | Secp256k1 | Secp256k1 Dependency + libboost | Utility | Library for threading, data structures, etc + libevent | Networking | OS independent asynchronous networking + libdb4.8 | Berkeley DB | Wallet storage (only needed when wallet enabled) + libsecp256k1| Secp256k1 | Elliptic Curve Cryptography + +Optional dependencies: + + Library | Purpose | Description + ------------|------------------|---------------------- + miniupnpc | UPnP Support | Firewall-jumping support + qt | GUI | GUI toolkit (only needed when GUI enabled) + protobuf | Payments in GUI | Data interchange format used for payment protocol (only needed when GUI enabled) + libqrencode | QR codes in GUI | Optional for generating QR codes (only needed when GUI enabled) + +For the versions used in the release, see [release-process.md](release-process.md) under *Fetch and build inputs*. + +System requirements +-------------------- + +C++ compilers are memory-hungry. It is recommended to have at least 1 GB of +memory available when compiling SONO Core. With 512MB of memory or less +compilation will take much longer due to swap thrashing. + +Dependency Build Instructions: Ubuntu & Debian +---------------------------------------------- +Build requirements: + + sudo apt-get install build-essential libtool automake autotools-dev autoconf pkg-config libssl-dev libgmp3-dev libevent-dev bsdmainutils + +On at least Ubuntu 14.04+ and Debian 7+ there are generic names for the +individual boost development packages, so the following can be used to only +install necessary parts of boost: + + sudo apt-get install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev + +If that doesn't work, you can install all boost development packages with: + + sudo apt-get install libboost-all-dev + +BerkeleyDB is required for the wallet. db4.8 packages are available [here](https://launchpad.net/~bitcoin/+archive/bitcoin). +You can add the repository and install using the following commands: + + sudo add-apt-repository ppa:bitcoin/bitcoin + sudo apt-get update + sudo apt-get install libdb4.8-dev libdb4.8++-dev + +Ubuntu and Debian have their own libdb-dev and libdb++-dev packages, but these will install +BerkeleyDB 5.1 or later, which break binary wallet compatibility with the distributed executables which +are based on BerkeleyDB 4.8. If you do not care about wallet compatibility, +pass `--with-incompatible-bdb` to configure. + +Optional: + + sudo apt-get install libminiupnpc-dev (see --with-miniupnpc and --enable-upnp-default) + +Dependencies for the GUI: Ubuntu & Debian +----------------------------------------- + +If you want to build SONO-Qt, make sure that the required packages for Qt development +are installed. Qt 5 is necessary to build the GUI. +If both Qt 4 and Qt 5 are installed, Qt 5 will be used. + +To build with Qt 5 (recommended) you need the following: + + sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler + +libqrencode (optional) can be installed with: + + sudo apt-get install libqrencode-dev + +Once these are installed, they will be found by configure and a SONO-qt executable will be +built by default. + +Berkeley DB +----------- +It is recommended to use Berkeley DB 4.8. If you have to build it yourself: + +```bash +TRANSFER_ROOT=$(pwd) + +# Pick some path to install BDB to, here we create a directory within the SONO directory +BDB_PREFIX="${TRANSFER_ROOT}/db4" +mkdir -p $BDB_PREFIX + +# Fetch the source and verify that it is not tampered with +wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz' +echo '12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef db-4.8.30.NC.tar.gz' | sha256sum -c +# -> db-4.8.30.NC.tar.gz: OK +tar -xzvf db-4.8.30.NC.tar.gz + +# Build the library and install to our prefix +cd db-4.8.30.NC/build_unix/ +# Note: Do a static build so that it can be embedded into the executable, instead of having to find a .so at runtime +../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX +make install + +# Configure SONO Core to use our own-built instance of BDB +cd $TRANSFER_ROOT +./autogen.sh +./configure LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/" # (other args...) +``` + +Notes +----- +1) You only need Berkeley DB if the wallet is enabled (see the section *Disable-Wallet mode* below). + +2) The release is built with GCC and then "strip SONOd" to strip the debug +symbols, which reduces the executable size by about 90%. + +To Build SONOd +-------- + +With UPNP: + + cd src && \ + make -f makefile.unix && \ + strip SONOd + +(Recommended) Without UPNP: + + cd src && \ + make -f makefile.unix USE_UPNP= && \ + strip SONOd + +To Build SONO-QT +-------- + +With UPNP: + qmake -qt=qt5 && \ + make \ + +(Recommended) Without UPNP: + + qmake -qt=qt5 USE_UPNP=- && \ + make \ + +Boost +----- +If you need to build Boost yourself: + + sudo su + ./bootstrap.sh + ./bjam install + +Upnp +--------- +If you need to build miniupnpc yourself: + + tar -xzvf miniupnpc-1.6.tar.gz + cd miniupnpc-1.6 + make + sudo su + make install + +Security +-------- +To help make your SONO installation more secure by making certain attacks impossible to +exploit even if a vulnerability is found, you can take the following measures: + +* Position Independent Executable + Build position independent code to take advantage of Address Space Layout Randomization + offered by some kernels. An attacker who is able to cause execution of code at an arbitrary + memory location is thwarted if he doesn't know where anything useful is located. + The stack and heap are randomly located by default but this allows the code section to be + randomly located as well. + + On an Amd64 processor where a library was not compiled with -fPIC, this will cause an error + such as: "relocation R_X86_64_32 against `......' can not be used when making a shared object;" + + To build with PIE, use: + make -f makefile.unix ... -e PIE=1 + + To test that you have built PIE executable, install scanelf, part of paxutils, and use: + scanelf -e ./SONO + + The output should contain: + TYPE + ET_DYN + +* Non-executable Stack + If the stack is executable then trivial stack based buffer overflow exploits are possible if + vulnerable buffers are found. By default, SONO should be built with a non-executable stack + but if one of the libraries it uses asks for an executable stack or someone makes a mistake + and uses a compiler extension which requires an executable stack, it will silently build an + executable without the non-executable stack protection. + + To verify that the stack is non-executable after compiling use: + scanelf -e ./SONO + + the output should contain: + STK/REL/PTL + RW- R-- RW- + + The STK RW- means that the stack is readable and writeable but not executable. diff --git a/doc/build-unix.txt b/doc/build-unix.txt new file mode 100644 index 0000000..a935585 --- /dev/null +++ b/doc/build-unix.txt @@ -0,0 +1,153 @@ +Copyright (c) 2009-2012 Bitcoin Developers +Distributed under the MIT/X11 software license, see the accompanying +file license.txt or http://www.opensource.org/licenses/mit-license.php. +This product includes software developed by the OpenSSL Project for use in +the OpenSSL Toolkit (http://www.openssl.org/). This product includes +cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP +software written by Thomas Bernard. + + +UNIX BUILD NOTES +================ + +To Build +-------- + +cd src/ +make -f makefile.unix # Headless SONO + +See readme-qt.rst for instructions on building SONO QT, +the graphical SONO. + +Dependencies +------------ + + Library Purpose Description + ------- ------- ----------- + libssl SSL Support Secure communications + libdb Berkeley DB Blockchain & wallet storage + libboost Boost C++ Library + miniupnpc UPnP Support Optional firewall-jumping support + libqrencode QRCode generation Optional QRCode generation + +Note that libexecinfo should be installed, if you building under *BSD systems. +This library provides backtrace facility. + +miniupnpc may be used for UPnP port mapping. It can be downloaded from +http://miniupnp.tuxfamily.org/files/. UPnP support is compiled in and +turned off by default. Set USE_UPNP to a different value to control this: + USE_UPNP=- No UPnP support - miniupnp not required + USE_UPNP=0 (the default) UPnP support turned off by default at runtime + USE_UPNP=1 UPnP support turned on by default at runtime + +libqrencode may be used for QRCode image generation. It can be downloaded +from http://fukuchi.org/works/qrencode/index.html.en, or installed via +your package manager. Set USE_QRCODE to control this: + USE_QRCODE=0 (the default) No QRCode support - libqrcode not required + USE_QRCODE=1 QRCode support enabled + +Licenses of statically linked libraries: + Berkeley DB New BSD license with additional requirement that linked + software must be free open source + Boost MIT-like license + miniupnpc New (3-clause) BSD license + +Versions used in this release: + GCC 4.9.0 + OpenSSL 1.0.1g + Berkeley DB 5.3.28.NC + Boost 1.55.0 + miniupnpc 1.9.20140401 + +Dependency Build Instructions: Ubuntu & Debian +---------------------------------------------- +sudo apt-get install build-essential +sudo apt-get install libssl-dev +sudo apt-get install libdb++-dev +sudo apt-get install libboost-all-dev +sudo apt-get install libqrencode-dev + +If using Boost 1.37, append -mt to the boost libraries in the makefile. + + +Dependency Build Instructions: Gentoo +------------------------------------- + +emerge -av1 --noreplace boost openssl sys-libs/db + +Take the following steps to build (no UPnP support): + cd ${TX_DIR}/src + make -f makefile.unix USE_UPNP= + strip SONOd + + +Notes +----- +The release is built with GCC and then "strip SONOd" to strip the debug +symbols, which reduces the executable size by about 90%. + + +miniupnpc +--------- +tar -xzvf miniupnpc-1.6.tar.gz +cd miniupnpc-1.6 +make +sudo su +make install + + +Berkeley DB +----------- +You need Berkeley DB. If you have to build Berkeley DB yourself: +../dist/configure --enable-cxx +make + + +Boost +----- +If you need to build Boost yourself: +sudo su +./bootstrap.sh +./bjam install + + +Security +-------- +To help make your SONO installation more secure by making certain attacks impossible to +exploit even if a vulnerability is found, you can take the following measures: + +* Position Independent Executable + Build position independent code to take advantage of Address Space Layout Randomization + offered by some kernels. An attacker who is able to cause execution of code at an arbitrary + memory location is thwarted if he doesn't know where anything useful is located. + The stack and heap are randomly located by default but this allows the code section to be + randomly located as well. + + On an Amd64 processor where a library was not compiled with -fPIC, this will cause an error + such as: "relocation R_X86_64_32 against `......' can not be used when making a shared object;" + + To build with PIE, use: + make -f makefile.unix ... -e PIE=1 + + To test that you have built PIE executable, install scanelf, part of paxutils, and use: + scanelf -e ./SONO + + The output should contain: + TYPE + ET_DYN + +* Non-executable Stack + If the stack is executable then trivial stack based buffer overflow exploits are possible if + vulnerable buffers are found. By default, SONO should be built with a non-executable stack + but if one of the libraries it uses asks for an executable stack or someone makes a mistake + and uses a compiler extension which requires an executable stack, it will silently build an + executable without the non-executable stack protection. + + To verify that the stack is non-executable after compiling use: + scanelf -e ./SONO + + the output should contain: + STK/REL/PTL + RW- R-- RW- + + The STK RW- means that the stack is readable and writeable but not executable. diff --git a/doc/coding.txt b/doc/coding.txt new file mode 100644 index 0000000..9ec3221 --- /dev/null +++ b/doc/coding.txt @@ -0,0 +1,93 @@ +Please be consistent with the existing coding style. + +Block style: + +bool Function(char* psz, int n) +{ + // Comment summarising what this section of code does + for (int i = 0; i < n; i++) + { + // When something fails, return early + if (!Something()) + return false; + ... + } + + // Success return is usually at the end + return true; +} + +- ANSI/Allman block style +- 4 space indenting, no tabs +- No extra spaces inside parenthesis; please don't do ( this ) +- No space after function names, one space after if, for and while + +Variable names begin with the type in lowercase, like nSomeVariable. +Please don't put the first word of the variable name in lowercase like +someVariable. + +Common types: +n integer number: short, unsigned short, int, unsigned int, + int64_t, uint64_t, sometimes char if used as a number +d double, float +f flag +hash uint256 +p pointer or array, one p for each level of indirection +psz pointer to null terminated string +str string object +v vector or similar list objects +map map or multimap +set set or multiset +bn CBigNum + +------------------------- +Locking/mutex usage notes + +The code is multi-threaded, and uses mutexes and the +CRITICAL_BLOCK/TRY_CRITICAL_BLOCK macros to protect data structures. + +Deadlocks due to inconsistent lock ordering (thread 1 locks cs_main +and then cs_wallet, while thread 2 locks them in the opposite order: +result, deadlock as each waits for the other to release its lock) are +a problem. Compile with -DDEBUG_LOCKORDER to get lock order +inconsistencies reported in the debug.log file. + +Re-architecting the core code so there are better-defined interfaces +between the various components is a goal, with any necessary locking +done by the components (e.g. see the self-contained CKeyStore class +and its cs_KeyStore lock for example). + +------- +Threads + +StartNode : Starts other threads. + +ThreadSocketHandler : Sends/Receives data from peers on port 8333. + +ThreadMessageHandler : Higher-level message handling (sending and +receiving). + +ThreadOpenConnections : Initiates new connections to peers. + +ThreadTopUpKeyPool : replenishes the keystore's keypool. + +ThreadCleanWalletPassphrase : re-locks an encrypted wallet after user +has unlocked it for a period of time. + +SendingDialogStartSONO : used by pay-via-ip-address code (obsolete) + +ThreadDelayedRepaint : repaint the gui + +ThreadFlushWalletDB : Close the wallet.dat file if it hasn't been used +in 500ms. + +ThreadRPCServer : Remote procedure call handler, listens on port 8332 +for connections and services them. + +ThreadBitcoinMiner : Generates bitcoins + +ThreadMapPort : Universal plug-and-play startup/shutdown + +Shutdown : Does an orderly shutdown of everything + +ExitTimeout : Windows-only, sleeps 5 seconds then exits application diff --git a/doc/readme-qt.rst b/doc/readme-qt.rst new file mode 100644 index 0000000..e357e9f --- /dev/null +++ b/doc/readme-qt.rst @@ -0,0 +1,14 @@ +SONO-qt: Qt5 GUI for SONO +=============================== + +Linux +------- +https://github.com/SONO/SONO/blob/master/doc/build-unix.md + +Windows +-------- +https://github.com/SONO/SONO/blob/master/doc/build-msw.md + +Mac OS X +-------- +https://github.com/SONO/SONO/blob/master/doc/build-osx.md diff --git a/doc/release-process.txt b/doc/release-process.txt new file mode 100644 index 0000000..4b618dc --- /dev/null +++ b/doc/release-process.txt @@ -0,0 +1,142 @@ +* update translations (ping tcatm on IRC for now) + +* update (commit) version in sources + bitcoin-qt.pro + src/clientversion.h (change CLIENT_VERSION_IS_RELEASE to true) + share/setup.nsi + doc/README* + +* tag version in git + + git tag -a v0.5.1 + +* write release notes. git shortlog helps a lot: + + git shortlog --no-merges v0.5.0.. + +* perform gitian builds + + * From a directory containing the bitcoin source, gitian-builder and gitian.sigs + export SIGNER=(your gitian key, ie bluematt, sipa, etc) + export VERSION=0.5.1 + cd ./gitian-builder + + * Fetch and build inputs: + mkdir -p inputs; cd inputs/ + wget 'http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.6.tar.gz' -O miniupnpc-1.6.tar.gz + wget 'http://www.openssl.org/source/openssl-1.0.1b.tar.gz' + wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz' + wget 'http://zlib.net/zlib-1.2.6.tar.gz' + wget 'ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.9.tar.gz' + wget 'http://fukuchi.org/works/qrencode/qrencode-3.2.0.tar.bz2' + wget 'http://downloads.sourceforge.net/project/boost/boost/1.47.0/boost_1_47_0.tar.bz2' + wget 'http://download.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.4.tar.gz' + cd .. + ./bin/gbuild ../bitcoin/contrib/gitian-descriptors/boost-win32.yml + cp build/out/boost-win32-1.47.0-gitian.zip inputs/ + ./bin/gbuild ../bitcoin/contrib/gitian-descriptors/qt-win32.yml + cp build/out/qt-win32-4.7.4-gitian.zip inputs/ + ./bin/gbuild ../bitcoin/contrib/gitian-descriptors/deps-win32.yml + cp build/out/bitcoin-deps-0.0.3.zip inputs/ + + * Build bitcoind and bitcoin-qt on Linux32, Linux64, and Win32: + ./bin/gbuild --commit bitcoin=v${VERSION} ../bitcoin/contrib/gitian-descriptors/gitian.yml + ./bin/gsign --signer $SIGNER --release ${VERSION} --destination ../gitian.sigs/ ../bitcoin/contrib/gitian-descriptors/gitian.yml + pushd build/out + zip -r bitcoin-${VERSION}-linux-gitian.zip * + mv bitcoin-${VERSION}-linux-gitian.zip ../../ + popd + ./bin/gbuild --commit bitcoin=v${VERSION} ../bitcoin/contrib/gitian-descriptors/gitian-win32.yml + ./bin/gsign --signer $SIGNER --release ${VERSION}-win32 --destination ../gitian.sigs/ ../bitcoin/contrib/gitian-descriptors/gitian-win32.yml + pushd build/out + zip -r bitcoin-${VERSION}-win32-gitian.zip * + mv bitcoin-${VERSION}-win32-gitian.zip ../../ + popd + + Build output expected: + 1. linux 32-bit and 64-bit binaries + source (bitcoin-${VERSION}-linux-gitian.zip) + 2. windows 32-bit binary, installer + source (bitcoin-${VERSION}-win32-gitian.zip) + 3. Gitian signatures (in gitian.sigs/${VERSION}[-win32]/(your gitian key)/ + +* repackage gitian builds for release as stand-alone zip/tar/installer exe + + * Linux .tar.gz: + unzip bitcoin-${VERSION}-linux-gitian.zip -d bitcoin-${VERSION}-linux + tar czvf bitcoin-${VERSION}-linux.tar.gz bitcoin-${VERSION}-linux + rm -rf bitcoin-${VERSION}-linux + + * Windows .zip and setup.exe: + unzip bitcoin-${VERSION}-win32-gitian.zip -d bitcoin-${VERSION}-win32 + mv bitcoin-${VERSION}-win32/bitcoin-*-setup.exe . + zip -r bitcoin-${VERSION}-win32.zip bitcoin-${VERSION}-win32 + rm -rf bitcoin-${VERSION}-win32 + +* perform Mac build + See this blog post for how Gavin set up his build environment to build the OSX + release; note that a patched version of macdeployqt is not needed anymore, as + the required functionality and fixes are implemented directly in macdeployqtplus: + http://gavintech.blogspot.com/2011/11/deploying-bitcoin-qt-on-osx.html + Gavin also had trouble with the macports py27-appscript package; he + ended up installing a version that worked with: /usr/bin/easy_install-2.7 appscript + + qmake RELEASE=1 USE_UPNP=1 USE_QRCODE=1 bitcoin-qt.pro + make + export QTDIR=/opt/local/share/qt4 # needed to find translations/qt_*.qm files + T=$(contrib/qt_translations.py $QTDIR/translations src/qt/locale) + python2.7 contrib/macdeploy/macdeployqtplus Bitcoin-Qt.app -add-qt-tr $T -dmg -fancy contrib/macdeploy/fancy.plist + + Build output expected: + Bitcoin-Qt.dmg + +* upload builds to SourceForge + +* create SHA256SUMS for builds, and PGP-sign it + +* update bitcoin.org version + +* update forum version + +* update wiki download links + +* update wiki changelog: https://en.bitcoin.it/wiki/Changelog + +* Commit your signature to gitian.sigs: + pushd gitian.sigs + git add ${VERSION}/${SIGNER} + git add ${VERSION}-win32/${SIGNER} + git commit -a + git push # Assuming you can push to the gitian.sigs tree + popd + +------------------------------------------------------------------------- + +* After 3 or more people have gitian-built, repackage gitian-signed zips: + + * From a directory containing bitcoin source, gitian.sigs and gitian zips + export VERSION=0.5.1 + mkdir bitcoin-${VERSION}-linux-gitian + pushd bitcoin-${VERSION}-linux-gitian + unzip ../bitcoin-${VERSION}-linux-gitian.zip + mkdir gitian + cp ../bitcoin/contrib/gitian-downloader/*.pgp ./gitian/ + for signer in $(ls ../gitian.sigs/${VERSION}/); do + cp ../gitian.sigs/${VERSION}/${signer}/bitcoin-build.assert ./gitian/${signer}-build.assert + cp ../gitian.sigs/${VERSION}/${signer}/bitcoin-build.assert.sig ./gitian/${signer}-build.assert.sig + done + zip -r bitcoin-${VERSION}-linux-gitian.zip * + cp bitcoin-${VERSION}-linux-gitian.zip ../ + popd + mkdir bitcoin-${VERSION}-win32-gitian + pushd bitcoin-${VERSION}-win32-gitian + unzip ../bitcoin-${VERSION}-win32-gitian.zip + mkdir gitian + cp ../bitcoin/contrib/gitian-downloader/*.pgp ./gitian/ + for signer in $(ls ../gitian.sigs/${VERSION}-win32/); do + cp ../gitian.sigs/${VERSION}-win32/${signer}/bitcoin-build.assert ./gitian/${signer}-build.assert + cp ../gitian.sigs/${VERSION}-win32/${signer}/bitcoin-build.assert.sig ./gitian/${signer}-build.assert.sig + done + zip -r bitcoin-${VERSION}-win32-gitian.zip * + cp bitcoin-${VERSION}-win32-gitian.zip ../ + popd + + * Upload gitian zips to SourceForge diff --git a/doc/ssl.md b/doc/ssl.md new file mode 100644 index 0000000..6f06bea --- /dev/null +++ b/doc/ssl.md @@ -0,0 +1,25 @@ +Enabling SSL on original client daemon +====================================== +By default, SONO allows JSON-RPC commands to be sent to http://localhost:61511 +and accepts connections only from the localhost. + +JSON-RPC Over SSL Setup +----------------------- +It can be configured to allow HTTPS connections. You must follow the steps below +for this to work properly. + +1. Setup a certificate and private key. A self signed certificate will work. + * cd ~/.SONO + * openssl genrsa -out server.pem 4096 + * openssl req -new -x509 -nodes -sha1 -days 3650 -key server.pem > server.cert + (NOTE: you should NOT enter a passphrase) + +2. Configure NeosCoin to use SSL + * Stop your current SONOd or SONO-qt + * Edit the SONO.conf and add + rpcssl=1 + +3. Restart SONO to make these changes take effect. + +4. Optionally you can test SSL functionality using the openssl s_client command + * openssl s_client -connect localhost:15004 diff --git a/doc/tor.md b/doc/tor.md new file mode 100644 index 0000000..95d19b5 --- /dev/null +++ b/doc/tor.md @@ -0,0 +1,87 @@ +TOR Support in SONO +======================= + +It is possible to run SONO as a Tor hidden service, and connect to such services. + +The following directions assume you have a Tor proxy running on port 9050. Many distributions +default to having a SOCKS proxy listening on port 9050, but others may not. +In particular, the Tor Browser Bundle defaults to listening on a random port. See +https://www.torproject.org/docs/faq.html.en#TBBSocksPort for how to properly +configure Tor. + + +1. Run SONO behind a Tor proxy +--------------------------------- + +The first step is running SONO behind a Tor proxy. This will already make all +outgoing connections be anonimized, but more is possible. + +-proxy=ip:port Set the proxy server. If SOCKS5 is selected (default), this proxy + server will be used to try to reach .onion addresses as well. + +-tor=ip:port Set the proxy server to use for tor hidden services. You do not + need to set this if it's the same as -proxy. You can use -notor + to explicitly disable access to hidden service. + +-listen When using -proxy, listening is disabled by default. If you want + to run a hidden service (see next section), you'll need to enable + it explicitly. + +-connect=X When behind a Tor proxy, you can specify .onion addresses instead +-addnode=X of IP addresses or hostnames in these parameters. It requires +-seednode=X SOCKS5. In Tor mode, such addresses can also be exchanged with + other P2P nodes. + +In a typical situation, this suffices to run behind a Tor proxy: + + ./SONOd -proxy=127.0.0.1:9050 + + +2. Run a SONO hidden server +------------------------------ + +If you configure your Tor system accordingly, it is possible to make your node also +reachable from the Tor network. Add these lines to your /etc/tor/torrc (or equivalent +config file): + + HiddenServiceDir /var/lib/tor/SONO-service/ + HiddenServicePort 61510 127.0.0.1:61510 + +The directory can be different of course, but (both) port numbers should be equal to +your SONOd's P2P listen port (61510 by default). + +-externalip=X You can tell litecoin about its publicly reachable address using + this option, and this can be a .onion address. Given the above + configuration, you can find your onion address in + /var/lib/tor/SONO-service/hostname. Onion addresses are given + preference for your node to advertize itself with, for connections + coming from unroutable addresses (such as 127.0.0.1, where the + Tor proxy typically runs). + +-listen You'll need to enable listening for incoming connections, as this + is off by default behind a proxy. + +-discover When -externalip is specified, no attempt is made to discover local + IPv4 or IPv6 addresses. If you want to run a dual stack, reachable + from both Tor and IPv4 (or IPv6), you'll need to either pass your + other addresses using -externalip, or explicitly enable -discover. + Note that both addresses of a dual-stack system may be easily + linkable using traffic analysis. + +In a typical situation, where you're only reachable via Tor, this should suffice: + + ./SONOd -proxy=127.0.0.1:9050 -externalip=57qr3yd1nyntf5k.onion -listen + +(obviously, replace the Onion address with your own). If you don't care too much +about hiding your node, and want to be reachable on IPv4 as well, additionally +specify: + + ./SONOd ... -discover + +and open port 61510 on your firewall (or use -upnp). + +If you only want to use Tor to reach onion addresses, but not use it as a proxy +for normal IPv4/IPv6 communication, use: + + ./SONOd -tor=127.0.0.1:9050 -externalip=57qr3yd1nyntf5k.onion -discover + diff --git a/doc/translation_process.md b/doc/translation_process.md new file mode 100644 index 0000000..3ddfc0c --- /dev/null +++ b/doc/translation_process.md @@ -0,0 +1,80 @@ +Translations +============ + +The Qt GUI can be easily translated into other languages. Here's how we +handle those translations. + +Files and Folders +----------------- + +### bitcoin-qt.pro + +This file takes care of generating `.qm` files from `.ts` files. It is mostly +automated. + +### src/qt/bitcoin.qrc + +This file must be updated whenever a new translation is added. Please note that +files must end with `.qm`, not `.ts`. + + + locale/bitcoin_en.qm + ... + + +### src/qt/locale/ + +This directory contains all translations. Filenames must adhere to this format: + + bitcoin_xx_YY.ts or bitcoin_xx.ts + +#### Source file + +`src/qt/locale/bitcoin_en.ts` is treated in a special way. It is used as the +source for all other translations. Whenever a string in the code is changed +this file must be updated to reflect those changes. Usually, this can be +accomplished by running `lupdate` (included in the Qt SDK). + +An updated source file should be merged to github and transifex will pick it +up from there. Afterwards the new strings show up as "Remaining" in transifex +and can be translated. + +Syncing with transifex +---------------------- + +We are using http://transifex.net as a frontend for translating the client. + +https://www.transifex.net/projects/p/bitcoin/resource/tx/ + +The "transifex client" (see: http://help.transifex.net/features/client/) +will help with fetching new translations from transifex. Use the following +config to be able to connect with the client. + +### .tx/config + + [main] + host = https://www.transifex.net + + [bitcoin.tx] + file_filter = src/qt/locale/bitcoin_.ts + source_file = src/qt/locale/bitcoin_en.ts + source_lang = en + +### .tx/config (for Windows) + + [main] + host = https://www.transifex.net + + [bitcoin.tx] + file_filter = src\qt\locale\bitcoin_.ts + source_file = src\qt\locale\bitcoin_en.ts + source_lang = en + +It is also possible to directly download new translations one by one from transifex. + +### Fetching new translations + +1. `tx pull -a` +2. update `src/qt/bitcoin.qrc` manually or via + `ls src/qt/locale/*ts|xargs -n1 basename|sed 's/\(bitcoin_\(.*\)\).ts/locale/\1.qm<\/file>/'` +3. `git add` new translations from `src/qt/locale/` diff --git a/install-dependencies.sh b/install-dependencies.sh new file mode 100644 index 0000000..d6a6d49 --- /dev/null +++ b/install-dependencies.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +date + +################################################################# +# Update Ubuntu and install prerequisites for running Bhcoin # +################################################################# +sudo apt-get update +################################################################# +# Build Bhcoin from source # +################################################################# +NPROC=$(nproc) +echo "nproc: $NPROC" +################################################################# +# Install all necessary packages for building Bhcoin # +################################################################# +sudo apt-get install -y qt4-qmake libqt4-dev libminiupnpc-dev libdb++-dev libdb-dev libcrypto++-dev libqrencode-dev libboost-all-dev build-essential libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libssl-dev libdb++-dev libssl-dev ufw git software-properties-common +sudo add-apt-repository -y ppa:bitcoin/bitcoin +sudo apt-get update +sudo apt-get install -y libdb4.8-dev libdb4.8++-dev + + diff --git a/share/genbuild.sh b/share/genbuild.sh new file mode 100644 index 0000000..d959877 --- /dev/null +++ b/share/genbuild.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +if [ $# -gt 0 ]; then + FILE="$1" + shift + if [ -f "$FILE" ]; then + INFO="$(head -n 1 "$FILE")" + fi +else + echo "Usage: $0 " + exit 1 +fi + +if [ -e "$(which git)" ]; then + # clean 'dirty' status of touched files that haven't been modified + git diff >/dev/null 2>/dev/null + + # get a string like "v0.6.0-66-g59887e8-dirty" + DESC="$(git describe --dirty 2>/dev/null)" + + # get a string like "2012-04-10 16:27:19 +0200" + TIME="$(git log -n 1 --format="%ci")" +fi + +if [ -n "$DESC" ]; then + NEWINFO="#define BUILD_DESC \"$DESC\"" +else + NEWINFO="// No build information available" +fi + +# only update build.h if necessary +if [ "$INFO" != "$NEWINFO" ]; then + echo "$NEWINFO" >"$FILE" + echo "#define BUILD_DATE \"$TIME\"" >>"$FILE" +fi diff --git a/share/pixmaps/addressbook16.bmp b/share/pixmaps/addressbook16.bmp new file mode 100644 index 0000000..c557691 Binary files /dev/null and b/share/pixmaps/addressbook16.bmp differ diff --git a/share/pixmaps/addressbook16mask.bmp b/share/pixmaps/addressbook16mask.bmp new file mode 100644 index 0000000..d3a478d Binary files /dev/null and b/share/pixmaps/addressbook16mask.bmp differ diff --git a/share/pixmaps/addressbook20.bmp b/share/pixmaps/addressbook20.bmp new file mode 100644 index 0000000..2b33b22 Binary files /dev/null and b/share/pixmaps/addressbook20.bmp differ diff --git a/share/pixmaps/addressbook20mask.bmp b/share/pixmaps/addressbook20mask.bmp new file mode 100644 index 0000000..56ce612 Binary files /dev/null and b/share/pixmaps/addressbook20mask.bmp differ diff --git a/share/pixmaps/bitcoin-bc.ico b/share/pixmaps/bitcoin-bc.ico new file mode 100644 index 0000000..88cc240 Binary files /dev/null and b/share/pixmaps/bitcoin-bc.ico differ diff --git a/share/pixmaps/bitcoin.ico b/share/pixmaps/bitcoin.ico new file mode 100644 index 0000000..6192680 Binary files /dev/null and b/share/pixmaps/bitcoin.ico differ diff --git a/share/pixmaps/bitcoin32.xpm b/share/pixmaps/bitcoin32.xpm new file mode 100644 index 0000000..f538a44 --- /dev/null +++ b/share/pixmaps/bitcoin32.xpm @@ -0,0 +1,232 @@ +/* XPM */ +static const char * bitcoin32_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 194 2", +" c #745305", +". c #785704", +"X c #7C5903", +"o c #75560B", +"O c #77590F", +"+ c #7C5C0B", +"@ c #795B12", +"# c #7F631D", +"$ c #825E07", +"% c #825F0B", +"& c #85610A", +"* c #8C660C", +"= c #8E680E", +"- c #916B0F", +"; c #856515", +": c #8B6714", +"> c #8F6A16", +", c #816218", +"< c #88691C", +"1 c #926D12", +"2 c #936F1C", +"3 c #997417", +"4 c #94721E", +"5 c #9B761C", +"6 c #9F781C", +"7 c #A17B1E", +"8 c #826622", +"9 c #916E20", +"0 c #967425", +"q c #9D7420", +"w c #9C7923", +"e c #997728", +"r c #99792C", +"t c #A37D23", +"y c #A37F2C", +"u c #A68125", +"i c #AB8225", +"p c #A5832B", +"a c #AA852C", +"s c #B28A2C", +"d c #A58233", +"f c #AC8734", +"g c #AE8C33", +"h c #AC8C3C", +"j c #B28C33", +"k c #B98E34", +"l c #B28D3D", +"z c #B59136", +"x c #BC9335", +"c c #B3913E", +"v c #BC933A", +"b c #BF9A3D", +"n c #C19235", +"m c #C2953C", +"M c #C39B3C", +"N c #CA9C3D", +"B c #B59343", +"V c #BE9642", +"C c #B69A44", +"Z c #BD9A45", +"A c #B49649", +"S c #BB9A49", +"D c #BB9F52", +"F c #BFA256", +"G c #C49C43", +"H c #CA9D41", +"J c #C59D4A", +"K c #C99E4D", +"L c #C3A144", +"P c #CDA244", +"I c #CFAA47", +"U c #C3A14D", +"Y c #CDA24A", +"T c #CCAB49", +"R c #D2A644", +"E c #D2A54B", +"W c #D6AA4C", +"Q c #DAAE4E", +"! c #DAB04F", +"~ c #C7A656", +"^ c #CDA452", +"/ c #CFAC52", +"( c #C0A65E", +") c #CEA75A", +"_ c #CCAC59", +"` c #D2AB53", +"' c #DCAF52", +"] c #D6AD5A", +"[ c #D9AE5B", +"{ c #DCB556", +"} c #DFB855", +"| c #D6B25F", +" . c #DCB35C", +".. c #DEBE5E", +"X. c #E2B656", +"o. c #E1B55A", +"O. c #E6BC5D", +"+. c #E9BD5E", +"@. c #C3AA63", +"#. c #CCAD62", +"$. c #D4AF62", +"%. c #CDB565", +"&. c #CEB46D", +"*. c #D7B164", +"=. c #DBB362", +"-. c #D6BD64", +";. c #DDBA64", +":. c #D3B66C", +">. c #DFB86B", +",. c #CEB772", +"<. c #D0B771", +"1. c #D4BA73", +"2. c #D9BE77", +"3. c #D6BE79", +"4. c #D8BF7A", +"5. c #E4BB62", +"6. c #E9BF64", +"7. c #E4BC69", +"8. c #E9BF69", +"9. c #E0BB71", +"0. c #E9C05E", +"q. c #D2C279", +"w. c #DBC27C", +"e. c #E2C667", +"r. c #EDC364", +"t. c #E3C16E", +"y. c #ECC46C", +"u. c #EDCC6C", +"i. c #F1C764", +"p. c #F5CA66", +"a. c #F9CD67", +"s. c #F5CC6A", +"d. c #F9CD6B", +"f. c #FBD36F", +"g. c #EDC572", +"h. c #E5CF77", +"j. c #ECCA74", +"k. c #E0C67E", +"l. c #EFCE78", +"z. c #F6CE72", +"x. c #FBCF71", +"c. c #F4CE79", +"v. c #F4D273", +"b. c #FCD473", +"n. c #F4DC75", +"m. c #FEDA74", +"M. c #F6D77C", +"N. c #FBD47A", +"B. c #F1DA7B", +"V. c #FDDA7C", +"C. c #FEE27D", +"Z. c #DDC683", +"A. c #DFC884", +"S. c #E4CA84", +"D. c #E3CC89", +"F. c #E7D183", +"G. c #EFD280", +"H. c #EFDC82", +"J. c #ECD48D", +"K. c #EFDA8C", +"L. c #F9D783", +"P. c #F2DF83", +"I. c #FCDB83", +"U. c #F5DC8F", +"Y. c #FADD8B", +"T. c #EBD593", +"R. c #EFDA99", +"E. c #F3DD93", +"W. c #F3DF9F", +"Q. c #FFE385", +"!. c #FEE986", +"~. c #FDE48C", +"^. c #FEEC8E", +"/. c #ECE199", +"(. c #F6E591", +"). c #FEE494", +"_. c #FEEB93", +"`. c #FEE69A", +"'. c #FFEB9B", +"]. c #FFF197", +"[. c #FFF39B", +"{. c #FEF99B", +"}. c #F6E2A2", +"|. c #F9E5A5", +" X c #F7E9A5", +".X c #FEECA4", +"XX c #FBE7A8", +"oX c #FDEAAB", +"OX c #F7F2AA", +"+X c #FEF2AC", +"@X c #FDF4B4", +"#X c #FFFABA", +"$X c #FFFEC2", +"%X c None", +/* pixels */ +"%X%X%X%X%X%X%X%X%X%X%X%Xp t 6 5 w t w %X%X%X%X%X%X%X%X%X%X%X%X%X", +"%X%X%X%X%X%X%X%X%Xu u x I X.0.s.u.0.W x 7 4 %X%X%X%X%X%X%X%X%X%X", +"%X%X%X%X%X%X%Xy i I i.a.f.m.m.b.f.s.a.s.i.W 7 > %X%X%X%X%X%X%X%X", +"%X%X%X%X%X%Xt M 0.a.m.m.m.m.f.d.p.p.p.f.d.f.i.b 1 < %X%X%X%X%X%X", +"%X%X%X%X%X7 ! d.f.f.m.f.+.W P R I Q 5.v.V.V.z.f.{ 5 + %X%X%X%X%X", +"%X%X%X%Xu X.f.m.m.f.' H s ~ V y _ Z J o.g.L.L.Q.!.e.5 X %X%X%X%X", +"%X%X%Xu X.b.C.m.+.N m n t }.3.> }.w.V 5.y.y.Y.[.^.^.-.1 + %X%X%X", +"%X%Xt P m.N.m.X.v v v k 6 }.1.: /.4.c 7.N.N.v.!.{.{.^.L & %X%X%X", +"%X%Xg Y.Y.V.+.m k a t t : }.1.% }.1.r | l.B.M.b.!.{.^.n.7 X %X%X", +"%Xp -._.'.Y.' Y n D.}.}.|.oXXX|.oX XT.w.F _ j.v.v._.^.C.T & @ %X", +"%Xa (.'.'.9.[ [ K S.}.oXoXoXoXXXoXoXoXoX XD / s.d.v.!.C.v.3 o %X", +"%XU '.'.Y.[ [ [ [ J f <.oXoX( 2 f S J.oXoXT.j r.s.i.C.C.C.z X %X", +"p e.'.'.F. .=.=.=.=.) 1.oXoX@.f . .F oXoX}.a +.i.i.b.C.m.I X O ", +"u w.'.[.j.5.8.7.7.7.] 2.oXoX@.y W c &.oXoXZ.k r.s.i.s.V.m.} = o ", +"u H.[.{.y.8.y.g.8.g.7.2.oXoXA.@.&.D.oXoXT.e G +.O.O.5.V.m.0.- o ", +"u !.].[.r.8.y.g.g.g.7.4.oXoXoXoXoXoXoXoXoX<.y W X.o.o.m.m.0.- o ", +"u B._._.5.5.8.y.g.c.g.w.oXoX,.h A F <..XoXoX1.k ' ' ' V.N.r.- ", +"u u.Q.~.r.6.z.N.V.I.v.k.oXoX@.B | _ c 1.oXoX}.a ' ' O.I.b.O.= o ", +"u ..Q.Q.v.i.s.c.N.L.l.Z.oXoX@.B t.=.S &.oXoXXXy Y R +.N.b.Q % o ", +"t T C.I.I.6.u.z.z.5.S 1.oXoX@.e B h D |.oXoXS.f Y Y 6.d.d.n X O ", +"%Xs m.V.Q.r.r.z.5.<.}.oXoXoXXXW.}.oXoXoXoXW.h G H R a.p.s.7 %X", +"%X7 O.V.V.v.+.r.` 4.oXoXoXoXoXoXoXoXXXR.<.h v N N o.a.p.Q = %X", +"%Xw x v.v.v.r.+. .Z l d e }.Z.r }.3.d l V G n n R a.s.a.s X O %X", +"%X%X6 { v.l.v.+.O.5.=.^ d }.4.9 }.1.f J G m m G d.d.x.Q = %X%X", +"%X%X%Xs u.v.v.v.r.6.o. .l }.4.9 W.4.l ^ ^ J ) c.N.N.y.7 X O %X%X", +"%X%X%X5 z v.v.M.I.g.;. .J 1.#.B 1.#.) 7.$.S..X'.W.Y.j $ %X%X%X", +"%X%X%X%X5 b N.Y.~.).Y.j.5.$.=.=.$.*.2.J.@X$X#X#XoXC $ %X%X%X%X", +"%X%X%X%X%X3 z U.@X+X`.`.`.(.E.E.E.|.@X@X#X#X#X/.j % %X%X%X%X%X", +"%X%X%X%X%X%Xw a q.OX|.).`._.'.'.XX.X.X+X+X X%.w X o %X%X%X%X%X%X", +"%X%X%X%X%X%X%X%Xw a _ j.~.~.).).`.`.`.F._ t & . # %X%X%X%X%X%X%X", +"%X%X%X%X%X%X%X%X%X%X4 3 t z L U Z z t 1 $ . 8 %X%X%X%X%X%X%X%X%X", +"%X%X%X%X%X%X%X%X%X%X%X%X%X< ; & + + , 8 %X%X%X%X%X%X%X%X%X%X%X%X" +}; diff --git a/share/pixmaps/bitcoin80.xpm b/share/pixmaps/bitcoin80.xpm new file mode 100644 index 0000000..c3c816e --- /dev/null +++ b/share/pixmaps/bitcoin80.xpm @@ -0,0 +1,292 @@ +/* XPM */ +static const char * bitcoin80_xpm[] = { +/* columns rows colors chars-per-pixel */ +"80 80 206 2", +" c #725203", +". c #785706", +"X c #7B5907", +"o c #7C5A09", +"O c #7F5F10", +"+ c #815E0B", +"@ c #85620C", +"# c #89650F", +"$ c #856313", +"% c #896614", +"& c #8D6913", +"* c #886718", +"= c #8D6B1B", +"- c #926D14", +"; c #926E1B", +": c #967116", +"> c #997317", +", c #95711E", +"< c #9B7419", +"1 c #9F781B", +"2 c #A27B1D", +"3 c #8F6F22", +"4 c #926F21", +"5 c #947323", +"6 c #9A7623", +"7 c #9D7925", +"8 c #957628", +"9 c #9A7729", +"0 c #9D7B2B", +"q c #9D7F33", +"w c #A47D23", +"e c #A97F27", +"r c #A37E2B", +"t c #9F8030", +"y c #A78021", +"u c #AC8425", +"i c #A5802D", +"p c #AC842B", +"a c #AF8829", +"s c #B2872C", +"d c #B28B2D", +"f c #A68333", +"g c #AA8633", +"h c #AD8A36", +"j c #A4863A", +"k c #A88638", +"l c #A7893B", +"z c #AC8B3B", +"x c #B28732", +"c c #B48C32", +"v c #B98E34", +"b c #B28D3B", +"n c #B88F3C", +"m c #B69033", +"M c #BD9235", +"N c #B4913D", +"B c #BC943A", +"V c #BE993C", +"C c #C19336", +"Z c #C1953B", +"A c #C49A3C", +"S c #C99C3D", +"D c #CDA13F", +"F c #D0A33F", +"G c #A88B40", +"H c #B08F40", +"J c #AE9142", +"K c #AE944C", +"L c #B49443", +"P c #BB9542", +"I c #B49946", +"U c #BD9846", +"Y c #B3964C", +"T c #BB974A", +"R c #B6994A", +"E c #BF9C4A", +"W c #B69B53", +"Q c #B99D53", +"! c #BCA055", +"~ c #BDA25A", +"^ c #C49742", +"/ c #C49C43", +"( c #CB9E42", +") c #C49D4B", +"_ c #C99E4C", +"` c #C29F52", +"' c #C5A244", +"] c #CDA245", +"[ c #C5A34C", +"{ c #CCA34B", +"} c #CCA94D", +"| c #D2A445", +" . c #D1A54B", +".. c #D5AA4E", +"X. c #DBAF4F", +"o. c #C6A352", +"O. c #CBA554", +"+. c #C5AA57", +"@. c #CEAC54", +"#. c #C4A65A", +"$. c #CDA458", +"%. c #C2A85F", +"&. c #CEAA5B", +"*. c #D0A550", +"=. c #D4AB53", +"-. c #DBAE53", +";. c #D0A75B", +":. c #D4AC5A", +">. c #D9AE5C", +",. c #CEB25E", +"<. c #D4B156", +"1. c #DDB156", +"2. c #D4B25C", +"3. c #DCB35D", +"4. c #D7B85C", +"5. c #DCBA5E", +"6. c #E2B355", +"7. c #E2B65B", +"8. c #E4BA5D", +"9. c #EABD5E", +"0. c #C5AA62", +"q. c #CCAE63", +"w. c #C6AE69", +"e. c #D5AF62", +"r. c #CEB167", +"t. c #CCB36C", +"y. c #D5B162", +"u. c #DCB462", +"i. c #D7B964", +"p. c #DCBC64", +"a. c #D2B66B", +"s. c #DCB669", +"d. c #D7BE69", +"f. c #DFB86A", +"g. c #D0B771", +"h. c #D2BA74", +"j. c #D5BE78", +"k. c #E1B766", +"l. c #E4BB63", +"z. c #E9BE63", +"x. c #E3BB6A", +"c. c #E9BF6A", +"v. c #E1BE72", +"b. c #DDC16B", +"n. c #DAC27E", +"m. c #E4C164", +"M. c #ECC264", +"N. c #E4C36B", +"B. c #EBC36C", +"V. c #E7C96F", +"C. c #EECA6E", +"Z. c #F1C564", +"A. c #F1C76A", +"S. c #F5CB6C", +"D. c #FACE6D", +"F. c #F4D06F", +"G. c #FCD06E", +"H. c #E5C371", +"J. c #EDC573", +"K. c #E4CA73", +"L. c #ECCC74", +"P. c #E7CF7A", +"I. c #EBCD7A", +"U. c #F3CD73", +"Y. c #F8CE71", +"T. c #F3CD7A", +"R. c #EDD076", +"E. c #EDD17B", +"W. c #F4D274", +"Q. c #FBD274", +"!. c #FED977", +"~. c #F3D47B", +"^. c #FDD47A", +"/. c #F5DA7C", +"(. c #FDDA7C", +"). c #FFE07F", +"_. c #DBC481", +"`. c #DFC885", +"'. c #E1CA86", +"]. c #EACC80", +"[. c #E4CD8A", +"{. c #EED383", +"}. c #E7D18F", +"|. c #EAD38C", +" X c #F4D680", +".X c #FDD780", +"XX c #F5DA83", +"oX c #FCDC84", +"OX c #F5DB8A", +"+X c #FADE89", +"@X c #EAD492", +"#X c #EED896", +"$X c #EFDA9A", +"%X c #F1DD9D", +"&X c #FDE283", +"*X c #F6E18D", +"=X c #FEE48D", +"-X c #FFE692", +";X c #FFE894", +":X c #FBE799", +">X c #FFEA98", +",X c #F6E2A3", +".J..X.X.X.X(.W.Z.C.&X;X;X;X;X-X-X-X<.u u < 3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3Xu u c oX=X=X=X=X=X=X=Xl.Z C M M C C v v v s w = '.2X2X2X5 $ = 2X2X2X}.5 g ) u./.+X+X=X=X=X&XW.Z.F.=X;X;X;X;X-X-X*XV u y @ X 3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3Xu u u N.-X-X-X-X=X=X=XB.Z M C v v s e e e e w > % `.2X2X2X= + % 2X2X2X}.= r L 4.E.OX+X-X=X=X&X).W.M.R.;X;X;X-X-X-X;XR.u u y 3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3Xu u U -X-X-X-X-X-X=XW.^ C C C x e e r 6 5 4 ; = $ `.2X2X2X= O = 2X2X2X}.O = t Q ,.b.P./.*X=X&X&X).F.M.W.;X;X;X;X&X-X&X} u u O 3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3Xu u u R.-X-X-X-X-X-X=X=.{ ^ Z C x n 2X2X.>.>.=.=._ n b 2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X:XI N +.V./.).).F.F.9.W.;X=X;X-X-X-XR.u u > 3X3X3X3X3X3X3X3X", +"3X3X3X3X3Xu u d =X;X-X-X-X-X-Xx.>.>.>.>.>...^ P 2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X2X,Xl N 4.R.!.!.!.G.Z.M.&X;X=X=X-X-X-XB a u 3X3X3X3X3X3X3X", +"3X3X3X3X3Xu u @.;X;X-X;X;X;XXX>.:.>.>.>.>.>._ P ` Y Y W _.2X2X2X2X2X2X@XW W ~ 0.t.'..>.>.>.>.>.>.=._ P z r 4 8 2X2X2X2X2X2X_.. $ , 6 1 3 t ~ 1X2X2X2X2X2X2X2Xt B 5.G.!.!.G.G.M.9.&X;X=X-X-X=X/.u u > 3X3X3X3X3X3X3X", +"3X3X3X3Xu u d =X;X;X=X;X;X=X3.>.>.>.e.>.3.3.>.:.*._ P r 9 2X2X2X2X2X1Xn.@ , c B N m h 8 ~ 2X2X2X2X2X2X2XI h <.F.!.G.G.F.M.9.W.;X=X-X-X=X=Xm u y . 3X3X3X3X3X3X", +"3X3X3X3Xu u ' -X-X>X-X-X-X X>.>.>.>.>.>.>.u.u.u.u.3.$.P f 2X2X2X2X2X2X_.$ i / -.<.8.} h 8 1X2X2X2X2X2X2X! i <.S.G.G.G.G.Z.9.Z.=X-X=X-X&X-X} u u X 3X3X3X3X3X3X", +"3X3X3X3Xu u 4.-X-X-X-X-X-XJ.3.>.>.k.k.k.k.k.u.k.u.u.:.U k 2X2X2X2X2X1X_.% f } 8.Z.F.8.U 8 ,X2X2X2X2X2X2XI g } Z.D.G.D.G.D.Z.9.&X-X=X=X=X-Xm.u u @ 3X3X3X3X3X3X", +"3X3X3X3Xu u K.;X-X;X-X>X-Xk.3.k.k.k.k.k.k.k.k.k.k.u.e.U k 2X2X2X2X2X2X_.% f [ 8.F.M.<.b i 2X2X2X2X2X2X2Xt a X.Z.D.D.D.G.G.Z.9./.=X-X=X=X=XR.u u & 3X3X3X3X3X3X", +"3X3X3X3Xu u E.;X-X;X-X-X=Xl.l.x.c.k.x.k.k.x.x.v.x.x.u.) z 2X2X2X2X2X2X_.$ 7 L <.<.} N 6 h.2X2X2X2X2X2X_.: V 1.S.D.D.G.D.S.M.6.W.-X=X-X=X=X&Xu u > X 3X3X3X3X3X", +"3X3X3Xu a u =X;X;X;X;X;XoX7.z.c.c.c.c.c.c.c.c.c.x.k.u.) z 2X2X2X2X2X2Xn.o = i N h i l n.2X2X2X2X2X2X.o.L r [.2X2X2X9 = 8 2X2X2X}.4 r ^ _ *.*._ ) ) ^ ^ ^ O.oX=X-X-X-X-X-X-X<.u u : . 3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3Xy u u i.=X=X=X=X=X-X*X=XW.9.M.A.B.3.5.5.;.U f [.2X2X2Xq 4 8 2X2X2X}.r q _ _ ;.;.*._ _ ` _ e.+X-X-X-X-X-X-X-XR.a u 2 3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3Xu u u K.=X=X=X-X=X=X=X=XXXz.M.8.5.8.u.:.) h }.2X2X2Xj r f 2X2X2X@Xq T _ e.e.u.e.;.$.$.b.-X-X-X=X;X=X;X-X&Xa a u + 3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3Xu u d ~.=X=X=X=X=X-X=X-X+XC.3.5.7.7.2.@.) q.r.q.q.H H L g.r.w.q.T ` e.k.v.k.k.s.s.{.-X-X;X-X;X;X;X;X*XV u u & . 3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X2 u u c XX-X=X=X=X=X-X=X-X-X Xl.7.7.u.2.$.o.[ [ o.O.$.&.&.` ` ` q.s.k.v.k.k.x.{.%X>X>X>X;X>X;X>X>X*XV u u > 3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X2 u u m ~.=X-X-X-X=X-X-X-X-X-X Xc.7.5.u.3.e.y.u.s.f.k.s.e.e.s.s.k.k.k.v. X:X>X>X>X>X>X>X;X>X>X*XV u u < 3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X2 u u d R.-X=X-X=X-X-X-X-X-X-X-X+XI.v.u.s.l.k.k.x.x.x.s.s.s.s.j.].+X>X>X>X>X>X:X>X>X>X>X>XOXV u u 1 3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X2 u u a p.-X-X-X;X;X;X-X-X-X:X-X-X-X-XOX XL.J.J.J.L.I.].OX:X>X-X>X>X-X>X>X>X>X>X>X>X>XK.a a u < 3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X2 u u u @.=X;X;X>X;X-X-X>X-X-X-X-X;X-X-X-X-X-X>X>X-X>X-X>X>X>X>X;X>X>X>X-X>X-X-X:X<.u u u > 3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X1 u u u m n.>X;X>X>X-X-X-X-X>X-X-X-X;X;X;X-X-X-X-X-X>X-X-X>X-X>X>X-X>X>X>X>XK.B u u u & 3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3Xw u u u / {.>X>X-X-X-X-X-X-X-X-X-X-X;X-X-X;X:X-X-X>X-X:X>X;X;X>X;X;X{.[ u u u w + 3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X2 u u u u ) K.-X-X-X-X:X-X-X-X-X-X-X-X-X-X-X-X-X>X-X-X-X-X-X-XE.[ u u u u - . 3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X1 u u u u m 2.E.-X+X:X-X-X-X-X-X-X-X-X-X:X-X-X-X;X-XOXi.B u u u u 1 o 3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X> u u u u u v [ l.I.OX-X-X-X-X-X-X-X-X+XI.f.@.m u u u u u 1 + o 3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X& 2 u u u u u u u d B V V V V B d u u u u u u u y - . o 3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X+ - 1 u u u u u u u a u u u u u u u u 2 - o o 3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3Xo . X # - > 1 2 2 2 1 2 > - # o . o 3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3Xo o . o 3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X", +"3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X3X" +}; diff --git a/share/pixmaps/check.ico b/share/pixmaps/check.ico new file mode 100644 index 0000000..0c4e6e8 Binary files /dev/null and b/share/pixmaps/check.ico differ diff --git a/share/pixmaps/favicon.ico b/share/pixmaps/favicon.ico new file mode 100644 index 0000000..d249e41 Binary files /dev/null and b/share/pixmaps/favicon.ico differ diff --git a/share/pixmaps/nsis-header.bmp b/share/pixmaps/nsis-header.bmp new file mode 100644 index 0000000..5eb10ae Binary files /dev/null and b/share/pixmaps/nsis-header.bmp differ diff --git a/share/pixmaps/nsis-wizard.bmp b/share/pixmaps/nsis-wizard.bmp new file mode 100644 index 0000000..330de6b Binary files /dev/null and b/share/pixmaps/nsis-wizard.bmp differ diff --git a/share/pixmaps/send16.bmp b/share/pixmaps/send16.bmp new file mode 100644 index 0000000..676b5c4 Binary files /dev/null and b/share/pixmaps/send16.bmp differ diff --git a/share/pixmaps/send16mask.bmp b/share/pixmaps/send16mask.bmp new file mode 100644 index 0000000..06c747f Binary files /dev/null and b/share/pixmaps/send16mask.bmp differ diff --git a/share/pixmaps/send16masknoshadow.bmp b/share/pixmaps/send16masknoshadow.bmp new file mode 100644 index 0000000..faf24e0 Binary files /dev/null and b/share/pixmaps/send16masknoshadow.bmp differ diff --git a/share/pixmaps/send20.bmp b/share/pixmaps/send20.bmp new file mode 100644 index 0000000..2b90422 Binary files /dev/null and b/share/pixmaps/send20.bmp differ diff --git a/share/pixmaps/send20mask.bmp b/share/pixmaps/send20mask.bmp new file mode 100644 index 0000000..f124d0d Binary files /dev/null and b/share/pixmaps/send20mask.bmp differ diff --git a/share/qt/Info.plist b/share/qt/Info.plist new file mode 100644 index 0000000..02b3bf1 --- /dev/null +++ b/share/qt/Info.plist @@ -0,0 +1,33 @@ + + + + + CFBundleIconFile + bitcoin.icns + CFBundlePackageType + APPL + CFBundleGetInfoString + ArpaCoin-Qt + CFBundleSignature + ???? + CFBundleExecutable + ArpaCoin-Qt + CFBundleIdentifier + co.ArpaCoin.ArpaCoin-Qt + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + co.ArpaCoin.ArpaCoinPayment + CFBundleURLSchemes + + ArpaCoin + + + + LSAppNapIsDisabled + True + + diff --git a/share/qt/extract_strings_qt.py b/share/qt/extract_strings_qt.py new file mode 100644 index 0000000..771f28a --- /dev/null +++ b/share/qt/extract_strings_qt.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +''' +Extract _("...") strings for translation and convert to Qt4 stringdefs so that +they can be picked up by Qt linguist. +''' +from subprocess import Popen, PIPE +import glob + +OUT_CPP="src/qt/bitcoinstrings.cpp" +EMPTY=['""'] + +def parse_po(text): + """ + Parse 'po' format produced by xgettext. + Return a list of (msgid,msgstr) tuples. + """ + messages = [] + msgid = [] + msgstr = [] + in_msgid = False + in_msgstr = False + + for line in text.split('\n'): + line = line.rstrip('\r') + if line.startswith('msgid '): + if in_msgstr: + messages.append((msgid, msgstr)) + in_msgstr = False + # message start + in_msgid = True + + msgid = [line[6:]] + elif line.startswith('msgstr '): + in_msgid = False + in_msgstr = True + msgstr = [line[7:]] + elif line.startswith('"'): + if in_msgid: + msgid.append(line) + if in_msgstr: + msgstr.append(line) + + if in_msgstr: + messages.append((msgid, msgstr)) + + return messages + +files = glob.glob('src/*.cpp') + glob.glob('src/*.h') + +# xgettext -n --keyword=_ $FILES +child = Popen(['xgettext','--output=-','-n','--keyword=_'] + files, stdout=PIPE) +(out, err) = child.communicate() + +messages = parse_po(out) + +f = open(OUT_CPP, 'w') +f.write("""#include +// Automatically generated by extract_strings.py +#ifdef __GNUC__ +#define UNUSED __attribute__((unused)) +#else +#define UNUSED +#endif +""") +f.write('static const char UNUSED *bitcoin_strings[] = {') +for (msgid, msgstr) in messages: + if msgid != EMPTY: + f.write('QT_TRANSLATE_NOOP("bitcoin-core", %s),\n' % ('\n'.join(msgid))) +f.write('};') +f.close() diff --git a/share/qt/img/reload.xcf b/share/qt/img/reload.xcf new file mode 100644 index 0000000..dc8be62 Binary files /dev/null and b/share/qt/img/reload.xcf differ diff --git a/share/qt/make_spinner.py b/share/qt/make_spinner.py new file mode 100644 index 0000000..136aff3 --- /dev/null +++ b/share/qt/make_spinner.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# W.J. van der Laan, 2011 +# Make spinning .mng animation from a .png +# Requires imagemagick 6.7+ +from __future__ import division +from os import path +from PIL import Image +from subprocess import Popen + +SRC='img/reload_scaled.png' +DST='../../src/qt/res/movies/update_spinner.mng' +TMPDIR='/tmp' +TMPNAME='tmp-%03i.png' +NUMFRAMES=35 +FRAMERATE=10.0 +CONVERT='convert' +CLOCKWISE=True +DSIZE=(16,16) + +im_src = Image.open(SRC) + +if CLOCKWISE: + im_src = im_src.transpose(Image.FLIP_LEFT_RIGHT) + +def frame_to_filename(frame): + return path.join(TMPDIR, TMPNAME % frame) + +frame_files = [] +for frame in xrange(NUMFRAMES): + rotation = (frame + 0.5) / NUMFRAMES * 360.0 + if CLOCKWISE: + rotation = -rotation + im_new = im_src.rotate(rotation, Image.BICUBIC) + im_new.thumbnail(DSIZE, Image.ANTIALIAS) + outfile = frame_to_filename(frame) + im_new.save(outfile, 'png') + frame_files.append(outfile) + +p = Popen([CONVERT, "-delay", str(FRAMERATE), "-dispose", "2"] + frame_files + [DST]) +p.communicate() + + + diff --git a/share/qt/make_windows_icon.sh b/share/qt/make_windows_icon.sh new file mode 100644 index 0000000..f775a30 --- /dev/null +++ b/share/qt/make_windows_icon.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# create multiresolution windows icon +ICON_DST=../../src/qt/res/icons/novacoin.ico + +convert ../../src/qt/res/icons/novacoin-16.png ../../src/qt/res/icons/novacoin-32.png ../../src/qt/res/icons/novacoin-48.png ${ICON_DST} diff --git a/share/seeds/generate-seeds.py b/share/seeds/generate-seeds.py new file mode 100644 index 0000000..58eba0c --- /dev/null +++ b/share/seeds/generate-seeds.py @@ -0,0 +1,131 @@ +#!/usr/bin/python +# Copyright (c) 2014 Wladmir J. van der Laan +# Distributed under the MIT/X11 software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +''' +Script to generate list of seed nodes for chainparams.cpp. + +This script expects two text files in the directory that is passed as an +argument: + + nodes_main.txt + nodes_test.txt + +These files must consist of lines in the format + + + : + [] + []: + .onion + 0xDDBBCCAA (IPv4 little-endian old pnSeeds format) + +The output will be two data structures with the peers in binary format: + + static SeedSpec6 pnSeed6_main[]={ + ... + } + static SeedSpec6 pnSeed6_test[]={ + ... + } + +These should be pasted into `src/chainparamsseeds.h`. +''' +from __future__ import print_function, division +from base64 import b32decode +from binascii import a2b_hex +import sys, os +import re + +# ipv4 in ipv6 prefix +pchIPv4 = bytearray([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff]) +# tor-specific ipv6 prefix +pchOnionCat = bytearray([0xFD,0x87,0xD8,0x7E,0xEB,0x43]) + +def name_to_ipv6(addr): + if len(addr)>6 and addr.endswith('.onion'): + vchAddr = b32decode(addr[0:-6], True) + if len(vchAddr) != 16-len(pchOnionCat): + raise ValueError('Invalid onion %s' % s) + return pchOnionCat + vchAddr + elif '.' in addr: # IPv4 + return pchIPv4 + bytearray((int(x) for x in addr.split('.'))) + elif ':' in addr: # IPv6 + sub = [[], []] # prefix, suffix + x = 0 + addr = addr.split(':') + for i,comp in enumerate(addr): + if comp == '': + if i == 0 or i == (len(addr)-1): # skip empty component at beginning or end + continue + x += 1 # :: skips to suffix + assert(x < 2) + else: # two bytes per component + val = int(comp, 16) + sub[x].append(val >> 8) + sub[x].append(val & 0xff) + nullbytes = 16 - len(sub[0]) - len(sub[1]) + assert((x == 0 and nullbytes == 0) or (x == 1 and nullbytes > 0)) + return bytearray(sub[0] + ([0] * nullbytes) + sub[1]) + elif addr.startswith('0x'): # IPv4-in-little-endian + return pchIPv4 + bytearray(reversed(a2b_hex(addr[2:]))) + else: + raise ValueError('Could not parse address %s' % addr) + +def parse_spec(s, defaultport): + match = re.match('\[([0-9a-fA-F:]+)\](?::([0-9]+))?$', s) + if match: # ipv6 + host = match.group(1) + port = match.group(2) + else: + (host,_,port) = s.partition(':') + + if not port: + port = defaultport + else: + port = int(port) + + host = name_to_ipv6(host) + + return (host,port) + +def process_nodes(g, f, structname, defaultport): + g.write('static SeedSpec6 %s[] = {\n' % structname) + first = True + for line in f: + comment = line.find('#') + if comment != -1: + line = line[0:comment] + line = line.strip() + if not line: + continue + if not first: + g.write(',\n') + first = False + + (host,port) = parse_spec(line, defaultport) + hoststr = ','.join(('0x%02x' % b) for b in host) + g.write(' {{%s}, %i}' % (hoststr, port)) + g.write('\n};\n') + +def main(): + if len(sys.argv)<2: + print(('Usage: %s ' % sys.argv[0]), file=sys.stderr) + exit(1) + g = sys.stdout + indir = sys.argv[1] + g.write('#ifndef H_CHAINPARAMSSEEDS\n') + g.write('#define H_CHAINPARAMSSEEDS\n') + g.write('// List of fixed seed nodes for the bitcoin network\n') + g.write('// AUTOGENERATED by contrib/devtools/generate-seeds.py\n\n') + g.write('// Each line contains a 16-byte IPv6 address and a port.\n') + g.write('// IPv4 as well as onion addresses are wrapped inside a IPv6 address accordingly.\n') + with open(os.path.join(indir,'nodes_main.txt'),'r') as f: + process_nodes(g, f, 'pnSeed6_main', 15714) + g.write('\n') + with open(os.path.join(indir,'nodes_test.txt'),'r') as f: + process_nodes(g, f, 'pnSeed6_test', 25714) + g.write('#endif\n') + +if __name__ == '__main__': + main() diff --git a/share/seeds/nodes_main.txt b/share/seeds/nodes_main.txt new file mode 100644 index 0000000..c666543 --- /dev/null +++ b/share/seeds/nodes_main.txt @@ -0,0 +1,12 @@ +# List of fixed seed nodes for main network + +# IPv4 nodes +109.230.231.216 +159.65.28.130 +159.65.28.135 + +# IPv6 nodes + + +# Onion nodes + diff --git a/share/seeds/nodes_test.txt b/share/seeds/nodes_test.txt new file mode 100644 index 0000000..77e5126 --- /dev/null +++ b/share/seeds/nodes_test.txt @@ -0,0 +1 @@ +# List of fixed seed nodes for testnet diff --git a/share/setup.nsi b/share/setup.nsi new file mode 100644 index 0000000..3454e24 --- /dev/null +++ b/share/setup.nsi @@ -0,0 +1,163 @@ +Name NovaCoin + +RequestExecutionLevel highest +SetCompressor /SOLID lzma + +# General Symbol Definitions +!define REGKEY "SOFTWARE\$(^Name)" +!define VERSION 0.3.0 +!define COMPANY "NovaCoin project" +!define URL http://www.novacoin.ru/ + +# MUI Symbol Definitions +!define MUI_ICON "../share/pixmaps/novacoin.ico" +!define MUI_WELCOMEFINISHPAGE_BITMAP "../share/pixmaps/nsis-wizard.bmp" +!define MUI_HEADERIMAGE +!define MUI_HEADERIMAGE_RIGHT +!define MUI_HEADERIMAGE_BITMAP "../share/pixmaps/nsis-header.bmp" +!define MUI_FINISHPAGE_NOAUTOCLOSE +!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM +!define MUI_STARTMENUPAGE_REGISTRY_KEY ${REGKEY} +!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup +!define MUI_STARTMENUPAGE_DEFAULTFOLDER NovaCoin +#!define MUI_FINISHPAGE_RUN $INSTDIR\novacoin-qt.exe +!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" +!define MUI_UNWELCOMEFINISHPAGE_BITMAP "../share/pixmaps/nsis-wizard.bmp" +!define MUI_UNFINISHPAGE_NOAUTOCLOSE + +# Included files +!include Sections.nsh +!include MUI2.nsh + +# Variables +Var StartMenuGroup + +# Installer pages +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +# Installer languages +!insertmacro MUI_LANGUAGE English + +# Installer attributes +OutFile novacoin-0.3.0-win32-setup.exe +InstallDir $PROGRAMFILES\NovaCoin +CRCCheck on +XPStyle on +BrandingText " " +ShowInstDetails show +VIProductVersion 0.3.0.0 +VIAddVersionKey ProductName NovaCoin +VIAddVersionKey ProductVersion "${VERSION}" +VIAddVersionKey CompanyName "${COMPANY}" +VIAddVersionKey CompanyWebsite "${URL}" +VIAddVersionKey FileVersion "${VERSION}" +VIAddVersionKey FileDescription "" +VIAddVersionKey LegalCopyright "" +InstallDirRegKey HKCU "${REGKEY}" Path +ShowUninstDetails show + +# Installer sections +Section -Main SEC0000 + SetOutPath $INSTDIR + SetOverwrite on + #File ../release/novacoin-qt.exe + File /oname=license.txt ../COPYING + File /oname=readme.txt ../doc/README_windows.txt + SetOutPath $INSTDIR\daemon + File ../src/novacoind.exe + SetOutPath $INSTDIR\src + File /r /x *.exe /x *.o ../src\*.* + SetOutPath $INSTDIR + WriteRegStr HKCU "${REGKEY}\Components" Main 1 + + # Remove old wxwidgets-based-bitcoin executable and locales: + #Delete /REBOOTOK $INSTDIR\novacoin.exe + #RMDir /r /REBOOTOK $INSTDIR\locale +SectionEnd + +Section -post SEC0001 + WriteRegStr HKCU "${REGKEY}" Path $INSTDIR + SetOutPath $INSTDIR + WriteUninstaller $INSTDIR\uninstall.exe + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application + CreateDirectory $SMPROGRAMS\$StartMenuGroup + CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall NovaCoin.lnk" $INSTDIR\uninstall.exe + !insertmacro MUI_STARTMENU_WRITE_END + WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)" + WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}" + WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}" + WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}" + WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe + WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe + WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1 + WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1 + + # bitcoin: URI handling disabled for 0.6.0 + # WriteRegStr HKCR "bitcoin" "URL Protocol" "" + # WriteRegStr HKCR "bitcoin" "" "URL:Bitcoin" + # WriteRegStr HKCR "bitcoin\DefaultIcon" "" $INSTDIR\bitcoin-qt.exe + # WriteRegStr HKCR "bitcoin\shell\open\command" "" '"$INSTDIR\bitcoin-qt.exe" "$$1"' +SectionEnd + +# Macro for selecting uninstaller sections +!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID + Push $R0 + ReadRegStr $R0 HKCU "${REGKEY}\Components" "${SECTION_NAME}" + StrCmp $R0 1 0 next${UNSECTION_ID} + !insertmacro SelectSection "${UNSECTION_ID}" + GoTo done${UNSECTION_ID} +next${UNSECTION_ID}: + !insertmacro UnselectSection "${UNSECTION_ID}" +done${UNSECTION_ID}: + Pop $R0 +!macroend + +# Uninstaller sections +Section /o -un.Main UNSEC0000 + #Delete /REBOOTOK $INSTDIR\novacoin-qt.exe + Delete /REBOOTOK $INSTDIR\license.txt + Delete /REBOOTOK $INSTDIR\readme.txt + RMDir /r /REBOOTOK $INSTDIR\daemon + RMDir /r /REBOOTOK $INSTDIR\src + DeleteRegValue HKCU "${REGKEY}\Components" Main +SectionEnd + +Section -un.post UNSEC0001 + DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" + Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall NovaCoin.lnk" + #Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk" + #Delete /REBOOTOK "$SMSTARTUP\Bitcoin.lnk" + Delete /REBOOTOK $INSTDIR\uninstall.exe + Delete /REBOOTOK $INSTDIR\debug.log + Delete /REBOOTOK $INSTDIR\db.log + DeleteRegValue HKCU "${REGKEY}" StartMenuGroup + DeleteRegValue HKCU "${REGKEY}" Path + DeleteRegKey /IfEmpty HKCU "${REGKEY}\Components" + DeleteRegKey /IfEmpty HKCU "${REGKEY}" + DeleteRegKey HKCR "novacoin" + RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup + RmDir /REBOOTOK $INSTDIR + Push $R0 + StrCpy $R0 $StartMenuGroup 1 + StrCmp $R0 ">" no_smgroup +no_smgroup: + Pop $R0 +SectionEnd + +# Installer functions +Function .onInit + InitPluginsDir +FunctionEnd + +# Uninstaller functions +Function un.onInit + ReadRegStr $INSTDIR HKCU "${REGKEY}" Path + !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuGroup + !insertmacro SELECT_UNSECTION Main ${UNSEC0000} +FunctionEnd diff --git a/share/ui.rc b/share/ui.rc new file mode 100644 index 0000000..c3cece1 --- /dev/null +++ b/share/ui.rc @@ -0,0 +1,15 @@ +bitcoin ICON "pixmaps/bitcoin.ico" + +#include "wx/msw/wx.rc" + +check ICON "pixmaps/check.ico" +send16 BITMAP "pixmaps/send16.bmp" +send16mask BITMAP "pixmaps/send16mask.bmp" +send16masknoshadow BITMAP "pixmaps/send16masknoshadow.bmp" +send20 BITMAP "pixmaps/send20.bmp" +send20mask BITMAP "pixmaps/send20mask.bmp" +addressbook16 BITMAP "pixmaps/addressbook16.bmp" +addressbook16mask BITMAP "pixmaps/addressbook16mask.bmp" +addressbook20 BITMAP "pixmaps/addressbook20.bmp" +addressbook20mask BITMAP "pixmaps/addressbook20mask.bmp" +favicon ICON "pixmaps/favicon.ico" diff --git a/sono-qt.pro b/sono-qt.pro new file mode 100644 index 0000000..bd30786 --- /dev/null +++ b/sono-qt.pro @@ -0,0 +1,571 @@ +TEMPLATE = app +TARGET = SONO-qt +VERSION = 1.2.0.0 +INCLUDEPATH += src src/json src/qt src/qt/plugins/mrichtexteditor +DEFINES += ENABLE_WALLET +DEFINES += BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE +CONFIG += no_include_pwd +CONFIG += thread +CONFIG += static +QT += core gui network printsupport +QMAKE_CXXFLAGS = -fpermissive + +greaterThan(QT_MAJOR_VERSION, 4) { + QT += widgets + DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 +} + + +win32 { +windows:LIBS += -lshlwapi +LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,) +LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX +windows:LIBS += -lws2_32 -lole32 -loleaut32 -luuid -lgdi32 +LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX +BOOST_INCLUDE_PATH=C:/deps/boost_1_57_0 +BOOST_LIB_PATH=C:/deps/boost_1_57_0/stage/lib +BDB_INCLUDE_PATH=C:/deps/db-4.8.30.NC/build_unix +BDB_LIB_PATH=C:/deps/db-4.8.30.NC/build_unix +OPENSSL_INCLUDE_PATH=C:/deps/openssl-1.0.1m/include +OPENSSL_LIB_PATH=C:/deps/openssl-1.0.1m +MINIUPNPC_INCLUDE_PATH=C:/deps/ +MINIUPNPC_LIB_PATH=C:/deps/miniupnpc +LIBPNG_INCLUDE_PATH=C:/deps/libpng-1.6.16 +LIBPNG_LIB_PATH=C:/deps/libpng-1.6.16/.libs +QRENCODE_INCLUDE_PATH=C:/deps/qrencode-3.4.4 +QRENCODE_LIB_PATH=C:/deps/qrencode-3.4.4/.libs +SECP256K1_LIB_PATH =/home/uzbek/sw/secp256k1/.libs +SECP256K1_INCLUDE_PATH = /home/uzbek/sw/secp256k1/include +#GMP_INCLUDE_PATH=C:/deps/gmp-6.0.0 +#GMP_LIB_PATH=C:/deps/gmp-6.0.0/.libs +} + + +linux { + SECP256K1_LIB_PATH = /usr/local/lib + SECP256K1_INCLUDE_PATH = /usr/local/include +} + +# for boost 1.37, add -mt to the boost libraries +# use: qmake BOOST_LIB_SUFFIX=-mt +# for boost thread win32 with _win32 sufix +# use: BOOST_THREAD_LIB_SUFFIX=_win32-... +# or when linking against a specific BerkelyDB version: BDB_LIB_SUFFIX=-4.8 + +# Dependency library locations can be customized with: +# BOOST_INCLUDE_PATH, BOOST_LIB_PATH, BDB_INCLUDE_PATH, +# BDB_LIB_PATH, OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively + +OBJECTS_DIR = build +MOC_DIR = build +UI_DIR = build + +# use: qmake "RELEASE=1" +contains(RELEASE, 1) { + # Mac: compile for maximum compatibility (10.5, 32-bit) + macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk + macx:QMAKE_CFLAGS += -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk + macx:QMAKE_LFLAGS += -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk + macx:QMAKE_OBJECTIVE_CFLAGS += -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk + + + !windows:!macx { + # Linux: static link + # LIBS += -Wl,-Bstatic + } +} + +!win32 { +# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection +QMAKE_CXXFLAGS *= -fstack-protector-all --param ssp-buffer-size=1 +QMAKE_LFLAGS *= -fstack-protector-all --param ssp-buffer-size=1 +# We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable! +# This can be enabled for Windows, when we switch to MinGW >= 4.4.x. +} +# for extra security on Windows: enable ASLR and DEP via GCC linker flags +win32:QMAKE_LFLAGS *= -Wl,--dynamicbase -Wl,--nxcompat +# on win32: enable GCC large address aware linker flag +win32:QMAKE_LFLAGS *= -Wl,--large-address-aware -static +win32:QMAKE_LFLAGS += -static-libgcc -static-libstdc++ +lessThan(QT_MAJOR_VERSION, 5): win32: QMAKE_LFLAGS *= -static + +# use: qmake "USE_QRCODE=1" +# libqrencode (http://fukuchi.org/works/qrencode/index.en.html) must be installed for support +contains(USE_QRCODE, 1) { + message(Building with QRCode support) + DEFINES += USE_QRCODE + LIBS += -lqrencode +} + +# use: qmake "USE_UPNP=1" ( enabled by default; default) +# or: qmake "USE_UPNP=0" (disabled by default) +# or: qmake "USE_UPNP=-" (not supported) +# miniupnpc (http://miniupnp.free.fr/files/) must be installed for support +contains(USE_UPNP, -) { + message(Building without UPNP support) +} else { + message(Building with UPNP support) + count(USE_UPNP, 0) { + USE_UPNP=1 + } + DEFINES += USE_UPNP=$$USE_UPNP STATICLIB + INCLUDEPATH += $$MINIUPNPC_INCLUDE_PATH + LIBS += $$join(MINIUPNPC_LIB_PATH,,-L,) -lminiupnpc + win32:LIBS += -liphlpapi +} + +# use: qmake "USE_DBUS=1" or qmake "USE_DBUS=0" +linux:count(USE_DBUS, 0) { + USE_DBUS=1 +} +contains(USE_DBUS, 1) { + message(Building with DBUS (Freedesktop notifications) support) + DEFINES += USE_DBUS + QT += dbus +} + +contains(BITCOIN_NEED_QT_PLUGINS, 1) { + DEFINES += BITCOIN_NEED_QT_PLUGINS + QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs qtaccessiblewidgets +} + +# LIBSEC256K1 SUPPORT +#QMAKE_CXXFLAGS *= -DUSE_SECP256K1 + +INCLUDEPATH += src/leveldb/include src/leveldb/helpers +LIBS += $$PWD/src/leveldb/libleveldb.a $$PWD/src/leveldb/libmemenv.a +SOURCES += src/txdb-leveldb.cpp \ + src/bloom.cpp \ + src/hash.cpp \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/qt/rpcexecutor.cpp \ + src/qt/forms/sidetoolbar.cpp + +!win32 { + # we use QMAKE_CXXFLAGS_RELEASE even without RELEASE=1 because we use RELEASE to indicate linking preferences not -O preferences + genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a +} else { + # make an educated guess about what the ranlib command is called + isEmpty(QMAKE_RANLIB) { + QMAKE_RANLIB = $$replace(QMAKE_STRIP, strip, ranlib) + } + LIBS += -lshlwapi + #genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libleveldb.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libmemenv.a +} +genleveldb.target = $$PWD/src/leveldb/libleveldb.a +genleveldb.depends = FORCE +PRE_TARGETDEPS += $$PWD/src/leveldb/libleveldb.a +QMAKE_EXTRA_TARGETS += genleveldb +# Gross ugly hack that depends on qmake internals, unfortunately there is no other way to do it. +QMAKE_CLEAN += $$PWD/src/leveldb/libleveldb.a; cd $$PWD/src/leveldb ; $(MAKE) clean + +# regenerate src/build.h +!windows|contains(USE_BUILD_INFO, 1) { + genbuild.depends = FORCE + genbuild.commands = cd $$PWD; /bin/sh share/genbuild.sh $$OUT_PWD/build/build.h + genbuild.target = $$OUT_PWD/build/build.h + PRE_TARGETDEPS += $$OUT_PWD/build/build.h + QMAKE_EXTRA_TARGETS += genbuild + DEFINES += HAVE_BUILD_INFO +} + +contains(USE_O3, 1) { + message(Building O3 optimization flag) + QMAKE_CXXFLAGS_RELEASE -= -O2 + QMAKE_CFLAGS_RELEASE -= -O2 + QMAKE_CXXFLAGS += -O3 + QMAKE_CFLAGS += -O3 +} + +*-g++-32 { + message("32 platform, adding -msse2 flag") + + QMAKE_CXXFLAGS += -msse2 + QMAKE_CFLAGS += -msse2 +} + +QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector + +# Input +DEPENDPATH += src src/json src/qt +HEADERS += src/qt/bitcoingui.h \ + src/qt/transactiontablemodel.h \ + src/qt/addresstablemodel.h \ + src/qt/optionsdialog.h \ + src/qt/coincontroldialog.h \ + src/qt/coincontroltreewidget.h \ + src/qt/sendcoinsdialog.h \ + src/qt/addressbookpage.h \ + src/qt/clientcontrolpage.h \ + src/qt/signverifymessagedialog.h \ + src/qt/aboutdialog.h \ + src/qt/editaddressdialog.h \ + src/qt/bitcoinaddressvalidator.h \ + src/alert.h \ + src/addrman.h \ + src/base58.h \ + src/bignum.h \ + src/chainparams.h \ + src/chainparamsseeds.h \ + src/checkpoints.h \ + src/compat.h \ + src/coincontrol.h \ + src/sync.h \ + src/util.h \ + src/hash.h \ + src/uint256.h \ + src/kernel.h \ + src/pbkdf2.h \ + src/serialize.h \ + src/core.h \ + src/main.h \ + src/miner.h \ + src/net.h \ + src/key.h \ + src/eckey.h \ + src/db.h \ + src/txdb.h \ + src/txmempool.h \ + src/walletdb.h \ + src/script.h \ + src/scrypt.h \ + src/init.h \ + src/mruset.h \ + src/json/json_spirit_writer_template.h \ + src/json/json_spirit_writer.h \ + src/json/json_spirit_value.h \ + src/json/json_spirit_utils.h \ + src/json/json_spirit_stream_reader.h \ + src/json/json_spirit_reader_template.h \ + src/json/json_spirit_reader.h \ + src/json/json_spirit_error_position.h \ + src/json/json_spirit.h \ + src/qt/blockbrowser.h \ + src/qt/clientmodel.h \ + src/qt/guiutil.h \ + src/qt/transactionrecord.h \ + src/qt/guiconstants.h \ + src/qt/optionsmodel.h \ + src/qt/monitoreddatamapper.h \ + src/qt/trafficgraphwidget.h \ + src/qt/transactiondesc.h \ + src/qt/transactiondescdialog.h \ + src/qt/bitcoinamountfield.h \ + src/wallet.h \ + src/keystore.h \ + src/qt/transactionfilterproxy.h \ + src/qt/transactionview.h \ + src/qt/walletmodel.h \ + src/rpcclient.h \ + src/rpcprotocol.h \ + src/rpcserver.h \ + src/timedata.h \ + src/qt/overviewpage.h \ + src/qt/csvmodelwriter.h \ + src/crypter.h \ + src/qt/sendcoinsentry.h \ + src/qt/qvalidatedlineedit.h \ + src/qt/bitcoinunits.h \ + src/qt/qvaluecombobox.h \ + src/qt/askpassphrasedialog.h \ + src/protocol.h \ + src/qt/notificator.h \ + src/qt/paymentserver.h \ + src/allocators.h \ + src/ui_interface.h \ + src/qt/rpcconsole.h \ + src/version.h \ + src/netbase.h \ + src/clientversion.h \ + src/threadsafety.h \ + src/tinyformat.h \ + src/stealth.h \ + src/qt/flowlayout.h \ + src/qt/darksendconfig.h \ + src/masternode.h \ + src/darksend.h \ + src/instantx.h \ + src/activemasternode.h \ + src/spork.h \ + src/crypto/common.h \ + src/crypto/hmac_sha256.h \ + src/crypto/hmac_sha512.h \ + src/crypto/rfc6979_hmac_sha256.h \ + src/crypto/ripemd160.h \ + src/crypto/sha1.h \ + src/crypto/sha256.h \ + src/crypto/sha512.h \ + src/eccryptoverify.h \ + src/qt/masternodemanager.h \ + src/qt/addeditadrenalinenode.h \ + src/qt/adrenalinenodeconfigdialog.h \ + src/qt/qcustomplot.h \ + src/smessage.h \ + src/qt/messagepage.h \ + src/qt/messagemodel.h \ + src/qt/sendmessagesdialog.h \ + src/qt/sendmessagesentry.h \ + src/qt/plugins/mrichtexteditor/mrichtextedit.h \ + src/qt/qvalidatedtextedit.h \ + src/bloom.h \ + src/hashblock.h \ + src/obj/skunkhash/sph_skein.h \ + src/obj/skunkhash/sph_types.h \ + src/obj/skunkhash/sph_cubehash.h \ + src/obj/skunkhash/sph_fugue.h \ + src/txdb-leveldb.h \ + src/qt/txviewdelegate.h \ + src/qt/rpcexecutor.h \ + src/qt/forms/sidetoolbar.h + +SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \ + src/obj/skunkhash/skein.c \ + src/obj/skunkhash/cubehash.c \ + src/obj/skunkhash/gost.c \ + src/obj/skunkhash/fugue.c \ + src/qt/transactiontablemodel.cpp \ + src/qt/addresstablemodel.cpp \ + src/qt/optionsdialog.cpp \ + src/qt/sendcoinsdialog.cpp \ + src/qt/coincontroldialog.cpp \ + src/qt/coincontroltreewidget.cpp \ + src/qt/addressbookpage.cpp \ + src/qt/signverifymessagedialog.cpp \ + src/qt/aboutdialog.cpp \ + src/qt/editaddressdialog.cpp \ + src/qt/bitcoinaddressvalidator.cpp \ + src/alert.cpp \ + src/chainparams.cpp \ + src/version.cpp \ + src/sync.cpp \ + src/txmempool.cpp \ + src/util.cpp \ + src/netbase.cpp \ + src/key.cpp \ + src/eckey.cpp \ + src/script.cpp \ + src/scrypt.cpp \ + src/core.cpp \ + src/main.cpp \ + src/miner.cpp \ + src/init.cpp \ + src/net.cpp \ + src/checkpoints.cpp \ + src/addrman.cpp \ + src/db.cpp \ + src/walletdb.cpp \ + src/qt/blockbrowser.cpp \ + src/qt/clientmodel.cpp \ + src/qt/clientcontrolpage.cpp \ + src/qt/guiutil.cpp \ + src/qt/transactionrecord.cpp \ + src/qt/optionsmodel.cpp \ + src/qt/monitoreddatamapper.cpp \ + src/qt/trafficgraphwidget.cpp \ + src/qt/transactiondesc.cpp \ + src/qt/transactiondescdialog.cpp \ + src/qt/bitcoinstrings.cpp \ + src/qt/bitcoinamountfield.cpp \ + src/wallet.cpp \ + src/keystore.cpp \ + src/qt/transactionfilterproxy.cpp \ + src/qt/transactionview.cpp \ + src/qt/walletmodel.cpp \ + src/rpcclient.cpp \ + src/rpcprotocol.cpp \ + src/rpcserver.cpp \ + src/rpcdump.cpp \ + src/rpcmisc.cpp \ + src/rpcnet.cpp \ + src/rpcmining.cpp \ + src/rpcwallet.cpp \ + src/rpcblockchain.cpp \ + src/rpcrawtransaction.cpp \ + src/timedata.cpp \ + src/qt/overviewpage.cpp \ + src/qt/csvmodelwriter.cpp \ + src/crypter.cpp \ + src/qt/sendcoinsentry.cpp \ + src/qt/qvalidatedlineedit.cpp \ + src/qt/bitcoinunits.cpp \ + src/qt/qvaluecombobox.cpp \ + src/qt/askpassphrasedialog.cpp \ + src/protocol.cpp \ + src/qt/notificator.cpp \ + src/qt/paymentserver.cpp \ + src/qt/rpcconsole.cpp \ + src/noui.cpp \ + src/kernel.cpp \ + src/pbkdf2.cpp \ + src/stealth.cpp \ + src/qt/flowlayout.cpp \ + src/qt/darksendconfig.cpp \ + src/masternode.cpp \ + src/darksend.cpp \ + src/rpcdarksend.cpp \ + src/instantx.cpp \ + src/activemasternode.cpp \ + src/spork.cpp \ + src/masternodeconfig.cpp \ + src/crypto/hmac_sha256.cpp \ + src/crypto/hmac_sha512.cpp \ + src/crypto/rfc6979_hmac_sha256.cpp \ + src/crypto/ripemd160.cpp \ + src/crypto/sha1.cpp \ + src/crypto/sha256.cpp \ + src/crypto/sha512.cpp \ + src/eccryptoverify.cpp \ + src/qt/masternodemanager.cpp \ + src/qt/addeditadrenalinenode.cpp \ + src/qt/adrenalinenodeconfigdialog.cpp \ + src/qt/qcustomplot.cpp \ + src/smessage.cpp \ + src/qt/messagepage.cpp \ + src/qt/messagemodel.cpp \ + src/qt/sendmessagesdialog.cpp \ + src/qt/sendmessagesentry.cpp \ + src/qt/qvalidatedtextedit.cpp \ + src/qt/plugins/mrichtexteditor/mrichtextedit.cpp \ + src/rpcsmessage.cpp + + +RESOURCES += \ + src/qt/bitcoin.qrc + +FORMS += \ + src/qt/forms/coincontroldialog.ui \ + src/qt/forms/sendcoinsdialog.ui \ + src/qt/forms/addressbookpage.ui \ + src/qt/forms/signverifymessagedialog.ui \ + src/qt/forms/aboutdialog.ui \ + src/qt/forms/editaddressdialog.ui \ + src/qt/forms/transactiondescdialog.ui \ + src/qt/forms/overviewpage.ui \ + src/qt/forms/clientcontrolpage.ui \ + src/qt/forms/sendcoinsentry.ui \ + src/qt/forms/askpassphrasedialog.ui \ + src/qt/forms/blockbrowser.ui \ + src/qt/forms/rpcconsole.ui \ + src/qt/forms/optionsdialog.ui \ + src/qt/forms/darksendconfig.ui \ + src/qt/forms/masternodemanager.ui \ + src/qt/forms/addeditadrenalinenode.ui \ + src/qt/forms/adrenalinenodeconfigdialog.ui \ + src/qt/forms/messagepage.ui \ + src/qt/forms/sendmessagesentry.ui \ + src/qt/forms/sendmessagesdialog.ui \ + src/qt/plugins/mrichtexteditor/mrichtextedit.ui \ + src/qt/forms/sidetoolbar.ui + +contains(USE_QRCODE, 1) { +HEADERS += src/qt/qrcodedialog.h +SOURCES += src/qt/qrcodedialog.cpp +FORMS += src/qt/forms/qrcodedialog.ui +} + +CODECFORTR = UTF-8 + +# for lrelease/lupdate +# also add new translations to src/qt/bitcoin.qrc under translations/ +TRANSLATIONS = $$files(src/qt/locale/bitcoin_*.ts) + +isEmpty(QMAKE_LRELEASE) { + win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\\lrelease.exe + else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease +} +isEmpty(QM_DIR):QM_DIR = $$PWD/src/qt/locale +# automatically build translations, so they can be included in resource file +TSQM.name = lrelease ${QMAKE_FILE_IN} +TSQM.input = TRANSLATIONS +TSQM.output = $$QM_DIR/${QMAKE_FILE_BASE}.qm +TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT} +TSQM.CONFIG = no_link +QMAKE_EXTRA_COMPILERS += TSQM + +# "Other files" to show in Qt Creator +OTHER_FILES += \ + doc/*.rst doc/*.txt doc/README README.md res/bitcoin-qt.rc + +# platform specific defaults, if not overridden on command line +isEmpty(BOOST_LIB_SUFFIX) { + macx:BOOST_LIB_SUFFIX = -mt + windows:BOOST_LIB_SUFFIX = -mt +} + +isEmpty(BOOST_THREAD_LIB_SUFFIX) { + BOOST_THREAD_LIB_SUFFIX = $$BOOST_LIB_SUFFIX + #win32:BOOST_THREAD_LIB_SUFFIX = _win32$$BOOST_LIB_SUFFIX + #else:BOOST_THREAD_LIB_SUFFIX = $$BOOST_LIB_SUFFIX +} + +isEmpty(BDB_LIB_PATH) { + macx:BDB_LIB_PATH = /opt/local/lib/db48 +} + +isEmpty(BDB_LIB_SUFFIX) { + macx:BDB_LIB_SUFFIX = -4.8 +} + +isEmpty(BDB_INCLUDE_PATH) { + macx:BDB_INCLUDE_PATH = /opt/local/include/db48 +} + +isEmpty(BOOST_LIB_PATH) { + macx:BOOST_LIB_PATH = /opt/local/lib +} + +isEmpty(BOOST_INCLUDE_PATH) { + macx:BOOST_INCLUDE_PATH = /opt/local/include +} + +windows:DEFINES += WIN32 +windows:RC_FILE = src/qt/res/bitcoin-qt.rc + +windows:!contains(MINGW_THREAD_BUGFIX, 0) { + # At least qmake's win32-g++-cross profile is missing the -lmingwthrd + # thread-safety flag. GCC has -mthreads to enable this, but it doesn't + # work with static linking. -lmingwthrd must come BEFORE -lmingw, so + # it is prepended to QMAKE_LIBS_QT_ENTRY. + # It can be turned off with MINGW_THREAD_BUGFIX=0, just in case it causes + # any problems on some untested qmake profile now or in the future. + DEFINES += _MT BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN + QMAKE_LIBS_QT_ENTRY = -lmingwthrd $$QMAKE_LIBS_QT_ENTRY +} + +macx:HEADERS += src/qt/macdockiconhandler.h +macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm +macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit +macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0 +macx:ICON = src/qt/res/icons/SONO.icns +macx:TARGET = "SONO-Qt" +macx:QMAKE_CFLAGS_THREAD += -pthread +macx:QMAKE_LFLAGS_THREAD += -pthread +macx:QMAKE_CXXFLAGS_THREAD += -pthread +macx:QMAKE_INFO_PLIST = share/qt/Info.plist + +# Set libraries and includes at end, to use platform-defined defaults if not overridden +INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH +LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,) +LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX +# -lgdi32 has to happen after -lcrypto (see #681) +windows:LIBS += -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32 +LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX +windows:LIBS += -lboost_chrono$$BOOST_LIB_SUFFIX + +contains(RELEASE, 1) { + !windows:!macx { + # Linux: turn dynamic linking back on for c/c++ runtime libraries + LIBS += -Wl,-Bdynamic + } +} + +!windows:!macx { + DEFINES += LINUX + LIBS += -lrt -ldl +} + +system($$QMAKE_LRELEASE -silent $$_PRO_FILE_) + diff --git a/src/activemasternode.cpp b/src/activemasternode.cpp new file mode 100644 index 0000000..fd64c80 --- /dev/null +++ b/src/activemasternode.cpp @@ -0,0 +1,473 @@ +// Copyright (c) 2009-2012 The Darkcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "protocol.h" +#include "activemasternode.h" +#include +#include "clientversion.h" + +// +// Bootup the masternode, look for a 1000 SONO input and register on the network +// +void CActiveMasternode::ManageStatus() +{ + std::string errorMessage; + + if(!fMasterNode) return; + + if (fDebug) LogPrintf("CActiveMasternode::ManageStatus() - Begin\n"); + + //need correct adjusted time to send ping + bool fIsInitialDownload = IsInitialBlockDownload(); + if(fIsInitialDownload) { + status = MASTERNODE_SYNC_IN_PROCESS; + LogPrintf("CActiveMasternode::ManageStatus() - Sync in progress. Must wait until sync is complete to start masternode.\n"); + return; + } + + if(status == MASTERNODE_INPUT_TOO_NEW || status == MASTERNODE_NOT_CAPABLE || status == MASTERNODE_SYNC_IN_PROCESS){ + status = MASTERNODE_NOT_PROCESSED; + } + + if(status == MASTERNODE_NOT_PROCESSED) { + if(strMasterNodeAddr.empty()) { + if(!GetLocal(service)) { + notCapableReason = "Can't detect external address. Please use the masternodeaddr configuration option."; + status = MASTERNODE_NOT_CAPABLE; + LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); + return; + } + } else { + service = CService(strMasterNodeAddr, true); + } + + LogPrintf("CActiveMasternode::ManageStatus() - Checking inbound connection to '%s'\n", service.ToString().c_str()); + + + if(!ConnectNode((CAddress)service, service.ToString().c_str())){ + notCapableReason = "Could not connect to " + service.ToString(); + status = MASTERNODE_NOT_CAPABLE; + LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); + return; + } + + + if(pwalletMain->IsLocked()){ + notCapableReason = "Wallet is locked."; + status = MASTERNODE_NOT_CAPABLE; + LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); + return; + } + + // Set defaults + status = MASTERNODE_NOT_CAPABLE; + notCapableReason = "Unknown. Check debug.log for more information.\n"; + + // Choose coins to use + CPubKey pubKeyCollateralAddress; + CKey keyCollateralAddress; + + if(GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress)) { + + if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS){ + LogPrintf("CActiveMasternode::ManageStatus() - Input must have least %d confirmations - %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS, GetInputAge(vin)); + status = MASTERNODE_INPUT_TOO_NEW; + return; + } + + LogPrintf("CActiveMasternode::ManageStatus() - Is capable master node!\n"); + + status = MASTERNODE_IS_CAPABLE; + notCapableReason = ""; + + pwalletMain->LockCoin(vin.prevout); + + // send to all nodes + CPubKey pubKeyMasternode; + CKey keyMasternode; + + if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode)) + { + LogPrintf("Register::ManageStatus() - Error upon calling SetKey: %s\n", errorMessage.c_str()); + return; + } + + if(!Register(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage)) { + LogPrintf("CActiveMasternode::ManageStatus() - Error on Register: %s\n", errorMessage.c_str()); + } + + return; + } else { + LogPrintf("CActiveMasternode::ManageStatus() - Could not find suitable coins!\n"); + } + } + + //send to all peers + if(!Dseep(errorMessage)) { + LogPrintf("CActiveMasternode::ManageStatus() - Error on Ping: %s", errorMessage.c_str()); + } +} + +// Send stop dseep to network for remote masternode +bool CActiveMasternode::StopMasterNode(std::string strService, std::string strKeyMasternode, std::string& errorMessage) { + CTxIn vin; + CKey keyMasternode; + CPubKey pubKeyMasternode; + + if(!darkSendSigner.SetKey(strKeyMasternode, errorMessage, keyMasternode, pubKeyMasternode)) { + LogPrintf("CActiveMasternode::StopMasterNode() - Error: %s\n", errorMessage.c_str()); + return false; + } + + return StopMasterNode(vin, CService(strService), keyMasternode, pubKeyMasternode, errorMessage); +} + +// Send stop dseep to network for main masternode +bool CActiveMasternode::StopMasterNode(std::string& errorMessage) { + if(status != MASTERNODE_IS_CAPABLE && status != MASTERNODE_REMOTELY_ENABLED) { + errorMessage = "masternode is not in a running status"; + LogPrintf("CActiveMasternode::StopMasterNode() - Error: %s\n", errorMessage.c_str()); + return false; + } + + status = MASTERNODE_STOPPED; + + CPubKey pubKeyMasternode; + CKey keyMasternode; + + if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode)) + { + LogPrintf("Register::ManageStatus() - Error upon calling SetKey: %s\n", errorMessage.c_str()); + return false; + } + + return StopMasterNode(vin, service, keyMasternode, pubKeyMasternode, errorMessage); +} + +// Send stop dseep to network for any masternode +bool CActiveMasternode::StopMasterNode(CTxIn vin, CService service, CKey keyMasternode, CPubKey pubKeyMasternode, std::string& errorMessage) { + pwalletMain->UnlockCoin(vin.prevout); + return Dseep(vin, service, keyMasternode, pubKeyMasternode, errorMessage, true); +} + +bool CActiveMasternode::Dseep(std::string& errorMessage) { + if(status != MASTERNODE_IS_CAPABLE && status != MASTERNODE_REMOTELY_ENABLED) { + errorMessage = "masternode is not in a running status"; + LogPrintf("CActiveMasternode::Dseep() - Error: %s\n", errorMessage.c_str()); + return false; + } + + CPubKey pubKeyMasternode; + CKey keyMasternode; + + if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode)) + { + LogPrintf("Register::ManageStatus() - Error upon calling SetKey: %s\n", errorMessage.c_str()); + return false; + } + + return Dseep(vin, service, keyMasternode, pubKeyMasternode, errorMessage, false); +} + +bool CActiveMasternode::Dseep(CTxIn vin, CService service, CKey keyMasternode, CPubKey pubKeyMasternode, std::string &retErrorMessage, bool stop) { + std::string errorMessage; + std::vector vchMasterNodeSignature; + std::string strMasterNodeSignMessage; + int64_t masterNodeSignatureTime = GetAdjustedTime(); + + std::string strMessage = service.ToString() + boost::lexical_cast(masterNodeSignatureTime) + boost::lexical_cast(stop); + + if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchMasterNodeSignature, keyMasternode)) { + retErrorMessage = "sign message failed: " + errorMessage; + LogPrintf("CActiveMasternode::Dseep() - Error: %s\n", retErrorMessage.c_str()); + return false; + } + + if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchMasterNodeSignature, strMessage, errorMessage)) { + retErrorMessage = "Verify message failed: " + errorMessage; + LogPrintf("CActiveMasternode::Dseep() - Error: %s\n", retErrorMessage.c_str()); + return false; + } + + // Update Last Seen timestamp in masternode list + bool found = false; + BOOST_FOREACH(CMasterNode& mn, vecMasternodes) { + //LogPrintf(" -- %s\n", mn.vin.ToString().c_str()); + if(mn.vin == vin) { + found = true; + mn.UpdateLastSeen(); + } + } + + if(!found){ + // Seems like we are trying to send a ping while the masternode is not registered in the network + retErrorMessage = "darksend Masternode List doesn't include our masternode, Shutting down masternode pinging service! " + vin.ToString(); + LogPrintf("CActiveMasternode::Dseep() - Error: %s\n", retErrorMessage.c_str()); + status = MASTERNODE_NOT_CAPABLE; + notCapableReason = retErrorMessage; + return false; + } + + //send to all peers + LogPrintf("CActiveMasternode::Dseep() - SendDarkSendElectionEntryPing vin = %s\n", vin.ToString().c_str()); + SendDarkSendElectionEntryPing(vin, vchMasterNodeSignature, masterNodeSignatureTime, stop); + + return true; +} + +bool CActiveMasternode::RegisterByPubKey(std::string strService, std::string strKeyMasternode, std::string collateralAddress, std::string& errorMessage) { + CTxIn vin; + CPubKey pubKeyCollateralAddress; + CKey keyCollateralAddress; + CPubKey pubKeyMasternode; + CKey keyMasternode; + + if(!darkSendSigner.SetKey(strKeyMasternode, errorMessage, keyMasternode, pubKeyMasternode)) + { + LogPrintf("CActiveMasternode::RegisterByPubKey() - Error upon calling SetKey: %s\n", errorMessage.c_str()); + return false; + } + + if(!GetMasterNodeVinForPubKey(collateralAddress, vin, pubKeyCollateralAddress, keyCollateralAddress)) { + errorMessage = "could not allocate vin for collateralAddress"; + LogPrintf("Register::Register() - Error: %s\n", errorMessage.c_str()); + return false; + } + return Register(vin, CService(strService), keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage); +} + +bool CActiveMasternode::Register(std::string strService, std::string strKeyMasternode, std::string txHash, std::string strOutputIndex, std::string& errorMessage) { + CTxIn vin; + CPubKey pubKeyCollateralAddress; + CKey keyCollateralAddress; + CPubKey pubKeyMasternode; + CKey keyMasternode; + + if(!darkSendSigner.SetKey(strKeyMasternode, errorMessage, keyMasternode, pubKeyMasternode)) + { + LogPrintf("CActiveMasternode::Register() - Error upon calling SetKey: %s\n", errorMessage.c_str()); + return false; + } + + if(!GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress, txHash, strOutputIndex)) { + errorMessage = "could not allocate vin"; + LogPrintf("Register::Register() - Error: %s\n", errorMessage.c_str()); + return false; + } + return Register(vin, CService(strService), keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage); +} + +bool CActiveMasternode::Register(CTxIn vin, CService service, CKey keyCollateralAddress, CPubKey pubKeyCollateralAddress, CKey keyMasternode, CPubKey pubKeyMasternode, std::string &retErrorMessage) { + std::string errorMessage; + std::vector vchMasterNodeSignature; + std::string strMasterNodeSignMessage; + int64_t masterNodeSignatureTime = GetAdjustedTime(); + + std::string vchPubKey(pubKeyCollateralAddress.begin(), pubKeyCollateralAddress.end()); + std::string vchPubKey2(pubKeyMasternode.begin(), pubKeyMasternode.end()); + + std::string strMessage = service.ToString() + boost::lexical_cast(masterNodeSignatureTime) + vchPubKey + vchPubKey2 + boost::lexical_cast(PROTOCOL_VERSION); + + if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchMasterNodeSignature, keyCollateralAddress)) { + retErrorMessage = "sign message failed: " + errorMessage; + LogPrintf("CActiveMasternode::Register() - Error: %s\n", retErrorMessage.c_str()); + return false; + } + + if(!darkSendSigner.VerifyMessage(pubKeyCollateralAddress, vchMasterNodeSignature, strMessage, errorMessage)) { + retErrorMessage = "Verify message failed: " + errorMessage; + LogPrintf("CActiveMasternode::Register() - Error: %s\n", retErrorMessage.c_str()); + return false; + } + + bool found = false; + LOCK(cs_masternodes); + BOOST_FOREACH(CMasterNode& mn, vecMasternodes) + if(mn.vin == vin) + found = true; + + if(!found) { + LogPrintf("CActiveMasternode::Register() - Adding to masternode list service: %s - vin: %s\n", service.ToString().c_str(), vin.ToString().c_str()); + CMasterNode mn(service, vin, pubKeyCollateralAddress, vchMasterNodeSignature, masterNodeSignatureTime, pubKeyMasternode, PROTOCOL_VERSION); + mn.UpdateLastSeen(masterNodeSignatureTime); + vecMasternodes.push_back(mn); + } + + //send to all peers + LogPrintf("CActiveMasternode::Register() - SendDarkSendElectionEntry vin = %s\n", vin.ToString().c_str()); + SendDarkSendElectionEntry(vin, service, vchMasterNodeSignature, masterNodeSignatureTime, pubKeyCollateralAddress, pubKeyMasternode, -1, -1, masterNodeSignatureTime, PROTOCOL_VERSION); + + return true; +} + +bool CActiveMasternode::GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secretKey) { + return GetMasterNodeVin(vin, pubkey, secretKey, "", ""); +} + +bool CActiveMasternode::GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secretKey, std::string strTxHash, std::string strOutputIndex) { + CScript pubScript; + + // Find possible candidates + vector possibleCoins = SelectCoinsMasternode(); + COutput *selectedOutput; + + // Find the vin + if(!strTxHash.empty()) { + // Let's find it + uint256 txHash(strTxHash); + int outputIndex = boost::lexical_cast(strOutputIndex); + bool found = false; + BOOST_FOREACH(COutput& out, possibleCoins) { + if(out.tx->GetHash() == txHash && out.i == outputIndex) + { + selectedOutput = &out; + found = true; + break; + } + } + if(!found) { + LogPrintf("CActiveMasternode::GetMasterNodeVin - Could not locate valid vin\n"); + return false; + } + } else { + // No output specified, Select the first one + if(possibleCoins.size() > 0) { + selectedOutput = &possibleCoins[0]; + } else { + LogPrintf("CActiveMasternode::GetMasterNodeVin - Could not locate specified vin from possible list\n"); + return false; + } + } + + // At this point we have a selected output, retrieve the associated info + return GetVinFromOutput(*selectedOutput, vin, pubkey, secretKey); +} + +bool CActiveMasternode::GetMasterNodeVinForPubKey(std::string collateralAddress, CTxIn& vin, CPubKey& pubkey, CKey& secretKey) { + return GetMasterNodeVinForPubKey(collateralAddress, vin, pubkey, secretKey, "", ""); +} + +bool CActiveMasternode::GetMasterNodeVinForPubKey(std::string collateralAddress, CTxIn& vin, CPubKey& pubkey, CKey& secretKey, std::string strTxHash, std::string strOutputIndex) { + CScript pubScript; + + // Find possible candidates + vector possibleCoins = SelectCoinsMasternodeForPubKey(collateralAddress); + COutput *selectedOutput; + + // Find the vin + if(!strTxHash.empty()) { + // Let's find it + uint256 txHash(strTxHash); + int outputIndex = boost::lexical_cast(strOutputIndex); + bool found = false; + BOOST_FOREACH(COutput& out, possibleCoins) { + if(out.tx->GetHash() == txHash && out.i == outputIndex) + { + selectedOutput = &out; + found = true; + break; + } + } + if(!found) { + LogPrintf("CActiveMasternode::GetMasterNodeVinForPubKey - Could not locate valid vin\n"); + return false; + } + } else { + // No output specified, Select the first one + if(possibleCoins.size() > 0) { + selectedOutput = &possibleCoins[0]; + } else { + LogPrintf("CActiveMasternode::GetMasterNodeVinForPubKey - Could not locate specified vin from possible list\n"); + return false; + } + } + + // At this point we have a selected output, retrieve the associated info + return GetVinFromOutput(*selectedOutput, vin, pubkey, secretKey); +} + + +// Extract masternode vin information from output +bool CActiveMasternode::GetVinFromOutput(COutput out, CTxIn& vin, CPubKey& pubkey, CKey& secretKey) { + + CScript pubScript; + + vin = CTxIn(out.tx->GetHash(),out.i); + pubScript = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey + + CTxDestination address1; + ExtractDestination(pubScript, address1); + CBitcoinAddress address2(address1); + + CKeyID keyID; + if (!address2.GetKeyID(keyID)) { + LogPrintf("CActiveMasternode::GetMasterNodeVin - Address does not refer to a key\n"); + return false; + } + + if (!pwalletMain->GetKey(keyID, secretKey)) { + LogPrintf ("CActiveMasternode::GetMasterNodeVin - Private key for address is not known\n"); + return false; + } + + pubkey = secretKey.GetPubKey(); + return true; +} + +// get all possible outputs for running masternode +vector CActiveMasternode::SelectCoinsMasternode() +{ + vector vCoins; + vector filteredCoins; + + // Retrieve all possible outputs + pwalletMain->AvailableCoinsMN(vCoins); + + // Filter + BOOST_FOREACH(const COutput& out, vCoins) + { + if(out.tx->vout[out.i].nValue == GetMNCollateral(pindexBest->nHeight)*COIN) { + filteredCoins.push_back(out); + } + } + return filteredCoins; +} + +// get all possible outputs for running masternode for a specific pubkey +vector CActiveMasternode::SelectCoinsMasternodeForPubKey(std::string collateralAddress) +{ + CBitcoinAddress address(collateralAddress); + CScript scriptPubKey; + scriptPubKey.SetDestination(address.Get()); + vector vCoins; + vector filteredCoins; + + // Retrieve all possible outputs + pwalletMain->AvailableCoins(vCoins); + + // Filter + BOOST_FOREACH(const COutput& out, vCoins) + { + if(out.tx->vout[out.i].scriptPubKey == scriptPubKey && out.tx->vout[out.i].nValue == 1000*COIN) { + filteredCoins.push_back(out); + } + } + return filteredCoins; +} + +// when starting a masternode, this can enable to run as a hot wallet with no funds +bool CActiveMasternode::EnableHotColdMasterNode(CTxIn& newVin, CService& newService) +{ + if(!fMasterNode) return false; + + status = MASTERNODE_REMOTELY_ENABLED; + + //The values below are needed for signing dseep messages going forward + this->vin = newVin; + this->service = newService; + + LogPrintf("CActiveMasternode::EnableHotColdMasterNode() - Enabled! You may shut down the cold daemon.\n"); + + return true; +} diff --git a/src/activemasternode.h b/src/activemasternode.h new file mode 100644 index 0000000..5a3d753 --- /dev/null +++ b/src/activemasternode.h @@ -0,0 +1,64 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The DarkCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef ACTIVEMASTERNODE_H +#define ACTIVEMASTERNODE_H + +#include "uint256.h" +#include "sync.h" +#include "net.h" +#include "key.h" +//#include "primitives/transaction.h" +#include "main.h" +#include "init.h" +#include "wallet.h" +#include "darksend.h" + +// Responsible for activating the masternode and pinging the network +class CActiveMasternode +{ +public: + // Initialized by init.cpp + // Keys for the main masternode + CPubKey pubKeyMasternode; + + // Initialized while registering masternode + CTxIn vin; + CService service; + + int status; + std::string notCapableReason; + + CActiveMasternode() + { + status = MASTERNODE_NOT_PROCESSED; + } + + void ManageStatus(); // manage status of main masternode + + bool Dseep(std::string& errorMessage); // ping for main masternode + bool Dseep(CTxIn vin, CService service, CKey key, CPubKey pubKey, std::string &retErrorMessage, bool stop); // ping for any masternode + + bool StopMasterNode(std::string& errorMessage); // stop main masternode + bool StopMasterNode(std::string strService, std::string strKeyMasternode, std::string& errorMessage); // stop remote masternode + bool StopMasterNode(CTxIn vin, CService service, CKey key, CPubKey pubKey, std::string& errorMessage); // stop any masternode + + bool Register(std::string strService, std::string strKey, std::string txHash, std::string strOutputIndex, std::string& errorMessage); // register remote masternode + bool Register(CTxIn vin, CService service, CKey key, CPubKey pubKey, CKey keyMasternode, CPubKey pubKeyMasternode, std::string &retErrorMessage); // register any masternode + bool RegisterByPubKey(std::string strService, std::string strKeyMasternode, std::string collateralAddress, std::string& errorMessage); // register for a specific collateral address + + // get 1000 SONO input that can be used for the masternode + bool GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secretKey); + bool GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secretKey, std::string strTxHash, std::string strOutputIndex); + bool GetMasterNodeVinForPubKey(std::string collateralAddress, CTxIn& vin, CPubKey& pubkey, CKey& secretKey); + bool GetMasterNodeVinForPubKey(std::string collateralAddress, CTxIn& vin, CPubKey& pubkey, CKey& secretKey, std::string strTxHash, std::string strOutputIndex); + vector SelectCoinsMasternode(); + vector SelectCoinsMasternodeForPubKey(std::string collateralAddress); + bool GetVinFromOutput(COutput out, CTxIn& vin, CPubKey& pubkey, CKey& secretKey); + + // enable hot wallet mode (run a masternode with no funds) + bool EnableHotColdMasterNode(CTxIn& vin, CService& addr); +}; + +#endif diff --git a/src/addrman.cpp b/src/addrman.cpp new file mode 100644 index 0000000..53b410d --- /dev/null +++ b/src/addrman.cpp @@ -0,0 +1,531 @@ +// Copyright (c) 2012 Pieter Wuille +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "addrman.h" +#include "hash.h" + +using namespace std; + +int CAddrInfo::GetTriedBucket(const std::vector &nKey) const +{ + CDataStream ss1(SER_GETHASH, 0); + std::vector vchKey = GetKey(); + ss1 << nKey << vchKey; + uint64_t hash1 = Hash(ss1.begin(), ss1.end()).Get64(); + + CDataStream ss2(SER_GETHASH, 0); + std::vector vchGroupKey = GetGroup(); + ss2 << nKey << vchGroupKey << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP); + uint64_t hash2 = Hash(ss2.begin(), ss2.end()).Get64(); + return hash2 % ADDRMAN_TRIED_BUCKET_COUNT; +} + +int CAddrInfo::GetNewBucket(const std::vector &nKey, const CNetAddr& src) const +{ + CDataStream ss1(SER_GETHASH, 0); + std::vector vchGroupKey = GetGroup(); + std::vector vchSourceGroupKey = src.GetGroup(); + ss1 << nKey << vchGroupKey << vchSourceGroupKey; + uint64_t hash1 = Hash(ss1.begin(), ss1.end()).Get64(); + + CDataStream ss2(SER_GETHASH, 0); + ss2 << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP); + uint64_t hash2 = Hash(ss2.begin(), ss2.end()).Get64(); + return hash2 % ADDRMAN_NEW_BUCKET_COUNT; +} + +bool CAddrInfo::IsTerrible(int64_t nNow) const +{ + if (nLastTry && nLastTry >= nNow-60) // never remove things tried the last minute + return false; + + if (nTime > nNow + 10*60) // came in a flying DeLorean + return true; + + if (nTime==0 || nNow-nTime > ADDRMAN_HORIZON_DAYS*24*60*60) // not seen in recent history + return true; + + if (nLastSuccess==0 && nAttempts>=ADDRMAN_RETRIES) // tried N times and never a success + return true; + + if (nNow-nLastSuccess > ADDRMAN_MIN_FAIL_DAYS*24*60*60 && nAttempts>=ADDRMAN_MAX_FAILURES) // N successive failures in the last week + return true; + + return false; +} + +double CAddrInfo::GetChance(int64_t nNow) const +{ + double fChance = 1.0; + + int64_t nSinceLastSeen = nNow - nTime; + int64_t nSinceLastTry = nNow - nLastTry; + + if (nSinceLastSeen < 0) nSinceLastSeen = 0; + if (nSinceLastTry < 0) nSinceLastTry = 0; + + fChance *= 600.0 / (600.0 + nSinceLastSeen); + + // deprioritize very recent attempts away + if (nSinceLastTry < 60*10) + fChance *= 0.01; + + // deprioritize 50% after each failed attempt + for (int n=0; n::iterator it = mapAddr.find(addr); + if (it == mapAddr.end()) + return NULL; + if (pnId) + *pnId = (*it).second; + std::map::iterator it2 = mapInfo.find((*it).second); + if (it2 != mapInfo.end()) + return &(*it2).second; + return NULL; +} + +CAddrInfo* CAddrMan::Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId) +{ + int nId = nIdCount++; + mapInfo[nId] = CAddrInfo(addr, addrSource); + mapAddr[addr] = nId; + mapInfo[nId].nRandomPos = vRandom.size(); + vRandom.push_back(nId); + if (pnId) + *pnId = nId; + return &mapInfo[nId]; +} + +void CAddrMan::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2) +{ + if (nRndPos1 == nRndPos2) + return; + + assert(nRndPos1 < vRandom.size() && nRndPos2 < vRandom.size()); + + int nId1 = vRandom[nRndPos1]; + int nId2 = vRandom[nRndPos2]; + + assert(mapInfo.count(nId1) == 1); + assert(mapInfo.count(nId2) == 1); + + mapInfo[nId1].nRandomPos = nRndPos2; + mapInfo[nId2].nRandomPos = nRndPos1; + + vRandom[nRndPos1] = nId2; + vRandom[nRndPos2] = nId1; +} + +int CAddrMan::SelectTried(int nKBucket) +{ + std::vector &vTried = vvTried[nKBucket]; + + // random shuffle the first few elements (using the entire list) + // find the least recently tried among them + int64_t nOldest = -1; + int nOldestPos = -1; + for (unsigned int i = 0; i < ADDRMAN_TRIED_ENTRIES_INSPECT_ON_EVICT && i < vTried.size(); i++) + { + int nPos = GetRandInt(vTried.size() - i) + i; + int nTemp = vTried[nPos]; + vTried[nPos] = vTried[i]; + vTried[i] = nTemp; + assert(nOldest == -1 || mapInfo.count(nTemp) == 1); + if (nOldest == -1 || mapInfo[nTemp].nLastSuccess < mapInfo[nOldest].nLastSuccess) { + nOldest = nTemp; + nOldestPos = nPos; + } + } + + return nOldestPos; +} + +int CAddrMan::ShrinkNew(int nUBucket) +{ + assert(nUBucket >= 0 && (unsigned int)nUBucket < vvNew.size()); + std::set &vNew = vvNew[nUBucket]; + + // first look for deletable items + for (std::set::iterator it = vNew.begin(); it != vNew.end(); it++) + { + assert(mapInfo.count(*it)); + CAddrInfo &info = mapInfo[*it]; + if (info.IsTerrible()) + { + if (--info.nRefCount == 0) + { + SwapRandom(info.nRandomPos, vRandom.size()-1); + vRandom.pop_back(); + mapAddr.erase(info); + mapInfo.erase(*it); + nNew--; + } + vNew.erase(it); + return 0; + } + } + + // otherwise, select four randomly, and pick the oldest of those to replace + int n[4] = {GetRandInt(vNew.size()), GetRandInt(vNew.size()), GetRandInt(vNew.size()), GetRandInt(vNew.size())}; + int nI = 0; + int nOldest = -1; + for (std::set::iterator it = vNew.begin(); it != vNew.end(); it++) + { + if (nI == n[0] || nI == n[1] || nI == n[2] || nI == n[3]) + { + assert(nOldest == -1 || mapInfo.count(*it) == 1); + if (nOldest == -1 || mapInfo[*it].nTime < mapInfo[nOldest].nTime) + nOldest = *it; + } + nI++; + } + assert(mapInfo.count(nOldest) == 1); + CAddrInfo &info = mapInfo[nOldest]; + if (--info.nRefCount == 0) + { + SwapRandom(info.nRandomPos, vRandom.size()-1); + vRandom.pop_back(); + mapAddr.erase(info); + mapInfo.erase(nOldest); + nNew--; + } + vNew.erase(nOldest); + + return 1; +} + +void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin) +{ + assert(vvNew[nOrigin].count(nId) == 1); + + // remove the entry from all new buckets + for (std::vector >::iterator it = vvNew.begin(); it != vvNew.end(); it++) + { + if ((*it).erase(nId)) + info.nRefCount--; + } + nNew--; + + assert(info.nRefCount == 0); + + // what tried bucket to move the entry to + int nKBucket = info.GetTriedBucket(nKey); + std::vector &vTried = vvTried[nKBucket]; + + // first check whether there is place to just add it + if (vTried.size() < ADDRMAN_TRIED_BUCKET_SIZE) + { + vTried.push_back(nId); + nTried++; + info.fInTried = true; + return; + } + + // otherwise, find an item to evict + int nPos = SelectTried(nKBucket); + + // find which new bucket it belongs to + assert(mapInfo.count(vTried[nPos]) == 1); + int nUBucket = mapInfo[vTried[nPos]].GetNewBucket(nKey); + std::set &vNew = vvNew[nUBucket]; + + // remove the to-be-replaced tried entry from the tried set + CAddrInfo& infoOld = mapInfo[vTried[nPos]]; + infoOld.fInTried = false; + infoOld.nRefCount = 1; + // do not update nTried, as we are going to move something else there immediately + + // check whether there is place in that one, + if (vNew.size() < ADDRMAN_NEW_BUCKET_SIZE) + { + // if so, move it back there + vNew.insert(vTried[nPos]); + } else { + // otherwise, move it to the new bucket nId came from (there is certainly place there) + vvNew[nOrigin].insert(vTried[nPos]); + } + nNew++; + + vTried[nPos] = nId; + // we just overwrote an entry in vTried; no need to update nTried + info.fInTried = true; + return; +} + +void CAddrMan::Good_(const CService &addr, int64_t nTime) +{ + int nId; + CAddrInfo *pinfo = Find(addr, &nId); + + // if not found, bail out + if (!pinfo) + return; + + CAddrInfo &info = *pinfo; + + // check whether we are talking about the exact same CService (including same port) + if (info != addr) + return; + + // update info + info.nLastSuccess = nTime; + info.nLastTry = nTime; + info.nTime = nTime; + info.nAttempts = 0; + + // if it is already in the tried set, don't do anything else + if (info.fInTried) + return; + + // find a bucket it is in now + int nRnd = GetRandInt(vvNew.size()); + int nUBucket = -1; + for (unsigned int n = 0; n < vvNew.size(); n++) + { + int nB = (n+nRnd) % vvNew.size(); + std::set &vNew = vvNew[nB]; + if (vNew.count(nId)) + { + nUBucket = nB; + break; + } + } + + // if no bucket is found, something bad happened; + // TODO: maybe re-add the node, but for now, just bail out + if (nUBucket == -1) return; + + LogPrint("addrman", "Moving %s to tried\n", addr.ToString()); + + // move nId to the tried tables + MakeTried(info, nId, nUBucket); +} + +bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty) +{ + if (!addr.IsRoutable()) + return false; + + bool fNew = false; + int nId; + CAddrInfo *pinfo = Find(addr, &nId); + + if (pinfo) + { + // periodically update nTime + bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60); + int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60); + if (addr.nTime && (!pinfo->nTime || pinfo->nTime < addr.nTime - nUpdateInterval - nTimePenalty)) + pinfo->nTime = max((int64_t)0, addr.nTime - nTimePenalty); + + // add services + pinfo->nServices |= addr.nServices; + + // do not update if no new information is present + if (!addr.nTime || (pinfo->nTime && addr.nTime <= pinfo->nTime)) + return false; + + // do not update if the entry was already in the "tried" table + if (pinfo->fInTried) + return false; + + // do not update if the max reference count is reached + if (pinfo->nRefCount == ADDRMAN_NEW_BUCKETS_PER_ADDRESS) + return false; + + // stochastic test: previous nRefCount == N: 2^N times harder to increase it + int nFactor = 1; + for (int n=0; nnRefCount; n++) + nFactor *= 2; + if (nFactor > 1 && (GetRandInt(nFactor) != 0)) + return false; + } else { + pinfo = Create(addr, source, &nId); + pinfo->nTime = max((int64_t)0, (int64_t)pinfo->nTime - nTimePenalty); + nNew++; + fNew = true; + } + + int nUBucket = pinfo->GetNewBucket(nKey, source); + std::set &vNew = vvNew[nUBucket]; + if (!vNew.count(nId)) + { + pinfo->nRefCount++; + if (vNew.size() == ADDRMAN_NEW_BUCKET_SIZE) + ShrinkNew(nUBucket); + vvNew[nUBucket].insert(nId); + } + return fNew; +} + +void CAddrMan::Attempt_(const CService &addr, int64_t nTime) +{ + CAddrInfo *pinfo = Find(addr); + + // if not found, bail out + if (!pinfo) + return; + + CAddrInfo &info = *pinfo; + + // check whether we are talking about the exact same CService (including same port) + if (info != addr) + return; + + // update info + info.nLastTry = nTime; + info.nAttempts++; +} + +CAddress CAddrMan::Select_(int nUnkBias) +{ + if (size() == 0) + return CAddress(); + + double nCorTried = sqrt(nTried) * (100.0 - nUnkBias); + double nCorNew = sqrt(nNew) * nUnkBias; + if ((nCorTried + nCorNew)*GetRandInt(1<<30)/(1<<30) < nCorTried) + { + // use a tried node + double fChanceFactor = 1.0; + while(1) + { + int nKBucket = GetRandInt(vvTried.size()); + std::vector &vTried = vvTried[nKBucket]; + if (vTried.size() == 0) continue; + int nPos = GetRandInt(vTried.size()); + assert(mapInfo.count(vTried[nPos]) == 1); + CAddrInfo &info = mapInfo[vTried[nPos]]; + if (GetRandInt(1<<30) < fChanceFactor*info.GetChance()*(1<<30)) + return info; + fChanceFactor *= 1.2; + } + } else { + // use a new node + double fChanceFactor = 1.0; + while(1) + { + int nUBucket = GetRandInt(vvNew.size()); + std::set &vNew = vvNew[nUBucket]; + if (vNew.size() == 0) continue; + int nPos = GetRandInt(vNew.size()); + std::set::iterator it = vNew.begin(); + while (nPos--) + it++; + assert(mapInfo.count(*it) == 1); + CAddrInfo &info = mapInfo[*it]; + if (GetRandInt(1<<30) < fChanceFactor*info.GetChance()*(1<<30)) + return info; + fChanceFactor *= 1.2; + } + } +} + +#ifdef DEBUG_ADDRMAN +int CAddrMan::Check_() +{ + std::set setTried; + std::map mapNew; + + if (vRandom.size() != nTried + nNew) return -7; + + for (std::map::iterator it = mapInfo.begin(); it != mapInfo.end(); it++) + { + int n = (*it).first; + CAddrInfo &info = (*it).second; + if (info.fInTried) + { + + if (!info.nLastSuccess) return -1; + if (info.nRefCount) return -2; + setTried.insert(n); + } else { + if (info.nRefCount < 0 || info.nRefCount > ADDRMAN_NEW_BUCKETS_PER_ADDRESS) return -3; + if (!info.nRefCount) return -4; + mapNew[n] = info.nRefCount; + } + if (mapAddr[info] != n) return -5; + if (info.nRandomPos<0 || info.nRandomPos>=vRandom.size() || vRandom[info.nRandomPos] != n) return -14; + if (info.nLastTry < 0) return -6; + if (info.nLastSuccess < 0) return -8; + } + + if (setTried.size() != nTried) return -9; + if (mapNew.size() != nNew) return -10; + + for (int n=0; n &vTried = vvTried[n]; + for (std::vector::iterator it = vTried.begin(); it != vTried.end(); it++) + { + if (!setTried.count(*it)) return -11; + setTried.erase(*it); + } + } + + for (int n=0; n &vNew = vvNew[n]; + for (std::set::iterator it = vNew.begin(); it != vNew.end(); it++) + { + if (!mapNew.count(*it)) return -12; + if (--mapNew[*it] == 0) + mapNew.erase(*it); + } + } + + if (setTried.size()) return -13; + if (mapNew.size()) return -15; + + return 0; +} +#endif + +void CAddrMan::GetAddr_(std::vector &vAddr) +{ + unsigned int nNodes = ADDRMAN_GETADDR_MAX_PCT * vRandom.size() / 100; + if (nNodes > ADDRMAN_GETADDR_MAX) + nNodes = ADDRMAN_GETADDR_MAX; + + // gather a list of random nodes, skipping those of low quality + for (unsigned int n = 0; n < vRandom.size(); n++) + { + if (vAddr.size() >= nNodes) + break; + + int nRndPos = GetRandInt(vRandom.size() - n) + n; + SwapRandom(n, nRndPos); + assert(mapInfo.count(vRandom[n]) == 1); + + const CAddrInfo& ai = mapInfo[vRandom[n]]; + if (!ai.IsTerrible()) + vAddr.push_back(ai); + } +} + +void CAddrMan::Connected_(const CService &addr, int64_t nTime) +{ + CAddrInfo *pinfo = Find(addr); + + // if not found, bail out + if (!pinfo) + return; + + CAddrInfo &info = *pinfo; + + // check whether we are talking about the exact same CService (including same port) + if (info != addr) + return; + + // update info + int64_t nUpdateInterval = 20 * 60; + if (nTime - info.nTime > nUpdateInterval) + info.nTime = nTime; +} diff --git a/src/addrman.h b/src/addrman.h new file mode 100644 index 0000000..74e200b --- /dev/null +++ b/src/addrman.h @@ -0,0 +1,505 @@ +// Copyright (c) 2012 Pieter Wuille +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef _BITCOIN_ADDRMAN +#define _BITCOIN_ADDRMAN 1 + +#include "netbase.h" +#include "protocol.h" +#include "sync.h" +#include "timedata.h" +#include "util.h" + +#include +#include + +#include + + +/** Extended statistics about a CAddress */ +class CAddrInfo : public CAddress +{ +private: + // where knowledge about this address first came from + CNetAddr source; + + // last successful connection by us + int64_t nLastSuccess; + + // last try whatsoever by us: + // int64_t CAddress::nLastTry + + // connection attempts since last successful attempt + int nAttempts; + + // reference count in new sets (memory only) + int nRefCount; + + // in tried set? (memory only) + bool fInTried; + + // position in vRandom + int nRandomPos; + + friend class CAddrMan; + +public: + + IMPLEMENT_SERIALIZE( + CAddress* pthis = (CAddress*)(this); + READWRITE(*pthis); + READWRITE(source); + READWRITE(nLastSuccess); + READWRITE(nAttempts); + ) + + void Init() + { + nLastSuccess = 0; + nLastTry = 0; + nAttempts = 0; + nRefCount = 0; + fInTried = false; + nRandomPos = -1; + } + + CAddrInfo(const CAddress &addrIn, const CNetAddr &addrSource) : CAddress(addrIn), source(addrSource) + { + Init(); + } + + CAddrInfo() : CAddress(), source() + { + Init(); + } + + // Calculate in which "tried" bucket this entry belongs + int GetTriedBucket(const std::vector &nKey) const; + + // Calculate in which "new" bucket this entry belongs, given a certain source + int GetNewBucket(const std::vector &nKey, const CNetAddr& src) const; + + // Calculate in which "new" bucket this entry belongs, using its default source + int GetNewBucket(const std::vector &nKey) const + { + return GetNewBucket(nKey, source); + } + + // Determine whether the statistics about this entry are bad enough so that it can just be deleted + bool IsTerrible(int64_t nNow = GetAdjustedTime()) const; + + // Calculate the relative chance this entry should be given when selecting nodes to connect to + double GetChance(int64_t nNow = GetAdjustedTime()) const; + +}; + +// Stochastic address manager +// +// Design goals: +// * Only keep a limited number of addresses around, so that addr.dat and memory requirements do not grow without bound. +// * Keep the address tables in-memory, and asynchronously dump the entire to able in addr.dat. +// * Make sure no (localized) attacker can fill the entire table with his nodes/addresses. +// +// To that end: +// * Addresses are organized into buckets. +// * Address that have not yet been tried go into 256 "new" buckets. +// * Based on the address range (/16 for IPv4) of source of the information, 32 buckets are selected at random +// * The actual bucket is chosen from one of these, based on the range the address itself is located. +// * One single address can occur in up to 4 different buckets, to increase selection chances for addresses that +// are seen frequently. The chance for increasing this multiplicity decreases exponentially. +// * When adding a new address to a full bucket, a randomly chosen entry (with a bias favoring less recently seen +// ones) is removed from it first. +// * Addresses of nodes that are known to be accessible go into 64 "tried" buckets. +// * Each address range selects at random 4 of these buckets. +// * The actual bucket is chosen from one of these, based on the full address. +// * When adding a new good address to a full bucket, a randomly chosen entry (with a bias favoring less recently +// tried ones) is evicted from it, back to the "new" buckets. +// * Bucket selection is based on cryptographic hashing, using a randomly-generated 256-bit key, which should not +// be observable by adversaries. +// * Several indexes are kept for high performance. Defining DEBUG_ADDRMAN will introduce frequent (and expensive) +// consistency checks for the entire data structure. + +// total number of buckets for tried addresses +#define ADDRMAN_TRIED_BUCKET_COUNT 64 + +// maximum allowed number of entries in buckets for tried addresses +#define ADDRMAN_TRIED_BUCKET_SIZE 64 + +// total number of buckets for new addresses +#define ADDRMAN_NEW_BUCKET_COUNT 256 + +// maximum allowed number of entries in buckets for new addresses +#define ADDRMAN_NEW_BUCKET_SIZE 64 + +// over how many buckets entries with tried addresses from a single group (/16 for IPv4) are spread +#define ADDRMAN_TRIED_BUCKETS_PER_GROUP 4 + +// over how many buckets entries with new addresses originating from a single group are spread +#define ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP 32 + +// in how many buckets for entries with new addresses a single address may occur +#define ADDRMAN_NEW_BUCKETS_PER_ADDRESS 4 + +// how many entries in a bucket with tried addresses are inspected, when selecting one to replace +#define ADDRMAN_TRIED_ENTRIES_INSPECT_ON_EVICT 4 + +// how old addresses can maximally be +#define ADDRMAN_HORIZON_DAYS 30 + +// after how many failed attempts we give up on a new node +#define ADDRMAN_RETRIES 3 + +// how many successive failures are allowed ... +#define ADDRMAN_MAX_FAILURES 10 + +// ... in at least this many days +#define ADDRMAN_MIN_FAIL_DAYS 7 + +// the maximum percentage of nodes to return in a getaddr call +#define ADDRMAN_GETADDR_MAX_PCT 23 + +// the maximum number of nodes to return in a getaddr call +#define ADDRMAN_GETADDR_MAX 2500 + +/** Stochastical (IP) address manager */ +class CAddrMan +{ +private: + // critical section to protect the inner data structures + mutable CCriticalSection cs; + + // secret key to randomize bucket select with + std::vector nKey; + + // last used nId + int nIdCount; + + // table with information about all nIds + std::map mapInfo; + + // find an nId based on its network address + std::map mapAddr; + + // randomly-ordered vector of all nIds + std::vector vRandom; + + // number of "tried" entries + int nTried; + + // list of "tried" buckets + std::vector > vvTried; + + // number of (unique) "new" entries + int nNew; + + // list of "new" buckets + std::vector > vvNew; + +protected: + + // Find an entry. + CAddrInfo* Find(const CNetAddr& addr, int *pnId = NULL); + + // find an entry, creating it if necessary. + // nTime and nServices of found node is updated, if necessary. + CAddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = NULL); + + // Swap two elements in vRandom. + void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2); + + // Return position in given bucket to replace. + int SelectTried(int nKBucket); + + // Remove an element from a "new" bucket. + // This is the only place where actual deletes occur. + // They are never deleted while in the "tried" table, only possibly evicted back to the "new" table. + int ShrinkNew(int nUBucket); + + // Move an entry from the "new" table(s) to the "tried" table + // @pre vvUnkown[nOrigin].count(nId) != 0 + void MakeTried(CAddrInfo& info, int nId, int nOrigin); + + // Mark an entry "good", possibly moving it from "new" to "tried". + void Good_(const CService &addr, int64_t nTime); + + // Add an entry to the "new" table. + bool Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty); + + // Mark an entry as attempted to connect. + void Attempt_(const CService &addr, int64_t nTime); + + // Select an address to connect to. + // nUnkBias determines how much to favor new addresses over tried ones (min=0, max=100) + CAddress Select_(int nUnkBias); + +#ifdef DEBUG_ADDRMAN + // Perform consistency check. Returns an error code or zero. + int Check_(); +#endif + + // Select several addresses at once. + void GetAddr_(std::vector &vAddr); + + // Mark an entry as currently-connected-to. + void Connected_(const CService &addr, int64_t nTime); + +public: + // serialized format: + // * version byte (currently 0) + // * nKey + // * nNew + // * nTried + // * number of "new" buckets + // * all nNew addrinfos in vvNew + // * all nTried addrinfos in vvTried + // * for each bucket: + // * number of elements + // * for each element: index + // + // Notice that vvTried, mapAddr and vVector are never encoded explicitly; + // they are instead reconstructed from the other information. + // + // vvNew is serialized, but only used if ADDRMAN_UNKOWN_BUCKET_COUNT didn't change, + // otherwise it is reconstructed as well. + // + // This format is more complex, but significantly smaller (at most 1.5 MiB), and supports + // changes to the ADDRMAN_ parameters without breaking the on-disk structure. + // + // We don't use IMPLEMENT_SERIALIZE since the serialization and deserialization code has + // very little in common. + template + void Serialize(Stream &s, int nType, int nVersionDummy) const + { + LOCK(cs); + + unsigned char nVersion = 0; + s << nVersion; + s << nKey; + s << nNew; + s << nTried; + + int nUBuckets = ADDRMAN_NEW_BUCKET_COUNT; + s << nUBuckets; + std::map mapUnkIds; + int nIds = 0; + for (std::map::const_iterator it = mapInfo.begin(); it != mapInfo.end(); it++) { + if (nIds == nNew) break; // this means nNew was wrong, oh ow + mapUnkIds[(*it).first] = nIds; + const CAddrInfo &info = (*it).second; + if (info.nRefCount) { + s << info; + nIds++; + } + } + nIds = 0; + for (std::map::const_iterator it = mapInfo.begin(); it != mapInfo.end(); it++) { + if (nIds == nTried) break; // this means nTried was wrong, oh ow + const CAddrInfo &info = (*it).second; + if (info.fInTried) { + s << info; + nIds++; + } + } + for (std::vector >::const_iterator it = vvNew.begin(); it != vvNew.end(); it++) { + const std::set &vNew = (*it); + int nSize = vNew.size(); + s << nSize; + for (std::set::const_iterator it2 = vNew.begin(); it2 != vNew.end(); it2++) { + int nIndex = mapUnkIds[*it2]; + s << nIndex; + } + } + } + + template + void Unserialize(Stream& s, int nType, int nVersionDummy) + { + LOCK(cs); + + unsigned char nVersion; + s >> nVersion; + s >> nKey; + s >> nNew; + s >> nTried; + + int nUBuckets = 0; + s >> nUBuckets; + nIdCount = 0; + mapInfo.clear(); + mapAddr.clear(); + vRandom.clear(); + vvTried = std::vector >(ADDRMAN_TRIED_BUCKET_COUNT, std::vector(0)); + vvNew = std::vector >(ADDRMAN_NEW_BUCKET_COUNT, std::set()); + for (int n = 0; n < nNew; n++) { + CAddrInfo &info = mapInfo[n]; + s >> info; + mapAddr[info] = n; + info.nRandomPos = vRandom.size(); + vRandom.push_back(n); + if (nUBuckets != ADDRMAN_NEW_BUCKET_COUNT) { + vvNew[info.GetNewBucket(nKey)].insert(n); + info.nRefCount++; + } + } + nIdCount = nNew; + int nLost = 0; + for (int n = 0; n < nTried; n++) { + CAddrInfo info; + s >> info; + std::vector &vTried = vvTried[info.GetTriedBucket(nKey)]; + if (vTried.size() < ADDRMAN_TRIED_BUCKET_SIZE) { + info.nRandomPos = vRandom.size(); + info.fInTried = true; + vRandom.push_back(nIdCount); + mapInfo[nIdCount] = info; + mapAddr[info] = nIdCount; + vTried.push_back(nIdCount); + nIdCount++; + } else { + nLost++; + } + } + nTried -= nLost; + for (int b = 0; b < nUBuckets; b++) { + std::set &vNew = vvNew[b]; + int nSize = 0; + s >> nSize; + for (int n = 0; n < nSize; n++) { + int nIndex = 0; + s >> nIndex; + CAddrInfo &info = mapInfo[nIndex]; + if (nUBuckets == ADDRMAN_NEW_BUCKET_COUNT && info.nRefCount < ADDRMAN_NEW_BUCKETS_PER_ADDRESS) { + info.nRefCount++; + vNew.insert(nIndex); + } + } + } + } + + unsigned int GetSerializeSize(int nType, int nVersion) const + { + return (CSizeComputer(nType, nVersion) << *this).size(); + } + + CAddrMan() : vRandom(0), vvTried(ADDRMAN_TRIED_BUCKET_COUNT, std::vector(0)), vvNew(ADDRMAN_NEW_BUCKET_COUNT, std::set()) + { + nKey.resize(32); + RAND_bytes(&nKey[0], 32); + + nIdCount = 0; + nTried = 0; + nNew = 0; + } + + // Return the number of (unique) addresses in all tables. + int size() + { + return vRandom.size(); + } + + // Consistency check + void Check() + { +#ifdef DEBUG_ADDRMAN + { + LOCK(cs); + int err; + if ((err=Check_())) + LogPrintf("ADDRMAN CONSISTENCY CHECK FAILED!!! err=%i\n", err); + } +#endif + } + + // Add a single address. + bool Add(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty = 0) + { + bool fRet = false; + { + LOCK(cs); + Check(); + fRet |= Add_(addr, source, nTimePenalty); + Check(); + } + if (fRet) + LogPrint("addrman", "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort(), source.ToString(), nTried, nNew); + return fRet; + } + + // Add multiple addresses. + bool Add(const std::vector &vAddr, const CNetAddr& source, int64_t nTimePenalty = 0) + { + int nAdd = 0; + { + LOCK(cs); + Check(); + for (std::vector::const_iterator it = vAddr.begin(); it != vAddr.end(); it++) + nAdd += Add_(*it, source, nTimePenalty) ? 1 : 0; + Check(); + } + if (nAdd) + LogPrint("addrman", "Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString(), nTried, nNew); + return nAdd > 0; + } + + // Mark an entry as accessible. + void Good(const CService &addr, int64_t nTime = GetAdjustedTime()) + { + { + LOCK(cs); + Check(); + Good_(addr, nTime); + Check(); + } + } + + // Mark an entry as connection attempted to. + void Attempt(const CService &addr, int64_t nTime = GetAdjustedTime()) + { + { + LOCK(cs); + Check(); + Attempt_(addr, nTime); + Check(); + } + } + + // Choose an address to connect to. + // nUnkBias determines how much "new" entries are favored over "tried" ones (0-100). + CAddress Select(int nUnkBias = 50) + { + CAddress addrRet; + { + LOCK(cs); + Check(); + addrRet = Select_(nUnkBias); + Check(); + } + return addrRet; + } + + // Return a bunch of addresses, selected at random. + std::vector GetAddr() + { + Check(); + std::vector vAddr; + { + LOCK(cs); + GetAddr_(vAddr); + } + Check(); + return vAddr; + } + + // Mark an entry as currently-connected-to. + void Connected(const CService &addr, int64_t nTime = GetAdjustedTime()) + { + { + LOCK(cs); + Check(); + Connected_(addr, nTime); + Check(); + } + } +}; + +#endif diff --git a/src/aes_helper.c b/src/aes_helper.c new file mode 100644 index 0000000..75b7cc6 --- /dev/null +++ b/src/aes_helper.c @@ -0,0 +1,392 @@ +/* $Id: aes_helper.c 220 2010-06-09 09:21:50Z tp $ */ +/* + * AES tables. This file is not meant to be compiled by itself; it + * is included by some hash function implementations. It contains + * the precomputed tables and helper macros for evaluating an AES + * round, optionally with a final XOR with a subkey. + * + * By default, this file defines the tables and macros for little-endian + * processing (i.e. it is assumed that the input bytes have been read + * from memory and assembled with the little-endian convention). If + * the 'AES_BIG_ENDIAN' macro is defined (to a non-zero integer value) + * when this file is included, then the tables and macros for big-endian + * processing are defined instead. The big-endian tables and macros have + * names distinct from the little-endian tables and macros, hence it is + * possible to have both simultaneously, by including this file twice + * (with and without the AES_BIG_ENDIAN macro). + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @author Thomas Pornin + */ + +#include "sph_types.h" +#ifdef __cplusplus +extern "C"{ +#endif +#if AES_BIG_ENDIAN + +#define AESx(x) ( ((SPH_C32(x) >> 24) & SPH_C32(0x000000FF)) \ + | ((SPH_C32(x) >> 8) & SPH_C32(0x0000FF00)) \ + | ((SPH_C32(x) << 8) & SPH_C32(0x00FF0000)) \ + | ((SPH_C32(x) << 24) & SPH_C32(0xFF000000))) + +#define AES0 AES0_BE +#define AES1 AES1_BE +#define AES2 AES2_BE +#define AES3 AES3_BE + +#define AES_ROUND_BE(X0, X1, X2, X3, K0, K1, K2, K3, Y0, Y1, Y2, Y3) do { \ + (Y0) = AES0[((X0) >> 24) & 0xFF] \ + ^ AES1[((X1) >> 16) & 0xFF] \ + ^ AES2[((X2) >> 8) & 0xFF] \ + ^ AES3[(X3) & 0xFF] ^ (K0); \ + (Y1) = AES0[((X1) >> 24) & 0xFF] \ + ^ AES1[((X2) >> 16) & 0xFF] \ + ^ AES2[((X3) >> 8) & 0xFF] \ + ^ AES3[(X0) & 0xFF] ^ (K1); \ + (Y2) = AES0[((X2) >> 24) & 0xFF] \ + ^ AES1[((X3) >> 16) & 0xFF] \ + ^ AES2[((X0) >> 8) & 0xFF] \ + ^ AES3[(X1) & 0xFF] ^ (K2); \ + (Y3) = AES0[((X3) >> 24) & 0xFF] \ + ^ AES1[((X0) >> 16) & 0xFF] \ + ^ AES2[((X1) >> 8) & 0xFF] \ + ^ AES3[(X2) & 0xFF] ^ (K3); \ + } while (0) + +#define AES_ROUND_NOKEY_BE(X0, X1, X2, X3, Y0, Y1, Y2, Y3) \ + AES_ROUND_BE(X0, X1, X2, X3, 0, 0, 0, 0, Y0, Y1, Y2, Y3) + +#else + +#define AESx(x) SPH_C32(x) +#define AES0 AES0_LE +#define AES1 AES1_LE +#define AES2 AES2_LE +#define AES3 AES3_LE + +#define AES_ROUND_LE(X0, X1, X2, X3, K0, K1, K2, K3, Y0, Y1, Y2, Y3) do { \ + (Y0) = AES0[(X0) & 0xFF] \ + ^ AES1[((X1) >> 8) & 0xFF] \ + ^ AES2[((X2) >> 16) & 0xFF] \ + ^ AES3[((X3) >> 24) & 0xFF] ^ (K0); \ + (Y1) = AES0[(X1) & 0xFF] \ + ^ AES1[((X2) >> 8) & 0xFF] \ + ^ AES2[((X3) >> 16) & 0xFF] \ + ^ AES3[((X0) >> 24) & 0xFF] ^ (K1); \ + (Y2) = AES0[(X2) & 0xFF] \ + ^ AES1[((X3) >> 8) & 0xFF] \ + ^ AES2[((X0) >> 16) & 0xFF] \ + ^ AES3[((X1) >> 24) & 0xFF] ^ (K2); \ + (Y3) = AES0[(X3) & 0xFF] \ + ^ AES1[((X0) >> 8) & 0xFF] \ + ^ AES2[((X1) >> 16) & 0xFF] \ + ^ AES3[((X2) >> 24) & 0xFF] ^ (K3); \ + } while (0) + +#define AES_ROUND_NOKEY_LE(X0, X1, X2, X3, Y0, Y1, Y2, Y3) \ + AES_ROUND_LE(X0, X1, X2, X3, 0, 0, 0, 0, Y0, Y1, Y2, Y3) + +#endif + +/* + * The AES*[] tables allow us to perform a fast evaluation of an AES + * round; table AESi[] combines SubBytes for a byte at row i, and + * MixColumns for the column where that byte goes after ShiftRows. + */ + +static const sph_u32 AES0[256] = { + AESx(0xA56363C6), AESx(0x847C7CF8), AESx(0x997777EE), AESx(0x8D7B7BF6), + AESx(0x0DF2F2FF), AESx(0xBD6B6BD6), AESx(0xB16F6FDE), AESx(0x54C5C591), + AESx(0x50303060), AESx(0x03010102), AESx(0xA96767CE), AESx(0x7D2B2B56), + AESx(0x19FEFEE7), AESx(0x62D7D7B5), AESx(0xE6ABAB4D), AESx(0x9A7676EC), + AESx(0x45CACA8F), AESx(0x9D82821F), AESx(0x40C9C989), AESx(0x877D7DFA), + AESx(0x15FAFAEF), AESx(0xEB5959B2), AESx(0xC947478E), AESx(0x0BF0F0FB), + AESx(0xECADAD41), AESx(0x67D4D4B3), AESx(0xFDA2A25F), AESx(0xEAAFAF45), + AESx(0xBF9C9C23), AESx(0xF7A4A453), AESx(0x967272E4), AESx(0x5BC0C09B), + AESx(0xC2B7B775), AESx(0x1CFDFDE1), AESx(0xAE93933D), AESx(0x6A26264C), + AESx(0x5A36366C), AESx(0x413F3F7E), AESx(0x02F7F7F5), AESx(0x4FCCCC83), + AESx(0x5C343468), AESx(0xF4A5A551), AESx(0x34E5E5D1), AESx(0x08F1F1F9), + AESx(0x937171E2), AESx(0x73D8D8AB), AESx(0x53313162), AESx(0x3F15152A), + AESx(0x0C040408), AESx(0x52C7C795), AESx(0x65232346), AESx(0x5EC3C39D), + AESx(0x28181830), AESx(0xA1969637), AESx(0x0F05050A), AESx(0xB59A9A2F), + AESx(0x0907070E), AESx(0x36121224), AESx(0x9B80801B), AESx(0x3DE2E2DF), + AESx(0x26EBEBCD), AESx(0x6927274E), AESx(0xCDB2B27F), AESx(0x9F7575EA), + AESx(0x1B090912), AESx(0x9E83831D), AESx(0x742C2C58), AESx(0x2E1A1A34), + AESx(0x2D1B1B36), AESx(0xB26E6EDC), AESx(0xEE5A5AB4), AESx(0xFBA0A05B), + AESx(0xF65252A4), AESx(0x4D3B3B76), AESx(0x61D6D6B7), AESx(0xCEB3B37D), + AESx(0x7B292952), AESx(0x3EE3E3DD), AESx(0x712F2F5E), AESx(0x97848413), + AESx(0xF55353A6), AESx(0x68D1D1B9), AESx(0x00000000), AESx(0x2CEDEDC1), + AESx(0x60202040), AESx(0x1FFCFCE3), AESx(0xC8B1B179), AESx(0xED5B5BB6), + AESx(0xBE6A6AD4), AESx(0x46CBCB8D), AESx(0xD9BEBE67), AESx(0x4B393972), + AESx(0xDE4A4A94), AESx(0xD44C4C98), AESx(0xE85858B0), AESx(0x4ACFCF85), + AESx(0x6BD0D0BB), AESx(0x2AEFEFC5), AESx(0xE5AAAA4F), AESx(0x16FBFBED), + AESx(0xC5434386), AESx(0xD74D4D9A), AESx(0x55333366), AESx(0x94858511), + AESx(0xCF45458A), AESx(0x10F9F9E9), AESx(0x06020204), AESx(0x817F7FFE), + AESx(0xF05050A0), AESx(0x443C3C78), AESx(0xBA9F9F25), AESx(0xE3A8A84B), + AESx(0xF35151A2), AESx(0xFEA3A35D), AESx(0xC0404080), AESx(0x8A8F8F05), + AESx(0xAD92923F), AESx(0xBC9D9D21), AESx(0x48383870), AESx(0x04F5F5F1), + AESx(0xDFBCBC63), AESx(0xC1B6B677), AESx(0x75DADAAF), AESx(0x63212142), + AESx(0x30101020), AESx(0x1AFFFFE5), AESx(0x0EF3F3FD), AESx(0x6DD2D2BF), + AESx(0x4CCDCD81), AESx(0x140C0C18), AESx(0x35131326), AESx(0x2FECECC3), + AESx(0xE15F5FBE), AESx(0xA2979735), AESx(0xCC444488), AESx(0x3917172E), + AESx(0x57C4C493), AESx(0xF2A7A755), AESx(0x827E7EFC), AESx(0x473D3D7A), + AESx(0xAC6464C8), AESx(0xE75D5DBA), AESx(0x2B191932), AESx(0x957373E6), + AESx(0xA06060C0), AESx(0x98818119), AESx(0xD14F4F9E), AESx(0x7FDCDCA3), + AESx(0x66222244), AESx(0x7E2A2A54), AESx(0xAB90903B), AESx(0x8388880B), + AESx(0xCA46468C), AESx(0x29EEEEC7), AESx(0xD3B8B86B), AESx(0x3C141428), + AESx(0x79DEDEA7), AESx(0xE25E5EBC), AESx(0x1D0B0B16), AESx(0x76DBDBAD), + AESx(0x3BE0E0DB), AESx(0x56323264), AESx(0x4E3A3A74), AESx(0x1E0A0A14), + AESx(0xDB494992), AESx(0x0A06060C), AESx(0x6C242448), AESx(0xE45C5CB8), + AESx(0x5DC2C29F), AESx(0x6ED3D3BD), AESx(0xEFACAC43), AESx(0xA66262C4), + AESx(0xA8919139), AESx(0xA4959531), AESx(0x37E4E4D3), AESx(0x8B7979F2), + AESx(0x32E7E7D5), AESx(0x43C8C88B), AESx(0x5937376E), AESx(0xB76D6DDA), + AESx(0x8C8D8D01), AESx(0x64D5D5B1), AESx(0xD24E4E9C), AESx(0xE0A9A949), + AESx(0xB46C6CD8), AESx(0xFA5656AC), AESx(0x07F4F4F3), AESx(0x25EAEACF), + AESx(0xAF6565CA), AESx(0x8E7A7AF4), AESx(0xE9AEAE47), AESx(0x18080810), + AESx(0xD5BABA6F), AESx(0x887878F0), AESx(0x6F25254A), AESx(0x722E2E5C), + AESx(0x241C1C38), AESx(0xF1A6A657), AESx(0xC7B4B473), AESx(0x51C6C697), + AESx(0x23E8E8CB), AESx(0x7CDDDDA1), AESx(0x9C7474E8), AESx(0x211F1F3E), + AESx(0xDD4B4B96), AESx(0xDCBDBD61), AESx(0x868B8B0D), AESx(0x858A8A0F), + AESx(0x907070E0), AESx(0x423E3E7C), AESx(0xC4B5B571), AESx(0xAA6666CC), + AESx(0xD8484890), AESx(0x05030306), AESx(0x01F6F6F7), AESx(0x120E0E1C), + AESx(0xA36161C2), AESx(0x5F35356A), AESx(0xF95757AE), AESx(0xD0B9B969), + AESx(0x91868617), AESx(0x58C1C199), AESx(0x271D1D3A), AESx(0xB99E9E27), + AESx(0x38E1E1D9), AESx(0x13F8F8EB), AESx(0xB398982B), AESx(0x33111122), + AESx(0xBB6969D2), AESx(0x70D9D9A9), AESx(0x898E8E07), AESx(0xA7949433), + AESx(0xB69B9B2D), AESx(0x221E1E3C), AESx(0x92878715), AESx(0x20E9E9C9), + AESx(0x49CECE87), AESx(0xFF5555AA), AESx(0x78282850), AESx(0x7ADFDFA5), + AESx(0x8F8C8C03), AESx(0xF8A1A159), AESx(0x80898909), AESx(0x170D0D1A), + AESx(0xDABFBF65), AESx(0x31E6E6D7), AESx(0xC6424284), AESx(0xB86868D0), + AESx(0xC3414182), AESx(0xB0999929), AESx(0x772D2D5A), AESx(0x110F0F1E), + AESx(0xCBB0B07B), AESx(0xFC5454A8), AESx(0xD6BBBB6D), AESx(0x3A16162C) +}; + +static const sph_u32 AES1[256] = { + AESx(0x6363C6A5), AESx(0x7C7CF884), AESx(0x7777EE99), AESx(0x7B7BF68D), + AESx(0xF2F2FF0D), AESx(0x6B6BD6BD), AESx(0x6F6FDEB1), AESx(0xC5C59154), + AESx(0x30306050), AESx(0x01010203), AESx(0x6767CEA9), AESx(0x2B2B567D), + AESx(0xFEFEE719), AESx(0xD7D7B562), AESx(0xABAB4DE6), AESx(0x7676EC9A), + AESx(0xCACA8F45), AESx(0x82821F9D), AESx(0xC9C98940), AESx(0x7D7DFA87), + AESx(0xFAFAEF15), AESx(0x5959B2EB), AESx(0x47478EC9), AESx(0xF0F0FB0B), + AESx(0xADAD41EC), AESx(0xD4D4B367), AESx(0xA2A25FFD), AESx(0xAFAF45EA), + AESx(0x9C9C23BF), AESx(0xA4A453F7), AESx(0x7272E496), AESx(0xC0C09B5B), + AESx(0xB7B775C2), AESx(0xFDFDE11C), AESx(0x93933DAE), AESx(0x26264C6A), + AESx(0x36366C5A), AESx(0x3F3F7E41), AESx(0xF7F7F502), AESx(0xCCCC834F), + AESx(0x3434685C), AESx(0xA5A551F4), AESx(0xE5E5D134), AESx(0xF1F1F908), + AESx(0x7171E293), AESx(0xD8D8AB73), AESx(0x31316253), AESx(0x15152A3F), + AESx(0x0404080C), AESx(0xC7C79552), AESx(0x23234665), AESx(0xC3C39D5E), + AESx(0x18183028), AESx(0x969637A1), AESx(0x05050A0F), AESx(0x9A9A2FB5), + AESx(0x07070E09), AESx(0x12122436), AESx(0x80801B9B), AESx(0xE2E2DF3D), + AESx(0xEBEBCD26), AESx(0x27274E69), AESx(0xB2B27FCD), AESx(0x7575EA9F), + AESx(0x0909121B), AESx(0x83831D9E), AESx(0x2C2C5874), AESx(0x1A1A342E), + AESx(0x1B1B362D), AESx(0x6E6EDCB2), AESx(0x5A5AB4EE), AESx(0xA0A05BFB), + AESx(0x5252A4F6), AESx(0x3B3B764D), AESx(0xD6D6B761), AESx(0xB3B37DCE), + AESx(0x2929527B), AESx(0xE3E3DD3E), AESx(0x2F2F5E71), AESx(0x84841397), + AESx(0x5353A6F5), AESx(0xD1D1B968), AESx(0x00000000), AESx(0xEDEDC12C), + AESx(0x20204060), AESx(0xFCFCE31F), AESx(0xB1B179C8), AESx(0x5B5BB6ED), + AESx(0x6A6AD4BE), AESx(0xCBCB8D46), AESx(0xBEBE67D9), AESx(0x3939724B), + AESx(0x4A4A94DE), AESx(0x4C4C98D4), AESx(0x5858B0E8), AESx(0xCFCF854A), + AESx(0xD0D0BB6B), AESx(0xEFEFC52A), AESx(0xAAAA4FE5), AESx(0xFBFBED16), + AESx(0x434386C5), AESx(0x4D4D9AD7), AESx(0x33336655), AESx(0x85851194), + AESx(0x45458ACF), AESx(0xF9F9E910), AESx(0x02020406), AESx(0x7F7FFE81), + AESx(0x5050A0F0), AESx(0x3C3C7844), AESx(0x9F9F25BA), AESx(0xA8A84BE3), + AESx(0x5151A2F3), AESx(0xA3A35DFE), AESx(0x404080C0), AESx(0x8F8F058A), + AESx(0x92923FAD), AESx(0x9D9D21BC), AESx(0x38387048), AESx(0xF5F5F104), + AESx(0xBCBC63DF), AESx(0xB6B677C1), AESx(0xDADAAF75), AESx(0x21214263), + AESx(0x10102030), AESx(0xFFFFE51A), AESx(0xF3F3FD0E), AESx(0xD2D2BF6D), + AESx(0xCDCD814C), AESx(0x0C0C1814), AESx(0x13132635), AESx(0xECECC32F), + AESx(0x5F5FBEE1), AESx(0x979735A2), AESx(0x444488CC), AESx(0x17172E39), + AESx(0xC4C49357), AESx(0xA7A755F2), AESx(0x7E7EFC82), AESx(0x3D3D7A47), + AESx(0x6464C8AC), AESx(0x5D5DBAE7), AESx(0x1919322B), AESx(0x7373E695), + AESx(0x6060C0A0), AESx(0x81811998), AESx(0x4F4F9ED1), AESx(0xDCDCA37F), + AESx(0x22224466), AESx(0x2A2A547E), AESx(0x90903BAB), AESx(0x88880B83), + AESx(0x46468CCA), AESx(0xEEEEC729), AESx(0xB8B86BD3), AESx(0x1414283C), + AESx(0xDEDEA779), AESx(0x5E5EBCE2), AESx(0x0B0B161D), AESx(0xDBDBAD76), + AESx(0xE0E0DB3B), AESx(0x32326456), AESx(0x3A3A744E), AESx(0x0A0A141E), + AESx(0x494992DB), AESx(0x06060C0A), AESx(0x2424486C), AESx(0x5C5CB8E4), + AESx(0xC2C29F5D), AESx(0xD3D3BD6E), AESx(0xACAC43EF), AESx(0x6262C4A6), + AESx(0x919139A8), AESx(0x959531A4), AESx(0xE4E4D337), AESx(0x7979F28B), + AESx(0xE7E7D532), AESx(0xC8C88B43), AESx(0x37376E59), AESx(0x6D6DDAB7), + AESx(0x8D8D018C), AESx(0xD5D5B164), AESx(0x4E4E9CD2), AESx(0xA9A949E0), + AESx(0x6C6CD8B4), AESx(0x5656ACFA), AESx(0xF4F4F307), AESx(0xEAEACF25), + AESx(0x6565CAAF), AESx(0x7A7AF48E), AESx(0xAEAE47E9), AESx(0x08081018), + AESx(0xBABA6FD5), AESx(0x7878F088), AESx(0x25254A6F), AESx(0x2E2E5C72), + AESx(0x1C1C3824), AESx(0xA6A657F1), AESx(0xB4B473C7), AESx(0xC6C69751), + AESx(0xE8E8CB23), AESx(0xDDDDA17C), AESx(0x7474E89C), AESx(0x1F1F3E21), + AESx(0x4B4B96DD), AESx(0xBDBD61DC), AESx(0x8B8B0D86), AESx(0x8A8A0F85), + AESx(0x7070E090), AESx(0x3E3E7C42), AESx(0xB5B571C4), AESx(0x6666CCAA), + AESx(0x484890D8), AESx(0x03030605), AESx(0xF6F6F701), AESx(0x0E0E1C12), + AESx(0x6161C2A3), AESx(0x35356A5F), AESx(0x5757AEF9), AESx(0xB9B969D0), + AESx(0x86861791), AESx(0xC1C19958), AESx(0x1D1D3A27), AESx(0x9E9E27B9), + AESx(0xE1E1D938), AESx(0xF8F8EB13), AESx(0x98982BB3), AESx(0x11112233), + AESx(0x6969D2BB), AESx(0xD9D9A970), AESx(0x8E8E0789), AESx(0x949433A7), + AESx(0x9B9B2DB6), AESx(0x1E1E3C22), AESx(0x87871592), AESx(0xE9E9C920), + AESx(0xCECE8749), AESx(0x5555AAFF), AESx(0x28285078), AESx(0xDFDFA57A), + AESx(0x8C8C038F), AESx(0xA1A159F8), AESx(0x89890980), AESx(0x0D0D1A17), + AESx(0xBFBF65DA), AESx(0xE6E6D731), AESx(0x424284C6), AESx(0x6868D0B8), + AESx(0x414182C3), AESx(0x999929B0), AESx(0x2D2D5A77), AESx(0x0F0F1E11), + AESx(0xB0B07BCB), AESx(0x5454A8FC), AESx(0xBBBB6DD6), AESx(0x16162C3A) +}; + +static const sph_u32 AES2[256] = { + AESx(0x63C6A563), AESx(0x7CF8847C), AESx(0x77EE9977), AESx(0x7BF68D7B), + AESx(0xF2FF0DF2), AESx(0x6BD6BD6B), AESx(0x6FDEB16F), AESx(0xC59154C5), + AESx(0x30605030), AESx(0x01020301), AESx(0x67CEA967), AESx(0x2B567D2B), + AESx(0xFEE719FE), AESx(0xD7B562D7), AESx(0xAB4DE6AB), AESx(0x76EC9A76), + AESx(0xCA8F45CA), AESx(0x821F9D82), AESx(0xC98940C9), AESx(0x7DFA877D), + AESx(0xFAEF15FA), AESx(0x59B2EB59), AESx(0x478EC947), AESx(0xF0FB0BF0), + AESx(0xAD41ECAD), AESx(0xD4B367D4), AESx(0xA25FFDA2), AESx(0xAF45EAAF), + AESx(0x9C23BF9C), AESx(0xA453F7A4), AESx(0x72E49672), AESx(0xC09B5BC0), + AESx(0xB775C2B7), AESx(0xFDE11CFD), AESx(0x933DAE93), AESx(0x264C6A26), + AESx(0x366C5A36), AESx(0x3F7E413F), AESx(0xF7F502F7), AESx(0xCC834FCC), + AESx(0x34685C34), AESx(0xA551F4A5), AESx(0xE5D134E5), AESx(0xF1F908F1), + AESx(0x71E29371), AESx(0xD8AB73D8), AESx(0x31625331), AESx(0x152A3F15), + AESx(0x04080C04), AESx(0xC79552C7), AESx(0x23466523), AESx(0xC39D5EC3), + AESx(0x18302818), AESx(0x9637A196), AESx(0x050A0F05), AESx(0x9A2FB59A), + AESx(0x070E0907), AESx(0x12243612), AESx(0x801B9B80), AESx(0xE2DF3DE2), + AESx(0xEBCD26EB), AESx(0x274E6927), AESx(0xB27FCDB2), AESx(0x75EA9F75), + AESx(0x09121B09), AESx(0x831D9E83), AESx(0x2C58742C), AESx(0x1A342E1A), + AESx(0x1B362D1B), AESx(0x6EDCB26E), AESx(0x5AB4EE5A), AESx(0xA05BFBA0), + AESx(0x52A4F652), AESx(0x3B764D3B), AESx(0xD6B761D6), AESx(0xB37DCEB3), + AESx(0x29527B29), AESx(0xE3DD3EE3), AESx(0x2F5E712F), AESx(0x84139784), + AESx(0x53A6F553), AESx(0xD1B968D1), AESx(0x00000000), AESx(0xEDC12CED), + AESx(0x20406020), AESx(0xFCE31FFC), AESx(0xB179C8B1), AESx(0x5BB6ED5B), + AESx(0x6AD4BE6A), AESx(0xCB8D46CB), AESx(0xBE67D9BE), AESx(0x39724B39), + AESx(0x4A94DE4A), AESx(0x4C98D44C), AESx(0x58B0E858), AESx(0xCF854ACF), + AESx(0xD0BB6BD0), AESx(0xEFC52AEF), AESx(0xAA4FE5AA), AESx(0xFBED16FB), + AESx(0x4386C543), AESx(0x4D9AD74D), AESx(0x33665533), AESx(0x85119485), + AESx(0x458ACF45), AESx(0xF9E910F9), AESx(0x02040602), AESx(0x7FFE817F), + AESx(0x50A0F050), AESx(0x3C78443C), AESx(0x9F25BA9F), AESx(0xA84BE3A8), + AESx(0x51A2F351), AESx(0xA35DFEA3), AESx(0x4080C040), AESx(0x8F058A8F), + AESx(0x923FAD92), AESx(0x9D21BC9D), AESx(0x38704838), AESx(0xF5F104F5), + AESx(0xBC63DFBC), AESx(0xB677C1B6), AESx(0xDAAF75DA), AESx(0x21426321), + AESx(0x10203010), AESx(0xFFE51AFF), AESx(0xF3FD0EF3), AESx(0xD2BF6DD2), + AESx(0xCD814CCD), AESx(0x0C18140C), AESx(0x13263513), AESx(0xECC32FEC), + AESx(0x5FBEE15F), AESx(0x9735A297), AESx(0x4488CC44), AESx(0x172E3917), + AESx(0xC49357C4), AESx(0xA755F2A7), AESx(0x7EFC827E), AESx(0x3D7A473D), + AESx(0x64C8AC64), AESx(0x5DBAE75D), AESx(0x19322B19), AESx(0x73E69573), + AESx(0x60C0A060), AESx(0x81199881), AESx(0x4F9ED14F), AESx(0xDCA37FDC), + AESx(0x22446622), AESx(0x2A547E2A), AESx(0x903BAB90), AESx(0x880B8388), + AESx(0x468CCA46), AESx(0xEEC729EE), AESx(0xB86BD3B8), AESx(0x14283C14), + AESx(0xDEA779DE), AESx(0x5EBCE25E), AESx(0x0B161D0B), AESx(0xDBAD76DB), + AESx(0xE0DB3BE0), AESx(0x32645632), AESx(0x3A744E3A), AESx(0x0A141E0A), + AESx(0x4992DB49), AESx(0x060C0A06), AESx(0x24486C24), AESx(0x5CB8E45C), + AESx(0xC29F5DC2), AESx(0xD3BD6ED3), AESx(0xAC43EFAC), AESx(0x62C4A662), + AESx(0x9139A891), AESx(0x9531A495), AESx(0xE4D337E4), AESx(0x79F28B79), + AESx(0xE7D532E7), AESx(0xC88B43C8), AESx(0x376E5937), AESx(0x6DDAB76D), + AESx(0x8D018C8D), AESx(0xD5B164D5), AESx(0x4E9CD24E), AESx(0xA949E0A9), + AESx(0x6CD8B46C), AESx(0x56ACFA56), AESx(0xF4F307F4), AESx(0xEACF25EA), + AESx(0x65CAAF65), AESx(0x7AF48E7A), AESx(0xAE47E9AE), AESx(0x08101808), + AESx(0xBA6FD5BA), AESx(0x78F08878), AESx(0x254A6F25), AESx(0x2E5C722E), + AESx(0x1C38241C), AESx(0xA657F1A6), AESx(0xB473C7B4), AESx(0xC69751C6), + AESx(0xE8CB23E8), AESx(0xDDA17CDD), AESx(0x74E89C74), AESx(0x1F3E211F), + AESx(0x4B96DD4B), AESx(0xBD61DCBD), AESx(0x8B0D868B), AESx(0x8A0F858A), + AESx(0x70E09070), AESx(0x3E7C423E), AESx(0xB571C4B5), AESx(0x66CCAA66), + AESx(0x4890D848), AESx(0x03060503), AESx(0xF6F701F6), AESx(0x0E1C120E), + AESx(0x61C2A361), AESx(0x356A5F35), AESx(0x57AEF957), AESx(0xB969D0B9), + AESx(0x86179186), AESx(0xC19958C1), AESx(0x1D3A271D), AESx(0x9E27B99E), + AESx(0xE1D938E1), AESx(0xF8EB13F8), AESx(0x982BB398), AESx(0x11223311), + AESx(0x69D2BB69), AESx(0xD9A970D9), AESx(0x8E07898E), AESx(0x9433A794), + AESx(0x9B2DB69B), AESx(0x1E3C221E), AESx(0x87159287), AESx(0xE9C920E9), + AESx(0xCE8749CE), AESx(0x55AAFF55), AESx(0x28507828), AESx(0xDFA57ADF), + AESx(0x8C038F8C), AESx(0xA159F8A1), AESx(0x89098089), AESx(0x0D1A170D), + AESx(0xBF65DABF), AESx(0xE6D731E6), AESx(0x4284C642), AESx(0x68D0B868), + AESx(0x4182C341), AESx(0x9929B099), AESx(0x2D5A772D), AESx(0x0F1E110F), + AESx(0xB07BCBB0), AESx(0x54A8FC54), AESx(0xBB6DD6BB), AESx(0x162C3A16) +}; + +static const sph_u32 AES3[256] = { + AESx(0xC6A56363), AESx(0xF8847C7C), AESx(0xEE997777), AESx(0xF68D7B7B), + AESx(0xFF0DF2F2), AESx(0xD6BD6B6B), AESx(0xDEB16F6F), AESx(0x9154C5C5), + AESx(0x60503030), AESx(0x02030101), AESx(0xCEA96767), AESx(0x567D2B2B), + AESx(0xE719FEFE), AESx(0xB562D7D7), AESx(0x4DE6ABAB), AESx(0xEC9A7676), + AESx(0x8F45CACA), AESx(0x1F9D8282), AESx(0x8940C9C9), AESx(0xFA877D7D), + AESx(0xEF15FAFA), AESx(0xB2EB5959), AESx(0x8EC94747), AESx(0xFB0BF0F0), + AESx(0x41ECADAD), AESx(0xB367D4D4), AESx(0x5FFDA2A2), AESx(0x45EAAFAF), + AESx(0x23BF9C9C), AESx(0x53F7A4A4), AESx(0xE4967272), AESx(0x9B5BC0C0), + AESx(0x75C2B7B7), AESx(0xE11CFDFD), AESx(0x3DAE9393), AESx(0x4C6A2626), + AESx(0x6C5A3636), AESx(0x7E413F3F), AESx(0xF502F7F7), AESx(0x834FCCCC), + AESx(0x685C3434), AESx(0x51F4A5A5), AESx(0xD134E5E5), AESx(0xF908F1F1), + AESx(0xE2937171), AESx(0xAB73D8D8), AESx(0x62533131), AESx(0x2A3F1515), + AESx(0x080C0404), AESx(0x9552C7C7), AESx(0x46652323), AESx(0x9D5EC3C3), + AESx(0x30281818), AESx(0x37A19696), AESx(0x0A0F0505), AESx(0x2FB59A9A), + AESx(0x0E090707), AESx(0x24361212), AESx(0x1B9B8080), AESx(0xDF3DE2E2), + AESx(0xCD26EBEB), AESx(0x4E692727), AESx(0x7FCDB2B2), AESx(0xEA9F7575), + AESx(0x121B0909), AESx(0x1D9E8383), AESx(0x58742C2C), AESx(0x342E1A1A), + AESx(0x362D1B1B), AESx(0xDCB26E6E), AESx(0xB4EE5A5A), AESx(0x5BFBA0A0), + AESx(0xA4F65252), AESx(0x764D3B3B), AESx(0xB761D6D6), AESx(0x7DCEB3B3), + AESx(0x527B2929), AESx(0xDD3EE3E3), AESx(0x5E712F2F), AESx(0x13978484), + AESx(0xA6F55353), AESx(0xB968D1D1), AESx(0x00000000), AESx(0xC12CEDED), + AESx(0x40602020), AESx(0xE31FFCFC), AESx(0x79C8B1B1), AESx(0xB6ED5B5B), + AESx(0xD4BE6A6A), AESx(0x8D46CBCB), AESx(0x67D9BEBE), AESx(0x724B3939), + AESx(0x94DE4A4A), AESx(0x98D44C4C), AESx(0xB0E85858), AESx(0x854ACFCF), + AESx(0xBB6BD0D0), AESx(0xC52AEFEF), AESx(0x4FE5AAAA), AESx(0xED16FBFB), + AESx(0x86C54343), AESx(0x9AD74D4D), AESx(0x66553333), AESx(0x11948585), + AESx(0x8ACF4545), AESx(0xE910F9F9), AESx(0x04060202), AESx(0xFE817F7F), + AESx(0xA0F05050), AESx(0x78443C3C), AESx(0x25BA9F9F), AESx(0x4BE3A8A8), + AESx(0xA2F35151), AESx(0x5DFEA3A3), AESx(0x80C04040), AESx(0x058A8F8F), + AESx(0x3FAD9292), AESx(0x21BC9D9D), AESx(0x70483838), AESx(0xF104F5F5), + AESx(0x63DFBCBC), AESx(0x77C1B6B6), AESx(0xAF75DADA), AESx(0x42632121), + AESx(0x20301010), AESx(0xE51AFFFF), AESx(0xFD0EF3F3), AESx(0xBF6DD2D2), + AESx(0x814CCDCD), AESx(0x18140C0C), AESx(0x26351313), AESx(0xC32FECEC), + AESx(0xBEE15F5F), AESx(0x35A29797), AESx(0x88CC4444), AESx(0x2E391717), + AESx(0x9357C4C4), AESx(0x55F2A7A7), AESx(0xFC827E7E), AESx(0x7A473D3D), + AESx(0xC8AC6464), AESx(0xBAE75D5D), AESx(0x322B1919), AESx(0xE6957373), + AESx(0xC0A06060), AESx(0x19988181), AESx(0x9ED14F4F), AESx(0xA37FDCDC), + AESx(0x44662222), AESx(0x547E2A2A), AESx(0x3BAB9090), AESx(0x0B838888), + AESx(0x8CCA4646), AESx(0xC729EEEE), AESx(0x6BD3B8B8), AESx(0x283C1414), + AESx(0xA779DEDE), AESx(0xBCE25E5E), AESx(0x161D0B0B), AESx(0xAD76DBDB), + AESx(0xDB3BE0E0), AESx(0x64563232), AESx(0x744E3A3A), AESx(0x141E0A0A), + AESx(0x92DB4949), AESx(0x0C0A0606), AESx(0x486C2424), AESx(0xB8E45C5C), + AESx(0x9F5DC2C2), AESx(0xBD6ED3D3), AESx(0x43EFACAC), AESx(0xC4A66262), + AESx(0x39A89191), AESx(0x31A49595), AESx(0xD337E4E4), AESx(0xF28B7979), + AESx(0xD532E7E7), AESx(0x8B43C8C8), AESx(0x6E593737), AESx(0xDAB76D6D), + AESx(0x018C8D8D), AESx(0xB164D5D5), AESx(0x9CD24E4E), AESx(0x49E0A9A9), + AESx(0xD8B46C6C), AESx(0xACFA5656), AESx(0xF307F4F4), AESx(0xCF25EAEA), + AESx(0xCAAF6565), AESx(0xF48E7A7A), AESx(0x47E9AEAE), AESx(0x10180808), + AESx(0x6FD5BABA), AESx(0xF0887878), AESx(0x4A6F2525), AESx(0x5C722E2E), + AESx(0x38241C1C), AESx(0x57F1A6A6), AESx(0x73C7B4B4), AESx(0x9751C6C6), + AESx(0xCB23E8E8), AESx(0xA17CDDDD), AESx(0xE89C7474), AESx(0x3E211F1F), + AESx(0x96DD4B4B), AESx(0x61DCBDBD), AESx(0x0D868B8B), AESx(0x0F858A8A), + AESx(0xE0907070), AESx(0x7C423E3E), AESx(0x71C4B5B5), AESx(0xCCAA6666), + AESx(0x90D84848), AESx(0x06050303), AESx(0xF701F6F6), AESx(0x1C120E0E), + AESx(0xC2A36161), AESx(0x6A5F3535), AESx(0xAEF95757), AESx(0x69D0B9B9), + AESx(0x17918686), AESx(0x9958C1C1), AESx(0x3A271D1D), AESx(0x27B99E9E), + AESx(0xD938E1E1), AESx(0xEB13F8F8), AESx(0x2BB39898), AESx(0x22331111), + AESx(0xD2BB6969), AESx(0xA970D9D9), AESx(0x07898E8E), AESx(0x33A79494), + AESx(0x2DB69B9B), AESx(0x3C221E1E), AESx(0x15928787), AESx(0xC920E9E9), + AESx(0x8749CECE), AESx(0xAAFF5555), AESx(0x50782828), AESx(0xA57ADFDF), + AESx(0x038F8C8C), AESx(0x59F8A1A1), AESx(0x09808989), AESx(0x1A170D0D), + AESx(0x65DABFBF), AESx(0xD731E6E6), AESx(0x84C64242), AESx(0xD0B86868), + AESx(0x82C34141), AESx(0x29B09999), AESx(0x5A772D2D), AESx(0x1E110F0F), + AESx(0x7BCBB0B0), AESx(0xA8FC5454), AESx(0x6DD6BBBB), AESx(0x2C3A1616) +}; + +#ifdef __cplusplus +} +#endif diff --git a/src/alert.cpp b/src/alert.cpp new file mode 100644 index 0000000..6241e48 --- /dev/null +++ b/src/alert.cpp @@ -0,0 +1,258 @@ +// +// Alert system +// + +#include "alert.h" + +#include "chainparams.h" +#include "key.h" +#include "net.h" +#include "timedata.h" +#include "ui_interface.h" +#include "util.h" + +#include +#include +#include + +#include +#include +#include + +using namespace std; + +map mapAlerts; +CCriticalSection cs_mapAlerts; + +void CUnsignedAlert::SetNull() +{ + nVersion = 1; + nRelayUntil = 0; + nExpiration = 0; + nID = 0; + nCancel = 0; + setCancel.clear(); + nMinVer = 0; + nMaxVer = 0; + setSubVer.clear(); + nPriority = 0; + + strComment.clear(); + strStatusBar.clear(); + strReserved.clear(); +} + +std::string CUnsignedAlert::ToString() const +{ + std::string strSetCancel; + BOOST_FOREACH(int n, setCancel) + strSetCancel += strprintf("%d ", n); + std::string strSetSubVer; + BOOST_FOREACH(std::string str, setSubVer) + strSetSubVer += "\"" + str + "\" "; + return strprintf( + "CAlert(\n" + " nVersion = %d\n" + " nRelayUntil = %d\n" + " nExpiration = %d\n" + " nID = %d\n" + " nCancel = %d\n" + " setCancel = %s\n" + " nMinVer = %d\n" + " nMaxVer = %d\n" + " setSubVer = %s\n" + " nPriority = %d\n" + " strComment = \"%s\"\n" + " strStatusBar = \"%s\"\n" + ")\n", + nVersion, + nRelayUntil, + nExpiration, + nID, + nCancel, + strSetCancel, + nMinVer, + nMaxVer, + strSetSubVer, + nPriority, + strComment, + strStatusBar); +} + +void CAlert::SetNull() +{ + CUnsignedAlert::SetNull(); + vchMsg.clear(); + vchSig.clear(); +} + +bool CAlert::IsNull() const +{ + return (nExpiration == 0); +} + +uint256 CAlert::GetHash() const +{ + return Hash(this->vchMsg.begin(), this->vchMsg.end()); +} + +bool CAlert::IsInEffect() const +{ + return (GetAdjustedTime() < nExpiration); +} + +bool CAlert::Cancels(const CAlert& alert) const +{ + if (!IsInEffect()) + return false; // this was a no-op before 31403 + return (alert.nID <= nCancel || setCancel.count(alert.nID)); +} + +bool CAlert::AppliesTo(int nVersion, std::string strSubVerIn) const +{ + // TODO: rework for client-version-embedded-in-strSubVer ? + return (IsInEffect() && + nMinVer <= nVersion && nVersion <= nMaxVer && + (setSubVer.empty() || setSubVer.count(strSubVerIn))); +} + +bool CAlert::AppliesToMe() const +{ + return AppliesTo(PROTOCOL_VERSION, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector())); +} + +bool CAlert::RelayTo(CNode* pnode) const +{ + if (!IsInEffect()) + return false; + // don't relay to nodes which haven't sent their version message + if (pnode->nVersion == 0) + return false; + // returns true if wasn't already contained in the set + if (pnode->setKnown.insert(GetHash()).second) + { + if (AppliesTo(pnode->nVersion, pnode->strSubVer) || + AppliesToMe() || + GetAdjustedTime() < nRelayUntil) + { + pnode->PushMessage("alert", *this); + return true; + } + } + return false; +} + +bool CAlert::CheckSignature() const +{ + CPubKey key(Params().AlertKey()); + if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig)) + return error("CAlert::CheckSignature() : verify signature failed"); + + // Now unserialize the data + CDataStream sMsg(vchMsg, SER_NETWORK, PROTOCOL_VERSION); + sMsg >> *(CUnsignedAlert*)this; + return true; +} + +CAlert CAlert::getAlertByHash(const uint256 &hash) +{ + CAlert retval; + { + LOCK(cs_mapAlerts); + map::iterator mi = mapAlerts.find(hash); + if(mi != mapAlerts.end()) + retval = mi->second; + } + return retval; +} + +bool CAlert::ProcessAlert(bool fThread) +{ + if (!CheckSignature()) + return false; + if (!IsInEffect()) + return false; + + // alert.nID=max is reserved for if the alert key is + // compromised. It must have a pre-defined message, + // must never expire, must apply to all versions, + // and must cancel all previous + // alerts or it will be ignored (so an attacker can't + // send an "everything is OK, don't panic" version that + // cannot be overridden): + int maxInt = std::numeric_limits::max(); + if (nID == maxInt) + { + if (!( + nExpiration == maxInt && + nCancel == (maxInt-1) && + nMinVer == 0 && + nMaxVer == maxInt && + setSubVer.empty() && + nPriority == maxInt && + strStatusBar == "URGENT: Alert key compromised, upgrade required" + )) + return false; + } + + { + LOCK(cs_mapAlerts); + // Cancel previous alerts + for (map::iterator mi = mapAlerts.begin(); mi != mapAlerts.end();) + { + const CAlert& alert = (*mi).second; + if (Cancels(alert)) + { + LogPrint("alert", "cancelling alert %d\n", alert.nID); + uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED); + mapAlerts.erase(mi++); + } + else if (!alert.IsInEffect()) + { + LogPrint("alert", "expiring alert %d\n", alert.nID); + uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED); + mapAlerts.erase(mi++); + } + else + mi++; + } + + // Check if this alert has been cancelled + BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts) + { + const CAlert& alert = item.second; + if (alert.Cancels(*this)) + { + LogPrint("alert", "alert already cancelled by %d\n", alert.nID); + return false; + } + } + + // Add to mapAlerts + mapAlerts.insert(make_pair(GetHash(), *this)); + // Notify UI and -alertnotify if it applies to me + if(AppliesToMe()) + { + uiInterface.NotifyAlertChanged(GetHash(), CT_NEW); + std::string strCmd = GetArg("-alertnotify", ""); + if (!strCmd.empty()) + { + // Alert text should be plain ascii coming from a trusted source, but to + // be safe we first strip anything not in safeChars, then add single quotes around + // the whole string before passing it to the shell: + std::string singleQuote("'"); + std::string safeStatus = SanitizeString(strStatusBar); + safeStatus = singleQuote+safeStatus+singleQuote; + boost::replace_all(strCmd, "%s", safeStatus); + + if (fThread) + boost::thread t(runCommand, strCmd); // thread runs free + else + runCommand(strCmd); + } + } + } + + LogPrint("alert", "accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe()); + return true; +} diff --git a/src/alert.h b/src/alert.h new file mode 100644 index 0000000..9475d69 --- /dev/null +++ b/src/alert.h @@ -0,0 +1,101 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef _BITCOINALERT_H_ +#define _BITCOINALERT_H_ 1 + +#include "serialize.h" + +#include +#include + +class CNode; +class uint256; + +/** Alerts are for notifying old versions if they become too obsolete and + * need to upgrade. The message is displayed in the status bar. + * Alert messages are broadcast as a vector of signed data. Unserializing may + * not read the entire buffer if the alert is for a newer version, but older + * versions can still relay the original data. + */ +class CUnsignedAlert +{ +public: + int nVersion; + int64_t nRelayUntil; // when newer nodes stop relaying to newer nodes + int64_t nExpiration; + int nID; + int nCancel; + std::set setCancel; + int nMinVer; // lowest version inclusive + int nMaxVer; // highest version inclusive + std::set setSubVer; // empty matches all + int nPriority; + + // Actions + std::string strComment; + std::string strStatusBar; + std::string strReserved; + + IMPLEMENT_SERIALIZE + ( + READWRITE(this->nVersion); + nVersion = this->nVersion; + READWRITE(nRelayUntil); + READWRITE(nExpiration); + READWRITE(nID); + READWRITE(nCancel); + READWRITE(setCancel); + READWRITE(nMinVer); + READWRITE(nMaxVer); + READWRITE(setSubVer); + READWRITE(nPriority); + + READWRITE(strComment); + READWRITE(strStatusBar); + READWRITE(strReserved); + ) + + void SetNull(); + + std::string ToString() const; +}; + +/** An alert is a combination of a serialized CUnsignedAlert and a signature. */ +class CAlert : public CUnsignedAlert +{ +public: + std::vector vchMsg; + std::vector vchSig; + + CAlert() + { + SetNull(); + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(vchMsg); + READWRITE(vchSig); + ) + + void SetNull(); + bool IsNull() const; + uint256 GetHash() const; + bool IsInEffect() const; + bool Cancels(const CAlert& alert) const; + bool AppliesTo(int nVersion, std::string strSubVerIn) const; + bool AppliesToMe() const; + bool RelayTo(CNode* pnode) const; + bool CheckSignature() const; + bool ProcessAlert(bool fThread = true); + + /* + * Get copy of (active) alert object by hash. Returns a null alert if it is not found. + */ + static CAlert getAlertByHash(const uint256 &hash); +}; + +#endif diff --git a/src/allocators.cpp b/src/allocators.cpp new file mode 100644 index 0000000..b759112 --- /dev/null +++ b/src/allocators.cpp @@ -0,0 +1,66 @@ +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "allocators.h" + +#ifdef WIN32 +#ifdef _WIN32_WINNT +#undef _WIN32_WINNT +#endif +#define _WIN32_WINNT 0x0501 +#define WIN32_LEAN_AND_MEAN 1 +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include +// This is used to attempt to keep keying material out of swap +// Note that VirtualLock does not provide this as a guarantee on Windows, +// but, in practice, memory that has been VirtualLock'd almost never gets written to +// the pagefile except in rare circumstances where memory is extremely low. +#else +#include +#include // for PAGESIZE +#include // for sysconf +#endif + +LockedPageManager* LockedPageManager::_instance = NULL; +boost::once_flag LockedPageManager::init_flag = BOOST_ONCE_INIT; + +/** Determine system page size in bytes */ +static inline size_t GetSystemPageSize() +{ + size_t page_size; +#if defined(WIN32) + SYSTEM_INFO sSysInfo; + GetSystemInfo(&sSysInfo); + page_size = sSysInfo.dwPageSize; +#elif defined(PAGESIZE) // defined in limits.h + page_size = PAGESIZE; +#else // assume some POSIX OS + page_size = sysconf(_SC_PAGESIZE); +#endif + return page_size; +} + +bool MemoryPageLocker::Lock(const void *addr, size_t len) +{ +#ifdef WIN32 + return VirtualLock(const_cast(addr), len); +#else + return mlock(addr, len) == 0; +#endif +} + +bool MemoryPageLocker::Unlock(const void *addr, size_t len) +{ +#ifdef WIN32 + return VirtualUnlock(const_cast(addr), len); +#else + return munlock(addr, len) == 0; +#endif +} + +LockedPageManager::LockedPageManager() : LockedPageManagerBase(GetSystemPageSize()) +{ +} diff --git a/src/allocators.h b/src/allocators.h new file mode 100644 index 0000000..85af8fe --- /dev/null +++ b/src/allocators.h @@ -0,0 +1,271 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_ALLOCATORS_H +#define BITCOIN_ALLOCATORS_H + +#include +#include +#include +#include +#include // for OPENSSL_cleanse() + +#ifdef WIN32 +#ifdef _WIN32_WINNT +#undef _WIN32_WINNT +#endif +#define _WIN32_WINNT 0x0501 +#define WIN32_LEAN_AND_MEAN 1 +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include +// This is used to attempt to keep keying material out of swap +// Note that VirtualLock does not provide this as a guarantee on Windows, +// but, in practice, memory that has been VirtualLock'd almost never gets written to +// the pagefile except in rare circumstances where memory is extremely low. +#else +#include +#include // for PAGESIZE +#include // for sysconf +#endif + +/** + * Thread-safe class to keep track of locked (ie, non-swappable) memory pages. + * + * Memory locks do not stack, that is, pages which have been locked several times by calls to mlock() + * will be unlocked by a single call to munlock(). This can result in keying material ending up in swap when + * those functions are used naively. This class simulates stacking memory locks by keeping a counter per page. + * + * @note By using a map from each page base address to lock count, this class is optimized for + * small objects that span up to a few pages, mostly smaller than a page. To support large allocations, + * something like an interval tree would be the preferred data structure. + */ +template class LockedPageManagerBase +{ +public: + LockedPageManagerBase(size_t page_size): + page_size(page_size) + { + // Determine bitmask for extracting page from address + assert(!(page_size & (page_size-1))); // size must be power of two + page_mask = ~(page_size - 1); + } + + // For all pages in affected range, increase lock count + void LockRange(void *p, size_t size) + { + boost::mutex::scoped_lock lock(mutex); + if(!size) return; + const size_t base_addr = reinterpret_cast(p); + const size_t start_page = base_addr & page_mask; + const size_t end_page = (base_addr + size - 1) & page_mask; + for(size_t page = start_page; page <= end_page; page += page_size) + { + Histogram::iterator it = histogram.find(page); + if(it == histogram.end()) // Newly locked page + { + locker.Lock(reinterpret_cast(page), page_size); + histogram.insert(std::make_pair(page, 1)); + } + else // Page was already locked; increase counter + { + it->second += 1; + } + } + } + + // For all pages in affected range, decrease lock count + void UnlockRange(void *p, size_t size) + { + boost::mutex::scoped_lock lock(mutex); + if(!size) return; + const size_t base_addr = reinterpret_cast(p); + const size_t start_page = base_addr & page_mask; + const size_t end_page = (base_addr + size - 1) & page_mask; + for(size_t page = start_page; page <= end_page; page += page_size) + { + Histogram::iterator it = histogram.find(page); + assert(it != histogram.end()); // Cannot unlock an area that was not locked + // Decrease counter for page, when it is zero, the page will be unlocked + it->second -= 1; + if(it->second == 0) // Nothing on the page anymore that keeps it locked + { + // Unlock page and remove the count from histogram + locker.Unlock(reinterpret_cast(page), page_size); + histogram.erase(it); + } + } + } + + // Get number of locked pages for diagnostics + int GetLockedPageCount() + { + boost::mutex::scoped_lock lock(mutex); + return histogram.size(); + } + +private: + Locker locker; + boost::mutex mutex; + size_t page_size, page_mask; + // map of page base address to lock count + typedef std::map Histogram; + Histogram histogram; +}; + +/** Determine system page size in bytes */ +static inline size_t GetSystemPageSize() +{ + size_t page_size; +#if defined(WIN32) + SYSTEM_INFO sSysInfo; + GetSystemInfo(&sSysInfo); + page_size = sSysInfo.dwPageSize; +#elif defined(PAGESIZE) // defined in limits.h + page_size = PAGESIZE; +#else // assume some POSIX OS + page_size = sysconf(_SC_PAGESIZE); +#endif + return page_size; +} + +/** + * OS-dependent memory page locking/unlocking. + * Defined as policy class to make stubbing for test possible. + */ +class MemoryPageLocker +{ +public: + /** Lock memory pages. + * addr and len must be a multiple of the system page size + */ + bool Lock(const void *addr, size_t len) + { +#ifdef WIN32 + return VirtualLock(const_cast(addr), len); +#else + return mlock(addr, len) == 0; +#endif + } + /** Unlock memory pages. + * addr and len must be a multiple of the system page size + */ + bool Unlock(const void *addr, size_t len) + { +#ifdef WIN32 + return VirtualUnlock(const_cast(addr), len); +#else + return munlock(addr, len) == 0; +#endif + } +}; + +/** + * Singleton class to keep track of locked (ie, non-swappable) memory pages, for use in + * std::allocator templates. + */ +class LockedPageManager: public LockedPageManagerBase +{ +public: + static LockedPageManager instance; // instantiated in util.cpp +private: + LockedPageManager(): + LockedPageManagerBase(GetSystemPageSize()) + {} +}; + +// +// Functions for directly locking/unlocking memory objects. +// Intended for non-dynamically allocated structures. +// +template void LockObject(const T &t) { + LockedPageManager::instance.LockRange((void*)(&t), sizeof(T)); +} + +template void UnlockObject(const T &t) { + OPENSSL_cleanse((void*)(&t), sizeof(T)); + LockedPageManager::instance.UnlockRange((void*)(&t), sizeof(T)); +} + +// +// Allocator that locks its contents from being paged +// out of memory and clears its contents before deletion. +// +template +struct secure_allocator : public std::allocator +{ + // MSVC8 default copy constructor is broken + typedef std::allocator base; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::value_type value_type; + secure_allocator() throw() {} + secure_allocator(const secure_allocator& a) throw() : base(a) {} + template + secure_allocator(const secure_allocator& a) throw() : base(a) {} + ~secure_allocator() throw() {} + template struct rebind + { typedef secure_allocator<_Other> other; }; + + T* allocate(std::size_t n, const void *hint = 0) + { + T *p; + p = std::allocator::allocate(n, hint); + if (p != NULL) + LockedPageManager::instance.LockRange(p, sizeof(T) * n); + return p; + } + + void deallocate(T* p, std::size_t n) + { + if (p != NULL) + { + OPENSSL_cleanse(p, sizeof(T) * n); + LockedPageManager::instance.UnlockRange(p, sizeof(T) * n); + } + std::allocator::deallocate(p, n); + } +}; + + +// +// Allocator that clears its contents before deletion. +// +template +struct zero_after_free_allocator : public std::allocator +{ + // MSVC8 default copy constructor is broken + typedef std::allocator base; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::value_type value_type; + zero_after_free_allocator() throw() {} + zero_after_free_allocator(const zero_after_free_allocator& a) throw() : base(a) {} + template + zero_after_free_allocator(const zero_after_free_allocator& a) throw() : base(a) {} + ~zero_after_free_allocator() throw() {} + template struct rebind + { typedef zero_after_free_allocator<_Other> other; }; + + void deallocate(T* p, std::size_t n) + { + if (p != NULL) + OPENSSL_cleanse(p, sizeof(T) * n); + std::allocator::deallocate(p, n); + } +}; + +// This is exactly like std::string, but with a custom allocator. +typedef std::basic_string, secure_allocator > SecureString; + +#endif diff --git a/src/arith_uint256.h b/src/arith_uint256.h new file mode 100644 index 0000000..3bb384c --- /dev/null +++ b/src/arith_uint256.h @@ -0,0 +1,19 @@ +#ifndef BITCOIN_ARITH_UINT256_H +#define BITCOIN_ARITH_UINT256_H + +// Temporary for migration to opaque uint160/256 +#include "uint256.h" + +class arith_uint256 : public uint256 { +public: + arith_uint256() {} + arith_uint256(const base_uint<256>& b) : uint256(b) {} + arith_uint256(uint64_t b) : uint256(b) {} + explicit arith_uint256(const std::string& str) : uint256(str) {} + explicit arith_uint256(const std::vector& vch) : uint256(vch) {} +}; + +#define ArithToUint256(x) (x) +#define UintToArith256(x) (x) + +#endif // BITCOIN_UINT256_H diff --git a/src/base58.cpp b/src/base58.cpp new file mode 100644 index 0000000..d3276f2 --- /dev/null +++ b/src/base58.cpp @@ -0,0 +1,380 @@ +// Copyright (c) 2014 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "base58.h" + +#include "hash.h" +#include "uint256.h" +#include "chainparams.h" + +#include +#include +#include +#include +#include +#include +#include + +/* All alphanumeric characters except for "0", "I", "O", and "l" */ +static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + +bool DecodeBase58(const char* psz, std::vector& vchRet) { + CAutoBN_CSONO pctx; + vchRet.clear(); + CBigNum bn58 = 58; + CBigNum bn = 0; + CBigNum bnChar; + // Skip leading spaces. + while (*psz && isspace(*psz)) + psz++; + // Skip and count leading '1's. + int zeroes = 0; + while (*psz == '1') { + zeroes++; + psz++; + } + // Convert big endian string to bignum + for (const char* p = psz; *p; p++) + { + const char* p1 = strchr(pszBase58, *p); + if (p1 == NULL) + { + while (isspace(*p)) + p++; + if (*p != '\0') + return false; + break; + } + bnChar.setulong(p1 - pszBase58); + if (!BN_mul(&bn, &bn, &bn58, pctx)) + throw bignum_error("DecodeBase58 : BN_mul failed"); + bn += bnChar; + } + + // Get bignum as little endian data + std::vector vchTmp = bn.getvch(); + + // Trim off sign byte if present + if (vchTmp.size() >= 2 && vchTmp.end()[-1] == 0 && vchTmp.end()[-2] >= 0x80) + vchTmp.erase(vchTmp.end()-1); + + // Restore leading zeros + int nLeadingZeros = 0; + for (const char* p = psz; *p == pszBase58[0]; p++) + nLeadingZeros++; + vchRet.assign(nLeadingZeros + vchTmp.size(), 0); + + // Convert little endian data to big endian + reverse_copy(vchTmp.begin(), vchTmp.end(), vchRet.end() - vchTmp.size()); + return true; + // Allocate enough space in big-endian base256 representation. + std::vector b256(strlen(psz) * 733 / 1000 + 1); // log(58) / log(256), rounded up. + // Process the characters. + while (*psz && !isspace(*psz)) { + // Decode base58 character + const char *ch = strchr(pszBase58, *psz); + if (ch == NULL) + return false; + // Apply "b256 = b256 * 58 + ch". + int carry = ch - pszBase58; + for (std::vector::reverse_iterator it = b256.rbegin(); it != b256.rend(); it++) { + carry += 58 * (*it); + *it = carry % 256; + carry /= 256; + } + assert(carry == 0); + psz++; + } + // Skip trailing spaces. + while (isspace(*psz)) + psz++; + if (*psz != 0) + return false; + // Skip leading zeroes in b256. + std::vector::iterator it = b256.begin(); + while (it != b256.end() && *it == 0) + it++; + // Copy result into output vector. + vchRet.reserve(zeroes + (b256.end() - it)); + vchRet.assign(zeroes, 0x00); + while (it != b256.end()) + vchRet.push_back(*(it++)); + return true; +} + +std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend) { + // Skip & count leading zeroes. + int zeroes = 0; + while (pbegin != pend && *pbegin == 0) { + pbegin++; + zeroes++; + } + // Allocate enough space in big-endian base58 representation. + std::vector b58((pend - pbegin) * 138 / 100 + 1); // log(256) / log(58), rounded up. + // Process the bytes. + while (pbegin != pend) { + int carry = *pbegin; + // Apply "b58 = b58 * 256 + ch". + for (std::vector::reverse_iterator it = b58.rbegin(); it != b58.rend(); it++) { + carry += 256 * (*it); + *it = carry % 58; + carry /= 58; + } + assert(carry == 0); + pbegin++; + } + // Skip leading zeroes in base58 result. + std::vector::iterator it = b58.begin(); + while (it != b58.end() && *it == 0) + it++; + // Translate the result into a string. + std::string str; + str.reserve(zeroes + (b58.end() - it)); + str.assign(zeroes, '1'); + while (it != b58.end()) + str += pszBase58[*(it++)]; + return str; +} + +std::string EncodeBase58(const std::vector& vch) { + return EncodeBase58(&vch[0], &vch[0] + vch.size()); +} + +bool DecodeBase58(const std::string& str, std::vector& vchRet) { + return DecodeBase58(str.c_str(), vchRet); +} + +std::string EncodeBase58Check(const std::vector& vchIn) { + // add 4-byte hash check to the end + std::vector vch(vchIn); + uint256 hash = Hash(vch.begin(), vch.end()); + vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4); + return EncodeBase58(vch); +} + +bool DecodeBase58Check(const char* psz, std::vector& vchRet) { + if (!DecodeBase58(psz, vchRet) || + (vchRet.size() < 4)) + { + vchRet.clear(); + return false; + } + // re-calculate the checksum, insure it matches the included 4-byte checksum + uint256 hash = Hash(vchRet.begin(), vchRet.end()-4); + if (memcmp(&hash, &vchRet.end()[-4], 4) != 0) + { + vchRet.clear(); + return false; + } + vchRet.resize(vchRet.size()-4); + return true; +} + +bool DecodeBase58Check(const std::string& str, std::vector& vchRet) { + return DecodeBase58Check(str.c_str(), vchRet); +} + +CBase58Data::CBase58Data() { + vchVersion.clear(); + vchData.clear(); +} + +void CBase58Data::SetData(const std::vector &vchVersionIn, const void* pdata, size_t nSize) { + vchVersion = vchVersionIn; + vchData.resize(nSize); + if (!vchData.empty()) + memcpy(&vchData[0], pdata, nSize); +} + +void CBase58Data::SetData(const std::vector &vchVersionIn, const unsigned char *pbegin, const unsigned char *pend) { + SetData(vchVersionIn, (void*)pbegin, pend - pbegin); +} + +bool CBase58Data::SetString(const char* psz, unsigned int nVersionBytes) { + std::vector vchTemp; + bool rc58 = DecodeBase58Check(psz, vchTemp); + if ((!rc58) || (vchTemp.size() < nVersionBytes)) { + vchData.clear(); + vchVersion.clear(); + return false; + } + vchVersion.assign(vchTemp.begin(), vchTemp.begin() + nVersionBytes); + vchData.resize(vchTemp.size() - nVersionBytes); + if (!vchData.empty()) + memcpy(&vchData[0], &vchTemp[nVersionBytes], vchData.size()); + memory_cleanse(&vchTemp[0], vchData.size()); + return true; +} + +bool CBase58Data::SetString(const std::string& str) { + return SetString(str.c_str()); +} + +std::string CBase58Data::ToString() const { + std::vector vch = vchVersion; + vch.insert(vch.end(), vchData.begin(), vchData.end()); + return EncodeBase58Check(vch); +} + +int CBase58Data::CompareTo(const CBase58Data& b58) const { + if (vchVersion < b58.vchVersion) return -1; + if (vchVersion > b58.vchVersion) return 1; + if (vchData < b58.vchData) return -1; + if (vchData > b58.vchData) return 1; + return 0; +} + +namespace { + class CSONOAddressVisitor : public boost::static_visitor { + private: + CSONOAddress *addr; + public: + CSONOAddressVisitor(CSONOAddress *addrIn) : addr(addrIn) { } + + bool operator()(const CKeyID &id) const { return addr->Set(id); } + bool operator()(const CScriptID &id) const { return addr->Set(id); } + bool operator()(const CNoDestination &no) const { return false; } + bool operator()(const CStealthAddress &stxAddr) const { return false; } + }; + class CBitcoinAddressVisitor : public boost::static_visitor { + private: + CBitcoinAddress *addr; + public: + CBitcoinAddressVisitor(CBitcoinAddress *addrIn) : addr(addrIn) { } + + bool operator()(const CKeyID &id) const { return addr->Set(id); } + bool operator()(const CScriptID &id) const { return addr->Set(id); } + bool operator()(const CNoDestination &no) const { return false; } + bool operator()(const CStealthAddress &stxAddr) const { return false; } + }; +}; + +bool CSONOAddress::Set(const CKeyID &id) { + SetData(Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS), &id, 20); + return true; +} + +bool CSONOAddress::Set(const CScriptID &id) { + SetData(Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS), &id, 20); + return true; +} + +bool CSONOAddress::Set(const CTxDestination &dest) { + return boost::apply_visitor(CSONOAddressVisitor(this), dest); +} + +bool CSONOAddress::IsValid() const { + bool fCorrectSize = vchData.size() == 20; + bool fKnownVersion = vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS) || + vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS); + return fCorrectSize && fKnownVersion; +} + +CTxDestination CSONOAddress::Get() const { + if (!IsValid()) + return CNoDestination(); + uint160 id; + memcpy(&id, &vchData[0], 20); + if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) + return CKeyID(id); + else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS)) + return CScriptID(id); + else + return CNoDestination(); +} + +bool CSONOAddress::GetKeyID(CKeyID &keyID) const { + if (!IsValid() || vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) + return false; + uint160 id; + memcpy(&id, &vchData[0], 20); + keyID = CKeyID(id); + return true; +} + +bool CSONOAddress::IsScript() const { + return IsValid() && vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS); +} + +void CSONOSecret::SetKey(const CKey& vchSecret) { + assert(vchSecret.IsValid()); + SetData(Params().Base58Prefix(CChainParams::SECRET_KEY), vchSecret.begin(), vchSecret.size()); + if (vchSecret.IsCompressed()) + vchData.push_back(1); +} + +CKey CSONOSecret::GetKey() { + CKey ret; + ret.Set(&vchData[0], &vchData[32], vchData.size() > 32 && vchData[32] == 1); + return ret; +} + +bool CSONOSecret::IsValid() const { + bool fExpectedFormat = vchData.size() == 32 || (vchData.size() == 33 && vchData[32] == 1); + bool fCorrectVersion = vchVersion == Params().Base58Prefix(CChainParams::SECRET_KEY); + return fExpectedFormat && fCorrectVersion; +} + +bool CSONOSecret::SetString(const char* pszSecret) { + return CBase58Data::SetString(pszSecret) && IsValid(); +} + +bool CSONOSecret::SetString(const std::string& strSecret) { + return SetString(strSecret.c_str()); +} + +/** base58-encoded Bitcoin addresses. + * Public-key-hash-addresses have version 0 (or 111 testnet). + * The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key. + * Script-hash-addresses have version 5 (or 196 testnet). + * The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script. + */ +CChainParams::Base58Type pubkey_address = (CChainParams::Base58Type)0; +CChainParams::Base58Type script_address = (CChainParams::Base58Type)5; +bool CBitcoinAddress::Set(const CKeyID &id) { + SetData(Params().Base58Prefix(pubkey_address), &id, 20); + return true; +} + +bool CBitcoinAddress::Set(const CScriptID &id) { + SetData(Params().Base58Prefix(script_address), &id, 20); + return true; +} + +bool CBitcoinAddress::Set(const CTxDestination &dest) { + return boost::apply_visitor(CBitcoinAddressVisitor(this), dest); +} + +bool CBitcoinAddress::IsValid() const { + bool fCorrectSize = vchData.size() == 20; + bool fKnownVersion = vchVersion == Params().Base58Prefix(pubkey_address) || + vchVersion == Params().Base58Prefix(script_address); + return fCorrectSize && fKnownVersion; +} + +CTxDestination CBitcoinAddress::Get() const { + if (!IsValid()) + return CNoDestination(); + uint160 id; + memcpy(&id, &vchData[0], 20); + if (vchVersion == Params().Base58Prefix(pubkey_address)) + return CKeyID(id); + else if (vchVersion == Params().Base58Prefix(script_address)) + return CScriptID(id); + else + return CNoDestination(); +} + +bool CBitcoinAddress::GetKeyID(CKeyID &keyID) const { + if (!IsValid() || vchVersion != Params().Base58Prefix(pubkey_address)) + return false; + uint160 id; + memcpy(&id, &vchData[0], 20); + keyID = CKeyID(id); + return true; +} + +bool CBitcoinAddress::IsScript() const { + return IsValid() && vchVersion == Params().Base58Prefix(script_address); +} diff --git a/src/base58.h b/src/base58.h new file mode 100644 index 0000000..bee8e10 --- /dev/null +++ b/src/base58.h @@ -0,0 +1,422 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + + +// +// Why base-58 instead of standard base-64 encoding? +// - Don't want 0OIl characters that look the same in some fonts and +// could be used to create visually identical looking account numbers. +// - A string with non-alphanumeric characters is not as easily accepted as an account number. +// - E-mail usually won't line-break if there's no punctuation to break at. +// - Double-clicking selects the whole number as one word if it's all alphanumeric. +// +#ifndef BITCOIN_BASE58_H +#define BITCOIN_BASE58_H + +#include +#include + +#include "chainparams.h" +#include "bignum.h" +#include "key.h" +#include "script.h" +#include "allocators.h" +#include "util.h" + +static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + +// Encode a byte sequence as a base58-encoded string +inline std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend) +{ + CAutoBN_CTX pctx; + CBigNum bn58 = 58; + CBigNum bn0 = 0; + + // Convert big endian data to little endian + // Extra zero at the end make sure bignum will interpret as a positive number + std::vector vchTmp(pend-pbegin+1, 0); + reverse_copy(pbegin, pend, vchTmp.begin()); + + // Convert little endian data to bignum + CBigNum bn; + bn.setvch(vchTmp); + + // Convert bignum to std::string + std::string str; + // Expected size increase from base58 conversion is approximately 137% + // use 138% to be safe + str.reserve((pend - pbegin) * 138 / 100 + 1); + CBigNum dv; + CBigNum rem; + while (bn > bn0) + { + if (!BN_div(&dv, &rem, &bn, &bn58, pctx)) + throw bignum_error("EncodeBase58 : BN_div failed"); + bn = dv; + unsigned int c = rem.getulong(); + str += pszBase58[c]; + } + + // Leading zeroes encoded as base58 zeros + for (const unsigned char* p = pbegin; p < pend && *p == 0; p++) + str += pszBase58[0]; + + // Convert little endian std::string to big endian + reverse(str.begin(), str.end()); + return str; +} + +// Encode a byte vector as a base58-encoded string +inline std::string EncodeBase58(const std::vector& vch) +{ + return EncodeBase58(&vch[0], &vch[0] + vch.size()); +} + +// Decode a base58-encoded string psz into byte vector vchRet +// returns true if decoding is successful +inline bool DecodeBase58(const char* psz, std::vector& vchRet) +{ + CAutoBN_CTX pctx; + vchRet.clear(); + CBigNum bn58 = 58; + CBigNum bn = 0; + CBigNum bnChar; + while (isspace(*psz)) + psz++; + + // Convert big endian string to bignum + for (const char* p = psz; *p; p++) + { + const char* p1 = strchr(pszBase58, *p); + if (p1 == NULL) + { + while (isspace(*p)) + p++; + if (*p != '\0') + return false; + break; + } + bnChar.setulong(p1 - pszBase58); + if (!BN_mul(&bn, &bn, &bn58, pctx)) + throw bignum_error("DecodeBase58 : BN_mul failed"); + bn += bnChar; + } + + // Get bignum as little endian data + std::vector vchTmp = bn.getvch(); + + // Trim off sign byte if present + if (vchTmp.size() >= 2 && vchTmp.end()[-1] == 0 && vchTmp.end()[-2] >= 0x80) + vchTmp.erase(vchTmp.end()-1); + + // Restore leading zeros + int nLeadingZeros = 0; + for (const char* p = psz; *p == pszBase58[0]; p++) + nLeadingZeros++; + vchRet.assign(nLeadingZeros + vchTmp.size(), 0); + + // Convert little endian data to big endian + reverse_copy(vchTmp.begin(), vchTmp.end(), vchRet.end() - vchTmp.size()); + return true; +} + +// Decode a base58-encoded string str into byte vector vchRet +// returns true if decoding is successful +inline bool DecodeBase58(const std::string& str, std::vector& vchRet) +{ + return DecodeBase58(str.c_str(), vchRet); +} + + + + +// Encode a byte vector to a base58-encoded string, including checksum +inline std::string EncodeBase58Check(const std::vector& vchIn) +{ + // add 4-byte hash check to the end + std::vector vch(vchIn); + uint256 hash = Hash(vch.begin(), vch.end()); + vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4); + return EncodeBase58(vch); +} + +// Decode a base58-encoded string psz that includes a checksum, into byte vector vchRet +// returns true if decoding is successful +inline bool DecodeBase58Check(const char* psz, std::vector& vchRet) +{ + if (!DecodeBase58(psz, vchRet)) + return false; + if (vchRet.size() < 4) + { + vchRet.clear(); + return false; + } + uint256 hash = Hash(vchRet.begin(), vchRet.end()-4); + if (memcmp(&hash, &vchRet.end()[-4], 4) != 0) + { + vchRet.clear(); + return false; + } + vchRet.resize(vchRet.size()-4); + return true; +} + +// Decode a base58-encoded string str that includes a checksum, into byte vector vchRet +// returns true if decoding is successful +inline bool DecodeBase58Check(const std::string& str, std::vector& vchRet) +{ + return DecodeBase58Check(str.c_str(), vchRet); +} + + + + + +/** Base class for all base58-encoded data */ +class CBase58Data +{ +protected: + // the version byte(s) + std::vector vchVersion; + + // the actually encoded data + typedef std::vector > vector_uchar; + vector_uchar vchData; + + CBase58Data() + { + vchVersion.clear(); + vchData.clear(); + } + + void SetData(const std::vector &vchVersionIn, const void* pdata, size_t nSize) + { + vchVersion = vchVersionIn; + vchData.resize(nSize); + if (!vchData.empty()) + memcpy(&vchData[0], pdata, nSize); + } + + void SetData(const std::vector &vchVersionIn, const unsigned char *pbegin, const unsigned char *pend) + { + SetData(vchVersionIn, (void*)pbegin, pend - pbegin); + } + +public: + bool SetString(const char* psz, unsigned int nVersionBytes = 1) + { + std::vector vchTemp; + DecodeBase58Check(psz, vchTemp); + if (vchTemp.size() < nVersionBytes) + { + vchData.clear(); + vchVersion.clear(); + return false; + } + vchVersion.assign(vchTemp.begin(), vchTemp.begin() + nVersionBytes); + vchData.resize(vchTemp.size() - nVersionBytes); + if (!vchData.empty()) + memcpy(&vchData[0], &vchTemp[nVersionBytes], vchData.size()); + OPENSSL_cleanse(&vchTemp[0], vchData.size()); + return true; + } + + bool SetString(const std::string& str) + { + return SetString(str.c_str()); + } + + std::string ToString() const + { + std::vector vch = vchVersion; + vch.insert(vch.end(), vchData.begin(), vchData.end()); + return EncodeBase58Check(vch); + } + + int CompareTo(const CBase58Data& b58) const + { + if (vchVersion < b58.vchVersion) return -1; + if (vchVersion > b58.vchVersion) return 1; + if (vchData < b58.vchData) return -1; + if (vchData > b58.vchData) return 1; + return 0; + } + + bool operator==(const CBase58Data& b58) const { return CompareTo(b58) == 0; } + bool operator<=(const CBase58Data& b58) const { return CompareTo(b58) <= 0; } + bool operator>=(const CBase58Data& b58) const { return CompareTo(b58) >= 0; } + bool operator< (const CBase58Data& b58) const { return CompareTo(b58) < 0; } + bool operator> (const CBase58Data& b58) const { return CompareTo(b58) > 0; } +}; + +/** base58-encoded addresses. + * Public-key-hash-addresses have version 25 (or 111 testnet). + * The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key. + * Script-hash-addresses have version 85 (or 196 testnet). + * The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script. + */ +class CBitcoinAddress; +class CBitcoinAddressVisitor : public boost::static_visitor +{ +private: + CBitcoinAddress *addr; +public: + CBitcoinAddressVisitor(CBitcoinAddress *addrIn) : addr(addrIn) { } + bool operator()(const CKeyID &id) const; + bool operator()(const CScriptID &id) const; + bool operator()(const CStealthAddress &stxAddr) const; + bool operator()(const CNoDestination &no) const; +}; + +class CBitcoinAddress : public CBase58Data +{ +public: + bool Set(const CKeyID &id) { + SetData(Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS), &id, 20); + return true; + } + + bool Set(const CScriptID &id) { + SetData(Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS), &id, 20); + return true; + } + + bool Set(const CTxDestination &dest) + { + return boost::apply_visitor(CBitcoinAddressVisitor(this), dest); + } + + bool IsValid() const + { + bool fCorrectSize = vchData.size() == 20; + bool fKnownVersion = vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS) || + vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS); + return fCorrectSize && fKnownVersion; + } + + CBitcoinAddress() + { + } + + CBitcoinAddress(const CTxDestination &dest) + { + Set(dest); + } + + CBitcoinAddress(const std::string& strAddress) + { + SetString(strAddress); + } + + CBitcoinAddress(const char* pszAddress) + { + SetString(pszAddress); + } + + CTxDestination Get() const { + if (!IsValid()) + return CNoDestination(); + uint160 id; + memcpy(&id, &vchData[0], 20); + if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) + return CKeyID(id); + else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS)) + return CScriptID(id); + else + return CNoDestination(); + } + + bool GetKeyID(CKeyID &keyID) const { + if (!IsValid() || vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) + return false; + uint160 id; + memcpy(&id, &vchData[0], 20); + keyID = CKeyID(id); + return true; + } + + bool IsScript() const { + return IsValid() && vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS); + } +}; + +bool inline CBitcoinAddressVisitor::operator()(const CKeyID &id) const { return addr->Set(id); } +bool inline CBitcoinAddressVisitor::operator()(const CScriptID &id) const { return addr->Set(id); } +bool inline CBitcoinAddressVisitor::operator()(const CStealthAddress &stxAddr) const { return false; } +bool inline CBitcoinAddressVisitor::operator()(const CNoDestination &id) const { return false; } + +/** A base58-encoded secret key */ +class CBitcoinSecret : public CBase58Data +{ +public: + void SetKey(const CKey& vchSecret) + { + assert(vchSecret.IsValid()); + SetData(Params().Base58Prefix(CChainParams::SECRET_KEY), vchSecret.begin(), vchSecret.size()); + if (vchSecret.IsCompressed()) + vchData.push_back(1); + } + + CKey GetKey() + { + CKey ret; + ret.Set(&vchData[0], &vchData[32], vchData.size() > 32 && vchData[32] == 1); + return ret; + } + + bool IsValid() const + { + bool fExpectedFormat = vchData.size() == 32 || (vchData.size() == 33 && vchData[32] == 1); + bool fCorrectVersion = vchVersion == Params().Base58Prefix(CChainParams::SECRET_KEY); + return fExpectedFormat && fCorrectVersion; + } + + bool SetString(const char* pszSecret) + { + return CBase58Data::SetString(pszSecret) && IsValid(); + } + + bool SetString(const std::string& strSecret) + { + return SetString(strSecret.c_str()); + } + + CBitcoinSecret(const CKey& vchSecret) + { + SetKey(vchSecret); + } + + CBitcoinSecret() + { + } +}; + + +template class CBitcoinExtKeyBase : public CBase58Data +{ +public: + void SetKey(const K &key) { + unsigned char vch[Size]; + key.Encode(vch); + SetData(Params().Base58Prefix(Type), vch, vch+Size); + } + + K GetKey() { + K ret; + ret.Decode(&vchData[0], &vchData[Size]); + return ret; + } + + CBitcoinExtKeyBase(const K &key) { + SetKey(key); + } + + CBitcoinExtKeyBase() {} +}; + +typedef CBitcoinExtKeyBase CBitcoinExtKey; +typedef CBitcoinExtKeyBase CBitcoinExtPubKey; + +#endif // BITCOIN_BASE58_H diff --git a/src/bignum.h b/src/bignum.h new file mode 100644 index 0000000..2352e7b --- /dev/null +++ b/src/bignum.h @@ -0,0 +1,726 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_BIGNUM_H +#define BITCOIN_BIGNUM_H + +#include "serialize.h" +#include "uint256.h" +#include "version.h" + +#include + +#include +#include + +#include + +/** Errors thrown by the bignum class */ +class bignum_error : public std::runtime_error +{ +public: + explicit bignum_error(const std::string& str) : std::runtime_error(str) {} +}; + + +/** RAII encapsulated BN_CTX (OpenSSL bignum context) */ +class CAutoBN_CTX +{ +protected: + BN_CTX* pctx; + BN_CTX* operator=(BN_CTX* pnew) { return pctx = pnew; } + +public: + CAutoBN_CTX() + { + pctx = BN_CTX_new(); + if (pctx == NULL) + throw bignum_error("CAutoBN_CTX : BN_CTX_new() returned NULL"); + } + + ~CAutoBN_CTX() + { + if (pctx != NULL) + BN_CTX_free(pctx); + } + + operator BN_CTX*() { return pctx; } + BN_CTX& operator*() { return *pctx; } + BN_CTX** operator&() { return &pctx; } + bool operator!() { return (pctx == NULL); } +}; + + +/** C++ wrapper for BIGNUM (OpenSSL bignum) */ +class CBigNum : public BIGNUM +{ +public: + CBigNum() + { + BN_init(this); + } + + CBigNum(const CBigNum& b) + { + BN_init(this); + if (!BN_copy(this, &b)) + { + BN_clear_free(this); + throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed"); + } + } + + CBigNum& operator=(const CBigNum& b) + { + if (!BN_copy(this, &b)) + throw bignum_error("CBigNum::operator= : BN_copy failed"); + return (*this); + } + + ~CBigNum() + { + BN_clear_free(this); + } + + //CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'. + CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(long long n) { BN_init(this); setint64(n); } + CBigNum(unsigned char n) { BN_init(this); setulong(n); } + CBigNum(unsigned short n) { BN_init(this); setulong(n); } + CBigNum(unsigned int n) { BN_init(this); setulong(n); } + CBigNum(unsigned long n) { BN_init(this); setulong(n); } + CBigNum(unsigned long long n) { BN_init(this); setuint64(n); } + explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); } + + explicit CBigNum(const std::vector& vch) + { + BN_init(this); + setvch(vch); + } + + /** Generates a cryptographically secure random number between zero and range exclusive + * i.e. 0 < returned number < range + * @param range The upper bound on the number. + * @return + */ + static CBigNum randBignum(const CBigNum& range) { + CBigNum ret; + if(!BN_rand_range(&ret, &range)){ + throw bignum_error("CBigNum:rand element : BN_rand_range failed"); + } + return ret; + } + + /** Generates a cryptographically secure random k-bit number + * @param k The bit length of the number. + * @return + */ + static CBigNum RandKBitBigum(const uint32_t k){ + CBigNum ret; + if(!BN_rand(&ret, k, -1, 0)){ + throw bignum_error("CBigNum:rand element : BN_rand failed"); + } + return ret; + } + + /**Returns the size in bits of the underlying bignum. + * + * @return the size + */ + int bitSize() const{ + return BN_num_bits(this); + } + + + void setulong(unsigned long n) + { + if (!BN_set_word(this, n)) + throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed"); + } + + unsigned long getulong() const + { + return BN_get_word(this); + } + + unsigned int getuint() const + { + return BN_get_word(this); + } + + int getint() const + { + unsigned long n = BN_get_word(this); + if (!BN_is_negative(this)) + return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::max() : n); + else + return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); + } + + void setint64(int64_t sn) + { + unsigned char pch[sizeof(sn) + 6]; + unsigned char* p = pch + 4; + bool fNegative; + uint64_t n; + + if (sn < (int64_t)0) + { + // Since the minimum signed integer cannot be represented as positive so long as its type is signed, and it's not well-defined what happens if you make it unsigned before negating it, we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate + n = -(sn + 1); + ++n; + fNegative = true; + } else { + n = sn; + fNegative = false; + } + + bool fLeadingZeroes = true; + for (int i = 0; i < 8; i++) + { + unsigned char c = (n >> 56) & 0xff; + n <<= 8; + if (fLeadingZeroes) + { + if (c == 0) + continue; + if (c & 0x80) + *p++ = (fNegative ? 0x80 : 0); + else if (fNegative) + c |= 0x80; + fLeadingZeroes = false; + } + *p++ = c; + } + unsigned int nSize = p - (pch + 4); + pch[0] = (nSize >> 24) & 0xff; + pch[1] = (nSize >> 16) & 0xff; + pch[2] = (nSize >> 8) & 0xff; + pch[3] = (nSize) & 0xff; + BN_mpi2bn(pch, p - pch, this); + } + + uint64_t getuint64() + { + unsigned int nSize = BN_bn2mpi(this, NULL); + if (nSize < 4) + return 0; + std::vector vch(nSize); + BN_bn2mpi(this, &vch[0]); + if (vch.size() > 4) + vch[4] &= 0x7f; + uint64_t n = 0; + for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--) + ((unsigned char*)&n)[i] = vch[j]; + return n; + } + + void setuint64(uint64_t n) + { + unsigned char pch[sizeof(n) + 6]; + unsigned char* p = pch + 4; + bool fLeadingZeroes = true; + for (int i = 0; i < 8; i++) + { + unsigned char c = (n >> 56) & 0xff; + n <<= 8; + if (fLeadingZeroes) + { + if (c == 0) + continue; + if (c & 0x80) + *p++ = 0; + fLeadingZeroes = false; + } + *p++ = c; + } + unsigned int nSize = p - (pch + 4); + pch[0] = (nSize >> 24) & 0xff; + pch[1] = (nSize >> 16) & 0xff; + pch[2] = (nSize >> 8) & 0xff; + pch[3] = (nSize) & 0xff; + BN_mpi2bn(pch, p - pch, this); + } + + void setuint256(uint256 n) + { + unsigned char pch[sizeof(n) + 6]; + unsigned char* p = pch + 4; + bool fLeadingZeroes = true; + unsigned char* pbegin = (unsigned char*)&n; + unsigned char* psrc = pbegin + sizeof(n); + while (psrc != pbegin) + { + unsigned char c = *(--psrc); + if (fLeadingZeroes) + { + if (c == 0) + continue; + if (c & 0x80) + *p++ = 0; + fLeadingZeroes = false; + } + *p++ = c; + } + unsigned int nSize = p - (pch + 4); + pch[0] = (nSize >> 24) & 0xff; + pch[1] = (nSize >> 16) & 0xff; + pch[2] = (nSize >> 8) & 0xff; + pch[3] = (nSize >> 0) & 0xff; + BN_mpi2bn(pch, p - pch, this); + } + + uint256 getuint256() const + { + unsigned int nSize = BN_bn2mpi(this, NULL); + if (nSize < 4) + return 0; + std::vector vch(nSize); + BN_bn2mpi(this, &vch[0]); + if (vch.size() > 4) + vch[4] &= 0x7f; + uint256 n = 0; + for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--) + ((unsigned char*)&n)[i] = vch[j]; + return n; + } + + + void setvch(const std::vector& vch) + { + std::vector vch2(vch.size() + 4); + unsigned int nSize = vch.size(); + // BIGNUM's byte stream format expects 4 bytes of + // big endian size data info at the front + vch2[0] = (nSize >> 24) & 0xff; + vch2[1] = (nSize >> 16) & 0xff; + vch2[2] = (nSize >> 8) & 0xff; + vch2[3] = (nSize >> 0) & 0xff; + // swap data to big endian + reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4); + BN_mpi2bn(&vch2[0], vch2.size(), this); + } + + std::vector getvch() const + { + unsigned int nSize = BN_bn2mpi(this, NULL); + if (nSize <= 4) + return std::vector(); + std::vector vch(nSize); + BN_bn2mpi(this, &vch[0]); + vch.erase(vch.begin(), vch.begin() + 4); + reverse(vch.begin(), vch.end()); + return vch; + } + + CBigNum& SetCompact(unsigned int nCompact) + { + unsigned int nSize = nCompact >> 24; + std::vector vch(4 + nSize); + vch[3] = nSize; + if (nSize >= 1) vch[4] = (nCompact >> 16) & 0xff; + if (nSize >= 2) vch[5] = (nCompact >> 8) & 0xff; + if (nSize >= 3) vch[6] = (nCompact >> 0) & 0xff; + BN_mpi2bn(&vch[0], vch.size(), this); + return *this; + } + + unsigned int GetCompact() const + { + unsigned int nSize = BN_bn2mpi(this, NULL); + std::vector vch(nSize); + nSize -= 4; + BN_bn2mpi(this, &vch[0]); + unsigned int nCompact = nSize << 24; + if (nSize >= 1) nCompact |= (vch[4] << 16); + if (nSize >= 2) nCompact |= (vch[5] << 8); + if (nSize >= 3) nCompact |= (vch[6] << 0); + return nCompact; + } + + void SetHex(const std::string& str) + { + // skip 0x + const char* psz = str.c_str(); + while (isspace(*psz)) + psz++; + bool fNegative = false; + if (*psz == '-') + { + fNegative = true; + psz++; + } + if (psz[0] == '0' && tolower(psz[1]) == 'x') + psz += 2; + while (isspace(*psz)) + psz++; + + // hex string to bignum + static const signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 }; + *this = 0; + while (isxdigit(*psz)) + { + *this <<= 4; + int n = phexdigit[(unsigned char)*psz++]; + *this += n; + } + if (fNegative) + *this = 0 - *this; + } + + std::string ToString(int nBase=10) const + { + CAutoBN_CTX pctx; + CBigNum bnBase = nBase; + CBigNum bn0 = 0; + std::string str; + CBigNum bn = *this; + BN_set_negative(&bn, false); + CBigNum dv; + CBigNum rem; + if (BN_cmp(&bn, &bn0) == 0) + return "0"; + while (BN_cmp(&bn, &bn0) > 0) + { + if (!BN_div(&dv, &rem, &bn, &bnBase, pctx)) + throw bignum_error("CBigNum::ToString() : BN_div failed"); + bn = dv; + unsigned int c = rem.getulong(); + str += "0123456789abcdef"[c]; + } + if (BN_is_negative(this)) + str += "-"; + reverse(str.begin(), str.end()); + return str; + } + + std::string GetHex() const + { + return ToString(16); + } + + unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const + { + return ::GetSerializeSize(getvch(), nType, nVersion); + } + + template + void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const + { + ::Serialize(s, getvch(), nType, nVersion); + } + + template + void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) + { + std::vector vch; + ::Unserialize(s, vch, nType, nVersion); + setvch(vch); + } + + /** + * exponentiation with an int. this^e + * @param e the exponent as an int + * @return + */ + CBigNum pow(const int e) const { + return this->pow(CBigNum(e)); + } + + /** + * exponentiation this^e + * @param e the exponent + * @return + */ + CBigNum pow(const CBigNum& e) const { + CAutoBN_CTX pctx; + CBigNum ret; + if (!BN_exp(&ret, this, &e, pctx)) + throw bignum_error("CBigNum::pow : BN_exp failed"); + return ret; + } + + /** + * modular multiplication: (this * b) mod m + * @param b operand + * @param m modulus + */ + CBigNum mul_mod(const CBigNum& b, const CBigNum& m) const { + CAutoBN_CTX pctx; + CBigNum ret; + if (!BN_mod_mul(&ret, this, &b, &m, pctx)) + throw bignum_error("CBigNum::mul_mod : BN_mod_mul failed"); + + return ret; + } + + /** + * modular exponentiation: this^e mod n + * @param e exponent + * @param m modulus + */ + CBigNum pow_mod(const CBigNum& e, const CBigNum& m) const { + CAutoBN_CTX pctx; + CBigNum ret; + if( e < 0){ + // g^-x = (g^-1)^x + CBigNum inv = this->inverse(m); + CBigNum posE = e * -1; + if (!BN_mod_exp(&ret, &inv, &posE, &m, pctx)) + throw bignum_error("CBigNum::pow_mod: BN_mod_exp failed on negative exponent"); + }else + if (!BN_mod_exp(&ret, this, &e, &m, pctx)) + throw bignum_error("CBigNum::pow_mod : BN_mod_exp failed"); + + return ret; + } + + /** + * Calculates the inverse of this element mod m. + * i.e. i such this*i = 1 mod m + * @param m the modu + * @return the inverse + */ + CBigNum inverse(const CBigNum& m) const { + CAutoBN_CTX pctx; + CBigNum ret; + if (!BN_mod_inverse(&ret, this, &m, pctx)) + throw bignum_error("CBigNum::inverse*= :BN_mod_inverse"); + return ret; + } + + /** + * Generates a random (safe) prime of numBits bits + * @param numBits the number of bits + * @param safe true for a safe prime + * @return the prime + */ + static CBigNum generatePrime(const unsigned int numBits, bool safe = false) { + CBigNum ret; + if(!BN_generate_prime_ex(&ret, numBits, (safe == true), NULL, NULL, NULL)) + throw bignum_error("CBigNum::generatePrime*= :BN_generate_prime_ex"); + return ret; + } + + /** + * Calculates the greatest common divisor (GCD) of two numbers. + * @param m the second element + * @return the GCD + */ + CBigNum gcd( const CBigNum& b) const{ + CAutoBN_CTX pctx; + CBigNum ret; + if (!BN_gcd(&ret, this, &b, pctx)) + throw bignum_error("CBigNum::gcd*= :BN_gcd"); + return ret; + } + + /** + * Miller-Rabin primality test on this element + * @param checks: optional, the number of Miller-Rabin tests to run + * default causes error rate of 2^-80. + * @return true if prime + */ + bool isPrime(const int checks=BN_prime_checks) const { + CAutoBN_CTX pctx; + int ret = BN_is_prime(this, checks, NULL, pctx, NULL); + if(ret < 0){ + throw bignum_error("CBigNum::isPrime :BN_is_prime"); + } + return ret; + } + + bool isOne() const { + return BN_is_one(this); + } + + + bool operator!() const + { + return BN_is_zero(this); + } + + CBigNum& operator+=(const CBigNum& b) + { + if (!BN_add(this, this, &b)) + throw bignum_error("CBigNum::operator+= : BN_add failed"); + return *this; + } + + CBigNum& operator-=(const CBigNum& b) + { + *this = *this - b; + return *this; + } + + CBigNum& operator*=(const CBigNum& b) + { + CAutoBN_CTX pctx; + if (!BN_mul(this, this, &b, pctx)) + throw bignum_error("CBigNum::operator*= : BN_mul failed"); + return *this; + } + + CBigNum& operator/=(const CBigNum& b) + { + *this = *this / b; + return *this; + } + + CBigNum& operator%=(const CBigNum& b) + { + *this = *this % b; + return *this; + } + + CBigNum& operator<<=(unsigned int shift) + { + if (!BN_lshift(this, this, shift)) + throw bignum_error("CBigNum:operator<<= : BN_lshift failed"); + return *this; + } + + CBigNum& operator>>=(unsigned int shift) + { + // Note: BN_rshift segfaults on 64-bit if 2^shift is greater than the number + // if built on ubuntu 9.04 or 9.10, probably depends on version of OpenSSL + CBigNum a = 1; + a <<= shift; + if (BN_cmp(&a, this) > 0) + { + *this = 0; + return *this; + } + + if (!BN_rshift(this, this, shift)) + throw bignum_error("CBigNum:operator>>= : BN_rshift failed"); + return *this; + } + + + CBigNum& operator++() + { + // prefix operator + if (!BN_add(this, this, BN_value_one())) + throw bignum_error("CBigNum::operator++ : BN_add failed"); + return *this; + } + + const CBigNum operator++(int) + { + // postfix operator + const CBigNum ret = *this; + ++(*this); + return ret; + } + + CBigNum& operator--() + { + // prefix operator + CBigNum r; + if (!BN_sub(&r, this, BN_value_one())) + throw bignum_error("CBigNum::operator-- : BN_sub failed"); + *this = r; + return *this; + } + + const CBigNum operator--(int) + { + // postfix operator + const CBigNum ret = *this; + --(*this); + return ret; + } + + + friend inline const CBigNum operator-(const CBigNum& a, const CBigNum& b); + friend inline const CBigNum operator/(const CBigNum& a, const CBigNum& b); + friend inline const CBigNum operator%(const CBigNum& a, const CBigNum& b); + friend inline const CBigNum operator*(const CBigNum& a, const CBigNum& b); + friend inline bool operator<(const CBigNum& a, const CBigNum& b); +}; + + + +inline const CBigNum operator+(const CBigNum& a, const CBigNum& b) +{ + CBigNum r; + if (!BN_add(&r, &a, &b)) + throw bignum_error("CBigNum::operator+ : BN_add failed"); + return r; +} + +inline const CBigNum operator-(const CBigNum& a, const CBigNum& b) +{ + CBigNum r; + if (!BN_sub(&r, &a, &b)) + throw bignum_error("CBigNum::operator- : BN_sub failed"); + return r; +} + +inline const CBigNum operator-(const CBigNum& a) +{ + CBigNum r(a); + BN_set_negative(&r, !BN_is_negative(&r)); + return r; +} + +inline const CBigNum operator*(const CBigNum& a, const CBigNum& b) +{ + CAutoBN_CTX pctx; + CBigNum r; + if (!BN_mul(&r, &a, &b, pctx)) + throw bignum_error("CBigNum::operator* : BN_mul failed"); + return r; +} + +inline const CBigNum operator/(const CBigNum& a, const CBigNum& b) +{ + CAutoBN_CTX pctx; + CBigNum r; + if (!BN_div(&r, NULL, &a, &b, pctx)) + throw bignum_error("CBigNum::operator/ : BN_div failed"); + return r; +} + +inline const CBigNum operator%(const CBigNum& a, const CBigNum& b) +{ + CAutoBN_CTX pctx; + CBigNum r; + if (!BN_nnmod(&r, &a, &b, pctx)) + throw bignum_error("CBigNum::operator% : BN_div failed"); + return r; +} + +inline const CBigNum operator<<(const CBigNum& a, unsigned int shift) +{ + CBigNum r; + if (!BN_lshift(&r, &a, shift)) + throw bignum_error("CBigNum:operator<< : BN_lshift failed"); + return r; +} + +inline const CBigNum operator>>(const CBigNum& a, unsigned int shift) +{ + CBigNum r = a; + r >>= shift; + return r; +} + +inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) == 0); } +inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) != 0); } +inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) <= 0); } +inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) >= 0); } +inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) < 0); } +inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) > 0); } + +inline std::ostream& operator<<(std::ostream &strm, const CBigNum &b) { return strm << b.ToString(10); } + +typedef CBigNum Bignum; + +#endif diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp new file mode 100644 index 0000000..64d1d36 --- /dev/null +++ b/src/bitcoind.cpp @@ -0,0 +1,141 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "rpcserver.h" +#include "rpcclient.h" +#include "init.h" +#include + +void WaitForShutdown(boost::thread_group* threadGroup) +{ + bool fShutdown = ShutdownRequested(); + // Tell the main threads to shutdown. + while (!fShutdown) + { + MilliSleep(200); + fShutdown = ShutdownRequested(); + } + if (threadGroup) + { + threadGroup->interrupt_all(); + threadGroup->join_all(); + } +} + +////////////////////////////////////////////////////////////////////////////// +// +// Start +// +bool AppInit(int argc, char* argv[]) +{ + boost::thread_group threadGroup; + + bool fRet = false; + try + { + // + // Parameters + // + // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main() + ParseParameters(argc, argv); + if (!boost::filesystem::is_directory(GetDataDir(false))) + { + fprintf(stderr, "Error: Specified directory does not exist\n"); + Shutdown(); + } + ReadConfigFile(mapArgs, mapMultiArgs); + + if (mapArgs.count("-?") || mapArgs.count("--help")) + { + // First part of help message is specific to bitcoind / RPC client + std::string strUsage = _("SONO version") + " " + FormatFullVersion() + "\n\n" + + _("Usage:") + "\n" + + " SONOd [options] " + "\n" + + " SONOd [options] [params] " + _("Send command to -server or SONOd") + "\n" + + " SONOd [options] help " + _("List commands") + "\n" + + " SONOd [options] help " + _("Get help for a command") + "\n"; + + strUsage += "\n" + HelpMessage(); + + fprintf(stdout, "%s", strUsage.c_str()); + return false; + } + + // Command-line RPC + for (int i = 1; i < argc; i++) + if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "SONO:")) + fCommandLine = true; + + if (fCommandLine) + { + if (!SelectParamsFromCommandLine()) { + fprintf(stderr, "Error: invalid combination of -regtest and -testnet.\n"); + return false; + } + int ret = CommandLineRPC(argc, argv); + exit(ret); + } +#if !defined(WIN32) + fDaemon = GetBoolArg("-daemon", false); + if (fDaemon) + { + // Daemonize + pid_t pid = fork(); + if (pid < 0) + { + fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno); + return false; + } + if (pid > 0) // Parent process, pid is child process id + { + CreatePidFile(GetPidFile(), pid); + return true; + } + // Child process falls through to rest of initialization + + pid_t sid = setsid(); + if (sid < 0) + fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno); + } +#endif + + fRet = AppInit2(threadGroup); + } + catch (std::exception& e) { + PrintException(&e, "AppInit()"); + } catch (...) { + PrintException(NULL, "AppInit()"); + } + + if (!fRet) + { + threadGroup.interrupt_all(); + // threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of + // the startup-failure cases to make sure they don't result in a hang due to some + // thread-blocking-waiting-for-another-thread-during-startup case + } else { + WaitForShutdown(&threadGroup); + } + Shutdown(); + + return fRet; +} + +extern void noui_connect(); +int main(int argc, char* argv[]) +{ + bool fRet = false; + fHaveGUI = false; + + // Connect bitcoind signal handlers + noui_connect(); + + fRet = AppInit(argc, argv); + + if (fRet && fDaemon) + return 0; + + return (fRet ? 0 : 1); +} diff --git a/src/bloom.cpp b/src/bloom.cpp new file mode 100644 index 0000000..ea0d12b --- /dev/null +++ b/src/bloom.cpp @@ -0,0 +1,182 @@ +// Copyright (c) 2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include +#include + +#include "bloom.h" +#include "main.h" +#include "script.h" +#include "hash.h" +#define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455 +#define LN2 0.6931471805599453094172321214581765680755001343602552 + +using namespace std; + +static const unsigned char bit_mask[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; + +CBloomFilter::CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweakIn, unsigned char nFlagsIn) : +// The ideal size for a bloom filter with a given number of elements and false positive rate is: +// - nElements * log(fp rate) / ln(2)^2 +// We ignore filter parameters which will create a bloom filter larger than the protocol limits +vData(min((unsigned int)(-1 / LN2SQUARED * nElements * log(nFPRate)), MAX_BLOOM_FILTER_SIZE * 8) / 8), +// The ideal number of hash functions is filter size * ln(2) / number of elements +// Again, we ignore filter parameters which will create a bloom filter with more hash functions than the protocol limits +// See http://en.wikipedia.org/wiki/Bloom_filter for an explanation of these formulas +isFull(false), +isEmpty(false), +nHashFuncs(min((unsigned int)(vData.size() * 8 / nElements * LN2), MAX_HASH_FUNCS)), +nTweak(nTweakIn), +nFlags(nFlagsIn) +{ +} + +inline unsigned int CBloomFilter::Hash(unsigned int nHashNum, const std::vector& vDataToHash) const +{ + // 0xFBA4C795 chosen as it guarantees a reasonable bit difference between nHashNum values. + return MurmurHash3(nHashNum * 0xFBA4C795 + nTweak, vDataToHash) % (vData.size() * 8); +} + +void CBloomFilter::insert(const vector& vKey) +{ + if (isFull) + return; + for (unsigned int i = 0; i < nHashFuncs; i++) + { + unsigned int nIndex = Hash(i, vKey); + // Sets bit nIndex of vData + vData[nIndex >> 3] |= bit_mask[7 & nIndex]; + } + isEmpty = false; +} + +void CBloomFilter::insert(const COutPoint& outpoint) +{ + CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); + stream << outpoint; + vector data(stream.begin(), stream.end()); + insert(data); +} + +void CBloomFilter::insert(const uint256& hash) +{ + vector data(hash.begin(), hash.end()); + insert(data); +} + +bool CBloomFilter::contains(const vector& vKey) const +{ + if (isFull) + return true; + if (isEmpty) + return false; + for (unsigned int i = 0; i < nHashFuncs; i++) + { + unsigned int nIndex = Hash(i, vKey); + // Checks bit nIndex of vData + if (!(vData[nIndex >> 3] & bit_mask[7 & nIndex])) + return false; + } + return true; +} + +bool CBloomFilter::contains(const COutPoint& outpoint) const +{ + CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); + stream << outpoint; + vector data(stream.begin(), stream.end()); + return contains(data); +} + +bool CBloomFilter::contains(const uint256& hash) const +{ + vector data(hash.begin(), hash.end()); + return contains(data); +} + +bool CBloomFilter::IsWithinSizeConstraints() const +{ + return vData.size() <= MAX_BLOOM_FILTER_SIZE && nHashFuncs <= MAX_HASH_FUNCS; +} + +bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx, const uint256& hash) +{ + bool fFound = false; + // Match if the filter contains the hash of tx + // for finding tx when they appear in a block + if (isFull) + return true; + if (isEmpty) + return false; + if (contains(hash)) + fFound = true; + + for (unsigned int i = 0; i < tx.vout.size(); i++) + { + const CTxOut& txout = tx.vout[i]; + // Match if the filter contains any arbitrary script data element in any scriptPubKey in tx + // If this matches, also add the specific output that was matched. + // This means clients don't have to update the filter themselves when a new relevant tx + // is discovered in order to find spending transactions, which avoids round-tripping and race conditions. + CScript::const_iterator pc = txout.scriptPubKey.begin(); + vector data; + while (pc < txout.scriptPubKey.end()) + { + opcodetype opcode; + if (!txout.scriptPubKey.GetOp(pc, opcode, data)) + break; + if (data.size() != 0 && contains(data)) + { + fFound = true; + if ((nFlags & BLOOM_UPDATE_MASK) == BLOOM_UPDATE_ALL) + insert(COutPoint(hash, i)); + else if ((nFlags & BLOOM_UPDATE_MASK) == BLOOM_UPDATE_P2PUBKEY_ONLY) + { + txnouttype type; + vector > vSolutions; + if (Solver(txout.scriptPubKey, type, vSolutions) && + (type == TX_PUBKEY || type == TX_MULTISIG)) + insert(COutPoint(hash, i)); + } + break; + } + } + } + + if (fFound) + return true; + + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + // Match if the filter contains an outpoint tx spends + if (contains(txin.prevout)) + return true; + + // Match if the filter contains any arbitrary script data element in any scriptSig in tx + CScript::const_iterator pc = txin.scriptSig.begin(); + vector data; + while (pc < txin.scriptSig.end()) + { + opcodetype opcode; + if (!txin.scriptSig.GetOp(pc, opcode, data)) + break; + if (data.size() != 0 && contains(data)) + return true; + } + } + + return false; +} + +void CBloomFilter::UpdateEmptyFull() +{ + bool full = true; + bool empty = true; + for (unsigned int i = 0; i < vData.size(); i++) + { + full &= vData[i] == 0xff; + empty &= vData[i] == 0; + } + isFull = full; + isEmpty = empty; +} diff --git a/src/bloom.h b/src/bloom.h new file mode 100644 index 0000000..f482bfc --- /dev/null +++ b/src/bloom.h @@ -0,0 +1,91 @@ +// Copyright (c) 2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_BLOOM_H +#define BITCOIN_BLOOM_H + +#include + +#include "uint256.h" +#include "serialize.h" + +class COutPoint; +class CTransaction; + +// 20,000 items with fp rate < 0.1% or 10,000 items and <0.0001% +static const unsigned int MAX_BLOOM_FILTER_SIZE = 36000; // bytes +static const unsigned int MAX_HASH_FUNCS = 50; + +// First two bits of nFlags control how much IsRelevantAndUpdate actually updates +// The remaining bits are reserved +enum bloomflags +{ + BLOOM_UPDATE_NONE = 0, + BLOOM_UPDATE_ALL = 1, + // Only adds outpoints to the filter if the output is a pay-to-pubkey/pay-to-multisig script + BLOOM_UPDATE_P2PUBKEY_ONLY = 2, + BLOOM_UPDATE_MASK = 3, +}; + +/** + * BloomFilter is a probabilistic filter which SPV clients provide + * so that we can filter the transactions we sends them. + * + * This allows for significantly more efficient transaction and block downloads. + * + * Because bloom filters are probabilistic, an SPV node can increase the false- + * positive rate, making us send them transactions which aren't actually theirs, + * allowing clients to trade more bandwidth for more privacy by obfuscating which + * keys are owned by them. + */ +class CBloomFilter +{ +private: + std::vector vData; + bool isFull; + bool isEmpty; + unsigned int nHashFuncs; + unsigned int nTweak; + unsigned char nFlags; + + unsigned int Hash(unsigned int nHashNum, const std::vector& vDataToHash) const; + +public: + // Creates a new bloom filter which will provide the given fp rate when filled with the given number of elements + // Note that if the given parameters will result in a filter outside the bounds of the protocol limits, + // the filter created will be as close to the given parameters as possible within the protocol limits. + // This will apply if nFPRate is very low or nElements is unreasonably high. + // nTweak is a constant which is added to the seed value passed to the hash function + // It should generally always be a random value (and is largely only exposed for unit testing) + // nFlags should be one of the BLOOM_UPDATE_* enums (not _MASK) + CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweak, unsigned char nFlagsIn); + CBloomFilter() : isFull(true) {} + + IMPLEMENT_SERIALIZE + ( + READWRITE(vData); + READWRITE(nHashFuncs); + READWRITE(nTweak); + READWRITE(nFlags); + ) + + void insert(const std::vector& vKey); + void insert(const COutPoint& outpoint); + void insert(const uint256& hash); + + bool contains(const std::vector& vKey) const; + bool contains(const COutPoint& outpoint) const; + bool contains(const uint256& hash) const; + + // True if the size is <= MAX_BLOOM_FILTER_SIZE and the number of hash functions is <= MAX_HASH_FUNCS + // (catch a filter which was just deserialized which was too big) + bool IsWithinSizeConstraints() const; + + // Also adds any outputs which match the filter to the filter (to match their spending txes) + bool IsRelevantAndUpdate(const CTransaction& tx, const uint256& hash); + + // Checks for empty and full filters to avoid wasting cpu + void UpdateEmptyFull(); +}; + +#endif /* BITCOIN_BLOOM_H */ diff --git a/src/chainparams.cpp b/src/chainparams.cpp new file mode 100644 index 0000000..c127eb3 --- /dev/null +++ b/src/chainparams.cpp @@ -0,0 +1,195 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// Masternode initilized & modified by 216k155. Used at your own risk. + +#include "assert.h" + +#include "chainparams.h" +#include "main.h" +#include "util.h" + +#include + +using namespace boost::assign; + +struct SeedSpec6 { + uint8_t addr[16]; + uint16_t port; +}; + +#include "chainparamsseeds.h" + +// Main network +// Follow my guide to generate new genesis block + +// Convert the pnSeeds6 array into usable address objects. +static void convertSeed6(std::vector &vSeedsOut, const SeedSpec6 *data, unsigned int count) +{ + // It'll only connect to one or two seed nodes because once it connects, + // it'll get a pile of addresses with newer timestamps. + // Seed nodes are given a random 'last seen time' of between one and two + // weeks ago. + const int64_t nOneWeek = 7*24*60*60; + for (unsigned int i = 0; i < count; i++) + { + struct in6_addr ip; + memcpy(&ip, data[i].addr, sizeof(ip)); + CAddress addr(CService(ip, data[i].port)); + addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek; + vSeedsOut.push_back(addr); + } +} + +class CMainParams : public CChainParams { +public: + CMainParams() { + // The message start string is designed to be unlikely to occur in normal data. + // The characters are rarely used upper ASCII, not valid as UTF-8, and produce + // a large 4-byte int at any alignment. + pchMessageStart[0] = 0x4a; + pchMessageStart[1] = 0x12; + pchMessageStart[2] = 0x22; + pchMessageStart[3] = 0x14; + vAlertPubKey = ParseHex("04e57adfbcdfad7c8131a7c77323fab6c1fdd44b0bdc2f969142d62b33246f37493babd68265e9e277a24fe92544596b5dad2df74763cc75c20bfde6e95603e714"); + nDefaultPort = 29855; + nRPCPort = 28855; + bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20); + + // Build the genesis block. Note that the output of the genesis coinbase cannot + // be spent as it did not originally exist in the database. + // + const char* pszTimestamp = "altcommunitycoin offically swapping"; + std::vector vin; + vin.resize(1); + vin[0].scriptSig = CScript() << 0 << CBigNum(42) << vector((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); + std::vector vout; + vout.resize(1); + vout[0].SetEmpty(); + CTransaction txNew(1, 1504894760, vin, vout, 0); + genesis.vtx.push_back(txNew); + genesis.hashPrevBlock = 0; + genesis.hashMerkleRoot = genesis.BuildMerkleTree(); + genesis.nVersion = 1; + genesis.nTime = 1504894760; + genesis.nBits = 0x1e0fffff; + genesis.nNonce = 718550; + + hashGenesisBlock = genesis.GetHash(); + assert(hashGenesisBlock == uint256("0x00000f14896ba98013ed07e0ecf6e29b360a20898aab5c23238fd08c17ac1b10")); + assert(genesis.hashMerkleRoot == uint256("0xcdcd7108ef39db12a5e03b30ef2790ac6ffb65436ea0beeb4c83adb72d79625b")); + + //MineGenesis(genesis); + + vSeeds.push_back(CDNSSeedData("109.230.231.216", "109.230.231.216")); + vSeeds.push_back(CDNSSeedData("159.65.28.130", "159.65.28.130")); + vSeeds.push_back(CDNSSeedData("159.65.28.135", "159.65.28.135")); + vSeeds.push_back(CDNSSeedData("188.68.56.33", "188.68.56.33")); + vSeeds.push_back(CDNSSeedData("185.194.142.254", "185.194.142.254")); + vSeeds.push_back(CDNSSeedData("37.120.184.247", "37.120.184.247")); + vSeeds.push_back(CDNSSeedData("zPools.de", "zPools.de")); + + + + base58Prefixes[PUBKEY_ADDRESS] = std::vector(1, 23); + base58Prefixes[SCRIPT_ADDRESS] = std::vector(1, 125); + base58Prefixes[SECRET_KEY] = std::vector(1, (63+128)); + base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xC2)(0x1E).convert_to_container >(); + base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0xDD).convert_to_container >(); + + convertSeed6(vFixedSeeds, pnSeed6_main, ARRAYLEN(pnSeed6_main)); + + nLastPOWBlock = 0x7fffffff; + } + + virtual const CBlock& GenesisBlock() const { return genesis; } + virtual Network NetworkID() const { return CChainParams::MAIN; } + + virtual const vector& FixedSeeds() const { + return vFixedSeeds; + } +protected: + CBlock genesis; + vector vFixedSeeds; +}; +static CMainParams mainParams; + + + +// Testnet +// Dont need to configure anything under this line +//------------------------------------------------// + +class CTestNetParams : public CMainParams { +public: + CTestNetParams() { + // The message start string is designed to be unlikely to occur in normal data. + // The characters are rarely used upper ASCII, not valid as UTF-8, and produce + // a large 4-byte int at any alignment. + pchMessageStart[0] = 0x54; + pchMessageStart[1] = 0xac; + pchMessageStart[2] = 0xb3; + pchMessageStart[3] = 0xaa; + bnProofOfWorkLimit = CBigNum(~uint256(0) >> 16); + vAlertPubKey = ParseHex(""); + nDefaultPort = 29844; + nRPCPort = 28844; + strDataDir = "testnet"; + + // Modify the testnet genesis block so the timestamp is valid for a later start. + genesis.nBits = bnProofOfWorkLimit.GetCompact();; + genesis.nTime = 1504886750; + genesis.nNonce = 0; // + + //assert(hashGenesisBlock == uint256("0x")); // + + vFixedSeeds.clear(); + vSeeds.clear(); + + base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,65); + base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,192); + base58Prefixes[SECRET_KEY] = std::vector(1,239); + base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container >(); + base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94).convert_to_container >(); + + convertSeed6(vFixedSeeds, pnSeed6_test, ARRAYLEN(pnSeed6_test)); + + nLastPOWBlock = 0x7fffffff; + } + virtual Network NetworkID() const { return CChainParams::TESTNET; } +}; +static CTestNetParams testNetParams; + + +static CChainParams *pCurrentParams = &mainParams; + +const CChainParams &Params() { + return *pCurrentParams; +} + +void SelectParams(CChainParams::Network network) { + switch (network) { + case CChainParams::MAIN: + pCurrentParams = &mainParams; + break; + case CChainParams::TESTNET: + pCurrentParams = &testNetParams; + break; + default: + assert(false && "Unimplemented network"); + return; + } +} + +bool SelectParamsFromCommandLine() { + + bool fTestNet = GetBoolArg("-testnet", false); + + if (fTestNet) { + SelectParams(CChainParams::TESTNET); + } else { + SelectParams(CChainParams::MAIN); + } + return true; +} diff --git a/src/chainparams.h b/src/chainparams.h new file mode 100644 index 0000000..b1d870a --- /dev/null +++ b/src/chainparams.h @@ -0,0 +1,108 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_CHAIN_PARAMS_H +#define BITCOIN_CHAIN_PARAMS_H + +#include "bignum.h" +#include "uint256.h" +#include "util.h" + +#include + +using namespace std; + +#define MESSAGE_START_SIZE 4 +typedef unsigned char MessageStartChars[MESSAGE_START_SIZE]; + +class CAddress; +class CBlock; + +struct CDNSSeedData { + string name, host; + CDNSSeedData(const string &strName, const string &strHost) : name(strName), host(strHost) {} +}; + +/** + * CChainParams defines various tweakable parameters of a given instance of the + * Bitcoin system. There are three: the main network on which people trade goods + * and services, the public test network which gets reset from time to time and + * a regression test mode which is intended for private networks only. It has + * minimal difficulty to ensure that blocks can be found instantly. + */ +class CChainParams +{ +public: + enum Network { + MAIN, + TESTNET, + REGTEST, + + MAX_NETWORK_TYPES + }; + + enum Base58Type { + PUBKEY_ADDRESS, + SCRIPT_ADDRESS, + SECRET_KEY, + EXT_PUBLIC_KEY, + EXT_SECRET_KEY, + + MAX_BASE58_TYPES + }; + + const uint256& HashGenesisBlock() const { return hashGenesisBlock; } + const MessageStartChars& MessageStart() const { return pchMessageStart; } + const vector& AlertKey() const { return vAlertPubKey; } + int GetDefaultPort() const { return nDefaultPort; } + const CBigNum& ProofOfWorkLimit() const { return bnProofOfWorkLimit; } + int SubsidyHalvingInterval() const { return nSubsidyHalvingInterval; } + virtual const CBlock& GenesisBlock() const = 0; + virtual bool RequireRPCPassword() const { return true; } + const string& DataDir() const { return strDataDir; } + virtual Network NetworkID() const = 0; + const vector& DNSSeeds() const { return vSeeds; } + const std::vector &Base58Prefix(Base58Type type) const { return base58Prefixes[type]; } + virtual const vector& FixedSeeds() const = 0; + int RPCPort() const { return nRPCPort; } + int LastPOWBlock() const { return nLastPOWBlock; } +protected: + CChainParams() {}; + + uint256 hashGenesisBlock; + MessageStartChars pchMessageStart; + // Raw pub key bytes for the broadcast alert signing key. + vector vAlertPubKey; + int nDefaultPort; + int nRPCPort; + CBigNum bnProofOfWorkLimit; + int nSubsidyHalvingInterval; + string strDataDir; + vector vSeeds; + std::vector base58Prefixes[MAX_BASE58_TYPES]; + int nLastPOWBlock; +}; + +/** + * Return the currently selected parameters. This won't change after app startup + * outside of the unit tests. + */ +const CChainParams &Params(); + +/** Sets the params returned by Params() to those for the given network. */ +void SelectParams(CChainParams::Network network); + +/** + * Looks for -regtest or -testnet and then calls SelectParams as appropriate. + * Returns false if an invalid combination is given. + */ +bool SelectParamsFromCommandLine(); + +inline bool TestNet() { + // Note: it's deliberate that this returns "false" for regression test mode. + return Params().NetworkID() == CChainParams::TESTNET; +} + +#endif diff --git a/src/chainparamsseeds.h b/src/chainparamsseeds.h new file mode 100644 index 0000000..727079d --- /dev/null +++ b/src/chainparamsseeds.h @@ -0,0 +1,16 @@ +#ifndef H_CHAINPARAMSSEEDS +#define H_CHAINPARAMSSEEDS +// List of fixed seed nodes for the bitcoin network +// AUTOGENERATED by contrib/devtools/generate-seeds.py + +// Each line contains a 16-byte IPv6 address and a port. +// IPv4 as well as onion addresses are wrapped inside a IPv6 address accordingly. +static SeedSpec6 pnSeed6_main[] = { + // {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x68,0x83,0xf8,0xbf}, 15714}, + +}; + +static SeedSpec6 pnSeed6_test[] = { + +}; +#endif diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp new file mode 100644 index 0000000..cbbaa26 --- /dev/null +++ b/src/checkpoints.cpp @@ -0,0 +1,90 @@ +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include // for 'map_list_of()' +#include + +#include "checkpoints.h" + +#include "txdb.h" +#include "main.h" +#include "uint256.h" + + +static const int nCheckpointSpan = 500; + +namespace Checkpoints +{ + typedef std::map MapCheckpoints; + + // + // What makes a good checkpoint block? + // + Is surrounded by blocks with reasonable timestamps + // (no blocks before with a timestamp after, none after with + // timestamp before) + // + Contains no strange transactions + // Initilised anti exploit protection for checkpoint | Auto checkpoint-back initilised + + static MapCheckpoints mapCheckpoints = + boost::assign::map_list_of + ( 0, uint256("0x") ) + + ; + + + // TestNet has no checkpoints + static MapCheckpoints mapCheckpointsTestnet; + + bool CheckHardened(int nHeight, const uint256& hash) + { + MapCheckpoints& checkpoints = (TestNet() ? mapCheckpointsTestnet : mapCheckpoints); + + MapCheckpoints::const_iterator i = checkpoints.find(nHeight); + if (i == checkpoints.end()) return true; + return hash == i->second; + } + + int GetTotalBlocksEstimate() + { + MapCheckpoints& checkpoints = (TestNet() ? mapCheckpointsTestnet : mapCheckpoints); + + if (checkpoints.empty()) + return 0; + return checkpoints.rbegin()->first; + } + + CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex) + { + MapCheckpoints& checkpoints = (TestNet() ? mapCheckpointsTestnet : mapCheckpoints); + + BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints) + { + const uint256& hash = i.second; + std::map::const_iterator t = mapBlockIndex.find(hash); + if (t != mapBlockIndex.end()) + return t->second; + } + return NULL; + } + + // Automatically select a suitable sync-checkpoint + const CBlockIndex* AutoSelectSyncCheckpoint() + { + const CBlockIndex *pindex = pindexBest; + // Search backward for a block within max span and maturity window + while (pindex->pprev && pindex->nHeight + nCheckpointSpan > pindexBest->nHeight) + pindex = pindex->pprev; + return pindex; + } + + // Check against synchronized checkpoint + bool CheckSync(int nHeight) + { + const CBlockIndex* pindexSync = AutoSelectSyncCheckpoint(); + + if (nHeight <= pindexSync->nHeight) + return false; + return true; + } +} diff --git a/src/checkpoints.h b/src/checkpoints.h new file mode 100644 index 0000000..838b5a8 --- /dev/null +++ b/src/checkpoints.h @@ -0,0 +1,31 @@ +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_CHECKPOINT_H +#define BITCOIN_CHECKPOINT_H + +#include +#include "net.h" +#include "util.h" + +class uint256; +class CBlockIndex; + +/** Block-chain checkpoints are compiled-in sanity checks. + * They are updated every release or three. + */ +namespace Checkpoints +{ + // Returns true if block passes checkpoint checks + bool CheckHardened(int nHeight, const uint256& hash); + + // Return conservative estimate of total number of blocks, 0 if unknown + int GetTotalBlocksEstimate(); + + // Returns last CBlockIndex* in mapBlockIndex that is a checkpoint + CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex); + + const CBlockIndex* AutoSelectSyncCheckpoint(); + bool CheckSync(int nHeight); +} +#endif diff --git a/src/checkpoints_Back.cpp b/src/checkpoints_Back.cpp new file mode 100644 index 0000000..542c816 --- /dev/null +++ b/src/checkpoints_Back.cpp @@ -0,0 +1,430 @@ +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include // for 'map_list_of()' +#include + +#include "checkpoints.h" + +#include "txdb.h" +#include "main.h" +#include "uint256.h" + + +static const int nCheckpointSpan = 500; + +namespace Checkpoints +{ + typedef std::map MapCheckpoints; + + // + // What makes a good checkpoint block? + // + Is surrounded by blocks with reasonable timestamps + // (no blocks before with a timestamp after, none after with + // timestamp before) + // + Contains no strange transactions + // Auto merged with checkpoint for anti exploit protection + static MapCheckpoints mapCheckpoints = + boost::assign::map_list_of + ( 0, uint256("0x00000759bb3da130d7c9aedae170da8335f5a0d01a9007e4c8d3ccd08ace6a42") ) + ( 175, uint256("0x000000000002611e8e3c2e460e7fcd0a39ee210b9915fc76a5573a0704bb2b33") ) + ( 2241, uint256("0x69e2e47fb84085c4b82b6090f701c7ac03a4e510bd1f41cc072c33061cf83a0d") ) + ( 6901, uint256("0x0000000000034bab666179e364e0cce7c19eaa255f1e4afd2170356acfa1a3ac") ) + ( 25318, uint256("0x092a04ee669d2d2241aba0ec9dcecb548c9cea9ff114b0ee52cdc7ddac98a1f4") ) + ( 97176, uint256("0x000000000004e4aac7926e7dbd778f21b15b62f0e4c1d424ac9e5a9889c1724a") ) + ; + + // TestNet has no checkpoints + static MapCheckpoints mapCheckpointsTestnet; + + bool CheckHardened(int nHeight, const uint256& hash) + { + MapCheckpoints& checkpoints = (TestNet() ? mapCheckpointsTestnet : mapCheckpoints); + + MapCheckpoints::const_iterator i = checkpoints.find(nHeight); + if (i == checkpoints.end()) return true; + return hash == i->second; + } + + int GetTotalBlocksEstimate() + { + MapCheckpoints& checkpoints = (TestNet() ? mapCheckpointsTestnet : mapCheckpoints); + + if (checkpoints.empty()) + return 0; + return checkpoints.rbegin()->first; + } + + CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex) + { + MapCheckpoints& checkpoints = (TestNet() ? mapCheckpointsTestnet : mapCheckpoints); + + BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints) + { + const uint256& hash = i.second; + std::map::const_iterator t = mapBlockIndex.find(hash); + if (t != mapBlockIndex.end()) + return t->second; + } + return NULL; + } + + // ppcoin: synchronized checkpoint (centrally broadcasted) + uint256 hashSyncCheckpoint = 0; + uint256 hashPendingCheckpoint = 0; + CSyncCheckpoint checkpointMessage; + CSyncCheckpoint checkpointMessagePending; + uint256 hashInvalidCheckpoint = 0; + CCriticalSection cs_hashSyncCheckpoint; + + // ppcoin: get last synchronized checkpoint + CBlockIndex* GetLastSyncCheckpoint() + { + LOCK(cs_hashSyncCheckpoint); + if (!mapBlockIndex.count(hashSyncCheckpoint)) + error("GetSyncCheckpoint: block index missing for current sync-checkpoint %s", hashSyncCheckpoint.ToString()); + else + return mapBlockIndex[hashSyncCheckpoint]; + return NULL; + } + + // ppcoin: only descendant of current sync-checkpoint is allowed + bool ValidateSyncCheckpoint(uint256 hashCheckpoint) + { + if (!mapBlockIndex.count(hashSyncCheckpoint)) + return error("ValidateSyncCheckpoint: block index missing for current sync-checkpoint %s", hashSyncCheckpoint.ToString()); + if (!mapBlockIndex.count(hashCheckpoint)) + return error("ValidateSyncCheckpoint: block index missing for received sync-checkpoint %s", hashCheckpoint.ToString()); + + CBlockIndex* pindexSyncCheckpoint = mapBlockIndex[hashSyncCheckpoint]; + CBlockIndex* pindexCheckpointRecv = mapBlockIndex[hashCheckpoint]; + + if (pindexCheckpointRecv->nHeight <= pindexSyncCheckpoint->nHeight) + { + // Received an older checkpoint, trace back from current checkpoint + // to the same height of the received checkpoint to verify + // that current checkpoint should be a descendant block + CBlockIndex* pindex = pindexSyncCheckpoint; + while (pindex->nHeight > pindexCheckpointRecv->nHeight) + if (!(pindex = pindex->pprev)) + return error("ValidateSyncCheckpoint: pprev null - block index structure failure"); + if (pindex->GetBlockHash() != hashCheckpoint) + { + hashInvalidCheckpoint = hashCheckpoint; + return error("ValidateSyncCheckpoint: new sync-checkpoint %s is conflicting with current sync-checkpoint %s", hashCheckpoint.ToString(), hashSyncCheckpoint.ToString()); + } + return false; // ignore older checkpoint + } + + // Received checkpoint should be a descendant block of the current + // checkpoint. Trace back to the same height of current checkpoint + // to verify. + CBlockIndex* pindex = pindexCheckpointRecv; + while (pindex->nHeight > pindexSyncCheckpoint->nHeight) + if (!(pindex = pindex->pprev)) + return error("ValidateSyncCheckpoint: pprev2 null - block index structure failure"); + if (pindex->GetBlockHash() != hashSyncCheckpoint) + { + hashInvalidCheckpoint = hashCheckpoint; + return error("ValidateSyncCheckpoint: new sync-checkpoint %s is not a descendant of current sync-checkpoint %s", hashCheckpoint.ToString(), hashSyncCheckpoint.ToString()); + } + return true; + } + + bool WriteSyncCheckpoint(const uint256& hashCheckpoint) + { + CTxDB txdb; + txdb.TxnBegin(); + if (!txdb.WriteSyncCheckpoint(hashCheckpoint)) + { + txdb.TxnAbort(); + return error("WriteSyncCheckpoint(): failed to write to db sync checkpoint %s", hashCheckpoint.ToString()); + } + if (!txdb.TxnCommit()) + return error("WriteSyncCheckpoint(): failed to commit to db sync checkpoint %s", hashCheckpoint.ToString()); + + Checkpoints::hashSyncCheckpoint = hashCheckpoint; + return true; + } + + bool AcceptPendingSyncCheckpoint() + { + LOCK(cs_hashSyncCheckpoint); + if (hashPendingCheckpoint != 0 && mapBlockIndex.count(hashPendingCheckpoint)) + { + if (!ValidateSyncCheckpoint(hashPendingCheckpoint)) + { + hashPendingCheckpoint = 0; + checkpointMessagePending.SetNull(); + return false; + } + + CTxDB txdb; + CBlockIndex* pindexCheckpoint = mapBlockIndex[hashPendingCheckpoint]; + if (!pindexCheckpoint->IsInMainChain()) + { + CBlock block; + if (!block.ReadFromDisk(pindexCheckpoint)) + return error("AcceptPendingSyncCheckpoint: ReadFromDisk failed for sync checkpoint %s", hashPendingCheckpoint.ToString()); + if (!block.SetBestChain(txdb, pindexCheckpoint)) + { + hashInvalidCheckpoint = hashPendingCheckpoint; + return error("AcceptPendingSyncCheckpoint: SetBestChain failed for sync checkpoint %s", hashPendingCheckpoint.ToString()); + } + } + + if (!WriteSyncCheckpoint(hashPendingCheckpoint)) + return error("AcceptPendingSyncCheckpoint(): failed to write sync checkpoint %s", hashPendingCheckpoint.ToString()); + hashPendingCheckpoint = 0; + checkpointMessage = checkpointMessagePending; + checkpointMessagePending.SetNull(); + LogPrintf("AcceptPendingSyncCheckpoint : sync-checkpoint at %s\n", hashSyncCheckpoint.ToString()); + // relay the checkpoint + if (!checkpointMessage.IsNull()) + { + BOOST_FOREACH(CNode* pnode, vNodes) + checkpointMessage.RelayTo(pnode); + } + return true; + } + return false; + } + + // Automatically select a suitable sync-checkpoint + uint256 AutoSelectSyncCheckpoint() + { + const CBlockIndex *pindex = pindexBest; + // Search backward for a block within max span and maturity window + while (pindex->pprev && pindex->nHeight + nCheckpointSpan > pindexBest->nHeight) + pindex = pindex->pprev; + return pindex->GetBlockHash(); + } + + // Check against synchronized checkpoint + bool CheckSync(const uint256& hashBlock, const CBlockIndex* pindexPrev) + { + if (TestNet()) return true; // Testnet has no checkpoints + int nHeight = pindexPrev->nHeight + 1; + + LOCK(cs_hashSyncCheckpoint); + // sync-checkpoint should always be accepted block + assert(mapBlockIndex.count(hashSyncCheckpoint)); + const CBlockIndex* pindexSync = mapBlockIndex[hashSyncCheckpoint]; + + if (nHeight > pindexSync->nHeight) + { + // trace back to same height as sync-checkpoint + const CBlockIndex* pindex = pindexPrev; + while (pindex->nHeight > pindexSync->nHeight) + if (!(pindex = pindex->pprev)) + return error("CheckSync: pprev null - block index structure failure"); + if (pindex->nHeight < pindexSync->nHeight || pindex->GetBlockHash() != hashSyncCheckpoint) + return false; // only descendant of sync-checkpoint can pass check + } + if (nHeight == pindexSync->nHeight && hashBlock != hashSyncCheckpoint) + return false; // same height with sync-checkpoint + if (nHeight < pindexSync->nHeight && !mapBlockIndex.count(hashBlock)) + return false; // lower height than sync-checkpoint + return true; + } + + bool WantedByPendingSyncCheckpoint(uint256 hashBlock) + { + LOCK(cs_hashSyncCheckpoint); + if (hashPendingCheckpoint == 0) + return false; + if (hashBlock == hashPendingCheckpoint) + return true; + if (mapOrphanBlocks.count(hashPendingCheckpoint) + && hashBlock == WantedByOrphan(mapOrphanBlocks[hashPendingCheckpoint])) + return true; + return false; + } + + // ppcoin: reset synchronized checkpoint to last hardened checkpoint + bool ResetSyncCheckpoint() + { + LOCK(cs_hashSyncCheckpoint); + const uint256& hash = mapCheckpoints.rbegin()->second; + if (mapBlockIndex.count(hash) && !mapBlockIndex[hash]->IsInMainChain()) + { + // checkpoint block accepted but not yet in main chain + LogPrintf("ResetSyncCheckpoint: SetBestChain to hardened checkpoint %s\n", hash.ToString()); + CTxDB txdb; + CBlock block; + if (!block.ReadFromDisk(mapBlockIndex[hash])) + return error("ResetSyncCheckpoint: ReadFromDisk failed for hardened checkpoint %s", hash.ToString()); + if (!block.SetBestChain(txdb, mapBlockIndex[hash])) + { + return error("ResetSyncCheckpoint: SetBestChain failed for hardened checkpoint %s", hash.ToString()); + } + } + else if(!mapBlockIndex.count(hash)) + { + // checkpoint block not yet accepted + hashPendingCheckpoint = hash; + checkpointMessagePending.SetNull(); + LogPrintf("ResetSyncCheckpoint: pending for sync-checkpoint %s\n", hashPendingCheckpoint.ToString()); + } + + BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints) + { + const uint256& hash = i.second; + if (mapBlockIndex.count(hash) && mapBlockIndex[hash]->IsInMainChain()) + { + if (!WriteSyncCheckpoint(hash)) + return error("ResetSyncCheckpoint: failed to write sync checkpoint %s", hash.ToString()); + LogPrintf("ResetSyncCheckpoint: sync-checkpoint reset to %s\n", hashSyncCheckpoint.ToString()); + return true; + } + } + + if (!WriteSyncCheckpoint(Params().HashGenesisBlock())) + return error("ResetSyncCheckpoint: failed to write sync checkpoint genesis block"); + LogPrintf("ResetSyncCheckpoint: sync-checkpoint reset to genesis block\n"); + return true; + } + + void AskForPendingSyncCheckpoint(CNode* pfrom) + { + LOCK(cs_hashSyncCheckpoint); + if (pfrom && hashPendingCheckpoint != 0 && (!mapBlockIndex.count(hashPendingCheckpoint)) && (!mapOrphanBlocks.count(hashPendingCheckpoint))) + pfrom->AskFor(CInv(MSG_BLOCK, hashPendingCheckpoint)); + } + + bool SetCheckpointPrivKey(std::string strPrivKey) + { + // Test signing a sync-checkpoint with genesis block + CSyncCheckpoint checkpoint; + checkpoint.hashCheckpoint = Params().HashGenesisBlock(); + CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION); + sMsg << (CUnsignedSyncCheckpoint)checkpoint; + checkpoint.vchMsg = std::vector(sMsg.begin(), sMsg.end()); + + std::vector vchPrivKey = ParseHex(strPrivKey); + CKey key; + key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end()), false); // if key is not correct openssl may crash + if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig)) + return false; + + // Test signing successful, proceed + CSyncCheckpoint::strMasterPrivKey = strPrivKey; + return true; + } + + bool SendSyncCheckpoint(uint256 hashCheckpoint) + { + CSyncCheckpoint checkpoint; + checkpoint.hashCheckpoint = hashCheckpoint; + CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION); + sMsg << (CUnsignedSyncCheckpoint)checkpoint; + checkpoint.vchMsg = std::vector(sMsg.begin(), sMsg.end()); + + if (CSyncCheckpoint::strMasterPrivKey.empty()) + return error("SendSyncCheckpoint: Checkpoint master key unavailable."); + std::vector vchPrivKey = ParseHex(CSyncCheckpoint::strMasterPrivKey); + CKey key; + key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end()), false); // if key is not correct openssl may crash + if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig)) + return error("SendSyncCheckpoint: Unable to sign checkpoint, check private key?"); + + if(!checkpoint.ProcessSyncCheckpoint(NULL)) + { + LogPrintf("WARNING: SendSyncCheckpoint: Failed to process checkpoint.\n"); + return false; + } + + // Relay checkpoint + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + checkpoint.RelayTo(pnode); + } + return true; + } +} + +// ppcoin: sync-checkpoint master key +const std::string CSyncCheckpoint::strMasterPubKey = "049F2C10997604217E7238A4C5CF2843570ADA001D1A247B228A7C5583ACD0F762A3130D0C4331EB262E3D0EB516AE6F7B0B1ADA43275013F8552A83A7C621B1D9"; + +std::string CSyncCheckpoint::strMasterPrivKey = ""; + +bool CSyncCheckpoint::RelayTo(CNode* pnode) const +{ + // don't relay to nodes which haven't sent their version message + if (pnode->nVersion == 0) + return false; + // returns true if wasn't already sent + if (pnode->hashCheckpointKnown != hashCheckpoint) + { + pnode->hashCheckpointKnown = hashCheckpoint; + pnode->PushMessage("checkpoint", *this); + return true; + } + return false; +} + +// ppcoin: verify signature of sync-checkpoint message +bool CSyncCheckpoint::CheckSignature() +{ + CPubKey key(ParseHex(CSyncCheckpoint::strMasterPubKey)); + if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig)) + return error("CSyncCheckpoint::CheckSignature() : verify signature failed"); + + // Now unserialize the data + CDataStream sMsg(vchMsg, SER_NETWORK, PROTOCOL_VERSION); + sMsg >> *(CUnsignedSyncCheckpoint*)this; + return true; +} + +// ppcoin: process synchronized checkpoint +bool CSyncCheckpoint::ProcessSyncCheckpoint(CNode* pfrom) +{ + if (!CheckSignature()) + return false; + + LOCK(Checkpoints::cs_hashSyncCheckpoint); + if (!mapBlockIndex.count(hashCheckpoint)) + { + // We haven't received the checkpoint chain, keep the checkpoint as pending + Checkpoints::hashPendingCheckpoint = hashCheckpoint; + Checkpoints::checkpointMessagePending = *this; + LogPrintf("ProcessSyncCheckpoint: pending for sync-checkpoint %s\n", hashCheckpoint.ToString()); + // Ask this guy to fill in what we're missing + if (pfrom) + { + PushGetBlocks(pfrom, pindexBest, hashCheckpoint); + // ask directly as well in case rejected earlier by duplicate + // proof-of-stake because getblocks may not get it this time + pfrom->AskFor(CInv(MSG_BLOCK, mapOrphanBlocks.count(hashCheckpoint)? WantedByOrphan(mapOrphanBlocks[hashCheckpoint]) : hashCheckpoint)); + } + return false; + } + + if (!Checkpoints::ValidateSyncCheckpoint(hashCheckpoint)) + return false; + + CTxDB txdb; + CBlockIndex* pindexCheckpoint = mapBlockIndex[hashCheckpoint]; + if (!pindexCheckpoint->IsInMainChain()) + { + // checkpoint chain received but not yet main chain + CBlock block; + if (!block.ReadFromDisk(pindexCheckpoint)) + return error("ProcessSyncCheckpoint: ReadFromDisk failed for sync checkpoint %s", hashCheckpoint.ToString()); + if (!block.SetBestChain(txdb, pindexCheckpoint)) + { + Checkpoints::hashInvalidCheckpoint = hashCheckpoint; + return error("ProcessSyncCheckpoint: SetBestChain failed for sync checkpoint %s", hashCheckpoint.ToString()); + } + } + + if (!Checkpoints::WriteSyncCheckpoint(hashCheckpoint)) + return error("ProcessSyncCheckpoint(): failed to write sync checkpoint %s", hashCheckpoint.ToString()); + Checkpoints::checkpointMessage = *this; + Checkpoints::hashPendingCheckpoint = 0; + Checkpoints::checkpointMessagePending.SetNull(); + LogPrintf("ProcessSyncCheckpoint: sync-checkpoint at %s\n", hashCheckpoint.ToString()); + return true; +} diff --git a/src/checkpoints_back.h b/src/checkpoints_back.h new file mode 100644 index 0000000..5fc139f --- /dev/null +++ b/src/checkpoints_back.h @@ -0,0 +1,137 @@ +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_CHECKPOINT_H +#define BITCOIN_CHECKPOINT_H + +#include +#include "net.h" +#include "util.h" + +#ifdef WIN32 +#undef STRICT +#undef PERMISSIVE +#undef ADVISORY +#endif + +class uint256; +class CBlockIndex; +class CSyncCheckpoint; + +/** Block-chain checkpoints are compiled-in sanity checks. + * They are updated every release or three. + */ +namespace Checkpoints +{ + /** Checkpointing mode */ + enum CPMode + { + // Scrict checkpoints policy, perform conflicts verification and resolve conflicts + STRICT = 0, + // Advisory checkpoints policy, perform conflicts verification but don't try to resolve them + ADVISORY = 1, + // Permissive checkpoints policy, don't perform any checking + PERMISSIVE = 2 + }; + + // Returns true if block passes checkpoint checks + bool CheckHardened(int nHeight, const uint256& hash); + + // Return conservative estimate of total number of blocks, 0 if unknown + int GetTotalBlocksEstimate(); + + // Returns last CBlockIndex* in mapBlockIndex that is a checkpoint + CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex); + + extern uint256 hashSyncCheckpoint; + extern CSyncCheckpoint checkpointMessage; + extern uint256 hashInvalidCheckpoint; + extern CCriticalSection cs_hashSyncCheckpoint; + + CBlockIndex* GetLastSyncCheckpoint(); + bool WriteSyncCheckpoint(const uint256& hashCheckpoint); + bool AcceptPendingSyncCheckpoint(); + uint256 AutoSelectSyncCheckpoint(); + bool CheckSync(const uint256& hashBlock, const CBlockIndex* pindexPrev); + bool WantedByPendingSyncCheckpoint(uint256 hashBlock); + bool ResetSyncCheckpoint(); + void AskForPendingSyncCheckpoint(CNode* pfrom); + bool SetCheckpointPrivKey(std::string strPrivKey); + bool SendSyncCheckpoint(uint256 hashCheckpoint); +} + +// ppcoin: synchronized checkpoint +class CUnsignedSyncCheckpoint +{ +public: + int nVersion; + uint256 hashCheckpoint; // checkpoint block + + IMPLEMENT_SERIALIZE + ( + READWRITE(this->nVersion); + nVersion = this->nVersion; + READWRITE(hashCheckpoint); + ) + + void SetNull() + { + nVersion = 1; + hashCheckpoint = 0; + } + + std::string ToString() const + { + return strprintf( + "CSyncCheckpoint(\n" + " nVersion = %d\n" + " hashCheckpoint = %s\n" + ")\n", + nVersion, + hashCheckpoint.ToString()); + } +}; + +class CSyncCheckpoint : public CUnsignedSyncCheckpoint +{ +public: + static const std::string strMasterPubKey; + static std::string strMasterPrivKey; + + std::vector vchMsg; + std::vector vchSig; + + CSyncCheckpoint() + { + SetNull(); + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(vchMsg); + READWRITE(vchSig); + ) + + void SetNull() + { + CUnsignedSyncCheckpoint::SetNull(); + vchMsg.clear(); + vchSig.clear(); + } + + bool IsNull() const + { + return (hashCheckpoint == 0); + } + + uint256 GetHash() const + { + return SerializeHash(*this); + } + + bool RelayTo(CNode* pnode) const; + bool CheckSignature(); + bool ProcessSyncCheckpoint(CNode* pfrom); +}; + +#endif diff --git a/src/clientversion.h b/src/clientversion.h new file mode 100644 index 0000000..36a5ca5 --- /dev/null +++ b/src/clientversion.h @@ -0,0 +1,22 @@ +#ifndef CLIENTVERSION_H +#define CLIENTVERSION_H + + +// client versioning + + +// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it +#define CLIENT_VERSION_MAJOR 1 +#define CLIENT_VERSION_MINOR 2 +#define CLIENT_VERSION_REVISION 0 +#define CLIENT_VERSION_BUILD 0 + +// Set to true for release, false for prerelease or test build +#define CLIENT_VERSION_IS_RELEASE true + +// Converts the parameter X to a string after macro replacement on X has been performed. +// Don't merge these into one macro! +#define STRINGIZE(X) DO_STRINGIZE(X) +#define DO_STRINGIZE(X) #X + +#endif // CLIENTVERSION_H diff --git a/src/coincontrol.h b/src/coincontrol.h new file mode 100644 index 0000000..416b86a --- /dev/null +++ b/src/coincontrol.h @@ -0,0 +1,59 @@ +#ifndef COINCONTROL_H +#define COINCONTROL_H + +#include "core.h" + +/** Coin Control Features. */ +class CCoinControl +{ +public: + CTxDestination destChange; + + CCoinControl() + { + SetNull(); + } + + void SetNull() + { + destChange = CNoDestination(); + setSelected.clear(); + } + + bool HasSelected() const + { + return (setSelected.size() > 0); + } + + bool IsSelected(const uint256& hash, unsigned int n) const + { + COutPoint outpt(hash, n); + return (setSelected.count(outpt) > 0); + } + + void Select(COutPoint& output) + { + setSelected.insert(output); + } + + void UnSelect(COutPoint& output) + { + setSelected.erase(output); + } + + void UnSelectAll() + { + setSelected.clear(); + } + + void ListSelected(std::vector& vOutpoints) + { + vOutpoints.assign(setSelected.begin(), setSelected.end()); + } + +private: + std::set setSelected; + +}; + +#endif // COINCONTROL_H diff --git a/src/compat.h b/src/compat.h new file mode 100644 index 0000000..03c6e95 --- /dev/null +++ b/src/compat.h @@ -0,0 +1,67 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef _BITCOIN_COMPAT_H +#define _BITCOIN_COMPAT_H 1 + +#ifdef WIN32 +#define _WIN32_WINNT 0x0501 +#define WIN32_LEAN_AND_MEAN 1 +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include +#include +#include +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef u_int SOCKET; +#endif + + +#ifdef WIN32 +#define MSG_NOSIGNAL 0 +#define MSG_DONTWAIT 0 +typedef int socklen_t; +#else +#include "errno.h" +#define WSAGetLastError() errno +#define WSAEINVAL EINVAL +#define WSAEALREADY EALREADY +#define WSAEWOULDBLOCK EWOULDBLOCK +#define WSAEMSGSIZE EMSGSIZE +#define WSAEINTR EINTR +#define WSAEINPROGRESS EINPROGRESS +#define WSAEADDRINUSE EADDRINUSE +#define WSAENOTSOCK EBADF +#define INVALID_SOCKET (SOCKET)(~0) +#define SOCKET_ERROR -1 +#endif + +inline int myclosesocket(SOCKET& hSocket) +{ + if (hSocket == INVALID_SOCKET) + return WSAENOTSOCK; +#ifdef WIN32 + int ret = closesocket(hSocket); +#else + int ret = close(hSocket); +#endif + hSocket = INVALID_SOCKET; + return ret; +} +#define closesocket(s) myclosesocket(s) + + +#endif diff --git a/src/core b/src/core new file mode 100644 index 0000000..5254a8f Binary files /dev/null and b/src/core differ diff --git a/src/core.cpp b/src/core.cpp new file mode 100644 index 0000000..cb1053b --- /dev/null +++ b/src/core.cpp @@ -0,0 +1,6 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "core.h" \ No newline at end of file diff --git a/src/core.h b/src/core.h new file mode 100644 index 0000000..e4e7047 --- /dev/null +++ b/src/core.h @@ -0,0 +1,212 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_CORE_H +#define BITCOIN_CORE_H + +#include "uint256.h" +#include "serialize.h" +#include "util.h" +#include "script.h" + +#include + +class CScript; +class CTransaction; + +/** An outpoint - a combination of a transaction hash and an index n into its vout */ +class COutPoint +{ +public: + uint256 hash; + unsigned int n; + + COutPoint() { SetNull(); } + COutPoint(uint256 hashIn, unsigned int nIn) { hash = hashIn; n = nIn; } + IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); ) + void SetNull() { hash = 0; n = (unsigned int) -1; } + bool IsNull() const { return (hash == 0 && n == (unsigned int) -1); } + + friend bool operator<(const COutPoint& a, const COutPoint& b) + { + return (a.hash < b.hash || (a.hash == b.hash && a.n < b.n)); + } + + friend bool operator==(const COutPoint& a, const COutPoint& b) + { + return (a.hash == b.hash && a.n == b.n); + } + + friend bool operator!=(const COutPoint& a, const COutPoint& b) + { + return !(a == b); + } + + std::string ToString() const + { + return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n); + } +}; + +/** An inpoint - a combination of a transaction and an index n into its vin */ +class CInPoint +{ +public: + CTransaction* ptx; + unsigned int n; + + CInPoint() { SetNull(); } + CInPoint(CTransaction* ptxIn, unsigned int nIn) { ptx = ptxIn; n = nIn; } + void SetNull() { ptx = NULL; n = (unsigned int) -1; } + bool IsNull() const { return (ptx == NULL && n == (unsigned int) -1); } +}; + +/** An input of a transaction. It contains the location of the previous + * transaction's output that it claims and a signature that matches the + * output's public key. + */ +class CTxIn +{ +public: + COutPoint prevout; + CScript scriptSig; + CScript prevPubKey; + unsigned int nSequence; + CScriptWitness scriptWitness; //! Only serialized through CTransaction + + CTxIn() + { + nSequence = std::numeric_limits::max(); + } + + explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=std::numeric_limits::max()) + { + prevout = prevoutIn; + scriptSig = scriptSigIn; + nSequence = nSequenceIn; + } + + explicit CTxIn(uint256 hashPrevTx, unsigned int nOut, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=std::numeric_limits::max()) + { + prevout = COutPoint(hashPrevTx, nOut); + scriptSig = scriptSigIn; + nSequence = nSequenceIn; + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(prevout); + READWRITE(scriptSig); + READWRITE(nSequence); + ) + + bool IsFinal() const + { + return (nSequence == std::numeric_limits::max()); + } + + friend bool operator==(const CTxIn& a, const CTxIn& b) + { + return (a.prevout == b.prevout && + a.scriptSig == b.scriptSig && + a.nSequence == b.nSequence); + } + + friend bool operator!=(const CTxIn& a, const CTxIn& b) + { + return !(a == b); + } + + std::string ToString() const + { + std::string str; + str += "CTxIn("; + str += prevout.ToString(); + if (prevout.IsNull()) + str += strprintf(", coinbase %s", HexStr(scriptSig)); + else + str += strprintf(", scriptSig=%s", scriptSig.ToString().substr(0,24)); + if (nSequence != std::numeric_limits::max()) + str += strprintf(", nSequence=%u", nSequence); + str += ")"; + return str; + } +}; + + + + +/** An output of a transaction. It contains the public key that the next input + * must be able to sign with to claim it. + */ +class CTxOut +{ +public: + int64_t nValue; + CScript scriptPubKey; + + CTxOut() + { + SetNull(); + } + + CTxOut(int64_t nValueIn, CScript scriptPubKeyIn) + { + nValue = nValueIn; + scriptPubKey = scriptPubKeyIn; + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(nValue); + READWRITE(scriptPubKey); + ) + + void SetNull() + { + nValue = -1; + scriptPubKey.clear(); + } + + bool IsNull() const + { + return (nValue == -1); + } + + void SetEmpty() + { + nValue = 0; + scriptPubKey.clear(); + } + + bool IsEmpty() const + { + return (nValue == 0 && scriptPubKey.empty()); + } + + uint256 GetHash() const + { + return SerializeHash(*this); + } + + friend bool operator==(const CTxOut& a, const CTxOut& b) + { + return (a.nValue == b.nValue && + a.scriptPubKey == b.scriptPubKey); + } + + friend bool operator!=(const CTxOut& a, const CTxOut& b) + { + return !(a == b); + } + + std::string ToString() const + { + if (IsEmpty()) return "CTxOut(empty)"; + return strprintf("CTxOut(nValue=%s, scriptPubKey=%s)", FormatMoney(nValue), scriptPubKey.ToString()); + } +}; + +#endif + diff --git a/src/crypter.cpp b/src/crypter.cpp new file mode 100644 index 0000000..a057d28 --- /dev/null +++ b/src/crypter.cpp @@ -0,0 +1,365 @@ +// Copyright (c) 2009-2012 The Bitcoin Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "crypter.h" + +#include "script.h" +#include "scrypt.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef WIN32 +#include +#endif + +bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod) +{ + if (nRounds < 1 || chSalt.size() != WALLET_CRYPTO_SALT_SIZE) + return false; + + int i = 0; + if (nDerivationMethod == 0) + { + i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha512(), &chSalt[0], + (unsigned char *)&strKeyData[0], strKeyData.size(), nRounds, chKey, chIV); + } + + if (nDerivationMethod == 1) + { + // Passphrase conversion + uint256 scryptHash = scrypt_salted_multiround_hash((const void*)strKeyData.c_str(), strKeyData.size(), &chSalt[0], 8, nRounds); + + i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha512(), &chSalt[0], + (unsigned char *)&scryptHash, sizeof scryptHash, nRounds, chKey, chIV); + OPENSSL_cleanse(&scryptHash, sizeof scryptHash); + } + + + if (i != (int)WALLET_CRYPTO_KEY_SIZE) + { + OPENSSL_cleanse(chKey, sizeof(chKey)); + OPENSSL_cleanse(chIV, sizeof(chIV)); + return false; + } + + fKeySet = true; + return true; +} + +bool CCrypter::SetKey(const CKeyingMaterial& chNewKey, const std::vector& chNewIV) +{ + if (chNewKey.size() != WALLET_CRYPTO_KEY_SIZE || chNewIV.size() != WALLET_CRYPTO_KEY_SIZE) + return false; + + memcpy(&chKey[0], &chNewKey[0], sizeof chKey); + memcpy(&chIV[0], &chNewIV[0], sizeof chIV); + + fKeySet = true; + return true; +} + +bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector &vchCiphertext) +{ + if (!fKeySet) + return false; + + // max ciphertext len for a n bytes of plaintext is + // n + AES_BLOCK_SIZE - 1 bytes + int nLen = vchPlaintext.size(); + int nCLen = nLen + AES_BLOCK_SIZE, nFLen = 0; + vchCiphertext = std::vector (nCLen); + + EVP_CIPHER_CTX ctx; + + bool fOk = true; + + EVP_CIPHER_CTX_init(&ctx); + if (fOk) fOk = EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); + if (fOk) fOk = EVP_EncryptUpdate(&ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen); + if (fOk) fOk = EVP_EncryptFinal_ex(&ctx, (&vchCiphertext[0])+nCLen, &nFLen); + EVP_CIPHER_CTX_cleanup(&ctx); + + if (!fOk) return false; + + vchCiphertext.resize(nCLen + nFLen); + return true; +} + +bool CCrypter::Decrypt(const std::vector& vchCiphertext, CKeyingMaterial& vchPlaintext) +{ + if (!fKeySet) + return false; + + // plaintext will always be equal to or lesser than length of ciphertext + int nLen = vchCiphertext.size(); + int nPLen = nLen, nFLen = 0; + + vchPlaintext = CKeyingMaterial(nPLen); + + EVP_CIPHER_CTX ctx; + + bool fOk = true; + + EVP_CIPHER_CTX_init(&ctx); + if (fOk) fOk = EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); + if (fOk) fOk = EVP_DecryptUpdate(&ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen); + if (fOk) fOk = EVP_DecryptFinal_ex(&ctx, (&vchPlaintext[0])+nPLen, &nFLen); + EVP_CIPHER_CTX_cleanup(&ctx); + + if (!fOk) return false; + + vchPlaintext.resize(nPLen + nFLen); + return true; +} + + +bool EncryptSecret(const CKeyingMaterial& vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256& nIV, std::vector &vchCiphertext) +{ + CCrypter cKeyCrypter; + std::vector chIV(WALLET_CRYPTO_KEY_SIZE); + memcpy(&chIV[0], &nIV, WALLET_CRYPTO_KEY_SIZE); + if(!cKeyCrypter.SetKey(vMasterKey, chIV)) + return false; + return cKeyCrypter.Encrypt(*((const CKeyingMaterial*)&vchPlaintext), vchCiphertext); +} + +bool DecryptSecret(const CKeyingMaterial& vMasterKey, const std::vector& vchCiphertext, const uint256& nIV, CKeyingMaterial& vchPlaintext) +{ + CCrypter cKeyCrypter; + std::vector chIV(WALLET_CRYPTO_KEY_SIZE); + memcpy(&chIV[0], &nIV, WALLET_CRYPTO_KEY_SIZE); + if(!cKeyCrypter.SetKey(vMasterKey, chIV)) + return false; + return cKeyCrypter.Decrypt(vchCiphertext, *((CKeyingMaterial*)&vchPlaintext)); +} + +// General secure AES 256 CBC encryption routine +bool EncryptAES256(const SecureString& sKey, const SecureString& sPlaintext, const std::string& sIV, std::string& sCiphertext) +{ + // max ciphertext len for a n bytes of plaintext is + // n + AES_BLOCK_SIZE - 1 bytes + int nLen = sPlaintext.size(); + int nCLen = nLen + AES_BLOCK_SIZE; + int nFLen = 0; + + // Verify key sizes + if(sKey.size() != 32 || sIV.size() != AES_BLOCK_SIZE) { + LogPrintf("crypter EncryptAES256 - Invalid key or block size: Key: %d sIV:%d\n", sKey.size(), sIV.size()); + return false; + } + + // Prepare output buffer + sCiphertext.resize(nCLen); + + // Perform the encryption + EVP_CIPHER_CTX ctx; + + bool fOk = true; + + EVP_CIPHER_CTX_init(&ctx); + if (fOk) fOk = EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, (const unsigned char*) &sKey[0], (const unsigned char*) &sIV[0]); + if (fOk) fOk = EVP_EncryptUpdate(&ctx, (unsigned char*) &sCiphertext[0], &nCLen, (const unsigned char*) &sPlaintext[0], nLen); + if (fOk) fOk = EVP_EncryptFinal_ex(&ctx, (unsigned char*) (&sCiphertext[0])+nCLen, &nFLen); + EVP_CIPHER_CTX_cleanup(&ctx); + + if (!fOk) return false; + + sCiphertext.resize(nCLen + nFLen); + return true; +} + +bool DecryptAES256(const SecureString& sKey, const std::string& sCiphertext, const std::string& sIV, SecureString& sPlaintext) +{ + // plaintext will always be equal to or lesser than length of ciphertext + int nLen = sCiphertext.size(); + int nPLen = nLen, nFLen = 0; + + // Verify key sizes + if(sKey.size() != 32 || sIV.size() != AES_BLOCK_SIZE) { + LogPrintf("crypter DecryptAES256 - Invalid key or block size\n"); + return false; + } + + sPlaintext.resize(nPLen); + + EVP_CIPHER_CTX ctx; + + bool fOk = true; + + EVP_CIPHER_CTX_init(&ctx); + if (fOk) fOk = EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, (const unsigned char*) &sKey[0], (const unsigned char*) &sIV[0]); + if (fOk) fOk = EVP_DecryptUpdate(&ctx, (unsigned char *) &sPlaintext[0], &nPLen, (const unsigned char *) &sCiphertext[0], nLen); + if (fOk) fOk = EVP_DecryptFinal_ex(&ctx, (unsigned char *) (&sPlaintext[0])+nPLen, &nFLen); + EVP_CIPHER_CTX_cleanup(&ctx); + + if (!fOk) return false; + + sPlaintext.resize(nPLen + nFLen); + return true; +} + + + +bool CCryptoKeyStore::SetCrypted() +{ + LOCK(cs_KeyStore); + if (fUseCrypto) + return true; + if (!mapKeys.empty()) + return false; + fUseCrypto = true; + return true; +} + +bool CCryptoKeyStore::LockKeyStore() +{ + if (!SetCrypted()) + return false; + + { + LOCK(cs_KeyStore); + vMasterKey.clear(); + } + + NotifyStatusChanged(this); + return true; +} + +bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn) +{ + { + LOCK(cs_KeyStore); + if (!SetCrypted()) + return false; + + CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin(); + for (; mi != mapCryptedKeys.end(); ++mi) + { + const CPubKey &vchPubKey = (*mi).second.first; + const std::vector &vchCryptedSecret = (*mi).second.second; + CKeyingMaterial vchSecret; + if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret, vchPubKey.GetHash(), vchSecret)) + return false; + if (vchSecret.size() != 32) + return false; + CKey key; + key.Set(vchSecret.begin(), vchSecret.end(), vchPubKey.IsCompressed()); + if (key.GetPubKey() == vchPubKey) + break; + return false; + } + vMasterKey = vMasterKeyIn; + } + NotifyStatusChanged(this); + return true; +} + +bool CCryptoKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey) +{ + { + LOCK(cs_KeyStore); + if (!IsCrypted()) + return CBasicKeyStore::AddKeyPubKey(key, pubkey); + + if (IsLocked()) + return false; + + std::vector vchCryptedSecret; + CKeyingMaterial vchSecret(key.begin(), key.end()); + if (!EncryptSecret(vMasterKey, vchSecret, pubkey.GetHash(), vchCryptedSecret)) + return false; + + if (!AddCryptedKey(pubkey, vchCryptedSecret)) + return false; + } + return true; +} + + +bool CCryptoKeyStore::AddCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret) +{ + { + LOCK(cs_KeyStore); + if (!SetCrypted()) + return false; + + mapCryptedKeys[vchPubKey.GetID()] = make_pair(vchPubKey, vchCryptedSecret); + } + return true; +} + +bool CCryptoKeyStore::GetKey(const CKeyID &address, CKey& keyOut) const +{ + { + LOCK(cs_KeyStore); + if (!IsCrypted()) + return CBasicKeyStore::GetKey(address, keyOut); + + CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address); + if (mi != mapCryptedKeys.end()) + { + const CPubKey &vchPubKey = (*mi).second.first; + const std::vector &vchCryptedSecret = (*mi).second.second; + CKeyingMaterial vchSecret; + if (!DecryptSecret(vMasterKey, vchCryptedSecret, vchPubKey.GetHash(), vchSecret)) + return false; + if (vchSecret.size() != 32) + return false; + keyOut.Set(vchSecret.begin(), vchSecret.end(), vchPubKey.IsCompressed()); + return true; + } + } + return false; +} + +bool CCryptoKeyStore::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const +{ + { + LOCK(cs_KeyStore); + if (!IsCrypted()) + return CKeyStore::GetPubKey(address, vchPubKeyOut); + + CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address); + if (mi != mapCryptedKeys.end()) + { + vchPubKeyOut = (*mi).second.first; + return true; + } + } + return false; +} + +bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn) +{ + { + LOCK(cs_KeyStore); + if (!mapCryptedKeys.empty() || IsCrypted()) + return false; + + fUseCrypto = true; + BOOST_FOREACH(KeyMap::value_type& mKey, mapKeys) + { + const CKey &key = mKey.second; + CPubKey vchPubKey = key.GetPubKey(); + CKeyingMaterial vchSecret(key.begin(), key.end()); + std::vector vchCryptedSecret; + if (!EncryptSecret(vMasterKeyIn, vchSecret, vchPubKey.GetHash(), vchCryptedSecret)) + return false; + if (!AddCryptedKey(vchPubKey, vchCryptedSecret)) + return false; + } + mapKeys.clear(); + } + return true; +} + + diff --git a/src/crypter.h b/src/crypter.h new file mode 100644 index 0000000..7d3f53b --- /dev/null +++ b/src/crypter.h @@ -0,0 +1,215 @@ +// Copyright (c) 2009-2012 The Bitcoin Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef __CRYPTER_H__ +#define __CRYPTER_H__ + +#include "allocators.h" /* for SecureString */ +#include "key.h" +#include "serialize.h" +#include "keystore.h" + +const unsigned int WALLET_CRYPTO_KEY_SIZE = 32; +const unsigned int WALLET_CRYPTO_SALT_SIZE = 8; + +/* +Private key encryption is done based on a CMasterKey, +which holds a salt and random encryption key. + +CMasterKeys are encrypted using AES-256-CBC using a key +derived using derivation method nDerivationMethod +(0 == EVP_sha512()) and derivation iterations nDeriveIterations. +vchOtherDerivationParameters is provided for alternative algorithms +which may require more parameters (such as scrypt). + +Wallet Private Keys are then encrypted using AES-256-CBC +with the double-sha256 of the public key as the IV, and the +master key's key as the encryption key (see keystore.[ch]). +*/ + +/** Master key for wallet encryption */ +class CMasterKey +{ +public: + std::vector vchCryptedKey; + std::vector vchSalt; + // 0 = EVP_sha512() + // 1 = scrypt() + unsigned int nDerivationMethod; + unsigned int nDeriveIterations; + // Use this for more parameters to key derivation, + // such as the various parameters to scrypt + std::vector vchOtherDerivationParameters; + + IMPLEMENT_SERIALIZE + ( + READWRITE(vchCryptedKey); + READWRITE(vchSalt); + READWRITE(nDerivationMethod); + READWRITE(nDeriveIterations); + READWRITE(vchOtherDerivationParameters); + ) + CMasterKey() + { + // 25000 rounds is just under 0.1 seconds on a 1.86 GHz Pentium M + // ie slightly lower than the lowest hardware we need bother supporting + nDeriveIterations = 25000; + nDerivationMethod = 1; + vchOtherDerivationParameters = std::vector(0); + } + + CMasterKey(unsigned int nDerivationMethodIndex) + { + switch (nDerivationMethodIndex) + { + case 0: // sha512 + default: + nDeriveIterations = 25000; + nDerivationMethod = 0; + vchOtherDerivationParameters = std::vector(0); + break; + + case 1: // scrypt+sha512 + nDeriveIterations = 10000; + nDerivationMethod = 1; + vchOtherDerivationParameters = std::vector(0); + break; + } + } + +}; + +typedef std::vector > CKeyingMaterial; + +/** Encryption/decryption context with key information */ +class CCrypter +{ +private: + unsigned char chKey[WALLET_CRYPTO_KEY_SIZE]; + unsigned char chIV[WALLET_CRYPTO_KEY_SIZE]; + bool fKeySet; + +public: + bool SetKeyFromPassphrase(const SecureString &strKeyData, const std::vector& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod); + bool Encrypt(const CKeyingMaterial& vchPlaintext, std::vector &vchCiphertext); + bool Decrypt(const std::vector& vchCiphertext, CKeyingMaterial& vchPlaintext); + bool SetKey(const CKeyingMaterial& chNewKey, const std::vector& chNewIV); + + void CleanKey() + { + OPENSSL_cleanse(chKey, sizeof(chKey)); + OPENSSL_cleanse(chIV, sizeof(chIV)); + fKeySet = false; + } + + CCrypter() + { + fKeySet = false; + + // Try to keep the key data out of swap (and be a bit over-careful to keep the IV that we don't even use out of swap) + // Note that this does nothing about suspend-to-disk (which will put all our key data on disk) + // Note as well that at no point in this program is any attempt made to prevent stealing of keys by reading the memory of the running process. + LockedPageManager::instance.LockRange(&chKey[0], sizeof chKey); + LockedPageManager::instance.LockRange(&chIV[0], sizeof chIV); + } + + ~CCrypter() + { + CleanKey(); + + LockedPageManager::instance.UnlockRange(&chKey[0], sizeof chKey); + LockedPageManager::instance.UnlockRange(&chIV[0], sizeof chIV); + } +}; + +bool EncryptSecret(const CKeyingMaterial& vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256& nIV, std::vector &vchCiphertext); +bool DecryptSecret(const CKeyingMaterial& vMasterKey, const std::vector& vchCiphertext, const uint256& nIV, CKeyingMaterial& vchPlaintext); + +bool EncryptAES256(const SecureString& sKey, const SecureString& sPlaintext, const std::string& sIV, std::string& sCiphertext); +bool DecryptAES256(const SecureString& sKey, const std::string& sCiphertext, const std::string& sIV, SecureString& sPlaintext); + +/** Keystore which keeps the private keys encrypted. + * It derives from the basic key store, which is used if no encryption is active. + */ +class CCryptoKeyStore : public CBasicKeyStore +{ +private: + // if fUseCrypto is true, mapKeys must be empty + // if fUseCrypto is false, vMasterKey must be empty + bool fUseCrypto; + +protected: + CryptedKeyMap mapCryptedKeys; + CKeyingMaterial vMasterKey; + + bool SetCrypted(); + + // will encrypt previously unencrypted keys + bool EncryptKeys(CKeyingMaterial& vMasterKeyIn); + + bool Unlock(const CKeyingMaterial& vMasterKeyIn); + +public: + CCryptoKeyStore() : fUseCrypto(false) + { + } + + bool IsCrypted() const + { + return fUseCrypto; + } + + bool IsLocked() const + { + if (!IsCrypted()) + return false; + bool result; + { + LOCK(cs_KeyStore); + result = vMasterKey.empty(); + } + return result; + } + + bool LockKeyStore(); + + virtual bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret); + bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey); + bool HaveKey(const CKeyID &address) const + { + { + LOCK(cs_KeyStore); + if (!IsCrypted()) + return CBasicKeyStore::HaveKey(address); + return mapCryptedKeys.count(address) > 0; + } + return false; + } + bool GetKey(const CKeyID &address, CKey& keyOut) const; + bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const; + void GetKeys(std::set &setAddress) const + { + if (!IsCrypted()) + { + CBasicKeyStore::GetKeys(setAddress); + return; + } + setAddress.clear(); + CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin(); + while (mi != mapCryptedKeys.end()) + { + setAddress.insert((*mi).first); + mi++; + } + } + + /* Wallet status (encrypted, locked) changed. + * Note: Called without locks held. + */ + boost::signals2::signal NotifyStatusChanged; +}; + + + + +#endif diff --git a/src/crypto/common.h b/src/crypto/common.h new file mode 100644 index 0000000..dab16cc --- /dev/null +++ b/src/crypto/common.h @@ -0,0 +1,116 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef SONO_CRYPTO_COMMON_H +#define SONO_CRYPTO_COMMON_H + +#include + +#if defined(HAVE_ENDIAN_H) +#include +#endif + +uint32_t static inline ReadLE32(const unsigned char* ptr) +{ +#if HAVE_DECL_LE32TOH == 1 + return le32toh(*((uint32_t*)ptr)); +#elif !defined(WORDS_BIGENDIAN) + return *((uint32_t*)ptr); +#else + return ((uint32_t)ptr[3] << 24 | (uint32_t)ptr[2] << 16 | (uint32_t)ptr[1] << 8 | (uint32_t)ptr[0]); +#endif +} + +uint64_t static inline ReadLE64(const unsigned char* ptr) +{ +#if HAVE_DECL_LE64TOH == 1 + return le64toh(*((uint64_t*)ptr)); +#elif !defined(WORDS_BIGENDIAN) + return *((uint64_t*)ptr); +#else + return ((uint64_t)ptr[7] << 56 | (uint64_t)ptr[6] << 48 | (uint64_t)ptr[5] << 40 | (uint64_t)ptr[4] << 32 | + (uint64_t)ptr[3] << 24 | (uint64_t)ptr[2] << 16 | (uint64_t)ptr[1] << 8 | (uint64_t)ptr[0]); +#endif +} + +void static inline WriteLE32(unsigned char* ptr, uint32_t x) +{ +#if HAVE_DECL_HTOLE32 == 1 + *((uint32_t*)ptr) = htole32(x); +#elif !defined(WORDS_BIGENDIAN) + *((uint32_t*)ptr) = x; +#else + ptr[3] = x >> 24; + ptr[2] = x >> 16; + ptr[1] = x >> 8; + ptr[0] = x; +#endif +} + +void static inline WriteLE64(unsigned char* ptr, uint64_t x) +{ +#if HAVE_DECL_HTOLE64 == 1 + *((uint64_t*)ptr) = htole64(x); +#elif !defined(WORDS_BIGENDIAN) + *((uint64_t*)ptr) = x; +#else + ptr[7] = x >> 56; + ptr[6] = x >> 48; + ptr[5] = x >> 40; + ptr[4] = x >> 32; + ptr[3] = x >> 24; + ptr[2] = x >> 16; + ptr[1] = x >> 8; + ptr[0] = x; +#endif +} + +uint32_t static inline ReadBE32(const unsigned char* ptr) +{ +#if HAVE_DECL_BE32TOH == 1 + return be32toh(*((uint32_t*)ptr)); +#else + return ((uint32_t)ptr[0] << 24 | (uint32_t)ptr[1] << 16 | (uint32_t)ptr[2] << 8 | (uint32_t)ptr[3]); +#endif +} + +uint64_t static inline ReadBE64(const unsigned char* ptr) +{ +#if HAVE_DECL_BE64TOH == 1 + return be64toh(*((uint64_t*)ptr)); +#else + return ((uint64_t)ptr[0] << 56 | (uint64_t)ptr[1] << 48 | (uint64_t)ptr[2] << 40 | (uint64_t)ptr[3] << 32 | + (uint64_t)ptr[4] << 24 | (uint64_t)ptr[5] << 16 | (uint64_t)ptr[6] << 8 | (uint64_t)ptr[7]); +#endif +} + +void static inline WriteBE32(unsigned char* ptr, uint32_t x) +{ +#if HAVE_DECL_HTOBE32 == 1 + *((uint32_t*)ptr) = htobe32(x); +#else + ptr[0] = x >> 24; + ptr[1] = x >> 16; + ptr[2] = x >> 8; + ptr[3] = x; +#endif +} + +void static inline WriteBE64(unsigned char* ptr, uint64_t x) +{ +#if HAVE_DECL_HTOBE64 == 1 + *((uint64_t*)ptr) = htobe64(x); +#else + ptr[0] = x >> 56; + ptr[1] = x >> 48; + ptr[2] = x >> 40; + ptr[3] = x >> 32; + ptr[4] = x >> 24; + ptr[5] = x >> 16; + ptr[6] = x >> 8; + ptr[7] = x; +#endif +} + +#endif // SONO_CRYPTO_COMMON_H diff --git a/src/crypto/hmac_sha256.cpp b/src/crypto/hmac_sha256.cpp new file mode 100644 index 0000000..3c79162 --- /dev/null +++ b/src/crypto/hmac_sha256.cpp @@ -0,0 +1,34 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "crypto/hmac_sha256.h" + +#include + +CHMAC_SHA256::CHMAC_SHA256(const unsigned char* key, size_t keylen) +{ + unsigned char rkey[64]; + if (keylen <= 64) { + memcpy(rkey, key, keylen); + memset(rkey + keylen, 0, 64 - keylen); + } else { + CSHA256().Write(key, keylen).Finalize(rkey); + memset(rkey + 32, 0, 32); + } + + for (int n = 0; n < 64; n++) + rkey[n] ^= 0x5c; + outer.Write(rkey, 64); + + for (int n = 0; n < 64; n++) + rkey[n] ^= 0x5c ^ 0x36; + inner.Write(rkey, 64); +} + +void CHMAC_SHA256::Finalize(unsigned char hash[OUTPUT_SIZE]) +{ + unsigned char temp[32]; + inner.Finalize(temp); + outer.Write(temp, 32).Finalize(hash); +} diff --git a/src/crypto/hmac_sha256.h b/src/crypto/hmac_sha256.h new file mode 100644 index 0000000..1519c14 --- /dev/null +++ b/src/crypto/hmac_sha256.h @@ -0,0 +1,32 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_CRYPTO_HMAC_SHA256_H +#define BITCOIN_CRYPTO_HMAC_SHA256_H + +#include "crypto/sha256.h" + +#include +#include + +/** A hasher class for HMAC-SHA-512. */ +class CHMAC_SHA256 +{ +private: + CSHA256 outer; + CSHA256 inner; + +public: + static const size_t OUTPUT_SIZE = 32; + + CHMAC_SHA256(const unsigned char* key, size_t keylen); + CHMAC_SHA256& Write(const unsigned char* data, size_t len) + { + inner.Write(data, len); + return *this; + } + void Finalize(unsigned char hash[OUTPUT_SIZE]); +}; + +#endif // BITCOIN_CRYPTO_HMAC_SHA256_H diff --git a/src/crypto/hmac_sha512.cpp b/src/crypto/hmac_sha512.cpp new file mode 100644 index 0000000..5939c6e --- /dev/null +++ b/src/crypto/hmac_sha512.cpp @@ -0,0 +1,34 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "crypto/hmac_sha512.h" + +#include + +CHMAC_SHA512::CHMAC_SHA512(const unsigned char* key, size_t keylen) +{ + unsigned char rkey[128]; + if (keylen <= 128) { + memcpy(rkey, key, keylen); + memset(rkey + keylen, 0, 128 - keylen); + } else { + CSHA512().Write(key, keylen).Finalize(rkey); + memset(rkey + 64, 0, 64); + } + + for (int n = 0; n < 128; n++) + rkey[n] ^= 0x5c; + outer.Write(rkey, 128); + + for (int n = 0; n < 128; n++) + rkey[n] ^= 0x5c ^ 0x36; + inner.Write(rkey, 128); +} + +void CHMAC_SHA512::Finalize(unsigned char hash[OUTPUT_SIZE]) +{ + unsigned char temp[64]; + inner.Finalize(temp); + outer.Write(temp, 64).Finalize(hash); +} diff --git a/src/crypto/hmac_sha512.h b/src/crypto/hmac_sha512.h new file mode 100644 index 0000000..17dee61 --- /dev/null +++ b/src/crypto/hmac_sha512.h @@ -0,0 +1,32 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_CRYPTO_HMAC_SHA512_H +#define BITCOIN_CRYPTO_HMAC_SHA512_H + +#include "crypto/sha512.h" + +#include +#include + +/** A hasher class for HMAC-SHA-512. */ +class CHMAC_SHA512 +{ +private: + CSHA512 outer; + CSHA512 inner; + +public: + static const size_t OUTPUT_SIZE = 64; + + CHMAC_SHA512(const unsigned char* key, size_t keylen); + CHMAC_SHA512& Write(const unsigned char* data, size_t len) + { + inner.Write(data, len); + return *this; + } + void Finalize(unsigned char hash[OUTPUT_SIZE]); +}; + +#endif // BITCOIN_CRYPTO_HMAC_SHA512_H diff --git a/src/crypto/rfc6979_hmac_sha256.cpp b/src/crypto/rfc6979_hmac_sha256.cpp new file mode 100644 index 0000000..a8c971c --- /dev/null +++ b/src/crypto/rfc6979_hmac_sha256.cpp @@ -0,0 +1,47 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "crypto/rfc6979_hmac_sha256.h" + +#include + +#include + +static const unsigned char zero[1] = {0x00}; +static const unsigned char one[1] = {0x01}; + +RFC6979_HMAC_SHA256::RFC6979_HMAC_SHA256(const unsigned char* key, size_t keylen, const unsigned char* msg, size_t msglen) : retry(false) +{ + memset(V, 0x01, sizeof(V)); + memset(K, 0x00, sizeof(K)); + + CHMAC_SHA256(K, sizeof(K)).Write(V, sizeof(V)).Write(zero, sizeof(zero)).Write(key, keylen).Write(msg, msglen).Finalize(K); + CHMAC_SHA256(K, sizeof(K)).Write(V, sizeof(V)).Finalize(V); + CHMAC_SHA256(K, sizeof(K)).Write(V, sizeof(V)).Write(one, sizeof(one)).Write(key, keylen).Write(msg, msglen).Finalize(K); + CHMAC_SHA256(K, sizeof(K)).Write(V, sizeof(V)).Finalize(V); +} + +RFC6979_HMAC_SHA256::~RFC6979_HMAC_SHA256() +{ + memset(V, 0x01, sizeof(V)); + memset(K, 0x00, sizeof(K)); +} + +void RFC6979_HMAC_SHA256::Generate(unsigned char* output, size_t outputlen) +{ + if (retry) { + CHMAC_SHA256(K, sizeof(K)).Write(V, sizeof(V)).Write(zero, sizeof(zero)).Finalize(K); + CHMAC_SHA256(K, sizeof(K)).Write(V, sizeof(V)).Finalize(V); + } + + while (outputlen > 0) { + CHMAC_SHA256(K, sizeof(K)).Write(V, sizeof(V)).Finalize(V); + size_t len = std::min(outputlen, sizeof(V)); + memcpy(output, V, len); + output += len; + outputlen -= len; + } + + retry = true; +} diff --git a/src/crypto/rfc6979_hmac_sha256.h b/src/crypto/rfc6979_hmac_sha256.h new file mode 100644 index 0000000..f3a54a5 --- /dev/null +++ b/src/crypto/rfc6979_hmac_sha256.h @@ -0,0 +1,36 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_RFC6979_HMAC_SHA256_H +#define BITCOIN_RFC6979_HMAC_SHA256_H + +#include "crypto/hmac_sha256.h" + +#include +#include + +/** The RFC 6979 PRNG using HMAC-SHA256. */ +class RFC6979_HMAC_SHA256 +{ +private: + unsigned char V[CHMAC_SHA256::OUTPUT_SIZE]; + unsigned char K[CHMAC_SHA256::OUTPUT_SIZE]; + bool retry; + +public: + /** + * Construct a new RFC6979 PRNG, using the given key and message. + * The message is assumed to be already hashed. + */ + RFC6979_HMAC_SHA256(const unsigned char* key, size_t keylen, const unsigned char* msg, size_t msglen); + + /** + * Generate a byte array. + */ + void Generate(unsigned char* output, size_t outputlen); + + ~RFC6979_HMAC_SHA256(); +}; + +#endif // BITCOIN_RFC6979_HMAC_SHA256_H diff --git a/src/crypto/ripemd160.cpp b/src/crypto/ripemd160.cpp new file mode 100644 index 0000000..77c9acf --- /dev/null +++ b/src/crypto/ripemd160.cpp @@ -0,0 +1,292 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "crypto/ripemd160.h" + +#include "crypto/common.h" + +#include + +// Internal implementation code. +namespace +{ +/// Internal RIPEMD-160 implementation. +namespace ripemd160 +{ +uint32_t inline f1(uint32_t x, uint32_t y, uint32_t z) { return x ^ y ^ z; } +uint32_t inline f2(uint32_t x, uint32_t y, uint32_t z) { return (x & y) | (~x & z); } +uint32_t inline f3(uint32_t x, uint32_t y, uint32_t z) { return (x | ~y) ^ z; } +uint32_t inline f4(uint32_t x, uint32_t y, uint32_t z) { return (x & z) | (y & ~z); } +uint32_t inline f5(uint32_t x, uint32_t y, uint32_t z) { return x ^ (y | ~z); } + +/** Initialize RIPEMD-160 state. */ +void inline Initialize(uint32_t* s) +{ + s[0] = 0x67452301ul; + s[1] = 0xEFCDAB89ul; + s[2] = 0x98BADCFEul; + s[3] = 0x10325476ul; + s[4] = 0xC3D2E1F0ul; +} + +uint32_t inline rol(uint32_t x, int i) { return (x << i) | (x >> (32 - i)); } + +void inline Round(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t f, uint32_t x, uint32_t k, int r) +{ + a = rol(a + f + x + k, r) + e; + c = rol(c, 10); +} + +void inline R11(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f1(b, c, d), x, 0, r); } +void inline R21(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f2(b, c, d), x, 0x5A827999ul, r); } +void inline R31(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f3(b, c, d), x, 0x6ED9EBA1ul, r); } +void inline R41(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f4(b, c, d), x, 0x8F1BBCDCul, r); } +void inline R51(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f5(b, c, d), x, 0xA953FD4Eul, r); } + +void inline R12(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f5(b, c, d), x, 0x50A28BE6ul, r); } +void inline R22(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f4(b, c, d), x, 0x5C4DD124ul, r); } +void inline R32(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f3(b, c, d), x, 0x6D703EF3ul, r); } +void inline R42(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f2(b, c, d), x, 0x7A6D76E9ul, r); } +void inline R52(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f1(b, c, d), x, 0, r); } + +/** Perform a RIPEMD-160 transformation, processing a 64-byte chunk. */ +void Transform(uint32_t* s, const unsigned char* chunk) +{ + uint32_t a1 = s[0], b1 = s[1], c1 = s[2], d1 = s[3], e1 = s[4]; + uint32_t a2 = a1, b2 = b1, c2 = c1, d2 = d1, e2 = e1; + uint32_t w0 = ReadLE32(chunk + 0), w1 = ReadLE32(chunk + 4), w2 = ReadLE32(chunk + 8), w3 = ReadLE32(chunk + 12); + uint32_t w4 = ReadLE32(chunk + 16), w5 = ReadLE32(chunk + 20), w6 = ReadLE32(chunk + 24), w7 = ReadLE32(chunk + 28); + uint32_t w8 = ReadLE32(chunk + 32), w9 = ReadLE32(chunk + 36), w10 = ReadLE32(chunk + 40), w11 = ReadLE32(chunk + 44); + uint32_t w12 = ReadLE32(chunk + 48), w13 = ReadLE32(chunk + 52), w14 = ReadLE32(chunk + 56), w15 = ReadLE32(chunk + 60); + + R11(a1, b1, c1, d1, e1, w0, 11); + R12(a2, b2, c2, d2, e2, w5, 8); + R11(e1, a1, b1, c1, d1, w1, 14); + R12(e2, a2, b2, c2, d2, w14, 9); + R11(d1, e1, a1, b1, c1, w2, 15); + R12(d2, e2, a2, b2, c2, w7, 9); + R11(c1, d1, e1, a1, b1, w3, 12); + R12(c2, d2, e2, a2, b2, w0, 11); + R11(b1, c1, d1, e1, a1, w4, 5); + R12(b2, c2, d2, e2, a2, w9, 13); + R11(a1, b1, c1, d1, e1, w5, 8); + R12(a2, b2, c2, d2, e2, w2, 15); + R11(e1, a1, b1, c1, d1, w6, 7); + R12(e2, a2, b2, c2, d2, w11, 15); + R11(d1, e1, a1, b1, c1, w7, 9); + R12(d2, e2, a2, b2, c2, w4, 5); + R11(c1, d1, e1, a1, b1, w8, 11); + R12(c2, d2, e2, a2, b2, w13, 7); + R11(b1, c1, d1, e1, a1, w9, 13); + R12(b2, c2, d2, e2, a2, w6, 7); + R11(a1, b1, c1, d1, e1, w10, 14); + R12(a2, b2, c2, d2, e2, w15, 8); + R11(e1, a1, b1, c1, d1, w11, 15); + R12(e2, a2, b2, c2, d2, w8, 11); + R11(d1, e1, a1, b1, c1, w12, 6); + R12(d2, e2, a2, b2, c2, w1, 14); + R11(c1, d1, e1, a1, b1, w13, 7); + R12(c2, d2, e2, a2, b2, w10, 14); + R11(b1, c1, d1, e1, a1, w14, 9); + R12(b2, c2, d2, e2, a2, w3, 12); + R11(a1, b1, c1, d1, e1, w15, 8); + R12(a2, b2, c2, d2, e2, w12, 6); + + R21(e1, a1, b1, c1, d1, w7, 7); + R22(e2, a2, b2, c2, d2, w6, 9); + R21(d1, e1, a1, b1, c1, w4, 6); + R22(d2, e2, a2, b2, c2, w11, 13); + R21(c1, d1, e1, a1, b1, w13, 8); + R22(c2, d2, e2, a2, b2, w3, 15); + R21(b1, c1, d1, e1, a1, w1, 13); + R22(b2, c2, d2, e2, a2, w7, 7); + R21(a1, b1, c1, d1, e1, w10, 11); + R22(a2, b2, c2, d2, e2, w0, 12); + R21(e1, a1, b1, c1, d1, w6, 9); + R22(e2, a2, b2, c2, d2, w13, 8); + R21(d1, e1, a1, b1, c1, w15, 7); + R22(d2, e2, a2, b2, c2, w5, 9); + R21(c1, d1, e1, a1, b1, w3, 15); + R22(c2, d2, e2, a2, b2, w10, 11); + R21(b1, c1, d1, e1, a1, w12, 7); + R22(b2, c2, d2, e2, a2, w14, 7); + R21(a1, b1, c1, d1, e1, w0, 12); + R22(a2, b2, c2, d2, e2, w15, 7); + R21(e1, a1, b1, c1, d1, w9, 15); + R22(e2, a2, b2, c2, d2, w8, 12); + R21(d1, e1, a1, b1, c1, w5, 9); + R22(d2, e2, a2, b2, c2, w12, 7); + R21(c1, d1, e1, a1, b1, w2, 11); + R22(c2, d2, e2, a2, b2, w4, 6); + R21(b1, c1, d1, e1, a1, w14, 7); + R22(b2, c2, d2, e2, a2, w9, 15); + R21(a1, b1, c1, d1, e1, w11, 13); + R22(a2, b2, c2, d2, e2, w1, 13); + R21(e1, a1, b1, c1, d1, w8, 12); + R22(e2, a2, b2, c2, d2, w2, 11); + + R31(d1, e1, a1, b1, c1, w3, 11); + R32(d2, e2, a2, b2, c2, w15, 9); + R31(c1, d1, e1, a1, b1, w10, 13); + R32(c2, d2, e2, a2, b2, w5, 7); + R31(b1, c1, d1, e1, a1, w14, 6); + R32(b2, c2, d2, e2, a2, w1, 15); + R31(a1, b1, c1, d1, e1, w4, 7); + R32(a2, b2, c2, d2, e2, w3, 11); + R31(e1, a1, b1, c1, d1, w9, 14); + R32(e2, a2, b2, c2, d2, w7, 8); + R31(d1, e1, a1, b1, c1, w15, 9); + R32(d2, e2, a2, b2, c2, w14, 6); + R31(c1, d1, e1, a1, b1, w8, 13); + R32(c2, d2, e2, a2, b2, w6, 6); + R31(b1, c1, d1, e1, a1, w1, 15); + R32(b2, c2, d2, e2, a2, w9, 14); + R31(a1, b1, c1, d1, e1, w2, 14); + R32(a2, b2, c2, d2, e2, w11, 12); + R31(e1, a1, b1, c1, d1, w7, 8); + R32(e2, a2, b2, c2, d2, w8, 13); + R31(d1, e1, a1, b1, c1, w0, 13); + R32(d2, e2, a2, b2, c2, w12, 5); + R31(c1, d1, e1, a1, b1, w6, 6); + R32(c2, d2, e2, a2, b2, w2, 14); + R31(b1, c1, d1, e1, a1, w13, 5); + R32(b2, c2, d2, e2, a2, w10, 13); + R31(a1, b1, c1, d1, e1, w11, 12); + R32(a2, b2, c2, d2, e2, w0, 13); + R31(e1, a1, b1, c1, d1, w5, 7); + R32(e2, a2, b2, c2, d2, w4, 7); + R31(d1, e1, a1, b1, c1, w12, 5); + R32(d2, e2, a2, b2, c2, w13, 5); + + R41(c1, d1, e1, a1, b1, w1, 11); + R42(c2, d2, e2, a2, b2, w8, 15); + R41(b1, c1, d1, e1, a1, w9, 12); + R42(b2, c2, d2, e2, a2, w6, 5); + R41(a1, b1, c1, d1, e1, w11, 14); + R42(a2, b2, c2, d2, e2, w4, 8); + R41(e1, a1, b1, c1, d1, w10, 15); + R42(e2, a2, b2, c2, d2, w1, 11); + R41(d1, e1, a1, b1, c1, w0, 14); + R42(d2, e2, a2, b2, c2, w3, 14); + R41(c1, d1, e1, a1, b1, w8, 15); + R42(c2, d2, e2, a2, b2, w11, 14); + R41(b1, c1, d1, e1, a1, w12, 9); + R42(b2, c2, d2, e2, a2, w15, 6); + R41(a1, b1, c1, d1, e1, w4, 8); + R42(a2, b2, c2, d2, e2, w0, 14); + R41(e1, a1, b1, c1, d1, w13, 9); + R42(e2, a2, b2, c2, d2, w5, 6); + R41(d1, e1, a1, b1, c1, w3, 14); + R42(d2, e2, a2, b2, c2, w12, 9); + R41(c1, d1, e1, a1, b1, w7, 5); + R42(c2, d2, e2, a2, b2, w2, 12); + R41(b1, c1, d1, e1, a1, w15, 6); + R42(b2, c2, d2, e2, a2, w13, 9); + R41(a1, b1, c1, d1, e1, w14, 8); + R42(a2, b2, c2, d2, e2, w9, 12); + R41(e1, a1, b1, c1, d1, w5, 6); + R42(e2, a2, b2, c2, d2, w7, 5); + R41(d1, e1, a1, b1, c1, w6, 5); + R42(d2, e2, a2, b2, c2, w10, 15); + R41(c1, d1, e1, a1, b1, w2, 12); + R42(c2, d2, e2, a2, b2, w14, 8); + + R51(b1, c1, d1, e1, a1, w4, 9); + R52(b2, c2, d2, e2, a2, w12, 8); + R51(a1, b1, c1, d1, e1, w0, 15); + R52(a2, b2, c2, d2, e2, w15, 5); + R51(e1, a1, b1, c1, d1, w5, 5); + R52(e2, a2, b2, c2, d2, w10, 12); + R51(d1, e1, a1, b1, c1, w9, 11); + R52(d2, e2, a2, b2, c2, w4, 9); + R51(c1, d1, e1, a1, b1, w7, 6); + R52(c2, d2, e2, a2, b2, w1, 12); + R51(b1, c1, d1, e1, a1, w12, 8); + R52(b2, c2, d2, e2, a2, w5, 5); + R51(a1, b1, c1, d1, e1, w2, 13); + R52(a2, b2, c2, d2, e2, w8, 14); + R51(e1, a1, b1, c1, d1, w10, 12); + R52(e2, a2, b2, c2, d2, w7, 6); + R51(d1, e1, a1, b1, c1, w14, 5); + R52(d2, e2, a2, b2, c2, w6, 8); + R51(c1, d1, e1, a1, b1, w1, 12); + R52(c2, d2, e2, a2, b2, w2, 13); + R51(b1, c1, d1, e1, a1, w3, 13); + R52(b2, c2, d2, e2, a2, w13, 6); + R51(a1, b1, c1, d1, e1, w8, 14); + R52(a2, b2, c2, d2, e2, w14, 5); + R51(e1, a1, b1, c1, d1, w11, 11); + R52(e2, a2, b2, c2, d2, w0, 15); + R51(d1, e1, a1, b1, c1, w6, 8); + R52(d2, e2, a2, b2, c2, w3, 13); + R51(c1, d1, e1, a1, b1, w15, 5); + R52(c2, d2, e2, a2, b2, w9, 11); + R51(b1, c1, d1, e1, a1, w13, 6); + R52(b2, c2, d2, e2, a2, w11, 11); + + uint32_t t = s[0]; + s[0] = s[1] + c1 + d2; + s[1] = s[2] + d1 + e2; + s[2] = s[3] + e1 + a2; + s[3] = s[4] + a1 + b2; + s[4] = t + b1 + c2; +} + +} // namespace ripemd160 + +} // namespace + +////// RIPEMD160 + +CRIPEMD160::CRIPEMD160() : bytes(0) +{ + ripemd160::Initialize(s); +} + +CRIPEMD160& CRIPEMD160::Write(const unsigned char* data, size_t len) +{ + const unsigned char* end = data + len; + size_t bufsize = bytes % 64; + if (bufsize && bufsize + len >= 64) { + // Fill the buffer, and process it. + memcpy(buf + bufsize, data, 64 - bufsize); + bytes += 64 - bufsize; + data += 64 - bufsize; + ripemd160::Transform(s, buf); + bufsize = 0; + } + while (end >= data + 64) { + // Process full chunks directly from the source. + ripemd160::Transform(s, data); + bytes += 64; + data += 64; + } + if (end > data) { + // Fill the buffer with what remains. + memcpy(buf + bufsize, data, end - data); + bytes += end - data; + } + return *this; +} + +void CRIPEMD160::Finalize(unsigned char hash[OUTPUT_SIZE]) +{ + static const unsigned char pad[64] = {0x80}; + unsigned char sizedesc[8]; + WriteLE64(sizedesc, bytes << 3); + Write(pad, 1 + ((119 - (bytes % 64)) % 64)); + Write(sizedesc, 8); + WriteLE32(hash, s[0]); + WriteLE32(hash + 4, s[1]); + WriteLE32(hash + 8, s[2]); + WriteLE32(hash + 12, s[3]); + WriteLE32(hash + 16, s[4]); +} + +CRIPEMD160& CRIPEMD160::Reset() +{ + bytes = 0; + ripemd160::Initialize(s); + return *this; +} diff --git a/src/crypto/ripemd160.h b/src/crypto/ripemd160.h new file mode 100644 index 0000000..687204f --- /dev/null +++ b/src/crypto/ripemd160.h @@ -0,0 +1,28 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_CRYPTO_RIPEMD160_H +#define BITCOIN_CRYPTO_RIPEMD160_H + +#include +#include + +/** A hasher class for RIPEMD-160. */ +class CRIPEMD160 +{ +private: + uint32_t s[5]; + unsigned char buf[64]; + size_t bytes; + +public: + static const size_t OUTPUT_SIZE = 20; + + CRIPEMD160(); + CRIPEMD160& Write(const unsigned char* data, size_t len); + void Finalize(unsigned char hash[OUTPUT_SIZE]); + CRIPEMD160& Reset(); +}; + +#endif // BITCOIN_CRYPTO_RIPEMD160_H diff --git a/src/crypto/sha1.cpp b/src/crypto/sha1.cpp new file mode 100644 index 0000000..0b895b3 --- /dev/null +++ b/src/crypto/sha1.cpp @@ -0,0 +1,199 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "crypto/sha1.h" + +#include "crypto/common.h" + +#include + +// Internal implementation code. +namespace +{ +/// Internal SHA-1 implementation. +namespace sha1 +{ +/** One round of SHA-1. */ +void inline Round(uint32_t a, uint32_t& b, uint32_t c, uint32_t d, uint32_t& e, uint32_t f, uint32_t k, uint32_t w) +{ + e += ((a << 5) | (a >> 27)) + f + k + w; + b = (b << 30) | (b >> 2); +} + +uint32_t inline f1(uint32_t b, uint32_t c, uint32_t d) { return d ^ (b & (c ^ d)); } +uint32_t inline f2(uint32_t b, uint32_t c, uint32_t d) { return b ^ c ^ d; } +uint32_t inline f3(uint32_t b, uint32_t c, uint32_t d) { return (b & c) | (d & (b | c)); } + +uint32_t inline left(uint32_t x) { return (x << 1) | (x >> 31); } + +/** Initialize SHA-1 state. */ +void inline Initialize(uint32_t* s) +{ + s[0] = 0x67452301ul; + s[1] = 0xEFCDAB89ul; + s[2] = 0x98BADCFEul; + s[3] = 0x10325476ul; + s[4] = 0xC3D2E1F0ul; +} + +const uint32_t k1 = 0x5A827999ul; +const uint32_t k2 = 0x6ED9EBA1ul; +const uint32_t k3 = 0x8F1BBCDCul; +const uint32_t k4 = 0xCA62C1D6ul; + +/** Perform a SHA-1 transformation, processing a 64-byte chunk. */ +void Transform(uint32_t* s, const unsigned char* chunk) +{ + uint32_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4]; + uint32_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15; + + Round(a, b, c, d, e, f1(b, c, d), k1, w0 = ReadBE32(chunk + 0)); + Round(e, a, b, c, d, f1(a, b, c), k1, w1 = ReadBE32(chunk + 4)); + Round(d, e, a, b, c, f1(e, a, b), k1, w2 = ReadBE32(chunk + 8)); + Round(c, d, e, a, b, f1(d, e, a), k1, w3 = ReadBE32(chunk + 12)); + Round(b, c, d, e, a, f1(c, d, e), k1, w4 = ReadBE32(chunk + 16)); + Round(a, b, c, d, e, f1(b, c, d), k1, w5 = ReadBE32(chunk + 20)); + Round(e, a, b, c, d, f1(a, b, c), k1, w6 = ReadBE32(chunk + 24)); + Round(d, e, a, b, c, f1(e, a, b), k1, w7 = ReadBE32(chunk + 28)); + Round(c, d, e, a, b, f1(d, e, a), k1, w8 = ReadBE32(chunk + 32)); + Round(b, c, d, e, a, f1(c, d, e), k1, w9 = ReadBE32(chunk + 36)); + Round(a, b, c, d, e, f1(b, c, d), k1, w10 = ReadBE32(chunk + 40)); + Round(e, a, b, c, d, f1(a, b, c), k1, w11 = ReadBE32(chunk + 44)); + Round(d, e, a, b, c, f1(e, a, b), k1, w12 = ReadBE32(chunk + 48)); + Round(c, d, e, a, b, f1(d, e, a), k1, w13 = ReadBE32(chunk + 52)); + Round(b, c, d, e, a, f1(c, d, e), k1, w14 = ReadBE32(chunk + 56)); + Round(a, b, c, d, e, f1(b, c, d), k1, w15 = ReadBE32(chunk + 60)); + + Round(e, a, b, c, d, f1(a, b, c), k1, w0 = left(w0 ^ w13 ^ w8 ^ w2)); + Round(d, e, a, b, c, f1(e, a, b), k1, w1 = left(w1 ^ w14 ^ w9 ^ w3)); + Round(c, d, e, a, b, f1(d, e, a), k1, w2 = left(w2 ^ w15 ^ w10 ^ w4)); + Round(b, c, d, e, a, f1(c, d, e), k1, w3 = left(w3 ^ w0 ^ w11 ^ w5)); + Round(a, b, c, d, e, f2(b, c, d), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6)); + Round(e, a, b, c, d, f2(a, b, c), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7)); + Round(d, e, a, b, c, f2(e, a, b), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8)); + Round(c, d, e, a, b, f2(d, e, a), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9)); + Round(b, c, d, e, a, f2(c, d, e), k2, w8 = left(w8 ^ w5 ^ w0 ^ w10)); + Round(a, b, c, d, e, f2(b, c, d), k2, w9 = left(w9 ^ w6 ^ w1 ^ w11)); + Round(e, a, b, c, d, f2(a, b, c), k2, w10 = left(w10 ^ w7 ^ w2 ^ w12)); + Round(d, e, a, b, c, f2(e, a, b), k2, w11 = left(w11 ^ w8 ^ w3 ^ w13)); + Round(c, d, e, a, b, f2(d, e, a), k2, w12 = left(w12 ^ w9 ^ w4 ^ w14)); + Round(b, c, d, e, a, f2(c, d, e), k2, w13 = left(w13 ^ w10 ^ w5 ^ w15)); + Round(a, b, c, d, e, f2(b, c, d), k2, w14 = left(w14 ^ w11 ^ w6 ^ w0)); + Round(e, a, b, c, d, f2(a, b, c), k2, w15 = left(w15 ^ w12 ^ w7 ^ w1)); + + Round(d, e, a, b, c, f2(e, a, b), k2, w0 = left(w0 ^ w13 ^ w8 ^ w2)); + Round(c, d, e, a, b, f2(d, e, a), k2, w1 = left(w1 ^ w14 ^ w9 ^ w3)); + Round(b, c, d, e, a, f2(c, d, e), k2, w2 = left(w2 ^ w15 ^ w10 ^ w4)); + Round(a, b, c, d, e, f2(b, c, d), k2, w3 = left(w3 ^ w0 ^ w11 ^ w5)); + Round(e, a, b, c, d, f2(a, b, c), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6)); + Round(d, e, a, b, c, f2(e, a, b), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7)); + Round(c, d, e, a, b, f2(d, e, a), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8)); + Round(b, c, d, e, a, f2(c, d, e), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9)); + Round(a, b, c, d, e, f3(b, c, d), k3, w8 = left(w8 ^ w5 ^ w0 ^ w10)); + Round(e, a, b, c, d, f3(a, b, c), k3, w9 = left(w9 ^ w6 ^ w1 ^ w11)); + Round(d, e, a, b, c, f3(e, a, b), k3, w10 = left(w10 ^ w7 ^ w2 ^ w12)); + Round(c, d, e, a, b, f3(d, e, a), k3, w11 = left(w11 ^ w8 ^ w3 ^ w13)); + Round(b, c, d, e, a, f3(c, d, e), k3, w12 = left(w12 ^ w9 ^ w4 ^ w14)); + Round(a, b, c, d, e, f3(b, c, d), k3, w13 = left(w13 ^ w10 ^ w5 ^ w15)); + Round(e, a, b, c, d, f3(a, b, c), k3, w14 = left(w14 ^ w11 ^ w6 ^ w0)); + Round(d, e, a, b, c, f3(e, a, b), k3, w15 = left(w15 ^ w12 ^ w7 ^ w1)); + + Round(c, d, e, a, b, f3(d, e, a), k3, w0 = left(w0 ^ w13 ^ w8 ^ w2)); + Round(b, c, d, e, a, f3(c, d, e), k3, w1 = left(w1 ^ w14 ^ w9 ^ w3)); + Round(a, b, c, d, e, f3(b, c, d), k3, w2 = left(w2 ^ w15 ^ w10 ^ w4)); + Round(e, a, b, c, d, f3(a, b, c), k3, w3 = left(w3 ^ w0 ^ w11 ^ w5)); + Round(d, e, a, b, c, f3(e, a, b), k3, w4 = left(w4 ^ w1 ^ w12 ^ w6)); + Round(c, d, e, a, b, f3(d, e, a), k3, w5 = left(w5 ^ w2 ^ w13 ^ w7)); + Round(b, c, d, e, a, f3(c, d, e), k3, w6 = left(w6 ^ w3 ^ w14 ^ w8)); + Round(a, b, c, d, e, f3(b, c, d), k3, w7 = left(w7 ^ w4 ^ w15 ^ w9)); + Round(e, a, b, c, d, f3(a, b, c), k3, w8 = left(w8 ^ w5 ^ w0 ^ w10)); + Round(d, e, a, b, c, f3(e, a, b), k3, w9 = left(w9 ^ w6 ^ w1 ^ w11)); + Round(c, d, e, a, b, f3(d, e, a), k3, w10 = left(w10 ^ w7 ^ w2 ^ w12)); + Round(b, c, d, e, a, f3(c, d, e), k3, w11 = left(w11 ^ w8 ^ w3 ^ w13)); + Round(a, b, c, d, e, f2(b, c, d), k4, w12 = left(w12 ^ w9 ^ w4 ^ w14)); + Round(e, a, b, c, d, f2(a, b, c), k4, w13 = left(w13 ^ w10 ^ w5 ^ w15)); + Round(d, e, a, b, c, f2(e, a, b), k4, w14 = left(w14 ^ w11 ^ w6 ^ w0)); + Round(c, d, e, a, b, f2(d, e, a), k4, w15 = left(w15 ^ w12 ^ w7 ^ w1)); + + Round(b, c, d, e, a, f2(c, d, e), k4, w0 = left(w0 ^ w13 ^ w8 ^ w2)); + Round(a, b, c, d, e, f2(b, c, d), k4, w1 = left(w1 ^ w14 ^ w9 ^ w3)); + Round(e, a, b, c, d, f2(a, b, c), k4, w2 = left(w2 ^ w15 ^ w10 ^ w4)); + Round(d, e, a, b, c, f2(e, a, b), k4, w3 = left(w3 ^ w0 ^ w11 ^ w5)); + Round(c, d, e, a, b, f2(d, e, a), k4, w4 = left(w4 ^ w1 ^ w12 ^ w6)); + Round(b, c, d, e, a, f2(c, d, e), k4, w5 = left(w5 ^ w2 ^ w13 ^ w7)); + Round(a, b, c, d, e, f2(b, c, d), k4, w6 = left(w6 ^ w3 ^ w14 ^ w8)); + Round(e, a, b, c, d, f2(a, b, c), k4, w7 = left(w7 ^ w4 ^ w15 ^ w9)); + Round(d, e, a, b, c, f2(e, a, b), k4, w8 = left(w8 ^ w5 ^ w0 ^ w10)); + Round(c, d, e, a, b, f2(d, e, a), k4, w9 = left(w9 ^ w6 ^ w1 ^ w11)); + Round(b, c, d, e, a, f2(c, d, e), k4, w10 = left(w10 ^ w7 ^ w2 ^ w12)); + Round(a, b, c, d, e, f2(b, c, d), k4, w11 = left(w11 ^ w8 ^ w3 ^ w13)); + Round(e, a, b, c, d, f2(a, b, c), k4, w12 = left(w12 ^ w9 ^ w4 ^ w14)); + Round(d, e, a, b, c, f2(e, a, b), k4, left(w13 ^ w10 ^ w5 ^ w15)); + Round(c, d, e, a, b, f2(d, e, a), k4, left(w14 ^ w11 ^ w6 ^ w0)); + Round(b, c, d, e, a, f2(c, d, e), k4, left(w15 ^ w12 ^ w7 ^ w1)); + + s[0] += a; + s[1] += b; + s[2] += c; + s[3] += d; + s[4] += e; +} + +} // namespace sha1 + +} // namespace + +////// SHA1 + +CSHA1::CSHA1() : bytes(0) +{ + sha1::Initialize(s); +} + +CSHA1& CSHA1::Write(const unsigned char* data, size_t len) +{ + const unsigned char* end = data + len; + size_t bufsize = bytes % 64; + if (bufsize && bufsize + len >= 64) { + // Fill the buffer, and process it. + memcpy(buf + bufsize, data, 64 - bufsize); + bytes += 64 - bufsize; + data += 64 - bufsize; + sha1::Transform(s, buf); + bufsize = 0; + } + while (end >= data + 64) { + // Process full chunks directly from the source. + sha1::Transform(s, data); + bytes += 64; + data += 64; + } + if (end > data) { + // Fill the buffer with what remains. + memcpy(buf + bufsize, data, end - data); + bytes += end - data; + } + return *this; +} + +void CSHA1::Finalize(unsigned char hash[OUTPUT_SIZE]) +{ + static const unsigned char pad[64] = {0x80}; + unsigned char sizedesc[8]; + WriteBE64(sizedesc, bytes << 3); + Write(pad, 1 + ((119 - (bytes % 64)) % 64)); + Write(sizedesc, 8); + WriteBE32(hash, s[0]); + WriteBE32(hash + 4, s[1]); + WriteBE32(hash + 8, s[2]); + WriteBE32(hash + 12, s[3]); + WriteBE32(hash + 16, s[4]); +} + +CSHA1& CSHA1::Reset() +{ + bytes = 0; + sha1::Initialize(s); + return *this; +} diff --git a/src/crypto/sha1.h b/src/crypto/sha1.h new file mode 100644 index 0000000..7b2a21b --- /dev/null +++ b/src/crypto/sha1.h @@ -0,0 +1,28 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_CRYPTO_SHA1_H +#define BITCOIN_CRYPTO_SHA1_H + +#include +#include + +/** A hasher class for SHA1. */ +class CSHA1 +{ +private: + uint32_t s[5]; + unsigned char buf[64]; + size_t bytes; + +public: + static const size_t OUTPUT_SIZE = 20; + + CSHA1(); + CSHA1& Write(const unsigned char* data, size_t len); + void Finalize(unsigned char hash[OUTPUT_SIZE]); + CSHA1& Reset(); +}; + +#endif // BITCOIN_CRYPTO_SHA1_H diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp new file mode 100644 index 0000000..5b9f00a --- /dev/null +++ b/src/crypto/sha256.cpp @@ -0,0 +1,189 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "crypto/sha256.h" + +#include "crypto/common.h" + +#include + +// Internal implementation code. +namespace +{ +/// Internal SHA-256 implementation. +namespace sha256 +{ +uint32_t inline Ch(uint32_t x, uint32_t y, uint32_t z) { return z ^ (x & (y ^ z)); } +uint32_t inline Maj(uint32_t x, uint32_t y, uint32_t z) { return (x & y) | (z & (x | y)); } +uint32_t inline Sigma0(uint32_t x) { return (x >> 2 | x << 30) ^ (x >> 13 | x << 19) ^ (x >> 22 | x << 10); } +uint32_t inline Sigma1(uint32_t x) { return (x >> 6 | x << 26) ^ (x >> 11 | x << 21) ^ (x >> 25 | x << 7); } +uint32_t inline sigma0(uint32_t x) { return (x >> 7 | x << 25) ^ (x >> 18 | x << 14) ^ (x >> 3); } +uint32_t inline sigma1(uint32_t x) { return (x >> 17 | x << 15) ^ (x >> 19 | x << 13) ^ (x >> 10); } + +/** One round of SHA-256. */ +void inline Round(uint32_t a, uint32_t b, uint32_t c, uint32_t& d, uint32_t e, uint32_t f, uint32_t g, uint32_t& h, uint32_t k, uint32_t w) +{ + uint32_t t1 = h + Sigma1(e) + Ch(e, f, g) + k + w; + uint32_t t2 = Sigma0(a) + Maj(a, b, c); + d += t1; + h = t1 + t2; +} + +/** Initialize SHA-256 state. */ +void inline Initialize(uint32_t* s) +{ + s[0] = 0x6a09e667ul; + s[1] = 0xbb67ae85ul; + s[2] = 0x3c6ef372ul; + s[3] = 0xa54ff53aul; + s[4] = 0x510e527ful; + s[5] = 0x9b05688cul; + s[6] = 0x1f83d9abul; + s[7] = 0x5be0cd19ul; +} + +/** Perform one SHA-256 transformation, processing a 64-byte chunk. */ +void Transform(uint32_t* s, const unsigned char* chunk) +{ + uint32_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4], f = s[5], g = s[6], h = s[7]; + uint32_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15; + + Round(a, b, c, d, e, f, g, h, 0x428a2f98, w0 = ReadBE32(chunk + 0)); + Round(h, a, b, c, d, e, f, g, 0x71374491, w1 = ReadBE32(chunk + 4)); + Round(g, h, a, b, c, d, e, f, 0xb5c0fbcf, w2 = ReadBE32(chunk + 8)); + Round(f, g, h, a, b, c, d, e, 0xe9b5dba5, w3 = ReadBE32(chunk + 12)); + Round(e, f, g, h, a, b, c, d, 0x3956c25b, w4 = ReadBE32(chunk + 16)); + Round(d, e, f, g, h, a, b, c, 0x59f111f1, w5 = ReadBE32(chunk + 20)); + Round(c, d, e, f, g, h, a, b, 0x923f82a4, w6 = ReadBE32(chunk + 24)); + Round(b, c, d, e, f, g, h, a, 0xab1c5ed5, w7 = ReadBE32(chunk + 28)); + Round(a, b, c, d, e, f, g, h, 0xd807aa98, w8 = ReadBE32(chunk + 32)); + Round(h, a, b, c, d, e, f, g, 0x12835b01, w9 = ReadBE32(chunk + 36)); + Round(g, h, a, b, c, d, e, f, 0x243185be, w10 = ReadBE32(chunk + 40)); + Round(f, g, h, a, b, c, d, e, 0x550c7dc3, w11 = ReadBE32(chunk + 44)); + Round(e, f, g, h, a, b, c, d, 0x72be5d74, w12 = ReadBE32(chunk + 48)); + Round(d, e, f, g, h, a, b, c, 0x80deb1fe, w13 = ReadBE32(chunk + 52)); + Round(c, d, e, f, g, h, a, b, 0x9bdc06a7, w14 = ReadBE32(chunk + 56)); + Round(b, c, d, e, f, g, h, a, 0xc19bf174, w15 = ReadBE32(chunk + 60)); + + Round(a, b, c, d, e, f, g, h, 0xe49b69c1, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0xefbe4786, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x0fc19dc6, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x240ca1cc, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x2de92c6f, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x4a7484aa, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x5cb0a9dc, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x76f988da, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0x983e5152, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0xa831c66d, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0xb00327c8, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0xbf597fc7, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0xc6e00bf3, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xd5a79147, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0x06ca6351, w14 += sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0x14292967, w15 += sigma1(w13) + w8 + sigma0(w0)); + + Round(a, b, c, d, e, f, g, h, 0x27b70a85, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0x2e1b2138, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x4d2c6dfc, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x53380d13, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x650a7354, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x766a0abb, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x81c2c92e, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x92722c85, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0xa2bfe8a1, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0xa81a664b, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0xc24b8b70, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0xc76c51a3, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0xd192e819, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xd6990624, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0xf40e3585, w14 += sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0x106aa070, w15 += sigma1(w13) + w8 + sigma0(w0)); + + Round(a, b, c, d, e, f, g, h, 0x19a4c116, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0x1e376c08, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x2748774c, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x34b0bcb5, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x391c0cb3, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x4ed8aa4a, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x5b9cca4f, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x682e6ff3, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0x748f82ee, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0x78a5636f, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0x84c87814, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0x8cc70208, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0x90befffa, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xa4506ceb, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0xbef9a3f7, w14 + sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0xc67178f2, w15 + sigma1(w13) + w8 + sigma0(w0)); + + s[0] += a; + s[1] += b; + s[2] += c; + s[3] += d; + s[4] += e; + s[5] += f; + s[6] += g; + s[7] += h; +} + +} // namespace sha256 +} // namespace + + +////// SHA-256 + +CSHA256::CSHA256() : bytes(0) +{ + sha256::Initialize(s); +} + +CSHA256& CSHA256::Write(const unsigned char* data, size_t len) +{ + const unsigned char* end = data + len; + size_t bufsize = bytes % 64; + if (bufsize && bufsize + len >= 64) { + // Fill the buffer, and process it. + memcpy(buf + bufsize, data, 64 - bufsize); + bytes += 64 - bufsize; + data += 64 - bufsize; + sha256::Transform(s, buf); + bufsize = 0; + } + while (end >= data + 64) { + // Process full chunks directly from the source. + sha256::Transform(s, data); + bytes += 64; + data += 64; + } + if (end > data) { + // Fill the buffer with what remains. + memcpy(buf + bufsize, data, end - data); + bytes += end - data; + } + return *this; +} + +void CSHA256::Finalize(unsigned char hash[OUTPUT_SIZE]) +{ + static const unsigned char pad[64] = {0x80}; + unsigned char sizedesc[8]; + WriteBE64(sizedesc, bytes << 3); + Write(pad, 1 + ((119 - (bytes % 64)) % 64)); + Write(sizedesc, 8); + WriteBE32(hash, s[0]); + WriteBE32(hash + 4, s[1]); + WriteBE32(hash + 8, s[2]); + WriteBE32(hash + 12, s[3]); + WriteBE32(hash + 16, s[4]); + WriteBE32(hash + 20, s[5]); + WriteBE32(hash + 24, s[6]); + WriteBE32(hash + 28, s[7]); +} + +CSHA256& CSHA256::Reset() +{ + bytes = 0; + sha256::Initialize(s); + return *this; +} diff --git a/src/crypto/sha256.h b/src/crypto/sha256.h new file mode 100644 index 0000000..85cf337 --- /dev/null +++ b/src/crypto/sha256.h @@ -0,0 +1,28 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_CRYPTO_SHA256_H +#define BITCOIN_CRYPTO_SHA256_H + +#include +#include + +/** A hasher class for SHA-256. */ +class CSHA256 +{ +private: + uint32_t s[8]; + unsigned char buf[64]; + size_t bytes; + +public: + static const size_t OUTPUT_SIZE = 32; + + CSHA256(); + CSHA256& Write(const unsigned char* data, size_t len); + void Finalize(unsigned char hash[OUTPUT_SIZE]); + CSHA256& Reset(); +}; + +#endif // BITCOIN_CRYPTO_SHA256_H diff --git a/src/crypto/sha512.cpp b/src/crypto/sha512.cpp new file mode 100644 index 0000000..564127c --- /dev/null +++ b/src/crypto/sha512.cpp @@ -0,0 +1,207 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "crypto/sha512.h" + +#include "crypto/common.h" + +#include + +// Internal implementation code. +namespace +{ +/// Internal SHA-512 implementation. +namespace sha512 +{ +uint64_t inline Ch(uint64_t x, uint64_t y, uint64_t z) { return z ^ (x & (y ^ z)); } +uint64_t inline Maj(uint64_t x, uint64_t y, uint64_t z) { return (x & y) | (z & (x | y)); } +uint64_t inline Sigma0(uint64_t x) { return (x >> 28 | x << 36) ^ (x >> 34 | x << 30) ^ (x >> 39 | x << 25); } +uint64_t inline Sigma1(uint64_t x) { return (x >> 14 | x << 50) ^ (x >> 18 | x << 46) ^ (x >> 41 | x << 23); } +uint64_t inline sigma0(uint64_t x) { return (x >> 1 | x << 63) ^ (x >> 8 | x << 56) ^ (x >> 7); } +uint64_t inline sigma1(uint64_t x) { return (x >> 19 | x << 45) ^ (x >> 61 | x << 3) ^ (x >> 6); } + +/** One round of SHA-512. */ +void inline Round(uint64_t a, uint64_t b, uint64_t c, uint64_t& d, uint64_t e, uint64_t f, uint64_t g, uint64_t& h, uint64_t k, uint64_t w) +{ + uint64_t t1 = h + Sigma1(e) + Ch(e, f, g) + k + w; + uint64_t t2 = Sigma0(a) + Maj(a, b, c); + d += t1; + h = t1 + t2; +} + +/** Initialize SHA-256 state. */ +void inline Initialize(uint64_t* s) +{ + s[0] = 0x6a09e667f3bcc908ull; + s[1] = 0xbb67ae8584caa73bull; + s[2] = 0x3c6ef372fe94f82bull; + s[3] = 0xa54ff53a5f1d36f1ull; + s[4] = 0x510e527fade682d1ull; + s[5] = 0x9b05688c2b3e6c1full; + s[6] = 0x1f83d9abfb41bd6bull; + s[7] = 0x5be0cd19137e2179ull; +} + +/** Perform one SHA-512 transformation, processing a 128-byte chunk. */ +void Transform(uint64_t* s, const unsigned char* chunk) +{ + uint64_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4], f = s[5], g = s[6], h = s[7]; + uint64_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15; + + Round(a, b, c, d, e, f, g, h, 0x428a2f98d728ae22ull, w0 = ReadBE64(chunk + 0)); + Round(h, a, b, c, d, e, f, g, 0x7137449123ef65cdull, w1 = ReadBE64(chunk + 8)); + Round(g, h, a, b, c, d, e, f, 0xb5c0fbcfec4d3b2full, w2 = ReadBE64(chunk + 16)); + Round(f, g, h, a, b, c, d, e, 0xe9b5dba58189dbbcull, w3 = ReadBE64(chunk + 24)); + Round(e, f, g, h, a, b, c, d, 0x3956c25bf348b538ull, w4 = ReadBE64(chunk + 32)); + Round(d, e, f, g, h, a, b, c, 0x59f111f1b605d019ull, w5 = ReadBE64(chunk + 40)); + Round(c, d, e, f, g, h, a, b, 0x923f82a4af194f9bull, w6 = ReadBE64(chunk + 48)); + Round(b, c, d, e, f, g, h, a, 0xab1c5ed5da6d8118ull, w7 = ReadBE64(chunk + 56)); + Round(a, b, c, d, e, f, g, h, 0xd807aa98a3030242ull, w8 = ReadBE64(chunk + 64)); + Round(h, a, b, c, d, e, f, g, 0x12835b0145706fbeull, w9 = ReadBE64(chunk + 72)); + Round(g, h, a, b, c, d, e, f, 0x243185be4ee4b28cull, w10 = ReadBE64(chunk + 80)); + Round(f, g, h, a, b, c, d, e, 0x550c7dc3d5ffb4e2ull, w11 = ReadBE64(chunk + 88)); + Round(e, f, g, h, a, b, c, d, 0x72be5d74f27b896full, w12 = ReadBE64(chunk + 96)); + Round(d, e, f, g, h, a, b, c, 0x80deb1fe3b1696b1ull, w13 = ReadBE64(chunk + 104)); + Round(c, d, e, f, g, h, a, b, 0x9bdc06a725c71235ull, w14 = ReadBE64(chunk + 112)); + Round(b, c, d, e, f, g, h, a, 0xc19bf174cf692694ull, w15 = ReadBE64(chunk + 120)); + + Round(a, b, c, d, e, f, g, h, 0xe49b69c19ef14ad2ull, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0xefbe4786384f25e3ull, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x0fc19dc68b8cd5b5ull, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x240ca1cc77ac9c65ull, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x2de92c6f592b0275ull, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x4a7484aa6ea6e483ull, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x5cb0a9dcbd41fbd4ull, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x76f988da831153b5ull, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0x983e5152ee66dfabull, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0xa831c66d2db43210ull, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0xb00327c898fb213full, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0xbf597fc7beef0ee4ull, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0xc6e00bf33da88fc2ull, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xd5a79147930aa725ull, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0x06ca6351e003826full, w14 += sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0x142929670a0e6e70ull, w15 += sigma1(w13) + w8 + sigma0(w0)); + + Round(a, b, c, d, e, f, g, h, 0x27b70a8546d22ffcull, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0x2e1b21385c26c926ull, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x4d2c6dfc5ac42aedull, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x53380d139d95b3dfull, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x650a73548baf63deull, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x766a0abb3c77b2a8ull, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x81c2c92e47edaee6ull, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x92722c851482353bull, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0xa2bfe8a14cf10364ull, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0xa81a664bbc423001ull, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0xc24b8b70d0f89791ull, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0xc76c51a30654be30ull, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0xd192e819d6ef5218ull, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xd69906245565a910ull, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0xf40e35855771202aull, w14 += sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0x106aa07032bbd1b8ull, w15 += sigma1(w13) + w8 + sigma0(w0)); + + Round(a, b, c, d, e, f, g, h, 0x19a4c116b8d2d0c8ull, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0x1e376c085141ab53ull, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x2748774cdf8eeb99ull, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x34b0bcb5e19b48a8ull, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x391c0cb3c5c95a63ull, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x4ed8aa4ae3418acbull, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x5b9cca4f7763e373ull, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x682e6ff3d6b2b8a3ull, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0x748f82ee5defb2fcull, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0x78a5636f43172f60ull, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0x84c87814a1f0ab72ull, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0x8cc702081a6439ecull, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0x90befffa23631e28ull, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xa4506cebde82bde9ull, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0xbef9a3f7b2c67915ull, w14 += sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0xc67178f2e372532bull, w15 += sigma1(w13) + w8 + sigma0(w0)); + + Round(a, b, c, d, e, f, g, h, 0xca273eceea26619cull, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0xd186b8c721c0c207ull, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0xeada7dd6cde0eb1eull, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0xf57d4f7fee6ed178ull, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x06f067aa72176fbaull, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x0a637dc5a2c898a6ull, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x113f9804bef90daeull, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x1b710b35131c471bull, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0x28db77f523047d84ull, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0x32caab7b40c72493ull, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0x3c9ebe0a15c9bebcull, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0x431d67c49c100d4cull, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0x4cc5d4becb3e42b6ull, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0x597f299cfc657e2aull, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0x5fcb6fab3ad6faecull, w14 + sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0x6c44198c4a475817ull, w15 + sigma1(w13) + w8 + sigma0(w0)); + + s[0] += a; + s[1] += b; + s[2] += c; + s[3] += d; + s[4] += e; + s[5] += f; + s[6] += g; + s[7] += h; +} + +} // namespace sha512 + +} // namespace + + +////// SHA-512 + +CSHA512::CSHA512() : bytes(0) +{ + sha512::Initialize(s); +} + +CSHA512& CSHA512::Write(const unsigned char* data, size_t len) +{ + const unsigned char* end = data + len; + size_t bufsize = bytes % 128; + if (bufsize && bufsize + len >= 128) { + // Fill the buffer, and process it. + memcpy(buf + bufsize, data, 128 - bufsize); + bytes += 128 - bufsize; + data += 128 - bufsize; + sha512::Transform(s, buf); + bufsize = 0; + } + while (end >= data + 128) { + // Process full chunks directly from the source. + sha512::Transform(s, data); + data += 128; + bytes += 128; + } + if (end > data) { + // Fill the buffer with what remains. + memcpy(buf + bufsize, data, end - data); + bytes += end - data; + } + return *this; +} + +void CSHA512::Finalize(unsigned char hash[OUTPUT_SIZE]) +{ + static const unsigned char pad[128] = {0x80}; + unsigned char sizedesc[16] = {0x00}; + WriteBE64(sizedesc + 8, bytes << 3); + Write(pad, 1 + ((239 - (bytes % 128)) % 128)); + Write(sizedesc, 16); + WriteBE64(hash, s[0]); + WriteBE64(hash + 8, s[1]); + WriteBE64(hash + 16, s[2]); + WriteBE64(hash + 24, s[3]); + WriteBE64(hash + 32, s[4]); + WriteBE64(hash + 40, s[5]); + WriteBE64(hash + 48, s[6]); + WriteBE64(hash + 56, s[7]); +} + +CSHA512& CSHA512::Reset() +{ + bytes = 0; + sha512::Initialize(s); + return *this; +} diff --git a/src/crypto/sha512.h b/src/crypto/sha512.h new file mode 100644 index 0000000..f1f17ca --- /dev/null +++ b/src/crypto/sha512.h @@ -0,0 +1,28 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_CRYPTO_SHA512_H +#define BITCOIN_CRYPTO_SHA512_H + +#include +#include + +/** A hasher class for SHA-512. */ +class CSHA512 +{ +private: + uint64_t s[8]; + unsigned char buf[128]; + size_t bytes; + +public: + static const size_t OUTPUT_SIZE = 64; + + CSHA512(); + CSHA512& Write(const unsigned char* data, size_t len); + void Finalize(unsigned char hash[OUTPUT_SIZE]); + CSHA512& Reset(); +}; + +#endif // BITCOIN_CRYPTO_SHA512_H diff --git a/src/darksend.cpp b/src/darksend.cpp new file mode 100644 index 0000000..2985744 --- /dev/null +++ b/src/darksend.cpp @@ -0,0 +1,2225 @@ +// Copyright (c) 2014-2015 The Darkcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + + +#include "darksend.h" +#include "main.h" +#include "init.h" +//#include "script/sign.h" +#include "util.h" +#include "masternode.h" +#include "instantx.h" +#include "ui_interface.h" +//#include "random.h" + +#include + +#include +#include +#include +#include + +#include +#include + +using namespace std; +using namespace boost; + +CCriticalSection cs_darksend; + +/** The main object for accessing darksend */ +CDarkSendPool darkSendPool; +/** A helper object for signing messages from masternodes */ +CDarkSendSigner darkSendSigner; +/** The current darksends in progress on the network */ +std::vector vecluxsendQueue; +/** Keep track of the used masternodes */ +std::vector vecMasternodesUsed; +// keep track of the scanning errors I've seen +map mapluxsendBroadcastTxes; +// +CActiveMasternode activeMasternode; + +// count peers we've requested the list from +int RequestedMasterNodeList = 0; + +/* *** BEGIN DARKSEND MAGIC ********** + Copyright 2014, Darkcoin Developers + eduffield - evan@darkcoin.io +*/ + +void ProcessMessageluxsend(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) +{ + if(fLiteMode) return; //disable all darksend/masternode related functionality + + if (strCommand == "dsf") { //DarkSend Final tx + if (pfrom->nVersion < darkSendPool.MIN_PEER_PROTO_VERSION) { + return; + } + + if((CNetAddr)darkSendPool.submittedToMasternode != (CNetAddr)pfrom->addr){ + //LogPrintf("dsc - message doesn't match current masternode - %s != %s\n", darkSendPool.submittedToMasternode.ToString().c_str(), pfrom->addr.ToString().c_str()); + return; + } + + int sessionID; + CTransaction txNew; + vRecv >> sessionID >> txNew; + + if(darkSendPool.sessionID != sessionID){ + if (fDebug) LogPrintf("dsf - message doesn't match current darksend session %d %d\n", darkSendPool.sessionID, sessionID); + return; + } + + //check to see if input is spent already? (and probably not confirmed) + darkSendPool.SignFinalTransaction(txNew, pfrom); + } + + else if (strCommand == "dsc") { //DarkSend Complete + if (pfrom->nVersion < darkSendPool.MIN_PEER_PROTO_VERSION) { + return; + } + + if((CNetAddr)darkSendPool.submittedToMasternode != (CNetAddr)pfrom->addr){ + //LogPrintf("dsc - message doesn't match current masternode - %s != %s\n", darkSendPool.submittedToMasternode.ToString().c_str(), pfrom->addr.ToString().c_str()); + return; + } + + int sessionID; + bool error; + std::string lastMessage; + vRecv >> sessionID >> error >> lastMessage; + + if(darkSendPool.sessionID != sessionID){ + if (fDebug) LogPrintf("dsc - message doesn't match current darksend session %d %d\n", darkSendPool.sessionID, sessionID); + return; + } + + darkSendPool.CompletedTransaction(error, lastMessage); + } + + else if (strCommand == "dsa") { //DarkSend Acceptable + + if (pfrom->nVersion < darkSendPool.MIN_PEER_PROTO_VERSION) { + std::string strError = _("Incompatible version."); + LogPrintf("dsa -- incompatible version! \n"); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, strError); + + return; + } + + if(!fMasterNode){ + std::string strError = _("This is not a masternode."); + LogPrintf("dsa -- not a masternode! \n"); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, strError); + + return; + } + + int nDenom; + CTransaction txCollateral; + vRecv >> nDenom >> txCollateral; + + std::string error = ""; + int mn = GetMasternodeByVin(activeMasternode.vin); + if(mn == -1){ + std::string strError = _("Not in the masternode list."); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, strError); + return; + } + + if(darkSendPool.sessionUsers == 0) { + if(vecMasternodes[mn].nLastDsq != 0 && + vecMasternodes[mn].nLastDsq + CountMasternodesAboveProtocol(darkSendPool.MIN_PEER_PROTO_VERSION)/5 > darkSendPool.nDsqCount){ + //LogPrintf("dsa -- last dsq too recent, must wait. %s \n", vecMasternodes[mn].addr.ToString().c_str()); + std::string strError = _("Last darksend was too recent."); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, strError); + return; + } + } + + if(!darkSendPool.IsCompatibleWithSession(nDenom, txCollateral, error)) + { + LogPrintf("dsa -- not compatible with existing transactions! \n"); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + return; + } else { + LogPrintf("dsa -- is compatible, please submit! \n"); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_ACCEPTED, error); + return; + } + } else if (strCommand == "dsq") { //DarkSend Queue + + if (pfrom->nVersion < darkSendPool.MIN_PEER_PROTO_VERSION) { + return; + } + + CluxsendQueue dsq; + vRecv >> dsq; + + + CService addr; + if(!dsq.GetAddress(addr)) return; + if(!dsq.CheckSignature()) return; + + if(dsq.IsExpired()) return; + + int mn = GetMasternodeByVin(dsq.vin); + if(mn == -1) return; + + // if the queue is ready, submit if we can + if(dsq.ready) { + if((CNetAddr)darkSendPool.submittedToMasternode != (CNetAddr)addr){ + LogPrintf("dsq - message doesn't match current masternode - %s != %s\n", darkSendPool.submittedToMasternode.ToString().c_str(), pfrom->addr.ToString().c_str()); + return; + } + + if (fDebug) LogPrintf("darksend queue is ready - %s\n", addr.ToString().c_str()); + darkSendPool.PrepareluxsendDenominate(); + } else { + BOOST_FOREACH(CluxsendQueue q, vecluxsendQueue){ + if(q.vin == dsq.vin) return; + } + + if(fDebug) LogPrintf("dsq last %d last2 %d count %d\n", vecMasternodes[mn].nLastDsq, vecMasternodes[mn].nLastDsq + (int)vecMasternodes.size()/5, darkSendPool.nDsqCount); + //don't allow a few nodes to dominate the queuing process + if(vecMasternodes[mn].nLastDsq != 0 && + vecMasternodes[mn].nLastDsq + CountMasternodesAboveProtocol(darkSendPool.MIN_PEER_PROTO_VERSION)/5 > darkSendPool.nDsqCount){ + if(fDebug) LogPrintf("dsq -- masternode sending too many dsq messages. %s \n", vecMasternodes[mn].addr.ToString().c_str()); + return; + } + darkSendPool.nDsqCount++; + vecMasternodes[mn].nLastDsq = darkSendPool.nDsqCount; + vecMasternodes[mn].allowFreeTx = true; + + if(fDebug) LogPrintf("dsq - new darksend queue object - %s\n", addr.ToString().c_str()); + vecluxsendQueue.push_back(dsq); + dsq.Relay(); + dsq.time = GetTime(); + } + + } else if (strCommand == "dsi") { //DarkSend vIn + std::string error = ""; + if (pfrom->nVersion < darkSendPool.MIN_PEER_PROTO_VERSION) { + LogPrintf("dsi -- incompatible version! \n"); + error = _("Incompatible version."); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + + return; + } + + if(!fMasterNode){ + LogPrintf("dsi -- not a masternode! \n"); + error = _("This is not a masternode."); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + + return; + } + + std::vector in; + int64_t nAmount; + CTransaction txCollateral; + std::vector out; + vRecv >> in >> nAmount >> txCollateral >> out; + + //do we have enough users in the current session? + if(!darkSendPool.IsSessionReady()){ + LogPrintf("dsi -- session not complete! \n"); + error = _("Session not complete!"); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + return; + } + + //do we have the same denominations as the current session? + if(!darkSendPool.IsCompatibleWithEntries(out)) + { + LogPrintf("dsi -- not compatible with existing transactions! \n"); + error = _("Not compatible with existing transactions."); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + return; + } + + //check it like a transaction + { + int64_t nValueIn = 0; + int64_t nValueOut = 0; + bool missingTx = false; + + CValidationState state; + CTransaction tx; + + BOOST_FOREACH(CTxOut o, out){ + nValueOut += o.nValue; + tx.vout.push_back(o); + + if(o.scriptPubKey.size() != 25){ + LogPrintf("dsi - non-standard pubkey detected! %s\n", o.scriptPubKey.ToString().c_str()); + error = _("Non-standard public key detected."); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + return; + } + if(!o.scriptPubKey.IsNormalPaymentScript()){ + LogPrintf("dsi - invalid script! %s\n", o.scriptPubKey.ToString().c_str()); + error = _("Invalid script detected."); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + return; + } + } + + BOOST_FOREACH(const CTxIn i, in){ + tx.vin.push_back(i); + + if(fDebug) LogPrintf("dsi -- tx in %s\n", i.ToString().c_str()); + + CTransaction tx2; + uint256 hash; + //if(GetTransaction(i.prevout.hash, tx2, hash, true)){ + if(GetTransaction(i.prevout.hash, tx2, hash)){ + if(tx2.vout.size() > i.prevout.n) { + nValueIn += tx2.vout[i.prevout.n].nValue; + } + } else{ + missingTx = true; + } + } + + if (nValueIn > DARKSEND_POOL_MAX) { + LogPrintf("dsi -- more than darksend pool max! %s\n", tx.ToString().c_str()); + error = _("Value more than darksend pool maximum allows."); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + return; + } + + if(!missingTx){ + if (nValueIn-nValueOut > nValueIn*.01) { + LogPrintf("dsi -- fees are too high! %s\n", tx.ToString().c_str()); + error = _("Transaction fees are too high."); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + return; + } + } else { + LogPrintf("dsi -- missing input tx! %s\n", tx.ToString().c_str()); + error = _("Missing input transaction information."); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + return; + } + + //if(!AcceptableInputs(mempool, state, tx)){ + bool* pfMissingInputs; + if(!AcceptableInputs(mempool, tx, false, pfMissingInputs)){ + LogPrintf("dsi -- transaction not valid! \n"); + error = _("Transaction not valid."); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + return; + } + } + + if(darkSendPool.AddEntry(in, nAmount, txCollateral, out, error)){ + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_ACCEPTED, error); + darkSendPool.Check(); + + RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); + } else { + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); + } + } + + else if (strCommand == "dssub") { //DarkSend Subscribe To + if (pfrom->nVersion < darkSendPool.MIN_PEER_PROTO_VERSION) { + return; + } + + if(!fMasterNode) return; + + std::string error = ""; + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET, error); + return; + } + + else if (strCommand == "dssu") { //DarkSend status update + + if (pfrom->nVersion < darkSendPool.MIN_PEER_PROTO_VERSION) { + return; + } + + if((CNetAddr)darkSendPool.submittedToMasternode != (CNetAddr)pfrom->addr){ + //LogPrintf("dssu - message doesn't match current masternode - %s != %s\n", darkSendPool.submittedToMasternode.ToString().c_str(), pfrom->addr.ToString().c_str()); + return; + } + + int sessionID; + int state; + int entriesCount; + int accepted; + std::string error; + vRecv >> sessionID >> state >> entriesCount >> accepted >> error; + + if(fDebug) LogPrintf("dssu - state: %i entriesCount: %i accepted: %i error: %s \n", state, entriesCount, accepted, error.c_str()); + + if((accepted != 1 && accepted != 0) && darkSendPool.sessionID != sessionID){ + LogPrintf("dssu - message doesn't match current darksend session %d %d\n", darkSendPool.sessionID, sessionID); + return; + } + + darkSendPool.StatusUpdate(state, entriesCount, accepted, error, sessionID); + + } + + else if (strCommand == "dss") { //DarkSend Sign Final Tx + if (pfrom->nVersion < darkSendPool.MIN_PEER_PROTO_VERSION) { + return; + } + + vector sigs; + vRecv >> sigs; + + bool success = false; + int count = 0; + + LogPrintf(" -- sigs count %d %d\n", (int)sigs.size(), count); + + BOOST_FOREACH(const CTxIn item, sigs) + { + if(darkSendPool.AddScriptSig(item)) success = true; + if(fDebug) LogPrintf(" -- sigs count %d %d\n", (int)sigs.size(), count); + count++; + } + + if(success){ + darkSendPool.Check(); + RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); + } + } + +} + +int randomizeList (int i) { return std::rand()%i;} + +// Recursively determine the rounds of a given input (How deep is the darksend chain for a given input) +int GetInputluxsendRounds(CTxIn in, int rounds) +{ + if(rounds >= 17) return rounds; + + std::string padding = ""; + padding.insert(0, ((rounds+1)*5)+3, ' '); + + CWalletTx tx; + if(pwalletMain->GetTransaction(in.prevout.hash,tx)) + { + // bounds check + if(in.prevout.n >= tx.vout.size()) return -4; + + if(tx.vout[in.prevout.n].nValue == DARKSEND_FEE) return -3; + + //make sure the final output is non-denominate + if(rounds == 0 && !pwalletMain->IsDenominatedAmount(tx.vout[in.prevout.n].nValue)) return -2; //NOT DENOM + + bool found = false; + BOOST_FOREACH(CTxOut out, tx.vout) + { + found = pwalletMain->IsDenominatedAmount(out.nValue); + if(found) break; // no need to loop more + } + if(!found) return rounds - 1; //NOT FOUND, "-1" because of the pre-mixing creation of denominated amounts + + // find my vin and look that up + BOOST_FOREACH(CTxIn in2, tx.vin) + { + if(pwalletMain->IsMine(in2)) + { + //LogPrintf("rounds :: %s %s %d NEXT\n", padding.c_str(), in.ToString().c_str(), rounds); + int n = GetInputluxsendRounds(in2, rounds+1); + if(n != -3) return n; + } + } + } + + return rounds-1; +} + +void CDarkSendPool::Reset(){ + cachedLastSuccess = 0; + vecMasternodesUsed.clear(); + UnlockCoins(); + SetNull(); +} + +void CDarkSendPool::SetNull(bool clearEverything){ + finalTransaction.vin.clear(); + finalTransaction.vout.clear(); + + entries.clear(); + + state = POOL_STATUS_ACCEPTING_ENTRIES; + + lastTimeChanged = GetTimeMillis(); + + entriesCount = 0; + lastEntryAccepted = 0; + countEntriesAccepted = 0; + lastNewBlock = 0; + + sessionUsers = 0; + sessionDenom = 0; + sessionFoundMasternode = false; + vecSessionCollateral.clear(); + txCollateral = CTransaction(); + + if(clearEverything){ + myEntries.clear(); + + if(fMasterNode){ + sessionID = 1 + (rand() % 999999); + } else { + sessionID = 0; + } + } + + // -- seed random number generator (used for ordering output lists) + unsigned int seed = 0; + GetRandBytes((unsigned char*)&seed, sizeof(seed)); + std::srand(seed); +} + +bool CDarkSendPool::SetCollateralAddress(std::string strAddress){ + CBitcoinAddress address; + if (!address.SetString(strAddress)) + { + LogPrintf("CDarkSendPool::SetCollateralAddress - Invalid DarkSend collateral address\n"); + return false; + } + collateralPubKey= GetScriptForDestination(address.Get()); + return true; +} + +// +// Unlock coins after darksend fails or succeeds +// +void CDarkSendPool::UnlockCoins(){ + BOOST_FOREACH(CTxIn v, lockedCoins) + pwalletMain->UnlockCoin(v.prevout); + + lockedCoins.clear(); +} + +// +// Check the darksend progress and send client updates if a masternode +// +void CDarkSendPool::Check() +{ + if(fDebug) LogPrintf("CDarkSendPool::Check()\n"); + if(fDebug) LogPrintf("CDarkSendPool::Check() - entries count %lu\n", entries.size()); + + // If entries is full, then move on to the next phase + if(state == POOL_STATUS_ACCEPTING_ENTRIES && (int)entries.size() >= GetMaxPoolTransactions()) + { + if(fDebug) LogPrintf("CDarkSendPool::Check() -- ACCEPTING OUTPUTS\n"); + UpdateState(POOL_STATUS_FINALIZE_TRANSACTION); + } + + // create the finalized transaction for distribution to the clients + if(state == POOL_STATUS_FINALIZE_TRANSACTION && finalTransaction.vin.empty() && finalTransaction.vout.empty()) { + if(fDebug) LogPrintf("CDarkSendPool::Check() -- FINALIZE TRANSACTIONS\n"); + UpdateState(POOL_STATUS_SIGNING); + + if (fMasterNode) { + // make our new transaction + CTransaction txNew; + for(unsigned int i = 0; i < entries.size(); i++){ + BOOST_FOREACH(const CTxOut v, entries[i].vout) + txNew.vout.push_back(v); + + BOOST_FOREACH(const CDarkSendEntryVin s, entries[i].sev) + txNew.vin.push_back(s.vin); + } + // shuffle the outputs for improved anonymity + std::random_shuffle ( txNew.vout.begin(), txNew.vout.end(), randomizeList); + + if(fDebug) LogPrintf("Transaction 1: %s\n", txNew.ToString().c_str()); + + SignFinalTransaction(txNew, NULL); + + // request signatures from clients + RelayDarkSendFinalTransaction(sessionID, txNew); + } + } + + // collect signatures from clients + + // If we have all of the signatures, try to compile the transaction + if(state == POOL_STATUS_SIGNING && SignaturesComplete()) { + if(fDebug) LogPrintf("CDarkSendPool::Check() -- SIGNING\n"); + UpdateState(POOL_STATUS_TRANSMISSION); + + CWalletTx txNew = CWalletTx(pwalletMain, finalTransaction); + + LOCK2(cs_main, pwalletMain->cs_wallet); + { + if (fMasterNode) { //only the main node is master atm + if(fDebug) LogPrintf("Transaction 2: %s\n", txNew.ToString().c_str()); + + // See if the transaction is valid + if (!txNew.AcceptToMemoryPool(true)) + { + LogPrintf("CDarkSendPool::Check() - CommitTransaction : Error: Transaction not valid\n"); + SetNull(); + pwalletMain->Lock(); + + // not much we can do in this case + UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); + RelayDarkSendCompletedTransaction(sessionID, true, "Transaction not valid, please try again"); + return; + } + + LogPrintf("CDarkSendPool::Check() -- IS MASTER -- TRANSMITTING DARKSEND\n"); + + // sign a message + + int64_t sigTime = GetAdjustedTime(); + std::string strMessage = txNew.GetHash().ToString() + boost::lexical_cast(sigTime); + std::string strError = ""; + std::vector vchSig; + CKey key2; + CPubKey pubkey2; + + if(!darkSendSigner.SetKey(strMasterNodePrivKey, strError, key2, pubkey2)) + { + LogPrintf("CDarkSendPool::Check() - ERROR: Invalid masternodeprivkey: '%s'\n", strError.c_str()); + return; + } + + if(!darkSendSigner.SignMessage(strMessage, strError, vchSig, key2)) { + LogPrintf("CDarkSendPool::Check() - Sign message failed\n"); + return; + } + + if(!darkSendSigner.VerifyMessage(pubkey2, vchSig, strMessage, strError)) { + LogPrintf("CDarkSendPool::Check() - Verify message failed\n"); + return; + } + + if(!mapluxsendBroadcastTxes.count(txNew.GetHash())){ + CluxsendBroadcastTx dstx; + dstx.tx = txNew; + dstx.vin = activeMasternode.vin; + dstx.vchSig = vchSig; + dstx.sigTime = sigTime; + + mapluxsendBroadcastTxes.insert(make_pair(txNew.GetHash(), dstx)); + } + + // Broadcast the transaction to the network + txNew.fTimeReceivedIsTxTime = true; + txNew.RelayWalletTransaction(); + + // Tell the clients it was successful + RelayDarkSendCompletedTransaction(sessionID, false, _("Transaction created successfully.")); + + // Randomly charge clients + ChargeRandomFees(); + } + } + } + + // move on to next phase, allow 3 seconds incase the masternode wants to send us anything else + if((state == POOL_STATUS_TRANSMISSION && fMasterNode) || (state == POOL_STATUS_SIGNING && completedTransaction) ) { + if(fDebug) LogPrintf("CDarkSendPool::Check() -- COMPLETED -- RESETTING \n"); + SetNull(true); + UnlockCoins(); + if(fMasterNode) RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); + pwalletMain->Lock(); + } + + // reset if we're here for 10 seconds + if((state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) && GetTimeMillis()-lastTimeChanged >= 10000) { + if(fDebug) LogPrintf("CDarkSendPool::Check() -- RESETTING MESSAGE \n"); + SetNull(true); + if(fMasterNode) RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); + UnlockCoins(); + } +} + +// +// Charge clients a fee if they're abusive +// +// Why bother? darksend uses collateral to ensure abuse to the process is kept to a minimum. +// The submission and signing stages in darksend are completely separate. In the cases where +// a client submits a transaction then refused to sign, there must be a cost. Otherwise they +// would be able to do this over and over again and bring the mixing to a hault. +// +// How does this work? Messages to masternodes come in via "dsi", these require a valid collateral +// transaction for the client to be able to enter the pool. This transaction is kept by the masternode +// until the transaction is either complete or fails. +// +void CDarkSendPool::ChargeFees(){ + if(fMasterNode) { + //we don't need to charge collateral for every offence. + int offences = 0; + int r = rand()%100; + if(r > 33) return; + + if(state == POOL_STATUS_ACCEPTING_ENTRIES){ + BOOST_FOREACH(const CTransaction& txCollateral, vecSessionCollateral) { + bool found = false; + BOOST_FOREACH(const CDarkSendEntry& v, entries) { + if(v.collateral == txCollateral) { + found = true; + } + } + + // This queue entry didn't send us the promised transaction + if(!found){ + LogPrintf("CDarkSendPool::ChargeFees -- found uncooperative node (didn't send transaction). Found offence.\n"); + offences++; + } + } + } + + if(state == POOL_STATUS_SIGNING) { + // who didn't sign? + BOOST_FOREACH(const CDarkSendEntry v, entries) { + BOOST_FOREACH(const CDarkSendEntryVin s, v.sev) { + if(!s.isSigSet){ + LogPrintf("CDarkSendPool::ChargeFees -- found uncooperative node (didn't sign). Found offence\n"); + offences++; + } + } + } + } + + r = rand()%100; + int target = 0; + + //mostly offending? + if(offences >= POOL_MAX_TRANSACTIONS-1 && r > 33) return; + + //everyone is an offender? That's not right + if(offences >= POOL_MAX_TRANSACTIONS) return; + + //charge one of the offenders randomly + if(offences > 1) target = 50; + + //pick random client to charge + r = rand()%100; + + if(state == POOL_STATUS_ACCEPTING_ENTRIES){ + BOOST_FOREACH(const CTransaction& txCollateral, vecSessionCollateral) { + bool found = false; + BOOST_FOREACH(const CDarkSendEntry& v, entries) { + if(v.collateral == txCollateral) { + found = true; + } + } + + // This queue entry didn't send us the promised transaction + if(!found && r > target){ + LogPrintf("CDarkSendPool::ChargeFees -- found uncooperative node (didn't send transaction). charging fees.\n"); + + CWalletTx wtxCollateral = CWalletTx(pwalletMain, txCollateral); + + // Broadcast + if (!wtxCollateral.AcceptToMemoryPool(true)) + { + // This must not fail. The transaction has already been signed and recorded. + LogPrintf("CDarkSendPool::ChargeFees() : Error: Transaction not valid"); + } + wtxCollateral.RelayWalletTransaction(); + return; + } + } + } + + if(state == POOL_STATUS_SIGNING) { + // who didn't sign? + BOOST_FOREACH(const CDarkSendEntry v, entries) { + BOOST_FOREACH(const CDarkSendEntryVin s, v.sev) { + if(!s.isSigSet && r > target){ + LogPrintf("CDarkSendPool::ChargeFees -- found uncooperative node (didn't sign). charging fees.\n"); + + CWalletTx wtxCollateral = CWalletTx(pwalletMain, v.collateral); + + // Broadcast + if (!wtxCollateral.AcceptToMemoryPool(true)) + { + // This must not fail. The transaction has already been signed and recorded. + LogPrintf("CDarkSendPool::ChargeFees() : Error: Transaction not valid"); + } + wtxCollateral.RelayWalletTransaction(); + return; + } + } + } + } + } +} + +// charge the collateral randomly +// - darksend is completely free, to pay miners we randomly pay the collateral of users. +void CDarkSendPool::ChargeRandomFees(){ + if(fMasterNode) { + int i = 0; + + BOOST_FOREACH(const CTransaction& txCollateral, vecSessionCollateral) { + int r = rand()%1000; + + /* + Collateral Fee Charges: + + Being that DarkSend has "no fees" we need to have some kind of cost associated + with using it to stop abuse. Otherwise it could serve as an attack vector and + allow endless transaction that would bloat SONO and make it unusable. To + stop these kinds of attacks 1 in 50 successful transactions are charged. This + adds up to a cost of 0.002SONO per transaction on average. + */ + if(r <= 20) + { + LogPrintf("CDarkSendPool::ChargeRandomFees -- charging random fees. %u\n", i); + + CWalletTx wtxCollateral = CWalletTx(pwalletMain, txCollateral); + + // Broadcast + if (!wtxCollateral.AcceptToMemoryPool(true)) + { + // This must not fail. The transaction has already been signed and recorded. + LogPrintf("CDarkSendPool::ChargeRandomFees() : Error: Transaction not valid"); + } + wtxCollateral.RelayWalletTransaction(); + } + } + } +} + +// +// Check for various timeouts (queue objects, darksend, etc) +// +void CDarkSendPool::CheckTimeout(){ + if(!fEnableluxsend && !fMasterNode) return; + + // catching hanging sessions + if(!fMasterNode) { + if(state == POOL_STATUS_TRANSMISSION) { + if(fDebug) LogPrintf("CDarkSendPool::CheckTimeout() -- Session complete -- Running Check()\n"); + Check(); + } + } + + // check darksend queue objects for timeouts + int c = 0; + vector::iterator it; + for(it=vecluxsendQueue.begin();it *vec = &myEntries; + if(fMasterNode) vec = &entries; + + // check for a timeout and reset if needed + vector::iterator it2; + for(it2=vec->begin();it2end();it2++){ + if((*it2).IsExpired()){ + if(fDebug) LogPrintf("CDarkSendPool::CheckTimeout() : Removing expired entry - %d\n", c); + vec->erase(it2); + if(entries.size() == 0 && myEntries.size() == 0){ + SetNull(true); + UnlockCoins(); + } + if(fMasterNode){ + RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); + } + break; + } + c++; + } + + if(GetTimeMillis()-lastTimeChanged >= (DARKSEND_QUEUE_TIMEOUT*1000)+addLagTime){ + lastTimeChanged = GetTimeMillis(); + + ChargeFees(); + // reset session information for the queue query stage (before entering a masternode, clients will send a queue request to make sure they're compatible denomination wise) + sessionUsers = 0; + sessionDenom = 0; + sessionFoundMasternode = false; + vecSessionCollateral.clear(); + + UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); + } + } else if(GetTimeMillis()-lastTimeChanged >= (DARKSEND_QUEUE_TIMEOUT*1000)+addLagTime){ + if(fDebug) LogPrintf("CDarkSendPool::CheckTimeout() -- Session timed out (30s) -- resetting\n"); + SetNull(); + UnlockCoins(); + + UpdateState(POOL_STATUS_ERROR); + lastMessage = _("Session timed out (30 seconds), please resubmit."); + } + + if(state == POOL_STATUS_SIGNING && GetTimeMillis()-lastTimeChanged >= (DARKSEND_SIGNING_TIMEOUT*1000)+addLagTime ) { + if(fDebug) LogPrintf("CDarkSendPool::CheckTimeout() -- Session timed out -- restting\n"); + ChargeFees(); + SetNull(); + UnlockCoins(); + //add my transactions to the new session + + UpdateState(POOL_STATUS_ERROR); + lastMessage = _("Signing timed out, please resubmit."); + } +} + +// check to see if the signature is valid +bool CDarkSendPool::SignatureValid(const CScript& newSig, const CTxIn& newVin){ + CTransaction txNew; + txNew.vin.clear(); + txNew.vout.clear(); + + int found = -1; + CScript sigPubKey = CScript(); + unsigned int i = 0; + + BOOST_FOREACH(CDarkSendEntry e, entries) { + BOOST_FOREACH(const CTxOut out, e.vout) + txNew.vout.push_back(out); + + BOOST_FOREACH(const CDarkSendEntryVin s, e.sev){ + txNew.vin.push_back(s.vin); + + if(s.vin == newVin){ + found = i; + sigPubKey = s.vin.prevPubKey; + } + i++; + } + } + + if(found >= 0){ //might have to do this one input at a time? + int n = found; + txNew.vin[n].scriptSig = newSig; + if(fDebug) LogPrintf("CDarkSendPool::SignatureValid() - Sign with sig %s\n", newSig.ToString().substr(0,24).c_str()); + if (!VerifyScript(txNew.vin[n].scriptSig, sigPubKey, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC, SignatureChecker(txNew, i))){ + if(fDebug) LogPrintf("CDarkSendPool::SignatureValid() - Signing - Error signing input %u\n", n); + return false; + } + } + + if(fDebug) LogPrintf("CDarkSendPool::SignatureValid() - Signing - Succesfully signed input\n"); + return true; +} + +// check to make sure the collateral provided by the client is valid +bool CDarkSendPool::IsCollateralValid(const CTransaction& txCollateral){ + if(txCollateral.vout.size() < 1) return false; + if(txCollateral.nLockTime != 0) return false; + + int64_t nValueIn = 0; + int64_t nValueOut = 0; + bool missingTx = false; + + BOOST_FOREACH(const CTxOut o, txCollateral.vout){ + nValueOut += o.nValue; + + if(!o.scriptPubKey.IsNormalPaymentScript()){ + LogPrintf ("CDarkSendPool::IsCollateralValid - Invalid Script %s\n", txCollateral.ToString().c_str()); + return false; + } + } + + BOOST_FOREACH(const CTxIn i, txCollateral.vin){ + CTransaction tx2; + uint256 hash; + //if(GetTransaction(i.prevout.hash, tx2, hash, true)){ + if(GetTransaction(i.prevout.hash, tx2, hash)){ + if(tx2.vout.size() > i.prevout.n) { + nValueIn += tx2.vout[i.prevout.n].nValue; + } + } else{ + missingTx = true; + } + } + + if(missingTx){ + if(fDebug) LogPrintf ("CDarkSendPool::IsCollateralValid - Unknown inputs in collateral transaction - %s\n", txCollateral.ToString().c_str()); + return false; + } + + //collateral transactions are required to pay out DARKSEND_COLLATERAL as a fee to the miners + if(nValueIn-nValueOut < DARKSEND_COLLATERAL) { + if(fDebug) LogPrintf ("CDarkSendPool::IsCollateralValid - did not include enough fees in transaction %d\n%s\n", nValueOut-nValueIn, txCollateral.ToString().c_str()); + return false; + } + + if(fDebug) LogPrintf("CDarkSendPool::IsCollateralValid %s\n", txCollateral.ToString().c_str()); + + CValidationState state; + //if(!AcceptableInputs(mempool, state, txCollateral)){ + bool* pfMissingInputs; + if(!AcceptableInputs(mempool, txCollateral, false, pfMissingInputs)){ + if(fDebug) LogPrintf ("CDarkSendPool::IsCollateralValid - didn't pass IsAcceptable\n"); + return false; + } + + return true; +} + + +// +// Add a clients transaction to the pool +// +bool CDarkSendPool::AddEntry(const std::vector& newInput, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& newOutput, std::string& error){ + if (!fMasterNode) return false; + + BOOST_FOREACH(CTxIn in, newInput) { + if (in.prevout.IsNull() || nAmount < 0) { + if(fDebug) LogPrintf ("CDarkSendPool::AddEntry - input not valid!\n"); + error = _("Input is not valid."); + sessionUsers--; + return false; + } + } + + if (!IsCollateralValid(txCollateral)){ + if(fDebug) LogPrintf ("CDarkSendPool::AddEntry - collateral not valid!\n"); + error = _("Collateral is not valid."); + sessionUsers--; + return false; + } + + if((int)entries.size() >= GetMaxPoolTransactions()){ + if(fDebug) LogPrintf ("CDarkSendPool::AddEntry - entries is full!\n"); + error = _("Entries are full."); + sessionUsers--; + return false; + } + + BOOST_FOREACH(CTxIn in, newInput) { + if(fDebug) LogPrintf("looking for vin -- %s\n", in.ToString().c_str()); + BOOST_FOREACH(const CDarkSendEntry v, entries) { + BOOST_FOREACH(const CDarkSendEntryVin s, v.sev){ + if(s.vin == in) { + if(fDebug) LogPrintf ("CDarkSendPool::AddEntry - found in vin\n"); + error = _("Already have that input."); + sessionUsers--; + return false; + } + } + } + } + + if(state == POOL_STATUS_ACCEPTING_ENTRIES) { + CDarkSendEntry v; + v.Add(newInput, nAmount, txCollateral, newOutput); + entries.push_back(v); + + if(fDebug) LogPrintf("CDarkSendPool::AddEntry -- adding %s\n", newInput[0].ToString().c_str()); + error = ""; + + return true; + } + + if(fDebug) LogPrintf ("CDarkSendPool::AddEntry - can't accept new entry, wrong state!\n"); + error = _("Wrong state."); + sessionUsers--; + return false; +} + +bool CDarkSendPool::AddScriptSig(const CTxIn newVin){ + if(fDebug) LogPrintf("CDarkSendPool::AddScriptSig -- new sig %s\n", newVin.scriptSig.ToString().substr(0,24).c_str()); + + BOOST_FOREACH(const CDarkSendEntry v, entries) { + BOOST_FOREACH(const CDarkSendEntryVin s, v.sev){ + if(s.vin.scriptSig == newVin.scriptSig) { + LogPrintf("CDarkSendPool::AddScriptSig - already exists \n"); + return false; + } + } + } + + if(!SignatureValid(newVin.scriptSig, newVin)){ + if(fDebug) LogPrintf("CDarkSendPool::AddScriptSig - Invalid Sig\n"); + return false; + } + + if(fDebug) LogPrintf("CDarkSendPool::AddScriptSig -- sig %s\n", newVin.ToString().c_str()); + + if(state == POOL_STATUS_SIGNING) { + BOOST_FOREACH(CTxIn& vin, finalTransaction.vin){ + if(newVin.prevout == vin.prevout && vin.nSequence == newVin.nSequence){ + vin.scriptSig = newVin.scriptSig; + vin.prevPubKey = newVin.prevPubKey; + if(fDebug) LogPrintf("CDarkSendPool::AddScriptSig -- adding to finalTransaction %s\n", newVin.scriptSig.ToString().substr(0,24).c_str()); + } + } + for(unsigned int i = 0; i < entries.size(); i++){ + if(entries[i].AddSig(newVin)){ + if(fDebug) LogPrintf("CDarkSendPool::AddScriptSig -- adding %s\n", newVin.scriptSig.ToString().substr(0,24).c_str()); + return true; + } + } + } + + LogPrintf("CDarkSendPool::AddScriptSig -- Couldn't set sig!\n" ); + return false; +} + +// check to make sure everything is signed +bool CDarkSendPool::SignaturesComplete(){ + BOOST_FOREACH(const CDarkSendEntry v, entries) { + BOOST_FOREACH(const CDarkSendEntryVin s, v.sev){ + if(!s.isSigSet) return false; + } + } + return true; +} + +// +// Execute a darksend denomination via a masternode. +// This is only ran from clients +// +void CDarkSendPool::SendluxsendDenominate(std::vector& vin, std::vector& vout, int64_t amount){ + if(darkSendPool.txCollateral == CTransaction()){ + LogPrintf ("CluxsendPool:SendluxsendDenominate() - darksend collateral not set"); + return; + } + + // lock the funds we're going to use + BOOST_FOREACH(CTxIn in, txCollateral.vin) + lockedCoins.push_back(in); + + BOOST_FOREACH(CTxIn in, vin) + lockedCoins.push_back(in); + + //BOOST_FOREACH(CTxOut o, vout) + // LogPrintf(" vout - %s\n", o.ToString().c_str()); + + + // we should already be connected to a masternode + if(!sessionFoundMasternode){ + LogPrintf("CDarkSendPool::SendluxsendDenominate() - No masternode has been selected yet.\n"); + UnlockCoins(); + SetNull(true); + return; + } + + if (!CheckDiskSpace()) + return; + + if(fMasterNode) { + LogPrintf("CDarkSendPool::SendluxsendDenominate() - DarkSend from a masternode is not supported currently.\n"); + return; + } + + UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); + + LogPrintf("CDarkSendPool::SendluxsendDenominate() - Added transaction to pool.\n"); + + ClearLastMessage(); + + //check it against the memory pool to make sure it's valid + { + int64_t nValueOut = 0; + + CValidationState state; + CTransaction tx; + + BOOST_FOREACH(const CTxOut o, vout){ + nValueOut += o.nValue; + tx.vout.push_back(o); + } + + BOOST_FOREACH(const CTxIn i, vin){ + tx.vin.push_back(i); + + if(fDebug) LogPrintf("dsi -- tx in %s\n", i.ToString().c_str()); + } + + //if(!AcceptableInputs(mempool, state, tx)){ + bool* pfMissingInputs; + if(!AcceptableInputs(mempool, tx, false, pfMissingInputs)){ + LogPrintf("dsi -- transaction not valid! %s \n", tx.ToString().c_str()); + return; + } + } + + // store our entry for later use + CDarkSendEntry e; + e.Add(vin, amount, txCollateral, vout); + myEntries.push_back(e); + + // relay our entry to the master node + RelayDarkSendIn(vin, amount, txCollateral, vout); + Check(); +} + +// Incoming message from masternode updating the progress of darksend +// newAccepted: -1 mean's it'n not a "transaction accepted/not accepted" message, just a standard update +// 0 means transaction was not accepted +// 1 means transaction was accepted + +bool CDarkSendPool::StatusUpdate(int newState, int newEntriesCount, int newAccepted, std::string& error, int newSessionID){ + if(fMasterNode) return false; + if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) return false; + + UpdateState(newState); + entriesCount = newEntriesCount; + + if(error.size() > 0) strAutoDenomResult = _("Masternode:") + " " + error; + + if(newAccepted != -1) { + lastEntryAccepted = newAccepted; + countEntriesAccepted += newAccepted; + if(newAccepted == 0){ + UpdateState(POOL_STATUS_ERROR); + lastMessage = error; + } + + if(newAccepted == 1) { + sessionID = newSessionID; + LogPrintf("CDarkSendPool::StatusUpdate - set sessionID to %d\n", sessionID); + sessionFoundMasternode = true; + } + } + + if(newState == POOL_STATUS_ACCEPTING_ENTRIES){ + if(newAccepted == 1){ + LogPrintf("CDarkSendPool::StatusUpdate - entry accepted! \n"); + sessionFoundMasternode = true; + //wait for other users. Masternode will report when ready + UpdateState(POOL_STATUS_QUEUE); + } else if (newAccepted == 0 && sessionID == 0 && !sessionFoundMasternode) { + LogPrintf("CDarkSendPool::StatusUpdate - entry not accepted by masternode \n"); + UnlockCoins(); + UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); + DoAutomaticDenominating(); //try another masternode + } + if(sessionFoundMasternode) return true; + } + + return true; +} + +// +// After we receive the finalized transaction from the masternode, we must +// check it to make sure it's what we want, then sign it if we agree. +// If we refuse to sign, it's possible we'll be charged collateral +// +bool CDarkSendPool::SignFinalTransaction(CTransaction& finalTransactionNew, CNode* node){ + if(fDebug) LogPrintf("CDarkSendPool::AddFinalTransaction - Got Finalized Transaction\n"); + + if(!finalTransaction.vin.empty()){ + LogPrintf("CDarkSendPool::AddFinalTransaction - Rejected Final Transaction!\n"); + return false; + } + + finalTransaction = finalTransactionNew; + LogPrintf("CDarkSendPool::SignFinalTransaction %s\n", finalTransaction.ToString().c_str()); + + vector sigs; + + //make sure my inputs/outputs are present, otherwise refuse to sign + BOOST_FOREACH(const CDarkSendEntry e, myEntries) { + BOOST_FOREACH(const CDarkSendEntryVin s, e.sev) { + /* Sign my transaction and all outputs */ + int mine = -1; + CScript prevPubKey = CScript(); + CTxIn vin = CTxIn(); + + for(unsigned int i = 0; i < finalTransaction.vin.size(); i++){ + if(finalTransaction.vin[i] == s.vin){ + mine = i; + prevPubKey = s.vin.prevPubKey; + vin = s.vin; + } + } + + if(mine >= 0){ //might have to do this one input at a time? + int foundOutputs = 0; + int64_t nValue1 = 0; + int64_t nValue2 = 0; + + for(unsigned int i = 0; i < finalTransaction.vout.size(); i++){ + BOOST_FOREACH(const CTxOut o, e.vout) { + if(finalTransaction.vout[i] == o){ + foundOutputs++; + nValue1 += finalTransaction.vout[i].nValue; + } + } + } + + BOOST_FOREACH(const CTxOut o, e.vout) + nValue2 += o.nValue; + + int targetOuputs = e.vout.size(); + if(foundOutputs < targetOuputs || nValue1 != nValue2) { + // in this case, something went wrong and we'll refuse to sign. It's possible we'll be charged collateral. But that's + // better then signing if the transaction doesn't look like what we wanted. + LogPrintf("CDarkSendPool::Sign - My entries are not correct! Refusing to sign. %d entries %d target. \n", foundOutputs, targetOuputs); + return false; + } + + if(fDebug) LogPrintf("CDarkSendPool::Sign - Signing my input %i\n", mine); + if(!SignSignature(*pwalletMain, prevPubKey, finalTransaction, mine, int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))) { // changes scriptSig + if(fDebug) LogPrintf("CDarkSendPool::Sign - Unable to sign my own transaction! \n"); + // not sure what to do here, it will timeout...? + } + + sigs.push_back(finalTransaction.vin[mine]); + if(fDebug) LogPrintf(" -- dss %d %d %s\n", mine, (int)sigs.size(), finalTransaction.vin[mine].scriptSig.ToString().c_str()); + } + + } + + if(fDebug) LogPrintf("CDarkSendPool::Sign - txNew:\n%s", finalTransaction.ToString().c_str()); + } + + // push all of our signatures to the masternode + if(sigs.size() > 0 && node != NULL) + node->PushMessage("dss", sigs); + + return true; +} + +void CDarkSendPool::NewBlock() +{ + if(fDebug) LogPrintf("CDarkSendPool::NewBlock \n"); + + //we we're processing lots of blocks, we'll just leave + if(GetTime() - lastNewBlock < 10) return; + lastNewBlock = GetTime(); + + darkSendPool.CheckTimeout(); + + if(!fEnableluxsend) return; + + if(!fMasterNode){ + //denominate all non-denominated inputs every 25 minutes. + if(pindexBest->nHeight % 10 == 0) UnlockCoins(); + ProcessMasternodeConnections(); + } +} + +// darksend transaction was completed (failed or successed) +void CDarkSendPool::CompletedTransaction(bool error, std::string lastMessageNew) +{ + if(fMasterNode) return; + + if(error){ + LogPrintf("CompletedTransaction -- error \n"); + UpdateState(POOL_STATUS_ERROR); + } else { + LogPrintf("CompletedTransaction -- success \n"); + UpdateState(POOL_STATUS_SUCCESS); + + myEntries.clear(); + + // To avoid race conditions, we'll only let DS run once per block + cachedLastSuccess = pindexBest->nHeight; + } + lastMessage = lastMessageNew; + + completedTransaction = true; + Check(); + UnlockCoins(); +} + +void CDarkSendPool::ClearLastMessage() +{ + lastMessage = ""; +} + +// +// Passively run darksend in the background to anonymize funds based on the given configuration. +// +// This does NOT run by default for daemons, only for QT. +// +bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun, bool ready) +{ + LOCK(cs_darksend); + + if(IsInitialBlockDownload()) return false; + + if(fMasterNode) return false; + if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) return false; + + if(pindexBest->nHeight - cachedLastSuccess < minBlockSpacing) { + LogPrintf("CDarkSendPool::DoAutomaticDenominating - Last successful darksend action was too recent\n"); + strAutoDenomResult = _("Last successful darksend action was too recent."); + return false; + } + if(!fEnableluxsend) { + if(fDebug) LogPrintf("CDarkSendPool::DoAutomaticDenominating - darksend is disabled\n"); + strAutoDenomResult = _("darksend is disabled."); + return false; + } + + if (!fDryRun && pwalletMain->IsLocked()){ + strAutoDenomResult = _("Wallet is locked."); + return false; + } + + if(darkSendPool.GetState() != POOL_STATUS_ERROR && darkSendPool.GetState() != POOL_STATUS_SUCCESS){ + if(darkSendPool.GetMyTransactionCount() > 0){ + return true; + } + } + + if(vecMasternodes.size() == 0){ + if(fDebug) LogPrintf("CDarkSendPool::DoAutomaticDenominating - No masternodes detected\n"); + strAutoDenomResult = _("No masternodes detected."); + return false; + } + + // ** find the coins we'll use + std::vector vCoins; + std::vector vCoins2; + int64_t nValueMin = CENT; + int64_t nValueIn = 0; + + // should not be less than fees in DARKSEND_FEE + few (lets say 5) smallest denoms + int64_t nLowestDenom = DARKSEND_FEE + darkSendDenominations[darkSendDenominations.size() - 1]*5; + + // if there are no DS collateral inputs yet + if(!pwalletMain->HasCollateralInputs()) + // should have some additional amount for them + nLowestDenom += (DARKSEND_COLLATERAL*4)+DARKSEND_FEE*2; + + int64_t nBalanceNeedsAnonymized = nAnonymizeSONOAmount*COIN - pwalletMain->GetAnonymizedBalance(); + + // if balanceNeedsAnonymized is more than pool max, take the pool max + if(nBalanceNeedsAnonymized > DARKSEND_POOL_MAX) nBalanceNeedsAnonymized = DARKSEND_POOL_MAX; + + // if balanceNeedsAnonymized is more than non-anonymized, take non-anonymized + int64_t nBalanceNotYetAnonymized = pwalletMain->GetBalance() - pwalletMain->GetAnonymizedBalance(); + if(nBalanceNeedsAnonymized > nBalanceNotYetAnonymized) nBalanceNeedsAnonymized = nBalanceNotYetAnonymized; + + if(nBalanceNeedsAnonymized < nLowestDenom) + { +// if(nBalanceNeedsAnonymized > nValueMin) +// nBalanceNeedsAnonymized = nLowestDenom; +// else +// { + LogPrintf("DoAutomaticDenominating : No funds detected in need of denominating \n"); + strAutoDenomResult = _("No funds detected in need of denominating."); + return false; +// } + } + + if (fDebug) LogPrintf("DoAutomaticDenominating : nLowestDenom=%d, nBalanceNeedsAnonymized=%d\n", nLowestDenom, nBalanceNeedsAnonymized); + + // select coins that should be given to the pool + if (!pwalletMain->SelectCoinsDark(nValueMin, nBalanceNeedsAnonymized, vCoins, nValueIn, 0, nDarksendRounds)) + { + nValueIn = 0; + vCoins.clear(); + + if (pwalletMain->SelectCoinsDark(nValueMin, 9999999*COIN, vCoins, nValueIn, -2, 0)) + { + if(!fDryRun) return CreateDenominated(nBalanceNeedsAnonymized); + return true; + } else { + LogPrintf("DoAutomaticDenominating : Can't denominate - no compatible inputs left\n"); + strAutoDenomResult = _("Can't denominate: no compatible inputs left."); + return false; + } + + } + + //check to see if we have the collateral sized inputs, it requires these + if(!pwalletMain->HasCollateralInputs()){ + if(!fDryRun) MakeCollateralAmounts(); + return true; + } + + if(fDryRun) return true; + + // initial phase, find a masternode + if(!sessionFoundMasternode){ + int nUseQueue = rand()%100; + + sessionTotalValue = pwalletMain->GetTotalValue(vCoins); + + //randomize the amounts we mix + if(sessionTotalValue > nBalanceNeedsAnonymized) sessionTotalValue = nBalanceNeedsAnonymized; + + double fSONOSubmitted = (sessionTotalValue / CENT); + LogPrintf("Submitting darksend for %f SONO CENT - sessionTotalValue %d\n", fSONOSubmitted, sessionTotalValue); + + if(pwalletMain->GetDenominatedBalance(true, true) > 0){ //get denominated unconfirmed inputs + LogPrintf("DoAutomaticDenominating -- Found unconfirmed denominated outputs, will wait till they confirm to continue.\n"); + strAutoDenomResult = _("Found unconfirmed denominated outputs, will wait till they confirm to continue."); + return false; + } + + //don't use the queues all of the time for mixing + if(nUseQueue > 33){ + + // Look through the queues and see if anything matches + BOOST_FOREACH(CluxsendQueue& dsq, vecluxsendQueue){ + CService addr; + if(dsq.time == 0) continue; + + if(!dsq.GetAddress(addr)) continue; + if(dsq.IsExpired()) continue; + + int protocolVersion; + if(!dsq.GetProtocolVersion(protocolVersion)) continue; + if(protocolVersion < MIN_PEER_PROTO_VERSION) continue; + + //non-denom's are incompatible + if((dsq.nDenom & (1 << 4))) continue; + + //don't reuse masternodes + BOOST_FOREACH(CTxIn usedVin, vecMasternodesUsed){ + if(dsq.vin == usedVin) { + continue; + } + } + + // Try to match their denominations if possible + if (!pwalletMain->SelectCoinsByDenominations(dsq.nDenom, nValueMin, nBalanceNeedsAnonymized, vCoins, vCoins2, nValueIn, 0, nDarksendRounds)){ + LogPrintf("DoAutomaticDenominating - Couldn't match denominations %d\n", dsq.nDenom); + continue; + } + + // connect to masternode and submit the queue request + if(ConnectNode((CAddress)addr, NULL, true)){ + submittedToMasternode = addr; + + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + if((CNetAddr)pnode->addr != (CNetAddr)submittedToMasternode) continue; + + std::string strReason; + if(txCollateral == CTransaction()){ + if(!pwalletMain->CreateCollateralTransaction(txCollateral, strReason)){ + LogPrintf("DoAutomaticDenominating -- dsa error:%s\n", strReason.c_str()); + return false; + } + } + + vecMasternodesUsed.push_back(dsq.vin); + sessionDenom = dsq.nDenom; + + pnode->PushMessage("dsa", sessionDenom, txCollateral); + LogPrintf("DoAutomaticDenominating --- connected (from queue), sending dsa for %d %d - %s\n", sessionDenom, GetDenominationsByAmount(sessionTotalValue), pnode->addr.ToString().c_str()); + strAutoDenomResult = ""; + return true; + } + } else { + LogPrintf("DoAutomaticDenominating --- error connecting \n"); + strAutoDenomResult = _("Error connecting to masternode."); + return DoAutomaticDenominating(); + } + + dsq.time = 0; //remove node + } + } + + //shuffle masternodes around before we try to connect + std::random_shuffle ( vecMasternodes.begin(), vecMasternodes.end() ); + int i = 0; + + // otherwise, try one randomly + while(i < 10) + { + //don't reuse masternodes + BOOST_FOREACH(CTxIn usedVin, vecMasternodesUsed) { + if(vecMasternodes[i].vin == usedVin){ + i++; + continue; + } + } + if(vecMasternodes[i].protocolVersion < MIN_PEER_PROTO_VERSION) { + i++; + continue; + } + + if(vecMasternodes[i].nLastDsq != 0 && + vecMasternodes[i].nLastDsq + CountMasternodesAboveProtocol(darkSendPool.MIN_PEER_PROTO_VERSION)/5 > darkSendPool.nDsqCount){ + i++; + continue; + } + + lastTimeChanged = GetTimeMillis(); + LogPrintf("DoAutomaticDenominating -- attempt %d connection to masternode %s\n", i, vecMasternodes[i].addr.ToString().c_str()); + if(ConnectNode((CAddress)vecMasternodes[i].addr, NULL, true)){ + submittedToMasternode = vecMasternodes[i].addr; + + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + if((CNetAddr)pnode->addr != (CNetAddr)vecMasternodes[i].addr) continue; + + std::string strReason; + if(txCollateral == CTransaction()){ + if(!pwalletMain->CreateCollateralTransaction(txCollateral, strReason)){ + LogPrintf("DoAutomaticDenominating -- create collateral error:%s\n", strReason.c_str()); + return false; + } + } + + vecMasternodesUsed.push_back(vecMasternodes[i].vin); + + std::vector vecAmounts; + pwalletMain->ConvertList(vCoins, vecAmounts); + sessionDenom = GetDenominationsByAmounts(vecAmounts); + + pnode->PushMessage("dsa", sessionDenom, txCollateral); + LogPrintf("DoAutomaticDenominating --- connected, sending dsa for %d - denom %d\n", sessionDenom, GetDenominationsByAmount(sessionTotalValue)); + strAutoDenomResult = ""; + return true; + } + } else { + i++; + continue; + } + } + + strAutoDenomResult = _("No compatible masternode found."); + return false; + } + + strAutoDenomResult = ""; + if(!ready) return true; + + if(sessionDenom == 0) return true; + + return false; +} + + +bool CDarkSendPool::PrepareluxsendDenominate() +{ + // Submit transaction to the pool if we get here, use sessionDenom so we use the same amount of money + std::string strError = pwalletMain->PrepareluxsendDenominate(0, nDarksendRounds); + LogPrintf("DoAutomaticDenominating : Running darksend denominate. Return '%s'\n", strError.c_str()); + + if(strError == "") return true; + + strAutoDenomResult = strError; + LogPrintf("DoAutomaticDenominating : Error running denominate, %s\n", strError.c_str()); + return false; +} + +bool CDarkSendPool::SendRandomPaymentToSelf() +{ + int64_t nBalance = pwalletMain->GetBalance(); + int64_t nPayment = (nBalance*0.35) + (rand() % nBalance); + + if(nPayment > nBalance) nPayment = nBalance-(0.1*COIN); + + // make our change address + CReserveKey reservekey(pwalletMain); + + CScript scriptChange; + CPubKey vchPubKey; + assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked + scriptChange= GetScriptForDestination(vchPubKey.GetID()); + + CWalletTx wtx; + int64_t nFeeRet = 0; + std::string strFail = ""; + vector< pair > vecSend; + + // ****** Add fees ************ / + vecSend.push_back(make_pair(scriptChange, nPayment)); + + CCoinControl *coinControl=NULL; + int32_t nChangePos; + bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePos, strFail, coinControl, ONLY_DENOMINATED); + if(!success){ + LogPrintf("SendRandomPaymentToSelf: Error - %s\n", strFail.c_str()); + return false; + } + + pwalletMain->CommitTransaction(wtx, reservekey); + + LogPrintf("SendRandomPaymentToSelf Success: tx %s\n", wtx.GetHash().GetHex().c_str()); + + return true; +} + +// Split up large inputs or create fee sized inputs +bool CDarkSendPool::MakeCollateralAmounts() +{ + // make our change address + CReserveKey reservekey(pwalletMain); + + CScript scriptChange; + CPubKey vchPubKey; + assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked + scriptChange= GetScriptForDestination(vchPubKey.GetID()); + + CWalletTx wtx; + int64_t nFeeRet = 0; + std::string strFail = ""; + vector< pair > vecSend; + + vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE)); + vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE)); + + CCoinControl *coinControl=NULL; + int32_t nChangePos; + // try to use non-denominated and not mn-like funds + bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, + nFeeRet, nChangePos, strFail, coinControl, ONLY_NONDENOMINATED_NOTMN); + if(!success){ + // if we failed (most likeky not enough funds), try to use denominated instead - + // MN-like funds should not be touched in any case and we can't mix denominated without collaterals anyway + success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, + nFeeRet, nChangePos, strFail, coinControl, ONLY_DENOMINATED); + if(!success){ + LogPrintf("MakeCollateralAmounts: Error - %s\n", strFail.c_str()); + return false; + } + } + + // use the same cachedLastSuccess as for DS mixinx to prevent race + if(pwalletMain->CommitTransaction(wtx, reservekey)) + cachedLastSuccess = pindexBest->nHeight; + + LogPrintf("MakeCollateralAmounts Success: tx %s\n", wtx.GetHash().GetHex().c_str()); + + return true; +} + +// Create denominations +bool CDarkSendPool::CreateDenominated(int64_t nTotalValue) +{ + // make our change address + CReserveKey reservekey(pwalletMain); + + CScript scriptChange; + CPubKey vchPubKey; + assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked + scriptChange= GetScriptForDestination(vchPubKey.GetID()); + + CWalletTx wtx; + int64_t nFeeRet = 0; + std::string strFail = ""; + vector< pair > vecSend; + int64_t nValueLeft = nTotalValue; + + // ****** Add collateral outputs ************ / + if(!pwalletMain->HasCollateralInputs()) { + vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE)); + nValueLeft -= (DARKSEND_COLLATERAL*2)+DARKSEND_FEE; + vecSend.push_back(make_pair(scriptChange, (DARKSEND_COLLATERAL*2)+DARKSEND_FEE)); + nValueLeft -= (DARKSEND_COLLATERAL*2)+DARKSEND_FEE; + } + + // ****** Add denoms ************ / + BOOST_REVERSE_FOREACH(int64_t v, darkSendDenominations){ + int nOutputs = 0; + + // add each output up to 10 times until it can't be added again + while(nValueLeft - v >= DARKSEND_FEE && nOutputs <= 10) { + CScript scriptChange; + CPubKey vchPubKey; + //use a unique change address + assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked + scriptChange= GetScriptForDestination(vchPubKey.GetID()); + reservekey.KeepKey(); + + vecSend.push_back(make_pair(scriptChange, v)); + + //increment outputs and subtract denomination amount + nOutputs++; + nValueLeft -= v; + LogPrintf("CreateDenominated1 %d\n", nValueLeft); + } + + if(nValueLeft == 0) break; + } + LogPrintf("CreateDenominated2 %d\n", nValueLeft); + + // if we have anything left over, it will be automatically send back as change - there is no need to send it manually + + CCoinControl *coinControl=NULL; + int32_t nChangePos; + bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, + nFeeRet, nChangePos, strFail, coinControl, ONLY_NONDENOMINATED_NOTMN); + if(!success){ + LogPrintf("CreateDenominated: Error - %s\n", strFail.c_str()); + return false; + } + + // use the same cachedLastSuccess as for DS mixinx to prevent race + if(pwalletMain->CommitTransaction(wtx, reservekey)) + cachedLastSuccess = pindexBest->nHeight; + + LogPrintf("CreateDenominated Success: tx %s\n", wtx.GetHash().GetHex().c_str()); + + return true; +} + +bool CDarkSendPool::IsCompatibleWithEntries(std::vector vout) +{ + BOOST_FOREACH(const CDarkSendEntry v, entries) { + LogPrintf(" IsCompatibleWithEntries %d %d\n", GetDenominations(vout), GetDenominations(v.vout)); +/* + BOOST_FOREACH(CTxOut o1, vout) + LogPrintf(" vout 1 - %s\n", o1.ToString().c_str()); + + BOOST_FOREACH(CTxOut o2, v.vout) + LogPrintf(" vout 2 - %s\n", o2.ToString().c_str()); +*/ + if(GetDenominations(vout) != GetDenominations(v.vout)) return false; + } + + return true; +} + +bool CDarkSendPool::IsCompatibleWithSession(int64_t nDenom, CTransaction txCollateral, std::string& strReason) +{ + LogPrintf("CDarkSendPool::IsCompatibleWithSession - sessionDenom %d sessionUsers %d\n", sessionDenom, sessionUsers); + + if (!unitTest && !IsCollateralValid(txCollateral)){ + if(fDebug) LogPrintf ("CDarkSendPool::IsCompatibleWithSession - collateral not valid!\n"); + strReason = _("Collateral not valid."); + return false; + } + + if(sessionUsers < 0) sessionUsers = 0; + + if(sessionUsers == 0) { + sessionDenom = nDenom; + sessionUsers++; + lastTimeChanged = GetTimeMillis(); + entries.clear(); + + if(!unitTest){ + //broadcast that I'm accepting entries, only if it's the first entry though + CluxsendQueue dsq; + dsq.nDenom = nDenom; + dsq.vin = activeMasternode.vin; + dsq.time = GetTime(); + dsq.Sign(); + dsq.Relay(); + } + + UpdateState(POOL_STATUS_QUEUE); + vecSessionCollateral.push_back(txCollateral); + return true; + } + + if((state != POOL_STATUS_ACCEPTING_ENTRIES && state != POOL_STATUS_QUEUE) || sessionUsers >= GetMaxPoolTransactions()){ + if((state != POOL_STATUS_ACCEPTING_ENTRIES && state != POOL_STATUS_QUEUE)) strReason = _("Incompatible mode."); + if(sessionUsers >= GetMaxPoolTransactions()) strReason = _("Masternode queue is full."); + LogPrintf("CDarkSendPool::IsCompatibleWithSession - incompatible mode, return false %d %d\n", state != POOL_STATUS_ACCEPTING_ENTRIES, sessionUsers >= GetMaxPoolTransactions()); + return false; + } + + if(nDenom != sessionDenom) { + strReason = _("No matching denominations found for mixing."); + return false; + } + + LogPrintf("CDarkSendPool::IsCompatibleWithSession - compatible\n"); + + sessionUsers++; + lastTimeChanged = GetTimeMillis(); + vecSessionCollateral.push_back(txCollateral); + + return true; +} + +//create a nice string to show the denominations +void CDarkSendPool::GetDenominationsToString(int nDenom, std::string& strDenom){ + // Function returns as follows: + // + // bit 0 - 100SONO+1 ( bit on if present ) + // bit 1 - 10SONO+1 + // bit 2 - 1SONO+1 + // bit 3 - .1SONO+1 + // bit 3 - non-denom + + + strDenom = ""; + + if(nDenom & (1 << 0)) { + if(strDenom.size() > 0) strDenom += "+"; + strDenom += "100"; + } + + if(nDenom & (1 << 1)) { + if(strDenom.size() > 0) strDenom += "+"; + strDenom += "10"; + } + + if(nDenom & (1 << 2)) { + if(strDenom.size() > 0) strDenom += "+"; + strDenom += "1"; + } + + if(nDenom & (1 << 3)) { + if(strDenom.size() > 0) strDenom += "+"; + strDenom += "0.1"; + } +} + +// return a bitshifted integer representing the denominations in this list +int CDarkSendPool::GetDenominations(const std::vector& vout){ + std::vector > denomUsed; + + // make a list of denominations, with zero uses + BOOST_FOREACH(int64_t d, darkSendDenominations) + denomUsed.push_back(make_pair(d, 0)); + + // look for denominations and update uses to 1 + BOOST_FOREACH(CTxOut out, vout){ + bool found = false; + BOOST_FOREACH (PAIRTYPE(int64_t, int)& s, denomUsed){ + if (out.nValue == s.first){ + s.second = 1; + found = true; + } + } + if(!found) return 0; + } + + int denom = 0; + int c = 0; + // if the denomination is used, shift the bit on. + // then move to the next + BOOST_FOREACH (PAIRTYPE(int64_t, int)& s, denomUsed) + denom |= s.second << c++; + + // Function returns as follows: + // + // bit 0 - 100SONO+1 ( bit on if present ) + // bit 1 - 10SONO+1 + // bit 2 - 1SONO+1 + // bit 3 - .1SONO+1 + + return denom; +} + + +int CDarkSendPool::GetDenominationsByAmounts(std::vector& vecAmount){ + CScript e = CScript(); + std::vector vout1; + + // Make outputs by looping through denominations, from small to large + BOOST_REVERSE_FOREACH(int64_t v, vecAmount){ + int nOutputs = 0; + + CTxOut o(v, e); + vout1.push_back(o); + nOutputs++; + } + + return GetDenominations(vout1); +} + +int CDarkSendPool::GetDenominationsByAmount(int64_t nAmount, int nDenomTarget){ + CScript e = CScript(); + int64_t nValueLeft = nAmount; + + std::vector vout1; + + // Make outputs by looping through denominations, from small to large + BOOST_REVERSE_FOREACH(int64_t v, darkSendDenominations){ + if(nDenomTarget != 0){ + bool fAccepted = false; + if((nDenomTarget & (1 << 0)) && v == ((100000*COIN)+100000000)) {fAccepted = true;} + else if((nDenomTarget & (1 << 1)) && v == ((10000*COIN) +10000000)) {fAccepted = true;} + else if((nDenomTarget & (1 << 2)) && v == ((1000*COIN) +1000000)) {fAccepted = true;} + else if((nDenomTarget & (1 << 3)) && v == ((100*COIN) +100000)) {fAccepted = true;} + else if((nDenomTarget & (1 << 4)) && v == ((10*COIN) +10000)) {fAccepted = true;} + else if((nDenomTarget & (1 << 5)) && v == ((1*COIN) +1000)) {fAccepted = true;} + else if((nDenomTarget & (1 << 6)) && v == ((.1*COIN) +100)) {fAccepted = true;} + if(!fAccepted) continue; + } + + int nOutputs = 0; + + // add each output up to 10 times until it can't be added again + while(nValueLeft - v >= 0 && nOutputs <= 10) { + CTxOut o(v, e); + vout1.push_back(o); + nValueLeft -= v; + nOutputs++; + } + LogPrintf("GetDenominationsByAmount --- %d nOutputs %d\n", v, nOutputs); + } + + //add non-denom left overs as change + if(nValueLeft > 0){ + CTxOut o(nValueLeft, e); + vout1.push_back(o); + } + + return GetDenominations(vout1); +} + +bool CDarkSendSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey){ + CScript payee2; + payee2= GetScriptForDestination(pubkey.GetID()); + + CTransaction txVin; + uint256 hash; + //if(GetTransaction(vin.prevout.hash, txVin, hash, true)){ + if(GetTransaction(vin.prevout.hash, txVin, hash)){ + BOOST_FOREACH(CTxOut out, txVin.vout){ + if(out.nValue == GetMNCollateral(pindexBest->nHeight)*COIN){ + if(out.scriptPubKey == payee2) return true; + } + } + } + + return false; +} + +bool CDarkSendSigner::SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey){ + CBitcoinSecret vchSecret; + bool fGood = vchSecret.SetString(strSecret); + + if (!fGood) { + errorMessage = _("Invalid private key."); + return false; + } + + key = vchSecret.GetKey(); + pubkey = key.GetPubKey(); + + return true; +} + +bool CDarkSendSigner::SignMessage(std::string strMessage, std::string& errorMessage, vector& vchSig, CKey key) +{ + CHashWriter ss(SER_GETHASH, 0); + ss << strMessageMagic; + ss << strMessage; + + if (!key.SignCompact(ss.GetHash(), vchSig)) { + errorMessage = _("Signing failed."); + return false; + } + + return true; +} + +bool CDarkSendSigner::VerifyMessage(CPubKey pubkey, vector& vchSig, std::string strMessage, std::string& errorMessage) +{ + CHashWriter ss(SER_GETHASH, 0); + ss << strMessageMagic; + ss << strMessage; + + CPubKey pubkey2; + if (!pubkey2.RecoverCompact(ss.GetHash(), vchSig)) { + errorMessage = _("Error recovering public key."); + return false; + } + + if (fDebug && pubkey2.GetID() != pubkey.GetID()) + LogPrintf("CDarkSendSigner::VerifyMessage -- keys don't match: %s %s", pubkey2.GetID().ToString(), pubkey.GetID().ToString()); + + return (pubkey2.GetID() == pubkey.GetID()); +} + +bool CluxsendQueue::Sign() +{ + if(!fMasterNode) return false; + + std::string strMessage = vin.ToString() + boost::lexical_cast(nDenom) + boost::lexical_cast(time) + boost::lexical_cast(ready); + + CKey key2; + CPubKey pubkey2; + std::string errorMessage = ""; + + if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, key2, pubkey2)) + { + LogPrintf("CluxsendQueue():Relay - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage.c_str()); + return false; + } + + if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, key2)) { + LogPrintf("CluxsendQueue():Relay - Sign message failed"); + return false; + } + + if(!darkSendSigner.VerifyMessage(pubkey2, vchSig, strMessage, errorMessage)) { + LogPrintf("CluxsendQueue():Relay - Verify message failed"); + return false; + } + + return true; +} + +bool CluxsendQueue::Relay() +{ + + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes){ + // always relay to everyone + pnode->PushMessage("dsq", (*this)); + } + + return true; +} + +bool CluxsendQueue::CheckSignature() +{ + BOOST_FOREACH(CMasterNode& mn, vecMasternodes) { + + if(mn.vin == vin) { + std::string strMessage = vin.ToString() + boost::lexical_cast(nDenom) + boost::lexical_cast(time) + boost::lexical_cast(ready); + + std::string errorMessage = ""; + if(!darkSendSigner.VerifyMessage(mn.pubkey2, vchSig, strMessage, errorMessage)){ + return error("CluxsendQueue::CheckSignature() - Got bad masternode address signature %s \n", vin.ToString().c_str()); + } + + return true; + } + } + + return false; +} + + +//TODO: Rename/move to core +void ThreadCheckDarkSendPool() +{ + if(fLiteMode) return; //disable all darksend/masternode related functionality + + // Make this thread recognisable as the wallet flushing thread + RenameThread("SONO-darksend"); + + unsigned int c = 0; + std::string errorMessage; + + while (true) + { + c++; + + MilliSleep(2500); + //LogPrintf("ThreadCheckDarkSendPool::check timeout\n"); + darkSendPool.CheckTimeout(); + + if(c % 60 == 0){ + LOCK(cs_main); + /* + cs_main is required for doing masternode.Check because something + is modifying the coins view without a mempool lock. It causes + segfaults from this code without the cs_main lock. + */ + { + + LOCK(cs_masternodes); + vector::iterator it = vecMasternodes.begin(); + //check them separately + while(it != vecMasternodes.end()){ + (*it).Check(); + ++it; + } + + int count = vecMasternodes.size(); + int i = 0; + + BOOST_FOREACH(CMasterNode mn, vecMasternodes) { + + if(mn.addr.IsRFC1918()) continue; //local network + if(mn.IsEnabled()) { + if(fDebug) LogPrintf("Sending masternode entry - %s \n", mn.addr.ToString().c_str()); + BOOST_FOREACH(CNode* pnode, vNodes) { + pnode->PushMessage("dsee", mn.vin, mn.addr, mn.sig, mn.now, mn.pubkey, mn.pubkey2, count, i, mn.lastTimeSeen, mn.protocolVersion); + } + } + i++; + } + + //remove inactive + it = vecMasternodes.begin(); + while(it != vecMasternodes.end()){ + if((*it).enabled == 4 || (*it).enabled == 3){ + LogPrintf("Removing inactive masternode %s\n", (*it).addr.ToString().c_str()); + it = vecMasternodes.erase(it); + } else { + ++it; + } + } + + } + + masternodePayments.CleanPaymentList(); + CleanTransactionLocksList(); + } + + //try to sync the masternode list and payment list every 5 seconds from at least 3 nodes + if(c % 5 == 0 && RequestedMasterNodeList < 3){ + bool fIsInitialDownload = IsInitialBlockDownload(); + if(!fIsInitialDownload) { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + if (pnode->nVersion >= darkSendPool.MIN_PEER_PROTO_VERSION) { + + //keep track of who we've asked for the list + if(pnode->HasFulfilledRequest("mnsync")) continue; + pnode->FulfilledRequest("mnsync"); + + LogPrintf("Successfully synced, asking for Masternode list and payment list\n"); + + pnode->PushMessage("dseg", CTxIn()); //request full mn list + pnode->PushMessage("mnget"); //sync payees + pnode->PushMessage("getsporks"); //get current network sporks + RequestedMasterNodeList++; + } + } + } + } + + if(c % MASTERNODE_PING_SECONDS == 0){ + activeMasternode.ManageStatus(); + } + + if(c % 60 == 0){ + //if we've used 1/5 of the masternode list, then clear the list. + if((int)vecMasternodesUsed.size() > (int)vecMasternodes.size() / 5) + vecMasternodesUsed.clear(); + } + + //auto denom every 1 minutes (liquidity provides try less often) + if(c % 60*(nLiquidityProvider+1) == 0){ + if(nLiquidityProvider!=0){ + int nRand = rand() % (101+nLiquidityProvider); + //about 1/100 chance of starting over after 4 rounds. + if(nRand == 50+nLiquidityProvider && pwalletMain->GetAverageAnonymizedRounds() > 8){ + darkSendPool.SendRandomPaymentToSelf(); + int nLeftToAnon = ((pwalletMain->GetBalance() - pwalletMain->GetAnonymizedBalance())/COIN)-3; + if(nLeftToAnon > 999) nLeftToAnon = 999; + nAnonymizeSONOAmount = (rand() % nLeftToAnon)+3; + } else { + darkSendPool.DoAutomaticDenominating(); + } + } else { + darkSendPool.DoAutomaticDenominating(); + } + } + } +} diff --git a/src/darksend.h b/src/darksend.h new file mode 100644 index 0000000..f3fefe3 --- /dev/null +++ b/src/darksend.h @@ -0,0 +1,432 @@ +// Copyright (c) 2014-2015 The Darkcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef DARKSEND_H +#define DARKSEND_H + +//#include "primitives/transaction.h" +#include "main.h" +#include "masternode.h" +#include "activemasternode.h" + +class CTxIn; +class CDarkSendPool; +class CDarkSendSigner; +class CMasterNodeVote; +class CBitcoinAddress; +class CluxsendQueue; +class CluxsendBroadcastTx; +class CActiveMasternode; + +#define POOL_MAX_TRANSACTIONS 3 // wait for X transactions to merge and publish +#define POOL_STATUS_UNKNOWN 0 // waiting for update +#define POOL_STATUS_IDLE 1 // waiting for update +#define POOL_STATUS_QUEUE 2 // waiting in a queue +#define POOL_STATUS_ACCEPTING_ENTRIES 3 // accepting entries +#define POOL_STATUS_FINALIZE_TRANSACTION 4 // master node will broadcast what it accepted +#define POOL_STATUS_SIGNING 5 // check inputs/outputs, sign final tx +#define POOL_STATUS_TRANSMISSION 6 // transmit transaction +#define POOL_STATUS_ERROR 7 // error +#define POOL_STATUS_SUCCESS 8 // success + +// status update message constants +#define MASTERNODE_ACCEPTED 1 +#define MASTERNODE_REJECTED 0 +#define MASTERNODE_RESET -1 + +#define DARKSEND_QUEUE_TIMEOUT 120 +#define DARKSEND_SIGNING_TIMEOUT 30 + +extern CDarkSendPool darkSendPool; +extern CDarkSendSigner darkSendSigner; +extern std::vector vecluxsendQueue; +extern std::string strMasterNodePrivKey; +extern map mapluxsendBroadcastTxes; +extern CActiveMasternode activeMasternode; + +//specific messages for the darksend protocol +void ProcessMessageluxsend(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); + +// get the darksend chain depth for a given input +int GetInputluxsendRounds(CTxIn in, int rounds=0); + + +// An input in the darksend pool +class CDarkSendEntryVin +{ +public: + bool isSigSet; + CTxIn vin; + + CDarkSendEntryVin() + { + isSigSet = false; + vin = CTxIn(); + } +}; + +// A clients transaction in the darksend pool +class CDarkSendEntry +{ +public: + bool isSet; + std::vector sev; + int64_t amount; + CTransaction collateral; + std::vector vout; + CTransaction txSupporting; + int64_t addedTime; + + CDarkSendEntry() + { + isSet = false; + collateral = CTransaction(); + amount = 0; + } + + bool Add(const std::vector vinIn, int64_t amountIn, const CTransaction collateralIn, const std::vector voutIn) + { + if(isSet){return false;} + + BOOST_FOREACH(const CTxIn v, vinIn) { + CDarkSendEntryVin s = CDarkSendEntryVin(); + s.vin = v; + sev.push_back(s); + } + vout = voutIn; + amount = amountIn; + collateral = collateralIn; + isSet = true; + addedTime = GetTime(); + + return true; + } + + bool AddSig(const CTxIn& vin) + { + BOOST_FOREACH(CDarkSendEntryVin& s, sev) { + if(s.vin.prevout == vin.prevout && s.vin.nSequence == vin.nSequence){ + if(s.isSigSet){return false;} + s.vin.scriptSig = vin.scriptSig; + s.vin.prevPubKey = vin.prevPubKey; + s.isSigSet = true; + + return true; + } + } + + return false; + } + + bool IsExpired() + { + return (GetTime() - addedTime) > DARKSEND_QUEUE_TIMEOUT;// 120 seconds + } +}; + +// +// A currently inprogress darksend merge and denomination information +// +class CluxsendQueue +{ +public: + CTxIn vin; + int64_t time; + int nDenom; + bool ready; //ready for submit + std::vector vchSig; + + CluxsendQueue() + { + nDenom = 0; + vin = CTxIn(); + time = 0; + vchSig.clear(); + ready = false; + } + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion){ + unsigned int nSerSize = 0; + READWRITE(nDenom); + READWRITE(vin); + READWRITE(time); + READWRITE(ready); + READWRITE(vchSig); + } + + bool GetAddress(CService &addr) + { + BOOST_FOREACH(CMasterNode mn, vecMasternodes) { + if(mn.vin == vin){ + addr = mn.addr; + return true; + } + } + return false; + } + + bool GetProtocolVersion(int &protocolVersion) + { + BOOST_FOREACH(CMasterNode mn, vecMasternodes) { + if(mn.vin == vin){ + protocolVersion = mn.protocolVersion; + return true; + } + } + return false; + } + + bool Sign(); + bool Relay(); + + bool IsExpired() + { + return (GetTime() - time) > DARKSEND_QUEUE_TIMEOUT;// 120 seconds + } + + bool CheckSignature(); + +}; + +// store darksend tx signature information +class CluxsendBroadcastTx +{ +public: + CTransaction tx; + CTxIn vin; + vector vchSig; + int64_t sigTime; +}; + +// +// Helper object for signing and checking signatures +// +class CDarkSendSigner +{ +public: + bool IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey); + bool SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey); + bool SignMessage(std::string strMessage, std::string& errorMessage, std::vector& vchSig, CKey key); + bool VerifyMessage(CPubKey pubkey, std::vector& vchSig, std::string strMessage, std::string& errorMessage); +}; + +class CluxsendSession +{ + +}; + +// +// Used to keep track of current status of darksend pool +// +class CDarkSendPool +{ +public: + static const int MIN_PEER_PROTO_VERSION = 69100; + + // clients entries + std::vector myEntries; + // masternode entries + std::vector entries; + // the finalized transaction ready for signing + CTransaction finalTransaction; + + int64_t lastTimeChanged; + int64_t lastAutoDenomination; + + unsigned int state; + unsigned int entriesCount; + unsigned int lastEntryAccepted; + unsigned int countEntriesAccepted; + + // where collateral should be made out to + CScript collateralPubKey; + + std::vector lockedCoins; + + uint256 masterNodeBlockHash; + + std::string lastMessage; + bool completedTransaction; + bool unitTest; + CService submittedToMasternode; + + int sessionID; + int sessionDenom; //Users must submit an denom matching this + int sessionUsers; //N Users have said they'll join + bool sessionFoundMasternode; //If we've found a compatible masternode + int64_t sessionTotalValue; //used for autoDenom + std::vector vecSessionCollateral; + + int cachedLastSuccess; + int cachedNumBlocks; //used for the overview screen + int minBlockSpacing; //required blocks between mixes + CTransaction txCollateral; + + int64_t lastNewBlock; + + //debugging data + std::string strAutoDenomResult; + + //incremented whenever a DSQ comes through + int64_t nDsqCount; + + CDarkSendPool() + { + /* DarkSend uses collateral addresses to trust parties entering the pool + to behave themselves. If they don't it takes their money. */ + + cachedLastSuccess = 0; + cachedNumBlocks = 0; + unitTest = false; + txCollateral = CTransaction(); + minBlockSpacing = 1; + nDsqCount = 0; + lastNewBlock = 0; + + SetNull(); + } + + void InitCollateralAddress(){ + std::string strAddress = ""; + strAddress = "ALP7BSz8eJsEL6dKsYkeWRGzS8fxaorNU4"; + SetCollateralAddress(strAddress); + } + + void SetMinBlockSpacing(int minBlockSpacingIn){ + minBlockSpacing = minBlockSpacingIn; + } + + bool SetCollateralAddress(std::string strAddress); + void Reset(); + void SetNull(bool clearEverything=false); + + void UnlockCoins(); + + bool IsNull() const + { + return (state == POOL_STATUS_ACCEPTING_ENTRIES && entries.empty() && myEntries.empty()); + } + + int GetState() const + { + return state; + } + + int GetEntriesCount() const + { + if(fMasterNode){ + return entries.size(); + } else { + return entriesCount; + } + } + + int GetLastEntryAccepted() const + { + return lastEntryAccepted; + } + + int GetCountEntriesAccepted() const + { + return countEntriesAccepted; + } + + int GetMyTransactionCount() const + { + return myEntries.size(); + } + + void UpdateState(unsigned int newState) + { + if (fMasterNode && (newState == POOL_STATUS_ERROR || newState == POOL_STATUS_SUCCESS)){ + LogPrintf("CDarkSendPool::UpdateState() - Can't set state to ERROR or SUCCESS as a masternode. \n"); + return; + } + + LogPrintf("CDarkSendPool::UpdateState() == %d | %d \n", state, newState); + if(state != newState){ + lastTimeChanged = GetTimeMillis(); + if(fMasterNode) { + RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); + } + } + state = newState; + } + + int GetMaxPoolTransactions() + { + + //use the production amount + return POOL_MAX_TRANSACTIONS; + } + + //Do we have enough users to take entries? + bool IsSessionReady(){ + return sessionUsers >= GetMaxPoolTransactions(); + } + + // Are these outputs compatible with other client in the pool? + bool IsCompatibleWithEntries(std::vector vout); + // Is this amount compatible with other client in the pool? + bool IsCompatibleWithSession(int64_t nAmount, CTransaction txCollateral, std::string& strReason); + + // Passively run darksend in the background according to the configuration in settings (only for QT) + bool DoAutomaticDenominating(bool fDryRun=false, bool ready=false); + bool PrepareluxsendDenominate(); + + + // check for process in darksend + void Check(); + // charge fees to bad actors + void ChargeFees(); + // rarely charge fees to pay miners + void ChargeRandomFees(); + void CheckTimeout(); + // check to make sure a signature matches an input in the pool + bool SignatureValid(const CScript& newSig, const CTxIn& newVin); + // if the collateral is valid given by a client + bool IsCollateralValid(const CTransaction& txCollateral); + // add a clients entry to the pool + bool AddEntry(const std::vector& newInput, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& newOutput, std::string& error); + // add signature to a vin + bool AddScriptSig(const CTxIn newVin); + // are all inputs signed? + bool SignaturesComplete(); + // as a client, send a transaction to a masternode to start the denomination process + void SendluxsendDenominate(std::vector& vin, std::vector& vout, int64_t amount); + // get masternode updates about the progress of darksend + bool StatusUpdate(int newState, int newEntriesCount, int newAccepted, std::string& error, int newSessionID=0); + + // as a client, check and sign the final transaction + bool SignFinalTransaction(CTransaction& finalTransactionNew, CNode* node); + + // get the last valid block hash for a given modulus + bool GetLastValidBlockHash(uint256& hash, int mod=1, int nBlockHeight=0); + // process a new block + void NewBlock(); + void CompletedTransaction(bool error, std::string lastMessageNew); + void ClearLastMessage(); + // used for liquidity providers + bool SendRandomPaymentToSelf(); + // split up large inputs or make fee sized inputs + bool MakeCollateralAmounts(); + bool CreateDenominated(int64_t nTotalValue); + // get the denominations for a list of outputs (returns a bitshifted integer) + int GetDenominations(const std::vector& vout); + void GetDenominationsToString(int nDenom, std::string& strDenom); + // get the denominations for a specific amount of SONO. + int GetDenominationsByAmount(int64_t nAmount, int nDenomTarget=0); + + int GetDenominationsByAmounts(std::vector& vecAmount); +}; + + +void ConnectToDarkSendMasterNodeWinner(); + +void ThreadCheckDarkSendPool(); + +#endif diff --git a/src/db.cpp b/src/db.cpp new file mode 100644 index 0000000..348288e --- /dev/null +++ b/src/db.cpp @@ -0,0 +1,478 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "db.h" + +#include "addrman.h" +#include "hash.h" +#include "util.h" + +#ifndef WIN32 +#include +#endif + +#include +#include +#include + +using namespace std; +using namespace boost; + + +unsigned int nWalletDBUpdated; + + + +// +// CDB +// + +CDBEnv bitdb; + +void CDBEnv::EnvShutdown() +{ + if (!fDbEnvInit) + return; + + fDbEnvInit = false; + int ret = dbenv.close(0); + if (ret != 0) + LogPrintf("EnvShutdown exception: %s (%d)\n", DbEnv::strerror(ret), ret); + if (!fMockDb) + DbEnv(0).remove(strPath.c_str(), 0); +} + +CDBEnv::CDBEnv() : dbenv(DB_CXX_NO_EXCEPTIONS) +{ + fDbEnvInit = false; + fMockDb = false; +} + +CDBEnv::~CDBEnv() +{ + EnvShutdown(); +} + +void CDBEnv::Close() +{ + EnvShutdown(); +} + +bool CDBEnv::Open(boost::filesystem::path pathEnv_) +{ + if (fDbEnvInit) + return true; + + boost::this_thread::interruption_point(); + + pathEnv = pathEnv_; + filesystem::path pathDataDir = pathEnv; + strPath = pathDataDir.string(); + filesystem::path pathLogDir = pathDataDir / "database"; + filesystem::create_directory(pathLogDir); + filesystem::path pathErrorFile = pathDataDir / "db.log"; + LogPrintf("dbenv.open LogDir=%s ErrorFile=%s\n", pathLogDir.string(), pathErrorFile.string()); + + unsigned int nEnvFlags = 0; + if (GetBoolArg("-privdb", true)) + nEnvFlags |= DB_PRIVATE; + + int nDbCache = GetArg("-dbcache", 25); + dbenv.set_lg_dir(pathLogDir.string().c_str()); + dbenv.set_cachesize(nDbCache / 1024, (nDbCache % 1024)*1048576, 1); + dbenv.set_lg_bsize(1048576); + dbenv.set_lg_max(10485760); + + // Bugfix: Bump lk_max_locks default to 537000, to safely handle reorgs with up to 5 blocks reversed + // dbenv.set_lk_max_locks(10000); + dbenv.set_lk_max_locks(537000); + + dbenv.set_lk_max_objects(10000); + dbenv.set_errfile(fopen(pathErrorFile.string().c_str(), "a")); /// debug + dbenv.set_flags(DB_AUTO_COMMIT, 1); + dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1); +#ifdef DB_LOG_AUTO_REMOVE + dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1); +#endif + int ret = dbenv.open(strPath.c_str(), + DB_CREATE | + DB_INIT_LOCK | + DB_INIT_LOG | + DB_INIT_MPOOL | + DB_INIT_TXN | + DB_THREAD | + DB_RECOVER | + nEnvFlags, + S_IRUSR | S_IWUSR); + if (ret != 0) + return error("CDB() : error %s (%d) opening database environment", DbEnv::strerror(ret), ret); + + fDbEnvInit = true; + fMockDb = false; + + return true; +} + +void CDBEnv::MakeMock() +{ + if (fDbEnvInit) + throw runtime_error("CDBEnv::MakeMock(): already initialized"); + + boost::this_thread::interruption_point(); + + LogPrint("db", "CDBEnv::MakeMock()\n"); + + dbenv.set_cachesize(1, 0, 1); + dbenv.set_lg_bsize(10485760*4); + dbenv.set_lg_max(10485760); + dbenv.set_lk_max_locks(10000); + dbenv.set_lk_max_objects(10000); + dbenv.set_flags(DB_AUTO_COMMIT, 1); +#ifdef DB_LOG_IN_MEMORY + dbenv.log_set_config(DB_LOG_IN_MEMORY, 1); +#endif + int ret = dbenv.open(NULL, + DB_CREATE | + DB_INIT_LOCK | + DB_INIT_LOG | + DB_INIT_MPOOL | + DB_INIT_TXN | + DB_THREAD | + DB_PRIVATE, + S_IRUSR | S_IWUSR); + if (ret > 0) + throw runtime_error(strprintf("CDBEnv::MakeMock(): error %d opening database environment", ret)); + + fDbEnvInit = true; + fMockDb = true; +} + +CDBEnv::VerifyResult CDBEnv::Verify(std::string strFile, bool (*recoverFunc)(CDBEnv& dbenv, std::string strFile)) +{ + LOCK(cs_db); + assert(mapFileUseCount.count(strFile) == 0); + + Db db(&dbenv, 0); + int result = db.verify(strFile.c_str(), NULL, NULL, 0); + if (result == 0) + return VERIFY_OK; + else if (recoverFunc == NULL) + return RECOVER_FAIL; + + // Try to recover: + bool fRecovered = (*recoverFunc)(*this, strFile); + return (fRecovered ? RECOVER_OK : RECOVER_FAIL); +} + +bool CDBEnv::Salvage(std::string strFile, bool fAggressive, + std::vector& vResult) +{ + LOCK(cs_db); + assert(mapFileUseCount.count(strFile) == 0); + + u_int32_t flags = DB_SALVAGE; + if (fAggressive) flags |= DB_AGGRESSIVE; + + stringstream strDump; + + Db db(&dbenv, 0); + int result = db.verify(strFile.c_str(), NULL, &strDump, flags); + if (result == DB_VERIFY_BAD) + { + LogPrintf("Error: Salvage found errors, all data may not be recoverable.\n"); + if (!fAggressive) + { + LogPrintf("Error: Rerun with aggressive mode to ignore errors and continue.\n"); + return false; + } + } + if (result != 0 && result != DB_VERIFY_BAD) + { + LogPrintf("ERROR: db salvage failed: %d\n",result); + return false; + } + + // Format of bdb dump is ascii lines: + // header lines... + // HEADER=END + // hexadecimal key + // hexadecimal value + // ... repeated + // DATA=END + + string strLine; + while (!strDump.eof() && strLine != "HEADER=END") + getline(strDump, strLine); // Skip past header + + std::string keyHex, valueHex; + while (!strDump.eof() && keyHex != "DATA=END") + { + getline(strDump, keyHex); + if (keyHex != "DATA_END") + { + getline(strDump, valueHex); + vResult.push_back(make_pair(ParseHex(keyHex),ParseHex(valueHex))); + } + } + + return (result == 0); +} + + +void CDBEnv::CheckpointLSN(const std::string& strFile) +{ + dbenv.txn_checkpoint(0, 0, 0); + if (fMockDb) + return; + dbenv.lsn_reset(strFile.c_str(), 0); +} + + +CDB::CDB(const std::string& strFilename, const char* pszMode) : + pdb(NULL), activeTxn(NULL) +{ + int ret; + fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w')); + if (strFilename.empty()) + return; + + bool fCreate = strchr(pszMode, 'c'); + unsigned int nFlags = DB_THREAD; + if (fCreate) + nFlags |= DB_CREATE; + + { + LOCK(bitdb.cs_db); + if (!bitdb.Open(GetDataDir())) + throw runtime_error("env open failed"); + + strFile = strFilename; + ++bitdb.mapFileUseCount[strFile]; + pdb = bitdb.mapDb[strFile]; + if (pdb == NULL) + { + pdb = new Db(&bitdb.dbenv, 0); + + bool fMockDb = bitdb.IsMock(); + if (fMockDb) + { + DbMpoolFile*mpf = pdb->get_mpf(); + ret = mpf->set_flags(DB_MPOOL_NOFILE, 1); + if (ret != 0) + throw runtime_error(strprintf("CDB : Failed to configure for no temp file backing for database %s", strFile)); + } + + ret = pdb->open(NULL, // Txn pointer + fMockDb ? NULL : strFile.c_str(), // Filename + fMockDb ? strFile.c_str() : "main", // Logical db name + DB_BTREE, // Database type + nFlags, // Flags + 0); + + if (ret != 0) + { + delete pdb; + pdb = NULL; + --bitdb.mapFileUseCount[strFile]; + strFile = ""; + throw runtime_error(strprintf("CDB : Error %d, can't open database %s", ret, strFile)); + } + + if (fCreate && !Exists(string("version"))) + { + bool fTmp = fReadOnly; + fReadOnly = false; + WriteVersion(CLIENT_VERSION); + fReadOnly = fTmp; + } + + bitdb.mapDb[strFile] = pdb; + } + } +} + +void CDB::Close() +{ + if (!pdb) + return; + if (activeTxn) + activeTxn->abort(); + activeTxn = NULL; + pdb = NULL; + + // Flush database activity from memory pool to disk log + unsigned int nMinutes = 0; + if (fReadOnly) + nMinutes = 1; + + bitdb.dbenv.txn_checkpoint(nMinutes ? GetArg("-dblogsize", 100)*1024 : 0, nMinutes, 0); + + { + LOCK(bitdb.cs_db); + --bitdb.mapFileUseCount[strFile]; + } +} + +void CDBEnv::CloseDb(const string& strFile) +{ + { + LOCK(cs_db); + if (mapDb[strFile] != NULL) + { + // Close the database handle + Db* pdb = mapDb[strFile]; + pdb->close(0); + delete pdb; + mapDb[strFile] = NULL; + } + } +} + +bool CDBEnv::RemoveDb(const string& strFile) +{ + this->CloseDb(strFile); + + LOCK(cs_db); + int rc = dbenv.dbremove(NULL, strFile.c_str(), NULL, DB_AUTO_COMMIT); + return (rc == 0); +} + +bool CDB::Rewrite(const string& strFile, const char* pszSkip) +{ + while (true) + { + { + LOCK(bitdb.cs_db); + if (!bitdb.mapFileUseCount.count(strFile) || bitdb.mapFileUseCount[strFile] == 0) + { + // Flush log data to the dat file + bitdb.CloseDb(strFile); + bitdb.CheckpointLSN(strFile); + bitdb.mapFileUseCount.erase(strFile); + + bool fSuccess = true; + LogPrintf("Rewriting %s...\n", strFile); + string strFileRes = strFile + ".rewrite"; + { // surround usage of db with extra {} + CDB db(strFile.c_str(), "r"); + Db* pdbCopy = new Db(&bitdb.dbenv, 0); + + int ret = pdbCopy->open(NULL, // Txn pointer + strFileRes.c_str(), // Filename + "main", // Logical db name + DB_BTREE, // Database type + DB_CREATE, // Flags + 0); + if (ret > 0) + { + LogPrintf("Cannot create database file %s\n", strFileRes); + fSuccess = false; + } + + Dbc* pcursor = db.GetCursor(); + if (pcursor) + while (fSuccess) + { + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + CDataStream ssValue(SER_DISK, CLIENT_VERSION); + int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT); + if (ret == DB_NOTFOUND) + { + pcursor->close(); + break; + } + else if (ret != 0) + { + pcursor->close(); + fSuccess = false; + break; + } + if (pszSkip && + strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0) + continue; + if (strncmp(&ssKey[0], "\x07version", 8) == 0) + { + // Update version: + ssValue.clear(); + ssValue << CLIENT_VERSION; + } + Dbt datKey(&ssKey[0], ssKey.size()); + Dbt datValue(&ssValue[0], ssValue.size()); + int ret2 = pdbCopy->put(NULL, &datKey, &datValue, DB_NOOVERWRITE); + if (ret2 > 0) + fSuccess = false; + } + if (fSuccess) + { + db.Close(); + bitdb.CloseDb(strFile); + if (pdbCopy->close(0)) + fSuccess = false; + delete pdbCopy; + } + } + if (fSuccess) + { + Db dbA(&bitdb.dbenv, 0); + if (dbA.remove(strFile.c_str(), NULL, 0)) + fSuccess = false; + Db dbB(&bitdb.dbenv, 0); + if (dbB.rename(strFileRes.c_str(), NULL, strFile.c_str(), 0)) + fSuccess = false; + } + if (!fSuccess) + LogPrintf("Rewriting of %s FAILED!\n", strFileRes); + return fSuccess; + } + } + MilliSleep(100); + } + return false; +} + + +void CDBEnv::Flush(bool fShutdown) +{ + int64_t nStart = GetTimeMillis(); + // Flush log data to the actual data file + // on all files that are not in use + LogPrint("db", "Flush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started"); + if (!fDbEnvInit) + return; + { + LOCK(cs_db); + map::iterator mi = mapFileUseCount.begin(); + while (mi != mapFileUseCount.end()) + { + string strFile = (*mi).first; + int nRefCount = (*mi).second; + LogPrint("db", "%s refcount=%d\n", strFile, nRefCount); + if (nRefCount == 0) + { + // Move log data to the dat file + CloseDb(strFile); + LogPrint("db", "%s checkpoint\n", strFile); + dbenv.txn_checkpoint(0, 0, 0); + LogPrint("db", "%s detach\n", strFile); + if (!fMockDb) + dbenv.lsn_reset(strFile.c_str(), 0); + LogPrint("db", "%s closed\n", strFile); + mapFileUseCount.erase(mi++); + } + else + mi++; + } + LogPrint("db", "DBFlush(%s)%s ended %15dms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart); + if (fShutdown) + { + char** listp; + if (mapFileUseCount.empty()) + { + dbenv.log_archive(&listp, DB_ARCH_REMOVE); + Close(); + } + } + } +} diff --git a/src/db.h b/src/db.h new file mode 100644 index 0000000..fd53707 --- /dev/null +++ b/src/db.h @@ -0,0 +1,312 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_DB_H +#define BITCOIN_DB_H + +#include "serialize.h" +#include "sync.h" +#include "version.h" + +#include +#include +#include + +#include +#include + +class CAddrMan; +class CBlockLocator; +class CDiskBlockIndex; +class CDiskTxPos; +class COutPoint; +class CTxIndex; + +extern unsigned int nWalletDBUpdated; + +void ThreadFlushWalletDB(const std::string& strWalletFile); + + +class CDBEnv +{ +private: + bool fDbEnvInit; + bool fMockDb; + boost::filesystem::path pathEnv; + std::string strPath; + + void EnvShutdown(); + +public: + mutable CCriticalSection cs_db; + DbEnv dbenv; + std::map mapFileUseCount; + std::map mapDb; + + CDBEnv(); + ~CDBEnv(); + void MakeMock(); + bool IsMock() { return fMockDb; }; + + /* + * Verify that database file strFile is OK. If it is not, + * call the callback to try to recover. + * This must be called BEFORE strFile is opened. + * Returns true if strFile is OK. + */ + enum VerifyResult { VERIFY_OK, RECOVER_OK, RECOVER_FAIL }; + VerifyResult Verify(std::string strFile, bool (*recoverFunc)(CDBEnv& dbenv, std::string strFile)); + /* + * Salvage data from a file that Verify says is bad. + * fAggressive sets the DB_AGGRESSIVE flag (see berkeley DB->verify() method documentation). + * Appends binary key/value pairs to vResult, returns true if successful. + * NOTE: reads the entire database into memory, so cannot be used + * for huge databases. + */ + typedef std::pair, std::vector > KeyValPair; + bool Salvage(std::string strFile, bool fAggressive, std::vector& vResult); + + bool Open(boost::filesystem::path pathEnv_); + void Close(); + void Flush(bool fShutdown); + void CheckpointLSN(const std::string& strFile); + + void CloseDb(const std::string& strFile); + bool RemoveDb(const std::string& strFile); + + DbTxn *TxnBegin(int flags=DB_TXN_WRITE_NOSYNC) + { + DbTxn* ptxn = NULL; + int ret = dbenv.txn_begin(NULL, &ptxn, flags); + if (!ptxn || ret != 0) + return NULL; + return ptxn; + } +}; + +extern CDBEnv bitdb; + + +/** RAII class that provides access to a Berkeley database */ +class CDB +{ +protected: + Db* pdb; + std::string strFile; + DbTxn *activeTxn; + bool fReadOnly; + + explicit CDB(const std::string& strFilename, const char* pszMode="r+"); + ~CDB() { Close(); } + +public: + void Close(); + +private: + CDB(const CDB&); + void operator=(const CDB&); + +protected: + template + bool Read(const K& key, T& value) + { + if (!pdb) + return false; + + // Key + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.reserve(1000); + ssKey << key; + Dbt datKey(&ssKey[0], ssKey.size()); + + // Read + Dbt datValue; + datValue.set_flags(DB_DBT_MALLOC); + int ret = pdb->get(activeTxn, &datKey, &datValue, 0); + memset(datKey.get_data(), 0, datKey.get_size()); + if (datValue.get_data() == NULL) + return false; + + // Unserialize value + try { + CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK, CLIENT_VERSION); + ssValue >> value; + } + catch (std::exception &e) { + return false; + } + + // Clear and free memory + memset(datValue.get_data(), 0, datValue.get_size()); + free(datValue.get_data()); + return (ret == 0); + } + + template + bool Write(const K& key, const T& value, bool fOverwrite=true) + { + if (!pdb) + return false; + if (fReadOnly) + assert(!"Write called on database in read-only mode"); + + // Key + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.reserve(1000); + ssKey << key; + Dbt datKey(&ssKey[0], ssKey.size()); + + // Value + CDataStream ssValue(SER_DISK, CLIENT_VERSION); + ssValue.reserve(10000); + ssValue << value; + Dbt datValue(&ssValue[0], ssValue.size()); + + // Write + int ret = pdb->put(activeTxn, &datKey, &datValue, (fOverwrite ? 0 : DB_NOOVERWRITE)); + + // Clear memory in case it was a private key + memset(datKey.get_data(), 0, datKey.get_size()); + memset(datValue.get_data(), 0, datValue.get_size()); + return (ret == 0); + } + + template + bool Erase(const K& key) + { + if (!pdb) + return false; + if (fReadOnly) + assert(!"Erase called on database in read-only mode"); + + // Key + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.reserve(1000); + ssKey << key; + Dbt datKey(&ssKey[0], ssKey.size()); + + // Erase + int ret = pdb->del(activeTxn, &datKey, 0); + + // Clear memory + memset(datKey.get_data(), 0, datKey.get_size()); + return (ret == 0 || ret == DB_NOTFOUND); + } + + template + bool Exists(const K& key) + { + if (!pdb) + return false; + + // Key + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.reserve(1000); + ssKey << key; + Dbt datKey(&ssKey[0], ssKey.size()); + + // Exists + int ret = pdb->exists(activeTxn, &datKey, 0); + + // Clear memory + memset(datKey.get_data(), 0, datKey.get_size()); + return (ret == 0); + } + + Dbc* GetCursor() + { + if (!pdb) + return NULL; + Dbc* pcursor = NULL; + int ret = pdb->cursor(NULL, &pcursor, 0); + if (ret != 0) + return NULL; + return pcursor; + } + + int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags=DB_NEXT) + { + // Read at cursor + Dbt datKey; + if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) + { + datKey.set_data(&ssKey[0]); + datKey.set_size(ssKey.size()); + } + Dbt datValue; + if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) + { + datValue.set_data(&ssValue[0]); + datValue.set_size(ssValue.size()); + } + datKey.set_flags(DB_DBT_MALLOC); + datValue.set_flags(DB_DBT_MALLOC); + int ret = pcursor->get(&datKey, &datValue, fFlags); + if (ret != 0) + return ret; + else if (datKey.get_data() == NULL || datValue.get_data() == NULL) + return 99999; + + // Convert to streams + ssKey.SetType(SER_DISK); + ssKey.clear(); + ssKey.write((char*)datKey.get_data(), datKey.get_size()); + ssValue.SetType(SER_DISK); + ssValue.clear(); + ssValue.write((char*)datValue.get_data(), datValue.get_size()); + + // Clear and free memory + memset(datKey.get_data(), 0, datKey.get_size()); + memset(datValue.get_data(), 0, datValue.get_size()); + free(datKey.get_data()); + free(datValue.get_data()); + return 0; + } + +public: + bool TxnBegin() + { + if (!pdb || activeTxn) + return false; + DbTxn* ptxn = bitdb.TxnBegin(); + if (!ptxn) + return false; + activeTxn = ptxn; + return true; + } + + bool TxnCommit() + { + if (!pdb || !activeTxn) + return false; + int ret = activeTxn->commit(0); + activeTxn = NULL; + return (ret == 0); + } + + bool TxnAbort() + { + if (!pdb || !activeTxn) + return false; + int ret = activeTxn->abort(); + activeTxn = NULL; + return (ret == 0); + } + + bool ReadVersion(int& nVersion) + { + nVersion = 0; + return Read(std::string("version"), nVersion); + } + + bool WriteVersion(int nVersion) + { + return Write(std::string("version"), nVersion); + } + + bool static Rewrite(const std::string& strFile, const char* pszSkip = NULL); +}; + +#endif // BITCOIN_DB_H diff --git a/src/eccryptoverify.cpp b/src/eccryptoverify.cpp new file mode 100644 index 0000000..a22bf41 --- /dev/null +++ b/src/eccryptoverify.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2015 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "eccryptoverify.h" + +namespace { + +int CompareBigEndian(const unsigned char *c1, size_t c1len, const unsigned char *c2, size_t c2len) { + while (c1len > c2len) { + if (*c1) + return 1; + c1++; + c1len--; + } + while (c2len > c1len) { + if (*c2) + return -1; + c2++; + c2len--; + } + while (c1len > 0) { + if (*c1 > *c2) + return 1; + if (*c2 > *c1) + return -1; + c1++; + c2++; + c1len--; + } + return 0; +} + +/** Order of secp256k1's generator minus 1. */ +const unsigned char vchMaxModOrder[32] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B, + 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x40 +}; + +/** Half of the order of secp256k1's generator minus 1. */ +const unsigned char vchMaxModHalfOrder[32] = { + 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x5D,0x57,0x6E,0x73,0x57,0xA4,0x50,0x1D, + 0xDF,0xE9,0x2F,0x46,0x68,0x1B,0x20,0xA0 +}; + +const unsigned char vchZero[1] = {0}; +} // anon namespace + +namespace eccrypto { + +bool Check(const unsigned char *vch) { + return vch && + CompareBigEndian(vch, 32, vchZero, 0) > 0 && + CompareBigEndian(vch, 32, vchMaxModOrder, 32) <= 0; +} + +bool CheckSignatureElement(const unsigned char *vch, int len, bool half) { + return vch && + CompareBigEndian(vch, len, vchZero, 0) > 0 && + CompareBigEndian(vch, len, half ? vchMaxModHalfOrder : vchMaxModOrder, 32) <= 0; +} + +} // namespace eccrypto diff --git a/src/eccryptoverify.h b/src/eccryptoverify.h new file mode 100644 index 0000000..cb16e37 --- /dev/null +++ b/src/eccryptoverify.h @@ -0,0 +1,21 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2015 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_ECCRYPTOVERIFY_H +#define BITCOIN_ECCRYPTOVERIFY_H + +#include +#include + +class uint256; + +namespace eccrypto { + +bool Check(const unsigned char *vch); +bool CheckSignatureElement(const unsigned char *vch, int len, bool half); + +} // eccrypto namespace + +#endif // BITCOIN_ECCRYPTOVERIFY_H diff --git a/src/eckey.cpp b/src/eckey.cpp new file mode 100644 index 0000000..ff87ed1 --- /dev/null +++ b/src/eckey.cpp @@ -0,0 +1,318 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Copyright (c) 2014-2015 The ShadowCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. + +#include "eckey.h" + +// anonymous namespace with local implementation code (OpenSSL interaction) +namespace { + +// Generate a private key from just the secret parameter +int EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key) +{ + int ok = 0; + BN_CTX *ctx = NULL; + EC_POINT *pub_key = NULL; + + if (!eckey) return 0; + + const EC_GROUP *group = EC_KEY_get0_group(eckey); + + if ((ctx = BN_CTX_new()) == NULL) + goto err; + + pub_key = EC_POINT_new(group); + + if (pub_key == NULL) + goto err; + + if (!EC_POINT_mul(group, pub_key, priv_key, NULL, NULL, ctx)) + goto err; + + EC_KEY_set_private_key(eckey,priv_key); + EC_KEY_set_public_key(eckey,pub_key); + + ok = 1; + +err: + + if (pub_key) + EC_POINT_free(pub_key); + if (ctx != NULL) + BN_CTX_free(ctx); + + return(ok); +} + +// Perform ECDSA key recovery (see SEC1 4.1.6) for curves over (mod p)-fields +// recid selects which key is recovered +// if check is non-zero, additional checks are performed +int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned char *msg, int msglen, int recid, int check) +{ + if (!eckey) return 0; + + int ret = 0; + BN_CTX *ctx = NULL; + + BIGNUM *x = NULL; + BIGNUM *e = NULL; + BIGNUM *order = NULL; + BIGNUM *sor = NULL; + BIGNUM *eor = NULL; + BIGNUM *field = NULL; + EC_POINT *R = NULL; + EC_POINT *O = NULL; + EC_POINT *Q = NULL; + BIGNUM *rr = NULL; + BIGNUM *zero = NULL; + int n = 0; + int i = recid / 2; + + const EC_GROUP *group = EC_KEY_get0_group(eckey); + if ((ctx = BN_CTX_new()) == NULL) { ret = -1; goto err; } + BN_CTX_start(ctx); + order = BN_CTX_get(ctx); + if (!EC_GROUP_get_order(group, order, ctx)) { ret = -2; goto err; } + x = BN_CTX_get(ctx); + if (!BN_copy(x, order)) { ret=-1; goto err; } + if (!BN_mul_word(x, i)) { ret=-1; goto err; } + if (!BN_add(x, x, ecsig->r)) { ret=-1; goto err; } + field = BN_CTX_get(ctx); + if (!EC_GROUP_get_curve_GFp(group, field, NULL, NULL, ctx)) { ret=-2; goto err; } + if (BN_cmp(x, field) >= 0) { ret=0; goto err; } + if ((R = EC_POINT_new(group)) == NULL) { ret = -2; goto err; } + if (!EC_POINT_set_compressed_coordinates_GFp(group, R, x, recid % 2, ctx)) { ret=0; goto err; } + if (check) + { + if ((O = EC_POINT_new(group)) == NULL) { ret = -2; goto err; } + if (!EC_POINT_mul(group, O, NULL, R, order, ctx)) { ret=-2; goto err; } + if (!EC_POINT_is_at_infinity(group, O)) { ret = 0; goto err; } + } + if ((Q = EC_POINT_new(group)) == NULL) { ret = -2; goto err; } + n = EC_GROUP_get_degree(group); + e = BN_CTX_get(ctx); + if (!BN_bin2bn(msg, msglen, e)) { ret=-1; goto err; } + if (8*msglen > n) BN_rshift(e, e, 8-(n & 7)); + zero = BN_CTX_get(ctx); + if (!BN_zero(zero)) { ret=-1; goto err; } + if (!BN_mod_sub(e, zero, e, order, ctx)) { ret=-1; goto err; } + rr = BN_CTX_get(ctx); + if (!BN_mod_inverse(rr, ecsig->r, order, ctx)) { ret=-1; goto err; } + sor = BN_CTX_get(ctx); + if (!BN_mod_mul(sor, ecsig->s, rr, order, ctx)) { ret=-1; goto err; } + eor = BN_CTX_get(ctx); + if (!BN_mod_mul(eor, e, rr, order, ctx)) { ret=-1; goto err; } + if (!EC_POINT_mul(group, Q, eor, R, sor, ctx)) { ret=-2; goto err; } + if (!EC_KEY_set_public_key(eckey, Q)) { ret=-2; goto err; } + + ret = 1; + +err: + if (ctx) { + BN_CTX_end(ctx); + BN_CTX_free(ctx); + } + if (R != NULL) EC_POINT_free(R); + if (O != NULL) EC_POINT_free(O); + if (Q != NULL) EC_POINT_free(Q); + return ret; +} + +}; // end of anonymous namespace + +void CECKey::GetSecretBytes(unsigned char vch[32]) const +{ + const BIGNUM *bn = EC_KEY_get0_private_key(pkey); + assert(bn); + int nBytes = BN_num_bytes(bn); + int n=BN_bn2bin(bn,&vch[32 - nBytes]); + assert(n == nBytes); + memset(vch, 0, 32 - nBytes); +} + +void CECKey::SetSecretBytes(const unsigned char vch[32]) +{ + BIGNUM bn; + BN_init(&bn); + assert(BN_bin2bn(vch, 32, &bn)); + assert(EC_KEY_regenerate_key(pkey, &bn)); + BN_clear_free(&bn); +} + +void CECKey::GetPrivKey(CPrivKey &privkey, bool fCompressed) { + EC_KEY_set_conv_form(pkey, fCompressed ? POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED); + int nSize = i2d_ECPrivateKey(pkey, NULL); + assert(nSize); + privkey.resize(nSize); + unsigned char* pbegin = &privkey[0]; + int nSize2 = i2d_ECPrivateKey(pkey, &pbegin); + assert(nSize == nSize2); +} + +bool CECKey::SetPrivKey(const CPrivKey &privkey, bool fSkipCheck) { + const unsigned char* pbegin = &privkey[0]; + if (d2i_ECPrivateKey(&pkey, &pbegin, privkey.size())) { + if(fSkipCheck) + return true; + + // d2i_ECPrivateKey returns true if parsing succeeds. + // This doesn't necessarily mean the key is valid. + if (EC_KEY_check_key(pkey)) + return true; + } + return false; +} + +void CECKey::GetPubKey(CPubKey &pubkey, bool fCompressed) { + EC_KEY_set_conv_form(pkey, fCompressed ? POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED); + int nSize = i2o_ECPublicKey(pkey, NULL); + assert(nSize); + assert(nSize <= 65); + unsigned char c[65]; + unsigned char *pbegin = c; + int nSize2 = i2o_ECPublicKey(pkey, &pbegin); + assert(nSize == nSize2); + pubkey.Set(&c[0], &c[nSize]); +} + +bool CECKey::SetPubKey(const CPubKey &pubkey) { + const unsigned char* pbegin = pubkey.begin(); + return o2i_ECPublicKey(&pkey, &pbegin, pubkey.size()); +} + +bool CECKey::Sign(const uint256 &hash, std::vector& vchSig) { + vchSig.clear(); + ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey); + if (sig == NULL) + return false; + BN_CTX *ctx = BN_CTX_new(); + BN_CTX_start(ctx); + const EC_GROUP *group = EC_KEY_get0_group(pkey); + BIGNUM *order = BN_CTX_get(ctx); + BIGNUM *halforder = BN_CTX_get(ctx); + EC_GROUP_get_order(group, order, ctx); + BN_rshift1(halforder, order); + if (BN_cmp(sig->s, halforder) > 0) { + // enforce low S values, by negating the value (modulo the order) if above order/2. + BN_sub(sig->s, order, sig->s); + } + BN_CTX_end(ctx); + BN_CTX_free(ctx); + unsigned int nSize = ECDSA_size(pkey); + vchSig.resize(nSize); // Make sure it is big enough + unsigned char *pos = &vchSig[0]; + nSize = i2d_ECDSA_SIG(sig, &pos); + ECDSA_SIG_free(sig); + vchSig.resize(nSize); // Shrink to fit actual size + return true; +} + +bool CECKey::Verify(const uint256 &hash, const std::vector& vchSig) { + // -1 = error, 0 = bad sig, 1 = good + if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1) + return false; + return true; +} + +bool CECKey::SignCompact(const uint256 &hash, unsigned char *p64, int &rec) { + bool fOk = false; + ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey); + if (sig==NULL) + return false; + memset(p64, 0, 64); + int nBitsR = BN_num_bits(sig->r); + int nBitsS = BN_num_bits(sig->s); + if (nBitsR <= 256 && nBitsS <= 256) { + CPubKey pubkey; + GetPubKey(pubkey, true); + for (int i=0; i<4; i++) { + CECKey keyRec; + if (ECDSA_SIG_recover_key_GFp(keyRec.pkey, sig, (unsigned char*)&hash, sizeof(hash), i, 1) == 1) { + CPubKey pubkeyRec; + keyRec.GetPubKey(pubkeyRec, true); + if (pubkeyRec == pubkey) { + rec = i; + fOk = true; + break; + } + } + } + assert(fOk); + BN_bn2bin(sig->r,&p64[32-(nBitsR+7)/8]); + BN_bn2bin(sig->s,&p64[64-(nBitsS+7)/8]); + } + ECDSA_SIG_free(sig); + return fOk; +} + +// reconstruct public key from a compact signature +// This is only slightly more CPU intensive than just verifying it. +// If this function succeeds, the recovered public key is guaranteed to be valid +// (the signature is a valid signature of the given data for that key) +bool CECKey::Recover(const uint256 &hash, const unsigned char *p64, int rec) +{ + if (rec<0 || rec>=3) + return false; + ECDSA_SIG *sig = ECDSA_SIG_new(); + BN_bin2bn(&p64[0], 32, sig->r); + BN_bin2bn(&p64[32], 32, sig->s); + bool ret = ECDSA_SIG_recover_key_GFp(pkey, sig, (unsigned char*)&hash, sizeof(hash), rec, 0) == 1; + ECDSA_SIG_free(sig); + return ret; +} + +bool CECKey::TweakPublic(const unsigned char vchTweak[32]) +{ + bool ret = true; + BN_CTX *ctx = BN_CTX_new(); + BN_CTX_start(ctx); + BIGNUM *bnTweak = BN_CTX_get(ctx); + BIGNUM *bnOrder = BN_CTX_get(ctx); + BIGNUM *bnOne = BN_CTX_get(ctx); + const EC_GROUP *group = EC_KEY_get0_group(pkey); + EC_GROUP_get_order(group, bnOrder, ctx); // what a grossly inefficient way to get the (constant) group order... + BN_bin2bn(vchTweak, 32, bnTweak); + if (BN_cmp(bnTweak, bnOrder) >= 0) + ret = false; // extremely unlikely + EC_POINT *point = EC_POINT_dup(EC_KEY_get0_public_key(pkey), group); + BN_one(bnOne); + EC_POINT_mul(group, point, bnTweak, point, bnOne, ctx); + if (EC_POINT_is_at_infinity(group, point)) + ret = false; // ridiculously unlikely + EC_KEY_set_public_key(pkey, point); + EC_POINT_free(point); + BN_CTX_end(ctx); + BN_CTX_free(ctx); + return ret; +} + +bool TweakSecret(unsigned char vchSecretOut[32], const unsigned char vchSecretIn[32], const unsigned char vchTweak[32]) +{ + bool ret = true; + BN_CTX *ctx = BN_CTX_new(); + BN_CTX_start(ctx); + BIGNUM *bnSecret = BN_CTX_get(ctx); + BIGNUM *bnTweak = BN_CTX_get(ctx); + BIGNUM *bnOrder = BN_CTX_get(ctx); + EC_GROUP *group = EC_GROUP_new_by_curve_name(NID_secp256k1); + EC_GROUP_get_order(group, bnOrder, ctx); // what a grossly inefficient way to get the (constant) group order... + BN_bin2bn(vchTweak, 32, bnTweak); + if (BN_cmp(bnTweak, bnOrder) >= 0) + ret = false; // extremely unlikely + BN_bin2bn(vchSecretIn, 32, bnSecret); + BN_add(bnSecret, bnSecret, bnTweak); + BN_nnmod(bnSecret, bnSecret, bnOrder, ctx); + if (BN_is_zero(bnSecret)) + ret = false; // ridiculously unlikely + int nBits = BN_num_bits(bnSecret); + memset(vchSecretOut, 0, 32); + BN_bn2bin(bnSecret, &vchSecretOut[32-(nBits+7)/8]); + EC_GROUP_free(group); + BN_CTX_end(ctx); + BN_CTX_free(ctx); + return ret; +} + + diff --git a/src/eckey.h b/src/eckey.h new file mode 100644 index 0000000..555aaca --- /dev/null +++ b/src/eckey.h @@ -0,0 +1,67 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Copyright (c) 2014-2015 The ShadowCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. + +#ifndef CEC_KEY_H +#define CEC_KEY_H + +#include +#include +#include +#include + +#include "key.h" + +// RAII Wrapper around OpenSSL's EC_KEY +class CECKey { +private: + EC_KEY *pkey; + +public: + CECKey() { + pkey = EC_KEY_new_by_curve_name(NID_secp256k1); + assert(pkey != NULL); + } + + ~CECKey() { + EC_KEY_free(pkey); + } + + EC_KEY* GetECKey() {return pkey;}; + + void GetSecretBytes(unsigned char vch[32]) const; + + void SetSecretBytes(const unsigned char vch[32]); + + void GetPrivKey(CPrivKey &privkey, bool fCompressed); + + bool SetPrivKey(const CPrivKey &privkey, bool fSkipCheck=false); + + void GetPubKey(CPubKey &pubkey, bool fCompressed); + + bool SetPubKey(const CPubKey &pubkey); + + bool Sign(const uint256 &hash, std::vector& vchSig); + + bool Verify(const uint256 &hash, const std::vector& vchSig); + + bool SignCompact(const uint256 &hash, unsigned char *p64, int &rec); + + // reconstruct public key from a compact signature + // This is only slightly more CPU intensive than just verifying it. + // If this function succeeds, the recovered public key is guaranteed to be valid + // (the signature is a valid signature of the given data for that key) + bool Recover(const uint256 &hash, const unsigned char *p64, int rec); + + bool TweakPublic(const unsigned char vchTweak[32]); +}; + +bool TweakSecret(unsigned char vchSecretOut[32], const unsigned char vchSecretIn[32], const unsigned char vchTweak[32]); + + + +#endif + + diff --git a/src/hash.cpp b/src/hash.cpp new file mode 100644 index 0000000..c2634c1 --- /dev/null +++ b/src/hash.cpp @@ -0,0 +1,101 @@ +#include "hash.h" + +int HMAC_SHA512_Init(HMAC_SHA512_CTX *pctx, const void *pkey, size_t len) +{ + unsigned char key[128]; + if (len <= 128) + { + memcpy(key, pkey, len); + memset(key + len, 0, 128-len); + } + else + { + SHA512_CTX ctxKey; + SHA512_Init(&ctxKey); + SHA512_Update(&ctxKey, pkey, len); + SHA512_Final(key, &ctxKey); + memset(key + 64, 0, 64); + } + + for (int n=0; n<128; n++) + key[n] ^= 0x5c; + SHA512_Init(&pctx->ctxOuter); + SHA512_Update(&pctx->ctxOuter, key, 128); + + for (int n=0; n<128; n++) + key[n] ^= 0x5c ^ 0x36; + SHA512_Init(&pctx->ctxInner); + return SHA512_Update(&pctx->ctxInner, key, 128); +} + +int HMAC_SHA512_Update(HMAC_SHA512_CTX *pctx, const void *pdata, size_t len) +{ + return SHA512_Update(&pctx->ctxInner, pdata, len); +} + +int HMAC_SHA512_Final(unsigned char *pmd, HMAC_SHA512_CTX *pctx) +{ + unsigned char buf[64]; + SHA512_Final(buf, &pctx->ctxInner); + SHA512_Update(&pctx->ctxOuter, buf, 64); + return SHA512_Final(pmd, &pctx->ctxOuter); +} + +////////////////// + +inline uint32_t ROTL32 ( uint32_t x, int8_t r ) +{ + return (x << r) | (x >> (32 - r)); +} + +unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector& vDataToHash) +{ + // The following is MurmurHash3 (x86_32), see http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp + uint32_t h1 = nHashSeed; + const uint32_t c1 = 0xcc9e2d51; + const uint32_t c2 = 0x1b873593; + + const int nblocks = vDataToHash.size() / 4; + + //---------- + // body + const uint32_t * blocks = (const uint32_t *)(&vDataToHash[0] + nblocks*4); + + for(int i = -nblocks; i; i++) + { + uint32_t k1 = blocks[i]; + + k1 *= c1; + k1 = ROTL32(k1,15); + k1 *= c2; + + h1 ^= k1; + h1 = ROTL32(h1,13); + h1 = h1*5+0xe6546b64; + } + + //---------- + // tail + const uint8_t * tail = (const uint8_t*)(&vDataToHash[0] + nblocks*4); + + uint32_t k1 = 0; + + switch(vDataToHash.size() & 3) + { + case 3: k1 ^= tail[2] << 16; + case 2: k1 ^= tail[1] << 8; + case 1: k1 ^= tail[0]; + k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; + }; + + //---------- + // finalization + h1 ^= vDataToHash.size(); + h1 ^= h1 >> 16; + h1 *= 0x85ebca6b; + h1 ^= h1 >> 13; + h1 *= 0xc2b2ae35; + h1 ^= h1 >> 16; + + return h1; +} diff --git a/src/hash.h b/src/hash.h new file mode 100644 index 0000000..a877b78 --- /dev/null +++ b/src/hash.h @@ -0,0 +1,135 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_HASH_H +#define BITCOIN_HASH_H + +#include "uint256.h" +#include "serialize.h" + +#include +#include + +template +inline uint256 Hash(const T1 pbegin, const T1 pend) +{ + static unsigned char pblank[1]; + uint256 hash1; + SHA256((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1); + uint256 hash2; + SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); + return hash2; +} + +class CHashWriter +{ +private: + SHA256_CTX ctx; + +public: + int nType; + int nVersion; + + void Init() { + SHA256_Init(&ctx); + } + + CHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) { + Init(); + } + + CHashWriter& write(const char *pch, size_t size) { + SHA256_Update(&ctx, pch, size); + return (*this); + } + + // invalidates the object + uint256 GetHash() { + uint256 hash1; + SHA256_Final((unsigned char*)&hash1, &ctx); + uint256 hash2; + SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); + return hash2; + } + + template + CHashWriter& operator<<(const T& obj) { + // Serialize to this stream + ::Serialize(*this, obj, nType, nVersion); + return (*this); + } +}; + + +template +inline uint256 Hash(const T1 p1begin, const T1 p1end, + const T2 p2begin, const T2 p2end) +{ + static unsigned char pblank[1]; + uint256 hash1; + SHA256_CTX ctx; + SHA256_Init(&ctx); + SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0])); + SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0])); + SHA256_Final((unsigned char*)&hash1, &ctx); + uint256 hash2; + SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); + return hash2; +} + +template +inline uint256 Hash(const T1 p1begin, const T1 p1end, + const T2 p2begin, const T2 p2end, + const T3 p3begin, const T3 p3end) +{ + static unsigned char pblank[1]; + uint256 hash1; + SHA256_CTX ctx; + SHA256_Init(&ctx); + SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0])); + SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0])); + SHA256_Update(&ctx, (p3begin == p3end ? pblank : (unsigned char*)&p3begin[0]), (p3end - p3begin) * sizeof(p3begin[0])); + SHA256_Final((unsigned char*)&hash1, &ctx); + uint256 hash2; + SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); + return hash2; +} + +template +uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION) +{ + CHashWriter ss(nType, nVersion); + ss << obj; + return ss.GetHash(); +} + +template +inline uint160 Hash160(const T1 pbegin, const T1 pend) +{ + static unsigned char pblank[1]; + uint256 hash1; + SHA256((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1); + uint160 hash2; + RIPEMD160((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); + return hash2; +} + +inline uint160 Hash160(const std::vector& vch) +{ + return Hash160(vch.begin(), vch.end()); +} + +typedef struct +{ + SHA512_CTX ctxInner; + SHA512_CTX ctxOuter; +} HMAC_SHA512_CTX; + +int HMAC_SHA512_Init(HMAC_SHA512_CTX *pctx, const void *pkey, size_t len); +int HMAC_SHA512_Update(HMAC_SHA512_CTX *pctx, const void *pdata, size_t len); +int HMAC_SHA512_Final(unsigned char *pmd, HMAC_SHA512_CTX *pctx); + +unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector& vDataToHash); + +#endif diff --git a/src/hashblock.h b/src/hashblock.h new file mode 100644 index 0000000..46d09a0 --- /dev/null +++ b/src/hashblock.h @@ -0,0 +1,74 @@ +#ifndef HASHBLOCK_H +#define HASHBLOCK_H + +#include "uint256.h" +#include "obj/skunkhash/sph_skein.h" +#include "obj/skunkhash/sph_cubehash.h" +#include "obj/skunkhash/sph_fugue.h" +#include "obj/skunkhash/sph_gost.h" +#include "obj/skunkhash/raptor.h" + + +#ifndef QT_NO_DEBUG +#include +#endif + +#ifdef GLOBALDEFINED +#define GLOBAL +#else +#define GLOBAL extern +#endif + +GLOBAL sph_skein512_context z_skein; +GLOBAL sph_cubehash512_context z_cubehash; +GLOBAL sph_fugue512_context z_fugue; +GLOBAL sph_gost512_context z_gost; + +#define fillz() do { \ + sph_skein512_init(&z_skein); \ + sph_cubehash512_init(&z_cubehash); \ + sph_fugue512_init(&z_fugue); \ + sph_gost512_init(&z_gost); \ +} while (0) + +#define ZSKEIN (memcpy(&ctx_skein, &z_skein, sizeof(z_skein))) +#define ZFUGUE (memcpy(&ctx_fugue, &z_fugue, sizeof(z_fugue))) +#define ZGOST (memcpy(&ctx_gost, &z_gost, sizeof(z_gost))) + +template +inline uint256 SkunkHash5(const T1 pbegin, const T1 pend) + +{ + sph_skein512_context ctx_skein; + sph_cubehash512_context ctx_cubehash; + sph_fugue512_context ctx_fugue; + sph_gost512_context ctx_gost; + static unsigned char pblank[1]; + +#ifndef QT_NO_DEBUG + //std::string strhash; + //strhash = ""; +#endif + + uint512 hash[17]; + + sph_skein512_init(&ctx_skein); + sph_skein512 (&ctx_skein, (pbegin == pend ? pblank : static_cast(&pbegin[0])), (pend - pbegin) * sizeof(pbegin[0])); + sph_skein512_close(&ctx_skein, static_cast(&hash[0])); + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512 (&ctx_cubehash, static_cast(&hash[0]), 64); + sph_cubehash512_close(&ctx_cubehash, static_cast(&hash[1])); + + sph_fugue512_init(&ctx_fugue); + sph_fugue512 (&ctx_fugue, static_cast(&hash[1]), 64); + sph_fugue512_close(&ctx_fugue, static_cast(&hash[2])); + + sph_gost512_init(&ctx_gost); + sph_gost512 (&ctx_gost, static_cast(&hash[2]), 64); + sph_gost512_close(&ctx_gost, static_cast(&hash[3])); + + return hash[3].trim256(); +} + +#endif // HASHBLOCK_H diff --git a/src/init.cpp b/src/init.cpp new file mode 100644 index 0000000..0b6d484 --- /dev/null +++ b/src/init.cpp @@ -0,0 +1,1052 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "init.h" +#include "main.h" +#include "chainparams.h" +#include "txdb.h" +#include "rpcserver.h" +#include "net.h" +#include "util.h" +#include "ui_interface.h" +#include "checkpoints.h" +#include "activemasternode.h" +#include "spork.h" +#include "smessage.h" + +#ifdef ENABLE_WALLET +#include "wallet.h" +#include "walletdb.h" +#endif + +#include +#include +#include +#include +#include +#include + +#ifndef WIN32 +#include +#endif + + +using namespace std; +using namespace boost; + +#ifdef ENABLE_WALLET +CWallet* pwalletMain = NULL; +#endif +CClientUIInterface uiInterface; +bool fConfChange; +bool fMinimizeCoinAge; +unsigned int nNodeLifespan; +unsigned int nDerivationMethodIndex; +unsigned int nMinerSleep; +bool fUseFastIndex; +bool fOnlyTor = false; + +//enum Checkpoints::CPMode CheckpointsMode; for anti exploit protection + +// Shutdown + + +// +// Thread management and startup/shutdown: +// +// The network-processing threads are all part of a thread group +// created by AppInit() or the Qt main() function. +// +// A clean exit happens when StartShutdown() or the SIGTERM +// signal handler sets fRequestShutdown, which triggers +// the DetectShutdownThread(), which interrupts the main thread group. +// DetectShutdownThread() then exits, which causes AppInit() to +// continue (it .joins the shutdown thread). +// Shutdown() is then +// called to clean up database connections, and stop other +// threads that should only be stopped after the main network-processing +// threads have exited. +// +// Note that if running -daemon the parent process returns from AppInit2 +// before adding any threads to the threadGroup, so .join_all() returns +// immediately and the parent exits from main(). +// +// Shutdown for Qt is very similar, only it uses a QTimer to detect +// fRequestShutdown getting set, and then does the normal Qt +// shutdown thing. +// + +volatile bool fRequestShutdown = false; + +void StartShutdown() +{ + fRequestShutdown = true; +} +bool ShutdownRequested() +{ + return fRequestShutdown; +} + +void Shutdown() +{ + LogPrintf("Shutdown : In progress...\n"); + static CCriticalSection cs_Shutdown; + TRY_LOCK(cs_Shutdown, lockShutdown); + if (!lockShutdown) return; + + RenameThread("SONO-shutoff"); + mempool.AddTransactionsUpdated(1); + StopRPCThreads(); + SecureMsgShutdown(); + +#ifdef ENABLE_WALLET + ShutdownRPCMining(); + if (pwalletMain) + bitdb.Flush(false); +#endif + StopNode(); + { + LOCK(cs_main); +#ifdef ENABLE_WALLET + if (pwalletMain) + pwalletMain->SetBestChain(CBlockLocator(pindexBest)); +#endif + } +#ifdef ENABLE_WALLET + if (pwalletMain) + bitdb.Flush(true); +#endif + boost::filesystem::remove(GetPidFile()); + UnregisterAllWallets(); +#ifdef ENABLE_WALLET + delete pwalletMain; + pwalletMain = NULL; +#endif + LogPrintf("Shutdown : done\n"); +} + +// +// Signal handlers are very limited in what they are allowed to do, so: +// +void HandleSIGTERM(int) +{ + fRequestShutdown = true; +} + +void HandleSIGHUP(int) +{ + fReopenDebugLog = true; +} + +bool static InitError(const std::string &str) +{ + uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR); + return false; +} + +bool static InitWarning(const std::string &str) +{ + uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING); + return true; +} + +bool static Bind(const CService &addr, bool fError = true) { + if (IsLimited(addr)) + return false; + std::string strError; + if (!BindListenPort(addr, strError)) { + if (fError) + return InitError(strError); + return false; + } + return true; +} + +// Core-specific options shared between UI and daemon +std::string HelpMessage() +{ + string strUsage = _("Options:") + "\n"; + strUsage += " -? " + _("This help message") + "\n"; + strUsage += " -conf= " + _("Specify configuration file (default: SONO.conf)") + "\n"; + strUsage += " -pid= " + _("Specify pid file (default: SONOd.pid)") + "\n"; + strUsage += " -datadir= " + _("Specify data directory") + "\n"; + strUsage += " -wallet= " + _("Specify wallet file (within data directory)") + "\n"; + strUsage += " -dbcache= " + _("Set database cache size in megabytes (default: 25)") + "\n"; + strUsage += " -dblogsize= " + _("Set database disk log size in megabytes (default: 100)") + "\n"; + strUsage += " -timeout= " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n"; + strUsage += " -proxy= " + _("Connect through SOCKS5 proxy") + "\n"; + strUsage += " -tor= " + _("Use proxy to reach tor hidden services (default: same as -proxy)") + "\n"; + strUsage += " -dns " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n"; + strUsage += " -port= " + _("Listen for connections on (default: 29855 or testnet: 39855)") + "\n"; + strUsage += " -maxconnections= " + _("Maintain at most connections to peers (default: 125)") + "\n"; + strUsage += " -addnode= " + _("Add a node to connect to and attempt to keep the connection open") + "\n"; + strUsage += " -connect= " + _("Connect only to the specified node(s)") + "\n"; + strUsage += " -seednode= " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n"; + strUsage += " -externalip= " + _("Specify your own public address") + "\n"; + strUsage += " -onlynet= " + _("Only connect to nodes in network (IPv4, IPv6 or Tor)") + "\n"; + strUsage += " -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n"; + strUsage += " -irc " + _("Find peers using internet relay chat (default: 0)") + "\n"; + strUsage += " -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n"; + strUsage += " -bind= " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n"; + strUsage += " -dnsseed " + _("Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect)") + "\n"; + strUsage += " -forcednsseed " + _("Always query for peer addresses via DNS lookup (default: 0)") + "\n"; + strUsage += " -synctime " + _("Sync time with other nodes. Disable if time on your system is precise e.g. syncing with NTP (default: 1)") + "\n"; + strUsage += " -cppolicy " + _("Sync checkpoints policy (default: strict)") + "\n"; + strUsage += " -banscore= " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n"; + strUsage += " -bantime= " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n"; + strUsage += " -maxreceivebuffer= " + _("Maximum per-connection receive buffer, *1000 bytes (default: 5000)") + "\n"; + strUsage += " -maxsendbuffer= " + _("Maximum per-connection send buffer, *1000 bytes (default: 1000)") + "\n"; +#ifdef USE_UPNP +#if USE_UPNP + strUsage += " -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n"; +#else + strUsage += " -upnp " + _("Use UPnP to map the listening port (default: 0)") + "\n"; +#endif +#endif + strUsage += " -paytxfee= " + _("Fee per KB to add to transactions you send") + "\n"; + strUsage += " -mininput= " + _("When creating transactions, ignore inputs with value less than this (default: 0.01)") + "\n"; + if (fHaveGUI) + strUsage += " -server " + _("Accept command line and JSON-RPC commands") + "\n"; +#if !defined(WIN32) + if (fHaveGUI) + strUsage += " -daemon " + _("Run in the background as a daemon and accept commands") + "\n"; +#endif + strUsage += " -testnet " + _("Use the test network") + "\n"; + strUsage += " -debug= " + _("Output debugging information (default: 0, supplying is optional)") + "\n"; + strUsage += _("If is not supplied, output all debugging information.") + "\n"; + strUsage += _(" can be:"); + strUsage += " addrman, alert, db, lock, rand, rpc, selectcoins, mempool, net,"; // Don't translate these and qt below + strUsage += " coinage, coinstake, creation, stakemodifier"; + if (fHaveGUI) + { + strUsage += ", qt.\n"; + } + else + { + strUsage += ".\n"; + } + strUsage += " -logtimestamps " + _("Prepend debug output with timestamp") + "\n"; + strUsage += " -shrinkdebugfile " + _("Shrink debug.log file on client startup (default: 1 when no -debug)") + "\n"; + strUsage += " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n"; + strUsage += " -regtest " + _("Enter regression test mode, which uses a special chain in which blocks can be " + "solved instantly. This is intended for regression testing tools and app development.") + "\n"; + strUsage += " -rpcuser= " + _("Username for JSON-RPC connections") + "\n"; + strUsage += " -rpcpassword= " + _("Password for JSON-RPC connections") + "\n"; + strUsage += " -rpcport= " + _("Listen for JSON-RPC connections on (default: 28855 or testnet: 38855)") + "\n"; + strUsage += " -rpcallowip= " + _("Allow JSON-RPC connections from specified IP address") + "\n"; + if (!fHaveGUI) + { + strUsage += " -rpcconnect= " + _("Send commands to node running on (default: 127.0.0.1)") + "\n"; + strUsage += " -rpcwait " + _("Wait for RPC server to start") + "\n"; + } + strUsage += " -rpcthreads= " + _("Set the number of threads to service RPC calls (default: 4)") + "\n"; + strUsage += " -blocknotify= " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n"; + strUsage += " -walletnotify= " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n"; + strUsage += " -confchange " + _("Require a confirmations for change (default: 0)") + "\n"; + strUsage += " -minimizecoinage " + _("Minimize weight consumption (experimental) (default: 0)") + "\n"; + strUsage += " -alertnotify= " + _("Execute command when a relevant alert is received (%s in cmd is replaced by message)") + "\n"; + strUsage += " -upgradewallet " + _("Upgrade wallet to latest format") + "\n"; + strUsage += " -keypool= " + _("Set key pool size to (default: 100)") + "\n"; + strUsage += " -rescan " + _("Rescan the block chain for missing wallet transactions") + "\n"; + strUsage += " -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + "\n"; + strUsage += " -checkblocks= " + _("How many blocks to check at startup (default: 500, 0 = all)") + "\n"; + strUsage += " -checklevel= " + _("How thorough the block verification is (0-6, default: 1)") + "\n"; + strUsage += " -loadblock= " + _("Imports blocks from external blk000?.dat file") + "\n"; + strUsage += " -maxorphanblocks= " + strprintf(_("Keep at most unconnectable blocks in memory (default: %u)"), DEFAULT_MAX_ORPHAN_BLOCKS) + "\n"; + + strUsage += "\n" + _("Block creation options:") + "\n"; + strUsage += " -blockminsize= " + _("Set minimum block size in bytes (default: 0)") + "\n"; + strUsage += " -blockmaxsize= " + _("Set maximum block size in bytes (default: 250000)") + "\n"; + strUsage += " -blockprioritysize= " + _("Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)") + "\n"; + + strUsage += "\n" + _("SSL options: (see the Bitcoin Wiki for SSL setup instructions)") + "\n"; + strUsage += " -rpcssl " + _("Use OpenSSL (https) for JSON-RPC connections") + "\n"; + strUsage += " -rpcsslcertificatechainfile= " + _("Server certificate file (default: server.cert)") + "\n"; + strUsage += " -rpcsslprivatekeyfile= " + _("Server private key (default: server.pem)") + "\n"; + strUsage += " -rpcsslciphers= " + _("Acceptable ciphers (default: TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH)") + "\n"; + strUsage += " -litemode= " + _("Disable all Masternode and darksend related functionality (0-1, default: 0)") + "\n"; +strUsage += "\n" + _("Masternode options:") + "\n"; + strUsage += " -masternode= " + _("Enable the client to act as a masternode (0-1, default: 0)") + "\n"; + strUsage += " -mnconf= " + _("Specify masternode configuration file (default: masternode.conf)") + "\n"; + strUsage += " -masternodeprivkey= " + _("Set the masternode private key") + "\n"; + strUsage += " -masternodeaddr= " + _("Set external address:port to get to this masternode (example: address:port)") + "\n"; + strUsage += " -masternodeminprotocol= " + _("Ignore masternodes less than version (example: 70007; default : 0)") + "\n"; + + strUsage += "\n" + _("darksend options:") + "\n"; + strUsage += " -enabledarksend= " + _("Enable use of automated darksend for funds stored in this wallet (0-1, default: 0)") + "\n"; + strUsage += " -darksendrounds= " + _("Use N separate masternodes to anonymize funds (2-8, default: 2)") + "\n"; + strUsage += " -anonymizeSONOamount= " + _("Keep N SONO anonymized (default: 0)") + "\n"; + strUsage += " -liquidityprovider= " + _("Provide liquidity to darksend by infrequently mixing coins on a continual basis (0-100, default: 0, 1=very frequent, high fees, 100=very infrequent, low fees)") + "\n"; + + strUsage += "\n" + _("InstantX options:") + "\n"; + strUsage += " -enableinstantx= " + _("Enable instantx, show confirmations for locked transactions (bool, default: true)") + "\n"; + strUsage += " -instantxdepth= " + _("Show N confirmations for a successfully locked transaction (0-9999, default: 1)") + "\n"; + strUsage += _("Secure messaging options:") + "\n" + + " -nosmsg " + _("Disable secure messaging.") + "\n" + + " -debugsmsg " + _("Log extra debug messages.") + "\n" + + " -smsgscanchain " + _("Scan the block chain for public key addresses on startup.") + "\n"; + + + return strUsage; +} + +/** Sanity checks + * Ensure that Bitcoin is running in a usable environment with all + * necessary library support. + */ +bool InitSanityCheck(void) +{ + if(!ECC_InitSanityCheck()) { + InitError("OpenSSL appears to lack support for elliptic curve cryptography. For more " + "information, visit https://en.bitcoin.it/wiki/OpenSSL_and_EC_Libraries"); + return false; + } + + // TODO: remaining sanity checks, see #4081 + + return true; +} + +/** Initialize bitcoin. + * @pre Parameters should be parsed and config file should be read. + */ +bool AppInit2(boost::thread_group& threadGroup) +{ + // ********************************************************* Step 1: setup +#ifdef _MSC_VER + // Turn off Microsoft heap dump noise + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0)); +#endif +#if _MSC_VER >= 1400 + // Disable confusing "helpful" text message on abort, Ctrl-C + _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); +#endif +#ifdef WIN32 + // Enable Data Execution Prevention (DEP) + // Minimum supported OS versions: WinXP SP3, WinVista >= SP1, Win Server 2008 + // A failure is non-critical and needs no further attention! +#ifndef PROCESS_DEP_ENABLE + // We define this here, because GCCs winbase.h limits this to _WIN32_WINNT >= 0x0601 (Windows 7), + // which is not correct. Can be removed, when GCCs winbase.h is fixed! +#define PROCESS_DEP_ENABLE 0x00000001 +#endif + typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD); + PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetProcessDEPPolicy"); + if (setProcDEPPol != NULL) setProcDEPPol(PROCESS_DEP_ENABLE); +#endif +#ifndef WIN32 + umask(077); + + // Clean shutdown on SIGTERM + struct sigaction sa; + sa.sa_handler = HandleSIGTERM; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sigaction(SIGTERM, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + + // Reopen debug.log on SIGHUP + struct sigaction sa_hup; + sa_hup.sa_handler = HandleSIGHUP; + sigemptyset(&sa_hup.sa_mask); + sa_hup.sa_flags = 0; + sigaction(SIGHUP, &sa_hup, NULL); +#endif + + // ********************************************************* Step 2: parameter interactions + + nNodeLifespan = GetArg("-addrlifespan", 7); + fUseFastIndex = GetBoolArg("-fastindex", true); + nMinerSleep = GetArg("-minersleep", 500); + + /*CheckpointsMode = Checkpoints::STRICT; + std::string strCpMode = GetArg("-cppolicy", "strict"); + + if(strCpMode == "strict") + CheckpointsMode = Checkpoints::STRICT; + + if(strCpMode == "advisory") + CheckpointsMode = Checkpoints::ADVISORY; + + if(strCpMode == "permissive") + CheckpointsMode = Checkpoints::PERMISSIVE;*/ + + nDerivationMethodIndex = 0; + + if (!SelectParamsFromCommandLine()) { + return InitError("Invalid combination of -testnet and -regtest."); + } + + if (TestNet()) + { + SoftSetBoolArg("-irc", true); + } + + if (mapArgs.count("-bind")) { + // when specifying an explicit binding address, you want to listen on it + // even when -connect or -proxy is specified + if (SoftSetBoolArg("-listen", true)) + LogPrintf("AppInit2 : parameter interaction: -bind set -> setting -listen=1\n"); + } + + if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) { + // when only connecting to trusted nodes, do not seed via DNS, or listen by default + if (SoftSetBoolArg("-dnsseed", false)) + LogPrintf("AppInit2 : parameter interaction: -connect set -> setting -dnsseed=0\n"); + if (SoftSetBoolArg("-listen", false)) + LogPrintf("AppInit2 : parameter interaction: -connect set -> setting -listen=0\n"); + } + + if (mapArgs.count("-proxy")) { + // to protect privacy, do not listen by default if a default proxy server is specified + if (SoftSetBoolArg("-listen", false)) + LogPrintf("AppInit2 : parameter interaction: -proxy set -> setting -listen=0\n"); + // to protect privacy, do not discover addresses by default + if (SoftSetBoolArg("-discover", false)) + LogPrintf("AppInit2 : parameter interaction: -proxy set -> setting -discover=0\n"); + } + + if (!GetBoolArg("-listen", true)) { + // do not map ports or try to retrieve public IP when not listening (pointless) + if (SoftSetBoolArg("-upnp", false)) + LogPrintf("AppInit2 : parameter interaction: -listen=0 -> setting -upnp=0\n"); + if (SoftSetBoolArg("-discover", false)) + LogPrintf("AppInit2 : parameter interaction: -listen=0 -> setting -discover=0\n"); + } + + if (mapArgs.count("-externalip")) { + // if an explicit public IP is specified, do not try to find others + if (SoftSetBoolArg("-discover", false)) + LogPrintf("AppInit2 : parameter interaction: -externalip set -> setting -discover=0\n"); + } + + if (GetBoolArg("-salvagewallet", false)) { + // Rewrite just private keys: rescan to find transactions + if (SoftSetBoolArg("-rescan", true)) + LogPrintf("AppInit2 : parameter interaction: -salvagewallet=1 -> setting -rescan=1\n"); + } + + // ********************************************************* Step 3: parameter-to-internal-flags + + fDebug = !mapMultiArgs["-debug"].empty(); + // Special-case: if -debug=0/-nodebug is set, turn off debugging messages + const vector& categories = mapMultiArgs["-debug"]; + if (GetBoolArg("-nodebug", false) || find(categories.begin(), categories.end(), string("0")) != categories.end()) + fDebug = false; + + if(fDebug) + { + fDebugSmsg = true; + } else + { + fDebugSmsg = GetBoolArg("-debugsmsg", false); + } + fNoSmsg = GetBoolArg("-nosmsg", false); + + + // Check for -debugnet (deprecated) + if (GetBoolArg("-debugnet", false)) + InitWarning(_("Warning: Deprecated argument -debugnet ignored, use -debug=net")); + // Check for -socks - as this is a privacy risk to continue, exit here + if (mapArgs.count("-socks")) + return InitError(_("Error: Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported.")); + + if (fDaemon) + fServer = true; + else + fServer = GetBoolArg("-server", false); + + /* force fServer when running without GUI */ + if (!fHaveGUI) + fServer = true; + fPrintToConsole = GetBoolArg("-printtoconsole", false); + fLogTimestamps = GetBoolArg("-logtimestamps", false); +#ifdef ENABLE_WALLET + bool fDisableWallet = GetBoolArg("-disablewallet", false); +#endif + + if (mapArgs.count("-timeout")) + { + int nNewTimeout = GetArg("-timeout", 5000); + if (nNewTimeout > 0 && nNewTimeout < 600000) + nConnectTimeout = nNewTimeout; + } + +#ifdef ENABLE_WALLET + if (mapArgs.count("-paytxfee")) + { + if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee)) + return InitError(strprintf(_("Invalid amount for -paytxfee=: '%s'"), mapArgs["-paytxfee"])); + if (nTransactionFee > 0.25 * COIN) + InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction.")); + } +#endif + + fConfChange = GetBoolArg("-confchange", false); + fMinimizeCoinAge = GetBoolArg("-minimizecoinage", false); + +#ifdef ENABLE_WALLET + if (mapArgs.count("-mininput")) + { + if (!ParseMoney(mapArgs["-mininput"], nMinimumInputValue)) + return InitError(strprintf(_("Invalid amount for -mininput=: '%s'"), mapArgs["-mininput"])); + } +#endif + + // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log + + // Sanity check + if (!InitSanityCheck()) + return InitError(_("Initialization sanity check failed. SONO is shutting down.")); + + std::string strDataDir = GetDataDir().string(); +#ifdef ENABLE_WALLET + std::string strWalletFileName = GetArg("-wallet", "wallet.dat"); + + // strWalletFileName must be a plain filename without a directory + if (strWalletFileName != boost::filesystem::basename(strWalletFileName) + boost::filesystem::extension(strWalletFileName)) + return InitError(strprintf(_("Wallet %s resides outside data directory %s."), strWalletFileName, strDataDir)); +#endif + // Make sure only a single Bitcoin process is using the data directory. + boost::filesystem::path pathLockFile = GetDataDir() / ".lock"; + FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist. + if (file) fclose(file); + static boost::interprocess::file_lock lock(pathLockFile.string().c_str()); + if (!lock.try_lock()) + return InitError(strprintf(_("Cannot obtain a lock on data directory %s. SONO is probably already running."), strDataDir)); + + if (GetBoolArg("-shrinkdebugfile", !fDebug)) + ShrinkDebugFile(); + LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + LogPrintf("SONO version %s (%s)\n", FormatFullVersion(), CLIENT_DATE); + LogPrintf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION)); + if (!fLogTimestamps) + LogPrintf("Startup time: %s\n", DateTimeStrFormat("%x %H:%M:%S", GetTime())); + LogPrintf("Default data directory %s\n", GetDefaultDataDir().string()); + LogPrintf("Used data directory %s\n", strDataDir); + std::ostringstream strErrors; + + if (mapArgs.count("-masternodepaymentskey")) // masternode payments priv key + { + if (!masternodePayments.SetPrivKey(GetArg("-masternodepaymentskey", ""))) + return InitError(_("Unable to sign masternode payment winner, wrong key?")); + if (!sporkManager.SetPrivKey(GetArg("-masternodepaymentskey", ""))) + return InitError(_("Unable to sign spork message, wrong key?")); + } + + //ignore masternodes below protocol version + CMasterNode::minProtoVersion = GetArg("-masternodeminprotocol", MIN_MN_PROTO_VERSION); + + if (fDaemon) + fprintf(stdout, "SONO server starting\n"); + + int64_t nStart; + + // ********************************************************* Step 5: verify database integrity +#ifdef ENABLE_WALLET + if (!fDisableWallet) { + uiInterface.InitMessage(_("Verifying database integrity...")); + + if (!bitdb.Open(GetDataDir())) + { + // try moving the database env out of the way + boost::filesystem::path pathDatabase = GetDataDir() / "database"; + boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%d.bak", GetTime()); + try { + boost::filesystem::rename(pathDatabase, pathDatabaseBak); + LogPrintf("Moved old %s to %s. Retrying.\n", pathDatabase.string(), pathDatabaseBak.string()); + } catch(boost::filesystem::filesystem_error &error) { + // failure is ok (well, not really, but it's not worse than what we started with) + } + + // try again + if (!bitdb.Open(GetDataDir())) { + // if it still fails, it probably means we can't even create the database env + string msg = strprintf(_("Error initializing wallet database environment %s!"), strDataDir); + return InitError(msg); + } + } + + if (GetBoolArg("-salvagewallet", false)) + { + // Recover readable keypairs: + if (!CWalletDB::Recover(bitdb, strWalletFileName, true)) + return false; + } + + if (filesystem::exists(GetDataDir() / strWalletFileName)) + { + CDBEnv::VerifyResult r = bitdb.Verify(strWalletFileName, CWalletDB::Recover); + if (r == CDBEnv::RECOVER_OK) + { + string msg = strprintf(_("Warning: wallet.dat corrupt, data salvaged!" + " Original wallet.dat saved as wallet.{timestamp}.bak in %s; if" + " your balance or transactions are incorrect you should" + " restore from a backup."), strDataDir); + InitWarning(msg); + } + if (r == CDBEnv::RECOVER_FAIL) + return InitError(_("wallet.dat corrupt, salvage failed")); + } + + } // (!fDisableWallet) +#endif // ENABLE_WALLET + // ********************************************************* Step 6: network initialization + + RegisterNodeSignals(GetNodeSignals()); + + if (mapArgs.count("-onlynet")) { + std::set nets; + BOOST_FOREACH(std::string snet, mapMultiArgs["-onlynet"]) { + enum Network net = ParseNetwork(snet); + if(net == NET_TOR) + fOnlyTor = true; + + if (net == NET_UNROUTABLE) + return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet)); + nets.insert(net); + } + for (int n = 0; n < NET_MAX; n++) { + enum Network net = (enum Network)n; + if (!nets.count(net)) + SetLimited(net); + } + } + + CService addrProxy; + bool fProxy = false; + if (mapArgs.count("-proxy")) { + addrProxy = CService(mapArgs["-proxy"], 9050); + if (!addrProxy.IsValid()) + return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"])); + + if (!IsLimited(NET_IPV4)) + SetProxy(NET_IPV4, addrProxy); + if (!IsLimited(NET_IPV6)) + SetProxy(NET_IPV6, addrProxy); + SetNameProxy(addrProxy); + fProxy = true; + } + + // -tor can override normal proxy, -notor disables tor entirely + if (!(mapArgs.count("-tor") && mapArgs["-tor"] == "0") && (fProxy || mapArgs.count("-tor"))) { + CService addrOnion; + if (!mapArgs.count("-tor")) + addrOnion = addrProxy; + else + addrOnion = CService(mapArgs["-tor"], 9050); + if (!addrOnion.IsValid()) + return InitError(strprintf(_("Invalid -tor address: '%s'"), mapArgs["-tor"])); + SetProxy(NET_TOR, addrOnion); + SetReachable(NET_TOR); + } + + // see Step 2: parameter interactions for more information about these + fNoListen = !GetBoolArg("-listen", true); + fDiscover = GetBoolArg("-discover", true); + fNameLookup = GetBoolArg("-dns", true); + + bool fBound = false; + if (!fNoListen) + { + std::string strError; + if (mapArgs.count("-bind")) { + BOOST_FOREACH(std::string strBind, mapMultiArgs["-bind"]) { + CService addrBind; + if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) + return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind)); + fBound |= Bind(addrBind); + } + } else { + struct in_addr inaddr_any; + inaddr_any.s_addr = INADDR_ANY; + if (!IsLimited(NET_IPV6)) + fBound |= Bind(CService(in6addr_any, GetListenPort()), false); + if (!IsLimited(NET_IPV4)) + fBound |= Bind(CService(inaddr_any, GetListenPort()), !fBound); + } + if (!fBound) + return InitError(_("Failed to listen on any port. Use -listen=0 if you want this.")); + } + + if (mapArgs.count("-externalip")) + { + BOOST_FOREACH(string strAddr, mapMultiArgs["-externalip"]) { + CService addrLocal(strAddr, GetListenPort(), fNameLookup); + if (!addrLocal.IsValid()) + return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr)); + AddLocal(CService(strAddr, GetListenPort(), fNameLookup), LOCAL_MANUAL); + } + } + +#ifdef ENABLE_WALLET + if (mapArgs.count("-reservebalance")) // ppcoin: reserve balance amount + { + if (!ParseMoney(mapArgs["-reservebalance"], nReserveBalance)) + { + InitError(_("Invalid amount for -reservebalance=")); + return false; + } + } +#endif + + /*if (mapArgs.count("-checkpointkey")) // ppcoin: checkpoint master priv key + { + if (!Checkpoints::SetCheckpointPrivKey(GetArg("-checkpointkey", ""))) + InitError(_("Unable to sign checkpoint, wrong checkpointkey?\n")); + }*/ + + BOOST_FOREACH(string strDest, mapMultiArgs["-seednode"]) + AddOneShot(strDest); + + // ********************************************************* Step 7: load blockchain + + if (GetBoolArg("-loadblockindextest", false)) + { + CTxDB txdb("r"); + txdb.LoadBlockIndex(); + PrintBlockTree(); + return false; + } + + uiInterface.InitMessage(_("Loading block index...")); + + nStart = GetTimeMillis(); + if (!LoadBlockIndex()) + return InitError(_("Error loading block database")); + + + // as LoadBlockIndex can take several minutes, it's possible the user + // requested to kill bitcoin-qt during the last operation. If so, exit. + // As the program has not fully started yet, Shutdown() is possibly overkill. + if (fRequestShutdown) + { + LogPrintf("Shutdown requested. Exiting.\n"); + return false; + } + LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart); + + if (GetBoolArg("-printblockindex", false) || GetBoolArg("-printblocktree", false)) + { + PrintBlockTree(); + return false; + } + + if (mapArgs.count("-printblock")) + { + string strMatch = mapArgs["-printblock"]; + int nFound = 0; + for (map::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi) + { + uint256 hash = (*mi).first; + if (strncmp(hash.ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0) + { + CBlockIndex* pindex = (*mi).second; + CBlock block; + block.ReadFromDisk(pindex); + block.BuildMerkleTree(); + LogPrintf("%s\n", block.ToString()); + nFound++; + } + } + if (nFound == 0) + LogPrintf("No blocks matching %s were found\n", strMatch); + return false; + } + + // ********************************************************* Step 8: load wallet +#ifdef ENABLE_WALLET + if (fDisableWallet) { + pwalletMain = NULL; + LogPrintf("Wallet disabled!\n"); + } else { + uiInterface.InitMessage(_("Loading wallet...")); + + nStart = GetTimeMillis(); + bool fFirstRun = true; + pwalletMain = new CWallet(strWalletFileName); + DBErrors nLoadWalletRet = pwalletMain->LoadWallet(fFirstRun); + if (nLoadWalletRet != DB_LOAD_OK) + { + if (nLoadWalletRet == DB_CORRUPT) + strErrors << _("Error loading wallet.dat: Wallet corrupted") << "\n"; + else if (nLoadWalletRet == DB_NONCRITICAL_ERROR) + { + string msg(_("Warning: error reading wallet.dat! All keys read correctly, but transaction data" + " or address book entries might be missing or incorrect.")); + InitWarning(msg); + } + else if (nLoadWalletRet == DB_TOO_NEW) + strErrors << _("Error loading wallet.dat: Wallet requires newer version of SONO") << "\n"; + else if (nLoadWalletRet == DB_NEED_REWRITE) + { + strErrors << _("Wallet needed to be rewritten: restart SONO to complete") << "\n"; + LogPrintf("%s", strErrors.str()); + return InitError(strErrors.str()); + } + else + strErrors << _("Error loading wallet.dat") << "\n"; + } + + if (GetBoolArg("-upgradewallet", fFirstRun)) + { + int nMaxVersion = GetArg("-upgradewallet", 0); + if (nMaxVersion == 0) // the -upgradewallet without argument case + { + LogPrintf("Performing wallet upgrade to %i\n", FEATURE_LATEST); + nMaxVersion = CLIENT_VERSION; + pwalletMain->SetMinVersion(FEATURE_LATEST); // permanently upgrade the wallet immediately + } + else + LogPrintf("Allowing wallet upgrade up to %i\n", nMaxVersion); + if (nMaxVersion < pwalletMain->GetVersion()) + strErrors << _("Cannot downgrade wallet") << "\n"; + pwalletMain->SetMaxVersion(nMaxVersion); + } + + if (fFirstRun) + { + // Create new keyUser and set as default key + RandAddSeedPerfmon(); + + CPubKey newDefaultKey; + if (pwalletMain->GetKeyFromPool(newDefaultKey)) { + pwalletMain->SetDefaultKey(newDefaultKey); + if (!pwalletMain->SetAddressBookName(pwalletMain->vchDefaultKey.GetID(), "")) + strErrors << _("Cannot write default address") << "\n"; + } + + pwalletMain->SetBestChain(CBlockLocator(pindexBest)); + } + + LogPrintf("%s", strErrors.str()); + LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart); + + RegisterWallet(pwalletMain); + + CBlockIndex *pindexRescan = pindexBest; + if (GetBoolArg("-rescan", false)) + pindexRescan = pindexGenesisBlock; + else + { + CWalletDB walletdb(strWalletFileName); + CBlockLocator locator; + if (walletdb.ReadBestBlock(locator)) + pindexRescan = locator.GetBlockIndex(); + else + pindexRescan = pindexGenesisBlock; + } + if (pindexBest != pindexRescan && pindexBest && pindexRescan && pindexBest->nHeight > pindexRescan->nHeight) + { + uiInterface.InitMessage(_("Rescanning...")); + LogPrintf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight); + nStart = GetTimeMillis(); + pwalletMain->ScanForWalletTransactions(pindexRescan, true); + LogPrintf(" rescan %15dms\n", GetTimeMillis() - nStart); + pwalletMain->SetBestChain(CBlockLocator(pindexBest)); + nWalletDBUpdated++; + } + } // (!fDisableWallet) +#else // ENABLE_WALLET + LogPrintf("No wallet compiled in!\n"); +#endif // !ENABLE_WALLET + // ********************************************************* Step 9: import blocks + + std::vector vImportFiles; + if (mapArgs.count("-loadblock")) + { + BOOST_FOREACH(string strFile, mapMultiArgs["-loadblock"]) + vImportFiles.push_back(strFile); + } + threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles)); + + // ********************************************************* Step 10: load peers + + uiInterface.InitMessage(_("Loading addresses...")); + + nStart = GetTimeMillis(); + + { + CAddrDB adb; + if (!adb.Read(addrman)) + LogPrintf("Invalid or missing peers.dat; recreating\n"); + } + + LogPrintf("Loaded %i addresses from peers.dat %dms\n", + addrman.size(), GetTimeMillis() - nStart); + + // ********************************************************* Step 10.1: startup secure messaging + + SecureMsgStart(fNoSmsg, GetBoolArg("-smsgscanchain", false)); + + // ********************************************************* Step 11: start node + + if (!CheckDiskSpace()) + return false; + + if (!strErrors.str().empty()) + return InitError(strErrors.str()); + + fMasterNode = GetBoolArg("-masternode", false); + if(fMasterNode) { + LogPrintf("IS DARKSEND MASTER NODE\n"); + strMasterNodeAddr = GetArg("-masternodeaddr", ""); + + LogPrintf(" addr %s\n", strMasterNodeAddr.c_str()); + + if(!strMasterNodeAddr.empty()){ + CService addrTest = CService(strMasterNodeAddr); + if (!addrTest.IsValid()) { + return InitError("Invalid -masternodeaddr address: " + strMasterNodeAddr); + } + } + + strMasterNodePrivKey = GetArg("-masternodeprivkey", ""); + if(!strMasterNodePrivKey.empty()){ + std::string errorMessage; + + CKey key; + CPubKey pubkey; + + if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, key, pubkey)) + { + return InitError(_("Invalid masternodeprivkey. Please see documenation.")); + } + + activeMasternode.pubKeyMasternode = pubkey; + + } else { + return InitError(_("You must specify a masternodeprivkey in the configuration. Please see documentation for help.")); + } + } + + fEnableluxsend = GetBoolArg("-enabledarksend", false); + + nDarksendRounds = GetArg("-darksendrounds", 2); + if(nDarksendRounds > 16) nDarksendRounds = 16; + if(nDarksendRounds < 1) nDarksendRounds = 1; + + nLiquidityProvider = GetArg("-liquidityprovider", 0); //0-100 + if(nLiquidityProvider != 0) { + darkSendPool.SetMinBlockSpacing(std::min(nLiquidityProvider,100)*15); + fEnableluxsend = true; + nDarksendRounds = 99999; + } + + nAnonymizeSONOAmount = GetArg("-anonymizeSONOamount", 0); + if(nAnonymizeSONOAmount > 999999) nAnonymizeSONOAmount = 999999; + if(nAnonymizeSONOAmount < 2) nAnonymizeSONOAmount = 2; + + bool fEnableInstantX = GetBoolArg("-enableinstantx", true); + if(fEnableInstantX){ + nInstantXDepth = GetArg("-instantxdepth", 5); + if(nInstantXDepth > 60) nInstantXDepth = 60; + if(nInstantXDepth < 0) nAnonymizeSONOAmount = 0; + } else { + nInstantXDepth = 0; + } + + //lite mode disables all Masternode and luxsend related functionality + fLiteMode = GetBoolArg("-litemode", false); + if(fMasterNode && fLiteMode){ + return InitError("You can not start a masternode in litemode"); + } + + LogPrintf("fLiteMode %d\n", fLiteMode); + LogPrintf("nInstantXDepth %d\n", nInstantXDepth); + LogPrintf("luxsend rounds %d\n", nDarksendRounds); + LogPrintf("Anonymize SONO Amount %d\n", nAnonymizeSONOAmount); + + /* Denominations + A note about convertability. Within luxsend pools, each denomination + is convertable to another. + For example: + 1SONO+1000 == (.1SONO+100)*10 + 10SONO+10000 == (1SONO+1000)*10 + */ + darkSendDenominations.push_back( (100000 * COIN)+100000000 ); + darkSendDenominations.push_back( (10000 * COIN)+10000000 ); + darkSendDenominations.push_back( (1000 * COIN)+1000000 ); + darkSendDenominations.push_back( (100 * COIN)+100000 ); + darkSendDenominations.push_back( (10 * COIN)+10000 ); + darkSendDenominations.push_back( (1 * COIN)+1000 ); + darkSendDenominations.push_back( (.1 * COIN)+100 ); + /* Disabled till we need them + darkSendDenominations.push_back( (.01 * COIN)+10 ); + darkSendDenominations.push_back( (.001 * COIN)+1 ); + */ + + darkSendPool.InitCollateralAddress(); + + threadGroup.create_thread(boost::bind(&ThreadCheckDarkSendPool)); + + + + RandAddSeedPerfmon(); + + // reindex addresses found in blockchain + if(GetBoolArg("-reindexaddr", false)) + { + uiInterface.InitMessage(_("Rebuilding address index...")); + CBlockIndex *pblockAddrIndex = pindexBest; + CTxDB txdbAddr("rw"); + while(pblockAddrIndex) + { + uiInterface.InitMessage(strprintf("Rebuilding address index, block %i", pblockAddrIndex->nHeight)); + bool ReadFromDisk(const CBlockIndex* pindex, bool fReadTransactions=true); + CBlock pblockAddr; + if(pblockAddr.ReadFromDisk(pblockAddrIndex, true)) + pblockAddr.RebuildAddressIndex(txdbAddr); + pblockAddrIndex = pblockAddrIndex->pprev; + } + } + + //// debug print + LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size()); + LogPrintf("nBestHeight = %d\n", nBestHeight); +#ifdef ENABLE_WALLET + LogPrintf("setKeyPool.size() = %u\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0); + LogPrintf("mapWallet.size() = %u\n", pwalletMain ? pwalletMain->mapWallet.size() : 0); + LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0); +#endif + + StartNode(threadGroup); +#ifdef ENABLE_WALLET + // InitRPCMining is needed here so getwork/getblocktemplate in the GUI debug console works properly. + InitRPCMining(); +#endif + if (fServer) + StartRPCThreads(); + +#ifdef ENABLE_WALLET + // Mine proof-of-stake blocks in the background + if (!GetBoolArg("-staking", true)) + LogPrintf("Staking disabled\n"); + else if (pwalletMain) + threadGroup.create_thread(boost::bind(&ThreadStakeMiner, pwalletMain)); +#endif + + // ********************************************************* Step 12: finished + + uiInterface.InitMessage(_("Done loading")); + +#ifdef ENABLE_WALLET + if (pwalletMain) { + BOOST_FOREACH(PAIRTYPE(std::string, CAdrenalineNodeConfig) adrenaline, pwalletMain->mapMyAdrenalineNodes) + { + uiInterface.NotifyAdrenalineNodeChanged(adrenaline.second); + } + + // Add wallet transactions that aren't already in a block to mapTransactions + pwalletMain->ReacceptWalletTransactions(); + + // Run a thread to flush wallet periodically + threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile))); + } +#endif + + return !fRequestShutdown; +} diff --git a/src/init.h b/src/init.h new file mode 100644 index 0000000..0d14b16 --- /dev/null +++ b/src/init.h @@ -0,0 +1,22 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_INIT_H +#define BITCOIN_INIT_H + +#include "wallet.h" + +namespace boost { + class thread_group; +} // namespace boost + +extern CWallet* pwalletMain; +void StartShutdown(); +bool ShutdownRequested(); +void Shutdown(); +bool AppInit2(boost::thread_group& threadGroup); +std::string HelpMessage(); +extern bool fOnlyTor; + +#endif diff --git a/src/instantx.cpp b/src/instantx.cpp new file mode 100644 index 0000000..62c2020 --- /dev/null +++ b/src/instantx.cpp @@ -0,0 +1,597 @@ + + + +#include "uint256.h" +#include "sync.h" +#include "net.h" +#include "key.h" +#include "util.h" +#include "base58.h" +#include "protocol.h" +#include "instantx.h" +#include "masternode.h" +#include "activemasternode.h" +#include "darksend.h" +#include "spork.h" +#include + +using namespace std; +using namespace boost; + +std::map mapTxLockReq; +std::map mapTxLockReqRejected; +std::map mapTxLockVote; +std::map mapTxLocks; +std::map mapLockedInputs; +std::map mapUnknownVotes; //track votes with no tx for DOS +int nCompleteTXLocks; + +//txlock - Locks transaction +// +//step 1.) Broadcast intention to lock transaction inputs, "txlreg", CTransaction +//step 2.) Top 10 masternodes, open connect to top 1 masternode. Send "txvote", CTransaction, Signature, Approve +//step 3.) Top 1 masternode, waits for 10 messages. Upon success, sends "txlock' + +void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) +{ + if(fLiteMode) return; //disable all darksend/masternode related functionality + if(!IsSporkActive(SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT)) return; + + if (strCommand == "txlreq") + { + //LogPrintf("ProcessMessageInstantX::txlreq\n"); + CDataStream vMsg(vRecv); + CTransaction tx; + vRecv >> tx; + + CInv inv(MSG_TXLOCK_REQUEST, tx.GetHash()); + pfrom->AddInventoryKnown(inv); + + if(mapTxLockReq.count(tx.GetHash()) || mapTxLockReqRejected.count(tx.GetHash())){ + return; + } + + if(!IsIXTXValid(tx)){ + return; + } + + BOOST_FOREACH(const CTxOut o, tx.vout){ + if(!o.scriptPubKey.IsNormalPaymentScript()){ + printf ("ProcessMessageInstantX::txlreq - Invalid Script %s\n", tx.ToString().c_str()); + return; + } + } + + int nBlockHeight = CreateNewLock(tx); + + bool fMissingInputs = false; + CValidationState state; + + + //if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs)) + if (AcceptToMemoryPool(mempool, tx, true, &fMissingInputs)) + { + vector vInv; + vInv.push_back(inv); + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + pnode->PushMessage("inv", vInv); + + DoConsensusVote(tx, nBlockHeight); + + mapTxLockReq.insert(make_pair(tx.GetHash(), tx)); + + LogPrintf("ProcessMessageInstantX::txlreq - Transaction Lock Request: %s %s : accepted %s\n", + pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str(), + tx.GetHash().ToString().c_str() + ); + + return; + + } else { + mapTxLockReqRejected.insert(make_pair(tx.GetHash(), tx)); + + // can we get the conflicting transaction as proof? + + LogPrintf("ProcessMessageInstantX::txlreq - Transaction Lock Request: %s %s : rejected %s\n", + pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str(), + tx.GetHash().ToString().c_str() + ); + + BOOST_FOREACH(const CTxIn& in, tx.vin){ + if(!mapLockedInputs.count(in.prevout)){ + mapLockedInputs.insert(make_pair(in.prevout, tx.GetHash())); + } + } + + // resolve conflicts + std::map::iterator i = mapTxLocks.find(tx.GetHash()); + if (i != mapTxLocks.end()){ + //we only care if we have a complete tx lock + if((*i).second.CountSignatures() >= INSTANTX_SIGNATURES_REQUIRED){ + if(!CheckForConflictingLocks(tx)){ + LogPrintf("ProcessMessageInstantX::txlreq - Found Existing Complete IX Lock\n"); + + CValidationState state; + //DisconnectBlockAndInputs(state, tx); + mapTxLockReq.insert(make_pair(tx.GetHash(), tx)); + } + } + } + + return; + } + } + else if (strCommand == "txlvote") //InstantX Lock Consensus Votes + { + CConsensusVote ctx; + vRecv >> ctx; + + CInv inv(MSG_TXLOCK_VOTE, ctx.GetHash()); + pfrom->AddInventoryKnown(inv); + + if(mapTxLockVote.count(ctx.GetHash())){ + return; + } + + mapTxLockVote.insert(make_pair(ctx.GetHash(), ctx)); + + if(ProcessConsensusVote(ctx)){ + //Spam/Dos protection + /* + Masternodes will sometimes propagate votes before the transaction is known to the client. + This tracks those messages and allows it at the same rate of the rest of the network, if + a peer violates it, it will simply be ignored + */ + if(!mapTxLockReq.count(ctx.txHash) && !mapTxLockReqRejected.count(ctx.txHash)){ + if(!mapUnknownVotes.count(ctx.vinMasternode.prevout.hash)){ + mapUnknownVotes[ctx.vinMasternode.prevout.hash] = GetTime()+(60*10); + } + + if(mapUnknownVotes[ctx.vinMasternode.prevout.hash] > GetTime() && + mapUnknownVotes[ctx.vinMasternode.prevout.hash] - GetAverageVoteTime() > 60*10){ + LogPrintf("ProcessMessageInstantX::txlreq - masternode is spamming transaction votes: %s %s\n", + ctx.vinMasternode.ToString().c_str(), + ctx.txHash.ToString().c_str() + ); + return; + } else { + mapUnknownVotes[ctx.vinMasternode.prevout.hash] = GetTime()+(60*10); + } + } + vector vInv; + vInv.push_back(inv); + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + pnode->PushMessage("inv", vInv); + + } + + return; + } +} + +bool IsIXTXValid(const CTransaction& txCollateral){ + if(txCollateral.vout.size() < 1) return false; + if(txCollateral.nLockTime != 0) return false; + + int64_t nValueIn = 0; + int64_t nValueOut = 0; + bool missingTx = false; + + BOOST_FOREACH(const CTxOut o, txCollateral.vout) + nValueOut += o.nValue; + + BOOST_FOREACH(const CTxIn i, txCollateral.vin){ + CTransaction tx2; + uint256 hash; + //if(GetTransaction(i.prevout.hash, tx2, hash, true)){ + if(GetTransaction(i.prevout.hash, tx2, hash)){ + if(tx2.vout.size() > i.prevout.n) { + nValueIn += tx2.vout[i.prevout.n].nValue; + } + } else{ + missingTx = true; + } + } + + if(nValueOut > GetSporkValue(SPORK_2_MAX_VALUE)*COIN){ + if(fDebug) LogPrintf ("IsIXTXValid - Transaction value too high - %s\n", txCollateral.ToString().c_str()); + return false; + } + + if(missingTx){ + if(fDebug) LogPrintf ("IsIXTXValid - Unknown inputs in IX transaction - %s\n", txCollateral.ToString().c_str()); + /* + This happens sometimes for an unknown reason, so we'll return that it's a valid transaction. + If someone submits an invalid transaction it will be rejected by the network anyway and this isn't + very common, but we don't want to block IX just because the client can't figure out the fee. + */ + return true; + } + + if(nValueIn-nValueOut < COIN*0.01) { + if(fDebug) LogPrintf ("IsIXTXValid - did not include enough fees in transaction %d\n%s\n", nValueOut-nValueIn, txCollateral.ToString().c_str()); + return false; + } + + return true; +} + +int64_t CreateNewLock(CTransaction tx) +{ + + int64_t nTxAge = 0; + BOOST_REVERSE_FOREACH(CTxIn i, tx.vin){ + nTxAge = GetInputAge(i); + if(nTxAge < 6) + { + LogPrintf("CreateNewLock - Transaction not found / too new: %d / %s\n", nTxAge, tx.GetHash().ToString().c_str()); + return 0; + } + } + + /* + Use a blockheight newer than the input. + This prevents attackers from using transaction mallibility to predict which masternodes + they'll use. + */ + int nBlockHeight = (pindexBest->nHeight - nTxAge)+4; + + if (!mapTxLocks.count(tx.GetHash())){ + LogPrintf("CreateNewLock - New Transaction Lock %s !\n", tx.GetHash().ToString().c_str()); + + CTransactionLock newLock; + newLock.nBlockHeight = nBlockHeight; + newLock.nExpiration = GetTime()+(60*60); //locks expire after 15 minutes (6 confirmations) + newLock.nTimeout = GetTime()+(60*5); + newLock.txHash = tx.GetHash(); + mapTxLocks.insert(make_pair(tx.GetHash(), newLock)); + } else { + mapTxLocks[tx.GetHash()].nBlockHeight = nBlockHeight; + if(fDebug) LogPrintf("CreateNewLock - Transaction Lock Exists %s !\n", tx.GetHash().ToString().c_str()); + } + + return nBlockHeight; +} + +// check if we need to vote on this transaction +void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight) +{ + if(!fMasterNode) return; + + int n = GetMasternodeRank(activeMasternode.vin, nBlockHeight, MIN_INSTANTX_PROTO_VERSION); + + if(n == -1) + { + if(fDebug) LogPrintf("InstantX::DoConsensusVote - Unknown Masternode\n"); + return; + } + + if(n > INSTANTX_SIGNATURES_TOTAL) + { + if(fDebug) LogPrintf("InstantX::DoConsensusVote - Masternode not in the top %d (%d)\n", INSTANTX_SIGNATURES_TOTAL, n); + return; + } + /* + nBlockHeight calculated from the transaction is the authoritive source + */ + + if(fDebug) LogPrintf("InstantX::DoConsensusVote - In the top %d (%d)\n", INSTANTX_SIGNATURES_TOTAL, n); + + CConsensusVote ctx; + ctx.vinMasternode = activeMasternode.vin; + ctx.txHash = tx.GetHash(); + ctx.nBlockHeight = nBlockHeight; + if(!ctx.Sign()){ + LogPrintf("InstantX::DoConsensusVote - Failed to sign consensus vote\n"); + return; + } + if(!ctx.SignatureValid()) { + LogPrintf("InstantX::DoConsensusVote - Signature invalid\n"); + return; + } + + mapTxLockVote[ctx.GetHash()] = ctx; + + CInv inv(MSG_TXLOCK_VOTE, ctx.GetHash()); + + vector vInv; + vInv.push_back(inv); + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes){ + pnode->PushMessage("inv", vInv); + } + +} + +//received a consensus vote +bool ProcessConsensusVote(CConsensusVote& ctx) +{ + int n = GetMasternodeRank(ctx.vinMasternode, ctx.nBlockHeight, MIN_INSTANTX_PROTO_VERSION); + + int x = GetMasternodeByVin(ctx.vinMasternode); + if(x != -1){ + if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Masternode ADDR %s %d\n", vecMasternodes[x].addr.ToString().c_str(), n); + } + + if(n == -1) + { + //can be caused by past versions trying to vote with an invalid protocol + if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Unknown Masternode\n"); + return false; + } + + if(n > INSTANTX_SIGNATURES_TOTAL) + { + if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Masternode not in the top %d (%d) - %s\n", INSTANTX_SIGNATURES_TOTAL, n, ctx.GetHash().ToString().c_str()); + return false; + } + + if(!ctx.SignatureValid()) { + LogPrintf("InstantX::ProcessConsensusVote - Signature invalid\n"); + //don't ban, it could just be a non-synced masternode + return false; + } + + if (!mapTxLocks.count(ctx.txHash)){ + LogPrintf("InstantX::ProcessConsensusVote - New Transaction Lock %s !\n", ctx.txHash.ToString().c_str()); + + CTransactionLock newLock; + newLock.nBlockHeight = 0; + newLock.nExpiration = GetTime()+(60*60); + newLock.nTimeout = GetTime()+(60*5); + newLock.txHash = ctx.txHash; + mapTxLocks.insert(make_pair(ctx.txHash, newLock)); + } else { + if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Transaction Lock Exists %s !\n", ctx.txHash.ToString().c_str()); + } + + //compile consessus vote + std::map::iterator i = mapTxLocks.find(ctx.txHash); + if (i != mapTxLocks.end()){ + (*i).second.AddSignature(ctx); + +#ifdef ENABLE_WALLET + if(pwalletMain){ + //when we get back signatures, we'll count them as requests. Otherwise the client will think it didn't propagate. + if(pwalletMain->mapRequestCount.count(ctx.txHash)) + pwalletMain->mapRequestCount[ctx.txHash]++; + } +#endif + + if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Transaction Lock Votes %d - %s !\n", (*i).second.CountSignatures(), ctx.GetHash().ToString().c_str()); + + if((*i).second.CountSignatures() >= INSTANTX_SIGNATURES_REQUIRED){ + if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Transaction Lock Is Complete %s !\n", (*i).second.GetHash().ToString().c_str()); + + CTransaction& tx = mapTxLockReq[ctx.txHash]; + if(!CheckForConflictingLocks(tx)){ + +#ifdef ENABLE_WALLET + if(pwalletMain){ + pwalletMain->UpdatedTransaction((*i).second.txHash); + nCompleteTXLocks++; + + } +#endif + + if(mapTxLockReq.count(ctx.txHash)){ + BOOST_FOREACH(const CTxIn& in, tx.vin){ + if(!mapLockedInputs.count(in.prevout)){ + mapLockedInputs.insert(make_pair(in.prevout, ctx.txHash)); + } + } + } + + // resolve conflicts + + //if this tx lock was rejected, we need to remove the conflicting blocks + if(mapTxLockReqRejected.count((*i).second.txHash)){ + CValidationState state; + //DisconnectBlockAndInputs(state, mapTxLockReqRejected[(*i).second.txHash]); + } + } + } + return true; + } + + + return false; +} + +bool CheckForConflictingLocks(CTransaction& tx) +{ + /* + It's possible (very unlikely though) to get 2 conflicting transaction locks approved by the network. + In that case, they will cancel each other out. + + Blocks could have been rejected during this time, which is OK. After they cancel out, the client will + rescan the blocks and find they're acceptable and then take the chain with the most work. + */ + BOOST_FOREACH(const CTxIn& in, tx.vin){ + if(mapLockedInputs.count(in.prevout)){ + if(mapLockedInputs[in.prevout] != tx.GetHash()){ + LogPrintf("InstantX::CheckForConflictingLocks - found two complete conflicting locks - removing both. %s %s", tx.GetHash().ToString().c_str(), mapLockedInputs[in.prevout].ToString().c_str()); + if(mapTxLocks.count(tx.GetHash())) mapTxLocks[tx.GetHash()].nExpiration = GetTime(); + if(mapTxLocks.count(mapLockedInputs[in.prevout])) mapTxLocks[mapLockedInputs[in.prevout]].nExpiration = GetTime(); + return true; + } + } + } + + return false; +} + +int64_t GetAverageVoteTime() +{ + std::map::iterator it = mapUnknownVotes.begin(); + int64_t total = 0; + int64_t count = 0; + + while(it != mapUnknownVotes.end()) { + total+= it->second; + count++; + it++; + } + + return total / count; +} + +void CleanTransactionLocksList() +{ + if(pindexBest == NULL) return; + + std::map::iterator it = mapTxLocks.begin(); + + while(it != mapTxLocks.end()) { + if(GetTime() > it->second.nExpiration){ //keep them for an hour + LogPrintf("Removing old transaction lock %s\n", it->second.txHash.ToString().c_str()); + + if(mapTxLockReq.count(it->second.txHash)){ + CTransaction& tx = mapTxLockReq[it->second.txHash]; + + BOOST_FOREACH(const CTxIn& in, tx.vin) + mapLockedInputs.erase(in.prevout); + + mapTxLockReq.erase(it->second.txHash); + mapTxLockReqRejected.erase(it->second.txHash); + + BOOST_FOREACH(CConsensusVote& v, it->second.vecConsensusVotes) + mapTxLockVote.erase(v.GetHash()); + } + + mapTxLocks.erase(it++); + } else { + it++; + } + } + +} + +uint256 CConsensusVote::GetHash() const +{ + return vinMasternode.prevout.hash + vinMasternode.prevout.n + txHash; +} + + +bool CConsensusVote::SignatureValid() +{ + std::string errorMessage; + std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast(nBlockHeight); + //LogPrintf("verify strMessage %s \n", strMessage.c_str()); + + int n = GetMasternodeByVin(vinMasternode); + + if(n == -1) + { + LogPrintf("InstantX::CConsensusVote::SignatureValid() - Unknown Masternode\n"); + return false; + } + + //LogPrintf("verify addr %s \n", vecMasternodes[0].addr.ToString().c_str()); + //LogPrintf("verify addr %s \n", vecMasternodes[1].addr.ToString().c_str()); + //LogPrintf("verify addr %d %s \n", n, vecMasternodes[n].addr.ToString().c_str()); + + CScript pubkey; + pubkey =GetScriptForDestination(vecMasternodes[n].pubkey2.GetID()); + CTxDestination address1; + ExtractDestination(pubkey, address1); + CBitcoinAddress address2(address1); + //LogPrintf("verify pubkey2 %s \n", address2.ToString().c_str()); + + if(!darkSendSigner.VerifyMessage(vecMasternodes[n].pubkey2, vchMasterNodeSignature, strMessage, errorMessage)) { + LogPrintf("InstantX::CConsensusVote::SignatureValid() - Verify message failed\n"); + return false; + } + + return true; +} + +bool CConsensusVote::Sign() +{ + std::string errorMessage; + + CKey key2; + CPubKey pubkey2; + std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast(nBlockHeight); + //LogPrintf("signing strMessage %s \n", strMessage.c_str()); + //LogPrintf("signing privkey %s \n", strMasterNodePrivKey.c_str()); + + if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, key2, pubkey2)) + { + LogPrintf("CActiveMasternode::RegisterAsMasterNode() - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage.c_str()); + return false; + } + + CScript pubkey; + pubkey =GetScriptForDestination(pubkey2.GetID()); + CTxDestination address1; + ExtractDestination(pubkey, address1); + CBitcoinAddress address2(address1); + //LogPrintf("signing pubkey2 %s \n", address2.ToString().c_str()); + + if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchMasterNodeSignature, key2)) { + LogPrintf("CActiveMasternode::RegisterAsMasterNode() - Sign message failed"); + return false; + } + + if(!darkSendSigner.VerifyMessage(pubkey2, vchMasterNodeSignature, strMessage, errorMessage)) { + LogPrintf("CActiveMasternode::RegisterAsMasterNode() - Verify message failed"); + return false; + } + + return true; +} + + +bool CTransactionLock::SignaturesValid() +{ + + BOOST_FOREACH(CConsensusVote vote, vecConsensusVotes) + { + int n = GetMasternodeRank(vote.vinMasternode, vote.nBlockHeight, MIN_INSTANTX_PROTO_VERSION); + + if(n == -1) + { + LogPrintf("InstantX::DoConsensusVote - Unknown Masternode\n"); + return false; + } + + if(n > INSTANTX_SIGNATURES_TOTAL) + { + LogPrintf("InstantX::DoConsensusVote - Masternode not in the top %s\n", INSTANTX_SIGNATURES_TOTAL); + return false; + } + + if(!vote.SignatureValid()){ + LogPrintf("InstantX::CTransactionLock::SignaturesValid - Signature not valid\n"); + return false; + } + } + + return true; +} + +void CTransactionLock::AddSignature(CConsensusVote& cv) +{ + vecConsensusVotes.push_back(cv); +} + +int CTransactionLock::CountSignatures() +{ + /* + Only count signatures where the BlockHeight matches the transaction's blockheight. + The votes have no proof it's the correct blockheight + */ + + if(nBlockHeight == 0) return -1; + + int n = 0; + BOOST_FOREACH(CConsensusVote v, vecConsensusVotes){ + if(v.nBlockHeight == nBlockHeight){ + n++; + } + } + return n; +} diff --git a/src/instantx.h b/src/instantx.h new file mode 100644 index 0000000..3b3c173 --- /dev/null +++ b/src/instantx.h @@ -0,0 +1,99 @@ + +// Copyright (c) 2009-2012 The Darkcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef INSTANTX_H +#define INSTANTX_H + +#include "uint256.h" +#include "sync.h" +#include "net.h" +#include "key.h" +//#include "primitives/transaction.h" +#include "util.h" +//#include "script/script.h" +#include "script.h" +#include "base58.h" +#include "main.h" + +using namespace std; +using namespace boost; + +class CConsensusVote; +class CTransaction; +class CTransactionLock; + +extern map mapTxLockReq; +extern map mapTxLockReqRejected; +extern map mapTxLockVote; +extern map mapTxLocks; +extern std::map mapLockedInputs; +extern int nCompleteTXLocks; + + +int64_t CreateNewLock(CTransaction tx); + +bool IsIXTXValid(const CTransaction& txCollateral); + +// if two conflicting locks are approved by the network, they will cancel out +bool CheckForConflictingLocks(CTransaction& tx); + +void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); + +//check if we need to vote on this transaction +void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight); + +//process consensus vote message +bool ProcessConsensusVote(CConsensusVote& ctx); + +// keep transaction locks in memory for an hour +void CleanTransactionLocksList(); + +int64_t GetAverageVoteTime(); + +class CConsensusVote +{ +public: + CTxIn vinMasternode; + uint256 txHash; + int nBlockHeight; + std::vector vchMasterNodeSignature; + + uint256 GetHash() const; + + bool SignatureValid(); + bool Sign(); + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + unsigned int nSerSize = 0; + READWRITE(txHash); + READWRITE(vinMasternode); + READWRITE(vchMasterNodeSignature); + READWRITE(nBlockHeight); + } +}; + +class CTransactionLock +{ +public: + int nBlockHeight; + uint256 txHash; + std::vector vecConsensusVotes; + int nExpiration; + int nTimeout; + + bool SignaturesValid(); + int CountSignatures(); + void AddSignature(CConsensusVote& cv); + + uint256 GetHash() + { + return txHash; + } +}; + + +#endif diff --git a/src/json/LICENSE.txt b/src/json/LICENSE.txt new file mode 100644 index 0000000..797d536 --- /dev/null +++ b/src/json/LICENSE.txt @@ -0,0 +1,24 @@ +The MIT License + +Copyright (c) 2007 - 2009 John W. Wilkinson + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/json/json_spirit.h b/src/json/json_spirit.h new file mode 100644 index 0000000..ac1879d --- /dev/null +++ b/src/json/json_spirit.h @@ -0,0 +1,18 @@ +#ifndef JSON_SPIRIT +#define JSON_SPIRIT + +// Copyright John W. Wilkinson 2007 - 2009. +// Distributed under the MIT License, see accompanying file LICENSE.txt + +// json spirit version 4.03 + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include "json_spirit_value.h" +#include "json_spirit_reader.h" +#include "json_spirit_writer.h" +#include "json_spirit_utils.h" + +#endif diff --git a/src/json/json_spirit_error_position.h b/src/json/json_spirit_error_position.h new file mode 100644 index 0000000..1720850 --- /dev/null +++ b/src/json/json_spirit_error_position.h @@ -0,0 +1,54 @@ +#ifndef JSON_SPIRIT_ERROR_POSITION +#define JSON_SPIRIT_ERROR_POSITION + +// Copyright John W. Wilkinson 2007 - 2009. +// Distributed under the MIT License, see accompanying file LICENSE.txt + +// json spirit version 4.03 + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include + +namespace json_spirit +{ + // An Error_position exception is thrown by the "read_or_throw" functions below on finding an error. + // Note the "read_or_throw" functions are around 3 times slower than the standard functions "read" + // functions that return a bool. + // + struct Error_position + { + Error_position(); + Error_position( unsigned int line, unsigned int column, const std::string& reason ); + bool operator==( const Error_position& lhs ) const; + unsigned int line_; + unsigned int column_; + std::string reason_; + }; + + inline Error_position::Error_position() + : line_( 0 ) + , column_( 0 ) + { + } + + inline Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason ) + : line_( line ) + , column_( column ) + , reason_( reason ) + { + } + + inline bool Error_position::operator==( const Error_position& lhs ) const + { + if( this == &lhs ) return true; + + return ( reason_ == lhs.reason_ ) && + ( line_ == lhs.line_ ) && + ( column_ == lhs.column_ ); +} +} + +#endif diff --git a/src/json/json_spirit_reader.cpp b/src/json/json_spirit_reader.cpp new file mode 100644 index 0000000..aa4f637 --- /dev/null +++ b/src/json/json_spirit_reader.cpp @@ -0,0 +1,137 @@ +// Copyright John W. Wilkinson 2007 - 2009. +// Distributed under the MIT License, see accompanying file LICENSE.txt + +// json spirit version 4.03 + +#include "json_spirit_reader.h" +#include "json_spirit_reader_template.h" + +using namespace json_spirit; + +bool json_spirit::read( const std::string& s, Value& value ) +{ + return read_string( s, value ); +} + +void json_spirit::read_or_throw( const std::string& s, Value& value ) +{ + read_string_or_throw( s, value ); +} + +bool json_spirit::read( std::istream& is, Value& value ) +{ + return read_stream( is, value ); +} + +void json_spirit::read_or_throw( std::istream& is, Value& value ) +{ + read_stream_or_throw( is, value ); +} + +bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ) +{ + return read_range( begin, end, value ); +} + +void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ) +{ + begin = read_range_or_throw( begin, end, value ); +} + +#ifndef BOOST_NO_STD_WSTRING + +bool json_spirit::read( const std::wstring& s, wValue& value ) +{ + return read_string( s, value ); +} + +void json_spirit::read_or_throw( const std::wstring& s, wValue& value ) +{ + read_string_or_throw( s, value ); +} + +bool json_spirit::read( std::wistream& is, wValue& value ) +{ + return read_stream( is, value ); +} + +void json_spirit::read_or_throw( std::wistream& is, wValue& value ) +{ + read_stream_or_throw( is, value ); +} + +bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ) +{ + return read_range( begin, end, value ); +} + +void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ) +{ + begin = read_range_or_throw( begin, end, value ); +} + +#endif + +bool json_spirit::read( const std::string& s, mValue& value ) +{ + return read_string( s, value ); +} + +void json_spirit::read_or_throw( const std::string& s, mValue& value ) +{ + read_string_or_throw( s, value ); +} + +bool json_spirit::read( std::istream& is, mValue& value ) +{ + return read_stream( is, value ); +} + +void json_spirit::read_or_throw( std::istream& is, mValue& value ) +{ + read_stream_or_throw( is, value ); +} + +bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ) +{ + return read_range( begin, end, value ); +} + +void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ) +{ + begin = read_range_or_throw( begin, end, value ); +} + +#ifndef BOOST_NO_STD_WSTRING + +bool json_spirit::read( const std::wstring& s, wmValue& value ) +{ + return read_string( s, value ); +} + +void json_spirit::read_or_throw( const std::wstring& s, wmValue& value ) +{ + read_string_or_throw( s, value ); +} + +bool json_spirit::read( std::wistream& is, wmValue& value ) +{ + return read_stream( is, value ); +} + +void json_spirit::read_or_throw( std::wistream& is, wmValue& value ) +{ + read_stream_or_throw( is, value ); +} + +bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ) +{ + return read_range( begin, end, value ); +} + +void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ) +{ + begin = read_range_or_throw( begin, end, value ); +} + +#endif diff --git a/src/json/json_spirit_reader.h b/src/json/json_spirit_reader.h new file mode 100644 index 0000000..96494a9 --- /dev/null +++ b/src/json/json_spirit_reader.h @@ -0,0 +1,62 @@ +#ifndef JSON_SPIRIT_READER +#define JSON_SPIRIT_READER + +// Copyright John W. Wilkinson 2007 - 2009. +// Distributed under the MIT License, see accompanying file LICENSE.txt + +// json spirit version 4.03 + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include "json_spirit_value.h" +#include "json_spirit_error_position.h" +#include + +namespace json_spirit +{ + // functions to reads a JSON values + + bool read( const std::string& s, Value& value ); + bool read( std::istream& is, Value& value ); + bool read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ); + + void read_or_throw( const std::string& s, Value& value ); + void read_or_throw( std::istream& is, Value& value ); + void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ); + +#ifndef BOOST_NO_STD_WSTRING + + bool read( const std::wstring& s, wValue& value ); + bool read( std::wistream& is, wValue& value ); + bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ); + + void read_or_throw( const std::wstring& s, wValue& value ); + void read_or_throw( std::wistream& is, wValue& value ); + void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ); + +#endif + + bool read( const std::string& s, mValue& value ); + bool read( std::istream& is, mValue& value ); + bool read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ); + + void read_or_throw( const std::string& s, mValue& value ); + void read_or_throw( std::istream& is, mValue& value ); + void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ); + +#ifndef BOOST_NO_STD_WSTRING + + bool read( const std::wstring& s, wmValue& value ); + bool read( std::wistream& is, wmValue& value ); + bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ); + + void read_or_throw( const std::wstring& s, wmValue& value ); + void read_or_throw( std::wistream& is, wmValue& value ); + void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ); + +#endif +} + +#endif diff --git a/src/json/json_spirit_reader_template.h b/src/json/json_spirit_reader_template.h new file mode 100644 index 0000000..46f5892 --- /dev/null +++ b/src/json/json_spirit_reader_template.h @@ -0,0 +1,612 @@ +#ifndef JSON_SPIRIT_READER_TEMPLATE +#define JSON_SPIRIT_READER_TEMPLATE + +// Copyright John W. Wilkinson 2007 - 2009. +// Distributed under the MIT License, see accompanying file LICENSE.txt + +// json spirit version 4.03 + +#include "json_spirit_value.h" +#include "json_spirit_error_position.h" + +//#define BOOST_SPIRIT_THREADSAFE // uncomment for multithreaded use, requires linking to boost.thread + +#include +#include +#include + +#if BOOST_VERSION >= 103800 + #include + #include + #include + #include + #include + #define spirit_namespace boost::spirit::classic +#else + #include + #include + #include + #include + #include + #define spirit_namespace boost::spirit +#endif + +namespace json_spirit +{ + const spirit_namespace::int_parser < int64_t > int64_p = spirit_namespace::int_parser < int64_t >(); + const spirit_namespace::uint_parser< uint64_t > uint64_p = spirit_namespace::uint_parser< uint64_t >(); + + template< class Iter_type > + bool is_eq( Iter_type first, Iter_type last, const char* c_str ) + { + for( Iter_type i = first; i != last; ++i, ++c_str ) + { + if( *c_str == 0 ) return false; + + if( *i != *c_str ) return false; + } + + return true; + } + + template< class Char_type > + Char_type hex_to_num( const Char_type c ) + { + if( ( c >= '0' ) && ( c <= '9' ) ) return c - '0'; + if( ( c >= 'a' ) && ( c <= 'f' ) ) return c - 'a' + 10; + if( ( c >= 'A' ) && ( c <= 'F' ) ) return c - 'A' + 10; + return 0; + } + + template< class Char_type, class Iter_type > + Char_type hex_str_to_char( Iter_type& begin ) + { + const Char_type c1( *( ++begin ) ); + const Char_type c2( *( ++begin ) ); + + return ( hex_to_num( c1 ) << 4 ) + hex_to_num( c2 ); + } + + template< class Char_type, class Iter_type > + Char_type unicode_str_to_char( Iter_type& begin ) + { + const Char_type c1( *( ++begin ) ); + const Char_type c2( *( ++begin ) ); + const Char_type c3( *( ++begin ) ); + const Char_type c4( *( ++begin ) ); + + return ( hex_to_num( c1 ) << 12 ) + + ( hex_to_num( c2 ) << 8 ) + + ( hex_to_num( c3 ) << 4 ) + + hex_to_num( c4 ); + } + + template< class String_type > + void append_esc_char_and_incr_iter( String_type& s, + typename String_type::const_iterator& begin, + typename String_type::const_iterator end ) + { + typedef typename String_type::value_type Char_type; + + const Char_type c2( *begin ); + + switch( c2 ) + { + case 't': s += '\t'; break; + case 'b': s += '\b'; break; + case 'f': s += '\f'; break; + case 'n': s += '\n'; break; + case 'r': s += '\r'; break; + case '\\': s += '\\'; break; + case '/': s += '/'; break; + case '"': s += '"'; break; + case 'x': + { + if( end - begin >= 3 ) // expecting "xHH..." + { + s += hex_str_to_char< Char_type >( begin ); + } + break; + } + case 'u': + { + if( end - begin >= 5 ) // expecting "uHHHH..." + { + s += unicode_str_to_char< Char_type >( begin ); + } + break; + } + } + } + + template< class String_type > + String_type substitute_esc_chars( typename String_type::const_iterator begin, + typename String_type::const_iterator end ) + { + typedef typename String_type::const_iterator Iter_type; + + if( end - begin < 2 ) return String_type( begin, end ); + + String_type result; + + result.reserve( end - begin ); + + const Iter_type end_minus_1( end - 1 ); + + Iter_type substr_start = begin; + Iter_type i = begin; + + for( ; i < end_minus_1; ++i ) + { + if( *i == '\\' ) + { + result.append( substr_start, i ); + + ++i; // skip the '\' + + append_esc_char_and_incr_iter( result, i, end ); + + substr_start = i + 1; + } + } + + result.append( substr_start, end ); + + return result; + } + + template< class String_type > + String_type get_str_( typename String_type::const_iterator begin, + typename String_type::const_iterator end ) + { + assert( end - begin >= 2 ); + + typedef typename String_type::const_iterator Iter_type; + + Iter_type str_without_quotes( ++begin ); + Iter_type end_without_quotes( --end ); + + return substitute_esc_chars< String_type >( str_without_quotes, end_without_quotes ); + } + + inline std::string get_str( std::string::const_iterator begin, std::string::const_iterator end ) + { + return get_str_< std::string >( begin, end ); + } + + inline std::wstring get_str( std::wstring::const_iterator begin, std::wstring::const_iterator end ) + { + return get_str_< std::wstring >( begin, end ); + } + + template< class String_type, class Iter_type > + String_type get_str( Iter_type begin, Iter_type end ) + { + const String_type tmp( begin, end ); // convert multipass iterators to string iterators + + return get_str( tmp.begin(), tmp.end() ); + } + + // this class's methods get called by the spirit parse resulting + // in the creation of a JSON object or array + // + // NB Iter_type could be a std::string iterator, wstring iterator, a position iterator or a multipass iterator + // + template< class Value_type, class Iter_type > + class Semantic_actions + { + public: + + typedef typename Value_type::Config_type Config_type; + typedef typename Config_type::String_type String_type; + typedef typename Config_type::Object_type Object_type; + typedef typename Config_type::Array_type Array_type; + typedef typename String_type::value_type Char_type; + + Semantic_actions( Value_type& value ) + : value_( value ) + , current_p_( 0 ) + { + } + + void begin_obj( Char_type c ) + { + assert( c == '{' ); + + begin_compound< Object_type >(); + } + + void end_obj( Char_type c ) + { + assert( c == '}' ); + + end_compound(); + } + + void begin_array( Char_type c ) + { + assert( c == '[' ); + + begin_compound< Array_type >(); + } + + void end_array( Char_type c ) + { + assert( c == ']' ); + + end_compound(); + } + + void new_name( Iter_type begin, Iter_type end ) + { + assert( current_p_->type() == obj_type ); + + name_ = get_str< String_type >( begin, end ); + } + + void new_str( Iter_type begin, Iter_type end ) + { + add_to_current( get_str< String_type >( begin, end ) ); + } + + void new_true( Iter_type begin, Iter_type end ) + { + assert( is_eq( begin, end, "true" ) ); + + add_to_current( true ); + } + + void new_false( Iter_type begin, Iter_type end ) + { + assert( is_eq( begin, end, "false" ) ); + + add_to_current( false ); + } + + void new_null( Iter_type begin, Iter_type end ) + { + assert( is_eq( begin, end, "null" ) ); + + add_to_current( Value_type() ); + } + + void new_int( int64_t i ) + { + add_to_current( i ); + } + + void new_uint64( uint64_t ui ) + { + add_to_current( ui ); + } + + void new_real( double d ) + { + add_to_current( d ); + } + + private: + + Semantic_actions& operator=( const Semantic_actions& ); + // to prevent "assignment operator could not be generated" warning + + Value_type* add_first( const Value_type& value ) + { + assert( current_p_ == 0 ); + + value_ = value; + current_p_ = &value_; + return current_p_; + } + + template< class Array_or_obj > + void begin_compound() + { + if( current_p_ == 0 ) + { + add_first( Array_or_obj() ); + } + else + { + stack_.push_back( current_p_ ); + + Array_or_obj new_array_or_obj; // avoid copy by building new array or object in place + + current_p_ = add_to_current( new_array_or_obj ); + } + } + + void end_compound() + { + if( current_p_ != &value_ ) + { + current_p_ = stack_.back(); + + stack_.pop_back(); + } + } + + Value_type* add_to_current( const Value_type& value ) + { + if( current_p_ == 0 ) + { + return add_first( value ); + } + else if( current_p_->type() == array_type ) + { + current_p_->get_array().push_back( value ); + + return ¤t_p_->get_array().back(); + } + + assert( current_p_->type() == obj_type ); + + return &Config_type::add( current_p_->get_obj(), name_, value ); + } + + Value_type& value_; // this is the object or array that is being created + Value_type* current_p_; // the child object or array that is currently being constructed + + std::vector< Value_type* > stack_; // previous child objects and arrays + + String_type name_; // of current name/value pair + }; + + template< typename Iter_type > + void throw_error( spirit_namespace::position_iterator< Iter_type > i, const std::string& reason ) + { + throw Error_position( i.get_position().line, i.get_position().column, reason ); + } + + template< typename Iter_type > + void throw_error( Iter_type i, const std::string& reason ) + { + throw reason; + } + + // the spirit grammer + // + template< class Value_type, class Iter_type > + class Json_grammer : public spirit_namespace::grammar< Json_grammer< Value_type, Iter_type > > + { + public: + + typedef Semantic_actions< Value_type, Iter_type > Semantic_actions_t; + + Json_grammer( Semantic_actions_t& semantic_actions ) + : actions_( semantic_actions ) + { + } + + static void throw_not_value( Iter_type begin, Iter_type end ) + { + throw_error( begin, "not a value" ); + } + + static void throw_not_array( Iter_type begin, Iter_type end ) + { + throw_error( begin, "not an array" ); + } + + static void throw_not_object( Iter_type begin, Iter_type end ) + { + throw_error( begin, "not an object" ); + } + + static void throw_not_pair( Iter_type begin, Iter_type end ) + { + throw_error( begin, "not a pair" ); + } + + static void throw_not_colon( Iter_type begin, Iter_type end ) + { + throw_error( begin, "no colon in pair" ); + } + + static void throw_not_string( Iter_type begin, Iter_type end ) + { + throw_error( begin, "not a string" ); + } + + template< typename ScannerT > + class definition + { + public: + + definition( const Json_grammer& self ) + { + using namespace spirit_namespace; + + typedef typename Value_type::String_type::value_type Char_type; + + // first we convert the semantic action class methods to functors with the + // parameter signature expected by spirit + + typedef boost::function< void( Char_type ) > Char_action; + typedef boost::function< void( Iter_type, Iter_type ) > Str_action; + typedef boost::function< void( double ) > Real_action; + typedef boost::function< void( int64_t ) > Int_action; + typedef boost::function< void( uint64_t ) > Uint64_action; + + Char_action begin_obj ( boost::bind( &Semantic_actions_t::begin_obj, &self.actions_, _1 ) ); + Char_action end_obj ( boost::bind( &Semantic_actions_t::end_obj, &self.actions_, _1 ) ); + Char_action begin_array( boost::bind( &Semantic_actions_t::begin_array, &self.actions_, _1 ) ); + Char_action end_array ( boost::bind( &Semantic_actions_t::end_array, &self.actions_, _1 ) ); + Str_action new_name ( boost::bind( &Semantic_actions_t::new_name, &self.actions_, _1, _2 ) ); + Str_action new_str ( boost::bind( &Semantic_actions_t::new_str, &self.actions_, _1, _2 ) ); + Str_action new_true ( boost::bind( &Semantic_actions_t::new_true, &self.actions_, _1, _2 ) ); + Str_action new_false ( boost::bind( &Semantic_actions_t::new_false, &self.actions_, _1, _2 ) ); + Str_action new_null ( boost::bind( &Semantic_actions_t::new_null, &self.actions_, _1, _2 ) ); + Real_action new_real ( boost::bind( &Semantic_actions_t::new_real, &self.actions_, _1 ) ); + Int_action new_int ( boost::bind( &Semantic_actions_t::new_int, &self.actions_, _1 ) ); + Uint64_action new_uint64 ( boost::bind( &Semantic_actions_t::new_uint64, &self.actions_, _1 ) ); + + // actual grammer + + json_ + = value_ | eps_p[ &throw_not_value ] + ; + + value_ + = string_[ new_str ] + | number_ + | object_ + | array_ + | str_p( "true" ) [ new_true ] + | str_p( "false" )[ new_false ] + | str_p( "null" ) [ new_null ] + ; + + object_ + = ch_p('{')[ begin_obj ] + >> !members_ + >> ( ch_p('}')[ end_obj ] | eps_p[ &throw_not_object ] ) + ; + + members_ + = pair_ >> *( ',' >> pair_ ) + ; + + pair_ + = string_[ new_name ] + >> ( ':' | eps_p[ &throw_not_colon ] ) + >> ( value_ | eps_p[ &throw_not_value ] ) + ; + + array_ + = ch_p('[')[ begin_array ] + >> !elements_ + >> ( ch_p(']')[ end_array ] | eps_p[ &throw_not_array ] ) + ; + + elements_ + = value_ >> *( ',' >> value_ ) + ; + + string_ + = lexeme_d // this causes white space inside a string to be retained + [ + confix_p + ( + '"', + *lex_escape_ch_p, + '"' + ) + ] + ; + + number_ + = strict_real_p[ new_real ] + | int64_p [ new_int ] + | uint64_p [ new_uint64 ] + ; + } + + spirit_namespace::rule< ScannerT > json_, object_, members_, pair_, array_, elements_, value_, string_, number_; + + const spirit_namespace::rule< ScannerT >& start() const { return json_; } + }; + + private: + + Json_grammer& operator=( const Json_grammer& ); // to prevent "assignment operator could not be generated" warning + + Semantic_actions_t& actions_; + }; + + template< class Iter_type, class Value_type > + Iter_type read_range_or_throw( Iter_type begin, Iter_type end, Value_type& value ) + { + Semantic_actions< Value_type, Iter_type > semantic_actions( value ); + + const spirit_namespace::parse_info< Iter_type > info = + spirit_namespace::parse( begin, end, + Json_grammer< Value_type, Iter_type >( semantic_actions ), + spirit_namespace::space_p ); + + if( !info.hit ) + { + assert( false ); // in theory exception should already have been thrown + throw_error( info.stop, "error" ); + } + + return info.stop; + } + + template< class Iter_type, class Value_type > + void add_posn_iter_and_read_range_or_throw( Iter_type begin, Iter_type end, Value_type& value ) + { + typedef spirit_namespace::position_iterator< Iter_type > Posn_iter_t; + + const Posn_iter_t posn_begin( begin, end ); + const Posn_iter_t posn_end( end, end ); + + read_range_or_throw( posn_begin, posn_end, value ); + } + + template< class Iter_type, class Value_type > + bool read_range( Iter_type& begin, Iter_type end, Value_type& value ) + { + try + { + begin = read_range_or_throw( begin, end, value ); + + return true; + } + catch( ... ) + { + return false; + } + } + + template< class String_type, class Value_type > + void read_string_or_throw( const String_type& s, Value_type& value ) + { + add_posn_iter_and_read_range_or_throw( s.begin(), s.end(), value ); + } + + template< class String_type, class Value_type > + bool read_string( const String_type& s, Value_type& value ) + { + typename String_type::const_iterator begin = s.begin(); + + return read_range( begin, s.end(), value ); + } + + template< class Istream_type > + struct Multi_pass_iters + { + typedef typename Istream_type::char_type Char_type; + typedef std::istream_iterator< Char_type, Char_type > istream_iter; + typedef spirit_namespace::multi_pass< istream_iter > Mp_iter; + + Multi_pass_iters( Istream_type& is ) + { + is.unsetf( std::ios::skipws ); + + begin_ = spirit_namespace::make_multi_pass( istream_iter( is ) ); + end_ = spirit_namespace::make_multi_pass( istream_iter() ); + } + + Mp_iter begin_; + Mp_iter end_; + }; + + template< class Istream_type, class Value_type > + bool read_stream( Istream_type& is, Value_type& value ) + { + Multi_pass_iters< Istream_type > mp_iters( is ); + + return read_range( mp_iters.begin_, mp_iters.end_, value ); + } + + template< class Istream_type, class Value_type > + void read_stream_or_throw( Istream_type& is, Value_type& value ) + { + const Multi_pass_iters< Istream_type > mp_iters( is ); + + add_posn_iter_and_read_range_or_throw( mp_iters.begin_, mp_iters.end_, value ); + } +} + +#endif diff --git a/src/json/json_spirit_stream_reader.h b/src/json/json_spirit_stream_reader.h new file mode 100644 index 0000000..7e59c9a --- /dev/null +++ b/src/json/json_spirit_stream_reader.h @@ -0,0 +1,70 @@ +#ifndef JSON_SPIRIT_READ_STREAM +#define JSON_SPIRIT_READ_STREAM + +// Copyright John W. Wilkinson 2007 - 2009. +// Distributed under the MIT License, see accompanying file LICENSE.txt + +// json spirit version 4.03 + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include "json_spirit_reader_template.h" + +namespace json_spirit +{ + // these classes allows you to read multiple top level contiguous values from a stream, + // the normal stream read functions have a bug that prevent multiple top level values + // from being read unless they are separated by spaces + + template< class Istream_type, class Value_type > + class Stream_reader + { + public: + + Stream_reader( Istream_type& is ) + : iters_( is ) + { + } + + bool read_next( Value_type& value ) + { + return read_range( iters_.begin_, iters_.end_, value ); + } + + private: + + typedef Multi_pass_iters< Istream_type > Mp_iters; + + Mp_iters iters_; + }; + + template< class Istream_type, class Value_type > + class Stream_reader_thrower + { + public: + + Stream_reader_thrower( Istream_type& is ) + : iters_( is ) + , posn_begin_( iters_.begin_, iters_.end_ ) + , posn_end_( iters_.end_, iters_.end_ ) + { + } + + void read_next( Value_type& value ) + { + posn_begin_ = read_range_or_throw( posn_begin_, posn_end_, value ); + } + + private: + + typedef Multi_pass_iters< Istream_type > Mp_iters; + typedef spirit_namespace::position_iterator< typename Mp_iters::Mp_iter > Posn_iter_t; + + Mp_iters iters_; + Posn_iter_t posn_begin_, posn_end_; + }; +} + +#endif diff --git a/src/json/json_spirit_utils.h b/src/json/json_spirit_utils.h new file mode 100644 index 0000000..553e3b9 --- /dev/null +++ b/src/json/json_spirit_utils.h @@ -0,0 +1,61 @@ +#ifndef JSON_SPIRIT_UTILS +#define JSON_SPIRIT_UTILS + +// Copyright John W. Wilkinson 2007 - 2009. +// Distributed under the MIT License, see accompanying file LICENSE.txt + +// json spirit version 4.03 + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include "json_spirit_value.h" +#include + +namespace json_spirit +{ + template< class Obj_t, class Map_t > + void obj_to_map( const Obj_t& obj, Map_t& mp_obj ) + { + mp_obj.clear(); + + for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i ) + { + mp_obj[ i->name_ ] = i->value_; + } + } + + template< class Obj_t, class Map_t > + void map_to_obj( const Map_t& mp_obj, Obj_t& obj ) + { + obj.clear(); + + for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i ) + { + obj.push_back( typename Obj_t::value_type( i->first, i->second ) ); + } + } + + typedef std::map< std::string, Value > Mapped_obj; + +#ifndef BOOST_NO_STD_WSTRING + typedef std::map< std::wstring, wValue > wMapped_obj; +#endif + + template< class Object_type, class String_type > + const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name ) + { + for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i ) + { + if( i->name_ == name ) + { + return i->value_; + } + } + + return Object_type::value_type::Value_type::null; + } +} + +#endif diff --git a/src/json/json_spirit_value.cpp b/src/json/json_spirit_value.cpp new file mode 100644 index 0000000..44d2f06 --- /dev/null +++ b/src/json/json_spirit_value.cpp @@ -0,0 +1,8 @@ +/* Copyright (c) 2007 John W Wilkinson + + This source code can be used for any purpose as long as + this comment is retained. */ + +// json spirit version 2.00 + +#include "json_spirit_value.h" diff --git a/src/json/json_spirit_value.h b/src/json/json_spirit_value.h new file mode 100644 index 0000000..13cc892 --- /dev/null +++ b/src/json/json_spirit_value.h @@ -0,0 +1,534 @@ +#ifndef JSON_SPIRIT_VALUE +#define JSON_SPIRIT_VALUE + +// Copyright John W. Wilkinson 2007 - 2009. +// Distributed under the MIT License, see accompanying file LICENSE.txt + +// json spirit version 4.03 + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace json_spirit +{ + enum Value_type{ obj_type, array_type, str_type, bool_type, int_type, real_type, null_type }; + static const char* Value_type_name[]={"obj", "array", "str", "bool", "int", "real", "null"}; + + template< class Config > // Config determines whether the value uses std::string or std::wstring and + // whether JSON Objects are represented as vectors or maps + class Value_impl + { + public: + + typedef Config Config_type; + typedef typename Config::String_type String_type; + typedef typename Config::Object_type Object; + typedef typename Config::Array_type Array; + typedef typename String_type::const_pointer Const_str_ptr; // eg const char* + + Value_impl(); // creates null value + Value_impl( Const_str_ptr value ); + Value_impl( const String_type& value ); + Value_impl( const Object& value ); + Value_impl( const Array& value ); + Value_impl( bool value ); + Value_impl( int value ); + Value_impl( int64_t value ); + Value_impl( uint64_t value ); + Value_impl( double value ); + + Value_impl( const Value_impl& other ); + + bool operator==( const Value_impl& lhs ) const; + + Value_impl& operator=( const Value_impl& lhs ); + + Value_type type() const; + + bool is_uint64() const; + bool is_null() const; + + const String_type& get_str() const; + const Object& get_obj() const; + const Array& get_array() const; + bool get_bool() const; + int get_int() const; + int64_t get_int64() const; + uint64_t get_uint64() const; + double get_real() const; + + Object& get_obj(); + Array& get_array(); + + template< typename T > T get_value() const; // example usage: int i = value.get_value< int >(); + // or double d = value.get_value< double >(); + + static const Value_impl null; + + private: + + void check_type( const Value_type vtype ) const; + + typedef boost::variant< String_type, + boost::recursive_wrapper< Object >, boost::recursive_wrapper< Array >, + bool, int64_t, double > Variant; + + Value_type type_; + Variant v_; + bool is_uint64_; + }; + + // vector objects + + template< class Config > + struct Pair_impl + { + typedef typename Config::String_type String_type; + typedef typename Config::Value_type Value_type; + + Pair_impl( const String_type& name, const Value_type& value ); + + bool operator==( const Pair_impl& lhs ) const; + + String_type name_; + Value_type value_; + }; + + template< class String > + struct Config_vector + { + typedef String String_type; + typedef Value_impl< Config_vector > Value_type; + typedef Pair_impl < Config_vector > Pair_type; + typedef std::vector< Value_type > Array_type; + typedef std::vector< Pair_type > Object_type; + + static Value_type& add( Object_type& obj, const String_type& name, const Value_type& value ) + { + obj.push_back( Pair_type( name , value ) ); + + return obj.back().value_; + } + + static String_type get_name( const Pair_type& pair ) + { + return pair.name_; + } + + static Value_type get_value( const Pair_type& pair ) + { + return pair.value_; + } + }; + + // typedefs for ASCII + + typedef Config_vector< std::string > Config; + + typedef Config::Value_type Value; + typedef Config::Pair_type Pair; + typedef Config::Object_type Object; + typedef Config::Array_type Array; + + // typedefs for Unicode + +#ifndef BOOST_NO_STD_WSTRING + + typedef Config_vector< std::wstring > wConfig; + + typedef wConfig::Value_type wValue; + typedef wConfig::Pair_type wPair; + typedef wConfig::Object_type wObject; + typedef wConfig::Array_type wArray; +#endif + + // map objects + + template< class String > + struct Config_map + { + typedef String String_type; + typedef Value_impl< Config_map > Value_type; + typedef std::vector< Value_type > Array_type; + typedef std::map< String_type, Value_type > Object_type; + typedef typename Object_type::value_type Pair_type; + + static Value_type& add( Object_type& obj, const String_type& name, const Value_type& value ) + { + return obj[ name ] = value; + } + + static String_type get_name( const Pair_type& pair ) + { + return pair.first; + } + + static Value_type get_value( const Pair_type& pair ) + { + return pair.second; + } + }; + + // typedefs for ASCII + + typedef Config_map< std::string > mConfig; + + typedef mConfig::Value_type mValue; + typedef mConfig::Object_type mObject; + typedef mConfig::Array_type mArray; + + // typedefs for Unicode + +#ifndef BOOST_NO_STD_WSTRING + + typedef Config_map< std::wstring > wmConfig; + + typedef wmConfig::Value_type wmValue; + typedef wmConfig::Object_type wmObject; + typedef wmConfig::Array_type wmArray; + +#endif + + /////////////////////////////////////////////////////////////////////////////////////////////// + // + // implementation + + template< class Config > + const Value_impl< Config > Value_impl< Config >::null; + + template< class Config > + Value_impl< Config >::Value_impl() + : type_( null_type ) + , is_uint64_( false ) + { + } + + template< class Config > + Value_impl< Config >::Value_impl( const Const_str_ptr value ) + : type_( str_type ) + , v_( String_type( value ) ) + , is_uint64_( false ) + { + } + + template< class Config > + Value_impl< Config >::Value_impl( const String_type& value ) + : type_( str_type ) + , v_( value ) + , is_uint64_( false ) + { + } + + template< class Config > + Value_impl< Config >::Value_impl( const Object& value ) + : type_( obj_type ) + , v_( value ) + , is_uint64_( false ) + { + } + + template< class Config > + Value_impl< Config >::Value_impl( const Array& value ) + : type_( array_type ) + , v_( value ) + , is_uint64_( false ) + { + } + + template< class Config > + Value_impl< Config >::Value_impl( bool value ) + : type_( bool_type ) + , v_( value ) + , is_uint64_( false ) + { + } + + template< class Config > + Value_impl< Config >::Value_impl( int value ) + : type_( int_type ) + , v_( static_cast< int64_t >( value ) ) + , is_uint64_( false ) + { + } + + template< class Config > + Value_impl< Config >::Value_impl( int64_t value ) + : type_( int_type ) + , v_( value ) + , is_uint64_( false ) + { + } + + template< class Config > + Value_impl< Config >::Value_impl( uint64_t value ) + : type_( int_type ) + , v_( static_cast< int64_t >( value ) ) + , is_uint64_( true ) + { + } + + template< class Config > + Value_impl< Config >::Value_impl( double value ) + : type_( real_type ) + , v_( value ) + , is_uint64_( false ) + { + } + + template< class Config > + Value_impl< Config >::Value_impl( const Value_impl< Config >& other ) + : type_( other.type() ) + , v_( other.v_ ) + , is_uint64_( other.is_uint64_ ) + { + } + + template< class Config > + Value_impl< Config >& Value_impl< Config >::operator=( const Value_impl& lhs ) + { + Value_impl tmp( lhs ); + + std::swap( type_, tmp.type_ ); + std::swap( v_, tmp.v_ ); + std::swap( is_uint64_, tmp.is_uint64_ ); + + return *this; + } + + template< class Config > + bool Value_impl< Config >::operator==( const Value_impl& lhs ) const + { + if( this == &lhs ) return true; + + if( type() != lhs.type() ) return false; + + return v_ == lhs.v_; + } + + template< class Config > + Value_type Value_impl< Config >::type() const + { + return type_; + } + + template< class Config > + bool Value_impl< Config >::is_uint64() const + { + return is_uint64_; + } + + template< class Config > + bool Value_impl< Config >::is_null() const + { + return type() == null_type; + } + + template< class Config > + void Value_impl< Config >::check_type( const Value_type vtype ) const + { + if( type() != vtype ) + { + std::ostringstream os; + + ///// Bitcoin: Tell the types by name instead of by number + os << "value is type " << Value_type_name[type()] << ", expected " << Value_type_name[vtype]; + + throw std::runtime_error( os.str() ); + } + } + + template< class Config > + const typename Config::String_type& Value_impl< Config >::get_str() const + { + check_type( str_type ); + + return *boost::get< String_type >( &v_ ); + } + + template< class Config > + const typename Value_impl< Config >::Object& Value_impl< Config >::get_obj() const + { + check_type( obj_type ); + + return *boost::get< Object >( &v_ ); + } + + template< class Config > + const typename Value_impl< Config >::Array& Value_impl< Config >::get_array() const + { + check_type( array_type ); + + return *boost::get< Array >( &v_ ); + } + + template< class Config > + bool Value_impl< Config >::get_bool() const + { + check_type( bool_type ); + + return boost::get< bool >( v_ ); + } + + template< class Config > + int Value_impl< Config >::get_int() const + { + check_type( int_type ); + + return static_cast< int >( get_int64() ); + } + + template< class Config > + int64_t Value_impl< Config >::get_int64() const + { + check_type( int_type ); + + return boost::get< int64_t >( v_ ); + } + + template< class Config > + uint64_t Value_impl< Config >::get_uint64() const + { + check_type( int_type ); + + return static_cast< uint64_t >( get_int64() ); + } + + template< class Config > + double Value_impl< Config >::get_real() const + { + if( type() == int_type ) + { + return is_uint64() ? static_cast< double >( get_uint64() ) + : static_cast< double >( get_int64() ); + } + + check_type( real_type ); + + return boost::get< double >( v_ ); + } + + template< class Config > + typename Value_impl< Config >::Object& Value_impl< Config >::get_obj() + { + check_type( obj_type ); + + return *boost::get< Object >( &v_ ); + } + + template< class Config > + typename Value_impl< Config >::Array& Value_impl< Config >::get_array() + { + check_type( array_type ); + + return *boost::get< Array >( &v_ ); + } + + template< class Config > + Pair_impl< Config >::Pair_impl( const String_type& name, const Value_type& value ) + : name_( name ) + , value_( value ) + { + } + + template< class Config > + bool Pair_impl< Config >::operator==( const Pair_impl< Config >& lhs ) const + { + if( this == &lhs ) return true; + + return ( name_ == lhs.name_ ) && ( value_ == lhs.value_ ); + } + + // converts a C string, ie. 8 bit char array, to a string object + // + template < class String_type > + String_type to_str( const char* c_str ) + { + String_type result; + + for( const char* p = c_str; *p != 0; ++p ) + { + result += *p; + } + + return result; + } + + // + + namespace internal_ + { + template< typename T > + struct Type_to_type + { + }; + + template< class Value > + int get_value( const Value& value, Type_to_type< int > ) + { + return value.get_int(); + } + + template< class Value > + int64_t get_value( const Value& value, Type_to_type< int64_t > ) + { + return value.get_int64(); + } + + template< class Value > + uint64_t get_value( const Value& value, Type_to_type< uint64_t > ) + { + return value.get_uint64(); + } + + template< class Value > + double get_value( const Value& value, Type_to_type< double > ) + { + return value.get_real(); + } + + template< class Value > + typename Value::String_type get_value( const Value& value, Type_to_type< typename Value::String_type > ) + { + return value.get_str(); + } + + template< class Value > + typename Value::Array get_value( const Value& value, Type_to_type< typename Value::Array > ) + { + return value.get_array(); + } + + template< class Value > + typename Value::Object get_value( const Value& value, Type_to_type< typename Value::Object > ) + { + return value.get_obj(); + } + + template< class Value > + bool get_value( const Value& value, Type_to_type< bool > ) + { + return value.get_bool(); + } + } + + template< class Config > + template< typename T > + T Value_impl< Config >::get_value() const + { + return internal_::get_value( *this, internal_::Type_to_type< T >() ); + } +} + +#endif diff --git a/src/json/json_spirit_writer.cpp b/src/json/json_spirit_writer.cpp new file mode 100644 index 0000000..d24a632 --- /dev/null +++ b/src/json/json_spirit_writer.cpp @@ -0,0 +1,95 @@ +// Copyright John W. Wilkinson 2007 - 2009. +// Distributed under the MIT License, see accompanying file LICENSE.txt + +// json spirit version 4.03 + +#include "json_spirit_writer.h" +#include "json_spirit_writer_template.h" + +void json_spirit::write( const Value& value, std::ostream& os ) +{ + write_stream( value, os, false ); +} + +void json_spirit::write_formatted( const Value& value, std::ostream& os ) +{ + write_stream( value, os, true ); +} + +std::string json_spirit::write( const Value& value ) +{ + return write_string( value, false ); +} + +std::string json_spirit::write_formatted( const Value& value ) +{ + return write_string( value, true ); +} + +#ifndef BOOST_NO_STD_WSTRING + +void json_spirit::write( const wValue& value, std::wostream& os ) +{ + write_stream( value, os, false ); +} + +void json_spirit::write_formatted( const wValue& value, std::wostream& os ) +{ + write_stream( value, os, true ); +} + +std::wstring json_spirit::write( const wValue& value ) +{ + return write_string( value, false ); +} + +std::wstring json_spirit::write_formatted( const wValue& value ) +{ + return write_string( value, true ); +} + +#endif + +void json_spirit::write( const mValue& value, std::ostream& os ) +{ + write_stream( value, os, false ); +} + +void json_spirit::write_formatted( const mValue& value, std::ostream& os ) +{ + write_stream( value, os, true ); +} + +std::string json_spirit::write( const mValue& value ) +{ + return write_string( value, false ); +} + +std::string json_spirit::write_formatted( const mValue& value ) +{ + return write_string( value, true ); +} + +#ifndef BOOST_NO_STD_WSTRING + +void json_spirit::write( const wmValue& value, std::wostream& os ) +{ + write_stream( value, os, false ); +} + +void json_spirit::write_formatted( const wmValue& value, std::wostream& os ) +{ + write_stream( value, os, true ); +} + +std::wstring json_spirit::write( const wmValue& value ) +{ + return write_string( value, false ); +} + +std::wstring json_spirit::write_formatted( const wmValue& value ) +{ + return write_string( value, true ); +} + +#endif diff --git a/src/json/json_spirit_writer.h b/src/json/json_spirit_writer.h new file mode 100644 index 0000000..52e1406 --- /dev/null +++ b/src/json/json_spirit_writer.h @@ -0,0 +1,50 @@ +#ifndef JSON_SPIRIT_WRITER +#define JSON_SPIRIT_WRITER + +// Copyright John W. Wilkinson 2007 - 2009. +// Distributed under the MIT License, see accompanying file LICENSE.txt + +// json spirit version 4.03 + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include "json_spirit_value.h" +#include + +namespace json_spirit +{ + // functions to convert JSON Values to text, + // the "formatted" versions add whitespace to format the output nicely + + void write ( const Value& value, std::ostream& os ); + void write_formatted( const Value& value, std::ostream& os ); + std::string write ( const Value& value ); + std::string write_formatted( const Value& value ); + +#ifndef BOOST_NO_STD_WSTRING + + void write ( const wValue& value, std::wostream& os ); + void write_formatted( const wValue& value, std::wostream& os ); + std::wstring write ( const wValue& value ); + std::wstring write_formatted( const wValue& value ); + +#endif + + void write ( const mValue& value, std::ostream& os ); + void write_formatted( const mValue& value, std::ostream& os ); + std::string write ( const mValue& value ); + std::string write_formatted( const mValue& value ); + +#ifndef BOOST_NO_STD_WSTRING + + void write ( const wmValue& value, std::wostream& os ); + void write_formatted( const wmValue& value, std::wostream& os ); + std::wstring write ( const wmValue& value ); + std::wstring write_formatted( const wmValue& value ); + +#endif +} + +#endif diff --git a/src/json/json_spirit_writer_template.h b/src/json/json_spirit_writer_template.h new file mode 100644 index 0000000..6b4978a --- /dev/null +++ b/src/json/json_spirit_writer_template.h @@ -0,0 +1,249 @@ +#ifndef JSON_SPIRIT_WRITER_TEMPLATE +#define JSON_SPIRIT_WRITER_TEMPLATE + +// Copyright John W. Wilkinson 2007 - 2009. +// Distributed under the MIT License, see accompanying file LICENSE.txt + +// json spirit version 4.03 + +#include "json_spirit_value.h" + +#include +#include +#include + +namespace json_spirit +{ + inline char to_hex_char( unsigned int c ) + { + assert( c <= 0xF ); + + const char ch = static_cast< char >( c ); + + if( ch < 10 ) return '0' + ch; + + return 'A' - 10 + ch; + } + + template< class String_type > + String_type non_printable_to_string( unsigned int c ) + { + // Silence the warning: typedef ‘Char_type’ locally defined but not used [-Wunused-local-typedefs] + // typedef typename String_type::value_type Char_type; + + String_type result( 6, '\\' ); + + result[1] = 'u'; + + result[ 5 ] = to_hex_char( c & 0x000F ); c >>= 4; + result[ 4 ] = to_hex_char( c & 0x000F ); c >>= 4; + result[ 3 ] = to_hex_char( c & 0x000F ); c >>= 4; + result[ 2 ] = to_hex_char( c & 0x000F ); + + return result; + } + + template< typename Char_type, class String_type > + bool add_esc_char( Char_type c, String_type& s ) + { + switch( c ) + { + case '"': s += to_str< String_type >( "\\\"" ); return true; + case '\\': s += to_str< String_type >( "\\\\" ); return true; + case '\b': s += to_str< String_type >( "\\b" ); return true; + case '\f': s += to_str< String_type >( "\\f" ); return true; + case '\n': s += to_str< String_type >( "\\n" ); return true; + case '\r': s += to_str< String_type >( "\\r" ); return true; + case '\t': s += to_str< String_type >( "\\t" ); return true; + } + + return false; + } + + template< class String_type > + String_type add_esc_chars( const String_type& s ) + { + typedef typename String_type::const_iterator Iter_type; + typedef typename String_type::value_type Char_type; + + String_type result; + + const Iter_type end( s.end() ); + + for( Iter_type i = s.begin(); i != end; ++i ) + { + const Char_type c( *i ); + + if( add_esc_char( c, result ) ) continue; + + const wint_t unsigned_c( ( c >= 0 ) ? c : 256 + c ); + + if( iswprint( unsigned_c ) ) + { + result += c; + } + else + { + result += non_printable_to_string< String_type >( unsigned_c ); + } + } + + return result; + } + + // this class generates the JSON text, + // it keeps track of the indentation level etc. + // + template< class Value_type, class Ostream_type > + class Generator + { + typedef typename Value_type::Config_type Config_type; + typedef typename Config_type::String_type String_type; + typedef typename Config_type::Object_type Object_type; + typedef typename Config_type::Array_type Array_type; + typedef typename String_type::value_type Char_type; + typedef typename Object_type::value_type Obj_member_type; + + public: + + Generator( const Value_type& value, Ostream_type& os, bool pretty ) + : os_( os ) + , indentation_level_( 0 ) + , pretty_( pretty ) + { + output( value ); + } + + private: + + void output( const Value_type& value ) + { + switch( value.type() ) + { + case obj_type: output( value.get_obj() ); break; + case array_type: output( value.get_array() ); break; + case str_type: output( value.get_str() ); break; + case bool_type: output( value.get_bool() ); break; + case int_type: output_int( value ); break; + + /// Bitcoin: Added std::fixed and changed precision from 16 to 8 + case real_type: os_ << std::showpoint << std::fixed << std::setprecision(8) + << value.get_real(); break; + + case null_type: os_ << "null"; break; + default: assert( false ); + } + } + + void output( const Object_type& obj ) + { + output_array_or_obj( obj, '{', '}' ); + } + + void output( const Array_type& arr ) + { + output_array_or_obj( arr, '[', ']' ); + } + + void output( const Obj_member_type& member ) + { + output( Config_type::get_name( member ) ); space(); + os_ << ':'; space(); + output( Config_type::get_value( member ) ); + } + + void output_int( const Value_type& value ) + { + if( value.is_uint64() ) + { + os_ << value.get_uint64(); + } + else + { + os_ << value.get_int64(); + } + } + + void output( const String_type& s ) + { + os_ << '"' << add_esc_chars( s ) << '"'; + } + + void output( bool b ) + { + os_ << to_str< String_type >( b ? "true" : "false" ); + } + + template< class T > + void output_array_or_obj( const T& t, Char_type start_char, Char_type end_char ) + { + os_ << start_char; new_line(); + + ++indentation_level_; + + for( typename T::const_iterator i = t.begin(); i != t.end(); ++i ) + { + indent(); output( *i ); + + typename T::const_iterator next = i; + + if( ++next != t.end()) + { + os_ << ','; + } + + new_line(); + } + + --indentation_level_; + + indent(); os_ << end_char; + } + + void indent() + { + if( !pretty_ ) return; + + for( int i = 0; i < indentation_level_; ++i ) + { + os_ << " "; + } + } + + void space() + { + if( pretty_ ) os_ << ' '; + } + + void new_line() + { + if( pretty_ ) os_ << '\n'; + } + + Generator& operator=( const Generator& ); // to prevent "assignment operator could not be generated" warning + + Ostream_type& os_; + int indentation_level_; + bool pretty_; + }; + + template< class Value_type, class Ostream_type > + void write_stream( const Value_type& value, Ostream_type& os, bool pretty ) + { + Generator< Value_type, Ostream_type >( value, os, pretty ); + } + + template< class Value_type > + typename Value_type::String_type write_string( const Value_type& value, bool pretty ) + { + typedef typename Value_type::String_type::value_type Char_type; + + std::basic_ostringstream< Char_type > os; + + write_stream( value, os, pretty ); + + return os.str(); + } +} + +#endif diff --git a/src/keepass.cpp b/src/keepass.cpp new file mode 100644 index 0000000..dbc32ef --- /dev/null +++ b/src/keepass.cpp @@ -0,0 +1,494 @@ +// Copyright (c) 2014 The Darkcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "keepass.h" + +#include +#include +#include +#include +//#include + +#include "util.h" +//#include "random.h" +#include "serialize.h" +//#include "utilstrencodings.h" +#include "clientversion.h" +#include "json/json_spirit_writer_template.h" +#include "json/json_spirit_reader_template.h" +#include "rpcprotocol.h" +#include "script.h" +//#include "script/script.h" // Necessary to prevent compile errors due to forward declaration of +//CScript in serialize.h (included from crypter.h) +#include "wallet.h" + +using boost::asio::ip::tcp; + +CKeePassIntegrator keePassInt; + +CKeePassIntegrator::CKeePassIntegrator() + :sKeyBase64(" "), sKey(" "), sUrl(" ") // Prevent LockedPageManagerBase complaints +{ + sKeyBase64.clear(); // Prevent LockedPageManagerBase complaints + sKey.clear(); // Prevent LockedPageManagerBase complaints + sUrl.clear(); // Prevent LockedPageManagerBase complaints + bIsActive = false; + nPort = KEEPASS_KEEPASSHTTP_PORT; +} + +// Initialze from application context +void CKeePassIntegrator::init() +{ + bIsActive = GetBoolArg("-keepass", false); + nPort = boost::lexical_cast(GetArg("-keepassport", KEEPASS_KEEPASSHTTP_PORT)); + sKeyBase64 = SecureString(GetArg("-keepasskey", "").c_str()); + sKeePassId = GetArg("-keepassid", ""); + sKeePassEntryName = GetArg("-keepassname", ""); + // Convert key if available + if(sKeyBase64.size() > 0) + { + sKey = DecodeBase64Secure(sKeyBase64); + } + // Construct url if available + if(sKeePassEntryName.size() > 0) + { + sUrl = SecureString("http://"); + sUrl += SecureString(sKeePassEntryName.c_str()); + sUrl += SecureString("/"); + //sSubmitUrl = "http://"; + //sSubmitUrl += SecureString(sKeePassEntryName.c_str()); + } +} + +void CKeePassIntegrator::CKeePassRequest::addStrParameter(std::string sName, std::string sValue) +{ + requestObj.push_back(json_spirit::Pair(sName, sValue)); +} + +void CKeePassIntegrator::CKeePassRequest::addStrParameter(std::string sName, SecureString sValue) +{ + std::string sCipherValue; + + if(!EncryptAES256(sKey, sValue, sIV, sCipherValue)) + { + throw std::runtime_error("Unable to encrypt Verifier"); + } + + addStrParameter(sName, EncodeBase64(sCipherValue)); +} + +std::string CKeePassIntegrator::CKeePassRequest::getJson() +{ + return json_spirit::write_string(json_spirit::Value(requestObj), false); +} + +void CKeePassIntegrator::CKeePassRequest::init() +{ + SecureString sIVSecure = generateRandomKey(KEEPASS_CRYPTO_BLOCK_SIZE); + sIV = std::string(&sIVSecure[0], sIVSecure.size()); + // Generate Nonce, Verifier and RequestType + SecureString sNonceBase64Secure = EncodeBase64Secure(sIVSecure); + addStrParameter("Nonce", std::string(&sNonceBase64Secure[0], sNonceBase64Secure.size())); // Plain + addStrParameter("Verifier", sNonceBase64Secure); // Encoded + addStrParameter("RequestType", sType); +} + +void CKeePassIntegrator::CKeePassResponse::parseResponse(std::string sResponse) +{ + json_spirit::Value responseValue; + if(!json_spirit::read_string(sResponse, responseValue)) + { + throw std::runtime_error("Unable to parse KeePassHttp response"); + } + + responseObj = responseValue.get_obj(); + + // retrieve main values + bSuccess = json_spirit::find_value(responseObj, "Success").get_bool(); + sType = getStr("RequestType"); + sIV = DecodeBase64(getStr("Nonce")); +} + +std::string CKeePassIntegrator::CKeePassResponse::getStr(std::string sName) +{ + std::string sValue(json_spirit::find_value(responseObj, sName).get_str()); + return sValue; +} + +SecureString CKeePassIntegrator::CKeePassResponse::getSecureStr(std::string sName) +{ + std::string sValueBase64Encrypted(json_spirit::find_value(responseObj, sName).get_str()); + SecureString sValue; + try + { + sValue = decrypt(sValueBase64Encrypted); + } + catch (std::exception &e) + { + std::string sErrorMessage = "Exception occured while decrypting "; + sErrorMessage += sName + ": " + e.what(); + throw std::runtime_error(sErrorMessage); + } + return sValue; +} + +SecureString CKeePassIntegrator::CKeePassResponse::decrypt(std::string sValueBase64Encrypted) +{ + std::string sValueEncrypted = DecodeBase64(sValueBase64Encrypted); + SecureString sValue; + if(!DecryptAES256(sKey, sValueEncrypted, sIV, sValue)) + { + throw std::runtime_error("Unable to decrypt value."); + } + return sValue; +} + +std::vector CKeePassIntegrator::CKeePassResponse::getEntries() +{ + + std::vector vEntries; + + json_spirit::Array aEntries = json_spirit::find_value(responseObj, "Entries").get_array(); + for(json_spirit::Array::iterator it = aEntries.begin(); it != aEntries.end(); ++it) + { + SecureString sEntryUuid(decrypt(json_spirit::find_value((*it).get_obj(), "Uuid").get_str().c_str())); + SecureString sEntryName(decrypt(json_spirit::find_value((*it).get_obj(), "Name").get_str().c_str())); + SecureString sEntryLogin(decrypt(json_spirit::find_value((*it).get_obj(), "Login").get_str().c_str())); + SecureString sEntryPassword(decrypt(json_spirit::find_value((*it).get_obj(), "Password").get_str().c_str())); + CKeePassEntry entry(sEntryUuid, sEntryUuid, sEntryLogin, sEntryPassword); + vEntries.push_back(entry); + } + + return vEntries; + +} + +SecureString CKeePassIntegrator::generateRandomKey(size_t nSize) +{ + // Generates random key + SecureString key; + key.resize(nSize); + + RandAddSeedPerfmon(); + RAND_bytes((unsigned char *) &key[0], nSize); + + return key; +} + +// Construct POST body for RPC JSON call +std::string CKeePassIntegrator::constructHTTPPost(const std::string& strMsg, const std::map& mapRequestHeaders) +{ + std::ostringstream s; + s << "POST / HTTP/1.1\r\n" + << "User-Agent: SONO-json-rpc/" << FormatFullVersion() << "\r\n" + << "Host: localhost\r\n" + << "Content-Type: application/json\r\n" + << "Content-Length: " << strMsg.size() << "\r\n" + << "Connection: close\r\n" + << "Accept: application/json\r\n"; + BOOST_FOREACH(const PAIRTYPE(std::string, std::string)& item, mapRequestHeaders) + s << item.first << ": " << item.second << "\r\n"; + s << "\r\n" << strMsg; + + return s.str(); +} + +// Send RPC message to KeePassHttp +void CKeePassIntegrator::doHTTPPost(const std::string& sRequest, int& nStatus, std::string& sResponse) +{ + // Prepare communication + boost::asio::io_service io_service; + + // Get a list of endpoints corresponding to the server name. + tcp::resolver resolver(io_service); + tcp::resolver::query query(KEEPASS_KEEPASSHTTP_HOST, boost::lexical_cast(nPort)); + tcp::resolver::iterator endpoint_iterator = resolver.resolve(query); + tcp::resolver::iterator end; + + // Try each endpoint until we successfully establish a connection. + tcp::socket socket(io_service); + boost::system::error_code error = boost::asio::error::host_not_found; + while (error && endpoint_iterator != end) + { + socket.close(); + socket.connect(*endpoint_iterator++, error); + } + + if(error) + { + throw boost::system::system_error(error); + } + + // Form the request. + std::map mapRequestHeaders; + std::string strPost = constructHTTPPost(sRequest, mapRequestHeaders); + + // Logging of actual post data disabled as to not write passphrase in debug.log. Only enable temporarily when needed + //if(fDebug) LogPrintf("CKeePassIntegrator::doHTTPPost - send POST data: %s\n", strPost.c_str()); + if(fDebug) LogPrintf("CKeePassIntegrator::doHTTPPost - send POST data\n"); + + boost::asio::streambuf request; + std::ostream request_stream(&request); + request_stream << strPost; + + // Send the request. + boost::asio::write(socket, request); + + if(fDebug) LogPrintf("CKeePassIntegrator::doHTTPPost - request written\n"); + + // Read the response status line. The response streambuf will automatically + // grow to accommodate the entire line. The growth may be limited by passing + // a maximum size to the streambuf constructor. + boost::asio::streambuf response; + boost::asio::read_until(socket, response, "\r\n"); + + if(fDebug) LogPrintf("CKeePassIntegrator::doHTTPPost - request status line read\n"); + + // Receive HTTP reply status + int nProto = 0; + std::istream response_stream(&response); + nStatus = ReadHTTPStatus(response_stream, nProto); + + if(fDebug) LogPrintf("CKeePassIntegrator::doHTTPPost - reading response body start\n"); + // Read until EOF, writing data to output as we go. + while (boost::asio::read(socket, response, boost::asio::transfer_at_least(1), error)) + { + if (error != boost::asio::error::eof) + { + if (error != 0) + { // 0 is success + throw boost::system::system_error(error); + } + } + } + if(fDebug) LogPrintf("CKeePassIntegrator::doHTTPPost - reading response body end\n"); + + // Receive HTTP reply message headers and body + std::map mapHeaders; + ReadHTTPMessage(response_stream, mapHeaders, sResponse, nProto, MAX_SIZE); + if(fDebug) LogPrintf("CKeePassIntegrator::doHTTPPost - Processed body\n"); +} + +void CKeePassIntegrator::rpcTestAssociation(bool bTriggerUnlock) +{ + CKeePassRequest request(sKey, "test-associate"); + request.addStrParameter("TriggerUnlock", std::string(bTriggerUnlock ? "true" : "false")); + + int nStatus; + std::string sResponse; + + doHTTPPost(request.getJson(), nStatus, sResponse); + + if(fDebug) LogPrintf("CKeePassIntegrator::rpcTestAssociation - send result: status: %d response: %s\n", nStatus, sResponse.c_str()); +} + +std::vector CKeePassIntegrator::rpcGetLogins() +{ + + // Convert key format + SecureString sKey = DecodeBase64Secure(sKeyBase64); + + CKeePassRequest request(sKey, "get-logins"); + request.addStrParameter("addStrParameter", std::string("true")); + request.addStrParameter("TriggerUnlock", std::string("true")); + request.addStrParameter("Id", sKeePassId); + request.addStrParameter("Url", sUrl); + + int nStatus; + std::string sResponse; + + doHTTPPost(request.getJson(), nStatus, sResponse); + + // Logging of actual response data disabled as to not write passphrase in debug.log. Only enable temporarily when needed + //if(fDebug) LogPrintf("CKeePassIntegrator::rpcGetLogins - send result: status: %d response: %s\n", nStatus, sResponse.c_str()); + if(fDebug) LogPrintf("CKeePassIntegrator::rpcGetLogins - send result: status: %d\n", nStatus); + + if(nStatus != 200) + { + std::string sErrorMessage = "Error returned by KeePassHttp: HTTP code "; + sErrorMessage += boost::lexical_cast(nStatus); + sErrorMessage += " - Response: "; + sErrorMessage += " response: ["; + sErrorMessage += sResponse; + sErrorMessage += "]"; + throw std::runtime_error(sErrorMessage); + } + + // Parse the response + CKeePassResponse response(sKey, sResponse); + + if(!response.getSuccess()) + { + std::string sErrorMessage = "KeePassHttp returned failure status"; + throw std::runtime_error(sErrorMessage); + } + + return response.getEntries(); +} + +void CKeePassIntegrator::rpcSetLogin(const SecureString& strWalletPass, const SecureString& sEntryId) +{ + + // Convert key format + SecureString sKey = DecodeBase64Secure(sKeyBase64); + + CKeePassRequest request(sKey, "set-login"); + request.addStrParameter("Id", sKeePassId); + request.addStrParameter("Url", sUrl); + + if(fDebug) LogPrintf("CKeePassIntegrator::rpcSetLogin - send Url: %s\n", sUrl.c_str()); + + //request.addStrParameter("SubmitUrl", sSubmitUrl); // Is used to construct the entry title + request.addStrParameter("Login", SecureString("SONO")); + request.addStrParameter("Password", strWalletPass); + if(sEntryId.size() != 0) + { + request.addStrParameter("Uuid", sEntryId); // Update existing + } + + int nStatus; + std::string sResponse; + + doHTTPPost(request.getJson(), nStatus, sResponse); + + + if(fDebug) LogPrintf("CKeePassIntegrator::rpcSetLogin - send result: status: %d response: %s\n", nStatus, sResponse.c_str()); + + if(nStatus != 200) + { + std::string sErrorMessage = "Error returned: HTTP code "; + sErrorMessage += boost::lexical_cast(nStatus); + sErrorMessage += " - Response: "; + sErrorMessage += " response: ["; + sErrorMessage += sResponse; + sErrorMessage += "]"; + throw std::runtime_error(sErrorMessage); + } + + // Parse the response + CKeePassResponse response(sKey, sResponse); + + if(!response.getSuccess()) + { + throw std::runtime_error("KeePassHttp returned failure status"); + } +} + + +SecureString CKeePassIntegrator::generateKeePassKey() +{ + SecureString sKey = generateRandomKey(KEEPASS_CRYPTO_KEY_SIZE); + SecureString sKeyBase64 = EncodeBase64Secure(sKey); + return sKeyBase64; +} + +void CKeePassIntegrator::rpcAssociate(std::string& sId, SecureString& sKeyBase64) +{ + sKey = generateRandomKey(KEEPASS_CRYPTO_KEY_SIZE); + CKeePassRequest request(sKey, "associate"); + + sKeyBase64 = EncodeBase64Secure(sKey); + request.addStrParameter("Key", std::string(&sKeyBase64[0], sKeyBase64.size())); + + int nStatus; + std::string sResponse; + + doHTTPPost(request.getJson(), nStatus, sResponse); + + if(fDebug) LogPrintf("CKeePassIntegrator::rpcAssociate - send result: status: %d response: %s\n", nStatus, sResponse.c_str()); + + if(nStatus != 200) + { + std::string sErrorMessage = "Error returned: HTTP code "; + sErrorMessage += boost::lexical_cast(nStatus); + sErrorMessage += " - Response: "; + sErrorMessage += " response: ["; + sErrorMessage += sResponse; + sErrorMessage += "]"; + throw std::runtime_error(sErrorMessage); + } + + // Parse the response + CKeePassResponse response(sKey, sResponse); + + if(!response.getSuccess()) + { + throw std::runtime_error("KeePassHttp returned failure status"); + } + + // If we got here, we were successful. Return the information + sId = response.getStr("Id"); +} + +// Retrieve wallet passphrase from KeePass +SecureString CKeePassIntegrator::retrievePassphrase() +{ + + // Check we have all required information + if(sKey.size() == 0) + { + throw std::runtime_error("keepasskey parameter is not defined. Please specify the configuration parameter."); + } + if(sKeePassId.size() == 0) + { + throw std::runtime_error("keepassid parameter is not defined. Please specify the configuration parameter."); + } + if(sKeePassEntryName == "") + { + throw std::runtime_error("keepassname parameter is not defined. Please specify the configuration parameter."); + } + + // Retrieve matching logins from KeePass + std::vector entries = rpcGetLogins(); + + // Only accept one unique match + if(entries.size() == 0) + { + throw std::runtime_error("KeePassHttp returned 0 matches, please verify the keepassurl setting."); + } + if(entries.size() > 1) + { + throw std::runtime_error("KeePassHttp returned multiple matches, bailing out."); + } + + return entries[0].getPassword(); +} + +// Update wallet passphrase in keepass +void CKeePassIntegrator::updatePassphrase(const SecureString& sWalletPassphrase) +{ + // Check we have all required information + if(sKey.size() == 0) + { + throw std::runtime_error("keepasskey parameter is not defined. Please specify the configuration parameter."); + } + if(sKeePassId.size() == 0) + { + throw std::runtime_error("keepassid parameter is not defined. Please specify the configuration parameter."); + } + if(sKeePassEntryName == "") + { + throw std::runtime_error("keepassname parameter is not defined. Please specify the configuration parameter."); + } + + SecureString sEntryId(""); + + std::string sErrorMessage; + + // Lookup existing entry + std::vector vEntries = rpcGetLogins(); + + if(vEntries.size() > 1) + { + throw std::runtime_error("KeePassHttp returned multiple matches, bailing out."); + } + + if(vEntries.size() == 1) + { + sEntryId = vEntries[0].getUuid(); + } + + // Update wallet passphrase in KeePass + rpcSetLogin(sWalletPassphrase, sEntryId); +} diff --git a/src/keepass.h b/src/keepass.h new file mode 100644 index 0000000..23af898 --- /dev/null +++ b/src/keepass.h @@ -0,0 +1,133 @@ +// Copyright (c) 2014 The Darkcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef _KEEPASS_H_ +#define _KEEPASS_H_ + +#define KEEPASS_CRYPTO_KEY_SIZE 32 +#define KEEPASS_CRYPTO_BLOCK_SIZE 16 +#define KEEPASS_KEEPASSHTTP_HOST "localhost" +#define KEEPASS_KEEPASSHTTP_PORT 19855 + +#include +#include +#include + +#include "json/json_spirit_value.h" + +#include "allocators.h" + +class CKeePassIntegrator { + + bool bIsActive; + unsigned int nPort; + SecureString sKeyBase64; + SecureString sKey; + SecureString sUrl; + //SecureString sSubmitUrl; + std::string sKeePassId; + std::string sKeePassEntryName; + + class CKeePassRequest { + + json_spirit::Object requestObj; + std::string sType; + std::string sIV; + SecureString sKey; + + void init(); + + public: + void addStrParameter(std::string sName, std::string sValue); // Regular + void addStrParameter(std::string sName, SecureString sValue); // Encrypt + std::string getJson(); + + CKeePassRequest(SecureString sKey, std::string sType) + { + this->sKey = sKey; + this->sType = sType; + init(); + }; + }; + + + class CKeePassEntry { + + SecureString uuid; + SecureString name; + SecureString login; + SecureString password; + + public: + CKeePassEntry(SecureString uuid, SecureString name, SecureString login, SecureString password) : + uuid(uuid), name(name), login(login), password(password) { + } + + SecureString getUuid() { + return uuid; + } + + SecureString getName() { + return name; + } + + SecureString getLogin() { + return login; + } + + SecureString getPassword() { + return password; + } + + }; + + + class CKeePassResponse { + + bool bSuccess; + std::string sType; + std::string sIV; + SecureString sKey; + + void parseResponse(std::string sResponse); + + public: + json_spirit::Object responseObj; + CKeePassResponse(SecureString sKey, std::string sResponse) { + this->sKey = sKey; + parseResponse(sResponse); + } + + bool getSuccess() { + return bSuccess; + } + + SecureString getSecureStr(std::string sName); + std::string getStr(std::string sName); + std::vector getEntries(); + + SecureString decrypt(std::string sValue); // DecodeBase64 and decrypt arbitrary string value + + }; + + static SecureString generateRandomKey(size_t nSize); + static std::string constructHTTPPost(const std::string& strMsg, const std::map& mapRequestHeaders); + void doHTTPPost(const std::string& sRequest, int& nStatus, std::string& sResponse); + void rpcTestAssociation(bool bTriggerUnlock); + std::vector rpcGetLogins(); + void rpcSetLogin(const SecureString& strWalletPass, const SecureString& sEntryId); + +public: + CKeePassIntegrator(); + void init(); + static SecureString generateKeePassKey(); + void rpcAssociate(std::string& sId, SecureString& sKeyBase64); + SecureString retrievePassphrase(); + void updatePassphrase(const SecureString& sWalletPassphrase); + +}; + +extern CKeePassIntegrator keePassInt; + +#endif diff --git a/src/kernel.cpp b/src/kernel.cpp new file mode 100644 index 0000000..9da95d2 --- /dev/null +++ b/src/kernel.cpp @@ -0,0 +1,461 @@ +// Copyright (c) 2012-2013 The PPCoin developers +// Copyright (c) 2014 The BlackCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include "kernel.h" +#include "txdb.h" + +using namespace std; + +// Get time weight +int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd) +{ + // Kernel hash weight starts from 0 at the min age + // this change increases active coins participating the hash and helps + // to secure the network when proof-of-stake difficulty is low + + return nIntervalEnd - nIntervalBeginning - nStakeMinAge; +} + +// Get the last stake modifier and its generation time from a given block +static bool GetLastStakeModifier(const CBlockIndex* pindex, uint64_t& nStakeModifier, int64_t& nModifierTime) +{ + if (!pindex) + return error("GetLastStakeModifier: null pindex"); + while (pindex && pindex->pprev && !pindex->GeneratedStakeModifier()) + pindex = pindex->pprev; + if (!pindex->GeneratedStakeModifier()) + return error("GetLastStakeModifier: no generation at genesis block"); + nStakeModifier = pindex->nStakeModifier; + nModifierTime = pindex->GetBlockTime(); + return true; +} + +// Get selection interval section (in seconds) +static int64_t GetStakeModifierSelectionIntervalSection(int nSection) +{ + assert (nSection >= 0 && nSection < 64); + return (nModifierInterval * 63 / (63 + ((63 - nSection) * (MODIFIER_INTERVAL_RATIO - 1)))); +} + +// Get stake modifier selection interval (in seconds) +static int64_t GetStakeModifierSelectionInterval() +{ + int64_t nSelectionInterval = 0; + for (int nSection=0; nSection<64; nSection++) + nSelectionInterval += GetStakeModifierSelectionIntervalSection(nSection); + return nSelectionInterval; +} + +// select a block from the candidate blocks in vSortedByTimestamp, excluding +// already selected blocks in vSelectedBlocks, and with timestamp up to +// nSelectionIntervalStop. +static bool SelectBlockFromCandidates(vector >& vSortedByTimestamp, map& mapSelectedBlocks, + int64_t nSelectionIntervalStop, uint64_t nStakeModifierPrev, const CBlockIndex** pindexSelected) +{ + bool fSelected = false; + uint256 hashBest = 0; + *pindexSelected = (const CBlockIndex*) 0; + BOOST_FOREACH(const PAIRTYPE(int64_t, uint256)& item, vSortedByTimestamp) + { + if (!mapBlockIndex.count(item.second)) + return error("SelectBlockFromCandidates: failed to find block index for candidate block %s", item.second.ToString()); + const CBlockIndex* pindex = mapBlockIndex[item.second]; + if (fSelected && pindex->GetBlockTime() > nSelectionIntervalStop) + break; + if (mapSelectedBlocks.count(pindex->GetBlockHash()) > 0) + continue; + // compute the selection hash by hashing its proof-hash and the + // previous proof-of-stake modifier + CDataStream ss(SER_GETHASH, 0); + ss << pindex->hashProof << nStakeModifierPrev; + uint256 hashSelection = Hash(ss.begin(), ss.end()); + // the selection hash is divided by 2**32 so that proof-of-stake block + // is always favored over proof-of-work block. this is to preserve + // the energy efficiency property + if (pindex->IsProofOfStake()) + hashSelection >>= 32; + if (fSelected && hashSelection < hashBest) + { + hashBest = hashSelection; + *pindexSelected = (const CBlockIndex*) pindex; + } + else if (!fSelected) + { + fSelected = true; + hashBest = hashSelection; + *pindexSelected = (const CBlockIndex*) pindex; + } + } + LogPrint("stakemodifier", "SelectBlockFromCandidates: selection hash=%s\n", hashBest.ToString()); + return fSelected; +} + +// Stake Modifier (hash modifier of proof-of-stake): +// The purpose of stake modifier is to prevent a txout (coin) owner from +// computing future proof-of-stake generated by this txout at the time +// of transaction confirmation. To meet kernel protocol, the txout +// must hash with a future stake modifier to generate the proof. +// Stake modifier consists of bits each of which is contributed from a +// selected block of a given block group in the past. +// The selection of a block is based on a hash of the block's proof-hash and +// the previous stake modifier. +// Stake modifier is recomputed at a fixed time interval instead of every +// block. This is to make it difficult for an attacker to gain control of +// additional bits in the stake modifier, even after generating a chain of +// blocks. +bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier) +{ + nStakeModifier = 0; + fGeneratedStakeModifier = false; + if (!pindexPrev) + { + fGeneratedStakeModifier = true; + return true; // genesis block's modifier is 0 + } + // First find current stake modifier and its generation block time + // if it's not old enough, return the same stake modifier + int64_t nModifierTime = 0; + if (!GetLastStakeModifier(pindexPrev, nStakeModifier, nModifierTime)) + return error("ComputeNextStakeModifier: unable to get last modifier"); + LogPrint("stakemodifier", "ComputeNextStakeModifier: prev modifier=0x%016x time=%s\n", nStakeModifier, DateTimeStrFormat(nModifierTime)); + + /*Stake modifier is recomputed at a fixed time interval instead of every block. This is to make it + difficult for an attacker to gain control of additional bits in the stake modifier, + even after generating a chain of blocks.*/ + + if (nModifierTime / nModifierInterval >= pindexPrev->GetBlockTime() / nModifierInterval) + return true; // Return the same stake modifier <------------------------------------------ + + // Sort candidate blocks by timestamp + vector > vSortedByTimestamp; + vSortedByTimestamp.reserve(64 * nModifierInterval / GetTargetSpacing(pindexPrev->nHeight)); + int64_t nSelectionInterval = GetStakeModifierSelectionInterval(); + int64_t nSelectionIntervalStart = (pindexPrev->GetBlockTime() / nModifierInterval) * nModifierInterval - nSelectionInterval; + const CBlockIndex* pindex = pindexPrev; + while (pindex && pindex->GetBlockTime() >= nSelectionIntervalStart) + { + vSortedByTimestamp.push_back(make_pair(pindex->GetBlockTime(), pindex->GetBlockHash())); + pindex = pindex->pprev; + } + int nHeightFirstCandidate = pindex ? (pindex->nHeight + 1) : 0; + reverse(vSortedByTimestamp.begin(), vSortedByTimestamp.end()); + sort(vSortedByTimestamp.begin(), vSortedByTimestamp.end()); + + // Select 64 blocks from candidate blocks to generate stake modifier + uint64_t nStakeModifierNew = 0; + int64_t nSelectionIntervalStop = nSelectionIntervalStart; + map mapSelectedBlocks; + for (int nRound=0; nRoundGetStakeEntropyBit()) << nRound); + // add the selected block from candidates to selected list + mapSelectedBlocks.insert(make_pair(pindex->GetBlockHash(), pindex)); + LogPrint("stakemodifier", "ComputeNextStakeModifier: selected round %d stop=%s height=%d bit=%d\n", nRound, DateTimeStrFormat(nSelectionIntervalStop), pindex->nHeight, pindex->GetStakeEntropyBit()); + } + + // Print selection map for visualization of the selected blocks + if (LogAcceptCategory("stakemodifier")) + { + string strSelectionMap = ""; + // '-' indicates proof-of-work blocks not selected + strSelectionMap.insert(0, pindexPrev->nHeight - nHeightFirstCandidate + 1, '-'); + pindex = pindexPrev; + while (pindex && pindex->nHeight >= nHeightFirstCandidate) + { + // '=' indicates proof-of-stake blocks not selected + if (pindex->IsProofOfStake()) + strSelectionMap.replace(pindex->nHeight - nHeightFirstCandidate, 1, "="); + pindex = pindex->pprev; + } + BOOST_FOREACH(const PAIRTYPE(uint256, const CBlockIndex*)& item, mapSelectedBlocks) + { + // 'S' indicates selected proof-of-stake blocks + // 'W' indicates selected proof-of-work blocks + strSelectionMap.replace(item.second->nHeight - nHeightFirstCandidate, 1, item.second->IsProofOfStake()? "S" : "W"); + } + LogPrintf("ComputeNextStakeModifier: selection height [%d, %d] map %s\n", nHeightFirstCandidate, pindexPrev->nHeight, strSelectionMap); + } + LogPrint("stakemodifier", "ComputeNextStakeModifier: new modifier=0x%016x time=%s\n", nStakeModifierNew, DateTimeStrFormat(pindexPrev->GetBlockTime())); + + nStakeModifier = nStakeModifierNew; + fGeneratedStakeModifier = true; + return true; +} + +// The stake modifier used to hash for a stake kernel is chosen as the stake +// modifier about a selection interval later than the coin generating the kernel +static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake) +{ + nStakeModifier = 0; + if (!mapBlockIndex.count(hashBlockFrom)) + return error("GetKernelStakeModifier() : block not indexed"); + const CBlockIndex* pindexFrom = mapBlockIndex[hashBlockFrom]; + nStakeModifierHeight = pindexFrom->nHeight; + nStakeModifierTime = pindexFrom->GetBlockTime(); + int64_t nStakeModifierSelectionInterval = GetStakeModifierSelectionInterval(); + const CBlockIndex* pindex = pindexFrom; + // loop to find the stake modifier later by a selection interval + while (nStakeModifierTime < pindexFrom->GetBlockTime() + nStakeModifierSelectionInterval) + { + if (!pindex->pnext) + { // reached best block; may happen if node is behind on block chain + if (fPrintProofOfStake || (pindex->GetBlockTime() + nStakeMinAge - nStakeModifierSelectionInterval > GetAdjustedTime())) + return error("GetKernelStakeModifier() : reached best block %s at height %d from block %s", + pindex->GetBlockHash().ToString(), pindex->nHeight, hashBlockFrom.ToString()); + else + return false; + } + pindex = pindex->pnext; + if (pindex->GeneratedStakeModifier()) + { + nStakeModifierHeight = pindex->nHeight; + nStakeModifierTime = pindex->GetBlockTime(); + } + } + nStakeModifier = pindex->nStakeModifier; + return true; +} + +// ppcoin kernel protocol +// coinstake must meet hash target according to the protocol: +// kernel (input 0) must meet the formula +// hash(nStakeModifier + txPrev.block.nTime + txPrev.offset + txPrev.nTime + txPrev.vout.n + nTime) < bnTarget * nCoinDayWeight +// this ensures that the chance of getting a coinstake is proportional to the +// amount of coin age one owns. +// The reason this hash is chosen is the following: +// nStakeModifier: scrambles computation to make it very difficult to precompute +// future proof-of-stake at the time of the coin's confirmation +// txPrev.block.nTime: prevent nodes from guessing a good timestamp to +// generate transaction for future advantage +// txPrev.offset: offset of txPrev inside block, to reduce the chance of +// nodes generating coinstake at the same time +// txPrev.nTime: reduce the chance of nodes generating coinstake at the same +// time +// txPrev.vout.n: output number of txPrev, to reduce the chance of nodes +// generating coinstake at the same time +// block/tx hash should not be used here as they can be generated in vast +// quantities so as to generate blocks faster, degrading the system back into +// a proof-of-work situation. +// +static bool CheckStakeKernelHashV1(unsigned int nBits, const CBlock& blockFrom, unsigned int nTxPrevOffset, const CTransaction& txPrev, const COutPoint& prevout, unsigned int nTimeTx, uint256& hashProofOfStake, uint256& targetProofOfStake, bool fPrintProofOfStake) +{ + if (nTimeTx < txPrev.nTime) // Transaction timestamp violation + return error("CheckStakeKernelHash() : nTime violation"); + + unsigned int nTimeBlockFrom = blockFrom.GetBlockTime(); + // if (nTimeBlockFrom + nStakeMinAge > nTimeTx) // Min age requirement + // return error("CheckStakeKernelHash() : min age violation"); + + CBigNum bnTargetPerCoinDay; + bnTargetPerCoinDay.SetCompact(nBits); + int64_t nValueIn = txPrev.vout[prevout.n].nValue; + + uint256 hashBlockFrom = blockFrom.GetHash(); + + CBigNum bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64_t)txPrev.nTime, (int64_t)nTimeTx) / COIN / (24 * 60 * 60); + targetProofOfStake = (bnCoinDayWeight * bnTargetPerCoinDay).getuint256(); + + // Calculate hash + CDataStream ss(SER_GETHASH, 0); + uint64_t nStakeModifier = 0; + int nStakeModifierHeight = 0; + int64_t nStakeModifierTime = 0; + + if (!GetKernelStakeModifier(hashBlockFrom, nStakeModifier, nStakeModifierHeight, nStakeModifierTime, fPrintProofOfStake)) + return false; + ss << nStakeModifier; + + ss << nTimeBlockFrom << nTxPrevOffset << txPrev.nTime << prevout.n << nTimeTx; + hashProofOfStake = Hash(ss.begin(), ss.end()); + if (fPrintProofOfStake) + { + LogPrintf("CheckStakeKernelHash() : using modifier 0x%016x at height=%d timestamp=%s for block from height=%d timestamp=%s\n", + nStakeModifier, nStakeModifierHeight, + DateTimeStrFormat(nStakeModifierTime), + mapBlockIndex[hashBlockFrom]->nHeight, + DateTimeStrFormat(blockFrom.GetBlockTime())); + LogPrintf("CheckStakeKernelHash() : check modifier=0x%016x nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", + nStakeModifier, + nTimeBlockFrom, nTxPrevOffset, txPrev.nTime, prevout.n, nTimeTx, + hashProofOfStake.ToString()); + } + + // Now check if proof-of-stake hash meets target protocol + if (CBigNum(hashProofOfStake) > bnCoinDayWeight * bnTargetPerCoinDay) + return false; + if (fDebug && !fPrintProofOfStake) + { + LogPrintf("CheckStakeKernelHash() : using modifier 0x%016x at height=%d timestamp=%s for block from height=%d timestamp=%s\n", + nStakeModifier, nStakeModifierHeight, + DateTimeStrFormat(nStakeModifierTime), + mapBlockIndex[hashBlockFrom]->nHeight, + DateTimeStrFormat(blockFrom.GetBlockTime())); + LogPrintf("CheckStakeKernelHash() : pass modifier=0x%016x nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", + nStakeModifier, + nTimeBlockFrom, nTxPrevOffset, txPrev.nTime, prevout.n, nTimeTx, + hashProofOfStake.ToString()); + } + return true; +} + +// Buxcoin kernel protocol +// coinstake must meet hash target according to the protocol: +// kernel (input 0) must meet the formula +// hash(nStakeModifier + txPrev.block.nTime + txPrev.nTime + txPrev.vout.hash + txPrev.vout.n + nTime) < bnTarget * nWeight +// this ensures that the chance of getting a coinstake is proportional to the +// amount of coins one owns. +// The reason this hash is chosen is the following: +// nStakeModifier: scrambles computation to make it very difficult to precompute +// future proof-of-stake +// txPrev.block.nTime: prevent nodes from guessing a good timestamp to +// generate transaction for future advantage +// txPrev.nTime: slightly scrambles computation +// txPrev.vout.hash: hash of txPrev, to reduce the chance of nodes +// generating coinstake at the same time +// txPrev.vout.n: output number of txPrev, to reduce the chance of nodes +// generating coinstake at the same time +// nTime: current timestamp +// block/tx hash should not be used here as they can be generated in vast +// quantities so as to generate blocks faster, degrading the system back into +// a proof-of-work situation. +// +static bool CheckStakeKernelHashV2(CBlockIndex* pindexPrev, unsigned int nBits, unsigned int nTimeBlockFrom, const CTransaction& txPrev, const COutPoint& prevout, unsigned int nTimeTx, uint256& hashProofOfStake, uint256& targetProofOfStake, bool fPrintProofOfStake) +{ + if (nTimeTx < txPrev.nTime) // Transaction timestamp violation + return error("CheckStakeKernelHash() : nTime violation"); + + // if (nTimeBlockFrom + nStakeMinAge > nTimeTx) // Min age requirement + // return error("CheckStakeKernelHash() : min age violation"); + + // Base target + CBigNum bnTarget; + bnTarget.SetCompact(nBits); + + // Weighted target + int64_t nValueIn = txPrev.vout[prevout.n].nValue; + CBigNum bnWeight = CBigNum(nValueIn); + bnTarget *= bnWeight; + + targetProofOfStake = bnTarget.getuint256(); + + uint64_t nStakeModifier = pindexPrev->nStakeModifier; + int nStakeModifierHeight = pindexPrev->nHeight; + int64_t nStakeModifierTime = pindexPrev->nTime; + + // Calculate hash + CDataStream ss(SER_GETHASH, 0); + ss << nStakeModifier << nTimeBlockFrom << txPrev.nTime << prevout.hash << prevout.n << nTimeTx; + hashProofOfStake = Hash(ss.begin(), ss.end()); + + if (fPrintProofOfStake) + { + LogPrintf("CheckStakeKernelHash() : using modifier 0x%016x at height=%d timestamp=%s for block from timestamp=%s\n", + nStakeModifier, nStakeModifierHeight, + DateTimeStrFormat(nStakeModifierTime), + DateTimeStrFormat(nTimeBlockFrom)); + LogPrintf("CheckStakeKernelHash() : check modifier=0x%016x nTimeBlockFrom=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", + nStakeModifier, + nTimeBlockFrom, txPrev.nTime, prevout.n, nTimeTx, + hashProofOfStake.ToString()); + } + + // Now check if proof-of-stake hash meets target protocol + if (CBigNum(hashProofOfStake) > bnTarget) + return false; + + if (fDebug && !fPrintProofOfStake) + { + LogPrintf("CheckStakeKernelHash() : using modifier 0x%016x at height=%d timestamp=%s for block from timestamp=%s\n", + nStakeModifier, nStakeModifierHeight, + DateTimeStrFormat(nStakeModifierTime), + DateTimeStrFormat(nTimeBlockFrom)); + LogPrintf("CheckStakeKernelHash() : pass modifier=0x%016x nTimeBlockFrom=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", + nStakeModifier, + nTimeBlockFrom, txPrev.nTime, prevout.n, nTimeTx, + hashProofOfStake.ToString()); + } + + return true; +} + +bool CheckStakeKernelHash(CBlockIndex* pindexPrev, unsigned int nBits, const CBlock& blockFrom, unsigned int nTxPrevOffset, const CTransaction& txPrev, const COutPoint& prevout, unsigned int nTimeTx, uint256& hashProofOfStake, uint256& targetProofOfStake, bool fPrintProofOfStake) +{ + if (IsProtocolV2(pindexPrev->nHeight+1)) + return CheckStakeKernelHashV2(pindexPrev, nBits, blockFrom.GetBlockTime(), txPrev, prevout, nTimeTx, hashProofOfStake, targetProofOfStake, fPrintProofOfStake); + else + return CheckStakeKernelHashV1(nBits, blockFrom, nTxPrevOffset, txPrev, prevout, nTimeTx, hashProofOfStake, targetProofOfStake, fPrintProofOfStake); +} + +// Check kernel hash target and coinstake signature +bool CheckProofOfStake(CBlockIndex* pindexPrev, const CTransaction& tx, unsigned int nBits, uint256& hashProofOfStake, uint256& targetProofOfStake) +{ + if (!tx.IsCoinStake()) + return error("CheckProofOfStake() : called on non-coinstake %s", tx.GetHash().ToString()); + + // Kernel (input 0) must match the stake hash target per coin age (nBits) + const CTxIn& txin = tx.vin[0]; + + // First try finding the previous transaction in database + CTxDB txdb("r"); + CTransaction txPrev; + CTxIndex txindex; + if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex)) + return tx.DoS(1, error("CheckProofOfStake() : INFO: read txPrev failed")); // previous transaction not in main chain, may occur during initial download + + // Verify signature + if (!VerifySignature(txPrev, tx, 0, SCRIPT_VERIFY_NONE, 0)) + return tx.DoS(100, error("CheckProofOfStake() : VerifySignature failed on coinstake %s", tx.GetHash().ToString())); + + // Read block header + CBlock block; + if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false)) + return fDebug? error("CheckProofOfStake() : read block failed") : false; // unable to read block of previous transaction + + // if (!CheckStakeKernelHash(pindexPrev, nBits, block, txindex.pos.nTxPos - txindex.pos.nBlockPos, txPrev, txin.prevout, tx.nTime, hashProofOfStake, targetProofOfStake, fDebug)) + // return tx.DoS(1, error("CheckProofOfStake() : INFO: check kernel failed on coinstake %s, hashProof=%s", tx.GetHash().ToString(), hashProofOfStake.ToString())); // may occur during initial download or if behind on block chain sync + + return true; +} + +// Check whether the coinstake timestamp meets protocol +bool CheckCoinStakeTimestamp(int nHeight, int64_t nTimeBlock, int64_t nTimeTx) +{ + if (IsProtocolV2(nHeight)) + return (nTimeBlock == nTimeTx) && ((nTimeTx & STAKE_TIMESTAMP_MASK) == 0); + else + return (nTimeBlock == nTimeTx); +} + +bool CheckKernel(CBlockIndex* pindexPrev, unsigned int nBits, int64_t nTime, const COutPoint& prevout, int64_t* pBlockTime) +{ + uint256 hashProofOfStake, targetProofOfStake; + + CTxDB txdb("r"); + CTransaction txPrev; + CTxIndex txindex; + if (!txPrev.ReadFromDisk(txdb, prevout, txindex)) + return false; + + // Read block header + CBlock block; + if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false)) + return false; + + if (block.GetBlockTime() + nStakeMinAge > nTime) + return false; // only count coins meeting min age requirement + + if (pBlockTime) + *pBlockTime = block.GetBlockTime(); + + return CheckStakeKernelHash(pindexPrev, nBits, block, txindex.pos.nTxPos - txindex.pos.nBlockPos, txPrev, prevout, nTime, hashProofOfStake, targetProofOfStake); +} diff --git a/src/kernel.h b/src/kernel.h new file mode 100644 index 0000000..8418579 --- /dev/null +++ b/src/kernel.h @@ -0,0 +1,42 @@ +// Copyright (c) 2012-2013 The PPCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef PPCOIN_KERNEL_H +#define PPCOIN_KERNEL_H + +#include "main.h" + +// To decrease granularity of timestamp +// Supposed to be 2^n-1 +static const int STAKE_TIMESTAMP_MASK = 15; + +// MODIFIER_INTERVAL: time to elapse before new modifier is computed +extern unsigned int nModifierInterval; + +// MODIFIER_INTERVAL_RATIO: +// ratio of group interval length between the last group and the first group +static const int MODIFIER_INTERVAL_RATIO = 3; + +// Compute the hash modifier for proof-of-stake +bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier); + +// Check whether stake kernel meets hash target +// Sets hashProofOfStake on success return +bool CheckStakeKernelHash(CBlockIndex* pindexPrev, unsigned int nBits, const CBlock& blockFrom, unsigned int nTxPrevOffset, const CTransaction& txPrev, const COutPoint& prevout, unsigned int nTimeTx, uint256& hashProofOfStake, uint256& targetProofOfStake, bool fPrintProofOfStake=false); + +// Check kernel hash target and coinstake signature +// Sets hashProofOfStake on success return +bool CheckProofOfStake(CBlockIndex* pindexPrev, const CTransaction& tx, unsigned int nBits, uint256& hashProofOfStake, uint256& targetProofOfStake); + +// Check whether the coinstake timestamp meets protocol +bool CheckCoinStakeTimestamp(int nHeight, int64_t nTimeBlock, int64_t nTimeTx); + +// Get time weight using supplied timestamps +int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd); + +// Wrapper around CheckStakeKernelHash() +// Also checks existence of kernel input and min age +// Convenient for searching a kernel +bool CheckKernel(CBlockIndex* pindexPrev, unsigned int nBits, int64_t nTime, const COutPoint& prevout, int64_t* pBlockTime = NULL); + +#endif // PPCOIN_KERNEL_H diff --git a/src/key.cpp b/src/key.cpp new file mode 100644 index 0000000..281e8ba --- /dev/null +++ b/src/key.cpp @@ -0,0 +1,832 @@ +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +// NOTE: libsecp256k1 verification methods presently not working, +// so here, we include both openssl libs and libsecp256k1 +// to at least gain what we can from it. + +#include +#include +#include +#include + +#include "key.h" + +#ifdef USE_SECP256K1 +#include +#endif +//#else +//#include + +//#endif + +// anonymous namespace with local implementation code (OpenSSL interaction) +namespace { +#ifdef USE_SECP256K1 +class CSecp256k1Init { +public: + secp256k1_context_t* ctx; + CSecp256k1Init() { + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); + } + ~CSecp256k1Init() { + secp256k1_context_destroy(ctx); + } +}; +static CSecp256k1Init instance_of_csecp256k1; +#endif +//#else + +// Generate a private key from just the secret parameter +int EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key) +{ + int ok = 0; + BN_CTX *ctx = NULL; + EC_POINT *pub_key = NULL; + + if (!eckey) return 0; + + const EC_GROUP *group = EC_KEY_get0_group(eckey); + + if ((ctx = BN_CTX_new()) == NULL) + goto err; + + pub_key = EC_POINT_new(group); + + if (pub_key == NULL) + goto err; + + if (!EC_POINT_mul(group, pub_key, priv_key, NULL, NULL, ctx)) + goto err; + + EC_KEY_set_private_key(eckey,priv_key); + EC_KEY_set_public_key(eckey,pub_key); + + ok = 1; + +err: + + if (pub_key) + EC_POINT_free(pub_key); + if (ctx != NULL) + BN_CTX_free(ctx); + + return(ok); +} + +// Perform ECDSA key recovery (see SEC1 4.1.6) for curves over (mod p)-fields +// recid selects which key is recovered +// if check is non-zero, additional checks are performed +int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned char *msg, int msglen, int recid, int check) +{ + if (!eckey) return 0; + + int ret = 0; + BN_CTX *ctx = NULL; + + BIGNUM *x = NULL; + BIGNUM *e = NULL; + BIGNUM *order = NULL; + BIGNUM *sor = NULL; + BIGNUM *eor = NULL; + BIGNUM *field = NULL; + EC_POINT *R = NULL; + EC_POINT *O = NULL; + EC_POINT *Q = NULL; + BIGNUM *rr = NULL; + BIGNUM *zero = NULL; + int n = 0; + int i = recid / 2; + + const EC_GROUP *group = EC_KEY_get0_group(eckey); + if ((ctx = BN_CTX_new()) == NULL) { ret = -1; goto err; } + BN_CTX_start(ctx); + order = BN_CTX_get(ctx); + if (!EC_GROUP_get_order(group, order, ctx)) { ret = -2; goto err; } + x = BN_CTX_get(ctx); + if (!BN_copy(x, order)) { ret=-1; goto err; } + if (!BN_mul_word(x, i)) { ret=-1; goto err; } + if (!BN_add(x, x, ecsig->r)) { ret=-1; goto err; } + field = BN_CTX_get(ctx); + if (!EC_GROUP_get_curve_GFp(group, field, NULL, NULL, ctx)) { ret=-2; goto err; } + if (BN_cmp(x, field) >= 0) { ret=0; goto err; } + if ((R = EC_POINT_new(group)) == NULL) { ret = -2; goto err; } + if (!EC_POINT_set_compressed_coordinates_GFp(group, R, x, recid % 2, ctx)) { ret=0; goto err; } + if (check) + { + if ((O = EC_POINT_new(group)) == NULL) { ret = -2; goto err; } + if (!EC_POINT_mul(group, O, NULL, R, order, ctx)) { ret=-2; goto err; } + if (!EC_POINT_is_at_infinity(group, O)) { ret = 0; goto err; } + } + if ((Q = EC_POINT_new(group)) == NULL) { ret = -2; goto err; } + n = EC_GROUP_get_degree(group); + e = BN_CTX_get(ctx); + if (!BN_bin2bn(msg, msglen, e)) { ret=-1; goto err; } + if (8*msglen > n) BN_rshift(e, e, 8-(n & 7)); + zero = BN_CTX_get(ctx); + if (!BN_zero(zero)) { ret=-1; goto err; } + if (!BN_mod_sub(e, zero, e, order, ctx)) { ret=-1; goto err; } + rr = BN_CTX_get(ctx); + if (!BN_mod_inverse(rr, ecsig->r, order, ctx)) { ret=-1; goto err; } + sor = BN_CTX_get(ctx); + if (!BN_mod_mul(sor, ecsig->s, rr, order, ctx)) { ret=-1; goto err; } + eor = BN_CTX_get(ctx); + if (!BN_mod_mul(eor, e, rr, order, ctx)) { ret=-1; goto err; } + if (!EC_POINT_mul(group, Q, eor, R, sor, ctx)) { ret=-2; goto err; } + if (!EC_KEY_set_public_key(eckey, Q)) { ret=-2; goto err; } + + ret = 1; + +err: + if (ctx) { + BN_CTX_end(ctx); + BN_CTX_free(ctx); + } + if (R != NULL) EC_POINT_free(R); + if (O != NULL) EC_POINT_free(O); + if (Q != NULL) EC_POINT_free(Q); + return ret; +} + +// RAII Wrapper around OpenSSL's EC_KEY +class CECKey { +private: + EC_KEY *pkey; + +public: + CECKey() { + pkey = EC_KEY_new_by_curve_name(NID_secp256k1); + assert(pkey != NULL); + } + + ~CECKey() { + EC_KEY_free(pkey); + } + + void GetSecretBytes(unsigned char vch[32]) const { + const BIGNUM *bn = EC_KEY_get0_private_key(pkey); + assert(bn); + int nBytes = BN_num_bytes(bn); + int n=BN_bn2bin(bn,&vch[32 - nBytes]); + assert(n == nBytes); + memset(vch, 0, 32 - nBytes); + } + + void SetSecretBytes(const unsigned char vch[32]) { + BIGNUM bn; + BN_init(&bn); + assert(BN_bin2bn(vch, 32, &bn)); + assert(EC_KEY_regenerate_key(pkey, &bn)); + BN_clear_free(&bn); + } + + void GetPrivKey(CPrivKey &privkey, bool fCompressed) { + EC_KEY_set_conv_form(pkey, fCompressed ? POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED); + int nSize = i2d_ECPrivateKey(pkey, NULL); + assert(nSize); + privkey.resize(nSize); + unsigned char* pbegin = &privkey[0]; + int nSize2 = i2d_ECPrivateKey(pkey, &pbegin); + assert(nSize == nSize2); + } + + bool SetPrivKey(const CPrivKey &privkey, bool fSkipCheck=false) { + const unsigned char* pbegin = &privkey[0]; + if (d2i_ECPrivateKey(&pkey, &pbegin, privkey.size())) { + if(fSkipCheck) + return true; + + // d2i_ECPrivateKey returns true if parsing succeeds. + // This doesn't necessarily mean the key is valid. + if (EC_KEY_check_key(pkey)) + return true; + } + return false; + } + + void GetPubKey(CPubKey &pubkey, bool fCompressed) { + EC_KEY_set_conv_form(pkey, fCompressed ? POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED); + int nSize = i2o_ECPublicKey(pkey, NULL); + assert(nSize); + assert(nSize <= 65); + unsigned char c[65]; + unsigned char *pbegin = c; + int nSize2 = i2o_ECPublicKey(pkey, &pbegin); + assert(nSize == nSize2); + pubkey.Set(&c[0], &c[nSize]); + } + + bool SetPubKey(const CPubKey &pubkey) { + const unsigned char* pbegin = pubkey.begin(); + return o2i_ECPublicKey(&pkey, &pbegin, pubkey.size()); + } + + bool Sign(const uint256 &hash, std::vector& vchSig) { + vchSig.clear(); + ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey); + if (sig == NULL) + return false; + BN_CTX *ctx = BN_CTX_new(); + BN_CTX_start(ctx); + const EC_GROUP *group = EC_KEY_get0_group(pkey); + BIGNUM *order = BN_CTX_get(ctx); + BIGNUM *halforder = BN_CTX_get(ctx); + EC_GROUP_get_order(group, order, ctx); + BN_rshift1(halforder, order); + if (BN_cmp(sig->s, halforder) > 0) { + // enforce low S values, by negating the value (modulo the order) if above order/2. + BN_sub(sig->s, order, sig->s); + } + BN_CTX_end(ctx); + BN_CTX_free(ctx); + unsigned int nSize = ECDSA_size(pkey); + vchSig.resize(nSize); // Make sure it is big enough + unsigned char *pos = &vchSig[0]; + nSize = i2d_ECDSA_SIG(sig, &pos); + ECDSA_SIG_free(sig); + vchSig.resize(nSize); // Shrink to fit actual size + return true; + } + + bool Verify(const uint256 &hash, const std::vector& vchSig) { + // -1 = error, 0 = bad sig, 1 = good + if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1) + return false; + return true; + } + + bool SignCompact(const uint256 &hash, unsigned char *p64, int &rec) { + bool fOk = false; + ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey); + if (sig==NULL) + return false; + memset(p64, 0, 64); + int nBitsR = BN_num_bits(sig->r); + int nBitsS = BN_num_bits(sig->s); + if (nBitsR <= 256 && nBitsS <= 256) { + CPubKey pubkey; + GetPubKey(pubkey, true); + for (int i=0; i<4; i++) { + CECKey keyRec; + if (ECDSA_SIG_recover_key_GFp(keyRec.pkey, sig, (unsigned char*)&hash, sizeof(hash), i, 1) == 1) { + CPubKey pubkeyRec; + keyRec.GetPubKey(pubkeyRec, true); + if (pubkeyRec == pubkey) { + rec = i; + fOk = true; + break; + } + } + } + assert(fOk); + BN_bn2bin(sig->r,&p64[32-(nBitsR+7)/8]); + BN_bn2bin(sig->s,&p64[64-(nBitsS+7)/8]); + } + ECDSA_SIG_free(sig); + return fOk; + } + + // reconstruct public key from a compact signature + // This is only slightly more CPU intensive than just verifying it. + // If this function succeeds, the recovered public key is guaranteed to be valid + // (the signature is a valid signature of the given data for that key) + bool Recover(const uint256 &hash, const unsigned char *p64, int rec) + { + if (rec<0 || rec>=3) + return false; + ECDSA_SIG *sig = ECDSA_SIG_new(); + BN_bin2bn(&p64[0], 32, sig->r); + BN_bin2bn(&p64[32], 32, sig->s); + bool ret = ECDSA_SIG_recover_key_GFp(pkey, sig, (unsigned char*)&hash, sizeof(hash), rec, 0) == 1; + ECDSA_SIG_free(sig); + return ret; + } + + static bool TweakSecret(unsigned char vchSecretOut[32], const unsigned char vchSecretIn[32], const unsigned char vchTweak[32]) + { + bool ret = true; + BN_CTX *ctx = BN_CTX_new(); + BN_CTX_start(ctx); + BIGNUM *bnSecret = BN_CTX_get(ctx); + BIGNUM *bnTweak = BN_CTX_get(ctx); + BIGNUM *bnOrder = BN_CTX_get(ctx); + EC_GROUP *group = EC_GROUP_new_by_curve_name(NID_secp256k1); + EC_GROUP_get_order(group, bnOrder, ctx); // what a grossly inefficient way to get the (constant) group order... + BN_bin2bn(vchTweak, 32, bnTweak); + if (BN_cmp(bnTweak, bnOrder) >= 0) + ret = false; // extremely unlikely + BN_bin2bn(vchSecretIn, 32, bnSecret); + BN_add(bnSecret, bnSecret, bnTweak); + BN_nnmod(bnSecret, bnSecret, bnOrder, ctx); + if (BN_is_zero(bnSecret)) + ret = false; // ridiculously unlikely + int nBits = BN_num_bits(bnSecret); + memset(vchSecretOut, 0, 32); + BN_bn2bin(bnSecret, &vchSecretOut[32-(nBits+7)/8]); + EC_GROUP_free(group); + BN_CTX_end(ctx); + BN_CTX_free(ctx); + return ret; + } + + bool TweakPublic(const unsigned char vchTweak[32]) { + bool ret = true; + BN_CTX *ctx = BN_CTX_new(); + BN_CTX_start(ctx); + BIGNUM *bnTweak = BN_CTX_get(ctx); + BIGNUM *bnOrder = BN_CTX_get(ctx); + BIGNUM *bnOne = BN_CTX_get(ctx); + const EC_GROUP *group = EC_KEY_get0_group(pkey); + EC_GROUP_get_order(group, bnOrder, ctx); // what a grossly inefficient way to get the (constant) group order... + BN_bin2bn(vchTweak, 32, bnTweak); + if (BN_cmp(bnTweak, bnOrder) >= 0) + ret = false; // extremely unlikely + EC_POINT *point = EC_POINT_dup(EC_KEY_get0_public_key(pkey), group); + BN_one(bnOne); + EC_POINT_mul(group, point, bnTweak, point, bnOne, ctx); + if (EC_POINT_is_at_infinity(group, point)) + ret = false; // ridiculously unlikely + EC_KEY_set_public_key(pkey, point); + EC_POINT_free(point); + BN_CTX_end(ctx); + BN_CTX_free(ctx); + return ret; + } +}; + +//#endif + +int CompareBigEndian(const unsigned char *c1, size_t c1len, const unsigned char *c2, size_t c2len) { + while (c1len > c2len) { + if (*c1) + return 1; + c1++; + c1len--; + } + while (c2len > c1len) { + if (*c2) + return -1; + c2++; + c2len--; + } + while (c1len > 0) { + if (*c1 > *c2) + return 1; + if (*c2 > *c1) + return -1; + c1++; + c2++; + c1len--; + } + return 0; +} + +// Order of secp256k1's generator minus 1. +const unsigned char vchMaxModOrder[32] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B, + 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x40 +}; + +// Half of the order of secp256k1's generator minus 1. +const unsigned char vchMaxModHalfOrder[32] = { + 0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x5D,0x57,0x6E,0x73,0x57,0xA4,0x50,0x1D, + 0xDF,0xE9,0x2F,0x46,0x68,0x1B,0x20,0xA0 +}; + +const unsigned char vchZero[0] = {}; + +}; // end of anonymous namespace + + +bool CKey::Check(const unsigned char *vch) { + // Do not convert to OpenSSL's data structures for range-checking keys, + // it's easy enough to do directly. + static const unsigned char vchMax[32] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B, + 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x40 + }; + bool fIsZero = true; + for (int i=0; i<32 && fIsZero; i++) + if (vch[i] != 0) + fIsZero = false; + if (fIsZero) + return false; + for (int i=0; i<32; i++) { + if (vch[i] < vchMax[i]) + return true; + if (vch[i] > vchMax[i]) + return false; + } + return true; +} + +bool CKey::CheckSignatureElement(const unsigned char *vch, int len, bool half) { + return CompareBigEndian(vch, len, vchZero, 0) > 0 && + CompareBigEndian(vch, len, half ? vchMaxModHalfOrder : vchMaxModOrder, 32) <= 0; +} + +bool CKey::ReserealizeSignature(std::vector& vchSig) { + unsigned char *pos; + + if (vchSig.empty()) + return false; + + pos = &vchSig[0]; + ECDSA_SIG *sig = d2i_ECDSA_SIG(NULL, (const unsigned char **)&pos, vchSig.size()); + if (sig == NULL) + return false; + + bool ret = false; + int nSize = i2d_ECDSA_SIG(sig, NULL); + if (nSize > 0) { + vchSig.resize(nSize); // grow or shrink as needed + + pos = &vchSig[0]; + i2d_ECDSA_SIG(sig, &pos); + + ret = true; + } + + ECDSA_SIG_free(sig); + return ret; +} + +void CKey::MakeNewKey(bool fCompressedIn) { + do { + RAND_bytes(vch, sizeof(vch)); + } while (!Check(vch)); + fValid = true; + fCompressed = fCompressedIn; +} + +bool CKey::SetPrivKey(const CPrivKey &privkey, bool fCompressedIn) { +#ifdef USE_SECP256K1 + if (!secp256k1_ec_privkey_import(instance_of_csecp256k1.ctx, (unsigned char*)begin(), &privkey[0], privkey.size())) + return false; +#else + CECKey key; + if (!key.SetPrivKey(privkey)) + return false; + key.GetSecretBytes(vch); +#endif + fCompressed = fCompressedIn; + fValid = true; + return true; +} + +CPrivKey CKey::GetPrivKey() const { + assert(fValid); + CPrivKey privkey; +#ifdef USE_SECP256K1 + privkey.resize(279); + int privkeylen = 279; + int ret = secp256k1_ec_privkey_export(instance_of_csecp256k1.ctx, begin(), (unsigned char*)&privkey[0], &privkeylen, fCompressed); + assert(ret); + privkey.resize(privkeylen); +#else + CECKey key; + key.SetSecretBytes(vch); + key.GetPrivKey(privkey, fCompressed); +#endif + return privkey; +} + +CPubKey CKey::GetPubKey() const { + assert(fValid); + CPubKey pubkey; +#ifdef USE_SECP256K1 + int clen = 65; + int ret = secp256k1_ec_pubkey_create(instance_of_csecp256k1.ctx, (unsigned char*)pubkey.begin(), &clen, begin(), fCompressed); + assert(ret); + assert(pubkey.IsValid()); + assert((int)pubkey.size() == clen); +#else + CECKey key; + key.SetSecretBytes(vch); + key.GetPubKey(pubkey, fCompressed); +#endif + return pubkey; +} + +bool CKey::Sign(const uint256 &hash, std::vector& vchSig) const { + if (!fValid) + return false; +#ifdef USE_SECP256K1 + vchSig.resize(72); + int nSigLen = 72; + CKey nonce; + do { + nonce.MakeNewKey(true); + + if (secp256k1_ecdsa_sign(instance_of_csecp256k1.ctx, hash.begin(), (unsigned char*)&vchSig[0], &nSigLen, begin(), secp256k1_nonce_function_rfc6979, NULL)) + //if (secp256k1_ecdsa_sign((const unsigned char*)&hash, 32, (unsigned char*)&vchSig[0], &nSigLen, begin(), nonce.begin())) + + //if (secp256k1_ecdsa_sign((const unsigned char*)&hash, 32, vchSig.begin(), &nSigLen, begin(), nonce.begin())) + break; + } while(true); + vchSig.resize(nSigLen); + return true; +#else + CECKey key; + key.SetSecretBytes(vch); + return key.Sign(hash, vchSig); +#endif +} + +bool CKey::SignCompact(const uint256 &hash, std::vector& vchSig) const { + if (!fValid) + return false; + vchSig.resize(65); + int rec = -1; +#ifdef USE_SECP256K1 + CKey nonce; + do { + nonce.MakeNewKey(true); + if (int ret = secp256k1_ecdsa_sign_compact(instance_of_csecp256k1.ctx, hash.begin(), &vchSig[1], begin(), secp256k1_nonce_function_rfc6979, NULL, &rec)) + break; + } while(true); +#else + CECKey key; + key.SetSecretBytes(vch); + if (!key.SignCompact(hash, &vchSig[1], rec)) + return false; +#endif + assert(rec != -1); + vchSig[0] = 27 + rec + (fCompressed ? 4 : 0); + return true; +} + +bool CKey::Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck=false) { +#ifdef USE_SECP256K1 + if (!secp256k1_ec_privkey_import(instance_of_csecp256k1.ctx, (unsigned char*)begin(), &privkey[0], privkey.size())) + return false; +#else + CECKey key; + if (!key.SetPrivKey(privkey, fSkipCheck)) + return false; + + key.GetSecretBytes(vch); +#endif + fCompressed = vchPubKey.IsCompressed(); + fValid = true; + + if (fSkipCheck) + return true; + + if (GetPubKey() != vchPubKey) + return false; + + return true; +} + +bool CPubKey::Verify(const uint256 &hash, const std::vector& vchSig) const { + if (!IsValid()) + return false; +/*#ifdef USE_SECP256K1 + if (secp256k1_ecdsa_verify(hash.begin(), 32, &vchSig[0], vchSig.size(), begin(), size()) != 1) + return false; +#else*/ + CECKey key; + if (!key.SetPubKey(*this)) + return false; + if (!key.Verify(hash, vchSig)) + return false; +//#endif + return true; +} + +bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector& vchSig) { + if (vchSig.size() != 65) + return false; + int recid = (vchSig[0] - 27) & 3; + bool fComp = (vchSig[0] - 27) & 4; +/*#ifdef USE_SECP256K1 + int pubkeylen = 65; + if (!secp256k1_ecdsa_recover_compact(hash.begin(), 32, &vchSig[1], begin(), &pubkeylen, fComp, recid)) + return false; + assert((int)size() == pubkeylen); +#else*/ + CECKey key; + //if (!key.Recover(hash, &vchSig[1], (vchSig[0] - 27) & ~4)) + if (!key.Recover(hash, &vchSig[1], recid)) + return false; + //key.GetPubKey(*this, (vchSig[0] - 27) & 4); + key.GetPubKey(*this, fComp); +//#endif + return true; +} + +bool CPubKey::VerifyCompact(const uint256 &hash, const std::vector& vchSig) const { + if (!IsValid()) + return false; + if (vchSig.size() != 65) + return false; + int recid = (vchSig[0] - 27) & 3; + CPubKey pubkeyRec; +/*#ifdef USE_SECP256K1 + bool fComp = IsCompressed(); + int pubkeylen = 65; + if (!secp256k1_ecdsa_recover_compact(hash.begin(), 32, &vchSig[1], pubkeyRec.begin(), &pubkeylen, fComp, recid)) + return false; + assert((int)pubkeyRec.size() == pubkeylen); +#else*/ + CECKey key; + if (!key.Recover(hash, &vchSig[1], recid)) + return false; + key.GetPubKey(pubkeyRec, IsCompressed()); +//#endif + if (*this != pubkeyRec) + return false; + return true; +} + +bool CPubKey::IsFullyValid() const { + if (!IsValid()) + return false; +#ifdef USE_SECP256K1 + if (!secp256k1_ec_pubkey_verify(instance_of_csecp256k1.ctx, begin(), size())) + return false; +#else + CECKey key; + if (!key.SetPubKey(*this)) + return false; +#endif + return true; +} + +bool CPubKey::Decompress() { + if (!IsValid()) + return false; +#ifdef USE_SECP256K1 + int clen = size(); + int ret = secp256k1_ec_pubkey_decompress(instance_of_csecp256k1.ctx, (unsigned char*)begin(), &clen); + assert(ret); + assert(clen == (int)size()); +#else + CECKey key; + if (!key.SetPubKey(*this)) + return false; + key.GetPubKey(*this, false); +#endif + return true; +} + +void static BIP32Hash(const unsigned char chainCode[32], unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64]) { + unsigned char num[4]; + num[0] = (nChild >> 24) & 0xFF; + num[1] = (nChild >> 16) & 0xFF; + num[2] = (nChild >> 8) & 0xFF; + num[3] = (nChild >> 0) & 0xFF; + HMAC_SHA512_CTX ctx; + HMAC_SHA512_Init(&ctx, chainCode, 32); + HMAC_SHA512_Update(&ctx, &header, 1); + HMAC_SHA512_Update(&ctx, data, 32); + HMAC_SHA512_Update(&ctx, num, 4); + HMAC_SHA512_Final(output, &ctx); +} + +bool CKey::Derive(CKey& keyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const { + assert(IsValid()); + assert(IsCompressed()); + unsigned char out[64]; + LockObject(out); + if ((nChild >> 31) == 0) { + CPubKey pubkey = GetPubKey(); + assert(pubkey.begin() + 33 == pubkey.end()); + BIP32Hash(cc, nChild, *pubkey.begin(), pubkey.begin()+1, out); + } else { + assert(begin() + 32 == end()); + BIP32Hash(cc, nChild, 0, begin(), out); + } + memcpy(ccChild, out+32, 32); +#ifdef USE_SECP256K1 + memcpy((unsigned char*)keyChild.begin(), begin(), 32); + bool ret = secp256k1_ec_privkey_tweak_add(instance_of_csecp256k1.ctx, (unsigned char*)keyChild.begin(), out); +#else + bool ret = CECKey::TweakSecret((unsigned char*)keyChild.begin(), begin(), out); +#endif + UnlockObject(out); + keyChild.fCompressed = true; + keyChild.fValid = ret; + return ret; +} + +bool CPubKey::Derive(CPubKey& pubkeyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const { + assert(IsValid()); + assert((nChild >> 31) == 0); + assert(begin() + 33 == end()); + unsigned char out[64]; + BIP32Hash(cc, nChild, *begin(), begin()+1, out); + memcpy(ccChild, out+32, 32); +#ifdef USE_SECP256K1 + pubkeyChild = *this; + bool ret = secp256k1_ec_pubkey_tweak_add(instance_of_csecp256k1.ctx, (unsigned char*)pubkeyChild.begin(), pubkeyChild.size(), out); +#else + CECKey key; + bool ret = key.SetPubKey(*this); + ret &= key.TweakPublic(out); + key.GetPubKey(pubkeyChild, true); +#endif + return ret; +} + +bool CExtKey::Derive(CExtKey &out, unsigned int nChild) const { + out.nDepth = nDepth + 1; + CKeyID id = key.GetPubKey().GetID(); + memcpy(&out.vchFingerprint[0], &id, 4); + out.nChild = nChild; + return key.Derive(out.key, out.vchChainCode, nChild, vchChainCode); +} + +void CExtKey::SetMaster(const unsigned char *seed, unsigned int nSeedLen) { + static const char hashkey[] = {'B','i','t','c','o','i','n',' ','s','e','e','d'}; + HMAC_SHA512_CTX ctx; + HMAC_SHA512_Init(&ctx, hashkey, sizeof(hashkey)); + HMAC_SHA512_Update(&ctx, seed, nSeedLen); + unsigned char out[64]; + LockObject(out); + HMAC_SHA512_Final(out, &ctx); + key.Set(&out[0], &out[32], true); + memcpy(vchChainCode, &out[32], 32); + UnlockObject(out); + nDepth = 0; + nChild = 0; + memset(vchFingerprint, 0, sizeof(vchFingerprint)); +} + +CExtPubKey CExtKey::Neuter() const { + CExtPubKey ret; + ret.nDepth = nDepth; + memcpy(&ret.vchFingerprint[0], &vchFingerprint[0], 4); + ret.nChild = nChild; + ret.pubkey = key.GetPubKey(); + memcpy(&ret.vchChainCode[0], &vchChainCode[0], 32); + return ret; +} + +void CExtKey::Encode(unsigned char code[74]) const { + code[0] = nDepth; + memcpy(code+1, vchFingerprint, 4); + code[5] = (nChild >> 24) & 0xFF; code[6] = (nChild >> 16) & 0xFF; + code[7] = (nChild >> 8) & 0xFF; code[8] = (nChild >> 0) & 0xFF; + memcpy(code+9, vchChainCode, 32); + code[41] = 0; + assert(key.size() == 32); + memcpy(code+42, key.begin(), 32); +} + +void CExtKey::Decode(const unsigned char code[74]) { + nDepth = code[0]; + memcpy(vchFingerprint, code+1, 4); + nChild = (code[5] << 24) | (code[6] << 16) | (code[7] << 8) | code[8]; + memcpy(vchChainCode, code+9, 32); + key.Set(code+42, code+74, true); +} + +void CExtPubKey::Encode(unsigned char code[74]) const { + code[0] = nDepth; + memcpy(code+1, vchFingerprint, 4); + code[5] = (nChild >> 24) & 0xFF; code[6] = (nChild >> 16) & 0xFF; + code[7] = (nChild >> 8) & 0xFF; code[8] = (nChild >> 0) & 0xFF; + memcpy(code+9, vchChainCode, 32); + assert(pubkey.size() == 33); + memcpy(code+41, pubkey.begin(), 33); +} + +void CExtPubKey::Decode(const unsigned char code[74]) { + nDepth = code[0]; + memcpy(vchFingerprint, code+1, 4); + nChild = (code[5] << 24) | (code[6] << 16) | (code[7] << 8) | code[8]; + memcpy(vchChainCode, code+9, 32); + pubkey.Set(code+41, code+74); +} + +bool CExtPubKey::Derive(CExtPubKey &out, unsigned int nChild) const { + out.nDepth = nDepth + 1; + CKeyID id = pubkey.GetID(); + memcpy(&out.vchFingerprint[0], &id, 4); + out.nChild = nChild; + return pubkey.Derive(out.pubkey, out.vchChainCode, nChild, vchChainCode); +} + +bool ECC_InitSanityCheck() { +#ifdef USE_SECP256K1 + return true; +#else + EC_KEY *pkey = EC_KEY_new_by_curve_name(NID_secp256k1); + if(pkey == NULL) + return false; + EC_KEY_free(pkey); + + // TODO Is there more EC functionality that could be missing? + return true; +#endif +} + diff --git a/src/key.h b/src/key.h new file mode 100644 index 0000000..87a068c --- /dev/null +++ b/src/key.h @@ -0,0 +1,326 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_KEY_H +#define BITCOIN_KEY_H + +#include + +#include "allocators.h" +#include "serialize.h" +#include "uint256.h" +#include "hash.h" + +// secp256k1: +// const unsigned int PRIVATE_KEY_SIZE = 279; +// const unsigned int PUBLIC_KEY_SIZE = 65; +// const unsigned int SIGNATURE_SIZE = 72; +// +// see www.keylength.com +// script supports up to 75 for single byte push + +/** A reference to a CKey: the Hash160 of its serialized public key */ +class CKeyID : public uint160 +{ +public: + CKeyID() : uint160(0) { } + CKeyID(const uint160 &in) : uint160(in) { } +}; + +/** A reference to a CScript: the Hash160 of its serialization (see script.h) */ +class CScriptID : public uint160 +{ +public: + CScriptID() : uint160(0) { } + CScriptID(const uint160 &in) : uint160(in) { } +}; + +/** An encapsulated public key. */ +class CPubKey { +private: + // Just store the serialized data. + // Its length can very cheaply be computed from the first byte. + unsigned char vch[65]; + + // Compute the length of a pubkey with a given first byte. + unsigned int static GetLen(unsigned char chHeader) { + if (chHeader == 2 || chHeader == 3) + return 33; + if (chHeader == 4 || chHeader == 6 || chHeader == 7) + return 65; + return 0; + } + + // Set this key data to be invalid + void Invalidate() { + vch[0] = 0xFF; + } + +public: + // Construct an invalid public key. + CPubKey() { + Invalidate(); + } + + // Initialize a public key using begin/end iterators to byte data. + template + void Set(const T pbegin, const T pend) { + int len = pend == pbegin ? 0 : GetLen(pbegin[0]); + if (len && len == (pend-pbegin)) + memcpy(vch, (unsigned char*)&pbegin[0], len); + else + Invalidate(); + } + + // Construct a public key using begin/end iterators to byte data. + template + CPubKey(const T pbegin, const T pend) { + Set(pbegin, pend); + } + + // Construct a public key from a byte vector. + CPubKey(const std::vector &vch) { + Set(vch.begin(), vch.end()); + } + + // Simple read-only vector-like interface to the pubkey data. + unsigned int size() const { return GetLen(vch[0]); } + const unsigned char *begin() const { return vch; } + const unsigned char *end() const { return vch+size(); } + const unsigned char &operator[](unsigned int pos) const { return vch[pos]; } + + // Comparator implementation. + friend bool operator==(const CPubKey &a, const CPubKey &b) { + return a.vch[0] == b.vch[0] && + memcmp(a.vch, b.vch, a.size()) == 0; + } + friend bool operator!=(const CPubKey &a, const CPubKey &b) { + return !(a == b); + } + friend bool operator<(const CPubKey &a, const CPubKey &b) { + return a.vch[0] < b.vch[0] || + (a.vch[0] == b.vch[0] && memcmp(a.vch, b.vch, a.size()) < 0); + } + + // Implement serialization, as if this was a byte vector. + unsigned int GetSerializeSize(int nType, int nVersion) const { + return size() + 1; + } + template void Serialize(Stream &s, int nType, int nVersion) const { + unsigned int len = size(); + ::WriteCompactSize(s, len); + s.write((char*)vch, len); + } + template void Unserialize(Stream &s, int nType, int nVersion) { + unsigned int len = ::ReadCompactSize(s); + if (len <= 65) { + s.read((char*)vch, len); + } else { + // invalid pubkey, skip available data + char dummy; + while (len--) + s.read(&dummy, 1); + Invalidate(); + } + } + + // Get the KeyID of this public key (hash of its serialization) + CKeyID GetID() const { + return CKeyID(Hash160(vch, vch+size())); + } + + // Get the 256-bit hash of this public key. + uint256 GetHash() const { + return Hash(vch, vch+size()); + } + + // Check syntactic correctness. + // + // Note that this is consensus critical as CheckSig() calls it! + bool IsValid() const { + return size() > 0; + } + + // fully validate whether this is a valid public key (more expensive than IsValid()) + bool IsFullyValid() const; + + // Check whether this is a compressed public key. + bool IsCompressed() const { + return size() == 33; + } + + // Verify a DER signature (~72 bytes). + // If this public key is not fully valid, the return value will be false. + bool Verify(const uint256 &hash, const std::vector& vchSig) const; + + // Verify a compact signature (~65 bytes). + // See CKey::SignCompact. + bool VerifyCompact(const uint256 &hash, const std::vector& vchSig) const; + + // Recover a public key from a compact signature. + bool RecoverCompact(const uint256 &hash, const std::vector& vchSig); + + // Turn this public key into an uncompressed public key. + bool Decompress(); + + // Derive BIP32 child pubkey. + bool Derive(CPubKey& pubkeyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const; + + // Raw for stealth address + std::vector Raw() const { + std::vector r; + r.insert(r.end(), vch, vch+size()); + return r; + } +}; + + +// secure_allocator is defined in allocators.h +// CPrivKey is a serialized private key, with all parameters included (279 bytes) +typedef std::vector > CPrivKey; +// CSecret is a serialization of just the secret parameter (32 bytes) +typedef std::vector > CSecret; + +/** An encapsulated private key. */ +class CKey { +private: + // Whether this private key is valid. We check for correctness when modifying the key + // data, so fValid should always correspond to the actual state. + bool fValid; + + // Whether the public key corresponding to this private key is (to be) compressed. + bool fCompressed; + + // The actual byte data + unsigned char vch[32]; + + // Check whether the 32-byte array pointed to be vch is valid keydata. + bool static Check(const unsigned char *vch); +public: + + // Construct an invalid private key. + CKey() : fValid(false) { + LockObject(vch); + } + + // Copy constructor. This is necessary because of memlocking. + CKey(const CKey &secret) : fValid(secret.fValid), fCompressed(secret.fCompressed) { + LockObject(vch); + memcpy(vch, secret.vch, sizeof(vch)); + } + + // Destructor (again necessary because of memlocking). + ~CKey() { + UnlockObject(vch); + } + + friend bool operator==(const CKey &a, const CKey &b) { + return a.fCompressed == b.fCompressed && a.size() == b.size() && + memcmp(&a.vch[0], &b.vch[0], a.size()) == 0; + } + + // Initialize using begin and end iterators to byte data. + template + void Set(const T pbegin, const T pend, bool fCompressedIn) { + if (pend - pbegin != 32) { + fValid = false; + return; + } + if (Check(&pbegin[0])) { + memcpy(vch, (unsigned char*)&pbegin[0], 32); + fValid = true; + fCompressed = fCompressedIn; + } else { + fValid = false; + } + } + + // Simple read-only vector-like interface. + unsigned int size() const { return (fValid ? 32 : 0); } + const unsigned char *begin() const { return vch; } + const unsigned char *end() const { return vch + size(); } + + // Check whether this private key is valid. + bool IsValid() const { return fValid; } + + // Check whether the public key corresponding to this private key is (to be) compressed. + bool IsCompressed() const { return fCompressed; } + + // Initialize from a CPrivKey (serialized OpenSSL private key data). + bool SetPrivKey(const CPrivKey &vchPrivKey, bool fCompressed); + + // Generate a new private key using a cryptographic PRNG. + void MakeNewKey(bool fCompressed); + + // Convert the private key to a CPrivKey (serialized OpenSSL private key data). + // This is expensive. + CPrivKey GetPrivKey() const; + + // Compute the public key from a private key. + // This is expensive. + CPubKey GetPubKey() const; + + // Create a DER-serialized signature. + bool Sign(const uint256 &hash, std::vector& vchSig) const; + + // Create a compact signature (65 bytes), which allows reconstructing the used public key. + // The format is one header byte, followed by two times 32 bytes for the serialized r and s values. + // The header byte: 0x1B = first key with even y, 0x1C = first key with odd y, + // 0x1D = second key with even y, 0x1E = second key with odd y, + // add 0x04 for compressed keys. + bool SignCompact(const uint256 &hash, std::vector& vchSig) const; + + // Derive BIP32 child key. + bool Derive(CKey& keyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const; + + // Load private key and check that public key matches. + bool Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck); + + // Check whether an element of a signature (r or s) is valid. + static bool CheckSignatureElement(const unsigned char *vch, int len, bool half); + + // Ensure that signature is DER-encoded + static bool ReserealizeSignature(std::vector& vchSig); +}; + +struct CExtPubKey { + unsigned char nDepth; + unsigned char vchFingerprint[4]; + unsigned int nChild; + unsigned char vchChainCode[32]; + CPubKey pubkey; + + friend bool operator==(const CExtPubKey &a, const CExtPubKey &b) { + return a.nDepth == b.nDepth && memcmp(&a.vchFingerprint[0], &b.vchFingerprint[0], 4) == 0 && a.nChild == b.nChild && + memcmp(&a.vchChainCode[0], &b.vchChainCode[0], 32) == 0 && a.pubkey == b.pubkey; + } + + void Encode(unsigned char code[74]) const; + void Decode(const unsigned char code[74]); + bool Derive(CExtPubKey &out, unsigned int nChild) const; +}; + +struct CExtKey { + unsigned char nDepth; + unsigned char vchFingerprint[4]; + unsigned int nChild; + unsigned char vchChainCode[32]; + CKey key; + + friend bool operator==(const CExtKey &a, const CExtKey &b) { + return a.nDepth == b.nDepth && memcmp(&a.vchFingerprint[0], &b.vchFingerprint[0], 4) == 0 && a.nChild == b.nChild && + memcmp(&a.vchChainCode[0], &b.vchChainCode[0], 32) == 0 && a.key == b.key; + } + + void Encode(unsigned char code[74]) const; + void Decode(const unsigned char code[74]); + bool Derive(CExtKey &out, unsigned int nChild) const; + CExtPubKey Neuter() const; + void SetMaster(const unsigned char *seed, unsigned int nSeedLen); +}; + +/** Check that required EC support is available at runtime */ +bool ECC_InitSanityCheck(void); + +#endif diff --git a/src/keystore.cpp b/src/keystore.cpp new file mode 100644 index 0000000..de15eef --- /dev/null +++ b/src/keystore.cpp @@ -0,0 +1,59 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "keystore.h" +#include "script.h" + + +bool CKeyStore::GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const +{ + CKey key; + if (!GetKey(address, key)) + return false; + vchPubKeyOut = key.GetPubKey(); + return true; +} + +bool CKeyStore::AddKey(const CKey &key) { + return AddKeyPubKey(key, key.GetPubKey()); +} + +bool CBasicKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey) +{ + LOCK(cs_KeyStore); + mapKeys[pubkey.GetID()] = key; + return true; +} + +bool CBasicKeyStore::AddCScript(const CScript& redeemScript) +{ + if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE) + return error("CBasicKeyStore::AddCScript() : redeemScripts > %i bytes are invalid", MAX_SCRIPT_ELEMENT_SIZE); + + LOCK(cs_KeyStore); + mapScripts[redeemScript.GetID()] = redeemScript; + return true; +} + +bool CBasicKeyStore::HaveCScript(const CScriptID& hash) const +{ + LOCK(cs_KeyStore); + return mapScripts.count(hash) > 0; +} + +bool CBasicKeyStore::GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const +{ + LOCK(cs_KeyStore); + ScriptMap::const_iterator mi = mapScripts.find(hash); + if (mi != mapScripts.end()) + { + redeemScriptOut = (*mi).second; + return true; + } + return false; +} + + + diff --git a/src/keystore.h b/src/keystore.h new file mode 100644 index 0000000..38fd142 --- /dev/null +++ b/src/keystore.h @@ -0,0 +1,97 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_KEYSTORE_H +#define BITCOIN_KEYSTORE_H + +#include "key.h" +#include "sync.h" +#include +#include "script.h" + + +class CScript; + +/** A virtual base class for key stores */ +class CKeyStore +{ +protected: + mutable CCriticalSection cs_KeyStore; + +public: + virtual ~CKeyStore() {} + + // Add a key to the store. + virtual bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) =0; + virtual bool AddKey(const CKey &key); + + // Check whether a key corresponding to a given address is present in the store. + virtual bool HaveKey(const CKeyID &address) const =0; + virtual bool GetKey(const CKeyID &address, CKey& keyOut) const =0; + virtual void GetKeys(std::set &setAddress) const =0; + virtual bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const; + + // Support for BIP 0013 : see https://en.bitcoin.it/wiki/BIP_0013 + virtual bool AddCScript(const CScript& redeemScript) =0; + virtual bool HaveCScript(const CScriptID &hash) const =0; + virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const =0; +}; + +typedef std::map KeyMap; +typedef std::map ScriptMap; + +/** Basic key store, that keeps keys in an address->secret map */ +class CBasicKeyStore : public CKeyStore +{ +protected: + KeyMap mapKeys; + ScriptMap mapScripts; + +public: + bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey); + bool HaveKey(const CKeyID &address) const + { + bool result; + { + LOCK(cs_KeyStore); + result = (mapKeys.count(address) > 0); + } + return result; + } + void GetKeys(std::set &setAddress) const + { + setAddress.clear(); + { + LOCK(cs_KeyStore); + KeyMap::const_iterator mi = mapKeys.begin(); + while (mi != mapKeys.end()) + { + setAddress.insert((*mi).first); + mi++; + } + } + } + bool GetKey(const CKeyID &address, CKey &keyOut) const + { + { + LOCK(cs_KeyStore); + KeyMap::const_iterator mi = mapKeys.find(address); + if (mi != mapKeys.end()) + { + keyOut = mi->second; + return true; + } + } + return false; + } + virtual bool AddCScript(const CScript& redeemScript); + virtual bool HaveCScript(const CScriptID &hash) const; + virtual bool GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const; +}; + +typedef std::map > > CryptedKeyMap; + + + +#endif diff --git a/src/leveldb/.gitcore b/src/leveldb/.gitcore new file mode 100644 index 0000000..0630251 --- /dev/null +++ b/src/leveldb/.gitcore @@ -0,0 +1,9 @@ +build_config.mk +*.a +*.o +*.dylib* +*.so +*.so.* +*_test +db_bench +leveldbutil diff --git a/src/leveldb/.gitignore b/src/leveldb/.gitignore new file mode 100644 index 0000000..71d87a4 --- /dev/null +++ b/src/leveldb/.gitignore @@ -0,0 +1,13 @@ +build_config.mk +*.a +*.o +*.dylib* +*.so +*.so.* +*_test +db_bench +leveldbutil +Release +Debug +Benchmark +vs2010.* diff --git a/src/leveldb/.travis.yml b/src/leveldb/.travis.yml new file mode 100644 index 0000000..f5bd74c --- /dev/null +++ b/src/leveldb/.travis.yml @@ -0,0 +1,13 @@ +language: cpp +compiler: +- clang +- gcc +os: +- linux +- osx +sudo: false +before_install: +- echo $LANG +- echo $LC_ALL +script: +- make -j 4 check diff --git a/src/leveldb/AUTHORS b/src/leveldb/AUTHORS new file mode 100755 index 0000000..2439d7a --- /dev/null +++ b/src/leveldb/AUTHORS @@ -0,0 +1,12 @@ +# Names should be added to this file like so: +# Name or Organization + +Google Inc. + +# Initial version authors: +Jeffrey Dean +Sanjay Ghemawat + +# Partial list of contributors: +Kevin Regan +Johan Bilien diff --git a/src/leveldb/LICENSE b/src/leveldb/LICENSE new file mode 100755 index 0000000..8e80208 --- /dev/null +++ b/src/leveldb/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2011 The LevelDB Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/leveldb/Makefile b/src/leveldb/Makefile new file mode 100755 index 0000000..344ff29 --- /dev/null +++ b/src/leveldb/Makefile @@ -0,0 +1,214 @@ +# Copyright (c) 2011 The LevelDB Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. See the AUTHORS file for names of contributors. + +#----------------------------------------------- +# Uncomment exactly one of the lines labelled (A), (B), and (C) below +# to switch between compilation modes. + +OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode) +# OPT ?= -g2 # (B) Debug mode, w/ full line-level debugging symbols +# OPT ?= -O2 -g2 -DNDEBUG # (C) Profiling mode: opt, but w/debugging symbols +#----------------------------------------------- + +# detect what platform we're building on +$(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \ + ./build_detect_platform build_config.mk ./) +# this file is generated by the previous line to set build flags and sources +include build_config.mk + +CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT) +CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) + +LDFLAGS += $(PLATFORM_LDFLAGS) +LIBS += $(PLATFORM_LIBS) + +LIBOBJECTS = $(SOURCES:.cc=.o) +MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o) + +TESTUTIL = ./util/testutil.o +TESTHARNESS = ./util/testharness.o $(TESTUTIL) + +TESTS = \ + arena_test \ + autocompact_test \ + bloom_test \ + c_test \ + cache_test \ + coding_test \ + corruption_test \ + crc32c_test \ + db_test \ + dbformat_test \ + env_test \ + filename_test \ + filter_block_test \ + issue178_test \ + issue200_test \ + log_test \ + memenv_test \ + skiplist_test \ + table_test \ + version_edit_test \ + version_set_test \ + write_batch_test + +PROGRAMS = db_bench leveldbutil $(TESTS) +BENCHMARKS = db_bench_sqlite3 db_bench_tree_db + +LIBRARY = libleveldb.a +MEMENVLIBRARY = libmemenv.a + +default: all + +# Should we build shared libraries? +ifneq ($(PLATFORM_SHARED_EXT),) + +ifneq ($(PLATFORM_SHARED_VERSIONED),true) +SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT) +SHARED2 = $(SHARED1) +SHARED3 = $(SHARED1) +SHARED = $(SHARED1) +else +# Update db.h if you change these. +SHARED_MAJOR = 1 +SHARED_MINOR = 15 +SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT) +SHARED2 = $(SHARED1).$(SHARED_MAJOR) +SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR) +SHARED = $(SHARED1) $(SHARED2) $(SHARED3) +$(SHARED1): $(SHARED3) + ln -fs $(SHARED3) $(SHARED1) +$(SHARED2): $(SHARED3) + ln -fs $(SHARED3) $(SHARED2) +endif + +$(SHARED3): + $(CXX) $(LDFLAGS) $(PLATFORM_SHARED_LDFLAGS)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(SOURCES) -o $(SHARED3) $(LIBS) + +endif # PLATFORM_SHARED_EXT + +all: $(SHARED) $(LIBRARY) + +check: all $(PROGRAMS) $(TESTS) + for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done + +clean: + -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk + -rm -rf ios-x86/* ios-arm/* + +$(LIBRARY): $(LIBOBJECTS) + rm -f $@ + $(AR) -rs $@ $(LIBOBJECTS) + +db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) + $(CXX) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LIBS) + +db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) + $(CXX) $(LDFLAGS) doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lsqlite3 $(LIBS) + +db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) + $(CXX) $(LDFLAGS) doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lkyotocabinet $(LIBS) + +leveldbutil: db/leveldb_main.o $(LIBOBJECTS) + $(CXX) $(LDFLAGS) db/leveldb_main.o $(LIBOBJECTS) -o $@ $(LIBS) + +arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +autocompact_test: db/autocompact_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) db/autocompact_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +bloom_test: util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +issue178_test: issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +issue200_test: issues/issue200_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) issues/issue200_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS) + +$(MEMENVLIBRARY) : $(MEMENVOBJECTS) + rm -f $@ + $(AR) -rs $@ $(MEMENVOBJECTS) + +memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) + $(CXX) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LIBS) + +ifeq ($(PLATFORM), IOS) +# For iOS, create universal object files to be used on both the simulator and +# a device. +PLATFORMSROOT=/Applications/Xcode.app/Contents/Developer/Platforms +SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer +DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer +IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString) + +.cc.o: + mkdir -p ios-x86/$(dir $@) + $(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@ + mkdir -p ios-arm/$(dir $@) + xcrun -sdk iphoneos $(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@ + lipo ios-x86/$@ ios-arm/$@ -create -output $@ + +.c.o: + mkdir -p ios-x86/$(dir $@) + $(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@ + mkdir -p ios-arm/$(dir $@) + xcrun -sdk iphoneos $(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@ + lipo ios-x86/$@ ios-arm/$@ -create -output $@ + +else +.cc.o: + $(CXX) $(CXXFLAGS) -c $< -o $@ + +.c.o: + $(CC) $(CFLAGS) -c $< -o $@ +endif diff --git a/src/leveldb/NEWS b/src/leveldb/NEWS new file mode 100755 index 0000000..3fd9924 --- /dev/null +++ b/src/leveldb/NEWS @@ -0,0 +1,17 @@ +Release 1.2 2011-05-16 +---------------------- + +Fixes for larger databases (tested up to one billion 100-byte entries, +i.e., ~100GB). + +(1) Place hard limit on number of level-0 files. This fixes errors +of the form "too many open files". + +(2) Fixed memtable management. Before the fix, a heavy write burst +could cause unbounded memory usage. + +A fix for a logging bug where the reader would incorrectly complain +about corruption. + +Allow public access to WriteBatch contents so that users can easily +wrap a DB. diff --git a/src/leveldb/PLATFORM_CCFLAGS= b/src/leveldb/PLATFORM_CCFLAGS= new file mode 100755 index 0000000..fe83eb4 --- /dev/null +++ b/src/leveldb/PLATFORM_CCFLAGS= @@ -0,0 +1,13 @@ +SOURCES= port/port_posix.cc +MEMENV_SOURCES=helpers/memenv/memenv.cc +CC=cc +CXX=g++ +PLATFORM=OS_LINUX +PLATFORM_LDFLAGS=-pthread +PLATFORM_LIBS= +PLATFORM_CCFLAGS= -fno-builtin-memcmp -pthread -DOS_LINUX -DLEVELDB_PLATFORM_POSIX +PLATFORM_CXXFLAGS= -fno-builtin-memcmp -pthread -DOS_LINUX -DLEVELDB_PLATFORM_POSIX +PLATFORM_SHARED_CFLAGS=-fPIC +PLATFORM_SHARED_EXT=so +PLATFORM_SHARED_LDFLAGS=-shared -Wl,-soname -Wl, +PLATFORM_SHARED_VERSIONED=true diff --git a/src/leveldb/README b/src/leveldb/README new file mode 100755 index 0000000..3618ade --- /dev/null +++ b/src/leveldb/README @@ -0,0 +1,51 @@ +leveldb: A key-value store +Authors: Sanjay Ghemawat (sanjay@google.com) and Jeff Dean (jeff@google.com) + +The code under this directory implements a system for maintaining a +persistent key/value store. + +See doc/index.html for more explanation. +See doc/impl.html for a brief overview of the implementation. + +The public interface is in include/*.h. Callers should not include or +rely on the details of any other header files in this package. Those +internal APIs may be changed without warning. + +Guide to header files: + +include/db.h + Main interface to the DB: Start here + +include/options.h + Control over the behavior of an entire database, and also + control over the behavior of individual reads and writes. + +include/comparator.h + Abstraction for user-specified comparison function. If you want + just bytewise comparison of keys, you can use the default comparator, + but clients can write their own comparator implementations if they + want custom ordering (e.g. to handle different character + encodings, etc.) + +include/iterator.h + Interface for iterating over data. You can get an iterator + from a DB object. + +include/write_batch.h + Interface for atomically applying multiple updates to a database. + +include/slice.h + A simple module for maintaining a pointer and a length into some + other byte array. + +include/status.h + Status is returned from many of the public interfaces and is used + to report success and various kinds of errors. + +include/env.h + Abstraction of the OS environment. A posix implementation of + this interface is in util/env_posix.cc + +include/table.h +include/table_builder.h + Lower-level modules that most clients probably won't use directly diff --git a/src/leveldb/TODO b/src/leveldb/TODO new file mode 100755 index 0000000..e603c07 --- /dev/null +++ b/src/leveldb/TODO @@ -0,0 +1,14 @@ +ss +- Stats + +db +- Maybe implement DB::BulkDeleteForRange(start_key, end_key) + that would blow away files whose ranges are entirely contained + within [start_key..end_key]? For Chrome, deletion of obsolete + object stores, etc. can be done in the background anyway, so + probably not that important. +- There have been requests for MultiGet. + +After a range is completely deleted, what gets rid of the +corresponding files if we do no future changes to that range. Make +the conditions for triggering compactions fire in more situations? diff --git a/src/leveldb/WINDOWS.md b/src/leveldb/WINDOWS.md new file mode 100755 index 0000000..5b76c24 --- /dev/null +++ b/src/leveldb/WINDOWS.md @@ -0,0 +1,39 @@ +# Building LevelDB On Windows + +## Prereqs + +Install the [Windows Software Development Kit version 7.1](http://www.microsoft.com/downloads/dlx/en-us/listdetailsview.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b). + +Download and extract the [Snappy source distribution](http://snappy.googlecode.com/files/snappy-1.0.5.tar.gz) + +1. Open the "Windows SDK 7.1 Command Prompt" : + Start Menu -> "Microsoft Windows SDK v7.1" > "Windows SDK 7.1 Command Prompt" +2. Change the directory to the leveldb project + +## Building the Static lib + +* 32 bit Version + + setenv /x86 + msbuild.exe /p:Configuration=Release /p:Platform=Win32 /p:Snappy=..\snappy-1.0.5 + +* 64 bit Version + + setenv /x64 + msbuild.exe /p:Configuration=Release /p:Platform=x64 /p:Snappy=..\snappy-1.0.5 + + +## Building and Running the Benchmark app + +* 32 bit Version + + setenv /x86 + msbuild.exe /p:Configuration=Benchmark /p:Platform=Win32 /p:Snappy=..\snappy-1.0.5 + Benchmark\leveldb.exe + +* 64 bit Version + + setenv /x64 + msbuild.exe /p:Configuration=Benchmark /p:Platform=x64 /p:Snappy=..\snappy-1.0.5 + x64\Benchmark\leveldb.exe + diff --git a/src/leveldb/build_detect_platform b/src/leveldb/build_detect_platform new file mode 100755 index 0000000..85b1ce0 --- /dev/null +++ b/src/leveldb/build_detect_platform @@ -0,0 +1,224 @@ +#!/bin/sh +# +# Detects OS we're compiling on and outputs a file specified by the first +# argument, which in turn gets read while processing Makefile. +# +# The output will set the following variables: +# CC C Compiler path +# CXX C++ Compiler path +# PLATFORM_LDFLAGS Linker flags +# PLATFORM_LIBS Libraries flags +# PLATFORM_SHARED_EXT Extension for shared libraries +# PLATFORM_SHARED_LDFLAGS Flags for building shared library +# This flag is embedded just before the name +# of the shared library without intervening spaces +# PLATFORM_SHARED_CFLAGS Flags for compiling objects for shared library +# PLATFORM_CCFLAGS C compiler flags +# PLATFORM_CXXFLAGS C++ compiler flags. Will contain: +# PLATFORM_SHARED_VERSIONED Set to 'true' if platform supports versioned +# shared libraries, empty otherwise. +# +# The PLATFORM_CCFLAGS and PLATFORM_CXXFLAGS might include the following: +# +# -DLEVELDB_CSTDATOMIC_PRESENT if is present +# -DLEVELDB_PLATFORM_POSIX for Posix-based platforms +# -DSNAPPY if the Snappy library is present +# + +OUTPUT=$1 +PREFIX=$2 +if test -z "$OUTPUT" || test -z "$PREFIX"; then + echo "usage: $0 " >&2 + exit 1 +fi + +# Delete existing output, if it exists +rm -f $OUTPUT +touch $OUTPUT + +if test -z "$CC"; then + CC=cc +fi + +if test -z "$CXX"; then + CXX=g++ +fi + +if test -z "$TMPDIR"; then + TMPDIR=/tmp +fi + +# Detect OS +if test -z "$TARGET_OS"; then + TARGET_OS=`uname -s` +fi + +COMMON_FLAGS= +CROSS_COMPILE= +PLATFORM_CCFLAGS= +PLATFORM_CXXFLAGS= +PLATFORM_LDFLAGS= +PLATFORM_LIBS= +PLATFORM_SHARED_EXT="so" +PLATFORM_SHARED_LDFLAGS="-shared -Wl,-soname -Wl," +PLATFORM_SHARED_CFLAGS="-fPIC" +PLATFORM_SHARED_VERSIONED=true + +MEMCMP_FLAG= +if [ "$CXX" = "g++" ]; then + # Use libc's memcmp instead of GCC's memcmp. This results in ~40% + # performance improvement on readrandom under gcc 4.4.3 on Linux/x86. + MEMCMP_FLAG="-fno-builtin-memcmp" +fi + +case "$TARGET_OS" in + Darwin) + PLATFORM=OS_MACOSX + COMMON_FLAGS="$MEMCMP_FLAG -DOS_MACOSX" + PLATFORM_SHARED_EXT=dylib + [ -z "$INSTALL_PATH" ] && INSTALL_PATH=`pwd` + PLATFORM_SHARED_LDFLAGS="-dynamiclib -install_name $INSTALL_PATH/" + PORT_FILE=port/port_posix.cc + ;; + Linux) + PLATFORM=OS_LINUX + COMMON_FLAGS="$MEMCMP_FLAG -pthread -DOS_LINUX" + PLATFORM_LDFLAGS="-pthread" + PORT_FILE=port/port_posix.cc + ;; + SunOS) + PLATFORM=OS_SOLARIS + COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_SOLARIS" + PLATFORM_LIBS="-lpthread -lrt" + PORT_FILE=port/port_posix.cc + ;; + FreeBSD) + PLATFORM=OS_FREEBSD + COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_FREEBSD" + PLATFORM_LIBS="-lpthread" + PORT_FILE=port/port_posix.cc + ;; + GNU/kFreeBSD) + PLATFORM=OS_KFREEBSD + COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_KFREEBSD" + PLATFORM_LIBS="-lpthread" + PORT_FILE=port/port_posix.cc + ;; + NetBSD) + PLATFORM=OS_NETBSD + COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_NETBSD" + PLATFORM_LIBS="-lpthread -lgcc_s" + PORT_FILE=port/port_posix.cc + ;; + OpenBSD) + PLATFORM=OS_OPENBSD + COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_OPENBSD" + PLATFORM_LDFLAGS="-pthread" + PORT_FILE=port/port_posix.cc + ;; + DragonFly) + PLATFORM=OS_DRAGONFLYBSD + COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_DRAGONFLYBSD" + PLATFORM_LIBS="-lpthread" + PORT_FILE=port/port_posix.cc + ;; + OS_ANDROID_CROSSCOMPILE) + PLATFORM=OS_ANDROID + COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_ANDROID -DLEVELDB_PLATFORM_POSIX" + PLATFORM_LDFLAGS="" # All pthread features are in the Android C library + PORT_FILE=port/port_posix.cc + CROSS_COMPILE=true + ;; + HP-UX) + PLATFORM=OS_HPUX + COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_HPUX" + PLATFORM_LDFLAGS="-pthread" + PORT_FILE=port/port_posix.cc + # man ld: +h internal_name + PLATFORM_SHARED_LDFLAGS="-shared -Wl,+h -Wl," + ;; + IOS) + PLATFORM=IOS + COMMON_FLAGS="$MEMCMP_FLAG -DOS_MACOSX" + [ -z "$INSTALL_PATH" ] && INSTALL_PATH=`pwd` + PORT_FILE=port/port_posix.cc + PLATFORM_SHARED_EXT= + PLATFORM_SHARED_LDFLAGS= + PLATFORM_SHARED_CFLAGS= + PLATFORM_SHARED_VERSIONED= + ;; + OS_WINDOWS_CROSSCOMPILE | NATIVE_WINDOWS) + PLATFORM=OS_WINDOWS + COMMON_FLAGS="-fno-builtin-memcmp -D_REENTRANT -DOS_WINDOWS -DLEVELDB_PLATFORM_WINDOWS -DWINVER=0x0500 -D__USE_MINGW_ANSI_STDIO=1" + PLATFORM_SOURCES="util/env_win.cc" + PLATFORM_LIBS="-lshlwapi" + PORT_FILE=port/port_win.cc + CROSS_COMPILE=true + ;; + *) + echo "Unknown platform!" >&2 + exit 1 +esac + +# We want to make a list of all cc files within util, db, table, and helpers +# except for the test and benchmark files. By default, find will output a list +# of all files matching either rule, so we need to append -print to make the +# prune take effect. +DIRS="$PREFIX/db $PREFIX/util $PREFIX/table" + +set -f # temporarily disable globbing so that our patterns aren't expanded +PRUNE_TEST="-name *test*.cc -prune" +PRUNE_BENCH="-name *_bench.cc -prune" +PRUNE_TOOL="-name leveldb_main.cc -prune" +PORTABLE_FILES=`find $DIRS $PRUNE_TEST -o $PRUNE_BENCH -o $PRUNE_TOOL -o -name '*.cc' -print | sort | sed "s,^$PREFIX/,," | tr "\n" " "` + +set +f # re-enable globbing + +# The sources consist of the portable files, plus the platform-specific port +# file. +echo "SOURCES=$PORTABLE_FILES $PORT_FILE" >> $OUTPUT +echo "MEMENV_SOURCES=helpers/memenv/memenv.cc" >> $OUTPUT + +if [ "$CROSS_COMPILE" = "true" ]; then + # Cross-compiling; do not try any compilation tests. + true +else + CXXOUTPUT="${TMPDIR}/leveldb_build_detect_platform-cxx.$$" + + # If -std=c++0x works, use . Otherwise use port_posix.h. + $CXX $CXXFLAGS -std=c++0x -x c++ - -o $CXXOUTPUT 2>/dev/null < + int main() {} +EOF + if [ "$?" = 0 ]; then + COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_CSTDATOMIC_PRESENT" + PLATFORM_CXXFLAGS="-std=c++0x" + else + COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX" + fi + + # Test whether tcmalloc is available + $CXX $CXXFLAGS -x c++ - -o $CXXOUTPUT -ltcmalloc 2>/dev/null </dev/null +fi + +PLATFORM_CCFLAGS="$PLATFORM_CCFLAGS $COMMON_FLAGS" +PLATFORM_CXXFLAGS="$PLATFORM_CXXFLAGS $COMMON_FLAGS" + +echo "CC=$CC" >> $OUTPUT +echo "CXX=$CXX" >> $OUTPUT +echo "PLATFORM=$PLATFORM" >> $OUTPUT +echo "PLATFORM_LDFLAGS=$PLATFORM_LDFLAGS" >> $OUTPUT +echo "PLATFORM_LIBS=$PLATFORM_LIBS" >> $OUTPUT +echo "PLATFORM_CCFLAGS=$PLATFORM_CCFLAGS" >> $OUTPUT +echo "PLATFORM_CXXFLAGS=$PLATFORM_CXXFLAGS" >> $OUTPUT +echo "PLATFORM_SHARED_CFLAGS=$PLATFORM_SHARED_CFLAGS" >> $OUTPUT +echo "PLATFORM_SHARED_EXT=$PLATFORM_SHARED_EXT" >> $OUTPUT +echo "PLATFORM_SHARED_LDFLAGS=$PLATFORM_SHARED_LDFLAGS" >> $OUTPUT +echo "PLATFORM_SHARED_VERSIONED=$PLATFORM_SHARED_VERSIONED" >> $OUTPUT diff --git a/src/leveldb/db/autocompact_test.cc b/src/leveldb/db/autocompact_test.cc new file mode 100644 index 0000000..d20a236 --- /dev/null +++ b/src/leveldb/db/autocompact_test.cc @@ -0,0 +1,118 @@ +// Copyright (c) 2013 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/db.h" +#include "db/db_impl.h" +#include "leveldb/cache.h" +#include "util/testharness.h" +#include "util/testutil.h" + +namespace leveldb { + +class AutoCompactTest { + public: + std::string dbname_; + Cache* tiny_cache_; + Options options_; + DB* db_; + + AutoCompactTest() { + dbname_ = test::TmpDir() + "/autocompact_test"; + tiny_cache_ = NewLRUCache(100); + options_.block_cache = tiny_cache_; + DestroyDB(dbname_, options_); + options_.create_if_missing = true; + options_.compression = kNoCompression; + ASSERT_OK(DB::Open(options_, dbname_, &db_)); + } + + ~AutoCompactTest() { + delete db_; + DestroyDB(dbname_, Options()); + delete tiny_cache_; + } + + std::string Key(int i) { + char buf[100]; + snprintf(buf, sizeof(buf), "key%06d", i); + return std::string(buf); + } + + uint64_t Size(const Slice& start, const Slice& limit) { + Range r(start, limit); + uint64_t size; + db_->GetApproximateSizes(&r, 1, &size); + return size; + } + + void DoReads(int n); +}; + +static const int kValueSize = 200 * 1024; +static const int kTotalSize = 100 * 1024 * 1024; +static const int kCount = kTotalSize / kValueSize; + +// Read through the first n keys repeatedly and check that they get +// compacted (verified by checking the size of the key space). +void AutoCompactTest::DoReads(int n) { + std::string value(kValueSize, 'x'); + DBImpl* dbi = reinterpret_cast(db_); + + // Fill database + for (int i = 0; i < kCount; i++) { + ASSERT_OK(db_->Put(WriteOptions(), Key(i), value)); + } + ASSERT_OK(dbi->TEST_CompactMemTable()); + + // Delete everything + for (int i = 0; i < kCount; i++) { + ASSERT_OK(db_->Delete(WriteOptions(), Key(i))); + } + ASSERT_OK(dbi->TEST_CompactMemTable()); + + // Get initial measurement of the space we will be reading. + const int64_t initial_size = Size(Key(0), Key(n)); + const int64_t initial_other_size = Size(Key(n), Key(kCount)); + + // Read until size drops significantly. + std::string limit_key = Key(n); + for (int read = 0; true; read++) { + ASSERT_LT(read, 100) << "Taking too long to compact"; + Iterator* iter = db_->NewIterator(ReadOptions()); + for (iter->SeekToFirst(); + iter->Valid() && iter->key().ToString() < limit_key; + iter->Next()) { + // Drop data + } + delete iter; + // Wait a little bit to allow any triggered compactions to complete. + Env::Default()->SleepForMicroseconds(1000000); + uint64_t size = Size(Key(0), Key(n)); + fprintf(stderr, "iter %3d => %7.3f MB [other %7.3f MB]\n", + read+1, size/1048576.0, Size(Key(n), Key(kCount))/1048576.0); + if (size <= initial_size/10) { + break; + } + } + + // Verify that the size of the key space not touched by the reads + // is pretty much unchanged. + const int64_t final_other_size = Size(Key(n), Key(kCount)); + ASSERT_LE(final_other_size, initial_other_size + 1048576); + ASSERT_GE(final_other_size, initial_other_size/5 - 1048576); +} + +TEST(AutoCompactTest, ReadAll) { + DoReads(kCount); +} + +TEST(AutoCompactTest, ReadHalf) { + DoReads(kCount/2); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/db/builder.cc b/src/leveldb/db/builder.cc new file mode 100644 index 0000000..f419882 --- /dev/null +++ b/src/leveldb/db/builder.cc @@ -0,0 +1,88 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/builder.h" + +#include "db/filename.h" +#include "db/dbformat.h" +#include "db/table_cache.h" +#include "db/version_edit.h" +#include "leveldb/db.h" +#include "leveldb/env.h" +#include "leveldb/iterator.h" + +namespace leveldb { + +Status BuildTable(const std::string& dbname, + Env* env, + const Options& options, + TableCache* table_cache, + Iterator* iter, + FileMetaData* meta) { + Status s; + meta->file_size = 0; + iter->SeekToFirst(); + + std::string fname = TableFileName(dbname, meta->number); + if (iter->Valid()) { + WritableFile* file; + s = env->NewWritableFile(fname, &file); + if (!s.ok()) { + return s; + } + + TableBuilder* builder = new TableBuilder(options, file); + meta->smallest.DecodeFrom(iter->key()); + for (; iter->Valid(); iter->Next()) { + Slice key = iter->key(); + meta->largest.DecodeFrom(key); + builder->Add(key, iter->value()); + } + + // Finish and check for builder errors + if (s.ok()) { + s = builder->Finish(); + if (s.ok()) { + meta->file_size = builder->FileSize(); + assert(meta->file_size > 0); + } + } else { + builder->Abandon(); + } + delete builder; + + // Finish and check for file errors + if (s.ok()) { + s = file->Sync(); + } + if (s.ok()) { + s = file->Close(); + } + delete file; + file = NULL; + + if (s.ok()) { + // Verify that the table is usable + Iterator* it = table_cache->NewIterator(ReadOptions(), + meta->number, + meta->file_size); + s = it->status(); + delete it; + } + } + + // Check for input iterator errors + if (!iter->status().ok()) { + s = iter->status(); + } + + if (s.ok() && meta->file_size > 0) { + // Keep it + } else { + env->DeleteFile(fname); + } + return s; +} + +} // namespace leveldb diff --git a/src/leveldb/db/builder.h b/src/leveldb/db/builder.h new file mode 100644 index 0000000..62431fc --- /dev/null +++ b/src/leveldb/db/builder.h @@ -0,0 +1,34 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_DB_BUILDER_H_ +#define STORAGE_LEVELDB_DB_BUILDER_H_ + +#include "leveldb/status.h" + +namespace leveldb { + +struct Options; +struct FileMetaData; + +class Env; +class Iterator; +class TableCache; +class VersionEdit; + +// Build a Table file from the contents of *iter. The generated file +// will be named according to meta->number. On success, the rest of +// *meta will be filled with metadata about the generated table. +// If no data is present in *iter, meta->file_size will be set to +// zero, and no Table file will be produced. +extern Status BuildTable(const std::string& dbname, + Env* env, + const Options& options, + TableCache* table_cache, + Iterator* iter, + FileMetaData* meta); + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_BUILDER_H_ diff --git a/src/leveldb/db/c.cc b/src/leveldb/db/c.cc new file mode 100644 index 0000000..08ff0ad --- /dev/null +++ b/src/leveldb/db/c.cc @@ -0,0 +1,595 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/c.h" + +#include +#include +#include "leveldb/cache.h" +#include "leveldb/comparator.h" +#include "leveldb/db.h" +#include "leveldb/env.h" +#include "leveldb/filter_policy.h" +#include "leveldb/iterator.h" +#include "leveldb/options.h" +#include "leveldb/status.h" +#include "leveldb/write_batch.h" + +using leveldb::Cache; +using leveldb::Comparator; +using leveldb::CompressionType; +using leveldb::DB; +using leveldb::Env; +using leveldb::FileLock; +using leveldb::FilterPolicy; +using leveldb::Iterator; +using leveldb::kMajorVersion; +using leveldb::kMinorVersion; +using leveldb::Logger; +using leveldb::NewBloomFilterPolicy; +using leveldb::NewLRUCache; +using leveldb::Options; +using leveldb::RandomAccessFile; +using leveldb::Range; +using leveldb::ReadOptions; +using leveldb::SequentialFile; +using leveldb::Slice; +using leveldb::Snapshot; +using leveldb::Status; +using leveldb::WritableFile; +using leveldb::WriteBatch; +using leveldb::WriteOptions; + +extern "C" { + +struct leveldb_t { DB* rep; }; +struct leveldb_iterator_t { Iterator* rep; }; +struct leveldb_writebatch_t { WriteBatch rep; }; +struct leveldb_snapshot_t { const Snapshot* rep; }; +struct leveldb_readoptions_t { ReadOptions rep; }; +struct leveldb_writeoptions_t { WriteOptions rep; }; +struct leveldb_options_t { Options rep; }; +struct leveldb_cache_t { Cache* rep; }; +struct leveldb_seqfile_t { SequentialFile* rep; }; +struct leveldb_randomfile_t { RandomAccessFile* rep; }; +struct leveldb_writablefile_t { WritableFile* rep; }; +struct leveldb_logger_t { Logger* rep; }; +struct leveldb_filelock_t { FileLock* rep; }; + +struct leveldb_comparator_t : public Comparator { + void* state_; + void (*destructor_)(void*); + int (*compare_)( + void*, + const char* a, size_t alen, + const char* b, size_t blen); + const char* (*name_)(void*); + + virtual ~leveldb_comparator_t() { + (*destructor_)(state_); + } + + virtual int Compare(const Slice& a, const Slice& b) const { + return (*compare_)(state_, a.data(), a.size(), b.data(), b.size()); + } + + virtual const char* Name() const { + return (*name_)(state_); + } + + // No-ops since the C binding does not support key shortening methods. + virtual void FindShortestSeparator(std::string*, const Slice&) const { } + virtual void FindShortSuccessor(std::string* key) const { } +}; + +struct leveldb_filterpolicy_t : public FilterPolicy { + void* state_; + void (*destructor_)(void*); + const char* (*name_)(void*); + char* (*create_)( + void*, + const char* const* key_array, const size_t* key_length_array, + int num_keys, + size_t* filter_length); + unsigned char (*key_match_)( + void*, + const char* key, size_t length, + const char* filter, size_t filter_length); + + virtual ~leveldb_filterpolicy_t() { + (*destructor_)(state_); + } + + virtual const char* Name() const { + return (*name_)(state_); + } + + virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const { + std::vector key_pointers(n); + std::vector key_sizes(n); + for (int i = 0; i < n; i++) { + key_pointers[i] = keys[i].data(); + key_sizes[i] = keys[i].size(); + } + size_t len; + char* filter = (*create_)(state_, &key_pointers[0], &key_sizes[0], n, &len); + dst->append(filter, len); + free(filter); + } + + virtual bool KeyMayMatch(const Slice& key, const Slice& filter) const { + return (*key_match_)(state_, key.data(), key.size(), + filter.data(), filter.size()); + } +}; + +struct leveldb_env_t { + Env* rep; + bool is_default; +}; + +static bool SaveError(char** errptr, const Status& s) { + assert(errptr != NULL); + if (s.ok()) { + return false; + } else if (*errptr == NULL) { + *errptr = strdup(s.ToString().c_str()); + } else { + // TODO(sanjay): Merge with existing error? + free(*errptr); + *errptr = strdup(s.ToString().c_str()); + } + return true; +} + +static char* CopyString(const std::string& str) { + char* result = reinterpret_cast(malloc(sizeof(char) * str.size())); + memcpy(result, str.data(), sizeof(char) * str.size()); + return result; +} + +leveldb_t* leveldb_open( + const leveldb_options_t* options, + const char* name, + char** errptr) { + DB* db; + if (SaveError(errptr, DB::Open(options->rep, std::string(name), &db))) { + return NULL; + } + leveldb_t* result = new leveldb_t; + result->rep = db; + return result; +} + +void leveldb_close(leveldb_t* db) { + delete db->rep; + delete db; +} + +void leveldb_put( + leveldb_t* db, + const leveldb_writeoptions_t* options, + const char* key, size_t keylen, + const char* val, size_t vallen, + char** errptr) { + SaveError(errptr, + db->rep->Put(options->rep, Slice(key, keylen), Slice(val, vallen))); +} + +void leveldb_delete( + leveldb_t* db, + const leveldb_writeoptions_t* options, + const char* key, size_t keylen, + char** errptr) { + SaveError(errptr, db->rep->Delete(options->rep, Slice(key, keylen))); +} + + +void leveldb_write( + leveldb_t* db, + const leveldb_writeoptions_t* options, + leveldb_writebatch_t* batch, + char** errptr) { + SaveError(errptr, db->rep->Write(options->rep, &batch->rep)); +} + +char* leveldb_get( + leveldb_t* db, + const leveldb_readoptions_t* options, + const char* key, size_t keylen, + size_t* vallen, + char** errptr) { + char* result = NULL; + std::string tmp; + Status s = db->rep->Get(options->rep, Slice(key, keylen), &tmp); + if (s.ok()) { + *vallen = tmp.size(); + result = CopyString(tmp); + } else { + *vallen = 0; + if (!s.IsNotFound()) { + SaveError(errptr, s); + } + } + return result; +} + +leveldb_iterator_t* leveldb_create_iterator( + leveldb_t* db, + const leveldb_readoptions_t* options) { + leveldb_iterator_t* result = new leveldb_iterator_t; + result->rep = db->rep->NewIterator(options->rep); + return result; +} + +const leveldb_snapshot_t* leveldb_create_snapshot( + leveldb_t* db) { + leveldb_snapshot_t* result = new leveldb_snapshot_t; + result->rep = db->rep->GetSnapshot(); + return result; +} + +void leveldb_release_snapshot( + leveldb_t* db, + const leveldb_snapshot_t* snapshot) { + db->rep->ReleaseSnapshot(snapshot->rep); + delete snapshot; +} + +char* leveldb_property_value( + leveldb_t* db, + const char* propname) { + std::string tmp; + if (db->rep->GetProperty(Slice(propname), &tmp)) { + // We use strdup() since we expect human readable output. + return strdup(tmp.c_str()); + } else { + return NULL; + } +} + +void leveldb_approximate_sizes( + leveldb_t* db, + int num_ranges, + const char* const* range_start_key, const size_t* range_start_key_len, + const char* const* range_limit_key, const size_t* range_limit_key_len, + uint64_t* sizes) { + Range* ranges = new Range[num_ranges]; + for (int i = 0; i < num_ranges; i++) { + ranges[i].start = Slice(range_start_key[i], range_start_key_len[i]); + ranges[i].limit = Slice(range_limit_key[i], range_limit_key_len[i]); + } + db->rep->GetApproximateSizes(ranges, num_ranges, sizes); + delete[] ranges; +} + +void leveldb_compact_range( + leveldb_t* db, + const char* start_key, size_t start_key_len, + const char* limit_key, size_t limit_key_len) { + Slice a, b; + db->rep->CompactRange( + // Pass NULL Slice if corresponding "const char*" is NULL + (start_key ? (a = Slice(start_key, start_key_len), &a) : NULL), + (limit_key ? (b = Slice(limit_key, limit_key_len), &b) : NULL)); +} + +void leveldb_destroy_db( + const leveldb_options_t* options, + const char* name, + char** errptr) { + SaveError(errptr, DestroyDB(name, options->rep)); +} + +void leveldb_repair_db( + const leveldb_options_t* options, + const char* name, + char** errptr) { + SaveError(errptr, RepairDB(name, options->rep)); +} + +void leveldb_iter_destroy(leveldb_iterator_t* iter) { + delete iter->rep; + delete iter; +} + +unsigned char leveldb_iter_valid(const leveldb_iterator_t* iter) { + return iter->rep->Valid(); +} + +void leveldb_iter_seek_to_first(leveldb_iterator_t* iter) { + iter->rep->SeekToFirst(); +} + +void leveldb_iter_seek_to_last(leveldb_iterator_t* iter) { + iter->rep->SeekToLast(); +} + +void leveldb_iter_seek(leveldb_iterator_t* iter, const char* k, size_t klen) { + iter->rep->Seek(Slice(k, klen)); +} + +void leveldb_iter_next(leveldb_iterator_t* iter) { + iter->rep->Next(); +} + +void leveldb_iter_prev(leveldb_iterator_t* iter) { + iter->rep->Prev(); +} + +const char* leveldb_iter_key(const leveldb_iterator_t* iter, size_t* klen) { + Slice s = iter->rep->key(); + *klen = s.size(); + return s.data(); +} + +const char* leveldb_iter_value(const leveldb_iterator_t* iter, size_t* vlen) { + Slice s = iter->rep->value(); + *vlen = s.size(); + return s.data(); +} + +void leveldb_iter_get_error(const leveldb_iterator_t* iter, char** errptr) { + SaveError(errptr, iter->rep->status()); +} + +leveldb_writebatch_t* leveldb_writebatch_create() { + return new leveldb_writebatch_t; +} + +void leveldb_writebatch_destroy(leveldb_writebatch_t* b) { + delete b; +} + +void leveldb_writebatch_clear(leveldb_writebatch_t* b) { + b->rep.Clear(); +} + +void leveldb_writebatch_put( + leveldb_writebatch_t* b, + const char* key, size_t klen, + const char* val, size_t vlen) { + b->rep.Put(Slice(key, klen), Slice(val, vlen)); +} + +void leveldb_writebatch_delete( + leveldb_writebatch_t* b, + const char* key, size_t klen) { + b->rep.Delete(Slice(key, klen)); +} + +void leveldb_writebatch_iterate( + leveldb_writebatch_t* b, + void* state, + void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen), + void (*deleted)(void*, const char* k, size_t klen)) { + class H : public WriteBatch::Handler { + public: + void* state_; + void (*put_)(void*, const char* k, size_t klen, const char* v, size_t vlen); + void (*deleted_)(void*, const char* k, size_t klen); + virtual void Put(const Slice& key, const Slice& value) { + (*put_)(state_, key.data(), key.size(), value.data(), value.size()); + } + virtual void Delete(const Slice& key) { + (*deleted_)(state_, key.data(), key.size()); + } + }; + H handler; + handler.state_ = state; + handler.put_ = put; + handler.deleted_ = deleted; + b->rep.Iterate(&handler); +} + +leveldb_options_t* leveldb_options_create() { + return new leveldb_options_t; +} + +void leveldb_options_destroy(leveldb_options_t* options) { + delete options; +} + +void leveldb_options_set_comparator( + leveldb_options_t* opt, + leveldb_comparator_t* cmp) { + opt->rep.comparator = cmp; +} + +void leveldb_options_set_filter_policy( + leveldb_options_t* opt, + leveldb_filterpolicy_t* policy) { + opt->rep.filter_policy = policy; +} + +void leveldb_options_set_create_if_missing( + leveldb_options_t* opt, unsigned char v) { + opt->rep.create_if_missing = v; +} + +void leveldb_options_set_error_if_exists( + leveldb_options_t* opt, unsigned char v) { + opt->rep.error_if_exists = v; +} + +void leveldb_options_set_paranoid_checks( + leveldb_options_t* opt, unsigned char v) { + opt->rep.paranoid_checks = v; +} + +void leveldb_options_set_env(leveldb_options_t* opt, leveldb_env_t* env) { + opt->rep.env = (env ? env->rep : NULL); +} + +void leveldb_options_set_info_log(leveldb_options_t* opt, leveldb_logger_t* l) { + opt->rep.info_log = (l ? l->rep : NULL); +} + +void leveldb_options_set_write_buffer_size(leveldb_options_t* opt, size_t s) { + opt->rep.write_buffer_size = s; +} + +void leveldb_options_set_max_open_files(leveldb_options_t* opt, int n) { + opt->rep.max_open_files = n; +} + +void leveldb_options_set_cache(leveldb_options_t* opt, leveldb_cache_t* c) { + opt->rep.block_cache = c->rep; +} + +void leveldb_options_set_block_size(leveldb_options_t* opt, size_t s) { + opt->rep.block_size = s; +} + +void leveldb_options_set_block_restart_interval(leveldb_options_t* opt, int n) { + opt->rep.block_restart_interval = n; +} + +void leveldb_options_set_compression(leveldb_options_t* opt, int t) { + opt->rep.compression = static_cast(t); +} + +leveldb_comparator_t* leveldb_comparator_create( + void* state, + void (*destructor)(void*), + int (*compare)( + void*, + const char* a, size_t alen, + const char* b, size_t blen), + const char* (*name)(void*)) { + leveldb_comparator_t* result = new leveldb_comparator_t; + result->state_ = state; + result->destructor_ = destructor; + result->compare_ = compare; + result->name_ = name; + return result; +} + +void leveldb_comparator_destroy(leveldb_comparator_t* cmp) { + delete cmp; +} + +leveldb_filterpolicy_t* leveldb_filterpolicy_create( + void* state, + void (*destructor)(void*), + char* (*create_filter)( + void*, + const char* const* key_array, const size_t* key_length_array, + int num_keys, + size_t* filter_length), + unsigned char (*key_may_match)( + void*, + const char* key, size_t length, + const char* filter, size_t filter_length), + const char* (*name)(void*)) { + leveldb_filterpolicy_t* result = new leveldb_filterpolicy_t; + result->state_ = state; + result->destructor_ = destructor; + result->create_ = create_filter; + result->key_match_ = key_may_match; + result->name_ = name; + return result; +} + +void leveldb_filterpolicy_destroy(leveldb_filterpolicy_t* filter) { + delete filter; +} + +leveldb_filterpolicy_t* leveldb_filterpolicy_create_bloom(int bits_per_key) { + // Make a leveldb_filterpolicy_t, but override all of its methods so + // they delegate to a NewBloomFilterPolicy() instead of user + // supplied C functions. + struct Wrapper : public leveldb_filterpolicy_t { + const FilterPolicy* rep_; + ~Wrapper() { delete rep_; } + const char* Name() const { return rep_->Name(); } + void CreateFilter(const Slice* keys, int n, std::string* dst) const { + return rep_->CreateFilter(keys, n, dst); + } + bool KeyMayMatch(const Slice& key, const Slice& filter) const { + return rep_->KeyMayMatch(key, filter); + } + static void DoNothing(void*) { } + }; + Wrapper* wrapper = new Wrapper; + wrapper->rep_ = NewBloomFilterPolicy(bits_per_key); + wrapper->state_ = NULL; + wrapper->destructor_ = &Wrapper::DoNothing; + return wrapper; +} + +leveldb_readoptions_t* leveldb_readoptions_create() { + return new leveldb_readoptions_t; +} + +void leveldb_readoptions_destroy(leveldb_readoptions_t* opt) { + delete opt; +} + +void leveldb_readoptions_set_verify_checksums( + leveldb_readoptions_t* opt, + unsigned char v) { + opt->rep.verify_checksums = v; +} + +void leveldb_readoptions_set_fill_cache( + leveldb_readoptions_t* opt, unsigned char v) { + opt->rep.fill_cache = v; +} + +void leveldb_readoptions_set_snapshot( + leveldb_readoptions_t* opt, + const leveldb_snapshot_t* snap) { + opt->rep.snapshot = (snap ? snap->rep : NULL); +} + +leveldb_writeoptions_t* leveldb_writeoptions_create() { + return new leveldb_writeoptions_t; +} + +void leveldb_writeoptions_destroy(leveldb_writeoptions_t* opt) { + delete opt; +} + +void leveldb_writeoptions_set_sync( + leveldb_writeoptions_t* opt, unsigned char v) { + opt->rep.sync = v; +} + +leveldb_cache_t* leveldb_cache_create_lru(size_t capacity) { + leveldb_cache_t* c = new leveldb_cache_t; + c->rep = NewLRUCache(capacity); + return c; +} + +void leveldb_cache_destroy(leveldb_cache_t* cache) { + delete cache->rep; + delete cache; +} + +leveldb_env_t* leveldb_create_default_env() { + leveldb_env_t* result = new leveldb_env_t; + result->rep = Env::Default(); + result->is_default = true; + return result; +} + +void leveldb_env_destroy(leveldb_env_t* env) { + if (!env->is_default) delete env->rep; + delete env; +} + +void leveldb_free(void* ptr) { + free(ptr); +} + +int leveldb_major_version() { + return kMajorVersion; +} + +int leveldb_minor_version() { + return kMinorVersion; +} + +} // end extern "C" diff --git a/src/leveldb/db/c_test.c b/src/leveldb/db/c_test.c new file mode 100644 index 0000000..7cd5ee0 --- /dev/null +++ b/src/leveldb/db/c_test.c @@ -0,0 +1,390 @@ +/* Copyright (c) 2011 The LevelDB Authors. All rights reserved. + Use of this source code is governed by a BSD-style license that can be + found in the LICENSE file. See the AUTHORS file for names of contributors. */ + +#include "leveldb/c.h" + +#include +#include +#include +#include +#include +#include + +const char* phase = ""; +static char dbname[200]; + +static void StartPhase(const char* name) { + fprintf(stderr, "=== Test %s\n", name); + phase = name; +} + +static const char* GetTempDir(void) { + const char* ret = getenv("TEST_TMPDIR"); + if (ret == NULL || ret[0] == '\0') + ret = "/tmp"; + return ret; +} + +#define CheckNoError(err) \ + if ((err) != NULL) { \ + fprintf(stderr, "%s:%d: %s: %s\n", __FILE__, __LINE__, phase, (err)); \ + abort(); \ + } + +#define CheckCondition(cond) \ + if (!(cond)) { \ + fprintf(stderr, "%s:%d: %s: %s\n", __FILE__, __LINE__, phase, #cond); \ + abort(); \ + } + +static void CheckEqual(const char* expected, const char* v, size_t n) { + if (expected == NULL && v == NULL) { + // ok + } else if (expected != NULL && v != NULL && n == strlen(expected) && + memcmp(expected, v, n) == 0) { + // ok + return; + } else { + fprintf(stderr, "%s: expected '%s', got '%s'\n", + phase, + (expected ? expected : "(null)"), + (v ? v : "(null")); + abort(); + } +} + +static void Free(char** ptr) { + if (*ptr) { + free(*ptr); + *ptr = NULL; + } +} + +static void CheckGet( + leveldb_t* db, + const leveldb_readoptions_t* options, + const char* key, + const char* expected) { + char* err = NULL; + size_t val_len; + char* val; + val = leveldb_get(db, options, key, strlen(key), &val_len, &err); + CheckNoError(err); + CheckEqual(expected, val, val_len); + Free(&val); +} + +static void CheckIter(leveldb_iterator_t* iter, + const char* key, const char* val) { + size_t len; + const char* str; + str = leveldb_iter_key(iter, &len); + CheckEqual(key, str, len); + str = leveldb_iter_value(iter, &len); + CheckEqual(val, str, len); +} + +// Callback from leveldb_writebatch_iterate() +static void CheckPut(void* ptr, + const char* k, size_t klen, + const char* v, size_t vlen) { + int* state = (int*) ptr; + CheckCondition(*state < 2); + switch (*state) { + case 0: + CheckEqual("bar", k, klen); + CheckEqual("b", v, vlen); + break; + case 1: + CheckEqual("box", k, klen); + CheckEqual("c", v, vlen); + break; + } + (*state)++; +} + +// Callback from leveldb_writebatch_iterate() +static void CheckDel(void* ptr, const char* k, size_t klen) { + int* state = (int*) ptr; + CheckCondition(*state == 2); + CheckEqual("bar", k, klen); + (*state)++; +} + +static void CmpDestroy(void* arg) { } + +static int CmpCompare(void* arg, const char* a, size_t alen, + const char* b, size_t blen) { + int n = (alen < blen) ? alen : blen; + int r = memcmp(a, b, n); + if (r == 0) { + if (alen < blen) r = -1; + else if (alen > blen) r = +1; + } + return r; +} + +static const char* CmpName(void* arg) { + return "foo"; +} + +// Custom filter policy +static unsigned char fake_filter_result = 1; +static void FilterDestroy(void* arg) { } +static const char* FilterName(void* arg) { + return "TestFilter"; +} +static char* FilterCreate( + void* arg, + const char* const* key_array, const size_t* key_length_array, + int num_keys, + size_t* filter_length) { + *filter_length = 4; + char* result = malloc(4); + memcpy(result, "fake", 4); + return result; +} +unsigned char FilterKeyMatch( + void* arg, + const char* key, size_t length, + const char* filter, size_t filter_length) { + CheckCondition(filter_length == 4); + CheckCondition(memcmp(filter, "fake", 4) == 0); + return fake_filter_result; +} + +int main(int argc, char** argv) { + leveldb_t* db; + leveldb_comparator_t* cmp; + leveldb_cache_t* cache; + leveldb_env_t* env; + leveldb_options_t* options; + leveldb_readoptions_t* roptions; + leveldb_writeoptions_t* woptions; + char* err = NULL; + int run = -1; + + CheckCondition(leveldb_major_version() >= 1); + CheckCondition(leveldb_minor_version() >= 1); + + snprintf(dbname, sizeof(dbname), + "%s/leveldb_c_test-%d", + GetTempDir(), + ((int) geteuid())); + + StartPhase("create_objects"); + cmp = leveldb_comparator_create(NULL, CmpDestroy, CmpCompare, CmpName); + env = leveldb_create_default_env(); + cache = leveldb_cache_create_lru(100000); + + options = leveldb_options_create(); + leveldb_options_set_comparator(options, cmp); + leveldb_options_set_error_if_exists(options, 1); + leveldb_options_set_cache(options, cache); + leveldb_options_set_env(options, env); + leveldb_options_set_info_log(options, NULL); + leveldb_options_set_write_buffer_size(options, 100000); + leveldb_options_set_paranoid_checks(options, 1); + leveldb_options_set_max_open_files(options, 10); + leveldb_options_set_block_size(options, 1024); + leveldb_options_set_block_restart_interval(options, 8); + leveldb_options_set_compression(options, leveldb_no_compression); + + roptions = leveldb_readoptions_create(); + leveldb_readoptions_set_verify_checksums(roptions, 1); + leveldb_readoptions_set_fill_cache(roptions, 0); + + woptions = leveldb_writeoptions_create(); + leveldb_writeoptions_set_sync(woptions, 1); + + StartPhase("destroy"); + leveldb_destroy_db(options, dbname, &err); + Free(&err); + + StartPhase("open_error"); + db = leveldb_open(options, dbname, &err); + CheckCondition(err != NULL); + Free(&err); + + StartPhase("leveldb_free"); + db = leveldb_open(options, dbname, &err); + CheckCondition(err != NULL); + leveldb_free(err); + err = NULL; + + StartPhase("open"); + leveldb_options_set_create_if_missing(options, 1); + db = leveldb_open(options, dbname, &err); + CheckNoError(err); + CheckGet(db, roptions, "foo", NULL); + + StartPhase("put"); + leveldb_put(db, woptions, "foo", 3, "hello", 5, &err); + CheckNoError(err); + CheckGet(db, roptions, "foo", "hello"); + + StartPhase("compactall"); + leveldb_compact_range(db, NULL, 0, NULL, 0); + CheckGet(db, roptions, "foo", "hello"); + + StartPhase("compactrange"); + leveldb_compact_range(db, "a", 1, "z", 1); + CheckGet(db, roptions, "foo", "hello"); + + StartPhase("writebatch"); + { + leveldb_writebatch_t* wb = leveldb_writebatch_create(); + leveldb_writebatch_put(wb, "foo", 3, "a", 1); + leveldb_writebatch_clear(wb); + leveldb_writebatch_put(wb, "bar", 3, "b", 1); + leveldb_writebatch_put(wb, "box", 3, "c", 1); + leveldb_writebatch_delete(wb, "bar", 3); + leveldb_write(db, woptions, wb, &err); + CheckNoError(err); + CheckGet(db, roptions, "foo", "hello"); + CheckGet(db, roptions, "bar", NULL); + CheckGet(db, roptions, "box", "c"); + int pos = 0; + leveldb_writebatch_iterate(wb, &pos, CheckPut, CheckDel); + CheckCondition(pos == 3); + leveldb_writebatch_destroy(wb); + } + + StartPhase("iter"); + { + leveldb_iterator_t* iter = leveldb_create_iterator(db, roptions); + CheckCondition(!leveldb_iter_valid(iter)); + leveldb_iter_seek_to_first(iter); + CheckCondition(leveldb_iter_valid(iter)); + CheckIter(iter, "box", "c"); + leveldb_iter_next(iter); + CheckIter(iter, "foo", "hello"); + leveldb_iter_prev(iter); + CheckIter(iter, "box", "c"); + leveldb_iter_prev(iter); + CheckCondition(!leveldb_iter_valid(iter)); + leveldb_iter_seek_to_last(iter); + CheckIter(iter, "foo", "hello"); + leveldb_iter_seek(iter, "b", 1); + CheckIter(iter, "box", "c"); + leveldb_iter_get_error(iter, &err); + CheckNoError(err); + leveldb_iter_destroy(iter); + } + + StartPhase("approximate_sizes"); + { + int i; + int n = 20000; + char keybuf[100]; + char valbuf[100]; + uint64_t sizes[2]; + const char* start[2] = { "a", "k00000000000000010000" }; + size_t start_len[2] = { 1, 21 }; + const char* limit[2] = { "k00000000000000010000", "z" }; + size_t limit_len[2] = { 21, 1 }; + leveldb_writeoptions_set_sync(woptions, 0); + for (i = 0; i < n; i++) { + snprintf(keybuf, sizeof(keybuf), "k%020d", i); + snprintf(valbuf, sizeof(valbuf), "v%020d", i); + leveldb_put(db, woptions, keybuf, strlen(keybuf), valbuf, strlen(valbuf), + &err); + CheckNoError(err); + } + leveldb_approximate_sizes(db, 2, start, start_len, limit, limit_len, sizes); + CheckCondition(sizes[0] > 0); + CheckCondition(sizes[1] > 0); + } + + StartPhase("property"); + { + char* prop = leveldb_property_value(db, "nosuchprop"); + CheckCondition(prop == NULL); + prop = leveldb_property_value(db, "leveldb.stats"); + CheckCondition(prop != NULL); + Free(&prop); + } + + StartPhase("snapshot"); + { + const leveldb_snapshot_t* snap; + snap = leveldb_create_snapshot(db); + leveldb_delete(db, woptions, "foo", 3, &err); + CheckNoError(err); + leveldb_readoptions_set_snapshot(roptions, snap); + CheckGet(db, roptions, "foo", "hello"); + leveldb_readoptions_set_snapshot(roptions, NULL); + CheckGet(db, roptions, "foo", NULL); + leveldb_release_snapshot(db, snap); + } + + StartPhase("repair"); + { + leveldb_close(db); + leveldb_options_set_create_if_missing(options, 0); + leveldb_options_set_error_if_exists(options, 0); + leveldb_repair_db(options, dbname, &err); + CheckNoError(err); + db = leveldb_open(options, dbname, &err); + CheckNoError(err); + CheckGet(db, roptions, "foo", NULL); + CheckGet(db, roptions, "bar", NULL); + CheckGet(db, roptions, "box", "c"); + leveldb_options_set_create_if_missing(options, 1); + leveldb_options_set_error_if_exists(options, 1); + } + + StartPhase("filter"); + for (run = 0; run < 2; run++) { + // First run uses custom filter, second run uses bloom filter + CheckNoError(err); + leveldb_filterpolicy_t* policy; + if (run == 0) { + policy = leveldb_filterpolicy_create( + NULL, FilterDestroy, FilterCreate, FilterKeyMatch, FilterName); + } else { + policy = leveldb_filterpolicy_create_bloom(10); + } + + // Create new database + leveldb_close(db); + leveldb_destroy_db(options, dbname, &err); + leveldb_options_set_filter_policy(options, policy); + db = leveldb_open(options, dbname, &err); + CheckNoError(err); + leveldb_put(db, woptions, "foo", 3, "foovalue", 8, &err); + CheckNoError(err); + leveldb_put(db, woptions, "bar", 3, "barvalue", 8, &err); + CheckNoError(err); + leveldb_compact_range(db, NULL, 0, NULL, 0); + + fake_filter_result = 1; + CheckGet(db, roptions, "foo", "foovalue"); + CheckGet(db, roptions, "bar", "barvalue"); + if (phase == 0) { + // Must not find value when custom filter returns false + fake_filter_result = 0; + CheckGet(db, roptions, "foo", NULL); + CheckGet(db, roptions, "bar", NULL); + fake_filter_result = 1; + + CheckGet(db, roptions, "foo", "foovalue"); + CheckGet(db, roptions, "bar", "barvalue"); + } + leveldb_options_set_filter_policy(options, NULL); + leveldb_filterpolicy_destroy(policy); + } + + StartPhase("cleanup"); + leveldb_close(db); + leveldb_options_destroy(options); + leveldb_readoptions_destroy(roptions); + leveldb_writeoptions_destroy(woptions); + leveldb_cache_destroy(cache); + leveldb_comparator_destroy(cmp); + leveldb_env_destroy(env); + + fprintf(stderr, "PASS\n"); + return 0; +} diff --git a/src/leveldb/db/corruption_test.cc b/src/leveldb/db/corruption_test.cc new file mode 100644 index 0000000..96afc68 --- /dev/null +++ b/src/leveldb/db/corruption_test.cc @@ -0,0 +1,374 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/db.h" + +#include +#include +#include +#include +#include "leveldb/cache.h" +#include "leveldb/env.h" +#include "leveldb/table.h" +#include "leveldb/write_batch.h" +#include "db/db_impl.h" +#include "db/filename.h" +#include "db/log_format.h" +#include "db/version_set.h" +#include "util/logging.h" +#include "util/testharness.h" +#include "util/testutil.h" + +namespace leveldb { + +static const int kValueSize = 1000; + +class CorruptionTest { + public: + test::ErrorEnv env_; + std::string dbname_; + Cache* tiny_cache_; + Options options_; + DB* db_; + + CorruptionTest() { + tiny_cache_ = NewLRUCache(100); + options_.env = &env_; + options_.block_cache = tiny_cache_; + dbname_ = test::TmpDir() + "/db_test"; + DestroyDB(dbname_, options_); + + db_ = NULL; + options_.create_if_missing = true; + Reopen(); + options_.create_if_missing = false; + } + + ~CorruptionTest() { + delete db_; + DestroyDB(dbname_, Options()); + delete tiny_cache_; + } + + Status TryReopen() { + delete db_; + db_ = NULL; + return DB::Open(options_, dbname_, &db_); + } + + void Reopen() { + ASSERT_OK(TryReopen()); + } + + void RepairDB() { + delete db_; + db_ = NULL; + ASSERT_OK(::leveldb::RepairDB(dbname_, options_)); + } + + void Build(int n) { + std::string key_space, value_space; + WriteBatch batch; + for (int i = 0; i < n; i++) { + //if ((i % 100) == 0) fprintf(stderr, "@ %d of %d\n", i, n); + Slice key = Key(i, &key_space); + batch.Clear(); + batch.Put(key, Value(i, &value_space)); + WriteOptions options; + // Corrupt() doesn't work without this sync on windows; stat reports 0 for + // the file size. + if (i == n - 1) { + options.sync = true; + } + ASSERT_OK(db_->Write(options, &batch)); + } + } + + void Check(int min_expected, int max_expected) { + int next_expected = 0; + int missed = 0; + int bad_keys = 0; + int bad_values = 0; + int correct = 0; + std::string value_space; + Iterator* iter = db_->NewIterator(ReadOptions()); + for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { + uint64_t key; + Slice in(iter->key()); + if (in == "" || in == "~") { + // Ignore boundary keys. + continue; + } + if (!ConsumeDecimalNumber(&in, &key) || + !in.empty() || + key < next_expected) { + bad_keys++; + continue; + } + missed += (key - next_expected); + next_expected = key + 1; + if (iter->value() != Value(key, &value_space)) { + bad_values++; + } else { + correct++; + } + } + delete iter; + + fprintf(stderr, + "expected=%d..%d; got=%d; bad_keys=%d; bad_values=%d; missed=%d\n", + min_expected, max_expected, correct, bad_keys, bad_values, missed); + ASSERT_LE(min_expected, correct); + ASSERT_GE(max_expected, correct); + } + + void Corrupt(FileType filetype, int offset, int bytes_to_corrupt) { + // Pick file to corrupt + std::vector filenames; + ASSERT_OK(env_.GetChildren(dbname_, &filenames)); + uint64_t number; + FileType type; + std::string fname; + int picked_number = -1; + for (size_t i = 0; i < filenames.size(); i++) { + if (ParseFileName(filenames[i], &number, &type) && + type == filetype && + int(number) > picked_number) { // Pick latest file + fname = dbname_ + "/" + filenames[i]; + picked_number = number; + } + } + ASSERT_TRUE(!fname.empty()) << filetype; + + struct stat sbuf; + if (stat(fname.c_str(), &sbuf) != 0) { + const char* msg = strerror(errno); + ASSERT_TRUE(false) << fname << ": " << msg; + } + + if (offset < 0) { + // Relative to end of file; make it absolute + if (-offset > sbuf.st_size) { + offset = 0; + } else { + offset = sbuf.st_size + offset; + } + } + if (offset > sbuf.st_size) { + offset = sbuf.st_size; + } + if (offset + bytes_to_corrupt > sbuf.st_size) { + bytes_to_corrupt = sbuf.st_size - offset; + } + + // Do it + std::string contents; + Status s = ReadFileToString(Env::Default(), fname, &contents); + ASSERT_TRUE(s.ok()) << s.ToString(); + for (int i = 0; i < bytes_to_corrupt; i++) { + contents[i + offset] ^= 0x80; + } + s = WriteStringToFile(Env::Default(), contents, fname); + ASSERT_TRUE(s.ok()) << s.ToString(); + } + + int Property(const std::string& name) { + std::string property; + int result; + if (db_->GetProperty(name, &property) && + sscanf(property.c_str(), "%d", &result) == 1) { + return result; + } else { + return -1; + } + } + + // Return the ith key + Slice Key(int i, std::string* storage) { + char buf[100]; + snprintf(buf, sizeof(buf), "%016d", i); + storage->assign(buf, strlen(buf)); + return Slice(*storage); + } + + // Return the value to associate with the specified key + Slice Value(int k, std::string* storage) { + Random r(k); + return test::RandomString(&r, kValueSize, storage); + } +}; + +TEST(CorruptionTest, Recovery) { + Build(100); + Check(100, 100); + Corrupt(kLogFile, 19, 1); // WriteBatch tag for first record + Corrupt(kLogFile, log::kBlockSize + 1000, 1); // Somewhere in second block + Reopen(); + + // The 64 records in the first two log blocks are completely lost. + Check(36, 36); +} + +TEST(CorruptionTest, RecoverWriteError) { + env_.writable_file_error_ = true; + Status s = TryReopen(); + ASSERT_TRUE(!s.ok()); +} + +TEST(CorruptionTest, NewFileErrorDuringWrite) { + // Do enough writing to force minor compaction + env_.writable_file_error_ = true; + const int num = 3 + (Options().write_buffer_size / kValueSize); + std::string value_storage; + Status s; + for (int i = 0; s.ok() && i < num; i++) { + WriteBatch batch; + batch.Put("a", Value(100, &value_storage)); + s = db_->Write(WriteOptions(), &batch); + } + ASSERT_TRUE(!s.ok()); + ASSERT_GE(env_.num_writable_file_errors_, 1); + env_.writable_file_error_ = false; + Reopen(); +} + +TEST(CorruptionTest, TableFile) { + Build(100); + DBImpl* dbi = reinterpret_cast(db_); + dbi->TEST_CompactMemTable(); + dbi->TEST_CompactRange(0, NULL, NULL); + dbi->TEST_CompactRange(1, NULL, NULL); + + Corrupt(kTableFile, 100, 1); + Check(90, 99); +} + +TEST(CorruptionTest, TableFileRepair) { + options_.block_size = 2 * kValueSize; // Limit scope of corruption + options_.paranoid_checks = true; + Reopen(); + Build(100); + DBImpl* dbi = reinterpret_cast(db_); + dbi->TEST_CompactMemTable(); + dbi->TEST_CompactRange(0, NULL, NULL); + dbi->TEST_CompactRange(1, NULL, NULL); + + Corrupt(kTableFile, 100, 1); + RepairDB(); + Reopen(); + Check(95, 99); +} + +TEST(CorruptionTest, TableFileIndexData) { + Build(10000); // Enough to build multiple Tables + DBImpl* dbi = reinterpret_cast(db_); + dbi->TEST_CompactMemTable(); + + Corrupt(kTableFile, -2000, 500); + Reopen(); + Check(5000, 9999); +} + +TEST(CorruptionTest, MissingDescriptor) { + Build(1000); + RepairDB(); + Reopen(); + Check(1000, 1000); +} + +TEST(CorruptionTest, SequenceNumberRecovery) { + ASSERT_OK(db_->Put(WriteOptions(), "foo", "v1")); + ASSERT_OK(db_->Put(WriteOptions(), "foo", "v2")); + ASSERT_OK(db_->Put(WriteOptions(), "foo", "v3")); + ASSERT_OK(db_->Put(WriteOptions(), "foo", "v4")); + ASSERT_OK(db_->Put(WriteOptions(), "foo", "v5")); + RepairDB(); + Reopen(); + std::string v; + ASSERT_OK(db_->Get(ReadOptions(), "foo", &v)); + ASSERT_EQ("v5", v); + // Write something. If sequence number was not recovered properly, + // it will be hidden by an earlier write. + ASSERT_OK(db_->Put(WriteOptions(), "foo", "v6")); + ASSERT_OK(db_->Get(ReadOptions(), "foo", &v)); + ASSERT_EQ("v6", v); + Reopen(); + ASSERT_OK(db_->Get(ReadOptions(), "foo", &v)); + ASSERT_EQ("v6", v); +} + +TEST(CorruptionTest, CorruptedDescriptor) { + ASSERT_OK(db_->Put(WriteOptions(), "foo", "hello")); + DBImpl* dbi = reinterpret_cast(db_); + dbi->TEST_CompactMemTable(); + dbi->TEST_CompactRange(0, NULL, NULL); + + Corrupt(kDescriptorFile, 0, 1000); + Status s = TryReopen(); + ASSERT_TRUE(!s.ok()); + + RepairDB(); + Reopen(); + std::string v; + ASSERT_OK(db_->Get(ReadOptions(), "foo", &v)); + ASSERT_EQ("hello", v); +} + +TEST(CorruptionTest, CompactionInputError) { + Build(10); + DBImpl* dbi = reinterpret_cast(db_); + dbi->TEST_CompactMemTable(); + const int last = config::kMaxMemCompactLevel; + ASSERT_EQ(1, Property("leveldb.num-files-at-level" + NumberToString(last))); + + Corrupt(kTableFile, 100, 1); + Check(5, 9); + + // Force compactions by writing lots of values + Build(10000); + Check(10000, 10000); +} + +TEST(CorruptionTest, CompactionInputErrorParanoid) { + options_.paranoid_checks = true; + options_.write_buffer_size = 512 << 10; + Reopen(); + DBImpl* dbi = reinterpret_cast(db_); + + // Make multiple inputs so we need to compact. + for (int i = 0; i < 2; i++) { + Build(10); + dbi->TEST_CompactMemTable(); + Corrupt(kTableFile, 100, 1); + env_.SleepForMicroseconds(100000); + } + dbi->CompactRange(NULL, NULL); + + // Write must fail because of corrupted table + std::string tmp1, tmp2; + Status s = db_->Put(WriteOptions(), Key(5, &tmp1), Value(5, &tmp2)); + ASSERT_TRUE(!s.ok()) << "write did not fail in corrupted paranoid db"; +} + +TEST(CorruptionTest, UnrelatedKeys) { + Build(10); + DBImpl* dbi = reinterpret_cast(db_); + dbi->TEST_CompactMemTable(); + Corrupt(kTableFile, 100, 1); + + std::string tmp1, tmp2; + ASSERT_OK(db_->Put(WriteOptions(), Key(1000, &tmp1), Value(1000, &tmp2))); + std::string v; + ASSERT_OK(db_->Get(ReadOptions(), Key(1000, &tmp1), &v)); + ASSERT_EQ(Value(1000, &tmp2).ToString(), v); + dbi->TEST_CompactMemTable(); + ASSERT_OK(db_->Get(ReadOptions(), Key(1000, &tmp1), &v)); + ASSERT_EQ(Value(1000, &tmp2).ToString(), v); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/db/db_bench.cc b/src/leveldb/db/db_bench.cc new file mode 100644 index 0000000..fc46d89 --- /dev/null +++ b/src/leveldb/db/db_bench.cc @@ -0,0 +1,979 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include +#include +#include +#include "db/db_impl.h" +#include "db/version_set.h" +#include "leveldb/cache.h" +#include "leveldb/db.h" +#include "leveldb/env.h" +#include "leveldb/write_batch.h" +#include "port/port.h" +#include "util/crc32c.h" +#include "util/histogram.h" +#include "util/mutexlock.h" +#include "util/random.h" +#include "util/testutil.h" + +// Comma-separated list of operations to run in the specified order +// Actual benchmarks: +// fillseq -- write N values in sequential key order in async mode +// fillrandom -- write N values in random key order in async mode +// overwrite -- overwrite N values in random key order in async mode +// fillsync -- write N/100 values in random key order in sync mode +// fill100K -- write N/1000 100K values in random order in async mode +// deleteseq -- delete N keys in sequential order +// deleterandom -- delete N keys in random order +// readseq -- read N times sequentially +// readreverse -- read N times in reverse order +// readrandom -- read N times in random order +// readmissing -- read N missing keys in random order +// readhot -- read N times in random order from 1% section of DB +// seekrandom -- N random seeks +// crc32c -- repeated crc32c of 4K of data +// acquireload -- load N*1000 times +// Meta operations: +// compact -- Compact the entire DB +// stats -- Print DB stats +// sstables -- Print sstable info +// heapprofile -- Dump a heap profile (if supported by this port) +static const char* FLAGS_benchmarks = + "fillseq," + "fillsync," + "fillrandom," + "overwrite," + "readrandom," + "readrandom," // Extra run to allow previous compactions to quiesce + "readseq," + "readreverse," + "compact," + "readrandom," + "readseq," + "readreverse," + "fill100K," + "crc32c," + "snappycomp," + "snappyuncomp," + "acquireload," + ; + +// Number of key/values to place in database +static int FLAGS_num = 1000000; + +// Number of read operations to do. If negative, do FLAGS_num reads. +static int FLAGS_reads = -1; + +// Number of concurrent threads to run. +static int FLAGS_threads = 1; + +// Size of each value +static int FLAGS_value_size = 100; + +// Arrange to generate values that shrink to this fraction of +// their original size after compression +static double FLAGS_compression_ratio = 0.5; + +// Print histogram of operation timings +static bool FLAGS_histogram = false; + +// Number of bytes to buffer in memtable before compacting +// (initialized to default value by "main") +static int FLAGS_write_buffer_size = 0; + +// Number of bytes to use as a cache of uncompressed data. +// Negative means use default settings. +static int FLAGS_cache_size = -1; + +// Maximum number of files to keep open at the same time (use default if == 0) +static int FLAGS_open_files = 0; + +// Bloom filter bits per key. +// Negative means use default settings. +static int FLAGS_bloom_bits = -1; + +// If true, do not destroy the existing database. If you set this +// flag and also specify a benchmark that wants a fresh database, that +// benchmark will fail. +static bool FLAGS_use_existing_db = false; + +// Use the db with the following name. +static const char* FLAGS_db = NULL; + +namespace leveldb { + +namespace { + +// Helper for quickly generating random data. +class RandomGenerator { + private: + std::string data_; + int pos_; + + public: + RandomGenerator() { + // We use a limited amount of data over and over again and ensure + // that it is larger than the compression window (32KB), and also + // large enough to serve all typical value sizes we want to write. + Random rnd(301); + std::string piece; + while (data_.size() < 1048576) { + // Add a short fragment that is as compressible as specified + // by FLAGS_compression_ratio. + test::CompressibleString(&rnd, FLAGS_compression_ratio, 100, &piece); + data_.append(piece); + } + pos_ = 0; + } + + Slice Generate(size_t len) { + if (pos_ + len > data_.size()) { + pos_ = 0; + assert(len < data_.size()); + } + pos_ += len; + return Slice(data_.data() + pos_ - len, len); + } +}; + +static Slice TrimSpace(Slice s) { + size_t start = 0; + while (start < s.size() && isspace(s[start])) { + start++; + } + size_t limit = s.size(); + while (limit > start && isspace(s[limit-1])) { + limit--; + } + return Slice(s.data() + start, limit - start); +} + +static void AppendWithSpace(std::string* str, Slice msg) { + if (msg.empty()) return; + if (!str->empty()) { + str->push_back(' '); + } + str->append(msg.data(), msg.size()); +} + +class Stats { + private: + double start_; + double finish_; + double seconds_; + int done_; + int next_report_; + int64_t bytes_; + double last_op_finish_; + Histogram hist_; + std::string message_; + + public: + Stats() { Start(); } + + void Start() { + next_report_ = 100; + last_op_finish_ = start_; + hist_.Clear(); + done_ = 0; + bytes_ = 0; + seconds_ = 0; + start_ = Env::Default()->NowMicros(); + finish_ = start_; + message_.clear(); + } + + void Merge(const Stats& other) { + hist_.Merge(other.hist_); + done_ += other.done_; + bytes_ += other.bytes_; + seconds_ += other.seconds_; + if (other.start_ < start_) start_ = other.start_; + if (other.finish_ > finish_) finish_ = other.finish_; + + // Just keep the messages from one thread + if (message_.empty()) message_ = other.message_; + } + + void Stop() { + finish_ = Env::Default()->NowMicros(); + seconds_ = (finish_ - start_) * 1e-6; + } + + void AddMessage(Slice msg) { + AppendWithSpace(&message_, msg); + } + + void FinishedSingleOp() { + if (FLAGS_histogram) { + double now = Env::Default()->NowMicros(); + double micros = now - last_op_finish_; + hist_.Add(micros); + if (micros > 20000) { + fprintf(stderr, "long op: %.1f micros%30s\r", micros, ""); + fflush(stderr); + } + last_op_finish_ = now; + } + + done_++; + if (done_ >= next_report_) { + if (next_report_ < 1000) next_report_ += 100; + else if (next_report_ < 5000) next_report_ += 500; + else if (next_report_ < 10000) next_report_ += 1000; + else if (next_report_ < 50000) next_report_ += 5000; + else if (next_report_ < 100000) next_report_ += 10000; + else if (next_report_ < 500000) next_report_ += 50000; + else next_report_ += 100000; + fprintf(stderr, "... finished %d ops%30s\r", done_, ""); + fflush(stderr); + } + } + + void AddBytes(int64_t n) { + bytes_ += n; + } + + void Report(const Slice& name) { + // Pretend at least one op was done in case we are running a benchmark + // that does not call FinishedSingleOp(). + if (done_ < 1) done_ = 1; + + std::string extra; + if (bytes_ > 0) { + // Rate is computed on actual elapsed time, not the sum of per-thread + // elapsed times. + double elapsed = (finish_ - start_) * 1e-6; + char rate[100]; + snprintf(rate, sizeof(rate), "%6.1f MB/s", + (bytes_ / 1048576.0) / elapsed); + extra = rate; + } + AppendWithSpace(&extra, message_); + + fprintf(stdout, "%-12s : %11.3f micros/op;%s%s\n", + name.ToString().c_str(), + seconds_ * 1e6 / done_, + (extra.empty() ? "" : " "), + extra.c_str()); + if (FLAGS_histogram) { + fprintf(stdout, "Microseconds per op:\n%s\n", hist_.ToString().c_str()); + } + fflush(stdout); + } +}; + +// State shared by all concurrent executions of the same benchmark. +struct SharedState { + port::Mutex mu; + port::CondVar cv; + int total; + + // Each thread goes through the following states: + // (1) initializing + // (2) waiting for others to be initialized + // (3) running + // (4) done + + int num_initialized; + int num_done; + bool start; + + SharedState() : cv(&mu) { } +}; + +// Per-thread state for concurrent executions of the same benchmark. +struct ThreadState { + int tid; // 0..n-1 when running in n threads + Random rand; // Has different seeds for different threads + Stats stats; + SharedState* shared; + + ThreadState(int index) + : tid(index), + rand(1000 + index) { + } +}; + +} // namespace + +class Benchmark { + private: + Cache* cache_; + const FilterPolicy* filter_policy_; + DB* db_; + int num_; + int value_size_; + int entries_per_batch_; + WriteOptions write_options_; + int reads_; + int heap_counter_; + + void PrintHeader() { + const int kKeySize = 16; + PrintEnvironment(); + fprintf(stdout, "Keys: %d bytes each\n", kKeySize); + fprintf(stdout, "Values: %d bytes each (%d bytes after compression)\n", + FLAGS_value_size, + static_cast(FLAGS_value_size * FLAGS_compression_ratio + 0.5)); + fprintf(stdout, "Entries: %d\n", num_); + fprintf(stdout, "RawSize: %.1f MB (estimated)\n", + ((static_cast(kKeySize + FLAGS_value_size) * num_) + / 1048576.0)); + fprintf(stdout, "FileSize: %.1f MB (estimated)\n", + (((kKeySize + FLAGS_value_size * FLAGS_compression_ratio) * num_) + / 1048576.0)); + PrintWarnings(); + fprintf(stdout, "------------------------------------------------\n"); + } + + void PrintWarnings() { +#if defined(__GNUC__) && !defined(__OPTIMIZE__) + fprintf(stdout, + "WARNING: Optimization is disabled: benchmarks unnecessarily slow\n" + ); +#endif +#ifndef NDEBUG + fprintf(stdout, + "WARNING: Assertions are enabled; benchmarks unnecessarily slow\n"); +#endif + + // See if snappy is working by attempting to compress a compressible string + const char text[] = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"; + std::string compressed; + if (!port::Snappy_Compress(text, sizeof(text), &compressed)) { + fprintf(stdout, "WARNING: Snappy compression is not enabled\n"); + } else if (compressed.size() >= sizeof(text)) { + fprintf(stdout, "WARNING: Snappy compression is not effective\n"); + } + } + + void PrintEnvironment() { + fprintf(stderr, "LevelDB: version %d.%d\n", + kMajorVersion, kMinorVersion); + +#if defined(__linux) + time_t now = time(NULL); + fprintf(stderr, "Date: %s", ctime(&now)); // ctime() adds newline + + FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); + if (cpuinfo != NULL) { + char line[1000]; + int num_cpus = 0; + std::string cpu_type; + std::string cache_size; + while (fgets(line, sizeof(line), cpuinfo) != NULL) { + const char* sep = strchr(line, ':'); + if (sep == NULL) { + continue; + } + Slice key = TrimSpace(Slice(line, sep - 1 - line)); + Slice val = TrimSpace(Slice(sep + 1)); + if (key == "model name") { + ++num_cpus; + cpu_type = val.ToString(); + } else if (key == "cache size") { + cache_size = val.ToString(); + } + } + fclose(cpuinfo); + fprintf(stderr, "CPU: %d * %s\n", num_cpus, cpu_type.c_str()); + fprintf(stderr, "CPUCache: %s\n", cache_size.c_str()); + } +#endif + } + + public: + Benchmark() + : cache_(FLAGS_cache_size >= 0 ? NewLRUCache(FLAGS_cache_size) : NULL), + filter_policy_(FLAGS_bloom_bits >= 0 + ? NewBloomFilterPolicy(FLAGS_bloom_bits) + : NULL), + db_(NULL), + num_(FLAGS_num), + value_size_(FLAGS_value_size), + entries_per_batch_(1), + reads_(FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads), + heap_counter_(0) { + std::vector files; + Env::Default()->GetChildren(FLAGS_db, &files); + for (size_t i = 0; i < files.size(); i++) { + if (Slice(files[i]).starts_with("heap-")) { + Env::Default()->DeleteFile(std::string(FLAGS_db) + "/" + files[i]); + } + } + if (!FLAGS_use_existing_db) { + DestroyDB(FLAGS_db, Options()); + } + } + + ~Benchmark() { + delete db_; + delete cache_; + delete filter_policy_; + } + + void Run() { + PrintHeader(); + Open(); + + const char* benchmarks = FLAGS_benchmarks; + while (benchmarks != NULL) { + const char* sep = strchr(benchmarks, ','); + Slice name; + if (sep == NULL) { + name = benchmarks; + benchmarks = NULL; + } else { + name = Slice(benchmarks, sep - benchmarks); + benchmarks = sep + 1; + } + + // Reset parameters that may be overriddden bwlow + num_ = FLAGS_num; + reads_ = (FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads); + value_size_ = FLAGS_value_size; + entries_per_batch_ = 1; + write_options_ = WriteOptions(); + + void (Benchmark::*method)(ThreadState*) = NULL; + bool fresh_db = false; + int num_threads = FLAGS_threads; + + if (name == Slice("fillseq")) { + fresh_db = true; + method = &Benchmark::WriteSeq; + } else if (name == Slice("fillbatch")) { + fresh_db = true; + entries_per_batch_ = 1000; + method = &Benchmark::WriteSeq; + } else if (name == Slice("fillrandom")) { + fresh_db = true; + method = &Benchmark::WriteRandom; + } else if (name == Slice("overwrite")) { + fresh_db = false; + method = &Benchmark::WriteRandom; + } else if (name == Slice("fillsync")) { + fresh_db = true; + num_ /= 1000; + write_options_.sync = true; + method = &Benchmark::WriteRandom; + } else if (name == Slice("fill100K")) { + fresh_db = true; + num_ /= 1000; + value_size_ = 100 * 1000; + method = &Benchmark::WriteRandom; + } else if (name == Slice("readseq")) { + method = &Benchmark::ReadSequential; + } else if (name == Slice("readreverse")) { + method = &Benchmark::ReadReverse; + } else if (name == Slice("readrandom")) { + method = &Benchmark::ReadRandom; + } else if (name == Slice("readmissing")) { + method = &Benchmark::ReadMissing; + } else if (name == Slice("seekrandom")) { + method = &Benchmark::SeekRandom; + } else if (name == Slice("readhot")) { + method = &Benchmark::ReadHot; + } else if (name == Slice("readrandomsmall")) { + reads_ /= 1000; + method = &Benchmark::ReadRandom; + } else if (name == Slice("deleteseq")) { + method = &Benchmark::DeleteSeq; + } else if (name == Slice("deleterandom")) { + method = &Benchmark::DeleteRandom; + } else if (name == Slice("readwhilewriting")) { + num_threads++; // Add extra thread for writing + method = &Benchmark::ReadWhileWriting; + } else if (name == Slice("compact")) { + method = &Benchmark::Compact; + } else if (name == Slice("crc32c")) { + method = &Benchmark::Crc32c; + } else if (name == Slice("acquireload")) { + method = &Benchmark::AcquireLoad; + } else if (name == Slice("snappycomp")) { + method = &Benchmark::SnappyCompress; + } else if (name == Slice("snappyuncomp")) { + method = &Benchmark::SnappyUncompress; + } else if (name == Slice("heapprofile")) { + HeapProfile(); + } else if (name == Slice("stats")) { + PrintStats("leveldb.stats"); + } else if (name == Slice("sstables")) { + PrintStats("leveldb.sstables"); + } else { + if (name != Slice()) { // No error message for empty name + fprintf(stderr, "unknown benchmark '%s'\n", name.ToString().c_str()); + } + } + + if (fresh_db) { + if (FLAGS_use_existing_db) { + fprintf(stdout, "%-12s : skipped (--use_existing_db is true)\n", + name.ToString().c_str()); + method = NULL; + } else { + delete db_; + db_ = NULL; + DestroyDB(FLAGS_db, Options()); + Open(); + } + } + + if (method != NULL) { + RunBenchmark(num_threads, name, method); + } + } + } + + private: + struct ThreadArg { + Benchmark* bm; + SharedState* shared; + ThreadState* thread; + void (Benchmark::*method)(ThreadState*); + }; + + static void ThreadBody(void* v) { + ThreadArg* arg = reinterpret_cast(v); + SharedState* shared = arg->shared; + ThreadState* thread = arg->thread; + { + MutexLock l(&shared->mu); + shared->num_initialized++; + if (shared->num_initialized >= shared->total) { + shared->cv.SignalAll(); + } + while (!shared->start) { + shared->cv.Wait(); + } + } + + thread->stats.Start(); + (arg->bm->*(arg->method))(thread); + thread->stats.Stop(); + + { + MutexLock l(&shared->mu); + shared->num_done++; + if (shared->num_done >= shared->total) { + shared->cv.SignalAll(); + } + } + } + + void RunBenchmark(int n, Slice name, + void (Benchmark::*method)(ThreadState*)) { + SharedState shared; + shared.total = n; + shared.num_initialized = 0; + shared.num_done = 0; + shared.start = false; + + ThreadArg* arg = new ThreadArg[n]; + for (int i = 0; i < n; i++) { + arg[i].bm = this; + arg[i].method = method; + arg[i].shared = &shared; + arg[i].thread = new ThreadState(i); + arg[i].thread->shared = &shared; + Env::Default()->StartThread(ThreadBody, &arg[i]); + } + + shared.mu.Lock(); + while (shared.num_initialized < n) { + shared.cv.Wait(); + } + + shared.start = true; + shared.cv.SignalAll(); + while (shared.num_done < n) { + shared.cv.Wait(); + } + shared.mu.Unlock(); + + for (int i = 1; i < n; i++) { + arg[0].thread->stats.Merge(arg[i].thread->stats); + } + arg[0].thread->stats.Report(name); + + for (int i = 0; i < n; i++) { + delete arg[i].thread; + } + delete[] arg; + } + + void Crc32c(ThreadState* thread) { + // Checksum about 500MB of data total + const int size = 4096; + const char* label = "(4K per op)"; + std::string data(size, 'x'); + int64_t bytes = 0; + uint32_t crc = 0; + while (bytes < 500 * 1048576) { + crc = crc32c::Value(data.data(), size); + thread->stats.FinishedSingleOp(); + bytes += size; + } + // Print so result is not dead + fprintf(stderr, "... crc=0x%x\r", static_cast(crc)); + + thread->stats.AddBytes(bytes); + thread->stats.AddMessage(label); + } + + void AcquireLoad(ThreadState* thread) { + int dummy; + port::AtomicPointer ap(&dummy); + int count = 0; + void *ptr = NULL; + thread->stats.AddMessage("(each op is 1000 loads)"); + while (count < 100000) { + for (int i = 0; i < 1000; i++) { + ptr = ap.Acquire_Load(); + } + count++; + thread->stats.FinishedSingleOp(); + } + if (ptr == NULL) exit(1); // Disable unused variable warning. + } + + void SnappyCompress(ThreadState* thread) { + RandomGenerator gen; + Slice input = gen.Generate(Options().block_size); + int64_t bytes = 0; + int64_t produced = 0; + bool ok = true; + std::string compressed; + while (ok && bytes < 1024 * 1048576) { // Compress 1G + ok = port::Snappy_Compress(input.data(), input.size(), &compressed); + produced += compressed.size(); + bytes += input.size(); + thread->stats.FinishedSingleOp(); + } + + if (!ok) { + thread->stats.AddMessage("(snappy failure)"); + } else { + char buf[100]; + snprintf(buf, sizeof(buf), "(output: %.1f%%)", + (produced * 100.0) / bytes); + thread->stats.AddMessage(buf); + thread->stats.AddBytes(bytes); + } + } + + void SnappyUncompress(ThreadState* thread) { + RandomGenerator gen; + Slice input = gen.Generate(Options().block_size); + std::string compressed; + bool ok = port::Snappy_Compress(input.data(), input.size(), &compressed); + int64_t bytes = 0; + char* uncompressed = new char[input.size()]; + while (ok && bytes < 1024 * 1048576) { // Compress 1G + ok = port::Snappy_Uncompress(compressed.data(), compressed.size(), + uncompressed); + bytes += input.size(); + thread->stats.FinishedSingleOp(); + } + delete[] uncompressed; + + if (!ok) { + thread->stats.AddMessage("(snappy failure)"); + } else { + thread->stats.AddBytes(bytes); + } + } + + void Open() { + assert(db_ == NULL); + Options options; + options.create_if_missing = !FLAGS_use_existing_db; + options.block_cache = cache_; + options.write_buffer_size = FLAGS_write_buffer_size; + options.max_open_files = FLAGS_open_files; + options.filter_policy = filter_policy_; + Status s = DB::Open(options, FLAGS_db, &db_); + if (!s.ok()) { + fprintf(stderr, "open error: %s\n", s.ToString().c_str()); + exit(1); + } + } + + void WriteSeq(ThreadState* thread) { + DoWrite(thread, true); + } + + void WriteRandom(ThreadState* thread) { + DoWrite(thread, false); + } + + void DoWrite(ThreadState* thread, bool seq) { + if (num_ != FLAGS_num) { + char msg[100]; + snprintf(msg, sizeof(msg), "(%d ops)", num_); + thread->stats.AddMessage(msg); + } + + RandomGenerator gen; + WriteBatch batch; + Status s; + int64_t bytes = 0; + for (int i = 0; i < num_; i += entries_per_batch_) { + batch.Clear(); + for (int j = 0; j < entries_per_batch_; j++) { + const int k = seq ? i+j : (thread->rand.Next() % FLAGS_num); + char key[100]; + snprintf(key, sizeof(key), "%016d", k); + batch.Put(key, gen.Generate(value_size_)); + bytes += value_size_ + strlen(key); + thread->stats.FinishedSingleOp(); + } + s = db_->Write(write_options_, &batch); + if (!s.ok()) { + fprintf(stderr, "put error: %s\n", s.ToString().c_str()); + exit(1); + } + } + thread->stats.AddBytes(bytes); + } + + void ReadSequential(ThreadState* thread) { + Iterator* iter = db_->NewIterator(ReadOptions()); + int i = 0; + int64_t bytes = 0; + for (iter->SeekToFirst(); i < reads_ && iter->Valid(); iter->Next()) { + bytes += iter->key().size() + iter->value().size(); + thread->stats.FinishedSingleOp(); + ++i; + } + delete iter; + thread->stats.AddBytes(bytes); + } + + void ReadReverse(ThreadState* thread) { + Iterator* iter = db_->NewIterator(ReadOptions()); + int i = 0; + int64_t bytes = 0; + for (iter->SeekToLast(); i < reads_ && iter->Valid(); iter->Prev()) { + bytes += iter->key().size() + iter->value().size(); + thread->stats.FinishedSingleOp(); + ++i; + } + delete iter; + thread->stats.AddBytes(bytes); + } + + void ReadRandom(ThreadState* thread) { + ReadOptions options; + std::string value; + int found = 0; + for (int i = 0; i < reads_; i++) { + char key[100]; + const int k = thread->rand.Next() % FLAGS_num; + snprintf(key, sizeof(key), "%016d", k); + if (db_->Get(options, key, &value).ok()) { + found++; + } + thread->stats.FinishedSingleOp(); + } + char msg[100]; + snprintf(msg, sizeof(msg), "(%d of %d found)", found, num_); + thread->stats.AddMessage(msg); + } + + void ReadMissing(ThreadState* thread) { + ReadOptions options; + std::string value; + for (int i = 0; i < reads_; i++) { + char key[100]; + const int k = thread->rand.Next() % FLAGS_num; + snprintf(key, sizeof(key), "%016d.", k); + db_->Get(options, key, &value); + thread->stats.FinishedSingleOp(); + } + } + + void ReadHot(ThreadState* thread) { + ReadOptions options; + std::string value; + const int range = (FLAGS_num + 99) / 100; + for (int i = 0; i < reads_; i++) { + char key[100]; + const int k = thread->rand.Next() % range; + snprintf(key, sizeof(key), "%016d", k); + db_->Get(options, key, &value); + thread->stats.FinishedSingleOp(); + } + } + + void SeekRandom(ThreadState* thread) { + ReadOptions options; + std::string value; + int found = 0; + for (int i = 0; i < reads_; i++) { + Iterator* iter = db_->NewIterator(options); + char key[100]; + const int k = thread->rand.Next() % FLAGS_num; + snprintf(key, sizeof(key), "%016d", k); + iter->Seek(key); + if (iter->Valid() && iter->key() == key) found++; + delete iter; + thread->stats.FinishedSingleOp(); + } + char msg[100]; + snprintf(msg, sizeof(msg), "(%d of %d found)", found, num_); + thread->stats.AddMessage(msg); + } + + void DoDelete(ThreadState* thread, bool seq) { + RandomGenerator gen; + WriteBatch batch; + Status s; + for (int i = 0; i < num_; i += entries_per_batch_) { + batch.Clear(); + for (int j = 0; j < entries_per_batch_; j++) { + const int k = seq ? i+j : (thread->rand.Next() % FLAGS_num); + char key[100]; + snprintf(key, sizeof(key), "%016d", k); + batch.Delete(key); + thread->stats.FinishedSingleOp(); + } + s = db_->Write(write_options_, &batch); + if (!s.ok()) { + fprintf(stderr, "del error: %s\n", s.ToString().c_str()); + exit(1); + } + } + } + + void DeleteSeq(ThreadState* thread) { + DoDelete(thread, true); + } + + void DeleteRandom(ThreadState* thread) { + DoDelete(thread, false); + } + + void ReadWhileWriting(ThreadState* thread) { + if (thread->tid > 0) { + ReadRandom(thread); + } else { + // Special thread that keeps writing until other threads are done. + RandomGenerator gen; + while (true) { + { + MutexLock l(&thread->shared->mu); + if (thread->shared->num_done + 1 >= thread->shared->num_initialized) { + // Other threads have finished + break; + } + } + + const int k = thread->rand.Next() % FLAGS_num; + char key[100]; + snprintf(key, sizeof(key), "%016d", k); + Status s = db_->Put(write_options_, key, gen.Generate(value_size_)); + if (!s.ok()) { + fprintf(stderr, "put error: %s\n", s.ToString().c_str()); + exit(1); + } + } + + // Do not count any of the preceding work/delay in stats. + thread->stats.Start(); + } + } + + void Compact(ThreadState* thread) { + db_->CompactRange(NULL, NULL); + } + + void PrintStats(const char* key) { + std::string stats; + if (!db_->GetProperty(key, &stats)) { + stats = "(failed)"; + } + fprintf(stdout, "\n%s\n", stats.c_str()); + } + + static void WriteToFile(void* arg, const char* buf, int n) { + reinterpret_cast(arg)->Append(Slice(buf, n)); + } + + void HeapProfile() { + char fname[100]; + snprintf(fname, sizeof(fname), "%s/heap-%04d", FLAGS_db, ++heap_counter_); + WritableFile* file; + Status s = Env::Default()->NewWritableFile(fname, &file); + if (!s.ok()) { + fprintf(stderr, "%s\n", s.ToString().c_str()); + return; + } + bool ok = port::GetHeapProfile(WriteToFile, file); + delete file; + if (!ok) { + fprintf(stderr, "heap profiling not supported\n"); + Env::Default()->DeleteFile(fname); + } + } +}; + +} // namespace leveldb + +int main(int argc, char** argv) { + FLAGS_write_buffer_size = leveldb::Options().write_buffer_size; + FLAGS_open_files = leveldb::Options().max_open_files; + std::string default_db_path; + + for (int i = 1; i < argc; i++) { + double d; + int n; + char junk; + if (leveldb::Slice(argv[i]).starts_with("--benchmarks=")) { + FLAGS_benchmarks = argv[i] + strlen("--benchmarks="); + } else if (sscanf(argv[i], "--compression_ratio=%lf%c", &d, &junk) == 1) { + FLAGS_compression_ratio = d; + } else if (sscanf(argv[i], "--histogram=%d%c", &n, &junk) == 1 && + (n == 0 || n == 1)) { + FLAGS_histogram = n; + } else if (sscanf(argv[i], "--use_existing_db=%d%c", &n, &junk) == 1 && + (n == 0 || n == 1)) { + FLAGS_use_existing_db = n; + } else if (sscanf(argv[i], "--num=%d%c", &n, &junk) == 1) { + FLAGS_num = n; + } else if (sscanf(argv[i], "--reads=%d%c", &n, &junk) == 1) { + FLAGS_reads = n; + } else if (sscanf(argv[i], "--threads=%d%c", &n, &junk) == 1) { + FLAGS_threads = n; + } else if (sscanf(argv[i], "--value_size=%d%c", &n, &junk) == 1) { + FLAGS_value_size = n; + } else if (sscanf(argv[i], "--write_buffer_size=%d%c", &n, &junk) == 1) { + FLAGS_write_buffer_size = n; + } else if (sscanf(argv[i], "--cache_size=%d%c", &n, &junk) == 1) { + FLAGS_cache_size = n; + } else if (sscanf(argv[i], "--bloom_bits=%d%c", &n, &junk) == 1) { + FLAGS_bloom_bits = n; + } else if (sscanf(argv[i], "--open_files=%d%c", &n, &junk) == 1) { + FLAGS_open_files = n; + } else if (strncmp(argv[i], "--db=", 5) == 0) { + FLAGS_db = argv[i] + 5; + } else { + fprintf(stderr, "Invalid flag '%s'\n", argv[i]); + exit(1); + } + } + + // Choose a location for the test database if none given with --db= + if (FLAGS_db == NULL) { + leveldb::Env::Default()->GetTestDirectory(&default_db_path); + default_db_path += "/dbbench"; + FLAGS_db = default_db_path.c_str(); + } + + leveldb::Benchmark benchmark; + benchmark.Run(); + return 0; +} diff --git a/src/leveldb/db/db_impl.cc b/src/leveldb/db/db_impl.cc new file mode 100644 index 0000000..faf5e7d --- /dev/null +++ b/src/leveldb/db/db_impl.cc @@ -0,0 +1,1513 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/db_impl.h" + +#include +#include +#include +#include +#include +#include +#include "db/builder.h" +#include "db/db_iter.h" +#include "db/dbformat.h" +#include "db/filename.h" +#include "db/log_reader.h" +#include "db/log_writer.h" +#include "db/memtable.h" +#include "db/table_cache.h" +#include "db/version_set.h" +#include "db/write_batch_internal.h" +#include "leveldb/db.h" +#include "leveldb/env.h" +#include "leveldb/status.h" +#include "leveldb/table.h" +#include "leveldb/table_builder.h" +#include "port/port.h" +#include "table/block.h" +#include "table/merger.h" +#include "table/two_level_iterator.h" +#include "util/coding.h" +#include "util/logging.h" +#include "util/mutexlock.h" + +namespace leveldb { + +const int kNumNonTableCacheFiles = 10; + +// Information kept for every waiting writer +struct DBImpl::Writer { + Status status; + WriteBatch* batch; + bool sync; + bool done; + port::CondVar cv; + + explicit Writer(port::Mutex* mu) : cv(mu) { } +}; + +struct DBImpl::CompactionState { + Compaction* const compaction; + + // Sequence numbers < smallest_snapshot are not significant since we + // will never have to service a snapshot below smallest_snapshot. + // Therefore if we have seen a sequence number S <= smallest_snapshot, + // we can drop all entries for the same key with sequence numbers < S. + SequenceNumber smallest_snapshot; + + // Files produced by compaction + struct Output { + uint64_t number; + uint64_t file_size; + InternalKey smallest, largest; + }; + std::vector outputs; + + // State kept for output being generated + WritableFile* outfile; + TableBuilder* builder; + + uint64_t total_bytes; + + Output* current_output() { return &outputs[outputs.size()-1]; } + + explicit CompactionState(Compaction* c) + : compaction(c), + outfile(NULL), + builder(NULL), + total_bytes(0) { + } +}; + +// Fix user-supplied options to be reasonable +template +static void ClipToRange(T* ptr, V minvalue, V maxvalue) { + if (static_cast(*ptr) > maxvalue) *ptr = maxvalue; + if (static_cast(*ptr) < minvalue) *ptr = minvalue; +} +Options SanitizeOptions(const std::string& dbname, + const InternalKeyComparator* icmp, + const InternalFilterPolicy* ipolicy, + const Options& src) { + Options result = src; + result.comparator = icmp; + result.filter_policy = (src.filter_policy != NULL) ? ipolicy : NULL; + ClipToRange(&result.max_open_files, 64 + kNumNonTableCacheFiles, 50000); + ClipToRange(&result.write_buffer_size, 64<<10, 1<<30); + ClipToRange(&result.block_size, 1<<10, 4<<20); + if (result.info_log == NULL) { + // Open a log file in the same directory as the db + src.env->CreateDir(dbname); // In case it does not exist + src.env->RenameFile(InfoLogFileName(dbname), OldInfoLogFileName(dbname)); + Status s = src.env->NewLogger(InfoLogFileName(dbname), &result.info_log); + if (!s.ok()) { + // No place suitable for logging + result.info_log = NULL; + } + } + if (result.block_cache == NULL) { + result.block_cache = NewLRUCache(8 << 20); + } + return result; +} + +DBImpl::DBImpl(const Options& raw_options, const std::string& dbname) + : env_(raw_options.env), + internal_comparator_(raw_options.comparator), + internal_filter_policy_(raw_options.filter_policy), + options_(SanitizeOptions(dbname, &internal_comparator_, + &internal_filter_policy_, raw_options)), + owns_info_log_(options_.info_log != raw_options.info_log), + owns_cache_(options_.block_cache != raw_options.block_cache), + dbname_(dbname), + db_lock_(NULL), + shutting_down_(NULL), + bg_cv_(&mutex_), + mem_(new MemTable(internal_comparator_)), + imm_(NULL), + logfile_(NULL), + logfile_number_(0), + log_(NULL), + seed_(0), + tmp_batch_(new WriteBatch), + bg_compaction_scheduled_(false), + manual_compaction_(NULL) { + mem_->Ref(); + has_imm_.Release_Store(NULL); + + // Reserve ten files or so for other uses and give the rest to TableCache. + const int table_cache_size = options_.max_open_files - kNumNonTableCacheFiles; + table_cache_ = new TableCache(dbname_, &options_, table_cache_size); + + versions_ = new VersionSet(dbname_, &options_, table_cache_, + &internal_comparator_); +} + +DBImpl::~DBImpl() { + // Wait for background work to finish + mutex_.Lock(); + shutting_down_.Release_Store(this); // Any non-NULL value is ok + while (bg_compaction_scheduled_) { + bg_cv_.Wait(); + } + mutex_.Unlock(); + + if (db_lock_ != NULL) { + env_->UnlockFile(db_lock_); + } + + delete versions_; + if (mem_ != NULL) mem_->Unref(); + if (imm_ != NULL) imm_->Unref(); + delete tmp_batch_; + delete log_; + delete logfile_; + delete table_cache_; + + if (owns_info_log_) { + delete options_.info_log; + } + if (owns_cache_) { + delete options_.block_cache; + } +} + +Status DBImpl::NewDB() { + VersionEdit new_db; + new_db.SetComparatorName(user_comparator()->Name()); + new_db.SetLogNumber(0); + new_db.SetNextFile(2); + new_db.SetLastSequence(0); + + const std::string manifest = DescriptorFileName(dbname_, 1); + WritableFile* file; + Status s = env_->NewWritableFile(manifest, &file); + if (!s.ok()) { + return s; + } + { + log::Writer log(file); + std::string record; + new_db.EncodeTo(&record); + s = log.AddRecord(record); + if (s.ok()) { + s = file->Close(); + } + } + delete file; + if (s.ok()) { + // Make "CURRENT" file that points to the new manifest file. + s = SetCurrentFile(env_, dbname_, 1); + } else { + env_->DeleteFile(manifest); + } + return s; +} + +void DBImpl::MaybeIgnoreError(Status* s) const { + if (s->ok() || options_.paranoid_checks) { + // No change needed + } else { + Log(options_.info_log, "Ignoring error %s", s->ToString().c_str()); + *s = Status::OK(); + } +} + +void DBImpl::DeleteObsoleteFiles() { + if (!bg_error_.ok()) { + // After a background error, we don't know whether a new version may + // or may not have been committed, so we cannot safely garbage collect. + return; + } + + // Make a set of all of the live files + std::set live = pending_outputs_; + versions_->AddLiveFiles(&live); + + std::vector filenames; + env_->GetChildren(dbname_, &filenames); // Ignoring errors on purpose + uint64_t number; + FileType type; + for (size_t i = 0; i < filenames.size(); i++) { + if (ParseFileName(filenames[i], &number, &type)) { + bool keep = true; + switch (type) { + case kLogFile: + keep = ((number >= versions_->LogNumber()) || + (number == versions_->PrevLogNumber())); + break; + case kDescriptorFile: + // Keep my manifest file, and any newer incarnations' + // (in case there is a race that allows other incarnations) + keep = (number >= versions_->ManifestFileNumber()); + break; + case kTableFile: + keep = (live.find(number) != live.end()); + break; + case kTempFile: + // Any temp files that are currently being written to must + // be recorded in pending_outputs_, which is inserted into "live" + keep = (live.find(number) != live.end()); + break; + case kCurrentFile: + case kDBLockFile: + case kInfoLogFile: + keep = true; + break; + } + + if (!keep) { + if (type == kTableFile) { + table_cache_->Evict(number); + } + Log(options_.info_log, "Delete type=%d #%lld\n", + int(type), + static_cast(number)); + env_->DeleteFile(dbname_ + "/" + filenames[i]); + } + } + } +} + +Status DBImpl::Recover(VersionEdit* edit) { + mutex_.AssertHeld(); + + // Ignore error from CreateDir since the creation of the DB is + // committed only when the descriptor is created, and this directory + // may already exist from a previous failed creation attempt. + env_->CreateDir(dbname_); + assert(db_lock_ == NULL); + Status s = env_->LockFile(LockFileName(dbname_), &db_lock_); + if (!s.ok()) { + return s; + } + + if (!env_->FileExists(CurrentFileName(dbname_))) { + if (options_.create_if_missing) { + s = NewDB(); + if (!s.ok()) { + return s; + } + } else { + return Status::InvalidArgument( + dbname_, "does not exist (create_if_missing is false)"); + } + } else { + if (options_.error_if_exists) { + return Status::InvalidArgument( + dbname_, "exists (error_if_exists is true)"); + } + } + + s = versions_->Recover(); + if (s.ok()) { + SequenceNumber max_sequence(0); + + // Recover from all newer log files than the ones named in the + // descriptor (new log files may have been added by the previous + // incarnation without registering them in the descriptor). + // + // Note that PrevLogNumber() is no longer used, but we pay + // attention to it in case we are recovering a database + // produced by an older version of leveldb. + const uint64_t min_log = versions_->LogNumber(); + const uint64_t prev_log = versions_->PrevLogNumber(); + std::vector filenames; + s = env_->GetChildren(dbname_, &filenames); + if (!s.ok()) { + return s; + } + std::set expected; + versions_->AddLiveFiles(&expected); + uint64_t number; + FileType type; + std::vector logs; + for (size_t i = 0; i < filenames.size(); i++) { + if (ParseFileName(filenames[i], &number, &type)) { + expected.erase(number); + if (type == kLogFile && ((number >= min_log) || (number == prev_log))) + logs.push_back(number); + } + } + if (!expected.empty()) { + char buf[50]; + snprintf(buf, sizeof(buf), "%d missing files; e.g.", + static_cast(expected.size())); + return Status::Corruption(buf, TableFileName(dbname_, *(expected.begin()))); + } + + // Recover in the order in which the logs were generated + std::sort(logs.begin(), logs.end()); + for (size_t i = 0; i < logs.size(); i++) { + s = RecoverLogFile(logs[i], edit, &max_sequence); + + // The previous incarnation may not have written any MANIFEST + // records after allocating this log number. So we manually + // update the file number allocation counter in VersionSet. + versions_->MarkFileNumberUsed(logs[i]); + } + + if (s.ok()) { + if (versions_->LastSequence() < max_sequence) { + versions_->SetLastSequence(max_sequence); + } + } + } + + return s; +} + +Status DBImpl::RecoverLogFile(uint64_t log_number, + VersionEdit* edit, + SequenceNumber* max_sequence) { + struct LogReporter : public log::Reader::Reporter { + Env* env; + Logger* info_log; + const char* fname; + Status* status; // NULL if options_.paranoid_checks==false + virtual void Corruption(size_t bytes, const Status& s) { + Log(info_log, "%s%s: dropping %d bytes; %s", + (this->status == NULL ? "(ignoring error) " : ""), + fname, static_cast(bytes), s.ToString().c_str()); + if (this->status != NULL && this->status->ok()) *this->status = s; + } + }; + + mutex_.AssertHeld(); + + // Open the log file + std::string fname = LogFileName(dbname_, log_number); + SequentialFile* file; + Status status = env_->NewSequentialFile(fname, &file); + if (!status.ok()) { + MaybeIgnoreError(&status); + return status; + } + + // Create the log reader. + LogReporter reporter; + reporter.env = env_; + reporter.info_log = options_.info_log; + reporter.fname = fname.c_str(); + reporter.status = (options_.paranoid_checks ? &status : NULL); + // We intentially make log::Reader do checksumming even if + // paranoid_checks==false so that corruptions cause entire commits + // to be skipped instead of propagating bad information (like overly + // large sequence numbers). + log::Reader reader(file, &reporter, true/*checksum*/, + 0/*initial_offset*/); + Log(options_.info_log, "Recovering log #%llu", + (unsigned long long) log_number); + + // Read all the records and add to a memtable + std::string scratch; + Slice record; + WriteBatch batch; + MemTable* mem = NULL; + while (reader.ReadRecord(&record, &scratch) && + status.ok()) { + if (record.size() < 12) { + reporter.Corruption( + record.size(), Status::Corruption("log record too small")); + continue; + } + WriteBatchInternal::SetContents(&batch, record); + + if (mem == NULL) { + mem = new MemTable(internal_comparator_); + mem->Ref(); + } + status = WriteBatchInternal::InsertInto(&batch, mem); + MaybeIgnoreError(&status); + if (!status.ok()) { + break; + } + const SequenceNumber last_seq = + WriteBatchInternal::Sequence(&batch) + + WriteBatchInternal::Count(&batch) - 1; + if (last_seq > *max_sequence) { + *max_sequence = last_seq; + } + + if (mem->ApproximateMemoryUsage() > options_.write_buffer_size) { + status = WriteLevel0Table(mem, edit, NULL); + if (!status.ok()) { + // Reflect errors immediately so that conditions like full + // file-systems cause the DB::Open() to fail. + break; + } + mem->Unref(); + mem = NULL; + } + } + + if (status.ok() && mem != NULL) { + status = WriteLevel0Table(mem, edit, NULL); + // Reflect errors immediately so that conditions like full + // file-systems cause the DB::Open() to fail. + } + + if (mem != NULL) mem->Unref(); + delete file; + return status; +} + +Status DBImpl::WriteLevel0Table(MemTable* mem, VersionEdit* edit, + Version* base) { + mutex_.AssertHeld(); + const uint64_t start_micros = env_->NowMicros(); + FileMetaData meta; + meta.number = versions_->NewFileNumber(); + pending_outputs_.insert(meta.number); + Iterator* iter = mem->NewIterator(); + Log(options_.info_log, "Level-0 table #%llu: started", + (unsigned long long) meta.number); + + Status s; + { + mutex_.Unlock(); + s = BuildTable(dbname_, env_, options_, table_cache_, iter, &meta); + mutex_.Lock(); + } + + Log(options_.info_log, "Level-0 table #%llu: %lld bytes %s", + (unsigned long long) meta.number, + (unsigned long long) meta.file_size, + s.ToString().c_str()); + delete iter; + pending_outputs_.erase(meta.number); + + + // Note that if file_size is zero, the file has been deleted and + // should not be added to the manifest. + int level = 0; + if (s.ok() && meta.file_size > 0) { + const Slice min_user_key = meta.smallest.user_key(); + const Slice max_user_key = meta.largest.user_key(); + if (base != NULL) { + level = base->PickLevelForMemTableOutput(min_user_key, max_user_key); + } + edit->AddFile(level, meta.number, meta.file_size, + meta.smallest, meta.largest); + } + + CompactionStats stats; + stats.micros = env_->NowMicros() - start_micros; + stats.bytes_written = meta.file_size; + stats_[level].Add(stats); + return s; +} + +void DBImpl::CompactMemTable() { + mutex_.AssertHeld(); + assert(imm_ != NULL); + + // Save the contents of the memtable as a new Table + VersionEdit edit; + Version* base = versions_->current(); + base->Ref(); + Status s = WriteLevel0Table(imm_, &edit, base); + base->Unref(); + + if (s.ok() && shutting_down_.Acquire_Load()) { + s = Status::IOError("Deleting DB during memtable compaction"); + } + + // Replace immutable memtable with the generated Table + if (s.ok()) { + edit.SetPrevLogNumber(0); + edit.SetLogNumber(logfile_number_); // Earlier logs no longer needed + s = versions_->LogAndApply(&edit, &mutex_); + } + + if (s.ok()) { + // Commit to the new state + imm_->Unref(); + imm_ = NULL; + has_imm_.Release_Store(NULL); + DeleteObsoleteFiles(); + } else { + RecordBackgroundError(s); + } +} + +void DBImpl::CompactRange(const Slice* begin, const Slice* end) { + int max_level_with_files = 1; + { + MutexLock l(&mutex_); + Version* base = versions_->current(); + for (int level = 1; level < config::kNumLevels; level++) { + if (base->OverlapInLevel(level, begin, end)) { + max_level_with_files = level; + } + } + } + TEST_CompactMemTable(); // TODO(sanjay): Skip if memtable does not overlap + for (int level = 0; level < max_level_with_files; level++) { + TEST_CompactRange(level, begin, end); + } +} + +void DBImpl::TEST_CompactRange(int level, const Slice* begin,const Slice* end) { + assert(level >= 0); + assert(level + 1 < config::kNumLevels); + + InternalKey begin_storage, end_storage; + + ManualCompaction manual; + manual.level = level; + manual.done = false; + if (begin == NULL) { + manual.begin = NULL; + } else { + begin_storage = InternalKey(*begin, kMaxSequenceNumber, kValueTypeForSeek); + manual.begin = &begin_storage; + } + if (end == NULL) { + manual.end = NULL; + } else { + end_storage = InternalKey(*end, 0, static_cast(0)); + manual.end = &end_storage; + } + + MutexLock l(&mutex_); + while (!manual.done && !shutting_down_.Acquire_Load() && bg_error_.ok()) { + if (manual_compaction_ == NULL) { // Idle + manual_compaction_ = &manual; + MaybeScheduleCompaction(); + } else { // Running either my compaction or another compaction. + bg_cv_.Wait(); + } + } + if (manual_compaction_ == &manual) { + // Cancel my manual compaction since we aborted early for some reason. + manual_compaction_ = NULL; + } +} + +Status DBImpl::TEST_CompactMemTable() { + // NULL batch means just wait for earlier writes to be done + Status s = Write(WriteOptions(), NULL); + if (s.ok()) { + // Wait until the compaction completes + MutexLock l(&mutex_); + while (imm_ != NULL && bg_error_.ok()) { + bg_cv_.Wait(); + } + if (imm_ != NULL) { + s = bg_error_; + } + } + return s; +} + +void DBImpl::RecordBackgroundError(const Status& s) { + mutex_.AssertHeld(); + if (bg_error_.ok()) { + bg_error_ = s; + bg_cv_.SignalAll(); + } +} + +void DBImpl::MaybeScheduleCompaction() { + mutex_.AssertHeld(); + if (bg_compaction_scheduled_) { + // Already scheduled + } else if (shutting_down_.Acquire_Load()) { + // DB is being deleted; no more background compactions + } else if (!bg_error_.ok()) { + // Already got an error; no more changes + } else if (imm_ == NULL && + manual_compaction_ == NULL && + !versions_->NeedsCompaction()) { + // No work to be done + } else { + bg_compaction_scheduled_ = true; + env_->Schedule(&DBImpl::BGWork, this); + } +} + +void DBImpl::BGWork(void* db) { + reinterpret_cast(db)->BackgroundCall(); +} + +void DBImpl::BackgroundCall() { + MutexLock l(&mutex_); + assert(bg_compaction_scheduled_); + if (shutting_down_.Acquire_Load()) { + // No more background work when shutting down. + } else if (!bg_error_.ok()) { + // No more background work after a background error. + } else { + BackgroundCompaction(); + } + + bg_compaction_scheduled_ = false; + + // Previous compaction may have produced too many files in a level, + // so reschedule another compaction if needed. + MaybeScheduleCompaction(); + bg_cv_.SignalAll(); +} + +void DBImpl::BackgroundCompaction() { + mutex_.AssertHeld(); + + if (imm_ != NULL) { + CompactMemTable(); + return; + } + + Compaction* c; + bool is_manual = (manual_compaction_ != NULL); + InternalKey manual_end; + if (is_manual) { + ManualCompaction* m = manual_compaction_; + c = versions_->CompactRange(m->level, m->begin, m->end); + m->done = (c == NULL); + if (c != NULL) { + manual_end = c->input(0, c->num_input_files(0) - 1)->largest; + } + Log(options_.info_log, + "Manual compaction at level-%d from %s .. %s; will stop at %s\n", + m->level, + (m->begin ? m->begin->DebugString().c_str() : "(begin)"), + (m->end ? m->end->DebugString().c_str() : "(end)"), + (m->done ? "(end)" : manual_end.DebugString().c_str())); + } else { + c = versions_->PickCompaction(); + } + + Status status; + if (c == NULL) { + // Nothing to do + } else if (!is_manual && c->IsTrivialMove()) { + // Move file to next level + assert(c->num_input_files(0) == 1); + FileMetaData* f = c->input(0, 0); + c->edit()->DeleteFile(c->level(), f->number); + c->edit()->AddFile(c->level() + 1, f->number, f->file_size, + f->smallest, f->largest); + status = versions_->LogAndApply(c->edit(), &mutex_); + if (!status.ok()) { + RecordBackgroundError(status); + } + VersionSet::LevelSummaryStorage tmp; + Log(options_.info_log, "Moved #%lld to level-%d %lld bytes %s: %s\n", + static_cast(f->number), + c->level() + 1, + static_cast(f->file_size), + status.ToString().c_str(), + versions_->LevelSummary(&tmp)); + } else { + CompactionState* compact = new CompactionState(c); + status = DoCompactionWork(compact); + if (!status.ok()) { + RecordBackgroundError(status); + } + CleanupCompaction(compact); + c->ReleaseInputs(); + DeleteObsoleteFiles(); + } + delete c; + + if (status.ok()) { + // Done + } else if (shutting_down_.Acquire_Load()) { + // Ignore compaction errors found during shutting down + } else { + Log(options_.info_log, + "Compaction error: %s", status.ToString().c_str()); + } + + if (is_manual) { + ManualCompaction* m = manual_compaction_; + if (!status.ok()) { + m->done = true; + } + if (!m->done) { + // We only compacted part of the requested range. Update *m + // to the range that is left to be compacted. + m->tmp_storage = manual_end; + m->begin = &m->tmp_storage; + } + manual_compaction_ = NULL; + } +} + +void DBImpl::CleanupCompaction(CompactionState* compact) { + mutex_.AssertHeld(); + if (compact->builder != NULL) { + // May happen if we get a shutdown call in the middle of compaction + compact->builder->Abandon(); + delete compact->builder; + } else { + assert(compact->outfile == NULL); + } + delete compact->outfile; + for (size_t i = 0; i < compact->outputs.size(); i++) { + const CompactionState::Output& out = compact->outputs[i]; + pending_outputs_.erase(out.number); + } + delete compact; +} + +Status DBImpl::OpenCompactionOutputFile(CompactionState* compact) { + assert(compact != NULL); + assert(compact->builder == NULL); + uint64_t file_number; + { + mutex_.Lock(); + file_number = versions_->NewFileNumber(); + pending_outputs_.insert(file_number); + CompactionState::Output out; + out.number = file_number; + out.smallest.Clear(); + out.largest.Clear(); + compact->outputs.push_back(out); + mutex_.Unlock(); + } + + // Make the output file + std::string fname = TableFileName(dbname_, file_number); + Status s = env_->NewWritableFile(fname, &compact->outfile); + if (s.ok()) { + compact->builder = new TableBuilder(options_, compact->outfile); + } + return s; +} + +Status DBImpl::FinishCompactionOutputFile(CompactionState* compact, + Iterator* input) { + assert(compact != NULL); + assert(compact->outfile != NULL); + assert(compact->builder != NULL); + + const uint64_t output_number = compact->current_output()->number; + assert(output_number != 0); + + // Check for iterator errors + Status s = input->status(); + const uint64_t current_entries = compact->builder->NumEntries(); + if (s.ok()) { + s = compact->builder->Finish(); + } else { + compact->builder->Abandon(); + } + const uint64_t current_bytes = compact->builder->FileSize(); + compact->current_output()->file_size = current_bytes; + compact->total_bytes += current_bytes; + delete compact->builder; + compact->builder = NULL; + + // Finish and check for file errors + if (s.ok()) { + s = compact->outfile->Sync(); + } + if (s.ok()) { + s = compact->outfile->Close(); + } + delete compact->outfile; + compact->outfile = NULL; + + if (s.ok() && current_entries > 0) { + // Verify that the table is usable + Iterator* iter = table_cache_->NewIterator(ReadOptions(), + output_number, + current_bytes); + s = iter->status(); + delete iter; + if (s.ok()) { + Log(options_.info_log, + "Generated table #%llu: %lld keys, %lld bytes", + (unsigned long long) output_number, + (unsigned long long) current_entries, + (unsigned long long) current_bytes); + } + } + return s; +} + + +Status DBImpl::InstallCompactionResults(CompactionState* compact) { + mutex_.AssertHeld(); + Log(options_.info_log, "Compacted %d@%d + %d@%d files => %lld bytes", + compact->compaction->num_input_files(0), + compact->compaction->level(), + compact->compaction->num_input_files(1), + compact->compaction->level() + 1, + static_cast(compact->total_bytes)); + + // Add compaction outputs + compact->compaction->AddInputDeletions(compact->compaction->edit()); + const int level = compact->compaction->level(); + for (size_t i = 0; i < compact->outputs.size(); i++) { + const CompactionState::Output& out = compact->outputs[i]; + compact->compaction->edit()->AddFile( + level + 1, + out.number, out.file_size, out.smallest, out.largest); + } + return versions_->LogAndApply(compact->compaction->edit(), &mutex_); +} + +Status DBImpl::DoCompactionWork(CompactionState* compact) { + const uint64_t start_micros = env_->NowMicros(); + int64_t imm_micros = 0; // Micros spent doing imm_ compactions + + Log(options_.info_log, "Compacting %d@%d + %d@%d files", + compact->compaction->num_input_files(0), + compact->compaction->level(), + compact->compaction->num_input_files(1), + compact->compaction->level() + 1); + + assert(versions_->NumLevelFiles(compact->compaction->level()) > 0); + assert(compact->builder == NULL); + assert(compact->outfile == NULL); + if (snapshots_.empty()) { + compact->smallest_snapshot = versions_->LastSequence(); + } else { + compact->smallest_snapshot = snapshots_.oldest()->number_; + } + + // Release mutex while we're actually doing the compaction work + mutex_.Unlock(); + + Iterator* input = versions_->MakeInputIterator(compact->compaction); + input->SeekToFirst(); + Status status; + ParsedInternalKey ikey; + std::string current_user_key; + bool has_current_user_key = false; + SequenceNumber last_sequence_for_key = kMaxSequenceNumber; + for (; input->Valid() && !shutting_down_.Acquire_Load(); ) { + // Prioritize immutable compaction work + if (has_imm_.NoBarrier_Load() != NULL) { + const uint64_t imm_start = env_->NowMicros(); + mutex_.Lock(); + if (imm_ != NULL) { + CompactMemTable(); + bg_cv_.SignalAll(); // Wakeup MakeRoomForWrite() if necessary + } + mutex_.Unlock(); + imm_micros += (env_->NowMicros() - imm_start); + } + + Slice key = input->key(); + if (compact->compaction->ShouldStopBefore(key) && + compact->builder != NULL) { + status = FinishCompactionOutputFile(compact, input); + if (!status.ok()) { + break; + } + } + + // Handle key/value, add to state, etc. + bool drop = false; + if (!ParseInternalKey(key, &ikey)) { + // Do not hide error keys + current_user_key.clear(); + has_current_user_key = false; + last_sequence_for_key = kMaxSequenceNumber; + } else { + if (!has_current_user_key || + user_comparator()->Compare(ikey.user_key, + Slice(current_user_key)) != 0) { + // First occurrence of this user key + current_user_key.assign(ikey.user_key.data(), ikey.user_key.size()); + has_current_user_key = true; + last_sequence_for_key = kMaxSequenceNumber; + } + + if (last_sequence_for_key <= compact->smallest_snapshot) { + // Hidden by an newer entry for same user key + drop = true; // (A) + } else if (ikey.type == kTypeDeletion && + ikey.sequence <= compact->smallest_snapshot && + compact->compaction->IsBaseLevelForKey(ikey.user_key)) { + // For this user key: + // (1) there is no data in higher levels + // (2) data in lower levels will have larger sequence numbers + // (3) data in layers that are being compacted here and have + // smaller sequence numbers will be dropped in the next + // few iterations of this loop (by rule (A) above). + // Therefore this deletion marker is obsolete and can be dropped. + drop = true; + } + + last_sequence_for_key = ikey.sequence; + } +#if 0 + Log(options_.info_log, + " Compact: %s, seq %d, type: %d %d, drop: %d, is_base: %d, " + "%d smallest_snapshot: %d", + ikey.user_key.ToString().c_str(), + (int)ikey.sequence, ikey.type, kTypeValue, drop, + compact->compaction->IsBaseLevelForKey(ikey.user_key), + (int)last_sequence_for_key, (int)compact->smallest_snapshot); +#endif + + if (!drop) { + // Open output file if necessary + if (compact->builder == NULL) { + status = OpenCompactionOutputFile(compact); + if (!status.ok()) { + break; + } + } + if (compact->builder->NumEntries() == 0) { + compact->current_output()->smallest.DecodeFrom(key); + } + compact->current_output()->largest.DecodeFrom(key); + compact->builder->Add(key, input->value()); + + // Close output file if it is big enough + if (compact->builder->FileSize() >= + compact->compaction->MaxOutputFileSize()) { + status = FinishCompactionOutputFile(compact, input); + if (!status.ok()) { + break; + } + } + } + + input->Next(); + } + + if (status.ok() && shutting_down_.Acquire_Load()) { + status = Status::IOError("Deleting DB during compaction"); + } + if (status.ok() && compact->builder != NULL) { + status = FinishCompactionOutputFile(compact, input); + } + if (status.ok()) { + status = input->status(); + } + delete input; + input = NULL; + + CompactionStats stats; + stats.micros = env_->NowMicros() - start_micros - imm_micros; + for (int which = 0; which < 2; which++) { + for (int i = 0; i < compact->compaction->num_input_files(which); i++) { + stats.bytes_read += compact->compaction->input(which, i)->file_size; + } + } + for (size_t i = 0; i < compact->outputs.size(); i++) { + stats.bytes_written += compact->outputs[i].file_size; + } + + mutex_.Lock(); + stats_[compact->compaction->level() + 1].Add(stats); + + if (status.ok()) { + status = InstallCompactionResults(compact); + } + if (!status.ok()) { + RecordBackgroundError(status); + } + VersionSet::LevelSummaryStorage tmp; + Log(options_.info_log, + "compacted to: %s", versions_->LevelSummary(&tmp)); + return status; +} + +namespace { +struct IterState { + port::Mutex* mu; + Version* version; + MemTable* mem; + MemTable* imm; +}; + +static void CleanupIteratorState(void* arg1, void* arg2) { + IterState* state = reinterpret_cast(arg1); + state->mu->Lock(); + state->mem->Unref(); + if (state->imm != NULL) state->imm->Unref(); + state->version->Unref(); + state->mu->Unlock(); + delete state; +} +} // namespace + +Iterator* DBImpl::NewInternalIterator(const ReadOptions& options, + SequenceNumber* latest_snapshot, + uint32_t* seed) { + IterState* cleanup = new IterState; + mutex_.Lock(); + *latest_snapshot = versions_->LastSequence(); + + // Collect together all needed child iterators + std::vector list; + list.push_back(mem_->NewIterator()); + mem_->Ref(); + if (imm_ != NULL) { + list.push_back(imm_->NewIterator()); + imm_->Ref(); + } + versions_->current()->AddIterators(options, &list); + Iterator* internal_iter = + NewMergingIterator(&internal_comparator_, &list[0], list.size()); + versions_->current()->Ref(); + + cleanup->mu = &mutex_; + cleanup->mem = mem_; + cleanup->imm = imm_; + cleanup->version = versions_->current(); + internal_iter->RegisterCleanup(CleanupIteratorState, cleanup, NULL); + + *seed = ++seed_; + mutex_.Unlock(); + return internal_iter; +} + +Iterator* DBImpl::TEST_NewInternalIterator() { + SequenceNumber ignored; + uint32_t ignored_seed; + return NewInternalIterator(ReadOptions(), &ignored, &ignored_seed); +} + +int64_t DBImpl::TEST_MaxNextLevelOverlappingBytes() { + MutexLock l(&mutex_); + return versions_->MaxNextLevelOverlappingBytes(); +} + +Status DBImpl::Get(const ReadOptions& options, + const Slice& key, + std::string* value) { + Status s; + MutexLock l(&mutex_); + SequenceNumber snapshot; + if (options.snapshot != NULL) { + snapshot = reinterpret_cast(options.snapshot)->number_; + } else { + snapshot = versions_->LastSequence(); + } + + MemTable* mem = mem_; + MemTable* imm = imm_; + Version* current = versions_->current(); + mem->Ref(); + if (imm != NULL) imm->Ref(); + current->Ref(); + + bool have_stat_update = false; + Version::GetStats stats; + + // Unlock while reading from files and memtables + { + mutex_.Unlock(); + // First look in the memtable, then in the immutable memtable (if any). + LookupKey lkey(key, snapshot); + if (mem->Get(lkey, value, &s)) { + // Done + } else if (imm != NULL && imm->Get(lkey, value, &s)) { + // Done + } else { + s = current->Get(options, lkey, value, &stats); + have_stat_update = true; + } + mutex_.Lock(); + } + + if (have_stat_update && current->UpdateStats(stats)) { + MaybeScheduleCompaction(); + } + mem->Unref(); + if (imm != NULL) imm->Unref(); + current->Unref(); + return s; +} + +Iterator* DBImpl::NewIterator(const ReadOptions& options) { + SequenceNumber latest_snapshot; + uint32_t seed; + Iterator* iter = NewInternalIterator(options, &latest_snapshot, &seed); + return NewDBIterator( + this, user_comparator(), iter, + (options.snapshot != NULL + ? reinterpret_cast(options.snapshot)->number_ + : latest_snapshot), + seed); +} + +void DBImpl::RecordReadSample(Slice key) { + MutexLock l(&mutex_); + if (versions_->current()->RecordReadSample(key)) { + MaybeScheduleCompaction(); + } +} + +const Snapshot* DBImpl::GetSnapshot() { + MutexLock l(&mutex_); + return snapshots_.New(versions_->LastSequence()); +} + +void DBImpl::ReleaseSnapshot(const Snapshot* s) { + MutexLock l(&mutex_); + snapshots_.Delete(reinterpret_cast(s)); +} + +// Convenience methods +Status DBImpl::Put(const WriteOptions& o, const Slice& key, const Slice& val) { + return DB::Put(o, key, val); +} + +Status DBImpl::Delete(const WriteOptions& options, const Slice& key) { + return DB::Delete(options, key); +} + +Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) { + Writer w(&mutex_); + w.batch = my_batch; + w.sync = options.sync; + w.done = false; + + MutexLock l(&mutex_); + writers_.push_back(&w); + while (!w.done && &w != writers_.front()) { + w.cv.Wait(); + } + if (w.done) { + return w.status; + } + + // May temporarily unlock and wait. + Status status = MakeRoomForWrite(my_batch == NULL); + uint64_t last_sequence = versions_->LastSequence(); + Writer* last_writer = &w; + if (status.ok() && my_batch != NULL) { // NULL batch is for compactions + WriteBatch* updates = BuildBatchGroup(&last_writer); + WriteBatchInternal::SetSequence(updates, last_sequence + 1); + last_sequence += WriteBatchInternal::Count(updates); + + // Add to log and apply to memtable. We can release the lock + // during this phase since &w is currently responsible for logging + // and protects against concurrent loggers and concurrent writes + // into mem_. + { + mutex_.Unlock(); + status = log_->AddRecord(WriteBatchInternal::Contents(updates)); + bool sync_error = false; + if (status.ok() && options.sync) { + status = logfile_->Sync(); + if (!status.ok()) { + sync_error = true; + } + } + if (status.ok()) { + status = WriteBatchInternal::InsertInto(updates, mem_); + } + mutex_.Lock(); + if (sync_error) { + // The state of the log file is indeterminate: the log record we + // just added may or may not show up when the DB is re-opened. + // So we force the DB into a mode where all future writes fail. + RecordBackgroundError(status); + } + } + if (updates == tmp_batch_) tmp_batch_->Clear(); + + versions_->SetLastSequence(last_sequence); + } + + while (true) { + Writer* ready = writers_.front(); + writers_.pop_front(); + if (ready != &w) { + ready->status = status; + ready->done = true; + ready->cv.Signal(); + } + if (ready == last_writer) break; + } + + // Notify new head of write queue + if (!writers_.empty()) { + writers_.front()->cv.Signal(); + } + + return status; +} + +// REQUIRES: Writer list must be non-empty +// REQUIRES: First writer must have a non-NULL batch +WriteBatch* DBImpl::BuildBatchGroup(Writer** last_writer) { + assert(!writers_.empty()); + Writer* first = writers_.front(); + WriteBatch* result = first->batch; + assert(result != NULL); + + size_t size = WriteBatchInternal::ByteSize(first->batch); + + // Allow the group to grow up to a maximum size, but if the + // original write is small, limit the growth so we do not slow + // down the small write too much. + size_t max_size = 1 << 20; + if (size <= (128<<10)) { + max_size = size + (128<<10); + } + + *last_writer = first; + std::deque::iterator iter = writers_.begin(); + ++iter; // Advance past "first" + for (; iter != writers_.end(); ++iter) { + Writer* w = *iter; + if (w->sync && !first->sync) { + // Do not include a sync write into a batch handled by a non-sync write. + break; + } + + if (w->batch != NULL) { + size += WriteBatchInternal::ByteSize(w->batch); + if (size > max_size) { + // Do not make batch too big + break; + } + + // Append to *reuslt + if (result == first->batch) { + // Switch to temporary batch instead of disturbing caller's batch + result = tmp_batch_; + assert(WriteBatchInternal::Count(result) == 0); + WriteBatchInternal::Append(result, first->batch); + } + WriteBatchInternal::Append(result, w->batch); + } + *last_writer = w; + } + return result; +} + +// REQUIRES: mutex_ is held +// REQUIRES: this thread is currently at the front of the writer queue +Status DBImpl::MakeRoomForWrite(bool force) { + mutex_.AssertHeld(); + assert(!writers_.empty()); + bool allow_delay = !force; + Status s; + while (true) { + if (!bg_error_.ok()) { + // Yield previous error + s = bg_error_; + break; + } else if ( + allow_delay && + versions_->NumLevelFiles(0) >= config::kL0_SlowdownWritesTrigger) { + // We are getting close to hitting a hard limit on the number of + // L0 files. Rather than delaying a single write by several + // seconds when we hit the hard limit, start delaying each + // individual write by 1ms to reduce latency variance. Also, + // this delay hands over some CPU to the compaction thread in + // case it is sharing the same core as the writer. + mutex_.Unlock(); + env_->SleepForMicroseconds(1000); + allow_delay = false; // Do not delay a single write more than once + mutex_.Lock(); + } else if (!force && + (mem_->ApproximateMemoryUsage() <= options_.write_buffer_size)) { + // There is room in current memtable + break; + } else if (imm_ != NULL) { + // We have filled up the current memtable, but the previous + // one is still being compacted, so we wait. + Log(options_.info_log, "Current memtable full; waiting...\n"); + bg_cv_.Wait(); + } else if (versions_->NumLevelFiles(0) >= config::kL0_StopWritesTrigger) { + // There are too many level-0 files. + Log(options_.info_log, "Too many L0 files; waiting...\n"); + bg_cv_.Wait(); + } else { + // Attempt to switch to a new memtable and trigger compaction of old + assert(versions_->PrevLogNumber() == 0); + uint64_t new_log_number = versions_->NewFileNumber(); + WritableFile* lfile = NULL; + s = env_->NewWritableFile(LogFileName(dbname_, new_log_number), &lfile); + if (!s.ok()) { + // Avoid chewing through file number space in a tight loop. + versions_->ReuseFileNumber(new_log_number); + break; + } + delete log_; + delete logfile_; + logfile_ = lfile; + logfile_number_ = new_log_number; + log_ = new log::Writer(lfile); + imm_ = mem_; + has_imm_.Release_Store(imm_); + mem_ = new MemTable(internal_comparator_); + mem_->Ref(); + force = false; // Do not force another compaction if have room + MaybeScheduleCompaction(); + } + } + return s; +} + +bool DBImpl::GetProperty(const Slice& property, std::string* value) { + value->clear(); + + MutexLock l(&mutex_); + Slice in = property; + Slice prefix("leveldb."); + if (!in.starts_with(prefix)) return false; + in.remove_prefix(prefix.size()); + + if (in.starts_with("num-files-at-level")) { + in.remove_prefix(strlen("num-files-at-level")); + uint64_t level; + bool ok = ConsumeDecimalNumber(&in, &level) && in.empty(); + if (!ok || level >= config::kNumLevels) { + return false; + } else { + char buf[100]; + snprintf(buf, sizeof(buf), "%d", + versions_->NumLevelFiles(static_cast(level))); + *value = buf; + return true; + } + } else if (in == "stats") { + char buf[200]; + snprintf(buf, sizeof(buf), + " Compactions\n" + "Level Files Size(MB) Time(sec) Read(MB) Write(MB)\n" + "--------------------------------------------------\n" + ); + value->append(buf); + for (int level = 0; level < config::kNumLevels; level++) { + int files = versions_->NumLevelFiles(level); + if (stats_[level].micros > 0 || files > 0) { + snprintf( + buf, sizeof(buf), + "%3d %8d %8.0f %9.0f %8.0f %9.0f\n", + level, + files, + versions_->NumLevelBytes(level) / 1048576.0, + stats_[level].micros / 1e6, + stats_[level].bytes_read / 1048576.0, + stats_[level].bytes_written / 1048576.0); + value->append(buf); + } + } + return true; + } else if (in == "sstables") { + *value = versions_->current()->DebugString(); + return true; + } + + return false; +} + +void DBImpl::GetApproximateSizes( + const Range* range, int n, + uint64_t* sizes) { + // TODO(opt): better implementation + Version* v; + { + MutexLock l(&mutex_); + versions_->current()->Ref(); + v = versions_->current(); + } + + for (int i = 0; i < n; i++) { + // Convert user_key into a corresponding internal key. + InternalKey k1(range[i].start, kMaxSequenceNumber, kValueTypeForSeek); + InternalKey k2(range[i].limit, kMaxSequenceNumber, kValueTypeForSeek); + uint64_t start = versions_->ApproximateOffsetOf(v, k1); + uint64_t limit = versions_->ApproximateOffsetOf(v, k2); + sizes[i] = (limit >= start ? limit - start : 0); + } + + { + MutexLock l(&mutex_); + v->Unref(); + } +} + +// Default implementations of convenience methods that subclasses of DB +// can call if they wish +Status DB::Put(const WriteOptions& opt, const Slice& key, const Slice& value) { + WriteBatch batch; + batch.Put(key, value); + return Write(opt, &batch); +} + +Status DB::Delete(const WriteOptions& opt, const Slice& key) { + WriteBatch batch; + batch.Delete(key); + return Write(opt, &batch); +} + +DB::~DB() { } + +Status DB::Open(const Options& options, const std::string& dbname, + DB** dbptr) { + *dbptr = NULL; + + DBImpl* impl = new DBImpl(options, dbname); + impl->mutex_.Lock(); + VersionEdit edit; + Status s = impl->Recover(&edit); // Handles create_if_missing, error_if_exists + if (s.ok()) { + uint64_t new_log_number = impl->versions_->NewFileNumber(); + WritableFile* lfile; + s = options.env->NewWritableFile(LogFileName(dbname, new_log_number), + &lfile); + if (s.ok()) { + edit.SetLogNumber(new_log_number); + impl->logfile_ = lfile; + impl->logfile_number_ = new_log_number; + impl->log_ = new log::Writer(lfile); + s = impl->versions_->LogAndApply(&edit, &impl->mutex_); + } + if (s.ok()) { + impl->DeleteObsoleteFiles(); + impl->MaybeScheduleCompaction(); + } + } + impl->mutex_.Unlock(); + if (s.ok()) { + *dbptr = impl; + } else { + delete impl; + } + return s; +} + +Snapshot::~Snapshot() { +} + +Status DestroyDB(const std::string& dbname, const Options& options) { + Env* env = options.env; + std::vector filenames; + // Ignore error in case directory does not exist + env->GetChildren(dbname, &filenames); + if (filenames.empty()) { + return Status::OK(); + } + + FileLock* lock; + const std::string lockname = LockFileName(dbname); + Status result = env->LockFile(lockname, &lock); + if (result.ok()) { + uint64_t number; + FileType type; + for (size_t i = 0; i < filenames.size(); i++) { + if (ParseFileName(filenames[i], &number, &type) && + type != kDBLockFile) { // Lock file will be deleted at end + Status del = env->DeleteFile(dbname + "/" + filenames[i]); + if (result.ok() && !del.ok()) { + result = del; + } + } + } + env->UnlockFile(lock); // Ignore error since state is already gone + env->DeleteFile(lockname); + env->DeleteDir(dbname); // Ignore error in case dir contains other files + } + return result; +} + +} // namespace leveldb diff --git a/src/leveldb/db/db_impl.h b/src/leveldb/db/db_impl.h new file mode 100644 index 0000000..cfc9981 --- /dev/null +++ b/src/leveldb/db/db_impl.h @@ -0,0 +1,211 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_DB_DB_IMPL_H_ +#define STORAGE_LEVELDB_DB_DB_IMPL_H_ + +#include +#include +#include "db/dbformat.h" +#include "db/log_writer.h" +#include "db/snapshot.h" +#include "leveldb/db.h" +#include "leveldb/env.h" +#include "port/port.h" +#include "port/thread_annotations.h" + +namespace leveldb { + +class MemTable; +class TableCache; +class Version; +class VersionEdit; +class VersionSet; + +class DBImpl : public DB { + public: + DBImpl(const Options& options, const std::string& dbname); + virtual ~DBImpl(); + + // Implementations of the DB interface + virtual Status Put(const WriteOptions&, const Slice& key, const Slice& value); + virtual Status Delete(const WriteOptions&, const Slice& key); + virtual Status Write(const WriteOptions& options, WriteBatch* updates); + virtual Status Get(const ReadOptions& options, + const Slice& key, + std::string* value); + virtual Iterator* NewIterator(const ReadOptions&); + virtual const Snapshot* GetSnapshot(); + virtual void ReleaseSnapshot(const Snapshot* snapshot); + virtual bool GetProperty(const Slice& property, std::string* value); + virtual void GetApproximateSizes(const Range* range, int n, uint64_t* sizes); + virtual void CompactRange(const Slice* begin, const Slice* end); + + // Extra methods (for testing) that are not in the public DB interface + + // Compact any files in the named level that overlap [*begin,*end] + void TEST_CompactRange(int level, const Slice* begin, const Slice* end); + + // Force current memtable contents to be compacted. + Status TEST_CompactMemTable(); + + // Return an internal iterator over the current state of the database. + // The keys of this iterator are internal keys (see format.h). + // The returned iterator should be deleted when no longer needed. + Iterator* TEST_NewInternalIterator(); + + // Return the maximum overlapping data (in bytes) at next level for any + // file at a level >= 1. + int64_t TEST_MaxNextLevelOverlappingBytes(); + + // Record a sample of bytes read at the specified internal key. + // Samples are taken approximately once every config::kReadBytesPeriod + // bytes. + void RecordReadSample(Slice key); + + private: + friend class DB; + struct CompactionState; + struct Writer; + + Iterator* NewInternalIterator(const ReadOptions&, + SequenceNumber* latest_snapshot, + uint32_t* seed); + + Status NewDB(); + + // Recover the descriptor from persistent storage. May do a significant + // amount of work to recover recently logged updates. Any changes to + // be made to the descriptor are added to *edit. + Status Recover(VersionEdit* edit) EXCLUSIVE_LOCKS_REQUIRED(mutex_); + + void MaybeIgnoreError(Status* s) const; + + // Delete any unneeded files and stale in-memory entries. + void DeleteObsoleteFiles(); + + // Compact the in-memory write buffer to disk. Switches to a new + // log-file/memtable and writes a new descriptor iff successful. + // Errors are recorded in bg_error_. + void CompactMemTable() EXCLUSIVE_LOCKS_REQUIRED(mutex_); + + Status RecoverLogFile(uint64_t log_number, + VersionEdit* edit, + SequenceNumber* max_sequence) + EXCLUSIVE_LOCKS_REQUIRED(mutex_); + + Status WriteLevel0Table(MemTable* mem, VersionEdit* edit, Version* base) + EXCLUSIVE_LOCKS_REQUIRED(mutex_); + + Status MakeRoomForWrite(bool force /* compact even if there is room? */) + EXCLUSIVE_LOCKS_REQUIRED(mutex_); + WriteBatch* BuildBatchGroup(Writer** last_writer); + + void RecordBackgroundError(const Status& s); + + void MaybeScheduleCompaction() EXCLUSIVE_LOCKS_REQUIRED(mutex_); + static void BGWork(void* db); + void BackgroundCall(); + void BackgroundCompaction() EXCLUSIVE_LOCKS_REQUIRED(mutex_); + void CleanupCompaction(CompactionState* compact) + EXCLUSIVE_LOCKS_REQUIRED(mutex_); + Status DoCompactionWork(CompactionState* compact) + EXCLUSIVE_LOCKS_REQUIRED(mutex_); + + Status OpenCompactionOutputFile(CompactionState* compact); + Status FinishCompactionOutputFile(CompactionState* compact, Iterator* input); + Status InstallCompactionResults(CompactionState* compact) + EXCLUSIVE_LOCKS_REQUIRED(mutex_); + + // Constant after construction + Env* const env_; + const InternalKeyComparator internal_comparator_; + const InternalFilterPolicy internal_filter_policy_; + const Options options_; // options_.comparator == &internal_comparator_ + bool owns_info_log_; + bool owns_cache_; + const std::string dbname_; + + // table_cache_ provides its own synchronization + TableCache* table_cache_; + + // Lock over the persistent DB state. Non-NULL iff successfully acquired. + FileLock* db_lock_; + + // State below is protected by mutex_ + port::Mutex mutex_; + port::AtomicPointer shutting_down_; + port::CondVar bg_cv_; // Signalled when background work finishes + MemTable* mem_; + MemTable* imm_; // Memtable being compacted + port::AtomicPointer has_imm_; // So bg thread can detect non-NULL imm_ + WritableFile* logfile_; + uint64_t logfile_number_; + log::Writer* log_; + uint32_t seed_; // For sampling. + + // Queue of writers. + std::deque writers_; + WriteBatch* tmp_batch_; + + SnapshotList snapshots_; + + // Set of table files to protect from deletion because they are + // part of ongoing compactions. + std::set pending_outputs_; + + // Has a background compaction been scheduled or is running? + bool bg_compaction_scheduled_; + + // Information for a manual compaction + struct ManualCompaction { + int level; + bool done; + const InternalKey* begin; // NULL means beginning of key range + const InternalKey* end; // NULL means end of key range + InternalKey tmp_storage; // Used to keep track of compaction progress + }; + ManualCompaction* manual_compaction_; + + VersionSet* versions_; + + // Have we encountered a background error in paranoid mode? + Status bg_error_; + + // Per level compaction stats. stats_[level] stores the stats for + // compactions that produced data for the specified "level". + struct CompactionStats { + int64_t micros; + int64_t bytes_read; + int64_t bytes_written; + + CompactionStats() : micros(0), bytes_read(0), bytes_written(0) { } + + void Add(const CompactionStats& c) { + this->micros += c.micros; + this->bytes_read += c.bytes_read; + this->bytes_written += c.bytes_written; + } + }; + CompactionStats stats_[config::kNumLevels]; + + // No copying allowed + DBImpl(const DBImpl&); + void operator=(const DBImpl&); + + const Comparator* user_comparator() const { + return internal_comparator_.user_comparator(); + } +}; + +// Sanitize db options. The caller should delete result.info_log if +// it is not equal to src.info_log. +extern Options SanitizeOptions(const std::string& db, + const InternalKeyComparator* icmp, + const InternalFilterPolicy* ipolicy, + const Options& src); + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_DB_IMPL_H_ diff --git a/src/leveldb/db/db_iter.cc b/src/leveldb/db/db_iter.cc new file mode 100644 index 0000000..3b2035e --- /dev/null +++ b/src/leveldb/db/db_iter.cc @@ -0,0 +1,317 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/db_iter.h" + +#include "db/filename.h" +#include "db/db_impl.h" +#include "db/dbformat.h" +#include "leveldb/env.h" +#include "leveldb/iterator.h" +#include "port/port.h" +#include "util/logging.h" +#include "util/mutexlock.h" +#include "util/random.h" + +namespace leveldb { + +#if 0 +static void DumpInternalIter(Iterator* iter) { + for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { + ParsedInternalKey k; + if (!ParseInternalKey(iter->key(), &k)) { + fprintf(stderr, "Corrupt '%s'\n", EscapeString(iter->key()).c_str()); + } else { + fprintf(stderr, "@ '%s'\n", k.DebugString().c_str()); + } + } +} +#endif + +namespace { + +// Memtables and sstables that make the DB representation contain +// (userkey,seq,type) => uservalue entries. DBIter +// combines multiple entries for the same userkey found in the DB +// representation into a single entry while accounting for sequence +// numbers, deletion markers, overwrites, etc. +class DBIter: public Iterator { + public: + // Which direction is the iterator currently moving? + // (1) When moving forward, the internal iterator is positioned at + // the exact entry that yields this->key(), this->value() + // (2) When moving backwards, the internal iterator is positioned + // just before all entries whose user key == this->key(). + enum Direction { + kForward, + kReverse + }; + + DBIter(DBImpl* db, const Comparator* cmp, Iterator* iter, SequenceNumber s, + uint32_t seed) + : db_(db), + user_comparator_(cmp), + iter_(iter), + sequence_(s), + direction_(kForward), + valid_(false), + rnd_(seed), + bytes_counter_(RandomPeriod()) { + } + virtual ~DBIter() { + delete iter_; + } + virtual bool Valid() const { return valid_; } + virtual Slice key() const { + assert(valid_); + return (direction_ == kForward) ? ExtractUserKey(iter_->key()) : saved_key_; + } + virtual Slice value() const { + assert(valid_); + return (direction_ == kForward) ? iter_->value() : saved_value_; + } + virtual Status status() const { + if (status_.ok()) { + return iter_->status(); + } else { + return status_; + } + } + + virtual void Next(); + virtual void Prev(); + virtual void Seek(const Slice& target); + virtual void SeekToFirst(); + virtual void SeekToLast(); + + private: + void FindNextUserEntry(bool skipping, std::string* skip); + void FindPrevUserEntry(); + bool ParseKey(ParsedInternalKey* key); + + inline void SaveKey(const Slice& k, std::string* dst) { + dst->assign(k.data(), k.size()); + } + + inline void ClearSavedValue() { + if (saved_value_.capacity() > 1048576) { + std::string empty; + swap(empty, saved_value_); + } else { + saved_value_.clear(); + } + } + + // Pick next gap with average value of config::kReadBytesPeriod. + ssize_t RandomPeriod() { + return rnd_.Uniform(2*config::kReadBytesPeriod); + } + + DBImpl* db_; + const Comparator* const user_comparator_; + Iterator* const iter_; + SequenceNumber const sequence_; + + Status status_; + std::string saved_key_; // == current key when direction_==kReverse + std::string saved_value_; // == current raw value when direction_==kReverse + Direction direction_; + bool valid_; + + Random rnd_; + ssize_t bytes_counter_; + + // No copying allowed + DBIter(const DBIter&); + void operator=(const DBIter&); +}; + +inline bool DBIter::ParseKey(ParsedInternalKey* ikey) { + Slice k = iter_->key(); + ssize_t n = k.size() + iter_->value().size(); + bytes_counter_ -= n; + while (bytes_counter_ < 0) { + bytes_counter_ += RandomPeriod(); + db_->RecordReadSample(k); + } + if (!ParseInternalKey(k, ikey)) { + status_ = Status::Corruption("corrupted internal key in DBIter"); + return false; + } else { + return true; + } +} + +void DBIter::Next() { + assert(valid_); + + if (direction_ == kReverse) { // Switch directions? + direction_ = kForward; + // iter_ is pointing just before the entries for this->key(), + // so advance into the range of entries for this->key() and then + // use the normal skipping code below. + if (!iter_->Valid()) { + iter_->SeekToFirst(); + } else { + iter_->Next(); + } + if (!iter_->Valid()) { + valid_ = false; + saved_key_.clear(); + return; + } + // saved_key_ already contains the key to skip past. + } else { + // Store in saved_key_ the current key so we skip it below. + SaveKey(ExtractUserKey(iter_->key()), &saved_key_); + } + + FindNextUserEntry(true, &saved_key_); +} + +void DBIter::FindNextUserEntry(bool skipping, std::string* skip) { + // Loop until we hit an acceptable entry to yield + assert(iter_->Valid()); + assert(direction_ == kForward); + do { + ParsedInternalKey ikey; + if (ParseKey(&ikey) && ikey.sequence <= sequence_) { + switch (ikey.type) { + case kTypeDeletion: + // Arrange to skip all upcoming entries for this key since + // they are hidden by this deletion. + SaveKey(ikey.user_key, skip); + skipping = true; + break; + case kTypeValue: + if (skipping && + user_comparator_->Compare(ikey.user_key, *skip) <= 0) { + // Entry hidden + } else { + valid_ = true; + saved_key_.clear(); + return; + } + break; + } + } + iter_->Next(); + } while (iter_->Valid()); + saved_key_.clear(); + valid_ = false; +} + +void DBIter::Prev() { + assert(valid_); + + if (direction_ == kForward) { // Switch directions? + // iter_ is pointing at the current entry. Scan backwards until + // the key changes so we can use the normal reverse scanning code. + assert(iter_->Valid()); // Otherwise valid_ would have been false + SaveKey(ExtractUserKey(iter_->key()), &saved_key_); + while (true) { + iter_->Prev(); + if (!iter_->Valid()) { + valid_ = false; + saved_key_.clear(); + ClearSavedValue(); + return; + } + if (user_comparator_->Compare(ExtractUserKey(iter_->key()), + saved_key_) < 0) { + break; + } + } + direction_ = kReverse; + } + + FindPrevUserEntry(); +} + +void DBIter::FindPrevUserEntry() { + assert(direction_ == kReverse); + + ValueType value_type = kTypeDeletion; + if (iter_->Valid()) { + do { + ParsedInternalKey ikey; + if (ParseKey(&ikey) && ikey.sequence <= sequence_) { + if ((value_type != kTypeDeletion) && + user_comparator_->Compare(ikey.user_key, saved_key_) < 0) { + // We encountered a non-deleted value in entries for previous keys, + break; + } + value_type = ikey.type; + if (value_type == kTypeDeletion) { + saved_key_.clear(); + ClearSavedValue(); + } else { + Slice raw_value = iter_->value(); + if (saved_value_.capacity() > raw_value.size() + 1048576) { + std::string empty; + swap(empty, saved_value_); + } + SaveKey(ExtractUserKey(iter_->key()), &saved_key_); + saved_value_.assign(raw_value.data(), raw_value.size()); + } + } + iter_->Prev(); + } while (iter_->Valid()); + } + + if (value_type == kTypeDeletion) { + // End + valid_ = false; + saved_key_.clear(); + ClearSavedValue(); + direction_ = kForward; + } else { + valid_ = true; + } +} + +void DBIter::Seek(const Slice& target) { + direction_ = kForward; + ClearSavedValue(); + saved_key_.clear(); + AppendInternalKey( + &saved_key_, ParsedInternalKey(target, sequence_, kValueTypeForSeek)); + iter_->Seek(saved_key_); + if (iter_->Valid()) { + FindNextUserEntry(false, &saved_key_ /* temporary storage */); + } else { + valid_ = false; + } +} + +void DBIter::SeekToFirst() { + direction_ = kForward; + ClearSavedValue(); + iter_->SeekToFirst(); + if (iter_->Valid()) { + FindNextUserEntry(false, &saved_key_ /* temporary storage */); + } else { + valid_ = false; + } +} + +void DBIter::SeekToLast() { + direction_ = kReverse; + ClearSavedValue(); + iter_->SeekToLast(); + FindPrevUserEntry(); +} + +} // anonymous namespace + +Iterator* NewDBIterator( + DBImpl* db, + const Comparator* user_key_comparator, + Iterator* internal_iter, + SequenceNumber sequence, + uint32_t seed) { + return new DBIter(db, user_key_comparator, internal_iter, sequence, seed); +} + +} // namespace leveldb diff --git a/src/leveldb/db/db_iter.h b/src/leveldb/db/db_iter.h new file mode 100644 index 0000000..04927e9 --- /dev/null +++ b/src/leveldb/db/db_iter.h @@ -0,0 +1,28 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_DB_DB_ITER_H_ +#define STORAGE_LEVELDB_DB_DB_ITER_H_ + +#include +#include "leveldb/db.h" +#include "db/dbformat.h" + +namespace leveldb { + +class DBImpl; + +// Return a new iterator that converts internal keys (yielded by +// "*internal_iter") that were live at the specified "sequence" number +// into appropriate user keys. +extern Iterator* NewDBIterator( + DBImpl* db, + const Comparator* user_key_comparator, + Iterator* internal_iter, + SequenceNumber sequence, + uint32_t seed); + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_DB_ITER_H_ diff --git a/src/leveldb/db/db_test.cc b/src/leveldb/db/db_test.cc new file mode 100644 index 0000000..280b01c --- /dev/null +++ b/src/leveldb/db/db_test.cc @@ -0,0 +1,2128 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/db.h" +#include "leveldb/filter_policy.h" +#include "db/db_impl.h" +#include "db/filename.h" +#include "db/version_set.h" +#include "db/write_batch_internal.h" +#include "leveldb/cache.h" +#include "leveldb/env.h" +#include "leveldb/table.h" +#include "util/hash.h" +#include "util/logging.h" +#include "util/mutexlock.h" +#include "util/testharness.h" +#include "util/testutil.h" + +namespace leveldb { + +static std::string RandomString(Random* rnd, int len) { + std::string r; + test::RandomString(rnd, len, &r); + return r; +} + +namespace { +class AtomicCounter { + private: + port::Mutex mu_; + int count_; + public: + AtomicCounter() : count_(0) { } + void Increment() { + IncrementBy(1); + } + void IncrementBy(int count) { + MutexLock l(&mu_); + count_ += count; + } + int Read() { + MutexLock l(&mu_); + return count_; + } + void Reset() { + MutexLock l(&mu_); + count_ = 0; + } +}; + +void DelayMilliseconds(int millis) { + Env::Default()->SleepForMicroseconds(millis * 1000); +} +} + +// Special Env used to delay background operations +class SpecialEnv : public EnvWrapper { + public: + // sstable/log Sync() calls are blocked while this pointer is non-NULL. + port::AtomicPointer delay_data_sync_; + + // sstable/log Sync() calls return an error. + port::AtomicPointer data_sync_error_; + + // Simulate no-space errors while this pointer is non-NULL. + port::AtomicPointer no_space_; + + // Simulate non-writable file system while this pointer is non-NULL + port::AtomicPointer non_writable_; + + // Force sync of manifest files to fail while this pointer is non-NULL + port::AtomicPointer manifest_sync_error_; + + // Force write to manifest files to fail while this pointer is non-NULL + port::AtomicPointer manifest_write_error_; + + bool count_random_reads_; + AtomicCounter random_read_counter_; + + explicit SpecialEnv(Env* base) : EnvWrapper(base) { + delay_data_sync_.Release_Store(NULL); + data_sync_error_.Release_Store(NULL); + no_space_.Release_Store(NULL); + non_writable_.Release_Store(NULL); + count_random_reads_ = false; + manifest_sync_error_.Release_Store(NULL); + manifest_write_error_.Release_Store(NULL); + } + + Status NewWritableFile(const std::string& f, WritableFile** r) { + class DataFile : public WritableFile { + private: + SpecialEnv* env_; + WritableFile* base_; + + public: + DataFile(SpecialEnv* env, WritableFile* base) + : env_(env), + base_(base) { + } + ~DataFile() { delete base_; } + Status Append(const Slice& data) { + if (env_->no_space_.Acquire_Load() != NULL) { + // Drop writes on the floor + return Status::OK(); + } else { + return base_->Append(data); + } + } + Status Close() { return base_->Close(); } + Status Flush() { return base_->Flush(); } + Status Sync() { + if (env_->data_sync_error_.Acquire_Load() != NULL) { + return Status::IOError("simulated data sync error"); + } + while (env_->delay_data_sync_.Acquire_Load() != NULL) { + DelayMilliseconds(100); + } + return base_->Sync(); + } + }; + class ManifestFile : public WritableFile { + private: + SpecialEnv* env_; + WritableFile* base_; + public: + ManifestFile(SpecialEnv* env, WritableFile* b) : env_(env), base_(b) { } + ~ManifestFile() { delete base_; } + Status Append(const Slice& data) { + if (env_->manifest_write_error_.Acquire_Load() != NULL) { + return Status::IOError("simulated writer error"); + } else { + return base_->Append(data); + } + } + Status Close() { return base_->Close(); } + Status Flush() { return base_->Flush(); } + Status Sync() { + if (env_->manifest_sync_error_.Acquire_Load() != NULL) { + return Status::IOError("simulated sync error"); + } else { + return base_->Sync(); + } + } + }; + + if (non_writable_.Acquire_Load() != NULL) { + return Status::IOError("simulated write error"); + } + + Status s = target()->NewWritableFile(f, r); + if (s.ok()) { + if (strstr(f.c_str(), ".ldb") != NULL || + strstr(f.c_str(), ".log") != NULL) { + *r = new DataFile(this, *r); + } else if (strstr(f.c_str(), "MANIFEST") != NULL) { + *r = new ManifestFile(this, *r); + } + } + return s; + } + + Status NewRandomAccessFile(const std::string& f, RandomAccessFile** r) { + class CountingFile : public RandomAccessFile { + private: + RandomAccessFile* target_; + AtomicCounter* counter_; + public: + CountingFile(RandomAccessFile* target, AtomicCounter* counter) + : target_(target), counter_(counter) { + } + virtual ~CountingFile() { delete target_; } + virtual Status Read(uint64_t offset, size_t n, Slice* result, + char* scratch) const { + counter_->Increment(); + return target_->Read(offset, n, result, scratch); + } + }; + + Status s = target()->NewRandomAccessFile(f, r); + if (s.ok() && count_random_reads_) { + *r = new CountingFile(*r, &random_read_counter_); + } + return s; + } +}; + +class DBTest { + private: + const FilterPolicy* filter_policy_; + + // Sequence of option configurations to try + enum OptionConfig { + kDefault, + kFilter, + kUncompressed, + kEnd + }; + int option_config_; + + public: + std::string dbname_; + SpecialEnv* env_; + DB* db_; + + Options last_options_; + + DBTest() : option_config_(kDefault), + env_(new SpecialEnv(Env::Default())) { + filter_policy_ = NewBloomFilterPolicy(10); + dbname_ = test::TmpDir() + "/db_test"; + DestroyDB(dbname_, Options()); + db_ = NULL; + Reopen(); + } + + ~DBTest() { + delete db_; + DestroyDB(dbname_, Options()); + delete env_; + delete filter_policy_; + } + + // Switch to a fresh database with the next option configuration to + // test. Return false if there are no more configurations to test. + bool ChangeOptions() { + option_config_++; + if (option_config_ >= kEnd) { + return false; + } else { + DestroyAndReopen(); + return true; + } + } + + // Return the current option configuration. + Options CurrentOptions() { + Options options; + switch (option_config_) { + case kFilter: + options.filter_policy = filter_policy_; + break; + case kUncompressed: + options.compression = kNoCompression; + break; + default: + break; + } + return options; + } + + DBImpl* dbfull() { + return reinterpret_cast(db_); + } + + void Reopen(Options* options = NULL) { + ASSERT_OK(TryReopen(options)); + } + + void Close() { + delete db_; + db_ = NULL; + } + + void DestroyAndReopen(Options* options = NULL) { + delete db_; + db_ = NULL; + DestroyDB(dbname_, Options()); + ASSERT_OK(TryReopen(options)); + } + + Status TryReopen(Options* options) { + delete db_; + db_ = NULL; + Options opts; + if (options != NULL) { + opts = *options; + } else { + opts = CurrentOptions(); + opts.create_if_missing = true; + } + last_options_ = opts; + + return DB::Open(opts, dbname_, &db_); + } + + Status Put(const std::string& k, const std::string& v) { + return db_->Put(WriteOptions(), k, v); + } + + Status Delete(const std::string& k) { + return db_->Delete(WriteOptions(), k); + } + + std::string Get(const std::string& k, const Snapshot* snapshot = NULL) { + ReadOptions options; + options.snapshot = snapshot; + std::string result; + Status s = db_->Get(options, k, &result); + if (s.IsNotFound()) { + result = "NOT_FOUND"; + } else if (!s.ok()) { + result = s.ToString(); + } + return result; + } + + // Return a string that contains all key,value pairs in order, + // formatted like "(k1->v1)(k2->v2)". + std::string Contents() { + std::vector forward; + std::string result; + Iterator* iter = db_->NewIterator(ReadOptions()); + for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { + std::string s = IterStatus(iter); + result.push_back('('); + result.append(s); + result.push_back(')'); + forward.push_back(s); + } + + // Check reverse iteration results are the reverse of forward results + size_t matched = 0; + for (iter->SeekToLast(); iter->Valid(); iter->Prev()) { + ASSERT_LT(matched, forward.size()); + ASSERT_EQ(IterStatus(iter), forward[forward.size() - matched - 1]); + matched++; + } + ASSERT_EQ(matched, forward.size()); + + delete iter; + return result; + } + + std::string AllEntriesFor(const Slice& user_key) { + Iterator* iter = dbfull()->TEST_NewInternalIterator(); + InternalKey target(user_key, kMaxSequenceNumber, kTypeValue); + iter->Seek(target.Encode()); + std::string result; + if (!iter->status().ok()) { + result = iter->status().ToString(); + } else { + result = "[ "; + bool first = true; + while (iter->Valid()) { + ParsedInternalKey ikey; + if (!ParseInternalKey(iter->key(), &ikey)) { + result += "CORRUPTED"; + } else { + if (last_options_.comparator->Compare(ikey.user_key, user_key) != 0) { + break; + } + if (!first) { + result += ", "; + } + first = false; + switch (ikey.type) { + case kTypeValue: + result += iter->value().ToString(); + break; + case kTypeDeletion: + result += "DEL"; + break; + } + } + iter->Next(); + } + if (!first) { + result += " "; + } + result += "]"; + } + delete iter; + return result; + } + + int NumTableFilesAtLevel(int level) { + std::string property; + ASSERT_TRUE( + db_->GetProperty("leveldb.num-files-at-level" + NumberToString(level), + &property)); + return atoi(property.c_str()); + } + + int TotalTableFiles() { + int result = 0; + for (int level = 0; level < config::kNumLevels; level++) { + result += NumTableFilesAtLevel(level); + } + return result; + } + + // Return spread of files per level + std::string FilesPerLevel() { + std::string result; + int last_non_zero_offset = 0; + for (int level = 0; level < config::kNumLevels; level++) { + int f = NumTableFilesAtLevel(level); + char buf[100]; + snprintf(buf, sizeof(buf), "%s%d", (level ? "," : ""), f); + result += buf; + if (f > 0) { + last_non_zero_offset = result.size(); + } + } + result.resize(last_non_zero_offset); + return result; + } + + int CountFiles() { + std::vector files; + env_->GetChildren(dbname_, &files); + return static_cast(files.size()); + } + + uint64_t Size(const Slice& start, const Slice& limit) { + Range r(start, limit); + uint64_t size; + db_->GetApproximateSizes(&r, 1, &size); + return size; + } + + void Compact(const Slice& start, const Slice& limit) { + db_->CompactRange(&start, &limit); + } + + // Do n memtable compactions, each of which produces an sstable + // covering the range [small,large]. + void MakeTables(int n, const std::string& small, const std::string& large) { + for (int i = 0; i < n; i++) { + Put(small, "begin"); + Put(large, "end"); + dbfull()->TEST_CompactMemTable(); + } + } + + // Prevent pushing of new sstables into deeper levels by adding + // tables that cover a specified range to all levels. + void FillLevels(const std::string& smallest, const std::string& largest) { + MakeTables(config::kNumLevels, smallest, largest); + } + + void DumpFileCounts(const char* label) { + fprintf(stderr, "---\n%s:\n", label); + fprintf(stderr, "maxoverlap: %lld\n", + static_cast( + dbfull()->TEST_MaxNextLevelOverlappingBytes())); + for (int level = 0; level < config::kNumLevels; level++) { + int num = NumTableFilesAtLevel(level); + if (num > 0) { + fprintf(stderr, " level %3d : %d files\n", level, num); + } + } + } + + std::string DumpSSTableList() { + std::string property; + db_->GetProperty("leveldb.sstables", &property); + return property; + } + + std::string IterStatus(Iterator* iter) { + std::string result; + if (iter->Valid()) { + result = iter->key().ToString() + "->" + iter->value().ToString(); + } else { + result = "(invalid)"; + } + return result; + } + + bool DeleteAnSSTFile() { + std::vector filenames; + ASSERT_OK(env_->GetChildren(dbname_, &filenames)); + uint64_t number; + FileType type; + for (size_t i = 0; i < filenames.size(); i++) { + if (ParseFileName(filenames[i], &number, &type) && type == kTableFile) { + ASSERT_OK(env_->DeleteFile(TableFileName(dbname_, number))); + return true; + } + } + return false; + } + + // Returns number of files renamed. + int RenameLDBToSST() { + std::vector filenames; + ASSERT_OK(env_->GetChildren(dbname_, &filenames)); + uint64_t number; + FileType type; + int files_renamed = 0; + for (size_t i = 0; i < filenames.size(); i++) { + if (ParseFileName(filenames[i], &number, &type) && type == kTableFile) { + const std::string from = TableFileName(dbname_, number); + const std::string to = SSTTableFileName(dbname_, number); + ASSERT_OK(env_->RenameFile(from, to)); + files_renamed++; + } + } + return files_renamed; + } +}; + +TEST(DBTest, Empty) { + do { + ASSERT_TRUE(db_ != NULL); + ASSERT_EQ("NOT_FOUND", Get("foo")); + } while (ChangeOptions()); +} + +TEST(DBTest, ReadWrite) { + do { + ASSERT_OK(Put("foo", "v1")); + ASSERT_EQ("v1", Get("foo")); + ASSERT_OK(Put("bar", "v2")); + ASSERT_OK(Put("foo", "v3")); + ASSERT_EQ("v3", Get("foo")); + ASSERT_EQ("v2", Get("bar")); + } while (ChangeOptions()); +} + +TEST(DBTest, PutDeleteGet) { + do { + ASSERT_OK(db_->Put(WriteOptions(), "foo", "v1")); + ASSERT_EQ("v1", Get("foo")); + ASSERT_OK(db_->Put(WriteOptions(), "foo", "v2")); + ASSERT_EQ("v2", Get("foo")); + ASSERT_OK(db_->Delete(WriteOptions(), "foo")); + ASSERT_EQ("NOT_FOUND", Get("foo")); + } while (ChangeOptions()); +} + +TEST(DBTest, GetFromImmutableLayer) { + do { + Options options = CurrentOptions(); + options.env = env_; + options.write_buffer_size = 100000; // Small write buffer + Reopen(&options); + + ASSERT_OK(Put("foo", "v1")); + ASSERT_EQ("v1", Get("foo")); + + env_->delay_data_sync_.Release_Store(env_); // Block sync calls + Put("k1", std::string(100000, 'x')); // Fill memtable + Put("k2", std::string(100000, 'y')); // Trigger compaction + ASSERT_EQ("v1", Get("foo")); + env_->delay_data_sync_.Release_Store(NULL); // Release sync calls + } while (ChangeOptions()); +} + +TEST(DBTest, GetFromVersions) { + do { + ASSERT_OK(Put("foo", "v1")); + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ("v1", Get("foo")); + } while (ChangeOptions()); +} + +TEST(DBTest, GetSnapshot) { + do { + // Try with both a short key and a long key + for (int i = 0; i < 2; i++) { + std::string key = (i == 0) ? std::string("foo") : std::string(200, 'x'); + ASSERT_OK(Put(key, "v1")); + const Snapshot* s1 = db_->GetSnapshot(); + ASSERT_OK(Put(key, "v2")); + ASSERT_EQ("v2", Get(key)); + ASSERT_EQ("v1", Get(key, s1)); + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ("v2", Get(key)); + ASSERT_EQ("v1", Get(key, s1)); + db_->ReleaseSnapshot(s1); + } + } while (ChangeOptions()); +} + +TEST(DBTest, GetLevel0Ordering) { + do { + // Check that we process level-0 files in correct order. The code + // below generates two level-0 files where the earlier one comes + // before the later one in the level-0 file list since the earlier + // one has a smaller "smallest" key. + ASSERT_OK(Put("bar", "b")); + ASSERT_OK(Put("foo", "v1")); + dbfull()->TEST_CompactMemTable(); + ASSERT_OK(Put("foo", "v2")); + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ("v2", Get("foo")); + } while (ChangeOptions()); +} + +TEST(DBTest, GetOrderedByLevels) { + do { + ASSERT_OK(Put("foo", "v1")); + Compact("a", "z"); + ASSERT_EQ("v1", Get("foo")); + ASSERT_OK(Put("foo", "v2")); + ASSERT_EQ("v2", Get("foo")); + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ("v2", Get("foo")); + } while (ChangeOptions()); +} + +TEST(DBTest, GetPicksCorrectFile) { + do { + // Arrange to have multiple files in a non-level-0 level. + ASSERT_OK(Put("a", "va")); + Compact("a", "b"); + ASSERT_OK(Put("x", "vx")); + Compact("x", "y"); + ASSERT_OK(Put("f", "vf")); + Compact("f", "g"); + ASSERT_EQ("va", Get("a")); + ASSERT_EQ("vf", Get("f")); + ASSERT_EQ("vx", Get("x")); + } while (ChangeOptions()); +} + +TEST(DBTest, GetEncountersEmptyLevel) { + do { + // Arrange for the following to happen: + // * sstable A in level 0 + // * nothing in level 1 + // * sstable B in level 2 + // Then do enough Get() calls to arrange for an automatic compaction + // of sstable A. A bug would cause the compaction to be marked as + // occuring at level 1 (instead of the correct level 0). + + // Step 1: First place sstables in levels 0 and 2 + int compaction_count = 0; + while (NumTableFilesAtLevel(0) == 0 || + NumTableFilesAtLevel(2) == 0) { + ASSERT_LE(compaction_count, 100) << "could not fill levels 0 and 2"; + compaction_count++; + Put("a", "begin"); + Put("z", "end"); + dbfull()->TEST_CompactMemTable(); + } + + // Step 2: clear level 1 if necessary. + dbfull()->TEST_CompactRange(1, NULL, NULL); + ASSERT_EQ(NumTableFilesAtLevel(0), 1); + ASSERT_EQ(NumTableFilesAtLevel(1), 0); + ASSERT_EQ(NumTableFilesAtLevel(2), 1); + + // Step 3: read a bunch of times + for (int i = 0; i < 1000; i++) { + ASSERT_EQ("NOT_FOUND", Get("missing")); + } + + // Step 4: Wait for compaction to finish + DelayMilliseconds(1000); + + ASSERT_EQ(NumTableFilesAtLevel(0), 0); + } while (ChangeOptions()); +} + +TEST(DBTest, IterEmpty) { + Iterator* iter = db_->NewIterator(ReadOptions()); + + iter->SeekToFirst(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + iter->SeekToLast(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + iter->Seek("foo"); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + delete iter; +} + +TEST(DBTest, IterSingle) { + ASSERT_OK(Put("a", "va")); + Iterator* iter = db_->NewIterator(ReadOptions()); + + iter->SeekToFirst(); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + iter->SeekToFirst(); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + iter->SeekToLast(); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + iter->SeekToLast(); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + iter->Seek(""); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + iter->Seek("a"); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + iter->Seek("b"); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + delete iter; +} + +TEST(DBTest, IterMulti) { + ASSERT_OK(Put("a", "va")); + ASSERT_OK(Put("b", "vb")); + ASSERT_OK(Put("c", "vc")); + Iterator* iter = db_->NewIterator(ReadOptions()); + + iter->SeekToFirst(); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "b->vb"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "c->vc"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + iter->SeekToFirst(); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + iter->SeekToLast(); + ASSERT_EQ(IterStatus(iter), "c->vc"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "b->vb"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + iter->SeekToLast(); + ASSERT_EQ(IterStatus(iter), "c->vc"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + iter->Seek(""); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Seek("a"); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Seek("ax"); + ASSERT_EQ(IterStatus(iter), "b->vb"); + iter->Seek("b"); + ASSERT_EQ(IterStatus(iter), "b->vb"); + iter->Seek("z"); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + // Switch from reverse to forward + iter->SeekToLast(); + iter->Prev(); + iter->Prev(); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "b->vb"); + + // Switch from forward to reverse + iter->SeekToFirst(); + iter->Next(); + iter->Next(); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "b->vb"); + + // Make sure iter stays at snapshot + ASSERT_OK(Put("a", "va2")); + ASSERT_OK(Put("a2", "va3")); + ASSERT_OK(Put("b", "vb2")); + ASSERT_OK(Put("c", "vc2")); + ASSERT_OK(Delete("b")); + iter->SeekToFirst(); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "b->vb"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "c->vc"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + iter->SeekToLast(); + ASSERT_EQ(IterStatus(iter), "c->vc"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "b->vb"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + delete iter; +} + +TEST(DBTest, IterSmallAndLargeMix) { + ASSERT_OK(Put("a", "va")); + ASSERT_OK(Put("b", std::string(100000, 'b'))); + ASSERT_OK(Put("c", "vc")); + ASSERT_OK(Put("d", std::string(100000, 'd'))); + ASSERT_OK(Put("e", std::string(100000, 'e'))); + + Iterator* iter = db_->NewIterator(ReadOptions()); + + iter->SeekToFirst(); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "b->" + std::string(100000, 'b')); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "c->vc"); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "d->" + std::string(100000, 'd')); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "e->" + std::string(100000, 'e')); + iter->Next(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + iter->SeekToLast(); + ASSERT_EQ(IterStatus(iter), "e->" + std::string(100000, 'e')); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "d->" + std::string(100000, 'd')); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "c->vc"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "b->" + std::string(100000, 'b')); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "a->va"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "(invalid)"); + + delete iter; +} + +TEST(DBTest, IterMultiWithDelete) { + do { + ASSERT_OK(Put("a", "va")); + ASSERT_OK(Put("b", "vb")); + ASSERT_OK(Put("c", "vc")); + ASSERT_OK(Delete("b")); + ASSERT_EQ("NOT_FOUND", Get("b")); + + Iterator* iter = db_->NewIterator(ReadOptions()); + iter->Seek("c"); + ASSERT_EQ(IterStatus(iter), "c->vc"); + iter->Prev(); + ASSERT_EQ(IterStatus(iter), "a->va"); + delete iter; + } while (ChangeOptions()); +} + +TEST(DBTest, Recover) { + do { + ASSERT_OK(Put("foo", "v1")); + ASSERT_OK(Put("baz", "v5")); + + Reopen(); + ASSERT_EQ("v1", Get("foo")); + + ASSERT_EQ("v1", Get("foo")); + ASSERT_EQ("v5", Get("baz")); + ASSERT_OK(Put("bar", "v2")); + ASSERT_OK(Put("foo", "v3")); + + Reopen(); + ASSERT_EQ("v3", Get("foo")); + ASSERT_OK(Put("foo", "v4")); + ASSERT_EQ("v4", Get("foo")); + ASSERT_EQ("v2", Get("bar")); + ASSERT_EQ("v5", Get("baz")); + } while (ChangeOptions()); +} + +TEST(DBTest, RecoveryWithEmptyLog) { + do { + ASSERT_OK(Put("foo", "v1")); + ASSERT_OK(Put("foo", "v2")); + Reopen(); + Reopen(); + ASSERT_OK(Put("foo", "v3")); + Reopen(); + ASSERT_EQ("v3", Get("foo")); + } while (ChangeOptions()); +} + +// Check that writes done during a memtable compaction are recovered +// if the database is shutdown during the memtable compaction. +TEST(DBTest, RecoverDuringMemtableCompaction) { + do { + Options options = CurrentOptions(); + options.env = env_; + options.write_buffer_size = 1000000; + Reopen(&options); + + // Trigger a long memtable compaction and reopen the database during it + ASSERT_OK(Put("foo", "v1")); // Goes to 1st log file + ASSERT_OK(Put("big1", std::string(10000000, 'x'))); // Fills memtable + ASSERT_OK(Put("big2", std::string(1000, 'y'))); // Triggers compaction + ASSERT_OK(Put("bar", "v2")); // Goes to new log file + + Reopen(&options); + ASSERT_EQ("v1", Get("foo")); + ASSERT_EQ("v2", Get("bar")); + ASSERT_EQ(std::string(10000000, 'x'), Get("big1")); + ASSERT_EQ(std::string(1000, 'y'), Get("big2")); + } while (ChangeOptions()); +} + +static std::string Key(int i) { + char buf[100]; + snprintf(buf, sizeof(buf), "key%06d", i); + return std::string(buf); +} + +TEST(DBTest, MinorCompactionsHappen) { + Options options = CurrentOptions(); + options.write_buffer_size = 10000; + Reopen(&options); + + const int N = 500; + + int starting_num_tables = TotalTableFiles(); + for (int i = 0; i < N; i++) { + ASSERT_OK(Put(Key(i), Key(i) + std::string(1000, 'v'))); + } + int ending_num_tables = TotalTableFiles(); + ASSERT_GT(ending_num_tables, starting_num_tables); + + for (int i = 0; i < N; i++) { + ASSERT_EQ(Key(i) + std::string(1000, 'v'), Get(Key(i))); + } + + Reopen(); + + for (int i = 0; i < N; i++) { + ASSERT_EQ(Key(i) + std::string(1000, 'v'), Get(Key(i))); + } +} + +TEST(DBTest, RecoverWithLargeLog) { + { + Options options = CurrentOptions(); + Reopen(&options); + ASSERT_OK(Put("big1", std::string(200000, '1'))); + ASSERT_OK(Put("big2", std::string(200000, '2'))); + ASSERT_OK(Put("small3", std::string(10, '3'))); + ASSERT_OK(Put("small4", std::string(10, '4'))); + ASSERT_EQ(NumTableFilesAtLevel(0), 0); + } + + // Make sure that if we re-open with a small write buffer size that + // we flush table files in the middle of a large log file. + Options options = CurrentOptions(); + options.write_buffer_size = 100000; + Reopen(&options); + ASSERT_EQ(NumTableFilesAtLevel(0), 3); + ASSERT_EQ(std::string(200000, '1'), Get("big1")); + ASSERT_EQ(std::string(200000, '2'), Get("big2")); + ASSERT_EQ(std::string(10, '3'), Get("small3")); + ASSERT_EQ(std::string(10, '4'), Get("small4")); + ASSERT_GT(NumTableFilesAtLevel(0), 1); +} + +TEST(DBTest, CompactionsGenerateMultipleFiles) { + Options options = CurrentOptions(); + options.write_buffer_size = 100000000; // Large write buffer + Reopen(&options); + + Random rnd(301); + + // Write 8MB (80 values, each 100K) + ASSERT_EQ(NumTableFilesAtLevel(0), 0); + std::vector values; + for (int i = 0; i < 80; i++) { + values.push_back(RandomString(&rnd, 100000)); + ASSERT_OK(Put(Key(i), values[i])); + } + + // Reopening moves updates to level-0 + Reopen(&options); + dbfull()->TEST_CompactRange(0, NULL, NULL); + + ASSERT_EQ(NumTableFilesAtLevel(0), 0); + ASSERT_GT(NumTableFilesAtLevel(1), 1); + for (int i = 0; i < 80; i++) { + ASSERT_EQ(Get(Key(i)), values[i]); + } +} + +TEST(DBTest, RepeatedWritesToSameKey) { + Options options = CurrentOptions(); + options.env = env_; + options.write_buffer_size = 100000; // Small write buffer + Reopen(&options); + + // We must have at most one file per level except for level-0, + // which may have up to kL0_StopWritesTrigger files. + const int kMaxFiles = config::kNumLevels + config::kL0_StopWritesTrigger; + + Random rnd(301); + std::string value = RandomString(&rnd, 2 * options.write_buffer_size); + for (int i = 0; i < 5 * kMaxFiles; i++) { + Put("key", value); + ASSERT_LE(TotalTableFiles(), kMaxFiles); + fprintf(stderr, "after %d: %d files\n", int(i+1), TotalTableFiles()); + } +} + +TEST(DBTest, SparseMerge) { + Options options = CurrentOptions(); + options.compression = kNoCompression; + Reopen(&options); + + FillLevels("A", "Z"); + + // Suppose there is: + // small amount of data with prefix A + // large amount of data with prefix B + // small amount of data with prefix C + // and that recent updates have made small changes to all three prefixes. + // Check that we do not do a compaction that merges all of B in one shot. + const std::string value(1000, 'x'); + Put("A", "va"); + // Write approximately 100MB of "B" values + for (int i = 0; i < 100000; i++) { + char key[100]; + snprintf(key, sizeof(key), "B%010d", i); + Put(key, value); + } + Put("C", "vc"); + dbfull()->TEST_CompactMemTable(); + dbfull()->TEST_CompactRange(0, NULL, NULL); + + // Make sparse update + Put("A", "va2"); + Put("B100", "bvalue2"); + Put("C", "vc2"); + dbfull()->TEST_CompactMemTable(); + + // Compactions should not cause us to create a situation where + // a file overlaps too much data at the next level. + ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20*1048576); + dbfull()->TEST_CompactRange(0, NULL, NULL); + ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20*1048576); + dbfull()->TEST_CompactRange(1, NULL, NULL); + ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20*1048576); +} + +static bool Between(uint64_t val, uint64_t low, uint64_t high) { + bool result = (val >= low) && (val <= high); + if (!result) { + fprintf(stderr, "Value %llu is not in range [%llu, %llu]\n", + (unsigned long long)(val), + (unsigned long long)(low), + (unsigned long long)(high)); + } + return result; +} + +TEST(DBTest, ApproximateSizes) { + do { + Options options = CurrentOptions(); + options.write_buffer_size = 100000000; // Large write buffer + options.compression = kNoCompression; + DestroyAndReopen(); + + ASSERT_TRUE(Between(Size("", "xyz"), 0, 0)); + Reopen(&options); + ASSERT_TRUE(Between(Size("", "xyz"), 0, 0)); + + // Write 8MB (80 values, each 100K) + ASSERT_EQ(NumTableFilesAtLevel(0), 0); + const int N = 80; + static const int S1 = 100000; + static const int S2 = 105000; // Allow some expansion from metadata + Random rnd(301); + for (int i = 0; i < N; i++) { + ASSERT_OK(Put(Key(i), RandomString(&rnd, S1))); + } + + // 0 because GetApproximateSizes() does not account for memtable space + ASSERT_TRUE(Between(Size("", Key(50)), 0, 0)); + + // Check sizes across recovery by reopening a few times + for (int run = 0; run < 3; run++) { + Reopen(&options); + + for (int compact_start = 0; compact_start < N; compact_start += 10) { + for (int i = 0; i < N; i += 10) { + ASSERT_TRUE(Between(Size("", Key(i)), S1*i, S2*i)); + ASSERT_TRUE(Between(Size("", Key(i)+".suffix"), S1*(i+1), S2*(i+1))); + ASSERT_TRUE(Between(Size(Key(i), Key(i+10)), S1*10, S2*10)); + } + ASSERT_TRUE(Between(Size("", Key(50)), S1*50, S2*50)); + ASSERT_TRUE(Between(Size("", Key(50)+".suffix"), S1*50, S2*50)); + + std::string cstart_str = Key(compact_start); + std::string cend_str = Key(compact_start + 9); + Slice cstart = cstart_str; + Slice cend = cend_str; + dbfull()->TEST_CompactRange(0, &cstart, &cend); + } + + ASSERT_EQ(NumTableFilesAtLevel(0), 0); + ASSERT_GT(NumTableFilesAtLevel(1), 0); + } + } while (ChangeOptions()); +} + +TEST(DBTest, ApproximateSizes_MixOfSmallAndLarge) { + do { + Options options = CurrentOptions(); + options.compression = kNoCompression; + Reopen(); + + Random rnd(301); + std::string big1 = RandomString(&rnd, 100000); + ASSERT_OK(Put(Key(0), RandomString(&rnd, 10000))); + ASSERT_OK(Put(Key(1), RandomString(&rnd, 10000))); + ASSERT_OK(Put(Key(2), big1)); + ASSERT_OK(Put(Key(3), RandomString(&rnd, 10000))); + ASSERT_OK(Put(Key(4), big1)); + ASSERT_OK(Put(Key(5), RandomString(&rnd, 10000))); + ASSERT_OK(Put(Key(6), RandomString(&rnd, 300000))); + ASSERT_OK(Put(Key(7), RandomString(&rnd, 10000))); + + // Check sizes across recovery by reopening a few times + for (int run = 0; run < 3; run++) { + Reopen(&options); + + ASSERT_TRUE(Between(Size("", Key(0)), 0, 0)); + ASSERT_TRUE(Between(Size("", Key(1)), 10000, 11000)); + ASSERT_TRUE(Between(Size("", Key(2)), 20000, 21000)); + ASSERT_TRUE(Between(Size("", Key(3)), 120000, 121000)); + ASSERT_TRUE(Between(Size("", Key(4)), 130000, 131000)); + ASSERT_TRUE(Between(Size("", Key(5)), 230000, 231000)); + ASSERT_TRUE(Between(Size("", Key(6)), 240000, 241000)); + ASSERT_TRUE(Between(Size("", Key(7)), 540000, 541000)); + ASSERT_TRUE(Between(Size("", Key(8)), 550000, 560000)); + + ASSERT_TRUE(Between(Size(Key(3), Key(5)), 110000, 111000)); + + dbfull()->TEST_CompactRange(0, NULL, NULL); + } + } while (ChangeOptions()); +} + +TEST(DBTest, IteratorPinsRef) { + Put("foo", "hello"); + + // Get iterator that will yield the current contents of the DB. + Iterator* iter = db_->NewIterator(ReadOptions()); + + // Write to force compactions + Put("foo", "newvalue1"); + for (int i = 0; i < 100; i++) { + ASSERT_OK(Put(Key(i), Key(i) + std::string(100000, 'v'))); // 100K values + } + Put("foo", "newvalue2"); + + iter->SeekToFirst(); + ASSERT_TRUE(iter->Valid()); + ASSERT_EQ("foo", iter->key().ToString()); + ASSERT_EQ("hello", iter->value().ToString()); + iter->Next(); + ASSERT_TRUE(!iter->Valid()); + delete iter; +} + +TEST(DBTest, Snapshot) { + do { + Put("foo", "v1"); + const Snapshot* s1 = db_->GetSnapshot(); + Put("foo", "v2"); + const Snapshot* s2 = db_->GetSnapshot(); + Put("foo", "v3"); + const Snapshot* s3 = db_->GetSnapshot(); + + Put("foo", "v4"); + ASSERT_EQ("v1", Get("foo", s1)); + ASSERT_EQ("v2", Get("foo", s2)); + ASSERT_EQ("v3", Get("foo", s3)); + ASSERT_EQ("v4", Get("foo")); + + db_->ReleaseSnapshot(s3); + ASSERT_EQ("v1", Get("foo", s1)); + ASSERT_EQ("v2", Get("foo", s2)); + ASSERT_EQ("v4", Get("foo")); + + db_->ReleaseSnapshot(s1); + ASSERT_EQ("v2", Get("foo", s2)); + ASSERT_EQ("v4", Get("foo")); + + db_->ReleaseSnapshot(s2); + ASSERT_EQ("v4", Get("foo")); + } while (ChangeOptions()); +} + +TEST(DBTest, HiddenValuesAreRemoved) { + do { + Random rnd(301); + FillLevels("a", "z"); + + std::string big = RandomString(&rnd, 50000); + Put("foo", big); + Put("pastfoo", "v"); + const Snapshot* snapshot = db_->GetSnapshot(); + Put("foo", "tiny"); + Put("pastfoo2", "v2"); // Advance sequence number one more + + ASSERT_OK(dbfull()->TEST_CompactMemTable()); + ASSERT_GT(NumTableFilesAtLevel(0), 0); + + ASSERT_EQ(big, Get("foo", snapshot)); + ASSERT_TRUE(Between(Size("", "pastfoo"), 50000, 60000)); + db_->ReleaseSnapshot(snapshot); + ASSERT_EQ(AllEntriesFor("foo"), "[ tiny, " + big + " ]"); + Slice x("x"); + dbfull()->TEST_CompactRange(0, NULL, &x); + ASSERT_EQ(AllEntriesFor("foo"), "[ tiny ]"); + ASSERT_EQ(NumTableFilesAtLevel(0), 0); + ASSERT_GE(NumTableFilesAtLevel(1), 1); + dbfull()->TEST_CompactRange(1, NULL, &x); + ASSERT_EQ(AllEntriesFor("foo"), "[ tiny ]"); + + ASSERT_TRUE(Between(Size("", "pastfoo"), 0, 1000)); + } while (ChangeOptions()); +} + +TEST(DBTest, DeletionMarkers1) { + Put("foo", "v1"); + ASSERT_OK(dbfull()->TEST_CompactMemTable()); + const int last = config::kMaxMemCompactLevel; + ASSERT_EQ(NumTableFilesAtLevel(last), 1); // foo => v1 is now in last level + + // Place a table at level last-1 to prevent merging with preceding mutation + Put("a", "begin"); + Put("z", "end"); + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ(NumTableFilesAtLevel(last), 1); + ASSERT_EQ(NumTableFilesAtLevel(last-1), 1); + + Delete("foo"); + Put("foo", "v2"); + ASSERT_EQ(AllEntriesFor("foo"), "[ v2, DEL, v1 ]"); + ASSERT_OK(dbfull()->TEST_CompactMemTable()); // Moves to level last-2 + ASSERT_EQ(AllEntriesFor("foo"), "[ v2, DEL, v1 ]"); + Slice z("z"); + dbfull()->TEST_CompactRange(last-2, NULL, &z); + // DEL eliminated, but v1 remains because we aren't compacting that level + // (DEL can be eliminated because v2 hides v1). + ASSERT_EQ(AllEntriesFor("foo"), "[ v2, v1 ]"); + dbfull()->TEST_CompactRange(last-1, NULL, NULL); + // Merging last-1 w/ last, so we are the base level for "foo", so + // DEL is removed. (as is v1). + ASSERT_EQ(AllEntriesFor("foo"), "[ v2 ]"); +} + +TEST(DBTest, DeletionMarkers2) { + Put("foo", "v1"); + ASSERT_OK(dbfull()->TEST_CompactMemTable()); + const int last = config::kMaxMemCompactLevel; + ASSERT_EQ(NumTableFilesAtLevel(last), 1); // foo => v1 is now in last level + + // Place a table at level last-1 to prevent merging with preceding mutation + Put("a", "begin"); + Put("z", "end"); + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ(NumTableFilesAtLevel(last), 1); + ASSERT_EQ(NumTableFilesAtLevel(last-1), 1); + + Delete("foo"); + ASSERT_EQ(AllEntriesFor("foo"), "[ DEL, v1 ]"); + ASSERT_OK(dbfull()->TEST_CompactMemTable()); // Moves to level last-2 + ASSERT_EQ(AllEntriesFor("foo"), "[ DEL, v1 ]"); + dbfull()->TEST_CompactRange(last-2, NULL, NULL); + // DEL kept: "last" file overlaps + ASSERT_EQ(AllEntriesFor("foo"), "[ DEL, v1 ]"); + dbfull()->TEST_CompactRange(last-1, NULL, NULL); + // Merging last-1 w/ last, so we are the base level for "foo", so + // DEL is removed. (as is v1). + ASSERT_EQ(AllEntriesFor("foo"), "[ ]"); +} + +TEST(DBTest, OverlapInLevel0) { + do { + ASSERT_EQ(config::kMaxMemCompactLevel, 2) << "Fix test to match config"; + + // Fill levels 1 and 2 to disable the pushing of new memtables to levels > 0. + ASSERT_OK(Put("100", "v100")); + ASSERT_OK(Put("999", "v999")); + dbfull()->TEST_CompactMemTable(); + ASSERT_OK(Delete("100")); + ASSERT_OK(Delete("999")); + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ("0,1,1", FilesPerLevel()); + + // Make files spanning the following ranges in level-0: + // files[0] 200 .. 900 + // files[1] 300 .. 500 + // Note that files are sorted by smallest key. + ASSERT_OK(Put("300", "v300")); + ASSERT_OK(Put("500", "v500")); + dbfull()->TEST_CompactMemTable(); + ASSERT_OK(Put("200", "v200")); + ASSERT_OK(Put("600", "v600")); + ASSERT_OK(Put("900", "v900")); + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ("2,1,1", FilesPerLevel()); + + // Compact away the placeholder files we created initially + dbfull()->TEST_CompactRange(1, NULL, NULL); + dbfull()->TEST_CompactRange(2, NULL, NULL); + ASSERT_EQ("2", FilesPerLevel()); + + // Do a memtable compaction. Before bug-fix, the compaction would + // not detect the overlap with level-0 files and would incorrectly place + // the deletion in a deeper level. + ASSERT_OK(Delete("600")); + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ("3", FilesPerLevel()); + ASSERT_EQ("NOT_FOUND", Get("600")); + } while (ChangeOptions()); +} + +TEST(DBTest, L0_CompactionBug_Issue44_a) { + Reopen(); + ASSERT_OK(Put("b", "v")); + Reopen(); + ASSERT_OK(Delete("b")); + ASSERT_OK(Delete("a")); + Reopen(); + ASSERT_OK(Delete("a")); + Reopen(); + ASSERT_OK(Put("a", "v")); + Reopen(); + Reopen(); + ASSERT_EQ("(a->v)", Contents()); + DelayMilliseconds(1000); // Wait for compaction to finish + ASSERT_EQ("(a->v)", Contents()); +} + +TEST(DBTest, L0_CompactionBug_Issue44_b) { + Reopen(); + Put("",""); + Reopen(); + Delete("e"); + Put("",""); + Reopen(); + Put("c", "cv"); + Reopen(); + Put("",""); + Reopen(); + Put("",""); + DelayMilliseconds(1000); // Wait for compaction to finish + Reopen(); + Put("d","dv"); + Reopen(); + Put("",""); + Reopen(); + Delete("d"); + Delete("b"); + Reopen(); + ASSERT_EQ("(->)(c->cv)", Contents()); + DelayMilliseconds(1000); // Wait for compaction to finish + ASSERT_EQ("(->)(c->cv)", Contents()); +} + +TEST(DBTest, ComparatorCheck) { + class NewComparator : public Comparator { + public: + virtual const char* Name() const { return "leveldb.NewComparator"; } + virtual int Compare(const Slice& a, const Slice& b) const { + return BytewiseComparator()->Compare(a, b); + } + virtual void FindShortestSeparator(std::string* s, const Slice& l) const { + BytewiseComparator()->FindShortestSeparator(s, l); + } + virtual void FindShortSuccessor(std::string* key) const { + BytewiseComparator()->FindShortSuccessor(key); + } + }; + NewComparator cmp; + Options new_options = CurrentOptions(); + new_options.comparator = &cmp; + Status s = TryReopen(&new_options); + ASSERT_TRUE(!s.ok()); + ASSERT_TRUE(s.ToString().find("comparator") != std::string::npos) + << s.ToString(); +} + +TEST(DBTest, CustomComparator) { + class NumberComparator : public Comparator { + public: + virtual const char* Name() const { return "test.NumberComparator"; } + virtual int Compare(const Slice& a, const Slice& b) const { + return ToNumber(a) - ToNumber(b); + } + virtual void FindShortestSeparator(std::string* s, const Slice& l) const { + ToNumber(*s); // Check format + ToNumber(l); // Check format + } + virtual void FindShortSuccessor(std::string* key) const { + ToNumber(*key); // Check format + } + private: + static int ToNumber(const Slice& x) { + // Check that there are no extra characters. + ASSERT_TRUE(x.size() >= 2 && x[0] == '[' && x[x.size()-1] == ']') + << EscapeString(x); + int val; + char ignored; + ASSERT_TRUE(sscanf(x.ToString().c_str(), "[%i]%c", &val, &ignored) == 1) + << EscapeString(x); + return val; + } + }; + NumberComparator cmp; + Options new_options = CurrentOptions(); + new_options.create_if_missing = true; + new_options.comparator = &cmp; + new_options.filter_policy = NULL; // Cannot use bloom filters + new_options.write_buffer_size = 1000; // Compact more often + DestroyAndReopen(&new_options); + ASSERT_OK(Put("[10]", "ten")); + ASSERT_OK(Put("[0x14]", "twenty")); + for (int i = 0; i < 2; i++) { + ASSERT_EQ("ten", Get("[10]")); + ASSERT_EQ("ten", Get("[0xa]")); + ASSERT_EQ("twenty", Get("[20]")); + ASSERT_EQ("twenty", Get("[0x14]")); + ASSERT_EQ("NOT_FOUND", Get("[15]")); + ASSERT_EQ("NOT_FOUND", Get("[0xf]")); + Compact("[0]", "[9999]"); + } + + for (int run = 0; run < 2; run++) { + for (int i = 0; i < 1000; i++) { + char buf[100]; + snprintf(buf, sizeof(buf), "[%d]", i*10); + ASSERT_OK(Put(buf, buf)); + } + Compact("[0]", "[1000000]"); + } +} + +TEST(DBTest, ManualCompaction) { + ASSERT_EQ(config::kMaxMemCompactLevel, 2) + << "Need to update this test to match kMaxMemCompactLevel"; + + MakeTables(3, "p", "q"); + ASSERT_EQ("1,1,1", FilesPerLevel()); + + // Compaction range falls before files + Compact("", "c"); + ASSERT_EQ("1,1,1", FilesPerLevel()); + + // Compaction range falls after files + Compact("r", "z"); + ASSERT_EQ("1,1,1", FilesPerLevel()); + + // Compaction range overlaps files + Compact("p1", "p9"); + ASSERT_EQ("0,0,1", FilesPerLevel()); + + // Populate a different range + MakeTables(3, "c", "e"); + ASSERT_EQ("1,1,2", FilesPerLevel()); + + // Compact just the new range + Compact("b", "f"); + ASSERT_EQ("0,0,2", FilesPerLevel()); + + // Compact all + MakeTables(1, "a", "z"); + ASSERT_EQ("0,1,2", FilesPerLevel()); + db_->CompactRange(NULL, NULL); + ASSERT_EQ("0,0,1", FilesPerLevel()); +} + +TEST(DBTest, DBOpen_Options) { + std::string dbname = test::TmpDir() + "/db_options_test"; + DestroyDB(dbname, Options()); + + // Does not exist, and create_if_missing == false: error + DB* db = NULL; + Options opts; + opts.create_if_missing = false; + Status s = DB::Open(opts, dbname, &db); + ASSERT_TRUE(strstr(s.ToString().c_str(), "does not exist") != NULL); + ASSERT_TRUE(db == NULL); + + // Does not exist, and create_if_missing == true: OK + opts.create_if_missing = true; + s = DB::Open(opts, dbname, &db); + ASSERT_OK(s); + ASSERT_TRUE(db != NULL); + + delete db; + db = NULL; + + // Does exist, and error_if_exists == true: error + opts.create_if_missing = false; + opts.error_if_exists = true; + s = DB::Open(opts, dbname, &db); + ASSERT_TRUE(strstr(s.ToString().c_str(), "exists") != NULL); + ASSERT_TRUE(db == NULL); + + // Does exist, and error_if_exists == false: OK + opts.create_if_missing = true; + opts.error_if_exists = false; + s = DB::Open(opts, dbname, &db); + ASSERT_OK(s); + ASSERT_TRUE(db != NULL); + + delete db; + db = NULL; +} + +TEST(DBTest, Locking) { + DB* db2 = NULL; + Status s = DB::Open(CurrentOptions(), dbname_, &db2); + ASSERT_TRUE(!s.ok()) << "Locking did not prevent re-opening db"; +} + +// Check that number of files does not grow when we are out of space +TEST(DBTest, NoSpace) { + Options options = CurrentOptions(); + options.env = env_; + Reopen(&options); + + ASSERT_OK(Put("foo", "v1")); + ASSERT_EQ("v1", Get("foo")); + Compact("a", "z"); + const int num_files = CountFiles(); + env_->no_space_.Release_Store(env_); // Force out-of-space errors + for (int i = 0; i < 10; i++) { + for (int level = 0; level < config::kNumLevels-1; level++) { + dbfull()->TEST_CompactRange(level, NULL, NULL); + } + } + env_->no_space_.Release_Store(NULL); + ASSERT_LT(CountFiles(), num_files + 3); +} + +TEST(DBTest, NonWritableFileSystem) { + Options options = CurrentOptions(); + options.write_buffer_size = 1000; + options.env = env_; + Reopen(&options); + ASSERT_OK(Put("foo", "v1")); + env_->non_writable_.Release_Store(env_); // Force errors for new files + std::string big(100000, 'x'); + int errors = 0; + for (int i = 0; i < 20; i++) { + fprintf(stderr, "iter %d; errors %d\n", i, errors); + if (!Put("foo", big).ok()) { + errors++; + DelayMilliseconds(100); + } + } + ASSERT_GT(errors, 0); + env_->non_writable_.Release_Store(NULL); +} + +TEST(DBTest, WriteSyncError) { + // Check that log sync errors cause the DB to disallow future writes. + + // (a) Cause log sync calls to fail + Options options = CurrentOptions(); + options.env = env_; + Reopen(&options); + env_->data_sync_error_.Release_Store(env_); + + // (b) Normal write should succeed + WriteOptions w; + ASSERT_OK(db_->Put(w, "k1", "v1")); + ASSERT_EQ("v1", Get("k1")); + + // (c) Do a sync write; should fail + w.sync = true; + ASSERT_TRUE(!db_->Put(w, "k2", "v2").ok()); + ASSERT_EQ("v1", Get("k1")); + ASSERT_EQ("NOT_FOUND", Get("k2")); + + // (d) make sync behave normally + env_->data_sync_error_.Release_Store(NULL); + + // (e) Do a non-sync write; should fail + w.sync = false; + ASSERT_TRUE(!db_->Put(w, "k3", "v3").ok()); + ASSERT_EQ("v1", Get("k1")); + ASSERT_EQ("NOT_FOUND", Get("k2")); + ASSERT_EQ("NOT_FOUND", Get("k3")); +} + +TEST(DBTest, ManifestWriteError) { + // Test for the following problem: + // (a) Compaction produces file F + // (b) Log record containing F is written to MANIFEST file, but Sync() fails + // (c) GC deletes F + // (d) After reopening DB, reads fail since deleted F is named in log record + + // We iterate twice. In the second iteration, everything is the + // same except the log record never makes it to the MANIFEST file. + for (int iter = 0; iter < 2; iter++) { + port::AtomicPointer* error_type = (iter == 0) + ? &env_->manifest_sync_error_ + : &env_->manifest_write_error_; + + // Insert foo=>bar mapping + Options options = CurrentOptions(); + options.env = env_; + options.create_if_missing = true; + options.error_if_exists = false; + DestroyAndReopen(&options); + ASSERT_OK(Put("foo", "bar")); + ASSERT_EQ("bar", Get("foo")); + + // Memtable compaction (will succeed) + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ("bar", Get("foo")); + const int last = config::kMaxMemCompactLevel; + ASSERT_EQ(NumTableFilesAtLevel(last), 1); // foo=>bar is now in last level + + // Merging compaction (will fail) + error_type->Release_Store(env_); + dbfull()->TEST_CompactRange(last, NULL, NULL); // Should fail + ASSERT_EQ("bar", Get("foo")); + + // Recovery: should not lose data + error_type->Release_Store(NULL); + Reopen(&options); + ASSERT_EQ("bar", Get("foo")); + } +} + +TEST(DBTest, MissingSSTFile) { + ASSERT_OK(Put("foo", "bar")); + ASSERT_EQ("bar", Get("foo")); + + // Dump the memtable to disk. + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ("bar", Get("foo")); + + Close(); + ASSERT_TRUE(DeleteAnSSTFile()); + Options options = CurrentOptions(); + options.paranoid_checks = true; + Status s = TryReopen(&options); + ASSERT_TRUE(!s.ok()); + ASSERT_TRUE(s.ToString().find("issing") != std::string::npos) + << s.ToString(); +} + +TEST(DBTest, StillReadSST) { + ASSERT_OK(Put("foo", "bar")); + ASSERT_EQ("bar", Get("foo")); + + // Dump the memtable to disk. + dbfull()->TEST_CompactMemTable(); + ASSERT_EQ("bar", Get("foo")); + Close(); + ASSERT_GT(RenameLDBToSST(), 0); + Options options = CurrentOptions(); + options.paranoid_checks = true; + Status s = TryReopen(&options); + ASSERT_TRUE(s.ok()); + ASSERT_EQ("bar", Get("foo")); +} + +TEST(DBTest, FilesDeletedAfterCompaction) { + ASSERT_OK(Put("foo", "v2")); + Compact("a", "z"); + const int num_files = CountFiles(); + for (int i = 0; i < 10; i++) { + ASSERT_OK(Put("foo", "v2")); + Compact("a", "z"); + } + ASSERT_EQ(CountFiles(), num_files); +} + +TEST(DBTest, BloomFilter) { + env_->count_random_reads_ = true; + Options options = CurrentOptions(); + options.env = env_; + options.block_cache = NewLRUCache(0); // Prevent cache hits + options.filter_policy = NewBloomFilterPolicy(10); + Reopen(&options); + + // Populate multiple layers + const int N = 10000; + for (int i = 0; i < N; i++) { + ASSERT_OK(Put(Key(i), Key(i))); + } + Compact("a", "z"); + for (int i = 0; i < N; i += 100) { + ASSERT_OK(Put(Key(i), Key(i))); + } + dbfull()->TEST_CompactMemTable(); + + // Prevent auto compactions triggered by seeks + env_->delay_data_sync_.Release_Store(env_); + + // Lookup present keys. Should rarely read from small sstable. + env_->random_read_counter_.Reset(); + for (int i = 0; i < N; i++) { + ASSERT_EQ(Key(i), Get(Key(i))); + } + int reads = env_->random_read_counter_.Read(); + fprintf(stderr, "%d present => %d reads\n", N, reads); + ASSERT_GE(reads, N); + ASSERT_LE(reads, N + 2*N/100); + + // Lookup present keys. Should rarely read from either sstable. + env_->random_read_counter_.Reset(); + for (int i = 0; i < N; i++) { + ASSERT_EQ("NOT_FOUND", Get(Key(i) + ".missing")); + } + reads = env_->random_read_counter_.Read(); + fprintf(stderr, "%d missing => %d reads\n", N, reads); + ASSERT_LE(reads, 3*N/100); + + env_->delay_data_sync_.Release_Store(NULL); + Close(); + delete options.block_cache; + delete options.filter_policy; +} + +// Multi-threaded test: +namespace { + +static const int kNumThreads = 4; +static const int kTestSeconds = 10; +static const int kNumKeys = 1000; + +struct MTState { + DBTest* test; + port::AtomicPointer stop; + port::AtomicPointer counter[kNumThreads]; + port::AtomicPointer thread_done[kNumThreads]; +}; + +struct MTThread { + MTState* state; + int id; +}; + +static void MTThreadBody(void* arg) { + MTThread* t = reinterpret_cast(arg); + int id = t->id; + DB* db = t->state->test->db_; + uintptr_t counter = 0; + fprintf(stderr, "... starting thread %d\n", id); + Random rnd(1000 + id); + std::string value; + char valbuf[1500]; + while (t->state->stop.Acquire_Load() == NULL) { + t->state->counter[id].Release_Store(reinterpret_cast(counter)); + + int key = rnd.Uniform(kNumKeys); + char keybuf[20]; + snprintf(keybuf, sizeof(keybuf), "%016d", key); + + if (rnd.OneIn(2)) { + // Write values of the form . + // We add some padding for force compactions. + snprintf(valbuf, sizeof(valbuf), "%d.%d.%-1000d", + key, id, static_cast(counter)); + ASSERT_OK(db->Put(WriteOptions(), Slice(keybuf), Slice(valbuf))); + } else { + // Read a value and verify that it matches the pattern written above. + Status s = db->Get(ReadOptions(), Slice(keybuf), &value); + if (s.IsNotFound()) { + // Key has not yet been written + } else { + // Check that the writer thread counter is >= the counter in the value + ASSERT_OK(s); + int k, w, c; + ASSERT_EQ(3, sscanf(value.c_str(), "%d.%d.%d", &k, &w, &c)) << value; + ASSERT_EQ(k, key); + ASSERT_GE(w, 0); + ASSERT_LT(w, kNumThreads); + ASSERT_LE(static_cast(c), reinterpret_cast( + t->state->counter[w].Acquire_Load())); + } + } + counter++; + } + t->state->thread_done[id].Release_Store(t); + fprintf(stderr, "... stopping thread %d after %d ops\n", id, int(counter)); +} + +} // namespace + +TEST(DBTest, MultiThreaded) { + do { + // Initialize state + MTState mt; + mt.test = this; + mt.stop.Release_Store(0); + for (int id = 0; id < kNumThreads; id++) { + mt.counter[id].Release_Store(0); + mt.thread_done[id].Release_Store(0); + } + + // Start threads + MTThread thread[kNumThreads]; + for (int id = 0; id < kNumThreads; id++) { + thread[id].state = &mt; + thread[id].id = id; + env_->StartThread(MTThreadBody, &thread[id]); + } + + // Let them run for a while + DelayMilliseconds(kTestSeconds * 1000); + + // Stop the threads and wait for them to finish + mt.stop.Release_Store(&mt); + for (int id = 0; id < kNumThreads; id++) { + while (mt.thread_done[id].Acquire_Load() == NULL) { + DelayMilliseconds(100); + } + } + } while (ChangeOptions()); +} + +namespace { +typedef std::map KVMap; +} + +class ModelDB: public DB { + public: + class ModelSnapshot : public Snapshot { + public: + KVMap map_; + }; + + explicit ModelDB(const Options& options): options_(options) { } + ~ModelDB() { } + virtual Status Put(const WriteOptions& o, const Slice& k, const Slice& v) { + return DB::Put(o, k, v); + } + virtual Status Delete(const WriteOptions& o, const Slice& key) { + return DB::Delete(o, key); + } + virtual Status Get(const ReadOptions& options, + const Slice& key, std::string* value) { + assert(false); // Not implemented + return Status::NotFound(key); + } + virtual Iterator* NewIterator(const ReadOptions& options) { + if (options.snapshot == NULL) { + KVMap* saved = new KVMap; + *saved = map_; + return new ModelIter(saved, true); + } else { + const KVMap* snapshot_state = + &(reinterpret_cast(options.snapshot)->map_); + return new ModelIter(snapshot_state, false); + } + } + virtual const Snapshot* GetSnapshot() { + ModelSnapshot* snapshot = new ModelSnapshot; + snapshot->map_ = map_; + return snapshot; + } + + virtual void ReleaseSnapshot(const Snapshot* snapshot) { + delete reinterpret_cast(snapshot); + } + virtual Status Write(const WriteOptions& options, WriteBatch* batch) { + class Handler : public WriteBatch::Handler { + public: + KVMap* map_; + virtual void Put(const Slice& key, const Slice& value) { + (*map_)[key.ToString()] = value.ToString(); + } + virtual void Delete(const Slice& key) { + map_->erase(key.ToString()); + } + }; + Handler handler; + handler.map_ = &map_; + return batch->Iterate(&handler); + } + + virtual bool GetProperty(const Slice& property, std::string* value) { + return false; + } + virtual void GetApproximateSizes(const Range* r, int n, uint64_t* sizes) { + for (int i = 0; i < n; i++) { + sizes[i] = 0; + } + } + virtual void CompactRange(const Slice* start, const Slice* end) { + } + + private: + class ModelIter: public Iterator { + public: + ModelIter(const KVMap* map, bool owned) + : map_(map), owned_(owned), iter_(map_->end()) { + } + ~ModelIter() { + if (owned_) delete map_; + } + virtual bool Valid() const { return iter_ != map_->end(); } + virtual void SeekToFirst() { iter_ = map_->begin(); } + virtual void SeekToLast() { + if (map_->empty()) { + iter_ = map_->end(); + } else { + iter_ = map_->find(map_->rbegin()->first); + } + } + virtual void Seek(const Slice& k) { + iter_ = map_->lower_bound(k.ToString()); + } + virtual void Next() { ++iter_; } + virtual void Prev() { --iter_; } + virtual Slice key() const { return iter_->first; } + virtual Slice value() const { return iter_->second; } + virtual Status status() const { return Status::OK(); } + private: + const KVMap* const map_; + const bool owned_; // Do we own map_ + KVMap::const_iterator iter_; + }; + const Options options_; + KVMap map_; +}; + +static std::string RandomKey(Random* rnd) { + int len = (rnd->OneIn(3) + ? 1 // Short sometimes to encourage collisions + : (rnd->OneIn(100) ? rnd->Skewed(10) : rnd->Uniform(10))); + return test::RandomKey(rnd, len); +} + +static bool CompareIterators(int step, + DB* model, + DB* db, + const Snapshot* model_snap, + const Snapshot* db_snap) { + ReadOptions options; + options.snapshot = model_snap; + Iterator* miter = model->NewIterator(options); + options.snapshot = db_snap; + Iterator* dbiter = db->NewIterator(options); + bool ok = true; + int count = 0; + for (miter->SeekToFirst(), dbiter->SeekToFirst(); + ok && miter->Valid() && dbiter->Valid(); + miter->Next(), dbiter->Next()) { + count++; + if (miter->key().compare(dbiter->key()) != 0) { + fprintf(stderr, "step %d: Key mismatch: '%s' vs. '%s'\n", + step, + EscapeString(miter->key()).c_str(), + EscapeString(dbiter->key()).c_str()); + ok = false; + break; + } + + if (miter->value().compare(dbiter->value()) != 0) { + fprintf(stderr, "step %d: Value mismatch for key '%s': '%s' vs. '%s'\n", + step, + EscapeString(miter->key()).c_str(), + EscapeString(miter->value()).c_str(), + EscapeString(miter->value()).c_str()); + ok = false; + } + } + + if (ok) { + if (miter->Valid() != dbiter->Valid()) { + fprintf(stderr, "step %d: Mismatch at end of iterators: %d vs. %d\n", + step, miter->Valid(), dbiter->Valid()); + ok = false; + } + } + fprintf(stderr, "%d entries compared: ok=%d\n", count, ok); + delete miter; + delete dbiter; + return ok; +} + +TEST(DBTest, Randomized) { + Random rnd(test::RandomSeed()); + do { + ModelDB model(CurrentOptions()); + const int N = 10000; + const Snapshot* model_snap = NULL; + const Snapshot* db_snap = NULL; + std::string k, v; + for (int step = 0; step < N; step++) { + if (step % 100 == 0) { + fprintf(stderr, "Step %d of %d\n", step, N); + } + // TODO(sanjay): Test Get() works + int p = rnd.Uniform(100); + if (p < 45) { // Put + k = RandomKey(&rnd); + v = RandomString(&rnd, + rnd.OneIn(20) + ? 100 + rnd.Uniform(100) + : rnd.Uniform(8)); + ASSERT_OK(model.Put(WriteOptions(), k, v)); + ASSERT_OK(db_->Put(WriteOptions(), k, v)); + + } else if (p < 90) { // Delete + k = RandomKey(&rnd); + ASSERT_OK(model.Delete(WriteOptions(), k)); + ASSERT_OK(db_->Delete(WriteOptions(), k)); + + + } else { // Multi-element batch + WriteBatch b; + const int num = rnd.Uniform(8); + for (int i = 0; i < num; i++) { + if (i == 0 || !rnd.OneIn(10)) { + k = RandomKey(&rnd); + } else { + // Periodically re-use the same key from the previous iter, so + // we have multiple entries in the write batch for the same key + } + if (rnd.OneIn(2)) { + v = RandomString(&rnd, rnd.Uniform(10)); + b.Put(k, v); + } else { + b.Delete(k); + } + } + ASSERT_OK(model.Write(WriteOptions(), &b)); + ASSERT_OK(db_->Write(WriteOptions(), &b)); + } + + if ((step % 100) == 0) { + ASSERT_TRUE(CompareIterators(step, &model, db_, NULL, NULL)); + ASSERT_TRUE(CompareIterators(step, &model, db_, model_snap, db_snap)); + // Save a snapshot from each DB this time that we'll use next + // time we compare things, to make sure the current state is + // preserved with the snapshot + if (model_snap != NULL) model.ReleaseSnapshot(model_snap); + if (db_snap != NULL) db_->ReleaseSnapshot(db_snap); + + Reopen(); + ASSERT_TRUE(CompareIterators(step, &model, db_, NULL, NULL)); + + model_snap = model.GetSnapshot(); + db_snap = db_->GetSnapshot(); + } + } + if (model_snap != NULL) model.ReleaseSnapshot(model_snap); + if (db_snap != NULL) db_->ReleaseSnapshot(db_snap); + } while (ChangeOptions()); +} + +std::string MakeKey(unsigned int num) { + char buf[30]; + snprintf(buf, sizeof(buf), "%016u", num); + return std::string(buf); +} + +void BM_LogAndApply(int iters, int num_base_files) { + std::string dbname = test::TmpDir() + "/leveldb_test_benchmark"; + DestroyDB(dbname, Options()); + + DB* db = NULL; + Options opts; + opts.create_if_missing = true; + Status s = DB::Open(opts, dbname, &db); + ASSERT_OK(s); + ASSERT_TRUE(db != NULL); + + delete db; + db = NULL; + + Env* env = Env::Default(); + + port::Mutex mu; + MutexLock l(&mu); + + InternalKeyComparator cmp(BytewiseComparator()); + Options options; + VersionSet vset(dbname, &options, NULL, &cmp); + ASSERT_OK(vset.Recover()); + VersionEdit vbase; + uint64_t fnum = 1; + for (int i = 0; i < num_base_files; i++) { + InternalKey start(MakeKey(2*fnum), 1, kTypeValue); + InternalKey limit(MakeKey(2*fnum+1), 1, kTypeDeletion); + vbase.AddFile(2, fnum++, 1 /* file size */, start, limit); + } + ASSERT_OK(vset.LogAndApply(&vbase, &mu)); + + uint64_t start_micros = env->NowMicros(); + + for (int i = 0; i < iters; i++) { + VersionEdit vedit; + vedit.DeleteFile(2, fnum); + InternalKey start(MakeKey(2*fnum), 1, kTypeValue); + InternalKey limit(MakeKey(2*fnum+1), 1, kTypeDeletion); + vedit.AddFile(2, fnum++, 1 /* file size */, start, limit); + vset.LogAndApply(&vedit, &mu); + } + uint64_t stop_micros = env->NowMicros(); + unsigned int us = stop_micros - start_micros; + char buf[16]; + snprintf(buf, sizeof(buf), "%d", num_base_files); + fprintf(stderr, + "BM_LogAndApply/%-6s %8d iters : %9u us (%7.0f us / iter)\n", + buf, iters, us, ((float)us) / iters); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + if (argc > 1 && std::string(argv[1]) == "--benchmark") { + leveldb::BM_LogAndApply(1000, 1); + leveldb::BM_LogAndApply(1000, 100); + leveldb::BM_LogAndApply(1000, 10000); + leveldb::BM_LogAndApply(100, 100000); + return 0; + } + + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/db/dbformat.cc b/src/leveldb/db/dbformat.cc new file mode 100644 index 0000000..20a7ca4 --- /dev/null +++ b/src/leveldb/db/dbformat.cc @@ -0,0 +1,140 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include +#include "db/dbformat.h" +#include "port/port.h" +#include "util/coding.h" + +namespace leveldb { + +static uint64_t PackSequenceAndType(uint64_t seq, ValueType t) { + assert(seq <= kMaxSequenceNumber); + assert(t <= kValueTypeForSeek); + return (seq << 8) | t; +} + +void AppendInternalKey(std::string* result, const ParsedInternalKey& key) { + result->append(key.user_key.data(), key.user_key.size()); + PutFixed64(result, PackSequenceAndType(key.sequence, key.type)); +} + +std::string ParsedInternalKey::DebugString() const { + char buf[50]; + snprintf(buf, sizeof(buf), "' @ %llu : %d", + (unsigned long long) sequence, + int(type)); + std::string result = "'"; + result += EscapeString(user_key.ToString()); + result += buf; + return result; +} + +std::string InternalKey::DebugString() const { + std::string result; + ParsedInternalKey parsed; + if (ParseInternalKey(rep_, &parsed)) { + result = parsed.DebugString(); + } else { + result = "(bad)"; + result.append(EscapeString(rep_)); + } + return result; +} + +const char* InternalKeyComparator::Name() const { + return "leveldb.InternalKeyComparator"; +} + +int InternalKeyComparator::Compare(const Slice& akey, const Slice& bkey) const { + // Order by: + // increasing user key (according to user-supplied comparator) + // decreasing sequence number + // decreasing type (though sequence# should be enough to disambiguate) + int r = user_comparator_->Compare(ExtractUserKey(akey), ExtractUserKey(bkey)); + if (r == 0) { + const uint64_t anum = DecodeFixed64(akey.data() + akey.size() - 8); + const uint64_t bnum = DecodeFixed64(bkey.data() + bkey.size() - 8); + if (anum > bnum) { + r = -1; + } else if (anum < bnum) { + r = +1; + } + } + return r; +} + +void InternalKeyComparator::FindShortestSeparator( + std::string* start, + const Slice& limit) const { + // Attempt to shorten the user portion of the key + Slice user_start = ExtractUserKey(*start); + Slice user_limit = ExtractUserKey(limit); + std::string tmp(user_start.data(), user_start.size()); + user_comparator_->FindShortestSeparator(&tmp, user_limit); + if (tmp.size() < user_start.size() && + user_comparator_->Compare(user_start, tmp) < 0) { + // User key has become shorter physically, but larger logically. + // Tack on the earliest possible number to the shortened user key. + PutFixed64(&tmp, PackSequenceAndType(kMaxSequenceNumber,kValueTypeForSeek)); + assert(this->Compare(*start, tmp) < 0); + assert(this->Compare(tmp, limit) < 0); + start->swap(tmp); + } +} + +void InternalKeyComparator::FindShortSuccessor(std::string* key) const { + Slice user_key = ExtractUserKey(*key); + std::string tmp(user_key.data(), user_key.size()); + user_comparator_->FindShortSuccessor(&tmp); + if (tmp.size() < user_key.size() && + user_comparator_->Compare(user_key, tmp) < 0) { + // User key has become shorter physically, but larger logically. + // Tack on the earliest possible number to the shortened user key. + PutFixed64(&tmp, PackSequenceAndType(kMaxSequenceNumber,kValueTypeForSeek)); + assert(this->Compare(*key, tmp) < 0); + key->swap(tmp); + } +} + +const char* InternalFilterPolicy::Name() const { + return user_policy_->Name(); +} + +void InternalFilterPolicy::CreateFilter(const Slice* keys, int n, + std::string* dst) const { + // We rely on the fact that the code in table.cc does not mind us + // adjusting keys[]. + Slice* mkey = const_cast(keys); + for (int i = 0; i < n; i++) { + mkey[i] = ExtractUserKey(keys[i]); + // TODO(sanjay): Suppress dups? + } + user_policy_->CreateFilter(keys, n, dst); +} + +bool InternalFilterPolicy::KeyMayMatch(const Slice& key, const Slice& f) const { + return user_policy_->KeyMayMatch(ExtractUserKey(key), f); +} + +LookupKey::LookupKey(const Slice& user_key, SequenceNumber s) { + size_t usize = user_key.size(); + size_t needed = usize + 13; // A conservative estimate + char* dst; + if (needed <= sizeof(space_)) { + dst = space_; + } else { + dst = new char[needed]; + } + start_ = dst; + dst = EncodeVarint32(dst, usize + 8); + kstart_ = dst; + memcpy(dst, user_key.data(), usize); + dst += usize; + EncodeFixed64(dst, PackSequenceAndType(s, kValueTypeForSeek)); + dst += 8; + end_ = dst; +} + +} // namespace leveldb diff --git a/src/leveldb/db/dbformat.h b/src/leveldb/db/dbformat.h new file mode 100644 index 0000000..5d8a032 --- /dev/null +++ b/src/leveldb/db/dbformat.h @@ -0,0 +1,230 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_DB_FORMAT_H_ +#define STORAGE_LEVELDB_DB_FORMAT_H_ + +#include +#include "leveldb/comparator.h" +#include "leveldb/db.h" +#include "leveldb/filter_policy.h" +#include "leveldb/slice.h" +#include "leveldb/table_builder.h" +#include "util/coding.h" +#include "util/logging.h" + +namespace leveldb { + +// Grouping of constants. We may want to make some of these +// parameters set via options. +namespace config { +static const int kNumLevels = 7; + +// Level-0 compaction is started when we hit this many files. +static const int kL0_CompactionTrigger = 4; + +// Soft limit on number of level-0 files. We slow down writes at this point. +static const int kL0_SlowdownWritesTrigger = 8; + +// Maximum number of level-0 files. We stop writes at this point. +static const int kL0_StopWritesTrigger = 12; + +// Maximum level to which a new compacted memtable is pushed if it +// does not create overlap. We try to push to level 2 to avoid the +// relatively expensive level 0=>1 compactions and to avoid some +// expensive manifest file operations. We do not push all the way to +// the largest level since that can generate a lot of wasted disk +// space if the same key space is being repeatedly overwritten. +static const int kMaxMemCompactLevel = 2; + +// Approximate gap in bytes between samples of data read during iteration. +static const int kReadBytesPeriod = 1048576; + +} // namespace config + +class InternalKey; + +// Value types encoded as the last component of internal keys. +// DO NOT CHANGE THESE ENUM VALUES: they are embedded in the on-disk +// data structures. +enum ValueType { + kTypeDeletion = 0x0, + kTypeValue = 0x1 +}; +// kValueTypeForSeek defines the ValueType that should be passed when +// constructing a ParsedInternalKey object for seeking to a particular +// sequence number (since we sort sequence numbers in decreasing order +// and the value type is embedded as the low 8 bits in the sequence +// number in internal keys, we need to use the highest-numbered +// ValueType, not the lowest). +static const ValueType kValueTypeForSeek = kTypeValue; + +typedef uint64_t SequenceNumber; + +// We leave eight bits empty at the bottom so a type and sequence# +// can be packed together into 64-bits. +static const SequenceNumber kMaxSequenceNumber = + ((0x1ull << 56) - 1); + +struct ParsedInternalKey { + Slice user_key; + SequenceNumber sequence; + ValueType type; + + ParsedInternalKey() { } // Intentionally left uninitialized (for speed) + ParsedInternalKey(const Slice& u, const SequenceNumber& seq, ValueType t) + : user_key(u), sequence(seq), type(t) { } + std::string DebugString() const; +}; + +// Return the length of the encoding of "key". +inline size_t InternalKeyEncodingLength(const ParsedInternalKey& key) { + return key.user_key.size() + 8; +} + +// Append the serialization of "key" to *result. +extern void AppendInternalKey(std::string* result, + const ParsedInternalKey& key); + +// Attempt to parse an internal key from "internal_key". On success, +// stores the parsed data in "*result", and returns true. +// +// On error, returns false, leaves "*result" in an undefined state. +extern bool ParseInternalKey(const Slice& internal_key, + ParsedInternalKey* result); + +// Returns the user key portion of an internal key. +inline Slice ExtractUserKey(const Slice& internal_key) { + assert(internal_key.size() >= 8); + return Slice(internal_key.data(), internal_key.size() - 8); +} + +inline ValueType ExtractValueType(const Slice& internal_key) { + assert(internal_key.size() >= 8); + const size_t n = internal_key.size(); + uint64_t num = DecodeFixed64(internal_key.data() + n - 8); + unsigned char c = num & 0xff; + return static_cast(c); +} + +// A comparator for internal keys that uses a specified comparator for +// the user key portion and breaks ties by decreasing sequence number. +class InternalKeyComparator : public Comparator { + private: + const Comparator* user_comparator_; + public: + explicit InternalKeyComparator(const Comparator* c) : user_comparator_(c) { } + virtual const char* Name() const; + virtual int Compare(const Slice& a, const Slice& b) const; + virtual void FindShortestSeparator( + std::string* start, + const Slice& limit) const; + virtual void FindShortSuccessor(std::string* key) const; + + const Comparator* user_comparator() const { return user_comparator_; } + + int Compare(const InternalKey& a, const InternalKey& b) const; +}; + +// Filter policy wrapper that converts from internal keys to user keys +class InternalFilterPolicy : public FilterPolicy { + private: + const FilterPolicy* const user_policy_; + public: + explicit InternalFilterPolicy(const FilterPolicy* p) : user_policy_(p) { } + virtual const char* Name() const; + virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const; + virtual bool KeyMayMatch(const Slice& key, const Slice& filter) const; +}; + +// Modules in this directory should keep internal keys wrapped inside +// the following class instead of plain strings so that we do not +// incorrectly use string comparisons instead of an InternalKeyComparator. +class InternalKey { + private: + std::string rep_; + public: + InternalKey() { } // Leave rep_ as empty to indicate it is invalid + InternalKey(const Slice& user_key, SequenceNumber s, ValueType t) { + AppendInternalKey(&rep_, ParsedInternalKey(user_key, s, t)); + } + + void DecodeFrom(const Slice& s) { rep_.assign(s.data(), s.size()); } + Slice Encode() const { + assert(!rep_.empty()); + return rep_; + } + + Slice user_key() const { return ExtractUserKey(rep_); } + + void SetFrom(const ParsedInternalKey& p) { + rep_.clear(); + AppendInternalKey(&rep_, p); + } + + void Clear() { rep_.clear(); } + + std::string DebugString() const; +}; + +inline int InternalKeyComparator::Compare( + const InternalKey& a, const InternalKey& b) const { + return Compare(a.Encode(), b.Encode()); +} + +inline bool ParseInternalKey(const Slice& internal_key, + ParsedInternalKey* result) { + const size_t n = internal_key.size(); + if (n < 8) return false; + uint64_t num = DecodeFixed64(internal_key.data() + n - 8); + unsigned char c = num & 0xff; + result->sequence = num >> 8; + result->type = static_cast(c); + result->user_key = Slice(internal_key.data(), n - 8); + return (c <= static_cast(kTypeValue)); +} + +// A helper class useful for DBImpl::Get() +class LookupKey { + public: + // Initialize *this for looking up user_key at a snapshot with + // the specified sequence number. + LookupKey(const Slice& user_key, SequenceNumber sequence); + + ~LookupKey(); + + // Return a key suitable for lookup in a MemTable. + Slice memtable_key() const { return Slice(start_, end_ - start_); } + + // Return an internal key (suitable for passing to an internal iterator) + Slice internal_key() const { return Slice(kstart_, end_ - kstart_); } + + // Return the user key + Slice user_key() const { return Slice(kstart_, end_ - kstart_ - 8); } + + private: + // We construct a char array of the form: + // klength varint32 <-- start_ + // userkey char[klength] <-- kstart_ + // tag uint64 + // <-- end_ + // The array is a suitable MemTable key. + // The suffix starting with "userkey" can be used as an InternalKey. + const char* start_; + const char* kstart_; + const char* end_; + char space_[200]; // Avoid allocation for short keys + + // No copying allowed + LookupKey(const LookupKey&); + void operator=(const LookupKey&); +}; + +inline LookupKey::~LookupKey() { + if (start_ != space_) delete[] start_; +} + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_FORMAT_H_ diff --git a/src/leveldb/db/dbformat_test.cc b/src/leveldb/db/dbformat_test.cc new file mode 100644 index 0000000..5d82f5d --- /dev/null +++ b/src/leveldb/db/dbformat_test.cc @@ -0,0 +1,112 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/dbformat.h" +#include "util/logging.h" +#include "util/testharness.h" + +namespace leveldb { + +static std::string IKey(const std::string& user_key, + uint64_t seq, + ValueType vt) { + std::string encoded; + AppendInternalKey(&encoded, ParsedInternalKey(user_key, seq, vt)); + return encoded; +} + +static std::string Shorten(const std::string& s, const std::string& l) { + std::string result = s; + InternalKeyComparator(BytewiseComparator()).FindShortestSeparator(&result, l); + return result; +} + +static std::string ShortSuccessor(const std::string& s) { + std::string result = s; + InternalKeyComparator(BytewiseComparator()).FindShortSuccessor(&result); + return result; +} + +static void TestKey(const std::string& key, + uint64_t seq, + ValueType vt) { + std::string encoded = IKey(key, seq, vt); + + Slice in(encoded); + ParsedInternalKey decoded("", 0, kTypeValue); + + ASSERT_TRUE(ParseInternalKey(in, &decoded)); + ASSERT_EQ(key, decoded.user_key.ToString()); + ASSERT_EQ(seq, decoded.sequence); + ASSERT_EQ(vt, decoded.type); + + ASSERT_TRUE(!ParseInternalKey(Slice("bar"), &decoded)); +} + +class FormatTest { }; + +TEST(FormatTest, InternalKey_EncodeDecode) { + const char* keys[] = { "", "k", "hello", "longggggggggggggggggggggg" }; + const uint64_t seq[] = { + 1, 2, 3, + (1ull << 8) - 1, 1ull << 8, (1ull << 8) + 1, + (1ull << 16) - 1, 1ull << 16, (1ull << 16) + 1, + (1ull << 32) - 1, 1ull << 32, (1ull << 32) + 1 + }; + for (int k = 0; k < sizeof(keys) / sizeof(keys[0]); k++) { + for (int s = 0; s < sizeof(seq) / sizeof(seq[0]); s++) { + TestKey(keys[k], seq[s], kTypeValue); + TestKey("hello", 1, kTypeDeletion); + } + } +} + +TEST(FormatTest, InternalKeyShortSeparator) { + // When user keys are same + ASSERT_EQ(IKey("foo", 100, kTypeValue), + Shorten(IKey("foo", 100, kTypeValue), + IKey("foo", 99, kTypeValue))); + ASSERT_EQ(IKey("foo", 100, kTypeValue), + Shorten(IKey("foo", 100, kTypeValue), + IKey("foo", 101, kTypeValue))); + ASSERT_EQ(IKey("foo", 100, kTypeValue), + Shorten(IKey("foo", 100, kTypeValue), + IKey("foo", 100, kTypeValue))); + ASSERT_EQ(IKey("foo", 100, kTypeValue), + Shorten(IKey("foo", 100, kTypeValue), + IKey("foo", 100, kTypeDeletion))); + + // When user keys are misordered + ASSERT_EQ(IKey("foo", 100, kTypeValue), + Shorten(IKey("foo", 100, kTypeValue), + IKey("bar", 99, kTypeValue))); + + // When user keys are different, but correctly ordered + ASSERT_EQ(IKey("g", kMaxSequenceNumber, kValueTypeForSeek), + Shorten(IKey("foo", 100, kTypeValue), + IKey("hello", 200, kTypeValue))); + + // When start user key is prefix of limit user key + ASSERT_EQ(IKey("foo", 100, kTypeValue), + Shorten(IKey("foo", 100, kTypeValue), + IKey("foobar", 200, kTypeValue))); + + // When limit user key is prefix of start user key + ASSERT_EQ(IKey("foobar", 100, kTypeValue), + Shorten(IKey("foobar", 100, kTypeValue), + IKey("foo", 200, kTypeValue))); +} + +TEST(FormatTest, InternalKeyShortestSuccessor) { + ASSERT_EQ(IKey("g", kMaxSequenceNumber, kValueTypeForSeek), + ShortSuccessor(IKey("foo", 100, kTypeValue))); + ASSERT_EQ(IKey("\xff\xff", 100, kTypeValue), + ShortSuccessor(IKey("\xff\xff", 100, kTypeValue))); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/db/filename.cc b/src/leveldb/db/filename.cc new file mode 100644 index 0000000..27d7506 --- /dev/null +++ b/src/leveldb/db/filename.cc @@ -0,0 +1,149 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include +#include +#include "db/filename.h" +#include "db/dbformat.h" +#include "leveldb/env.h" +#include "util/logging.h" + +namespace leveldb { + +// A utility routine: write "data" to the named file and Sync() it. +extern Status WriteStringToFileSync(Env* env, const Slice& data, + const std::string& fname); + +static std::string MakeFileName(const std::string& name, uint64_t number, + const char* suffix) { + char buf[100]; + snprintf(buf, sizeof(buf), "/%06llu.%s", + static_cast(number), + suffix); + return name + buf; +} + +std::string LogFileName(const std::string& name, uint64_t number) { + assert(number > 0); + return MakeFileName(name, number, "log"); +} + +// TableFileName returns the filenames we usually write to, while +// SSTTableFileName returns the alternative filenames we also try to read from +// for backward compatibility. For now, swap them around. +// TODO: when compatibility is no longer necessary, swap them back +// (TableFileName to use "ldb" and SSTTableFileName to use "sst"). +std::string TableFileName(const std::string& name, uint64_t number) { + assert(number > 0); + return MakeFileName(name, number, "sst"); +} + +std::string SSTTableFileName(const std::string& name, uint64_t number) { + assert(number > 0); + return MakeFileName(name, number, "ldb"); +} + +std::string DescriptorFileName(const std::string& dbname, uint64_t number) { + assert(number > 0); + char buf[100]; + snprintf(buf, sizeof(buf), "/MANIFEST-%06llu", + static_cast(number)); + return dbname + buf; +} + +std::string CurrentFileName(const std::string& dbname) { + return dbname + "/CURRENT"; +} + +std::string LockFileName(const std::string& dbname) { + return dbname + "/LOCK"; +} + +std::string TempFileName(const std::string& dbname, uint64_t number) { + assert(number > 0); + return MakeFileName(dbname, number, "dbtmp"); +} + +std::string InfoLogFileName(const std::string& dbname) { + return dbname + "/LOG"; +} + +// Return the name of the old info log file for "dbname". +std::string OldInfoLogFileName(const std::string& dbname) { + return dbname + "/LOG.old"; +} + + +// Owned filenames have the form: +// dbname/CURRENT +// dbname/LOCK +// dbname/LOG +// dbname/LOG.old +// dbname/MANIFEST-[0-9]+ +// dbname/[0-9]+.(log|sst|ldb) +bool ParseFileName(const std::string& fname, + uint64_t* number, + FileType* type) { + Slice rest(fname); + if (rest == "CURRENT") { + *number = 0; + *type = kCurrentFile; + } else if (rest == "LOCK") { + *number = 0; + *type = kDBLockFile; + } else if (rest == "LOG" || rest == "LOG.old") { + *number = 0; + *type = kInfoLogFile; + } else if (rest.starts_with("MANIFEST-")) { + rest.remove_prefix(strlen("MANIFEST-")); + uint64_t num; + if (!ConsumeDecimalNumber(&rest, &num)) { + return false; + } + if (!rest.empty()) { + return false; + } + *type = kDescriptorFile; + *number = num; + } else { + // Avoid strtoull() to keep filename format independent of the + // current locale + uint64_t num; + if (!ConsumeDecimalNumber(&rest, &num)) { + return false; + } + Slice suffix = rest; + if (suffix == Slice(".log")) { + *type = kLogFile; + } else if (suffix == Slice(".sst") || suffix == Slice(".ldb")) { + *type = kTableFile; + } else if (suffix == Slice(".dbtmp")) { + *type = kTempFile; + } else { + return false; + } + *number = num; + } + return true; +} + +Status SetCurrentFile(Env* env, const std::string& dbname, + uint64_t descriptor_number) { + // Remove leading "dbname/" and add newline to manifest file name + std::string manifest = DescriptorFileName(dbname, descriptor_number); + Slice contents = manifest; + assert(contents.starts_with(dbname + "/")); + contents.remove_prefix(dbname.size() + 1); + std::string tmp = TempFileName(dbname, descriptor_number); + Status s = WriteStringToFileSync(env, contents.ToString() + "\n", tmp); + if (s.ok()) { + s = env->RenameFile(tmp, CurrentFileName(dbname)); + } + if (!s.ok()) { + env->DeleteFile(tmp); + } + return s; +} + +} // namespace leveldb diff --git a/src/leveldb/db/filename.h b/src/leveldb/db/filename.h new file mode 100644 index 0000000..87a7526 --- /dev/null +++ b/src/leveldb/db/filename.h @@ -0,0 +1,85 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// File names used by DB code + +#ifndef STORAGE_LEVELDB_DB_FILENAME_H_ +#define STORAGE_LEVELDB_DB_FILENAME_H_ + +#include +#include +#include "leveldb/slice.h" +#include "leveldb/status.h" +#include "port/port.h" + +namespace leveldb { + +class Env; + +enum FileType { + kLogFile, + kDBLockFile, + kTableFile, + kDescriptorFile, + kCurrentFile, + kTempFile, + kInfoLogFile // Either the current one, or an old one +}; + +// Return the name of the log file with the specified number +// in the db named by "dbname". The result will be prefixed with +// "dbname". +extern std::string LogFileName(const std::string& dbname, uint64_t number); + +// Return the name of the sstable with the specified number +// in the db named by "dbname". The result will be prefixed with +// "dbname". +extern std::string TableFileName(const std::string& dbname, uint64_t number); + +// Return the legacy file name for an sstable with the specified number +// in the db named by "dbname". The result will be prefixed with +// "dbname". +extern std::string SSTTableFileName(const std::string& dbname, uint64_t number); + +// Return the name of the descriptor file for the db named by +// "dbname" and the specified incarnation number. The result will be +// prefixed with "dbname". +extern std::string DescriptorFileName(const std::string& dbname, + uint64_t number); + +// Return the name of the current file. This file contains the name +// of the current manifest file. The result will be prefixed with +// "dbname". +extern std::string CurrentFileName(const std::string& dbname); + +// Return the name of the lock file for the db named by +// "dbname". The result will be prefixed with "dbname". +extern std::string LockFileName(const std::string& dbname); + +// Return the name of a temporary file owned by the db named "dbname". +// The result will be prefixed with "dbname". +extern std::string TempFileName(const std::string& dbname, uint64_t number); + +// Return the name of the info log file for "dbname". +extern std::string InfoLogFileName(const std::string& dbname); + +// Return the name of the old info log file for "dbname". +extern std::string OldInfoLogFileName(const std::string& dbname); + +// If filename is a leveldb file, store the type of the file in *type. +// The number encoded in the filename is stored in *number. If the +// filename was successfully parsed, returns true. Else return false. +extern bool ParseFileName(const std::string& filename, + uint64_t* number, + FileType* type); + +// Make the CURRENT file point to the descriptor file with the +// specified number. +extern Status SetCurrentFile(Env* env, const std::string& dbname, + uint64_t descriptor_number); + + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_FILENAME_H_ diff --git a/src/leveldb/db/filename_test.cc b/src/leveldb/db/filename_test.cc new file mode 100644 index 0000000..a32556d --- /dev/null +++ b/src/leveldb/db/filename_test.cc @@ -0,0 +1,123 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/filename.h" + +#include "db/dbformat.h" +#include "port/port.h" +#include "util/logging.h" +#include "util/testharness.h" + +namespace leveldb { + +class FileNameTest { }; + +TEST(FileNameTest, Parse) { + Slice db; + FileType type; + uint64_t number; + + // Successful parses + static struct { + const char* fname; + uint64_t number; + FileType type; + } cases[] = { + { "100.log", 100, kLogFile }, + { "0.log", 0, kLogFile }, + { "0.sst", 0, kTableFile }, + { "0.ldb", 0, kTableFile }, + { "CURRENT", 0, kCurrentFile }, + { "LOCK", 0, kDBLockFile }, + { "MANIFEST-2", 2, kDescriptorFile }, + { "MANIFEST-7", 7, kDescriptorFile }, + { "LOG", 0, kInfoLogFile }, + { "LOG.old", 0, kInfoLogFile }, + { "18446744073709551615.log", 18446744073709551615ull, kLogFile }, + }; + for (int i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) { + std::string f = cases[i].fname; + ASSERT_TRUE(ParseFileName(f, &number, &type)) << f; + ASSERT_EQ(cases[i].type, type) << f; + ASSERT_EQ(cases[i].number, number) << f; + } + + // Errors + static const char* errors[] = { + "", + "foo", + "foo-dx-100.log", + ".log", + "", + "manifest", + "CURREN", + "CURRENTX", + "MANIFES", + "MANIFEST", + "MANIFEST-", + "XMANIFEST-3", + "MANIFEST-3x", + "LOC", + "LOCKx", + "LO", + "LOGx", + "18446744073709551616.log", + "184467440737095516150.log", + "100", + "100.", + "100.lop" + }; + for (int i = 0; i < sizeof(errors) / sizeof(errors[0]); i++) { + std::string f = errors[i]; + ASSERT_TRUE(!ParseFileName(f, &number, &type)) << f; + } +} + +TEST(FileNameTest, Construction) { + uint64_t number; + FileType type; + std::string fname; + + fname = CurrentFileName("foo"); + ASSERT_EQ("foo/", std::string(fname.data(), 4)); + ASSERT_TRUE(ParseFileName(fname.c_str() + 4, &number, &type)); + ASSERT_EQ(0, number); + ASSERT_EQ(kCurrentFile, type); + + fname = LockFileName("foo"); + ASSERT_EQ("foo/", std::string(fname.data(), 4)); + ASSERT_TRUE(ParseFileName(fname.c_str() + 4, &number, &type)); + ASSERT_EQ(0, number); + ASSERT_EQ(kDBLockFile, type); + + fname = LogFileName("foo", 192); + ASSERT_EQ("foo/", std::string(fname.data(), 4)); + ASSERT_TRUE(ParseFileName(fname.c_str() + 4, &number, &type)); + ASSERT_EQ(192, number); + ASSERT_EQ(kLogFile, type); + + fname = TableFileName("bar", 200); + ASSERT_EQ("bar/", std::string(fname.data(), 4)); + ASSERT_TRUE(ParseFileName(fname.c_str() + 4, &number, &type)); + ASSERT_EQ(200, number); + ASSERT_EQ(kTableFile, type); + + fname = DescriptorFileName("bar", 100); + ASSERT_EQ("bar/", std::string(fname.data(), 4)); + ASSERT_TRUE(ParseFileName(fname.c_str() + 4, &number, &type)); + ASSERT_EQ(100, number); + ASSERT_EQ(kDescriptorFile, type); + + fname = TempFileName("tmp", 999); + ASSERT_EQ("tmp/", std::string(fname.data(), 4)); + ASSERT_TRUE(ParseFileName(fname.c_str() + 4, &number, &type)); + ASSERT_EQ(999, number); + ASSERT_EQ(kTempFile, type); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/db/leveldb_main.cc b/src/leveldb/db/leveldb_main.cc new file mode 100644 index 0000000..995d761 --- /dev/null +++ b/src/leveldb/db/leveldb_main.cc @@ -0,0 +1,238 @@ +// Copyright (c) 2012 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include +#include "db/dbformat.h" +#include "db/filename.h" +#include "db/log_reader.h" +#include "db/version_edit.h" +#include "db/write_batch_internal.h" +#include "leveldb/env.h" +#include "leveldb/iterator.h" +#include "leveldb/options.h" +#include "leveldb/status.h" +#include "leveldb/table.h" +#include "leveldb/write_batch.h" +#include "util/logging.h" + +namespace leveldb { + +namespace { + +bool GuessType(const std::string& fname, FileType* type) { + size_t pos = fname.rfind('/'); + std::string basename; + if (pos == std::string::npos) { + basename = fname; + } else { + basename = std::string(fname.data() + pos + 1, fname.size() - pos - 1); + } + uint64_t ignored; + return ParseFileName(basename, &ignored, type); +} + +// Notified when log reader encounters corruption. +class CorruptionReporter : public log::Reader::Reporter { + public: + virtual void Corruption(size_t bytes, const Status& status) { + printf("corruption: %d bytes; %s\n", + static_cast(bytes), + status.ToString().c_str()); + } +}; + +// Print contents of a log file. (*func)() is called on every record. +bool PrintLogContents(Env* env, const std::string& fname, + void (*func)(Slice)) { + SequentialFile* file; + Status s = env->NewSequentialFile(fname, &file); + if (!s.ok()) { + fprintf(stderr, "%s\n", s.ToString().c_str()); + return false; + } + CorruptionReporter reporter; + log::Reader reader(file, &reporter, true, 0); + Slice record; + std::string scratch; + while (reader.ReadRecord(&record, &scratch)) { + printf("--- offset %llu; ", + static_cast(reader.LastRecordOffset())); + (*func)(record); + } + delete file; + return true; +} + +// Called on every item found in a WriteBatch. +class WriteBatchItemPrinter : public WriteBatch::Handler { + public: + uint64_t offset_; + uint64_t sequence_; + + virtual void Put(const Slice& key, const Slice& value) { + printf(" put '%s' '%s'\n", + EscapeString(key).c_str(), + EscapeString(value).c_str()); + } + virtual void Delete(const Slice& key) { + printf(" del '%s'\n", + EscapeString(key).c_str()); + } +}; + + +// Called on every log record (each one of which is a WriteBatch) +// found in a kLogFile. +static void WriteBatchPrinter(Slice record) { + if (record.size() < 12) { + printf("log record length %d is too small\n", + static_cast(record.size())); + return; + } + WriteBatch batch; + WriteBatchInternal::SetContents(&batch, record); + printf("sequence %llu\n", + static_cast(WriteBatchInternal::Sequence(&batch))); + WriteBatchItemPrinter batch_item_printer; + Status s = batch.Iterate(&batch_item_printer); + if (!s.ok()) { + printf(" error: %s\n", s.ToString().c_str()); + } +} + +bool DumpLog(Env* env, const std::string& fname) { + return PrintLogContents(env, fname, WriteBatchPrinter); +} + +// Called on every log record (each one of which is a WriteBatch) +// found in a kDescriptorFile. +static void VersionEditPrinter(Slice record) { + VersionEdit edit; + Status s = edit.DecodeFrom(record); + if (!s.ok()) { + printf("%s\n", s.ToString().c_str()); + return; + } + printf("%s", edit.DebugString().c_str()); +} + +bool DumpDescriptor(Env* env, const std::string& fname) { + return PrintLogContents(env, fname, VersionEditPrinter); +} + +bool DumpTable(Env* env, const std::string& fname) { + uint64_t file_size; + RandomAccessFile* file = NULL; + Table* table = NULL; + Status s = env->GetFileSize(fname, &file_size); + if (s.ok()) { + s = env->NewRandomAccessFile(fname, &file); + } + if (s.ok()) { + // We use the default comparator, which may or may not match the + // comparator used in this database. However this should not cause + // problems since we only use Table operations that do not require + // any comparisons. In particular, we do not call Seek or Prev. + s = Table::Open(Options(), file, file_size, &table); + } + if (!s.ok()) { + fprintf(stderr, "%s\n", s.ToString().c_str()); + delete table; + delete file; + return false; + } + + ReadOptions ro; + ro.fill_cache = false; + Iterator* iter = table->NewIterator(ro); + for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { + ParsedInternalKey key; + if (!ParseInternalKey(iter->key(), &key)) { + printf("badkey '%s' => '%s'\n", + EscapeString(iter->key()).c_str(), + EscapeString(iter->value()).c_str()); + } else { + char kbuf[20]; + const char* type; + if (key.type == kTypeDeletion) { + type = "del"; + } else if (key.type == kTypeValue) { + type = "val"; + } else { + snprintf(kbuf, sizeof(kbuf), "%d", static_cast(key.type)); + type = kbuf; + } + printf("'%s' @ %8llu : %s => '%s'\n", + EscapeString(key.user_key).c_str(), + static_cast(key.sequence), + type, + EscapeString(iter->value()).c_str()); + } + } + s = iter->status(); + if (!s.ok()) { + printf("iterator error: %s\n", s.ToString().c_str()); + } + + delete iter; + delete table; + delete file; + return true; +} + +bool DumpFile(Env* env, const std::string& fname) { + FileType ftype; + if (!GuessType(fname, &ftype)) { + fprintf(stderr, "%s: unknown file type\n", fname.c_str()); + return false; + } + switch (ftype) { + case kLogFile: return DumpLog(env, fname); + case kDescriptorFile: return DumpDescriptor(env, fname); + case kTableFile: return DumpTable(env, fname); + + default: { + fprintf(stderr, "%s: not a dump-able file type\n", fname.c_str()); + break; + } + } + return false; +} + +bool HandleDumpCommand(Env* env, char** files, int num) { + bool ok = true; + for (int i = 0; i < num; i++) { + ok &= DumpFile(env, files[i]); + } + return ok; +} + +} +} // namespace leveldb + +static void Usage() { + fprintf( + stderr, + "Usage: leveldbutil command...\n" + " dump files... -- dump contents of specified files\n" + ); +} + +int main(int argc, char** argv) { + leveldb::Env* env = leveldb::Env::Default(); + bool ok = true; + if (argc < 2) { + Usage(); + ok = false; + } else { + std::string command = argv[1]; + if (command == "dump") { + ok = leveldb::HandleDumpCommand(env, argv+2, argc-2); + } else { + Usage(); + ok = false; + } + } + return (ok ? 0 : 1); +} diff --git a/src/leveldb/db/log_format.h b/src/leveldb/db/log_format.h new file mode 100644 index 0000000..2690cb9 --- /dev/null +++ b/src/leveldb/db/log_format.h @@ -0,0 +1,35 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// Log format information shared by reader and writer. +// See ../doc/log_format.txt for more detail. + +#ifndef STORAGE_LEVELDB_DB_LOG_FORMAT_H_ +#define STORAGE_LEVELDB_DB_LOG_FORMAT_H_ + +namespace leveldb { +namespace log { + +enum RecordType { + // Zero is reserved for preallocated files + kZeroType = 0, + + kFullType = 1, + + // For fragments + kFirstType = 2, + kMiddleType = 3, + kLastType = 4 +}; +static const int kMaxRecordType = kLastType; + +static const int kBlockSize = 32768; + +// Header is checksum (4 bytes), type (1 byte), length (2 bytes). +static const int kHeaderSize = 4 + 1 + 2; + +} // namespace log +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_LOG_FORMAT_H_ diff --git a/src/leveldb/db/log_reader.cc b/src/leveldb/db/log_reader.cc new file mode 100644 index 0000000..b35f115 --- /dev/null +++ b/src/leveldb/db/log_reader.cc @@ -0,0 +1,259 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/log_reader.h" + +#include +#include "leveldb/env.h" +#include "util/coding.h" +#include "util/crc32c.h" + +namespace leveldb { +namespace log { + +Reader::Reporter::~Reporter() { +} + +Reader::Reader(SequentialFile* file, Reporter* reporter, bool checksum, + uint64_t initial_offset) + : file_(file), + reporter_(reporter), + checksum_(checksum), + backing_store_(new char[kBlockSize]), + buffer_(), + eof_(false), + last_record_offset_(0), + end_of_buffer_offset_(0), + initial_offset_(initial_offset) { +} + +Reader::~Reader() { + delete[] backing_store_; +} + +bool Reader::SkipToInitialBlock() { + size_t offset_in_block = initial_offset_ % kBlockSize; + uint64_t block_start_location = initial_offset_ - offset_in_block; + + // Don't search a block if we'd be in the trailer + if (offset_in_block > kBlockSize - 6) { + offset_in_block = 0; + block_start_location += kBlockSize; + } + + end_of_buffer_offset_ = block_start_location; + + // Skip to start of first block that can contain the initial record + if (block_start_location > 0) { + Status skip_status = file_->Skip(block_start_location); + if (!skip_status.ok()) { + ReportDrop(block_start_location, skip_status); + return false; + } + } + + return true; +} + +bool Reader::ReadRecord(Slice* record, std::string* scratch) { + if (last_record_offset_ < initial_offset_) { + if (!SkipToInitialBlock()) { + return false; + } + } + + scratch->clear(); + record->clear(); + bool in_fragmented_record = false; + // Record offset of the logical record that we're reading + // 0 is a dummy value to make compilers happy + uint64_t prospective_record_offset = 0; + + Slice fragment; + while (true) { + uint64_t physical_record_offset = end_of_buffer_offset_ - buffer_.size(); + const unsigned int record_type = ReadPhysicalRecord(&fragment); + switch (record_type) { + case kFullType: + if (in_fragmented_record) { + // Handle bug in earlier versions of log::Writer where + // it could emit an empty kFirstType record at the tail end + // of a block followed by a kFullType or kFirstType record + // at the beginning of the next block. + if (scratch->empty()) { + in_fragmented_record = false; + } else { + ReportCorruption(scratch->size(), "partial record without end(1)"); + } + } + prospective_record_offset = physical_record_offset; + scratch->clear(); + *record = fragment; + last_record_offset_ = prospective_record_offset; + return true; + + case kFirstType: + if (in_fragmented_record) { + // Handle bug in earlier versions of log::Writer where + // it could emit an empty kFirstType record at the tail end + // of a block followed by a kFullType or kFirstType record + // at the beginning of the next block. + if (scratch->empty()) { + in_fragmented_record = false; + } else { + ReportCorruption(scratch->size(), "partial record without end(2)"); + } + } + prospective_record_offset = physical_record_offset; + scratch->assign(fragment.data(), fragment.size()); + in_fragmented_record = true; + break; + + case kMiddleType: + if (!in_fragmented_record) { + ReportCorruption(fragment.size(), + "missing start of fragmented record(1)"); + } else { + scratch->append(fragment.data(), fragment.size()); + } + break; + + case kLastType: + if (!in_fragmented_record) { + ReportCorruption(fragment.size(), + "missing start of fragmented record(2)"); + } else { + scratch->append(fragment.data(), fragment.size()); + *record = Slice(*scratch); + last_record_offset_ = prospective_record_offset; + return true; + } + break; + + case kEof: + if (in_fragmented_record) { + ReportCorruption(scratch->size(), "partial record without end(3)"); + scratch->clear(); + } + return false; + + case kBadRecord: + if (in_fragmented_record) { + ReportCorruption(scratch->size(), "error in middle of record"); + in_fragmented_record = false; + scratch->clear(); + } + break; + + default: { + char buf[40]; + snprintf(buf, sizeof(buf), "unknown record type %u", record_type); + ReportCorruption( + (fragment.size() + (in_fragmented_record ? scratch->size() : 0)), + buf); + in_fragmented_record = false; + scratch->clear(); + break; + } + } + } + return false; +} + +uint64_t Reader::LastRecordOffset() { + return last_record_offset_; +} + +void Reader::ReportCorruption(size_t bytes, const char* reason) { + ReportDrop(bytes, Status::Corruption(reason)); +} + +void Reader::ReportDrop(size_t bytes, const Status& reason) { + if (reporter_ != NULL && + end_of_buffer_offset_ - buffer_.size() - bytes >= initial_offset_) { + reporter_->Corruption(bytes, reason); + } +} + +unsigned int Reader::ReadPhysicalRecord(Slice* result) { + while (true) { + if (buffer_.size() < kHeaderSize) { + if (!eof_) { + // Last read was a full read, so this is a trailer to skip + buffer_.clear(); + Status status = file_->Read(kBlockSize, &buffer_, backing_store_); + end_of_buffer_offset_ += buffer_.size(); + if (!status.ok()) { + buffer_.clear(); + ReportDrop(kBlockSize, status); + eof_ = true; + return kEof; + } else if (buffer_.size() < kBlockSize) { + eof_ = true; + } + continue; + } else if (buffer_.size() == 0) { + // End of file + return kEof; + } else { + size_t drop_size = buffer_.size(); + buffer_.clear(); + ReportCorruption(drop_size, "truncated record at end of file"); + return kEof; + } + } + + // Parse the header + const char* header = buffer_.data(); + const uint32_t a = static_cast(header[4]) & 0xff; + const uint32_t b = static_cast(header[5]) & 0xff; + const unsigned int type = header[6]; + const uint32_t length = a | (b << 8); + if (kHeaderSize + length > buffer_.size()) { + size_t drop_size = buffer_.size(); + buffer_.clear(); + ReportCorruption(drop_size, "bad record length"); + return kBadRecord; + } + + if (type == kZeroType && length == 0) { + // Skip zero length record without reporting any drops since + // such records are produced by the mmap based writing code in + // env_posix.cc that preallocates file regions. + buffer_.clear(); + return kBadRecord; + } + + // Check crc + if (checksum_) { + uint32_t expected_crc = crc32c::Unmask(DecodeFixed32(header)); + uint32_t actual_crc = crc32c::Value(header + 6, 1 + length); + if (actual_crc != expected_crc) { + // Drop the rest of the buffer since "length" itself may have + // been corrupted and if we trust it, we could find some + // fragment of a real log record that just happens to look + // like a valid log record. + size_t drop_size = buffer_.size(); + buffer_.clear(); + ReportCorruption(drop_size, "checksum mismatch"); + return kBadRecord; + } + } + + buffer_.remove_prefix(kHeaderSize + length); + + // Skip physical record that started before initial_offset_ + if (end_of_buffer_offset_ - buffer_.size() - kHeaderSize - length < + initial_offset_) { + result->clear(); + return kBadRecord; + } + + *result = Slice(header + kHeaderSize, length); + return type; + } +} + +} // namespace log +} // namespace leveldb diff --git a/src/leveldb/db/log_reader.h b/src/leveldb/db/log_reader.h new file mode 100644 index 0000000..82d4bee --- /dev/null +++ b/src/leveldb/db/log_reader.h @@ -0,0 +1,108 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_DB_LOG_READER_H_ +#define STORAGE_LEVELDB_DB_LOG_READER_H_ + +#include + +#include "db/log_format.h" +#include "leveldb/slice.h" +#include "leveldb/status.h" + +namespace leveldb { + +class SequentialFile; + +namespace log { + +class Reader { + public: + // Interface for reporting errors. + class Reporter { + public: + virtual ~Reporter(); + + // Some corruption was detected. "size" is the approximate number + // of bytes dropped due to the corruption. + virtual void Corruption(size_t bytes, const Status& status) = 0; + }; + + // Create a reader that will return log records from "*file". + // "*file" must remain live while this Reader is in use. + // + // If "reporter" is non-NULL, it is notified whenever some data is + // dropped due to a detected corruption. "*reporter" must remain + // live while this Reader is in use. + // + // If "checksum" is true, verify checksums if available. + // + // The Reader will start reading at the first record located at physical + // position >= initial_offset within the file. + Reader(SequentialFile* file, Reporter* reporter, bool checksum, + uint64_t initial_offset); + + ~Reader(); + + // Read the next record into *record. Returns true if read + // successfully, false if we hit end of the input. May use + // "*scratch" as temporary storage. The contents filled in *record + // will only be valid until the next mutating operation on this + // reader or the next mutation to *scratch. + bool ReadRecord(Slice* record, std::string* scratch); + + // Returns the physical offset of the last record returned by ReadRecord. + // + // Undefined before the first call to ReadRecord. + uint64_t LastRecordOffset(); + + private: + SequentialFile* const file_; + Reporter* const reporter_; + bool const checksum_; + char* const backing_store_; + Slice buffer_; + bool eof_; // Last Read() indicated EOF by returning < kBlockSize + + // Offset of the last record returned by ReadRecord. + uint64_t last_record_offset_; + // Offset of the first location past the end of buffer_. + uint64_t end_of_buffer_offset_; + + // Offset at which to start looking for the first record to return + uint64_t const initial_offset_; + + // Extend record types with the following special values + enum { + kEof = kMaxRecordType + 1, + // Returned whenever we find an invalid physical record. + // Currently there are three situations in which this happens: + // * The record has an invalid CRC (ReadPhysicalRecord reports a drop) + // * The record is a 0-length record (No drop is reported) + // * The record is below constructor's initial_offset (No drop is reported) + kBadRecord = kMaxRecordType + 2 + }; + + // Skips all blocks that are completely before "initial_offset_". + // + // Returns true on success. Handles reporting. + bool SkipToInitialBlock(); + + // Return type, or one of the preceding special values + unsigned int ReadPhysicalRecord(Slice* result); + + // Reports dropped bytes to the reporter. + // buffer_ must be updated to remove the dropped bytes prior to invocation. + void ReportCorruption(size_t bytes, const char* reason); + void ReportDrop(size_t bytes, const Status& reason); + + // No copying allowed + Reader(const Reader&); + void operator=(const Reader&); +}; + +} // namespace log +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_LOG_READER_H_ diff --git a/src/leveldb/db/log_test.cc b/src/leveldb/db/log_test.cc new file mode 100644 index 0000000..4c5cf87 --- /dev/null +++ b/src/leveldb/db/log_test.cc @@ -0,0 +1,500 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/log_reader.h" +#include "db/log_writer.h" +#include "leveldb/env.h" +#include "util/coding.h" +#include "util/crc32c.h" +#include "util/random.h" +#include "util/testharness.h" + +namespace leveldb { +namespace log { + +// Construct a string of the specified length made out of the supplied +// partial string. +static std::string BigString(const std::string& partial_string, size_t n) { + std::string result; + while (result.size() < n) { + result.append(partial_string); + } + result.resize(n); + return result; +} + +// Construct a string from a number +static std::string NumberString(int n) { + char buf[50]; + snprintf(buf, sizeof(buf), "%d.", n); + return std::string(buf); +} + +// Return a skewed potentially long string +static std::string RandomSkewedString(int i, Random* rnd) { + return BigString(NumberString(i), rnd->Skewed(17)); +} + +class LogTest { + private: + class StringDest : public WritableFile { + public: + std::string contents_; + + virtual Status Close() { return Status::OK(); } + virtual Status Flush() { return Status::OK(); } + virtual Status Sync() { return Status::OK(); } + virtual Status Append(const Slice& slice) { + contents_.append(slice.data(), slice.size()); + return Status::OK(); + } + }; + + class StringSource : public SequentialFile { + public: + Slice contents_; + bool force_error_; + bool returned_partial_; + StringSource() : force_error_(false), returned_partial_(false) { } + + virtual Status Read(size_t n, Slice* result, char* scratch) { + ASSERT_TRUE(!returned_partial_) << "must not Read() after eof/error"; + + if (force_error_) { + force_error_ = false; + returned_partial_ = true; + return Status::Corruption("read error"); + } + + if (contents_.size() < n) { + n = contents_.size(); + returned_partial_ = true; + } + *result = Slice(contents_.data(), n); + contents_.remove_prefix(n); + return Status::OK(); + } + + virtual Status Skip(uint64_t n) { + if (n > contents_.size()) { + contents_.clear(); + return Status::NotFound("in-memory file skipepd past end"); + } + + contents_.remove_prefix(n); + + return Status::OK(); + } + }; + + class ReportCollector : public Reader::Reporter { + public: + size_t dropped_bytes_; + std::string message_; + + ReportCollector() : dropped_bytes_(0) { } + virtual void Corruption(size_t bytes, const Status& status) { + dropped_bytes_ += bytes; + message_.append(status.ToString()); + } + }; + + StringDest dest_; + StringSource source_; + ReportCollector report_; + bool reading_; + Writer writer_; + Reader reader_; + + // Record metadata for testing initial offset functionality + static size_t initial_offset_record_sizes_[]; + static uint64_t initial_offset_last_record_offsets_[]; + + public: + LogTest() : reading_(false), + writer_(&dest_), + reader_(&source_, &report_, true/*checksum*/, + 0/*initial_offset*/) { + } + + void Write(const std::string& msg) { + ASSERT_TRUE(!reading_) << "Write() after starting to read"; + writer_.AddRecord(Slice(msg)); + } + + size_t WrittenBytes() const { + return dest_.contents_.size(); + } + + std::string Read() { + if (!reading_) { + reading_ = true; + source_.contents_ = Slice(dest_.contents_); + } + std::string scratch; + Slice record; + if (reader_.ReadRecord(&record, &scratch)) { + return record.ToString(); + } else { + return "EOF"; + } + } + + void IncrementByte(int offset, int delta) { + dest_.contents_[offset] += delta; + } + + void SetByte(int offset, char new_byte) { + dest_.contents_[offset] = new_byte; + } + + void ShrinkSize(int bytes) { + dest_.contents_.resize(dest_.contents_.size() - bytes); + } + + void FixChecksum(int header_offset, int len) { + // Compute crc of type/len/data + uint32_t crc = crc32c::Value(&dest_.contents_[header_offset+6], 1 + len); + crc = crc32c::Mask(crc); + EncodeFixed32(&dest_.contents_[header_offset], crc); + } + + void ForceError() { + source_.force_error_ = true; + } + + size_t DroppedBytes() const { + return report_.dropped_bytes_; + } + + std::string ReportMessage() const { + return report_.message_; + } + + // Returns OK iff recorded error message contains "msg" + std::string MatchError(const std::string& msg) const { + if (report_.message_.find(msg) == std::string::npos) { + return report_.message_; + } else { + return "OK"; + } + } + + void WriteInitialOffsetLog() { + for (int i = 0; i < 4; i++) { + std::string record(initial_offset_record_sizes_[i], + static_cast('a' + i)); + Write(record); + } + } + + void CheckOffsetPastEndReturnsNoRecords(uint64_t offset_past_end) { + WriteInitialOffsetLog(); + reading_ = true; + source_.contents_ = Slice(dest_.contents_); + Reader* offset_reader = new Reader(&source_, &report_, true/*checksum*/, + WrittenBytes() + offset_past_end); + Slice record; + std::string scratch; + ASSERT_TRUE(!offset_reader->ReadRecord(&record, &scratch)); + delete offset_reader; + } + + void CheckInitialOffsetRecord(uint64_t initial_offset, + int expected_record_offset) { + WriteInitialOffsetLog(); + reading_ = true; + source_.contents_ = Slice(dest_.contents_); + Reader* offset_reader = new Reader(&source_, &report_, true/*checksum*/, + initial_offset); + Slice record; + std::string scratch; + ASSERT_TRUE(offset_reader->ReadRecord(&record, &scratch)); + ASSERT_EQ(initial_offset_record_sizes_[expected_record_offset], + record.size()); + ASSERT_EQ(initial_offset_last_record_offsets_[expected_record_offset], + offset_reader->LastRecordOffset()); + ASSERT_EQ((char)('a' + expected_record_offset), record.data()[0]); + delete offset_reader; + } + +}; + +size_t LogTest::initial_offset_record_sizes_[] = + {10000, // Two sizable records in first block + 10000, + 2 * log::kBlockSize - 1000, // Span three blocks + 1}; + +uint64_t LogTest::initial_offset_last_record_offsets_[] = + {0, + kHeaderSize + 10000, + 2 * (kHeaderSize + 10000), + 2 * (kHeaderSize + 10000) + + (2 * log::kBlockSize - 1000) + 3 * kHeaderSize}; + + +TEST(LogTest, Empty) { + ASSERT_EQ("EOF", Read()); +} + +TEST(LogTest, ReadWrite) { + Write("foo"); + Write("bar"); + Write(""); + Write("xxxx"); + ASSERT_EQ("foo", Read()); + ASSERT_EQ("bar", Read()); + ASSERT_EQ("", Read()); + ASSERT_EQ("xxxx", Read()); + ASSERT_EQ("EOF", Read()); + ASSERT_EQ("EOF", Read()); // Make sure reads at eof work +} + +TEST(LogTest, ManyBlocks) { + for (int i = 0; i < 100000; i++) { + Write(NumberString(i)); + } + for (int i = 0; i < 100000; i++) { + ASSERT_EQ(NumberString(i), Read()); + } + ASSERT_EQ("EOF", Read()); +} + +TEST(LogTest, Fragmentation) { + Write("small"); + Write(BigString("medium", 50000)); + Write(BigString("large", 100000)); + ASSERT_EQ("small", Read()); + ASSERT_EQ(BigString("medium", 50000), Read()); + ASSERT_EQ(BigString("large", 100000), Read()); + ASSERT_EQ("EOF", Read()); +} + +TEST(LogTest, MarginalTrailer) { + // Make a trailer that is exactly the same length as an empty record. + const int n = kBlockSize - 2*kHeaderSize; + Write(BigString("foo", n)); + ASSERT_EQ(kBlockSize - kHeaderSize, WrittenBytes()); + Write(""); + Write("bar"); + ASSERT_EQ(BigString("foo", n), Read()); + ASSERT_EQ("", Read()); + ASSERT_EQ("bar", Read()); + ASSERT_EQ("EOF", Read()); +} + +TEST(LogTest, MarginalTrailer2) { + // Make a trailer that is exactly the same length as an empty record. + const int n = kBlockSize - 2*kHeaderSize; + Write(BigString("foo", n)); + ASSERT_EQ(kBlockSize - kHeaderSize, WrittenBytes()); + Write("bar"); + ASSERT_EQ(BigString("foo", n), Read()); + ASSERT_EQ("bar", Read()); + ASSERT_EQ("EOF", Read()); + ASSERT_EQ(0, DroppedBytes()); + ASSERT_EQ("", ReportMessage()); +} + +TEST(LogTest, ShortTrailer) { + const int n = kBlockSize - 2*kHeaderSize + 4; + Write(BigString("foo", n)); + ASSERT_EQ(kBlockSize - kHeaderSize + 4, WrittenBytes()); + Write(""); + Write("bar"); + ASSERT_EQ(BigString("foo", n), Read()); + ASSERT_EQ("", Read()); + ASSERT_EQ("bar", Read()); + ASSERT_EQ("EOF", Read()); +} + +TEST(LogTest, AlignedEof) { + const int n = kBlockSize - 2*kHeaderSize + 4; + Write(BigString("foo", n)); + ASSERT_EQ(kBlockSize - kHeaderSize + 4, WrittenBytes()); + ASSERT_EQ(BigString("foo", n), Read()); + ASSERT_EQ("EOF", Read()); +} + +TEST(LogTest, RandomRead) { + const int N = 500; + Random write_rnd(301); + for (int i = 0; i < N; i++) { + Write(RandomSkewedString(i, &write_rnd)); + } + Random read_rnd(301); + for (int i = 0; i < N; i++) { + ASSERT_EQ(RandomSkewedString(i, &read_rnd), Read()); + } + ASSERT_EQ("EOF", Read()); +} + +// Tests of all the error paths in log_reader.cc follow: + +TEST(LogTest, ReadError) { + Write("foo"); + ForceError(); + ASSERT_EQ("EOF", Read()); + ASSERT_EQ(kBlockSize, DroppedBytes()); + ASSERT_EQ("OK", MatchError("read error")); +} + +TEST(LogTest, BadRecordType) { + Write("foo"); + // Type is stored in header[6] + IncrementByte(6, 100); + FixChecksum(0, 3); + ASSERT_EQ("EOF", Read()); + ASSERT_EQ(3, DroppedBytes()); + ASSERT_EQ("OK", MatchError("unknown record type")); +} + +TEST(LogTest, TruncatedTrailingRecord) { + Write("foo"); + ShrinkSize(4); // Drop all payload as well as a header byte + ASSERT_EQ("EOF", Read()); + ASSERT_EQ(kHeaderSize - 1, DroppedBytes()); + ASSERT_EQ("OK", MatchError("truncated record at end of file")); +} + +TEST(LogTest, BadLength) { + Write("foo"); + ShrinkSize(1); + ASSERT_EQ("EOF", Read()); + ASSERT_EQ(kHeaderSize + 2, DroppedBytes()); + ASSERT_EQ("OK", MatchError("bad record length")); +} + +TEST(LogTest, ChecksumMismatch) { + Write("foo"); + IncrementByte(0, 10); + ASSERT_EQ("EOF", Read()); + ASSERT_EQ(10, DroppedBytes()); + ASSERT_EQ("OK", MatchError("checksum mismatch")); +} + +TEST(LogTest, UnexpectedMiddleType) { + Write("foo"); + SetByte(6, kMiddleType); + FixChecksum(0, 3); + ASSERT_EQ("EOF", Read()); + ASSERT_EQ(3, DroppedBytes()); + ASSERT_EQ("OK", MatchError("missing start")); +} + +TEST(LogTest, UnexpectedLastType) { + Write("foo"); + SetByte(6, kLastType); + FixChecksum(0, 3); + ASSERT_EQ("EOF", Read()); + ASSERT_EQ(3, DroppedBytes()); + ASSERT_EQ("OK", MatchError("missing start")); +} + +TEST(LogTest, UnexpectedFullType) { + Write("foo"); + Write("bar"); + SetByte(6, kFirstType); + FixChecksum(0, 3); + ASSERT_EQ("bar", Read()); + ASSERT_EQ("EOF", Read()); + ASSERT_EQ(3, DroppedBytes()); + ASSERT_EQ("OK", MatchError("partial record without end")); +} + +TEST(LogTest, UnexpectedFirstType) { + Write("foo"); + Write(BigString("bar", 100000)); + SetByte(6, kFirstType); + FixChecksum(0, 3); + ASSERT_EQ(BigString("bar", 100000), Read()); + ASSERT_EQ("EOF", Read()); + ASSERT_EQ(3, DroppedBytes()); + ASSERT_EQ("OK", MatchError("partial record without end")); +} + +TEST(LogTest, ErrorJoinsRecords) { + // Consider two fragmented records: + // first(R1) last(R1) first(R2) last(R2) + // where the middle two fragments disappear. We do not want + // first(R1),last(R2) to get joined and returned as a valid record. + + // Write records that span two blocks + Write(BigString("foo", kBlockSize)); + Write(BigString("bar", kBlockSize)); + Write("correct"); + + // Wipe the middle block + for (int offset = kBlockSize; offset < 2*kBlockSize; offset++) { + SetByte(offset, 'x'); + } + + ASSERT_EQ("correct", Read()); + ASSERT_EQ("EOF", Read()); + const int dropped = DroppedBytes(); + ASSERT_LE(dropped, 2*kBlockSize + 100); + ASSERT_GE(dropped, 2*kBlockSize); +} + +TEST(LogTest, ReadStart) { + CheckInitialOffsetRecord(0, 0); +} + +TEST(LogTest, ReadSecondOneOff) { + CheckInitialOffsetRecord(1, 1); +} + +TEST(LogTest, ReadSecondTenThousand) { + CheckInitialOffsetRecord(10000, 1); +} + +TEST(LogTest, ReadSecondStart) { + CheckInitialOffsetRecord(10007, 1); +} + +TEST(LogTest, ReadThirdOneOff) { + CheckInitialOffsetRecord(10008, 2); +} + +TEST(LogTest, ReadThirdStart) { + CheckInitialOffsetRecord(20014, 2); +} + +TEST(LogTest, ReadFourthOneOff) { + CheckInitialOffsetRecord(20015, 3); +} + +TEST(LogTest, ReadFourthFirstBlockTrailer) { + CheckInitialOffsetRecord(log::kBlockSize - 4, 3); +} + +TEST(LogTest, ReadFourthMiddleBlock) { + CheckInitialOffsetRecord(log::kBlockSize + 1, 3); +} + +TEST(LogTest, ReadFourthLastBlock) { + CheckInitialOffsetRecord(2 * log::kBlockSize + 1, 3); +} + +TEST(LogTest, ReadFourthStart) { + CheckInitialOffsetRecord( + 2 * (kHeaderSize + 1000) + (2 * log::kBlockSize - 1000) + 3 * kHeaderSize, + 3); +} + +TEST(LogTest, ReadEnd) { + CheckOffsetPastEndReturnsNoRecords(0); +} + +TEST(LogTest, ReadPastEnd) { + CheckOffsetPastEndReturnsNoRecords(5); +} + +} // namespace log +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/db/log_writer.cc b/src/leveldb/db/log_writer.cc new file mode 100644 index 0000000..2da99ac --- /dev/null +++ b/src/leveldb/db/log_writer.cc @@ -0,0 +1,103 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/log_writer.h" + +#include +#include "leveldb/env.h" +#include "util/coding.h" +#include "util/crc32c.h" + +namespace leveldb { +namespace log { + +Writer::Writer(WritableFile* dest) + : dest_(dest), + block_offset_(0) { + for (int i = 0; i <= kMaxRecordType; i++) { + char t = static_cast(i); + type_crc_[i] = crc32c::Value(&t, 1); + } +} + +Writer::~Writer() { +} + +Status Writer::AddRecord(const Slice& slice) { + const char* ptr = slice.data(); + size_t left = slice.size(); + + // Fragment the record if necessary and emit it. Note that if slice + // is empty, we still want to iterate once to emit a single + // zero-length record + Status s; + bool begin = true; + do { + const int leftover = kBlockSize - block_offset_; + assert(leftover >= 0); + if (leftover < kHeaderSize) { + // Switch to a new block + if (leftover > 0) { + // Fill the trailer (literal below relies on kHeaderSize being 7) + assert(kHeaderSize == 7); + dest_->Append(Slice("\x00\x00\x00\x00\x00\x00", leftover)); + } + block_offset_ = 0; + } + + // Invariant: we never leave < kHeaderSize bytes in a block. + assert(kBlockSize - block_offset_ - kHeaderSize >= 0); + + const size_t avail = kBlockSize - block_offset_ - kHeaderSize; + const size_t fragment_length = (left < avail) ? left : avail; + + RecordType type; + const bool end = (left == fragment_length); + if (begin && end) { + type = kFullType; + } else if (begin) { + type = kFirstType; + } else if (end) { + type = kLastType; + } else { + type = kMiddleType; + } + + s = EmitPhysicalRecord(type, ptr, fragment_length); + ptr += fragment_length; + left -= fragment_length; + begin = false; + } while (s.ok() && left > 0); + return s; +} + +Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr, size_t n) { + assert(n <= 0xffff); // Must fit in two bytes + assert(block_offset_ + kHeaderSize + n <= kBlockSize); + + // Format the header + char buf[kHeaderSize]; + buf[4] = static_cast(n & 0xff); + buf[5] = static_cast(n >> 8); + buf[6] = static_cast(t); + + // Compute the crc of the record type and the payload. + uint32_t crc = crc32c::Extend(type_crc_[t], ptr, n); + crc = crc32c::Mask(crc); // Adjust for storage + EncodeFixed32(buf, crc); + + // Write the header and the payload + Status s = dest_->Append(Slice(buf, kHeaderSize)); + if (s.ok()) { + s = dest_->Append(Slice(ptr, n)); + if (s.ok()) { + s = dest_->Flush(); + } + } + block_offset_ += kHeaderSize + n; + return s; +} + +} // namespace log +} // namespace leveldb diff --git a/src/leveldb/db/log_writer.h b/src/leveldb/db/log_writer.h new file mode 100644 index 0000000..a3a954d --- /dev/null +++ b/src/leveldb/db/log_writer.h @@ -0,0 +1,48 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_DB_LOG_WRITER_H_ +#define STORAGE_LEVELDB_DB_LOG_WRITER_H_ + +#include +#include "db/log_format.h" +#include "leveldb/slice.h" +#include "leveldb/status.h" + +namespace leveldb { + +class WritableFile; + +namespace log { + +class Writer { + public: + // Create a writer that will append data to "*dest". + // "*dest" must be initially empty. + // "*dest" must remain live while this Writer is in use. + explicit Writer(WritableFile* dest); + ~Writer(); + + Status AddRecord(const Slice& slice); + + private: + WritableFile* dest_; + int block_offset_; // Current offset in block + + // crc32c values for all supported record types. These are + // pre-computed to reduce the overhead of computing the crc of the + // record type stored in the header. + uint32_t type_crc_[kMaxRecordType + 1]; + + Status EmitPhysicalRecord(RecordType type, const char* ptr, size_t length); + + // No copying allowed + Writer(const Writer&); + void operator=(const Writer&); +}; + +} // namespace log +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_LOG_WRITER_H_ diff --git a/src/leveldb/db/memtable.cc b/src/leveldb/db/memtable.cc new file mode 100644 index 0000000..bfec0a7 --- /dev/null +++ b/src/leveldb/db/memtable.cc @@ -0,0 +1,145 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/memtable.h" +#include "db/dbformat.h" +#include "leveldb/comparator.h" +#include "leveldb/env.h" +#include "leveldb/iterator.h" +#include "util/coding.h" + +namespace leveldb { + +static Slice GetLengthPrefixedSlice(const char* data) { + uint32_t len; + const char* p = data; + p = GetVarint32Ptr(p, p + 5, &len); // +5: we assume "p" is not corrupted + return Slice(p, len); +} + +MemTable::MemTable(const InternalKeyComparator& cmp) + : comparator_(cmp), + refs_(0), + table_(comparator_, &arena_) { +} + +MemTable::~MemTable() { + assert(refs_ == 0); +} + +size_t MemTable::ApproximateMemoryUsage() { return arena_.MemoryUsage(); } + +int MemTable::KeyComparator::operator()(const char* aptr, const char* bptr) + const { + // Internal keys are encoded as length-prefixed strings. + Slice a = GetLengthPrefixedSlice(aptr); + Slice b = GetLengthPrefixedSlice(bptr); + return comparator.Compare(a, b); +} + +// Encode a suitable internal key target for "target" and return it. +// Uses *scratch as scratch space, and the returned pointer will point +// into this scratch space. +static const char* EncodeKey(std::string* scratch, const Slice& target) { + scratch->clear(); + PutVarint32(scratch, target.size()); + scratch->append(target.data(), target.size()); + return scratch->data(); +} + +class MemTableIterator: public Iterator { + public: + explicit MemTableIterator(MemTable::Table* table) : iter_(table) { } + + virtual bool Valid() const { return iter_.Valid(); } + virtual void Seek(const Slice& k) { iter_.Seek(EncodeKey(&tmp_, k)); } + virtual void SeekToFirst() { iter_.SeekToFirst(); } + virtual void SeekToLast() { iter_.SeekToLast(); } + virtual void Next() { iter_.Next(); } + virtual void Prev() { iter_.Prev(); } + virtual Slice key() const { return GetLengthPrefixedSlice(iter_.key()); } + virtual Slice value() const { + Slice key_slice = GetLengthPrefixedSlice(iter_.key()); + return GetLengthPrefixedSlice(key_slice.data() + key_slice.size()); + } + + virtual Status status() const { return Status::OK(); } + + private: + MemTable::Table::Iterator iter_; + std::string tmp_; // For passing to EncodeKey + + // No copying allowed + MemTableIterator(const MemTableIterator&); + void operator=(const MemTableIterator&); +}; + +Iterator* MemTable::NewIterator() { + return new MemTableIterator(&table_); +} + +void MemTable::Add(SequenceNumber s, ValueType type, + const Slice& key, + const Slice& value) { + // Format of an entry is concatenation of: + // key_size : varint32 of internal_key.size() + // key bytes : char[internal_key.size()] + // value_size : varint32 of value.size() + // value bytes : char[value.size()] + size_t key_size = key.size(); + size_t val_size = value.size(); + size_t internal_key_size = key_size + 8; + const size_t encoded_len = + VarintLength(internal_key_size) + internal_key_size + + VarintLength(val_size) + val_size; + char* buf = arena_.Allocate(encoded_len); + char* p = EncodeVarint32(buf, internal_key_size); + memcpy(p, key.data(), key_size); + p += key_size; + EncodeFixed64(p, (s << 8) | type); + p += 8; + p = EncodeVarint32(p, val_size); + memcpy(p, value.data(), val_size); + assert((p + val_size) - buf == encoded_len); + table_.Insert(buf); +} + +bool MemTable::Get(const LookupKey& key, std::string* value, Status* s) { + Slice memkey = key.memtable_key(); + Table::Iterator iter(&table_); + iter.Seek(memkey.data()); + if (iter.Valid()) { + // entry format is: + // klength varint32 + // userkey char[klength] + // tag uint64 + // vlength varint32 + // value char[vlength] + // Check that it belongs to same user key. We do not check the + // sequence number since the Seek() call above should have skipped + // all entries with overly large sequence numbers. + const char* entry = iter.key(); + uint32_t key_length; + const char* key_ptr = GetVarint32Ptr(entry, entry+5, &key_length); + if (comparator_.comparator.user_comparator()->Compare( + Slice(key_ptr, key_length - 8), + key.user_key()) == 0) { + // Correct user key + const uint64_t tag = DecodeFixed64(key_ptr + key_length - 8); + switch (static_cast(tag & 0xff)) { + case kTypeValue: { + Slice v = GetLengthPrefixedSlice(key_ptr + key_length); + value->assign(v.data(), v.size()); + return true; + } + case kTypeDeletion: + *s = Status::NotFound(Slice()); + return true; + } + } + } + return false; +} + +} // namespace leveldb diff --git a/src/leveldb/db/memtable.h b/src/leveldb/db/memtable.h new file mode 100644 index 0000000..92e90bb --- /dev/null +++ b/src/leveldb/db/memtable.h @@ -0,0 +1,91 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_DB_MEMTABLE_H_ +#define STORAGE_LEVELDB_DB_MEMTABLE_H_ + +#include +#include "leveldb/db.h" +#include "db/dbformat.h" +#include "db/skiplist.h" +#include "util/arena.h" + +namespace leveldb { + +class InternalKeyComparator; +class Mutex; +class MemTableIterator; + +class MemTable { + public: + // MemTables are reference counted. The initial reference count + // is zero and the caller must call Ref() at least once. + explicit MemTable(const InternalKeyComparator& comparator); + + // Increase reference count. + void Ref() { ++refs_; } + + // Drop reference count. Delete if no more references exist. + void Unref() { + --refs_; + assert(refs_ >= 0); + if (refs_ <= 0) { + delete this; + } + } + + // Returns an estimate of the number of bytes of data in use by this + // data structure. + // + // REQUIRES: external synchronization to prevent simultaneous + // operations on the same MemTable. + size_t ApproximateMemoryUsage(); + + // Return an iterator that yields the contents of the memtable. + // + // The caller must ensure that the underlying MemTable remains live + // while the returned iterator is live. The keys returned by this + // iterator are internal keys encoded by AppendInternalKey in the + // db/format.{h,cc} module. + Iterator* NewIterator(); + + // Add an entry into memtable that maps key to value at the + // specified sequence number and with the specified type. + // Typically value will be empty if type==kTypeDeletion. + void Add(SequenceNumber seq, ValueType type, + const Slice& key, + const Slice& value); + + // If memtable contains a value for key, store it in *value and return true. + // If memtable contains a deletion for key, store a NotFound() error + // in *status and return true. + // Else, return false. + bool Get(const LookupKey& key, std::string* value, Status* s); + + private: + ~MemTable(); // Private since only Unref() should be used to delete it + + struct KeyComparator { + const InternalKeyComparator comparator; + explicit KeyComparator(const InternalKeyComparator& c) : comparator(c) { } + int operator()(const char* a, const char* b) const; + }; + friend class MemTableIterator; + friend class MemTableBackwardIterator; + + typedef SkipList Table; + + KeyComparator comparator_; + int refs_; + Arena arena_; + Table table_; + + // No copying allowed + MemTable(const MemTable&); + void operator=(const MemTable&); +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_MEMTABLE_H_ diff --git a/src/leveldb/db/repair.cc b/src/leveldb/db/repair.cc new file mode 100644 index 0000000..96c9b37 --- /dev/null +++ b/src/leveldb/db/repair.cc @@ -0,0 +1,462 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// We recover the contents of the descriptor from the other files we find. +// (1) Any log files are first converted to tables +// (2) We scan every table to compute +// (a) smallest/largest for the table +// (b) largest sequence number in the table +// (3) We generate descriptor contents: +// - log number is set to zero +// - next-file-number is set to 1 + largest file number we found +// - last-sequence-number is set to largest sequence# found across +// all tables (see 2c) +// - compaction pointers are cleared +// - every table file is added at level 0 +// +// Possible optimization 1: +// (a) Compute total size and use to pick appropriate max-level M +// (b) Sort tables by largest sequence# in the table +// (c) For each table: if it overlaps earlier table, place in level-0, +// else place in level-M. +// Possible optimization 2: +// Store per-table metadata (smallest, largest, largest-seq#, ...) +// in the table's meta section to speed up ScanTable. + +#include "db/builder.h" +#include "db/db_impl.h" +#include "db/dbformat.h" +#include "db/filename.h" +#include "db/log_reader.h" +#include "db/log_writer.h" +#include "db/memtable.h" +#include "db/table_cache.h" +#include "db/version_edit.h" +#include "db/write_batch_internal.h" +#include "leveldb/comparator.h" +#include "leveldb/db.h" +#include "leveldb/env.h" + +namespace leveldb { + +namespace { + +class Repairer { + public: + Repairer(const std::string& dbname, const Options& options) + : dbname_(dbname), + env_(options.env), + icmp_(options.comparator), + ipolicy_(options.filter_policy), + options_(SanitizeOptions(dbname, &icmp_, &ipolicy_, options)), + owns_info_log_(options_.info_log != options.info_log), + owns_cache_(options_.block_cache != options.block_cache), + next_file_number_(1) { + // TableCache can be small since we expect each table to be opened once. + table_cache_ = new TableCache(dbname_, &options_, 10); + } + + ~Repairer() { + delete table_cache_; + if (owns_info_log_) { + delete options_.info_log; + } + if (owns_cache_) { + delete options_.block_cache; + } + } + + Status Run() { + Status status = FindFiles(); + if (status.ok()) { + ConvertLogFilesToTables(); + ExtractMetaData(); + status = WriteDescriptor(); + } + if (status.ok()) { + unsigned long long bytes = 0; + for (size_t i = 0; i < tables_.size(); i++) { + bytes += tables_[i].meta.file_size; + } + Log(options_.info_log, + "**** Repaired leveldb %s; " + "recovered %d files; %llu bytes. " + "Some data may have been lost. " + "****", + dbname_.c_str(), + static_cast(tables_.size()), + bytes); + } + return status; + } + + private: + struct TableInfo { + FileMetaData meta; + SequenceNumber max_sequence; + }; + + std::string const dbname_; + Env* const env_; + InternalKeyComparator const icmp_; + InternalFilterPolicy const ipolicy_; + Options const options_; + bool owns_info_log_; + bool owns_cache_; + TableCache* table_cache_; + VersionEdit edit_; + + std::vector manifests_; + std::vector table_numbers_; + std::vector logs_; + std::vector tables_; + uint64_t next_file_number_; + + Status FindFiles() { + std::vector filenames; + Status status = env_->GetChildren(dbname_, &filenames); + if (!status.ok()) { + return status; + } + if (filenames.empty()) { + return Status::IOError(dbname_, "repair found no files"); + } + + uint64_t number; + FileType type; + for (size_t i = 0; i < filenames.size(); i++) { + if (ParseFileName(filenames[i], &number, &type)) { + if (type == kDescriptorFile) { + manifests_.push_back(filenames[i]); + } else { + if (number + 1 > next_file_number_) { + next_file_number_ = number + 1; + } + if (type == kLogFile) { + logs_.push_back(number); + } else if (type == kTableFile) { + table_numbers_.push_back(number); + } else { + // Ignore other files + } + } + } + } + return status; + } + + void ConvertLogFilesToTables() { + for (size_t i = 0; i < logs_.size(); i++) { + std::string logname = LogFileName(dbname_, logs_[i]); + Status status = ConvertLogToTable(logs_[i]); + if (!status.ok()) { + Log(options_.info_log, "Log #%llu: ignoring conversion error: %s", + (unsigned long long) logs_[i], + status.ToString().c_str()); + } + ArchiveFile(logname); + } + } + + Status ConvertLogToTable(uint64_t log) { + struct LogReporter : public log::Reader::Reporter { + Env* env; + Logger* info_log; + uint64_t lognum; + virtual void Corruption(size_t bytes, const Status& s) { + // We print error messages for corruption, but continue repairing. + Log(info_log, "Log #%llu: dropping %d bytes; %s", + (unsigned long long) lognum, + static_cast(bytes), + s.ToString().c_str()); + } + }; + + // Open the log file + std::string logname = LogFileName(dbname_, log); + SequentialFile* lfile; + Status status = env_->NewSequentialFile(logname, &lfile); + if (!status.ok()) { + return status; + } + + // Create the log reader. + LogReporter reporter; + reporter.env = env_; + reporter.info_log = options_.info_log; + reporter.lognum = log; + // We intentially make log::Reader do checksumming so that + // corruptions cause entire commits to be skipped instead of + // propagating bad information (like overly large sequence + // numbers). + log::Reader reader(lfile, &reporter, false/*do not checksum*/, + 0/*initial_offset*/); + + // Read all the records and add to a memtable + std::string scratch; + Slice record; + WriteBatch batch; + MemTable* mem = new MemTable(icmp_); + mem->Ref(); + int counter = 0; + while (reader.ReadRecord(&record, &scratch)) { + if (record.size() < 12) { + reporter.Corruption( + record.size(), Status::Corruption("log record too small")); + continue; + } + WriteBatchInternal::SetContents(&batch, record); + status = WriteBatchInternal::InsertInto(&batch, mem); + if (status.ok()) { + counter += WriteBatchInternal::Count(&batch); + } else { + Log(options_.info_log, "Log #%llu: ignoring %s", + (unsigned long long) log, + status.ToString().c_str()); + status = Status::OK(); // Keep going with rest of file + } + } + delete lfile; + + // Do not record a version edit for this conversion to a Table + // since ExtractMetaData() will also generate edits. + FileMetaData meta; + meta.number = next_file_number_++; + Iterator* iter = mem->NewIterator(); + status = BuildTable(dbname_, env_, options_, table_cache_, iter, &meta); + delete iter; + mem->Unref(); + mem = NULL; + if (status.ok()) { + if (meta.file_size > 0) { + table_numbers_.push_back(meta.number); + } + } + Log(options_.info_log, "Log #%llu: %d ops saved to Table #%llu %s", + (unsigned long long) log, + counter, + (unsigned long long) meta.number, + status.ToString().c_str()); + return status; + } + + void ExtractMetaData() { + std::vector kept; + for (size_t i = 0; i < table_numbers_.size(); i++) { + ScanTable(table_numbers_[i]); + } + } + + Iterator* NewTableIterator(const FileMetaData& meta) { + // Same as compaction iterators: if paranoid_checks are on, turn + // on checksum verification. + ReadOptions r; + r.verify_checksums = options_.paranoid_checks; + return table_cache_->NewIterator(r, meta.number, meta.file_size); + } + + void ScanTable(uint64_t number) { + TableInfo t; + t.meta.number = number; + std::string fname = TableFileName(dbname_, number); + Status status = env_->GetFileSize(fname, &t.meta.file_size); + if (!status.ok()) { + // Try alternate file name. + fname = SSTTableFileName(dbname_, number); + Status s2 = env_->GetFileSize(fname, &t.meta.file_size); + if (s2.ok()) { + status = Status::OK(); + } + } + if (!status.ok()) { + ArchiveFile(TableFileName(dbname_, number)); + ArchiveFile(SSTTableFileName(dbname_, number)); + Log(options_.info_log, "Table #%llu: dropped: %s", + (unsigned long long) t.meta.number, + status.ToString().c_str()); + return; + } + + // Extract metadata by scanning through table. + int counter = 0; + Iterator* iter = NewTableIterator(t.meta); + bool empty = true; + ParsedInternalKey parsed; + t.max_sequence = 0; + for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { + Slice key = iter->key(); + if (!ParseInternalKey(key, &parsed)) { + Log(options_.info_log, "Table #%llu: unparsable key %s", + (unsigned long long) t.meta.number, + EscapeString(key).c_str()); + continue; + } + + counter++; + if (empty) { + empty = false; + t.meta.smallest.DecodeFrom(key); + } + t.meta.largest.DecodeFrom(key); + if (parsed.sequence > t.max_sequence) { + t.max_sequence = parsed.sequence; + } + } + if (!iter->status().ok()) { + status = iter->status(); + } + delete iter; + Log(options_.info_log, "Table #%llu: %d entries %s", + (unsigned long long) t.meta.number, + counter, + status.ToString().c_str()); + + if (status.ok()) { + tables_.push_back(t); + } else { + RepairTable(fname, t); // RepairTable archives input file. + } + } + + void RepairTable(const std::string& src, TableInfo t) { + // We will copy src contents to a new table and then rename the + // new table over the source. + + // Create builder. + std::string copy = TableFileName(dbname_, next_file_number_++); + WritableFile* file; + Status s = env_->NewWritableFile(copy, &file); + if (!s.ok()) { + return; + } + TableBuilder* builder = new TableBuilder(options_, file); + + // Copy data. + Iterator* iter = NewTableIterator(t.meta); + int counter = 0; + for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { + builder->Add(iter->key(), iter->value()); + counter++; + } + delete iter; + + ArchiveFile(src); + if (counter == 0) { + builder->Abandon(); // Nothing to save + } else { + s = builder->Finish(); + if (s.ok()) { + t.meta.file_size = builder->FileSize(); + } + } + delete builder; + builder = NULL; + + if (s.ok()) { + s = file->Close(); + } + delete file; + file = NULL; + + if (counter > 0 && s.ok()) { + std::string orig = TableFileName(dbname_, t.meta.number); + s = env_->RenameFile(copy, orig); + if (s.ok()) { + Log(options_.info_log, "Table #%llu: %d entries repaired", + (unsigned long long) t.meta.number, counter); + tables_.push_back(t); + } + } + if (!s.ok()) { + env_->DeleteFile(copy); + } + } + + Status WriteDescriptor() { + std::string tmp = TempFileName(dbname_, 1); + WritableFile* file; + Status status = env_->NewWritableFile(tmp, &file); + if (!status.ok()) { + return status; + } + + SequenceNumber max_sequence = 0; + for (size_t i = 0; i < tables_.size(); i++) { + if (max_sequence < tables_[i].max_sequence) { + max_sequence = tables_[i].max_sequence; + } + } + + edit_.SetComparatorName(icmp_.user_comparator()->Name()); + edit_.SetLogNumber(0); + edit_.SetNextFile(next_file_number_); + edit_.SetLastSequence(max_sequence); + + for (size_t i = 0; i < tables_.size(); i++) { + // TODO(opt): separate out into multiple levels + const TableInfo& t = tables_[i]; + edit_.AddFile(0, t.meta.number, t.meta.file_size, + t.meta.smallest, t.meta.largest); + } + + //fprintf(stderr, "NewDescriptor:\n%s\n", edit_.DebugString().c_str()); + { + log::Writer log(file); + std::string record; + edit_.EncodeTo(&record); + status = log.AddRecord(record); + } + if (status.ok()) { + status = file->Close(); + } + delete file; + file = NULL; + + if (!status.ok()) { + env_->DeleteFile(tmp); + } else { + // Discard older manifests + for (size_t i = 0; i < manifests_.size(); i++) { + ArchiveFile(dbname_ + "/" + manifests_[i]); + } + + // Install new manifest + status = env_->RenameFile(tmp, DescriptorFileName(dbname_, 1)); + if (status.ok()) { + status = SetCurrentFile(env_, dbname_, 1); + } else { + env_->DeleteFile(tmp); + } + } + return status; + } + + void ArchiveFile(const std::string& fname) { + // Move into another directory. E.g., for + // dir/foo + // rename to + // dir/lost/foo + const char* slash = strrchr(fname.c_str(), '/'); + std::string new_dir; + if (slash != NULL) { + new_dir.assign(fname.data(), slash - fname.data()); + } + new_dir.append("/lost"); + env_->CreateDir(new_dir); // Ignore error + std::string new_file = new_dir; + new_file.append("/"); + new_file.append((slash == NULL) ? fname.c_str() : slash + 1); + Status s = env_->RenameFile(fname, new_file); + Log(options_.info_log, "Archiving %s: %s\n", + fname.c_str(), s.ToString().c_str()); + } +}; +} // namespace + +Status RepairDB(const std::string& dbname, const Options& options) { + Repairer repairer(dbname, options); + return repairer.Run(); +} + +} // namespace leveldb diff --git a/src/leveldb/db/skiplist.h b/src/leveldb/db/skiplist.h new file mode 100644 index 0000000..af85be6 --- /dev/null +++ b/src/leveldb/db/skiplist.h @@ -0,0 +1,379 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// Thread safety +// ------------- +// +// Writes require external synchronization, most likely a mutex. +// Reads require a guarantee that the SkipList will not be destroyed +// while the read is in progress. Apart from that, reads progress +// without any internal locking or synchronization. +// +// Invariants: +// +// (1) Allocated nodes are never deleted until the SkipList is +// destroyed. This is trivially guaranteed by the code since we +// never delete any skip list nodes. +// +// (2) The contents of a Node except for the next/prev pointers are +// immutable after the Node has been linked into the SkipList. +// Only Insert() modifies the list, and it is careful to initialize +// a node and use release-stores to publish the nodes in one or +// more lists. +// +// ... prev vs. next pointer ordering ... + +#include +#include +#include "port/port.h" +#include "util/arena.h" +#include "util/random.h" + +namespace leveldb { + +class Arena; + +template +class SkipList { + private: + struct Node; + + public: + // Create a new SkipList object that will use "cmp" for comparing keys, + // and will allocate memory using "*arena". Objects allocated in the arena + // must remain allocated for the lifetime of the skiplist object. + explicit SkipList(Comparator cmp, Arena* arena); + + // Insert key into the list. + // REQUIRES: nothing that compares equal to key is currently in the list. + void Insert(const Key& key); + + // Returns true iff an entry that compares equal to key is in the list. + bool Contains(const Key& key) const; + + // Iteration over the contents of a skip list + class Iterator { + public: + // Initialize an iterator over the specified list. + // The returned iterator is not valid. + explicit Iterator(const SkipList* list); + + // Returns true iff the iterator is positioned at a valid node. + bool Valid() const; + + // Returns the key at the current position. + // REQUIRES: Valid() + const Key& key() const; + + // Advances to the next position. + // REQUIRES: Valid() + void Next(); + + // Advances to the previous position. + // REQUIRES: Valid() + void Prev(); + + // Advance to the first entry with a key >= target + void Seek(const Key& target); + + // Position at the first entry in list. + // Final state of iterator is Valid() iff list is not empty. + void SeekToFirst(); + + // Position at the last entry in list. + // Final state of iterator is Valid() iff list is not empty. + void SeekToLast(); + + private: + const SkipList* list_; + Node* node_; + // Intentionally copyable + }; + + private: + enum { kMaxHeight = 12 }; + + // Immutable after construction + Comparator const compare_; + Arena* const arena_; // Arena used for allocations of nodes + + Node* const head_; + + // Modified only by Insert(). Read racily by readers, but stale + // values are ok. + port::AtomicPointer max_height_; // Height of the entire list + + inline int GetMaxHeight() const { + return static_cast( + reinterpret_cast(max_height_.NoBarrier_Load())); + } + + // Read/written only by Insert(). + Random rnd_; + + Node* NewNode(const Key& key, int height); + int RandomHeight(); + bool Equal(const Key& a, const Key& b) const { return (compare_(a, b) == 0); } + + // Return true if key is greater than the data stored in "n" + bool KeyIsAfterNode(const Key& key, Node* n) const; + + // Return the earliest node that comes at or after key. + // Return NULL if there is no such node. + // + // If prev is non-NULL, fills prev[level] with pointer to previous + // node at "level" for every level in [0..max_height_-1]. + Node* FindGreaterOrEqual(const Key& key, Node** prev) const; + + // Return the latest node with a key < key. + // Return head_ if there is no such node. + Node* FindLessThan(const Key& key) const; + + // Return the last node in the list. + // Return head_ if list is empty. + Node* FindLast() const; + + // No copying allowed + SkipList(const SkipList&); + void operator=(const SkipList&); +}; + +// Implementation details follow +template +struct SkipList::Node { + explicit Node(const Key& k) : key(k) { } + + Key const key; + + // Accessors/mutators for links. Wrapped in methods so we can + // add the appropriate barriers as necessary. + Node* Next(int n) { + assert(n >= 0); + // Use an 'acquire load' so that we observe a fully initialized + // version of the returned Node. + return reinterpret_cast(next_[n].Acquire_Load()); + } + void SetNext(int n, Node* x) { + assert(n >= 0); + // Use a 'release store' so that anybody who reads through this + // pointer observes a fully initialized version of the inserted node. + next_[n].Release_Store(x); + } + + // No-barrier variants that can be safely used in a few locations. + Node* NoBarrier_Next(int n) { + assert(n >= 0); + return reinterpret_cast(next_[n].NoBarrier_Load()); + } + void NoBarrier_SetNext(int n, Node* x) { + assert(n >= 0); + next_[n].NoBarrier_Store(x); + } + + private: + // Array of length equal to the node height. next_[0] is lowest level link. + port::AtomicPointer next_[1]; +}; + +template +typename SkipList::Node* +SkipList::NewNode(const Key& key, int height) { + char* mem = arena_->AllocateAligned( + sizeof(Node) + sizeof(port::AtomicPointer) * (height - 1)); + return new (mem) Node(key); +} + +template +inline SkipList::Iterator::Iterator(const SkipList* list) { + list_ = list; + node_ = NULL; +} + +template +inline bool SkipList::Iterator::Valid() const { + return node_ != NULL; +} + +template +inline const Key& SkipList::Iterator::key() const { + assert(Valid()); + return node_->key; +} + +template +inline void SkipList::Iterator::Next() { + assert(Valid()); + node_ = node_->Next(0); +} + +template +inline void SkipList::Iterator::Prev() { + // Instead of using explicit "prev" links, we just search for the + // last node that falls before key. + assert(Valid()); + node_ = list_->FindLessThan(node_->key); + if (node_ == list_->head_) { + node_ = NULL; + } +} + +template +inline void SkipList::Iterator::Seek(const Key& target) { + node_ = list_->FindGreaterOrEqual(target, NULL); +} + +template +inline void SkipList::Iterator::SeekToFirst() { + node_ = list_->head_->Next(0); +} + +template +inline void SkipList::Iterator::SeekToLast() { + node_ = list_->FindLast(); + if (node_ == list_->head_) { + node_ = NULL; + } +} + +template +int SkipList::RandomHeight() { + // Increase height with probability 1 in kBranching + static const unsigned int kBranching = 4; + int height = 1; + while (height < kMaxHeight && ((rnd_.Next() % kBranching) == 0)) { + height++; + } + assert(height > 0); + assert(height <= kMaxHeight); + return height; +} + +template +bool SkipList::KeyIsAfterNode(const Key& key, Node* n) const { + // NULL n is considered infinite + return (n != NULL) && (compare_(n->key, key) < 0); +} + +template +typename SkipList::Node* SkipList::FindGreaterOrEqual(const Key& key, Node** prev) + const { + Node* x = head_; + int level = GetMaxHeight() - 1; + while (true) { + Node* next = x->Next(level); + if (KeyIsAfterNode(key, next)) { + // Keep searching in this list + x = next; + } else { + if (prev != NULL) prev[level] = x; + if (level == 0) { + return next; + } else { + // Switch to next list + level--; + } + } + } +} + +template +typename SkipList::Node* +SkipList::FindLessThan(const Key& key) const { + Node* x = head_; + int level = GetMaxHeight() - 1; + while (true) { + assert(x == head_ || compare_(x->key, key) < 0); + Node* next = x->Next(level); + if (next == NULL || compare_(next->key, key) >= 0) { + if (level == 0) { + return x; + } else { + // Switch to next list + level--; + } + } else { + x = next; + } + } +} + +template +typename SkipList::Node* SkipList::FindLast() + const { + Node* x = head_; + int level = GetMaxHeight() - 1; + while (true) { + Node* next = x->Next(level); + if (next == NULL) { + if (level == 0) { + return x; + } else { + // Switch to next list + level--; + } + } else { + x = next; + } + } +} + +template +SkipList::SkipList(Comparator cmp, Arena* arena) + : compare_(cmp), + arena_(arena), + head_(NewNode(0 /* any key will do */, kMaxHeight)), + max_height_(reinterpret_cast(1)), + rnd_(0xdeadbeef) { + for (int i = 0; i < kMaxHeight; i++) { + head_->SetNext(i, NULL); + } +} + +template +void SkipList::Insert(const Key& key) { + // TODO(opt): We can use a barrier-free variant of FindGreaterOrEqual() + // here since Insert() is externally synchronized. + Node* prev[kMaxHeight]; + Node* x = FindGreaterOrEqual(key, prev); + + // Our data structure does not allow duplicate insertion + assert(x == NULL || !Equal(key, x->key)); + + int height = RandomHeight(); + if (height > GetMaxHeight()) { + for (int i = GetMaxHeight(); i < height; i++) { + prev[i] = head_; + } + //fprintf(stderr, "Change height from %d to %d\n", max_height_, height); + + // It is ok to mutate max_height_ without any synchronization + // with concurrent readers. A concurrent reader that observes + // the new value of max_height_ will see either the old value of + // new level pointers from head_ (NULL), or a new value set in + // the loop below. In the former case the reader will + // immediately drop to the next level since NULL sorts after all + // keys. In the latter case the reader will use the new node. + max_height_.NoBarrier_Store(reinterpret_cast(height)); + } + + x = NewNode(key, height); + for (int i = 0; i < height; i++) { + // NoBarrier_SetNext() suffices since we will add a barrier when + // we publish a pointer to "x" in prev[i]. + x->NoBarrier_SetNext(i, prev[i]->NoBarrier_Next(i)); + prev[i]->SetNext(i, x); + } +} + +template +bool SkipList::Contains(const Key& key) const { + Node* x = FindGreaterOrEqual(key, NULL); + if (x != NULL && Equal(key, x->key)) { + return true; + } else { + return false; + } +} + +} // namespace leveldb diff --git a/src/leveldb/db/skiplist_test.cc b/src/leveldb/db/skiplist_test.cc new file mode 100644 index 0000000..c78f4b4 --- /dev/null +++ b/src/leveldb/db/skiplist_test.cc @@ -0,0 +1,378 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/skiplist.h" +#include +#include "leveldb/env.h" +#include "util/arena.h" +#include "util/hash.h" +#include "util/random.h" +#include "util/testharness.h" + +namespace leveldb { + +typedef uint64_t Key; + +struct Comparator { + int operator()(const Key& a, const Key& b) const { + if (a < b) { + return -1; + } else if (a > b) { + return +1; + } else { + return 0; + } + } +}; + +class SkipTest { }; + +TEST(SkipTest, Empty) { + Arena arena; + Comparator cmp; + SkipList list(cmp, &arena); + ASSERT_TRUE(!list.Contains(10)); + + SkipList::Iterator iter(&list); + ASSERT_TRUE(!iter.Valid()); + iter.SeekToFirst(); + ASSERT_TRUE(!iter.Valid()); + iter.Seek(100); + ASSERT_TRUE(!iter.Valid()); + iter.SeekToLast(); + ASSERT_TRUE(!iter.Valid()); +} + +TEST(SkipTest, InsertAndLookup) { + const int N = 2000; + const int R = 5000; + Random rnd(1000); + std::set keys; + Arena arena; + Comparator cmp; + SkipList list(cmp, &arena); + for (int i = 0; i < N; i++) { + Key key = rnd.Next() % R; + if (keys.insert(key).second) { + list.Insert(key); + } + } + + for (int i = 0; i < R; i++) { + if (list.Contains(i)) { + ASSERT_EQ(keys.count(i), 1); + } else { + ASSERT_EQ(keys.count(i), 0); + } + } + + // Simple iterator tests + { + SkipList::Iterator iter(&list); + ASSERT_TRUE(!iter.Valid()); + + iter.Seek(0); + ASSERT_TRUE(iter.Valid()); + ASSERT_EQ(*(keys.begin()), iter.key()); + + iter.SeekToFirst(); + ASSERT_TRUE(iter.Valid()); + ASSERT_EQ(*(keys.begin()), iter.key()); + + iter.SeekToLast(); + ASSERT_TRUE(iter.Valid()); + ASSERT_EQ(*(keys.rbegin()), iter.key()); + } + + // Forward iteration test + for (int i = 0; i < R; i++) { + SkipList::Iterator iter(&list); + iter.Seek(i); + + // Compare against model iterator + std::set::iterator model_iter = keys.lower_bound(i); + for (int j = 0; j < 3; j++) { + if (model_iter == keys.end()) { + ASSERT_TRUE(!iter.Valid()); + break; + } else { + ASSERT_TRUE(iter.Valid()); + ASSERT_EQ(*model_iter, iter.key()); + ++model_iter; + iter.Next(); + } + } + } + + // Backward iteration test + { + SkipList::Iterator iter(&list); + iter.SeekToLast(); + + // Compare against model iterator + for (std::set::reverse_iterator model_iter = keys.rbegin(); + model_iter != keys.rend(); + ++model_iter) { + ASSERT_TRUE(iter.Valid()); + ASSERT_EQ(*model_iter, iter.key()); + iter.Prev(); + } + ASSERT_TRUE(!iter.Valid()); + } +} + +// We want to make sure that with a single writer and multiple +// concurrent readers (with no synchronization other than when a +// reader's iterator is created), the reader always observes all the +// data that was present in the skip list when the iterator was +// constructor. Because insertions are happening concurrently, we may +// also observe new values that were inserted since the iterator was +// constructed, but we should never miss any values that were present +// at iterator construction time. +// +// We generate multi-part keys: +// +// where: +// key is in range [0..K-1] +// gen is a generation number for key +// hash is hash(key,gen) +// +// The insertion code picks a random key, sets gen to be 1 + the last +// generation number inserted for that key, and sets hash to Hash(key,gen). +// +// At the beginning of a read, we snapshot the last inserted +// generation number for each key. We then iterate, including random +// calls to Next() and Seek(). For every key we encounter, we +// check that it is either expected given the initial snapshot or has +// been concurrently added since the iterator started. +class ConcurrentTest { + private: + static const uint32_t K = 4; + + static uint64_t key(Key key) { return (key >> 40); } + static uint64_t gen(Key key) { return (key >> 8) & 0xffffffffu; } + static uint64_t hash(Key key) { return key & 0xff; } + + static uint64_t HashNumbers(uint64_t k, uint64_t g) { + uint64_t data[2] = { k, g }; + return Hash(reinterpret_cast(data), sizeof(data), 0); + } + + static Key MakeKey(uint64_t k, uint64_t g) { + assert(sizeof(Key) == sizeof(uint64_t)); + assert(k <= K); // We sometimes pass K to seek to the end of the skiplist + assert(g <= 0xffffffffu); + return ((k << 40) | (g << 8) | (HashNumbers(k, g) & 0xff)); + } + + static bool IsValidKey(Key k) { + return hash(k) == (HashNumbers(key(k), gen(k)) & 0xff); + } + + static Key RandomTarget(Random* rnd) { + switch (rnd->Next() % 10) { + case 0: + // Seek to beginning + return MakeKey(0, 0); + case 1: + // Seek to end + return MakeKey(K, 0); + default: + // Seek to middle + return MakeKey(rnd->Next() % K, 0); + } + } + + // Per-key generation + struct State { + port::AtomicPointer generation[K]; + void Set(int k, intptr_t v) { + generation[k].Release_Store(reinterpret_cast(v)); + } + intptr_t Get(int k) { + return reinterpret_cast(generation[k].Acquire_Load()); + } + + State() { + for (int k = 0; k < K; k++) { + Set(k, 0); + } + } + }; + + // Current state of the test + State current_; + + Arena arena_; + + // SkipList is not protected by mu_. We just use a single writer + // thread to modify it. + SkipList list_; + + public: + ConcurrentTest() : list_(Comparator(), &arena_) { } + + // REQUIRES: External synchronization + void WriteStep(Random* rnd) { + const uint32_t k = rnd->Next() % K; + const intptr_t g = current_.Get(k) + 1; + const Key key = MakeKey(k, g); + list_.Insert(key); + current_.Set(k, g); + } + + void ReadStep(Random* rnd) { + // Remember the initial committed state of the skiplist. + State initial_state; + for (int k = 0; k < K; k++) { + initial_state.Set(k, current_.Get(k)); + } + + Key pos = RandomTarget(rnd); + SkipList::Iterator iter(&list_); + iter.Seek(pos); + while (true) { + Key current; + if (!iter.Valid()) { + current = MakeKey(K, 0); + } else { + current = iter.key(); + ASSERT_TRUE(IsValidKey(current)) << current; + } + ASSERT_LE(pos, current) << "should not go backwards"; + + // Verify that everything in [pos,current) was not present in + // initial_state. + while (pos < current) { + ASSERT_LT(key(pos), K) << pos; + + // Note that generation 0 is never inserted, so it is ok if + // <*,0,*> is missing. + ASSERT_TRUE((gen(pos) == 0) || + (gen(pos) > initial_state.Get(key(pos))) + ) << "key: " << key(pos) + << "; gen: " << gen(pos) + << "; initgen: " + << initial_state.Get(key(pos)); + + // Advance to next key in the valid key space + if (key(pos) < key(current)) { + pos = MakeKey(key(pos) + 1, 0); + } else { + pos = MakeKey(key(pos), gen(pos) + 1); + } + } + + if (!iter.Valid()) { + break; + } + + if (rnd->Next() % 2) { + iter.Next(); + pos = MakeKey(key(pos), gen(pos) + 1); + } else { + Key new_target = RandomTarget(rnd); + if (new_target > pos) { + pos = new_target; + iter.Seek(new_target); + } + } + } + } +}; +const uint32_t ConcurrentTest::K; + +// Simple test that does single-threaded testing of the ConcurrentTest +// scaffolding. +TEST(SkipTest, ConcurrentWithoutThreads) { + ConcurrentTest test; + Random rnd(test::RandomSeed()); + for (int i = 0; i < 10000; i++) { + test.ReadStep(&rnd); + test.WriteStep(&rnd); + } +} + +class TestState { + public: + ConcurrentTest t_; + int seed_; + port::AtomicPointer quit_flag_; + + enum ReaderState { + STARTING, + RUNNING, + DONE + }; + + explicit TestState(int s) + : seed_(s), + quit_flag_(NULL), + state_(STARTING), + state_cv_(&mu_) {} + + void Wait(ReaderState s) { + mu_.Lock(); + while (state_ != s) { + state_cv_.Wait(); + } + mu_.Unlock(); + } + + void Change(ReaderState s) { + mu_.Lock(); + state_ = s; + state_cv_.Signal(); + mu_.Unlock(); + } + + private: + port::Mutex mu_; + ReaderState state_; + port::CondVar state_cv_; +}; + +static void ConcurrentReader(void* arg) { + TestState* state = reinterpret_cast(arg); + Random rnd(state->seed_); + int64_t reads = 0; + state->Change(TestState::RUNNING); + while (!state->quit_flag_.Acquire_Load()) { + state->t_.ReadStep(&rnd); + ++reads; + } + state->Change(TestState::DONE); +} + +static void RunConcurrent(int run) { + const int seed = test::RandomSeed() + (run * 100); + Random rnd(seed); + const int N = 1000; + const int kSize = 1000; + for (int i = 0; i < N; i++) { + if ((i % 100) == 0) { + fprintf(stderr, "Run %d of %d\n", i, N); + } + TestState state(seed + 1); + Env::Default()->Schedule(ConcurrentReader, &state); + state.Wait(TestState::RUNNING); + for (int i = 0; i < kSize; i++) { + state.t_.WriteStep(&rnd); + } + state.quit_flag_.Release_Store(&state); // Any non-NULL arg will do + state.Wait(TestState::DONE); + } +} + +TEST(SkipTest, Concurrent1) { RunConcurrent(1); } +TEST(SkipTest, Concurrent2) { RunConcurrent(2); } +TEST(SkipTest, Concurrent3) { RunConcurrent(3); } +TEST(SkipTest, Concurrent4) { RunConcurrent(4); } +TEST(SkipTest, Concurrent5) { RunConcurrent(5); } + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/db/snapshot.h b/src/leveldb/db/snapshot.h new file mode 100644 index 0000000..e7f8fd2 --- /dev/null +++ b/src/leveldb/db/snapshot.h @@ -0,0 +1,66 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_DB_SNAPSHOT_H_ +#define STORAGE_LEVELDB_DB_SNAPSHOT_H_ + +#include "leveldb/db.h" + +namespace leveldb { + +class SnapshotList; + +// Snapshots are kept in a doubly-linked list in the DB. +// Each SnapshotImpl corresponds to a particular sequence number. +class SnapshotImpl : public Snapshot { + public: + SequenceNumber number_; // const after creation + + private: + friend class SnapshotList; + + // SnapshotImpl is kept in a doubly-linked circular list + SnapshotImpl* prev_; + SnapshotImpl* next_; + + SnapshotList* list_; // just for sanity checks +}; + +class SnapshotList { + public: + SnapshotList() { + list_.prev_ = &list_; + list_.next_ = &list_; + } + + bool empty() const { return list_.next_ == &list_; } + SnapshotImpl* oldest() const { assert(!empty()); return list_.next_; } + SnapshotImpl* newest() const { assert(!empty()); return list_.prev_; } + + const SnapshotImpl* New(SequenceNumber seq) { + SnapshotImpl* s = new SnapshotImpl; + s->number_ = seq; + s->list_ = this; + s->next_ = &list_; + s->prev_ = list_.prev_; + s->prev_->next_ = s; + s->next_->prev_ = s; + return s; + } + + void Delete(const SnapshotImpl* s) { + assert(s->list_ == this); + s->prev_->next_ = s->next_; + s->next_->prev_ = s->prev_; + delete s; + } + + private: + // Dummy head of doubly-linked list of snapshots + SnapshotImpl list_; +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_SNAPSHOT_H_ diff --git a/src/leveldb/db/table_cache.cc b/src/leveldb/db/table_cache.cc new file mode 100644 index 0000000..e3d82cd --- /dev/null +++ b/src/leveldb/db/table_cache.cc @@ -0,0 +1,127 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/table_cache.h" + +#include "db/filename.h" +#include "leveldb/env.h" +#include "leveldb/table.h" +#include "util/coding.h" + +namespace leveldb { + +struct TableAndFile { + RandomAccessFile* file; + Table* table; +}; + +static void DeleteEntry(const Slice& key, void* value) { + TableAndFile* tf = reinterpret_cast(value); + delete tf->table; + delete tf->file; + delete tf; +} + +static void UnrefEntry(void* arg1, void* arg2) { + Cache* cache = reinterpret_cast(arg1); + Cache::Handle* h = reinterpret_cast(arg2); + cache->Release(h); +} + +TableCache::TableCache(const std::string& dbname, + const Options* options, + int entries) + : env_(options->env), + dbname_(dbname), + options_(options), + cache_(NewLRUCache(entries)) { +} + +TableCache::~TableCache() { + delete cache_; +} + +Status TableCache::FindTable(uint64_t file_number, uint64_t file_size, + Cache::Handle** handle) { + Status s; + char buf[sizeof(file_number)]; + EncodeFixed64(buf, file_number); + Slice key(buf, sizeof(buf)); + *handle = cache_->Lookup(key); + if (*handle == NULL) { + std::string fname = TableFileName(dbname_, file_number); + RandomAccessFile* file = NULL; + Table* table = NULL; + s = env_->NewRandomAccessFile(fname, &file); + if (!s.ok()) { + std::string old_fname = SSTTableFileName(dbname_, file_number); + if (env_->NewRandomAccessFile(old_fname, &file).ok()) { + s = Status::OK(); + } + } + if (s.ok()) { + s = Table::Open(*options_, file, file_size, &table); + } + + if (!s.ok()) { + assert(table == NULL); + delete file; + // We do not cache error results so that if the error is transient, + // or somebody repairs the file, we recover automatically. + } else { + TableAndFile* tf = new TableAndFile; + tf->file = file; + tf->table = table; + *handle = cache_->Insert(key, tf, 1, &DeleteEntry); + } + } + return s; +} + +Iterator* TableCache::NewIterator(const ReadOptions& options, + uint64_t file_number, + uint64_t file_size, + Table** tableptr) { + if (tableptr != NULL) { + *tableptr = NULL; + } + + Cache::Handle* handle = NULL; + Status s = FindTable(file_number, file_size, &handle); + if (!s.ok()) { + return NewErrorIterator(s); + } + + Table* table = reinterpret_cast(cache_->Value(handle))->table; + Iterator* result = table->NewIterator(options); + result->RegisterCleanup(&UnrefEntry, cache_, handle); + if (tableptr != NULL) { + *tableptr = table; + } + return result; +} + +Status TableCache::Get(const ReadOptions& options, + uint64_t file_number, + uint64_t file_size, + const Slice& k, + void* arg, + void (*saver)(void*, const Slice&, const Slice&)) { + Cache::Handle* handle = NULL; + Status s = FindTable(file_number, file_size, &handle); + if (s.ok()) { + Table* t = reinterpret_cast(cache_->Value(handle))->table; + s = t->InternalGet(options, k, arg, saver); + cache_->Release(handle); + } + return s; +} + +void TableCache::Evict(uint64_t file_number) { + char buf[sizeof(file_number)]; + EncodeFixed64(buf, file_number); + cache_->Erase(Slice(buf, sizeof(buf))); +} + +} // namespace leveldb diff --git a/src/leveldb/db/table_cache.h b/src/leveldb/db/table_cache.h new file mode 100644 index 0000000..8cf4aaf --- /dev/null +++ b/src/leveldb/db/table_cache.h @@ -0,0 +1,61 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// Thread-safe (provides internal synchronization) + +#ifndef STORAGE_LEVELDB_DB_TABLE_CACHE_H_ +#define STORAGE_LEVELDB_DB_TABLE_CACHE_H_ + +#include +#include +#include "db/dbformat.h" +#include "leveldb/cache.h" +#include "leveldb/table.h" +#include "port/port.h" + +namespace leveldb { + +class Env; + +class TableCache { + public: + TableCache(const std::string& dbname, const Options* options, int entries); + ~TableCache(); + + // Return an iterator for the specified file number (the corresponding + // file length must be exactly "file_size" bytes). If "tableptr" is + // non-NULL, also sets "*tableptr" to point to the Table object + // underlying the returned iterator, or NULL if no Table object underlies + // the returned iterator. The returned "*tableptr" object is owned by + // the cache and should not be deleted, and is valid for as long as the + // returned iterator is live. + Iterator* NewIterator(const ReadOptions& options, + uint64_t file_number, + uint64_t file_size, + Table** tableptr = NULL); + + // If a seek to internal key "k" in specified file finds an entry, + // call (*handle_result)(arg, found_key, found_value). + Status Get(const ReadOptions& options, + uint64_t file_number, + uint64_t file_size, + const Slice& k, + void* arg, + void (*handle_result)(void*, const Slice&, const Slice&)); + + // Evict any entry for the specified file number + void Evict(uint64_t file_number); + + private: + Env* const env_; + const std::string dbname_; + const Options* options_; + Cache* cache_; + + Status FindTable(uint64_t file_number, uint64_t file_size, Cache::Handle**); +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_TABLE_CACHE_H_ diff --git a/src/leveldb/db/version_edit.cc b/src/leveldb/db/version_edit.cc new file mode 100644 index 0000000..f10a2d5 --- /dev/null +++ b/src/leveldb/db/version_edit.cc @@ -0,0 +1,266 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/version_edit.h" + +#include "db/version_set.h" +#include "util/coding.h" + +namespace leveldb { + +// Tag numbers for serialized VersionEdit. These numbers are written to +// disk and should not be changed. +enum Tag { + kComparator = 1, + kLogNumber = 2, + kNextFileNumber = 3, + kLastSequence = 4, + kCompactPointer = 5, + kDeletedFile = 6, + kNewFile = 7, + // 8 was used for large value refs + kPrevLogNumber = 9 +}; + +void VersionEdit::Clear() { + comparator_.clear(); + log_number_ = 0; + prev_log_number_ = 0; + last_sequence_ = 0; + next_file_number_ = 0; + has_comparator_ = false; + has_log_number_ = false; + has_prev_log_number_ = false; + has_next_file_number_ = false; + has_last_sequence_ = false; + deleted_files_.clear(); + new_files_.clear(); +} + +void VersionEdit::EncodeTo(std::string* dst) const { + if (has_comparator_) { + PutVarint32(dst, kComparator); + PutLengthPrefixedSlice(dst, comparator_); + } + if (has_log_number_) { + PutVarint32(dst, kLogNumber); + PutVarint64(dst, log_number_); + } + if (has_prev_log_number_) { + PutVarint32(dst, kPrevLogNumber); + PutVarint64(dst, prev_log_number_); + } + if (has_next_file_number_) { + PutVarint32(dst, kNextFileNumber); + PutVarint64(dst, next_file_number_); + } + if (has_last_sequence_) { + PutVarint32(dst, kLastSequence); + PutVarint64(dst, last_sequence_); + } + + for (size_t i = 0; i < compact_pointers_.size(); i++) { + PutVarint32(dst, kCompactPointer); + PutVarint32(dst, compact_pointers_[i].first); // level + PutLengthPrefixedSlice(dst, compact_pointers_[i].second.Encode()); + } + + for (DeletedFileSet::const_iterator iter = deleted_files_.begin(); + iter != deleted_files_.end(); + ++iter) { + PutVarint32(dst, kDeletedFile); + PutVarint32(dst, iter->first); // level + PutVarint64(dst, iter->second); // file number + } + + for (size_t i = 0; i < new_files_.size(); i++) { + const FileMetaData& f = new_files_[i].second; + PutVarint32(dst, kNewFile); + PutVarint32(dst, new_files_[i].first); // level + PutVarint64(dst, f.number); + PutVarint64(dst, f.file_size); + PutLengthPrefixedSlice(dst, f.smallest.Encode()); + PutLengthPrefixedSlice(dst, f.largest.Encode()); + } +} + +static bool GetInternalKey(Slice* input, InternalKey* dst) { + Slice str; + if (GetLengthPrefixedSlice(input, &str)) { + dst->DecodeFrom(str); + return true; + } else { + return false; + } +} + +static bool GetLevel(Slice* input, int* level) { + uint32_t v; + if (GetVarint32(input, &v) && + v < config::kNumLevels) { + *level = v; + return true; + } else { + return false; + } +} + +Status VersionEdit::DecodeFrom(const Slice& src) { + Clear(); + Slice input = src; + const char* msg = NULL; + uint32_t tag; + + // Temporary storage for parsing + int level; + uint64_t number; + FileMetaData f; + Slice str; + InternalKey key; + + while (msg == NULL && GetVarint32(&input, &tag)) { + switch (tag) { + case kComparator: + if (GetLengthPrefixedSlice(&input, &str)) { + comparator_ = str.ToString(); + has_comparator_ = true; + } else { + msg = "comparator name"; + } + break; + + case kLogNumber: + if (GetVarint64(&input, &log_number_)) { + has_log_number_ = true; + } else { + msg = "log number"; + } + break; + + case kPrevLogNumber: + if (GetVarint64(&input, &prev_log_number_)) { + has_prev_log_number_ = true; + } else { + msg = "previous log number"; + } + break; + + case kNextFileNumber: + if (GetVarint64(&input, &next_file_number_)) { + has_next_file_number_ = true; + } else { + msg = "next file number"; + } + break; + + case kLastSequence: + if (GetVarint64(&input, &last_sequence_)) { + has_last_sequence_ = true; + } else { + msg = "last sequence number"; + } + break; + + case kCompactPointer: + if (GetLevel(&input, &level) && + GetInternalKey(&input, &key)) { + compact_pointers_.push_back(std::make_pair(level, key)); + } else { + msg = "compaction pointer"; + } + break; + + case kDeletedFile: + if (GetLevel(&input, &level) && + GetVarint64(&input, &number)) { + deleted_files_.insert(std::make_pair(level, number)); + } else { + msg = "deleted file"; + } + break; + + case kNewFile: + if (GetLevel(&input, &level) && + GetVarint64(&input, &f.number) && + GetVarint64(&input, &f.file_size) && + GetInternalKey(&input, &f.smallest) && + GetInternalKey(&input, &f.largest)) { + new_files_.push_back(std::make_pair(level, f)); + } else { + msg = "new-file entry"; + } + break; + + default: + msg = "unknown tag"; + break; + } + } + + if (msg == NULL && !input.empty()) { + msg = "invalid tag"; + } + + Status result; + if (msg != NULL) { + result = Status::Corruption("VersionEdit", msg); + } + return result; +} + +std::string VersionEdit::DebugString() const { + std::string r; + r.append("VersionEdit {"); + if (has_comparator_) { + r.append("\n Comparator: "); + r.append(comparator_); + } + if (has_log_number_) { + r.append("\n LogNumber: "); + AppendNumberTo(&r, log_number_); + } + if (has_prev_log_number_) { + r.append("\n PrevLogNumber: "); + AppendNumberTo(&r, prev_log_number_); + } + if (has_next_file_number_) { + r.append("\n NextFile: "); + AppendNumberTo(&r, next_file_number_); + } + if (has_last_sequence_) { + r.append("\n LastSeq: "); + AppendNumberTo(&r, last_sequence_); + } + for (size_t i = 0; i < compact_pointers_.size(); i++) { + r.append("\n CompactPointer: "); + AppendNumberTo(&r, compact_pointers_[i].first); + r.append(" "); + r.append(compact_pointers_[i].second.DebugString()); + } + for (DeletedFileSet::const_iterator iter = deleted_files_.begin(); + iter != deleted_files_.end(); + ++iter) { + r.append("\n DeleteFile: "); + AppendNumberTo(&r, iter->first); + r.append(" "); + AppendNumberTo(&r, iter->second); + } + for (size_t i = 0; i < new_files_.size(); i++) { + const FileMetaData& f = new_files_[i].second; + r.append("\n AddFile: "); + AppendNumberTo(&r, new_files_[i].first); + r.append(" "); + AppendNumberTo(&r, f.number); + r.append(" "); + AppendNumberTo(&r, f.file_size); + r.append(" "); + r.append(f.smallest.DebugString()); + r.append(" .. "); + r.append(f.largest.DebugString()); + } + r.append("\n}\n"); + return r; +} + +} // namespace leveldb diff --git a/src/leveldb/db/version_edit.h b/src/leveldb/db/version_edit.h new file mode 100644 index 0000000..eaef77b --- /dev/null +++ b/src/leveldb/db/version_edit.h @@ -0,0 +1,107 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_DB_VERSION_EDIT_H_ +#define STORAGE_LEVELDB_DB_VERSION_EDIT_H_ + +#include +#include +#include +#include "db/dbformat.h" + +namespace leveldb { + +class VersionSet; + +struct FileMetaData { + int refs; + int allowed_seeks; // Seeks allowed until compaction + uint64_t number; + uint64_t file_size; // File size in bytes + InternalKey smallest; // Smallest internal key served by table + InternalKey largest; // Largest internal key served by table + + FileMetaData() : refs(0), allowed_seeks(1 << 30), file_size(0) { } +}; + +class VersionEdit { + public: + VersionEdit() { Clear(); } + ~VersionEdit() { } + + void Clear(); + + void SetComparatorName(const Slice& name) { + has_comparator_ = true; + comparator_ = name.ToString(); + } + void SetLogNumber(uint64_t num) { + has_log_number_ = true; + log_number_ = num; + } + void SetPrevLogNumber(uint64_t num) { + has_prev_log_number_ = true; + prev_log_number_ = num; + } + void SetNextFile(uint64_t num) { + has_next_file_number_ = true; + next_file_number_ = num; + } + void SetLastSequence(SequenceNumber seq) { + has_last_sequence_ = true; + last_sequence_ = seq; + } + void SetCompactPointer(int level, const InternalKey& key) { + compact_pointers_.push_back(std::make_pair(level, key)); + } + + // Add the specified file at the specified number. + // REQUIRES: This version has not been saved (see VersionSet::SaveTo) + // REQUIRES: "smallest" and "largest" are smallest and largest keys in file + void AddFile(int level, uint64_t file, + uint64_t file_size, + const InternalKey& smallest, + const InternalKey& largest) { + FileMetaData f; + f.number = file; + f.file_size = file_size; + f.smallest = smallest; + f.largest = largest; + new_files_.push_back(std::make_pair(level, f)); + } + + // Delete the specified "file" from the specified "level". + void DeleteFile(int level, uint64_t file) { + deleted_files_.insert(std::make_pair(level, file)); + } + + void EncodeTo(std::string* dst) const; + Status DecodeFrom(const Slice& src); + + std::string DebugString() const; + + private: + friend class VersionSet; + + typedef std::set< std::pair > DeletedFileSet; + + std::string comparator_; + uint64_t log_number_; + uint64_t prev_log_number_; + uint64_t next_file_number_; + SequenceNumber last_sequence_; + bool has_comparator_; + bool has_log_number_; + bool has_prev_log_number_; + bool has_next_file_number_; + bool has_last_sequence_; + + std::vector< std::pair > compact_pointers_; + DeletedFileSet deleted_files_; + std::vector< std::pair > new_files_; +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_VERSION_EDIT_H_ diff --git a/src/leveldb/db/version_edit_test.cc b/src/leveldb/db/version_edit_test.cc new file mode 100644 index 0000000..280310b --- /dev/null +++ b/src/leveldb/db/version_edit_test.cc @@ -0,0 +1,46 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/version_edit.h" +#include "util/testharness.h" + +namespace leveldb { + +static void TestEncodeDecode(const VersionEdit& edit) { + std::string encoded, encoded2; + edit.EncodeTo(&encoded); + VersionEdit parsed; + Status s = parsed.DecodeFrom(encoded); + ASSERT_TRUE(s.ok()) << s.ToString(); + parsed.EncodeTo(&encoded2); + ASSERT_EQ(encoded, encoded2); +} + +class VersionEditTest { }; + +TEST(VersionEditTest, EncodeDecode) { + static const uint64_t kBig = 1ull << 50; + + VersionEdit edit; + for (int i = 0; i < 4; i++) { + TestEncodeDecode(edit); + edit.AddFile(3, kBig + 300 + i, kBig + 400 + i, + InternalKey("foo", kBig + 500 + i, kTypeValue), + InternalKey("zoo", kBig + 600 + i, kTypeDeletion)); + edit.DeleteFile(4, kBig + 700 + i); + edit.SetCompactPointer(i, InternalKey("x", kBig + 900 + i, kTypeValue)); + } + + edit.SetComparatorName("foo"); + edit.SetLogNumber(kBig + 100); + edit.SetNextFile(kBig + 200); + edit.SetLastSequence(kBig + 1000); + TestEncodeDecode(edit); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/db/version_set.cc b/src/leveldb/db/version_set.cc new file mode 100644 index 0000000..517edd3 --- /dev/null +++ b/src/leveldb/db/version_set.cc @@ -0,0 +1,1498 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/version_set.h" + +#include +#include +#include "db/filename.h" +#include "db/log_reader.h" +#include "db/log_writer.h" +#include "db/memtable.h" +#include "db/table_cache.h" +#include "leveldb/env.h" +#include "leveldb/table_builder.h" +#include "table/merger.h" +#include "table/two_level_iterator.h" +#include "util/coding.h" +#include "util/logging.h" + +namespace leveldb { + +static const int kTargetFileSize = 2 * 1048576; + +// Maximum bytes of overlaps in grandparent (i.e., level+2) before we +// stop building a single file in a level->level+1 compaction. +static const int64_t kMaxGrandParentOverlapBytes = 10 * kTargetFileSize; + +// Maximum number of bytes in all compacted files. We avoid expanding +// the lower level file set of a compaction if it would make the +// total compaction cover more than this many bytes. +static const int64_t kExpandedCompactionByteSizeLimit = 25 * kTargetFileSize; + +static double MaxBytesForLevel(int level) { + // Note: the result for level zero is not really used since we set + // the level-0 compaction threshold based on number of files. + double result = 10 * 1048576.0; // Result for both level-0 and level-1 + while (level > 1) { + result *= 10; + level--; + } + return result; +} + +static uint64_t MaxFileSizeForLevel(int level) { + return kTargetFileSize; // We could vary per level to reduce number of files? +} + +static int64_t TotalFileSize(const std::vector& files) { + int64_t sum = 0; + for (size_t i = 0; i < files.size(); i++) { + sum += files[i]->file_size; + } + return sum; +} + +namespace { +std::string IntSetToString(const std::set& s) { + std::string result = "{"; + for (std::set::const_iterator it = s.begin(); + it != s.end(); + ++it) { + result += (result.size() > 1) ? "," : ""; + result += NumberToString(*it); + } + result += "}"; + return result; +} +} // namespace + +Version::~Version() { + assert(refs_ == 0); + + // Remove from linked list + prev_->next_ = next_; + next_->prev_ = prev_; + + // Drop references to files + for (int level = 0; level < config::kNumLevels; level++) { + for (size_t i = 0; i < files_[level].size(); i++) { + FileMetaData* f = files_[level][i]; + assert(f->refs > 0); + f->refs--; + if (f->refs <= 0) { + delete f; + } + } + } +} + +int FindFile(const InternalKeyComparator& icmp, + const std::vector& files, + const Slice& key) { + uint32_t left = 0; + uint32_t right = files.size(); + while (left < right) { + uint32_t mid = (left + right) / 2; + const FileMetaData* f = files[mid]; + if (icmp.InternalKeyComparator::Compare(f->largest.Encode(), key) < 0) { + // Key at "mid.largest" is < "target". Therefore all + // files at or before "mid" are uninteresting. + left = mid + 1; + } else { + // Key at "mid.largest" is >= "target". Therefore all files + // after "mid" are uninteresting. + right = mid; + } + } + return right; +} + +static bool AfterFile(const Comparator* ucmp, + const Slice* user_key, const FileMetaData* f) { + // NULL user_key occurs before all keys and is therefore never after *f + return (user_key != NULL && + ucmp->Compare(*user_key, f->largest.user_key()) > 0); +} + +static bool BeforeFile(const Comparator* ucmp, + const Slice* user_key, const FileMetaData* f) { + // NULL user_key occurs after all keys and is therefore never before *f + return (user_key != NULL && + ucmp->Compare(*user_key, f->smallest.user_key()) < 0); +} + +bool SomeFileOverlapsRange( + const InternalKeyComparator& icmp, + bool disjoint_sorted_files, + const std::vector& files, + const Slice* smallest_user_key, + const Slice* largest_user_key) { + const Comparator* ucmp = icmp.user_comparator(); + if (!disjoint_sorted_files) { + // Need to check against all files + for (size_t i = 0; i < files.size(); i++) { + const FileMetaData* f = files[i]; + if (AfterFile(ucmp, smallest_user_key, f) || + BeforeFile(ucmp, largest_user_key, f)) { + // No overlap + } else { + return true; // Overlap + } + } + return false; + } + + // Binary search over file list + uint32_t index = 0; + if (smallest_user_key != NULL) { + // Find the earliest possible internal key for smallest_user_key + InternalKey small(*smallest_user_key, kMaxSequenceNumber,kValueTypeForSeek); + index = FindFile(icmp, files, small.Encode()); + } + + if (index >= files.size()) { + // beginning of range is after all files, so no overlap. + return false; + } + + return !BeforeFile(ucmp, largest_user_key, files[index]); +} + +// An internal iterator. For a given version/level pair, yields +// information about the files in the level. For a given entry, key() +// is the largest key that occurs in the file, and value() is an +// 16-byte value containing the file number and file size, both +// encoded using EncodeFixed64. +class Version::LevelFileNumIterator : public Iterator { + public: + LevelFileNumIterator(const InternalKeyComparator& icmp, + const std::vector* flist) + : icmp_(icmp), + flist_(flist), + index_(flist->size()) { // Marks as invalid + } + virtual bool Valid() const { + return index_ < flist_->size(); + } + virtual void Seek(const Slice& target) { + index_ = FindFile(icmp_, *flist_, target); + } + virtual void SeekToFirst() { index_ = 0; } + virtual void SeekToLast() { + index_ = flist_->empty() ? 0 : flist_->size() - 1; + } + virtual void Next() { + assert(Valid()); + index_++; + } + virtual void Prev() { + assert(Valid()); + if (index_ == 0) { + index_ = flist_->size(); // Marks as invalid + } else { + index_--; + } + } + Slice key() const { + assert(Valid()); + return (*flist_)[index_]->largest.Encode(); + } + Slice value() const { + assert(Valid()); + EncodeFixed64(value_buf_, (*flist_)[index_]->number); + EncodeFixed64(value_buf_+8, (*flist_)[index_]->file_size); + return Slice(value_buf_, sizeof(value_buf_)); + } + virtual Status status() const { return Status::OK(); } + private: + const InternalKeyComparator icmp_; + const std::vector* const flist_; + uint32_t index_; + + // Backing store for value(). Holds the file number and size. + mutable char value_buf_[16]; +}; + +static Iterator* GetFileIterator(void* arg, + const ReadOptions& options, + const Slice& file_value) { + TableCache* cache = reinterpret_cast(arg); + if (file_value.size() != 16) { + return NewErrorIterator( + Status::Corruption("FileReader invoked with unexpected value")); + } else { + return cache->NewIterator(options, + DecodeFixed64(file_value.data()), + DecodeFixed64(file_value.data() + 8)); + } +} + +Iterator* Version::NewConcatenatingIterator(const ReadOptions& options, + int level) const { + return NewTwoLevelIterator( + new LevelFileNumIterator(vset_->icmp_, &files_[level]), + &GetFileIterator, vset_->table_cache_, options); +} + +void Version::AddIterators(const ReadOptions& options, + std::vector* iters) { + // Merge all level zero files together since they may overlap + for (size_t i = 0; i < files_[0].size(); i++) { + iters->push_back( + vset_->table_cache_->NewIterator( + options, files_[0][i]->number, files_[0][i]->file_size)); + } + + // For levels > 0, we can use a concatenating iterator that sequentially + // walks through the non-overlapping files in the level, opening them + // lazily. + for (int level = 1; level < config::kNumLevels; level++) { + if (!files_[level].empty()) { + iters->push_back(NewConcatenatingIterator(options, level)); + } + } +} + +// Callback from TableCache::Get() +namespace { +enum SaverState { + kNotFound, + kFound, + kDeleted, + kCorrupt, +}; +struct Saver { + SaverState state; + const Comparator* ucmp; + Slice user_key; + std::string* value; +}; +} +static void SaveValue(void* arg, const Slice& ikey, const Slice& v) { + Saver* s = reinterpret_cast(arg); + ParsedInternalKey parsed_key; + if (!ParseInternalKey(ikey, &parsed_key)) { + s->state = kCorrupt; + } else { + if (s->ucmp->Compare(parsed_key.user_key, s->user_key) == 0) { + s->state = (parsed_key.type == kTypeValue) ? kFound : kDeleted; + if (s->state == kFound) { + s->value->assign(v.data(), v.size()); + } + } + } +} + +static bool NewestFirst(FileMetaData* a, FileMetaData* b) { + return a->number > b->number; +} + +void Version::ForEachOverlapping(Slice user_key, Slice internal_key, + void* arg, + bool (*func)(void*, int, FileMetaData*)) { + // TODO(sanjay): Change Version::Get() to use this function. + const Comparator* ucmp = vset_->icmp_.user_comparator(); + + // Search level-0 in order from newest to oldest. + std::vector tmp; + tmp.reserve(files_[0].size()); + for (uint32_t i = 0; i < files_[0].size(); i++) { + FileMetaData* f = files_[0][i]; + if (ucmp->Compare(user_key, f->smallest.user_key()) >= 0 && + ucmp->Compare(user_key, f->largest.user_key()) <= 0) { + tmp.push_back(f); + } + } + if (!tmp.empty()) { + std::sort(tmp.begin(), tmp.end(), NewestFirst); + for (uint32_t i = 0; i < tmp.size(); i++) { + if (!(*func)(arg, 0, tmp[i])) { + return; + } + } + } + + // Search other levels. + for (int level = 1; level < config::kNumLevels; level++) { + size_t num_files = files_[level].size(); + if (num_files == 0) continue; + + // Binary search to find earliest index whose largest key >= internal_key. + uint32_t index = FindFile(vset_->icmp_, files_[level], internal_key); + if (index < num_files) { + FileMetaData* f = files_[level][index]; + if (ucmp->Compare(user_key, f->smallest.user_key()) < 0) { + // All of "f" is past any data for user_key + } else { + if (!(*func)(arg, level, f)) { + return; + } + } + } + } +} + +Status Version::Get(const ReadOptions& options, + const LookupKey& k, + std::string* value, + GetStats* stats) { + Slice ikey = k.internal_key(); + Slice user_key = k.user_key(); + const Comparator* ucmp = vset_->icmp_.user_comparator(); + Status s; + + stats->seek_file = NULL; + stats->seek_file_level = -1; + FileMetaData* last_file_read = NULL; + int last_file_read_level = -1; + + // We can search level-by-level since entries never hop across + // levels. Therefore we are guaranteed that if we find data + // in an smaller level, later levels are irrelevant. + std::vector tmp; + FileMetaData* tmp2; + for (int level = 0; level < config::kNumLevels; level++) { + size_t num_files = files_[level].size(); + if (num_files == 0) continue; + + // Get the list of files to search in this level + FileMetaData* const* files = &files_[level][0]; + if (level == 0) { + // Level-0 files may overlap each other. Find all files that + // overlap user_key and process them in order from newest to oldest. + tmp.reserve(num_files); + for (uint32_t i = 0; i < num_files; i++) { + FileMetaData* f = files[i]; + if (ucmp->Compare(user_key, f->smallest.user_key()) >= 0 && + ucmp->Compare(user_key, f->largest.user_key()) <= 0) { + tmp.push_back(f); + } + } + if (tmp.empty()) continue; + + std::sort(tmp.begin(), tmp.end(), NewestFirst); + files = &tmp[0]; + num_files = tmp.size(); + } else { + // Binary search to find earliest index whose largest key >= ikey. + uint32_t index = FindFile(vset_->icmp_, files_[level], ikey); + if (index >= num_files) { + files = NULL; + num_files = 0; + } else { + tmp2 = files[index]; + if (ucmp->Compare(user_key, tmp2->smallest.user_key()) < 0) { + // All of "tmp2" is past any data for user_key + files = NULL; + num_files = 0; + } else { + files = &tmp2; + num_files = 1; + } + } + } + + for (uint32_t i = 0; i < num_files; ++i) { + if (last_file_read != NULL && stats->seek_file == NULL) { + // We have had more than one seek for this read. Charge the 1st file. + stats->seek_file = last_file_read; + stats->seek_file_level = last_file_read_level; + } + + FileMetaData* f = files[i]; + last_file_read = f; + last_file_read_level = level; + + Saver saver; + saver.state = kNotFound; + saver.ucmp = ucmp; + saver.user_key = user_key; + saver.value = value; + s = vset_->table_cache_->Get(options, f->number, f->file_size, + ikey, &saver, SaveValue); + if (!s.ok()) { + return s; + } + switch (saver.state) { + case kNotFound: + break; // Keep searching in other files + case kFound: + return s; + case kDeleted: + s = Status::NotFound(Slice()); // Use empty error message for speed + return s; + case kCorrupt: + s = Status::Corruption("corrupted key for ", user_key); + return s; + } + } + } + + return Status::NotFound(Slice()); // Use an empty error message for speed +} + +bool Version::UpdateStats(const GetStats& stats) { + FileMetaData* f = stats.seek_file; + if (f != NULL) { + f->allowed_seeks--; + if (f->allowed_seeks <= 0 && file_to_compact_ == NULL) { + file_to_compact_ = f; + file_to_compact_level_ = stats.seek_file_level; + return true; + } + } + return false; +} + +bool Version::RecordReadSample(Slice internal_key) { + ParsedInternalKey ikey; + if (!ParseInternalKey(internal_key, &ikey)) { + return false; + } + + struct State { + GetStats stats; // Holds first matching file + int matches; + + static bool Match(void* arg, int level, FileMetaData* f) { + State* state = reinterpret_cast(arg); + state->matches++; + if (state->matches == 1) { + // Remember first match. + state->stats.seek_file = f; + state->stats.seek_file_level = level; + } + // We can stop iterating once we have a second match. + return state->matches < 2; + } + }; + + State state; + state.matches = 0; + ForEachOverlapping(ikey.user_key, internal_key, &state, &State::Match); + + // Must have at least two matches since we want to merge across + // files. But what if we have a single file that contains many + // overwrites and deletions? Should we have another mechanism for + // finding such files? + if (state.matches >= 2) { + // 1MB cost is about 1 seek (see comment in Builder::Apply). + return UpdateStats(state.stats); + } + return false; +} + +void Version::Ref() { + ++refs_; +} + +void Version::Unref() { + assert(this != &vset_->dummy_versions_); + assert(refs_ >= 1); + --refs_; + if (refs_ == 0) { + delete this; + } +} + +bool Version::OverlapInLevel(int level, + const Slice* smallest_user_key, + const Slice* largest_user_key) { + return SomeFileOverlapsRange(vset_->icmp_, (level > 0), files_[level], + smallest_user_key, largest_user_key); +} + +int Version::PickLevelForMemTableOutput( + const Slice& smallest_user_key, + const Slice& largest_user_key) { + int level = 0; + if (!OverlapInLevel(0, &smallest_user_key, &largest_user_key)) { + // Push to next level if there is no overlap in next level, + // and the #bytes overlapping in the level after that are limited. + InternalKey start(smallest_user_key, kMaxSequenceNumber, kValueTypeForSeek); + InternalKey limit(largest_user_key, 0, static_cast(0)); + std::vector overlaps; + while (level < config::kMaxMemCompactLevel) { + if (OverlapInLevel(level + 1, &smallest_user_key, &largest_user_key)) { + break; + } + if (level + 2 < config::kNumLevels) { + // Check that file does not overlap too many grandparent bytes. + GetOverlappingInputs(level + 2, &start, &limit, &overlaps); + const int64_t sum = TotalFileSize(overlaps); + if (sum > kMaxGrandParentOverlapBytes) { + break; + } + } + level++; + } + } + return level; +} + +// Store in "*inputs" all files in "level" that overlap [begin,end] +void Version::GetOverlappingInputs( + int level, + const InternalKey* begin, + const InternalKey* end, + std::vector* inputs) { + assert(level >= 0); + assert(level < config::kNumLevels); + inputs->clear(); + Slice user_begin, user_end; + if (begin != NULL) { + user_begin = begin->user_key(); + } + if (end != NULL) { + user_end = end->user_key(); + } + const Comparator* user_cmp = vset_->icmp_.user_comparator(); + for (size_t i = 0; i < files_[level].size(); ) { + FileMetaData* f = files_[level][i++]; + const Slice file_start = f->smallest.user_key(); + const Slice file_limit = f->largest.user_key(); + if (begin != NULL && user_cmp->Compare(file_limit, user_begin) < 0) { + // "f" is completely before specified range; skip it + } else if (end != NULL && user_cmp->Compare(file_start, user_end) > 0) { + // "f" is completely after specified range; skip it + } else { + inputs->push_back(f); + if (level == 0) { + // Level-0 files may overlap each other. So check if the newly + // added file has expanded the range. If so, restart search. + if (begin != NULL && user_cmp->Compare(file_start, user_begin) < 0) { + user_begin = file_start; + inputs->clear(); + i = 0; + } else if (end != NULL && user_cmp->Compare(file_limit, user_end) > 0) { + user_end = file_limit; + inputs->clear(); + i = 0; + } + } + } + } +} + +std::string Version::DebugString() const { + std::string r; + for (int level = 0; level < config::kNumLevels; level++) { + // E.g., + // --- level 1 --- + // 17:123['a' .. 'd'] + // 20:43['e' .. 'g'] + r.append("--- level "); + AppendNumberTo(&r, level); + r.append(" ---\n"); + const std::vector& files = files_[level]; + for (size_t i = 0; i < files.size(); i++) { + r.push_back(' '); + AppendNumberTo(&r, files[i]->number); + r.push_back(':'); + AppendNumberTo(&r, files[i]->file_size); + r.append("["); + r.append(files[i]->smallest.DebugString()); + r.append(" .. "); + r.append(files[i]->largest.DebugString()); + r.append("]\n"); + } + } + return r; +} + +// A helper class so we can efficiently apply a whole sequence +// of edits to a particular state without creating intermediate +// Versions that contain full copies of the intermediate state. +class VersionSet::Builder { + private: + // Helper to sort by v->files_[file_number].smallest + struct BySmallestKey { + const InternalKeyComparator* internal_comparator; + + bool operator()(FileMetaData* f1, FileMetaData* f2) const { + int r = internal_comparator->Compare(f1->smallest, f2->smallest); + if (r != 0) { + return (r < 0); + } else { + // Break ties by file number + return (f1->number < f2->number); + } + } + }; + + typedef std::set FileSet; + struct LevelState { + std::set deleted_files; + FileSet* added_files; + }; + + VersionSet* vset_; + Version* base_; + LevelState levels_[config::kNumLevels]; + + public: + // Initialize a builder with the files from *base and other info from *vset + Builder(VersionSet* vset, Version* base) + : vset_(vset), + base_(base) { + base_->Ref(); + BySmallestKey cmp; + cmp.internal_comparator = &vset_->icmp_; + for (int level = 0; level < config::kNumLevels; level++) { + levels_[level].added_files = new FileSet(cmp); + } + } + + ~Builder() { + for (int level = 0; level < config::kNumLevels; level++) { + const FileSet* added = levels_[level].added_files; + std::vector to_unref; + to_unref.reserve(added->size()); + for (FileSet::const_iterator it = added->begin(); + it != added->end(); ++it) { + to_unref.push_back(*it); + } + delete added; + for (uint32_t i = 0; i < to_unref.size(); i++) { + FileMetaData* f = to_unref[i]; + f->refs--; + if (f->refs <= 0) { + delete f; + } + } + } + base_->Unref(); + } + + // Apply all of the edits in *edit to the current state. + void Apply(VersionEdit* edit) { + // Update compaction pointers + for (size_t i = 0; i < edit->compact_pointers_.size(); i++) { + const int level = edit->compact_pointers_[i].first; + vset_->compact_pointer_[level] = + edit->compact_pointers_[i].second.Encode().ToString(); + } + + // Delete files + const VersionEdit::DeletedFileSet& del = edit->deleted_files_; + for (VersionEdit::DeletedFileSet::const_iterator iter = del.begin(); + iter != del.end(); + ++iter) { + const int level = iter->first; + const uint64_t number = iter->second; + levels_[level].deleted_files.insert(number); + } + + // Add new files + for (size_t i = 0; i < edit->new_files_.size(); i++) { + const int level = edit->new_files_[i].first; + FileMetaData* f = new FileMetaData(edit->new_files_[i].second); + f->refs = 1; + + // We arrange to automatically compact this file after + // a certain number of seeks. Let's assume: + // (1) One seek costs 10ms + // (2) Writing or reading 1MB costs 10ms (100MB/s) + // (3) A compaction of 1MB does 25MB of IO: + // 1MB read from this level + // 10-12MB read from next level (boundaries may be misaligned) + // 10-12MB written to next level + // This implies that 25 seeks cost the same as the compaction + // of 1MB of data. I.e., one seek costs approximately the + // same as the compaction of 40KB of data. We are a little + // conservative and allow approximately one seek for every 16KB + // of data before triggering a compaction. + f->allowed_seeks = (f->file_size / 16384); + if (f->allowed_seeks < 100) f->allowed_seeks = 100; + + levels_[level].deleted_files.erase(f->number); + levels_[level].added_files->insert(f); + } + } + + // Save the current state in *v. + void SaveTo(Version* v) { + BySmallestKey cmp; + cmp.internal_comparator = &vset_->icmp_; + for (int level = 0; level < config::kNumLevels; level++) { + // Merge the set of added files with the set of pre-existing files. + // Drop any deleted files. Store the result in *v. + const std::vector& base_files = base_->files_[level]; + std::vector::const_iterator base_iter = base_files.begin(); + std::vector::const_iterator base_end = base_files.end(); + const FileSet* added = levels_[level].added_files; + v->files_[level].reserve(base_files.size() + added->size()); + for (FileSet::const_iterator added_iter = added->begin(); + added_iter != added->end(); + ++added_iter) { + // Add all smaller files listed in base_ + for (std::vector::const_iterator bpos + = std::upper_bound(base_iter, base_end, *added_iter, cmp); + base_iter != bpos; + ++base_iter) { + MaybeAddFile(v, level, *base_iter); + } + + MaybeAddFile(v, level, *added_iter); + } + + // Add remaining base files + for (; base_iter != base_end; ++base_iter) { + MaybeAddFile(v, level, *base_iter); + } + +#ifndef NDEBUG + // Make sure there is no overlap in levels > 0 + if (level > 0) { + for (uint32_t i = 1; i < v->files_[level].size(); i++) { + const InternalKey& prev_end = v->files_[level][i-1]->largest; + const InternalKey& this_begin = v->files_[level][i]->smallest; + if (vset_->icmp_.Compare(prev_end, this_begin) >= 0) { + fprintf(stderr, "overlapping ranges in same level %s vs. %s\n", + prev_end.DebugString().c_str(), + this_begin.DebugString().c_str()); + abort(); + } + } + } +#endif + } + } + + void MaybeAddFile(Version* v, int level, FileMetaData* f) { + if (levels_[level].deleted_files.count(f->number) > 0) { + // File is deleted: do nothing + } else { + std::vector* files = &v->files_[level]; + if (level > 0 && !files->empty()) { + // Must not overlap + assert(vset_->icmp_.Compare((*files)[files->size()-1]->largest, + f->smallest) < 0); + } + f->refs++; + files->push_back(f); + } + } +}; + +VersionSet::VersionSet(const std::string& dbname, + const Options* options, + TableCache* table_cache, + const InternalKeyComparator* cmp) + : env_(options->env), + dbname_(dbname), + options_(options), + table_cache_(table_cache), + icmp_(*cmp), + next_file_number_(2), + manifest_file_number_(0), // Filled by Recover() + last_sequence_(0), + log_number_(0), + prev_log_number_(0), + descriptor_file_(NULL), + descriptor_log_(NULL), + dummy_versions_(this), + current_(NULL) { + AppendVersion(new Version(this)); +} + +VersionSet::~VersionSet() { + current_->Unref(); + assert(dummy_versions_.next_ == &dummy_versions_); // List must be empty + delete descriptor_log_; + delete descriptor_file_; +} + +void VersionSet::AppendVersion(Version* v) { + // Make "v" current + assert(v->refs_ == 0); + assert(v != current_); + if (current_ != NULL) { + current_->Unref(); + } + current_ = v; + v->Ref(); + + // Append to linked list + v->prev_ = dummy_versions_.prev_; + v->next_ = &dummy_versions_; + v->prev_->next_ = v; + v->next_->prev_ = v; +} + +Status VersionSet::LogAndApply(VersionEdit* edit, port::Mutex* mu) { + if (edit->has_log_number_) { + assert(edit->log_number_ >= log_number_); + assert(edit->log_number_ < next_file_number_); + } else { + edit->SetLogNumber(log_number_); + } + + if (!edit->has_prev_log_number_) { + edit->SetPrevLogNumber(prev_log_number_); + } + + edit->SetNextFile(next_file_number_); + edit->SetLastSequence(last_sequence_); + + Version* v = new Version(this); + { + Builder builder(this, current_); + builder.Apply(edit); + builder.SaveTo(v); + } + Finalize(v); + + // Initialize new descriptor log file if necessary by creating + // a temporary file that contains a snapshot of the current version. + std::string new_manifest_file; + Status s; + if (descriptor_log_ == NULL) { + // No reason to unlock *mu here since we only hit this path in the + // first call to LogAndApply (when opening the database). + assert(descriptor_file_ == NULL); + new_manifest_file = DescriptorFileName(dbname_, manifest_file_number_); + edit->SetNextFile(next_file_number_); + s = env_->NewWritableFile(new_manifest_file, &descriptor_file_); + if (s.ok()) { + descriptor_log_ = new log::Writer(descriptor_file_); + s = WriteSnapshot(descriptor_log_); + } + } + + // Unlock during expensive MANIFEST log write + { + mu->Unlock(); + + // Write new record to MANIFEST log + if (s.ok()) { + std::string record; + edit->EncodeTo(&record); + s = descriptor_log_->AddRecord(record); + if (s.ok()) { + s = descriptor_file_->Sync(); + } + if (!s.ok()) { + Log(options_->info_log, "MANIFEST write: %s\n", s.ToString().c_str()); + } + } + + // If we just created a new descriptor file, install it by writing a + // new CURRENT file that points to it. + if (s.ok() && !new_manifest_file.empty()) { + s = SetCurrentFile(env_, dbname_, manifest_file_number_); + } + + mu->Lock(); + } + + // Install the new version + if (s.ok()) { + AppendVersion(v); + log_number_ = edit->log_number_; + prev_log_number_ = edit->prev_log_number_; + } else { + delete v; + if (!new_manifest_file.empty()) { + delete descriptor_log_; + delete descriptor_file_; + descriptor_log_ = NULL; + descriptor_file_ = NULL; + env_->DeleteFile(new_manifest_file); + } + } + + return s; +} + +Status VersionSet::Recover() { + struct LogReporter : public log::Reader::Reporter { + Status* status; + virtual void Corruption(size_t bytes, const Status& s) { + if (this->status->ok()) *this->status = s; + } + }; + + // Read "CURRENT" file, which contains a pointer to the current manifest file + std::string current; + Status s = ReadFileToString(env_, CurrentFileName(dbname_), ¤t); + if (!s.ok()) { + return s; + } + if (current.empty() || current[current.size()-1] != '\n') { + return Status::Corruption("CURRENT file does not end with newline"); + } + current.resize(current.size() - 1); + + std::string dscname = dbname_ + "/" + current; + SequentialFile* file; + s = env_->NewSequentialFile(dscname, &file); + if (!s.ok()) { + return s; + } + + bool have_log_number = false; + bool have_prev_log_number = false; + bool have_next_file = false; + bool have_last_sequence = false; + uint64_t next_file = 0; + uint64_t last_sequence = 0; + uint64_t log_number = 0; + uint64_t prev_log_number = 0; + Builder builder(this, current_); + + { + LogReporter reporter; + reporter.status = &s; + log::Reader reader(file, &reporter, true/*checksum*/, 0/*initial_offset*/); + Slice record; + std::string scratch; + while (reader.ReadRecord(&record, &scratch) && s.ok()) { + VersionEdit edit; + s = edit.DecodeFrom(record); + if (s.ok()) { + if (edit.has_comparator_ && + edit.comparator_ != icmp_.user_comparator()->Name()) { + s = Status::InvalidArgument( + edit.comparator_ + " does not match existing comparator ", + icmp_.user_comparator()->Name()); + } + } + + if (s.ok()) { + builder.Apply(&edit); + } + + if (edit.has_log_number_) { + log_number = edit.log_number_; + have_log_number = true; + } + + if (edit.has_prev_log_number_) { + prev_log_number = edit.prev_log_number_; + have_prev_log_number = true; + } + + if (edit.has_next_file_number_) { + next_file = edit.next_file_number_; + have_next_file = true; + } + + if (edit.has_last_sequence_) { + last_sequence = edit.last_sequence_; + have_last_sequence = true; + } + } + } + delete file; + file = NULL; + + if (s.ok()) { + if (!have_next_file) { + s = Status::Corruption("no meta-nextfile entry in descriptor"); + } else if (!have_log_number) { + s = Status::Corruption("no meta-lognumber entry in descriptor"); + } else if (!have_last_sequence) { + s = Status::Corruption("no last-sequence-number entry in descriptor"); + } + + if (!have_prev_log_number) { + prev_log_number = 0; + } + + MarkFileNumberUsed(prev_log_number); + MarkFileNumberUsed(log_number); + } + + if (s.ok()) { + Version* v = new Version(this); + builder.SaveTo(v); + // Install recovered version + Finalize(v); + AppendVersion(v); + manifest_file_number_ = next_file; + next_file_number_ = next_file + 1; + last_sequence_ = last_sequence; + log_number_ = log_number; + prev_log_number_ = prev_log_number; + } + + return s; +} + +void VersionSet::MarkFileNumberUsed(uint64_t number) { + if (next_file_number_ <= number) { + next_file_number_ = number + 1; + } +} + +void VersionSet::Finalize(Version* v) { + // Precomputed best level for next compaction + int best_level = -1; + double best_score = -1; + + for (int level = 0; level < config::kNumLevels-1; level++) { + double score; + if (level == 0) { + // We treat level-0 specially by bounding the number of files + // instead of number of bytes for two reasons: + // + // (1) With larger write-buffer sizes, it is nice not to do too + // many level-0 compactions. + // + // (2) The files in level-0 are merged on every read and + // therefore we wish to avoid too many files when the individual + // file size is small (perhaps because of a small write-buffer + // setting, or very high compression ratios, or lots of + // overwrites/deletions). + score = v->files_[level].size() / + static_cast(config::kL0_CompactionTrigger); + } else { + // Compute the ratio of current size to size limit. + const uint64_t level_bytes = TotalFileSize(v->files_[level]); + score = static_cast(level_bytes) / MaxBytesForLevel(level); + } + + if (score > best_score) { + best_level = level; + best_score = score; + } + } + + v->compaction_level_ = best_level; + v->compaction_score_ = best_score; +} + +Status VersionSet::WriteSnapshot(log::Writer* log) { + // TODO: Break up into multiple records to reduce memory usage on recovery? + + // Save metadata + VersionEdit edit; + edit.SetComparatorName(icmp_.user_comparator()->Name()); + + // Save compaction pointers + for (int level = 0; level < config::kNumLevels; level++) { + if (!compact_pointer_[level].empty()) { + InternalKey key; + key.DecodeFrom(compact_pointer_[level]); + edit.SetCompactPointer(level, key); + } + } + + // Save files + for (int level = 0; level < config::kNumLevels; level++) { + const std::vector& files = current_->files_[level]; + for (size_t i = 0; i < files.size(); i++) { + const FileMetaData* f = files[i]; + edit.AddFile(level, f->number, f->file_size, f->smallest, f->largest); + } + } + + std::string record; + edit.EncodeTo(&record); + return log->AddRecord(record); +} + +int VersionSet::NumLevelFiles(int level) const { + assert(level >= 0); + assert(level < config::kNumLevels); + return current_->files_[level].size(); +} + +const char* VersionSet::LevelSummary(LevelSummaryStorage* scratch) const { + // Update code if kNumLevels changes + assert(config::kNumLevels == 7); + snprintf(scratch->buffer, sizeof(scratch->buffer), + "files[ %d %d %d %d %d %d %d ]", + int(current_->files_[0].size()), + int(current_->files_[1].size()), + int(current_->files_[2].size()), + int(current_->files_[3].size()), + int(current_->files_[4].size()), + int(current_->files_[5].size()), + int(current_->files_[6].size())); + return scratch->buffer; +} + +uint64_t VersionSet::ApproximateOffsetOf(Version* v, const InternalKey& ikey) { + uint64_t result = 0; + for (int level = 0; level < config::kNumLevels; level++) { + const std::vector& files = v->files_[level]; + for (size_t i = 0; i < files.size(); i++) { + if (icmp_.Compare(files[i]->largest, ikey) <= 0) { + // Entire file is before "ikey", so just add the file size + result += files[i]->file_size; + } else if (icmp_.Compare(files[i]->smallest, ikey) > 0) { + // Entire file is after "ikey", so ignore + if (level > 0) { + // Files other than level 0 are sorted by meta->smallest, so + // no further files in this level will contain data for + // "ikey". + break; + } + } else { + // "ikey" falls in the range for this table. Add the + // approximate offset of "ikey" within the table. + Table* tableptr; + Iterator* iter = table_cache_->NewIterator( + ReadOptions(), files[i]->number, files[i]->file_size, &tableptr); + if (tableptr != NULL) { + result += tableptr->ApproximateOffsetOf(ikey.Encode()); + } + delete iter; + } + } + } + return result; +} + +void VersionSet::AddLiveFiles(std::set* live) { + for (Version* v = dummy_versions_.next_; + v != &dummy_versions_; + v = v->next_) { + for (int level = 0; level < config::kNumLevels; level++) { + const std::vector& files = v->files_[level]; + for (size_t i = 0; i < files.size(); i++) { + live->insert(files[i]->number); + } + } + } +} + +int64_t VersionSet::NumLevelBytes(int level) const { + assert(level >= 0); + assert(level < config::kNumLevels); + return TotalFileSize(current_->files_[level]); +} + +int64_t VersionSet::MaxNextLevelOverlappingBytes() { + int64_t result = 0; + std::vector overlaps; + for (int level = 1; level < config::kNumLevels - 1; level++) { + for (size_t i = 0; i < current_->files_[level].size(); i++) { + const FileMetaData* f = current_->files_[level][i]; + current_->GetOverlappingInputs(level+1, &f->smallest, &f->largest, + &overlaps); + const int64_t sum = TotalFileSize(overlaps); + if (sum > result) { + result = sum; + } + } + } + return result; +} + +// Stores the minimal range that covers all entries in inputs in +// *smallest, *largest. +// REQUIRES: inputs is not empty +void VersionSet::GetRange(const std::vector& inputs, + InternalKey* smallest, + InternalKey* largest) { + assert(!inputs.empty()); + smallest->Clear(); + largest->Clear(); + for (size_t i = 0; i < inputs.size(); i++) { + FileMetaData* f = inputs[i]; + if (i == 0) { + *smallest = f->smallest; + *largest = f->largest; + } else { + if (icmp_.Compare(f->smallest, *smallest) < 0) { + *smallest = f->smallest; + } + if (icmp_.Compare(f->largest, *largest) > 0) { + *largest = f->largest; + } + } + } +} + +// Stores the minimal range that covers all entries in inputs1 and inputs2 +// in *smallest, *largest. +// REQUIRES: inputs is not empty +void VersionSet::GetRange2(const std::vector& inputs1, + const std::vector& inputs2, + InternalKey* smallest, + InternalKey* largest) { + std::vector all = inputs1; + all.insert(all.end(), inputs2.begin(), inputs2.end()); + GetRange(all, smallest, largest); +} + +Iterator* VersionSet::MakeInputIterator(Compaction* c) { + ReadOptions options; + options.verify_checksums = options_->paranoid_checks; + options.fill_cache = false; + + // Level-0 files have to be merged together. For other levels, + // we will make a concatenating iterator per level. + // TODO(opt): use concatenating iterator for level-0 if there is no overlap + const int space = (c->level() == 0 ? c->inputs_[0].size() + 1 : 2); + Iterator** list = new Iterator*[space]; + int num = 0; + for (int which = 0; which < 2; which++) { + if (!c->inputs_[which].empty()) { + if (c->level() + which == 0) { + const std::vector& files = c->inputs_[which]; + for (size_t i = 0; i < files.size(); i++) { + list[num++] = table_cache_->NewIterator( + options, files[i]->number, files[i]->file_size); + } + } else { + // Create concatenating iterator for the files from this level + list[num++] = NewTwoLevelIterator( + new Version::LevelFileNumIterator(icmp_, &c->inputs_[which]), + &GetFileIterator, table_cache_, options); + } + } + } + assert(num <= space); + Iterator* result = NewMergingIterator(&icmp_, list, num); + delete[] list; + return result; +} + +Compaction* VersionSet::PickCompaction() { + Compaction* c; + int level; + + // We prefer compactions triggered by too much data in a level over + // the compactions triggered by seeks. + const bool size_compaction = (current_->compaction_score_ >= 1); + const bool seek_compaction = (current_->file_to_compact_ != NULL); + if (size_compaction) { + level = current_->compaction_level_; + assert(level >= 0); + assert(level+1 < config::kNumLevels); + c = new Compaction(level); + + // Pick the first file that comes after compact_pointer_[level] + for (size_t i = 0; i < current_->files_[level].size(); i++) { + FileMetaData* f = current_->files_[level][i]; + if (compact_pointer_[level].empty() || + icmp_.Compare(f->largest.Encode(), compact_pointer_[level]) > 0) { + c->inputs_[0].push_back(f); + break; + } + } + if (c->inputs_[0].empty()) { + // Wrap-around to the beginning of the key space + c->inputs_[0].push_back(current_->files_[level][0]); + } + } else if (seek_compaction) { + level = current_->file_to_compact_level_; + c = new Compaction(level); + c->inputs_[0].push_back(current_->file_to_compact_); + } else { + return NULL; + } + + c->input_version_ = current_; + c->input_version_->Ref(); + + // Files in level 0 may overlap each other, so pick up all overlapping ones + if (level == 0) { + InternalKey smallest, largest; + GetRange(c->inputs_[0], &smallest, &largest); + // Note that the next call will discard the file we placed in + // c->inputs_[0] earlier and replace it with an overlapping set + // which will include the picked file. + current_->GetOverlappingInputs(0, &smallest, &largest, &c->inputs_[0]); + assert(!c->inputs_[0].empty()); + } + + SetupOtherInputs(c); + + return c; +} + +void VersionSet::SetupOtherInputs(Compaction* c) { + const int level = c->level(); + InternalKey smallest, largest; + GetRange(c->inputs_[0], &smallest, &largest); + + current_->GetOverlappingInputs(level+1, &smallest, &largest, &c->inputs_[1]); + + // Get entire range covered by compaction + InternalKey all_start, all_limit; + GetRange2(c->inputs_[0], c->inputs_[1], &all_start, &all_limit); + + // See if we can grow the number of inputs in "level" without + // changing the number of "level+1" files we pick up. + if (!c->inputs_[1].empty()) { + std::vector expanded0; + current_->GetOverlappingInputs(level, &all_start, &all_limit, &expanded0); + const int64_t inputs0_size = TotalFileSize(c->inputs_[0]); + const int64_t inputs1_size = TotalFileSize(c->inputs_[1]); + const int64_t expanded0_size = TotalFileSize(expanded0); + if (expanded0.size() > c->inputs_[0].size() && + inputs1_size + expanded0_size < kExpandedCompactionByteSizeLimit) { + InternalKey new_start, new_limit; + GetRange(expanded0, &new_start, &new_limit); + std::vector expanded1; + current_->GetOverlappingInputs(level+1, &new_start, &new_limit, + &expanded1); + if (expanded1.size() == c->inputs_[1].size()) { + Log(options_->info_log, + "Expanding@%d %d+%d (%ld+%ld bytes) to %d+%d (%ld+%ld bytes)\n", + level, + int(c->inputs_[0].size()), + int(c->inputs_[1].size()), + long(inputs0_size), long(inputs1_size), + int(expanded0.size()), + int(expanded1.size()), + long(expanded0_size), long(inputs1_size)); + smallest = new_start; + largest = new_limit; + c->inputs_[0] = expanded0; + c->inputs_[1] = expanded1; + GetRange2(c->inputs_[0], c->inputs_[1], &all_start, &all_limit); + } + } + } + + // Compute the set of grandparent files that overlap this compaction + // (parent == level+1; grandparent == level+2) + if (level + 2 < config::kNumLevels) { + current_->GetOverlappingInputs(level + 2, &all_start, &all_limit, + &c->grandparents_); + } + + if (false) { + Log(options_->info_log, "Compacting %d '%s' .. '%s'", + level, + smallest.DebugString().c_str(), + largest.DebugString().c_str()); + } + + // Update the place where we will do the next compaction for this level. + // We update this immediately instead of waiting for the VersionEdit + // to be applied so that if the compaction fails, we will try a different + // key range next time. + compact_pointer_[level] = largest.Encode().ToString(); + c->edit_.SetCompactPointer(level, largest); +} + +Compaction* VersionSet::CompactRange( + int level, + const InternalKey* begin, + const InternalKey* end) { + std::vector inputs; + current_->GetOverlappingInputs(level, begin, end, &inputs); + if (inputs.empty()) { + return NULL; + } + + // Avoid compacting too much in one shot in case the range is large. + // But we cannot do this for level-0 since level-0 files can overlap + // and we must not pick one file and drop another older file if the + // two files overlap. + if (level > 0) { + const uint64_t limit = MaxFileSizeForLevel(level); + uint64_t total = 0; + for (size_t i = 0; i < inputs.size(); i++) { + uint64_t s = inputs[i]->file_size; + total += s; + if (total >= limit) { + inputs.resize(i + 1); + break; + } + } + } + + Compaction* c = new Compaction(level); + c->input_version_ = current_; + c->input_version_->Ref(); + c->inputs_[0] = inputs; + SetupOtherInputs(c); + return c; +} + +Compaction::Compaction(int level) + : level_(level), + max_output_file_size_(MaxFileSizeForLevel(level)), + input_version_(NULL), + grandparent_index_(0), + seen_key_(false), + overlapped_bytes_(0) { + for (int i = 0; i < config::kNumLevels; i++) { + level_ptrs_[i] = 0; + } +} + +Compaction::~Compaction() { + if (input_version_ != NULL) { + input_version_->Unref(); + } +} + +bool Compaction::IsTrivialMove() const { + // Avoid a move if there is lots of overlapping grandparent data. + // Otherwise, the move could create a parent file that will require + // a very expensive merge later on. + return (num_input_files(0) == 1 && + num_input_files(1) == 0 && + TotalFileSize(grandparents_) <= kMaxGrandParentOverlapBytes); +} + +void Compaction::AddInputDeletions(VersionEdit* edit) { + for (int which = 0; which < 2; which++) { + for (size_t i = 0; i < inputs_[which].size(); i++) { + edit->DeleteFile(level_ + which, inputs_[which][i]->number); + } + } +} + +bool Compaction::IsBaseLevelForKey(const Slice& user_key) { + // Maybe use binary search to find right entry instead of linear search? + const Comparator* user_cmp = input_version_->vset_->icmp_.user_comparator(); + for (int lvl = level_ + 2; lvl < config::kNumLevels; lvl++) { + const std::vector& files = input_version_->files_[lvl]; + for (; level_ptrs_[lvl] < files.size(); ) { + FileMetaData* f = files[level_ptrs_[lvl]]; + if (user_cmp->Compare(user_key, f->largest.user_key()) <= 0) { + // We've advanced far enough + if (user_cmp->Compare(user_key, f->smallest.user_key()) >= 0) { + // Key falls in this file's range, so definitely not base level + return false; + } + break; + } + level_ptrs_[lvl]++; + } + } + return true; +} + +bool Compaction::ShouldStopBefore(const Slice& internal_key) { + // Scan to find earliest grandparent file that contains key. + const InternalKeyComparator* icmp = &input_version_->vset_->icmp_; + while (grandparent_index_ < grandparents_.size() && + icmp->Compare(internal_key, + grandparents_[grandparent_index_]->largest.Encode()) > 0) { + if (seen_key_) { + overlapped_bytes_ += grandparents_[grandparent_index_]->file_size; + } + grandparent_index_++; + } + seen_key_ = true; + + if (overlapped_bytes_ > kMaxGrandParentOverlapBytes) { + // Too much overlap for current output; start new output + overlapped_bytes_ = 0; + return true; + } else { + return false; + } +} + +void Compaction::ReleaseInputs() { + if (input_version_ != NULL) { + input_version_->Unref(); + input_version_ = NULL; + } +} + +} // namespace leveldb diff --git a/src/leveldb/db/version_set.h b/src/leveldb/db/version_set.h new file mode 100644 index 0000000..8dc14b8 --- /dev/null +++ b/src/leveldb/db/version_set.h @@ -0,0 +1,396 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// The representation of a DBImpl consists of a set of Versions. The +// newest version is called "current". Older versions may be kept +// around to provide a consistent view to live iterators. +// +// Each Version keeps track of a set of Table files per level. The +// entire set of versions is maintained in a VersionSet. +// +// Version,VersionSet are thread-compatible, but require external +// synchronization on all accesses. + +#ifndef STORAGE_LEVELDB_DB_VERSION_SET_H_ +#define STORAGE_LEVELDB_DB_VERSION_SET_H_ + +#include +#include +#include +#include "db/dbformat.h" +#include "db/version_edit.h" +#include "port/port.h" +#include "port/thread_annotations.h" + +namespace leveldb { + +namespace log { class Writer; } + +class Compaction; +class Iterator; +class MemTable; +class TableBuilder; +class TableCache; +class Version; +class VersionSet; +class WritableFile; + +// Return the smallest index i such that files[i]->largest >= key. +// Return files.size() if there is no such file. +// REQUIRES: "files" contains a sorted list of non-overlapping files. +extern int FindFile(const InternalKeyComparator& icmp, + const std::vector& files, + const Slice& key); + +// Returns true iff some file in "files" overlaps the user key range +// [*smallest,*largest]. +// smallest==NULL represents a key smaller than all keys in the DB. +// largest==NULL represents a key largest than all keys in the DB. +// REQUIRES: If disjoint_sorted_files, files[] contains disjoint ranges +// in sorted order. +extern bool SomeFileOverlapsRange( + const InternalKeyComparator& icmp, + bool disjoint_sorted_files, + const std::vector& files, + const Slice* smallest_user_key, + const Slice* largest_user_key); + +class Version { + public: + // Append to *iters a sequence of iterators that will + // yield the contents of this Version when merged together. + // REQUIRES: This version has been saved (see VersionSet::SaveTo) + void AddIterators(const ReadOptions&, std::vector* iters); + + // Lookup the value for key. If found, store it in *val and + // return OK. Else return a non-OK status. Fills *stats. + // REQUIRES: lock is not held + struct GetStats { + FileMetaData* seek_file; + int seek_file_level; + }; + Status Get(const ReadOptions&, const LookupKey& key, std::string* val, + GetStats* stats); + + // Adds "stats" into the current state. Returns true if a new + // compaction may need to be triggered, false otherwise. + // REQUIRES: lock is held + bool UpdateStats(const GetStats& stats); + + // Record a sample of bytes read at the specified internal key. + // Samples are taken approximately once every config::kReadBytesPeriod + // bytes. Returns true if a new compaction may need to be triggered. + // REQUIRES: lock is held + bool RecordReadSample(Slice key); + + // Reference count management (so Versions do not disappear out from + // under live iterators) + void Ref(); + void Unref(); + + void GetOverlappingInputs( + int level, + const InternalKey* begin, // NULL means before all keys + const InternalKey* end, // NULL means after all keys + std::vector* inputs); + + // Returns true iff some file in the specified level overlaps + // some part of [*smallest_user_key,*largest_user_key]. + // smallest_user_key==NULL represents a key smaller than all keys in the DB. + // largest_user_key==NULL represents a key largest than all keys in the DB. + bool OverlapInLevel(int level, + const Slice* smallest_user_key, + const Slice* largest_user_key); + + // Return the level at which we should place a new memtable compaction + // result that covers the range [smallest_user_key,largest_user_key]. + int PickLevelForMemTableOutput(const Slice& smallest_user_key, + const Slice& largest_user_key); + + int NumFiles(int level) const { return files_[level].size(); } + + // Return a human readable string that describes this version's contents. + std::string DebugString() const; + + private: + friend class Compaction; + friend class VersionSet; + + class LevelFileNumIterator; + Iterator* NewConcatenatingIterator(const ReadOptions&, int level) const; + + // Call func(arg, level, f) for every file that overlaps user_key in + // order from newest to oldest. If an invocation of func returns + // false, makes no more calls. + // + // REQUIRES: user portion of internal_key == user_key. + void ForEachOverlapping(Slice user_key, Slice internal_key, + void* arg, + bool (*func)(void*, int, FileMetaData*)); + + VersionSet* vset_; // VersionSet to which this Version belongs + Version* next_; // Next version in linked list + Version* prev_; // Previous version in linked list + int refs_; // Number of live refs to this version + + // List of files per level + std::vector files_[config::kNumLevels]; + + // Next file to compact based on seek stats. + FileMetaData* file_to_compact_; + int file_to_compact_level_; + + // Level that should be compacted next and its compaction score. + // Score < 1 means compaction is not strictly needed. These fields + // are initialized by Finalize(). + double compaction_score_; + int compaction_level_; + + explicit Version(VersionSet* vset) + : vset_(vset), next_(this), prev_(this), refs_(0), + file_to_compact_(NULL), + file_to_compact_level_(-1), + compaction_score_(-1), + compaction_level_(-1) { + } + + ~Version(); + + // No copying allowed + Version(const Version&); + void operator=(const Version&); +}; + +class VersionSet { + public: + VersionSet(const std::string& dbname, + const Options* options, + TableCache* table_cache, + const InternalKeyComparator*); + ~VersionSet(); + + // Apply *edit to the current version to form a new descriptor that + // is both saved to persistent state and installed as the new + // current version. Will release *mu while actually writing to the file. + // REQUIRES: *mu is held on entry. + // REQUIRES: no other thread concurrently calls LogAndApply() + Status LogAndApply(VersionEdit* edit, port::Mutex* mu) + EXCLUSIVE_LOCKS_REQUIRED(mu); + + // Recover the last saved descriptor from persistent storage. + Status Recover(); + + // Return the current version. + Version* current() const { return current_; } + + // Return the current manifest file number + uint64_t ManifestFileNumber() const { return manifest_file_number_; } + + // Allocate and return a new file number + uint64_t NewFileNumber() { return next_file_number_++; } + + // Arrange to reuse "file_number" unless a newer file number has + // already been allocated. + // REQUIRES: "file_number" was returned by a call to NewFileNumber(). + void ReuseFileNumber(uint64_t file_number) { + if (next_file_number_ == file_number + 1) { + next_file_number_ = file_number; + } + } + + // Return the number of Table files at the specified level. + int NumLevelFiles(int level) const; + + // Return the combined file size of all files at the specified level. + int64_t NumLevelBytes(int level) const; + + // Return the last sequence number. + uint64_t LastSequence() const { return last_sequence_; } + + // Set the last sequence number to s. + void SetLastSequence(uint64_t s) { + assert(s >= last_sequence_); + last_sequence_ = s; + } + + // Mark the specified file number as used. + void MarkFileNumberUsed(uint64_t number); + + // Return the current log file number. + uint64_t LogNumber() const { return log_number_; } + + // Return the log file number for the log file that is currently + // being compacted, or zero if there is no such log file. + uint64_t PrevLogNumber() const { return prev_log_number_; } + + // Pick level and inputs for a new compaction. + // Returns NULL if there is no compaction to be done. + // Otherwise returns a pointer to a heap-allocated object that + // describes the compaction. Caller should delete the result. + Compaction* PickCompaction(); + + // Return a compaction object for compacting the range [begin,end] in + // the specified level. Returns NULL if there is nothing in that + // level that overlaps the specified range. Caller should delete + // the result. + Compaction* CompactRange( + int level, + const InternalKey* begin, + const InternalKey* end); + + // Return the maximum overlapping data (in bytes) at next level for any + // file at a level >= 1. + int64_t MaxNextLevelOverlappingBytes(); + + // Create an iterator that reads over the compaction inputs for "*c". + // The caller should delete the iterator when no longer needed. + Iterator* MakeInputIterator(Compaction* c); + + // Returns true iff some level needs a compaction. + bool NeedsCompaction() const { + Version* v = current_; + return (v->compaction_score_ >= 1) || (v->file_to_compact_ != NULL); + } + + // Add all files listed in any live version to *live. + // May also mutate some internal state. + void AddLiveFiles(std::set* live); + + // Return the approximate offset in the database of the data for + // "key" as of version "v". + uint64_t ApproximateOffsetOf(Version* v, const InternalKey& key); + + // Return a human-readable short (single-line) summary of the number + // of files per level. Uses *scratch as backing store. + struct LevelSummaryStorage { + char buffer[100]; + }; + const char* LevelSummary(LevelSummaryStorage* scratch) const; + + private: + class Builder; + + friend class Compaction; + friend class Version; + + void Finalize(Version* v); + + void GetRange(const std::vector& inputs, + InternalKey* smallest, + InternalKey* largest); + + void GetRange2(const std::vector& inputs1, + const std::vector& inputs2, + InternalKey* smallest, + InternalKey* largest); + + void SetupOtherInputs(Compaction* c); + + // Save current contents to *log + Status WriteSnapshot(log::Writer* log); + + void AppendVersion(Version* v); + + Env* const env_; + const std::string dbname_; + const Options* const options_; + TableCache* const table_cache_; + const InternalKeyComparator icmp_; + uint64_t next_file_number_; + uint64_t manifest_file_number_; + uint64_t last_sequence_; + uint64_t log_number_; + uint64_t prev_log_number_; // 0 or backing store for memtable being compacted + + // Opened lazily + WritableFile* descriptor_file_; + log::Writer* descriptor_log_; + Version dummy_versions_; // Head of circular doubly-linked list of versions. + Version* current_; // == dummy_versions_.prev_ + + // Per-level key at which the next compaction at that level should start. + // Either an empty string, or a valid InternalKey. + std::string compact_pointer_[config::kNumLevels]; + + // No copying allowed + VersionSet(const VersionSet&); + void operator=(const VersionSet&); +}; + +// A Compaction encapsulates information about a compaction. +class Compaction { + public: + ~Compaction(); + + // Return the level that is being compacted. Inputs from "level" + // and "level+1" will be merged to produce a set of "level+1" files. + int level() const { return level_; } + + // Return the object that holds the edits to the descriptor done + // by this compaction. + VersionEdit* edit() { return &edit_; } + + // "which" must be either 0 or 1 + int num_input_files(int which) const { return inputs_[which].size(); } + + // Return the ith input file at "level()+which" ("which" must be 0 or 1). + FileMetaData* input(int which, int i) const { return inputs_[which][i]; } + + // Maximum size of files to build during this compaction. + uint64_t MaxOutputFileSize() const { return max_output_file_size_; } + + // Is this a trivial compaction that can be implemented by just + // moving a single input file to the next level (no merging or splitting) + bool IsTrivialMove() const; + + // Add all inputs to this compaction as delete operations to *edit. + void AddInputDeletions(VersionEdit* edit); + + // Returns true if the information we have available guarantees that + // the compaction is producing data in "level+1" for which no data exists + // in levels greater than "level+1". + bool IsBaseLevelForKey(const Slice& user_key); + + // Returns true iff we should stop building the current output + // before processing "internal_key". + bool ShouldStopBefore(const Slice& internal_key); + + // Release the input version for the compaction, once the compaction + // is successful. + void ReleaseInputs(); + + private: + friend class Version; + friend class VersionSet; + + explicit Compaction(int level); + + int level_; + uint64_t max_output_file_size_; + Version* input_version_; + VersionEdit edit_; + + // Each compaction reads inputs from "level_" and "level_+1" + std::vector inputs_[2]; // The two sets of inputs + + // State used to check for number of of overlapping grandparent files + // (parent == level_ + 1, grandparent == level_ + 2) + std::vector grandparents_; + size_t grandparent_index_; // Index in grandparent_starts_ + bool seen_key_; // Some output key has been seen + int64_t overlapped_bytes_; // Bytes of overlap between current output + // and grandparent files + + // State for implementing IsBaseLevelForKey + + // level_ptrs_ holds indices into input_version_->levels_: our state + // is that we are positioned at one of the file ranges for each + // higher level than the ones involved in this compaction (i.e. for + // all L >= level_ + 2). + size_t level_ptrs_[config::kNumLevels]; +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_DB_VERSION_SET_H_ diff --git a/src/leveldb/db/version_set_test.cc b/src/leveldb/db/version_set_test.cc new file mode 100644 index 0000000..501e34d --- /dev/null +++ b/src/leveldb/db/version_set_test.cc @@ -0,0 +1,179 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "db/version_set.h" +#include "util/logging.h" +#include "util/testharness.h" +#include "util/testutil.h" + +namespace leveldb { + +class FindFileTest { + public: + std::vector files_; + bool disjoint_sorted_files_; + + FindFileTest() : disjoint_sorted_files_(true) { } + + ~FindFileTest() { + for (int i = 0; i < files_.size(); i++) { + delete files_[i]; + } + } + + void Add(const char* smallest, const char* largest, + SequenceNumber smallest_seq = 100, + SequenceNumber largest_seq = 100) { + FileMetaData* f = new FileMetaData; + f->number = files_.size() + 1; + f->smallest = InternalKey(smallest, smallest_seq, kTypeValue); + f->largest = InternalKey(largest, largest_seq, kTypeValue); + files_.push_back(f); + } + + int Find(const char* key) { + InternalKey target(key, 100, kTypeValue); + InternalKeyComparator cmp(BytewiseComparator()); + return FindFile(cmp, files_, target.Encode()); + } + + bool Overlaps(const char* smallest, const char* largest) { + InternalKeyComparator cmp(BytewiseComparator()); + Slice s(smallest != NULL ? smallest : ""); + Slice l(largest != NULL ? largest : ""); + return SomeFileOverlapsRange(cmp, disjoint_sorted_files_, files_, + (smallest != NULL ? &s : NULL), + (largest != NULL ? &l : NULL)); + } +}; + +TEST(FindFileTest, Empty) { + ASSERT_EQ(0, Find("foo")); + ASSERT_TRUE(! Overlaps("a", "z")); + ASSERT_TRUE(! Overlaps(NULL, "z")); + ASSERT_TRUE(! Overlaps("a", NULL)); + ASSERT_TRUE(! Overlaps(NULL, NULL)); +} + +TEST(FindFileTest, Single) { + Add("p", "q"); + ASSERT_EQ(0, Find("a")); + ASSERT_EQ(0, Find("p")); + ASSERT_EQ(0, Find("p1")); + ASSERT_EQ(0, Find("q")); + ASSERT_EQ(1, Find("q1")); + ASSERT_EQ(1, Find("z")); + + ASSERT_TRUE(! Overlaps("a", "b")); + ASSERT_TRUE(! Overlaps("z1", "z2")); + ASSERT_TRUE(Overlaps("a", "p")); + ASSERT_TRUE(Overlaps("a", "q")); + ASSERT_TRUE(Overlaps("a", "z")); + ASSERT_TRUE(Overlaps("p", "p1")); + ASSERT_TRUE(Overlaps("p", "q")); + ASSERT_TRUE(Overlaps("p", "z")); + ASSERT_TRUE(Overlaps("p1", "p2")); + ASSERT_TRUE(Overlaps("p1", "z")); + ASSERT_TRUE(Overlaps("q", "q")); + ASSERT_TRUE(Overlaps("q", "q1")); + + ASSERT_TRUE(! Overlaps(NULL, "j")); + ASSERT_TRUE(! Overlaps("r", NULL)); + ASSERT_TRUE(Overlaps(NULL, "p")); + ASSERT_TRUE(Overlaps(NULL, "p1")); + ASSERT_TRUE(Overlaps("q", NULL)); + ASSERT_TRUE(Overlaps(NULL, NULL)); +} + + +TEST(FindFileTest, Multiple) { + Add("150", "200"); + Add("200", "250"); + Add("300", "350"); + Add("400", "450"); + ASSERT_EQ(0, Find("100")); + ASSERT_EQ(0, Find("150")); + ASSERT_EQ(0, Find("151")); + ASSERT_EQ(0, Find("199")); + ASSERT_EQ(0, Find("200")); + ASSERT_EQ(1, Find("201")); + ASSERT_EQ(1, Find("249")); + ASSERT_EQ(1, Find("250")); + ASSERT_EQ(2, Find("251")); + ASSERT_EQ(2, Find("299")); + ASSERT_EQ(2, Find("300")); + ASSERT_EQ(2, Find("349")); + ASSERT_EQ(2, Find("350")); + ASSERT_EQ(3, Find("351")); + ASSERT_EQ(3, Find("400")); + ASSERT_EQ(3, Find("450")); + ASSERT_EQ(4, Find("451")); + + ASSERT_TRUE(! Overlaps("100", "149")); + ASSERT_TRUE(! Overlaps("251", "299")); + ASSERT_TRUE(! Overlaps("451", "500")); + ASSERT_TRUE(! Overlaps("351", "399")); + + ASSERT_TRUE(Overlaps("100", "150")); + ASSERT_TRUE(Overlaps("100", "200")); + ASSERT_TRUE(Overlaps("100", "300")); + ASSERT_TRUE(Overlaps("100", "400")); + ASSERT_TRUE(Overlaps("100", "500")); + ASSERT_TRUE(Overlaps("375", "400")); + ASSERT_TRUE(Overlaps("450", "450")); + ASSERT_TRUE(Overlaps("450", "500")); +} + +TEST(FindFileTest, MultipleNullBoundaries) { + Add("150", "200"); + Add("200", "250"); + Add("300", "350"); + Add("400", "450"); + ASSERT_TRUE(! Overlaps(NULL, "149")); + ASSERT_TRUE(! Overlaps("451", NULL)); + ASSERT_TRUE(Overlaps(NULL, NULL)); + ASSERT_TRUE(Overlaps(NULL, "150")); + ASSERT_TRUE(Overlaps(NULL, "199")); + ASSERT_TRUE(Overlaps(NULL, "200")); + ASSERT_TRUE(Overlaps(NULL, "201")); + ASSERT_TRUE(Overlaps(NULL, "400")); + ASSERT_TRUE(Overlaps(NULL, "800")); + ASSERT_TRUE(Overlaps("100", NULL)); + ASSERT_TRUE(Overlaps("200", NULL)); + ASSERT_TRUE(Overlaps("449", NULL)); + ASSERT_TRUE(Overlaps("450", NULL)); +} + +TEST(FindFileTest, OverlapSequenceChecks) { + Add("200", "200", 5000, 3000); + ASSERT_TRUE(! Overlaps("199", "199")); + ASSERT_TRUE(! Overlaps("201", "300")); + ASSERT_TRUE(Overlaps("200", "200")); + ASSERT_TRUE(Overlaps("190", "200")); + ASSERT_TRUE(Overlaps("200", "210")); +} + +TEST(FindFileTest, OverlappingFiles) { + Add("150", "600"); + Add("400", "500"); + disjoint_sorted_files_ = false; + ASSERT_TRUE(! Overlaps("100", "149")); + ASSERT_TRUE(! Overlaps("601", "700")); + ASSERT_TRUE(Overlaps("100", "150")); + ASSERT_TRUE(Overlaps("100", "200")); + ASSERT_TRUE(Overlaps("100", "300")); + ASSERT_TRUE(Overlaps("100", "400")); + ASSERT_TRUE(Overlaps("100", "500")); + ASSERT_TRUE(Overlaps("375", "400")); + ASSERT_TRUE(Overlaps("450", "450")); + ASSERT_TRUE(Overlaps("450", "500")); + ASSERT_TRUE(Overlaps("450", "700")); + ASSERT_TRUE(Overlaps("600", "700")); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/db/write_batch.cc b/src/leveldb/db/write_batch.cc new file mode 100644 index 0000000..33f4a42 --- /dev/null +++ b/src/leveldb/db/write_batch.cc @@ -0,0 +1,147 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// WriteBatch::rep_ := +// sequence: fixed64 +// count: fixed32 +// data: record[count] +// record := +// kTypeValue varstring varstring | +// kTypeDeletion varstring +// varstring := +// len: varint32 +// data: uint8[len] + +#include "leveldb/write_batch.h" + +#include "leveldb/db.h" +#include "db/dbformat.h" +#include "db/memtable.h" +#include "db/write_batch_internal.h" +#include "util/coding.h" + +namespace leveldb { + +// WriteBatch header has an 8-byte sequence number followed by a 4-byte count. +static const size_t kHeader = 12; + +WriteBatch::WriteBatch() { + Clear(); +} + +WriteBatch::~WriteBatch() { } + +WriteBatch::Handler::~Handler() { } + +void WriteBatch::Clear() { + rep_.clear(); + rep_.resize(kHeader); +} + +Status WriteBatch::Iterate(Handler* handler) const { + Slice input(rep_); + if (input.size() < kHeader) { + return Status::Corruption("malformed WriteBatch (too small)"); + } + + input.remove_prefix(kHeader); + Slice key, value; + int found = 0; + while (!input.empty()) { + found++; + char tag = input[0]; + input.remove_prefix(1); + switch (tag) { + case kTypeValue: + if (GetLengthPrefixedSlice(&input, &key) && + GetLengthPrefixedSlice(&input, &value)) { + handler->Put(key, value); + } else { + return Status::Corruption("bad WriteBatch Put"); + } + break; + case kTypeDeletion: + if (GetLengthPrefixedSlice(&input, &key)) { + handler->Delete(key); + } else { + return Status::Corruption("bad WriteBatch Delete"); + } + break; + default: + return Status::Corruption("unknown WriteBatch tag"); + } + } + if (found != WriteBatchInternal::Count(this)) { + return Status::Corruption("WriteBatch has wrong count"); + } else { + return Status::OK(); + } +} + +int WriteBatchInternal::Count(const WriteBatch* b) { + return DecodeFixed32(b->rep_.data() + 8); +} + +void WriteBatchInternal::SetCount(WriteBatch* b, int n) { + EncodeFixed32(&b->rep_[8], n); +} + +SequenceNumber WriteBatchInternal::Sequence(const WriteBatch* b) { + return SequenceNumber(DecodeFixed64(b->rep_.data())); +} + +void WriteBatchInternal::SetSequence(WriteBatch* b, SequenceNumber seq) { + EncodeFixed64(&b->rep_[0], seq); +} + +void WriteBatch::Put(const Slice& key, const Slice& value) { + WriteBatchInternal::SetCount(this, WriteBatchInternal::Count(this) + 1); + rep_.push_back(static_cast(kTypeValue)); + PutLengthPrefixedSlice(&rep_, key); + PutLengthPrefixedSlice(&rep_, value); +} + +void WriteBatch::Delete(const Slice& key) { + WriteBatchInternal::SetCount(this, WriteBatchInternal::Count(this) + 1); + rep_.push_back(static_cast(kTypeDeletion)); + PutLengthPrefixedSlice(&rep_, key); +} + +namespace { +class MemTableInserter : public WriteBatch::Handler { + public: + SequenceNumber sequence_; + MemTable* mem_; + + virtual void Put(const Slice& key, const Slice& value) { + mem_->Add(sequence_, kTypeValue, key, value); + sequence_++; + } + virtual void Delete(const Slice& key) { + mem_->Add(sequence_, kTypeDeletion, key, Slice()); + sequence_++; + } +}; +} // namespace + +Status WriteBatchInternal::InsertInto(const WriteBatch* b, + MemTable* memtable) { + MemTableInserter inserter; + inserter.sequence_ = WriteBatchInternal::Sequence(b); + inserter.mem_ = memtable; + return b->Iterate(&inserter); +} + +void WriteBatchInternal::SetContents(WriteBatch* b, const Slice& contents) { + assert(contents.size() >= kHeader); + b->rep_.assign(contents.data(), contents.size()); +} + +void WriteBatchInternal::Append(WriteBatch* dst, const WriteBatch* src) { + SetCount(dst, Count(dst) + Count(src)); + assert(src->rep_.size() >= kHeader); + dst->rep_.append(src->rep_.data() + kHeader, src->rep_.size() - kHeader); +} + +} // namespace leveldb diff --git a/src/leveldb/db/write_batch_internal.h b/src/leveldb/db/write_batch_internal.h new file mode 100644 index 0000000..4423a7f --- /dev/null +++ b/src/leveldb/db/write_batch_internal.h @@ -0,0 +1,49 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ +#define STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ + +#include "leveldb/write_batch.h" + +namespace leveldb { + +class MemTable; + +// WriteBatchInternal provides static methods for manipulating a +// WriteBatch that we don't want in the public WriteBatch interface. +class WriteBatchInternal { + public: + // Return the number of entries in the batch. + static int Count(const WriteBatch* batch); + + // Set the count for the number of entries in the batch. + static void SetCount(WriteBatch* batch, int n); + + // Return the seqeunce number for the start of this batch. + static SequenceNumber Sequence(const WriteBatch* batch); + + // Store the specified number as the seqeunce number for the start of + // this batch. + static void SetSequence(WriteBatch* batch, SequenceNumber seq); + + static Slice Contents(const WriteBatch* batch) { + return Slice(batch->rep_); + } + + static size_t ByteSize(const WriteBatch* batch) { + return batch->rep_.size(); + } + + static void SetContents(WriteBatch* batch, const Slice& contents); + + static Status InsertInto(const WriteBatch* batch, MemTable* memtable); + + static void Append(WriteBatch* dst, const WriteBatch* src); +}; + +} // namespace leveldb + + +#endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ diff --git a/src/leveldb/db/write_batch_test.cc b/src/leveldb/db/write_batch_test.cc new file mode 100644 index 0000000..9064e3d --- /dev/null +++ b/src/leveldb/db/write_batch_test.cc @@ -0,0 +1,120 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/db.h" + +#include "db/memtable.h" +#include "db/write_batch_internal.h" +#include "leveldb/env.h" +#include "util/logging.h" +#include "util/testharness.h" + +namespace leveldb { + +static std::string PrintContents(WriteBatch* b) { + InternalKeyComparator cmp(BytewiseComparator()); + MemTable* mem = new MemTable(cmp); + mem->Ref(); + std::string state; + Status s = WriteBatchInternal::InsertInto(b, mem); + int count = 0; + Iterator* iter = mem->NewIterator(); + for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { + ParsedInternalKey ikey; + ASSERT_TRUE(ParseInternalKey(iter->key(), &ikey)); + switch (ikey.type) { + case kTypeValue: + state.append("Put("); + state.append(ikey.user_key.ToString()); + state.append(", "); + state.append(iter->value().ToString()); + state.append(")"); + count++; + break; + case kTypeDeletion: + state.append("Delete("); + state.append(ikey.user_key.ToString()); + state.append(")"); + count++; + break; + } + state.append("@"); + state.append(NumberToString(ikey.sequence)); + } + delete iter; + if (!s.ok()) { + state.append("ParseError()"); + } else if (count != WriteBatchInternal::Count(b)) { + state.append("CountMismatch()"); + } + mem->Unref(); + return state; +} + +class WriteBatchTest { }; + +TEST(WriteBatchTest, Empty) { + WriteBatch batch; + ASSERT_EQ("", PrintContents(&batch)); + ASSERT_EQ(0, WriteBatchInternal::Count(&batch)); +} + +TEST(WriteBatchTest, Multiple) { + WriteBatch batch; + batch.Put(Slice("foo"), Slice("bar")); + batch.Delete(Slice("box")); + batch.Put(Slice("baz"), Slice("boo")); + WriteBatchInternal::SetSequence(&batch, 100); + ASSERT_EQ(100, WriteBatchInternal::Sequence(&batch)); + ASSERT_EQ(3, WriteBatchInternal::Count(&batch)); + ASSERT_EQ("Put(baz, boo)@102" + "Delete(box)@101" + "Put(foo, bar)@100", + PrintContents(&batch)); +} + +TEST(WriteBatchTest, Corruption) { + WriteBatch batch; + batch.Put(Slice("foo"), Slice("bar")); + batch.Delete(Slice("box")); + WriteBatchInternal::SetSequence(&batch, 200); + Slice contents = WriteBatchInternal::Contents(&batch); + WriteBatchInternal::SetContents(&batch, + Slice(contents.data(),contents.size()-1)); + ASSERT_EQ("Put(foo, bar)@200" + "ParseError()", + PrintContents(&batch)); +} + +TEST(WriteBatchTest, Append) { + WriteBatch b1, b2; + WriteBatchInternal::SetSequence(&b1, 200); + WriteBatchInternal::SetSequence(&b2, 300); + WriteBatchInternal::Append(&b1, &b2); + ASSERT_EQ("", + PrintContents(&b1)); + b2.Put("a", "va"); + WriteBatchInternal::Append(&b1, &b2); + ASSERT_EQ("Put(a, va)@200", + PrintContents(&b1)); + b2.Clear(); + b2.Put("b", "vb"); + WriteBatchInternal::Append(&b1, &b2); + ASSERT_EQ("Put(a, va)@200" + "Put(b, vb)@201", + PrintContents(&b1)); + b2.Delete("foo"); + WriteBatchInternal::Append(&b1, &b2); + ASSERT_EQ("Put(a, va)@200" + "Put(b, vb)@202" + "Put(b, vb)@201" + "Delete(foo)@203", + PrintContents(&b1)); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/doc/bench/db_bench_sqlite3.cc b/src/leveldb/doc/bench/db_bench_sqlite3.cc new file mode 100644 index 0000000..e63aaa8 --- /dev/null +++ b/src/leveldb/doc/bench/db_bench_sqlite3.cc @@ -0,0 +1,718 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include +#include +#include +#include "util/histogram.h" +#include "util/random.h" +#include "util/testutil.h" + +// Comma-separated list of operations to run in the specified order +// Actual benchmarks: +// +// fillseq -- write N values in sequential key order in async mode +// fillseqsync -- write N/100 values in sequential key order in sync mode +// fillseqbatch -- batch write N values in sequential key order in async mode +// fillrandom -- write N values in random key order in async mode +// fillrandsync -- write N/100 values in random key order in sync mode +// fillrandbatch -- batch write N values in sequential key order in async mode +// overwrite -- overwrite N values in random key order in async mode +// fillrand100K -- write N/1000 100K values in random order in async mode +// fillseq100K -- write N/1000 100K values in sequential order in async mode +// readseq -- read N times sequentially +// readrandom -- read N times in random order +// readrand100K -- read N/1000 100K values in sequential order in async mode +static const char* FLAGS_benchmarks = + "fillseq," + "fillseqsync," + "fillseqbatch," + "fillrandom," + "fillrandsync," + "fillrandbatch," + "overwrite," + "overwritebatch," + "readrandom," + "readseq," + "fillrand100K," + "fillseq100K," + "readseq," + "readrand100K," + ; + +// Number of key/values to place in database +static int FLAGS_num = 1000000; + +// Number of read operations to do. If negative, do FLAGS_num reads. +static int FLAGS_reads = -1; + +// Size of each value +static int FLAGS_value_size = 100; + +// Print histogram of operation timings +static bool FLAGS_histogram = false; + +// Arrange to generate values that shrink to this fraction of +// their original size after compression +static double FLAGS_compression_ratio = 0.5; + +// Page size. Default 1 KB. +static int FLAGS_page_size = 1024; + +// Number of pages. +// Default cache size = FLAGS_page_size * FLAGS_num_pages = 4 MB. +static int FLAGS_num_pages = 4096; + +// If true, do not destroy the existing database. If you set this +// flag and also specify a benchmark that wants a fresh database, that +// benchmark will fail. +static bool FLAGS_use_existing_db = false; + +// If true, we allow batch writes to occur +static bool FLAGS_transaction = true; + +// If true, we enable Write-Ahead Logging +static bool FLAGS_WAL_enabled = true; + +// Use the db with the following name. +static const char* FLAGS_db = NULL; + +inline +static void ExecErrorCheck(int status, char *err_msg) { + if (status != SQLITE_OK) { + fprintf(stderr, "SQL error: %s\n", err_msg); + sqlite3_free(err_msg); + exit(1); + } +} + +inline +static void StepErrorCheck(int status) { + if (status != SQLITE_DONE) { + fprintf(stderr, "SQL step error: status = %d\n", status); + exit(1); + } +} + +inline +static void ErrorCheck(int status) { + if (status != SQLITE_OK) { + fprintf(stderr, "sqlite3 error: status = %d\n", status); + exit(1); + } +} + +inline +static void WalCheckpoint(sqlite3* db_) { + // Flush all writes to disk + if (FLAGS_WAL_enabled) { + sqlite3_wal_checkpoint_v2(db_, NULL, SQLITE_CHECKPOINT_FULL, NULL, NULL); + } +} + +namespace leveldb { + +// Helper for quickly generating random data. +namespace { +class RandomGenerator { + private: + std::string data_; + int pos_; + + public: + RandomGenerator() { + // We use a limited amount of data over and over again and ensure + // that it is larger than the compression window (32KB), and also + // large enough to serve all typical value sizes we want to write. + Random rnd(301); + std::string piece; + while (data_.size() < 1048576) { + // Add a short fragment that is as compressible as specified + // by FLAGS_compression_ratio. + test::CompressibleString(&rnd, FLAGS_compression_ratio, 100, &piece); + data_.append(piece); + } + pos_ = 0; + } + + Slice Generate(int len) { + if (pos_ + len > data_.size()) { + pos_ = 0; + assert(len < data_.size()); + } + pos_ += len; + return Slice(data_.data() + pos_ - len, len); + } +}; + +static Slice TrimSpace(Slice s) { + int start = 0; + while (start < s.size() && isspace(s[start])) { + start++; + } + int limit = s.size(); + while (limit > start && isspace(s[limit-1])) { + limit--; + } + return Slice(s.data() + start, limit - start); +} + +} // namespace + +class Benchmark { + private: + sqlite3* db_; + int db_num_; + int num_; + int reads_; + double start_; + double last_op_finish_; + int64_t bytes_; + std::string message_; + Histogram hist_; + RandomGenerator gen_; + Random rand_; + + // State kept for progress messages + int done_; + int next_report_; // When to report next + + void PrintHeader() { + const int kKeySize = 16; + PrintEnvironment(); + fprintf(stdout, "Keys: %d bytes each\n", kKeySize); + fprintf(stdout, "Values: %d bytes each\n", FLAGS_value_size); + fprintf(stdout, "Entries: %d\n", num_); + fprintf(stdout, "RawSize: %.1f MB (estimated)\n", + ((static_cast(kKeySize + FLAGS_value_size) * num_) + / 1048576.0)); + PrintWarnings(); + fprintf(stdout, "------------------------------------------------\n"); + } + + void PrintWarnings() { +#if defined(__GNUC__) && !defined(__OPTIMIZE__) + fprintf(stdout, + "WARNING: Optimization is disabled: benchmarks unnecessarily slow\n" + ); +#endif +#ifndef NDEBUG + fprintf(stdout, + "WARNING: Assertions are enabled; benchmarks unnecessarily slow\n"); +#endif + } + + void PrintEnvironment() { + fprintf(stderr, "SQLite: version %s\n", SQLITE_VERSION); + +#if defined(__linux) + time_t now = time(NULL); + fprintf(stderr, "Date: %s", ctime(&now)); // ctime() adds newline + + FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); + if (cpuinfo != NULL) { + char line[1000]; + int num_cpus = 0; + std::string cpu_type; + std::string cache_size; + while (fgets(line, sizeof(line), cpuinfo) != NULL) { + const char* sep = strchr(line, ':'); + if (sep == NULL) { + continue; + } + Slice key = TrimSpace(Slice(line, sep - 1 - line)); + Slice val = TrimSpace(Slice(sep + 1)); + if (key == "model name") { + ++num_cpus; + cpu_type = val.ToString(); + } else if (key == "cache size") { + cache_size = val.ToString(); + } + } + fclose(cpuinfo); + fprintf(stderr, "CPU: %d * %s\n", num_cpus, cpu_type.c_str()); + fprintf(stderr, "CPUCache: %s\n", cache_size.c_str()); + } +#endif + } + + void Start() { + start_ = Env::Default()->NowMicros() * 1e-6; + bytes_ = 0; + message_.clear(); + last_op_finish_ = start_; + hist_.Clear(); + done_ = 0; + next_report_ = 100; + } + + void FinishedSingleOp() { + if (FLAGS_histogram) { + double now = Env::Default()->NowMicros() * 1e-6; + double micros = (now - last_op_finish_) * 1e6; + hist_.Add(micros); + if (micros > 20000) { + fprintf(stderr, "long op: %.1f micros%30s\r", micros, ""); + fflush(stderr); + } + last_op_finish_ = now; + } + + done_++; + if (done_ >= next_report_) { + if (next_report_ < 1000) next_report_ += 100; + else if (next_report_ < 5000) next_report_ += 500; + else if (next_report_ < 10000) next_report_ += 1000; + else if (next_report_ < 50000) next_report_ += 5000; + else if (next_report_ < 100000) next_report_ += 10000; + else if (next_report_ < 500000) next_report_ += 50000; + else next_report_ += 100000; + fprintf(stderr, "... finished %d ops%30s\r", done_, ""); + fflush(stderr); + } + } + + void Stop(const Slice& name) { + double finish = Env::Default()->NowMicros() * 1e-6; + + // Pretend at least one op was done in case we are running a benchmark + // that does not call FinishedSingleOp(). + if (done_ < 1) done_ = 1; + + if (bytes_ > 0) { + char rate[100]; + snprintf(rate, sizeof(rate), "%6.1f MB/s", + (bytes_ / 1048576.0) / (finish - start_)); + if (!message_.empty()) { + message_ = std::string(rate) + " " + message_; + } else { + message_ = rate; + } + } + + fprintf(stdout, "%-12s : %11.3f micros/op;%s%s\n", + name.ToString().c_str(), + (finish - start_) * 1e6 / done_, + (message_.empty() ? "" : " "), + message_.c_str()); + if (FLAGS_histogram) { + fprintf(stdout, "Microseconds per op:\n%s\n", hist_.ToString().c_str()); + } + fflush(stdout); + } + + public: + enum Order { + SEQUENTIAL, + RANDOM + }; + enum DBState { + FRESH, + EXISTING + }; + + Benchmark() + : db_(NULL), + db_num_(0), + num_(FLAGS_num), + reads_(FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads), + bytes_(0), + rand_(301) { + std::vector files; + std::string test_dir; + Env::Default()->GetTestDirectory(&test_dir); + Env::Default()->GetChildren(test_dir, &files); + if (!FLAGS_use_existing_db) { + for (int i = 0; i < files.size(); i++) { + if (Slice(files[i]).starts_with("dbbench_sqlite3")) { + std::string file_name(test_dir); + file_name += "/"; + file_name += files[i]; + Env::Default()->DeleteFile(file_name.c_str()); + } + } + } + } + + ~Benchmark() { + int status = sqlite3_close(db_); + ErrorCheck(status); + } + + void Run() { + PrintHeader(); + Open(); + + const char* benchmarks = FLAGS_benchmarks; + while (benchmarks != NULL) { + const char* sep = strchr(benchmarks, ','); + Slice name; + if (sep == NULL) { + name = benchmarks; + benchmarks = NULL; + } else { + name = Slice(benchmarks, sep - benchmarks); + benchmarks = sep + 1; + } + + bytes_ = 0; + Start(); + + bool known = true; + bool write_sync = false; + if (name == Slice("fillseq")) { + Write(write_sync, SEQUENTIAL, FRESH, num_, FLAGS_value_size, 1); + WalCheckpoint(db_); + } else if (name == Slice("fillseqbatch")) { + Write(write_sync, SEQUENTIAL, FRESH, num_, FLAGS_value_size, 1000); + WalCheckpoint(db_); + } else if (name == Slice("fillrandom")) { + Write(write_sync, RANDOM, FRESH, num_, FLAGS_value_size, 1); + WalCheckpoint(db_); + } else if (name == Slice("fillrandbatch")) { + Write(write_sync, RANDOM, FRESH, num_, FLAGS_value_size, 1000); + WalCheckpoint(db_); + } else if (name == Slice("overwrite")) { + Write(write_sync, RANDOM, EXISTING, num_, FLAGS_value_size, 1); + WalCheckpoint(db_); + } else if (name == Slice("overwritebatch")) { + Write(write_sync, RANDOM, EXISTING, num_, FLAGS_value_size, 1000); + WalCheckpoint(db_); + } else if (name == Slice("fillrandsync")) { + write_sync = true; + Write(write_sync, RANDOM, FRESH, num_ / 100, FLAGS_value_size, 1); + WalCheckpoint(db_); + } else if (name == Slice("fillseqsync")) { + write_sync = true; + Write(write_sync, SEQUENTIAL, FRESH, num_ / 100, FLAGS_value_size, 1); + WalCheckpoint(db_); + } else if (name == Slice("fillrand100K")) { + Write(write_sync, RANDOM, FRESH, num_ / 1000, 100 * 1000, 1); + WalCheckpoint(db_); + } else if (name == Slice("fillseq100K")) { + Write(write_sync, SEQUENTIAL, FRESH, num_ / 1000, 100 * 1000, 1); + WalCheckpoint(db_); + } else if (name == Slice("readseq")) { + ReadSequential(); + } else if (name == Slice("readrandom")) { + Read(RANDOM, 1); + } else if (name == Slice("readrand100K")) { + int n = reads_; + reads_ /= 1000; + Read(RANDOM, 1); + reads_ = n; + } else { + known = false; + if (name != Slice()) { // No error message for empty name + fprintf(stderr, "unknown benchmark '%s'\n", name.ToString().c_str()); + } + } + if (known) { + Stop(name); + } + } + } + + void Open() { + assert(db_ == NULL); + + int status; + char file_name[100]; + char* err_msg = NULL; + db_num_++; + + // Open database + std::string tmp_dir; + Env::Default()->GetTestDirectory(&tmp_dir); + snprintf(file_name, sizeof(file_name), + "%s/dbbench_sqlite3-%d.db", + tmp_dir.c_str(), + db_num_); + status = sqlite3_open(file_name, &db_); + if (status) { + fprintf(stderr, "open error: %s\n", sqlite3_errmsg(db_)); + exit(1); + } + + // Change SQLite cache size + char cache_size[100]; + snprintf(cache_size, sizeof(cache_size), "PRAGMA cache_size = %d", + FLAGS_num_pages); + status = sqlite3_exec(db_, cache_size, NULL, NULL, &err_msg); + ExecErrorCheck(status, err_msg); + + // FLAGS_page_size is defaulted to 1024 + if (FLAGS_page_size != 1024) { + char page_size[100]; + snprintf(page_size, sizeof(page_size), "PRAGMA page_size = %d", + FLAGS_page_size); + status = sqlite3_exec(db_, page_size, NULL, NULL, &err_msg); + ExecErrorCheck(status, err_msg); + } + + // Change journal mode to WAL if WAL enabled flag is on + if (FLAGS_WAL_enabled) { + std::string WAL_stmt = "PRAGMA journal_mode = WAL"; + + // LevelDB's default cache size is a combined 4 MB + std::string WAL_checkpoint = "PRAGMA wal_autocheckpoint = 4096"; + status = sqlite3_exec(db_, WAL_stmt.c_str(), NULL, NULL, &err_msg); + ExecErrorCheck(status, err_msg); + status = sqlite3_exec(db_, WAL_checkpoint.c_str(), NULL, NULL, &err_msg); + ExecErrorCheck(status, err_msg); + } + + // Change locking mode to exclusive and create tables/index for database + std::string locking_stmt = "PRAGMA locking_mode = EXCLUSIVE"; + std::string create_stmt = + "CREATE TABLE test (key blob, value blob, PRIMARY KEY(key))"; + std::string stmt_array[] = { locking_stmt, create_stmt }; + int stmt_array_length = sizeof(stmt_array) / sizeof(std::string); + for (int i = 0; i < stmt_array_length; i++) { + status = sqlite3_exec(db_, stmt_array[i].c_str(), NULL, NULL, &err_msg); + ExecErrorCheck(status, err_msg); + } + } + + void Write(bool write_sync, Order order, DBState state, + int num_entries, int value_size, int entries_per_batch) { + // Create new database if state == FRESH + if (state == FRESH) { + if (FLAGS_use_existing_db) { + message_ = "skipping (--use_existing_db is true)"; + return; + } + sqlite3_close(db_); + db_ = NULL; + Open(); + Start(); + } + + if (num_entries != num_) { + char msg[100]; + snprintf(msg, sizeof(msg), "(%d ops)", num_entries); + message_ = msg; + } + + char* err_msg = NULL; + int status; + + sqlite3_stmt *replace_stmt, *begin_trans_stmt, *end_trans_stmt; + std::string replace_str = "REPLACE INTO test (key, value) VALUES (?, ?)"; + std::string begin_trans_str = "BEGIN TRANSACTION;"; + std::string end_trans_str = "END TRANSACTION;"; + + // Check for synchronous flag in options + std::string sync_stmt = (write_sync) ? "PRAGMA synchronous = FULL" : + "PRAGMA synchronous = OFF"; + status = sqlite3_exec(db_, sync_stmt.c_str(), NULL, NULL, &err_msg); + ExecErrorCheck(status, err_msg); + + // Preparing sqlite3 statements + status = sqlite3_prepare_v2(db_, replace_str.c_str(), -1, + &replace_stmt, NULL); + ErrorCheck(status); + status = sqlite3_prepare_v2(db_, begin_trans_str.c_str(), -1, + &begin_trans_stmt, NULL); + ErrorCheck(status); + status = sqlite3_prepare_v2(db_, end_trans_str.c_str(), -1, + &end_trans_stmt, NULL); + ErrorCheck(status); + + bool transaction = (entries_per_batch > 1); + for (int i = 0; i < num_entries; i += entries_per_batch) { + // Begin write transaction + if (FLAGS_transaction && transaction) { + status = sqlite3_step(begin_trans_stmt); + StepErrorCheck(status); + status = sqlite3_reset(begin_trans_stmt); + ErrorCheck(status); + } + + // Create and execute SQL statements + for (int j = 0; j < entries_per_batch; j++) { + const char* value = gen_.Generate(value_size).data(); + + // Create values for key-value pair + const int k = (order == SEQUENTIAL) ? i + j : + (rand_.Next() % num_entries); + char key[100]; + snprintf(key, sizeof(key), "%016d", k); + + // Bind KV values into replace_stmt + status = sqlite3_bind_blob(replace_stmt, 1, key, 16, SQLITE_STATIC); + ErrorCheck(status); + status = sqlite3_bind_blob(replace_stmt, 2, value, + value_size, SQLITE_STATIC); + ErrorCheck(status); + + // Execute replace_stmt + bytes_ += value_size + strlen(key); + status = sqlite3_step(replace_stmt); + StepErrorCheck(status); + + // Reset SQLite statement for another use + status = sqlite3_clear_bindings(replace_stmt); + ErrorCheck(status); + status = sqlite3_reset(replace_stmt); + ErrorCheck(status); + + FinishedSingleOp(); + } + + // End write transaction + if (FLAGS_transaction && transaction) { + status = sqlite3_step(end_trans_stmt); + StepErrorCheck(status); + status = sqlite3_reset(end_trans_stmt); + ErrorCheck(status); + } + } + + status = sqlite3_finalize(replace_stmt); + ErrorCheck(status); + status = sqlite3_finalize(begin_trans_stmt); + ErrorCheck(status); + status = sqlite3_finalize(end_trans_stmt); + ErrorCheck(status); + } + + void Read(Order order, int entries_per_batch) { + int status; + sqlite3_stmt *read_stmt, *begin_trans_stmt, *end_trans_stmt; + + std::string read_str = "SELECT * FROM test WHERE key = ?"; + std::string begin_trans_str = "BEGIN TRANSACTION;"; + std::string end_trans_str = "END TRANSACTION;"; + + // Preparing sqlite3 statements + status = sqlite3_prepare_v2(db_, begin_trans_str.c_str(), -1, + &begin_trans_stmt, NULL); + ErrorCheck(status); + status = sqlite3_prepare_v2(db_, end_trans_str.c_str(), -1, + &end_trans_stmt, NULL); + ErrorCheck(status); + status = sqlite3_prepare_v2(db_, read_str.c_str(), -1, &read_stmt, NULL); + ErrorCheck(status); + + bool transaction = (entries_per_batch > 1); + for (int i = 0; i < reads_; i += entries_per_batch) { + // Begin read transaction + if (FLAGS_transaction && transaction) { + status = sqlite3_step(begin_trans_stmt); + StepErrorCheck(status); + status = sqlite3_reset(begin_trans_stmt); + ErrorCheck(status); + } + + // Create and execute SQL statements + for (int j = 0; j < entries_per_batch; j++) { + // Create key value + char key[100]; + int k = (order == SEQUENTIAL) ? i + j : (rand_.Next() % reads_); + snprintf(key, sizeof(key), "%016d", k); + + // Bind key value into read_stmt + status = sqlite3_bind_blob(read_stmt, 1, key, 16, SQLITE_STATIC); + ErrorCheck(status); + + // Execute read statement + while ((status = sqlite3_step(read_stmt)) == SQLITE_ROW) {} + StepErrorCheck(status); + + // Reset SQLite statement for another use + status = sqlite3_clear_bindings(read_stmt); + ErrorCheck(status); + status = sqlite3_reset(read_stmt); + ErrorCheck(status); + FinishedSingleOp(); + } + + // End read transaction + if (FLAGS_transaction && transaction) { + status = sqlite3_step(end_trans_stmt); + StepErrorCheck(status); + status = sqlite3_reset(end_trans_stmt); + ErrorCheck(status); + } + } + + status = sqlite3_finalize(read_stmt); + ErrorCheck(status); + status = sqlite3_finalize(begin_trans_stmt); + ErrorCheck(status); + status = sqlite3_finalize(end_trans_stmt); + ErrorCheck(status); + } + + void ReadSequential() { + int status; + sqlite3_stmt *pStmt; + std::string read_str = "SELECT * FROM test ORDER BY key"; + + status = sqlite3_prepare_v2(db_, read_str.c_str(), -1, &pStmt, NULL); + ErrorCheck(status); + for (int i = 0; i < reads_ && SQLITE_ROW == sqlite3_step(pStmt); i++) { + bytes_ += sqlite3_column_bytes(pStmt, 1) + sqlite3_column_bytes(pStmt, 2); + FinishedSingleOp(); + } + + status = sqlite3_finalize(pStmt); + ErrorCheck(status); + } + +}; + +} // namespace leveldb + +int main(int argc, char** argv) { + std::string default_db_path; + for (int i = 1; i < argc; i++) { + double d; + int n; + char junk; + if (leveldb::Slice(argv[i]).starts_with("--benchmarks=")) { + FLAGS_benchmarks = argv[i] + strlen("--benchmarks="); + } else if (sscanf(argv[i], "--histogram=%d%c", &n, &junk) == 1 && + (n == 0 || n == 1)) { + FLAGS_histogram = n; + } else if (sscanf(argv[i], "--compression_ratio=%lf%c", &d, &junk) == 1) { + FLAGS_compression_ratio = d; + } else if (sscanf(argv[i], "--use_existing_db=%d%c", &n, &junk) == 1 && + (n == 0 || n == 1)) { + FLAGS_use_existing_db = n; + } else if (sscanf(argv[i], "--num=%d%c", &n, &junk) == 1) { + FLAGS_num = n; + } else if (sscanf(argv[i], "--reads=%d%c", &n, &junk) == 1) { + FLAGS_reads = n; + } else if (sscanf(argv[i], "--value_size=%d%c", &n, &junk) == 1) { + FLAGS_value_size = n; + } else if (leveldb::Slice(argv[i]) == leveldb::Slice("--no_transaction")) { + FLAGS_transaction = false; + } else if (sscanf(argv[i], "--page_size=%d%c", &n, &junk) == 1) { + FLAGS_page_size = n; + } else if (sscanf(argv[i], "--num_pages=%d%c", &n, &junk) == 1) { + FLAGS_num_pages = n; + } else if (sscanf(argv[i], "--WAL_enabled=%d%c", &n, &junk) == 1 && + (n == 0 || n == 1)) { + FLAGS_WAL_enabled = n; + } else if (strncmp(argv[i], "--db=", 5) == 0) { + FLAGS_db = argv[i] + 5; + } else { + fprintf(stderr, "Invalid flag '%s'\n", argv[i]); + exit(1); + } + } + + // Choose a location for the test database if none given with --db= + if (FLAGS_db == NULL) { + leveldb::Env::Default()->GetTestDirectory(&default_db_path); + default_db_path += "/dbbench"; + FLAGS_db = default_db_path.c_str(); + } + + leveldb::Benchmark benchmark; + benchmark.Run(); + return 0; +} diff --git a/src/leveldb/doc/bench/db_bench_tree_db.cc b/src/leveldb/doc/bench/db_bench_tree_db.cc new file mode 100644 index 0000000..ed86f03 --- /dev/null +++ b/src/leveldb/doc/bench/db_bench_tree_db.cc @@ -0,0 +1,528 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include +#include +#include +#include "util/histogram.h" +#include "util/random.h" +#include "util/testutil.h" + +// Comma-separated list of operations to run in the specified order +// Actual benchmarks: +// +// fillseq -- write N values in sequential key order in async mode +// fillrandom -- write N values in random key order in async mode +// overwrite -- overwrite N values in random key order in async mode +// fillseqsync -- write N/100 values in sequential key order in sync mode +// fillrandsync -- write N/100 values in random key order in sync mode +// fillrand100K -- write N/1000 100K values in random order in async mode +// fillseq100K -- write N/1000 100K values in seq order in async mode +// readseq -- read N times sequentially +// readseq100K -- read N/1000 100K values in sequential order in async mode +// readrand100K -- read N/1000 100K values in sequential order in async mode +// readrandom -- read N times in random order +static const char* FLAGS_benchmarks = + "fillseq," + "fillseqsync," + "fillrandsync," + "fillrandom," + "overwrite," + "readrandom," + "readseq," + "fillrand100K," + "fillseq100K," + "readseq100K," + "readrand100K," + ; + +// Number of key/values to place in database +static int FLAGS_num = 1000000; + +// Number of read operations to do. If negative, do FLAGS_num reads. +static int FLAGS_reads = -1; + +// Size of each value +static int FLAGS_value_size = 100; + +// Arrange to generate values that shrink to this fraction of +// their original size after compression +static double FLAGS_compression_ratio = 0.5; + +// Print histogram of operation timings +static bool FLAGS_histogram = false; + +// Cache size. Default 4 MB +static int FLAGS_cache_size = 4194304; + +// Page size. Default 1 KB +static int FLAGS_page_size = 1024; + +// If true, do not destroy the existing database. If you set this +// flag and also specify a benchmark that wants a fresh database, that +// benchmark will fail. +static bool FLAGS_use_existing_db = false; + +// Compression flag. If true, compression is on. If false, compression +// is off. +static bool FLAGS_compression = true; + +// Use the db with the following name. +static const char* FLAGS_db = NULL; + +inline +static void DBSynchronize(kyotocabinet::TreeDB* db_) +{ + // Synchronize will flush writes to disk + if (!db_->synchronize()) { + fprintf(stderr, "synchronize error: %s\n", db_->error().name()); + } +} + +namespace leveldb { + +// Helper for quickly generating random data. +namespace { +class RandomGenerator { + private: + std::string data_; + int pos_; + + public: + RandomGenerator() { + // We use a limited amount of data over and over again and ensure + // that it is larger than the compression window (32KB), and also + // large enough to serve all typical value sizes we want to write. + Random rnd(301); + std::string piece; + while (data_.size() < 1048576) { + // Add a short fragment that is as compressible as specified + // by FLAGS_compression_ratio. + test::CompressibleString(&rnd, FLAGS_compression_ratio, 100, &piece); + data_.append(piece); + } + pos_ = 0; + } + + Slice Generate(int len) { + if (pos_ + len > data_.size()) { + pos_ = 0; + assert(len < data_.size()); + } + pos_ += len; + return Slice(data_.data() + pos_ - len, len); + } +}; + +static Slice TrimSpace(Slice s) { + int start = 0; + while (start < s.size() && isspace(s[start])) { + start++; + } + int limit = s.size(); + while (limit > start && isspace(s[limit-1])) { + limit--; + } + return Slice(s.data() + start, limit - start); +} + +} // namespace + +class Benchmark { + private: + kyotocabinet::TreeDB* db_; + int db_num_; + int num_; + int reads_; + double start_; + double last_op_finish_; + int64_t bytes_; + std::string message_; + Histogram hist_; + RandomGenerator gen_; + Random rand_; + kyotocabinet::LZOCompressor comp_; + + // State kept for progress messages + int done_; + int next_report_; // When to report next + + void PrintHeader() { + const int kKeySize = 16; + PrintEnvironment(); + fprintf(stdout, "Keys: %d bytes each\n", kKeySize); + fprintf(stdout, "Values: %d bytes each (%d bytes after compression)\n", + FLAGS_value_size, + static_cast(FLAGS_value_size * FLAGS_compression_ratio + 0.5)); + fprintf(stdout, "Entries: %d\n", num_); + fprintf(stdout, "RawSize: %.1f MB (estimated)\n", + ((static_cast(kKeySize + FLAGS_value_size) * num_) + / 1048576.0)); + fprintf(stdout, "FileSize: %.1f MB (estimated)\n", + (((kKeySize + FLAGS_value_size * FLAGS_compression_ratio) * num_) + / 1048576.0)); + PrintWarnings(); + fprintf(stdout, "------------------------------------------------\n"); + } + + void PrintWarnings() { +#if defined(__GNUC__) && !defined(__OPTIMIZE__) + fprintf(stdout, + "WARNING: Optimization is disabled: benchmarks unnecessarily slow\n" + ); +#endif +#ifndef NDEBUG + fprintf(stdout, + "WARNING: Assertions are enabled; benchmarks unnecessarily slow\n"); +#endif + } + + void PrintEnvironment() { + fprintf(stderr, "Kyoto Cabinet: version %s, lib ver %d, lib rev %d\n", + kyotocabinet::VERSION, kyotocabinet::LIBVER, kyotocabinet::LIBREV); + +#if defined(__linux) + time_t now = time(NULL); + fprintf(stderr, "Date: %s", ctime(&now)); // ctime() adds newline + + FILE* cpuinfo = fopen("/proc/cpuinfo", "r"); + if (cpuinfo != NULL) { + char line[1000]; + int num_cpus = 0; + std::string cpu_type; + std::string cache_size; + while (fgets(line, sizeof(line), cpuinfo) != NULL) { + const char* sep = strchr(line, ':'); + if (sep == NULL) { + continue; + } + Slice key = TrimSpace(Slice(line, sep - 1 - line)); + Slice val = TrimSpace(Slice(sep + 1)); + if (key == "model name") { + ++num_cpus; + cpu_type = val.ToString(); + } else if (key == "cache size") { + cache_size = val.ToString(); + } + } + fclose(cpuinfo); + fprintf(stderr, "CPU: %d * %s\n", num_cpus, cpu_type.c_str()); + fprintf(stderr, "CPUCache: %s\n", cache_size.c_str()); + } +#endif + } + + void Start() { + start_ = Env::Default()->NowMicros() * 1e-6; + bytes_ = 0; + message_.clear(); + last_op_finish_ = start_; + hist_.Clear(); + done_ = 0; + next_report_ = 100; + } + + void FinishedSingleOp() { + if (FLAGS_histogram) { + double now = Env::Default()->NowMicros() * 1e-6; + double micros = (now - last_op_finish_) * 1e6; + hist_.Add(micros); + if (micros > 20000) { + fprintf(stderr, "long op: %.1f micros%30s\r", micros, ""); + fflush(stderr); + } + last_op_finish_ = now; + } + + done_++; + if (done_ >= next_report_) { + if (next_report_ < 1000) next_report_ += 100; + else if (next_report_ < 5000) next_report_ += 500; + else if (next_report_ < 10000) next_report_ += 1000; + else if (next_report_ < 50000) next_report_ += 5000; + else if (next_report_ < 100000) next_report_ += 10000; + else if (next_report_ < 500000) next_report_ += 50000; + else next_report_ += 100000; + fprintf(stderr, "... finished %d ops%30s\r", done_, ""); + fflush(stderr); + } + } + + void Stop(const Slice& name) { + double finish = Env::Default()->NowMicros() * 1e-6; + + // Pretend at least one op was done in case we are running a benchmark + // that does not call FinishedSingleOp(). + if (done_ < 1) done_ = 1; + + if (bytes_ > 0) { + char rate[100]; + snprintf(rate, sizeof(rate), "%6.1f MB/s", + (bytes_ / 1048576.0) / (finish - start_)); + if (!message_.empty()) { + message_ = std::string(rate) + " " + message_; + } else { + message_ = rate; + } + } + + fprintf(stdout, "%-12s : %11.3f micros/op;%s%s\n", + name.ToString().c_str(), + (finish - start_) * 1e6 / done_, + (message_.empty() ? "" : " "), + message_.c_str()); + if (FLAGS_histogram) { + fprintf(stdout, "Microseconds per op:\n%s\n", hist_.ToString().c_str()); + } + fflush(stdout); + } + + public: + enum Order { + SEQUENTIAL, + RANDOM + }; + enum DBState { + FRESH, + EXISTING + }; + + Benchmark() + : db_(NULL), + num_(FLAGS_num), + reads_(FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads), + bytes_(0), + rand_(301) { + std::vector files; + std::string test_dir; + Env::Default()->GetTestDirectory(&test_dir); + Env::Default()->GetChildren(test_dir.c_str(), &files); + if (!FLAGS_use_existing_db) { + for (int i = 0; i < files.size(); i++) { + if (Slice(files[i]).starts_with("dbbench_polyDB")) { + std::string file_name(test_dir); + file_name += "/"; + file_name += files[i]; + Env::Default()->DeleteFile(file_name.c_str()); + } + } + } + } + + ~Benchmark() { + if (!db_->close()) { + fprintf(stderr, "close error: %s\n", db_->error().name()); + } + } + + void Run() { + PrintHeader(); + Open(false); + + const char* benchmarks = FLAGS_benchmarks; + while (benchmarks != NULL) { + const char* sep = strchr(benchmarks, ','); + Slice name; + if (sep == NULL) { + name = benchmarks; + benchmarks = NULL; + } else { + name = Slice(benchmarks, sep - benchmarks); + benchmarks = sep + 1; + } + + Start(); + + bool known = true; + bool write_sync = false; + if (name == Slice("fillseq")) { + Write(write_sync, SEQUENTIAL, FRESH, num_, FLAGS_value_size, 1); + + } else if (name == Slice("fillrandom")) { + Write(write_sync, RANDOM, FRESH, num_, FLAGS_value_size, 1); + DBSynchronize(db_); + } else if (name == Slice("overwrite")) { + Write(write_sync, RANDOM, EXISTING, num_, FLAGS_value_size, 1); + DBSynchronize(db_); + } else if (name == Slice("fillrandsync")) { + write_sync = true; + Write(write_sync, RANDOM, FRESH, num_ / 100, FLAGS_value_size, 1); + DBSynchronize(db_); + } else if (name == Slice("fillseqsync")) { + write_sync = true; + Write(write_sync, SEQUENTIAL, FRESH, num_ / 100, FLAGS_value_size, 1); + DBSynchronize(db_); + } else if (name == Slice("fillrand100K")) { + Write(write_sync, RANDOM, FRESH, num_ / 1000, 100 * 1000, 1); + DBSynchronize(db_); + } else if (name == Slice("fillseq100K")) { + Write(write_sync, SEQUENTIAL, FRESH, num_ / 1000, 100 * 1000, 1); + DBSynchronize(db_); + } else if (name == Slice("readseq")) { + ReadSequential(); + } else if (name == Slice("readrandom")) { + ReadRandom(); + } else if (name == Slice("readrand100K")) { + int n = reads_; + reads_ /= 1000; + ReadRandom(); + reads_ = n; + } else if (name == Slice("readseq100K")) { + int n = reads_; + reads_ /= 1000; + ReadSequential(); + reads_ = n; + } else { + known = false; + if (name != Slice()) { // No error message for empty name + fprintf(stderr, "unknown benchmark '%s'\n", name.ToString().c_str()); + } + } + if (known) { + Stop(name); + } + } + } + + private: + void Open(bool sync) { + assert(db_ == NULL); + + // Initialize db_ + db_ = new kyotocabinet::TreeDB(); + char file_name[100]; + db_num_++; + std::string test_dir; + Env::Default()->GetTestDirectory(&test_dir); + snprintf(file_name, sizeof(file_name), + "%s/dbbench_polyDB-%d.kct", + test_dir.c_str(), + db_num_); + + // Create tuning options and open the database + int open_options = kyotocabinet::PolyDB::OWRITER | + kyotocabinet::PolyDB::OCREATE; + int tune_options = kyotocabinet::TreeDB::TSMALL | + kyotocabinet::TreeDB::TLINEAR; + if (FLAGS_compression) { + tune_options |= kyotocabinet::TreeDB::TCOMPRESS; + db_->tune_compressor(&comp_); + } + db_->tune_options(tune_options); + db_->tune_page_cache(FLAGS_cache_size); + db_->tune_page(FLAGS_page_size); + db_->tune_map(256LL<<20); + if (sync) { + open_options |= kyotocabinet::PolyDB::OAUTOSYNC; + } + if (!db_->open(file_name, open_options)) { + fprintf(stderr, "open error: %s\n", db_->error().name()); + } + } + + void Write(bool sync, Order order, DBState state, + int num_entries, int value_size, int entries_per_batch) { + // Create new database if state == FRESH + if (state == FRESH) { + if (FLAGS_use_existing_db) { + message_ = "skipping (--use_existing_db is true)"; + return; + } + delete db_; + db_ = NULL; + Open(sync); + Start(); // Do not count time taken to destroy/open + } + + if (num_entries != num_) { + char msg[100]; + snprintf(msg, sizeof(msg), "(%d ops)", num_entries); + message_ = msg; + } + + // Write to database + for (int i = 0; i < num_entries; i++) + { + const int k = (order == SEQUENTIAL) ? i : (rand_.Next() % num_entries); + char key[100]; + snprintf(key, sizeof(key), "%016d", k); + bytes_ += value_size + strlen(key); + std::string cpp_key = key; + if (!db_->set(cpp_key, gen_.Generate(value_size).ToString())) { + fprintf(stderr, "set error: %s\n", db_->error().name()); + } + FinishedSingleOp(); + } + } + + void ReadSequential() { + kyotocabinet::DB::Cursor* cur = db_->cursor(); + cur->jump(); + std::string ckey, cvalue; + while (cur->get(&ckey, &cvalue, true)) { + bytes_ += ckey.size() + cvalue.size(); + FinishedSingleOp(); + } + delete cur; + } + + void ReadRandom() { + std::string value; + for (int i = 0; i < reads_; i++) { + char key[100]; + const int k = rand_.Next() % reads_; + snprintf(key, sizeof(key), "%016d", k); + db_->get(key, &value); + FinishedSingleOp(); + } + } +}; + +} // namespace leveldb + +int main(int argc, char** argv) { + std::string default_db_path; + for (int i = 1; i < argc; i++) { + double d; + int n; + char junk; + if (leveldb::Slice(argv[i]).starts_with("--benchmarks=")) { + FLAGS_benchmarks = argv[i] + strlen("--benchmarks="); + } else if (sscanf(argv[i], "--compression_ratio=%lf%c", &d, &junk) == 1) { + FLAGS_compression_ratio = d; + } else if (sscanf(argv[i], "--histogram=%d%c", &n, &junk) == 1 && + (n == 0 || n == 1)) { + FLAGS_histogram = n; + } else if (sscanf(argv[i], "--num=%d%c", &n, &junk) == 1) { + FLAGS_num = n; + } else if (sscanf(argv[i], "--reads=%d%c", &n, &junk) == 1) { + FLAGS_reads = n; + } else if (sscanf(argv[i], "--value_size=%d%c", &n, &junk) == 1) { + FLAGS_value_size = n; + } else if (sscanf(argv[i], "--cache_size=%d%c", &n, &junk) == 1) { + FLAGS_cache_size = n; + } else if (sscanf(argv[i], "--page_size=%d%c", &n, &junk) == 1) { + FLAGS_page_size = n; + } else if (sscanf(argv[i], "--compression=%d%c", &n, &junk) == 1 && + (n == 0 || n == 1)) { + FLAGS_compression = (n == 1) ? true : false; + } else if (strncmp(argv[i], "--db=", 5) == 0) { + FLAGS_db = argv[i] + 5; + } else { + fprintf(stderr, "Invalid flag '%s'\n", argv[i]); + exit(1); + } + } + + // Choose a location for the test database if none given with --db= + if (FLAGS_db == NULL) { + leveldb::Env::Default()->GetTestDirectory(&default_db_path); + default_db_path += "/dbbench"; + FLAGS_db = default_db_path.c_str(); + } + + leveldb::Benchmark benchmark; + benchmark.Run(); + return 0; +} diff --git a/src/leveldb/doc/benchmark.html b/src/leveldb/doc/benchmark.html new file mode 100644 index 0000000..c463977 --- /dev/null +++ b/src/leveldb/doc/benchmark.html @@ -0,0 +1,459 @@ + + + +LevelDB Benchmarks + + + + +

LevelDB Benchmarks

+

Google, July 2011

+
+ +

In order to test LevelDB's performance, we benchmark it against other well-established database implementations. We compare LevelDB (revision 39) against SQLite3 (version 3.7.6.3) and Kyoto Cabinet's (version 1.2.67) TreeDB (a B+Tree based key-value store). We would like to acknowledge Scott Hess and Mikio Hirabayashi for their suggestions and contributions to the SQLite3 and Kyoto Cabinet benchmarks, respectively.

+ +

Benchmarks were all performed on a six-core Intel(R) Xeon(R) CPU X5650 @ 2.67GHz, with 12288 KB of total L3 cache and 12 GB of DDR3 RAM at 1333 MHz. (Note that LevelDB uses at most two CPUs since the benchmarks are single threaded: one to run the benchmark, and one for background compactions.) We ran the benchmarks on two machines (with identical processors), one with an Ext3 file system and one with an Ext4 file system. The machine with the Ext3 file system has a SATA Hitachi HDS721050CLA362 hard drive. The machine with the Ext4 file system has a SATA Samsung HD502HJ hard drive. Both hard drives spin at 7200 RPM and have hard drive write-caching enabled (using `hdparm -W 1 [device]`). The numbers reported below are the median of three measurements.

+ +

Benchmark Source Code

+

We wrote benchmark tools for SQLite and Kyoto TreeDB based on LevelDB's db_bench. The code for each of the benchmarks resides here:

+ + +

Custom Build Specifications

+
    +
  • LevelDB: LevelDB was compiled with the tcmalloc library and the Snappy compression library (revision 33). Assertions were disabled.
  • +
  • TreeDB: TreeDB was compiled using the LZO compression library (version 2.03). Furthermore, we enabled the TSMALL and TLINEAR options when opening the database in order to reduce the footprint of each record.
  • +
  • SQLite: We tuned SQLite's performance, by setting its locking mode to exclusive. We also enabled SQLite's write-ahead logging.
  • +
+ +

1. Baseline Performance

+

This section gives the baseline performance of all the +databases. Following sections show how performance changes as various +parameters are varied. For the baseline:

+
    +
  • Each database is allowed 4 MB of cache memory.
  • +
  • Databases are opened in asynchronous write mode. + (LevelDB's sync option, TreeDB's OAUTOSYNC option, and + SQLite3's synchronous options are all turned off). I.e., + every write is pushed to the operating system, but the + benchmark does not wait for the write to reach the disk.
  • +
  • Keys are 16 bytes each.
  • +
  • Value are 100 bytes each (with enough redundancy so that + a simple compressor shrinks them to 50% of their original + size).
  • +
  • Sequential reads/writes traverse the key space in increasing order.
  • +
  • Random reads/writes traverse the key space in random order.
  • +
+ +

A. Sequential Reads

+ + + + + + + + + + +
LevelDB4,030,000 ops/sec
 
Kyoto TreeDB1,010,000 ops/sec
 
SQLite3383,000 ops/sec
 
+

B. Random Reads

+ + + + + + + + + + +
LevelDB129,000 ops/sec
 
Kyoto TreeDB151,000 ops/sec
 
SQLite3134,000 ops/sec
 
+

C. Sequential Writes

+ + + + + + + + + + +
LevelDB779,000 ops/sec
 
Kyoto TreeDB342,000 ops/sec
 
SQLite348,600 ops/sec
 
+

D. Random Writes

+ + + + + + + + + + +
LevelDB164,000 ops/sec
 
Kyoto TreeDB88,500 ops/sec
 
SQLite39,860 ops/sec
 
+ +

LevelDB outperforms both SQLite3 and TreeDB in sequential and random write operations and sequential read operations. Kyoto Cabinet has the fastest random read operations.

+ +

2. Write Performance under Different Configurations

+

A. Large Values

+

For this benchmark, we start with an empty database, and write 100,000 byte values (~50% compressible). To keep the benchmark running time reasonable, we stop after writing 1000 values.

+

Sequential Writes

+ + + + + + + + + + +
LevelDB1,100 ops/sec
 
Kyoto TreeDB1,000 ops/sec
 
SQLite31,600 ops/sec
 
+

Random Writes

+ + + + + + + + + + +
LevelDB480 ops/sec
 
Kyoto TreeDB1,100 ops/sec
 
SQLite31,600 ops/sec
 
+

LevelDB doesn't perform as well with large values of 100,000 bytes each. This is because LevelDB writes keys and values at least twice: first time to the transaction log, and second time (during a compaction) to a sorted file. +With larger values, LevelDB's per-operation efficiency is swamped by the +cost of extra copies of large values.

+

B. Batch Writes

+

A batch write is a set of writes that are applied atomically to the underlying database. A single batch of N writes may be significantly faster than N individual writes. The following benchmark writes one thousand batches where each batch contains one thousand 100-byte values. TreeDB does not support batch writes and is omitted from this benchmark.

+

Sequential Writes

+ + + + + + + + + +
LevelDB840,000 entries/sec
 
(1.08x baseline)
SQLite3124,000 entries/sec
 
(2.55x baseline)
+

Random Writes

+ + + + + + + + + +
LevelDB221,000 entries/sec
 
(1.35x baseline)
SQLite322,000 entries/sec
 
(2.23x baseline)
+ +

Because of the way LevelDB persistent storage is organized, batches of +random writes are not much slower (only a factor of 4x) than batches +of sequential writes.

+ +

C. Synchronous Writes

+

In the following benchmark, we enable the synchronous writing modes +of all of the databases. Since this change significantly slows down the +benchmark, we stop after 10,000 writes. For synchronous write tests, we've +disabled hard drive write-caching (using `hdparm -W 0 [device]`).

+
    +
  • For LevelDB, we set WriteOptions.sync = true.
  • +
  • In TreeDB, we enabled TreeDB's OAUTOSYNC option.
  • +
  • For SQLite3, we set "PRAGMA synchronous = FULL".
  • +
+

Sequential Writes

+ + + + + + + + + + + + + +
LevelDB100 ops/sec
 
(0.003x baseline)
Kyoto TreeDB7 ops/sec
 
(0.0004x baseline)
SQLite388 ops/sec
 
(0.002x baseline)
+

Random Writes

+ + + + + + + + + + + + + +
LevelDB100 ops/sec
 
(0.015x baseline)
Kyoto TreeDB8 ops/sec
 
(0.001x baseline)
SQLite388 ops/sec
 
(0.009x baseline)
+ +

Also see the ext4 performance numbers below +since synchronous writes behave significantly differently +on ext3 and ext4.

+ +

D. Turning Compression Off

+ +

In the baseline measurements, LevelDB and TreeDB were using +light-weight compression +(Snappy for LevelDB, +and LZO for +TreeDB). SQLite3, by default does not use compression. The +experiments below show what happens when compression is disabled in +all of the databases (the SQLite3 numbers are just a copy of +its baseline measurements):

+ +

Sequential Writes

+ + + + + + + + + + + + + +
LevelDB594,000 ops/sec
 
(0.76x baseline)
Kyoto TreeDB485,000 ops/sec
 
(1.42x baseline)
SQLite348,600 ops/sec
 
(1.00x baseline)
+

Random Writes

+ + + + + + + + + + + + + +
LevelDB135,000 ops/sec
 
(0.82x baseline)
Kyoto TreeDB159,000 ops/sec
 
(1.80x baseline)
SQLite39,860 ops/sec
 
(1.00x baseline)
+ +

LevelDB's write performance is better with compression than without +since compression decreases the amount of data that has to be written +to disk. Therefore LevelDB users can leave compression enabled in +most scenarios without having worry about a tradeoff between space +usage and performance. TreeDB's performance on the other hand is +better without compression than with compression. Presumably this is +because TreeDB's compression library (LZO) is more expensive than +LevelDB's compression library (Snappy).

+ +

E. Using More Memory

+

We increased the overall cache size for each database to 128 MB. For LevelDB, we partitioned 128 MB into a 120 MB write buffer and 8 MB of cache (up from 2 MB of write buffer and 2 MB of cache). For SQLite3, we kept the page size at 1024 bytes, but increased the number of pages to 131,072 (up from 4096). For TreeDB, we also kept the page size at 1024 bytes, but increased the cache size to 128 MB (up from 4 MB).

+

Sequential Writes

+ + + + + + + + + + + + + +
LevelDB812,000 ops/sec
 
(1.04x baseline)
Kyoto TreeDB321,000 ops/sec
 
(0.94x baseline)
SQLite348,500 ops/sec
 
(1.00x baseline)
+

Random Writes

+ + + + + + + + + + + + + +
LevelDB355,000 ops/sec
 
(2.16x baseline)
Kyoto TreeDB284,000 ops/sec
 
(3.21x baseline)
SQLite39,670 ops/sec
 
(0.98x baseline)
+ +

SQLite's performance does not change substantially when compared to +the baseline, but the random write performance for both LevelDB and +TreeDB increases significantly. LevelDB's performance improves +because a larger write buffer reduces the need to merge sorted files +(since it creates a smaller number of larger sorted files). TreeDB's +performance goes up because the entire database is available in memory +for fast in-place updates.

+ +

3. Read Performance under Different Configurations

+

A. Larger Caches

+

We increased the overall memory usage to 128 MB for each database. +For LevelDB, we allocated 8 MB to LevelDB's write buffer and 120 MB +to LevelDB's cache. The other databases don't differentiate between a +write buffer and a cache, so we simply set their cache size to 128 +MB.

+

Sequential Reads

+ + + + + + + + + + + + + +
LevelDB5,210,000 ops/sec
 
(1.29x baseline)
Kyoto TreeDB1,070,000 ops/sec
 
(1.06x baseline)
SQLite3609,000 ops/sec
 
(1.59x baseline)
+ +

Random Reads

+ + + + + + + + + + + + + +
LevelDB190,000 ops/sec
 
(1.47x baseline)
Kyoto TreeDB463,000 ops/sec
 
(3.07x baseline)
SQLite3186,000 ops/sec
 
(1.39x baseline)
+ +

As expected, the read performance of all of the databases increases +when the caches are enlarged. In particular, TreeDB seems to make +very effective use of a cache that is large enough to hold the entire +database.

+ +

B. No Compression Reads

+

For this benchmark, we populated a database with 1 million entries consisting of 16 byte keys and 100 byte values. We compiled LevelDB and Kyoto Cabinet without compression support, so results that are read out from the database are already uncompressed. We've listed the SQLite3 baseline read performance as a point of comparison.

+

Sequential Reads

+ + + + + + + + + + + + + +
LevelDB4,880,000 ops/sec
 
(1.21x baseline)
Kyoto TreeDB1,230,000 ops/sec
 
(3.60x baseline)
SQLite3383,000 ops/sec
 
(1.00x baseline)
+

Random Reads

+ + + + + + + + + + + + + +
LevelDB149,000 ops/sec
 
(1.16x baseline)
Kyoto TreeDB175,000 ops/sec
 
(1.16x baseline)
SQLite3134,000 ops/sec
 
(1.00x baseline)
+ +

Performance of both LevelDB and TreeDB improves a small amount when +compression is disabled. Note however that under different workloads, +performance may very well be better with compression if it allows more +of the working set to fit in memory.

+ +

Note about Ext4 Filesystems

+

The preceding numbers are for an ext3 file system. Synchronous writes are much slower under ext4 (LevelDB drops to ~31 writes / second and TreeDB drops to ~5 writes / second; SQLite3's synchronous writes do not noticeably drop) due to ext4's different handling of fsync / msync calls. Even LevelDB's asynchronous write performance drops somewhat since it spreads its storage across multiple files and issues fsync calls when switching to a new file.

+ +

Acknowledgements

+

Jeff Dean and Sanjay Ghemawat wrote LevelDB. Kevin Tseng wrote and compiled these benchmarks. Mikio Hirabayashi, Scott Hess, and Gabor Cselle provided help and advice.

+ + diff --git a/src/leveldb/doc/doc.css b/src/leveldb/doc/doc.css new file mode 100644 index 0000000..700c564 --- /dev/null +++ b/src/leveldb/doc/doc.css @@ -0,0 +1,89 @@ +body { + margin-left: 0.5in; + margin-right: 0.5in; + background: white; + color: black; +} + +h1 { + margin-left: -0.2in; + font-size: 14pt; +} +h2 { + margin-left: -0in; + font-size: 12pt; +} +h3 { + margin-left: -0in; +} +h4 { + margin-left: -0in; +} +hr { + margin-left: -0in; +} + +/* Definition lists: definition term bold */ +dt { + font-weight: bold; +} + +address { + text-align: center; +} +code,samp,var { + color: blue; +} +kbd { + color: #600000; +} +div.note p { + float: right; + width: 3in; + margin-right: 0%; + padding: 1px; + border: 2px solid #6060a0; + background-color: #fffff0; +} + +ul { + margin-top: -0em; + margin-bottom: -0em; +} + +ol { + margin-top: -0em; + margin-bottom: -0em; +} + +UL.nobullets { + list-style-type: none; + list-style-image: none; + margin-left: -1em; +} + +p { + margin: 1em 0 1em 0; + padding: 0 0 0 0; +} + +pre { + line-height: 1.3em; + padding: 0.4em 0 0.8em 0; + margin: 0 0 0 0; + border: 0 0 0 0; + color: blue; +} + +.datatable { + margin-left: auto; + margin-right: auto; + margin-top: 2em; + margin-bottom: 2em; + border: 1px solid; +} + +.datatable td,th { + padding: 0 0.5em 0 0.5em; + text-align: right; +} diff --git a/src/leveldb/doc/impl.html b/src/leveldb/doc/impl.html new file mode 100644 index 0000000..28817fe --- /dev/null +++ b/src/leveldb/doc/impl.html @@ -0,0 +1,213 @@ + + + + +Leveldb file layout and compactions + + + + +

Files

+ +The implementation of leveldb is similar in spirit to the +representation of a single + +Bigtable tablet (section 5.3). +However the organization of the files that make up the representation +is somewhat different and is explained below. + +

+Each database is represented by a set of files stored in a directory. +There are several different types of files as documented below: +

+

Log files

+

+A log file (*.log) stores a sequence of recent updates. Each update +is appended to the current log file. When the log file reaches a +pre-determined size (approximately 4MB by default), it is converted +to a sorted table (see below) and a new log file is created for future +updates. +

+A copy of the current log file is kept in an in-memory structure (the +memtable). This copy is consulted on every read so that read +operations reflect all logged updates. +

+

Sorted tables

+

+A sorted table (*.sst) stores a sequence of entries sorted by key. +Each entry is either a value for the key, or a deletion marker for the +key. (Deletion markers are kept around to hide obsolete values +present in older sorted tables). +

+The set of sorted tables are organized into a sequence of levels. The +sorted table generated from a log file is placed in a special young +level (also called level-0). When the number of young files exceeds a +certain threshold (currently four), all of the young files are merged +together with all of the overlapping level-1 files to produce a +sequence of new level-1 files (we create a new level-1 file for every +2MB of data.) +

+Files in the young level may contain overlapping keys. However files +in other levels have distinct non-overlapping key ranges. Consider +level number L where L >= 1. When the combined size of files in +level-L exceeds (10^L) MB (i.e., 10MB for level-1, 100MB for level-2, +...), one file in level-L, and all of the overlapping files in +level-(L+1) are merged to form a set of new files for level-(L+1). +These merges have the effect of gradually migrating new updates from +the young level to the largest level using only bulk reads and writes +(i.e., minimizing expensive seeks). + +

Manifest

+

+A MANIFEST file lists the set of sorted tables that make up each +level, the corresponding key ranges, and other important metadata. +A new MANIFEST file (with a new number embedded in the file name) +is created whenever the database is reopened. The MANIFEST file is +formatted as a log, and changes made to the serving state (as files +are added or removed) are appended to this log. +

+

Current

+

+CURRENT is a simple text file that contains the name of the latest +MANIFEST file. +

+

Info logs

+

+Informational messages are printed to files named LOG and LOG.old. +

+

Others

+

+Other files used for miscellaneous purposes may also be present +(LOCK, *.dbtmp). + +

Level 0

+When the log file grows above a certain size (1MB by default): +
    +
  • Create a brand new memtable and log file and direct future updates here +
  • In the background: +
      +
    • Write the contents of the previous memtable to an sstable +
    • Discard the memtable +
    • Delete the old log file and the old memtable +
    • Add the new sstable to the young (level-0) level. +
    +
+ +

Compactions

+ +

+When the size of level L exceeds its limit, we compact it in a +background thread. The compaction picks a file from level L and all +overlapping files from the next level L+1. Note that if a level-L +file overlaps only part of a level-(L+1) file, the entire file at +level-(L+1) is used as an input to the compaction and will be +discarded after the compaction. Aside: because level-0 is special +(files in it may overlap each other), we treat compactions from +level-0 to level-1 specially: a level-0 compaction may pick more than +one level-0 file in case some of these files overlap each other. + +

+A compaction merges the contents of the picked files to produce a +sequence of level-(L+1) files. We switch to producing a new +level-(L+1) file after the current output file has reached the target +file size (2MB). We also switch to a new output file when the key +range of the current output file has grown enough to overlap more then +ten level-(L+2) files. This last rule ensures that a later compaction +of a level-(L+1) file will not pick up too much data from level-(L+2). + +

+The old files are discarded and the new files are added to the serving +state. + +

+Compactions for a particular level rotate through the key space. In +more detail, for each level L, we remember the ending key of the last +compaction at level L. The next compaction for level L will pick the +first file that starts after this key (wrapping around to the +beginning of the key space if there is no such file). + +

+Compactions drop overwritten values. They also drop deletion markers +if there are no higher numbered levels that contain a file whose range +overlaps the current key. + +

Timing

+ +Level-0 compactions will read up to four 1MB files from level-0, and +at worst all the level-1 files (10MB). I.e., we will read 14MB and +write 14MB. + +

+Other than the special level-0 compactions, we will pick one 2MB file +from level L. In the worst case, this will overlap ~ 12 files from +level L+1 (10 because level-(L+1) is ten times the size of level-L, +and another two at the boundaries since the file ranges at level-L +will usually not be aligned with the file ranges at level-L+1). The +compaction will therefore read 26MB and write 26MB. Assuming a disk +IO rate of 100MB/s (ballpark range for modern drives), the worst +compaction cost will be approximately 0.5 second. + +

+If we throttle the background writing to something small, say 10% of +the full 100MB/s speed, a compaction may take up to 5 seconds. If the +user is writing at 10MB/s, we might build up lots of level-0 files +(~50 to hold the 5*10MB). This may signficantly increase the cost of +reads due to the overhead of merging more files together on every +read. + +

+Solution 1: To reduce this problem, we might want to increase the log +switching threshold when the number of level-0 files is large. Though +the downside is that the larger this threshold, the more memory we will +need to hold the corresponding memtable. + +

+Solution 2: We might want to decrease write rate artificially when the +number of level-0 files goes up. + +

+Solution 3: We work on reducing the cost of very wide merges. +Perhaps most of the level-0 files will have their blocks sitting +uncompressed in the cache and we will only need to worry about the +O(N) complexity in the merging iterator. + +

Number of files

+ +Instead of always making 2MB files, we could make larger files for +larger levels to reduce the total file count, though at the expense of +more bursty compactions. Alternatively, we could shard the set of +files into multiple directories. + +

+An experiment on an ext3 filesystem on Feb 04, 2011 shows +the following timings to do 100K file opens in directories with +varying number of files: + + + + + +
Files in directoryMicroseconds to open a file
10009
1000010
10000016
+So maybe even the sharding is not necessary on modern filesystems? + +

Recovery

+ +
    +
  • Read CURRENT to find name of the latest committed MANIFEST +
  • Read the named MANIFEST file +
  • Clean up stale files +
  • We could open all sstables here, but it is probably better to be lazy... +
  • Convert log chunk to a new level-0 sstable +
  • Start directing new writes to a new log file with recovered sequence# +
+ +

Garbage collection of files

+ +DeleteObsoleteFiles() is called at the end of every +compaction and at the end of recovery. It finds the names of all +files in the database. It deletes all log files that are not the +current log file. It deletes all table files that are not referenced +from some level and are not the output of an active compaction. + + + diff --git a/src/leveldb/doc/index.html b/src/leveldb/doc/index.html new file mode 100644 index 0000000..3ed0ed9 --- /dev/null +++ b/src/leveldb/doc/index.html @@ -0,0 +1,549 @@ + + + + +Leveldb + + + +

Leveldb

+
Jeff Dean, Sanjay Ghemawat
+

+The leveldb library provides a persistent key value store. Keys and +values are arbitrary byte arrays. The keys are ordered within the key +value store according to a user-specified comparator function. + +

+

Opening A Database

+

+A leveldb database has a name which corresponds to a file system +directory. All of the contents of database are stored in this +directory. The following example shows how to open a database, +creating it if necessary: +

+

+  #include <assert>
+  #include "leveldb/db.h"
+
+  leveldb::DB* db;
+  leveldb::Options options;
+  options.create_if_missing = true;
+  leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);
+  assert(status.ok());
+  ...
+
+If you want to raise an error if the database already exists, add +the following line before the leveldb::DB::Open call: +
+  options.error_if_exists = true;
+
+

Status

+

+You may have noticed the leveldb::Status type above. Values of this +type are returned by most functions in leveldb that may encounter an +error. You can check if such a result is ok, and also print an +associated error message: +

+

+   leveldb::Status s = ...;
+   if (!s.ok()) cerr << s.ToString() << endl;
+
+

Closing A Database

+

+When you are done with a database, just delete the database object. +Example: +

+

+  ... open the db as described above ...
+  ... do something with db ...
+  delete db;
+
+

Reads And Writes

+

+The database provides Put, Delete, and Get methods to +modify/query the database. For example, the following code +moves the value stored under key1 to key2. +

+  std::string value;
+  leveldb::Status s = db->Get(leveldb::ReadOptions(), key1, &value);
+  if (s.ok()) s = db->Put(leveldb::WriteOptions(), key2, value);
+  if (s.ok()) s = db->Delete(leveldb::WriteOptions(), key1);
+
+ +

Atomic Updates

+

+Note that if the process dies after the Put of key2 but before the +delete of key1, the same value may be left stored under multiple keys. +Such problems can be avoided by using the WriteBatch class to +atomically apply a set of updates: +

+

+  #include "leveldb/write_batch.h"
+  ...
+  std::string value;
+  leveldb::Status s = db->Get(leveldb::ReadOptions(), key1, &value);
+  if (s.ok()) {
+    leveldb::WriteBatch batch;
+    batch.Delete(key1);
+    batch.Put(key2, value);
+    s = db->Write(leveldb::WriteOptions(), &batch);
+  }
+
+The WriteBatch holds a sequence of edits to be made to the database, +and these edits within the batch are applied in order. Note that we +called Delete before Put so that if key1 is identical to key2, +we do not end up erroneously dropping the value entirely. +

+Apart from its atomicity benefits, WriteBatch may also be used to +speed up bulk updates by placing lots of individual mutations into the +same batch. + +

Synchronous Writes

+By default, each write to leveldb is asynchronous: it +returns after pushing the write from the process into the operating +system. The transfer from operating system memory to the underlying +persistent storage happens asynchronously. The sync flag +can be turned on for a particular write to make the write operation +not return until the data being written has been pushed all the way to +persistent storage. (On Posix systems, this is implemented by calling +either fsync(...) or fdatasync(...) or +msync(..., MS_SYNC) before the write operation returns.) +
+  leveldb::WriteOptions write_options;
+  write_options.sync = true;
+  db->Put(write_options, ...);
+
+Asynchronous writes are often more than a thousand times as fast as +synchronous writes. The downside of asynchronous writes is that a +crash of the machine may cause the last few updates to be lost. Note +that a crash of just the writing process (i.e., not a reboot) will not +cause any loss since even when sync is false, an update +is pushed from the process memory into the operating system before it +is considered done. + +

+Asynchronous writes can often be used safely. For example, when +loading a large amount of data into the database you can handle lost +updates by restarting the bulk load after a crash. A hybrid scheme is +also possible where every Nth write is synchronous, and in the event +of a crash, the bulk load is restarted just after the last synchronous +write finished by the previous run. (The synchronous write can update +a marker that describes where to restart on a crash.) + +

+WriteBatch provides an alternative to asynchronous writes. +Multiple updates may be placed in the same WriteBatch and +applied together using a synchronous write (i.e., +write_options.sync is set to true). The extra cost of +the synchronous write will be amortized across all of the writes in +the batch. + +

+

Concurrency

+

+A database may only be opened by one process at a time. +The leveldb implementation acquires a lock from the +operating system to prevent misuse. Within a single process, the +same leveldb::DB object may be safely shared by multiple +concurrent threads. I.e., different threads may write into or fetch +iterators or call Get on the same database without any +external synchronization (the leveldb implementation will +automatically do the required synchronization). However other objects +(like Iterator and WriteBatch) may require external synchronization. +If two threads share such an object, they must protect access to it +using their own locking protocol. More details are available in +the public header files. +

+

Iteration

+

+The following example demonstrates how to print all key,value pairs +in a database. +

+

+  leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions());
+  for (it->SeekToFirst(); it->Valid(); it->Next()) {
+    cout << it->key().ToString() << ": "  << it->value().ToString() << endl;
+  }
+  assert(it->status().ok());  // Check for any errors found during the scan
+  delete it;
+
+The following variation shows how to process just the keys in the +range [start,limit): +

+

+  for (it->Seek(start);
+       it->Valid() && it->key().ToString() < limit;
+       it->Next()) {
+    ...
+  }
+
+You can also process entries in reverse order. (Caveat: reverse +iteration may be somewhat slower than forward iteration.) +

+

+  for (it->SeekToLast(); it->Valid(); it->Prev()) {
+    ...
+  }
+
+

Snapshots

+

+Snapshots provide consistent read-only views over the entire state of +the key-value store. ReadOptions::snapshot may be non-NULL to indicate +that a read should operate on a particular version of the DB state. +If ReadOptions::snapshot is NULL, the read will operate on an +implicit snapshot of the current state. +

+Snapshots are created by the DB::GetSnapshot() method: +

+

+  leveldb::ReadOptions options;
+  options.snapshot = db->GetSnapshot();
+  ... apply some updates to db ...
+  leveldb::Iterator* iter = db->NewIterator(options);
+  ... read using iter to view the state when the snapshot was created ...
+  delete iter;
+  db->ReleaseSnapshot(options.snapshot);
+
+Note that when a snapshot is no longer needed, it should be released +using the DB::ReleaseSnapshot interface. This allows the +implementation to get rid of state that was being maintained just to +support reading as of that snapshot. +

Slice

+

+The return value of the it->key() and it->value() calls above +are instances of the leveldb::Slice type. Slice is a simple +structure that contains a length and a pointer to an external byte +array. Returning a Slice is a cheaper alternative to returning a +std::string since we do not need to copy potentially large keys and +values. In addition, leveldb methods do not return null-terminated +C-style strings since leveldb keys and values are allowed to +contain '\0' bytes. +

+C++ strings and null-terminated C-style strings can be easily converted +to a Slice: +

+

+   leveldb::Slice s1 = "hello";
+
+   std::string str("world");
+   leveldb::Slice s2 = str;
+
+A Slice can be easily converted back to a C++ string: +
+   std::string str = s1.ToString();
+   assert(str == std::string("hello"));
+
+Be careful when using Slices since it is up to the caller to ensure that +the external byte array into which the Slice points remains live while +the Slice is in use. For example, the following is buggy: +

+

+   leveldb::Slice slice;
+   if (...) {
+     std::string str = ...;
+     slice = str;
+   }
+   Use(slice);
+
+When the if statement goes out of scope, str will be destroyed and the +backing storage for slice will disappear. +

+

Comparators

+

+The preceding examples used the default ordering function for key, +which orders bytes lexicographically. You can however supply a custom +comparator when opening a database. For example, suppose each +database key consists of two numbers and we should sort by the first +number, breaking ties by the second number. First, define a proper +subclass of leveldb::Comparator that expresses these rules: +

+

+  class TwoPartComparator : public leveldb::Comparator {
+   public:
+    // Three-way comparison function:
+    //   if a < b: negative result
+    //   if a > b: positive result
+    //   else: zero result
+    int Compare(const leveldb::Slice& a, const leveldb::Slice& b) const {
+      int a1, a2, b1, b2;
+      ParseKey(a, &a1, &a2);
+      ParseKey(b, &b1, &b2);
+      if (a1 < b1) return -1;
+      if (a1 > b1) return +1;
+      if (a2 < b2) return -1;
+      if (a2 > b2) return +1;
+      return 0;
+    }
+
+    // Ignore the following methods for now:
+    const char* Name() const { return "TwoPartComparator"; }
+    void FindShortestSeparator(std::string*, const leveldb::Slice&) const { }
+    void FindShortSuccessor(std::string*) const { }
+  };
+
+Now create a database using this custom comparator: +

+

+  TwoPartComparator cmp;
+  leveldb::DB* db;
+  leveldb::Options options;
+  options.create_if_missing = true;
+  options.comparator = &cmp;
+  leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);
+  ...
+
+

Backwards compatibility

+

+The result of the comparator's Name method is attached to the +database when it is created, and is checked on every subsequent +database open. If the name changes, the leveldb::DB::Open call will +fail. Therefore, change the name if and only if the new key format +and comparison function are incompatible with existing databases, and +it is ok to discard the contents of all existing databases. +

+You can however still gradually evolve your key format over time with +a little bit of pre-planning. For example, you could store a version +number at the end of each key (one byte should suffice for most uses). +When you wish to switch to a new key format (e.g., adding an optional +third part to the keys processed by TwoPartComparator), +(a) keep the same comparator name (b) increment the version number +for new keys (c) change the comparator function so it uses the +version numbers found in the keys to decide how to interpret them. +

+

Performance

+

+Performance can be tuned by changing the default values of the +types defined in include/leveldb/options.h. + +

+

Block size

+

+leveldb groups adjacent keys together into the same block and such a +block is the unit of transfer to and from persistent storage. The +default block size is approximately 4096 uncompressed bytes. +Applications that mostly do bulk scans over the contents of the +database may wish to increase this size. Applications that do a lot +of point reads of small values may wish to switch to a smaller block +size if performance measurements indicate an improvement. There isn't +much benefit in using blocks smaller than one kilobyte, or larger than +a few megabytes. Also note that compression will be more effective +with larger block sizes. +

+

Compression

+

+Each block is individually compressed before being written to +persistent storage. Compression is on by default since the default +compression method is very fast, and is automatically disabled for +uncompressible data. In rare cases, applications may want to disable +compression entirely, but should only do so if benchmarks show a +performance improvement: +

+

+  leveldb::Options options;
+  options.compression = leveldb::kNoCompression;
+  ... leveldb::DB::Open(options, name, ...) ....
+
+

Cache

+

+The contents of the database are stored in a set of files in the +filesystem and each file stores a sequence of compressed blocks. If +options.cache is non-NULL, it is used to cache frequently used +uncompressed block contents. +

+

+  #include "leveldb/cache.h"
+
+  leveldb::Options options;
+  options.cache = leveldb::NewLRUCache(100 * 1048576);  // 100MB cache
+  leveldb::DB* db;
+  leveldb::DB::Open(options, name, &db);
+  ... use the db ...
+  delete db
+  delete options.cache;
+
+Note that the cache holds uncompressed data, and therefore it should +be sized according to application level data sizes, without any +reduction from compression. (Caching of compressed blocks is left to +the operating system buffer cache, or any custom Env +implementation provided by the client.) +

+When performing a bulk read, the application may wish to disable +caching so that the data processed by the bulk read does not end up +displacing most of the cached contents. A per-iterator option can be +used to achieve this: +

+

+  leveldb::ReadOptions options;
+  options.fill_cache = false;
+  leveldb::Iterator* it = db->NewIterator(options);
+  for (it->SeekToFirst(); it->Valid(); it->Next()) {
+    ...
+  }
+
+

Key Layout

+

+Note that the unit of disk transfer and caching is a block. Adjacent +keys (according to the database sort order) will usually be placed in +the same block. Therefore the application can improve its performance +by placing keys that are accessed together near each other and placing +infrequently used keys in a separate region of the key space. +

+For example, suppose we are implementing a simple file system on top +of leveldb. The types of entries we might wish to store are: +

+

+   filename -> permission-bits, length, list of file_block_ids
+   file_block_id -> data
+
+We might want to prefix filename keys with one letter (say '/') and the +file_block_id keys with a different letter (say '0') so that scans +over just the metadata do not force us to fetch and cache bulky file +contents. +

+

Filters

+

+Because of the way leveldb data is organized on disk, +a single Get() call may involve multiple reads from disk. +The optional FilterPolicy mechanism can be used to reduce +the number of disk reads substantially. +

+   leveldb::Options options;
+   options.filter_policy = NewBloomFilterPolicy(10);
+   leveldb::DB* db;
+   leveldb::DB::Open(options, "/tmp/testdb", &db);
+   ... use the database ...
+   delete db;
+   delete options.filter_policy;
+
+The preceding code associates a +Bloom filter +based filtering policy with the database. Bloom filter based +filtering relies on keeping some number of bits of data in memory per +key (in this case 10 bits per key since that is the argument we passed +to NewBloomFilterPolicy). This filter will reduce the number of unnecessary +disk reads needed for Get() calls by a factor of +approximately a 100. Increasing the bits per key will lead to a +larger reduction at the cost of more memory usage. We recommend that +applications whose working set does not fit in memory and that do a +lot of random reads set a filter policy. +

+If you are using a custom comparator, you should ensure that the filter +policy you are using is compatible with your comparator. For example, +consider a comparator that ignores trailing spaces when comparing keys. +NewBloomFilterPolicy must not be used with such a comparator. +Instead, the application should provide a custom filter policy that +also ignores trailing spaces. For example: +

+  class CustomFilterPolicy : public leveldb::FilterPolicy {
+   private:
+    FilterPolicy* builtin_policy_;
+   public:
+    CustomFilterPolicy() : builtin_policy_(NewBloomFilterPolicy(10)) { }
+    ~CustomFilterPolicy() { delete builtin_policy_; }
+
+    const char* Name() const { return "IgnoreTrailingSpacesFilter"; }
+
+    void CreateFilter(const Slice* keys, int n, std::string* dst) const {
+      // Use builtin bloom filter code after removing trailing spaces
+      std::vector<Slice> trimmed(n);
+      for (int i = 0; i < n; i++) {
+        trimmed[i] = RemoveTrailingSpaces(keys[i]);
+      }
+      return builtin_policy_->CreateFilter(&trimmed[i], n, dst);
+    }
+
+    bool KeyMayMatch(const Slice& key, const Slice& filter) const {
+      // Use builtin bloom filter code after removing trailing spaces
+      return builtin_policy_->KeyMayMatch(RemoveTrailingSpaces(key), filter);
+    }
+  };
+
+

+Advanced applications may provide a filter policy that does not use +a bloom filter but uses some other mechanism for summarizing a set +of keys. See leveldb/filter_policy.h for detail. +

+

Checksums

+

+leveldb associates checksums with all data it stores in the file system. +There are two separate controls provided over how aggressively these +checksums are verified: +

+

    +
  • ReadOptions::verify_checksums may be set to true to force + checksum verification of all data that is read from the file system on + behalf of a particular read. By default, no such verification is + done. +

    +

  • Options::paranoid_checks may be set to true before opening a + database to make the database implementation raise an error as soon as + it detects an internal corruption. Depending on which portion of the + database has been corrupted, the error may be raised when the database + is opened, or later by another database operation. By default, + paranoid checking is off so that the database can be used even if + parts of its persistent storage have been corrupted. +

    + If a database is corrupted (perhaps it cannot be opened when + paranoid checking is turned on), the leveldb::RepairDB function + may be used to recover as much of the data as possible +

    +

+

Approximate Sizes

+

+The GetApproximateSizes method can used to get the approximate +number of bytes of file system space used by one or more key ranges. +

+

+   leveldb::Range ranges[2];
+   ranges[0] = leveldb::Range("a", "c");
+   ranges[1] = leveldb::Range("x", "z");
+   uint64_t sizes[2];
+   leveldb::Status s = db->GetApproximateSizes(ranges, 2, sizes);
+
+The preceding call will set sizes[0] to the approximate number of +bytes of file system space used by the key range [a..c) and +sizes[1] to the approximate number of bytes used by the key range +[x..z). +

+

Environment

+

+All file operations (and other operating system calls) issued by the +leveldb implementation are routed through a leveldb::Env object. +Sophisticated clients may wish to provide their own Env +implementation to get better control. For example, an application may +introduce artificial delays in the file IO paths to limit the impact +of leveldb on other activities in the system. +

+

+  class SlowEnv : public leveldb::Env {
+    .. implementation of the Env interface ...
+  };
+
+  SlowEnv env;
+  leveldb::Options options;
+  options.env = &env;
+  Status s = leveldb::DB::Open(options, ...);
+
+

Porting

+

+leveldb may be ported to a new platform by providing platform +specific implementations of the types/methods/functions exported by +leveldb/port/port.h. See leveldb/port/port_example.h for more +details. +

+In addition, the new platform may need a new default leveldb::Env +implementation. See leveldb/util/env_posix.h for an example. + +

Other Information

+ +

+Details about the leveldb implementation may be found in +the following documents: +

+ + + diff --git a/src/leveldb/doc/log_format.txt b/src/leveldb/doc/log_format.txt new file mode 100644 index 0000000..5228f62 --- /dev/null +++ b/src/leveldb/doc/log_format.txt @@ -0,0 +1,75 @@ +The log file contents are a sequence of 32KB blocks. The only +exception is that the tail of the file may contain a partial block. + +Each block consists of a sequence of records: + block := record* trailer? + record := + checksum: uint32 // crc32c of type and data[] ; little-endian + length: uint16 // little-endian + type: uint8 // One of FULL, FIRST, MIDDLE, LAST + data: uint8[length] + +A record never starts within the last six bytes of a block (since it +won't fit). Any leftover bytes here form the trailer, which must +consist entirely of zero bytes and must be skipped by readers. + +Aside: if exactly seven bytes are left in the current block, and a new +non-zero length record is added, the writer must emit a FIRST record +(which contains zero bytes of user data) to fill up the trailing seven +bytes of the block and then emit all of the user data in subsequent +blocks. + +More types may be added in the future. Some Readers may skip record +types they do not understand, others may report that some data was +skipped. + +FULL == 1 +FIRST == 2 +MIDDLE == 3 +LAST == 4 + +The FULL record contains the contents of an entire user record. + +FIRST, MIDDLE, LAST are types used for user records that have been +split into multiple fragments (typically because of block boundaries). +FIRST is the type of the first fragment of a user record, LAST is the +type of the last fragment of a user record, and MID is the type of all +interior fragments of a user record. + +Example: consider a sequence of user records: + A: length 1000 + B: length 97270 + C: length 8000 +A will be stored as a FULL record in the first block. + +B will be split into three fragments: first fragment occupies the rest +of the first block, second fragment occupies the entirety of the +second block, and the third fragment occupies a prefix of the third +block. This will leave six bytes free in the third block, which will +be left empty as the trailer. + +C will be stored as a FULL record in the fourth block. + +=================== + +Some benefits over the recordio format: + +(1) We do not need any heuristics for resyncing - just go to next +block boundary and scan. If there is a corruption, skip to the next +block. As a side-benefit, we do not get confused when part of the +contents of one log file are embedded as a record inside another log +file. + +(2) Splitting at approximate boundaries (e.g., for mapreduce) is +simple: find the next block boundary and skip records until we +hit a FULL or FIRST record. + +(3) We do not need extra buffering for large records. + +Some downsides compared to recordio format: + +(1) No packing of tiny records. This could be fixed by adding a new +record type, so it is a shortcoming of the current implementation, +not necessarily the format. + +(2) No compression. Again, this could be fixed by adding new record types. diff --git a/src/leveldb/doc/table_format.txt b/src/leveldb/doc/table_format.txt new file mode 100644 index 0000000..ca8f9b4 --- /dev/null +++ b/src/leveldb/doc/table_format.txt @@ -0,0 +1,104 @@ +File format +=========== + + + [data block 1] + [data block 2] + ... + [data block N] + [meta block 1] + ... + [meta block K] + [metaindex block] + [index block] + [Footer] (fixed size; starts at file_size - sizeof(Footer)) + + +The file contains internal pointers. Each such pointer is called +a BlockHandle and contains the following information: + offset: varint64 + size: varint64 +See https://developers.google.com/protocol-buffers/docs/encoding#varints +for an explanation of varint64 format. + +(1) The sequence of key/value pairs in the file are stored in sorted +order and partitioned into a sequence of data blocks. These blocks +come one after another at the beginning of the file. Each data block +is formatted according to the code in block_builder.cc, and then +optionally compressed. + +(2) After the data blocks we store a bunch of meta blocks. The +supported meta block types are described below. More meta block types +may be added in the future. Each meta block is again formatted using +block_builder.cc and then optionally compressed. + +(3) A "metaindex" block. It contains one entry for every other meta +block where the key is the name of the meta block and the value is a +BlockHandle pointing to that meta block. + +(4) An "index" block. This block contains one entry per data block, +where the key is a string >= last key in that data block and before +the first key in the successive data block. The value is the +BlockHandle for the data block. + +(6) At the very end of the file is a fixed length footer that contains +the BlockHandle of the metaindex and index blocks as well as a magic number. + metaindex_handle: char[p]; // Block handle for metaindex + index_handle: char[q]; // Block handle for index + padding: char[40-p-q]; // zeroed bytes to make fixed length + // (40==2*BlockHandle::kMaxEncodedLength) + magic: fixed64; // == 0xdb4775248b80fb57 (little-endian) + +"filter" Meta Block +------------------- + +If a "FilterPolicy" was specified when the database was opened, a +filter block is stored in each table. The "metaindex" block contains +an entry that maps from "filter." to the BlockHandle for the filter +block where "" is the string returned by the filter policy's +"Name()" method. + +The filter block stores a sequence of filters, where filter i contains +the output of FilterPolicy::CreateFilter() on all keys that are stored +in a block whose file offset falls within the range + + [ i*base ... (i+1)*base-1 ] + +Currently, "base" is 2KB. So for example, if blocks X and Y start in +the range [ 0KB .. 2KB-1 ], all of the keys in X and Y will be +converted to a filter by calling FilterPolicy::CreateFilter(), and the +resulting filter will be stored as the first filter in the filter +block. + +The filter block is formatted as follows: + + [filter 0] + [filter 1] + [filter 2] + ... + [filter N-1] + + [offset of filter 0] : 4 bytes + [offset of filter 1] : 4 bytes + [offset of filter 2] : 4 bytes + ... + [offset of filter N-1] : 4 bytes + + [offset of beginning of offset array] : 4 bytes + lg(base) : 1 byte + +The offset array at the end of the filter block allows efficient +mapping from a data block offset to the corresponding filter. + +"stats" Meta Block +------------------ + +This meta block contains a bunch of stats. The key is the name +of the statistic. The value contains the statistic. +TODO(postrelease): record following stats. + data size + index size + key size (uncompressed) + value size (uncompressed) + number of entries + number of data blocks diff --git a/src/leveldb/helpers/memenv/memenv.cc b/src/leveldb/helpers/memenv/memenv.cc new file mode 100644 index 0000000..5879de1 --- /dev/null +++ b/src/leveldb/helpers/memenv/memenv.cc @@ -0,0 +1,384 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "helpers/memenv/memenv.h" + +#include "leveldb/env.h" +#include "leveldb/status.h" +#include "port/port.h" +#include "util/mutexlock.h" +#include +#include +#include +#include + +namespace leveldb { + +namespace { + +class FileState { + public: + // FileStates are reference counted. The initial reference count is zero + // and the caller must call Ref() at least once. + FileState() : refs_(0), size_(0) {} + + // Increase the reference count. + void Ref() { + MutexLock lock(&refs_mutex_); + ++refs_; + } + + // Decrease the reference count. Delete if this is the last reference. + void Unref() { + bool do_delete = false; + + { + MutexLock lock(&refs_mutex_); + --refs_; + assert(refs_ >= 0); + if (refs_ <= 0) { + do_delete = true; + } + } + + if (do_delete) { + delete this; + } + } + + uint64_t Size() const { return size_; } + + Status Read(uint64_t offset, size_t n, Slice* result, char* scratch) const { + if (offset > size_) { + return Status::IOError("Offset greater than file size."); + } + const uint64_t available = size_ - offset; + if (n > available) { + n = available; + } + if (n == 0) { + *result = Slice(); + return Status::OK(); + } + + size_t block = offset / kBlockSize; + size_t block_offset = offset % kBlockSize; + + if (n <= kBlockSize - block_offset) { + // The requested bytes are all in the first block. + *result = Slice(blocks_[block] + block_offset, n); + return Status::OK(); + } + + size_t bytes_to_copy = n; + char* dst = scratch; + + while (bytes_to_copy > 0) { + size_t avail = kBlockSize - block_offset; + if (avail > bytes_to_copy) { + avail = bytes_to_copy; + } + memcpy(dst, blocks_[block] + block_offset, avail); + + bytes_to_copy -= avail; + dst += avail; + block++; + block_offset = 0; + } + + *result = Slice(scratch, n); + return Status::OK(); + } + + Status Append(const Slice& data) { + const char* src = data.data(); + size_t src_len = data.size(); + + while (src_len > 0) { + size_t avail; + size_t offset = size_ % kBlockSize; + + if (offset != 0) { + // There is some room in the last block. + avail = kBlockSize - offset; + } else { + // No room in the last block; push new one. + blocks_.push_back(new char[kBlockSize]); + avail = kBlockSize; + } + + if (avail > src_len) { + avail = src_len; + } + memcpy(blocks_.back() + offset, src, avail); + src_len -= avail; + src += avail; + size_ += avail; + } + + return Status::OK(); + } + + private: + // Private since only Unref() should be used to delete it. + ~FileState() { + for (std::vector::iterator i = blocks_.begin(); i != blocks_.end(); + ++i) { + delete [] *i; + } + } + + // No copying allowed. + FileState(const FileState&); + void operator=(const FileState&); + + port::Mutex refs_mutex_; + int refs_; // Protected by refs_mutex_; + + // The following fields are not protected by any mutex. They are only mutable + // while the file is being written, and concurrent access is not allowed + // to writable files. + std::vector blocks_; + uint64_t size_; + + enum { kBlockSize = 8 * 1024 }; +}; + +class SequentialFileImpl : public SequentialFile { + public: + explicit SequentialFileImpl(FileState* file) : file_(file), pos_(0) { + file_->Ref(); + } + + ~SequentialFileImpl() { + file_->Unref(); + } + + virtual Status Read(size_t n, Slice* result, char* scratch) { + Status s = file_->Read(pos_, n, result, scratch); + if (s.ok()) { + pos_ += result->size(); + } + return s; + } + + virtual Status Skip(uint64_t n) { + if (pos_ > file_->Size()) { + return Status::IOError("pos_ > file_->Size()"); + } + const size_t available = file_->Size() - pos_; + if (n > available) { + n = available; + } + pos_ += n; + return Status::OK(); + } + + private: + FileState* file_; + size_t pos_; +}; + +class RandomAccessFileImpl : public RandomAccessFile { + public: + explicit RandomAccessFileImpl(FileState* file) : file_(file) { + file_->Ref(); + } + + ~RandomAccessFileImpl() { + file_->Unref(); + } + + virtual Status Read(uint64_t offset, size_t n, Slice* result, + char* scratch) const { + return file_->Read(offset, n, result, scratch); + } + + private: + FileState* file_; +}; + +class WritableFileImpl : public WritableFile { + public: + WritableFileImpl(FileState* file) : file_(file) { + file_->Ref(); + } + + ~WritableFileImpl() { + file_->Unref(); + } + + virtual Status Append(const Slice& data) { + return file_->Append(data); + } + + virtual Status Close() { return Status::OK(); } + virtual Status Flush() { return Status::OK(); } + virtual Status Sync() { return Status::OK(); } + + private: + FileState* file_; +}; + +class NoOpLogger : public Logger { + public: + virtual void Logv(const char* format, va_list ap) { } +}; + +class InMemoryEnv : public EnvWrapper { + public: + explicit InMemoryEnv(Env* base_env) : EnvWrapper(base_env) { } + + virtual ~InMemoryEnv() { + for (FileSystem::iterator i = file_map_.begin(); i != file_map_.end(); ++i){ + i->second->Unref(); + } + } + + // Partial implementation of the Env interface. + virtual Status NewSequentialFile(const std::string& fname, + SequentialFile** result) { + MutexLock lock(&mutex_); + if (file_map_.find(fname) == file_map_.end()) { + *result = NULL; + return Status::IOError(fname, "File not found"); + } + + *result = new SequentialFileImpl(file_map_[fname]); + return Status::OK(); + } + + virtual Status NewRandomAccessFile(const std::string& fname, + RandomAccessFile** result) { + MutexLock lock(&mutex_); + if (file_map_.find(fname) == file_map_.end()) { + *result = NULL; + return Status::IOError(fname, "File not found"); + } + + *result = new RandomAccessFileImpl(file_map_[fname]); + return Status::OK(); + } + + virtual Status NewWritableFile(const std::string& fname, + WritableFile** result) { + MutexLock lock(&mutex_); + if (file_map_.find(fname) != file_map_.end()) { + DeleteFileInternal(fname); + } + + FileState* file = new FileState(); + file->Ref(); + file_map_[fname] = file; + + *result = new WritableFileImpl(file); + return Status::OK(); + } + + virtual bool FileExists(const std::string& fname) { + MutexLock lock(&mutex_); + return file_map_.find(fname) != file_map_.end(); + } + + virtual Status GetChildren(const std::string& dir, + std::vector* result) { + MutexLock lock(&mutex_); + result->clear(); + + for (FileSystem::iterator i = file_map_.begin(); i != file_map_.end(); ++i){ + const std::string& filename = i->first; + + if (filename.size() >= dir.size() + 1 && filename[dir.size()] == '/' && + Slice(filename).starts_with(Slice(dir))) { + result->push_back(filename.substr(dir.size() + 1)); + } + } + + return Status::OK(); + } + + void DeleteFileInternal(const std::string& fname) { + if (file_map_.find(fname) == file_map_.end()) { + return; + } + + file_map_[fname]->Unref(); + file_map_.erase(fname); + } + + virtual Status DeleteFile(const std::string& fname) { + MutexLock lock(&mutex_); + if (file_map_.find(fname) == file_map_.end()) { + return Status::IOError(fname, "File not found"); + } + + DeleteFileInternal(fname); + return Status::OK(); + } + + virtual Status CreateDir(const std::string& dirname) { + return Status::OK(); + } + + virtual Status DeleteDir(const std::string& dirname) { + return Status::OK(); + } + + virtual Status GetFileSize(const std::string& fname, uint64_t* file_size) { + MutexLock lock(&mutex_); + if (file_map_.find(fname) == file_map_.end()) { + return Status::IOError(fname, "File not found"); + } + + *file_size = file_map_[fname]->Size(); + return Status::OK(); + } + + virtual Status RenameFile(const std::string& src, + const std::string& target) { + MutexLock lock(&mutex_); + if (file_map_.find(src) == file_map_.end()) { + return Status::IOError(src, "File not found"); + } + + DeleteFileInternal(target); + file_map_[target] = file_map_[src]; + file_map_.erase(src); + return Status::OK(); + } + + virtual Status LockFile(const std::string& fname, FileLock** lock) { + *lock = new FileLock; + return Status::OK(); + } + + virtual Status UnlockFile(FileLock* lock) { + delete lock; + return Status::OK(); + } + + virtual Status GetTestDirectory(std::string* path) { + *path = "/test"; + return Status::OK(); + } + + virtual Status NewLogger(const std::string& fname, Logger** result) { + *result = new NoOpLogger; + return Status::OK(); + } + + private: + // Map from filenames to FileState objects, representing a simple file system. + typedef std::map FileSystem; + port::Mutex mutex_; + FileSystem file_map_; // Protected by mutex_. +}; + +} // namespace + +Env* NewMemEnv(Env* base_env) { + return new InMemoryEnv(base_env); +} + +} // namespace leveldb diff --git a/src/leveldb/helpers/memenv/memenv.h b/src/leveldb/helpers/memenv/memenv.h new file mode 100644 index 0000000..03b88de --- /dev/null +++ b/src/leveldb/helpers/memenv/memenv.h @@ -0,0 +1,20 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_HELPERS_MEMENV_MEMENV_H_ +#define STORAGE_LEVELDB_HELPERS_MEMENV_MEMENV_H_ + +namespace leveldb { + +class Env; + +// Returns a new environment that stores its data in memory and delegates +// all non-file-storage tasks to base_env. The caller must delete the result +// when it is no longer needed. +// *base_env must remain live while the result is in use. +Env* NewMemEnv(Env* base_env); + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_HELPERS_MEMENV_MEMENV_H_ diff --git a/src/leveldb/helpers/memenv/memenv_test.cc b/src/leveldb/helpers/memenv/memenv_test.cc new file mode 100644 index 0000000..a44310f --- /dev/null +++ b/src/leveldb/helpers/memenv/memenv_test.cc @@ -0,0 +1,232 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "helpers/memenv/memenv.h" + +#include "db/db_impl.h" +#include "leveldb/db.h" +#include "leveldb/env.h" +#include "util/testharness.h" +#include +#include + +namespace leveldb { + +class MemEnvTest { + public: + Env* env_; + + MemEnvTest() + : env_(NewMemEnv(Env::Default())) { + } + ~MemEnvTest() { + delete env_; + } +}; + +TEST(MemEnvTest, Basics) { + uint64_t file_size; + WritableFile* writable_file; + std::vector children; + + ASSERT_OK(env_->CreateDir("/dir")); + + // Check that the directory is empty. + ASSERT_TRUE(!env_->FileExists("/dir/non_existent")); + ASSERT_TRUE(!env_->GetFileSize("/dir/non_existent", &file_size).ok()); + ASSERT_OK(env_->GetChildren("/dir", &children)); + ASSERT_EQ(0, children.size()); + + // Create a file. + ASSERT_OK(env_->NewWritableFile("/dir/f", &writable_file)); + delete writable_file; + + // Check that the file exists. + ASSERT_TRUE(env_->FileExists("/dir/f")); + ASSERT_OK(env_->GetFileSize("/dir/f", &file_size)); + ASSERT_EQ(0, file_size); + ASSERT_OK(env_->GetChildren("/dir", &children)); + ASSERT_EQ(1, children.size()); + ASSERT_EQ("f", children[0]); + + // Write to the file. + ASSERT_OK(env_->NewWritableFile("/dir/f", &writable_file)); + ASSERT_OK(writable_file->Append("abc")); + delete writable_file; + + // Check for expected size. + ASSERT_OK(env_->GetFileSize("/dir/f", &file_size)); + ASSERT_EQ(3, file_size); + + // Check that renaming works. + ASSERT_TRUE(!env_->RenameFile("/dir/non_existent", "/dir/g").ok()); + ASSERT_OK(env_->RenameFile("/dir/f", "/dir/g")); + ASSERT_TRUE(!env_->FileExists("/dir/f")); + ASSERT_TRUE(env_->FileExists("/dir/g")); + ASSERT_OK(env_->GetFileSize("/dir/g", &file_size)); + ASSERT_EQ(3, file_size); + + // Check that opening non-existent file fails. + SequentialFile* seq_file; + RandomAccessFile* rand_file; + ASSERT_TRUE(!env_->NewSequentialFile("/dir/non_existent", &seq_file).ok()); + ASSERT_TRUE(!seq_file); + ASSERT_TRUE(!env_->NewRandomAccessFile("/dir/non_existent", &rand_file).ok()); + ASSERT_TRUE(!rand_file); + + // Check that deleting works. + ASSERT_TRUE(!env_->DeleteFile("/dir/non_existent").ok()); + ASSERT_OK(env_->DeleteFile("/dir/g")); + ASSERT_TRUE(!env_->FileExists("/dir/g")); + ASSERT_OK(env_->GetChildren("/dir", &children)); + ASSERT_EQ(0, children.size()); + ASSERT_OK(env_->DeleteDir("/dir")); +} + +TEST(MemEnvTest, ReadWrite) { + WritableFile* writable_file; + SequentialFile* seq_file; + RandomAccessFile* rand_file; + Slice result; + char scratch[100]; + + ASSERT_OK(env_->CreateDir("/dir")); + + ASSERT_OK(env_->NewWritableFile("/dir/f", &writable_file)); + ASSERT_OK(writable_file->Append("hello ")); + ASSERT_OK(writable_file->Append("world")); + delete writable_file; + + // Read sequentially. + ASSERT_OK(env_->NewSequentialFile("/dir/f", &seq_file)); + ASSERT_OK(seq_file->Read(5, &result, scratch)); // Read "hello". + ASSERT_EQ(0, result.compare("hello")); + ASSERT_OK(seq_file->Skip(1)); + ASSERT_OK(seq_file->Read(1000, &result, scratch)); // Read "world". + ASSERT_EQ(0, result.compare("world")); + ASSERT_OK(seq_file->Read(1000, &result, scratch)); // Try reading past EOF. + ASSERT_EQ(0, result.size()); + ASSERT_OK(seq_file->Skip(100)); // Try to skip past end of file. + ASSERT_OK(seq_file->Read(1000, &result, scratch)); + ASSERT_EQ(0, result.size()); + delete seq_file; + + // Random reads. + ASSERT_OK(env_->NewRandomAccessFile("/dir/f", &rand_file)); + ASSERT_OK(rand_file->Read(6, 5, &result, scratch)); // Read "world". + ASSERT_EQ(0, result.compare("world")); + ASSERT_OK(rand_file->Read(0, 5, &result, scratch)); // Read "hello". + ASSERT_EQ(0, result.compare("hello")); + ASSERT_OK(rand_file->Read(10, 100, &result, scratch)); // Read "d". + ASSERT_EQ(0, result.compare("d")); + + // Too high offset. + ASSERT_TRUE(!rand_file->Read(1000, 5, &result, scratch).ok()); + delete rand_file; +} + +TEST(MemEnvTest, Locks) { + FileLock* lock; + + // These are no-ops, but we test they return success. + ASSERT_OK(env_->LockFile("some file", &lock)); + ASSERT_OK(env_->UnlockFile(lock)); +} + +TEST(MemEnvTest, Misc) { + std::string test_dir; + ASSERT_OK(env_->GetTestDirectory(&test_dir)); + ASSERT_TRUE(!test_dir.empty()); + + WritableFile* writable_file; + ASSERT_OK(env_->NewWritableFile("/a/b", &writable_file)); + + // These are no-ops, but we test they return success. + ASSERT_OK(writable_file->Sync()); + ASSERT_OK(writable_file->Flush()); + ASSERT_OK(writable_file->Close()); + delete writable_file; +} + +TEST(MemEnvTest, LargeWrite) { + const size_t kWriteSize = 300 * 1024; + char* scratch = new char[kWriteSize * 2]; + + std::string write_data; + for (size_t i = 0; i < kWriteSize; ++i) { + write_data.append(1, static_cast(i)); + } + + WritableFile* writable_file; + ASSERT_OK(env_->NewWritableFile("/dir/f", &writable_file)); + ASSERT_OK(writable_file->Append("foo")); + ASSERT_OK(writable_file->Append(write_data)); + delete writable_file; + + SequentialFile* seq_file; + Slice result; + ASSERT_OK(env_->NewSequentialFile("/dir/f", &seq_file)); + ASSERT_OK(seq_file->Read(3, &result, scratch)); // Read "foo". + ASSERT_EQ(0, result.compare("foo")); + + size_t read = 0; + std::string read_data; + while (read < kWriteSize) { + ASSERT_OK(seq_file->Read(kWriteSize - read, &result, scratch)); + read_data.append(result.data(), result.size()); + read += result.size(); + } + ASSERT_TRUE(write_data == read_data); + delete seq_file; + delete [] scratch; +} + +TEST(MemEnvTest, DBTest) { + Options options; + options.create_if_missing = true; + options.env = env_; + DB* db; + + const Slice keys[] = {Slice("aaa"), Slice("bbb"), Slice("ccc")}; + const Slice vals[] = {Slice("foo"), Slice("bar"), Slice("baz")}; + + ASSERT_OK(DB::Open(options, "/dir/db", &db)); + for (size_t i = 0; i < 3; ++i) { + ASSERT_OK(db->Put(WriteOptions(), keys[i], vals[i])); + } + + for (size_t i = 0; i < 3; ++i) { + std::string res; + ASSERT_OK(db->Get(ReadOptions(), keys[i], &res)); + ASSERT_TRUE(res == vals[i]); + } + + Iterator* iterator = db->NewIterator(ReadOptions()); + iterator->SeekToFirst(); + for (size_t i = 0; i < 3; ++i) { + ASSERT_TRUE(iterator->Valid()); + ASSERT_TRUE(keys[i] == iterator->key()); + ASSERT_TRUE(vals[i] == iterator->value()); + iterator->Next(); + } + ASSERT_TRUE(!iterator->Valid()); + delete iterator; + + DBImpl* dbi = reinterpret_cast(db); + ASSERT_OK(dbi->TEST_CompactMemTable()); + + for (size_t i = 0; i < 3; ++i) { + std::string res; + ASSERT_OK(db->Get(ReadOptions(), keys[i], &res)); + ASSERT_TRUE(res == vals[i]); + } + + delete db; +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/include/leveldb/c.h b/src/leveldb/include/leveldb/c.h new file mode 100644 index 0000000..1fa5886 --- /dev/null +++ b/src/leveldb/include/leveldb/c.h @@ -0,0 +1,291 @@ +/* Copyright (c) 2011 The LevelDB Authors. All rights reserved. + Use of this source code is governed by a BSD-style license that can be + found in the LICENSE file. See the AUTHORS file for names of contributors. + + C bindings for leveldb. May be useful as a stable ABI that can be + used by programs that keep leveldb in a shared library, or for + a JNI api. + + Does not support: + . getters for the option types + . custom comparators that implement key shortening + . capturing post-write-snapshot + . custom iter, db, env, cache implementations using just the C bindings + + Some conventions: + + (1) We expose just opaque struct pointers and functions to clients. + This allows us to change internal representations without having to + recompile clients. + + (2) For simplicity, there is no equivalent to the Slice type. Instead, + the caller has to pass the pointer and length as separate + arguments. + + (3) Errors are represented by a null-terminated c string. NULL + means no error. All operations that can raise an error are passed + a "char** errptr" as the last argument. One of the following must + be true on entry: + *errptr == NULL + *errptr points to a malloc()ed null-terminated error message + (On Windows, *errptr must have been malloc()-ed by this library.) + On success, a leveldb routine leaves *errptr unchanged. + On failure, leveldb frees the old value of *errptr and + set *errptr to a malloc()ed error message. + + (4) Bools have the type unsigned char (0 == false; rest == true) + + (5) All of the pointer arguments must be non-NULL. +*/ + +#ifndef STORAGE_LEVELDB_INCLUDE_C_H_ +#define STORAGE_LEVELDB_INCLUDE_C_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* Exported types */ + +typedef struct leveldb_t leveldb_t; +typedef struct leveldb_cache_t leveldb_cache_t; +typedef struct leveldb_comparator_t leveldb_comparator_t; +typedef struct leveldb_env_t leveldb_env_t; +typedef struct leveldb_filelock_t leveldb_filelock_t; +typedef struct leveldb_filterpolicy_t leveldb_filterpolicy_t; +typedef struct leveldb_iterator_t leveldb_iterator_t; +typedef struct leveldb_logger_t leveldb_logger_t; +typedef struct leveldb_options_t leveldb_options_t; +typedef struct leveldb_randomfile_t leveldb_randomfile_t; +typedef struct leveldb_readoptions_t leveldb_readoptions_t; +typedef struct leveldb_seqfile_t leveldb_seqfile_t; +typedef struct leveldb_snapshot_t leveldb_snapshot_t; +typedef struct leveldb_writablefile_t leveldb_writablefile_t; +typedef struct leveldb_writebatch_t leveldb_writebatch_t; +typedef struct leveldb_writeoptions_t leveldb_writeoptions_t; + +/* DB operations */ + +extern leveldb_t* leveldb_open( + const leveldb_options_t* options, + const char* name, + char** errptr); + +extern void leveldb_close(leveldb_t* db); + +extern void leveldb_put( + leveldb_t* db, + const leveldb_writeoptions_t* options, + const char* key, size_t keylen, + const char* val, size_t vallen, + char** errptr); + +extern void leveldb_delete( + leveldb_t* db, + const leveldb_writeoptions_t* options, + const char* key, size_t keylen, + char** errptr); + +extern void leveldb_write( + leveldb_t* db, + const leveldb_writeoptions_t* options, + leveldb_writebatch_t* batch, + char** errptr); + +/* Returns NULL if not found. A malloc()ed array otherwise. + Stores the length of the array in *vallen. */ +extern char* leveldb_get( + leveldb_t* db, + const leveldb_readoptions_t* options, + const char* key, size_t keylen, + size_t* vallen, + char** errptr); + +extern leveldb_iterator_t* leveldb_create_iterator( + leveldb_t* db, + const leveldb_readoptions_t* options); + +extern const leveldb_snapshot_t* leveldb_create_snapshot( + leveldb_t* db); + +extern void leveldb_release_snapshot( + leveldb_t* db, + const leveldb_snapshot_t* snapshot); + +/* Returns NULL if property name is unknown. + Else returns a pointer to a malloc()-ed null-terminated value. */ +extern char* leveldb_property_value( + leveldb_t* db, + const char* propname); + +extern void leveldb_approximate_sizes( + leveldb_t* db, + int num_ranges, + const char* const* range_start_key, const size_t* range_start_key_len, + const char* const* range_limit_key, const size_t* range_limit_key_len, + uint64_t* sizes); + +extern void leveldb_compact_range( + leveldb_t* db, + const char* start_key, size_t start_key_len, + const char* limit_key, size_t limit_key_len); + +/* Management operations */ + +extern void leveldb_destroy_db( + const leveldb_options_t* options, + const char* name, + char** errptr); + +extern void leveldb_repair_db( + const leveldb_options_t* options, + const char* name, + char** errptr); + +/* Iterator */ + +extern void leveldb_iter_destroy(leveldb_iterator_t*); +extern unsigned char leveldb_iter_valid(const leveldb_iterator_t*); +extern void leveldb_iter_seek_to_first(leveldb_iterator_t*); +extern void leveldb_iter_seek_to_last(leveldb_iterator_t*); +extern void leveldb_iter_seek(leveldb_iterator_t*, const char* k, size_t klen); +extern void leveldb_iter_next(leveldb_iterator_t*); +extern void leveldb_iter_prev(leveldb_iterator_t*); +extern const char* leveldb_iter_key(const leveldb_iterator_t*, size_t* klen); +extern const char* leveldb_iter_value(const leveldb_iterator_t*, size_t* vlen); +extern void leveldb_iter_get_error(const leveldb_iterator_t*, char** errptr); + +/* Write batch */ + +extern leveldb_writebatch_t* leveldb_writebatch_create(); +extern void leveldb_writebatch_destroy(leveldb_writebatch_t*); +extern void leveldb_writebatch_clear(leveldb_writebatch_t*); +extern void leveldb_writebatch_put( + leveldb_writebatch_t*, + const char* key, size_t klen, + const char* val, size_t vlen); +extern void leveldb_writebatch_delete( + leveldb_writebatch_t*, + const char* key, size_t klen); +extern void leveldb_writebatch_iterate( + leveldb_writebatch_t*, + void* state, + void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen), + void (*deleted)(void*, const char* k, size_t klen)); + +/* Options */ + +extern leveldb_options_t* leveldb_options_create(); +extern void leveldb_options_destroy(leveldb_options_t*); +extern void leveldb_options_set_comparator( + leveldb_options_t*, + leveldb_comparator_t*); +extern void leveldb_options_set_filter_policy( + leveldb_options_t*, + leveldb_filterpolicy_t*); +extern void leveldb_options_set_create_if_missing( + leveldb_options_t*, unsigned char); +extern void leveldb_options_set_error_if_exists( + leveldb_options_t*, unsigned char); +extern void leveldb_options_set_paranoid_checks( + leveldb_options_t*, unsigned char); +extern void leveldb_options_set_env(leveldb_options_t*, leveldb_env_t*); +extern void leveldb_options_set_info_log(leveldb_options_t*, leveldb_logger_t*); +extern void leveldb_options_set_write_buffer_size(leveldb_options_t*, size_t); +extern void leveldb_options_set_max_open_files(leveldb_options_t*, int); +extern void leveldb_options_set_cache(leveldb_options_t*, leveldb_cache_t*); +extern void leveldb_options_set_block_size(leveldb_options_t*, size_t); +extern void leveldb_options_set_block_restart_interval(leveldb_options_t*, int); + +enum { + leveldb_no_compression = 0, + leveldb_snappy_compression = 1 +}; +extern void leveldb_options_set_compression(leveldb_options_t*, int); + +/* Comparator */ + +extern leveldb_comparator_t* leveldb_comparator_create( + void* state, + void (*destructor)(void*), + int (*compare)( + void*, + const char* a, size_t alen, + const char* b, size_t blen), + const char* (*name)(void*)); +extern void leveldb_comparator_destroy(leveldb_comparator_t*); + +/* Filter policy */ + +extern leveldb_filterpolicy_t* leveldb_filterpolicy_create( + void* state, + void (*destructor)(void*), + char* (*create_filter)( + void*, + const char* const* key_array, const size_t* key_length_array, + int num_keys, + size_t* filter_length), + unsigned char (*key_may_match)( + void*, + const char* key, size_t length, + const char* filter, size_t filter_length), + const char* (*name)(void*)); +extern void leveldb_filterpolicy_destroy(leveldb_filterpolicy_t*); + +extern leveldb_filterpolicy_t* leveldb_filterpolicy_create_bloom( + int bits_per_key); + +/* Read options */ + +extern leveldb_readoptions_t* leveldb_readoptions_create(); +extern void leveldb_readoptions_destroy(leveldb_readoptions_t*); +extern void leveldb_readoptions_set_verify_checksums( + leveldb_readoptions_t*, + unsigned char); +extern void leveldb_readoptions_set_fill_cache( + leveldb_readoptions_t*, unsigned char); +extern void leveldb_readoptions_set_snapshot( + leveldb_readoptions_t*, + const leveldb_snapshot_t*); + +/* Write options */ + +extern leveldb_writeoptions_t* leveldb_writeoptions_create(); +extern void leveldb_writeoptions_destroy(leveldb_writeoptions_t*); +extern void leveldb_writeoptions_set_sync( + leveldb_writeoptions_t*, unsigned char); + +/* Cache */ + +extern leveldb_cache_t* leveldb_cache_create_lru(size_t capacity); +extern void leveldb_cache_destroy(leveldb_cache_t* cache); + +/* Env */ + +extern leveldb_env_t* leveldb_create_default_env(); +extern void leveldb_env_destroy(leveldb_env_t*); + +/* Utility */ + +/* Calls free(ptr). + REQUIRES: ptr was malloc()-ed and returned by one of the routines + in this file. Note that in certain cases (typically on Windows), you + may need to call this routine instead of free(ptr) to dispose of + malloc()-ed memory returned by this library. */ +extern void leveldb_free(void* ptr); + +/* Return the major version number for this release. */ +extern int leveldb_major_version(); + +/* Return the minor version number for this release. */ +extern int leveldb_minor_version(); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif + +#endif /* STORAGE_LEVELDB_INCLUDE_C_H_ */ diff --git a/src/leveldb/include/leveldb/cache.h b/src/leveldb/include/leveldb/cache.h new file mode 100644 index 0000000..5e3b476 --- /dev/null +++ b/src/leveldb/include/leveldb/cache.h @@ -0,0 +1,99 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// A Cache is an interface that maps keys to values. It has internal +// synchronization and may be safely accessed concurrently from +// multiple threads. It may automatically evict entries to make room +// for new entries. Values have a specified charge against the cache +// capacity. For example, a cache where the values are variable +// length strings, may use the length of the string as the charge for +// the string. +// +// A builtin cache implementation with a least-recently-used eviction +// policy is provided. Clients may use their own implementations if +// they want something more sophisticated (like scan-resistance, a +// custom eviction policy, variable cache sizing, etc.) + +#ifndef STORAGE_LEVELDB_INCLUDE_CACHE_H_ +#define STORAGE_LEVELDB_INCLUDE_CACHE_H_ + +#include +#include "leveldb/slice.h" + +namespace leveldb { + +class Cache; + +// Create a new cache with a fixed size capacity. This implementation +// of Cache uses a least-recently-used eviction policy. +extern Cache* NewLRUCache(size_t capacity); + +class Cache { + public: + Cache() { } + + // Destroys all existing entries by calling the "deleter" + // function that was passed to the constructor. + virtual ~Cache(); + + // Opaque handle to an entry stored in the cache. + struct Handle { }; + + // Insert a mapping from key->value into the cache and assign it + // the specified charge against the total cache capacity. + // + // Returns a handle that corresponds to the mapping. The caller + // must call this->Release(handle) when the returned mapping is no + // longer needed. + // + // When the inserted entry is no longer needed, the key and + // value will be passed to "deleter". + virtual Handle* Insert(const Slice& key, void* value, size_t charge, + void (*deleter)(const Slice& key, void* value)) = 0; + + // If the cache has no mapping for "key", returns NULL. + // + // Else return a handle that corresponds to the mapping. The caller + // must call this->Release(handle) when the returned mapping is no + // longer needed. + virtual Handle* Lookup(const Slice& key) = 0; + + // Release a mapping returned by a previous Lookup(). + // REQUIRES: handle must not have been released yet. + // REQUIRES: handle must have been returned by a method on *this. + virtual void Release(Handle* handle) = 0; + + // Return the value encapsulated in a handle returned by a + // successful Lookup(). + // REQUIRES: handle must not have been released yet. + // REQUIRES: handle must have been returned by a method on *this. + virtual void* Value(Handle* handle) = 0; + + // If the cache contains entry for key, erase it. Note that the + // underlying entry will be kept around until all existing handles + // to it have been released. + virtual void Erase(const Slice& key) = 0; + + // Return a new numeric id. May be used by multiple clients who are + // sharing the same cache to partition the key space. Typically the + // client will allocate a new id at startup and prepend the id to + // its cache keys. + virtual uint64_t NewId() = 0; + + private: + void LRU_Remove(Handle* e); + void LRU_Append(Handle* e); + void Unref(Handle* e); + + struct Rep; + Rep* rep_; + + // No copying allowed + Cache(const Cache&); + void operator=(const Cache&); +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_UTIL_CACHE_H_ diff --git a/src/leveldb/include/leveldb/comparator.h b/src/leveldb/include/leveldb/comparator.h new file mode 100644 index 0000000..556b984 --- /dev/null +++ b/src/leveldb/include/leveldb/comparator.h @@ -0,0 +1,63 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_INCLUDE_COMPARATOR_H_ +#define STORAGE_LEVELDB_INCLUDE_COMPARATOR_H_ + +#include + +namespace leveldb { + +class Slice; + +// A Comparator object provides a total order across slices that are +// used as keys in an sstable or a database. A Comparator implementation +// must be thread-safe since leveldb may invoke its methods concurrently +// from multiple threads. +class Comparator { + public: + virtual ~Comparator(); + + // Three-way comparison. Returns value: + // < 0 iff "a" < "b", + // == 0 iff "a" == "b", + // > 0 iff "a" > "b" + virtual int Compare(const Slice& a, const Slice& b) const = 0; + + // The name of the comparator. Used to check for comparator + // mismatches (i.e., a DB created with one comparator is + // accessed using a different comparator. + // + // The client of this package should switch to a new name whenever + // the comparator implementation changes in a way that will cause + // the relative ordering of any two keys to change. + // + // Names starting with "leveldb." are reserved and should not be used + // by any clients of this package. + virtual const char* Name() const = 0; + + // Advanced functions: these are used to reduce the space requirements + // for internal data structures like index blocks. + + // If *start < limit, changes *start to a short string in [start,limit). + // Simple comparator implementations may return with *start unchanged, + // i.e., an implementation of this method that does nothing is correct. + virtual void FindShortestSeparator( + std::string* start, + const Slice& limit) const = 0; + + // Changes *key to a short string >= *key. + // Simple comparator implementations may return with *key unchanged, + // i.e., an implementation of this method that does nothing is correct. + virtual void FindShortSuccessor(std::string* key) const = 0; +}; + +// Return a builtin comparator that uses lexicographic byte-wise +// ordering. The result remains the property of this module and +// must not be deleted. +extern const Comparator* BytewiseComparator(); + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_INCLUDE_COMPARATOR_H_ diff --git a/src/leveldb/include/leveldb/db.h b/src/leveldb/include/leveldb/db.h new file mode 100644 index 0000000..5ffb29d --- /dev/null +++ b/src/leveldb/include/leveldb/db.h @@ -0,0 +1,161 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_INCLUDE_DB_H_ +#define STORAGE_LEVELDB_INCLUDE_DB_H_ + +#include +#include +#include "leveldb/iterator.h" +#include "leveldb/options.h" + +namespace leveldb { + +// Update Makefile if you change these +static const int kMajorVersion = 1; +static const int kMinorVersion = 15; + +struct Options; +struct ReadOptions; +struct WriteOptions; +class WriteBatch; + +// Abstract handle to particular state of a DB. +// A Snapshot is an immutable object and can therefore be safely +// accessed from multiple threads without any external synchronization. +class Snapshot { + protected: + virtual ~Snapshot(); +}; + +// A range of keys +struct Range { + Slice start; // Included in the range + Slice limit; // Not included in the range + + Range() { } + Range(const Slice& s, const Slice& l) : start(s), limit(l) { } +}; + +// A DB is a persistent ordered map from keys to values. +// A DB is safe for concurrent access from multiple threads without +// any external synchronization. +class DB { + public: + // Open the database with the specified "name". + // Stores a pointer to a heap-allocated database in *dbptr and returns + // OK on success. + // Stores NULL in *dbptr and returns a non-OK status on error. + // Caller should delete *dbptr when it is no longer needed. + static Status Open(const Options& options, + const std::string& name, + DB** dbptr); + + DB() { } + virtual ~DB(); + + // Set the database entry for "key" to "value". Returns OK on success, + // and a non-OK status on error. + // Note: consider setting options.sync = true. + virtual Status Put(const WriteOptions& options, + const Slice& key, + const Slice& value) = 0; + + // Remove the database entry (if any) for "key". Returns OK on + // success, and a non-OK status on error. It is not an error if "key" + // did not exist in the database. + // Note: consider setting options.sync = true. + virtual Status Delete(const WriteOptions& options, const Slice& key) = 0; + + // Apply the specified updates to the database. + // Returns OK on success, non-OK on failure. + // Note: consider setting options.sync = true. + virtual Status Write(const WriteOptions& options, WriteBatch* updates) = 0; + + // If the database contains an entry for "key" store the + // corresponding value in *value and return OK. + // + // If there is no entry for "key" leave *value unchanged and return + // a status for which Status::IsNotFound() returns true. + // + // May return some other Status on an error. + virtual Status Get(const ReadOptions& options, + const Slice& key, std::string* value) = 0; + + // Return a heap-allocated iterator over the contents of the database. + // The result of NewIterator() is initially invalid (caller must + // call one of the Seek methods on the iterator before using it). + // + // Caller should delete the iterator when it is no longer needed. + // The returned iterator should be deleted before this db is deleted. + virtual Iterator* NewIterator(const ReadOptions& options) = 0; + + // Return a handle to the current DB state. Iterators created with + // this handle will all observe a stable snapshot of the current DB + // state. The caller must call ReleaseSnapshot(result) when the + // snapshot is no longer needed. + virtual const Snapshot* GetSnapshot() = 0; + + // Release a previously acquired snapshot. The caller must not + // use "snapshot" after this call. + virtual void ReleaseSnapshot(const Snapshot* snapshot) = 0; + + // DB implementations can export properties about their state + // via this method. If "property" is a valid property understood by this + // DB implementation, fills "*value" with its current value and returns + // true. Otherwise returns false. + // + // + // Valid property names include: + // + // "leveldb.num-files-at-level" - return the number of files at level , + // where is an ASCII representation of a level number (e.g. "0"). + // "leveldb.stats" - returns a multi-line string that describes statistics + // about the internal operation of the DB. + // "leveldb.sstables" - returns a multi-line string that describes all + // of the sstables that make up the db contents. + virtual bool GetProperty(const Slice& property, std::string* value) = 0; + + // For each i in [0,n-1], store in "sizes[i]", the approximate + // file system space used by keys in "[range[i].start .. range[i].limit)". + // + // Note that the returned sizes measure file system space usage, so + // if the user data compresses by a factor of ten, the returned + // sizes will be one-tenth the size of the corresponding user data size. + // + // The results may not include the sizes of recently written data. + virtual void GetApproximateSizes(const Range* range, int n, + uint64_t* sizes) = 0; + + // Compact the underlying storage for the key range [*begin,*end]. + // In particular, deleted and overwritten versions are discarded, + // and the data is rearranged to reduce the cost of operations + // needed to access the data. This operation should typically only + // be invoked by users who understand the underlying implementation. + // + // begin==NULL is treated as a key before all keys in the database. + // end==NULL is treated as a key after all keys in the database. + // Therefore the following call will compact the entire database: + // db->CompactRange(NULL, NULL); + virtual void CompactRange(const Slice* begin, const Slice* end) = 0; + + private: + // No copying allowed + DB(const DB&); + void operator=(const DB&); +}; + +// Destroy the contents of the specified database. +// Be very careful using this method. +Status DestroyDB(const std::string& name, const Options& options); + +// If a DB cannot be opened, you may attempt to call this method to +// resurrect as much of the contents of the database as possible. +// Some data may be lost, so be careful when calling this function +// on a database that contains important information. +Status RepairDB(const std::string& dbname, const Options& options); + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_INCLUDE_DB_H_ diff --git a/src/leveldb/include/leveldb/env.h b/src/leveldb/include/leveldb/env.h new file mode 100644 index 0000000..b2072d0 --- /dev/null +++ b/src/leveldb/include/leveldb/env.h @@ -0,0 +1,333 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// An Env is an interface used by the leveldb implementation to access +// operating system functionality like the filesystem etc. Callers +// may wish to provide a custom Env object when opening a database to +// get fine gain control; e.g., to rate limit file system operations. +// +// All Env implementations are safe for concurrent access from +// multiple threads without any external synchronization. + +#ifndef STORAGE_LEVELDB_INCLUDE_ENV_H_ +#define STORAGE_LEVELDB_INCLUDE_ENV_H_ + +#include +#include +#include +#include +#include "leveldb/status.h" + +namespace leveldb { + +class FileLock; +class Logger; +class RandomAccessFile; +class SequentialFile; +class Slice; +class WritableFile; + +class Env { + public: + Env() { } + virtual ~Env(); + + // Return a default environment suitable for the current operating + // system. Sophisticated users may wish to provide their own Env + // implementation instead of relying on this default environment. + // + // The result of Default() belongs to leveldb and must never be deleted. + static Env* Default(); + + // Create a brand new sequentially-readable file with the specified name. + // On success, stores a pointer to the new file in *result and returns OK. + // On failure stores NULL in *result and returns non-OK. If the file does + // not exist, returns a non-OK status. + // + // The returned file will only be accessed by one thread at a time. + virtual Status NewSequentialFile(const std::string& fname, + SequentialFile** result) = 0; + + // Create a brand new random access read-only file with the + // specified name. On success, stores a pointer to the new file in + // *result and returns OK. On failure stores NULL in *result and + // returns non-OK. If the file does not exist, returns a non-OK + // status. + // + // The returned file may be concurrently accessed by multiple threads. + virtual Status NewRandomAccessFile(const std::string& fname, + RandomAccessFile** result) = 0; + + // Create an object that writes to a new file with the specified + // name. Deletes any existing file with the same name and creates a + // new file. On success, stores a pointer to the new file in + // *result and returns OK. On failure stores NULL in *result and + // returns non-OK. + // + // The returned file will only be accessed by one thread at a time. + virtual Status NewWritableFile(const std::string& fname, + WritableFile** result) = 0; + + // Returns true iff the named file exists. + virtual bool FileExists(const std::string& fname) = 0; + + // Store in *result the names of the children of the specified directory. + // The names are relative to "dir". + // Original contents of *results are dropped. + virtual Status GetChildren(const std::string& dir, + std::vector* result) = 0; + + // Delete the named file. + virtual Status DeleteFile(const std::string& fname) = 0; + + // Create the specified directory. + virtual Status CreateDir(const std::string& dirname) = 0; + + // Delete the specified directory. + virtual Status DeleteDir(const std::string& dirname) = 0; + + // Store the size of fname in *file_size. + virtual Status GetFileSize(const std::string& fname, uint64_t* file_size) = 0; + + // Rename file src to target. + virtual Status RenameFile(const std::string& src, + const std::string& target) = 0; + + // Lock the specified file. Used to prevent concurrent access to + // the same db by multiple processes. On failure, stores NULL in + // *lock and returns non-OK. + // + // On success, stores a pointer to the object that represents the + // acquired lock in *lock and returns OK. The caller should call + // UnlockFile(*lock) to release the lock. If the process exits, + // the lock will be automatically released. + // + // If somebody else already holds the lock, finishes immediately + // with a failure. I.e., this call does not wait for existing locks + // to go away. + // + // May create the named file if it does not already exist. + virtual Status LockFile(const std::string& fname, FileLock** lock) = 0; + + // Release the lock acquired by a previous successful call to LockFile. + // REQUIRES: lock was returned by a successful LockFile() call + // REQUIRES: lock has not already been unlocked. + virtual Status UnlockFile(FileLock* lock) = 0; + + // Arrange to run "(*function)(arg)" once in a background thread. + // + // "function" may run in an unspecified thread. Multiple functions + // added to the same Env may run concurrently in different threads. + // I.e., the caller may not assume that background work items are + // serialized. + virtual void Schedule( + void (*function)(void* arg), + void* arg) = 0; + + // Start a new thread, invoking "function(arg)" within the new thread. + // When "function(arg)" returns, the thread will be destroyed. + virtual void StartThread(void (*function)(void* arg), void* arg) = 0; + + // *path is set to a temporary directory that can be used for testing. It may + // or many not have just been created. The directory may or may not differ + // between runs of the same process, but subsequent calls will return the + // same directory. + virtual Status GetTestDirectory(std::string* path) = 0; + + // Create and return a log file for storing informational messages. + virtual Status NewLogger(const std::string& fname, Logger** result) = 0; + + // Returns the number of micro-seconds since some fixed point in time. Only + // useful for computing deltas of time. + virtual uint64_t NowMicros() = 0; + + // Sleep/delay the thread for the perscribed number of micro-seconds. + virtual void SleepForMicroseconds(int micros) = 0; + + private: + // No copying allowed + Env(const Env&); + void operator=(const Env&); +}; + +// A file abstraction for reading sequentially through a file +class SequentialFile { + public: + SequentialFile() { } + virtual ~SequentialFile(); + + // Read up to "n" bytes from the file. "scratch[0..n-1]" may be + // written by this routine. Sets "*result" to the data that was + // read (including if fewer than "n" bytes were successfully read). + // May set "*result" to point at data in "scratch[0..n-1]", so + // "scratch[0..n-1]" must be live when "*result" is used. + // If an error was encountered, returns a non-OK status. + // + // REQUIRES: External synchronization + virtual Status Read(size_t n, Slice* result, char* scratch) = 0; + + // Skip "n" bytes from the file. This is guaranteed to be no + // slower that reading the same data, but may be faster. + // + // If end of file is reached, skipping will stop at the end of the + // file, and Skip will return OK. + // + // REQUIRES: External synchronization + virtual Status Skip(uint64_t n) = 0; + + private: + // No copying allowed + SequentialFile(const SequentialFile&); + void operator=(const SequentialFile&); +}; + +// A file abstraction for randomly reading the contents of a file. +class RandomAccessFile { + public: + RandomAccessFile() { } + virtual ~RandomAccessFile(); + + // Read up to "n" bytes from the file starting at "offset". + // "scratch[0..n-1]" may be written by this routine. Sets "*result" + // to the data that was read (including if fewer than "n" bytes were + // successfully read). May set "*result" to point at data in + // "scratch[0..n-1]", so "scratch[0..n-1]" must be live when + // "*result" is used. If an error was encountered, returns a non-OK + // status. + // + // Safe for concurrent use by multiple threads. + virtual Status Read(uint64_t offset, size_t n, Slice* result, + char* scratch) const = 0; + + private: + // No copying allowed + RandomAccessFile(const RandomAccessFile&); + void operator=(const RandomAccessFile&); +}; + +// A file abstraction for sequential writing. The implementation +// must provide buffering since callers may append small fragments +// at a time to the file. +class WritableFile { + public: + WritableFile() { } + virtual ~WritableFile(); + + virtual Status Append(const Slice& data) = 0; + virtual Status Close() = 0; + virtual Status Flush() = 0; + virtual Status Sync() = 0; + + private: + // No copying allowed + WritableFile(const WritableFile&); + void operator=(const WritableFile&); +}; + +// An interface for writing log messages. +class Logger { + public: + Logger() { } + virtual ~Logger(); + + // Write an entry to the log file with the specified format. + virtual void Logv(const char* format, va_list ap) = 0; + + private: + // No copying allowed + Logger(const Logger&); + void operator=(const Logger&); +}; + + +// Identifies a locked file. +class FileLock { + public: + FileLock() { } + virtual ~FileLock(); + private: + // No copying allowed + FileLock(const FileLock&); + void operator=(const FileLock&); +}; + +// Log the specified data to *info_log if info_log is non-NULL. +extern void Log(Logger* info_log, const char* format, ...) +# if defined(__GNUC__) || defined(__clang__) + __attribute__((__format__ (__printf__, 2, 3))) +# endif + ; + +// A utility routine: write "data" to the named file. +extern Status WriteStringToFile(Env* env, const Slice& data, + const std::string& fname); + +// A utility routine: read contents of named file into *data +extern Status ReadFileToString(Env* env, const std::string& fname, + std::string* data); + +// An implementation of Env that forwards all calls to another Env. +// May be useful to clients who wish to override just part of the +// functionality of another Env. +class EnvWrapper : public Env { + public: + // Initialize an EnvWrapper that delegates all calls to *t + explicit EnvWrapper(Env* t) : target_(t) { } + virtual ~EnvWrapper(); + + // Return the target to which this Env forwards all calls + Env* target() const { return target_; } + + // The following text is boilerplate that forwards all methods to target() + Status NewSequentialFile(const std::string& f, SequentialFile** r) { + return target_->NewSequentialFile(f, r); + } + Status NewRandomAccessFile(const std::string& f, RandomAccessFile** r) { + return target_->NewRandomAccessFile(f, r); + } + Status NewWritableFile(const std::string& f, WritableFile** r) { + return target_->NewWritableFile(f, r); + } + bool FileExists(const std::string& f) { return target_->FileExists(f); } + Status GetChildren(const std::string& dir, std::vector* r) { + return target_->GetChildren(dir, r); + } + Status DeleteFile(const std::string& f) { return target_->DeleteFile(f); } + Status CreateDir(const std::string& d) { return target_->CreateDir(d); } + Status DeleteDir(const std::string& d) { return target_->DeleteDir(d); } + Status GetFileSize(const std::string& f, uint64_t* s) { + return target_->GetFileSize(f, s); + } + Status RenameFile(const std::string& s, const std::string& t) { + return target_->RenameFile(s, t); + } + Status LockFile(const std::string& f, FileLock** l) { + return target_->LockFile(f, l); + } + Status UnlockFile(FileLock* l) { return target_->UnlockFile(l); } + void Schedule(void (*f)(void*), void* a) { + return target_->Schedule(f, a); + } + void StartThread(void (*f)(void*), void* a) { + return target_->StartThread(f, a); + } + virtual Status GetTestDirectory(std::string* path) { + return target_->GetTestDirectory(path); + } + virtual Status NewLogger(const std::string& fname, Logger** result) { + return target_->NewLogger(fname, result); + } + uint64_t NowMicros() { + return target_->NowMicros(); + } + void SleepForMicroseconds(int micros) { + target_->SleepForMicroseconds(micros); + } + private: + Env* target_; +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_INCLUDE_ENV_H_ diff --git a/src/leveldb/include/leveldb/filter_policy.h b/src/leveldb/include/leveldb/filter_policy.h new file mode 100644 index 0000000..1fba080 --- /dev/null +++ b/src/leveldb/include/leveldb/filter_policy.h @@ -0,0 +1,70 @@ +// Copyright (c) 2012 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// A database can be configured with a custom FilterPolicy object. +// This object is responsible for creating a small filter from a set +// of keys. These filters are stored in leveldb and are consulted +// automatically by leveldb to decide whether or not to read some +// information from disk. In many cases, a filter can cut down the +// number of disk seeks form a handful to a single disk seek per +// DB::Get() call. +// +// Most people will want to use the builtin bloom filter support (see +// NewBloomFilterPolicy() below). + +#ifndef STORAGE_LEVELDB_INCLUDE_FILTER_POLICY_H_ +#define STORAGE_LEVELDB_INCLUDE_FILTER_POLICY_H_ + +#include + +namespace leveldb { + +class Slice; + +class FilterPolicy { + public: + virtual ~FilterPolicy(); + + // Return the name of this policy. Note that if the filter encoding + // changes in an incompatible way, the name returned by this method + // must be changed. Otherwise, old incompatible filters may be + // passed to methods of this type. + virtual const char* Name() const = 0; + + // keys[0,n-1] contains a list of keys (potentially with duplicates) + // that are ordered according to the user supplied comparator. + // Append a filter that summarizes keys[0,n-1] to *dst. + // + // Warning: do not change the initial contents of *dst. Instead, + // append the newly constructed filter to *dst. + virtual void CreateFilter(const Slice* keys, int n, std::string* dst) + const = 0; + + // "filter" contains the data appended by a preceding call to + // CreateFilter() on this class. This method must return true if + // the key was in the list of keys passed to CreateFilter(). + // This method may return true or false if the key was not on the + // list, but it should aim to return false with a high probability. + virtual bool KeyMayMatch(const Slice& key, const Slice& filter) const = 0; +}; + +// Return a new filter policy that uses a bloom filter with approximately +// the specified number of bits per key. A good value for bits_per_key +// is 10, which yields a filter with ~ 1% false positive rate. +// +// Callers must delete the result after any database that is using the +// result has been closed. +// +// Note: if you are using a custom comparator that ignores some parts +// of the keys being compared, you must not use NewBloomFilterPolicy() +// and must provide your own FilterPolicy that also ignores the +// corresponding parts of the keys. For example, if the comparator +// ignores trailing spaces, it would be incorrect to use a +// FilterPolicy (like NewBloomFilterPolicy) that does not ignore +// trailing spaces in keys. +extern const FilterPolicy* NewBloomFilterPolicy(int bits_per_key); + +} + +#endif // STORAGE_LEVELDB_INCLUDE_FILTER_POLICY_H_ diff --git a/src/leveldb/include/leveldb/iterator.h b/src/leveldb/include/leveldb/iterator.h new file mode 100644 index 0000000..ad543eb --- /dev/null +++ b/src/leveldb/include/leveldb/iterator.h @@ -0,0 +1,100 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// An iterator yields a sequence of key/value pairs from a source. +// The following class defines the interface. Multiple implementations +// are provided by this library. In particular, iterators are provided +// to access the contents of a Table or a DB. +// +// Multiple threads can invoke const methods on an Iterator without +// external synchronization, but if any of the threads may call a +// non-const method, all threads accessing the same Iterator must use +// external synchronization. + +#ifndef STORAGE_LEVELDB_INCLUDE_ITERATOR_H_ +#define STORAGE_LEVELDB_INCLUDE_ITERATOR_H_ + +#include "leveldb/slice.h" +#include "leveldb/status.h" + +namespace leveldb { + +class Iterator { + public: + Iterator(); + virtual ~Iterator(); + + // An iterator is either positioned at a key/value pair, or + // not valid. This method returns true iff the iterator is valid. + virtual bool Valid() const = 0; + + // Position at the first key in the source. The iterator is Valid() + // after this call iff the source is not empty. + virtual void SeekToFirst() = 0; + + // Position at the last key in the source. The iterator is + // Valid() after this call iff the source is not empty. + virtual void SeekToLast() = 0; + + // Position at the first key in the source that at or past target + // The iterator is Valid() after this call iff the source contains + // an entry that comes at or past target. + virtual void Seek(const Slice& target) = 0; + + // Moves to the next entry in the source. After this call, Valid() is + // true iff the iterator was not positioned at the last entry in the source. + // REQUIRES: Valid() + virtual void Next() = 0; + + // Moves to the previous entry in the source. After this call, Valid() is + // true iff the iterator was not positioned at the first entry in source. + // REQUIRES: Valid() + virtual void Prev() = 0; + + // Return the key for the current entry. The underlying storage for + // the returned slice is valid only until the next modification of + // the iterator. + // REQUIRES: Valid() + virtual Slice key() const = 0; + + // Return the value for the current entry. The underlying storage for + // the returned slice is valid only until the next modification of + // the iterator. + // REQUIRES: !AtEnd() && !AtStart() + virtual Slice value() const = 0; + + // If an error has occurred, return it. Else return an ok status. + virtual Status status() const = 0; + + // Clients are allowed to register function/arg1/arg2 triples that + // will be invoked when this iterator is destroyed. + // + // Note that unlike all of the preceding methods, this method is + // not abstract and therefore clients should not override it. + typedef void (*CleanupFunction)(void* arg1, void* arg2); + void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2); + + private: + struct Cleanup { + CleanupFunction function; + void* arg1; + void* arg2; + Cleanup* next; + }; + Cleanup cleanup_; + + // No copying allowed + Iterator(const Iterator&); + void operator=(const Iterator&); +}; + +// Return an empty iterator (yields nothing). +extern Iterator* NewEmptyIterator(); + +// Return an empty iterator with the specified status. +extern Iterator* NewErrorIterator(const Status& status); + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_INCLUDE_ITERATOR_H_ diff --git a/src/leveldb/include/leveldb/options.h b/src/leveldb/include/leveldb/options.h new file mode 100644 index 0000000..fdda718 --- /dev/null +++ b/src/leveldb/include/leveldb/options.h @@ -0,0 +1,195 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_INCLUDE_OPTIONS_H_ +#define STORAGE_LEVELDB_INCLUDE_OPTIONS_H_ + +#include + +namespace leveldb { + +class Cache; +class Comparator; +class Env; +class FilterPolicy; +class Logger; +class Snapshot; + +// DB contents are stored in a set of blocks, each of which holds a +// sequence of key,value pairs. Each block may be compressed before +// being stored in a file. The following enum describes which +// compression method (if any) is used to compress a block. +enum CompressionType { + // NOTE: do not change the values of existing entries, as these are + // part of the persistent format on disk. + kNoCompression = 0x0, + kSnappyCompression = 0x1 +}; + +// Options to control the behavior of a database (passed to DB::Open) +struct Options { + // ------------------- + // Parameters that affect behavior + + // Comparator used to define the order of keys in the table. + // Default: a comparator that uses lexicographic byte-wise ordering + // + // REQUIRES: The client must ensure that the comparator supplied + // here has the same name and orders keys *exactly* the same as the + // comparator provided to previous open calls on the same DB. + const Comparator* comparator; + + // If true, the database will be created if it is missing. + // Default: false + bool create_if_missing; + + // If true, an error is raised if the database already exists. + // Default: false + bool error_if_exists; + + // If true, the implementation will do aggressive checking of the + // data it is processing and will stop early if it detects any + // errors. This may have unforeseen ramifications: for example, a + // corruption of one DB entry may cause a large number of entries to + // become unreadable or for the entire DB to become unopenable. + // Default: false + bool paranoid_checks; + + // Use the specified object to interact with the environment, + // e.g. to read/write files, schedule background work, etc. + // Default: Env::Default() + Env* env; + + // Any internal progress/error information generated by the db will + // be written to info_log if it is non-NULL, or to a file stored + // in the same directory as the DB contents if info_log is NULL. + // Default: NULL + Logger* info_log; + + // ------------------- + // Parameters that affect performance + + // Amount of data to build up in memory (backed by an unsorted log + // on disk) before converting to a sorted on-disk file. + // + // Larger values increase performance, especially during bulk loads. + // Up to two write buffers may be held in memory at the same time, + // so you may wish to adjust this parameter to control memory usage. + // Also, a larger write buffer will result in a longer recovery time + // the next time the database is opened. + // + // Default: 4MB + size_t write_buffer_size; + + // Number of open files that can be used by the DB. You may need to + // increase this if your database has a large working set (budget + // one open file per 2MB of working set). + // + // Default: 1000 + int max_open_files; + + // Control over blocks (user data is stored in a set of blocks, and + // a block is the unit of reading from disk). + + // If non-NULL, use the specified cache for blocks. + // If NULL, leveldb will automatically create and use an 8MB internal cache. + // Default: NULL + Cache* block_cache; + + // Approximate size of user data packed per block. Note that the + // block size specified here corresponds to uncompressed data. The + // actual size of the unit read from disk may be smaller if + // compression is enabled. This parameter can be changed dynamically. + // + // Default: 4K + size_t block_size; + + // Number of keys between restart points for delta encoding of keys. + // This parameter can be changed dynamically. Most clients should + // leave this parameter alone. + // + // Default: 16 + int block_restart_interval; + + // Compress blocks using the specified compression algorithm. This + // parameter can be changed dynamically. + // + // Default: kSnappyCompression, which gives lightweight but fast + // compression. + // + // Typical speeds of kSnappyCompression on an Intel(R) Core(TM)2 2.4GHz: + // ~200-500MB/s compression + // ~400-800MB/s decompression + // Note that these speeds are significantly faster than most + // persistent storage speeds, and therefore it is typically never + // worth switching to kNoCompression. Even if the input data is + // incompressible, the kSnappyCompression implementation will + // efficiently detect that and will switch to uncompressed mode. + CompressionType compression; + + // If non-NULL, use the specified filter policy to reduce disk reads. + // Many applications will benefit from passing the result of + // NewBloomFilterPolicy() here. + // + // Default: NULL + const FilterPolicy* filter_policy; + + // Create an Options object with default values for all fields. + Options(); +}; + +// Options that control read operations +struct ReadOptions { + // If true, all data read from underlying storage will be + // verified against corresponding checksums. + // Default: false + bool verify_checksums; + + // Should the data read for this iteration be cached in memory? + // Callers may wish to set this field to false for bulk scans. + // Default: true + bool fill_cache; + + // If "snapshot" is non-NULL, read as of the supplied snapshot + // (which must belong to the DB that is being read and which must + // not have been released). If "snapshot" is NULL, use an impliicit + // snapshot of the state at the beginning of this read operation. + // Default: NULL + const Snapshot* snapshot; + + ReadOptions() + : verify_checksums(false), + fill_cache(true), + snapshot(NULL) { + } +}; + +// Options that control write operations +struct WriteOptions { + // If true, the write will be flushed from the operating system + // buffer cache (by calling WritableFile::Sync()) before the write + // is considered complete. If this flag is true, writes will be + // slower. + // + // If this flag is false, and the machine crashes, some recent + // writes may be lost. Note that if it is just the process that + // crashes (i.e., the machine does not reboot), no writes will be + // lost even if sync==false. + // + // In other words, a DB write with sync==false has similar + // crash semantics as the "write()" system call. A DB write + // with sync==true has similar crash semantics to a "write()" + // system call followed by "fsync()". + // + // Default: false + bool sync; + + WriteOptions() + : sync(false) { + } +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_INCLUDE_OPTIONS_H_ diff --git a/src/leveldb/include/leveldb/slice.h b/src/leveldb/include/leveldb/slice.h new file mode 100644 index 0000000..74ea8fa --- /dev/null +++ b/src/leveldb/include/leveldb/slice.h @@ -0,0 +1,109 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// Slice is a simple structure containing a pointer into some external +// storage and a size. The user of a Slice must ensure that the slice +// is not used after the corresponding external storage has been +// deallocated. +// +// Multiple threads can invoke const methods on a Slice without +// external synchronization, but if any of the threads may call a +// non-const method, all threads accessing the same Slice must use +// external synchronization. + +#ifndef STORAGE_LEVELDB_INCLUDE_SLICE_H_ +#define STORAGE_LEVELDB_INCLUDE_SLICE_H_ + +#include +#include +#include +#include + +namespace leveldb { + +class Slice { + public: + // Create an empty slice. + Slice() : data_(""), size_(0) { } + + // Create a slice that refers to d[0,n-1]. + Slice(const char* d, size_t n) : data_(d), size_(n) { } + + // Create a slice that refers to the contents of "s" + Slice(const std::string& s) : data_(s.data()), size_(s.size()) { } + + // Create a slice that refers to s[0,strlen(s)-1] + Slice(const char* s) : data_(s), size_(strlen(s)) { } + + // Return a pointer to the beginning of the referenced data + const char* data() const { return data_; } + + // Return the length (in bytes) of the referenced data + size_t size() const { return size_; } + + // Return true iff the length of the referenced data is zero + bool empty() const { return size_ == 0; } + + // Return the ith byte in the referenced data. + // REQUIRES: n < size() + char operator[](size_t n) const { + assert(n < size()); + return data_[n]; + } + + // Change this slice to refer to an empty array + void clear() { data_ = ""; size_ = 0; } + + // Drop the first "n" bytes from this slice. + void remove_prefix(size_t n) { + assert(n <= size()); + data_ += n; + size_ -= n; + } + + // Return a string that contains the copy of the referenced data. + std::string ToString() const { return std::string(data_, size_); } + + // Three-way comparison. Returns value: + // < 0 iff "*this" < "b", + // == 0 iff "*this" == "b", + // > 0 iff "*this" > "b" + int compare(const Slice& b) const; + + // Return true iff "x" is a prefix of "*this" + bool starts_with(const Slice& x) const { + return ((size_ >= x.size_) && + (memcmp(data_, x.data_, x.size_) == 0)); + } + + private: + const char* data_; + size_t size_; + + // Intentionally copyable +}; + +inline bool operator==(const Slice& x, const Slice& y) { + return ((x.size() == y.size()) && + (memcmp(x.data(), y.data(), x.size()) == 0)); +} + +inline bool operator!=(const Slice& x, const Slice& y) { + return !(x == y); +} + +inline int Slice::compare(const Slice& b) const { + const int min_len = (size_ < b.size_) ? size_ : b.size_; + int r = memcmp(data_, b.data_, min_len); + if (r == 0) { + if (size_ < b.size_) r = -1; + else if (size_ > b.size_) r = +1; + } + return r; +} + +} // namespace leveldb + + +#endif // STORAGE_LEVELDB_INCLUDE_SLICE_H_ diff --git a/src/leveldb/include/leveldb/status.h b/src/leveldb/include/leveldb/status.h new file mode 100644 index 0000000..11dbd4b --- /dev/null +++ b/src/leveldb/include/leveldb/status.h @@ -0,0 +1,106 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// A Status encapsulates the result of an operation. It may indicate success, +// or it may indicate an error with an associated error message. +// +// Multiple threads can invoke const methods on a Status without +// external synchronization, but if any of the threads may call a +// non-const method, all threads accessing the same Status must use +// external synchronization. + +#ifndef STORAGE_LEVELDB_INCLUDE_STATUS_H_ +#define STORAGE_LEVELDB_INCLUDE_STATUS_H_ + +#include +#include "leveldb/slice.h" + +namespace leveldb { + +class Status { + public: + // Create a success status. + Status() : state_(NULL) { } + ~Status() { delete[] state_; } + + // Copy the specified status. + Status(const Status& s); + void operator=(const Status& s); + + // Return a success status. + static Status OK() { return Status(); } + + // Return error status of an appropriate type. + static Status NotFound(const Slice& msg, const Slice& msg2 = Slice()) { + return Status(kNotFound, msg, msg2); + } + static Status Corruption(const Slice& msg, const Slice& msg2 = Slice()) { + return Status(kCorruption, msg, msg2); + } + static Status NotSupported(const Slice& msg, const Slice& msg2 = Slice()) { + return Status(kNotSupported, msg, msg2); + } + static Status InvalidArgument(const Slice& msg, const Slice& msg2 = Slice()) { + return Status(kInvalidArgument, msg, msg2); + } + static Status IOError(const Slice& msg, const Slice& msg2 = Slice()) { + return Status(kIOError, msg, msg2); + } + + // Returns true iff the status indicates success. + bool ok() const { return (state_ == NULL); } + + // Returns true iff the status indicates a NotFound error. + bool IsNotFound() const { return code() == kNotFound; } + + // Returns true iff the status indicates a Corruption error. + bool IsCorruption() const { return code() == kCorruption; } + + // Returns true iff the status indicates an IOError. + bool IsIOError() const { return code() == kIOError; } + + // Return a string representation of this status suitable for printing. + // Returns the string "OK" for success. + std::string ToString() const; + + private: + // OK status has a NULL state_. Otherwise, state_ is a new[] array + // of the following form: + // state_[0..3] == length of message + // state_[4] == code + // state_[5..] == message + const char* state_; + + enum Code { + kOk = 0, + kNotFound = 1, + kCorruption = 2, + kNotSupported = 3, + kInvalidArgument = 4, + kIOError = 5 + }; + + Code code() const { + return (state_ == NULL) ? kOk : static_cast(state_[4]); + } + + Status(Code code, const Slice& msg, const Slice& msg2); + static const char* CopyState(const char* s); +}; + +inline Status::Status(const Status& s) { + state_ = (s.state_ == NULL) ? NULL : CopyState(s.state_); +} +inline void Status::operator=(const Status& s) { + // The following condition catches both aliasing (when this == &s), + // and the common case where both s and *this are ok. + if (state_ != s.state_) { + delete[] state_; + state_ = (s.state_ == NULL) ? NULL : CopyState(s.state_); + } +} + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_INCLUDE_STATUS_H_ diff --git a/src/leveldb/include/leveldb/table.h b/src/leveldb/include/leveldb/table.h new file mode 100644 index 0000000..a9746c3 --- /dev/null +++ b/src/leveldb/include/leveldb/table.h @@ -0,0 +1,85 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_INCLUDE_TABLE_H_ +#define STORAGE_LEVELDB_INCLUDE_TABLE_H_ + +#include +#include "leveldb/iterator.h" + +namespace leveldb { + +class Block; +class BlockHandle; +class Footer; +struct Options; +class RandomAccessFile; +struct ReadOptions; +class TableCache; + +// A Table is a sorted map from strings to strings. Tables are +// immutable and persistent. A Table may be safely accessed from +// multiple threads without external synchronization. +class Table { + public: + // Attempt to open the table that is stored in bytes [0..file_size) + // of "file", and read the metadata entries necessary to allow + // retrieving data from the table. + // + // If successful, returns ok and sets "*table" to the newly opened + // table. The client should delete "*table" when no longer needed. + // If there was an error while initializing the table, sets "*table" + // to NULL and returns a non-ok status. Does not take ownership of + // "*source", but the client must ensure that "source" remains live + // for the duration of the returned table's lifetime. + // + // *file must remain live while this Table is in use. + static Status Open(const Options& options, + RandomAccessFile* file, + uint64_t file_size, + Table** table); + + ~Table(); + + // Returns a new iterator over the table contents. + // The result of NewIterator() is initially invalid (caller must + // call one of the Seek methods on the iterator before using it). + Iterator* NewIterator(const ReadOptions&) const; + + // Given a key, return an approximate byte offset in the file where + // the data for that key begins (or would begin if the key were + // present in the file). The returned value is in terms of file + // bytes, and so includes effects like compression of the underlying data. + // E.g., the approximate offset of the last key in the table will + // be close to the file length. + uint64_t ApproximateOffsetOf(const Slice& key) const; + + private: + struct Rep; + Rep* rep_; + + explicit Table(Rep* rep) { rep_ = rep; } + static Iterator* BlockReader(void*, const ReadOptions&, const Slice&); + + // Calls (*handle_result)(arg, ...) with the entry found after a call + // to Seek(key). May not make such a call if filter policy says + // that key is not present. + friend class TableCache; + Status InternalGet( + const ReadOptions&, const Slice& key, + void* arg, + void (*handle_result)(void* arg, const Slice& k, const Slice& v)); + + + void ReadMeta(const Footer& footer); + void ReadFilter(const Slice& filter_handle_value); + + // No copying allowed + Table(const Table&); + void operator=(const Table&); +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_INCLUDE_TABLE_H_ diff --git a/src/leveldb/include/leveldb/table_builder.h b/src/leveldb/include/leveldb/table_builder.h new file mode 100644 index 0000000..5fd1dc7 --- /dev/null +++ b/src/leveldb/include/leveldb/table_builder.h @@ -0,0 +1,92 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// TableBuilder provides the interface used to build a Table +// (an immutable and sorted map from keys to values). +// +// Multiple threads can invoke const methods on a TableBuilder without +// external synchronization, but if any of the threads may call a +// non-const method, all threads accessing the same TableBuilder must use +// external synchronization. + +#ifndef STORAGE_LEVELDB_INCLUDE_TABLE_BUILDER_H_ +#define STORAGE_LEVELDB_INCLUDE_TABLE_BUILDER_H_ + +#include +#include "leveldb/options.h" +#include "leveldb/status.h" + +namespace leveldb { + +class BlockBuilder; +class BlockHandle; +class WritableFile; + +class TableBuilder { + public: + // Create a builder that will store the contents of the table it is + // building in *file. Does not close the file. It is up to the + // caller to close the file after calling Finish(). + TableBuilder(const Options& options, WritableFile* file); + + // REQUIRES: Either Finish() or Abandon() has been called. + ~TableBuilder(); + + // Change the options used by this builder. Note: only some of the + // option fields can be changed after construction. If a field is + // not allowed to change dynamically and its value in the structure + // passed to the constructor is different from its value in the + // structure passed to this method, this method will return an error + // without changing any fields. + Status ChangeOptions(const Options& options); + + // Add key,value to the table being constructed. + // REQUIRES: key is after any previously added key according to comparator. + // REQUIRES: Finish(), Abandon() have not been called + void Add(const Slice& key, const Slice& value); + + // Advanced operation: flush any buffered key/value pairs to file. + // Can be used to ensure that two adjacent entries never live in + // the same data block. Most clients should not need to use this method. + // REQUIRES: Finish(), Abandon() have not been called + void Flush(); + + // Return non-ok iff some error has been detected. + Status status() const; + + // Finish building the table. Stops using the file passed to the + // constructor after this function returns. + // REQUIRES: Finish(), Abandon() have not been called + Status Finish(); + + // Indicate that the contents of this builder should be abandoned. Stops + // using the file passed to the constructor after this function returns. + // If the caller is not going to call Finish(), it must call Abandon() + // before destroying this builder. + // REQUIRES: Finish(), Abandon() have not been called + void Abandon(); + + // Number of calls to Add() so far. + uint64_t NumEntries() const; + + // Size of the file generated so far. If invoked after a successful + // Finish() call, returns the size of the final generated file. + uint64_t FileSize() const; + + private: + bool ok() const { return status().ok(); } + void WriteBlock(BlockBuilder* block, BlockHandle* handle); + void WriteRawBlock(const Slice& data, CompressionType, BlockHandle* handle); + + struct Rep; + Rep* rep_; + + // No copying allowed + TableBuilder(const TableBuilder&); + void operator=(const TableBuilder&); +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_INCLUDE_TABLE_BUILDER_H_ diff --git a/src/leveldb/include/leveldb/write_batch.h b/src/leveldb/include/leveldb/write_batch.h new file mode 100644 index 0000000..ee9aab6 --- /dev/null +++ b/src/leveldb/include/leveldb/write_batch.h @@ -0,0 +1,64 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// WriteBatch holds a collection of updates to apply atomically to a DB. +// +// The updates are applied in the order in which they are added +// to the WriteBatch. For example, the value of "key" will be "v3" +// after the following batch is written: +// +// batch.Put("key", "v1"); +// batch.Delete("key"); +// batch.Put("key", "v2"); +// batch.Put("key", "v3"); +// +// Multiple threads can invoke const methods on a WriteBatch without +// external synchronization, but if any of the threads may call a +// non-const method, all threads accessing the same WriteBatch must use +// external synchronization. + +#ifndef STORAGE_LEVELDB_INCLUDE_WRITE_BATCH_H_ +#define STORAGE_LEVELDB_INCLUDE_WRITE_BATCH_H_ + +#include +#include "leveldb/status.h" + +namespace leveldb { + +class Slice; + +class WriteBatch { + public: + WriteBatch(); + ~WriteBatch(); + + // Store the mapping "key->value" in the database. + void Put(const Slice& key, const Slice& value); + + // If the database contains a mapping for "key", erase it. Else do nothing. + void Delete(const Slice& key); + + // Clear all updates buffered in this batch. + void Clear(); + + // Support for iterating over the contents of a batch. + class Handler { + public: + virtual ~Handler(); + virtual void Put(const Slice& key, const Slice& value) = 0; + virtual void Delete(const Slice& key) = 0; + }; + Status Iterate(Handler* handler) const; + + private: + friend class WriteBatchInternal; + + std::string rep_; // See comment in write_batch.cc for the format of rep_ + + // Intentionally copyable +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_INCLUDE_WRITE_BATCH_H_ diff --git a/src/leveldb/issues/issue178_test.cc b/src/leveldb/issues/issue178_test.cc new file mode 100644 index 0000000..1b1cf8b --- /dev/null +++ b/src/leveldb/issues/issue178_test.cc @@ -0,0 +1,92 @@ +// Copyright (c) 2013 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +// Test for issue 178: a manual compaction causes deleted data to reappear. +#include +#include +#include + +#include "leveldb/db.h" +#include "leveldb/write_batch.h" +#include "util/testharness.h" + +namespace { + +const int kNumKeys = 1100000; + +std::string Key1(int i) { + char buf[100]; + snprintf(buf, sizeof(buf), "my_key_%d", i); + return buf; +} + +std::string Key2(int i) { + return Key1(i) + "_xxx"; +} + +class Issue178 { }; + +TEST(Issue178, Test) { + // Get rid of any state from an old run. + std::string dbpath = leveldb::test::TmpDir() + "/leveldb_cbug_test"; + DestroyDB(dbpath, leveldb::Options()); + + // Open database. Disable compression since it affects the creation + // of layers and the code below is trying to test against a very + // specific scenario. + leveldb::DB* db; + leveldb::Options db_options; + db_options.create_if_missing = true; + db_options.compression = leveldb::kNoCompression; + ASSERT_OK(leveldb::DB::Open(db_options, dbpath, &db)); + + // create first key range + leveldb::WriteBatch batch; + for (size_t i = 0; i < kNumKeys; i++) { + batch.Put(Key1(i), "value for range 1 key"); + } + ASSERT_OK(db->Write(leveldb::WriteOptions(), &batch)); + + // create second key range + batch.Clear(); + for (size_t i = 0; i < kNumKeys; i++) { + batch.Put(Key2(i), "value for range 2 key"); + } + ASSERT_OK(db->Write(leveldb::WriteOptions(), &batch)); + + // delete second key range + batch.Clear(); + for (size_t i = 0; i < kNumKeys; i++) { + batch.Delete(Key2(i)); + } + ASSERT_OK(db->Write(leveldb::WriteOptions(), &batch)); + + // compact database + std::string start_key = Key1(0); + std::string end_key = Key1(kNumKeys - 1); + leveldb::Slice least(start_key.data(), start_key.size()); + leveldb::Slice greatest(end_key.data(), end_key.size()); + + // commenting out the line below causes the example to work correctly + db->CompactRange(&least, &greatest); + + // count the keys + leveldb::Iterator* iter = db->NewIterator(leveldb::ReadOptions()); + size_t num_keys = 0; + for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { + num_keys++; + } + delete iter; + ASSERT_EQ(kNumKeys, num_keys) << "Bad number of keys"; + + // close database + delete db; + DestroyDB(dbpath, leveldb::Options()); +} + +} // anonymous namespace + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/issues/issue200_test.cc b/src/leveldb/issues/issue200_test.cc new file mode 100644 index 0000000..1cec79f --- /dev/null +++ b/src/leveldb/issues/issue200_test.cc @@ -0,0 +1,59 @@ +// Copyright (c) 2013 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +// Test for issue 200: when iterator switches direction from backward +// to forward, the current key can be yielded unexpectedly if a new +// mutation has been added just before the current key. + +#include "leveldb/db.h" +#include "util/testharness.h" + +namespace leveldb { + +class Issue200 { }; + +TEST(Issue200, Test) { + // Get rid of any state from an old run. + std::string dbpath = test::TmpDir() + "/leveldb_issue200_test"; + DestroyDB(dbpath, Options()); + + DB *db; + Options options; + options.create_if_missing = true; + ASSERT_OK(DB::Open(options, dbpath, &db)); + + WriteOptions write_options; + ASSERT_OK(db->Put(write_options, "1", "b")); + ASSERT_OK(db->Put(write_options, "2", "c")); + ASSERT_OK(db->Put(write_options, "3", "d")); + ASSERT_OK(db->Put(write_options, "4", "e")); + ASSERT_OK(db->Put(write_options, "5", "f")); + + ReadOptions read_options; + Iterator *iter = db->NewIterator(read_options); + + // Add an element that should not be reflected in the iterator. + ASSERT_OK(db->Put(write_options, "25", "cd")); + + iter->Seek("5"); + ASSERT_EQ(iter->key().ToString(), "5"); + iter->Prev(); + ASSERT_EQ(iter->key().ToString(), "4"); + iter->Prev(); + ASSERT_EQ(iter->key().ToString(), "3"); + iter->Next(); + ASSERT_EQ(iter->key().ToString(), "4"); + iter->Next(); + ASSERT_EQ(iter->key().ToString(), "5"); + + delete iter; + delete db; + DestroyDB(dbpath, options); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/port/README b/src/leveldb/port/README new file mode 100644 index 0000000..422563e --- /dev/null +++ b/src/leveldb/port/README @@ -0,0 +1,10 @@ +This directory contains interfaces and implementations that isolate the +rest of the package from platform details. + +Code in the rest of the package includes "port.h" from this directory. +"port.h" in turn includes a platform specific "port_.h" file +that provides the platform specific implementation. + +See port_posix.h for an example of what must be provided in a platform +specific header file. + diff --git a/src/leveldb/port/atomic_pointer.h b/src/leveldb/port/atomic_pointer.h new file mode 100644 index 0000000..a9866b2 --- /dev/null +++ b/src/leveldb/port/atomic_pointer.h @@ -0,0 +1,224 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +// AtomicPointer provides storage for a lock-free pointer. +// Platform-dependent implementation of AtomicPointer: +// - If the platform provides a cheap barrier, we use it with raw pointers +// - If cstdatomic is present (on newer versions of gcc, it is), we use +// a cstdatomic-based AtomicPointer. However we prefer the memory +// barrier based version, because at least on a gcc 4.4 32-bit build +// on linux, we have encountered a buggy +// implementation. Also, some implementations are much +// slower than a memory-barrier based implementation (~16ns for +// based acquire-load vs. ~1ns for a barrier based +// acquire-load). +// This code is based on atomicops-internals-* in Google's perftools: +// http://code.google.com/p/google-perftools/source/browse/#svn%2Ftrunk%2Fsrc%2Fbase + +#ifndef PORT_ATOMIC_POINTER_H_ +#define PORT_ATOMIC_POINTER_H_ + +#include +#ifdef LEVELDB_CSTDATOMIC_PRESENT +#include +#endif +#ifdef OS_WIN +#include +#endif +#ifdef OS_MACOSX +#include +#endif + +#if defined(_M_X64) || defined(__x86_64__) +#define ARCH_CPU_X86_FAMILY 1 +#elif defined(_M_IX86) || defined(__i386__) || defined(__i386) +#define ARCH_CPU_X86_FAMILY 1 +#elif defined(__ARMEL__) +#define ARCH_CPU_ARM_FAMILY 1 +#elif defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__) +#define ARCH_CPU_PPC_FAMILY 1 +#endif + +namespace leveldb { +namespace port { + +// Define MemoryBarrier() if available +// Windows on x86 +#if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY) +// windows.h already provides a MemoryBarrier(void) macro +// http://msdn.microsoft.com/en-us/library/ms684208(v=vs.85).aspx +#define LEVELDB_HAVE_MEMORY_BARRIER + +// Mac OS +#elif defined(OS_MACOSX) +inline void MemoryBarrier() { + OSMemoryBarrier(); +} +#define LEVELDB_HAVE_MEMORY_BARRIER + +// Gcc on x86 +#elif defined(ARCH_CPU_X86_FAMILY) && defined(__GNUC__) +inline void MemoryBarrier() { + // See http://gcc.gnu.org/ml/gcc/2003-04/msg01180.html for a discussion on + // this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering. + __asm__ __volatile__("" : : : "memory"); +} +#define LEVELDB_HAVE_MEMORY_BARRIER + +// Sun Studio +#elif defined(ARCH_CPU_X86_FAMILY) && defined(__SUNPRO_CC) +inline void MemoryBarrier() { + // See http://gcc.gnu.org/ml/gcc/2003-04/msg01180.html for a discussion on + // this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering. + asm volatile("" : : : "memory"); +} +#define LEVELDB_HAVE_MEMORY_BARRIER + +// ARM Linux +#elif defined(ARCH_CPU_ARM_FAMILY) && defined(__linux__) +typedef void (*LinuxKernelMemoryBarrierFunc)(void); +// The Linux ARM kernel provides a highly optimized device-specific memory +// barrier function at a fixed memory address that is mapped in every +// user-level process. +// +// This beats using CPU-specific instructions which are, on single-core +// devices, un-necessary and very costly (e.g. ARMv7-A "dmb" takes more +// than 180ns on a Cortex-A8 like the one on a Nexus One). Benchmarking +// shows that the extra function call cost is completely negligible on +// multi-core devices. +// +inline void MemoryBarrier() { + (*(LinuxKernelMemoryBarrierFunc)0xffff0fa0)(); +} +#define LEVELDB_HAVE_MEMORY_BARRIER + +// PPC +#elif defined(ARCH_CPU_PPC_FAMILY) && defined(__GNUC__) +inline void MemoryBarrier() { + // TODO for some powerpc expert: is there a cheaper suitable variant? + // Perhaps by having separate barriers for acquire and release ops. + asm volatile("sync" : : : "memory"); +} +#define LEVELDB_HAVE_MEMORY_BARRIER + +#endif + +// AtomicPointer built using platform-specific MemoryBarrier() +#if defined(LEVELDB_HAVE_MEMORY_BARRIER) +class AtomicPointer { + private: + void* rep_; + public: + AtomicPointer() { } + explicit AtomicPointer(void* p) : rep_(p) {} + inline void* NoBarrier_Load() const { return rep_; } + inline void NoBarrier_Store(void* v) { rep_ = v; } + inline void* Acquire_Load() const { + void* result = rep_; + MemoryBarrier(); + return result; + } + inline void Release_Store(void* v) { + MemoryBarrier(); + rep_ = v; + } +}; + +// AtomicPointer based on +#elif defined(LEVELDB_CSTDATOMIC_PRESENT) +class AtomicPointer { + private: + std::atomic rep_; + public: + AtomicPointer() { } + explicit AtomicPointer(void* v) : rep_(v) { } + inline void* Acquire_Load() const { + return rep_.load(std::memory_order_acquire); + } + inline void Release_Store(void* v) { + rep_.store(v, std::memory_order_release); + } + inline void* NoBarrier_Load() const { + return rep_.load(std::memory_order_relaxed); + } + inline void NoBarrier_Store(void* v) { + rep_.store(v, std::memory_order_relaxed); + } +}; + +// Atomic pointer based on sparc memory barriers +#elif defined(__sparcv9) && defined(__GNUC__) +class AtomicPointer { + private: + void* rep_; + public: + AtomicPointer() { } + explicit AtomicPointer(void* v) : rep_(v) { } + inline void* Acquire_Load() const { + void* val; + __asm__ __volatile__ ( + "ldx [%[rep_]], %[val] \n\t" + "membar #LoadLoad|#LoadStore \n\t" + : [val] "=r" (val) + : [rep_] "r" (&rep_) + : "memory"); + return val; + } + inline void Release_Store(void* v) { + __asm__ __volatile__ ( + "membar #LoadStore|#StoreStore \n\t" + "stx %[v], [%[rep_]] \n\t" + : + : [rep_] "r" (&rep_), [v] "r" (v) + : "memory"); + } + inline void* NoBarrier_Load() const { return rep_; } + inline void NoBarrier_Store(void* v) { rep_ = v; } +}; + +// Atomic pointer based on ia64 acq/rel +#elif defined(__ia64) && defined(__GNUC__) +class AtomicPointer { + private: + void* rep_; + public: + AtomicPointer() { } + explicit AtomicPointer(void* v) : rep_(v) { } + inline void* Acquire_Load() const { + void* val ; + __asm__ __volatile__ ( + "ld8.acq %[val] = [%[rep_]] \n\t" + : [val] "=r" (val) + : [rep_] "r" (&rep_) + : "memory" + ); + return val; + } + inline void Release_Store(void* v) { + __asm__ __volatile__ ( + "st8.rel [%[rep_]] = %[v] \n\t" + : + : [rep_] "r" (&rep_), [v] "r" (v) + : "memory" + ); + } + inline void* NoBarrier_Load() const { return rep_; } + inline void NoBarrier_Store(void* v) { rep_ = v; } +}; + +// We have neither MemoryBarrier(), nor +#else +#error Please implement AtomicPointer for this platform. + +#endif + +#undef LEVELDB_HAVE_MEMORY_BARRIER +#undef ARCH_CPU_X86_FAMILY +#undef ARCH_CPU_ARM_FAMILY +#undef ARCH_CPU_PPC_FAMILY + +} // namespace port +} // namespace leveldb + +#endif // PORT_ATOMIC_POINTER_H_ diff --git a/src/leveldb/port/port.h b/src/leveldb/port/port.h new file mode 100644 index 0000000..4baafa8 --- /dev/null +++ b/src/leveldb/port/port.h @@ -0,0 +1,21 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_PORT_PORT_H_ +#define STORAGE_LEVELDB_PORT_PORT_H_ + +#include + +// Include the appropriate platform specific file below. If you are +// porting to a new platform, see "port_example.h" for documentation +// of what the new port_.h file must provide. +#if defined(LEVELDB_PLATFORM_POSIX) +# include "port/port_posix.h" +#elif defined(LEVELDB_PLATFORM_CHROMIUM) +# include "port/port_chromium.h" +#elif defined(LEVELDB_PLATFORM_WINDOWS) +# include "port/port_win.h" +#endif + +#endif // STORAGE_LEVELDB_PORT_PORT_H_ diff --git a/src/leveldb/port/port_example.h b/src/leveldb/port/port_example.h new file mode 100644 index 0000000..ab9e489 --- /dev/null +++ b/src/leveldb/port/port_example.h @@ -0,0 +1,135 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// This file contains the specification, but not the implementations, +// of the types/operations/etc. that should be defined by a platform +// specific port_.h file. Use this file as a reference for +// how to port this package to a new platform. + +#ifndef STORAGE_LEVELDB_PORT_PORT_EXAMPLE_H_ +#define STORAGE_LEVELDB_PORT_PORT_EXAMPLE_H_ + +namespace leveldb { +namespace port { + +// TODO(jorlow): Many of these belong more in the environment class rather than +// here. We should try moving them and see if it affects perf. + +// The following boolean constant must be true on a little-endian machine +// and false otherwise. +static const bool kLittleEndian = true /* or some other expression */; + +// ------------------ Threading ------------------- + +// A Mutex represents an exclusive lock. +class Mutex { + public: + Mutex(); + ~Mutex(); + + // Lock the mutex. Waits until other lockers have exited. + // Will deadlock if the mutex is already locked by this thread. + void Lock(); + + // Unlock the mutex. + // REQUIRES: This mutex was locked by this thread. + void Unlock(); + + // Optionally crash if this thread does not hold this mutex. + // The implementation must be fast, especially if NDEBUG is + // defined. The implementation is allowed to skip all checks. + void AssertHeld(); +}; + +class CondVar { + public: + explicit CondVar(Mutex* mu); + ~CondVar(); + + // Atomically release *mu and block on this condition variable until + // either a call to SignalAll(), or a call to Signal() that picks + // this thread to wakeup. + // REQUIRES: this thread holds *mu + void Wait(); + + // If there are some threads waiting, wake up at least one of them. + void Signal(); + + // Wake up all waiting threads. + void SignallAll(); +}; + +// Thread-safe initialization. +// Used as follows: +// static port::OnceType init_control = LEVELDB_ONCE_INIT; +// static void Initializer() { ... do something ...; } +// ... +// port::InitOnce(&init_control, &Initializer); +typedef intptr_t OnceType; +#define LEVELDB_ONCE_INIT 0 +extern void InitOnce(port::OnceType*, void (*initializer)()); + +// A type that holds a pointer that can be read or written atomically +// (i.e., without word-tearing.) +class AtomicPointer { + private: + intptr_t rep_; + public: + // Initialize to arbitrary value + AtomicPointer(); + + // Initialize to hold v + explicit AtomicPointer(void* v) : rep_(v) { } + + // Read and return the stored pointer with the guarantee that no + // later memory access (read or write) by this thread can be + // reordered ahead of this read. + void* Acquire_Load() const; + + // Set v as the stored pointer with the guarantee that no earlier + // memory access (read or write) by this thread can be reordered + // after this store. + void Release_Store(void* v); + + // Read the stored pointer with no ordering guarantees. + void* NoBarrier_Load() const; + + // Set va as the stored pointer with no ordering guarantees. + void NoBarrier_Store(void* v); +}; + +// ------------------ Compression ------------------- + +// Store the snappy compression of "input[0,input_length-1]" in *output. +// Returns false if snappy is not supported by this port. +extern bool Snappy_Compress(const char* input, size_t input_length, + std::string* output); + +// If input[0,input_length-1] looks like a valid snappy compressed +// buffer, store the size of the uncompressed data in *result and +// return true. Else return false. +extern bool Snappy_GetUncompressedLength(const char* input, size_t length, + size_t* result); + +// Attempt to snappy uncompress input[0,input_length-1] into *output. +// Returns true if successful, false if the input is invalid lightweight +// compressed data. +// +// REQUIRES: at least the first "n" bytes of output[] must be writable +// where "n" is the result of a successful call to +// Snappy_GetUncompressedLength. +extern bool Snappy_Uncompress(const char* input_data, size_t input_length, + char* output); + +// ------------------ Miscellaneous ------------------- + +// If heap profiling is not supported, returns false. +// Else repeatedly calls (*func)(arg, data, n) and then returns true. +// The concatenation of all "data[0,n-1]" fragments is the heap profile. +extern bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg); + +} // namespace port +} // namespace leveldb + +#endif // STORAGE_LEVELDB_PORT_PORT_EXAMPLE_H_ diff --git a/src/leveldb/port/port_posix.cc b/src/leveldb/port/port_posix.cc new file mode 100644 index 0000000..5ba127a --- /dev/null +++ b/src/leveldb/port/port_posix.cc @@ -0,0 +1,54 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "port/port_posix.h" + +#include +#include +#include +#include "util/logging.h" + +namespace leveldb { +namespace port { + +static void PthreadCall(const char* label, int result) { + if (result != 0) { + fprintf(stderr, "pthread %s: %s\n", label, strerror(result)); + abort(); + } +} + +Mutex::Mutex() { PthreadCall("init mutex", pthread_mutex_init(&mu_, NULL)); } + +Mutex::~Mutex() { PthreadCall("destroy mutex", pthread_mutex_destroy(&mu_)); } + +void Mutex::Lock() { PthreadCall("lock", pthread_mutex_lock(&mu_)); } + +void Mutex::Unlock() { PthreadCall("unlock", pthread_mutex_unlock(&mu_)); } + +CondVar::CondVar(Mutex* mu) + : mu_(mu) { + PthreadCall("init cv", pthread_cond_init(&cv_, NULL)); +} + +CondVar::~CondVar() { PthreadCall("destroy cv", pthread_cond_destroy(&cv_)); } + +void CondVar::Wait() { + PthreadCall("wait", pthread_cond_wait(&cv_, &mu_->mu_)); +} + +void CondVar::Signal() { + PthreadCall("signal", pthread_cond_signal(&cv_)); +} + +void CondVar::SignalAll() { + PthreadCall("broadcast", pthread_cond_broadcast(&cv_)); +} + +void InitOnce(OnceType* once, void (*initializer)()) { + PthreadCall("once", pthread_once(once, initializer)); +} + +} // namespace port +} // namespace leveldb diff --git a/src/leveldb/port/port_posix.h b/src/leveldb/port/port_posix.h new file mode 100644 index 0000000..21c845e --- /dev/null +++ b/src/leveldb/port/port_posix.h @@ -0,0 +1,161 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// See port_example.h for documentation for the following types/functions. + +#ifndef STORAGE_LEVELDB_PORT_PORT_POSIX_H_ +#define STORAGE_LEVELDB_PORT_PORT_POSIX_H_ + +#undef PLATFORM_IS_LITTLE_ENDIAN +#if defined(OS_MACOSX) + #include + #if defined(__DARWIN_LITTLE_ENDIAN) && defined(__DARWIN_BYTE_ORDER) + #define PLATFORM_IS_LITTLE_ENDIAN \ + (__DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN) + #endif +#elif defined(OS_SOLARIS) + #include + #ifdef _LITTLE_ENDIAN + #define PLATFORM_IS_LITTLE_ENDIAN true + #else + #define PLATFORM_IS_LITTLE_ENDIAN false + #endif +#elif defined(OS_FREEBSD) + #include + #include + #define PLATFORM_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN) +#elif defined(OS_OPENBSD) || defined(OS_NETBSD) ||\ + defined(OS_DRAGONFLYBSD) + #include + #include +#elif defined(OS_HPUX) + #define PLATFORM_IS_LITTLE_ENDIAN false +#elif defined(OS_ANDROID) + // Due to a bug in the NDK x86 definition, + // _BYTE_ORDER must be used instead of __BYTE_ORDER on Android. + // See http://code.google.com/p/android/issues/detail?id=39824 + #include + #define PLATFORM_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN) +#else + #include +#endif + +#include +#ifdef SNAPPY +#include +#endif +#include +#include +#include "port/atomic_pointer.h" + +#ifndef PLATFORM_IS_LITTLE_ENDIAN +#define PLATFORM_IS_LITTLE_ENDIAN (__BYTE_ORDER == __LITTLE_ENDIAN) +#endif + +#if defined(OS_MACOSX) || defined(OS_SOLARIS) || defined(OS_FREEBSD) ||\ + defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD) ||\ + defined(OS_ANDROID) || defined(OS_HPUX) +// Use fread/fwrite/fflush on platforms without _unlocked variants +#define fread_unlocked fread +#define fwrite_unlocked fwrite +#define fflush_unlocked fflush +#endif + +#if defined(OS_FREEBSD) ||\ + defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD) +// Use fsync() on platforms without fdatasync() +#define fdatasync fsync +#endif + +#if defined(OS_MACOSX) +#define fdatasync(fd) fcntl(fd, F_FULLFSYNC, 0) +#endif + +#if defined(OS_ANDROID) && __ANDROID_API__ < 9 +// fdatasync() was only introduced in API level 9 on Android. Use fsync() +// when targetting older platforms. +#define fdatasync fsync +#endif + +namespace leveldb { +namespace port { + +static const bool kLittleEndian = PLATFORM_IS_LITTLE_ENDIAN; +#undef PLATFORM_IS_LITTLE_ENDIAN + +class CondVar; + +class Mutex { + public: + Mutex(); + ~Mutex(); + + void Lock(); + void Unlock(); + void AssertHeld() { } + + private: + friend class CondVar; + pthread_mutex_t mu_; + + // No copying + Mutex(const Mutex&); + void operator=(const Mutex&); +}; + +class CondVar { + public: + explicit CondVar(Mutex* mu); + ~CondVar(); + void Wait(); + void Signal(); + void SignalAll(); + private: + pthread_cond_t cv_; + Mutex* mu_; +}; + +typedef pthread_once_t OnceType; +#define LEVELDB_ONCE_INIT PTHREAD_ONCE_INIT +extern void InitOnce(OnceType* once, void (*initializer)()); + +inline bool Snappy_Compress(const char* input, size_t length, + ::std::string* output) { +#ifdef SNAPPY + output->resize(snappy::MaxCompressedLength(length)); + size_t outlen; + snappy::RawCompress(input, length, &(*output)[0], &outlen); + output->resize(outlen); + return true; +#endif + + return false; +} + +inline bool Snappy_GetUncompressedLength(const char* input, size_t length, + size_t* result) { +#ifdef SNAPPY + return snappy::GetUncompressedLength(input, length, result); +#else + return false; +#endif +} + +inline bool Snappy_Uncompress(const char* input, size_t length, + char* output) { +#ifdef SNAPPY + return snappy::RawUncompress(input, length, output); +#else + return false; +#endif +} + +inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { + return false; +} + +} // namespace port +} // namespace leveldb + +#endif // STORAGE_LEVELDB_PORT_PORT_POSIX_H_ diff --git a/src/leveldb/port/port_win.cc b/src/leveldb/port/port_win.cc new file mode 100644 index 0000000..1b0f060 --- /dev/null +++ b/src/leveldb/port/port_win.cc @@ -0,0 +1,147 @@ +// LevelDB Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// See port_example.h for documentation for the following types/functions. + +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the University of California, Berkeley nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#include "port/port_win.h" + +#include +#include + +namespace leveldb { +namespace port { + +Mutex::Mutex() : + cs_(NULL) { + assert(!cs_); + cs_ = static_cast(new CRITICAL_SECTION()); + ::InitializeCriticalSection(static_cast(cs_)); + assert(cs_); +} + +Mutex::~Mutex() { + assert(cs_); + ::DeleteCriticalSection(static_cast(cs_)); + delete static_cast(cs_); + cs_ = NULL; + assert(!cs_); +} + +void Mutex::Lock() { + assert(cs_); + ::EnterCriticalSection(static_cast(cs_)); +} + +void Mutex::Unlock() { + assert(cs_); + ::LeaveCriticalSection(static_cast(cs_)); +} + +void Mutex::AssertHeld() { + assert(cs_); + assert(1); +} + +CondVar::CondVar(Mutex* mu) : + waiting_(0), + mu_(mu), + sem1_(::CreateSemaphore(NULL, 0, 10000, NULL)), + sem2_(::CreateSemaphore(NULL, 0, 10000, NULL)) { + assert(mu_); +} + +CondVar::~CondVar() { + ::CloseHandle(sem1_); + ::CloseHandle(sem2_); +} + +void CondVar::Wait() { + mu_->AssertHeld(); + + wait_mtx_.Lock(); + ++waiting_; + wait_mtx_.Unlock(); + + mu_->Unlock(); + + // initiate handshake + ::WaitForSingleObject(sem1_, INFINITE); + ::ReleaseSemaphore(sem2_, 1, NULL); + mu_->Lock(); +} + +void CondVar::Signal() { + wait_mtx_.Lock(); + if (waiting_ > 0) { + --waiting_; + + // finalize handshake + ::ReleaseSemaphore(sem1_, 1, NULL); + ::WaitForSingleObject(sem2_, INFINITE); + } + wait_mtx_.Unlock(); +} + +void CondVar::SignalAll() { + wait_mtx_.Lock(); + ::ReleaseSemaphore(sem1_, waiting_, NULL); + while(waiting_ > 0) { + --waiting_; + ::WaitForSingleObject(sem2_, INFINITE); + } + wait_mtx_.Unlock(); +} + +AtomicPointer::AtomicPointer(void* v) { + Release_Store(v); +} + +void InitOnce(OnceType* once, void (*initializer)()) { + once->InitOnce(initializer); +} + +void* AtomicPointer::Acquire_Load() const { + void * p = NULL; + InterlockedExchangePointer(&p, rep_); + return p; +} + +void AtomicPointer::Release_Store(void* v) { + InterlockedExchangePointer(&rep_, v); +} + +void* AtomicPointer::NoBarrier_Load() const { + return rep_; +} + +void AtomicPointer::NoBarrier_Store(void* v) { + rep_ = v; +} + +} +} diff --git a/src/leveldb/port/port_win.h b/src/leveldb/port/port_win.h new file mode 100644 index 0000000..45bf2f0 --- /dev/null +++ b/src/leveldb/port/port_win.h @@ -0,0 +1,174 @@ +// LevelDB Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// See port_example.h for documentation for the following types/functions. + +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the University of California, Berkeley nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef STORAGE_LEVELDB_PORT_PORT_WIN_H_ +#define STORAGE_LEVELDB_PORT_PORT_WIN_H_ + +#ifdef _MSC_VER +#define snprintf _snprintf +#define close _close +#define fread_unlocked _fread_nolock +#endif + +#include +#include +#ifdef SNAPPY +#include +#endif + +namespace leveldb { +namespace port { + +// Windows is little endian (for now :p) +static const bool kLittleEndian = true; + +class CondVar; + +class Mutex { + public: + Mutex(); + ~Mutex(); + + void Lock(); + void Unlock(); + void AssertHeld(); + + private: + friend class CondVar; + // critical sections are more efficient than mutexes + // but they are not recursive and can only be used to synchronize threads within the same process + // we use opaque void * to avoid including windows.h in port_win.h + void * cs_; + + // No copying + Mutex(const Mutex&); + void operator=(const Mutex&); +}; + +// the Win32 API offers a dependable condition variable mechanism, but only starting with +// Windows 2008 and Vista +// no matter what we will implement our own condition variable with a semaphore +// implementation as described in a paper written by Andrew D. Birrell in 2003 +class CondVar { + public: + explicit CondVar(Mutex* mu); + ~CondVar(); + void Wait(); + void Signal(); + void SignalAll(); + private: + Mutex* mu_; + + Mutex wait_mtx_; + long waiting_; + + void * sem1_; + void * sem2_; + + +}; + +class OnceType { +public: +// OnceType() : init_(false) {} + OnceType(const OnceType &once) : init_(once.init_) {} + OnceType(bool f) : init_(f) {} + void InitOnce(void (*initializer)()) { + mutex_.Lock(); + if (!init_) { + init_ = true; + initializer(); + } + mutex_.Unlock(); + } + +private: + bool init_; + Mutex mutex_; +}; + +#define LEVELDB_ONCE_INIT false +extern void InitOnce(port::OnceType*, void (*initializer)()); + +// Storage for a lock-free pointer +class AtomicPointer { + private: + void * rep_; + public: + AtomicPointer() : rep_(NULL) { } + explicit AtomicPointer(void* v); + void* Acquire_Load() const; + + void Release_Store(void* v); + + void* NoBarrier_Load() const; + + void NoBarrier_Store(void* v); +}; + +inline bool Snappy_Compress(const char* input, size_t length, + ::std::string* output) { +#ifdef SNAPPY + output->resize(snappy::MaxCompressedLength(length)); + size_t outlen; + snappy::RawCompress(input, length, &(*output)[0], &outlen); + output->resize(outlen); + return true; +#endif + + return false; +} + +inline bool Snappy_GetUncompressedLength(const char* input, size_t length, + size_t* result) { +#ifdef SNAPPY + return snappy::GetUncompressedLength(input, length, result); +#else + return false; +#endif +} + +inline bool Snappy_Uncompress(const char* input, size_t length, + char* output) { +#ifdef SNAPPY + return snappy::RawUncompress(input, length, output); +#else + return false; +#endif +} + +inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { + return false; +} + +} +} + +#endif // STORAGE_LEVELDB_PORT_PORT_WIN_H_ diff --git a/src/leveldb/port/thread_annotations.h b/src/leveldb/port/thread_annotations.h new file mode 100644 index 0000000..6f9b6a7 --- /dev/null +++ b/src/leveldb/port/thread_annotations.h @@ -0,0 +1,59 @@ +// Copyright (c) 2012 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H + +// Some environments provide custom macros to aid in static thread-safety +// analysis. Provide empty definitions of such macros unless they are already +// defined. + +#ifndef EXCLUSIVE_LOCKS_REQUIRED +#define EXCLUSIVE_LOCKS_REQUIRED(...) +#endif + +#ifndef SHARED_LOCKS_REQUIRED +#define SHARED_LOCKS_REQUIRED(...) +#endif + +#ifndef LOCKS_EXCLUDED +#define LOCKS_EXCLUDED(...) +#endif + +#ifndef LOCK_RETURNED +#define LOCK_RETURNED(x) +#endif + +#ifndef LOCKABLE +#define LOCKABLE +#endif + +#ifndef SCOPED_LOCKABLE +#define SCOPED_LOCKABLE +#endif + +#ifndef EXCLUSIVE_LOCK_FUNCTION +#define EXCLUSIVE_LOCK_FUNCTION(...) +#endif + +#ifndef SHARED_LOCK_FUNCTION +#define SHARED_LOCK_FUNCTION(...) +#endif + +#ifndef EXCLUSIVE_TRYLOCK_FUNCTION +#define EXCLUSIVE_TRYLOCK_FUNCTION(...) +#endif + +#ifndef SHARED_TRYLOCK_FUNCTION +#define SHARED_TRYLOCK_FUNCTION(...) +#endif + +#ifndef UNLOCK_FUNCTION +#define UNLOCK_FUNCTION(...) +#endif + +#ifndef NO_THREAD_SAFETY_ANALYSIS +#define NO_THREAD_SAFETY_ANALYSIS +#endif + +#endif // STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H diff --git a/src/leveldb/port/win/stdint.h b/src/leveldb/port/win/stdint.h new file mode 100644 index 0000000..39edd0d --- /dev/null +++ b/src/leveldb/port/win/stdint.h @@ -0,0 +1,24 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +// MSVC didn't ship with this file until the 2010 version. + +#ifndef STORAGE_LEVELDB_PORT_WIN_STDINT_H_ +#define STORAGE_LEVELDB_PORT_WIN_STDINT_H_ + +#if !defined(_MSC_VER) +#error This file should only be included when compiling with MSVC. +#endif + +// Define C99 equivalent types. +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef signed long long int64_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +#endif // STORAGE_LEVELDB_PORT_WIN_STDINT_H_ diff --git a/src/leveldb/table/block.cc b/src/leveldb/table/block.cc new file mode 100644 index 0000000..79ea9d9 --- /dev/null +++ b/src/leveldb/table/block.cc @@ -0,0 +1,268 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// Decodes the blocks generated by block_builder.cc. + +#include "table/block.h" + +#include +#include +#include "leveldb/comparator.h" +#include "table/format.h" +#include "util/coding.h" +#include "util/logging.h" + +namespace leveldb { + +inline uint32_t Block::NumRestarts() const { + assert(size_ >= sizeof(uint32_t)); + return DecodeFixed32(data_ + size_ - sizeof(uint32_t)); +} + +Block::Block(const BlockContents& contents) + : data_(contents.data.data()), + size_(contents.data.size()), + owned_(contents.heap_allocated) { + if (size_ < sizeof(uint32_t)) { + size_ = 0; // Error marker + } else { + size_t max_restarts_allowed = (size_-sizeof(uint32_t)) / sizeof(uint32_t); + if (NumRestarts() > max_restarts_allowed) { + // The size is too small for NumRestarts() + size_ = 0; + } else { + restart_offset_ = size_ - (1 + NumRestarts()) * sizeof(uint32_t); + } + } +} + +Block::~Block() { + if (owned_) { + delete[] data_; + } +} + +// Helper routine: decode the next block entry starting at "p", +// storing the number of shared key bytes, non_shared key bytes, +// and the length of the value in "*shared", "*non_shared", and +// "*value_length", respectively. Will not derefence past "limit". +// +// If any errors are detected, returns NULL. Otherwise, returns a +// pointer to the key delta (just past the three decoded values). +static inline const char* DecodeEntry(const char* p, const char* limit, + uint32_t* shared, + uint32_t* non_shared, + uint32_t* value_length) { + if (limit - p < 3) return NULL; + *shared = reinterpret_cast(p)[0]; + *non_shared = reinterpret_cast(p)[1]; + *value_length = reinterpret_cast(p)[2]; + if ((*shared | *non_shared | *value_length) < 128) { + // Fast path: all three values are encoded in one byte each + p += 3; + } else { + if ((p = GetVarint32Ptr(p, limit, shared)) == NULL) return NULL; + if ((p = GetVarint32Ptr(p, limit, non_shared)) == NULL) return NULL; + if ((p = GetVarint32Ptr(p, limit, value_length)) == NULL) return NULL; + } + + if (static_cast(limit - p) < (*non_shared + *value_length)) { + return NULL; + } + return p; +} + +class Block::Iter : public Iterator { + private: + const Comparator* const comparator_; + const char* const data_; // underlying block contents + uint32_t const restarts_; // Offset of restart array (list of fixed32) + uint32_t const num_restarts_; // Number of uint32_t entries in restart array + + // current_ is offset in data_ of current entry. >= restarts_ if !Valid + uint32_t current_; + uint32_t restart_index_; // Index of restart block in which current_ falls + std::string key_; + Slice value_; + Status status_; + + inline int Compare(const Slice& a, const Slice& b) const { + return comparator_->Compare(a, b); + } + + // Return the offset in data_ just past the end of the current entry. + inline uint32_t NextEntryOffset() const { + return (value_.data() + value_.size()) - data_; + } + + uint32_t GetRestartPoint(uint32_t index) { + assert(index < num_restarts_); + return DecodeFixed32(data_ + restarts_ + index * sizeof(uint32_t)); + } + + void SeekToRestartPoint(uint32_t index) { + key_.clear(); + restart_index_ = index; + // current_ will be fixed by ParseNextKey(); + + // ParseNextKey() starts at the end of value_, so set value_ accordingly + uint32_t offset = GetRestartPoint(index); + value_ = Slice(data_ + offset, 0); + } + + public: + Iter(const Comparator* comparator, + const char* data, + uint32_t restarts, + uint32_t num_restarts) + : comparator_(comparator), + data_(data), + restarts_(restarts), + num_restarts_(num_restarts), + current_(restarts_), + restart_index_(num_restarts_) { + assert(num_restarts_ > 0); + } + + virtual bool Valid() const { return current_ < restarts_; } + virtual Status status() const { return status_; } + virtual Slice key() const { + assert(Valid()); + return key_; + } + virtual Slice value() const { + assert(Valid()); + return value_; + } + + virtual void Next() { + assert(Valid()); + ParseNextKey(); + } + + virtual void Prev() { + assert(Valid()); + + // Scan backwards to a restart point before current_ + const uint32_t original = current_; + while (GetRestartPoint(restart_index_) >= original) { + if (restart_index_ == 0) { + // No more entries + current_ = restarts_; + restart_index_ = num_restarts_; + return; + } + restart_index_--; + } + + SeekToRestartPoint(restart_index_); + do { + // Loop until end of current entry hits the start of original entry + } while (ParseNextKey() && NextEntryOffset() < original); + } + + virtual void Seek(const Slice& target) { + // Binary search in restart array to find the last restart point + // with a key < target + uint32_t left = 0; + uint32_t right = num_restarts_ - 1; + while (left < right) { + uint32_t mid = (left + right + 1) / 2; + uint32_t region_offset = GetRestartPoint(mid); + uint32_t shared, non_shared, value_length; + const char* key_ptr = DecodeEntry(data_ + region_offset, + data_ + restarts_, + &shared, &non_shared, &value_length); + if (key_ptr == NULL || (shared != 0)) { + CorruptionError(); + return; + } + Slice mid_key(key_ptr, non_shared); + if (Compare(mid_key, target) < 0) { + // Key at "mid" is smaller than "target". Therefore all + // blocks before "mid" are uninteresting. + left = mid; + } else { + // Key at "mid" is >= "target". Therefore all blocks at or + // after "mid" are uninteresting. + right = mid - 1; + } + } + + // Linear search (within restart block) for first key >= target + SeekToRestartPoint(left); + while (true) { + if (!ParseNextKey()) { + return; + } + if (Compare(key_, target) >= 0) { + return; + } + } + } + + virtual void SeekToFirst() { + SeekToRestartPoint(0); + ParseNextKey(); + } + + virtual void SeekToLast() { + SeekToRestartPoint(num_restarts_ - 1); + while (ParseNextKey() && NextEntryOffset() < restarts_) { + // Keep skipping + } + } + + private: + void CorruptionError() { + current_ = restarts_; + restart_index_ = num_restarts_; + status_ = Status::Corruption("bad entry in block"); + key_.clear(); + value_.clear(); + } + + bool ParseNextKey() { + current_ = NextEntryOffset(); + const char* p = data_ + current_; + const char* limit = data_ + restarts_; // Restarts come right after data + if (p >= limit) { + // No more entries to return. Mark as invalid. + current_ = restarts_; + restart_index_ = num_restarts_; + return false; + } + + // Decode next entry + uint32_t shared, non_shared, value_length; + p = DecodeEntry(p, limit, &shared, &non_shared, &value_length); + if (p == NULL || key_.size() < shared) { + CorruptionError(); + return false; + } else { + key_.resize(shared); + key_.append(p, non_shared); + value_ = Slice(p + non_shared, value_length); + while (restart_index_ + 1 < num_restarts_ && + GetRestartPoint(restart_index_ + 1) < current_) { + ++restart_index_; + } + return true; + } + } +}; + +Iterator* Block::NewIterator(const Comparator* cmp) { + if (size_ < sizeof(uint32_t)) { + return NewErrorIterator(Status::Corruption("bad block contents")); + } + const uint32_t num_restarts = NumRestarts(); + if (num_restarts == 0) { + return NewEmptyIterator(); + } else { + return new Iter(cmp, data_, restart_offset_, num_restarts); + } +} + +} // namespace leveldb diff --git a/src/leveldb/table/block.h b/src/leveldb/table/block.h new file mode 100644 index 0000000..2493eb9 --- /dev/null +++ b/src/leveldb/table/block.h @@ -0,0 +1,44 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_TABLE_BLOCK_H_ +#define STORAGE_LEVELDB_TABLE_BLOCK_H_ + +#include +#include +#include "leveldb/iterator.h" + +namespace leveldb { + +struct BlockContents; +class Comparator; + +class Block { + public: + // Initialize the block with the specified contents. + explicit Block(const BlockContents& contents); + + ~Block(); + + size_t size() const { return size_; } + Iterator* NewIterator(const Comparator* comparator); + + private: + uint32_t NumRestarts() const; + + const char* data_; + size_t size_; + uint32_t restart_offset_; // Offset in data_ of restart array + bool owned_; // Block owns data_[] + + // No copying allowed + Block(const Block&); + void operator=(const Block&); + + class Iter; +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_TABLE_BLOCK_H_ diff --git a/src/leveldb/table/block_builder.cc b/src/leveldb/table/block_builder.cc new file mode 100644 index 0000000..db660cd --- /dev/null +++ b/src/leveldb/table/block_builder.cc @@ -0,0 +1,109 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// BlockBuilder generates blocks where keys are prefix-compressed: +// +// When we store a key, we drop the prefix shared with the previous +// string. This helps reduce the space requirement significantly. +// Furthermore, once every K keys, we do not apply the prefix +// compression and store the entire key. We call this a "restart +// point". The tail end of the block stores the offsets of all of the +// restart points, and can be used to do a binary search when looking +// for a particular key. Values are stored as-is (without compression) +// immediately following the corresponding key. +// +// An entry for a particular key-value pair has the form: +// shared_bytes: varint32 +// unshared_bytes: varint32 +// value_length: varint32 +// key_delta: char[unshared_bytes] +// value: char[value_length] +// shared_bytes == 0 for restart points. +// +// The trailer of the block has the form: +// restarts: uint32[num_restarts] +// num_restarts: uint32 +// restarts[i] contains the offset within the block of the ith restart point. + +#include "table/block_builder.h" + +#include +#include +#include "leveldb/comparator.h" +#include "leveldb/table_builder.h" +#include "util/coding.h" + +namespace leveldb { + +BlockBuilder::BlockBuilder(const Options* options) + : options_(options), + restarts_(), + counter_(0), + finished_(false) { + assert(options->block_restart_interval >= 1); + restarts_.push_back(0); // First restart point is at offset 0 +} + +void BlockBuilder::Reset() { + buffer_.clear(); + restarts_.clear(); + restarts_.push_back(0); // First restart point is at offset 0 + counter_ = 0; + finished_ = false; + last_key_.clear(); +} + +size_t BlockBuilder::CurrentSizeEstimate() const { + return (buffer_.size() + // Raw data buffer + restarts_.size() * sizeof(uint32_t) + // Restart array + sizeof(uint32_t)); // Restart array length +} + +Slice BlockBuilder::Finish() { + // Append restart array + for (size_t i = 0; i < restarts_.size(); i++) { + PutFixed32(&buffer_, restarts_[i]); + } + PutFixed32(&buffer_, restarts_.size()); + finished_ = true; + return Slice(buffer_); +} + +void BlockBuilder::Add(const Slice& key, const Slice& value) { + Slice last_key_piece(last_key_); + assert(!finished_); + assert(counter_ <= options_->block_restart_interval); + assert(buffer_.empty() // No values yet? + || options_->comparator->Compare(key, last_key_piece) > 0); + size_t shared = 0; + if (counter_ < options_->block_restart_interval) { + // See how much sharing to do with previous string + const size_t min_length = std::min(last_key_piece.size(), key.size()); + while ((shared < min_length) && (last_key_piece[shared] == key[shared])) { + shared++; + } + } else { + // Restart compression + restarts_.push_back(buffer_.size()); + counter_ = 0; + } + const size_t non_shared = key.size() - shared; + + // Add "" to buffer_ + PutVarint32(&buffer_, shared); + PutVarint32(&buffer_, non_shared); + PutVarint32(&buffer_, value.size()); + + // Add string delta to buffer_ followed by value + buffer_.append(key.data() + shared, non_shared); + buffer_.append(value.data(), value.size()); + + // Update state + last_key_.resize(shared); + last_key_.append(key.data() + shared, non_shared); + assert(Slice(last_key_) == key); + counter_++; +} + +} // namespace leveldb diff --git a/src/leveldb/table/block_builder.h b/src/leveldb/table/block_builder.h new file mode 100644 index 0000000..5b545bd --- /dev/null +++ b/src/leveldb/table/block_builder.h @@ -0,0 +1,57 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_ +#define STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_ + +#include + +#include +#include "leveldb/slice.h" + +namespace leveldb { + +struct Options; + +class BlockBuilder { + public: + explicit BlockBuilder(const Options* options); + + // Reset the contents as if the BlockBuilder was just constructed. + void Reset(); + + // REQUIRES: Finish() has not been callled since the last call to Reset(). + // REQUIRES: key is larger than any previously added key + void Add(const Slice& key, const Slice& value); + + // Finish building the block and return a slice that refers to the + // block contents. The returned slice will remain valid for the + // lifetime of this builder or until Reset() is called. + Slice Finish(); + + // Returns an estimate of the current (uncompressed) size of the block + // we are building. + size_t CurrentSizeEstimate() const; + + // Return true iff no entries have been added since the last Reset() + bool empty() const { + return buffer_.empty(); + } + + private: + const Options* options_; + std::string buffer_; // Destination buffer + std::vector restarts_; // Restart points + int counter_; // Number of entries emitted since restart + bool finished_; // Has Finish() been called? + std::string last_key_; + + // No copying allowed + BlockBuilder(const BlockBuilder&); + void operator=(const BlockBuilder&); +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_ diff --git a/src/leveldb/table/filter_block.cc b/src/leveldb/table/filter_block.cc new file mode 100644 index 0000000..203e15c --- /dev/null +++ b/src/leveldb/table/filter_block.cc @@ -0,0 +1,111 @@ +// Copyright (c) 2012 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "table/filter_block.h" + +#include "leveldb/filter_policy.h" +#include "util/coding.h" + +namespace leveldb { + +// See doc/table_format.txt for an explanation of the filter block format. + +// Generate new filter every 2KB of data +static const size_t kFilterBaseLg = 11; +static const size_t kFilterBase = 1 << kFilterBaseLg; + +FilterBlockBuilder::FilterBlockBuilder(const FilterPolicy* policy) + : policy_(policy) { +} + +void FilterBlockBuilder::StartBlock(uint64_t block_offset) { + uint64_t filter_index = (block_offset / kFilterBase); + assert(filter_index >= filter_offsets_.size()); + while (filter_index > filter_offsets_.size()) { + GenerateFilter(); + } +} + +void FilterBlockBuilder::AddKey(const Slice& key) { + Slice k = key; + start_.push_back(keys_.size()); + keys_.append(k.data(), k.size()); +} + +Slice FilterBlockBuilder::Finish() { + if (!start_.empty()) { + GenerateFilter(); + } + + // Append array of per-filter offsets + const uint32_t array_offset = result_.size(); + for (size_t i = 0; i < filter_offsets_.size(); i++) { + PutFixed32(&result_, filter_offsets_[i]); + } + + PutFixed32(&result_, array_offset); + result_.push_back(kFilterBaseLg); // Save encoding parameter in result + return Slice(result_); +} + +void FilterBlockBuilder::GenerateFilter() { + const size_t num_keys = start_.size(); + if (num_keys == 0) { + // Fast path if there are no keys for this filter + filter_offsets_.push_back(result_.size()); + return; + } + + // Make list of keys from flattened key structure + start_.push_back(keys_.size()); // Simplify length computation + tmp_keys_.resize(num_keys); + for (size_t i = 0; i < num_keys; i++) { + const char* base = keys_.data() + start_[i]; + size_t length = start_[i+1] - start_[i]; + tmp_keys_[i] = Slice(base, length); + } + + // Generate filter for current set of keys and append to result_. + filter_offsets_.push_back(result_.size()); + policy_->CreateFilter(&tmp_keys_[0], num_keys, &result_); + + tmp_keys_.clear(); + keys_.clear(); + start_.clear(); +} + +FilterBlockReader::FilterBlockReader(const FilterPolicy* policy, + const Slice& contents) + : policy_(policy), + data_(NULL), + offset_(NULL), + num_(0), + base_lg_(0) { + size_t n = contents.size(); + if (n < 5) return; // 1 byte for base_lg_ and 4 for start of offset array + base_lg_ = contents[n-1]; + uint32_t last_word = DecodeFixed32(contents.data() + n - 5); + if (last_word > n - 5) return; + data_ = contents.data(); + offset_ = data_ + last_word; + num_ = (n - 5 - last_word) / 4; +} + +bool FilterBlockReader::KeyMayMatch(uint64_t block_offset, const Slice& key) { + uint64_t index = block_offset >> base_lg_; + if (index < num_) { + uint32_t start = DecodeFixed32(offset_ + index*4); + uint32_t limit = DecodeFixed32(offset_ + index*4 + 4); + if (start <= limit && limit <= (offset_ - data_)) { + Slice filter = Slice(data_ + start, limit - start); + return policy_->KeyMayMatch(key, filter); + } else if (start == limit) { + // Empty filters do not match any keys + return false; + } + } + return true; // Errors are treated as potential matches +} + +} diff --git a/src/leveldb/table/filter_block.h b/src/leveldb/table/filter_block.h new file mode 100644 index 0000000..c67d010 --- /dev/null +++ b/src/leveldb/table/filter_block.h @@ -0,0 +1,68 @@ +// Copyright (c) 2012 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// A filter block is stored near the end of a Table file. It contains +// filters (e.g., bloom filters) for all data blocks in the table combined +// into a single filter block. + +#ifndef STORAGE_LEVELDB_TABLE_FILTER_BLOCK_H_ +#define STORAGE_LEVELDB_TABLE_FILTER_BLOCK_H_ + +#include +#include +#include +#include +#include "leveldb/slice.h" +#include "util/hash.h" + +namespace leveldb { + +class FilterPolicy; + +// A FilterBlockBuilder is used to construct all of the filters for a +// particular Table. It generates a single string which is stored as +// a special block in the Table. +// +// The sequence of calls to FilterBlockBuilder must match the regexp: +// (StartBlock AddKey*)* Finish +class FilterBlockBuilder { + public: + explicit FilterBlockBuilder(const FilterPolicy*); + + void StartBlock(uint64_t block_offset); + void AddKey(const Slice& key); + Slice Finish(); + + private: + void GenerateFilter(); + + const FilterPolicy* policy_; + std::string keys_; // Flattened key contents + std::vector start_; // Starting index in keys_ of each key + std::string result_; // Filter data computed so far + std::vector tmp_keys_; // policy_->CreateFilter() argument + std::vector filter_offsets_; + + // No copying allowed + FilterBlockBuilder(const FilterBlockBuilder&); + void operator=(const FilterBlockBuilder&); +}; + +class FilterBlockReader { + public: + // REQUIRES: "contents" and *policy must stay live while *this is live. + FilterBlockReader(const FilterPolicy* policy, const Slice& contents); + bool KeyMayMatch(uint64_t block_offset, const Slice& key); + + private: + const FilterPolicy* policy_; + const char* data_; // Pointer to filter data (at block-start) + const char* offset_; // Pointer to beginning of offset array (at block-end) + size_t num_; // Number of entries in offset array + size_t base_lg_; // Encoding parameter (see kFilterBaseLg in .cc file) +}; + +} + +#endif // STORAGE_LEVELDB_TABLE_FILTER_BLOCK_H_ diff --git a/src/leveldb/table/filter_block_test.cc b/src/leveldb/table/filter_block_test.cc new file mode 100644 index 0000000..8c4a474 --- /dev/null +++ b/src/leveldb/table/filter_block_test.cc @@ -0,0 +1,128 @@ +// Copyright (c) 2012 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "table/filter_block.h" + +#include "leveldb/filter_policy.h" +#include "util/coding.h" +#include "util/hash.h" +#include "util/logging.h" +#include "util/testharness.h" +#include "util/testutil.h" + +namespace leveldb { + +// For testing: emit an array with one hash value per key +class TestHashFilter : public FilterPolicy { + public: + virtual const char* Name() const { + return "TestHashFilter"; + } + + virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const { + for (int i = 0; i < n; i++) { + uint32_t h = Hash(keys[i].data(), keys[i].size(), 1); + PutFixed32(dst, h); + } + } + + virtual bool KeyMayMatch(const Slice& key, const Slice& filter) const { + uint32_t h = Hash(key.data(), key.size(), 1); + for (size_t i = 0; i + 4 <= filter.size(); i += 4) { + if (h == DecodeFixed32(filter.data() + i)) { + return true; + } + } + return false; + } +}; + +class FilterBlockTest { + public: + TestHashFilter policy_; +}; + +TEST(FilterBlockTest, EmptyBuilder) { + FilterBlockBuilder builder(&policy_); + Slice block = builder.Finish(); + ASSERT_EQ("\\x00\\x00\\x00\\x00\\x0b", EscapeString(block)); + FilterBlockReader reader(&policy_, block); + ASSERT_TRUE(reader.KeyMayMatch(0, "foo")); + ASSERT_TRUE(reader.KeyMayMatch(100000, "foo")); +} + +TEST(FilterBlockTest, SingleChunk) { + FilterBlockBuilder builder(&policy_); + builder.StartBlock(100); + builder.AddKey("foo"); + builder.AddKey("bar"); + builder.AddKey("box"); + builder.StartBlock(200); + builder.AddKey("box"); + builder.StartBlock(300); + builder.AddKey("hello"); + Slice block = builder.Finish(); + FilterBlockReader reader(&policy_, block); + ASSERT_TRUE(reader.KeyMayMatch(100, "foo")); + ASSERT_TRUE(reader.KeyMayMatch(100, "bar")); + ASSERT_TRUE(reader.KeyMayMatch(100, "box")); + ASSERT_TRUE(reader.KeyMayMatch(100, "hello")); + ASSERT_TRUE(reader.KeyMayMatch(100, "foo")); + ASSERT_TRUE(! reader.KeyMayMatch(100, "missing")); + ASSERT_TRUE(! reader.KeyMayMatch(100, "other")); +} + +TEST(FilterBlockTest, MultiChunk) { + FilterBlockBuilder builder(&policy_); + + // First filter + builder.StartBlock(0); + builder.AddKey("foo"); + builder.StartBlock(2000); + builder.AddKey("bar"); + + // Second filter + builder.StartBlock(3100); + builder.AddKey("box"); + + // Third filter is empty + + // Last filter + builder.StartBlock(9000); + builder.AddKey("box"); + builder.AddKey("hello"); + + Slice block = builder.Finish(); + FilterBlockReader reader(&policy_, block); + + // Check first filter + ASSERT_TRUE(reader.KeyMayMatch(0, "foo")); + ASSERT_TRUE(reader.KeyMayMatch(2000, "bar")); + ASSERT_TRUE(! reader.KeyMayMatch(0, "box")); + ASSERT_TRUE(! reader.KeyMayMatch(0, "hello")); + + // Check second filter + ASSERT_TRUE(reader.KeyMayMatch(3100, "box")); + ASSERT_TRUE(! reader.KeyMayMatch(3100, "foo")); + ASSERT_TRUE(! reader.KeyMayMatch(3100, "bar")); + ASSERT_TRUE(! reader.KeyMayMatch(3100, "hello")); + + // Check third filter (empty) + ASSERT_TRUE(! reader.KeyMayMatch(4100, "foo")); + ASSERT_TRUE(! reader.KeyMayMatch(4100, "bar")); + ASSERT_TRUE(! reader.KeyMayMatch(4100, "box")); + ASSERT_TRUE(! reader.KeyMayMatch(4100, "hello")); + + // Check last filter + ASSERT_TRUE(reader.KeyMayMatch(9000, "box")); + ASSERT_TRUE(reader.KeyMayMatch(9000, "hello")); + ASSERT_TRUE(! reader.KeyMayMatch(9000, "foo")); + ASSERT_TRUE(! reader.KeyMayMatch(9000, "bar")); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/table/format.cc b/src/leveldb/table/format.cc new file mode 100644 index 0000000..cda1dec --- /dev/null +++ b/src/leveldb/table/format.cc @@ -0,0 +1,145 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "table/format.h" + +#include "leveldb/env.h" +#include "port/port.h" +#include "table/block.h" +#include "util/coding.h" +#include "util/crc32c.h" + +namespace leveldb { + +void BlockHandle::EncodeTo(std::string* dst) const { + // Sanity check that all fields have been set + assert(offset_ != ~static_cast(0)); + assert(size_ != ~static_cast(0)); + PutVarint64(dst, offset_); + PutVarint64(dst, size_); +} + +Status BlockHandle::DecodeFrom(Slice* input) { + if (GetVarint64(input, &offset_) && + GetVarint64(input, &size_)) { + return Status::OK(); + } else { + return Status::Corruption("bad block handle"); + } +} + +void Footer::EncodeTo(std::string* dst) const { +#ifndef NDEBUG + const size_t original_size = dst->size(); +#endif + metaindex_handle_.EncodeTo(dst); + index_handle_.EncodeTo(dst); + dst->resize(2 * BlockHandle::kMaxEncodedLength); // Padding + PutFixed32(dst, static_cast(kTableMagicNumber & 0xffffffffu)); + PutFixed32(dst, static_cast(kTableMagicNumber >> 32)); + assert(dst->size() == original_size + kEncodedLength); +} + +Status Footer::DecodeFrom(Slice* input) { + const char* magic_ptr = input->data() + kEncodedLength - 8; + const uint32_t magic_lo = DecodeFixed32(magic_ptr); + const uint32_t magic_hi = DecodeFixed32(magic_ptr + 4); + const uint64_t magic = ((static_cast(magic_hi) << 32) | + (static_cast(magic_lo))); + if (magic != kTableMagicNumber) { + return Status::InvalidArgument("not an sstable (bad magic number)"); + } + + Status result = metaindex_handle_.DecodeFrom(input); + if (result.ok()) { + result = index_handle_.DecodeFrom(input); + } + if (result.ok()) { + // We skip over any leftover data (just padding for now) in "input" + const char* end = magic_ptr + 8; + *input = Slice(end, input->data() + input->size() - end); + } + return result; +} + +Status ReadBlock(RandomAccessFile* file, + const ReadOptions& options, + const BlockHandle& handle, + BlockContents* result) { + result->data = Slice(); + result->cachable = false; + result->heap_allocated = false; + + // Read the block contents as well as the type/crc footer. + // See table_builder.cc for the code that built this structure. + size_t n = static_cast(handle.size()); + char* buf = new char[n + kBlockTrailerSize]; + Slice contents; + Status s = file->Read(handle.offset(), n + kBlockTrailerSize, &contents, buf); + if (!s.ok()) { + delete[] buf; + return s; + } + if (contents.size() != n + kBlockTrailerSize) { + delete[] buf; + return Status::Corruption("truncated block read"); + } + + // Check the crc of the type and the block contents + const char* data = contents.data(); // Pointer to where Read put the data + if (options.verify_checksums) { + const uint32_t crc = crc32c::Unmask(DecodeFixed32(data + n + 1)); + const uint32_t actual = crc32c::Value(data, n + 1); + if (actual != crc) { + delete[] buf; + s = Status::Corruption("block checksum mismatch"); + return s; + } + } + + switch (data[n]) { + case kNoCompression: + if (data != buf) { + // File implementation gave us pointer to some other data. + // Use it directly under the assumption that it will be live + // while the file is open. + delete[] buf; + result->data = Slice(data, n); + result->heap_allocated = false; + result->cachable = false; // Do not double-cache + } else { + result->data = Slice(buf, n); + result->heap_allocated = true; + result->cachable = true; + } + + // Ok + break; + case kSnappyCompression: { + size_t ulength = 0; + if (!port::Snappy_GetUncompressedLength(data, n, &ulength)) { + delete[] buf; + return Status::Corruption("corrupted compressed block contents"); + } + char* ubuf = new char[ulength]; + if (!port::Snappy_Uncompress(data, n, ubuf)) { + delete[] buf; + delete[] ubuf; + return Status::Corruption("corrupted compressed block contents"); + } + delete[] buf; + result->data = Slice(ubuf, ulength); + result->heap_allocated = true; + result->cachable = true; + break; + } + default: + delete[] buf; + return Status::Corruption("bad block type"); + } + + return Status::OK(); +} + +} // namespace leveldb diff --git a/src/leveldb/table/format.h b/src/leveldb/table/format.h new file mode 100644 index 0000000..6c0b80c --- /dev/null +++ b/src/leveldb/table/format.h @@ -0,0 +1,108 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_TABLE_FORMAT_H_ +#define STORAGE_LEVELDB_TABLE_FORMAT_H_ + +#include +#include +#include "leveldb/slice.h" +#include "leveldb/status.h" +#include "leveldb/table_builder.h" + +namespace leveldb { + +class Block; +class RandomAccessFile; +struct ReadOptions; + +// BlockHandle is a pointer to the extent of a file that stores a data +// block or a meta block. +class BlockHandle { + public: + BlockHandle(); + + // The offset of the block in the file. + uint64_t offset() const { return offset_; } + void set_offset(uint64_t offset) { offset_ = offset; } + + // The size of the stored block + uint64_t size() const { return size_; } + void set_size(uint64_t size) { size_ = size; } + + void EncodeTo(std::string* dst) const; + Status DecodeFrom(Slice* input); + + // Maximum encoding length of a BlockHandle + enum { kMaxEncodedLength = 10 + 10 }; + + private: + uint64_t offset_; + uint64_t size_; +}; + +// Footer encapsulates the fixed information stored at the tail +// end of every table file. +class Footer { + public: + Footer() { } + + // The block handle for the metaindex block of the table + const BlockHandle& metaindex_handle() const { return metaindex_handle_; } + void set_metaindex_handle(const BlockHandle& h) { metaindex_handle_ = h; } + + // The block handle for the index block of the table + const BlockHandle& index_handle() const { + return index_handle_; + } + void set_index_handle(const BlockHandle& h) { + index_handle_ = h; + } + + void EncodeTo(std::string* dst) const; + Status DecodeFrom(Slice* input); + + // Encoded length of a Footer. Note that the serialization of a + // Footer will always occupy exactly this many bytes. It consists + // of two block handles and a magic number. + enum { + kEncodedLength = 2*BlockHandle::kMaxEncodedLength + 8 + }; + + private: + BlockHandle metaindex_handle_; + BlockHandle index_handle_; +}; + +// kTableMagicNumber was picked by running +// echo http://code.google.com/p/leveldb/ | sha1sum +// and taking the leading 64 bits. +static const uint64_t kTableMagicNumber = 0xdb4775248b80fb57ull; + +// 1-byte type + 32-bit crc +static const size_t kBlockTrailerSize = 5; + +struct BlockContents { + Slice data; // Actual contents of data + bool cachable; // True iff data can be cached + bool heap_allocated; // True iff caller should delete[] data.data() +}; + +// Read the block identified by "handle" from "file". On failure +// return non-OK. On success fill *result and return OK. +extern Status ReadBlock(RandomAccessFile* file, + const ReadOptions& options, + const BlockHandle& handle, + BlockContents* result); + +// Implementation details follow. Clients should ignore, + +inline BlockHandle::BlockHandle() + : offset_(~static_cast(0)), + size_(~static_cast(0)) { +} + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_TABLE_FORMAT_H_ diff --git a/src/leveldb/table/iterator.cc b/src/leveldb/table/iterator.cc new file mode 100644 index 0000000..3d1c87f --- /dev/null +++ b/src/leveldb/table/iterator.cc @@ -0,0 +1,67 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/iterator.h" + +namespace leveldb { + +Iterator::Iterator() { + cleanup_.function = NULL; + cleanup_.next = NULL; +} + +Iterator::~Iterator() { + if (cleanup_.function != NULL) { + (*cleanup_.function)(cleanup_.arg1, cleanup_.arg2); + for (Cleanup* c = cleanup_.next; c != NULL; ) { + (*c->function)(c->arg1, c->arg2); + Cleanup* next = c->next; + delete c; + c = next; + } + } +} + +void Iterator::RegisterCleanup(CleanupFunction func, void* arg1, void* arg2) { + assert(func != NULL); + Cleanup* c; + if (cleanup_.function == NULL) { + c = &cleanup_; + } else { + c = new Cleanup; + c->next = cleanup_.next; + cleanup_.next = c; + } + c->function = func; + c->arg1 = arg1; + c->arg2 = arg2; +} + +namespace { +class EmptyIterator : public Iterator { + public: + EmptyIterator(const Status& s) : status_(s) { } + virtual bool Valid() const { return false; } + virtual void Seek(const Slice& target) { } + virtual void SeekToFirst() { } + virtual void SeekToLast() { } + virtual void Next() { assert(false); } + virtual void Prev() { assert(false); } + Slice key() const { assert(false); return Slice(); } + Slice value() const { assert(false); return Slice(); } + virtual Status status() const { return status_; } + private: + Status status_; +}; +} // namespace + +Iterator* NewEmptyIterator() { + return new EmptyIterator(Status::OK()); +} + +Iterator* NewErrorIterator(const Status& status) { + return new EmptyIterator(status); +} + +} // namespace leveldb diff --git a/src/leveldb/table/iterator_wrapper.h b/src/leveldb/table/iterator_wrapper.h new file mode 100644 index 0000000..9e16b3d --- /dev/null +++ b/src/leveldb/table/iterator_wrapper.h @@ -0,0 +1,63 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_TABLE_ITERATOR_WRAPPER_H_ +#define STORAGE_LEVELDB_TABLE_ITERATOR_WRAPPER_H_ + +namespace leveldb { + +// A internal wrapper class with an interface similar to Iterator that +// caches the valid() and key() results for an underlying iterator. +// This can help avoid virtual function calls and also gives better +// cache locality. +class IteratorWrapper { + public: + IteratorWrapper(): iter_(NULL), valid_(false) { } + explicit IteratorWrapper(Iterator* iter): iter_(NULL) { + Set(iter); + } + ~IteratorWrapper() { delete iter_; } + Iterator* iter() const { return iter_; } + + // Takes ownership of "iter" and will delete it when destroyed, or + // when Set() is invoked again. + void Set(Iterator* iter) { + delete iter_; + iter_ = iter; + if (iter_ == NULL) { + valid_ = false; + } else { + Update(); + } + } + + + // Iterator interface methods + bool Valid() const { return valid_; } + Slice key() const { assert(Valid()); return key_; } + Slice value() const { assert(Valid()); return iter_->value(); } + // Methods below require iter() != NULL + Status status() const { assert(iter_); return iter_->status(); } + void Next() { assert(iter_); iter_->Next(); Update(); } + void Prev() { assert(iter_); iter_->Prev(); Update(); } + void Seek(const Slice& k) { assert(iter_); iter_->Seek(k); Update(); } + void SeekToFirst() { assert(iter_); iter_->SeekToFirst(); Update(); } + void SeekToLast() { assert(iter_); iter_->SeekToLast(); Update(); } + + private: + void Update() { + valid_ = iter_->Valid(); + if (valid_) { + key_ = iter_->key(); + } + } + + Iterator* iter_; + bool valid_; + Slice key_; +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_TABLE_ITERATOR_WRAPPER_H_ diff --git a/src/leveldb/table/merger.cc b/src/leveldb/table/merger.cc new file mode 100644 index 0000000..2dde4dc --- /dev/null +++ b/src/leveldb/table/merger.cc @@ -0,0 +1,197 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "table/merger.h" + +#include "leveldb/comparator.h" +#include "leveldb/iterator.h" +#include "table/iterator_wrapper.h" + +namespace leveldb { + +namespace { +class MergingIterator : public Iterator { + public: + MergingIterator(const Comparator* comparator, Iterator** children, int n) + : comparator_(comparator), + children_(new IteratorWrapper[n]), + n_(n), + current_(NULL), + direction_(kForward) { + for (int i = 0; i < n; i++) { + children_[i].Set(children[i]); + } + } + + virtual ~MergingIterator() { + delete[] children_; + } + + virtual bool Valid() const { + return (current_ != NULL); + } + + virtual void SeekToFirst() { + for (int i = 0; i < n_; i++) { + children_[i].SeekToFirst(); + } + FindSmallest(); + direction_ = kForward; + } + + virtual void SeekToLast() { + for (int i = 0; i < n_; i++) { + children_[i].SeekToLast(); + } + FindLargest(); + direction_ = kReverse; + } + + virtual void Seek(const Slice& target) { + for (int i = 0; i < n_; i++) { + children_[i].Seek(target); + } + FindSmallest(); + direction_ = kForward; + } + + virtual void Next() { + assert(Valid()); + + // Ensure that all children are positioned after key(). + // If we are moving in the forward direction, it is already + // true for all of the non-current_ children since current_ is + // the smallest child and key() == current_->key(). Otherwise, + // we explicitly position the non-current_ children. + if (direction_ != kForward) { + for (int i = 0; i < n_; i++) { + IteratorWrapper* child = &children_[i]; + if (child != current_) { + child->Seek(key()); + if (child->Valid() && + comparator_->Compare(key(), child->key()) == 0) { + child->Next(); + } + } + } + direction_ = kForward; + } + + current_->Next(); + FindSmallest(); + } + + virtual void Prev() { + assert(Valid()); + + // Ensure that all children are positioned before key(). + // If we are moving in the reverse direction, it is already + // true for all of the non-current_ children since current_ is + // the largest child and key() == current_->key(). Otherwise, + // we explicitly position the non-current_ children. + if (direction_ != kReverse) { + for (int i = 0; i < n_; i++) { + IteratorWrapper* child = &children_[i]; + if (child != current_) { + child->Seek(key()); + if (child->Valid()) { + // Child is at first entry >= key(). Step back one to be < key() + child->Prev(); + } else { + // Child has no entries >= key(). Position at last entry. + child->SeekToLast(); + } + } + } + direction_ = kReverse; + } + + current_->Prev(); + FindLargest(); + } + + virtual Slice key() const { + assert(Valid()); + return current_->key(); + } + + virtual Slice value() const { + assert(Valid()); + return current_->value(); + } + + virtual Status status() const { + Status status; + for (int i = 0; i < n_; i++) { + status = children_[i].status(); + if (!status.ok()) { + break; + } + } + return status; + } + + private: + void FindSmallest(); + void FindLargest(); + + // We might want to use a heap in case there are lots of children. + // For now we use a simple array since we expect a very small number + // of children in leveldb. + const Comparator* comparator_; + IteratorWrapper* children_; + int n_; + IteratorWrapper* current_; + + // Which direction is the iterator moving? + enum Direction { + kForward, + kReverse + }; + Direction direction_; +}; + +void MergingIterator::FindSmallest() { + IteratorWrapper* smallest = NULL; + for (int i = 0; i < n_; i++) { + IteratorWrapper* child = &children_[i]; + if (child->Valid()) { + if (smallest == NULL) { + smallest = child; + } else if (comparator_->Compare(child->key(), smallest->key()) < 0) { + smallest = child; + } + } + } + current_ = smallest; +} + +void MergingIterator::FindLargest() { + IteratorWrapper* largest = NULL; + for (int i = n_-1; i >= 0; i--) { + IteratorWrapper* child = &children_[i]; + if (child->Valid()) { + if (largest == NULL) { + largest = child; + } else if (comparator_->Compare(child->key(), largest->key()) > 0) { + largest = child; + } + } + } + current_ = largest; +} +} // namespace + +Iterator* NewMergingIterator(const Comparator* cmp, Iterator** list, int n) { + assert(n >= 0); + if (n == 0) { + return NewEmptyIterator(); + } else if (n == 1) { + return list[0]; + } else { + return new MergingIterator(cmp, list, n); + } +} + +} // namespace leveldb diff --git a/src/leveldb/table/merger.h b/src/leveldb/table/merger.h new file mode 100644 index 0000000..91ddd80 --- /dev/null +++ b/src/leveldb/table/merger.h @@ -0,0 +1,26 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_TABLE_MERGER_H_ +#define STORAGE_LEVELDB_TABLE_MERGER_H_ + +namespace leveldb { + +class Comparator; +class Iterator; + +// Return an iterator that provided the union of the data in +// children[0,n-1]. Takes ownership of the child iterators and +// will delete them when the result iterator is deleted. +// +// The result does no duplicate suppression. I.e., if a particular +// key is present in K child iterators, it will be yielded K times. +// +// REQUIRES: n >= 0 +extern Iterator* NewMergingIterator( + const Comparator* comparator, Iterator** children, int n); + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_TABLE_MERGER_H_ diff --git a/src/leveldb/table/table.cc b/src/leveldb/table/table.cc new file mode 100644 index 0000000..71c1756 --- /dev/null +++ b/src/leveldb/table/table.cc @@ -0,0 +1,275 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/table.h" + +#include "leveldb/cache.h" +#include "leveldb/comparator.h" +#include "leveldb/env.h" +#include "leveldb/filter_policy.h" +#include "leveldb/options.h" +#include "table/block.h" +#include "table/filter_block.h" +#include "table/format.h" +#include "table/two_level_iterator.h" +#include "util/coding.h" + +namespace leveldb { + +struct Table::Rep { + ~Rep() { + delete filter; + delete [] filter_data; + delete index_block; + } + + Options options; + Status status; + RandomAccessFile* file; + uint64_t cache_id; + FilterBlockReader* filter; + const char* filter_data; + + BlockHandle metaindex_handle; // Handle to metaindex_block: saved from footer + Block* index_block; +}; + +Status Table::Open(const Options& options, + RandomAccessFile* file, + uint64_t size, + Table** table) { + *table = NULL; + if (size < Footer::kEncodedLength) { + return Status::InvalidArgument("file is too short to be an sstable"); + } + + char footer_space[Footer::kEncodedLength]; + Slice footer_input; + Status s = file->Read(size - Footer::kEncodedLength, Footer::kEncodedLength, + &footer_input, footer_space); + if (!s.ok()) return s; + + Footer footer; + s = footer.DecodeFrom(&footer_input); + if (!s.ok()) return s; + + // Read the index block + BlockContents contents; + Block* index_block = NULL; + if (s.ok()) { + s = ReadBlock(file, ReadOptions(), footer.index_handle(), &contents); + if (s.ok()) { + index_block = new Block(contents); + } + } + + if (s.ok()) { + // We've successfully read the footer and the index block: we're + // ready to serve requests. + Rep* rep = new Table::Rep; + rep->options = options; + rep->file = file; + rep->metaindex_handle = footer.metaindex_handle(); + rep->index_block = index_block; + rep->cache_id = (options.block_cache ? options.block_cache->NewId() : 0); + rep->filter_data = NULL; + rep->filter = NULL; + *table = new Table(rep); + (*table)->ReadMeta(footer); + } else { + if (index_block) delete index_block; + } + + return s; +} + +void Table::ReadMeta(const Footer& footer) { + if (rep_->options.filter_policy == NULL) { + return; // Do not need any metadata + } + + // TODO(sanjay): Skip this if footer.metaindex_handle() size indicates + // it is an empty block. + ReadOptions opt; + BlockContents contents; + if (!ReadBlock(rep_->file, opt, footer.metaindex_handle(), &contents).ok()) { + // Do not propagate errors since meta info is not needed for operation + return; + } + Block* meta = new Block(contents); + + Iterator* iter = meta->NewIterator(BytewiseComparator()); + std::string key = "filter."; + key.append(rep_->options.filter_policy->Name()); + iter->Seek(key); + if (iter->Valid() && iter->key() == Slice(key)) { + ReadFilter(iter->value()); + } + delete iter; + delete meta; +} + +void Table::ReadFilter(const Slice& filter_handle_value) { + Slice v = filter_handle_value; + BlockHandle filter_handle; + if (!filter_handle.DecodeFrom(&v).ok()) { + return; + } + + // We might want to unify with ReadBlock() if we start + // requiring checksum verification in Table::Open. + ReadOptions opt; + BlockContents block; + if (!ReadBlock(rep_->file, opt, filter_handle, &block).ok()) { + return; + } + if (block.heap_allocated) { + rep_->filter_data = block.data.data(); // Will need to delete later + } + rep_->filter = new FilterBlockReader(rep_->options.filter_policy, block.data); +} + +Table::~Table() { + delete rep_; +} + +static void DeleteBlock(void* arg, void* ignored) { + delete reinterpret_cast(arg); +} + +static void DeleteCachedBlock(const Slice& key, void* value) { + Block* block = reinterpret_cast(value); + delete block; +} + +static void ReleaseBlock(void* arg, void* h) { + Cache* cache = reinterpret_cast(arg); + Cache::Handle* handle = reinterpret_cast(h); + cache->Release(handle); +} + +// Convert an index iterator value (i.e., an encoded BlockHandle) +// into an iterator over the contents of the corresponding block. +Iterator* Table::BlockReader(void* arg, + const ReadOptions& options, + const Slice& index_value) { + Table* table = reinterpret_cast(arg); + Cache* block_cache = table->rep_->options.block_cache; + Block* block = NULL; + Cache::Handle* cache_handle = NULL; + + BlockHandle handle; + Slice input = index_value; + Status s = handle.DecodeFrom(&input); + // We intentionally allow extra stuff in index_value so that we + // can add more features in the future. + + if (s.ok()) { + BlockContents contents; + if (block_cache != NULL) { + char cache_key_buffer[16]; + EncodeFixed64(cache_key_buffer, table->rep_->cache_id); + EncodeFixed64(cache_key_buffer+8, handle.offset()); + Slice key(cache_key_buffer, sizeof(cache_key_buffer)); + cache_handle = block_cache->Lookup(key); + if (cache_handle != NULL) { + block = reinterpret_cast(block_cache->Value(cache_handle)); + } else { + s = ReadBlock(table->rep_->file, options, handle, &contents); + if (s.ok()) { + block = new Block(contents); + if (contents.cachable && options.fill_cache) { + cache_handle = block_cache->Insert( + key, block, block->size(), &DeleteCachedBlock); + } + } + } + } else { + s = ReadBlock(table->rep_->file, options, handle, &contents); + if (s.ok()) { + block = new Block(contents); + } + } + } + + Iterator* iter; + if (block != NULL) { + iter = block->NewIterator(table->rep_->options.comparator); + if (cache_handle == NULL) { + iter->RegisterCleanup(&DeleteBlock, block, NULL); + } else { + iter->RegisterCleanup(&ReleaseBlock, block_cache, cache_handle); + } + } else { + iter = NewErrorIterator(s); + } + return iter; +} + +Iterator* Table::NewIterator(const ReadOptions& options) const { + return NewTwoLevelIterator( + rep_->index_block->NewIterator(rep_->options.comparator), + &Table::BlockReader, const_cast(this), options); +} + +Status Table::InternalGet(const ReadOptions& options, const Slice& k, + void* arg, + void (*saver)(void*, const Slice&, const Slice&)) { + Status s; + Iterator* iiter = rep_->index_block->NewIterator(rep_->options.comparator); + iiter->Seek(k); + if (iiter->Valid()) { + Slice handle_value = iiter->value(); + FilterBlockReader* filter = rep_->filter; + BlockHandle handle; + if (filter != NULL && + handle.DecodeFrom(&handle_value).ok() && + !filter->KeyMayMatch(handle.offset(), k)) { + // Not found + } else { + Iterator* block_iter = BlockReader(this, options, iiter->value()); + block_iter->Seek(k); + if (block_iter->Valid()) { + (*saver)(arg, block_iter->key(), block_iter->value()); + } + s = block_iter->status(); + delete block_iter; + } + } + if (s.ok()) { + s = iiter->status(); + } + delete iiter; + return s; +} + + +uint64_t Table::ApproximateOffsetOf(const Slice& key) const { + Iterator* index_iter = + rep_->index_block->NewIterator(rep_->options.comparator); + index_iter->Seek(key); + uint64_t result; + if (index_iter->Valid()) { + BlockHandle handle; + Slice input = index_iter->value(); + Status s = handle.DecodeFrom(&input); + if (s.ok()) { + result = handle.offset(); + } else { + // Strange: we can't decode the block handle in the index block. + // We'll just return the offset of the metaindex block, which is + // close to the whole file size for this case. + result = rep_->metaindex_handle.offset(); + } + } else { + // key is past the last key in the file. Approximate the offset + // by returning the offset of the metaindex block (which is + // right near the end of the file). + result = rep_->metaindex_handle.offset(); + } + delete index_iter; + return result; +} + +} // namespace leveldb diff --git a/src/leveldb/table/table_builder.cc b/src/leveldb/table/table_builder.cc new file mode 100644 index 0000000..62002c8 --- /dev/null +++ b/src/leveldb/table/table_builder.cc @@ -0,0 +1,270 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/table_builder.h" + +#include +#include "leveldb/comparator.h" +#include "leveldb/env.h" +#include "leveldb/filter_policy.h" +#include "leveldb/options.h" +#include "table/block_builder.h" +#include "table/filter_block.h" +#include "table/format.h" +#include "util/coding.h" +#include "util/crc32c.h" + +namespace leveldb { + +struct TableBuilder::Rep { + Options options; + Options index_block_options; + WritableFile* file; + uint64_t offset; + Status status; + BlockBuilder data_block; + BlockBuilder index_block; + std::string last_key; + int64_t num_entries; + bool closed; // Either Finish() or Abandon() has been called. + FilterBlockBuilder* filter_block; + + // We do not emit the index entry for a block until we have seen the + // first key for the next data block. This allows us to use shorter + // keys in the index block. For example, consider a block boundary + // between the keys "the quick brown fox" and "the who". We can use + // "the r" as the key for the index block entry since it is >= all + // entries in the first block and < all entries in subsequent + // blocks. + // + // Invariant: r->pending_index_entry is true only if data_block is empty. + bool pending_index_entry; + BlockHandle pending_handle; // Handle to add to index block + + std::string compressed_output; + + Rep(const Options& opt, WritableFile* f) + : options(opt), + index_block_options(opt), + file(f), + offset(0), + data_block(&options), + index_block(&index_block_options), + num_entries(0), + closed(false), + filter_block(opt.filter_policy == NULL ? NULL + : new FilterBlockBuilder(opt.filter_policy)), + pending_index_entry(false) { + index_block_options.block_restart_interval = 1; + } +}; + +TableBuilder::TableBuilder(const Options& options, WritableFile* file) + : rep_(new Rep(options, file)) { + if (rep_->filter_block != NULL) { + rep_->filter_block->StartBlock(0); + } +} + +TableBuilder::~TableBuilder() { + assert(rep_->closed); // Catch errors where caller forgot to call Finish() + delete rep_->filter_block; + delete rep_; +} + +Status TableBuilder::ChangeOptions(const Options& options) { + // Note: if more fields are added to Options, update + // this function to catch changes that should not be allowed to + // change in the middle of building a Table. + if (options.comparator != rep_->options.comparator) { + return Status::InvalidArgument("changing comparator while building table"); + } + + // Note that any live BlockBuilders point to rep_->options and therefore + // will automatically pick up the updated options. + rep_->options = options; + rep_->index_block_options = options; + rep_->index_block_options.block_restart_interval = 1; + return Status::OK(); +} + +void TableBuilder::Add(const Slice& key, const Slice& value) { + Rep* r = rep_; + assert(!r->closed); + if (!ok()) return; + if (r->num_entries > 0) { + assert(r->options.comparator->Compare(key, Slice(r->last_key)) > 0); + } + + if (r->pending_index_entry) { + assert(r->data_block.empty()); + r->options.comparator->FindShortestSeparator(&r->last_key, key); + std::string handle_encoding; + r->pending_handle.EncodeTo(&handle_encoding); + r->index_block.Add(r->last_key, Slice(handle_encoding)); + r->pending_index_entry = false; + } + + if (r->filter_block != NULL) { + r->filter_block->AddKey(key); + } + + r->last_key.assign(key.data(), key.size()); + r->num_entries++; + r->data_block.Add(key, value); + + const size_t estimated_block_size = r->data_block.CurrentSizeEstimate(); + if (estimated_block_size >= r->options.block_size) { + Flush(); + } +} + +void TableBuilder::Flush() { + Rep* r = rep_; + assert(!r->closed); + if (!ok()) return; + if (r->data_block.empty()) return; + assert(!r->pending_index_entry); + WriteBlock(&r->data_block, &r->pending_handle); + if (ok()) { + r->pending_index_entry = true; + r->status = r->file->Flush(); + } + if (r->filter_block != NULL) { + r->filter_block->StartBlock(r->offset); + } +} + +void TableBuilder::WriteBlock(BlockBuilder* block, BlockHandle* handle) { + // File format contains a sequence of blocks where each block has: + // block_data: uint8[n] + // type: uint8 + // crc: uint32 + assert(ok()); + Rep* r = rep_; + Slice raw = block->Finish(); + + Slice block_contents; + CompressionType type = r->options.compression; + // TODO(postrelease): Support more compression options: zlib? + switch (type) { + case kNoCompression: + block_contents = raw; + break; + + case kSnappyCompression: { + std::string* compressed = &r->compressed_output; + if (port::Snappy_Compress(raw.data(), raw.size(), compressed) && + compressed->size() < raw.size() - (raw.size() / 8u)) { + block_contents = *compressed; + } else { + // Snappy not supported, or compressed less than 12.5%, so just + // store uncompressed form + block_contents = raw; + type = kNoCompression; + } + break; + } + } + WriteRawBlock(block_contents, type, handle); + r->compressed_output.clear(); + block->Reset(); +} + +void TableBuilder::WriteRawBlock(const Slice& block_contents, + CompressionType type, + BlockHandle* handle) { + Rep* r = rep_; + handle->set_offset(r->offset); + handle->set_size(block_contents.size()); + r->status = r->file->Append(block_contents); + if (r->status.ok()) { + char trailer[kBlockTrailerSize]; + trailer[0] = type; + uint32_t crc = crc32c::Value(block_contents.data(), block_contents.size()); + crc = crc32c::Extend(crc, trailer, 1); // Extend crc to cover block type + EncodeFixed32(trailer+1, crc32c::Mask(crc)); + r->status = r->file->Append(Slice(trailer, kBlockTrailerSize)); + if (r->status.ok()) { + r->offset += block_contents.size() + kBlockTrailerSize; + } + } +} + +Status TableBuilder::status() const { + return rep_->status; +} + +Status TableBuilder::Finish() { + Rep* r = rep_; + Flush(); + assert(!r->closed); + r->closed = true; + + BlockHandle filter_block_handle, metaindex_block_handle, index_block_handle; + + // Write filter block + if (ok() && r->filter_block != NULL) { + WriteRawBlock(r->filter_block->Finish(), kNoCompression, + &filter_block_handle); + } + + // Write metaindex block + if (ok()) { + BlockBuilder meta_index_block(&r->options); + if (r->filter_block != NULL) { + // Add mapping from "filter.Name" to location of filter data + std::string key = "filter."; + key.append(r->options.filter_policy->Name()); + std::string handle_encoding; + filter_block_handle.EncodeTo(&handle_encoding); + meta_index_block.Add(key, handle_encoding); + } + + // TODO(postrelease): Add stats and other meta blocks + WriteBlock(&meta_index_block, &metaindex_block_handle); + } + + // Write index block + if (ok()) { + if (r->pending_index_entry) { + r->options.comparator->FindShortSuccessor(&r->last_key); + std::string handle_encoding; + r->pending_handle.EncodeTo(&handle_encoding); + r->index_block.Add(r->last_key, Slice(handle_encoding)); + r->pending_index_entry = false; + } + WriteBlock(&r->index_block, &index_block_handle); + } + + // Write footer + if (ok()) { + Footer footer; + footer.set_metaindex_handle(metaindex_block_handle); + footer.set_index_handle(index_block_handle); + std::string footer_encoding; + footer.EncodeTo(&footer_encoding); + r->status = r->file->Append(footer_encoding); + if (r->status.ok()) { + r->offset += footer_encoding.size(); + } + } + return r->status; +} + +void TableBuilder::Abandon() { + Rep* r = rep_; + assert(!r->closed); + r->closed = true; +} + +uint64_t TableBuilder::NumEntries() const { + return rep_->num_entries; +} + +uint64_t TableBuilder::FileSize() const { + return rep_->offset; +} + +} // namespace leveldb diff --git a/src/leveldb/table/table_test.cc b/src/leveldb/table/table_test.cc new file mode 100644 index 0000000..c723bf8 --- /dev/null +++ b/src/leveldb/table/table_test.cc @@ -0,0 +1,868 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/table.h" + +#include +#include +#include "db/dbformat.h" +#include "db/memtable.h" +#include "db/write_batch_internal.h" +#include "leveldb/db.h" +#include "leveldb/env.h" +#include "leveldb/iterator.h" +#include "leveldb/table_builder.h" +#include "table/block.h" +#include "table/block_builder.h" +#include "table/format.h" +#include "util/random.h" +#include "util/testharness.h" +#include "util/testutil.h" + +namespace leveldb { + +// Return reverse of "key". +// Used to test non-lexicographic comparators. +static std::string Reverse(const Slice& key) { + std::string str(key.ToString()); + std::string rev(""); + for (std::string::reverse_iterator rit = str.rbegin(); + rit != str.rend(); ++rit) { + rev.push_back(*rit); + } + return rev; +} + +namespace { +class ReverseKeyComparator : public Comparator { + public: + virtual const char* Name() const { + return "leveldb.ReverseBytewiseComparator"; + } + + virtual int Compare(const Slice& a, const Slice& b) const { + return BytewiseComparator()->Compare(Reverse(a), Reverse(b)); + } + + virtual void FindShortestSeparator( + std::string* start, + const Slice& limit) const { + std::string s = Reverse(*start); + std::string l = Reverse(limit); + BytewiseComparator()->FindShortestSeparator(&s, l); + *start = Reverse(s); + } + + virtual void FindShortSuccessor(std::string* key) const { + std::string s = Reverse(*key); + BytewiseComparator()->FindShortSuccessor(&s); + *key = Reverse(s); + } +}; +} // namespace +static ReverseKeyComparator reverse_key_comparator; + +static void Increment(const Comparator* cmp, std::string* key) { + if (cmp == BytewiseComparator()) { + key->push_back('\0'); + } else { + assert(cmp == &reverse_key_comparator); + std::string rev = Reverse(*key); + rev.push_back('\0'); + *key = Reverse(rev); + } +} + +// An STL comparator that uses a Comparator +namespace { +struct STLLessThan { + const Comparator* cmp; + + STLLessThan() : cmp(BytewiseComparator()) { } + STLLessThan(const Comparator* c) : cmp(c) { } + bool operator()(const std::string& a, const std::string& b) const { + return cmp->Compare(Slice(a), Slice(b)) < 0; + } +}; +} // namespace + +class StringSink: public WritableFile { + public: + ~StringSink() { } + + const std::string& contents() const { return contents_; } + + virtual Status Close() { return Status::OK(); } + virtual Status Flush() { return Status::OK(); } + virtual Status Sync() { return Status::OK(); } + + virtual Status Append(const Slice& data) { + contents_.append(data.data(), data.size()); + return Status::OK(); + } + + private: + std::string contents_; +}; + + +class StringSource: public RandomAccessFile { + public: + StringSource(const Slice& contents) + : contents_(contents.data(), contents.size()) { + } + + virtual ~StringSource() { } + + uint64_t Size() const { return contents_.size(); } + + virtual Status Read(uint64_t offset, size_t n, Slice* result, + char* scratch) const { + if (offset > contents_.size()) { + return Status::InvalidArgument("invalid Read offset"); + } + if (offset + n > contents_.size()) { + n = contents_.size() - offset; + } + memcpy(scratch, &contents_[offset], n); + *result = Slice(scratch, n); + return Status::OK(); + } + + private: + std::string contents_; +}; + +typedef std::map KVMap; + +// Helper class for tests to unify the interface between +// BlockBuilder/TableBuilder and Block/Table. +class Constructor { + public: + explicit Constructor(const Comparator* cmp) : data_(STLLessThan(cmp)) { } + virtual ~Constructor() { } + + void Add(const std::string& key, const Slice& value) { + data_[key] = value.ToString(); + } + + // Finish constructing the data structure with all the keys that have + // been added so far. Returns the keys in sorted order in "*keys" + // and stores the key/value pairs in "*kvmap" + void Finish(const Options& options, + std::vector* keys, + KVMap* kvmap) { + *kvmap = data_; + keys->clear(); + for (KVMap::const_iterator it = data_.begin(); + it != data_.end(); + ++it) { + keys->push_back(it->first); + } + data_.clear(); + Status s = FinishImpl(options, *kvmap); + ASSERT_TRUE(s.ok()) << s.ToString(); + } + + // Construct the data structure from the data in "data" + virtual Status FinishImpl(const Options& options, const KVMap& data) = 0; + + virtual Iterator* NewIterator() const = 0; + + virtual const KVMap& data() { return data_; } + + virtual DB* db() const { return NULL; } // Overridden in DBConstructor + + private: + KVMap data_; +}; + +class BlockConstructor: public Constructor { + public: + explicit BlockConstructor(const Comparator* cmp) + : Constructor(cmp), + comparator_(cmp), + block_(NULL) { } + ~BlockConstructor() { + delete block_; + } + virtual Status FinishImpl(const Options& options, const KVMap& data) { + delete block_; + block_ = NULL; + BlockBuilder builder(&options); + + for (KVMap::const_iterator it = data.begin(); + it != data.end(); + ++it) { + builder.Add(it->first, it->second); + } + // Open the block + data_ = builder.Finish().ToString(); + BlockContents contents; + contents.data = data_; + contents.cachable = false; + contents.heap_allocated = false; + block_ = new Block(contents); + return Status::OK(); + } + virtual Iterator* NewIterator() const { + return block_->NewIterator(comparator_); + } + + private: + const Comparator* comparator_; + std::string data_; + Block* block_; + + BlockConstructor(); +}; + +class TableConstructor: public Constructor { + public: + TableConstructor(const Comparator* cmp) + : Constructor(cmp), + source_(NULL), table_(NULL) { + } + ~TableConstructor() { + Reset(); + } + virtual Status FinishImpl(const Options& options, const KVMap& data) { + Reset(); + StringSink sink; + TableBuilder builder(options, &sink); + + for (KVMap::const_iterator it = data.begin(); + it != data.end(); + ++it) { + builder.Add(it->first, it->second); + ASSERT_TRUE(builder.status().ok()); + } + Status s = builder.Finish(); + ASSERT_TRUE(s.ok()) << s.ToString(); + + ASSERT_EQ(sink.contents().size(), builder.FileSize()); + + // Open the table + source_ = new StringSource(sink.contents()); + Options table_options; + table_options.comparator = options.comparator; + return Table::Open(table_options, source_, sink.contents().size(), &table_); + } + + virtual Iterator* NewIterator() const { + return table_->NewIterator(ReadOptions()); + } + + uint64_t ApproximateOffsetOf(const Slice& key) const { + return table_->ApproximateOffsetOf(key); + } + + private: + void Reset() { + delete table_; + delete source_; + table_ = NULL; + source_ = NULL; + } + + StringSource* source_; + Table* table_; + + TableConstructor(); +}; + +// A helper class that converts internal format keys into user keys +class KeyConvertingIterator: public Iterator { + public: + explicit KeyConvertingIterator(Iterator* iter) : iter_(iter) { } + virtual ~KeyConvertingIterator() { delete iter_; } + virtual bool Valid() const { return iter_->Valid(); } + virtual void Seek(const Slice& target) { + ParsedInternalKey ikey(target, kMaxSequenceNumber, kTypeValue); + std::string encoded; + AppendInternalKey(&encoded, ikey); + iter_->Seek(encoded); + } + virtual void SeekToFirst() { iter_->SeekToFirst(); } + virtual void SeekToLast() { iter_->SeekToLast(); } + virtual void Next() { iter_->Next(); } + virtual void Prev() { iter_->Prev(); } + + virtual Slice key() const { + assert(Valid()); + ParsedInternalKey key; + if (!ParseInternalKey(iter_->key(), &key)) { + status_ = Status::Corruption("malformed internal key"); + return Slice("corrupted key"); + } + return key.user_key; + } + + virtual Slice value() const { return iter_->value(); } + virtual Status status() const { + return status_.ok() ? iter_->status() : status_; + } + + private: + mutable Status status_; + Iterator* iter_; + + // No copying allowed + KeyConvertingIterator(const KeyConvertingIterator&); + void operator=(const KeyConvertingIterator&); +}; + +class MemTableConstructor: public Constructor { + public: + explicit MemTableConstructor(const Comparator* cmp) + : Constructor(cmp), + internal_comparator_(cmp) { + memtable_ = new MemTable(internal_comparator_); + memtable_->Ref(); + } + ~MemTableConstructor() { + memtable_->Unref(); + } + virtual Status FinishImpl(const Options& options, const KVMap& data) { + memtable_->Unref(); + memtable_ = new MemTable(internal_comparator_); + memtable_->Ref(); + int seq = 1; + for (KVMap::const_iterator it = data.begin(); + it != data.end(); + ++it) { + memtable_->Add(seq, kTypeValue, it->first, it->second); + seq++; + } + return Status::OK(); + } + virtual Iterator* NewIterator() const { + return new KeyConvertingIterator(memtable_->NewIterator()); + } + + private: + InternalKeyComparator internal_comparator_; + MemTable* memtable_; +}; + +class DBConstructor: public Constructor { + public: + explicit DBConstructor(const Comparator* cmp) + : Constructor(cmp), + comparator_(cmp) { + db_ = NULL; + NewDB(); + } + ~DBConstructor() { + delete db_; + } + virtual Status FinishImpl(const Options& options, const KVMap& data) { + delete db_; + db_ = NULL; + NewDB(); + for (KVMap::const_iterator it = data.begin(); + it != data.end(); + ++it) { + WriteBatch batch; + batch.Put(it->first, it->second); + ASSERT_TRUE(db_->Write(WriteOptions(), &batch).ok()); + } + return Status::OK(); + } + virtual Iterator* NewIterator() const { + return db_->NewIterator(ReadOptions()); + } + + virtual DB* db() const { return db_; } + + private: + void NewDB() { + std::string name = test::TmpDir() + "/table_testdb"; + + Options options; + options.comparator = comparator_; + Status status = DestroyDB(name, options); + ASSERT_TRUE(status.ok()) << status.ToString(); + + options.create_if_missing = true; + options.error_if_exists = true; + options.write_buffer_size = 10000; // Something small to force merging + status = DB::Open(options, name, &db_); + ASSERT_TRUE(status.ok()) << status.ToString(); + } + + const Comparator* comparator_; + DB* db_; +}; + +enum TestType { + TABLE_TEST, + BLOCK_TEST, + MEMTABLE_TEST, + DB_TEST +}; + +struct TestArgs { + TestType type; + bool reverse_compare; + int restart_interval; +}; + +static const TestArgs kTestArgList[] = { + { TABLE_TEST, false, 16 }, + { TABLE_TEST, false, 1 }, + { TABLE_TEST, false, 1024 }, + { TABLE_TEST, true, 16 }, + { TABLE_TEST, true, 1 }, + { TABLE_TEST, true, 1024 }, + + { BLOCK_TEST, false, 16 }, + { BLOCK_TEST, false, 1 }, + { BLOCK_TEST, false, 1024 }, + { BLOCK_TEST, true, 16 }, + { BLOCK_TEST, true, 1 }, + { BLOCK_TEST, true, 1024 }, + + // Restart interval does not matter for memtables + { MEMTABLE_TEST, false, 16 }, + { MEMTABLE_TEST, true, 16 }, + + // Do not bother with restart interval variations for DB + { DB_TEST, false, 16 }, + { DB_TEST, true, 16 }, +}; +static const int kNumTestArgs = sizeof(kTestArgList) / sizeof(kTestArgList[0]); + +class Harness { + public: + Harness() : constructor_(NULL) { } + + void Init(const TestArgs& args) { + delete constructor_; + constructor_ = NULL; + options_ = Options(); + + options_.block_restart_interval = args.restart_interval; + // Use shorter block size for tests to exercise block boundary + // conditions more. + options_.block_size = 256; + if (args.reverse_compare) { + options_.comparator = &reverse_key_comparator; + } + switch (args.type) { + case TABLE_TEST: + constructor_ = new TableConstructor(options_.comparator); + break; + case BLOCK_TEST: + constructor_ = new BlockConstructor(options_.comparator); + break; + case MEMTABLE_TEST: + constructor_ = new MemTableConstructor(options_.comparator); + break; + case DB_TEST: + constructor_ = new DBConstructor(options_.comparator); + break; + } + } + + ~Harness() { + delete constructor_; + } + + void Add(const std::string& key, const std::string& value) { + constructor_->Add(key, value); + } + + void Test(Random* rnd) { + std::vector keys; + KVMap data; + constructor_->Finish(options_, &keys, &data); + + TestForwardScan(keys, data); + TestBackwardScan(keys, data); + TestRandomAccess(rnd, keys, data); + } + + void TestForwardScan(const std::vector& keys, + const KVMap& data) { + Iterator* iter = constructor_->NewIterator(); + ASSERT_TRUE(!iter->Valid()); + iter->SeekToFirst(); + for (KVMap::const_iterator model_iter = data.begin(); + model_iter != data.end(); + ++model_iter) { + ASSERT_EQ(ToString(data, model_iter), ToString(iter)); + iter->Next(); + } + ASSERT_TRUE(!iter->Valid()); + delete iter; + } + + void TestBackwardScan(const std::vector& keys, + const KVMap& data) { + Iterator* iter = constructor_->NewIterator(); + ASSERT_TRUE(!iter->Valid()); + iter->SeekToLast(); + for (KVMap::const_reverse_iterator model_iter = data.rbegin(); + model_iter != data.rend(); + ++model_iter) { + ASSERT_EQ(ToString(data, model_iter), ToString(iter)); + iter->Prev(); + } + ASSERT_TRUE(!iter->Valid()); + delete iter; + } + + void TestRandomAccess(Random* rnd, + const std::vector& keys, + const KVMap& data) { + static const bool kVerbose = false; + Iterator* iter = constructor_->NewIterator(); + ASSERT_TRUE(!iter->Valid()); + KVMap::const_iterator model_iter = data.begin(); + if (kVerbose) fprintf(stderr, "---\n"); + for (int i = 0; i < 200; i++) { + const int toss = rnd->Uniform(5); + switch (toss) { + case 0: { + if (iter->Valid()) { + if (kVerbose) fprintf(stderr, "Next\n"); + iter->Next(); + ++model_iter; + ASSERT_EQ(ToString(data, model_iter), ToString(iter)); + } + break; + } + + case 1: { + if (kVerbose) fprintf(stderr, "SeekToFirst\n"); + iter->SeekToFirst(); + model_iter = data.begin(); + ASSERT_EQ(ToString(data, model_iter), ToString(iter)); + break; + } + + case 2: { + std::string key = PickRandomKey(rnd, keys); + model_iter = data.lower_bound(key); + if (kVerbose) fprintf(stderr, "Seek '%s'\n", + EscapeString(key).c_str()); + iter->Seek(Slice(key)); + ASSERT_EQ(ToString(data, model_iter), ToString(iter)); + break; + } + + case 3: { + if (iter->Valid()) { + if (kVerbose) fprintf(stderr, "Prev\n"); + iter->Prev(); + if (model_iter == data.begin()) { + model_iter = data.end(); // Wrap around to invalid value + } else { + --model_iter; + } + ASSERT_EQ(ToString(data, model_iter), ToString(iter)); + } + break; + } + + case 4: { + if (kVerbose) fprintf(stderr, "SeekToLast\n"); + iter->SeekToLast(); + if (keys.empty()) { + model_iter = data.end(); + } else { + std::string last = data.rbegin()->first; + model_iter = data.lower_bound(last); + } + ASSERT_EQ(ToString(data, model_iter), ToString(iter)); + break; + } + } + } + delete iter; + } + + std::string ToString(const KVMap& data, const KVMap::const_iterator& it) { + if (it == data.end()) { + return "END"; + } else { + return "'" + it->first + "->" + it->second + "'"; + } + } + + std::string ToString(const KVMap& data, + const KVMap::const_reverse_iterator& it) { + if (it == data.rend()) { + return "END"; + } else { + return "'" + it->first + "->" + it->second + "'"; + } + } + + std::string ToString(const Iterator* it) { + if (!it->Valid()) { + return "END"; + } else { + return "'" + it->key().ToString() + "->" + it->value().ToString() + "'"; + } + } + + std::string PickRandomKey(Random* rnd, const std::vector& keys) { + if (keys.empty()) { + return "foo"; + } else { + const int index = rnd->Uniform(keys.size()); + std::string result = keys[index]; + switch (rnd->Uniform(3)) { + case 0: + // Return an existing key + break; + case 1: { + // Attempt to return something smaller than an existing key + if (result.size() > 0 && result[result.size()-1] > '\0') { + result[result.size()-1]--; + } + break; + } + case 2: { + // Return something larger than an existing key + Increment(options_.comparator, &result); + break; + } + } + return result; + } + } + + // Returns NULL if not running against a DB + DB* db() const { return constructor_->db(); } + + private: + Options options_; + Constructor* constructor_; +}; + +// Test empty table/block. +TEST(Harness, Empty) { + for (int i = 0; i < kNumTestArgs; i++) { + Init(kTestArgList[i]); + Random rnd(test::RandomSeed() + 1); + Test(&rnd); + } +} + +// Special test for a block with no restart entries. The C++ leveldb +// code never generates such blocks, but the Java version of leveldb +// seems to. +TEST(Harness, ZeroRestartPointsInBlock) { + char data[sizeof(uint32_t)]; + memset(data, 0, sizeof(data)); + BlockContents contents; + contents.data = Slice(data, sizeof(data)); + contents.cachable = false; + contents.heap_allocated = false; + Block block(contents); + Iterator* iter = block.NewIterator(BytewiseComparator()); + iter->SeekToFirst(); + ASSERT_TRUE(!iter->Valid()); + iter->SeekToLast(); + ASSERT_TRUE(!iter->Valid()); + iter->Seek("foo"); + ASSERT_TRUE(!iter->Valid()); + delete iter; +} + +// Test the empty key +TEST(Harness, SimpleEmptyKey) { + for (int i = 0; i < kNumTestArgs; i++) { + Init(kTestArgList[i]); + Random rnd(test::RandomSeed() + 1); + Add("", "v"); + Test(&rnd); + } +} + +TEST(Harness, SimpleSingle) { + for (int i = 0; i < kNumTestArgs; i++) { + Init(kTestArgList[i]); + Random rnd(test::RandomSeed() + 2); + Add("abc", "v"); + Test(&rnd); + } +} + +TEST(Harness, SimpleMulti) { + for (int i = 0; i < kNumTestArgs; i++) { + Init(kTestArgList[i]); + Random rnd(test::RandomSeed() + 3); + Add("abc", "v"); + Add("abcd", "v"); + Add("ac", "v2"); + Test(&rnd); + } +} + +TEST(Harness, SimpleSpecialKey) { + for (int i = 0; i < kNumTestArgs; i++) { + Init(kTestArgList[i]); + Random rnd(test::RandomSeed() + 4); + Add("\xff\xff", "v3"); + Test(&rnd); + } +} + +TEST(Harness, Randomized) { + for (int i = 0; i < kNumTestArgs; i++) { + Init(kTestArgList[i]); + Random rnd(test::RandomSeed() + 5); + for (int num_entries = 0; num_entries < 2000; + num_entries += (num_entries < 50 ? 1 : 200)) { + if ((num_entries % 10) == 0) { + fprintf(stderr, "case %d of %d: num_entries = %d\n", + (i + 1), int(kNumTestArgs), num_entries); + } + for (int e = 0; e < num_entries; e++) { + std::string v; + Add(test::RandomKey(&rnd, rnd.Skewed(4)), + test::RandomString(&rnd, rnd.Skewed(5), &v).ToString()); + } + Test(&rnd); + } + } +} + +TEST(Harness, RandomizedLongDB) { + Random rnd(test::RandomSeed()); + TestArgs args = { DB_TEST, false, 16 }; + Init(args); + int num_entries = 100000; + for (int e = 0; e < num_entries; e++) { + std::string v; + Add(test::RandomKey(&rnd, rnd.Skewed(4)), + test::RandomString(&rnd, rnd.Skewed(5), &v).ToString()); + } + Test(&rnd); + + // We must have created enough data to force merging + int files = 0; + for (int level = 0; level < config::kNumLevels; level++) { + std::string value; + char name[100]; + snprintf(name, sizeof(name), "leveldb.num-files-at-level%d", level); + ASSERT_TRUE(db()->GetProperty(name, &value)); + files += atoi(value.c_str()); + } + ASSERT_GT(files, 0); +} + +class MemTableTest { }; + +TEST(MemTableTest, Simple) { + InternalKeyComparator cmp(BytewiseComparator()); + MemTable* memtable = new MemTable(cmp); + memtable->Ref(); + WriteBatch batch; + WriteBatchInternal::SetSequence(&batch, 100); + batch.Put(std::string("k1"), std::string("v1")); + batch.Put(std::string("k2"), std::string("v2")); + batch.Put(std::string("k3"), std::string("v3")); + batch.Put(std::string("largekey"), std::string("vlarge")); + ASSERT_TRUE(WriteBatchInternal::InsertInto(&batch, memtable).ok()); + + Iterator* iter = memtable->NewIterator(); + iter->SeekToFirst(); + while (iter->Valid()) { + fprintf(stderr, "key: '%s' -> '%s'\n", + iter->key().ToString().c_str(), + iter->value().ToString().c_str()); + iter->Next(); + } + + delete iter; + memtable->Unref(); +} + +static bool Between(uint64_t val, uint64_t low, uint64_t high) { + bool result = (val >= low) && (val <= high); + if (!result) { + fprintf(stderr, "Value %llu is not in range [%llu, %llu]\n", + (unsigned long long)(val), + (unsigned long long)(low), + (unsigned long long)(high)); + } + return result; +} + +class TableTest { }; + +TEST(TableTest, ApproximateOffsetOfPlain) { + TableConstructor c(BytewiseComparator()); + c.Add("k01", "hello"); + c.Add("k02", "hello2"); + c.Add("k03", std::string(10000, 'x')); + c.Add("k04", std::string(200000, 'x')); + c.Add("k05", std::string(300000, 'x')); + c.Add("k06", "hello3"); + c.Add("k07", std::string(100000, 'x')); + std::vector keys; + KVMap kvmap; + Options options; + options.block_size = 1024; + options.compression = kNoCompression; + c.Finish(options, &keys, &kvmap); + + ASSERT_TRUE(Between(c.ApproximateOffsetOf("abc"), 0, 0)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k01"), 0, 0)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k01a"), 0, 0)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k02"), 0, 0)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k03"), 0, 0)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k04"), 10000, 11000)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k04a"), 210000, 211000)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k05"), 210000, 211000)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k06"), 510000, 511000)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k07"), 510000, 511000)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("xyz"), 610000, 612000)); + +} + +static bool SnappyCompressionSupported() { + std::string out; + Slice in = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + return port::Snappy_Compress(in.data(), in.size(), &out); +} + +TEST(TableTest, ApproximateOffsetOfCompressed) { + if (!SnappyCompressionSupported()) { + fprintf(stderr, "skipping compression tests\n"); + return; + } + + Random rnd(301); + TableConstructor c(BytewiseComparator()); + std::string tmp; + c.Add("k01", "hello"); + c.Add("k02", test::CompressibleString(&rnd, 0.25, 10000, &tmp)); + c.Add("k03", "hello3"); + c.Add("k04", test::CompressibleString(&rnd, 0.25, 10000, &tmp)); + std::vector keys; + KVMap kvmap; + Options options; + options.block_size = 1024; + options.compression = kSnappyCompression; + c.Finish(options, &keys, &kvmap); + + ASSERT_TRUE(Between(c.ApproximateOffsetOf("abc"), 0, 0)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k01"), 0, 0)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k02"), 0, 0)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k03"), 2000, 3000)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("k04"), 2000, 3000)); + ASSERT_TRUE(Between(c.ApproximateOffsetOf("xyz"), 4000, 6000)); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/table/two_level_iterator.cc b/src/leveldb/table/two_level_iterator.cc new file mode 100644 index 0000000..7822eba --- /dev/null +++ b/src/leveldb/table/two_level_iterator.cc @@ -0,0 +1,182 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "table/two_level_iterator.h" + +#include "leveldb/table.h" +#include "table/block.h" +#include "table/format.h" +#include "table/iterator_wrapper.h" + +namespace leveldb { + +namespace { + +typedef Iterator* (*BlockFunction)(void*, const ReadOptions&, const Slice&); + +class TwoLevelIterator: public Iterator { + public: + TwoLevelIterator( + Iterator* index_iter, + BlockFunction block_function, + void* arg, + const ReadOptions& options); + + virtual ~TwoLevelIterator(); + + virtual void Seek(const Slice& target); + virtual void SeekToFirst(); + virtual void SeekToLast(); + virtual void Next(); + virtual void Prev(); + + virtual bool Valid() const { + return data_iter_.Valid(); + } + virtual Slice key() const { + assert(Valid()); + return data_iter_.key(); + } + virtual Slice value() const { + assert(Valid()); + return data_iter_.value(); + } + virtual Status status() const { + // It'd be nice if status() returned a const Status& instead of a Status + if (!index_iter_.status().ok()) { + return index_iter_.status(); + } else if (data_iter_.iter() != NULL && !data_iter_.status().ok()) { + return data_iter_.status(); + } else { + return status_; + } + } + + private: + void SaveError(const Status& s) { + if (status_.ok() && !s.ok()) status_ = s; + } + void SkipEmptyDataBlocksForward(); + void SkipEmptyDataBlocksBackward(); + void SetDataIterator(Iterator* data_iter); + void InitDataBlock(); + + BlockFunction block_function_; + void* arg_; + const ReadOptions options_; + Status status_; + IteratorWrapper index_iter_; + IteratorWrapper data_iter_; // May be NULL + // If data_iter_ is non-NULL, then "data_block_handle_" holds the + // "index_value" passed to block_function_ to create the data_iter_. + std::string data_block_handle_; +}; + +TwoLevelIterator::TwoLevelIterator( + Iterator* index_iter, + BlockFunction block_function, + void* arg, + const ReadOptions& options) + : block_function_(block_function), + arg_(arg), + options_(options), + index_iter_(index_iter), + data_iter_(NULL) { +} + +TwoLevelIterator::~TwoLevelIterator() { +} + +void TwoLevelIterator::Seek(const Slice& target) { + index_iter_.Seek(target); + InitDataBlock(); + if (data_iter_.iter() != NULL) data_iter_.Seek(target); + SkipEmptyDataBlocksForward(); +} + +void TwoLevelIterator::SeekToFirst() { + index_iter_.SeekToFirst(); + InitDataBlock(); + if (data_iter_.iter() != NULL) data_iter_.SeekToFirst(); + SkipEmptyDataBlocksForward(); +} + +void TwoLevelIterator::SeekToLast() { + index_iter_.SeekToLast(); + InitDataBlock(); + if (data_iter_.iter() != NULL) data_iter_.SeekToLast(); + SkipEmptyDataBlocksBackward(); +} + +void TwoLevelIterator::Next() { + assert(Valid()); + data_iter_.Next(); + SkipEmptyDataBlocksForward(); +} + +void TwoLevelIterator::Prev() { + assert(Valid()); + data_iter_.Prev(); + SkipEmptyDataBlocksBackward(); +} + + +void TwoLevelIterator::SkipEmptyDataBlocksForward() { + while (data_iter_.iter() == NULL || !data_iter_.Valid()) { + // Move to next block + if (!index_iter_.Valid()) { + SetDataIterator(NULL); + return; + } + index_iter_.Next(); + InitDataBlock(); + if (data_iter_.iter() != NULL) data_iter_.SeekToFirst(); + } +} + +void TwoLevelIterator::SkipEmptyDataBlocksBackward() { + while (data_iter_.iter() == NULL || !data_iter_.Valid()) { + // Move to next block + if (!index_iter_.Valid()) { + SetDataIterator(NULL); + return; + } + index_iter_.Prev(); + InitDataBlock(); + if (data_iter_.iter() != NULL) data_iter_.SeekToLast(); + } +} + +void TwoLevelIterator::SetDataIterator(Iterator* data_iter) { + if (data_iter_.iter() != NULL) SaveError(data_iter_.status()); + data_iter_.Set(data_iter); +} + +void TwoLevelIterator::InitDataBlock() { + if (!index_iter_.Valid()) { + SetDataIterator(NULL); + } else { + Slice handle = index_iter_.value(); + if (data_iter_.iter() != NULL && handle.compare(data_block_handle_) == 0) { + // data_iter_ is already constructed with this iterator, so + // no need to change anything + } else { + Iterator* iter = (*block_function_)(arg_, options_, handle); + data_block_handle_.assign(handle.data(), handle.size()); + SetDataIterator(iter); + } + } +} + +} // namespace + +Iterator* NewTwoLevelIterator( + Iterator* index_iter, + BlockFunction block_function, + void* arg, + const ReadOptions& options) { + return new TwoLevelIterator(index_iter, block_function, arg, options); +} + +} // namespace leveldb diff --git a/src/leveldb/table/two_level_iterator.h b/src/leveldb/table/two_level_iterator.h new file mode 100644 index 0000000..629ca34 --- /dev/null +++ b/src/leveldb/table/two_level_iterator.h @@ -0,0 +1,34 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_TABLE_TWO_LEVEL_ITERATOR_H_ +#define STORAGE_LEVELDB_TABLE_TWO_LEVEL_ITERATOR_H_ + +#include "leveldb/iterator.h" + +namespace leveldb { + +struct ReadOptions; + +// Return a new two level iterator. A two-level iterator contains an +// index iterator whose values point to a sequence of blocks where +// each block is itself a sequence of key,value pairs. The returned +// two-level iterator yields the concatenation of all key/value pairs +// in the sequence of blocks. Takes ownership of "index_iter" and +// will delete it when no longer needed. +// +// Uses a supplied function to convert an index_iter value into +// an iterator over the contents of the corresponding block. +extern Iterator* NewTwoLevelIterator( + Iterator* index_iter, + Iterator* (*block_function)( + void* arg, + const ReadOptions& options, + const Slice& index_value), + void* arg, + const ReadOptions& options); + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_TABLE_TWO_LEVEL_ITERATOR_H_ diff --git a/src/leveldb/util/arena.cc b/src/leveldb/util/arena.cc new file mode 100644 index 0000000..9367f71 --- /dev/null +++ b/src/leveldb/util/arena.cc @@ -0,0 +1,68 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "util/arena.h" +#include + +namespace leveldb { + +static const int kBlockSize = 4096; + +Arena::Arena() { + blocks_memory_ = 0; + alloc_ptr_ = NULL; // First allocation will allocate a block + alloc_bytes_remaining_ = 0; +} + +Arena::~Arena() { + for (size_t i = 0; i < blocks_.size(); i++) { + delete[] blocks_[i]; + } +} + +char* Arena::AllocateFallback(size_t bytes) { + if (bytes > kBlockSize / 4) { + // Object is more than a quarter of our block size. Allocate it separately + // to avoid wasting too much space in leftover bytes. + char* result = AllocateNewBlock(bytes); + return result; + } + + // We waste the remaining space in the current block. + alloc_ptr_ = AllocateNewBlock(kBlockSize); + alloc_bytes_remaining_ = kBlockSize; + + char* result = alloc_ptr_; + alloc_ptr_ += bytes; + alloc_bytes_remaining_ -= bytes; + return result; +} + +char* Arena::AllocateAligned(size_t bytes) { + const int align = (sizeof(void*) > 8) ? sizeof(void*) : 8; + assert((align & (align-1)) == 0); // Pointer size should be a power of 2 + size_t current_mod = reinterpret_cast(alloc_ptr_) & (align-1); + size_t slop = (current_mod == 0 ? 0 : align - current_mod); + size_t needed = bytes + slop; + char* result; + if (needed <= alloc_bytes_remaining_) { + result = alloc_ptr_ + slop; + alloc_ptr_ += needed; + alloc_bytes_remaining_ -= needed; + } else { + // AllocateFallback always returned aligned memory + result = AllocateFallback(bytes); + } + assert((reinterpret_cast(result) & (align-1)) == 0); + return result; +} + +char* Arena::AllocateNewBlock(size_t block_bytes) { + char* result = new char[block_bytes]; + blocks_memory_ += block_bytes; + blocks_.push_back(result); + return result; +} + +} // namespace leveldb diff --git a/src/leveldb/util/arena.h b/src/leveldb/util/arena.h new file mode 100644 index 0000000..73bbf1c --- /dev/null +++ b/src/leveldb/util/arena.h @@ -0,0 +1,68 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_UTIL_ARENA_H_ +#define STORAGE_LEVELDB_UTIL_ARENA_H_ + +#include +#include +#include +#include + +namespace leveldb { + +class Arena { + public: + Arena(); + ~Arena(); + + // Return a pointer to a newly allocated memory block of "bytes" bytes. + char* Allocate(size_t bytes); + + // Allocate memory with the normal alignment guarantees provided by malloc + char* AllocateAligned(size_t bytes); + + // Returns an estimate of the total memory usage of data allocated + // by the arena (including space allocated but not yet used for user + // allocations). + size_t MemoryUsage() const { + return blocks_memory_ + blocks_.capacity() * sizeof(char*); + } + + private: + char* AllocateFallback(size_t bytes); + char* AllocateNewBlock(size_t block_bytes); + + // Allocation state + char* alloc_ptr_; + size_t alloc_bytes_remaining_; + + // Array of new[] allocated memory blocks + std::vector blocks_; + + // Bytes of memory in blocks allocated so far + size_t blocks_memory_; + + // No copying allowed + Arena(const Arena&); + void operator=(const Arena&); +}; + +inline char* Arena::Allocate(size_t bytes) { + // The semantics of what to return are a bit messy if we allow + // 0-byte allocations, so we disallow them here (we don't need + // them for our internal use). + assert(bytes > 0); + if (bytes <= alloc_bytes_remaining_) { + char* result = alloc_ptr_; + alloc_ptr_ += bytes; + alloc_bytes_remaining_ -= bytes; + return result; + } + return AllocateFallback(bytes); +} + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_UTIL_ARENA_H_ diff --git a/src/leveldb/util/arena_test.cc b/src/leveldb/util/arena_test.cc new file mode 100644 index 0000000..58e870e --- /dev/null +++ b/src/leveldb/util/arena_test.cc @@ -0,0 +1,68 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "util/arena.h" + +#include "util/random.h" +#include "util/testharness.h" + +namespace leveldb { + +class ArenaTest { }; + +TEST(ArenaTest, Empty) { + Arena arena; +} + +TEST(ArenaTest, Simple) { + std::vector > allocated; + Arena arena; + const int N = 100000; + size_t bytes = 0; + Random rnd(301); + for (int i = 0; i < N; i++) { + size_t s; + if (i % (N / 10) == 0) { + s = i; + } else { + s = rnd.OneIn(4000) ? rnd.Uniform(6000) : + (rnd.OneIn(10) ? rnd.Uniform(100) : rnd.Uniform(20)); + } + if (s == 0) { + // Our arena disallows size 0 allocations. + s = 1; + } + char* r; + if (rnd.OneIn(10)) { + r = arena.AllocateAligned(s); + } else { + r = arena.Allocate(s); + } + + for (size_t b = 0; b < s; b++) { + // Fill the "i"th allocation with a known bit pattern + r[b] = i % 256; + } + bytes += s; + allocated.push_back(std::make_pair(s, r)); + ASSERT_GE(arena.MemoryUsage(), bytes); + if (i > N/10) { + ASSERT_LE(arena.MemoryUsage(), bytes * 1.10); + } + } + for (size_t i = 0; i < allocated.size(); i++) { + size_t num_bytes = allocated[i].first; + const char* p = allocated[i].second; + for (size_t b = 0; b < num_bytes; b++) { + // Check the "i"th allocation for the known bit pattern + ASSERT_EQ(int(p[b]) & 0xff, i % 256); + } + } +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/util/bloom.cc b/src/leveldb/util/bloom.cc new file mode 100644 index 0000000..d7941cd --- /dev/null +++ b/src/leveldb/util/bloom.cc @@ -0,0 +1,95 @@ +// Copyright (c) 2012 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/filter_policy.h" + +#include "leveldb/slice.h" +#include "util/hash.h" + +namespace leveldb { + +namespace { +static uint32_t BloomHash(const Slice& key) { + return Hash(key.data(), key.size(), 0xbc9f1d34); +} + +class BloomFilterPolicy : public FilterPolicy { + private: + size_t bits_per_key_; + size_t k_; + + public: + explicit BloomFilterPolicy(int bits_per_key) + : bits_per_key_(bits_per_key) { + // We intentionally round down to reduce probing cost a little bit + k_ = static_cast(bits_per_key * 0.69); // 0.69 =~ ln(2) + if (k_ < 1) k_ = 1; + if (k_ > 30) k_ = 30; + } + + virtual const char* Name() const { + return "leveldb.BuiltinBloomFilter"; + } + + virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const { + // Compute bloom filter size (in both bits and bytes) + size_t bits = n * bits_per_key_; + + // For small n, we can see a very high false positive rate. Fix it + // by enforcing a minimum bloom filter length. + if (bits < 64) bits = 64; + + size_t bytes = (bits + 7) / 8; + bits = bytes * 8; + + const size_t init_size = dst->size(); + dst->resize(init_size + bytes, 0); + dst->push_back(static_cast(k_)); // Remember # of probes in filter + char* array = &(*dst)[init_size]; + for (size_t i = 0; i < n; i++) { + // Use double-hashing to generate a sequence of hash values. + // See analysis in [Kirsch,Mitzenmacher 2006]. + uint32_t h = BloomHash(keys[i]); + const uint32_t delta = (h >> 17) | (h << 15); // Rotate right 17 bits + for (size_t j = 0; j < k_; j++) { + const uint32_t bitpos = h % bits; + array[bitpos/8] |= (1 << (bitpos % 8)); + h += delta; + } + } + } + + virtual bool KeyMayMatch(const Slice& key, const Slice& bloom_filter) const { + const size_t len = bloom_filter.size(); + if (len < 2) return false; + + const char* array = bloom_filter.data(); + const size_t bits = (len - 1) * 8; + + // Use the encoded k so that we can read filters generated by + // bloom filters created using different parameters. + const size_t k = array[len-1]; + if (k > 30) { + // Reserved for potentially new encodings for short bloom filters. + // Consider it a match. + return true; + } + + uint32_t h = BloomHash(key); + const uint32_t delta = (h >> 17) | (h << 15); // Rotate right 17 bits + for (size_t j = 0; j < k; j++) { + const uint32_t bitpos = h % bits; + if ((array[bitpos/8] & (1 << (bitpos % 8))) == 0) return false; + h += delta; + } + return true; + } +}; +} + +const FilterPolicy* NewBloomFilterPolicy(int bits_per_key) { + return new BloomFilterPolicy(bits_per_key); +} + +} // namespace leveldb diff --git a/src/leveldb/util/bloom_test.cc b/src/leveldb/util/bloom_test.cc new file mode 100644 index 0000000..77fb1b3 --- /dev/null +++ b/src/leveldb/util/bloom_test.cc @@ -0,0 +1,161 @@ +// Copyright (c) 2012 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/filter_policy.h" + +#include "util/coding.h" +#include "util/logging.h" +#include "util/testharness.h" +#include "util/testutil.h" + +namespace leveldb { + +static const int kVerbose = 1; + +static Slice Key(int i, char* buffer) { + EncodeFixed32(buffer, i); + return Slice(buffer, sizeof(uint32_t)); +} + +class BloomTest { + private: + const FilterPolicy* policy_; + std::string filter_; + std::vector keys_; + + public: + BloomTest() : policy_(NewBloomFilterPolicy(10)) { } + + ~BloomTest() { + delete policy_; + } + + void Reset() { + keys_.clear(); + filter_.clear(); + } + + void Add(const Slice& s) { + keys_.push_back(s.ToString()); + } + + void Build() { + std::vector key_slices; + for (size_t i = 0; i < keys_.size(); i++) { + key_slices.push_back(Slice(keys_[i])); + } + filter_.clear(); + policy_->CreateFilter(&key_slices[0], key_slices.size(), &filter_); + keys_.clear(); + if (kVerbose >= 2) DumpFilter(); + } + + size_t FilterSize() const { + return filter_.size(); + } + + void DumpFilter() { + fprintf(stderr, "F("); + for (size_t i = 0; i+1 < filter_.size(); i++) { + const unsigned int c = static_cast(filter_[i]); + for (int j = 0; j < 8; j++) { + fprintf(stderr, "%c", (c & (1 <KeyMayMatch(s, filter_); + } + + double FalsePositiveRate() { + char buffer[sizeof(int)]; + int result = 0; + for (int i = 0; i < 10000; i++) { + if (Matches(Key(i + 1000000000, buffer))) { + result++; + } + } + return result / 10000.0; + } +}; + +TEST(BloomTest, EmptyFilter) { + ASSERT_TRUE(! Matches("hello")); + ASSERT_TRUE(! Matches("world")); +} + +TEST(BloomTest, Small) { + Add("hello"); + Add("world"); + ASSERT_TRUE(Matches("hello")); + ASSERT_TRUE(Matches("world")); + ASSERT_TRUE(! Matches("x")); + ASSERT_TRUE(! Matches("foo")); +} + +static int NextLength(int length) { + if (length < 10) { + length += 1; + } else if (length < 100) { + length += 10; + } else if (length < 1000) { + length += 100; + } else { + length += 1000; + } + return length; +} + +TEST(BloomTest, VaryingLengths) { + char buffer[sizeof(int)]; + + // Count number of filters that significantly exceed the false positive rate + int mediocre_filters = 0; + int good_filters = 0; + + for (int length = 1; length <= 10000; length = NextLength(length)) { + Reset(); + for (int i = 0; i < length; i++) { + Add(Key(i, buffer)); + } + Build(); + + ASSERT_LE(FilterSize(), static_cast((length * 10 / 8) + 40)) + << length; + + // All added keys must match + for (int i = 0; i < length; i++) { + ASSERT_TRUE(Matches(Key(i, buffer))) + << "Length " << length << "; key " << i; + } + + // Check false positive rate + double rate = FalsePositiveRate(); + if (kVerbose >= 1) { + fprintf(stderr, "False positives: %5.2f%% @ length = %6d ; bytes = %6d\n", + rate*100.0, length, static_cast(FilterSize())); + } + ASSERT_LE(rate, 0.02); // Must not be over 2% + if (rate > 0.0125) mediocre_filters++; // Allowed, but not too often + else good_filters++; + } + if (kVerbose >= 1) { + fprintf(stderr, "Filters: %d good, %d mediocre\n", + good_filters, mediocre_filters); + } + ASSERT_LE(mediocre_filters, good_filters/5); +} + +// Different bits-per-byte + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/util/cache.cc b/src/leveldb/util/cache.cc new file mode 100644 index 0000000..8b197bc --- /dev/null +++ b/src/leveldb/util/cache.cc @@ -0,0 +1,325 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include +#include +#include + +#include "leveldb/cache.h" +#include "port/port.h" +#include "util/hash.h" +#include "util/mutexlock.h" + +namespace leveldb { + +Cache::~Cache() { +} + +namespace { + +// LRU cache implementation + +// An entry is a variable length heap-allocated structure. Entries +// are kept in a circular doubly linked list ordered by access time. +struct LRUHandle { + void* value; + void (*deleter)(const Slice&, void* value); + LRUHandle* next_hash; + LRUHandle* next; + LRUHandle* prev; + size_t charge; // TODO(opt): Only allow uint32_t? + size_t key_length; + uint32_t refs; + uint32_t hash; // Hash of key(); used for fast sharding and comparisons + char key_data[1]; // Beginning of key + + Slice key() const { + // For cheaper lookups, we allow a temporary Handle object + // to store a pointer to a key in "value". + if (next == this) { + return *(reinterpret_cast(value)); + } else { + return Slice(key_data, key_length); + } + } +}; + +// We provide our own simple hash table since it removes a whole bunch +// of porting hacks and is also faster than some of the built-in hash +// table implementations in some of the compiler/runtime combinations +// we have tested. E.g., readrandom speeds up by ~5% over the g++ +// 4.4.3's builtin hashtable. +class HandleTable { + public: + HandleTable() : length_(0), elems_(0), list_(NULL) { Resize(); } + ~HandleTable() { delete[] list_; } + + LRUHandle* Lookup(const Slice& key, uint32_t hash) { + return *FindPointer(key, hash); + } + + LRUHandle* Insert(LRUHandle* h) { + LRUHandle** ptr = FindPointer(h->key(), h->hash); + LRUHandle* old = *ptr; + h->next_hash = (old == NULL ? NULL : old->next_hash); + *ptr = h; + if (old == NULL) { + ++elems_; + if (elems_ > length_) { + // Since each cache entry is fairly large, we aim for a small + // average linked list length (<= 1). + Resize(); + } + } + return old; + } + + LRUHandle* Remove(const Slice& key, uint32_t hash) { + LRUHandle** ptr = FindPointer(key, hash); + LRUHandle* result = *ptr; + if (result != NULL) { + *ptr = result->next_hash; + --elems_; + } + return result; + } + + private: + // The table consists of an array of buckets where each bucket is + // a linked list of cache entries that hash into the bucket. + uint32_t length_; + uint32_t elems_; + LRUHandle** list_; + + // Return a pointer to slot that points to a cache entry that + // matches key/hash. If there is no such cache entry, return a + // pointer to the trailing slot in the corresponding linked list. + LRUHandle** FindPointer(const Slice& key, uint32_t hash) { + LRUHandle** ptr = &list_[hash & (length_ - 1)]; + while (*ptr != NULL && + ((*ptr)->hash != hash || key != (*ptr)->key())) { + ptr = &(*ptr)->next_hash; + } + return ptr; + } + + void Resize() { + uint32_t new_length = 4; + while (new_length < elems_) { + new_length *= 2; + } + LRUHandle** new_list = new LRUHandle*[new_length]; + memset(new_list, 0, sizeof(new_list[0]) * new_length); + uint32_t count = 0; + for (uint32_t i = 0; i < length_; i++) { + LRUHandle* h = list_[i]; + while (h != NULL) { + LRUHandle* next = h->next_hash; + uint32_t hash = h->hash; + LRUHandle** ptr = &new_list[hash & (new_length - 1)]; + h->next_hash = *ptr; + *ptr = h; + h = next; + count++; + } + } + assert(elems_ == count); + delete[] list_; + list_ = new_list; + length_ = new_length; + } +}; + +// A single shard of sharded cache. +class LRUCache { + public: + LRUCache(); + ~LRUCache(); + + // Separate from constructor so caller can easily make an array of LRUCache + void SetCapacity(size_t capacity) { capacity_ = capacity; } + + // Like Cache methods, but with an extra "hash" parameter. + Cache::Handle* Insert(const Slice& key, uint32_t hash, + void* value, size_t charge, + void (*deleter)(const Slice& key, void* value)); + Cache::Handle* Lookup(const Slice& key, uint32_t hash); + void Release(Cache::Handle* handle); + void Erase(const Slice& key, uint32_t hash); + + private: + void LRU_Remove(LRUHandle* e); + void LRU_Append(LRUHandle* e); + void Unref(LRUHandle* e); + + // Initialized before use. + size_t capacity_; + + // mutex_ protects the following state. + port::Mutex mutex_; + size_t usage_; + + // Dummy head of LRU list. + // lru.prev is newest entry, lru.next is oldest entry. + LRUHandle lru_; + + HandleTable table_; +}; + +LRUCache::LRUCache() + : usage_(0) { + // Make empty circular linked list + lru_.next = &lru_; + lru_.prev = &lru_; +} + +LRUCache::~LRUCache() { + for (LRUHandle* e = lru_.next; e != &lru_; ) { + LRUHandle* next = e->next; + assert(e->refs == 1); // Error if caller has an unreleased handle + Unref(e); + e = next; + } +} + +void LRUCache::Unref(LRUHandle* e) { + assert(e->refs > 0); + e->refs--; + if (e->refs <= 0) { + usage_ -= e->charge; + (*e->deleter)(e->key(), e->value); + free(e); + } +} + +void LRUCache::LRU_Remove(LRUHandle* e) { + e->next->prev = e->prev; + e->prev->next = e->next; +} + +void LRUCache::LRU_Append(LRUHandle* e) { + // Make "e" newest entry by inserting just before lru_ + e->next = &lru_; + e->prev = lru_.prev; + e->prev->next = e; + e->next->prev = e; +} + +Cache::Handle* LRUCache::Lookup(const Slice& key, uint32_t hash) { + MutexLock l(&mutex_); + LRUHandle* e = table_.Lookup(key, hash); + if (e != NULL) { + e->refs++; + LRU_Remove(e); + LRU_Append(e); + } + return reinterpret_cast(e); +} + +void LRUCache::Release(Cache::Handle* handle) { + MutexLock l(&mutex_); + Unref(reinterpret_cast(handle)); +} + +Cache::Handle* LRUCache::Insert( + const Slice& key, uint32_t hash, void* value, size_t charge, + void (*deleter)(const Slice& key, void* value)) { + MutexLock l(&mutex_); + + LRUHandle* e = reinterpret_cast( + malloc(sizeof(LRUHandle)-1 + key.size())); + e->value = value; + e->deleter = deleter; + e->charge = charge; + e->key_length = key.size(); + e->hash = hash; + e->refs = 2; // One from LRUCache, one for the returned handle + memcpy(e->key_data, key.data(), key.size()); + LRU_Append(e); + usage_ += charge; + + LRUHandle* old = table_.Insert(e); + if (old != NULL) { + LRU_Remove(old); + Unref(old); + } + + while (usage_ > capacity_ && lru_.next != &lru_) { + LRUHandle* old = lru_.next; + LRU_Remove(old); + table_.Remove(old->key(), old->hash); + Unref(old); + } + + return reinterpret_cast(e); +} + +void LRUCache::Erase(const Slice& key, uint32_t hash) { + MutexLock l(&mutex_); + LRUHandle* e = table_.Remove(key, hash); + if (e != NULL) { + LRU_Remove(e); + Unref(e); + } +} + +static const int kNumShardBits = 4; +static const int kNumShards = 1 << kNumShardBits; + +class ShardedLRUCache : public Cache { + private: + LRUCache shard_[kNumShards]; + port::Mutex id_mutex_; + uint64_t last_id_; + + static inline uint32_t HashSlice(const Slice& s) { + return Hash(s.data(), s.size(), 0); + } + + static uint32_t Shard(uint32_t hash) { + return hash >> (32 - kNumShardBits); + } + + public: + explicit ShardedLRUCache(size_t capacity) + : last_id_(0) { + const size_t per_shard = (capacity + (kNumShards - 1)) / kNumShards; + for (int s = 0; s < kNumShards; s++) { + shard_[s].SetCapacity(per_shard); + } + } + virtual ~ShardedLRUCache() { } + virtual Handle* Insert(const Slice& key, void* value, size_t charge, + void (*deleter)(const Slice& key, void* value)) { + const uint32_t hash = HashSlice(key); + return shard_[Shard(hash)].Insert(key, hash, value, charge, deleter); + } + virtual Handle* Lookup(const Slice& key) { + const uint32_t hash = HashSlice(key); + return shard_[Shard(hash)].Lookup(key, hash); + } + virtual void Release(Handle* handle) { + LRUHandle* h = reinterpret_cast(handle); + shard_[Shard(h->hash)].Release(handle); + } + virtual void Erase(const Slice& key) { + const uint32_t hash = HashSlice(key); + shard_[Shard(hash)].Erase(key, hash); + } + virtual void* Value(Handle* handle) { + return reinterpret_cast(handle)->value; + } + virtual uint64_t NewId() { + MutexLock l(&id_mutex_); + return ++(last_id_); + } +}; + +} // end anonymous namespace + +Cache* NewLRUCache(size_t capacity) { + return new ShardedLRUCache(capacity); +} + +} // namespace leveldb diff --git a/src/leveldb/util/cache_test.cc b/src/leveldb/util/cache_test.cc new file mode 100644 index 0000000..4371671 --- /dev/null +++ b/src/leveldb/util/cache_test.cc @@ -0,0 +1,186 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/cache.h" + +#include +#include "util/coding.h" +#include "util/testharness.h" + +namespace leveldb { + +// Conversions between numeric keys/values and the types expected by Cache. +static std::string EncodeKey(int k) { + std::string result; + PutFixed32(&result, k); + return result; +} +static int DecodeKey(const Slice& k) { + assert(k.size() == 4); + return DecodeFixed32(k.data()); +} +static void* EncodeValue(uintptr_t v) { return reinterpret_cast(v); } +static int DecodeValue(void* v) { return reinterpret_cast(v); } + +class CacheTest { + public: + static CacheTest* current_; + + static void Deleter(const Slice& key, void* v) { + current_->deleted_keys_.push_back(DecodeKey(key)); + current_->deleted_values_.push_back(DecodeValue(v)); + } + + static const int kCacheSize = 1000; + std::vector deleted_keys_; + std::vector deleted_values_; + Cache* cache_; + + CacheTest() : cache_(NewLRUCache(kCacheSize)) { + current_ = this; + } + + ~CacheTest() { + delete cache_; + } + + int Lookup(int key) { + Cache::Handle* handle = cache_->Lookup(EncodeKey(key)); + const int r = (handle == NULL) ? -1 : DecodeValue(cache_->Value(handle)); + if (handle != NULL) { + cache_->Release(handle); + } + return r; + } + + void Insert(int key, int value, int charge = 1) { + cache_->Release(cache_->Insert(EncodeKey(key), EncodeValue(value), charge, + &CacheTest::Deleter)); + } + + void Erase(int key) { + cache_->Erase(EncodeKey(key)); + } +}; +CacheTest* CacheTest::current_; + +TEST(CacheTest, HitAndMiss) { + ASSERT_EQ(-1, Lookup(100)); + + Insert(100, 101); + ASSERT_EQ(101, Lookup(100)); + ASSERT_EQ(-1, Lookup(200)); + ASSERT_EQ(-1, Lookup(300)); + + Insert(200, 201); + ASSERT_EQ(101, Lookup(100)); + ASSERT_EQ(201, Lookup(200)); + ASSERT_EQ(-1, Lookup(300)); + + Insert(100, 102); + ASSERT_EQ(102, Lookup(100)); + ASSERT_EQ(201, Lookup(200)); + ASSERT_EQ(-1, Lookup(300)); + + ASSERT_EQ(1, deleted_keys_.size()); + ASSERT_EQ(100, deleted_keys_[0]); + ASSERT_EQ(101, deleted_values_[0]); +} + +TEST(CacheTest, Erase) { + Erase(200); + ASSERT_EQ(0, deleted_keys_.size()); + + Insert(100, 101); + Insert(200, 201); + Erase(100); + ASSERT_EQ(-1, Lookup(100)); + ASSERT_EQ(201, Lookup(200)); + ASSERT_EQ(1, deleted_keys_.size()); + ASSERT_EQ(100, deleted_keys_[0]); + ASSERT_EQ(101, deleted_values_[0]); + + Erase(100); + ASSERT_EQ(-1, Lookup(100)); + ASSERT_EQ(201, Lookup(200)); + ASSERT_EQ(1, deleted_keys_.size()); +} + +TEST(CacheTest, EntriesArePinned) { + Insert(100, 101); + Cache::Handle* h1 = cache_->Lookup(EncodeKey(100)); + ASSERT_EQ(101, DecodeValue(cache_->Value(h1))); + + Insert(100, 102); + Cache::Handle* h2 = cache_->Lookup(EncodeKey(100)); + ASSERT_EQ(102, DecodeValue(cache_->Value(h2))); + ASSERT_EQ(0, deleted_keys_.size()); + + cache_->Release(h1); + ASSERT_EQ(1, deleted_keys_.size()); + ASSERT_EQ(100, deleted_keys_[0]); + ASSERT_EQ(101, deleted_values_[0]); + + Erase(100); + ASSERT_EQ(-1, Lookup(100)); + ASSERT_EQ(1, deleted_keys_.size()); + + cache_->Release(h2); + ASSERT_EQ(2, deleted_keys_.size()); + ASSERT_EQ(100, deleted_keys_[1]); + ASSERT_EQ(102, deleted_values_[1]); +} + +TEST(CacheTest, EvictionPolicy) { + Insert(100, 101); + Insert(200, 201); + + // Frequently used entry must be kept around + for (int i = 0; i < kCacheSize + 100; i++) { + Insert(1000+i, 2000+i); + ASSERT_EQ(2000+i, Lookup(1000+i)); + ASSERT_EQ(101, Lookup(100)); + } + ASSERT_EQ(101, Lookup(100)); + ASSERT_EQ(-1, Lookup(200)); +} + +TEST(CacheTest, HeavyEntries) { + // Add a bunch of light and heavy entries and then count the combined + // size of items still in the cache, which must be approximately the + // same as the total capacity. + const int kLight = 1; + const int kHeavy = 10; + int added = 0; + int index = 0; + while (added < 2*kCacheSize) { + const int weight = (index & 1) ? kLight : kHeavy; + Insert(index, 1000+index, weight); + added += weight; + index++; + } + + int cached_weight = 0; + for (int i = 0; i < index; i++) { + const int weight = (i & 1 ? kLight : kHeavy); + int r = Lookup(i); + if (r >= 0) { + cached_weight += weight; + ASSERT_EQ(1000+i, r); + } + } + ASSERT_LE(cached_weight, kCacheSize + kCacheSize/10); +} + +TEST(CacheTest, NewId) { + uint64_t a = cache_->NewId(); + uint64_t b = cache_->NewId(); + ASSERT_NE(a, b); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/util/coding.cc b/src/leveldb/util/coding.cc new file mode 100644 index 0000000..21e3186 --- /dev/null +++ b/src/leveldb/util/coding.cc @@ -0,0 +1,194 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "util/coding.h" + +namespace leveldb { + +void EncodeFixed32(char* buf, uint32_t value) { + if (port::kLittleEndian) { + memcpy(buf, &value, sizeof(value)); + } else { + buf[0] = value & 0xff; + buf[1] = (value >> 8) & 0xff; + buf[2] = (value >> 16) & 0xff; + buf[3] = (value >> 24) & 0xff; + } +} + +void EncodeFixed64(char* buf, uint64_t value) { + if (port::kLittleEndian) { + memcpy(buf, &value, sizeof(value)); + } else { + buf[0] = value & 0xff; + buf[1] = (value >> 8) & 0xff; + buf[2] = (value >> 16) & 0xff; + buf[3] = (value >> 24) & 0xff; + buf[4] = (value >> 32) & 0xff; + buf[5] = (value >> 40) & 0xff; + buf[6] = (value >> 48) & 0xff; + buf[7] = (value >> 56) & 0xff; + } +} + +void PutFixed32(std::string* dst, uint32_t value) { + char buf[sizeof(value)]; + EncodeFixed32(buf, value); + dst->append(buf, sizeof(buf)); +} + +void PutFixed64(std::string* dst, uint64_t value) { + char buf[sizeof(value)]; + EncodeFixed64(buf, value); + dst->append(buf, sizeof(buf)); +} + +char* EncodeVarint32(char* dst, uint32_t v) { + // Operate on characters as unsigneds + unsigned char* ptr = reinterpret_cast(dst); + static const int B = 128; + if (v < (1<<7)) { + *(ptr++) = v; + } else if (v < (1<<14)) { + *(ptr++) = v | B; + *(ptr++) = v>>7; + } else if (v < (1<<21)) { + *(ptr++) = v | B; + *(ptr++) = (v>>7) | B; + *(ptr++) = v>>14; + } else if (v < (1<<28)) { + *(ptr++) = v | B; + *(ptr++) = (v>>7) | B; + *(ptr++) = (v>>14) | B; + *(ptr++) = v>>21; + } else { + *(ptr++) = v | B; + *(ptr++) = (v>>7) | B; + *(ptr++) = (v>>14) | B; + *(ptr++) = (v>>21) | B; + *(ptr++) = v>>28; + } + return reinterpret_cast(ptr); +} + +void PutVarint32(std::string* dst, uint32_t v) { + char buf[5]; + char* ptr = EncodeVarint32(buf, v); + dst->append(buf, ptr - buf); +} + +char* EncodeVarint64(char* dst, uint64_t v) { + static const int B = 128; + unsigned char* ptr = reinterpret_cast(dst); + while (v >= B) { + *(ptr++) = (v & (B-1)) | B; + v >>= 7; + } + *(ptr++) = static_cast(v); + return reinterpret_cast(ptr); +} + +void PutVarint64(std::string* dst, uint64_t v) { + char buf[10]; + char* ptr = EncodeVarint64(buf, v); + dst->append(buf, ptr - buf); +} + +void PutLengthPrefixedSlice(std::string* dst, const Slice& value) { + PutVarint32(dst, value.size()); + dst->append(value.data(), value.size()); +} + +int VarintLength(uint64_t v) { + int len = 1; + while (v >= 128) { + v >>= 7; + len++; + } + return len; +} + +const char* GetVarint32PtrFallback(const char* p, + const char* limit, + uint32_t* value) { + uint32_t result = 0; + for (uint32_t shift = 0; shift <= 28 && p < limit; shift += 7) { + uint32_t byte = *(reinterpret_cast(p)); + p++; + if (byte & 128) { + // More bytes are present + result |= ((byte & 127) << shift); + } else { + result |= (byte << shift); + *value = result; + return reinterpret_cast(p); + } + } + return NULL; +} + +bool GetVarint32(Slice* input, uint32_t* value) { + const char* p = input->data(); + const char* limit = p + input->size(); + const char* q = GetVarint32Ptr(p, limit, value); + if (q == NULL) { + return false; + } else { + *input = Slice(q, limit - q); + return true; + } +} + +const char* GetVarint64Ptr(const char* p, const char* limit, uint64_t* value) { + uint64_t result = 0; + for (uint32_t shift = 0; shift <= 63 && p < limit; shift += 7) { + uint64_t byte = *(reinterpret_cast(p)); + p++; + if (byte & 128) { + // More bytes are present + result |= ((byte & 127) << shift); + } else { + result |= (byte << shift); + *value = result; + return reinterpret_cast(p); + } + } + return NULL; +} + +bool GetVarint64(Slice* input, uint64_t* value) { + const char* p = input->data(); + const char* limit = p + input->size(); + const char* q = GetVarint64Ptr(p, limit, value); + if (q == NULL) { + return false; + } else { + *input = Slice(q, limit - q); + return true; + } +} + +const char* GetLengthPrefixedSlice(const char* p, const char* limit, + Slice* result) { + uint32_t len; + p = GetVarint32Ptr(p, limit, &len); + if (p == NULL) return NULL; + if (p + len > limit) return NULL; + *result = Slice(p, len); + return p + len; +} + +bool GetLengthPrefixedSlice(Slice* input, Slice* result) { + uint32_t len; + if (GetVarint32(input, &len) && + input->size() >= len) { + *result = Slice(input->data(), len); + input->remove_prefix(len); + return true; + } else { + return false; + } +} + +} // namespace leveldb diff --git a/src/leveldb/util/coding.h b/src/leveldb/util/coding.h new file mode 100644 index 0000000..3993c4a --- /dev/null +++ b/src/leveldb/util/coding.h @@ -0,0 +1,104 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// Endian-neutral encoding: +// * Fixed-length numbers are encoded with least-significant byte first +// * In addition we support variable length "varint" encoding +// * Strings are encoded prefixed by their length in varint format + +#ifndef STORAGE_LEVELDB_UTIL_CODING_H_ +#define STORAGE_LEVELDB_UTIL_CODING_H_ + +#include +#include +#include +#include "leveldb/slice.h" +#include "port/port.h" + +namespace leveldb { + +// Standard Put... routines append to a string +extern void PutFixed32(std::string* dst, uint32_t value); +extern void PutFixed64(std::string* dst, uint64_t value); +extern void PutVarint32(std::string* dst, uint32_t value); +extern void PutVarint64(std::string* dst, uint64_t value); +extern void PutLengthPrefixedSlice(std::string* dst, const Slice& value); + +// Standard Get... routines parse a value from the beginning of a Slice +// and advance the slice past the parsed value. +extern bool GetVarint32(Slice* input, uint32_t* value); +extern bool GetVarint64(Slice* input, uint64_t* value); +extern bool GetLengthPrefixedSlice(Slice* input, Slice* result); + +// Pointer-based variants of GetVarint... These either store a value +// in *v and return a pointer just past the parsed value, or return +// NULL on error. These routines only look at bytes in the range +// [p..limit-1] +extern const char* GetVarint32Ptr(const char* p,const char* limit, uint32_t* v); +extern const char* GetVarint64Ptr(const char* p,const char* limit, uint64_t* v); + +// Returns the length of the varint32 or varint64 encoding of "v" +extern int VarintLength(uint64_t v); + +// Lower-level versions of Put... that write directly into a character buffer +// REQUIRES: dst has enough space for the value being written +extern void EncodeFixed32(char* dst, uint32_t value); +extern void EncodeFixed64(char* dst, uint64_t value); + +// Lower-level versions of Put... that write directly into a character buffer +// and return a pointer just past the last byte written. +// REQUIRES: dst has enough space for the value being written +extern char* EncodeVarint32(char* dst, uint32_t value); +extern char* EncodeVarint64(char* dst, uint64_t value); + +// Lower-level versions of Get... that read directly from a character buffer +// without any bounds checking. + +inline uint32_t DecodeFixed32(const char* ptr) { + if (port::kLittleEndian) { + // Load the raw bytes + uint32_t result; + memcpy(&result, ptr, sizeof(result)); // gcc optimizes this to a plain load + return result; + } else { + return ((static_cast(static_cast(ptr[0]))) + | (static_cast(static_cast(ptr[1])) << 8) + | (static_cast(static_cast(ptr[2])) << 16) + | (static_cast(static_cast(ptr[3])) << 24)); + } +} + +inline uint64_t DecodeFixed64(const char* ptr) { + if (port::kLittleEndian) { + // Load the raw bytes + uint64_t result; + memcpy(&result, ptr, sizeof(result)); // gcc optimizes this to a plain load + return result; + } else { + uint64_t lo = DecodeFixed32(ptr); + uint64_t hi = DecodeFixed32(ptr + 4); + return (hi << 32) | lo; + } +} + +// Internal routine for use by fallback path of GetVarint32Ptr +extern const char* GetVarint32PtrFallback(const char* p, + const char* limit, + uint32_t* value); +inline const char* GetVarint32Ptr(const char* p, + const char* limit, + uint32_t* value) { + if (p < limit) { + uint32_t result = *(reinterpret_cast(p)); + if ((result & 128) == 0) { + *value = result; + return p + 1; + } + } + return GetVarint32PtrFallback(p, limit, value); +} + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_UTIL_CODING_H_ diff --git a/src/leveldb/util/coding_test.cc b/src/leveldb/util/coding_test.cc new file mode 100644 index 0000000..521541e --- /dev/null +++ b/src/leveldb/util/coding_test.cc @@ -0,0 +1,196 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "util/coding.h" + +#include "util/testharness.h" + +namespace leveldb { + +class Coding { }; + +TEST(Coding, Fixed32) { + std::string s; + for (uint32_t v = 0; v < 100000; v++) { + PutFixed32(&s, v); + } + + const char* p = s.data(); + for (uint32_t v = 0; v < 100000; v++) { + uint32_t actual = DecodeFixed32(p); + ASSERT_EQ(v, actual); + p += sizeof(uint32_t); + } +} + +TEST(Coding, Fixed64) { + std::string s; + for (int power = 0; power <= 63; power++) { + uint64_t v = static_cast(1) << power; + PutFixed64(&s, v - 1); + PutFixed64(&s, v + 0); + PutFixed64(&s, v + 1); + } + + const char* p = s.data(); + for (int power = 0; power <= 63; power++) { + uint64_t v = static_cast(1) << power; + uint64_t actual; + actual = DecodeFixed64(p); + ASSERT_EQ(v-1, actual); + p += sizeof(uint64_t); + + actual = DecodeFixed64(p); + ASSERT_EQ(v+0, actual); + p += sizeof(uint64_t); + + actual = DecodeFixed64(p); + ASSERT_EQ(v+1, actual); + p += sizeof(uint64_t); + } +} + +// Test that encoding routines generate little-endian encodings +TEST(Coding, EncodingOutput) { + std::string dst; + PutFixed32(&dst, 0x04030201); + ASSERT_EQ(4, dst.size()); + ASSERT_EQ(0x01, static_cast(dst[0])); + ASSERT_EQ(0x02, static_cast(dst[1])); + ASSERT_EQ(0x03, static_cast(dst[2])); + ASSERT_EQ(0x04, static_cast(dst[3])); + + dst.clear(); + PutFixed64(&dst, 0x0807060504030201ull); + ASSERT_EQ(8, dst.size()); + ASSERT_EQ(0x01, static_cast(dst[0])); + ASSERT_EQ(0x02, static_cast(dst[1])); + ASSERT_EQ(0x03, static_cast(dst[2])); + ASSERT_EQ(0x04, static_cast(dst[3])); + ASSERT_EQ(0x05, static_cast(dst[4])); + ASSERT_EQ(0x06, static_cast(dst[5])); + ASSERT_EQ(0x07, static_cast(dst[6])); + ASSERT_EQ(0x08, static_cast(dst[7])); +} + +TEST(Coding, Varint32) { + std::string s; + for (uint32_t i = 0; i < (32 * 32); i++) { + uint32_t v = (i / 32) << (i % 32); + PutVarint32(&s, v); + } + + const char* p = s.data(); + const char* limit = p + s.size(); + for (uint32_t i = 0; i < (32 * 32); i++) { + uint32_t expected = (i / 32) << (i % 32); + uint32_t actual; + const char* start = p; + p = GetVarint32Ptr(p, limit, &actual); + ASSERT_TRUE(p != NULL); + ASSERT_EQ(expected, actual); + ASSERT_EQ(VarintLength(actual), p - start); + } + ASSERT_EQ(p, s.data() + s.size()); +} + +TEST(Coding, Varint64) { + // Construct the list of values to check + std::vector values; + // Some special values + values.push_back(0); + values.push_back(100); + values.push_back(~static_cast(0)); + values.push_back(~static_cast(0) - 1); + for (uint32_t k = 0; k < 64; k++) { + // Test values near powers of two + const uint64_t power = 1ull << k; + values.push_back(power); + values.push_back(power-1); + values.push_back(power+1); + } + + std::string s; + for (size_t i = 0; i < values.size(); i++) { + PutVarint64(&s, values[i]); + } + + const char* p = s.data(); + const char* limit = p + s.size(); + for (size_t i = 0; i < values.size(); i++) { + ASSERT_TRUE(p < limit); + uint64_t actual; + const char* start = p; + p = GetVarint64Ptr(p, limit, &actual); + ASSERT_TRUE(p != NULL); + ASSERT_EQ(values[i], actual); + ASSERT_EQ(VarintLength(actual), p - start); + } + ASSERT_EQ(p, limit); + +} + +TEST(Coding, Varint32Overflow) { + uint32_t result; + std::string input("\x81\x82\x83\x84\x85\x11"); + ASSERT_TRUE(GetVarint32Ptr(input.data(), input.data() + input.size(), &result) + == NULL); +} + +TEST(Coding, Varint32Truncation) { + uint32_t large_value = (1u << 31) + 100; + std::string s; + PutVarint32(&s, large_value); + uint32_t result; + for (size_t len = 0; len < s.size() - 1; len++) { + ASSERT_TRUE(GetVarint32Ptr(s.data(), s.data() + len, &result) == NULL); + } + ASSERT_TRUE(GetVarint32Ptr(s.data(), s.data() + s.size(), &result) != NULL); + ASSERT_EQ(large_value, result); +} + +TEST(Coding, Varint64Overflow) { + uint64_t result; + std::string input("\x81\x82\x83\x84\x85\x81\x82\x83\x84\x85\x11"); + ASSERT_TRUE(GetVarint64Ptr(input.data(), input.data() + input.size(), &result) + == NULL); +} + +TEST(Coding, Varint64Truncation) { + uint64_t large_value = (1ull << 63) + 100ull; + std::string s; + PutVarint64(&s, large_value); + uint64_t result; + for (size_t len = 0; len < s.size() - 1; len++) { + ASSERT_TRUE(GetVarint64Ptr(s.data(), s.data() + len, &result) == NULL); + } + ASSERT_TRUE(GetVarint64Ptr(s.data(), s.data() + s.size(), &result) != NULL); + ASSERT_EQ(large_value, result); +} + +TEST(Coding, Strings) { + std::string s; + PutLengthPrefixedSlice(&s, Slice("")); + PutLengthPrefixedSlice(&s, Slice("foo")); + PutLengthPrefixedSlice(&s, Slice("bar")); + PutLengthPrefixedSlice(&s, Slice(std::string(200, 'x'))); + + Slice input(s); + Slice v; + ASSERT_TRUE(GetLengthPrefixedSlice(&input, &v)); + ASSERT_EQ("", v.ToString()); + ASSERT_TRUE(GetLengthPrefixedSlice(&input, &v)); + ASSERT_EQ("foo", v.ToString()); + ASSERT_TRUE(GetLengthPrefixedSlice(&input, &v)); + ASSERT_EQ("bar", v.ToString()); + ASSERT_TRUE(GetLengthPrefixedSlice(&input, &v)); + ASSERT_EQ(std::string(200, 'x'), v.ToString()); + ASSERT_EQ("", input.ToString()); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/util/comparator.cc b/src/leveldb/util/comparator.cc new file mode 100644 index 0000000..4b7b572 --- /dev/null +++ b/src/leveldb/util/comparator.cc @@ -0,0 +1,81 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include +#include +#include "leveldb/comparator.h" +#include "leveldb/slice.h" +#include "port/port.h" +#include "util/logging.h" + +namespace leveldb { + +Comparator::~Comparator() { } + +namespace { +class BytewiseComparatorImpl : public Comparator { + public: + BytewiseComparatorImpl() { } + + virtual const char* Name() const { + return "leveldb.BytewiseComparator"; + } + + virtual int Compare(const Slice& a, const Slice& b) const { + return a.compare(b); + } + + virtual void FindShortestSeparator( + std::string* start, + const Slice& limit) const { + // Find length of common prefix + size_t min_length = std::min(start->size(), limit.size()); + size_t diff_index = 0; + while ((diff_index < min_length) && + ((*start)[diff_index] == limit[diff_index])) { + diff_index++; + } + + if (diff_index >= min_length) { + // Do not shorten if one string is a prefix of the other + } else { + uint8_t diff_byte = static_cast((*start)[diff_index]); + if (diff_byte < static_cast(0xff) && + diff_byte + 1 < static_cast(limit[diff_index])) { + (*start)[diff_index]++; + start->resize(diff_index + 1); + assert(Compare(*start, limit) < 0); + } + } + } + + virtual void FindShortSuccessor(std::string* key) const { + // Find first character that can be incremented + size_t n = key->size(); + for (size_t i = 0; i < n; i++) { + const uint8_t byte = (*key)[i]; + if (byte != static_cast(0xff)) { + (*key)[i] = byte + 1; + key->resize(i+1); + return; + } + } + // *key is a run of 0xffs. Leave it alone. + } +}; +} // namespace + +static port::OnceType once = LEVELDB_ONCE_INIT; +static const Comparator* bytewise; + +static void InitModule() { + bytewise = new BytewiseComparatorImpl; +} + +const Comparator* BytewiseComparator() { + port::InitOnce(&once, InitModule); + return bytewise; +} + +} // namespace leveldb diff --git a/src/leveldb/util/crc32c.cc b/src/leveldb/util/crc32c.cc new file mode 100644 index 0000000..6db9e77 --- /dev/null +++ b/src/leveldb/util/crc32c.cc @@ -0,0 +1,332 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// A portable implementation of crc32c, optimized to handle +// four bytes at a time. + +#include "util/crc32c.h" + +#include +#include "util/coding.h" + +namespace leveldb { +namespace crc32c { + +static const uint32_t table0_[256] = { + 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, + 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb, + 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b, + 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, + 0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b, + 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384, + 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, + 0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b, + 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a, + 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, + 0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5, + 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa, + 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, + 0xf779deae, 0x05125dad, 0x1642ae59, 0xe4292d5a, + 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a, + 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, + 0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48, + 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957, + 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, + 0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198, + 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927, + 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, + 0xdbfc821c, 0x2997011f, 0x3ac7f2eb, 0xc8ac71e8, + 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7, + 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, + 0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789, + 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859, + 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, + 0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9, + 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6, + 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, + 0x3cdb9bdd, 0xceb018de, 0xdde0eb2a, 0x2f8b6829, + 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c, + 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, + 0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043, + 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c, + 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, + 0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc, + 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c, + 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, + 0xa24bb5a6, 0x502036a5, 0x4370c551, 0xb11b4652, + 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d, + 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, + 0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982, + 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d, + 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, + 0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2, + 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed, + 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, + 0x0417b1db, 0xf67c32d8, 0xe52cc12c, 0x1747422f, + 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff, + 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, + 0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f, + 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540, + 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, + 0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f, + 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee, + 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, + 0x69e9f0d5, 0x9b8273d6, 0x88d28022, 0x7ab90321, + 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e, + 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, + 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e, + 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, + 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351 +}; +static const uint32_t table1_[256] = { + 0x00000000, 0x13a29877, 0x274530ee, 0x34e7a899, + 0x4e8a61dc, 0x5d28f9ab, 0x69cf5132, 0x7a6dc945, + 0x9d14c3b8, 0x8eb65bcf, 0xba51f356, 0xa9f36b21, + 0xd39ea264, 0xc03c3a13, 0xf4db928a, 0xe7790afd, + 0x3fc5f181, 0x2c6769f6, 0x1880c16f, 0x0b225918, + 0x714f905d, 0x62ed082a, 0x560aa0b3, 0x45a838c4, + 0xa2d13239, 0xb173aa4e, 0x859402d7, 0x96369aa0, + 0xec5b53e5, 0xfff9cb92, 0xcb1e630b, 0xd8bcfb7c, + 0x7f8be302, 0x6c297b75, 0x58ced3ec, 0x4b6c4b9b, + 0x310182de, 0x22a31aa9, 0x1644b230, 0x05e62a47, + 0xe29f20ba, 0xf13db8cd, 0xc5da1054, 0xd6788823, + 0xac154166, 0xbfb7d911, 0x8b507188, 0x98f2e9ff, + 0x404e1283, 0x53ec8af4, 0x670b226d, 0x74a9ba1a, + 0x0ec4735f, 0x1d66eb28, 0x298143b1, 0x3a23dbc6, + 0xdd5ad13b, 0xcef8494c, 0xfa1fe1d5, 0xe9bd79a2, + 0x93d0b0e7, 0x80722890, 0xb4958009, 0xa737187e, + 0xff17c604, 0xecb55e73, 0xd852f6ea, 0xcbf06e9d, + 0xb19da7d8, 0xa23f3faf, 0x96d89736, 0x857a0f41, + 0x620305bc, 0x71a19dcb, 0x45463552, 0x56e4ad25, + 0x2c896460, 0x3f2bfc17, 0x0bcc548e, 0x186eccf9, + 0xc0d23785, 0xd370aff2, 0xe797076b, 0xf4359f1c, + 0x8e585659, 0x9dface2e, 0xa91d66b7, 0xbabffec0, + 0x5dc6f43d, 0x4e646c4a, 0x7a83c4d3, 0x69215ca4, + 0x134c95e1, 0x00ee0d96, 0x3409a50f, 0x27ab3d78, + 0x809c2506, 0x933ebd71, 0xa7d915e8, 0xb47b8d9f, + 0xce1644da, 0xddb4dcad, 0xe9537434, 0xfaf1ec43, + 0x1d88e6be, 0x0e2a7ec9, 0x3acdd650, 0x296f4e27, + 0x53028762, 0x40a01f15, 0x7447b78c, 0x67e52ffb, + 0xbf59d487, 0xacfb4cf0, 0x981ce469, 0x8bbe7c1e, + 0xf1d3b55b, 0xe2712d2c, 0xd69685b5, 0xc5341dc2, + 0x224d173f, 0x31ef8f48, 0x050827d1, 0x16aabfa6, + 0x6cc776e3, 0x7f65ee94, 0x4b82460d, 0x5820de7a, + 0xfbc3faf9, 0xe861628e, 0xdc86ca17, 0xcf245260, + 0xb5499b25, 0xa6eb0352, 0x920cabcb, 0x81ae33bc, + 0x66d73941, 0x7575a136, 0x419209af, 0x523091d8, + 0x285d589d, 0x3bffc0ea, 0x0f186873, 0x1cbaf004, + 0xc4060b78, 0xd7a4930f, 0xe3433b96, 0xf0e1a3e1, + 0x8a8c6aa4, 0x992ef2d3, 0xadc95a4a, 0xbe6bc23d, + 0x5912c8c0, 0x4ab050b7, 0x7e57f82e, 0x6df56059, + 0x1798a91c, 0x043a316b, 0x30dd99f2, 0x237f0185, + 0x844819fb, 0x97ea818c, 0xa30d2915, 0xb0afb162, + 0xcac27827, 0xd960e050, 0xed8748c9, 0xfe25d0be, + 0x195cda43, 0x0afe4234, 0x3e19eaad, 0x2dbb72da, + 0x57d6bb9f, 0x447423e8, 0x70938b71, 0x63311306, + 0xbb8de87a, 0xa82f700d, 0x9cc8d894, 0x8f6a40e3, + 0xf50789a6, 0xe6a511d1, 0xd242b948, 0xc1e0213f, + 0x26992bc2, 0x353bb3b5, 0x01dc1b2c, 0x127e835b, + 0x68134a1e, 0x7bb1d269, 0x4f567af0, 0x5cf4e287, + 0x04d43cfd, 0x1776a48a, 0x23910c13, 0x30339464, + 0x4a5e5d21, 0x59fcc556, 0x6d1b6dcf, 0x7eb9f5b8, + 0x99c0ff45, 0x8a626732, 0xbe85cfab, 0xad2757dc, + 0xd74a9e99, 0xc4e806ee, 0xf00fae77, 0xe3ad3600, + 0x3b11cd7c, 0x28b3550b, 0x1c54fd92, 0x0ff665e5, + 0x759baca0, 0x663934d7, 0x52de9c4e, 0x417c0439, + 0xa6050ec4, 0xb5a796b3, 0x81403e2a, 0x92e2a65d, + 0xe88f6f18, 0xfb2df76f, 0xcfca5ff6, 0xdc68c781, + 0x7b5fdfff, 0x68fd4788, 0x5c1aef11, 0x4fb87766, + 0x35d5be23, 0x26772654, 0x12908ecd, 0x013216ba, + 0xe64b1c47, 0xf5e98430, 0xc10e2ca9, 0xd2acb4de, + 0xa8c17d9b, 0xbb63e5ec, 0x8f844d75, 0x9c26d502, + 0x449a2e7e, 0x5738b609, 0x63df1e90, 0x707d86e7, + 0x0a104fa2, 0x19b2d7d5, 0x2d557f4c, 0x3ef7e73b, + 0xd98eedc6, 0xca2c75b1, 0xfecbdd28, 0xed69455f, + 0x97048c1a, 0x84a6146d, 0xb041bcf4, 0xa3e32483 +}; +static const uint32_t table2_[256] = { + 0x00000000, 0xa541927e, 0x4f6f520d, 0xea2ec073, + 0x9edea41a, 0x3b9f3664, 0xd1b1f617, 0x74f06469, + 0x38513ec5, 0x9d10acbb, 0x773e6cc8, 0xd27ffeb6, + 0xa68f9adf, 0x03ce08a1, 0xe9e0c8d2, 0x4ca15aac, + 0x70a27d8a, 0xd5e3eff4, 0x3fcd2f87, 0x9a8cbdf9, + 0xee7cd990, 0x4b3d4bee, 0xa1138b9d, 0x045219e3, + 0x48f3434f, 0xedb2d131, 0x079c1142, 0xa2dd833c, + 0xd62de755, 0x736c752b, 0x9942b558, 0x3c032726, + 0xe144fb14, 0x4405696a, 0xae2ba919, 0x0b6a3b67, + 0x7f9a5f0e, 0xdadbcd70, 0x30f50d03, 0x95b49f7d, + 0xd915c5d1, 0x7c5457af, 0x967a97dc, 0x333b05a2, + 0x47cb61cb, 0xe28af3b5, 0x08a433c6, 0xade5a1b8, + 0x91e6869e, 0x34a714e0, 0xde89d493, 0x7bc846ed, + 0x0f382284, 0xaa79b0fa, 0x40577089, 0xe516e2f7, + 0xa9b7b85b, 0x0cf62a25, 0xe6d8ea56, 0x43997828, + 0x37691c41, 0x92288e3f, 0x78064e4c, 0xdd47dc32, + 0xc76580d9, 0x622412a7, 0x880ad2d4, 0x2d4b40aa, + 0x59bb24c3, 0xfcfab6bd, 0x16d476ce, 0xb395e4b0, + 0xff34be1c, 0x5a752c62, 0xb05bec11, 0x151a7e6f, + 0x61ea1a06, 0xc4ab8878, 0x2e85480b, 0x8bc4da75, + 0xb7c7fd53, 0x12866f2d, 0xf8a8af5e, 0x5de93d20, + 0x29195949, 0x8c58cb37, 0x66760b44, 0xc337993a, + 0x8f96c396, 0x2ad751e8, 0xc0f9919b, 0x65b803e5, + 0x1148678c, 0xb409f5f2, 0x5e273581, 0xfb66a7ff, + 0x26217bcd, 0x8360e9b3, 0x694e29c0, 0xcc0fbbbe, + 0xb8ffdfd7, 0x1dbe4da9, 0xf7908dda, 0x52d11fa4, + 0x1e704508, 0xbb31d776, 0x511f1705, 0xf45e857b, + 0x80aee112, 0x25ef736c, 0xcfc1b31f, 0x6a802161, + 0x56830647, 0xf3c29439, 0x19ec544a, 0xbcadc634, + 0xc85da25d, 0x6d1c3023, 0x8732f050, 0x2273622e, + 0x6ed23882, 0xcb93aafc, 0x21bd6a8f, 0x84fcf8f1, + 0xf00c9c98, 0x554d0ee6, 0xbf63ce95, 0x1a225ceb, + 0x8b277743, 0x2e66e53d, 0xc448254e, 0x6109b730, + 0x15f9d359, 0xb0b84127, 0x5a968154, 0xffd7132a, + 0xb3764986, 0x1637dbf8, 0xfc191b8b, 0x595889f5, + 0x2da8ed9c, 0x88e97fe2, 0x62c7bf91, 0xc7862def, + 0xfb850ac9, 0x5ec498b7, 0xb4ea58c4, 0x11abcaba, + 0x655baed3, 0xc01a3cad, 0x2a34fcde, 0x8f756ea0, + 0xc3d4340c, 0x6695a672, 0x8cbb6601, 0x29faf47f, + 0x5d0a9016, 0xf84b0268, 0x1265c21b, 0xb7245065, + 0x6a638c57, 0xcf221e29, 0x250cde5a, 0x804d4c24, + 0xf4bd284d, 0x51fcba33, 0xbbd27a40, 0x1e93e83e, + 0x5232b292, 0xf77320ec, 0x1d5de09f, 0xb81c72e1, + 0xccec1688, 0x69ad84f6, 0x83834485, 0x26c2d6fb, + 0x1ac1f1dd, 0xbf8063a3, 0x55aea3d0, 0xf0ef31ae, + 0x841f55c7, 0x215ec7b9, 0xcb7007ca, 0x6e3195b4, + 0x2290cf18, 0x87d15d66, 0x6dff9d15, 0xc8be0f6b, + 0xbc4e6b02, 0x190ff97c, 0xf321390f, 0x5660ab71, + 0x4c42f79a, 0xe90365e4, 0x032da597, 0xa66c37e9, + 0xd29c5380, 0x77ddc1fe, 0x9df3018d, 0x38b293f3, + 0x7413c95f, 0xd1525b21, 0x3b7c9b52, 0x9e3d092c, + 0xeacd6d45, 0x4f8cff3b, 0xa5a23f48, 0x00e3ad36, + 0x3ce08a10, 0x99a1186e, 0x738fd81d, 0xd6ce4a63, + 0xa23e2e0a, 0x077fbc74, 0xed517c07, 0x4810ee79, + 0x04b1b4d5, 0xa1f026ab, 0x4bdee6d8, 0xee9f74a6, + 0x9a6f10cf, 0x3f2e82b1, 0xd50042c2, 0x7041d0bc, + 0xad060c8e, 0x08479ef0, 0xe2695e83, 0x4728ccfd, + 0x33d8a894, 0x96993aea, 0x7cb7fa99, 0xd9f668e7, + 0x9557324b, 0x3016a035, 0xda386046, 0x7f79f238, + 0x0b899651, 0xaec8042f, 0x44e6c45c, 0xe1a75622, + 0xdda47104, 0x78e5e37a, 0x92cb2309, 0x378ab177, + 0x437ad51e, 0xe63b4760, 0x0c158713, 0xa954156d, + 0xe5f54fc1, 0x40b4ddbf, 0xaa9a1dcc, 0x0fdb8fb2, + 0x7b2bebdb, 0xde6a79a5, 0x3444b9d6, 0x91052ba8 +}; +static const uint32_t table3_[256] = { + 0x00000000, 0xdd45aab8, 0xbf672381, 0x62228939, + 0x7b2231f3, 0xa6679b4b, 0xc4451272, 0x1900b8ca, + 0xf64463e6, 0x2b01c95e, 0x49234067, 0x9466eadf, + 0x8d665215, 0x5023f8ad, 0x32017194, 0xef44db2c, + 0xe964b13d, 0x34211b85, 0x560392bc, 0x8b463804, + 0x924680ce, 0x4f032a76, 0x2d21a34f, 0xf06409f7, + 0x1f20d2db, 0xc2657863, 0xa047f15a, 0x7d025be2, + 0x6402e328, 0xb9474990, 0xdb65c0a9, 0x06206a11, + 0xd725148b, 0x0a60be33, 0x6842370a, 0xb5079db2, + 0xac072578, 0x71428fc0, 0x136006f9, 0xce25ac41, + 0x2161776d, 0xfc24ddd5, 0x9e0654ec, 0x4343fe54, + 0x5a43469e, 0x8706ec26, 0xe524651f, 0x3861cfa7, + 0x3e41a5b6, 0xe3040f0e, 0x81268637, 0x5c632c8f, + 0x45639445, 0x98263efd, 0xfa04b7c4, 0x27411d7c, + 0xc805c650, 0x15406ce8, 0x7762e5d1, 0xaa274f69, + 0xb327f7a3, 0x6e625d1b, 0x0c40d422, 0xd1057e9a, + 0xaba65fe7, 0x76e3f55f, 0x14c17c66, 0xc984d6de, + 0xd0846e14, 0x0dc1c4ac, 0x6fe34d95, 0xb2a6e72d, + 0x5de23c01, 0x80a796b9, 0xe2851f80, 0x3fc0b538, + 0x26c00df2, 0xfb85a74a, 0x99a72e73, 0x44e284cb, + 0x42c2eeda, 0x9f874462, 0xfda5cd5b, 0x20e067e3, + 0x39e0df29, 0xe4a57591, 0x8687fca8, 0x5bc25610, + 0xb4868d3c, 0x69c32784, 0x0be1aebd, 0xd6a40405, + 0xcfa4bccf, 0x12e11677, 0x70c39f4e, 0xad8635f6, + 0x7c834b6c, 0xa1c6e1d4, 0xc3e468ed, 0x1ea1c255, + 0x07a17a9f, 0xdae4d027, 0xb8c6591e, 0x6583f3a6, + 0x8ac7288a, 0x57828232, 0x35a00b0b, 0xe8e5a1b3, + 0xf1e51979, 0x2ca0b3c1, 0x4e823af8, 0x93c79040, + 0x95e7fa51, 0x48a250e9, 0x2a80d9d0, 0xf7c57368, + 0xeec5cba2, 0x3380611a, 0x51a2e823, 0x8ce7429b, + 0x63a399b7, 0xbee6330f, 0xdcc4ba36, 0x0181108e, + 0x1881a844, 0xc5c402fc, 0xa7e68bc5, 0x7aa3217d, + 0x52a0c93f, 0x8fe56387, 0xedc7eabe, 0x30824006, + 0x2982f8cc, 0xf4c75274, 0x96e5db4d, 0x4ba071f5, + 0xa4e4aad9, 0x79a10061, 0x1b838958, 0xc6c623e0, + 0xdfc69b2a, 0x02833192, 0x60a1b8ab, 0xbde41213, + 0xbbc47802, 0x6681d2ba, 0x04a35b83, 0xd9e6f13b, + 0xc0e649f1, 0x1da3e349, 0x7f816a70, 0xa2c4c0c8, + 0x4d801be4, 0x90c5b15c, 0xf2e73865, 0x2fa292dd, + 0x36a22a17, 0xebe780af, 0x89c50996, 0x5480a32e, + 0x8585ddb4, 0x58c0770c, 0x3ae2fe35, 0xe7a7548d, + 0xfea7ec47, 0x23e246ff, 0x41c0cfc6, 0x9c85657e, + 0x73c1be52, 0xae8414ea, 0xcca69dd3, 0x11e3376b, + 0x08e38fa1, 0xd5a62519, 0xb784ac20, 0x6ac10698, + 0x6ce16c89, 0xb1a4c631, 0xd3864f08, 0x0ec3e5b0, + 0x17c35d7a, 0xca86f7c2, 0xa8a47efb, 0x75e1d443, + 0x9aa50f6f, 0x47e0a5d7, 0x25c22cee, 0xf8878656, + 0xe1873e9c, 0x3cc29424, 0x5ee01d1d, 0x83a5b7a5, + 0xf90696d8, 0x24433c60, 0x4661b559, 0x9b241fe1, + 0x8224a72b, 0x5f610d93, 0x3d4384aa, 0xe0062e12, + 0x0f42f53e, 0xd2075f86, 0xb025d6bf, 0x6d607c07, + 0x7460c4cd, 0xa9256e75, 0xcb07e74c, 0x16424df4, + 0x106227e5, 0xcd278d5d, 0xaf050464, 0x7240aedc, + 0x6b401616, 0xb605bcae, 0xd4273597, 0x09629f2f, + 0xe6264403, 0x3b63eebb, 0x59416782, 0x8404cd3a, + 0x9d0475f0, 0x4041df48, 0x22635671, 0xff26fcc9, + 0x2e238253, 0xf36628eb, 0x9144a1d2, 0x4c010b6a, + 0x5501b3a0, 0x88441918, 0xea669021, 0x37233a99, + 0xd867e1b5, 0x05224b0d, 0x6700c234, 0xba45688c, + 0xa345d046, 0x7e007afe, 0x1c22f3c7, 0xc167597f, + 0xc747336e, 0x1a0299d6, 0x782010ef, 0xa565ba57, + 0xbc65029d, 0x6120a825, 0x0302211c, 0xde478ba4, + 0x31035088, 0xec46fa30, 0x8e647309, 0x5321d9b1, + 0x4a21617b, 0x9764cbc3, 0xf54642fa, 0x2803e842 +}; + +// Used to fetch a naturally-aligned 32-bit word in little endian byte-order +static inline uint32_t LE_LOAD32(const uint8_t *p) { + return DecodeFixed32(reinterpret_cast(p)); +} + +uint32_t Extend(uint32_t crc, const char* buf, size_t size) { + const uint8_t *p = reinterpret_cast(buf); + const uint8_t *e = p + size; + uint32_t l = crc ^ 0xffffffffu; + +#define STEP1 do { \ + int c = (l & 0xff) ^ *p++; \ + l = table0_[c] ^ (l >> 8); \ +} while (0) +#define STEP4 do { \ + uint32_t c = l ^ LE_LOAD32(p); \ + p += 4; \ + l = table3_[c & 0xff] ^ \ + table2_[(c >> 8) & 0xff] ^ \ + table1_[(c >> 16) & 0xff] ^ \ + table0_[c >> 24]; \ +} while (0) + + // Point x at first 4-byte aligned byte in string. This might be + // just past the end of the string. + const uintptr_t pval = reinterpret_cast(p); + const uint8_t* x = reinterpret_cast(((pval + 3) >> 2) << 2); + if (x <= e) { + // Process bytes until finished or p is 4-byte aligned + while (p != x) { + STEP1; + } + } + // Process bytes 16 at a time + while ((e-p) >= 16) { + STEP4; STEP4; STEP4; STEP4; + } + // Process bytes 4 at a time + while ((e-p) >= 4) { + STEP4; + } + // Process the last few bytes + while (p != e) { + STEP1; + } +#undef STEP4 +#undef STEP1 + return l ^ 0xffffffffu; +} + +} // namespace crc32c +} // namespace leveldb diff --git a/src/leveldb/util/crc32c.h b/src/leveldb/util/crc32c.h new file mode 100644 index 0000000..1d7e5c0 --- /dev/null +++ b/src/leveldb/util/crc32c.h @@ -0,0 +1,45 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_UTIL_CRC32C_H_ +#define STORAGE_LEVELDB_UTIL_CRC32C_H_ + +#include +#include + +namespace leveldb { +namespace crc32c { + +// Return the crc32c of concat(A, data[0,n-1]) where init_crc is the +// crc32c of some string A. Extend() is often used to maintain the +// crc32c of a stream of data. +extern uint32_t Extend(uint32_t init_crc, const char* data, size_t n); + +// Return the crc32c of data[0,n-1] +inline uint32_t Value(const char* data, size_t n) { + return Extend(0, data, n); +} + +static const uint32_t kMaskDelta = 0xa282ead8ul; + +// Return a masked representation of crc. +// +// Motivation: it is problematic to compute the CRC of a string that +// contains embedded CRCs. Therefore we recommend that CRCs stored +// somewhere (e.g., in files) should be masked before being stored. +inline uint32_t Mask(uint32_t crc) { + // Rotate right by 15 bits and add a constant. + return ((crc >> 15) | (crc << 17)) + kMaskDelta; +} + +// Return the crc whose masked representation is masked_crc. +inline uint32_t Unmask(uint32_t masked_crc) { + uint32_t rot = masked_crc - kMaskDelta; + return ((rot >> 17) | (rot << 15)); +} + +} // namespace crc32c +} // namespace leveldb + +#endif // STORAGE_LEVELDB_UTIL_CRC32C_H_ diff --git a/src/leveldb/util/crc32c_test.cc b/src/leveldb/util/crc32c_test.cc new file mode 100644 index 0000000..4b957ee --- /dev/null +++ b/src/leveldb/util/crc32c_test.cc @@ -0,0 +1,72 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "util/crc32c.h" +#include "util/testharness.h" + +namespace leveldb { +namespace crc32c { + +class CRC { }; + +TEST(CRC, StandardResults) { + // From rfc3720 section B.4. + char buf[32]; + + memset(buf, 0, sizeof(buf)); + ASSERT_EQ(0x8a9136aa, Value(buf, sizeof(buf))); + + memset(buf, 0xff, sizeof(buf)); + ASSERT_EQ(0x62a8ab43, Value(buf, sizeof(buf))); + + for (int i = 0; i < 32; i++) { + buf[i] = i; + } + ASSERT_EQ(0x46dd794e, Value(buf, sizeof(buf))); + + for (int i = 0; i < 32; i++) { + buf[i] = 31 - i; + } + ASSERT_EQ(0x113fdb5c, Value(buf, sizeof(buf))); + + unsigned char data[48] = { + 0x01, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x14, + 0x00, 0x00, 0x00, 0x18, + 0x28, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }; + ASSERT_EQ(0xd9963a56, Value(reinterpret_cast(data), sizeof(data))); +} + +TEST(CRC, Values) { + ASSERT_NE(Value("a", 1), Value("foo", 3)); +} + +TEST(CRC, Extend) { + ASSERT_EQ(Value("hello world", 11), + Extend(Value("hello ", 6), "world", 5)); +} + +TEST(CRC, Mask) { + uint32_t crc = Value("foo", 3); + ASSERT_NE(crc, Mask(crc)); + ASSERT_NE(crc, Mask(Mask(crc))); + ASSERT_EQ(crc, Unmask(Mask(crc))); + ASSERT_EQ(crc, Unmask(Unmask(Mask(Mask(crc))))); +} + +} // namespace crc32c +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/util/env.cc b/src/leveldb/util/env.cc new file mode 100644 index 0000000..c2600e9 --- /dev/null +++ b/src/leveldb/util/env.cc @@ -0,0 +1,96 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/env.h" + +namespace leveldb { + +Env::~Env() { +} + +SequentialFile::~SequentialFile() { +} + +RandomAccessFile::~RandomAccessFile() { +} + +WritableFile::~WritableFile() { +} + +Logger::~Logger() { +} + +FileLock::~FileLock() { +} + +void Log(Logger* info_log, const char* format, ...) { + if (info_log != NULL) { + va_list ap; + va_start(ap, format); + info_log->Logv(format, ap); + va_end(ap); + } +} + +static Status DoWriteStringToFile(Env* env, const Slice& data, + const std::string& fname, + bool should_sync) { + WritableFile* file; + Status s = env->NewWritableFile(fname, &file); + if (!s.ok()) { + return s; + } + s = file->Append(data); + if (s.ok() && should_sync) { + s = file->Sync(); + } + if (s.ok()) { + s = file->Close(); + } + delete file; // Will auto-close if we did not close above + if (!s.ok()) { + env->DeleteFile(fname); + } + return s; +} + +Status WriteStringToFile(Env* env, const Slice& data, + const std::string& fname) { + return DoWriteStringToFile(env, data, fname, false); +} + +Status WriteStringToFileSync(Env* env, const Slice& data, + const std::string& fname) { + return DoWriteStringToFile(env, data, fname, true); +} + +Status ReadFileToString(Env* env, const std::string& fname, std::string* data) { + data->clear(); + SequentialFile* file; + Status s = env->NewSequentialFile(fname, &file); + if (!s.ok()) { + return s; + } + static const int kBufferSize = 8192; + char* space = new char[kBufferSize]; + while (true) { + Slice fragment; + s = file->Read(kBufferSize, &fragment, space); + if (!s.ok()) { + break; + } + data->append(fragment.data(), fragment.size()); + if (fragment.empty()) { + break; + } + } + delete[] space; + delete file; + return s; +} + +EnvWrapper::~EnvWrapper() { +} + +} // namespace leveldb diff --git a/src/leveldb/util/env_posix.cc b/src/leveldb/util/env_posix.cc new file mode 100644 index 0000000..93eadb1 --- /dev/null +++ b/src/leveldb/util/env_posix.cc @@ -0,0 +1,610 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +#if !defined(LEVELDB_PLATFORM_WINDOWS) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(LEVELDB_PLATFORM_ANDROID) +#include +#endif +#include "leveldb/env.h" +#include "leveldb/slice.h" +#include "port/port.h" +#include "util/logging.h" +#include "util/mutexlock.h" +#include "util/posix_logger.h" + +namespace leveldb { + +namespace { + +static Status IOError(const std::string& context, int err_number) { + return Status::IOError(context, strerror(err_number)); +} + +class PosixSequentialFile: public SequentialFile { + private: + std::string filename_; + FILE* file_; + + public: + PosixSequentialFile(const std::string& fname, FILE* f) + : filename_(fname), file_(f) { } + virtual ~PosixSequentialFile() { fclose(file_); } + + virtual Status Read(size_t n, Slice* result, char* scratch) { + Status s; + size_t r = fread_unlocked(scratch, 1, n, file_); + *result = Slice(scratch, r); + if (r < n) { + if (feof(file_)) { + // We leave status as ok if we hit the end of the file + } else { + // A partial read with an error: return a non-ok status + s = IOError(filename_, errno); + } + } + return s; + } + + virtual Status Skip(uint64_t n) { + if (fseek(file_, n, SEEK_CUR)) { + return IOError(filename_, errno); + } + return Status::OK(); + } +}; + +// pread() based random-access +class PosixRandomAccessFile: public RandomAccessFile { + private: + std::string filename_; + int fd_; + + public: + PosixRandomAccessFile(const std::string& fname, int fd) + : filename_(fname), fd_(fd) { } + virtual ~PosixRandomAccessFile() { close(fd_); } + + virtual Status Read(uint64_t offset, size_t n, Slice* result, + char* scratch) const { + Status s; + ssize_t r = pread(fd_, scratch, n, static_cast(offset)); + *result = Slice(scratch, (r < 0) ? 0 : r); + if (r < 0) { + // An error: return a non-ok status + s = IOError(filename_, errno); + } + return s; + } +}; + +// Helper class to limit mmap file usage so that we do not end up +// running out virtual memory or running into kernel performance +// problems for very large databases. +class MmapLimiter { + public: + // Up to 1000 mmaps for 64-bit binaries; none for smaller pointer sizes. + MmapLimiter() { + SetAllowed(sizeof(void*) >= 8 ? 1000 : 0); + } + + // If another mmap slot is available, acquire it and return true. + // Else return false. + bool Acquire() { + if (GetAllowed() <= 0) { + return false; + } + MutexLock l(&mu_); + intptr_t x = GetAllowed(); + if (x <= 0) { + return false; + } else { + SetAllowed(x - 1); + return true; + } + } + + // Release a slot acquired by a previous call to Acquire() that returned true. + void Release() { + MutexLock l(&mu_); + SetAllowed(GetAllowed() + 1); + } + + private: + port::Mutex mu_; + port::AtomicPointer allowed_; + + intptr_t GetAllowed() const { + return reinterpret_cast(allowed_.Acquire_Load()); + } + + // REQUIRES: mu_ must be held + void SetAllowed(intptr_t v) { + allowed_.Release_Store(reinterpret_cast(v)); + } + + MmapLimiter(const MmapLimiter&); + void operator=(const MmapLimiter&); +}; + +// mmap() based random-access +class PosixMmapReadableFile: public RandomAccessFile { + private: + std::string filename_; + void* mmapped_region_; + size_t length_; + MmapLimiter* limiter_; + + public: + // base[0,length-1] contains the mmapped contents of the file. + PosixMmapReadableFile(const std::string& fname, void* base, size_t length, + MmapLimiter* limiter) + : filename_(fname), mmapped_region_(base), length_(length), + limiter_(limiter) { + } + + virtual ~PosixMmapReadableFile() { + munmap(mmapped_region_, length_); + limiter_->Release(); + } + + virtual Status Read(uint64_t offset, size_t n, Slice* result, + char* scratch) const { + Status s; + if (offset + n > length_) { + *result = Slice(); + s = IOError(filename_, EINVAL); + } else { + *result = Slice(reinterpret_cast(mmapped_region_) + offset, n); + } + return s; + } +}; + +class PosixWritableFile : public WritableFile { + private: + std::string filename_; + FILE* file_; + + public: + PosixWritableFile(const std::string& fname, FILE* f) + : filename_(fname), file_(f) { } + + ~PosixWritableFile() { + if (file_ != NULL) { + // Ignoring any potential errors + fclose(file_); + } + } + + virtual Status Append(const Slice& data) { + size_t r = fwrite_unlocked(data.data(), 1, data.size(), file_); + if (r != data.size()) { + return IOError(filename_, errno); + } + return Status::OK(); + } + + virtual Status Close() { + Status result; + if (fclose(file_) != 0) { + result = IOError(filename_, errno); + } + file_ = NULL; + return result; + } + + virtual Status Flush() { + if (fflush_unlocked(file_) != 0) { + return IOError(filename_, errno); + } + return Status::OK(); + } + + Status SyncDirIfManifest() { + const char* f = filename_.c_str(); + const char* sep = strrchr(f, '/'); + Slice basename; + std::string dir; + if (sep == NULL) { + dir = "."; + basename = f; + } else { + dir = std::string(f, sep - f); + basename = sep + 1; + } + Status s; + if (basename.starts_with("MANIFEST")) { + int fd = open(dir.c_str(), O_RDONLY); + if (fd < 0) { + s = IOError(dir, errno); + } else { + if (fsync(fd) < 0) { + s = IOError(dir, errno); + } + close(fd); + } + } + return s; + } + + virtual Status Sync() { + // Ensure new files referred to by the manifest are in the filesystem. + Status s = SyncDirIfManifest(); + if (!s.ok()) { + return s; + } + if (fflush_unlocked(file_) != 0 || + fdatasync(fileno(file_)) != 0) { + s = Status::IOError(filename_, strerror(errno)); + } + return s; + } +}; + +static int LockOrUnlock(int fd, bool lock) { + errno = 0; + struct flock f; + memset(&f, 0, sizeof(f)); + f.l_type = (lock ? F_WRLCK : F_UNLCK); + f.l_whence = SEEK_SET; + f.l_start = 0; + f.l_len = 0; // Lock/unlock entire file + return fcntl(fd, F_SETLK, &f); +} + +class PosixFileLock : public FileLock { + public: + int fd_; + std::string name_; +}; + +// Set of locked files. We keep a separate set instead of just +// relying on fcntrl(F_SETLK) since fcntl(F_SETLK) does not provide +// any protection against multiple uses from the same process. +class PosixLockTable { + private: + port::Mutex mu_; + std::set locked_files_; + public: + bool Insert(const std::string& fname) { + MutexLock l(&mu_); + return locked_files_.insert(fname).second; + } + void Remove(const std::string& fname) { + MutexLock l(&mu_); + locked_files_.erase(fname); + } +}; + +class PosixEnv : public Env { + public: + PosixEnv(); + virtual ~PosixEnv() { + fprintf(stderr, "Destroying Env::Default()\n"); + abort(); + } + + virtual Status NewSequentialFile(const std::string& fname, + SequentialFile** result) { + FILE* f = fopen(fname.c_str(), "r"); + if (f == NULL) { + *result = NULL; + return IOError(fname, errno); + } else { + *result = new PosixSequentialFile(fname, f); + return Status::OK(); + } + } + + virtual Status NewRandomAccessFile(const std::string& fname, + RandomAccessFile** result) { + *result = NULL; + Status s; + int fd = open(fname.c_str(), O_RDONLY); + if (fd < 0) { + s = IOError(fname, errno); + } else if (mmap_limit_.Acquire()) { + uint64_t size; + s = GetFileSize(fname, &size); + if (s.ok()) { + void* base = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); + if (base != MAP_FAILED) { + *result = new PosixMmapReadableFile(fname, base, size, &mmap_limit_); + } else { + s = IOError(fname, errno); + } + } + close(fd); + if (!s.ok()) { + mmap_limit_.Release(); + } + } else { + *result = new PosixRandomAccessFile(fname, fd); + } + return s; + } + + virtual Status NewWritableFile(const std::string& fname, + WritableFile** result) { + Status s; + FILE* f = fopen(fname.c_str(), "w"); + if (f == NULL) { + *result = NULL; + s = IOError(fname, errno); + } else { + *result = new PosixWritableFile(fname, f); + } + return s; + } + + virtual bool FileExists(const std::string& fname) { + return access(fname.c_str(), F_OK) == 0; + } + + virtual Status GetChildren(const std::string& dir, + std::vector* result) { + result->clear(); + DIR* d = opendir(dir.c_str()); + if (d == NULL) { + return IOError(dir, errno); + } + struct dirent* entry; + while ((entry = readdir(d)) != NULL) { + result->push_back(entry->d_name); + } + closedir(d); + return Status::OK(); + } + + virtual Status DeleteFile(const std::string& fname) { + Status result; + if (unlink(fname.c_str()) != 0) { + result = IOError(fname, errno); + } + return result; + } + + virtual Status CreateDir(const std::string& name) { + Status result; + if (mkdir(name.c_str(), 0755) != 0) { + result = IOError(name, errno); + } + return result; + } + + virtual Status DeleteDir(const std::string& name) { + Status result; + if (rmdir(name.c_str()) != 0) { + result = IOError(name, errno); + } + return result; + } + + virtual Status GetFileSize(const std::string& fname, uint64_t* size) { + Status s; + struct stat sbuf; + if (stat(fname.c_str(), &sbuf) != 0) { + *size = 0; + s = IOError(fname, errno); + } else { + *size = sbuf.st_size; + } + return s; + } + + virtual Status RenameFile(const std::string& src, const std::string& target) { + Status result; + if (rename(src.c_str(), target.c_str()) != 0) { + result = IOError(src, errno); + } + return result; + } + + virtual Status LockFile(const std::string& fname, FileLock** lock) { + *lock = NULL; + Status result; + int fd = open(fname.c_str(), O_RDWR | O_CREAT, 0644); + if (fd < 0) { + result = IOError(fname, errno); + } else if (!locks_.Insert(fname)) { + close(fd); + result = Status::IOError("lock " + fname, "already held by process"); + } else if (LockOrUnlock(fd, true) == -1) { + result = IOError("lock " + fname, errno); + close(fd); + locks_.Remove(fname); + } else { + PosixFileLock* my_lock = new PosixFileLock; + my_lock->fd_ = fd; + my_lock->name_ = fname; + *lock = my_lock; + } + return result; + } + + virtual Status UnlockFile(FileLock* lock) { + PosixFileLock* my_lock = reinterpret_cast(lock); + Status result; + if (LockOrUnlock(my_lock->fd_, false) == -1) { + result = IOError("unlock", errno); + } + locks_.Remove(my_lock->name_); + close(my_lock->fd_); + delete my_lock; + return result; + } + + virtual void Schedule(void (*function)(void*), void* arg); + + virtual void StartThread(void (*function)(void* arg), void* arg); + + virtual Status GetTestDirectory(std::string* result) { + const char* env = getenv("TEST_TMPDIR"); + if (env && env[0] != '\0') { + *result = env; + } else { + char buf[100]; + snprintf(buf, sizeof(buf), "/tmp/leveldbtest-%d", int(geteuid())); + *result = buf; + } + // Directory may already exist + CreateDir(*result); + return Status::OK(); + } + + static uint64_t gettid() { + pthread_t tid = pthread_self(); + uint64_t thread_id = 0; + memcpy(&thread_id, &tid, std::min(sizeof(thread_id), sizeof(tid))); + return thread_id; + } + + virtual Status NewLogger(const std::string& fname, Logger** result) { + FILE* f = fopen(fname.c_str(), "w"); + if (f == NULL) { + *result = NULL; + return IOError(fname, errno); + } else { + *result = new PosixLogger(f, &PosixEnv::gettid); + return Status::OK(); + } + } + + virtual uint64_t NowMicros() { + struct timeval tv; + gettimeofday(&tv, NULL); + return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; + } + + virtual void SleepForMicroseconds(int micros) { + usleep(micros); + } + + private: + void PthreadCall(const char* label, int result) { + if (result != 0) { + fprintf(stderr, "pthread %s: %s\n", label, strerror(result)); + abort(); + } + } + + // BGThread() is the body of the background thread + void BGThread(); + static void* BGThreadWrapper(void* arg) { + reinterpret_cast(arg)->BGThread(); + return NULL; + } + + pthread_mutex_t mu_; + pthread_cond_t bgsignal_; + pthread_t bgthread_; + bool started_bgthread_; + + // Entry per Schedule() call + struct BGItem { void* arg; void (*function)(void*); }; + typedef std::deque BGQueue; + BGQueue queue_; + + PosixLockTable locks_; + MmapLimiter mmap_limit_; +}; + +PosixEnv::PosixEnv() : started_bgthread_(false) { + PthreadCall("mutex_init", pthread_mutex_init(&mu_, NULL)); + PthreadCall("cvar_init", pthread_cond_init(&bgsignal_, NULL)); +} + +void PosixEnv::Schedule(void (*function)(void*), void* arg) { + PthreadCall("lock", pthread_mutex_lock(&mu_)); + + // Start background thread if necessary + if (!started_bgthread_) { + started_bgthread_ = true; + PthreadCall( + "create thread", + pthread_create(&bgthread_, NULL, &PosixEnv::BGThreadWrapper, this)); + } + + // If the queue is currently empty, the background thread may currently be + // waiting. + if (queue_.empty()) { + PthreadCall("signal", pthread_cond_signal(&bgsignal_)); + } + + // Add to priority queue + queue_.push_back(BGItem()); + queue_.back().function = function; + queue_.back().arg = arg; + + PthreadCall("unlock", pthread_mutex_unlock(&mu_)); +} + +void PosixEnv::BGThread() { + while (true) { + // Wait until there is an item that is ready to run + PthreadCall("lock", pthread_mutex_lock(&mu_)); + while (queue_.empty()) { + PthreadCall("wait", pthread_cond_wait(&bgsignal_, &mu_)); + } + + void (*function)(void*) = queue_.front().function; + void* arg = queue_.front().arg; + queue_.pop_front(); + + PthreadCall("unlock", pthread_mutex_unlock(&mu_)); + (*function)(arg); + } +} + +namespace { +struct StartThreadState { + void (*user_function)(void*); + void* arg; +}; +} +static void* StartThreadWrapper(void* arg) { + StartThreadState* state = reinterpret_cast(arg); + state->user_function(state->arg); + delete state; + return NULL; +} + +void PosixEnv::StartThread(void (*function)(void* arg), void* arg) { + pthread_t t; + StartThreadState* state = new StartThreadState; + state->user_function = function; + state->arg = arg; + PthreadCall("start thread", + pthread_create(&t, NULL, &StartThreadWrapper, state)); +} + +} // namespace + +static pthread_once_t once = PTHREAD_ONCE_INIT; +static Env* default_env; +static void InitDefaultEnv() { default_env = new PosixEnv; } + +Env* Env::Default() { + pthread_once(&once, InitDefaultEnv); + return default_env; +} + +} // namespace leveldb + +#endif diff --git a/src/leveldb/util/env_test.cc b/src/leveldb/util/env_test.cc new file mode 100644 index 0000000..b72cb44 --- /dev/null +++ b/src/leveldb/util/env_test.cc @@ -0,0 +1,104 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/env.h" + +#include "port/port.h" +#include "util/testharness.h" + +namespace leveldb { + +static const int kDelayMicros = 100000; + +class EnvPosixTest { + private: + port::Mutex mu_; + std::string events_; + + public: + Env* env_; + EnvPosixTest() : env_(Env::Default()) { } +}; + +static void SetBool(void* ptr) { + reinterpret_cast(ptr)->NoBarrier_Store(ptr); +} + +TEST(EnvPosixTest, RunImmediately) { + port::AtomicPointer called (NULL); + env_->Schedule(&SetBool, &called); + Env::Default()->SleepForMicroseconds(kDelayMicros); + ASSERT_TRUE(called.NoBarrier_Load() != NULL); +} + +TEST(EnvPosixTest, RunMany) { + port::AtomicPointer last_id (NULL); + + struct CB { + port::AtomicPointer* last_id_ptr; // Pointer to shared slot + uintptr_t id; // Order# for the execution of this callback + + CB(port::AtomicPointer* p, int i) : last_id_ptr(p), id(i) { } + + static void Run(void* v) { + CB* cb = reinterpret_cast(v); + void* cur = cb->last_id_ptr->NoBarrier_Load(); + ASSERT_EQ(cb->id-1, reinterpret_cast(cur)); + cb->last_id_ptr->Release_Store(reinterpret_cast(cb->id)); + } + }; + + // Schedule in different order than start time + CB cb1(&last_id, 1); + CB cb2(&last_id, 2); + CB cb3(&last_id, 3); + CB cb4(&last_id, 4); + env_->Schedule(&CB::Run, &cb1); + env_->Schedule(&CB::Run, &cb2); + env_->Schedule(&CB::Run, &cb3); + env_->Schedule(&CB::Run, &cb4); + + Env::Default()->SleepForMicroseconds(kDelayMicros); + void* cur = last_id.Acquire_Load(); + ASSERT_EQ(4, reinterpret_cast(cur)); +} + +struct State { + port::Mutex mu; + int val; + int num_running; +}; + +static void ThreadBody(void* arg) { + State* s = reinterpret_cast(arg); + s->mu.Lock(); + s->val += 1; + s->num_running -= 1; + s->mu.Unlock(); +} + +TEST(EnvPosixTest, StartThread) { + State state; + state.val = 0; + state.num_running = 3; + for (int i = 0; i < 3; i++) { + env_->StartThread(&ThreadBody, &state); + } + while (true) { + state.mu.Lock(); + int num = state.num_running; + state.mu.Unlock(); + if (num == 0) { + break; + } + Env::Default()->SleepForMicroseconds(kDelayMicros); + } + ASSERT_EQ(state.val, 3); +} + +} // namespace leveldb + +int main(int argc, char** argv) { + return leveldb::test::RunAllTests(); +} diff --git a/src/leveldb/util/env_win.cc b/src/leveldb/util/env_win.cc new file mode 100644 index 0000000..ef2ecae --- /dev/null +++ b/src/leveldb/util/env_win.cc @@ -0,0 +1,1031 @@ +// This file contains source that originates from: +// http://code.google.com/p/leveldbwin/source/browse/trunk/win32_impl_src/env_win32.h +// http://code.google.com/p/leveldbwin/source/browse/trunk/win32_impl_src/port_win32.cc +// Those files dont' have any explict license headers but the +// project (http://code.google.com/p/leveldbwin/) lists the 'New BSD License' +// as the license. +#if defined(LEVELDB_PLATFORM_WINDOWS) +#include + + +#include "leveldb/env.h" + +#include "port/port.h" +#include "leveldb/slice.h" +#include "util/logging.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef max +#undef max +#endif + +#ifndef va_copy +#define va_copy(d,s) ((d) = (s)) +#endif + +#if defined DeleteFile +#undef DeleteFile +#endif + +//Declarations +namespace leveldb +{ + +namespace Win32 +{ + +#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ + TypeName(const TypeName&); \ + void operator=(const TypeName&) + +std::string GetCurrentDir(); +std::wstring GetCurrentDirW(); + +static const std::string CurrentDir = GetCurrentDir(); +static const std::wstring CurrentDirW = GetCurrentDirW(); + +std::string& ModifyPath(std::string& path); +std::wstring& ModifyPath(std::wstring& path); + +std::string GetLastErrSz(); +std::wstring GetLastErrSzW(); + +size_t GetPageSize(); + +typedef void (*ScheduleProc)(void*) ; + +struct WorkItemWrapper +{ + WorkItemWrapper(ScheduleProc proc_,void* content_); + ScheduleProc proc; + void* pContent; +}; + +DWORD WINAPI WorkItemWrapperProc(LPVOID pContent); + +class Win32SequentialFile : public SequentialFile +{ +public: + friend class Win32Env; + virtual ~Win32SequentialFile(); + virtual Status Read(size_t n, Slice* result, char* scratch); + virtual Status Skip(uint64_t n); + BOOL isEnable(); +private: + BOOL _Init(); + void _CleanUp(); + Win32SequentialFile(const std::string& fname); + std::string _filename; + ::HANDLE _hFile; + DISALLOW_COPY_AND_ASSIGN(Win32SequentialFile); +}; + +class Win32RandomAccessFile : public RandomAccessFile +{ +public: + friend class Win32Env; + virtual ~Win32RandomAccessFile(); + virtual Status Read(uint64_t offset, size_t n, Slice* result,char* scratch) const; + BOOL isEnable(); +private: + BOOL _Init(LPCWSTR path); + void _CleanUp(); + Win32RandomAccessFile(const std::string& fname); + HANDLE _hFile; + const std::string _filename; + DISALLOW_COPY_AND_ASSIGN(Win32RandomAccessFile); +}; + +class Win32MapFile : public WritableFile +{ +public: + Win32MapFile(const std::string& fname); + + ~Win32MapFile(); + virtual Status Append(const Slice& data); + virtual Status Close(); + virtual Status Flush(); + virtual Status Sync(); + BOOL isEnable(); +private: + std::string _filename; + HANDLE _hFile; + size_t _page_size; + size_t _map_size; // How much extra memory to map at a time + char* _base; // The mapped region + HANDLE _base_handle; + char* _limit; // Limit of the mapped region + char* _dst; // Where to write next (in range [base_,limit_]) + char* _last_sync; // Where have we synced up to + uint64_t _file_offset; // Offset of base_ in file + //LARGE_INTEGER file_offset_; + // Have we done an munmap of unsynced data? + bool _pending_sync; + + // Roundup x to a multiple of y + static size_t _Roundup(size_t x, size_t y); + size_t _TruncateToPageBoundary(size_t s); + bool _UnmapCurrentRegion(); + bool _MapNewRegion(); + DISALLOW_COPY_AND_ASSIGN(Win32MapFile); + BOOL _Init(LPCWSTR Path); +}; + +class Win32FileLock : public FileLock +{ +public: + friend class Win32Env; + virtual ~Win32FileLock(); + BOOL isEnable(); +private: + BOOL _Init(LPCWSTR path); + void _CleanUp(); + Win32FileLock(const std::string& fname); + HANDLE _hFile; + std::string _filename; + DISALLOW_COPY_AND_ASSIGN(Win32FileLock); +}; + +class Win32Logger : public Logger +{ +public: + friend class Win32Env; + virtual ~Win32Logger(); + virtual void Logv(const char* format, va_list ap); +private: + explicit Win32Logger(WritableFile* pFile); + WritableFile* _pFileProxy; + DISALLOW_COPY_AND_ASSIGN(Win32Logger); +}; + +class Win32Env : public Env +{ +public: + Win32Env(); + virtual ~Win32Env(); + virtual Status NewSequentialFile(const std::string& fname, + SequentialFile** result); + + virtual Status NewRandomAccessFile(const std::string& fname, + RandomAccessFile** result); + virtual Status NewWritableFile(const std::string& fname, + WritableFile** result); + + virtual bool FileExists(const std::string& fname); + + virtual Status GetChildren(const std::string& dir, + std::vector* result); + + virtual Status DeleteFile(const std::string& fname); + + virtual Status CreateDir(const std::string& dirname); + + virtual Status DeleteDir(const std::string& dirname); + + virtual Status GetFileSize(const std::string& fname, uint64_t* file_size); + + virtual Status RenameFile(const std::string& src, + const std::string& target); + + virtual Status LockFile(const std::string& fname, FileLock** lock); + + virtual Status UnlockFile(FileLock* lock); + + virtual void Schedule( + void (*function)(void* arg), + void* arg); + + virtual void StartThread(void (*function)(void* arg), void* arg); + + virtual Status GetTestDirectory(std::string* path); + + //virtual void Logv(WritableFile* log, const char* format, va_list ap); + + virtual Status NewLogger(const std::string& fname, Logger** result); + + virtual uint64_t NowMicros(); + + virtual void SleepForMicroseconds(int micros); +}; + +void ToWidePath(const std::string& value, std::wstring& target) { + wchar_t buffer[MAX_PATH]; + MultiByteToWideChar(CP_ACP, 0, value.c_str(), -1, buffer, MAX_PATH); + target = buffer; +} + +void ToNarrowPath(const std::wstring& value, std::string& target) { + char buffer[MAX_PATH]; + WideCharToMultiByte(CP_ACP, 0, value.c_str(), -1, buffer, MAX_PATH, NULL, NULL); + target = buffer; +} + +std::string GetCurrentDir() +{ + CHAR path[MAX_PATH]; + ::GetModuleFileNameA(::GetModuleHandleA(NULL),path,MAX_PATH); + *strrchr(path,'\\') = 0; + return std::string(path); +} + +std::wstring GetCurrentDirW() +{ + WCHAR path[MAX_PATH]; + ::GetModuleFileNameW(::GetModuleHandleW(NULL),path,MAX_PATH); + *wcsrchr(path,L'\\') = 0; + return std::wstring(path); +} + +std::string& ModifyPath(std::string& path) +{ + if(path[0] == '/' || path[0] == '\\'){ + path = CurrentDir + path; + } + std::replace(path.begin(),path.end(),'/','\\'); + + return path; +} + +std::wstring& ModifyPath(std::wstring& path) +{ + if(path[0] == L'/' || path[0] == L'\\'){ + path = CurrentDirW + path; + } + std::replace(path.begin(),path.end(),L'/',L'\\'); + return path; +} + +std::string GetLastErrSz() +{ + LPWSTR lpMsgBuf; + FormatMessageW( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + 0, // Default language + (LPWSTR) &lpMsgBuf, + 0, + NULL + ); + std::string Err; + ToNarrowPath(lpMsgBuf, Err); + LocalFree( lpMsgBuf ); + return Err; +} + +std::wstring GetLastErrSzW() +{ + LPVOID lpMsgBuf; + FormatMessageW( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + 0, // Default language + (LPWSTR) &lpMsgBuf, + 0, + NULL + ); + std::wstring Err = (LPCWSTR)lpMsgBuf; + LocalFree(lpMsgBuf); + return Err; +} + +WorkItemWrapper::WorkItemWrapper( ScheduleProc proc_,void* content_ ) : + proc(proc_),pContent(content_) +{ + +} + +DWORD WINAPI WorkItemWrapperProc(LPVOID pContent) +{ + WorkItemWrapper* item = static_cast(pContent); + ScheduleProc TempProc = item->proc; + void* arg = item->pContent; + delete item; + TempProc(arg); + return 0; +} + +size_t GetPageSize() +{ + SYSTEM_INFO si; + GetSystemInfo(&si); + return std::max(si.dwPageSize,si.dwAllocationGranularity); +} + +const size_t g_PageSize = GetPageSize(); + + +Win32SequentialFile::Win32SequentialFile( const std::string& fname ) : + _filename(fname),_hFile(NULL) +{ + _Init(); +} + +Win32SequentialFile::~Win32SequentialFile() +{ + _CleanUp(); +} + +Status Win32SequentialFile::Read( size_t n, Slice* result, char* scratch ) +{ + Status sRet; + DWORD hasRead = 0; + if(_hFile && ReadFile(_hFile,scratch,n,&hasRead,NULL) ){ + *result = Slice(scratch,hasRead); + } else { + sRet = Status::IOError(_filename, Win32::GetLastErrSz() ); + } + return sRet; +} + +Status Win32SequentialFile::Skip( uint64_t n ) +{ + Status sRet; + LARGE_INTEGER Move,NowPointer; + Move.QuadPart = n; + if(!SetFilePointerEx(_hFile,Move,&NowPointer,FILE_CURRENT)){ + sRet = Status::IOError(_filename,Win32::GetLastErrSz()); + } + return sRet; +} + +BOOL Win32SequentialFile::isEnable() +{ + return _hFile ? TRUE : FALSE; +} + +BOOL Win32SequentialFile::_Init() +{ + std::wstring path; + ToWidePath(_filename, path); + _hFile = CreateFileW(path.c_str(), + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + return _hFile ? TRUE : FALSE; +} + +void Win32SequentialFile::_CleanUp() +{ + if(_hFile){ + CloseHandle(_hFile); + _hFile = NULL; + } +} + +Win32RandomAccessFile::Win32RandomAccessFile( const std::string& fname ) : + _filename(fname),_hFile(NULL) +{ + std::wstring path; + ToWidePath(fname, path); + _Init( path.c_str() ); +} + +Win32RandomAccessFile::~Win32RandomAccessFile() +{ + _CleanUp(); +} + +Status Win32RandomAccessFile::Read(uint64_t offset,size_t n,Slice* result,char* scratch) const +{ + Status sRet; + OVERLAPPED ol = {0}; + ZeroMemory(&ol,sizeof(ol)); + ol.Offset = (DWORD)offset; + ol.OffsetHigh = (DWORD)(offset >> 32); + DWORD hasRead = 0; + if(!ReadFile(_hFile,scratch,n,&hasRead,&ol)) + sRet = Status::IOError(_filename,Win32::GetLastErrSz()); + else + *result = Slice(scratch,hasRead); + return sRet; +} + +BOOL Win32RandomAccessFile::_Init( LPCWSTR path ) +{ + BOOL bRet = FALSE; + if(!_hFile) + _hFile = ::CreateFileW(path,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,NULL); + if(!_hFile || _hFile == INVALID_HANDLE_VALUE ) + _hFile = NULL; + else + bRet = TRUE; + return bRet; +} + +BOOL Win32RandomAccessFile::isEnable() +{ + return _hFile ? TRUE : FALSE; +} + +void Win32RandomAccessFile::_CleanUp() +{ + if(_hFile){ + ::CloseHandle(_hFile); + _hFile = NULL; + } +} + +size_t Win32MapFile::_Roundup( size_t x, size_t y ) +{ + return ((x + y - 1) / y) * y; +} + +size_t Win32MapFile::_TruncateToPageBoundary( size_t s ) +{ + s -= (s & (_page_size - 1)); + assert((s % _page_size) == 0); + return s; +} + +bool Win32MapFile::_UnmapCurrentRegion() +{ + bool result = true; + if (_base != NULL) { + if (_last_sync < _limit) { + // Defer syncing this data until next Sync() call, if any + _pending_sync = true; + } + if (!UnmapViewOfFile(_base) || !CloseHandle(_base_handle)) + result = false; + _file_offset += _limit - _base; + _base = NULL; + _base_handle = NULL; + _limit = NULL; + _last_sync = NULL; + _dst = NULL; + // Increase the amount we map the next time, but capped at 1MB + if (_map_size < (1<<20)) { + _map_size *= 2; + } + } + return result; +} + +bool Win32MapFile::_MapNewRegion() +{ + assert(_base == NULL); + //LONG newSizeHigh = (LONG)((file_offset_ + map_size_) >> 32); + //LONG newSizeLow = (LONG)((file_offset_ + map_size_) & 0xFFFFFFFF); + DWORD off_hi = (DWORD)(_file_offset >> 32); + DWORD off_lo = (DWORD)(_file_offset & 0xFFFFFFFF); + LARGE_INTEGER newSize; + newSize.QuadPart = _file_offset + _map_size; + SetFilePointerEx(_hFile, newSize, NULL, FILE_BEGIN); + SetEndOfFile(_hFile); + + _base_handle = CreateFileMappingA( + _hFile, + NULL, + PAGE_READWRITE, + 0, + 0, + 0); + if (_base_handle != NULL) { + _base = (char*) MapViewOfFile(_base_handle, + FILE_MAP_ALL_ACCESS, + off_hi, + off_lo, + _map_size); + if (_base != NULL) { + _limit = _base + _map_size; + _dst = _base; + _last_sync = _base; + return true; + } + } + return false; +} + +Win32MapFile::Win32MapFile( const std::string& fname) : + _filename(fname), + _hFile(NULL), + _page_size(Win32::g_PageSize), + _map_size(_Roundup(65536, Win32::g_PageSize)), + _base(NULL), + _base_handle(NULL), + _limit(NULL), + _dst(NULL), + _last_sync(NULL), + _file_offset(0), + _pending_sync(false) +{ + std::wstring path; + ToWidePath(fname, path); + _Init(path.c_str()); + assert((Win32::g_PageSize & (Win32::g_PageSize - 1)) == 0); +} + +Status Win32MapFile::Append( const Slice& data ) +{ + const char* src = data.data(); + size_t left = data.size(); + Status s; + while (left > 0) { + assert(_base <= _dst); + assert(_dst <= _limit); + size_t avail = _limit - _dst; + if (avail == 0) { + if (!_UnmapCurrentRegion() || + !_MapNewRegion()) { + return Status::IOError("WinMmapFile.Append::UnmapCurrentRegion or MapNewRegion: ", Win32::GetLastErrSz()); + } + } + size_t n = (left <= avail) ? left : avail; + memcpy(_dst, src, n); + _dst += n; + src += n; + left -= n; + } + return s; +} + +Status Win32MapFile::Close() +{ + Status s; + size_t unused = _limit - _dst; + if (!_UnmapCurrentRegion()) { + s = Status::IOError("WinMmapFile.Close::UnmapCurrentRegion: ",Win32::GetLastErrSz()); + } else if (unused > 0) { + // Trim the extra space at the end of the file + LARGE_INTEGER newSize; + newSize.QuadPart = _file_offset - unused; + if (!SetFilePointerEx(_hFile, newSize, NULL, FILE_BEGIN)) { + s = Status::IOError("WinMmapFile.Close::SetFilePointer: ",Win32::GetLastErrSz()); + } else + SetEndOfFile(_hFile); + } + if (!CloseHandle(_hFile)) { + if (s.ok()) { + s = Status::IOError("WinMmapFile.Close::CloseHandle: ", Win32::GetLastErrSz()); + } + } + _hFile = INVALID_HANDLE_VALUE; + _base = NULL; + _base_handle = NULL; + _limit = NULL; + + return s; +} + +Status Win32MapFile::Sync() +{ + Status s; + if (_pending_sync) { + // Some unmapped data was not synced + _pending_sync = false; + if (!FlushFileBuffers(_hFile)) { + s = Status::IOError("WinMmapFile.Sync::FlushFileBuffers: ",Win32::GetLastErrSz()); + } + } + if (_dst > _last_sync) { + // Find the beginnings of the pages that contain the first and last + // bytes to be synced. + size_t p1 = _TruncateToPageBoundary(_last_sync - _base); + size_t p2 = _TruncateToPageBoundary(_dst - _base - 1); + _last_sync = _dst; + if (!FlushViewOfFile(_base + p1, p2 - p1 + _page_size)) { + s = Status::IOError("WinMmapFile.Sync::FlushViewOfFile: ",Win32::GetLastErrSz()); + } + } + return s; +} + +Status Win32MapFile::Flush() +{ + return Status::OK(); +} + +Win32MapFile::~Win32MapFile() +{ + if (_hFile != INVALID_HANDLE_VALUE) { + Win32MapFile::Close(); + } +} + +BOOL Win32MapFile::_Init( LPCWSTR Path ) +{ + DWORD Flag = PathFileExistsW(Path) ? OPEN_EXISTING : CREATE_ALWAYS; + _hFile = CreateFileW(Path, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_DELETE|FILE_SHARE_WRITE, + NULL, + Flag, + FILE_ATTRIBUTE_NORMAL, + NULL); + if(!_hFile || _hFile == INVALID_HANDLE_VALUE) + return FALSE; + else + return TRUE; +} + +BOOL Win32MapFile::isEnable() +{ + return _hFile ? TRUE : FALSE; +} + +Win32FileLock::Win32FileLock( const std::string& fname ) : + _hFile(NULL),_filename(fname) +{ + std::wstring path; + ToWidePath(fname, path); + _Init(path.c_str()); +} + +Win32FileLock::~Win32FileLock() +{ + _CleanUp(); +} + +BOOL Win32FileLock::_Init( LPCWSTR path ) +{ + BOOL bRet = FALSE; + if(!_hFile) + _hFile = ::CreateFileW(path,0,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); + if(!_hFile || _hFile == INVALID_HANDLE_VALUE ){ + _hFile = NULL; + } + else + bRet = TRUE; + return bRet; +} + +void Win32FileLock::_CleanUp() +{ + ::CloseHandle(_hFile); + _hFile = NULL; +} + +BOOL Win32FileLock::isEnable() +{ + return _hFile ? TRUE : FALSE; +} + +Win32Logger::Win32Logger(WritableFile* pFile) : _pFileProxy(pFile) +{ + assert(_pFileProxy); +} + +Win32Logger::~Win32Logger() +{ + if(_pFileProxy) + delete _pFileProxy; +} + +void Win32Logger::Logv( const char* format, va_list ap ) +{ + uint64_t thread_id = ::GetCurrentThreadId(); + + // We try twice: the first time with a fixed-size stack allocated buffer, + // and the second time with a much larger dynamically allocated buffer. + char buffer[500]; + for (int iter = 0; iter < 2; iter++) { + char* base; + int bufsize; + if (iter == 0) { + bufsize = sizeof(buffer); + base = buffer; + } else { + bufsize = 30000; + base = new char[bufsize]; + } + char* p = base; + char* limit = base + bufsize; + + SYSTEMTIME st; + GetLocalTime(&st); + p += snprintf(p, limit - p, + "%04d/%02d/%02d-%02d:%02d:%02d.%06d %llx ", + int(st.wYear), + int(st.wMonth), + int(st.wDay), + int(st.wHour), + int(st.wMinute), + int(st.wMinute), + int(st.wMilliseconds), + static_cast(thread_id)); + + // Print the message + if (p < limit) { + va_list backup_ap; + va_copy(backup_ap, ap); + p += vsnprintf(p, limit - p, format, backup_ap); + va_end(backup_ap); + } + + // Truncate to available space if necessary + if (p >= limit) { + if (iter == 0) { + continue; // Try again with larger buffer + } else { + p = limit - 1; + } + } + + // Add newline if necessary + if (p == base || p[-1] != '\n') { + *p++ = '\n'; + } + + assert(p <= limit); + DWORD hasWritten = 0; + if(_pFileProxy){ + _pFileProxy->Append(Slice(base, p - base)); + _pFileProxy->Flush(); + } + if (base != buffer) { + delete[] base; + } + break; + } +} + +bool Win32Env::FileExists(const std::string& fname) +{ + std::string path = fname; + std::wstring wpath; + ToWidePath(ModifyPath(path), wpath); + return ::PathFileExistsW(wpath.c_str()) ? true : false; +} + +Status Win32Env::GetChildren(const std::string& dir, std::vector* result) +{ + Status sRet; + ::WIN32_FIND_DATAW wfd; + std::string path = dir; + ModifyPath(path); + path += "\\*.*"; + std::wstring wpath; + ToWidePath(path, wpath); + + ::HANDLE hFind = ::FindFirstFileW(wpath.c_str() ,&wfd); + if(hFind && hFind != INVALID_HANDLE_VALUE){ + BOOL hasNext = TRUE; + std::string child; + while(hasNext){ + ToNarrowPath(wfd.cFileName, child); + if(child != ".." && child != ".") { + result->push_back(child); + } + hasNext = ::FindNextFileW(hFind,&wfd); + } + ::FindClose(hFind); + } + else + sRet = Status::IOError(dir,"Could not get children."); + return sRet; +} + +void Win32Env::SleepForMicroseconds( int micros ) +{ + ::Sleep((micros + 999) /1000); +} + + +Status Win32Env::DeleteFile( const std::string& fname ) +{ + Status sRet; + std::string path = fname; + std::wstring wpath; + ToWidePath(ModifyPath(path), wpath); + + if(!::DeleteFileW(wpath.c_str())) { + sRet = Status::IOError(path, "Could not delete file."); + } + return sRet; +} + +Status Win32Env::GetFileSize( const std::string& fname, uint64_t* file_size ) +{ + Status sRet; + std::string path = fname; + std::wstring wpath; + ToWidePath(ModifyPath(path), wpath); + + HANDLE file = ::CreateFileW(wpath.c_str(), + GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); + LARGE_INTEGER li; + if(::GetFileSizeEx(file,&li)){ + *file_size = (uint64_t)li.QuadPart; + }else + sRet = Status::IOError(path,"Could not get the file size."); + CloseHandle(file); + return sRet; +} + +Status Win32Env::RenameFile( const std::string& src, const std::string& target ) +{ + Status sRet; + std::string src_path = src; + std::wstring wsrc_path; + ToWidePath(ModifyPath(src_path), wsrc_path); + std::string target_path = target; + std::wstring wtarget_path; + ToWidePath(ModifyPath(target_path), wtarget_path); + + if(!MoveFileW(wsrc_path.c_str(), wtarget_path.c_str() ) ){ + DWORD err = GetLastError(); + if(err == 0x000000b7){ + if(!::DeleteFileW(wtarget_path.c_str() ) ) + sRet = Status::IOError(src, "Could not rename file."); + else if(!::MoveFileW(wsrc_path.c_str(), + wtarget_path.c_str() ) ) + sRet = Status::IOError(src, "Could not rename file."); + } + } + return sRet; +} + +Status Win32Env::LockFile( const std::string& fname, FileLock** lock ) +{ + Status sRet; + std::string path = fname; + ModifyPath(path); + Win32FileLock* _lock = new Win32FileLock(path); + if(!_lock->isEnable()){ + delete _lock; + *lock = NULL; + sRet = Status::IOError(path, "Could not lock file."); + } + else + *lock = _lock; + return sRet; +} + +Status Win32Env::UnlockFile( FileLock* lock ) +{ + Status sRet; + delete lock; + return sRet; +} + +void Win32Env::Schedule( void (*function)(void* arg), void* arg ) +{ + QueueUserWorkItem(Win32::WorkItemWrapperProc, + new Win32::WorkItemWrapper(function,arg), + WT_EXECUTEDEFAULT); +} + +void Win32Env::StartThread( void (*function)(void* arg), void* arg ) +{ + ::_beginthread(function,0,arg); +} + +Status Win32Env::GetTestDirectory( std::string* path ) +{ + Status sRet; + WCHAR TempPath[MAX_PATH]; + ::GetTempPathW(MAX_PATH,TempPath); + ToNarrowPath(TempPath, *path); + path->append("leveldb\\test\\"); + ModifyPath(*path); + return sRet; +} + +uint64_t Win32Env::NowMicros() +{ +#ifndef USE_VISTA_API +#define GetTickCount64 GetTickCount +#endif + return (uint64_t)(GetTickCount64()*1000); +} + +static Status CreateDirInner( const std::string& dirname ) +{ + Status sRet; + DWORD attr = ::GetFileAttributes(dirname.c_str()); + if (attr == INVALID_FILE_ATTRIBUTES) { // doesn't exist: + std::size_t slash = dirname.find_last_of("\\"); + if (slash != std::string::npos){ + sRet = CreateDirInner(dirname.substr(0, slash)); + if (!sRet.ok()) return sRet; + } + BOOL result = ::CreateDirectory(dirname.c_str(), NULL); + if (result == FALSE) { + sRet = Status::IOError(dirname, "Could not create directory."); + return sRet; + } + } + return sRet; +} + +Status Win32Env::CreateDir( const std::string& dirname ) +{ + std::string path = dirname; + if(path[path.length() - 1] != '\\'){ + path += '\\'; + } + ModifyPath(path); + + return CreateDirInner(path); +} + +Status Win32Env::DeleteDir( const std::string& dirname ) +{ + Status sRet; + std::wstring path; + ToWidePath(dirname, path); + ModifyPath(path); + if(!::RemoveDirectoryW( path.c_str() ) ){ + sRet = Status::IOError(dirname, "Could not delete directory."); + } + return sRet; +} + +Status Win32Env::NewSequentialFile( const std::string& fname, SequentialFile** result ) +{ + Status sRet; + std::string path = fname; + ModifyPath(path); + Win32SequentialFile* pFile = new Win32SequentialFile(path); + if(pFile->isEnable()){ + *result = pFile; + }else { + delete pFile; + sRet = Status::IOError(path, Win32::GetLastErrSz()); + } + return sRet; +} + +Status Win32Env::NewRandomAccessFile( const std::string& fname, RandomAccessFile** result ) +{ + Status sRet; + std::string path = fname; + Win32RandomAccessFile* pFile = new Win32RandomAccessFile(ModifyPath(path)); + if(!pFile->isEnable()){ + delete pFile; + *result = NULL; + sRet = Status::IOError(path, Win32::GetLastErrSz()); + }else + *result = pFile; + return sRet; +} + +Status Win32Env::NewLogger( const std::string& fname, Logger** result ) +{ + Status sRet; + std::string path = fname; + Win32MapFile* pMapFile = new Win32MapFile(ModifyPath(path)); + if(!pMapFile->isEnable()){ + delete pMapFile; + *result = NULL; + sRet = Status::IOError(path,"could not create a logger."); + }else + *result = new Win32Logger(pMapFile); + return sRet; +} + +Status Win32Env::NewWritableFile( const std::string& fname, WritableFile** result ) +{ + Status sRet; + std::string path = fname; + Win32MapFile* pFile = new Win32MapFile(ModifyPath(path)); + if(!pFile->isEnable()){ + *result = NULL; + sRet = Status::IOError(fname,Win32::GetLastErrSz()); + }else + *result = pFile; + return sRet; +} + +Win32Env::Win32Env() +{ + +} + +Win32Env::~Win32Env() +{ + +} + + +} // Win32 namespace + +static port::OnceType once = LEVELDB_ONCE_INIT; +static Env* default_env; +static void InitDefaultEnv() { default_env = new Win32::Win32Env(); } + +Env* Env::Default() { + port::InitOnce(&once, InitDefaultEnv); + return default_env; +} + +} // namespace leveldb + +#endif // defined(LEVELDB_PLATFORM_WINDOWS) diff --git a/src/leveldb/util/filter_policy.cc b/src/leveldb/util/filter_policy.cc new file mode 100644 index 0000000..7b045c8 --- /dev/null +++ b/src/leveldb/util/filter_policy.cc @@ -0,0 +1,11 @@ +// Copyright (c) 2012 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/filter_policy.h" + +namespace leveldb { + +FilterPolicy::~FilterPolicy() { } + +} // namespace leveldb diff --git a/src/leveldb/util/hash.cc b/src/leveldb/util/hash.cc new file mode 100644 index 0000000..07cf022 --- /dev/null +++ b/src/leveldb/util/hash.cc @@ -0,0 +1,52 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include +#include "util/coding.h" +#include "util/hash.h" + +// The FALLTHROUGH_INTENDED macro can be used to annotate implicit fall-through +// between switch labels. The real definition should be provided externally. +// This one is a fallback version for unsupported compilers. +#ifndef FALLTHROUGH_INTENDED +#define FALLTHROUGH_INTENDED do { } while (0) +#endif + +namespace leveldb { + +uint32_t Hash(const char* data, size_t n, uint32_t seed) { + // Similar to murmur hash + const uint32_t m = 0xc6a4a793; + const uint32_t r = 24; + const char* limit = data + n; + uint32_t h = seed ^ (n * m); + + // Pick up four bytes at a time + while (data + 4 <= limit) { + uint32_t w = DecodeFixed32(data); + data += 4; + h += w; + h *= m; + h ^= (h >> 16); + } + + // Pick up remaining bytes + switch (limit - data) { + case 3: + h += data[2] << 16; + FALLTHROUGH_INTENDED; + case 2: + h += data[1] << 8; + FALLTHROUGH_INTENDED; + case 1: + h += data[0]; + h *= m; + h ^= (h >> r); + break; + } + return h; +} + + +} // namespace leveldb diff --git a/src/leveldb/util/hash.h b/src/leveldb/util/hash.h new file mode 100644 index 0000000..8889d56 --- /dev/null +++ b/src/leveldb/util/hash.h @@ -0,0 +1,19 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// Simple hash function used for internal data structures + +#ifndef STORAGE_LEVELDB_UTIL_HASH_H_ +#define STORAGE_LEVELDB_UTIL_HASH_H_ + +#include +#include + +namespace leveldb { + +extern uint32_t Hash(const char* data, size_t n, uint32_t seed); + +} + +#endif // STORAGE_LEVELDB_UTIL_HASH_H_ diff --git a/src/leveldb/util/histogram.cc b/src/leveldb/util/histogram.cc new file mode 100644 index 0000000..bb95f58 --- /dev/null +++ b/src/leveldb/util/histogram.cc @@ -0,0 +1,139 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include +#include +#include "port/port.h" +#include "util/histogram.h" + +namespace leveldb { + +const double Histogram::kBucketLimit[kNumBuckets] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 25, 30, 35, 40, 45, + 50, 60, 70, 80, 90, 100, 120, 140, 160, 180, 200, 250, 300, 350, 400, 450, + 500, 600, 700, 800, 900, 1000, 1200, 1400, 1600, 1800, 2000, 2500, 3000, + 3500, 4000, 4500, 5000, 6000, 7000, 8000, 9000, 10000, 12000, 14000, + 16000, 18000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 60000, + 70000, 80000, 90000, 100000, 120000, 140000, 160000, 180000, 200000, + 250000, 300000, 350000, 400000, 450000, 500000, 600000, 700000, 800000, + 900000, 1000000, 1200000, 1400000, 1600000, 1800000, 2000000, 2500000, + 3000000, 3500000, 4000000, 4500000, 5000000, 6000000, 7000000, 8000000, + 9000000, 10000000, 12000000, 14000000, 16000000, 18000000, 20000000, + 25000000, 30000000, 35000000, 40000000, 45000000, 50000000, 60000000, + 70000000, 80000000, 90000000, 100000000, 120000000, 140000000, 160000000, + 180000000, 200000000, 250000000, 300000000, 350000000, 400000000, + 450000000, 500000000, 600000000, 700000000, 800000000, 900000000, + 1000000000, 1200000000, 1400000000, 1600000000, 1800000000, 2000000000, + 2500000000.0, 3000000000.0, 3500000000.0, 4000000000.0, 4500000000.0, + 5000000000.0, 6000000000.0, 7000000000.0, 8000000000.0, 9000000000.0, + 1e200, +}; + +void Histogram::Clear() { + min_ = kBucketLimit[kNumBuckets-1]; + max_ = 0; + num_ = 0; + sum_ = 0; + sum_squares_ = 0; + for (int i = 0; i < kNumBuckets; i++) { + buckets_[i] = 0; + } +} + +void Histogram::Add(double value) { + // Linear search is fast enough for our usage in db_bench + int b = 0; + while (b < kNumBuckets - 1 && kBucketLimit[b] <= value) { + b++; + } + buckets_[b] += 1.0; + if (min_ > value) min_ = value; + if (max_ < value) max_ = value; + num_++; + sum_ += value; + sum_squares_ += (value * value); +} + +void Histogram::Merge(const Histogram& other) { + if (other.min_ < min_) min_ = other.min_; + if (other.max_ > max_) max_ = other.max_; + num_ += other.num_; + sum_ += other.sum_; + sum_squares_ += other.sum_squares_; + for (int b = 0; b < kNumBuckets; b++) { + buckets_[b] += other.buckets_[b]; + } +} + +double Histogram::Median() const { + return Percentile(50.0); +} + +double Histogram::Percentile(double p) const { + double threshold = num_ * (p / 100.0); + double sum = 0; + for (int b = 0; b < kNumBuckets; b++) { + sum += buckets_[b]; + if (sum >= threshold) { + // Scale linearly within this bucket + double left_point = (b == 0) ? 0 : kBucketLimit[b-1]; + double right_point = kBucketLimit[b]; + double left_sum = sum - buckets_[b]; + double right_sum = sum; + double pos = (threshold - left_sum) / (right_sum - left_sum); + double r = left_point + (right_point - left_point) * pos; + if (r < min_) r = min_; + if (r > max_) r = max_; + return r; + } + } + return max_; +} + +double Histogram::Average() const { + if (num_ == 0.0) return 0; + return sum_ / num_; +} + +double Histogram::StandardDeviation() const { + if (num_ == 0.0) return 0; + double variance = (sum_squares_ * num_ - sum_ * sum_) / (num_ * num_); + return sqrt(variance); +} + +std::string Histogram::ToString() const { + std::string r; + char buf[200]; + snprintf(buf, sizeof(buf), + "Count: %.0f Average: %.4f StdDev: %.2f\n", + num_, Average(), StandardDeviation()); + r.append(buf); + snprintf(buf, sizeof(buf), + "Min: %.4f Median: %.4f Max: %.4f\n", + (num_ == 0.0 ? 0.0 : min_), Median(), max_); + r.append(buf); + r.append("------------------------------------------------------\n"); + const double mult = 100.0 / num_; + double sum = 0; + for (int b = 0; b < kNumBuckets; b++) { + if (buckets_[b] <= 0.0) continue; + sum += buckets_[b]; + snprintf(buf, sizeof(buf), + "[ %7.0f, %7.0f ) %7.0f %7.3f%% %7.3f%% ", + ((b == 0) ? 0.0 : kBucketLimit[b-1]), // left + kBucketLimit[b], // right + buckets_[b], // count + mult * buckets_[b], // percentage + mult * sum); // cumulative percentage + r.append(buf); + + // Add hash marks based on percentage; 20 marks for 100%. + int marks = static_cast(20*(buckets_[b] / num_) + 0.5); + r.append(marks, '#'); + r.push_back('\n'); + } + return r; +} + +} // namespace leveldb diff --git a/src/leveldb/util/histogram.h b/src/leveldb/util/histogram.h new file mode 100644 index 0000000..1ef9f3c --- /dev/null +++ b/src/leveldb/util/histogram.h @@ -0,0 +1,42 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_UTIL_HISTOGRAM_H_ +#define STORAGE_LEVELDB_UTIL_HISTOGRAM_H_ + +#include + +namespace leveldb { + +class Histogram { + public: + Histogram() { } + ~Histogram() { } + + void Clear(); + void Add(double value); + void Merge(const Histogram& other); + + std::string ToString() const; + + private: + double min_; + double max_; + double num_; + double sum_; + double sum_squares_; + + enum { kNumBuckets = 154 }; + static const double kBucketLimit[kNumBuckets]; + double buckets_[kNumBuckets]; + + double Median() const; + double Percentile(double p) const; + double Average() const; + double StandardDeviation() const; +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_UTIL_HISTOGRAM_H_ diff --git a/src/leveldb/util/logging.cc b/src/leveldb/util/logging.cc new file mode 100644 index 0000000..22cf278 --- /dev/null +++ b/src/leveldb/util/logging.cc @@ -0,0 +1,81 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "util/logging.h" + +#include +#include +#include +#include +#include "leveldb/env.h" +#include "leveldb/slice.h" + +namespace leveldb { + +void AppendNumberTo(std::string* str, uint64_t num) { + char buf[30]; + snprintf(buf, sizeof(buf), "%llu", (unsigned long long) num); + str->append(buf); +} + +void AppendEscapedStringTo(std::string* str, const Slice& value) { + for (size_t i = 0; i < value.size(); i++) { + char c = value[i]; + if (c >= ' ' && c <= '~') { + str->push_back(c); + } else { + char buf[10]; + snprintf(buf, sizeof(buf), "\\x%02x", + static_cast(c) & 0xff); + str->append(buf); + } + } +} + +std::string NumberToString(uint64_t num) { + std::string r; + AppendNumberTo(&r, num); + return r; +} + +std::string EscapeString(const Slice& value) { + std::string r; + AppendEscapedStringTo(&r, value); + return r; +} + +bool ConsumeChar(Slice* in, char c) { + if (!in->empty() && (*in)[0] == c) { + in->remove_prefix(1); + return true; + } else { + return false; + } +} + +bool ConsumeDecimalNumber(Slice* in, uint64_t* val) { + uint64_t v = 0; + int digits = 0; + while (!in->empty()) { + char c = (*in)[0]; + if (c >= '0' && c <= '9') { + ++digits; + const int delta = (c - '0'); + static const uint64_t kMaxUint64 = ~static_cast(0); + if (v > kMaxUint64/10 || + (v == kMaxUint64/10 && delta > kMaxUint64%10)) { + // Overflow + return false; + } + v = (v * 10) + delta; + in->remove_prefix(1); + } else { + break; + } + } + *val = v; + return (digits > 0); +} + +} // namespace leveldb diff --git a/src/leveldb/util/logging.h b/src/leveldb/util/logging.h new file mode 100644 index 0000000..b0c5da8 --- /dev/null +++ b/src/leveldb/util/logging.h @@ -0,0 +1,47 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// Must not be included from any .h files to avoid polluting the namespace +// with macros. + +#ifndef STORAGE_LEVELDB_UTIL_LOGGING_H_ +#define STORAGE_LEVELDB_UTIL_LOGGING_H_ + +#include +#include +#include +#include "port/port.h" + +namespace leveldb { + +class Slice; +class WritableFile; + +// Append a human-readable printout of "num" to *str +extern void AppendNumberTo(std::string* str, uint64_t num); + +// Append a human-readable printout of "value" to *str. +// Escapes any non-printable characters found in "value". +extern void AppendEscapedStringTo(std::string* str, const Slice& value); + +// Return a human-readable printout of "num" +extern std::string NumberToString(uint64_t num); + +// Return a human-readable version of "value". +// Escapes any non-printable characters found in "value". +extern std::string EscapeString(const Slice& value); + +// If *in starts with "c", advances *in past the first character and +// returns true. Otherwise, returns false. +extern bool ConsumeChar(Slice* in, char c); + +// Parse a human-readable number from "*in" into *value. On success, +// advances "*in" past the consumed number and sets "*val" to the +// numeric value. Otherwise, returns false and leaves *in in an +// unspecified state. +extern bool ConsumeDecimalNumber(Slice* in, uint64_t* val); + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_UTIL_LOGGING_H_ diff --git a/src/leveldb/util/mutexlock.h b/src/leveldb/util/mutexlock.h new file mode 100644 index 0000000..1ff5a9e --- /dev/null +++ b/src/leveldb/util/mutexlock.h @@ -0,0 +1,41 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_ +#define STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_ + +#include "port/port.h" +#include "port/thread_annotations.h" + +namespace leveldb { + +// Helper class that locks a mutex on construction and unlocks the mutex when +// the destructor of the MutexLock object is invoked. +// +// Typical usage: +// +// void MyClass::MyMethod() { +// MutexLock l(&mu_); // mu_ is an instance variable +// ... some complex code, possibly with multiple return paths ... +// } + +class SCOPED_LOCKABLE MutexLock { + public: + explicit MutexLock(port::Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu) + : mu_(mu) { + this->mu_->Lock(); + } + ~MutexLock() UNLOCK_FUNCTION() { this->mu_->Unlock(); } + + private: + port::Mutex *const mu_; + // No copying allowed + MutexLock(const MutexLock&); + void operator=(const MutexLock&); +}; + +} // namespace leveldb + + +#endif // STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_ diff --git a/src/leveldb/util/options.cc b/src/leveldb/util/options.cc new file mode 100644 index 0000000..76af5b9 --- /dev/null +++ b/src/leveldb/util/options.cc @@ -0,0 +1,29 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "leveldb/options.h" + +#include "leveldb/comparator.h" +#include "leveldb/env.h" + +namespace leveldb { + +Options::Options() + : comparator(BytewiseComparator()), + create_if_missing(false), + error_if_exists(false), + paranoid_checks(false), + env(Env::Default()), + info_log(NULL), + write_buffer_size(4<<20), + max_open_files(1000), + block_cache(NULL), + block_size(4096), + block_restart_interval(16), + compression(kSnappyCompression), + filter_policy(NULL) { +} + + +} // namespace leveldb diff --git a/src/leveldb/util/posix_logger.h b/src/leveldb/util/posix_logger.h new file mode 100644 index 0000000..c063c2b --- /dev/null +++ b/src/leveldb/util/posix_logger.h @@ -0,0 +1,98 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// Logger implementation that can be shared by all environments +// where enough Posix functionality is available. + +#ifndef STORAGE_LEVELDB_UTIL_POSIX_LOGGER_H_ +#define STORAGE_LEVELDB_UTIL_POSIX_LOGGER_H_ + +#include +#include +#include +#include +#include "leveldb/env.h" + +namespace leveldb { + +class PosixLogger : public Logger { + private: + FILE* file_; + uint64_t (*gettid_)(); // Return the thread id for the current thread + public: + PosixLogger(FILE* f, uint64_t (*gettid)()) : file_(f), gettid_(gettid) { } + virtual ~PosixLogger() { + fclose(file_); + } + virtual void Logv(const char* format, va_list ap) { + const uint64_t thread_id = (*gettid_)(); + + // We try twice: the first time with a fixed-size stack allocated buffer, + // and the second time with a much larger dynamically allocated buffer. + char buffer[500]; + for (int iter = 0; iter < 2; iter++) { + char* base; + int bufsize; + if (iter == 0) { + bufsize = sizeof(buffer); + base = buffer; + } else { + bufsize = 30000; + base = new char[bufsize]; + } + char* p = base; + char* limit = base + bufsize; + + struct timeval now_tv; + gettimeofday(&now_tv, NULL); + const time_t seconds = now_tv.tv_sec; + struct tm t; + localtime_r(&seconds, &t); + p += snprintf(p, limit - p, + "%04d/%02d/%02d-%02d:%02d:%02d.%06d %llx ", + t.tm_year + 1900, + t.tm_mon + 1, + t.tm_mday, + t.tm_hour, + t.tm_min, + t.tm_sec, + static_cast(now_tv.tv_usec), + static_cast(thread_id)); + + // Print the message + if (p < limit) { + va_list backup_ap; + va_copy(backup_ap, ap); + p += vsnprintf(p, limit - p, format, backup_ap); + va_end(backup_ap); + } + + // Truncate to available space if necessary + if (p >= limit) { + if (iter == 0) { + continue; // Try again with larger buffer + } else { + p = limit - 1; + } + } + + // Add newline if necessary + if (p == base || p[-1] != '\n') { + *p++ = '\n'; + } + + assert(p <= limit); + fwrite(base, 1, p - base, file_); + fflush(file_); + if (base != buffer) { + delete[] base; + } + break; + } + } +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_UTIL_POSIX_LOGGER_H_ diff --git a/src/leveldb/util/random.h b/src/leveldb/util/random.h new file mode 100644 index 0000000..ddd51b1 --- /dev/null +++ b/src/leveldb/util/random.h @@ -0,0 +1,64 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_UTIL_RANDOM_H_ +#define STORAGE_LEVELDB_UTIL_RANDOM_H_ + +#include + +namespace leveldb { + +// A very simple random number generator. Not especially good at +// generating truly random bits, but good enough for our needs in this +// package. +class Random { + private: + uint32_t seed_; + public: + explicit Random(uint32_t s) : seed_(s & 0x7fffffffu) { + // Avoid bad seeds. + if (seed_ == 0 || seed_ == 2147483647L) { + seed_ = 1; + } + } + uint32_t Next() { + static const uint32_t M = 2147483647L; // 2^31-1 + static const uint64_t A = 16807; // bits 14, 8, 7, 5, 2, 1, 0 + // We are computing + // seed_ = (seed_ * A) % M, where M = 2^31-1 + // + // seed_ must not be zero or M, or else all subsequent computed values + // will be zero or M respectively. For all other values, seed_ will end + // up cycling through every number in [1,M-1] + uint64_t product = seed_ * A; + + // Compute (product % M) using the fact that ((x << 31) % M) == x. + seed_ = static_cast((product >> 31) + (product & M)); + // The first reduction may overflow by 1 bit, so we may need to + // repeat. mod == M is not possible; using > allows the faster + // sign-bit-based test. + if (seed_ > M) { + seed_ -= M; + } + return seed_; + } + // Returns a uniformly distributed value in the range [0..n-1] + // REQUIRES: n > 0 + uint32_t Uniform(int n) { return Next() % n; } + + // Randomly returns true ~"1/n" of the time, and false otherwise. + // REQUIRES: n > 0 + bool OneIn(int n) { return (Next() % n) == 0; } + + // Skewed: pick "base" uniformly from range [0,max_log] and then + // return "base" random bits. The effect is to pick a number in the + // range [0,2^max_log-1] with exponential bias towards smaller numbers. + uint32_t Skewed(int max_log) { + return Uniform(1 << Uniform(max_log + 1)); + } +}; + +} // namespace leveldb + +#endif // STORAGE_LEVELDB_UTIL_RANDOM_H_ diff --git a/src/leveldb/util/status.cc b/src/leveldb/util/status.cc new file mode 100644 index 0000000..a44f35b --- /dev/null +++ b/src/leveldb/util/status.cc @@ -0,0 +1,75 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include +#include "port/port.h" +#include "leveldb/status.h" + +namespace leveldb { + +const char* Status::CopyState(const char* state) { + uint32_t size; + memcpy(&size, state, sizeof(size)); + char* result = new char[size + 5]; + memcpy(result, state, size + 5); + return result; +} + +Status::Status(Code code, const Slice& msg, const Slice& msg2) { + assert(code != kOk); + const uint32_t len1 = msg.size(); + const uint32_t len2 = msg2.size(); + const uint32_t size = len1 + (len2 ? (2 + len2) : 0); + char* result = new char[size + 5]; + memcpy(result, &size, sizeof(size)); + result[4] = static_cast(code); + memcpy(result + 5, msg.data(), len1); + if (len2) { + result[5 + len1] = ':'; + result[6 + len1] = ' '; + memcpy(result + 7 + len1, msg2.data(), len2); + } + state_ = result; +} + +std::string Status::ToString() const { + if (state_ == NULL) { + return "OK"; + } else { + char tmp[30]; + const char* type; + switch (code()) { + case kOk: + type = "OK"; + break; + case kNotFound: + type = "NotFound: "; + break; + case kCorruption: + type = "Corruption: "; + break; + case kNotSupported: + type = "Not implemented: "; + break; + case kInvalidArgument: + type = "Invalid argument: "; + break; + case kIOError: + type = "IO error: "; + break; + default: + snprintf(tmp, sizeof(tmp), "Unknown code(%d): ", + static_cast(code())); + type = tmp; + break; + } + std::string result(type); + uint32_t length; + memcpy(&length, state_, sizeof(length)); + result.append(state_ + 5, length); + return result; + } +} + +} // namespace leveldb diff --git a/src/leveldb/util/testharness.cc b/src/leveldb/util/testharness.cc new file mode 100644 index 0000000..402fab3 --- /dev/null +++ b/src/leveldb/util/testharness.cc @@ -0,0 +1,77 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "util/testharness.h" + +#include +#include +#include +#include + +namespace leveldb { +namespace test { + +namespace { +struct Test { + const char* base; + const char* name; + void (*func)(); +}; +std::vector* tests; +} + +bool RegisterTest(const char* base, const char* name, void (*func)()) { + if (tests == NULL) { + tests = new std::vector; + } + Test t; + t.base = base; + t.name = name; + t.func = func; + tests->push_back(t); + return true; +} + +int RunAllTests() { + const char* matcher = getenv("LEVELDB_TESTS"); + + int num = 0; + if (tests != NULL) { + for (size_t i = 0; i < tests->size(); i++) { + const Test& t = (*tests)[i]; + if (matcher != NULL) { + std::string name = t.base; + name.push_back('.'); + name.append(t.name); + if (strstr(name.c_str(), matcher) == NULL) { + continue; + } + } + fprintf(stderr, "==== Test %s.%s\n", t.base, t.name); + (*t.func)(); + ++num; + } + } + fprintf(stderr, "==== PASSED %d tests\n", num); + return 0; +} + +std::string TmpDir() { + std::string dir; + Status s = Env::Default()->GetTestDirectory(&dir); + ASSERT_TRUE(s.ok()) << s.ToString(); + return dir; +} + +int RandomSeed() { + const char* env = getenv("TEST_RANDOM_SEED"); + int result = (env != NULL ? atoi(env) : 301); + if (result <= 0) { + result = 301; + } + return result; +} + +} // namespace test +} // namespace leveldb diff --git a/src/leveldb/util/testharness.h b/src/leveldb/util/testharness.h new file mode 100644 index 0000000..da4fe68 --- /dev/null +++ b/src/leveldb/util/testharness.h @@ -0,0 +1,138 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_UTIL_TESTHARNESS_H_ +#define STORAGE_LEVELDB_UTIL_TESTHARNESS_H_ + +#include +#include +#include +#include "leveldb/env.h" +#include "leveldb/slice.h" +#include "util/random.h" + +namespace leveldb { +namespace test { + +// Run some of the tests registered by the TEST() macro. If the +// environment variable "LEVELDB_TESTS" is not set, runs all tests. +// Otherwise, runs only the tests whose name contains the value of +// "LEVELDB_TESTS" as a substring. E.g., suppose the tests are: +// TEST(Foo, Hello) { ... } +// TEST(Foo, World) { ... } +// LEVELDB_TESTS=Hello will run the first test +// LEVELDB_TESTS=o will run both tests +// LEVELDB_TESTS=Junk will run no tests +// +// Returns 0 if all tests pass. +// Dies or returns a non-zero value if some test fails. +extern int RunAllTests(); + +// Return the directory to use for temporary storage. +extern std::string TmpDir(); + +// Return a randomization seed for this run. Typically returns the +// same number on repeated invocations of this binary, but automated +// runs may be able to vary the seed. +extern int RandomSeed(); + +// An instance of Tester is allocated to hold temporary state during +// the execution of an assertion. +class Tester { + private: + bool ok_; + const char* fname_; + int line_; + std::stringstream ss_; + + public: + Tester(const char* f, int l) + : ok_(true), fname_(f), line_(l) { + } + + ~Tester() { + if (!ok_) { + fprintf(stderr, "%s:%d:%s\n", fname_, line_, ss_.str().c_str()); + exit(1); + } + } + + Tester& Is(bool b, const char* msg) { + if (!b) { + ss_ << " Assertion failure " << msg; + ok_ = false; + } + return *this; + } + + Tester& IsOk(const Status& s) { + if (!s.ok()) { + ss_ << " " << s.ToString(); + ok_ = false; + } + return *this; + } + +#define BINARY_OP(name,op) \ + template \ + Tester& name(const X& x, const Y& y) { \ + if (! (x op y)) { \ + ss_ << " failed: " << x << (" " #op " ") << y; \ + ok_ = false; \ + } \ + return *this; \ + } + + BINARY_OP(IsEq, ==) + BINARY_OP(IsNe, !=) + BINARY_OP(IsGe, >=) + BINARY_OP(IsGt, >) + BINARY_OP(IsLe, <=) + BINARY_OP(IsLt, <) +#undef BINARY_OP + + // Attach the specified value to the error message if an error has occurred + template + Tester& operator<<(const V& value) { + if (!ok_) { + ss_ << " " << value; + } + return *this; + } +}; + +#define ASSERT_TRUE(c) ::leveldb::test::Tester(__FILE__, __LINE__).Is((c), #c) +#define ASSERT_OK(s) ::leveldb::test::Tester(__FILE__, __LINE__).IsOk((s)) +#define ASSERT_EQ(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsEq((a),(b)) +#define ASSERT_NE(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsNe((a),(b)) +#define ASSERT_GE(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsGe((a),(b)) +#define ASSERT_GT(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsGt((a),(b)) +#define ASSERT_LE(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsLe((a),(b)) +#define ASSERT_LT(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsLt((a),(b)) + +#define TCONCAT(a,b) TCONCAT1(a,b) +#define TCONCAT1(a,b) a##b + +#define TEST(base,name) \ +class TCONCAT(_Test_,name) : public base { \ + public: \ + void _Run(); \ + static void _RunIt() { \ + TCONCAT(_Test_,name) t; \ + t._Run(); \ + } \ +}; \ +bool TCONCAT(_Test_ignored_,name) = \ + ::leveldb::test::RegisterTest(#base, #name, &TCONCAT(_Test_,name)::_RunIt); \ +void TCONCAT(_Test_,name)::_Run() + +// Register the specified test. Typically not used directly, but +// invoked via the macro expansion of TEST. +extern bool RegisterTest(const char* base, const char* name, void (*func)()); + + +} // namespace test +} // namespace leveldb + +#endif // STORAGE_LEVELDB_UTIL_TESTHARNESS_H_ diff --git a/src/leveldb/util/testutil.cc b/src/leveldb/util/testutil.cc new file mode 100644 index 0000000..bee56bf --- /dev/null +++ b/src/leveldb/util/testutil.cc @@ -0,0 +1,51 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "util/testutil.h" + +#include "util/random.h" + +namespace leveldb { +namespace test { + +Slice RandomString(Random* rnd, int len, std::string* dst) { + dst->resize(len); + for (int i = 0; i < len; i++) { + (*dst)[i] = static_cast(' ' + rnd->Uniform(95)); // ' ' .. '~' + } + return Slice(*dst); +} + +std::string RandomKey(Random* rnd, int len) { + // Make sure to generate a wide variety of characters so we + // test the boundary conditions for short-key optimizations. + static const char kTestChars[] = { + '\0', '\1', 'a', 'b', 'c', 'd', 'e', '\xfd', '\xfe', '\xff' + }; + std::string result; + for (int i = 0; i < len; i++) { + result += kTestChars[rnd->Uniform(sizeof(kTestChars))]; + } + return result; +} + + +extern Slice CompressibleString(Random* rnd, double compressed_fraction, + size_t len, std::string* dst) { + int raw = static_cast(len * compressed_fraction); + if (raw < 1) raw = 1; + std::string raw_data; + RandomString(rnd, raw, &raw_data); + + // Duplicate the random data until we have filled "len" bytes + dst->clear(); + while (dst->size() < len) { + dst->append(raw_data); + } + dst->resize(len); + return Slice(*dst); +} + +} // namespace test +} // namespace leveldb diff --git a/src/leveldb/util/testutil.h b/src/leveldb/util/testutil.h new file mode 100644 index 0000000..adad3fc --- /dev/null +++ b/src/leveldb/util/testutil.h @@ -0,0 +1,53 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#ifndef STORAGE_LEVELDB_UTIL_TESTUTIL_H_ +#define STORAGE_LEVELDB_UTIL_TESTUTIL_H_ + +#include "leveldb/env.h" +#include "leveldb/slice.h" +#include "util/random.h" + +namespace leveldb { +namespace test { + +// Store in *dst a random string of length "len" and return a Slice that +// references the generated data. +extern Slice RandomString(Random* rnd, int len, std::string* dst); + +// Return a random key with the specified length that may contain interesting +// characters (e.g. \x00, \xff, etc.). +extern std::string RandomKey(Random* rnd, int len); + +// Store in *dst a string of length "len" that will compress to +// "N*compressed_fraction" bytes and return a Slice that references +// the generated data. +extern Slice CompressibleString(Random* rnd, double compressed_fraction, + size_t len, std::string* dst); + +// A wrapper that allows injection of errors. +class ErrorEnv : public EnvWrapper { + public: + bool writable_file_error_; + int num_writable_file_errors_; + + ErrorEnv() : EnvWrapper(Env::Default()), + writable_file_error_(false), + num_writable_file_errors_(0) { } + + virtual Status NewWritableFile(const std::string& fname, + WritableFile** result) { + if (writable_file_error_) { + ++num_writable_file_errors_; + *result = NULL; + return Status::IOError(fname, "fake error"); + } + return target()->NewWritableFile(fname, result); + } +}; + +} // namespace test +} // namespace leveldb + +#endif // STORAGE_LEVELDB_UTIL_TESTUTIL_H_ diff --git a/src/lz4/LICENSE b/src/lz4/LICENSE new file mode 100644 index 0000000..b566df3 --- /dev/null +++ b/src/lz4/LICENSE @@ -0,0 +1,24 @@ +LZ4 Library +Copyright (c) 2011-2014, Yann Collet +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/src/lz4/lz4.c b/src/lz4/lz4.c new file mode 100644 index 0000000..fd229ef --- /dev/null +++ b/src/lz4/lz4.c @@ -0,0 +1,880 @@ +/* + LZ4 - Fast LZ compression algorithm + Copyright (C) 2011-2014, Yann Collet. + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - LZ4 source repository : http://code.google.com/p/lz4/ + - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c +*/ + +/************************************** + Tuning parameters +**************************************/ +/* + * MEMORY_USAGE : + * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.) + * Increasing memory usage improves compression ratio + * Reduced memory usage can improve speed, due to cache effect + * Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache + */ +#define MEMORY_USAGE 14 + +/* + * HEAPMODE : + * Select how default compression functions will allocate memory for their hash table, + * in memory stack (0:default, fastest), or in memory heap (1:requires memory allocation (malloc)). + */ +#define HEAPMODE 0 + + +/************************************** + CPU Feature Detection +**************************************/ +/* 32 or 64 bits ? */ +#if (defined(__x86_64__) || defined(_M_X64) || defined(_WIN64) \ + || defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) \ + || defined(__64BIT__) || defined(_LP64) || defined(__LP64__) \ + || defined(__ia64) || defined(__itanium__) || defined(_M_IA64) ) /* Detects 64 bits mode */ +# define LZ4_ARCH64 1 +#else +# define LZ4_ARCH64 0 +#endif + +/* + * Little Endian or Big Endian ? + * Overwrite the #define below if you know your architecture endianess + */ +#if defined (__GLIBC__) +# include +# if (__BYTE_ORDER == __BIG_ENDIAN) +# define LZ4_BIG_ENDIAN 1 +# endif +#elif (defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN)) && !(defined(__LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN) || defined(_LITTLE_ENDIAN)) +# define LZ4_BIG_ENDIAN 1 +#elif defined(__sparc) || defined(__sparc__) \ + || defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) \ + || defined(__hpux) || defined(__hppa) \ + || defined(_MIPSEB) || defined(__s390__) +# define LZ4_BIG_ENDIAN 1 +#else +/* Little Endian assumed. PDP Endian and other very rare endian format are unsupported. */ +#endif + +/* + * Unaligned memory access is automatically enabled for "common" CPU, such as x86. + * For others CPU, such as ARM, the compiler may be more cautious, inserting unnecessary extra code to ensure aligned access property + * If you know your target CPU supports unaligned memory access, you want to force this option manually to improve performance + */ +#if defined(__ARM_FEATURE_UNALIGNED) +# define LZ4_FORCE_UNALIGNED_ACCESS 1 +#endif + +/* Define this parameter if your target system or compiler does not support hardware bit count */ +#if defined(_MSC_VER) && defined(_WIN32_WCE) /* Visual Studio for Windows CE does not support Hardware bit count */ +# define LZ4_FORCE_SW_BITCOUNT +#endif + +/* + * BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE : + * This option may provide a small boost to performance for some big endian cpu, although probably modest. + * You may set this option to 1 if data will remain within closed environment. + * This option is useless on Little_Endian CPU (such as x86) + */ + +/* #define BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE 1 */ + + +/************************************** + Compiler Options +**************************************/ +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */ +/* "restrict" is a known keyword */ +#else +# define restrict /* Disable restrict */ +#endif + +#ifdef _MSC_VER /* Visual Studio */ +# define FORCE_INLINE static __forceinline +# include /* For Visual 2005 */ +# if LZ4_ARCH64 /* 64-bits */ +# pragma intrinsic(_BitScanForward64) /* For Visual 2005 */ +# pragma intrinsic(_BitScanReverse64) /* For Visual 2005 */ +# else /* 32-bits */ +# pragma intrinsic(_BitScanForward) /* For Visual 2005 */ +# pragma intrinsic(_BitScanReverse) /* For Visual 2005 */ +# endif +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ +#else +# ifdef __GNUC__ +# define FORCE_INLINE static inline __attribute__((always_inline)) +# else +# define FORCE_INLINE static inline +# endif +#endif + +#ifdef _MSC_VER /* Visual Studio */ +# define lz4_bswap16(x) _byteswap_ushort(x) +#else +# define lz4_bswap16(x) ((unsigned short int) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))) +#endif + +#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) + +#if (GCC_VERSION >= 302) || (__INTEL_COMPILER >= 800) || defined(__clang__) +# define expect(expr,value) (__builtin_expect ((expr),(value)) ) +#else +# define expect(expr,value) (expr) +#endif + +#define likely(expr) expect((expr) != 0, 1) +#define unlikely(expr) expect((expr) != 0, 0) + + +/************************************** + Memory routines +**************************************/ +#include /* malloc, calloc, free */ +#define ALLOCATOR(n,s) calloc(n,s) +#define FREEMEM free +#include /* memset, memcpy */ +#define MEM_INIT memset + + +/************************************** + Includes +**************************************/ +#include "lz4.h" + + +/************************************** + Basic Types +**************************************/ +#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */ +# include + typedef uint8_t BYTE; + typedef uint16_t U16; + typedef uint32_t U32; + typedef int32_t S32; + typedef uint64_t U64; +#else + typedef unsigned char BYTE; + typedef unsigned short U16; + typedef unsigned int U32; + typedef signed int S32; + typedef unsigned long long U64; +#endif + +#if defined(__GNUC__) && !defined(LZ4_FORCE_UNALIGNED_ACCESS) +# define _PACKED __attribute__ ((packed)) +#else +# define _PACKED +#endif + +#if !defined(LZ4_FORCE_UNALIGNED_ACCESS) && !defined(__GNUC__) +# if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# pragma pack(1) +# else +# pragma pack(push, 1) +# endif +#endif + +typedef struct { U16 v; } _PACKED U16_S; +typedef struct { U32 v; } _PACKED U32_S; +typedef struct { U64 v; } _PACKED U64_S; +typedef struct {size_t v;} _PACKED size_t_S; + +#if !defined(LZ4_FORCE_UNALIGNED_ACCESS) && !defined(__GNUC__) +# if defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# pragma pack(0) +# else +# pragma pack(pop) +# endif +#endif + +#define A16(x) (((U16_S *)(x))->v) +#define A32(x) (((U32_S *)(x))->v) +#define A64(x) (((U64_S *)(x))->v) +#define AARCH(x) (((size_t_S *)(x))->v) + + +/************************************** + Constants +**************************************/ +#define LZ4_HASHLOG (MEMORY_USAGE-2) +#define HASHTABLESIZE (1 << MEMORY_USAGE) +#define HASHNBCELLS4 (1 << LZ4_HASHLOG) + +#define MINMATCH 4 + +#define COPYLENGTH 8 +#define LASTLITERALS 5 +#define MFLIMIT (COPYLENGTH+MINMATCH) +static const int LZ4_minLength = (MFLIMIT+1); + +#define KB *(1U<<10) +#define MB *(1U<<20) +#define GB *(1U<<30) + +#define LZ4_64KLIMIT ((64 KB) + (MFLIMIT-1)) +#define SKIPSTRENGTH 6 /* Increasing this value will make the compression run slower on incompressible data */ + +#define MAXD_LOG 16 +#define MAX_DISTANCE ((1 << MAXD_LOG) - 1) + +#define ML_BITS 4 +#define ML_MASK ((1U<=e; */ +#else +# define LZ4_WILDCOPY(d,s,e) { if (likely(e-d <= 8)) LZ4_COPY8(d,s) else do { LZ4_COPY8(d,s) } while (d>3); +# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT) + return (__builtin_clzll(val) >> 3); +# else + int r; + if (!(val>>32)) { r=4; } else { r=0; val>>=32; } + if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; } + r += (!val); + return r; +# endif +# else +# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT) + unsigned long r = 0; + _BitScanForward64( &r, val ); + return (int)(r>>3); +# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT) + return (__builtin_ctzll(val) >> 3); +# else + static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 }; + return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58]; +# endif +# endif +} + +#else + +FORCE_INLINE int LZ4_NbCommonBytes (register U32 val) +{ +# if defined(LZ4_BIG_ENDIAN) +# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT) + unsigned long r = 0; + _BitScanReverse( &r, val ); + return (int)(r>>3); +# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT) + return (__builtin_clz(val) >> 3); +# else + int r; + if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; } + r += (!val); + return r; +# endif +# else +# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT) + unsigned long r; + _BitScanForward( &r, val ); + return (int)(r>>3); +# elif defined(__GNUC__) && (GCC_VERSION >= 304) && !defined(LZ4_FORCE_SW_BITCOUNT) + return (__builtin_ctz(val) >> 3); +# else + static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 }; + return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27]; +# endif +# endif +} + +#endif + + +/**************************** + Compression functions +****************************/ +int LZ4_compressBound(int isize) { return LZ4_COMPRESSBOUND(isize); } + +FORCE_INLINE int LZ4_hashSequence(U32 sequence, tableType_t tableType) +{ + if (tableType == byU16) + return (((sequence) * 2654435761U) >> ((MINMATCH*8)-(LZ4_HASHLOG+1))); + else + return (((sequence) * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG)); +} + +FORCE_INLINE int LZ4_hashPosition(const BYTE* p, tableType_t tableType) { return LZ4_hashSequence(A32(p), tableType); } + +FORCE_INLINE void LZ4_putPositionOnHash(const BYTE* p, U32 h, void* tableBase, tableType_t tableType, const BYTE* srcBase) +{ + switch (tableType) + { + case byPtr: { const BYTE** hashTable = (const BYTE**) tableBase; hashTable[h] = p; break; } + case byU32: { U32* hashTable = (U32*) tableBase; hashTable[h] = (U32)(p-srcBase); break; } + case byU16: { U16* hashTable = (U16*) tableBase; hashTable[h] = (U16)(p-srcBase); break; } + } +} + +FORCE_INLINE void LZ4_putPosition(const BYTE* p, void* tableBase, tableType_t tableType, const BYTE* srcBase) +{ + U32 h = LZ4_hashPosition(p, tableType); + LZ4_putPositionOnHash(p, h, tableBase, tableType, srcBase); +} + +FORCE_INLINE const BYTE* LZ4_getPositionOnHash(U32 h, void* tableBase, tableType_t tableType, const BYTE* srcBase) +{ + if (tableType == byPtr) { const BYTE** hashTable = (const BYTE**) tableBase; return hashTable[h]; } + if (tableType == byU32) { U32* hashTable = (U32*) tableBase; return hashTable[h] + srcBase; } + { U16* hashTable = (U16*) tableBase; return hashTable[h] + srcBase; } /* default, to ensure a return */ +} + +FORCE_INLINE const BYTE* LZ4_getPosition(const BYTE* p, void* tableBase, tableType_t tableType, const BYTE* srcBase) +{ + U32 h = LZ4_hashPosition(p, tableType); + return LZ4_getPositionOnHash(h, tableBase, tableType, srcBase); +} + + +FORCE_INLINE int LZ4_compress_generic( + void* ctx, + const char* source, + char* dest, + int inputSize, + int maxOutputSize, + + limitedOutput_directive limitedOutput, + tableType_t tableType, + prefix64k_directive prefix) +{ + const BYTE* ip = (const BYTE*) source; + const BYTE* const base = (prefix==withPrefix) ? ((LZ4_Data_Structure*)ctx)->base : (const BYTE*) source; + const BYTE* const lowLimit = ((prefix==withPrefix) ? ((LZ4_Data_Structure*)ctx)->bufferStart : (const BYTE*)source); + const BYTE* anchor = (const BYTE*) source; + const BYTE* const iend = ip + inputSize; + const BYTE* const mflimit = iend - MFLIMIT; + const BYTE* const matchlimit = iend - LASTLITERALS; + + BYTE* op = (BYTE*) dest; + BYTE* const oend = op + maxOutputSize; + + int length; + const int skipStrength = SKIPSTRENGTH; + U32 forwardH; + + /* Init conditions */ + if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported input size, too large (or negative) */ + if ((prefix==withPrefix) && (ip != ((LZ4_Data_Structure*)ctx)->nextBlock)) return 0; /* must continue from end of previous block */ + if (prefix==withPrefix) ((LZ4_Data_Structure*)ctx)->nextBlock=iend; /* do it now, due to potential early exit */ + if ((tableType == byU16) && (inputSize>=(int)LZ4_64KLIMIT)) return 0; /* Size too large (not within 64K limit) */ + if (inputSize> skipStrength; + ip = forwardIp; + forwardIp = ip + step; + + if (unlikely(forwardIp > mflimit)) { goto _last_literals; } + + forwardH = LZ4_hashPosition(forwardIp, tableType); + ref = LZ4_getPositionOnHash(h, ctx, tableType, base); + LZ4_putPositionOnHash(ip, h, ctx, tableType, base); + + } while ((ref + MAX_DISTANCE < ip) || (A32(ref) != A32(ip))); + + /* Catch up */ + while ((ip>anchor) && (ref > lowLimit) && (unlikely(ip[-1]==ref[-1]))) { ip--; ref--; } + + /* Encode Literal length */ + length = (int)(ip - anchor); + token = op++; + if ((limitedOutput) && (unlikely(op + length + (2 + 1 + LASTLITERALS) + (length/255) > oend))) return 0; /* Check output limit */ + if (length>=(int)RUN_MASK) + { + int len = length-RUN_MASK; + *token=(RUN_MASK<= 255 ; len-=255) *op++ = 255; + *op++ = (BYTE)len; + } + else *token = (BYTE)(length<>8) > oend))) return 0; /* Check output limit */ + if (length>=(int)ML_MASK) + { + *token += ML_MASK; + length -= ML_MASK; + for (; length > 509 ; length-=510) { *op++ = 255; *op++ = 255; } + if (length >= 255) { length-=255; *op++ = 255; } + *op++ = (BYTE)length; + } + else *token += (BYTE)(length); + + /* Test end of chunk */ + if (ip > mflimit) { anchor = ip; break; } + + /* Fill table */ + LZ4_putPosition(ip-2, ctx, tableType, base); + + /* Test next position */ + ref = LZ4_getPosition(ip, ctx, tableType, base); + LZ4_putPosition(ip, ctx, tableType, base); + if ((ref + MAX_DISTANCE >= ip) && (A32(ref) == A32(ip))) { token = op++; *token=0; goto _next_match; } + + /* Prepare next loop */ + anchor = ip++; + forwardH = LZ4_hashPosition(ip, tableType); + } + +_last_literals: + /* Encode Last Literals */ + { + int lastRun = (int)(iend - anchor); + if ((limitedOutput) && (((char*)op - dest) + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > (U32)maxOutputSize)) return 0; /* Check output limit */ + if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<= 255 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; } + else *op++ = (BYTE)(lastRun<hashTable, 0, sizeof(lz4ds->hashTable)); + lz4ds->bufferStart = base; + lz4ds->base = base; + lz4ds->nextBlock = base; +} + +int LZ4_resetStreamState(void* state, const char* inputBuffer) +{ + if ((((size_t)state) & 3) != 0) return 1; /* Error : pointer is not aligned on 4-bytes boundary */ + LZ4_init((LZ4_Data_Structure*)state, (const BYTE*)inputBuffer); + return 0; +} + +void* LZ4_create (const char* inputBuffer) +{ + void* lz4ds = ALLOCATOR(1, sizeof(LZ4_Data_Structure)); + LZ4_init ((LZ4_Data_Structure*)lz4ds, (const BYTE*)inputBuffer); + return lz4ds; +} + + +int LZ4_free (void* LZ4_Data) +{ + FREEMEM(LZ4_Data); + return (0); +} + + +char* LZ4_slideInputBuffer (void* LZ4_Data) +{ + LZ4_Data_Structure* lz4ds = (LZ4_Data_Structure*)LZ4_Data; + size_t delta = lz4ds->nextBlock - (lz4ds->bufferStart + 64 KB); + + if ( (lz4ds->base - delta > lz4ds->base) /* underflow control */ + || ((size_t)(lz4ds->nextBlock - lz4ds->base) > 0xE0000000) ) /* close to 32-bits limit */ + { + size_t deltaLimit = (lz4ds->nextBlock - 64 KB) - lz4ds->base; + int nH; + + for (nH=0; nH < HASHNBCELLS4; nH++) + { + if ((size_t)(lz4ds->hashTable[nH]) < deltaLimit) lz4ds->hashTable[nH] = 0; + else lz4ds->hashTable[nH] -= (U32)deltaLimit; + } + memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB); + lz4ds->base = lz4ds->bufferStart; + lz4ds->nextBlock = lz4ds->base + 64 KB; + } + else + { + memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB); + lz4ds->nextBlock -= delta; + lz4ds->base -= delta; + } + + return (char*)(lz4ds->nextBlock); +} + + +int LZ4_compress_continue (void* LZ4_Data, const char* source, char* dest, int inputSize) +{ + return LZ4_compress_generic(LZ4_Data, source, dest, inputSize, 0, notLimited, byU32, withPrefix); +} + + +int LZ4_compress_limitedOutput_continue (void* LZ4_Data, const char* source, char* dest, int inputSize, int maxOutputSize) +{ + return LZ4_compress_generic(LZ4_Data, source, dest, inputSize, maxOutputSize, limited, byU32, withPrefix); +} + + +/**************************** + Decompression functions +****************************/ +/* + * This generic decompression function cover all use cases. + * It shall be instanciated several times, using different sets of directives + * Note that it is essential this generic function is really inlined, + * in order to remove useless branches during compilation optimisation. + */ +FORCE_INLINE int LZ4_decompress_generic( + const char* source, + char* dest, + int inputSize, + int outputSize, /* If endOnInput==endOnInputSize, this value is the max size of Output Buffer. */ + + int endOnInput, /* endOnOutputSize, endOnInputSize */ + int prefix64k, /* noPrefix, withPrefix */ + int partialDecoding, /* full, partial */ + int targetOutputSize /* only used if partialDecoding==partial */ + ) +{ + /* Local Variables */ + const BYTE* restrict ip = (const BYTE*) source; + const BYTE* ref; + const BYTE* const iend = ip + inputSize; + + BYTE* op = (BYTE*) dest; + BYTE* const oend = op + outputSize; + BYTE* cpy; + BYTE* oexit = op + targetOutputSize; + + /*const size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0}; / static reduces speed for LZ4_decompress_safe() on GCC64 */ + const size_t dec32table[] = {4-0, 4-3, 4-2, 4-3, 4-0, 4-0, 4-0, 4-0}; /* static reduces speed for LZ4_decompress_safe() on GCC64 */ + static const size_t dec64table[] = {0, 0, 0, (size_t)-1, 0, 1, 2, 3}; + + + /* Special cases */ + if ((partialDecoding) && (oexit> oend-MFLIMIT)) oexit = oend-MFLIMIT; /* targetOutputSize too high => decode everything */ + if ((endOnInput) && (unlikely(outputSize==0))) return ((inputSize==1) && (*ip==0)) ? 0 : -1; /* Empty output buffer */ + if ((!endOnInput) && (unlikely(outputSize==0))) return (*ip==0?1:-1); + + + /* Main Loop */ + while (1) + { + unsigned token; + size_t length; + + /* get runlength */ + token = *ip++; + if ((length=(token>>ML_BITS)) == RUN_MASK) + { + unsigned s=255; + while (((endOnInput)?ip(partialDecoding?oexit:oend-MFLIMIT)) || (ip+length>iend-(2+1+LASTLITERALS))) ) + || ((!endOnInput) && (cpy>oend-COPYLENGTH))) + { + if (partialDecoding) + { + if (cpy > oend) goto _output_error; /* Error : write attempt beyond end of output buffer */ + if ((endOnInput) && (ip+length > iend)) goto _output_error; /* Error : read attempt beyond end of input buffer */ + } + else + { + if ((!endOnInput) && (cpy != oend)) goto _output_error; /* Error : block decoding must stop exactly there */ + if ((endOnInput) && ((ip+length != iend) || (cpy > oend))) goto _output_error; /* Error : input must be consumed */ + } + memcpy(op, ip, length); + ip += length; + op += length; + break; /* Necessarily EOF, due to parsing restrictions */ + } + LZ4_WILDCOPY(op, ip, cpy); ip -= (op-cpy); op = cpy; + + /* get offset */ + LZ4_READ_LITTLEENDIAN_16(ref,cpy,ip); ip+=2; + if ((prefix64k==noPrefix) && (unlikely(ref < (BYTE* const)dest))) goto _output_error; /* Error : offset outside destination buffer */ + + /* get matchlength */ + if ((length=(token&ML_MASK)) == ML_MASK) + { + while ((!endOnInput) || (ipoend-COPYLENGTH-(STEPSIZE-4))) + { + if (cpy > oend-LASTLITERALS) goto _output_error; /* Error : last 5 bytes must be literals */ + LZ4_SECURECOPY(op, ref, (oend-COPYLENGTH)); + while(op (unsigned int)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16) + +/* +LZ4_compressBound() : + Provides the maximum size that LZ4 may output in a "worst case" scenario (input data not compressible) + primarily useful for memory allocation of output buffer. + inline function is recommended for the general case, + macro is also provided when result needs to be evaluated at compilation (such as stack memory allocation). + + isize : is the input size. Max supported value is LZ4_MAX_INPUT_SIZE + return : maximum output size in a "worst case" scenario + or 0, if input size is too large ( > LZ4_MAX_INPUT_SIZE) +*/ +int LZ4_compressBound(int isize); + + +/* +LZ4_compress_limitedOutput() : + Compress 'inputSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'. + If it cannot achieve it, compression will stop, and result of the function will be zero. + This function never writes outside of provided output buffer. + + inputSize : Max supported value is LZ4_MAX_INPUT_VALUE + maxOutputSize : is the size of the destination buffer (which must be already allocated) + return : the number of bytes written in buffer 'dest' + or 0 if the compression fails +*/ +int LZ4_compress_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize); + + +/* +LZ4_decompress_fast() : + originalSize : is the original and therefore uncompressed size + return : the number of bytes read from the source buffer (in other words, the compressed size) + If the source stream is malformed, the function will stop decoding and return a negative result. + note : This function is a bit faster than LZ4_decompress_safe() + This function never writes outside of output buffers, but may read beyond input buffer in case of malicious data packet. + Use this function preferably into a trusted environment (data to decode comes from a trusted source). + Destination buffer must be already allocated. Its size must be a minimum of 'outputSize' bytes. +*/ +int LZ4_decompress_fast (const char* source, char* dest, int originalSize); + + +/* +LZ4_decompress_safe_partial() : + This function decompress a compressed block of size 'inputSize' at position 'source' + into output buffer 'dest' of size 'maxOutputSize'. + The function tries to stop decompressing operation as soon as 'targetOutputSize' has been reached, + reducing decompression time. + return : the number of bytes decoded in the destination buffer (necessarily <= maxOutputSize) + Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller. + Always control how many bytes were decoded. + If the source stream is detected malformed, the function will stop decoding and return a negative result. + This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets +*/ +int LZ4_decompress_safe_partial (const char* source, char* dest, int inputSize, int targetOutputSize, int maxOutputSize); + + +/* +These functions are provided should you prefer to allocate memory for compression tables with your own allocation methods. +To know how much memory must be allocated for the compression tables, use : +int LZ4_sizeofState(); + +Note that tables must be aligned on 4-bytes boundaries, otherwise compression will fail (return code 0). + +The allocated memory can be provided to the compressions functions using 'void* state' parameter. +LZ4_compress_withState() and LZ4_compress_limitedOutput_withState() are equivalent to previously described functions. +They just use the externally allocated memory area instead of allocating their own (on stack, or on heap). +*/ +int LZ4_sizeofState(void); +int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize); +int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); + + +/************************************** + Streaming Functions +**************************************/ +void* LZ4_create (const char* inputBuffer); +int LZ4_compress_continue (void* LZ4_Data, const char* source, char* dest, int inputSize); +int LZ4_compress_limitedOutput_continue (void* LZ4_Data, const char* source, char* dest, int inputSize, int maxOutputSize); +char* LZ4_slideInputBuffer (void* LZ4_Data); +int LZ4_free (void* LZ4_Data); + +/* +These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks. +In order to achieve this, it is necessary to start creating the LZ4 Data Structure, thanks to the function : + +void* LZ4_create (const char* inputBuffer); +The result of the function is the (void*) pointer on the LZ4 Data Structure. +This pointer will be needed in all other functions. +If the pointer returned is NULL, then the allocation has failed, and compression must be aborted. +The only parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer. +The input buffer must be already allocated, and size at least 192KB. +'inputBuffer' will also be the 'const char* source' of the first block. + +All blocks are expected to lay next to each other within the input buffer, starting from 'inputBuffer'. +To compress each block, use either LZ4_compress_continue() or LZ4_compress_limitedOutput_continue(). +Their behavior are identical to LZ4_compress() or LZ4_compress_limitedOutput(), +but require the LZ4 Data Structure as their first argument, and check that each block starts right after the previous one. +If next block does not begin immediately after the previous one, the compression will fail (return 0). + +When it's no longer possible to lay the next block after the previous one (not enough space left into input buffer), a call to : +char* LZ4_slideInputBuffer(void* LZ4_Data); +must be performed. It will typically copy the latest 64KB of input at the beginning of input buffer. +Note that, for this function to work properly, minimum size of an input buffer must be 192KB. +==> The memory position where the next input data block must start is provided as the result of the function. + +Compression can then resume, using LZ4_compress_continue() or LZ4_compress_limitedOutput_continue(), as usual. + +When compression is completed, a call to LZ4_free() will release the memory used by the LZ4 Data Structure. +*/ + + +int LZ4_sizeofStreamState(void); +int LZ4_resetStreamState(void* state, const char* inputBuffer); + +/* +These functions achieve the same result as : +void* LZ4_create (const char* inputBuffer); + +They are provided here to allow the user program to allocate memory using its own routines. + +To know how much space must be allocated, use LZ4_sizeofStreamState(); +Note also that space must be 4-bytes aligned. + +Once space is allocated, you must initialize it using : LZ4_resetStreamState(void* state, const char* inputBuffer); +void* state is a pointer to the space allocated. +It must be aligned on 4-bytes boundaries, and be large enough. +The parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer. +The input buffer must be already allocated, and size at least 192KB. +'inputBuffer' will also be the 'const char* source' of the first block. + +The same space can be re-used multiple times, just by initializing it each time with LZ4_resetStreamState(). +return value of LZ4_resetStreamState() must be 0 is OK. +Any other value means there was an error (typically, pointer is not aligned on 4-bytes boundaries). +*/ + + +int LZ4_decompress_safe_withPrefix64k (const char* source, char* dest, int inputSize, int maxOutputSize); +int LZ4_decompress_fast_withPrefix64k (const char* source, char* dest, int outputSize); + +/* +*_withPrefix64k() : + These decoding functions work the same as their "normal name" versions, + but can use up to 64KB of data in front of 'char* dest'. + These functions are necessary to decode inter-dependant blocks. +*/ + + +/************************************** + Obsolete Functions +**************************************/ +/* +These functions are deprecated and should no longer be used. +They are provided here for compatibility with existing user programs. +*/ +int LZ4_uncompress (const char* source, char* dest, int outputSize); +int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); + + +#if defined (__cplusplus) +} +#endif diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..3aa9b79 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,4311 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include +#include + +#include "alert.h" +#include "chainparams.h" +#include "checkpoints.h" +#include "db.h" +#include "init.h" +#include "kernel.h" +#include "txdb.h" +#include "txmempool.h" +#include "ui_interface.h" +#include "instantx.h" +#include "darksend.h" +#include "masternode.h" +#include "spork.h" +#include "smessage.h" + +using namespace std; +using namespace boost; + + +// Global state + + +CCriticalSection cs_setpwalletRegistered; +set setpwalletRegistered; + +CCriticalSection cs_main; + +CTxMemPool mempool; + +map mapBlockIndex; +set > setStakeSeen; + +CBigNum bnProofOfWorkLimit(~uint256(0) >> 4); +CBigNum bnProofOfStakeLimit(~uint256(0) >> 20); +CBigNum bnProofOfStakeLimitV2(~uint256(0) >> 34); + +unsigned int nStakeMinAge = 24 * 60 * 60; // +unsigned int nModifierInterval = 10 * 60; // time to elapse before new modifier is computed + +int nCoinbaseMaturity = 50; // Estimated 80 +CBlockIndex* pindexGenesisBlock = NULL; // Should be NULL +int nBestHeight = -1; + +uint256 nBestChainTrust = 0; +uint256 nBestInvalidTrust = 0; + +uint256 hashBestChain = 0; +CBlockIndex* pindexBest = NULL; // Should be NULL +int64_t nTimeBestReceived = 0; +bool fImporting = false; +bool fReindex = false; +bool fAddrIndex = false; +bool fHaveGUI = false; + +struct COrphanBlock { + uint256 hashBlock; + uint256 hashPrev; + std::pair stake; + vector vchBlock; +}; +map mapOrphanBlocks; +multimap mapOrphanBlocksByPrev; +set > setStakeSeenOrphan; +size_t nOrphanBlocksSize = 0; + +map mapOrphanTransactions; +map > mapOrphanTransactionsByPrev; + +// Constant stuff for coinbase transactions we create: +CScript COINBASE_FLAGS; + +const string strMessageMagic = "SONO Signed Message:\n"; + +//extern enum Checkpoints::CPMode CheckpointsMode; + +std::set setValidatedTx; + + +// dispatching functions +// Modified registered wallet functions to prevent 0 day exploit + +// These functions dispatch to one or all registered wallets + +namespace { +struct CMainSignals { + // Notifies listeners of updated transaction data (passing hash, transaction, and optionally the block it is found in. + boost::signals2::signal SyncTransaction; + // Notifies listeners of an erased transaction (currently disabled, requires transaction replacement). + boost::signals2::signal EraseTransaction; + // Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). + boost::signals2::signal UpdatedTransaction; + // Notifies listeners of a new active block chain. + boost::signals2::signal SetBestChain; + // Notifies listeners about an inventory item being seen on the network. + boost::signals2::signal Inventory; + // Tells listeners to broadcast their data. + boost::signals2::signal Broadcast; +} g_signals; +} +// Anti exploit functions templates start from here through out the entire main.cpp ( hiden functions ) +//-----------------------------------------------------------------------------------------------------// +void RegisterWallet(CWalletInterface* pwalletIn) { + g_signals.SyncTransaction.connect(boost::bind(&CWalletInterface::SyncTransaction, pwalletIn, _1, _2, _3)); + g_signals.EraseTransaction.connect(boost::bind(&CWalletInterface::EraseFromWallet, pwalletIn, _1)); + g_signals.UpdatedTransaction.connect(boost::bind(&CWalletInterface::UpdatedTransaction, pwalletIn, _1)); + g_signals.SetBestChain.connect(boost::bind(&CWalletInterface::SetBestChain, pwalletIn, _1)); + g_signals.Inventory.connect(boost::bind(&CWalletInterface::Inventory, pwalletIn, _1)); + g_signals.Broadcast.connect(boost::bind(&CWalletInterface::ResendWalletTransactions, pwalletIn, _1)); +} + +void UnregisterWallet(CWalletInterface* pwalletIn) { + g_signals.Broadcast.disconnect(boost::bind(&CWalletInterface::ResendWalletTransactions, pwalletIn, _1)); + g_signals.Inventory.disconnect(boost::bind(&CWalletInterface::Inventory, pwalletIn, _1)); + g_signals.SetBestChain.disconnect(boost::bind(&CWalletInterface::SetBestChain, pwalletIn, _1)); + g_signals.UpdatedTransaction.disconnect(boost::bind(&CWalletInterface::UpdatedTransaction, pwalletIn, _1)); + g_signals.EraseTransaction.disconnect(boost::bind(&CWalletInterface::EraseFromWallet, pwalletIn, _1)); + g_signals.SyncTransaction.disconnect(boost::bind(&CWalletInterface::SyncTransaction, pwalletIn, _1, _2, _3)); +} + +void UnregisterAllWallets() { + g_signals.Broadcast.disconnect_all_slots(); + g_signals.Inventory.disconnect_all_slots(); + g_signals.SetBestChain.disconnect_all_slots(); + g_signals.UpdatedTransaction.disconnect_all_slots(); + g_signals.EraseTransaction.disconnect_all_slots(); + g_signals.SyncTransaction.disconnect_all_slots(); +} + +void SyncWithWallets(const CTransaction &tx, const CBlock *pblock, bool fConnect) { + g_signals.SyncTransaction(tx, pblock, fConnect); +} + +void ResendWalletTransactions(bool fForce) { + g_signals.Broadcast(fForce); +} + + + +// Registration of network node signals. + + +void RegisterNodeSignals(CNodeSignals& nodeSignals) +{ + nodeSignals.ProcessMessages.connect(&ProcessMessages); + nodeSignals.SendMessages.connect(&SendMessages); +} + +void UnregisterNodeSignals(CNodeSignals& nodeSignals) +{ + nodeSignals.ProcessMessages.disconnect(&ProcessMessages); + nodeSignals.SendMessages.disconnect(&SendMessages); +} + +bool AbortNode(const std::string &strMessage, const std::string &userMessage) { + strMiscWarning = strMessage; + LogPrintf("*** %s\n", strMessage); + uiInterface.ThreadSafeMessageBox( + userMessage.empty() ? _("Error: A fatal internal error occured, see debug.log for details") : userMessage, + "", CClientUIInterface::MSG_ERROR); + StartShutdown(); + return false; +} + +// mapOrphanTransactions + + +bool AddOrphanTx(const CTransaction& tx) +{ + uint256 hash = tx.GetHash(); + if (mapOrphanTransactions.count(hash)) + return false; + + // Ignore big transactions, to avoid a + // send-big-orphans memory exhaustion attack. If a peer has a legitimate + // large transaction with a missing parent then we assume + // it will rebroadcast it later, after the parent transaction(s) + // have been mined or received. + // 10,000 orphans, each of which is at most 5,000 bytes big is + // at most 500 megabytes of orphans: + + size_t nSize = tx.GetSerializeSize(SER_NETWORK, CTransaction::CURRENT_VERSION); + + if (nSize > 5000) + { + LogPrint("mempool", "ignoring large orphan tx (size: %u, hash: %s)\n", nSize, hash.ToString()); + return false; + } + + mapOrphanTransactions[hash] = tx; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash); + + LogPrint("mempool", "stored orphan tx %s (mapsz %u)\n", hash.ToString(), + mapOrphanTransactions.size()); + return true; +} + +void static EraseOrphanTx(uint256 hash) +{ + map::iterator it = mapOrphanTransactions.find(hash); + if (it == mapOrphanTransactions.end()) + return; + BOOST_FOREACH(const CTxIn& txin, it->second.vin) + { + map >::iterator itPrev = mapOrphanTransactionsByPrev.find(txin.prevout.hash); + if (itPrev == mapOrphanTransactionsByPrev.end()) + continue; + itPrev->second.erase(hash); + if (itPrev->second.empty()) + mapOrphanTransactionsByPrev.erase(itPrev); + } + mapOrphanTransactions.erase(it); +} + +unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) +{ + unsigned int nEvicted = 0; + while (mapOrphanTransactions.size() > nMaxOrphans) + { + // Evict a random orphan: + uint256 randomhash = GetRandHash(); + map::iterator it = mapOrphanTransactions.lower_bound(randomhash); + if (it == mapOrphanTransactions.end()) + it = mapOrphanTransactions.begin(); + EraseOrphanTx(it->first); + ++nEvicted; + } + return nEvicted; +} + +// CTransaction and CTxIndex + + +bool CTransaction::ReadFromDisk(CTxDB& txdb, const uint256& hash, CTxIndex& txindexRet) +{ + SetNull(); + if (!txdb.ReadTxIndex(hash, txindexRet)) + return false; + if (!ReadFromDisk(txindexRet.pos)) + return false; + + return true; +} + +bool CTransaction::ReadFromDisk(CTxDB& txdb, COutPoint prevout, CTxIndex& txindexRet) +{ + if (!ReadFromDisk(txdb, prevout.hash, txindexRet)) + return false; + + if (prevout.n >= vout.size()) + { + SetNull(); + return false; + } + return true; +} + +bool CTransaction::ReadFromDisk(CTxDB& txdb, COutPoint prevout) +{ + CTxIndex txindex; + return ReadFromDisk(txdb, prevout, txindex); +} + +bool CTransaction::ReadFromDisk(COutPoint prevout) +{ + CTxDB txdb("r"); + CTxIndex txindex; + return ReadFromDisk(txdb, prevout, txindex); +} + +bool IsStandardTx(const CTransaction& tx, string& reason) +{ + if (tx.nVersion > CTransaction::CURRENT_VERSION) { + reason = "version"; + return false; + } + + // Treat non-final transactions as non-standard to prevent a specific type + // of double-spend attack, as well as DoS attacks. (if the transaction + // can't be mined, the attacker isn't expending resources broadcasting it) + // Basically we don't want to propagate transactions that can't be included in + // the next block. + // + // However, IsFinalTx() is confusing... Without arguments, it uses + // chainActive.Height() to evaluate nLockTime; when a block is accepted, chainActive.Height() + // is set to the value of nHeight in the block. However, when IsFinalTx() + // is called within CBlock::AcceptBlock(), the height of the block *being* + // evaluated is what is used. Thus if we want to know if a transaction can + // be part of the *next* block, we need to call IsFinalTx() with one more + // than chainActive.Height(). + // + // Timestamps on the other hand don't get any special treatment, because we + // can't know what timestamp the next block will have, and there aren't + // timestamp applications where it matters. + if (!IsFinalTx(tx, nBestHeight + 1)) { + reason = "non-final"; + return false; + } + // nTime has different purpose from nLockTime but can be used in similar attacks + if (tx.nTime > FutureDrift(GetAdjustedTime(), nBestHeight + 1)) { + reason = "time-too-new"; + return false; + } + + // Extremely large transactions with lots of inputs can cost the network + // almost as much to process as they cost the sender in fees, because + // computing signature hashes is O(ninputs*txsize). Limiting transactions + // to MAX_STANDARD_TX_SIZE mitigates CPU exhaustion attacks. + unsigned int sz = tx.GetSerializeSize(SER_NETWORK, CTransaction::CURRENT_VERSION); + if (sz >= MAX_STANDARD_TX_SIZE) { + reason = "tx-size"; + return false; + } + + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + // Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed + // keys. (remember the 520 byte limit on redeemScript size) That works + // out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627 + // bytes of scriptSig, which we round off to 1650 bytes for some minor + // future-proofing. That's also enough to spend a 20-of-20 + // CHECKMULTISIG scriptPubKey, though such a scriptPubKey is not + // considered standard) + if (txin.scriptSig.size() > 1650) { + reason = "scriptsig-size"; + return false; + } + if (!txin.scriptSig.IsPushOnly()) { + reason = "scriptsig-not-pushonly"; + return false; + } + if (!txin.scriptSig.HasCanonicalPushes()) { + reason = "scriptsig-non-canonical-push"; + return false; + } + } + + unsigned int nDataOut = 0; + txnouttype whichType; + BOOST_FOREACH(const CTxOut& txout, tx.vout) { + if (!::IsStandard(txout.scriptPubKey, whichType)) { + reason = "scriptpubkey"; + return false; + } + if (whichType == TX_NULL_DATA) + nDataOut++; + if (txout.nValue == 0) { + reason = "dust"; + return false; + } + if (!txout.scriptPubKey.HasCanonicalPushes()) { + reason = "scriptpubkey-non-canonical-push"; + return false; + } + } + + // not more than one data txout per non-data txout is permitted + // only one data txout is permitted too + if (nDataOut > 1 && nDataOut > tx.vout.size()/2) { + reason = "multi-op-return"; + return false; + } + + return true; +} + +bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime) +{ + AssertLockHeld(cs_main); + // Time based nLockTime implemented in 0.1.6 + if (tx.nLockTime == 0) + return true; + if (nBlockHeight == 0) + nBlockHeight = nBestHeight; + if (nBlockTime == 0) + nBlockTime = GetAdjustedTime(); + if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) + return true; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + if (!txin.IsFinal()) + return false; + return true; +} + +// Check transaction inputs to mitigate two +// potential denial-of-service attacks: +// +// 1. scriptSigs with extra data stuffed into them, +// not consumed by scriptPubKey (or P2SH script) +// 2. P2SH scripts with a crazy number of expensive +// CHECKSIG/CHECKMULTISIG operations +// +bool AreInputsStandard(const CTransaction& tx, const MapPrevTx& mapInputs) +{ + if (tx.IsCoinBase()) + return true; // Coinbases don't use vin normally + + for (unsigned int i = 0; i < tx.vin.size(); i++) + { + const CTxOut& prev = tx.GetOutputFor(tx.vin[i], mapInputs); + + vector > vSolutions; + txnouttype whichType; + // get the scriptPubKey corresponding to this input: + const CScript& prevScript = prev.scriptPubKey; + if (!Solver(prevScript, whichType, vSolutions)) + return false; + int nArgsExpected = ScriptSigArgsExpected(whichType, vSolutions); + if (nArgsExpected < 0) + return false; + + // Transactions with extra stuff in their scriptSigs are + // non-standard. Note that this EvalScript() call will + // be quick, because if there are any operations + // beside "push data" in the scriptSig + // IsStandard() will have already returned false + // and this method isn't called. + vector > stack; + if (!EvalScript(stack, tx.vin[i].scriptSig, tx, i, SCRIPT_VERIFY_NONE, 0)) + return false; + + if (whichType == TX_SCRIPTHASH) + { + if (stack.empty()) + return false; + CScript subscript(stack.back().begin(), stack.back().end()); + vector > vSolutions2; + txnouttype whichType2; + if (Solver(subscript, whichType2, vSolutions2)) + { + int tmpExpected = ScriptSigArgsExpected(whichType2, vSolutions2); + if (tmpExpected < 0) + return false; + nArgsExpected += tmpExpected; + } + else + { + // Any other Script with less than 15 sigops OK: + unsigned int sigops = subscript.GetSigOpCount(true); + // ... extra data left on the stack after execution is OK, too: + return (sigops <= MAX_P2SH_SIGOPS); + } + } + + if (stack.size() != (unsigned int)nArgsExpected) + return false; + } + + return true; +} + +unsigned int GetLegacySigOpCount(const CTransaction& tx) +{ + unsigned int nSigOps = 0; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + nSigOps += txin.scriptSig.GetSigOpCount(false); + } + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + nSigOps += txout.scriptPubKey.GetSigOpCount(false); + } + return nSigOps; +} + +unsigned int GetP2SHSigOpCount(const CTransaction& tx, const MapPrevTx& inputs) +{ + if (tx.IsCoinBase()) + return 0; + + unsigned int nSigOps = 0; + for (unsigned int i = 0; i < tx.vin.size(); i++) + { + const CTxOut& prevout = tx.GetOutputFor(tx.vin[i], inputs); + if (prevout.scriptPubKey.IsPayToScriptHash()) + nSigOps += prevout.scriptPubKey.GetSigOpCount(tx.vin[i].scriptSig); + } + return nSigOps; +} + +int CMerkleTx::SetMerkleBranch(const CBlock* pblock) +{ + AssertLockHeld(cs_main); + + CBlock blockTmp; + if (pblock == NULL) + { + // Load the block this tx is in + CTxIndex txindex; + if (!CTxDB("r").ReadTxIndex(GetHash(), txindex)) + return 0; + if (!blockTmp.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos)) + return 0; + pblock = &blockTmp; + } + + // Update the tx's hashBlock + hashBlock = pblock->GetHash(); + + // Locate the transaction + for (nIndex = 0; nIndex < (int)pblock->vtx.size(); nIndex++) + if (pblock->vtx[nIndex] == *(CTransaction*)this) + break; + if (nIndex == (int)pblock->vtx.size()) + { + vMerkleBranch.clear(); + nIndex = -1; + LogPrintf("ERROR: SetMerkleBranch() : couldn't find tx in block\n"); + return 0; + } + + // Fill in merkle branch + vMerkleBranch = pblock->GetMerkleBranch(nIndex); + + // Is the tx in a block that's in the main chain + map::iterator mi = mapBlockIndex.find(hashBlock); + if (mi == mapBlockIndex.end()) + return 0; + CBlockIndex* pindex = (*mi).second; + if (!pindex || !pindex->IsInMainChain()) + return 0; + + return pindexBest->nHeight - pindex->nHeight + 1; +} + +bool CTransaction::CheckTransaction() const +{ + // Basic checks that don't depend on any context + if (vin.empty()) + return DoS(10, error("CTransaction::CheckTransaction() : vin empty")); + if (vout.empty()) + return DoS(10, error("CTransaction::CheckTransaction() : vout empty")); + // Size limits + if (::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE) + return DoS(100, error("CTransaction::CheckTransaction() : size limits failed")); + + // Check for negative or overflow output values + int64_t nValueOut = 0; + for (unsigned int i = 0; i < vout.size(); i++) + { + const CTxOut& txout = vout[i]; + if (txout.IsEmpty() && !IsCoinBase() && !IsCoinStake()) + return DoS(100, error("CTransaction::CheckTransaction() : txout empty for user transaction")); + if (txout.nValue < 0) + return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue negative")); + if (txout.nValue > MAX_MONEY) + return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue too high")); + nValueOut += txout.nValue; + if (!MoneyRange(nValueOut)) + return DoS(100, error("CTransaction::CheckTransaction() : txout total out of range")); + } + + // Check for duplicate inputs + set vInOutPoints; + BOOST_FOREACH(const CTxIn& txin, vin) + { + if (vInOutPoints.count(txin.prevout)) + return false; + vInOutPoints.insert(txin.prevout); + } + + if (IsCoinBase()) + { + if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100) + return DoS(100, error("CTransaction::CheckTransaction() : coinbase script size is invalid")); + } + else + { + BOOST_FOREACH(const CTxIn& txin, vin) + if (txin.prevout.IsNull()) + return DoS(10, error("CTransaction::CheckTransaction() : prevout is null")); + } + + return true; +} + +int64_t GetMinFee(const CTransaction& tx, unsigned int nBlockSize, enum GetMinFee_mode mode, unsigned int nBytes) +{ + // Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE + int64_t nBaseFee = (mode == GMF_RELAY) ? MIN_RELAY_TX_FEE : MIN_TX_FEE; + + unsigned int nNewBlockSize = nBlockSize + nBytes; + int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee; + + // Raise the price as the block approaches full + if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2) + { + if (nNewBlockSize >= MAX_BLOCK_SIZE_GEN) + return MAX_MONEY; + nMinFee *= MAX_BLOCK_SIZE_GEN / (MAX_BLOCK_SIZE_GEN - nNewBlockSize); + } + + if (!MoneyRange(nMinFee)) + nMinFee = MAX_MONEY; + return nMinFee; +} + + +bool AcceptToMemoryPool(CTxMemPool& pool, CTransaction &tx, bool fLimitFree, + bool* pfMissingInputs) +{ + AssertLockHeld(cs_main); + if (pfMissingInputs) + *pfMissingInputs = false; + + if (!tx.CheckTransaction()) + return error("AcceptToMemoryPool : CheckTransaction failed"); + + // Coinbase is only valid in a block, not as a loose transaction + if (tx.IsCoinBase()) + return tx.DoS(100, error("AcceptToMemoryPool : coinbase as individual tx")); + + // ppcoin: coinstake is also only valid in a block, not as a loose transaction + if (tx.IsCoinStake()) + return tx.DoS(100, error("AcceptToMemoryPool : coinstake as individual tx")); + + // Rather not work on nonstandard transactions (unless -testnet) + string reason; + if (!TestNet() && !IsStandardTx(tx, reason)) + return error("AcceptToMemoryPool : nonstandard transaction: %s", + reason); + + // is it already in the memory pool? + uint256 hash = tx.GetHash(); + if (pool.exists(hash)) + return false; + + // Check for conflicts with in-memory transactions + { + LOCK(pool.cs); // protect pool.mapNextTx + for (unsigned int i = 0; i < tx.vin.size(); i++) + { + COutPoint outpoint = tx.vin[i].prevout; + if (pool.mapNextTx.count(outpoint)) + { + // Disable replacement feature for now + return false; + } + } + } + + { + CTxDB txdb("r"); + + // do we already have it? + if (txdb.ContainsTx(hash)) + return false; + + MapPrevTx mapInputs; + map mapUnused; + bool fInvalid = false; + if (!tx.FetchInputs(txdb, mapUnused, false, false, mapInputs, fInvalid)) + { + if (fInvalid) + return error("AcceptToMemoryPool : FetchInputs found invalid tx %s", hash.ToString()); + if (pfMissingInputs) + *pfMissingInputs = true; + return false; + } + + // Check for non-standard pay-to-script-hash in inputs + if (!TestNet() && !AreInputsStandard(tx, mapInputs)) + return error("AcceptToMemoryPool : nonstandard transaction input"); + + // Check that the transaction doesn't have an excessive number of + // sigops, making it impossible to mine. Since the coinbase transaction + // itself can contain sigops MAX_TX_SIGOPS is less than + // MAX_BLOCK_SIGOPS; we still consider this an invalid rather than + // merely non-standard transaction. + unsigned int nSigOps = GetLegacySigOpCount(tx); + nSigOps += GetP2SHSigOpCount(tx, mapInputs); + if (nSigOps > MAX_TX_SIGOPS) + return tx.DoS(0, + error("AcceptToMemoryPool : too many sigops %s, %d > %d", + hash.ToString(), nSigOps, MAX_TX_SIGOPS)); + + int64_t nFees = tx.GetValueIn(mapInputs)-tx.GetValueOut(); + unsigned int nSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + + // Don't accept it if it can't get into a block + int64_t txMinFee = GetMinFee(tx, 1000, GMF_RELAY, nSize); + if ((fLimitFree && nFees < txMinFee) || (!fLimitFree && nFees < MIN_TX_FEE)) + return error("AcceptToMemoryPool : not enough fees %s, %d < %d", + hash.ToString(), + nFees, txMinFee); + + // Continuously rate-limit free transactions + // This mitigates 'penny-flooding' -- sending thousands of free transactions just to + // be annoying or make others' transactions take longer to confirm. + if (fLimitFree && nFees < MIN_RELAY_TX_FEE) + { + static CCriticalSection csFreeLimiter; + static double dFreeCount; + static int64_t nLastTime; + int64_t nNow = GetTime(); + + LOCK(csFreeLimiter); + + // Use an exponentially decaying ~10-minute window: + dFreeCount *= pow(1.0 - 1.0/600.0, (double)(nNow - nLastTime)); + nLastTime = nNow; + // -limitfreerelay unit is thousand-bytes-per-minute + // At default rate it would take over a month to fill 1GB + if (dFreeCount > GetArg("-limitfreerelay", 15)*10*1000) + return error("AcceptToMemoryPool : free transaction rejected by rate limiter"); + LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize); + dFreeCount += nSize; + } + + // Check against previous transactions + // This is done last to help prevent CPU exhaustion denial-of-service attacks. + if (!tx.ConnectInputs(txdb, mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, false, false, STANDARD_SCRIPT_VERIFY_FLAGS)) + { + return error("AcceptToMemoryPool : ConnectInputs failed %s", hash.ToString()); + } + + // Check again against just the consensus-critical mandatory script + // verification flags, in case of bugs in the standard flags that cause + // transactions to pass as valid when they're actually invalid. For + // instance the STRICTENC flag was incorrectly allowing certain + // CHECKSIG NOT scripts to pass, even though they were invalid. + // + // There is a similar check in CreateNewBlock() to prevent creating + // invalid blocks, however allowing such transactions into the mempool + // can be exploited as a DoS attack. + if (!tx.ConnectInputs(txdb, mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, false, false, MANDATORY_SCRIPT_VERIFY_FLAGS)) + { + return error("AcceptToMemoryPool: : BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags %s", hash.ToString()); + } + } + + // Store transaction in memory + pool.addUnchecked(hash, tx); + setValidatedTx.insert(hash); + + SyncWithWallets(tx, NULL); + + LogPrint("mempool", "AcceptToMemoryPool : accepted %s (poolsz %u)\n", + hash.ToString(), + pool.mapTx.size()); + return true; +} + +bool AcceptableInputs(CTxMemPool& pool, const CTransaction &txo, bool fLimitFree, + bool* pfMissingInputs) +{ + AssertLockHeld(cs_main); + if (pfMissingInputs) + *pfMissingInputs = false; + + CTransaction tx(txo); + string reason; + + if (!tx.CheckTransaction()) + return error("AcceptableInputs : CheckTransaction failed"); + + // Coinbase is only valid in a block, not as a loose transaction + if (tx.IsCoinBase()) + return tx.DoS(100, error("AcceptableInputs : coinbase as individual tx")); + + // ppcoin: coinstake is also only valid in a block, not as a loose transaction + if (tx.IsCoinStake()) + return tx.DoS(100, error("AcceptableInputs : coinstake as individual tx")); + + // Rather not work on nonstandard transactions (unless -testnet) + /*if (!TestNet() && !IsStandardTx(tx, reason)) + return error("AcceptableInputs : nonstandard transaction: %s", + reason);*/ + + // is it already in the memory pool? + uint256 hash = tx.GetHash(); + if (pool.exists(hash)) + return false; + + // Check for conflicts with in-memory transactions + { + LOCK(pool.cs); // protect pool.mapNextTx + for (unsigned int i = 0; i < tx.vin.size(); i++) + { + COutPoint outpoint = tx.vin[i].prevout; + if (pool.mapNextTx.count(outpoint)) + { + // Disable replacement feature for now + return false; + } + } + } + + { + CTxDB txdb("r"); + + // do we already have it? + if (txdb.ContainsTx(hash)) + return false; + + MapPrevTx mapInputs; + map mapUnused; + bool fInvalid = false; + if (!tx.FetchInputs(txdb, mapUnused, false, false, mapInputs, fInvalid)) + { + if (fInvalid) + return error("AcceptableInputs : FetchInputs found invalid tx %s", hash.ToString()); + if (pfMissingInputs) + *pfMissingInputs = true; + return false; + } + + // Check for non-standard pay-to-script-hash in inputs + //if (!TestNet() && !AreInputsStandard(tx, mapInputs)) + // return error("AcceptToMemoryPool : nonstandard transaction input"); + + // Check that the transaction doesn't have an excessive number of + // sigops, making it impossible to mine. Since the coinbase transaction + // itself can contain sigops MAX_TX_SIGOPS is less than + // MAX_BLOCK_SIGOPS; we still consider this an invalid rather than + // merely non-standard transaction. + unsigned int nSigOps = GetLegacySigOpCount(tx); + nSigOps += GetP2SHSigOpCount(tx, mapInputs); + if (nSigOps > MAX_TX_SIGOPS) + return tx.DoS(0, + error("AcceptableInputs : too many sigops %s, %d > %d", + hash.ToString(), nSigOps, MAX_TX_SIGOPS)); + + int64_t nFees = tx.GetValueIn(mapInputs)-tx.GetValueOut(); + unsigned int nSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + + // Don't accept it if it can't get into a block + int64_t txMinFee = GetMinFee(tx, 1000, GMF_RELAY, nSize); + if ((fLimitFree && nFees < txMinFee) || (!fLimitFree && nFees < MIN_TX_FEE)) + return error("AcceptableInputs : not enough fees %s, %d < %d", + hash.ToString(), + nFees, txMinFee); + + // Continuously rate-limit free transactions + // This mitigates 'penny-flooding' -- sending thousands of free transactions just to + // be annoying or make others' transactions take longer to confirm. + if (fLimitFree && nFees < MIN_RELAY_TX_FEE) + { + static CCriticalSection csFreeLimiter; + static double dFreeCount; + static int64_t nLastTime; + int64_t nNow = GetTime(); + + LOCK(csFreeLimiter); + + // Use an exponentially decaying ~10-minute window: + dFreeCount *= pow(1.0 - 1.0/600.0, (double)(nNow - nLastTime)); + nLastTime = nNow; + // -limitfreerelay unit is thousand-bytes-per-minute + // At default rate it would take over a month to fill 1GB + if (dFreeCount > GetArg("-limitfreerelay", 15)*10*1000) + return error("AcceptableInputs : free transaction rejected by rate limiter"); + LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize); + dFreeCount += nSize; + } + + // Check against previous transactions + // This is done last to help prevent CPU exhaustion denial-of-service attacks. + if (!tx.ConnectInputs(txdb, mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, true, false, STANDARD_SCRIPT_VERIFY_FLAGS, false)) + { + return error("AcceptableInputs : ConnectInputs failed %s", hash.ToString()); + } + } + + + /*LogPrint("mempool", "AcceptableInputs : accepted %s (poolsz %u)\n", + hash.ToString(), + pool.mapTx.size()); + */ + return true; +} + + +int CMerkleTx::GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const +{ + if (hashBlock == 0 || nIndex == -1) + return 0; + AssertLockHeld(cs_main); + + // Find the block it claims to be in + map::iterator mi = mapBlockIndex.find(hashBlock); + if (mi == mapBlockIndex.end()) + return 0; + CBlockIndex* pindex = (*mi).second; + if (!pindex || !pindex->IsInMainChain()) + return 0; + + // Make sure the merkle branch connects to this block + if (!fMerkleVerified) + { + if (CBlock::CheckMerkleBranch(GetHash(), vMerkleBranch, nIndex) != pindex->hashMerkleRoot) + return 0; + fMerkleVerified = true; + } + + pindexRet = pindex; + return pindexBest->nHeight - pindex->nHeight + 1; +} + +int CMerkleTx::GetDepthInMainChain(CBlockIndex* &pindexRet) const +{ + AssertLockHeld(cs_main); + int nResult = GetDepthInMainChainINTERNAL(pindexRet); + if (nResult == 0 && !mempool.exists(GetHash())) + return -1; // Not in chain, not in mempool + + return nResult; +} + +int CMerkleTx::GetBlocksToMaturity() const +{ + if (!(IsCoinBase() || IsCoinStake())) + return 0; + return max(0, (nCoinbaseMaturity+1) - GetDepthInMainChain()); +} + + +bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree) +{ + return ::AcceptToMemoryPool(mempool, *this, fLimitFree, NULL); +} + + + +bool CWalletTx::AcceptWalletTransaction(CTxDB& txdb) +{ + + { + // Add previous supporting transactions first + BOOST_FOREACH(CMerkleTx& tx, vtxPrev) + { + if (!(tx.IsCoinBase() || tx.IsCoinStake())) + { + uint256 hash = tx.GetHash(); + if (!mempool.exists(hash) && !txdb.ContainsTx(hash)) + tx.AcceptToMemoryPool(false); + } + } + return AcceptToMemoryPool(false); + } + return false; +} + +bool CWalletTx::AcceptWalletTransaction() +{ + CTxDB txdb("r"); + return AcceptWalletTransaction(txdb); +} + +int GetInputAge(CTxIn& vin) +{ + const uint256& prevHash = vin.prevout.hash; + CTransaction tx; + uint256 hashBlock; + bool fFound = GetTransaction(prevHash, tx, hashBlock); + if(fFound) + { + if(mapBlockIndex.find(hashBlock) != mapBlockIndex.end()) + { + return pindexBest->nHeight - mapBlockIndex[hashBlock]->nHeight; + } + else + return 0; + } + else + return 0; +} + +int CTxIndex::GetDepthInMainChain() const +{ + // Read block header + CBlock block; + if (!block.ReadFromDisk(pos.nFile, pos.nBlockPos, false)) + return 0; + // Find the block in the index + map::iterator mi = mapBlockIndex.find(block.GetHash()); + if (mi == mapBlockIndex.end()) + return 0; + CBlockIndex* pindex = (*mi).second; + if (!pindex || !pindex->IsInMainChain()) + return 0; + return 1 + nBestHeight - pindex->nHeight; +} + +// Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock +bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock) +{ + { + LOCK(cs_main); + { + if (mempool.lookup(hash, tx)) + { + return true; + } + } + CTxDB txdb("r"); + CTxIndex txindex; + if (tx.ReadFromDisk(txdb, hash, txindex)) + { + CBlock block; + if (block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false)) + hashBlock = block.GetHash(); + return true; + } + + // look for transaction in disconnected blocks to find orphaned CoinBase and CoinStake transactions + BOOST_FOREACH(PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) + { + CBlockIndex* pindex = item.second; + if (pindex == pindexBest || pindex->pnext != 0) + continue; + CBlock block; + if (!block.ReadFromDisk(pindex)) + continue; + BOOST_FOREACH(const CTransaction& txOrphan, block.vtx) + { + if (txOrphan.GetHash() == hash) + { + tx = txOrphan; + return true; + } + } + } + + } + return false; +} + +// CBlock and CBlockIndex + + +static CBlockIndex* pblockindexFBBHLast; +CBlockIndex* FindBlockByHeight(int nHeight) +{ + CBlockIndex *pblockindex; + if (nHeight < nBestHeight / 2) + pblockindex = pindexGenesisBlock; + else + pblockindex = pindexBest; + if (pblockindexFBBHLast && abs(nHeight - pblockindex->nHeight) > abs(nHeight - pblockindexFBBHLast->nHeight)) + pblockindex = pblockindexFBBHLast; + while (pblockindex->nHeight > nHeight) + pblockindex = pblockindex->pprev; + while (pblockindex->nHeight < nHeight) + pblockindex = pblockindex->pnext; + pblockindexFBBHLast = pblockindex; + return pblockindex; +} + +bool CBlock::ReadFromDisk(const CBlockIndex* pindex, bool fReadTransactions) +{ + if (!fReadTransactions) + { + *this = pindex->GetBlockHeader(); + return true; + } + if (!ReadFromDisk(pindex->nFile, pindex->nBlockPos, fReadTransactions)) + return false; + if (GetHash() != pindex->GetBlockHash()) + return error("CBlock::ReadFromDisk() : GetHash() doesn't match index"); + return true; +} + +uint256 static GetOrphanRoot(const uint256& hash) +{ + map::iterator it = mapOrphanBlocks.find(hash); + if (it == mapOrphanBlocks.end()) + return hash; + + // Work back to the first block in the orphan chain + do { + map::iterator it2 = mapOrphanBlocks.find(it->second->hashPrev); + if (it2 == mapOrphanBlocks.end()) + return it->first; + it = it2; + } while(true); +} + +// ppcoin: find block wanted by given orphan block +uint256 WantedByOrphan(const COrphanBlock* pblockOrphan) +{ + // Work back to the first block in the orphan chain + while (mapOrphanBlocks.count(pblockOrphan->hashPrev)) + pblockOrphan = mapOrphanBlocks[pblockOrphan->hashPrev]; + return pblockOrphan->hashPrev; +} + +// Remove a random orphan block (which does not have any dependent orphans). +void static PruneOrphanBlocks() +{ + size_t nMaxOrphanBlocksSize = GetArg("-maxorphanblocksmib", DEFAULT_MAX_ORPHAN_BLOCKS) * ((size_t) 1 << 20); + while (nOrphanBlocksSize > nMaxOrphanBlocksSize) + { + // Pick a random orphan block. + int pos = insecure_rand() % mapOrphanBlocksByPrev.size(); + std::multimap::iterator it = mapOrphanBlocksByPrev.begin(); + while (pos--) it++; + + // As long as this block has other orphans depending on it, move to one of those successors. + do { + std::multimap::iterator it2 = mapOrphanBlocksByPrev.find(it->second->hashBlock); + if (it2 == mapOrphanBlocksByPrev.end()) + break; + it = it2; + } while(1); + + setStakeSeenOrphan.erase(it->second->stake); + uint256 hash = it->second->hashBlock; + nOrphanBlocksSize -= it->second->vchBlock.size(); + delete it->second; + mapOrphanBlocksByPrev.erase(it); + mapOrphanBlocks.erase(hash); + } +} + +static CBigNum GetProofOfStakeLimit(int nHeight) +{ + if (IsProtocolV2(nHeight)) + return bnProofOfStakeLimitV2; + else + return bnProofOfStakeLimit; +} + +// miner's coin base reward +int64_t GetProofOfWorkReward(int64_t nFees) +{ + int64_t nSubsidy = 1 * COIN; + + if(pindexBest->nHeight <= 1) { + nSubsidy = 65000 * COIN; + } else if(pindexBest->nHeight <= 250) { + nSubsidy = 0.01 * COIN; + } else if(pindexBest->nHeight >= 240000) { + nSubsidy = 2 * COIN; + } else { + nSubsidy = 1 * COIN; + } + + LogPrint("GetProofOfWorkReward() : create=%s", FormatMoney(nSubsidy).c_str(), nSubsidy); + + return nSubsidy + nFees; +} + +// miner's coin stake reward +int64_t GetProofOfStakeReward(const CBlockIndex* pindexPrev, int64_t nCoinAge, int64_t nFees) +{ + int64_t nSubsidy; + + nSubsidy = nCoinAge * COIN_YEAR_REWARD * 33 / (365 * 33 + 8); + + if(pindexBest->nHeight >= 240000) { + nSubsidy = nCoinAge * COIN_YEAR_REWARD * 33 / (365 * 33 + 8) /180 * 50; +} + LogPrint("creation", "GetProofOfStakeReward(): create=%s nCoinAge=%d\n", FormatMoney(nSubsidy), nCoinAge); + + return nSubsidy + nFees; +} + +static const int64_t nTargetTimespan = 7 * 24 * 60 * 60; // 7 days + + +// +// maximum nBits value could possible be required nTime after +// +unsigned int ComputeMaxBits(CBigNum bnTargetLimit, unsigned int nBase, int64_t nTime) +{ + CBigNum bnResult; + bnResult.SetCompact(nBase); + bnResult *= 2; + while (nTime > 0 && bnResult < bnTargetLimit) + { + // Maximum 10% adjustment per day... + bnResult *= 2; + nTime -= 24 * 60 * 60; + } + if (bnResult > bnTargetLimit) + bnResult = bnTargetLimit; + return bnResult.GetCompact(); +} + +// +// minimum amount of work that could possibly be required nTime after +// minimum proof-of-work required was nBase +// +unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime) +{ + return ComputeMaxBits(Params().ProofOfWorkLimit(), nBase, nTime); +} + +// +// minimum amount of stake that could possibly be required nTime after +// minimum proof-of-stake required was nBase +// +unsigned int ComputeMinStake(unsigned int nBase, int64_t nTime, unsigned int nBlockTime) +{ + return ComputeMaxBits(bnProofOfStakeLimit, nBase, nTime); +} + + +// ppcoin: find last block index up to pindex +const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfStake) +{ + while (pindex && pindex->pprev && (pindex->IsProofOfStake() != fProofOfStake)) + pindex = pindex->pprev; + return pindex; +} + +int nTargetSpacing = 135; + +unsigned int GetNextTargetRequired_PoS(const CBlockIndex* pindexLast, bool fProofOfStake) +{ + CBigNum bnTargetLimit = fProofOfStake ? GetProofOfStakeLimit(pindexLast->nHeight) : Params().ProofOfWorkLimit(); + + if (pindexLast == NULL) + return bnTargetLimit.GetCompact(); // genesis block + + const CBlockIndex* pindexPrev = GetLastBlockIndex(pindexLast, fProofOfStake); + if (pindexPrev->pprev == NULL) + return bnTargetLimit.GetCompact(); // first block + const CBlockIndex* pindexPrevPrev = GetLastBlockIndex(pindexPrev->pprev, fProofOfStake); + if (pindexPrevPrev->pprev == NULL) + return bnTargetLimit.GetCompact(); // second block + + int64_t nTargetSpacing = GetTargetSpacing(pindexLast->nHeight); + int64_t nActualSpacing = pindexPrev->GetBlockTime() - pindexPrevPrev->GetBlockTime(); + if (IsProtocolV1RetargetingFixed(pindexLast->nHeight)) { + if (nActualSpacing < 0) + nActualSpacing = nTargetSpacing; + } + if (IsProtocolV3(pindexLast->nTime)) { + if (nActualSpacing > nTargetSpacing * 10) + nActualSpacing = nTargetSpacing * 10; + } + + // ppcoin: target change every block + // ppcoin: retarget with exponential moving toward target spacing + CBigNum bnNew; + bnNew.SetCompact(pindexPrev->nBits); + int64_t nInterval = nTargetTimespan / nTargetSpacing; + bnNew *= ((nInterval - 1) * nTargetSpacing + nActualSpacing + nActualSpacing); + bnNew /= ((nInterval + 1) * nTargetSpacing); + + if (bnNew <= 0 || bnNew > bnTargetLimit) + bnNew = bnTargetLimit; + + return bnNew.GetCompact(); +} + +unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast/*, const CBlock *pblock*/) { + /* current difficulty formula, darkcoin - DarkGravity v3, written by Evan Duffield - evan@darkcoin.io */ + const CBlockIndex *BlockLastSolved = pindexLast; + const CBlockIndex *BlockReading = pindexLast; + // const CBlock *BlockCreating = pblock; + // BlockCreating = BlockCreating; + int64_t nActualTimespan = 0; + int64_t LastBlockTime = 0; + int64_t PastBlocksMin = 24; + int64_t PastBlocksMax = 24; + int64_t CountBlocks = 0; + CBigNum PastDifficultyAverage; + CBigNum PastDifficultyAveragePrev; + + if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || BlockLastSolved->nHeight < PastBlocksMin) { + return bnProofOfWorkLimit.GetCompact(); + } + + for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) { + if (PastBlocksMax > 0 && i > PastBlocksMax) { break; } + CountBlocks++; + + if(CountBlocks <= PastBlocksMin) { + if (CountBlocks == 1) { PastDifficultyAverage.SetCompact(BlockReading->nBits); } + else { PastDifficultyAverage = ((PastDifficultyAveragePrev * CountBlocks)+(CBigNum().SetCompact(BlockReading->nBits))) / (CountBlocks+1); } + PastDifficultyAveragePrev = PastDifficultyAverage; + } + + if(LastBlockTime > 0){ + int64_t Diff = (LastBlockTime - BlockReading->GetBlockTime()); + nActualTimespan += Diff; + } + LastBlockTime = BlockReading->GetBlockTime(); + + if (BlockReading->pprev == NULL) { assert(BlockReading); break; } + BlockReading = BlockReading->pprev; + } + + int64_t nTargetSpacing = GetTargetSpacing(pindexLast->nHeight); + + CBigNum bnNew(PastDifficultyAverage); + + int64_t nTargetTimespan = CountBlocks*nTargetSpacing; + + if (nActualTimespan < nTargetTimespan/3) + nActualTimespan = nTargetTimespan/3; + if (nActualTimespan > nTargetTimespan*3) + nActualTimespan = nTargetTimespan*3; + + // Retarget + bnNew *= nActualTimespan; + bnNew /= nTargetTimespan; + + if (bnNew > bnProofOfWorkLimit){ + bnNew = bnProofOfWorkLimit; + } + + //printf("Difficulty Retarget - Dark Gravity Wave 3\n"); + //printf("Before: %08x %s\n", BlockLastSolved->nBits, CBigNum().SetCompact(BlockLastSolved->nBits).getuint256().ToString().c_str()); + //printf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString().c_str()); + + return bnNew.GetCompact(); +} + +unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake) +{ + // Smoothly Transition: GetNextTargetRequired_Initial_POW -> DGW -> GetNextTargetRequired_POS + if (pindexLast->nHeight < 10) + return GetNextTargetRequired_PoS(pindexLast, fProofOfStake); + else if (pindexLast->nHeight < 100000000) + return DarkGravityWave3(pindexLast); + else + return GetNextTargetRequired_PoS(pindexLast, fProofOfStake); +} + + +bool CheckProofOfWork(uint256 hash, unsigned int nBits) +{ + CBigNum bnTarget; + bnTarget.SetCompact(nBits); + + // Check range + // if (bnTarget <= 0 || bnTarget > Params().ProofOfWorkLimit()) + // return error("CheckProofOfWork() : nBits below minimum work"); + + // Check proof of work matches claimed amount + if (hash > bnTarget.getuint256()) + return error("CheckProofOfWork() : hash doesn't match nBits"); + + return true; +} + +bool IsInitialBlockDownload() +{ + LOCK(cs_main); + if (pindexBest == NULL || nBestHeight < Checkpoints::GetTotalBlocksEstimate()) + return true; + static int64_t nLastUpdate; + static CBlockIndex* pindexLastBest; + if (pindexBest != pindexLastBest) + { + pindexLastBest = pindexBest; + nLastUpdate = GetTime(); + } + return (GetTime() - nLastUpdate < 15 && + pindexBest->GetBlockTime() < GetTime() - 8 * 60 * 60); +} + +// Requires cs_main. +void Misbehaving(NodeId pnode, int howmuch) +{ + if (howmuch == 0) + return; + + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pn, vNodes) + { + if(pn->GetId() == pnode) + { + pn->nMisbehavior += howmuch; + int banscore = GetArg("-banscore", 100); + if (pn->nMisbehavior >= banscore && pn->nMisbehavior - howmuch < banscore) + { + LogPrintf("Misbehaving: %s (%d -> %d) BAN THRESHOLD EXCEEDED\n", pn->addrName, pn->nMisbehavior-howmuch, pn->nMisbehavior); + //pn->fShouldBan = true; + } + else + LogPrintf("Misbehaving: %s (%d -> %d)\n", pn->addrName, pn->nMisbehavior-howmuch, pn->nMisbehavior); + + break; + } + } +} + +void static InvalidChainFound(CBlockIndex* pindexNew) +{ + if (pindexNew->nChainTrust > nBestInvalidTrust) + { + nBestInvalidTrust = pindexNew->nChainTrust; + CTxDB().WriteBestInvalidTrust(CBigNum(nBestInvalidTrust)); + } + + uint256 nBestInvalidBlockTrust = pindexNew->nChainTrust - pindexNew->pprev->nChainTrust; + uint256 nBestBlockTrust = pindexBest->nHeight != 0 ? (pindexBest->nChainTrust - pindexBest->pprev->nChainTrust) : pindexBest->nChainTrust; + + LogPrintf("InvalidChainFound: invalid block=%s height=%d trust=%s blocktrust=%d date=%s\n", + pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, + CBigNum(pindexNew->nChainTrust).ToString(), nBestInvalidBlockTrust.Get64(), + DateTimeStrFormat("%x %H:%M:%S", pindexNew->GetBlockTime())); + LogPrintf("InvalidChainFound: current best=%s height=%d trust=%s blocktrust=%d date=%s\n", + hashBestChain.ToString(), nBestHeight, + CBigNum(pindexBest->nChainTrust).ToString(), + nBestBlockTrust.Get64(), + DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime())); +} + + +void CBlock::UpdateTime(const CBlockIndex* pindexPrev) +{ + nTime = max(GetBlockTime(), GetAdjustedTime()); +} + + + + +bool CTransaction::DisconnectInputs(CTxDB& txdb) +{ + // Relinquish previous transactions' spent pointers + if (!IsCoinBase()) + { + BOOST_FOREACH(const CTxIn& txin, vin) + { + COutPoint prevout = txin.prevout; + + // Get prev txindex from disk + CTxIndex txindex; + if (!txdb.ReadTxIndex(prevout.hash, txindex)) + return error("DisconnectInputs() : ReadTxIndex failed"); + + if (prevout.n >= txindex.vSpent.size()) + return error("DisconnectInputs() : prevout.n out of range"); + + // Mark outpoint as not spent + txindex.vSpent[prevout.n].SetNull(); + + // Write back + if (!txdb.UpdateTxIndex(prevout.hash, txindex)) + return error("DisconnectInputs() : UpdateTxIndex failed"); + } + } + + // Remove transaction from index + // This can fail if a duplicate of this transaction was in a chain that got + // reorganized away. This is only possible if this transaction was completely + // spent, so erasing it would be a no-op anyway. + txdb.EraseTxIndex(*this); + + return true; +} + + +bool CTransaction::FetchInputs(CTxDB& txdb, const map& mapTestPool, + bool fBlock, bool fMiner, MapPrevTx& inputsRet, bool& fInvalid) +{ + // FetchInputs can return false either because we just haven't seen some inputs + // (in which case the transaction should be stored as an orphan) + // or because the transaction is malformed (in which case the transaction should + // be dropped). If tx is definitely invalid, fInvalid will be set to true. + fInvalid = false; + + if (IsCoinBase()) + return true; // Coinbase transactions have no inputs to fetch. + + for (unsigned int i = 0; i < vin.size(); i++) + { + COutPoint prevout = vin[i].prevout; + if (inputsRet.count(prevout.hash)) + continue; // Got it already + + // Read txindex + CTxIndex& txindex = inputsRet[prevout.hash].first; + bool fFound = true; + if ((fBlock || fMiner) && mapTestPool.count(prevout.hash)) + { + // Get txindex from current proposed changes + txindex = mapTestPool.find(prevout.hash)->second; + } + else + { + // Read txindex from txdb + fFound = txdb.ReadTxIndex(prevout.hash, txindex); + } + if (!fFound && (fBlock || fMiner)) + return fMiner ? false : error("FetchInputs() : %s prev tx %s index entry not found", GetHash().ToString(), prevout.hash.ToString()); + + // Read txPrev + CTransaction& txPrev = inputsRet[prevout.hash].second; + if (!fFound || txindex.pos == CDiskTxPos(1,1,1)) + { + // Get prev tx from single transactions in memory + if (!mempool.lookup(prevout.hash, txPrev)) + return error("FetchInputs() : %s mempool Tx prev not found %s", GetHash().ToString(), prevout.hash.ToString()); + if (!fFound) + txindex.vSpent.resize(txPrev.vout.size()); + } + else + { + // Get prev tx from disk + if (!txPrev.ReadFromDisk(txindex.pos)) + return error("FetchInputs() : %s ReadFromDisk prev tx %s failed", GetHash().ToString(), prevout.hash.ToString()); + } + } + + // Make sure all prevout.n indexes are valid: + for (unsigned int i = 0; i < vin.size(); i++) + { + const COutPoint prevout = vin[i].prevout; + assert(inputsRet.count(prevout.hash) != 0); + const CTxIndex& txindex = inputsRet[prevout.hash].first; + const CTransaction& txPrev = inputsRet[prevout.hash].second; + if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) + { + // Revisit this if/when transaction replacement is implemented and allows + // adding inputs: + fInvalid = true; + return DoS(100, error("FetchInputs() : %s prevout.n out of range %d %u %u prev tx %s\n%s", GetHash().ToString(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString(), txPrev.ToString())); + } + } + + return true; +} + +const CTxOut& CTransaction::GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const +{ + MapPrevTx::const_iterator mi = inputs.find(input.prevout.hash); + if (mi == inputs.end()) + throw std::runtime_error("CTransaction::GetOutputFor() : prevout.hash not found"); + + const CTransaction& txPrev = (mi->second).second; + if (input.prevout.n >= txPrev.vout.size()) + throw std::runtime_error("CTransaction::GetOutputFor() : prevout.n out of range"); + + return txPrev.vout[input.prevout.n]; +} + +int64_t CTransaction::GetValueIn(const MapPrevTx& inputs) const +{ + if (IsCoinBase()) + return 0; + + int64_t nResult = 0; + for (unsigned int i = 0; i < vin.size(); i++) + { + nResult += GetOutputFor(vin[i], inputs).nValue; + } + return nResult; + +} + +bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs, map& mapTestPool, const CDiskTxPos& posThisTx, + const CBlockIndex* pindexBlock, bool fBlock, bool fMiner, unsigned int flags, bool fValidateSig) +{ + // Take over previous transactions' spent pointers + // fBlock is true when this is called from AcceptBlock when a new best-block is added to the blockchain + // fMiner is true when called from the internal bitcoin miner + // ... both are false when called from CTransaction::AcceptToMemoryPool + if (!IsCoinBase()) + { + int64_t nValueIn = 0; + int64_t nFees = 0; + for (unsigned int i = 0; i < vin.size(); i++) + { + COutPoint prevout = vin[i].prevout; + assert(inputs.count(prevout.hash) > 0); + CTxIndex& txindex = inputs[prevout.hash].first; + CTransaction& txPrev = inputs[prevout.hash].second; + + if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) + return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %u %u prev tx %s\n%s", GetHash().ToString(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString(), txPrev.ToString())); + + // If prev is coinbase or coinstake, check that it's matured + if (txPrev.IsCoinBase() || txPrev.IsCoinStake()) + for (const CBlockIndex* pindex = pindexBlock; pindex && pindexBlock->nHeight - pindex->nHeight < nCoinbaseMaturity; pindex = pindex->pprev) + if (pindex->nBlockPos == txindex.pos.nBlockPos && pindex->nFile == txindex.pos.nFile) + return error("ConnectInputs() : tried to spend %s at depth %d", txPrev.IsCoinBase() ? "coinbase" : "coinstake", pindexBlock->nHeight - pindex->nHeight); + + // ppcoin: check transaction timestamp + if (txPrev.nTime > nTime) + return DoS(100, error("ConnectInputs() : transaction timestamp earlier than input transaction")); + + // Check for negative or overflow input values + nValueIn += txPrev.vout[prevout.n].nValue; + if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn)) + return DoS(100, error("ConnectInputs() : txin values out of range")); + + } + // The first loop above does all the inexpensive checks. + // Only if ALL inputs pass do we perform expensive ECDSA signature checks. + // Helps prevent CPU exhaustion attacks. + for (unsigned int i = 0; i < vin.size(); i++) + { + COutPoint prevout = vin[i].prevout; + assert(inputs.count(prevout.hash) > 0); + CTxIndex& txindex = inputs[prevout.hash].first; + CTransaction& txPrev = inputs[prevout.hash].second; + + // Check for conflicts (double-spend) + // This doesn't trigger the DoS code on purpose; if it did, it would make it easier + // for an attacker to attempt to split the network. + if (!txindex.vSpent[prevout.n].IsNull()) + return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString(), txindex.vSpent[prevout.n].ToString()); + + if(fValidateSig) + { + // Skip ECDSA signature verification when connecting blocks (fBlock=true) + // before the last blockchain checkpoint. This is safe because block merkle hashes are + // still computed and checked, and any change will be caught at the next checkpoint. + if (!(fBlock && (nBestHeight < Checkpoints::GetTotalBlocksEstimate()))) + { + // Verify signature + if (!VerifySignature(txPrev, *this, i, flags, 0)) + { + if (flags & STANDARD_NOT_MANDATORY_VERIFY_FLAGS) { + // Check whether the failure was caused by a + // non-mandatory script verification check, such as + // non-null dummy arguments; + // if so, don't trigger DoS protection to + // avoid splitting the network between upgraded and + // non-upgraded nodes. + if (VerifySignature(txPrev, *this, i, flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS, 0)) + return error("ConnectInputs() : %s non-mandatory VerifySignature failed", GetHash().ToString()); + } + // Failures of other flags indicate a transaction that is + // invalid in new blocks, e.g. a invalid P2SH. We DoS ban + // such nodes as they are not following the protocol. That + // said during an upgrade careful thought should be taken + // as to the correct behavior - we may want to continue + // peering with non-upgraded nodes even after a soft-fork + // super-majority vote has passed. + return DoS(100,error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString())); + } + } + } + + // Mark outpoints as spent + txindex.vSpent[prevout.n] = posThisTx; + + // Write back + if (fBlock || fMiner) + { + mapTestPool[prevout.hash] = txindex; + } + } + + if (!IsCoinStake()) + { + if (nValueIn < GetValueOut()) + return DoS(100, error("ConnectInputs() : %s value in < value out", GetHash().ToString())); + + // Tally transaction fees + int64_t nTxFee = nValueIn - GetValueOut(); + if (nTxFee < 0) + return DoS(100, error("ConnectInputs() : %s nTxFee < 0", GetHash().ToString())); + + // enforce transaction fees for every block + int64_t nRequiredFee = GetMinFee(*this); + if (nTxFee < nRequiredFee) + return fBlock? DoS(100, error("ConnectInputs() : %s not paying required fee=%s, paid=%s", GetHash().ToString(), FormatMoney(nRequiredFee), FormatMoney(nTxFee))) : false; + + nFees += nTxFee; + if (!MoneyRange(nFees)) + return DoS(100, error("ConnectInputs() : nFees out of range")); + } + } + + return true; +} + +bool CBlock::DisconnectBlock(CTxDB& txdb, CBlockIndex* pindex) +{ + // Disconnect in reverse order + for (int i = vtx.size()-1; i >= 0; i--) + if (!vtx[i].DisconnectInputs(txdb)) + return false; + + // Update block index on disk without changing it in memory. + // The memory index structure will be changed after the db commits. + if (pindex->pprev) + { + CDiskBlockIndex blockindexPrev(pindex->pprev); + blockindexPrev.hashNext = 0; + if (!txdb.WriteBlockIndex(blockindexPrev)) + return error("DisconnectBlock() : WriteBlockIndex failed"); + } + + // ppcoin: clean up wallet after disconnecting coinstake + BOOST_FOREACH(CTransaction& tx, vtx) + SyncWithWallets(tx, this, false); + + return true; +} + +bool static BuildAddrIndex(const CScript &script, std::vector& addrIds) +{ + CScript::const_iterator pc = script.begin(); + CScript::const_iterator pend = script.end(); + std::vector data; + opcodetype opcode; + bool fHaveData = false; + while (pc < pend) { + script.GetOp(pc, opcode, data); + if (0 <= opcode && opcode <= OP_PUSHDATA4 && data.size() >= 8) { // data element + uint160 addrid = 0; + if (data.size() <= 20) { + memcpy(&addrid, &data[0], data.size()); + } else { + addrid = Hash160(data); + } + addrIds.push_back(addrid); + fHaveData = true; + } + } + if (!fHaveData) { + uint160 addrid = Hash160(script); + addrIds.push_back(addrid); + return true; + } + else + { + if(addrIds.size() > 0) + return true; + else + return false; + } +} + +bool FindTransactionsByDestination(const CTxDestination &dest, std::vector &vtxhash) { + uint160 addrid = 0; + const CKeyID *pkeyid = boost::get(&dest); + if (pkeyid) + addrid = static_cast(*pkeyid); + if (!addrid) { + const CScriptID *pscriptid = boost::get(&dest); + if (pscriptid) + addrid = static_cast(*pscriptid); + } + if (!addrid) + { + LogPrintf("FindTransactionsByDestination(): Couldn't parse dest into addrid\n"); + return false; + } + + LOCK(cs_main); + CTxDB txdb("r"); + if(!txdb.ReadAddrIndex(addrid, vtxhash)) + { + LogPrintf("FindTransactionsByDestination(): txdb.ReadAddrIndex failed\n"); + return false; + } + return true; +} + +void CBlock::RebuildAddressIndex(CTxDB& txdb) +{ + BOOST_FOREACH(CTransaction& tx, vtx) + { + uint256 hashTx = tx.GetHash(); + // inputs + if(!tx.IsCoinBase()) + { + MapPrevTx mapInputs; + map mapQueuedChangesT; + bool fInvalid; + if (!tx.FetchInputs(txdb, mapQueuedChangesT, true, false, mapInputs, fInvalid)) + return; + + MapPrevTx::const_iterator mi; + for(MapPrevTx::const_iterator mi = mapInputs.begin(); mi != mapInputs.end(); ++mi) + { + BOOST_FOREACH(const CTxOut &atxout, (*mi).second.second.vout) + { + std::vector addrIds; + if(BuildAddrIndex(atxout.scriptPubKey, addrIds)) + { + BOOST_FOREACH(uint160 addrId, addrIds) + { + if(!txdb.WriteAddrIndex(addrId, hashTx)) + LogPrintf("RebuildAddressIndex(): txins WriteAddrIndex failed addrId: %s txhash: %s\n", addrId.ToString().c_str(), hashTx.ToString().c_str()); + } + } + } + } + + } + // outputs + BOOST_FOREACH(const CTxOut &atxout, tx.vout) { + std::vector addrIds; + if(BuildAddrIndex(atxout.scriptPubKey, addrIds)) + { + BOOST_FOREACH(uint160 addrId, addrIds) + { + if(!txdb.WriteAddrIndex(addrId, hashTx)) + LogPrintf("RebuildAddressIndex(): txouts WriteAddrIndex failed addrId: %s txhash: %s\n", addrId.ToString().c_str(), hashTx.ToString().c_str()); + } + } + } + } +} + +bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) +{ + // Check it again in case a previous version let a bad block in, but skip BlockSig checking + if (!CheckBlock(!fJustCheck, !fJustCheck, false)) + return false; + + unsigned int flags = SCRIPT_VERIFY_NOCACHE; + + //// issue here: it doesn't know the version + unsigned int nTxPos; + if (fJustCheck) + // FetchInputs treats CDiskTxPos(1,1,1) as a special "refer to memorypool" indicator + // Since we're just checking the block and not actually connecting it, it might not (and probably shouldn't) be on the disk to get the transaction from + nTxPos = 1; + else + nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK, CLIENT_VERSION) - (2 * GetSizeOfCompactSize(0)) + GetSizeOfCompactSize(vtx.size()); + + map mapQueuedChanges; + int64_t nFees = 0; + int64_t nValueIn = 0; + int64_t nValueOut = 0; + int64_t nStakeReward = 0; + unsigned int nSigOps = 0; + int nInputs = 0; + + BOOST_FOREACH(CTransaction& tx, vtx) + { + uint256 hashTx = tx.GetHash(); + nInputs += tx.vin.size(); + + // Do not allow blocks that contain transactions which 'overwrite' older transactions, + // unless those are already completely spent. + // If such overwrites are allowed, coinbases and transactions depending upon those + // can be duplicated to remove the ability to spend the first instance -- even after + // being sent to another address. + // See BIP30 and http://r6.ca/blog/20120206T005236Z.html for more information. + // This logic is not necessary for memory pool transactions, as AcceptToMemoryPool + // already refuses previously-known transaction ids entirely. + // This rule was originally applied all blocks whose timestamp was after March 15, 2012, 0:00 UTC. + // Now that the whole chain is irreversibly beyond that time it is applied to all blocks except the + // two in the chain that violate it. This prevents exploiting the issue against nodes in their + // initial block download. + CTxIndex txindexOld; + if (txdb.ReadTxIndex(hashTx, txindexOld)) { + BOOST_FOREACH(CDiskTxPos &pos, txindexOld.vSpent) + if (pos.IsNull()) + return DoS(100, error("ConnectBlock() : tried to overwrite transaction")); + } + + nSigOps += GetLegacySigOpCount(tx); + if (nSigOps > MAX_BLOCK_SIGOPS) + return DoS(100, error("ConnectBlock() : too many sigops")); + + CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos); + if (!fJustCheck) + nTxPos += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION); + + MapPrevTx mapInputs; + if (tx.IsCoinBase()) + nValueOut += tx.GetValueOut(); + else + { + bool fInvalid; + if (!tx.FetchInputs(txdb, mapQueuedChanges, true, false, mapInputs, fInvalid)) + return false; + + // Add in sigops done by pay-to-script-hash inputs; + // this is to prevent a "rogue miner" from creating + // an incredibly-expensive-to-validate block. + nSigOps += GetP2SHSigOpCount(tx, mapInputs); + if (nSigOps > MAX_BLOCK_SIGOPS) + return DoS(100, error("ConnectBlock() : too many sigops")); + + int64_t nTxValueIn = tx.GetValueIn(mapInputs); + int64_t nTxValueOut = tx.GetValueOut(); + nValueIn += nTxValueIn; + nValueOut += nTxValueOut; + if (!tx.IsCoinStake()) + nFees += nTxValueIn - nTxValueOut; + if (tx.IsCoinStake()) + nStakeReward = nTxValueOut - nTxValueIn; + + + if (!tx.ConnectInputs(txdb, mapInputs, mapQueuedChanges, posThisTx, pindex, true, false, flags)) + return false; + } + + mapQueuedChanges[hashTx] = CTxIndex(posThisTx, tx.vout.size()); + } + + if (IsProofOfWork()) + { + int64_t nReward = GetProofOfWorkReward(nFees); + // Check coinbase reward + if (vtx[0].GetValueOut() > nReward) + return DoS(50, error("ConnectBlock() : coinbase reward exceeded (actual=%d vs calculated=%d)", + vtx[0].GetValueOut(), + nReward)); + } + if (IsProofOfStake()) + { + // ppcoin: coin stake tx earns reward instead of paying fee + uint64_t nCoinAge; + if (!vtx[1].GetCoinAge(txdb, nCoinAge)) + return error("ConnectBlock() : %s unable to get coin age for coinstake", vtx[1].GetHash().ToString()); + + // int64_t nCalculatedStakeReward = GetProofOfStakeReward(pindex->pprev, nCoinAge, nFees); + + // if (nStakeReward > nCalculatedStakeReward) + // return DoS(100, error("ConnectBlock() : coinstake pays too much(actual=%d vs calculated=%d)", nStakeReward, nCalculatedStakeReward)); + } + + // ppcoin: track money supply and mint amount info + pindex->nMint = nValueOut - nValueIn + nFees; + pindex->nMoneySupply = (pindex->pprev? pindex->pprev->nMoneySupply : 0) + nValueOut - nValueIn; + if (!txdb.WriteBlockIndex(CDiskBlockIndex(pindex))) + return error("Connect() : WriteBlockIndex for pindex failed"); + + if (fJustCheck) + return true; + + // Write queued txindex changes + for (map::iterator mi = mapQueuedChanges.begin(); mi != mapQueuedChanges.end(); ++mi) + { + if (!txdb.UpdateTxIndex((*mi).first, (*mi).second)) + return error("ConnectBlock() : UpdateTxIndex failed"); + } + if(GetBoolArg("-addrindex", false)) + + // Write Address Index + BOOST_FOREACH(CTransaction& tx, vtx) + { + uint256 hashTx = tx.GetHash(); + // inputs + if(!tx.IsCoinBase()) + { + MapPrevTx mapInputs; + map mapQueuedChangesT; + bool fInvalid; + if (!tx.FetchInputs(txdb, mapQueuedChangesT, true, false, mapInputs, fInvalid)) + return false; + + MapPrevTx::const_iterator mi; + for(MapPrevTx::const_iterator mi = mapInputs.begin(); mi != mapInputs.end(); ++mi) + { + BOOST_FOREACH(const CTxOut &atxout, (*mi).second.second.vout) + { + std::vector addrIds; + if(BuildAddrIndex(atxout.scriptPubKey, addrIds)) + { + BOOST_FOREACH(uint160 addrId, addrIds) + { + if(!txdb.WriteAddrIndex(addrId, hashTx)) + LogPrintf("ConnectBlock(): txins WriteAddrIndex failed addrId: %s txhash: %s\n", addrId.ToString().c_str(), hashTx.ToString().c_str()); + } + } + } + } + + } + + // outputs + BOOST_FOREACH(const CTxOut &atxout, tx.vout) { + std::vector addrIds; + if(BuildAddrIndex(atxout.scriptPubKey, addrIds)) + { + BOOST_FOREACH(uint160 addrId, addrIds) + { + if(!txdb.WriteAddrIndex(addrId, hashTx)) + LogPrintf("ConnectBlock(): txouts WriteAddrIndex failed addrId: %s txhash: %s\n", addrId.ToString().c_str(), hashTx.ToString().c_str()); + } + } + } + } + + // Update block index on disk without changing it in memory. + // The memory index structure will be changed after the db commits. + if (pindex->pprev) + { + CDiskBlockIndex blockindexPrev(pindex->pprev); + blockindexPrev.hashNext = pindex->GetBlockHash(); + if (!txdb.WriteBlockIndex(blockindexPrev)) + return error("ConnectBlock() : WriteBlockIndex failed"); + } + + // Watch for transactions paying to me + BOOST_FOREACH(CTransaction& tx, vtx) + SyncWithWallets(tx, this); + + return true; +} + +bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) +{ + LogPrintf("REORGANIZE\n"); + + // Find the fork + CBlockIndex* pfork = pindexBest; + CBlockIndex* plonger = pindexNew; + while (pfork != plonger) + { + while (plonger->nHeight > pfork->nHeight) + if (!(plonger = plonger->pprev)) + return error("Reorganize() : plonger->pprev is null"); + if (pfork == plonger) + break; + if (!(pfork = pfork->pprev)) + return error("Reorganize() : pfork->pprev is null"); + } + + // List of what to disconnect + vector vDisconnect; + for (CBlockIndex* pindex = pindexBest; pindex != pfork; pindex = pindex->pprev) + vDisconnect.push_back(pindex); + + // List of what to connect + vector vConnect; + for (CBlockIndex* pindex = pindexNew; pindex != pfork; pindex = pindex->pprev) + vConnect.push_back(pindex); + reverse(vConnect.begin(), vConnect.end()); + + LogPrintf("REORGANIZE: Disconnect %u blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString(), pindexBest->GetBlockHash().ToString()); + LogPrintf("REORGANIZE: Connect %u blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString(), pindexNew->GetBlockHash().ToString()); + + // Disconnect shorter branch + list vResurrect; + BOOST_FOREACH(CBlockIndex* pindex, vDisconnect) + { + CBlock block; + if (!block.ReadFromDisk(pindex)) + return error("Reorganize() : ReadFromDisk for disconnect failed"); + if (!block.DisconnectBlock(txdb, pindex)) + return error("Reorganize() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString()); + + // Queue memory transactions to resurrect. + // We only do this for blocks after the last checkpoint (reorganisation before that + // point should only happen with -reindex/-loadblock, or a misbehaving peer. + BOOST_REVERSE_FOREACH(const CTransaction& tx, block.vtx) + if (!(tx.IsCoinBase() || tx.IsCoinStake()) && pindex->nHeight > Checkpoints::GetTotalBlocksEstimate()) + vResurrect.push_front(tx); + } + + // Connect longer branch + vector vDelete; + for (unsigned int i = 0; i < vConnect.size(); i++) + { + CBlockIndex* pindex = vConnect[i]; + CBlock block; + if (!block.ReadFromDisk(pindex)) + return error("Reorganize() : ReadFromDisk for connect failed"); + if (!block.ConnectBlock(txdb, pindex)) + { + // Invalid block + return error("Reorganize() : ConnectBlock %s failed", pindex->GetBlockHash().ToString()); + } + + // Queue memory transactions to delete + BOOST_FOREACH(const CTransaction& tx, block.vtx) + vDelete.push_back(tx); + } + if (!txdb.WriteHashBestChain(pindexNew->GetBlockHash())) + return error("Reorganize() : WriteHashBestChain failed"); + + // Make sure it's successfully written to disk before changing memory structure + if (!txdb.TxnCommit()) + return error("Reorganize() : TxnCommit failed"); + + // Disconnect shorter branch + BOOST_FOREACH(CBlockIndex* pindex, vDisconnect) + if (pindex->pprev) + pindex->pprev->pnext = NULL; + + // Connect longer branch + BOOST_FOREACH(CBlockIndex* pindex, vConnect) + if (pindex->pprev) + pindex->pprev->pnext = pindex; + + // Resurrect memory transactions that were in the disconnected branch + BOOST_FOREACH(CTransaction& tx, vResurrect) + AcceptToMemoryPool(mempool, tx, false, NULL); + + // Delete redundant memory transactions that are in the connected branch + BOOST_FOREACH(CTransaction& tx, vDelete) { + mempool.remove(tx); + mempool.removeConflicts(tx); + } + + LogPrintf("REORGANIZE: done\n"); + + return true; +} + + +// Called from inside SetBestChain: attaches a block to the new best chain being built +bool CBlock::SetBestChainInner(CTxDB& txdb, CBlockIndex *pindexNew) +{ + uint256 hash = GetHash(); + + // Adding to current best branch + if (!ConnectBlock(txdb, pindexNew) || !txdb.WriteHashBestChain(hash)) + { + txdb.TxnAbort(); + InvalidChainFound(pindexNew); + return false; + } + if (!txdb.TxnCommit()) + return error("SetBestChain() : TxnCommit failed"); + + // Add to current best branch + pindexNew->pprev->pnext = pindexNew; + + // Delete redundant memory transactions + BOOST_FOREACH(CTransaction& tx, vtx) + mempool.remove(tx); + + return true; +} + +bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew) +{ + uint256 hash = GetHash(); + + if (!txdb.TxnBegin()) + return error("SetBestChain() : TxnBegin failed"); + + if (pindexGenesisBlock == NULL && hash == Params().HashGenesisBlock()) + { + txdb.WriteHashBestChain(hash); + if (!txdb.TxnCommit()) + return error("SetBestChain() : TxnCommit failed"); + pindexGenesisBlock = pindexNew; + } + else if (hashPrevBlock == hashBestChain) + { + if (!SetBestChainInner(txdb, pindexNew)) + return error("SetBestChain() : SetBestChainInner failed"); + } + else + { + // the first block in the new chain that will cause it to become the new best chain + CBlockIndex *pindexIntermediate = pindexNew; + + // list of blocks that need to be connected afterwards + std::vector vpindexSecondary; + + // Reorganize is costly in terms of db load, as it works in a single db transaction. + // Try to limit how much needs to be done inside + while (pindexIntermediate->pprev && pindexIntermediate->pprev->nChainTrust > pindexBest->nChainTrust) + { + vpindexSecondary.push_back(pindexIntermediate); + pindexIntermediate = pindexIntermediate->pprev; + } + + if (!vpindexSecondary.empty()) + LogPrintf("Postponing %u reconnects\n", vpindexSecondary.size()); + + // Switch to new best branch + if (!Reorganize(txdb, pindexIntermediate)) + { + txdb.TxnAbort(); + InvalidChainFound(pindexNew); + return error("SetBestChain() : Reorganize failed"); + } + + // Connect further blocks + BOOST_REVERSE_FOREACH(CBlockIndex *pindex, vpindexSecondary) + { + CBlock block; + if (!block.ReadFromDisk(pindex)) + { + LogPrintf("SetBestChain() : ReadFromDisk failed\n"); + break; + } + if (!txdb.TxnBegin()) { + LogPrintf("SetBestChain() : TxnBegin 2 failed\n"); + break; + } + // errors now are not fatal, we still did a reorganisation to a new chain in a valid way + if (!block.SetBestChainInner(txdb, pindex)) + break; + } + } + + // Update best block in wallet (so we can detect restored wallets) + bool fIsInitialDownload = IsInitialBlockDownload(); + if ((pindexNew->nHeight % 20160) == 0 || (!fIsInitialDownload && (pindexNew->nHeight % 144) == 0)) + { + const CBlockLocator locator(pindexNew); + g_signals.SetBestChain(locator); + } + + // New best block + hashBestChain = hash; + pindexBest = pindexNew; + pblockindexFBBHLast = NULL; + nBestHeight = pindexBest->nHeight; + nBestChainTrust = pindexNew->nChainTrust; + nTimeBestReceived = GetTime(); + mempool.AddTransactionsUpdated(1); + + uint256 nBestBlockTrust = pindexBest->nHeight != 0 ? (pindexBest->nChainTrust - pindexBest->pprev->nChainTrust) : pindexBest->nChainTrust; + + LogPrintf("SetBestChain: new best=%s height=%d trust=%s blocktrust=%d date=%s\n", + hashBestChain.ToString(), nBestHeight, + CBigNum(nBestChainTrust).ToString(), + nBestBlockTrust.Get64(), + DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime())); + + // Check the version of the last 100 blocks to see if we need to upgrade: + if (!fIsInitialDownload) + { + int nUpgraded = 0; + const CBlockIndex* pindex = pindexBest; + for (int i = 0; i < 100 && pindex != NULL; i++) + { + if (pindex->nVersion > CBlock::CURRENT_VERSION) + ++nUpgraded; + pindex = pindex->pprev; + } + if (nUpgraded > 0) + LogPrintf("SetBestChain: %d of last 100 blocks above version %d\n", nUpgraded, (int)CBlock::CURRENT_VERSION); + if (nUpgraded > 100/2) + // strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user: + strMiscWarning = _("Warning: This version is obsolete, upgrade required!"); + } + + std::string strCmd = GetArg("-blocknotify", ""); + + if (!fIsInitialDownload && !strCmd.empty()) + { + boost::replace_all(strCmd, "%s", hashBestChain.GetHex()); + boost::thread t(runCommand, strCmd); // thread runs free + } + + return true; +} + +// ppcoin: total coin age spent in transaction, in the unit of coin-days. +// Only those coins meeting minimum age requirement counts. As those +// transactions not in main chain are not currently indexed so we +// might not find out about their coin age. Older transactions are +// guaranteed to be in main chain by sync-checkpoint. This rule is +// introduced to help nodes establish a consistent view of the coin +// age (trust score) of competing branches. +bool CTransaction::GetCoinAge(CTxDB& txdb, uint64_t& nCoinAge) const +{ + CBigNum bnCentSecond = 0; // coin age in the unit of cent-seconds + nCoinAge = 0; + + if (IsCoinBase()) + return true; + + BOOST_FOREACH(const CTxIn& txin, vin) + { + // First try finding the previous transaction in database + CTransaction txPrev; + CTxIndex txindex; + if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex)) + continue; // previous transaction not in main chain + if (nTime < txPrev.nTime) + return false; // Transaction timestamp violation + + // Read block header + CBlock block; + if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false)) + return false; // unable to read block of previous transaction + if (block.GetBlockTime() + nStakeMinAge > nTime) + continue; // only count coins meeting min age requirement + + int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue; + bnCentSecond += CBigNum(nValueIn) * (nTime-txPrev.nTime) / CENT; + + LogPrint("coinage", "coin age nValueIn=%d nTimeDiff=%d bnCentSecond=%s\n", nValueIn, nTime - txPrev.nTime, bnCentSecond.ToString()); + } + + CBigNum bnCoinDay = bnCentSecond * CENT / COIN / (24 * 60 * 60); + LogPrint("coinage", "coin age bnCoinDay=%s\n", bnCoinDay.ToString()); + nCoinAge = bnCoinDay.getuint64(); + return true; +} + +bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos, const uint256& hashProof) +{ + AssertLockHeld(cs_main); + + // Check for duplicate + uint256 hash = GetHash(); + if (mapBlockIndex.count(hash)) + return error("AddToBlockIndex() : %s already exists", hash.ToString()); + + // Construct new block index object + CBlockIndex* pindexNew = new CBlockIndex(nFile, nBlockPos, *this); + if (!pindexNew) + return error("AddToBlockIndex() : new CBlockIndex failed"); + pindexNew->phashBlock = &hash; + map::iterator miPrev = mapBlockIndex.find(hashPrevBlock); + if (miPrev != mapBlockIndex.end()) + { + pindexNew->pprev = (*miPrev).second; + pindexNew->nHeight = pindexNew->pprev->nHeight + 1; + } + + // ppcoin: compute chain trust score + pindexNew->nChainTrust = (pindexNew->pprev ? pindexNew->pprev->nChainTrust : 0) + pindexNew->GetBlockTrust(); + + // ppcoin: compute stake entropy bit for stake modifier + if (!pindexNew->SetStakeEntropyBit(GetStakeEntropyBit())) + return error("AddToBlockIndex() : SetStakeEntropyBit() failed"); + + // Record proof hash value + pindexNew->hashProof = hashProof; + + // ppcoin: compute stake modifier + uint64_t nStakeModifier = 0; + bool fGeneratedStakeModifier = false; + if (!ComputeNextStakeModifier(pindexNew->pprev, nStakeModifier, fGeneratedStakeModifier)) + return error("AddToBlockIndex() : ComputeNextStakeModifier() failed"); + pindexNew->SetStakeModifier(nStakeModifier, fGeneratedStakeModifier); + + // Add to mapBlockIndex + map::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; + if (pindexNew->IsProofOfStake()) + setStakeSeen.insert(make_pair(pindexNew->prevoutStake, pindexNew->nStakeTime)); + pindexNew->phashBlock = &((*mi).first); + + // Write to disk block index + CTxDB txdb; + if (!txdb.TxnBegin()) + return false; + txdb.WriteBlockIndex(CDiskBlockIndex(pindexNew)); + if (!txdb.TxnCommit()) + return false; + + // New best + if (pindexNew->nChainTrust > nBestChainTrust) + if (!SetBestChain(txdb, pindexNew)) + return false; + + if (pindexNew == pindexBest) + { + // Notify UI to display prev block's coinbase if it was ours + static uint256 hashPrevBestCoinBase; + g_signals.UpdatedTransaction(hashPrevBestCoinBase); + hashPrevBestCoinBase = vtx[0].GetHash(); + } + + return true; +} + + + + +bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) const +{ + // These are checks that are independent of context + // that can be verified before saving an orphan block. + + // Size limits + if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE) + return DoS(100, error("CheckBlock() : size limits failed")); + + // Check proof of work matches claimed amount + if (fCheckPOW && IsProofOfWork() && !CheckProofOfWork(GetPoWHash(), nBits)) + return DoS(50, error("CheckBlock() : proof of work failed")); + + // Check timestamp + if (GetBlockTime() > FutureDriftV2(GetAdjustedTime())) + return error("CheckBlock() : block timestamp too far in the future"); + + // First transaction must be coinbase, the rest must not be + if (vtx.empty() || !vtx[0].IsCoinBase()) + return DoS(100, error("CheckBlock() : first tx is not coinbase")); + for (unsigned int i = 1; i < vtx.size(); i++) + if (vtx[i].IsCoinBase()) + return DoS(100, error("CheckBlock() : more than one coinbase")); + + if (IsProofOfStake()) + { + // Coinbase output should be empty if proof-of-stake block + if (vtx[0].vout.size() != 1 || !vtx[0].vout[0].IsEmpty()) + return DoS(100, error("CheckBlock() : coinbase output not empty for proof-of-stake block")); + + // Second transaction must be coinstake, the rest must not be + if (vtx.empty() || !vtx[1].IsCoinStake()) + return DoS(100, error("CheckBlock() : second tx is not coinstake")); + for (unsigned int i = 2; i < vtx.size(); i++) + if (vtx[i].IsCoinStake()) + return DoS(100, error("CheckBlock() : more than one coinstake")); + } + + // Check proof-of-stake block signature + if (fCheckSig && !CheckBlockSignature()) + return DoS(100, error("CheckBlock() : bad proof-of-stake block signature")); + + +// ----------- instantX transaction scanning ----------- + + + BOOST_FOREACH(const CTransaction& tx, vtx){ + if (!tx.IsCoinBase()){ + //only reject blocks when it's based on complete consensus + BOOST_FOREACH(const CTxIn& in, tx.vin){ + if(mapLockedInputs.count(in.prevout)){ + if(mapLockedInputs[in.prevout] != tx.GetHash()){ + if(fDebug) { LogPrintf("CheckBlock() : found conflicting transaction with transaction lock %s %s\n", mapLockedInputs[in.prevout].ToString().c_str(), tx.GetHash().ToString().c_str()); } + return DoS(0, error("CheckBlock() : found conflicting transaction with transaction lock")); + } + } + } + } + } + + + + // ----------- masternode payments ----------- + + bool MasternodePayments = false; + + if(nTime > START_MASTERNODE_PAYMENTS) MasternodePayments = true; + + if(MasternodePayments) + { + LOCK2(cs_main, mempool.cs); + + CBlockIndex *pindex = pindexBest; + if(IsProofOfStake() && pindex != NULL){ + if(pindex->GetBlockHash() == hashPrevBlock){ + CAmount masternodePaymentAmount = GetMasternodePayment(pindex->nHeight+1, vtx[1].GetValueOut()); + bool fIsInitialDownload = IsInitialBlockDownload(); + + // If we don't already have its previous block, skip masternode payment step + if (!fIsInitialDownload && pindex != NULL) + { + bool foundPaymentAmount = false; + bool foundPayee = false; + bool foundPaymentAndPayee = false; + + CScript payee; + if(!masternodePayments.GetBlockPayee(pindexBest->nHeight+1, payee) || payee == CScript()){ + foundPayee = true; //doesn't require a specific payee + foundPaymentAmount = true; + foundPaymentAndPayee = true; + if(fDebug) { LogPrintf("CheckBlock() : Using non-specific masternode payments %d\n", pindexBest->nHeight+1); } + } + + for (unsigned int i = 0; i < vtx[1].vout.size(); i++) { + if(vtx[1].vout[i].nValue == masternodePaymentAmount ) + foundPaymentAmount = true; + if(vtx[1].vout[i].scriptPubKey == payee ) + foundPayee = true; + if(vtx[1].vout[i].nValue == masternodePaymentAmount && vtx[1].vout[i].scriptPubKey == payee) + foundPaymentAndPayee = true; + } + + if(!foundPaymentAndPayee) { + CTxDestination address1; + ExtractDestination(payee, address1); + CBitcoinAddress address2(address1); + + if(fDebug) { LogPrintf("CheckBlock() : Couldn't find masternode payment(%d|%d) or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), pindexBest->nHeight+1); } + return DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee")); + } else { + if(fDebug) { LogPrintf("CheckBlock() : Found masternode payment %d\n", pindexBest->nHeight+1); } + } + } else { + if(fDebug) { LogPrintf("CheckBlock() : Is initial download, skipping masternode payment check %d\n", pindexBest->nHeight+1); } + } + } else { + if(fDebug) { LogPrintf("CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n", pindexBest->nHeight+1, GetHash().ToString().c_str()); } + } + } else { + if(fDebug) { LogPrintf("CheckBlock() : pindex is null, skipping masternode payment check\n"); } + } + } else { + if(fDebug) { LogPrintf("CheckBlock() : skipping masternode payment checks\n"); } + } + + + + // Check transactions + BOOST_FOREACH(const CTransaction& tx, vtx) + { + if (!tx.CheckTransaction()) + return DoS(tx.nDoS, error("CheckBlock() : CheckTransaction failed")); + + // ppcoin: check transaction timestamp + if (GetBlockTime() < (int64_t)tx.nTime) + return DoS(50, error("CheckBlock() : block timestamp earlier than transaction timestamp")); + } + + // Check for duplicate txids. This is caught by ConnectInputs(), + // but catching it earlier avoids a potential DoS attack: + set uniqueTx; + BOOST_FOREACH(const CTransaction& tx, vtx) + { + uniqueTx.insert(tx.GetHash()); + } + if (uniqueTx.size() != vtx.size()) + return DoS(100, error("CheckBlock() : duplicate transaction")); + + unsigned int nSigOps = 0; + BOOST_FOREACH(const CTransaction& tx, vtx) + { + nSigOps += GetLegacySigOpCount(tx); + } + if (nSigOps > MAX_BLOCK_SIGOPS) + return DoS(100, error("CheckBlock() : out-of-bounds SigOpCount")); + + // Check merkle root + if (fCheckMerkleRoot && hashMerkleRoot != BuildMerkleTree()) + return DoS(100, error("CheckBlock() : hashMerkleRoot mismatch")); + + + return true; +} + +bool CBlock::AcceptBlock() +{ + AssertLockHeld(cs_main); + + if (nVersion > CURRENT_VERSION) + return DoS(100, error("AcceptBlock() : reject unknown block version %d", nVersion)); + + // Check for duplicate + uint256 hash = GetHash(); + if (mapBlockIndex.count(hash)) + return error("AcceptBlock() : block already in mapBlockIndex"); + + // Get prev block index + map::iterator mi = mapBlockIndex.find(hashPrevBlock); + if (mi == mapBlockIndex.end()) + return DoS(10, error("AcceptBlock() : prev block not found")); + CBlockIndex* pindexPrev = (*mi).second; + int nHeight = pindexPrev->nHeight+1; + + if (IsProtocolV2(nHeight) && nVersion < 7) + return DoS(100, error("AcceptBlock() : reject too old nVersion = %d", nVersion)); + else if (!IsProtocolV2(nHeight) && nVersion > 6) + return DoS(100, error("AcceptBlock() : reject too new nVersion = %d", nVersion)); + + if (IsProofOfWork() && nHeight > Params().LastPOWBlock()) + return DoS(100, error("AcceptBlock() : reject proof-of-work at height %d", nHeight)); + + // Check coinbase timestamp + if (GetBlockTime() > FutureDrift((int64_t)vtx[0].nTime, nHeight)) + return DoS(50, error("AcceptBlock() : coinbase timestamp is too early")); + + // Check coinstake timestamp + if (IsProofOfStake() && !CheckCoinStakeTimestamp(nHeight, GetBlockTime(), (int64_t)vtx[1].nTime)) + return DoS(50, error("AcceptBlock() : coinstake timestamp violation nTimeBlock=%d nTimeTx=%u", GetBlockTime(), vtx[1].nTime)); + + // Check proof-of-work or proof-of-stake + if (nBits != GetNextTargetRequired(pindexPrev, IsProofOfStake())) + return DoS(100, error("AcceptBlock() : incorrect %s", IsProofOfWork() ? "proof-of-work" : "proof-of-stake")); + + // Check timestamp against prev + if (GetBlockTime() <= pindexPrev->GetPastTimeLimit() || FutureDrift(GetBlockTime(), nHeight) < pindexPrev->GetBlockTime()) + return error("AcceptBlock() : block's timestamp is too early"); + + // Check that all transactions are finalized + BOOST_FOREACH(const CTransaction& tx, vtx) + if (!IsFinalTx(tx, nHeight, GetBlockTime())) + return DoS(10, error("AcceptBlock() : contains a non-final transaction")); + + // Check that the block chain matches the known block chain up to a checkpoint + if (!Checkpoints::CheckHardened(nHeight, hash)) + return DoS(100, error("AcceptBlock() : rejected by hardened checkpoint lock-in at %d", nHeight)); + + uint256 hashProof; + // Verify hash target and signature of coinstake tx + if (IsProofOfStake()) + { + uint256 targetProofOfStake; + if (!CheckProofOfStake(pindexPrev, vtx[1], nBits, hashProof, targetProofOfStake)) + { + return error("AcceptBlock() : check proof-of-stake failed for block %s", hash.ToString()); + } + } + // PoW is checked in CheckBlock() + if (IsProofOfWork()) + { + hashProof = GetPoWHash(); + } + + //bool cpSatisfies = Checkpoints::CheckSync(hash, pindexPrev); + + /*// Check that the block satisfies synchronized checkpoint + if (CheckpointsMode == Checkpoints::STRICT && !cpSatisfies) + return error("AcceptBlock() : rejected by synchronized checkpoint"); + + if (CheckpointsMode == Checkpoints::ADVISORY && !cpSatisfies) + strMiscWarning = _("WARNING: syncronized checkpoint violation detected, but skipped!");*/ + + // Enforce rule that the coinbase starts with serialized block height + CScript expect = CScript() << nHeight; + if (vtx[0].vin[0].scriptSig.size() < expect.size() || + !std::equal(expect.begin(), expect.end(), vtx[0].vin[0].scriptSig.begin())) + return DoS(100, error("AcceptBlock() : block height mismatch in coinbase")); + + // Write block to history file + if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK, CLIENT_VERSION))) + return error("AcceptBlock() : out of disk space"); + unsigned int nFile = -1; + unsigned int nBlockPos = 0; + if (!WriteToDisk(nFile, nBlockPos)) + return error("AcceptBlock() : WriteToDisk failed"); + if (!AddToBlockIndex(nFile, nBlockPos, hashProof)) + return error("AcceptBlock() : AddToBlockIndex failed"); + + // Relay inventory, but don't relay old inventory during initial block download + int nBlockEstimate = Checkpoints::GetTotalBlocksEstimate(); + if (hashBestChain == hash) + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) + pnode->PushInventory(CInv(MSG_BLOCK, hash)); + } + + /*// ppcoin: check pending sync-checkpoint + Checkpoints::AcceptPendingSyncCheckpoint();*/ + + return true; +} + +uint256 CBlockIndex::GetBlockTrust() const +{ + CBigNum bnTarget; + bnTarget.SetCompact(nBits); + + if (bnTarget <= 0) + return 0; + + return ((CBigNum(1)<<256) / (bnTarget+1)).getuint256(); +} + +bool CBlockIndex::IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned int nRequired, unsigned int nToCheck) +{ + unsigned int nFound = 0; + for (unsigned int i = 0; i < nToCheck && nFound < nRequired && pstart != NULL; i++) + { + if (pstart->nVersion >= minVersion) + ++nFound; + pstart = pstart->pprev; + } + return (nFound >= nRequired); +} + +void PushGetBlocks(CNode* pnode, CBlockIndex* pindexBegin, uint256 hashEnd) +{ + // Filter out duplicate requests + if (pindexBegin == pnode->pindexLastGetBlocksBegin && hashEnd == pnode->hashLastGetBlocksEnd) + return; + pnode->pindexLastGetBlocksBegin = pindexBegin; + pnode->hashLastGetBlocksEnd = hashEnd; + + pnode->PushMessage("getblocks", CBlockLocator(pindexBegin), hashEnd); +} + +/*bool static ReserealizeBlockSignature(CBlock* pblock) +{ + if (pblock->IsProofOfWork()) { + pblock->vchBlockSig.clear(); + return true; + } + + return CKey::ReserealizeSignature(pblock->vchBlockSig); +} + +bool static IsCanonicalBlockSignature(CBlock* pblock) +{ + if (pblock->IsProofOfWork()) { + return pblock->vchBlockSig.empty(); + } + + return IsDERSignature(pblock->vchBlockSig, false); +}*/ + +bool ProcessBlock(CNode* pfrom, CBlock* pblock) +{ + AssertLockHeld(cs_main); + + // Check for duplicate + uint256 hash = pblock->GetHash(); + if (mapBlockIndex.count(hash)) + return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString()); + if (mapOrphanBlocks.count(hash)) + return error("ProcessBlock() : already have block (orphan) %s", hash.ToString()); + + // ppcoin: check proof-of-stake + // Limited duplicity on stake: prevents block flood attack + // Duplicate stake allowed only when there is orphan child block + if (!fReindex && !fImporting && pblock->IsProofOfStake() && setStakeSeen.count(pblock->GetProofOfStake()) && !mapOrphanBlocksByPrev.count(hash)) + return error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for block %s", pblock->GetProofOfStake().first.ToString(), pblock->GetProofOfStake().second, hash.ToString()); + + if (pblock->hashPrevBlock != hashBestChain) + { + // Extra checks to prevent "fill up memory by spamming with bogus blocks" + const CBlockIndex* pcheckpoint = Checkpoints::AutoSelectSyncCheckpoint(); + int64_t deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime; + if (deltaTime < 0) + { + if (pfrom) + pfrom->Misbehaving(1); + return error("ProcessBlock() : block with timestamp before last checkpoint"); + } + } + + // Preliminary checks + if (!pblock->CheckBlock()) + return error("ProcessBlock() : CheckBlock FAILED"); + + // If we don't already have its previous block, shunt it off to holding area until we get it + if (!mapBlockIndex.count(pblock->hashPrevBlock)) + { + LogPrintf("ProcessBlock: ORPHAN BLOCK %lu, prev=%s\n", (unsigned long)mapOrphanBlocks.size(), pblock->hashPrevBlock.ToString()); + + // Accept orphans as long as there is a node to request its parents from + if (pfrom) { + // ppcoin: check proof-of-stake + if (pblock->IsProofOfStake()) + { + // Limited duplicity on stake: prevents block flood attack + // Duplicate stake allowed only when there is orphan child block + if (setStakeSeenOrphan.count(pblock->GetProofOfStake()) && !mapOrphanBlocksByPrev.count(hash)) + return error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for orphan block %s", pblock->GetProofOfStake().first.ToString(), pblock->GetProofOfStake().second, hash.ToString()); + } + PruneOrphanBlocks(); + COrphanBlock* pblock2 = new COrphanBlock(); + { + CDataStream ss(SER_DISK, CLIENT_VERSION); + ss << *pblock; + pblock2->vchBlock = std::vector(ss.begin(), ss.end()); + } + pblock2->hashBlock = hash; + pblock2->hashPrev = pblock->hashPrevBlock; + pblock2->stake = pblock->GetProofOfStake(); + nOrphanBlocksSize += pblock2->vchBlock.size(); + mapOrphanBlocks.insert(make_pair(hash, pblock2)); + mapOrphanBlocksByPrev.insert(make_pair(pblock2->hashPrev, pblock2)); + if (pblock->IsProofOfStake()) + setStakeSeenOrphan.insert(pblock->GetProofOfStake()); + + // Ask this guy to fill in what we're missing + PushGetBlocks(pfrom, pindexBest, GetOrphanRoot(hash)); + // ppcoin: getblocks may not obtain the ancestor block rejected + // earlier by duplicate-stake check so we ask for it again directly + if (!IsInitialBlockDownload()) + pfrom->AskFor(CInv(MSG_BLOCK, WantedByOrphan(pblock2))); + } + return true; + } + + // Store to disk + if (!pblock->AcceptBlock()) + return error("ProcessBlock() : AcceptBlock FAILED"); + + // Recursively process any orphan blocks that depended on this one + vector vWorkQueue; + vWorkQueue.push_back(hash); + for (unsigned int i = 0; i < vWorkQueue.size(); i++) + { + uint256 hashPrev = vWorkQueue[i]; + for (multimap::iterator mi = mapOrphanBlocksByPrev.lower_bound(hashPrev); + mi != mapOrphanBlocksByPrev.upper_bound(hashPrev); + ++mi) + { + CBlock block; + { + CDataStream ss(mi->second->vchBlock, SER_DISK, CLIENT_VERSION); + ss >> block; + } + block.BuildMerkleTree(); + if (block.AcceptBlock()) + vWorkQueue.push_back(mi->second->hashBlock); + mapOrphanBlocks.erase(mi->second->hashBlock); + setStakeSeenOrphan.erase(block.GetProofOfStake()); + nOrphanBlocksSize -= mi->second->vchBlock.size(); + delete mi->second; + } + mapOrphanBlocksByPrev.erase(hashPrev); + } + + LogPrintf("ProcessBlock: ACCEPTED\n"); + + return true; +} + +#ifdef ENABLE_WALLET +// cream: attempt to generate suitable proof-of-stake +bool CBlock::SignBlock(CWallet& wallet, int64_t nFees) +{ + // if we are trying to sign + // something except proof-of-stake block template + if (!vtx[0].vout[0].IsEmpty()) + return false; + + // if we are trying to sign + // a complete proof-of-stake block + if (IsProofOfStake()) + return true; + + static int64_t nLastCoinStakeSearchTime = GetAdjustedTime(); // startup timestamp + + CKey key; + CTransaction txCoinStake; + if (IsProtocolV2(nBestHeight+1)) + txCoinStake.nTime &= ~STAKE_TIMESTAMP_MASK; + + int64_t nSearchTime = txCoinStake.nTime; // search to current time + + if (nSearchTime > nLastCoinStakeSearchTime) + { + int64_t nSearchInterval = IsProtocolV2(nBestHeight+1) ? 1 : nSearchTime - nLastCoinStakeSearchTime; + if (wallet.CreateCoinStake(wallet, nBits, nSearchInterval, nFees, txCoinStake, key)) + { + if (txCoinStake.nTime >= pindexBest->GetPastTimeLimit()+1) + { + // make sure coinstake would meet timestamp protocol + // as it would be the same as the block timestamp + vtx[0].nTime = nTime = txCoinStake.nTime; + + // we have to make sure that we have no future timestamps in + // our transactions set + for (vector::iterator it = vtx.begin(); it != vtx.end();) + if (it->nTime > nTime) { it = vtx.erase(it); } else { ++it; } + + vtx.insert(vtx.begin() + 1, txCoinStake); + hashMerkleRoot = BuildMerkleTree(); + + // append a signature to our block + return key.Sign(GetHash(), vchBlockSig); + } + } + nLastCoinStakeSearchInterval = nSearchTime - nLastCoinStakeSearchTime; + nLastCoinStakeSearchTime = nSearchTime; + } + + return false; +} +#endif + +bool CBlock::CheckBlockSignature() const +{ + if (IsProofOfWork()) + return vchBlockSig.empty(); + + if (vchBlockSig.empty()) + return false; + + vector vSolutions; + txnouttype whichType; + + const CTxOut& txout = vtx[1].vout[1]; + + if (!Solver(txout.scriptPubKey, whichType, vSolutions)) + return false; + + if (whichType == TX_PUBKEY) + { + valtype& vchPubKey = vSolutions[0]; + return CPubKey(vchPubKey).Verify(GetHash(), vchBlockSig); + } + + return false; +} + +bool CheckDiskSpace(uint64_t nAdditionalBytes) +{ + uint64_t nFreeBytesAvailable = filesystem::space(GetDataDir()).available; + + // Check for nMinDiskSpace bytes (currently 50MB) + if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes) + { + string strMessage = _("Error: Disk space is low!"); + strMiscWarning = strMessage; + LogPrintf("*** %s\n", strMessage); + uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_ERROR); + StartShutdown(); + return false; + } + return true; +} + +static filesystem::path BlockFilePath(unsigned int nFile) +{ + string strBlockFn = strprintf("blk%04u.dat", nFile); + return GetDataDir() / strBlockFn; +} + +FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode) +{ + if ((nFile < 1) || (nFile == (unsigned int) -1)) + return NULL; + FILE* file = fopen(BlockFilePath(nFile).string().c_str(), pszMode); + if (!file) + return NULL; + if (nBlockPos != 0 && !strchr(pszMode, 'a') && !strchr(pszMode, 'w')) + { + if (fseek(file, nBlockPos, SEEK_SET) != 0) + { + fclose(file); + return NULL; + } + } + return file; +} + +static unsigned int nCurrentBlockFile = 1; + +FILE* AppendBlockFile(unsigned int& nFileRet) +{ + nFileRet = 0; + while (true) + { + FILE* file = OpenBlockFile(nCurrentBlockFile, 0, "ab"); + if (!file) + return NULL; + if (fseek(file, 0, SEEK_END) != 0) + return NULL; + // FAT32 file size max 4GB, fseek and ftell max 2GB, so we must stay under 2GB + if (ftell(file) < (long)(0x7F000000 - MAX_SIZE)) + { + nFileRet = nCurrentBlockFile; + return file; + } + fclose(file); + nCurrentBlockFile++; + } +} + +bool LoadBlockIndex(bool fAllowNew) +{ + LOCK(cs_main); + + if (TestNet()) + { + nStakeMinAge = 1 * 60 * 60; // test net min age is 1 hour + nCoinbaseMaturity = 10; // test maturity is 10 blocks + } + + // + // Load block index + // + CTxDB txdb("cr+"); + if (!txdb.LoadBlockIndex()) + return false; + + // + // Init with genesis block + // + if (mapBlockIndex.empty()) + { + if (!fAllowNew) + return false; + + CBlock &block = const_cast(Params().GenesisBlock()); + // Start new block file + unsigned int nFile; + unsigned int nBlockPos; + if (!block.WriteToDisk(nFile, nBlockPos)) + return error("LoadBlockIndex() : writing genesis block to disk failed"); + if (!block.AddToBlockIndex(nFile, nBlockPos, Params().HashGenesisBlock())) + return error("LoadBlockIndex() : genesis block not accepted"); + } + + return true; +} + + + +void PrintBlockTree() +{ + AssertLockHeld(cs_main); + // pre-compute tree structure + map > mapNext; + for (map::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi) + { + CBlockIndex* pindex = (*mi).second; + mapNext[pindex->pprev].push_back(pindex); + // test + //while (rand() % 3 == 0) + // mapNext[pindex->pprev].push_back(pindex); + } + + vector > vStack; + vStack.push_back(make_pair(0, pindexGenesisBlock)); + + int nPrevCol = 0; + while (!vStack.empty()) + { + int nCol = vStack.back().first; + CBlockIndex* pindex = vStack.back().second; + vStack.pop_back(); + + // print split or gap + if (nCol > nPrevCol) + { + for (int i = 0; i < nCol-1; i++) + LogPrintf("| "); + LogPrintf("|\\\n"); + } + else if (nCol < nPrevCol) + { + for (int i = 0; i < nCol; i++) + LogPrintf("| "); + LogPrintf("|\n"); + } + nPrevCol = nCol; + + // print columns + for (int i = 0; i < nCol; i++) + LogPrintf("| "); + + // print item + CBlock block; + block.ReadFromDisk(pindex); + LogPrintf("%d (%u,%u) %s %08x %s mint %7s tx %u", + pindex->nHeight, + pindex->nFile, + pindex->nBlockPos, + block.GetHash().ToString(), + block.nBits, + DateTimeStrFormat("%x %H:%M:%S", block.GetBlockTime()), + FormatMoney(pindex->nMint), + block.vtx.size()); + + // put the main time-chain first + vector& vNext = mapNext[pindex]; + for (unsigned int i = 0; i < vNext.size(); i++) + { + if (vNext[i]->pnext) + { + swap(vNext[0], vNext[i]); + break; + } + } + + // iterate children + for (unsigned int i = 0; i < vNext.size(); i++) + vStack.push_back(make_pair(nCol+i, vNext[i])); + } +} + +bool LoadExternalBlockFile(FILE* fileIn) +{ + int64_t nStart = GetTimeMillis(); + + int nLoaded = 0; + { + try { + CAutoFile blkdat(fileIn, SER_DISK, CLIENT_VERSION); + unsigned int nPos = 0; + while (nPos != (unsigned int)-1 && blkdat.good()) + { + boost::this_thread::interruption_point(); + unsigned char pchData[65536]; + do { + fseek(blkdat, nPos, SEEK_SET); + int nRead = fread(pchData, 1, sizeof(pchData), blkdat); + if (nRead <= 8) + { + nPos = (unsigned int)-1; + break; + } + void* nFind = memchr(pchData, Params().MessageStart()[0], nRead+1-MESSAGE_START_SIZE); + if (nFind) + { + if (memcmp(nFind, Params().MessageStart(), MESSAGE_START_SIZE)==0) + { + nPos += ((unsigned char*)nFind - pchData) + MESSAGE_START_SIZE; + break; + } + nPos += ((unsigned char*)nFind - pchData) + 1; + } + else + nPos += sizeof(pchData) - MESSAGE_START_SIZE + 1; + boost::this_thread::interruption_point(); + } while(true); + if (nPos == (unsigned int)-1) + break; + fseek(blkdat, nPos, SEEK_SET); + unsigned int nSize; + blkdat >> nSize; + if (nSize > 0 && nSize <= MAX_BLOCK_SIZE) + { + CBlock block; + blkdat >> block; + LOCK(cs_main); + if (ProcessBlock(NULL,&block)) + { + nLoaded++; + nPos += 4 + nSize; + } + } + } + } + catch (std::exception &e) { + LogPrintf("%s() : Deserialize or I/O error caught during load\n", + __PRETTY_FUNCTION__); + } + } + LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, GetTimeMillis() - nStart); + return nLoaded > 0; +} + +struct CImportingNow +{ + CImportingNow() { + assert(fImporting == false); + fImporting = true; + } + + ~CImportingNow() { + assert(fImporting == true); + fImporting = false; + } +}; + +void ThreadImport(std::vector vImportFiles) +{ + RenameThread("Cream-loadblk"); + + CImportingNow imp; + + // -loadblock= + BOOST_FOREACH(boost::filesystem::path &path, vImportFiles) { + FILE *file = fopen(path.string().c_str(), "rb"); + if (file) + LoadExternalBlockFile(file); + } + + // hardcoded $DATADIR/bootstrap.dat + filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat"; + if (filesystem::exists(pathBootstrap)) { + FILE *file = fopen(pathBootstrap.string().c_str(), "rb"); + if (file) { + filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old"; + LoadExternalBlockFile(file); + RenameOver(pathBootstrap, pathBootstrapOld); + } + } +} + + + + + + + + + + +////////////////////////////////////////////////////////////////////////////// +// +// CAlert +// + +extern map mapAlerts; +extern CCriticalSection cs_mapAlerts; + +string GetWarnings(string strFor) +{ + string strStatusBar; + string strRPC; + + if (GetBoolArg("-testsafemode", false)) + strRPC = "test"; + + if (!CLIENT_VERSION_IS_RELEASE) + strStatusBar = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"); + + // Misc warnings like out of disk space and clock is wrong + if (strMiscWarning != "") + { + strStatusBar = strMiscWarning; + } + + if (strFor == "statusbar") + return strStatusBar; + else if (strFor == "rpc") + return strRPC; + assert(!"GetWarnings() : invalid parameter"); + return "error"; +} + + + + + + + + +////////////////////////////////////////////////////////////////////////////// +// +// Messages +// + + +bool static AlreadyHave(CTxDB& txdb, const CInv& inv) +{ + switch (inv.type) + { + case MSG_TX: + { + bool txInMap = false; + txInMap = mempool.exists(inv.hash); + return txInMap || + mapOrphanTransactions.count(inv.hash) || + txdb.ContainsTx(inv.hash); + } + + case MSG_BLOCK: + return mapBlockIndex.count(inv.hash) || + mapOrphanBlocks.count(inv.hash); + case MSG_TXLOCK_REQUEST: + return mapTxLockReq.count(inv.hash) || + mapTxLockReqRejected.count(inv.hash); + case MSG_TXLOCK_VOTE: + return mapTxLockVote.count(inv.hash); + case MSG_SPORK: + return mapSporks.count(inv.hash); + case MSG_MASTERNODE_WINNER: + return mapSeenMasternodeVotes.count(inv.hash); + } + // Don't know what it is, just say we already got one + return true; +} + + + + +void static ProcessGetData(CNode* pfrom) +{ + std::deque::iterator it = pfrom->vRecvGetData.begin(); + + vector vNotFound; + + LOCK(cs_main); + + while (it != pfrom->vRecvGetData.end()) { + // Don't bother if send buffer is too full to respond anyway + if (pfrom->nSendSize >= SendBufferSize()) + break; + + const CInv &inv = *it; + { + boost::this_thread::interruption_point(); + it++; + + if (inv.type == MSG_BLOCK) + { + // Send block from disk + map::iterator mi = mapBlockIndex.find(inv.hash); + if (mi != mapBlockIndex.end()) + { + CBlock block; + block.ReadFromDisk((*mi).second); + pfrom->PushMessage("block", block); + + // Trigger them to send a getblocks request for the next batch of inventory + if (inv.hash == pfrom->hashContinue) + { + // Bypass PushInventory, this must send even if redundant, + // and we want it right after the last block so they don't + // wait for other stuff first. + vector vInv; + vInv.push_back(CInv(MSG_BLOCK, hashBestChain)); + pfrom->PushMessage("inv", vInv); + pfrom->hashContinue = 0; + } + } + } + else if (inv.IsKnownType()) + { + // Send stream from relay memory + bool pushed = false; + { + LOCK(cs_mapRelay); + map::iterator mi = mapRelay.find(inv); + if (mi != mapRelay.end()) { + pfrom->PushMessage(inv.GetCommand(), (*mi).second); + pushed = true; + } + } + if (!pushed && inv.type == MSG_TX) { + if(mapluxsendBroadcastTxes.count(inv.hash)){ + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss.reserve(1000); + ss << + mapluxsendBroadcastTxes[inv.hash].tx << + mapluxsendBroadcastTxes[inv.hash].vin << + mapluxsendBroadcastTxes[inv.hash].vchSig << + mapluxsendBroadcastTxes[inv.hash].sigTime; + + pfrom->PushMessage("dstx", ss); + pushed = true; + } else { + CTransaction tx; + if (mempool.lookup(inv.hash, tx)) { + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss.reserve(1000); + ss << tx; + pfrom->PushMessage("tx", ss); + pushed = true; + } + } + } + if (!pushed && inv.type == MSG_TXLOCK_VOTE) { + if(mapTxLockVote.count(inv.hash)){ + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss.reserve(1000); + ss << mapTxLockVote[inv.hash]; + pfrom->PushMessage("txlvote", ss); + pushed = true; + } + } + if (!pushed && inv.type == MSG_TXLOCK_REQUEST) { + if(mapTxLockReq.count(inv.hash)){ + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss.reserve(1000); + ss << mapTxLockReq[inv.hash]; + pfrom->PushMessage("txlreq", ss); + pushed = true; + } + } + if (!pushed && inv.type == MSG_SPORK) { + if(mapSporks.count(inv.hash)){ + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss.reserve(1000); + ss << mapSporks[inv.hash]; + pfrom->PushMessage("spork", ss); + pushed = true; + } + } + if (!pushed && inv.type == MSG_MASTERNODE_WINNER) { + if(mapSeenMasternodeVotes.count(inv.hash)){ + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + int a = 0; + ss.reserve(1000); + ss << mapSeenMasternodeVotes[inv.hash] << a; + pfrom->PushMessage("mnw", ss); + pushed = true; + } + } + if (!pushed) { + vNotFound.push_back(inv); + } + } + + // Track requests for our stuff. + g_signals.Inventory(inv.hash); + + if (inv.type == MSG_BLOCK /* || inv.type == MSG_FILTERED_BLOCK */) + break; + } + } + + pfrom->vRecvGetData.erase(pfrom->vRecvGetData.begin(), it); + + if (!vNotFound.empty()) { + // Let the peer know that we didn't find what it asked for, so it doesn't + // have to wait around forever. Currently only SPV clients actually care + // about this message: it's needed when they are recursively walking the + // dependencies of relevant unconfirmed transactions. SPV clients want to + // do that because they want to know about (and store and rebroadcast and + // risk analyze) the dependencies of transactions relevant to them, without + // having to download the entire memory pool. + pfrom->PushMessage("notfound", vNotFound); + } +} + +bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived) +{ + RandAddSeedPerfmon(); + LogPrint("net", "received: %s (%u bytes)\n", strCommand, vRecv.size()); + if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) + { + LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); + return true; + } + + if (strCommand == "version") + { + // Each connection can only send one version message + if (pfrom->nVersion != 0) + { + pfrom->Misbehaving(1); + return false; + } + + int64_t nTime; + CAddress addrMe; + CAddress addrFrom; + uint64_t nNonce = 1; + vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; + if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) + { + // disconnect from peers older than this proto version + LogPrintf("partner %s using obsolete version %i; disconnecting\n", pfrom->addr.ToString(), pfrom->nVersion); + pfrom->fDisconnect = true; + return false; + } + + if (pfrom->nVersion == 10300) + pfrom->nVersion = 300; + if (!vRecv.empty()) + vRecv >> addrFrom >> nNonce; + if (!vRecv.empty()) + vRecv >> pfrom->strSubVer; + if (!vRecv.empty()) + vRecv >> pfrom->nStartingHeight; + + pfrom->cleanSubVer = SanitizeString(pfrom->strSubVer); + + // Disconnect if we connected to ourself + if (nNonce == nLocalHostNonce && nNonce > 1) + { + LogPrintf("connected to self at %s, disconnecting\n", pfrom->addr.ToString()); + pfrom->fDisconnect = true; + return true; + } + + pfrom->addrLocal = addrMe; + if (pfrom->fInbound && addrMe.IsRoutable()) + { + SeenLocal(addrMe); + } + + // Be shy and don't send version until we hear + if (pfrom->fInbound) + pfrom->PushVersion(); + + pfrom->fClient = !(pfrom->nServices & NODE_NETWORK); + + // Change version + pfrom->PushMessage("verack"); + pfrom->ssSend.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); + + if (!pfrom->fInbound) + { + // Advertise our address + if (!fNoListen && !IsInitialBlockDownload()) + { + CAddress addr = GetLocalAddress(&pfrom->addr); + if (addr.IsRoutable()) + { + pfrom->PushAddress(addr); + } else if (IsPeerAddrLocalGood(pfrom)) { + addr.SetIP(pfrom->addrLocal); + pfrom->PushAddress(addr); + } + } + + // Get recent addresses + if (pfrom->fOneShot || pfrom->nVersion >= CADDR_TIME_VERSION || addrman.size() < 1000) + { + pfrom->PushMessage("getaddr"); + pfrom->fGetAddr = true; + } + addrman.Good(pfrom->addr); + } else { + if (((CNetAddr)pfrom->addr) == (CNetAddr)addrFrom) + { + addrman.Add(addrFrom, addrFrom); + addrman.Good(addrFrom); + } + } + + /*// Relay alerts + { + LOCK(cs_mapAlerts); + BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts) + item.second.RelayTo(pfrom); + } + + // Relay sync-checkpoint + { + LOCK(Checkpoints::cs_hashSyncCheckpoint); + if (!Checkpoints::checkpointMessage.IsNull()) + Checkpoints::checkpointMessage.RelayTo(pfrom); + }*/ + + pfrom->fSuccessfullyConnected = true; + + LogPrintf("receive version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString(), addrFrom.ToString(), pfrom->addr.ToString()); + + //int64_t nTimeOffset = nTime - GetTime(); + //pfrom->nTimeOffset = nTimeOffset; + if (GetBoolArg("-synctime", true)) + //AddTimeData(pfrom->addr, nTimeOffset); + AddTimeData(pfrom->addr, nTime); + } + + + else if (pfrom->nVersion == 0) + { + // Must have a version message before anything else + pfrom->Misbehaving(1); + return false; + } + + + else if (strCommand == "verack") + { + pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); + } + + + else if (strCommand == "addr") + { + vector vAddr; + vRecv >> vAddr; + + // Don't want addr from older versions unless seeding + if (pfrom->nVersion < CADDR_TIME_VERSION && addrman.size() > 1000) + return true; + if (vAddr.size() > 1000) + { + pfrom->Misbehaving(20); + return error("message addr size() = %u", vAddr.size()); + } + + // Store the new addresses + vector vAddrOk; + int64_t nNow = GetAdjustedTime(); + int64_t nSince = nNow - 10 * 60; + BOOST_FOREACH(CAddress& addr, vAddr) + { + boost::this_thread::interruption_point(); + + if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60) + addr.nTime = nNow - 5 * 24 * 60 * 60; + pfrom->AddAddressKnown(addr); + bool fReachable = IsReachable(addr); + if (addr.nTime > nSince && !pfrom->fGetAddr && vAddr.size() <= 10 && addr.IsRoutable()) + { + // Relay to a limited number of other nodes + { + LOCK(cs_vNodes); + // Use deterministic randomness to send to the same nodes for 24 hours + // at a time so the setAddrKnowns of the chosen nodes prevent repeats + static uint256 hashSalt; + if (hashSalt == 0) + hashSalt = GetRandHash(); + uint64_t hashAddr = addr.GetHash(); + uint256 hashRand = hashSalt ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/(24*60*60)); + hashRand = Hash(BEGIN(hashRand), END(hashRand)); + multimap mapMix; + BOOST_FOREACH(CNode* pnode, vNodes) + { + if (pnode->nVersion < CADDR_TIME_VERSION) + continue; + unsigned int nPointer; + memcpy(&nPointer, &pnode, sizeof(nPointer)); + uint256 hashKey = hashRand ^ nPointer; + hashKey = Hash(BEGIN(hashKey), END(hashKey)); + mapMix.insert(make_pair(hashKey, pnode)); + } + int nRelayNodes = fReachable ? 2 : 1; // limited relaying of addresses outside our network(s) + for (multimap::iterator mi = mapMix.begin(); mi != mapMix.end() && nRelayNodes-- > 0; ++mi) + ((*mi).second)->PushAddress(addr); + } + } + // Do not store addresses outside our network + if (fReachable) + vAddrOk.push_back(addr); + } + addrman.Add(vAddrOk, pfrom->addr, 2 * 60 * 60); + if (vAddr.size() < 1000) + pfrom->fGetAddr = false; + if (pfrom->fOneShot) + pfrom->fDisconnect = true; + } + + else if (strCommand == "inv") + { + vector vInv; + vRecv >> vInv; + if (vInv.size() > MAX_INV_SZ) + { + pfrom->Misbehaving(20); + return error("message inv size() = %u", vInv.size()); + } + + // find last block in inv vector + unsigned int nLastBlock = (unsigned int)(-1); + for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) { + if (vInv[vInv.size() - 1 - nInv].type == MSG_BLOCK) { + nLastBlock = vInv.size() - 1 - nInv; + break; + } + } + + LOCK(cs_main); + CTxDB txdb("r"); + + for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) + { + const CInv &inv = vInv[nInv]; + + boost::this_thread::interruption_point(); + pfrom->AddInventoryKnown(inv); + + bool fAlreadyHave = AlreadyHave(txdb, inv); + LogPrint("net", " got inventory: %s %s\n", inv.ToString(), fAlreadyHave ? "have" : "new"); + + if (!fAlreadyHave) { + if (!fImporting) + pfrom->AskFor(inv); + } else if (inv.type == MSG_BLOCK && mapOrphanBlocks.count(inv.hash)) { + PushGetBlocks(pfrom, pindexBest, GetOrphanRoot(inv.hash)); + } else if (nInv == nLastBlock) { + // In case we are on a very long side-chain, it is possible that we already have + // the last block in an inv bundle sent in response to getblocks. Try to detect + // this situation and push another getblocks to continue. + PushGetBlocks(pfrom, mapBlockIndex[inv.hash], uint256(0)); + if (fDebug) + LogPrintf("force request: %s\n", inv.ToString()); + } + + // Track requests for our stuff + g_signals.Inventory(inv.hash); + } + } + + + else if (strCommand == "getdata") + { + vector vInv; + vRecv >> vInv; + if (vInv.size() > MAX_INV_SZ) + { + pfrom->Misbehaving(20); + return error("message getdata size() = %u", vInv.size()); + } + + if (fDebug || (vInv.size() != 1)) + LogPrint("net", "received getdata (%u invsz)\n", vInv.size()); + + if ((fDebug && vInv.size() > 0) || (vInv.size() == 1)) + LogPrint("net", "received getdata for: %s\n", vInv[0].ToString()); + + pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end()); + ProcessGetData(pfrom); + } + + + else if (strCommand == "getblocks") + { + CBlockLocator locator; + uint256 hashStop; + vRecv >> locator >> hashStop; + + LOCK(cs_main); + + // Find the last block the caller has in the main chain + CBlockIndex* pindex = locator.GetBlockIndex(); + + // Send the rest of the chain + if (pindex) + pindex = pindex->pnext; + int nLimit = 500; + LogPrint("net", "getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString(), nLimit); + for (; pindex; pindex = pindex->pnext) + { + if (pindex->GetBlockHash() == hashStop) + { + LogPrint("net", " getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); + break; + } + pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); + if (--nLimit <= 0) + { + // When this block is requested, we'll send an inv that'll make them + // getblocks the next batch of inventory. + LogPrint("net", " getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); + pfrom->hashContinue = pindex->GetBlockHash(); + break; + } + } + } + /*else if (strCommand == "checkpoint") + { + CSyncCheckpoint checkpoint; + vRecv >> checkpoint; + + if (checkpoint.ProcessSyncCheckpoint(pfrom)) + { + // Relay + pfrom->hashCheckpointKnown = checkpoint.hashCheckpoint; + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + checkpoint.RelayTo(pnode); + } + }*/ + + else if (strCommand == "getheaders") + { + CBlockLocator locator; + uint256 hashStop; + vRecv >> locator >> hashStop; + + LOCK(cs_main); + + CBlockIndex* pindex = NULL; + if (locator.IsNull()) + { + // If locator is null, return the hashStop block + map::iterator mi = mapBlockIndex.find(hashStop); + if (mi == mapBlockIndex.end()) + return true; + pindex = (*mi).second; + } + else + { + // Find the last block the caller has in the main chain + pindex = locator.GetBlockIndex(); + if (pindex) + pindex = pindex->pnext; + } + + vector vHeaders; + int nLimit = 2000; + LogPrint("net", "getheaders %d to %s\n", (pindex ? pindex->nHeight : -1), hashStop.ToString()); + for (; pindex; pindex = pindex->pnext) + { + vHeaders.push_back(pindex->GetBlockHeader()); + if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop) + break; + } + pfrom->PushMessage("headers", vHeaders); + } + + + else if (strCommand == "tx") + { + vector vWorkQueue; + vector vEraseQueue; + CTransaction tx; + vRecv >> tx; + + CInv inv(MSG_TX, tx.GetHash()); + pfrom->AddInventoryKnown(inv); + + LOCK(cs_main); + + bool fMissingInputs = false; + + mapAlreadyAskedFor.erase(inv); + + if (AcceptToMemoryPool(mempool, tx, true, &fMissingInputs)) + { + RelayTransaction(tx, inv.hash); + vWorkQueue.push_back(inv.hash); + vEraseQueue.push_back(inv.hash); + + // Recursively process any orphan transactions that depended on this one + for (unsigned int i = 0; i < vWorkQueue.size(); i++) + { + map >::iterator itByPrev = mapOrphanTransactionsByPrev.find(vWorkQueue[i]); + if (itByPrev == mapOrphanTransactionsByPrev.end()) + continue; + for (set::iterator mi = itByPrev->second.begin(); + mi != itByPrev->second.end(); + ++mi) + { + const uint256& orphanTxHash = *mi; + CTransaction& orphanTx = mapOrphanTransactions[orphanTxHash]; + bool fMissingInputs2 = false; + + if (AcceptToMemoryPool(mempool, orphanTx, true, &fMissingInputs2)) + { + LogPrint("mempool", " accepted orphan tx %s\n", orphanTxHash.ToString()); + RelayTransaction(orphanTx, orphanTxHash); + vWorkQueue.push_back(orphanTxHash); + vEraseQueue.push_back(orphanTxHash); + } + else if (!fMissingInputs2) + { + // invalid or too-little-fee orphan + vEraseQueue.push_back(orphanTxHash); + LogPrint("mempool", " removed orphan tx %s\n", orphanTxHash.ToString()); + } + } + } + + BOOST_FOREACH(uint256 hash, vEraseQueue) + EraseOrphanTx(hash); + } + else if (fMissingInputs) + { + AddOrphanTx(tx); + + // DoS prevention: do not allow mapOrphanTransactions to grow unbounded + unsigned int nEvicted = LimitOrphanTxSize(MAX_ORPHAN_TRANSACTIONS); + if (nEvicted > 0) + LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted); + } + if (tx.nDoS) pfrom->Misbehaving(tx.nDoS); + } + + + else if (strCommand == "block") + { + CBlock block; + vRecv >> block; + uint256 hashBlock = block.GetHash(); + + LogPrint("net", "received block %s\n", hashBlock.ToString()); + + CInv inv(MSG_BLOCK, hashBlock); + pfrom->AddInventoryKnown(inv); + + LOCK(cs_main); + + if (ProcessBlock(pfrom, &block)) + mapAlreadyAskedFor.erase(inv); + if (block.nDoS) pfrom->Misbehaving(block.nDoS); + + if (fSecMsgEnabled) + SecureMsgScanBlock(block); + } + + else if (strCommand == "getaddr") + { + // Don't return addresses older than nCutOff timestamp + int64_t nCutOff = GetTime() - (nNodeLifespan * 24 * 60 * 60); + pfrom->vAddrToSend.clear(); + vector vAddr = addrman.GetAddr(); + BOOST_FOREACH(const CAddress &addr, vAddr) + if(addr.nTime > nCutOff) + pfrom->PushAddress(addr); + } + else if (strCommand == "mempool") + { + LOCK(cs_main); + + std::vector vtxid; + mempool.queryHashes(vtxid); + vector vInv; + for (unsigned int i = 0; i < vtxid.size(); i++) { + CInv inv(MSG_TX, vtxid[i]); + vInv.push_back(inv); + if (i == (MAX_INV_SZ - 1)) + break; + } + if (vInv.size() > 0) + pfrom->PushMessage("inv", vInv); + } + + + else if (strCommand == "ping") + { + if (pfrom->nVersion > BIP0031_VERSION) + { + uint64_t nonce = 0; + vRecv >> nonce; + // Echo the message back with the nonce. This allows for two useful features: + // + // 1) A remote node can quickly check if the connection is operational + // 2) Remote nodes can measure the latency of the network thread. If this node + // is overloaded it won't respond to pings quickly and the remote node can + // avoid sending us more work, like chain download requests. + // + // The nonce stops the remote getting confused between different pings: without + // it, if the remote node sends a ping once per second and this node takes 5 + // seconds to respond to each, the 5th ping the remote sends would appear to + // return very quickly. + pfrom->PushMessage("pong", nonce); + } + } + + + else if (strCommand == "pong") + { + int64_t pingUsecEnd = nTimeReceived; + uint64_t nonce = 0; + size_t nAvail = vRecv.in_avail(); + bool bPingFinished = false; + std::string sProblem; + + if (nAvail >= sizeof(nonce)) { + vRecv >> nonce; + + // Only process pong message if there is an outstanding ping (old ping without nonce should never pong) + if (pfrom->nPingNonceSent != 0) { + if (nonce == pfrom->nPingNonceSent) { + // Matching pong received, this ping is no longer outstanding + bPingFinished = true; + int64_t pingUsecTime = pingUsecEnd - pfrom->nPingUsecStart; + if (pingUsecTime > 0) { + // Successful ping time measurement, replace previous + pfrom->nPingUsecTime = pingUsecTime; + } else { + // This should never happen + sProblem = "Timing mishap"; + } + } else { + // Nonce mismatches are normal when pings are overlapping + sProblem = "Nonce mismatch"; + if (nonce == 0) { + // This is most likely a bug in another implementation somewhere, cancel this ping + bPingFinished = true; + sProblem = "Nonce zero"; + } + } + } else { + sProblem = "Unsolicited pong without ping"; + } + } else { + // This is most likely a bug in another implementation somewhere, cancel this ping + bPingFinished = true; + sProblem = "Short payload"; + } + + if (!(sProblem.empty())) { + LogPrint("net", "pong %s %s: %s, %x expected, %x received, %zu bytes\n" + , pfrom->addr.ToString() + , pfrom->strSubVer + , sProblem + , pfrom->nPingNonceSent + , nonce + , nAvail); + } + if (bPingFinished) { + pfrom->nPingNonceSent = 0; + } + } + + + else if (strCommand == "alert") + { + CAlert alert; + vRecv >> alert; + + uint256 alertHash = alert.GetHash(); + if (pfrom->setKnown.count(alertHash) == 0) + { + if (alert.ProcessAlert()) + { + // Relay + pfrom->setKnown.insert(alertHash); + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + alert.RelayTo(pnode); + } + } + else { + // Small DoS penalty so peers that send us lots of + // duplicate/expired/invalid-signature/whatever alerts + // eventually get banned. + // This isn't a Misbehaving(100) (immediate ban) because the + // peer might be an older or different implementation with + // a different signature key, etc. + pfrom->Misbehaving(10); + } + } + } + + + else + { + if (fSecMsgEnabled) + SecureMsgReceiveData(pfrom, strCommand, vRecv); + + ProcessMessageluxsend(pfrom, strCommand, vRecv); + ProcessMessageMasternode(pfrom, strCommand, vRecv); + ProcessMessageInstantX(pfrom, strCommand, vRecv); + ProcessSpork(pfrom, strCommand, vRecv); + + // Ignore unknown commands for extensibility + } + + + // Update the last seen time for this node's address + if (pfrom->fNetworkNode) + if (strCommand == "version" || strCommand == "addr" || strCommand == "inv" || strCommand == "getdata" || strCommand == "ping") + AddressCurrentlyConnected(pfrom->addr); + + + return true; +} + +// requires LOCK(cs_vRecvMsg) +bool ProcessMessages(CNode* pfrom) +{ + //if (fDebug) + // LogPrintf("ProcessMessages(%zu messages)\n", pfrom->vRecvMsg.size()); + + // + // Message format + // (4) message start + // (12) command + // (4) size + // (4) checksum + // (x) data + // + bool fOk = true; + + if (!pfrom->vRecvGetData.empty()) + ProcessGetData(pfrom); + + // this maintains the order of responses + if (!pfrom->vRecvGetData.empty()) return fOk; + + std::deque::iterator it = pfrom->vRecvMsg.begin(); + while (!pfrom->fDisconnect && it != pfrom->vRecvMsg.end()) { + // Don't bother if send buffer is too full to respond anyway + if (pfrom->nSendSize >= SendBufferSize()) + break; + + // get next message + CNetMessage& msg = *it; + + //if (fDebug) + // LogPrintf("ProcessMessages(message %u msgsz, %zu bytes, complete:%s)\n", + // msg.hdr.nMessageSize, msg.vRecv.size(), + // msg.complete() ? "Y" : "N"); + + // end, if an incomplete message is found + if (!msg.complete()) + break; + + // at this point, any failure means we can delete the current message + it++; + + // Scan for message start + if (memcmp(msg.hdr.pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE) != 0) { + LogPrintf("\n\nPROCESSMESSAGE: INVALID MESSAGESTART\n\n"); + fOk = false; + break; + } + + // Read header + CMessageHeader& hdr = msg.hdr; + if (!hdr.IsValid()) + { + LogPrintf("\n\nPROCESSMESSAGE: ERRORS IN HEADER %s\n\n\n", hdr.GetCommand()); + continue; + } + string strCommand = hdr.GetCommand(); + + // Message size + unsigned int nMessageSize = hdr.nMessageSize; + + // Checksum + CDataStream& vRecv = msg.vRecv; + uint256 hash = Hash(vRecv.begin(), vRecv.begin() + nMessageSize); + unsigned int nChecksum = 0; + memcpy(&nChecksum, &hash, sizeof(nChecksum)); + if (nChecksum != hdr.nChecksum) + { + LogPrintf("ProcessMessages(%s, %u bytes) : CHECKSUM ERROR nChecksum=%08x hdr.nChecksum=%08x\n", + strCommand, nMessageSize, nChecksum, hdr.nChecksum); + continue; + } + + // Process message + bool fRet = false; + try + { + fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime); + boost::this_thread::interruption_point(); + } + catch (std::ios_base::failure& e) + { + if (strstr(e.what(), "end of data")) + { + // Allow exceptions from under-length message on vRecv + LogPrintf("ProcessMessages(%s, %u bytes) : Exception '%s' caught, normally caused by a message being shorter than its stated length\n", strCommand, nMessageSize, e.what()); + } + else if (strstr(e.what(), "size too large")) + { + // Allow exceptions from over-long size + LogPrintf("ProcessMessages(%s, %u bytes) : Exception '%s' caught\n", strCommand, nMessageSize, e.what()); + } + else + { + PrintExceptionContinue(&e, "ProcessMessages()"); + } + } + catch (boost::thread_interrupted) { + throw; + } + catch (std::exception& e) { + PrintExceptionContinue(&e, "ProcessMessages()"); + } catch (...) { + PrintExceptionContinue(NULL, "ProcessMessages()"); + } + + if (!fRet) + LogPrintf("ProcessMessage(%s, %u bytes) FAILED\n", strCommand, nMessageSize); + + break; + } + + // In case the connection got shut down, its receive buffer was wiped + if (!pfrom->fDisconnect) + pfrom->vRecvMsg.erase(pfrom->vRecvMsg.begin(), it); + + return fOk; +} + + +bool SendMessages(CNode* pto, bool fSendTrickle) +{ + TRY_LOCK(cs_main, lockMain); + if (lockMain) { + // Don't send anything until we get their version message + if (pto->nVersion == 0) + return true; + + // + // Message: ping + // + bool pingSend = false; + if (pto->fPingQueued) { + // RPC ping request by user + pingSend = true; + } + if (pto->nPingNonceSent == 0 && pto->nPingUsecStart + PING_INTERVAL * 1000000 < GetTimeMicros()) { + // Ping automatically sent as a latency probe & keepalive. + pingSend = true; + } + if (pingSend) { + uint64_t nonce = 0; + while (nonce == 0) { + RAND_bytes((unsigned char*)&nonce, sizeof(nonce)); + } + pto->fPingQueued = false; + pto->nPingUsecStart = GetTimeMicros(); + if (pto->nVersion > BIP0031_VERSION) { + pto->nPingNonceSent = nonce; + pto->PushMessage("ping", nonce); + } else { + // Peer is too old to support ping command with nonce, pong will never arrive. + pto->nPingNonceSent = 0; + pto->PushMessage("ping"); + } + } + + // Start block sync + if (pto->fStartSync && !fImporting && !fReindex) { + pto->fStartSync = false; + PushGetBlocks(pto, pindexBest, uint256(0)); + } + + // Resend wallet transactions that haven't gotten in a block yet + ResendWalletTransactions(); + + // Address refresh broadcast + static int64_t nLastRebroadcast; + if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60)) + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + // Periodically clear setAddrKnown to allow refresh broadcasts + if (nLastRebroadcast) + pnode->setAddrKnown.clear(); + + // Rebroadcast our address + AdvertizeLocal(pnode); + } + if (!vNodes.empty()) + nLastRebroadcast = GetTime(); + } + + // + // Message: addr + // + if (fSendTrickle) + { + vector vAddr; + vAddr.reserve(pto->vAddrToSend.size()); + BOOST_FOREACH(const CAddress& addr, pto->vAddrToSend) + { + // returns true if wasn't already contained in the set + if (pto->setAddrKnown.insert(addr).second) + { + vAddr.push_back(addr); + // receiver rejects addr messages larger than 1000 + if (vAddr.size() >= 1000) + { + pto->PushMessage("addr", vAddr); + vAddr.clear(); + } + } + } + pto->vAddrToSend.clear(); + if (!vAddr.empty()) + pto->PushMessage("addr", vAddr); + } + + + // + // Message: inventory + // + vector vInv; + vector vInvWait; + { + LOCK(pto->cs_inventory); + vInv.reserve(pto->vInventoryToSend.size()); + vInvWait.reserve(pto->vInventoryToSend.size()); + BOOST_FOREACH(const CInv& inv, pto->vInventoryToSend) + { + if (pto->setInventoryKnown.count(inv)) + continue; + + // trickle out tx inv to protect privacy + if (inv.type == MSG_TX && !fSendTrickle) + { + // 1/4 of tx invs blast to all immediately + static uint256 hashSalt; + if (hashSalt == 0) + hashSalt = GetRandHash(); + uint256 hashRand = inv.hash ^ hashSalt; + hashRand = Hash(BEGIN(hashRand), END(hashRand)); + bool fTrickleWait = ((hashRand & 3) != 0); + + if (fTrickleWait) + { + vInvWait.push_back(inv); + continue; + } + } + + // returns true if wasn't already contained in the set + if (pto->setInventoryKnown.insert(inv).second) + { + vInv.push_back(inv); + if (vInv.size() >= 1000) + { + pto->PushMessage("inv", vInv); + vInv.clear(); + } + } + } + pto->vInventoryToSend = vInvWait; + } + if (!vInv.empty()) + pto->PushMessage("inv", vInv); + + + // + // Message: getdata + // + vector vGetData; + int64_t nNow = GetTime() * 1000000; + CTxDB txdb("r"); + while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow) + { + const CInv& inv = (*pto->mapAskFor.begin()).second; + if (!AlreadyHave(txdb, inv)) + { + if (fDebug) + LogPrint("net", "sending getdata: %s\n", inv.ToString()); + vGetData.push_back(inv); + if (vGetData.size() >= 1000) + { + pto->PushMessage("getdata", vGetData); + vGetData.clear(); + } + mapAlreadyAskedFor[inv] = nNow; + } + pto->mapAskFor.erase(pto->mapAskFor.begin()); + } + if (!vGetData.empty()) + pto->PushMessage("getdata", vGetData); + + if (fSecMsgEnabled) + SecureMsgSendData(pto, fSendTrickle); // should be in cs_main? + + } + return true; +} + + + +int64_t GetMasternodePayment(int nHeight, int64_t blockValue) +{ + int64_t ret = blockValue * 0.25; // 25% + + return ret; +} + +unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP; + +int64_t GetTransactionWeight(const CTransaction& tx) +{ + return ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR -1) + ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); +} + +int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost) +{ + return (std::max(nWeight, nSigOpCost * nBytesPerSigOp) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR; +} + +int64_t GetVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost) +{ + return GetVirtualTransactionSize(GetTransactionWeight(tx), nSigOpCost); +} + diff --git a/src/main.h b/src/main.h new file mode 100644 index 0000000..d776d2f --- /dev/null +++ b/src/main.h @@ -0,0 +1,1467 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_MAIN_H +#define BITCOIN_MAIN_H + +#include "core.h" +#include "bignum.h" +#include "sync.h" +#include "txmempool.h" +#include "net.h" +#include "script.h" +#include "hashblock.h" + +#include + +class CValidationState; + +#define START_MASTERNODE_PAYMENTS_TESTNET 1517076000 +#define START_MASTERNODE_PAYMENTS 1517076000 + +static const int SERIALIZE_TRANSACTION_NO_WITNESS = 0x40000000; + +static const int WITNESS_SCALE_FACTOR = 4; +static const unsigned int DEFAULT_BYTES_PER_SIGOP = 20; + +static const int64_t DARKSEND_COLLATERAL = (1000*COIN); //1000 SONO +static const int64_t DARKSEND_FEE = (0.0001*COIN); +static const int64_t DARKSEND_POOL_MAX = (1999999.99*COIN); + +/* + At 15 signatures, 1/2 of the masternode network can be owned by + one party without comprimising the security of InstantX + (1000/2150.0)**15 = 1.031e-05 +*/ +#define INSTANTX_SIGNATURES_REQUIRED 20 +#define INSTANTX_SIGNATURES_TOTAL 30 + +#define MASTERNODE_NOT_PROCESSED 0 // initial state +#define MASTERNODE_IS_CAPABLE 1 +#define MASTERNODE_NOT_CAPABLE 2 +#define MASTERNODE_STOPPED 3 +#define MASTERNODE_INPUT_TOO_NEW 4 +#define MASTERNODE_PORT_NOT_OPEN 6 +#define MASTERNODE_PORT_OPEN 7 +#define MASTERNODE_SYNC_IN_PROCESS 8 +#define MASTERNODE_REMOTELY_ENABLED 9 + +#define MASTERNODE_MIN_CONFIRMATIONS 7 +#define MASTERNODE_MIN_DSEEP_SECONDS (30*60) +#define MASTERNODE_MIN_DSEE_SECONDS (5*60) +#define MASTERNODE_PING_SECONDS (1*60) //(1*60) +#define MASTERNODE_PING_WAIT_SECONDS (5*60) +#define MASTERNODE_EXPIRATION_SECONDS (65*60) //Old 65*60 +#define MASTERNODE_REMOVAL_SECONDS (70*60) //Old 70*60 + + +class CBlock; +class CBlockIndex; +class CInv; +class CKeyItem; +class CNode; +class CReserveKey; +class CWallet; + +/** The maximum allowed size for a serialized block, in bytes (network rule) */ +static const unsigned int MAX_BLOCK_SIZE = 5000000; +/** The maximum size for mined blocks */ +static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2; +/** The maximum size for transactions we're willing to relay/mine **/ +static const unsigned int MAX_STANDARD_TX_SIZE = MAX_BLOCK_SIZE_GEN/5; +/** The maximum allowed number of signature check operations in a block (network rule) */ +static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; +/** Maxiumum number of signature check operations in an IsStandard() P2SH script */ +static const unsigned int MAX_P2SH_SIGOPS = 15; //<-------------------------------- +/** The maximum number of sigops we're willing to relay/mine in a single tx */ +static const unsigned int MAX_TX_SIGOPS = MAX_BLOCK_SIGOPS/5; //<------------------------------- +/** The maximum number of orphan transactions kept in memory */ +static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100; //<-------------------------- +/** Default for -maxorphanblocks, maximum number of orphan blocks kept in memory */ +static const unsigned int DEFAULT_MAX_ORPHAN_BLOCKS = 750; +/** The maximum number of entries in an 'inv' protocol message */ +static const unsigned int MAX_INV_SZ = 50000; +/** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */ +static const int64_t MIN_TX_FEE = 10000; //<--------------------------------------------- +/** Fees smaller than this (in satoshi) are considered zero fee (for relaying) */ +static const int64_t MIN_RELAY_TX_FEE = MIN_TX_FEE; +/** No amount larger than this (in satoshi) is valid */ +static const int64_t MAX_MONEY = 500000000 * COIN; + +static const int64_t COIN_YEAR_REWARD = 180 * CENT; // 5% per year + + +// First POS block +static const int MODIFIER_INTERVAL_SWITCH = 500; + +inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } +/** Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp. */ +static const unsigned int LOCKTIME_THRESHOLD = 500000000; // + +inline bool IsProtocolV1RetargetingFixed(int nHeight) { return TestNet() || nHeight > 0; } +inline bool IsProtocolV2(int nHeight) { return TestNet() || nHeight > 0; } +inline bool IsProtocolV3(int64_t nTime) { return TestNet() || nTime > 1470467000; } + +inline int64_t FutureDriftV1(int64_t nTime) { return nTime + 10 * 60; } +inline int64_t FutureDriftV2(int64_t nTime) { return nTime + 10 * 60; } +inline int64_t FutureDrift(int64_t nTime, int nHeight) { return IsProtocolV2(nHeight) ? FutureDriftV2(nTime) : FutureDriftV1(nTime); } + +inline unsigned int GetTargetSpacing(int nHeight) { return IsProtocolV2(nHeight) ? 60 : 60; } +inline int64_t GetMNCollateral(int nHeight) { return 1000; } + +extern CScript COINBASE_FLAGS; +extern CCriticalSection cs_main; +extern CTxMemPool mempool; +extern std::map mapBlockIndex; +extern std::set > setStakeSeen; +extern CBlockIndex* pindexGenesisBlock; +extern unsigned int nStakeMinAge; +extern unsigned int nNodeLifespan; +extern int nCoinbaseMaturity; +extern int nBestHeight; +extern uint256 nBestChainTrust; +extern uint256 nBestInvalidTrust; +extern uint256 hashBestChain; +extern CBlockIndex* pindexBest; +extern uint64_t nLastBlockTx; +extern uint64_t nLastBlockSize; +extern int64_t nLastCoinStakeSearchInterval; +extern const std::string strMessageMagic; +extern int64_t nTimeBestReceived; +extern bool fImporting; +extern bool fReindex; +struct COrphanBlock; +extern std::map mapOrphanBlocks; +extern bool fHaveGUI; + +// Settings +extern bool fUseFastIndex; +extern unsigned int nDerivationMethodIndex; + +extern bool fMinimizeCoinAge; + +// Minimum disk space required - used in CheckDiskSpace() +static const uint64_t nMinDiskSpace = 52428800; + +class CReserveKey; +class CTxDB; +class CTxIndex; +class CWalletInterface; + +/** Register a wallet to receive updates from core */ +void RegisterWallet(CWalletInterface* pwalletIn); +/** Unregister a wallet from core */ +void UnregisterWallet(CWalletInterface* pwalletIn); +/** Unregister all wallets from core */ +void UnregisterAllWallets(); +/** Push an updated transaction to all registered wallets */ +void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL, bool fConnect = true); +/** Ask wallets to resend their transactions */ +void ResendWalletTransactions(bool fForce = false); + +/** Register with a network node to receive its signals */ +void RegisterNodeSignals(CNodeSignals& nodeSignals); +/** Unregister a network node */ +void UnregisterNodeSignals(CNodeSignals& nodeSignals); + +void PushGetBlocks(CNode* pnode, CBlockIndex* pindexBegin, uint256 hashEnd); + +bool ProcessBlock(CNode* pfrom, CBlock* pblock); +bool CheckDiskSpace(uint64_t nAdditionalBytes=0); +FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb"); +FILE* AppendBlockFile(unsigned int& nFileRet); +bool LoadBlockIndex(bool fAllowNew=true); +void PrintBlockTree(); +CBlockIndex* FindBlockByHeight(int nHeight); +bool ProcessMessages(CNode* pfrom); +bool SendMessages(CNode* pto, bool fSendTrickle); +void ThreadImport(std::vector vImportFiles); + +bool CheckProofOfWork(uint256 hash, unsigned int nBits); +unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake); +int64_t GetProofOfWorkReward(int64_t nFees); +int64_t GetProofOfStakeReward(const CBlockIndex* pindexPrev, int64_t nCoinAge, int64_t nFees); +unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime); +unsigned int ComputeMinStake(unsigned int nBase, int64_t nTime, unsigned int nBlockTime); +bool IsInitialBlockDownload(); +std::string GetWarnings(std::string strFor); +bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock); +uint256 WantedByOrphan(const COrphanBlock* pblockOrphan); +const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfStake); +void ThreadStakeMiner(CWallet *pwallet); + + +/** (try to) add transaction to memory pool **/ +bool AcceptToMemoryPool(CTxMemPool& pool, CTransaction &tx, bool fLimitFree, + bool* pfMissingInputs); + +bool AcceptableInputs(CTxMemPool& pool, const CTransaction &txo, bool fLimitFree, + bool* pfMissingInputs); + + +bool FindTransactionsByDestination(const CTxDestination &dest, std::vector &vtxhash); + +int GetInputAge(CTxIn& vin); +/** Abort with a message */ +bool AbortNode(const std::string &msg, const std::string &userMessage=""); +/** Increase a node's misbehavior score. */ +void Misbehaving(NodeId nodeid, int howmuch); + +int64_t GetMasternodePayment(int nHeight, int64_t blockValue); + + +/** Position on disk for a particular transaction. */ +class CDiskTxPos +{ +public: + unsigned int nFile; + unsigned int nBlockPos; + unsigned int nTxPos; + + CDiskTxPos() + { + SetNull(); + } + + CDiskTxPos(unsigned int nFileIn, unsigned int nBlockPosIn, unsigned int nTxPosIn) + { + nFile = nFileIn; + nBlockPos = nBlockPosIn; + nTxPos = nTxPosIn; + } + + IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); ) + void SetNull() { nFile = (unsigned int) -1; nBlockPos = 0; nTxPos = 0; } + bool IsNull() const { return (nFile == (unsigned int) -1); } + + friend bool operator==(const CDiskTxPos& a, const CDiskTxPos& b) + { + return (a.nFile == b.nFile && + a.nBlockPos == b.nBlockPos && + a.nTxPos == b.nTxPos); + } + + friend bool operator!=(const CDiskTxPos& a, const CDiskTxPos& b) + { + return !(a == b); + } + + + std::string ToString() const + { + if (IsNull()) + return "null"; + else + return strprintf("(nFile=%u, nBlockPos=%u, nTxPos=%u)", nFile, nBlockPos, nTxPos); + } +}; + + + + +enum GetMinFee_mode +{ + GMF_BLOCK, + GMF_RELAY, + GMF_SEND, +}; + +typedef std::map > MapPrevTx; + +int64_t GetMinFee(const CTransaction& tx, unsigned int nBlockSize = 1, enum GetMinFee_mode mode = GMF_BLOCK, unsigned int nBytes = 0); + +/** The basic transaction that is broadcasted on the network and contained in + * blocks. A transaction can contain multiple inputs and outputs. + */ +class CTransaction +{ +public: + static const int CURRENT_VERSION=1; + int nVersion; + unsigned int nTime; + std::vector vin; + std::vector vout; + unsigned int nLockTime; + + // Denial-of-service detection: + mutable int nDoS; + bool DoS(int nDoSIn, bool fIn) const { nDoS += nDoSIn; return fIn; } + + CTransaction() + { + SetNull(); + } + + CTransaction(int nVersion, unsigned int nTime, const std::vector& vin, const std::vector& vout, unsigned int nLockTime) + : nVersion(nVersion), nTime(nTime), vin(vin), vout(vout), nLockTime(nLockTime), nDoS(0) + { + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(this->nVersion); + nVersion = this->nVersion; + READWRITE(nTime); + READWRITE(vin); + READWRITE(vout); + READWRITE(nLockTime); + ) + + void SetNull() + { + nVersion = CTransaction::CURRENT_VERSION; + nTime = GetAdjustedTime(); + vin.clear(); + vout.clear(); + nLockTime = 0; + nDoS = 0; // Denial-of-service prevention + } + + bool IsNull() const + { + return (vin.empty() && vout.empty()); + } + + uint256 GetHash() const + { + return SerializeHash(*this, SER_GETHASH, SERIALIZE_TRANSACTION_NO_WITNESS); + } + + uint256 GetWitnessHash() const + { + return SerializeHash(*this, SER_GETHASH, 0); + } + + bool IsCoinBase() const + { + return (vin.size() == 1 && vin[0].prevout.IsNull() && vout.size() >= 1); + } + + bool IsCoinStake() const + { + // ppcoin: the coin stake transaction is marked with the first output empty + return (vin.size() > 0 && (!vin[0].prevout.IsNull()) && vout.size() >= 2 && vout[0].IsEmpty()); + } + + /** Amount of bitcoins spent by this transaction. + @return sum of all outputs (note: does not include fees) + */ + int64_t GetValueOut() const + { + int64_t nValueOut = 0; + BOOST_FOREACH(const CTxOut& txout, vout) + { + nValueOut += txout.nValue; + if (!MoneyRange(txout.nValue) || !MoneyRange(nValueOut)) + throw std::runtime_error("CTransaction::GetValueOut() : value out of range"); + } + return nValueOut; + } + + /** Amount of bitcoins coming in to this transaction + Note that lightweight clients may not know anything besides the hash of previous transactions, + so may not be able to calculate this. + + @param[in] mapInputs Map of previous transactions that have outputs we're spending + @return Sum of value of all inputs (scriptSigs) + @see CTransaction::FetchInputs + */ + int64_t GetValueIn(const MapPrevTx& mapInputs) const; + + bool ReadFromDisk(CDiskTxPos pos, FILE** pfileRet=NULL) + { + CAutoFile filein = CAutoFile(OpenBlockFile(pos.nFile, 0, pfileRet ? "rb+" : "rb"), SER_DISK, CLIENT_VERSION); + if (!filein) + return error("CTransaction::ReadFromDisk() : OpenBlockFile failed"); + + // Read transaction + if (fseek(filein, pos.nTxPos, SEEK_SET) != 0) + return error("CTransaction::ReadFromDisk() : fseek failed"); + + try { + filein >> *this; + } + catch (std::exception &e) { + return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__); + } + + // Return file pointer + if (pfileRet) + { + if (fseek(filein, pos.nTxPos, SEEK_SET) != 0) + return error("CTransaction::ReadFromDisk() : second fseek failed"); + *pfileRet = filein.release(); + } + return true; + } + + friend bool operator==(const CTransaction& a, const CTransaction& b) + { + return (a.nVersion == b.nVersion && + a.nTime == b.nTime && + a.vin == b.vin && + a.vout == b.vout && + a.nLockTime == b.nLockTime); + } + + friend bool operator!=(const CTransaction& a, const CTransaction& b) + { + return !(a == b); + } + + std::string ToString() const + { + std::string str; + str += IsCoinBase()? "Coinbase" : (IsCoinStake()? "Coinstake" : "CTransaction"); + str += strprintf("(hash=%s, nTime=%d, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%d)\n", + GetHash().ToString(), + nTime, + nVersion, + vin.size(), + vout.size(), + nLockTime); + for (unsigned int i = 0; i < vin.size(); i++) + str += " " + vin[i].ToString() + "\n"; + for (unsigned int i = 0; i < vin.size(); i++) + str += " " + vin[i].scriptWitness.ToString() + "\n"; + for (unsigned int i = 0; i < vout.size(); i++) + str += " " + vout[i].ToString() + "\n"; + return str; + } + + bool ReadFromDisk(CTxDB& txdb, const uint256& hash, CTxIndex& txindexRet); + bool ReadFromDisk(CTxDB& txdb, COutPoint prevout, CTxIndex& txindexRet); + bool ReadFromDisk(CTxDB& txdb, COutPoint prevout); + bool ReadFromDisk(COutPoint prevout); + bool DisconnectInputs(CTxDB& txdb); + + /** Fetch from memory and/or disk. inputsRet keys are transaction hashes. + + @param[in] txdb Transaction database + @param[in] mapTestPool List of pending changes to the transaction index database + @param[in] fBlock True if being called to add a new best-block to the chain + @param[in] fMiner True if being called by CreateNewBlock + @param[out] inputsRet Pointers to this transaction's inputs + @param[out] fInvalid returns true if transaction is invalid + @return Returns true if all inputs are in txdb or mapTestPool + */ + bool FetchInputs(CTxDB& txdb, const std::map& mapTestPool, + bool fBlock, bool fMiner, MapPrevTx& inputsRet, bool& fInvalid); + + /** Sanity check previous transactions, then, if all checks succeed, + mark them as spent by this transaction. + + @param[in] inputs Previous transactions (from FetchInputs) + @param[out] mapTestPool Keeps track of inputs that need to be updated on disk + @param[in] posThisTx Position of this transaction on disk + @param[in] pindexBlock + @param[in] fBlock true if called from ConnectBlock + @param[in] fMiner true if called from CreateNewBlock + @return Returns true if all checks succeed + */ + bool ConnectInputs(CTxDB& txdb, MapPrevTx inputs, + std::map& mapTestPool, const CDiskTxPos& posThisTx, + const CBlockIndex* pindexBlock, bool fBlock, bool fMiner, unsigned int flags = STANDARD_SCRIPT_VERIFY_FLAGS, bool fValidateSig = true); + bool CheckTransaction() const; + bool GetCoinAge(CTxDB& txdb, uint64_t& nCoinAge) const; // ppcoin: get transaction coin age + + const CTxOut& GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const; + + bool HasWitness() const + { + for (size_t i = 0; i < vin.size(); i++) { + if (!vin[i].scriptWitness.IsNull()) { + return true; + } + } + return false; + } +}; + +int64_t GetTransactionWeight(const CTransaction& tx); +int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost); +int64_t GetVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost=0); + +/** wrapper for CTxOut that provides a more compact serialization */ +class CTxOutCompressor +{ +private: + CTxOut &txout; +public: + CTxOutCompressor(CTxOut &txoutIn) : txout(txoutIn) { } + + IMPLEMENT_SERIALIZE( + READWRITE(VARINT(txout.nValue)); + CScriptCompressor cscript(REF(txout.scriptPubKey)); + READWRITE(cscript); + ) +}; + +/** Check for standard transaction types + @param[in] mapInputs Map of previous transactions that have outputs we're spending + @return True if all inputs (scriptSigs) use only standard transaction forms + @see CTransaction::FetchInputs +*/ +bool AreInputsStandard(const CTransaction& tx, const MapPrevTx& mapInputs); + +/** Count ECDSA signature operations the old-fashioned (pre-0.6) way + @return number of sigops this transaction's outputs will produce when spent + @see CTransaction::FetchInputs +*/ +unsigned int GetLegacySigOpCount(const CTransaction& tx); + +/** Count ECDSA signature operations in pay-to-script-hash inputs. + + @param[in] mapInputs Map of previous transactions that have outputs we're spending + @return maximum number of sigops required to validate this transaction's inputs + @see CTransaction::FetchInputs + */ +unsigned int GetP2SHSigOpCount(const CTransaction& tx, const MapPrevTx& mapInputs); + +/** Check for standard transaction types + @return True if all outputs (scriptPubKeys) use only standard transaction forms +*/ +bool IsStandardTx(const CTransaction& tx, std::string& reason); + +bool IsFinalTx(const CTransaction &tx, int nBlockHeight = 0, int64_t nBlockTime = 0); + + + +/** A transaction with a merkle branch linking it to the block chain. */ +class CMerkleTx : public CTransaction +{ +private: + int GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const; +public: + uint256 hashBlock; + std::vector vMerkleBranch; + int nIndex; + + // memory only + mutable bool fMerkleVerified; + + + CMerkleTx() + { + Init(); + } + + CMerkleTx(const CTransaction& txIn) : CTransaction(txIn) + { + Init(); + } + + void Init() + { + hashBlock = 0; + nIndex = -1; + fMerkleVerified = false; + } + + + IMPLEMENT_SERIALIZE + ( + nSerSize += SerReadWrite(s, *(CTransaction*)this, nType, nVersion, ser_action); + nVersion = this->nVersion; + READWRITE(hashBlock); + READWRITE(vMerkleBranch); + READWRITE(nIndex); + ) + + + int SetMerkleBranch(const CBlock* pblock=NULL); + + // Return depth of transaction in blockchain: + // -1 : not in blockchain, and not in memory pool (conflicted transaction) + // 0 : in memory pool, waiting to be included in a block + // >=1 : this many blocks deep in the main chain + int GetDepthInMainChain(CBlockIndex* &pindexRet) const; + int GetDepthInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); } + bool IsInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChainINTERNAL(pindexRet) > 0; } + int GetBlocksToMaturity() const; + bool AcceptToMemoryPool(bool fLimitFree=true); + int GetTransactionLockSignatures() const; + bool IsTransactionLockTimedOut() const; +}; + + + + +/** A txdb record that contains the disk location of a transaction and the + * locations of transactions that spend its outputs. vSpent is really only + * used as a flag, but having the location is very helpful for debugging. + */ +class CTxIndex +{ +public: + CDiskTxPos pos; + std::vector vSpent; + + CTxIndex() + { + SetNull(); + } + + CTxIndex(const CDiskTxPos& posIn, unsigned int nOutputs) + { + pos = posIn; + vSpent.resize(nOutputs); + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(pos); + READWRITE(vSpent); + ) + + void SetNull() + { + pos.SetNull(); + vSpent.clear(); + } + + bool IsNull() + { + return pos.IsNull(); + } + + friend bool operator==(const CTxIndex& a, const CTxIndex& b) + { + return (a.pos == b.pos && + a.vSpent == b.vSpent); + } + + friend bool operator!=(const CTxIndex& a, const CTxIndex& b) + { + return !(a == b); + } + int GetDepthInMainChain() const; + +}; + + + + + +/** Nodes collect new transactions into a block, hash them into a hash tree, + * and scan through nonce values to make the block's hash satisfy proof-of-work + * requirements. When they solve the proof-of-work, they broadcast the block + * to everyone and the block is added to the block chain. The first transaction + * in the block is a special one that creates a new coin owned by the creator + * of the block. + * + * Blocks are appended to blk0001.dat files on disk. Their location on disk + * is indexed by CBlockIndex objects in memory. + */ +class CBlock +{ +public: + // header + static const int CURRENT_VERSION = 7; + int nVersion; + uint256 hashPrevBlock; + uint256 hashMerkleRoot; + unsigned int nTime; + unsigned int nBits; + unsigned int nNonce; + + // network and disk + std::vector vtx; + + // ppcoin: block signature - signed by one of the coin base txout[N]'s owner + std::vector vchBlockSig; + + // memory only + mutable std::vector vMerkleTree; + + // Denial-of-service detection: + mutable int nDoS; + bool DoS(int nDoSIn, bool fIn) const { nDoS += nDoSIn; return fIn; } + + CBlock() + { + SetNull(); + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(this->nVersion); + nVersion = this->nVersion; + READWRITE(hashPrevBlock); + READWRITE(hashMerkleRoot); + READWRITE(nTime); + READWRITE(nBits); + READWRITE(nNonce); + + // ConnectBlock depends on vtx following header to generate CDiskTxPos + if (!(nType & (SER_GETHASH|SER_BLOCKHEADERONLY))) + { + READWRITE(vtx); + READWRITE(vchBlockSig); + } + else if (fRead) + { + const_cast(this)->vtx.clear(); + const_cast(this)->vchBlockSig.clear(); + } + ) + + void SetNull() + { + nVersion = CBlock::CURRENT_VERSION; + hashPrevBlock = 0; + hashMerkleRoot = 0; + nTime = 0; + nBits = 0; + nNonce = 0; + vtx.clear(); + vchBlockSig.clear(); + vMerkleTree.clear(); + nDoS = 0; + } + + bool IsNull() const + { + return (nBits == 0); + } + + uint256 GetHash() const + { + if (nVersion > 6) + return Hash(BEGIN(nVersion), END(nNonce)); + + else + return GetPoWHash(); + } + + uint256 GetPoWHash() const + { + return SkunkHash5(BEGIN(nVersion), END(nNonce)); + } + + + int64_t GetBlockTime() const + { + return (int64_t)nTime; + } + + void UpdateTime(const CBlockIndex* pindexPrev); + + // entropy bit for stake modifier if chosen by modifier + unsigned int GetStakeEntropyBit() const + { + // Take last bit of block hash as entropy bit + unsigned int nEntropyBit = ((GetHash().Get64()) & 1llu); + LogPrint("stakemodifier", "GetStakeEntropyBit: hashBlock=%s nEntropyBit=%u\n", GetHash().ToString(), nEntropyBit); + return nEntropyBit; + } + + // ppcoin: two types of block: proof-of-work or proof-of-stake + bool IsProofOfStake() const + { + return (vtx.size() > 1 && vtx[1].IsCoinStake()); + } + + bool IsProofOfWork() const + { + return !IsProofOfStake(); + } + + std::pair GetProofOfStake() const + { + return IsProofOfStake()? std::make_pair(vtx[1].vin[0].prevout, vtx[1].nTime) : std::make_pair(COutPoint(), (unsigned int)0); + } + + // ppcoin: get max transaction timestamp + int64_t GetMaxTransactionTime() const + { + int64_t maxTransactionTime = 0; + BOOST_FOREACH(const CTransaction& tx, vtx) + maxTransactionTime = std::max(maxTransactionTime, (int64_t)tx.nTime); + return maxTransactionTime; + } + + uint256 BuildMerkleTree() const + { + vMerkleTree.clear(); + BOOST_FOREACH(const CTransaction& tx, vtx) + vMerkleTree.push_back(tx.GetHash()); + int j = 0; + for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) + { + for (int i = 0; i < nSize; i += 2) + { + int i2 = std::min(i+1, nSize-1); + vMerkleTree.push_back(Hash(BEGIN(vMerkleTree[j+i]), END(vMerkleTree[j+i]), + BEGIN(vMerkleTree[j+i2]), END(vMerkleTree[j+i2]))); + } + j += nSize; + } + return (vMerkleTree.empty() ? 0 : vMerkleTree.back()); + } + + std::vector GetMerkleBranch(int nIndex) const + { + if (vMerkleTree.empty()) + BuildMerkleTree(); + std::vector vMerkleBranch; + int j = 0; + for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) + { + int i = std::min(nIndex^1, nSize-1); + vMerkleBranch.push_back(vMerkleTree[j+i]); + nIndex >>= 1; + j += nSize; + } + return vMerkleBranch; + } + + static uint256 CheckMerkleBranch(uint256 hash, const std::vector& vMerkleBranch, int nIndex) + { + if (nIndex == -1) + return 0; + BOOST_FOREACH(const uint256& otherside, vMerkleBranch) + { + if (nIndex & 1) + hash = Hash(BEGIN(otherside), END(otherside), BEGIN(hash), END(hash)); + else + hash = Hash(BEGIN(hash), END(hash), BEGIN(otherside), END(otherside)); + nIndex >>= 1; + } + return hash; + } + + + bool WriteToDisk(unsigned int& nFileRet, unsigned int& nBlockPosRet) + { + // Open history file to append + CAutoFile fileout = CAutoFile(AppendBlockFile(nFileRet), SER_DISK, CLIENT_VERSION); + if (!fileout) + return error("CBlock::WriteToDisk() : AppendBlockFile failed"); + + // Write index header + unsigned int nSize = fileout.GetSerializeSize(*this); + fileout << FLATDATA(Params().MessageStart()) << nSize; + + // Write block + long fileOutPos = ftell(fileout); + if (fileOutPos < 0) + return error("CBlock::WriteToDisk() : ftell failed"); + nBlockPosRet = fileOutPos; + fileout << *this; + + // Flush stdio buffers and commit to disk before returning + fflush(fileout); + if (!IsInitialBlockDownload() || (nBestHeight+1) % 500 == 0) + FileCommit(fileout); + + return true; + } + + bool ReadFromDisk(unsigned int nFile, unsigned int nBlockPos, bool fReadTransactions=true) + { + SetNull(); + + // Open history file to read + CAutoFile filein = CAutoFile(OpenBlockFile(nFile, nBlockPos, "rb"), SER_DISK, CLIENT_VERSION); + if (!filein) + return error("CBlock::ReadFromDisk() : OpenBlockFile failed"); + if (!fReadTransactions) + filein.nType |= SER_BLOCKHEADERONLY; + + // Read block + try { + filein >> *this; + } + catch (std::exception &e) { + return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__); + } + + // Check the header + if (fReadTransactions && IsProofOfWork() && !CheckProofOfWork(GetPoWHash(), nBits)) + return error("CBlock::ReadFromDisk() : errors in block header"); + + return true; + } + + + + std::string ToString() const + { + std::stringstream s; + s << strprintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u, vchBlockSig=%s)\n", + GetHash().ToString(), + nVersion, + hashPrevBlock.ToString(), + hashMerkleRoot.ToString(), + nTime, nBits, nNonce, + vtx.size(), + HexStr(vchBlockSig.begin(), vchBlockSig.end())); + for (unsigned int i = 0; i < vtx.size(); i++) + { + s << " " << vtx[i].ToString() << "\n"; + } + s << " vMerkleTree: "; + for (unsigned int i = 0; i < vMerkleTree.size(); i++) + s << " " << vMerkleTree[i].ToString(); + s << "\n"; + return s.str(); + } + + + bool DisconnectBlock(CTxDB& txdb, CBlockIndex* pindex); + bool ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck=false); + bool ReadFromDisk(const CBlockIndex* pindex, bool fReadTransactions=true); + bool SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew); + bool AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos, const uint256& hashProof); + bool CheckBlock(bool fCheckPOW=true, bool fCheckMerkleRoot=true, bool fCheckSig=true) const; + bool AcceptBlock(); + bool SignBlock(CWallet& keystore, int64_t nFees); + bool CheckBlockSignature() const; + void RebuildAddressIndex(CTxDB& txdb); + +private: + bool SetBestChainInner(CTxDB& txdb, CBlockIndex *pindexNew); +}; + + + + + + +/** The block chain is a tree shaped structure starting with the + * genesis block at the root, with each block potentially having multiple + * candidates to be the next block. pprev and pnext link a path through the + * main/longest chain. A blockindex may have multiple pprev pointing back + * to it, but pnext will only point forward to the longest branch, or will + * be null if the block is not part of the longest chain. + */ +class CBlockIndex +{ +public: + const uint256* phashBlock; + CBlockIndex* pprev; + CBlockIndex* pnext; + unsigned int nFile; + unsigned int nBlockPos; + uint256 nChainTrust; // ppcoin: trust score of block chain + int nHeight; + + int64_t nMint; + int64_t nMoneySupply; + + unsigned int nFlags; // ppcoin: block index flags + enum + { + BLOCK_PROOF_OF_STAKE = (1 << 0), // is proof-of-stake block + BLOCK_STAKE_ENTROPY = (1 << 1), // entropy bit for stake modifier + BLOCK_STAKE_MODIFIER = (1 << 2), // regenerated stake modifier + }; + + uint64_t nStakeModifier; // hash modifier for proof-of-stake + + // proof-of-stake specific fields + COutPoint prevoutStake; + unsigned int nStakeTime; + + uint256 hashProof; + + // block header + int nVersion; + uint256 hashMerkleRoot; + unsigned int nTime; + unsigned int nBits; + unsigned int nNonce; + + CBlockIndex() + { + phashBlock = NULL; + pprev = NULL; + pnext = NULL; + nFile = 0; + nBlockPos = 0; + nHeight = 0; + nChainTrust = 0; + nMint = 0; + nMoneySupply = 0; + nFlags = 0; + nStakeModifier = 0; + hashProof = 0; + prevoutStake.SetNull(); + nStakeTime = 0; + + nVersion = 0; + hashMerkleRoot = 0; + nTime = 0; + nBits = 0; + nNonce = 0; + } + + CBlockIndex(unsigned int nFileIn, unsigned int nBlockPosIn, CBlock& block) + { + phashBlock = NULL; + pprev = NULL; + pnext = NULL; + nFile = nFileIn; + nBlockPos = nBlockPosIn; + nHeight = 0; + nChainTrust = 0; + nMint = 0; + nMoneySupply = 0; + nFlags = 0; + nStakeModifier = 0; + hashProof = 0; + if (block.IsProofOfStake()) + { + SetProofOfStake(); + prevoutStake = block.vtx[1].vin[0].prevout; + nStakeTime = block.vtx[1].nTime; + } + else + { + prevoutStake.SetNull(); + nStakeTime = 0; + } + + nVersion = block.nVersion; + hashMerkleRoot = block.hashMerkleRoot; + nTime = block.nTime; + nBits = block.nBits; + nNonce = block.nNonce; + } + + CBlock GetBlockHeader() const + { + CBlock block; + block.nVersion = nVersion; + if (pprev) + block.hashPrevBlock = pprev->GetBlockHash(); + block.hashMerkleRoot = hashMerkleRoot; + block.nTime = nTime; + block.nBits = nBits; + block.nNonce = nNonce; + return block; + } + + uint256 GetBlockHash() const + { + return *phashBlock; + } + + int64_t GetBlockTime() const + { + return (int64_t)nTime; + } + + uint256 GetBlockTrust() const; + + bool IsInMainChain() const + { + return (pnext || this == pindexBest); + } + + bool CheckIndex() const + { + return true; + } + + int64_t GetPastTimeLimit() const + { + if (IsProtocolV2(nHeight)) + return GetBlockTime() - 120; + else + return GetMedianTimePast(); + } + + enum { nMedianTimeSpan=11 }; + + int64_t GetMedianTimePast() const + { + int64_t pmedian[nMedianTimeSpan]; + int64_t* pbegin = &pmedian[nMedianTimeSpan]; + int64_t* pend = &pmedian[nMedianTimeSpan]; + + const CBlockIndex* pindex = this; + for (int i = 0; i < nMedianTimeSpan && pindex; i++, pindex = pindex->pprev) + *(--pbegin) = pindex->GetBlockTime(); + + std::sort(pbegin, pend); + return pbegin[(pend - pbegin)/2]; + } + + /** + * Returns true if there are nRequired or more blocks of minVersion or above + * in the last nToCheck blocks, starting at pstart and going backwards. + */ + static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, + unsigned int nRequired, unsigned int nToCheck); + + + bool IsProofOfWork() const + { + return !(nFlags & BLOCK_PROOF_OF_STAKE); + } + + bool IsProofOfStake() const + { + return (nFlags & BLOCK_PROOF_OF_STAKE); + } + + void SetProofOfStake() + { + nFlags |= BLOCK_PROOF_OF_STAKE; + } + + unsigned int GetStakeEntropyBit() const + { + return ((nFlags & BLOCK_STAKE_ENTROPY) >> 1); + } + + bool SetStakeEntropyBit(unsigned int nEntropyBit) + { + if (nEntropyBit > 1) + return false; + nFlags |= (nEntropyBit? BLOCK_STAKE_ENTROPY : 0); + return true; + } + + bool GeneratedStakeModifier() const + { + return (nFlags & BLOCK_STAKE_MODIFIER); + } + + void SetStakeModifier(uint64_t nModifier, bool fGeneratedStakeModifier) + { + nStakeModifier = nModifier; + if (fGeneratedStakeModifier) + nFlags |= BLOCK_STAKE_MODIFIER; + } + + std::string ToString() const + { + return strprintf("CBlockIndex(nprev=%p, pnext=%p, nFile=%u, nBlockPos=%-6d nHeight=%d, nMint=%s, nMoneySupply=%s, nFlags=(%s)(%d)(%s), nStakeModifier=%016x, hashProof=%s, prevoutStake=(%s), nStakeTime=%d merkle=%s, hashBlock=%s)", + pprev, pnext, nFile, nBlockPos, nHeight, + FormatMoney(nMint), FormatMoney(nMoneySupply), + GeneratedStakeModifier() ? "MOD" : "-", GetStakeEntropyBit(), IsProofOfStake()? "PoS" : "PoW", + nStakeModifier, + hashProof.ToString(), + prevoutStake.ToString(), nStakeTime, + hashMerkleRoot.ToString(), + GetBlockHash().ToString()); + } +}; + + + +/** Used to marshal pointers into hashes for db storage. */ +class CDiskBlockIndex : public CBlockIndex +{ +private: + uint256 blockHash; + +public: + uint256 hashPrev; + uint256 hashNext; + + CDiskBlockIndex() + { + hashPrev = 0; + hashNext = 0; + blockHash = 0; + } + + explicit CDiskBlockIndex(CBlockIndex* pindex) : CBlockIndex(*pindex) + { + hashPrev = (pprev ? pprev->GetBlockHash() : 0); + hashNext = (pnext ? pnext->GetBlockHash() : 0); + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + + READWRITE(hashNext); + READWRITE(nFile); + READWRITE(nBlockPos); + READWRITE(nHeight); + READWRITE(nMint); + READWRITE(nMoneySupply); + READWRITE(nFlags); + READWRITE(nStakeModifier); + if (IsProofOfStake()) + { + READWRITE(prevoutStake); + READWRITE(nStakeTime); + } + else if (fRead) + { + const_cast(this)->prevoutStake.SetNull(); + const_cast(this)->nStakeTime = 0; + } + READWRITE(hashProof); + + // block header + READWRITE(this->nVersion); + READWRITE(hashPrev); + READWRITE(hashMerkleRoot); + READWRITE(nTime); + READWRITE(nBits); + READWRITE(nNonce); + READWRITE(blockHash); + ) + + uint256 GetBlockHash() const + { + if (fUseFastIndex && (nTime < GetAdjustedTime() - 24 * 60 * 60) && blockHash != 0) + return blockHash; + + CBlock block; + block.nVersion = nVersion; + block.hashPrevBlock = hashPrev; + block.hashMerkleRoot = hashMerkleRoot; + block.nTime = nTime; + block.nBits = nBits; + block.nNonce = nNonce; + + const_cast(this)->blockHash = block.GetHash(); + + return blockHash; + } + + std::string ToString() const + { + std::string str = "CDiskBlockIndex("; + str += CBlockIndex::ToString(); + str += strprintf("\n hashBlock=%s, hashPrev=%s, hashNext=%s)", + GetBlockHash().ToString(), + hashPrev.ToString(), + hashNext.ToString()); + return str; + } +}; + + + + + + + + +/** Describes a place in the block chain to another node such that if the + * other node doesn't have the same branch, it can find a recent common trunk. + * The further back it is, the further before the fork it may be. + */ +class CBlockLocator +{ +protected: + std::vector vHave; +public: + + CBlockLocator() + { + } + + explicit CBlockLocator(const CBlockIndex* pindex) + { + Set(pindex); + } + + explicit CBlockLocator(uint256 hashBlock) + { + std::map::iterator mi = mapBlockIndex.find(hashBlock); + if (mi != mapBlockIndex.end()) + Set((*mi).second); + } + + CBlockLocator(const std::vector& vHaveIn) + { + vHave = vHaveIn; + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(vHave); + ) + + void SetNull() + { + vHave.clear(); + } + + bool IsNull() + { + return vHave.empty(); + } + + void Set(const CBlockIndex* pindex) + { + vHave.clear(); + int nStep = 1; + while (pindex) + { + vHave.push_back(pindex->GetBlockHash()); + + // Exponentially larger steps back + for (int i = 0; pindex && i < nStep; i++) + pindex = pindex->pprev; + if (vHave.size() > 10) + nStep *= 2; + } + vHave.push_back(Params().HashGenesisBlock()); + } + + int GetDistanceBack() + { + // Retrace how far back it was in the sender's branch + int nDistance = 0; + int nStep = 1; + BOOST_FOREACH(const uint256& hash, vHave) + { + std::map::iterator mi = mapBlockIndex.find(hash); + if (mi != mapBlockIndex.end()) + { + CBlockIndex* pindex = (*mi).second; + if (pindex->IsInMainChain()) + return nDistance; + } + nDistance += nStep; + if (nDistance > 10) + nStep *= 2; + } + return nDistance; + } + + CBlockIndex* GetBlockIndex() + { + // Find the first block the caller has in the main chain + BOOST_FOREACH(const uint256& hash, vHave) + { + std::map::iterator mi = mapBlockIndex.find(hash); + if (mi != mapBlockIndex.end()) + { + CBlockIndex* pindex = (*mi).second; + if (pindex->IsInMainChain()) + return pindex; + } + } + return pindexGenesisBlock; + } + + uint256 GetBlockHash() + { + // Find the first block the caller has in the main chain + BOOST_FOREACH(const uint256& hash, vHave) + { + std::map::iterator mi = mapBlockIndex.find(hash); + if (mi != mapBlockIndex.end()) + { + CBlockIndex* pindex = (*mi).second; + if (pindex->IsInMainChain()) + return hash; + } + } + return Params().HashGenesisBlock(); + } + + int GetHeight() + { + CBlockIndex* pindex = GetBlockIndex(); + if (!pindex) + return 0; + return pindex->nHeight; + } +}; + + + + +/** Capture information about block/transaction validation */ +class CValidationState { +private: + enum mode_state { + MODE_VALID, //! everything ok + MODE_INVALID, //! network rule violation (DoS value may be set) + MODE_ERROR, //! run-time error + } mode; + int nDoS; + std::string strRejectReason; + unsigned char chRejectCode; + bool corruptionPossible; +public: + CValidationState() : mode(MODE_VALID), nDoS(0), chRejectCode(0), corruptionPossible(false) {} + bool DoS(int level, bool ret = false, + unsigned char chRejectCodeIn=0, std::string strRejectReasonIn="", + bool corruptionIn=false) { + chRejectCode = chRejectCodeIn; + strRejectReason = strRejectReasonIn; + corruptionPossible = corruptionIn; + if (mode == MODE_ERROR) + return ret; + nDoS += level; + mode = MODE_INVALID; + return ret; + } + bool Invalid(bool ret = false, + unsigned char _chRejectCode=0, std::string _strRejectReason="") { + return DoS(0, ret, _chRejectCode, _strRejectReason); + } + bool Error(std::string strRejectReasonIn="") { + if (mode == MODE_VALID) + strRejectReason = strRejectReasonIn; + mode = MODE_ERROR; + return false; + } + bool Abort(const std::string &msg) { + AbortNode(msg); + return Error(msg); + } + bool IsValid() const { + return mode == MODE_VALID; + } + bool IsInvalid() const { + return mode == MODE_INVALID; + } + bool IsError() const { + return mode == MODE_ERROR; + } + bool IsInvalid(int &nDoSOut) const { + if (IsInvalid()) { + nDoSOut = nDoS; + return true; + } + return false; + } + bool CorruptionPossible() const { + return corruptionPossible; + } + unsigned char GetRejectCode() const { return chRejectCode; } + std::string GetRejectReason() const { return strRejectReason; } +}; + + + + + + + +class CWalletInterface { +protected: + virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock, bool fConnect) =0; + virtual void EraseFromWallet(const uint256 &hash) =0; + virtual void SetBestChain(const CBlockLocator &locator) =0; + virtual void UpdatedTransaction(const uint256 &hash) =0; + virtual void Inventory(const uint256 &hash) =0; + virtual void ResendWalletTransactions(bool fForce) =0; + friend void ::RegisterWallet(CWalletInterface*); + friend void ::UnregisterWallet(CWalletInterface*); + friend void ::UnregisterAllWallets(); +}; + +#endif + diff --git a/src/makefile.bsd b/src/makefile.bsd new file mode 100644 index 0000000..e78e513 --- /dev/null +++ b/src/makefile.bsd @@ -0,0 +1,188 @@ +# Copyright (c) 2009-2010 Satoshi Nakamoto +# Distributed under the MIT/X11 software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +USE_UPNP:=0 +USE_WALLET:=1 + +LINK:=$(CXX) + +DEFS=-DBOOST_SPIRIT_THREADSAFE + +DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH)) +LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH)) + +LMODE = dynamic +LMODE2 = dynamic +ifdef STATIC + LMODE = static + ifeq (${STATIC}, all) + LMODE2 = static + endif +endif + +# for boost 1.37, add -mt to the boost libraries +LIBS += \ + -Wl,-B$(LMODE) \ + -l boost_system$(BOOST_LIB_SUFFIX) \ + -l boost_filesystem$(BOOST_LIB_SUFFIX) \ + -l boost_program_options$(BOOST_LIB_SUFFIX) \ + -l boost_thread$(BOOST_LIB_SUFFIX) \ + -l db_cxx$(BDB_LIB_SUFFIX) \ + -l ssl \ + -l crypto \ + -l execinfo + +ifndef USE_UPNP + override USE_UPNP = - +endif +ifneq (${USE_UPNP}, -) + LIBS += -l miniupnpc + DEFS += -DUSE_UPNP=$(USE_UPNP) +endif + +LIBS+= \ + -Wl,-B$(LMODE2) \ + -l z \ + -l dl \ + -l pthread + + +# Hardening +# Make some classes of vulnerabilities unexploitable in case one is discovered. +# + # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes + # -fstack-protector-all to be ignored unless -fno-stack-protector is used first. + # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722 + HARDENING=-fno-stack-protector + + # Stack Canaries + # Put numbers at the beginning of each stack frame and check that they are the same. + # If a stack buffer if overflowed, it writes over the canary number and then on return + # when that number is checked, it won't be the same and the program will exit with + # a "Stack smashing detected" error instead of being exploited. + HARDENING+=-fstack-protector-all -Wstack-protector + + # Make some important things such as the global offset table read only as soon as + # the dynamic linker is finished building it. This will prevent overwriting of addresses + # which would later be jumped to. + LDHARDENING+=-Wl,-z,relro -Wl,-z,now + + # Build position independent code to take advantage of Address Space Layout Randomization + # offered by some kernels. + # see doc/build-unix.txt for more information. + ifdef PIE + HARDENING+=-fPIE + LDHARDENING+=-pie + endif + + # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in + # the source such overflowing a statically defined buffer. + HARDENING+=-D_FORTIFY_SOURCE=2 +# + + +DEBUGFLAGS=-g + +# CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only +# adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work. +xCXXFLAGS=-O0 -msse2 -pthread -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter \ + $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS) + +# LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only +# adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work. +xLDFLAGS=$(LDHARDENING) $(LDFLAGS) + +OBJS= \ + obj/alert.o \ + obj/version.o \ + obj/checkpoints.o \ + obj/netbase.o \ + obj/addrman.o \ + obj/crypter.o \ + obj/key.o \ + obj/init.o \ + obj/bitcoind.o \ + obj/keystore.o \ + obj/core.o \ + obj/main.o \ + obj/net.o \ + obj/protocol.o \ + obj/rpcclient.o \ + obj/rpcprotocol.o \ + obj/rpcserver.o \ + obj/rpcmisc.o \ + obj/rpcnet.o \ + obj/rpcblockchain.o \ + obj/rpcrawtransaction.o \ + obj/timedata.o \ + obj/script.o \ + obj/sync.o \ + obj/txmempool.o \ + obj/util.o \ + obj/hash.o \ + obj/noui.o \ + obj/kernel.o \ + obj/pbkdf2.o \ + obj/scrypt.o \ + obj/scrypt-arm.o \ + obj/scrypt-x86.o \ + obj/scrypt-x86_64.o \ + obj/chainparams.o + +ifeq (${USE_WALLET}, 1) + DEFS += -DENABLE_WALLET + OBJS += \ + obj/db.o \ + obj/miner.o \ + obj/rpcdump.o \ + obj/rpcmining.o \ + obj/rpcwallet.o \ + obj/wallet.o \ + obj/walletdb.o +endif + +all: SONOd + +LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a +DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) +DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers) +OBJS += obj/txdb-leveldb.o +leveldb/libleveldb.a: + @echo "Building LevelDB ..."; cd leveldb; make libleveldb.a libmemenv.a; cd ..; +obj/txdb-leveldb.o: leveldb/libleveldb.a + +# auto-generated dependencies: +-include obj/*.P + +obj/build.h: FORCE + /bin/sh ../share/genbuild.sh obj/build.h +version.cpp: obj/build.h +DEFS += -DHAVE_BUILD_INFO + +obj/scrypt-x86.o: scrypt-x86.S + $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + +obj/scrypt-x86_64.o: scrypt-x86_64.S + $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + +obj/scrypt-arm.o: scrypt-arm.S + $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + +obj/%.o: %.cpp + $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< + @cp $(@:%.o=%.d) $(@:%.o=%.P); \ + sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ + -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ + rm -f $(@:%.o=%.d) + +SONOd: $(OBJS:obj/%=obj/%) + $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS) + +clean: + -rm -f SONOd + -rm -f obj/*.o + -rm -f obj/*.P + -rm -f obj/build.h + +FORCE: diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw new file mode 100644 index 0000000..50ba928 --- /dev/null +++ b/src/makefile.linux-mingw @@ -0,0 +1,142 @@ +# Copyright (c) 2009-2010 Satoshi Nakamoto +# Distributed under the MIT/X11 software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +TARGET_PLATFORM:=i686 +#TARGET_PLATFORM:=x86_64 + +DEPSDIR:=/usr/$(TARGET_PLATFORM)-w64-mingw32 +CC:=$(TARGET_PLATFORM)-w64-mingw32-gcc +CXX:=$(TARGET_PLATFORM)-w64-mingw32-g++ +RANLIB=$(TARGET_PLATFORM)-w64-mingw32-ranlib +STRIP=$(TARGET_PLATFORM)-w64-mingw32-strip + +USE_UPNP:=0 +USE_WALLET:=1 + +INCLUDEPATHS= \ + -I"$(CURDIR)" \ + -I"$(CURDIR)"/obj \ + -I"$(DEPSDIR)/boost_1_55_0" \ + -I"$(DEPSDIR)/db-6.0.20/build_unix" \ + -I"$(DEPSDIR)/openssl-1.0.1f/include" \ + -I"$(DEPSDIR)" + +LIBPATHS= \ + -L"$(DEPSDIR)/boost_1_55_0/stage/lib" \ + -L"$(DEPSDIR)/db-6.0.20/build_unix" \ + -L"$(DEPSDIR)/openssl-1.0.1f" + +LIBS= \ + -l boost_system-mt \ + -l boost_filesystem-mt \ + -l boost_program_options-mt \ + -l boost_thread_win32-mt \ + -l boost_chrono-mt \ + -l db_cxx \ + -l ssl \ + -l crypto \ + -l z + +DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE +DEBUGFLAGS=-g +CFLAGS=-O2 -msse2 -w -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) +LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -static-libgcc -static-libstdc++ + +ifndef USE_UPNP + override USE_UPNP = - +endif +ifneq (${USE_UPNP}, -) + LIBPATHS += -L"$(DEPSDIR)/miniupnpc" + LIBS += -l miniupnpc -l iphlpapi + DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP) +endif + +LIBS += -l mingwthrd -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l mswsock -l shlwapi + +# TODO: make the mingw builds smarter about dependencies, like the linux/osx builds are +HEADERS = $(wildcard *.h) + +OBJS= \ + obj/alert.o \ + obj/version.o \ + obj/checkpoints.o \ + obj/netbase.o \ + obj/addrman.o \ + obj/crypter.o \ + obj/key.o \ + obj/init.o \ + obj/bitcoind.o \ + obj/keystore.o \ + obj/core.o \ + obj/main.o \ + obj/net.o \ + obj/protocol.o \ + obj/rpcclient.o \ + obj/rpcprotocol.o \ + obj/rpcserver.o \ + obj/rpcmisc.o \ + obj/rpcnet.o \ + obj/rpcblockchain.o \ + obj/rpcrawtransaction.o \ + obj/timedata.o \ + obj/script.o \ + obj/sync.o \ + obj/txmempool.o \ + obj/util.o \ + obj/hash.o \ + obj/noui.o \ + obj/kernel.o \ + obj/pbkdf2.o \ + obj/scrypt.o \ + obj/scrypt-x86.o \ + obj/scrypt-x86_64.o \ + obj/chainparams.o + +ifeq (${USE_WALLET}, 1) + DEFS += -DENABLE_WALLET + OBJS += \ + obj/db.o \ + obj/miner.o \ + obj/rpcdump.o \ + obj/rpcmining.o \ + obj/rpcwallet.o \ + obj/wallet.o \ + obj/walletdb.o +endif + +all: SONOd.exe + +LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a +DEFS += -I"$(CURDIR)/leveldb/include" +DEFS += -I"$(CURDIR)/leveldb/helpers" +OBJS += obj/txdb-leveldb.o +leveldb/libleveldb.a: + @echo "Building LevelDB ..." && cd leveldb && CC=$(CC) CXX=$(CXX) TARGET_OS=OS_WINDOWS_CROSSCOMPILE CXXFLAGS="-I$(INCLUDEPATHS)" LDFLAGS="-L$(LIBPATHS)" $(MAKE) libleveldb.a libmemenv.a && $(RANLIB) libleveldb.a && $(RANLIB) libmemenv.a && cd .. +obj/txdb-leveldb.o: leveldb/libleveldb.a + +obj/build.h: FORCE + /bin/sh ../share/genbuild.sh obj/build.h +version.cpp: obj/build.h +DEFS += -DHAVE_BUILD_INFO + +obj/%.o: %.cpp $(HEADERS) + $(CXX) -c $(CFLAGS) -o $@ $< + +SONOd.exe: $(OBJS:obj/%=obj/%) + $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lshlwapi + $(STRIP) SONOd.exe + +obj/scrypt-x86.o: scrypt-x86.S + $(CXX) -c $(CFLAGS) -MMD -o $@ $< + +obj/scrypt-x86_64.o: scrypt-x86_64.S + $(CXX) -c $(CFLAGS) -MMD -o $@ $< + +clean: + -rm -f obj/*.o + -rm -f SONOd.exe + -rm -f obj/build.h + cd leveldb && TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) clean && cd .. + +FORCE: diff --git a/src/makefile.mingw b/src/makefile.mingw new file mode 100644 index 0000000..0acbc29 --- /dev/null +++ b/src/makefile.mingw @@ -0,0 +1,124 @@ +# Copyright (c) 2009-2010 Satoshi Nakamoto +# Distributed under the MIT/X11 software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +USE_UPNP:=0 +USE_WALLET:=1 + +INCLUDEPATHS= \ + -I"C:\boost-1.50.0-mgw" \ + -I"C:\db-4.8.30.NC-mgw\build_unix" \ + -I"C:\openssl-1.0.1c-mgw\include" + +LIBPATHS= \ + -L"C:\boost-1.50.0-mgw\stage\lib" \ + -L"C:\db-4.8.30.NC-mgw\build_unix" \ + -L"C:\openssl-1.0.1c-mgw" + +LIBS= \ + -l boost_system-mgw44-mt-1_53 \ + -l boost_filesystem-mgw44-mt-1_53 \ + -l boost_program_options-mgw44-mt-1_53 \ + -l boost_thread-mgw44-mt-1_53 \ + -l boost_chrono-mgw44-mt-1_53 \ + -l db_cxx \ + -l ssl \ + -l crypto + +DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE +DEBUGFLAGS=-g +CFLAGS=-mthreads -O2 -msse2 -w -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) +LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat + +TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) + +ifndef USE_UPNP + override USE_UPNP = - +endif +ifneq (${USE_UPNP}, -) + INCLUDEPATHS += -I"C:\miniupnpc-1.6-mgw" + LIBPATHS += -L"C:\miniupnpc-1.6-mgw" + LIBS += -l miniupnpc -l iphlpapi + DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP) +endif + +LIBS += -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l mswsock -l shlwapi + +# TODO: make the mingw builds smarter about dependencies, like the linux/osx builds are +HEADERS = $(wildcard *.h) + +OBJS= \ + obj/alert.o \ + obj/version.o \ + obj/checkpoints.o \ + obj/netbase.o \ + obj/addrman.o \ + obj/crypter.o \ + obj/key.o \ + obj/init.o \ + obj/bitcoind.o \ + obj/keystore.o \ + obj/core.o \ + obj/main.o \ + obj/net.o \ + obj/protocol.o \ + obj/rpcclient.o \ + obj/rpcprotocol.o \ + obj/rpcserver.o \ + obj/rpcmisc.o \ + obj/rpcnet.o \ + obj/rpcblockchain.o \ + obj/rpcrawtransaction.o \ + obj/timedata.o \ + obj/script.o \ + obj/sync.o \ + obj/txmempool.o \ + obj/util.o \ + obj/hash.o \ + obj/noui.o \ + obj/kernel.o \ + obj/pbkdf2.o \ + obj/scrypt.o \ + obj/scrypt-x86.o \ + obj/scrypt-x86_64.o \ + obj/chainparams.o + +ifeq (${USE_WALLET}, 1) + DEFS += -DENABLE_WALLET + OBJS += \ + obj/db.o \ + obj/miner.o \ + obj/rpcdump.o \ + obj/rpcmining.o \ + obj/rpcwallet.o \ + obj/wallet.o \ + obj/walletdb.o +endif + +all: SONOd.exe + +LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a +DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) +DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers) +OBJS += obj/txdb-leveldb.o +leveldb/libleveldb.a: + cd leveldb; make; cd .. +obj/txdb-leveldb.o: leveldb/libleveldb.a + +obj/%.o: %.cpp $(HEADERS) + g++ -c $(CFLAGS) -o $@ $< + +obj/scrypt-x86.o: scrypt-x86.S + $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + +obj/scrypt-x86_64.o: scrypt-x86_64.S + $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + +SONOd.exe: $(OBJS:obj/%=obj/%) + g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) + +clean: + -del /Q SONOd + -del /Q obj\* + +FORCE: diff --git a/src/makefile.osx b/src/makefile.osx new file mode 100644 index 0000000..22af4d5 --- /dev/null +++ b/src/makefile.osx @@ -0,0 +1,186 @@ +# -*- mode: Makefile; -*- +# Copyright (c) 2011 Bitcoin Developers +# Distributed under the MIT/X11 software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +# Mac OS X makefile for SONO +# Originally by Laszlo Hanyecz (solar@heliacal.net) + +CXX=g++ +DEPSDIR=/usr/local + +INCLUDEPATHS= \ + -I"$(CURDIR)" \ + -I"$(CURDIR)"/obj \ + -I"$(DEPSDIR)/include" \ + -I"$(DEPSDIR)/include/db48" + +LIBPATHS= \ + -L"$(DEPSDIR)/lib" \ + -I"$(DEPSDIR)/include/berkeley-db4" + +USE_UPNP:=1 +USE_WALLET:=1 + +LIBS= -dead_strip + +ifdef STATIC +# Build STATIC if you are redistributing the SONOd binary +LIBS += \ + $(DEPSDIR)/lib/db48/libdb_cxx-4.8.a \ + $(DEPSDIR)/lib/libboost_system.a \ + $(DEPSDIR)/lib/libboost_filesystem.a \ + $(DEPSDIR)/lib/libboost_program_options.a \ + $(DEPSDIR)/lib/libboost_thread.a \ + $(DEPSDIR)/lib/libssl.a \ + $(DEPSDIR)/lib/libcrypto.a \ + -lz +else +LIBS += \ + -ldb_cxx-4.8 \ + -lboost_system \ + -lboost_filesystem \ + -lboost_program_options \ + -lboost_thread \ + -lssl \ + -lcrypto \ + -lz +endif + +DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DBOOST_SPIRIT_THREADSAFE + +ifdef RELEASE +# Compile for maximum compatibility and smallest size. +# This requires that dependencies are compiled +# the same way. +CFLAGS = -mmacosx-version-min=10.5 -arch x86_64 -O2 -msse2 +else +CFLAGS = -g -msse2 +endif + +# ppc doesn't work because we don't support big-endian +CFLAGS += -Wall -Wextra -Wformat -Wno-ignored-qualifiers -Wformat-security -Wno-unused-parameter -Wunused-function -Wunused-variable -fpermissive -Wconversion-null -Wmaybe-uninitialized\ \ + $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) + +OBJS= \ + obj/alert.o \ + obj/version.o \ + obj/checkpoints.o \ + obj/netbase.o \ + obj/addrman.o \ + obj/crypter.o \ + obj/key.o \ + obj/eckey.o \ + obj/rpcsmessage.o \ + obj/scrypt.o \ + obj/init.o \ + obj/bitcoind.o \ + obj/keystore.o \ + obj/core.o \ + obj/main.o \ + obj/net.o \ + obj/protocol.o \ + obj/rpcclient.o \ + obj/rpcprotocol.o \ + obj/rpcserver.o \ + obj/rpcmisc.o \ + obj/rpcnet.o \ + obj/rpcblockchain.o \ + obj/rpcrawtransaction.o \ + obj/timedata.o \ + obj/script.o \ + obj/sync.o \ + obj/txmempool.o \ + obj/util.o \ + obj/hash.o \ + obj/noui.o \ + obj/pbkdf2.o \ + obj/kernel.o \ + obj/stealth.o \ + obj/activemasternode.o \ + obj/darksend.o \ + obj/eccryptoverify.o \ + obj/instantx.o \ + obj/masternodeconfig.o \ + obj/masternode.o \ + obj/rpcdarksend.o \ + obj/spork.o \ + obj/crypto/hmac_sha256.o \ + obj/crypto/hmac_sha512.o \ + obj/crypto/rfc6979_hmac_sha256.o \ + obj/crypto/ripemd160.o \ + obj/crypto/sha1.o \ + obj/crypto/sha256.o \ + obj/crypto/sha512.o \ + obj/smessage.o \ + obj/skunkhash/cubehash.o \ + obj/skunkhash/aes_helper.o \ + obj/skunkhash/gost.o \ + obj/skunkhash/skein.o\ + obj/skunkhash/fugue.o + +ifeq (${USE_WALLET}, 1) + DEFS += -DENABLE_WALLET + OBJS += \ + obj/db.o \ + obj/miner.o \ + obj/rpcdump.o \ + obj/rpcmining.o \ + obj/rpcwallet.o \ + obj/wallet.o \ + obj/walletdb.o +endif + +ifndef USE_UPNP + override USE_UPNP = - +endif +ifneq (${USE_UPNP}, -) + DEFS += -DUSE_UPNP=$(USE_UPNP) +ifdef STATIC + LIBS += $(DEPSDIR)/lib/libminiupnpc.a +else + LIBS += -lminiupnpc +endif +endif + +all: SONOd + +LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a +DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) +DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers) +OBJS += obj/txdb-leveldb.o +leveldb/libleveldb.a: + @echo "Building LevelDB ..."; cd leveldb; make libleveldb.a libmemenv.a; cd .. +obj/txdb-leveldb.o: leveldb/libleveldb.a + +# auto-generated dependencies: +-include obj/*.P + +obj/build.h: FORCE + /bin/sh ../share/genbuild.sh obj/build.h +version.cpp: obj/build.h +DEFS += -DHAVE_BUILD_INFO + +obj/%.o: %.cpp + $(CXX) -c $(CFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< + @cp $(@:%.o=%.d) $(@:%.o=%.P); \ + sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ + -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ + rm -f $(@:%.o=%.d) + +obj/scrypt-x86.o: scrypt-x86.S + $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + +obj/scrypt-x86_64.o: scrypt-x86_64.S + $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + +SONOd: $(OBJS:obj/%=obj/%) + $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) + +clean: + -rm -f SONOd + -rm -f obj/*.o + -rm -f obj/*.P + -rm -f obj/build.h + +FORCE: diff --git a/src/makefile.unix b/src/makefile.unix new file mode 100644 index 0000000..9e83a3a --- /dev/null +++ b/src/makefile.unix @@ -0,0 +1,230 @@ +# Copyright (c) 2009-2010 Satoshi Nakamoto +# Distributed under the MIT/X11 software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +USE_UPNP:=0 +USE_WALLET:=1 + +LINK:=$(CXX) +ARCH:=$(system lscpu | head -n 1 | awk '{print $2}') + +DEFS=-DBOOST_SPIRIT_THREADSAFE +#DEFS += -DUSE_SECP256K1 +DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH)) +LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH)) + +LMODE = dynamic +LMODE2 = dynamic +ifdef STATIC + LMODE = static + ifeq (${STATIC}, all) + LMODE2 = static + endif +endif + +#LIBS += \ + #-Wl,-B$(LMODE) \ + # -l secp256k1 + +# for boost 1.37, add -mt to the boost libraries +LIBS += \ + -Wl,-B$(LMODE) \ + -l boost_system$(BOOST_LIB_SUFFIX) \ + -l boost_filesystem$(BOOST_LIB_SUFFIX) \ + -l boost_program_options$(BOOST_LIB_SUFFIX) \ + -l boost_thread$(BOOST_LIB_SUFFIX) \ + -l db_cxx$(BDB_LIB_SUFFIX) \ + -l ssl \ + -l crypto + +ifndef USE_UPNP + override USE_UPNP = - +endif +ifneq (${USE_UPNP}, -) + LIBS += -l miniupnpc + DEFS += -DUSE_UPNP=$(USE_UPNP) +endif + +LIBS+= \ + -Wl,-B$(LMODE2) \ + -l z \ + -l dl \ + -l pthread + + +# Hardening +# Make some classes of vulnerabilities unexploitable in case one is discovered. +# + # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes + # -fstack-protector-all to be ignored unless -fno-stack-protector is used first. + # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722 + HARDENING=-fno-stack-protector + + # Stack Canaries + # Put numbers at the beginning of each stack frame and check that they are the same. + # If a stack buffer if overflowed, it writes over the canary number and then on return + # when that number is checked, it won't be the same and the program will exit with + # a "Stack smashing detected" error instead of being exploited. + HARDENING+=-fstack-protector-all -Wstack-protector + + # Make some important things such as the global offset table read only as soon as + # the dynamic linker is finished building it. This will prevent overwriting of addresses + # which would later be jumped to. + LDHARDENING+=-Wl,-z,relro -Wl,-z,now + + # Build position independent code to take advantage of Address Space Layout Randomization + # offered by some kernels. + # see doc/build-unix.txt for more information. + ifdef PIE + HARDENING+=-fPIE + LDHARDENING+=-pie + endif + + # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in + # the source such overflowing a statically defined buffer. + HARDENING+=-D_FORTIFY_SOURCE=2 +# + + +DEBUGFLAGS=-g + + +ifeq (${ARCH}, i686) + EXT_OPTIONS=-msse2 +endif + + +# CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only +# adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work. +xCXXFLAGS=-O2 $(EXT_OPTIONS) -pthread -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter -Wunused-function -Wunused-variable -fpermissive -Wconversion-null -Wmaybe-uninitialized \ + $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS) + +# LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only +# adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work. +xLDFLAGS=$(LDHARDENING) $(LDFLAGS) + +OBJS= \ + obj/alert.o \ + obj/version.o \ + obj/checkpoints.o \ + obj/netbase.o \ + obj/addrman.o \ + obj/crypter.o \ + obj/key.o \ + obj/eckey.o \ + obj/init.o \ + obj/bitcoind.o \ + obj/keystore.o \ + obj/core.o \ + obj/main.o \ + obj/net.o \ + obj/protocol.o \ + obj/rpcclient.o \ + obj/rpcprotocol.o \ + obj/rpcserver.o \ + obj/rpcmisc.o \ + obj/rpcnet.o \ + obj/rpcblockchain.o \ + obj/rpcrawtransaction.o \ + obj/rpcsmessage.o \ + obj/timedata.o \ + obj/script.o \ + obj/scrypt.o \ + obj/sync.o \ + obj/txmempool.o \ + obj/util.o \ + obj/hash.o \ + obj/noui.o \ + obj/kernel.o \ + obj/pbkdf2.o \ + obj/chainparams.o \ + obj/stealth.o \ + obj/activemasternode.o \ + obj/darksend.o \ + obj/eccryptoverify.o \ + obj/instantx.o \ + obj/masternodeconfig.o \ + obj/masternode.o \ + obj/rpcdarksend.o \ + obj/spork.o \ + obj/crypto/hmac_sha256.o \ + obj/crypto/hmac_sha512.o \ + obj/crypto/rfc6979_hmac_sha256.o \ + obj/crypto/ripemd160.o \ + obj/crypto/sha1.o \ + obj/crypto/sha256.o \ + obj/crypto/sha512.o \ + obj/smessage.o \ + obj/skunkhash/cubehash.o \ + obj/skunkhash/aes_helper.o \ + obj/skunkhash/gost.o \ + obj/skunkhash/skein.o\ + obj/skunkhash/fugue.o + +ifeq (${USE_WALLET}, 1) + DEFS += -DENABLE_WALLET + OBJS += \ + obj/db.o \ + obj/miner.o \ + obj/rpcdump.o \ + obj/rpcmining.o \ + obj/rpcwallet.o \ + obj/wallet.o \ + obj/walletdb.o +endif + +all: SONOd + +LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a +DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) +DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers) +OBJS += obj/txdb-leveldb.o +leveldb/libleveldb.a: + @echo "Building LevelDB ..."; cd leveldb; make libleveldb.a libmemenv.a; cd ..; +obj/txdb-leveldb.o: leveldb/libleveldb.a + +# auto-generated dependencies: +-include obj/*.P + +obj/build.h: FORCE + /bin/sh ../share/genbuild.sh obj/build.h +version.cpp: obj/build.h +DEFS += -DHAVE_BUILD_INFO + +obj/scrypt-x86.o: scrypt-x86.S + $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + +obj/scrypt-x86_64.o: scrypt-x86_64.S + $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + +obj/scrypt-arm.o: scrypt-arm.S + $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + +obj/%.o: %.c + $(CXX) -c $(xCXXFLAGS) -fpermissive -MMD -MF $(@:%.o=%.d) -o $@ $< + @cp $(@:%.o=%.d) $(@:%.o=%.P); \ + sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ + -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ + rm -f $(@:%.o=%.d) + +obj/%.o: %.cpp + $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< + @cp $(@:%.o=%.d) $(@:%.o=%.P); \ + sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ + -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ + rm -f $(@:%.o=%.d) + +SONOd: $(OBJS:obj/%=obj/%) + $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS) + +clean: + -rm -f SONOd + -rm -f obj/*.o + -rm -f obj/*.P + -rm -f obj-test/*.o + -rm -f obj-test/*.P + -rm -f obj/*.d + -rm -f obj/build.h + cd leveldb && $(MAKE) clean && cd .. + +FORCE: diff --git a/src/masternode.cpp b/src/masternode.cpp new file mode 100644 index 0000000..96c1c01 --- /dev/null +++ b/src/masternode.cpp @@ -0,0 +1,839 @@ +#include "masternode.h" +#include "activemasternode.h" +#include "darksend.h" +//#include "primitives/transaction.h" +#include "main.h" +#include "util.h" +#include "addrman.h" +#include +//tt + +int CMasterNode::minProtoVersion = MIN_MN_PROTO_VERSION; + +CCriticalSection cs_masternodes; + +/** The list of active masternodes */ +std::vector vecMasternodes; +/** Object for who's going to get paid on which blocks */ +CMasternodePayments masternodePayments; +// keep track of masternode votes I've seen +map mapSeenMasternodeVotes; +// keep track of the scanning errors I've seen +map mapSeenMasternodeScanningErrors; +// who's asked for the masternode list and the last time +std::map askedForMasternodeList; +// which masternodes we've asked for +std::map askedForMasternodeListEntry; +// cache block hashes as we calculate them +std::map mapCacheBlockHashes; + +// manage the masternode connections +void ProcessMasternodeConnections(){ + LOCK(cs_vNodes); + + BOOST_FOREACH(CNode* pnode, vNodes) + { + //if it's our masternode, let it be + if(darkSendPool.submittedToMasternode == pnode->addr) continue; + + if(pnode->fDarkSendMaster){ + LogPrintf("Closing masternode connection %s \n", pnode->addr.ToString().c_str()); + pnode->CloseSocketDisconnect(); + } + } +} + +void ProcessMessageMasternode(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) +{ + + if (strCommand == "dsee") { //DarkSend Election Entry + if(fLiteMode) return; //disable all darksend/masternode related functionality + + bool fIsInitialDownload = IsInitialBlockDownload(); + if(fIsInitialDownload) return; + + CTxIn vin; + CService addr; + CPubKey pubkey; + CPubKey pubkey2; + vector vchSig; + int64_t sigTime; + int count; + int current; + int64_t lastUpdated; + int protocolVersion; + std::string strMessage; + + // 70047 and greater + vRecv >> vin >> addr >> vchSig >> sigTime >> pubkey >> pubkey2 >> count >> current >> lastUpdated >> protocolVersion; + + // make sure signature isn't in the future (past is OK) + if (sigTime > GetAdjustedTime() + 60 * 60) { + LogPrintf("dsee - Signature rejected, too far into the future %s\n", vin.ToString().c_str()); + return; + } + + bool isLocal = addr.IsRFC1918() || addr.IsLocal(); + //if(Params().MineBlocksOnDemand()) isLocal = false; + + std::string vchPubKey(pubkey.begin(), pubkey.end()); + std::string vchPubKey2(pubkey2.begin(), pubkey2.end()); + + strMessage = addr.ToString() + boost::lexical_cast(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast(protocolVersion); + + if(protocolVersion < MIN_MN_PROTO_VERSION) { + LogPrintf("dsee - ignoring outdated masternode %s protocol version %d\n", vin.ToString().c_str(), protocolVersion); + return; + } + + CScript pubkeyScript; + pubkeyScript =GetScriptForDestination(pubkey.GetID()); + + if(pubkeyScript.size() != 25) { + LogPrintf("dsee - pubkey the wrong size\n"); + Misbehaving(pfrom->GetId(), 100); + return; + } + + CScript pubkeyScript2; + pubkeyScript2 =GetScriptForDestination(pubkey2.GetID()); + + if(pubkeyScript2.size() != 25) { + LogPrintf("dsee - pubkey2 the wrong size\n"); + Misbehaving(pfrom->GetId(), 100); + return; + } + + std::string errorMessage = ""; + if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){ + LogPrintf("dsee - Got bad masternode address signature\n"); + Misbehaving(pfrom->GetId(), 100); + return; + } + + + + //search existing masternode list, this is where we update existing masternodes with new dsee broadcasts + LOCK(cs_masternodes); + BOOST_FOREACH(CMasterNode& mn, vecMasternodes) { + if(mn.vin.prevout == vin.prevout) { + // count == -1 when it's a new entry + // e.g. We don't want the entry relayed/time updated when we're syncing the list + // mn.pubkey = pubkey, IsVinAssociatedWithPubkey is validated once below, + // after that they just need to match + if(count == -1 && mn.pubkey == pubkey && !mn.UpdatedWithin(MASTERNODE_MIN_DSEE_SECONDS)){ + mn.UpdateLastSeen(); + + if(mn.now < sigTime){ //take the newest entry + LogPrintf("dsee - Got updated entry for %s\n", addr.ToString().c_str()); + mn.pubkey2 = pubkey2; + mn.now = sigTime; + mn.sig = vchSig; + mn.protocolVersion = protocolVersion; + mn.addr = addr; + + RelayDarkSendElectionEntry(vin, addr, vchSig, sigTime, pubkey, pubkey2, count, current, lastUpdated, protocolVersion); + } + } + + return; + } + } + + // make sure the vout that was signed is related to the transaction that spawned the masternode + // - this is expensive, so it's only done once per masternode + if(!darkSendSigner.IsVinAssociatedWithPubkey(vin, pubkey)) { + LogPrintf("dsee - Got mismatched pubkey and vin\n"); + Misbehaving(pfrom->GetId(), 100); + return; + } + + if(fDebug) LogPrintf("dsee - Got NEW masternode entry %s\n", addr.ToString().c_str()); + + // make sure it's still unspent + // - this is checked later by .check() in many places and by ThreadCheckDarkSendPool() + + CValidationState state; + CTransaction tx = CTransaction(); + CTxOut vout = CTxOut((GetMNCollateral(pindexBest->nHeight)-1)*COIN, darkSendPool.collateralPubKey); + tx.vin.push_back(vin); + tx.vout.push_back(vout); + //if(AcceptableInputs(mempool, state, tx)){ + bool pfMissingInputs; + if(AcceptableInputs(mempool, tx, false, &pfMissingInputs)){ + if(fDebug) LogPrintf("dsee - Accepted masternode entry %i %i\n", count, current); + + if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS){ + LogPrintf("dsee - Input must have least %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS); + Misbehaving(pfrom->GetId(), 20); + return; + } + + // use this as a peer + addrman.Add(CAddress(addr), pfrom->addr, 2*60*60); + + // add our masternode + CMasterNode mn(addr, vin, pubkey, vchSig, sigTime, pubkey2, protocolVersion); + mn.UpdateLastSeen(lastUpdated); + vecMasternodes.push_back(mn); + + // if it matches our masternodeprivkey, then we've been remotely activated + if(pubkey2 == activeMasternode.pubKeyMasternode && protocolVersion == PROTOCOL_VERSION){ + activeMasternode.EnableHotColdMasterNode(vin, addr); + } + + if(count == -1 && !isLocal) + RelayDarkSendElectionEntry(vin, addr, vchSig, sigTime, pubkey, pubkey2, count, current, lastUpdated, protocolVersion); + + } else { + LogPrintf("dsee - Rejected masternode entry %s\n", addr.ToString().c_str()); + + int nDoS = 0; + if (state.IsInvalid(nDoS)) + { + LogPrintf("dsee - %s from %s %s was not accepted into the memory pool\n", tx.GetHash().ToString().c_str(), + pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str()); + if (nDoS > 0) + Misbehaving(pfrom->GetId(), nDoS); + } + } + } + + else if (strCommand == "dseep") { //DarkSend Election Entry Ping + if(fLiteMode) return; //disable all darksend/masternode related functionality + bool fIsInitialDownload = IsInitialBlockDownload(); + if(fIsInitialDownload) return; + + CTxIn vin; + vector vchSig; + int64_t sigTime; + bool stop; + vRecv >> vin >> vchSig >> sigTime >> stop; + + //LogPrintf("dseep - Received: vin: %s sigTime: %lld stop: %s\n", vin.ToString().c_str(), sigTime, stop ? "true" : "false"); + + if (sigTime > GetAdjustedTime() + 60 * 60) { + LogPrintf("dseep - Signature rejected, too far into the future %s\n", vin.ToString().c_str()); + return; + } + + if (sigTime <= GetAdjustedTime() - 60 * 60) { + LogPrintf("dseep - Signature rejected, too far into the past %s - %d %d \n", vin.ToString().c_str(), sigTime, GetAdjustedTime()); + return; + } + + // see if we have this masternode + LOCK(cs_masternodes); + BOOST_FOREACH(CMasterNode& mn, vecMasternodes) { + if(mn.vin.prevout == vin.prevout) { + // LogPrintf("dseep - Found corresponding mn for vin: %s\n", vin.ToString().c_str()); + // take this only if it's newer + if(mn.lastDseep < sigTime){ + std::string strMessage = mn.addr.ToString() + boost::lexical_cast(sigTime) + boost::lexical_cast(stop); + + std::string errorMessage = ""; + if(!darkSendSigner.VerifyMessage(mn.pubkey2, vchSig, strMessage, errorMessage)){ + LogPrintf("dseep - Got bad masternode address signature %s \n", vin.ToString().c_str()); + //Misbehaving(pfrom->GetId(), 100); + return; + } + + mn.lastDseep = sigTime; + + if(!mn.UpdatedWithin(MASTERNODE_MIN_DSEEP_SECONDS)){ + mn.UpdateLastSeen(); + if(stop) { + mn.Disable(); + mn.Check(); + } + RelayDarkSendElectionEntryPing(vin, vchSig, sigTime, stop); + } + } + return; + } + } + + if(fDebug) LogPrintf("dseep - Couldn't find masternode entry %s\n", vin.ToString().c_str()); + + std::map::iterator i = askedForMasternodeListEntry.find(vin.prevout); + if (i != askedForMasternodeListEntry.end()){ + int64_t t = (*i).second; + if (GetTime() < t) { + // we've asked recently + return; + } + } + + // ask for the dsee info once from the node that sent dseep + + LogPrintf("dseep - Asking source node for missing entry %s\n", vin.ToString().c_str()); + pfrom->PushMessage("dseg", vin); + int64_t askAgain = GetTime()+(60*60*24); + askedForMasternodeListEntry[vin.prevout] = askAgain; + + } else if (strCommand == "dseg") { //Get masternode list or specific entry + if(fLiteMode) return; //disable all darksend/masternode related functionality + CTxIn vin; + vRecv >> vin; + + if(vin == CTxIn()) { //only should ask for this once + //local network + //Note tor peers show up as local proxied addrs //if(!pfrom->addr.IsRFC1918())//&& !Params().MineBlocksOnDemand()) + //{ + std::map::iterator i = askedForMasternodeList.find(pfrom->addr); + if (i != askedForMasternodeList.end()) + { + int64_t t = (*i).second; + if (GetTime() < t) { + //Misbehaving(pfrom->GetId(), 34); + //LogPrintf("dseg - peer already asked me for the list\n"); + //return; + } + } + + int64_t askAgain = GetTime()+(60*60*3); + askedForMasternodeList[pfrom->addr] = askAgain; + //} + } //else, asking for a specific node which is ok + + LOCK(cs_masternodes); + int count = vecMasternodes.size(); + int i = 0; + + BOOST_FOREACH(CMasterNode mn, vecMasternodes) { + + if(mn.addr.IsRFC1918()) continue; //local network + + if(vin == CTxIn()){ + mn.Check(); + if(mn.IsEnabled()) { + if(fDebug) LogPrintf("dseg - Sending masternode entry - %s \n", mn.addr.ToString().c_str()); + pfrom->PushMessage("dsee", mn.vin, mn.addr, mn.sig, mn.now, mn.pubkey, mn.pubkey2, count, i, mn.lastTimeSeen, mn.protocolVersion); + } + } else if (vin == mn.vin) { + if(fDebug) LogPrintf("dseg - Sending masternode entry - %s \n", mn.addr.ToString().c_str()); + pfrom->PushMessage("dsee", mn.vin, mn.addr, mn.sig, mn.now, mn.pubkey, mn.pubkey2, count, i, mn.lastTimeSeen, mn.protocolVersion); + LogPrintf("dseg - Sent 1 masternode entries to %s\n", pfrom->addr.ToString().c_str()); + return; + } + i++; + } + + LogPrintf("dseg - Sent %d masternode entries to %s\n", count, pfrom->addr.ToString().c_str()); + } + + else if (strCommand == "mnget") { //Masternode Payments Request Sync + if(fLiteMode) return; //disable all darksend/masternode related functionality + + /*if(pfrom->HasFulfilledRequest("mnget")) { + LogPrintf("mnget - peer already asked me for the list\n"); + Misbehaving(pfrom->GetId(), 20); + return; + }*/ + + pfrom->FulfilledRequest("mnget"); + masternodePayments.Sync(pfrom); + LogPrintf("mnget - Sent masternode winners to %s\n", pfrom->addr.ToString().c_str()); + } + else if (strCommand == "mnw") { //Masternode Payments Declare Winner + //this is required in litemode + CMasternodePaymentWinner winner; + int a = 0; + vRecv >> winner >> a; + + if(pindexBest == NULL) return; + + uint256 hash = winner.GetHash(); + if(mapSeenMasternodeVotes.count(hash)) { + if(fDebug) LogPrintf("mnw - seen vote %s Height %d bestHeight %d\n", hash.ToString().c_str(), winner.nBlockHeight, pindexBest->nHeight); + return; + } + + if(winner.nBlockHeight < pindexBest->nHeight - 10 || winner.nBlockHeight > pindexBest->nHeight+20){ + LogPrintf("mnw - winner out of range %s Height %d bestHeight %d\n", winner.vin.ToString().c_str(), winner.nBlockHeight, pindexBest->nHeight); + return; + } + + if(winner.vin.nSequence != std::numeric_limits::max()){ + LogPrintf("mnw - invalid nSequence\n"); + Misbehaving(pfrom->GetId(), 100); + return; + } + + LogPrintf("mnw - winning vote %s Height %d bestHeight %d\n", winner.vin.ToString().c_str(), winner.nBlockHeight, pindexBest->nHeight); + + if(!masternodePayments.CheckSignature(winner)){ + LogPrintf("mnw - invalid signature\n"); + Misbehaving(pfrom->GetId(), 100); + return; + } + + mapSeenMasternodeVotes.insert(make_pair(hash, winner)); + + if(masternodePayments.AddWinningMasternode(winner)){ + masternodePayments.Relay(winner); + } + } +} + +struct CompareValueOnly +{ + bool operator()(const pair& t1, + const pair& t2) const + { + return t1.first < t2.first; + } +}; + +struct CompareValueOnly2 +{ + bool operator()(const pair& t1, + const pair& t2) const + { + return t1.first < t2.first; + } +}; + +int CountMasternodesAboveProtocol(int protocolVersion) +{ + int i = 0; + LOCK(cs_masternodes); + BOOST_FOREACH(CMasterNode& mn, vecMasternodes) { + if(mn.protocolVersion < protocolVersion) continue; + i++; + } + + return i; + +} + + +int GetMasternodeByVin(CTxIn& vin) +{ + int i = 0; + LOCK(cs_masternodes); + BOOST_FOREACH(CMasterNode& mn, vecMasternodes) { + if (mn.vin == vin) return i; + i++; + } + + return -1; +} + +int GetCurrentMasterNode(int mod, int64_t nBlockHeight, int minProtocol) +{ + int i = 0; + unsigned int score = 0; + int winner = -1; + LOCK(cs_masternodes); + // scan for winner + BOOST_FOREACH(CMasterNode mn, vecMasternodes) { + mn.Check(); + if(mn.protocolVersion < minProtocol) continue; + if(!mn.IsEnabled()) { + i++; + continue; + } + + // calculate the score for each masternode + uint256 n = mn.CalculateScore(mod, nBlockHeight); + unsigned int n2 = 0; + memcpy(&n2, &n, sizeof(n2)); + + // determine the winner + if(n2 > score){ + score = n2; + winner = i; + } + i++; + } + + return winner; +} + +int GetMasternodeByRank(int findRank, int64_t nBlockHeight, int minProtocol) +{ + LOCK(cs_masternodes); + int i = 0; + + std::vector > vecMasternodeScores; + + i = 0; + BOOST_FOREACH(CMasterNode mn, vecMasternodes) { + mn.Check(); + if(mn.protocolVersion < minProtocol) continue; + if(!mn.IsEnabled()) { + i++; + continue; + } + + uint256 n = mn.CalculateScore(1, nBlockHeight); + unsigned int n2 = 0; + memcpy(&n2, &n, sizeof(n2)); + + vecMasternodeScores.push_back(make_pair(n2, i)); + i++; + } + + sort(vecMasternodeScores.rbegin(), vecMasternodeScores.rend(), CompareValueOnly2()); + + int rank = 0; + BOOST_FOREACH (PAIRTYPE(unsigned int, int)& s, vecMasternodeScores){ + rank++; + if(rank == findRank) return s.second; + } + + return -1; +} + +int GetMasternodeRank(CTxIn& vin, int64_t nBlockHeight, int minProtocol) +{ + LOCK(cs_masternodes); + std::vector > vecMasternodeScores; + + BOOST_FOREACH(CMasterNode& mn, vecMasternodes) { + mn.Check(); + + if(mn.protocolVersion < minProtocol) continue; + if(!mn.IsEnabled()) { + continue; + } + + uint256 n = mn.CalculateScore(1, nBlockHeight); + unsigned int n2 = 0; + memcpy(&n2, &n, sizeof(n2)); + + vecMasternodeScores.push_back(make_pair(n2, mn.vin)); + } + + sort(vecMasternodeScores.rbegin(), vecMasternodeScores.rend(), CompareValueOnly()); + + unsigned int rank = 0; + BOOST_FOREACH (PAIRTYPE(unsigned int, CTxIn)& s, vecMasternodeScores){ + rank++; + if(s.second == vin) { + return rank; + } + } + + return -1; +} + +//Get the last hash that matches the modulus given. Processed in reverse order +bool GetBlockHash(uint256& hash, int nBlockHeight) +{ + if (pindexBest == NULL) return false; + + if(nBlockHeight == 0) + nBlockHeight = pindexBest->nHeight; + + if(mapCacheBlockHashes.count(nBlockHeight)){ + hash = mapCacheBlockHashes[nBlockHeight]; + return true; + } + + const CBlockIndex *BlockLastSolved = pindexBest; + const CBlockIndex *BlockReading = pindexBest; + + if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || pindexBest->nHeight+1 < nBlockHeight) return false; + + int nBlocksAgo = 0; + if(nBlockHeight > 0) nBlocksAgo = (pindexBest->nHeight+1)-nBlockHeight; + assert(nBlocksAgo >= 0); + + int n = 0; + for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) { + if(n >= nBlocksAgo){ + hash = BlockReading->GetBlockHash(); + mapCacheBlockHashes[nBlockHeight] = hash; + return true; + } + n++; + + if (BlockReading->pprev == NULL) { assert(BlockReading); break; } + BlockReading = BlockReading->pprev; + } + + return false; +} + +// +// Deterministically calculate a given "score" for a masternode depending on how close it's hash is to +// the proof of work for that block. The further away they are the better, the furthest will win the election +// and get paid this block +// +uint256 CMasterNode::CalculateScore(int mod, int64_t nBlockHeight) +{ + if(pindexBest == NULL) return 0; + + uint256 hash = 0; + uint256 aux = vin.prevout.hash + vin.prevout.n; + + if(!GetBlockHash(hash, nBlockHeight)) return 0; + + uint256 hash2 = Hash(BEGIN(hash), END(hash)); + uint256 hash3 = Hash(BEGIN(hash), END(aux)); + + uint256 r = (hash3 > hash2 ? hash3 - hash2 : hash2 - hash3); + + return r; +} + +void CMasterNode::Check() +{ + //once spent, stop doing the checks + if(enabled==3) return; + + + if(!UpdatedWithin(MASTERNODE_REMOVAL_SECONDS)){ + enabled = 4; + return; + } + + if(!UpdatedWithin(MASTERNODE_EXPIRATION_SECONDS)){ + enabled = 2; + return; + } + + + if(!unitTest){ + CValidationState state; + CTransaction tx = CTransaction(); + CTxOut vout = CTxOut((GetMNCollateral(pindexBest->nHeight)-1)*COIN, darkSendPool.collateralPubKey); + tx.vin.push_back(vin); + tx.vout.push_back(vout); + + //if(!AcceptableInputs(mempool, state, tx)){ + bool pfMissingInputs; + if(!AcceptableInputs(mempool, tx, false, &pfMissingInputs)){ + enabled = 3; + return; + } + } + + enabled = 1; // OK +} + +bool CMasternodePayments::CheckSignature(CMasternodePaymentWinner& winner) +{ + //note: need to investigate why this is failing + std::string strMessage = winner.vin.ToString().c_str() + boost::lexical_cast(winner.nBlockHeight) + winner.payee.ToString(); + std::string strPubKey = strMainPubKey ; + CPubKey pubkey(ParseHex(strPubKey)); + + std::string errorMessage = ""; + if(!darkSendSigner.VerifyMessage(pubkey, winner.vchSig, strMessage, errorMessage)){ + return false; + } + + return true; +} + +bool CMasternodePayments::Sign(CMasternodePaymentWinner& winner) +{ + std::string strMessage = winner.vin.ToString().c_str() + boost::lexical_cast(winner.nBlockHeight) + winner.payee.ToString(); + + CKey key2; + CPubKey pubkey2; + std::string errorMessage = ""; + + if(!darkSendSigner.SetKey(strMasterPrivKey, errorMessage, key2, pubkey2)) + { + LogPrintf("CMasternodePayments::Sign - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage.c_str()); + return false; + } + + if(!darkSendSigner.SignMessage(strMessage, errorMessage, winner.vchSig, key2)) { + LogPrintf("CMasternodePayments::Sign - Sign message failed"); + return false; + } + + if(!darkSendSigner.VerifyMessage(pubkey2, winner.vchSig, strMessage, errorMessage)) { + LogPrintf("CMasternodePayments::Sign - Verify message failed"); + return false; + } + + return true; +} + +uint64_t CMasternodePayments::CalculateScore(uint256 blockHash, CTxIn& vin) +{ + uint256 n1 = blockHash; + uint256 n2 = Hash(BEGIN(n1), END(n1)); + uint256 n3 = Hash(BEGIN(vin.prevout.hash), END(vin.prevout.hash)); + uint256 n4 = n3 > n2 ? (n3 - n2) : (n2 - n3); + + printf(" -- CMasternodePayments CalculateScore() n2 = %d \n", n2.Get64()); + printf(" -- CMasternodePayments CalculateScore() n3 = %d \n", n3.Get64()); + printf(" -- CMasternodePayments CalculateScore() n4 = %d \n", n4.Get64()); + + return n4.Get64(); +} + +bool CMasternodePayments::GetBlockPayee(int nBlockHeight, CScript& payee) +{ + BOOST_FOREACH(CMasternodePaymentWinner& winner, vWinning){ + if(winner.nBlockHeight == nBlockHeight) { + payee = winner.payee; + return true; + } + } + + return false; +} + +bool CMasternodePayments::GetWinningMasternode(int nBlockHeight, CTxIn& vinOut) +{ + BOOST_FOREACH(CMasternodePaymentWinner& winner, vWinning){ + if(winner.nBlockHeight == nBlockHeight) { + vinOut = winner.vin; + return true; + } + } + + return false; +} + +bool CMasternodePayments::AddWinningMasternode(CMasternodePaymentWinner& winnerIn) +{ + uint256 blockHash = 0; + if(!GetBlockHash(blockHash, winnerIn.nBlockHeight-576)) { + return false; + } + + winnerIn.score = CalculateScore(blockHash, winnerIn.vin); + + bool foundBlock = false; + BOOST_FOREACH(CMasternodePaymentWinner& winner, vWinning){ + if(winner.nBlockHeight == winnerIn.nBlockHeight) { + foundBlock = true; + if(winner.score < winnerIn.score){ + winner.score = winnerIn.score; + winner.vin = winnerIn.vin; + winner.payee = winnerIn.payee; + winner.vchSig = winnerIn.vchSig; + + return true; + } + } + } + + // if it's not in the vector + if(!foundBlock){ + vWinning.push_back(winnerIn); + mapSeenMasternodeVotes.insert(make_pair(winnerIn.GetHash(), winnerIn)); + + return true; + } + + return false; +} + +void CMasternodePayments::CleanPaymentList() +{ + LOCK(cs_masternodes); + if(pindexBest == NULL) return; + + int nLimit = std::max(((int)vecMasternodes.size())*2, 1000); + + vector::iterator it; + for(it=vWinning.begin();itnHeight - (*it).nBlockHeight > nLimit){ + if(fDebug) LogPrintf("CMasternodePayments::CleanPaymentList - Removing old masternode payment - block %d\n", (*it).nBlockHeight); + vWinning.erase(it); + break; + } + } +} + +bool CMasternodePayments::ProcessBlock(int nBlockHeight) +{ + LOCK(cs_masternodes); + if(!enabled) return false; + CMasternodePaymentWinner winner; + + std::vector vecLastPayments; + int c = 0; + BOOST_REVERSE_FOREACH(CMasternodePaymentWinner& winner, vWinning){ + vecLastPayments.push_back(winner.vin); + //if we have one full payment cycle, break + if(++c > (int)vecMasternodes.size()) break; + } + + std::random_shuffle ( vecMasternodes.begin(), vecMasternodes.end() ); + BOOST_FOREACH(CMasterNode& mn, vecMasternodes) { + bool found = false; + BOOST_FOREACH(CTxIn& vin, vecLastPayments) + if(mn.vin == vin) found = true; + + if(found) continue; + + mn.Check(); + if(!mn.IsEnabled()) { + continue; + } + + winner.score = 0; + winner.nBlockHeight = nBlockHeight; + winner.vin = mn.vin; + winner.payee =GetScriptForDestination(mn.pubkey.GetID()); + + break; + } + + //if we can't find someone to get paid, pick randomly + if(winner.nBlockHeight == 0 && vecMasternodes.size() > 0) { + winner.score = 0; + winner.nBlockHeight = nBlockHeight; + winner.vin = vecMasternodes[0].vin; + winner.payee =GetScriptForDestination(vecMasternodes[0].pubkey.GetID()); + } + + if(Sign(winner)){ + if(AddWinningMasternode(winner)){ + Relay(winner); + return true; + } + } + + return false; +} + +void CMasternodePayments::Relay(CMasternodePaymentWinner& winner) +{ + CInv inv(MSG_MASTERNODE_WINNER, winner.GetHash()); + + vector vInv; + vInv.push_back(inv); + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes){ + pnode->PushMessage("inv", vInv); + } +} + +void CMasternodePayments::Sync(CNode* node) +{ + int a = 0; + BOOST_FOREACH(CMasternodePaymentWinner& winner, vWinning) + if(winner.nBlockHeight >= pindexBest->nHeight-10 && winner.nBlockHeight <= pindexBest->nHeight + 20) + node->PushMessage("mnw", winner, a); +} + + +bool CMasternodePayments::SetPrivKey(std::string strPrivKey) +{ + CMasternodePaymentWinner winner; + + // Test signing successful, proceed + strMasterPrivKey = strPrivKey; + + Sign(winner); + + if(CheckSignature(winner)){ + LogPrintf("CMasternodePayments::SetPrivKey - Successfully initialized as masternode payments master\n"); + enabled = true; + return true; + } else { + return false; + } +} diff --git a/src/masternode.h b/src/masternode.h new file mode 100644 index 0000000..07fc0c0 --- /dev/null +++ b/src/masternode.h @@ -0,0 +1,248 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Darkcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef MASTERNODE_H +#define MASTERNODE_H + +#include "uint256.h" +#include "uint256.h" +#include "sync.h" +#include "net.h" +#include "key.h" +#include "util.h" +#include "base58.h" +#include "main.h" +#include "timedata.h" +#include "script.h" + +class CMasterNode; +class CMasternodePayments; +class uint256; + +#define MASTERNODE_NOT_PROCESSED 0 // initial state +#define MASTERNODE_IS_CAPABLE 1 +#define MASTERNODE_NOT_CAPABLE 2 +#define MASTERNODE_STOPPED 3 +#define MASTERNODE_INPUT_TOO_NEW 4 +#define MASTERNODE_PORT_NOT_OPEN 6 +#define MASTERNODE_PORT_OPEN 7 +#define MASTERNODE_SYNC_IN_PROCESS 8 +#define MASTERNODE_REMOTELY_ENABLED 9 + +#define MASTERNODE_MIN_CONFIRMATIONS 7 +#define MASTERNODE_MIN_DSEEP_SECONDS (30*60) +#define MASTERNODE_MIN_DSEE_SECONDS (5*60) +#define MASTERNODE_PING_SECONDS (1*60) //(1*60) +#define MASTERNODE_PING_WAIT_SECONDS (5*60) +#define MASTERNODE_EXPIRATION_SECONDS (65*60) //Old 65*60 +#define MASTERNODE_REMOVAL_SECONDS (70*60) //Old 70*60 + +using namespace std; + +class CMasternodePaymentWinner; + +extern CCriticalSection cs_masternodes; +extern std::vector vecMasternodes; +extern CMasternodePayments masternodePayments; +extern std::vector vecMasternodeAskedFor; +extern map mapSeenMasternodeVotes; +extern map mapCacheBlockHashes; + + +// manage the masternode connections +void ProcessMasternodeConnections(); +int CountMasternodesAboveProtocol(int protocolVersion); + + +void ProcessMessageMasternode(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); + +// +// The Masternode Class. For managing the darksend process. It contains the input of the 1000SONO, signature to prove +// it's the one who own that ip address and code for calculating the payment election. +// +class CMasterNode +{ +public: + static int minProtoVersion; + CService addr; + CTxIn vin; + int64_t lastTimeSeen; + CPubKey pubkey; + CPubKey pubkey2; + std::vector sig; + int64_t now; //dsee message times + int64_t lastDseep; + int cacheInputAge; + int cacheInputAgeBlock; + int enabled; + bool unitTest; + bool allowFreeTx; + int protocolVersion; + + //the dsq count from the last dsq broadcast of this node + int64_t nLastDsq; + + CMasterNode(CService newAddr, CTxIn newVin, CPubKey newPubkey, std::vector newSig, int64_t newNow, CPubKey newPubkey2, int protocolVersionIn) + { + addr = newAddr; + vin = newVin; + pubkey = newPubkey; + pubkey2 = newPubkey2; + sig = newSig; + now = newNow; + enabled = 1; + lastTimeSeen = 0; + unitTest = false; + cacheInputAge = 0; + cacheInputAgeBlock = 0; + nLastDsq = 0; + lastDseep = 0; + allowFreeTx = true; + protocolVersion = protocolVersionIn; + } + + uint256 CalculateScore(int mod=1, int64_t nBlockHeight=0); + + void UpdateLastSeen(int64_t override=0) + { + if(override == 0){ + lastTimeSeen = GetAdjustedTime(); + } else { + lastTimeSeen = override; + } + } + + inline uint64_t SliceHash(uint256& hash, int slice) + { + uint64_t n = 0; + memcpy(&n, &hash+slice*64, 64); + return n; + } + + void Check(); + + bool UpdatedWithin(int seconds) + { + //LogPrintf("UpdatedWithin %d, %d -- %d \n", GetAdjustedTime() , lastTimeSeen, (GetAdjustedTime() - lastTimeSeen) < seconds); + + return (GetAdjustedTime() - lastTimeSeen) < seconds; + } + + void Disable() + { + lastTimeSeen = 0; + } + + bool IsEnabled() + { + return enabled == 1; + } + + int GetMasternodeInputAge() + { + if(pindexBest == NULL) return 0; + + if(cacheInputAge == 0){ + cacheInputAge = GetInputAge(vin); + cacheInputAgeBlock = pindexBest->nHeight; + } + + return cacheInputAge+(pindexBest->nHeight-cacheInputAgeBlock); + } +}; + + +// Get the current winner for this block +int GetCurrentMasterNode(int mod=1, int64_t nBlockHeight=0, int minProtocol=CMasterNode::minProtoVersion); + +int GetMasternodeByVin(CTxIn& vin); +int GetMasternodeRank(CTxIn& vin, int64_t nBlockHeight=0, int minProtocol=CMasterNode::minProtoVersion); +int GetMasternodeByRank(int findRank, int64_t nBlockHeight=0, int minProtocol=CMasterNode::minProtoVersion); + + +// for storing the winning payments +class CMasternodePaymentWinner +{ +public: + int nBlockHeight; + CTxIn vin; + CScript payee; + std::vector vchSig; + uint64_t score; + + CMasternodePaymentWinner() { + nBlockHeight = 0; + score = 0; + vin = CTxIn(); + payee = CScript(); + } + + uint256 GetHash(){ + uint256 n2 = Hash(BEGIN(nBlockHeight), END(nBlockHeight)); + uint256 n3 = vin.prevout.hash > n2 ? (vin.prevout.hash - n2) : (n2 - vin.prevout.hash); + + return n3; + } + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion){ + unsigned int nSerSize = 0; + READWRITE(nBlockHeight); + READWRITE(payee); + READWRITE(vin); + READWRITE(score); + READWRITE(vchSig); + } +}; + +// +// Masternode Payments Class +// Keeps track of who should get paid for which blocks +// + +class CMasternodePayments +{ +private: + std::vector vWinning; + int nSyncedFromPeer; + std::string strMasterPrivKey; + std::string strTestPubKey; + std::string strMainPubKey; + bool enabled; + +public: + + CMasternodePayments() { + strMainPubKey = "04fc6ba06e04030703953aaf72fdd41025ab891070acdfa49f9cae88c49ac7cbfbd43bb3b737e4bb40bdf7522543d04033e5759a8099f2eb11cd6ab699f7aabccb"; + strTestPubKey = "04fc6ba06e04030703953aaf72fdd41025ab891070acdfa49f9cae88c49ac7cbfbd43bb3b737e4bb40bdf7522543d04033e5759a8099f2eb11cd6ab699f7aabccb"; + enabled = false; + } + + bool SetPrivKey(std::string strPrivKey); + bool CheckSignature(CMasternodePaymentWinner& winner); + bool Sign(CMasternodePaymentWinner& winner); + + // Deterministically calculate a given "score" for a masternode depending on how close it's hash is + // to the blockHeight. The further away they are the better, the furthest will win the election + // and get paid this block + // + + uint64_t CalculateScore(uint256 blockHash, CTxIn& vin); + bool GetWinningMasternode(int nBlockHeight, CTxIn& vinOut); + bool AddWinningMasternode(CMasternodePaymentWinner& winner); + bool ProcessBlock(int nBlockHeight); + void Relay(CMasternodePaymentWinner& winner); + void Sync(CNode* node); + void CleanPaymentList(); + int LastPayment(CMasterNode& mn); + + //slow + bool GetBlockPayee(int nBlockHeight, CScript& payee); +}; + + + +#endif diff --git a/src/masternodeconfig.cpp b/src/masternodeconfig.cpp new file mode 100644 index 0000000..dc14fcb --- /dev/null +++ b/src/masternodeconfig.cpp @@ -0,0 +1,52 @@ + +#include "net.h" +#include "masternodeconfig.h" +#include "util.h" + +CMasternodeConfig masternodeConfig; + +void CMasternodeConfig::add(std::string alias, std::string ip, std::string privKey, std::string txHash, std::string outputIndex) { + CMasternodeEntry cme(alias, ip, privKey, txHash, outputIndex); + entries.push_back(cme); +} + +bool CMasternodeConfig::read(boost::filesystem::path path) { + boost::filesystem::ifstream streamConfig(GetMasternodeConfigFile()); + if (!streamConfig.good()) { + return true; // No masternode.conf file is OK + } + + for(std::string line; std::getline(streamConfig, line); ) + { + if(line.empty()) { + continue; + } + std::istringstream iss(line); + std::string alias, ip, privKey, txHash, outputIndex; + if (!(iss >> alias >> ip >> privKey >> txHash >> outputIndex)) { + LogPrintf("CMasternodeConfig::read - Could not parse masternode.conf. Line: %s\n", line.c_str()); + streamConfig.close(); + return false; + } + + /* if(Params().NetworkID() == CChainParams::MAIN){ + if(CService(ip).GetPort() != 28666) { + LogPrintf("Invalid port detected in masternode.conf: %s (must be 17170 for mainnet)\n", line.c_str()); + streamConfig.close(); + return false; + } + } else if(CService(ip).GetPort() == 28666) { + LogPrintf("Invalid port detected in masternode.conf: %s (17170 must be only on mainnet)\n", line.c_str()); + streamConfig.close(); + return false; + } +*/ + if (!(CService(ip).IsIPv4() && CService(ip).IsRoutable())) { + LogPrintf("Invalid Address detected in masternode.conf: %s (IPV4 ONLY) \n", line.c_str()); + streamConfig.close(); + return false; + } + + add(alias, ip, privKey, txHash, outputIndex); + } +} diff --git a/src/masternodeconfig.h b/src/masternodeconfig.h new file mode 100644 index 0000000..9f56da5 --- /dev/null +++ b/src/masternodeconfig.h @@ -0,0 +1,102 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef SRC_MASTERNODECONFIG_H_ +#define SRC_MASTERNODECONFIG_H_ + +#include +#include + +#include +#include + +class CMasternodeConfig; +extern CMasternodeConfig masternodeConfig; + +class CMasternodeConfig +{ + +public: + class CMasternodeEntry { + + private: + std::string alias; + std::string ip; + std::string privKey; + std::string txHash; + std::string outputIndex; + + public: + + CMasternodeEntry(std::string alias, std::string ip, std::string privKey, std::string txHash, std::string outputIndex) { + this->alias = alias; + this->ip = ip; + this->privKey = privKey; + this->txHash = txHash; + this->outputIndex = outputIndex; + } + + const std::string& getAlias() const { + return alias; + } + + void setAlias(const std::string& alias) { + this->alias = alias; + } + + const std::string& getOutputIndex() const { + return outputIndex; + } + + void setOutputIndex(const std::string& outputIndex) { + this->outputIndex = outputIndex; + } + + const std::string& getPrivKey() const { + return privKey; + } + + void setPrivKey(const std::string& privKey) { + this->privKey = privKey; + } + + const std::string& getTxHash() const { + return txHash; + } + + void setTxHash(const std::string& txHash) { + this->txHash = txHash; + } + + const std::string& getIp() const { + return ip; + } + + void setIp(const std::string& ip) { + this->ip = ip; + } + }; + + CMasternodeConfig() { + entries = std::vector(); + } + + void clear(); + bool read(boost::filesystem::path path); + void add(std::string alias, std::string ip, std::string privKey, std::string txHash, std::string outputIndex); + + std::vector& getEntries() { + return entries; + } + +private: + std::vector entries; + + +}; + + +#endif /* SRC_MASTERNODECONFIG_H_ */ + diff --git a/src/miner.cpp b/src/miner.cpp new file mode 100644 index 0000000..88ca410 --- /dev/null +++ b/src/miner.cpp @@ -0,0 +1,573 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2013 The NovaCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "txdb.h" +#include "miner.h" +#include "kernel.h" +#include "masternode.h" + + +using namespace std; + + +// Implemented SONO parallel miner | Auto deploy + +extern unsigned int nMinerSleep; + +int static FormatHashBlocks(void* pbuffer, unsigned int len) +{ + unsigned char* pdata = (unsigned char*)pbuffer; + unsigned int blocks = 1 + ((len + 8) / 64); + unsigned char* pend = pdata + 64 * blocks; + memset(pdata + len, 0, 64 * blocks - len); + pdata[len] = 0x80; + unsigned int bits = len * 8; + pend[-1] = (bits >> 0) & 0xff; + pend[-2] = (bits >> 8) & 0xff; + pend[-3] = (bits >> 16) & 0xff; + pend[-4] = (bits >> 24) & 0xff; + return blocks; +} + +static const unsigned int pSHA256InitState[8] = +{0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; + +void SHA256Transform(void* pstate, void* pinput, const void* pinit) +{ + SHA256_CTX ctx; + unsigned char data[64]; + + SHA256_Init(&ctx); + + for (int i = 0; i < 16; i++) + ((uint32_t*)data)[i] = ByteReverse(((uint32_t*)pinput)[i]); + + for (int i = 0; i < 8; i++) + ctx.h[i] = ((uint32_t*)pinit)[i]; + + SHA256_Update(&ctx, data, sizeof(data)); + for (int i = 0; i < 8; i++) + ((uint32_t*)pstate)[i] = ctx.h[i]; +} + +// Some explaining would be appreciated +class COrphan +{ +public: + CTransaction* ptx; + set setDependsOn; + double dPriority; + double dFeePerKb; + + COrphan(CTransaction* ptxIn) + { + ptx = ptxIn; + dPriority = dFeePerKb = 0; + } +}; + + +uint64_t nLastBlockTx = 0; +uint64_t nLastBlockSize = 0; +int64_t nLastCoinStakeSearchInterval = 0; + +// We want to sort transactions by priority and fee, so: +typedef boost::tuple TxPriority; +class TxPriorityCompare +{ + bool byFee; +public: + TxPriorityCompare(bool _byFee) : byFee(_byFee) { } + bool operator()(const TxPriority& a, const TxPriority& b) + { + if (byFee) + { + if (a.get<1>() == b.get<1>()) + return a.get<0>() < b.get<0>(); + return a.get<1>() < b.get<1>(); + } + else + { + if (a.get<0>() == b.get<0>()) + return a.get<1>() < b.get<1>(); + return a.get<0>() < b.get<0>(); + } + } +}; + +// CreateNewBlock: create new block (without proof-of-work/proof-of-stake) +CBlock* CreateNewBlock(CReserveKey& reservekey, bool fProofOfStake, int64_t* pFees) +{ + // Create new block + auto_ptr pblock(new CBlock()); + if (!pblock.get()) + return NULL; + + CBlockIndex* pindexPrev = pindexBest; + int nHeight = pindexPrev->nHeight + 1; + + // Create coinbase tx + CTransaction txNew; + txNew.vin.resize(1); + txNew.vin[0].prevout.SetNull(); + txNew.vout.resize(1); + + if (!fProofOfStake) + { + CPubKey pubkey; + if (!reservekey.GetReservedKey(pubkey)) + return NULL; + txNew.vout[0].scriptPubKey.SetDestination(pubkey.GetID()); + } + else + { + // Height first in coinbase required for block.version=2 + txNew.vin[0].scriptSig = (CScript() << nHeight) + COINBASE_FLAGS; + assert(txNew.vin[0].scriptSig.size() <= 100); + + txNew.vout[0].SetEmpty(); + } + + // Add our coinbase tx as first transaction + pblock->vtx.push_back(txNew); + + // Largest block you're willing to create: + unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2); + // Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity: + nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize)); + + // How much of the block should be dedicated to high-priority transactions, + // included regardless of the fees they pay + unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", 27000); + nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize); + + // Minimum block size you want to create; block will be filled with free transactions + // until there are no more or the block reaches this size: + unsigned int nBlockMinSize = GetArg("-blockminsize", 0); + nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); + + // Fee-per-kilobyte amount considered the same as "free" + // Be careful setting this: if you set it to zero then + // a transaction spammer can cheaply fill blocks using + // 1-satoshi-fee transactions. It should be set above the real + // cost to you of processing a transaction. + int64_t nMinTxFee = MIN_TX_FEE; + if (mapArgs.count("-mintxfee")) + ParseMoney(mapArgs["-mintxfee"], nMinTxFee); + + pblock->nBits = GetNextTargetRequired(pindexPrev, fProofOfStake); + + + // Collect memory pool transactions into the block + int64_t nFees = 0; + { + LOCK2(cs_main, mempool.cs); + CTxDB txdb("r"); +//>SONO< + // Priority order to process transactions + list vOrphan; // list memory doesn't move + map > mapDependers; + + // This vector will be sorted into a priority queue: + vector vecPriority; + vecPriority.reserve(mempool.mapTx.size()); + for (map::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi) + { + CTransaction& tx = (*mi).second; + if (tx.IsCoinBase() || tx.IsCoinStake() || !IsFinalTx(tx, nHeight)) + continue; + + COrphan* porphan = NULL; + double dPriority = 0; + int64_t nTotalIn = 0; + bool fMissingInputs = false; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + // Read prev transaction + CTransaction txPrev; + CTxIndex txindex; + if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex)) + { + // This should never happen; all transactions in the memory + // pool should connect to either transactions in the chain + // or other transactions in the memory pool. + if (!mempool.mapTx.count(txin.prevout.hash)) + { + LogPrintf("ERROR: mempool transaction missing input\n"); + if (fDebug) assert("mempool transaction missing input" == 0); + fMissingInputs = true; + if (porphan) + vOrphan.pop_back(); + break; + } + + // Has to wait for dependencies + if (!porphan) + { + // Use list for automatic deletion + vOrphan.push_back(COrphan(&tx)); + porphan = &vOrphan.back(); + } + mapDependers[txin.prevout.hash].push_back(porphan); + porphan->setDependsOn.insert(txin.prevout.hash); + nTotalIn += mempool.mapTx[txin.prevout.hash].vout[txin.prevout.n].nValue; + continue; + } + int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue; + nTotalIn += nValueIn; + + int nConf = txindex.GetDepthInMainChain(); + dPriority += (double)nValueIn * nConf; + } + if (fMissingInputs) continue; + + // Priority is sum(valuein * age) / txsize + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + dPriority /= nTxSize; + + // This is a more accurate fee-per-kilobyte than is used by the client code, because the + // client code rounds up the size to the nearest 1K. That's good, because it gives an + // incentive to create smaller transactions. + double dFeePerKb = double(nTotalIn-tx.GetValueOut()) / (double(nTxSize)/1000.0); + + if (porphan) + { + porphan->dPriority = dPriority; + porphan->dFeePerKb = dFeePerKb; + } + else + vecPriority.push_back(TxPriority(dPriority, dFeePerKb, &(*mi).second)); + } + + // Collect transactions into block + map mapTestPool; + uint64_t nBlockSize = 1000; + uint64_t nBlockTx = 0; + int nBlockSigOps = 100; + bool fSortedByFee = (nBlockPrioritySize <= 0); + + TxPriorityCompare comparer(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + + while (!vecPriority.empty()) + { + // Take highest priority transaction off the priority queue: + double dPriority = vecPriority.front().get<0>(); + double dFeePerKb = vecPriority.front().get<1>(); + CTransaction& tx = *(vecPriority.front().get<2>()); + + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); + + // Size limits + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + if (nBlockSize + nTxSize >= nBlockMaxSize) + continue; + + // Legacy limits on sigOps: + unsigned int nTxSigOps = GetLegacySigOpCount(tx); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) + continue; + + // Timestamp limit + if (tx.nTime > GetAdjustedTime() || (fProofOfStake && tx.nTime > pblock->vtx[0].nTime)) + continue; + + // Transaction fee + int64_t nMinFee = GetMinFee(tx, nBlockSize, GMF_BLOCK); + + // Skip free transactions if we're past the minimum block size: + if (fSortedByFee && (dFeePerKb < nMinTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) + continue; + + // Prioritize by fee once past the priority size or we run out of high-priority + // transactions: + if (!fSortedByFee && + ((nBlockSize + nTxSize >= nBlockPrioritySize) || (dPriority < COIN * 144 / 250))) + { + fSortedByFee = true; + comparer = TxPriorityCompare(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + } + + // Connecting shouldn't fail due to dependency on other memory pool transactions + // because we're already processing them in order of dependency + map mapTestPoolTmp(mapTestPool); + MapPrevTx mapInputs; + bool fInvalid; + if (!tx.FetchInputs(txdb, mapTestPoolTmp, false, true, mapInputs, fInvalid)) + continue; + + int64_t nTxFees = tx.GetValueIn(mapInputs)-tx.GetValueOut(); + if (nTxFees < nMinFee) + continue; + + nTxSigOps += GetP2SHSigOpCount(tx, mapInputs); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) + continue; + + // Note that flags: we don't want to set mempool/IsStandard() + // policy here, but we still have to ensure that the block we + // create only contains transactions that are valid in new blocks. + if (!tx.ConnectInputs(txdb, mapInputs, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, false, true, MANDATORY_SCRIPT_VERIFY_FLAGS)) + continue; + mapTestPoolTmp[tx.GetHash()] = CTxIndex(CDiskTxPos(1,1,1), tx.vout.size()); + swap(mapTestPool, mapTestPoolTmp); + + // Added + pblock->vtx.push_back(tx); + nBlockSize += nTxSize; + ++nBlockTx; + nBlockSigOps += nTxSigOps; + nFees += nTxFees; + + if (fDebug && GetBoolArg("-printpriority", false)) + { + LogPrintf("priority %.1f feeperkb %.1f txid %s\n", + dPriority, dFeePerKb, tx.GetHash().ToString()); + } + + // Add transactions that depend on this one to the priority queue + uint256 hash = tx.GetHash(); + if (mapDependers.count(hash)) + { + BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) + { + if (!porphan->setDependsOn.empty()) + { + porphan->setDependsOn.erase(hash); + if (porphan->setDependsOn.empty()) + { + vecPriority.push_back(TxPriority(porphan->dPriority, porphan->dFeePerKb, porphan->ptx)); + std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); + } + } + } + } + } + + nLastBlockTx = nBlockTx; + nLastBlockSize = nBlockSize; + + if (fDebug && GetBoolArg("-printpriority", false)) + LogPrintf("CreateNewBlock(): total size %u\n", nBlockSize); +// >SONO< + if (!fProofOfStake) + pblock->vtx[0].vout[0].nValue = GetProofOfWorkReward(nFees); + + if (pFees) + *pFees = nFees; + + // Fill in header + pblock->hashPrevBlock = pindexPrev->GetBlockHash(); + pblock->nTime = max(pindexPrev->GetPastTimeLimit()+1, pblock->GetMaxTransactionTime()); + if (!fProofOfStake) + pblock->UpdateTime(pindexPrev); + pblock->nNonce = 0; + } + + return pblock.release(); +} + + +void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce) +{ + // Update nExtraNonce + static uint256 hashPrevBlock; + if (hashPrevBlock != pblock->hashPrevBlock) + { + nExtraNonce = 0; + hashPrevBlock = pblock->hashPrevBlock; + } + ++nExtraNonce; + + unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2 + pblock->vtx[0].vin[0].scriptSig = (CScript() << nHeight << CBigNum(nExtraNonce)) + COINBASE_FLAGS; + assert(pblock->vtx[0].vin[0].scriptSig.size() <= 100); + + pblock->hashMerkleRoot = pblock->BuildMerkleTree(); +} + + +void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1) +{ + // + // Pre-build hash buffers + // + struct + { + struct unnamed2 + { + int nVersion; + uint256 hashPrevBlock; + uint256 hashMerkleRoot; + unsigned int nTime; + unsigned int nBits; + unsigned int nNonce; + } + block; + unsigned char pchPadding0[64]; + uint256 hash1; + unsigned char pchPadding1[64]; + } + tmp; + memset(&tmp, 0, sizeof(tmp)); + + tmp.block.nVersion = pblock->nVersion; + tmp.block.hashPrevBlock = pblock->hashPrevBlock; + tmp.block.hashMerkleRoot = pblock->hashMerkleRoot; + tmp.block.nTime = pblock->nTime; + tmp.block.nBits = pblock->nBits; + tmp.block.nNonce = pblock->nNonce; + + FormatHashBlocks(&tmp.block, sizeof(tmp.block)); + FormatHashBlocks(&tmp.hash1, sizeof(tmp.hash1)); + + // Byte swap all the input buffer + for (unsigned int i = 0; i < sizeof(tmp)/4; i++) + ((unsigned int*)&tmp)[i] = ByteReverse(((unsigned int*)&tmp)[i]); + + // Precalc the first half of the first hash, which stays constant + SHA256Transform(pmidstate, &tmp.block, pSHA256InitState); + + memcpy(pdata, &tmp.block, 128); + memcpy(phash1, &tmp.hash1, 64); +} + + +bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) +{ + uint256 hashBlock = pblock->GetHash(); + uint256 hashProof = pblock->GetPoWHash(); + uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); + + if(!pblock->IsProofOfWork()) + return error("CheckWork() : %s is not a proof-of-work block", hashBlock.GetHex()); + + if (hashProof > hashTarget) + return error("CheckWork() : proof-of-work not meeting target"); + + //// debug print + LogPrintf("CheckWork() : new proof-of-work block found \n proof hash: %s \ntarget: %s\n", hashProof.GetHex(), hashTarget.GetHex()); + LogPrintf("%s\n", pblock->ToString()); + LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue)); + + // Found a solution + { + LOCK(cs_main); + if (pblock->hashPrevBlock != hashBestChain) + return error("CheckWork() : generated block is stale"); + + // Remove key from key pool + reservekey.KeepKey(); + + // Track how many getdata requests this block gets + { + LOCK(wallet.cs_wallet); + wallet.mapRequestCount[hashBlock] = 0; + } + + // Process this block the same as if we had received it from another node + if (!ProcessBlock(NULL, pblock)) + return error("CheckWork() : ProcessBlock, block not accepted"); + } + + return true; +} + +bool CheckStake(CBlock* pblock, CWallet& wallet) +{ + uint256 proofHash = 0, hashTarget = 0; + uint256 hashBlock = pblock->GetHash(); + + if(!pblock->IsProofOfStake()) + return error("CheckStake() : %s is not a proof-of-stake block", hashBlock.GetHex()); + + // verify hash target and signature of coinstake tx + if (!CheckProofOfStake(mapBlockIndex[pblock->hashPrevBlock], pblock->vtx[1], pblock->nBits, proofHash, hashTarget)) + return error("CheckStake() : proof-of-stake checking failed"); + + //// debug print + LogPrintf("CheckStake() : new proof-of-stake block found \n hash: %s \nproofhash: %s \ntarget: %s\n", hashBlock.GetHex(), proofHash.GetHex(), hashTarget.GetHex()); + LogPrintf("%s\n", pblock->ToString()); + LogPrintf("out %s\n", FormatMoney(pblock->vtx[1].GetValueOut())); + + // Found a solution + { + LOCK(cs_main); + if (pblock->hashPrevBlock != hashBestChain) + return error("CheckStake() : generated block is stale"); + + // Track how many getdata requests this block gets + { + LOCK(wallet.cs_wallet); + wallet.mapRequestCount[hashBlock] = 0; + } + + // Process this block the same as if we had received it from another node + if (!ProcessBlock(NULL, pblock)) + return error("CheckStake() : ProcessBlock, block not accepted"); + } + + return true; +} + +void ThreadStakeMiner(CWallet *pwallet) +{ + SetThreadPriority(THREAD_PRIORITY_LOWEST); + + // Make this thread recognisable as the mining thread + RenameThread("SONO-miner"); + + CReserveKey reservekey(pwallet); + + bool fTryToSync = true; + + while (true) + { + while (pwallet->IsLocked()) + { + nLastCoinStakeSearchInterval = 0; + MilliSleep(1000); + } + + while (vNodes.size() < 3 || IsInitialBlockDownload()) + { + nLastCoinStakeSearchInterval = 0; + fTryToSync = true; + MilliSleep(1000); + } + + if (fTryToSync) + { + fTryToSync = false; + if (vNodes.size() < 3 || pindexBest->GetBlockTime() < GetTime() - 10 * 60) + { + MilliSleep(10000); + continue; + } + } + + // + // Create new block + // + int64_t nFees; + auto_ptr pblock(CreateNewBlock(reservekey, true, &nFees)); + if (!pblock.get()) + return; + + // Trying to sign a block + if (pblock->SignBlock(*pwallet, nFees)) + { + SetThreadPriority(THREAD_PRIORITY_NORMAL); + CheckStake(pblock.get(), *pwallet); + SetThreadPriority(THREAD_PRIORITY_LOWEST); + MilliSleep(500); + } + else + MilliSleep(nMinerSleep); + } +} diff --git a/src/miner.h b/src/miner.h new file mode 100644 index 0000000..d75de49 --- /dev/null +++ b/src/miner.h @@ -0,0 +1,30 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2013 The NovaCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef NOVACOIN_MINER_H +#define NOVACOIN_MINER_H + +#include "main.h" +#include "wallet.h" + +/* Generate a new block, without valid proof-of-work */ +CBlock* CreateNewBlock(CReserveKey& reservekey, bool fProofOfStake=false, int64_t* pFees = 0); + +/** Modify the extranonce in a block */ +void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce); + +/** Do mining precalculation */ +void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1); + +/** Check mined proof-of-work block */ +bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey); + +/** Check mined proof-of-stake block */ +bool CheckStake(CBlock* pblock, CWallet& wallet); + +/** Base sha256 mining transform */ +void SHA256Transform(void* pstate, void* pinput, const void* pinit); + +#endif // NOVACOIN_MINER_H diff --git a/src/mruset.h b/src/mruset.h new file mode 100644 index 0000000..3b8c30a --- /dev/null +++ b/src/mruset.h @@ -0,0 +1,65 @@ +// Copyright (c) 2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_MRUSET_H +#define BITCOIN_MRUSET_H + +#include +#include + +/** STL-like set container that only keeps the most recent N elements. */ +template class mruset +{ +public: + typedef T key_type; + typedef T value_type; + typedef typename std::set::iterator iterator; + typedef typename std::set::const_iterator const_iterator; + typedef typename std::set::size_type size_type; + +protected: + std::set set; + std::deque queue; + size_type nMaxSize; + +public: + mruset(size_type nMaxSizeIn = 0) { nMaxSize = nMaxSizeIn; } + iterator begin() const { return set.begin(); } + iterator end() const { return set.end(); } + size_type size() const { return set.size(); } + bool empty() const { return set.empty(); } + iterator find(const key_type& k) const { return set.find(k); } + size_type count(const key_type& k) const { return set.count(k); } + void clear() { set.clear(); queue.clear(); } + bool inline friend operator==(const mruset& a, const mruset& b) { return a.set == b.set; } + bool inline friend operator==(const mruset& a, const std::set& b) { return a.set == b; } + bool inline friend operator<(const mruset& a, const mruset& b) { return a.set < b.set; } + std::pair insert(const key_type& x) + { + std::pair ret = set.insert(x); + if (ret.second) + { + if (nMaxSize && queue.size() == nMaxSize) + { + set.erase(queue.front()); + queue.pop_front(); + } + queue.push_back(x); + } + return ret; + } + size_type max_size() const { return nMaxSize; } + size_type max_size(size_type s) + { + if (s) + while (queue.size() > s) + { + set.erase(queue.front()); + queue.pop_front(); + } + nMaxSize = s; + return nMaxSize; + } +}; + +#endif diff --git a/src/net.cpp b/src/net.cpp new file mode 100644 index 0000000..6a2848c --- /dev/null +++ b/src/net.cpp @@ -0,0 +1,1992 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "init.h" +#include "chainparams.h" +#include "db.h" +#include "net.h" +#include "main.h" +#include "addrman.h" +#include "ui_interface.h" +#include "darksend.h" +#include "wallet.h" + +#ifdef WIN32 +#include +#endif + +#ifdef USE_UPNP +#include +#include +#include +#include +#endif + +// Dump addresses to peers.dat every 15 minutes (900s) +#define DUMP_ADDRESSES_INTERVAL 900 + +using namespace std; +using namespace boost; + +static const int MAX_OUTBOUND_CONNECTIONS = 12; // Reduced to 12 connections. ( Manual edit to suit your needs) + +bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false); + + +struct LocalServiceInfo { + int nScore; + int nPort; +}; + +// +// Global state variables +// +bool fDiscover = true; +uint64_t nLocalServices = NODE_NETWORK; +static CCriticalSection cs_mapLocalHost; +static map mapLocalHost; +static bool vfReachable[NET_MAX] = {}; +static bool vfLimited[NET_MAX] = {}; +static CNode* pnodeLocalHost = NULL; +static CNode* pnodeSync = NULL; +uint64_t nLocalHostNonce = 0; +static std::vector vhListenSocket; +CAddrMan addrman; + +vector vNodes; +CCriticalSection cs_vNodes; +map mapRelay; +deque > vRelayExpiration; +CCriticalSection cs_mapRelay; +map mapAlreadyAskedFor; + +static deque vOneShots; +CCriticalSection cs_vOneShots; + +set setservAddNodeAddresses; +CCriticalSection cs_setservAddNodeAddresses; + +vector vAddedNodes; +CCriticalSection cs_vAddedNodes; + +NodeId nLastNodeId = 0; +CCriticalSection cs_nLastNodeId; + +static CSemaphore *semOutbound = NULL; + +// Signals for message handling +static CNodeSignals g_signals; +CNodeSignals& GetNodeSignals() { return g_signals; } + +void AddOneShot(string strDest) +{ + LOCK(cs_vOneShots); + vOneShots.push_back(strDest); +} + +unsigned short GetListenPort() +{ + return (unsigned short)(GetArg("-port", Params().GetDefaultPort())); +} + +// find 'best' local address for a particular peer +bool GetLocal(CService& addr, const CNetAddr *paddrPeer) +{ + if (fNoListen) + return false; + + int nBestScore = -1; + int nBestReachability = -1; + { + LOCK(cs_mapLocalHost); + for (map::iterator it = mapLocalHost.begin(); it != mapLocalHost.end(); it++) + { + int nScore = (*it).second.nScore; + int nReachability = (*it).first.GetReachabilityFrom(paddrPeer); + if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore)) + { + addr = CService((*it).first, (*it).second.nPort); + nBestReachability = nReachability; + nBestScore = nScore; + } + } + } + return nBestScore >= 0; +} + +// get best local address for a particular peer as a CAddress +// Otherwise, return the unroutable 0.0.0.0 but filled in with +// the normal parameters, since the IP may be changed to a useful +// one by discovery. +CAddress GetLocalAddress(const CNetAddr *paddrPeer) +{ + CAddress ret(CService("0.0.0.0",GetListenPort()),0); + CService addr; + if (GetLocal(addr, paddrPeer)) + { + ret = CAddress(addr); + } + ret.nServices = nLocalServices; + ret.nTime = GetAdjustedTime(); + return ret; +} + +bool RecvLine(SOCKET hSocket, string& strLine) +{ + strLine = ""; + while (!ShutdownRequested()) + { + char c; + int nBytes = recv(hSocket, &c, 1, MSG_DONTWAIT); + if(ShutdownRequested()) + return false; + + if (nBytes > 0) + { + if (c == '\n') + continue; + if (c == '\r') + return true; + strLine += c; + if (strLine.size() >= 9000) + return true; + } + else if (nBytes <= 0) + { + boost::this_thread::interruption_point(); + if (nBytes < 0) + { + int nErr = WSAGetLastError(); + if (nErr == WSAEMSGSIZE) + continue; + if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS) + { + MilliSleep(10); + continue; + } + } + if (!strLine.empty()) + return true; + if (nBytes == 0) + { + // socket closed + LogPrint("net", "socket closed\n"); + return false; + } + else + { + // socket error + int nErr = WSAGetLastError(); + LogPrint("net", "recv failed: %d\n", nErr); + return false; + } + } + } + return false; +} + +int GetnScore(const CService& addr) +{ + LOCK(cs_mapLocalHost); + if (mapLocalHost.count(addr) == LOCAL_NONE) + return 0; + return mapLocalHost[addr].nScore; +} + +// Is our peer's addrLocal potentially useful as an external IP source? +bool IsPeerAddrLocalGood(CNode *pnode) +{ + return fDiscover && pnode->addr.IsRoutable() && pnode->addrLocal.IsRoutable() && + !IsLimited(pnode->addrLocal.GetNetwork()); +} + +// pushes our own address to a peer +void AdvertizeLocal(CNode *pnode) +{ + if (!fNoListen && pnode->fSuccessfullyConnected) + { + CAddress addrLocal = GetLocalAddress(&pnode->addr); + // If discovery is enabled, sometimes give our peer the address it + // tells us that it sees us as in case it has a better idea of our + // address than we do. + if (IsPeerAddrLocalGood(pnode) && (!addrLocal.IsRoutable() || + GetRand((GetnScore(addrLocal) > LOCAL_MANUAL) ? 8:2) == 0)) + { + addrLocal.SetIP(pnode->addrLocal); + } + if (addrLocal.IsRoutable()) + { + pnode->PushAddress(addrLocal); + } + } +} + +void SetReachable(enum Network net, bool fFlag) +{ + LOCK(cs_mapLocalHost); + vfReachable[net] = fFlag; + if (net == NET_IPV6 && fFlag) + vfReachable[NET_IPV4] = true; +} + +// learn a new local address +bool AddLocal(const CService& addr, int nScore) +{ + if (!addr.IsRoutable()) + return false; + + if (!fDiscover && nScore < LOCAL_MANUAL) + return false; + + if (IsLimited(addr)) + return false; + + LogPrintf("AddLocal(%s,%i)\n", addr.ToString(), nScore); + + { + LOCK(cs_mapLocalHost); + bool fAlready = mapLocalHost.count(addr) > 0; + LocalServiceInfo &info = mapLocalHost[addr]; + if (!fAlready || nScore >= info.nScore) { + info.nScore = nScore + (fAlready ? 1 : 0); + info.nPort = addr.GetPort(); + } + SetReachable(addr.GetNetwork()); + } + + return true; +} + +bool AddLocal(const CNetAddr &addr, int nScore) +{ + return AddLocal(CService(addr, GetListenPort()), nScore); +} + +/** Make a particular network entirely off-limits (no automatic connects to it) */ +void SetLimited(enum Network net, bool fLimited) +{ + if (net == NET_UNROUTABLE) + return; + LOCK(cs_mapLocalHost); + vfLimited[net] = fLimited; +} + +bool IsLimited(enum Network net) +{ + LOCK(cs_mapLocalHost); + return vfLimited[net]; +} + +bool IsLimited(const CNetAddr &addr) +{ + return IsLimited(addr.GetNetwork()); +} + +/** vote for a local address */ +bool SeenLocal(const CService& addr) +{ + { + LOCK(cs_mapLocalHost); + if (mapLocalHost.count(addr) == 0) + return false; + mapLocalHost[addr].nScore++; + } + return true; +} + + +/** check whether a given address is potentially local */ +bool IsLocal(const CService& addr) +{ + LOCK(cs_mapLocalHost); + return mapLocalHost.count(addr) > 0; +} + +/** check whether a given address is in a network we can probably connect to */ +bool IsReachable(const CNetAddr& addr) +{ + LOCK(cs_mapLocalHost); + enum Network net = addr.GetNetwork(); + return vfReachable[net] && !vfLimited[net]; +} + +void AddressCurrentlyConnected(const CService& addr) +{ + addrman.Connected(addr); +} + + +uint64_t CNode::nTotalBytesRecv = 0; +uint64_t CNode::nTotalBytesSent = 0; +CCriticalSection CNode::cs_totalBytesRecv; +CCriticalSection CNode::cs_totalBytesSent; + +CNode* FindNode(const CNetAddr& ip) +{ + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + if ((CNetAddr)pnode->addr == ip) + return (pnode); + } + return NULL; +} + +CNode* FindNode(const std::string& addrName) +{ + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + if (pnode->addrName == addrName) + return (pnode); + return NULL; +} + +CNode* FindNode(const CService& addr) +{ + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + if ((CService)pnode->addr == addr) + return (pnode); + } + return NULL; +} + +CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool darkSendMaster) +{ + if (pszDest == NULL) { + if (IsLocal(addrConnect)) + return NULL; + + // Look for an existing connection + CNode* pnode = FindNode((CService)addrConnect); + if (pnode) + { + if(darkSendMaster) + pnode->fDarkSendMaster = true; + + pnode->AddRef(); + return pnode; + } + } + + + /// debug print + LogPrint("net", "trying connection %s lastseen=%.1fhrs\n", + pszDest ? pszDest : addrConnect.ToString(), + pszDest ? 0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0); + + // Connect + SOCKET hSocket; + bool proxyConnectionFailed = false; + if (pszDest ? ConnectSocketByName(addrConnect, hSocket, pszDest, Params().GetDefaultPort(), nConnectTimeout, &proxyConnectionFailed) : + ConnectSocket(addrConnect, hSocket, nConnectTimeout, &proxyConnectionFailed)) + { + addrman.Attempt(addrConnect); + + LogPrint("net", "connected %s\n", pszDest ? pszDest : addrConnect.ToString()); + + // Set to non-blocking +#ifdef WIN32 + u_long nOne = 1; + if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) + LogPrintf("ConnectSocket() : ioctlsocket non-blocking setting failed, error %d\n", WSAGetLastError()); +#else + if (fcntl(hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR) + LogPrintf("ConnectSocket() : fcntl non-blocking setting failed, error %d\n", errno); +#endif + + // Add node + CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false); + pnode->AddRef(); + + { + LOCK(cs_vNodes); + vNodes.push_back(pnode); + } + + pnode->nTimeConnected = GetTime(); + return pnode; + } else if (!proxyConnectionFailed) { + // If connecting to the node failed, and failure is not caused by a problem connecting to + // the proxy, mark this as an attempt. + addrman.Attempt(addrConnect); + } + + return NULL; +} + +void CNode::CloseSocketDisconnect() +{ + fDisconnect = true; + if (hSocket != INVALID_SOCKET) + { + LogPrint("net", "disconnecting node %s\n", addrName); + closesocket(hSocket); + hSocket = INVALID_SOCKET; + } + + // in case this fails, we'll empty the recv buffer when the CNode is deleted + TRY_LOCK(cs_vRecvMsg, lockRecv); + if (lockRecv) + vRecvMsg.clear(); + + // if this was the sync node, we'll need a new one + if (this == pnodeSync) + pnodeSync = NULL; +} + +void CNode::PushVersion() +{ + /// when NTP implemented, change to just nTime = GetAdjustedTime() + int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime()); + CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0))); + CAddress addrMe = GetLocalAddress(&addr); + RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); + LogPrint("net", "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), addrYou.ToString(), addr.ToString()); + PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe, + nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector()), nBestHeight); +} + + + + + +std::map CNode::setBanned; +CCriticalSection CNode::cs_setBanned; + +void CNode::ClearBanned() +{ + setBanned.clear(); +} + +bool CNode::IsBanned(CNetAddr ip) +{ + bool fResult = false; + { + LOCK(cs_setBanned); + std::map::iterator i = setBanned.find(ip); + if (i != setBanned.end()) + { + int64_t t = (*i).second; + if (GetTime() < t) + fResult = true; + } + } + return fResult; +} + +bool CNode::Misbehaving(int howmuch) +{ + if (addr.IsLocal()) + { + LogPrintf("Warning: Local node %s misbehaving (delta: %d)!\n", addrName, howmuch); + return false; + } + + nMisbehavior += howmuch; + if (nMisbehavior >= GetArg("-banscore", 100)) + { + int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban + LogPrintf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString(), nMisbehavior-howmuch, nMisbehavior); + { + LOCK(cs_setBanned); + if (setBanned[addr] < banTime) + setBanned[addr] = banTime; + } + CloseSocketDisconnect(); + return true; + } else + LogPrintf("Misbehaving: %s (%d -> %d)\n", addr.ToString(), nMisbehavior-howmuch, nMisbehavior); + return false; +} + +#undef X +#define X(name) stats.name = name +void CNode::copyStats(CNodeStats &stats) +{ + stats.nodeid = this->GetId(); + X(nServices); + X(nLastSend); + X(nLastRecv); + X(nTimeConnected); + //X(nTimeOffset); + X(addrName); + X(nVersion); + X(cleanSubVer); + X(strSubVer); + X(fInbound); + X(nStartingHeight); + X(nMisbehavior); + X(nSendBytes); + X(nRecvBytes); + stats.fSyncNode = (this == pnodeSync); + + // It is common for nodes with good ping times to suddenly become lagged, + // due to a new block arriving or other large transfer. + // Merely reporting pingtime might fool the caller into thinking the node was still responsive, + // since pingtime does not update until the ping is complete, which might take a while. + // So, if a ping is taking an unusually long time in flight, + // the caller can immediately detect that this is happening. + int64_t nPingUsecWait = 0; + if ((0 != nPingNonceSent) && (0 != nPingUsecStart)) { + nPingUsecWait = GetTimeMicros() - nPingUsecStart; + } + + // Raw ping time is in microseconds, but show it to user as whole seconds (Bitcoin users should be well used to small numbers with many decimal places by now :) + stats.dPingTime = (((double)nPingUsecTime) / 1e6); + stats.dPingWait = (((double)nPingUsecWait) / 1e6); + + // Leave string empty if addrLocal invalid (not filled in yet) + stats.addrLocal = addrLocal.IsValid() ? addrLocal.ToString() : ""; +} +#undef X + +// requires LOCK(cs_vRecvMsg) +bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes) +{ + while (nBytes > 0) { + + // get current incomplete message, or create a new one + if (vRecvMsg.empty() || + vRecvMsg.back().complete()) + vRecvMsg.push_back(CNetMessage(SER_NETWORK, nRecvVersion)); + + CNetMessage& msg = vRecvMsg.back(); + + // absorb network data + int handled; + if (!msg.in_data) + handled = msg.readHeader(pch, nBytes); + else + handled = msg.readData(pch, nBytes); + + if (handled < 0) + return false; + + pch += handled; + nBytes -= handled; + + if (msg.complete()) + msg.nTime = GetTimeMicros(); + } + + return true; +} + +int CNetMessage::readHeader(const char *pch, unsigned int nBytes) +{ + // copy data to temporary parsing buffer + unsigned int nRemaining = 24 - nHdrPos; + unsigned int nCopy = std::min(nRemaining, nBytes); + + memcpy(&hdrbuf[nHdrPos], pch, nCopy); + nHdrPos += nCopy; + + // if header incomplete, exit + if (nHdrPos < 24) + return nCopy; + + // deserialize to CMessageHeader + try { + hdrbuf >> hdr; + } + catch (std::exception &e) { + return -1; + } + + // reject messages larger than MAX_SIZE + if (hdr.nMessageSize > MAX_SIZE) + return -1; + + // switch state to reading message data + in_data = true; + + return nCopy; +} + +int CNetMessage::readData(const char *pch, unsigned int nBytes) +{ + unsigned int nRemaining = hdr.nMessageSize - nDataPos; + unsigned int nCopy = std::min(nRemaining, nBytes); + + if (vRecv.size() < nDataPos + nCopy) { + // Allocate up to 256 KiB ahead, but never more than the total message size. + vRecv.resize(std::min(hdr.nMessageSize, nDataPos + nCopy + 256 * 1024)); + } + + memcpy(&vRecv[nDataPos], pch, nCopy); + nDataPos += nCopy; + + return nCopy; +} + + + + + + + + + +// requires LOCK(cs_vSend) +void SocketSendData(CNode *pnode) +{ + std::deque::iterator it = pnode->vSendMsg.begin(); + + while (it != pnode->vSendMsg.end()) { + const CSerializeData &data = *it; + assert(data.size() > pnode->nSendOffset); + int nBytes = send(pnode->hSocket, &data[pnode->nSendOffset], data.size() - pnode->nSendOffset, MSG_NOSIGNAL | MSG_DONTWAIT); + if (nBytes > 0) { + pnode->nLastSend = GetTime(); + pnode->nSendBytes += nBytes; + pnode->nSendOffset += nBytes; + pnode->RecordBytesSent(nBytes); + if (pnode->nSendOffset == data.size()) { + pnode->nSendOffset = 0; + pnode->nSendSize -= data.size(); + it++; + } else { + // could not send full message; stop sending more + break; + } + } else { + if (nBytes < 0) { + // error + int nErr = WSAGetLastError(); + if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) + { + LogPrintf("socket send error %d\n", nErr); + pnode->CloseSocketDisconnect(); + } + } + // couldn't send anything at all + break; + } + } + + if (it == pnode->vSendMsg.end()) { + assert(pnode->nSendOffset == 0); + assert(pnode->nSendSize == 0); + } + pnode->vSendMsg.erase(pnode->vSendMsg.begin(), it); +} + +static list vNodesDisconnected; + +void ThreadSocketHandler() +{ + unsigned int nPrevNodeCount = 0; + + while (true) + { + // + // Disconnect nodes + // + { + LOCK(cs_vNodes); + // Disconnect unused nodes + vector vNodesCopy = vNodes; + BOOST_FOREACH(CNode* pnode, vNodesCopy) + { + if (pnode->fDisconnect || + (pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->nSendSize == 0 && pnode->ssSend.empty())) + { + // remove from vNodes + vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end()); + + // release outbound grant (if any) + pnode->grantOutbound.Release(); + + // close socket and cleanup + pnode->CloseSocketDisconnect(); + + // hold in disconnected pool until all refs are released + if (pnode->fNetworkNode || pnode->fInbound) + pnode->Release(); + vNodesDisconnected.push_back(pnode); + } + } + } + { + // Delete disconnected nodes + list vNodesDisconnectedCopy = vNodesDisconnected; + BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy) + { + // wait until threads are done using it + if (pnode->GetRefCount() <= 0) + { + bool fDelete = false; + { + TRY_LOCK(pnode->cs_vSend, lockSend); + if (lockSend) + { + TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); + if (lockRecv) + { + TRY_LOCK(pnode->cs_inventory, lockInv); + if (lockInv) + fDelete = true; + } + } + } + if (fDelete) + { + vNodesDisconnected.remove(pnode); + delete pnode; + } + } + } + } + if(vNodes.size() != nPrevNodeCount) { + nPrevNodeCount = vNodes.size(); + uiInterface.NotifyNumConnectionsChanged(nPrevNodeCount); + } + + + // + // Find which sockets have data to receive + // + struct timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 50000; // frequency to poll pnode->vSend + + fd_set fdsetRecv; + fd_set fdsetSend; + fd_set fdsetError; + FD_ZERO(&fdsetRecv); + FD_ZERO(&fdsetSend); + FD_ZERO(&fdsetError); + SOCKET hSocketMax = 0; + bool have_fds = false; + + BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) { + FD_SET(hListenSocket, &fdsetRecv); + hSocketMax = max(hSocketMax, hListenSocket); + have_fds = true; + } + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + if (pnode->hSocket == INVALID_SOCKET) + continue; + { + TRY_LOCK(pnode->cs_vSend, lockSend); + if (lockSend) { + // do not read, if draining write queue + if (!pnode->vSendMsg.empty()) + FD_SET(pnode->hSocket, &fdsetSend); + else + FD_SET(pnode->hSocket, &fdsetRecv); + FD_SET(pnode->hSocket, &fdsetError); + hSocketMax = max(hSocketMax, pnode->hSocket); + have_fds = true; + } + } + } + } + + int nSelect = select(have_fds ? hSocketMax + 1 : 0, + &fdsetRecv, &fdsetSend, &fdsetError, &timeout); + boost::this_thread::interruption_point(); + + if (nSelect == SOCKET_ERROR) + { + if (have_fds) + { + int nErr = WSAGetLastError(); + LogPrintf("socket select error %d\n", nErr); + for (unsigned int i = 0; i <= hSocketMax; i++) + FD_SET(i, &fdsetRecv); + } + FD_ZERO(&fdsetSend); + FD_ZERO(&fdsetError); + MilliSleep(timeout.tv_usec/1000); + } + + + // + // Accept new connections + // + BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) + if (hListenSocket != INVALID_SOCKET && FD_ISSET(hListenSocket, &fdsetRecv)) + { + struct sockaddr_storage sockaddr; + socklen_t len = sizeof(sockaddr); + SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len); + CAddress addr; + int nInbound = 0; + + if (hSocket != INVALID_SOCKET) + if (!addr.SetSockAddr((const struct sockaddr*)&sockaddr)) + LogPrintf("Warning: Unknown socket family\n"); + + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + if (pnode->fInbound) + nInbound++; + } + + if (hSocket == INVALID_SOCKET) + { + int nErr = WSAGetLastError(); + if (nErr != WSAEWOULDBLOCK) + LogPrintf("socket error accept failed: %d\n", nErr); + } + else if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS) + { + closesocket(hSocket); + } + else if (CNode::IsBanned(addr)) + { + LogPrintf("connection from %s dropped (banned)\n", addr.ToString()); + closesocket(hSocket); + } + else + { + + // According to the internet TCP_NODELAY is not carried into accepted sockets + // on all platforms. Set it again here just to be sure. + int set = 1; + #ifdef WIN32 + setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&set, sizeof(int)); + #else + setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&set, sizeof(int)); + #endif + LogPrint("net", "accepted connection %s\n", addr.ToString()); + CNode* pnode = new CNode(hSocket, addr, "", true); + pnode->AddRef(); + { + LOCK(cs_vNodes); + vNodes.push_back(pnode); + } + } + } + + + // + // Service each socket + // + vector vNodesCopy; + { + LOCK(cs_vNodes); + vNodesCopy = vNodes; + BOOST_FOREACH(CNode* pnode, vNodesCopy) + pnode->AddRef(); + } + BOOST_FOREACH(CNode* pnode, vNodesCopy) + { + boost::this_thread::interruption_point(); + + // + // Receive + // + if (pnode->hSocket == INVALID_SOCKET) + continue; + if (FD_ISSET(pnode->hSocket, &fdsetRecv) || FD_ISSET(pnode->hSocket, &fdsetError)) + { + TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); + if (lockRecv) + { + if (pnode->GetTotalRecvSize() > ReceiveFloodSize()) { + if (!pnode->fDisconnect) + LogPrintf("socket recv flood control disconnect (%u bytes)\n", pnode->GetTotalRecvSize()); + pnode->CloseSocketDisconnect(); + } + else { + // typical socket buffer is 8K-64K + char pchBuf[0x10000]; + int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT); + if (nBytes > 0) + { + if (!pnode->ReceiveMsgBytes(pchBuf, nBytes)) + pnode->CloseSocketDisconnect(); + pnode->nLastRecv = GetTime(); + pnode->nRecvBytes += nBytes; + pnode->RecordBytesRecv(nBytes); + } + else if (nBytes == 0) + { + // socket closed gracefully + if (!pnode->fDisconnect) + LogPrint("net", "socket closed\n"); + pnode->CloseSocketDisconnect(); + } + else if (nBytes < 0) + { + // error + int nErr = WSAGetLastError(); + if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) + { + if (!pnode->fDisconnect) + LogPrintf("socket recv error %d\n", nErr); + pnode->CloseSocketDisconnect(); + } + } + } + } + } + + // + // Send + // + if (pnode->hSocket == INVALID_SOCKET) + continue; + if (FD_ISSET(pnode->hSocket, &fdsetSend)) + { + TRY_LOCK(pnode->cs_vSend, lockSend); + if (lockSend) + SocketSendData(pnode); + } + + // + // Inactivity checking + // + int64_t nTime = GetTime(); + if (nTime - pnode->nTimeConnected > 60) + { + if (pnode->nLastRecv == 0 || pnode->nLastSend == 0) + { + LogPrint("net", "socket no message in first 60 seconds, %d %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0); + pnode->fDisconnect = true; + } + else if (nTime - pnode->nLastSend > TIMEOUT_INTERVAL) + { + LogPrintf("socket sending timeout: %ds\n", nTime - pnode->nLastSend); + pnode->fDisconnect = true; + } + else if (nTime - pnode->nLastRecv > (pnode->nVersion > BIP0031_VERSION ? TIMEOUT_INTERVAL : 90*60)) + { + LogPrintf("socket receive timeout: %ds\n", nTime - pnode->nLastRecv); + pnode->fDisconnect = true; + } + else if (pnode->nPingNonceSent && pnode->nPingUsecStart + TIMEOUT_INTERVAL * 1000000 < GetTimeMicros()) + { + LogPrintf("ping timeout: %fs\n", 0.000001 * (GetTimeMicros() - pnode->nPingUsecStart)); + pnode->fDisconnect = true; + } + } + } + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodesCopy) + pnode->Release(); + } + } +} + + + + + + + + + +#ifdef USE_UPNP +void ThreadMapPort() +{ + std::string port = strprintf("%u", GetListenPort()); + const char * multicastif = 0; + const char * minissdpdpath = 0; + struct UPNPDev * devlist = 0; + char lanaddr[64]; + +#ifndef UPNPDISCOVER_SUCCESS + /* miniupnpc 1.5 */ + devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0); +#else + /* miniupnpc 1.6 */ + int error = 0; + devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error); +#endif + + struct UPNPUrls urls; + struct IGDdatas data; + int r; + + r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); + if (r == 1) + { + if (fDiscover) { + char externalIPAddress[40]; + r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress); + if(r != UPNPCOMMAND_SUCCESS) + LogPrintf("UPnP: GetExternalIPAddress() returned %d\n", r); + else + { + if(externalIPAddress[0]) + { + LogPrintf("UPnP: ExternalIPAddress = %s\n", externalIPAddress); + AddLocal(CNetAddr(externalIPAddress), LOCAL_UPNP); + } + else + LogPrintf("UPnP: GetExternalIPAddress failed.\n"); + } + } + + string strDesc = "SONO " + FormatFullVersion(); + + try { + while (!ShutdownRequested()) { + boost::this_thread::interruption_point(); + +#ifndef UPNPDISCOVER_SUCCESS + /* miniupnpc 1.5 */ + r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, + port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0); +#else + /* miniupnpc 1.6 */ + r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, + port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0"); +#endif + + if(r!=UPNPCOMMAND_SUCCESS) + LogPrintf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", + port, port, lanaddr, r, strupnperror(r)); + else + LogPrintf("UPnP Port Mapping successful.\n");; + + MilliSleep(20*60*1000); // Refresh every 20 minutes + } + } + catch (boost::thread_interrupted) + { + r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0); + LogPrintf("UPNP_DeletePortMapping() returned : %d\n", r); + freeUPNPDevlist(devlist); devlist = 0; + FreeUPNPUrls(&urls); + throw; + } + } else { + LogPrintf("No valid UPnP IGDs found\n"); + freeUPNPDevlist(devlist); devlist = 0; + if (r != 0) + FreeUPNPUrls(&urls); + } +} + +void MapPort(bool fUseUPnP) +{ + static boost::thread* upnp_thread = NULL; + + if (fUseUPnP) + { + if (upnp_thread) { + upnp_thread->interrupt(); + upnp_thread->join(); + delete upnp_thread; + } + upnp_thread = new boost::thread(boost::bind(&TraceThread, "upnp", &ThreadMapPort)); + } + else if (upnp_thread) { + upnp_thread->interrupt(); + upnp_thread->join(); + delete upnp_thread; + upnp_thread = NULL; + } +} + +#else +void MapPort(bool) +{ + // Intentionally left blank. +} +#endif + + + + + + +void ThreadDNSAddressSeed() +{ + // goal: only query DNS seeds if address need is acute + if ((addrman.size() > 0) && + (!GetBoolArg("-forcednsseed", false))) { + MilliSleep(11 * 1000); + + LOCK(cs_vNodes); + if (vNodes.size() >= 2) { + LogPrintf("P2P peers available. Skipped DNS seeding.\n"); + return; + } + } + + const vector &vSeeds = Params().DNSSeeds(); + int found = 0; + + LogPrintf("Loading addresses from DNS seeds (could take a while)\n"); + + BOOST_FOREACH(const CDNSSeedData &seed, vSeeds) { + if (HaveNameProxy()) { + AddOneShot(seed.host); + } else { + vector vIPs; + vector vAdd; + if (LookupHost(seed.host.c_str(), vIPs)) + { + BOOST_FOREACH(CNetAddr& ip, vIPs) + { + int nOneDay = 24*3600; + CAddress addr = CAddress(CService(ip, Params().GetDefaultPort())); + addr.nTime = GetTime() - 3*nOneDay - GetRand(4*nOneDay); // use a random age between 3 and 7 days old + vAdd.push_back(addr); + found++; + } + } + addrman.Add(vAdd, CNetAddr(seed.name, true)); + } + } + + LogPrintf("%d addresses found from DNS seeds\n", found); +} + + + + + + + + + +void DumpAddresses() +{ + int64_t nStart = GetTimeMillis(); + + CAddrDB adb; + adb.Write(addrman); + + LogPrint("net", "Flushed %d addresses to peers.dat %dms\n", + addrman.size(), GetTimeMillis() - nStart); +} + +void static ProcessOneShot() +{ + string strDest; + { + LOCK(cs_vOneShots); + if (vOneShots.empty()) + return; + strDest = vOneShots.front(); + vOneShots.pop_front(); + } + CAddress addr; + CSemaphoreGrant grant(*semOutbound, true); + if (grant) { + if (!OpenNetworkConnection(addr, &grant, strDest.c_str(), true)) + AddOneShot(strDest); + } +} + +void ThreadOpenConnections() +{ + // Connect to specific addresses + if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) + { + for (int64_t nLoop = 0;; nLoop++) + { + ProcessOneShot(); + BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"]) + { + CAddress addr; + OpenNetworkConnection(addr, NULL, strAddr.c_str()); + for (int i = 0; i < 10 && i < nLoop; i++) + { + MilliSleep(500); + } + } + MilliSleep(500); + } + } + + // Initiate network connections + int64_t nStart = GetTime(); + while (true) + { + ProcessOneShot(); + + MilliSleep(500); + + CSemaphoreGrant grant(*semOutbound); + boost::this_thread::interruption_point(); + + // Add seed nodes if DNS seeds are all down (an infrastructure attack?). + if (addrman.size() == 0 && (GetTime() - nStart > 60)) { + static bool done = false; + if (!done) { + LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n"); + addrman.Add(Params().FixedSeeds(), CNetAddr("127.0.0.1")); + done = true; + } + } + + // + // Choose an address to connect to based on most recently seen + // + CAddress addrConnect; + + // Only connect out to one peer per network group (/16 for IPv4). + // Do this here so we don't have to critsect vNodes inside mapAddresses critsect. + int nOutbound = 0; + set > setConnected; + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) { + if (!pnode->fInbound) { + setConnected.insert(pnode->addr.GetGroup()); + nOutbound++; + } + } + } + + int64_t nANow = GetAdjustedTime(); + + int nTries = 0; + while (true) + { + // use an nUnkBias between 10 (no outgoing connections) and 90 (8 outgoing connections) + CAddress addr = addrman.Select(10 + min(nOutbound,8)*10); + + // if we selected an invalid address, restart + if (!addr.IsValid() || setConnected.count(addr.GetGroup()) || IsLocal(addr)) + break; + + // If we didn't find an appropriate destination after trying 100 addresses fetched from addrman, + // stop this loop, and let the outer loop run again (which sleeps, adds seed nodes, recalculates + // already-connected network ranges, ...) before trying new addrman addresses. + nTries++; + if (nTries > 100) + break; + + if (IsLimited(addr)) + continue; + + // only consider very recently tried nodes after 30 failed attempts + if (nANow - addr.nLastTry < 600 && nTries < 30) + continue; + + // do not allow non-default ports, unless after 50 invalid addresses selected already + if (addr.GetPort() != Params().GetDefaultPort() && nTries < 50) + continue; + + addrConnect = addr; + break; + } + + if (addrConnect.IsValid()) + OpenNetworkConnection(addrConnect, &grant); + } +} + +void ThreadOpenAddedConnections() +{ + { + LOCK(cs_vAddedNodes); + vAddedNodes = mapMultiArgs["-addnode"]; + } + + if (HaveNameProxy()) { + while(true) { + list lAddresses(0); + { + LOCK(cs_vAddedNodes); + BOOST_FOREACH(string& strAddNode, vAddedNodes) + lAddresses.push_back(strAddNode); + } + BOOST_FOREACH(string& strAddNode, lAddresses) { + CAddress addr; + CSemaphoreGrant grant(*semOutbound); + OpenNetworkConnection(addr, &grant, strAddNode.c_str()); + MilliSleep(500); + } + MilliSleep(120000); // Retry every 2 minutes + } + } + + for (unsigned int i = 0; true; i++) + { + list lAddresses(0); + { + LOCK(cs_vAddedNodes); + BOOST_FOREACH(string& strAddNode, vAddedNodes) + lAddresses.push_back(strAddNode); + } + + list > lservAddressesToAdd(0); + BOOST_FOREACH(string& strAddNode, lAddresses) + { + vector vservNode(0); + if(Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0)) + { + lservAddressesToAdd.push_back(vservNode); + { + LOCK(cs_setservAddNodeAddresses); + BOOST_FOREACH(CService& serv, vservNode) + setservAddNodeAddresses.insert(serv); + } + } + } + // Attempt to connect to each IP for each addnode entry until at least one is successful per addnode entry + // (keeping in mind that addnode entries can have many IPs if fNameLookup) + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + for (list >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++) + BOOST_FOREACH(CService& addrNode, *(it)) + if (pnode->addr == addrNode) + { + it = lservAddressesToAdd.erase(it); + it--; + break; + } + } + BOOST_FOREACH(vector& vserv, lservAddressesToAdd) + { + CSemaphoreGrant grant(*semOutbound); + OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant); + MilliSleep(500); + } + MilliSleep(120000); // Retry every 2 minutes + } +} + +// if successful, this moves the passed grant to the constructed node +bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound, const char *strDest, bool fOneShot) +{ + // + // Initiate outbound network connection + // + boost::this_thread::interruption_point(); + if (!strDest) + if (IsLocal(addrConnect) || + FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect) || + FindNode(addrConnect.ToStringIPPort().c_str())) + return false; + if (strDest && FindNode(strDest)) + return false; + + CNode* pnode = ConnectNode(addrConnect, strDest); + boost::this_thread::interruption_point(); + + if (!pnode) + return false; + if (grantOutbound) + grantOutbound->MoveTo(pnode->grantOutbound); + pnode->fNetworkNode = true; + if (fOneShot) + pnode->fOneShot = true; + + return true; +} + + +// for now, use a very simple selection metric: the node from which we received +// most recently +static int64_t NodeSyncScore(const CNode *pnode) { + return pnode->nLastRecv; +} + +void static StartSync(const vector &vNodes) { + CNode *pnodeNewSync = NULL; + int64_t nBestScore = 0; + + // fImporting and fReindex are accessed out of cs_main here, but only + // as an optimization - they are checked again in SendMessages. + if (fImporting || fReindex) + return; + + // Iterate over all nodes + BOOST_FOREACH(CNode* pnode, vNodes) { + // check preconditions for allowing a sync + if (!pnode->fClient && !pnode->fOneShot && + !pnode->fDisconnect && pnode->fSuccessfullyConnected && + (pnode->nStartingHeight > (nBestHeight - 144)) && + (pnode->nVersion < NOBLKS_VERSION_START || pnode->nVersion >= NOBLKS_VERSION_END)) { + // if ok, compare node's score with the best so far + int64_t nScore = NodeSyncScore(pnode); + if (pnodeNewSync == NULL || nScore > nBestScore) { + pnodeNewSync = pnode; + nBestScore = nScore; + } + } + } + // if a new sync candidate was found, start sync! + if (pnodeNewSync) { + pnodeNewSync->fStartSync = true; + pnodeSync = pnodeNewSync; + } +} + +void ThreadMessageHandler() +{ + SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL); + while (true) + { + bool fHaveSyncNode = false; + + vector vNodesCopy; + { + LOCK(cs_vNodes); + vNodesCopy = vNodes; + BOOST_FOREACH(CNode* pnode, vNodesCopy) { + pnode->AddRef(); + if (pnode == pnodeSync) + fHaveSyncNode = true; + } + } + + if (!fHaveSyncNode) + StartSync(vNodesCopy); + + // Poll the connected nodes for messages + CNode* pnodeTrickle = NULL; + if (!vNodesCopy.empty()) + pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())]; + + bool fSleep = true; + + BOOST_FOREACH(CNode* pnode, vNodesCopy) + { + if (pnode->fDisconnect) + continue; + + // Receive messages + { + TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); + if (lockRecv) + { + if (!g_signals.ProcessMessages(pnode)) + pnode->CloseSocketDisconnect(); + + if (pnode->nSendSize < SendBufferSize()) + { + if (!pnode->vRecvGetData.empty() || (!pnode->vRecvMsg.empty() && pnode->vRecvMsg[0].complete())) + { + fSleep = false; + } + } + } + } + boost::this_thread::interruption_point(); + + // Send messages + { + TRY_LOCK(pnode->cs_vSend, lockSend); + if (lockSend) + g_signals.SendMessages(pnode, pnode == pnodeTrickle); + } + boost::this_thread::interruption_point(); + } + + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodesCopy) + pnode->Release(); + } + + if (fSleep) + MilliSleep(100); + } +} + + + + + + +bool BindListenPort(const CService &addrBind, string& strError) +{ + strError = ""; + int nOne = 1; + +#ifdef WIN32 + // Initialize Windows Sockets + WSADATA wsadata; + int ret = WSAStartup(MAKEWORD(2,2), &wsadata); + if (ret != NO_ERROR) + { + strError = strprintf("Error: TCP/IP socket library failed to start (WSAStartup returned error %d)", ret); + LogPrintf("%s\n", strError); + return false; + } +#endif + + // Create socket for listening for incoming connections + struct sockaddr_storage sockaddr; + socklen_t len = sizeof(sockaddr); + if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len)) + { + strError = strprintf("Error: bind address family for %s not supported", addrBind.ToString()); + LogPrintf("%s\n", strError); + return false; + } + + SOCKET hListenSocket = socket(((struct sockaddr*)&sockaddr)->sa_family, SOCK_STREAM, IPPROTO_TCP); + if (hListenSocket == INVALID_SOCKET) + { + strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %d)", WSAGetLastError()); + LogPrintf("%s\n", strError); + return false; + } +#ifndef WIN32 +#ifdef SO_NOSIGPIPE + // Different way of disabling SIGPIPE on BSD + setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int)); +#endif + + + // Allow binding if the port is still in TIME_WAIT state after + // the program was closed and restarted. Not an issue on windows. + setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int)); + + // Disable Nagle's algorithm + setsockopt(hListenSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&nOne, sizeof(int)); +#else + setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&nOne, sizeof(int)); + setsockopt(hListenSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&nOne, sizeof(int)); + +#endif + + +#ifdef WIN32 + // Set to non-blocking, incoming connections will also inherit this + if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR) +#else + if (fcntl(hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR) +#endif + { + strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %d)", WSAGetLastError()); + LogPrintf("%s\n", strError); + return false; + } + + // some systems don't have IPV6_V6ONLY but are always v6only; others do have the option + // and enable it by default or not. Try to enable it, if possible. + if (addrBind.IsIPv6()) { +#ifdef IPV6_V6ONLY +#ifdef WIN32 + setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&nOne, sizeof(int)); +#else + setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int)); +#endif +#endif +#ifdef WIN32 + int nProtLevel = 10 /* PROTECTION_LEVEL_UNRESTRICTED */; + int nParameterId = 23 /* IPV6_PROTECTION_LEVEl */; + // this call is allowed to fail + setsockopt(hListenSocket, IPPROTO_IPV6, nParameterId, (const char*)&nProtLevel, sizeof(int)); +#endif + } + + if (::bind(hListenSocket, (struct sockaddr*)&sockaddr, len) == SOCKET_ERROR) + { + int nErr = WSAGetLastError(); + if (nErr == WSAEADDRINUSE) + strError = strprintf(_("Unable to bind to %s on this computer. SONO is probably already running."), addrBind.ToString()); + else + strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %d, %s)"), addrBind.ToString(), nErr, strerror(nErr)); + LogPrintf("%s\n", strError); + return false; + } + LogPrintf("Bound to %s\n", addrBind.ToString()); + + // Listen for incoming connections + if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR) + { + strError = strprintf("Error: Listening for incoming connections failed (listen returned error %d)", WSAGetLastError()); + LogPrintf("%s\n", strError); + return false; + } + + vhListenSocket.push_back(hListenSocket); + + if (addrBind.IsRoutable() && fDiscover) + AddLocal(addrBind, LOCAL_BIND); + + return true; +} + +void static Discover(boost::thread_group& threadGroup) +{ + if (!fDiscover) + return; + +#ifdef WIN32 + // Get local host IP + char pszHostName[1000] = ""; + if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR) + { + vector vaddr; + if (LookupHost(pszHostName, vaddr)) + { + BOOST_FOREACH (const CNetAddr &addr, vaddr) + { + AddLocal(addr, LOCAL_IF); + } + } + } +#else + // Get local host ip + struct ifaddrs* myaddrs; + if (getifaddrs(&myaddrs) == 0) + { + for (struct ifaddrs* ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next) + { + if (ifa->ifa_addr == NULL) continue; + if ((ifa->ifa_flags & IFF_UP) == 0) continue; + if (strcmp(ifa->ifa_name, "lo") == 0) continue; + if (strcmp(ifa->ifa_name, "lo0") == 0) continue; + if (ifa->ifa_addr->sa_family == AF_INET) + { + struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr); + CNetAddr addr(s4->sin_addr); + if (AddLocal(addr, LOCAL_IF)) + LogPrintf("IPv4 %s: %s\n", ifa->ifa_name, addr.ToString()); + } + else if (ifa->ifa_addr->sa_family == AF_INET6) + { + struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr); + CNetAddr addr(s6->sin6_addr); + if (AddLocal(addr, LOCAL_IF)) + LogPrintf("IPv6 %s: %s\n", ifa->ifa_name, addr.ToString()); + } + } + freeifaddrs(myaddrs); + } +#endif + +} + +void StartNode(boost::thread_group& threadGroup) +{ + if (semOutbound == NULL) { + // initialize semaphore + int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, (int)GetArg("-maxconnections", 125)); + semOutbound = new CSemaphore(nMaxOutbound); + } + + if (pnodeLocalHost == NULL) + pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices)); + + Discover(threadGroup); + + // + // Start threads + // + + if (!GetBoolArg("-dnsseed", true)) + LogPrintf("DNS seeding disabled\n"); + else + threadGroup.create_thread(boost::bind(&TraceThread, "dnsseed", &ThreadDNSAddressSeed)); + +#ifdef USE_UPNP + // Map ports with UPnP + MapPort(GetBoolArg("-upnp", USE_UPNP)); +#endif + + // Send and receive from sockets, accept connections + threadGroup.create_thread(boost::bind(&TraceThread, "net", &ThreadSocketHandler)); + + // Initiate outbound connections from -addnode + threadGroup.create_thread(boost::bind(&TraceThread, "addcon", &ThreadOpenAddedConnections)); + + // Initiate outbound connections + threadGroup.create_thread(boost::bind(&TraceThread, "opencon", &ThreadOpenConnections)); + + // Process messages + threadGroup.create_thread(boost::bind(&TraceThread, "msghand", &ThreadMessageHandler)); + + // Dump network addresses + threadGroup.create_thread(boost::bind(&LoopForever, "dumpaddr", &DumpAddresses, DUMP_ADDRESSES_INTERVAL * 1000)); +} + +bool StopNode() +{ + LogPrintf("StopNode()\n"); + MapPort(false); + mempool.AddTransactionsUpdated(1); + if (semOutbound) + for (int i=0; ipost(); + DumpAddresses(); + return true; +} + +class CNetCleanup +{ +public: + CNetCleanup() + { + } + ~CNetCleanup() + { + // Close sockets + BOOST_FOREACH(CNode* pnode, vNodes) + if (pnode->hSocket != INVALID_SOCKET) + closesocket(pnode->hSocket); + BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) + if (hListenSocket != INVALID_SOCKET) + if (closesocket(hListenSocket) == SOCKET_ERROR) + LogPrintf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError()); + +#ifdef WIN32 + // Shutdown Windows Sockets + WSACleanup(); +#endif + } +} +instance_of_cnetcleanup; + +void RelayTransaction(const CTransaction& tx, const uint256& hash) +{ + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss.reserve(10000); + ss << tx; + RelayTransaction(tx, hash, ss); +} + +void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataStream& ss) +{ + CInv inv(MSG_TX, hash); + { + LOCK(cs_mapRelay); + // Expire old relay messages + while (!vRelayExpiration.empty() && vRelayExpiration.front().first < GetTime()) + { + mapRelay.erase(vRelayExpiration.front().second); + vRelayExpiration.pop_front(); + } + + // Save original serialized message so newer versions are preserved + mapRelay.insert(std::make_pair(inv, ss)); + vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv)); + } + + RelayInventory(inv); +} + +void RelayTransactionLockReq(const CTransaction& tx, const uint256& hash, bool relayToAll) +{ + CInv inv(MSG_TXLOCK_REQUEST, tx.GetHash()); + + //broadcast the new lock + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + if(!relayToAll && !pnode->fRelayTxes) + continue; + + pnode->PushMessage("txlreq", tx); + } + +} + +void RelayDarkSendFinalTransaction(const int sessionID, const CTransaction& txNew) +{ + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + pnode->PushMessage("dsf", sessionID, txNew); + } +} + +void RelayDarkSendIn(const std::vector& in, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& out) +{ + LOCK(cs_vNodes); + + BOOST_FOREACH(CNode* pnode, vNodes) + { + if((CNetAddr)darkSendPool.submittedToMasternode != (CNetAddr)pnode->addr) continue; + LogPrintf("RelayDarkSendIn - found master, relaying message - %s \n", pnode->addr.ToString().c_str()); + pnode->PushMessage("dsi", in, nAmount, txCollateral, out); + } +} + +void RelayDarkSendStatus(const int sessionID, const int newState, const int newEntriesCount, const int newAccepted, const std::string error) +{ + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + pnode->PushMessage("dssu", sessionID, newState, newEntriesCount, newAccepted, error); + } +} + +void RelayDarkSendElectionEntry(const CTxIn vin, const CService addr, const std::vector vchSig, const int64_t nNow, const CPubKey pubkey, const CPubKey pubkey2, const int count, const int current, const int64_t lastUpdated, const int protocolVersion) +{ + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + if(!pnode->fRelayTxes) continue; + + pnode->PushMessage("dsee", vin, addr, vchSig, nNow, pubkey, pubkey2, count, current, lastUpdated, protocolVersion); + } +} + +void SendDarkSendElectionEntry(const CTxIn vin, const CService addr, const std::vector vchSig, const int64_t nNow, const CPubKey pubkey, const CPubKey pubkey2, const int count, const int current, const int64_t lastUpdated, const int protocolVersion) +{ + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + pnode->PushMessage("dsee", vin, addr, vchSig, nNow, pubkey, pubkey2, count, current, lastUpdated, protocolVersion); + } +} + +void RelayDarkSendElectionEntryPing(const CTxIn vin, const std::vector vchSig, const int64_t nNow, const bool stop) +{ + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + if(!pnode->fRelayTxes) continue; + + pnode->PushMessage("dseep", vin, vchSig, nNow, stop); + } +} + +void SendDarkSendElectionEntryPing(const CTxIn vin, const std::vector vchSig, const int64_t nNow, const bool stop) +{ + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + pnode->PushMessage("dseep", vin, vchSig, nNow, stop); + } +} + +void RelayDarkSendCompletedTransaction(const int sessionID, const bool error, const std::string errorMessage) +{ + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + pnode->PushMessage("dsc", sessionID, error, errorMessage); + } +} + + +void CNode::RecordBytesRecv(uint64_t bytes) +{ + LOCK(cs_totalBytesRecv); + nTotalBytesRecv += bytes; +} + +void CNode::RecordBytesSent(uint64_t bytes) +{ + LOCK(cs_totalBytesSent); + nTotalBytesSent += bytes; +} + +uint64_t CNode::GetTotalBytesRecv() +{ + LOCK(cs_totalBytesRecv); + return nTotalBytesRecv; +} + +uint64_t CNode::GetTotalBytesSent() +{ + LOCK(cs_totalBytesSent); + return nTotalBytesSent; +} + +// +// CAddrDB +// + +CAddrDB::CAddrDB() +{ + pathAddr = GetDataDir() / "peers.dat"; +} + +bool CAddrDB::Write(const CAddrMan& addr) +{ + // Generate random temporary filename + unsigned short randv = 0; + RAND_bytes((unsigned char *)&randv, sizeof(randv)); + std::string tmpfn = strprintf("peers.dat.%04x", randv); + + // serialize addresses, checksum data up to that point, then append csum + CDataStream ssPeers(SER_DISK, CLIENT_VERSION); + ssPeers << FLATDATA(Params().MessageStart()); + ssPeers << addr; + uint256 hash = Hash(ssPeers.begin(), ssPeers.end()); + ssPeers << hash; + + // open temp output file, and associate with CAutoFile + boost::filesystem::path pathTmp = GetDataDir() / tmpfn; + FILE *file = fopen(pathTmp.string().c_str(), "wb"); + CAutoFile fileout = CAutoFile(file, SER_DISK, CLIENT_VERSION); + if (!fileout) + return error("CAddrman::Write() : open failed"); + + // Write and commit header, data + try { + fileout << ssPeers; + } + catch (std::exception &e) { + return error("CAddrman::Write() : I/O error"); + } + FileCommit(fileout); + fileout.fclose(); + + // replace existing peers.dat, if any, with new peers.dat.XXXX + if (!RenameOver(pathTmp, pathAddr)) + return error("CAddrman::Write() : Rename-into-place failed"); + + return true; +} + +bool CAddrDB::Read(CAddrMan& addr) +{ + // open input file, and associate with CAutoFile + FILE *file = fopen(pathAddr.string().c_str(), "rb"); + CAutoFile filein = CAutoFile(file, SER_DISK, CLIENT_VERSION); + if (!filein) + return error("CAddrman::Read() : open failed"); + + // use file size to size memory buffer + int fileSize = boost::filesystem::file_size(pathAddr); + int dataSize = fileSize - sizeof(uint256); + // Don't try to resize to a negative number if file is small + if ( dataSize < 0 ) dataSize = 0; + vector vchData; + vchData.resize(dataSize); + uint256 hashIn; + + // read data and checksum from file + try { + filein.read((char *)&vchData[0], dataSize); + filein >> hashIn; + } + catch (std::exception &e) { + return error("CAddrman::Read() 2 : I/O error or stream data corrupted"); + } + filein.fclose(); + + CDataStream ssPeers(vchData, SER_DISK, CLIENT_VERSION); + + // verify stored checksum matches input data + uint256 hashTmp = Hash(ssPeers.begin(), ssPeers.end()); + if (hashIn != hashTmp) + return error("CAddrman::Read() : checksum mismatch; data corrupted"); + + unsigned char pchMsgTmp[4]; + try { + // de-serialize file header (network specific magic number) and .. + ssPeers >> FLATDATA(pchMsgTmp); + + // ... verify the network matches ours + if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp))) + return error("CAddrman::Read() : invalid network magic number"); + + // de-serialize address data into one CAddrMan object + ssPeers >> addr; + } + catch (std::exception &e) { + return error("CAddrman::Read() : I/O error or stream data corrupted"); + } + + return true; +} diff --git a/src/net.h b/src/net.h new file mode 100644 index 0000000..4ea9910 --- /dev/null +++ b/src/net.h @@ -0,0 +1,788 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_NET_H +#define BITCOIN_NET_H + +#include +#include +#include +#include +#include + + +#ifndef WIN32 +#include +#endif + +#include "mruset.h" +#include "netbase.h" +#include "protocol.h" +#include "addrman.h" +#include "hash.h" +#include "core.h" + +class CNode; +class CBlockIndex; +extern int nBestHeight; + + +/** Time between pings automatically sent out for latency probing and keepalive (in seconds). */ +static const int PING_INTERVAL = 1 * 60; +/** Time after which to disconnect, after waiting for a ping response (or inactivity). */ +static const int TIMEOUT_INTERVAL = 20 * 60; + +inline unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); } +inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); } + +void AddOneShot(std::string strDest); +bool RecvLine(SOCKET hSocket, std::string& strLine); +void AddressCurrentlyConnected(const CService& addr); +CNode* FindNode(const CNetAddr& ip); +CNode* FindNode(const std::string& addrName); +CNode* FindNode(const CService& ip); +CNode* ConnectNode(CAddress addrConnect, const char *strDest = NULL, bool darkSendMaster=false); +void MapPort(bool fUseUPnP); +unsigned short GetListenPort(); +bool BindListenPort(const CService &bindAddr, std::string& strError=REF(std::string())); +void StartNode(boost::thread_group& threadGroup); +bool StopNode(); +void SocketSendData(CNode *pnode); + +// Signals for message handling +struct CNodeSignals +{ + boost::signals2::signal ProcessMessages; + boost::signals2::signal SendMessages; +}; + +CNodeSignals& GetNodeSignals(); + +typedef int NodeId; + +enum +{ + LOCAL_NONE, // unknown + LOCAL_IF, // address a local interface listens on + LOCAL_BIND, // address explicit bound to + LOCAL_UPNP, // address reported by UPnP + LOCAL_IRC, // address reported by IRC (deprecated) + LOCAL_MANUAL, // address explicitly specified (-externalip=) + + LOCAL_MAX +}; + +bool IsPeerAddrLocalGood(CNode *pnode); +void AdvertizeLocal(CNode *pnode); +void SetLimited(enum Network net, bool fLimited = true); +bool IsLimited(enum Network net); +bool IsLimited(const CNetAddr& addr); +bool AddLocal(const CService& addr, int nScore = LOCAL_NONE); +bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE); +bool SeenLocal(const CService& addr); +bool IsLocal(const CService& addr); +bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL); +bool IsReachable(const CNetAddr &addr); +void SetReachable(enum Network net, bool fFlag = true); +CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL); + + +enum { + MSG_TX = 1, + MSG_BLOCK, + // Nodes may always request a MSG_FILTERED_BLOCK in a getdata, however, + // MSG_FILTERED_BLOCK should not appear in any invs except as a part of getdata. + MSG_FILTERED_BLOCK, + MSG_TXLOCK_REQUEST, + MSG_TXLOCK_VOTE, + MSG_SPORK, + MSG_MASTERNODE_WINNER +}; + +extern bool fDiscover; +extern uint64_t nLocalServices; +extern uint64_t nLocalHostNonce; +extern CAddrMan addrman; + +extern std::vector vNodes; +extern CCriticalSection cs_vNodes; +extern std::map mapRelay; +extern std::deque > vRelayExpiration; +extern CCriticalSection cs_mapRelay; +extern std::map mapAlreadyAskedFor; + +extern std::vector vAddedNodes; +extern CCriticalSection cs_vAddedNodes; + +extern NodeId nLastNodeId; +extern CCriticalSection cs_nLastNodeId; + + +class CNodeStats +{ +public: + NodeId nodeid; + uint64_t nServices; + int64_t nLastSend; + int64_t nLastRecv; + int64_t nTimeConnected; + //int64_t nTimeOffset; + std::string addrName; + int nVersion; + std::string cleanSubVer; + std::string strSubVer; + bool fInbound; + int nStartingHeight; + int nMisbehavior; + uint64_t nSendBytes; + uint64_t nRecvBytes; + bool fSyncNode; + double dPingTime; + double dPingWait; + std::string addrLocal; +}; + + + + +class CNetMessage { +public: + bool in_data; // parsing header (false) or data (true) + + CDataStream hdrbuf; // partially received header + CMessageHeader hdr; // complete header + unsigned int nHdrPos; + + CDataStream vRecv; // received message data + unsigned int nDataPos; + + int64_t nTime; // time (in microseconds) of message receipt. + + CNetMessage(int nTypeIn, int nVersionIn) : hdrbuf(nTypeIn, nVersionIn), vRecv(nTypeIn, nVersionIn) { + hdrbuf.resize(24); + in_data = false; + nHdrPos = 0; + nDataPos = 0; + nTime = 0; + } + + bool complete() const + { + if (!in_data) + return false; + return (hdr.nMessageSize == nDataPos); + } + + void SetVersion(int nVersionIn) + { + hdrbuf.SetVersion(nVersionIn); + vRecv.SetVersion(nVersionIn); + } + + int readHeader(const char *pch, unsigned int nBytes); + int readData(const char *pch, unsigned int nBytes); +}; + + +class SecMsgNode +{ +public: + SecMsgNode() + { + lastSeen = 0; + lastMatched = 0; + ignoreUntil = 0; + nWakeCounter = 0; + nPeerId = 0; + fEnabled = false; + }; + + ~SecMsgNode() {}; + + int64_t lastSeen; + int64_t lastMatched; + int64_t ignoreUntil; + uint32_t nWakeCounter; + uint32_t nPeerId; + bool fEnabled; + +}; + + + +/** Information about a peer */ +class CNode +{ +public: + // socket + uint64_t nServices; + SOCKET hSocket; + CDataStream ssSend; + size_t nSendSize; // total size of all vSendMsg entries + size_t nSendOffset; // offset inside the first vSendMsg already sent + uint64_t nSendBytes; + std::deque vSendMsg; + CCriticalSection cs_vSend; + + std::deque vRecvGetData; + std::deque vRecvMsg; + CCriticalSection cs_vRecvMsg; + uint64_t nRecvBytes; + int nRecvVersion; + + int64_t nLastSend; + int64_t nLastRecv; + int64_t nTimeConnected; + //int64_t nTimeOffset; + CAddress addr; + std::string addrName; + CService addrLocal; + int nVersion; + // strSubVer is whatever byte array we read from the wire. However, this field is intended + // to be printed out, displayed to humans in various forms and so on. So we sanitize it and + // store the sanitized version in cleanSubVer. The original should be used when dealing with + // the network or wire types and the cleaned string used when displayed or logged. + std::string strSubVer, cleanSubVer; + bool fOneShot; + bool fClient; + bool fInbound; + bool fNetworkNode; + bool fSuccessfullyConnected; + bool fDisconnect; + // We use fRelayTxes for two purposes - + // a) it allows us to not relay tx invs before receiving the peer's version message + // b) the peer may tell us in their version message that we should not relay tx invs + // until they have initialized their bloom filter. + bool fRelayTxes; + bool fDarkSendMaster; + CSemaphoreGrant grantOutbound; + int nRefCount; + NodeId id; +protected: + + // Denial-of-service detection/prevention + // Key is IP address, value is banned-until-time + static std::map setBanned; + static CCriticalSection cs_setBanned; + + + std::vector vecRequestsFulfilled; //keep track of what client has asked for + +public: + int nMisbehavior; + uint256 hashContinue; + CBlockIndex* pindexLastGetBlocksBegin; + uint256 hashLastGetBlocksEnd; + int nStartingHeight; + bool fStartSync; + + // flood relay + std::vector vAddrToSend; + mruset setAddrKnown; + bool fGetAddr; + std::set setKnown; + uint256 hashCheckpointKnown; // ppcoin: known sent sync-checkpoint + + // inventory based relay + mruset setInventoryKnown; + std::vector vInventoryToSend; + CCriticalSection cs_inventory; + std::multimap mapAskFor; + + SecMsgNode smsgData; + + // Ping time measurement: + // The pong reply we're expecting, or 0 if no pong expected. + uint64_t nPingNonceSent; + // Time (in usec) the last ping was sent, or 0 if no ping was ever sent. + int64_t nPingUsecStart; + // Last measured round-trip time. + int64_t nPingUsecTime; + // Whether a ping is requested. + bool fPingQueued; + + CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : ssSend(SER_NETWORK, INIT_PROTO_VERSION), setAddrKnown(5000) + { + nServices = 0; + hSocket = hSocketIn; + nRecvVersion = INIT_PROTO_VERSION; + nLastSend = 0; + nLastRecv = 0; + nSendBytes = 0; + nRecvBytes = 0; + nTimeConnected = GetTime(); + //nTimeOffset = 0; + addr = addrIn; + addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; + nVersion = 0; + strSubVer = ""; + fOneShot = false; + fClient = false; // set by version message + fInbound = fInboundIn; + fNetworkNode = false; + fSuccessfullyConnected = false; + fDisconnect = false; + nRefCount = 0; + nSendSize = 0; + nSendOffset = 0; + hashContinue = 0; + pindexLastGetBlocksBegin = 0; + hashLastGetBlocksEnd = 0; + nStartingHeight = -1; + fStartSync = false; + fGetAddr = false; + nMisbehavior = 0; + hashCheckpointKnown = 0; + setInventoryKnown.max_size(SendBufferSize() / 1000); + nPingNonceSent = 0; + nPingUsecStart = 0; + nPingUsecTime = 0; + fPingQueued = false; + + { + LOCK(cs_nLastNodeId); + id = nLastNodeId++; + } + + // Be shy and don't send version until we hear + if (hSocket != INVALID_SOCKET && !fInbound) + PushVersion(); + } + + ~CNode() + { + if (hSocket != INVALID_SOCKET) + { + closesocket(hSocket); + hSocket = INVALID_SOCKET; + } + } + +private: + // Network usage totals + static CCriticalSection cs_totalBytesRecv; + static CCriticalSection cs_totalBytesSent; + static uint64_t nTotalBytesRecv; + static uint64_t nTotalBytesSent; + + CNode(const CNode&); + void operator=(const CNode&); + +public: + NodeId GetId() const { + return id; + } + + int GetRefCount() + { + assert(nRefCount >= 0); + return nRefCount; + } + + // requires LOCK(cs_vRecvMsg) + unsigned int GetTotalRecvSize() + { + unsigned int total = 0; + BOOST_FOREACH(const CNetMessage &msg, vRecvMsg) + total += msg.vRecv.size() + 24; + return total; + } + + // requires LOCK(cs_vRecvMsg) + bool ReceiveMsgBytes(const char *pch, unsigned int nBytes); + + // requires LOCK(cs_vRecvMsg) + void SetRecvVersion(int nVersionIn) + { + nRecvVersion = nVersionIn; + BOOST_FOREACH(CNetMessage &msg, vRecvMsg) + msg.SetVersion(nVersionIn); + } + + CNode* AddRef() + { + nRefCount++; + return this; + } + + void Release() + { + nRefCount--; + } + + + + void AddAddressKnown(const CAddress& addr) + { + setAddrKnown.insert(addr); + } + + void PushAddress(const CAddress& addr) + { + // Known checking here is only to save space from duplicates. + // SendMessages will filter it again for knowns that were added + // after addresses were pushed. + if (addr.IsValid() && !setAddrKnown.count(addr)) + vAddrToSend.push_back(addr); + } + + + void AddInventoryKnown(const CInv& inv) + { + { + LOCK(cs_inventory); + setInventoryKnown.insert(inv); + } + } + + void PushInventory(const CInv& inv) + { + { + LOCK(cs_inventory); + if (!setInventoryKnown.count(inv)) + vInventoryToSend.push_back(inv); + } + } + + void AskFor(const CInv& inv, bool fImmediateRetry = false) + { + // We're using mapAskFor as a priority queue, + // the key is the earliest time the request can be sent + int64_t& nRequestTime = mapAlreadyAskedFor[inv]; + LogPrint("net", "askfor %s %d (%s)\n", inv.ToString(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000)); + + // Make sure not to reuse time indexes to keep things in the same order + int64_t nNow = (GetTime() - 1) * 1000000; + static int64_t nLastTime; + ++nLastTime; + nNow = std::max(nNow, nLastTime); + nLastTime = nNow; + + // Retry immediately during initial sync otherwise retry 2 minutes after the last + if (fImmediateRetry) + nRequestTime = nNow; + + else + nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow); + mapAskFor.insert(std::make_pair(nRequestTime, inv)); + } + + + + // TODO: Document the postcondition of this function. Is cs_vSend locked? + void BeginMessage(const char* pszCommand) EXCLUSIVE_LOCK_FUNCTION(cs_vSend) + { + ENTER_CRITICAL_SECTION(cs_vSend); + assert(ssSend.size() == 0); + ssSend << CMessageHeader(pszCommand, 0); + LogPrint("net", "sending: %s ", pszCommand); + } + + // TODO: Document the precondition of this function. Is cs_vSend locked? + void AbortMessage() UNLOCK_FUNCTION(cs_vSend) + { + ssSend.clear(); + + LEAVE_CRITICAL_SECTION(cs_vSend); + + LogPrint("net", "(aborted)\n"); + } + + // TODO: Document the precondition of this function. Is cs_vSend locked? + void EndMessage() UNLOCK_FUNCTION(cs_vSend) + { + if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) + { + LogPrint("net", "dropmessages DROPPING SEND MESSAGE\n"); + AbortMessage(); + return; + } + + if (ssSend.size() == 0) + return; + + // Set the size + unsigned int nSize = ssSend.size() - CMessageHeader::HEADER_SIZE; + memcpy((char*)&ssSend[CMessageHeader::MESSAGE_SIZE_OFFSET], &nSize, sizeof(nSize)); + + // Set the checksum + uint256 hash = Hash(ssSend.begin() + CMessageHeader::HEADER_SIZE, ssSend.end()); + unsigned int nChecksum = 0; + memcpy(&nChecksum, &hash, sizeof(nChecksum)); + assert(ssSend.size () >= CMessageHeader::CHECKSUM_OFFSET + sizeof(nChecksum)); + memcpy((char*)&ssSend[CMessageHeader::CHECKSUM_OFFSET], &nChecksum, sizeof(nChecksum)); + + LogPrint("net", "(%d bytes)\n", nSize); + + std::deque::iterator it = vSendMsg.insert(vSendMsg.end(), CSerializeData()); + ssSend.GetAndClear(*it); + nSendSize += (*it).size(); + + // If write queue empty, attempt "optimistic write" + if (it == vSendMsg.begin()) + SocketSendData(this); + + LEAVE_CRITICAL_SECTION(cs_vSend); + } + + void PushVersion(); + + + void PushMessage(const char* pszCommand) + { + try + { + BeginMessage(pszCommand); + EndMessage(); + } + catch (...) + { + AbortMessage(); + throw; + } + } + + template + void PushMessage(const char* pszCommand, const T1& a1) + { + try + { + BeginMessage(pszCommand); + ssSend << a1; + EndMessage(); + } + catch (...) + { + AbortMessage(); + throw; + } + } + + template + void PushMessage(const char* pszCommand, const T1& a1, const T2& a2) + { + try + { + BeginMessage(pszCommand); + ssSend << a1 << a2; + EndMessage(); + } + catch (...) + { + AbortMessage(); + throw; + } + } + + template + void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3) + { + try + { + BeginMessage(pszCommand); + ssSend << a1 << a2 << a3; + EndMessage(); + } + catch (...) + { + AbortMessage(); + throw; + } + } + + template + void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4) + { + try + { + BeginMessage(pszCommand); + ssSend << a1 << a2 << a3 << a4; + EndMessage(); + } + catch (...) + { + AbortMessage(); + throw; + } + } + + template + void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5) + { + try + { + BeginMessage(pszCommand); + ssSend << a1 << a2 << a3 << a4 << a5; + EndMessage(); + } + catch (...) + { + AbortMessage(); + throw; + } + } + + template + void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6) + { + try + { + BeginMessage(pszCommand); + ssSend << a1 << a2 << a3 << a4 << a5 << a6; + EndMessage(); + } + catch (...) + { + AbortMessage(); + throw; + } + } + + template + void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6, const T7& a7) + { + try + { + BeginMessage(pszCommand); + ssSend << a1 << a2 << a3 << a4 << a5 << a6 << a7; + EndMessage(); + } + catch (...) + { + AbortMessage(); + throw; + } + } + + template + void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6, const T7& a7, const T8& a8) + { + try + { + BeginMessage(pszCommand); + ssSend << a1 << a2 << a3 << a4 << a5 << a6 << a7 << a8; + EndMessage(); + } + catch (...) + { + AbortMessage(); + throw; + } + } + + template + void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6, const T7& a7, const T8& a8, const T9& a9) + { + try + { + BeginMessage(pszCommand); + ssSend << a1 << a2 << a3 << a4 << a5 << a6 << a7 << a8 << a9; + EndMessage(); + } + catch (...) + { + AbortMessage(); + throw; + } + } + +template + void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6, const T7& a7, const T8& a8, const T9& a9, const T10& a10) + { + try + { + BeginMessage(pszCommand); + ssSend << a1 << a2 << a3 << a4 << a5 << a6 << a7 << a8 << a9 << a10; + EndMessage(); + } + catch (...) + { + AbortMessage(); + throw; + } + } + + bool HasFulfilledRequest(std::string strRequest) + { + BOOST_FOREACH(std::string& type, vecRequestsFulfilled) + { + if(type == strRequest) return true; + } + return false; + } + + void FulfilledRequest(std::string strRequest) + { + if(HasFulfilledRequest(strRequest)) return; + vecRequestsFulfilled.push_back(strRequest); + } + + bool IsSubscribed(unsigned int nChannel); + void Subscribe(unsigned int nChannel, unsigned int nHops=0); + void CancelSubscribe(unsigned int nChannel); + void CloseSocketDisconnect(); + + // Denial-of-service detection/prevention + // The idea is to detect peers that are behaving + // badly and disconnect/ban them, but do it in a + // one-coding-mistake-won't-shatter-the-entire-network + // way. + // IMPORTANT: There should be nothing I can give a + // node that it will forward on that will make that + // node's peers drop it. If there is, an attacker + // can isolate a node and/or try to split the network. + // Dropping a node for sending stuff that is invalid + // now but might be valid in a later version is also + // dangerous, because it can cause a network split + // between nodes running old code and nodes running + // new code. + static void ClearBanned(); // needed for unit testing + static bool IsBanned(CNetAddr ip); + bool Misbehaving(int howmuch); // 1 == a little, 100 == a lot + void copyStats(CNodeStats &stats); + + // Network stats + static void RecordBytesRecv(uint64_t bytes); + static void RecordBytesSent(uint64_t bytes); + + static uint64_t GetTotalBytesRecv(); + static uint64_t GetTotalBytesSent(); +}; + +inline void RelayInventory(const CInv& inv) +{ + // Put on lists to offer to the other nodes + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + pnode->PushInventory(inv); + } +} + +class CTransaction; +void RelayTransaction(const CTransaction& tx, const uint256& hash); +void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataStream& ss); +void RelayTransactionLockReq(const CTransaction& tx, const uint256& hash, bool relayToAll=false); +void RelayDarkSendFinalTransaction(const int sessionID, const CTransaction& txNew); +void RelayDarkSendIn(const std::vector& in, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& out); +void RelayDarkSendStatus(const int sessionID, const int newState, const int newEntriesCount, const int newAccepted, const std::string error=""); +void RelayDarkSendElectionEntry(const CTxIn vin, const CService addr, const std::vector vchSig, const int64_t nNow, const CPubKey pubkey, const CPubKey pubkey2, const int count, const int current, const int64_t lastUpdated, const int protocolVersion); +void SendDarkSendElectionEntry(const CTxIn vin, const CService addr, const std::vector vchSig, const int64_t nNow, const CPubKey pubkey, const CPubKey pubkey2, const int count, const int current, const int64_t lastUpdated, const int protocolVersion); +void RelayDarkSendElectionEntryPing(const CTxIn vin, const std::vector vchSig, const int64_t nNow, const bool stop); +void SendDarkSendElectionEntryPing(const CTxIn vin, const std::vector vchSig, const int64_t nNow, const bool stop); +void RelayDarkSendCompletedTransaction(const int sessionID, const bool error, const std::string errorMessage); +void RelayDarkSendMasterNodeContestant(); + +/** Access to the (IP) address database (peers.dat) */ +class CAddrDB +{ +private: + boost::filesystem::path pathAddr; +public: + CAddrDB(); + bool Write(const CAddrMan& addr); + bool Read(CAddrMan& addr); +}; + +#endif diff --git a/src/netbase.cpp b/src/netbase.cpp new file mode 100644 index 0000000..a0d7424 --- /dev/null +++ b/src/netbase.cpp @@ -0,0 +1,1094 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "netbase.h" +#include "util.h" +#include "sync.h" +#include "hash.h" + +#ifndef WIN32 +#include +#endif + +#include // for to_lower() +#include // for startswith() and endswith() + +using namespace std; + +// Settings +static proxyType proxyInfo[NET_MAX]; +static CService nameProxy; +static CCriticalSection cs_proxyInfos; +int nConnectTimeout = 5000; +bool fNameLookup = false; + +static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff }; + +enum Network ParseNetwork(std::string net) { + boost::to_lower(net); + if (net == "ipv4") return NET_IPV4; + if (net == "ipv6") return NET_IPV6; + if (net == "tor") return NET_TOR; + if (net == "i2p") return NET_I2P; // Initilised I2pd full C# implemented by 216k155 for later start + return NET_UNROUTABLE; +} + +void SplitHostPort(std::string in, int &portOut, std::string &hostOut) { + size_t colon = in.find_last_of(':'); + // if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator + bool fHaveColon = colon != in.npos; + bool fBracketed = fHaveColon && (in[0]=='[' && in[colon-1]==']'); // if there is a colon, and in[0]=='[', colon is not 0, so in[colon-1] is safe + bool fMultiColon = fHaveColon && (in.find_last_of(':',colon-1) != in.npos); + if (fHaveColon && (colon==0 || fBracketed || !fMultiColon)) { + char *endp = NULL; + int n = strtol(in.c_str() + colon + 1, &endp, 10); + if (endp && *endp == 0 && n >= 0) { + in = in.substr(0, colon); + if (n > 0 && n < 0x10000) + portOut = n; + } + } + if (in.size()>0 && in[0] == '[' && in[in.size()-1] == ']') + hostOut = in.substr(1, in.size()-2); + else + hostOut = in; +} + +bool static LookupIntern(const char *pszName, std::vector& vIP, unsigned int nMaxSolutions, bool fAllowLookup) +{ + vIP.clear(); + + { + CNetAddr addr; + if (addr.SetSpecial(std::string(pszName))) { + vIP.push_back(addr); + return true; + } + } + + struct addrinfo aiHint; + memset(&aiHint, 0, sizeof(struct addrinfo)); + + aiHint.ai_socktype = SOCK_STREAM; + aiHint.ai_protocol = IPPROTO_TCP; +#ifdef WIN32 + aiHint.ai_family = AF_UNSPEC; + aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST; +#else + aiHint.ai_family = AF_UNSPEC; + aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST; +#endif + struct addrinfo *aiRes = NULL; + int nErr = getaddrinfo(pszName, NULL, &aiHint, &aiRes); + if (nErr) + return false; + + struct addrinfo *aiTrav = aiRes; + while (aiTrav != NULL && (nMaxSolutions == 0 || vIP.size() < nMaxSolutions)) + { + if (aiTrav->ai_family == AF_INET) + { + assert(aiTrav->ai_addrlen >= sizeof(sockaddr_in)); + vIP.push_back(CNetAddr(((struct sockaddr_in*)(aiTrav->ai_addr))->sin_addr)); + } + + if (aiTrav->ai_family == AF_INET6) + { + assert(aiTrav->ai_addrlen >= sizeof(sockaddr_in6)); + vIP.push_back(CNetAddr(((struct sockaddr_in6*)(aiTrav->ai_addr))->sin6_addr)); + } + + aiTrav = aiTrav->ai_next; + } + + freeaddrinfo(aiRes); + + return (vIP.size() > 0); +} + +bool LookupHost(const char *pszName, std::vector& vIP, unsigned int nMaxSolutions, bool fAllowLookup) +{ + std::string str(pszName); + std::string strHost = str; + if (str.empty()) + return false; + if (boost::algorithm::starts_with(str, "[") && boost::algorithm::ends_with(str, "]")) + { + strHost = str.substr(1, str.size() - 2); + } + + return LookupIntern(strHost.c_str(), vIP, nMaxSolutions, fAllowLookup); +} + +bool Lookup(const char *pszName, std::vector& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions) +{ + if (pszName[0] == 0) + return false; + int port = portDefault; + std::string hostname = ""; + SplitHostPort(std::string(pszName), port, hostname); + + std::vector vIP; + bool fRet = LookupIntern(hostname.c_str(), vIP, nMaxSolutions, fAllowLookup); + if (!fRet) + return false; + vAddr.resize(vIP.size()); + for (unsigned int i = 0; i < vIP.size(); i++) + vAddr[i] = CService(vIP[i], port); + return true; +} + +bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLookup) +{ + std::vector vService; + bool fRet = Lookup(pszName, vService, portDefault, fAllowLookup, 1); + if (!fRet) + return false; + addr = vService[0]; + return true; +} + +bool LookupNumeric(const char *pszName, CService& addr, int portDefault) +{ + return Lookup(pszName, addr, portDefault, false); +} + +bool static Socks5(string strDest, int port, SOCKET& hSocket) +{ + LogPrintf("SOCKS5 connecting %s\n", strDest); + if (strDest.size() > 255) + { + closesocket(hSocket); + return error("Hostname too long"); + } + char pszSocks5Init[] = "\5\1\0"; + char *pszSocks5 = pszSocks5Init; + ssize_t nSize = sizeof(pszSocks5Init) - 1; + + ssize_t ret = send(hSocket, pszSocks5, nSize, MSG_NOSIGNAL); + if (ret != nSize) + { + closesocket(hSocket); + return error("Error sending to proxy"); + } + char pchRet1[2]; + if (recv(hSocket, pchRet1, 2, 0) != 2) + { + closesocket(hSocket); + return error("Error reading proxy response"); + } + if (pchRet1[0] != 0x05 || pchRet1[1] != 0x00) + { + closesocket(hSocket); + return error("Proxy failed to initialize"); + } + string strSocks5("\5\1"); + strSocks5 += '\000'; strSocks5 += '\003'; + strSocks5 += static_cast(std::min((int)strDest.size(), 255)); + strSocks5 += strDest; + strSocks5 += static_cast((port >> 8) & 0xFF); + strSocks5 += static_cast((port >> 0) & 0xFF); + ret = send(hSocket, strSocks5.data(), strSocks5.size(), MSG_NOSIGNAL); + if (ret != (ssize_t)strSocks5.size()) + { + closesocket(hSocket); + return error("Error sending to proxy"); + } + char pchRet2[4]; + if (recv(hSocket, pchRet2, 4, 0) != 4) + { + closesocket(hSocket); + return error("Error reading proxy response"); + } + if (pchRet2[0] != 0x05) + { + closesocket(hSocket); + return error("Proxy failed to accept request"); + } + if (pchRet2[1] != 0x00) + { + closesocket(hSocket); + switch (pchRet2[1]) + { + case 0x01: return error("Proxy error: general failure"); + case 0x02: return error("Proxy error: connection not allowed"); + case 0x03: return error("Proxy error: network unreachable"); + case 0x04: return error("Proxy error: host unreachable"); + case 0x05: return error("Proxy error: connection refused"); + case 0x06: return error("Proxy error: TTL expired"); + case 0x07: return error("Proxy error: protocol error"); + case 0x08: return error("Proxy error: address type not supported"); + default: return error("Proxy error: unknown"); + } + } + if (pchRet2[2] != 0x00) + { + closesocket(hSocket); + return error("Error: malformed proxy response"); + } + char pchRet3[256]; + switch (pchRet2[3]) + { + case 0x01: ret = recv(hSocket, pchRet3, 4, 0) != 4; break; + case 0x04: ret = recv(hSocket, pchRet3, 16, 0) != 16; break; + case 0x03: + { + ret = recv(hSocket, pchRet3, 1, 0) != 1; + if (ret) { + closesocket(hSocket); + return error("Error reading from proxy"); + } + int nRecv = pchRet3[0]; + ret = recv(hSocket, pchRet3, nRecv, 0) != nRecv; + break; + } + default: closesocket(hSocket); return error("Error: malformed proxy response"); + } + if (ret) + { + closesocket(hSocket); + return error("Error reading from proxy"); + } + if (recv(hSocket, pchRet3, 2, 0) != 2) + { + closesocket(hSocket); + return error("Error reading from proxy"); + } + LogPrintf("SOCKS5 connected %s\n", strDest); + return true; +} + +bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRet, int nTimeout) +{ + hSocketRet = INVALID_SOCKET; + + struct sockaddr_storage sockaddr; + socklen_t len = sizeof(sockaddr); + if (!addrConnect.GetSockAddr((struct sockaddr*)&sockaddr, &len)) { + LogPrintf("Cannot connect to %s: unsupported network\n", addrConnect.ToString()); + return false; + } + + SOCKET hSocket = socket(((struct sockaddr*)&sockaddr)->sa_family, SOCK_STREAM, IPPROTO_TCP); + if (hSocket == INVALID_SOCKET) + return false; + int set = 1; +#ifdef SO_NOSIGPIPE + // Different way of disabling SIGPIPE on BSD + setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int)); +#endif + + //Disable Nagle's algorithm +#ifdef WIN32 + setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&set, sizeof(int)); +#else + setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&set, sizeof(int)); +#endif + +#ifdef WIN32 + u_long fNonblock = 1; + if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR) +#else + int fFlags = fcntl(hSocket, F_GETFL, 0); + if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == -1) +#endif + { + closesocket(hSocket); + return false; + } + + if (connect(hSocket, (struct sockaddr*)&sockaddr, len) == SOCKET_ERROR) + { + int nErr = WSAGetLastError(); + // WSAEINVAL is here because some legacy version of winsock uses it + if (nErr == WSAEINPROGRESS || nErr == WSAEWOULDBLOCK || nErr == WSAEINVAL) + { + struct timeval timeout; + timeout.tv_sec = nTimeout / 1000; + timeout.tv_usec = (nTimeout % 1000) * 1000; + + fd_set fdset; + FD_ZERO(&fdset); + FD_SET(hSocket, &fdset); + int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout); + if (nRet == 0) + { + LogPrint("net", "connection to %s timeout\n", addrConnect.ToString()); + closesocket(hSocket); + return false; + } + if (nRet == SOCKET_ERROR) + { + LogPrintf("select() for %s failed: %i\n", addrConnect.ToString(), WSAGetLastError()); + closesocket(hSocket); + return false; + } + socklen_t nRetSize = sizeof(nRet); +#ifdef WIN32 + if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, (char*)(&nRet), &nRetSize) == SOCKET_ERROR) +#else + if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR) +#endif + { + LogPrintf("getsockopt() for %s failed: %i\n", addrConnect.ToString(), WSAGetLastError()); + closesocket(hSocket); + return false; + } + if (nRet != 0) + { + LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), strerror(nRet)); + closesocket(hSocket); + return false; + } + } +#ifdef WIN32 + else if (WSAGetLastError() != WSAEISCONN) +#else + else +#endif + { + LogPrintf("connect() to %s failed: %i\n", addrConnect.ToString(), WSAGetLastError()); + closesocket(hSocket); + return false; + } + } + + // this isn't even strictly necessary + // CNode::ConnectNode immediately turns the socket back to non-blocking + // but we'll turn it back to blocking just in case +#ifdef WIN32 + fNonblock = 0; + if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR) +#else + fFlags = fcntl(hSocket, F_GETFL, 0); + if (fcntl(hSocket, F_SETFL, fFlags & !O_NONBLOCK) == SOCKET_ERROR) +#endif + { + closesocket(hSocket); + return false; + } + + hSocketRet = hSocket; + return true; +} + +bool SetProxy(enum Network net, CService addrProxy) { + assert(net >= 0 && net < NET_MAX); + if (!addrProxy.IsValid()) + return false; + LOCK(cs_proxyInfos); + proxyInfo[net] = addrProxy; + return true; +} + +bool GetProxy(enum Network net, proxyType &proxyInfoOut) { + assert(net >= 0 && net < NET_MAX); + LOCK(cs_proxyInfos); + if (!proxyInfo[net].IsValid()) + return false; + proxyInfoOut = proxyInfo[net]; + return true; +} + +bool SetNameProxy(CService addrProxy) { + if (!addrProxy.IsValid()) + return false; + LOCK(cs_proxyInfos); + nameProxy = addrProxy; + return true; +} + +bool GetNameProxy(CService &nameProxyOut) { + LOCK(cs_proxyInfos); + if(!nameProxy.IsValid()) + return false; + nameProxyOut = nameProxy; + return true; +} + +bool HaveNameProxy() { + LOCK(cs_proxyInfos); + return nameProxy.IsValid(); +} + +bool IsProxy(const CNetAddr &addr) { + LOCK(cs_proxyInfos); + for (int i = 0; i < NET_MAX; i++) { + if (addr == (CNetAddr)proxyInfo[i]) + return true; + } + return false; +} + +bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed) +{ + proxyType proxy; + if (outProxyConnectionFailed) + *outProxyConnectionFailed = false; + // no proxy needed (none set for target network) + if (!GetProxy(addrDest.GetNetwork(), proxy)) + return ConnectSocketDirectly(addrDest, hSocketRet, nTimeout); + + SOCKET hSocket = INVALID_SOCKET; + + // first connect to proxy server + if (!ConnectSocketDirectly(proxy, hSocket, nTimeout)) { + if (outProxyConnectionFailed) + *outProxyConnectionFailed = true; + return false; + } + // do socks negotiation + if (!Socks5(addrDest.ToStringIP(), addrDest.GetPort(), hSocket)) + return false; + + hSocketRet = hSocket; + return true; +} + +bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout, bool *outProxyConnectionFailed) +{ + string strDest; + int port = portDefault; + + if (outProxyConnectionFailed) + *outProxyConnectionFailed = false; + + SplitHostPort(string(pszDest), port, strDest); + + SOCKET hSocket = INVALID_SOCKET; + + CService nameProxy; + GetNameProxy(nameProxy); + + CService addrResolved(CNetAddr(strDest, fNameLookup && !HaveNameProxy()), port); + if (addrResolved.IsValid()) { + addr = addrResolved; + return ConnectSocket(addr, hSocketRet, nTimeout); + } + + addr = CService("0.0.0.0:0"); + + if (!HaveNameProxy()) + return false; + // first connect to name proxy server + if (!ConnectSocketDirectly(nameProxy, hSocket, nTimeout)) { + if (outProxyConnectionFailed) + *outProxyConnectionFailed = true; + return false; + } + // do socks negotiation + if (!Socks5(strDest, (unsigned short)port, hSocket)) + return false; + + hSocketRet = hSocket; + return true; +} + +void CNetAddr::Init() +{ + memset(ip, 0, sizeof(ip)); +} + +void CNetAddr::SetIP(const CNetAddr& ipIn) +{ + memcpy(ip, ipIn.ip, sizeof(ip)); +} + +static const unsigned char pchOnionCat[] = {0xFD,0x87,0xD8,0x7E,0xEB,0x43}; +static const unsigned char pchGarliCat[] = {0xFD,0x60,0xDB,0x4D,0xDD,0xB5}; + +bool CNetAddr::SetSpecial(const std::string &strName) +{ + if (strName.size()>6 && strName.substr(strName.size() - 6, 6) == ".onion") { + std::vector vchAddr = DecodeBase32(strName.substr(0, strName.size() - 6).c_str()); + if (vchAddr.size() != 16-sizeof(pchOnionCat)) + return false; + memcpy(ip, pchOnionCat, sizeof(pchOnionCat)); + for (unsigned int i=0; i<16-sizeof(pchOnionCat); i++) + ip[i + sizeof(pchOnionCat)] = vchAddr[i]; + return true; + } + if (strName.size()>11 && strName.substr(strName.size() - 11, 11) == ".oc.b32.i2p") { + std::vector vchAddr = DecodeBase32(strName.substr(0, strName.size() - 11).c_str()); + if (vchAddr.size() != 16-sizeof(pchGarliCat)) + return false; + memcpy(ip, pchOnionCat, sizeof(pchGarliCat)); + for (unsigned int i=0; i<16-sizeof(pchGarliCat); i++) + ip[i + sizeof(pchGarliCat)] = vchAddr[i]; + return true; + } + return false; +} + +CNetAddr::CNetAddr() +{ + Init(); +} + +CNetAddr::CNetAddr(const struct in_addr& ipv4Addr) +{ + memcpy(ip, pchIPv4, 12); + memcpy(ip+12, &ipv4Addr, 4); +} + +CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr) +{ + memcpy(ip, &ipv6Addr, 16); +} + +CNetAddr::CNetAddr(const char *pszIp, bool fAllowLookup) +{ + Init(); + std::vector vIP; + if (LookupHost(pszIp, vIP, 1, fAllowLookup)) + *this = vIP[0]; +} + +CNetAddr::CNetAddr(const std::string &strIp, bool fAllowLookup) +{ + Init(); + std::vector vIP; + if (LookupHost(strIp.c_str(), vIP, 1, fAllowLookup)) + *this = vIP[0]; +} + +unsigned int CNetAddr::GetByte(int n) const +{ + return ip[15-n]; +} + +bool CNetAddr::IsIPv4() const +{ + return (memcmp(ip, pchIPv4, sizeof(pchIPv4)) == 0); +} + +bool CNetAddr::IsIPv6() const +{ + return (!IsIPv4() && !IsTor() && !IsI2P()); +} + +bool CNetAddr::IsRFC1918() const +{ + return IsIPv4() && ( + GetByte(3) == 10 || + (GetByte(3) == 192 && GetByte(2) == 168) || + (GetByte(3) == 172 && (GetByte(2) >= 16 && GetByte(2) <= 31))); +} + +bool CNetAddr::IsRFC3927() const +{ + return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254); +} + +bool CNetAddr::IsRFC3849() const +{ + return GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x0D && GetByte(12) == 0xB8; +} + +bool CNetAddr::IsRFC3964() const +{ + return (GetByte(15) == 0x20 && GetByte(14) == 0x02); +} + +bool CNetAddr::IsRFC6052() const +{ + static const unsigned char pchRFC6052[] = {0,0x64,0xFF,0x9B,0,0,0,0,0,0,0,0}; + return (memcmp(ip, pchRFC6052, sizeof(pchRFC6052)) == 0); +} + +bool CNetAddr::IsRFC4380() const +{ + return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0 && GetByte(12) == 0); +} + +bool CNetAddr::IsRFC4862() const +{ + static const unsigned char pchRFC4862[] = {0xFE,0x80,0,0,0,0,0,0}; + return (memcmp(ip, pchRFC4862, sizeof(pchRFC4862)) == 0); +} + +bool CNetAddr::IsRFC4193() const +{ + return ((GetByte(15) & 0xFE) == 0xFC); +} + +bool CNetAddr::IsRFC6145() const +{ + static const unsigned char pchRFC6145[] = {0,0,0,0,0,0,0,0,0xFF,0xFF,0,0}; + return (memcmp(ip, pchRFC6145, sizeof(pchRFC6145)) == 0); +} + +bool CNetAddr::IsRFC4843() const +{ + return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x00 && (GetByte(12) & 0xF0) == 0x10); +} + +bool CNetAddr::IsTor() const +{ + return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0); +} + +bool CNetAddr::IsI2P() const +{ + return (memcmp(ip, pchGarliCat, sizeof(pchGarliCat)) == 0); +} + +bool CNetAddr::IsLocal() const +{ + // IPv4 loopback + if (IsIPv4() && (GetByte(3) == 127 || GetByte(3) == 0)) + return true; + + // IPv6 loopback (::1/128) + static const unsigned char pchLocal[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; + if (memcmp(ip, pchLocal, 16) == 0) + return true; + + return false; +} + +bool CNetAddr::IsMulticast() const +{ + return (IsIPv4() && (GetByte(3) & 0xF0) == 0xE0) + || (GetByte(15) == 0xFF); +} + +bool CNetAddr::IsValid() const +{ + // Cleanup 3-byte shifted addresses caused by garbage in size field + // of addr messages from versions before 0.2.9 checksum. + // Two consecutive addr messages look like this: + // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26... + // so if the first length field is garbled, it reads the second batch + // of addr misaligned by 3 bytes. + if (memcmp(ip, pchIPv4+3, sizeof(pchIPv4)-3) == 0) + return false; + + // unspecified IPv6 address (::/128) + unsigned char ipNone[16] = {}; + if (memcmp(ip, ipNone, 16) == 0) + return false; + + // documentation IPv6 address + if (IsRFC3849()) + return false; + + if (IsIPv4()) + { + // INADDR_NONE + uint32_t ipNone = INADDR_NONE; + if (memcmp(ip+12, &ipNone, 4) == 0) + return false; + + // 0 + ipNone = 0; + if (memcmp(ip+12, &ipNone, 4) == 0) + return false; + } + + return true; +} + +bool CNetAddr::IsRoutable() const +{ + return IsValid() && !(IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193() && !IsTor() && !IsI2P()) || IsRFC4843() || IsLocal()); +} + +enum Network CNetAddr::GetNetwork() const +{ + if (!IsRoutable()) + return NET_UNROUTABLE; + + if (IsIPv4()) + return NET_IPV4; + + if (IsTor()) + return NET_TOR; + + if (IsI2P()) + return NET_I2P; + + return NET_IPV6; +} + +std::string CNetAddr::ToStringIP() const +{ + if (IsTor()) + return EncodeBase32(&ip[6], 10) + ".onion"; + if (IsI2P()) + return EncodeBase32(&ip[6], 10) + ".oc.b32.i2p"; + CService serv(*this, 0); + struct sockaddr_storage sockaddr; + socklen_t socklen = sizeof(sockaddr); + if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) { + char name[1025] = ""; + if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name, sizeof(name), NULL, 0, NI_NUMERICHOST)) + return std::string(name); + } + if (IsIPv4()) + return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0)); + else + return strprintf("%x:%x:%x:%x:%x:%x:%x:%x", + GetByte(15) << 8 | GetByte(14), GetByte(13) << 8 | GetByte(12), + GetByte(11) << 8 | GetByte(10), GetByte(9) << 8 | GetByte(8), + GetByte(7) << 8 | GetByte(6), GetByte(5) << 8 | GetByte(4), + GetByte(3) << 8 | GetByte(2), GetByte(1) << 8 | GetByte(0)); +} + +std::string CNetAddr::ToString() const +{ + return ToStringIP(); +} + +bool operator==(const CNetAddr& a, const CNetAddr& b) +{ + return (memcmp(a.ip, b.ip, 16) == 0); +} + +bool operator!=(const CNetAddr& a, const CNetAddr& b) +{ + return (memcmp(a.ip, b.ip, 16) != 0); +} + +bool operator<(const CNetAddr& a, const CNetAddr& b) +{ + return (memcmp(a.ip, b.ip, 16) < 0); +} + +bool CNetAddr::GetInAddr(struct in_addr* pipv4Addr) const +{ + if (!IsIPv4()) + return false; + memcpy(pipv4Addr, ip+12, 4); + return true; +} + +bool CNetAddr::GetIn6Addr(struct in6_addr* pipv6Addr) const +{ + memcpy(pipv6Addr, ip, 16); + return true; +} + +// get canonical identifier of an address' group +// no two connections will be attempted to addresses with the same group +std::vector CNetAddr::GetGroup() const +{ + std::vector vchRet; + int nClass = NET_IPV6; + int nStartByte = 0; + int nBits = 16; + + // all local addresses belong to the same group + if (IsLocal()) + { + nClass = 255; + nBits = 0; + } + + // all unroutable addresses belong to the same group + if (!IsRoutable()) + { + nClass = NET_UNROUTABLE; + nBits = 0; + } + // for IPv4 addresses, '1' + the 16 higher-order bits of the IP + // includes mapped IPv4, SIIT translated IPv4, and the well-known prefix + else if (IsIPv4() || IsRFC6145() || IsRFC6052()) + { + nClass = NET_IPV4; + nStartByte = 12; + } + // for 6to4 tunnelled addresses, use the encapsulated IPv4 address + else if (IsRFC3964()) + { + nClass = NET_IPV4; + nStartByte = 2; + } + // for Teredo-tunnelled IPv6 addresses, use the encapsulated IPv4 address + else if (IsRFC4380()) + { + vchRet.push_back(NET_IPV4); + vchRet.push_back(GetByte(3) ^ 0xFF); + vchRet.push_back(GetByte(2) ^ 0xFF); + return vchRet; + } + else if (IsTor()) + { + nClass = NET_TOR; + nStartByte = 6; + nBits = 4; + } + else if (IsI2P()) + { + nClass = NET_I2P; + nStartByte = 6; + nBits = 4; + } + // for he.net, use /36 groups + else if (GetByte(15) == 0x20 && GetByte(14) == 0x11 && GetByte(13) == 0x04 && GetByte(12) == 0x70) + nBits = 36; + // for the rest of the IPv6 network, use /32 groups + else + nBits = 32; + + vchRet.push_back(nClass); + while (nBits >= 8) + { + vchRet.push_back(GetByte(15 - nStartByte)); + nStartByte++; + nBits -= 8; + } + if (nBits > 0) + vchRet.push_back(GetByte(15 - nStartByte) | ((1 << nBits) - 1)); + + return vchRet; +} + +uint64_t CNetAddr::GetHash() const +{ + uint256 hash = Hash(&ip[0], &ip[16]); + uint64_t nRet; + memcpy(&nRet, &hash, sizeof(nRet)); + return nRet; +} + +// private extensions to enum Network, only returned by GetExtNetwork, +// and only used in GetReachabilityFrom +static const int NET_UNKNOWN = NET_MAX + 0; +static const int NET_TEREDO = NET_MAX + 1; +int static GetExtNetwork(const CNetAddr *addr) +{ + if (addr == NULL) + return NET_UNKNOWN; + if (addr->IsRFC4380()) + return NET_TEREDO; + return addr->GetNetwork(); +} + +/** Calculates a metric for how reachable (*this) is from a given partner */ +int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const +{ + enum Reachability { + REACH_UNREACHABLE, + REACH_DEFAULT, + REACH_TEREDO, + REACH_IPV6_WEAK, + REACH_IPV4, + REACH_IPV6_STRONG, + REACH_PRIVATE + }; + + if (!IsRoutable()) + return REACH_UNREACHABLE; + + int ourNet = GetExtNetwork(this); + int theirNet = GetExtNetwork(paddrPartner); + bool fTunnel = IsRFC3964() || IsRFC6052() || IsRFC6145(); + + switch(theirNet) { + case NET_IPV4: + switch(ourNet) { + default: return REACH_DEFAULT; + case NET_IPV4: return REACH_IPV4; + } + case NET_IPV6: + switch(ourNet) { + default: return REACH_DEFAULT; + case NET_TEREDO: return REACH_TEREDO; + case NET_IPV4: return REACH_IPV4; + case NET_IPV6: return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; // only prefer giving our IPv6 address if it's not tunnelled + } + case NET_TOR: + switch(ourNet) { + default: return REACH_DEFAULT; + case NET_IPV4: return REACH_IPV4; // Tor users can connect to IPv4 as well + case NET_TOR: return REACH_PRIVATE; + } + case NET_I2P: + switch(ourNet) { + default: return REACH_DEFAULT; + case NET_I2P: return REACH_PRIVATE; + } + case NET_TEREDO: + switch(ourNet) { + default: return REACH_DEFAULT; + case NET_TEREDO: return REACH_TEREDO; + case NET_IPV6: return REACH_IPV6_WEAK; + case NET_IPV4: return REACH_IPV4; + } + case NET_UNKNOWN: + case NET_UNROUTABLE: + default: + switch(ourNet) { + default: return REACH_DEFAULT; + case NET_TEREDO: return REACH_TEREDO; + case NET_IPV6: return REACH_IPV6_WEAK; + case NET_IPV4: return REACH_IPV4; + case NET_I2P: return REACH_PRIVATE; // assume connections from unroutable addresses are + case NET_TOR: return REACH_PRIVATE; // either from Tor/I2P, or don't care about our address + } + } +} + +void CService::Init() +{ + port = 0; +} + +CService::CService() +{ + Init(); +} + +CService::CService(const CNetAddr& cip, unsigned short portIn) : CNetAddr(cip), port(portIn) +{ +} + +CService::CService(const struct in_addr& ipv4Addr, unsigned short portIn) : CNetAddr(ipv4Addr), port(portIn) +{ +} + +CService::CService(const struct in6_addr& ipv6Addr, unsigned short portIn) : CNetAddr(ipv6Addr), port(portIn) +{ +} + +CService::CService(const struct sockaddr_in& addr) : CNetAddr(addr.sin_addr), port(ntohs(addr.sin_port)) +{ + assert(addr.sin_family == AF_INET); +} + +CService::CService(const struct sockaddr_in6 &addr) : CNetAddr(addr.sin6_addr), port(ntohs(addr.sin6_port)) +{ + assert(addr.sin6_family == AF_INET6); +} + +bool CService::SetSockAddr(const struct sockaddr *paddr) +{ + switch (paddr->sa_family) { + case AF_INET: + *this = CService(*(const struct sockaddr_in*)paddr); + return true; + case AF_INET6: + *this = CService(*(const struct sockaddr_in6*)paddr); + return true; + default: + return false; + } +} + +CService::CService(const char *pszIpPort, bool fAllowLookup) +{ + Init(); + CService ip; + if (Lookup(pszIpPort, ip, 0, fAllowLookup)) + *this = ip; +} + +CService::CService(const char *pszIpPort, int portDefault, bool fAllowLookup) +{ + Init(); + CService ip; + if (Lookup(pszIpPort, ip, portDefault, fAllowLookup)) + *this = ip; +} + +CService::CService(const std::string &strIpPort, bool fAllowLookup) +{ + Init(); + CService ip; + if (Lookup(strIpPort.c_str(), ip, 0, fAllowLookup)) + *this = ip; +} + +CService::CService(const std::string &strIpPort, int portDefault, bool fAllowLookup) +{ + Init(); + CService ip; + if (Lookup(strIpPort.c_str(), ip, portDefault, fAllowLookup)) + *this = ip; +} + +unsigned short CService::GetPort() const +{ + return port; +} + +bool operator==(const CService& a, const CService& b) +{ + return (CNetAddr)a == (CNetAddr)b && a.port == b.port; +} + +bool operator!=(const CService& a, const CService& b) +{ + return (CNetAddr)a != (CNetAddr)b || a.port != b.port; +} + +bool operator<(const CService& a, const CService& b) +{ + return (CNetAddr)a < (CNetAddr)b || ((CNetAddr)a == (CNetAddr)b && a.port < b.port); +} + +bool CService::GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const +{ + if (IsIPv4()) { + if (*addrlen < (socklen_t)sizeof(struct sockaddr_in)) + return false; + *addrlen = sizeof(struct sockaddr_in); + struct sockaddr_in *paddrin = (struct sockaddr_in*)paddr; + memset(paddrin, 0, *addrlen); + if (!GetInAddr(&paddrin->sin_addr)) + return false; + paddrin->sin_family = AF_INET; + paddrin->sin_port = htons(port); + return true; + } + if (IsIPv6()) { + if (*addrlen < (socklen_t)sizeof(struct sockaddr_in6)) + return false; + *addrlen = sizeof(struct sockaddr_in6); + struct sockaddr_in6 *paddrin6 = (struct sockaddr_in6*)paddr; + memset(paddrin6, 0, *addrlen); + if (!GetIn6Addr(&paddrin6->sin6_addr)) + return false; + paddrin6->sin6_family = AF_INET6; + paddrin6->sin6_port = htons(port); + return true; + } + return false; +} + +std::vector CService::GetKey() const +{ + std::vector vKey; + vKey.resize(18); + memcpy(&vKey[0], ip, 16); + vKey[16] = port / 0x100; + vKey[17] = port & 0x0FF; + return vKey; +} + +std::string CService::ToStringPort() const +{ + return strprintf("%u", port); +} + +std::string CService::ToStringIPPort() const +{ + if (IsIPv4() || IsTor() || IsI2P()) { + return ToStringIP() + ":" + ToStringPort(); + } else { + return "[" + ToStringIP() + "]:" + ToStringPort(); + } +} + +std::string CService::ToString() const +{ + return ToStringIPPort(); +} + +void CService::SetPort(unsigned short portIn) +{ + port = portIn; +} diff --git a/src/netbase.h b/src/netbase.h new file mode 100644 index 0000000..94e7f0f --- /dev/null +++ b/src/netbase.h @@ -0,0 +1,144 @@ +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_NETBASE_H +#define BITCOIN_NETBASE_H + +#include +#include + +#include "serialize.h" +#include "compat.h" + +extern int nConnectTimeout; +extern bool fNameLookup; + +#ifdef WIN32 +// In MSVC, this is defined as a macro, undefine it to prevent a compile and link error +#undef SetPort +#endif + +enum Network +{ + NET_UNROUTABLE, + NET_IPV4, + NET_IPV6, + NET_TOR, + NET_I2P, // Remote activation i2pd + + NET_MAX, +}; + +/** IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96)) */ +class CNetAddr +{ + protected: + unsigned char ip[16]; // in network byte order + + public: + CNetAddr(); + CNetAddr(const struct in_addr& ipv4Addr); + explicit CNetAddr(const char *pszIp, bool fAllowLookup = false); + explicit CNetAddr(const std::string &strIp, bool fAllowLookup = false); + void Init(); + void SetIP(const CNetAddr& ip); + bool SetSpecial(const std::string &strName); // for Tor and I2P addresses + bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0) + bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor/I2P) + bool IsRFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12) + bool IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32) + bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16) + bool IsRFC3964() const; // IPv6 6to4 tunnelling (2002::/16) + bool IsRFC4193() const; // IPv6 unique local (FC00::/15) + bool IsRFC4380() const; // IPv6 Teredo tunnelling (2001::/32) + bool IsRFC4843() const; // IPv6 ORCHID (2001:10::/28) + bool IsRFC4862() const; // IPv6 autoconfig (FE80::/64) + bool IsRFC6052() const; // IPv6 well-known prefix (64:FF9B::/96) + bool IsRFC6145() const; // IPv6 IPv4-translated address (::FFFF:0:0:0/96) + bool IsTor() const; + bool IsI2P() const; + bool IsLocal() const; + bool IsRoutable() const; + bool IsValid() const; + bool IsMulticast() const; + enum Network GetNetwork() const; + std::string ToString() const; + std::string ToStringIP() const; + unsigned int GetByte(int n) const; + uint64_t GetHash() const; + bool GetInAddr(struct in_addr* pipv4Addr) const; + std::vector GetGroup() const; + int GetReachabilityFrom(const CNetAddr *paddrPartner = NULL) const; + + CNetAddr(const struct in6_addr& pipv6Addr); + bool GetIn6Addr(struct in6_addr* pipv6Addr) const; + + friend bool operator==(const CNetAddr& a, const CNetAddr& b); + friend bool operator!=(const CNetAddr& a, const CNetAddr& b); + friend bool operator<(const CNetAddr& a, const CNetAddr& b); + + IMPLEMENT_SERIALIZE + ( + READWRITE(FLATDATA(ip)); + ) +}; + +/** A combination of a network address (CNetAddr) and a (TCP) port */ +class CService : public CNetAddr +{ + protected: + unsigned short port; // host order + + public: + CService(); + CService(const CNetAddr& ip, unsigned short port); + CService(const struct in_addr& ipv4Addr, unsigned short port); + CService(const struct sockaddr_in& addr); + explicit CService(const char *pszIpPort, int portDefault, bool fAllowLookup = false); + explicit CService(const char *pszIpPort, bool fAllowLookup = false); + explicit CService(const std::string& strIpPort, int portDefault, bool fAllowLookup = false); + explicit CService(const std::string& strIpPort, bool fAllowLookup = false); + void Init(); + void SetPort(unsigned short portIn); + unsigned short GetPort() const; + bool GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const; + bool SetSockAddr(const struct sockaddr* paddr); + friend bool operator==(const CService& a, const CService& b); + friend bool operator!=(const CService& a, const CService& b); + friend bool operator<(const CService& a, const CService& b); + std::vector GetKey() const; + std::string ToString() const; + std::string ToStringPort() const; + std::string ToStringIPPort() const; + + CService(const struct in6_addr& ipv6Addr, unsigned short port); + CService(const struct sockaddr_in6& addr); + + IMPLEMENT_SERIALIZE + ( + CService* pthis = const_cast(this); + READWRITE(FLATDATA(ip)); + unsigned short portN = htons(port); + READWRITE(portN); + if (fRead) + pthis->port = ntohs(portN); + ) +}; + +typedef CService proxyType; + +enum Network ParseNetwork(std::string net); +void SplitHostPort(std::string in, int &portOut, std::string &hostOut); +bool SetProxy(enum Network net, CService addrProxy); +bool GetProxy(enum Network net, proxyType &proxyInfoOut); +bool IsProxy(const CNetAddr &addr); +bool SetNameProxy(CService addrProxy); +bool HaveNameProxy(); +bool LookupHost(const char *pszName, std::vector& vIP, unsigned int nMaxSolutions = 0, bool fAllowLookup = true); +bool Lookup(const char *pszName, CService& addr, int portDefault = 0, bool fAllowLookup = true); +bool Lookup(const char *pszName, std::vector& vAddr, int portDefault = 0, bool fAllowLookup = true, unsigned int nMaxSolutions = 0); +bool LookupNumeric(const char *pszName, CService& addr, int portDefault = 0); +bool ConnectSocket(const CService &addr, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed = 0); +bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout, bool *outProxyConnectionFailed = 0); + +#endif diff --git a/src/noui.cpp b/src/noui.cpp new file mode 100644 index 0000000..1290007 --- /dev/null +++ b/src/noui.cpp @@ -0,0 +1,50 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "ui_interface.h" +#include "init.h" + +#include + +static int noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style) +{ + std::string strCaption; + // Check for usage of predefined caption + switch (style) { + case CClientUIInterface::MSG_ERROR: + strCaption += _("Error"); + break; + case CClientUIInterface::MSG_WARNING: + strCaption += _("Warning"); + break; + case CClientUIInterface::MSG_INFORMATION: + strCaption += _("Information"); + break; + default: + strCaption += caption; // Use supplied caption + } + + LogPrintf("%s: %s\n", caption, message); + fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str()); + return 4; +} + +static bool noui_ThreadSafeAskFee(int64_t nFeeRequired, const std::string& strCaption) +{ + return true; +} + +static void noui_InitMessage(const std::string &message) +{ + LogPrintf("init message: %s\n", message); +} + +void noui_connect() +{ + // Connect bitcoind signal handlers + uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox); + uiInterface.ThreadSafeAskFee.connect(noui_ThreadSafeAskFee); + uiInterface.InitMessage.connect(noui_InitMessage); +} diff --git a/src/obj-test/.gitignore b/src/obj-test/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/src/obj-test/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/src/obj/crypto/hmac_sha256.P b/src/obj/crypto/hmac_sha256.P new file mode 100644 index 0000000..4de6a47 --- /dev/null +++ b/src/obj/crypto/hmac_sha256.P @@ -0,0 +1,6 @@ +obj/crypto/hmac_sha256.o: crypto/hmac_sha256.cpp \ + /root/SONO-master/src/crypto/hmac_sha256.h \ + /root/SONO-master/src/crypto/sha256.h +crypto/hmac_sha256.cpp : + /root/SONO-master/src/crypto/hmac_sha256.h : + /root/SONO-master/src/crypto/sha256.h : diff --git a/src/obj/crypto/hmac_sha256.o b/src/obj/crypto/hmac_sha256.o new file mode 100644 index 0000000..8c8c007 Binary files /dev/null and b/src/obj/crypto/hmac_sha256.o differ diff --git a/src/obj/crypto/hmac_sha512.P b/src/obj/crypto/hmac_sha512.P new file mode 100644 index 0000000..fcbc98b --- /dev/null +++ b/src/obj/crypto/hmac_sha512.P @@ -0,0 +1,6 @@ +obj/crypto/hmac_sha512.o: crypto/hmac_sha512.cpp \ + /root/SONO-master/src/crypto/hmac_sha512.h \ + /root/SONO-master/src/crypto/sha512.h +crypto/hmac_sha512.cpp : + /root/SONO-master/src/crypto/hmac_sha512.h : + /root/SONO-master/src/crypto/sha512.h : diff --git a/src/obj/crypto/hmac_sha512.o b/src/obj/crypto/hmac_sha512.o new file mode 100644 index 0000000..db6e36a Binary files /dev/null and b/src/obj/crypto/hmac_sha512.o differ diff --git a/src/obj/crypto/rfc6979_hmac_sha256.P b/src/obj/crypto/rfc6979_hmac_sha256.P new file mode 100644 index 0000000..e8c4df6 --- /dev/null +++ b/src/obj/crypto/rfc6979_hmac_sha256.P @@ -0,0 +1,8 @@ +obj/crypto/rfc6979_hmac_sha256.o: crypto/rfc6979_hmac_sha256.cpp \ + /root/SONO-master/src/crypto/rfc6979_hmac_sha256.h \ + /root/SONO-master/src/crypto/hmac_sha256.h \ + /root/SONO-master/src/crypto/sha256.h +crypto/rfc6979_hmac_sha256.cpp : + /root/SONO-master/src/crypto/rfc6979_hmac_sha256.h : + /root/SONO-master/src/crypto/hmac_sha256.h : + /root/SONO-master/src/crypto/sha256.h : diff --git a/src/obj/crypto/rfc6979_hmac_sha256.o b/src/obj/crypto/rfc6979_hmac_sha256.o new file mode 100644 index 0000000..f1d7d9d Binary files /dev/null and b/src/obj/crypto/rfc6979_hmac_sha256.o differ diff --git a/src/obj/crypto/ripemd160.P b/src/obj/crypto/ripemd160.P new file mode 100644 index 0000000..bb819e2 --- /dev/null +++ b/src/obj/crypto/ripemd160.P @@ -0,0 +1,6 @@ +obj/crypto/ripemd160.o: crypto/ripemd160.cpp \ + /root/SONO-master/src/crypto/ripemd160.h \ + /root/SONO-master/src/crypto/common.h +crypto/ripemd160.cpp : + /root/SONO-master/src/crypto/ripemd160.h : + /root/SONO-master/src/crypto/common.h : diff --git a/src/obj/crypto/ripemd160.o b/src/obj/crypto/ripemd160.o new file mode 100644 index 0000000..de50680 Binary files /dev/null and b/src/obj/crypto/ripemd160.o differ diff --git a/src/obj/crypto/sha1.P b/src/obj/crypto/sha1.P new file mode 100644 index 0000000..f04429d --- /dev/null +++ b/src/obj/crypto/sha1.P @@ -0,0 +1,4 @@ +obj/crypto/sha1.o: crypto/sha1.cpp /root/SONO-master/src/crypto/sha1.h \ + /root/SONO-master/src/crypto/common.h +crypto/sha1.cpp /root/SONO-master/src/crypto/sha1.h : + /root/SONO-master/src/crypto/common.h : diff --git a/src/obj/crypto/sha1.o b/src/obj/crypto/sha1.o new file mode 100644 index 0000000..26daad3 Binary files /dev/null and b/src/obj/crypto/sha1.o differ diff --git a/src/obj/crypto/sha256.P b/src/obj/crypto/sha256.P new file mode 100644 index 0000000..447699e --- /dev/null +++ b/src/obj/crypto/sha256.P @@ -0,0 +1,6 @@ +obj/crypto/sha256.o: crypto/sha256.cpp \ + /root/SONO-master/src/crypto/sha256.h \ + /root/SONO-master/src/crypto/common.h +crypto/sha256.cpp : + /root/SONO-master/src/crypto/sha256.h : + /root/SONO-master/src/crypto/common.h : diff --git a/src/obj/crypto/sha256.o b/src/obj/crypto/sha256.o new file mode 100644 index 0000000..166381b Binary files /dev/null and b/src/obj/crypto/sha256.o differ diff --git a/src/obj/crypto/sha512.P b/src/obj/crypto/sha512.P new file mode 100644 index 0000000..41e50b4 --- /dev/null +++ b/src/obj/crypto/sha512.P @@ -0,0 +1,6 @@ +obj/crypto/sha512.o: crypto/sha512.cpp \ + /root/SONO-master/src/crypto/sha512.h \ + /root/SONO-master/src/crypto/common.h +crypto/sha512.cpp : + /root/SONO-master/src/crypto/sha512.h : + /root/SONO-master/src/crypto/common.h : diff --git a/src/obj/crypto/sha512.o b/src/obj/crypto/sha512.o new file mode 100644 index 0000000..72f480d Binary files /dev/null and b/src/obj/crypto/sha512.o differ diff --git a/src/obj/skunkhash/aes_helper.c b/src/obj/skunkhash/aes_helper.c new file mode 100644 index 0000000..75b7cc6 --- /dev/null +++ b/src/obj/skunkhash/aes_helper.c @@ -0,0 +1,392 @@ +/* $Id: aes_helper.c 220 2010-06-09 09:21:50Z tp $ */ +/* + * AES tables. This file is not meant to be compiled by itself; it + * is included by some hash function implementations. It contains + * the precomputed tables and helper macros for evaluating an AES + * round, optionally with a final XOR with a subkey. + * + * By default, this file defines the tables and macros for little-endian + * processing (i.e. it is assumed that the input bytes have been read + * from memory and assembled with the little-endian convention). If + * the 'AES_BIG_ENDIAN' macro is defined (to a non-zero integer value) + * when this file is included, then the tables and macros for big-endian + * processing are defined instead. The big-endian tables and macros have + * names distinct from the little-endian tables and macros, hence it is + * possible to have both simultaneously, by including this file twice + * (with and without the AES_BIG_ENDIAN macro). + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @author Thomas Pornin + */ + +#include "sph_types.h" +#ifdef __cplusplus +extern "C"{ +#endif +#if AES_BIG_ENDIAN + +#define AESx(x) ( ((SPH_C32(x) >> 24) & SPH_C32(0x000000FF)) \ + | ((SPH_C32(x) >> 8) & SPH_C32(0x0000FF00)) \ + | ((SPH_C32(x) << 8) & SPH_C32(0x00FF0000)) \ + | ((SPH_C32(x) << 24) & SPH_C32(0xFF000000))) + +#define AES0 AES0_BE +#define AES1 AES1_BE +#define AES2 AES2_BE +#define AES3 AES3_BE + +#define AES_ROUND_BE(X0, X1, X2, X3, K0, K1, K2, K3, Y0, Y1, Y2, Y3) do { \ + (Y0) = AES0[((X0) >> 24) & 0xFF] \ + ^ AES1[((X1) >> 16) & 0xFF] \ + ^ AES2[((X2) >> 8) & 0xFF] \ + ^ AES3[(X3) & 0xFF] ^ (K0); \ + (Y1) = AES0[((X1) >> 24) & 0xFF] \ + ^ AES1[((X2) >> 16) & 0xFF] \ + ^ AES2[((X3) >> 8) & 0xFF] \ + ^ AES3[(X0) & 0xFF] ^ (K1); \ + (Y2) = AES0[((X2) >> 24) & 0xFF] \ + ^ AES1[((X3) >> 16) & 0xFF] \ + ^ AES2[((X0) >> 8) & 0xFF] \ + ^ AES3[(X1) & 0xFF] ^ (K2); \ + (Y3) = AES0[((X3) >> 24) & 0xFF] \ + ^ AES1[((X0) >> 16) & 0xFF] \ + ^ AES2[((X1) >> 8) & 0xFF] \ + ^ AES3[(X2) & 0xFF] ^ (K3); \ + } while (0) + +#define AES_ROUND_NOKEY_BE(X0, X1, X2, X3, Y0, Y1, Y2, Y3) \ + AES_ROUND_BE(X0, X1, X2, X3, 0, 0, 0, 0, Y0, Y1, Y2, Y3) + +#else + +#define AESx(x) SPH_C32(x) +#define AES0 AES0_LE +#define AES1 AES1_LE +#define AES2 AES2_LE +#define AES3 AES3_LE + +#define AES_ROUND_LE(X0, X1, X2, X3, K0, K1, K2, K3, Y0, Y1, Y2, Y3) do { \ + (Y0) = AES0[(X0) & 0xFF] \ + ^ AES1[((X1) >> 8) & 0xFF] \ + ^ AES2[((X2) >> 16) & 0xFF] \ + ^ AES3[((X3) >> 24) & 0xFF] ^ (K0); \ + (Y1) = AES0[(X1) & 0xFF] \ + ^ AES1[((X2) >> 8) & 0xFF] \ + ^ AES2[((X3) >> 16) & 0xFF] \ + ^ AES3[((X0) >> 24) & 0xFF] ^ (K1); \ + (Y2) = AES0[(X2) & 0xFF] \ + ^ AES1[((X3) >> 8) & 0xFF] \ + ^ AES2[((X0) >> 16) & 0xFF] \ + ^ AES3[((X1) >> 24) & 0xFF] ^ (K2); \ + (Y3) = AES0[(X3) & 0xFF] \ + ^ AES1[((X0) >> 8) & 0xFF] \ + ^ AES2[((X1) >> 16) & 0xFF] \ + ^ AES3[((X2) >> 24) & 0xFF] ^ (K3); \ + } while (0) + +#define AES_ROUND_NOKEY_LE(X0, X1, X2, X3, Y0, Y1, Y2, Y3) \ + AES_ROUND_LE(X0, X1, X2, X3, 0, 0, 0, 0, Y0, Y1, Y2, Y3) + +#endif + +/* + * The AES*[] tables allow us to perform a fast evaluation of an AES + * round; table AESi[] combines SubBytes for a byte at row i, and + * MixColumns for the column where that byte goes after ShiftRows. + */ + +static const sph_u32 AES0[256] = { + AESx(0xA56363C6), AESx(0x847C7CF8), AESx(0x997777EE), AESx(0x8D7B7BF6), + AESx(0x0DF2F2FF), AESx(0xBD6B6BD6), AESx(0xB16F6FDE), AESx(0x54C5C591), + AESx(0x50303060), AESx(0x03010102), AESx(0xA96767CE), AESx(0x7D2B2B56), + AESx(0x19FEFEE7), AESx(0x62D7D7B5), AESx(0xE6ABAB4D), AESx(0x9A7676EC), + AESx(0x45CACA8F), AESx(0x9D82821F), AESx(0x40C9C989), AESx(0x877D7DFA), + AESx(0x15FAFAEF), AESx(0xEB5959B2), AESx(0xC947478E), AESx(0x0BF0F0FB), + AESx(0xECADAD41), AESx(0x67D4D4B3), AESx(0xFDA2A25F), AESx(0xEAAFAF45), + AESx(0xBF9C9C23), AESx(0xF7A4A453), AESx(0x967272E4), AESx(0x5BC0C09B), + AESx(0xC2B7B775), AESx(0x1CFDFDE1), AESx(0xAE93933D), AESx(0x6A26264C), + AESx(0x5A36366C), AESx(0x413F3F7E), AESx(0x02F7F7F5), AESx(0x4FCCCC83), + AESx(0x5C343468), AESx(0xF4A5A551), AESx(0x34E5E5D1), AESx(0x08F1F1F9), + AESx(0x937171E2), AESx(0x73D8D8AB), AESx(0x53313162), AESx(0x3F15152A), + AESx(0x0C040408), AESx(0x52C7C795), AESx(0x65232346), AESx(0x5EC3C39D), + AESx(0x28181830), AESx(0xA1969637), AESx(0x0F05050A), AESx(0xB59A9A2F), + AESx(0x0907070E), AESx(0x36121224), AESx(0x9B80801B), AESx(0x3DE2E2DF), + AESx(0x26EBEBCD), AESx(0x6927274E), AESx(0xCDB2B27F), AESx(0x9F7575EA), + AESx(0x1B090912), AESx(0x9E83831D), AESx(0x742C2C58), AESx(0x2E1A1A34), + AESx(0x2D1B1B36), AESx(0xB26E6EDC), AESx(0xEE5A5AB4), AESx(0xFBA0A05B), + AESx(0xF65252A4), AESx(0x4D3B3B76), AESx(0x61D6D6B7), AESx(0xCEB3B37D), + AESx(0x7B292952), AESx(0x3EE3E3DD), AESx(0x712F2F5E), AESx(0x97848413), + AESx(0xF55353A6), AESx(0x68D1D1B9), AESx(0x00000000), AESx(0x2CEDEDC1), + AESx(0x60202040), AESx(0x1FFCFCE3), AESx(0xC8B1B179), AESx(0xED5B5BB6), + AESx(0xBE6A6AD4), AESx(0x46CBCB8D), AESx(0xD9BEBE67), AESx(0x4B393972), + AESx(0xDE4A4A94), AESx(0xD44C4C98), AESx(0xE85858B0), AESx(0x4ACFCF85), + AESx(0x6BD0D0BB), AESx(0x2AEFEFC5), AESx(0xE5AAAA4F), AESx(0x16FBFBED), + AESx(0xC5434386), AESx(0xD74D4D9A), AESx(0x55333366), AESx(0x94858511), + AESx(0xCF45458A), AESx(0x10F9F9E9), AESx(0x06020204), AESx(0x817F7FFE), + AESx(0xF05050A0), AESx(0x443C3C78), AESx(0xBA9F9F25), AESx(0xE3A8A84B), + AESx(0xF35151A2), AESx(0xFEA3A35D), AESx(0xC0404080), AESx(0x8A8F8F05), + AESx(0xAD92923F), AESx(0xBC9D9D21), AESx(0x48383870), AESx(0x04F5F5F1), + AESx(0xDFBCBC63), AESx(0xC1B6B677), AESx(0x75DADAAF), AESx(0x63212142), + AESx(0x30101020), AESx(0x1AFFFFE5), AESx(0x0EF3F3FD), AESx(0x6DD2D2BF), + AESx(0x4CCDCD81), AESx(0x140C0C18), AESx(0x35131326), AESx(0x2FECECC3), + AESx(0xE15F5FBE), AESx(0xA2979735), AESx(0xCC444488), AESx(0x3917172E), + AESx(0x57C4C493), AESx(0xF2A7A755), AESx(0x827E7EFC), AESx(0x473D3D7A), + AESx(0xAC6464C8), AESx(0xE75D5DBA), AESx(0x2B191932), AESx(0x957373E6), + AESx(0xA06060C0), AESx(0x98818119), AESx(0xD14F4F9E), AESx(0x7FDCDCA3), + AESx(0x66222244), AESx(0x7E2A2A54), AESx(0xAB90903B), AESx(0x8388880B), + AESx(0xCA46468C), AESx(0x29EEEEC7), AESx(0xD3B8B86B), AESx(0x3C141428), + AESx(0x79DEDEA7), AESx(0xE25E5EBC), AESx(0x1D0B0B16), AESx(0x76DBDBAD), + AESx(0x3BE0E0DB), AESx(0x56323264), AESx(0x4E3A3A74), AESx(0x1E0A0A14), + AESx(0xDB494992), AESx(0x0A06060C), AESx(0x6C242448), AESx(0xE45C5CB8), + AESx(0x5DC2C29F), AESx(0x6ED3D3BD), AESx(0xEFACAC43), AESx(0xA66262C4), + AESx(0xA8919139), AESx(0xA4959531), AESx(0x37E4E4D3), AESx(0x8B7979F2), + AESx(0x32E7E7D5), AESx(0x43C8C88B), AESx(0x5937376E), AESx(0xB76D6DDA), + AESx(0x8C8D8D01), AESx(0x64D5D5B1), AESx(0xD24E4E9C), AESx(0xE0A9A949), + AESx(0xB46C6CD8), AESx(0xFA5656AC), AESx(0x07F4F4F3), AESx(0x25EAEACF), + AESx(0xAF6565CA), AESx(0x8E7A7AF4), AESx(0xE9AEAE47), AESx(0x18080810), + AESx(0xD5BABA6F), AESx(0x887878F0), AESx(0x6F25254A), AESx(0x722E2E5C), + AESx(0x241C1C38), AESx(0xF1A6A657), AESx(0xC7B4B473), AESx(0x51C6C697), + AESx(0x23E8E8CB), AESx(0x7CDDDDA1), AESx(0x9C7474E8), AESx(0x211F1F3E), + AESx(0xDD4B4B96), AESx(0xDCBDBD61), AESx(0x868B8B0D), AESx(0x858A8A0F), + AESx(0x907070E0), AESx(0x423E3E7C), AESx(0xC4B5B571), AESx(0xAA6666CC), + AESx(0xD8484890), AESx(0x05030306), AESx(0x01F6F6F7), AESx(0x120E0E1C), + AESx(0xA36161C2), AESx(0x5F35356A), AESx(0xF95757AE), AESx(0xD0B9B969), + AESx(0x91868617), AESx(0x58C1C199), AESx(0x271D1D3A), AESx(0xB99E9E27), + AESx(0x38E1E1D9), AESx(0x13F8F8EB), AESx(0xB398982B), AESx(0x33111122), + AESx(0xBB6969D2), AESx(0x70D9D9A9), AESx(0x898E8E07), AESx(0xA7949433), + AESx(0xB69B9B2D), AESx(0x221E1E3C), AESx(0x92878715), AESx(0x20E9E9C9), + AESx(0x49CECE87), AESx(0xFF5555AA), AESx(0x78282850), AESx(0x7ADFDFA5), + AESx(0x8F8C8C03), AESx(0xF8A1A159), AESx(0x80898909), AESx(0x170D0D1A), + AESx(0xDABFBF65), AESx(0x31E6E6D7), AESx(0xC6424284), AESx(0xB86868D0), + AESx(0xC3414182), AESx(0xB0999929), AESx(0x772D2D5A), AESx(0x110F0F1E), + AESx(0xCBB0B07B), AESx(0xFC5454A8), AESx(0xD6BBBB6D), AESx(0x3A16162C) +}; + +static const sph_u32 AES1[256] = { + AESx(0x6363C6A5), AESx(0x7C7CF884), AESx(0x7777EE99), AESx(0x7B7BF68D), + AESx(0xF2F2FF0D), AESx(0x6B6BD6BD), AESx(0x6F6FDEB1), AESx(0xC5C59154), + AESx(0x30306050), AESx(0x01010203), AESx(0x6767CEA9), AESx(0x2B2B567D), + AESx(0xFEFEE719), AESx(0xD7D7B562), AESx(0xABAB4DE6), AESx(0x7676EC9A), + AESx(0xCACA8F45), AESx(0x82821F9D), AESx(0xC9C98940), AESx(0x7D7DFA87), + AESx(0xFAFAEF15), AESx(0x5959B2EB), AESx(0x47478EC9), AESx(0xF0F0FB0B), + AESx(0xADAD41EC), AESx(0xD4D4B367), AESx(0xA2A25FFD), AESx(0xAFAF45EA), + AESx(0x9C9C23BF), AESx(0xA4A453F7), AESx(0x7272E496), AESx(0xC0C09B5B), + AESx(0xB7B775C2), AESx(0xFDFDE11C), AESx(0x93933DAE), AESx(0x26264C6A), + AESx(0x36366C5A), AESx(0x3F3F7E41), AESx(0xF7F7F502), AESx(0xCCCC834F), + AESx(0x3434685C), AESx(0xA5A551F4), AESx(0xE5E5D134), AESx(0xF1F1F908), + AESx(0x7171E293), AESx(0xD8D8AB73), AESx(0x31316253), AESx(0x15152A3F), + AESx(0x0404080C), AESx(0xC7C79552), AESx(0x23234665), AESx(0xC3C39D5E), + AESx(0x18183028), AESx(0x969637A1), AESx(0x05050A0F), AESx(0x9A9A2FB5), + AESx(0x07070E09), AESx(0x12122436), AESx(0x80801B9B), AESx(0xE2E2DF3D), + AESx(0xEBEBCD26), AESx(0x27274E69), AESx(0xB2B27FCD), AESx(0x7575EA9F), + AESx(0x0909121B), AESx(0x83831D9E), AESx(0x2C2C5874), AESx(0x1A1A342E), + AESx(0x1B1B362D), AESx(0x6E6EDCB2), AESx(0x5A5AB4EE), AESx(0xA0A05BFB), + AESx(0x5252A4F6), AESx(0x3B3B764D), AESx(0xD6D6B761), AESx(0xB3B37DCE), + AESx(0x2929527B), AESx(0xE3E3DD3E), AESx(0x2F2F5E71), AESx(0x84841397), + AESx(0x5353A6F5), AESx(0xD1D1B968), AESx(0x00000000), AESx(0xEDEDC12C), + AESx(0x20204060), AESx(0xFCFCE31F), AESx(0xB1B179C8), AESx(0x5B5BB6ED), + AESx(0x6A6AD4BE), AESx(0xCBCB8D46), AESx(0xBEBE67D9), AESx(0x3939724B), + AESx(0x4A4A94DE), AESx(0x4C4C98D4), AESx(0x5858B0E8), AESx(0xCFCF854A), + AESx(0xD0D0BB6B), AESx(0xEFEFC52A), AESx(0xAAAA4FE5), AESx(0xFBFBED16), + AESx(0x434386C5), AESx(0x4D4D9AD7), AESx(0x33336655), AESx(0x85851194), + AESx(0x45458ACF), AESx(0xF9F9E910), AESx(0x02020406), AESx(0x7F7FFE81), + AESx(0x5050A0F0), AESx(0x3C3C7844), AESx(0x9F9F25BA), AESx(0xA8A84BE3), + AESx(0x5151A2F3), AESx(0xA3A35DFE), AESx(0x404080C0), AESx(0x8F8F058A), + AESx(0x92923FAD), AESx(0x9D9D21BC), AESx(0x38387048), AESx(0xF5F5F104), + AESx(0xBCBC63DF), AESx(0xB6B677C1), AESx(0xDADAAF75), AESx(0x21214263), + AESx(0x10102030), AESx(0xFFFFE51A), AESx(0xF3F3FD0E), AESx(0xD2D2BF6D), + AESx(0xCDCD814C), AESx(0x0C0C1814), AESx(0x13132635), AESx(0xECECC32F), + AESx(0x5F5FBEE1), AESx(0x979735A2), AESx(0x444488CC), AESx(0x17172E39), + AESx(0xC4C49357), AESx(0xA7A755F2), AESx(0x7E7EFC82), AESx(0x3D3D7A47), + AESx(0x6464C8AC), AESx(0x5D5DBAE7), AESx(0x1919322B), AESx(0x7373E695), + AESx(0x6060C0A0), AESx(0x81811998), AESx(0x4F4F9ED1), AESx(0xDCDCA37F), + AESx(0x22224466), AESx(0x2A2A547E), AESx(0x90903BAB), AESx(0x88880B83), + AESx(0x46468CCA), AESx(0xEEEEC729), AESx(0xB8B86BD3), AESx(0x1414283C), + AESx(0xDEDEA779), AESx(0x5E5EBCE2), AESx(0x0B0B161D), AESx(0xDBDBAD76), + AESx(0xE0E0DB3B), AESx(0x32326456), AESx(0x3A3A744E), AESx(0x0A0A141E), + AESx(0x494992DB), AESx(0x06060C0A), AESx(0x2424486C), AESx(0x5C5CB8E4), + AESx(0xC2C29F5D), AESx(0xD3D3BD6E), AESx(0xACAC43EF), AESx(0x6262C4A6), + AESx(0x919139A8), AESx(0x959531A4), AESx(0xE4E4D337), AESx(0x7979F28B), + AESx(0xE7E7D532), AESx(0xC8C88B43), AESx(0x37376E59), AESx(0x6D6DDAB7), + AESx(0x8D8D018C), AESx(0xD5D5B164), AESx(0x4E4E9CD2), AESx(0xA9A949E0), + AESx(0x6C6CD8B4), AESx(0x5656ACFA), AESx(0xF4F4F307), AESx(0xEAEACF25), + AESx(0x6565CAAF), AESx(0x7A7AF48E), AESx(0xAEAE47E9), AESx(0x08081018), + AESx(0xBABA6FD5), AESx(0x7878F088), AESx(0x25254A6F), AESx(0x2E2E5C72), + AESx(0x1C1C3824), AESx(0xA6A657F1), AESx(0xB4B473C7), AESx(0xC6C69751), + AESx(0xE8E8CB23), AESx(0xDDDDA17C), AESx(0x7474E89C), AESx(0x1F1F3E21), + AESx(0x4B4B96DD), AESx(0xBDBD61DC), AESx(0x8B8B0D86), AESx(0x8A8A0F85), + AESx(0x7070E090), AESx(0x3E3E7C42), AESx(0xB5B571C4), AESx(0x6666CCAA), + AESx(0x484890D8), AESx(0x03030605), AESx(0xF6F6F701), AESx(0x0E0E1C12), + AESx(0x6161C2A3), AESx(0x35356A5F), AESx(0x5757AEF9), AESx(0xB9B969D0), + AESx(0x86861791), AESx(0xC1C19958), AESx(0x1D1D3A27), AESx(0x9E9E27B9), + AESx(0xE1E1D938), AESx(0xF8F8EB13), AESx(0x98982BB3), AESx(0x11112233), + AESx(0x6969D2BB), AESx(0xD9D9A970), AESx(0x8E8E0789), AESx(0x949433A7), + AESx(0x9B9B2DB6), AESx(0x1E1E3C22), AESx(0x87871592), AESx(0xE9E9C920), + AESx(0xCECE8749), AESx(0x5555AAFF), AESx(0x28285078), AESx(0xDFDFA57A), + AESx(0x8C8C038F), AESx(0xA1A159F8), AESx(0x89890980), AESx(0x0D0D1A17), + AESx(0xBFBF65DA), AESx(0xE6E6D731), AESx(0x424284C6), AESx(0x6868D0B8), + AESx(0x414182C3), AESx(0x999929B0), AESx(0x2D2D5A77), AESx(0x0F0F1E11), + AESx(0xB0B07BCB), AESx(0x5454A8FC), AESx(0xBBBB6DD6), AESx(0x16162C3A) +}; + +static const sph_u32 AES2[256] = { + AESx(0x63C6A563), AESx(0x7CF8847C), AESx(0x77EE9977), AESx(0x7BF68D7B), + AESx(0xF2FF0DF2), AESx(0x6BD6BD6B), AESx(0x6FDEB16F), AESx(0xC59154C5), + AESx(0x30605030), AESx(0x01020301), AESx(0x67CEA967), AESx(0x2B567D2B), + AESx(0xFEE719FE), AESx(0xD7B562D7), AESx(0xAB4DE6AB), AESx(0x76EC9A76), + AESx(0xCA8F45CA), AESx(0x821F9D82), AESx(0xC98940C9), AESx(0x7DFA877D), + AESx(0xFAEF15FA), AESx(0x59B2EB59), AESx(0x478EC947), AESx(0xF0FB0BF0), + AESx(0xAD41ECAD), AESx(0xD4B367D4), AESx(0xA25FFDA2), AESx(0xAF45EAAF), + AESx(0x9C23BF9C), AESx(0xA453F7A4), AESx(0x72E49672), AESx(0xC09B5BC0), + AESx(0xB775C2B7), AESx(0xFDE11CFD), AESx(0x933DAE93), AESx(0x264C6A26), + AESx(0x366C5A36), AESx(0x3F7E413F), AESx(0xF7F502F7), AESx(0xCC834FCC), + AESx(0x34685C34), AESx(0xA551F4A5), AESx(0xE5D134E5), AESx(0xF1F908F1), + AESx(0x71E29371), AESx(0xD8AB73D8), AESx(0x31625331), AESx(0x152A3F15), + AESx(0x04080C04), AESx(0xC79552C7), AESx(0x23466523), AESx(0xC39D5EC3), + AESx(0x18302818), AESx(0x9637A196), AESx(0x050A0F05), AESx(0x9A2FB59A), + AESx(0x070E0907), AESx(0x12243612), AESx(0x801B9B80), AESx(0xE2DF3DE2), + AESx(0xEBCD26EB), AESx(0x274E6927), AESx(0xB27FCDB2), AESx(0x75EA9F75), + AESx(0x09121B09), AESx(0x831D9E83), AESx(0x2C58742C), AESx(0x1A342E1A), + AESx(0x1B362D1B), AESx(0x6EDCB26E), AESx(0x5AB4EE5A), AESx(0xA05BFBA0), + AESx(0x52A4F652), AESx(0x3B764D3B), AESx(0xD6B761D6), AESx(0xB37DCEB3), + AESx(0x29527B29), AESx(0xE3DD3EE3), AESx(0x2F5E712F), AESx(0x84139784), + AESx(0x53A6F553), AESx(0xD1B968D1), AESx(0x00000000), AESx(0xEDC12CED), + AESx(0x20406020), AESx(0xFCE31FFC), AESx(0xB179C8B1), AESx(0x5BB6ED5B), + AESx(0x6AD4BE6A), AESx(0xCB8D46CB), AESx(0xBE67D9BE), AESx(0x39724B39), + AESx(0x4A94DE4A), AESx(0x4C98D44C), AESx(0x58B0E858), AESx(0xCF854ACF), + AESx(0xD0BB6BD0), AESx(0xEFC52AEF), AESx(0xAA4FE5AA), AESx(0xFBED16FB), + AESx(0x4386C543), AESx(0x4D9AD74D), AESx(0x33665533), AESx(0x85119485), + AESx(0x458ACF45), AESx(0xF9E910F9), AESx(0x02040602), AESx(0x7FFE817F), + AESx(0x50A0F050), AESx(0x3C78443C), AESx(0x9F25BA9F), AESx(0xA84BE3A8), + AESx(0x51A2F351), AESx(0xA35DFEA3), AESx(0x4080C040), AESx(0x8F058A8F), + AESx(0x923FAD92), AESx(0x9D21BC9D), AESx(0x38704838), AESx(0xF5F104F5), + AESx(0xBC63DFBC), AESx(0xB677C1B6), AESx(0xDAAF75DA), AESx(0x21426321), + AESx(0x10203010), AESx(0xFFE51AFF), AESx(0xF3FD0EF3), AESx(0xD2BF6DD2), + AESx(0xCD814CCD), AESx(0x0C18140C), AESx(0x13263513), AESx(0xECC32FEC), + AESx(0x5FBEE15F), AESx(0x9735A297), AESx(0x4488CC44), AESx(0x172E3917), + AESx(0xC49357C4), AESx(0xA755F2A7), AESx(0x7EFC827E), AESx(0x3D7A473D), + AESx(0x64C8AC64), AESx(0x5DBAE75D), AESx(0x19322B19), AESx(0x73E69573), + AESx(0x60C0A060), AESx(0x81199881), AESx(0x4F9ED14F), AESx(0xDCA37FDC), + AESx(0x22446622), AESx(0x2A547E2A), AESx(0x903BAB90), AESx(0x880B8388), + AESx(0x468CCA46), AESx(0xEEC729EE), AESx(0xB86BD3B8), AESx(0x14283C14), + AESx(0xDEA779DE), AESx(0x5EBCE25E), AESx(0x0B161D0B), AESx(0xDBAD76DB), + AESx(0xE0DB3BE0), AESx(0x32645632), AESx(0x3A744E3A), AESx(0x0A141E0A), + AESx(0x4992DB49), AESx(0x060C0A06), AESx(0x24486C24), AESx(0x5CB8E45C), + AESx(0xC29F5DC2), AESx(0xD3BD6ED3), AESx(0xAC43EFAC), AESx(0x62C4A662), + AESx(0x9139A891), AESx(0x9531A495), AESx(0xE4D337E4), AESx(0x79F28B79), + AESx(0xE7D532E7), AESx(0xC88B43C8), AESx(0x376E5937), AESx(0x6DDAB76D), + AESx(0x8D018C8D), AESx(0xD5B164D5), AESx(0x4E9CD24E), AESx(0xA949E0A9), + AESx(0x6CD8B46C), AESx(0x56ACFA56), AESx(0xF4F307F4), AESx(0xEACF25EA), + AESx(0x65CAAF65), AESx(0x7AF48E7A), AESx(0xAE47E9AE), AESx(0x08101808), + AESx(0xBA6FD5BA), AESx(0x78F08878), AESx(0x254A6F25), AESx(0x2E5C722E), + AESx(0x1C38241C), AESx(0xA657F1A6), AESx(0xB473C7B4), AESx(0xC69751C6), + AESx(0xE8CB23E8), AESx(0xDDA17CDD), AESx(0x74E89C74), AESx(0x1F3E211F), + AESx(0x4B96DD4B), AESx(0xBD61DCBD), AESx(0x8B0D868B), AESx(0x8A0F858A), + AESx(0x70E09070), AESx(0x3E7C423E), AESx(0xB571C4B5), AESx(0x66CCAA66), + AESx(0x4890D848), AESx(0x03060503), AESx(0xF6F701F6), AESx(0x0E1C120E), + AESx(0x61C2A361), AESx(0x356A5F35), AESx(0x57AEF957), AESx(0xB969D0B9), + AESx(0x86179186), AESx(0xC19958C1), AESx(0x1D3A271D), AESx(0x9E27B99E), + AESx(0xE1D938E1), AESx(0xF8EB13F8), AESx(0x982BB398), AESx(0x11223311), + AESx(0x69D2BB69), AESx(0xD9A970D9), AESx(0x8E07898E), AESx(0x9433A794), + AESx(0x9B2DB69B), AESx(0x1E3C221E), AESx(0x87159287), AESx(0xE9C920E9), + AESx(0xCE8749CE), AESx(0x55AAFF55), AESx(0x28507828), AESx(0xDFA57ADF), + AESx(0x8C038F8C), AESx(0xA159F8A1), AESx(0x89098089), AESx(0x0D1A170D), + AESx(0xBF65DABF), AESx(0xE6D731E6), AESx(0x4284C642), AESx(0x68D0B868), + AESx(0x4182C341), AESx(0x9929B099), AESx(0x2D5A772D), AESx(0x0F1E110F), + AESx(0xB07BCBB0), AESx(0x54A8FC54), AESx(0xBB6DD6BB), AESx(0x162C3A16) +}; + +static const sph_u32 AES3[256] = { + AESx(0xC6A56363), AESx(0xF8847C7C), AESx(0xEE997777), AESx(0xF68D7B7B), + AESx(0xFF0DF2F2), AESx(0xD6BD6B6B), AESx(0xDEB16F6F), AESx(0x9154C5C5), + AESx(0x60503030), AESx(0x02030101), AESx(0xCEA96767), AESx(0x567D2B2B), + AESx(0xE719FEFE), AESx(0xB562D7D7), AESx(0x4DE6ABAB), AESx(0xEC9A7676), + AESx(0x8F45CACA), AESx(0x1F9D8282), AESx(0x8940C9C9), AESx(0xFA877D7D), + AESx(0xEF15FAFA), AESx(0xB2EB5959), AESx(0x8EC94747), AESx(0xFB0BF0F0), + AESx(0x41ECADAD), AESx(0xB367D4D4), AESx(0x5FFDA2A2), AESx(0x45EAAFAF), + AESx(0x23BF9C9C), AESx(0x53F7A4A4), AESx(0xE4967272), AESx(0x9B5BC0C0), + AESx(0x75C2B7B7), AESx(0xE11CFDFD), AESx(0x3DAE9393), AESx(0x4C6A2626), + AESx(0x6C5A3636), AESx(0x7E413F3F), AESx(0xF502F7F7), AESx(0x834FCCCC), + AESx(0x685C3434), AESx(0x51F4A5A5), AESx(0xD134E5E5), AESx(0xF908F1F1), + AESx(0xE2937171), AESx(0xAB73D8D8), AESx(0x62533131), AESx(0x2A3F1515), + AESx(0x080C0404), AESx(0x9552C7C7), AESx(0x46652323), AESx(0x9D5EC3C3), + AESx(0x30281818), AESx(0x37A19696), AESx(0x0A0F0505), AESx(0x2FB59A9A), + AESx(0x0E090707), AESx(0x24361212), AESx(0x1B9B8080), AESx(0xDF3DE2E2), + AESx(0xCD26EBEB), AESx(0x4E692727), AESx(0x7FCDB2B2), AESx(0xEA9F7575), + AESx(0x121B0909), AESx(0x1D9E8383), AESx(0x58742C2C), AESx(0x342E1A1A), + AESx(0x362D1B1B), AESx(0xDCB26E6E), AESx(0xB4EE5A5A), AESx(0x5BFBA0A0), + AESx(0xA4F65252), AESx(0x764D3B3B), AESx(0xB761D6D6), AESx(0x7DCEB3B3), + AESx(0x527B2929), AESx(0xDD3EE3E3), AESx(0x5E712F2F), AESx(0x13978484), + AESx(0xA6F55353), AESx(0xB968D1D1), AESx(0x00000000), AESx(0xC12CEDED), + AESx(0x40602020), AESx(0xE31FFCFC), AESx(0x79C8B1B1), AESx(0xB6ED5B5B), + AESx(0xD4BE6A6A), AESx(0x8D46CBCB), AESx(0x67D9BEBE), AESx(0x724B3939), + AESx(0x94DE4A4A), AESx(0x98D44C4C), AESx(0xB0E85858), AESx(0x854ACFCF), + AESx(0xBB6BD0D0), AESx(0xC52AEFEF), AESx(0x4FE5AAAA), AESx(0xED16FBFB), + AESx(0x86C54343), AESx(0x9AD74D4D), AESx(0x66553333), AESx(0x11948585), + AESx(0x8ACF4545), AESx(0xE910F9F9), AESx(0x04060202), AESx(0xFE817F7F), + AESx(0xA0F05050), AESx(0x78443C3C), AESx(0x25BA9F9F), AESx(0x4BE3A8A8), + AESx(0xA2F35151), AESx(0x5DFEA3A3), AESx(0x80C04040), AESx(0x058A8F8F), + AESx(0x3FAD9292), AESx(0x21BC9D9D), AESx(0x70483838), AESx(0xF104F5F5), + AESx(0x63DFBCBC), AESx(0x77C1B6B6), AESx(0xAF75DADA), AESx(0x42632121), + AESx(0x20301010), AESx(0xE51AFFFF), AESx(0xFD0EF3F3), AESx(0xBF6DD2D2), + AESx(0x814CCDCD), AESx(0x18140C0C), AESx(0x26351313), AESx(0xC32FECEC), + AESx(0xBEE15F5F), AESx(0x35A29797), AESx(0x88CC4444), AESx(0x2E391717), + AESx(0x9357C4C4), AESx(0x55F2A7A7), AESx(0xFC827E7E), AESx(0x7A473D3D), + AESx(0xC8AC6464), AESx(0xBAE75D5D), AESx(0x322B1919), AESx(0xE6957373), + AESx(0xC0A06060), AESx(0x19988181), AESx(0x9ED14F4F), AESx(0xA37FDCDC), + AESx(0x44662222), AESx(0x547E2A2A), AESx(0x3BAB9090), AESx(0x0B838888), + AESx(0x8CCA4646), AESx(0xC729EEEE), AESx(0x6BD3B8B8), AESx(0x283C1414), + AESx(0xA779DEDE), AESx(0xBCE25E5E), AESx(0x161D0B0B), AESx(0xAD76DBDB), + AESx(0xDB3BE0E0), AESx(0x64563232), AESx(0x744E3A3A), AESx(0x141E0A0A), + AESx(0x92DB4949), AESx(0x0C0A0606), AESx(0x486C2424), AESx(0xB8E45C5C), + AESx(0x9F5DC2C2), AESx(0xBD6ED3D3), AESx(0x43EFACAC), AESx(0xC4A66262), + AESx(0x39A89191), AESx(0x31A49595), AESx(0xD337E4E4), AESx(0xF28B7979), + AESx(0xD532E7E7), AESx(0x8B43C8C8), AESx(0x6E593737), AESx(0xDAB76D6D), + AESx(0x018C8D8D), AESx(0xB164D5D5), AESx(0x9CD24E4E), AESx(0x49E0A9A9), + AESx(0xD8B46C6C), AESx(0xACFA5656), AESx(0xF307F4F4), AESx(0xCF25EAEA), + AESx(0xCAAF6565), AESx(0xF48E7A7A), AESx(0x47E9AEAE), AESx(0x10180808), + AESx(0x6FD5BABA), AESx(0xF0887878), AESx(0x4A6F2525), AESx(0x5C722E2E), + AESx(0x38241C1C), AESx(0x57F1A6A6), AESx(0x73C7B4B4), AESx(0x9751C6C6), + AESx(0xCB23E8E8), AESx(0xA17CDDDD), AESx(0xE89C7474), AESx(0x3E211F1F), + AESx(0x96DD4B4B), AESx(0x61DCBDBD), AESx(0x0D868B8B), AESx(0x0F858A8A), + AESx(0xE0907070), AESx(0x7C423E3E), AESx(0x71C4B5B5), AESx(0xCCAA6666), + AESx(0x90D84848), AESx(0x06050303), AESx(0xF701F6F6), AESx(0x1C120E0E), + AESx(0xC2A36161), AESx(0x6A5F3535), AESx(0xAEF95757), AESx(0x69D0B9B9), + AESx(0x17918686), AESx(0x9958C1C1), AESx(0x3A271D1D), AESx(0x27B99E9E), + AESx(0xD938E1E1), AESx(0xEB13F8F8), AESx(0x2BB39898), AESx(0x22331111), + AESx(0xD2BB6969), AESx(0xA970D9D9), AESx(0x07898E8E), AESx(0x33A79494), + AESx(0x2DB69B9B), AESx(0x3C221E1E), AESx(0x15928787), AESx(0xC920E9E9), + AESx(0x8749CECE), AESx(0xAAFF5555), AESx(0x50782828), AESx(0xA57ADFDF), + AESx(0x038F8C8C), AESx(0x59F8A1A1), AESx(0x09808989), AESx(0x1A170D0D), + AESx(0x65DABFBF), AESx(0xD731E6E6), AESx(0x84C64242), AESx(0xD0B86868), + AESx(0x82C34141), AESx(0x29B09999), AESx(0x5A772D2D), AESx(0x1E110F0F), + AESx(0x7BCBB0B0), AESx(0xA8FC5454), AESx(0x6DD6BBBB), AESx(0x2C3A1616) +}; + +#ifdef __cplusplus +} +#endif diff --git a/src/obj/skunkhash/aes_helper.o b/src/obj/skunkhash/aes_helper.o new file mode 100644 index 0000000..78f2a8d Binary files /dev/null and b/src/obj/skunkhash/aes_helper.o differ diff --git a/src/obj/skunkhash/cubehash.c b/src/obj/skunkhash/cubehash.c new file mode 100644 index 0000000..9322fe1 --- /dev/null +++ b/src/obj/skunkhash/cubehash.c @@ -0,0 +1,723 @@ +/* $Id: cubehash.c 227 2010-06-16 17:28:38Z tp $ */ +/* + * CubeHash implementation. + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @author Thomas Pornin + */ + +#include +#include +#include + +#include "sph_cubehash.h" +#ifdef __cplusplus +extern "C"{ +#endif + +#if SPH_SMALL_FOOTPRINT && !defined SPH_SMALL_FOOTPRINT_CUBEHASH +#define SPH_SMALL_FOOTPRINT_CUBEHASH 1 +#endif + +/* + * Some tests were conducted on an Intel Core2 Q6600 (32-bit and 64-bit + * mode), a PowerPC G3, and a MIPS-compatible CPU (Broadcom BCM3302). + * It appears that the optimal settings are: + * -- full unroll, no state copy on the "big" systems (x86, PowerPC) + * -- unroll to 4 or 8, state copy on the "small" system (MIPS) + */ + +#if SPH_SMALL_FOOTPRINT_CUBEHASH + +#if !defined SPH_CUBEHASH_UNROLL +#define SPH_CUBEHASH_UNROLL 4 +#endif +#if !defined SPH_CUBEHASH_NOCOPY +#define SPH_CUBEHASH_NOCOPY 1 +#endif + +#else + +#if !defined SPH_CUBEHASH_UNROLL +#define SPH_CUBEHASH_UNROLL 0 +#endif +#if !defined SPH_CUBEHASH_NOCOPY +#define SPH_CUBEHASH_NOCOPY 0 +#endif + +#endif + +#ifdef _MSC_VER +#pragma warning (disable: 4146) +#endif + +static const sph_u32 IV224[] = { + SPH_C32(0xB0FC8217), SPH_C32(0x1BEE1A90), SPH_C32(0x829E1A22), + SPH_C32(0x6362C342), SPH_C32(0x24D91C30), SPH_C32(0x03A7AA24), + SPH_C32(0xA63721C8), SPH_C32(0x85B0E2EF), SPH_C32(0xF35D13F3), + SPH_C32(0x41DA807D), SPH_C32(0x21A70CA6), SPH_C32(0x1F4E9774), + SPH_C32(0xB3E1C932), SPH_C32(0xEB0A79A8), SPH_C32(0xCDDAAA66), + SPH_C32(0xE2F6ECAA), SPH_C32(0x0A713362), SPH_C32(0xAA3080E0), + SPH_C32(0xD8F23A32), SPH_C32(0xCEF15E28), SPH_C32(0xDB086314), + SPH_C32(0x7F709DF7), SPH_C32(0xACD228A4), SPH_C32(0x704D6ECE), + SPH_C32(0xAA3EC95F), SPH_C32(0xE387C214), SPH_C32(0x3A6445FF), + SPH_C32(0x9CAB81C3), SPH_C32(0xC73D4B98), SPH_C32(0xD277AEBE), + SPH_C32(0xFD20151C), SPH_C32(0x00CB573E) +}; + +static const sph_u32 IV256[] = { + SPH_C32(0xEA2BD4B4), SPH_C32(0xCCD6F29F), SPH_C32(0x63117E71), + SPH_C32(0x35481EAE), SPH_C32(0x22512D5B), SPH_C32(0xE5D94E63), + SPH_C32(0x7E624131), SPH_C32(0xF4CC12BE), SPH_C32(0xC2D0B696), + SPH_C32(0x42AF2070), SPH_C32(0xD0720C35), SPH_C32(0x3361DA8C), + SPH_C32(0x28CCECA4), SPH_C32(0x8EF8AD83), SPH_C32(0x4680AC00), + SPH_C32(0x40E5FBAB), SPH_C32(0xD89041C3), SPH_C32(0x6107FBD5), + SPH_C32(0x6C859D41), SPH_C32(0xF0B26679), SPH_C32(0x09392549), + SPH_C32(0x5FA25603), SPH_C32(0x65C892FD), SPH_C32(0x93CB6285), + SPH_C32(0x2AF2B5AE), SPH_C32(0x9E4B4E60), SPH_C32(0x774ABFDD), + SPH_C32(0x85254725), SPH_C32(0x15815AEB), SPH_C32(0x4AB6AAD6), + SPH_C32(0x9CDAF8AF), SPH_C32(0xD6032C0A) +}; + +static const sph_u32 IV384[] = { + SPH_C32(0xE623087E), SPH_C32(0x04C00C87), SPH_C32(0x5EF46453), + SPH_C32(0x69524B13), SPH_C32(0x1A05C7A9), SPH_C32(0x3528DF88), + SPH_C32(0x6BDD01B5), SPH_C32(0x5057B792), SPH_C32(0x6AA7A922), + SPH_C32(0x649C7EEE), SPH_C32(0xF426309F), SPH_C32(0xCB629052), + SPH_C32(0xFC8E20ED), SPH_C32(0xB3482BAB), SPH_C32(0xF89E5E7E), + SPH_C32(0xD83D4DE4), SPH_C32(0x44BFC10D), SPH_C32(0x5FC1E63D), + SPH_C32(0x2104E6CB), SPH_C32(0x17958F7F), SPH_C32(0xDBEAEF70), + SPH_C32(0xB4B97E1E), SPH_C32(0x32C195F6), SPH_C32(0x6184A8E4), + SPH_C32(0x796C2543), SPH_C32(0x23DE176D), SPH_C32(0xD33BBAEC), + SPH_C32(0x0C12E5D2), SPH_C32(0x4EB95A7B), SPH_C32(0x2D18BA01), + SPH_C32(0x04EE475F), SPH_C32(0x1FC5F22E) +}; + +static const sph_u32 IV512[] = { + SPH_C32(0x2AEA2A61), SPH_C32(0x50F494D4), SPH_C32(0x2D538B8B), + SPH_C32(0x4167D83E), SPH_C32(0x3FEE2313), SPH_C32(0xC701CF8C), + SPH_C32(0xCC39968E), SPH_C32(0x50AC5695), SPH_C32(0x4D42C787), + SPH_C32(0xA647A8B3), SPH_C32(0x97CF0BEF), SPH_C32(0x825B4537), + SPH_C32(0xEEF864D2), SPH_C32(0xF22090C4), SPH_C32(0xD0E5CD33), + SPH_C32(0xA23911AE), SPH_C32(0xFCD398D9), SPH_C32(0x148FE485), + SPH_C32(0x1B017BEF), SPH_C32(0xB6444532), SPH_C32(0x6A536159), + SPH_C32(0x2FF5781C), SPH_C32(0x91FA7934), SPH_C32(0x0DBADEA9), + SPH_C32(0xD65C8A2B), SPH_C32(0xA5A70E75), SPH_C32(0xB1C62456), + SPH_C32(0xBC796576), SPH_C32(0x1921C8F7), SPH_C32(0xE7989AF1), + SPH_C32(0x7795D246), SPH_C32(0xD43E3B44) +}; + +#define T32 SPH_T32 +#define ROTL32 SPH_ROTL32 + +#if SPH_CUBEHASH_NOCOPY + +#define DECL_STATE +#define READ_STATE(cc) +#define WRITE_STATE(cc) + +#define x0 ((sc)->state[ 0]) +#define x1 ((sc)->state[ 1]) +#define x2 ((sc)->state[ 2]) +#define x3 ((sc)->state[ 3]) +#define x4 ((sc)->state[ 4]) +#define x5 ((sc)->state[ 5]) +#define x6 ((sc)->state[ 6]) +#define x7 ((sc)->state[ 7]) +#define x8 ((sc)->state[ 8]) +#define x9 ((sc)->state[ 9]) +#define xa ((sc)->state[10]) +#define xb ((sc)->state[11]) +#define xc ((sc)->state[12]) +#define xd ((sc)->state[13]) +#define xe ((sc)->state[14]) +#define xf ((sc)->state[15]) +#define xg ((sc)->state[16]) +#define xh ((sc)->state[17]) +#define xi ((sc)->state[18]) +#define xj ((sc)->state[19]) +#define xk ((sc)->state[20]) +#define xl ((sc)->state[21]) +#define xm ((sc)->state[22]) +#define xn ((sc)->state[23]) +#define xo ((sc)->state[24]) +#define xp ((sc)->state[25]) +#define xq ((sc)->state[26]) +#define xr ((sc)->state[27]) +#define xs ((sc)->state[28]) +#define xt ((sc)->state[29]) +#define xu ((sc)->state[30]) +#define xv ((sc)->state[31]) + +#else + +#define DECL_STATE \ + sph_u32 x0, x1, x2, x3, x4, x5, x6, x7; \ + sph_u32 x8, x9, xa, xb, xc, xd, xe, xf; \ + sph_u32 xg, xh, xi, xj, xk, xl, xm, xn; \ + sph_u32 xo, xp, xq, xr, xs, xt, xu, xv; + +#define READ_STATE(cc) do { \ + x0 = (cc)->state[ 0]; \ + x1 = (cc)->state[ 1]; \ + x2 = (cc)->state[ 2]; \ + x3 = (cc)->state[ 3]; \ + x4 = (cc)->state[ 4]; \ + x5 = (cc)->state[ 5]; \ + x6 = (cc)->state[ 6]; \ + x7 = (cc)->state[ 7]; \ + x8 = (cc)->state[ 8]; \ + x9 = (cc)->state[ 9]; \ + xa = (cc)->state[10]; \ + xb = (cc)->state[11]; \ + xc = (cc)->state[12]; \ + xd = (cc)->state[13]; \ + xe = (cc)->state[14]; \ + xf = (cc)->state[15]; \ + xg = (cc)->state[16]; \ + xh = (cc)->state[17]; \ + xi = (cc)->state[18]; \ + xj = (cc)->state[19]; \ + xk = (cc)->state[20]; \ + xl = (cc)->state[21]; \ + xm = (cc)->state[22]; \ + xn = (cc)->state[23]; \ + xo = (cc)->state[24]; \ + xp = (cc)->state[25]; \ + xq = (cc)->state[26]; \ + xr = (cc)->state[27]; \ + xs = (cc)->state[28]; \ + xt = (cc)->state[29]; \ + xu = (cc)->state[30]; \ + xv = (cc)->state[31]; \ + } while (0) + +#define WRITE_STATE(cc) do { \ + (cc)->state[ 0] = x0; \ + (cc)->state[ 1] = x1; \ + (cc)->state[ 2] = x2; \ + (cc)->state[ 3] = x3; \ + (cc)->state[ 4] = x4; \ + (cc)->state[ 5] = x5; \ + (cc)->state[ 6] = x6; \ + (cc)->state[ 7] = x7; \ + (cc)->state[ 8] = x8; \ + (cc)->state[ 9] = x9; \ + (cc)->state[10] = xa; \ + (cc)->state[11] = xb; \ + (cc)->state[12] = xc; \ + (cc)->state[13] = xd; \ + (cc)->state[14] = xe; \ + (cc)->state[15] = xf; \ + (cc)->state[16] = xg; \ + (cc)->state[17] = xh; \ + (cc)->state[18] = xi; \ + (cc)->state[19] = xj; \ + (cc)->state[20] = xk; \ + (cc)->state[21] = xl; \ + (cc)->state[22] = xm; \ + (cc)->state[23] = xn; \ + (cc)->state[24] = xo; \ + (cc)->state[25] = xp; \ + (cc)->state[26] = xq; \ + (cc)->state[27] = xr; \ + (cc)->state[28] = xs; \ + (cc)->state[29] = xt; \ + (cc)->state[30] = xu; \ + (cc)->state[31] = xv; \ + } while (0) + +#endif + +#define INPUT_BLOCK do { \ + x0 ^= sph_dec32le_aligned(buf + 0); \ + x1 ^= sph_dec32le_aligned(buf + 4); \ + x2 ^= sph_dec32le_aligned(buf + 8); \ + x3 ^= sph_dec32le_aligned(buf + 12); \ + x4 ^= sph_dec32le_aligned(buf + 16); \ + x5 ^= sph_dec32le_aligned(buf + 20); \ + x6 ^= sph_dec32le_aligned(buf + 24); \ + x7 ^= sph_dec32le_aligned(buf + 28); \ + } while (0) + +#define ROUND_EVEN do { \ + xg = T32(x0 + xg); \ + x0 = ROTL32(x0, 7); \ + xh = T32(x1 + xh); \ + x1 = ROTL32(x1, 7); \ + xi = T32(x2 + xi); \ + x2 = ROTL32(x2, 7); \ + xj = T32(x3 + xj); \ + x3 = ROTL32(x3, 7); \ + xk = T32(x4 + xk); \ + x4 = ROTL32(x4, 7); \ + xl = T32(x5 + xl); \ + x5 = ROTL32(x5, 7); \ + xm = T32(x6 + xm); \ + x6 = ROTL32(x6, 7); \ + xn = T32(x7 + xn); \ + x7 = ROTL32(x7, 7); \ + xo = T32(x8 + xo); \ + x8 = ROTL32(x8, 7); \ + xp = T32(x9 + xp); \ + x9 = ROTL32(x9, 7); \ + xq = T32(xa + xq); \ + xa = ROTL32(xa, 7); \ + xr = T32(xb + xr); \ + xb = ROTL32(xb, 7); \ + xs = T32(xc + xs); \ + xc = ROTL32(xc, 7); \ + xt = T32(xd + xt); \ + xd = ROTL32(xd, 7); \ + xu = T32(xe + xu); \ + xe = ROTL32(xe, 7); \ + xv = T32(xf + xv); \ + xf = ROTL32(xf, 7); \ + x8 ^= xg; \ + x9 ^= xh; \ + xa ^= xi; \ + xb ^= xj; \ + xc ^= xk; \ + xd ^= xl; \ + xe ^= xm; \ + xf ^= xn; \ + x0 ^= xo; \ + x1 ^= xp; \ + x2 ^= xq; \ + x3 ^= xr; \ + x4 ^= xs; \ + x5 ^= xt; \ + x6 ^= xu; \ + x7 ^= xv; \ + xi = T32(x8 + xi); \ + x8 = ROTL32(x8, 11); \ + xj = T32(x9 + xj); \ + x9 = ROTL32(x9, 11); \ + xg = T32(xa + xg); \ + xa = ROTL32(xa, 11); \ + xh = T32(xb + xh); \ + xb = ROTL32(xb, 11); \ + xm = T32(xc + xm); \ + xc = ROTL32(xc, 11); \ + xn = T32(xd + xn); \ + xd = ROTL32(xd, 11); \ + xk = T32(xe + xk); \ + xe = ROTL32(xe, 11); \ + xl = T32(xf + xl); \ + xf = ROTL32(xf, 11); \ + xq = T32(x0 + xq); \ + x0 = ROTL32(x0, 11); \ + xr = T32(x1 + xr); \ + x1 = ROTL32(x1, 11); \ + xo = T32(x2 + xo); \ + x2 = ROTL32(x2, 11); \ + xp = T32(x3 + xp); \ + x3 = ROTL32(x3, 11); \ + xu = T32(x4 + xu); \ + x4 = ROTL32(x4, 11); \ + xv = T32(x5 + xv); \ + x5 = ROTL32(x5, 11); \ + xs = T32(x6 + xs); \ + x6 = ROTL32(x6, 11); \ + xt = T32(x7 + xt); \ + x7 = ROTL32(x7, 11); \ + xc ^= xi; \ + xd ^= xj; \ + xe ^= xg; \ + xf ^= xh; \ + x8 ^= xm; \ + x9 ^= xn; \ + xa ^= xk; \ + xb ^= xl; \ + x4 ^= xq; \ + x5 ^= xr; \ + x6 ^= xo; \ + x7 ^= xp; \ + x0 ^= xu; \ + x1 ^= xv; \ + x2 ^= xs; \ + x3 ^= xt; \ + } while (0) + +#define ROUND_ODD do { \ + xj = T32(xc + xj); \ + xc = ROTL32(xc, 7); \ + xi = T32(xd + xi); \ + xd = ROTL32(xd, 7); \ + xh = T32(xe + xh); \ + xe = ROTL32(xe, 7); \ + xg = T32(xf + xg); \ + xf = ROTL32(xf, 7); \ + xn = T32(x8 + xn); \ + x8 = ROTL32(x8, 7); \ + xm = T32(x9 + xm); \ + x9 = ROTL32(x9, 7); \ + xl = T32(xa + xl); \ + xa = ROTL32(xa, 7); \ + xk = T32(xb + xk); \ + xb = ROTL32(xb, 7); \ + xr = T32(x4 + xr); \ + x4 = ROTL32(x4, 7); \ + xq = T32(x5 + xq); \ + x5 = ROTL32(x5, 7); \ + xp = T32(x6 + xp); \ + x6 = ROTL32(x6, 7); \ + xo = T32(x7 + xo); \ + x7 = ROTL32(x7, 7); \ + xv = T32(x0 + xv); \ + x0 = ROTL32(x0, 7); \ + xu = T32(x1 + xu); \ + x1 = ROTL32(x1, 7); \ + xt = T32(x2 + xt); \ + x2 = ROTL32(x2, 7); \ + xs = T32(x3 + xs); \ + x3 = ROTL32(x3, 7); \ + x4 ^= xj; \ + x5 ^= xi; \ + x6 ^= xh; \ + x7 ^= xg; \ + x0 ^= xn; \ + x1 ^= xm; \ + x2 ^= xl; \ + x3 ^= xk; \ + xc ^= xr; \ + xd ^= xq; \ + xe ^= xp; \ + xf ^= xo; \ + x8 ^= xv; \ + x9 ^= xu; \ + xa ^= xt; \ + xb ^= xs; \ + xh = T32(x4 + xh); \ + x4 = ROTL32(x4, 11); \ + xg = T32(x5 + xg); \ + x5 = ROTL32(x5, 11); \ + xj = T32(x6 + xj); \ + x6 = ROTL32(x6, 11); \ + xi = T32(x7 + xi); \ + x7 = ROTL32(x7, 11); \ + xl = T32(x0 + xl); \ + x0 = ROTL32(x0, 11); \ + xk = T32(x1 + xk); \ + x1 = ROTL32(x1, 11); \ + xn = T32(x2 + xn); \ + x2 = ROTL32(x2, 11); \ + xm = T32(x3 + xm); \ + x3 = ROTL32(x3, 11); \ + xp = T32(xc + xp); \ + xc = ROTL32(xc, 11); \ + xo = T32(xd + xo); \ + xd = ROTL32(xd, 11); \ + xr = T32(xe + xr); \ + xe = ROTL32(xe, 11); \ + xq = T32(xf + xq); \ + xf = ROTL32(xf, 11); \ + xt = T32(x8 + xt); \ + x8 = ROTL32(x8, 11); \ + xs = T32(x9 + xs); \ + x9 = ROTL32(x9, 11); \ + xv = T32(xa + xv); \ + xa = ROTL32(xa, 11); \ + xu = T32(xb + xu); \ + xb = ROTL32(xb, 11); \ + x0 ^= xh; \ + x1 ^= xg; \ + x2 ^= xj; \ + x3 ^= xi; \ + x4 ^= xl; \ + x5 ^= xk; \ + x6 ^= xn; \ + x7 ^= xm; \ + x8 ^= xp; \ + x9 ^= xo; \ + xa ^= xr; \ + xb ^= xq; \ + xc ^= xt; \ + xd ^= xs; \ + xe ^= xv; \ + xf ^= xu; \ + } while (0) + +/* + * There is no need to unroll all 16 rounds. The word-swapping permutation + * is an involution, so we need to unroll an even number of rounds. On + * "big" systems, unrolling 4 rounds yields about 97% of the speed + * achieved with full unrolling; and it keeps the code more compact + * for small architectures. + */ + +#if SPH_CUBEHASH_UNROLL == 2 + +#define SIXTEEN_ROUNDS do { \ + int j; \ + for (j = 0; j < 8; j ++) { \ + ROUND_EVEN; \ + ROUND_ODD; \ + } \ + } while (0) + +#elif SPH_CUBEHASH_UNROLL == 4 + +#define SIXTEEN_ROUNDS do { \ + int j; \ + for (j = 0; j < 4; j ++) { \ + ROUND_EVEN; \ + ROUND_ODD; \ + ROUND_EVEN; \ + ROUND_ODD; \ + } \ + } while (0) + +#elif SPH_CUBEHASH_UNROLL == 8 + +#define SIXTEEN_ROUNDS do { \ + int j; \ + for (j = 0; j < 2; j ++) { \ + ROUND_EVEN; \ + ROUND_ODD; \ + ROUND_EVEN; \ + ROUND_ODD; \ + ROUND_EVEN; \ + ROUND_ODD; \ + ROUND_EVEN; \ + ROUND_ODD; \ + } \ + } while (0) + +#else + +#define SIXTEEN_ROUNDS do { \ + ROUND_EVEN; \ + ROUND_ODD; \ + ROUND_EVEN; \ + ROUND_ODD; \ + ROUND_EVEN; \ + ROUND_ODD; \ + ROUND_EVEN; \ + ROUND_ODD; \ + ROUND_EVEN; \ + ROUND_ODD; \ + ROUND_EVEN; \ + ROUND_ODD; \ + ROUND_EVEN; \ + ROUND_ODD; \ + ROUND_EVEN; \ + ROUND_ODD; \ + } while (0) + +#endif + +static void +cubehash_init(sph_cubehash_context *sc, const sph_u32 *iv) +{ + memcpy(sc->state, iv, sizeof sc->state); + sc->ptr = 0; +} + +static void +cubehash_core(sph_cubehash_context *sc, const void *data, size_t len) +{ + unsigned char *buf; + size_t ptr; + DECL_STATE + + buf = sc->buf; + ptr = sc->ptr; + if (len < (sizeof sc->buf) - ptr) { + memcpy(buf + ptr, data, len); + ptr += len; + sc->ptr = ptr; + return; + } + + READ_STATE(sc); + while (len > 0) { + size_t clen; + + clen = (sizeof sc->buf) - ptr; + if (clen > len) + clen = len; + memcpy(buf + ptr, data, clen); + ptr += clen; + data = (const unsigned char *)data + clen; + len -= clen; + if (ptr == sizeof sc->buf) { + INPUT_BLOCK; + SIXTEEN_ROUNDS; + ptr = 0; + } + } + WRITE_STATE(sc); + sc->ptr = ptr; +} + +static void +cubehash_close(sph_cubehash_context *sc, unsigned ub, unsigned n, + void *dst, size_t out_size_w32) +{ + unsigned char *buf, *out; + size_t ptr; + unsigned z; + int i; + DECL_STATE + + buf = sc->buf; + ptr = sc->ptr; + z = 0x80 >> n; + buf[ptr ++] = ((ub & -z) | z) & 0xFF; + memset(buf + ptr, 0, (sizeof sc->buf) - ptr); + READ_STATE(sc); + INPUT_BLOCK; + for (i = 0; i < 11; i ++) { + SIXTEEN_ROUNDS; + if (i == 0) + xv ^= SPH_C32(1); + } + WRITE_STATE(sc); + out = dst; + for (z = 0; z < out_size_w32; z ++) + sph_enc32le(out + (z << 2), sc->state[z]); +} + +/* see sph_cubehash.h */ +void +sph_cubehash224_init(void *cc) +{ + cubehash_init(cc, IV224); +} + +/* see sph_cubehash.h */ +void +sph_cubehash224(void *cc, const void *data, size_t len) +{ + cubehash_core(cc, data, len); +} + +/* see sph_cubehash.h */ +void +sph_cubehash224_close(void *cc, void *dst) +{ + sph_cubehash224_addbits_and_close(cc, 0, 0, dst); +} + +/* see sph_cubehash.h */ +void +sph_cubehash224_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + cubehash_close(cc, ub, n, dst, 7); + sph_cubehash224_init(cc); +} + +/* see sph_cubehash.h */ +void +sph_cubehash256_init(void *cc) +{ + cubehash_init(cc, IV256); +} + +/* see sph_cubehash.h */ +void +sph_cubehash256(void *cc, const void *data, size_t len) +{ + cubehash_core(cc, data, len); +} + +/* see sph_cubehash.h */ +void +sph_cubehash256_close(void *cc, void *dst) +{ + sph_cubehash256_addbits_and_close(cc, 0, 0, dst); +} + +/* see sph_cubehash.h */ +void +sph_cubehash256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + cubehash_close(cc, ub, n, dst, 8); + sph_cubehash256_init(cc); +} + +/* see sph_cubehash.h */ +void +sph_cubehash384_init(void *cc) +{ + cubehash_init(cc, IV384); +} + +/* see sph_cubehash.h */ +void +sph_cubehash384(void *cc, const void *data, size_t len) +{ + cubehash_core(cc, data, len); +} + +/* see sph_cubehash.h */ +void +sph_cubehash384_close(void *cc, void *dst) +{ + sph_cubehash384_addbits_and_close(cc, 0, 0, dst); +} + +/* see sph_cubehash.h */ +void +sph_cubehash384_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + cubehash_close(cc, ub, n, dst, 12); + sph_cubehash384_init(cc); +} + +/* see sph_cubehash.h */ +void +sph_cubehash512_init(void *cc) +{ + cubehash_init(cc, IV512); +} + +/* see sph_cubehash.h */ +void +sph_cubehash512(void *cc, const void *data, size_t len) +{ + cubehash_core(cc, data, len); +} + +/* see sph_cubehash.h */ +void +sph_cubehash512_close(void *cc, void *dst) +{ + sph_cubehash512_addbits_and_close(cc, 0, 0, dst); +} + +/* see sph_cubehash.h */ +void +sph_cubehash512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + cubehash_close(cc, ub, n, dst, 16); + sph_cubehash512_init(cc); +} +#ifdef __cplusplus +} +#endif diff --git a/src/obj/skunkhash/cubehash.o b/src/obj/skunkhash/cubehash.o new file mode 100644 index 0000000..7236585 Binary files /dev/null and b/src/obj/skunkhash/cubehash.o differ diff --git a/src/obj/skunkhash/fugue.c b/src/obj/skunkhash/fugue.c new file mode 100644 index 0000000..85767c9 --- /dev/null +++ b/src/obj/skunkhash/fugue.c @@ -0,0 +1,1208 @@ +#include +#include + +#include "sph_fugue.h" + +#ifdef __cplusplus +extern "C"{ +#endif + +#ifdef _MSC_VER +#pragma warning (disable: 4146) +#endif + +static const sph_u32 IV224[] = { + SPH_C32(0xf4c9120d), SPH_C32(0x6286f757), SPH_C32(0xee39e01c), + SPH_C32(0xe074e3cb), SPH_C32(0xa1127c62), SPH_C32(0x9a43d215), + SPH_C32(0xbd8d679a) +}; + +static const sph_u32 IV256[] = { + SPH_C32(0xe952bdde), SPH_C32(0x6671135f), SPH_C32(0xe0d4f668), + SPH_C32(0xd2b0b594), SPH_C32(0xf96c621d), SPH_C32(0xfbf929de), + SPH_C32(0x9149e899), SPH_C32(0x34f8c248) +}; + +static const sph_u32 IV384[] = { + SPH_C32(0xaa61ec0d), SPH_C32(0x31252e1f), SPH_C32(0xa01db4c7), + SPH_C32(0x00600985), SPH_C32(0x215ef44a), SPH_C32(0x741b5e9c), + SPH_C32(0xfa693e9a), SPH_C32(0x473eb040), SPH_C32(0xe502ae8a), + SPH_C32(0xa99c25e0), SPH_C32(0xbc95517c), SPH_C32(0x5c1095a1) +}; + +static const sph_u32 IV512[] = { + SPH_C32(0x8807a57e), SPH_C32(0xe616af75), SPH_C32(0xc5d3e4db), + SPH_C32(0xac9ab027), SPH_C32(0xd915f117), SPH_C32(0xb6eecc54), + SPH_C32(0x06e8020b), SPH_C32(0x4a92efd1), SPH_C32(0xaac6e2c9), + SPH_C32(0xddb21398), SPH_C32(0xcae65838), SPH_C32(0x437f203f), + SPH_C32(0x25ea78e7), SPH_C32(0x951fddd6), SPH_C32(0xda6ed11d), + SPH_C32(0xe13e3567) +}; + +static const sph_u32 mixtab0[] = { + SPH_C32(0x63633297), SPH_C32(0x7c7c6feb), SPH_C32(0x77775ec7), + SPH_C32(0x7b7b7af7), SPH_C32(0xf2f2e8e5), SPH_C32(0x6b6b0ab7), + SPH_C32(0x6f6f16a7), SPH_C32(0xc5c56d39), SPH_C32(0x303090c0), + SPH_C32(0x01010704), SPH_C32(0x67672e87), SPH_C32(0x2b2bd1ac), + SPH_C32(0xfefeccd5), SPH_C32(0xd7d71371), SPH_C32(0xabab7c9a), + SPH_C32(0x767659c3), SPH_C32(0xcaca4005), SPH_C32(0x8282a33e), + SPH_C32(0xc9c94909), SPH_C32(0x7d7d68ef), SPH_C32(0xfafad0c5), + SPH_C32(0x5959947f), SPH_C32(0x4747ce07), SPH_C32(0xf0f0e6ed), + SPH_C32(0xadad6e82), SPH_C32(0xd4d41a7d), SPH_C32(0xa2a243be), + SPH_C32(0xafaf608a), SPH_C32(0x9c9cf946), SPH_C32(0xa4a451a6), + SPH_C32(0x727245d3), SPH_C32(0xc0c0762d), SPH_C32(0xb7b728ea), + SPH_C32(0xfdfdc5d9), SPH_C32(0x9393d47a), SPH_C32(0x2626f298), + SPH_C32(0x363682d8), SPH_C32(0x3f3fbdfc), SPH_C32(0xf7f7f3f1), + SPH_C32(0xcccc521d), SPH_C32(0x34348cd0), SPH_C32(0xa5a556a2), + SPH_C32(0xe5e58db9), SPH_C32(0xf1f1e1e9), SPH_C32(0x71714cdf), + SPH_C32(0xd8d83e4d), SPH_C32(0x313197c4), SPH_C32(0x15156b54), + SPH_C32(0x04041c10), SPH_C32(0xc7c76331), SPH_C32(0x2323e98c), + SPH_C32(0xc3c37f21), SPH_C32(0x18184860), SPH_C32(0x9696cf6e), + SPH_C32(0x05051b14), SPH_C32(0x9a9aeb5e), SPH_C32(0x0707151c), + SPH_C32(0x12127e48), SPH_C32(0x8080ad36), SPH_C32(0xe2e298a5), + SPH_C32(0xebeba781), SPH_C32(0x2727f59c), SPH_C32(0xb2b233fe), + SPH_C32(0x757550cf), SPH_C32(0x09093f24), SPH_C32(0x8383a43a), + SPH_C32(0x2c2cc4b0), SPH_C32(0x1a1a4668), SPH_C32(0x1b1b416c), + SPH_C32(0x6e6e11a3), SPH_C32(0x5a5a9d73), SPH_C32(0xa0a04db6), + SPH_C32(0x5252a553), SPH_C32(0x3b3ba1ec), SPH_C32(0xd6d61475), + SPH_C32(0xb3b334fa), SPH_C32(0x2929dfa4), SPH_C32(0xe3e39fa1), + SPH_C32(0x2f2fcdbc), SPH_C32(0x8484b126), SPH_C32(0x5353a257), + SPH_C32(0xd1d10169), SPH_C32(0x00000000), SPH_C32(0xededb599), + SPH_C32(0x2020e080), SPH_C32(0xfcfcc2dd), SPH_C32(0xb1b13af2), + SPH_C32(0x5b5b9a77), SPH_C32(0x6a6a0db3), SPH_C32(0xcbcb4701), + SPH_C32(0xbebe17ce), SPH_C32(0x3939afe4), SPH_C32(0x4a4aed33), + SPH_C32(0x4c4cff2b), SPH_C32(0x5858937b), SPH_C32(0xcfcf5b11), + SPH_C32(0xd0d0066d), SPH_C32(0xefefbb91), SPH_C32(0xaaaa7b9e), + SPH_C32(0xfbfbd7c1), SPH_C32(0x4343d217), SPH_C32(0x4d4df82f), + SPH_C32(0x333399cc), SPH_C32(0x8585b622), SPH_C32(0x4545c00f), + SPH_C32(0xf9f9d9c9), SPH_C32(0x02020e08), SPH_C32(0x7f7f66e7), + SPH_C32(0x5050ab5b), SPH_C32(0x3c3cb4f0), SPH_C32(0x9f9ff04a), + SPH_C32(0xa8a87596), SPH_C32(0x5151ac5f), SPH_C32(0xa3a344ba), + SPH_C32(0x4040db1b), SPH_C32(0x8f8f800a), SPH_C32(0x9292d37e), + SPH_C32(0x9d9dfe42), SPH_C32(0x3838a8e0), SPH_C32(0xf5f5fdf9), + SPH_C32(0xbcbc19c6), SPH_C32(0xb6b62fee), SPH_C32(0xdada3045), + SPH_C32(0x2121e784), SPH_C32(0x10107040), SPH_C32(0xffffcbd1), + SPH_C32(0xf3f3efe1), SPH_C32(0xd2d20865), SPH_C32(0xcdcd5519), + SPH_C32(0x0c0c2430), SPH_C32(0x1313794c), SPH_C32(0xececb29d), + SPH_C32(0x5f5f8667), SPH_C32(0x9797c86a), SPH_C32(0x4444c70b), + SPH_C32(0x1717655c), SPH_C32(0xc4c46a3d), SPH_C32(0xa7a758aa), + SPH_C32(0x7e7e61e3), SPH_C32(0x3d3db3f4), SPH_C32(0x6464278b), + SPH_C32(0x5d5d886f), SPH_C32(0x19194f64), SPH_C32(0x737342d7), + SPH_C32(0x60603b9b), SPH_C32(0x8181aa32), SPH_C32(0x4f4ff627), + SPH_C32(0xdcdc225d), SPH_C32(0x2222ee88), SPH_C32(0x2a2ad6a8), + SPH_C32(0x9090dd76), SPH_C32(0x88889516), SPH_C32(0x4646c903), + SPH_C32(0xeeeebc95), SPH_C32(0xb8b805d6), SPH_C32(0x14146c50), + SPH_C32(0xdede2c55), SPH_C32(0x5e5e8163), SPH_C32(0x0b0b312c), + SPH_C32(0xdbdb3741), SPH_C32(0xe0e096ad), SPH_C32(0x32329ec8), + SPH_C32(0x3a3aa6e8), SPH_C32(0x0a0a3628), SPH_C32(0x4949e43f), + SPH_C32(0x06061218), SPH_C32(0x2424fc90), SPH_C32(0x5c5c8f6b), + SPH_C32(0xc2c27825), SPH_C32(0xd3d30f61), SPH_C32(0xacac6986), + SPH_C32(0x62623593), SPH_C32(0x9191da72), SPH_C32(0x9595c662), + SPH_C32(0xe4e48abd), SPH_C32(0x797974ff), SPH_C32(0xe7e783b1), + SPH_C32(0xc8c84e0d), SPH_C32(0x373785dc), SPH_C32(0x6d6d18af), + SPH_C32(0x8d8d8e02), SPH_C32(0xd5d51d79), SPH_C32(0x4e4ef123), + SPH_C32(0xa9a97292), SPH_C32(0x6c6c1fab), SPH_C32(0x5656b943), + SPH_C32(0xf4f4fafd), SPH_C32(0xeaeaa085), SPH_C32(0x6565208f), + SPH_C32(0x7a7a7df3), SPH_C32(0xaeae678e), SPH_C32(0x08083820), + SPH_C32(0xbaba0bde), SPH_C32(0x787873fb), SPH_C32(0x2525fb94), + SPH_C32(0x2e2ecab8), SPH_C32(0x1c1c5470), SPH_C32(0xa6a65fae), + SPH_C32(0xb4b421e6), SPH_C32(0xc6c66435), SPH_C32(0xe8e8ae8d), + SPH_C32(0xdddd2559), SPH_C32(0x747457cb), SPH_C32(0x1f1f5d7c), + SPH_C32(0x4b4bea37), SPH_C32(0xbdbd1ec2), SPH_C32(0x8b8b9c1a), + SPH_C32(0x8a8a9b1e), SPH_C32(0x70704bdb), SPH_C32(0x3e3ebaf8), + SPH_C32(0xb5b526e2), SPH_C32(0x66662983), SPH_C32(0x4848e33b), + SPH_C32(0x0303090c), SPH_C32(0xf6f6f4f5), SPH_C32(0x0e0e2a38), + SPH_C32(0x61613c9f), SPH_C32(0x35358bd4), SPH_C32(0x5757be47), + SPH_C32(0xb9b902d2), SPH_C32(0x8686bf2e), SPH_C32(0xc1c17129), + SPH_C32(0x1d1d5374), SPH_C32(0x9e9ef74e), SPH_C32(0xe1e191a9), + SPH_C32(0xf8f8decd), SPH_C32(0x9898e556), SPH_C32(0x11117744), + SPH_C32(0x696904bf), SPH_C32(0xd9d93949), SPH_C32(0x8e8e870e), + SPH_C32(0x9494c166), SPH_C32(0x9b9bec5a), SPH_C32(0x1e1e5a78), + SPH_C32(0x8787b82a), SPH_C32(0xe9e9a989), SPH_C32(0xcece5c15), + SPH_C32(0x5555b04f), SPH_C32(0x2828d8a0), SPH_C32(0xdfdf2b51), + SPH_C32(0x8c8c8906), SPH_C32(0xa1a14ab2), SPH_C32(0x89899212), + SPH_C32(0x0d0d2334), SPH_C32(0xbfbf10ca), SPH_C32(0xe6e684b5), + SPH_C32(0x4242d513), SPH_C32(0x686803bb), SPH_C32(0x4141dc1f), + SPH_C32(0x9999e252), SPH_C32(0x2d2dc3b4), SPH_C32(0x0f0f2d3c), + SPH_C32(0xb0b03df6), SPH_C32(0x5454b74b), SPH_C32(0xbbbb0cda), + SPH_C32(0x16166258) +}; + +static const sph_u32 mixtab1[] = { + SPH_C32(0x97636332), SPH_C32(0xeb7c7c6f), SPH_C32(0xc777775e), + SPH_C32(0xf77b7b7a), SPH_C32(0xe5f2f2e8), SPH_C32(0xb76b6b0a), + SPH_C32(0xa76f6f16), SPH_C32(0x39c5c56d), SPH_C32(0xc0303090), + SPH_C32(0x04010107), SPH_C32(0x8767672e), SPH_C32(0xac2b2bd1), + SPH_C32(0xd5fefecc), SPH_C32(0x71d7d713), SPH_C32(0x9aabab7c), + SPH_C32(0xc3767659), SPH_C32(0x05caca40), SPH_C32(0x3e8282a3), + SPH_C32(0x09c9c949), SPH_C32(0xef7d7d68), SPH_C32(0xc5fafad0), + SPH_C32(0x7f595994), SPH_C32(0x074747ce), SPH_C32(0xedf0f0e6), + SPH_C32(0x82adad6e), SPH_C32(0x7dd4d41a), SPH_C32(0xbea2a243), + SPH_C32(0x8aafaf60), SPH_C32(0x469c9cf9), SPH_C32(0xa6a4a451), + SPH_C32(0xd3727245), SPH_C32(0x2dc0c076), SPH_C32(0xeab7b728), + SPH_C32(0xd9fdfdc5), SPH_C32(0x7a9393d4), SPH_C32(0x982626f2), + SPH_C32(0xd8363682), SPH_C32(0xfc3f3fbd), SPH_C32(0xf1f7f7f3), + SPH_C32(0x1dcccc52), SPH_C32(0xd034348c), SPH_C32(0xa2a5a556), + SPH_C32(0xb9e5e58d), SPH_C32(0xe9f1f1e1), SPH_C32(0xdf71714c), + SPH_C32(0x4dd8d83e), SPH_C32(0xc4313197), SPH_C32(0x5415156b), + SPH_C32(0x1004041c), SPH_C32(0x31c7c763), SPH_C32(0x8c2323e9), + SPH_C32(0x21c3c37f), SPH_C32(0x60181848), SPH_C32(0x6e9696cf), + SPH_C32(0x1405051b), SPH_C32(0x5e9a9aeb), SPH_C32(0x1c070715), + SPH_C32(0x4812127e), SPH_C32(0x368080ad), SPH_C32(0xa5e2e298), + SPH_C32(0x81ebeba7), SPH_C32(0x9c2727f5), SPH_C32(0xfeb2b233), + SPH_C32(0xcf757550), SPH_C32(0x2409093f), SPH_C32(0x3a8383a4), + SPH_C32(0xb02c2cc4), SPH_C32(0x681a1a46), SPH_C32(0x6c1b1b41), + SPH_C32(0xa36e6e11), SPH_C32(0x735a5a9d), SPH_C32(0xb6a0a04d), + SPH_C32(0x535252a5), SPH_C32(0xec3b3ba1), SPH_C32(0x75d6d614), + SPH_C32(0xfab3b334), SPH_C32(0xa42929df), SPH_C32(0xa1e3e39f), + SPH_C32(0xbc2f2fcd), SPH_C32(0x268484b1), SPH_C32(0x575353a2), + SPH_C32(0x69d1d101), SPH_C32(0x00000000), SPH_C32(0x99ededb5), + SPH_C32(0x802020e0), SPH_C32(0xddfcfcc2), SPH_C32(0xf2b1b13a), + SPH_C32(0x775b5b9a), SPH_C32(0xb36a6a0d), SPH_C32(0x01cbcb47), + SPH_C32(0xcebebe17), SPH_C32(0xe43939af), SPH_C32(0x334a4aed), + SPH_C32(0x2b4c4cff), SPH_C32(0x7b585893), SPH_C32(0x11cfcf5b), + SPH_C32(0x6dd0d006), SPH_C32(0x91efefbb), SPH_C32(0x9eaaaa7b), + SPH_C32(0xc1fbfbd7), SPH_C32(0x174343d2), SPH_C32(0x2f4d4df8), + SPH_C32(0xcc333399), SPH_C32(0x228585b6), SPH_C32(0x0f4545c0), + SPH_C32(0xc9f9f9d9), SPH_C32(0x0802020e), SPH_C32(0xe77f7f66), + SPH_C32(0x5b5050ab), SPH_C32(0xf03c3cb4), SPH_C32(0x4a9f9ff0), + SPH_C32(0x96a8a875), SPH_C32(0x5f5151ac), SPH_C32(0xbaa3a344), + SPH_C32(0x1b4040db), SPH_C32(0x0a8f8f80), SPH_C32(0x7e9292d3), + SPH_C32(0x429d9dfe), SPH_C32(0xe03838a8), SPH_C32(0xf9f5f5fd), + SPH_C32(0xc6bcbc19), SPH_C32(0xeeb6b62f), SPH_C32(0x45dada30), + SPH_C32(0x842121e7), SPH_C32(0x40101070), SPH_C32(0xd1ffffcb), + SPH_C32(0xe1f3f3ef), SPH_C32(0x65d2d208), SPH_C32(0x19cdcd55), + SPH_C32(0x300c0c24), SPH_C32(0x4c131379), SPH_C32(0x9dececb2), + SPH_C32(0x675f5f86), SPH_C32(0x6a9797c8), SPH_C32(0x0b4444c7), + SPH_C32(0x5c171765), SPH_C32(0x3dc4c46a), SPH_C32(0xaaa7a758), + SPH_C32(0xe37e7e61), SPH_C32(0xf43d3db3), SPH_C32(0x8b646427), + SPH_C32(0x6f5d5d88), SPH_C32(0x6419194f), SPH_C32(0xd7737342), + SPH_C32(0x9b60603b), SPH_C32(0x328181aa), SPH_C32(0x274f4ff6), + SPH_C32(0x5ddcdc22), SPH_C32(0x882222ee), SPH_C32(0xa82a2ad6), + SPH_C32(0x769090dd), SPH_C32(0x16888895), SPH_C32(0x034646c9), + SPH_C32(0x95eeeebc), SPH_C32(0xd6b8b805), SPH_C32(0x5014146c), + SPH_C32(0x55dede2c), SPH_C32(0x635e5e81), SPH_C32(0x2c0b0b31), + SPH_C32(0x41dbdb37), SPH_C32(0xade0e096), SPH_C32(0xc832329e), + SPH_C32(0xe83a3aa6), SPH_C32(0x280a0a36), SPH_C32(0x3f4949e4), + SPH_C32(0x18060612), SPH_C32(0x902424fc), SPH_C32(0x6b5c5c8f), + SPH_C32(0x25c2c278), SPH_C32(0x61d3d30f), SPH_C32(0x86acac69), + SPH_C32(0x93626235), SPH_C32(0x729191da), SPH_C32(0x629595c6), + SPH_C32(0xbde4e48a), SPH_C32(0xff797974), SPH_C32(0xb1e7e783), + SPH_C32(0x0dc8c84e), SPH_C32(0xdc373785), SPH_C32(0xaf6d6d18), + SPH_C32(0x028d8d8e), SPH_C32(0x79d5d51d), SPH_C32(0x234e4ef1), + SPH_C32(0x92a9a972), SPH_C32(0xab6c6c1f), SPH_C32(0x435656b9), + SPH_C32(0xfdf4f4fa), SPH_C32(0x85eaeaa0), SPH_C32(0x8f656520), + SPH_C32(0xf37a7a7d), SPH_C32(0x8eaeae67), SPH_C32(0x20080838), + SPH_C32(0xdebaba0b), SPH_C32(0xfb787873), SPH_C32(0x942525fb), + SPH_C32(0xb82e2eca), SPH_C32(0x701c1c54), SPH_C32(0xaea6a65f), + SPH_C32(0xe6b4b421), SPH_C32(0x35c6c664), SPH_C32(0x8de8e8ae), + SPH_C32(0x59dddd25), SPH_C32(0xcb747457), SPH_C32(0x7c1f1f5d), + SPH_C32(0x374b4bea), SPH_C32(0xc2bdbd1e), SPH_C32(0x1a8b8b9c), + SPH_C32(0x1e8a8a9b), SPH_C32(0xdb70704b), SPH_C32(0xf83e3eba), + SPH_C32(0xe2b5b526), SPH_C32(0x83666629), SPH_C32(0x3b4848e3), + SPH_C32(0x0c030309), SPH_C32(0xf5f6f6f4), SPH_C32(0x380e0e2a), + SPH_C32(0x9f61613c), SPH_C32(0xd435358b), SPH_C32(0x475757be), + SPH_C32(0xd2b9b902), SPH_C32(0x2e8686bf), SPH_C32(0x29c1c171), + SPH_C32(0x741d1d53), SPH_C32(0x4e9e9ef7), SPH_C32(0xa9e1e191), + SPH_C32(0xcdf8f8de), SPH_C32(0x569898e5), SPH_C32(0x44111177), + SPH_C32(0xbf696904), SPH_C32(0x49d9d939), SPH_C32(0x0e8e8e87), + SPH_C32(0x669494c1), SPH_C32(0x5a9b9bec), SPH_C32(0x781e1e5a), + SPH_C32(0x2a8787b8), SPH_C32(0x89e9e9a9), SPH_C32(0x15cece5c), + SPH_C32(0x4f5555b0), SPH_C32(0xa02828d8), SPH_C32(0x51dfdf2b), + SPH_C32(0x068c8c89), SPH_C32(0xb2a1a14a), SPH_C32(0x12898992), + SPH_C32(0x340d0d23), SPH_C32(0xcabfbf10), SPH_C32(0xb5e6e684), + SPH_C32(0x134242d5), SPH_C32(0xbb686803), SPH_C32(0x1f4141dc), + SPH_C32(0x529999e2), SPH_C32(0xb42d2dc3), SPH_C32(0x3c0f0f2d), + SPH_C32(0xf6b0b03d), SPH_C32(0x4b5454b7), SPH_C32(0xdabbbb0c), + SPH_C32(0x58161662) +}; + +static const sph_u32 mixtab2[] = { + SPH_C32(0x32976363), SPH_C32(0x6feb7c7c), SPH_C32(0x5ec77777), + SPH_C32(0x7af77b7b), SPH_C32(0xe8e5f2f2), SPH_C32(0x0ab76b6b), + SPH_C32(0x16a76f6f), SPH_C32(0x6d39c5c5), SPH_C32(0x90c03030), + SPH_C32(0x07040101), SPH_C32(0x2e876767), SPH_C32(0xd1ac2b2b), + SPH_C32(0xccd5fefe), SPH_C32(0x1371d7d7), SPH_C32(0x7c9aabab), + SPH_C32(0x59c37676), SPH_C32(0x4005caca), SPH_C32(0xa33e8282), + SPH_C32(0x4909c9c9), SPH_C32(0x68ef7d7d), SPH_C32(0xd0c5fafa), + SPH_C32(0x947f5959), SPH_C32(0xce074747), SPH_C32(0xe6edf0f0), + SPH_C32(0x6e82adad), SPH_C32(0x1a7dd4d4), SPH_C32(0x43bea2a2), + SPH_C32(0x608aafaf), SPH_C32(0xf9469c9c), SPH_C32(0x51a6a4a4), + SPH_C32(0x45d37272), SPH_C32(0x762dc0c0), SPH_C32(0x28eab7b7), + SPH_C32(0xc5d9fdfd), SPH_C32(0xd47a9393), SPH_C32(0xf2982626), + SPH_C32(0x82d83636), SPH_C32(0xbdfc3f3f), SPH_C32(0xf3f1f7f7), + SPH_C32(0x521dcccc), SPH_C32(0x8cd03434), SPH_C32(0x56a2a5a5), + SPH_C32(0x8db9e5e5), SPH_C32(0xe1e9f1f1), SPH_C32(0x4cdf7171), + SPH_C32(0x3e4dd8d8), SPH_C32(0x97c43131), SPH_C32(0x6b541515), + SPH_C32(0x1c100404), SPH_C32(0x6331c7c7), SPH_C32(0xe98c2323), + SPH_C32(0x7f21c3c3), SPH_C32(0x48601818), SPH_C32(0xcf6e9696), + SPH_C32(0x1b140505), SPH_C32(0xeb5e9a9a), SPH_C32(0x151c0707), + SPH_C32(0x7e481212), SPH_C32(0xad368080), SPH_C32(0x98a5e2e2), + SPH_C32(0xa781ebeb), SPH_C32(0xf59c2727), SPH_C32(0x33feb2b2), + SPH_C32(0x50cf7575), SPH_C32(0x3f240909), SPH_C32(0xa43a8383), + SPH_C32(0xc4b02c2c), SPH_C32(0x46681a1a), SPH_C32(0x416c1b1b), + SPH_C32(0x11a36e6e), SPH_C32(0x9d735a5a), SPH_C32(0x4db6a0a0), + SPH_C32(0xa5535252), SPH_C32(0xa1ec3b3b), SPH_C32(0x1475d6d6), + SPH_C32(0x34fab3b3), SPH_C32(0xdfa42929), SPH_C32(0x9fa1e3e3), + SPH_C32(0xcdbc2f2f), SPH_C32(0xb1268484), SPH_C32(0xa2575353), + SPH_C32(0x0169d1d1), SPH_C32(0x00000000), SPH_C32(0xb599eded), + SPH_C32(0xe0802020), SPH_C32(0xc2ddfcfc), SPH_C32(0x3af2b1b1), + SPH_C32(0x9a775b5b), SPH_C32(0x0db36a6a), SPH_C32(0x4701cbcb), + SPH_C32(0x17cebebe), SPH_C32(0xafe43939), SPH_C32(0xed334a4a), + SPH_C32(0xff2b4c4c), SPH_C32(0x937b5858), SPH_C32(0x5b11cfcf), + SPH_C32(0x066dd0d0), SPH_C32(0xbb91efef), SPH_C32(0x7b9eaaaa), + SPH_C32(0xd7c1fbfb), SPH_C32(0xd2174343), SPH_C32(0xf82f4d4d), + SPH_C32(0x99cc3333), SPH_C32(0xb6228585), SPH_C32(0xc00f4545), + SPH_C32(0xd9c9f9f9), SPH_C32(0x0e080202), SPH_C32(0x66e77f7f), + SPH_C32(0xab5b5050), SPH_C32(0xb4f03c3c), SPH_C32(0xf04a9f9f), + SPH_C32(0x7596a8a8), SPH_C32(0xac5f5151), SPH_C32(0x44baa3a3), + SPH_C32(0xdb1b4040), SPH_C32(0x800a8f8f), SPH_C32(0xd37e9292), + SPH_C32(0xfe429d9d), SPH_C32(0xa8e03838), SPH_C32(0xfdf9f5f5), + SPH_C32(0x19c6bcbc), SPH_C32(0x2feeb6b6), SPH_C32(0x3045dada), + SPH_C32(0xe7842121), SPH_C32(0x70401010), SPH_C32(0xcbd1ffff), + SPH_C32(0xefe1f3f3), SPH_C32(0x0865d2d2), SPH_C32(0x5519cdcd), + SPH_C32(0x24300c0c), SPH_C32(0x794c1313), SPH_C32(0xb29decec), + SPH_C32(0x86675f5f), SPH_C32(0xc86a9797), SPH_C32(0xc70b4444), + SPH_C32(0x655c1717), SPH_C32(0x6a3dc4c4), SPH_C32(0x58aaa7a7), + SPH_C32(0x61e37e7e), SPH_C32(0xb3f43d3d), SPH_C32(0x278b6464), + SPH_C32(0x886f5d5d), SPH_C32(0x4f641919), SPH_C32(0x42d77373), + SPH_C32(0x3b9b6060), SPH_C32(0xaa328181), SPH_C32(0xf6274f4f), + SPH_C32(0x225ddcdc), SPH_C32(0xee882222), SPH_C32(0xd6a82a2a), + SPH_C32(0xdd769090), SPH_C32(0x95168888), SPH_C32(0xc9034646), + SPH_C32(0xbc95eeee), SPH_C32(0x05d6b8b8), SPH_C32(0x6c501414), + SPH_C32(0x2c55dede), SPH_C32(0x81635e5e), SPH_C32(0x312c0b0b), + SPH_C32(0x3741dbdb), SPH_C32(0x96ade0e0), SPH_C32(0x9ec83232), + SPH_C32(0xa6e83a3a), SPH_C32(0x36280a0a), SPH_C32(0xe43f4949), + SPH_C32(0x12180606), SPH_C32(0xfc902424), SPH_C32(0x8f6b5c5c), + SPH_C32(0x7825c2c2), SPH_C32(0x0f61d3d3), SPH_C32(0x6986acac), + SPH_C32(0x35936262), SPH_C32(0xda729191), SPH_C32(0xc6629595), + SPH_C32(0x8abde4e4), SPH_C32(0x74ff7979), SPH_C32(0x83b1e7e7), + SPH_C32(0x4e0dc8c8), SPH_C32(0x85dc3737), SPH_C32(0x18af6d6d), + SPH_C32(0x8e028d8d), SPH_C32(0x1d79d5d5), SPH_C32(0xf1234e4e), + SPH_C32(0x7292a9a9), SPH_C32(0x1fab6c6c), SPH_C32(0xb9435656), + SPH_C32(0xfafdf4f4), SPH_C32(0xa085eaea), SPH_C32(0x208f6565), + SPH_C32(0x7df37a7a), SPH_C32(0x678eaeae), SPH_C32(0x38200808), + SPH_C32(0x0bdebaba), SPH_C32(0x73fb7878), SPH_C32(0xfb942525), + SPH_C32(0xcab82e2e), SPH_C32(0x54701c1c), SPH_C32(0x5faea6a6), + SPH_C32(0x21e6b4b4), SPH_C32(0x6435c6c6), SPH_C32(0xae8de8e8), + SPH_C32(0x2559dddd), SPH_C32(0x57cb7474), SPH_C32(0x5d7c1f1f), + SPH_C32(0xea374b4b), SPH_C32(0x1ec2bdbd), SPH_C32(0x9c1a8b8b), + SPH_C32(0x9b1e8a8a), SPH_C32(0x4bdb7070), SPH_C32(0xbaf83e3e), + SPH_C32(0x26e2b5b5), SPH_C32(0x29836666), SPH_C32(0xe33b4848), + SPH_C32(0x090c0303), SPH_C32(0xf4f5f6f6), SPH_C32(0x2a380e0e), + SPH_C32(0x3c9f6161), SPH_C32(0x8bd43535), SPH_C32(0xbe475757), + SPH_C32(0x02d2b9b9), SPH_C32(0xbf2e8686), SPH_C32(0x7129c1c1), + SPH_C32(0x53741d1d), SPH_C32(0xf74e9e9e), SPH_C32(0x91a9e1e1), + SPH_C32(0xdecdf8f8), SPH_C32(0xe5569898), SPH_C32(0x77441111), + SPH_C32(0x04bf6969), SPH_C32(0x3949d9d9), SPH_C32(0x870e8e8e), + SPH_C32(0xc1669494), SPH_C32(0xec5a9b9b), SPH_C32(0x5a781e1e), + SPH_C32(0xb82a8787), SPH_C32(0xa989e9e9), SPH_C32(0x5c15cece), + SPH_C32(0xb04f5555), SPH_C32(0xd8a02828), SPH_C32(0x2b51dfdf), + SPH_C32(0x89068c8c), SPH_C32(0x4ab2a1a1), SPH_C32(0x92128989), + SPH_C32(0x23340d0d), SPH_C32(0x10cabfbf), SPH_C32(0x84b5e6e6), + SPH_C32(0xd5134242), SPH_C32(0x03bb6868), SPH_C32(0xdc1f4141), + SPH_C32(0xe2529999), SPH_C32(0xc3b42d2d), SPH_C32(0x2d3c0f0f), + SPH_C32(0x3df6b0b0), SPH_C32(0xb74b5454), SPH_C32(0x0cdabbbb), + SPH_C32(0x62581616) +}; + +static const sph_u32 mixtab3[] = { + SPH_C32(0x63329763), SPH_C32(0x7c6feb7c), SPH_C32(0x775ec777), + SPH_C32(0x7b7af77b), SPH_C32(0xf2e8e5f2), SPH_C32(0x6b0ab76b), + SPH_C32(0x6f16a76f), SPH_C32(0xc56d39c5), SPH_C32(0x3090c030), + SPH_C32(0x01070401), SPH_C32(0x672e8767), SPH_C32(0x2bd1ac2b), + SPH_C32(0xfeccd5fe), SPH_C32(0xd71371d7), SPH_C32(0xab7c9aab), + SPH_C32(0x7659c376), SPH_C32(0xca4005ca), SPH_C32(0x82a33e82), + SPH_C32(0xc94909c9), SPH_C32(0x7d68ef7d), SPH_C32(0xfad0c5fa), + SPH_C32(0x59947f59), SPH_C32(0x47ce0747), SPH_C32(0xf0e6edf0), + SPH_C32(0xad6e82ad), SPH_C32(0xd41a7dd4), SPH_C32(0xa243bea2), + SPH_C32(0xaf608aaf), SPH_C32(0x9cf9469c), SPH_C32(0xa451a6a4), + SPH_C32(0x7245d372), SPH_C32(0xc0762dc0), SPH_C32(0xb728eab7), + SPH_C32(0xfdc5d9fd), SPH_C32(0x93d47a93), SPH_C32(0x26f29826), + SPH_C32(0x3682d836), SPH_C32(0x3fbdfc3f), SPH_C32(0xf7f3f1f7), + SPH_C32(0xcc521dcc), SPH_C32(0x348cd034), SPH_C32(0xa556a2a5), + SPH_C32(0xe58db9e5), SPH_C32(0xf1e1e9f1), SPH_C32(0x714cdf71), + SPH_C32(0xd83e4dd8), SPH_C32(0x3197c431), SPH_C32(0x156b5415), + SPH_C32(0x041c1004), SPH_C32(0xc76331c7), SPH_C32(0x23e98c23), + SPH_C32(0xc37f21c3), SPH_C32(0x18486018), SPH_C32(0x96cf6e96), + SPH_C32(0x051b1405), SPH_C32(0x9aeb5e9a), SPH_C32(0x07151c07), + SPH_C32(0x127e4812), SPH_C32(0x80ad3680), SPH_C32(0xe298a5e2), + SPH_C32(0xeba781eb), SPH_C32(0x27f59c27), SPH_C32(0xb233feb2), + SPH_C32(0x7550cf75), SPH_C32(0x093f2409), SPH_C32(0x83a43a83), + SPH_C32(0x2cc4b02c), SPH_C32(0x1a46681a), SPH_C32(0x1b416c1b), + SPH_C32(0x6e11a36e), SPH_C32(0x5a9d735a), SPH_C32(0xa04db6a0), + SPH_C32(0x52a55352), SPH_C32(0x3ba1ec3b), SPH_C32(0xd61475d6), + SPH_C32(0xb334fab3), SPH_C32(0x29dfa429), SPH_C32(0xe39fa1e3), + SPH_C32(0x2fcdbc2f), SPH_C32(0x84b12684), SPH_C32(0x53a25753), + SPH_C32(0xd10169d1), SPH_C32(0x00000000), SPH_C32(0xedb599ed), + SPH_C32(0x20e08020), SPH_C32(0xfcc2ddfc), SPH_C32(0xb13af2b1), + SPH_C32(0x5b9a775b), SPH_C32(0x6a0db36a), SPH_C32(0xcb4701cb), + SPH_C32(0xbe17cebe), SPH_C32(0x39afe439), SPH_C32(0x4aed334a), + SPH_C32(0x4cff2b4c), SPH_C32(0x58937b58), SPH_C32(0xcf5b11cf), + SPH_C32(0xd0066dd0), SPH_C32(0xefbb91ef), SPH_C32(0xaa7b9eaa), + SPH_C32(0xfbd7c1fb), SPH_C32(0x43d21743), SPH_C32(0x4df82f4d), + SPH_C32(0x3399cc33), SPH_C32(0x85b62285), SPH_C32(0x45c00f45), + SPH_C32(0xf9d9c9f9), SPH_C32(0x020e0802), SPH_C32(0x7f66e77f), + SPH_C32(0x50ab5b50), SPH_C32(0x3cb4f03c), SPH_C32(0x9ff04a9f), + SPH_C32(0xa87596a8), SPH_C32(0x51ac5f51), SPH_C32(0xa344baa3), + SPH_C32(0x40db1b40), SPH_C32(0x8f800a8f), SPH_C32(0x92d37e92), + SPH_C32(0x9dfe429d), SPH_C32(0x38a8e038), SPH_C32(0xf5fdf9f5), + SPH_C32(0xbc19c6bc), SPH_C32(0xb62feeb6), SPH_C32(0xda3045da), + SPH_C32(0x21e78421), SPH_C32(0x10704010), SPH_C32(0xffcbd1ff), + SPH_C32(0xf3efe1f3), SPH_C32(0xd20865d2), SPH_C32(0xcd5519cd), + SPH_C32(0x0c24300c), SPH_C32(0x13794c13), SPH_C32(0xecb29dec), + SPH_C32(0x5f86675f), SPH_C32(0x97c86a97), SPH_C32(0x44c70b44), + SPH_C32(0x17655c17), SPH_C32(0xc46a3dc4), SPH_C32(0xa758aaa7), + SPH_C32(0x7e61e37e), SPH_C32(0x3db3f43d), SPH_C32(0x64278b64), + SPH_C32(0x5d886f5d), SPH_C32(0x194f6419), SPH_C32(0x7342d773), + SPH_C32(0x603b9b60), SPH_C32(0x81aa3281), SPH_C32(0x4ff6274f), + SPH_C32(0xdc225ddc), SPH_C32(0x22ee8822), SPH_C32(0x2ad6a82a), + SPH_C32(0x90dd7690), SPH_C32(0x88951688), SPH_C32(0x46c90346), + SPH_C32(0xeebc95ee), SPH_C32(0xb805d6b8), SPH_C32(0x146c5014), + SPH_C32(0xde2c55de), SPH_C32(0x5e81635e), SPH_C32(0x0b312c0b), + SPH_C32(0xdb3741db), SPH_C32(0xe096ade0), SPH_C32(0x329ec832), + SPH_C32(0x3aa6e83a), SPH_C32(0x0a36280a), SPH_C32(0x49e43f49), + SPH_C32(0x06121806), SPH_C32(0x24fc9024), SPH_C32(0x5c8f6b5c), + SPH_C32(0xc27825c2), SPH_C32(0xd30f61d3), SPH_C32(0xac6986ac), + SPH_C32(0x62359362), SPH_C32(0x91da7291), SPH_C32(0x95c66295), + SPH_C32(0xe48abde4), SPH_C32(0x7974ff79), SPH_C32(0xe783b1e7), + SPH_C32(0xc84e0dc8), SPH_C32(0x3785dc37), SPH_C32(0x6d18af6d), + SPH_C32(0x8d8e028d), SPH_C32(0xd51d79d5), SPH_C32(0x4ef1234e), + SPH_C32(0xa97292a9), SPH_C32(0x6c1fab6c), SPH_C32(0x56b94356), + SPH_C32(0xf4fafdf4), SPH_C32(0xeaa085ea), SPH_C32(0x65208f65), + SPH_C32(0x7a7df37a), SPH_C32(0xae678eae), SPH_C32(0x08382008), + SPH_C32(0xba0bdeba), SPH_C32(0x7873fb78), SPH_C32(0x25fb9425), + SPH_C32(0x2ecab82e), SPH_C32(0x1c54701c), SPH_C32(0xa65faea6), + SPH_C32(0xb421e6b4), SPH_C32(0xc66435c6), SPH_C32(0xe8ae8de8), + SPH_C32(0xdd2559dd), SPH_C32(0x7457cb74), SPH_C32(0x1f5d7c1f), + SPH_C32(0x4bea374b), SPH_C32(0xbd1ec2bd), SPH_C32(0x8b9c1a8b), + SPH_C32(0x8a9b1e8a), SPH_C32(0x704bdb70), SPH_C32(0x3ebaf83e), + SPH_C32(0xb526e2b5), SPH_C32(0x66298366), SPH_C32(0x48e33b48), + SPH_C32(0x03090c03), SPH_C32(0xf6f4f5f6), SPH_C32(0x0e2a380e), + SPH_C32(0x613c9f61), SPH_C32(0x358bd435), SPH_C32(0x57be4757), + SPH_C32(0xb902d2b9), SPH_C32(0x86bf2e86), SPH_C32(0xc17129c1), + SPH_C32(0x1d53741d), SPH_C32(0x9ef74e9e), SPH_C32(0xe191a9e1), + SPH_C32(0xf8decdf8), SPH_C32(0x98e55698), SPH_C32(0x11774411), + SPH_C32(0x6904bf69), SPH_C32(0xd93949d9), SPH_C32(0x8e870e8e), + SPH_C32(0x94c16694), SPH_C32(0x9bec5a9b), SPH_C32(0x1e5a781e), + SPH_C32(0x87b82a87), SPH_C32(0xe9a989e9), SPH_C32(0xce5c15ce), + SPH_C32(0x55b04f55), SPH_C32(0x28d8a028), SPH_C32(0xdf2b51df), + SPH_C32(0x8c89068c), SPH_C32(0xa14ab2a1), SPH_C32(0x89921289), + SPH_C32(0x0d23340d), SPH_C32(0xbf10cabf), SPH_C32(0xe684b5e6), + SPH_C32(0x42d51342), SPH_C32(0x6803bb68), SPH_C32(0x41dc1f41), + SPH_C32(0x99e25299), SPH_C32(0x2dc3b42d), SPH_C32(0x0f2d3c0f), + SPH_C32(0xb03df6b0), SPH_C32(0x54b74b54), SPH_C32(0xbb0cdabb), + SPH_C32(0x16625816) +}; + +#define TIX2(q, x00, x01, x08, x10, x24) do { \ + x10 ^= x00; \ + x00 = (q); \ + x08 ^= x00; \ + x01 ^= x24; \ + } while (0) + +#define TIX3(q, x00, x01, x04, x08, x16, x27, x30) do { \ + x16 ^= x00; \ + x00 = (q); \ + x08 ^= x00; \ + x01 ^= x27; \ + x04 ^= x30; \ + } while (0) + +#define TIX4(q, x00, x01, x04, x07, x08, x22, x24, x27, x30) do { \ + x22 ^= x00; \ + x00 = (q); \ + x08 ^= x00; \ + x01 ^= x24; \ + x04 ^= x27; \ + x07 ^= x30; \ + } while (0) + +#define CMIX30(x00, x01, x02, x04, x05, x06, x15, x16, x17) do { \ + x00 ^= x04; \ + x01 ^= x05; \ + x02 ^= x06; \ + x15 ^= x04; \ + x16 ^= x05; \ + x17 ^= x06; \ + } while (0) + +#define CMIX36(x00, x01, x02, x04, x05, x06, x18, x19, x20) do { \ + x00 ^= x04; \ + x01 ^= x05; \ + x02 ^= x06; \ + x18 ^= x04; \ + x19 ^= x05; \ + x20 ^= x06; \ + } while (0) + +#define SMIX(x0, x1, x2, x3) do { \ + sph_u32 c0 = 0; \ + sph_u32 c1 = 0; \ + sph_u32 c2 = 0; \ + sph_u32 c3 = 0; \ + sph_u32 r0 = 0; \ + sph_u32 r1 = 0; \ + sph_u32 r2 = 0; \ + sph_u32 r3 = 0; \ + sph_u32 tmp; \ + tmp = mixtab0[x0 >> 24]; \ + c0 ^= tmp; \ + tmp = mixtab1[(x0 >> 16) & 0xFF]; \ + c0 ^= tmp; \ + r1 ^= tmp; \ + tmp = mixtab2[(x0 >> 8) & 0xFF]; \ + c0 ^= tmp; \ + r2 ^= tmp; \ + tmp = mixtab3[x0 & 0xFF]; \ + c0 ^= tmp; \ + r3 ^= tmp; \ + tmp = mixtab0[x1 >> 24]; \ + c1 ^= tmp; \ + r0 ^= tmp; \ + tmp = mixtab1[(x1 >> 16) & 0xFF]; \ + c1 ^= tmp; \ + tmp = mixtab2[(x1 >> 8) & 0xFF]; \ + c1 ^= tmp; \ + r2 ^= tmp; \ + tmp = mixtab3[x1 & 0xFF]; \ + c1 ^= tmp; \ + r3 ^= tmp; \ + tmp = mixtab0[x2 >> 24]; \ + c2 ^= tmp; \ + r0 ^= tmp; \ + tmp = mixtab1[(x2 >> 16) & 0xFF]; \ + c2 ^= tmp; \ + r1 ^= tmp; \ + tmp = mixtab2[(x2 >> 8) & 0xFF]; \ + c2 ^= tmp; \ + tmp = mixtab3[x2 & 0xFF]; \ + c2 ^= tmp; \ + r3 ^= tmp; \ + tmp = mixtab0[x3 >> 24]; \ + c3 ^= tmp; \ + r0 ^= tmp; \ + tmp = mixtab1[(x3 >> 16) & 0xFF]; \ + c3 ^= tmp; \ + r1 ^= tmp; \ + tmp = mixtab2[(x3 >> 8) & 0xFF]; \ + c3 ^= tmp; \ + r2 ^= tmp; \ + tmp = mixtab3[x3 & 0xFF]; \ + c3 ^= tmp; \ + x0 = ((c0 ^ r0) & SPH_C32(0xFF000000)) \ + | ((c1 ^ r1) & SPH_C32(0x00FF0000)) \ + | ((c2 ^ r2) & SPH_C32(0x0000FF00)) \ + | ((c3 ^ r3) & SPH_C32(0x000000FF)); \ + x1 = ((c1 ^ (r0 << 8)) & SPH_C32(0xFF000000)) \ + | ((c2 ^ (r1 << 8)) & SPH_C32(0x00FF0000)) \ + | ((c3 ^ (r2 << 8)) & SPH_C32(0x0000FF00)) \ + | ((c0 ^ (r3 >> 24)) & SPH_C32(0x000000FF)); \ + x2 = ((c2 ^ (r0 << 16)) & SPH_C32(0xFF000000)) \ + | ((c3 ^ (r1 << 16)) & SPH_C32(0x00FF0000)) \ + | ((c0 ^ (r2 >> 16)) & SPH_C32(0x0000FF00)) \ + | ((c1 ^ (r3 >> 16)) & SPH_C32(0x000000FF)); \ + x3 = ((c3 ^ (r0 << 24)) & SPH_C32(0xFF000000)) \ + | ((c0 ^ (r1 >> 8)) & SPH_C32(0x00FF0000)) \ + | ((c1 ^ (r2 >> 8)) & SPH_C32(0x0000FF00)) \ + | ((c2 ^ (r3 >> 8)) & SPH_C32(0x000000FF)); \ + /* */ \ + } while (0) + +#if SPH_FUGUE_NOCOPY + +#define DECL_STATE_SMALL +#define READ_STATE_SMALL(state) +#define WRITE_STATE_SMALL(state) +#define DECL_STATE_BIG +#define READ_STATE_BIG(state) +#define WRITE_STATE_BIG(state) + +#define S00 ((sc)->S[ 0]) +#define S01 ((sc)->S[ 1]) +#define S02 ((sc)->S[ 2]) +#define S03 ((sc)->S[ 3]) +#define S04 ((sc)->S[ 4]) +#define S05 ((sc)->S[ 5]) +#define S06 ((sc)->S[ 6]) +#define S07 ((sc)->S[ 7]) +#define S08 ((sc)->S[ 8]) +#define S09 ((sc)->S[ 9]) +#define S10 ((sc)->S[10]) +#define S11 ((sc)->S[11]) +#define S12 ((sc)->S[12]) +#define S13 ((sc)->S[13]) +#define S14 ((sc)->S[14]) +#define S15 ((sc)->S[15]) +#define S16 ((sc)->S[16]) +#define S17 ((sc)->S[17]) +#define S18 ((sc)->S[18]) +#define S19 ((sc)->S[19]) +#define S20 ((sc)->S[20]) +#define S21 ((sc)->S[21]) +#define S22 ((sc)->S[22]) +#define S23 ((sc)->S[23]) +#define S24 ((sc)->S[24]) +#define S25 ((sc)->S[25]) +#define S26 ((sc)->S[26]) +#define S27 ((sc)->S[27]) +#define S28 ((sc)->S[28]) +#define S29 ((sc)->S[29]) +#define S30 ((sc)->S[30]) +#define S31 ((sc)->S[31]) +#define S32 ((sc)->S[32]) +#define S33 ((sc)->S[33]) +#define S34 ((sc)->S[34]) +#define S35 ((sc)->S[35]) + +#else + +#define DECL_STATE_SMALL \ + sph_u32 S00, S01, S02, S03, S04, S05, S06, S07, S08, S09; \ + sph_u32 S10, S11, S12, S13, S14, S15, S16, S17, S18, S19; \ + sph_u32 S20, S21, S22, S23, S24, S25, S26, S27, S28, S29; + +#define DECL_STATE_BIG \ + DECL_STATE_SMALL \ + sph_u32 S30, S31, S32, S33, S34, S35; + +#define READ_STATE_SMALL(state) do { \ + S00 = (state)->S[ 0]; \ + S01 = (state)->S[ 1]; \ + S02 = (state)->S[ 2]; \ + S03 = (state)->S[ 3]; \ + S04 = (state)->S[ 4]; \ + S05 = (state)->S[ 5]; \ + S06 = (state)->S[ 6]; \ + S07 = (state)->S[ 7]; \ + S08 = (state)->S[ 8]; \ + S09 = (state)->S[ 9]; \ + S10 = (state)->S[10]; \ + S11 = (state)->S[11]; \ + S12 = (state)->S[12]; \ + S13 = (state)->S[13]; \ + S14 = (state)->S[14]; \ + S15 = (state)->S[15]; \ + S16 = (state)->S[16]; \ + S17 = (state)->S[17]; \ + S18 = (state)->S[18]; \ + S19 = (state)->S[19]; \ + S20 = (state)->S[20]; \ + S21 = (state)->S[21]; \ + S22 = (state)->S[22]; \ + S23 = (state)->S[23]; \ + S24 = (state)->S[24]; \ + S25 = (state)->S[25]; \ + S26 = (state)->S[26]; \ + S27 = (state)->S[27]; \ + S28 = (state)->S[28]; \ + S29 = (state)->S[29]; \ + } while (0) + +#define READ_STATE_BIG(state) do { \ + READ_STATE_SMALL(state); \ + S30 = (state)->S[30]; \ + S31 = (state)->S[31]; \ + S32 = (state)->S[32]; \ + S33 = (state)->S[33]; \ + S34 = (state)->S[34]; \ + S35 = (state)->S[35]; \ + } while (0) + +#define WRITE_STATE_SMALL(state) do { \ + (state)->S[ 0] = S00; \ + (state)->S[ 1] = S01; \ + (state)->S[ 2] = S02; \ + (state)->S[ 3] = S03; \ + (state)->S[ 4] = S04; \ + (state)->S[ 5] = S05; \ + (state)->S[ 6] = S06; \ + (state)->S[ 7] = S07; \ + (state)->S[ 8] = S08; \ + (state)->S[ 9] = S09; \ + (state)->S[10] = S10; \ + (state)->S[11] = S11; \ + (state)->S[12] = S12; \ + (state)->S[13] = S13; \ + (state)->S[14] = S14; \ + (state)->S[15] = S15; \ + (state)->S[16] = S16; \ + (state)->S[17] = S17; \ + (state)->S[18] = S18; \ + (state)->S[19] = S19; \ + (state)->S[20] = S20; \ + (state)->S[21] = S21; \ + (state)->S[22] = S22; \ + (state)->S[23] = S23; \ + (state)->S[24] = S24; \ + (state)->S[25] = S25; \ + (state)->S[26] = S26; \ + (state)->S[27] = S27; \ + (state)->S[28] = S28; \ + (state)->S[29] = S29; \ + } while (0) + +#define WRITE_STATE_BIG(state) do { \ + WRITE_STATE_SMALL(state); \ + (state)->S[30] = S30; \ + (state)->S[31] = S31; \ + (state)->S[32] = S32; \ + (state)->S[33] = S33; \ + (state)->S[34] = S34; \ + (state)->S[35] = S35; \ + } while (0) + +#endif + +static void +fugue_init(sph_fugue_context *sc, size_t z_len, + const sph_u32 *iv, size_t iv_len) +{ + size_t u; + + for (u = 0; u < z_len; u ++) + sc->S[u] = 0; + memcpy(&sc->S[z_len], iv, iv_len * sizeof *iv); + sc->partial = 0; + sc->partial_len = 0; + sc->round_shift = 0; +#if SPH_64 + sc->bit_count = 0; +#else + sc->bit_count_high = 0; + sc->bit_count_low = 0; +#endif +} + +#if SPH_64 + +#define INCR_COUNTER do { \ + sc->bit_count += (sph_u64)len << 3; \ + } while (0) + +#else + +#define INCR_COUNTER do { \ + sph_u32 tmp = SPH_T32((sph_u32)len << 3); \ + sc->bit_count_low = SPH_T32(sc->bit_count_low + tmp); \ + if (sc->bit_count_low < tmp) \ + sc->bit_count_high ++; \ + sc->bit_count_high = SPH_T32(sc->bit_count_high \ + + ((sph_u32)len >> 29)); \ + } while (0) + +#endif + +#define CORE_ENTRY \ + sph_u32 p; \ + unsigned plen, rshift; \ + INCR_COUNTER; \ + p = sc->partial; \ + plen = sc->partial_len; \ + if (plen < 4) { \ + unsigned count = 4 - plen; \ + if (len < count) \ + count = len; \ + plen += count; \ + while (count -- > 0) { \ + p = (p << 8) | *(const unsigned char *)data; \ + data = (const unsigned char *)data + 1; \ + len --; \ + } \ + if (len == 0) { \ + sc->partial = p; \ + sc->partial_len = plen; \ + return; \ + } \ + } + +#define CORE_EXIT \ + p = 0; \ + sc->partial_len = (unsigned)len; \ + while (len -- > 0) { \ + p = (p << 8) | *(const unsigned char *)data; \ + data = (const unsigned char *)data + 1; \ + } \ + sc->partial = p; \ + sc->round_shift = rshift; + +/* + * Not in a do..while: the 'break' must exit the outer loop. + */ +#define NEXT(rc) \ + if (len <= 4) { \ + rshift = (rc); \ + break; \ + } \ + p = sph_dec32be(data); \ + data = (const unsigned char *)data + 4; \ + len -= 4 + +static void +fugue2_core(sph_fugue_context *sc, const void *data, size_t len) +{ + DECL_STATE_SMALL + CORE_ENTRY + READ_STATE_SMALL(sc); + rshift = sc->round_shift; + switch (rshift) { + for (;;) { + sph_u32 q; + + case 0: + q = p; + TIX2(q, S00, S01, S08, S10, S24); + CMIX30(S27, S28, S29, S01, S02, S03, S12, S13, S14); + SMIX(S27, S28, S29, S00); + CMIX30(S24, S25, S26, S28, S29, S00, S09, S10, S11); + SMIX(S24, S25, S26, S27); + NEXT(1); + /* fall through */ + case 1: + q = p; + TIX2(q, S24, S25, S02, S04, S18); + CMIX30(S21, S22, S23, S25, S26, S27, S06, S07, S08); + SMIX(S21, S22, S23, S24); + CMIX30(S18, S19, S20, S22, S23, S24, S03, S04, S05); + SMIX(S18, S19, S20, S21); + NEXT(2); + /* fall through */ + case 2: + q = p; + TIX2(q, S18, S19, S26, S28, S12); + CMIX30(S15, S16, S17, S19, S20, S21, S00, S01, S02); + SMIX(S15, S16, S17, S18); + CMIX30(S12, S13, S14, S16, S17, S18, S27, S28, S29); + SMIX(S12, S13, S14, S15); + NEXT(3); + /* fall through */ + case 3: + q = p; + TIX2(q, S12, S13, S20, S22, S06); + CMIX30(S09, S10, S11, S13, S14, S15, S24, S25, S26); + SMIX(S09, S10, S11, S12); + CMIX30(S06, S07, S08, S10, S11, S12, S21, S22, S23); + SMIX(S06, S07, S08, S09); + NEXT(4); + /* fall through */ + case 4: + q = p; + TIX2(q, S06, S07, S14, S16, S00); + CMIX30(S03, S04, S05, S07, S08, S09, S18, S19, S20); + SMIX(S03, S04, S05, S06); + CMIX30(S00, S01, S02, S04, S05, S06, S15, S16, S17); + SMIX(S00, S01, S02, S03); + NEXT(0); + } + } + CORE_EXIT + WRITE_STATE_SMALL(sc); +} + +static void +fugue3_core(sph_fugue_context *sc, const void *data, size_t len) +{ + DECL_STATE_BIG + CORE_ENTRY + READ_STATE_BIG(sc); + rshift = sc->round_shift; + switch (rshift) { + for (;;) { + sph_u32 q; + + case 0: + q = p; + TIX3(q, S00, S01, S04, S08, S16, S27, S30); + CMIX36(S33, S34, S35, S01, S02, S03, S15, S16, S17); + SMIX(S33, S34, S35, S00); + CMIX36(S30, S31, S32, S34, S35, S00, S12, S13, S14); + SMIX(S30, S31, S32, S33); + CMIX36(S27, S28, S29, S31, S32, S33, S09, S10, S11); + SMIX(S27, S28, S29, S30); + NEXT(1); + /* fall through */ + case 1: + q = p; + TIX3(q, S27, S28, S31, S35, S07, S18, S21); + CMIX36(S24, S25, S26, S28, S29, S30, S06, S07, S08); + SMIX(S24, S25, S26, S27); + CMIX36(S21, S22, S23, S25, S26, S27, S03, S04, S05); + SMIX(S21, S22, S23, S24); + CMIX36(S18, S19, S20, S22, S23, S24, S00, S01, S02); + SMIX(S18, S19, S20, S21); + NEXT(2); + /* fall through */ + case 2: + q = p; + TIX3(q, S18, S19, S22, S26, S34, S09, S12); + CMIX36(S15, S16, S17, S19, S20, S21, S33, S34, S35); + SMIX(S15, S16, S17, S18); + CMIX36(S12, S13, S14, S16, S17, S18, S30, S31, S32); + SMIX(S12, S13, S14, S15); + CMIX36(S09, S10, S11, S13, S14, S15, S27, S28, S29); + SMIX(S09, S10, S11, S12); + NEXT(3); + /* fall through */ + case 3: + q = p; + TIX3(q, S09, S10, S13, S17, S25, S00, S03); + CMIX36(S06, S07, S08, S10, S11, S12, S24, S25, S26); + SMIX(S06, S07, S08, S09); + CMIX36(S03, S04, S05, S07, S08, S09, S21, S22, S23); + SMIX(S03, S04, S05, S06); + CMIX36(S00, S01, S02, S04, S05, S06, S18, S19, S20); + SMIX(S00, S01, S02, S03); + NEXT(0); + } + } + CORE_EXIT + WRITE_STATE_BIG(sc); +} + +static void +fugue4_core(sph_fugue_context *sc, const void *data, size_t len) +{ + DECL_STATE_BIG + CORE_ENTRY + READ_STATE_BIG(sc); + rshift = sc->round_shift; + switch (rshift) { + for (;;) { + sph_u32 q; + + case 0: + q = p; + TIX4(q, S00, S01, S04, S07, S08, S22, S24, S27, S30); + CMIX36(S33, S34, S35, S01, S02, S03, S15, S16, S17); + SMIX(S33, S34, S35, S00); + CMIX36(S30, S31, S32, S34, S35, S00, S12, S13, S14); + SMIX(S30, S31, S32, S33); + CMIX36(S27, S28, S29, S31, S32, S33, S09, S10, S11); + SMIX(S27, S28, S29, S30); + CMIX36(S24, S25, S26, S28, S29, S30, S06, S07, S08); + SMIX(S24, S25, S26, S27); + NEXT(1); + /* fall through */ + case 1: + q = p; + TIX4(q, S24, S25, S28, S31, S32, S10, S12, S15, S18); + CMIX36(S21, S22, S23, S25, S26, S27, S03, S04, S05); + SMIX(S21, S22, S23, S24); + CMIX36(S18, S19, S20, S22, S23, S24, S00, S01, S02); + SMIX(S18, S19, S20, S21); + CMIX36(S15, S16, S17, S19, S20, S21, S33, S34, S35); + SMIX(S15, S16, S17, S18); + CMIX36(S12, S13, S14, S16, S17, S18, S30, S31, S32); + SMIX(S12, S13, S14, S15); + NEXT(2); + /* fall through */ + case 2: + q = p; + TIX4(q, S12, S13, S16, S19, S20, S34, S00, S03, S06); + CMIX36(S09, S10, S11, S13, S14, S15, S27, S28, S29); + SMIX(S09, S10, S11, S12); + CMIX36(S06, S07, S08, S10, S11, S12, S24, S25, S26); + SMIX(S06, S07, S08, S09); + CMIX36(S03, S04, S05, S07, S08, S09, S21, S22, S23); + SMIX(S03, S04, S05, S06); + CMIX36(S00, S01, S02, S04, S05, S06, S18, S19, S20); + SMIX(S00, S01, S02, S03); + NEXT(0); + } + } + CORE_EXIT + WRITE_STATE_BIG(sc); +} + +#if SPH_64 + +#define WRITE_COUNTER do { \ + sph_enc64be(buf + 4, sc->bit_count + n); \ + } while (0) + +#else + +#define WRITE_COUNTER do { \ + sph_enc32be(buf + 4, sc->bit_count_high); \ + sph_enc32be(buf + 8, sc->bit_count_low + n); \ + } while (0) + +#endif + +#define CLOSE_ENTRY(s, rcm, core) \ + unsigned char buf[16]; \ + unsigned plen, rms; \ + unsigned char *out; \ + sph_u32 S[s]; \ + plen = sc->partial_len; \ + WRITE_COUNTER; \ + if (plen == 0 && n == 0) { \ + plen = 4; \ + } else if (plen < 4 || n != 0) { \ + unsigned u; \ + \ + if (plen == 4) \ + plen = 0; \ + buf[plen] = ub & ~(0xFFU >> n); \ + for (u = plen + 1; u < 4; u ++) \ + buf[u] = 0; \ + } \ + core(sc, buf + plen, (sizeof buf) - plen); \ + rms = sc->round_shift * (rcm); \ + memcpy(S, sc->S + (s) - rms, rms * sizeof(sph_u32)); \ + memcpy(S + rms, sc->S, ((s) - rms) * sizeof(sph_u32)); + +#define ROR(n, s) do { \ + sph_u32 tmp[n]; \ + memcpy(tmp, S + ((s) - (n)), (n) * sizeof(sph_u32)); \ + memmove(S + (n), S, ((s) - (n)) * sizeof(sph_u32)); \ + memcpy(S, tmp, (n) * sizeof(sph_u32)); \ + } while (0) + +static void +fugue2_close(sph_fugue_context *sc, unsigned ub, unsigned n, + void *dst, size_t out_size_w32) +{ + int i; + + CLOSE_ENTRY(30, 6, fugue2_core) + for (i = 0; i < 10; i ++) { + ROR(3, 30); + CMIX30(S[0], S[1], S[2], S[4], S[5], S[6], S[15], S[16], S[17]); + SMIX(S[0], S[1], S[2], S[3]); + } + for (i = 0; i < 13; i ++) { + S[4] ^= S[0]; + S[15] ^= S[0]; + ROR(15, 30); + SMIX(S[0], S[1], S[2], S[3]); + S[4] ^= S[0]; + S[16] ^= S[0]; + ROR(14, 30); + SMIX(S[0], S[1], S[2], S[3]); + } + S[4] ^= S[0]; + S[15] ^= S[0]; + out = dst; + sph_enc32be(out + 0, S[ 1]); + sph_enc32be(out + 4, S[ 2]); + sph_enc32be(out + 8, S[ 3]); + sph_enc32be(out + 12, S[ 4]); + sph_enc32be(out + 16, S[15]); + sph_enc32be(out + 20, S[16]); + sph_enc32be(out + 24, S[17]); + if (out_size_w32 == 8) { + sph_enc32be(out + 28, S[18]); + sph_fugue256_init(sc); + } else { + sph_fugue224_init(sc); + } +} + +static void +fugue3_close(sph_fugue_context *sc, unsigned ub, unsigned n, void *dst) +{ + int i; + + CLOSE_ENTRY(36, 9, fugue3_core) + for (i = 0; i < 18; i ++) { + ROR(3, 36); + CMIX36(S[0], S[1], S[2], S[4], S[5], S[6], S[18], S[19], S[20]); + SMIX(S[0], S[1], S[2], S[3]); + } + for (i = 0; i < 13; i ++) { + S[4] ^= S[0]; + S[12] ^= S[0]; + S[24] ^= S[0]; + ROR(12, 36); + SMIX(S[0], S[1], S[2], S[3]); + S[4] ^= S[0]; + S[13] ^= S[0]; + S[24] ^= S[0]; + ROR(12, 36); + SMIX(S[0], S[1], S[2], S[3]); + S[4] ^= S[0]; + S[13] ^= S[0]; + S[25] ^= S[0]; + ROR(11, 36); + SMIX(S[0], S[1], S[2], S[3]); + } + S[4] ^= S[0]; + S[12] ^= S[0]; + S[24] ^= S[0]; + out = dst; + sph_enc32be(out + 0, S[ 1]); + sph_enc32be(out + 4, S[ 2]); + sph_enc32be(out + 8, S[ 3]); + sph_enc32be(out + 12, S[ 4]); + sph_enc32be(out + 16, S[12]); + sph_enc32be(out + 20, S[13]); + sph_enc32be(out + 24, S[14]); + sph_enc32be(out + 28, S[15]); + sph_enc32be(out + 32, S[24]); + sph_enc32be(out + 36, S[25]); + sph_enc32be(out + 40, S[26]); + sph_enc32be(out + 44, S[27]); + sph_fugue384_init(sc); +} + +static void +fugue4_close(sph_fugue_context *sc, unsigned ub, unsigned n, void *dst) +{ + int i; + + CLOSE_ENTRY(36, 12, fugue4_core) + for (i = 0; i < 32; i ++) { + ROR(3, 36); + CMIX36(S[0], S[1], S[2], S[4], S[5], S[6], S[18], S[19], S[20]); + SMIX(S[0], S[1], S[2], S[3]); + } + for (i = 0; i < 13; i ++) { + S[4] ^= S[0]; + S[9] ^= S[0]; + S[18] ^= S[0]; + S[27] ^= S[0]; + ROR(9, 36); + SMIX(S[0], S[1], S[2], S[3]); + S[4] ^= S[0]; + S[10] ^= S[0]; + S[18] ^= S[0]; + S[27] ^= S[0]; + ROR(9, 36); + SMIX(S[0], S[1], S[2], S[3]); + S[4] ^= S[0]; + S[10] ^= S[0]; + S[19] ^= S[0]; + S[27] ^= S[0]; + ROR(9, 36); + SMIX(S[0], S[1], S[2], S[3]); + S[4] ^= S[0]; + S[10] ^= S[0]; + S[19] ^= S[0]; + S[28] ^= S[0]; + ROR(8, 36); + SMIX(S[0], S[1], S[2], S[3]); + } + S[4] ^= S[0]; + S[9] ^= S[0]; + S[18] ^= S[0]; + S[27] ^= S[0]; + out = dst; + sph_enc32be(out + 0, S[ 1]); + sph_enc32be(out + 4, S[ 2]); + sph_enc32be(out + 8, S[ 3]); + sph_enc32be(out + 12, S[ 4]); + sph_enc32be(out + 16, S[ 9]); + sph_enc32be(out + 20, S[10]); + sph_enc32be(out + 24, S[11]); + sph_enc32be(out + 28, S[12]); + sph_enc32be(out + 32, S[18]); + sph_enc32be(out + 36, S[19]); + sph_enc32be(out + 40, S[20]); + sph_enc32be(out + 44, S[21]); + sph_enc32be(out + 48, S[27]); + sph_enc32be(out + 52, S[28]); + sph_enc32be(out + 56, S[29]); + sph_enc32be(out + 60, S[30]); + sph_fugue512_init(sc); +} + +void +sph_fugue224_init(void *cc) +{ + fugue_init(cc, 23, IV224, 7); +} + +void +sph_fugue224(void *cc, const void *data, size_t len) +{ + fugue2_core(cc, data, len); +} + +void +sph_fugue224_close(void *cc, void *dst) +{ + fugue2_close(cc, 0, 0, dst, 7); +} + +void +sph_fugue224_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + fugue2_close(cc, ub, n, dst, 7); +} + +void +sph_fugue256_init(void *cc) +{ + fugue_init(cc, 22, IV256, 8); +} + +void +sph_fugue256(void *cc, const void *data, size_t len) +{ + fugue2_core(cc, data, len); +} + +void +sph_fugue256_close(void *cc, void *dst) +{ + fugue2_close(cc, 0, 0, dst, 8); +} + +void +sph_fugue256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + fugue2_close(cc, ub, n, dst, 8); +} + +void +sph_fugue384_init(void *cc) +{ + fugue_init(cc, 24, IV384, 12); +} + +void +sph_fugue384(void *cc, const void *data, size_t len) +{ + fugue3_core(cc, data, len); +} + +void +sph_fugue384_close(void *cc, void *dst) +{ + fugue3_close(cc, 0, 0, dst); +} + +void +sph_fugue384_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + fugue3_close(cc, ub, n, dst); +} + +void +sph_fugue512_init(void *cc) +{ + fugue_init(cc, 20, IV512, 16); +} + +void +sph_fugue512(void *cc, const void *data, size_t len) +{ + fugue4_core(cc, data, len); +} + +void +sph_fugue512_close(void *cc, void *dst) +{ + fugue4_close(cc, 0, 0, dst); +} + +void +sph_fugue512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + fugue4_close(cc, ub, n, dst); +} +#ifdef __cplusplus +} +#endif diff --git a/src/obj/skunkhash/fugue.o b/src/obj/skunkhash/fugue.o new file mode 100644 index 0000000..4b60692 Binary files /dev/null and b/src/obj/skunkhash/fugue.o differ diff --git a/src/obj/skunkhash/gost.c b/src/obj/skunkhash/gost.c new file mode 100644 index 0000000..134ebbd --- /dev/null +++ b/src/obj/skunkhash/gost.c @@ -0,0 +1,1101 @@ +/* $Id: gost.c 259 2011-07-19 22:11:27Z tp $ */ +/* + * Keccak implementation. + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @author Thomas Pornin + */ + +//#include +//#include + +#include +#include +#include +#include + +#include "sph_gost.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifdef _MSC_VER +#pragma warning (disable: 4146) +#endif + +//-------------------------------------------------------------------------------------------- +// +// stribog implementation +// +//-------------------------------------------------------------------------------------------- + + +// Tables for function F +const unsigned long long T[8][256] = { + { + 0xE6F87E5C5B711FD0,0x258377800924FA16,0xC849E07E852EA4A8,0x5B4686A18F06C16A, + 0x0B32E9A2D77B416E,0xABDA37A467815C66,0xF61796A81A686676,0xF5DC0B706391954B, + 0x4862F38DB7E64BF1,0xFF5C629A68BD85C5,0xCB827DA6FCD75795,0x66D36DAF69B9F089, + 0x356C9F74483D83B0,0x7CBCECB1238C99A1,0x36A702AC31C4708D,0x9EB6A8D02FBCDFD6, + 0x8B19FA51E5B3AE37,0x9CCFB5408A127D0B,0xBC0C78B508208F5A,0xE533E3842288ECED, + 0xCEC2C7D377C15FD2,0xEC7817B6505D0F5E,0xB94CC2C08336871D,0x8C205DB4CB0B04AD, + 0x763C855B28A0892F,0x588D1B79F6FF3257,0x3FECF69E4311933E,0x0FC0D39F803A18C9, + 0xEE010A26F5F3AD83,0x10EFE8F4411979A6,0x5DCDA10C7DE93A10,0x4A1BEE1D1248E92C, + 0x53BFF2DB21847339,0xB4F50CCFA6A23D09,0x5FB4BC9CD84798CD,0xE88A2D8B071C56F9, + 0x7F7771695A756A9C,0xC5F02E71A0BA1EBC,0xA663F9AB4215E672,0x2EB19E22DE5FBB78, + 0x0DB9CE0F2594BA14,0x82520E6397664D84,0x2F031E6A0208EA98,0x5C7F2144A1BE6BF0, + 0x7A37CB1CD16362DB,0x83E08E2B4B311C64,0xCF70479BAB960E32,0x856BA986B9DEE71E, + 0xB5478C877AF56CE9,0xB8FE42885F61D6FD,0x1BDD0156966238C8,0x622157923EF8A92E, + 0xFC97FF42114476F8,0x9D7D350856452CEB,0x4C90C9B0E0A71256,0x2308502DFBCB016C, + 0x2D7A03FAA7A64845,0xF46E8B38BFC6C4AB,0xBDBEF8FDD477DEBA,0x3AAC4CEBC8079B79, + 0xF09CB105E8879D0C,0x27FA6A10AC8A58CB,0x8960E7C1401D0CEA,0x1A6F811E4A356928, + 0x90C4FB0773D196FF,0x43501A2F609D0A9F,0xF7A516E0C63F3796,0x1CE4A6B3B8DA9252, + 0x1324752C38E08A9B,0xA5A864733BEC154F,0x2BF124575549B33F,0xD766DB15440DC5C7, + 0xA7D179E39E42B792,0xDADF151A61997FD3,0x86A0345EC0271423,0x38D5517B6DA939A4, + 0x6518F077104003B4,0x02791D90A5AEA2DD,0x88D267899C4A5D0A,0x930F66DF0A2865C2, + 0x4EE9D4204509B08B,0x325538916685292A,0x412907BFC533A842,0xB27E2B62544DC673, + 0x6C5304456295E007,0x5AF406E95351908A,0x1F2F3B6BC123616F,0xC37B09DC5255E5C6, + 0x3967D133B1FE6844,0x298839C7F0E711E2,0x409B87F71964F9A2,0xE938ADC3DB4B0719, + 0x0C0B4E47F9C3EBF4,0x5534D576D36B8843,0x4610A05AEB8B02D8,0x20C3CDF58232F251, + 0x6DE1840DBEC2B1E7,0xA0E8DE06B0FA1D08,0x7B854B540D34333B,0x42E29A67BCCA5B7F, + 0xD8A6088AC437DD0E,0xC63BB3A9D943ED81,0x21714DBD5E65A3B1,0x6761EDE7B5EEA169, + 0x2431F7C8D573ABF6,0xD51FC685E1A3671A,0x5E063CD40410C92D,0x283AB98F2CB04002, + 0x8FEBC06CB2F2F790,0x17D64F116FA1D33C,0xE07359F1A99EE4AA,0x784ED68C74CDC006, + 0x6E2A19D5C73B42DA,0x8712B4161C7045C3,0x371582E4ED93216D,0xACE390414939F6FC, + 0x7EC5F12186223B7C,0xC0B094042BAC16FB,0xF9D745379A527EBF,0x737C3F2EA3B68168, + 0x33E7B8D9BAD278CA,0xA9A32A34C22FFEBB,0xE48163CCFEDFBD0D,0x8E5940246EA5A670, + 0x51C6EF4B842AD1E4,0x22BAD065279C508C,0xD91488C218608CEE,0x319EA5491F7CDA17, + 0xD394E128134C9C60,0x094BF43272D5E3B3,0x9BF612A5A4AAD791,0xCCBBDA43D26FFD0F, + 0x34DE1F3C946AD250,0x4F5B5468995EE16B,0xDF9FAF6FEA8F7794,0x2648EA5870DD092B, + 0xBFC7E56D71D97C67,0xDDE6B2FF4F21D549,0x3C276B463AE86003,0x91767B4FAF86C71F, + 0x68A13E7835D4B9A0,0xB68C115F030C9FD4,0x141DD2C916582001,0x983D8F7DDD5324AC, + 0x64AA703FCC175254,0xC2C989948E02B426,0x3E5E76D69F46C2DE,0x50746F03587D8004, + 0x45DB3D829272F1E5,0x60584A029B560BF3,0xFBAE58A73FFCDC62,0xA15A5E4E6CAD4CE8, + 0x4BA96E55CE1FB8CC,0x08F9747AAE82B253,0xC102144CF7FB471B,0x9F042898F3EB8E36, + 0x068B27ADF2EFFB7A,0xEDCA97FE8C0A5EBE,0x778E0513F4F7D8CF,0x302C2501C32B8BF7, + 0x8D92DDFC175C554D,0xF865C57F46052F5F,0xEAF3301BA2B2F424,0xAA68B7ECBBD60D86, + 0x998F0F350104754C,0x0000000000000000,0xF12E314D34D0CCEC,0x710522BE061823B5, + 0xAF280D9930C005C1,0x97FD5CE25D693C65,0x19A41CC633CC9A15,0x95844172F8C79EB8, + 0xDC5432B7937684A9,0x9436C13A2490CF58,0x802B13F332C8EF59,0xC442AE397CED4F5C, + 0xFA1CD8EFE3AB8D82,0xF2E5AC954D293FD1,0x6AD823E8907A1B7D,0x4D2249F83CF043B6, + 0x03CB9DD879F9F33D,0xDE2D2F2736D82674,0x2A43A41F891EE2DF,0x6F98999D1B6C133A, + 0xD4AD46CD3DF436FA,0xBB35DF50269825C0,0x964FDCAA813E6D85,0xEB41B0537EE5A5C4, + 0x0540BA758B160847,0xA41AE43BE7BB44AF,0xE3B8C429D0671797,0x819993BBEE9FBEB9, + 0xAE9A8DD1EC975421,0xF3572CDD917E6E31,0x6393D7DAE2AFF8CE,0x47A2201237DC5338, + 0xA32343DEC903EE35,0x79FC56C4A89A91E6,0x01B28048DC5751E0,0x1296F564E4B7DB7B, + 0x75F7188351597A12,0xDB6D9552BDCE2E33,0x1E9DBB231D74308F,0x520D7293FDD322D9, + 0xE20A44610C304677,0xFEEEE2D2B4EAD425,0xCA30FDEE20800675,0x61EACA4A47015A13, + 0xE74AFE1487264E30,0x2CC883B27BF119A5,0x1664CF59B3F682DC,0xA811AA7C1E78AF5B, + 0x1D5626FB648DC3B2,0xB73E9117DF5BCE34,0xD05F7CF06AB56F5D,0xFD257F0ACD132718, + 0x574DC8E676C52A9E,0x0739A7E52EB8AA9A,0x5486553E0F3CD9A3,0x56FF48AEAA927B7E, + 0xBE756525AD8E2D87,0x7D0E6CF9FFDBC841,0x3B1ECCA31450CA99,0x6913BE30E983E840, + 0xAD511009956EA71C,0xB1B5B6BA2DB4354E,0x4469BDCA4E25A005,0x15AF5281CA0F71E1, + 0x744598CB8D0E2BF2,0x593F9B312AA863B7,0xEFB38A6E29A4FC63,0x6B6AA3A04C2D4A9D, + 0x3D95EB0EE6BF31E3,0xA291C3961554BFD5,0x18169C8EEF9BCBF5,0x115D68BC9D4E2846, + 0xBA875F18FACF7420,0xD1EDFCB8B6E23EBD,0xB00736F2F1E364AE,0x84D929CE6589B6FE, + 0x70B7A2F6DA4F7255,0x0E7253D75C6D4929,0x04F23A3D574159A7,0x0A8069EA0B2C108E, + 0x49D073C56BB11A11,0x8AAB7A1939E4FFD7,0xCD095A0B0E38ACEF,0xC9FB60365979F548, + 0x92BDE697D67F3422,0xC78933E10514BC61,0xE1C1D9B975C9B54A,0xD2266160CF1BCD80, + 0x9A4492ED78FD8671,0xB3CCAB2A881A9793,0x72CEBF667FE1D088,0xD6D45B5D985A9427 + }, + { + 0xC811A8058C3F55DE,0x65F5B43196B50619,0xF74F96B1D6706E43,0x859D1E8BCB43D336, + 0x5AAB8A85CCFA3D84,0xF9C7BF99C295FCFD,0xA21FD5A1DE4B630F,0xCDB3EF763B8B456D, + 0x803F59F87CF7C385,0xB27C73BE5F31913C,0x98E3AC6633B04821,0xBF61674C26B8F818, + 0x0FFBC995C4C130C8,0xAAA0862010761A98,0x6057F342210116AA,0xF63C760C0654CC35, + 0x2DDB45CC667D9042,0xBCF45A964BD40382,0x68E8A0C3EF3C6F3D,0xA7BD92D269FF73BC, + 0x290AE20201ED2287,0xB7DE34CDE885818F,0xD901EEA7DD61059B,0xD6FA273219A03553, + 0xD56F1AE874CCCEC9,0xEA31245C2E83F554,0x7034555DA07BE499,0xCE26D2AC56E7BEF7, + 0xFD161857A5054E38,0x6A0E7DA4527436D1,0x5BD86A381CDE9FF2,0xCAF7756231770C32, + 0xB09AAED9E279C8D0,0x5DEF1091C60674DB,0x111046A2515E5045,0x23536CE4729802FC, + 0xC50CBCF7F5B63CFA,0x73A16887CD171F03,0x7D2941AFD9F28DBD,0x3F5E3EB45A4F3B9D, + 0x84EEFE361B677140,0x3DB8E3D3E7076271,0x1A3A28F9F20FD248,0x7EBC7C75B49E7627, + 0x74E5F293C7EB565C,0x18DCF59E4F478BA4,0x0C6EF44FA9ADCB52,0xC699812D98DAC760, + 0x788B06DC6E469D0E,0xFC65F8EA7521EC4E,0x30A5F7219E8E0B55,0x2BEC3F65BCA57B6B, + 0xDDD04969BAF1B75E,0x99904CDBE394EA57,0x14B201D1E6EA40F6,0xBBB0C08241284ADD, + 0x50F20463BF8F1DFF,0xE8D7F93B93CBACB8,0x4D8CB68E477C86E8,0xC1DD1B3992268E3F, + 0x7C5AA11209D62FCB,0x2F3D98ABDB35C9AE,0x671369562BFD5FF5,0x15C1E16C36CEE280, + 0x1D7EB2EDF8F39B17,0xDA94D37DB00DFE01,0x877BC3EC760B8ADA,0xCB8495DFE153AE44, + 0x05A24773B7B410B3,0x12857B783C32ABDF,0x8EB770D06812513B,0x536739B9D2E3E665, + 0x584D57E271B26468,0xD789C78FC9849725,0xA935BBFA7D1AE102,0x8B1537A3DFA64188, + 0xD0CD5D9BC378DE7A,0x4AC82C9A4D80CFB7,0x42777F1B83BDB620,0x72D2883A1D33BD75, + 0x5E7A2D4BAB6A8F41,0xF4DAAB6BBB1C95D9,0x905CFFE7FD8D31B6,0x83AA6422119B381F, + 0xC0AEFB8442022C49,0xA0F908C663033AE3,0xA428AF0804938826,0xADE41C341A8A53C7, + 0xAE7121EE77E6A85D,0xC47F5C4A25929E8C,0xB538E9AA55CDD863,0x06377AA9DAD8EB29, + 0xA18AE87BB3279895,0x6EDFDA6A35E48414,0x6B7D9D19825094A7,0xD41CFA55A4E86CBF, + 0xE5CAEDC9EA42C59C,0xA36C351C0E6FC179,0x5181E4DE6FABBF89,0xFFF0C530184D17D4, + 0x9D41EB1584045892,0x1C0D525028D73961,0xF178EC180CA8856A,0x9A0571018EF811CD, + 0x4091A27C3EF5EFCC,0x19AF15239F6329D2,0x347450EFF91EB990,0xE11B4A078DD27759, + 0xB9561DE5FC601331,0x912F1F5A2DA993C0,0x1654DCB65BA2191A,0x3E2DDE098A6B99EB, + 0x8A66D71E0F82E3FE,0x8C51ADB7D55A08D7,0x4533E50F8941FF7F,0x02E6DD67BD4859EC, + 0xE068AABA5DF6D52F,0xC24826E3FF4A75A5,0x6C39070D88ACDDF8,0x6486548C4691A46F, + 0xD1BEBD26135C7C0C,0xB30F93038F15334A,0x82D9849FC1BF9A69,0x9C320BA85420FAE4, + 0xFA528243AFF90767,0x9ED4D6CFE968A308,0xB825FD582C44B147,0x9B7691BC5EDCB3BB, + 0xC7EA619048FE6516,0x1063A61F817AF233,0x47D538683409A693,0x63C2CE984C6DED30, + 0x2A9FDFD86C81D91D,0x7B1E3B06032A6694,0x666089EBFBD9FD83,0x0A598EE67375207B, + 0x07449A140AFC495F,0x2CA8A571B6593234,0x1F986F8A45BBC2FB,0x381AA4A050B372C2, + 0x5423A3ADD81FAF3A,0x17273C0B8B86BB6C,0xFE83258DC869B5A2,0x287902BFD1C980F1, + 0xF5A94BD66B3837AF,0x88800A79B2CABA12,0x55504310083B0D4C,0xDF36940E07B9EEB2, + 0x04D1A7CE6790B2C5,0x612413FFF125B4DC,0x26F12B97C52C124F,0x86082351A62F28AC, + 0xEF93632F9937E5E7,0x3507B052293A1BE6,0xE72C30AE570A9C70,0xD3586041AE1425E0, + 0xDE4574B3D79D4CC4,0x92BA228040C5685A,0xF00B0CA5DC8C271C,0xBE1287F1F69C5A6E, + 0xF39E317FB1E0DC86,0x495D114020EC342D,0x699B407E3F18CD4B,0xDCA3A9D46AD51528, + 0x0D1D14F279896924,0x0000000000000000,0x593EB75FA196C61E,0x2E4E78160B116BD8, + 0x6D4AE7B058887F8E,0xE65FD013872E3E06,0x7A6DDBBBD30EC4E2,0xAC97FC89CAAEF1B1, + 0x09CCB33C1E19DBE1,0x89F3EAC462EE1864,0x7770CF49AA87ADC6,0x56C57ECA6557F6D6, + 0x03953DDA6D6CFB9A,0x36928D884456E07C,0x1EEB8F37959F608D,0x31D6179C4EAAA923, + 0x6FAC3AD7E5C02662,0x43049FA653991456,0xABD3669DC052B8EE,0xAF02C153A7C20A2B, + 0x3CCB036E3723C007,0x93C9C23D90E1CA2C,0xC33BC65E2F6ED7D3,0x4CFF56339758249E, + 0xB1E94E64325D6AA6,0x37E16D359472420A,0x79F8E661BE623F78,0x5214D90402C74413, + 0x482EF1FDF0C8965B,0x13F69BC5EC1609A9,0x0E88292814E592BE,0x4E198B542A107D72, + 0xCCC00FCBEBAFE71B,0x1B49C844222B703E,0x2564164DA840E9D5,0x20C6513E1FF4F966, + 0xBAC3203F910CE8AB,0xF2EDD1C261C47EF0,0x814CB945ACD361F3,0x95FEB8944A392105, + 0x5C9CF02C1622D6AD,0x971865F3F77178E9,0xBD87BA2B9BF0A1F4,0x444005B259655D09, + 0xED75BE48247FBC0B,0x7596122E17CFF42A,0xB44B091785E97A15,0x966B854E2755DA9F, + 0xEEE0839249134791,0x32432A4623C652B9,0xA8465B47AD3E4374,0xF8B45F2412B15E8B, + 0x2417F6F078644BA3,0xFB2162FE7FDDA511,0x4BBBCC279DA46DC1,0x0173E0BDD024A276, + 0x22208C59A2BCA08A,0x8FC4906DB836F34D,0xE4B90D743A6667EA,0x7147B5E0705F46EF, + 0x2782CB2A1508B039,0xEC065EF5F45B1E7D,0x21B5B183CFD05B10,0xDBE733C060295C77, + 0x9FA73672394C017E,0xCF55321186C31C81,0xD8720E1A0D45A7ED,0x3B8F997A3DDF8958, + 0x3AFC79C7EDFB2B2E,0xE9A4198643EF0ECE,0x5F09CDF67B4E2D37,0x4F6A6BE9FA34DF04, + 0xB6ADD47038A123F9,0x8D224D0A057EAAA1,0xC96248B85C1BF7A8,0xE3FD9760309A2EB5, + 0x0B2A6E5BA351820D,0xEB42C4E1FEA75722,0x948D58299A1D8373,0x7FCF9CC864BAD451, + 0xA55B4FB5D4B72A50,0x08BF5381CE3D7997,0x46A6D8D5E42D04E5,0xD22B80FC7E308796, + 0x57B69E77B57354A0,0x3969441D8097D0B4,0x3330CAFBF3E2F0CF,0xE28E77DDE0BE8CC3, + 0x62B12E259C494F46,0xA6CE726FB9DBD1CA,0x41E242C1EED14DBA,0x76032FF47AA30FB0 + }, + { + 0x45B268A93ACDE4CC,0xAF7F0BE884549D08,0x048354B3C1468263,0x925435C2C80EFED2, + 0xEE4E37F27FDFFBA7,0x167A33920C60F14D,0xFB123B52EA03E584,0x4A0CAB53FDBB9007, + 0x9DEAF6380F788A19,0xCB48EC558F0CB32A,0xB59DC4B2D6FEF7E0,0xDCDBCA22F4F3ECB6, + 0x11DF5813549A9C40,0xE33FDEDF568ACED3,0xA0C1C8124322E9C3,0x07A56B8158FA6D0D, + 0x77279579B1E1F3DD,0xD9B18B74422AC004,0xB8EC2D9FFFABC294,0xF4ACF8A82D75914F, + 0x7BBF69B1EF2B6878,0xC4F62FAF487AC7E1,0x76CE809CC67E5D0C,0x6711D88F92E4C14C, + 0x627B99D9243DEDFE,0x234AA5C3DFB68B51,0x909B1F15262DBF6D,0x4F66EA054B62BCB5, + 0x1AE2CF5A52AA6AE8,0xBEA053FBD0CE0148,0xED6808C0E66314C9,0x43FE16CD15A82710, + 0xCD049231A06970F6,0xE7BC8A6C97CC4CB0,0x337CE835FCB3B9C0,0x65DEF2587CC780F3, + 0x52214EDE4132BB50,0x95F15E4390F493DF,0x870839625DD2E0F1,0x41313C1AFB8B66AF, + 0x91720AF051B211BC,0x477D427ED4EEA573,0x2E3B4CEEF6E3BE25,0x82627834EB0BCC43, + 0x9C03E3DD78E724C8,0x2877328AD9867DF9,0x14B51945E243B0F2,0x574B0F88F7EB97E2, + 0x88B6FA989AA4943A,0x19C4F068CB168586,0x50EE6409AF11FAEF,0x7DF317D5C04EABA4, + 0x7A567C5498B4C6A9,0xB6BBFB804F42188E,0x3CC22BCF3BC5CD0B,0xD04336EAAA397713, + 0xF02FAC1BEC33132C,0x2506DBA7F0D3488D,0xD7E65D6BF2C31A1E,0x5EB9B2161FF820F5, + 0x842E0650C46E0F9F,0x716BEB1D9E843001,0xA933758CAB315ED4,0x3FE414FDA2792265, + 0x27C9F1701EF00932,0x73A4C1CA70A771BE,0x94184BA6E76B3D0E,0x40D829FF8C14C87E, + 0x0FBEC3FAC77674CB,0x3616A9634A6A9572,0x8F139119C25EF937,0xF545ED4D5AEA3F9E, + 0xE802499650BA387B,0x6437E7BD0B582E22,0xE6559F89E053E261,0x80AD52E305288DFC, + 0x6DC55A23E34B9935,0xDE14E0F51AD0AD09,0xC6390578A659865E,0x96D7617109487CB1, + 0xE2D6CB3A21156002,0x01E915E5779FAED1,0xADB0213F6A77DCB7,0x9880B76EB9A1A6AB, + 0x5D9F8D248644CF9B,0xFD5E4536C5662658,0xF1C6B9FE9BACBDFD,0xEACD6341BE9979C4, + 0xEFA7221708405576,0x510771ECD88E543E,0xC2BA51CB671F043D,0x0AD482AC71AF5879, + 0xFE787A045CDAC936,0xB238AF338E049AED,0xBD866CC94972EE26,0x615DA6EBBD810290, + 0x3295FDD08B2C1711,0xF834046073BF0AEA,0xF3099329758FFC42,0x1CAEB13E7DCFA934, + 0xBA2307481188832B,0x24EFCE42874CE65C,0x0E57D61FB0E9DA1A,0xB3D1BAD6F99B343C, + 0xC0757B1C893C4582,0x2B510DB8403A9297,0x5C7698C1F1DB614A,0x3E0D0118D5E68CB4, + 0xD60F488E855CB4CF,0xAE961E0DF3CB33D9,0x3A8E55AB14A00ED7,0x42170328623789C1, + 0x838B6DD19C946292,0x895FEF7DED3B3AEB,0xCFCBB8E64E4A3149,0x064C7E642F65C3DC, + 0x3D2B3E2A4C5A63DA,0x5BD3F340A9210C47,0xB474D157A1615931,0xAC5934DA1DE87266, + 0x6EE365117AF7765B,0xC86ED36716B05C44,0x9BA6885C201D49C5,0xB905387A88346C45, + 0x131072C4BAB9DDFF,0xBF49461EA751AF99,0xD52977BC1CE05BA1,0xB0F785E46027DB52, + 0x546D30BA6E57788C,0x305AD707650F56AE,0xC987C682612FF295,0xA5AB8944F5FBC571, + 0x7ED528E759F244CA,0x8DDCBBCE2C7DB888,0xAA154ABE328DB1BA,0x1E619BE993ECE88B, + 0x09F2BD9EE813B717,0x7401AA4B285D1CB3,0x21858F143195CAEE,0x48C381841398D1B8, + 0xFCB750D3B2F98889,0x39A86A998D1CE1B9,0x1F888E0CE473465A,0x7899568376978716, + 0x02CF2AD7EE2341BF,0x85C713B5B3F1A14E,0xFF916FE12B4567E7,0x7C1A0230B7D10575, + 0x0C98FCC85ECA9BA5,0xA3E7F720DA9E06AD,0x6A6031A2BBB1F438,0x973E74947ED7D260, + 0x2CF4663918C0FF9A,0x5F50A7F368678E24,0x34D983B4A449D4CD,0x68AF1B755592B587, + 0x7F3C3D022E6DEA1B,0xABFC5F5B45121F6B,0x0D71E92D29553574,0xDFFDF5106D4F03D8, + 0x081BA87B9F8C19C6,0xDB7EA1A3AC0981BB,0xBBCA12AD66172DFA,0x79704366010829C7, + 0x179326777BFF5F9C,0x0000000000000000,0xEB2476A4C906D715,0x724DD42F0738DF6F, + 0xB752EE6538DDB65F,0x37FFBC863DF53BA3,0x8EFA84FCB5C157E6,0xE9EB5C73272596AA, + 0x1B0BDABF2535C439,0x86E12C872A4D4E20,0x9969A28BCE3E087A,0xFAFB2EB79D9C4B55, + 0x056A4156B6D92CB2,0x5A3AE6A5DEBEA296,0x22A3B026A8292580,0x53C85B3B36AD1581, + 0xB11E900117B87583,0xC51F3A4A3FE56930,0xE019E1EDCF3621BD,0xEC811D2591FCBA18, + 0x445B7D4C4D524A1D,0xA8DA6069DCAEF005,0x58F5CC72309DE329,0xD4C062596B7FF570, + 0xCE22AD0339D59F98,0x591CD99747024DF8,0x8B90C5AA03187B54,0xF663D27FC356D0F0, + 0xD8589E9135B56ED5,0x35309651D3D67A1C,0x12F96721CD26732E,0xD28C1C3D441A36AC, + 0x492A946164077F69,0x2D1D73DC6F5F514B,0x6F0A70F40D68D88A,0x60B4B30ECA1EAC41, + 0xD36509D83385987D,0x0B3D97490630F6A8,0x9ECCC90A96C46577,0xA20EE2C5AD01A87C, + 0xE49AB55E0E70A3DE,0xA4429CA182646BA0,0xDA97B446DB962F6A,0xCCED87D4D7F6DE27, + 0x2AB8185D37A53C46,0x9F25DCEFE15BCBA6,0xC19C6EF9FEA3EB53,0xA764A3931BD884CE, + 0x2FD2590B817C10F4,0x56A21A6D80743933,0xE573A0BB79EF0D0F,0x155C0CA095DC1E23, + 0x6C2C4FC694D437E4,0x10364DF623053291,0xDD32DFC7836C4267,0x03263F3299BCEF6E, + 0x66F8CD6AE57B6F9D,0x8C35AE2B5BE21659,0x31B3C2E21290F87F,0x93BD2027BF915003, + 0x69460E90220D1B56,0x299E276FAE19D328,0x63928C3C53A2432F,0x7082FEF8E91B9ED0, + 0xBC6F792C3EED40F7,0x4C40D537D2DE53DB,0x75E8BFAE5FC2B262,0x4DA9C0D2A541FD0A, + 0x4E8FFFE03CFD1264,0x2620E495696FA7E3,0xE1F0F408B8A98F6C,0xD1AA230FDDA6D9C2, + 0xC7D0109DD1C6288F,0x8A79D04F7487D585,0x4694579BA3710BA2,0x38417F7CFA834F68, + 0x1D47A4DB0A5007E5,0x206C9AF1460A643F,0xA128DDF734BD4712,0x8144470672B7232D, + 0xF2E086CC02105293,0x182DE58DBC892B57,0xCAA1F9B0F8931DFB,0x6B892447CC2E5AE9, + 0xF9DD11850420A43B,0x4BE5BEB68A243ED6,0x5584255F19C8D65D,0x3B67404E633FA006, + 0xA68DB6766C472A1F,0xF78AC79AB4C97E21,0xC353442E1080AAEC,0x9A4F9DB95782E714 + }, + { + 0x05BA7BC82C9B3220,0x31A54665F8B65E4F,0xB1B651F77547F4D4,0x8BFA0D857BA46682, + 0x85A96C5AA16A98BB,0x990FAEF908EB79C9,0xA15E37A247F4A62D,0x76857DCD5D27741E, + 0xF8C50B800A1820BC,0xBE65DCB201F7A2B4,0x666D1B986F9426E7,0x4CC921BF53C4E648, + 0x95410A0F93D9CA42,0x20CDCCAA647BA4EF,0x429A4060890A1871,0x0C4EA4F69B32B38B, + 0xCCDA362DDE354CD3,0x96DC23BC7C5B2FA9,0xC309BB68AA851AB3,0xD26131A73648E013, + 0x021DC52941FC4DB2,0xCD5ADAB7704BE48A,0xA77965D984ED71E6,0x32386FD61734BBA4, + 0xE82D6DD538AB7245,0x5C2147EA6177B4B1,0x5DA1AB70CF091CE8,0xAC907FCE72B8BDFF, + 0x57C85DFD972278A8,0xA4E44C6A6B6F940D,0x3851995B4F1FDFE4,0x62578CCAED71BC9E, + 0xD9882BB0C01D2C0A,0x917B9D5D113C503B,0xA2C31E11A87643C6,0xE463C923A399C1CE, + 0xF71686C57EA876DC,0x87B4A973E096D509,0xAF0D567D9D3A5814,0xB40C2A3F59DCC6F4, + 0x3602F88495D121DD,0xD3E1DD3D9836484A,0xF945E71AA46688E5,0x7518547EB2A591F5, + 0x9366587450C01D89,0x9EA81018658C065B,0x4F54080CBC4603A3,0x2D0384C65137BF3D, + 0xDC325078EC861E2A,0xEA30A8FC79573FF7,0x214D2030CA050CB6,0x65F0322B8016C30C, + 0x69BE96DD1B247087,0xDB95EE9981E161B8,0xD1FC1814D9CA05F8,0x820ED2BBCC0DE729, + 0x63D76050430F14C7,0x3BCCB0E8A09D3A0F,0x8E40764D573F54A2,0x39D175C1E16177BD, + 0x12F5A37C734F1F4B,0xAB37C12F1FDFC26D,0x5648B167395CD0F1,0x6C04ED1537BF42A7, + 0xED97161D14304065,0x7D6C67DAAB72B807,0xEC17FA87BA4EE83C,0xDFAF79CB0304FBC1, + 0x733F060571BC463E,0x78D61C1287E98A27,0xD07CF48E77B4ADA1,0xB9C262536C90DD26, + 0xE2449B5860801605,0x8FC09AD7F941FCFB,0xFAD8CEA94BE46D0E,0xA343F28B0608EB9F, + 0x9B126BD04917347B,0x9A92874AE7699C22,0x1B017C42C4E69EE0,0x3A4C5C720EE39256, + 0x4B6E9F5E3EA399DA,0x6BA353F45AD83D35,0xE7FEE0904C1B2425,0x22D009832587E95D, + 0x842980C00F1430E2,0xC6B3C0A0861E2893,0x087433A419D729F2,0x341F3DADD42D6C6F, + 0xEE0A3FAEFBB2A58E,0x4AEE73C490DD3183,0xAAB72DB5B1A16A34,0xA92A04065E238FDF, + 0x7B4B35A1686B6FCC,0x6A23BF6EF4A6956C,0x191CB96B851AD352,0x55D598D4D6DE351A, + 0xC9604DE5F2AE7EF3,0x1CA6C2A3A981E172,0xDE2F9551AD7A5398,0x3025AAFF56C8F616, + 0x15521D9D1E2860D9,0x506FE31CFA45073A,0x189C55F12B647B0B,0x0180EC9AAE7EA859, + 0x7CEC8B40050C105E,0x2350E5198BF94104,0xEF8AD33455CC0DD7,0x07A7BEE16D677F92, + 0xE5E325B90DE76997,0x5A061591A26E637A,0xB611EF1618208B46,0x09F4DF3EB7A981AB, + 0x1EBB078AE87DACC0,0xB791038CB65E231F,0x0FD38D4574B05660,0x67EDF702C1EA8EBE, + 0xBA5F4BE0831238CD,0xE3C477C2CEFEBE5C,0x0DCE486C354C1BD2,0x8C5DB36416C31910, + 0x26EA9ED1A7627324,0x039D29B3EF82E5EB,0x9F28FC82CBF2AE02,0xA8AAE89CF05D2786, + 0x431AACFA2774B028,0xCF471F9E31B7A938,0x581BD0B8E3922EC8,0xBC78199B400BEF06, + 0x90FB71C7BF42F862,0x1F3BEB1046030499,0x683E7A47B55AD8DE,0x988F4263A695D190, + 0xD808C72A6E638453,0x0627527BC319D7CB,0xEBB04466D72997AE,0xE67E0C0AE2658C7C, + 0x14D2F107B056C880,0x7122C32C30400B8C,0x8A7AE11FD5DACEDB,0xA0DEDB38E98A0E74, + 0xAD109354DCC615A6,0x0BE91A17F655CC19,0x8DDD5FFEB8BDB149,0xBFE53028AF890AED, + 0xD65BA6F5B4AD7A6A,0x7956F0882997227E,0x10E8665532B352F9,0x0E5361DFDACEFE39, + 0xCEC7F3049FC90161,0xFF62B561677F5F2E,0x975CCF26D22587F0,0x51EF0F86543BAF63, + 0x2F1E41EF10CBF28F,0x52722635BBB94A88,0xAE8DBAE73344F04D,0x410769D36688FD9A, + 0xB3AB94DE34BBB966,0x801317928DF1AA9B,0xA564A0F0C5113C54,0xF131D4BEBDB1A117, + 0x7F71A2F3EA8EF5B5,0x40878549C8F655C3,0x7EF14E6944F05DEC,0xD44663DCF55137D8, + 0xF2ACFD0D523344FC,0x0000000000000000,0x5FBC6E598EF5515A,0x16CF342EF1AA8532, + 0xB036BD6DDB395C8D,0x13754FE6DD31B712,0xBBDFA77A2D6C9094,0x89E7C8AC3A582B30, + 0x3C6B0E09CDFA459D,0xC4AE0589C7E26521,0x49735A777F5FD468,0xCAFD64561D2C9B18, + 0xDA1502032F9FC9E1,0x8867243694268369,0x3782141E3BAF8984,0x9CB5D53124704BE9, + 0xD7DB4A6F1AD3D233,0xA6F989432A93D9BF,0x9D3539AB8A0EE3B0,0x53F2CAAF15C7E2D1, + 0x6E19283C76430F15,0x3DEBE2936384EDC4,0x5E3C82C3208BF903,0x33B8834CB94A13FD, + 0x6470DEB12E686B55,0x359FD1377A53C436,0x61CAA57902F35975,0x043A975282E59A79, + 0xFD7F70482683129C,0xC52EE913699CCD78,0x28B9FF0E7DAC8D1D,0x5455744E78A09D43, + 0xCB7D88CCB3523341,0x44BD121B4A13CFBA,0x4D49CD25FDBA4E11,0x3E76CB208C06082F, + 0x3FF627BA2278A076,0xC28957F204FBB2EA,0x453DFE81E46D67E3,0x94C1E6953DA7621B, + 0x2C83685CFF491764,0xF32C1197FC4DECA5,0x2B24D6BD922E68F6,0xB22B78449AC5113F, + 0x48F3B6EDD1217C31,0x2E9EAD75BEB55AD6,0x174FD8B45FD42D6B,0x4ED4E4961238ABFA, + 0x92E6B4EEFEBEB5D0,0x46A0D7320BEF8208,0x47203BA8A5912A51,0x24F75BF8E69E3E96, + 0xF0B1382413CF094E,0xFEE259FBC901F777,0x276A724B091CDB7D,0xBDF8F501EE75475F, + 0x599B3C224DEC8691,0x6D84018F99C1EAFE,0x7498B8E41CDB39AC,0xE0595E71217C5BB7, + 0x2AA43A273C50C0AF,0xF50B43EC3F543B6E,0x838E3E2162734F70,0xC09492DB4507FF58, + 0x72BFEA9FDFC2EE67,0x11688ACF9CCDFAA0,0x1A8190D86A9836B9,0x7ACBD93BC615C795, + 0xC7332C3A286080CA,0x863445E94EE87D50,0xF6966A5FD0D6DE85,0xE9AD814F96D5DA1C, + 0x70A22FB69E3EA3D5,0x0A69F68D582B6440,0xB8428EC9C2EE757F,0x604A49E3AC8DF12C, + 0x5B86F90B0C10CB23,0xE1D9B2EB8F02F3EE,0x29391394D3D22544,0xC8E0A17F5CD0D6AA, + 0xB58CC6A5F7A26EAD,0x8193FB08238F02C2,0xD5C68F465B2F9F81,0xFCFF9CD288FDBAC5, + 0x77059157F359DC47,0x1D262E3907FF492B,0xFB582233E59AC557,0xDDB2BCE242F8B673, + 0x2577B76248E096CF,0x6F99C4A6D83DA74C,0xC1147E41EB795701,0xF48BAF76912A9337 + }, + { + 0x3EF29D249B2C0A19,0xE9E16322B6F8622F,0x5536994047757F7A,0x9F4D56D5A47B0B33, + 0x822567466AA1174C,0xB8F5057DEB082FB2,0xCC48C10BF4475F53,0x373088D4275DEC3A, + 0x968F4325180AED10,0x173D232CF7016151,0xAE4ED09F946FCC13,0xFD4B4741C4539873, + 0x1B5B3F0DD9933765,0x2FFCB0967B644052,0xE02376D20A89840C,0xA3AE3A70329B18D7, + 0x419CBD2335DE8526,0xFAFEBF115B7C3199,0x0397074F85AA9B0D,0xC58AD4FB4836B970, + 0xBEC60BE3FC4104A8,0x1EFF36DC4B708772,0x131FDC33ED8453B6,0x0844E33E341764D3, + 0x0FF11B6EAB38CD39,0x64351F0A7761B85A,0x3B5694F509CFBA0E,0x30857084B87245D0, + 0x47AFB3BD2297AE3C,0xF2BA5C2F6F6B554A,0x74BDC4761F4F70E1,0xCFDFC64471EDC45E, + 0xE610784C1DC0AF16,0x7ACA29D63C113F28,0x2DED411776A859AF,0xAC5F211E99A3D5EE, + 0xD484F949A87EF33B,0x3CE36CA596E013E4,0xD120F0983A9D432C,0x6BC40464DC597563, + 0x69D5F5E5D1956C9E,0x9AE95F043698BB24,0xC9ECC8DA66A4EF44,0xD69508C8A5B2EAC6, + 0xC40C2235C0503B80,0x38C193BA8C652103,0x1CEEC75D46BC9E8F,0xD331011937515AD1, + 0xD8E2E56886ECA50F,0xB137108D5779C991,0x709F3B6905CA4206,0x4FEB50831680CAEF, + 0xEC456AF3241BD238,0x58D673AFE181ABBE,0x242F54E7CAD9BF8C,0x0211F1810DCC19FD, + 0x90BC4DBB0F43C60A,0x9518446A9DA0761D,0xA1BFCBF13F57012A,0x2BDE4F8961E172B5, + 0x27B853A84F732481,0xB0B1E643DF1F4B61,0x18CC38425C39AC68,0xD2B7F7D7BF37D821, + 0x3103864A3014C720,0x14AA246372ABFA5C,0x6E600DB54EBAC574,0x394765740403A3F3, + 0x09C215F0BC71E623,0x2A58B947E987F045,0x7B4CDF18B477BDD8,0x9709B5EB906C6FE0, + 0x73083C268060D90B,0xFEDC400E41F9037E,0x284948C6E44BE9B8,0x728ECAE808065BFB, + 0x06330E9E17492B1A,0x5950856169E7294E,0xBAE4F4FCE6C4364F,0xCA7BCF95E30E7449, + 0x7D7FD186A33E96C2,0x52836110D85AD690,0x4DFAA1021B4CD312,0x913ABB75872544FA, + 0xDD46ECB9140F1518,0x3D659A6B1E869114,0xC23F2CABD719109A,0xD713FE062DD46836, + 0xD0A60656B2FBC1DC,0x221C5A79DD909496,0xEFD26DBCA1B14935,0x0E77EDA0235E4FC9, + 0xCBFD395B6B68F6B9,0x0DE0EAEFA6F4D4C4,0x0422FF1F1A8532E7,0xF969B85EDED6AA94, + 0x7F6E2007AEF28F3F,0x3AD0623B81A938FE,0x6624EE8B7AADA1A7,0xB682E8DDC856607B, + 0xA78CC56F281E2A30,0xC79B257A45FAA08D,0x5B4174E0642B30B3,0x5F638BFF7EAE0254, + 0x4BC9AF9C0C05F808,0xCE59308AF98B46AE,0x8FC58DA9CC55C388,0x803496C7676D0EB1, + 0xF33CAAE1E70DD7BA,0xBB6202326EA2B4BF,0xD5020F87201871CB,0x9D5CA754A9B712CE, + 0x841669D87DE83C56,0x8A6184785EB6739F,0x420BBA6CB0741E2B,0xF12D5B60EAC1CE47, + 0x76AC35F71283691C,0x2C6BB7D9FECEDB5F,0xFCCDB18F4C351A83,0x1F79C012C3160582, + 0xF0ABADAE62A74CB7,0xE1A5801C82EF06FC,0x67A21845F2CB2357,0x5114665F5DF04D9D, + 0xBF40FD2D74278658,0xA0393D3FB73183DA,0x05A409D192E3B017,0xA9FB28CF0B4065F9, + 0x25A9A22942BF3D7C,0xDB75E22703463E02,0xB326E10C5AB5D06C,0xE7968E8295A62DE6, + 0xB973F3B3636EAD42,0xDF571D3819C30CE5,0xEE549B7229D7CBC5,0x12992AFD65E2D146, + 0xF8EF4E9056B02864,0xB7041E134030E28B,0xC02EDD2ADAD50967,0x932B4AF48AE95D07, + 0x6FE6FB7BC6DC4784,0x239AACB755F61666,0x401A4BEDBDB807D6,0x485EA8D389AF6305, + 0xA41BC220ADB4B13D,0x753B32B89729F211,0x997E584BB3322029,0x1D683193CEDA1C7F, + 0xFF5AB6C0C99F818E,0x16BBD5E27F67E3A1,0xA59D34EE25D233CD,0x98F8AE853B54A2D9, + 0x6DF70AFACB105E79,0x795D2E99B9BBA425,0x8E437B6744334178,0x0186F6CE886682F0, + 0xEBF092A3BB347BD2,0xBCD7FA62F18D1D55,0xADD9D7D011C5571E,0x0BD3E471B1BDFFDE, + 0xAA6C2F808EEAFEF4,0x5EE57D31F6C880A4,0xF50FA47FF044FCA0,0x1ADDC9C351F5B595, + 0xEA76646D3352F922,0x0000000000000000,0x85909F16F58EBEA6,0x46294573AAF12CCC, + 0x0A5512BF39DB7D2E,0x78DBD85731DD26D5,0x29CFBE086C2D6B48,0x218B5D36583A0F9B, + 0x152CD2ADFACD78AC,0x83A39188E2C795BC,0xC3B9DA655F7F926A,0x9ECBA01B2C1D89C3, + 0x07B5F8509F2FA9EA,0x7EE8D6C926940DCF,0x36B67E1AAF3B6ECA,0x86079859702425AB, + 0xFB7849DFD31AB369,0x4C7C57CC932A51E2,0xD96413A60E8A27FF,0x263EA566C715A671, + 0x6C71FC344376DC89,0x4A4F595284637AF8,0xDAF314E98B20BCF2,0x572768C14AB96687, + 0x1088DB7C682EC8BB,0x887075F9537A6A62,0x2E7A4658F302C2A2,0x619116DBE582084D, + 0xA87DDE018326E709,0xDCC01A779C6997E8,0xEDC39C3DAC7D50C8,0xA60A33A1A078A8C0, + 0xC1A82BE452B38B97,0x3F746BEA134A88E9,0xA228CCBEBAFD9A27,0xABEAD94E068C7C04, + 0xF48952B178227E50,0x5CF48CB0FB049959,0x6017E0156DE48ABD,0x4438B4F2A73D3531, + 0x8C528AE649FF5885,0xB515EF924DFCFB76,0x0C661C212E925634,0xB493195CC59A7986, + 0x9CDA519A21D1903E,0x32948105B5BE5C2D,0x194ACE8CD45F2E98,0x438D4CA238129CDB, + 0x9B6FA9CABEFE39D4,0x81B26009EF0B8C41,0xDED1EBF691A58E15,0x4E6DA64D9EE6481F, + 0x54B06F8ECF13FD8A,0x49D85E1D01C9E1F5,0xAFC826511C094EE3,0xF698A33075EE67AD, + 0x5AC7822EEC4DB243,0x8DD47C28C199DA75,0x89F68337DB1CE892,0xCDCE37C57C21DDA3, + 0x530597DE503C5460,0x6A42F2AA543FF793,0x5D727A7E73621BA9,0xE232875307459DF1, + 0x56A19E0FC2DFE477,0xC61DD3B4CD9C227D,0xE5877F03986A341B,0x949EB2A415C6F4ED, + 0x6206119460289340,0x6380E75AE84E11B0,0x8BE772B6D6D0F16F,0x50929091D596CF6D, + 0xE86795EC3E9EE0DF,0x7CF927482B581432,0xC86A3E14EEC26DB4,0x7119CDA78DACC0F6, + 0xE40189CD100CB6EB,0x92ADBC3A028FDFF7,0xB2A017C2D2D3529C,0x200DABF8D05C8D6B, + 0x34A78F9BA2F77737,0xE3B4719D8F231F01,0x45BE423C2F5BB7C1,0xF71E55FEFD88E55D, + 0x6853032B59F3EE6E,0x65B3E9C4FF073AAA,0x772AC3399AE5EBEC,0x87816E97F842A75B, + 0x110E2DB2E0484A4B,0x331277CB3DD8DEDD,0xBD510CAC79EB9FA5,0x352179552A91F5C7 + }, + { + 0x8AB0A96846E06A6D,0x43C7E80B4BF0B33A,0x08C9B3546B161EE5,0x39F1C235EBA990BE, + 0xC1BEF2376606C7B2,0x2C209233614569AA,0xEB01523B6FC3289A,0x946953AB935ACEDD, + 0x272838F63E13340E,0x8B0455ECA12BA052,0x77A1B2C4978FF8A2,0xA55122CA13E54086, + 0x2276135862D3F1CD,0xDB8DDFDE08B76CFE,0x5D1E12C89E4A178A,0x0E56816B03969867, + 0xEE5F79953303ED59,0xAFED748BAB78D71D,0x6D929F2DF93E53EE,0xF5D8A8F8BA798C2A, + 0xF619B1698E39CF6B,0x95DDAF2F749104E2,0xEC2A9C80E0886427,0xCE5C8FD8825B95EA, + 0xC4E0D9993AC60271,0x4699C3A5173076F9,0x3D1B151F50A29F42,0x9ED505EA2BC75946, + 0x34665ACFDC7F4B98,0x61B1FB53292342F7,0xC721C0080E864130,0x8693CD1696FD7B74, + 0x872731927136B14B,0xD3446C8A63A1721B,0x669A35E8A6680E4A,0xCAB658F239509A16, + 0xA4E5DE4EF42E8AB9,0x37A7435EE83F08D9,0x134E6239E26C7F96,0x82791A3C2DF67488, + 0x3F6EF00A8329163C,0x8E5A7E42FDEB6591,0x5CAAEE4C7981DDB5,0x19F234785AF1E80D, + 0x255DDDE3ED98BD70,0x50898A32A99CCCAC,0x28CA4519DA4E6656,0xAE59880F4CB31D22, + 0x0D9798FA37D6DB26,0x32F968F0B4FFCD1A,0xA00F09644F258545,0xFA3AD5175E24DE72, + 0xF46C547C5DB24615,0x713E80FBFF0F7E20,0x7843CF2B73D2AAFA,0xBD17EA36AEDF62B4, + 0xFD111BACD16F92CF,0x4ABAA7DBC72D67E0,0xB3416B5DAD49FAD3,0xBCA316B24914A88B, + 0x15D150068AECF914,0xE27C1DEBE31EFC40,0x4FE48C759BEDA223,0x7EDCFD141B522C78, + 0x4E5070F17C26681C,0xE696CAC15815F3BC,0x35D2A64B3BB481A7,0x800CFF29FE7DFDF6, + 0x1ED9FAC3D5BAA4B0,0x6C2663A91EF599D1,0x03C1199134404341,0xF7AD4DED69F20554, + 0xCD9D9649B61BD6AB,0xC8C3BDE7EADB1368,0xD131899FB02AFB65,0x1D18E352E1FAE7F1, + 0xDA39235AEF7CA6C1,0xA1BBF5E0A8EE4F7A,0x91377805CF9A0B1E,0x3138716180BF8E5B, + 0xD9F83ACBDB3CE580,0x0275E515D38B897E,0x472D3F21F0FBBCC6,0x2D946EB7868EA395, + 0xBA3C248D21942E09,0xE7223645BFDE3983,0xFF64FEB902E41BB1,0xC97741630D10D957, + 0xC3CB1722B58D4ECC,0xA27AEC719CAE0C3B,0x99FECB51A48C15FB,0x1465AC826D27332B, + 0xE1BD047AD75EBF01,0x79F733AF941960C5,0x672EC96C41A3C475,0xC27FEBA6524684F3, + 0x64EFD0FD75E38734,0xED9E60040743AE18,0xFB8E2993B9EF144D,0x38453EB10C625A81, + 0x6978480742355C12,0x48CF42CE14A6EE9E,0x1CAC1FD606312DCE,0x7B82D6BA4792E9BB, + 0x9D141C7B1F871A07,0x5616B80DC11C4A2E,0xB849C198F21FA777,0x7CA91801C8D9A506, + 0xB1348E487EC273AD,0x41B20D1E987B3A44,0x7460AB55A3CFBBE3,0x84E628034576F20A, + 0x1B87D16D897A6173,0x0FE27DEFE45D5258,0x83CDE6B8CA3DBEB7,0x0C23647ED01D1119, + 0x7A362A3EA0592384,0xB61F40F3F1893F10,0x75D457D1440471DC,0x4558DA34237035B8, + 0xDCA6116587FC2043,0x8D9B67D3C9AB26D0,0x2B0B5C88EE0E2517,0x6FE77A382AB5DA90, + 0x269CC472D9D8FE31,0x63C41E46FAA8CB89,0xB7ABBC771642F52F,0x7D1DE4852F126F39, + 0xA8C6BA3024339BA0,0x600507D7CEE888C8,0x8FEE82C61A20AFAE,0x57A2448926D78011, + 0xFCA5E72836A458F0,0x072BCEBB8F4B4CBD,0x497BBE4AF36D24A1,0x3CAFE99BB769557D, + 0x12FA9EBD05A7B5A9,0xE8C04BAA5B836BDB,0x4273148FAC3B7905,0x908384812851C121, + 0xE557D3506C55B0FD,0x72FF996ACB4F3D61,0x3EDA0C8E64E2DC03,0xF0868356E6B949E9, + 0x04EAD72ABB0B0FFC,0x17A4B5135967706A,0xE3C8E16F04D5367F,0xF84F30028DAF570C, + 0x1846C8FCBD3A2232,0x5B8120F7F6CA9108,0xD46FA231ECEA3EA6,0x334D947453340725, + 0x58403966C28AD249,0xBED6F3A79A9F21F5,0x68CCB483A5FE962D,0xD085751B57E1315A, + 0xFED0023DE52FD18E,0x4B0E5B5F20E6ADDF,0x1A332DE96EB1AB4C,0xA3CE10F57B65C604, + 0x108F7BA8D62C3CD7,0xAB07A3A11073D8E1,0x6B0DAD1291BED56C,0xF2F366433532C097, + 0x2E557726B2CEE0D4,0x0000000000000000,0xCB02A476DE9B5029,0xE4E32FD48B9E7AC2, + 0x734B65EE2C84F75E,0x6E5386BCCD7E10AF,0x01B4FC84E7CBCA3F,0xCFE8735C65905FD5, + 0x3613BFDA0FF4C2E6,0x113B872C31E7F6E8,0x2FE18BA255052AEB,0xE974B72EBC48A1E4, + 0x0ABC5641B89D979B,0xB46AA5E62202B66E,0x44EC26B0C4BBFF87,0xA6903B5B27A503C7, + 0x7F680190FC99E647,0x97A84A3AA71A8D9C,0xDD12EDE16037EA7C,0xC554251DDD0DC84E, + 0x88C54C7D956BE313,0x4D91696048662B5D,0xB08072CC9909B992,0xB5DE5962C5C97C51, + 0x81B803AD19B637C9,0xB2F597D94A8230EC,0x0B08AAC55F565DA4,0xF1327FD2017283D6, + 0xAD98919E78F35E63,0x6AB9519676751F53,0x24E921670A53774F,0xB9FD3D1C15D46D48, + 0x92F66194FBDA485F,0x5A35DC7311015B37,0xDED3F4705477A93D,0xC00A0EB381CD0D8D, + 0xBB88D809C65FE436,0x16104997BEACBA55,0x21B70AC95693B28C,0x59F4C5E225411876, + 0xD5DB5EB50B21F499,0x55D7A19CF55C096F,0xA97246B4C3F8519F,0x8552D487A2BD3835, + 0x54635D181297C350,0x23C2EFDC85183BF2,0x9F61F96ECC0C9379,0x534893A39DDC8FED, + 0x5EDF0B59AA0A54CB,0xAC2C6D1A9F38945C,0xD7AEBBA0D8AA7DE7,0x2ABFA00C09C5EF28, + 0xD84CC64F3CF72FBF,0x2003F64DB15878B3,0xA724C7DFC06EC9F8,0x069F323F68808682, + 0xCC296ACD51D01C94,0x055E2BAE5CC0C5C3,0x6270E2C21D6301B6,0x3B842720382219C0, + 0xD2F0900E846AB824,0x52FC6F277A1745D2,0xC6953C8CE94D8B0F,0xE009F8FE3095753E, + 0x655B2C7992284D0B,0x984A37D54347DFC4,0xEAB5AEBF8808E2A5,0x9A3FD2C090CC56BA, + 0x9CA0E0FFF84CD038,0x4C2595E4AFADE162,0xDF6708F4B3BC6302,0xBF620F237D54EBCA, + 0x93429D101C118260,0x097D4FD08CDDD4DA,0x8C2F9B572E60ECEF,0x708A7C7F18C4B41F, + 0x3A30DBA4DFE9D3FF,0x4006F19A7FB0F07B,0x5F6BF7DD4DC19EF4,0x1F6D064732716E8F, + 0xF9FBCC866A649D33,0x308C8DE567744464,0x8971B0F972A0292C,0xD61A47243F61B7D8, + 0xEFEB8511D4C82766,0x961CB6BE40D147A3,0xAAB35F25F7B812DE,0x76154E407044329D, + 0x513D76B64E570693,0xF3479AC7D2F90AA8,0x9B8B2E4477079C85,0x297EB99D3D85AC69 + }, + { + 0x7E37E62DFC7D40C3,0x776F25A4EE939E5B,0xE045C850DD8FB5AD,0x86ED5BA711FF1952, + 0xE91D0BD9CF616B35,0x37E0AB256E408FFB,0x9607F6C031025A7A,0x0B02F5E116D23C9D, + 0xF3D8486BFB50650C,0x621CFF27C40875F5,0x7D40CB71FA5FD34A,0x6DAA6616DAA29062, + 0x9F5F354923EC84E2,0xEC847C3DC507C3B3,0x025A3668043CE205,0xA8BF9E6C4DAC0B19, + 0xFA808BE2E9BEBB94,0xB5B99C5277C74FA3,0x78D9BC95F0397BCC,0xE332E50CDBAD2624, + 0xC74FCE129332797E,0x1729ECEB2EA709AB,0xC2D6B9F69954D1F8,0x5D898CBFBAB8551A, + 0x859A76FB17DD8ADB,0x1BE85886362F7FB5,0xF6413F8FF136CD8A,0xD3110FA5BBB7E35C, + 0x0A2FEED514CC4D11,0xE83010EDCD7F1AB9,0xA1E75DE55F42D581,0xEEDE4A55C13B21B6, + 0xF2F5535FF94E1480,0x0CC1B46D1888761E,0xBCE15FDB6529913B,0x2D25E8975A7181C2, + 0x71817F1CE2D7A554,0x2E52C5CB5C53124B,0xF9F7A6BEEF9C281D,0x9E722E7D21F2F56E, + 0xCE170D9B81DCA7E6,0x0E9B82051CB4941B,0x1E712F623C49D733,0x21E45CFA42F9F7DC, + 0xCB8E7A7F8BBA0F60,0x8E98831A010FB646,0x474CCF0D8E895B23,0xA99285584FB27A95, + 0x8CC2B57205335443,0x42D5B8E984EFF3A5,0x012D1B34021E718C,0x57A6626AAE74180B, + 0xFF19FC06E3D81312,0x35BA9D4D6A7C6DFE,0xC9D44C178F86ED65,0x506523E6A02E5288, + 0x03772D5C06229389,0x8B01F4FE0B691EC0,0xF8DABD8AED825991,0x4C4E3AEC985B67BE, + 0xB10DF0827FBF96A9,0x6A69279AD4F8DAE1,0xE78689DCD3D5FF2E,0x812E1A2B1FA553D1, + 0xFBAD90D6EBA0CA18,0x1AC543B234310E39,0x1604F7DF2CB97827,0xA6241C6951189F02, + 0x753513CCEAAF7C5E,0x64F2A59FC84C4EFA,0x247D2B1E489F5F5A,0xDB64D718AB474C48, + 0x79F4A7A1F2270A40,0x1573DA832A9BEBAE,0x3497867968621C72,0x514838D2A2302304, + 0xF0AF6537FD72F685,0x1D06023E3A6B44BA,0x678588C3CE6EDD73,0x66A893F7CC70ACFF, + 0xD4D24E29B5EDA9DF,0x3856321470EA6A6C,0x07C3418C0E5A4A83,0x2BCBB22F5635BACD, + 0x04B46CD00878D90A,0x06EE5AB80C443B0F,0x3B211F4876C8F9E5,0x0958C38912EEDE98, + 0xD14B39CDBF8B0159,0x397B292072F41BE0,0x87C0409313E168DE,0xAD26E98847CAA39F, + 0x4E140C849C6785BB,0xD5FF551DB7F3D853,0xA0CA46D15D5CA40D,0xCD6020C787FE346F, + 0x84B76DCF15C3FB57,0xDEFDA0FCA121E4CE,0x4B8D7B6096012D3D,0x9AC642AD298A2C64, + 0x0875D8BD10F0AF14,0xB357C6EA7B8374AC,0x4D6321D89A451632,0xEDA96709C719B23F, + 0xF76C24BBF328BC06,0xC662D526912C08F2,0x3CE25EC47892B366,0xB978283F6F4F39BD, + 0xC08C8F9E9D6833FD,0x4F3917B09E79F437,0x593DE06FB2C08C10,0xD6887841B1D14BDA, + 0x19B26EEE32139DB0,0xB494876675D93E2F,0x825937771987C058,0x90E9AC783D466175, + 0xF1827E03FF6C8709,0x945DC0A8353EB87F,0x4516F9658AB5B926,0x3F9573987EB020EF, + 0xB855330B6D514831,0x2AE6A91B542BCB41,0x6331E413C6160479,0x408F8E8180D311A0, + 0xEFF35161C325503A,0xD06622F9BD9570D5,0x8876D9A20D4B8D49,0xA5533135573A0C8B, + 0xE168D364DF91C421,0xF41B09E7F50A2F8F,0x12B09B0F24C1A12D,0xDA49CC2CA9593DC4, + 0x1F5C34563E57A6BF,0x54D14F36A8568B82,0xAF7CDFE043F6419A,0xEA6A2685C943F8BC, + 0xE5DCBFB4D7E91D2B,0xB27ADDDE799D0520,0x6B443CAED6E6AB6D,0x7BAE91C9F61BE845, + 0x3EB868AC7CAE5163,0x11C7B65322E332A4,0xD23C1491B9A992D0,0x8FB5982E0311C7CA, + 0x70AC6428E0C9D4D8,0x895BC2960F55FCC5,0x76423E90EC8DEFD7,0x6FF0507EDE9E7267, + 0x3DCF45F07A8CC2EA,0x4AA06054941F5CB1,0x5810FB5BB0DEFD9C,0x5EFEA1E3BC9AC693, + 0x6EDD4B4ADC8003EB,0x741808F8E8B10DD2,0x145EC1B728859A22,0x28BC9F7350172944, + 0x270A06424EBDCCD3,0x972AEDF4331C2BF6,0x059977E40A66A886,0x2550302A4A812ED6, + 0xDD8A8DA0A7037747,0xC515F87A970E9B7B,0x3023EAA9601AC578,0xB7E3AA3A73FBADA6, + 0x0FB699311EAAE597,0x0000000000000000,0x310EF19D6204B4F4,0x229371A644DB6455, + 0x0DECAF591A960792,0x5CA4978BB8A62496,0x1C2B190A38753536,0x41A295B582CD602C, + 0x3279DCC16426277D,0xC1A194AA9F764271,0x139D803B26DFD0A1,0xAE51C4D441E83016, + 0xD813FA44AD65DFC1,0xAC0BF2BC45D4D213,0x23BE6A9246C515D9,0x49D74D08923DCF38, + 0x9D05032127D066E7,0x2F7FDEFF5E4D63C7,0xA47E2A0155247D07,0x99B16FF12FA8BFED, + 0x4661D4398C972AAF,0xDFD0BBC8A33F9542,0xDCA79694A51D06CB,0xB020EBB67DA1E725, + 0xBA0F0563696DAA34,0xE4F1A480D5F76CA7,0xC438E34E9510EAF7,0x939E81243B64F2FC, + 0x8DEFAE46072D25CF,0x2C08F3A3586FF04E,0xD7A56375B3CF3A56,0x20C947CE40E78650, + 0x43F8A3DD86F18229,0x568B795EAC6A6987,0x8003011F1DBB225D,0xF53612D3F7145E03, + 0x189F75DA300DEC3C,0x9570DB9C3720C9F3,0xBB221E576B73DBB8,0x72F65240E4F536DD, + 0x443BE25188ABC8AA,0xE21FFE38D9B357A8,0xFD43CA6EE7E4F117,0xCAA3614B89A47EEC, + 0xFE34E732E1C6629E,0x83742C431B99B1D4,0xCF3A16AF83C2D66A,0xAAE5A8044990E91C, + 0x26271D764CA3BD5F,0x91C4B74C3F5810F9,0x7C6DD045F841A2C6,0x7F1AFD19FE63314F, + 0xC8F957238D989CE9,0xA709075D5306EE8E,0x55FC5402AA48FA0E,0x48FA563C9023BEB4, + 0x65DFBEABCA523F76,0x6C877D22D8BCE1EE,0xCC4D3BF385E045E3,0xBEBB69B36115733E, + 0x10EAAD6720FD4328,0xB6CEB10E71E5DC2A,0xBDCC44EF6737E0B7,0x523F158EA412B08D, + 0x989C74C52DB6CE61,0x9BEB59992B945DE8,0x8A2CEFCA09776F4C,0xA3BD6B8D5B7E3784, + 0xEB473DB1CB5D8930,0xC3FBA2C29B4AA074,0x9C28181525CE176B,0x683311F2D0C438E4, + 0x5FD3BAD7BE84B71F,0xFC6ED15AE5FA809B,0x36CDB0116C5EFE77,0x29918447520958C8, + 0xA29070B959604608,0x53120EBAA60CC101,0x3A0C047C74D68869,0x691E0AC6D2DA4968, + 0x73DB4974E6EB4751,0x7A838AFDF40599C9,0x5A4ACD33B4E21F99,0x6046C94FC03497F0, + 0xE6AB92E8D1CB8EA2,0x3354C7F5663856F1,0xD93EE170AF7BAE4D,0x616BD27BC22AE67C, + 0x92B39A10397A8370,0xABC8B3304B8E9890,0xBF967287630B02B2,0x5B67D607B6FC6E15 + }, + { + 0xD031C397CE553FE6,0x16BA5B01B006B525,0xA89BADE6296E70C8,0x6A1F525D77D3435B, + 0x6E103570573DFA0B,0x660EFB2A17FC95AB,0x76327A9E97634BF6,0x4BAD9D6462458BF5, + 0xF1830CAEDBC3F748,0xC5C8F542669131FF,0x95044A1CDC48B0CB,0x892962DF3CF8B866, + 0xB0B9E208E930C135,0xA14FB3F0611A767C,0x8D2605F21C160136,0xD6B71922FECC549E, + 0x37089438A5907D8B,0x0B5DA38E5803D49C,0x5A5BCC9CEA6F3CBC,0xEDAE246D3B73FFE5, + 0xD2B87E0FDE22EDCE,0x5E54ABB1CA8185EC,0x1DE7F88FE80561B9,0xAD5E1A870135A08C, + 0x2F2ADBD665CECC76,0x5780B5A782F58358,0x3EDC8A2EEDE47B3F,0xC9D95C3506BEE70F, + 0x83BE111D6C4E05EE,0xA603B90959367410,0x103C81B4809FDE5D,0x2C69B6027D0C774A, + 0x399080D7D5C87953,0x09D41E16487406B4,0xCDD63B1826505E5F,0xF99DC2F49B0298E8, + 0x9CD0540A943CB67F,0xBCA84B7F891F17C5,0x723D1DB3B78DF2A6,0x78AA6E71E73B4F2E, + 0x1433E699A071670D,0x84F21BE454620782,0x98DF3327B4D20F2F,0xF049DCE2D3769E5C, + 0xDB6C60199656EB7A,0x648746B2078B4783,0x32CD23598DCBADCF,0x1EA4955BF0C7DA85, + 0xE9A143401B9D46B5,0xFD92A5D9BBEC21B8,0xC8138C790E0B8E1B,0x2EE00B9A6D7BA562, + 0xF85712B893B7F1FC,0xEB28FED80BEA949D,0x564A65EB8A40EA4C,0x6C9988E8474A2823, + 0x4535898B121D8F2D,0xABD8C03231ACCBF4,0xBA2E91CAB9867CBD,0x7960BE3DEF8E263A, + 0x0C11A977602FD6F0,0xCB50E1AD16C93527,0xEAE22E94035FFD89,0x2866D12F5DE2CE1A, + 0xFF1B1841AB9BF390,0x9F9339DE8CFE0D43,0x964727C8C48A0BF7,0x524502C6AAAE531C, + 0x9B9C5EF3AC10B413,0x4FA2FA4942AB32A5,0x3F165A62E551122B,0xC74148DA76E6E3D7, + 0x924840E5E464B2A7,0xD372AE43D69784DA,0x233B72A105E11A86,0xA48A04914941A638, + 0xB4B68525C9DE7865,0xDDEABAACA6CF8002,0x0A9773C250B6BD88,0xC284FFBB5EBD3393, + 0x8BA0DF472C8F6A4E,0x2AEF6CB74D951C32,0x427983722A318D41,0x73F7CDFFBF389BB2, + 0x074C0AF9382C026C,0x8A6A0F0B243A035A,0x6FDAE53C5F88931F,0xC68B98967E538AC3, + 0x44FF59C71AA8E639,0xE2FCE0CE439E9229,0xA20CDE2479D8CD40,0x19E89FA2C8EBD8E9, + 0xF446BBCFF398270C,0x43B3533E2284E455,0xD82F0DCD8E945046,0x51066F12B26CE820, + 0xE73957AF6BC5426D,0x081ECE5A40C16FA0,0x3B193D4FC5BFAB7B,0x7FE66488DF174D42, + 0x0E9814EF705804D8,0x8137AC857C39D7C6,0xB1733244E185A821,0x695C3F896F11F867, + 0xF6CF0657E3EFF524,0x1AABF276D02963D5,0x2DA3664E75B91E5E,0x0289BD981077D228, + 0x90C1FD7DF413608F,0x3C5537B6FD93A917,0xAA12107E3919A2E0,0x0686DAB530996B78, + 0xDAA6B0559EE3826E,0xC34E2FF756085A87,0x6D5358A44FFF4137,0xFC587595B35948AC, + 0x7CA5095CC7D5F67E,0xFB147F6C8B754AC0,0xBFEB26AB91DDACF9,0x6896EFC567A49173, + 0xCA9A31E11E7C5C33,0xBBE44186B13315A9,0x0DDB793B689ABFE4,0x70B4A02BA7FA208E, + 0xE47A3A7B7307F951,0x8CECD5BE14A36822,0xEEED49B923B144D9,0x17708B4DB8B3DC31, + 0x6088219F2765FED3,0xB3FA8FDCF1F27A09,0x910B2D31FCA6099B,0x0F52C4A378ED6DCC, + 0x50CCBF5EBAD98134,0x6BD582117F662A4F,0x94CE9A50D4FDD9DF,0x2B25BCFB45207526, + 0x67C42B661F49FCBF,0x492420FC723259DD,0x03436DD418C2BB3C,0x1F6E4517F872B391, + 0xA08563BC69AF1F68,0xD43EA4BAEEBB86B6,0x01CAD04C08B56914,0xAC94CACB0980C998, + 0x54C3D8739A373864,0x26FEC5C02DBACAC2,0xDEA9D778BE0D3B3E,0x040F672D20EEB950, + 0xE5B0EA377BB29045,0xF30AB136CBB42560,0x62019C0737122CFB,0xE86B930C13282FA1, + 0xCC1CEB542EE5374B,0x538FD28AA21B3A08,0x1B61223AD89C0AC1,0x36C24474AD25149F, + 0x7A23D3E9F74C9D06,0xBE21F6E79968C5ED,0xCF5F868036278C77,0xF705D61BEB5A9C30, + 0x4D2B47D152DCE08D,0x5F9E7BFDC234ECF8,0x247778583DCD18EA,0x867BA67C4415D5AA, + 0x4CE1979D5A698999,0x0000000000000000,0xEC64F42133C696F1,0xB57C5569C16B1171, + 0xC1C7926F467F88AF,0x654D96FE0F3E2E97,0x15F936D5A8C40E19,0xB8A72C52A9F1AE95, + 0xA9517DAA21DB19DC,0x58D27104FA18EE94,0x5918A148F2AD8780,0x5CDD1629DAF657C4, + 0x8274C15164FB6CFA,0xD1FB13DBC6E056F2,0x7D6FD910CF609F6A,0xB63F38BDD9A9AA4D, + 0x3D9FE7FAF526C003,0x74BBC706871499DE,0xDF630734B6B8522A,0x3AD3ED03CD0AC26F, + 0xFADEAF2083C023D4,0xC00D42234ECAE1BB,0x8538CBA85CD76E96,0xC402250E6E2458EB, + 0x47BC3413026A5D05,0xAFD7A71F114272A4,0x978DF784CC3F62E3,0xB96DFC1EA144C781, + 0x21B2CF391596C8AE,0x318E4E8D950916F3,0xCE9556CC3E92E563,0x385A509BDD7D1047, + 0x358129A0B5E7AFA3,0xE6F387E363702B79,0xE0755D5653E94001,0x7BE903A5FFF9F412, + 0x12B53C2C90E80C75,0x3307F315857EC4DB,0x8FAFB86A0C61D31E,0xD9E5DD8186213952, + 0x77F8AAD29FD622E2,0x25BDA814357871FE,0x7571174A8FA1F0CA,0x137FEC60985D6561, + 0x30449EC19DBC7FE7,0xA540D4DD41F4CF2C,0xDC206AE0AE7AE916,0x5B911CD0E2DA55A8, + 0xB2305F90F947131D,0x344BF9ECBD52C6B7,0x5D17C665D2433ED0,0x18224FEEC05EB1FD, + 0x9E59E992844B6457,0x9A568EBFA4A5DD07,0xA3C60E68716DA454,0x7E2CB4C4D7A22456, + 0x87B176304CA0BCBE,0x413AEEA632F3367D,0x9915E36BBC67663B,0x40F03EEA3A465F69, + 0x1C2D28C3E0B008AD,0x4E682A054A1E5BB1,0x05C5B761285BD044,0xE1BF8D1A5B5C2915, + 0xF2C0617AC3014C74,0xB7F5E8F1D11CC359,0x63CB4C4B3FA745EF,0x9D1A84469C89DF6B, + 0xE33630824B2BFB3D,0xD5F474F6E60EEFA2,0xF58C6B83FB2D4E18,0x4676E45F0ADF3411, + 0x20781F751D23A1BA,0xBD629B3381AA7ED1,0xAE1D775319F71BB0,0xFED1C80DA32E9A84, + 0x5509083F92825170,0x29AC01635557A70E,0xA7C9694551831D04,0x8E65682604D4BA0A, + 0x11F651F8882AB749,0xD77DC96EF6793D8A,0xEF2799F52B042DCD,0x48EEF0B07A8730C9, + 0x22F1A2ED0D547392,0x6142F1D32FD097C7,0x4A674D286AF0E2E1,0x80FD7CC9748CBED2, + 0x717E7067AF4F499A,0x938290A9ECD1DBB3,0x88E3B293344DD172,0x2734158C250FA3D6 + } +}; + +// Constant values for KeySchedule function +const unsigned char C[12][64] = { + { + 0xB1,0x08,0x5B,0xDA,0x1E,0xCA,0xDA,0xE9,0xEB,0xCB,0x2F,0x81,0xC0,0x65,0x7C,0x1F, + 0x2F,0x6A,0x76,0x43,0x2E,0x45,0xD0,0x16,0x71,0x4E,0xB8,0x8D,0x75,0x85,0xC4,0xFC, + 0x4B,0x7C,0xE0,0x91,0x92,0x67,0x69,0x01,0xA2,0x42,0x2A,0x08,0xA4,0x60,0xD3,0x15, + 0x05,0x76,0x74,0x36,0xCC,0x74,0x4D,0x23,0xDD,0x80,0x65,0x59,0xF2,0xA6,0x45,0x07 + }, + { + 0x6F,0xA3,0xB5,0x8A,0xA9,0x9D,0x2F,0x1A,0x4F,0xE3,0x9D,0x46,0x0F,0x70,0xB5,0xD7, + 0xF3,0xFE,0xEA,0x72,0x0A,0x23,0x2B,0x98,0x61,0xD5,0x5E,0x0F,0x16,0xB5,0x01,0x31, + 0x9A,0xB5,0x17,0x6B,0x12,0xD6,0x99,0x58,0x5C,0xB5,0x61,0xC2,0xDB,0x0A,0xA7,0xCA, + 0x55,0xDD,0xA2,0x1B,0xD7,0xCB,0xCD,0x56,0xE6,0x79,0x04,0x70,0x21,0xB1,0x9B,0xB7 + }, + { + 0xF5,0x74,0xDC,0xAC,0x2B,0xCE,0x2F,0xC7,0x0A,0x39,0xFC,0x28,0x6A,0x3D,0x84,0x35, + 0x06,0xF1,0x5E,0x5F,0x52,0x9C,0x1F,0x8B,0xF2,0xEA,0x75,0x14,0xB1,0x29,0x7B,0x7B, + 0xD3,0xE2,0x0F,0xE4,0x90,0x35,0x9E,0xB1,0xC1,0xC9,0x3A,0x37,0x60,0x62,0xDB,0x09, + 0xC2,0xB6,0xF4,0x43,0x86,0x7A,0xDB,0x31,0x99,0x1E,0x96,0xF5,0x0A,0xBA,0x0A,0xB2 + }, + { + 0xEF,0x1F,0xDF,0xB3,0xE8,0x15,0x66,0xD2,0xF9,0x48,0xE1,0xA0,0x5D,0x71,0xE4,0xDD, + 0x48,0x8E,0x85,0x7E,0x33,0x5C,0x3C,0x7D,0x9D,0x72,0x1C,0xAD,0x68,0x5E,0x35,0x3F, + 0xA9,0xD7,0x2C,0x82,0xED,0x03,0xD6,0x75,0xD8,0xB7,0x13,0x33,0x93,0x52,0x03,0xBE, + 0x34,0x53,0xEA,0xA1,0x93,0xE8,0x37,0xF1,0x22,0x0C,0xBE,0xBC,0x84,0xE3,0xD1,0x2E + }, + { + 0x4B,0xEA,0x6B,0xAC,0xAD,0x47,0x47,0x99,0x9A,0x3F,0x41,0x0C,0x6C,0xA9,0x23,0x63, + 0x7F,0x15,0x1C,0x1F,0x16,0x86,0x10,0x4A,0x35,0x9E,0x35,0xD7,0x80,0x0F,0xFF,0xBD, + 0xBF,0xCD,0x17,0x47,0x25,0x3A,0xF5,0xA3,0xDF,0xFF,0x00,0xB7,0x23,0x27,0x1A,0x16, + 0x7A,0x56,0xA2,0x7E,0xA9,0xEA,0x63,0xF5,0x60,0x17,0x58,0xFD,0x7C,0x6C,0xFE,0x57 + }, + { + 0xAE,0x4F,0xAE,0xAE,0x1D,0x3A,0xD3,0xD9,0x6F,0xA4,0xC3,0x3B,0x7A,0x30,0x39,0xC0, + 0x2D,0x66,0xC4,0xF9,0x51,0x42,0xA4,0x6C,0x18,0x7F,0x9A,0xB4,0x9A,0xF0,0x8E,0xC6, + 0xCF,0xFA,0xA6,0xB7,0x1C,0x9A,0xB7,0xB4,0x0A,0xF2,0x1F,0x66,0xC2,0xBE,0xC6,0xB6, + 0xBF,0x71,0xC5,0x72,0x36,0x90,0x4F,0x35,0xFA,0x68,0x40,0x7A,0x46,0x64,0x7D,0x6E + }, + { + 0xF4,0xC7,0x0E,0x16,0xEE,0xAA,0xC5,0xEC,0x51,0xAC,0x86,0xFE,0xBF,0x24,0x09,0x54, + 0x39,0x9E,0xC6,0xC7,0xE6,0xBF,0x87,0xC9,0xD3,0x47,0x3E,0x33,0x19,0x7A,0x93,0xC9, + 0x09,0x92,0xAB,0xC5,0x2D,0x82,0x2C,0x37,0x06,0x47,0x69,0x83,0x28,0x4A,0x05,0x04, + 0x35,0x17,0x45,0x4C,0xA2,0x3C,0x4A,0xF3,0x88,0x86,0x56,0x4D,0x3A,0x14,0xD4,0x93 + }, + { + 0x9B,0x1F,0x5B,0x42,0x4D,0x93,0xC9,0xA7,0x03,0xE7,0xAA,0x02,0x0C,0x6E,0x41,0x41, + 0x4E,0xB7,0xF8,0x71,0x9C,0x36,0xDE,0x1E,0x89,0xB4,0x44,0x3B,0x4D,0xDB,0xC4,0x9A, + 0xF4,0x89,0x2B,0xCB,0x92,0x9B,0x06,0x90,0x69,0xD1,0x8D,0x2B,0xD1,0xA5,0xC4,0x2F, + 0x36,0xAC,0xC2,0x35,0x59,0x51,0xA8,0xD9,0xA4,0x7F,0x0D,0xD4,0xBF,0x02,0xE7,0x1E + }, + { + 0x37,0x8F,0x5A,0x54,0x16,0x31,0x22,0x9B,0x94,0x4C,0x9A,0xD8,0xEC,0x16,0x5F,0xDE, + 0x3A,0x7D,0x3A,0x1B,0x25,0x89,0x42,0x24,0x3C,0xD9,0x55,0xB7,0xE0,0x0D,0x09,0x84, + 0x80,0x0A,0x44,0x0B,0xDB,0xB2,0xCE,0xB1,0x7B,0x2B,0x8A,0x9A,0xA6,0x07,0x9C,0x54, + 0x0E,0x38,0xDC,0x92,0xCB,0x1F,0x2A,0x60,0x72,0x61,0x44,0x51,0x83,0x23,0x5A,0xDB + }, + { + 0xAB,0xBE,0xDE,0xA6,0x80,0x05,0x6F,0x52,0x38,0x2A,0xE5,0x48,0xB2,0xE4,0xF3,0xF3, + 0x89,0x41,0xE7,0x1C,0xFF,0x8A,0x78,0xDB,0x1F,0xFF,0xE1,0x8A,0x1B,0x33,0x61,0x03, + 0x9F,0xE7,0x67,0x02,0xAF,0x69,0x33,0x4B,0x7A,0x1E,0x6C,0x30,0x3B,0x76,0x52,0xF4, + 0x36,0x98,0xFA,0xD1,0x15,0x3B,0xB6,0xC3,0x74,0xB4,0xC7,0xFB,0x98,0x45,0x9C,0xED + }, + { + 0x7B,0xCD,0x9E,0xD0,0xEF,0xC8,0x89,0xFB,0x30,0x02,0xC6,0xCD,0x63,0x5A,0xFE,0x94, + 0xD8,0xFA,0x6B,0xBB,0xEB,0xAB,0x07,0x61,0x20,0x01,0x80,0x21,0x14,0x84,0x66,0x79, + 0x8A,0x1D,0x71,0xEF,0xEA,0x48,0xB9,0xCA,0xEF,0xBA,0xCD,0x1D,0x7D,0x47,0x6E,0x98, + 0xDE,0xA2,0x59,0x4A,0xC0,0x6F,0xD8,0x5D,0x6B,0xCA,0xA4,0xCD,0x81,0xF3,0x2D,0x1B + }, + { + 0x37,0x8E,0xE7,0x67,0xF1,0x16,0x31,0xBA,0xD2,0x13,0x80,0xB0,0x04,0x49,0xB1,0x7A, + 0xCD,0xA4,0x3C,0x32,0xBC,0xDF,0x1D,0x77,0xF8,0x20,0x12,0xD4,0x30,0x21,0x9F,0x9B, + 0x5D,0x80,0xEF,0x9D,0x18,0x91,0xCC,0x86,0xE7,0x1D,0xA4,0xAA,0x88,0xE1,0x28,0x52, + 0xFA,0xF4,0x17,0xD5,0xD9,0xB2,0x1B,0x99,0x48,0xBC,0x92,0x4A,0xF1,0x1B,0xD7,0x20 + } +}; + + +void AddModulo512(const void *a,const void *b,void *c) +{ + const unsigned char *A=a, *B=b; + unsigned char *C=c; + int t = 0; +#ifdef FULL_UNROLL +#define ADDBYTE_8(i) t = A[i] + B[i] + (t >> 8); C[i] = t & 0xFF; + + ADDBYTE_8(63) + ADDBYTE_8(62) + ADDBYTE_8(61) + ADDBYTE_8(60) + ADDBYTE_8(59) + ADDBYTE_8(58) + ADDBYTE_8(57) + ADDBYTE_8(56) + ADDBYTE_8(55) + ADDBYTE_8(54) + ADDBYTE_8(53) + ADDBYTE_8(52) + ADDBYTE_8(51) + ADDBYTE_8(50) + ADDBYTE_8(49) + ADDBYTE_8(48) + ADDBYTE_8(47) + ADDBYTE_8(46) + ADDBYTE_8(45) + ADDBYTE_8(44) + ADDBYTE_8(43) + ADDBYTE_8(42) + ADDBYTE_8(41) + ADDBYTE_8(40) + ADDBYTE_8(39) + ADDBYTE_8(38) + ADDBYTE_8(37) + ADDBYTE_8(36) + ADDBYTE_8(35) + ADDBYTE_8(34) + ADDBYTE_8(33) + ADDBYTE_8(32) + ADDBYTE_8(31) + ADDBYTE_8(30) + ADDBYTE_8(29) + ADDBYTE_8(28) + ADDBYTE_8(27) + ADDBYTE_8(26) + ADDBYTE_8(25) + ADDBYTE_8(24) + ADDBYTE_8(23) + ADDBYTE_8(22) + ADDBYTE_8(21) + ADDBYTE_8(20) + ADDBYTE_8(19) + ADDBYTE_8(18) + ADDBYTE_8(17) + ADDBYTE_8(16) + ADDBYTE_8(15) + ADDBYTE_8(14) + ADDBYTE_8(13) + ADDBYTE_8(12) + ADDBYTE_8(11) + ADDBYTE_8(10) + ADDBYTE_8(9) + ADDBYTE_8(8) + ADDBYTE_8(7) + ADDBYTE_8(6) + ADDBYTE_8(5) + ADDBYTE_8(4) + ADDBYTE_8(3) + ADDBYTE_8(2) + ADDBYTE_8(1) + ADDBYTE_8(0) + +#else + int i = 0; + + for(i=63;i>=0;i--) + { + t = A[i] + B[i] + (t >> 8); + C[i] = t & 0xFF; + } +#endif +} + +void AddXor512(const void *a,const void *b,void *c) +{ + const unsigned long long *A=a, *B=b; + unsigned long long *C=c; +#ifdef FULL_UNROLL + C[0] = A[0] ^ B[0]; + C[1] = A[1] ^ B[1]; + C[2] = A[2] ^ B[2]; + C[3] = A[3] ^ B[3]; + C[4] = A[4] ^ B[4]; + C[5] = A[5] ^ B[5]; + C[6] = A[6] ^ B[6]; + C[7] = A[7] ^ B[7]; +#else + int i = 0; + + for(i=0;i<8;i++) + { + C[i] = A[i] ^ B[i]; + } +#endif +} + +void F(unsigned char *state) +{ + unsigned long long return_state[8]; + register unsigned long long r = 0; + r ^= T[0][state[56]]; + r ^= T[1][state[48]]; + r ^= T[2][state[40]]; + r ^= T[3][state[32]]; + r ^= T[4][state[24]]; + r ^= T[5][state[16]]; + r ^= T[6][state[8]]; + r ^= T[7][state[0]]; + return_state[0] = r; + r = 0; + + r ^= T[0][state[57]]; + r ^= T[1][state[49]]; + r ^= T[2][state[41]]; + r ^= T[3][state[33]]; + r ^= T[4][state[25]]; + r ^= T[5][state[17]]; + r ^= T[6][state[9]]; + r ^= T[7][state[1]]; + return_state[1] = r; + r = 0; + + r ^= T[0][state[58]]; + r ^= T[1][state[50]]; + r ^= T[2][state[42]]; + r ^= T[3][state[34]]; + r ^= T[4][state[26]]; + r ^= T[5][state[18]]; + r ^= T[6][state[10]]; + r ^= T[7][state[2]]; + return_state[2] = r; + r = 0; + + r ^= T[0][state[59]]; + r ^= T[1][state[51]]; + r ^= T[2][state[43]]; + r ^= T[3][state[35]]; + r ^= T[4][state[27]]; + r ^= T[5][state[19]]; + r ^= T[6][state[11]]; + r ^= T[7][state[3]]; + return_state[3] = r; + r = 0; + + r ^= T[0][state[60]]; + r ^= T[1][state[52]]; + r ^= T[2][state[44]]; + r ^= T[3][state[36]]; + r ^= T[4][state[28]]; + r ^= T[5][state[20]]; + r ^= T[6][state[12]]; + r ^= T[7][state[4]]; + return_state[4] = r; + r = 0; + + r ^= T[0][state[61]]; + r ^= T[1][state[53]]; + r ^= T[2][state[45]]; + r ^= T[3][state[37]]; + r ^= T[4][state[29]]; + r ^= T[5][state[21]]; + r ^= T[6][state[13]]; + r ^= T[7][state[5]]; + return_state[5] = r; + r = 0; + + r ^= T[0][state[62]]; + r ^= T[1][state[54]]; + r ^= T[2][state[46]]; + r ^= T[3][state[38]]; + r ^= T[4][state[30]]; + r ^= T[5][state[22]]; + r ^= T[6][state[14]]; + r ^= T[7][state[6]]; + return_state[6] = r; + r = 0; + + r ^= T[0][state[63]]; + r ^= T[1][state[55]]; + r ^= T[2][state[47]]; + r ^= T[3][state[39]]; + r ^= T[4][state[31]]; + r ^= T[5][state[23]]; + r ^= T[6][state[15]]; + r ^= T[7][state[7]]; + return_state[7] = r; + + memcpy(state,(unsigned char*)return_state,64); +} + +#define KeySchedule(K,i) AddXor512(K,C[i],K); F(K); + +void E(unsigned char *K,const unsigned char *m, unsigned char *state) +{ +#ifdef FULL_UNROLL + AddXor512(m,K,state); + + F(state); + KeySchedule(K,0); + AddXor512(state,K,state); + + F(state); + KeySchedule(K,1); + AddXor512(state,K,state); + + F(state); + KeySchedule(K,2); + AddXor512(state,K,state); + + F(state); + KeySchedule(K,3); + AddXor512(state,K,state); + + F(state); + KeySchedule(K,4); + AddXor512(state,K,state); + + F(state); + KeySchedule(K,5); + AddXor512(state,K,state); + + F(state); + KeySchedule(K,6); + AddXor512(state,K,state); + + F(state); + KeySchedule(K,7); + AddXor512(state,K,state); + + F(state); + KeySchedule(K,8); + AddXor512(state,K,state); + + F(state); + KeySchedule(K,9); + AddXor512(state,K,state); + + F(state); + KeySchedule(K,10); + AddXor512(state,K,state); + + F(state); + KeySchedule(K,11); + AddXor512(state,K,state); +#else + int i = 0; + + AddXor512(m,K,state); + + for(i=0;i<12;i++) + { + F(state); + KeySchedule(K,i); + AddXor512(state,K,state); + } +#endif +} + +static void g_N(const unsigned char *N,unsigned char *h,const unsigned char *m) +{ + unsigned char t[64], K[64]; + + AddXor512(N,h,K); + + F(K); + + E(K,m,t); + + AddXor512(t,h,t); + AddXor512(t,m,h); +} + +static void hash_X(unsigned char *IV,const unsigned char *message,unsigned long long length,unsigned char *out) +{ + unsigned char v512[64] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00 + }; + unsigned char v0[64] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + }; + unsigned char Sigma[64] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + }; + unsigned char N[64] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + }; + unsigned char m[64], *hash = IV; + unsigned long long len = length; + + // Stage 2 + while (len >= 512) + { + memcpy(m, message + len/8 - 63 - ( (len & 0x7) == 0 ), 64); + + g_N(N,hash,m); + AddModulo512(N,v512,N); + AddModulo512(Sigma,m,Sigma); + len -= 512; + } + + memset(m,0,64); + memcpy(m + 63 - len/8 + ( (len & 0x7) == 0 ), message, len/8 + 1 - ( (len & 0x7) == 0 )); + + // Stage 3 + m[ 63 - len/8 ] |= (1 << (len & 0x7)); + + g_N(N,hash,m); + v512[63] = len & 0xFF; + v512[62] = len >> 8; + AddModulo512(N,v512,N); + + AddModulo512(Sigma,m,Sigma); + + g_N(v0,hash,N); + g_N(v0,hash,Sigma); + + memcpy(out, hash, 64); +} + +static void hash_512(const unsigned char *message,unsigned long long length,unsigned char *out) +{ + unsigned char IV[64] = + { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + }; + + hash_X(IV,message,length,out); +} + +static void hash_256(const unsigned char *message,unsigned long long length,unsigned char *out) +{ + unsigned char IV[64] = + { + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 + }; + unsigned char hash[64]; + + hash_X(IV,message,length,hash); + + memcpy(out,hash,32); +} + + + + + +/* see sph_gost.h */ +void +sph_gost256_init(void *cc) +{ + //gost_init(cc, 256); +} + +/* see sph_gost.h */ +void +sph_gost256(void *cc, const void *data, size_t len) +{ + hash_256(data, len * 8, cc); +} + +/* see sph_gost.h */ +void +sph_gost256_close(void *cc, void *dst) +{ + //sph_gost256_addbits_and_close(cc, 0, 0, dst); + memcpy(dst, cc, 32); +} + +/* see sph_gost.h */ +void +sph_gost256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + //gost_close32(cc, ub, n, dst); +} + +/* see sph_gost.h */ +void sph_gost512_init(void *cc) +{ + //gost_init(cc, 512); +} + +/* see sph_gost.h */ +void sph_gost512(void *cc, const void *data, size_t len) +{ + hash_512(data, len * 8, cc); +} + +/* see sph_gost.h */ +void sph_gost512_close(void *cc, void *dst) +{ + //sph_gost512_addbits_and_close(cc, 0, 0, dst); + memcpy(dst, cc, 64); +} + +/* see sph_gost.h */ +void +sph_gost512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + //gost_close64(cc, ub, n, dst); +} + + +#ifdef __cplusplus +} +#endif diff --git a/src/obj/skunkhash/gost.o b/src/obj/skunkhash/gost.o new file mode 100644 index 0000000..80e6e9a Binary files /dev/null and b/src/obj/skunkhash/gost.o differ diff --git a/src/obj/skunkhash/hamsi.c b/src/obj/skunkhash/hamsi.c new file mode 100644 index 0000000..8e87ab4 --- /dev/null +++ b/src/obj/skunkhash/hamsi.c @@ -0,0 +1,867 @@ +/* $Id: hamsi.c 251 2010-10-19 14:31:51Z tp $ */ +/* + * Hamsi implementation. + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @author Thomas Pornin + */ + +#include +#include + +#include "sph_hamsi.h" + +#ifdef __cplusplus +extern "C"{ +#endif + +#if SPH_SMALL_FOOTPRINT && !defined SPH_SMALL_FOOTPRINT_HAMSI +#define SPH_SMALL_FOOTPRINT_HAMSI 1 +#endif + +/* + * The SPH_HAMSI_EXPAND_* define how many input bits we handle in one + * table lookup during message expansion (1 to 8, inclusive). If we note + * w the number of bits per message word (w=32 for Hamsi-224/256, w=64 + * for Hamsi-384/512), r the size of a "row" in 32-bit words (r=8 for + * Hamsi-224/256, r=16 for Hamsi-384/512), and n the expansion level, + * then we will get t tables (where t=ceil(w/n)) of individual size + * 2^n*r*4 (in bytes). The last table may be shorter (e.g. with w=32 and + * n=5, there are 7 tables, but the last one uses only two bits on + * input, not five). + * + * Also, we read t rows of r words from RAM. Words in a given row are + * concatenated in RAM in that order, so most of the cost is about + * reading the first row word; comparatively, cache misses are thus + * less expensive with Hamsi-512 (r=16) than with Hamsi-256 (r=8). + * + * When n=1, tables are "special" in that we omit the first entry of + * each table (which always contains 0), so that total table size is + * halved. + * + * We thus have the following (size1 is the cumulative table size of + * Hamsi-224/256; size2 is for Hamsi-384/512; similarly, t1 and t2 + * are for Hamsi-224/256 and Hamsi-384/512, respectively). + * + * n size1 size2 t1 t2 + * --------------------------------------- + * 1 1024 4096 32 64 + * 2 2048 8192 16 32 + * 3 2688 10880 11 22 + * 4 4096 16384 8 16 + * 5 6272 25600 7 13 + * 6 10368 41984 6 11 + * 7 16896 73856 5 10 + * 8 32768 131072 4 8 + * + * So there is a trade-off: a lower n makes the tables fit better in + * L1 cache, but increases the number of memory accesses. The optimal + * value depends on the amount of available L1 cache and the relative + * impact of a cache miss. + * + * Experimentally, in ideal benchmark conditions (which are not necessarily + * realistic with regards to L1 cache contention), it seems that n=8 is + * the best value on "big" architectures (those with 32 kB or more of L1 + * cache), while n=4 is better on "small" architectures. This was tested + * on an Intel Core2 Q6600 (both 32-bit and 64-bit mode), a PowerPC G3 + * (32 kB L1 cache, hence "big"), and a MIPS-compatible Broadcom BCM3302 + * (8 kB L1 cache). + * + * Note: with n=1, the 32 tables (actually implemented as one big table) + * are read entirely and sequentially, regardless of the input data, + * thus avoiding any data-dependent table access pattern. + */ + +#if !defined SPH_HAMSI_EXPAND_SMALL +#if SPH_SMALL_FOOTPRINT_HAMSI +#define SPH_HAMSI_EXPAND_SMALL 4 +#else +#define SPH_HAMSI_EXPAND_SMALL 8 +#endif +#endif + +#if !defined SPH_HAMSI_EXPAND_BIG +#define SPH_HAMSI_EXPAND_BIG 8 +#endif + +#ifdef _MSC_VER +#pragma warning (disable: 4146) +#endif + +#include "hamsi_helper.c" + +static const sph_u32 IV224[] = { + SPH_C32(0xc3967a67), SPH_C32(0xc3bc6c20), SPH_C32(0x4bc3bcc3), + SPH_C32(0xa7c3bc6b), SPH_C32(0x2c204b61), SPH_C32(0x74686f6c), + SPH_C32(0x69656b65), SPH_C32(0x20556e69) +}; + +/* + * This version is the one used in the Hamsi submission package for + * round 2 of the SHA-3 competition; the UTF-8 encoding is wrong and + * shall soon be corrected in the official Hamsi specification. + * +static const sph_u32 IV224[] = { + SPH_C32(0x3c967a67), SPH_C32(0x3cbc6c20), SPH_C32(0xb4c343c3), + SPH_C32(0xa73cbc6b), SPH_C32(0x2c204b61), SPH_C32(0x74686f6c), + SPH_C32(0x69656b65), SPH_C32(0x20556e69) +}; + */ + +static const sph_u32 IV256[] = { + SPH_C32(0x76657273), SPH_C32(0x69746569), SPH_C32(0x74204c65), + SPH_C32(0x7576656e), SPH_C32(0x2c204465), SPH_C32(0x70617274), + SPH_C32(0x656d656e), SPH_C32(0x7420456c) +}; + +static const sph_u32 IV384[] = { + SPH_C32(0x656b7472), SPH_C32(0x6f746563), SPH_C32(0x686e6965), + SPH_C32(0x6b2c2043), SPH_C32(0x6f6d7075), SPH_C32(0x74657220), + SPH_C32(0x53656375), SPH_C32(0x72697479), SPH_C32(0x20616e64), + SPH_C32(0x20496e64), SPH_C32(0x75737472), SPH_C32(0x69616c20), + SPH_C32(0x43727970), SPH_C32(0x746f6772), SPH_C32(0x61706879), + SPH_C32(0x2c204b61) +}; + +static const sph_u32 IV512[] = { + SPH_C32(0x73746565), SPH_C32(0x6c706172), SPH_C32(0x6b204172), + SPH_C32(0x656e6265), SPH_C32(0x72672031), SPH_C32(0x302c2062), + SPH_C32(0x75732032), SPH_C32(0x3434362c), SPH_C32(0x20422d33), + SPH_C32(0x30303120), SPH_C32(0x4c657576), SPH_C32(0x656e2d48), + SPH_C32(0x65766572), SPH_C32(0x6c65652c), SPH_C32(0x2042656c), + SPH_C32(0x6769756d) +}; + +static const sph_u32 alpha_n[] = { + SPH_C32(0xff00f0f0), SPH_C32(0xccccaaaa), SPH_C32(0xf0f0cccc), + SPH_C32(0xff00aaaa), SPH_C32(0xccccaaaa), SPH_C32(0xf0f0ff00), + SPH_C32(0xaaaacccc), SPH_C32(0xf0f0ff00), SPH_C32(0xf0f0cccc), + SPH_C32(0xaaaaff00), SPH_C32(0xccccff00), SPH_C32(0xaaaaf0f0), + SPH_C32(0xaaaaf0f0), SPH_C32(0xff00cccc), SPH_C32(0xccccf0f0), + SPH_C32(0xff00aaaa), SPH_C32(0xccccaaaa), SPH_C32(0xff00f0f0), + SPH_C32(0xff00aaaa), SPH_C32(0xf0f0cccc), SPH_C32(0xf0f0ff00), + SPH_C32(0xccccaaaa), SPH_C32(0xf0f0ff00), SPH_C32(0xaaaacccc), + SPH_C32(0xaaaaff00), SPH_C32(0xf0f0cccc), SPH_C32(0xaaaaf0f0), + SPH_C32(0xccccff00), SPH_C32(0xff00cccc), SPH_C32(0xaaaaf0f0), + SPH_C32(0xff00aaaa), SPH_C32(0xccccf0f0) +}; + +static const sph_u32 alpha_f[] = { + SPH_C32(0xcaf9639c), SPH_C32(0x0ff0f9c0), SPH_C32(0x639c0ff0), + SPH_C32(0xcaf9f9c0), SPH_C32(0x0ff0f9c0), SPH_C32(0x639ccaf9), + SPH_C32(0xf9c00ff0), SPH_C32(0x639ccaf9), SPH_C32(0x639c0ff0), + SPH_C32(0xf9c0caf9), SPH_C32(0x0ff0caf9), SPH_C32(0xf9c0639c), + SPH_C32(0xf9c0639c), SPH_C32(0xcaf90ff0), SPH_C32(0x0ff0639c), + SPH_C32(0xcaf9f9c0), SPH_C32(0x0ff0f9c0), SPH_C32(0xcaf9639c), + SPH_C32(0xcaf9f9c0), SPH_C32(0x639c0ff0), SPH_C32(0x639ccaf9), + SPH_C32(0x0ff0f9c0), SPH_C32(0x639ccaf9), SPH_C32(0xf9c00ff0), + SPH_C32(0xf9c0caf9), SPH_C32(0x639c0ff0), SPH_C32(0xf9c0639c), + SPH_C32(0x0ff0caf9), SPH_C32(0xcaf90ff0), SPH_C32(0xf9c0639c), + SPH_C32(0xcaf9f9c0), SPH_C32(0x0ff0639c) +}; + +#define DECL_STATE_SMALL \ + sph_u32 c0, c1, c2, c3, c4, c5, c6, c7; + +#define READ_STATE_SMALL(sc) do { \ + c0 = sc->h[0x0]; \ + c1 = sc->h[0x1]; \ + c2 = sc->h[0x2]; \ + c3 = sc->h[0x3]; \ + c4 = sc->h[0x4]; \ + c5 = sc->h[0x5]; \ + c6 = sc->h[0x6]; \ + c7 = sc->h[0x7]; \ + } while (0) + +#define WRITE_STATE_SMALL(sc) do { \ + sc->h[0x0] = c0; \ + sc->h[0x1] = c1; \ + sc->h[0x2] = c2; \ + sc->h[0x3] = c3; \ + sc->h[0x4] = c4; \ + sc->h[0x5] = c5; \ + sc->h[0x6] = c6; \ + sc->h[0x7] = c7; \ + } while (0) + +#define s0 m0 +#define s1 m1 +#define s2 c0 +#define s3 c1 +#define s4 c2 +#define s5 c3 +#define s6 m2 +#define s7 m3 +#define s8 m4 +#define s9 m5 +#define sA c4 +#define sB c5 +#define sC c6 +#define sD c7 +#define sE m6 +#define sF m7 + +#define SBOX(a, b, c, d) do { \ + sph_u32 t; \ + t = (a); \ + (a) &= (c); \ + (a) ^= (d); \ + (c) ^= (b); \ + (c) ^= (a); \ + (d) |= t; \ + (d) ^= (b); \ + t ^= (c); \ + (b) = (d); \ + (d) |= t; \ + (d) ^= (a); \ + (a) &= (b); \ + t ^= (a); \ + (b) ^= (d); \ + (b) ^= t; \ + (a) = (c); \ + (c) = (b); \ + (b) = (d); \ + (d) = SPH_T32(~t); \ + } while (0) + +#define L(a, b, c, d) do { \ + (a) = SPH_ROTL32(a, 13); \ + (c) = SPH_ROTL32(c, 3); \ + (b) ^= (a) ^ (c); \ + (d) ^= (c) ^ SPH_T32((a) << 3); \ + (b) = SPH_ROTL32(b, 1); \ + (d) = SPH_ROTL32(d, 7); \ + (a) ^= (b) ^ (d); \ + (c) ^= (d) ^ SPH_T32((b) << 7); \ + (a) = SPH_ROTL32(a, 5); \ + (c) = SPH_ROTL32(c, 22); \ + } while (0) + +#define ROUND_SMALL(rc, alpha) do { \ + s0 ^= alpha[0x00]; \ + s1 ^= alpha[0x01] ^ (sph_u32)(rc); \ + s2 ^= alpha[0x02]; \ + s3 ^= alpha[0x03]; \ + s4 ^= alpha[0x08]; \ + s5 ^= alpha[0x09]; \ + s6 ^= alpha[0x0A]; \ + s7 ^= alpha[0x0B]; \ + s8 ^= alpha[0x10]; \ + s9 ^= alpha[0x11]; \ + sA ^= alpha[0x12]; \ + sB ^= alpha[0x13]; \ + sC ^= alpha[0x18]; \ + sD ^= alpha[0x19]; \ + sE ^= alpha[0x1A]; \ + sF ^= alpha[0x1B]; \ + SBOX(s0, s4, s8, sC); \ + SBOX(s1, s5, s9, sD); \ + SBOX(s2, s6, sA, sE); \ + SBOX(s3, s7, sB, sF); \ + L(s0, s5, sA, sF); \ + L(s1, s6, sB, sC); \ + L(s2, s7, s8, sD); \ + L(s3, s4, s9, sE); \ + } while (0) + +#define P_SMALL do { \ + ROUND_SMALL(0, alpha_n); \ + ROUND_SMALL(1, alpha_n); \ + ROUND_SMALL(2, alpha_n); \ + } while (0) + +#define PF_SMALL do { \ + ROUND_SMALL(0, alpha_f); \ + ROUND_SMALL(1, alpha_f); \ + ROUND_SMALL(2, alpha_f); \ + ROUND_SMALL(3, alpha_f); \ + ROUND_SMALL(4, alpha_f); \ + ROUND_SMALL(5, alpha_f); \ + } while (0) + +#define T_SMALL do { \ + /* order is important */ \ + c7 = (sc->h[7] ^= sB); \ + c6 = (sc->h[6] ^= sA); \ + c5 = (sc->h[5] ^= s9); \ + c4 = (sc->h[4] ^= s8); \ + c3 = (sc->h[3] ^= s3); \ + c2 = (sc->h[2] ^= s2); \ + c1 = (sc->h[1] ^= s1); \ + c0 = (sc->h[0] ^= s0); \ + } while (0) + +static void +hamsi_small(sph_hamsi_small_context *sc, const unsigned char *buf, size_t num) +{ + DECL_STATE_SMALL +#if !SPH_64 + sph_u32 tmp; +#endif + +#if SPH_64 + sc->count += (sph_u64)num << 5; +#else + tmp = SPH_T32((sph_u32)num << 5); + sc->count_low = SPH_T32(sc->count_low + tmp); + sc->count_high += (sph_u32)((num >> 13) >> 14); + if (sc->count_low < tmp) + sc->count_high ++; +#endif + READ_STATE_SMALL(sc); + while (num -- > 0) { + sph_u32 m0, m1, m2, m3, m4, m5, m6, m7; + + INPUT_SMALL; + P_SMALL; + T_SMALL; + buf += 4; + } + WRITE_STATE_SMALL(sc); +} + +static void +hamsi_small_final(sph_hamsi_small_context *sc, const unsigned char *buf) +{ + sph_u32 m0, m1, m2, m3, m4, m5, m6, m7; + DECL_STATE_SMALL + + READ_STATE_SMALL(sc); + INPUT_SMALL; + PF_SMALL; + T_SMALL; + WRITE_STATE_SMALL(sc); +} + +static void +hamsi_small_init(sph_hamsi_small_context *sc, const sph_u32 *iv) +{ + sc->partial_len = 0; + memcpy(sc->h, iv, sizeof sc->h); +#if SPH_64 + sc->count = 0; +#else + sc->count_high = sc->count_low = 0; +#endif +} + +static void +hamsi_small_core(sph_hamsi_small_context *sc, const void *data, size_t len) +{ + if (sc->partial_len != 0) { + size_t mlen; + + mlen = 4 - sc->partial_len; + if (len < mlen) { + memcpy(sc->partial + sc->partial_len, data, len); + sc->partial_len += len; + return; + } else { + memcpy(sc->partial + sc->partial_len, data, mlen); + len -= mlen; + data = (const unsigned char *)data + mlen; + hamsi_small(sc, sc->partial, 1); + sc->partial_len = 0; + } + } + + hamsi_small(sc, data, (len >> 2)); + data = (const unsigned char *)data + (len & ~(size_t)3); + len &= (size_t)3; + memcpy(sc->partial, data, len); + sc->partial_len = len; +} + +static void +hamsi_small_close(sph_hamsi_small_context *sc, + unsigned ub, unsigned n, void *dst, size_t out_size_w32) +{ + unsigned char pad[12]; + size_t ptr, u; + unsigned z; + unsigned char *out; + + ptr = sc->partial_len; + memcpy(pad, sc->partial, ptr); +#if SPH_64 + sph_enc64be(pad + 4, sc->count + (ptr << 3) + n); +#else + sph_enc32be(pad + 4, sc->count_high); + sph_enc32be(pad + 8, sc->count_low + (ptr << 3) + n); +#endif + z = 0x80 >> n; + pad[ptr ++] = ((ub & -z) | z) & 0xFF; + while (ptr < 4) + pad[ptr ++] = 0; + hamsi_small(sc, pad, 2); + hamsi_small_final(sc, pad + 8); + out = dst; + for (u = 0; u < out_size_w32; u ++) + sph_enc32be(out + (u << 2), sc->h[u]); +} + +#define DECL_STATE_BIG \ + sph_u32 c0, c1, c2, c3, c4, c5, c6, c7; \ + sph_u32 c8, c9, cA, cB, cC, cD, cE, cF; + +#define READ_STATE_BIG(sc) do { \ + c0 = sc->h[0x0]; \ + c1 = sc->h[0x1]; \ + c2 = sc->h[0x2]; \ + c3 = sc->h[0x3]; \ + c4 = sc->h[0x4]; \ + c5 = sc->h[0x5]; \ + c6 = sc->h[0x6]; \ + c7 = sc->h[0x7]; \ + c8 = sc->h[0x8]; \ + c9 = sc->h[0x9]; \ + cA = sc->h[0xA]; \ + cB = sc->h[0xB]; \ + cC = sc->h[0xC]; \ + cD = sc->h[0xD]; \ + cE = sc->h[0xE]; \ + cF = sc->h[0xF]; \ + } while (0) + +#define WRITE_STATE_BIG(sc) do { \ + sc->h[0x0] = c0; \ + sc->h[0x1] = c1; \ + sc->h[0x2] = c2; \ + sc->h[0x3] = c3; \ + sc->h[0x4] = c4; \ + sc->h[0x5] = c5; \ + sc->h[0x6] = c6; \ + sc->h[0x7] = c7; \ + sc->h[0x8] = c8; \ + sc->h[0x9] = c9; \ + sc->h[0xA] = cA; \ + sc->h[0xB] = cB; \ + sc->h[0xC] = cC; \ + sc->h[0xD] = cD; \ + sc->h[0xE] = cE; \ + sc->h[0xF] = cF; \ + } while (0) + +#define s00 m0 +#define s01 m1 +#define s02 c0 +#define s03 c1 +#define s04 m2 +#define s05 m3 +#define s06 c2 +#define s07 c3 +#define s08 c4 +#define s09 c5 +#define s0A m4 +#define s0B m5 +#define s0C c6 +#define s0D c7 +#define s0E m6 +#define s0F m7 +#define s10 m8 +#define s11 m9 +#define s12 c8 +#define s13 c9 +#define s14 mA +#define s15 mB +#define s16 cA +#define s17 cB +#define s18 cC +#define s19 cD +#define s1A mC +#define s1B mD +#define s1C cE +#define s1D cF +#define s1E mE +#define s1F mF + +#define ROUND_BIG(rc, alpha) do { \ + s00 ^= alpha[0x00]; \ + s01 ^= alpha[0x01] ^ (sph_u32)(rc); \ + s02 ^= alpha[0x02]; \ + s03 ^= alpha[0x03]; \ + s04 ^= alpha[0x04]; \ + s05 ^= alpha[0x05]; \ + s06 ^= alpha[0x06]; \ + s07 ^= alpha[0x07]; \ + s08 ^= alpha[0x08]; \ + s09 ^= alpha[0x09]; \ + s0A ^= alpha[0x0A]; \ + s0B ^= alpha[0x0B]; \ + s0C ^= alpha[0x0C]; \ + s0D ^= alpha[0x0D]; \ + s0E ^= alpha[0x0E]; \ + s0F ^= alpha[0x0F]; \ + s10 ^= alpha[0x10]; \ + s11 ^= alpha[0x11]; \ + s12 ^= alpha[0x12]; \ + s13 ^= alpha[0x13]; \ + s14 ^= alpha[0x14]; \ + s15 ^= alpha[0x15]; \ + s16 ^= alpha[0x16]; \ + s17 ^= alpha[0x17]; \ + s18 ^= alpha[0x18]; \ + s19 ^= alpha[0x19]; \ + s1A ^= alpha[0x1A]; \ + s1B ^= alpha[0x1B]; \ + s1C ^= alpha[0x1C]; \ + s1D ^= alpha[0x1D]; \ + s1E ^= alpha[0x1E]; \ + s1F ^= alpha[0x1F]; \ + SBOX(s00, s08, s10, s18); \ + SBOX(s01, s09, s11, s19); \ + SBOX(s02, s0A, s12, s1A); \ + SBOX(s03, s0B, s13, s1B); \ + SBOX(s04, s0C, s14, s1C); \ + SBOX(s05, s0D, s15, s1D); \ + SBOX(s06, s0E, s16, s1E); \ + SBOX(s07, s0F, s17, s1F); \ + L(s00, s09, s12, s1B); \ + L(s01, s0A, s13, s1C); \ + L(s02, s0B, s14, s1D); \ + L(s03, s0C, s15, s1E); \ + L(s04, s0D, s16, s1F); \ + L(s05, s0E, s17, s18); \ + L(s06, s0F, s10, s19); \ + L(s07, s08, s11, s1A); \ + L(s00, s02, s05, s07); \ + L(s10, s13, s15, s16); \ + L(s09, s0B, s0C, s0E); \ + L(s19, s1A, s1C, s1F); \ + } while (0) + +#if SPH_SMALL_FOOTPRINT_HAMSI + +#define P_BIG do { \ + unsigned r; \ + for (r = 0; r < 6; r ++) \ + ROUND_BIG(r, alpha_n); \ + } while (0) + +#define PF_BIG do { \ + unsigned r; \ + for (r = 0; r < 12; r ++) \ + ROUND_BIG(r, alpha_f); \ + } while (0) + +#else + +#define P_BIG do { \ + ROUND_BIG(0, alpha_n); \ + ROUND_BIG(1, alpha_n); \ + ROUND_BIG(2, alpha_n); \ + ROUND_BIG(3, alpha_n); \ + ROUND_BIG(4, alpha_n); \ + ROUND_BIG(5, alpha_n); \ + } while (0) + +#define PF_BIG do { \ + ROUND_BIG(0, alpha_f); \ + ROUND_BIG(1, alpha_f); \ + ROUND_BIG(2, alpha_f); \ + ROUND_BIG(3, alpha_f); \ + ROUND_BIG(4, alpha_f); \ + ROUND_BIG(5, alpha_f); \ + ROUND_BIG(6, alpha_f); \ + ROUND_BIG(7, alpha_f); \ + ROUND_BIG(8, alpha_f); \ + ROUND_BIG(9, alpha_f); \ + ROUND_BIG(10, alpha_f); \ + ROUND_BIG(11, alpha_f); \ + } while (0) + +#endif + +#define T_BIG do { \ + /* order is important */ \ + cF = (sc->h[0xF] ^= s17); \ + cE = (sc->h[0xE] ^= s16); \ + cD = (sc->h[0xD] ^= s15); \ + cC = (sc->h[0xC] ^= s14); \ + cB = (sc->h[0xB] ^= s13); \ + cA = (sc->h[0xA] ^= s12); \ + c9 = (sc->h[0x9] ^= s11); \ + c8 = (sc->h[0x8] ^= s10); \ + c7 = (sc->h[0x7] ^= s07); \ + c6 = (sc->h[0x6] ^= s06); \ + c5 = (sc->h[0x5] ^= s05); \ + c4 = (sc->h[0x4] ^= s04); \ + c3 = (sc->h[0x3] ^= s03); \ + c2 = (sc->h[0x2] ^= s02); \ + c1 = (sc->h[0x1] ^= s01); \ + c0 = (sc->h[0x0] ^= s00); \ + } while (0) + +static void +hamsi_big(sph_hamsi_big_context *sc, const unsigned char *buf, size_t num) +{ + DECL_STATE_BIG +#if !SPH_64 + sph_u32 tmp; +#endif + +#if SPH_64 + sc->count += (sph_u64)num << 6; +#else + tmp = SPH_T32((sph_u32)num << 6); + sc->count_low = SPH_T32(sc->count_low + tmp); + sc->count_high += (sph_u32)((num >> 13) >> 13); + if (sc->count_low < tmp) + sc->count_high ++; +#endif + READ_STATE_BIG(sc); + while (num -- > 0) { + sph_u32 m0, m1, m2, m3, m4, m5, m6, m7; + sph_u32 m8, m9, mA, mB, mC, mD, mE, mF; + + INPUT_BIG; + P_BIG; + T_BIG; + buf += 8; + } + WRITE_STATE_BIG(sc); +} + +static void +hamsi_big_final(sph_hamsi_big_context *sc, const unsigned char *buf) +{ + sph_u32 m0, m1, m2, m3, m4, m5, m6, m7; + sph_u32 m8, m9, mA, mB, mC, mD, mE, mF; + DECL_STATE_BIG + + READ_STATE_BIG(sc); + INPUT_BIG; + PF_BIG; + T_BIG; + WRITE_STATE_BIG(sc); +} + +static void +hamsi_big_init(sph_hamsi_big_context *sc, const sph_u32 *iv) +{ + sc->partial_len = 0; + memcpy(sc->h, iv, sizeof sc->h); +#if SPH_64 + sc->count = 0; +#else + sc->count_high = sc->count_low = 0; +#endif +} + +static void +hamsi_big_core(sph_hamsi_big_context *sc, const void *data, size_t len) +{ + if (sc->partial_len != 0) { + size_t mlen; + + mlen = 8 - sc->partial_len; + if (len < mlen) { + memcpy(sc->partial + sc->partial_len, data, len); + sc->partial_len += len; + return; + } else { + memcpy(sc->partial + sc->partial_len, data, mlen); + len -= mlen; + data = (const unsigned char *)data + mlen; + hamsi_big(sc, sc->partial, 1); + sc->partial_len = 0; + } + } + + hamsi_big(sc, data, (len >> 3)); + data = (const unsigned char *)data + (len & ~(size_t)7); + len &= (size_t)7; + memcpy(sc->partial, data, len); + sc->partial_len = len; +} + +static void +hamsi_big_close(sph_hamsi_big_context *sc, + unsigned ub, unsigned n, void *dst, size_t out_size_w32) +{ + unsigned char pad[8]; + size_t ptr, u; + unsigned z; + unsigned char *out; + + ptr = sc->partial_len; +#if SPH_64 + sph_enc64be(pad, sc->count + (ptr << 3) + n); +#else + sph_enc32be(pad, sc->count_high); + sph_enc32be(pad + 4, sc->count_low + (ptr << 3) + n); +#endif + z = 0x80 >> n; + sc->partial[ptr ++] = ((ub & -z) | z) & 0xFF; + while (ptr < 8) + sc->partial[ptr ++] = 0; + hamsi_big(sc, sc->partial, 1); + hamsi_big_final(sc, pad); + out = dst; + if (out_size_w32 == 12) { + sph_enc32be(out + 0, sc->h[ 0]); + sph_enc32be(out + 4, sc->h[ 1]); + sph_enc32be(out + 8, sc->h[ 3]); + sph_enc32be(out + 12, sc->h[ 4]); + sph_enc32be(out + 16, sc->h[ 5]); + sph_enc32be(out + 20, sc->h[ 6]); + sph_enc32be(out + 24, sc->h[ 8]); + sph_enc32be(out + 28, sc->h[ 9]); + sph_enc32be(out + 32, sc->h[10]); + sph_enc32be(out + 36, sc->h[12]); + sph_enc32be(out + 40, sc->h[13]); + sph_enc32be(out + 44, sc->h[15]); + } else { + for (u = 0; u < 16; u ++) + sph_enc32be(out + (u << 2), sc->h[u]); + } +} + +/* see sph_hamsi.h */ +void +sph_hamsi224_init(void *cc) +{ + hamsi_small_init(cc, IV224); +} + +/* see sph_hamsi.h */ +void +sph_hamsi224(void *cc, const void *data, size_t len) +{ + hamsi_small_core(cc, data, len); +} + +/* see sph_hamsi.h */ +void +sph_hamsi224_close(void *cc, void *dst) +{ + hamsi_small_close(cc, 0, 0, dst, 7); + hamsi_small_init(cc, IV224); +} + +/* see sph_hamsi.h */ +void +sph_hamsi224_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + hamsi_small_close(cc, ub, n, dst, 7); + hamsi_small_init(cc, IV224); +} + +/* see sph_hamsi.h */ +void +sph_hamsi256_init(void *cc) +{ + hamsi_small_init(cc, IV256); +} + +/* see sph_hamsi.h */ +void +sph_hamsi256(void *cc, const void *data, size_t len) +{ + hamsi_small_core(cc, data, len); +} + +/* see sph_hamsi.h */ +void +sph_hamsi256_close(void *cc, void *dst) +{ + hamsi_small_close(cc, 0, 0, dst, 8); + hamsi_small_init(cc, IV256); +} + +/* see sph_hamsi.h */ +void +sph_hamsi256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + hamsi_small_close(cc, ub, n, dst, 8); + hamsi_small_init(cc, IV256); +} + +/* see sph_hamsi.h */ +void +sph_hamsi384_init(void *cc) +{ + hamsi_big_init(cc, IV384); +} + +/* see sph_hamsi.h */ +void +sph_hamsi384(void *cc, const void *data, size_t len) +{ + hamsi_big_core(cc, data, len); +} + +/* see sph_hamsi.h */ +void +sph_hamsi384_close(void *cc, void *dst) +{ + hamsi_big_close(cc, 0, 0, dst, 12); + hamsi_big_init(cc, IV384); +} + +/* see sph_hamsi.h */ +void +sph_hamsi384_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + hamsi_big_close(cc, ub, n, dst, 12); + hamsi_big_init(cc, IV384); +} + +/* see sph_hamsi.h */ +void +sph_hamsi512_init(void *cc) +{ + hamsi_big_init(cc, IV512); +} + +/* see sph_hamsi.h */ +void +sph_hamsi512(void *cc, const void *data, size_t len) +{ + hamsi_big_core(cc, data, len); +} + +/* see sph_hamsi.h */ +void +sph_hamsi512_close(void *cc, void *dst) +{ + hamsi_big_close(cc, 0, 0, dst, 16); + hamsi_big_init(cc, IV512); +} + +/* see sph_hamsi.h */ +void +sph_hamsi512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + hamsi_big_close(cc, ub, n, dst, 16); + hamsi_big_init(cc, IV512); +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/src/obj/skunkhash/hamsi_helper.c b/src/obj/skunkhash/hamsi_helper.c new file mode 100644 index 0000000..0c7a51b --- /dev/null +++ b/src/obj/skunkhash/hamsi_helper.c @@ -0,0 +1,39648 @@ +/* $Id: hamsi_helper.c 202 2010-05-31 15:46:48Z tp $ */ +/* + * Helper code for Hamsi (input block expansion). This code is + * automatically generated and includes precomputed tables for + * expansion code which handles 2 to 8 bits at a time. + * + * This file is included from hamsi.c, and is not meant to be compiled + * independently. + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @author Thomas Pornin + */ + +#ifdef __cplusplus +extern "C"{ +#endif + +#if SPH_HAMSI_EXPAND_SMALL == 1 + +/* Note: this table lists bits within each byte from least + siginificant to most significant. */ +static const sph_u32 T256[32][8] = { + { SPH_C32(0x74951000), SPH_C32(0x5a2b467e), SPH_C32(0x88fd1d2b), + SPH_C32(0x1ee68292), SPH_C32(0xcba90000), SPH_C32(0x90273769), + SPH_C32(0xbbdcf407), SPH_C32(0xd0f4af61) }, + { SPH_C32(0xcba90000), SPH_C32(0x90273769), SPH_C32(0xbbdcf407), + SPH_C32(0xd0f4af61), SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), + SPH_C32(0x3321e92c), SPH_C32(0xce122df3) }, + { SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), SPH_C32(0x11fa3a57), + SPH_C32(0x3dc90524), SPH_C32(0x97530000), SPH_C32(0x204f6ed3), + SPH_C32(0x77b9e80f), SPH_C32(0xa1ec5ec1) }, + { SPH_C32(0x97530000), SPH_C32(0x204f6ed3), SPH_C32(0x77b9e80f), + SPH_C32(0xa1ec5ec1), SPH_C32(0x7e792000), SPH_C32(0x9418e22f), + SPH_C32(0x6643d258), SPH_C32(0x9c255be5) }, + { SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), SPH_C32(0x8dfacfab), + SPH_C32(0xce36cc72), SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), + SPH_C32(0x848598ba), SPH_C32(0x1041003e) }, + { SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), SPH_C32(0x848598ba), + SPH_C32(0x1041003e), SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), + SPH_C32(0x097f5711), SPH_C32(0xde77cc4c) }, + { SPH_C32(0xe4788000), SPH_C32(0x859673c1), SPH_C32(0xb5fb2452), + SPH_C32(0x29cc5edf), SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), + SPH_C32(0x62fc79d0), SPH_C32(0x731ebdc2) }, + { SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), SPH_C32(0x62fc79d0), + SPH_C32(0x731ebdc2), SPH_C32(0xe0278000), SPH_C32(0x19dce008), + SPH_C32(0xd7075d82), SPH_C32(0x5ad2e31d) }, + { SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), SPH_C32(0x8589d8ab), + SPH_C32(0xe6c46464), SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), + SPH_C32(0xa29d1297), SPH_C32(0x6ee56854) }, + { SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), SPH_C32(0xa29d1297), + SPH_C32(0x6ee56854), SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), + SPH_C32(0x2714ca3c), SPH_C32(0x88210c30) }, + { SPH_C32(0xa7b80200), SPH_C32(0x1f128433), SPH_C32(0x60e5f9f2), + SPH_C32(0x9e147576), SPH_C32(0xee260000), SPH_C32(0x124b683e), + SPH_C32(0x80c2d68f), SPH_C32(0x3bf3ab2c) }, + { SPH_C32(0xee260000), SPH_C32(0x124b683e), SPH_C32(0x80c2d68f), + SPH_C32(0x3bf3ab2c), SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), + SPH_C32(0xe0272f7d), SPH_C32(0xa5e7de5a) }, + { SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), SPH_C32(0x6fc548e1), + SPH_C32(0x898d2cd6), SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), + SPH_C32(0x6a72e5bb), SPH_C32(0x247febe6) }, + { SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), SPH_C32(0x6a72e5bb), + SPH_C32(0x247febe6), SPH_C32(0x9b830400), SPH_C32(0x2227ff88), + SPH_C32(0x05b7ad5a), SPH_C32(0xadf2c730) }, + { SPH_C32(0xde320800), SPH_C32(0x288350fe), SPH_C32(0x71852ac7), + SPH_C32(0xa6bf9f96), SPH_C32(0xe18b0000), SPH_C32(0x5459887d), + SPH_C32(0xbf1283d3), SPH_C32(0x1b666a73) }, + { SPH_C32(0xe18b0000), SPH_C32(0x5459887d), SPH_C32(0xbf1283d3), + SPH_C32(0x1b666a73), SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), + SPH_C32(0xce97a914), SPH_C32(0xbdd9f5e5) }, + { SPH_C32(0x515c0010), SPH_C32(0x40f372fb), SPH_C32(0xfce72602), + SPH_C32(0x71575061), SPH_C32(0x2e390000), SPH_C32(0x64dd6689), + SPH_C32(0x3cd406fc), SPH_C32(0xb1f490bc) }, + { SPH_C32(0x2e390000), SPH_C32(0x64dd6689), SPH_C32(0x3cd406fc), + SPH_C32(0xb1f490bc), SPH_C32(0x7f650010), SPH_C32(0x242e1472), + SPH_C32(0xc03320fe), SPH_C32(0xc0a3c0dd) }, + { SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), SPH_C32(0xf9ce4c04), + SPH_C32(0xe2afa0c0), SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), + SPH_C32(0x79a90df9), SPH_C32(0x63e92178) }, + { SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), SPH_C32(0x79a90df9), + SPH_C32(0x63e92178), SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), + SPH_C32(0x806741fd), SPH_C32(0x814681b8) }, + { SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), SPH_C32(0x36656ba8), + SPH_C32(0x23633a05), SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), + SPH_C32(0x5d5ca0f7), SPH_C32(0x727784cb) }, + { SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), SPH_C32(0x5d5ca0f7), + SPH_C32(0x727784cb), SPH_C32(0x35650040), SPH_C32(0x9b96b64a), + SPH_C32(0x6b39cb5f), SPH_C32(0x5114bece) }, + { SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), SPH_C32(0xc2c46c55), + SPH_C32(0xf362b233), SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), + SPH_C32(0xd14e094b), SPH_C32(0xb772b42b) }, + { SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), SPH_C32(0xd14e094b), + SPH_C32(0xb772b42b), SPH_C32(0x62740080), SPH_C32(0x0fb84b07), + SPH_C32(0x138a651e), SPH_C32(0x44100618) }, + { SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), SPH_C32(0xae0ebb05), + SPH_C32(0xb5a4c63b), SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), + SPH_C32(0x6bf648a4), SPH_C32(0x539cbdbf) }, + { SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), SPH_C32(0x6bf648a4), + SPH_C32(0x539cbdbf), SPH_C32(0x08bf0001), SPH_C32(0x38942792), + SPH_C32(0xc5f8f3a1), SPH_C32(0xe6387b84) }, + { SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), SPH_C32(0x99e585aa), + SPH_C32(0x8d75f7f1), SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), + SPH_C32(0x79e22a4c), SPH_C32(0x1298bd46) }, + { SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), SPH_C32(0x79e22a4c), + SPH_C32(0x1298bd46), SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), + SPH_C32(0xe007afe6), SPH_C32(0x9fed4ab7) }, + { SPH_C32(0xd0080004), SPH_C32(0x8c768f77), SPH_C32(0x9dc5b050), + SPH_C32(0xaf4a29da), SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), + SPH_C32(0x98321c3d), SPH_C32(0x76acc733) }, + { SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), SPH_C32(0x98321c3d), + SPH_C32(0x76acc733), SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), + SPH_C32(0x05f7ac6d), SPH_C32(0xd9e6eee9) }, + { SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), SPH_C32(0xfe739301), + SPH_C32(0xb8a92831), SPH_C32(0x171c0000), SPH_C32(0xb26e3344), + SPH_C32(0x9e6a837e), SPH_C32(0x58f8485f) }, + { SPH_C32(0x171c0000), SPH_C32(0xb26e3344), SPH_C32(0x9e6a837e), + SPH_C32(0x58f8485f), SPH_C32(0xbfb20008), SPH_C32(0x92170a39), + SPH_C32(0x6019107f), SPH_C32(0xe051606e) } +}; + +#define INPUT_SMALL do { \ + const sph_u32 *tp = &T256[0][0]; \ + unsigned u, v; \ + m0 = 0; \ + m1 = 0; \ + m2 = 0; \ + m3 = 0; \ + m4 = 0; \ + m5 = 0; \ + m6 = 0; \ + m7 = 0; \ + for (u = 0; u < 4; u ++) { \ + unsigned db = buf[u]; \ + for (v = 0; v < 8; v ++, db >>= 1) { \ + sph_u32 dm = SPH_T32(-(sph_u32)(db & 1)); \ + m0 ^= dm & *tp ++; \ + m1 ^= dm & *tp ++; \ + m2 ^= dm & *tp ++; \ + m3 ^= dm & *tp ++; \ + m4 ^= dm & *tp ++; \ + m5 ^= dm & *tp ++; \ + m6 ^= dm & *tp ++; \ + m7 ^= dm & *tp ++; \ + } \ + } \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_SMALL == 2 + +static const sph_u32 T256_0[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xe4788000), SPH_C32(0x859673c1), SPH_C32(0xb5fb2452), + SPH_C32(0x29cc5edf), SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), + SPH_C32(0x62fc79d0), SPH_C32(0x731ebdc2) }, + { SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), SPH_C32(0x62fc79d0), + SPH_C32(0x731ebdc2), SPH_C32(0xe0278000), SPH_C32(0x19dce008), + SPH_C32(0xd7075d82), SPH_C32(0x5ad2e31d) }, + { SPH_C32(0xe0278000), SPH_C32(0x19dce008), SPH_C32(0xd7075d82), + SPH_C32(0x5ad2e31d), SPH_C32(0xe4788000), SPH_C32(0x859673c1), + SPH_C32(0xb5fb2452), SPH_C32(0x29cc5edf) } +}; + +static const sph_u32 T256_2[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), SPH_C32(0x8dfacfab), + SPH_C32(0xce36cc72), SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), + SPH_C32(0x848598ba), SPH_C32(0x1041003e) }, + { SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), SPH_C32(0x848598ba), + SPH_C32(0x1041003e), SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), + SPH_C32(0x097f5711), SPH_C32(0xde77cc4c) }, + { SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), SPH_C32(0x097f5711), + SPH_C32(0xde77cc4c), SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), + SPH_C32(0x8dfacfab), SPH_C32(0xce36cc72) } +}; + +static const sph_u32 T256_4[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), SPH_C32(0x11fa3a57), + SPH_C32(0x3dc90524), SPH_C32(0x97530000), SPH_C32(0x204f6ed3), + SPH_C32(0x77b9e80f), SPH_C32(0xa1ec5ec1) }, + { SPH_C32(0x97530000), SPH_C32(0x204f6ed3), SPH_C32(0x77b9e80f), + SPH_C32(0xa1ec5ec1), SPH_C32(0x7e792000), SPH_C32(0x9418e22f), + SPH_C32(0x6643d258), SPH_C32(0x9c255be5) }, + { SPH_C32(0x7e792000), SPH_C32(0x9418e22f), SPH_C32(0x6643d258), + SPH_C32(0x9c255be5), SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), + SPH_C32(0x11fa3a57), SPH_C32(0x3dc90524) } +}; + +static const sph_u32 T256_6[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x74951000), SPH_C32(0x5a2b467e), SPH_C32(0x88fd1d2b), + SPH_C32(0x1ee68292), SPH_C32(0xcba90000), SPH_C32(0x90273769), + SPH_C32(0xbbdcf407), SPH_C32(0xd0f4af61) }, + { SPH_C32(0xcba90000), SPH_C32(0x90273769), SPH_C32(0xbbdcf407), + SPH_C32(0xd0f4af61), SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), + SPH_C32(0x3321e92c), SPH_C32(0xce122df3) }, + { SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), SPH_C32(0x3321e92c), + SPH_C32(0xce122df3), SPH_C32(0x74951000), SPH_C32(0x5a2b467e), + SPH_C32(0x88fd1d2b), SPH_C32(0x1ee68292) } +}; + +static const sph_u32 T256_8[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xde320800), SPH_C32(0x288350fe), SPH_C32(0x71852ac7), + SPH_C32(0xa6bf9f96), SPH_C32(0xe18b0000), SPH_C32(0x5459887d), + SPH_C32(0xbf1283d3), SPH_C32(0x1b666a73) }, + { SPH_C32(0xe18b0000), SPH_C32(0x5459887d), SPH_C32(0xbf1283d3), + SPH_C32(0x1b666a73), SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), + SPH_C32(0xce97a914), SPH_C32(0xbdd9f5e5) }, + { SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), SPH_C32(0xce97a914), + SPH_C32(0xbdd9f5e5), SPH_C32(0xde320800), SPH_C32(0x288350fe), + SPH_C32(0x71852ac7), SPH_C32(0xa6bf9f96) } +}; + +static const sph_u32 T256_10[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), SPH_C32(0x6fc548e1), + SPH_C32(0x898d2cd6), SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), + SPH_C32(0x6a72e5bb), SPH_C32(0x247febe6) }, + { SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), SPH_C32(0x6a72e5bb), + SPH_C32(0x247febe6), SPH_C32(0x9b830400), SPH_C32(0x2227ff88), + SPH_C32(0x05b7ad5a), SPH_C32(0xadf2c730) }, + { SPH_C32(0x9b830400), SPH_C32(0x2227ff88), SPH_C32(0x05b7ad5a), + SPH_C32(0xadf2c730), SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), + SPH_C32(0x6fc548e1), SPH_C32(0x898d2cd6) } +}; + +static const sph_u32 T256_12[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xa7b80200), SPH_C32(0x1f128433), SPH_C32(0x60e5f9f2), + SPH_C32(0x9e147576), SPH_C32(0xee260000), SPH_C32(0x124b683e), + SPH_C32(0x80c2d68f), SPH_C32(0x3bf3ab2c) }, + { SPH_C32(0xee260000), SPH_C32(0x124b683e), SPH_C32(0x80c2d68f), + SPH_C32(0x3bf3ab2c), SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), + SPH_C32(0xe0272f7d), SPH_C32(0xa5e7de5a) }, + { SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), SPH_C32(0xe0272f7d), + SPH_C32(0xa5e7de5a), SPH_C32(0xa7b80200), SPH_C32(0x1f128433), + SPH_C32(0x60e5f9f2), SPH_C32(0x9e147576) } +}; + +static const sph_u32 T256_14[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), SPH_C32(0x8589d8ab), + SPH_C32(0xe6c46464), SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), + SPH_C32(0xa29d1297), SPH_C32(0x6ee56854) }, + { SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), SPH_C32(0xa29d1297), + SPH_C32(0x6ee56854), SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), + SPH_C32(0x2714ca3c), SPH_C32(0x88210c30) }, + { SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), SPH_C32(0x2714ca3c), + SPH_C32(0x88210c30), SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), + SPH_C32(0x8589d8ab), SPH_C32(0xe6c46464) } +}; + +static const sph_u32 T256_16[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), SPH_C32(0xc2c46c55), + SPH_C32(0xf362b233), SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), + SPH_C32(0xd14e094b), SPH_C32(0xb772b42b) }, + { SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), SPH_C32(0xd14e094b), + SPH_C32(0xb772b42b), SPH_C32(0x62740080), SPH_C32(0x0fb84b07), + SPH_C32(0x138a651e), SPH_C32(0x44100618) }, + { SPH_C32(0x62740080), SPH_C32(0x0fb84b07), SPH_C32(0x138a651e), + SPH_C32(0x44100618), SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), + SPH_C32(0xc2c46c55), SPH_C32(0xf362b233) } +}; + +static const sph_u32 T256_18[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), SPH_C32(0x36656ba8), + SPH_C32(0x23633a05), SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), + SPH_C32(0x5d5ca0f7), SPH_C32(0x727784cb) }, + { SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), SPH_C32(0x5d5ca0f7), + SPH_C32(0x727784cb), SPH_C32(0x35650040), SPH_C32(0x9b96b64a), + SPH_C32(0x6b39cb5f), SPH_C32(0x5114bece) }, + { SPH_C32(0x35650040), SPH_C32(0x9b96b64a), SPH_C32(0x6b39cb5f), + SPH_C32(0x5114bece), SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), + SPH_C32(0x36656ba8), SPH_C32(0x23633a05) } +}; + +static const sph_u32 T256_20[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), SPH_C32(0xf9ce4c04), + SPH_C32(0xe2afa0c0), SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), + SPH_C32(0x79a90df9), SPH_C32(0x63e92178) }, + { SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), SPH_C32(0x79a90df9), + SPH_C32(0x63e92178), SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), + SPH_C32(0x806741fd), SPH_C32(0x814681b8) }, + { SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), SPH_C32(0x806741fd), + SPH_C32(0x814681b8), SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), + SPH_C32(0xf9ce4c04), SPH_C32(0xe2afa0c0) } +}; + +static const sph_u32 T256_22[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x515c0010), SPH_C32(0x40f372fb), SPH_C32(0xfce72602), + SPH_C32(0x71575061), SPH_C32(0x2e390000), SPH_C32(0x64dd6689), + SPH_C32(0x3cd406fc), SPH_C32(0xb1f490bc) }, + { SPH_C32(0x2e390000), SPH_C32(0x64dd6689), SPH_C32(0x3cd406fc), + SPH_C32(0xb1f490bc), SPH_C32(0x7f650010), SPH_C32(0x242e1472), + SPH_C32(0xc03320fe), SPH_C32(0xc0a3c0dd) }, + { SPH_C32(0x7f650010), SPH_C32(0x242e1472), SPH_C32(0xc03320fe), + SPH_C32(0xc0a3c0dd), SPH_C32(0x515c0010), SPH_C32(0x40f372fb), + SPH_C32(0xfce72602), SPH_C32(0x71575061) } +}; + +static const sph_u32 T256_24[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), SPH_C32(0xfe739301), + SPH_C32(0xb8a92831), SPH_C32(0x171c0000), SPH_C32(0xb26e3344), + SPH_C32(0x9e6a837e), SPH_C32(0x58f8485f) }, + { SPH_C32(0x171c0000), SPH_C32(0xb26e3344), SPH_C32(0x9e6a837e), + SPH_C32(0x58f8485f), SPH_C32(0xbfb20008), SPH_C32(0x92170a39), + SPH_C32(0x6019107f), SPH_C32(0xe051606e) }, + { SPH_C32(0xbfb20008), SPH_C32(0x92170a39), SPH_C32(0x6019107f), + SPH_C32(0xe051606e), SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), + SPH_C32(0xfe739301), SPH_C32(0xb8a92831) } +}; + +static const sph_u32 T256_26[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xd0080004), SPH_C32(0x8c768f77), SPH_C32(0x9dc5b050), + SPH_C32(0xaf4a29da), SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), + SPH_C32(0x98321c3d), SPH_C32(0x76acc733) }, + { SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), SPH_C32(0x98321c3d), + SPH_C32(0x76acc733), SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), + SPH_C32(0x05f7ac6d), SPH_C32(0xd9e6eee9) }, + { SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), SPH_C32(0x05f7ac6d), + SPH_C32(0xd9e6eee9), SPH_C32(0xd0080004), SPH_C32(0x8c768f77), + SPH_C32(0x9dc5b050), SPH_C32(0xaf4a29da) } +}; + +static const sph_u32 T256_28[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), SPH_C32(0x99e585aa), + SPH_C32(0x8d75f7f1), SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), + SPH_C32(0x79e22a4c), SPH_C32(0x1298bd46) }, + { SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), SPH_C32(0x79e22a4c), + SPH_C32(0x1298bd46), SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), + SPH_C32(0xe007afe6), SPH_C32(0x9fed4ab7) }, + { SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), SPH_C32(0xe007afe6), + SPH_C32(0x9fed4ab7), SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), + SPH_C32(0x99e585aa), SPH_C32(0x8d75f7f1) } +}; + +static const sph_u32 T256_30[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), SPH_C32(0xae0ebb05), + SPH_C32(0xb5a4c63b), SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), + SPH_C32(0x6bf648a4), SPH_C32(0x539cbdbf) }, + { SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), SPH_C32(0x6bf648a4), + SPH_C32(0x539cbdbf), SPH_C32(0x08bf0001), SPH_C32(0x38942792), + SPH_C32(0xc5f8f3a1), SPH_C32(0xe6387b84) }, + { SPH_C32(0x08bf0001), SPH_C32(0x38942792), SPH_C32(0xc5f8f3a1), + SPH_C32(0xe6387b84), SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), + SPH_C32(0xae0ebb05), SPH_C32(0xb5a4c63b) } +}; + +#define INPUT_SMALL do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T256_0[acc >> 6][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + rp = &T256_2[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_4[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_6[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = buf[1]; \ + rp = &T256_8[acc >> 6][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_10[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_12[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_14[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = buf[2]; \ + rp = &T256_16[acc >> 6][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_18[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_20[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_22[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = buf[3]; \ + rp = &T256_24[acc >> 6][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_26[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_28[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_30[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_SMALL == 3 + +static const sph_u32 T256_0[8][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), SPH_C32(0x848598ba), + SPH_C32(0x1041003e), SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), + SPH_C32(0x097f5711), SPH_C32(0xde77cc4c) }, + { SPH_C32(0xe4788000), SPH_C32(0x859673c1), SPH_C32(0xb5fb2452), + SPH_C32(0x29cc5edf), SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), + SPH_C32(0x62fc79d0), SPH_C32(0x731ebdc2) }, + { SPH_C32(0x022f8000), SPH_C32(0xce2549e4), SPH_C32(0x317ebce8), + SPH_C32(0x398d5ee1), SPH_C32(0xf0134000), SPH_C32(0x8cee7004), + SPH_C32(0x6b832ec1), SPH_C32(0xad69718e) }, + { SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), SPH_C32(0x62fc79d0), + SPH_C32(0x731ebdc2), SPH_C32(0xe0278000), SPH_C32(0x19dce008), + SPH_C32(0xd7075d82), SPH_C32(0x5ad2e31d) }, + { SPH_C32(0xe2080000), SPH_C32(0xd7f9a9ec), SPH_C32(0xe679e16a), + SPH_C32(0x635fbdfc), SPH_C32(0x146bc000), SPH_C32(0x097803c5), + SPH_C32(0xde780a93), SPH_C32(0x84a52f51) }, + { SPH_C32(0xe0278000), SPH_C32(0x19dce008), SPH_C32(0xd7075d82), + SPH_C32(0x5ad2e31d), SPH_C32(0xe4788000), SPH_C32(0x859673c1), + SPH_C32(0xb5fb2452), SPH_C32(0x29cc5edf) }, + { SPH_C32(0x06708000), SPH_C32(0x526fda2d), SPH_C32(0x5382c538), + SPH_C32(0x4a93e323), SPH_C32(0x1034c000), SPH_C32(0x9532900c), + SPH_C32(0xbc847343), SPH_C32(0xf7bb9293) } +}; + +static const sph_u32 T256_3[8][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), SPH_C32(0x11fa3a57), + SPH_C32(0x3dc90524), SPH_C32(0x97530000), SPH_C32(0x204f6ed3), + SPH_C32(0x77b9e80f), SPH_C32(0xa1ec5ec1) }, + { SPH_C32(0x97530000), SPH_C32(0x204f6ed3), SPH_C32(0x77b9e80f), + SPH_C32(0xa1ec5ec1), SPH_C32(0x7e792000), SPH_C32(0x9418e22f), + SPH_C32(0x6643d258), SPH_C32(0x9c255be5) }, + { SPH_C32(0x7e792000), SPH_C32(0x9418e22f), SPH_C32(0x6643d258), + SPH_C32(0x9c255be5), SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), + SPH_C32(0x11fa3a57), SPH_C32(0x3dc90524) }, + { SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), SPH_C32(0x8dfacfab), + SPH_C32(0xce36cc72), SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), + SPH_C32(0x848598ba), SPH_C32(0x1041003e) }, + { SPH_C32(0xfb316000), SPH_C32(0xef405514), SPH_C32(0x9c00f5fc), + SPH_C32(0xf3ffc956), SPH_C32(0x71040000), SPH_C32(0x6bfc54f6), + SPH_C32(0xf33c70b5), SPH_C32(0xb1ad5eff) }, + { SPH_C32(0x85484000), SPH_C32(0x7b58b73b), SPH_C32(0xfa4327a4), + SPH_C32(0x6fda92b3), SPH_C32(0x982e2000), SPH_C32(0xdfabd80a), + SPH_C32(0xe2c64ae2), SPH_C32(0x8c645bdb) }, + { SPH_C32(0x6c626000), SPH_C32(0xcf0f3bc7), SPH_C32(0xebb91df3), + SPH_C32(0x52139797), SPH_C32(0x0f7d2000), SPH_C32(0xffe4b6d9), + SPH_C32(0x957fa2ed), SPH_C32(0x2d88051a) } +}; + +static const sph_u32 T256_6[8][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xe18b0000), SPH_C32(0x5459887d), SPH_C32(0xbf1283d3), + SPH_C32(0x1b666a73), SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), + SPH_C32(0xce97a914), SPH_C32(0xbdd9f5e5) }, + { SPH_C32(0x74951000), SPH_C32(0x5a2b467e), SPH_C32(0x88fd1d2b), + SPH_C32(0x1ee68292), SPH_C32(0xcba90000), SPH_C32(0x90273769), + SPH_C32(0xbbdcf407), SPH_C32(0xd0f4af61) }, + { SPH_C32(0x951e1000), SPH_C32(0x0e72ce03), SPH_C32(0x37ef9ef8), + SPH_C32(0x0580e8e1), SPH_C32(0xf4100800), SPH_C32(0xecfdefea), + SPH_C32(0x754b5d13), SPH_C32(0x6d2d5a84) }, + { SPH_C32(0xcba90000), SPH_C32(0x90273769), SPH_C32(0xbbdcf407), + SPH_C32(0xd0f4af61), SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), + SPH_C32(0x3321e92c), SPH_C32(0xce122df3) }, + { SPH_C32(0x2a220000), SPH_C32(0xc47ebf14), SPH_C32(0x04ce77d4), + SPH_C32(0xcb92c512), SPH_C32(0x80851800), SPH_C32(0xb6d6a994), + SPH_C32(0xfdb64038), SPH_C32(0x73cbd816) }, + { SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), SPH_C32(0x3321e92c), + SPH_C32(0xce122df3), SPH_C32(0x74951000), SPH_C32(0x5a2b467e), + SPH_C32(0x88fd1d2b), SPH_C32(0x1ee68292) }, + { SPH_C32(0x5eb71000), SPH_C32(0x9e55f96a), SPH_C32(0x8c336aff), + SPH_C32(0xd5744780), SPH_C32(0x4b2c1800), SPH_C32(0x26f19efd), + SPH_C32(0x466ab43f), SPH_C32(0xa33f7777) } +}; + +static const sph_u32 T256_9[8][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), SPH_C32(0x6fc548e1), + SPH_C32(0x898d2cd6), SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), + SPH_C32(0x6a72e5bb), SPH_C32(0x247febe6) }, + { SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), SPH_C32(0x6a72e5bb), + SPH_C32(0x247febe6), SPH_C32(0x9b830400), SPH_C32(0x2227ff88), + SPH_C32(0x05b7ad5a), SPH_C32(0xadf2c730) }, + { SPH_C32(0x9b830400), SPH_C32(0x2227ff88), SPH_C32(0x05b7ad5a), + SPH_C32(0xadf2c730), SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), + SPH_C32(0x6fc548e1), SPH_C32(0x898d2cd6) }, + { SPH_C32(0xde320800), SPH_C32(0x288350fe), SPH_C32(0x71852ac7), + SPH_C32(0xa6bf9f96), SPH_C32(0xe18b0000), SPH_C32(0x5459887d), + SPH_C32(0xbf1283d3), SPH_C32(0x1b666a73) }, + { SPH_C32(0x510c0c00), SPH_C32(0x251e9889), SPH_C32(0x1e406226), + SPH_C32(0x2f32b340), SPH_C32(0xf5360000), SPH_C32(0x7be3bf82), + SPH_C32(0xd5606668), SPH_C32(0x3f198195) }, + { SPH_C32(0xca8f0800), SPH_C32(0x07396701), SPH_C32(0x1bf7cf7c), + SPH_C32(0x82c07470), SPH_C32(0x7a080400), SPH_C32(0x767e77f5), + SPH_C32(0xbaa52e89), SPH_C32(0xb694ad43) }, + { SPH_C32(0x45b10c00), SPH_C32(0x0aa4af76), SPH_C32(0x7432879d), + SPH_C32(0x0b4d58a6), SPH_C32(0x6eb50400), SPH_C32(0x59c4400a), + SPH_C32(0xd0d7cb32), SPH_C32(0x92eb46a5) } +}; + +static const sph_u32 T256_12[8][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), SPH_C32(0xa29d1297), + SPH_C32(0x6ee56854), SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), + SPH_C32(0x2714ca3c), SPH_C32(0x88210c30) }, + { SPH_C32(0xa7b80200), SPH_C32(0x1f128433), SPH_C32(0x60e5f9f2), + SPH_C32(0x9e147576), SPH_C32(0xee260000), SPH_C32(0x124b683e), + SPH_C32(0x80c2d68f), SPH_C32(0x3bf3ab2c) }, + { SPH_C32(0xd4f40200), SPH_C32(0x8a7d23e5), SPH_C32(0xc278eb65), + SPH_C32(0xf0f11d22), SPH_C32(0x2ace0100), SPH_C32(0x0d3bfe30), + SPH_C32(0xa7d61cb3), SPH_C32(0xb3d2a71c) }, + { SPH_C32(0xee260000), SPH_C32(0x124b683e), SPH_C32(0x80c2d68f), + SPH_C32(0x3bf3ab2c), SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), + SPH_C32(0xe0272f7d), SPH_C32(0xa5e7de5a) }, + { SPH_C32(0x9d6a0000), SPH_C32(0x8724cfe8), SPH_C32(0x225fc418), + SPH_C32(0x5516c378), SPH_C32(0x8d760300), SPH_C32(0x12297a03), + SPH_C32(0xc733e541), SPH_C32(0x2dc6d26a) }, + { SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), SPH_C32(0xe0272f7d), + SPH_C32(0xa5e7de5a), SPH_C32(0xa7b80200), SPH_C32(0x1f128433), + SPH_C32(0x60e5f9f2), SPH_C32(0x9e147576) }, + { SPH_C32(0x3ad20200), SPH_C32(0x98364bdb), SPH_C32(0x42ba3dea), + SPH_C32(0xcb02b60e), SPH_C32(0x63500300), SPH_C32(0x0062123d), + SPH_C32(0x47f133ce), SPH_C32(0x16357946) } +}; + +static const sph_u32 T256_15[8][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), SPH_C32(0xc2c46c55), + SPH_C32(0xf362b233), SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), + SPH_C32(0xd14e094b), SPH_C32(0xb772b42b) }, + { SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), SPH_C32(0xd14e094b), + SPH_C32(0xb772b42b), SPH_C32(0x62740080), SPH_C32(0x0fb84b07), + SPH_C32(0x138a651e), SPH_C32(0x44100618) }, + { SPH_C32(0x62740080), SPH_C32(0x0fb84b07), SPH_C32(0x138a651e), + SPH_C32(0x44100618), SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), + SPH_C32(0xc2c46c55), SPH_C32(0xf362b233) }, + { SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), SPH_C32(0x8589d8ab), + SPH_C32(0xe6c46464), SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), + SPH_C32(0xa29d1297), SPH_C32(0x6ee56854) }, + { SPH_C32(0xec760180), SPH_C32(0xcf102934), SPH_C32(0x474db4fe), + SPH_C32(0x15a6d657), SPH_C32(0x4aea0000), SPH_C32(0xdfd8f43d), + SPH_C32(0x73d31bdc), SPH_C32(0xd997dc7f) }, + { SPH_C32(0x8e020100), SPH_C32(0xc0a86233), SPH_C32(0x54c7d1e0), + SPH_C32(0x51b6d04f), SPH_C32(0x11380080), SPH_C32(0x9ad7ecd1), + SPH_C32(0xb1177789), SPH_C32(0x2af56e4c) }, + { SPH_C32(0xd5d00180), SPH_C32(0x85a77adf), SPH_C32(0x9603bdb5), + SPH_C32(0xa2d4627c), SPH_C32(0x289e0080), SPH_C32(0xd060bf3a), + SPH_C32(0x60597ec2), SPH_C32(0x9d87da67) } +}; + +static const sph_u32 T256_18[8][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), SPH_C32(0x79a90df9), + SPH_C32(0x63e92178), SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), + SPH_C32(0x806741fd), SPH_C32(0x814681b8) }, + { SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), SPH_C32(0x36656ba8), + SPH_C32(0x23633a05), SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), + SPH_C32(0x5d5ca0f7), SPH_C32(0x727784cb) }, + { SPH_C32(0x11bc0040), SPH_C32(0xf2e1216c), SPH_C32(0x4fcc6651), + SPH_C32(0x408a1b7d), SPH_C32(0x86610020), SPH_C32(0xe89072d0), + SPH_C32(0xdd3be10a), SPH_C32(0xf3310573) }, + { SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), SPH_C32(0x5d5ca0f7), + SPH_C32(0x727784cb), SPH_C32(0x35650040), SPH_C32(0x9b96b64a), + SPH_C32(0x6b39cb5f), SPH_C32(0x5114bece) }, + { SPH_C32(0x24d90000), SPH_C32(0x69779726), SPH_C32(0x24f5ad0e), + SPH_C32(0x119ea5b3), SPH_C32(0xcbaf0060), SPH_C32(0xd3cb9eae), + SPH_C32(0xeb5e8aa2), SPH_C32(0xd0523f76) }, + { SPH_C32(0x35650040), SPH_C32(0x9b96b64a), SPH_C32(0x6b39cb5f), + SPH_C32(0x5114bece), SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), + SPH_C32(0x36656ba8), SPH_C32(0x23633a05) }, + { SPH_C32(0x69170040), SPH_C32(0x522c7b58), SPH_C32(0x1290c6a6), + SPH_C32(0x32fd9fb6), SPH_C32(0xb3040060), SPH_C32(0x7306c49a), + SPH_C32(0xb6022a55), SPH_C32(0xa225bbbd) } +}; + +static const sph_u32 T256_21[8][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x515c0010), SPH_C32(0x40f372fb), SPH_C32(0xfce72602), + SPH_C32(0x71575061), SPH_C32(0x2e390000), SPH_C32(0x64dd6689), + SPH_C32(0x3cd406fc), SPH_C32(0xb1f490bc) }, + { SPH_C32(0x2e390000), SPH_C32(0x64dd6689), SPH_C32(0x3cd406fc), + SPH_C32(0xb1f490bc), SPH_C32(0x7f650010), SPH_C32(0x242e1472), + SPH_C32(0xc03320fe), SPH_C32(0xc0a3c0dd) }, + { SPH_C32(0x7f650010), SPH_C32(0x242e1472), SPH_C32(0xc03320fe), + SPH_C32(0xc0a3c0dd), SPH_C32(0x515c0010), SPH_C32(0x40f372fb), + SPH_C32(0xfce72602), SPH_C32(0x71575061) }, + { SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), SPH_C32(0xf9ce4c04), + SPH_C32(0xe2afa0c0), SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), + SPH_C32(0x79a90df9), SPH_C32(0x63e92178) }, + { SPH_C32(0xf3e40030), SPH_C32(0xc114970d), SPH_C32(0x05296a06), + SPH_C32(0x93f8f0a1), SPH_C32(0x724b0000), SPH_C32(0xad67ab9b), + SPH_C32(0x457d0b05), SPH_C32(0xd21db1c4) }, + { SPH_C32(0x8c810020), SPH_C32(0xe53a837f), SPH_C32(0xc51a4af8), + SPH_C32(0x535b307c), SPH_C32(0x23170010), SPH_C32(0xed94d960), + SPH_C32(0xb99a2d07), SPH_C32(0xa34ae1a5) }, + { SPH_C32(0xdddd0030), SPH_C32(0xa5c9f184), SPH_C32(0x39fd6cfa), + SPH_C32(0x220c601d), SPH_C32(0x0d2e0010), SPH_C32(0x8949bfe9), + SPH_C32(0x854e2bfb), SPH_C32(0x12be7119) } +}; + +static const sph_u32 T256_24[8][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), SPH_C32(0x98321c3d), + SPH_C32(0x76acc733), SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), + SPH_C32(0x05f7ac6d), SPH_C32(0xd9e6eee9) }, + { SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), SPH_C32(0xfe739301), + SPH_C32(0xb8a92831), SPH_C32(0x171c0000), SPH_C32(0xb26e3344), + SPH_C32(0x9e6a837e), SPH_C32(0x58f8485f) }, + { SPH_C32(0xc3070008), SPH_C32(0x6092c0d7), SPH_C32(0x66418f3c), + SPH_C32(0xce05ef02), SPH_C32(0xacbd0004), SPH_C32(0x7ef34599), + SPH_C32(0x9b9d2f13), SPH_C32(0x811ea6b6) }, + { SPH_C32(0x171c0000), SPH_C32(0xb26e3344), SPH_C32(0x9e6a837e), + SPH_C32(0x58f8485f), SPH_C32(0xbfb20008), SPH_C32(0x92170a39), + SPH_C32(0x6019107f), SPH_C32(0xe051606e) }, + { SPH_C32(0x7cb50000), SPH_C32(0xf285caee), SPH_C32(0x06589f43), + SPH_C32(0x2e548f6c), SPH_C32(0x0413000c), SPH_C32(0x5e8a7ce4), + SPH_C32(0x65eebc12), SPH_C32(0x39b78e87) }, + { SPH_C32(0xbfb20008), SPH_C32(0x92170a39), SPH_C32(0x6019107f), + SPH_C32(0xe051606e), SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), + SPH_C32(0xfe739301), SPH_C32(0xb8a92831) }, + { SPH_C32(0xd41b0008), SPH_C32(0xd2fcf393), SPH_C32(0xf82b0c42), + SPH_C32(0x96fda75d), SPH_C32(0x130f000c), SPH_C32(0xece44fa0), + SPH_C32(0xfb843f6c), SPH_C32(0x614fc6d8) } +}; + +static const sph_u32 T256_27[8][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), SPH_C32(0x99e585aa), + SPH_C32(0x8d75f7f1), SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), + SPH_C32(0x79e22a4c), SPH_C32(0x1298bd46) }, + { SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), SPH_C32(0x79e22a4c), + SPH_C32(0x1298bd46), SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), + SPH_C32(0xe007afe6), SPH_C32(0x9fed4ab7) }, + { SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), SPH_C32(0xe007afe6), + SPH_C32(0x9fed4ab7), SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), + SPH_C32(0x99e585aa), SPH_C32(0x8d75f7f1) }, + { SPH_C32(0xd0080004), SPH_C32(0x8c768f77), SPH_C32(0x9dc5b050), + SPH_C32(0xaf4a29da), SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), + SPH_C32(0x98321c3d), SPH_C32(0x76acc733) }, + { SPH_C32(0x582b0006), SPH_C32(0xd39128c4), SPH_C32(0x042035fa), + SPH_C32(0x223fde2b), SPH_C32(0x3a050000), SPH_C32(0x6508f6be), + SPH_C32(0xe1d03671), SPH_C32(0x64347a75) }, + { SPH_C32(0x81a40004), SPH_C32(0xa9958063), SPH_C32(0xe4279a1c), + SPH_C32(0xbdd2949c), SPH_C32(0xb2260002), SPH_C32(0x3aef510d), + SPH_C32(0x7835b3db), SPH_C32(0xe9418d84) }, + { SPH_C32(0x09870006), SPH_C32(0xf67227d0), SPH_C32(0x7dc21fb6), + SPH_C32(0x30a7636d), SPH_C32(0xe38a0002), SPH_C32(0x1f0c5e19), + SPH_C32(0x01d79997), SPH_C32(0xfbd930c2) } +}; + +static const sph_u32 T256_30[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), SPH_C32(0xae0ebb05), + SPH_C32(0xb5a4c63b), SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), + SPH_C32(0x6bf648a4), SPH_C32(0x539cbdbf) }, + { SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), SPH_C32(0x6bf648a4), + SPH_C32(0x539cbdbf), SPH_C32(0x08bf0001), SPH_C32(0x38942792), + SPH_C32(0xc5f8f3a1), SPH_C32(0xe6387b84) }, + { SPH_C32(0x08bf0001), SPH_C32(0x38942792), SPH_C32(0xc5f8f3a1), + SPH_C32(0xe6387b84), SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), + SPH_C32(0xae0ebb05), SPH_C32(0xb5a4c63b) } +}; + +#define INPUT_SMALL do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T256_0[acc >> 5][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + rp = &T256_3[(acc >> 2) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = (acc << 8) | buf[1]; \ + rp = &T256_6[(acc >> 7) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_9[(acc >> 4) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_12[(acc >> 1) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = (acc << 8) | buf[2]; \ + rp = &T256_15[(acc >> 6) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_18[(acc >> 3) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_21[acc & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = buf[3]; \ + rp = &T256_24[acc >> 5][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_27[(acc >> 2) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_30[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_SMALL == 4 + +static const sph_u32 T256_0[16][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), SPH_C32(0x8dfacfab), + SPH_C32(0xce36cc72), SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), + SPH_C32(0x848598ba), SPH_C32(0x1041003e) }, + { SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), SPH_C32(0x848598ba), + SPH_C32(0x1041003e), SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), + SPH_C32(0x097f5711), SPH_C32(0xde77cc4c) }, + { SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), SPH_C32(0x097f5711), + SPH_C32(0xde77cc4c), SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), + SPH_C32(0x8dfacfab), SPH_C32(0xce36cc72) }, + { SPH_C32(0xe4788000), SPH_C32(0x859673c1), SPH_C32(0xb5fb2452), + SPH_C32(0x29cc5edf), SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), + SPH_C32(0x62fc79d0), SPH_C32(0x731ebdc2) }, + { SPH_C32(0xf663c000), SPH_C32(0xde81aa29), SPH_C32(0x3801ebf9), + SPH_C32(0xe7fa92ad), SPH_C32(0xe2080000), SPH_C32(0xd7f9a9ec), + SPH_C32(0xe679e16a), SPH_C32(0x635fbdfc) }, + { SPH_C32(0x022f8000), SPH_C32(0xce2549e4), SPH_C32(0x317ebce8), + SPH_C32(0x398d5ee1), SPH_C32(0xf0134000), SPH_C32(0x8cee7004), + SPH_C32(0x6b832ec1), SPH_C32(0xad69718e) }, + { SPH_C32(0x1034c000), SPH_C32(0x9532900c), SPH_C32(0xbc847343), + SPH_C32(0xf7bb9293), SPH_C32(0x16444000), SPH_C32(0xc75d4a21), + SPH_C32(0xef06b67b), SPH_C32(0xbd2871b0) }, + { SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), SPH_C32(0x62fc79d0), + SPH_C32(0x731ebdc2), SPH_C32(0xe0278000), SPH_C32(0x19dce008), + SPH_C32(0xd7075d82), SPH_C32(0x5ad2e31d) }, + { SPH_C32(0x16444000), SPH_C32(0xc75d4a21), SPH_C32(0xef06b67b), + SPH_C32(0xbd2871b0), SPH_C32(0x06708000), SPH_C32(0x526fda2d), + SPH_C32(0x5382c538), SPH_C32(0x4a93e323) }, + { SPH_C32(0xe2080000), SPH_C32(0xd7f9a9ec), SPH_C32(0xe679e16a), + SPH_C32(0x635fbdfc), SPH_C32(0x146bc000), SPH_C32(0x097803c5), + SPH_C32(0xde780a93), SPH_C32(0x84a52f51) }, + { SPH_C32(0xf0134000), SPH_C32(0x8cee7004), SPH_C32(0x6b832ec1), + SPH_C32(0xad69718e), SPH_C32(0xf23cc000), SPH_C32(0x42cb39e0), + SPH_C32(0x5afd9229), SPH_C32(0x94e42f6f) }, + { SPH_C32(0xe0278000), SPH_C32(0x19dce008), SPH_C32(0xd7075d82), + SPH_C32(0x5ad2e31d), SPH_C32(0xe4788000), SPH_C32(0x859673c1), + SPH_C32(0xb5fb2452), SPH_C32(0x29cc5edf) }, + { SPH_C32(0xf23cc000), SPH_C32(0x42cb39e0), SPH_C32(0x5afd9229), + SPH_C32(0x94e42f6f), SPH_C32(0x022f8000), SPH_C32(0xce2549e4), + SPH_C32(0x317ebce8), SPH_C32(0x398d5ee1) }, + { SPH_C32(0x06708000), SPH_C32(0x526fda2d), SPH_C32(0x5382c538), + SPH_C32(0x4a93e323), SPH_C32(0x1034c000), SPH_C32(0x9532900c), + SPH_C32(0xbc847343), SPH_C32(0xf7bb9293) }, + { SPH_C32(0x146bc000), SPH_C32(0x097803c5), SPH_C32(0xde780a93), + SPH_C32(0x84a52f51), SPH_C32(0xf663c000), SPH_C32(0xde81aa29), + SPH_C32(0x3801ebf9), SPH_C32(0xe7fa92ad) } +}; + +static const sph_u32 T256_4[16][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x74951000), SPH_C32(0x5a2b467e), SPH_C32(0x88fd1d2b), + SPH_C32(0x1ee68292), SPH_C32(0xcba90000), SPH_C32(0x90273769), + SPH_C32(0xbbdcf407), SPH_C32(0xd0f4af61) }, + { SPH_C32(0xcba90000), SPH_C32(0x90273769), SPH_C32(0xbbdcf407), + SPH_C32(0xd0f4af61), SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), + SPH_C32(0x3321e92c), SPH_C32(0xce122df3) }, + { SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), SPH_C32(0x3321e92c), + SPH_C32(0xce122df3), SPH_C32(0x74951000), SPH_C32(0x5a2b467e), + SPH_C32(0x88fd1d2b), SPH_C32(0x1ee68292) }, + { SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), SPH_C32(0x11fa3a57), + SPH_C32(0x3dc90524), SPH_C32(0x97530000), SPH_C32(0x204f6ed3), + SPH_C32(0x77b9e80f), SPH_C32(0xa1ec5ec1) }, + { SPH_C32(0x9dbf3000), SPH_C32(0xee7cca82), SPH_C32(0x9907277c), + SPH_C32(0x232f87b6), SPH_C32(0x5cfa0000), SPH_C32(0xb06859ba), + SPH_C32(0xcc651c08), SPH_C32(0x7118f1a0) }, + { SPH_C32(0x22832000), SPH_C32(0x2470bb95), SPH_C32(0xaa26ce50), + SPH_C32(0xed3daa45), SPH_C32(0x286f1000), SPH_C32(0xea431fc4), + SPH_C32(0x44980123), SPH_C32(0x6ffe7332) }, + { SPH_C32(0x56163000), SPH_C32(0x7e5bfdeb), SPH_C32(0x22dbd37b), + SPH_C32(0xf3db28d7), SPH_C32(0xe3c61000), SPH_C32(0x7a6428ad), + SPH_C32(0xff44f524), SPH_C32(0xbf0adc53) }, + { SPH_C32(0x97530000), SPH_C32(0x204f6ed3), SPH_C32(0x77b9e80f), + SPH_C32(0xa1ec5ec1), SPH_C32(0x7e792000), SPH_C32(0x9418e22f), + SPH_C32(0x6643d258), SPH_C32(0x9c255be5) }, + { SPH_C32(0xe3c61000), SPH_C32(0x7a6428ad), SPH_C32(0xff44f524), + SPH_C32(0xbf0adc53), SPH_C32(0xb5d02000), SPH_C32(0x043fd546), + SPH_C32(0xdd9f265f), SPH_C32(0x4cd1f484) }, + { SPH_C32(0x5cfa0000), SPH_C32(0xb06859ba), SPH_C32(0xcc651c08), + SPH_C32(0x7118f1a0), SPH_C32(0xc1453000), SPH_C32(0x5e149338), + SPH_C32(0x55623b74), SPH_C32(0x52377616) }, + { SPH_C32(0x286f1000), SPH_C32(0xea431fc4), SPH_C32(0x44980123), + SPH_C32(0x6ffe7332), SPH_C32(0x0aec3000), SPH_C32(0xce33a451), + SPH_C32(0xeebecf73), SPH_C32(0x82c3d977) }, + { SPH_C32(0x7e792000), SPH_C32(0x9418e22f), SPH_C32(0x6643d258), + SPH_C32(0x9c255be5), SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), + SPH_C32(0x11fa3a57), SPH_C32(0x3dc90524) }, + { SPH_C32(0x0aec3000), SPH_C32(0xce33a451), SPH_C32(0xeebecf73), + SPH_C32(0x82c3d977), SPH_C32(0x22832000), SPH_C32(0x2470bb95), + SPH_C32(0xaa26ce50), SPH_C32(0xed3daa45) }, + { SPH_C32(0xb5d02000), SPH_C32(0x043fd546), SPH_C32(0xdd9f265f), + SPH_C32(0x4cd1f484), SPH_C32(0x56163000), SPH_C32(0x7e5bfdeb), + SPH_C32(0x22dbd37b), SPH_C32(0xf3db28d7) }, + { SPH_C32(0xc1453000), SPH_C32(0x5e149338), SPH_C32(0x55623b74), + SPH_C32(0x52377616), SPH_C32(0x9dbf3000), SPH_C32(0xee7cca82), + SPH_C32(0x9907277c), SPH_C32(0x232f87b6) } +}; + +static const sph_u32 T256_8[16][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), SPH_C32(0x6fc548e1), + SPH_C32(0x898d2cd6), SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), + SPH_C32(0x6a72e5bb), SPH_C32(0x247febe6) }, + { SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), SPH_C32(0x6a72e5bb), + SPH_C32(0x247febe6), SPH_C32(0x9b830400), SPH_C32(0x2227ff88), + SPH_C32(0x05b7ad5a), SPH_C32(0xadf2c730) }, + { SPH_C32(0x9b830400), SPH_C32(0x2227ff88), SPH_C32(0x05b7ad5a), + SPH_C32(0xadf2c730), SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), + SPH_C32(0x6fc548e1), SPH_C32(0x898d2cd6) }, + { SPH_C32(0xde320800), SPH_C32(0x288350fe), SPH_C32(0x71852ac7), + SPH_C32(0xa6bf9f96), SPH_C32(0xe18b0000), SPH_C32(0x5459887d), + SPH_C32(0xbf1283d3), SPH_C32(0x1b666a73) }, + { SPH_C32(0x510c0c00), SPH_C32(0x251e9889), SPH_C32(0x1e406226), + SPH_C32(0x2f32b340), SPH_C32(0xf5360000), SPH_C32(0x7be3bf82), + SPH_C32(0xd5606668), SPH_C32(0x3f198195) }, + { SPH_C32(0xca8f0800), SPH_C32(0x07396701), SPH_C32(0x1bf7cf7c), + SPH_C32(0x82c07470), SPH_C32(0x7a080400), SPH_C32(0x767e77f5), + SPH_C32(0xbaa52e89), SPH_C32(0xb694ad43) }, + { SPH_C32(0x45b10c00), SPH_C32(0x0aa4af76), SPH_C32(0x7432879d), + SPH_C32(0x0b4d58a6), SPH_C32(0x6eb50400), SPH_C32(0x59c4400a), + SPH_C32(0xd0d7cb32), SPH_C32(0x92eb46a5) }, + { SPH_C32(0xe18b0000), SPH_C32(0x5459887d), SPH_C32(0xbf1283d3), + SPH_C32(0x1b666a73), SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), + SPH_C32(0xce97a914), SPH_C32(0xbdd9f5e5) }, + { SPH_C32(0x6eb50400), SPH_C32(0x59c4400a), SPH_C32(0xd0d7cb32), + SPH_C32(0x92eb46a5), SPH_C32(0x2b040800), SPH_C32(0x5360ef7c), + SPH_C32(0xa4e54caf), SPH_C32(0x99a61e03) }, + { SPH_C32(0xf5360000), SPH_C32(0x7be3bf82), SPH_C32(0xd5606668), + SPH_C32(0x3f198195), SPH_C32(0xa43a0c00), SPH_C32(0x5efd270b), + SPH_C32(0xcb20044e), SPH_C32(0x102b32d5) }, + { SPH_C32(0x7a080400), SPH_C32(0x767e77f5), SPH_C32(0xbaa52e89), + SPH_C32(0xb694ad43), SPH_C32(0xb0870c00), SPH_C32(0x714710f4), + SPH_C32(0xa152e1f5), SPH_C32(0x3454d933) }, + { SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), SPH_C32(0xce97a914), + SPH_C32(0xbdd9f5e5), SPH_C32(0xde320800), SPH_C32(0x288350fe), + SPH_C32(0x71852ac7), SPH_C32(0xa6bf9f96) }, + { SPH_C32(0xb0870c00), SPH_C32(0x714710f4), SPH_C32(0xa152e1f5), + SPH_C32(0x3454d933), SPH_C32(0xca8f0800), SPH_C32(0x07396701), + SPH_C32(0x1bf7cf7c), SPH_C32(0x82c07470) }, + { SPH_C32(0x2b040800), SPH_C32(0x5360ef7c), SPH_C32(0xa4e54caf), + SPH_C32(0x99a61e03), SPH_C32(0x45b10c00), SPH_C32(0x0aa4af76), + SPH_C32(0x7432879d), SPH_C32(0x0b4d58a6) }, + { SPH_C32(0xa43a0c00), SPH_C32(0x5efd270b), SPH_C32(0xcb20044e), + SPH_C32(0x102b32d5), SPH_C32(0x510c0c00), SPH_C32(0x251e9889), + SPH_C32(0x1e406226), SPH_C32(0x2f32b340) } +}; + +static const sph_u32 T256_12[16][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), SPH_C32(0x8589d8ab), + SPH_C32(0xe6c46464), SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), + SPH_C32(0xa29d1297), SPH_C32(0x6ee56854) }, + { SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), SPH_C32(0xa29d1297), + SPH_C32(0x6ee56854), SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), + SPH_C32(0x2714ca3c), SPH_C32(0x88210c30) }, + { SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), SPH_C32(0x2714ca3c), + SPH_C32(0x88210c30), SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), + SPH_C32(0x8589d8ab), SPH_C32(0xe6c46464) }, + { SPH_C32(0xa7b80200), SPH_C32(0x1f128433), SPH_C32(0x60e5f9f2), + SPH_C32(0x9e147576), SPH_C32(0xee260000), SPH_C32(0x124b683e), + SPH_C32(0x80c2d68f), SPH_C32(0x3bf3ab2c) }, + { SPH_C32(0x101c0300), SPH_C32(0x950db5eb), SPH_C32(0xe56c2159), + SPH_C32(0x78d01112), SPH_C32(0x9d6a0000), SPH_C32(0x8724cfe8), + SPH_C32(0x225fc418), SPH_C32(0x5516c378) }, + { SPH_C32(0xd4f40200), SPH_C32(0x8a7d23e5), SPH_C32(0xc278eb65), + SPH_C32(0xf0f11d22), SPH_C32(0x2ace0100), SPH_C32(0x0d3bfe30), + SPH_C32(0xa7d61cb3), SPH_C32(0xb3d2a71c) }, + { SPH_C32(0x63500300), SPH_C32(0x0062123d), SPH_C32(0x47f133ce), + SPH_C32(0x16357946), SPH_C32(0x59820100), SPH_C32(0x985459e6), + SPH_C32(0x054b0e24), SPH_C32(0xdd37cf48) }, + { SPH_C32(0xee260000), SPH_C32(0x124b683e), SPH_C32(0x80c2d68f), + SPH_C32(0x3bf3ab2c), SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), + SPH_C32(0xe0272f7d), SPH_C32(0xa5e7de5a) }, + { SPH_C32(0x59820100), SPH_C32(0x985459e6), SPH_C32(0x054b0e24), + SPH_C32(0xdd37cf48), SPH_C32(0x3ad20200), SPH_C32(0x98364bdb), + SPH_C32(0x42ba3dea), SPH_C32(0xcb02b60e) }, + { SPH_C32(0x9d6a0000), SPH_C32(0x8724cfe8), SPH_C32(0x225fc418), + SPH_C32(0x5516c378), SPH_C32(0x8d760300), SPH_C32(0x12297a03), + SPH_C32(0xc733e541), SPH_C32(0x2dc6d26a) }, + { SPH_C32(0x2ace0100), SPH_C32(0x0d3bfe30), SPH_C32(0xa7d61cb3), + SPH_C32(0xb3d2a71c), SPH_C32(0xfe3a0300), SPH_C32(0x8746ddd5), + SPH_C32(0x65aef7d6), SPH_C32(0x4323ba3e) }, + { SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), SPH_C32(0xe0272f7d), + SPH_C32(0xa5e7de5a), SPH_C32(0xa7b80200), SPH_C32(0x1f128433), + SPH_C32(0x60e5f9f2), SPH_C32(0x9e147576) }, + { SPH_C32(0xfe3a0300), SPH_C32(0x8746ddd5), SPH_C32(0x65aef7d6), + SPH_C32(0x4323ba3e), SPH_C32(0xd4f40200), SPH_C32(0x8a7d23e5), + SPH_C32(0xc278eb65), SPH_C32(0xf0f11d22) }, + { SPH_C32(0x3ad20200), SPH_C32(0x98364bdb), SPH_C32(0x42ba3dea), + SPH_C32(0xcb02b60e), SPH_C32(0x63500300), SPH_C32(0x0062123d), + SPH_C32(0x47f133ce), SPH_C32(0x16357946) }, + { SPH_C32(0x8d760300), SPH_C32(0x12297a03), SPH_C32(0xc733e541), + SPH_C32(0x2dc6d26a), SPH_C32(0x101c0300), SPH_C32(0x950db5eb), + SPH_C32(0xe56c2159), SPH_C32(0x78d01112) } +}; + +static const sph_u32 T256_16[16][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), SPH_C32(0x36656ba8), + SPH_C32(0x23633a05), SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), + SPH_C32(0x5d5ca0f7), SPH_C32(0x727784cb) }, + { SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), SPH_C32(0x5d5ca0f7), + SPH_C32(0x727784cb), SPH_C32(0x35650040), SPH_C32(0x9b96b64a), + SPH_C32(0x6b39cb5f), SPH_C32(0x5114bece) }, + { SPH_C32(0x35650040), SPH_C32(0x9b96b64a), SPH_C32(0x6b39cb5f), + SPH_C32(0x5114bece), SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), + SPH_C32(0x36656ba8), SPH_C32(0x23633a05) }, + { SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), SPH_C32(0xc2c46c55), + SPH_C32(0xf362b233), SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), + SPH_C32(0xd14e094b), SPH_C32(0xb772b42b) }, + { SPH_C32(0x161c00c0), SPH_C32(0x7e54f492), SPH_C32(0xf4a107fd), + SPH_C32(0xd0018836), SPH_C32(0x410d0000), SPH_C32(0xea7a09df), + SPH_C32(0x8c12a9bc), SPH_C32(0xc50530e0) }, + { SPH_C32(0x23790080), SPH_C32(0xe5c242d8), SPH_C32(0x9f98cca2), + SPH_C32(0x811536f8), SPH_C32(0x0cc30040), SPH_C32(0xd121e5a1), + SPH_C32(0xba77c214), SPH_C32(0xe6660ae5) }, + { SPH_C32(0x6eb700c0), SPH_C32(0xde99aea6), SPH_C32(0xa9fda70a), + SPH_C32(0xa2760cfd), SPH_C32(0x74680040), SPH_C32(0x71ecbf95), + SPH_C32(0xe72b62e3), SPH_C32(0x94118e2e) }, + { SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), SPH_C32(0xd14e094b), + SPH_C32(0xb772b42b), SPH_C32(0x62740080), SPH_C32(0x0fb84b07), + SPH_C32(0x138a651e), SPH_C32(0x44100618) }, + { SPH_C32(0x74680040), SPH_C32(0x71ecbf95), SPH_C32(0xe72b62e3), + SPH_C32(0x94118e2e), SPH_C32(0x1adf0080), SPH_C32(0xaf751133), + SPH_C32(0x4ed6c5e9), SPH_C32(0x366782d3) }, + { SPH_C32(0x410d0000), SPH_C32(0xea7a09df), SPH_C32(0x8c12a9bc), + SPH_C32(0xc50530e0), SPH_C32(0x571100c0), SPH_C32(0x942efd4d), + SPH_C32(0x78b3ae41), SPH_C32(0x1504b8d6) }, + { SPH_C32(0x0cc30040), SPH_C32(0xd121e5a1), SPH_C32(0xba77c214), + SPH_C32(0xe6660ae5), SPH_C32(0x2fba00c0), SPH_C32(0x34e3a779), + SPH_C32(0x25ef0eb6), SPH_C32(0x67733c1d) }, + { SPH_C32(0x62740080), SPH_C32(0x0fb84b07), SPH_C32(0x138a651e), + SPH_C32(0x44100618), SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), + SPH_C32(0xc2c46c55), SPH_C32(0xf362b233) }, + { SPH_C32(0x2fba00c0), SPH_C32(0x34e3a779), SPH_C32(0x25ef0eb6), + SPH_C32(0x67733c1d), SPH_C32(0x23790080), SPH_C32(0xe5c242d8), + SPH_C32(0x9f98cca2), SPH_C32(0x811536f8) }, + { SPH_C32(0x1adf0080), SPH_C32(0xaf751133), SPH_C32(0x4ed6c5e9), + SPH_C32(0x366782d3), SPH_C32(0x6eb700c0), SPH_C32(0xde99aea6), + SPH_C32(0xa9fda70a), SPH_C32(0xa2760cfd) }, + { SPH_C32(0x571100c0), SPH_C32(0x942efd4d), SPH_C32(0x78b3ae41), + SPH_C32(0x1504b8d6), SPH_C32(0x161c00c0), SPH_C32(0x7e54f492), + SPH_C32(0xf4a107fd), SPH_C32(0xd0018836) } +}; + +static const sph_u32 T256_20[16][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x515c0010), SPH_C32(0x40f372fb), SPH_C32(0xfce72602), + SPH_C32(0x71575061), SPH_C32(0x2e390000), SPH_C32(0x64dd6689), + SPH_C32(0x3cd406fc), SPH_C32(0xb1f490bc) }, + { SPH_C32(0x2e390000), SPH_C32(0x64dd6689), SPH_C32(0x3cd406fc), + SPH_C32(0xb1f490bc), SPH_C32(0x7f650010), SPH_C32(0x242e1472), + SPH_C32(0xc03320fe), SPH_C32(0xc0a3c0dd) }, + { SPH_C32(0x7f650010), SPH_C32(0x242e1472), SPH_C32(0xc03320fe), + SPH_C32(0xc0a3c0dd), SPH_C32(0x515c0010), SPH_C32(0x40f372fb), + SPH_C32(0xfce72602), SPH_C32(0x71575061) }, + { SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), SPH_C32(0xf9ce4c04), + SPH_C32(0xe2afa0c0), SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), + SPH_C32(0x79a90df9), SPH_C32(0x63e92178) }, + { SPH_C32(0xf3e40030), SPH_C32(0xc114970d), SPH_C32(0x05296a06), + SPH_C32(0x93f8f0a1), SPH_C32(0x724b0000), SPH_C32(0xad67ab9b), + SPH_C32(0x457d0b05), SPH_C32(0xd21db1c4) }, + { SPH_C32(0x8c810020), SPH_C32(0xe53a837f), SPH_C32(0xc51a4af8), + SPH_C32(0x535b307c), SPH_C32(0x23170010), SPH_C32(0xed94d960), + SPH_C32(0xb99a2d07), SPH_C32(0xa34ae1a5) }, + { SPH_C32(0xdddd0030), SPH_C32(0xa5c9f184), SPH_C32(0x39fd6cfa), + SPH_C32(0x220c601d), SPH_C32(0x0d2e0010), SPH_C32(0x8949bfe9), + SPH_C32(0x854e2bfb), SPH_C32(0x12be7119) }, + { SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), SPH_C32(0x79a90df9), + SPH_C32(0x63e92178), SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), + SPH_C32(0x806741fd), SPH_C32(0x814681b8) }, + { SPH_C32(0x0d2e0010), SPH_C32(0x8949bfe9), SPH_C32(0x854e2bfb), + SPH_C32(0x12be7119), SPH_C32(0xd0f30020), SPH_C32(0x2c804e6d), + SPH_C32(0xbcb34701), SPH_C32(0x30b21104) }, + { SPH_C32(0x724b0000), SPH_C32(0xad67ab9b), SPH_C32(0x457d0b05), + SPH_C32(0xd21db1c4), SPH_C32(0x81af0030), SPH_C32(0x6c733c96), + SPH_C32(0x40546103), SPH_C32(0x41e54165) }, + { SPH_C32(0x23170010), SPH_C32(0xed94d960), SPH_C32(0xb99a2d07), + SPH_C32(0xa34ae1a5), SPH_C32(0xaf960030), SPH_C32(0x08ae5a1f), + SPH_C32(0x7c8067ff), SPH_C32(0xf011d1d9) }, + { SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), SPH_C32(0x806741fd), + SPH_C32(0x814681b8), SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), + SPH_C32(0xf9ce4c04), SPH_C32(0xe2afa0c0) }, + { SPH_C32(0xaf960030), SPH_C32(0x08ae5a1f), SPH_C32(0x7c8067ff), + SPH_C32(0xf011d1d9), SPH_C32(0x8c810020), SPH_C32(0xe53a837f), + SPH_C32(0xc51a4af8), SPH_C32(0x535b307c) }, + { SPH_C32(0xd0f30020), SPH_C32(0x2c804e6d), SPH_C32(0xbcb34701), + SPH_C32(0x30b21104), SPH_C32(0xdddd0030), SPH_C32(0xa5c9f184), + SPH_C32(0x39fd6cfa), SPH_C32(0x220c601d) }, + { SPH_C32(0x81af0030), SPH_C32(0x6c733c96), SPH_C32(0x40546103), + SPH_C32(0x41e54165), SPH_C32(0xf3e40030), SPH_C32(0xc114970d), + SPH_C32(0x05296a06), SPH_C32(0x93f8f0a1) } +}; + +static const sph_u32 T256_24[16][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xd0080004), SPH_C32(0x8c768f77), SPH_C32(0x9dc5b050), + SPH_C32(0xaf4a29da), SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), + SPH_C32(0x98321c3d), SPH_C32(0x76acc733) }, + { SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), SPH_C32(0x98321c3d), + SPH_C32(0x76acc733), SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), + SPH_C32(0x05f7ac6d), SPH_C32(0xd9e6eee9) }, + { SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), SPH_C32(0x05f7ac6d), + SPH_C32(0xd9e6eee9), SPH_C32(0xd0080004), SPH_C32(0x8c768f77), + SPH_C32(0x9dc5b050), SPH_C32(0xaf4a29da) }, + { SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), SPH_C32(0xfe739301), + SPH_C32(0xb8a92831), SPH_C32(0x171c0000), SPH_C32(0xb26e3344), + SPH_C32(0x9e6a837e), SPH_C32(0x58f8485f) }, + { SPH_C32(0x78a6000c), SPH_C32(0xac0fb60a), SPH_C32(0x63b62351), + SPH_C32(0x17e301eb), SPH_C32(0x7cb50000), SPH_C32(0xf285caee), + SPH_C32(0x06589f43), SPH_C32(0x2e548f6c) }, + { SPH_C32(0xc3070008), SPH_C32(0x6092c0d7), SPH_C32(0x66418f3c), + SPH_C32(0xce05ef02), SPH_C32(0xacbd0004), SPH_C32(0x7ef34599), + SPH_C32(0x9b9d2f13), SPH_C32(0x811ea6b6) }, + { SPH_C32(0x130f000c), SPH_C32(0xece44fa0), SPH_C32(0xfb843f6c), + SPH_C32(0x614fc6d8), SPH_C32(0xc7140004), SPH_C32(0x3e18bc33), + SPH_C32(0x03af332e), SPH_C32(0xf7b26185) }, + { SPH_C32(0x171c0000), SPH_C32(0xb26e3344), SPH_C32(0x9e6a837e), + SPH_C32(0x58f8485f), SPH_C32(0xbfb20008), SPH_C32(0x92170a39), + SPH_C32(0x6019107f), SPH_C32(0xe051606e) }, + { SPH_C32(0xc7140004), SPH_C32(0x3e18bc33), SPH_C32(0x03af332e), + SPH_C32(0xf7b26185), SPH_C32(0xd41b0008), SPH_C32(0xd2fcf393), + SPH_C32(0xf82b0c42), SPH_C32(0x96fda75d) }, + { SPH_C32(0x7cb50000), SPH_C32(0xf285caee), SPH_C32(0x06589f43), + SPH_C32(0x2e548f6c), SPH_C32(0x0413000c), SPH_C32(0x5e8a7ce4), + SPH_C32(0x65eebc12), SPH_C32(0x39b78e87) }, + { SPH_C32(0xacbd0004), SPH_C32(0x7ef34599), SPH_C32(0x9b9d2f13), + SPH_C32(0x811ea6b6), SPH_C32(0x6fba000c), SPH_C32(0x1e61854e), + SPH_C32(0xfddca02f), SPH_C32(0x4f1b49b4) }, + { SPH_C32(0xbfb20008), SPH_C32(0x92170a39), SPH_C32(0x6019107f), + SPH_C32(0xe051606e), SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), + SPH_C32(0xfe739301), SPH_C32(0xb8a92831) }, + { SPH_C32(0x6fba000c), SPH_C32(0x1e61854e), SPH_C32(0xfddca02f), + SPH_C32(0x4f1b49b4), SPH_C32(0xc3070008), SPH_C32(0x6092c0d7), + SPH_C32(0x66418f3c), SPH_C32(0xce05ef02) }, + { SPH_C32(0xd41b0008), SPH_C32(0xd2fcf393), SPH_C32(0xf82b0c42), + SPH_C32(0x96fda75d), SPH_C32(0x130f000c), SPH_C32(0xece44fa0), + SPH_C32(0xfb843f6c), SPH_C32(0x614fc6d8) }, + { SPH_C32(0x0413000c), SPH_C32(0x5e8a7ce4), SPH_C32(0x65eebc12), + SPH_C32(0x39b78e87), SPH_C32(0x78a6000c), SPH_C32(0xac0fb60a), + SPH_C32(0x63b62351), SPH_C32(0x17e301eb) } +}; + +static const sph_u32 T256_28[16][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), SPH_C32(0xae0ebb05), + SPH_C32(0xb5a4c63b), SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), + SPH_C32(0x6bf648a4), SPH_C32(0x539cbdbf) }, + { SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), SPH_C32(0x6bf648a4), + SPH_C32(0x539cbdbf), SPH_C32(0x08bf0001), SPH_C32(0x38942792), + SPH_C32(0xc5f8f3a1), SPH_C32(0xe6387b84) }, + { SPH_C32(0x08bf0001), SPH_C32(0x38942792), SPH_C32(0xc5f8f3a1), + SPH_C32(0xe6387b84), SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), + SPH_C32(0xae0ebb05), SPH_C32(0xb5a4c63b) }, + { SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), SPH_C32(0x99e585aa), + SPH_C32(0x8d75f7f1), SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), + SPH_C32(0x79e22a4c), SPH_C32(0x1298bd46) }, + { SPH_C32(0x486d0003), SPH_C32(0x6c5e67a3), SPH_C32(0x37eb3eaf), + SPH_C32(0x38d131ca), SPH_C32(0x995d0000), SPH_C32(0x2ecee896), + SPH_C32(0x121462e8), SPH_C32(0x410400f9) }, + { SPH_C32(0x40d20002), SPH_C32(0x54ca4031), SPH_C32(0xf213cd0e), + SPH_C32(0xdee94a4e), SPH_C32(0x59130001), SPH_C32(0x1d772886), + SPH_C32(0xbc1ad9ed), SPH_C32(0xf4a0c6c2) }, + { SPH_C32(0x809c0003), SPH_C32(0x67738021), SPH_C32(0x5c1d760b), + SPH_C32(0x6b4d8c75), SPH_C32(0x91e20001), SPH_C32(0x165acf04), + SPH_C32(0xd7ec9149), SPH_C32(0xa73c7b7d) }, + { SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), SPH_C32(0x79e22a4c), + SPH_C32(0x1298bd46), SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), + SPH_C32(0xe007afe6), SPH_C32(0x9fed4ab7) }, + { SPH_C32(0x91e20001), SPH_C32(0x165acf04), SPH_C32(0xd7ec9149), + SPH_C32(0xa73c7b7d), SPH_C32(0x117e0002), SPH_C32(0x71294f25), + SPH_C32(0x8bf1e742), SPH_C32(0xcc71f708) }, + { SPH_C32(0x995d0000), SPH_C32(0x2ecee896), SPH_C32(0x121462e8), + SPH_C32(0x410400f9), SPH_C32(0xd1300003), SPH_C32(0x42908f35), + SPH_C32(0x25ff5c47), SPH_C32(0x79d53133) }, + { SPH_C32(0x59130001), SPH_C32(0x1d772886), SPH_C32(0xbc1ad9ed), + SPH_C32(0xf4a0c6c2), SPH_C32(0x19c10003), SPH_C32(0x49bd68b7), + SPH_C32(0x4e0914e3), SPH_C32(0x2a498c8c) }, + { SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), SPH_C32(0xe007afe6), + SPH_C32(0x9fed4ab7), SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), + SPH_C32(0x99e585aa), SPH_C32(0x8d75f7f1) }, + { SPH_C32(0x19c10003), SPH_C32(0x49bd68b7), SPH_C32(0x4e0914e3), + SPH_C32(0x2a498c8c), SPH_C32(0x40d20002), SPH_C32(0x54ca4031), + SPH_C32(0xf213cd0e), SPH_C32(0xdee94a4e) }, + { SPH_C32(0x117e0002), SPH_C32(0x71294f25), SPH_C32(0x8bf1e742), + SPH_C32(0xcc71f708), SPH_C32(0x809c0003), SPH_C32(0x67738021), + SPH_C32(0x5c1d760b), SPH_C32(0x6b4d8c75) }, + { SPH_C32(0xd1300003), SPH_C32(0x42908f35), SPH_C32(0x25ff5c47), + SPH_C32(0x79d53133), SPH_C32(0x486d0003), SPH_C32(0x6c5e67a3), + SPH_C32(0x37eb3eaf), SPH_C32(0x38d131ca) } +}; + +#define INPUT_SMALL do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T256_0[acc >> 4][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + rp = &T256_4[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = buf[1]; \ + rp = &T256_8[acc >> 4][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_12[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = buf[2]; \ + rp = &T256_16[acc >> 4][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_20[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = buf[3]; \ + rp = &T256_24[acc >> 4][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_28[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_SMALL == 5 + +static const sph_u32 T256_0[32][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x97530000), SPH_C32(0x204f6ed3), SPH_C32(0x77b9e80f), + SPH_C32(0xa1ec5ec1), SPH_C32(0x7e792000), SPH_C32(0x9418e22f), + SPH_C32(0x6643d258), SPH_C32(0x9c255be5) }, + { SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), SPH_C32(0x8dfacfab), + SPH_C32(0xce36cc72), SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), + SPH_C32(0x848598ba), SPH_C32(0x1041003e) }, + { SPH_C32(0x85484000), SPH_C32(0x7b58b73b), SPH_C32(0xfa4327a4), + SPH_C32(0x6fda92b3), SPH_C32(0x982e2000), SPH_C32(0xdfabd80a), + SPH_C32(0xe2c64ae2), SPH_C32(0x8c645bdb) }, + { SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), SPH_C32(0x848598ba), + SPH_C32(0x1041003e), SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), + SPH_C32(0x097f5711), SPH_C32(0xde77cc4c) }, + { SPH_C32(0x71040000), SPH_C32(0x6bfc54f6), SPH_C32(0xf33c70b5), + SPH_C32(0xb1ad5eff), SPH_C32(0x8a356000), SPH_C32(0x84bc01e2), + SPH_C32(0x6f3c8549), SPH_C32(0x425297a9) }, + { SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), SPH_C32(0x097f5711), + SPH_C32(0xde77cc4c), SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), + SPH_C32(0x8dfacfab), SPH_C32(0xce36cc72) }, + { SPH_C32(0x631f4000), SPH_C32(0x30eb8d1e), SPH_C32(0x7ec6bf1e), + SPH_C32(0x7f9b928d), SPH_C32(0x6c626000), SPH_C32(0xcf0f3bc7), + SPH_C32(0xebb91df3), SPH_C32(0x52139797) }, + { SPH_C32(0xe4788000), SPH_C32(0x859673c1), SPH_C32(0xb5fb2452), + SPH_C32(0x29cc5edf), SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), + SPH_C32(0x62fc79d0), SPH_C32(0x731ebdc2) }, + { SPH_C32(0x732b8000), SPH_C32(0xa5d91d12), SPH_C32(0xc242cc5d), + SPH_C32(0x8820001e), SPH_C32(0x7a262000), SPH_C32(0x085271e6), + SPH_C32(0x04bfab88), SPH_C32(0xef3be627) }, + { SPH_C32(0xf663c000), SPH_C32(0xde81aa29), SPH_C32(0x3801ebf9), + SPH_C32(0xe7fa92ad), SPH_C32(0xe2080000), SPH_C32(0xd7f9a9ec), + SPH_C32(0xe679e16a), SPH_C32(0x635fbdfc) }, + { SPH_C32(0x6130c000), SPH_C32(0xfecec4fa), SPH_C32(0x4fb803f6), + SPH_C32(0x4616cc6c), SPH_C32(0x9c712000), SPH_C32(0x43e14bc3), + SPH_C32(0x803a3332), SPH_C32(0xff7ae619) }, + { SPH_C32(0x022f8000), SPH_C32(0xce2549e4), SPH_C32(0x317ebce8), + SPH_C32(0x398d5ee1), SPH_C32(0xf0134000), SPH_C32(0x8cee7004), + SPH_C32(0x6b832ec1), SPH_C32(0xad69718e) }, + { SPH_C32(0x957c8000), SPH_C32(0xee6a2737), SPH_C32(0x46c754e7), + SPH_C32(0x98610020), SPH_C32(0x8e6a6000), SPH_C32(0x18f6922b), + SPH_C32(0x0dc0fc99), SPH_C32(0x314c2a6b) }, + { SPH_C32(0x1034c000), SPH_C32(0x9532900c), SPH_C32(0xbc847343), + SPH_C32(0xf7bb9293), SPH_C32(0x16444000), SPH_C32(0xc75d4a21), + SPH_C32(0xef06b67b), SPH_C32(0xbd2871b0) }, + { SPH_C32(0x8767c000), SPH_C32(0xb57dfedf), SPH_C32(0xcb3d9b4c), + SPH_C32(0x5657cc52), SPH_C32(0x683d6000), SPH_C32(0x5345a80e), + SPH_C32(0x89456423), SPH_C32(0x210d2a55) }, + { SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), SPH_C32(0x62fc79d0), + SPH_C32(0x731ebdc2), SPH_C32(0xe0278000), SPH_C32(0x19dce008), + SPH_C32(0xd7075d82), SPH_C32(0x5ad2e31d) }, + { SPH_C32(0x930c0000), SPH_C32(0xbc05fd1a), SPH_C32(0x154591df), + SPH_C32(0xd2f2e303), SPH_C32(0x9e5ea000), SPH_C32(0x8dc40227), + SPH_C32(0xb1448fda), SPH_C32(0xc6f7b8f8) }, + { SPH_C32(0x16444000), SPH_C32(0xc75d4a21), SPH_C32(0xef06b67b), + SPH_C32(0xbd2871b0), SPH_C32(0x06708000), SPH_C32(0x526fda2d), + SPH_C32(0x5382c538), SPH_C32(0x4a93e323) }, + { SPH_C32(0x81174000), SPH_C32(0xe71224f2), SPH_C32(0x98bf5e74), + SPH_C32(0x1cc42f71), SPH_C32(0x7809a000), SPH_C32(0xc6773802), + SPH_C32(0x35c11760), SPH_C32(0xd6b6b8c6) }, + { SPH_C32(0xe2080000), SPH_C32(0xd7f9a9ec), SPH_C32(0xe679e16a), + SPH_C32(0x635fbdfc), SPH_C32(0x146bc000), SPH_C32(0x097803c5), + SPH_C32(0xde780a93), SPH_C32(0x84a52f51) }, + { SPH_C32(0x755b0000), SPH_C32(0xf7b6c73f), SPH_C32(0x91c00965), + SPH_C32(0xc2b3e33d), SPH_C32(0x6a12e000), SPH_C32(0x9d60e1ea), + SPH_C32(0xb83bd8cb), SPH_C32(0x188074b4) }, + { SPH_C32(0xf0134000), SPH_C32(0x8cee7004), SPH_C32(0x6b832ec1), + SPH_C32(0xad69718e), SPH_C32(0xf23cc000), SPH_C32(0x42cb39e0), + SPH_C32(0x5afd9229), SPH_C32(0x94e42f6f) }, + { SPH_C32(0x67404000), SPH_C32(0xaca11ed7), SPH_C32(0x1c3ac6ce), + SPH_C32(0x0c852f4f), SPH_C32(0x8c45e000), SPH_C32(0xd6d3dbcf), + SPH_C32(0x3cbe4071), SPH_C32(0x08c1748a) }, + { SPH_C32(0xe0278000), SPH_C32(0x19dce008), SPH_C32(0xd7075d82), + SPH_C32(0x5ad2e31d), SPH_C32(0xe4788000), SPH_C32(0x859673c1), + SPH_C32(0xb5fb2452), SPH_C32(0x29cc5edf) }, + { SPH_C32(0x77748000), SPH_C32(0x39938edb), SPH_C32(0xa0beb58d), + SPH_C32(0xfb3ebddc), SPH_C32(0x9a01a000), SPH_C32(0x118e91ee), + SPH_C32(0xd3b8f60a), SPH_C32(0xb5e9053a) }, + { SPH_C32(0xf23cc000), SPH_C32(0x42cb39e0), SPH_C32(0x5afd9229), + SPH_C32(0x94e42f6f), SPH_C32(0x022f8000), SPH_C32(0xce2549e4), + SPH_C32(0x317ebce8), SPH_C32(0x398d5ee1) }, + { SPH_C32(0x656fc000), SPH_C32(0x62845733), SPH_C32(0x2d447a26), + SPH_C32(0x350871ae), SPH_C32(0x7c56a000), SPH_C32(0x5a3dabcb), + SPH_C32(0x573d6eb0), SPH_C32(0xa5a80504) }, + { SPH_C32(0x06708000), SPH_C32(0x526fda2d), SPH_C32(0x5382c538), + SPH_C32(0x4a93e323), SPH_C32(0x1034c000), SPH_C32(0x9532900c), + SPH_C32(0xbc847343), SPH_C32(0xf7bb9293) }, + { SPH_C32(0x91238000), SPH_C32(0x7220b4fe), SPH_C32(0x243b2d37), + SPH_C32(0xeb7fbde2), SPH_C32(0x6e4de000), SPH_C32(0x012a7223), + SPH_C32(0xdac7a11b), SPH_C32(0x6b9ec976) }, + { SPH_C32(0x146bc000), SPH_C32(0x097803c5), SPH_C32(0xde780a93), + SPH_C32(0x84a52f51), SPH_C32(0xf663c000), SPH_C32(0xde81aa29), + SPH_C32(0x3801ebf9), SPH_C32(0xe7fa92ad) }, + { SPH_C32(0x8338c000), SPH_C32(0x29376d16), SPH_C32(0xa9c1e29c), + SPH_C32(0x25497190), SPH_C32(0x881ae000), SPH_C32(0x4a994806), + SPH_C32(0x5e4239a1), SPH_C32(0x7bdfc948) } +}; + +static const sph_u32 T256_5[32][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xde320800), SPH_C32(0x288350fe), SPH_C32(0x71852ac7), + SPH_C32(0xa6bf9f96), SPH_C32(0xe18b0000), SPH_C32(0x5459887d), + SPH_C32(0xbf1283d3), SPH_C32(0x1b666a73) }, + { SPH_C32(0xe18b0000), SPH_C32(0x5459887d), SPH_C32(0xbf1283d3), + SPH_C32(0x1b666a73), SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), + SPH_C32(0xce97a914), SPH_C32(0xbdd9f5e5) }, + { SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), SPH_C32(0xce97a914), + SPH_C32(0xbdd9f5e5), SPH_C32(0xde320800), SPH_C32(0x288350fe), + SPH_C32(0x71852ac7), SPH_C32(0xa6bf9f96) }, + { SPH_C32(0x74951000), SPH_C32(0x5a2b467e), SPH_C32(0x88fd1d2b), + SPH_C32(0x1ee68292), SPH_C32(0xcba90000), SPH_C32(0x90273769), + SPH_C32(0xbbdcf407), SPH_C32(0xd0f4af61) }, + { SPH_C32(0xaaa71800), SPH_C32(0x72a81680), SPH_C32(0xf97837ec), + SPH_C32(0xb8591d04), SPH_C32(0x2a220000), SPH_C32(0xc47ebf14), + SPH_C32(0x04ce77d4), SPH_C32(0xcb92c512) }, + { SPH_C32(0x951e1000), SPH_C32(0x0e72ce03), SPH_C32(0x37ef9ef8), + SPH_C32(0x0580e8e1), SPH_C32(0xf4100800), SPH_C32(0xecfdefea), + SPH_C32(0x754b5d13), SPH_C32(0x6d2d5a84) }, + { SPH_C32(0x4b2c1800), SPH_C32(0x26f19efd), SPH_C32(0x466ab43f), + SPH_C32(0xa33f7777), SPH_C32(0x159b0800), SPH_C32(0xb8a46797), + SPH_C32(0xca59dec0), SPH_C32(0x764b30f7) }, + { SPH_C32(0xcba90000), SPH_C32(0x90273769), SPH_C32(0xbbdcf407), + SPH_C32(0xd0f4af61), SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), + SPH_C32(0x3321e92c), SPH_C32(0xce122df3) }, + { SPH_C32(0x159b0800), SPH_C32(0xb8a46797), SPH_C32(0xca59dec0), + SPH_C32(0x764b30f7), SPH_C32(0x5eb71000), SPH_C32(0x9e55f96a), + SPH_C32(0x8c336aff), SPH_C32(0xd5744780) }, + { SPH_C32(0x2a220000), SPH_C32(0xc47ebf14), SPH_C32(0x04ce77d4), + SPH_C32(0xcb92c512), SPH_C32(0x80851800), SPH_C32(0xb6d6a994), + SPH_C32(0xfdb64038), SPH_C32(0x73cbd816) }, + { SPH_C32(0xf4100800), SPH_C32(0xecfdefea), SPH_C32(0x754b5d13), + SPH_C32(0x6d2d5a84), SPH_C32(0x610e1800), SPH_C32(0xe28f21e9), + SPH_C32(0x42a4c3eb), SPH_C32(0x68adb265) }, + { SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), SPH_C32(0x3321e92c), + SPH_C32(0xce122df3), SPH_C32(0x74951000), SPH_C32(0x5a2b467e), + SPH_C32(0x88fd1d2b), SPH_C32(0x1ee68292) }, + { SPH_C32(0x610e1800), SPH_C32(0xe28f21e9), SPH_C32(0x42a4c3eb), + SPH_C32(0x68adb265), SPH_C32(0x951e1000), SPH_C32(0x0e72ce03), + SPH_C32(0x37ef9ef8), SPH_C32(0x0580e8e1) }, + { SPH_C32(0x5eb71000), SPH_C32(0x9e55f96a), SPH_C32(0x8c336aff), + SPH_C32(0xd5744780), SPH_C32(0x4b2c1800), SPH_C32(0x26f19efd), + SPH_C32(0x466ab43f), SPH_C32(0xa33f7777) }, + { SPH_C32(0x80851800), SPH_C32(0xb6d6a994), SPH_C32(0xfdb64038), + SPH_C32(0x73cbd816), SPH_C32(0xaaa71800), SPH_C32(0x72a81680), + SPH_C32(0xf97837ec), SPH_C32(0xb8591d04) }, + { SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), SPH_C32(0x11fa3a57), + SPH_C32(0x3dc90524), SPH_C32(0x97530000), SPH_C32(0x204f6ed3), + SPH_C32(0x77b9e80f), SPH_C32(0xa1ec5ec1) }, + { SPH_C32(0x37182800), SPH_C32(0x9cd4dc02), SPH_C32(0x607f1090), + SPH_C32(0x9b769ab2), SPH_C32(0x76d80000), SPH_C32(0x7416e6ae), + SPH_C32(0xc8ab6bdc), SPH_C32(0xba8a34b2) }, + { SPH_C32(0x08a12000), SPH_C32(0xe00e0481), SPH_C32(0xaee8b984), + SPH_C32(0x26af6f57), SPH_C32(0xa8ea0800), SPH_C32(0x5c95b650), + SPH_C32(0xb92e411b), SPH_C32(0x1c35ab24) }, + { SPH_C32(0xd6932800), SPH_C32(0xc88d547f), SPH_C32(0xdf6d9343), + SPH_C32(0x8010f0c1), SPH_C32(0x49610800), SPH_C32(0x08cc3e2d), + SPH_C32(0x063cc2c8), SPH_C32(0x0753c157) }, + { SPH_C32(0x9dbf3000), SPH_C32(0xee7cca82), SPH_C32(0x9907277c), + SPH_C32(0x232f87b6), SPH_C32(0x5cfa0000), SPH_C32(0xb06859ba), + SPH_C32(0xcc651c08), SPH_C32(0x7118f1a0) }, + { SPH_C32(0x438d3800), SPH_C32(0xc6ff9a7c), SPH_C32(0xe8820dbb), + SPH_C32(0x85901820), SPH_C32(0xbd710000), SPH_C32(0xe431d1c7), + SPH_C32(0x73779fdb), SPH_C32(0x6a7e9bd3) }, + { SPH_C32(0x7c343000), SPH_C32(0xba2542ff), SPH_C32(0x2615a4af), + SPH_C32(0x3849edc5), SPH_C32(0x63430800), SPH_C32(0xccb28139), + SPH_C32(0x02f2b51c), SPH_C32(0xccc10445) }, + { SPH_C32(0xa2063800), SPH_C32(0x92a61201), SPH_C32(0x57908e68), + SPH_C32(0x9ef67253), SPH_C32(0x82c80800), SPH_C32(0x98eb0944), + SPH_C32(0xbde036cf), SPH_C32(0xd7a76e36) }, + { SPH_C32(0x22832000), SPH_C32(0x2470bb95), SPH_C32(0xaa26ce50), + SPH_C32(0xed3daa45), SPH_C32(0x286f1000), SPH_C32(0xea431fc4), + SPH_C32(0x44980123), SPH_C32(0x6ffe7332) }, + { SPH_C32(0xfcb12800), SPH_C32(0x0cf3eb6b), SPH_C32(0xdba3e497), + SPH_C32(0x4b8235d3), SPH_C32(0xc9e41000), SPH_C32(0xbe1a97b9), + SPH_C32(0xfb8a82f0), SPH_C32(0x74981941) }, + { SPH_C32(0xc3082000), SPH_C32(0x702933e8), SPH_C32(0x15344d83), + SPH_C32(0xf65bc036), SPH_C32(0x17d61800), SPH_C32(0x9699c747), + SPH_C32(0x8a0fa837), SPH_C32(0xd22786d7) }, + { SPH_C32(0x1d3a2800), SPH_C32(0x58aa6316), SPH_C32(0x64b16744), + SPH_C32(0x50e45fa0), SPH_C32(0xf65d1800), SPH_C32(0xc2c04f3a), + SPH_C32(0x351d2be4), SPH_C32(0xc941eca4) }, + { SPH_C32(0x56163000), SPH_C32(0x7e5bfdeb), SPH_C32(0x22dbd37b), + SPH_C32(0xf3db28d7), SPH_C32(0xe3c61000), SPH_C32(0x7a6428ad), + SPH_C32(0xff44f524), SPH_C32(0xbf0adc53) }, + { SPH_C32(0x88243800), SPH_C32(0x56d8ad15), SPH_C32(0x535ef9bc), + SPH_C32(0x5564b741), SPH_C32(0x024d1000), SPH_C32(0x2e3da0d0), + SPH_C32(0x405676f7), SPH_C32(0xa46cb620) }, + { SPH_C32(0xb79d3000), SPH_C32(0x2a027596), SPH_C32(0x9dc950a8), + SPH_C32(0xe8bd42a4), SPH_C32(0xdc7f1800), SPH_C32(0x06bef02e), + SPH_C32(0x31d35c30), SPH_C32(0x02d329b6) }, + { SPH_C32(0x69af3800), SPH_C32(0x02812568), SPH_C32(0xec4c7a6f), + SPH_C32(0x4e02dd32), SPH_C32(0x3df41800), SPH_C32(0x52e77853), + SPH_C32(0x8ec1dfe3), SPH_C32(0x19b543c5) } +}; + +static const sph_u32 T256_10[32][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), SPH_C32(0xa29d1297), + SPH_C32(0x6ee56854), SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), + SPH_C32(0x2714ca3c), SPH_C32(0x88210c30) }, + { SPH_C32(0xa7b80200), SPH_C32(0x1f128433), SPH_C32(0x60e5f9f2), + SPH_C32(0x9e147576), SPH_C32(0xee260000), SPH_C32(0x124b683e), + SPH_C32(0x80c2d68f), SPH_C32(0x3bf3ab2c) }, + { SPH_C32(0xd4f40200), SPH_C32(0x8a7d23e5), SPH_C32(0xc278eb65), + SPH_C32(0xf0f11d22), SPH_C32(0x2ace0100), SPH_C32(0x0d3bfe30), + SPH_C32(0xa7d61cb3), SPH_C32(0xb3d2a71c) }, + { SPH_C32(0xee260000), SPH_C32(0x124b683e), SPH_C32(0x80c2d68f), + SPH_C32(0x3bf3ab2c), SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), + SPH_C32(0xe0272f7d), SPH_C32(0xa5e7de5a) }, + { SPH_C32(0x9d6a0000), SPH_C32(0x8724cfe8), SPH_C32(0x225fc418), + SPH_C32(0x5516c378), SPH_C32(0x8d760300), SPH_C32(0x12297a03), + SPH_C32(0xc733e541), SPH_C32(0x2dc6d26a) }, + { SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), SPH_C32(0xe0272f7d), + SPH_C32(0xa5e7de5a), SPH_C32(0xa7b80200), SPH_C32(0x1f128433), + SPH_C32(0x60e5f9f2), SPH_C32(0x9e147576) }, + { SPH_C32(0x3ad20200), SPH_C32(0x98364bdb), SPH_C32(0x42ba3dea), + SPH_C32(0xcb02b60e), SPH_C32(0x63500300), SPH_C32(0x0062123d), + SPH_C32(0x47f133ce), SPH_C32(0x16357946) }, + { SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), SPH_C32(0x6fc548e1), + SPH_C32(0x898d2cd6), SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), + SPH_C32(0x6a72e5bb), SPH_C32(0x247febe6) }, + { SPH_C32(0xfc720400), SPH_C32(0x98f26fa1), SPH_C32(0xcd585a76), + SPH_C32(0xe7684482), SPH_C32(0xd0550100), SPH_C32(0x30caa1f1), + SPH_C32(0x4d662f87), SPH_C32(0xac5ee7d6) }, + { SPH_C32(0x28860600), SPH_C32(0x128f4c44), SPH_C32(0x0f20b113), + SPH_C32(0x179959a0), SPH_C32(0xfa9b0000), SPH_C32(0x3df15fc1), + SPH_C32(0xeab03334), SPH_C32(0x1f8c40ca) }, + { SPH_C32(0x5bca0600), SPH_C32(0x87e0eb92), SPH_C32(0xadbda384), + SPH_C32(0x797c31f4), SPH_C32(0x3e730100), SPH_C32(0x2281c9cf), + SPH_C32(0xcda4f908), SPH_C32(0x97ad4cfa) }, + { SPH_C32(0x61180400), SPH_C32(0x1fd6a049), SPH_C32(0xef079e6e), + SPH_C32(0xb27e87fa), SPH_C32(0x5d230200), SPH_C32(0x22e3dbf2), + SPH_C32(0x8a55cac6), SPH_C32(0x819835bc) }, + { SPH_C32(0x12540400), SPH_C32(0x8ab9079f), SPH_C32(0x4d9a8cf9), + SPH_C32(0xdc9befae), SPH_C32(0x99cb0300), SPH_C32(0x3d934dfc), + SPH_C32(0xad4100fa), SPH_C32(0x09b9398c) }, + { SPH_C32(0xc6a00600), SPH_C32(0x00c4247a), SPH_C32(0x8fe2679c), + SPH_C32(0x2c6af28c), SPH_C32(0xb3050200), SPH_C32(0x30a8b3cc), + SPH_C32(0x0a971c49), SPH_C32(0xba6b9e90) }, + { SPH_C32(0xb5ec0600), SPH_C32(0x95ab83ac), SPH_C32(0x2d7f750b), + SPH_C32(0x428f9ad8), SPH_C32(0x77ed0300), SPH_C32(0x2fd825c2), + SPH_C32(0x2d83d675), SPH_C32(0x324a92a0) }, + { SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), SPH_C32(0x6a72e5bb), + SPH_C32(0x247febe6), SPH_C32(0x9b830400), SPH_C32(0x2227ff88), + SPH_C32(0x05b7ad5a), SPH_C32(0xadf2c730) }, + { SPH_C32(0x67f10000), SPH_C32(0xbad59029), SPH_C32(0xc8eff72c), + SPH_C32(0x4a9a83b2), SPH_C32(0x5f6b0500), SPH_C32(0x3d496986), + SPH_C32(0x22a36766), SPH_C32(0x25d3cb00) }, + { SPH_C32(0xb3050200), SPH_C32(0x30a8b3cc), SPH_C32(0x0a971c49), + SPH_C32(0xba6b9e90), SPH_C32(0x75a50400), SPH_C32(0x306c97b6), + SPH_C32(0x85757bd5), SPH_C32(0x96016c1c) }, + { SPH_C32(0xc0490200), SPH_C32(0xa5c7141a), SPH_C32(0xa80a0ede), + SPH_C32(0xd48ef6c4), SPH_C32(0xb14d0500), SPH_C32(0x2f1c01b8), + SPH_C32(0xa261b1e9), SPH_C32(0x1e20602c) }, + { SPH_C32(0xfa9b0000), SPH_C32(0x3df15fc1), SPH_C32(0xeab03334), + SPH_C32(0x1f8c40ca), SPH_C32(0xd21d0600), SPH_C32(0x2f7e1385), + SPH_C32(0xe5908227), SPH_C32(0x0815196a) }, + { SPH_C32(0x89d70000), SPH_C32(0xa89ef817), SPH_C32(0x482d21a3), + SPH_C32(0x7169289e), SPH_C32(0x16f50700), SPH_C32(0x300e858b), + SPH_C32(0xc284481b), SPH_C32(0x8034155a) }, + { SPH_C32(0x5d230200), SPH_C32(0x22e3dbf2), SPH_C32(0x8a55cac6), + SPH_C32(0x819835bc), SPH_C32(0x3c3b0600), SPH_C32(0x3d357bbb), + SPH_C32(0x655254a8), SPH_C32(0x33e6b246) }, + { SPH_C32(0x2e6f0200), SPH_C32(0xb78c7c24), SPH_C32(0x28c8d851), + SPH_C32(0xef7d5de8), SPH_C32(0xf8d30700), SPH_C32(0x2245edb5), + SPH_C32(0x42469e94), SPH_C32(0xbbc7be76) }, + { SPH_C32(0x9b830400), SPH_C32(0x2227ff88), SPH_C32(0x05b7ad5a), + SPH_C32(0xadf2c730), SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), + SPH_C32(0x6fc548e1), SPH_C32(0x898d2cd6) }, + { SPH_C32(0xe8cf0400), SPH_C32(0xb748585e), SPH_C32(0xa72abfcd), + SPH_C32(0xc317af64), SPH_C32(0x4bd60500), SPH_C32(0x12ed5e79), + SPH_C32(0x48d182dd), SPH_C32(0x01ac20e6) }, + { SPH_C32(0x3c3b0600), SPH_C32(0x3d357bbb), SPH_C32(0x655254a8), + SPH_C32(0x33e6b246), SPH_C32(0x61180400), SPH_C32(0x1fd6a049), + SPH_C32(0xef079e6e), SPH_C32(0xb27e87fa) }, + { SPH_C32(0x4f770600), SPH_C32(0xa85adc6d), SPH_C32(0xc7cf463f), + SPH_C32(0x5d03da12), SPH_C32(0xa5f00500), SPH_C32(0x00a63647), + SPH_C32(0xc8135452), SPH_C32(0x3a5f8bca) }, + { SPH_C32(0x75a50400), SPH_C32(0x306c97b6), SPH_C32(0x85757bd5), + SPH_C32(0x96016c1c), SPH_C32(0xc6a00600), SPH_C32(0x00c4247a), + SPH_C32(0x8fe2679c), SPH_C32(0x2c6af28c) }, + { SPH_C32(0x06e90400), SPH_C32(0xa5033060), SPH_C32(0x27e86942), + SPH_C32(0xf8e40448), SPH_C32(0x02480700), SPH_C32(0x1fb4b274), + SPH_C32(0xa8f6ada0), SPH_C32(0xa44bfebc) }, + { SPH_C32(0xd21d0600), SPH_C32(0x2f7e1385), SPH_C32(0xe5908227), + SPH_C32(0x0815196a), SPH_C32(0x28860600), SPH_C32(0x128f4c44), + SPH_C32(0x0f20b113), SPH_C32(0x179959a0) }, + { SPH_C32(0xa1510600), SPH_C32(0xba11b453), SPH_C32(0x470d90b0), + SPH_C32(0x66f0713e), SPH_C32(0xec6e0700), SPH_C32(0x0dffda4a), + SPH_C32(0x28347b2f), SPH_C32(0x9fb85590) } +}; + +static const sph_u32 T256_15[32][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), SPH_C32(0x36656ba8), + SPH_C32(0x23633a05), SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), + SPH_C32(0x5d5ca0f7), SPH_C32(0x727784cb) }, + { SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), SPH_C32(0x5d5ca0f7), + SPH_C32(0x727784cb), SPH_C32(0x35650040), SPH_C32(0x9b96b64a), + SPH_C32(0x6b39cb5f), SPH_C32(0x5114bece) }, + { SPH_C32(0x35650040), SPH_C32(0x9b96b64a), SPH_C32(0x6b39cb5f), + SPH_C32(0x5114bece), SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), + SPH_C32(0x36656ba8), SPH_C32(0x23633a05) }, + { SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), SPH_C32(0xc2c46c55), + SPH_C32(0xf362b233), SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), + SPH_C32(0xd14e094b), SPH_C32(0xb772b42b) }, + { SPH_C32(0x161c00c0), SPH_C32(0x7e54f492), SPH_C32(0xf4a107fd), + SPH_C32(0xd0018836), SPH_C32(0x410d0000), SPH_C32(0xea7a09df), + SPH_C32(0x8c12a9bc), SPH_C32(0xc50530e0) }, + { SPH_C32(0x23790080), SPH_C32(0xe5c242d8), SPH_C32(0x9f98cca2), + SPH_C32(0x811536f8), SPH_C32(0x0cc30040), SPH_C32(0xd121e5a1), + SPH_C32(0xba77c214), SPH_C32(0xe6660ae5) }, + { SPH_C32(0x6eb700c0), SPH_C32(0xde99aea6), SPH_C32(0xa9fda70a), + SPH_C32(0xa2760cfd), SPH_C32(0x74680040), SPH_C32(0x71ecbf95), + SPH_C32(0xe72b62e3), SPH_C32(0x94118e2e) }, + { SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), SPH_C32(0xd14e094b), + SPH_C32(0xb772b42b), SPH_C32(0x62740080), SPH_C32(0x0fb84b07), + SPH_C32(0x138a651e), SPH_C32(0x44100618) }, + { SPH_C32(0x74680040), SPH_C32(0x71ecbf95), SPH_C32(0xe72b62e3), + SPH_C32(0x94118e2e), SPH_C32(0x1adf0080), SPH_C32(0xaf751133), + SPH_C32(0x4ed6c5e9), SPH_C32(0x366782d3) }, + { SPH_C32(0x410d0000), SPH_C32(0xea7a09df), SPH_C32(0x8c12a9bc), + SPH_C32(0xc50530e0), SPH_C32(0x571100c0), SPH_C32(0x942efd4d), + SPH_C32(0x78b3ae41), SPH_C32(0x1504b8d6) }, + { SPH_C32(0x0cc30040), SPH_C32(0xd121e5a1), SPH_C32(0xba77c214), + SPH_C32(0xe6660ae5), SPH_C32(0x2fba00c0), SPH_C32(0x34e3a779), + SPH_C32(0x25ef0eb6), SPH_C32(0x67733c1d) }, + { SPH_C32(0x62740080), SPH_C32(0x0fb84b07), SPH_C32(0x138a651e), + SPH_C32(0x44100618), SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), + SPH_C32(0xc2c46c55), SPH_C32(0xf362b233) }, + { SPH_C32(0x2fba00c0), SPH_C32(0x34e3a779), SPH_C32(0x25ef0eb6), + SPH_C32(0x67733c1d), SPH_C32(0x23790080), SPH_C32(0xe5c242d8), + SPH_C32(0x9f98cca2), SPH_C32(0x811536f8) }, + { SPH_C32(0x1adf0080), SPH_C32(0xaf751133), SPH_C32(0x4ed6c5e9), + SPH_C32(0x366782d3), SPH_C32(0x6eb700c0), SPH_C32(0xde99aea6), + SPH_C32(0xa9fda70a), SPH_C32(0xa2760cfd) }, + { SPH_C32(0x571100c0), SPH_C32(0x942efd4d), SPH_C32(0x78b3ae41), + SPH_C32(0x1504b8d6), SPH_C32(0x161c00c0), SPH_C32(0x7e54f492), + SPH_C32(0xf4a107fd), SPH_C32(0xd0018836) }, + { SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), SPH_C32(0x8589d8ab), + SPH_C32(0xe6c46464), SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), + SPH_C32(0xa29d1297), SPH_C32(0x6ee56854) }, + { SPH_C32(0xfa6a0140), SPH_C32(0xb144dda6), SPH_C32(0xb3ecb303), + SPH_C32(0xc5a75e61), SPH_C32(0x0be70000), SPH_C32(0x35a2fde2), + SPH_C32(0xffc1b260), SPH_C32(0x1c92ec9f) }, + { SPH_C32(0xcf0f0100), SPH_C32(0x2ad26bec), SPH_C32(0xd8d5785c), + SPH_C32(0x94b3e0af), SPH_C32(0x46290040), SPH_C32(0x0ef9119c), + SPH_C32(0xc9a4d9c8), SPH_C32(0x3ff1d69a) }, + { SPH_C32(0x82c10140), SPH_C32(0x11898792), SPH_C32(0xeeb013f4), + SPH_C32(0xb7d0daaa), SPH_C32(0x3e820040), SPH_C32(0xae344ba8), + SPH_C32(0x94f8793f), SPH_C32(0x4d865251) }, + { SPH_C32(0xec760180), SPH_C32(0xcf102934), SPH_C32(0x474db4fe), + SPH_C32(0x15a6d657), SPH_C32(0x4aea0000), SPH_C32(0xdfd8f43d), + SPH_C32(0x73d31bdc), SPH_C32(0xd997dc7f) }, + { SPH_C32(0xa1b801c0), SPH_C32(0xf44bc54a), SPH_C32(0x7128df56), + SPH_C32(0x36c5ec52), SPH_C32(0x32410000), SPH_C32(0x7f15ae09), + SPH_C32(0x2e8fbb2b), SPH_C32(0xabe058b4) }, + { SPH_C32(0x94dd0180), SPH_C32(0x6fdd7300), SPH_C32(0x1a111409), + SPH_C32(0x67d1529c), SPH_C32(0x7f8f0040), SPH_C32(0x444e4277), + SPH_C32(0x18ead083), SPH_C32(0x888362b1) }, + { SPH_C32(0xd91301c0), SPH_C32(0x54869f7e), SPH_C32(0x2c747fa1), + SPH_C32(0x44b26899), SPH_C32(0x07240040), SPH_C32(0xe4831843), + SPH_C32(0x45b67074), SPH_C32(0xfaf4e67a) }, + { SPH_C32(0x8e020100), SPH_C32(0xc0a86233), SPH_C32(0x54c7d1e0), + SPH_C32(0x51b6d04f), SPH_C32(0x11380080), SPH_C32(0x9ad7ecd1), + SPH_C32(0xb1177789), SPH_C32(0x2af56e4c) }, + { SPH_C32(0xc3cc0140), SPH_C32(0xfbf38e4d), SPH_C32(0x62a2ba48), + SPH_C32(0x72d5ea4a), SPH_C32(0x69930080), SPH_C32(0x3a1ab6e5), + SPH_C32(0xec4bd77e), SPH_C32(0x5882ea87) }, + { SPH_C32(0xf6a90100), SPH_C32(0x60653807), SPH_C32(0x099b7117), + SPH_C32(0x23c15484), SPH_C32(0x245d00c0), SPH_C32(0x01415a9b), + SPH_C32(0xda2ebcd6), SPH_C32(0x7be1d082) }, + { SPH_C32(0xbb670140), SPH_C32(0x5b3ed479), SPH_C32(0x3ffe1abf), + SPH_C32(0x00a26e81), SPH_C32(0x5cf600c0), SPH_C32(0xa18c00af), + SPH_C32(0x87721c21), SPH_C32(0x09965449) }, + { SPH_C32(0xd5d00180), SPH_C32(0x85a77adf), SPH_C32(0x9603bdb5), + SPH_C32(0xa2d4627c), SPH_C32(0x289e0080), SPH_C32(0xd060bf3a), + SPH_C32(0x60597ec2), SPH_C32(0x9d87da67) }, + { SPH_C32(0x981e01c0), SPH_C32(0xbefc96a1), SPH_C32(0xa066d61d), + SPH_C32(0x81b75879), SPH_C32(0x50350080), SPH_C32(0x70ade50e), + SPH_C32(0x3d05de35), SPH_C32(0xeff05eac) }, + { SPH_C32(0xad7b0180), SPH_C32(0x256a20eb), SPH_C32(0xcb5f1d42), + SPH_C32(0xd0a3e6b7), SPH_C32(0x1dfb00c0), SPH_C32(0x4bf60970), + SPH_C32(0x0b60b59d), SPH_C32(0xcc9364a9) }, + { SPH_C32(0xe0b501c0), SPH_C32(0x1e31cc95), SPH_C32(0xfd3a76ea), + SPH_C32(0xf3c0dcb2), SPH_C32(0x655000c0), SPH_C32(0xeb3b5344), + SPH_C32(0x563c156a), SPH_C32(0xbee4e062) } +}; + +static const sph_u32 T256_20[32][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x171c0000), SPH_C32(0xb26e3344), SPH_C32(0x9e6a837e), + SPH_C32(0x58f8485f), SPH_C32(0xbfb20008), SPH_C32(0x92170a39), + SPH_C32(0x6019107f), SPH_C32(0xe051606e) }, + { SPH_C32(0x515c0010), SPH_C32(0x40f372fb), SPH_C32(0xfce72602), + SPH_C32(0x71575061), SPH_C32(0x2e390000), SPH_C32(0x64dd6689), + SPH_C32(0x3cd406fc), SPH_C32(0xb1f490bc) }, + { SPH_C32(0x46400010), SPH_C32(0xf29d41bf), SPH_C32(0x628da57c), + SPH_C32(0x29af183e), SPH_C32(0x918b0008), SPH_C32(0xf6ca6cb0), + SPH_C32(0x5ccd1683), SPH_C32(0x51a5f0d2) }, + { SPH_C32(0x2e390000), SPH_C32(0x64dd6689), SPH_C32(0x3cd406fc), + SPH_C32(0xb1f490bc), SPH_C32(0x7f650010), SPH_C32(0x242e1472), + SPH_C32(0xc03320fe), SPH_C32(0xc0a3c0dd) }, + { SPH_C32(0x39250000), SPH_C32(0xd6b355cd), SPH_C32(0xa2be8582), + SPH_C32(0xe90cd8e3), SPH_C32(0xc0d70018), SPH_C32(0xb6391e4b), + SPH_C32(0xa02a3081), SPH_C32(0x20f2a0b3) }, + { SPH_C32(0x7f650010), SPH_C32(0x242e1472), SPH_C32(0xc03320fe), + SPH_C32(0xc0a3c0dd), SPH_C32(0x515c0010), SPH_C32(0x40f372fb), + SPH_C32(0xfce72602), SPH_C32(0x71575061) }, + { SPH_C32(0x68790010), SPH_C32(0x96402736), SPH_C32(0x5e59a380), + SPH_C32(0x985b8882), SPH_C32(0xeeee0018), SPH_C32(0xd2e478c2), + SPH_C32(0x9cfe367d), SPH_C32(0x9106300f) }, + { SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), SPH_C32(0xf9ce4c04), + SPH_C32(0xe2afa0c0), SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), + SPH_C32(0x79a90df9), SPH_C32(0x63e92178) }, + { SPH_C32(0xb5a40020), SPH_C32(0x3389d6b2), SPH_C32(0x67a4cf7a), + SPH_C32(0xba57e89f), SPH_C32(0xe3c00008), SPH_C32(0x5badc72b), + SPH_C32(0x19b01d86), SPH_C32(0x83b84116) }, + { SPH_C32(0xf3e40030), SPH_C32(0xc114970d), SPH_C32(0x05296a06), + SPH_C32(0x93f8f0a1), SPH_C32(0x724b0000), SPH_C32(0xad67ab9b), + SPH_C32(0x457d0b05), SPH_C32(0xd21db1c4) }, + { SPH_C32(0xe4f80030), SPH_C32(0x737aa449), SPH_C32(0x9b43e978), + SPH_C32(0xcb00b8fe), SPH_C32(0xcdf90008), SPH_C32(0x3f70a1a2), + SPH_C32(0x25641b7a), SPH_C32(0x324cd1aa) }, + { SPH_C32(0x8c810020), SPH_C32(0xe53a837f), SPH_C32(0xc51a4af8), + SPH_C32(0x535b307c), SPH_C32(0x23170010), SPH_C32(0xed94d960), + SPH_C32(0xb99a2d07), SPH_C32(0xa34ae1a5) }, + { SPH_C32(0x9b9d0020), SPH_C32(0x5754b03b), SPH_C32(0x5b70c986), + SPH_C32(0x0ba37823), SPH_C32(0x9ca50018), SPH_C32(0x7f83d359), + SPH_C32(0xd9833d78), SPH_C32(0x431b81cb) }, + { SPH_C32(0xdddd0030), SPH_C32(0xa5c9f184), SPH_C32(0x39fd6cfa), + SPH_C32(0x220c601d), SPH_C32(0x0d2e0010), SPH_C32(0x8949bfe9), + SPH_C32(0x854e2bfb), SPH_C32(0x12be7119) }, + { SPH_C32(0xcac10030), SPH_C32(0x17a7c2c0), SPH_C32(0xa797ef84), + SPH_C32(0x7af42842), SPH_C32(0xb29c0018), SPH_C32(0x1b5eb5d0), + SPH_C32(0xe5573b84), SPH_C32(0xf2ef1177) }, + { SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), SPH_C32(0x79a90df9), + SPH_C32(0x63e92178), SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), + SPH_C32(0x806741fd), SPH_C32(0x814681b8) }, + { SPH_C32(0x4b6e0000), SPH_C32(0x7bd4fe56), SPH_C32(0xe7c38e87), + SPH_C32(0x3b116927), SPH_C32(0x41780028), SPH_C32(0xda4a22dd), + SPH_C32(0xe07e5182), SPH_C32(0x6117e1d6) }, + { SPH_C32(0x0d2e0010), SPH_C32(0x8949bfe9), SPH_C32(0x854e2bfb), + SPH_C32(0x12be7119), SPH_C32(0xd0f30020), SPH_C32(0x2c804e6d), + SPH_C32(0xbcb34701), SPH_C32(0x30b21104) }, + { SPH_C32(0x1a320010), SPH_C32(0x3b278cad), SPH_C32(0x1b24a885), + SPH_C32(0x4a463946), SPH_C32(0x6f410028), SPH_C32(0xbe974454), + SPH_C32(0xdcaa577e), SPH_C32(0xd0e3716a) }, + { SPH_C32(0x724b0000), SPH_C32(0xad67ab9b), SPH_C32(0x457d0b05), + SPH_C32(0xd21db1c4), SPH_C32(0x81af0030), SPH_C32(0x6c733c96), + SPH_C32(0x40546103), SPH_C32(0x41e54165) }, + { SPH_C32(0x65570000), SPH_C32(0x1f0998df), SPH_C32(0xdb17887b), + SPH_C32(0x8ae5f99b), SPH_C32(0x3e1d0038), SPH_C32(0xfe6436af), + SPH_C32(0x204d717c), SPH_C32(0xa1b4210b) }, + { SPH_C32(0x23170010), SPH_C32(0xed94d960), SPH_C32(0xb99a2d07), + SPH_C32(0xa34ae1a5), SPH_C32(0xaf960030), SPH_C32(0x08ae5a1f), + SPH_C32(0x7c8067ff), SPH_C32(0xf011d1d9) }, + { SPH_C32(0x340b0010), SPH_C32(0x5ffaea24), SPH_C32(0x27f0ae79), + SPH_C32(0xfbb2a9fa), SPH_C32(0x10240038), SPH_C32(0x9ab95026), + SPH_C32(0x1c997780), SPH_C32(0x1040b1b7) }, + { SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), SPH_C32(0x806741fd), + SPH_C32(0x814681b8), SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), + SPH_C32(0xf9ce4c04), SPH_C32(0xe2afa0c0) }, + { SPH_C32(0xe9d60020), SPH_C32(0xfa331ba0), SPH_C32(0x1e0dc283), + SPH_C32(0xd9bec9e7), SPH_C32(0x1d0a0028), SPH_C32(0x13f0efcf), + SPH_C32(0x99d75c7b), SPH_C32(0x02fec0ae) }, + { SPH_C32(0xaf960030), SPH_C32(0x08ae5a1f), SPH_C32(0x7c8067ff), + SPH_C32(0xf011d1d9), SPH_C32(0x8c810020), SPH_C32(0xe53a837f), + SPH_C32(0xc51a4af8), SPH_C32(0x535b307c) }, + { SPH_C32(0xb88a0030), SPH_C32(0xbac0695b), SPH_C32(0xe2eae481), + SPH_C32(0xa8e99986), SPH_C32(0x33330028), SPH_C32(0x772d8946), + SPH_C32(0xa5035a87), SPH_C32(0xb30a5012) }, + { SPH_C32(0xd0f30020), SPH_C32(0x2c804e6d), SPH_C32(0xbcb34701), + SPH_C32(0x30b21104), SPH_C32(0xdddd0030), SPH_C32(0xa5c9f184), + SPH_C32(0x39fd6cfa), SPH_C32(0x220c601d) }, + { SPH_C32(0xc7ef0020), SPH_C32(0x9eee7d29), SPH_C32(0x22d9c47f), + SPH_C32(0x684a595b), SPH_C32(0x626f0038), SPH_C32(0x37defbbd), + SPH_C32(0x59e47c85), SPH_C32(0xc25d0073) }, + { SPH_C32(0x81af0030), SPH_C32(0x6c733c96), SPH_C32(0x40546103), + SPH_C32(0x41e54165), SPH_C32(0xf3e40030), SPH_C32(0xc114970d), + SPH_C32(0x05296a06), SPH_C32(0x93f8f0a1) }, + { SPH_C32(0x96b30030), SPH_C32(0xde1d0fd2), SPH_C32(0xde3ee27d), + SPH_C32(0x191d093a), SPH_C32(0x4c560038), SPH_C32(0x53039d34), + SPH_C32(0x65307a79), SPH_C32(0x73a990cf) } +}; + +static const sph_u32 T256_25[32][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), SPH_C32(0x99e585aa), + SPH_C32(0x8d75f7f1), SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), + SPH_C32(0x79e22a4c), SPH_C32(0x1298bd46) }, + { SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), SPH_C32(0x79e22a4c), + SPH_C32(0x1298bd46), SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), + SPH_C32(0xe007afe6), SPH_C32(0x9fed4ab7) }, + { SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), SPH_C32(0xe007afe6), + SPH_C32(0x9fed4ab7), SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), + SPH_C32(0x99e585aa), SPH_C32(0x8d75f7f1) }, + { SPH_C32(0xd0080004), SPH_C32(0x8c768f77), SPH_C32(0x9dc5b050), + SPH_C32(0xaf4a29da), SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), + SPH_C32(0x98321c3d), SPH_C32(0x76acc733) }, + { SPH_C32(0x582b0006), SPH_C32(0xd39128c4), SPH_C32(0x042035fa), + SPH_C32(0x223fde2b), SPH_C32(0x3a050000), SPH_C32(0x6508f6be), + SPH_C32(0xe1d03671), SPH_C32(0x64347a75) }, + { SPH_C32(0x81a40004), SPH_C32(0xa9958063), SPH_C32(0xe4279a1c), + SPH_C32(0xbdd2949c), SPH_C32(0xb2260002), SPH_C32(0x3aef510d), + SPH_C32(0x7835b3db), SPH_C32(0xe9418d84) }, + { SPH_C32(0x09870006), SPH_C32(0xf67227d0), SPH_C32(0x7dc21fb6), + SPH_C32(0x30a7636d), SPH_C32(0xe38a0002), SPH_C32(0x1f0c5e19), + SPH_C32(0x01d79997), SPH_C32(0xfbd930c2) }, + { SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), SPH_C32(0x98321c3d), + SPH_C32(0x76acc733), SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), + SPH_C32(0x05f7ac6d), SPH_C32(0xd9e6eee9) }, + { SPH_C32(0xe38a0002), SPH_C32(0x1f0c5e19), SPH_C32(0x01d79997), + SPH_C32(0xfbd930c2), SPH_C32(0xea0d0004), SPH_C32(0xe97e79c9), + SPH_C32(0x7c158621), SPH_C32(0xcb7e53af) }, + { SPH_C32(0x3a050000), SPH_C32(0x6508f6be), SPH_C32(0xe1d03671), + SPH_C32(0x64347a75), SPH_C32(0x622e0006), SPH_C32(0xb699de7a), + SPH_C32(0xe5f0038b), SPH_C32(0x460ba45e) }, + { SPH_C32(0xb2260002), SPH_C32(0x3aef510d), SPH_C32(0x7835b3db), + SPH_C32(0xe9418d84), SPH_C32(0x33820006), SPH_C32(0x937ad16e), + SPH_C32(0x9c1229c7), SPH_C32(0x54931918) }, + { SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), SPH_C32(0x05f7ac6d), + SPH_C32(0xd9e6eee9), SPH_C32(0xd0080004), SPH_C32(0x8c768f77), + SPH_C32(0x9dc5b050), SPH_C32(0xaf4a29da) }, + { SPH_C32(0x33820006), SPH_C32(0x937ad16e), SPH_C32(0x9c1229c7), + SPH_C32(0x54931918), SPH_C32(0x81a40004), SPH_C32(0xa9958063), + SPH_C32(0xe4279a1c), SPH_C32(0xbdd2949c) }, + { SPH_C32(0xea0d0004), SPH_C32(0xe97e79c9), SPH_C32(0x7c158621), + SPH_C32(0xcb7e53af), SPH_C32(0x09870006), SPH_C32(0xf67227d0), + SPH_C32(0x7dc21fb6), SPH_C32(0x30a7636d) }, + { SPH_C32(0x622e0006), SPH_C32(0xb699de7a), SPH_C32(0xe5f0038b), + SPH_C32(0x460ba45e), SPH_C32(0x582b0006), SPH_C32(0xd39128c4), + SPH_C32(0x042035fa), SPH_C32(0x223fde2b) }, + { SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), SPH_C32(0xfe739301), + SPH_C32(0xb8a92831), SPH_C32(0x171c0000), SPH_C32(0xb26e3344), + SPH_C32(0x9e6a837e), SPH_C32(0x58f8485f) }, + { SPH_C32(0x208d000a), SPH_C32(0x7f9e9ece), SPH_C32(0x679616ab), + SPH_C32(0x35dcdfc0), SPH_C32(0x46b00000), SPH_C32(0x978d3c50), + SPH_C32(0xe788a932), SPH_C32(0x4a60f519) }, + { SPH_C32(0xf9020008), SPH_C32(0x059a3669), SPH_C32(0x8791b94d), + SPH_C32(0xaa319577), SPH_C32(0xce930002), SPH_C32(0xc86a9be3), + SPH_C32(0x7e6d2c98), SPH_C32(0xc71502e8) }, + { SPH_C32(0x7121000a), SPH_C32(0x5a7d91da), SPH_C32(0x1e743ce7), + SPH_C32(0x27446286), SPH_C32(0x9f3f0002), SPH_C32(0xed8994f7), + SPH_C32(0x078f06d4), SPH_C32(0xd58dbfae) }, + { SPH_C32(0x78a6000c), SPH_C32(0xac0fb60a), SPH_C32(0x63b62351), + SPH_C32(0x17e301eb), SPH_C32(0x7cb50000), SPH_C32(0xf285caee), + SPH_C32(0x06589f43), SPH_C32(0x2e548f6c) }, + { SPH_C32(0xf085000e), SPH_C32(0xf3e811b9), SPH_C32(0xfa53a6fb), + SPH_C32(0x9a96f61a), SPH_C32(0x2d190000), SPH_C32(0xd766c5fa), + SPH_C32(0x7fbab50f), SPH_C32(0x3ccc322a) }, + { SPH_C32(0x290a000c), SPH_C32(0x89ecb91e), SPH_C32(0x1a54091d), + SPH_C32(0x057bbcad), SPH_C32(0xa53a0002), SPH_C32(0x88816249), + SPH_C32(0xe65f30a5), SPH_C32(0xb1b9c5db) }, + { SPH_C32(0xa129000e), SPH_C32(0xd60b1ead), SPH_C32(0x83b18cb7), + SPH_C32(0x880e4b5c), SPH_C32(0xf4960002), SPH_C32(0xad626d5d), + SPH_C32(0x9fbd1ae9), SPH_C32(0xa321789d) }, + { SPH_C32(0xc3070008), SPH_C32(0x6092c0d7), SPH_C32(0x66418f3c), + SPH_C32(0xce05ef02), SPH_C32(0xacbd0004), SPH_C32(0x7ef34599), + SPH_C32(0x9b9d2f13), SPH_C32(0x811ea6b6) }, + { SPH_C32(0x4b24000a), SPH_C32(0x3f756764), SPH_C32(0xffa40a96), + SPH_C32(0x437018f3), SPH_C32(0xfd110004), SPH_C32(0x5b104a8d), + SPH_C32(0xe27f055f), SPH_C32(0x93861bf0) }, + { SPH_C32(0x92ab0008), SPH_C32(0x4571cfc3), SPH_C32(0x1fa3a570), + SPH_C32(0xdc9d5244), SPH_C32(0x75320006), SPH_C32(0x04f7ed3e), + SPH_C32(0x7b9a80f5), SPH_C32(0x1ef3ec01) }, + { SPH_C32(0x1a88000a), SPH_C32(0x1a966870), SPH_C32(0x864620da), + SPH_C32(0x51e8a5b5), SPH_C32(0x249e0006), SPH_C32(0x2114e22a), + SPH_C32(0x0278aab9), SPH_C32(0x0c6b5147) }, + { SPH_C32(0x130f000c), SPH_C32(0xece44fa0), SPH_C32(0xfb843f6c), + SPH_C32(0x614fc6d8), SPH_C32(0xc7140004), SPH_C32(0x3e18bc33), + SPH_C32(0x03af332e), SPH_C32(0xf7b26185) }, + { SPH_C32(0x9b2c000e), SPH_C32(0xb303e813), SPH_C32(0x6261bac6), + SPH_C32(0xec3a3129), SPH_C32(0x96b80004), SPH_C32(0x1bfbb327), + SPH_C32(0x7a4d1962), SPH_C32(0xe52adcc3) }, + { SPH_C32(0x42a3000c), SPH_C32(0xc90740b4), SPH_C32(0x82661520), + SPH_C32(0x73d77b9e), SPH_C32(0x1e9b0006), SPH_C32(0x441c1494), + SPH_C32(0xe3a89cc8), SPH_C32(0x685f2b32) }, + { SPH_C32(0xca80000e), SPH_C32(0x96e0e707), SPH_C32(0x1b83908a), + SPH_C32(0xfea28c6f), SPH_C32(0x4f370006), SPH_C32(0x61ff1b80), + SPH_C32(0x9a4ab684), SPH_C32(0x7ac79674) } +}; + +static const sph_u32 T256_30[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), SPH_C32(0xae0ebb05), + SPH_C32(0xb5a4c63b), SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), + SPH_C32(0x6bf648a4), SPH_C32(0x539cbdbf) }, + { SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), SPH_C32(0x6bf648a4), + SPH_C32(0x539cbdbf), SPH_C32(0x08bf0001), SPH_C32(0x38942792), + SPH_C32(0xc5f8f3a1), SPH_C32(0xe6387b84) }, + { SPH_C32(0x08bf0001), SPH_C32(0x38942792), SPH_C32(0xc5f8f3a1), + SPH_C32(0xe6387b84), SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), + SPH_C32(0xae0ebb05), SPH_C32(0xb5a4c63b) } +}; + +#define INPUT_SMALL do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T256_0[acc >> 3][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + acc = (acc << 8) | buf[1]; \ + rp = &T256_5[(acc >> 6) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_10[(acc >> 1) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = (acc << 8) | buf[2]; \ + rp = &T256_15[(acc >> 4) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = (acc << 8) | buf[3]; \ + rp = &T256_20[(acc >> 7) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_25[(acc >> 2) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_30[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_SMALL == 6 + +static const sph_u32 T256_0[64][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), SPH_C32(0x11fa3a57), + SPH_C32(0x3dc90524), SPH_C32(0x97530000), SPH_C32(0x204f6ed3), + SPH_C32(0x77b9e80f), SPH_C32(0xa1ec5ec1) }, + { SPH_C32(0x97530000), SPH_C32(0x204f6ed3), SPH_C32(0x77b9e80f), + SPH_C32(0xa1ec5ec1), SPH_C32(0x7e792000), SPH_C32(0x9418e22f), + SPH_C32(0x6643d258), SPH_C32(0x9c255be5) }, + { SPH_C32(0x7e792000), SPH_C32(0x9418e22f), SPH_C32(0x6643d258), + SPH_C32(0x9c255be5), SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), + SPH_C32(0x11fa3a57), SPH_C32(0x3dc90524) }, + { SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), SPH_C32(0x8dfacfab), + SPH_C32(0xce36cc72), SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), + SPH_C32(0x848598ba), SPH_C32(0x1041003e) }, + { SPH_C32(0xfb316000), SPH_C32(0xef405514), SPH_C32(0x9c00f5fc), + SPH_C32(0xf3ffc956), SPH_C32(0x71040000), SPH_C32(0x6bfc54f6), + SPH_C32(0xf33c70b5), SPH_C32(0xb1ad5eff) }, + { SPH_C32(0x85484000), SPH_C32(0x7b58b73b), SPH_C32(0xfa4327a4), + SPH_C32(0x6fda92b3), SPH_C32(0x982e2000), SPH_C32(0xdfabd80a), + SPH_C32(0xe2c64ae2), SPH_C32(0x8c645bdb) }, + { SPH_C32(0x6c626000), SPH_C32(0xcf0f3bc7), SPH_C32(0xebb91df3), + SPH_C32(0x52139797), SPH_C32(0x0f7d2000), SPH_C32(0xffe4b6d9), + SPH_C32(0x957fa2ed), SPH_C32(0x2d88051a) }, + { SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), SPH_C32(0x848598ba), + SPH_C32(0x1041003e), SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), + SPH_C32(0x097f5711), SPH_C32(0xde77cc4c) }, + { SPH_C32(0x0f7d2000), SPH_C32(0xffe4b6d9), SPH_C32(0x957fa2ed), + SPH_C32(0x2d88051a), SPH_C32(0x631f4000), SPH_C32(0x30eb8d1e), + SPH_C32(0x7ec6bf1e), SPH_C32(0x7f9b928d) }, + { SPH_C32(0x71040000), SPH_C32(0x6bfc54f6), SPH_C32(0xf33c70b5), + SPH_C32(0xb1ad5eff), SPH_C32(0x8a356000), SPH_C32(0x84bc01e2), + SPH_C32(0x6f3c8549), SPH_C32(0x425297a9) }, + { SPH_C32(0x982e2000), SPH_C32(0xdfabd80a), SPH_C32(0xe2c64ae2), + SPH_C32(0x8c645bdb), SPH_C32(0x1d666000), SPH_C32(0xa4f36f31), + SPH_C32(0x18856d46), SPH_C32(0xe3bec968) }, + { SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), SPH_C32(0x097f5711), + SPH_C32(0xde77cc4c), SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), + SPH_C32(0x8dfacfab), SPH_C32(0xce36cc72) }, + { SPH_C32(0x1d666000), SPH_C32(0xa4f36f31), SPH_C32(0x18856d46), + SPH_C32(0xe3bec968), SPH_C32(0x85484000), SPH_C32(0x7b58b73b), + SPH_C32(0xfa4327a4), SPH_C32(0x6fda92b3) }, + { SPH_C32(0x631f4000), SPH_C32(0x30eb8d1e), SPH_C32(0x7ec6bf1e), + SPH_C32(0x7f9b928d), SPH_C32(0x6c626000), SPH_C32(0xcf0f3bc7), + SPH_C32(0xebb91df3), SPH_C32(0x52139797) }, + { SPH_C32(0x8a356000), SPH_C32(0x84bc01e2), SPH_C32(0x6f3c8549), + SPH_C32(0x425297a9), SPH_C32(0xfb316000), SPH_C32(0xef405514), + SPH_C32(0x9c00f5fc), SPH_C32(0xf3ffc956) }, + { SPH_C32(0xe4788000), SPH_C32(0x859673c1), SPH_C32(0xb5fb2452), + SPH_C32(0x29cc5edf), SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), + SPH_C32(0x62fc79d0), SPH_C32(0x731ebdc2) }, + { SPH_C32(0x0d52a000), SPH_C32(0x31c1ff3d), SPH_C32(0xa4011e05), + SPH_C32(0x14055bfb), SPH_C32(0x930c0000), SPH_C32(0xbc05fd1a), + SPH_C32(0x154591df), SPH_C32(0xd2f2e303) }, + { SPH_C32(0x732b8000), SPH_C32(0xa5d91d12), SPH_C32(0xc242cc5d), + SPH_C32(0x8820001e), SPH_C32(0x7a262000), SPH_C32(0x085271e6), + SPH_C32(0x04bfab88), SPH_C32(0xef3be627) }, + { SPH_C32(0x9a01a000), SPH_C32(0x118e91ee), SPH_C32(0xd3b8f60a), + SPH_C32(0xb5e9053a), SPH_C32(0xed752000), SPH_C32(0x281d1f35), + SPH_C32(0x73064387), SPH_C32(0x4ed7b8e6) }, + { SPH_C32(0xf663c000), SPH_C32(0xde81aa29), SPH_C32(0x3801ebf9), + SPH_C32(0xe7fa92ad), SPH_C32(0xe2080000), SPH_C32(0xd7f9a9ec), + SPH_C32(0xe679e16a), SPH_C32(0x635fbdfc) }, + { SPH_C32(0x1f49e000), SPH_C32(0x6ad626d5), SPH_C32(0x29fbd1ae), + SPH_C32(0xda339789), SPH_C32(0x755b0000), SPH_C32(0xf7b6c73f), + SPH_C32(0x91c00965), SPH_C32(0xc2b3e33d) }, + { SPH_C32(0x6130c000), SPH_C32(0xfecec4fa), SPH_C32(0x4fb803f6), + SPH_C32(0x4616cc6c), SPH_C32(0x9c712000), SPH_C32(0x43e14bc3), + SPH_C32(0x803a3332), SPH_C32(0xff7ae619) }, + { SPH_C32(0x881ae000), SPH_C32(0x4a994806), SPH_C32(0x5e4239a1), + SPH_C32(0x7bdfc948), SPH_C32(0x0b222000), SPH_C32(0x63ae2510), + SPH_C32(0xf783db3d), SPH_C32(0x5e96b8d8) }, + { SPH_C32(0x022f8000), SPH_C32(0xce2549e4), SPH_C32(0x317ebce8), + SPH_C32(0x398d5ee1), SPH_C32(0xf0134000), SPH_C32(0x8cee7004), + SPH_C32(0x6b832ec1), SPH_C32(0xad69718e) }, + { SPH_C32(0xeb05a000), SPH_C32(0x7a72c518), SPH_C32(0x208486bf), + SPH_C32(0x04445bc5), SPH_C32(0x67404000), SPH_C32(0xaca11ed7), + SPH_C32(0x1c3ac6ce), SPH_C32(0x0c852f4f) }, + { SPH_C32(0x957c8000), SPH_C32(0xee6a2737), SPH_C32(0x46c754e7), + SPH_C32(0x98610020), SPH_C32(0x8e6a6000), SPH_C32(0x18f6922b), + SPH_C32(0x0dc0fc99), SPH_C32(0x314c2a6b) }, + { SPH_C32(0x7c56a000), SPH_C32(0x5a3dabcb), SPH_C32(0x573d6eb0), + SPH_C32(0xa5a80504), SPH_C32(0x19396000), SPH_C32(0x38b9fcf8), + SPH_C32(0x7a791496), SPH_C32(0x90a074aa) }, + { SPH_C32(0x1034c000), SPH_C32(0x9532900c), SPH_C32(0xbc847343), + SPH_C32(0xf7bb9293), SPH_C32(0x16444000), SPH_C32(0xc75d4a21), + SPH_C32(0xef06b67b), SPH_C32(0xbd2871b0) }, + { SPH_C32(0xf91ee000), SPH_C32(0x21651cf0), SPH_C32(0xad7e4914), + SPH_C32(0xca7297b7), SPH_C32(0x81174000), SPH_C32(0xe71224f2), + SPH_C32(0x98bf5e74), SPH_C32(0x1cc42f71) }, + { SPH_C32(0x8767c000), SPH_C32(0xb57dfedf), SPH_C32(0xcb3d9b4c), + SPH_C32(0x5657cc52), SPH_C32(0x683d6000), SPH_C32(0x5345a80e), + SPH_C32(0x89456423), SPH_C32(0x210d2a55) }, + { SPH_C32(0x6e4de000), SPH_C32(0x012a7223), SPH_C32(0xdac7a11b), + SPH_C32(0x6b9ec976), SPH_C32(0xff6e6000), SPH_C32(0x730ac6dd), + SPH_C32(0xfefc8c2c), SPH_C32(0x80e17494) }, + { SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), SPH_C32(0x62fc79d0), + SPH_C32(0x731ebdc2), SPH_C32(0xe0278000), SPH_C32(0x19dce008), + SPH_C32(0xd7075d82), SPH_C32(0x5ad2e31d) }, + { SPH_C32(0xed752000), SPH_C32(0x281d1f35), SPH_C32(0x73064387), + SPH_C32(0x4ed7b8e6), SPH_C32(0x77748000), SPH_C32(0x39938edb), + SPH_C32(0xa0beb58d), SPH_C32(0xfb3ebddc) }, + { SPH_C32(0x930c0000), SPH_C32(0xbc05fd1a), SPH_C32(0x154591df), + SPH_C32(0xd2f2e303), SPH_C32(0x9e5ea000), SPH_C32(0x8dc40227), + SPH_C32(0xb1448fda), SPH_C32(0xc6f7b8f8) }, + { SPH_C32(0x7a262000), SPH_C32(0x085271e6), SPH_C32(0x04bfab88), + SPH_C32(0xef3be627), SPH_C32(0x090da000), SPH_C32(0xad8b6cf4), + SPH_C32(0xc6fd67d5), SPH_C32(0x671be639) }, + { SPH_C32(0x16444000), SPH_C32(0xc75d4a21), SPH_C32(0xef06b67b), + SPH_C32(0xbd2871b0), SPH_C32(0x06708000), SPH_C32(0x526fda2d), + SPH_C32(0x5382c538), SPH_C32(0x4a93e323) }, + { SPH_C32(0xff6e6000), SPH_C32(0x730ac6dd), SPH_C32(0xfefc8c2c), + SPH_C32(0x80e17494), SPH_C32(0x91238000), SPH_C32(0x7220b4fe), + SPH_C32(0x243b2d37), SPH_C32(0xeb7fbde2) }, + { SPH_C32(0x81174000), SPH_C32(0xe71224f2), SPH_C32(0x98bf5e74), + SPH_C32(0x1cc42f71), SPH_C32(0x7809a000), SPH_C32(0xc6773802), + SPH_C32(0x35c11760), SPH_C32(0xd6b6b8c6) }, + { SPH_C32(0x683d6000), SPH_C32(0x5345a80e), SPH_C32(0x89456423), + SPH_C32(0x210d2a55), SPH_C32(0xef5aa000), SPH_C32(0xe63856d1), + SPH_C32(0x4278ff6f), SPH_C32(0x775ae607) }, + { SPH_C32(0xe2080000), SPH_C32(0xd7f9a9ec), SPH_C32(0xe679e16a), + SPH_C32(0x635fbdfc), SPH_C32(0x146bc000), SPH_C32(0x097803c5), + SPH_C32(0xde780a93), SPH_C32(0x84a52f51) }, + { SPH_C32(0x0b222000), SPH_C32(0x63ae2510), SPH_C32(0xf783db3d), + SPH_C32(0x5e96b8d8), SPH_C32(0x8338c000), SPH_C32(0x29376d16), + SPH_C32(0xa9c1e29c), SPH_C32(0x25497190) }, + { SPH_C32(0x755b0000), SPH_C32(0xf7b6c73f), SPH_C32(0x91c00965), + SPH_C32(0xc2b3e33d), SPH_C32(0x6a12e000), SPH_C32(0x9d60e1ea), + SPH_C32(0xb83bd8cb), SPH_C32(0x188074b4) }, + { SPH_C32(0x9c712000), SPH_C32(0x43e14bc3), SPH_C32(0x803a3332), + SPH_C32(0xff7ae619), SPH_C32(0xfd41e000), SPH_C32(0xbd2f8f39), + SPH_C32(0xcf8230c4), SPH_C32(0xb96c2a75) }, + { SPH_C32(0xf0134000), SPH_C32(0x8cee7004), SPH_C32(0x6b832ec1), + SPH_C32(0xad69718e), SPH_C32(0xf23cc000), SPH_C32(0x42cb39e0), + SPH_C32(0x5afd9229), SPH_C32(0x94e42f6f) }, + { SPH_C32(0x19396000), SPH_C32(0x38b9fcf8), SPH_C32(0x7a791496), + SPH_C32(0x90a074aa), SPH_C32(0x656fc000), SPH_C32(0x62845733), + SPH_C32(0x2d447a26), SPH_C32(0x350871ae) }, + { SPH_C32(0x67404000), SPH_C32(0xaca11ed7), SPH_C32(0x1c3ac6ce), + SPH_C32(0x0c852f4f), SPH_C32(0x8c45e000), SPH_C32(0xd6d3dbcf), + SPH_C32(0x3cbe4071), SPH_C32(0x08c1748a) }, + { SPH_C32(0x8e6a6000), SPH_C32(0x18f6922b), SPH_C32(0x0dc0fc99), + SPH_C32(0x314c2a6b), SPH_C32(0x1b16e000), SPH_C32(0xf69cb51c), + SPH_C32(0x4b07a87e), SPH_C32(0xa92d2a4b) }, + { SPH_C32(0xe0278000), SPH_C32(0x19dce008), SPH_C32(0xd7075d82), + SPH_C32(0x5ad2e31d), SPH_C32(0xe4788000), SPH_C32(0x859673c1), + SPH_C32(0xb5fb2452), SPH_C32(0x29cc5edf) }, + { SPH_C32(0x090da000), SPH_C32(0xad8b6cf4), SPH_C32(0xc6fd67d5), + SPH_C32(0x671be639), SPH_C32(0x732b8000), SPH_C32(0xa5d91d12), + SPH_C32(0xc242cc5d), SPH_C32(0x8820001e) }, + { SPH_C32(0x77748000), SPH_C32(0x39938edb), SPH_C32(0xa0beb58d), + SPH_C32(0xfb3ebddc), SPH_C32(0x9a01a000), SPH_C32(0x118e91ee), + SPH_C32(0xd3b8f60a), SPH_C32(0xb5e9053a) }, + { SPH_C32(0x9e5ea000), SPH_C32(0x8dc40227), SPH_C32(0xb1448fda), + SPH_C32(0xc6f7b8f8), SPH_C32(0x0d52a000), SPH_C32(0x31c1ff3d), + SPH_C32(0xa4011e05), SPH_C32(0x14055bfb) }, + { SPH_C32(0xf23cc000), SPH_C32(0x42cb39e0), SPH_C32(0x5afd9229), + SPH_C32(0x94e42f6f), SPH_C32(0x022f8000), SPH_C32(0xce2549e4), + SPH_C32(0x317ebce8), SPH_C32(0x398d5ee1) }, + { SPH_C32(0x1b16e000), SPH_C32(0xf69cb51c), SPH_C32(0x4b07a87e), + SPH_C32(0xa92d2a4b), SPH_C32(0x957c8000), SPH_C32(0xee6a2737), + SPH_C32(0x46c754e7), SPH_C32(0x98610020) }, + { SPH_C32(0x656fc000), SPH_C32(0x62845733), SPH_C32(0x2d447a26), + SPH_C32(0x350871ae), SPH_C32(0x7c56a000), SPH_C32(0x5a3dabcb), + SPH_C32(0x573d6eb0), SPH_C32(0xa5a80504) }, + { SPH_C32(0x8c45e000), SPH_C32(0xd6d3dbcf), SPH_C32(0x3cbe4071), + SPH_C32(0x08c1748a), SPH_C32(0xeb05a000), SPH_C32(0x7a72c518), + SPH_C32(0x208486bf), SPH_C32(0x04445bc5) }, + { SPH_C32(0x06708000), SPH_C32(0x526fda2d), SPH_C32(0x5382c538), + SPH_C32(0x4a93e323), SPH_C32(0x1034c000), SPH_C32(0x9532900c), + SPH_C32(0xbc847343), SPH_C32(0xf7bb9293) }, + { SPH_C32(0xef5aa000), SPH_C32(0xe63856d1), SPH_C32(0x4278ff6f), + SPH_C32(0x775ae607), SPH_C32(0x8767c000), SPH_C32(0xb57dfedf), + SPH_C32(0xcb3d9b4c), SPH_C32(0x5657cc52) }, + { SPH_C32(0x91238000), SPH_C32(0x7220b4fe), SPH_C32(0x243b2d37), + SPH_C32(0xeb7fbde2), SPH_C32(0x6e4de000), SPH_C32(0x012a7223), + SPH_C32(0xdac7a11b), SPH_C32(0x6b9ec976) }, + { SPH_C32(0x7809a000), SPH_C32(0xc6773802), SPH_C32(0x35c11760), + SPH_C32(0xd6b6b8c6), SPH_C32(0xf91ee000), SPH_C32(0x21651cf0), + SPH_C32(0xad7e4914), SPH_C32(0xca7297b7) }, + { SPH_C32(0x146bc000), SPH_C32(0x097803c5), SPH_C32(0xde780a93), + SPH_C32(0x84a52f51), SPH_C32(0xf663c000), SPH_C32(0xde81aa29), + SPH_C32(0x3801ebf9), SPH_C32(0xe7fa92ad) }, + { SPH_C32(0xfd41e000), SPH_C32(0xbd2f8f39), SPH_C32(0xcf8230c4), + SPH_C32(0xb96c2a75), SPH_C32(0x6130c000), SPH_C32(0xfecec4fa), + SPH_C32(0x4fb803f6), SPH_C32(0x4616cc6c) }, + { SPH_C32(0x8338c000), SPH_C32(0x29376d16), SPH_C32(0xa9c1e29c), + SPH_C32(0x25497190), SPH_C32(0x881ae000), SPH_C32(0x4a994806), + SPH_C32(0x5e4239a1), SPH_C32(0x7bdfc948) }, + { SPH_C32(0x6a12e000), SPH_C32(0x9d60e1ea), SPH_C32(0xb83bd8cb), + SPH_C32(0x188074b4), SPH_C32(0x1f49e000), SPH_C32(0x6ad626d5), + SPH_C32(0x29fbd1ae), SPH_C32(0xda339789) } +}; + +static const sph_u32 T256_6[64][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), SPH_C32(0x6fc548e1), + SPH_C32(0x898d2cd6), SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), + SPH_C32(0x6a72e5bb), SPH_C32(0x247febe6) }, + { SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), SPH_C32(0x6a72e5bb), + SPH_C32(0x247febe6), SPH_C32(0x9b830400), SPH_C32(0x2227ff88), + SPH_C32(0x05b7ad5a), SPH_C32(0xadf2c730) }, + { SPH_C32(0x9b830400), SPH_C32(0x2227ff88), SPH_C32(0x05b7ad5a), + SPH_C32(0xadf2c730), SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), + SPH_C32(0x6fc548e1), SPH_C32(0x898d2cd6) }, + { SPH_C32(0xde320800), SPH_C32(0x288350fe), SPH_C32(0x71852ac7), + SPH_C32(0xa6bf9f96), SPH_C32(0xe18b0000), SPH_C32(0x5459887d), + SPH_C32(0xbf1283d3), SPH_C32(0x1b666a73) }, + { SPH_C32(0x510c0c00), SPH_C32(0x251e9889), SPH_C32(0x1e406226), + SPH_C32(0x2f32b340), SPH_C32(0xf5360000), SPH_C32(0x7be3bf82), + SPH_C32(0xd5606668), SPH_C32(0x3f198195) }, + { SPH_C32(0xca8f0800), SPH_C32(0x07396701), SPH_C32(0x1bf7cf7c), + SPH_C32(0x82c07470), SPH_C32(0x7a080400), SPH_C32(0x767e77f5), + SPH_C32(0xbaa52e89), SPH_C32(0xb694ad43) }, + { SPH_C32(0x45b10c00), SPH_C32(0x0aa4af76), SPH_C32(0x7432879d), + SPH_C32(0x0b4d58a6), SPH_C32(0x6eb50400), SPH_C32(0x59c4400a), + SPH_C32(0xd0d7cb32), SPH_C32(0x92eb46a5) }, + { SPH_C32(0xe18b0000), SPH_C32(0x5459887d), SPH_C32(0xbf1283d3), + SPH_C32(0x1b666a73), SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), + SPH_C32(0xce97a914), SPH_C32(0xbdd9f5e5) }, + { SPH_C32(0x6eb50400), SPH_C32(0x59c4400a), SPH_C32(0xd0d7cb32), + SPH_C32(0x92eb46a5), SPH_C32(0x2b040800), SPH_C32(0x5360ef7c), + SPH_C32(0xa4e54caf), SPH_C32(0x99a61e03) }, + { SPH_C32(0xf5360000), SPH_C32(0x7be3bf82), SPH_C32(0xd5606668), + SPH_C32(0x3f198195), SPH_C32(0xa43a0c00), SPH_C32(0x5efd270b), + SPH_C32(0xcb20044e), SPH_C32(0x102b32d5) }, + { SPH_C32(0x7a080400), SPH_C32(0x767e77f5), SPH_C32(0xbaa52e89), + SPH_C32(0xb694ad43), SPH_C32(0xb0870c00), SPH_C32(0x714710f4), + SPH_C32(0xa152e1f5), SPH_C32(0x3454d933) }, + { SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), SPH_C32(0xce97a914), + SPH_C32(0xbdd9f5e5), SPH_C32(0xde320800), SPH_C32(0x288350fe), + SPH_C32(0x71852ac7), SPH_C32(0xa6bf9f96) }, + { SPH_C32(0xb0870c00), SPH_C32(0x714710f4), SPH_C32(0xa152e1f5), + SPH_C32(0x3454d933), SPH_C32(0xca8f0800), SPH_C32(0x07396701), + SPH_C32(0x1bf7cf7c), SPH_C32(0x82c07470) }, + { SPH_C32(0x2b040800), SPH_C32(0x5360ef7c), SPH_C32(0xa4e54caf), + SPH_C32(0x99a61e03), SPH_C32(0x45b10c00), SPH_C32(0x0aa4af76), + SPH_C32(0x7432879d), SPH_C32(0x0b4d58a6) }, + { SPH_C32(0xa43a0c00), SPH_C32(0x5efd270b), SPH_C32(0xcb20044e), + SPH_C32(0x102b32d5), SPH_C32(0x510c0c00), SPH_C32(0x251e9889), + SPH_C32(0x1e406226), SPH_C32(0x2f32b340) }, + { SPH_C32(0x74951000), SPH_C32(0x5a2b467e), SPH_C32(0x88fd1d2b), + SPH_C32(0x1ee68292), SPH_C32(0xcba90000), SPH_C32(0x90273769), + SPH_C32(0xbbdcf407), SPH_C32(0xd0f4af61) }, + { SPH_C32(0xfbab1400), SPH_C32(0x57b68e09), SPH_C32(0xe73855ca), + SPH_C32(0x976bae44), SPH_C32(0xdf140000), SPH_C32(0xbf9d0096), + SPH_C32(0xd1ae11bc), SPH_C32(0xf48b4487) }, + { SPH_C32(0x60281000), SPH_C32(0x75917181), SPH_C32(0xe28ff890), + SPH_C32(0x3a9496974), SPH_C32(0x502a0400), SPH_C32(0xb200c8e1), + SPH_C32(0xbe6b595d), SPH_C32(0x7d066851) }, + { SPH_C32(0xef161400), SPH_C32(0x780cb9f6), SPH_C32(0x8d4ab071), + SPH_C32(0xb31445a2), SPH_C32(0x44970400), SPH_C32(0x9dbaff1e), + SPH_C32(0xd419bce6), SPH_C32(0x597983b7) }, + { SPH_C32(0xaaa71800), SPH_C32(0x72a81680), SPH_C32(0xf97837ec), + SPH_C32(0xb8591d04), SPH_C32(0x2a220000), SPH_C32(0xc47ebf14), + SPH_C32(0x04ce77d4), SPH_C32(0xcb92c512) }, + { SPH_C32(0x25991c00), SPH_C32(0x7f35def7), SPH_C32(0x96bd7f0d), + SPH_C32(0x31d431d2), SPH_C32(0x3e9f0000), SPH_C32(0xebc488eb), + SPH_C32(0x6ebc926f), SPH_C32(0xefed2ef4) }, + { SPH_C32(0xbe1a1800), SPH_C32(0x5d12217f), SPH_C32(0x930ad257), + SPH_C32(0x9c26f6e2), SPH_C32(0xb1a10400), SPH_C32(0xe659409c), + SPH_C32(0x0179da8e), SPH_C32(0x66600222) }, + { SPH_C32(0x31241c00), SPH_C32(0x508fe908), SPH_C32(0xfccf9ab6), + SPH_C32(0x15abda34), SPH_C32(0xa51c0400), SPH_C32(0xc9e37763), + SPH_C32(0x6b0b3f35), SPH_C32(0x421fe9c4) }, + { SPH_C32(0x951e1000), SPH_C32(0x0e72ce03), SPH_C32(0x37ef9ef8), + SPH_C32(0x0580e8e1), SPH_C32(0xf4100800), SPH_C32(0xecfdefea), + SPH_C32(0x754b5d13), SPH_C32(0x6d2d5a84) }, + { SPH_C32(0x1a201400), SPH_C32(0x03ef0674), SPH_C32(0x582ad619), + SPH_C32(0x8c0dc437), SPH_C32(0xe0ad0800), SPH_C32(0xc347d815), + SPH_C32(0x1f39b8a8), SPH_C32(0x4952b162) }, + { SPH_C32(0x81a31000), SPH_C32(0x21c8f9fc), SPH_C32(0x5d9d7b43), + SPH_C32(0x21ff0307), SPH_C32(0x6f930c00), SPH_C32(0xceda1062), + SPH_C32(0x70fcf049), SPH_C32(0xc0df9db4) }, + { SPH_C32(0x0e9d1400), SPH_C32(0x2c55318b), SPH_C32(0x325833a2), + SPH_C32(0xa8722fd1), SPH_C32(0x7b2e0c00), SPH_C32(0xe160279d), + SPH_C32(0x1a8e15f2), SPH_C32(0xe4a07652) }, + { SPH_C32(0x4b2c1800), SPH_C32(0x26f19efd), SPH_C32(0x466ab43f), + SPH_C32(0xa33f7777), SPH_C32(0x159b0800), SPH_C32(0xb8a46797), + SPH_C32(0xca59dec0), SPH_C32(0x764b30f7) }, + { SPH_C32(0xc4121c00), SPH_C32(0x2b6c568a), SPH_C32(0x29affcde), + SPH_C32(0x2ab25ba1), SPH_C32(0x01260800), SPH_C32(0x971e5068), + SPH_C32(0xa02b3b7b), SPH_C32(0x5234db11) }, + { SPH_C32(0x5f911800), SPH_C32(0x094ba902), SPH_C32(0x2c185184), + SPH_C32(0x87409c91), SPH_C32(0x8e180c00), SPH_C32(0x9a83981f), + SPH_C32(0xcfee739a), SPH_C32(0xdbb9f7c7) }, + { SPH_C32(0xd0af1c00), SPH_C32(0x04d66175), SPH_C32(0x43dd1965), + SPH_C32(0x0ecdb047), SPH_C32(0x9aa50c00), SPH_C32(0xb539afe0), + SPH_C32(0xa59c9621), SPH_C32(0xffc61c21) }, + { SPH_C32(0xcba90000), SPH_C32(0x90273769), SPH_C32(0xbbdcf407), + SPH_C32(0xd0f4af61), SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), + SPH_C32(0x3321e92c), SPH_C32(0xce122df3) }, + { SPH_C32(0x44970400), SPH_C32(0x9dbaff1e), SPH_C32(0xd419bce6), + SPH_C32(0x597983b7), SPH_C32(0xab811000), SPH_C32(0xe5b646e8), + SPH_C32(0x59530c97), SPH_C32(0xea6dc615) }, + { SPH_C32(0xdf140000), SPH_C32(0xbf9d0096), SPH_C32(0xd1ae11bc), + SPH_C32(0xf48b4487), SPH_C32(0x24bf1400), SPH_C32(0xe82b8e9f), + SPH_C32(0x36964476), SPH_C32(0x63e0eac3) }, + { SPH_C32(0x502a0400), SPH_C32(0xb200c8e1), SPH_C32(0xbe6b595d), + SPH_C32(0x7d066851), SPH_C32(0x30021400), SPH_C32(0xc791b960), + SPH_C32(0x5ce4a1cd), SPH_C32(0x479f0125) }, + { SPH_C32(0x159b0800), SPH_C32(0xb8a46797), SPH_C32(0xca59dec0), + SPH_C32(0x764b30f7), SPH_C32(0x5eb71000), SPH_C32(0x9e55f96a), + SPH_C32(0x8c336aff), SPH_C32(0xd5744780) }, + { SPH_C32(0x9aa50c00), SPH_C32(0xb539afe0), SPH_C32(0xa59c9621), + SPH_C32(0xffc61c21), SPH_C32(0x4a0a1000), SPH_C32(0xb1efce95), + SPH_C32(0xe6418f44), SPH_C32(0xf10bac66) }, + { SPH_C32(0x01260800), SPH_C32(0x971e5068), SPH_C32(0xa02b3b7b), + SPH_C32(0x5234db11), SPH_C32(0xc5341400), SPH_C32(0xbc7206e2), + SPH_C32(0x8984c7a5), SPH_C32(0x788680b0) }, + { SPH_C32(0x8e180c00), SPH_C32(0x9a83981f), SPH_C32(0xcfee739a), + SPH_C32(0xdbb9f7c7), SPH_C32(0xd1891400), SPH_C32(0x93c8311d), + SPH_C32(0xe3f6221e), SPH_C32(0x5cf96b56) }, + { SPH_C32(0x2a220000), SPH_C32(0xc47ebf14), SPH_C32(0x04ce77d4), + SPH_C32(0xcb92c512), SPH_C32(0x80851800), SPH_C32(0xb6d6a994), + SPH_C32(0xfdb64038), SPH_C32(0x73cbd816) }, + { SPH_C32(0xa51c0400), SPH_C32(0xc9e37763), SPH_C32(0x6b0b3f35), + SPH_C32(0x421fe9c4), SPH_C32(0x94381800), SPH_C32(0x996c9e6b), + SPH_C32(0x97c4a583), SPH_C32(0x57b433f0) }, + { SPH_C32(0x3e9f0000), SPH_C32(0xebc488eb), SPH_C32(0x6ebc926f), + SPH_C32(0xefed2ef4), SPH_C32(0x1b061c00), SPH_C32(0x94f1561c), + SPH_C32(0xf801ed62), SPH_C32(0xde391f26) }, + { SPH_C32(0xb1a10400), SPH_C32(0xe659409c), SPH_C32(0x0179da8e), + SPH_C32(0x66600222), SPH_C32(0x0fbb1c00), SPH_C32(0xbb4b61e3), + SPH_C32(0x927308d9), SPH_C32(0xfa46f4c0) }, + { SPH_C32(0xf4100800), SPH_C32(0xecfdefea), SPH_C32(0x754b5d13), + SPH_C32(0x6d2d5a84), SPH_C32(0x610e1800), SPH_C32(0xe28f21e9), + SPH_C32(0x42a4c3eb), SPH_C32(0x68adb265) }, + { SPH_C32(0x7b2e0c00), SPH_C32(0xe160279d), SPH_C32(0x1a8e15f2), + SPH_C32(0xe4a07652), SPH_C32(0x75b31800), SPH_C32(0xcd351616), + SPH_C32(0x28d62650), SPH_C32(0x4cd25983) }, + { SPH_C32(0xe0ad0800), SPH_C32(0xc347d815), SPH_C32(0x1f39b8a8), + SPH_C32(0x4952b162), SPH_C32(0xfa8d1c00), SPH_C32(0xc0a8de61), + SPH_C32(0x47136eb1), SPH_C32(0xc55f7555) }, + { SPH_C32(0x6f930c00), SPH_C32(0xceda1062), SPH_C32(0x70fcf049), + SPH_C32(0xc0df9db4), SPH_C32(0xee301c00), SPH_C32(0xef12e99e), + SPH_C32(0x2d618b0a), SPH_C32(0xe1209eb3) }, + { SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), SPH_C32(0x3321e92c), + SPH_C32(0xce122df3), SPH_C32(0x74951000), SPH_C32(0x5a2b467e), + SPH_C32(0x88fd1d2b), SPH_C32(0x1ee68292) }, + { SPH_C32(0x30021400), SPH_C32(0xc791b960), SPH_C32(0x5ce4a1cd), + SPH_C32(0x479f0125), SPH_C32(0x60281000), SPH_C32(0x75917181), + SPH_C32(0xe28ff890), SPH_C32(0x3a9496974) }, + { SPH_C32(0xab811000), SPH_C32(0xe5b646e8), SPH_C32(0x59530c97), + SPH_C32(0xea6dc615), SPH_C32(0xef161400), SPH_C32(0x780cb9f6), + SPH_C32(0x8d4ab071), SPH_C32(0xb31445a2) }, + { SPH_C32(0x24bf1400), SPH_C32(0xe82b8e9f), SPH_C32(0x36964476), + SPH_C32(0x63e0eac3), SPH_C32(0xfbab1400), SPH_C32(0x57b68e09), + SPH_C32(0xe73855ca), SPH_C32(0x976bae44) }, + { SPH_C32(0x610e1800), SPH_C32(0xe28f21e9), SPH_C32(0x42a4c3eb), + SPH_C32(0x68adb265), SPH_C32(0x951e1000), SPH_C32(0x0e72ce03), + SPH_C32(0x37ef9ef8), SPH_C32(0x0580e8e1) }, + { SPH_C32(0xee301c00), SPH_C32(0xef12e99e), SPH_C32(0x2d618b0a), + SPH_C32(0xe1209eb3), SPH_C32(0x81a31000), SPH_C32(0x21c8f9fc), + SPH_C32(0x5d9d7b43), SPH_C32(0x21ff0307) }, + { SPH_C32(0x75b31800), SPH_C32(0xcd351616), SPH_C32(0x28d62650), + SPH_C32(0x4cd25983), SPH_C32(0x0e9d1400), SPH_C32(0x2c55318b), + SPH_C32(0x325833a2), SPH_C32(0xa8722fd1) }, + { SPH_C32(0xfa8d1c00), SPH_C32(0xc0a8de61), SPH_C32(0x47136eb1), + SPH_C32(0xc55f7555), SPH_C32(0x1a201400), SPH_C32(0x03ef0674), + SPH_C32(0x582ad619), SPH_C32(0x8c0dc437) }, + { SPH_C32(0x5eb71000), SPH_C32(0x9e55f96a), SPH_C32(0x8c336aff), + SPH_C32(0xd5744780), SPH_C32(0x4b2c1800), SPH_C32(0x26f19efd), + SPH_C32(0x466ab43f), SPH_C32(0xa33f7777) }, + { SPH_C32(0xd1891400), SPH_C32(0x93c8311d), SPH_C32(0xe3f6221e), + SPH_C32(0x5cf96b56), SPH_C32(0x5f911800), SPH_C32(0x094ba902), + SPH_C32(0x2c185184), SPH_C32(0x87409c91) }, + { SPH_C32(0x4a0a1000), SPH_C32(0xb1efce95), SPH_C32(0xe6418f44), + SPH_C32(0xf10bac66), SPH_C32(0xd0af1c00), SPH_C32(0x04d66175), + SPH_C32(0x43dd1965), SPH_C32(0x0ecdb047) }, + { SPH_C32(0xc5341400), SPH_C32(0xbc7206e2), SPH_C32(0x8984c7a5), + SPH_C32(0x788680b0), SPH_C32(0xc4121c00), SPH_C32(0x2b6c568a), + SPH_C32(0x29affcde), SPH_C32(0x2ab25ba1) }, + { SPH_C32(0x80851800), SPH_C32(0xb6d6a994), SPH_C32(0xfdb64038), + SPH_C32(0x73cbd816), SPH_C32(0xaaa71800), SPH_C32(0x72a81680), + SPH_C32(0xf97837ec), SPH_C32(0xb8591d04) }, + { SPH_C32(0x0fbb1c00), SPH_C32(0xbb4b61e3), SPH_C32(0x927308d9), + SPH_C32(0xfa46f4c0), SPH_C32(0xbe1a1800), SPH_C32(0x5d12217f), + SPH_C32(0x930ad257), SPH_C32(0x9c26f6e2) }, + { SPH_C32(0x94381800), SPH_C32(0x996c9e6b), SPH_C32(0x97c4a583), + SPH_C32(0x57b433f0), SPH_C32(0x31241c00), SPH_C32(0x508fe908), + SPH_C32(0xfccf9ab6), SPH_C32(0x15abda34) }, + { SPH_C32(0x1b061c00), SPH_C32(0x94f1561c), SPH_C32(0xf801ed62), + SPH_C32(0xde391f26), SPH_C32(0x25991c00), SPH_C32(0x7f35def7), + SPH_C32(0x96bd7f0d), SPH_C32(0x31d431d2) } +}; + +static const sph_u32 T256_12[64][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), SPH_C32(0xc2c46c55), + SPH_C32(0xf362b233), SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), + SPH_C32(0xd14e094b), SPH_C32(0xb772b42b) }, + { SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), SPH_C32(0xd14e094b), + SPH_C32(0xb772b42b), SPH_C32(0x62740080), SPH_C32(0x0fb84b07), + SPH_C32(0x138a651e), SPH_C32(0x44100618) }, + { SPH_C32(0x62740080), SPH_C32(0x0fb84b07), SPH_C32(0x138a651e), + SPH_C32(0x44100618), SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), + SPH_C32(0xc2c46c55), SPH_C32(0xf362b233) }, + { SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), SPH_C32(0x8589d8ab), + SPH_C32(0xe6c46464), SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), + SPH_C32(0xa29d1297), SPH_C32(0x6ee56854) }, + { SPH_C32(0xec760180), SPH_C32(0xcf102934), SPH_C32(0x474db4fe), + SPH_C32(0x15a6d657), SPH_C32(0x4aea0000), SPH_C32(0xdfd8f43d), + SPH_C32(0x73d31bdc), SPH_C32(0xd997dc7f) }, + { SPH_C32(0x8e020100), SPH_C32(0xc0a86233), SPH_C32(0x54c7d1e0), + SPH_C32(0x51b6d04f), SPH_C32(0x11380080), SPH_C32(0x9ad7ecd1), + SPH_C32(0xb1177789), SPH_C32(0x2af56e4c) }, + { SPH_C32(0xd5d00180), SPH_C32(0x85a77adf), SPH_C32(0x9603bdb5), + SPH_C32(0xa2d4627c), SPH_C32(0x289e0080), SPH_C32(0xd060bf3a), + SPH_C32(0x60597ec2), SPH_C32(0x9d87da67) }, + { SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), SPH_C32(0xa29d1297), + SPH_C32(0x6ee56854), SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), + SPH_C32(0x2714ca3c), SPH_C32(0x88210c30) }, + { SPH_C32(0x289e0080), SPH_C32(0xd060bf3a), SPH_C32(0x60597ec2), + SPH_C32(0x9d87da67), SPH_C32(0xfd4e0100), SPH_C32(0x55c7c5e5), + SPH_C32(0xf65ac377), SPH_C32(0x3f53b81b) }, + { SPH_C32(0x4aea0000), SPH_C32(0xdfd8f43d), SPH_C32(0x73d31bdc), + SPH_C32(0xd997dc7f), SPH_C32(0xa69c0180), SPH_C32(0x10c8dd09), + SPH_C32(0x349eaf22), SPH_C32(0xcc310a28) }, + { SPH_C32(0x11380080), SPH_C32(0x9ad7ecd1), SPH_C32(0xb1177789), + SPH_C32(0x2af56e4c), SPH_C32(0x9f3a0180), SPH_C32(0x5a7f8ee2), + SPH_C32(0xe5d0a669), SPH_C32(0x7b43be03) }, + { SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), SPH_C32(0x2714ca3c), + SPH_C32(0x88210c30), SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), + SPH_C32(0x8589d8ab), SPH_C32(0xe6c46464) }, + { SPH_C32(0x9f3a0180), SPH_C32(0x5a7f8ee2), SPH_C32(0xe5d0a669), + SPH_C32(0x7b43be03), SPH_C32(0x8e020100), SPH_C32(0xc0a86233), + SPH_C32(0x54c7d1e0), SPH_C32(0x51b6d04f) }, + { SPH_C32(0xfd4e0100), SPH_C32(0x55c7c5e5), SPH_C32(0xf65ac377), + SPH_C32(0x3f53b81b), SPH_C32(0xd5d00180), SPH_C32(0x85a77adf), + SPH_C32(0x9603bdb5), SPH_C32(0xa2d4627c) }, + { SPH_C32(0xa69c0180), SPH_C32(0x10c8dd09), SPH_C32(0x349eaf22), + SPH_C32(0xcc310a28), SPH_C32(0xec760180), SPH_C32(0xcf102934), + SPH_C32(0x474db4fe), SPH_C32(0x15a6d657) }, + { SPH_C32(0xa7b80200), SPH_C32(0x1f128433), SPH_C32(0x60e5f9f2), + SPH_C32(0x9e147576), SPH_C32(0xee260000), SPH_C32(0x124b683e), + SPH_C32(0x80c2d68f), SPH_C32(0x3bf3ab2c) }, + { SPH_C32(0xfc6a0280), SPH_C32(0x5a1d9cdf), SPH_C32(0xa22195a7), + SPH_C32(0x6d76c745), SPH_C32(0xd7800000), SPH_C32(0x58fc3bd5), + SPH_C32(0x518cdfc4), SPH_C32(0x8c811f07) }, + { SPH_C32(0x9e1e0200), SPH_C32(0x55a5d7d8), SPH_C32(0xb1abf0b9), + SPH_C32(0x2966c15d), SPH_C32(0x8c520080), SPH_C32(0x1df32339), + SPH_C32(0x9348b391), SPH_C32(0x7fe3ad34) }, + { SPH_C32(0xc5cc0280), SPH_C32(0x10aacf34), SPH_C32(0x736f9cec), + SPH_C32(0xda04736e), SPH_C32(0xb5f40080), SPH_C32(0x574470d2), + SPH_C32(0x4206bada), SPH_C32(0xc891191f) }, + { SPH_C32(0x101c0300), SPH_C32(0x950db5eb), SPH_C32(0xe56c2159), + SPH_C32(0x78d01112), SPH_C32(0x9d6a0000), SPH_C32(0x8724cfe8), + SPH_C32(0x225fc418), SPH_C32(0x5516c378) }, + { SPH_C32(0x4bce0380), SPH_C32(0xd002ad07), SPH_C32(0x27a84d0c), + SPH_C32(0x8bb2a321), SPH_C32(0xa4cc0000), SPH_C32(0xcd939c03), + SPH_C32(0xf311cd53), SPH_C32(0xe2647753) }, + { SPH_C32(0x29ba0300), SPH_C32(0xdfbae600), SPH_C32(0x34222812), + SPH_C32(0xcfa2a539), SPH_C32(0xff1e0080), SPH_C32(0x889c84ef), + SPH_C32(0x31d5a106), SPH_C32(0x1106c560) }, + { SPH_C32(0x72680380), SPH_C32(0x9ab5feec), SPH_C32(0xf6e64447), + SPH_C32(0x3cc0170a), SPH_C32(0xc6b80080), SPH_C32(0xc22bd704), + SPH_C32(0xe09ba84d), SPH_C32(0xa674714b) }, + { SPH_C32(0xd4f40200), SPH_C32(0x8a7d23e5), SPH_C32(0xc278eb65), + SPH_C32(0xf0f11d22), SPH_C32(0x2ace0100), SPH_C32(0x0d3bfe30), + SPH_C32(0xa7d61cb3), SPH_C32(0xb3d2a71c) }, + { SPH_C32(0x8f260280), SPH_C32(0xcf723b09), SPH_C32(0x00bc8730), + SPH_C32(0x0393af11), SPH_C32(0x13680100), SPH_C32(0x478caddb), + SPH_C32(0x769815f8), SPH_C32(0x04a01337) }, + { SPH_C32(0xed520200), SPH_C32(0xc0ca700e), SPH_C32(0x1336e22e), + SPH_C32(0x4783a909), SPH_C32(0x48ba0180), SPH_C32(0x0283b537), + SPH_C32(0xb45c79ad), SPH_C32(0xf7c2a104) }, + { SPH_C32(0xb6800280), SPH_C32(0x85c568e2), SPH_C32(0xd1f28e7b), + SPH_C32(0xb4e11b3a), SPH_C32(0x711c0180), SPH_C32(0x4834e6dc), + SPH_C32(0x651270e6), SPH_C32(0x40b0152f) }, + { SPH_C32(0x63500300), SPH_C32(0x0062123d), SPH_C32(0x47f133ce), + SPH_C32(0x16357946), SPH_C32(0x59820100), SPH_C32(0x985459e6), + SPH_C32(0x054b0e24), SPH_C32(0xdd37cf48) }, + { SPH_C32(0x38820380), SPH_C32(0x456d0ad1), SPH_C32(0x85355f9b), + SPH_C32(0xe557cb75), SPH_C32(0x60240100), SPH_C32(0xd2e30a0d), + SPH_C32(0xd405076f), SPH_C32(0x6a457b63) }, + { SPH_C32(0x5af60300), SPH_C32(0x4ad541d6), SPH_C32(0x96bf3a85), + SPH_C32(0xa147cd6d), SPH_C32(0x3bf60180), SPH_C32(0x97ec12e1), + SPH_C32(0x16c16b3a), SPH_C32(0x9927c950) }, + { SPH_C32(0x01240380), SPH_C32(0x0fda593a), SPH_C32(0x547b56d0), + SPH_C32(0x52257f5e), SPH_C32(0x02500180), SPH_C32(0xdd5b410a), + SPH_C32(0xc78f6271), SPH_C32(0x2e557d7b) }, + { SPH_C32(0xee260000), SPH_C32(0x124b683e), SPH_C32(0x80c2d68f), + SPH_C32(0x3bf3ab2c), SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), + SPH_C32(0xe0272f7d), SPH_C32(0xa5e7de5a) }, + { SPH_C32(0xb5f40080), SPH_C32(0x574470d2), SPH_C32(0x4206bada), + SPH_C32(0xc891191f), SPH_C32(0x70380200), SPH_C32(0x47eebfe6), + SPH_C32(0x31692636), SPH_C32(0x12956a71) }, + { SPH_C32(0xd7800000), SPH_C32(0x58fc3bd5), SPH_C32(0x518cdfc4), + SPH_C32(0x8c811f07), SPH_C32(0x2bea0280), SPH_C32(0x02e1a70a), + SPH_C32(0xf3ad4a63), SPH_C32(0xe1f7d842) }, + { SPH_C32(0x8c520080), SPH_C32(0x1df32339), SPH_C32(0x9348b391), + SPH_C32(0x7fe3ad34), SPH_C32(0x124c0280), SPH_C32(0x4856f4e1), + SPH_C32(0x22e34328), SPH_C32(0x56856c69) }, + { SPH_C32(0x59820100), SPH_C32(0x985459e6), SPH_C32(0x054b0e24), + SPH_C32(0xdd37cf48), SPH_C32(0x3ad20200), SPH_C32(0x98364bdb), + SPH_C32(0x42ba3dea), SPH_C32(0xcb02b60e) }, + { SPH_C32(0x02500180), SPH_C32(0xdd5b410a), SPH_C32(0xc78f6271), + SPH_C32(0x2e557d7b), SPH_C32(0x03740200), SPH_C32(0xd2811830), + SPH_C32(0x93f434a1), SPH_C32(0x7c700225) }, + { SPH_C32(0x60240100), SPH_C32(0xd2e30a0d), SPH_C32(0xd405076f), + SPH_C32(0x6a457b63), SPH_C32(0x58a60280), SPH_C32(0x978e00dc), + SPH_C32(0x513058f4), SPH_C32(0x8f12b016) }, + { SPH_C32(0x3bf60180), SPH_C32(0x97ec12e1), SPH_C32(0x16c16b3a), + SPH_C32(0x9927c950), SPH_C32(0x61000280), SPH_C32(0xdd395337), + SPH_C32(0x807e51bf), SPH_C32(0x3860043d) }, + { SPH_C32(0x9d6a0000), SPH_C32(0x8724cfe8), SPH_C32(0x225fc418), + SPH_C32(0x5516c378), SPH_C32(0x8d760300), SPH_C32(0x12297a03), + SPH_C32(0xc733e541), SPH_C32(0x2dc6d26a) }, + { SPH_C32(0xc6b80080), SPH_C32(0xc22bd704), SPH_C32(0xe09ba84d), + SPH_C32(0xa674714b), SPH_C32(0xb4d00300), SPH_C32(0x589e29e8), + SPH_C32(0x167dec0a), SPH_C32(0x9ab46641) }, + { SPH_C32(0xa4cc0000), SPH_C32(0xcd939c03), SPH_C32(0xf311cd53), + SPH_C32(0xe2647753), SPH_C32(0xef020380), SPH_C32(0x1d913104), + SPH_C32(0xd4b9805f), SPH_C32(0x69d6d472) }, + { SPH_C32(0xff1e0080), SPH_C32(0x889c84ef), SPH_C32(0x31d5a106), + SPH_C32(0x1106c560), SPH_C32(0xd6a40380), SPH_C32(0x572662ef), + SPH_C32(0x05f78914), SPH_C32(0xdea46059) }, + { SPH_C32(0x2ace0100), SPH_C32(0x0d3bfe30), SPH_C32(0xa7d61cb3), + SPH_C32(0xb3d2a71c), SPH_C32(0xfe3a0300), SPH_C32(0x8746ddd5), + SPH_C32(0x65aef7d6), SPH_C32(0x4323ba3e) }, + { SPH_C32(0x711c0180), SPH_C32(0x4834e6dc), SPH_C32(0x651270e6), + SPH_C32(0x40b0152f), SPH_C32(0xc79c0300), SPH_C32(0xcdf18e3e), + SPH_C32(0xb4e0fe9d), SPH_C32(0xf4510e15) }, + { SPH_C32(0x13680100), SPH_C32(0x478caddb), SPH_C32(0x769815f8), + SPH_C32(0x04a01337), SPH_C32(0x9c4e0380), SPH_C32(0x88fe96d2), + SPH_C32(0x762492c8), SPH_C32(0x0733bc26) }, + { SPH_C32(0x48ba0180), SPH_C32(0x0283b537), SPH_C32(0xb45c79ad), + SPH_C32(0xf7c2a104), SPH_C32(0xa5e80380), SPH_C32(0xc249c539), + SPH_C32(0xa76a9b83), SPH_C32(0xb041080d) }, + { SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), SPH_C32(0xe0272f7d), + SPH_C32(0xa5e7de5a), SPH_C32(0xa7b80200), SPH_C32(0x1f128433), + SPH_C32(0x60e5f9f2), SPH_C32(0x9e147576) }, + { SPH_C32(0x124c0280), SPH_C32(0x4856f4e1), SPH_C32(0x22e34328), + SPH_C32(0x56856c69), SPH_C32(0x9e1e0200), SPH_C32(0x55a5d7d8), + SPH_C32(0xb1abf0b9), SPH_C32(0x2966c15d) }, + { SPH_C32(0x70380200), SPH_C32(0x47eebfe6), SPH_C32(0x31692636), + SPH_C32(0x12956a71), SPH_C32(0xc5cc0280), SPH_C32(0x10aacf34), + SPH_C32(0x736f9cec), SPH_C32(0xda04736e) }, + { SPH_C32(0x2bea0280), SPH_C32(0x02e1a70a), SPH_C32(0xf3ad4a63), + SPH_C32(0xe1f7d842), SPH_C32(0xfc6a0280), SPH_C32(0x5a1d9cdf), + SPH_C32(0xa22195a7), SPH_C32(0x6d76c745) }, + { SPH_C32(0xfe3a0300), SPH_C32(0x8746ddd5), SPH_C32(0x65aef7d6), + SPH_C32(0x4323ba3e), SPH_C32(0xd4f40200), SPH_C32(0x8a7d23e5), + SPH_C32(0xc278eb65), SPH_C32(0xf0f11d22) }, + { SPH_C32(0xa5e80380), SPH_C32(0xc249c539), SPH_C32(0xa76a9b83), + SPH_C32(0xb041080d), SPH_C32(0xed520200), SPH_C32(0xc0ca700e), + SPH_C32(0x1336e22e), SPH_C32(0x4783a909) }, + { SPH_C32(0xc79c0300), SPH_C32(0xcdf18e3e), SPH_C32(0xb4e0fe9d), + SPH_C32(0xf4510e15), SPH_C32(0xb6800280), SPH_C32(0x85c568e2), + SPH_C32(0xd1f28e7b), SPH_C32(0xb4e11b3a) }, + { SPH_C32(0x9c4e0380), SPH_C32(0x88fe96d2), SPH_C32(0x762492c8), + SPH_C32(0x0733bc26), SPH_C32(0x8f260280), SPH_C32(0xcf723b09), + SPH_C32(0x00bc8730), SPH_C32(0x0393af11) }, + { SPH_C32(0x3ad20200), SPH_C32(0x98364bdb), SPH_C32(0x42ba3dea), + SPH_C32(0xcb02b60e), SPH_C32(0x63500300), SPH_C32(0x0062123d), + SPH_C32(0x47f133ce), SPH_C32(0x16357946) }, + { SPH_C32(0x61000280), SPH_C32(0xdd395337), SPH_C32(0x807e51bf), + SPH_C32(0x3860043d), SPH_C32(0x5af60300), SPH_C32(0x4ad541d6), + SPH_C32(0x96bf3a85), SPH_C32(0xa147cd6d) }, + { SPH_C32(0x03740200), SPH_C32(0xd2811830), SPH_C32(0x93f434a1), + SPH_C32(0x7c700225), SPH_C32(0x01240380), SPH_C32(0x0fda593a), + SPH_C32(0x547b56d0), SPH_C32(0x52257f5e) }, + { SPH_C32(0x58a60280), SPH_C32(0x978e00dc), SPH_C32(0x513058f4), + SPH_C32(0x8f12b016), SPH_C32(0x38820380), SPH_C32(0x456d0ad1), + SPH_C32(0x85355f9b), SPH_C32(0xe557cb75) }, + { SPH_C32(0x8d760300), SPH_C32(0x12297a03), SPH_C32(0xc733e541), + SPH_C32(0x2dc6d26a), SPH_C32(0x101c0300), SPH_C32(0x950db5eb), + SPH_C32(0xe56c2159), SPH_C32(0x78d01112) }, + { SPH_C32(0xd6a40380), SPH_C32(0x572662ef), SPH_C32(0x05f78914), + SPH_C32(0xdea46059), SPH_C32(0x29ba0300), SPH_C32(0xdfbae600), + SPH_C32(0x34222812), SPH_C32(0xcfa2a539) }, + { SPH_C32(0xb4d00300), SPH_C32(0x589e29e8), SPH_C32(0x167dec0a), + SPH_C32(0x9ab46641), SPH_C32(0x72680380), SPH_C32(0x9ab5feec), + SPH_C32(0xf6e64447), SPH_C32(0x3cc0170a) }, + { SPH_C32(0xef020380), SPH_C32(0x1d913104), SPH_C32(0xd4b9805f), + SPH_C32(0x69d6d472), SPH_C32(0x4bce0380), SPH_C32(0xd002ad07), + SPH_C32(0x27a84d0c), SPH_C32(0x8bb2a321) } +}; + +static const sph_u32 T256_18[64][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x515c0010), SPH_C32(0x40f372fb), SPH_C32(0xfce72602), + SPH_C32(0x71575061), SPH_C32(0x2e390000), SPH_C32(0x64dd6689), + SPH_C32(0x3cd406fc), SPH_C32(0xb1f490bc) }, + { SPH_C32(0x2e390000), SPH_C32(0x64dd6689), SPH_C32(0x3cd406fc), + SPH_C32(0xb1f490bc), SPH_C32(0x7f650010), SPH_C32(0x242e1472), + SPH_C32(0xc03320fe), SPH_C32(0xc0a3c0dd) }, + { SPH_C32(0x7f650010), SPH_C32(0x242e1472), SPH_C32(0xc03320fe), + SPH_C32(0xc0a3c0dd), SPH_C32(0x515c0010), SPH_C32(0x40f372fb), + SPH_C32(0xfce72602), SPH_C32(0x71575061) }, + { SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), SPH_C32(0xf9ce4c04), + SPH_C32(0xe2afa0c0), SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), + SPH_C32(0x79a90df9), SPH_C32(0x63e92178) }, + { SPH_C32(0xf3e40030), SPH_C32(0xc114970d), SPH_C32(0x05296a06), + SPH_C32(0x93f8f0a1), SPH_C32(0x724b0000), SPH_C32(0xad67ab9b), + SPH_C32(0x457d0b05), SPH_C32(0xd21db1c4) }, + { SPH_C32(0x8c810020), SPH_C32(0xe53a837f), SPH_C32(0xc51a4af8), + SPH_C32(0x535b307c), SPH_C32(0x23170010), SPH_C32(0xed94d960), + SPH_C32(0xb99a2d07), SPH_C32(0xa34ae1a5) }, + { SPH_C32(0xdddd0030), SPH_C32(0xa5c9f184), SPH_C32(0x39fd6cfa), + SPH_C32(0x220c601d), SPH_C32(0x0d2e0010), SPH_C32(0x8949bfe9), + SPH_C32(0x854e2bfb), SPH_C32(0x12be7119) }, + { SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), SPH_C32(0x79a90df9), + SPH_C32(0x63e92178), SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), + SPH_C32(0x806741fd), SPH_C32(0x814681b8) }, + { SPH_C32(0x0d2e0010), SPH_C32(0x8949bfe9), SPH_C32(0x854e2bfb), + SPH_C32(0x12be7119), SPH_C32(0xd0f30020), SPH_C32(0x2c804e6d), + SPH_C32(0xbcb34701), SPH_C32(0x30b21104) }, + { SPH_C32(0x724b0000), SPH_C32(0xad67ab9b), SPH_C32(0x457d0b05), + SPH_C32(0xd21db1c4), SPH_C32(0x81af0030), SPH_C32(0x6c733c96), + SPH_C32(0x40546103), SPH_C32(0x41e54165) }, + { SPH_C32(0x23170010), SPH_C32(0xed94d960), SPH_C32(0xb99a2d07), + SPH_C32(0xa34ae1a5), SPH_C32(0xaf960030), SPH_C32(0x08ae5a1f), + SPH_C32(0x7c8067ff), SPH_C32(0xf011d1d9) }, + { SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), SPH_C32(0x806741fd), + SPH_C32(0x814681b8), SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), + SPH_C32(0xf9ce4c04), SPH_C32(0xe2afa0c0) }, + { SPH_C32(0xaf960030), SPH_C32(0x08ae5a1f), SPH_C32(0x7c8067ff), + SPH_C32(0xf011d1d9), SPH_C32(0x8c810020), SPH_C32(0xe53a837f), + SPH_C32(0xc51a4af8), SPH_C32(0x535b307c) }, + { SPH_C32(0xd0f30020), SPH_C32(0x2c804e6d), SPH_C32(0xbcb34701), + SPH_C32(0x30b21104), SPH_C32(0xdddd0030), SPH_C32(0xa5c9f184), + SPH_C32(0x39fd6cfa), SPH_C32(0x220c601d) }, + { SPH_C32(0x81af0030), SPH_C32(0x6c733c96), SPH_C32(0x40546103), + SPH_C32(0x41e54165), SPH_C32(0xf3e40030), SPH_C32(0xc114970d), + SPH_C32(0x05296a06), SPH_C32(0x93f8f0a1) }, + { SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), SPH_C32(0x36656ba8), + SPH_C32(0x23633a05), SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), + SPH_C32(0x5d5ca0f7), SPH_C32(0x727784cb) }, + { SPH_C32(0x1c920050), SPH_C32(0x7ba89e85), SPH_C32(0xca824daa), + SPH_C32(0x52346a64), SPH_C32(0x56920000), SPH_C32(0xc4103cbd), + SPH_C32(0x6188a60b), SPH_C32(0xc3831477) }, + { SPH_C32(0x63f70040), SPH_C32(0x5f868af7), SPH_C32(0x0ab16d54), + SPH_C32(0x9297aab9), SPH_C32(0x07ce0010), SPH_C32(0x84e34e46), + SPH_C32(0x9d6f8009), SPH_C32(0xb2d44416) }, + { SPH_C32(0x32ab0050), SPH_C32(0x1f75f80c), SPH_C32(0xf6564b56), + SPH_C32(0xe3c0fad8), SPH_C32(0x29f70010), SPH_C32(0xe03e28cf), + SPH_C32(0xa1bb86f5), SPH_C32(0x0320d4aa) }, + { SPH_C32(0xef760060), SPH_C32(0xbabc0988), SPH_C32(0xcfab27ac), + SPH_C32(0xc1cc9ac5), SPH_C32(0x24d90000), SPH_C32(0x69779726), + SPH_C32(0x24f5ad0e), SPH_C32(0x119ea5b3) }, + { SPH_C32(0xbe2a0070), SPH_C32(0xfa4f7b73), SPH_C32(0x334c01ae), + SPH_C32(0xb09bcaa4), SPH_C32(0x0ae00000), SPH_C32(0x0daaf1af), + SPH_C32(0x1821abf2), SPH_C32(0xa06a350f) }, + { SPH_C32(0xc14f0060), SPH_C32(0xde616f01), SPH_C32(0xf37f2150), + SPH_C32(0x70380a79), SPH_C32(0x5bbc0010), SPH_C32(0x4d598354), + SPH_C32(0xe4c68df0), SPH_C32(0xd13d656e) }, + { SPH_C32(0x90130070), SPH_C32(0x9e921dfa), SPH_C32(0x0f980752), + SPH_C32(0x016f5a18), SPH_C32(0x75850010), SPH_C32(0x2984e5dd), + SPH_C32(0xd8128b0c), SPH_C32(0x60c9f5d2) }, + { SPH_C32(0x11bc0040), SPH_C32(0xf2e1216c), SPH_C32(0x4fcc6651), + SPH_C32(0x408a1b7d), SPH_C32(0x86610020), SPH_C32(0xe89072d0), + SPH_C32(0xdd3be10a), SPH_C32(0xf3310573) }, + { SPH_C32(0x40e00050), SPH_C32(0xb2125397), SPH_C32(0xb32b4053), + SPH_C32(0x31dd4b1c), SPH_C32(0xa8580020), SPH_C32(0x8c4d1459), + SPH_C32(0xe1efe7f6), SPH_C32(0x42c595cf) }, + { SPH_C32(0x3f850040), SPH_C32(0x963c47e5), SPH_C32(0x731860ad), + SPH_C32(0xf17e8bc1), SPH_C32(0xf9040030), SPH_C32(0xccbe66a2), + SPH_C32(0x1d08c1f4), SPH_C32(0x3392c5ae) }, + { SPH_C32(0x6ed90050), SPH_C32(0xd6cf351e), SPH_C32(0x8fff46af), + SPH_C32(0x8029dba0), SPH_C32(0xd73d0030), SPH_C32(0xa863002b), + SPH_C32(0x21dcc708), SPH_C32(0x82665512) }, + { SPH_C32(0xb3040060), SPH_C32(0x7306c49a), SPH_C32(0xb6022a55), + SPH_C32(0xa225bbbd), SPH_C32(0xda130020), SPH_C32(0x212abfc2), + SPH_C32(0xa492ecf3), SPH_C32(0x90d8240b) }, + { SPH_C32(0xe2580070), SPH_C32(0x33f5b661), SPH_C32(0x4ae50c57), + SPH_C32(0xd372ebdc), SPH_C32(0xf42a0020), SPH_C32(0x45f7d94b), + SPH_C32(0x9846ea0f), SPH_C32(0x212cb4b7) }, + { SPH_C32(0x9d3d0060), SPH_C32(0x17dba213), SPH_C32(0x8ad62ca9), + SPH_C32(0x13d12b01), SPH_C32(0xa5760030), SPH_C32(0x0504abb0), + SPH_C32(0x64a1cc0d), SPH_C32(0x507be4d6) }, + { SPH_C32(0xcc610070), SPH_C32(0x5728d0e8), SPH_C32(0x76310aab), + SPH_C32(0x62867b60), SPH_C32(0x8b4f0030), SPH_C32(0x61d9cd39), + SPH_C32(0x5875caf1), SPH_C32(0xe18f746a) }, + { SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), SPH_C32(0x5d5ca0f7), + SPH_C32(0x727784cb), SPH_C32(0x35650040), SPH_C32(0x9b96b64a), + SPH_C32(0x6b39cb5f), SPH_C32(0x5114bece) }, + { SPH_C32(0x29f70010), SPH_C32(0xe03e28cf), SPH_C32(0xa1bb86f5), + SPH_C32(0x0320d4aa), SPH_C32(0x1b5c0040), SPH_C32(0xff4bd0c3), + SPH_C32(0x57edcda3), SPH_C32(0xe0e02e72) }, + { SPH_C32(0x56920000), SPH_C32(0xc4103cbd), SPH_C32(0x6188a60b), + SPH_C32(0xc3831477), SPH_C32(0x4a000050), SPH_C32(0xbfb8a238), + SPH_C32(0xab0aeba1), SPH_C32(0x91b77e13) }, + { SPH_C32(0x07ce0010), SPH_C32(0x84e34e46), SPH_C32(0x9d6f8009), + SPH_C32(0xb2d44416), SPH_C32(0x64390050), SPH_C32(0xdb65c4b1), + SPH_C32(0x97deed5d), SPH_C32(0x2043eeaf) }, + { SPH_C32(0xda130020), SPH_C32(0x212abfc2), SPH_C32(0xa492ecf3), + SPH_C32(0x90d8240b), SPH_C32(0x69170040), SPH_C32(0x522c7b58), + SPH_C32(0x1290c6a6), SPH_C32(0x32fd9fb6) }, + { SPH_C32(0x8b4f0030), SPH_C32(0x61d9cd39), SPH_C32(0x5875caf1), + SPH_C32(0xe18f746a), SPH_C32(0x472e0040), SPH_C32(0x36f11dd1), + SPH_C32(0x2e44c05a), SPH_C32(0x83090f0a) }, + { SPH_C32(0xf42a0020), SPH_C32(0x45f7d94b), SPH_C32(0x9846ea0f), + SPH_C32(0x212cb4b7), SPH_C32(0x16720050), SPH_C32(0x76026f2a), + SPH_C32(0xd2a3e658), SPH_C32(0xf25e5f6b) }, + { SPH_C32(0xa5760030), SPH_C32(0x0504abb0), SPH_C32(0x64a1cc0d), + SPH_C32(0x507be4d6), SPH_C32(0x384b0050), SPH_C32(0x12df09a3), + SPH_C32(0xee77e0a4), SPH_C32(0x43aacfd7) }, + { SPH_C32(0x24d90000), SPH_C32(0x69779726), SPH_C32(0x24f5ad0e), + SPH_C32(0x119ea5b3), SPH_C32(0xcbaf0060), SPH_C32(0xd3cb9eae), + SPH_C32(0xeb5e8aa2), SPH_C32(0xd0523f76) }, + { SPH_C32(0x75850010), SPH_C32(0x2984e5dd), SPH_C32(0xd8128b0c), + SPH_C32(0x60c9f5d2), SPH_C32(0xe5960060), SPH_C32(0xb716f827), + SPH_C32(0xd78a8c5e), SPH_C32(0x61a6afca) }, + { SPH_C32(0x0ae00000), SPH_C32(0x0daaf1af), SPH_C32(0x1821abf2), + SPH_C32(0xa06a350f), SPH_C32(0xb4ca0070), SPH_C32(0xf7e58adc), + SPH_C32(0x2b6daa5c), SPH_C32(0x10f1ffab) }, + { SPH_C32(0x5bbc0010), SPH_C32(0x4d598354), SPH_C32(0xe4c68df0), + SPH_C32(0xd13d656e), SPH_C32(0x9af30070), SPH_C32(0x9338ec55), + SPH_C32(0x17b9aca0), SPH_C32(0xa1056f17) }, + { SPH_C32(0x86610020), SPH_C32(0xe89072d0), SPH_C32(0xdd3be10a), + SPH_C32(0xf3310573), SPH_C32(0x97dd0060), SPH_C32(0x1a7153bc), + SPH_C32(0x92f7875b), SPH_C32(0xb3bb1e0e) }, + { SPH_C32(0xd73d0030), SPH_C32(0xa863002b), SPH_C32(0x21dcc708), + SPH_C32(0x82665512), SPH_C32(0xb9e40060), SPH_C32(0x7eac3535), + SPH_C32(0xae2381a7), SPH_C32(0x024f8eb2) }, + { SPH_C32(0xa8580020), SPH_C32(0x8c4d1459), SPH_C32(0xe1efe7f6), + SPH_C32(0x42c595cf), SPH_C32(0xe8b80070), SPH_C32(0x3e5f47ce), + SPH_C32(0x52c4a7a5), SPH_C32(0x7318ded3) }, + { SPH_C32(0xf9040030), SPH_C32(0xccbe66a2), SPH_C32(0x1d08c1f4), + SPH_C32(0x3392c5ae), SPH_C32(0xc6810070), SPH_C32(0x5a822147), + SPH_C32(0x6e10a159), SPH_C32(0xc2ec4e6f) }, + { SPH_C32(0x35650040), SPH_C32(0x9b96b64a), SPH_C32(0x6b39cb5f), + SPH_C32(0x5114bece), SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), + SPH_C32(0x36656ba8), SPH_C32(0x23633a05) }, + { SPH_C32(0x64390050), SPH_C32(0xdb65c4b1), SPH_C32(0x97deed5d), + SPH_C32(0x2043eeaf), SPH_C32(0x63f70040), SPH_C32(0x5f868af7), + SPH_C32(0x0ab16d54), SPH_C32(0x9297aab9) }, + { SPH_C32(0x1b5c0040), SPH_C32(0xff4bd0c3), SPH_C32(0x57edcda3), + SPH_C32(0xe0e02e72), SPH_C32(0x32ab0050), SPH_C32(0x1f75f80c), + SPH_C32(0xf6564b56), SPH_C32(0xe3c0fad8) }, + { SPH_C32(0x4a000050), SPH_C32(0xbfb8a238), SPH_C32(0xab0aeba1), + SPH_C32(0x91b77e13), SPH_C32(0x1c920050), SPH_C32(0x7ba89e85), + SPH_C32(0xca824daa), SPH_C32(0x52346a64) }, + { SPH_C32(0x97dd0060), SPH_C32(0x1a7153bc), SPH_C32(0x92f7875b), + SPH_C32(0xb3bb1e0e), SPH_C32(0x11bc0040), SPH_C32(0xf2e1216c), + SPH_C32(0x4fcc6651), SPH_C32(0x408a1b7d) }, + { SPH_C32(0xc6810070), SPH_C32(0x5a822147), SPH_C32(0x6e10a159), + SPH_C32(0xc2ec4e6f), SPH_C32(0x3f850040), SPH_C32(0x963c47e5), + SPH_C32(0x731860ad), SPH_C32(0xf17e8bc1) }, + { SPH_C32(0xb9e40060), SPH_C32(0x7eac3535), SPH_C32(0xae2381a7), + SPH_C32(0x024f8eb2), SPH_C32(0x6ed90050), SPH_C32(0xd6cf351e), + SPH_C32(0x8fff46af), SPH_C32(0x8029dba0) }, + { SPH_C32(0xe8b80070), SPH_C32(0x3e5f47ce), SPH_C32(0x52c4a7a5), + SPH_C32(0x7318ded3), SPH_C32(0x40e00050), SPH_C32(0xb2125397), + SPH_C32(0xb32b4053), SPH_C32(0x31dd4b1c) }, + { SPH_C32(0x69170040), SPH_C32(0x522c7b58), SPH_C32(0x1290c6a6), + SPH_C32(0x32fd9fb6), SPH_C32(0xb3040060), SPH_C32(0x7306c49a), + SPH_C32(0xb6022a55), SPH_C32(0xa225bbbd) }, + { SPH_C32(0x384b0050), SPH_C32(0x12df09a3), SPH_C32(0xee77e0a4), + SPH_C32(0x43aacfd7), SPH_C32(0x9d3d0060), SPH_C32(0x17dba213), + SPH_C32(0x8ad62ca9), SPH_C32(0x13d12b01) }, + { SPH_C32(0x472e0040), SPH_C32(0x36f11dd1), SPH_C32(0x2e44c05a), + SPH_C32(0x83090f0a), SPH_C32(0xcc610070), SPH_C32(0x5728d0e8), + SPH_C32(0x76310aab), SPH_C32(0x62867b60) }, + { SPH_C32(0x16720050), SPH_C32(0x76026f2a), SPH_C32(0xd2a3e658), + SPH_C32(0xf25e5f6b), SPH_C32(0xe2580070), SPH_C32(0x33f5b661), + SPH_C32(0x4ae50c57), SPH_C32(0xd372ebdc) }, + { SPH_C32(0xcbaf0060), SPH_C32(0xd3cb9eae), SPH_C32(0xeb5e8aa2), + SPH_C32(0xd0523f76), SPH_C32(0xef760060), SPH_C32(0xbabc0988), + SPH_C32(0xcfab27ac), SPH_C32(0xc1cc9ac5) }, + { SPH_C32(0x9af30070), SPH_C32(0x9338ec55), SPH_C32(0x17b9aca0), + SPH_C32(0xa1056f17), SPH_C32(0xc14f0060), SPH_C32(0xde616f01), + SPH_C32(0xf37f2150), SPH_C32(0x70380a79) }, + { SPH_C32(0xe5960060), SPH_C32(0xb716f827), SPH_C32(0xd78a8c5e), + SPH_C32(0x61a6afca), SPH_C32(0x90130070), SPH_C32(0x9e921dfa), + SPH_C32(0x0f980752), SPH_C32(0x016f5a18) }, + { SPH_C32(0xb4ca0070), SPH_C32(0xf7e58adc), SPH_C32(0x2b6daa5c), + SPH_C32(0x10f1ffab), SPH_C32(0xbe2a0070), SPH_C32(0xfa4f7b73), + SPH_C32(0x334c01ae), SPH_C32(0xb09bcaa4) } +}; + +static const sph_u32 T256_24[64][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), SPH_C32(0x99e585aa), + SPH_C32(0x8d75f7f1), SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), + SPH_C32(0x79e22a4c), SPH_C32(0x1298bd46) }, + { SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), SPH_C32(0x79e22a4c), + SPH_C32(0x1298bd46), SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), + SPH_C32(0xe007afe6), SPH_C32(0x9fed4ab7) }, + { SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), SPH_C32(0xe007afe6), + SPH_C32(0x9fed4ab7), SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), + SPH_C32(0x99e585aa), SPH_C32(0x8d75f7f1) }, + { SPH_C32(0xd0080004), SPH_C32(0x8c768f77), SPH_C32(0x9dc5b050), + SPH_C32(0xaf4a29da), SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), + SPH_C32(0x98321c3d), SPH_C32(0x76acc733) }, + { SPH_C32(0x582b0006), SPH_C32(0xd39128c4), SPH_C32(0x042035fa), + SPH_C32(0x223fde2b), SPH_C32(0x3a050000), SPH_C32(0x6508f6be), + SPH_C32(0xe1d03671), SPH_C32(0x64347a75) }, + { SPH_C32(0x81a40004), SPH_C32(0xa9958063), SPH_C32(0xe4279a1c), + SPH_C32(0xbdd2949c), SPH_C32(0xb2260002), SPH_C32(0x3aef510d), + SPH_C32(0x7835b3db), SPH_C32(0xe9418d84) }, + { SPH_C32(0x09870006), SPH_C32(0xf67227d0), SPH_C32(0x7dc21fb6), + SPH_C32(0x30a7636d), SPH_C32(0xe38a0002), SPH_C32(0x1f0c5e19), + SPH_C32(0x01d79997), SPH_C32(0xfbd930c2) }, + { SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), SPH_C32(0x98321c3d), + SPH_C32(0x76acc733), SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), + SPH_C32(0x05f7ac6d), SPH_C32(0xd9e6eee9) }, + { SPH_C32(0xe38a0002), SPH_C32(0x1f0c5e19), SPH_C32(0x01d79997), + SPH_C32(0xfbd930c2), SPH_C32(0xea0d0004), SPH_C32(0xe97e79c9), + SPH_C32(0x7c158621), SPH_C32(0xcb7e53af) }, + { SPH_C32(0x3a050000), SPH_C32(0x6508f6be), SPH_C32(0xe1d03671), + SPH_C32(0x64347a75), SPH_C32(0x622e0006), SPH_C32(0xb699de7a), + SPH_C32(0xe5f0038b), SPH_C32(0x460ba45e) }, + { SPH_C32(0xb2260002), SPH_C32(0x3aef510d), SPH_C32(0x7835b3db), + SPH_C32(0xe9418d84), SPH_C32(0x33820006), SPH_C32(0x937ad16e), + SPH_C32(0x9c1229c7), SPH_C32(0x54931918) }, + { SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), SPH_C32(0x05f7ac6d), + SPH_C32(0xd9e6eee9), SPH_C32(0xd0080004), SPH_C32(0x8c768f77), + SPH_C32(0x9dc5b050), SPH_C32(0xaf4a29da) }, + { SPH_C32(0x33820006), SPH_C32(0x937ad16e), SPH_C32(0x9c1229c7), + SPH_C32(0x54931918), SPH_C32(0x81a40004), SPH_C32(0xa9958063), + SPH_C32(0xe4279a1c), SPH_C32(0xbdd2949c) }, + { SPH_C32(0xea0d0004), SPH_C32(0xe97e79c9), SPH_C32(0x7c158621), + SPH_C32(0xcb7e53af), SPH_C32(0x09870006), SPH_C32(0xf67227d0), + SPH_C32(0x7dc21fb6), SPH_C32(0x30a7636d) }, + { SPH_C32(0x622e0006), SPH_C32(0xb699de7a), SPH_C32(0xe5f0038b), + SPH_C32(0x460ba45e), SPH_C32(0x582b0006), SPH_C32(0xd39128c4), + SPH_C32(0x042035fa), SPH_C32(0x223fde2b) }, + { SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), SPH_C32(0xfe739301), + SPH_C32(0xb8a92831), SPH_C32(0x171c0000), SPH_C32(0xb26e3344), + SPH_C32(0x9e6a837e), SPH_C32(0x58f8485f) }, + { SPH_C32(0x208d000a), SPH_C32(0x7f9e9ece), SPH_C32(0x679616ab), + SPH_C32(0x35dcdfc0), SPH_C32(0x46b00000), SPH_C32(0x978d3c50), + SPH_C32(0xe788a932), SPH_C32(0x4a60f519) }, + { SPH_C32(0xf9020008), SPH_C32(0x059a3669), SPH_C32(0x8791b94d), + SPH_C32(0xaa319577), SPH_C32(0xce930002), SPH_C32(0xc86a9be3), + SPH_C32(0x7e6d2c98), SPH_C32(0xc71502e8) }, + { SPH_C32(0x7121000a), SPH_C32(0x5a7d91da), SPH_C32(0x1e743ce7), + SPH_C32(0x27446286), SPH_C32(0x9f3f0002), SPH_C32(0xed8994f7), + SPH_C32(0x078f06d4), SPH_C32(0xd58dbfae) }, + { SPH_C32(0x78a6000c), SPH_C32(0xac0fb60a), SPH_C32(0x63b62351), + SPH_C32(0x17e301eb), SPH_C32(0x7cb50000), SPH_C32(0xf285caee), + SPH_C32(0x06589f43), SPH_C32(0x2e548f6c) }, + { SPH_C32(0xf085000e), SPH_C32(0xf3e811b9), SPH_C32(0xfa53a6fb), + SPH_C32(0x9a96f61a), SPH_C32(0x2d190000), SPH_C32(0xd766c5fa), + SPH_C32(0x7fbab50f), SPH_C32(0x3ccc322a) }, + { SPH_C32(0x290a000c), SPH_C32(0x89ecb91e), SPH_C32(0x1a54091d), + SPH_C32(0x057bbcad), SPH_C32(0xa53a0002), SPH_C32(0x88816249), + SPH_C32(0xe65f30a5), SPH_C32(0xb1b9c5db) }, + { SPH_C32(0xa129000e), SPH_C32(0xd60b1ead), SPH_C32(0x83b18cb7), + SPH_C32(0x880e4b5c), SPH_C32(0xf4960002), SPH_C32(0xad626d5d), + SPH_C32(0x9fbd1ae9), SPH_C32(0xa321789d) }, + { SPH_C32(0xc3070008), SPH_C32(0x6092c0d7), SPH_C32(0x66418f3c), + SPH_C32(0xce05ef02), SPH_C32(0xacbd0004), SPH_C32(0x7ef34599), + SPH_C32(0x9b9d2f13), SPH_C32(0x811ea6b6) }, + { SPH_C32(0x4b24000a), SPH_C32(0x3f756764), SPH_C32(0xffa40a96), + SPH_C32(0x437018f3), SPH_C32(0xfd110004), SPH_C32(0x5b104a8d), + SPH_C32(0xe27f055f), SPH_C32(0x93861bf0) }, + { SPH_C32(0x92ab0008), SPH_C32(0x4571cfc3), SPH_C32(0x1fa3a570), + SPH_C32(0xdc9d5244), SPH_C32(0x75320006), SPH_C32(0x04f7ed3e), + SPH_C32(0x7b9a80f5), SPH_C32(0x1ef3ec01) }, + { SPH_C32(0x1a88000a), SPH_C32(0x1a966870), SPH_C32(0x864620da), + SPH_C32(0x51e8a5b5), SPH_C32(0x249e0006), SPH_C32(0x2114e22a), + SPH_C32(0x0278aab9), SPH_C32(0x0c6b5147) }, + { SPH_C32(0x130f000c), SPH_C32(0xece44fa0), SPH_C32(0xfb843f6c), + SPH_C32(0x614fc6d8), SPH_C32(0xc7140004), SPH_C32(0x3e18bc33), + SPH_C32(0x03af332e), SPH_C32(0xf7b26185) }, + { SPH_C32(0x9b2c000e), SPH_C32(0xb303e813), SPH_C32(0x6261bac6), + SPH_C32(0xec3a3129), SPH_C32(0x96b80004), SPH_C32(0x1bfbb327), + SPH_C32(0x7a4d1962), SPH_C32(0xe52adcc3) }, + { SPH_C32(0x42a3000c), SPH_C32(0xc90740b4), SPH_C32(0x82661520), + SPH_C32(0x73d77b9e), SPH_C32(0x1e9b0006), SPH_C32(0x441c1494), + SPH_C32(0xe3a89cc8), SPH_C32(0x685f2b32) }, + { SPH_C32(0xca80000e), SPH_C32(0x96e0e707), SPH_C32(0x1b83908a), + SPH_C32(0xfea28c6f), SPH_C32(0x4f370006), SPH_C32(0x61ff1b80), + SPH_C32(0x9a4ab684), SPH_C32(0x7ac79674) }, + { SPH_C32(0x171c0000), SPH_C32(0xb26e3344), SPH_C32(0x9e6a837e), + SPH_C32(0x58f8485f), SPH_C32(0xbfb20008), SPH_C32(0x92170a39), + SPH_C32(0x6019107f), SPH_C32(0xe051606e) }, + { SPH_C32(0x9f3f0002), SPH_C32(0xed8994f7), SPH_C32(0x078f06d4), + SPH_C32(0xd58dbfae), SPH_C32(0xee1e0008), SPH_C32(0xb7f4052d), + SPH_C32(0x19fb3a33), SPH_C32(0xf2c9dd28) }, + { SPH_C32(0x46b00000), SPH_C32(0x978d3c50), SPH_C32(0xe788a932), + SPH_C32(0x4a60f519), SPH_C32(0x663d000a), SPH_C32(0xe813a29e), + SPH_C32(0x801ebf99), SPH_C32(0x7fbc2ad9) }, + { SPH_C32(0xce930002), SPH_C32(0xc86a9be3), SPH_C32(0x7e6d2c98), + SPH_C32(0xc71502e8), SPH_C32(0x3791000a), SPH_C32(0xcdf0ad8a), + SPH_C32(0xf9fc95d5), SPH_C32(0x6d24979f) }, + { SPH_C32(0xc7140004), SPH_C32(0x3e18bc33), SPH_C32(0x03af332e), + SPH_C32(0xf7b26185), SPH_C32(0xd41b0008), SPH_C32(0xd2fcf393), + SPH_C32(0xf82b0c42), SPH_C32(0x96fda75d) }, + { SPH_C32(0x4f370006), SPH_C32(0x61ff1b80), SPH_C32(0x9a4ab684), + SPH_C32(0x7ac79674), SPH_C32(0x85b70008), SPH_C32(0xf71ffc87), + SPH_C32(0x81c9260e), SPH_C32(0x84651a1b) }, + { SPH_C32(0x96b80004), SPH_C32(0x1bfbb327), SPH_C32(0x7a4d1962), + SPH_C32(0xe52adcc3), SPH_C32(0x0d94000a), SPH_C32(0xa8f85b34), + SPH_C32(0x182ca3a4), SPH_C32(0x0910edea) }, + { SPH_C32(0x1e9b0006), SPH_C32(0x441c1494), SPH_C32(0xe3a89cc8), + SPH_C32(0x685f2b32), SPH_C32(0x5c38000a), SPH_C32(0x8d1b5420), + SPH_C32(0x61ce89e8), SPH_C32(0x1b8850ac) }, + { SPH_C32(0x7cb50000), SPH_C32(0xf285caee), SPH_C32(0x06589f43), + SPH_C32(0x2e548f6c), SPH_C32(0x0413000c), SPH_C32(0x5e8a7ce4), + SPH_C32(0x65eebc12), SPH_C32(0x39b78e87) }, + { SPH_C32(0xf4960002), SPH_C32(0xad626d5d), SPH_C32(0x9fbd1ae9), + SPH_C32(0xa321789d), SPH_C32(0x55bf000c), SPH_C32(0x7b6973f0), + SPH_C32(0x1c0c965e), SPH_C32(0x2b2f33c1) }, + { SPH_C32(0x2d190000), SPH_C32(0xd766c5fa), SPH_C32(0x7fbab50f), + SPH_C32(0x3ccc322a), SPH_C32(0xdd9c000e), SPH_C32(0x248ed443), + SPH_C32(0x85e913f4), SPH_C32(0xa65ac430) }, + { SPH_C32(0xa53a0002), SPH_C32(0x88816249), SPH_C32(0xe65f30a5), + SPH_C32(0xb1b9c5db), SPH_C32(0x8c30000e), SPH_C32(0x016ddb57), + SPH_C32(0xfc0b39b8), SPH_C32(0xb4c27976) }, + { SPH_C32(0xacbd0004), SPH_C32(0x7ef34599), SPH_C32(0x9b9d2f13), + SPH_C32(0x811ea6b6), SPH_C32(0x6fba000c), SPH_C32(0x1e61854e), + SPH_C32(0xfddca02f), SPH_C32(0x4f1b49b4) }, + { SPH_C32(0x249e0006), SPH_C32(0x2114e22a), SPH_C32(0x0278aab9), + SPH_C32(0x0c6b5147), SPH_C32(0x3e16000c), SPH_C32(0x3b828a5a), + SPH_C32(0x843e8a63), SPH_C32(0x5d83f4f2) }, + { SPH_C32(0xfd110004), SPH_C32(0x5b104a8d), SPH_C32(0xe27f055f), + SPH_C32(0x93861bf0), SPH_C32(0xb635000e), SPH_C32(0x64652de9), + SPH_C32(0x1ddb0fc9), SPH_C32(0xd0f60303) }, + { SPH_C32(0x75320006), SPH_C32(0x04f7ed3e), SPH_C32(0x7b9a80f5), + SPH_C32(0x1ef3ec01), SPH_C32(0xe799000e), SPH_C32(0x418622fd), + SPH_C32(0x64392585), SPH_C32(0xc26ebe45) }, + { SPH_C32(0xbfb20008), SPH_C32(0x92170a39), SPH_C32(0x6019107f), + SPH_C32(0xe051606e), SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), + SPH_C32(0xfe739301), SPH_C32(0xb8a92831) }, + { SPH_C32(0x3791000a), SPH_C32(0xcdf0ad8a), SPH_C32(0xf9fc95d5), + SPH_C32(0x6d24979f), SPH_C32(0xf9020008), SPH_C32(0x059a3669), + SPH_C32(0x8791b94d), SPH_C32(0xaa319577) }, + { SPH_C32(0xee1e0008), SPH_C32(0xb7f4052d), SPH_C32(0x19fb3a33), + SPH_C32(0xf2c9dd28), SPH_C32(0x7121000a), SPH_C32(0x5a7d91da), + SPH_C32(0x1e743ce7), SPH_C32(0x27446286) }, + { SPH_C32(0x663d000a), SPH_C32(0xe813a29e), SPH_C32(0x801ebf99), + SPH_C32(0x7fbc2ad9), SPH_C32(0x208d000a), SPH_C32(0x7f9e9ece), + SPH_C32(0x679616ab), SPH_C32(0x35dcdfc0) }, + { SPH_C32(0x6fba000c), SPH_C32(0x1e61854e), SPH_C32(0xfddca02f), + SPH_C32(0x4f1b49b4), SPH_C32(0xc3070008), SPH_C32(0x6092c0d7), + SPH_C32(0x66418f3c), SPH_C32(0xce05ef02) }, + { SPH_C32(0xe799000e), SPH_C32(0x418622fd), SPH_C32(0x64392585), + SPH_C32(0xc26ebe45), SPH_C32(0x92ab0008), SPH_C32(0x4571cfc3), + SPH_C32(0x1fa3a570), SPH_C32(0xdc9d5244) }, + { SPH_C32(0x3e16000c), SPH_C32(0x3b828a5a), SPH_C32(0x843e8a63), + SPH_C32(0x5d83f4f2), SPH_C32(0x1a88000a), SPH_C32(0x1a966870), + SPH_C32(0x864620da), SPH_C32(0x51e8a5b5) }, + { SPH_C32(0xb635000e), SPH_C32(0x64652de9), SPH_C32(0x1ddb0fc9), + SPH_C32(0xd0f60303), SPH_C32(0x4b24000a), SPH_C32(0x3f756764), + SPH_C32(0xffa40a96), SPH_C32(0x437018f3) }, + { SPH_C32(0xd41b0008), SPH_C32(0xd2fcf393), SPH_C32(0xf82b0c42), + SPH_C32(0x96fda75d), SPH_C32(0x130f000c), SPH_C32(0xece44fa0), + SPH_C32(0xfb843f6c), SPH_C32(0x614fc6d8) }, + { SPH_C32(0x5c38000a), SPH_C32(0x8d1b5420), SPH_C32(0x61ce89e8), + SPH_C32(0x1b8850ac), SPH_C32(0x42a3000c), SPH_C32(0xc90740b4), + SPH_C32(0x82661520), SPH_C32(0x73d77b9e) }, + { SPH_C32(0x85b70008), SPH_C32(0xf71ffc87), SPH_C32(0x81c9260e), + SPH_C32(0x84651a1b), SPH_C32(0xca80000e), SPH_C32(0x96e0e707), + SPH_C32(0x1b83908a), SPH_C32(0xfea28c6f) }, + { SPH_C32(0x0d94000a), SPH_C32(0xa8f85b34), SPH_C32(0x182ca3a4), + SPH_C32(0x0910edea), SPH_C32(0x9b2c000e), SPH_C32(0xb303e813), + SPH_C32(0x6261bac6), SPH_C32(0xec3a3129) }, + { SPH_C32(0x0413000c), SPH_C32(0x5e8a7ce4), SPH_C32(0x65eebc12), + SPH_C32(0x39b78e87), SPH_C32(0x78a6000c), SPH_C32(0xac0fb60a), + SPH_C32(0x63b62351), SPH_C32(0x17e301eb) }, + { SPH_C32(0x8c30000e), SPH_C32(0x016ddb57), SPH_C32(0xfc0b39b8), + SPH_C32(0xb4c27976), SPH_C32(0x290a000c), SPH_C32(0x89ecb91e), + SPH_C32(0x1a54091d), SPH_C32(0x057bbcad) }, + { SPH_C32(0x55bf000c), SPH_C32(0x7b6973f0), SPH_C32(0x1c0c965e), + SPH_C32(0x2b2f33c1), SPH_C32(0xa129000e), SPH_C32(0xd60b1ead), + SPH_C32(0x83b18cb7), SPH_C32(0x880e4b5c) }, + { SPH_C32(0xdd9c000e), SPH_C32(0x248ed443), SPH_C32(0x85e913f4), + SPH_C32(0xa65ac430), SPH_C32(0xf085000e), SPH_C32(0xf3e811b9), + SPH_C32(0xfa53a6fb), SPH_C32(0x9a96f61a) } +}; + +static const sph_u32 T256_30[4][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), SPH_C32(0xae0ebb05), + SPH_C32(0xb5a4c63b), SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), + SPH_C32(0x6bf648a4), SPH_C32(0x539cbdbf) }, + { SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), SPH_C32(0x6bf648a4), + SPH_C32(0x539cbdbf), SPH_C32(0x08bf0001), SPH_C32(0x38942792), + SPH_C32(0xc5f8f3a1), SPH_C32(0xe6387b84) }, + { SPH_C32(0x08bf0001), SPH_C32(0x38942792), SPH_C32(0xc5f8f3a1), + SPH_C32(0xe6387b84), SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), + SPH_C32(0xae0ebb05), SPH_C32(0xb5a4c63b) } +}; + +#define INPUT_SMALL do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T256_0[acc >> 2][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + acc = (acc << 8) | buf[1]; \ + rp = &T256_6[(acc >> 4) & 0x3f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = (acc << 8) | buf[2]; \ + rp = &T256_12[(acc >> 6) & 0x3f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_18[acc & 0x3f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = buf[3]; \ + rp = &T256_24[acc >> 2][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_30[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_SMALL == 7 + +static const sph_u32 T256_0[128][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xcba90000), SPH_C32(0x90273769), SPH_C32(0xbbdcf407), + SPH_C32(0xd0f4af61), SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), + SPH_C32(0x3321e92c), SPH_C32(0xce122df3) }, + { SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), SPH_C32(0x11fa3a57), + SPH_C32(0x3dc90524), SPH_C32(0x97530000), SPH_C32(0x204f6ed3), + SPH_C32(0x77b9e80f), SPH_C32(0xa1ec5ec1) }, + { SPH_C32(0x22832000), SPH_C32(0x2470bb95), SPH_C32(0xaa26ce50), + SPH_C32(0xed3daa45), SPH_C32(0x286f1000), SPH_C32(0xea431fc4), + SPH_C32(0x44980123), SPH_C32(0x6ffe7332) }, + { SPH_C32(0x97530000), SPH_C32(0x204f6ed3), SPH_C32(0x77b9e80f), + SPH_C32(0xa1ec5ec1), SPH_C32(0x7e792000), SPH_C32(0x9418e22f), + SPH_C32(0x6643d258), SPH_C32(0x9c255be5) }, + { SPH_C32(0x5cfa0000), SPH_C32(0xb06859ba), SPH_C32(0xcc651c08), + SPH_C32(0x7118f1a0), SPH_C32(0xc1453000), SPH_C32(0x5e149338), + SPH_C32(0x55623b74), SPH_C32(0x52377616) }, + { SPH_C32(0x7e792000), SPH_C32(0x9418e22f), SPH_C32(0x6643d258), + SPH_C32(0x9c255be5), SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), + SPH_C32(0x11fa3a57), SPH_C32(0x3dc90524) }, + { SPH_C32(0xb5d02000), SPH_C32(0x043fd546), SPH_C32(0xdd9f265f), + SPH_C32(0x4cd1f484), SPH_C32(0x56163000), SPH_C32(0x7e5bfdeb), + SPH_C32(0x22dbd37b), SPH_C32(0xf3db28d7) }, + { SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), SPH_C32(0x8dfacfab), + SPH_C32(0xce36cc72), SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), + SPH_C32(0x848598ba), SPH_C32(0x1041003e) }, + { SPH_C32(0xd9b24000), SPH_C32(0xcb30ee81), SPH_C32(0x36263bac), + SPH_C32(0x1ec26313), SPH_C32(0x596b1000), SPH_C32(0x81bf4b32), + SPH_C32(0xb7a47196), SPH_C32(0xde532dcd) }, + { SPH_C32(0xfb316000), SPH_C32(0xef405514), SPH_C32(0x9c00f5fc), + SPH_C32(0xf3ffc956), SPH_C32(0x71040000), SPH_C32(0x6bfc54f6), + SPH_C32(0xf33c70b5), SPH_C32(0xb1ad5eff) }, + { SPH_C32(0x30986000), SPH_C32(0x7f67627d), SPH_C32(0x27dc01fb), + SPH_C32(0x230b6637), SPH_C32(0xce381000), SPH_C32(0xa1f025e1), + SPH_C32(0xc01d9999), SPH_C32(0x7fbf730c) }, + { SPH_C32(0x85484000), SPH_C32(0x7b58b73b), SPH_C32(0xfa4327a4), + SPH_C32(0x6fda92b3), SPH_C32(0x982e2000), SPH_C32(0xdfabd80a), + SPH_C32(0xe2c64ae2), SPH_C32(0x8c645bdb) }, + { SPH_C32(0x4ee14000), SPH_C32(0xeb7f8052), SPH_C32(0x419fd3a3), + SPH_C32(0xbf2e3dd2), SPH_C32(0x27123000), SPH_C32(0x15a7a91d), + SPH_C32(0xd1e7a3ce), SPH_C32(0x42767628) }, + { SPH_C32(0x6c626000), SPH_C32(0xcf0f3bc7), SPH_C32(0xebb91df3), + SPH_C32(0x52139797), SPH_C32(0x0f7d2000), SPH_C32(0xffe4b6d9), + SPH_C32(0x957fa2ed), SPH_C32(0x2d88051a) }, + { SPH_C32(0xa7cb6000), SPH_C32(0x5f280cae), SPH_C32(0x5065e9f4), + SPH_C32(0x82e738f6), SPH_C32(0xb0413000), SPH_C32(0x35e8c7ce), + SPH_C32(0xa65e4bc1), SPH_C32(0xe39a28e9) }, + { SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), SPH_C32(0x848598ba), + SPH_C32(0x1041003e), SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), + SPH_C32(0x097f5711), SPH_C32(0xde77cc4c) }, + { SPH_C32(0x2dfe0000), SPH_C32(0xdb940d4c), SPH_C32(0x3f596cbd), + SPH_C32(0xc0b5af5f), SPH_C32(0x4b705000), SPH_C32(0xdaa892da), + SPH_C32(0x3a5ebe3d), SPH_C32(0x1065e1bf) }, + { SPH_C32(0x0f7d2000), SPH_C32(0xffe4b6d9), SPH_C32(0x957fa2ed), + SPH_C32(0x2d88051a), SPH_C32(0x631f4000), SPH_C32(0x30eb8d1e), + SPH_C32(0x7ec6bf1e), SPH_C32(0x7f9b928d) }, + { SPH_C32(0xc4d42000), SPH_C32(0x6fc381b0), SPH_C32(0x2ea356ea), + SPH_C32(0xfd7caa7b), SPH_C32(0xdc235000), SPH_C32(0xfae7fc09), + SPH_C32(0x4de75632), SPH_C32(0xb189bf7e) }, + { SPH_C32(0x71040000), SPH_C32(0x6bfc54f6), SPH_C32(0xf33c70b5), + SPH_C32(0xb1ad5eff), SPH_C32(0x8a356000), SPH_C32(0x84bc01e2), + SPH_C32(0x6f3c8549), SPH_C32(0x425297a9) }, + { SPH_C32(0xbaad0000), SPH_C32(0xfbdb639f), SPH_C32(0x48e084b2), + SPH_C32(0x6159f19e), SPH_C32(0x35097000), SPH_C32(0x4eb070f5), + SPH_C32(0x5c1d6c65), SPH_C32(0x8c40ba5a) }, + { SPH_C32(0x982e2000), SPH_C32(0xdfabd80a), SPH_C32(0xe2c64ae2), + SPH_C32(0x8c645bdb), SPH_C32(0x1d666000), SPH_C32(0xa4f36f31), + SPH_C32(0x18856d46), SPH_C32(0xe3bec968) }, + { SPH_C32(0x53872000), SPH_C32(0x4f8cef63), SPH_C32(0x591abee5), + SPH_C32(0x5c90f4ba), SPH_C32(0xa25a7000), SPH_C32(0x6eff1e26), + SPH_C32(0x2ba4846a), SPH_C32(0x2dace49b) }, + { SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), SPH_C32(0x097f5711), + SPH_C32(0xde77cc4c), SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), + SPH_C32(0x8dfacfab), SPH_C32(0xce36cc72) }, + { SPH_C32(0x3fe54000), SPH_C32(0x8083d4a4), SPH_C32(0xb2a3a316), + SPH_C32(0x0e83632d), SPH_C32(0xad275000), SPH_C32(0x911ba8ff), + SPH_C32(0xbedb2687), SPH_C32(0x0024e181) }, + { SPH_C32(0x1d666000), SPH_C32(0xa4f36f31), SPH_C32(0x18856d46), + SPH_C32(0xe3bec968), SPH_C32(0x85484000), SPH_C32(0x7b58b73b), + SPH_C32(0xfa4327a4), SPH_C32(0x6fda92b3) }, + { SPH_C32(0xd6cf6000), SPH_C32(0x34d45858), SPH_C32(0xa3599941), + SPH_C32(0x334a6609), SPH_C32(0x3a745000), SPH_C32(0xb154c62c), + SPH_C32(0xc962ce88), SPH_C32(0xa1c8bf40) }, + { SPH_C32(0x631f4000), SPH_C32(0x30eb8d1e), SPH_C32(0x7ec6bf1e), + SPH_C32(0x7f9b928d), SPH_C32(0x6c626000), SPH_C32(0xcf0f3bc7), + SPH_C32(0xebb91df3), SPH_C32(0x52139797) }, + { SPH_C32(0xa8b64000), SPH_C32(0xa0ccba77), SPH_C32(0xc51a4b19), + SPH_C32(0xaf6f3dec), SPH_C32(0xd35e7000), SPH_C32(0x05034ad0), + SPH_C32(0xd898f4df), SPH_C32(0x9c01ba64) }, + { SPH_C32(0x8a356000), SPH_C32(0x84bc01e2), SPH_C32(0x6f3c8549), + SPH_C32(0x425297a9), SPH_C32(0xfb316000), SPH_C32(0xef405514), + SPH_C32(0x9c00f5fc), SPH_C32(0xf3ffc956) }, + { SPH_C32(0x419c6000), SPH_C32(0x149b368b), SPH_C32(0xd4e0714e), + SPH_C32(0x92a638c8), SPH_C32(0x440d7000), SPH_C32(0x254c2403), + SPH_C32(0xaf211cd0), SPH_C32(0x3dede4a5) }, + { SPH_C32(0xe4788000), SPH_C32(0x859673c1), SPH_C32(0xb5fb2452), + SPH_C32(0x29cc5edf), SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), + SPH_C32(0x62fc79d0), SPH_C32(0x731ebdc2) }, + { SPH_C32(0x2fd18000), SPH_C32(0x15b144a8), SPH_C32(0x0e27d055), + SPH_C32(0xf938f1be), SPH_C32(0xbb631000), SPH_C32(0x5646e2de), + SPH_C32(0x51dd90fc), SPH_C32(0xbd0c9031) }, + { SPH_C32(0x0d52a000), SPH_C32(0x31c1ff3d), SPH_C32(0xa4011e05), + SPH_C32(0x14055bfb), SPH_C32(0x930c0000), SPH_C32(0xbc05fd1a), + SPH_C32(0x154591df), SPH_C32(0xd2f2e303) }, + { SPH_C32(0xc6fba000), SPH_C32(0xa1e6c854), SPH_C32(0x1fddea02), + SPH_C32(0xc4f1f49a), SPH_C32(0x2c301000), SPH_C32(0x76098c0d), + SPH_C32(0x266478f3), SPH_C32(0x1ce0cef0) }, + { SPH_C32(0x732b8000), SPH_C32(0xa5d91d12), SPH_C32(0xc242cc5d), + SPH_C32(0x8820001e), SPH_C32(0x7a262000), SPH_C32(0x085271e6), + SPH_C32(0x04bfab88), SPH_C32(0xef3be627) }, + { SPH_C32(0xb8828000), SPH_C32(0x35fe2a7b), SPH_C32(0x799e385a), + SPH_C32(0x58d4af7f), SPH_C32(0xc51a3000), SPH_C32(0xc25e00f1), + SPH_C32(0x379e42a4), SPH_C32(0x2129cbd4) }, + { SPH_C32(0x9a01a000), SPH_C32(0x118e91ee), SPH_C32(0xd3b8f60a), + SPH_C32(0xb5e9053a), SPH_C32(0xed752000), SPH_C32(0x281d1f35), + SPH_C32(0x73064387), SPH_C32(0x4ed7b8e6) }, + { SPH_C32(0x51a8a000), SPH_C32(0x81a9a687), SPH_C32(0x6864020d), + SPH_C32(0x651daa5b), SPH_C32(0x52493000), SPH_C32(0xe2116e22), + SPH_C32(0x4027aaab), SPH_C32(0x80c59515) }, + { SPH_C32(0xf663c000), SPH_C32(0xde81aa29), SPH_C32(0x3801ebf9), + SPH_C32(0xe7fa92ad), SPH_C32(0xe2080000), SPH_C32(0xd7f9a9ec), + SPH_C32(0xe679e16a), SPH_C32(0x635fbdfc) }, + { SPH_C32(0x3dcac000), SPH_C32(0x4ea69d40), SPH_C32(0x83dd1ffe), + SPH_C32(0x370e3dcc), SPH_C32(0x5d341000), SPH_C32(0x1df5d8fb), + SPH_C32(0xd5580846), SPH_C32(0xad4d900f) }, + { SPH_C32(0x1f49e000), SPH_C32(0x6ad626d5), SPH_C32(0x29fbd1ae), + SPH_C32(0xda339789), SPH_C32(0x755b0000), SPH_C32(0xf7b6c73f), + SPH_C32(0x91c00965), SPH_C32(0xc2b3e33d) }, + { SPH_C32(0xd4e0e000), SPH_C32(0xfaf111bc), SPH_C32(0x922725a9), + SPH_C32(0x0ac738e8), SPH_C32(0xca671000), SPH_C32(0x3dbab628), + SPH_C32(0xa2e1e049), SPH_C32(0x0ca1cece) }, + { SPH_C32(0x6130c000), SPH_C32(0xfecec4fa), SPH_C32(0x4fb803f6), + SPH_C32(0x4616cc6c), SPH_C32(0x9c712000), SPH_C32(0x43e14bc3), + SPH_C32(0x803a3332), SPH_C32(0xff7ae619) }, + { SPH_C32(0xaa99c000), SPH_C32(0x6ee9f393), SPH_C32(0xf464f7f1), + SPH_C32(0x96e2630d), SPH_C32(0x234d3000), SPH_C32(0x89ed3ad4), + SPH_C32(0xb31bda1e), SPH_C32(0x3168cbea) }, + { SPH_C32(0x881ae000), SPH_C32(0x4a994806), SPH_C32(0x5e4239a1), + SPH_C32(0x7bdfc948), SPH_C32(0x0b222000), SPH_C32(0x63ae2510), + SPH_C32(0xf783db3d), SPH_C32(0x5e96b8d8) }, + { SPH_C32(0x43b3e000), SPH_C32(0xdabe7f6f), SPH_C32(0xe59ecda6), + SPH_C32(0xab2b6629), SPH_C32(0xb41e3000), SPH_C32(0xa9a25407), + SPH_C32(0xc4a23211), SPH_C32(0x9084952b) }, + { SPH_C32(0x022f8000), SPH_C32(0xce2549e4), SPH_C32(0x317ebce8), + SPH_C32(0x398d5ee1), SPH_C32(0xf0134000), SPH_C32(0x8cee7004), + SPH_C32(0x6b832ec1), SPH_C32(0xad69718e) }, + { SPH_C32(0xc9868000), SPH_C32(0x5e027e8d), SPH_C32(0x8aa248ef), + SPH_C32(0xe979f180), SPH_C32(0x4f2f5000), SPH_C32(0x46e20113), + SPH_C32(0x58a2c7ed), SPH_C32(0x637b5c7d) }, + { SPH_C32(0xeb05a000), SPH_C32(0x7a72c518), SPH_C32(0x208486bf), + SPH_C32(0x04445bc5), SPH_C32(0x67404000), SPH_C32(0xaca11ed7), + SPH_C32(0x1c3ac6ce), SPH_C32(0x0c852f4f) }, + { SPH_C32(0x20aca000), SPH_C32(0xea55f271), SPH_C32(0x9b5872b8), + SPH_C32(0xd4b0f4a4), SPH_C32(0xd87c5000), SPH_C32(0x66ad6fc0), + SPH_C32(0x2f1b2fe2), SPH_C32(0xc29702bc) }, + { SPH_C32(0x957c8000), SPH_C32(0xee6a2737), SPH_C32(0x46c754e7), + SPH_C32(0x98610020), SPH_C32(0x8e6a6000), SPH_C32(0x18f6922b), + SPH_C32(0x0dc0fc99), SPH_C32(0x314c2a6b) }, + { SPH_C32(0x5ed58000), SPH_C32(0x7e4d105e), SPH_C32(0xfd1ba0e0), + SPH_C32(0x4895af41), SPH_C32(0x31567000), SPH_C32(0xd2fae33c), + SPH_C32(0x3ee115b5), SPH_C32(0xff5e0798) }, + { SPH_C32(0x7c56a000), SPH_C32(0x5a3dabcb), SPH_C32(0x573d6eb0), + SPH_C32(0xa5a80504), SPH_C32(0x19396000), SPH_C32(0x38b9fcf8), + SPH_C32(0x7a791496), SPH_C32(0x90a074aa) }, + { SPH_C32(0xb7ffa000), SPH_C32(0xca1a9ca2), SPH_C32(0xece19ab7), + SPH_C32(0x755caa65), SPH_C32(0xa6057000), SPH_C32(0xf2b58def), + SPH_C32(0x4958fdba), SPH_C32(0x5eb25959) }, + { SPH_C32(0x1034c000), SPH_C32(0x9532900c), SPH_C32(0xbc847343), + SPH_C32(0xf7bb9293), SPH_C32(0x16444000), SPH_C32(0xc75d4a21), + SPH_C32(0xef06b67b), SPH_C32(0xbd2871b0) }, + { SPH_C32(0xdb9dc000), SPH_C32(0x0515a765), SPH_C32(0x07588744), + SPH_C32(0x274f3df2), SPH_C32(0xa9785000), SPH_C32(0x0d513b36), + SPH_C32(0xdc275f57), SPH_C32(0x733a5c43) }, + { SPH_C32(0xf91ee000), SPH_C32(0x21651cf0), SPH_C32(0xad7e4914), + SPH_C32(0xca7297b7), SPH_C32(0x81174000), SPH_C32(0xe71224f2), + SPH_C32(0x98bf5e74), SPH_C32(0x1cc42f71) }, + { SPH_C32(0x32b7e000), SPH_C32(0xb1422b99), SPH_C32(0x16a2bd13), + SPH_C32(0x1a8638d6), SPH_C32(0x3e2b5000), SPH_C32(0x2d1e55e5), + SPH_C32(0xab9eb758), SPH_C32(0xd2d60282) }, + { SPH_C32(0x8767c000), SPH_C32(0xb57dfedf), SPH_C32(0xcb3d9b4c), + SPH_C32(0x5657cc52), SPH_C32(0x683d6000), SPH_C32(0x5345a80e), + SPH_C32(0x89456423), SPH_C32(0x210d2a55) }, + { SPH_C32(0x4ccec000), SPH_C32(0x255ac9b6), SPH_C32(0x70e16f4b), + SPH_C32(0x86a36333), SPH_C32(0xd7017000), SPH_C32(0x9949d919), + SPH_C32(0xba648d0f), SPH_C32(0xef1f07a6) }, + { SPH_C32(0x6e4de000), SPH_C32(0x012a7223), SPH_C32(0xdac7a11b), + SPH_C32(0x6b9ec976), SPH_C32(0xff6e6000), SPH_C32(0x730ac6dd), + SPH_C32(0xfefc8c2c), SPH_C32(0x80e17494) }, + { SPH_C32(0xa5e4e000), SPH_C32(0x910d454a), SPH_C32(0x611b551c), + SPH_C32(0xbb6a6617), SPH_C32(0x40527000), SPH_C32(0xb906b7ca), + SPH_C32(0xcddd6500), SPH_C32(0x4ef35967) }, + { SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), SPH_C32(0x62fc79d0), + SPH_C32(0x731ebdc2), SPH_C32(0xe0278000), SPH_C32(0x19dce008), + SPH_C32(0xd7075d82), SPH_C32(0x5ad2e31d) }, + { SPH_C32(0xcff60000), SPH_C32(0x0c6da4a0), SPH_C32(0xd9208dd7), + SPH_C32(0xa3ea12a3), SPH_C32(0x5f1b9000), SPH_C32(0xd3d0911f), + SPH_C32(0xe426b4ae), SPH_C32(0x94c0ceee) }, + { SPH_C32(0xed752000), SPH_C32(0x281d1f35), SPH_C32(0x73064387), + SPH_C32(0x4ed7b8e6), SPH_C32(0x77748000), SPH_C32(0x39938edb), + SPH_C32(0xa0beb58d), SPH_C32(0xfb3ebddc) }, + { SPH_C32(0x26dc2000), SPH_C32(0xb83a285c), SPH_C32(0xc8dab780), + SPH_C32(0x9e231787), SPH_C32(0xc8489000), SPH_C32(0xf39fffcc), + SPH_C32(0x939f5ca1), SPH_C32(0x352c902f) }, + { SPH_C32(0x930c0000), SPH_C32(0xbc05fd1a), SPH_C32(0x154591df), + SPH_C32(0xd2f2e303), SPH_C32(0x9e5ea000), SPH_C32(0x8dc40227), + SPH_C32(0xb1448fda), SPH_C32(0xc6f7b8f8) }, + { SPH_C32(0x58a50000), SPH_C32(0x2c22ca73), SPH_C32(0xae9965d8), + SPH_C32(0x02064c62), SPH_C32(0x2162b000), SPH_C32(0x47c87330), + SPH_C32(0x826566f6), SPH_C32(0x08e5950b) }, + { SPH_C32(0x7a262000), SPH_C32(0x085271e6), SPH_C32(0x04bfab88), + SPH_C32(0xef3be627), SPH_C32(0x090da000), SPH_C32(0xad8b6cf4), + SPH_C32(0xc6fd67d5), SPH_C32(0x671be639) }, + { SPH_C32(0xb18f2000), SPH_C32(0x9875468f), SPH_C32(0xbf635f8f), + SPH_C32(0x3fcf4946), SPH_C32(0xb631b000), SPH_C32(0x67871de3), + SPH_C32(0xf5dc8ef9), SPH_C32(0xa909cbca) }, + { SPH_C32(0x16444000), SPH_C32(0xc75d4a21), SPH_C32(0xef06b67b), + SPH_C32(0xbd2871b0), SPH_C32(0x06708000), SPH_C32(0x526fda2d), + SPH_C32(0x5382c538), SPH_C32(0x4a93e323) }, + { SPH_C32(0xdded4000), SPH_C32(0x577a7d48), SPH_C32(0x54da427c), + SPH_C32(0x6ddcded1), SPH_C32(0xb94c9000), SPH_C32(0x9863ab3a), + SPH_C32(0x60a32c14), SPH_C32(0x8481ced0) }, + { SPH_C32(0xff6e6000), SPH_C32(0x730ac6dd), SPH_C32(0xfefc8c2c), + SPH_C32(0x80e17494), SPH_C32(0x91238000), SPH_C32(0x7220b4fe), + SPH_C32(0x243b2d37), SPH_C32(0xeb7fbde2) }, + { SPH_C32(0x34c76000), SPH_C32(0xe32df1b4), SPH_C32(0x4520782b), + SPH_C32(0x5015dbf5), SPH_C32(0x2e1f9000), SPH_C32(0xb82cc5e9), + SPH_C32(0x171ac41b), SPH_C32(0x256d9011) }, + { SPH_C32(0x81174000), SPH_C32(0xe71224f2), SPH_C32(0x98bf5e74), + SPH_C32(0x1cc42f71), SPH_C32(0x7809a000), SPH_C32(0xc6773802), + SPH_C32(0x35c11760), SPH_C32(0xd6b6b8c6) }, + { SPH_C32(0x4abe4000), SPH_C32(0x7735139b), SPH_C32(0x2363aa73), + SPH_C32(0xcc308010), SPH_C32(0xc735b000), SPH_C32(0x0c7b4915), + SPH_C32(0x06e0fe4c), SPH_C32(0x18a49535) }, + { SPH_C32(0x683d6000), SPH_C32(0x5345a80e), SPH_C32(0x89456423), + SPH_C32(0x210d2a55), SPH_C32(0xef5aa000), SPH_C32(0xe63856d1), + SPH_C32(0x4278ff6f), SPH_C32(0x775ae607) }, + { SPH_C32(0xa3946000), SPH_C32(0xc3629f67), SPH_C32(0x32999024), + SPH_C32(0xf1f98534), SPH_C32(0x5066b000), SPH_C32(0x2c3427c6), + SPH_C32(0x71591643), SPH_C32(0xb948cbf4) }, + { SPH_C32(0xe2080000), SPH_C32(0xd7f9a9ec), SPH_C32(0xe679e16a), + SPH_C32(0x635fbdfc), SPH_C32(0x146bc000), SPH_C32(0x097803c5), + SPH_C32(0xde780a93), SPH_C32(0x84a52f51) }, + { SPH_C32(0x29a10000), SPH_C32(0x47de9e85), SPH_C32(0x5da5156d), + SPH_C32(0xb3ab129d), SPH_C32(0xab57d000), SPH_C32(0xc37472d2), + SPH_C32(0xed59e3bf), SPH_C32(0x4ab702a2) }, + { SPH_C32(0x0b222000), SPH_C32(0x63ae2510), SPH_C32(0xf783db3d), + SPH_C32(0x5e96b8d8), SPH_C32(0x8338c000), SPH_C32(0x29376d16), + SPH_C32(0xa9c1e29c), SPH_C32(0x25497190) }, + { SPH_C32(0xc08b2000), SPH_C32(0xf3891279), SPH_C32(0x4c5f2f3a), + SPH_C32(0x8e6217b9), SPH_C32(0x3c04d000), SPH_C32(0xe33b1c01), + SPH_C32(0x9ae00bb0), SPH_C32(0xeb5b5c63) }, + { SPH_C32(0x755b0000), SPH_C32(0xf7b6c73f), SPH_C32(0x91c00965), + SPH_C32(0xc2b3e33d), SPH_C32(0x6a12e000), SPH_C32(0x9d60e1ea), + SPH_C32(0xb83bd8cb), SPH_C32(0x188074b4) }, + { SPH_C32(0xbef20000), SPH_C32(0x6791f056), SPH_C32(0x2a1cfd62), + SPH_C32(0x12474c5c), SPH_C32(0xd52ef000), SPH_C32(0x576c90fd), + SPH_C32(0x8b1a31e7), SPH_C32(0xd6925947) }, + { SPH_C32(0x9c712000), SPH_C32(0x43e14bc3), SPH_C32(0x803a3332), + SPH_C32(0xff7ae619), SPH_C32(0xfd41e000), SPH_C32(0xbd2f8f39), + SPH_C32(0xcf8230c4), SPH_C32(0xb96c2a75) }, + { SPH_C32(0x57d82000), SPH_C32(0xd3c67caa), SPH_C32(0x3be6c735), + SPH_C32(0x2f8e4978), SPH_C32(0x427df000), SPH_C32(0x7723fe2e), + SPH_C32(0xfca3d9e8), SPH_C32(0x777e0786) }, + { SPH_C32(0xf0134000), SPH_C32(0x8cee7004), SPH_C32(0x6b832ec1), + SPH_C32(0xad69718e), SPH_C32(0xf23cc000), SPH_C32(0x42cb39e0), + SPH_C32(0x5afd9229), SPH_C32(0x94e42f6f) }, + { SPH_C32(0x3bba4000), SPH_C32(0x1cc9476d), SPH_C32(0xd05fdac6), + SPH_C32(0x7d9ddeef), SPH_C32(0x4d00d000), SPH_C32(0x88c748f7), + SPH_C32(0x69dc7b05), SPH_C32(0x5af6029c) }, + { SPH_C32(0x19396000), SPH_C32(0x38b9fcf8), SPH_C32(0x7a791496), + SPH_C32(0x90a074aa), SPH_C32(0x656fc000), SPH_C32(0x62845733), + SPH_C32(0x2d447a26), SPH_C32(0x350871ae) }, + { SPH_C32(0xd2906000), SPH_C32(0xa89ecb91), SPH_C32(0xc1a5e091), + SPH_C32(0x4054dbcb), SPH_C32(0xda53d000), SPH_C32(0xa8882624), + SPH_C32(0x1e65930a), SPH_C32(0xfb1a5c5d) }, + { SPH_C32(0x67404000), SPH_C32(0xaca11ed7), SPH_C32(0x1c3ac6ce), + SPH_C32(0x0c852f4f), SPH_C32(0x8c45e000), SPH_C32(0xd6d3dbcf), + SPH_C32(0x3cbe4071), SPH_C32(0x08c1748a) }, + { SPH_C32(0xace94000), SPH_C32(0x3c8629be), SPH_C32(0xa7e632c9), + SPH_C32(0xdc71802e), SPH_C32(0x3379f000), SPH_C32(0x1cdfaad8), + SPH_C32(0x0f9fa95d), SPH_C32(0xc6d35979) }, + { SPH_C32(0x8e6a6000), SPH_C32(0x18f6922b), SPH_C32(0x0dc0fc99), + SPH_C32(0x314c2a6b), SPH_C32(0x1b16e000), SPH_C32(0xf69cb51c), + SPH_C32(0x4b07a87e), SPH_C32(0xa92d2a4b) }, + { SPH_C32(0x45c36000), SPH_C32(0x88d1a542), SPH_C32(0xb61c089e), + SPH_C32(0xe1b8850a), SPH_C32(0xa42af000), SPH_C32(0x3c90c40b), + SPH_C32(0x78264152), SPH_C32(0x673f07b8) }, + { SPH_C32(0xe0278000), SPH_C32(0x19dce008), SPH_C32(0xd7075d82), + SPH_C32(0x5ad2e31d), SPH_C32(0xe4788000), SPH_C32(0x859673c1), + SPH_C32(0xb5fb2452), SPH_C32(0x29cc5edf) }, + { SPH_C32(0x2b8e8000), SPH_C32(0x89fbd761), SPH_C32(0x6cdba985), + SPH_C32(0x8a264c7c), SPH_C32(0x5b449000), SPH_C32(0x4f9a02d6), + SPH_C32(0x86dacd7e), SPH_C32(0xe7de732c) }, + { SPH_C32(0x090da000), SPH_C32(0xad8b6cf4), SPH_C32(0xc6fd67d5), + SPH_C32(0x671be639), SPH_C32(0x732b8000), SPH_C32(0xa5d91d12), + SPH_C32(0xc242cc5d), SPH_C32(0x8820001e) }, + { SPH_C32(0xc2a4a000), SPH_C32(0x3dac5b9d), SPH_C32(0x7d2193d2), + SPH_C32(0xb7ef4958), SPH_C32(0xcc179000), SPH_C32(0x6fd56c05), + SPH_C32(0xf1632571), SPH_C32(0x46322ded) }, + { SPH_C32(0x77748000), SPH_C32(0x39938edb), SPH_C32(0xa0beb58d), + SPH_C32(0xfb3ebddc), SPH_C32(0x9a01a000), SPH_C32(0x118e91ee), + SPH_C32(0xd3b8f60a), SPH_C32(0xb5e9053a) }, + { SPH_C32(0xbcdd8000), SPH_C32(0xa9b4b9b2), SPH_C32(0x1b62418a), + SPH_C32(0x2bca12bd), SPH_C32(0x253db000), SPH_C32(0xdb82e0f9), + SPH_C32(0xe0991f26), SPH_C32(0x7bfb28c9) }, + { SPH_C32(0x9e5ea000), SPH_C32(0x8dc40227), SPH_C32(0xb1448fda), + SPH_C32(0xc6f7b8f8), SPH_C32(0x0d52a000), SPH_C32(0x31c1ff3d), + SPH_C32(0xa4011e05), SPH_C32(0x14055bfb) }, + { SPH_C32(0x55f7a000), SPH_C32(0x1de3354e), SPH_C32(0x0a987bdd), + SPH_C32(0x16031799), SPH_C32(0xb26eb000), SPH_C32(0xfbcd8e2a), + SPH_C32(0x9720f729), SPH_C32(0xda177608) }, + { SPH_C32(0xf23cc000), SPH_C32(0x42cb39e0), SPH_C32(0x5afd9229), + SPH_C32(0x94e42f6f), SPH_C32(0x022f8000), SPH_C32(0xce2549e4), + SPH_C32(0x317ebce8), SPH_C32(0x398d5ee1) }, + { SPH_C32(0x3995c000), SPH_C32(0xd2ec0e89), SPH_C32(0xe121662e), + SPH_C32(0x4410800e), SPH_C32(0xbd139000), SPH_C32(0x042938f3), + SPH_C32(0x025f55c4), SPH_C32(0xf79f7312) }, + { SPH_C32(0x1b16e000), SPH_C32(0xf69cb51c), SPH_C32(0x4b07a87e), + SPH_C32(0xa92d2a4b), SPH_C32(0x957c8000), SPH_C32(0xee6a2737), + SPH_C32(0x46c754e7), SPH_C32(0x98610020) }, + { SPH_C32(0xd0bfe000), SPH_C32(0x66bb8275), SPH_C32(0xf0db5c79), + SPH_C32(0x79d9852a), SPH_C32(0x2a409000), SPH_C32(0x24665620), + SPH_C32(0x75e6bdcb), SPH_C32(0x56732dd3) }, + { SPH_C32(0x656fc000), SPH_C32(0x62845733), SPH_C32(0x2d447a26), + SPH_C32(0x350871ae), SPH_C32(0x7c56a000), SPH_C32(0x5a3dabcb), + SPH_C32(0x573d6eb0), SPH_C32(0xa5a80504) }, + { SPH_C32(0xaec6c000), SPH_C32(0xf2a3605a), SPH_C32(0x496988e21), + SPH_C32(0xe5fcdecf), SPH_C32(0xc36ab000), SPH_C32(0x9031dadc), + SPH_C32(0x641c879c), SPH_C32(0x6bba28f7) }, + { SPH_C32(0x8c45e000), SPH_C32(0xd6d3dbcf), SPH_C32(0x3cbe4071), + SPH_C32(0x08c1748a), SPH_C32(0xeb05a000), SPH_C32(0x7a72c518), + SPH_C32(0x208486bf), SPH_C32(0x04445bc5) }, + { SPH_C32(0x47ece000), SPH_C32(0x46f4eca6), SPH_C32(0x8762b476), + SPH_C32(0xd835dbeb), SPH_C32(0x5439b000), SPH_C32(0xb07eb40f), + SPH_C32(0x13a56f93), SPH_C32(0xca567636) }, + { SPH_C32(0x06708000), SPH_C32(0x526fda2d), SPH_C32(0x5382c538), + SPH_C32(0x4a93e323), SPH_C32(0x1034c000), SPH_C32(0x9532900c), + SPH_C32(0xbc847343), SPH_C32(0xf7bb9293) }, + { SPH_C32(0xcdd98000), SPH_C32(0xc248ed44), SPH_C32(0xe85e313f), + SPH_C32(0x9a674c42), SPH_C32(0xaf08d000), SPH_C32(0x5f3ee11b), + SPH_C32(0x8fa59a6f), SPH_C32(0x39a9bf60) }, + { SPH_C32(0xef5aa000), SPH_C32(0xe63856d1), SPH_C32(0x4278ff6f), + SPH_C32(0x775ae607), SPH_C32(0x8767c000), SPH_C32(0xb57dfedf), + SPH_C32(0xcb3d9b4c), SPH_C32(0x5657cc52) }, + { SPH_C32(0x24f3a000), SPH_C32(0x761f61b8), SPH_C32(0xf9a40b68), + SPH_C32(0xa7ae4966), SPH_C32(0x385bd000), SPH_C32(0x7f718fc8), + SPH_C32(0xf81c7260), SPH_C32(0x9845e1a1) }, + { SPH_C32(0x91238000), SPH_C32(0x7220b4fe), SPH_C32(0x243b2d37), + SPH_C32(0xeb7fbde2), SPH_C32(0x6e4de000), SPH_C32(0x012a7223), + SPH_C32(0xdac7a11b), SPH_C32(0x6b9ec976) }, + { SPH_C32(0x5a8a8000), SPH_C32(0xe2078397), SPH_C32(0x9fe7d930), + SPH_C32(0x3b8b1283), SPH_C32(0xd171f000), SPH_C32(0xcb260334), + SPH_C32(0xe9e64837), SPH_C32(0xa58ce485) }, + { SPH_C32(0x7809a000), SPH_C32(0xc6773802), SPH_C32(0x35c11760), + SPH_C32(0xd6b6b8c6), SPH_C32(0xf91ee000), SPH_C32(0x21651cf0), + SPH_C32(0xad7e4914), SPH_C32(0xca7297b7) }, + { SPH_C32(0xb3a0a000), SPH_C32(0x56500f6b), SPH_C32(0x8e1de367), + SPH_C32(0x064217a7), SPH_C32(0x4622f000), SPH_C32(0xeb696de7), + SPH_C32(0x9e5fa038), SPH_C32(0x0460ba44) }, + { SPH_C32(0x146bc000), SPH_C32(0x097803c5), SPH_C32(0xde780a93), + SPH_C32(0x84a52f51), SPH_C32(0xf663c000), SPH_C32(0xde81aa29), + SPH_C32(0x3801ebf9), SPH_C32(0xe7fa92ad) }, + { SPH_C32(0xdfc2c000), SPH_C32(0x995f34ac), SPH_C32(0x65a4fe94), + SPH_C32(0x54518030), SPH_C32(0x495fd000), SPH_C32(0x148ddb3e), + SPH_C32(0x0b2002d5), SPH_C32(0x29e8bf5e) }, + { SPH_C32(0xfd41e000), SPH_C32(0xbd2f8f39), SPH_C32(0xcf8230c4), + SPH_C32(0xb96c2a75), SPH_C32(0x6130c000), SPH_C32(0xfecec4fa), + SPH_C32(0x4fb803f6), SPH_C32(0x4616cc6c) }, + { SPH_C32(0x36e8e000), SPH_C32(0x2d08b850), SPH_C32(0x745ec4c3), + SPH_C32(0x69988514), SPH_C32(0xde0cd000), SPH_C32(0x34c2b5ed), + SPH_C32(0x7c99eada), SPH_C32(0x8804e19f) }, + { SPH_C32(0x8338c000), SPH_C32(0x29376d16), SPH_C32(0xa9c1e29c), + SPH_C32(0x25497190), SPH_C32(0x881ae000), SPH_C32(0x4a994806), + SPH_C32(0x5e4239a1), SPH_C32(0x7bdfc948) }, + { SPH_C32(0x4891c000), SPH_C32(0xb9105a7f), SPH_C32(0x121d169b), + SPH_C32(0xf5bddef1), SPH_C32(0x3726f000), SPH_C32(0x80953911), + SPH_C32(0x6d63d08d), SPH_C32(0xb5cde4bb) }, + { SPH_C32(0x6a12e000), SPH_C32(0x9d60e1ea), SPH_C32(0xb83bd8cb), + SPH_C32(0x188074b4), SPH_C32(0x1f49e000), SPH_C32(0x6ad626d5), + SPH_C32(0x29fbd1ae), SPH_C32(0xda339789) }, + { SPH_C32(0xa1bbe000), SPH_C32(0x0d47d683), SPH_C32(0x03e72ccc), + SPH_C32(0xc874dbd5), SPH_C32(0xa075f000), SPH_C32(0xa0da57c2), + SPH_C32(0x1ada3882), SPH_C32(0x1421ba7a) } +}; + +static const sph_u32 T256_7[128][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xa7b80200), SPH_C32(0x1f128433), SPH_C32(0x60e5f9f2), + SPH_C32(0x9e147576), SPH_C32(0xee260000), SPH_C32(0x124b683e), + SPH_C32(0x80c2d68f), SPH_C32(0x3bf3ab2c) }, + { SPH_C32(0xee260000), SPH_C32(0x124b683e), SPH_C32(0x80c2d68f), + SPH_C32(0x3bf3ab2c), SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), + SPH_C32(0xe0272f7d), SPH_C32(0xa5e7de5a) }, + { SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), SPH_C32(0xe0272f7d), + SPH_C32(0xa5e7de5a), SPH_C32(0xa7b80200), SPH_C32(0x1f128433), + SPH_C32(0x60e5f9f2), SPH_C32(0x9e147576) }, + { SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), SPH_C32(0x6fc548e1), + SPH_C32(0x898d2cd6), SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), + SPH_C32(0x6a72e5bb), SPH_C32(0x247febe6) }, + { SPH_C32(0x28860600), SPH_C32(0x128f4c44), SPH_C32(0x0f20b113), + SPH_C32(0x179959a0), SPH_C32(0xfa9b0000), SPH_C32(0x3df15fc1), + SPH_C32(0xeab03334), SPH_C32(0x1f8c40ca) }, + { SPH_C32(0x61180400), SPH_C32(0x1fd6a049), SPH_C32(0xef079e6e), + SPH_C32(0xb27e87fa), SPH_C32(0x5d230200), SPH_C32(0x22e3dbf2), + SPH_C32(0x8a55cac6), SPH_C32(0x819835bc) }, + { SPH_C32(0xc6a00600), SPH_C32(0x00c4247a), SPH_C32(0x8fe2679c), + SPH_C32(0x2c6af28c), SPH_C32(0xb3050200), SPH_C32(0x30a8b3cc), + SPH_C32(0x0a971c49), SPH_C32(0xba6b9e90) }, + { SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), SPH_C32(0x6a72e5bb), + SPH_C32(0x247febe6), SPH_C32(0x9b830400), SPH_C32(0x2227ff88), + SPH_C32(0x05b7ad5a), SPH_C32(0xadf2c730) }, + { SPH_C32(0xb3050200), SPH_C32(0x30a8b3cc), SPH_C32(0x0a971c49), + SPH_C32(0xba6b9e90), SPH_C32(0x75a50400), SPH_C32(0x306c97b6), + SPH_C32(0x85757bd5), SPH_C32(0x96016c1c) }, + { SPH_C32(0xfa9b0000), SPH_C32(0x3df15fc1), SPH_C32(0xeab03334), + SPH_C32(0x1f8c40ca), SPH_C32(0xd21d0600), SPH_C32(0x2f7e1385), + SPH_C32(0xe5908227), SPH_C32(0x0815196a) }, + { SPH_C32(0x5d230200), SPH_C32(0x22e3dbf2), SPH_C32(0x8a55cac6), + SPH_C32(0x819835bc), SPH_C32(0x3c3b0600), SPH_C32(0x3d357bbb), + SPH_C32(0x655254a8), SPH_C32(0x33e6b246) }, + { SPH_C32(0x9b830400), SPH_C32(0x2227ff88), SPH_C32(0x05b7ad5a), + SPH_C32(0xadf2c730), SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), + SPH_C32(0x6fc548e1), SPH_C32(0x898d2cd6) }, + { SPH_C32(0x3c3b0600), SPH_C32(0x3d357bbb), SPH_C32(0x655254a8), + SPH_C32(0x33e6b246), SPH_C32(0x61180400), SPH_C32(0x1fd6a049), + SPH_C32(0xef079e6e), SPH_C32(0xb27e87fa) }, + { SPH_C32(0x75a50400), SPH_C32(0x306c97b6), SPH_C32(0x85757bd5), + SPH_C32(0x96016c1c), SPH_C32(0xc6a00600), SPH_C32(0x00c4247a), + SPH_C32(0x8fe2679c), SPH_C32(0x2c6af28c) }, + { SPH_C32(0xd21d0600), SPH_C32(0x2f7e1385), SPH_C32(0xe5908227), + SPH_C32(0x0815196a), SPH_C32(0x28860600), SPH_C32(0x128f4c44), + SPH_C32(0x0f20b113), SPH_C32(0x179959a0) }, + { SPH_C32(0xde320800), SPH_C32(0x288350fe), SPH_C32(0x71852ac7), + SPH_C32(0xa6bf9f96), SPH_C32(0xe18b0000), SPH_C32(0x5459887d), + SPH_C32(0xbf1283d3), SPH_C32(0x1b666a73) }, + { SPH_C32(0x798a0a00), SPH_C32(0x3791d4cd), SPH_C32(0x1160d335), + SPH_C32(0x38abeae0), SPH_C32(0x0fad0000), SPH_C32(0x4612e043), + SPH_C32(0x3fd0555c), SPH_C32(0x2095c15f) }, + { SPH_C32(0x30140800), SPH_C32(0x3ac838c0), SPH_C32(0xf147fc48), + SPH_C32(0x9d4c34ba), SPH_C32(0xa8150200), SPH_C32(0x59006470), + SPH_C32(0x5f35acae), SPH_C32(0xbe81b429) }, + { SPH_C32(0x97ac0a00), SPH_C32(0x25dabcf3), SPH_C32(0x91a205ba), + SPH_C32(0x035841cc), SPH_C32(0x46330200), SPH_C32(0x4b4b0c4e), + SPH_C32(0xdff77a21), SPH_C32(0x85721f05) }, + { SPH_C32(0x510c0c00), SPH_C32(0x251e9889), SPH_C32(0x1e406226), + SPH_C32(0x2f32b340), SPH_C32(0xf5360000), SPH_C32(0x7be3bf82), + SPH_C32(0xd5606668), SPH_C32(0x3f198195) }, + { SPH_C32(0xf6b40e00), SPH_C32(0x3a0c1cba), SPH_C32(0x7ea59bd4), + SPH_C32(0xb126c636), SPH_C32(0x1b100000), SPH_C32(0x69a8d7bc), + SPH_C32(0x55a2b0e7), SPH_C32(0x04ea2ab9) }, + { SPH_C32(0xbf2a0c00), SPH_C32(0x3755f0b7), SPH_C32(0x9e82b4a9), + SPH_C32(0x14c1186c), SPH_C32(0xbca80200), SPH_C32(0x76ba538f), + SPH_C32(0x35474915), SPH_C32(0x9afe5fcf) }, + { SPH_C32(0x18920e00), SPH_C32(0x28477484), SPH_C32(0xfe674d5b), + SPH_C32(0x8ad56d1a), SPH_C32(0x528e0200), SPH_C32(0x64f13bb1), + SPH_C32(0xb5859f9a), SPH_C32(0xa10df4e3) }, + { SPH_C32(0xca8f0800), SPH_C32(0x07396701), SPH_C32(0x1bf7cf7c), + SPH_C32(0x82c07470), SPH_C32(0x7a080400), SPH_C32(0x767e77f5), + SPH_C32(0xbaa52e89), SPH_C32(0xb694ad43) }, + { SPH_C32(0x6d370a00), SPH_C32(0x182be332), SPH_C32(0x7b12368e), + SPH_C32(0x1cd40106), SPH_C32(0x942e0400), SPH_C32(0x64351fcb), + SPH_C32(0x3a67f806), SPH_C32(0x8d67066f) }, + { SPH_C32(0x24a90800), SPH_C32(0x15720f3f), SPH_C32(0x9b3519f3), + SPH_C32(0xb933df5c), SPH_C32(0x33960600), SPH_C32(0x7b279bf8), + SPH_C32(0x5a8201f4), SPH_C32(0x13737319) }, + { SPH_C32(0x83110a00), SPH_C32(0x0a608b0c), SPH_C32(0xfbd0e001), + SPH_C32(0x2727aa2a), SPH_C32(0xddb00600), SPH_C32(0x696cf3c6), + SPH_C32(0xda40d77b), SPH_C32(0x2880d835) }, + { SPH_C32(0x45b10c00), SPH_C32(0x0aa4af76), SPH_C32(0x7432879d), + SPH_C32(0x0b4d58a6), SPH_C32(0x6eb50400), SPH_C32(0x59c4400a), + SPH_C32(0xd0d7cb32), SPH_C32(0x92eb46a5) }, + { SPH_C32(0xe2090e00), SPH_C32(0x15b62b45), SPH_C32(0x14d77e6f), + SPH_C32(0x95592dd0), SPH_C32(0x80930400), SPH_C32(0x4b8f2834), + SPH_C32(0x50151dbd), SPH_C32(0xa918ed89) }, + { SPH_C32(0xab970c00), SPH_C32(0x18efc748), SPH_C32(0xf4f05112), + SPH_C32(0x30bef38a), SPH_C32(0x272b0600), SPH_C32(0x549dac07), + SPH_C32(0x30f0e44f), SPH_C32(0x370c98ff) }, + { SPH_C32(0x0c2f0e00), SPH_C32(0x07fd437b), SPH_C32(0x9415a8e0), + SPH_C32(0xaeaa86fc), SPH_C32(0xc90d0600), SPH_C32(0x46d6c439), + SPH_C32(0xb03232c0), SPH_C32(0x0cff33d3) }, + { SPH_C32(0xe18b0000), SPH_C32(0x5459887d), SPH_C32(0xbf1283d3), + SPH_C32(0x1b666a73), SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), + SPH_C32(0xce97a914), SPH_C32(0xbdd9f5e5) }, + { SPH_C32(0x46330200), SPH_C32(0x4b4b0c4e), SPH_C32(0xdff77a21), + SPH_C32(0x85721f05), SPH_C32(0xd19f0800), SPH_C32(0x6e91b0bd), + SPH_C32(0x4e557f9b), SPH_C32(0x862a5ec9) }, + { SPH_C32(0x0fad0000), SPH_C32(0x4612e043), SPH_C32(0x3fd0555c), + SPH_C32(0x2095c15f), SPH_C32(0x76270a00), SPH_C32(0x7183348e), + SPH_C32(0x2eb08669), SPH_C32(0x183e2bbf) }, + { SPH_C32(0xa8150200), SPH_C32(0x59006470), SPH_C32(0x5f35acae), + SPH_C32(0xbe81b429), SPH_C32(0x98010a00), SPH_C32(0x63c85cb0), + SPH_C32(0xae7250e6), SPH_C32(0x23cd8093) }, + { SPH_C32(0x6eb50400), SPH_C32(0x59c4400a), SPH_C32(0xd0d7cb32), + SPH_C32(0x92eb46a5), SPH_C32(0x2b040800), SPH_C32(0x5360ef7c), + SPH_C32(0xa4e54caf), SPH_C32(0x99a61e03) }, + { SPH_C32(0xc90d0600), SPH_C32(0x46d6c439), SPH_C32(0xb03232c0), + SPH_C32(0x0cff33d3), SPH_C32(0xc5220800), SPH_C32(0x412b8742), + SPH_C32(0x24279a20), SPH_C32(0xa255b52f) }, + { SPH_C32(0x80930400), SPH_C32(0x4b8f2834), SPH_C32(0x50151dbd), + SPH_C32(0xa918ed89), SPH_C32(0x629a0a00), SPH_C32(0x5e390371), + SPH_C32(0x44c263d2), SPH_C32(0x3c41c059) }, + { SPH_C32(0x272b0600), SPH_C32(0x549dac07), SPH_C32(0x30f0e44f), + SPH_C32(0x370c98ff), SPH_C32(0x8cbc0a00), SPH_C32(0x4c726b4f), + SPH_C32(0xc400b55d), SPH_C32(0x07b26b75) }, + { SPH_C32(0xf5360000), SPH_C32(0x7be3bf82), SPH_C32(0xd5606668), + SPH_C32(0x3f198195), SPH_C32(0xa43a0c00), SPH_C32(0x5efd270b), + SPH_C32(0xcb20044e), SPH_C32(0x102b32d5) }, + { SPH_C32(0x528e0200), SPH_C32(0x64f13bb1), SPH_C32(0xb5859f9a), + SPH_C32(0xa10df4e3), SPH_C32(0x4a1c0c00), SPH_C32(0x4cb64f35), + SPH_C32(0x4be2d2c1), SPH_C32(0x2bd899f9) }, + { SPH_C32(0x1b100000), SPH_C32(0x69a8d7bc), SPH_C32(0x55a2b0e7), + SPH_C32(0x04ea2ab9), SPH_C32(0xeda40e00), SPH_C32(0x53a4cb06), + SPH_C32(0x2b072b33), SPH_C32(0xb5ccec8f) }, + { SPH_C32(0xbca80200), SPH_C32(0x76ba538f), SPH_C32(0x35474915), + SPH_C32(0x9afe5fcf), SPH_C32(0x03820e00), SPH_C32(0x41efa338), + SPH_C32(0xabc5fdbc), SPH_C32(0x8e3f47a3) }, + { SPH_C32(0x7a080400), SPH_C32(0x767e77f5), SPH_C32(0xbaa52e89), + SPH_C32(0xb694ad43), SPH_C32(0xb0870c00), SPH_C32(0x714710f4), + SPH_C32(0xa152e1f5), SPH_C32(0x3454d933) }, + { SPH_C32(0xddb00600), SPH_C32(0x696cf3c6), SPH_C32(0xda40d77b), + SPH_C32(0x2880d835), SPH_C32(0x5ea10c00), SPH_C32(0x630c78ca), + SPH_C32(0x2190377a), SPH_C32(0x0fa7721f) }, + { SPH_C32(0x942e0400), SPH_C32(0x64351fcb), SPH_C32(0x3a67f806), + SPH_C32(0x8d67066f), SPH_C32(0xf9190e00), SPH_C32(0x7c1efcf9), + SPH_C32(0x4175ce88), SPH_C32(0x91b30769) }, + { SPH_C32(0x33960600), SPH_C32(0x7b279bf8), SPH_C32(0x5a8201f4), + SPH_C32(0x13737319), SPH_C32(0x173f0e00), SPH_C32(0x6e5594c7), + SPH_C32(0xc1b71807), SPH_C32(0xaa40ac45) }, + { SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), SPH_C32(0xce97a914), + SPH_C32(0xbdd9f5e5), SPH_C32(0xde320800), SPH_C32(0x288350fe), + SPH_C32(0x71852ac7), SPH_C32(0xa6bf9f96) }, + { SPH_C32(0x98010a00), SPH_C32(0x63c85cb0), SPH_C32(0xae7250e6), + SPH_C32(0x23cd8093), SPH_C32(0x30140800), SPH_C32(0x3ac838c0), + SPH_C32(0xf147fc48), SPH_C32(0x9d4c34ba) }, + { SPH_C32(0xd19f0800), SPH_C32(0x6e91b0bd), SPH_C32(0x4e557f9b), + SPH_C32(0x862a5ec9), SPH_C32(0x97ac0a00), SPH_C32(0x25dabcf3), + SPH_C32(0x91a205ba), SPH_C32(0x035841cc) }, + { SPH_C32(0x76270a00), SPH_C32(0x7183348e), SPH_C32(0x2eb08669), + SPH_C32(0x183e2bbf), SPH_C32(0x798a0a00), SPH_C32(0x3791d4cd), + SPH_C32(0x1160d335), SPH_C32(0x38abeae0) }, + { SPH_C32(0xb0870c00), SPH_C32(0x714710f4), SPH_C32(0xa152e1f5), + SPH_C32(0x3454d933), SPH_C32(0xca8f0800), SPH_C32(0x07396701), + SPH_C32(0x1bf7cf7c), SPH_C32(0x82c07470) }, + { SPH_C32(0x173f0e00), SPH_C32(0x6e5594c7), SPH_C32(0xc1b71807), + SPH_C32(0xaa40ac45), SPH_C32(0x24a90800), SPH_C32(0x15720f3f), + SPH_C32(0x9b3519f3), SPH_C32(0xb933df5c) }, + { SPH_C32(0x5ea10c00), SPH_C32(0x630c78ca), SPH_C32(0x2190377a), + SPH_C32(0x0fa7721f), SPH_C32(0x83110a00), SPH_C32(0x0a608b0c), + SPH_C32(0xfbd0e001), SPH_C32(0x2727aa2a) }, + { SPH_C32(0xf9190e00), SPH_C32(0x7c1efcf9), SPH_C32(0x4175ce88), + SPH_C32(0x91b30769), SPH_C32(0x6d370a00), SPH_C32(0x182be332), + SPH_C32(0x7b12368e), SPH_C32(0x1cd40106) }, + { SPH_C32(0x2b040800), SPH_C32(0x5360ef7c), SPH_C32(0xa4e54caf), + SPH_C32(0x99a61e03), SPH_C32(0x45b10c00), SPH_C32(0x0aa4af76), + SPH_C32(0x7432879d), SPH_C32(0x0b4d58a6) }, + { SPH_C32(0x8cbc0a00), SPH_C32(0x4c726b4f), SPH_C32(0xc400b55d), + SPH_C32(0x07b26b75), SPH_C32(0xab970c00), SPH_C32(0x18efc748), + SPH_C32(0xf4f05112), SPH_C32(0x30bef38a) }, + { SPH_C32(0xc5220800), SPH_C32(0x412b8742), SPH_C32(0x24279a20), + SPH_C32(0xa255b52f), SPH_C32(0x0c2f0e00), SPH_C32(0x07fd437b), + SPH_C32(0x9415a8e0), SPH_C32(0xaeaa86fc) }, + { SPH_C32(0x629a0a00), SPH_C32(0x5e390371), SPH_C32(0x44c263d2), + SPH_C32(0x3c41c059), SPH_C32(0xe2090e00), SPH_C32(0x15b62b45), + SPH_C32(0x14d77e6f), SPH_C32(0x95592dd0) }, + { SPH_C32(0xa43a0c00), SPH_C32(0x5efd270b), SPH_C32(0xcb20044e), + SPH_C32(0x102b32d5), SPH_C32(0x510c0c00), SPH_C32(0x251e9889), + SPH_C32(0x1e406226), SPH_C32(0x2f32b340) }, + { SPH_C32(0x03820e00), SPH_C32(0x41efa338), SPH_C32(0xabc5fdbc), + SPH_C32(0x8e3f47a3), SPH_C32(0xbf2a0c00), SPH_C32(0x3755f0b7), + SPH_C32(0x9e82b4a9), SPH_C32(0x14c1186c) }, + { SPH_C32(0x4a1c0c00), SPH_C32(0x4cb64f35), SPH_C32(0x4be2d2c1), + SPH_C32(0x2bd899f9), SPH_C32(0x18920e00), SPH_C32(0x28477484), + SPH_C32(0xfe674d5b), SPH_C32(0x8ad56d1a) }, + { SPH_C32(0xeda40e00), SPH_C32(0x53a4cb06), SPH_C32(0x2b072b33), + SPH_C32(0xb5ccec8f), SPH_C32(0xf6b40e00), SPH_C32(0x3a0c1cba), + SPH_C32(0x7ea59bd4), SPH_C32(0xb126c636) }, + { SPH_C32(0x74951000), SPH_C32(0x5a2b467e), SPH_C32(0x88fd1d2b), + SPH_C32(0x1ee68292), SPH_C32(0xcba90000), SPH_C32(0x90273769), + SPH_C32(0xbbdcf407), SPH_C32(0xd0f4af61) }, + { SPH_C32(0xd32d1200), SPH_C32(0x4539c24d), SPH_C32(0xe818e4d9), + SPH_C32(0x80f2f7e4), SPH_C32(0x258f0000), SPH_C32(0x826c5f57), + SPH_C32(0x3b1e2288), SPH_C32(0xeb07044d) }, + { SPH_C32(0x9ab31000), SPH_C32(0x48602e40), SPH_C32(0x083fcba4), + SPH_C32(0x251529be), SPH_C32(0x82370200), SPH_C32(0x9d7edb64), + SPH_C32(0x5bfbdb7a), SPH_C32(0x7513713b) }, + { SPH_C32(0x3d0b1200), SPH_C32(0x5772aa73), SPH_C32(0x68da3256), + SPH_C32(0xbb015cc8), SPH_C32(0x6c110200), SPH_C32(0x8f35b35a), + SPH_C32(0xdb390df5), SPH_C32(0x4ee0da17) }, + { SPH_C32(0xfbab1400), SPH_C32(0x57b68e09), SPH_C32(0xe73855ca), + SPH_C32(0x976bae44), SPH_C32(0xdf140000), SPH_C32(0xbf9d0096), + SPH_C32(0xd1ae11bc), SPH_C32(0xf48b4487) }, + { SPH_C32(0x5c131600), SPH_C32(0x48a40a3a), SPH_C32(0x87ddac38), + SPH_C32(0x097fdb32), SPH_C32(0x31320000), SPH_C32(0xadd668a8), + SPH_C32(0x516cc733), SPH_C32(0xcf78efab) }, + { SPH_C32(0x158d1400), SPH_C32(0x45fde637), SPH_C32(0x67fa8345), + SPH_C32(0xac980568), SPH_C32(0x968a0200), SPH_C32(0xb2c4ec9b), + SPH_C32(0x31893ec1), SPH_C32(0x516c9add) }, + { SPH_C32(0xb2351600), SPH_C32(0x5aef6204), SPH_C32(0x071f7ab7), + SPH_C32(0x328c701e), SPH_C32(0x78ac0200), SPH_C32(0xa08f84a5), + SPH_C32(0xb14be84e), SPH_C32(0x6a9f31f1) }, + { SPH_C32(0x60281000), SPH_C32(0x75917181), SPH_C32(0xe28ff890), + SPH_C32(0x3a9496974), SPH_C32(0x502a0400), SPH_C32(0xb200c8e1), + SPH_C32(0xbe6b595d), SPH_C32(0x7d066851) }, + { SPH_C32(0xc7901200), SPH_C32(0x6a83f5b2), SPH_C32(0x826a0162), + SPH_C32(0xa48d1c02), SPH_C32(0xbe0c0400), SPH_C32(0xa04ba0df), + SPH_C32(0x3ea98fd2), SPH_C32(0x46f5c37d) }, + { SPH_C32(0x8e0e1000), SPH_C32(0x67da19bf), SPH_C32(0x624d2e1f), + SPH_C32(0x016ac258), SPH_C32(0x19b40600), SPH_C32(0xbf5924ec), + SPH_C32(0x5e4c7620), SPH_C32(0xd8e1b60b) }, + { SPH_C32(0x29b61200), SPH_C32(0x78c89d8c), SPH_C32(0x02a8d7ed), + SPH_C32(0x9f7eb72e), SPH_C32(0xf7920600), SPH_C32(0xad124cd2), + SPH_C32(0xde8ea0af), SPH_C32(0xe3121d27) }, + { SPH_C32(0xef161400), SPH_C32(0x780cb9f6), SPH_C32(0x8d4ab071), + SPH_C32(0xb31445a2), SPH_C32(0x44970400), SPH_C32(0x9dbaff1e), + SPH_C32(0xd419bce6), SPH_C32(0x597983b7) }, + { SPH_C32(0x48ae1600), SPH_C32(0x671e3dc5), SPH_C32(0xedaf4983), + SPH_C32(0x2d0030d4), SPH_C32(0xaab10400), SPH_C32(0x8ff19720), + SPH_C32(0x54db6a69), SPH_C32(0x628a289b) }, + { SPH_C32(0x01301400), SPH_C32(0x6a47d1c8), SPH_C32(0x0d8866fe), + SPH_C32(0x88e7ee8e), SPH_C32(0x0d090600), SPH_C32(0x90e31313), + SPH_C32(0x343e939b), SPH_C32(0xfc9e5ded) }, + { SPH_C32(0xa6881600), SPH_C32(0x755555fb), SPH_C32(0x6d6d9f0c), + SPH_C32(0x16f39bf8), SPH_C32(0xe32f0600), SPH_C32(0x82a87b2d), + SPH_C32(0xb4fc4514), SPH_C32(0xc76df6c1) }, + { SPH_C32(0xaaa71800), SPH_C32(0x72a81680), SPH_C32(0xf97837ec), + SPH_C32(0xb8591d04), SPH_C32(0x2a220000), SPH_C32(0xc47ebf14), + SPH_C32(0x04ce77d4), SPH_C32(0xcb92c512) }, + { SPH_C32(0x0d1f1a00), SPH_C32(0x6dba92b3), SPH_C32(0x999dce1e), + SPH_C32(0x264d6872), SPH_C32(0xc4040000), SPH_C32(0xd635d72a), + SPH_C32(0x840ca15b), SPH_C32(0xf0616e3e) }, + { SPH_C32(0x44811800), SPH_C32(0x60e37ebe), SPH_C32(0x79bae163), + SPH_C32(0x83aab628), SPH_C32(0x63bc0200), SPH_C32(0xc9275319), + SPH_C32(0xe4e958a9), SPH_C32(0x6e751b48) }, + { SPH_C32(0xe3391a00), SPH_C32(0x7ff1fa8d), SPH_C32(0x195f1891), + SPH_C32(0x1dbec35e), SPH_C32(0x8d9a0200), SPH_C32(0xdb6c3b27), + SPH_C32(0x642b8e26), SPH_C32(0x5586b064) }, + { SPH_C32(0x25991c00), SPH_C32(0x7f35def7), SPH_C32(0x96bd7f0d), + SPH_C32(0x31d431d2), SPH_C32(0x3e9f0000), SPH_C32(0xebc488eb), + SPH_C32(0x6ebc926f), SPH_C32(0xefed2ef4) }, + { SPH_C32(0x82211e00), SPH_C32(0x60275ac4), SPH_C32(0xf65886ff), + SPH_C32(0xafc044a4), SPH_C32(0xd0b90000), SPH_C32(0xf98fe0d5), + SPH_C32(0xee7e44e0), SPH_C32(0xd41e85d8) }, + { SPH_C32(0xcbbf1c00), SPH_C32(0x6d7eb6c9), SPH_C32(0x167fa982), + SPH_C32(0x0a279afe), SPH_C32(0x77010200), SPH_C32(0xe69d64e6), + SPH_C32(0x8e9bbd12), SPH_C32(0x4a0af0ae) }, + { SPH_C32(0x6c071e00), SPH_C32(0x726c32fa), SPH_C32(0x769a5070), + SPH_C32(0x9433ef88), SPH_C32(0x99270200), SPH_C32(0xf4d60cd8), + SPH_C32(0x0e596b9d), SPH_C32(0x71f95b82) }, + { SPH_C32(0xbe1a1800), SPH_C32(0x5d12217f), SPH_C32(0x930ad257), + SPH_C32(0x9c26f6e2), SPH_C32(0xb1a10400), SPH_C32(0xe659409c), + SPH_C32(0x0179da8e), SPH_C32(0x66600222) }, + { SPH_C32(0x19a21a00), SPH_C32(0x4200a54c), SPH_C32(0xf3ef2ba5), + SPH_C32(0x02328394), SPH_C32(0x5f870400), SPH_C32(0xf41228a2), + SPH_C32(0x81bb0c01), SPH_C32(0x5d93a90e) }, + { SPH_C32(0x503c1800), SPH_C32(0x4f594941), SPH_C32(0x13c804d8), + SPH_C32(0xa7d55dce), SPH_C32(0xf83f0600), SPH_C32(0xeb00ac91), + SPH_C32(0xe15ef5f3), SPH_C32(0xc387dc78) }, + { SPH_C32(0xf7841a00), SPH_C32(0x504bcd72), SPH_C32(0x732dfd2a), + SPH_C32(0x39c128b8), SPH_C32(0x16190600), SPH_C32(0xf94bc4af), + SPH_C32(0x619c237c), SPH_C32(0xf8747754) }, + { SPH_C32(0x31241c00), SPH_C32(0x508fe908), SPH_C32(0xfccf9ab6), + SPH_C32(0x15abda34), SPH_C32(0xa51c0400), SPH_C32(0xc9e37763), + SPH_C32(0x6b0b3f35), SPH_C32(0x421fe9c4) }, + { SPH_C32(0x969c1e00), SPH_C32(0x4f9d6d3b), SPH_C32(0x9c2a6344), + SPH_C32(0x8bbfaf42), SPH_C32(0x4b3a0400), SPH_C32(0xdba81f5d), + SPH_C32(0xebc9e9ba), SPH_C32(0x79ec42e8) }, + { SPH_C32(0xdf021c00), SPH_C32(0x42c48136), SPH_C32(0x7c0d4c39), + SPH_C32(0x2e587118), SPH_C32(0xec820600), SPH_C32(0xc4ba9b6e), + SPH_C32(0x8b2c1048), SPH_C32(0xe7f8379e) }, + { SPH_C32(0x78ba1e00), SPH_C32(0x5dd60505), SPH_C32(0x1ce8b5cb), + SPH_C32(0xb04c046e), SPH_C32(0x02a40600), SPH_C32(0xd6f1f350), + SPH_C32(0x0beec6c7), SPH_C32(0xdc0b9cb2) }, + { SPH_C32(0x951e1000), SPH_C32(0x0e72ce03), SPH_C32(0x37ef9ef8), + SPH_C32(0x0580e8e1), SPH_C32(0xf4100800), SPH_C32(0xecfdefea), + SPH_C32(0x754b5d13), SPH_C32(0x6d2d5a84) }, + { SPH_C32(0x32a61200), SPH_C32(0x11604a30), SPH_C32(0x570a670a), + SPH_C32(0x9b949d97), SPH_C32(0x1a360800), SPH_C32(0xfeb687d4), + SPH_C32(0xf5898b9c), SPH_C32(0x56def1a8) }, + { SPH_C32(0x7b381000), SPH_C32(0x1c39a63d), SPH_C32(0xb72d4877), + SPH_C32(0x3e7343cd), SPH_C32(0xbd8e0a00), SPH_C32(0xe1a403e7), + SPH_C32(0x956c726e), SPH_C32(0xc8ca84de) }, + { SPH_C32(0xdc801200), SPH_C32(0x032b220e), SPH_C32(0xd7c8b185), + SPH_C32(0xa06736bb), SPH_C32(0x53a80a00), SPH_C32(0xf3ef6bd9), + SPH_C32(0x15aea4e1), SPH_C32(0xf3392ff2) }, + { SPH_C32(0x1a201400), SPH_C32(0x03ef0674), SPH_C32(0x582ad619), + SPH_C32(0x8c0dc437), SPH_C32(0xe0ad0800), SPH_C32(0xc347d815), + SPH_C32(0x1f39b8a8), SPH_C32(0x4952b162) }, + { SPH_C32(0xbd981600), SPH_C32(0x1cfd8247), SPH_C32(0x38cf2feb), + SPH_C32(0x1219b141), SPH_C32(0x0e8b0800), SPH_C32(0xd10cb02b), + SPH_C32(0x9ffb6e27), SPH_C32(0x72a11a4e) }, + { SPH_C32(0xf4061400), SPH_C32(0x11a46e4a), SPH_C32(0xd8e80096), + SPH_C32(0xb7fe6f1b), SPH_C32(0xa9330a00), SPH_C32(0xce1e3418), + SPH_C32(0xff1e97d5), SPH_C32(0xecb56f38) }, + { SPH_C32(0x53be1600), SPH_C32(0x0eb6ea79), SPH_C32(0xb80df964), + SPH_C32(0x29ea1a6d), SPH_C32(0x47150a00), SPH_C32(0xdc555c26), + SPH_C32(0x7fdc415a), SPH_C32(0xd746c414) }, + { SPH_C32(0x81a31000), SPH_C32(0x21c8f9fc), SPH_C32(0x5d9d7b43), + SPH_C32(0x21ff0307), SPH_C32(0x6f930c00), SPH_C32(0xceda1062), + SPH_C32(0x70fcf049), SPH_C32(0xc0df9db4) }, + { SPH_C32(0x261b1200), SPH_C32(0x3eda7dcf), SPH_C32(0x3d7882b1), + SPH_C32(0xbfeb7671), SPH_C32(0x81b50c00), SPH_C32(0xdc91785c), + SPH_C32(0xf03e26c6), SPH_C32(0xfb2c3698) }, + { SPH_C32(0x6f851000), SPH_C32(0x338391c2), SPH_C32(0xdd5fadcc), + SPH_C32(0x1a0ca82b), SPH_C32(0x260d0e00), SPH_C32(0xc383fc6f), + SPH_C32(0x90dbdf34), SPH_C32(0x653843ee) }, + { SPH_C32(0xc83d1200), SPH_C32(0x2c9115f1), SPH_C32(0xbdba543e), + SPH_C32(0x8418dd5d), SPH_C32(0xc82b0e00), SPH_C32(0xd1c89451), + SPH_C32(0x101909bb), SPH_C32(0x5ecbe8c2) }, + { SPH_C32(0x0e9d1400), SPH_C32(0x2c55318b), SPH_C32(0x325833a2), + SPH_C32(0xa8722fd1), SPH_C32(0x7b2e0c00), SPH_C32(0xe160279d), + SPH_C32(0x1a8e15f2), SPH_C32(0xe4a07652) }, + { SPH_C32(0xa9251600), SPH_C32(0x3347b5b8), SPH_C32(0x52bdca50), + SPH_C32(0x36665aa7), SPH_C32(0x95080c00), SPH_C32(0xf32b4fa3), + SPH_C32(0x9a4cc37d), SPH_C32(0xdf53dd7e) }, + { SPH_C32(0xe0bb1400), SPH_C32(0x3e1e59b5), SPH_C32(0xb29ae52d), + SPH_C32(0x938184fd), SPH_C32(0x32b00e00), SPH_C32(0xec39cb90), + SPH_C32(0xfaa93a8f), SPH_C32(0x4147a808) }, + { SPH_C32(0x47031600), SPH_C32(0x210cdd86), SPH_C32(0xd27f1cdf), + SPH_C32(0x0d95f18b), SPH_C32(0xdc960e00), SPH_C32(0xfe72a3ae), + SPH_C32(0x7a6bec00), SPH_C32(0x7ab40324) }, + { SPH_C32(0x4b2c1800), SPH_C32(0x26f19efd), SPH_C32(0x466ab43f), + SPH_C32(0xa33f7777), SPH_C32(0x159b0800), SPH_C32(0xb8a46797), + SPH_C32(0xca59dec0), SPH_C32(0x764b30f7) }, + { SPH_C32(0xec941a00), SPH_C32(0x39e31ace), SPH_C32(0x268f4dcd), + SPH_C32(0x3d2b0201), SPH_C32(0xfbbd0800), SPH_C32(0xaaef0fa9), + SPH_C32(0x4a9b084f), SPH_C32(0x4db89bdb) }, + { SPH_C32(0xa50a1800), SPH_C32(0x34baf6c3), SPH_C32(0xc6a862b0), + SPH_C32(0x98ccdc5b), SPH_C32(0x5c050a00), SPH_C32(0xb5fd8b9a), + SPH_C32(0x2a7ef1bd), SPH_C32(0xd3aceead) }, + { SPH_C32(0x02b21a00), SPH_C32(0x2ba872f0), SPH_C32(0xa64d9b42), + SPH_C32(0x06d8a92d), SPH_C32(0xb2230a00), SPH_C32(0xa7b6e3a4), + SPH_C32(0xaabc2732), SPH_C32(0xe85f4581) }, + { SPH_C32(0xc4121c00), SPH_C32(0x2b6c568a), SPH_C32(0x29affcde), + SPH_C32(0x2ab25ba1), SPH_C32(0x01260800), SPH_C32(0x971e5068), + SPH_C32(0xa02b3b7b), SPH_C32(0x5234db11) }, + { SPH_C32(0x63aa1e00), SPH_C32(0x347ed2b9), SPH_C32(0x494a052c), + SPH_C32(0xb4a62ed7), SPH_C32(0xef000800), SPH_C32(0x85553856), + SPH_C32(0x20e9edf4), SPH_C32(0x69c7703d) }, + { SPH_C32(0x2a341c00), SPH_C32(0x39273eb4), SPH_C32(0xa96d2a51), + SPH_C32(0x1141f08d), SPH_C32(0x48b80a00), SPH_C32(0x9a47bc65), + SPH_C32(0x400c1406), SPH_C32(0xf7d3054b) }, + { SPH_C32(0x8d8c1e00), SPH_C32(0x2635ba87), SPH_C32(0xc988d3a3), + SPH_C32(0x8f5585fb), SPH_C32(0xa69e0a00), SPH_C32(0x880cd45b), + SPH_C32(0xc0cec289), SPH_C32(0xcc20ae67) }, + { SPH_C32(0x5f911800), SPH_C32(0x094ba902), SPH_C32(0x2c185184), + SPH_C32(0x87409c91), SPH_C32(0x8e180c00), SPH_C32(0x9a83981f), + SPH_C32(0xcfee739a), SPH_C32(0xdbb9f7c7) }, + { SPH_C32(0xf8291a00), SPH_C32(0x16592d31), SPH_C32(0x4cfda876), + SPH_C32(0x1954e9e7), SPH_C32(0x603e0c00), SPH_C32(0x88c8f021), + SPH_C32(0x4f2ca515), SPH_C32(0xe04a5ceb) }, + { SPH_C32(0xb1b71800), SPH_C32(0x1b00c13c), SPH_C32(0xacda870b), + SPH_C32(0xbcb337bd), SPH_C32(0xc7860e00), SPH_C32(0x97da7412), + SPH_C32(0x2fc95ce7), SPH_C32(0x7e5e299d) }, + { SPH_C32(0x160f1a00), SPH_C32(0x0412450f), SPH_C32(0xcc3f7ef9), + SPH_C32(0x22a742cb), SPH_C32(0x29a00e00), SPH_C32(0x85911c2c), + SPH_C32(0xaf0b8a68), SPH_C32(0x45ad82b1) }, + { SPH_C32(0xd0af1c00), SPH_C32(0x04d66175), SPH_C32(0x43dd1965), + SPH_C32(0x0ecdb047), SPH_C32(0x9aa50c00), SPH_C32(0xb539afe0), + SPH_C32(0xa59c9621), SPH_C32(0xffc61c21) }, + { SPH_C32(0x77171e00), SPH_C32(0x1bc4e546), SPH_C32(0x2338e097), + SPH_C32(0x90d9c531), SPH_C32(0x74830c00), SPH_C32(0xa772c7de), + SPH_C32(0x255e40ae), SPH_C32(0xc435b70d) }, + { SPH_C32(0x3e891c00), SPH_C32(0x169d094b), SPH_C32(0xc31fcfea), + SPH_C32(0x353e1b6b), SPH_C32(0xd33b0e00), SPH_C32(0xb86043ed), + SPH_C32(0x45bbb95c), SPH_C32(0x5a21c27b) }, + { SPH_C32(0x99311e00), SPH_C32(0x098f8d78), SPH_C32(0xa3fa3618), + SPH_C32(0xab2a6e1d), SPH_C32(0x3d1d0e00), SPH_C32(0xaa2b2bd3), + SPH_C32(0xc5796fd3), SPH_C32(0x61d26957) } +}; + +static const sph_u32 T256_14[128][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), SPH_C32(0x79a90df9), + SPH_C32(0x63e92178), SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), + SPH_C32(0x806741fd), SPH_C32(0x814681b8) }, + { SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), SPH_C32(0x36656ba8), + SPH_C32(0x23633a05), SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), + SPH_C32(0x5d5ca0f7), SPH_C32(0x727784cb) }, + { SPH_C32(0x11bc0040), SPH_C32(0xf2e1216c), SPH_C32(0x4fcc6651), + SPH_C32(0x408a1b7d), SPH_C32(0x86610020), SPH_C32(0xe89072d0), + SPH_C32(0xdd3be10a), SPH_C32(0xf3310573) }, + { SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), SPH_C32(0x5d5ca0f7), + SPH_C32(0x727784cb), SPH_C32(0x35650040), SPH_C32(0x9b96b64a), + SPH_C32(0x6b39cb5f), SPH_C32(0x5114bece) }, + { SPH_C32(0x24d90000), SPH_C32(0x69779726), SPH_C32(0x24f5ad0e), + SPH_C32(0x119ea5b3), SPH_C32(0xcbaf0060), SPH_C32(0xd3cb9eae), + SPH_C32(0xeb5e8aa2), SPH_C32(0xd0523f76) }, + { SPH_C32(0x35650040), SPH_C32(0x9b96b64a), SPH_C32(0x6b39cb5f), + SPH_C32(0x5114bece), SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), + SPH_C32(0x36656ba8), SPH_C32(0x23633a05) }, + { SPH_C32(0x69170040), SPH_C32(0x522c7b58), SPH_C32(0x1290c6a6), + SPH_C32(0x32fd9fb6), SPH_C32(0xb3040060), SPH_C32(0x7306c49a), + SPH_C32(0xb6022a55), SPH_C32(0xa225bbbd) }, + { SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), SPH_C32(0xc2c46c55), + SPH_C32(0xf362b233), SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), + SPH_C32(0xd14e094b), SPH_C32(0xb772b42b) }, + { SPH_C32(0x07a00080), SPH_C32(0x8cb5d5fe), SPH_C32(0xbb6d61ac), + SPH_C32(0x908b934b), SPH_C32(0xc76c0020), SPH_C32(0x02ea7b0f), + SPH_C32(0x512948b6), SPH_C32(0x36343593) }, + { SPH_C32(0x161c00c0), SPH_C32(0x7e54f492), SPH_C32(0xf4a107fd), + SPH_C32(0xd0018836), SPH_C32(0x410d0000), SPH_C32(0xea7a09df), + SPH_C32(0x8c12a9bc), SPH_C32(0xc50530e0) }, + { SPH_C32(0x4a6e00c0), SPH_C32(0xb7ee3980), SPH_C32(0x8d080a04), + SPH_C32(0xb3e8a94e), SPH_C32(0xbfc70020), SPH_C32(0xa227213b), + SPH_C32(0x0c75e841), SPH_C32(0x4443b158) }, + { SPH_C32(0x23790080), SPH_C32(0xe5c242d8), SPH_C32(0x9f98cca2), + SPH_C32(0x811536f8), SPH_C32(0x0cc30040), SPH_C32(0xd121e5a1), + SPH_C32(0xba77c214), SPH_C32(0xe6660ae5) }, + { SPH_C32(0x7f0b0080), SPH_C32(0x2c788fca), SPH_C32(0xe631c15b), + SPH_C32(0xe2fc1780), SPH_C32(0xf2090060), SPH_C32(0x997ccd45), + SPH_C32(0x3a1083e9), SPH_C32(0x67208b5d) }, + { SPH_C32(0x6eb700c0), SPH_C32(0xde99aea6), SPH_C32(0xa9fda70a), + SPH_C32(0xa2760cfd), SPH_C32(0x74680040), SPH_C32(0x71ecbf95), + SPH_C32(0xe72b62e3), SPH_C32(0x94118e2e) }, + { SPH_C32(0x32c500c0), SPH_C32(0x172363b4), SPH_C32(0xd054aaf3), + SPH_C32(0xc19f2d85), SPH_C32(0x8aa20060), SPH_C32(0x39b19771), + SPH_C32(0x674c231e), SPH_C32(0x15570f96) }, + { SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), SPH_C32(0xd14e094b), + SPH_C32(0xb772b42b), SPH_C32(0x62740080), SPH_C32(0x0fb84b07), + SPH_C32(0x138a651e), SPH_C32(0x44100618) }, + { SPH_C32(0x65d40000), SPH_C32(0x830d9ef9), SPH_C32(0xa8e704b2), + SPH_C32(0xd49b9553), SPH_C32(0x9cbe00a0), SPH_C32(0x47e563e3), + SPH_C32(0x93ed24e3), SPH_C32(0xc55687a0) }, + { SPH_C32(0x74680040), SPH_C32(0x71ecbf95), SPH_C32(0xe72b62e3), + SPH_C32(0x94118e2e), SPH_C32(0x1adf0080), SPH_C32(0xaf751133), + SPH_C32(0x4ed6c5e9), SPH_C32(0x366782d3) }, + { SPH_C32(0x281a0040), SPH_C32(0xb8567287), SPH_C32(0x9e826f1a), + SPH_C32(0xf7f8af56), SPH_C32(0xe41500a0), SPH_C32(0xe72839d7), + SPH_C32(0xceb18414), SPH_C32(0xb721036b) }, + { SPH_C32(0x410d0000), SPH_C32(0xea7a09df), SPH_C32(0x8c12a9bc), + SPH_C32(0xc50530e0), SPH_C32(0x571100c0), SPH_C32(0x942efd4d), + SPH_C32(0x78b3ae41), SPH_C32(0x1504b8d6) }, + { SPH_C32(0x1d7f0000), SPH_C32(0x23c0c4cd), SPH_C32(0xf5bba445), + SPH_C32(0xa6ec1198), SPH_C32(0xa9db00e0), SPH_C32(0xdc73d5a9), + SPH_C32(0xf8d4efbc), SPH_C32(0x9442396e) }, + { SPH_C32(0x0cc30040), SPH_C32(0xd121e5a1), SPH_C32(0xba77c214), + SPH_C32(0xe6660ae5), SPH_C32(0x2fba00c0), SPH_C32(0x34e3a779), + SPH_C32(0x25ef0eb6), SPH_C32(0x67733c1d) }, + { SPH_C32(0x50b10040), SPH_C32(0x189b28b3), SPH_C32(0xc3decfed), + SPH_C32(0x858f2b9d), SPH_C32(0xd17000e0), SPH_C32(0x7cbe8f9d), + SPH_C32(0xa5884f4b), SPH_C32(0xe635bda5) }, + { SPH_C32(0x62740080), SPH_C32(0x0fb84b07), SPH_C32(0x138a651e), + SPH_C32(0x44100618), SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), + SPH_C32(0xc2c46c55), SPH_C32(0xf362b233) }, + { SPH_C32(0x3e060080), SPH_C32(0xc6028615), SPH_C32(0x6a2368e7), + SPH_C32(0x27f92760), SPH_C32(0xa51800a0), SPH_C32(0x0d523008), + SPH_C32(0x42a32da8), SPH_C32(0x7224338b) }, + { SPH_C32(0x2fba00c0), SPH_C32(0x34e3a779), SPH_C32(0x25ef0eb6), + SPH_C32(0x67733c1d), SPH_C32(0x23790080), SPH_C32(0xe5c242d8), + SPH_C32(0x9f98cca2), SPH_C32(0x811536f8) }, + { SPH_C32(0x73c800c0), SPH_C32(0xfd596a6b), SPH_C32(0x5c46034f), + SPH_C32(0x049a1d65), SPH_C32(0xddb300a0), SPH_C32(0xad9f6a3c), + SPH_C32(0x1fff8d5f), SPH_C32(0x0053b740) }, + { SPH_C32(0x1adf0080), SPH_C32(0xaf751133), SPH_C32(0x4ed6c5e9), + SPH_C32(0x366782d3), SPH_C32(0x6eb700c0), SPH_C32(0xde99aea6), + SPH_C32(0xa9fda70a), SPH_C32(0xa2760cfd) }, + { SPH_C32(0x46ad0080), SPH_C32(0x66cfdc21), SPH_C32(0x377fc810), + SPH_C32(0x558ea3ab), SPH_C32(0x907d00e0), SPH_C32(0x96c48642), + SPH_C32(0x299ae6f7), SPH_C32(0x23308d45) }, + { SPH_C32(0x571100c0), SPH_C32(0x942efd4d), SPH_C32(0x78b3ae41), + SPH_C32(0x1504b8d6), SPH_C32(0x161c00c0), SPH_C32(0x7e54f492), + SPH_C32(0xf4a107fd), SPH_C32(0xd0018836) }, + { SPH_C32(0x0b6300c0), SPH_C32(0x5d94305f), SPH_C32(0x011aa3b8), + SPH_C32(0x76ed99ae), SPH_C32(0xe8d600e0), SPH_C32(0x3609dc76), + SPH_C32(0x74c64600), SPH_C32(0x5147098e) }, + { SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), SPH_C32(0x8589d8ab), + SPH_C32(0xe6c46464), SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), + SPH_C32(0xa29d1297), SPH_C32(0x6ee56854) }, + { SPH_C32(0xebd60100), SPH_C32(0x43a5fcca), SPH_C32(0xfc20d552), + SPH_C32(0x852d451c), SPH_C32(0x8d860020), SPH_C32(0xdd328f32), + SPH_C32(0x22fa536a), SPH_C32(0xefa3e9ec) }, + { SPH_C32(0xfa6a0140), SPH_C32(0xb144dda6), SPH_C32(0xb3ecb303), + SPH_C32(0xc5a75e61), SPH_C32(0x0be70000), SPH_C32(0x35a2fde2), + SPH_C32(0xffc1b260), SPH_C32(0x1c92ec9f) }, + { SPH_C32(0xa6180140), SPH_C32(0x78fe10b4), SPH_C32(0xca45befa), + SPH_C32(0xa64e7f19), SPH_C32(0xf52d0020), SPH_C32(0x7dffd506), + SPH_C32(0x7fa6f39d), SPH_C32(0x9dd46d27) }, + { SPH_C32(0xcf0f0100), SPH_C32(0x2ad26bec), SPH_C32(0xd8d5785c), + SPH_C32(0x94b3e0af), SPH_C32(0x46290040), SPH_C32(0x0ef9119c), + SPH_C32(0xc9a4d9c8), SPH_C32(0x3ff1d69a) }, + { SPH_C32(0x937d0100), SPH_C32(0xe368a6fe), SPH_C32(0xa17c75a5), + SPH_C32(0xf75ac1d7), SPH_C32(0xb8e30060), SPH_C32(0x46a43978), + SPH_C32(0x49c39835), SPH_C32(0xbeb75722) }, + { SPH_C32(0x82c10140), SPH_C32(0x11898792), SPH_C32(0xeeb013f4), + SPH_C32(0xb7d0daaa), SPH_C32(0x3e820040), SPH_C32(0xae344ba8), + SPH_C32(0x94f8793f), SPH_C32(0x4d865251) }, + { SPH_C32(0xdeb30140), SPH_C32(0xd8334a80), SPH_C32(0x97191e0d), + SPH_C32(0xd439fbd2), SPH_C32(0xc0480060), SPH_C32(0xe669634c), + SPH_C32(0x149f38c2), SPH_C32(0xccc0d3e9) }, + { SPH_C32(0xec760180), SPH_C32(0xcf102934), SPH_C32(0x474db4fe), + SPH_C32(0x15a6d657), SPH_C32(0x4aea0000), SPH_C32(0xdfd8f43d), + SPH_C32(0x73d31bdc), SPH_C32(0xd997dc7f) }, + { SPH_C32(0xb0040180), SPH_C32(0x06aae426), SPH_C32(0x3ee4b907), + SPH_C32(0x764ff72f), SPH_C32(0xb4200020), SPH_C32(0x9785dcd9), + SPH_C32(0xf3b45a21), SPH_C32(0x58d15dc7) }, + { SPH_C32(0xa1b801c0), SPH_C32(0xf44bc54a), SPH_C32(0x7128df56), + SPH_C32(0x36c5ec52), SPH_C32(0x32410000), SPH_C32(0x7f15ae09), + SPH_C32(0x2e8fbb2b), SPH_C32(0xabe058b4) }, + { SPH_C32(0xfdca01c0), SPH_C32(0x3df10858), SPH_C32(0x0881d2af), + SPH_C32(0x552ccd2a), SPH_C32(0xcc8b0020), SPH_C32(0x374886ed), + SPH_C32(0xaee8fad6), SPH_C32(0x2aa6d90c) }, + { SPH_C32(0x94dd0180), SPH_C32(0x6fdd7300), SPH_C32(0x1a111409), + SPH_C32(0x67d1529c), SPH_C32(0x7f8f0040), SPH_C32(0x444e4277), + SPH_C32(0x18ead083), SPH_C32(0x888362b1) }, + { SPH_C32(0xc8af0180), SPH_C32(0xa667be12), SPH_C32(0x63b819f0), + SPH_C32(0x043873e4), SPH_C32(0x81450060), SPH_C32(0x0c136a93), + SPH_C32(0x988d917e), SPH_C32(0x09c5e309) }, + { SPH_C32(0xd91301c0), SPH_C32(0x54869f7e), SPH_C32(0x2c747fa1), + SPH_C32(0x44b26899), SPH_C32(0x07240040), SPH_C32(0xe4831843), + SPH_C32(0x45b67074), SPH_C32(0xfaf4e67a) }, + { SPH_C32(0x856101c0), SPH_C32(0x9d3c526c), SPH_C32(0x55dd7258), + SPH_C32(0x275b49e1), SPH_C32(0xf9ee0060), SPH_C32(0xacde30a7), + SPH_C32(0xc5d13189), SPH_C32(0x7bb267c2) }, + { SPH_C32(0x8e020100), SPH_C32(0xc0a86233), SPH_C32(0x54c7d1e0), + SPH_C32(0x51b6d04f), SPH_C32(0x11380080), SPH_C32(0x9ad7ecd1), + SPH_C32(0xb1177789), SPH_C32(0x2af56e4c) }, + { SPH_C32(0xd2700100), SPH_C32(0x0912af21), SPH_C32(0x2d6edc19), + SPH_C32(0x325ff137), SPH_C32(0xeff200a0), SPH_C32(0xd28ac435), + SPH_C32(0x31703674), SPH_C32(0xabb3eff4) }, + { SPH_C32(0xc3cc0140), SPH_C32(0xfbf38e4d), SPH_C32(0x62a2ba48), + SPH_C32(0x72d5ea4a), SPH_C32(0x69930080), SPH_C32(0x3a1ab6e5), + SPH_C32(0xec4bd77e), SPH_C32(0x5882ea87) }, + { SPH_C32(0x9fbe0140), SPH_C32(0x3249435f), SPH_C32(0x1b0bb7b1), + SPH_C32(0x113ccb32), SPH_C32(0x975900a0), SPH_C32(0x72479e01), + SPH_C32(0x6c2c9683), SPH_C32(0xd9c46b3f) }, + { SPH_C32(0xf6a90100), SPH_C32(0x60653807), SPH_C32(0x099b7117), + SPH_C32(0x23c15484), SPH_C32(0x245d00c0), SPH_C32(0x01415a9b), + SPH_C32(0xda2ebcd6), SPH_C32(0x7be1d082) }, + { SPH_C32(0xaadb0100), SPH_C32(0xa9dff515), SPH_C32(0x70327cee), + SPH_C32(0x402875fc), SPH_C32(0xda9700e0), SPH_C32(0x491c727f), + SPH_C32(0x5a49fd2b), SPH_C32(0xfaa7513a) }, + { SPH_C32(0xbb670140), SPH_C32(0x5b3ed479), SPH_C32(0x3ffe1abf), + SPH_C32(0x00a26e81), SPH_C32(0x5cf600c0), SPH_C32(0xa18c00af), + SPH_C32(0x87721c21), SPH_C32(0x09965449) }, + { SPH_C32(0xe7150140), SPH_C32(0x9284196b), SPH_C32(0x46571746), + SPH_C32(0x634b4ff9), SPH_C32(0xa23c00e0), SPH_C32(0xe9d1284b), + SPH_C32(0x07155ddc), SPH_C32(0x88d0d5f1) }, + { SPH_C32(0xd5d00180), SPH_C32(0x85a77adf), SPH_C32(0x9603bdb5), + SPH_C32(0xa2d4627c), SPH_C32(0x289e0080), SPH_C32(0xd060bf3a), + SPH_C32(0x60597ec2), SPH_C32(0x9d87da67) }, + { SPH_C32(0x89a20180), SPH_C32(0x4c1db7cd), SPH_C32(0xefaab04c), + SPH_C32(0xc13d4304), SPH_C32(0xd65400a0), SPH_C32(0x983d97de), + SPH_C32(0xe03e3f3f), SPH_C32(0x1cc15bdf) }, + { SPH_C32(0x981e01c0), SPH_C32(0xbefc96a1), SPH_C32(0xa066d61d), + SPH_C32(0x81b75879), SPH_C32(0x50350080), SPH_C32(0x70ade50e), + SPH_C32(0x3d05de35), SPH_C32(0xeff05eac) }, + { SPH_C32(0xc46c01c0), SPH_C32(0x77465bb3), SPH_C32(0xd9cfdbe4), + SPH_C32(0xe25e7901), SPH_C32(0xaeff00a0), SPH_C32(0x38f0cdea), + SPH_C32(0xbd629fc8), SPH_C32(0x6eb6df14) }, + { SPH_C32(0xad7b0180), SPH_C32(0x256a20eb), SPH_C32(0xcb5f1d42), + SPH_C32(0xd0a3e6b7), SPH_C32(0x1dfb00c0), SPH_C32(0x4bf60970), + SPH_C32(0x0b60b59d), SPH_C32(0xcc9364a9) }, + { SPH_C32(0xf1090180), SPH_C32(0xecd0edf9), SPH_C32(0xb2f610bb), + SPH_C32(0xb34ac7cf), SPH_C32(0xe33100e0), SPH_C32(0x03ab2194), + SPH_C32(0x8b07f460), SPH_C32(0x4dd5e511) }, + { SPH_C32(0xe0b501c0), SPH_C32(0x1e31cc95), SPH_C32(0xfd3a76ea), + SPH_C32(0xf3c0dcb2), SPH_C32(0x655000c0), SPH_C32(0xeb3b5344), + SPH_C32(0x563c156a), SPH_C32(0xbee4e062) }, + { SPH_C32(0xbcc701c0), SPH_C32(0xd78b0187), SPH_C32(0x84937b13), + SPH_C32(0x9029fdca), SPH_C32(0x9b9a00e0), SPH_C32(0xa3667ba0), + SPH_C32(0xd65b5497), SPH_C32(0x3fa261da) }, + { SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), SPH_C32(0xa29d1297), + SPH_C32(0x6ee56854), SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), + SPH_C32(0x2714ca3c), SPH_C32(0x88210c30) }, + { SPH_C32(0x2f3e0000), SPH_C32(0x5cd56ac4), SPH_C32(0xdb341f6e), + SPH_C32(0x0d0c492c), SPH_C32(0x3a220120), SPH_C32(0x572dbeea), + SPH_C32(0xa7738bc1), SPH_C32(0x09678d88) }, + { SPH_C32(0x3e820040), SPH_C32(0xae344ba8), SPH_C32(0x94f8793f), + SPH_C32(0x4d865251), SPH_C32(0xbc430100), SPH_C32(0xbfbdcc3a), + SPH_C32(0x7a486acb), SPH_C32(0xfa5688fb) }, + { SPH_C32(0x62f00040), SPH_C32(0x678e86ba), SPH_C32(0xed5174c6), + SPH_C32(0x2e6f7329), SPH_C32(0x42890120), SPH_C32(0xf7e0e4de), + SPH_C32(0xfa2f2b36), SPH_C32(0x7b100943) }, + { SPH_C32(0x0be70000), SPH_C32(0x35a2fde2), SPH_C32(0xffc1b260), + SPH_C32(0x1c92ec9f), SPH_C32(0xf18d0140), SPH_C32(0x84e62044), + SPH_C32(0x4c2d0163), SPH_C32(0xd935b2fe) }, + { SPH_C32(0x57950000), SPH_C32(0xfc1830f0), SPH_C32(0x8668bf99), + SPH_C32(0x7f7bcde7), SPH_C32(0x0f470160), SPH_C32(0xccbb08a0), + SPH_C32(0xcc4a409e), SPH_C32(0x58733346) }, + { SPH_C32(0x46290040), SPH_C32(0x0ef9119c), SPH_C32(0xc9a4d9c8), + SPH_C32(0x3ff1d69a), SPH_C32(0x89260140), SPH_C32(0x242b7a70), + SPH_C32(0x1171a194), SPH_C32(0xab423635) }, + { SPH_C32(0x1a5b0040), SPH_C32(0xc743dc8e), SPH_C32(0xb00dd431), + SPH_C32(0x5c18f7e2), SPH_C32(0x77ec0160), SPH_C32(0x6c765294), + SPH_C32(0x9116e069), SPH_C32(0x2a04b78d) }, + { SPH_C32(0x289e0080), SPH_C32(0xd060bf3a), SPH_C32(0x60597ec2), + SPH_C32(0x9d87da67), SPH_C32(0xfd4e0100), SPH_C32(0x55c7c5e5), + SPH_C32(0xf65ac377), SPH_C32(0x3f53b81b) }, + { SPH_C32(0x74ec0080), SPH_C32(0x19da7228), SPH_C32(0x19f0733b), + SPH_C32(0xfe6efb1f), SPH_C32(0x03840120), SPH_C32(0x1d9aed01), + SPH_C32(0x763d828a), SPH_C32(0xbe1539a3) }, + { SPH_C32(0x655000c0), SPH_C32(0xeb3b5344), SPH_C32(0x563c156a), + SPH_C32(0xbee4e062), SPH_C32(0x85e50100), SPH_C32(0xf50a9fd1), + SPH_C32(0xab066380), SPH_C32(0x4d243cd0) }, + { SPH_C32(0x392200c0), SPH_C32(0x22819e56), SPH_C32(0x2f951893), + SPH_C32(0xdd0dc11a), SPH_C32(0x7b2f0120), SPH_C32(0xbd57b735), + SPH_C32(0x2b61227d), SPH_C32(0xcc62bd68) }, + { SPH_C32(0x50350080), SPH_C32(0x70ade50e), SPH_C32(0x3d05de35), + SPH_C32(0xeff05eac), SPH_C32(0xc82b0140), SPH_C32(0xce5173af), + SPH_C32(0x9d630828), SPH_C32(0x6e4706d5) }, + { SPH_C32(0x0c470080), SPH_C32(0xb917281c), SPH_C32(0x44acd3cc), + SPH_C32(0x8c197fd4), SPH_C32(0x36e10160), SPH_C32(0x860c5b4b), + SPH_C32(0x1d0449d5), SPH_C32(0xef01876d) }, + { SPH_C32(0x1dfb00c0), SPH_C32(0x4bf60970), SPH_C32(0x0b60b59d), + SPH_C32(0xcc9364a9), SPH_C32(0xb0800140), SPH_C32(0x6e9c299b), + SPH_C32(0xc03fa8df), SPH_C32(0x1c30821e) }, + { SPH_C32(0x418900c0), SPH_C32(0x824cc462), SPH_C32(0x72c9b864), + SPH_C32(0xaf7a45d1), SPH_C32(0x4e4a0160), SPH_C32(0x26c1017f), + SPH_C32(0x4058e922), SPH_C32(0x9d7603a6) }, + { SPH_C32(0x4aea0000), SPH_C32(0xdfd8f43d), SPH_C32(0x73d31bdc), + SPH_C32(0xd997dc7f), SPH_C32(0xa69c0180), SPH_C32(0x10c8dd09), + SPH_C32(0x349eaf22), SPH_C32(0xcc310a28) }, + { SPH_C32(0x16980000), SPH_C32(0x1662392f), SPH_C32(0x0a7a1625), + SPH_C32(0xba7efd07), SPH_C32(0x585601a0), SPH_C32(0x5895f5ed), + SPH_C32(0xb4f9eedf), SPH_C32(0x4d778b90) }, + { SPH_C32(0x07240040), SPH_C32(0xe4831843), SPH_C32(0x45b67074), + SPH_C32(0xfaf4e67a), SPH_C32(0xde370180), SPH_C32(0xb005873d), + SPH_C32(0x69c20fd5), SPH_C32(0xbe468ee3) }, + { SPH_C32(0x5b560040), SPH_C32(0x2d39d551), SPH_C32(0x3c1f7d8d), + SPH_C32(0x991dc702), SPH_C32(0x20fd01a0), SPH_C32(0xf858afd9), + SPH_C32(0xe9a54e28), SPH_C32(0x3f000f5b) }, + { SPH_C32(0x32410000), SPH_C32(0x7f15ae09), SPH_C32(0x2e8fbb2b), + SPH_C32(0xabe058b4), SPH_C32(0x93f901c0), SPH_C32(0x8b5e6b43), + SPH_C32(0x5fa7647d), SPH_C32(0x9d25b4e6) }, + { SPH_C32(0x6e330000), SPH_C32(0xb6af631b), SPH_C32(0x5726b6d2), + SPH_C32(0xc80979cc), SPH_C32(0x6d3301e0), SPH_C32(0xc30343a7), + SPH_C32(0xdfc02580), SPH_C32(0x1c63355e) }, + { SPH_C32(0x7f8f0040), SPH_C32(0x444e4277), SPH_C32(0x18ead083), + SPH_C32(0x888362b1), SPH_C32(0xeb5201c0), SPH_C32(0x2b933177), + SPH_C32(0x02fbc48a), SPH_C32(0xef52302d) }, + { SPH_C32(0x23fd0040), SPH_C32(0x8df48f65), SPH_C32(0x6143dd7a), + SPH_C32(0xeb6a43c9), SPH_C32(0x159801e0), SPH_C32(0x63ce1993), + SPH_C32(0x829c8577), SPH_C32(0x6e14b195) }, + { SPH_C32(0x11380080), SPH_C32(0x9ad7ecd1), SPH_C32(0xb1177789), + SPH_C32(0x2af56e4c), SPH_C32(0x9f3a0180), SPH_C32(0x5a7f8ee2), + SPH_C32(0xe5d0a669), SPH_C32(0x7b43be03) }, + { SPH_C32(0x4d4a0080), SPH_C32(0x536d21c3), SPH_C32(0xc8be7a70), + SPH_C32(0x491c4f34), SPH_C32(0x61f001a0), SPH_C32(0x1222a606), + SPH_C32(0x65b7e794), SPH_C32(0xfa053fbb) }, + { SPH_C32(0x5cf600c0), SPH_C32(0xa18c00af), SPH_C32(0x87721c21), + SPH_C32(0x09965449), SPH_C32(0xe7910180), SPH_C32(0xfab2d4d6), + SPH_C32(0xb88c069e), SPH_C32(0x09343ac8) }, + { SPH_C32(0x008400c0), SPH_C32(0x6836cdbd), SPH_C32(0xfedb11d8), + SPH_C32(0x6a7f7531), SPH_C32(0x195b01a0), SPH_C32(0xb2effc32), + SPH_C32(0x38eb4763), SPH_C32(0x8872bb70) }, + { SPH_C32(0x69930080), SPH_C32(0x3a1ab6e5), SPH_C32(0xec4bd77e), + SPH_C32(0x5882ea87), SPH_C32(0xaa5f01c0), SPH_C32(0xc1e938a8), + SPH_C32(0x8ee96d36), SPH_C32(0x2a5700cd) }, + { SPH_C32(0x35e10080), SPH_C32(0xf3a07bf7), SPH_C32(0x95e2da87), + SPH_C32(0x3b6bcbff), SPH_C32(0x549501e0), SPH_C32(0x89b4104c), + SPH_C32(0x0e8e2ccb), SPH_C32(0xab118175) }, + { SPH_C32(0x245d00c0), SPH_C32(0x01415a9b), SPH_C32(0xda2ebcd6), + SPH_C32(0x7be1d082), SPH_C32(0xd2f401c0), SPH_C32(0x6124629c), + SPH_C32(0xd3b5cdc1), SPH_C32(0x58208406) }, + { SPH_C32(0x782f00c0), SPH_C32(0xc8fb9789), SPH_C32(0xa387b12f), + SPH_C32(0x1808f1fa), SPH_C32(0x2c3e01e0), SPH_C32(0x29794a78), + SPH_C32(0x53d28c3c), SPH_C32(0xd96605be) }, + { SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), SPH_C32(0x2714ca3c), + SPH_C32(0x88210c30), SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), + SPH_C32(0x8589d8ab), SPH_C32(0xe6c46464) }, + { SPH_C32(0x989a0100), SPH_C32(0xd6ca5b1c), SPH_C32(0x5ebdc7c5), + SPH_C32(0xebc82d48), SPH_C32(0x496e0120), SPH_C32(0xc242193c), + SPH_C32(0x05ee9956), SPH_C32(0x6782e5dc) }, + { SPH_C32(0x89260140), SPH_C32(0x242b7a70), SPH_C32(0x1171a194), + SPH_C32(0xab423635), SPH_C32(0xcf0f0100), SPH_C32(0x2ad26bec), + SPH_C32(0xd8d5785c), SPH_C32(0x94b3e0af) }, + { SPH_C32(0xd5540140), SPH_C32(0xed91b762), SPH_C32(0x68d8ac6d), + SPH_C32(0xc8ab174d), SPH_C32(0x31c50120), SPH_C32(0x628f4308), + SPH_C32(0x58b239a1), SPH_C32(0x15f56117) }, + { SPH_C32(0xbc430100), SPH_C32(0xbfbdcc3a), SPH_C32(0x7a486acb), + SPH_C32(0xfa5688fb), SPH_C32(0x82c10140), SPH_C32(0x11898792), + SPH_C32(0xeeb013f4), SPH_C32(0xb7d0daaa) }, + { SPH_C32(0xe0310100), SPH_C32(0x76070128), SPH_C32(0x03e16732), + SPH_C32(0x99bfa983), SPH_C32(0x7c0b0160), SPH_C32(0x59d4af76), + SPH_C32(0x6ed75209), SPH_C32(0x36965b12) }, + { SPH_C32(0xf18d0140), SPH_C32(0x84e62044), SPH_C32(0x4c2d0163), + SPH_C32(0xd935b2fe), SPH_C32(0xfa6a0140), SPH_C32(0xb144dda6), + SPH_C32(0xb3ecb303), SPH_C32(0xc5a75e61) }, + { SPH_C32(0xadff0140), SPH_C32(0x4d5ced56), SPH_C32(0x35840c9a), + SPH_C32(0xbadc9386), SPH_C32(0x04a00160), SPH_C32(0xf919f542), + SPH_C32(0x338bf2fe), SPH_C32(0x44e1dfd9) }, + { SPH_C32(0x9f3a0180), SPH_C32(0x5a7f8ee2), SPH_C32(0xe5d0a669), + SPH_C32(0x7b43be03), SPH_C32(0x8e020100), SPH_C32(0xc0a86233), + SPH_C32(0x54c7d1e0), SPH_C32(0x51b6d04f) }, + { SPH_C32(0xc3480180), SPH_C32(0x93c543f0), SPH_C32(0x9c79ab90), + SPH_C32(0x18aa9f7b), SPH_C32(0x70c80120), SPH_C32(0x88f54ad7), + SPH_C32(0xd4a0901d), SPH_C32(0xd0f051f7) }, + { SPH_C32(0xd2f401c0), SPH_C32(0x6124629c), SPH_C32(0xd3b5cdc1), + SPH_C32(0x58208406), SPH_C32(0xf6a90100), SPH_C32(0x60653807), + SPH_C32(0x099b7117), SPH_C32(0x23c15484) }, + { SPH_C32(0x8e8601c0), SPH_C32(0xa89eaf8e), SPH_C32(0xaa1cc038), + SPH_C32(0x3bc9a57e), SPH_C32(0x08630120), SPH_C32(0x283810e3), + SPH_C32(0x89fc30ea), SPH_C32(0xa287d53c) }, + { SPH_C32(0xe7910180), SPH_C32(0xfab2d4d6), SPH_C32(0xb88c069e), + SPH_C32(0x09343ac8), SPH_C32(0xbb670140), SPH_C32(0x5b3ed479), + SPH_C32(0x3ffe1abf), SPH_C32(0x00a26e81) }, + { SPH_C32(0xbbe30180), SPH_C32(0x330819c4), SPH_C32(0xc1250b67), + SPH_C32(0x6add1bb0), SPH_C32(0x45ad0160), SPH_C32(0x1363fc9d), + SPH_C32(0xbf995b42), SPH_C32(0x81e4ef39) }, + { SPH_C32(0xaa5f01c0), SPH_C32(0xc1e938a8), SPH_C32(0x8ee96d36), + SPH_C32(0x2a5700cd), SPH_C32(0xc3cc0140), SPH_C32(0xfbf38e4d), + SPH_C32(0x62a2ba48), SPH_C32(0x72d5ea4a) }, + { SPH_C32(0xf62d01c0), SPH_C32(0x0853f5ba), SPH_C32(0xf74060cf), + SPH_C32(0x49be21b5), SPH_C32(0x3d060160), SPH_C32(0xb3aea6a9), + SPH_C32(0xe2c5fbb5), SPH_C32(0xf3936bf2) }, + { SPH_C32(0xfd4e0100), SPH_C32(0x55c7c5e5), SPH_C32(0xf65ac377), + SPH_C32(0x3f53b81b), SPH_C32(0xd5d00180), SPH_C32(0x85a77adf), + SPH_C32(0x9603bdb5), SPH_C32(0xa2d4627c) }, + { SPH_C32(0xa13c0100), SPH_C32(0x9c7d08f7), SPH_C32(0x8ff3ce8e), + SPH_C32(0x5cba9963), SPH_C32(0x2b1a01a0), SPH_C32(0xcdfa523b), + SPH_C32(0x1664fc48), SPH_C32(0x2392e3c4) }, + { SPH_C32(0xb0800140), SPH_C32(0x6e9c299b), SPH_C32(0xc03fa8df), + SPH_C32(0x1c30821e), SPH_C32(0xad7b0180), SPH_C32(0x256a20eb), + SPH_C32(0xcb5f1d42), SPH_C32(0xd0a3e6b7) }, + { SPH_C32(0xecf20140), SPH_C32(0xa726e489), SPH_C32(0xb996a526), + SPH_C32(0x7fd9a366), SPH_C32(0x53b101a0), SPH_C32(0x6d37080f), + SPH_C32(0x4b385cbf), SPH_C32(0x51e5670f) }, + { SPH_C32(0x85e50100), SPH_C32(0xf50a9fd1), SPH_C32(0xab066380), + SPH_C32(0x4d243cd0), SPH_C32(0xe0b501c0), SPH_C32(0x1e31cc95), + SPH_C32(0xfd3a76ea), SPH_C32(0xf3c0dcb2) }, + { SPH_C32(0xd9970100), SPH_C32(0x3cb052c3), SPH_C32(0xd2af6e79), + SPH_C32(0x2ecd1da8), SPH_C32(0x1e7f01e0), SPH_C32(0x566ce471), + SPH_C32(0x7d5d3717), SPH_C32(0x72865d0a) }, + { SPH_C32(0xc82b0140), SPH_C32(0xce5173af), SPH_C32(0x9d630828), + SPH_C32(0x6e4706d5), SPH_C32(0x981e01c0), SPH_C32(0xbefc96a1), + SPH_C32(0xa066d61d), SPH_C32(0x81b75879) }, + { SPH_C32(0x94590140), SPH_C32(0x07ebbebd), SPH_C32(0xe4ca05d1), + SPH_C32(0x0dae27ad), SPH_C32(0x66d401e0), SPH_C32(0xf6a1be45), + SPH_C32(0x200197e0), SPH_C32(0x00f1d9c1) }, + { SPH_C32(0xa69c0180), SPH_C32(0x10c8dd09), SPH_C32(0x349eaf22), + SPH_C32(0xcc310a28), SPH_C32(0xec760180), SPH_C32(0xcf102934), + SPH_C32(0x474db4fe), SPH_C32(0x15a6d657) }, + { SPH_C32(0xfaee0180), SPH_C32(0xd972101b), SPH_C32(0x4d37a2db), + SPH_C32(0xafd82b50), SPH_C32(0x12bc01a0), SPH_C32(0x874d01d0), + SPH_C32(0xc72af503), SPH_C32(0x94e057ef) }, + { SPH_C32(0xeb5201c0), SPH_C32(0x2b933177), SPH_C32(0x02fbc48a), + SPH_C32(0xef52302d), SPH_C32(0x94dd0180), SPH_C32(0x6fdd7300), + SPH_C32(0x1a111409), SPH_C32(0x67d1529c) }, + { SPH_C32(0xb72001c0), SPH_C32(0xe229fc65), SPH_C32(0x7b52c973), + SPH_C32(0x8cbb1155), SPH_C32(0x6a1701a0), SPH_C32(0x27805be4), + SPH_C32(0x9a7655f4), SPH_C32(0xe697d324) }, + { SPH_C32(0xde370180), SPH_C32(0xb005873d), SPH_C32(0x69c20fd5), + SPH_C32(0xbe468ee3), SPH_C32(0xd91301c0), SPH_C32(0x54869f7e), + SPH_C32(0x2c747fa1), SPH_C32(0x44b26899) }, + { SPH_C32(0x82450180), SPH_C32(0x79bf4a2f), SPH_C32(0x106b022c), + SPH_C32(0xddafaf9b), SPH_C32(0x27d901e0), SPH_C32(0x1cdbb79a), + SPH_C32(0xac133e5c), SPH_C32(0xc5f4e921) }, + { SPH_C32(0x93f901c0), SPH_C32(0x8b5e6b43), SPH_C32(0x5fa7647d), + SPH_C32(0x9d25b4e6), SPH_C32(0xa1b801c0), SPH_C32(0xf44bc54a), + SPH_C32(0x7128df56), SPH_C32(0x36c5ec52) }, + { SPH_C32(0xcf8b01c0), SPH_C32(0x42e4a651), SPH_C32(0x260e6984), + SPH_C32(0xfecc959e), SPH_C32(0x5f7201e0), SPH_C32(0xbc16edae), + SPH_C32(0xf14f9eab), SPH_C32(0xb7836dea) } +}; + +static const sph_u32 T256_21[128][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xd0080004), SPH_C32(0x8c768f77), SPH_C32(0x9dc5b050), + SPH_C32(0xaf4a29da), SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), + SPH_C32(0x98321c3d), SPH_C32(0x76acc733) }, + { SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), SPH_C32(0x98321c3d), + SPH_C32(0x76acc733), SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), + SPH_C32(0x05f7ac6d), SPH_C32(0xd9e6eee9) }, + { SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), SPH_C32(0x05f7ac6d), + SPH_C32(0xd9e6eee9), SPH_C32(0xd0080004), SPH_C32(0x8c768f77), + SPH_C32(0x9dc5b050), SPH_C32(0xaf4a29da) }, + { SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), SPH_C32(0xfe739301), + SPH_C32(0xb8a92831), SPH_C32(0x171c0000), SPH_C32(0xb26e3344), + SPH_C32(0x9e6a837e), SPH_C32(0x58f8485f) }, + { SPH_C32(0x78a6000c), SPH_C32(0xac0fb60a), SPH_C32(0x63b62351), + SPH_C32(0x17e301eb), SPH_C32(0x7cb50000), SPH_C32(0xf285caee), + SPH_C32(0x06589f43), SPH_C32(0x2e548f6c) }, + { SPH_C32(0xc3070008), SPH_C32(0x6092c0d7), SPH_C32(0x66418f3c), + SPH_C32(0xce05ef02), SPH_C32(0xacbd0004), SPH_C32(0x7ef34599), + SPH_C32(0x9b9d2f13), SPH_C32(0x811ea6b6) }, + { SPH_C32(0x130f000c), SPH_C32(0xece44fa0), SPH_C32(0xfb843f6c), + SPH_C32(0x614fc6d8), SPH_C32(0xc7140004), SPH_C32(0x3e18bc33), + SPH_C32(0x03af332e), SPH_C32(0xf7b26185) }, + { SPH_C32(0x171c0000), SPH_C32(0xb26e3344), SPH_C32(0x9e6a837e), + SPH_C32(0x58f8485f), SPH_C32(0xbfb20008), SPH_C32(0x92170a39), + SPH_C32(0x6019107f), SPH_C32(0xe051606e) }, + { SPH_C32(0xc7140004), SPH_C32(0x3e18bc33), SPH_C32(0x03af332e), + SPH_C32(0xf7b26185), SPH_C32(0xd41b0008), SPH_C32(0xd2fcf393), + SPH_C32(0xf82b0c42), SPH_C32(0x96fda75d) }, + { SPH_C32(0x7cb50000), SPH_C32(0xf285caee), SPH_C32(0x06589f43), + SPH_C32(0x2e548f6c), SPH_C32(0x0413000c), SPH_C32(0x5e8a7ce4), + SPH_C32(0x65eebc12), SPH_C32(0x39b78e87) }, + { SPH_C32(0xacbd0004), SPH_C32(0x7ef34599), SPH_C32(0x9b9d2f13), + SPH_C32(0x811ea6b6), SPH_C32(0x6fba000c), SPH_C32(0x1e61854e), + SPH_C32(0xfddca02f), SPH_C32(0x4f1b49b4) }, + { SPH_C32(0xbfb20008), SPH_C32(0x92170a39), SPH_C32(0x6019107f), + SPH_C32(0xe051606e), SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), + SPH_C32(0xfe739301), SPH_C32(0xb8a92831) }, + { SPH_C32(0x6fba000c), SPH_C32(0x1e61854e), SPH_C32(0xfddca02f), + SPH_C32(0x4f1b49b4), SPH_C32(0xc3070008), SPH_C32(0x6092c0d7), + SPH_C32(0x66418f3c), SPH_C32(0xce05ef02) }, + { SPH_C32(0xd41b0008), SPH_C32(0xd2fcf393), SPH_C32(0xf82b0c42), + SPH_C32(0x96fda75d), SPH_C32(0x130f000c), SPH_C32(0xece44fa0), + SPH_C32(0xfb843f6c), SPH_C32(0x614fc6d8) }, + { SPH_C32(0x0413000c), SPH_C32(0x5e8a7ce4), SPH_C32(0x65eebc12), + SPH_C32(0x39b78e87), SPH_C32(0x78a6000c), SPH_C32(0xac0fb60a), + SPH_C32(0x63b62351), SPH_C32(0x17e301eb) }, + { SPH_C32(0x515c0010), SPH_C32(0x40f372fb), SPH_C32(0xfce72602), + SPH_C32(0x71575061), SPH_C32(0x2e390000), SPH_C32(0x64dd6689), + SPH_C32(0x3cd406fc), SPH_C32(0xb1f490bc) }, + { SPH_C32(0x81540014), SPH_C32(0xcc85fd8c), SPH_C32(0x61229652), + SPH_C32(0xde1d79bb), SPH_C32(0x45900000), SPH_C32(0x24369f23), + SPH_C32(0xa4e61ac1), SPH_C32(0xc758578f) }, + { SPH_C32(0x3af50010), SPH_C32(0x00188b51), SPH_C32(0x64d53a3f), + SPH_C32(0x07fb9752), SPH_C32(0x95980004), SPH_C32(0xa8401054), + SPH_C32(0x3923aa91), SPH_C32(0x68127e55) }, + { SPH_C32(0xeafd0014), SPH_C32(0x8c6e0426), SPH_C32(0xf9108a6f), + SPH_C32(0xa8b1be88), SPH_C32(0xfe310004), SPH_C32(0xe8abe9fe), + SPH_C32(0xa111b6ac), SPH_C32(0x1ebeb966) }, + { SPH_C32(0xf9f20018), SPH_C32(0x608a4b86), SPH_C32(0x0294b503), + SPH_C32(0xc9fe7850), SPH_C32(0x39250000), SPH_C32(0xd6b355cd), + SPH_C32(0xa2be8582), SPH_C32(0xe90cd8e3) }, + { SPH_C32(0x29fa001c), SPH_C32(0xecfcc4f1), SPH_C32(0x9f510553), + SPH_C32(0x66b4518a), SPH_C32(0x528c0000), SPH_C32(0x9658ac67), + SPH_C32(0x3a8c99bf), SPH_C32(0x9fa01fd0) }, + { SPH_C32(0x925b0018), SPH_C32(0x2061b22c), SPH_C32(0x9aa6a93e), + SPH_C32(0xbf52bf63), SPH_C32(0x82840004), SPH_C32(0x1a2e2310), + SPH_C32(0xa74929ef), SPH_C32(0x30ea360a) }, + { SPH_C32(0x4253001c), SPH_C32(0xac173d5b), SPH_C32(0x0763196e), + SPH_C32(0x101896b9), SPH_C32(0xe92d0004), SPH_C32(0x5ac5daba), + SPH_C32(0x3f7b35d2), SPH_C32(0x4646f139) }, + { SPH_C32(0x46400010), SPH_C32(0xf29d41bf), SPH_C32(0x628da57c), + SPH_C32(0x29af183e), SPH_C32(0x918b0008), SPH_C32(0xf6ca6cb0), + SPH_C32(0x5ccd1683), SPH_C32(0x51a5f0d2) }, + { SPH_C32(0x96480014), SPH_C32(0x7eebcec8), SPH_C32(0xff48152c), + SPH_C32(0x86e531e4), SPH_C32(0xfa220008), SPH_C32(0xb621951a), + SPH_C32(0xc4ff0abe), SPH_C32(0x270937e1) }, + { SPH_C32(0x2de90010), SPH_C32(0xb276b815), SPH_C32(0xfabfb941), + SPH_C32(0x5f03df0d), SPH_C32(0x2a2a000c), SPH_C32(0x3a571a6d), + SPH_C32(0x593abaee), SPH_C32(0x88431e3b) }, + { SPH_C32(0xfde10014), SPH_C32(0x3e003762), SPH_C32(0x677a0911), + SPH_C32(0xf049f6d7), SPH_C32(0x4183000c), SPH_C32(0x7abce3c7), + SPH_C32(0xc108a6d3), SPH_C32(0xfeefd908) }, + { SPH_C32(0xeeee0018), SPH_C32(0xd2e478c2), SPH_C32(0x9cfe367d), + SPH_C32(0x9106300f), SPH_C32(0x496970008), SPH_C32(0x44a45ff4), + SPH_C32(0xc2a795fd), SPH_C32(0x095db88d) }, + { SPH_C32(0x3ee6001c), SPH_C32(0x5e92f7b5), SPH_C32(0x013b862d), + SPH_C32(0x3e4c19d5), SPH_C32(0xed3e0008), SPH_C32(0x044fa65e), + SPH_C32(0x5a9589c0), SPH_C32(0x7ff17fbe) }, + { SPH_C32(0x85470018), SPH_C32(0x920f8168), SPH_C32(0x04cc2a40), + SPH_C32(0xe7aaf73c), SPH_C32(0x3d36000c), SPH_C32(0x88392929), + SPH_C32(0xc7503990), SPH_C32(0xd0bb5664) }, + { SPH_C32(0x554f001c), SPH_C32(0x1e790e1f), SPH_C32(0x99099a10), + SPH_C32(0x48e0dee6), SPH_C32(0x569f000c), SPH_C32(0xc8d2d083), + SPH_C32(0x5f6225ad), SPH_C32(0xa6179157) }, + { SPH_C32(0x2e390000), SPH_C32(0x64dd6689), SPH_C32(0x3cd406fc), + SPH_C32(0xb1f490bc), SPH_C32(0x7f650010), SPH_C32(0x242e1472), + SPH_C32(0xc03320fe), SPH_C32(0xc0a3c0dd) }, + { SPH_C32(0xfe310004), SPH_C32(0xe8abe9fe), SPH_C32(0xa111b6ac), + SPH_C32(0x1ebeb966), SPH_C32(0x14cc0010), SPH_C32(0x64c5edd8), + SPH_C32(0x58013cc3), SPH_C32(0xb60f07ee) }, + { SPH_C32(0x45900000), SPH_C32(0x24369f23), SPH_C32(0xa4e61ac1), + SPH_C32(0xc758578f), SPH_C32(0xc4c40014), SPH_C32(0xe8b362af), + SPH_C32(0xc5c48c93), SPH_C32(0x19452e34) }, + { SPH_C32(0x95980004), SPH_C32(0xa8401054), SPH_C32(0x3923aa91), + SPH_C32(0x68127e55), SPH_C32(0xaf6d0014), SPH_C32(0xa8589b05), + SPH_C32(0x5df690ae), SPH_C32(0x6fe9e907) }, + { SPH_C32(0x496970008), SPH_C32(0x44a45ff4), SPH_C32(0xc2a795fd), + SPH_C32(0x095db88d), SPH_C32(0x68790010), SPH_C32(0x96402736), + SPH_C32(0x5e59a380), SPH_C32(0x985b8882) }, + { SPH_C32(0x569f000c), SPH_C32(0xc8d2d083), SPH_C32(0x5f6225ad), + SPH_C32(0xa6179157), SPH_C32(0x03d00010), SPH_C32(0xd6abde9c), + SPH_C32(0xc66bbfbd), SPH_C32(0xeef74fb1) }, + { SPH_C32(0xed3e0008), SPH_C32(0x044fa65e), SPH_C32(0x5a9589c0), + SPH_C32(0x7ff17fbe), SPH_C32(0xd3d80014), SPH_C32(0x5add51eb), + SPH_C32(0x5bae0fed), SPH_C32(0x41bd666b) }, + { SPH_C32(0x3d36000c), SPH_C32(0x88392929), SPH_C32(0xc7503990), + SPH_C32(0xd0bb5664), SPH_C32(0xb8710014), SPH_C32(0x1a36a841), + SPH_C32(0xc39c13d0), SPH_C32(0x3711a158) }, + { SPH_C32(0x39250000), SPH_C32(0xd6b355cd), SPH_C32(0xa2be8582), + SPH_C32(0xe90cd8e3), SPH_C32(0xc0d70018), SPH_C32(0xb6391e4b), + SPH_C32(0xa02a3081), SPH_C32(0x20f2a0b3) }, + { SPH_C32(0xe92d0004), SPH_C32(0x5ac5daba), SPH_C32(0x3f7b35d2), + SPH_C32(0x4646f139), SPH_C32(0xab7e0018), SPH_C32(0xf6d2e7e1), + SPH_C32(0x38182cbc), SPH_C32(0x565e6780) }, + { SPH_C32(0x528c0000), SPH_C32(0x9658ac67), SPH_C32(0x3a8c99bf), + SPH_C32(0x9fa01fd0), SPH_C32(0x7b76001c), SPH_C32(0x7aa46896), + SPH_C32(0xa5dd9cec), SPH_C32(0xf9144e5a) }, + { SPH_C32(0x82840004), SPH_C32(0x1a2e2310), SPH_C32(0xa74929ef), + SPH_C32(0x30ea360a), SPH_C32(0x10df001c), SPH_C32(0x3a4f913c), + SPH_C32(0x3def80d1), SPH_C32(0x8fb88969) }, + { SPH_C32(0x918b0008), SPH_C32(0xf6ca6cb0), SPH_C32(0x5ccd1683), + SPH_C32(0x51a5f0d2), SPH_C32(0xd7cb0018), SPH_C32(0x04572d0f), + SPH_C32(0x3e40b3ff), SPH_C32(0x780ae8ec) }, + { SPH_C32(0x4183000c), SPH_C32(0x7abce3c7), SPH_C32(0xc108a6d3), + SPH_C32(0xfeefd908), SPH_C32(0xbc620018), SPH_C32(0x44bcd4a5), + SPH_C32(0xa672afc2), SPH_C32(0x0ea62fdf) }, + { SPH_C32(0xfa220008), SPH_C32(0xb621951a), SPH_C32(0xc4ff0abe), + SPH_C32(0x270937e1), SPH_C32(0x6c6a001c), SPH_C32(0xc8ca5bd2), + SPH_C32(0x3bb71f92), SPH_C32(0xa1ec0605) }, + { SPH_C32(0x2a2a000c), SPH_C32(0x3a571a6d), SPH_C32(0x593abaee), + SPH_C32(0x88431e3b), SPH_C32(0x07c3001c), SPH_C32(0x8821a278), + SPH_C32(0xa38503af), SPH_C32(0xd740c136) }, + { SPH_C32(0x7f650010), SPH_C32(0x242e1472), SPH_C32(0xc03320fe), + SPH_C32(0xc0a3c0dd), SPH_C32(0x515c0010), SPH_C32(0x40f372fb), + SPH_C32(0xfce72602), SPH_C32(0x71575061) }, + { SPH_C32(0xaf6d0014), SPH_C32(0xa8589b05), SPH_C32(0x5df690ae), + SPH_C32(0x6fe9e907), SPH_C32(0x3af50010), SPH_C32(0x00188b51), + SPH_C32(0x64d53a3f), SPH_C32(0x07fb9752) }, + { SPH_C32(0x14cc0010), SPH_C32(0x64c5edd8), SPH_C32(0x58013cc3), + SPH_C32(0xb60f07ee), SPH_C32(0xeafd0014), SPH_C32(0x8c6e0426), + SPH_C32(0xf9108a6f), SPH_C32(0xa8b1be88) }, + { SPH_C32(0xc4c40014), SPH_C32(0xe8b362af), SPH_C32(0xc5c48c93), + SPH_C32(0x19452e34), SPH_C32(0x81540014), SPH_C32(0xcc85fd8c), + SPH_C32(0x61229652), SPH_C32(0xde1d79bb) }, + { SPH_C32(0xd7cb0018), SPH_C32(0x04572d0f), SPH_C32(0x3e40b3ff), + SPH_C32(0x780ae8ec), SPH_C32(0x46400010), SPH_C32(0xf29d41bf), + SPH_C32(0x628da57c), SPH_C32(0x29af183e) }, + { SPH_C32(0x07c3001c), SPH_C32(0x8821a278), SPH_C32(0xa38503af), + SPH_C32(0xd740c136), SPH_C32(0x2de90010), SPH_C32(0xb276b815), + SPH_C32(0xfabfb941), SPH_C32(0x5f03df0d) }, + { SPH_C32(0xbc620018), SPH_C32(0x44bcd4a5), SPH_C32(0xa672afc2), + SPH_C32(0x0ea62fdf), SPH_C32(0xfde10014), SPH_C32(0x3e003762), + SPH_C32(0x677a0911), SPH_C32(0xf049f6d7) }, + { SPH_C32(0x6c6a001c), SPH_C32(0xc8ca5bd2), SPH_C32(0x3bb71f92), + SPH_C32(0xa1ec0605), SPH_C32(0x96480014), SPH_C32(0x7eebcec8), + SPH_C32(0xff48152c), SPH_C32(0x86e531e4) }, + { SPH_C32(0x68790010), SPH_C32(0x96402736), SPH_C32(0x5e59a380), + SPH_C32(0x985b8882), SPH_C32(0xeeee0018), SPH_C32(0xd2e478c2), + SPH_C32(0x9cfe367d), SPH_C32(0x9106300f) }, + { SPH_C32(0xb8710014), SPH_C32(0x1a36a841), SPH_C32(0xc39c13d0), + SPH_C32(0x3711a158), SPH_C32(0x85470018), SPH_C32(0x920f8168), + SPH_C32(0x04cc2a40), SPH_C32(0xe7aaf73c) }, + { SPH_C32(0x03d00010), SPH_C32(0xd6abde9c), SPH_C32(0xc66bbfbd), + SPH_C32(0xeef74fb1), SPH_C32(0x554f001c), SPH_C32(0x1e790e1f), + SPH_C32(0x99099a10), SPH_C32(0x48e0dee6) }, + { SPH_C32(0xd3d80014), SPH_C32(0x5add51eb), SPH_C32(0x5bae0fed), + SPH_C32(0x41bd666b), SPH_C32(0x3ee6001c), SPH_C32(0x5e92f7b5), + SPH_C32(0x013b862d), SPH_C32(0x3e4c19d5) }, + { SPH_C32(0xc0d70018), SPH_C32(0xb6391e4b), SPH_C32(0xa02a3081), + SPH_C32(0x20f2a0b3), SPH_C32(0xf9f20018), SPH_C32(0x608a4b86), + SPH_C32(0x0294b503), SPH_C32(0xc9fe7850) }, + { SPH_C32(0x10df001c), SPH_C32(0x3a4f913c), SPH_C32(0x3def80d1), + SPH_C32(0x8fb88969), SPH_C32(0x925b0018), SPH_C32(0x2061b22c), + SPH_C32(0x9aa6a93e), SPH_C32(0xbf52bf63) }, + { SPH_C32(0xab7e0018), SPH_C32(0xf6d2e7e1), SPH_C32(0x38182cbc), + SPH_C32(0x565e6780), SPH_C32(0x4253001c), SPH_C32(0xac173d5b), + SPH_C32(0x0763196e), SPH_C32(0x101896b9) }, + { SPH_C32(0x7b76001c), SPH_C32(0x7aa46896), SPH_C32(0xa5dd9cec), + SPH_C32(0xf9144e5a), SPH_C32(0x29fa001c), SPH_C32(0xecfcc4f1), + SPH_C32(0x9f510553), SPH_C32(0x66b4518a) }, + { SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), SPH_C32(0xf9ce4c04), + SPH_C32(0xe2afa0c0), SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), + SPH_C32(0x79a90df9), SPH_C32(0x63e92178) }, + { SPH_C32(0x72b00024), SPH_C32(0x0d916a81), SPH_C32(0x640bfc54), + SPH_C32(0x4de5891a), SPH_C32(0x37db0000), SPH_C32(0x895134b8), + SPH_C32(0xe19b11c4), SPH_C32(0x1545e64b) }, + { SPH_C32(0xc9110020), SPH_C32(0xc10c1c5c), SPH_C32(0x61fc5039), + SPH_C32(0x940367f3), SPH_C32(0xe7d30004), SPH_C32(0x0527bbcf), + SPH_C32(0x7c5ea194), SPH_C32(0xba0fcf91) }, + { SPH_C32(0x19190024), SPH_C32(0x4d7a932b), SPH_C32(0xfc39e069), + SPH_C32(0x3b494e29), SPH_C32(0x8c7a0004), SPH_C32(0x45cc4265), + SPH_C32(0xe46cbda9), SPH_C32(0xcca308a2) }, + { SPH_C32(0x0a160028), SPH_C32(0xa19edc8b), SPH_C32(0x07bddf05), + SPH_C32(0x5a0688f1), SPH_C32(0x4b6e0000), SPH_C32(0x7bd4fe56), + SPH_C32(0xe7c38e87), SPH_C32(0x3b116927) }, + { SPH_C32(0xda1e002c), SPH_C32(0x2de853fc), SPH_C32(0x9a786f55), + SPH_C32(0xf54ca12b), SPH_C32(0x20c70000), SPH_C32(0x3b3f07fc), + SPH_C32(0x7ff192ba), SPH_C32(0x4dbdae14) }, + { SPH_C32(0x61bf0028), SPH_C32(0xe1752521), SPH_C32(0x9f8fc338), + SPH_C32(0x2caa4fc2), SPH_C32(0xf0cf0004), SPH_C32(0xb749888b), + SPH_C32(0xe23422ea), SPH_C32(0xe2f787ce) }, + { SPH_C32(0xb1b7002c), SPH_C32(0x6d03aa56), SPH_C32(0x024a7368), + SPH_C32(0x83e06618), SPH_C32(0x9b660004), SPH_C32(0xf7a27121), + SPH_C32(0x7a063ed7), SPH_C32(0x945b40fd) }, + { SPH_C32(0xb5a40020), SPH_C32(0x3389d6b2), SPH_C32(0x67a4cf7a), + SPH_C32(0xba57e89f), SPH_C32(0xe3c00008), SPH_C32(0x5badc72b), + SPH_C32(0x19b01d86), SPH_C32(0x83b84116) }, + { SPH_C32(0x65ac0024), SPH_C32(0xbfff59c5), SPH_C32(0xfa617f2a), + SPH_C32(0x151dc145), SPH_C32(0x88690008), SPH_C32(0x1b463e81), + SPH_C32(0x818201bb), SPH_C32(0xf5148625) }, + { SPH_C32(0xde0d0020), SPH_C32(0x73622f18), SPH_C32(0xff96d347), + SPH_C32(0xccfb2fac), SPH_C32(0x5861000c), SPH_C32(0x9730b1f6), + SPH_C32(0x1c47b1eb), SPH_C32(0x5a5eafff) }, + { SPH_C32(0x0e050024), SPH_C32(0xff14a06f), SPH_C32(0x62536317), + SPH_C32(0x63b10676), SPH_C32(0x33c8000c), SPH_C32(0xd7db485c), + SPH_C32(0x8475add6), SPH_C32(0x2cf268cc) }, + { SPH_C32(0x1d0a0028), SPH_C32(0x13f0efcf), SPH_C32(0x99d75c7b), + SPH_C32(0x02fec0ae), SPH_C32(0xf4dc0008), SPH_C32(0xe9c3f46f), + SPH_C32(0x87da9ef8), SPH_C32(0xdb400949) }, + { SPH_C32(0xcd02002c), SPH_C32(0x9f8660b8), SPH_C32(0x0412ec2b), + SPH_C32(0xadb4e974), SPH_C32(0x9f750008), SPH_C32(0xa9280dc5), + SPH_C32(0x1fe882c5), SPH_C32(0xadecce7a) }, + { SPH_C32(0x76a30028), SPH_C32(0x531b1665), SPH_C32(0x01e54046), + SPH_C32(0x7452079d), SPH_C32(0x4f7d000c), SPH_C32(0x255e82b2), + SPH_C32(0x822d3295), SPH_C32(0x02a6e7a0) }, + { SPH_C32(0xa6ab002c), SPH_C32(0xdf6d9912), SPH_C32(0x9c20f016), + SPH_C32(0xdb182e47), SPH_C32(0x24d4000c), SPH_C32(0x65b57b18), + SPH_C32(0x1a1f2ea8), SPH_C32(0x740a2093) }, + { SPH_C32(0xf3e40030), SPH_C32(0xc114970d), SPH_C32(0x05296a06), + SPH_C32(0x93f8f0a1), SPH_C32(0x724b0000), SPH_C32(0xad67ab9b), + SPH_C32(0x457d0b05), SPH_C32(0xd21db1c4) }, + { SPH_C32(0x23ec0034), SPH_C32(0x4d62187a), SPH_C32(0x98ecda56), + SPH_C32(0x3cb2d97b), SPH_C32(0x19e20000), SPH_C32(0xed8c5231), + SPH_C32(0xdd4f1738), SPH_C32(0xa4b176f7) }, + { SPH_C32(0x984d0030), SPH_C32(0x81ff6ea7), SPH_C32(0x9d1b763b), + SPH_C32(0xe5543792), SPH_C32(0xc9ea0004), SPH_C32(0x61fadd46), + SPH_C32(0x408aa768), SPH_C32(0x0bfb5f2d) }, + { SPH_C32(0x48450034), SPH_C32(0x0d89e1d0), SPH_C32(0x00dec66b), + SPH_C32(0x4a1e1e48), SPH_C32(0xa2430004), SPH_C32(0x211124ec), + SPH_C32(0xd8b8bb55), SPH_C32(0x7d57981e) }, + { SPH_C32(0x5b4a0038), SPH_C32(0xe16dae70), SPH_C32(0xfb5af907), + SPH_C32(0x2b51d890), SPH_C32(0x65570000), SPH_C32(0x1f0998df), + SPH_C32(0xdb17887b), SPH_C32(0x8ae5f99b) }, + { SPH_C32(0x8b42003c), SPH_C32(0x6d1b2107), SPH_C32(0x669f4957), + SPH_C32(0x841bf14a), SPH_C32(0x0efe0000), SPH_C32(0x5fe26175), + SPH_C32(0x43259446), SPH_C32(0xfc493ea8) }, + { SPH_C32(0x30e30038), SPH_C32(0xa18657da), SPH_C32(0x6368e53a), + SPH_C32(0x5dfd1fa3), SPH_C32(0xdef60004), SPH_C32(0xd394ee02), + SPH_C32(0xdee02416), SPH_C32(0x53031772) }, + { SPH_C32(0xe0eb003c), SPH_C32(0x2df0d8ad), SPH_C32(0xfead556a), + SPH_C32(0xf2b73679), SPH_C32(0xb55f0004), SPH_C32(0x937f17a8), + SPH_C32(0x46d2382b), SPH_C32(0x25afd041) }, + { SPH_C32(0xe4f80030), SPH_C32(0x737aa449), SPH_C32(0x9b43e978), + SPH_C32(0xcb00b8fe), SPH_C32(0xcdf90008), SPH_C32(0x3f70a1a2), + SPH_C32(0x25641b7a), SPH_C32(0x324cd1aa) }, + { SPH_C32(0x34f00034), SPH_C32(0xff0c2b3e), SPH_C32(0x06865928), + SPH_C32(0x644a9124), SPH_C32(0xa6500008), SPH_C32(0x7f9b5808), + SPH_C32(0xbd560747), SPH_C32(0x44e01699) }, + { SPH_C32(0x8f510030), SPH_C32(0x33915de3), SPH_C32(0x0371f545), + SPH_C32(0xbdac7fcd), SPH_C32(0x7658000c), SPH_C32(0xf3edd77f), + SPH_C32(0x2093b717), SPH_C32(0xebaa3f43) }, + { SPH_C32(0x5f590034), SPH_C32(0xbfe7d294), SPH_C32(0x9eb44515), + SPH_C32(0x12e65617), SPH_C32(0x1df1000c), SPH_C32(0xb3062ed5), + SPH_C32(0xb8a1ab2a), SPH_C32(0x9d06f870) }, + { SPH_C32(0x4c560038), SPH_C32(0x53039d34), SPH_C32(0x65307a79), + SPH_C32(0x73a990cf), SPH_C32(0xdae50008), SPH_C32(0x8d1e92e6), + SPH_C32(0xbb0e9804), SPH_C32(0x6ab499f5) }, + { SPH_C32(0x9c5e003c), SPH_C32(0xdf751243), SPH_C32(0xf8f5ca29), + SPH_C32(0xdce3b915), SPH_C32(0xb14c0008), SPH_C32(0xcdf56b4c), + SPH_C32(0x233c8439), SPH_C32(0x1c185ec6) }, + { SPH_C32(0x27ff0038), SPH_C32(0x13e8649e), SPH_C32(0xfd026644), + SPH_C32(0x050557fc), SPH_C32(0x6144000c), SPH_C32(0x4183e43b), + SPH_C32(0xbef93469), SPH_C32(0xb352771c) }, + { SPH_C32(0xf7f7003c), SPH_C32(0x9f9eebe9), SPH_C32(0x60c7d614), + SPH_C32(0xaa4f7e26), SPH_C32(0x0aed000c), SPH_C32(0x01681d91), + SPH_C32(0x26cb2854), SPH_C32(0xc5feb02f) }, + { SPH_C32(0x8c810020), SPH_C32(0xe53a837f), SPH_C32(0xc51a4af8), + SPH_C32(0x535b307c), SPH_C32(0x23170010), SPH_C32(0xed94d960), + SPH_C32(0xb99a2d07), SPH_C32(0xa34ae1a5) }, + { SPH_C32(0x5c890024), SPH_C32(0x694c0c08), SPH_C32(0x58dffaa8), + SPH_C32(0xfc1119a6), SPH_C32(0x48be0010), SPH_C32(0xad7f20ca), + SPH_C32(0x21a8313a), SPH_C32(0xd5e62696) }, + { SPH_C32(0xe7280020), SPH_C32(0xa5d17ad5), SPH_C32(0x5d2856c5), + SPH_C32(0x25f7f74f), SPH_C32(0x98b60014), SPH_C32(0x2109afbd), + SPH_C32(0xbc6d816a), SPH_C32(0x7aac0f4c) }, + { SPH_C32(0x37200024), SPH_C32(0x29a7f5a2), SPH_C32(0xc0ede695), + SPH_C32(0x8abdde95), SPH_C32(0xf31f0014), SPH_C32(0x61e25617), + SPH_C32(0x245f9d57), SPH_C32(0x0c00c87f) }, + { SPH_C32(0x242f0028), SPH_C32(0xc543ba02), SPH_C32(0x3b69d9f9), + SPH_C32(0xebf2184d), SPH_C32(0x340b0010), SPH_C32(0x5ffaea24), + SPH_C32(0x27f0ae79), SPH_C32(0xfbb2a9fa) }, + { SPH_C32(0xf427002c), SPH_C32(0x49353575), SPH_C32(0xa6ac69a9), + SPH_C32(0x44b83197), SPH_C32(0x5fa20010), SPH_C32(0x1f11138e), + SPH_C32(0xbfc2b244), SPH_C32(0x8d1e6ec9) }, + { SPH_C32(0x4f860028), SPH_C32(0x85a843a8), SPH_C32(0xa35bc5c4), + SPH_C32(0x9d5edf7e), SPH_C32(0x8faa0014), SPH_C32(0x93679cf9), + SPH_C32(0x22070214), SPH_C32(0x22544713) }, + { SPH_C32(0x9f8e002c), SPH_C32(0x09deccdf), SPH_C32(0x3e9e7594), + SPH_C32(0x3214f6a4), SPH_C32(0xe4030014), SPH_C32(0xd38c6553), + SPH_C32(0xba351e29), SPH_C32(0x54f88020) }, + { SPH_C32(0x9b9d0020), SPH_C32(0x5754b03b), SPH_C32(0x5b70c986), + SPH_C32(0x0ba37823), SPH_C32(0x9ca50018), SPH_C32(0x7f83d359), + SPH_C32(0xd9833d78), SPH_C32(0x431b81cb) }, + { SPH_C32(0x4b950024), SPH_C32(0xdb223f4c), SPH_C32(0xc6b579d6), + SPH_C32(0xa4e951f9), SPH_C32(0xf70c0018), SPH_C32(0x3f682af3), + SPH_C32(0x41b12145), SPH_C32(0x35b746f8) }, + { SPH_C32(0xf0340020), SPH_C32(0x17bf4991), SPH_C32(0xc342d5bb), + SPH_C32(0x7d0fbf10), SPH_C32(0x2704001c), SPH_C32(0xb31ea584), + SPH_C32(0xdc749115), SPH_C32(0x9afd6f22) }, + { SPH_C32(0x203c0024), SPH_C32(0x9bc9c6e6), SPH_C32(0x5e8765eb), + SPH_C32(0xd24596ca), SPH_C32(0x4cad001c), SPH_C32(0xf3f55c2e), + SPH_C32(0x44468d28), SPH_C32(0xec51a811) }, + { SPH_C32(0x33330028), SPH_C32(0x772d8946), SPH_C32(0xa5035a87), + SPH_C32(0xb30a5012), SPH_C32(0x8bb90018), SPH_C32(0xcdede01d), + SPH_C32(0x47e9be06), SPH_C32(0x1be3c994) }, + { SPH_C32(0xe33b002c), SPH_C32(0xfb5b0631), SPH_C32(0x38c6ead7), + SPH_C32(0x1c4079c8), SPH_C32(0xe0100018), SPH_C32(0x8d0619b7), + SPH_C32(0xdfdba23b), SPH_C32(0x6d4f0ea7) }, + { SPH_C32(0x589a0028), SPH_C32(0x37c670ec), SPH_C32(0x3d3146ba), + SPH_C32(0xc5a69721), SPH_C32(0x3018001c), SPH_C32(0x017096c0), + SPH_C32(0x421e126b), SPH_C32(0xc205277d) }, + { SPH_C32(0x8892002c), SPH_C32(0xbbb0ff9b), SPH_C32(0xa0f4f6ea), + SPH_C32(0x6aecbefb), SPH_C32(0x5bb1001c), SPH_C32(0x419b6f6a), + SPH_C32(0xda2c0e56), SPH_C32(0xb4a9e04e) }, + { SPH_C32(0xdddd0030), SPH_C32(0xa5c9f184), SPH_C32(0x39fd6cfa), + SPH_C32(0x220c601d), SPH_C32(0x0d2e0010), SPH_C32(0x8949bfe9), + SPH_C32(0x854e2bfb), SPH_C32(0x12be7119) }, + { SPH_C32(0x0dd50034), SPH_C32(0x29bf7ef3), SPH_C32(0xa438dcaa), + SPH_C32(0x8d4649c7), SPH_C32(0x66870010), SPH_C32(0xc9a24643), + SPH_C32(0x1d7c37c6), SPH_C32(0x6412b62a) }, + { SPH_C32(0xb6740030), SPH_C32(0xe522082e), SPH_C32(0xa1cf70c7), + SPH_C32(0x54a0a72e), SPH_C32(0xb68f0014), SPH_C32(0x45d4c934), + SPH_C32(0x80b98796), SPH_C32(0xcb589ff0) }, + { SPH_C32(0x667c0034), SPH_C32(0x69548759), SPH_C32(0x3c0ac097), + SPH_C32(0xfbea8ef4), SPH_C32(0xdd260014), SPH_C32(0x053f309e), + SPH_C32(0x188b9bab), SPH_C32(0xbdf458c3) }, + { SPH_C32(0x75730038), SPH_C32(0x85b0c8f9), SPH_C32(0xc78efffb), + SPH_C32(0x9aa5482c), SPH_C32(0x1a320010), SPH_C32(0x3b278cad), + SPH_C32(0x1b24a885), SPH_C32(0x4a463946) }, + { SPH_C32(0xa57b003c), SPH_C32(0x09c6478e), SPH_C32(0x5a4b4fab), + SPH_C32(0x35ef61f6), SPH_C32(0x719b0010), SPH_C32(0x7bcc7507), + SPH_C32(0x8316b4b8), SPH_C32(0x3ceafe75) }, + { SPH_C32(0x1eda0038), SPH_C32(0xc55b3153), SPH_C32(0x5fbce3c6), + SPH_C32(0xec098f1f), SPH_C32(0xa1930014), SPH_C32(0xf7bafa70), + SPH_C32(0x1ed304e8), SPH_C32(0x93a0d7af) }, + { SPH_C32(0xced2003c), SPH_C32(0x492dbe24), SPH_C32(0xc2795396), + SPH_C32(0x4343a6c5), SPH_C32(0xca3a0014), SPH_C32(0xb75103da), + SPH_C32(0x86e118d5), SPH_C32(0xe50c109c) }, + { SPH_C32(0xcac10030), SPH_C32(0x17a7c2c0), SPH_C32(0xa797ef84), + SPH_C32(0x7af42842), SPH_C32(0xb29c0018), SPH_C32(0x1b5eb5d0), + SPH_C32(0xe5573b84), SPH_C32(0xf2ef1177) }, + { SPH_C32(0x1ac90034), SPH_C32(0x9bd14db7), SPH_C32(0x3a525fd4), + SPH_C32(0xd5be0198), SPH_C32(0xd9350018), SPH_C32(0x5bb54c7a), + SPH_C32(0x7d6527b9), SPH_C32(0x8443d644) }, + { SPH_C32(0xa1680030), SPH_C32(0x574c3b6a), SPH_C32(0x3fa5f3b9), + SPH_C32(0x0c58ef71), SPH_C32(0x093d001c), SPH_C32(0xd7c3c30d), + SPH_C32(0xe0a097e9), SPH_C32(0x2b09ff9e) }, + { SPH_C32(0x71600034), SPH_C32(0xdb3ab41d), SPH_C32(0xa26043e9), + SPH_C32(0xa312c6ab), SPH_C32(0x6294001c), SPH_C32(0x97283aa7), + SPH_C32(0x78928bd4), SPH_C32(0x5da538ad) }, + { SPH_C32(0x626f0038), SPH_C32(0x37defbbd), SPH_C32(0x59e47c85), + SPH_C32(0xc25d0073), SPH_C32(0xa5800018), SPH_C32(0xa9308694), + SPH_C32(0x7b3db8fa), SPH_C32(0xaa175928) }, + { SPH_C32(0xb267003c), SPH_C32(0xbba874ca), SPH_C32(0xc421ccd5), + SPH_C32(0x6d1729a9), SPH_C32(0xce290018), SPH_C32(0xe9db7f3e), + SPH_C32(0xe30fa4c7), SPH_C32(0xdcbb9e1b) }, + { SPH_C32(0x09c60038), SPH_C32(0x77350217), SPH_C32(0xc1d660b8), + SPH_C32(0xb4f1c740), SPH_C32(0x1e21001c), SPH_C32(0x65adf049), + SPH_C32(0x7eca1497), SPH_C32(0x73f1b7c1) }, + { SPH_C32(0xd9ce003c), SPH_C32(0xfb438d60), SPH_C32(0x5c13d0e8), + SPH_C32(0x1bbbee9a), SPH_C32(0x7588001c), SPH_C32(0x254609e3), + SPH_C32(0xe6f808aa), SPH_C32(0x055d70f2) } +}; + +static const sph_u32 T256_28[16][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), SPH_C32(0xae0ebb05), + SPH_C32(0xb5a4c63b), SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), + SPH_C32(0x6bf648a4), SPH_C32(0x539cbdbf) }, + { SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), SPH_C32(0x6bf648a4), + SPH_C32(0x539cbdbf), SPH_C32(0x08bf0001), SPH_C32(0x38942792), + SPH_C32(0xc5f8f3a1), SPH_C32(0xe6387b84) }, + { SPH_C32(0x08bf0001), SPH_C32(0x38942792), SPH_C32(0xc5f8f3a1), + SPH_C32(0xe6387b84), SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), + SPH_C32(0xae0ebb05), SPH_C32(0xb5a4c63b) }, + { SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), SPH_C32(0x99e585aa), + SPH_C32(0x8d75f7f1), SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), + SPH_C32(0x79e22a4c), SPH_C32(0x1298bd46) }, + { SPH_C32(0x486d0003), SPH_C32(0x6c5e67a3), SPH_C32(0x37eb3eaf), + SPH_C32(0x38d131ca), SPH_C32(0x995d0000), SPH_C32(0x2ecee896), + SPH_C32(0x121462e8), SPH_C32(0x410400f9) }, + { SPH_C32(0x40d20002), SPH_C32(0x54ca4031), SPH_C32(0xf213cd0e), + SPH_C32(0xdee94a4e), SPH_C32(0x59130001), SPH_C32(0x1d772886), + SPH_C32(0xbc1ad9ed), SPH_C32(0xf4a0c6c2) }, + { SPH_C32(0x809c0003), SPH_C32(0x67738021), SPH_C32(0x5c1d760b), + SPH_C32(0x6b4d8c75), SPH_C32(0x91e20001), SPH_C32(0x165acf04), + SPH_C32(0xd7ec9149), SPH_C32(0xa73c7b7d) }, + { SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), SPH_C32(0x79e22a4c), + SPH_C32(0x1298bd46), SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), + SPH_C32(0xe007afe6), SPH_C32(0x9fed4ab7) }, + { SPH_C32(0x91e20001), SPH_C32(0x165acf04), SPH_C32(0xd7ec9149), + SPH_C32(0xa73c7b7d), SPH_C32(0x117e0002), SPH_C32(0x71294f25), + SPH_C32(0x8bf1e742), SPH_C32(0xcc71f708) }, + { SPH_C32(0x995d0000), SPH_C32(0x2ecee896), SPH_C32(0x121462e8), + SPH_C32(0x410400f9), SPH_C32(0xd1300003), SPH_C32(0x42908f35), + SPH_C32(0x25ff5c47), SPH_C32(0x79d53133) }, + { SPH_C32(0x59130001), SPH_C32(0x1d772886), SPH_C32(0xbc1ad9ed), + SPH_C32(0xf4a0c6c2), SPH_C32(0x19c10003), SPH_C32(0x49bd68b7), + SPH_C32(0x4e0914e3), SPH_C32(0x2a498c8c) }, + { SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), SPH_C32(0xe007afe6), + SPH_C32(0x9fed4ab7), SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), + SPH_C32(0x99e585aa), SPH_C32(0x8d75f7f1) }, + { SPH_C32(0x19c10003), SPH_C32(0x49bd68b7), SPH_C32(0x4e0914e3), + SPH_C32(0x2a498c8c), SPH_C32(0x40d20002), SPH_C32(0x54ca4031), + SPH_C32(0xf213cd0e), SPH_C32(0xdee94a4e) }, + { SPH_C32(0x117e0002), SPH_C32(0x71294f25), SPH_C32(0x8bf1e742), + SPH_C32(0xcc71f708), SPH_C32(0x809c0003), SPH_C32(0x67738021), + SPH_C32(0x5c1d760b), SPH_C32(0x6b4d8c75) }, + { SPH_C32(0xd1300003), SPH_C32(0x42908f35), SPH_C32(0x25ff5c47), + SPH_C32(0x79d53133), SPH_C32(0x486d0003), SPH_C32(0x6c5e67a3), + SPH_C32(0x37eb3eaf), SPH_C32(0x38d131ca) } +}; + +#define INPUT_SMALL do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T256_0[acc >> 1][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + acc = (acc << 8) | buf[1]; \ + rp = &T256_7[(acc >> 2) & 0x7f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = (acc << 8) | buf[2]; \ + rp = &T256_14[(acc >> 3) & 0x7f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = (acc << 8) | buf[3]; \ + rp = &T256_21[(acc >> 4) & 0x7f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + rp = &T256_28[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_SMALL == 8 + +static const sph_u32 T256_0[256][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x74951000), SPH_C32(0x5a2b467e), SPH_C32(0x88fd1d2b), + SPH_C32(0x1ee68292), SPH_C32(0xcba90000), SPH_C32(0x90273769), + SPH_C32(0xbbdcf407), SPH_C32(0xd0f4af61) }, + { SPH_C32(0xcba90000), SPH_C32(0x90273769), SPH_C32(0xbbdcf407), + SPH_C32(0xd0f4af61), SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), + SPH_C32(0x3321e92c), SPH_C32(0xce122df3) }, + { SPH_C32(0xbf3c1000), SPH_C32(0xca0c7117), SPH_C32(0x3321e92c), + SPH_C32(0xce122df3), SPH_C32(0x74951000), SPH_C32(0x5a2b467e), + SPH_C32(0x88fd1d2b), SPH_C32(0x1ee68292) }, + { SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), SPH_C32(0x11fa3a57), + SPH_C32(0x3dc90524), SPH_C32(0x97530000), SPH_C32(0x204f6ed3), + SPH_C32(0x77b9e80f), SPH_C32(0xa1ec5ec1) }, + { SPH_C32(0x9dbf3000), SPH_C32(0xee7cca82), SPH_C32(0x9907277c), + SPH_C32(0x232f87b6), SPH_C32(0x5cfa0000), SPH_C32(0xb06859ba), + SPH_C32(0xcc651c08), SPH_C32(0x7118f1a0) }, + { SPH_C32(0x22832000), SPH_C32(0x2470bb95), SPH_C32(0xaa26ce50), + SPH_C32(0xed3daa45), SPH_C32(0x286f1000), SPH_C32(0xea431fc4), + SPH_C32(0x44980123), SPH_C32(0x6ffe7332) }, + { SPH_C32(0x56163000), SPH_C32(0x7e5bfdeb), SPH_C32(0x22dbd37b), + SPH_C32(0xf3db28d7), SPH_C32(0xe3c61000), SPH_C32(0x7a6428ad), + SPH_C32(0xff44f524), SPH_C32(0xbf0adc53) }, + { SPH_C32(0x97530000), SPH_C32(0x204f6ed3), SPH_C32(0x77b9e80f), + SPH_C32(0xa1ec5ec1), SPH_C32(0x7e792000), SPH_C32(0x9418e22f), + SPH_C32(0x6643d258), SPH_C32(0x9c255be5) }, + { SPH_C32(0xe3c61000), SPH_C32(0x7a6428ad), SPH_C32(0xff44f524), + SPH_C32(0xbf0adc53), SPH_C32(0xb5d02000), SPH_C32(0x043fd546), + SPH_C32(0xdd9f265f), SPH_C32(0x4cd1f484) }, + { SPH_C32(0x5cfa0000), SPH_C32(0xb06859ba), SPH_C32(0xcc651c08), + SPH_C32(0x7118f1a0), SPH_C32(0xc1453000), SPH_C32(0x5e149338), + SPH_C32(0x55623b74), SPH_C32(0x52377616) }, + { SPH_C32(0x286f1000), SPH_C32(0xea431fc4), SPH_C32(0x44980123), + SPH_C32(0x6ffe7332), SPH_C32(0x0aec3000), SPH_C32(0xce33a451), + SPH_C32(0xeebecf73), SPH_C32(0x82c3d977) }, + { SPH_C32(0x7e792000), SPH_C32(0x9418e22f), SPH_C32(0x6643d258), + SPH_C32(0x9c255be5), SPH_C32(0xe92a2000), SPH_C32(0xb4578cfc), + SPH_C32(0x11fa3a57), SPH_C32(0x3dc90524) }, + { SPH_C32(0x0aec3000), SPH_C32(0xce33a451), SPH_C32(0xeebecf73), + SPH_C32(0x82c3d977), SPH_C32(0x22832000), SPH_C32(0x2470bb95), + SPH_C32(0xaa26ce50), SPH_C32(0xed3daa45) }, + { SPH_C32(0xb5d02000), SPH_C32(0x043fd546), SPH_C32(0xdd9f265f), + SPH_C32(0x4cd1f484), SPH_C32(0x56163000), SPH_C32(0x7e5bfdeb), + SPH_C32(0x22dbd37b), SPH_C32(0xf3db28d7) }, + { SPH_C32(0xc1453000), SPH_C32(0x5e149338), SPH_C32(0x55623b74), + SPH_C32(0x52377616), SPH_C32(0x9dbf3000), SPH_C32(0xee7cca82), + SPH_C32(0x9907277c), SPH_C32(0x232f87b6) }, + { SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), SPH_C32(0x8dfacfab), + SPH_C32(0xce36cc72), SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), + SPH_C32(0x848598ba), SPH_C32(0x1041003e) }, + { SPH_C32(0x668e5000), SPH_C32(0x013c9f96), SPH_C32(0x0507d280), + SPH_C32(0xd0d04ee0), SPH_C32(0x2dfe0000), SPH_C32(0xdb940d4c), + SPH_C32(0x3f596cbd), SPH_C32(0xc0b5af5f) }, + { SPH_C32(0xd9b24000), SPH_C32(0xcb30ee81), SPH_C32(0x36263bac), + SPH_C32(0x1ec26313), SPH_C32(0x596b1000), SPH_C32(0x81bf4b32), + SPH_C32(0xb7a47196), SPH_C32(0xde532dcd) }, + { SPH_C32(0xad275000), SPH_C32(0x911ba8ff), SPH_C32(0xbedb2687), + SPH_C32(0x0024e181), SPH_C32(0x92c21000), SPH_C32(0x11987c5b), + SPH_C32(0x0c788591), SPH_C32(0x0ea782ac) }, + { SPH_C32(0xfb316000), SPH_C32(0xef405514), SPH_C32(0x9c00f5fc), + SPH_C32(0xf3ffc956), SPH_C32(0x71040000), SPH_C32(0x6bfc54f6), + SPH_C32(0xf33c70b5), SPH_C32(0xb1ad5eff) }, + { SPH_C32(0x8fa47000), SPH_C32(0xb56b136a), SPH_C32(0x14fde8d7), + SPH_C32(0xed194bc4), SPH_C32(0xbaad0000), SPH_C32(0xfbdb639f), + SPH_C32(0x48e084b2), SPH_C32(0x6159f19e) }, + { SPH_C32(0x30986000), SPH_C32(0x7f67627d), SPH_C32(0x27dc01fb), + SPH_C32(0x230b6637), SPH_C32(0xce381000), SPH_C32(0xa1f025e1), + SPH_C32(0xc01d9999), SPH_C32(0x7fbf730c) }, + { SPH_C32(0x440d7000), SPH_C32(0x254c2403), SPH_C32(0xaf211cd0), + SPH_C32(0x3dede4a5), SPH_C32(0x05911000), SPH_C32(0x31d71288), + SPH_C32(0x7bc16d9e), SPH_C32(0xaf4bdc6d) }, + { SPH_C32(0x85484000), SPH_C32(0x7b58b73b), SPH_C32(0xfa4327a4), + SPH_C32(0x6fda92b3), SPH_C32(0x982e2000), SPH_C32(0xdfabd80a), + SPH_C32(0xe2c64ae2), SPH_C32(0x8c645bdb) }, + { SPH_C32(0xf1dd5000), SPH_C32(0x2173f145), SPH_C32(0x72be3a8f), + SPH_C32(0x713c1021), SPH_C32(0x53872000), SPH_C32(0x4f8cef63), + SPH_C32(0x591abee5), SPH_C32(0x5c90f4ba) }, + { SPH_C32(0x4ee14000), SPH_C32(0xeb7f8052), SPH_C32(0x419fd3a3), + SPH_C32(0xbf2e3dd2), SPH_C32(0x27123000), SPH_C32(0x15a7a91d), + SPH_C32(0xd1e7a3ce), SPH_C32(0x42767628) }, + { SPH_C32(0x3a745000), SPH_C32(0xb154c62c), SPH_C32(0xc962ce88), + SPH_C32(0xa1c8bf40), SPH_C32(0xecbb3000), SPH_C32(0x85809e74), + SPH_C32(0x6a3b57c9), SPH_C32(0x9282d949) }, + { SPH_C32(0x6c626000), SPH_C32(0xcf0f3bc7), SPH_C32(0xebb91df3), + SPH_C32(0x52139797), SPH_C32(0x0f7d2000), SPH_C32(0xffe4b6d9), + SPH_C32(0x957fa2ed), SPH_C32(0x2d88051a) }, + { SPH_C32(0x18f77000), SPH_C32(0x95247db9), SPH_C32(0x634400d8), + SPH_C32(0x4cf51505), SPH_C32(0xc4d42000), SPH_C32(0x6fc381b0), + SPH_C32(0x2ea356ea), SPH_C32(0xfd7caa7b) }, + { SPH_C32(0xa7cb6000), SPH_C32(0x5f280cae), SPH_C32(0x5065e9f4), + SPH_C32(0x82e738f6), SPH_C32(0xb0413000), SPH_C32(0x35e8c7ce), + SPH_C32(0xa65e4bc1), SPH_C32(0xe39a28e9) }, + { SPH_C32(0xd35e7000), SPH_C32(0x05034ad0), SPH_C32(0xd898f4df), + SPH_C32(0x9c01ba64), SPH_C32(0x7be83000), SPH_C32(0xa5cff0a7), + SPH_C32(0x1d82bfc6), SPH_C32(0x336e8788) }, + { SPH_C32(0xe6570000), SPH_C32(0x4bb33a25), SPH_C32(0x848598ba), + SPH_C32(0x1041003e), SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), + SPH_C32(0x097f5711), SPH_C32(0xde77cc4c) }, + { SPH_C32(0x92c21000), SPH_C32(0x11987c5b), SPH_C32(0x0c788591), + SPH_C32(0x0ea782ac), SPH_C32(0x3fe54000), SPH_C32(0x8083d4a4), + SPH_C32(0xb2a3a316), SPH_C32(0x0e83632d) }, + { SPH_C32(0x2dfe0000), SPH_C32(0xdb940d4c), SPH_C32(0x3f596cbd), + SPH_C32(0xc0b5af5f), SPH_C32(0x4b705000), SPH_C32(0xdaa892da), + SPH_C32(0x3a5ebe3d), SPH_C32(0x1065e1bf) }, + { SPH_C32(0x596b1000), SPH_C32(0x81bf4b32), SPH_C32(0xb7a47196), + SPH_C32(0xde532dcd), SPH_C32(0x80d95000), SPH_C32(0x4a8fa5b3), + SPH_C32(0x81824a3a), SPH_C32(0xc0914ede) }, + { SPH_C32(0x0f7d2000), SPH_C32(0xffe4b6d9), SPH_C32(0x957fa2ed), + SPH_C32(0x2d88051a), SPH_C32(0x631f4000), SPH_C32(0x30eb8d1e), + SPH_C32(0x7ec6bf1e), SPH_C32(0x7f9b928d) }, + { SPH_C32(0x7be83000), SPH_C32(0xa5cff0a7), SPH_C32(0x1d82bfc6), + SPH_C32(0x336e8788), SPH_C32(0xa8b64000), SPH_C32(0xa0ccba77), + SPH_C32(0xc51a4b19), SPH_C32(0xaf6f3dec) }, + { SPH_C32(0xc4d42000), SPH_C32(0x6fc381b0), SPH_C32(0x2ea356ea), + SPH_C32(0xfd7caa7b), SPH_C32(0xdc235000), SPH_C32(0xfae7fc09), + SPH_C32(0x4de75632), SPH_C32(0xb189bf7e) }, + { SPH_C32(0xb0413000), SPH_C32(0x35e8c7ce), SPH_C32(0xa65e4bc1), + SPH_C32(0xe39a28e9), SPH_C32(0x178a5000), SPH_C32(0x6ac0cb60), + SPH_C32(0xf63ba235), SPH_C32(0x617d101f) }, + { SPH_C32(0x71040000), SPH_C32(0x6bfc54f6), SPH_C32(0xf33c70b5), + SPH_C32(0xb1ad5eff), SPH_C32(0x8a356000), SPH_C32(0x84bc01e2), + SPH_C32(0x6f3c8549), SPH_C32(0x425297a9) }, + { SPH_C32(0x05911000), SPH_C32(0x31d71288), SPH_C32(0x7bc16d9e), + SPH_C32(0xaf4bdc6d), SPH_C32(0x419c6000), SPH_C32(0x149b368b), + SPH_C32(0xd4e0714e), SPH_C32(0x92a638c8) }, + { SPH_C32(0xbaad0000), SPH_C32(0xfbdb639f), SPH_C32(0x48e084b2), + SPH_C32(0x6159f19e), SPH_C32(0x35097000), SPH_C32(0x4eb070f5), + SPH_C32(0x5c1d6c65), SPH_C32(0x8c40ba5a) }, + { SPH_C32(0xce381000), SPH_C32(0xa1f025e1), SPH_C32(0xc01d9999), + SPH_C32(0x7fbf730c), SPH_C32(0xfea07000), SPH_C32(0xde97479c), + SPH_C32(0xe7c19862), SPH_C32(0x5cb4153b) }, + { SPH_C32(0x982e2000), SPH_C32(0xdfabd80a), SPH_C32(0xe2c64ae2), + SPH_C32(0x8c645bdb), SPH_C32(0x1d666000), SPH_C32(0xa4f36f31), + SPH_C32(0x18856d46), SPH_C32(0xe3bec968) }, + { SPH_C32(0xecbb3000), SPH_C32(0x85809e74), SPH_C32(0x6a3b57c9), + SPH_C32(0x9282d949), SPH_C32(0xd6cf6000), SPH_C32(0x34d45858), + SPH_C32(0xa3599941), SPH_C32(0x334a6609) }, + { SPH_C32(0x53872000), SPH_C32(0x4f8cef63), SPH_C32(0x591abee5), + SPH_C32(0x5c90f4ba), SPH_C32(0xa25a7000), SPH_C32(0x6eff1e26), + SPH_C32(0x2ba4846a), SPH_C32(0x2dace49b) }, + { SPH_C32(0x27123000), SPH_C32(0x15a7a91d), SPH_C32(0xd1e7a3ce), + SPH_C32(0x42767628), SPH_C32(0x69f37000), SPH_C32(0xfed8294f), + SPH_C32(0x9078706d), SPH_C32(0xfd584bfa) }, + { SPH_C32(0xf44c4000), SPH_C32(0x10a4e3cd), SPH_C32(0x097f5711), + SPH_C32(0xde77cc4c), SPH_C32(0x121b4000), SPH_C32(0x5b17d9e8), + SPH_C32(0x8dfacfab), SPH_C32(0xce36cc72) }, + { SPH_C32(0x80d95000), SPH_C32(0x4a8fa5b3), SPH_C32(0x81824a3a), + SPH_C32(0xc0914ede), SPH_C32(0xd9b24000), SPH_C32(0xcb30ee81), + SPH_C32(0x36263bac), SPH_C32(0x1ec26313) }, + { SPH_C32(0x3fe54000), SPH_C32(0x8083d4a4), SPH_C32(0xb2a3a316), + SPH_C32(0x0e83632d), SPH_C32(0xad275000), SPH_C32(0x911ba8ff), + SPH_C32(0xbedb2687), SPH_C32(0x0024e181) }, + { SPH_C32(0x4b705000), SPH_C32(0xdaa892da), SPH_C32(0x3a5ebe3d), + SPH_C32(0x1065e1bf), SPH_C32(0x668e5000), SPH_C32(0x013c9f96), + SPH_C32(0x0507d280), SPH_C32(0xd0d04ee0) }, + { SPH_C32(0x1d666000), SPH_C32(0xa4f36f31), SPH_C32(0x18856d46), + SPH_C32(0xe3bec968), SPH_C32(0x85484000), SPH_C32(0x7b58b73b), + SPH_C32(0xfa4327a4), SPH_C32(0x6fda92b3) }, + { SPH_C32(0x69f37000), SPH_C32(0xfed8294f), SPH_C32(0x9078706d), + SPH_C32(0xfd584bfa), SPH_C32(0x4ee14000), SPH_C32(0xeb7f8052), + SPH_C32(0x419fd3a3), SPH_C32(0xbf2e3dd2) }, + { SPH_C32(0xd6cf6000), SPH_C32(0x34d45858), SPH_C32(0xa3599941), + SPH_C32(0x334a6609), SPH_C32(0x3a745000), SPH_C32(0xb154c62c), + SPH_C32(0xc962ce88), SPH_C32(0xa1c8bf40) }, + { SPH_C32(0xa25a7000), SPH_C32(0x6eff1e26), SPH_C32(0x2ba4846a), + SPH_C32(0x2dace49b), SPH_C32(0xf1dd5000), SPH_C32(0x2173f145), + SPH_C32(0x72be3a8f), SPH_C32(0x713c1021) }, + { SPH_C32(0x631f4000), SPH_C32(0x30eb8d1e), SPH_C32(0x7ec6bf1e), + SPH_C32(0x7f9b928d), SPH_C32(0x6c626000), SPH_C32(0xcf0f3bc7), + SPH_C32(0xebb91df3), SPH_C32(0x52139797) }, + { SPH_C32(0x178a5000), SPH_C32(0x6ac0cb60), SPH_C32(0xf63ba235), + SPH_C32(0x617d101f), SPH_C32(0xa7cb6000), SPH_C32(0x5f280cae), + SPH_C32(0x5065e9f4), SPH_C32(0x82e738f6) }, + { SPH_C32(0xa8b64000), SPH_C32(0xa0ccba77), SPH_C32(0xc51a4b19), + SPH_C32(0xaf6f3dec), SPH_C32(0xd35e7000), SPH_C32(0x05034ad0), + SPH_C32(0xd898f4df), SPH_C32(0x9c01ba64) }, + { SPH_C32(0xdc235000), SPH_C32(0xfae7fc09), SPH_C32(0x4de75632), + SPH_C32(0xb189bf7e), SPH_C32(0x18f77000), SPH_C32(0x95247db9), + SPH_C32(0x634400d8), SPH_C32(0x4cf51505) }, + { SPH_C32(0x8a356000), SPH_C32(0x84bc01e2), SPH_C32(0x6f3c8549), + SPH_C32(0x425297a9), SPH_C32(0xfb316000), SPH_C32(0xef405514), + SPH_C32(0x9c00f5fc), SPH_C32(0xf3ffc956) }, + { SPH_C32(0xfea07000), SPH_C32(0xde97479c), SPH_C32(0xe7c19862), + SPH_C32(0x5cb4153b), SPH_C32(0x30986000), SPH_C32(0x7f67627d), + SPH_C32(0x27dc01fb), SPH_C32(0x230b6637) }, + { SPH_C32(0x419c6000), SPH_C32(0x149b368b), SPH_C32(0xd4e0714e), + SPH_C32(0x92a638c8), SPH_C32(0x440d7000), SPH_C32(0x254c2403), + SPH_C32(0xaf211cd0), SPH_C32(0x3dede4a5) }, + { SPH_C32(0x35097000), SPH_C32(0x4eb070f5), SPH_C32(0x5c1d6c65), + SPH_C32(0x8c40ba5a), SPH_C32(0x8fa47000), SPH_C32(0xb56b136a), + SPH_C32(0x14fde8d7), SPH_C32(0xed194bc4) }, + { SPH_C32(0xe4788000), SPH_C32(0x859673c1), SPH_C32(0xb5fb2452), + SPH_C32(0x29cc5edf), SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), + SPH_C32(0x62fc79d0), SPH_C32(0x731ebdc2) }, + { SPH_C32(0x90ed9000), SPH_C32(0xdfbd35bf), SPH_C32(0x3d063979), + SPH_C32(0x372adc4d), SPH_C32(0xcff60000), SPH_C32(0x0c6da4a0), + SPH_C32(0xd9208dd7), SPH_C32(0xa3ea12a3) }, + { SPH_C32(0x2fd18000), SPH_C32(0x15b144a8), SPH_C32(0x0e27d055), + SPH_C32(0xf938f1be), SPH_C32(0xbb631000), SPH_C32(0x5646e2de), + SPH_C32(0x51dd90fc), SPH_C32(0xbd0c9031) }, + { SPH_C32(0x5b449000), SPH_C32(0x4f9a02d6), SPH_C32(0x86dacd7e), + SPH_C32(0xe7de732c), SPH_C32(0x70ca1000), SPH_C32(0xc661d5b7), + SPH_C32(0xea0164fb), SPH_C32(0x6df83f50) }, + { SPH_C32(0x0d52a000), SPH_C32(0x31c1ff3d), SPH_C32(0xa4011e05), + SPH_C32(0x14055bfb), SPH_C32(0x930c0000), SPH_C32(0xbc05fd1a), + SPH_C32(0x154591df), SPH_C32(0xd2f2e303) }, + { SPH_C32(0x79c7b000), SPH_C32(0x6beab943), SPH_C32(0x2cfc032e), + SPH_C32(0x0ae3d969), SPH_C32(0x58a50000), SPH_C32(0x2c22ca73), + SPH_C32(0xae9965d8), SPH_C32(0x02064c62) }, + { SPH_C32(0xc6fba000), SPH_C32(0xa1e6c854), SPH_C32(0x1fddea02), + SPH_C32(0xc4f1f49a), SPH_C32(0x2c301000), SPH_C32(0x76098c0d), + SPH_C32(0x266478f3), SPH_C32(0x1ce0cef0) }, + { SPH_C32(0xb26eb000), SPH_C32(0xfbcd8e2a), SPH_C32(0x9720f729), + SPH_C32(0xda177608), SPH_C32(0xe7991000), SPH_C32(0xe62ebb64), + SPH_C32(0x9db88cf4), SPH_C32(0xcc146191) }, + { SPH_C32(0x732b8000), SPH_C32(0xa5d91d12), SPH_C32(0xc242cc5d), + SPH_C32(0x8820001e), SPH_C32(0x7a262000), SPH_C32(0x085271e6), + SPH_C32(0x04bfab88), SPH_C32(0xef3be627) }, + { SPH_C32(0x07be9000), SPH_C32(0xfff25b6c), SPH_C32(0x4abfd176), + SPH_C32(0x96c6828c), SPH_C32(0xb18f2000), SPH_C32(0x9875468f), + SPH_C32(0xbf635f8f), SPH_C32(0x3fcf4946) }, + { SPH_C32(0xb8828000), SPH_C32(0x35fe2a7b), SPH_C32(0x799e385a), + SPH_C32(0x58d4af7f), SPH_C32(0xc51a3000), SPH_C32(0xc25e00f1), + SPH_C32(0x379e42a4), SPH_C32(0x2129cbd4) }, + { SPH_C32(0xcc179000), SPH_C32(0x6fd56c05), SPH_C32(0xf1632571), + SPH_C32(0x46322ded), SPH_C32(0x0eb33000), SPH_C32(0x52793798), + SPH_C32(0x8c42b6a3), SPH_C32(0xf1dd64b5) }, + { SPH_C32(0x9a01a000), SPH_C32(0x118e91ee), SPH_C32(0xd3b8f60a), + SPH_C32(0xb5e9053a), SPH_C32(0xed752000), SPH_C32(0x281d1f35), + SPH_C32(0x73064387), SPH_C32(0x4ed7b8e6) }, + { SPH_C32(0xee94b000), SPH_C32(0x4ba5d790), SPH_C32(0x5b45eb21), + SPH_C32(0xab0f87a8), SPH_C32(0x26dc2000), SPH_C32(0xb83a285c), + SPH_C32(0xc8dab780), SPH_C32(0x9e231787) }, + { SPH_C32(0x51a8a000), SPH_C32(0x81a9a687), SPH_C32(0x6864020d), + SPH_C32(0x651daa5b), SPH_C32(0x52493000), SPH_C32(0xe2116e22), + SPH_C32(0x4027aaab), SPH_C32(0x80c59515) }, + { SPH_C32(0x253db000), SPH_C32(0xdb82e0f9), SPH_C32(0xe0991f26), + SPH_C32(0x7bfb28c9), SPH_C32(0x99e03000), SPH_C32(0x7236594b), + SPH_C32(0xfbfb5eac), SPH_C32(0x50313a74) }, + { SPH_C32(0xf663c000), SPH_C32(0xde81aa29), SPH_C32(0x3801ebf9), + SPH_C32(0xe7fa92ad), SPH_C32(0xe2080000), SPH_C32(0xd7f9a9ec), + SPH_C32(0xe679e16a), SPH_C32(0x635fbdfc) }, + { SPH_C32(0x82f6d000), SPH_C32(0x84aaec57), SPH_C32(0xb0fcf6d2), + SPH_C32(0xf91c103f), SPH_C32(0x29a10000), SPH_C32(0x47de9e85), + SPH_C32(0x5da5156d), SPH_C32(0xb3ab129d) }, + { SPH_C32(0x3dcac000), SPH_C32(0x4ea69d40), SPH_C32(0x83dd1ffe), + SPH_C32(0x370e3dcc), SPH_C32(0x5d341000), SPH_C32(0x1df5d8fb), + SPH_C32(0xd5580846), SPH_C32(0xad4d900f) }, + { SPH_C32(0x495fd000), SPH_C32(0x148ddb3e), SPH_C32(0x0b2002d5), + SPH_C32(0x29e8bf5e), SPH_C32(0x969d1000), SPH_C32(0x8dd2ef92), + SPH_C32(0x6e84fc41), SPH_C32(0x7db93f6e) }, + { SPH_C32(0x1f49e000), SPH_C32(0x6ad626d5), SPH_C32(0x29fbd1ae), + SPH_C32(0xda339789), SPH_C32(0x755b0000), SPH_C32(0xf7b6c73f), + SPH_C32(0x91c00965), SPH_C32(0xc2b3e33d) }, + { SPH_C32(0x6bdcf000), SPH_C32(0x30fd60ab), SPH_C32(0xa106cc85), + SPH_C32(0xc4d5151b), SPH_C32(0xbef20000), SPH_C32(0x6791f056), + SPH_C32(0x2a1cfd62), SPH_C32(0x12474c5c) }, + { SPH_C32(0xd4e0e000), SPH_C32(0xfaf111bc), SPH_C32(0x922725a9), + SPH_C32(0x0ac738e8), SPH_C32(0xca671000), SPH_C32(0x3dbab628), + SPH_C32(0xa2e1e049), SPH_C32(0x0ca1cece) }, + { SPH_C32(0xa075f000), SPH_C32(0xa0da57c2), SPH_C32(0x1ada3882), + SPH_C32(0x1421ba7a), SPH_C32(0x01ce1000), SPH_C32(0xad9d8141), + SPH_C32(0x193d144e), SPH_C32(0xdc5561af) }, + { SPH_C32(0x6130c000), SPH_C32(0xfecec4fa), SPH_C32(0x4fb803f6), + SPH_C32(0x4616cc6c), SPH_C32(0x9c712000), SPH_C32(0x43e14bc3), + SPH_C32(0x803a3332), SPH_C32(0xff7ae619) }, + { SPH_C32(0x15a5d000), SPH_C32(0xa4e58284), SPH_C32(0xc7451edd), + SPH_C32(0x58f04efe), SPH_C32(0x57d82000), SPH_C32(0xd3c67caa), + SPH_C32(0x3be6c735), SPH_C32(0x2f8e4978) }, + { SPH_C32(0xaa99c000), SPH_C32(0x6ee9f393), SPH_C32(0xf464f7f1), + SPH_C32(0x96e2630d), SPH_C32(0x234d3000), SPH_C32(0x89ed3ad4), + SPH_C32(0xb31bda1e), SPH_C32(0x3168cbea) }, + { SPH_C32(0xde0cd000), SPH_C32(0x34c2b5ed), SPH_C32(0x7c99eada), + SPH_C32(0x8804e19f), SPH_C32(0xe8e43000), SPH_C32(0x19ca0dbd), + SPH_C32(0x08c72e19), SPH_C32(0xe19c648b) }, + { SPH_C32(0x881ae000), SPH_C32(0x4a994806), SPH_C32(0x5e4239a1), + SPH_C32(0x7bdfc948), SPH_C32(0x0b222000), SPH_C32(0x63ae2510), + SPH_C32(0xf783db3d), SPH_C32(0x5e96b8d8) }, + { SPH_C32(0xfc8ff000), SPH_C32(0x10b20e78), SPH_C32(0xd6bf248a), + SPH_C32(0x65394bda), SPH_C32(0xc08b2000), SPH_C32(0xf3891279), + SPH_C32(0x4c5f2f3a), SPH_C32(0x8e6217b9) }, + { SPH_C32(0x43b3e000), SPH_C32(0xdabe7f6f), SPH_C32(0xe59ecda6), + SPH_C32(0xab2b6629), SPH_C32(0xb41e3000), SPH_C32(0xa9a25407), + SPH_C32(0xc4a23211), SPH_C32(0x9084952b) }, + { SPH_C32(0x3726f000), SPH_C32(0x80953911), SPH_C32(0x6d63d08d), + SPH_C32(0xb5cde4bb), SPH_C32(0x7fb73000), SPH_C32(0x3985636e), + SPH_C32(0x7f7ec616), SPH_C32(0x40703a4a) }, + { SPH_C32(0x022f8000), SPH_C32(0xce2549e4), SPH_C32(0x317ebce8), + SPH_C32(0x398d5ee1), SPH_C32(0xf0134000), SPH_C32(0x8cee7004), + SPH_C32(0x6b832ec1), SPH_C32(0xad69718e) }, + { SPH_C32(0x76ba9000), SPH_C32(0x940e0f9a), SPH_C32(0xb983a1c3), + SPH_C32(0x276bdc73), SPH_C32(0x3bba4000), SPH_C32(0x1cc9476d), + SPH_C32(0xd05fdac6), SPH_C32(0x7d9ddeef) }, + { SPH_C32(0xc9868000), SPH_C32(0x5e027e8d), SPH_C32(0x8aa248ef), + SPH_C32(0xe979f180), SPH_C32(0x4f2f5000), SPH_C32(0x46e20113), + SPH_C32(0x58a2c7ed), SPH_C32(0x637b5c7d) }, + { SPH_C32(0xbd139000), SPH_C32(0x042938f3), SPH_C32(0x025f55c4), + SPH_C32(0xf79f7312), SPH_C32(0x84865000), SPH_C32(0xd6c5367a), + SPH_C32(0xe37e33ea), SPH_C32(0xb38ff31c) }, + { SPH_C32(0xeb05a000), SPH_C32(0x7a72c518), SPH_C32(0x208486bf), + SPH_C32(0x04445bc5), SPH_C32(0x67404000), SPH_C32(0xaca11ed7), + SPH_C32(0x1c3ac6ce), SPH_C32(0x0c852f4f) }, + { SPH_C32(0x9f90b000), SPH_C32(0x20598366), SPH_C32(0xa8799b94), + SPH_C32(0x1aa2d957), SPH_C32(0xace94000), SPH_C32(0x3c8629be), + SPH_C32(0xa7e632c9), SPH_C32(0xdc71802e) }, + { SPH_C32(0x20aca000), SPH_C32(0xea55f271), SPH_C32(0x9b5872b8), + SPH_C32(0xd4b0f4a4), SPH_C32(0xd87c5000), SPH_C32(0x66ad6fc0), + SPH_C32(0x2f1b2fe2), SPH_C32(0xc29702bc) }, + { SPH_C32(0x5439b000), SPH_C32(0xb07eb40f), SPH_C32(0x13a56f93), + SPH_C32(0xca567636), SPH_C32(0x13d55000), SPH_C32(0xf68a58a9), + SPH_C32(0x94c7dbe5), SPH_C32(0x1263addd) }, + { SPH_C32(0x957c8000), SPH_C32(0xee6a2737), SPH_C32(0x46c754e7), + SPH_C32(0x98610020), SPH_C32(0x8e6a6000), SPH_C32(0x18f6922b), + SPH_C32(0x0dc0fc99), SPH_C32(0x314c2a6b) }, + { SPH_C32(0xe1e99000), SPH_C32(0xb4416149), SPH_C32(0xce3a49cc), + SPH_C32(0x868782b2), SPH_C32(0x45c36000), SPH_C32(0x88d1a542), + SPH_C32(0xb61c089e), SPH_C32(0xe1b8850a) }, + { SPH_C32(0x5ed58000), SPH_C32(0x7e4d105e), SPH_C32(0xfd1ba0e0), + SPH_C32(0x4895af41), SPH_C32(0x31567000), SPH_C32(0xd2fae33c), + SPH_C32(0x3ee115b5), SPH_C32(0xff5e0798) }, + { SPH_C32(0x2a409000), SPH_C32(0x24665620), SPH_C32(0x75e6bdcb), + SPH_C32(0x56732dd3), SPH_C32(0xfaff7000), SPH_C32(0x42ddd455), + SPH_C32(0x853de1b2), SPH_C32(0x2faaa8f9) }, + { SPH_C32(0x7c56a000), SPH_C32(0x5a3dabcb), SPH_C32(0x573d6eb0), + SPH_C32(0xa5a80504), SPH_C32(0x19396000), SPH_C32(0x38b9fcf8), + SPH_C32(0x7a791496), SPH_C32(0x90a074aa) }, + { SPH_C32(0x08c3b000), SPH_C32(0x0016edb5), SPH_C32(0xdfc0739b), + SPH_C32(0xbb4e8796), SPH_C32(0xd2906000), SPH_C32(0xa89ecb91), + SPH_C32(0xc1a5e091), SPH_C32(0x4054dbcb) }, + { SPH_C32(0xb7ffa000), SPH_C32(0xca1a9ca2), SPH_C32(0xece19ab7), + SPH_C32(0x755caa65), SPH_C32(0xa6057000), SPH_C32(0xf2b58def), + SPH_C32(0x4958fdba), SPH_C32(0x5eb25959) }, + { SPH_C32(0xc36ab000), SPH_C32(0x9031dadc), SPH_C32(0x641c879c), + SPH_C32(0x6bba28f7), SPH_C32(0x6dac7000), SPH_C32(0x6292ba86), + SPH_C32(0xf28409bd), SPH_C32(0x8e46f638) }, + { SPH_C32(0x1034c000), SPH_C32(0x9532900c), SPH_C32(0xbc847343), + SPH_C32(0xf7bb9293), SPH_C32(0x16444000), SPH_C32(0xc75d4a21), + SPH_C32(0xef06b67b), SPH_C32(0xbd2871b0) }, + { SPH_C32(0x64a1d000), SPH_C32(0xcf19d672), SPH_C32(0x34796e68), + SPH_C32(0xe95d1001), SPH_C32(0xdded4000), SPH_C32(0x577a7d48), + SPH_C32(0x54da427c), SPH_C32(0x6ddcded1) }, + { SPH_C32(0xdb9dc000), SPH_C32(0x0515a765), SPH_C32(0x07588744), + SPH_C32(0x274f3df2), SPH_C32(0xa9785000), SPH_C32(0x0d513b36), + SPH_C32(0xdc275f57), SPH_C32(0x733a5c43) }, + { SPH_C32(0xaf08d000), SPH_C32(0x5f3ee11b), SPH_C32(0x8fa59a6f), + SPH_C32(0x39a9bf60), SPH_C32(0x62d15000), SPH_C32(0x9d760c5f), + SPH_C32(0x67fbab50), SPH_C32(0xa3cef322) }, + { SPH_C32(0xf91ee000), SPH_C32(0x21651cf0), SPH_C32(0xad7e4914), + SPH_C32(0xca7297b7), SPH_C32(0x81174000), SPH_C32(0xe71224f2), + SPH_C32(0x98bf5e74), SPH_C32(0x1cc42f71) }, + { SPH_C32(0x8d8bf000), SPH_C32(0x7b4e5a8e), SPH_C32(0x2583543f), + SPH_C32(0xd4941525), SPH_C32(0x4abe4000), SPH_C32(0x7735139b), + SPH_C32(0x2363aa73), SPH_C32(0xcc308010) }, + { SPH_C32(0x32b7e000), SPH_C32(0xb1422b99), SPH_C32(0x16a2bd13), + SPH_C32(0x1a8638d6), SPH_C32(0x3e2b5000), SPH_C32(0x2d1e55e5), + SPH_C32(0xab9eb758), SPH_C32(0xd2d60282) }, + { SPH_C32(0x4622f000), SPH_C32(0xeb696de7), SPH_C32(0x9e5fa038), + SPH_C32(0x0460ba44), SPH_C32(0xf5825000), SPH_C32(0xbd39628c), + SPH_C32(0x1042435f), SPH_C32(0x0222ade3) }, + { SPH_C32(0x8767c000), SPH_C32(0xb57dfedf), SPH_C32(0xcb3d9b4c), + SPH_C32(0x5657cc52), SPH_C32(0x683d6000), SPH_C32(0x5345a80e), + SPH_C32(0x89456423), SPH_C32(0x210d2a55) }, + { SPH_C32(0xf3f2d000), SPH_C32(0xef56b8a1), SPH_C32(0x43c08667), + SPH_C32(0x48b14ec0), SPH_C32(0xa3946000), SPH_C32(0xc3629f67), + SPH_C32(0x32999024), SPH_C32(0xf1f98534) }, + { SPH_C32(0x4ccec000), SPH_C32(0x255ac9b6), SPH_C32(0x70e16f4b), + SPH_C32(0x86a36333), SPH_C32(0xd7017000), SPH_C32(0x9949d919), + SPH_C32(0xba648d0f), SPH_C32(0xef1f07a6) }, + { SPH_C32(0x385bd000), SPH_C32(0x7f718fc8), SPH_C32(0xf81c7260), + SPH_C32(0x9845e1a1), SPH_C32(0x1ca87000), SPH_C32(0x096eee70), + SPH_C32(0x01b87908), SPH_C32(0x3feba8c7) }, + { SPH_C32(0x6e4de000), SPH_C32(0x012a7223), SPH_C32(0xdac7a11b), + SPH_C32(0x6b9ec976), SPH_C32(0xff6e6000), SPH_C32(0x730ac6dd), + SPH_C32(0xfefc8c2c), SPH_C32(0x80e17494) }, + { SPH_C32(0x1ad8f000), SPH_C32(0x5b01345d), SPH_C32(0x523abc30), + SPH_C32(0x75784be4), SPH_C32(0x34c76000), SPH_C32(0xe32df1b4), + SPH_C32(0x4520782b), SPH_C32(0x5015dbf5) }, + { SPH_C32(0xa5e4e000), SPH_C32(0x910d454a), SPH_C32(0x611b551c), + SPH_C32(0xbb6a6617), SPH_C32(0x40527000), SPH_C32(0xb906b7ca), + SPH_C32(0xcddd6500), SPH_C32(0x4ef35967) }, + { SPH_C32(0xd171f000), SPH_C32(0xcb260334), SPH_C32(0xe9e64837), + SPH_C32(0xa58ce485), SPH_C32(0x8bfb7000), SPH_C32(0x292180a3), + SPH_C32(0x76019107), SPH_C32(0x9e07f606) }, + { SPH_C32(0x045f0000), SPH_C32(0x9c4a93c9), SPH_C32(0x62fc79d0), + SPH_C32(0x731ebdc2), SPH_C32(0xe0278000), SPH_C32(0x19dce008), + SPH_C32(0xd7075d82), SPH_C32(0x5ad2e31d) }, + { SPH_C32(0x70ca1000), SPH_C32(0xc661d5b7), SPH_C32(0xea0164fb), + SPH_C32(0x6df83f50), SPH_C32(0x2b8e8000), SPH_C32(0x89fbd761), + SPH_C32(0x6cdba985), SPH_C32(0x8a264c7c) }, + { SPH_C32(0xcff60000), SPH_C32(0x0c6da4a0), SPH_C32(0xd9208dd7), + SPH_C32(0xa3ea12a3), SPH_C32(0x5f1b9000), SPH_C32(0xd3d0911f), + SPH_C32(0xe426b4ae), SPH_C32(0x94c0ceee) }, + { SPH_C32(0xbb631000), SPH_C32(0x5646e2de), SPH_C32(0x51dd90fc), + SPH_C32(0xbd0c9031), SPH_C32(0x94b29000), SPH_C32(0x43f7a676), + SPH_C32(0x5ffa40a9), SPH_C32(0x4434618f) }, + { SPH_C32(0xed752000), SPH_C32(0x281d1f35), SPH_C32(0x73064387), + SPH_C32(0x4ed7b8e6), SPH_C32(0x77748000), SPH_C32(0x39938edb), + SPH_C32(0xa0beb58d), SPH_C32(0xfb3ebddc) }, + { SPH_C32(0x99e03000), SPH_C32(0x7236594b), SPH_C32(0xfbfb5eac), + SPH_C32(0x50313a74), SPH_C32(0xbcdd8000), SPH_C32(0xa9b4b9b2), + SPH_C32(0x1b62418a), SPH_C32(0x2bca12bd) }, + { SPH_C32(0x26dc2000), SPH_C32(0xb83a285c), SPH_C32(0xc8dab780), + SPH_C32(0x9e231787), SPH_C32(0xc8489000), SPH_C32(0xf39fffcc), + SPH_C32(0x939f5ca1), SPH_C32(0x352c902f) }, + { SPH_C32(0x52493000), SPH_C32(0xe2116e22), SPH_C32(0x4027aaab), + SPH_C32(0x80c59515), SPH_C32(0x03e19000), SPH_C32(0x63b8c8a5), + SPH_C32(0x2843a8a6), SPH_C32(0xe5d83f4e) }, + { SPH_C32(0x930c0000), SPH_C32(0xbc05fd1a), SPH_C32(0x154591df), + SPH_C32(0xd2f2e303), SPH_C32(0x9e5ea000), SPH_C32(0x8dc40227), + SPH_C32(0xb1448fda), SPH_C32(0xc6f7b8f8) }, + { SPH_C32(0xe7991000), SPH_C32(0xe62ebb64), SPH_C32(0x9db88cf4), + SPH_C32(0xcc146191), SPH_C32(0x55f7a000), SPH_C32(0x1de3354e), + SPH_C32(0x0a987bdd), SPH_C32(0x16031799) }, + { SPH_C32(0x58a50000), SPH_C32(0x2c22ca73), SPH_C32(0xae9965d8), + SPH_C32(0x02064c62), SPH_C32(0x2162b000), SPH_C32(0x47c87330), + SPH_C32(0x826566f6), SPH_C32(0x08e5950b) }, + { SPH_C32(0x2c301000), SPH_C32(0x76098c0d), SPH_C32(0x266478f3), + SPH_C32(0x1ce0cef0), SPH_C32(0xeacbb000), SPH_C32(0xd7ef4459), + SPH_C32(0x39b992f1), SPH_C32(0xd8113a6a) }, + { SPH_C32(0x7a262000), SPH_C32(0x085271e6), SPH_C32(0x04bfab88), + SPH_C32(0xef3be627), SPH_C32(0x090da000), SPH_C32(0xad8b6cf4), + SPH_C32(0xc6fd67d5), SPH_C32(0x671be639) }, + { SPH_C32(0x0eb33000), SPH_C32(0x52793798), SPH_C32(0x8c42b6a3), + SPH_C32(0xf1dd64b5), SPH_C32(0xc2a4a000), SPH_C32(0x3dac5b9d), + SPH_C32(0x7d2193d2), SPH_C32(0xb7ef4958) }, + { SPH_C32(0xb18f2000), SPH_C32(0x9875468f), SPH_C32(0xbf635f8f), + SPH_C32(0x3fcf4946), SPH_C32(0xb631b000), SPH_C32(0x67871de3), + SPH_C32(0xf5dc8ef9), SPH_C32(0xa909cbca) }, + { SPH_C32(0xc51a3000), SPH_C32(0xc25e00f1), SPH_C32(0x379e42a4), + SPH_C32(0x2129cbd4), SPH_C32(0x7d98b000), SPH_C32(0xf7a02a8a), + SPH_C32(0x4e007afe), SPH_C32(0x79fd64ab) }, + { SPH_C32(0x16444000), SPH_C32(0xc75d4a21), SPH_C32(0xef06b67b), + SPH_C32(0xbd2871b0), SPH_C32(0x06708000), SPH_C32(0x526fda2d), + SPH_C32(0x5382c538), SPH_C32(0x4a93e323) }, + { SPH_C32(0x62d15000), SPH_C32(0x9d760c5f), SPH_C32(0x67fbab50), + SPH_C32(0xa3cef322), SPH_C32(0xcdd98000), SPH_C32(0xc248ed44), + SPH_C32(0xe85e313f), SPH_C32(0x9a674c42) }, + { SPH_C32(0xdded4000), SPH_C32(0x577a7d48), SPH_C32(0x54da427c), + SPH_C32(0x6ddcded1), SPH_C32(0xb94c9000), SPH_C32(0x9863ab3a), + SPH_C32(0x60a32c14), SPH_C32(0x8481ced0) }, + { SPH_C32(0xa9785000), SPH_C32(0x0d513b36), SPH_C32(0xdc275f57), + SPH_C32(0x733a5c43), SPH_C32(0x72e59000), SPH_C32(0x08449c53), + SPH_C32(0xdb7fd813), SPH_C32(0x547561b1) }, + { SPH_C32(0xff6e6000), SPH_C32(0x730ac6dd), SPH_C32(0xfefc8c2c), + SPH_C32(0x80e17494), SPH_C32(0x91238000), SPH_C32(0x7220b4fe), + SPH_C32(0x243b2d37), SPH_C32(0xeb7fbde2) }, + { SPH_C32(0x8bfb7000), SPH_C32(0x292180a3), SPH_C32(0x76019107), + SPH_C32(0x9e07f606), SPH_C32(0x5a8a8000), SPH_C32(0xe2078397), + SPH_C32(0x9fe7d930), SPH_C32(0x3b8b1283) }, + { SPH_C32(0x34c76000), SPH_C32(0xe32df1b4), SPH_C32(0x4520782b), + SPH_C32(0x5015dbf5), SPH_C32(0x2e1f9000), SPH_C32(0xb82cc5e9), + SPH_C32(0x171ac41b), SPH_C32(0x256d9011) }, + { SPH_C32(0x40527000), SPH_C32(0xb906b7ca), SPH_C32(0xcddd6500), + SPH_C32(0x4ef35967), SPH_C32(0xe5b69000), SPH_C32(0x280bf280), + SPH_C32(0xacc6301c), SPH_C32(0xf5993f70) }, + { SPH_C32(0x81174000), SPH_C32(0xe71224f2), SPH_C32(0x98bf5e74), + SPH_C32(0x1cc42f71), SPH_C32(0x7809a000), SPH_C32(0xc6773802), + SPH_C32(0x35c11760), SPH_C32(0xd6b6b8c6) }, + { SPH_C32(0xf5825000), SPH_C32(0xbd39628c), SPH_C32(0x1042435f), + SPH_C32(0x0222ade3), SPH_C32(0xb3a0a000), SPH_C32(0x56500f6b), + SPH_C32(0x8e1de367), SPH_C32(0x064217a7) }, + { SPH_C32(0x4abe4000), SPH_C32(0x7735139b), SPH_C32(0x2363aa73), + SPH_C32(0xcc308010), SPH_C32(0xc735b000), SPH_C32(0x0c7b4915), + SPH_C32(0x06e0fe4c), SPH_C32(0x18a49535) }, + { SPH_C32(0x3e2b5000), SPH_C32(0x2d1e55e5), SPH_C32(0xab9eb758), + SPH_C32(0xd2d60282), SPH_C32(0x0c9cb000), SPH_C32(0x9c5c7e7c), + SPH_C32(0xbd3c0a4b), SPH_C32(0xc8503a54) }, + { SPH_C32(0x683d6000), SPH_C32(0x5345a80e), SPH_C32(0x89456423), + SPH_C32(0x210d2a55), SPH_C32(0xef5aa000), SPH_C32(0xe63856d1), + SPH_C32(0x4278ff6f), SPH_C32(0x775ae607) }, + { SPH_C32(0x1ca87000), SPH_C32(0x096eee70), SPH_C32(0x01b87908), + SPH_C32(0x3feba8c7), SPH_C32(0x24f3a000), SPH_C32(0x761f61b8), + SPH_C32(0xf9a40b68), SPH_C32(0xa7ae4966) }, + { SPH_C32(0xa3946000), SPH_C32(0xc3629f67), SPH_C32(0x32999024), + SPH_C32(0xf1f98534), SPH_C32(0x5066b000), SPH_C32(0x2c3427c6), + SPH_C32(0x71591643), SPH_C32(0xb948cbf4) }, + { SPH_C32(0xd7017000), SPH_C32(0x9949d919), SPH_C32(0xba648d0f), + SPH_C32(0xef1f07a6), SPH_C32(0x9bcfb000), SPH_C32(0xbc1310af), + SPH_C32(0xca85e244), SPH_C32(0x69bc6495) }, + { SPH_C32(0xe2080000), SPH_C32(0xd7f9a9ec), SPH_C32(0xe679e16a), + SPH_C32(0x635fbdfc), SPH_C32(0x146bc000), SPH_C32(0x097803c5), + SPH_C32(0xde780a93), SPH_C32(0x84a52f51) }, + { SPH_C32(0x969d1000), SPH_C32(0x8dd2ef92), SPH_C32(0x6e84fc41), + SPH_C32(0x7db93f6e), SPH_C32(0xdfc2c000), SPH_C32(0x995f34ac), + SPH_C32(0x65a4fe94), SPH_C32(0x54518030) }, + { SPH_C32(0x29a10000), SPH_C32(0x47de9e85), SPH_C32(0x5da5156d), + SPH_C32(0xb3ab129d), SPH_C32(0xab57d000), SPH_C32(0xc37472d2), + SPH_C32(0xed59e3bf), SPH_C32(0x4ab702a2) }, + { SPH_C32(0x5d341000), SPH_C32(0x1df5d8fb), SPH_C32(0xd5580846), + SPH_C32(0xad4d900f), SPH_C32(0x60fed000), SPH_C32(0x535345bb), + SPH_C32(0x568517b8), SPH_C32(0x9a43adc3) }, + { SPH_C32(0x0b222000), SPH_C32(0x63ae2510), SPH_C32(0xf783db3d), + SPH_C32(0x5e96b8d8), SPH_C32(0x8338c000), SPH_C32(0x29376d16), + SPH_C32(0xa9c1e29c), SPH_C32(0x25497190) }, + { SPH_C32(0x7fb73000), SPH_C32(0x3985636e), SPH_C32(0x7f7ec616), + SPH_C32(0x40703a4a), SPH_C32(0x4891c000), SPH_C32(0xb9105a7f), + SPH_C32(0x121d169b), SPH_C32(0xf5bddef1) }, + { SPH_C32(0xc08b2000), SPH_C32(0xf3891279), SPH_C32(0x4c5f2f3a), + SPH_C32(0x8e6217b9), SPH_C32(0x3c04d000), SPH_C32(0xe33b1c01), + SPH_C32(0x9ae00bb0), SPH_C32(0xeb5b5c63) }, + { SPH_C32(0xb41e3000), SPH_C32(0xa9a25407), SPH_C32(0xc4a23211), + SPH_C32(0x9084952b), SPH_C32(0xf7add000), SPH_C32(0x731c2b68), + SPH_C32(0x213cffb7), SPH_C32(0x3baff302) }, + { SPH_C32(0x755b0000), SPH_C32(0xf7b6c73f), SPH_C32(0x91c00965), + SPH_C32(0xc2b3e33d), SPH_C32(0x6a12e000), SPH_C32(0x9d60e1ea), + SPH_C32(0xb83bd8cb), SPH_C32(0x188074b4) }, + { SPH_C32(0x01ce1000), SPH_C32(0xad9d8141), SPH_C32(0x193d144e), + SPH_C32(0xdc5561af), SPH_C32(0xa1bbe000), SPH_C32(0x0d47d683), + SPH_C32(0x03e72ccc), SPH_C32(0xc874dbd5) }, + { SPH_C32(0xbef20000), SPH_C32(0x6791f056), SPH_C32(0x2a1cfd62), + SPH_C32(0x12474c5c), SPH_C32(0xd52ef000), SPH_C32(0x576c90fd), + SPH_C32(0x8b1a31e7), SPH_C32(0xd6925947) }, + { SPH_C32(0xca671000), SPH_C32(0x3dbab628), SPH_C32(0xa2e1e049), + SPH_C32(0x0ca1cece), SPH_C32(0x1e87f000), SPH_C32(0xc74ba794), + SPH_C32(0x30c6c5e0), SPH_C32(0x0666f626) }, + { SPH_C32(0x9c712000), SPH_C32(0x43e14bc3), SPH_C32(0x803a3332), + SPH_C32(0xff7ae619), SPH_C32(0xfd41e000), SPH_C32(0xbd2f8f39), + SPH_C32(0xcf8230c4), SPH_C32(0xb96c2a75) }, + { SPH_C32(0xe8e43000), SPH_C32(0x19ca0dbd), SPH_C32(0x08c72e19), + SPH_C32(0xe19c648b), SPH_C32(0x36e8e000), SPH_C32(0x2d08b850), + SPH_C32(0x745ec4c3), SPH_C32(0x69988514) }, + { SPH_C32(0x57d82000), SPH_C32(0xd3c67caa), SPH_C32(0x3be6c735), + SPH_C32(0x2f8e4978), SPH_C32(0x427df000), SPH_C32(0x7723fe2e), + SPH_C32(0xfca3d9e8), SPH_C32(0x777e0786) }, + { SPH_C32(0x234d3000), SPH_C32(0x89ed3ad4), SPH_C32(0xb31bda1e), + SPH_C32(0x3168cbea), SPH_C32(0x89d4f000), SPH_C32(0xe704c947), + SPH_C32(0x477f2def), SPH_C32(0xa78aa8e7) }, + { SPH_C32(0xf0134000), SPH_C32(0x8cee7004), SPH_C32(0x6b832ec1), + SPH_C32(0xad69718e), SPH_C32(0xf23cc000), SPH_C32(0x42cb39e0), + SPH_C32(0x5afd9229), SPH_C32(0x94e42f6f) }, + { SPH_C32(0x84865000), SPH_C32(0xd6c5367a), SPH_C32(0xe37e33ea), + SPH_C32(0xb38ff31c), SPH_C32(0x3995c000), SPH_C32(0xd2ec0e89), + SPH_C32(0xe121662e), SPH_C32(0x4410800e) }, + { SPH_C32(0x3bba4000), SPH_C32(0x1cc9476d), SPH_C32(0xd05fdac6), + SPH_C32(0x7d9ddeef), SPH_C32(0x4d00d000), SPH_C32(0x88c748f7), + SPH_C32(0x69dc7b05), SPH_C32(0x5af6029c) }, + { SPH_C32(0x4f2f5000), SPH_C32(0x46e20113), SPH_C32(0x58a2c7ed), + SPH_C32(0x637b5c7d), SPH_C32(0x86a9d000), SPH_C32(0x18e07f9e), + SPH_C32(0xd2008f02), SPH_C32(0x8a02adfd) }, + { SPH_C32(0x19396000), SPH_C32(0x38b9fcf8), SPH_C32(0x7a791496), + SPH_C32(0x90a074aa), SPH_C32(0x656fc000), SPH_C32(0x62845733), + SPH_C32(0x2d447a26), SPH_C32(0x350871ae) }, + { SPH_C32(0x6dac7000), SPH_C32(0x6292ba86), SPH_C32(0xf28409bd), + SPH_C32(0x8e46f638), SPH_C32(0xaec6c000), SPH_C32(0xf2a3605a), + SPH_C32(0x496988e21), SPH_C32(0xe5fcdecf) }, + { SPH_C32(0xd2906000), SPH_C32(0xa89ecb91), SPH_C32(0xc1a5e091), + SPH_C32(0x4054dbcb), SPH_C32(0xda53d000), SPH_C32(0xa8882624), + SPH_C32(0x1e65930a), SPH_C32(0xfb1a5c5d) }, + { SPH_C32(0xa6057000), SPH_C32(0xf2b58def), SPH_C32(0x4958fdba), + SPH_C32(0x5eb25959), SPH_C32(0x11fad000), SPH_C32(0x38af114d), + SPH_C32(0xa5b9670d), SPH_C32(0x2beef33c) }, + { SPH_C32(0x67404000), SPH_C32(0xaca11ed7), SPH_C32(0x1c3ac6ce), + SPH_C32(0x0c852f4f), SPH_C32(0x8c45e000), SPH_C32(0xd6d3dbcf), + SPH_C32(0x3cbe4071), SPH_C32(0x08c1748a) }, + { SPH_C32(0x13d55000), SPH_C32(0xf68a58a9), SPH_C32(0x94c7dbe5), + SPH_C32(0x1263addd), SPH_C32(0x47ece000), SPH_C32(0x46f4eca6), + SPH_C32(0x8762b476), SPH_C32(0xd835dbeb) }, + { SPH_C32(0xace94000), SPH_C32(0x3c8629be), SPH_C32(0xa7e632c9), + SPH_C32(0xdc71802e), SPH_C32(0x3379f000), SPH_C32(0x1cdfaad8), + SPH_C32(0x0f9fa95d), SPH_C32(0xc6d35979) }, + { SPH_C32(0xd87c5000), SPH_C32(0x66ad6fc0), SPH_C32(0x2f1b2fe2), + SPH_C32(0xc29702bc), SPH_C32(0xf8d0f000), SPH_C32(0x8cf89db1), + SPH_C32(0xb4435d5a), SPH_C32(0x1627f618) }, + { SPH_C32(0x8e6a6000), SPH_C32(0x18f6922b), SPH_C32(0x0dc0fc99), + SPH_C32(0x314c2a6b), SPH_C32(0x1b16e000), SPH_C32(0xf69cb51c), + SPH_C32(0x4b07a87e), SPH_C32(0xa92d2a4b) }, + { SPH_C32(0xfaff7000), SPH_C32(0x42ddd455), SPH_C32(0x853de1b2), + SPH_C32(0x2faaa8f9), SPH_C32(0xd0bfe000), SPH_C32(0x66bb8275), + SPH_C32(0xf0db5c79), SPH_C32(0x79d9852a) }, + { SPH_C32(0x45c36000), SPH_C32(0x88d1a542), SPH_C32(0xb61c089e), + SPH_C32(0xe1b8850a), SPH_C32(0xa42af000), SPH_C32(0x3c90c40b), + SPH_C32(0x78264152), SPH_C32(0x673f07b8) }, + { SPH_C32(0x31567000), SPH_C32(0xd2fae33c), SPH_C32(0x3ee115b5), + SPH_C32(0xff5e0798), SPH_C32(0x6f83f000), SPH_C32(0xacb7f362), + SPH_C32(0xc3fab555), SPH_C32(0xb7cba8d9) }, + { SPH_C32(0xe0278000), SPH_C32(0x19dce008), SPH_C32(0xd7075d82), + SPH_C32(0x5ad2e31d), SPH_C32(0xe4788000), SPH_C32(0x859673c1), + SPH_C32(0xb5fb2452), SPH_C32(0x29cc5edf) }, + { SPH_C32(0x94b29000), SPH_C32(0x43f7a676), SPH_C32(0x5ffa40a9), + SPH_C32(0x4434618f), SPH_C32(0x2fd18000), SPH_C32(0x15b144a8), + SPH_C32(0x0e27d055), SPH_C32(0xf938f1be) }, + { SPH_C32(0x2b8e8000), SPH_C32(0x89fbd761), SPH_C32(0x6cdba985), + SPH_C32(0x8a264c7c), SPH_C32(0x5b449000), SPH_C32(0x4f9a02d6), + SPH_C32(0x86dacd7e), SPH_C32(0xe7de732c) }, + { SPH_C32(0x5f1b9000), SPH_C32(0xd3d0911f), SPH_C32(0xe426b4ae), + SPH_C32(0x94c0ceee), SPH_C32(0x90ed9000), SPH_C32(0xdfbd35bf), + SPH_C32(0x3d063979), SPH_C32(0x372adc4d) }, + { SPH_C32(0x090da000), SPH_C32(0xad8b6cf4), SPH_C32(0xc6fd67d5), + SPH_C32(0x671be639), SPH_C32(0x732b8000), SPH_C32(0xa5d91d12), + SPH_C32(0xc242cc5d), SPH_C32(0x8820001e) }, + { SPH_C32(0x7d98b000), SPH_C32(0xf7a02a8a), SPH_C32(0x4e007afe), + SPH_C32(0x79fd64ab), SPH_C32(0xb8828000), SPH_C32(0x35fe2a7b), + SPH_C32(0x799e385a), SPH_C32(0x58d4af7f) }, + { SPH_C32(0xc2a4a000), SPH_C32(0x3dac5b9d), SPH_C32(0x7d2193d2), + SPH_C32(0xb7ef4958), SPH_C32(0xcc179000), SPH_C32(0x6fd56c05), + SPH_C32(0xf1632571), SPH_C32(0x46322ded) }, + { SPH_C32(0xb631b000), SPH_C32(0x67871de3), SPH_C32(0xf5dc8ef9), + SPH_C32(0xa909cbca), SPH_C32(0x07be9000), SPH_C32(0xfff25b6c), + SPH_C32(0x4abfd176), SPH_C32(0x96c6828c) }, + { SPH_C32(0x77748000), SPH_C32(0x39938edb), SPH_C32(0xa0beb58d), + SPH_C32(0xfb3ebddc), SPH_C32(0x9a01a000), SPH_C32(0x118e91ee), + SPH_C32(0xd3b8f60a), SPH_C32(0xb5e9053a) }, + { SPH_C32(0x03e19000), SPH_C32(0x63b8c8a5), SPH_C32(0x2843a8a6), + SPH_C32(0xe5d83f4e), SPH_C32(0x51a8a000), SPH_C32(0x81a9a687), + SPH_C32(0x6864020d), SPH_C32(0x651daa5b) }, + { SPH_C32(0xbcdd8000), SPH_C32(0xa9b4b9b2), SPH_C32(0x1b62418a), + SPH_C32(0x2bca12bd), SPH_C32(0x253db000), SPH_C32(0xdb82e0f9), + SPH_C32(0xe0991f26), SPH_C32(0x7bfb28c9) }, + { SPH_C32(0xc8489000), SPH_C32(0xf39fffcc), SPH_C32(0x939f5ca1), + SPH_C32(0x352c902f), SPH_C32(0xee94b000), SPH_C32(0x4ba5d790), + SPH_C32(0x5b45eb21), SPH_C32(0xab0f87a8) }, + { SPH_C32(0x9e5ea000), SPH_C32(0x8dc40227), SPH_C32(0xb1448fda), + SPH_C32(0xc6f7b8f8), SPH_C32(0x0d52a000), SPH_C32(0x31c1ff3d), + SPH_C32(0xa4011e05), SPH_C32(0x14055bfb) }, + { SPH_C32(0xeacbb000), SPH_C32(0xd7ef4459), SPH_C32(0x39b992f1), + SPH_C32(0xd8113a6a), SPH_C32(0xc6fba000), SPH_C32(0xa1e6c854), + SPH_C32(0x1fddea02), SPH_C32(0xc4f1f49a) }, + { SPH_C32(0x55f7a000), SPH_C32(0x1de3354e), SPH_C32(0x0a987bdd), + SPH_C32(0x16031799), SPH_C32(0xb26eb000), SPH_C32(0xfbcd8e2a), + SPH_C32(0x9720f729), SPH_C32(0xda177608) }, + { SPH_C32(0x2162b000), SPH_C32(0x47c87330), SPH_C32(0x826566f6), + SPH_C32(0x08e5950b), SPH_C32(0x79c7b000), SPH_C32(0x6beab943), + SPH_C32(0x2cfc032e), SPH_C32(0x0ae3d969) }, + { SPH_C32(0xf23cc000), SPH_C32(0x42cb39e0), SPH_C32(0x5afd9229), + SPH_C32(0x94e42f6f), SPH_C32(0x022f8000), SPH_C32(0xce2549e4), + SPH_C32(0x317ebce8), SPH_C32(0x398d5ee1) }, + { SPH_C32(0x86a9d000), SPH_C32(0x18e07f9e), SPH_C32(0xd2008f02), + SPH_C32(0x8a02adfd), SPH_C32(0xc9868000), SPH_C32(0x5e027e8d), + SPH_C32(0x8aa248ef), SPH_C32(0xe979f180) }, + { SPH_C32(0x3995c000), SPH_C32(0xd2ec0e89), SPH_C32(0xe121662e), + SPH_C32(0x4410800e), SPH_C32(0xbd139000), SPH_C32(0x042938f3), + SPH_C32(0x025f55c4), SPH_C32(0xf79f7312) }, + { SPH_C32(0x4d00d000), SPH_C32(0x88c748f7), SPH_C32(0x69dc7b05), + SPH_C32(0x5af6029c), SPH_C32(0x76ba9000), SPH_C32(0x940e0f9a), + SPH_C32(0xb983a1c3), SPH_C32(0x276bdc73) }, + { SPH_C32(0x1b16e000), SPH_C32(0xf69cb51c), SPH_C32(0x4b07a87e), + SPH_C32(0xa92d2a4b), SPH_C32(0x957c8000), SPH_C32(0xee6a2737), + SPH_C32(0x46c754e7), SPH_C32(0x98610020) }, + { SPH_C32(0x6f83f000), SPH_C32(0xacb7f362), SPH_C32(0xc3fab555), + SPH_C32(0xb7cba8d9), SPH_C32(0x5ed58000), SPH_C32(0x7e4d105e), + SPH_C32(0xfd1ba0e0), SPH_C32(0x4895af41) }, + { SPH_C32(0xd0bfe000), SPH_C32(0x66bb8275), SPH_C32(0xf0db5c79), + SPH_C32(0x79d9852a), SPH_C32(0x2a409000), SPH_C32(0x24665620), + SPH_C32(0x75e6bdcb), SPH_C32(0x56732dd3) }, + { SPH_C32(0xa42af000), SPH_C32(0x3c90c40b), SPH_C32(0x78264152), + SPH_C32(0x673f07b8), SPH_C32(0xe1e99000), SPH_C32(0xb4416149), + SPH_C32(0xce3a49cc), SPH_C32(0x868782b2) }, + { SPH_C32(0x656fc000), SPH_C32(0x62845733), SPH_C32(0x2d447a26), + SPH_C32(0x350871ae), SPH_C32(0x7c56a000), SPH_C32(0x5a3dabcb), + SPH_C32(0x573d6eb0), SPH_C32(0xa5a80504) }, + { SPH_C32(0x11fad000), SPH_C32(0x38af114d), SPH_C32(0xa5b9670d), + SPH_C32(0x2beef33c), SPH_C32(0xb7ffa000), SPH_C32(0xca1a9ca2), + SPH_C32(0xece19ab7), SPH_C32(0x755caa65) }, + { SPH_C32(0xaec6c000), SPH_C32(0xf2a3605a), SPH_C32(0x496988e21), + SPH_C32(0xe5fcdecf), SPH_C32(0xc36ab000), SPH_C32(0x9031dadc), + SPH_C32(0x641c879c), SPH_C32(0x6bba28f7) }, + { SPH_C32(0xda53d000), SPH_C32(0xa8882624), SPH_C32(0x1e65930a), + SPH_C32(0xfb1a5c5d), SPH_C32(0x08c3b000), SPH_C32(0x0016edb5), + SPH_C32(0xdfc0739b), SPH_C32(0xbb4e8796) }, + { SPH_C32(0x8c45e000), SPH_C32(0xd6d3dbcf), SPH_C32(0x3cbe4071), + SPH_C32(0x08c1748a), SPH_C32(0xeb05a000), SPH_C32(0x7a72c518), + SPH_C32(0x208486bf), SPH_C32(0x04445bc5) }, + { SPH_C32(0xf8d0f000), SPH_C32(0x8cf89db1), SPH_C32(0xb4435d5a), + SPH_C32(0x1627f618), SPH_C32(0x20aca000), SPH_C32(0xea55f271), + SPH_C32(0x9b5872b8), SPH_C32(0xd4b0f4a4) }, + { SPH_C32(0x47ece000), SPH_C32(0x46f4eca6), SPH_C32(0x8762b476), + SPH_C32(0xd835dbeb), SPH_C32(0x5439b000), SPH_C32(0xb07eb40f), + SPH_C32(0x13a56f93), SPH_C32(0xca567636) }, + { SPH_C32(0x3379f000), SPH_C32(0x1cdfaad8), SPH_C32(0x0f9fa95d), + SPH_C32(0xc6d35979), SPH_C32(0x9f90b000), SPH_C32(0x20598366), + SPH_C32(0xa8799b94), SPH_C32(0x1aa2d957) }, + { SPH_C32(0x06708000), SPH_C32(0x526fda2d), SPH_C32(0x5382c538), + SPH_C32(0x4a93e323), SPH_C32(0x1034c000), SPH_C32(0x9532900c), + SPH_C32(0xbc847343), SPH_C32(0xf7bb9293) }, + { SPH_C32(0x72e59000), SPH_C32(0x08449c53), SPH_C32(0xdb7fd813), + SPH_C32(0x547561b1), SPH_C32(0xdb9dc000), SPH_C32(0x0515a765), + SPH_C32(0x07588744), SPH_C32(0x274f3df2) }, + { SPH_C32(0xcdd98000), SPH_C32(0xc248ed44), SPH_C32(0xe85e313f), + SPH_C32(0x9a674c42), SPH_C32(0xaf08d000), SPH_C32(0x5f3ee11b), + SPH_C32(0x8fa59a6f), SPH_C32(0x39a9bf60) }, + { SPH_C32(0xb94c9000), SPH_C32(0x9863ab3a), SPH_C32(0x60a32c14), + SPH_C32(0x8481ced0), SPH_C32(0x64a1d000), SPH_C32(0xcf19d672), + SPH_C32(0x34796e68), SPH_C32(0xe95d1001) }, + { SPH_C32(0xef5aa000), SPH_C32(0xe63856d1), SPH_C32(0x4278ff6f), + SPH_C32(0x775ae607), SPH_C32(0x8767c000), SPH_C32(0xb57dfedf), + SPH_C32(0xcb3d9b4c), SPH_C32(0x5657cc52) }, + { SPH_C32(0x9bcfb000), SPH_C32(0xbc1310af), SPH_C32(0xca85e244), + SPH_C32(0x69bc6495), SPH_C32(0x4ccec000), SPH_C32(0x255ac9b6), + SPH_C32(0x70e16f4b), SPH_C32(0x86a36333) }, + { SPH_C32(0x24f3a000), SPH_C32(0x761f61b8), SPH_C32(0xf9a40b68), + SPH_C32(0xa7ae4966), SPH_C32(0x385bd000), SPH_C32(0x7f718fc8), + SPH_C32(0xf81c7260), SPH_C32(0x9845e1a1) }, + { SPH_C32(0x5066b000), SPH_C32(0x2c3427c6), SPH_C32(0x71591643), + SPH_C32(0xb948cbf4), SPH_C32(0xf3f2d000), SPH_C32(0xef56b8a1), + SPH_C32(0x43c08667), SPH_C32(0x48b14ec0) }, + { SPH_C32(0x91238000), SPH_C32(0x7220b4fe), SPH_C32(0x243b2d37), + SPH_C32(0xeb7fbde2), SPH_C32(0x6e4de000), SPH_C32(0x012a7223), + SPH_C32(0xdac7a11b), SPH_C32(0x6b9ec976) }, + { SPH_C32(0xe5b69000), SPH_C32(0x280bf280), SPH_C32(0xacc6301c), + SPH_C32(0xf5993f70), SPH_C32(0xa5e4e000), SPH_C32(0x910d454a), + SPH_C32(0x611b551c), SPH_C32(0xbb6a6617) }, + { SPH_C32(0x5a8a8000), SPH_C32(0xe2078397), SPH_C32(0x9fe7d930), + SPH_C32(0x3b8b1283), SPH_C32(0xd171f000), SPH_C32(0xcb260334), + SPH_C32(0xe9e64837), SPH_C32(0xa58ce485) }, + { SPH_C32(0x2e1f9000), SPH_C32(0xb82cc5e9), SPH_C32(0x171ac41b), + SPH_C32(0x256d9011), SPH_C32(0x1ad8f000), SPH_C32(0x5b01345d), + SPH_C32(0x523abc30), SPH_C32(0x75784be4) }, + { SPH_C32(0x7809a000), SPH_C32(0xc6773802), SPH_C32(0x35c11760), + SPH_C32(0xd6b6b8c6), SPH_C32(0xf91ee000), SPH_C32(0x21651cf0), + SPH_C32(0xad7e4914), SPH_C32(0xca7297b7) }, + { SPH_C32(0x0c9cb000), SPH_C32(0x9c5c7e7c), SPH_C32(0xbd3c0a4b), + SPH_C32(0xc8503a54), SPH_C32(0x32b7e000), SPH_C32(0xb1422b99), + SPH_C32(0x16a2bd13), SPH_C32(0x1a8638d6) }, + { SPH_C32(0xb3a0a000), SPH_C32(0x56500f6b), SPH_C32(0x8e1de367), + SPH_C32(0x064217a7), SPH_C32(0x4622f000), SPH_C32(0xeb696de7), + SPH_C32(0x9e5fa038), SPH_C32(0x0460ba44) }, + { SPH_C32(0xc735b000), SPH_C32(0x0c7b4915), SPH_C32(0x06e0fe4c), + SPH_C32(0x18a49535), SPH_C32(0x8d8bf000), SPH_C32(0x7b4e5a8e), + SPH_C32(0x2583543f), SPH_C32(0xd4941525) }, + { SPH_C32(0x146bc000), SPH_C32(0x097803c5), SPH_C32(0xde780a93), + SPH_C32(0x84a52f51), SPH_C32(0xf663c000), SPH_C32(0xde81aa29), + SPH_C32(0x3801ebf9), SPH_C32(0xe7fa92ad) }, + { SPH_C32(0x60fed000), SPH_C32(0x535345bb), SPH_C32(0x568517b8), + SPH_C32(0x9a43adc3), SPH_C32(0x3dcac000), SPH_C32(0x4ea69d40), + SPH_C32(0x83dd1ffe), SPH_C32(0x370e3dcc) }, + { SPH_C32(0xdfc2c000), SPH_C32(0x995f34ac), SPH_C32(0x65a4fe94), + SPH_C32(0x54518030), SPH_C32(0x495fd000), SPH_C32(0x148ddb3e), + SPH_C32(0x0b2002d5), SPH_C32(0x29e8bf5e) }, + { SPH_C32(0xab57d000), SPH_C32(0xc37472d2), SPH_C32(0xed59e3bf), + SPH_C32(0x4ab702a2), SPH_C32(0x82f6d000), SPH_C32(0x84aaec57), + SPH_C32(0xb0fcf6d2), SPH_C32(0xf91c103f) }, + { SPH_C32(0xfd41e000), SPH_C32(0xbd2f8f39), SPH_C32(0xcf8230c4), + SPH_C32(0xb96c2a75), SPH_C32(0x6130c000), SPH_C32(0xfecec4fa), + SPH_C32(0x4fb803f6), SPH_C32(0x4616cc6c) }, + { SPH_C32(0x89d4f000), SPH_C32(0xe704c947), SPH_C32(0x477f2def), + SPH_C32(0xa78aa8e7), SPH_C32(0xaa99c000), SPH_C32(0x6ee9f393), + SPH_C32(0xf464f7f1), SPH_C32(0x96e2630d) }, + { SPH_C32(0x36e8e000), SPH_C32(0x2d08b850), SPH_C32(0x745ec4c3), + SPH_C32(0x69988514), SPH_C32(0xde0cd000), SPH_C32(0x34c2b5ed), + SPH_C32(0x7c99eada), SPH_C32(0x8804e19f) }, + { SPH_C32(0x427df000), SPH_C32(0x7723fe2e), SPH_C32(0xfca3d9e8), + SPH_C32(0x777e0786), SPH_C32(0x15a5d000), SPH_C32(0xa4e58284), + SPH_C32(0xc7451edd), SPH_C32(0x58f04efe) }, + { SPH_C32(0x8338c000), SPH_C32(0x29376d16), SPH_C32(0xa9c1e29c), + SPH_C32(0x25497190), SPH_C32(0x881ae000), SPH_C32(0x4a994806), + SPH_C32(0x5e4239a1), SPH_C32(0x7bdfc948) }, + { SPH_C32(0xf7add000), SPH_C32(0x731c2b68), SPH_C32(0x213cffb7), + SPH_C32(0x3baff302), SPH_C32(0x43b3e000), SPH_C32(0xdabe7f6f), + SPH_C32(0xe59ecda6), SPH_C32(0xab2b6629) }, + { SPH_C32(0x4891c000), SPH_C32(0xb9105a7f), SPH_C32(0x121d169b), + SPH_C32(0xf5bddef1), SPH_C32(0x3726f000), SPH_C32(0x80953911), + SPH_C32(0x6d63d08d), SPH_C32(0xb5cde4bb) }, + { SPH_C32(0x3c04d000), SPH_C32(0xe33b1c01), SPH_C32(0x9ae00bb0), + SPH_C32(0xeb5b5c63), SPH_C32(0xfc8ff000), SPH_C32(0x10b20e78), + SPH_C32(0xd6bf248a), SPH_C32(0x65394bda) }, + { SPH_C32(0x6a12e000), SPH_C32(0x9d60e1ea), SPH_C32(0xb83bd8cb), + SPH_C32(0x188074b4), SPH_C32(0x1f49e000), SPH_C32(0x6ad626d5), + SPH_C32(0x29fbd1ae), SPH_C32(0xda339789) }, + { SPH_C32(0x1e87f000), SPH_C32(0xc74ba794), SPH_C32(0x30c6c5e0), + SPH_C32(0x0666f626), SPH_C32(0xd4e0e000), SPH_C32(0xfaf111bc), + SPH_C32(0x922725a9), SPH_C32(0x0ac738e8) }, + { SPH_C32(0xa1bbe000), SPH_C32(0x0d47d683), SPH_C32(0x03e72ccc), + SPH_C32(0xc874dbd5), SPH_C32(0xa075f000), SPH_C32(0xa0da57c2), + SPH_C32(0x1ada3882), SPH_C32(0x1421ba7a) }, + { SPH_C32(0xd52ef000), SPH_C32(0x576c90fd), SPH_C32(0x8b1a31e7), + SPH_C32(0xd6925947), SPH_C32(0x6bdcf000), SPH_C32(0x30fd60ab), + SPH_C32(0xa106cc85), SPH_C32(0xc4d5151b) } +}; + +static const sph_u32 T256_8[256][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), SPH_C32(0x8589d8ab), + SPH_C32(0xe6c46464), SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), + SPH_C32(0xa29d1297), SPH_C32(0x6ee56854) }, + { SPH_C32(0x734c0000), SPH_C32(0x956fa7d6), SPH_C32(0xa29d1297), + SPH_C32(0x6ee56854), SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), + SPH_C32(0x2714ca3c), SPH_C32(0x88210c30) }, + { SPH_C32(0xc4e80100), SPH_C32(0x1f70960e), SPH_C32(0x2714ca3c), + SPH_C32(0x88210c30), SPH_C32(0xb7a40100), SPH_C32(0x8a1f31d8), + SPH_C32(0x8589d8ab), SPH_C32(0xe6c46464) }, + { SPH_C32(0xa7b80200), SPH_C32(0x1f128433), SPH_C32(0x60e5f9f2), + SPH_C32(0x9e147576), SPH_C32(0xee260000), SPH_C32(0x124b683e), + SPH_C32(0x80c2d68f), SPH_C32(0x3bf3ab2c) }, + { SPH_C32(0x101c0300), SPH_C32(0x950db5eb), SPH_C32(0xe56c2159), + SPH_C32(0x78d01112), SPH_C32(0x9d6a0000), SPH_C32(0x8724cfe8), + SPH_C32(0x225fc418), SPH_C32(0x5516c378) }, + { SPH_C32(0xd4f40200), SPH_C32(0x8a7d23e5), SPH_C32(0xc278eb65), + SPH_C32(0xf0f11d22), SPH_C32(0x2ace0100), SPH_C32(0x0d3bfe30), + SPH_C32(0xa7d61cb3), SPH_C32(0xb3d2a71c) }, + { SPH_C32(0x63500300), SPH_C32(0x0062123d), SPH_C32(0x47f133ce), + SPH_C32(0x16357946), SPH_C32(0x59820100), SPH_C32(0x985459e6), + SPH_C32(0x054b0e24), SPH_C32(0xdd37cf48) }, + { SPH_C32(0xee260000), SPH_C32(0x124b683e), SPH_C32(0x80c2d68f), + SPH_C32(0x3bf3ab2c), SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), + SPH_C32(0xe0272f7d), SPH_C32(0xa5e7de5a) }, + { SPH_C32(0x59820100), SPH_C32(0x985459e6), SPH_C32(0x054b0e24), + SPH_C32(0xdd37cf48), SPH_C32(0x3ad20200), SPH_C32(0x98364bdb), + SPH_C32(0x42ba3dea), SPH_C32(0xcb02b60e) }, + { SPH_C32(0x9d6a0000), SPH_C32(0x8724cfe8), SPH_C32(0x225fc418), + SPH_C32(0x5516c378), SPH_C32(0x8d760300), SPH_C32(0x12297a03), + SPH_C32(0xc733e541), SPH_C32(0x2dc6d26a) }, + { SPH_C32(0x2ace0100), SPH_C32(0x0d3bfe30), SPH_C32(0xa7d61cb3), + SPH_C32(0xb3d2a71c), SPH_C32(0xfe3a0300), SPH_C32(0x8746ddd5), + SPH_C32(0x65aef7d6), SPH_C32(0x4323ba3e) }, + { SPH_C32(0x499e0200), SPH_C32(0x0d59ec0d), SPH_C32(0xe0272f7d), + SPH_C32(0xa5e7de5a), SPH_C32(0xa7b80200), SPH_C32(0x1f128433), + SPH_C32(0x60e5f9f2), SPH_C32(0x9e147576) }, + { SPH_C32(0xfe3a0300), SPH_C32(0x8746ddd5), SPH_C32(0x65aef7d6), + SPH_C32(0x4323ba3e), SPH_C32(0xd4f40200), SPH_C32(0x8a7d23e5), + SPH_C32(0xc278eb65), SPH_C32(0xf0f11d22) }, + { SPH_C32(0x3ad20200), SPH_C32(0x98364bdb), SPH_C32(0x42ba3dea), + SPH_C32(0xcb02b60e), SPH_C32(0x63500300), SPH_C32(0x0062123d), + SPH_C32(0x47f133ce), SPH_C32(0x16357946) }, + { SPH_C32(0x8d760300), SPH_C32(0x12297a03), SPH_C32(0xc733e541), + SPH_C32(0x2dc6d26a), SPH_C32(0x101c0300), SPH_C32(0x950db5eb), + SPH_C32(0xe56c2159), SPH_C32(0x78d01112) }, + { SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), SPH_C32(0x6fc548e1), + SPH_C32(0x898d2cd6), SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), + SPH_C32(0x6a72e5bb), SPH_C32(0x247febe6) }, + { SPH_C32(0x389a0500), SPH_C32(0x8782f9af), SPH_C32(0xea4c904a), + SPH_C32(0x6f4948b2), SPH_C32(0x67f10000), SPH_C32(0xbad59029), + SPH_C32(0xc8eff72c), SPH_C32(0x4a9a83b2) }, + { SPH_C32(0xfc720400), SPH_C32(0x98f26fa1), SPH_C32(0xcd585a76), + SPH_C32(0xe7684482), SPH_C32(0xd0550100), SPH_C32(0x30caa1f1), + SPH_C32(0x4d662f87), SPH_C32(0xac5ee7d6) }, + { SPH_C32(0x4bd60500), SPH_C32(0x12ed5e79), SPH_C32(0x48d182dd), + SPH_C32(0x01ac20e6), SPH_C32(0xa3190100), SPH_C32(0xa5a50627), + SPH_C32(0xeffb3d10), SPH_C32(0xc2bb8f82) }, + { SPH_C32(0x28860600), SPH_C32(0x128f4c44), SPH_C32(0x0f20b113), + SPH_C32(0x179959a0), SPH_C32(0xfa9b0000), SPH_C32(0x3df15fc1), + SPH_C32(0xeab03334), SPH_C32(0x1f8c40ca) }, + { SPH_C32(0x9f220700), SPH_C32(0x98907d9c), SPH_C32(0x8aa969b8), + SPH_C32(0xf15d3dc4), SPH_C32(0x89d70000), SPH_C32(0xa89ef817), + SPH_C32(0x482d21a3), SPH_C32(0x7169289e) }, + { SPH_C32(0x5bca0600), SPH_C32(0x87e0eb92), SPH_C32(0xadbda384), + SPH_C32(0x797c31f4), SPH_C32(0x3e730100), SPH_C32(0x2281c9cf), + SPH_C32(0xcda4f908), SPH_C32(0x97ad4cfa) }, + { SPH_C32(0xec6e0700), SPH_C32(0x0dffda4a), SPH_C32(0x28347b2f), + SPH_C32(0x9fb85590), SPH_C32(0x4d3f0100), SPH_C32(0xb7ee6e19), + SPH_C32(0x6f39eb9f), SPH_C32(0xf94824ae) }, + { SPH_C32(0x61180400), SPH_C32(0x1fd6a049), SPH_C32(0xef079e6e), + SPH_C32(0xb27e87fa), SPH_C32(0x5d230200), SPH_C32(0x22e3dbf2), + SPH_C32(0x8a55cac6), SPH_C32(0x819835bc) }, + { SPH_C32(0xd6bc0500), SPH_C32(0x95c99191), SPH_C32(0x6a8e46c5), + SPH_C32(0x54bae39e), SPH_C32(0x2e6f0200), SPH_C32(0xb78c7c24), + SPH_C32(0x28c8d851), SPH_C32(0xef7d5de8) }, + { SPH_C32(0x12540400), SPH_C32(0x8ab9079f), SPH_C32(0x4d9a8cf9), + SPH_C32(0xdc9befae), SPH_C32(0x99cb0300), SPH_C32(0x3d934dfc), + SPH_C32(0xad4100fa), SPH_C32(0x09b9398c) }, + { SPH_C32(0xa5f00500), SPH_C32(0x00a63647), SPH_C32(0xc8135452), + SPH_C32(0x3a5f8bca), SPH_C32(0xea870300), SPH_C32(0xa8fcea2a), + SPH_C32(0x0fdc126d), SPH_C32(0x675c51d8) }, + { SPH_C32(0xc6a00600), SPH_C32(0x00c4247a), SPH_C32(0x8fe2679c), + SPH_C32(0x2c6af28c), SPH_C32(0xb3050200), SPH_C32(0x30a8b3cc), + SPH_C32(0x0a971c49), SPH_C32(0xba6b9e90) }, + { SPH_C32(0x71040700), SPH_C32(0x8adb15a2), SPH_C32(0x0a6bbf37), + SPH_C32(0xcaae96e8), SPH_C32(0xc0490200), SPH_C32(0xa5c7141a), + SPH_C32(0xa80a0ede), SPH_C32(0xd48ef6c4) }, + { SPH_C32(0xb5ec0600), SPH_C32(0x95ab83ac), SPH_C32(0x2d7f750b), + SPH_C32(0x428f9ad8), SPH_C32(0x77ed0300), SPH_C32(0x2fd825c2), + SPH_C32(0x2d83d675), SPH_C32(0x324a92a0) }, + { SPH_C32(0x02480700), SPH_C32(0x1fb4b274), SPH_C32(0xa8f6ada0), + SPH_C32(0xa44bfebc), SPH_C32(0x04a10300), SPH_C32(0xbab78214), + SPH_C32(0x8f1ec4e2), SPH_C32(0x5caffaf4) }, + { SPH_C32(0x14bd0000), SPH_C32(0x2fba37ff), SPH_C32(0x6a72e5bb), + SPH_C32(0x247febe6), SPH_C32(0x9b830400), SPH_C32(0x2227ff88), + SPH_C32(0x05b7ad5a), SPH_C32(0xadf2c730) }, + { SPH_C32(0xa3190100), SPH_C32(0xa5a50627), SPH_C32(0xeffb3d10), + SPH_C32(0xc2bb8f82), SPH_C32(0xe8cf0400), SPH_C32(0xb748585e), + SPH_C32(0xa72abfcd), SPH_C32(0xc317af64) }, + { SPH_C32(0x67f10000), SPH_C32(0xbad59029), SPH_C32(0xc8eff72c), + SPH_C32(0x4a9a83b2), SPH_C32(0x5f6b0500), SPH_C32(0x3d496986), + SPH_C32(0x22a36766), SPH_C32(0x25d3cb00) }, + { SPH_C32(0xd0550100), SPH_C32(0x30caa1f1), SPH_C32(0x4d662f87), + SPH_C32(0xac5ee7d6), SPH_C32(0x2c270500), SPH_C32(0xa838ce50), + SPH_C32(0x803e75f1), SPH_C32(0x4b36a354) }, + { SPH_C32(0xb3050200), SPH_C32(0x30a8b3cc), SPH_C32(0x0a971c49), + SPH_C32(0xba6b9e90), SPH_C32(0x75a50400), SPH_C32(0x306c97b6), + SPH_C32(0x85757bd5), SPH_C32(0x96016c1c) }, + { SPH_C32(0x04a10300), SPH_C32(0xbab78214), SPH_C32(0x8f1ec4e2), + SPH_C32(0x5caffaf4), SPH_C32(0x06e90400), SPH_C32(0xa5033060), + SPH_C32(0x27e86942), SPH_C32(0xf8e40448) }, + { SPH_C32(0xc0490200), SPH_C32(0xa5c7141a), SPH_C32(0xa80a0ede), + SPH_C32(0xd48ef6c4), SPH_C32(0xb14d0500), SPH_C32(0x2f1c01b8), + SPH_C32(0xa261b1e9), SPH_C32(0x1e20602c) }, + { SPH_C32(0x77ed0300), SPH_C32(0x2fd825c2), SPH_C32(0x2d83d675), + SPH_C32(0x324a92a0), SPH_C32(0xc2010500), SPH_C32(0xba73a66e), + SPH_C32(0x00fca37e), SPH_C32(0x70c50878) }, + { SPH_C32(0xfa9b0000), SPH_C32(0x3df15fc1), SPH_C32(0xeab03334), + SPH_C32(0x1f8c40ca), SPH_C32(0xd21d0600), SPH_C32(0x2f7e1385), + SPH_C32(0xe5908227), SPH_C32(0x0815196a) }, + { SPH_C32(0x4d3f0100), SPH_C32(0xb7ee6e19), SPH_C32(0x6f39eb9f), + SPH_C32(0xf94824ae), SPH_C32(0xa1510600), SPH_C32(0xba11b453), + SPH_C32(0x470d90b0), SPH_C32(0x66f0713e) }, + { SPH_C32(0x89d70000), SPH_C32(0xa89ef817), SPH_C32(0x482d21a3), + SPH_C32(0x7169289e), SPH_C32(0x16f50700), SPH_C32(0x300e858b), + SPH_C32(0xc284481b), SPH_C32(0x8034155a) }, + { SPH_C32(0x3e730100), SPH_C32(0x2281c9cf), SPH_C32(0xcda4f908), + SPH_C32(0x97ad4cfa), SPH_C32(0x65b90700), SPH_C32(0xa561225d), + SPH_C32(0x60195a8c), SPH_C32(0xeed17d0e) }, + { SPH_C32(0x5d230200), SPH_C32(0x22e3dbf2), SPH_C32(0x8a55cac6), + SPH_C32(0x819835bc), SPH_C32(0x3c3b0600), SPH_C32(0x3d357bbb), + SPH_C32(0x655254a8), SPH_C32(0x33e6b246) }, + { SPH_C32(0xea870300), SPH_C32(0xa8fcea2a), SPH_C32(0x0fdc126d), + SPH_C32(0x675c51d8), SPH_C32(0x4f770600), SPH_C32(0xa85adc6d), + SPH_C32(0xc7cf463f), SPH_C32(0x5d03da12) }, + { SPH_C32(0x2e6f0200), SPH_C32(0xb78c7c24), SPH_C32(0x28c8d851), + SPH_C32(0xef7d5de8), SPH_C32(0xf8d30700), SPH_C32(0x2245edb5), + SPH_C32(0x42469e94), SPH_C32(0xbbc7be76) }, + { SPH_C32(0x99cb0300), SPH_C32(0x3d934dfc), SPH_C32(0xad4100fa), + SPH_C32(0x09b9398c), SPH_C32(0x8b9f0700), SPH_C32(0xb72a4a63), + SPH_C32(0xe0db8c03), SPH_C32(0xd522d622) }, + { SPH_C32(0x9b830400), SPH_C32(0x2227ff88), SPH_C32(0x05b7ad5a), + SPH_C32(0xadf2c730), SPH_C32(0x8f3e0400), SPH_C32(0x0d9dc877), + SPH_C32(0x6fc548e1), SPH_C32(0x898d2cd6) }, + { SPH_C32(0x2c270500), SPH_C32(0xa838ce50), SPH_C32(0x803e75f1), + SPH_C32(0x4b36a354), SPH_C32(0xfc720400), SPH_C32(0x98f26fa1), + SPH_C32(0xcd585a76), SPH_C32(0xe7684482) }, + { SPH_C32(0xe8cf0400), SPH_C32(0xb748585e), SPH_C32(0xa72abfcd), + SPH_C32(0xc317af64), SPH_C32(0x4bd60500), SPH_C32(0x12ed5e79), + SPH_C32(0x48d182dd), SPH_C32(0x01ac20e6) }, + { SPH_C32(0x5f6b0500), SPH_C32(0x3d496986), SPH_C32(0x22a36766), + SPH_C32(0x25d3cb00), SPH_C32(0x389a0500), SPH_C32(0x8782f9af), + SPH_C32(0xea4c904a), SPH_C32(0x6f4948b2) }, + { SPH_C32(0x3c3b0600), SPH_C32(0x3d357bbb), SPH_C32(0x655254a8), + SPH_C32(0x33e6b246), SPH_C32(0x61180400), SPH_C32(0x1fd6a049), + SPH_C32(0xef079e6e), SPH_C32(0xb27e87fa) }, + { SPH_C32(0x8b9f0700), SPH_C32(0xb72a4a63), SPH_C32(0xe0db8c03), + SPH_C32(0xd522d622), SPH_C32(0x12540400), SPH_C32(0x8ab9079f), + SPH_C32(0x4d9a8cf9), SPH_C32(0xdc9befae) }, + { SPH_C32(0x4f770600), SPH_C32(0xa85adc6d), SPH_C32(0xc7cf463f), + SPH_C32(0x5d03da12), SPH_C32(0xa5f00500), SPH_C32(0x00a63647), + SPH_C32(0xc8135452), SPH_C32(0x3a5f8bca) }, + { SPH_C32(0xf8d30700), SPH_C32(0x2245edb5), SPH_C32(0x42469e94), + SPH_C32(0xbbc7be76), SPH_C32(0xd6bc0500), SPH_C32(0x95c99191), + SPH_C32(0x6a8e46c5), SPH_C32(0x54bae39e) }, + { SPH_C32(0x75a50400), SPH_C32(0x306c97b6), SPH_C32(0x85757bd5), + SPH_C32(0x96016c1c), SPH_C32(0xc6a00600), SPH_C32(0x00c4247a), + SPH_C32(0x8fe2679c), SPH_C32(0x2c6af28c) }, + { SPH_C32(0xc2010500), SPH_C32(0xba73a66e), SPH_C32(0x00fca37e), + SPH_C32(0x70c50878), SPH_C32(0xb5ec0600), SPH_C32(0x95ab83ac), + SPH_C32(0x2d7f750b), SPH_C32(0x428f9ad8) }, + { SPH_C32(0x06e90400), SPH_C32(0xa5033060), SPH_C32(0x27e86942), + SPH_C32(0xf8e40448), SPH_C32(0x02480700), SPH_C32(0x1fb4b274), + SPH_C32(0xa8f6ada0), SPH_C32(0xa44bfebc) }, + { SPH_C32(0xb14d0500), SPH_C32(0x2f1c01b8), SPH_C32(0xa261b1e9), + SPH_C32(0x1e20602c), SPH_C32(0x71040700), SPH_C32(0x8adb15a2), + SPH_C32(0x0a6bbf37), SPH_C32(0xcaae96e8) }, + { SPH_C32(0xd21d0600), SPH_C32(0x2f7e1385), SPH_C32(0xe5908227), + SPH_C32(0x0815196a), SPH_C32(0x28860600), SPH_C32(0x128f4c44), + SPH_C32(0x0f20b113), SPH_C32(0x179959a0) }, + { SPH_C32(0x65b90700), SPH_C32(0xa561225d), SPH_C32(0x60195a8c), + SPH_C32(0xeed17d0e), SPH_C32(0x5bca0600), SPH_C32(0x87e0eb92), + SPH_C32(0xadbda384), SPH_C32(0x797c31f4) }, + { SPH_C32(0xa1510600), SPH_C32(0xba11b453), SPH_C32(0x470d90b0), + SPH_C32(0x66f0713e), SPH_C32(0xec6e0700), SPH_C32(0x0dffda4a), + SPH_C32(0x28347b2f), SPH_C32(0x9fb85590) }, + { SPH_C32(0x16f50700), SPH_C32(0x300e858b), SPH_C32(0xc284481b), + SPH_C32(0x8034155a), SPH_C32(0x9f220700), SPH_C32(0x98907d9c), + SPH_C32(0x8aa969b8), SPH_C32(0xf15d3dc4) }, + { SPH_C32(0xde320800), SPH_C32(0x288350fe), SPH_C32(0x71852ac7), + SPH_C32(0xa6bf9f96), SPH_C32(0xe18b0000), SPH_C32(0x5459887d), + SPH_C32(0xbf1283d3), SPH_C32(0x1b666a73) }, + { SPH_C32(0x69960900), SPH_C32(0xa29c6126), SPH_C32(0xf40cf26c), + SPH_C32(0x407bfbf2), SPH_C32(0x92c70000), SPH_C32(0xc1362fab), + SPH_C32(0x1d8f9144), SPH_C32(0x75830227) }, + { SPH_C32(0xad7e0800), SPH_C32(0xbdecf728), SPH_C32(0xd3183850), + SPH_C32(0xc85af7c2), SPH_C32(0x25630100), SPH_C32(0x4b291e73), + SPH_C32(0x980649ef), SPH_C32(0x93476643) }, + { SPH_C32(0x1ada0900), SPH_C32(0x37f3c6f0), SPH_C32(0x5691e0fb), + SPH_C32(0x2e9e93a6), SPH_C32(0x562f0100), SPH_C32(0xde46b9a5), + SPH_C32(0x3a9b5b78), SPH_C32(0xfda20e17) }, + { SPH_C32(0x798a0a00), SPH_C32(0x3791d4cd), SPH_C32(0x1160d335), + SPH_C32(0x38abeae0), SPH_C32(0x0fad0000), SPH_C32(0x4612e043), + SPH_C32(0x3fd0555c), SPH_C32(0x2095c15f) }, + { SPH_C32(0xce2e0b00), SPH_C32(0xbd8ee515), SPH_C32(0x94e90b9e), + SPH_C32(0xde6f8e84), SPH_C32(0x7ce10000), SPH_C32(0xd37d4795), + SPH_C32(0x9d4d47cb), SPH_C32(0x4e70a90b) }, + { SPH_C32(0x0ac60a00), SPH_C32(0xa2fe731b), SPH_C32(0xb3fdc1a2), + SPH_C32(0x564e82b4), SPH_C32(0xcb450100), SPH_C32(0x5962764d), + SPH_C32(0x18c49f60), SPH_C32(0xa8b4cd6f) }, + { SPH_C32(0xbd620b00), SPH_C32(0x28e142c3), SPH_C32(0x36741909), + SPH_C32(0xb08ae6d0), SPH_C32(0xb8090100), SPH_C32(0xcc0dd19b), + SPH_C32(0xba598df7), SPH_C32(0xc651a53b) }, + { SPH_C32(0x30140800), SPH_C32(0x3ac838c0), SPH_C32(0xf147fc48), + SPH_C32(0x9d4c34ba), SPH_C32(0xa8150200), SPH_C32(0x59006470), + SPH_C32(0x5f35acae), SPH_C32(0xbe81b429) }, + { SPH_C32(0x87b00900), SPH_C32(0xb0d70918), SPH_C32(0x74ce24e3), + SPH_C32(0x7b8850de), SPH_C32(0xdb590200), SPH_C32(0xcc6fc3a6), + SPH_C32(0xfda8be39), SPH_C32(0xd064dc7d) }, + { SPH_C32(0x43580800), SPH_C32(0xafa79f16), SPH_C32(0x53daeedf), + SPH_C32(0xf3a95cee), SPH_C32(0x6cfd0300), SPH_C32(0x4670f27e), + SPH_C32(0x78216692), SPH_C32(0x36a0b819) }, + { SPH_C32(0xf4fc0900), SPH_C32(0x25b8aece), SPH_C32(0xd6533674), + SPH_C32(0x156d388a), SPH_C32(0x1fb10300), SPH_C32(0xd31f55a8), + SPH_C32(0xdabc7405), SPH_C32(0x5845d04d) }, + { SPH_C32(0x97ac0a00), SPH_C32(0x25dabcf3), SPH_C32(0x91a205ba), + SPH_C32(0x035841cc), SPH_C32(0x46330200), SPH_C32(0x4b4b0c4e), + SPH_C32(0xdff77a21), SPH_C32(0x85721f05) }, + { SPH_C32(0x20080b00), SPH_C32(0xafc58d2b), SPH_C32(0x142bdd11), + SPH_C32(0xe59c25a8), SPH_C32(0x357f0200), SPH_C32(0xde24ab98), + SPH_C32(0x7d6a68b6), SPH_C32(0xeb977751) }, + { SPH_C32(0xe4e00a00), SPH_C32(0xb0b51b25), SPH_C32(0x333f172d), + SPH_C32(0x6dbd2998), SPH_C32(0x82db0300), SPH_C32(0x543b9a40), + SPH_C32(0xf8e3b01d), SPH_C32(0x0d531335) }, + { SPH_C32(0x53440b00), SPH_C32(0x3aaa2afd), SPH_C32(0xb6b6cf86), + SPH_C32(0x8b794dfc), SPH_C32(0xf1970300), SPH_C32(0xc1543d96), + SPH_C32(0x5a7ea28a), SPH_C32(0x63b67b61) }, + { SPH_C32(0x510c0c00), SPH_C32(0x251e9889), SPH_C32(0x1e406226), + SPH_C32(0x2f32b340), SPH_C32(0xf5360000), SPH_C32(0x7be3bf82), + SPH_C32(0xd5606668), SPH_C32(0x3f198195) }, + { SPH_C32(0xe6a80d00), SPH_C32(0xaf01a951), SPH_C32(0x9bc9ba8d), + SPH_C32(0xc9f6d724), SPH_C32(0x867a0000), SPH_C32(0xee8c1854), + SPH_C32(0x77fd74ff), SPH_C32(0x51fce9c1) }, + { SPH_C32(0x22400c00), SPH_C32(0xb0713f5f), SPH_C32(0xbcdd70b1), + SPH_C32(0x41d7db14), SPH_C32(0x31de0100), SPH_C32(0x6493298c), + SPH_C32(0xf274ac54), SPH_C32(0xb7388da5) }, + { SPH_C32(0x95e40d00), SPH_C32(0x3a6e0e87), SPH_C32(0x3954a81a), + SPH_C32(0xa713bf70), SPH_C32(0x42920100), SPH_C32(0xf1fc8e5a), + SPH_C32(0x50e9bec3), SPH_C32(0xd9dde5f1) }, + { SPH_C32(0xf6b40e00), SPH_C32(0x3a0c1cba), SPH_C32(0x7ea59bd4), + SPH_C32(0xb126c636), SPH_C32(0x1b100000), SPH_C32(0x69a8d7bc), + SPH_C32(0x55a2b0e7), SPH_C32(0x04ea2ab9) }, + { SPH_C32(0x41100f00), SPH_C32(0xb0132d62), SPH_C32(0xfb2c437f), + SPH_C32(0x57e2a252), SPH_C32(0x685c0000), SPH_C32(0xfcc7706a), + SPH_C32(0xf73fa270), SPH_C32(0x6a0f42ed) }, + { SPH_C32(0x85f80e00), SPH_C32(0xaf63bb6c), SPH_C32(0xdc388943), + SPH_C32(0xdfc3ae62), SPH_C32(0xdff80100), SPH_C32(0x76d841b2), + SPH_C32(0x72b67adb), SPH_C32(0x8ccb2689) }, + { SPH_C32(0x325c0f00), SPH_C32(0x257c8ab4), SPH_C32(0x59b151e8), + SPH_C32(0x3907ca06), SPH_C32(0xacb40100), SPH_C32(0xe3b7e664), + SPH_C32(0xd02b684c), SPH_C32(0xe22e4edd) }, + { SPH_C32(0xbf2a0c00), SPH_C32(0x3755f0b7), SPH_C32(0x9e82b4a9), + SPH_C32(0x14c1186c), SPH_C32(0xbca80200), SPH_C32(0x76ba538f), + SPH_C32(0x35474915), SPH_C32(0x9afe5fcf) }, + { SPH_C32(0x088e0d00), SPH_C32(0xbd4ac16f), SPH_C32(0x1b0b6c02), + SPH_C32(0xf2057c08), SPH_C32(0xcfe40200), SPH_C32(0xe3d5f459), + SPH_C32(0x97da5b82), SPH_C32(0xf41b379b) }, + { SPH_C32(0xcc660c00), SPH_C32(0xa23a5761), SPH_C32(0x3c1fa63e), + SPH_C32(0x7a247038), SPH_C32(0x78400300), SPH_C32(0x69cac581), + SPH_C32(0x12538329), SPH_C32(0x12df53ff) }, + { SPH_C32(0x7bc20d00), SPH_C32(0x282566b9), SPH_C32(0xb9967e95), + SPH_C32(0x9ce0145c), SPH_C32(0x0b0c0300), SPH_C32(0xfca56257), + SPH_C32(0xb0ce91be), SPH_C32(0x7c3a3bab) }, + { SPH_C32(0x18920e00), SPH_C32(0x28477484), SPH_C32(0xfe674d5b), + SPH_C32(0x8ad56d1a), SPH_C32(0x528e0200), SPH_C32(0x64f13bb1), + SPH_C32(0xb5859f9a), SPH_C32(0xa10df4e3) }, + { SPH_C32(0xaf360f00), SPH_C32(0xa258455c), SPH_C32(0x7bee95f0), + SPH_C32(0x6c11097e), SPH_C32(0x21c20200), SPH_C32(0xf19e9c67), + SPH_C32(0x17188d0d), SPH_C32(0xcfe89cb7) }, + { SPH_C32(0x6bde0e00), SPH_C32(0xbd28d352), SPH_C32(0x5cfa5fcc), + SPH_C32(0xe430054e), SPH_C32(0x96660300), SPH_C32(0x7b81adbf), + SPH_C32(0x929155a6), SPH_C32(0x292cf8d3) }, + { SPH_C32(0xdc7a0f00), SPH_C32(0x3737e28a), SPH_C32(0xd9738767), + SPH_C32(0x02f4612a), SPH_C32(0xe52a0300), SPH_C32(0xeeee0a69), + SPH_C32(0x300c4731), SPH_C32(0x47c99087) }, + { SPH_C32(0xca8f0800), SPH_C32(0x07396701), SPH_C32(0x1bf7cf7c), + SPH_C32(0x82c07470), SPH_C32(0x7a080400), SPH_C32(0x767e77f5), + SPH_C32(0xbaa52e89), SPH_C32(0xb694ad43) }, + { SPH_C32(0x7d2b0900), SPH_C32(0x8d2656d9), SPH_C32(0x9e7e17d7), + SPH_C32(0x64041014), SPH_C32(0x09440400), SPH_C32(0xe311d023), + SPH_C32(0x18383c1e), SPH_C32(0xd871c517) }, + { SPH_C32(0xb9c30800), SPH_C32(0x9256c0d7), SPH_C32(0xb96addeb), + SPH_C32(0xec251c24), SPH_C32(0xbee00500), SPH_C32(0x690ee1fb), + SPH_C32(0x9db1e4b5), SPH_C32(0x3eb5a173) }, + { SPH_C32(0x0e670900), SPH_C32(0x1849f10f), SPH_C32(0x3ce30540), + SPH_C32(0x0ae17840), SPH_C32(0xcdac0500), SPH_C32(0xfc61462d), + SPH_C32(0x3f2cf622), SPH_C32(0x5050c927) }, + { SPH_C32(0x6d370a00), SPH_C32(0x182be332), SPH_C32(0x7b12368e), + SPH_C32(0x1cd40106), SPH_C32(0x942e0400), SPH_C32(0x64351fcb), + SPH_C32(0x3a67f806), SPH_C32(0x8d67066f) }, + { SPH_C32(0xda930b00), SPH_C32(0x9234d2ea), SPH_C32(0xfe9bee25), + SPH_C32(0xfa106562), SPH_C32(0xe7620400), SPH_C32(0xf15ab81d), + SPH_C32(0x98faea91), SPH_C32(0xe3826e3b) }, + { SPH_C32(0x1e7b0a00), SPH_C32(0x8d4444e4), SPH_C32(0xd98f2419), + SPH_C32(0x72316952), SPH_C32(0x50c60500), SPH_C32(0x7b4589c5), + SPH_C32(0x1d73323a), SPH_C32(0x05460a5f) }, + { SPH_C32(0xa9df0b00), SPH_C32(0x075b753c), SPH_C32(0x5c06fcb2), + SPH_C32(0x94f50d36), SPH_C32(0x238a0500), SPH_C32(0xee2a2e13), + SPH_C32(0xbfee20ad), SPH_C32(0x6ba3620b) }, + { SPH_C32(0x24a90800), SPH_C32(0x15720f3f), SPH_C32(0x9b3519f3), + SPH_C32(0xb933df5c), SPH_C32(0x33960600), SPH_C32(0x7b279bf8), + SPH_C32(0x5a8201f4), SPH_C32(0x13737319) }, + { SPH_C32(0x930d0900), SPH_C32(0x9f6d3ee7), SPH_C32(0x1ebcc158), + SPH_C32(0x5ff7bb38), SPH_C32(0x40da0600), SPH_C32(0xee483c2e), + SPH_C32(0xf81f1363), SPH_C32(0x7d961b4d) }, + { SPH_C32(0x57e50800), SPH_C32(0x801da8e9), SPH_C32(0x39a80b64), + SPH_C32(0xd7d6b708), SPH_C32(0xf77e0700), SPH_C32(0x64570df6), + SPH_C32(0x7d96cbc8), SPH_C32(0x9b527f29) }, + { SPH_C32(0xe0410900), SPH_C32(0x0a029931), SPH_C32(0xbc21d3cf), + SPH_C32(0x3112d36c), SPH_C32(0x84320700), SPH_C32(0xf138aa20), + SPH_C32(0xdf0bd95f), SPH_C32(0xf5b7177d) }, + { SPH_C32(0x83110a00), SPH_C32(0x0a608b0c), SPH_C32(0xfbd0e001), + SPH_C32(0x2727aa2a), SPH_C32(0xddb00600), SPH_C32(0x696cf3c6), + SPH_C32(0xda40d77b), SPH_C32(0x2880d835) }, + { SPH_C32(0x34b50b00), SPH_C32(0x807fbad4), SPH_C32(0x7e5938aa), + SPH_C32(0xc1e3ce4e), SPH_C32(0xaefc0600), SPH_C32(0xfc035410), + SPH_C32(0x78ddc5ec), SPH_C32(0x4665b061) }, + { SPH_C32(0xf05d0a00), SPH_C32(0x9f0f2cda), SPH_C32(0x594df296), + SPH_C32(0x49c2c27e), SPH_C32(0x19580700), SPH_C32(0x761c65c8), + SPH_C32(0xfd541d47), SPH_C32(0xa0a1d405) }, + { SPH_C32(0x47f90b00), SPH_C32(0x15101d02), SPH_C32(0xdcc42a3d), + SPH_C32(0xaf06a61a), SPH_C32(0x6a140700), SPH_C32(0xe373c21e), + SPH_C32(0x5fc90fd0), SPH_C32(0xce44bc51) }, + { SPH_C32(0x45b10c00), SPH_C32(0x0aa4af76), SPH_C32(0x7432879d), + SPH_C32(0x0b4d58a6), SPH_C32(0x6eb50400), SPH_C32(0x59c4400a), + SPH_C32(0xd0d7cb32), SPH_C32(0x92eb46a5) }, + { SPH_C32(0xf2150d00), SPH_C32(0x80bb9eae), SPH_C32(0xf1bb5f36), + SPH_C32(0xed893cc2), SPH_C32(0x1df90400), SPH_C32(0xccabe7dc), + SPH_C32(0x724ad9a5), SPH_C32(0xfc0e2ef1) }, + { SPH_C32(0x36fd0c00), SPH_C32(0x9fcb08a0), SPH_C32(0xd6af950a), + SPH_C32(0x65a830f2), SPH_C32(0xaa5d0500), SPH_C32(0x46b4d604), + SPH_C32(0xf7c3010e), SPH_C32(0x1aca4a95) }, + { SPH_C32(0x81590d00), SPH_C32(0x15d43978), SPH_C32(0x53264da1), + SPH_C32(0x836c5496), SPH_C32(0xd9110500), SPH_C32(0xd3db71d2), + SPH_C32(0x555e1399), SPH_C32(0x742f22c1) }, + { SPH_C32(0xe2090e00), SPH_C32(0x15b62b45), SPH_C32(0x14d77e6f), + SPH_C32(0x95592dd0), SPH_C32(0x80930400), SPH_C32(0x4b8f2834), + SPH_C32(0x50151dbd), SPH_C32(0xa918ed89) }, + { SPH_C32(0x55ad0f00), SPH_C32(0x9fa91a9d), SPH_C32(0x915ea6c4), + SPH_C32(0x739d49b4), SPH_C32(0xf3df0400), SPH_C32(0xdee08fe2), + SPH_C32(0xf2880f2a), SPH_C32(0xc7fd85dd) }, + { SPH_C32(0x91450e00), SPH_C32(0x80d98c93), SPH_C32(0xb64a6cf8), + SPH_C32(0xfbbc4584), SPH_C32(0x447b0500), SPH_C32(0x54ffbe3a), + SPH_C32(0x7701d781), SPH_C32(0x2139e1b9) }, + { SPH_C32(0x26e10f00), SPH_C32(0x0ac6bd4b), SPH_C32(0x33c3b453), + SPH_C32(0x1d7821e0), SPH_C32(0x37370500), SPH_C32(0xc19019ec), + SPH_C32(0xd59cc516), SPH_C32(0x4fdc89ed) }, + { SPH_C32(0xab970c00), SPH_C32(0x18efc748), SPH_C32(0xf4f05112), + SPH_C32(0x30bef38a), SPH_C32(0x272b0600), SPH_C32(0x549dac07), + SPH_C32(0x30f0e44f), SPH_C32(0x370c98ff) }, + { SPH_C32(0x1c330d00), SPH_C32(0x92f0f690), SPH_C32(0x717989b9), + SPH_C32(0xd67a97ee), SPH_C32(0x54670600), SPH_C32(0xc1f20bd1), + SPH_C32(0x926df6d8), SPH_C32(0x59e9f0ab) }, + { SPH_C32(0xd8db0c00), SPH_C32(0x8d80609e), SPH_C32(0x566d4385), + SPH_C32(0x5e5b9bde), SPH_C32(0xe3c30700), SPH_C32(0x4bed3a09), + SPH_C32(0x17e42e73), SPH_C32(0xbf2d94cf) }, + { SPH_C32(0x6f7f0d00), SPH_C32(0x079f5146), SPH_C32(0xd3e49b2e), + SPH_C32(0xb89fffba), SPH_C32(0x908f0700), SPH_C32(0xde829ddf), + SPH_C32(0xb5793ce4), SPH_C32(0xd1c8fc9b) }, + { SPH_C32(0x0c2f0e00), SPH_C32(0x07fd437b), SPH_C32(0x9415a8e0), + SPH_C32(0xaeaa86fc), SPH_C32(0xc90d0600), SPH_C32(0x46d6c439), + SPH_C32(0xb03232c0), SPH_C32(0x0cff33d3) }, + { SPH_C32(0xbb8b0f00), SPH_C32(0x8de272a3), SPH_C32(0x119c704b), + SPH_C32(0x486ee298), SPH_C32(0xba410600), SPH_C32(0xd3b963ef), + SPH_C32(0x12af2057), SPH_C32(0x621a5b87) }, + { SPH_C32(0x7f630e00), SPH_C32(0x9292e4ad), SPH_C32(0x3688ba77), + SPH_C32(0xc04feea8), SPH_C32(0x0de50700), SPH_C32(0x59a65237), + SPH_C32(0x9726f8fc), SPH_C32(0x84de3fe3) }, + { SPH_C32(0xc8c70f00), SPH_C32(0x188dd575), SPH_C32(0xb30162dc), + SPH_C32(0x268b8acc), SPH_C32(0x7ea90700), SPH_C32(0xccc9f5e1), + SPH_C32(0x35bbea6b), SPH_C32(0xea3b57b7) }, + { SPH_C32(0xe18b0000), SPH_C32(0x5459887d), SPH_C32(0xbf1283d3), + SPH_C32(0x1b666a73), SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), + SPH_C32(0xce97a914), SPH_C32(0xbdd9f5e5) }, + { SPH_C32(0x562f0100), SPH_C32(0xde46b9a5), SPH_C32(0x3a9b5b78), + SPH_C32(0xfda20e17), SPH_C32(0x4cf50800), SPH_C32(0xe9b57f55), + SPH_C32(0x6c0abb83), SPH_C32(0xd33c9db1) }, + { SPH_C32(0x92c70000), SPH_C32(0xc1362fab), SPH_C32(0x1d8f9144), + SPH_C32(0x75830227), SPH_C32(0xfb510900), SPH_C32(0x63aa4e8d), + SPH_C32(0xe9836328), SPH_C32(0x35f8f9d5) }, + { SPH_C32(0x25630100), SPH_C32(0x4b291e73), SPH_C32(0x980649ef), + SPH_C32(0x93476643), SPH_C32(0x881d0900), SPH_C32(0xf6c5e95b), + SPH_C32(0x4b1e71bf), SPH_C32(0x5b1d9181) }, + { SPH_C32(0x46330200), SPH_C32(0x4b4b0c4e), SPH_C32(0xdff77a21), + SPH_C32(0x85721f05), SPH_C32(0xd19f0800), SPH_C32(0x6e91b0bd), + SPH_C32(0x4e557f9b), SPH_C32(0x862a5ec9) }, + { SPH_C32(0xf1970300), SPH_C32(0xc1543d96), SPH_C32(0x5a7ea28a), + SPH_C32(0x63b67b61), SPH_C32(0xa2d30800), SPH_C32(0xfbfe176b), + SPH_C32(0xecc86d0c), SPH_C32(0xe8cf369d) }, + { SPH_C32(0x357f0200), SPH_C32(0xde24ab98), SPH_C32(0x7d6a68b6), + SPH_C32(0xeb977751), SPH_C32(0x15770900), SPH_C32(0x71e126b3), + SPH_C32(0x6941b5a7), SPH_C32(0x0e0b52f9) }, + { SPH_C32(0x82db0300), SPH_C32(0x543b9a40), SPH_C32(0xf8e3b01d), + SPH_C32(0x0d531335), SPH_C32(0x663b0900), SPH_C32(0xe48e8165), + SPH_C32(0xcbdca730), SPH_C32(0x60ee3aad) }, + { SPH_C32(0x0fad0000), SPH_C32(0x4612e043), SPH_C32(0x3fd0555c), + SPH_C32(0x2095c15f), SPH_C32(0x76270a00), SPH_C32(0x7183348e), + SPH_C32(0x2eb08669), SPH_C32(0x183e2bbf) }, + { SPH_C32(0xb8090100), SPH_C32(0xcc0dd19b), SPH_C32(0xba598df7), + SPH_C32(0xc651a53b), SPH_C32(0x056b0a00), SPH_C32(0xe4ec9358), + SPH_C32(0x8c2d94fe), SPH_C32(0x76db43eb) }, + { SPH_C32(0x7ce10000), SPH_C32(0xd37d4795), SPH_C32(0x9d4d47cb), + SPH_C32(0x4e70a90b), SPH_C32(0xb2cf0b00), SPH_C32(0x6ef3a280), + SPH_C32(0x09a44c55), SPH_C32(0x901f278f) }, + { SPH_C32(0xcb450100), SPH_C32(0x5962764d), SPH_C32(0x18c49f60), + SPH_C32(0xa8b4cd6f), SPH_C32(0xc1830b00), SPH_C32(0xfb9c0556), + SPH_C32(0xab395ec2), SPH_C32(0xfefa4fdb) }, + { SPH_C32(0xa8150200), SPH_C32(0x59006470), SPH_C32(0x5f35acae), + SPH_C32(0xbe81b429), SPH_C32(0x98010a00), SPH_C32(0x63c85cb0), + SPH_C32(0xae7250e6), SPH_C32(0x23cd8093) }, + { SPH_C32(0x1fb10300), SPH_C32(0xd31f55a8), SPH_C32(0xdabc7405), + SPH_C32(0x5845d04d), SPH_C32(0xeb4d0a00), SPH_C32(0xf6a7fb66), + SPH_C32(0x0cef4271), SPH_C32(0x4d28e8c7) }, + { SPH_C32(0xdb590200), SPH_C32(0xcc6fc3a6), SPH_C32(0xfda8be39), + SPH_C32(0xd064dc7d), SPH_C32(0x5ce90b00), SPH_C32(0x7cb8cabe), + SPH_C32(0x89669ada), SPH_C32(0xabec8ca3) }, + { SPH_C32(0x6cfd0300), SPH_C32(0x4670f27e), SPH_C32(0x78216692), + SPH_C32(0x36a0b819), SPH_C32(0x2fa50b00), SPH_C32(0xe9d76d68), + SPH_C32(0x2bfb884d), SPH_C32(0xc509e4f7) }, + { SPH_C32(0x6eb50400), SPH_C32(0x59c4400a), SPH_C32(0xd0d7cb32), + SPH_C32(0x92eb46a5), SPH_C32(0x2b040800), SPH_C32(0x5360ef7c), + SPH_C32(0xa4e54caf), SPH_C32(0x99a61e03) }, + { SPH_C32(0xd9110500), SPH_C32(0xd3db71d2), SPH_C32(0x555e1399), + SPH_C32(0x742f22c1), SPH_C32(0x58480800), SPH_C32(0xc60f48aa), + SPH_C32(0x06785e38), SPH_C32(0xf7437657) }, + { SPH_C32(0x1df90400), SPH_C32(0xccabe7dc), SPH_C32(0x724ad9a5), + SPH_C32(0xfc0e2ef1), SPH_C32(0xefec0900), SPH_C32(0x4c107972), + SPH_C32(0x83f18693), SPH_C32(0x11871233) }, + { SPH_C32(0xaa5d0500), SPH_C32(0x46b4d604), SPH_C32(0xf7c3010e), + SPH_C32(0x1aca4a95), SPH_C32(0x9ca00900), SPH_C32(0xd97fdea4), + SPH_C32(0x216c9404), SPH_C32(0x7f627a67) }, + { SPH_C32(0xc90d0600), SPH_C32(0x46d6c439), SPH_C32(0xb03232c0), + SPH_C32(0x0cff33d3), SPH_C32(0xc5220800), SPH_C32(0x412b8742), + SPH_C32(0x24279a20), SPH_C32(0xa255b52f) }, + { SPH_C32(0x7ea90700), SPH_C32(0xccc9f5e1), SPH_C32(0x35bbea6b), + SPH_C32(0xea3b57b7), SPH_C32(0xb66e0800), SPH_C32(0xd4442094), + SPH_C32(0x86ba88b7), SPH_C32(0xccb0dd7b) }, + { SPH_C32(0xba410600), SPH_C32(0xd3b963ef), SPH_C32(0x12af2057), + SPH_C32(0x621a5b87), SPH_C32(0x01ca0900), SPH_C32(0x5e5b114c), + SPH_C32(0x0333501c), SPH_C32(0x2a74b91f) }, + { SPH_C32(0x0de50700), SPH_C32(0x59a65237), SPH_C32(0x9726f8fc), + SPH_C32(0x84de3fe3), SPH_C32(0x72860900), SPH_C32(0xcb34b69a), + SPH_C32(0xa1ae428b), SPH_C32(0x4491d14b) }, + { SPH_C32(0x80930400), SPH_C32(0x4b8f2834), SPH_C32(0x50151dbd), + SPH_C32(0xa918ed89), SPH_C32(0x629a0a00), SPH_C32(0x5e390371), + SPH_C32(0x44c263d2), SPH_C32(0x3c41c059) }, + { SPH_C32(0x37370500), SPH_C32(0xc19019ec), SPH_C32(0xd59cc516), + SPH_C32(0x4fdc89ed), SPH_C32(0x11d60a00), SPH_C32(0xcb56a4a7), + SPH_C32(0xe65f7145), SPH_C32(0x52a4a80d) }, + { SPH_C32(0xf3df0400), SPH_C32(0xdee08fe2), SPH_C32(0xf2880f2a), + SPH_C32(0xc7fd85dd), SPH_C32(0xa6720b00), SPH_C32(0x4149957f), + SPH_C32(0x63d6a9ee), SPH_C32(0xb460cc69) }, + { SPH_C32(0x447b0500), SPH_C32(0x54ffbe3a), SPH_C32(0x7701d781), + SPH_C32(0x2139e1b9), SPH_C32(0xd53e0b00), SPH_C32(0xd42632a9), + SPH_C32(0xc14bbb79), SPH_C32(0xda85a43d) }, + { SPH_C32(0x272b0600), SPH_C32(0x549dac07), SPH_C32(0x30f0e44f), + SPH_C32(0x370c98ff), SPH_C32(0x8cbc0a00), SPH_C32(0x4c726b4f), + SPH_C32(0xc400b55d), SPH_C32(0x07b26b75) }, + { SPH_C32(0x908f0700), SPH_C32(0xde829ddf), SPH_C32(0xb5793ce4), + SPH_C32(0xd1c8fc9b), SPH_C32(0xfff00a00), SPH_C32(0xd91dcc99), + SPH_C32(0x669da7ca), SPH_C32(0x69570321) }, + { SPH_C32(0x54670600), SPH_C32(0xc1f20bd1), SPH_C32(0x926df6d8), + SPH_C32(0x59e9f0ab), SPH_C32(0x48540b00), SPH_C32(0x5302fd41), + SPH_C32(0xe3147f61), SPH_C32(0x8f936745) }, + { SPH_C32(0xe3c30700), SPH_C32(0x4bed3a09), SPH_C32(0x17e42e73), + SPH_C32(0xbf2d94cf), SPH_C32(0x3b180b00), SPH_C32(0xc66d5a97), + SPH_C32(0x41896df6), SPH_C32(0xe1760f11) }, + { SPH_C32(0xf5360000), SPH_C32(0x7be3bf82), SPH_C32(0xd5606668), + SPH_C32(0x3f198195), SPH_C32(0xa43a0c00), SPH_C32(0x5efd270b), + SPH_C32(0xcb20044e), SPH_C32(0x102b32d5) }, + { SPH_C32(0x42920100), SPH_C32(0xf1fc8e5a), SPH_C32(0x50e9bec3), + SPH_C32(0xd9dde5f1), SPH_C32(0xd7760c00), SPH_C32(0xcb9280dd), + SPH_C32(0x69bd16d9), SPH_C32(0x7ece5a81) }, + { SPH_C32(0x867a0000), SPH_C32(0xee8c1854), SPH_C32(0x77fd74ff), + SPH_C32(0x51fce9c1), SPH_C32(0x60d20d00), SPH_C32(0x418db105), + SPH_C32(0xec34ce72), SPH_C32(0x980a3ee5) }, + { SPH_C32(0x31de0100), SPH_C32(0x6493298c), SPH_C32(0xf274ac54), + SPH_C32(0xb7388da5), SPH_C32(0x139e0d00), SPH_C32(0xd4e216d3), + SPH_C32(0x4ea9dce5), SPH_C32(0xf6ef56b1) }, + { SPH_C32(0x528e0200), SPH_C32(0x64f13bb1), SPH_C32(0xb5859f9a), + SPH_C32(0xa10df4e3), SPH_C32(0x4a1c0c00), SPH_C32(0x4cb64f35), + SPH_C32(0x4be2d2c1), SPH_C32(0x2bd899f9) }, + { SPH_C32(0xe52a0300), SPH_C32(0xeeee0a69), SPH_C32(0x300c4731), + SPH_C32(0x47c99087), SPH_C32(0x39500c00), SPH_C32(0xd9d9e8e3), + SPH_C32(0xe97fc056), SPH_C32(0x453df1ad) }, + { SPH_C32(0x21c20200), SPH_C32(0xf19e9c67), SPH_C32(0x17188d0d), + SPH_C32(0xcfe89cb7), SPH_C32(0x8ef40d00), SPH_C32(0x53c6d93b), + SPH_C32(0x6cf618fd), SPH_C32(0xa3f995c9) }, + { SPH_C32(0x96660300), SPH_C32(0x7b81adbf), SPH_C32(0x929155a6), + SPH_C32(0x292cf8d3), SPH_C32(0xfdb80d00), SPH_C32(0xc6a97eed), + SPH_C32(0xce6b0a6a), SPH_C32(0xcd1cfd9d) }, + { SPH_C32(0x1b100000), SPH_C32(0x69a8d7bc), SPH_C32(0x55a2b0e7), + SPH_C32(0x04ea2ab9), SPH_C32(0xeda40e00), SPH_C32(0x53a4cb06), + SPH_C32(0x2b072b33), SPH_C32(0xb5ccec8f) }, + { SPH_C32(0xacb40100), SPH_C32(0xe3b7e664), SPH_C32(0xd02b684c), + SPH_C32(0xe22e4edd), SPH_C32(0x9ee80e00), SPH_C32(0xc6cb6cd0), + SPH_C32(0x899a39a4), SPH_C32(0xdb2984db) }, + { SPH_C32(0x685c0000), SPH_C32(0xfcc7706a), SPH_C32(0xf73fa270), + SPH_C32(0x6a0f42ed), SPH_C32(0x294c0f00), SPH_C32(0x4cd45d08), + SPH_C32(0x0c13e10f), SPH_C32(0x3dede0bf) }, + { SPH_C32(0xdff80100), SPH_C32(0x76d841b2), SPH_C32(0x72b67adb), + SPH_C32(0x8ccb2689), SPH_C32(0x5a000f00), SPH_C32(0xd9bbfade), + SPH_C32(0xae8ef398), SPH_C32(0x530888eb) }, + { SPH_C32(0xbca80200), SPH_C32(0x76ba538f), SPH_C32(0x35474915), + SPH_C32(0x9afe5fcf), SPH_C32(0x03820e00), SPH_C32(0x41efa338), + SPH_C32(0xabc5fdbc), SPH_C32(0x8e3f47a3) }, + { SPH_C32(0x0b0c0300), SPH_C32(0xfca56257), SPH_C32(0xb0ce91be), + SPH_C32(0x7c3a3bab), SPH_C32(0x70ce0e00), SPH_C32(0xd48004ee), + SPH_C32(0x0958ef2b), SPH_C32(0xe0da2ff7) }, + { SPH_C32(0xcfe40200), SPH_C32(0xe3d5f459), SPH_C32(0x97da5b82), + SPH_C32(0xf41b379b), SPH_C32(0xc76a0f00), SPH_C32(0x5e9f3536), + SPH_C32(0x8cd13780), SPH_C32(0x061e4b93) }, + { SPH_C32(0x78400300), SPH_C32(0x69cac581), SPH_C32(0x12538329), + SPH_C32(0x12df53ff), SPH_C32(0xb4260f00), SPH_C32(0xcbf092e0), + SPH_C32(0x2e4c2517), SPH_C32(0x68fb23c7) }, + { SPH_C32(0x7a080400), SPH_C32(0x767e77f5), SPH_C32(0xbaa52e89), + SPH_C32(0xb694ad43), SPH_C32(0xb0870c00), SPH_C32(0x714710f4), + SPH_C32(0xa152e1f5), SPH_C32(0x3454d933) }, + { SPH_C32(0xcdac0500), SPH_C32(0xfc61462d), SPH_C32(0x3f2cf622), + SPH_C32(0x5050c927), SPH_C32(0xc3cb0c00), SPH_C32(0xe428b722), + SPH_C32(0x03cff362), SPH_C32(0x5ab1b167) }, + { SPH_C32(0x09440400), SPH_C32(0xe311d023), SPH_C32(0x18383c1e), + SPH_C32(0xd871c517), SPH_C32(0x746f0d00), SPH_C32(0x6e3786fa), + SPH_C32(0x86462bc9), SPH_C32(0xbc75d503) }, + { SPH_C32(0xbee00500), SPH_C32(0x690ee1fb), SPH_C32(0x9db1e4b5), + SPH_C32(0x3eb5a173), SPH_C32(0x07230d00), SPH_C32(0xfb58212c), + SPH_C32(0x24db395e), SPH_C32(0xd290bd57) }, + { SPH_C32(0xddb00600), SPH_C32(0x696cf3c6), SPH_C32(0xda40d77b), + SPH_C32(0x2880d835), SPH_C32(0x5ea10c00), SPH_C32(0x630c78ca), + SPH_C32(0x2190377a), SPH_C32(0x0fa7721f) }, + { SPH_C32(0x6a140700), SPH_C32(0xe373c21e), SPH_C32(0x5fc90fd0), + SPH_C32(0xce44bc51), SPH_C32(0x2ded0c00), SPH_C32(0xf663df1c), + SPH_C32(0x830d25ed), SPH_C32(0x61421a4b) }, + { SPH_C32(0xaefc0600), SPH_C32(0xfc035410), SPH_C32(0x78ddc5ec), + SPH_C32(0x4665b061), SPH_C32(0x9a490d00), SPH_C32(0x7c7ceec4), + SPH_C32(0x0684fd46), SPH_C32(0x87867e2f) }, + { SPH_C32(0x19580700), SPH_C32(0x761c65c8), SPH_C32(0xfd541d47), + SPH_C32(0xa0a1d405), SPH_C32(0xe9050d00), SPH_C32(0xe9134912), + SPH_C32(0xa419efd1), SPH_C32(0xe963167b) }, + { SPH_C32(0x942e0400), SPH_C32(0x64351fcb), SPH_C32(0x3a67f806), + SPH_C32(0x8d67066f), SPH_C32(0xf9190e00), SPH_C32(0x7c1efcf9), + SPH_C32(0x4175ce88), SPH_C32(0x91b30769) }, + { SPH_C32(0x238a0500), SPH_C32(0xee2a2e13), SPH_C32(0xbfee20ad), + SPH_C32(0x6ba3620b), SPH_C32(0x8a550e00), SPH_C32(0xe9715b2f), + SPH_C32(0xe3e8dc1f), SPH_C32(0xff566f3d) }, + { SPH_C32(0xe7620400), SPH_C32(0xf15ab81d), SPH_C32(0x98faea91), + SPH_C32(0xe3826e3b), SPH_C32(0x3df10f00), SPH_C32(0x636e6af7), + SPH_C32(0x666104b4), SPH_C32(0x19920b59) }, + { SPH_C32(0x50c60500), SPH_C32(0x7b4589c5), SPH_C32(0x1d73323a), + SPH_C32(0x05460a5f), SPH_C32(0x4ebd0f00), SPH_C32(0xf601cd21), + SPH_C32(0xc4fc1623), SPH_C32(0x7777630d) }, + { SPH_C32(0x33960600), SPH_C32(0x7b279bf8), SPH_C32(0x5a8201f4), + SPH_C32(0x13737319), SPH_C32(0x173f0e00), SPH_C32(0x6e5594c7), + SPH_C32(0xc1b71807), SPH_C32(0xaa40ac45) }, + { SPH_C32(0x84320700), SPH_C32(0xf138aa20), SPH_C32(0xdf0bd95f), + SPH_C32(0xf5b7177d), SPH_C32(0x64730e00), SPH_C32(0xfb3a3311), + SPH_C32(0x632a0a90), SPH_C32(0xc4a5c411) }, + { SPH_C32(0x40da0600), SPH_C32(0xee483c2e), SPH_C32(0xf81f1363), + SPH_C32(0x7d961b4d), SPH_C32(0xd3d70f00), SPH_C32(0x712502c9), + SPH_C32(0xe6a3d23b), SPH_C32(0x2261a075) }, + { SPH_C32(0xf77e0700), SPH_C32(0x64570df6), SPH_C32(0x7d96cbc8), + SPH_C32(0x9b527f29), SPH_C32(0xa09b0f00), SPH_C32(0xe44aa51f), + SPH_C32(0x443ec0ac), SPH_C32(0x4c84c821) }, + { SPH_C32(0x3fb90800), SPH_C32(0x7cdad883), SPH_C32(0xce97a914), + SPH_C32(0xbdd9f5e5), SPH_C32(0xde320800), SPH_C32(0x288350fe), + SPH_C32(0x71852ac7), SPH_C32(0xa6bf9f96) }, + { SPH_C32(0x881d0900), SPH_C32(0xf6c5e95b), SPH_C32(0x4b1e71bf), + SPH_C32(0x5b1d9181), SPH_C32(0xad7e0800), SPH_C32(0xbdecf728), + SPH_C32(0xd3183850), SPH_C32(0xc85af7c2) }, + { SPH_C32(0x4cf50800), SPH_C32(0xe9b57f55), SPH_C32(0x6c0abb83), + SPH_C32(0xd33c9db1), SPH_C32(0x1ada0900), SPH_C32(0x37f3c6f0), + SPH_C32(0x5691e0fb), SPH_C32(0x2e9e93a6) }, + { SPH_C32(0xfb510900), SPH_C32(0x63aa4e8d), SPH_C32(0xe9836328), + SPH_C32(0x35f8f9d5), SPH_C32(0x69960900), SPH_C32(0xa29c6126), + SPH_C32(0xf40cf26c), SPH_C32(0x407bfbf2) }, + { SPH_C32(0x98010a00), SPH_C32(0x63c85cb0), SPH_C32(0xae7250e6), + SPH_C32(0x23cd8093), SPH_C32(0x30140800), SPH_C32(0x3ac838c0), + SPH_C32(0xf147fc48), SPH_C32(0x9d4c34ba) }, + { SPH_C32(0x2fa50b00), SPH_C32(0xe9d76d68), SPH_C32(0x2bfb884d), + SPH_C32(0xc509e4f7), SPH_C32(0x43580800), SPH_C32(0xafa79f16), + SPH_C32(0x53daeedf), SPH_C32(0xf3a95cee) }, + { SPH_C32(0xeb4d0a00), SPH_C32(0xf6a7fb66), SPH_C32(0x0cef4271), + SPH_C32(0x4d28e8c7), SPH_C32(0xf4fc0900), SPH_C32(0x25b8aece), + SPH_C32(0xd6533674), SPH_C32(0x156d388a) }, + { SPH_C32(0x5ce90b00), SPH_C32(0x7cb8cabe), SPH_C32(0x89669ada), + SPH_C32(0xabec8ca3), SPH_C32(0x87b00900), SPH_C32(0xb0d70918), + SPH_C32(0x74ce24e3), SPH_C32(0x7b8850de) }, + { SPH_C32(0xd19f0800), SPH_C32(0x6e91b0bd), SPH_C32(0x4e557f9b), + SPH_C32(0x862a5ec9), SPH_C32(0x97ac0a00), SPH_C32(0x25dabcf3), + SPH_C32(0x91a205ba), SPH_C32(0x035841cc) }, + { SPH_C32(0x663b0900), SPH_C32(0xe48e8165), SPH_C32(0xcbdca730), + SPH_C32(0x60ee3aad), SPH_C32(0xe4e00a00), SPH_C32(0xb0b51b25), + SPH_C32(0x333f172d), SPH_C32(0x6dbd2998) }, + { SPH_C32(0xa2d30800), SPH_C32(0xfbfe176b), SPH_C32(0xecc86d0c), + SPH_C32(0xe8cf369d), SPH_C32(0x53440b00), SPH_C32(0x3aaa2afd), + SPH_C32(0xb6b6cf86), SPH_C32(0x8b794dfc) }, + { SPH_C32(0x15770900), SPH_C32(0x71e126b3), SPH_C32(0x6941b5a7), + SPH_C32(0x0e0b52f9), SPH_C32(0x20080b00), SPH_C32(0xafc58d2b), + SPH_C32(0x142bdd11), SPH_C32(0xe59c25a8) }, + { SPH_C32(0x76270a00), SPH_C32(0x7183348e), SPH_C32(0x2eb08669), + SPH_C32(0x183e2bbf), SPH_C32(0x798a0a00), SPH_C32(0x3791d4cd), + SPH_C32(0x1160d335), SPH_C32(0x38abeae0) }, + { SPH_C32(0xc1830b00), SPH_C32(0xfb9c0556), SPH_C32(0xab395ec2), + SPH_C32(0xfefa4fdb), SPH_C32(0x0ac60a00), SPH_C32(0xa2fe731b), + SPH_C32(0xb3fdc1a2), SPH_C32(0x564e82b4) }, + { SPH_C32(0x056b0a00), SPH_C32(0xe4ec9358), SPH_C32(0x8c2d94fe), + SPH_C32(0x76db43eb), SPH_C32(0xbd620b00), SPH_C32(0x28e142c3), + SPH_C32(0x36741909), SPH_C32(0xb08ae6d0) }, + { SPH_C32(0xb2cf0b00), SPH_C32(0x6ef3a280), SPH_C32(0x09a44c55), + SPH_C32(0x901f278f), SPH_C32(0xce2e0b00), SPH_C32(0xbd8ee515), + SPH_C32(0x94e90b9e), SPH_C32(0xde6f8e84) }, + { SPH_C32(0xb0870c00), SPH_C32(0x714710f4), SPH_C32(0xa152e1f5), + SPH_C32(0x3454d933), SPH_C32(0xca8f0800), SPH_C32(0x07396701), + SPH_C32(0x1bf7cf7c), SPH_C32(0x82c07470) }, + { SPH_C32(0x07230d00), SPH_C32(0xfb58212c), SPH_C32(0x24db395e), + SPH_C32(0xd290bd57), SPH_C32(0xb9c30800), SPH_C32(0x9256c0d7), + SPH_C32(0xb96addeb), SPH_C32(0xec251c24) }, + { SPH_C32(0xc3cb0c00), SPH_C32(0xe428b722), SPH_C32(0x03cff362), + SPH_C32(0x5ab1b167), SPH_C32(0x0e670900), SPH_C32(0x1849f10f), + SPH_C32(0x3ce30540), SPH_C32(0x0ae17840) }, + { SPH_C32(0x746f0d00), SPH_C32(0x6e3786fa), SPH_C32(0x86462bc9), + SPH_C32(0xbc75d503), SPH_C32(0x7d2b0900), SPH_C32(0x8d2656d9), + SPH_C32(0x9e7e17d7), SPH_C32(0x64041014) }, + { SPH_C32(0x173f0e00), SPH_C32(0x6e5594c7), SPH_C32(0xc1b71807), + SPH_C32(0xaa40ac45), SPH_C32(0x24a90800), SPH_C32(0x15720f3f), + SPH_C32(0x9b3519f3), SPH_C32(0xb933df5c) }, + { SPH_C32(0xa09b0f00), SPH_C32(0xe44aa51f), SPH_C32(0x443ec0ac), + SPH_C32(0x4c84c821), SPH_C32(0x57e50800), SPH_C32(0x801da8e9), + SPH_C32(0x39a80b64), SPH_C32(0xd7d6b708) }, + { SPH_C32(0x64730e00), SPH_C32(0xfb3a3311), SPH_C32(0x632a0a90), + SPH_C32(0xc4a5c411), SPH_C32(0xe0410900), SPH_C32(0x0a029931), + SPH_C32(0xbc21d3cf), SPH_C32(0x3112d36c) }, + { SPH_C32(0xd3d70f00), SPH_C32(0x712502c9), SPH_C32(0xe6a3d23b), + SPH_C32(0x2261a075), SPH_C32(0x930d0900), SPH_C32(0x9f6d3ee7), + SPH_C32(0x1ebcc158), SPH_C32(0x5ff7bb38) }, + { SPH_C32(0x5ea10c00), SPH_C32(0x630c78ca), SPH_C32(0x2190377a), + SPH_C32(0x0fa7721f), SPH_C32(0x83110a00), SPH_C32(0x0a608b0c), + SPH_C32(0xfbd0e001), SPH_C32(0x2727aa2a) }, + { SPH_C32(0xe9050d00), SPH_C32(0xe9134912), SPH_C32(0xa419efd1), + SPH_C32(0xe963167b), SPH_C32(0xf05d0a00), SPH_C32(0x9f0f2cda), + SPH_C32(0x594df296), SPH_C32(0x49c2c27e) }, + { SPH_C32(0x2ded0c00), SPH_C32(0xf663df1c), SPH_C32(0x830d25ed), + SPH_C32(0x61421a4b), SPH_C32(0x47f90b00), SPH_C32(0x15101d02), + SPH_C32(0xdcc42a3d), SPH_C32(0xaf06a61a) }, + { SPH_C32(0x9a490d00), SPH_C32(0x7c7ceec4), SPH_C32(0x0684fd46), + SPH_C32(0x87867e2f), SPH_C32(0x34b50b00), SPH_C32(0x807fbad4), + SPH_C32(0x7e5938aa), SPH_C32(0xc1e3ce4e) }, + { SPH_C32(0xf9190e00), SPH_C32(0x7c1efcf9), SPH_C32(0x4175ce88), + SPH_C32(0x91b30769), SPH_C32(0x6d370a00), SPH_C32(0x182be332), + SPH_C32(0x7b12368e), SPH_C32(0x1cd40106) }, + { SPH_C32(0x4ebd0f00), SPH_C32(0xf601cd21), SPH_C32(0xc4fc1623), + SPH_C32(0x7777630d), SPH_C32(0x1e7b0a00), SPH_C32(0x8d4444e4), + SPH_C32(0xd98f2419), SPH_C32(0x72316952) }, + { SPH_C32(0x8a550e00), SPH_C32(0xe9715b2f), SPH_C32(0xe3e8dc1f), + SPH_C32(0xff566f3d), SPH_C32(0xa9df0b00), SPH_C32(0x075b753c), + SPH_C32(0x5c06fcb2), SPH_C32(0x94f50d36) }, + { SPH_C32(0x3df10f00), SPH_C32(0x636e6af7), SPH_C32(0x666104b4), + SPH_C32(0x19920b59), SPH_C32(0xda930b00), SPH_C32(0x9234d2ea), + SPH_C32(0xfe9bee25), SPH_C32(0xfa106562) }, + { SPH_C32(0x2b040800), SPH_C32(0x5360ef7c), SPH_C32(0xa4e54caf), + SPH_C32(0x99a61e03), SPH_C32(0x45b10c00), SPH_C32(0x0aa4af76), + SPH_C32(0x7432879d), SPH_C32(0x0b4d58a6) }, + { SPH_C32(0x9ca00900), SPH_C32(0xd97fdea4), SPH_C32(0x216c9404), + SPH_C32(0x7f627a67), SPH_C32(0x36fd0c00), SPH_C32(0x9fcb08a0), + SPH_C32(0xd6af950a), SPH_C32(0x65a830f2) }, + { SPH_C32(0x58480800), SPH_C32(0xc60f48aa), SPH_C32(0x06785e38), + SPH_C32(0xf7437657), SPH_C32(0x81590d00), SPH_C32(0x15d43978), + SPH_C32(0x53264da1), SPH_C32(0x836c5496) }, + { SPH_C32(0xefec0900), SPH_C32(0x4c107972), SPH_C32(0x83f18693), + SPH_C32(0x11871233), SPH_C32(0xf2150d00), SPH_C32(0x80bb9eae), + SPH_C32(0xf1bb5f36), SPH_C32(0xed893cc2) }, + { SPH_C32(0x8cbc0a00), SPH_C32(0x4c726b4f), SPH_C32(0xc400b55d), + SPH_C32(0x07b26b75), SPH_C32(0xab970c00), SPH_C32(0x18efc748), + SPH_C32(0xf4f05112), SPH_C32(0x30bef38a) }, + { SPH_C32(0x3b180b00), SPH_C32(0xc66d5a97), SPH_C32(0x41896df6), + SPH_C32(0xe1760f11), SPH_C32(0xd8db0c00), SPH_C32(0x8d80609e), + SPH_C32(0x566d4385), SPH_C32(0x5e5b9bde) }, + { SPH_C32(0xfff00a00), SPH_C32(0xd91dcc99), SPH_C32(0x669da7ca), + SPH_C32(0x69570321), SPH_C32(0x6f7f0d00), SPH_C32(0x079f5146), + SPH_C32(0xd3e49b2e), SPH_C32(0xb89fffba) }, + { SPH_C32(0x48540b00), SPH_C32(0x5302fd41), SPH_C32(0xe3147f61), + SPH_C32(0x8f936745), SPH_C32(0x1c330d00), SPH_C32(0x92f0f690), + SPH_C32(0x717989b9), SPH_C32(0xd67a97ee) }, + { SPH_C32(0xc5220800), SPH_C32(0x412b8742), SPH_C32(0x24279a20), + SPH_C32(0xa255b52f), SPH_C32(0x0c2f0e00), SPH_C32(0x07fd437b), + SPH_C32(0x9415a8e0), SPH_C32(0xaeaa86fc) }, + { SPH_C32(0x72860900), SPH_C32(0xcb34b69a), SPH_C32(0xa1ae428b), + SPH_C32(0x4491d14b), SPH_C32(0x7f630e00), SPH_C32(0x9292e4ad), + SPH_C32(0x3688ba77), SPH_C32(0xc04feea8) }, + { SPH_C32(0xb66e0800), SPH_C32(0xd4442094), SPH_C32(0x86ba88b7), + SPH_C32(0xccb0dd7b), SPH_C32(0xc8c70f00), SPH_C32(0x188dd575), + SPH_C32(0xb30162dc), SPH_C32(0x268b8acc) }, + { SPH_C32(0x01ca0900), SPH_C32(0x5e5b114c), SPH_C32(0x0333501c), + SPH_C32(0x2a74b91f), SPH_C32(0xbb8b0f00), SPH_C32(0x8de272a3), + SPH_C32(0x119c704b), SPH_C32(0x486ee298) }, + { SPH_C32(0x629a0a00), SPH_C32(0x5e390371), SPH_C32(0x44c263d2), + SPH_C32(0x3c41c059), SPH_C32(0xe2090e00), SPH_C32(0x15b62b45), + SPH_C32(0x14d77e6f), SPH_C32(0x95592dd0) }, + { SPH_C32(0xd53e0b00), SPH_C32(0xd42632a9), SPH_C32(0xc14bbb79), + SPH_C32(0xda85a43d), SPH_C32(0x91450e00), SPH_C32(0x80d98c93), + SPH_C32(0xb64a6cf8), SPH_C32(0xfbbc4584) }, + { SPH_C32(0x11d60a00), SPH_C32(0xcb56a4a7), SPH_C32(0xe65f7145), + SPH_C32(0x52a4a80d), SPH_C32(0x26e10f00), SPH_C32(0x0ac6bd4b), + SPH_C32(0x33c3b453), SPH_C32(0x1d7821e0) }, + { SPH_C32(0xa6720b00), SPH_C32(0x4149957f), SPH_C32(0x63d6a9ee), + SPH_C32(0xb460cc69), SPH_C32(0x55ad0f00), SPH_C32(0x9fa91a9d), + SPH_C32(0x915ea6c4), SPH_C32(0x739d49b4) }, + { SPH_C32(0xa43a0c00), SPH_C32(0x5efd270b), SPH_C32(0xcb20044e), + SPH_C32(0x102b32d5), SPH_C32(0x510c0c00), SPH_C32(0x251e9889), + SPH_C32(0x1e406226), SPH_C32(0x2f32b340) }, + { SPH_C32(0x139e0d00), SPH_C32(0xd4e216d3), SPH_C32(0x4ea9dce5), + SPH_C32(0xf6ef56b1), SPH_C32(0x22400c00), SPH_C32(0xb0713f5f), + SPH_C32(0xbcdd70b1), SPH_C32(0x41d7db14) }, + { SPH_C32(0xd7760c00), SPH_C32(0xcb9280dd), SPH_C32(0x69bd16d9), + SPH_C32(0x7ece5a81), SPH_C32(0x95e40d00), SPH_C32(0x3a6e0e87), + SPH_C32(0x3954a81a), SPH_C32(0xa713bf70) }, + { SPH_C32(0x60d20d00), SPH_C32(0x418db105), SPH_C32(0xec34ce72), + SPH_C32(0x980a3ee5), SPH_C32(0xe6a80d00), SPH_C32(0xaf01a951), + SPH_C32(0x9bc9ba8d), SPH_C32(0xc9f6d724) }, + { SPH_C32(0x03820e00), SPH_C32(0x41efa338), SPH_C32(0xabc5fdbc), + SPH_C32(0x8e3f47a3), SPH_C32(0xbf2a0c00), SPH_C32(0x3755f0b7), + SPH_C32(0x9e82b4a9), SPH_C32(0x14c1186c) }, + { SPH_C32(0xb4260f00), SPH_C32(0xcbf092e0), SPH_C32(0x2e4c2517), + SPH_C32(0x68fb23c7), SPH_C32(0xcc660c00), SPH_C32(0xa23a5761), + SPH_C32(0x3c1fa63e), SPH_C32(0x7a247038) }, + { SPH_C32(0x70ce0e00), SPH_C32(0xd48004ee), SPH_C32(0x0958ef2b), + SPH_C32(0xe0da2ff7), SPH_C32(0x7bc20d00), SPH_C32(0x282566b9), + SPH_C32(0xb9967e95), SPH_C32(0x9ce0145c) }, + { SPH_C32(0xc76a0f00), SPH_C32(0x5e9f3536), SPH_C32(0x8cd13780), + SPH_C32(0x061e4b93), SPH_C32(0x088e0d00), SPH_C32(0xbd4ac16f), + SPH_C32(0x1b0b6c02), SPH_C32(0xf2057c08) }, + { SPH_C32(0x4a1c0c00), SPH_C32(0x4cb64f35), SPH_C32(0x4be2d2c1), + SPH_C32(0x2bd899f9), SPH_C32(0x18920e00), SPH_C32(0x28477484), + SPH_C32(0xfe674d5b), SPH_C32(0x8ad56d1a) }, + { SPH_C32(0xfdb80d00), SPH_C32(0xc6a97eed), SPH_C32(0xce6b0a6a), + SPH_C32(0xcd1cfd9d), SPH_C32(0x6bde0e00), SPH_C32(0xbd28d352), + SPH_C32(0x5cfa5fcc), SPH_C32(0xe430054e) }, + { SPH_C32(0x39500c00), SPH_C32(0xd9d9e8e3), SPH_C32(0xe97fc056), + SPH_C32(0x453df1ad), SPH_C32(0xdc7a0f00), SPH_C32(0x3737e28a), + SPH_C32(0xd9738767), SPH_C32(0x02f4612a) }, + { SPH_C32(0x8ef40d00), SPH_C32(0x53c6d93b), SPH_C32(0x6cf618fd), + SPH_C32(0xa3f995c9), SPH_C32(0xaf360f00), SPH_C32(0xa258455c), + SPH_C32(0x7bee95f0), SPH_C32(0x6c11097e) }, + { SPH_C32(0xeda40e00), SPH_C32(0x53a4cb06), SPH_C32(0x2b072b33), + SPH_C32(0xb5ccec8f), SPH_C32(0xf6b40e00), SPH_C32(0x3a0c1cba), + SPH_C32(0x7ea59bd4), SPH_C32(0xb126c636) }, + { SPH_C32(0x5a000f00), SPH_C32(0xd9bbfade), SPH_C32(0xae8ef398), + SPH_C32(0x530888eb), SPH_C32(0x85f80e00), SPH_C32(0xaf63bb6c), + SPH_C32(0xdc388943), SPH_C32(0xdfc3ae62) }, + { SPH_C32(0x9ee80e00), SPH_C32(0xc6cb6cd0), SPH_C32(0x899a39a4), + SPH_C32(0xdb2984db), SPH_C32(0x325c0f00), SPH_C32(0x257c8ab4), + SPH_C32(0x59b151e8), SPH_C32(0x3907ca06) }, + { SPH_C32(0x294c0f00), SPH_C32(0x4cd45d08), SPH_C32(0x0c13e10f), + SPH_C32(0x3dede0bf), SPH_C32(0x41100f00), SPH_C32(0xb0132d62), + SPH_C32(0xfb2c437f), SPH_C32(0x57e2a252) } +}; + +static const sph_u32 T256_16[256][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0x515c0010), SPH_C32(0x40f372fb), SPH_C32(0xfce72602), + SPH_C32(0x71575061), SPH_C32(0x2e390000), SPH_C32(0x64dd6689), + SPH_C32(0x3cd406fc), SPH_C32(0xb1f490bc) }, + { SPH_C32(0x2e390000), SPH_C32(0x64dd6689), SPH_C32(0x3cd406fc), + SPH_C32(0xb1f490bc), SPH_C32(0x7f650010), SPH_C32(0x242e1472), + SPH_C32(0xc03320fe), SPH_C32(0xc0a3c0dd) }, + { SPH_C32(0x7f650010), SPH_C32(0x242e1472), SPH_C32(0xc03320fe), + SPH_C32(0xc0a3c0dd), SPH_C32(0x515c0010), SPH_C32(0x40f372fb), + SPH_C32(0xfce72602), SPH_C32(0x71575061) }, + { SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), SPH_C32(0xf9ce4c04), + SPH_C32(0xe2afa0c0), SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), + SPH_C32(0x79a90df9), SPH_C32(0x63e92178) }, + { SPH_C32(0xf3e40030), SPH_C32(0xc114970d), SPH_C32(0x05296a06), + SPH_C32(0x93f8f0a1), SPH_C32(0x724b0000), SPH_C32(0xad67ab9b), + SPH_C32(0x457d0b05), SPH_C32(0xd21db1c4) }, + { SPH_C32(0x8c810020), SPH_C32(0xe53a837f), SPH_C32(0xc51a4af8), + SPH_C32(0x535b307c), SPH_C32(0x23170010), SPH_C32(0xed94d960), + SPH_C32(0xb99a2d07), SPH_C32(0xa34ae1a5) }, + { SPH_C32(0xdddd0030), SPH_C32(0xa5c9f184), SPH_C32(0x39fd6cfa), + SPH_C32(0x220c601d), SPH_C32(0x0d2e0010), SPH_C32(0x8949bfe9), + SPH_C32(0x854e2bfb), SPH_C32(0x12be7119) }, + { SPH_C32(0x5c720000), SPH_C32(0xc9bacd12), SPH_C32(0x79a90df9), + SPH_C32(0x63e92178), SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), + SPH_C32(0x806741fd), SPH_C32(0x814681b8) }, + { SPH_C32(0x0d2e0010), SPH_C32(0x8949bfe9), SPH_C32(0x854e2bfb), + SPH_C32(0x12be7119), SPH_C32(0xd0f30020), SPH_C32(0x2c804e6d), + SPH_C32(0xbcb34701), SPH_C32(0x30b21104) }, + { SPH_C32(0x724b0000), SPH_C32(0xad67ab9b), SPH_C32(0x457d0b05), + SPH_C32(0xd21db1c4), SPH_C32(0x81af0030), SPH_C32(0x6c733c96), + SPH_C32(0x40546103), SPH_C32(0x41e54165) }, + { SPH_C32(0x23170010), SPH_C32(0xed94d960), SPH_C32(0xb99a2d07), + SPH_C32(0xa34ae1a5), SPH_C32(0xaf960030), SPH_C32(0x08ae5a1f), + SPH_C32(0x7c8067ff), SPH_C32(0xf011d1d9) }, + { SPH_C32(0xfeca0020), SPH_C32(0x485d28e4), SPH_C32(0x806741fd), + SPH_C32(0x814681b8), SPH_C32(0xa2b80020), SPH_C32(0x81e7e5f6), + SPH_C32(0xf9ce4c04), SPH_C32(0xe2afa0c0) }, + { SPH_C32(0xaf960030), SPH_C32(0x08ae5a1f), SPH_C32(0x7c8067ff), + SPH_C32(0xf011d1d9), SPH_C32(0x8c810020), SPH_C32(0xe53a837f), + SPH_C32(0xc51a4af8), SPH_C32(0x535b307c) }, + { SPH_C32(0xd0f30020), SPH_C32(0x2c804e6d), SPH_C32(0xbcb34701), + SPH_C32(0x30b21104), SPH_C32(0xdddd0030), SPH_C32(0xa5c9f184), + SPH_C32(0x39fd6cfa), SPH_C32(0x220c601d) }, + { SPH_C32(0x81af0030), SPH_C32(0x6c733c96), SPH_C32(0x40546103), + SPH_C32(0x41e54165), SPH_C32(0xf3e40030), SPH_C32(0xc114970d), + SPH_C32(0x05296a06), SPH_C32(0x93f8f0a1) }, + { SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), SPH_C32(0x36656ba8), + SPH_C32(0x23633a05), SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), + SPH_C32(0x5d5ca0f7), SPH_C32(0x727784cb) }, + { SPH_C32(0x1c920050), SPH_C32(0x7ba89e85), SPH_C32(0xca824daa), + SPH_C32(0x52346a64), SPH_C32(0x56920000), SPH_C32(0xc4103cbd), + SPH_C32(0x6188a60b), SPH_C32(0xc3831477) }, + { SPH_C32(0x63f70040), SPH_C32(0x5f868af7), SPH_C32(0x0ab16d54), + SPH_C32(0x9297aab9), SPH_C32(0x07ce0010), SPH_C32(0x84e34e46), + SPH_C32(0x9d6f8009), SPH_C32(0xb2d44416) }, + { SPH_C32(0x32ab0050), SPH_C32(0x1f75f80c), SPH_C32(0xf6564b56), + SPH_C32(0xe3c0fad8), SPH_C32(0x29f70010), SPH_C32(0xe03e28cf), + SPH_C32(0xa1bb86f5), SPH_C32(0x0320d4aa) }, + { SPH_C32(0xef760060), SPH_C32(0xbabc0988), SPH_C32(0xcfab27ac), + SPH_C32(0xc1cc9ac5), SPH_C32(0x24d90000), SPH_C32(0x69779726), + SPH_C32(0x24f5ad0e), SPH_C32(0x119ea5b3) }, + { SPH_C32(0xbe2a0070), SPH_C32(0xfa4f7b73), SPH_C32(0x334c01ae), + SPH_C32(0xb09bcaa4), SPH_C32(0x0ae00000), SPH_C32(0x0daaf1af), + SPH_C32(0x1821abf2), SPH_C32(0xa06a350f) }, + { SPH_C32(0xc14f0060), SPH_C32(0xde616f01), SPH_C32(0xf37f2150), + SPH_C32(0x70380a79), SPH_C32(0x5bbc0010), SPH_C32(0x4d598354), + SPH_C32(0xe4c68df0), SPH_C32(0xd13d656e) }, + { SPH_C32(0x90130070), SPH_C32(0x9e921dfa), SPH_C32(0x0f980752), + SPH_C32(0x016f5a18), SPH_C32(0x75850010), SPH_C32(0x2984e5dd), + SPH_C32(0xd8128b0c), SPH_C32(0x60c9f5d2) }, + { SPH_C32(0x11bc0040), SPH_C32(0xf2e1216c), SPH_C32(0x4fcc6651), + SPH_C32(0x408a1b7d), SPH_C32(0x86610020), SPH_C32(0xe89072d0), + SPH_C32(0xdd3be10a), SPH_C32(0xf3310573) }, + { SPH_C32(0x40e00050), SPH_C32(0xb2125397), SPH_C32(0xb32b4053), + SPH_C32(0x31dd4b1c), SPH_C32(0xa8580020), SPH_C32(0x8c4d1459), + SPH_C32(0xe1efe7f6), SPH_C32(0x42c595cf) }, + { SPH_C32(0x3f850040), SPH_C32(0x963c47e5), SPH_C32(0x731860ad), + SPH_C32(0xf17e8bc1), SPH_C32(0xf9040030), SPH_C32(0xccbe66a2), + SPH_C32(0x1d08c1f4), SPH_C32(0x3392c5ae) }, + { SPH_C32(0x6ed90050), SPH_C32(0xd6cf351e), SPH_C32(0x8fff46af), + SPH_C32(0x8029dba0), SPH_C32(0xd73d0030), SPH_C32(0xa863002b), + SPH_C32(0x21dcc708), SPH_C32(0x82665512) }, + { SPH_C32(0xb3040060), SPH_C32(0x7306c49a), SPH_C32(0xb6022a55), + SPH_C32(0xa225bbbd), SPH_C32(0xda130020), SPH_C32(0x212abfc2), + SPH_C32(0xa492ecf3), SPH_C32(0x90d8240b) }, + { SPH_C32(0xe2580070), SPH_C32(0x33f5b661), SPH_C32(0x4ae50c57), + SPH_C32(0xd372ebdc), SPH_C32(0xf42a0020), SPH_C32(0x45f7d94b), + SPH_C32(0x9846ea0f), SPH_C32(0x212cb4b7) }, + { SPH_C32(0x9d3d0060), SPH_C32(0x17dba213), SPH_C32(0x8ad62ca9), + SPH_C32(0x13d12b01), SPH_C32(0xa5760030), SPH_C32(0x0504abb0), + SPH_C32(0x64a1cc0d), SPH_C32(0x507be4d6) }, + { SPH_C32(0xcc610070), SPH_C32(0x5728d0e8), SPH_C32(0x76310aab), + SPH_C32(0x62867b60), SPH_C32(0x8b4f0030), SPH_C32(0x61d9cd39), + SPH_C32(0x5875caf1), SPH_C32(0xe18f746a) }, + { SPH_C32(0x78ab0000), SPH_C32(0xa0cd5a34), SPH_C32(0x5d5ca0f7), + SPH_C32(0x727784cb), SPH_C32(0x35650040), SPH_C32(0x9b96b64a), + SPH_C32(0x6b39cb5f), SPH_C32(0x5114bece) }, + { SPH_C32(0x29f70010), SPH_C32(0xe03e28cf), SPH_C32(0xa1bb86f5), + SPH_C32(0x0320d4aa), SPH_C32(0x1b5c0040), SPH_C32(0xff4bd0c3), + SPH_C32(0x57edcda3), SPH_C32(0xe0e02e72) }, + { SPH_C32(0x56920000), SPH_C32(0xc4103cbd), SPH_C32(0x6188a60b), + SPH_C32(0xc3831477), SPH_C32(0x4a000050), SPH_C32(0xbfb8a238), + SPH_C32(0xab0aeba1), SPH_C32(0x91b77e13) }, + { SPH_C32(0x07ce0010), SPH_C32(0x84e34e46), SPH_C32(0x9d6f8009), + SPH_C32(0xb2d44416), SPH_C32(0x64390050), SPH_C32(0xdb65c4b1), + SPH_C32(0x97deed5d), SPH_C32(0x2043eeaf) }, + { SPH_C32(0xda130020), SPH_C32(0x212abfc2), SPH_C32(0xa492ecf3), + SPH_C32(0x90d8240b), SPH_C32(0x69170040), SPH_C32(0x522c7b58), + SPH_C32(0x1290c6a6), SPH_C32(0x32fd9fb6) }, + { SPH_C32(0x8b4f0030), SPH_C32(0x61d9cd39), SPH_C32(0x5875caf1), + SPH_C32(0xe18f746a), SPH_C32(0x472e0040), SPH_C32(0x36f11dd1), + SPH_C32(0x2e44c05a), SPH_C32(0x83090f0a) }, + { SPH_C32(0xf42a0020), SPH_C32(0x45f7d94b), SPH_C32(0x9846ea0f), + SPH_C32(0x212cb4b7), SPH_C32(0x16720050), SPH_C32(0x76026f2a), + SPH_C32(0xd2a3e658), SPH_C32(0xf25e5f6b) }, + { SPH_C32(0xa5760030), SPH_C32(0x0504abb0), SPH_C32(0x64a1cc0d), + SPH_C32(0x507be4d6), SPH_C32(0x384b0050), SPH_C32(0x12df09a3), + SPH_C32(0xee77e0a4), SPH_C32(0x43aacfd7) }, + { SPH_C32(0x24d90000), SPH_C32(0x69779726), SPH_C32(0x24f5ad0e), + SPH_C32(0x119ea5b3), SPH_C32(0xcbaf0060), SPH_C32(0xd3cb9eae), + SPH_C32(0xeb5e8aa2), SPH_C32(0xd0523f76) }, + { SPH_C32(0x75850010), SPH_C32(0x2984e5dd), SPH_C32(0xd8128b0c), + SPH_C32(0x60c9f5d2), SPH_C32(0xe5960060), SPH_C32(0xb716f827), + SPH_C32(0xd78a8c5e), SPH_C32(0x61a6afca) }, + { SPH_C32(0x0ae00000), SPH_C32(0x0daaf1af), SPH_C32(0x1821abf2), + SPH_C32(0xa06a350f), SPH_C32(0xb4ca0070), SPH_C32(0xf7e58adc), + SPH_C32(0x2b6daa5c), SPH_C32(0x10f1ffab) }, + { SPH_C32(0x5bbc0010), SPH_C32(0x4d598354), SPH_C32(0xe4c68df0), + SPH_C32(0xd13d656e), SPH_C32(0x9af30070), SPH_C32(0x9338ec55), + SPH_C32(0x17b9aca0), SPH_C32(0xa1056f17) }, + { SPH_C32(0x86610020), SPH_C32(0xe89072d0), SPH_C32(0xdd3be10a), + SPH_C32(0xf3310573), SPH_C32(0x97dd0060), SPH_C32(0x1a7153bc), + SPH_C32(0x92f7875b), SPH_C32(0xb3bb1e0e) }, + { SPH_C32(0xd73d0030), SPH_C32(0xa863002b), SPH_C32(0x21dcc708), + SPH_C32(0x82665512), SPH_C32(0xb9e40060), SPH_C32(0x7eac3535), + SPH_C32(0xae2381a7), SPH_C32(0x024f8eb2) }, + { SPH_C32(0xa8580020), SPH_C32(0x8c4d1459), SPH_C32(0xe1efe7f6), + SPH_C32(0x42c595cf), SPH_C32(0xe8b80070), SPH_C32(0x3e5f47ce), + SPH_C32(0x52c4a7a5), SPH_C32(0x7318ded3) }, + { SPH_C32(0xf9040030), SPH_C32(0xccbe66a2), SPH_C32(0x1d08c1f4), + SPH_C32(0x3392c5ae), SPH_C32(0xc6810070), SPH_C32(0x5a822147), + SPH_C32(0x6e10a159), SPH_C32(0xc2ec4e6f) }, + { SPH_C32(0x35650040), SPH_C32(0x9b96b64a), SPH_C32(0x6b39cb5f), + SPH_C32(0x5114bece), SPH_C32(0x4dce0040), SPH_C32(0x3b5bec7e), + SPH_C32(0x36656ba8), SPH_C32(0x23633a05) }, + { SPH_C32(0x64390050), SPH_C32(0xdb65c4b1), SPH_C32(0x97deed5d), + SPH_C32(0x2043eeaf), SPH_C32(0x63f70040), SPH_C32(0x5f868af7), + SPH_C32(0x0ab16d54), SPH_C32(0x9297aab9) }, + { SPH_C32(0x1b5c0040), SPH_C32(0xff4bd0c3), SPH_C32(0x57edcda3), + SPH_C32(0xe0e02e72), SPH_C32(0x32ab0050), SPH_C32(0x1f75f80c), + SPH_C32(0xf6564b56), SPH_C32(0xe3c0fad8) }, + { SPH_C32(0x4a000050), SPH_C32(0xbfb8a238), SPH_C32(0xab0aeba1), + SPH_C32(0x91b77e13), SPH_C32(0x1c920050), SPH_C32(0x7ba89e85), + SPH_C32(0xca824daa), SPH_C32(0x52346a64) }, + { SPH_C32(0x97dd0060), SPH_C32(0x1a7153bc), SPH_C32(0x92f7875b), + SPH_C32(0xb3bb1e0e), SPH_C32(0x11bc0040), SPH_C32(0xf2e1216c), + SPH_C32(0x4fcc6651), SPH_C32(0x408a1b7d) }, + { SPH_C32(0xc6810070), SPH_C32(0x5a822147), SPH_C32(0x6e10a159), + SPH_C32(0xc2ec4e6f), SPH_C32(0x3f850040), SPH_C32(0x963c47e5), + SPH_C32(0x731860ad), SPH_C32(0xf17e8bc1) }, + { SPH_C32(0xb9e40060), SPH_C32(0x7eac3535), SPH_C32(0xae2381a7), + SPH_C32(0x024f8eb2), SPH_C32(0x6ed90050), SPH_C32(0xd6cf351e), + SPH_C32(0x8fff46af), SPH_C32(0x8029dba0) }, + { SPH_C32(0xe8b80070), SPH_C32(0x3e5f47ce), SPH_C32(0x52c4a7a5), + SPH_C32(0x7318ded3), SPH_C32(0x40e00050), SPH_C32(0xb2125397), + SPH_C32(0xb32b4053), SPH_C32(0x31dd4b1c) }, + { SPH_C32(0x69170040), SPH_C32(0x522c7b58), SPH_C32(0x1290c6a6), + SPH_C32(0x32fd9fb6), SPH_C32(0xb3040060), SPH_C32(0x7306c49a), + SPH_C32(0xb6022a55), SPH_C32(0xa225bbbd) }, + { SPH_C32(0x384b0050), SPH_C32(0x12df09a3), SPH_C32(0xee77e0a4), + SPH_C32(0x43aacfd7), SPH_C32(0x9d3d0060), SPH_C32(0x17dba213), + SPH_C32(0x8ad62ca9), SPH_C32(0x13d12b01) }, + { SPH_C32(0x472e0040), SPH_C32(0x36f11dd1), SPH_C32(0x2e44c05a), + SPH_C32(0x83090f0a), SPH_C32(0xcc610070), SPH_C32(0x5728d0e8), + SPH_C32(0x76310aab), SPH_C32(0x62867b60) }, + { SPH_C32(0x16720050), SPH_C32(0x76026f2a), SPH_C32(0xd2a3e658), + SPH_C32(0xf25e5f6b), SPH_C32(0xe2580070), SPH_C32(0x33f5b661), + SPH_C32(0x4ae50c57), SPH_C32(0xd372ebdc) }, + { SPH_C32(0xcbaf0060), SPH_C32(0xd3cb9eae), SPH_C32(0xeb5e8aa2), + SPH_C32(0xd0523f76), SPH_C32(0xef760060), SPH_C32(0xbabc0988), + SPH_C32(0xcfab27ac), SPH_C32(0xc1cc9ac5) }, + { SPH_C32(0x9af30070), SPH_C32(0x9338ec55), SPH_C32(0x17b9aca0), + SPH_C32(0xa1056f17), SPH_C32(0xc14f0060), SPH_C32(0xde616f01), + SPH_C32(0xf37f2150), SPH_C32(0x70380a79) }, + { SPH_C32(0xe5960060), SPH_C32(0xb716f827), SPH_C32(0xd78a8c5e), + SPH_C32(0x61a6afca), SPH_C32(0x90130070), SPH_C32(0x9e921dfa), + SPH_C32(0x0f980752), SPH_C32(0x016f5a18) }, + { SPH_C32(0xb4ca0070), SPH_C32(0xf7e58adc), SPH_C32(0x2b6daa5c), + SPH_C32(0x10f1ffab), SPH_C32(0xbe2a0070), SPH_C32(0xfa4f7b73), + SPH_C32(0x334c01ae), SPH_C32(0xb09bcaa4) }, + { SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), SPH_C32(0xc2c46c55), + SPH_C32(0xf362b233), SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), + SPH_C32(0xd14e094b), SPH_C32(0xb772b42b) }, + { SPH_C32(0x0a8e0090), SPH_C32(0x05fc6a17), SPH_C32(0x3e234a57), + SPH_C32(0x8235e252), SPH_C32(0x179f0000), SPH_C32(0x2e6a3562), + SPH_C32(0xed9a0fb7), SPH_C32(0x06862497) }, + { SPH_C32(0x75eb0080), SPH_C32(0x21d27e65), SPH_C32(0xfe106aa9), + SPH_C32(0x4296228f), SPH_C32(0x46c30010), SPH_C32(0x6e994799), + SPH_C32(0x117d29b5), SPH_C32(0x77d174f6) }, + { SPH_C32(0x24b70090), SPH_C32(0x61210c9e), SPH_C32(0x02f74cab), + SPH_C32(0x33c172ee), SPH_C32(0x68fa0010), SPH_C32(0x0a442110), + SPH_C32(0x2da92f49), SPH_C32(0xc625e44a) }, + { SPH_C32(0xf96a00a0), SPH_C32(0xc4e8fd1a), SPH_C32(0x3b0a2051), + SPH_C32(0x11cd12f3), SPH_C32(0x65d40000), SPH_C32(0x830d9ef9), + SPH_C32(0xa8e704b2), SPH_C32(0xd49b9553) }, + { SPH_C32(0xa83600b0), SPH_C32(0x841b8fe1), SPH_C32(0xc7ed0653), + SPH_C32(0x609a4292), SPH_C32(0x4bed0000), SPH_C32(0xe7d0f870), + SPH_C32(0x9433024e), SPH_C32(0x656f05ef) }, + { SPH_C32(0xd75300a0), SPH_C32(0xa0359b93), SPH_C32(0x07de26ad), + SPH_C32(0xa039824f), SPH_C32(0x1ab10010), SPH_C32(0xa7238a8b), + SPH_C32(0x68d4244c), SPH_C32(0x1438558e) }, + { SPH_C32(0x860f00b0), SPH_C32(0xe0c6e968), SPH_C32(0xfb3900af), + SPH_C32(0xd16ed22e), SPH_C32(0x34880010), SPH_C32(0xc3feec02), + SPH_C32(0x540022b0), SPH_C32(0xa5ccc532) }, + { SPH_C32(0x07a00080), SPH_C32(0x8cb5d5fe), SPH_C32(0xbb6d61ac), + SPH_C32(0x908b934b), SPH_C32(0xc76c0020), SPH_C32(0x02ea7b0f), + SPH_C32(0x512948b6), SPH_C32(0x36343593) }, + { SPH_C32(0x56fc0090), SPH_C32(0xcc46a705), SPH_C32(0x478a47ae), + SPH_C32(0xe1dcc32a), SPH_C32(0xe9550020), SPH_C32(0x66371d86), + SPH_C32(0x6dfd4e4a), SPH_C32(0x87c0a52f) }, + { SPH_C32(0x29990080), SPH_C32(0xe868b377), SPH_C32(0x87b96750), + SPH_C32(0x217f03f7), SPH_C32(0xb8090030), SPH_C32(0x26c46f7d), + SPH_C32(0x911a6848), SPH_C32(0xf697f54e) }, + { SPH_C32(0x78c50090), SPH_C32(0xa89bc18c), SPH_C32(0x7b5e4152), + SPH_C32(0x50285396), SPH_C32(0x96300030), SPH_C32(0x421909f4), + SPH_C32(0xadce6eb4), SPH_C32(0x476365f2) }, + { SPH_C32(0xa51800a0), SPH_C32(0x0d523008), SPH_C32(0x42a32da8), + SPH_C32(0x7224338b), SPH_C32(0x9b1e0020), SPH_C32(0xcb50b61d), + SPH_C32(0x2880454f), SPH_C32(0x55dd14eb) }, + { SPH_C32(0xf44400b0), SPH_C32(0x4da142f3), SPH_C32(0xbe440baa), + SPH_C32(0x037363ea), SPH_C32(0xb5270020), SPH_C32(0xaf8dd094), + SPH_C32(0x145443b3), SPH_C32(0xe4298457) }, + { SPH_C32(0x8b2100a0), SPH_C32(0x698f5681), SPH_C32(0x7e772b54), + SPH_C32(0xc3d0a337), SPH_C32(0xe47b0030), SPH_C32(0xef7ea26f), + SPH_C32(0xe8b365b1), SPH_C32(0x957ed436) }, + { SPH_C32(0xda7d00b0), SPH_C32(0x297c247a), SPH_C32(0x82900d56), + SPH_C32(0xb287f356), SPH_C32(0xca420030), SPH_C32(0x8ba3c4e6), + SPH_C32(0xd467634d), SPH_C32(0x248a448a) }, + { SPH_C32(0x161c00c0), SPH_C32(0x7e54f492), SPH_C32(0xf4a107fd), + SPH_C32(0xd0018836), SPH_C32(0x410d0000), SPH_C32(0xea7a09df), + SPH_C32(0x8c12a9bc), SPH_C32(0xc50530e0) }, + { SPH_C32(0x474000d0), SPH_C32(0x3ea78669), SPH_C32(0x084621ff), + SPH_C32(0xa156d857), SPH_C32(0x6f340000), SPH_C32(0x8ea76f56), + SPH_C32(0xb0c6af40), SPH_C32(0x74f1a05c) }, + { SPH_C32(0x382500c0), SPH_C32(0x1a89921b), SPH_C32(0xc8750101), + SPH_C32(0x61f5188a), SPH_C32(0x3e680010), SPH_C32(0xce541dad), + SPH_C32(0x4c218942), SPH_C32(0x05a6f03d) }, + { SPH_C32(0x697900d0), SPH_C32(0x5a7ae0e0), SPH_C32(0x34922703), + SPH_C32(0x10a248eb), SPH_C32(0x10510010), SPH_C32(0xaa897b24), + SPH_C32(0x70f58fbe), SPH_C32(0xb4526081) }, + { SPH_C32(0xb4a400e0), SPH_C32(0xffb31164), SPH_C32(0x0d6f4bf9), + SPH_C32(0x32ae28f6), SPH_C32(0x1d7f0000), SPH_C32(0x23c0c4cd), + SPH_C32(0xf5bba445), SPH_C32(0xa6ec1198) }, + { SPH_C32(0xe5f800f0), SPH_C32(0xbf40639f), SPH_C32(0xf1886dfb), + SPH_C32(0x43f97897), SPH_C32(0x33460000), SPH_C32(0x471da244), + SPH_C32(0xc96fa2b9), SPH_C32(0x17188124) }, + { SPH_C32(0x9a9d00e0), SPH_C32(0x9b6e77ed), SPH_C32(0x31bb4d05), + SPH_C32(0x835ab84a), SPH_C32(0x621a0010), SPH_C32(0x07eed0bf), + SPH_C32(0x358884bb), SPH_C32(0x664fd145) }, + { SPH_C32(0xcbc100f0), SPH_C32(0xdb9d0516), SPH_C32(0xcd5c6b07), + SPH_C32(0xf20de82b), SPH_C32(0x4c230010), SPH_C32(0x6333b636), + SPH_C32(0x095c8247), SPH_C32(0xd7bb41f9) }, + { SPH_C32(0x4a6e00c0), SPH_C32(0xb7ee3980), SPH_C32(0x8d080a04), + SPH_C32(0xb3e8a94e), SPH_C32(0xbfc70020), SPH_C32(0xa227213b), + SPH_C32(0x0c75e841), SPH_C32(0x4443b158) }, + { SPH_C32(0x1b3200d0), SPH_C32(0xf71d4b7b), SPH_C32(0x71ef2c06), + SPH_C32(0xc2bff92f), SPH_C32(0x91fe0020), SPH_C32(0xc6fa47b2), + SPH_C32(0x30a1eebd), SPH_C32(0xf5b721e4) }, + { SPH_C32(0x645700c0), SPH_C32(0xd3335f09), SPH_C32(0xb1dc0cf8), + SPH_C32(0x021c39f2), SPH_C32(0xc0a20030), SPH_C32(0x86093549), + SPH_C32(0xcc46c8bf), SPH_C32(0x84e07185) }, + { SPH_C32(0x350b00d0), SPH_C32(0x93c02df2), SPH_C32(0x4d3b2afa), + SPH_C32(0x734b6993), SPH_C32(0xee9b0030), SPH_C32(0xe2d453c0), + SPH_C32(0xf092ce43), SPH_C32(0x3514e139) }, + { SPH_C32(0xe8d600e0), SPH_C32(0x3609dc76), SPH_C32(0x74c64600), + SPH_C32(0x5147098e), SPH_C32(0xe3b50020), SPH_C32(0x6b9dec29), + SPH_C32(0x75dce5b8), SPH_C32(0x27aa9020) }, + { SPH_C32(0xb98a00f0), SPH_C32(0x76faae8d), SPH_C32(0x88216002), + SPH_C32(0x201059ef), SPH_C32(0xcd8c0020), SPH_C32(0x0f408aa0), + SPH_C32(0x4908e344), SPH_C32(0x965e009c) }, + { SPH_C32(0xc6ef00e0), SPH_C32(0x52d4baff), SPH_C32(0x481240fc), + SPH_C32(0xe0b39932), SPH_C32(0x9cd00030), SPH_C32(0x4fb3f85b), + SPH_C32(0xb5efc546), SPH_C32(0xe70950fd) }, + { SPH_C32(0x97b300f0), SPH_C32(0x1227c804), SPH_C32(0xb4f566fe), + SPH_C32(0x91e4c953), SPH_C32(0xb2e90030), SPH_C32(0x2b6e9ed2), + SPH_C32(0x893bc3ba), SPH_C32(0x56fdc041) }, + { SPH_C32(0x23790080), SPH_C32(0xe5c242d8), SPH_C32(0x9f98cca2), + SPH_C32(0x811536f8), SPH_C32(0x0cc30040), SPH_C32(0xd121e5a1), + SPH_C32(0xba77c214), SPH_C32(0xe6660ae5) }, + { SPH_C32(0x72250090), SPH_C32(0xa5313023), SPH_C32(0x637feaa0), + SPH_C32(0xf0426699), SPH_C32(0x22fa0040), SPH_C32(0xb5fc8328), + SPH_C32(0x86a3c4e8), SPH_C32(0x57929a59) }, + { SPH_C32(0x0d400080), SPH_C32(0x811f2451), SPH_C32(0xa34cca5e), + SPH_C32(0x30e1a644), SPH_C32(0x73a60050), SPH_C32(0xf50ff1d3), + SPH_C32(0x7a44e2ea), SPH_C32(0x26c5ca38) }, + { SPH_C32(0x5c1c0090), SPH_C32(0xc1ec56aa), SPH_C32(0x5fabec5c), + SPH_C32(0x41b6f625), SPH_C32(0x5d9f0050), SPH_C32(0x91d2975a), + SPH_C32(0x4690e416), SPH_C32(0x97315a84) }, + { SPH_C32(0x81c100a0), SPH_C32(0x6425a72e), SPH_C32(0x665680a6), + SPH_C32(0x63ba9638), SPH_C32(0x50b10040), SPH_C32(0x189b28b3), + SPH_C32(0xc3decfed), SPH_C32(0x858f2b9d) }, + { SPH_C32(0xd09d00b0), SPH_C32(0x24d6d5d5), SPH_C32(0x9ab1a6a4), + SPH_C32(0x12edc659), SPH_C32(0x7e880040), SPH_C32(0x7c464e3a), + SPH_C32(0xff0ac911), SPH_C32(0x347bbb21) }, + { SPH_C32(0xaff800a0), SPH_C32(0x00f8c1a7), SPH_C32(0x5a82865a), + SPH_C32(0xd24e0684), SPH_C32(0x2fd40050), SPH_C32(0x3cb53cc1), + SPH_C32(0x03edef13), SPH_C32(0x452ceb40) }, + { SPH_C32(0xfea400b0), SPH_C32(0x400bb35c), SPH_C32(0xa665a058), + SPH_C32(0xa31956e5), SPH_C32(0x01ed0050), SPH_C32(0x58685a48), + SPH_C32(0x3f39e9ef), SPH_C32(0xf4d87bfc) }, + { SPH_C32(0x7f0b0080), SPH_C32(0x2c788fca), SPH_C32(0xe631c15b), + SPH_C32(0xe2fc1780), SPH_C32(0xf2090060), SPH_C32(0x997ccd45), + SPH_C32(0x3a1083e9), SPH_C32(0x67208b5d) }, + { SPH_C32(0x2e570090), SPH_C32(0x6c8bfd31), SPH_C32(0x1ad6e759), + SPH_C32(0x93ab47e1), SPH_C32(0xdc300060), SPH_C32(0xfda1abcc), + SPH_C32(0x06c48515), SPH_C32(0xd6d41be1) }, + { SPH_C32(0x51320080), SPH_C32(0x48a5e943), SPH_C32(0xdae5c7a7), + SPH_C32(0x5308873c), SPH_C32(0x8d6c0070), SPH_C32(0xbd52d937), + SPH_C32(0xfa23a317), SPH_C32(0xa7834b80) }, + { SPH_C32(0x006e0090), SPH_C32(0x08569bb8), SPH_C32(0x2602e1a5), + SPH_C32(0x225fd75d), SPH_C32(0xa3550070), SPH_C32(0xd98fbfbe), + SPH_C32(0xc6f7a5eb), SPH_C32(0x1677db3c) }, + { SPH_C32(0xddb300a0), SPH_C32(0xad9f6a3c), SPH_C32(0x1fff8d5f), + SPH_C32(0x0053b740), SPH_C32(0xae7b0060), SPH_C32(0x50c60057), + SPH_C32(0x43b98e10), SPH_C32(0x04c9aa25) }, + { SPH_C32(0x8cef00b0), SPH_C32(0xed6c18c7), SPH_C32(0xe318ab5d), + SPH_C32(0x7104e721), SPH_C32(0x80420060), SPH_C32(0x341b66de), + SPH_C32(0x7f6d88ec), SPH_C32(0xb53d3a99) }, + { SPH_C32(0xf38a00a0), SPH_C32(0xc9420cb5), SPH_C32(0x232b8ba3), + SPH_C32(0xb1a727fc), SPH_C32(0xd11e0070), SPH_C32(0x74e81425), + SPH_C32(0x838aaeee), SPH_C32(0xc46a6af8) }, + { SPH_C32(0xa2d600b0), SPH_C32(0x89b17e4e), SPH_C32(0xdfccada1), + SPH_C32(0xc0f0779d), SPH_C32(0xff270070), SPH_C32(0x103572ac), + SPH_C32(0xbf5ea812), SPH_C32(0x759efa44) }, + { SPH_C32(0x6eb700c0), SPH_C32(0xde99aea6), SPH_C32(0xa9fda70a), + SPH_C32(0xa2760cfd), SPH_C32(0x74680040), SPH_C32(0x71ecbf95), + SPH_C32(0xe72b62e3), SPH_C32(0x94118e2e) }, + { SPH_C32(0x3feb00d0), SPH_C32(0x9e6adc5d), SPH_C32(0x551a8108), + SPH_C32(0xd3215c9c), SPH_C32(0x5a510040), SPH_C32(0x1531d91c), + SPH_C32(0xdbff641f), SPH_C32(0x25e51e92) }, + { SPH_C32(0x408e00c0), SPH_C32(0xba44c82f), SPH_C32(0x9529a1f6), + SPH_C32(0x13829c41), SPH_C32(0x0b0d0050), SPH_C32(0x55c2abe7), + SPH_C32(0x2718421d), SPH_C32(0x54b24ef3) }, + { SPH_C32(0x11d200d0), SPH_C32(0xfab7bad4), SPH_C32(0x69ce87f4), + SPH_C32(0x62d5cc20), SPH_C32(0x25340050), SPH_C32(0x311fcd6e), + SPH_C32(0x1bcc44e1), SPH_C32(0xe546de4f) }, + { SPH_C32(0xcc0f00e0), SPH_C32(0x5f7e4b50), SPH_C32(0x5033eb0e), + SPH_C32(0x40d9ac3d), SPH_C32(0x281a0040), SPH_C32(0xb8567287), + SPH_C32(0x9e826f1a), SPH_C32(0xf7f8af56) }, + { SPH_C32(0x9d5300f0), SPH_C32(0x1f8d39ab), SPH_C32(0xacd4cd0c), + SPH_C32(0x318efc5c), SPH_C32(0x06230040), SPH_C32(0xdc8b140e), + SPH_C32(0xa25669e6), SPH_C32(0x460c3fea) }, + { SPH_C32(0xe23600e0), SPH_C32(0x3ba32dd9), SPH_C32(0x6ce7edf2), + SPH_C32(0xf12d3c81), SPH_C32(0x577f0050), SPH_C32(0x9c7866f5), + SPH_C32(0x5eb14fe4), SPH_C32(0x375b6f8b) }, + { SPH_C32(0xb36a00f0), SPH_C32(0x7b505f22), SPH_C32(0x9000cbf0), + SPH_C32(0x807a6ce0), SPH_C32(0x79460050), SPH_C32(0xf8a5007c), + SPH_C32(0x62654918), SPH_C32(0x86afff37) }, + { SPH_C32(0x32c500c0), SPH_C32(0x172363b4), SPH_C32(0xd054aaf3), + SPH_C32(0xc19f2d85), SPH_C32(0x8aa20060), SPH_C32(0x39b19771), + SPH_C32(0x674c231e), SPH_C32(0x15570f96) }, + { SPH_C32(0x639900d0), SPH_C32(0x57d0114f), SPH_C32(0x2cb38cf1), + SPH_C32(0xb0c87de4), SPH_C32(0xa49b0060), SPH_C32(0x5d6cf1f8), + SPH_C32(0x5b9825e2), SPH_C32(0xa4a39f2a) }, + { SPH_C32(0x1cfc00c0), SPH_C32(0x73fe053d), SPH_C32(0xec80ac0f), + SPH_C32(0x706bbd39), SPH_C32(0xf5c70070), SPH_C32(0x1d9f8303), + SPH_C32(0xa77f03e0), SPH_C32(0xd5f4cf4b) }, + { SPH_C32(0x4da000d0), SPH_C32(0x330d77c6), SPH_C32(0x10678a0d), + SPH_C32(0x013ced58), SPH_C32(0xdbfe0070), SPH_C32(0x7942e58a), + SPH_C32(0x9bab051c), SPH_C32(0x64005ff7) }, + { SPH_C32(0x907d00e0), SPH_C32(0x96c48642), SPH_C32(0x299ae6f7), + SPH_C32(0x23308d45), SPH_C32(0xd6d00060), SPH_C32(0xf00b5a63), + SPH_C32(0x1ee52ee7), SPH_C32(0x76be2eee) }, + { SPH_C32(0xc12100f0), SPH_C32(0xd637f4b9), SPH_C32(0xd57dc0f5), + SPH_C32(0x5267dd24), SPH_C32(0xf8e90060), SPH_C32(0x94d63cea), + SPH_C32(0x2231281b), SPH_C32(0xc74abe52) }, + { SPH_C32(0xbe4400e0), SPH_C32(0xf219e0cb), SPH_C32(0x154ee00b), + SPH_C32(0x92c41df9), SPH_C32(0xa9b50070), SPH_C32(0xd4254e11), + SPH_C32(0xded60e19), SPH_C32(0xb61dee33) }, + { SPH_C32(0xef1800f0), SPH_C32(0xb2ea9230), SPH_C32(0xe9a9c609), + SPH_C32(0xe3934d98), SPH_C32(0x878c0070), SPH_C32(0xb0f82898), + SPH_C32(0xe20208e5), SPH_C32(0x07e97e8f) }, + { SPH_C32(0x39a60000), SPH_C32(0x4ab753eb), SPH_C32(0xd14e094b), + SPH_C32(0xb772b42b), SPH_C32(0x62740080), SPH_C32(0x0fb84b07), + SPH_C32(0x138a651e), SPH_C32(0x44100618) }, + { SPH_C32(0x68fa0010), SPH_C32(0x0a442110), SPH_C32(0x2da92f49), + SPH_C32(0xc625e44a), SPH_C32(0x4c4d0080), SPH_C32(0x6b652d8e), + SPH_C32(0x2f5e63e2), SPH_C32(0xf5e496a4) }, + { SPH_C32(0x179f0000), SPH_C32(0x2e6a3562), SPH_C32(0xed9a0fb7), + SPH_C32(0x06862497), SPH_C32(0x1d110090), SPH_C32(0x2b965f75), + SPH_C32(0xd3b945e0), SPH_C32(0x84b3c6c5) }, + { SPH_C32(0x46c30010), SPH_C32(0x6e994799), SPH_C32(0x117d29b5), + SPH_C32(0x77d174f6), SPH_C32(0x33280090), SPH_C32(0x4f4b39fc), + SPH_C32(0xef6d431c), SPH_C32(0x35475679) }, + { SPH_C32(0x9b1e0020), SPH_C32(0xcb50b61d), SPH_C32(0x2880454f), + SPH_C32(0x55dd14eb), SPH_C32(0x3e060080), SPH_C32(0xc6028615), + SPH_C32(0x6a2368e7), SPH_C32(0x27f92760) }, + { SPH_C32(0xca420030), SPH_C32(0x8ba3c4e6), SPH_C32(0xd467634d), + SPH_C32(0x248a448a), SPH_C32(0x103f0080), SPH_C32(0xa2dfe09c), + SPH_C32(0x56f76e1b), SPH_C32(0x960db7dc) }, + { SPH_C32(0xb5270020), SPH_C32(0xaf8dd094), SPH_C32(0x145443b3), + SPH_C32(0xe4298457), SPH_C32(0x41630090), SPH_C32(0xe22c9267), + SPH_C32(0xaa104819), SPH_C32(0xe75ae7bd) }, + { SPH_C32(0xe47b0030), SPH_C32(0xef7ea26f), SPH_C32(0xe8b365b1), + SPH_C32(0x957ed436), SPH_C32(0x6f5a0090), SPH_C32(0x86f1f4ee), + SPH_C32(0x96c44ee5), SPH_C32(0x56ae7701) }, + { SPH_C32(0x65d40000), SPH_C32(0x830d9ef9), SPH_C32(0xa8e704b2), + SPH_C32(0xd49b9553), SPH_C32(0x9cbe00a0), SPH_C32(0x47e563e3), + SPH_C32(0x93ed24e3), SPH_C32(0xc55687a0) }, + { SPH_C32(0x34880010), SPH_C32(0xc3feec02), SPH_C32(0x540022b0), + SPH_C32(0xa5ccc532), SPH_C32(0xb28700a0), SPH_C32(0x2338056a), + SPH_C32(0xaf39221f), SPH_C32(0x74a2171c) }, + { SPH_C32(0x4bed0000), SPH_C32(0xe7d0f870), SPH_C32(0x9433024e), + SPH_C32(0x656f05ef), SPH_C32(0xe3db00b0), SPH_C32(0x63cb7791), + SPH_C32(0x53de041d), SPH_C32(0x05f5477d) }, + { SPH_C32(0x1ab10010), SPH_C32(0xa7238a8b), SPH_C32(0x68d4244c), + SPH_C32(0x1438558e), SPH_C32(0xcde200b0), SPH_C32(0x07161118), + SPH_C32(0x6f0a02e1), SPH_C32(0xb401d7c1) }, + { SPH_C32(0xc76c0020), SPH_C32(0x02ea7b0f), SPH_C32(0x512948b6), + SPH_C32(0x36343593), SPH_C32(0xc0cc00a0), SPH_C32(0x8e5faef1), + SPH_C32(0xea44291a), SPH_C32(0xa6bfa6d8) }, + { SPH_C32(0x96300030), SPH_C32(0x421909f4), SPH_C32(0xadce6eb4), + SPH_C32(0x476365f2), SPH_C32(0xeef500a0), SPH_C32(0xea82c878), + SPH_C32(0xd6902fe6), SPH_C32(0x174b3664) }, + { SPH_C32(0xe9550020), SPH_C32(0x66371d86), SPH_C32(0x6dfd4e4a), + SPH_C32(0x87c0a52f), SPH_C32(0xbfa900b0), SPH_C32(0xaa71ba83), + SPH_C32(0x2a7709e4), SPH_C32(0x661c6605) }, + { SPH_C32(0xb8090030), SPH_C32(0x26c46f7d), SPH_C32(0x911a6848), + SPH_C32(0xf697f54e), SPH_C32(0x919000b0), SPH_C32(0xceacdc0a), + SPH_C32(0x16a30f18), SPH_C32(0xd7e8f6b9) }, + { SPH_C32(0x74680040), SPH_C32(0x71ecbf95), SPH_C32(0xe72b62e3), + SPH_C32(0x94118e2e), SPH_C32(0x1adf0080), SPH_C32(0xaf751133), + SPH_C32(0x4ed6c5e9), SPH_C32(0x366782d3) }, + { SPH_C32(0x25340050), SPH_C32(0x311fcd6e), SPH_C32(0x1bcc44e1), + SPH_C32(0xe546de4f), SPH_C32(0x34e60080), SPH_C32(0xcba877ba), + SPH_C32(0x7202c315), SPH_C32(0x8793126f) }, + { SPH_C32(0x5a510040), SPH_C32(0x1531d91c), SPH_C32(0xdbff641f), + SPH_C32(0x25e51e92), SPH_C32(0x65ba0090), SPH_C32(0x8b5b0541), + SPH_C32(0x8ee5e517), SPH_C32(0xf6c4420e) }, + { SPH_C32(0x0b0d0050), SPH_C32(0x55c2abe7), SPH_C32(0x2718421d), + SPH_C32(0x54b24ef3), SPH_C32(0x4b830090), SPH_C32(0xef8663c8), + SPH_C32(0xb231e3eb), SPH_C32(0x4730d2b2) }, + { SPH_C32(0xd6d00060), SPH_C32(0xf00b5a63), SPH_C32(0x1ee52ee7), + SPH_C32(0x76be2eee), SPH_C32(0x46ad0080), SPH_C32(0x66cfdc21), + SPH_C32(0x377fc810), SPH_C32(0x558ea3ab) }, + { SPH_C32(0x878c0070), SPH_C32(0xb0f82898), SPH_C32(0xe20208e5), + SPH_C32(0x07e97e8f), SPH_C32(0x68940080), SPH_C32(0x0212baa8), + SPH_C32(0x0babceec), SPH_C32(0xe47a3317) }, + { SPH_C32(0xf8e90060), SPH_C32(0x94d63cea), SPH_C32(0x2231281b), + SPH_C32(0xc74abe52), SPH_C32(0x39c80090), SPH_C32(0x42e1c853), + SPH_C32(0xf74ce8ee), SPH_C32(0x952d6376) }, + { SPH_C32(0xa9b50070), SPH_C32(0xd4254e11), SPH_C32(0xded60e19), + SPH_C32(0xb61dee33), SPH_C32(0x17f10090), SPH_C32(0x263caeda), + SPH_C32(0xcb98ee12), SPH_C32(0x24d9f3ca) }, + { SPH_C32(0x281a0040), SPH_C32(0xb8567287), SPH_C32(0x9e826f1a), + SPH_C32(0xf7f8af56), SPH_C32(0xe41500a0), SPH_C32(0xe72839d7), + SPH_C32(0xceb18414), SPH_C32(0xb721036b) }, + { SPH_C32(0x79460050), SPH_C32(0xf8a5007c), SPH_C32(0x62654918), + SPH_C32(0x86afff37), SPH_C32(0xca2c00a0), SPH_C32(0x83f55f5e), + SPH_C32(0xf26582e8), SPH_C32(0x06d593d7) }, + { SPH_C32(0x06230040), SPH_C32(0xdc8b140e), SPH_C32(0xa25669e6), + SPH_C32(0x460c3fea), SPH_C32(0x9b7000b0), SPH_C32(0xc3062da5), + SPH_C32(0x0e82a4ea), SPH_C32(0x7782c3b6) }, + { SPH_C32(0x577f0050), SPH_C32(0x9c7866f5), SPH_C32(0x5eb14fe4), + SPH_C32(0x375b6f8b), SPH_C32(0xb54900b0), SPH_C32(0xa7db4b2c), + SPH_C32(0x3256a216), SPH_C32(0xc676530a) }, + { SPH_C32(0x8aa20060), SPH_C32(0x39b19771), SPH_C32(0x674c231e), + SPH_C32(0x15570f96), SPH_C32(0xb86700a0), SPH_C32(0x2e92f4c5), + SPH_C32(0xb71889ed), SPH_C32(0xd4c82213) }, + { SPH_C32(0xdbfe0070), SPH_C32(0x7942e58a), SPH_C32(0x9bab051c), + SPH_C32(0x64005ff7), SPH_C32(0x965e00a0), SPH_C32(0x4a4f924c), + SPH_C32(0x8bcc8f11), SPH_C32(0x653cb2af) }, + { SPH_C32(0xa49b0060), SPH_C32(0x5d6cf1f8), SPH_C32(0x5b9825e2), + SPH_C32(0xa4a39f2a), SPH_C32(0xc70200b0), SPH_C32(0x0abce0b7), + SPH_C32(0x772ba913), SPH_C32(0x146be2ce) }, + { SPH_C32(0xf5c70070), SPH_C32(0x1d9f8303), SPH_C32(0xa77f03e0), + SPH_C32(0xd5f4cf4b), SPH_C32(0xe93b00b0), SPH_C32(0x6e61863e), + SPH_C32(0x4bffafef), SPH_C32(0xa59f7272) }, + { SPH_C32(0x410d0000), SPH_C32(0xea7a09df), SPH_C32(0x8c12a9bc), + SPH_C32(0xc50530e0), SPH_C32(0x571100c0), SPH_C32(0x942efd4d), + SPH_C32(0x78b3ae41), SPH_C32(0x1504b8d6) }, + { SPH_C32(0x10510010), SPH_C32(0xaa897b24), SPH_C32(0x70f58fbe), + SPH_C32(0xb4526081), SPH_C32(0x792800c0), SPH_C32(0xf0f39bc4), + SPH_C32(0x4467a8bd), SPH_C32(0xa4f0286a) }, + { SPH_C32(0x6f340000), SPH_C32(0x8ea76f56), SPH_C32(0xb0c6af40), + SPH_C32(0x74f1a05c), SPH_C32(0x287400d0), SPH_C32(0xb000e93f), + SPH_C32(0xb8808ebf), SPH_C32(0xd5a7780b) }, + { SPH_C32(0x3e680010), SPH_C32(0xce541dad), SPH_C32(0x4c218942), + SPH_C32(0x05a6f03d), SPH_C32(0x064d00d0), SPH_C32(0xd4dd8fb6), + SPH_C32(0x84548843), SPH_C32(0x6453e8b7) }, + { SPH_C32(0xe3b50020), SPH_C32(0x6b9dec29), SPH_C32(0x75dce5b8), + SPH_C32(0x27aa9020), SPH_C32(0x0b6300c0), SPH_C32(0x5d94305f), + SPH_C32(0x011aa3b8), SPH_C32(0x76ed99ae) }, + { SPH_C32(0xb2e90030), SPH_C32(0x2b6e9ed2), SPH_C32(0x893bc3ba), + SPH_C32(0x56fdc041), SPH_C32(0x255a00c0), SPH_C32(0x394956d6), + SPH_C32(0x3dcea544), SPH_C32(0xc7190912) }, + { SPH_C32(0xcd8c0020), SPH_C32(0x0f408aa0), SPH_C32(0x4908e344), + SPH_C32(0x965e009c), SPH_C32(0x740600d0), SPH_C32(0x79ba242d), + SPH_C32(0xc1298346), SPH_C32(0xb64e5973) }, + { SPH_C32(0x9cd00030), SPH_C32(0x4fb3f85b), SPH_C32(0xb5efc546), + SPH_C32(0xe70950fd), SPH_C32(0x5a3f00d0), SPH_C32(0x1d6742a4), + SPH_C32(0xfdfd85ba), SPH_C32(0x07bac9cf) }, + { SPH_C32(0x1d7f0000), SPH_C32(0x23c0c4cd), SPH_C32(0xf5bba445), + SPH_C32(0xa6ec1198), SPH_C32(0xa9db00e0), SPH_C32(0xdc73d5a9), + SPH_C32(0xf8d4efbc), SPH_C32(0x9442396e) }, + { SPH_C32(0x4c230010), SPH_C32(0x6333b636), SPH_C32(0x095c8247), + SPH_C32(0xd7bb41f9), SPH_C32(0x87e200e0), SPH_C32(0xb8aeb320), + SPH_C32(0xc400e940), SPH_C32(0x25b6a9d2) }, + { SPH_C32(0x33460000), SPH_C32(0x471da244), SPH_C32(0xc96fa2b9), + SPH_C32(0x17188124), SPH_C32(0xd6be00f0), SPH_C32(0xf85dc1db), + SPH_C32(0x38e7cf42), SPH_C32(0x54e1f9b3) }, + { SPH_C32(0x621a0010), SPH_C32(0x07eed0bf), SPH_C32(0x358884bb), + SPH_C32(0x664fd145), SPH_C32(0xf88700f0), SPH_C32(0x9c80a752), + SPH_C32(0x0433c9be), SPH_C32(0xe515690f) }, + { SPH_C32(0xbfc70020), SPH_C32(0xa227213b), SPH_C32(0x0c75e841), + SPH_C32(0x4443b158), SPH_C32(0xf5a900e0), SPH_C32(0x15c918bb), + SPH_C32(0x817de245), SPH_C32(0xf7ab1816) }, + { SPH_C32(0xee9b0030), SPH_C32(0xe2d453c0), SPH_C32(0xf092ce43), + SPH_C32(0x3514e139), SPH_C32(0xdb9000e0), SPH_C32(0x71147e32), + SPH_C32(0xbda9e4b9), SPH_C32(0x465f88aa) }, + { SPH_C32(0x91fe0020), SPH_C32(0xc6fa47b2), SPH_C32(0x30a1eebd), + SPH_C32(0xf5b721e4), SPH_C32(0x8acc00f0), SPH_C32(0x31e70cc9), + SPH_C32(0x414ec2bb), SPH_C32(0x3708d8cb) }, + { SPH_C32(0xc0a20030), SPH_C32(0x86093549), SPH_C32(0xcc46c8bf), + SPH_C32(0x84e07185), SPH_C32(0xa4f500f0), SPH_C32(0x553a6a40), + SPH_C32(0x7d9ac447), SPH_C32(0x86fc4877) }, + { SPH_C32(0x0cc30040), SPH_C32(0xd121e5a1), SPH_C32(0xba77c214), + SPH_C32(0xe6660ae5), SPH_C32(0x2fba00c0), SPH_C32(0x34e3a779), + SPH_C32(0x25ef0eb6), SPH_C32(0x67733c1d) }, + { SPH_C32(0x5d9f0050), SPH_C32(0x91d2975a), SPH_C32(0x4690e416), + SPH_C32(0x97315a84), SPH_C32(0x018300c0), SPH_C32(0x503ec1f0), + SPH_C32(0x193b084a), SPH_C32(0xd687aca1) }, + { SPH_C32(0x22fa0040), SPH_C32(0xb5fc8328), SPH_C32(0x86a3c4e8), + SPH_C32(0x57929a59), SPH_C32(0x50df00d0), SPH_C32(0x10cdb30b), + SPH_C32(0xe5dc2e48), SPH_C32(0xa7d0fcc0) }, + { SPH_C32(0x73a60050), SPH_C32(0xf50ff1d3), SPH_C32(0x7a44e2ea), + SPH_C32(0x26c5ca38), SPH_C32(0x7ee600d0), SPH_C32(0x7410d582), + SPH_C32(0xd90828b4), SPH_C32(0x16246c7c) }, + { SPH_C32(0xae7b0060), SPH_C32(0x50c60057), SPH_C32(0x43b98e10), + SPH_C32(0x04c9aa25), SPH_C32(0x73c800c0), SPH_C32(0xfd596a6b), + SPH_C32(0x5c46034f), SPH_C32(0x049a1d65) }, + { SPH_C32(0xff270070), SPH_C32(0x103572ac), SPH_C32(0xbf5ea812), + SPH_C32(0x759efa44), SPH_C32(0x5df100c0), SPH_C32(0x99840ce2), + SPH_C32(0x609205b3), SPH_C32(0xb56e8dd9) }, + { SPH_C32(0x80420060), SPH_C32(0x341b66de), SPH_C32(0x7f6d88ec), + SPH_C32(0xb53d3a99), SPH_C32(0x0cad00d0), SPH_C32(0xd9777e19), + SPH_C32(0x9c7523b1), SPH_C32(0xc439ddb8) }, + { SPH_C32(0xd11e0070), SPH_C32(0x74e81425), SPH_C32(0x838aaeee), + SPH_C32(0xc46a6af8), SPH_C32(0x229400d0), SPH_C32(0xbdaa1890), + SPH_C32(0xa0a1254d), SPH_C32(0x75cd4d04) }, + { SPH_C32(0x50b10040), SPH_C32(0x189b28b3), SPH_C32(0xc3decfed), + SPH_C32(0x858f2b9d), SPH_C32(0xd17000e0), SPH_C32(0x7cbe8f9d), + SPH_C32(0xa5884f4b), SPH_C32(0xe635bda5) }, + { SPH_C32(0x01ed0050), SPH_C32(0x58685a48), SPH_C32(0x3f39e9ef), + SPH_C32(0xf4d87bfc), SPH_C32(0xff4900e0), SPH_C32(0x1863e914), + SPH_C32(0x995c49b7), SPH_C32(0x57c12d19) }, + { SPH_C32(0x7e880040), SPH_C32(0x7c464e3a), SPH_C32(0xff0ac911), + SPH_C32(0x347bbb21), SPH_C32(0xae1500f0), SPH_C32(0x58909bef), + SPH_C32(0x65bb6fb5), SPH_C32(0x26967d78) }, + { SPH_C32(0x2fd40050), SPH_C32(0x3cb53cc1), SPH_C32(0x03edef13), + SPH_C32(0x452ceb40), SPH_C32(0x802c00f0), SPH_C32(0x3c4dfd66), + SPH_C32(0x596f6949), SPH_C32(0x9762edc4) }, + { SPH_C32(0xf2090060), SPH_C32(0x997ccd45), SPH_C32(0x3a1083e9), + SPH_C32(0x67208b5d), SPH_C32(0x8d0200e0), SPH_C32(0xb504428f), + SPH_C32(0xdc2142b2), SPH_C32(0x85dc9cdd) }, + { SPH_C32(0xa3550070), SPH_C32(0xd98fbfbe), SPH_C32(0xc6f7a5eb), + SPH_C32(0x1677db3c), SPH_C32(0xa33b00e0), SPH_C32(0xd1d92406), + SPH_C32(0xe0f5444e), SPH_C32(0x34280c61) }, + { SPH_C32(0xdc300060), SPH_C32(0xfda1abcc), SPH_C32(0x06c48515), + SPH_C32(0xd6d41be1), SPH_C32(0xf26700f0), SPH_C32(0x912a56fd), + SPH_C32(0x1c12624c), SPH_C32(0x457f5c00) }, + { SPH_C32(0x8d6c0070), SPH_C32(0xbd52d937), SPH_C32(0xfa23a317), + SPH_C32(0xa7834b80), SPH_C32(0xdc5e00f0), SPH_C32(0xf5f73074), + SPH_C32(0x20c664b0), SPH_C32(0xf48bccbc) }, + { SPH_C32(0x62740080), SPH_C32(0x0fb84b07), SPH_C32(0x138a651e), + SPH_C32(0x44100618), SPH_C32(0x5bd20080), SPH_C32(0x450f18ec), + SPH_C32(0xc2c46c55), SPH_C32(0xf362b233) }, + { SPH_C32(0x33280090), SPH_C32(0x4f4b39fc), SPH_C32(0xef6d431c), + SPH_C32(0x35475679), SPH_C32(0x75eb0080), SPH_C32(0x21d27e65), + SPH_C32(0xfe106aa9), SPH_C32(0x4296228f) }, + { SPH_C32(0x4c4d0080), SPH_C32(0x6b652d8e), SPH_C32(0x2f5e63e2), + SPH_C32(0xf5e496a4), SPH_C32(0x24b70090), SPH_C32(0x61210c9e), + SPH_C32(0x02f74cab), SPH_C32(0x33c172ee) }, + { SPH_C32(0x1d110090), SPH_C32(0x2b965f75), SPH_C32(0xd3b945e0), + SPH_C32(0x84b3c6c5), SPH_C32(0x0a8e0090), SPH_C32(0x05fc6a17), + SPH_C32(0x3e234a57), SPH_C32(0x8235e252) }, + { SPH_C32(0xc0cc00a0), SPH_C32(0x8e5faef1), SPH_C32(0xea44291a), + SPH_C32(0xa6bfa6d8), SPH_C32(0x07a00080), SPH_C32(0x8cb5d5fe), + SPH_C32(0xbb6d61ac), SPH_C32(0x908b934b) }, + { SPH_C32(0x919000b0), SPH_C32(0xceacdc0a), SPH_C32(0x16a30f18), + SPH_C32(0xd7e8f6b9), SPH_C32(0x29990080), SPH_C32(0xe868b377), + SPH_C32(0x87b96750), SPH_C32(0x217f03f7) }, + { SPH_C32(0xeef500a0), SPH_C32(0xea82c878), SPH_C32(0xd6902fe6), + SPH_C32(0x174b3664), SPH_C32(0x78c50090), SPH_C32(0xa89bc18c), + SPH_C32(0x7b5e4152), SPH_C32(0x50285396) }, + { SPH_C32(0xbfa900b0), SPH_C32(0xaa71ba83), SPH_C32(0x2a7709e4), + SPH_C32(0x661c6605), SPH_C32(0x56fc0090), SPH_C32(0xcc46a705), + SPH_C32(0x478a47ae), SPH_C32(0xe1dcc32a) }, + { SPH_C32(0x3e060080), SPH_C32(0xc6028615), SPH_C32(0x6a2368e7), + SPH_C32(0x27f92760), SPH_C32(0xa51800a0), SPH_C32(0x0d523008), + SPH_C32(0x42a32da8), SPH_C32(0x7224338b) }, + { SPH_C32(0x6f5a0090), SPH_C32(0x86f1f4ee), SPH_C32(0x96c44ee5), + SPH_C32(0x56ae7701), SPH_C32(0x8b2100a0), SPH_C32(0x698f5681), + SPH_C32(0x7e772b54), SPH_C32(0xc3d0a337) }, + { SPH_C32(0x103f0080), SPH_C32(0xa2dfe09c), SPH_C32(0x56f76e1b), + SPH_C32(0x960db7dc), SPH_C32(0xda7d00b0), SPH_C32(0x297c247a), + SPH_C32(0x82900d56), SPH_C32(0xb287f356) }, + { SPH_C32(0x41630090), SPH_C32(0xe22c9267), SPH_C32(0xaa104819), + SPH_C32(0xe75ae7bd), SPH_C32(0xf44400b0), SPH_C32(0x4da142f3), + SPH_C32(0xbe440baa), SPH_C32(0x037363ea) }, + { SPH_C32(0x9cbe00a0), SPH_C32(0x47e563e3), SPH_C32(0x93ed24e3), + SPH_C32(0xc55687a0), SPH_C32(0xf96a00a0), SPH_C32(0xc4e8fd1a), + SPH_C32(0x3b0a2051), SPH_C32(0x11cd12f3) }, + { SPH_C32(0xcde200b0), SPH_C32(0x07161118), SPH_C32(0x6f0a02e1), + SPH_C32(0xb401d7c1), SPH_C32(0xd75300a0), SPH_C32(0xa0359b93), + SPH_C32(0x07de26ad), SPH_C32(0xa039824f) }, + { SPH_C32(0xb28700a0), SPH_C32(0x2338056a), SPH_C32(0xaf39221f), + SPH_C32(0x74a2171c), SPH_C32(0x860f00b0), SPH_C32(0xe0c6e968), + SPH_C32(0xfb3900af), SPH_C32(0xd16ed22e) }, + { SPH_C32(0xe3db00b0), SPH_C32(0x63cb7791), SPH_C32(0x53de041d), + SPH_C32(0x05f5477d), SPH_C32(0xa83600b0), SPH_C32(0x841b8fe1), + SPH_C32(0xc7ed0653), SPH_C32(0x609a4292) }, + { SPH_C32(0x2fba00c0), SPH_C32(0x34e3a779), SPH_C32(0x25ef0eb6), + SPH_C32(0x67733c1d), SPH_C32(0x23790080), SPH_C32(0xe5c242d8), + SPH_C32(0x9f98cca2), SPH_C32(0x811536f8) }, + { SPH_C32(0x7ee600d0), SPH_C32(0x7410d582), SPH_C32(0xd90828b4), + SPH_C32(0x16246c7c), SPH_C32(0x0d400080), SPH_C32(0x811f2451), + SPH_C32(0xa34cca5e), SPH_C32(0x30e1a644) }, + { SPH_C32(0x018300c0), SPH_C32(0x503ec1f0), SPH_C32(0x193b084a), + SPH_C32(0xd687aca1), SPH_C32(0x5c1c0090), SPH_C32(0xc1ec56aa), + SPH_C32(0x5fabec5c), SPH_C32(0x41b6f625) }, + { SPH_C32(0x50df00d0), SPH_C32(0x10cdb30b), SPH_C32(0xe5dc2e48), + SPH_C32(0xa7d0fcc0), SPH_C32(0x72250090), SPH_C32(0xa5313023), + SPH_C32(0x637feaa0), SPH_C32(0xf0426699) }, + { SPH_C32(0x8d0200e0), SPH_C32(0xb504428f), SPH_C32(0xdc2142b2), + SPH_C32(0x85dc9cdd), SPH_C32(0x7f0b0080), SPH_C32(0x2c788fca), + SPH_C32(0xe631c15b), SPH_C32(0xe2fc1780) }, + { SPH_C32(0xdc5e00f0), SPH_C32(0xf5f73074), SPH_C32(0x20c664b0), + SPH_C32(0xf48bccbc), SPH_C32(0x51320080), SPH_C32(0x48a5e943), + SPH_C32(0xdae5c7a7), SPH_C32(0x5308873c) }, + { SPH_C32(0xa33b00e0), SPH_C32(0xd1d92406), SPH_C32(0xe0f5444e), + SPH_C32(0x34280c61), SPH_C32(0x006e0090), SPH_C32(0x08569bb8), + SPH_C32(0x2602e1a5), SPH_C32(0x225fd75d) }, + { SPH_C32(0xf26700f0), SPH_C32(0x912a56fd), SPH_C32(0x1c12624c), + SPH_C32(0x457f5c00), SPH_C32(0x2e570090), SPH_C32(0x6c8bfd31), + SPH_C32(0x1ad6e759), SPH_C32(0x93ab47e1) }, + { SPH_C32(0x73c800c0), SPH_C32(0xfd596a6b), SPH_C32(0x5c46034f), + SPH_C32(0x049a1d65), SPH_C32(0xddb300a0), SPH_C32(0xad9f6a3c), + SPH_C32(0x1fff8d5f), SPH_C32(0x0053b740) }, + { SPH_C32(0x229400d0), SPH_C32(0xbdaa1890), SPH_C32(0xa0a1254d), + SPH_C32(0x75cd4d04), SPH_C32(0xf38a00a0), SPH_C32(0xc9420cb5), + SPH_C32(0x232b8ba3), SPH_C32(0xb1a727fc) }, + { SPH_C32(0x5df100c0), SPH_C32(0x99840ce2), SPH_C32(0x609205b3), + SPH_C32(0xb56e8dd9), SPH_C32(0xa2d600b0), SPH_C32(0x89b17e4e), + SPH_C32(0xdfccada1), SPH_C32(0xc0f0779d) }, + { SPH_C32(0x0cad00d0), SPH_C32(0xd9777e19), SPH_C32(0x9c7523b1), + SPH_C32(0xc439ddb8), SPH_C32(0x8cef00b0), SPH_C32(0xed6c18c7), + SPH_C32(0xe318ab5d), SPH_C32(0x7104e721) }, + { SPH_C32(0xd17000e0), SPH_C32(0x7cbe8f9d), SPH_C32(0xa5884f4b), + SPH_C32(0xe635bda5), SPH_C32(0x81c100a0), SPH_C32(0x6425a72e), + SPH_C32(0x665680a6), SPH_C32(0x63ba9638) }, + { SPH_C32(0x802c00f0), SPH_C32(0x3c4dfd66), SPH_C32(0x596f6949), + SPH_C32(0x9762edc4), SPH_C32(0xaff800a0), SPH_C32(0x00f8c1a7), + SPH_C32(0x5a82865a), SPH_C32(0xd24e0684) }, + { SPH_C32(0xff4900e0), SPH_C32(0x1863e914), SPH_C32(0x995c49b7), + SPH_C32(0x57c12d19), SPH_C32(0xfea400b0), SPH_C32(0x400bb35c), + SPH_C32(0xa665a058), SPH_C32(0xa31956e5) }, + { SPH_C32(0xae1500f0), SPH_C32(0x58909bef), SPH_C32(0x65bb6fb5), + SPH_C32(0x26967d78), SPH_C32(0xd09d00b0), SPH_C32(0x24d6d5d5), + SPH_C32(0x9ab1a6a4), SPH_C32(0x12edc659) }, + { SPH_C32(0x1adf0080), SPH_C32(0xaf751133), SPH_C32(0x4ed6c5e9), + SPH_C32(0x366782d3), SPH_C32(0x6eb700c0), SPH_C32(0xde99aea6), + SPH_C32(0xa9fda70a), SPH_C32(0xa2760cfd) }, + { SPH_C32(0x4b830090), SPH_C32(0xef8663c8), SPH_C32(0xb231e3eb), + SPH_C32(0x4730d2b2), SPH_C32(0x408e00c0), SPH_C32(0xba44c82f), + SPH_C32(0x9529a1f6), SPH_C32(0x13829c41) }, + { SPH_C32(0x34e60080), SPH_C32(0xcba877ba), SPH_C32(0x7202c315), + SPH_C32(0x8793126f), SPH_C32(0x11d200d0), SPH_C32(0xfab7bad4), + SPH_C32(0x69ce87f4), SPH_C32(0x62d5cc20) }, + { SPH_C32(0x65ba0090), SPH_C32(0x8b5b0541), SPH_C32(0x8ee5e517), + SPH_C32(0xf6c4420e), SPH_C32(0x3feb00d0), SPH_C32(0x9e6adc5d), + SPH_C32(0x551a8108), SPH_C32(0xd3215c9c) }, + { SPH_C32(0xb86700a0), SPH_C32(0x2e92f4c5), SPH_C32(0xb71889ed), + SPH_C32(0xd4c82213), SPH_C32(0x32c500c0), SPH_C32(0x172363b4), + SPH_C32(0xd054aaf3), SPH_C32(0xc19f2d85) }, + { SPH_C32(0xe93b00b0), SPH_C32(0x6e61863e), SPH_C32(0x4bffafef), + SPH_C32(0xa59f7272), SPH_C32(0x1cfc00c0), SPH_C32(0x73fe053d), + SPH_C32(0xec80ac0f), SPH_C32(0x706bbd39) }, + { SPH_C32(0x965e00a0), SPH_C32(0x4a4f924c), SPH_C32(0x8bcc8f11), + SPH_C32(0x653cb2af), SPH_C32(0x4da000d0), SPH_C32(0x330d77c6), + SPH_C32(0x10678a0d), SPH_C32(0x013ced58) }, + { SPH_C32(0xc70200b0), SPH_C32(0x0abce0b7), SPH_C32(0x772ba913), + SPH_C32(0x146be2ce), SPH_C32(0x639900d0), SPH_C32(0x57d0114f), + SPH_C32(0x2cb38cf1), SPH_C32(0xb0c87de4) }, + { SPH_C32(0x46ad0080), SPH_C32(0x66cfdc21), SPH_C32(0x377fc810), + SPH_C32(0x558ea3ab), SPH_C32(0x907d00e0), SPH_C32(0x96c48642), + SPH_C32(0x299ae6f7), SPH_C32(0x23308d45) }, + { SPH_C32(0x17f10090), SPH_C32(0x263caeda), SPH_C32(0xcb98ee12), + SPH_C32(0x24d9f3ca), SPH_C32(0xbe4400e0), SPH_C32(0xf219e0cb), + SPH_C32(0x154ee00b), SPH_C32(0x92c41df9) }, + { SPH_C32(0x68940080), SPH_C32(0x0212baa8), SPH_C32(0x0babceec), + SPH_C32(0xe47a3317), SPH_C32(0xef1800f0), SPH_C32(0xb2ea9230), + SPH_C32(0xe9a9c609), SPH_C32(0xe3934d98) }, + { SPH_C32(0x39c80090), SPH_C32(0x42e1c853), SPH_C32(0xf74ce8ee), + SPH_C32(0x952d6376), SPH_C32(0xc12100f0), SPH_C32(0xd637f4b9), + SPH_C32(0xd57dc0f5), SPH_C32(0x5267dd24) }, + { SPH_C32(0xe41500a0), SPH_C32(0xe72839d7), SPH_C32(0xceb18414), + SPH_C32(0xb721036b), SPH_C32(0xcc0f00e0), SPH_C32(0x5f7e4b50), + SPH_C32(0x5033eb0e), SPH_C32(0x40d9ac3d) }, + { SPH_C32(0xb54900b0), SPH_C32(0xa7db4b2c), SPH_C32(0x3256a216), + SPH_C32(0xc676530a), SPH_C32(0xe23600e0), SPH_C32(0x3ba32dd9), + SPH_C32(0x6ce7edf2), SPH_C32(0xf12d3c81) }, + { SPH_C32(0xca2c00a0), SPH_C32(0x83f55f5e), SPH_C32(0xf26582e8), + SPH_C32(0x06d593d7), SPH_C32(0xb36a00f0), SPH_C32(0x7b505f22), + SPH_C32(0x9000cbf0), SPH_C32(0x807a6ce0) }, + { SPH_C32(0x9b7000b0), SPH_C32(0xc3062da5), SPH_C32(0x0e82a4ea), + SPH_C32(0x7782c3b6), SPH_C32(0x9d5300f0), SPH_C32(0x1f8d39ab), + SPH_C32(0xacd4cd0c), SPH_C32(0x318efc5c) }, + { SPH_C32(0x571100c0), SPH_C32(0x942efd4d), SPH_C32(0x78b3ae41), + SPH_C32(0x1504b8d6), SPH_C32(0x161c00c0), SPH_C32(0x7e54f492), + SPH_C32(0xf4a107fd), SPH_C32(0xd0018836) }, + { SPH_C32(0x064d00d0), SPH_C32(0xd4dd8fb6), SPH_C32(0x84548843), + SPH_C32(0x6453e8b7), SPH_C32(0x382500c0), SPH_C32(0x1a89921b), + SPH_C32(0xc8750101), SPH_C32(0x61f5188a) }, + { SPH_C32(0x792800c0), SPH_C32(0xf0f39bc4), SPH_C32(0x4467a8bd), + SPH_C32(0xa4f0286a), SPH_C32(0x697900d0), SPH_C32(0x5a7ae0e0), + SPH_C32(0x34922703), SPH_C32(0x10a248eb) }, + { SPH_C32(0x287400d0), SPH_C32(0xb000e93f), SPH_C32(0xb8808ebf), + SPH_C32(0xd5a7780b), SPH_C32(0x474000d0), SPH_C32(0x3ea78669), + SPH_C32(0x084621ff), SPH_C32(0xa156d857) }, + { SPH_C32(0xf5a900e0), SPH_C32(0x15c918bb), SPH_C32(0x817de245), + SPH_C32(0xf7ab1816), SPH_C32(0x4a6e00c0), SPH_C32(0xb7ee3980), + SPH_C32(0x8d080a04), SPH_C32(0xb3e8a94e) }, + { SPH_C32(0xa4f500f0), SPH_C32(0x553a6a40), SPH_C32(0x7d9ac447), + SPH_C32(0x86fc4877), SPH_C32(0x645700c0), SPH_C32(0xd3335f09), + SPH_C32(0xb1dc0cf8), SPH_C32(0x021c39f2) }, + { SPH_C32(0xdb9000e0), SPH_C32(0x71147e32), SPH_C32(0xbda9e4b9), + SPH_C32(0x465f88aa), SPH_C32(0x350b00d0), SPH_C32(0x93c02df2), + SPH_C32(0x4d3b2afa), SPH_C32(0x734b6993) }, + { SPH_C32(0x8acc00f0), SPH_C32(0x31e70cc9), SPH_C32(0x414ec2bb), + SPH_C32(0x3708d8cb), SPH_C32(0x1b3200d0), SPH_C32(0xf71d4b7b), + SPH_C32(0x71ef2c06), SPH_C32(0xc2bff92f) }, + { SPH_C32(0x0b6300c0), SPH_C32(0x5d94305f), SPH_C32(0x011aa3b8), + SPH_C32(0x76ed99ae), SPH_C32(0xe8d600e0), SPH_C32(0x3609dc76), + SPH_C32(0x74c64600), SPH_C32(0x5147098e) }, + { SPH_C32(0x5a3f00d0), SPH_C32(0x1d6742a4), SPH_C32(0xfdfd85ba), + SPH_C32(0x07bac9cf), SPH_C32(0xc6ef00e0), SPH_C32(0x52d4baff), + SPH_C32(0x481240fc), SPH_C32(0xe0b39932) }, + { SPH_C32(0x255a00c0), SPH_C32(0x394956d6), SPH_C32(0x3dcea544), + SPH_C32(0xc7190912), SPH_C32(0x97b300f0), SPH_C32(0x1227c804), + SPH_C32(0xb4f566fe), SPH_C32(0x91e4c953) }, + { SPH_C32(0x740600d0), SPH_C32(0x79ba242d), SPH_C32(0xc1298346), + SPH_C32(0xb64e5973), SPH_C32(0xb98a00f0), SPH_C32(0x76faae8d), + SPH_C32(0x88216002), SPH_C32(0x201059ef) }, + { SPH_C32(0xa9db00e0), SPH_C32(0xdc73d5a9), SPH_C32(0xf8d4efbc), + SPH_C32(0x9442396e), SPH_C32(0xb4a400e0), SPH_C32(0xffb31164), + SPH_C32(0x0d6f4bf9), SPH_C32(0x32ae28f6) }, + { SPH_C32(0xf88700f0), SPH_C32(0x9c80a752), SPH_C32(0x0433c9be), + SPH_C32(0xe515690f), SPH_C32(0x9a9d00e0), SPH_C32(0x9b6e77ed), + SPH_C32(0x31bb4d05), SPH_C32(0x835ab84a) }, + { SPH_C32(0x87e200e0), SPH_C32(0xb8aeb320), SPH_C32(0xc400e940), + SPH_C32(0x25b6a9d2), SPH_C32(0xcbc100f0), SPH_C32(0xdb9d0516), + SPH_C32(0xcd5c6b07), SPH_C32(0xf20de82b) }, + { SPH_C32(0xd6be00f0), SPH_C32(0xf85dc1db), SPH_C32(0x38e7cf42), + SPH_C32(0x54e1f9b3), SPH_C32(0xe5f800f0), SPH_C32(0xbf40639f), + SPH_C32(0xf1886dfb), SPH_C32(0x43f97897) } +}; + +static const sph_u32 T256_24[256][8] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000) }, + { SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), SPH_C32(0xae0ebb05), + SPH_C32(0xb5a4c63b), SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), + SPH_C32(0x6bf648a4), SPH_C32(0x539cbdbf) }, + { SPH_C32(0xc8f10000), SPH_C32(0x0b2de782), SPH_C32(0x6bf648a4), + SPH_C32(0x539cbdbf), SPH_C32(0x08bf0001), SPH_C32(0x38942792), + SPH_C32(0xc5f8f3a1), SPH_C32(0xe6387b84) }, + { SPH_C32(0x08bf0001), SPH_C32(0x38942792), SPH_C32(0xc5f8f3a1), + SPH_C32(0xe6387b84), SPH_C32(0xc04e0001), SPH_C32(0x33b9c010), + SPH_C32(0xae0ebb05), SPH_C32(0xb5a4c63b) }, + { SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), SPH_C32(0x99e585aa), + SPH_C32(0x8d75f7f1), SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), + SPH_C32(0x79e22a4c), SPH_C32(0x1298bd46) }, + { SPH_C32(0x486d0003), SPH_C32(0x6c5e67a3), SPH_C32(0x37eb3eaf), + SPH_C32(0x38d131ca), SPH_C32(0x995d0000), SPH_C32(0x2ecee896), + SPH_C32(0x121462e8), SPH_C32(0x410400f9) }, + { SPH_C32(0x40d20002), SPH_C32(0x54ca4031), SPH_C32(0xf213cd0e), + SPH_C32(0xdee94a4e), SPH_C32(0x59130001), SPH_C32(0x1d772886), + SPH_C32(0xbc1ad9ed), SPH_C32(0xf4a0c6c2) }, + { SPH_C32(0x809c0003), SPH_C32(0x67738021), SPH_C32(0x5c1d760b), + SPH_C32(0x6b4d8c75), SPH_C32(0x91e20001), SPH_C32(0x165acf04), + SPH_C32(0xd7ec9149), SPH_C32(0xa73c7b7d) }, + { SPH_C32(0x51ac0000), SPH_C32(0x25e30f14), SPH_C32(0x79e22a4c), + SPH_C32(0x1298bd46), SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), + SPH_C32(0xe007afe6), SPH_C32(0x9fed4ab7) }, + { SPH_C32(0x91e20001), SPH_C32(0x165acf04), SPH_C32(0xd7ec9149), + SPH_C32(0xa73c7b7d), SPH_C32(0x117e0002), SPH_C32(0x71294f25), + SPH_C32(0x8bf1e742), SPH_C32(0xcc71f708) }, + { SPH_C32(0x995d0000), SPH_C32(0x2ecee896), SPH_C32(0x121462e8), + SPH_C32(0x410400f9), SPH_C32(0xd1300003), SPH_C32(0x42908f35), + SPH_C32(0x25ff5c47), SPH_C32(0x79d53133) }, + { SPH_C32(0x59130001), SPH_C32(0x1d772886), SPH_C32(0xbc1ad9ed), + SPH_C32(0xf4a0c6c2), SPH_C32(0x19c10003), SPH_C32(0x49bd68b7), + SPH_C32(0x4e0914e3), SPH_C32(0x2a498c8c) }, + { SPH_C32(0xd98f0002), SPH_C32(0x7a04a8a7), SPH_C32(0xe007afe6), + SPH_C32(0x9fed4ab7), SPH_C32(0x88230002), SPH_C32(0x5fe7a7b3), + SPH_C32(0x99e585aa), SPH_C32(0x8d75f7f1) }, + { SPH_C32(0x19c10003), SPH_C32(0x49bd68b7), SPH_C32(0x4e0914e3), + SPH_C32(0x2a498c8c), SPH_C32(0x40d20002), SPH_C32(0x54ca4031), + SPH_C32(0xf213cd0e), SPH_C32(0xdee94a4e) }, + { SPH_C32(0x117e0002), SPH_C32(0x71294f25), SPH_C32(0x8bf1e742), + SPH_C32(0xcc71f708), SPH_C32(0x809c0003), SPH_C32(0x67738021), + SPH_C32(0x5c1d760b), SPH_C32(0x6b4d8c75) }, + { SPH_C32(0xd1300003), SPH_C32(0x42908f35), SPH_C32(0x25ff5c47), + SPH_C32(0x79d53133), SPH_C32(0x486d0003), SPH_C32(0x6c5e67a3), + SPH_C32(0x37eb3eaf), SPH_C32(0x38d131ca) }, + { SPH_C32(0xd0080004), SPH_C32(0x8c768f77), SPH_C32(0x9dc5b050), + SPH_C32(0xaf4a29da), SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), + SPH_C32(0x98321c3d), SPH_C32(0x76acc733) }, + { SPH_C32(0x10460005), SPH_C32(0xbfcf4f67), SPH_C32(0x33cb0b55), + SPH_C32(0x1aeeefe1), SPH_C32(0xa3580000), SPH_C32(0x4bc61e28), + SPH_C32(0xf3c45499), SPH_C32(0x25307a8c) }, + { SPH_C32(0x18f90004), SPH_C32(0x875b68f5), SPH_C32(0xf633f8f4), + SPH_C32(0xfcd69465), SPH_C32(0x63160001), SPH_C32(0x787fde38), + SPH_C32(0x5dcaef9c), SPH_C32(0x9094bcb7) }, + { SPH_C32(0xd8b70005), SPH_C32(0xb4e2a8e5), SPH_C32(0x583d43f1), + SPH_C32(0x4972525e), SPH_C32(0xabe70001), SPH_C32(0x735239ba), + SPH_C32(0x363ca738), SPH_C32(0xc3080108) }, + { SPH_C32(0x582b0006), SPH_C32(0xd39128c4), SPH_C32(0x042035fa), + SPH_C32(0x223fde2b), SPH_C32(0x3a050000), SPH_C32(0x6508f6be), + SPH_C32(0xe1d03671), SPH_C32(0x64347a75) }, + { SPH_C32(0x98650007), SPH_C32(0xe028e8d4), SPH_C32(0xaa2e8eff), + SPH_C32(0x979b1810), SPH_C32(0xf2f40000), SPH_C32(0x6e25113c), + SPH_C32(0x8a267ed5), SPH_C32(0x37a8c7ca) }, + { SPH_C32(0x90da0006), SPH_C32(0xd8bccf46), SPH_C32(0x6fd67d5e), + SPH_C32(0x71a36394), SPH_C32(0x32ba0001), SPH_C32(0x5d9cd12c), + SPH_C32(0x2428c5d0), SPH_C32(0x820c01f1) }, + { SPH_C32(0x50940007), SPH_C32(0xeb050f56), SPH_C32(0xc1d8c65b), + SPH_C32(0xc407a5af), SPH_C32(0xfa4b0001), SPH_C32(0x56b136ae), + SPH_C32(0x4fde8d74), SPH_C32(0xd190bc4e) }, + { SPH_C32(0x81a40004), SPH_C32(0xa9958063), SPH_C32(0xe4279a1c), + SPH_C32(0xbdd2949c), SPH_C32(0xb2260002), SPH_C32(0x3aef510d), + SPH_C32(0x7835b3db), SPH_C32(0xe9418d84) }, + { SPH_C32(0x41ea0005), SPH_C32(0x9a2c4073), SPH_C32(0x4a292119), + SPH_C32(0x087652a7), SPH_C32(0x7ad70002), SPH_C32(0x31c2b68f), + SPH_C32(0x13c3fb7f), SPH_C32(0xbadd303b) }, + { SPH_C32(0x49550004), SPH_C32(0xa2b867e1), SPH_C32(0x8fd1d2b8), + SPH_C32(0xee4e2923), SPH_C32(0xba990003), SPH_C32(0x027b769f), + SPH_C32(0xbdcd407a), SPH_C32(0x0f79f600) }, + { SPH_C32(0x891b0005), SPH_C32(0x9101a7f1), SPH_C32(0x21df69bd), + SPH_C32(0x5beaef18), SPH_C32(0x72680003), SPH_C32(0x0956911d), + SPH_C32(0xd63b08de), SPH_C32(0x5ce54bbf) }, + { SPH_C32(0x09870006), SPH_C32(0xf67227d0), SPH_C32(0x7dc21fb6), + SPH_C32(0x30a7636d), SPH_C32(0xe38a0002), SPH_C32(0x1f0c5e19), + SPH_C32(0x01d79997), SPH_C32(0xfbd930c2) }, + { SPH_C32(0xc9c90007), SPH_C32(0xc5cbe7c0), SPH_C32(0xd3cca4b3), + SPH_C32(0x8503a556), SPH_C32(0x2b7b0002), SPH_C32(0x1421b99b), + SPH_C32(0x6a21d133), SPH_C32(0xa8458d7d) }, + { SPH_C32(0xc1760006), SPH_C32(0xfd5fc052), SPH_C32(0x16345712), + SPH_C32(0x633bded2), SPH_C32(0xeb350003), SPH_C32(0x2798798b), + SPH_C32(0xc42f6a36), SPH_C32(0x1de14b46) }, + { SPH_C32(0x01380007), SPH_C32(0xcee60042), SPH_C32(0xb83aec17), + SPH_C32(0xd69f18e9), SPH_C32(0x23c40003), SPH_C32(0x2cb59e09), + SPH_C32(0xafd92292), SPH_C32(0x4e7df6f9) }, + { SPH_C32(0x6ba90000), SPH_C32(0x40ebf9aa), SPH_C32(0x98321c3d), + SPH_C32(0x76acc733), SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), + SPH_C32(0x05f7ac6d), SPH_C32(0xd9e6eee9) }, + { SPH_C32(0xabe70001), SPH_C32(0x735239ba), SPH_C32(0x363ca738), + SPH_C32(0xc3080108), SPH_C32(0x73500004), SPH_C32(0xc7b0915f), + SPH_C32(0x6e01e4c9), SPH_C32(0x8a7a5356) }, + { SPH_C32(0xa3580000), SPH_C32(0x4bc61e28), SPH_C32(0xf3c45499), + SPH_C32(0x25307a8c), SPH_C32(0xb31e0005), SPH_C32(0xf409514f), + SPH_C32(0xc00f5fcc), SPH_C32(0x3fde956d) }, + { SPH_C32(0x63160001), SPH_C32(0x787fde38), SPH_C32(0x5dcaef9c), + SPH_C32(0x9094bcb7), SPH_C32(0x7bef0005), SPH_C32(0xff24b6cd), + SPH_C32(0xabf91768), SPH_C32(0x6c4228d2) }, + { SPH_C32(0xe38a0002), SPH_C32(0x1f0c5e19), SPH_C32(0x01d79997), + SPH_C32(0xfbd930c2), SPH_C32(0xea0d0004), SPH_C32(0xe97e79c9), + SPH_C32(0x7c158621), SPH_C32(0xcb7e53af) }, + { SPH_C32(0x23c40003), SPH_C32(0x2cb59e09), SPH_C32(0xafd92292), + SPH_C32(0x4e7df6f9), SPH_C32(0x22fc0004), SPH_C32(0xe2539e4b), + SPH_C32(0x17e3ce85), SPH_C32(0x98e2ee10) }, + { SPH_C32(0x2b7b0002), SPH_C32(0x1421b99b), SPH_C32(0x6a21d133), + SPH_C32(0xa8458d7d), SPH_C32(0xe2b20005), SPH_C32(0xd1ea5e5b), + SPH_C32(0xb9ed7580), SPH_C32(0x2d46282b) }, + { SPH_C32(0xeb350003), SPH_C32(0x2798798b), SPH_C32(0xc42f6a36), + SPH_C32(0x1de14b46), SPH_C32(0x2a430005), SPH_C32(0xdac7b9d9), + SPH_C32(0xd21b3d24), SPH_C32(0x7eda9594) }, + { SPH_C32(0x3a050000), SPH_C32(0x6508f6be), SPH_C32(0xe1d03671), + SPH_C32(0x64347a75), SPH_C32(0x622e0006), SPH_C32(0xb699de7a), + SPH_C32(0xe5f0038b), SPH_C32(0x460ba45e) }, + { SPH_C32(0xfa4b0001), SPH_C32(0x56b136ae), SPH_C32(0x4fde8d74), + SPH_C32(0xd190bc4e), SPH_C32(0xaadf0006), SPH_C32(0xbdb439f8), + SPH_C32(0x8e064b2f), SPH_C32(0x159719e1) }, + { SPH_C32(0xf2f40000), SPH_C32(0x6e25113c), SPH_C32(0x8a267ed5), + SPH_C32(0x37a8c7ca), SPH_C32(0x6a910007), SPH_C32(0x8e0df9e8), + SPH_C32(0x2008f02a), SPH_C32(0xa033dfda) }, + { SPH_C32(0x32ba0001), SPH_C32(0x5d9cd12c), SPH_C32(0x2428c5d0), + SPH_C32(0x820c01f1), SPH_C32(0xa2600007), SPH_C32(0x85201e6a), + SPH_C32(0x4bfeb88e), SPH_C32(0xf3af6265) }, + { SPH_C32(0xb2260002), SPH_C32(0x3aef510d), SPH_C32(0x7835b3db), + SPH_C32(0xe9418d84), SPH_C32(0x33820006), SPH_C32(0x937ad16e), + SPH_C32(0x9c1229c7), SPH_C32(0x54931918) }, + { SPH_C32(0x72680003), SPH_C32(0x0956911d), SPH_C32(0xd63b08de), + SPH_C32(0x5ce54bbf), SPH_C32(0xfb730006), SPH_C32(0x985736ec), + SPH_C32(0xf7e46163), SPH_C32(0x070fa4a7) }, + { SPH_C32(0x7ad70002), SPH_C32(0x31c2b68f), SPH_C32(0x13c3fb7f), + SPH_C32(0xbadd303b), SPH_C32(0x3b3d0007), SPH_C32(0xabeef6fc), + SPH_C32(0x59eada66), SPH_C32(0xb2ab629c) }, + { SPH_C32(0xba990003), SPH_C32(0x027b769f), SPH_C32(0xbdcd407a), + SPH_C32(0x0f79f600), SPH_C32(0xf3cc0007), SPH_C32(0xa0c3117e), + SPH_C32(0x321c92c2), SPH_C32(0xe137df23) }, + { SPH_C32(0xbba10004), SPH_C32(0xcc9d76dd), SPH_C32(0x05f7ac6d), + SPH_C32(0xd9e6eee9), SPH_C32(0xd0080004), SPH_C32(0x8c768f77), + SPH_C32(0x9dc5b050), SPH_C32(0xaf4a29da) }, + { SPH_C32(0x7bef0005), SPH_C32(0xff24b6cd), SPH_C32(0xabf91768), + SPH_C32(0x6c4228d2), SPH_C32(0x18f90004), SPH_C32(0x875b68f5), + SPH_C32(0xf633f8f4), SPH_C32(0xfcd69465) }, + { SPH_C32(0x73500004), SPH_C32(0xc7b0915f), SPH_C32(0x6e01e4c9), + SPH_C32(0x8a7a5356), SPH_C32(0xd8b70005), SPH_C32(0xb4e2a8e5), + SPH_C32(0x583d43f1), SPH_C32(0x4972525e) }, + { SPH_C32(0xb31e0005), SPH_C32(0xf409514f), SPH_C32(0xc00f5fcc), + SPH_C32(0x3fde956d), SPH_C32(0x10460005), SPH_C32(0xbfcf4f67), + SPH_C32(0x33cb0b55), SPH_C32(0x1aeeefe1) }, + { SPH_C32(0x33820006), SPH_C32(0x937ad16e), SPH_C32(0x9c1229c7), + SPH_C32(0x54931918), SPH_C32(0x81a40004), SPH_C32(0xa9958063), + SPH_C32(0xe4279a1c), SPH_C32(0xbdd2949c) }, + { SPH_C32(0xf3cc0007), SPH_C32(0xa0c3117e), SPH_C32(0x321c92c2), + SPH_C32(0xe137df23), SPH_C32(0x49550004), SPH_C32(0xa2b867e1), + SPH_C32(0x8fd1d2b8), SPH_C32(0xee4e2923) }, + { SPH_C32(0xfb730006), SPH_C32(0x985736ec), SPH_C32(0xf7e46163), + SPH_C32(0x070fa4a7), SPH_C32(0x891b0005), SPH_C32(0x9101a7f1), + SPH_C32(0x21df69bd), SPH_C32(0x5beaef18) }, + { SPH_C32(0x3b3d0007), SPH_C32(0xabeef6fc), SPH_C32(0x59eada66), + SPH_C32(0xb2ab629c), SPH_C32(0x41ea0005), SPH_C32(0x9a2c4073), + SPH_C32(0x4a292119), SPH_C32(0x087652a7) }, + { SPH_C32(0xea0d0004), SPH_C32(0xe97e79c9), SPH_C32(0x7c158621), + SPH_C32(0xcb7e53af), SPH_C32(0x09870006), SPH_C32(0xf67227d0), + SPH_C32(0x7dc21fb6), SPH_C32(0x30a7636d) }, + { SPH_C32(0x2a430005), SPH_C32(0xdac7b9d9), SPH_C32(0xd21b3d24), + SPH_C32(0x7eda9594), SPH_C32(0xc1760006), SPH_C32(0xfd5fc052), + SPH_C32(0x16345712), SPH_C32(0x633bded2) }, + { SPH_C32(0x22fc0004), SPH_C32(0xe2539e4b), SPH_C32(0x17e3ce85), + SPH_C32(0x98e2ee10), SPH_C32(0x01380007), SPH_C32(0xcee60042), + SPH_C32(0xb83aec17), SPH_C32(0xd69f18e9) }, + { SPH_C32(0xe2b20005), SPH_C32(0xd1ea5e5b), SPH_C32(0xb9ed7580), + SPH_C32(0x2d46282b), SPH_C32(0xc9c90007), SPH_C32(0xc5cbe7c0), + SPH_C32(0xd3cca4b3), SPH_C32(0x8503a556) }, + { SPH_C32(0x622e0006), SPH_C32(0xb699de7a), SPH_C32(0xe5f0038b), + SPH_C32(0x460ba45e), SPH_C32(0x582b0006), SPH_C32(0xd39128c4), + SPH_C32(0x042035fa), SPH_C32(0x223fde2b) }, + { SPH_C32(0xa2600007), SPH_C32(0x85201e6a), SPH_C32(0x4bfeb88e), + SPH_C32(0xf3af6265), SPH_C32(0x90da0006), SPH_C32(0xd8bccf46), + SPH_C32(0x6fd67d5e), SPH_C32(0x71a36394) }, + { SPH_C32(0xaadf0006), SPH_C32(0xbdb439f8), SPH_C32(0x8e064b2f), + SPH_C32(0x159719e1), SPH_C32(0x50940007), SPH_C32(0xeb050f56), + SPH_C32(0xc1d8c65b), SPH_C32(0xc407a5af) }, + { SPH_C32(0x6a910007), SPH_C32(0x8e0df9e8), SPH_C32(0x2008f02a), + SPH_C32(0xa033dfda), SPH_C32(0x98650007), SPH_C32(0xe028e8d4), + SPH_C32(0xaa2e8eff), SPH_C32(0x979b1810) }, + { SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), SPH_C32(0xfe739301), + SPH_C32(0xb8a92831), SPH_C32(0x171c0000), SPH_C32(0xb26e3344), + SPH_C32(0x9e6a837e), SPH_C32(0x58f8485f) }, + { SPH_C32(0x68e00009), SPH_C32(0x13c0f96d), SPH_C32(0x507d2804), + SPH_C32(0x0d0dee0a), SPH_C32(0xdfed0000), SPH_C32(0xb943d4c6), + SPH_C32(0xf59ccbda), SPH_C32(0x0b64f5e0) }, + { SPH_C32(0x605f0008), SPH_C32(0x2b54deff), SPH_C32(0x9585dba5), + SPH_C32(0xeb35958e), SPH_C32(0x1fa30001), SPH_C32(0x8afa14d6), + SPH_C32(0x5b9270df), SPH_C32(0xbec033db) }, + { SPH_C32(0xa0110009), SPH_C32(0x18ed1eef), SPH_C32(0x3b8b60a0), + SPH_C32(0x5e9153b5), SPH_C32(0xd7520001), SPH_C32(0x81d7f354), + SPH_C32(0x3064387b), SPH_C32(0xed5c8e64) }, + { SPH_C32(0x208d000a), SPH_C32(0x7f9e9ece), SPH_C32(0x679616ab), + SPH_C32(0x35dcdfc0), SPH_C32(0x46b00000), SPH_C32(0x978d3c50), + SPH_C32(0xe788a932), SPH_C32(0x4a60f519) }, + { SPH_C32(0xe0c3000b), SPH_C32(0x4c275ede), SPH_C32(0xc998adae), + SPH_C32(0x807819fb), SPH_C32(0x8e410000), SPH_C32(0x9ca0dbd2), + SPH_C32(0x8c7ee196), SPH_C32(0x19fc48a6) }, + { SPH_C32(0xe87c000a), SPH_C32(0x74b3794c), SPH_C32(0x0c605e0f), + SPH_C32(0x6640627f), SPH_C32(0x4e0f0001), SPH_C32(0xaf191bc2), + SPH_C32(0x22705a93), SPH_C32(0xac588e9d) }, + { SPH_C32(0x2832000b), SPH_C32(0x470ab95c), SPH_C32(0xa26ee50a), + SPH_C32(0xd3e4a444), SPH_C32(0x86fe0001), SPH_C32(0xa434fc40), + SPH_C32(0x49861237), SPH_C32(0xffc43322) }, + { SPH_C32(0xf9020008), SPH_C32(0x059a3669), SPH_C32(0x8791b94d), + SPH_C32(0xaa319577), SPH_C32(0xce930002), SPH_C32(0xc86a9be3), + SPH_C32(0x7e6d2c98), SPH_C32(0xc71502e8) }, + { SPH_C32(0x394c0009), SPH_C32(0x3623f679), SPH_C32(0x299f0248), + SPH_C32(0x1f95534c), SPH_C32(0x06620002), SPH_C32(0xc3477c61), + SPH_C32(0x159b643c), SPH_C32(0x9489bf57) }, + { SPH_C32(0x31f30008), SPH_C32(0x0eb7d1eb), SPH_C32(0xec67f1e9), + SPH_C32(0xf9ad28c8), SPH_C32(0xc62c0003), SPH_C32(0xf0febc71), + SPH_C32(0xbb95df39), SPH_C32(0x212d796c) }, + { SPH_C32(0xf1bd0009), SPH_C32(0x3d0e11fb), SPH_C32(0x42694aec), + SPH_C32(0x4c09eef3), SPH_C32(0x0edd0003), SPH_C32(0xfbd35bf3), + SPH_C32(0xd063979d), SPH_C32(0x72b1c4d3) }, + { SPH_C32(0x7121000a), SPH_C32(0x5a7d91da), SPH_C32(0x1e743ce7), + SPH_C32(0x27446286), SPH_C32(0x9f3f0002), SPH_C32(0xed8994f7), + SPH_C32(0x078f06d4), SPH_C32(0xd58dbfae) }, + { SPH_C32(0xb16f000b), SPH_C32(0x69c451ca), SPH_C32(0xb07a87e2), + SPH_C32(0x92e0a4bd), SPH_C32(0x57ce0002), SPH_C32(0xe6a47375), + SPH_C32(0x6c794e70), SPH_C32(0x86110211) }, + { SPH_C32(0xb9d0000a), SPH_C32(0x51507658), SPH_C32(0x75827443), + SPH_C32(0x74d8df39), SPH_C32(0x97800003), SPH_C32(0xd51db365), + SPH_C32(0xc277f575), SPH_C32(0x33b5c42a) }, + { SPH_C32(0x799e000b), SPH_C32(0x62e9b648), SPH_C32(0xdb8ccf46), + SPH_C32(0xc17c1902), SPH_C32(0x5f710003), SPH_C32(0xde3054e7), + SPH_C32(0xa981bdd1), SPH_C32(0x60297995) }, + { SPH_C32(0x78a6000c), SPH_C32(0xac0fb60a), SPH_C32(0x63b62351), + SPH_C32(0x17e301eb), SPH_C32(0x7cb50000), SPH_C32(0xf285caee), + SPH_C32(0x06589f43), SPH_C32(0x2e548f6c) }, + { SPH_C32(0xb8e8000d), SPH_C32(0x9fb6761a), SPH_C32(0xcdb89854), + SPH_C32(0xa247c7d0), SPH_C32(0xb4440000), SPH_C32(0xf9a82d6c), + SPH_C32(0x6daed7e7), SPH_C32(0x7dc832d3) }, + { SPH_C32(0xb057000c), SPH_C32(0xa7225188), SPH_C32(0x08406bf5), + SPH_C32(0x447fbc54), SPH_C32(0x740a0001), SPH_C32(0xca11ed7c), + SPH_C32(0xc3a06ce2), SPH_C32(0xc86cf4e8) }, + { SPH_C32(0x7019000d), SPH_C32(0x949b9198), SPH_C32(0xa64ed0f0), + SPH_C32(0xf1db7a6f), SPH_C32(0xbcfb0001), SPH_C32(0xc13c0afe), + SPH_C32(0xa8562446), SPH_C32(0x9bf04957) }, + { SPH_C32(0xf085000e), SPH_C32(0xf3e811b9), SPH_C32(0xfa53a6fb), + SPH_C32(0x9a96f61a), SPH_C32(0x2d190000), SPH_C32(0xd766c5fa), + SPH_C32(0x7fbab50f), SPH_C32(0x3ccc322a) }, + { SPH_C32(0x30cb000f), SPH_C32(0xc051d1a9), SPH_C32(0x545d1dfe), + SPH_C32(0x2f323021), SPH_C32(0xe5e80000), SPH_C32(0xdc4b2278), + SPH_C32(0x144cfdab), SPH_C32(0x6f508f95) }, + { SPH_C32(0x3874000e), SPH_C32(0xf8c5f63b), SPH_C32(0x91a5ee5f), + SPH_C32(0xc90a4ba5), SPH_C32(0x25a60001), SPH_C32(0xeff2e268), + SPH_C32(0xba4246ae), SPH_C32(0xdaf449ae) }, + { SPH_C32(0xf83a000f), SPH_C32(0xcb7c362b), SPH_C32(0x3fab555a), + SPH_C32(0x7cae8d9e), SPH_C32(0xed570001), SPH_C32(0xe4df05ea), + SPH_C32(0xd1b40e0a), SPH_C32(0x8968f411) }, + { SPH_C32(0x290a000c), SPH_C32(0x89ecb91e), SPH_C32(0x1a54091d), + SPH_C32(0x057bbcad), SPH_C32(0xa53a0002), SPH_C32(0x88816249), + SPH_C32(0xe65f30a5), SPH_C32(0xb1b9c5db) }, + { SPH_C32(0xe944000d), SPH_C32(0xba55790e), SPH_C32(0xb45ab218), + SPH_C32(0xb0df7a96), SPH_C32(0x6dcb0002), SPH_C32(0x83ac85cb), + SPH_C32(0x8da97801), SPH_C32(0xe2257864) }, + { SPH_C32(0xe1fb000c), SPH_C32(0x82c15e9c), SPH_C32(0x71a241b9), + SPH_C32(0x56e70112), SPH_C32(0xad850003), SPH_C32(0xb01545db), + SPH_C32(0x23a7c304), SPH_C32(0x5781be5f) }, + { SPH_C32(0x21b5000d), SPH_C32(0xb1789e8c), SPH_C32(0xdfacfabc), + SPH_C32(0xe343c729), SPH_C32(0x65740003), SPH_C32(0xbb38a259), + SPH_C32(0x48518ba0), SPH_C32(0x041d03e0) }, + { SPH_C32(0xa129000e), SPH_C32(0xd60b1ead), SPH_C32(0x83b18cb7), + SPH_C32(0x880e4b5c), SPH_C32(0xf4960002), SPH_C32(0xad626d5d), + SPH_C32(0x9fbd1ae9), SPH_C32(0xa321789d) }, + { SPH_C32(0x6167000f), SPH_C32(0xe5b2debd), SPH_C32(0x2dbf37b2), + SPH_C32(0x3daa8d67), SPH_C32(0x3c670002), SPH_C32(0xa64f8adf), + SPH_C32(0xf44b524d), SPH_C32(0xf0bdc522) }, + { SPH_C32(0x69d8000e), SPH_C32(0xdd26f92f), SPH_C32(0xe847c413), + SPH_C32(0xdb92f6e3), SPH_C32(0xfc290003), SPH_C32(0x95f64acf), + SPH_C32(0x5a45e948), SPH_C32(0x45190319) }, + { SPH_C32(0xa996000f), SPH_C32(0xee9f393f), SPH_C32(0x46497f16), + SPH_C32(0x6e3630d8), SPH_C32(0x34d80003), SPH_C32(0x9edbad4d), + SPH_C32(0x31b3a1ec), SPH_C32(0x1685bea6) }, + { SPH_C32(0xc3070008), SPH_C32(0x6092c0d7), SPH_C32(0x66418f3c), + SPH_C32(0xce05ef02), SPH_C32(0xacbd0004), SPH_C32(0x7ef34599), + SPH_C32(0x9b9d2f13), SPH_C32(0x811ea6b6) }, + { SPH_C32(0x03490009), SPH_C32(0x532b00c7), SPH_C32(0xc84f3439), + SPH_C32(0x7ba12939), SPH_C32(0x644c0004), SPH_C32(0x75dea21b), + SPH_C32(0xf06b67b7), SPH_C32(0xd2821b09) }, + { SPH_C32(0x0bf60008), SPH_C32(0x6bbf2755), SPH_C32(0x0db7c798), + SPH_C32(0x9d9952bd), SPH_C32(0xa4020005), SPH_C32(0x4667620b), + SPH_C32(0x5e65dcb2), SPH_C32(0x6726dd32) }, + { SPH_C32(0xcbb80009), SPH_C32(0x5806e745), SPH_C32(0xa3b97c9d), + SPH_C32(0x283d9486), SPH_C32(0x6cf30005), SPH_C32(0x4d4a8589), + SPH_C32(0x35939416), SPH_C32(0x34ba608d) }, + { SPH_C32(0x4b24000a), SPH_C32(0x3f756764), SPH_C32(0xffa40a96), + SPH_C32(0x437018f3), SPH_C32(0xfd110004), SPH_C32(0x5b104a8d), + SPH_C32(0xe27f055f), SPH_C32(0x93861bf0) }, + { SPH_C32(0x8b6a000b), SPH_C32(0x0ccca774), SPH_C32(0x51aab193), + SPH_C32(0xf6d4dec8), SPH_C32(0x35e00004), SPH_C32(0x503dad0f), + SPH_C32(0x89894dfb), SPH_C32(0xc01aa64f) }, + { SPH_C32(0x83d5000a), SPH_C32(0x345880e6), SPH_C32(0x94524232), + SPH_C32(0x10eca54c), SPH_C32(0xf5ae0005), SPH_C32(0x63846d1f), + SPH_C32(0x2787f6fe), SPH_C32(0x75be6074) }, + { SPH_C32(0x439b000b), SPH_C32(0x07e140f6), SPH_C32(0x3a5cf937), + SPH_C32(0xa5486377), SPH_C32(0x3d5f0005), SPH_C32(0x68a98a9d), + SPH_C32(0x4c71be5a), SPH_C32(0x2622ddcb) }, + { SPH_C32(0x92ab0008), SPH_C32(0x4571cfc3), SPH_C32(0x1fa3a570), + SPH_C32(0xdc9d5244), SPH_C32(0x75320006), SPH_C32(0x04f7ed3e), + SPH_C32(0x7b9a80f5), SPH_C32(0x1ef3ec01) }, + { SPH_C32(0x52e50009), SPH_C32(0x76c80fd3), SPH_C32(0xb1ad1e75), + SPH_C32(0x6939947f), SPH_C32(0xbdc30006), SPH_C32(0x0fda0abc), + SPH_C32(0x106cc851), SPH_C32(0x4d6f51be) }, + { SPH_C32(0x5a5a0008), SPH_C32(0x4e5c2841), SPH_C32(0x7455edd4), + SPH_C32(0x8f01effb), SPH_C32(0x7d8d0007), SPH_C32(0x3c63caac), + SPH_C32(0xbe627354), SPH_C32(0xf8cb9785) }, + { SPH_C32(0x9a140009), SPH_C32(0x7de5e851), SPH_C32(0xda5b56d1), + SPH_C32(0x3aa529c0), SPH_C32(0xb57c0007), SPH_C32(0x374e2d2e), + SPH_C32(0xd5943bf0), SPH_C32(0xab572a3a) }, + { SPH_C32(0x1a88000a), SPH_C32(0x1a966870), SPH_C32(0x864620da), + SPH_C32(0x51e8a5b5), SPH_C32(0x249e0006), SPH_C32(0x2114e22a), + SPH_C32(0x0278aab9), SPH_C32(0x0c6b5147) }, + { SPH_C32(0xdac6000b), SPH_C32(0x292fa860), SPH_C32(0x28489bdf), + SPH_C32(0xe44c638e), SPH_C32(0xec6f0006), SPH_C32(0x2a3905a8), + SPH_C32(0x698ee21d), SPH_C32(0x5ff7ecf8) }, + { SPH_C32(0xd279000a), SPH_C32(0x11bb8ff2), SPH_C32(0xedb0687e), + SPH_C32(0x0274180a), SPH_C32(0x2c210007), SPH_C32(0x1980c5b8), + SPH_C32(0xc7805918), SPH_C32(0xea532ac3) }, + { SPH_C32(0x1237000b), SPH_C32(0x22024fe2), SPH_C32(0x43bed37b), + SPH_C32(0xb7d0de31), SPH_C32(0xe4d00007), SPH_C32(0x12ad223a), + SPH_C32(0xac7611bc), SPH_C32(0xb9cf977c) }, + { SPH_C32(0x130f000c), SPH_C32(0xece44fa0), SPH_C32(0xfb843f6c), + SPH_C32(0x614fc6d8), SPH_C32(0xc7140004), SPH_C32(0x3e18bc33), + SPH_C32(0x03af332e), SPH_C32(0xf7b26185) }, + { SPH_C32(0xd341000d), SPH_C32(0xdf5d8fb0), SPH_C32(0x558a8469), + SPH_C32(0xd4eb00e3), SPH_C32(0x0fe50004), SPH_C32(0x35355bb1), + SPH_C32(0x68597b8a), SPH_C32(0xa42edc3a) }, + { SPH_C32(0xdbfe000c), SPH_C32(0xe7c9a822), SPH_C32(0x907277c8), + SPH_C32(0x32d37b67), SPH_C32(0xcfab0005), SPH_C32(0x068c9ba1), + SPH_C32(0xc657c08f), SPH_C32(0x118a1a01) }, + { SPH_C32(0x1bb0000d), SPH_C32(0xd4706832), SPH_C32(0x3e7ccccd), + SPH_C32(0x8777bd5c), SPH_C32(0x075a0005), SPH_C32(0x0da17c23), + SPH_C32(0xada1882b), SPH_C32(0x4216a7be) }, + { SPH_C32(0x9b2c000e), SPH_C32(0xb303e813), SPH_C32(0x6261bac6), + SPH_C32(0xec3a3129), SPH_C32(0x96b80004), SPH_C32(0x1bfbb327), + SPH_C32(0x7a4d1962), SPH_C32(0xe52adcc3) }, + { SPH_C32(0x5b62000f), SPH_C32(0x80ba2803), SPH_C32(0xcc6f01c3), + SPH_C32(0x599ef712), SPH_C32(0x5e490004), SPH_C32(0x10d654a5), + SPH_C32(0x11bb51c6), SPH_C32(0xb6b6617c) }, + { SPH_C32(0x53dd000e), SPH_C32(0xb82e0f91), SPH_C32(0x0997f262), + SPH_C32(0xbfa68c96), SPH_C32(0x9e070005), SPH_C32(0x236f94b5), + SPH_C32(0xbfb5eac3), SPH_C32(0x0312a747) }, + { SPH_C32(0x9393000f), SPH_C32(0x8b97cf81), SPH_C32(0xa7994967), + SPH_C32(0x0a024aad), SPH_C32(0x56f60005), SPH_C32(0x28427337), + SPH_C32(0xd443a267), SPH_C32(0x508e1af8) }, + { SPH_C32(0x42a3000c), SPH_C32(0xc90740b4), SPH_C32(0x82661520), + SPH_C32(0x73d77b9e), SPH_C32(0x1e9b0006), SPH_C32(0x441c1494), + SPH_C32(0xe3a89cc8), SPH_C32(0x685f2b32) }, + { SPH_C32(0x82ed000d), SPH_C32(0xfabe80a4), SPH_C32(0x2c68ae25), + SPH_C32(0xc673bda5), SPH_C32(0xd66a0006), SPH_C32(0x4f31f316), + SPH_C32(0x885ed46c), SPH_C32(0x3bc3968d) }, + { SPH_C32(0x8a52000c), SPH_C32(0xc22aa736), SPH_C32(0xe9905d84), + SPH_C32(0x204bc621), SPH_C32(0x16240007), SPH_C32(0x7c883306), + SPH_C32(0x26506f69), SPH_C32(0x8e6750b6) }, + { SPH_C32(0x4a1c000d), SPH_C32(0xf1936726), SPH_C32(0x479ee681), + SPH_C32(0x95ef001a), SPH_C32(0xded50007), SPH_C32(0x77a5d484), + SPH_C32(0x4da627cd), SPH_C32(0xddfbed09) }, + { SPH_C32(0xca80000e), SPH_C32(0x96e0e707), SPH_C32(0x1b83908a), + SPH_C32(0xfea28c6f), SPH_C32(0x4f370006), SPH_C32(0x61ff1b80), + SPH_C32(0x9a4ab684), SPH_C32(0x7ac79674) }, + { SPH_C32(0x0ace000f), SPH_C32(0xa5592717), SPH_C32(0xb58d2b8f), + SPH_C32(0x4b064a54), SPH_C32(0x87c60006), SPH_C32(0x6ad2fc02), + SPH_C32(0xf1bcfe20), SPH_C32(0x295b2bcb) }, + { SPH_C32(0x0271000e), SPH_C32(0x9dcd0085), SPH_C32(0x7075d82e), + SPH_C32(0xad3e31d0), SPH_C32(0x47880007), SPH_C32(0x596b3c12), + SPH_C32(0x5fb24525), SPH_C32(0x9cffedf0) }, + { SPH_C32(0xc23f000f), SPH_C32(0xae74c095), SPH_C32(0xde7b632b), + SPH_C32(0x189af7eb), SPH_C32(0x8f790007), SPH_C32(0x5246db90), + SPH_C32(0x34440d81), SPH_C32(0xcf63504f) }, + { SPH_C32(0x171c0000), SPH_C32(0xb26e3344), SPH_C32(0x9e6a837e), + SPH_C32(0x58f8485f), SPH_C32(0xbfb20008), SPH_C32(0x92170a39), + SPH_C32(0x6019107f), SPH_C32(0xe051606e) }, + { SPH_C32(0xd7520001), SPH_C32(0x81d7f354), SPH_C32(0x3064387b), + SPH_C32(0xed5c8e64), SPH_C32(0x77430008), SPH_C32(0x993aedbb), + SPH_C32(0x0bef58db), SPH_C32(0xb3cdddd1) }, + { SPH_C32(0xdfed0000), SPH_C32(0xb943d4c6), SPH_C32(0xf59ccbda), + SPH_C32(0x0b64f5e0), SPH_C32(0xb70d0009), SPH_C32(0xaa832dab), + SPH_C32(0xa5e1e3de), SPH_C32(0x06691bea) }, + { SPH_C32(0x1fa30001), SPH_C32(0x8afa14d6), SPH_C32(0x5b9270df), + SPH_C32(0xbec033db), SPH_C32(0x7ffc0009), SPH_C32(0xa1aeca29), + SPH_C32(0xce17ab7a), SPH_C32(0x55f5a655) }, + { SPH_C32(0x9f3f0002), SPH_C32(0xed8994f7), SPH_C32(0x078f06d4), + SPH_C32(0xd58dbfae), SPH_C32(0xee1e0008), SPH_C32(0xb7f4052d), + SPH_C32(0x19fb3a33), SPH_C32(0xf2c9dd28) }, + { SPH_C32(0x5f710003), SPH_C32(0xde3054e7), SPH_C32(0xa981bdd1), + SPH_C32(0x60297995), SPH_C32(0x26ef0008), SPH_C32(0xbcd9e2af), + SPH_C32(0x720d7297), SPH_C32(0xa1556097) }, + { SPH_C32(0x57ce0002), SPH_C32(0xe6a47375), SPH_C32(0x6c794e70), + SPH_C32(0x86110211), SPH_C32(0xe6a10009), SPH_C32(0x8f6022bf), + SPH_C32(0xdc03c992), SPH_C32(0x14f1a6ac) }, + { SPH_C32(0x97800003), SPH_C32(0xd51db365), SPH_C32(0xc277f575), + SPH_C32(0x33b5c42a), SPH_C32(0x2e500009), SPH_C32(0x844dc53d), + SPH_C32(0xb7f58136), SPH_C32(0x476d1b13) }, + { SPH_C32(0x46b00000), SPH_C32(0x978d3c50), SPH_C32(0xe788a932), + SPH_C32(0x4a60f519), SPH_C32(0x663d000a), SPH_C32(0xe813a29e), + SPH_C32(0x801ebf99), SPH_C32(0x7fbc2ad9) }, + { SPH_C32(0x86fe0001), SPH_C32(0xa434fc40), SPH_C32(0x49861237), + SPH_C32(0xffc43322), SPH_C32(0xaecc000a), SPH_C32(0xe33e451c), + SPH_C32(0xebe8f73d), SPH_C32(0x2c209766) }, + { SPH_C32(0x8e410000), SPH_C32(0x9ca0dbd2), SPH_C32(0x8c7ee196), + SPH_C32(0x19fc48a6), SPH_C32(0x6e82000b), SPH_C32(0xd087850c), + SPH_C32(0x45e64c38), SPH_C32(0x9984515d) }, + { SPH_C32(0x4e0f0001), SPH_C32(0xaf191bc2), SPH_C32(0x22705a93), + SPH_C32(0xac588e9d), SPH_C32(0xa673000b), SPH_C32(0xdbaa628e), + SPH_C32(0x2e10049c), SPH_C32(0xca18ece2) }, + { SPH_C32(0xce930002), SPH_C32(0xc86a9be3), SPH_C32(0x7e6d2c98), + SPH_C32(0xc71502e8), SPH_C32(0x3791000a), SPH_C32(0xcdf0ad8a), + SPH_C32(0xf9fc95d5), SPH_C32(0x6d24979f) }, + { SPH_C32(0x0edd0003), SPH_C32(0xfbd35bf3), SPH_C32(0xd063979d), + SPH_C32(0x72b1c4d3), SPH_C32(0xff60000a), SPH_C32(0xc6dd4a08), + SPH_C32(0x920add71), SPH_C32(0x3eb82a20) }, + { SPH_C32(0x06620002), SPH_C32(0xc3477c61), SPH_C32(0x159b643c), + SPH_C32(0x9489bf57), SPH_C32(0x3f2e000b), SPH_C32(0xf5648a18), + SPH_C32(0x3c046674), SPH_C32(0x8b1cec1b) }, + { SPH_C32(0xc62c0003), SPH_C32(0xf0febc71), SPH_C32(0xbb95df39), + SPH_C32(0x212d796c), SPH_C32(0xf7df000b), SPH_C32(0xfe496d9a), + SPH_C32(0x57f22ed0), SPH_C32(0xd88051a4) }, + { SPH_C32(0xc7140004), SPH_C32(0x3e18bc33), SPH_C32(0x03af332e), + SPH_C32(0xf7b26185), SPH_C32(0xd41b0008), SPH_C32(0xd2fcf393), + SPH_C32(0xf82b0c42), SPH_C32(0x96fda75d) }, + { SPH_C32(0x075a0005), SPH_C32(0x0da17c23), SPH_C32(0xada1882b), + SPH_C32(0x4216a7be), SPH_C32(0x1cea0008), SPH_C32(0xd9d11411), + SPH_C32(0x93dd44e6), SPH_C32(0xc5611ae2) }, + { SPH_C32(0x0fe50004), SPH_C32(0x35355bb1), SPH_C32(0x68597b8a), + SPH_C32(0xa42edc3a), SPH_C32(0xdca40009), SPH_C32(0xea68d401), + SPH_C32(0x3dd3ffe3), SPH_C32(0x70c5dcd9) }, + { SPH_C32(0xcfab0005), SPH_C32(0x068c9ba1), SPH_C32(0xc657c08f), + SPH_C32(0x118a1a01), SPH_C32(0x14550009), SPH_C32(0xe1453383), + SPH_C32(0x5625b747), SPH_C32(0x23596166) }, + { SPH_C32(0x4f370006), SPH_C32(0x61ff1b80), SPH_C32(0x9a4ab684), + SPH_C32(0x7ac79674), SPH_C32(0x85b70008), SPH_C32(0xf71ffc87), + SPH_C32(0x81c9260e), SPH_C32(0x84651a1b) }, + { SPH_C32(0x8f790007), SPH_C32(0x5246db90), SPH_C32(0x34440d81), + SPH_C32(0xcf63504f), SPH_C32(0x4d460008), SPH_C32(0xfc321b05), + SPH_C32(0xea3f6eaa), SPH_C32(0xd7f9a7a4) }, + { SPH_C32(0x87c60006), SPH_C32(0x6ad2fc02), SPH_C32(0xf1bcfe20), + SPH_C32(0x295b2bcb), SPH_C32(0x8d080009), SPH_C32(0xcf8bdb15), + SPH_C32(0x4431d5af), SPH_C32(0x625d619f) }, + { SPH_C32(0x47880007), SPH_C32(0x596b3c12), SPH_C32(0x5fb24525), + SPH_C32(0x9cffedf0), SPH_C32(0x45f90009), SPH_C32(0xc4a63c97), + SPH_C32(0x2fc79d0b), SPH_C32(0x31c1dc20) }, + { SPH_C32(0x96b80004), SPH_C32(0x1bfbb327), SPH_C32(0x7a4d1962), + SPH_C32(0xe52adcc3), SPH_C32(0x0d94000a), SPH_C32(0xa8f85b34), + SPH_C32(0x182ca3a4), SPH_C32(0x0910edea) }, + { SPH_C32(0x56f60005), SPH_C32(0x28427337), SPH_C32(0xd443a267), + SPH_C32(0x508e1af8), SPH_C32(0xc565000a), SPH_C32(0xa3d5bcb6), + SPH_C32(0x73daeb00), SPH_C32(0x5a8c5055) }, + { SPH_C32(0x5e490004), SPH_C32(0x10d654a5), SPH_C32(0x11bb51c6), + SPH_C32(0xb6b6617c), SPH_C32(0x052b000b), SPH_C32(0x906c7ca6), + SPH_C32(0xddd45005), SPH_C32(0xef28966e) }, + { SPH_C32(0x9e070005), SPH_C32(0x236f94b5), SPH_C32(0xbfb5eac3), + SPH_C32(0x0312a747), SPH_C32(0xcdda000b), SPH_C32(0x9b419b24), + SPH_C32(0xb62218a1), SPH_C32(0xbcb42bd1) }, + { SPH_C32(0x1e9b0006), SPH_C32(0x441c1494), SPH_C32(0xe3a89cc8), + SPH_C32(0x685f2b32), SPH_C32(0x5c38000a), SPH_C32(0x8d1b5420), + SPH_C32(0x61ce89e8), SPH_C32(0x1b8850ac) }, + { SPH_C32(0xded50007), SPH_C32(0x77a5d484), SPH_C32(0x4da627cd), + SPH_C32(0xddfbed09), SPH_C32(0x94c9000a), SPH_C32(0x8636b3a2), + SPH_C32(0x0a38c14c), SPH_C32(0x4814ed13) }, + { SPH_C32(0xd66a0006), SPH_C32(0x4f31f316), SPH_C32(0x885ed46c), + SPH_C32(0x3bc3968d), SPH_C32(0x5487000b), SPH_C32(0xb58f73b2), + SPH_C32(0xa4367a49), SPH_C32(0xfdb02b28) }, + { SPH_C32(0x16240007), SPH_C32(0x7c883306), SPH_C32(0x26506f69), + SPH_C32(0x8e6750b6), SPH_C32(0x9c76000b), SPH_C32(0xbea29430), + SPH_C32(0xcfc032ed), SPH_C32(0xae2c49697) }, + { SPH_C32(0x7cb50000), SPH_C32(0xf285caee), SPH_C32(0x06589f43), + SPH_C32(0x2e548f6c), SPH_C32(0x0413000c), SPH_C32(0x5e8a7ce4), + SPH_C32(0x65eebc12), SPH_C32(0x39b78e87) }, + { SPH_C32(0xbcfb0001), SPH_C32(0xc13c0afe), SPH_C32(0xa8562446), + SPH_C32(0x9bf04957), SPH_C32(0xcce2000c), SPH_C32(0x55a79b66), + SPH_C32(0x0e18f4b6), SPH_C32(0x6a2b3338) }, + { SPH_C32(0xb4440000), SPH_C32(0xf9a82d6c), SPH_C32(0x6daed7e7), + SPH_C32(0x7dc832d3), SPH_C32(0x0cac000d), SPH_C32(0x661e5b76), + SPH_C32(0xa0164fb3), SPH_C32(0xdf8ff503) }, + { SPH_C32(0x740a0001), SPH_C32(0xca11ed7c), SPH_C32(0xc3a06ce2), + SPH_C32(0xc86cf4e8), SPH_C32(0xc45d000d), SPH_C32(0x6d33bcf4), + SPH_C32(0xcbe00717), SPH_C32(0x8c1348bc) }, + { SPH_C32(0xf4960002), SPH_C32(0xad626d5d), SPH_C32(0x9fbd1ae9), + SPH_C32(0xa321789d), SPH_C32(0x55bf000c), SPH_C32(0x7b6973f0), + SPH_C32(0x1c0c965e), SPH_C32(0x2b2f33c1) }, + { SPH_C32(0x34d80003), SPH_C32(0x9edbad4d), SPH_C32(0x31b3a1ec), + SPH_C32(0x1685bea6), SPH_C32(0x9d4e000c), SPH_C32(0x70449472), + SPH_C32(0x77fadefa), SPH_C32(0x78b38e7e) }, + { SPH_C32(0x3c670002), SPH_C32(0xa64f8adf), SPH_C32(0xf44b524d), + SPH_C32(0xf0bdc522), SPH_C32(0x5d00000d), SPH_C32(0x43fd5462), + SPH_C32(0xd9f465ff), SPH_C32(0xcd174845) }, + { SPH_C32(0xfc290003), SPH_C32(0x95f64acf), SPH_C32(0x5a45e948), + SPH_C32(0x45190319), SPH_C32(0x95f1000d), SPH_C32(0x48d0b3e0), + SPH_C32(0xb2022d5b), SPH_C32(0x9e8bf5fa) }, + { SPH_C32(0x2d190000), SPH_C32(0xd766c5fa), SPH_C32(0x7fbab50f), + SPH_C32(0x3ccc322a), SPH_C32(0xdd9c000e), SPH_C32(0x248ed443), + SPH_C32(0x85e913f4), SPH_C32(0xa65ac430) }, + { SPH_C32(0xed570001), SPH_C32(0xe4df05ea), SPH_C32(0xd1b40e0a), + SPH_C32(0x8968f411), SPH_C32(0x156d000e), SPH_C32(0x2fa333c1), + SPH_C32(0xee1f5b50), SPH_C32(0xf5c6798f) }, + { SPH_C32(0xe5e80000), SPH_C32(0xdc4b2278), SPH_C32(0x144cfdab), + SPH_C32(0x6f508f95), SPH_C32(0xd523000f), SPH_C32(0x1c1af3d1), + SPH_C32(0x4011e055), SPH_C32(0x4062bfb4) }, + { SPH_C32(0x25a60001), SPH_C32(0xeff2e268), SPH_C32(0xba4246ae), + SPH_C32(0xdaf449ae), SPH_C32(0x1dd2000f), SPH_C32(0x17371453), + SPH_C32(0x2be7a8f1), SPH_C32(0x13fe020b) }, + { SPH_C32(0xa53a0002), SPH_C32(0x88816249), SPH_C32(0xe65f30a5), + SPH_C32(0xb1b9c5db), SPH_C32(0x8c30000e), SPH_C32(0x016ddb57), + SPH_C32(0xfc0b39b8), SPH_C32(0xb4c27976) }, + { SPH_C32(0x65740003), SPH_C32(0xbb38a259), SPH_C32(0x48518ba0), + SPH_C32(0x041d03e0), SPH_C32(0x44c1000e), SPH_C32(0x0a403cd5), + SPH_C32(0x97fd711c), SPH_C32(0xe75ec4c9) }, + { SPH_C32(0x6dcb0002), SPH_C32(0x83ac85cb), SPH_C32(0x8da97801), + SPH_C32(0xe2257864), SPH_C32(0x848f000f), SPH_C32(0x39f9fcc5), + SPH_C32(0x39f3ca19), SPH_C32(0x52fa02f2) }, + { SPH_C32(0xad850003), SPH_C32(0xb01545db), SPH_C32(0x23a7c304), + SPH_C32(0x5781be5f), SPH_C32(0x4c7e000f), SPH_C32(0x32d41b47), + SPH_C32(0x520582bd), SPH_C32(0x0166bf4d) }, + { SPH_C32(0xacbd0004), SPH_C32(0x7ef34599), SPH_C32(0x9b9d2f13), + SPH_C32(0x811ea6b6), SPH_C32(0x6fba000c), SPH_C32(0x1e61854e), + SPH_C32(0xfddca02f), SPH_C32(0x4f1b49b4) }, + { SPH_C32(0x6cf30005), SPH_C32(0x4d4a8589), SPH_C32(0x35939416), + SPH_C32(0x34ba608d), SPH_C32(0xa74b000c), SPH_C32(0x154c62cc), + SPH_C32(0x962ae88b), SPH_C32(0x1c87f40b) }, + { SPH_C32(0x644c0004), SPH_C32(0x75dea21b), SPH_C32(0xf06b67b7), + SPH_C32(0xd2821b09), SPH_C32(0x6705000d), SPH_C32(0x26f5a2dc), + SPH_C32(0x3824538e), SPH_C32(0xa9233230) }, + { SPH_C32(0xa4020005), SPH_C32(0x4667620b), SPH_C32(0x5e65dcb2), + SPH_C32(0x6726dd32), SPH_C32(0xaff4000d), SPH_C32(0x2dd8455e), + SPH_C32(0x53d21b2a), SPH_C32(0xfabf8f8f) }, + { SPH_C32(0x249e0006), SPH_C32(0x2114e22a), SPH_C32(0x0278aab9), + SPH_C32(0x0c6b5147), SPH_C32(0x3e16000c), SPH_C32(0x3b828a5a), + SPH_C32(0x843e8a63), SPH_C32(0x5d83f4f2) }, + { SPH_C32(0xe4d00007), SPH_C32(0x12ad223a), SPH_C32(0xac7611bc), + SPH_C32(0xb9cf977c), SPH_C32(0xf6e7000c), SPH_C32(0x30af6dd8), + SPH_C32(0xefc8c2c7), SPH_C32(0x0e1f494d) }, + { SPH_C32(0xec6f0006), SPH_C32(0x2a3905a8), SPH_C32(0x698ee21d), + SPH_C32(0x5ff7ecf8), SPH_C32(0x36a9000d), SPH_C32(0x0316adc8), + SPH_C32(0x41c679c2), SPH_C32(0xbbbb8f76) }, + { SPH_C32(0x2c210007), SPH_C32(0x1980c5b8), SPH_C32(0xc7805918), + SPH_C32(0xea532ac3), SPH_C32(0xfe58000d), SPH_C32(0x083b4a4a), + SPH_C32(0x2a303166), SPH_C32(0xe82732c9) }, + { SPH_C32(0xfd110004), SPH_C32(0x5b104a8d), SPH_C32(0xe27f055f), + SPH_C32(0x93861bf0), SPH_C32(0xb635000e), SPH_C32(0x64652de9), + SPH_C32(0x1ddb0fc9), SPH_C32(0xd0f60303) }, + { SPH_C32(0x3d5f0005), SPH_C32(0x68a98a9d), SPH_C32(0x4c71be5a), + SPH_C32(0x2622ddcb), SPH_C32(0x7ec4000e), SPH_C32(0x6f48ca6b), + SPH_C32(0x762d476d), SPH_C32(0x836abebc) }, + { SPH_C32(0x35e00004), SPH_C32(0x503dad0f), SPH_C32(0x89894dfb), + SPH_C32(0xc01aa64f), SPH_C32(0xbe8a000f), SPH_C32(0x5cf10a7b), + SPH_C32(0xd823fc68), SPH_C32(0x36ce7887) }, + { SPH_C32(0xf5ae0005), SPH_C32(0x63846d1f), SPH_C32(0x2787f6fe), + SPH_C32(0x75be6074), SPH_C32(0x767b000f), SPH_C32(0x57dcedf9), + SPH_C32(0xb3d5b4cc), SPH_C32(0x6552c538) }, + { SPH_C32(0x75320006), SPH_C32(0x04f7ed3e), SPH_C32(0x7b9a80f5), + SPH_C32(0x1ef3ec01), SPH_C32(0xe799000e), SPH_C32(0x418622fd), + SPH_C32(0x64392585), SPH_C32(0xc26ebe45) }, + { SPH_C32(0xb57c0007), SPH_C32(0x374e2d2e), SPH_C32(0xd5943bf0), + SPH_C32(0xab572a3a), SPH_C32(0x2f68000e), SPH_C32(0x4aabc57f), + SPH_C32(0x0fcf6d21), SPH_C32(0x91f203fa) }, + { SPH_C32(0xbdc30006), SPH_C32(0x0fda0abc), SPH_C32(0x106cc851), + SPH_C32(0x4d6f51be), SPH_C32(0xef26000f), SPH_C32(0x7912056f), + SPH_C32(0xa1c1d624), SPH_C32(0x2456c5c1) }, + { SPH_C32(0x7d8d0007), SPH_C32(0x3c63caac), SPH_C32(0xbe627354), + SPH_C32(0xf8cb9785), SPH_C32(0x27d7000f), SPH_C32(0x723fe2ed), + SPH_C32(0xca379e80), SPH_C32(0x77ca787e) }, + { SPH_C32(0xbfb20008), SPH_C32(0x92170a39), SPH_C32(0x6019107f), + SPH_C32(0xe051606e), SPH_C32(0xa8ae0008), SPH_C32(0x2079397d), + SPH_C32(0xfe739301), SPH_C32(0xb8a92831) }, + { SPH_C32(0x7ffc0009), SPH_C32(0xa1aeca29), SPH_C32(0xce17ab7a), + SPH_C32(0x55f5a655), SPH_C32(0x605f0008), SPH_C32(0x2b54deff), + SPH_C32(0x9585dba5), SPH_C32(0xeb35958e) }, + { SPH_C32(0x77430008), SPH_C32(0x993aedbb), SPH_C32(0x0bef58db), + SPH_C32(0xb3cdddd1), SPH_C32(0xa0110009), SPH_C32(0x18ed1eef), + SPH_C32(0x3b8b60a0), SPH_C32(0x5e9153b5) }, + { SPH_C32(0xb70d0009), SPH_C32(0xaa832dab), SPH_C32(0xa5e1e3de), + SPH_C32(0x06691bea), SPH_C32(0x68e00009), SPH_C32(0x13c0f96d), + SPH_C32(0x507d2804), SPH_C32(0x0d0dee0a) }, + { SPH_C32(0x3791000a), SPH_C32(0xcdf0ad8a), SPH_C32(0xf9fc95d5), + SPH_C32(0x6d24979f), SPH_C32(0xf9020008), SPH_C32(0x059a3669), + SPH_C32(0x8791b94d), SPH_C32(0xaa319577) }, + { SPH_C32(0xf7df000b), SPH_C32(0xfe496d9a), SPH_C32(0x57f22ed0), + SPH_C32(0xd88051a4), SPH_C32(0x31f30008), SPH_C32(0x0eb7d1eb), + SPH_C32(0xec67f1e9), SPH_C32(0xf9ad28c8) }, + { SPH_C32(0xff60000a), SPH_C32(0xc6dd4a08), SPH_C32(0x920add71), + SPH_C32(0x3eb82a20), SPH_C32(0xf1bd0009), SPH_C32(0x3d0e11fb), + SPH_C32(0x42694aec), SPH_C32(0x4c09eef3) }, + { SPH_C32(0x3f2e000b), SPH_C32(0xf5648a18), SPH_C32(0x3c046674), + SPH_C32(0x8b1cec1b), SPH_C32(0x394c0009), SPH_C32(0x3623f679), + SPH_C32(0x299f0248), SPH_C32(0x1f95534c) }, + { SPH_C32(0xee1e0008), SPH_C32(0xb7f4052d), SPH_C32(0x19fb3a33), + SPH_C32(0xf2c9dd28), SPH_C32(0x7121000a), SPH_C32(0x5a7d91da), + SPH_C32(0x1e743ce7), SPH_C32(0x27446286) }, + { SPH_C32(0x2e500009), SPH_C32(0x844dc53d), SPH_C32(0xb7f58136), + SPH_C32(0x476d1b13), SPH_C32(0xb9d0000a), SPH_C32(0x51507658), + SPH_C32(0x75827443), SPH_C32(0x74d8df39) }, + { SPH_C32(0x26ef0008), SPH_C32(0xbcd9e2af), SPH_C32(0x720d7297), + SPH_C32(0xa1556097), SPH_C32(0x799e000b), SPH_C32(0x62e9b648), + SPH_C32(0xdb8ccf46), SPH_C32(0xc17c1902) }, + { SPH_C32(0xe6a10009), SPH_C32(0x8f6022bf), SPH_C32(0xdc03c992), + SPH_C32(0x14f1a6ac), SPH_C32(0xb16f000b), SPH_C32(0x69c451ca), + SPH_C32(0xb07a87e2), SPH_C32(0x92e0a4bd) }, + { SPH_C32(0x663d000a), SPH_C32(0xe813a29e), SPH_C32(0x801ebf99), + SPH_C32(0x7fbc2ad9), SPH_C32(0x208d000a), SPH_C32(0x7f9e9ece), + SPH_C32(0x679616ab), SPH_C32(0x35dcdfc0) }, + { SPH_C32(0xa673000b), SPH_C32(0xdbaa628e), SPH_C32(0x2e10049c), + SPH_C32(0xca18ece2), SPH_C32(0xe87c000a), SPH_C32(0x74b3794c), + SPH_C32(0x0c605e0f), SPH_C32(0x6640627f) }, + { SPH_C32(0xaecc000a), SPH_C32(0xe33e451c), SPH_C32(0xebe8f73d), + SPH_C32(0x2c209766), SPH_C32(0x2832000b), SPH_C32(0x470ab95c), + SPH_C32(0xa26ee50a), SPH_C32(0xd3e4a444) }, + { SPH_C32(0x6e82000b), SPH_C32(0xd087850c), SPH_C32(0x45e64c38), + SPH_C32(0x9984515d), SPH_C32(0xe0c3000b), SPH_C32(0x4c275ede), + SPH_C32(0xc998adae), SPH_C32(0x807819fb) }, + { SPH_C32(0x6fba000c), SPH_C32(0x1e61854e), SPH_C32(0xfddca02f), + SPH_C32(0x4f1b49b4), SPH_C32(0xc3070008), SPH_C32(0x6092c0d7), + SPH_C32(0x66418f3c), SPH_C32(0xce05ef02) }, + { SPH_C32(0xaff4000d), SPH_C32(0x2dd8455e), SPH_C32(0x53d21b2a), + SPH_C32(0xfabf8f8f), SPH_C32(0x0bf60008), SPH_C32(0x6bbf2755), + SPH_C32(0x0db7c798), SPH_C32(0x9d9952bd) }, + { SPH_C32(0xa74b000c), SPH_C32(0x154c62cc), SPH_C32(0x962ae88b), + SPH_C32(0x1c87f40b), SPH_C32(0xcbb80009), SPH_C32(0x5806e745), + SPH_C32(0xa3b97c9d), SPH_C32(0x283d9486) }, + { SPH_C32(0x6705000d), SPH_C32(0x26f5a2dc), SPH_C32(0x3824538e), + SPH_C32(0xa9233230), SPH_C32(0x03490009), SPH_C32(0x532b00c7), + SPH_C32(0xc84f3439), SPH_C32(0x7ba12939) }, + { SPH_C32(0xe799000e), SPH_C32(0x418622fd), SPH_C32(0x64392585), + SPH_C32(0xc26ebe45), SPH_C32(0x92ab0008), SPH_C32(0x4571cfc3), + SPH_C32(0x1fa3a570), SPH_C32(0xdc9d5244) }, + { SPH_C32(0x27d7000f), SPH_C32(0x723fe2ed), SPH_C32(0xca379e80), + SPH_C32(0x77ca787e), SPH_C32(0x5a5a0008), SPH_C32(0x4e5c2841), + SPH_C32(0x7455edd4), SPH_C32(0x8f01effb) }, + { SPH_C32(0x2f68000e), SPH_C32(0x4aabc57f), SPH_C32(0x0fcf6d21), + SPH_C32(0x91f203fa), SPH_C32(0x9a140009), SPH_C32(0x7de5e851), + SPH_C32(0xda5b56d1), SPH_C32(0x3aa529c0) }, + { SPH_C32(0xef26000f), SPH_C32(0x7912056f), SPH_C32(0xa1c1d624), + SPH_C32(0x2456c5c1), SPH_C32(0x52e50009), SPH_C32(0x76c80fd3), + SPH_C32(0xb1ad1e75), SPH_C32(0x6939947f) }, + { SPH_C32(0x3e16000c), SPH_C32(0x3b828a5a), SPH_C32(0x843e8a63), + SPH_C32(0x5d83f4f2), SPH_C32(0x1a88000a), SPH_C32(0x1a966870), + SPH_C32(0x864620da), SPH_C32(0x51e8a5b5) }, + { SPH_C32(0xfe58000d), SPH_C32(0x083b4a4a), SPH_C32(0x2a303166), + SPH_C32(0xe82732c9), SPH_C32(0xd279000a), SPH_C32(0x11bb8ff2), + SPH_C32(0xedb0687e), SPH_C32(0x0274180a) }, + { SPH_C32(0xf6e7000c), SPH_C32(0x30af6dd8), SPH_C32(0xefc8c2c7), + SPH_C32(0x0e1f494d), SPH_C32(0x1237000b), SPH_C32(0x22024fe2), + SPH_C32(0x43bed37b), SPH_C32(0xb7d0de31) }, + { SPH_C32(0x36a9000d), SPH_C32(0x0316adc8), SPH_C32(0x41c679c2), + SPH_C32(0xbbbb8f76), SPH_C32(0xdac6000b), SPH_C32(0x292fa860), + SPH_C32(0x28489bdf), SPH_C32(0xe44c638e) }, + { SPH_C32(0xb635000e), SPH_C32(0x64652de9), SPH_C32(0x1ddb0fc9), + SPH_C32(0xd0f60303), SPH_C32(0x4b24000a), SPH_C32(0x3f756764), + SPH_C32(0xffa40a96), SPH_C32(0x437018f3) }, + { SPH_C32(0x767b000f), SPH_C32(0x57dcedf9), SPH_C32(0xb3d5b4cc), + SPH_C32(0x6552c538), SPH_C32(0x83d5000a), SPH_C32(0x345880e6), + SPH_C32(0x94524232), SPH_C32(0x10eca54c) }, + { SPH_C32(0x7ec4000e), SPH_C32(0x6f48ca6b), SPH_C32(0x762d476d), + SPH_C32(0x836abebc), SPH_C32(0x439b000b), SPH_C32(0x07e140f6), + SPH_C32(0x3a5cf937), SPH_C32(0xa5486377) }, + { SPH_C32(0xbe8a000f), SPH_C32(0x5cf10a7b), SPH_C32(0xd823fc68), + SPH_C32(0x36ce7887), SPH_C32(0x8b6a000b), SPH_C32(0x0ccca774), + SPH_C32(0x51aab193), SPH_C32(0xf6d4dec8) }, + { SPH_C32(0xd41b0008), SPH_C32(0xd2fcf393), SPH_C32(0xf82b0c42), + SPH_C32(0x96fda75d), SPH_C32(0x130f000c), SPH_C32(0xece44fa0), + SPH_C32(0xfb843f6c), SPH_C32(0x614fc6d8) }, + { SPH_C32(0x14550009), SPH_C32(0xe1453383), SPH_C32(0x5625b747), + SPH_C32(0x23596166), SPH_C32(0xdbfe000c), SPH_C32(0xe7c9a822), + SPH_C32(0x907277c8), SPH_C32(0x32d37b67) }, + { SPH_C32(0x1cea0008), SPH_C32(0xd9d11411), SPH_C32(0x93dd44e6), + SPH_C32(0xc5611ae2), SPH_C32(0x1bb0000d), SPH_C32(0xd4706832), + SPH_C32(0x3e7ccccd), SPH_C32(0x8777bd5c) }, + { SPH_C32(0xdca40009), SPH_C32(0xea68d401), SPH_C32(0x3dd3ffe3), + SPH_C32(0x70c5dcd9), SPH_C32(0xd341000d), SPH_C32(0xdf5d8fb0), + SPH_C32(0x558a8469), SPH_C32(0xd4eb00e3) }, + { SPH_C32(0x5c38000a), SPH_C32(0x8d1b5420), SPH_C32(0x61ce89e8), + SPH_C32(0x1b8850ac), SPH_C32(0x42a3000c), SPH_C32(0xc90740b4), + SPH_C32(0x82661520), SPH_C32(0x73d77b9e) }, + { SPH_C32(0x9c76000b), SPH_C32(0xbea29430), SPH_C32(0xcfc032ed), + SPH_C32(0xae2c49697), SPH_C32(0x8a52000c), SPH_C32(0xc22aa736), + SPH_C32(0xe9905d84), SPH_C32(0x204bc621) }, + { SPH_C32(0x94c9000a), SPH_C32(0x8636b3a2), SPH_C32(0x0a38c14c), + SPH_C32(0x4814ed13), SPH_C32(0x4a1c000d), SPH_C32(0xf1936726), + SPH_C32(0x479ee681), SPH_C32(0x95ef001a) }, + { SPH_C32(0x5487000b), SPH_C32(0xb58f73b2), SPH_C32(0xa4367a49), + SPH_C32(0xfdb02b28), SPH_C32(0x82ed000d), SPH_C32(0xfabe80a4), + SPH_C32(0x2c68ae25), SPH_C32(0xc673bda5) }, + { SPH_C32(0x85b70008), SPH_C32(0xf71ffc87), SPH_C32(0x81c9260e), + SPH_C32(0x84651a1b), SPH_C32(0xca80000e), SPH_C32(0x96e0e707), + SPH_C32(0x1b83908a), SPH_C32(0xfea28c6f) }, + { SPH_C32(0x45f90009), SPH_C32(0xc4a63c97), SPH_C32(0x2fc79d0b), + SPH_C32(0x31c1dc20), SPH_C32(0x0271000e), SPH_C32(0x9dcd0085), + SPH_C32(0x7075d82e), SPH_C32(0xad3e31d0) }, + { SPH_C32(0x4d460008), SPH_C32(0xfc321b05), SPH_C32(0xea3f6eaa), + SPH_C32(0xd7f9a7a4), SPH_C32(0xc23f000f), SPH_C32(0xae74c095), + SPH_C32(0xde7b632b), SPH_C32(0x189af7eb) }, + { SPH_C32(0x8d080009), SPH_C32(0xcf8bdb15), SPH_C32(0x4431d5af), + SPH_C32(0x625d619f), SPH_C32(0x0ace000f), SPH_C32(0xa5592717), + SPH_C32(0xb58d2b8f), SPH_C32(0x4b064a54) }, + { SPH_C32(0x0d94000a), SPH_C32(0xa8f85b34), SPH_C32(0x182ca3a4), + SPH_C32(0x0910edea), SPH_C32(0x9b2c000e), SPH_C32(0xb303e813), + SPH_C32(0x6261bac6), SPH_C32(0xec3a3129) }, + { SPH_C32(0xcdda000b), SPH_C32(0x9b419b24), SPH_C32(0xb62218a1), + SPH_C32(0xbcb42bd1), SPH_C32(0x53dd000e), SPH_C32(0xb82e0f91), + SPH_C32(0x0997f262), SPH_C32(0xbfa68c96) }, + { SPH_C32(0xc565000a), SPH_C32(0xa3d5bcb6), SPH_C32(0x73daeb00), + SPH_C32(0x5a8c5055), SPH_C32(0x9393000f), SPH_C32(0x8b97cf81), + SPH_C32(0xa7994967), SPH_C32(0x0a024aad) }, + { SPH_C32(0x052b000b), SPH_C32(0x906c7ca6), SPH_C32(0xddd45005), + SPH_C32(0xef28966e), SPH_C32(0x5b62000f), SPH_C32(0x80ba2803), + SPH_C32(0xcc6f01c3), SPH_C32(0x599ef712) }, + { SPH_C32(0x0413000c), SPH_C32(0x5e8a7ce4), SPH_C32(0x65eebc12), + SPH_C32(0x39b78e87), SPH_C32(0x78a6000c), SPH_C32(0xac0fb60a), + SPH_C32(0x63b62351), SPH_C32(0x17e301eb) }, + { SPH_C32(0xc45d000d), SPH_C32(0x6d33bcf4), SPH_C32(0xcbe00717), + SPH_C32(0x8c1348bc), SPH_C32(0xb057000c), SPH_C32(0xa7225188), + SPH_C32(0x08406bf5), SPH_C32(0x447fbc54) }, + { SPH_C32(0xcce2000c), SPH_C32(0x55a79b66), SPH_C32(0x0e18f4b6), + SPH_C32(0x6a2b3338), SPH_C32(0x7019000d), SPH_C32(0x949b9198), + SPH_C32(0xa64ed0f0), SPH_C32(0xf1db7a6f) }, + { SPH_C32(0x0cac000d), SPH_C32(0x661e5b76), SPH_C32(0xa0164fb3), + SPH_C32(0xdf8ff503), SPH_C32(0xb8e8000d), SPH_C32(0x9fb6761a), + SPH_C32(0xcdb89854), SPH_C32(0xa247c7d0) }, + { SPH_C32(0x8c30000e), SPH_C32(0x016ddb57), SPH_C32(0xfc0b39b8), + SPH_C32(0xb4c27976), SPH_C32(0x290a000c), SPH_C32(0x89ecb91e), + SPH_C32(0x1a54091d), SPH_C32(0x057bbcad) }, + { SPH_C32(0x4c7e000f), SPH_C32(0x32d41b47), SPH_C32(0x520582bd), + SPH_C32(0x0166bf4d), SPH_C32(0xe1fb000c), SPH_C32(0x82c15e9c), + SPH_C32(0x71a241b9), SPH_C32(0x56e70112) }, + { SPH_C32(0x44c1000e), SPH_C32(0x0a403cd5), SPH_C32(0x97fd711c), + SPH_C32(0xe75ec4c9), SPH_C32(0x21b5000d), SPH_C32(0xb1789e8c), + SPH_C32(0xdfacfabc), SPH_C32(0xe343c729) }, + { SPH_C32(0x848f000f), SPH_C32(0x39f9fcc5), SPH_C32(0x39f3ca19), + SPH_C32(0x52fa02f2), SPH_C32(0xe944000d), SPH_C32(0xba55790e), + SPH_C32(0xb45ab218), SPH_C32(0xb0df7a96) }, + { SPH_C32(0x55bf000c), SPH_C32(0x7b6973f0), SPH_C32(0x1c0c965e), + SPH_C32(0x2b2f33c1), SPH_C32(0xa129000e), SPH_C32(0xd60b1ead), + SPH_C32(0x83b18cb7), SPH_C32(0x880e4b5c) }, + { SPH_C32(0x95f1000d), SPH_C32(0x48d0b3e0), SPH_C32(0xb2022d5b), + SPH_C32(0x9e8bf5fa), SPH_C32(0x69d8000e), SPH_C32(0xdd26f92f), + SPH_C32(0xe847c413), SPH_C32(0xdb92f6e3) }, + { SPH_C32(0x9d4e000c), SPH_C32(0x70449472), SPH_C32(0x77fadefa), + SPH_C32(0x78b38e7e), SPH_C32(0xa996000f), SPH_C32(0xee9f393f), + SPH_C32(0x46497f16), SPH_C32(0x6e3630d8) }, + { SPH_C32(0x5d00000d), SPH_C32(0x43fd5462), SPH_C32(0xd9f465ff), + SPH_C32(0xcd174845), SPH_C32(0x6167000f), SPH_C32(0xe5b2debd), + SPH_C32(0x2dbf37b2), SPH_C32(0x3daa8d67) }, + { SPH_C32(0xdd9c000e), SPH_C32(0x248ed443), SPH_C32(0x85e913f4), + SPH_C32(0xa65ac430), SPH_C32(0xf085000e), SPH_C32(0xf3e811b9), + SPH_C32(0xfa53a6fb), SPH_C32(0x9a96f61a) }, + { SPH_C32(0x1dd2000f), SPH_C32(0x17371453), SPH_C32(0x2be7a8f1), + SPH_C32(0x13fe020b), SPH_C32(0x3874000e), SPH_C32(0xf8c5f63b), + SPH_C32(0x91a5ee5f), SPH_C32(0xc90a4ba5) }, + { SPH_C32(0x156d000e), SPH_C32(0x2fa333c1), SPH_C32(0xee1f5b50), + SPH_C32(0xf5c6798f), SPH_C32(0xf83a000f), SPH_C32(0xcb7c362b), + SPH_C32(0x3fab555a), SPH_C32(0x7cae8d9e) }, + { SPH_C32(0xd523000f), SPH_C32(0x1c1af3d1), SPH_C32(0x4011e055), + SPH_C32(0x4062bfb4), SPH_C32(0x30cb000f), SPH_C32(0xc051d1a9), + SPH_C32(0x545d1dfe), SPH_C32(0x2f323021) } +}; + +#define INPUT_SMALL do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T256_0[acc][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + acc = buf[1]; \ + rp = &T256_8[acc][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = buf[2]; \ + rp = &T256_16[acc][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + acc = buf[3]; \ + rp = &T256_24[acc][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_BIG == 1 + +/* Note: this table lists bits within each byte from least + siginificant to most significant. */ +static const sph_u32 T512[64][16] = { + { SPH_C32(0xef0b0270), SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), + SPH_C32(0x69490000), SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), + SPH_C32(0x66140a51), SPH_C32(0x924f5d0a), SPH_C32(0xc96b0030), + SPH_C32(0xe7250000), SPH_C32(0x2f840000), SPH_C32(0x264f0000), + SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), SPH_C32(0x509f6984), + SPH_C32(0x9e69af68) }, + { SPH_C32(0xc96b0030), SPH_C32(0xe7250000), SPH_C32(0x2f840000), + SPH_C32(0x264f0000), SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), + SPH_C32(0x509f6984), SPH_C32(0x9e69af68), SPH_C32(0x26600240), + SPH_C32(0xddd80000), SPH_C32(0x722a0000), SPH_C32(0x4f060000), + SPH_C32(0x936667ff), SPH_C32(0x29f944ce), SPH_C32(0x368b63d5), + SPH_C32(0x0c26f262) }, + { SPH_C32(0x145a3c00), SPH_C32(0xb9e90000), SPH_C32(0x61270000), + SPH_C32(0xf1610000), SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), + SPH_C32(0x47a96720), SPH_C32(0xe18e24c5), SPH_C32(0x23671400), + SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), SPH_C32(0xfb750000), + SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), SPH_C32(0x02c40a3f), + SPH_C32(0xdc24e61f) }, + { SPH_C32(0x23671400), SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), + SPH_C32(0xfb750000), SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), + SPH_C32(0x02c40a3f), SPH_C32(0xdc24e61f), SPH_C32(0x373d2800), + SPH_C32(0x71500000), SPH_C32(0x95e00000), SPH_C32(0x0a140000), + SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), SPH_C32(0x456d6d1f), + SPH_C32(0x3daac2da) }, + { SPH_C32(0x54285c00), SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), + SPH_C32(0xa1c50000), SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), + SPH_C32(0x6bb0419d), SPH_C32(0x551b3782), SPH_C32(0x9cbb1800), + SPH_C32(0xb0d30000), SPH_C32(0x92510000), SPH_C32(0xed930000), + SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), SPH_C32(0x430633da), + SPH_C32(0x78cace29) }, + { SPH_C32(0x9cbb1800), SPH_C32(0xb0d30000), SPH_C32(0x92510000), + SPH_C32(0xed930000), SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), + SPH_C32(0x430633da), SPH_C32(0x78cace29), SPH_C32(0xc8934400), + SPH_C32(0x5a3e0000), SPH_C32(0x57870000), SPH_C32(0x4c560000), + SPH_C32(0xea982435), SPH_C32(0x75b11115), SPH_C32(0x28b67247), + SPH_C32(0x2dd1f9ab) }, + { SPH_C32(0x29449c00), SPH_C32(0x64e70000), SPH_C32(0xf24b0000), + SPH_C32(0xc2f30000), SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), + SPH_C32(0xf3e04259), SPH_C32(0x8d0d9ec4), SPH_C32(0x466d0c00), + SPH_C32(0x08620000), SPH_C32(0xdd5d0000), SPH_C32(0xbadd0000), + SPH_C32(0x6a927942), SPH_C32(0x441f2b93), SPH_C32(0x218ace6f), + SPH_C32(0xbf2c0be2) }, + { SPH_C32(0x466d0c00), SPH_C32(0x08620000), SPH_C32(0xdd5d0000), + SPH_C32(0xbadd0000), SPH_C32(0x6a927942), SPH_C32(0x441f2b93), + SPH_C32(0x218ace6f), SPH_C32(0xbf2c0be2), SPH_C32(0x6f299000), + SPH_C32(0x6c850000), SPH_C32(0x2f160000), SPH_C32(0x782e0000), + SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), SPH_C32(0xd26a8c36), + SPH_C32(0x32219526) }, + { SPH_C32(0xf6800005), SPH_C32(0x3443c000), SPH_C32(0x24070000), + SPH_C32(0x8f3d0000), SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), + SPH_C32(0xcdc58b19), SPH_C32(0xd795ba31), SPH_C32(0xa67f0001), + SPH_C32(0x71378000), SPH_C32(0x19fc0000), SPH_C32(0x96db0000), + SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), SPH_C32(0x2c6d478f), + SPH_C32(0xac8e6c88) }, + { SPH_C32(0xa67f0001), SPH_C32(0x71378000), SPH_C32(0x19fc0000), + SPH_C32(0x96db0000), SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), + SPH_C32(0x2c6d478f), SPH_C32(0xac8e6c88), SPH_C32(0x50ff0004), + SPH_C32(0x45744000), SPH_C32(0x3dfb0000), SPH_C32(0x19e60000), + SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), SPH_C32(0xe1a8cc96), + SPH_C32(0x7b1bd6b9) }, + { SPH_C32(0xf7750009), SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), + SPH_C32(0x04920000), SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), + SPH_C32(0x7a87f14e), SPH_C32(0x9e16981a), SPH_C32(0xd46a0000), + SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), SPH_C32(0x4a290000), + SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), SPH_C32(0x98369604), + SPH_C32(0xf746c320) }, + { SPH_C32(0xd46a0000), SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), + SPH_C32(0x4a290000), SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), + SPH_C32(0x98369604), SPH_C32(0xf746c320), SPH_C32(0x231f0009), + SPH_C32(0x42f40000), SPH_C32(0x66790000), SPH_C32(0x4ebb0000), + SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), SPH_C32(0xe2b1674a), + SPH_C32(0x69505b3a) }, + { SPH_C32(0x774400f0), SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), + SPH_C32(0x34140000), SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), + SPH_C32(0x0bc3cd1e), SPH_C32(0xcf3775cb), SPH_C32(0xf46c0050), + SPH_C32(0x96180000), SPH_C32(0x14a50000), SPH_C32(0x031f0000), + SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), SPH_C32(0x9ca470d2), + SPH_C32(0x8a341574) }, + { SPH_C32(0xf46c0050), SPH_C32(0x96180000), SPH_C32(0x14a50000), + SPH_C32(0x031f0000), SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), + SPH_C32(0x9ca470d2), SPH_C32(0x8a341574), SPH_C32(0x832800a0), + SPH_C32(0x67420000), SPH_C32(0xe1170000), SPH_C32(0x370b0000), + SPH_C32(0xcba30034), SPH_C32(0x3c34923c), SPH_C32(0x9767bdcc), + SPH_C32(0x450360bf) }, + { SPH_C32(0xe8870170), SPH_C32(0x9d720000), SPH_C32(0x12db0000), + SPH_C32(0xd4220000), SPH_C32(0xf2886b27), SPH_C32(0xa921e543), + SPH_C32(0x4ef8b518), SPH_C32(0x618813b1), SPH_C32(0xb4370060), + SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), SPH_C32(0x5cae0000), + SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), SPH_C32(0x1b365f3d), + SPH_C32(0xf3d45758) }, + { SPH_C32(0xb4370060), SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), + SPH_C32(0x5cae0000), SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), + SPH_C32(0x1b365f3d), SPH_C32(0xf3d45758), SPH_C32(0x5cb00110), + SPH_C32(0x913e0000), SPH_C32(0x44190000), SPH_C32(0x888c0000), + SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), SPH_C32(0x55ceea25), + SPH_C32(0x925c44e9) }, + { SPH_C32(0x0c720000), SPH_C32(0x49e50f00), SPH_C32(0x42790000), + SPH_C32(0x5cea0000), SPH_C32(0x33aa301a), SPH_C32(0x15822514), + SPH_C32(0x95a34b7b), SPH_C32(0xb44b0090), SPH_C32(0xfe220000), + SPH_C32(0xa7580500), SPH_C32(0x25d10000), SPH_C32(0xf7600000), + SPH_C32(0x893178da), SPH_C32(0x1fd4f860), SPH_C32(0x4ed0a315), + SPH_C32(0xa123ff9f) }, + { SPH_C32(0xfe220000), SPH_C32(0xa7580500), SPH_C32(0x25d10000), + SPH_C32(0xf7600000), SPH_C32(0x893178da), SPH_C32(0x1fd4f860), + SPH_C32(0x4ed0a315), SPH_C32(0xa123ff9f), SPH_C32(0xf2500000), + SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), SPH_C32(0xab8a0000), + SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), SPH_C32(0xdb73e86e), + SPH_C32(0x1568ff0f) }, + { SPH_C32(0x45180000), SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), + SPH_C32(0x3b480000), SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), + SPH_C32(0x16bca6b0), SPH_C32(0xdf33f4df), SPH_C32(0xb83d0000), + SPH_C32(0x16710600), SPH_C32(0x379a0000), SPH_C32(0xf5b10000), + SPH_C32(0x228161ac), SPH_C32(0xae48f145), SPH_C32(0x66241616), + SPH_C32(0xc5c1eb3e) }, + { SPH_C32(0xb83d0000), SPH_C32(0x16710600), SPH_C32(0x379a0000), + SPH_C32(0xf5b10000), SPH_C32(0x228161ac), SPH_C32(0xae48f145), + SPH_C32(0x66241616), SPH_C32(0xc5c1eb3e), SPH_C32(0xfd250000), + SPH_C32(0xb3c41100), SPH_C32(0xcef00000), SPH_C32(0xcef90000), + SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), SPH_C32(0x7098b0a6), + SPH_C32(0x1af21fe1) }, + { SPH_C32(0x75a40000), SPH_C32(0xc28b2700), SPH_C32(0x94a40000), + SPH_C32(0x90f50000), SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), + SPH_C32(0x1767c483), SPH_C32(0xaedf667e), SPH_C32(0xd1660000), + SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), SPH_C32(0xf6940000), + SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), SPH_C32(0xb4431b17), + SPH_C32(0x857f3c2b) }, + { SPH_C32(0xd1660000), SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), + SPH_C32(0xf6940000), SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), + SPH_C32(0xb4431b17), SPH_C32(0x857f3c2b), SPH_C32(0xa4c20000), + SPH_C32(0xd9372400), SPH_C32(0x0a480000), SPH_C32(0x66610000), + SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), SPH_C32(0xa324df94), + SPH_C32(0x2ba05a55) }, + { SPH_C32(0x75c90003), SPH_C32(0x0e10c000), SPH_C32(0xd1200000), + SPH_C32(0xbaea0000), SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), + SPH_C32(0xbb28761d), SPH_C32(0x00b72e2b), SPH_C32(0xeecf0001), + SPH_C32(0x6f564000), SPH_C32(0xf33e0000), SPH_C32(0xa79e0000), + SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), SPH_C32(0x4a3b40ba), + SPH_C32(0xfeabf254) }, + { SPH_C32(0xeecf0001), SPH_C32(0x6f564000), SPH_C32(0xf33e0000), + SPH_C32(0xa79e0000), SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), + SPH_C32(0x4a3b40ba), SPH_C32(0xfeabf254), SPH_C32(0x9b060002), + SPH_C32(0x61468000), SPH_C32(0x221e0000), SPH_C32(0x1d740000), + SPH_C32(0x36715d27), SPH_C32(0x30495c92), SPH_C32(0xf11336a7), + SPH_C32(0xfe1cdc7f) }, + { SPH_C32(0x86790000), SPH_C32(0x3f390002), SPH_C32(0xe19ae000), + SPH_C32(0x98560000), SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), + SPH_C32(0xd3dd4944), SPH_C32(0x161ddab9), SPH_C32(0x30b70000), + SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), SPH_C32(0x42c40000), + SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), SPH_C32(0x21afa1ea), + SPH_C32(0xb0a51834) }, + { SPH_C32(0x30b70000), SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), + SPH_C32(0x42c40000), SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), + SPH_C32(0x21afa1ea), SPH_C32(0xb0a51834), SPH_C32(0xb6ce0000), + SPH_C32(0xdae90002), SPH_C32(0x156e8000), SPH_C32(0xda920000), + SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), SPH_C32(0xf272e8ae), + SPH_C32(0xa6b8c28d) }, + { SPH_C32(0x14190000), SPH_C32(0x23ca003c), SPH_C32(0x50df0000), + SPH_C32(0x44b60000), SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), + SPH_C32(0x61e610b0), SPH_C32(0xdbcadb80), SPH_C32(0xe3430000), + SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), SPH_C32(0xaa4e0000), + SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), SPH_C32(0x123db156), + SPH_C32(0x3a4e99d7) }, + { SPH_C32(0xe3430000), SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), + SPH_C32(0xaa4e0000), SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), + SPH_C32(0x123db156), SPH_C32(0x3a4e99d7), SPH_C32(0xf75a0000), + SPH_C32(0x19840028), SPH_C32(0xa2190000), SPH_C32(0xeef80000), + SPH_C32(0xc0722516), SPH_C32(0x19981260), SPH_C32(0x73dba1e6), + SPH_C32(0xe1844257) }, + { SPH_C32(0x54500000), SPH_C32(0x0671005c), SPH_C32(0x25ae0000), + SPH_C32(0x6a1e0000), SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), + SPH_C32(0xbfba18c3), SPH_C32(0x7e715d17), SPH_C32(0xbc8d0000), + SPH_C32(0xfc3b0018), SPH_C32(0x19830000), SPH_C32(0xd10b0000), + SPH_C32(0xae1878c4), SPH_C32(0x42a69856), SPH_C32(0x0012da37), + SPH_C32(0x2c3b504e) }, + { SPH_C32(0xbc8d0000), SPH_C32(0xfc3b0018), SPH_C32(0x19830000), + SPH_C32(0xd10b0000), SPH_C32(0xae1878c4), SPH_C32(0x42a69856), + SPH_C32(0x0012da37), SPH_C32(0x2c3b504e), SPH_C32(0xe8dd0000), + SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), SPH_C32(0xbb150000), + SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), SPH_C32(0xbfa8c2f4), + SPH_C32(0x524a0d59) }, + { SPH_C32(0x69510000), SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), + SPH_C32(0xac2f0000), SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), + SPH_C32(0x87ec287c), SPH_C32(0xbce1a3ce), SPH_C32(0xc6730000), + SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), SPH_C32(0x218d0000), + SPH_C32(0x23111587), SPH_C32(0x7913512f), SPH_C32(0x1d28ac88), + SPH_C32(0x378dd173) }, + { SPH_C32(0xc6730000), SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), + SPH_C32(0x218d0000), SPH_C32(0x23111587), SPH_C32(0x7913512f), + SPH_C32(0x1d28ac88), SPH_C32(0x378dd173), SPH_C32(0xaf220000), + SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), SPH_C32(0x8da20000), + SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), SPH_C32(0x9ac484f4), + SPH_C32(0x8b6c72bd) }, + { SPH_C32(0xcc140000), SPH_C32(0xa5630000), SPH_C32(0x5ab90780), + SPH_C32(0x3b500000), SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), + SPH_C32(0x694348c1), SPH_C32(0xca5a87fe), SPH_C32(0x819e0000), + SPH_C32(0xec570000), SPH_C32(0x66320280), SPH_C32(0x95f30000), + SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), SPH_C32(0xe65aa22d), + SPH_C32(0x8e67b7fa) }, + { SPH_C32(0x819e0000), SPH_C32(0xec570000), SPH_C32(0x66320280), + SPH_C32(0x95f30000), SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), + SPH_C32(0xe65aa22d), SPH_C32(0x8e67b7fa), SPH_C32(0x4d8a0000), + SPH_C32(0x49340000), SPH_C32(0x3c8b0500), SPH_C32(0xaea30000), + SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), SPH_C32(0x8f19eaec), + SPH_C32(0x443d3004) }, + { SPH_C32(0x78230000), SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), + SPH_C32(0x90a50000), SPH_C32(0x713e2879), SPH_C32(0x7ee98924), + SPH_C32(0xf08ca062), SPH_C32(0x636f8bab), SPH_C32(0x02af0000), + SPH_C32(0xb7280000), SPH_C32(0xba1c0300), SPH_C32(0x56980000), + SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), SPH_C32(0xa95c149a), + SPH_C32(0xf4f6ea7b) }, + { SPH_C32(0x02af0000), SPH_C32(0xb7280000), SPH_C32(0xba1c0300), + SPH_C32(0x56980000), SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), + SPH_C32(0xa95c149a), SPH_C32(0xf4f6ea7b), SPH_C32(0x7a8c0000), + SPH_C32(0xa5d40000), SPH_C32(0x13260880), SPH_C32(0xc63d0000), + SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), SPH_C32(0x59d0b4f8), + SPH_C32(0x979961d0) }, + { SPH_C32(0xac480000), SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), + SPH_C32(0x03430000), SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), + SPH_C32(0xfe72c7fe), SPH_C32(0x91e478f6), SPH_C32(0x1e4e0000), + SPH_C32(0xdecf0000), SPH_C32(0x6df80180), SPH_C32(0x77240000), + SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), SPH_C32(0xcda31812), + SPH_C32(0x98aa496e) }, + { SPH_C32(0x1e4e0000), SPH_C32(0xdecf0000), SPH_C32(0x6df80180), + SPH_C32(0x77240000), SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), + SPH_C32(0xcda31812), SPH_C32(0x98aa496e), SPH_C32(0xb2060000), + SPH_C32(0xc5690000), SPH_C32(0x28031200), SPH_C32(0x74670000), + SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), SPH_C32(0x33d1dfec), + SPH_C32(0x094e3198) }, + { SPH_C32(0xaec30000), SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), + SPH_C32(0x2c150000), SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), + SPH_C32(0xab92f78f), SPH_C32(0xa312567b), SPH_C32(0xdb250000), + SPH_C32(0x09290000), SPH_C32(0x49aac000), SPH_C32(0x81e10000), + SPH_C32(0xcafe6b59), SPH_C32(0x42793431), SPH_C32(0x43566b76), + SPH_C32(0xe86cba2e) }, + { SPH_C32(0xdb250000), SPH_C32(0x09290000), SPH_C32(0x49aac000), + SPH_C32(0x81e10000), SPH_C32(0xcafe6b59), SPH_C32(0x42793431), + SPH_C32(0x43566b76), SPH_C32(0xe86cba2e), SPH_C32(0x75e60000), + SPH_C32(0x95660001), SPH_C32(0x307b2000), SPH_C32(0xadf40000), + SPH_C32(0x8f321eea), SPH_C32(0x24298307), SPH_C32(0xe8c49cf9), + SPH_C32(0x4b7eec55) }, + { SPH_C32(0x58430000), SPH_C32(0x807e0000), SPH_C32(0x78330001), + SPH_C32(0xc66b3800), SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), + SPH_C32(0xac73fe6f), SPH_C32(0x3a4479b1), SPH_C32(0x1d5a0000), + SPH_C32(0x2b720000), SPH_C32(0x488d0000), SPH_C32(0xaf611800), + SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), SPH_C32(0x81a20429), + SPH_C32(0x1e7536a6) }, + { SPH_C32(0x1d5a0000), SPH_C32(0x2b720000), SPH_C32(0x488d0000), + SPH_C32(0xaf611800), SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), + SPH_C32(0x81a20429), SPH_C32(0x1e7536a6), SPH_C32(0x45190000), + SPH_C32(0xab0c0000), SPH_C32(0x30be0001), SPH_C32(0x690a2000), + SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), SPH_C32(0x2dd1fa46), + SPH_C32(0x24314f17) }, + { SPH_C32(0xa53b0000), SPH_C32(0x14260000), SPH_C32(0x4e30001e), + SPH_C32(0x7cae0000), SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), + SPH_C32(0xf73168d8), SPH_C32(0x0b1b4946), SPH_C32(0x07ed0000), + SPH_C32(0xb2500000), SPH_C32(0x8774000a), SPH_C32(0x970d0000), + SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), SPH_C32(0xf4786222), + SPH_C32(0x9075b1ce) }, + { SPH_C32(0x07ed0000), SPH_C32(0xb2500000), SPH_C32(0x8774000a), + SPH_C32(0x970d0000), SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), + SPH_C32(0xf4786222), SPH_C32(0x9075b1ce), SPH_C32(0xa2d60000), + SPH_C32(0xa6760000), SPH_C32(0xc9440014), SPH_C32(0xeba30000), + SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), SPH_C32(0x03490afa), + SPH_C32(0x9b6ef888) }, + { SPH_C32(0x88980000), SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), + SPH_C32(0xfb4e0000), SPH_C32(0xf158079a), SPH_C32(0x61ae9167), + SPH_C32(0xa895706c), SPH_C32(0xe6107494), SPH_C32(0x0bc20000), + SPH_C32(0xdb630000), SPH_C32(0x7e88000c), SPH_C32(0x15860000), + SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), SPH_C32(0xf460449e), + SPH_C32(0xd8b61463) }, + { SPH_C32(0x0bc20000), SPH_C32(0xdb630000), SPH_C32(0x7e88000c), + SPH_C32(0x15860000), SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), + SPH_C32(0xf460449e), SPH_C32(0xd8b61463), SPH_C32(0x835a0000), + SPH_C32(0xc4f70000), SPH_C32(0x01470022), SPH_C32(0xeec80000), + SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), SPH_C32(0x5cf534f2), + SPH_C32(0x3ea660f7) }, + { SPH_C32(0x52500000), SPH_C32(0x29540000), SPH_C32(0x6a61004e), + SPH_C32(0xf0ff0000), SPH_C32(0x9a317eec), SPH_C32(0x452341ce), + SPH_C32(0xcf568fe5), SPH_C32(0x5303130f), SPH_C32(0x538d0000), + SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), SPH_C32(0x56ff0000), + SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), SPH_C32(0xa9444018), + SPH_C32(0x7f975691) }, + { SPH_C32(0x538d0000), SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), + SPH_C32(0x56ff0000), SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), + SPH_C32(0xa9444018), SPH_C32(0x7f975691), SPH_C32(0x01dd0000), + SPH_C32(0x80a80000), SPH_C32(0xf4960048), SPH_C32(0xa6000000), + SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), SPH_C32(0x6612cffd), + SPH_C32(0x2c94459e) }, + { SPH_C32(0xe6280000), SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), + SPH_C32(0xd3d002e0), SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), + SPH_C32(0x289506b4), SPH_C32(0xd75a4897), SPH_C32(0xf0c50000), + SPH_C32(0x59230000), SPH_C32(0x45820000), SPH_C32(0xe18d00c0), + SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), SPH_C32(0xcbe0fe1c), + SPH_C32(0x56a7b19f) }, + { SPH_C32(0xf0c50000), SPH_C32(0x59230000), SPH_C32(0x45820000), + SPH_C32(0xe18d00c0), SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), + SPH_C32(0xcbe0fe1c), SPH_C32(0x56a7b19f), SPH_C32(0x16ed0000), + SPH_C32(0x15680000), SPH_C32(0xedd70000), SPH_C32(0x325d0220), + SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), SPH_C32(0xe375f8a8), + SPH_C32(0x81fdf908) }, + { SPH_C32(0xb4310000), SPH_C32(0x77330000), SPH_C32(0xb15d0000), + SPH_C32(0x7fd004e0), SPH_C32(0x78a26138), SPH_C32(0xd116c35d), + SPH_C32(0xd256d489), SPH_C32(0x4e6f74de), SPH_C32(0xe3060000), + SPH_C32(0xbdc10000), SPH_C32(0x87130000), SPH_C32(0xbff20060), + SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), SPH_C32(0x73c5ab06), + SPH_C32(0x5bd61539) }, + { SPH_C32(0xe3060000), SPH_C32(0xbdc10000), SPH_C32(0x87130000), + SPH_C32(0xbff20060), SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), + SPH_C32(0x73c5ab06), SPH_C32(0x5bd61539), SPH_C32(0x57370000), + SPH_C32(0xcaf20000), SPH_C32(0x364e0000), SPH_C32(0xc0220480), + SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), SPH_C32(0xa1937f8f), + SPH_C32(0x15b961e7) }, + { SPH_C32(0x02f20000), SPH_C32(0xa2810000), SPH_C32(0x873f0000), + SPH_C32(0xe36c7800), SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), + SPH_C32(0xc4c23237), SPH_C32(0x7f32259e), SPH_C32(0xbadd0000), + SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), SPH_C32(0xf7282800), + SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), SPH_C32(0xea5a8d14), + SPH_C32(0x2a2c18f0) }, + { SPH_C32(0xbadd0000), SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), + SPH_C32(0xf7282800), SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), + SPH_C32(0xea5a8d14), SPH_C32(0x2a2c18f0), SPH_C32(0xb82f0000), + SPH_C32(0xb12c0000), SPH_C32(0x30d80000), SPH_C32(0x14445000), + SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), SPH_C32(0x2e98bf23), + SPH_C32(0x551e3d6e) }, + { SPH_C32(0x1e6c0000), SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), + SPH_C32(0xbcb6b800), SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), + SPH_C32(0x6a0c1bc8), SPH_C32(0xb99dc2eb), SPH_C32(0x92560000), + SPH_C32(0x1eda0000), SPH_C32(0xea510000), SPH_C32(0xe8b13000), + SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), SPH_C32(0xb15c2254), + SPH_C32(0x33c5244f) }, + { SPH_C32(0x92560000), SPH_C32(0x1eda0000), SPH_C32(0xea510000), + SPH_C32(0xe8b13000), SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), + SPH_C32(0xb15c2254), SPH_C32(0x33c5244f), SPH_C32(0x8c3a0000), + SPH_C32(0xda980000), SPH_C32(0x607f0000), SPH_C32(0x54078800), + SPH_C32(0x85714513), SPH_C32(0x6006b243), SPH_C32(0xdb50399c), + SPH_C32(0x8a58e6a4) }, + { SPH_C32(0x033d0000), SPH_C32(0x08b30000), SPH_C32(0xf33a0000), + SPH_C32(0x3ac20007), SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), + SPH_C32(0x0ea5cfe3), SPH_C32(0xe6da7ffe), SPH_C32(0xa8da0000), + SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), SPH_C32(0x07da0002), + SPH_C32(0x7d669583), SPH_C32(0x1f98708a), SPH_C32(0xbb668808), + SPH_C32(0xda878000) }, + { SPH_C32(0xa8da0000), SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), + SPH_C32(0x07da0002), SPH_C32(0x7d669583), SPH_C32(0x1f98708a), + SPH_C32(0xbb668808), SPH_C32(0xda878000), SPH_C32(0xabe70000), + SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), SPH_C32(0x3d180005), + SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), SPH_C32(0xb5c347eb), + SPH_C32(0x3c5dfffe) }, + { SPH_C32(0x01930000), SPH_C32(0xe7820000), SPH_C32(0xedfb0000), + SPH_C32(0xcf0c000b), SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), + SPH_C32(0x063661e1), SPH_C32(0x536f9e7b), SPH_C32(0x92280000), + SPH_C32(0xdc850000), SPH_C32(0x57fa0000), SPH_C32(0x56dc0003), + SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), SPH_C32(0x90cef752), + SPH_C32(0x7b1675d7) }, + { SPH_C32(0x92280000), SPH_C32(0xdc850000), SPH_C32(0x57fa0000), + SPH_C32(0x56dc0003), SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), + SPH_C32(0x90cef752), SPH_C32(0x7b1675d7), SPH_C32(0x93bb0000), + SPH_C32(0x3b070000), SPH_C32(0xba010000), SPH_C32(0x99d00008), + SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), SPH_C32(0x96f896b3), + SPH_C32(0x2879ebac) }, + { SPH_C32(0x5fa80000), SPH_C32(0x56030000), SPH_C32(0x43ae0000), + SPH_C32(0x64f30013), SPH_C32(0x257e86bf), SPH_C32(0x1311944e), + SPH_C32(0x541e95bf), SPH_C32(0x8ea4db69), SPH_C32(0x00440000), + SPH_C32(0x7f480000), SPH_C32(0xda7c0000), SPH_C32(0x2a230001), + SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), SPH_C32(0x030a9e60), + SPH_C32(0xbe0a679e) }, + { SPH_C32(0x00440000), SPH_C32(0x7f480000), SPH_C32(0xda7c0000), + SPH_C32(0x2a230001), SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), + SPH_C32(0x030a9e60), SPH_C32(0xbe0a679e), SPH_C32(0x5fec0000), + SPH_C32(0x294b0000), SPH_C32(0x99d20000), SPH_C32(0x4ed00012), + SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), SPH_C32(0x57140bdf), + SPH_C32(0x30aebcf7) }, + { SPH_C32(0xee930000), SPH_C32(0xd6070000), SPH_C32(0x92c10000), + SPH_C32(0x2b9801e0), SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), + SPH_C32(0x45312374), SPH_C32(0x201f6a64), SPH_C32(0x7b280000), + SPH_C32(0x57420000), SPH_C32(0xa9e50000), SPH_C32(0x634300a0), + SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), SPH_C32(0x27f83b03), + SPH_C32(0xc7ff60f0) }, + { SPH_C32(0x7b280000), SPH_C32(0x57420000), SPH_C32(0xa9e50000), + SPH_C32(0x634300a0), SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), + SPH_C32(0x27f83b03), SPH_C32(0xc7ff60f0), SPH_C32(0x95bb0000), + SPH_C32(0x81450000), SPH_C32(0x3b240000), SPH_C32(0x48db0140), + SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), SPH_C32(0x62c91877), + SPH_C32(0xe7e00a94) } +}; + +#define INPUT_BIG do { \ + const sph_u32 *tp = &T512[0][0]; \ + unsigned u, v; \ + m0 = 0; \ + m1 = 0; \ + m2 = 0; \ + m3 = 0; \ + m4 = 0; \ + m5 = 0; \ + m6 = 0; \ + m7 = 0; \ + m8 = 0; \ + m9 = 0; \ + mA = 0; \ + mB = 0; \ + mC = 0; \ + mD = 0; \ + mE = 0; \ + mF = 0; \ + for (u = 0; u < 8; u ++) { \ + unsigned db = buf[u]; \ + for (v = 0; v < 8; v ++, db >>= 1) { \ + sph_u32 dm = SPH_T32(-(sph_u32)(db & 1)); \ + m0 ^= dm & *tp ++; \ + m1 ^= dm & *tp ++; \ + m2 ^= dm & *tp ++; \ + m3 ^= dm & *tp ++; \ + m4 ^= dm & *tp ++; \ + m5 ^= dm & *tp ++; \ + m6 ^= dm & *tp ++; \ + m7 ^= dm & *tp ++; \ + m8 ^= dm & *tp ++; \ + m9 ^= dm & *tp ++; \ + mA ^= dm & *tp ++; \ + mB ^= dm & *tp ++; \ + mC ^= dm & *tp ++; \ + mD ^= dm & *tp ++; \ + mE ^= dm & *tp ++; \ + mF ^= dm & *tp ++; \ + } \ + } \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_BIG == 2 + +static const sph_u32 T512_0[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x29449c00), SPH_C32(0x64e70000), SPH_C32(0xf24b0000), + SPH_C32(0xc2f30000), SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), + SPH_C32(0xf3e04259), SPH_C32(0x8d0d9ec4), SPH_C32(0x466d0c00), + SPH_C32(0x08620000), SPH_C32(0xdd5d0000), SPH_C32(0xbadd0000), + SPH_C32(0x6a927942), SPH_C32(0x441f2b93), SPH_C32(0x218ace6f), + SPH_C32(0xbf2c0be2) }, + { SPH_C32(0x466d0c00), SPH_C32(0x08620000), SPH_C32(0xdd5d0000), + SPH_C32(0xbadd0000), SPH_C32(0x6a927942), SPH_C32(0x441f2b93), + SPH_C32(0x218ace6f), SPH_C32(0xbf2c0be2), SPH_C32(0x6f299000), + SPH_C32(0x6c850000), SPH_C32(0x2f160000), SPH_C32(0x782e0000), + SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), SPH_C32(0xd26a8c36), + SPH_C32(0x32219526) }, + { SPH_C32(0x6f299000), SPH_C32(0x6c850000), SPH_C32(0x2f160000), + SPH_C32(0x782e0000), SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), + SPH_C32(0xd26a8c36), SPH_C32(0x32219526), SPH_C32(0x29449c00), + SPH_C32(0x64e70000), SPH_C32(0xf24b0000), SPH_C32(0xc2f30000), + SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), SPH_C32(0xf3e04259), + SPH_C32(0x8d0d9ec4) } +}; + +static const sph_u32 T512_2[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x54285c00), SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), + SPH_C32(0xa1c50000), SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), + SPH_C32(0x6bb0419d), SPH_C32(0x551b3782), SPH_C32(0x9cbb1800), + SPH_C32(0xb0d30000), SPH_C32(0x92510000), SPH_C32(0xed930000), + SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), SPH_C32(0x430633da), + SPH_C32(0x78cace29) }, + { SPH_C32(0x9cbb1800), SPH_C32(0xb0d30000), SPH_C32(0x92510000), + SPH_C32(0xed930000), SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), + SPH_C32(0x430633da), SPH_C32(0x78cace29), SPH_C32(0xc8934400), + SPH_C32(0x5a3e0000), SPH_C32(0x57870000), SPH_C32(0x4c560000), + SPH_C32(0xea982435), SPH_C32(0x75b11115), SPH_C32(0x28b67247), + SPH_C32(0x2dd1f9ab) }, + { SPH_C32(0xc8934400), SPH_C32(0x5a3e0000), SPH_C32(0x57870000), + SPH_C32(0x4c560000), SPH_C32(0xea982435), SPH_C32(0x75b11115), + SPH_C32(0x28b67247), SPH_C32(0x2dd1f9ab), SPH_C32(0x54285c00), + SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), SPH_C32(0xa1c50000), + SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), SPH_C32(0x6bb0419d), + SPH_C32(0x551b3782) } +}; + +static const sph_u32 T512_4[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x145a3c00), SPH_C32(0xb9e90000), SPH_C32(0x61270000), + SPH_C32(0xf1610000), SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), + SPH_C32(0x47a96720), SPH_C32(0xe18e24c5), SPH_C32(0x23671400), + SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), SPH_C32(0xfb750000), + SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), SPH_C32(0x02c40a3f), + SPH_C32(0xdc24e61f) }, + { SPH_C32(0x23671400), SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), + SPH_C32(0xfb750000), SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), + SPH_C32(0x02c40a3f), SPH_C32(0xdc24e61f), SPH_C32(0x373d2800), + SPH_C32(0x71500000), SPH_C32(0x95e00000), SPH_C32(0x0a140000), + SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), SPH_C32(0x456d6d1f), + SPH_C32(0x3daac2da) }, + { SPH_C32(0x373d2800), SPH_C32(0x71500000), SPH_C32(0x95e00000), + SPH_C32(0x0a140000), SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), + SPH_C32(0x456d6d1f), SPH_C32(0x3daac2da), SPH_C32(0x145a3c00), + SPH_C32(0xb9e90000), SPH_C32(0x61270000), SPH_C32(0xf1610000), + SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), SPH_C32(0x47a96720), + SPH_C32(0xe18e24c5) } +}; + +static const sph_u32 T512_6[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xef0b0270), SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), + SPH_C32(0x69490000), SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), + SPH_C32(0x66140a51), SPH_C32(0x924f5d0a), SPH_C32(0xc96b0030), + SPH_C32(0xe7250000), SPH_C32(0x2f840000), SPH_C32(0x264f0000), + SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), SPH_C32(0x509f6984), + SPH_C32(0x9e69af68) }, + { SPH_C32(0xc96b0030), SPH_C32(0xe7250000), SPH_C32(0x2f840000), + SPH_C32(0x264f0000), SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), + SPH_C32(0x509f6984), SPH_C32(0x9e69af68), SPH_C32(0x26600240), + SPH_C32(0xddd80000), SPH_C32(0x722a0000), SPH_C32(0x4f060000), + SPH_C32(0x936667ff), SPH_C32(0x29f944ce), SPH_C32(0x368b63d5), + SPH_C32(0x0c26f262) }, + { SPH_C32(0x26600240), SPH_C32(0xddd80000), SPH_C32(0x722a0000), + SPH_C32(0x4f060000), SPH_C32(0x936667ff), SPH_C32(0x29f944ce), + SPH_C32(0x368b63d5), SPH_C32(0x0c26f262), SPH_C32(0xef0b0270), + SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), SPH_C32(0x69490000), + SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), SPH_C32(0x66140a51), + SPH_C32(0x924f5d0a) } +}; + +static const sph_u32 T512_8[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xe8870170), SPH_C32(0x9d720000), SPH_C32(0x12db0000), + SPH_C32(0xd4220000), SPH_C32(0xf2886b27), SPH_C32(0xa921e543), + SPH_C32(0x4ef8b518), SPH_C32(0x618813b1), SPH_C32(0xb4370060), + SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), SPH_C32(0x5cae0000), + SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), SPH_C32(0x1b365f3d), + SPH_C32(0xf3d45758) }, + { SPH_C32(0xb4370060), SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), + SPH_C32(0x5cae0000), SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), + SPH_C32(0x1b365f3d), SPH_C32(0xf3d45758), SPH_C32(0x5cb00110), + SPH_C32(0x913e0000), SPH_C32(0x44190000), SPH_C32(0x888c0000), + SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), SPH_C32(0x55ceea25), + SPH_C32(0x925c44e9) }, + { SPH_C32(0x5cb00110), SPH_C32(0x913e0000), SPH_C32(0x44190000), + SPH_C32(0x888c0000), SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), + SPH_C32(0x55ceea25), SPH_C32(0x925c44e9), SPH_C32(0xe8870170), + SPH_C32(0x9d720000), SPH_C32(0x12db0000), SPH_C32(0xd4220000), + SPH_C32(0xf2886b27), SPH_C32(0xa921e543), SPH_C32(0x4ef8b518), + SPH_C32(0x618813b1) } +}; + +static const sph_u32 T512_10[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x774400f0), SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), + SPH_C32(0x34140000), SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), + SPH_C32(0x0bc3cd1e), SPH_C32(0xcf3775cb), SPH_C32(0xf46c0050), + SPH_C32(0x96180000), SPH_C32(0x14a50000), SPH_C32(0x031f0000), + SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), SPH_C32(0x9ca470d2), + SPH_C32(0x8a341574) }, + { SPH_C32(0xf46c0050), SPH_C32(0x96180000), SPH_C32(0x14a50000), + SPH_C32(0x031f0000), SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), + SPH_C32(0x9ca470d2), SPH_C32(0x8a341574), SPH_C32(0x832800a0), + SPH_C32(0x67420000), SPH_C32(0xe1170000), SPH_C32(0x370b0000), + SPH_C32(0xcba30034), SPH_C32(0x3c34923c), SPH_C32(0x9767bdcc), + SPH_C32(0x450360bf) }, + { SPH_C32(0x832800a0), SPH_C32(0x67420000), SPH_C32(0xe1170000), + SPH_C32(0x370b0000), SPH_C32(0xcba30034), SPH_C32(0x3c34923c), + SPH_C32(0x9767bdcc), SPH_C32(0x450360bf), SPH_C32(0x774400f0), + SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), SPH_C32(0x34140000), + SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), SPH_C32(0x0bc3cd1e), + SPH_C32(0xcf3775cb) } +}; + +static const sph_u32 T512_12[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xf7750009), SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), + SPH_C32(0x04920000), SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), + SPH_C32(0x7a87f14e), SPH_C32(0x9e16981a), SPH_C32(0xd46a0000), + SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), SPH_C32(0x4a290000), + SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), SPH_C32(0x98369604), + SPH_C32(0xf746c320) }, + { SPH_C32(0xd46a0000), SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), + SPH_C32(0x4a290000), SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), + SPH_C32(0x98369604), SPH_C32(0xf746c320), SPH_C32(0x231f0009), + SPH_C32(0x42f40000), SPH_C32(0x66790000), SPH_C32(0x4ebb0000), + SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), SPH_C32(0xe2b1674a), + SPH_C32(0x69505b3a) }, + { SPH_C32(0x231f0009), SPH_C32(0x42f40000), SPH_C32(0x66790000), + SPH_C32(0x4ebb0000), SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), + SPH_C32(0xe2b1674a), SPH_C32(0x69505b3a), SPH_C32(0xf7750009), + SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), SPH_C32(0x04920000), + SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), SPH_C32(0x7a87f14e), + SPH_C32(0x9e16981a) } +}; + +static const sph_u32 T512_14[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xf6800005), SPH_C32(0x3443c000), SPH_C32(0x24070000), + SPH_C32(0x8f3d0000), SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), + SPH_C32(0xcdc58b19), SPH_C32(0xd795ba31), SPH_C32(0xa67f0001), + SPH_C32(0x71378000), SPH_C32(0x19fc0000), SPH_C32(0x96db0000), + SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), SPH_C32(0x2c6d478f), + SPH_C32(0xac8e6c88) }, + { SPH_C32(0xa67f0001), SPH_C32(0x71378000), SPH_C32(0x19fc0000), + SPH_C32(0x96db0000), SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), + SPH_C32(0x2c6d478f), SPH_C32(0xac8e6c88), SPH_C32(0x50ff0004), + SPH_C32(0x45744000), SPH_C32(0x3dfb0000), SPH_C32(0x19e60000), + SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), SPH_C32(0xe1a8cc96), + SPH_C32(0x7b1bd6b9) }, + { SPH_C32(0x50ff0004), SPH_C32(0x45744000), SPH_C32(0x3dfb0000), + SPH_C32(0x19e60000), SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), + SPH_C32(0xe1a8cc96), SPH_C32(0x7b1bd6b9), SPH_C32(0xf6800005), + SPH_C32(0x3443c000), SPH_C32(0x24070000), SPH_C32(0x8f3d0000), + SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), SPH_C32(0xcdc58b19), + SPH_C32(0xd795ba31) } +}; + +static const sph_u32 T512_16[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x75c90003), SPH_C32(0x0e10c000), SPH_C32(0xd1200000), + SPH_C32(0xbaea0000), SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), + SPH_C32(0xbb28761d), SPH_C32(0x00b72e2b), SPH_C32(0xeecf0001), + SPH_C32(0x6f564000), SPH_C32(0xf33e0000), SPH_C32(0xa79e0000), + SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), SPH_C32(0x4a3b40ba), + SPH_C32(0xfeabf254) }, + { SPH_C32(0xeecf0001), SPH_C32(0x6f564000), SPH_C32(0xf33e0000), + SPH_C32(0xa79e0000), SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), + SPH_C32(0x4a3b40ba), SPH_C32(0xfeabf254), SPH_C32(0x9b060002), + SPH_C32(0x61468000), SPH_C32(0x221e0000), SPH_C32(0x1d740000), + SPH_C32(0x36715d27), SPH_C32(0x30495c92), SPH_C32(0xf11336a7), + SPH_C32(0xfe1cdc7f) }, + { SPH_C32(0x9b060002), SPH_C32(0x61468000), SPH_C32(0x221e0000), + SPH_C32(0x1d740000), SPH_C32(0x36715d27), SPH_C32(0x30495c92), + SPH_C32(0xf11336a7), SPH_C32(0xfe1cdc7f), SPH_C32(0x75c90003), + SPH_C32(0x0e10c000), SPH_C32(0xd1200000), SPH_C32(0xbaea0000), + SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), SPH_C32(0xbb28761d), + SPH_C32(0x00b72e2b) } +}; + +static const sph_u32 T512_18[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x75a40000), SPH_C32(0xc28b2700), SPH_C32(0x94a40000), + SPH_C32(0x90f50000), SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), + SPH_C32(0x1767c483), SPH_C32(0xaedf667e), SPH_C32(0xd1660000), + SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), SPH_C32(0xf6940000), + SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), SPH_C32(0xb4431b17), + SPH_C32(0x857f3c2b) }, + { SPH_C32(0xd1660000), SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), + SPH_C32(0xf6940000), SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), + SPH_C32(0xb4431b17), SPH_C32(0x857f3c2b), SPH_C32(0xa4c20000), + SPH_C32(0xd9372400), SPH_C32(0x0a480000), SPH_C32(0x66610000), + SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), SPH_C32(0xa324df94), + SPH_C32(0x2ba05a55) }, + { SPH_C32(0xa4c20000), SPH_C32(0xd9372400), SPH_C32(0x0a480000), + SPH_C32(0x66610000), SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), + SPH_C32(0xa324df94), SPH_C32(0x2ba05a55), SPH_C32(0x75a40000), + SPH_C32(0xc28b2700), SPH_C32(0x94a40000), SPH_C32(0x90f50000), + SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), SPH_C32(0x1767c483), + SPH_C32(0xaedf667e) } +}; + +static const sph_u32 T512_20[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x45180000), SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), + SPH_C32(0x3b480000), SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), + SPH_C32(0x16bca6b0), SPH_C32(0xdf33f4df), SPH_C32(0xb83d0000), + SPH_C32(0x16710600), SPH_C32(0x379a0000), SPH_C32(0xf5b10000), + SPH_C32(0x228161ac), SPH_C32(0xae48f145), SPH_C32(0x66241616), + SPH_C32(0xc5c1eb3e) }, + { SPH_C32(0xb83d0000), SPH_C32(0x16710600), SPH_C32(0x379a0000), + SPH_C32(0xf5b10000), SPH_C32(0x228161ac), SPH_C32(0xae48f145), + SPH_C32(0x66241616), SPH_C32(0xc5c1eb3e), SPH_C32(0xfd250000), + SPH_C32(0xb3c41100), SPH_C32(0xcef00000), SPH_C32(0xcef90000), + SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), SPH_C32(0x7098b0a6), + SPH_C32(0x1af21fe1) }, + { SPH_C32(0xfd250000), SPH_C32(0xb3c41100), SPH_C32(0xcef00000), + SPH_C32(0xcef90000), SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), + SPH_C32(0x7098b0a6), SPH_C32(0x1af21fe1), SPH_C32(0x45180000), + SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), SPH_C32(0x3b480000), + SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), SPH_C32(0x16bca6b0), + SPH_C32(0xdf33f4df) } +}; + +static const sph_u32 T512_22[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x0c720000), SPH_C32(0x49e50f00), SPH_C32(0x42790000), + SPH_C32(0x5cea0000), SPH_C32(0x33aa301a), SPH_C32(0x15822514), + SPH_C32(0x95a34b7b), SPH_C32(0xb44b0090), SPH_C32(0xfe220000), + SPH_C32(0xa7580500), SPH_C32(0x25d10000), SPH_C32(0xf7600000), + SPH_C32(0x893178da), SPH_C32(0x1fd4f860), SPH_C32(0x4ed0a315), + SPH_C32(0xa123ff9f) }, + { SPH_C32(0xfe220000), SPH_C32(0xa7580500), SPH_C32(0x25d10000), + SPH_C32(0xf7600000), SPH_C32(0x893178da), SPH_C32(0x1fd4f860), + SPH_C32(0x4ed0a315), SPH_C32(0xa123ff9f), SPH_C32(0xf2500000), + SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), SPH_C32(0xab8a0000), + SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), SPH_C32(0xdb73e86e), + SPH_C32(0x1568ff0f) }, + { SPH_C32(0xf2500000), SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), + SPH_C32(0xab8a0000), SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), + SPH_C32(0xdb73e86e), SPH_C32(0x1568ff0f), SPH_C32(0x0c720000), + SPH_C32(0x49e50f00), SPH_C32(0x42790000), SPH_C32(0x5cea0000), + SPH_C32(0x33aa301a), SPH_C32(0x15822514), SPH_C32(0x95a34b7b), + SPH_C32(0xb44b0090) } +}; + +static const sph_u32 T512_24[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x69510000), SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), + SPH_C32(0xac2f0000), SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), + SPH_C32(0x87ec287c), SPH_C32(0xbce1a3ce), SPH_C32(0xc6730000), + SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), SPH_C32(0x218d0000), + SPH_C32(0x23111587), SPH_C32(0x7913512f), SPH_C32(0x1d28ac88), + SPH_C32(0x378dd173) }, + { SPH_C32(0xc6730000), SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), + SPH_C32(0x218d0000), SPH_C32(0x23111587), SPH_C32(0x7913512f), + SPH_C32(0x1d28ac88), SPH_C32(0x378dd173), SPH_C32(0xaf220000), + SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), SPH_C32(0x8da20000), + SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), SPH_C32(0x9ac484f4), + SPH_C32(0x8b6c72bd) }, + { SPH_C32(0xaf220000), SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), + SPH_C32(0x8da20000), SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), + SPH_C32(0x9ac484f4), SPH_C32(0x8b6c72bd), SPH_C32(0x69510000), + SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), SPH_C32(0xac2f0000), + SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), SPH_C32(0x87ec287c), + SPH_C32(0xbce1a3ce) } +}; + +static const sph_u32 T512_26[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x54500000), SPH_C32(0x0671005c), SPH_C32(0x25ae0000), + SPH_C32(0x6a1e0000), SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), + SPH_C32(0xbfba18c3), SPH_C32(0x7e715d17), SPH_C32(0xbc8d0000), + SPH_C32(0xfc3b0018), SPH_C32(0x19830000), SPH_C32(0xd10b0000), + SPH_C32(0xae1878c4), SPH_C32(0x42a69856), SPH_C32(0x0012da37), + SPH_C32(0x2c3b504e) }, + { SPH_C32(0xbc8d0000), SPH_C32(0xfc3b0018), SPH_C32(0x19830000), + SPH_C32(0xd10b0000), SPH_C32(0xae1878c4), SPH_C32(0x42a69856), + SPH_C32(0x0012da37), SPH_C32(0x2c3b504e), SPH_C32(0xe8dd0000), + SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), SPH_C32(0xbb150000), + SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), SPH_C32(0xbfa8c2f4), + SPH_C32(0x524a0d59) }, + { SPH_C32(0xe8dd0000), SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), + SPH_C32(0xbb150000), SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), + SPH_C32(0xbfa8c2f4), SPH_C32(0x524a0d59), SPH_C32(0x54500000), + SPH_C32(0x0671005c), SPH_C32(0x25ae0000), SPH_C32(0x6a1e0000), + SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), SPH_C32(0xbfba18c3), + SPH_C32(0x7e715d17) } +}; + +static const sph_u32 T512_28[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x14190000), SPH_C32(0x23ca003c), SPH_C32(0x50df0000), + SPH_C32(0x44b60000), SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), + SPH_C32(0x61e610b0), SPH_C32(0xdbcadb80), SPH_C32(0xe3430000), + SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), SPH_C32(0xaa4e0000), + SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), SPH_C32(0x123db156), + SPH_C32(0x3a4e99d7) }, + { SPH_C32(0xe3430000), SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), + SPH_C32(0xaa4e0000), SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), + SPH_C32(0x123db156), SPH_C32(0x3a4e99d7), SPH_C32(0xf75a0000), + SPH_C32(0x19840028), SPH_C32(0xa2190000), SPH_C32(0xeef80000), + SPH_C32(0xc0722516), SPH_C32(0x19981260), SPH_C32(0x73dba1e6), + SPH_C32(0xe1844257) }, + { SPH_C32(0xf75a0000), SPH_C32(0x19840028), SPH_C32(0xa2190000), + SPH_C32(0xeef80000), SPH_C32(0xc0722516), SPH_C32(0x19981260), + SPH_C32(0x73dba1e6), SPH_C32(0xe1844257), SPH_C32(0x14190000), + SPH_C32(0x23ca003c), SPH_C32(0x50df0000), SPH_C32(0x44b60000), + SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), SPH_C32(0x61e610b0), + SPH_C32(0xdbcadb80) } +}; + +static const sph_u32 T512_30[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x86790000), SPH_C32(0x3f390002), SPH_C32(0xe19ae000), + SPH_C32(0x98560000), SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), + SPH_C32(0xd3dd4944), SPH_C32(0x161ddab9), SPH_C32(0x30b70000), + SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), SPH_C32(0x42c40000), + SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), SPH_C32(0x21afa1ea), + SPH_C32(0xb0a51834) }, + { SPH_C32(0x30b70000), SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), + SPH_C32(0x42c40000), SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), + SPH_C32(0x21afa1ea), SPH_C32(0xb0a51834), SPH_C32(0xb6ce0000), + SPH_C32(0xdae90002), SPH_C32(0x156e8000), SPH_C32(0xda920000), + SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), SPH_C32(0xf272e8ae), + SPH_C32(0xa6b8c28d) }, + { SPH_C32(0xb6ce0000), SPH_C32(0xdae90002), SPH_C32(0x156e8000), + SPH_C32(0xda920000), SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), + SPH_C32(0xf272e8ae), SPH_C32(0xa6b8c28d), SPH_C32(0x86790000), + SPH_C32(0x3f390002), SPH_C32(0xe19ae000), SPH_C32(0x98560000), + SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), SPH_C32(0xd3dd4944), + SPH_C32(0x161ddab9) } +}; + +static const sph_u32 T512_32[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xaec30000), SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), + SPH_C32(0x2c150000), SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), + SPH_C32(0xab92f78f), SPH_C32(0xa312567b), SPH_C32(0xdb250000), + SPH_C32(0x09290000), SPH_C32(0x49aac000), SPH_C32(0x81e10000), + SPH_C32(0xcafe6b59), SPH_C32(0x42793431), SPH_C32(0x43566b76), + SPH_C32(0xe86cba2e) }, + { SPH_C32(0xdb250000), SPH_C32(0x09290000), SPH_C32(0x49aac000), + SPH_C32(0x81e10000), SPH_C32(0xcafe6b59), SPH_C32(0x42793431), + SPH_C32(0x43566b76), SPH_C32(0xe86cba2e), SPH_C32(0x75e60000), + SPH_C32(0x95660001), SPH_C32(0x307b2000), SPH_C32(0xadf40000), + SPH_C32(0x8f321eea), SPH_C32(0x24298307), SPH_C32(0xe8c49cf9), + SPH_C32(0x4b7eec55) }, + { SPH_C32(0x75e60000), SPH_C32(0x95660001), SPH_C32(0x307b2000), + SPH_C32(0xadf40000), SPH_C32(0x8f321eea), SPH_C32(0x24298307), + SPH_C32(0xe8c49cf9), SPH_C32(0x4b7eec55), SPH_C32(0xaec30000), + SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), SPH_C32(0x2c150000), + SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), SPH_C32(0xab92f78f), + SPH_C32(0xa312567b) } +}; + +static const sph_u32 T512_34[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xac480000), SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), + SPH_C32(0x03430000), SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), + SPH_C32(0xfe72c7fe), SPH_C32(0x91e478f6), SPH_C32(0x1e4e0000), + SPH_C32(0xdecf0000), SPH_C32(0x6df80180), SPH_C32(0x77240000), + SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), SPH_C32(0xcda31812), + SPH_C32(0x98aa496e) }, + { SPH_C32(0x1e4e0000), SPH_C32(0xdecf0000), SPH_C32(0x6df80180), + SPH_C32(0x77240000), SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), + SPH_C32(0xcda31812), SPH_C32(0x98aa496e), SPH_C32(0xb2060000), + SPH_C32(0xc5690000), SPH_C32(0x28031200), SPH_C32(0x74670000), + SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), SPH_C32(0x33d1dfec), + SPH_C32(0x094e3198) }, + { SPH_C32(0xb2060000), SPH_C32(0xc5690000), SPH_C32(0x28031200), + SPH_C32(0x74670000), SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), + SPH_C32(0x33d1dfec), SPH_C32(0x094e3198), SPH_C32(0xac480000), + SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), SPH_C32(0x03430000), + SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), SPH_C32(0xfe72c7fe), + SPH_C32(0x91e478f6) } +}; + +static const sph_u32 T512_36[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x78230000), SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), + SPH_C32(0x90a50000), SPH_C32(0x713e2879), SPH_C32(0x7ee98924), + SPH_C32(0xf08ca062), SPH_C32(0x636f8bab), SPH_C32(0x02af0000), + SPH_C32(0xb7280000), SPH_C32(0xba1c0300), SPH_C32(0x56980000), + SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), SPH_C32(0xa95c149a), + SPH_C32(0xf4f6ea7b) }, + { SPH_C32(0x02af0000), SPH_C32(0xb7280000), SPH_C32(0xba1c0300), + SPH_C32(0x56980000), SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), + SPH_C32(0xa95c149a), SPH_C32(0xf4f6ea7b), SPH_C32(0x7a8c0000), + SPH_C32(0xa5d40000), SPH_C32(0x13260880), SPH_C32(0xc63d0000), + SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), SPH_C32(0x59d0b4f8), + SPH_C32(0x979961d0) }, + { SPH_C32(0x7a8c0000), SPH_C32(0xa5d40000), SPH_C32(0x13260880), + SPH_C32(0xc63d0000), SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), + SPH_C32(0x59d0b4f8), SPH_C32(0x979961d0), SPH_C32(0x78230000), + SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), SPH_C32(0x90a50000), + SPH_C32(0x713e2879), SPH_C32(0x7ee98924), SPH_C32(0xf08ca062), + SPH_C32(0x636f8bab) } +}; + +static const sph_u32 T512_38[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xcc140000), SPH_C32(0xa5630000), SPH_C32(0x5ab90780), + SPH_C32(0x3b500000), SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), + SPH_C32(0x694348c1), SPH_C32(0xca5a87fe), SPH_C32(0x819e0000), + SPH_C32(0xec570000), SPH_C32(0x66320280), SPH_C32(0x95f30000), + SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), SPH_C32(0xe65aa22d), + SPH_C32(0x8e67b7fa) }, + { SPH_C32(0x819e0000), SPH_C32(0xec570000), SPH_C32(0x66320280), + SPH_C32(0x95f30000), SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), + SPH_C32(0xe65aa22d), SPH_C32(0x8e67b7fa), SPH_C32(0x4d8a0000), + SPH_C32(0x49340000), SPH_C32(0x3c8b0500), SPH_C32(0xaea30000), + SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), SPH_C32(0x8f19eaec), + SPH_C32(0x443d3004) }, + { SPH_C32(0x4d8a0000), SPH_C32(0x49340000), SPH_C32(0x3c8b0500), + SPH_C32(0xaea30000), SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), + SPH_C32(0x8f19eaec), SPH_C32(0x443d3004), SPH_C32(0xcc140000), + SPH_C32(0xa5630000), SPH_C32(0x5ab90780), SPH_C32(0x3b500000), + SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), SPH_C32(0x694348c1), + SPH_C32(0xca5a87fe) } +}; + +static const sph_u32 T512_40[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x52500000), SPH_C32(0x29540000), SPH_C32(0x6a61004e), + SPH_C32(0xf0ff0000), SPH_C32(0x9a317eec), SPH_C32(0x452341ce), + SPH_C32(0xcf568fe5), SPH_C32(0x5303130f), SPH_C32(0x538d0000), + SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), SPH_C32(0x56ff0000), + SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), SPH_C32(0xa9444018), + SPH_C32(0x7f975691) }, + { SPH_C32(0x538d0000), SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), + SPH_C32(0x56ff0000), SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), + SPH_C32(0xa9444018), SPH_C32(0x7f975691), SPH_C32(0x01dd0000), + SPH_C32(0x80a80000), SPH_C32(0xf4960048), SPH_C32(0xa6000000), + SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), SPH_C32(0x6612cffd), + SPH_C32(0x2c94459e) }, + { SPH_C32(0x01dd0000), SPH_C32(0x80a80000), SPH_C32(0xf4960048), + SPH_C32(0xa6000000), SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), + SPH_C32(0x6612cffd), SPH_C32(0x2c94459e), SPH_C32(0x52500000), + SPH_C32(0x29540000), SPH_C32(0x6a61004e), SPH_C32(0xf0ff0000), + SPH_C32(0x9a317eec), SPH_C32(0x452341ce), SPH_C32(0xcf568fe5), + SPH_C32(0x5303130f) } +}; + +static const sph_u32 T512_42[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x88980000), SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), + SPH_C32(0xfb4e0000), SPH_C32(0xf158079a), SPH_C32(0x61ae9167), + SPH_C32(0xa895706c), SPH_C32(0xe6107494), SPH_C32(0x0bc20000), + SPH_C32(0xdb630000), SPH_C32(0x7e88000c), SPH_C32(0x15860000), + SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), SPH_C32(0xf460449e), + SPH_C32(0xd8b61463) }, + { SPH_C32(0x0bc20000), SPH_C32(0xdb630000), SPH_C32(0x7e88000c), + SPH_C32(0x15860000), SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), + SPH_C32(0xf460449e), SPH_C32(0xd8b61463), SPH_C32(0x835a0000), + SPH_C32(0xc4f70000), SPH_C32(0x01470022), SPH_C32(0xeec80000), + SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), SPH_C32(0x5cf534f2), + SPH_C32(0x3ea660f7) }, + { SPH_C32(0x835a0000), SPH_C32(0xc4f70000), SPH_C32(0x01470022), + SPH_C32(0xeec80000), SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), + SPH_C32(0x5cf534f2), SPH_C32(0x3ea660f7), SPH_C32(0x88980000), + SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), SPH_C32(0xfb4e0000), + SPH_C32(0xf158079a), SPH_C32(0x61ae9167), SPH_C32(0xa895706c), + SPH_C32(0xe6107494) } +}; + +static const sph_u32 T512_44[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xa53b0000), SPH_C32(0x14260000), SPH_C32(0x4e30001e), + SPH_C32(0x7cae0000), SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), + SPH_C32(0xf73168d8), SPH_C32(0x0b1b4946), SPH_C32(0x07ed0000), + SPH_C32(0xb2500000), SPH_C32(0x8774000a), SPH_C32(0x970d0000), + SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), SPH_C32(0xf4786222), + SPH_C32(0x9075b1ce) }, + { SPH_C32(0x07ed0000), SPH_C32(0xb2500000), SPH_C32(0x8774000a), + SPH_C32(0x970d0000), SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), + SPH_C32(0xf4786222), SPH_C32(0x9075b1ce), SPH_C32(0xa2d60000), + SPH_C32(0xa6760000), SPH_C32(0xc9440014), SPH_C32(0xeba30000), + SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), SPH_C32(0x03490afa), + SPH_C32(0x9b6ef888) }, + { SPH_C32(0xa2d60000), SPH_C32(0xa6760000), SPH_C32(0xc9440014), + SPH_C32(0xeba30000), SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), + SPH_C32(0x03490afa), SPH_C32(0x9b6ef888), SPH_C32(0xa53b0000), + SPH_C32(0x14260000), SPH_C32(0x4e30001e), SPH_C32(0x7cae0000), + SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), SPH_C32(0xf73168d8), + SPH_C32(0x0b1b4946) } +}; + +static const sph_u32 T512_46[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x58430000), SPH_C32(0x807e0000), SPH_C32(0x78330001), + SPH_C32(0xc66b3800), SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), + SPH_C32(0xac73fe6f), SPH_C32(0x3a4479b1), SPH_C32(0x1d5a0000), + SPH_C32(0x2b720000), SPH_C32(0x488d0000), SPH_C32(0xaf611800), + SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), SPH_C32(0x81a20429), + SPH_C32(0x1e7536a6) }, + { SPH_C32(0x1d5a0000), SPH_C32(0x2b720000), SPH_C32(0x488d0000), + SPH_C32(0xaf611800), SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), + SPH_C32(0x81a20429), SPH_C32(0x1e7536a6), SPH_C32(0x45190000), + SPH_C32(0xab0c0000), SPH_C32(0x30be0001), SPH_C32(0x690a2000), + SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), SPH_C32(0x2dd1fa46), + SPH_C32(0x24314f17) }, + { SPH_C32(0x45190000), SPH_C32(0xab0c0000), SPH_C32(0x30be0001), + SPH_C32(0x690a2000), SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), + SPH_C32(0x2dd1fa46), SPH_C32(0x24314f17), SPH_C32(0x58430000), + SPH_C32(0x807e0000), SPH_C32(0x78330001), SPH_C32(0xc66b3800), + SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), SPH_C32(0xac73fe6f), + SPH_C32(0x3a4479b1) } +}; + +static const sph_u32 T512_48[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x1e6c0000), SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), + SPH_C32(0xbcb6b800), SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), + SPH_C32(0x6a0c1bc8), SPH_C32(0xb99dc2eb), SPH_C32(0x92560000), + SPH_C32(0x1eda0000), SPH_C32(0xea510000), SPH_C32(0xe8b13000), + SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), SPH_C32(0xb15c2254), + SPH_C32(0x33c5244f) }, + { SPH_C32(0x92560000), SPH_C32(0x1eda0000), SPH_C32(0xea510000), + SPH_C32(0xe8b13000), SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), + SPH_C32(0xb15c2254), SPH_C32(0x33c5244f), SPH_C32(0x8c3a0000), + SPH_C32(0xda980000), SPH_C32(0x607f0000), SPH_C32(0x54078800), + SPH_C32(0x85714513), SPH_C32(0x6006b243), SPH_C32(0xdb50399c), + SPH_C32(0x8a58e6a4) }, + { SPH_C32(0x8c3a0000), SPH_C32(0xda980000), SPH_C32(0x607f0000), + SPH_C32(0x54078800), SPH_C32(0x85714513), SPH_C32(0x6006b243), + SPH_C32(0xdb50399c), SPH_C32(0x8a58e6a4), SPH_C32(0x1e6c0000), + SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), SPH_C32(0xbcb6b800), + SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), SPH_C32(0x6a0c1bc8), + SPH_C32(0xb99dc2eb) } +}; + +static const sph_u32 T512_50[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x02f20000), SPH_C32(0xa2810000), SPH_C32(0x873f0000), + SPH_C32(0xe36c7800), SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), + SPH_C32(0xc4c23237), SPH_C32(0x7f32259e), SPH_C32(0xbadd0000), + SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), SPH_C32(0xf7282800), + SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), SPH_C32(0xea5a8d14), + SPH_C32(0x2a2c18f0) }, + { SPH_C32(0xbadd0000), SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), + SPH_C32(0xf7282800), SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), + SPH_C32(0xea5a8d14), SPH_C32(0x2a2c18f0), SPH_C32(0xb82f0000), + SPH_C32(0xb12c0000), SPH_C32(0x30d80000), SPH_C32(0x14445000), + SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), SPH_C32(0x2e98bf23), + SPH_C32(0x551e3d6e) }, + { SPH_C32(0xb82f0000), SPH_C32(0xb12c0000), SPH_C32(0x30d80000), + SPH_C32(0x14445000), SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), + SPH_C32(0x2e98bf23), SPH_C32(0x551e3d6e), SPH_C32(0x02f20000), + SPH_C32(0xa2810000), SPH_C32(0x873f0000), SPH_C32(0xe36c7800), + SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), SPH_C32(0xc4c23237), + SPH_C32(0x7f32259e) } +}; + +static const sph_u32 T512_52[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xb4310000), SPH_C32(0x77330000), SPH_C32(0xb15d0000), + SPH_C32(0x7fd004e0), SPH_C32(0x78a26138), SPH_C32(0xd116c35d), + SPH_C32(0xd256d489), SPH_C32(0x4e6f74de), SPH_C32(0xe3060000), + SPH_C32(0xbdc10000), SPH_C32(0x87130000), SPH_C32(0xbff20060), + SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), SPH_C32(0x73c5ab06), + SPH_C32(0x5bd61539) }, + { SPH_C32(0xe3060000), SPH_C32(0xbdc10000), SPH_C32(0x87130000), + SPH_C32(0xbff20060), SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), + SPH_C32(0x73c5ab06), SPH_C32(0x5bd61539), SPH_C32(0x57370000), + SPH_C32(0xcaf20000), SPH_C32(0x364e0000), SPH_C32(0xc0220480), + SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), SPH_C32(0xa1937f8f), + SPH_C32(0x15b961e7) }, + { SPH_C32(0x57370000), SPH_C32(0xcaf20000), SPH_C32(0x364e0000), + SPH_C32(0xc0220480), SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), + SPH_C32(0xa1937f8f), SPH_C32(0x15b961e7), SPH_C32(0xb4310000), + SPH_C32(0x77330000), SPH_C32(0xb15d0000), SPH_C32(0x7fd004e0), + SPH_C32(0x78a26138), SPH_C32(0xd116c35d), SPH_C32(0xd256d489), + SPH_C32(0x4e6f74de) } +}; + +static const sph_u32 T512_54[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xe6280000), SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), + SPH_C32(0xd3d002e0), SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), + SPH_C32(0x289506b4), SPH_C32(0xd75a4897), SPH_C32(0xf0c50000), + SPH_C32(0x59230000), SPH_C32(0x45820000), SPH_C32(0xe18d00c0), + SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), SPH_C32(0xcbe0fe1c), + SPH_C32(0x56a7b19f) }, + { SPH_C32(0xf0c50000), SPH_C32(0x59230000), SPH_C32(0x45820000), + SPH_C32(0xe18d00c0), SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), + SPH_C32(0xcbe0fe1c), SPH_C32(0x56a7b19f), SPH_C32(0x16ed0000), + SPH_C32(0x15680000), SPH_C32(0xedd70000), SPH_C32(0x325d0220), + SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), SPH_C32(0xe375f8a8), + SPH_C32(0x81fdf908) }, + { SPH_C32(0x16ed0000), SPH_C32(0x15680000), SPH_C32(0xedd70000), + SPH_C32(0x325d0220), SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), + SPH_C32(0xe375f8a8), SPH_C32(0x81fdf908), SPH_C32(0xe6280000), + SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), SPH_C32(0xd3d002e0), + SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), SPH_C32(0x289506b4), + SPH_C32(0xd75a4897) } +}; + +static const sph_u32 T512_56[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xee930000), SPH_C32(0xd6070000), SPH_C32(0x92c10000), + SPH_C32(0x2b9801e0), SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), + SPH_C32(0x45312374), SPH_C32(0x201f6a64), SPH_C32(0x7b280000), + SPH_C32(0x57420000), SPH_C32(0xa9e50000), SPH_C32(0x634300a0), + SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), SPH_C32(0x27f83b03), + SPH_C32(0xc7ff60f0) }, + { SPH_C32(0x7b280000), SPH_C32(0x57420000), SPH_C32(0xa9e50000), + SPH_C32(0x634300a0), SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), + SPH_C32(0x27f83b03), SPH_C32(0xc7ff60f0), SPH_C32(0x95bb0000), + SPH_C32(0x81450000), SPH_C32(0x3b240000), SPH_C32(0x48db0140), + SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), SPH_C32(0x62c91877), + SPH_C32(0xe7e00a94) }, + { SPH_C32(0x95bb0000), SPH_C32(0x81450000), SPH_C32(0x3b240000), + SPH_C32(0x48db0140), SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), + SPH_C32(0x62c91877), SPH_C32(0xe7e00a94), SPH_C32(0xee930000), + SPH_C32(0xd6070000), SPH_C32(0x92c10000), SPH_C32(0x2b9801e0), + SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), SPH_C32(0x45312374), + SPH_C32(0x201f6a64) } +}; + +static const sph_u32 T512_58[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x5fa80000), SPH_C32(0x56030000), SPH_C32(0x43ae0000), + SPH_C32(0x64f30013), SPH_C32(0x257e86bf), SPH_C32(0x1311944e), + SPH_C32(0x541e95bf), SPH_C32(0x8ea4db69), SPH_C32(0x00440000), + SPH_C32(0x7f480000), SPH_C32(0xda7c0000), SPH_C32(0x2a230001), + SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), SPH_C32(0x030a9e60), + SPH_C32(0xbe0a679e) }, + { SPH_C32(0x00440000), SPH_C32(0x7f480000), SPH_C32(0xda7c0000), + SPH_C32(0x2a230001), SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), + SPH_C32(0x030a9e60), SPH_C32(0xbe0a679e), SPH_C32(0x5fec0000), + SPH_C32(0x294b0000), SPH_C32(0x99d20000), SPH_C32(0x4ed00012), + SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), SPH_C32(0x57140bdf), + SPH_C32(0x30aebcf7) }, + { SPH_C32(0x5fec0000), SPH_C32(0x294b0000), SPH_C32(0x99d20000), + SPH_C32(0x4ed00012), SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), + SPH_C32(0x57140bdf), SPH_C32(0x30aebcf7), SPH_C32(0x5fa80000), + SPH_C32(0x56030000), SPH_C32(0x43ae0000), SPH_C32(0x64f30013), + SPH_C32(0x257e86bf), SPH_C32(0x1311944e), SPH_C32(0x541e95bf), + SPH_C32(0x8ea4db69) } +}; + +static const sph_u32 T512_60[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x01930000), SPH_C32(0xe7820000), SPH_C32(0xedfb0000), + SPH_C32(0xcf0c000b), SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), + SPH_C32(0x063661e1), SPH_C32(0x536f9e7b), SPH_C32(0x92280000), + SPH_C32(0xdc850000), SPH_C32(0x57fa0000), SPH_C32(0x56dc0003), + SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), SPH_C32(0x90cef752), + SPH_C32(0x7b1675d7) }, + { SPH_C32(0x92280000), SPH_C32(0xdc850000), SPH_C32(0x57fa0000), + SPH_C32(0x56dc0003), SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), + SPH_C32(0x90cef752), SPH_C32(0x7b1675d7), SPH_C32(0x93bb0000), + SPH_C32(0x3b070000), SPH_C32(0xba010000), SPH_C32(0x99d00008), + SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), SPH_C32(0x96f896b3), + SPH_C32(0x2879ebac) }, + { SPH_C32(0x93bb0000), SPH_C32(0x3b070000), SPH_C32(0xba010000), + SPH_C32(0x99d00008), SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), + SPH_C32(0x96f896b3), SPH_C32(0x2879ebac), SPH_C32(0x01930000), + SPH_C32(0xe7820000), SPH_C32(0xedfb0000), SPH_C32(0xcf0c000b), + SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), SPH_C32(0x063661e1), + SPH_C32(0x536f9e7b) } +}; + +static const sph_u32 T512_62[4][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x033d0000), SPH_C32(0x08b30000), SPH_C32(0xf33a0000), + SPH_C32(0x3ac20007), SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), + SPH_C32(0x0ea5cfe3), SPH_C32(0xe6da7ffe), SPH_C32(0xa8da0000), + SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), SPH_C32(0x07da0002), + SPH_C32(0x7d669583), SPH_C32(0x1f98708a), SPH_C32(0xbb668808), + SPH_C32(0xda878000) }, + { SPH_C32(0xa8da0000), SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), + SPH_C32(0x07da0002), SPH_C32(0x7d669583), SPH_C32(0x1f98708a), + SPH_C32(0xbb668808), SPH_C32(0xda878000), SPH_C32(0xabe70000), + SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), SPH_C32(0x3d180005), + SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), SPH_C32(0xb5c347eb), + SPH_C32(0x3c5dfffe) }, + { SPH_C32(0xabe70000), SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), + SPH_C32(0x3d180005), SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), + SPH_C32(0xb5c347eb), SPH_C32(0x3c5dfffe), SPH_C32(0x033d0000), + SPH_C32(0x08b30000), SPH_C32(0xf33a0000), SPH_C32(0x3ac20007), + SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), SPH_C32(0x0ea5cfe3), + SPH_C32(0xe6da7ffe) } +}; + +#define INPUT_BIG do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T512_0[acc >> 6][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + m8 = rp[8]; \ + m9 = rp[9]; \ + mA = rp[10]; \ + mB = rp[11]; \ + mC = rp[12]; \ + mD = rp[13]; \ + mE = rp[14]; \ + mF = rp[15]; \ + rp = &T512_2[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_4[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_6[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[1]; \ + rp = &T512_8[acc >> 6][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_10[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_12[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_14[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[2]; \ + rp = &T512_16[acc >> 6][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_18[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_20[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_22[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[3]; \ + rp = &T512_24[acc >> 6][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_26[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_28[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_30[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[4]; \ + rp = &T512_32[acc >> 6][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_34[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_36[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_38[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[5]; \ + rp = &T512_40[acc >> 6][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_42[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_44[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_46[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[6]; \ + rp = &T512_48[acc >> 6][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_50[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_52[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_54[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[7]; \ + rp = &T512_56[acc >> 6][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_58[(acc >> 4) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_60[(acc >> 2) & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_62[acc & 0x03][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_BIG == 3 + +static const sph_u32 T512_0[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x9cbb1800), SPH_C32(0xb0d30000), SPH_C32(0x92510000), + SPH_C32(0xed930000), SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), + SPH_C32(0x430633da), SPH_C32(0x78cace29), SPH_C32(0xc8934400), + SPH_C32(0x5a3e0000), SPH_C32(0x57870000), SPH_C32(0x4c560000), + SPH_C32(0xea982435), SPH_C32(0x75b11115), SPH_C32(0x28b67247), + SPH_C32(0x2dd1f9ab) }, + { SPH_C32(0x29449c00), SPH_C32(0x64e70000), SPH_C32(0xf24b0000), + SPH_C32(0xc2f30000), SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), + SPH_C32(0xf3e04259), SPH_C32(0x8d0d9ec4), SPH_C32(0x466d0c00), + SPH_C32(0x08620000), SPH_C32(0xdd5d0000), SPH_C32(0xbadd0000), + SPH_C32(0x6a927942), SPH_C32(0x441f2b93), SPH_C32(0x218ace6f), + SPH_C32(0xbf2c0be2) }, + { SPH_C32(0xb5ff8400), SPH_C32(0xd4340000), SPH_C32(0x601a0000), + SPH_C32(0x2f600000), SPH_C32(0x57e40dca), SPH_C32(0xb7d6e2b1), + SPH_C32(0xb0e67183), SPH_C32(0xf5c750ed), SPH_C32(0x8efe4800), + SPH_C32(0x525c0000), SPH_C32(0x8ada0000), SPH_C32(0xf68b0000), + SPH_C32(0x800a5d77), SPH_C32(0x31ae3a86), SPH_C32(0x093cbc28), + SPH_C32(0x92fdf249) }, + { SPH_C32(0x466d0c00), SPH_C32(0x08620000), SPH_C32(0xdd5d0000), + SPH_C32(0xbadd0000), SPH_C32(0x6a927942), SPH_C32(0x441f2b93), + SPH_C32(0x218ace6f), SPH_C32(0xbf2c0be2), SPH_C32(0x6f299000), + SPH_C32(0x6c850000), SPH_C32(0x2f160000), SPH_C32(0x782e0000), + SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), SPH_C32(0xd26a8c36), + SPH_C32(0x32219526) }, + { SPH_C32(0xdad61400), SPH_C32(0xb8b10000), SPH_C32(0x4f0c0000), + SPH_C32(0x574e0000), SPH_C32(0x33a83a07), SPH_C32(0xa50bfe67), + SPH_C32(0x628cfdb5), SPH_C32(0xc7e6c5cb), SPH_C32(0xa7bad400), + SPH_C32(0x36bb0000), SPH_C32(0x78910000), SPH_C32(0x34780000), + SPH_C32(0x8ed413f8), SPH_C32(0x676c0dc3), SPH_C32(0xfadcfe71), + SPH_C32(0x1ff06c8d) }, + { SPH_C32(0x6f299000), SPH_C32(0x6c850000), SPH_C32(0x2f160000), + SPH_C32(0x782e0000), SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), + SPH_C32(0xd26a8c36), SPH_C32(0x32219526), SPH_C32(0x29449c00), + SPH_C32(0x64e70000), SPH_C32(0xf24b0000), SPH_C32(0xc2f30000), + SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), SPH_C32(0xf3e04259), + SPH_C32(0x8d0d9ec4) }, + { SPH_C32(0xf3928800), SPH_C32(0xdc560000), SPH_C32(0xbd470000), + SPH_C32(0x95bd0000), SPH_C32(0x3d767488), SPH_C32(0xf3c9c922), + SPH_C32(0x916cbfec), SPH_C32(0x4aeb5b0f), SPH_C32(0xe1d7d800), + SPH_C32(0x3ed90000), SPH_C32(0xa5cc0000), SPH_C32(0x8ea50000), + SPH_C32(0xe4466aba), SPH_C32(0x23732650), SPH_C32(0xdb56301e), + SPH_C32(0xa0dc676f) } +}; + +static const sph_u32 T512_3[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x145a3c00), SPH_C32(0xb9e90000), SPH_C32(0x61270000), + SPH_C32(0xf1610000), SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), + SPH_C32(0x47a96720), SPH_C32(0xe18e24c5), SPH_C32(0x23671400), + SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), SPH_C32(0xfb750000), + SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), SPH_C32(0x02c40a3f), + SPH_C32(0xdc24e61f) }, + { SPH_C32(0x23671400), SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), + SPH_C32(0xfb750000), SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), + SPH_C32(0x02c40a3f), SPH_C32(0xdc24e61f), SPH_C32(0x373d2800), + SPH_C32(0x71500000), SPH_C32(0x95e00000), SPH_C32(0x0a140000), + SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), SPH_C32(0x456d6d1f), + SPH_C32(0x3daac2da) }, + { SPH_C32(0x373d2800), SPH_C32(0x71500000), SPH_C32(0x95e00000), + SPH_C32(0x0a140000), SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), + SPH_C32(0x456d6d1f), SPH_C32(0x3daac2da), SPH_C32(0x145a3c00), + SPH_C32(0xb9e90000), SPH_C32(0x61270000), SPH_C32(0xf1610000), + SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), SPH_C32(0x47a96720), + SPH_C32(0xe18e24c5) }, + { SPH_C32(0x54285c00), SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), + SPH_C32(0xa1c50000), SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), + SPH_C32(0x6bb0419d), SPH_C32(0x551b3782), SPH_C32(0x9cbb1800), + SPH_C32(0xb0d30000), SPH_C32(0x92510000), SPH_C32(0xed930000), + SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), SPH_C32(0x430633da), + SPH_C32(0x78cace29) }, + { SPH_C32(0x40726000), SPH_C32(0x53040000), SPH_C32(0xa4f10000), + SPH_C32(0x50a40000), SPH_C32(0x7dc35a1c), SPH_C32(0x24ecf999), + SPH_C32(0x2c1926bd), SPH_C32(0xb4951347), SPH_C32(0xbfdc0c00), + SPH_C32(0x786a0000), SPH_C32(0x66960000), SPH_C32(0x16e60000), + SPH_C32(0x2af76720), SPH_C32(0x19b270bd), SPH_C32(0x41c239e5), + SPH_C32(0xa4ee2836) }, + { SPH_C32(0x774f4800), SPH_C32(0x22540000), SPH_C32(0x31110000), + SPH_C32(0x5ab00000), SPH_C32(0xc06f4315), SPH_C32(0x6c0361a8), + SPH_C32(0x69744ba2), SPH_C32(0x893fd19d), SPH_C32(0xab863000), + SPH_C32(0xc1830000), SPH_C32(0x07b10000), SPH_C32(0xe7870000), + SPH_C32(0xe4965a4c), SPH_C32(0xa9fb4dc5), SPH_C32(0x066b5ec5), + SPH_C32(0x45600cf3) }, + { SPH_C32(0x63157400), SPH_C32(0x9bbd0000), SPH_C32(0x50360000), + SPH_C32(0xabd10000), SPH_C32(0x0e0e7e79), SPH_C32(0xdc4a5cd0), + SPH_C32(0x2edd2c82), SPH_C32(0x68b1f558), SPH_C32(0x88e12400), + SPH_C32(0x093a0000), SPH_C32(0xf3760000), SPH_C32(0x1cf20000), + SPH_C32(0x975b7e29), SPH_C32(0x515de88c), SPH_C32(0x04af54fa), + SPH_C32(0x9944eaec) } +}; + +static const sph_u32 T512_6[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xb4370060), SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), + SPH_C32(0x5cae0000), SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), + SPH_C32(0x1b365f3d), SPH_C32(0xf3d45758), SPH_C32(0x5cb00110), + SPH_C32(0x913e0000), SPH_C32(0x44190000), SPH_C32(0x888c0000), + SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), SPH_C32(0x55ceea25), + SPH_C32(0x925c44e9) }, + { SPH_C32(0xef0b0270), SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), + SPH_C32(0x69490000), SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), + SPH_C32(0x66140a51), SPH_C32(0x924f5d0a), SPH_C32(0xc96b0030), + SPH_C32(0xe7250000), SPH_C32(0x2f840000), SPH_C32(0x264f0000), + SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), SPH_C32(0x509f6984), + SPH_C32(0x9e69af68) }, + { SPH_C32(0x5b3c0210), SPH_C32(0x36b10000), SPH_C32(0x0b6c0000), + SPH_C32(0x35e70000), SPH_C32(0x0f5b2339), SPH_C32(0x7f3b4ddc), + SPH_C32(0x7d22556c), SPH_C32(0x619b0a52), SPH_C32(0x95db0120), + SPH_C32(0x761b0000), SPH_C32(0x6b9d0000), SPH_C32(0xaec30000), + SPH_C32(0x6eb52fe1), SPH_C32(0xffe3ec51), SPH_C32(0x055183a1), + SPH_C32(0x0c35eb81) }, + { SPH_C32(0xc96b0030), SPH_C32(0xe7250000), SPH_C32(0x2f840000), + SPH_C32(0x264f0000), SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), + SPH_C32(0x509f6984), SPH_C32(0x9e69af68), SPH_C32(0x26600240), + SPH_C32(0xddd80000), SPH_C32(0x722a0000), SPH_C32(0x4f060000), + SPH_C32(0x936667ff), SPH_C32(0x29f944ce), SPH_C32(0x368b63d5), + SPH_C32(0x0c26f262) }, + { SPH_C32(0x7d5c0050), SPH_C32(0xeb690000), SPH_C32(0x79460000), + SPH_C32(0x7ae10000), SPH_C32(0x9c3d44c6), SPH_C32(0x56c20912), + SPH_C32(0x4ba936b9), SPH_C32(0x6dbdf830), SPH_C32(0x7ad00350), + SPH_C32(0x4ce60000), SPH_C32(0x36330000), SPH_C32(0xc78a0000), + SPH_C32(0xf5ba13e7), SPH_C32(0xbbe659a8), SPH_C32(0x634589f0), + SPH_C32(0x9e7ab68b) }, + { SPH_C32(0x26600240), SPH_C32(0xddd80000), SPH_C32(0x722a0000), + SPH_C32(0x4f060000), SPH_C32(0x936667ff), SPH_C32(0x29f944ce), + SPH_C32(0x368b63d5), SPH_C32(0x0c26f262), SPH_C32(0xef0b0270), + SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), SPH_C32(0x69490000), + SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), SPH_C32(0x66140a51), + SPH_C32(0x924f5d0a) }, + { SPH_C32(0x92570220), SPH_C32(0xd1940000), SPH_C32(0x24e80000), + SPH_C32(0x13a80000), SPH_C32(0x073278c0), SPH_C32(0x12c7bceb), + SPH_C32(0x2dbd3ce8), SPH_C32(0xfff2a53a), SPH_C32(0xb3bb0360), + SPH_C32(0xabc30000), SPH_C32(0x19b70000), SPH_C32(0xe1c50000), + SPH_C32(0xfdd3481e), SPH_C32(0xd61aa89f), SPH_C32(0x33dae074), + SPH_C32(0x001319e3) } +}; + +static const sph_u32 T512_9[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x774400f0), SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), + SPH_C32(0x34140000), SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), + SPH_C32(0x0bc3cd1e), SPH_C32(0xcf3775cb), SPH_C32(0xf46c0050), + SPH_C32(0x96180000), SPH_C32(0x14a50000), SPH_C32(0x031f0000), + SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), SPH_C32(0x9ca470d2), + SPH_C32(0x8a341574) }, + { SPH_C32(0xf46c0050), SPH_C32(0x96180000), SPH_C32(0x14a50000), + SPH_C32(0x031f0000), SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), + SPH_C32(0x9ca470d2), SPH_C32(0x8a341574), SPH_C32(0x832800a0), + SPH_C32(0x67420000), SPH_C32(0xe1170000), SPH_C32(0x370b0000), + SPH_C32(0xcba30034), SPH_C32(0x3c34923c), SPH_C32(0x9767bdcc), + SPH_C32(0x450360bf) }, + { SPH_C32(0x832800a0), SPH_C32(0x67420000), SPH_C32(0xe1170000), + SPH_C32(0x370b0000), SPH_C32(0xcba30034), SPH_C32(0x3c34923c), + SPH_C32(0x9767bdcc), SPH_C32(0x450360bf), SPH_C32(0x774400f0), + SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), SPH_C32(0x34140000), + SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), SPH_C32(0x0bc3cd1e), + SPH_C32(0xcf3775cb) }, + { SPH_C32(0xe8870170), SPH_C32(0x9d720000), SPH_C32(0x12db0000), + SPH_C32(0xd4220000), SPH_C32(0xf2886b27), SPH_C32(0xa921e543), + SPH_C32(0x4ef8b518), SPH_C32(0x618813b1), SPH_C32(0xb4370060), + SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), SPH_C32(0x5cae0000), + SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), SPH_C32(0x1b365f3d), + SPH_C32(0xf3d45758) }, + { SPH_C32(0x9fc30180), SPH_C32(0x6c280000), SPH_C32(0xe7690000), + SPH_C32(0xe0360000), SPH_C32(0x7bbf15ab), SPH_C32(0xf3aa0966), + SPH_C32(0x453b7806), SPH_C32(0xaebf667a), SPH_C32(0x405b0030), + SPH_C32(0x9a540000), SPH_C32(0x42670000), SPH_C32(0x5fb10000), + SPH_C32(0xd6c06187), SPH_C32(0x5d81863c), SPH_C32(0x87922fef), + SPH_C32(0x79e0422c) }, + { SPH_C32(0x1ceb0120), SPH_C32(0x0b6a0000), SPH_C32(0x067e0000), + SPH_C32(0xd73d0000), SPH_C32(0xb01c159f), SPH_C32(0xcf9e9b5a), + SPH_C32(0xd25cc5ca), SPH_C32(0xebbc06c5), SPH_C32(0x371f00c0), + SPH_C32(0x6b0e0000), SPH_C32(0xb7d50000), SPH_C32(0x6ba50000), + SPH_C32(0x5ff71f0b), SPH_C32(0x070a6a19), SPH_C32(0x8c51e2f1), + SPH_C32(0xb6d737e7) }, + { SPH_C32(0x6baf01d0), SPH_C32(0xfa300000), SPH_C32(0xf3cc0000), + SPH_C32(0xe3290000), SPH_C32(0x392b6b13), SPH_C32(0x9515777f), + SPH_C32(0xd99f08d4), SPH_C32(0x248b730e), SPH_C32(0xc3730090), + SPH_C32(0xfd160000), SPH_C32(0xa3700000), SPH_C32(0x68ba0000), + SPH_C32(0x1d6361b3), SPH_C32(0x61b51400), SPH_C32(0x10f59223), + SPH_C32(0x3ce32293) } +}; + +static const sph_u32 T512_12[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xa67f0001), SPH_C32(0x71378000), SPH_C32(0x19fc0000), + SPH_C32(0x96db0000), SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), + SPH_C32(0x2c6d478f), SPH_C32(0xac8e6c88), SPH_C32(0x50ff0004), + SPH_C32(0x45744000), SPH_C32(0x3dfb0000), SPH_C32(0x19e60000), + SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), SPH_C32(0xe1a8cc96), + SPH_C32(0x7b1bd6b9) }, + { SPH_C32(0xf7750009), SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), + SPH_C32(0x04920000), SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), + SPH_C32(0x7a87f14e), SPH_C32(0x9e16981a), SPH_C32(0xd46a0000), + SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), SPH_C32(0x4a290000), + SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), SPH_C32(0x98369604), + SPH_C32(0xf746c320) }, + { SPH_C32(0x510a0008), SPH_C32(0xbe0b4000), SPH_C32(0xda2a0000), + SPH_C32(0x92490000), SPH_C32(0x381e7454), SPH_C32(0x13229849), + SPH_C32(0x56eab6c1), SPH_C32(0x3298f492), SPH_C32(0x84950004), + SPH_C32(0xc8bc8000), SPH_C32(0x98540000), SPH_C32(0x53cf0000), + SPH_C32(0xe7f2147c), SPH_C32(0x28c6fd31), SPH_C32(0x799e5a92), + SPH_C32(0x8c5d1599) }, + { SPH_C32(0xd46a0000), SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), + SPH_C32(0x4a290000), SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), + SPH_C32(0x98369604), SPH_C32(0xf746c320), SPH_C32(0x231f0009), + SPH_C32(0x42f40000), SPH_C32(0x66790000), SPH_C32(0x4ebb0000), + SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), SPH_C32(0xe2b1674a), + SPH_C32(0x69505b3a) }, + { SPH_C32(0x72150001), SPH_C32(0xfcff4000), SPH_C32(0xbc530000), + SPH_C32(0xdcf20000), SPH_C32(0xc6c52f87), SPH_C32(0x227e289f), + SPH_C32(0xb45bd18b), SPH_C32(0x5bc8afa8), SPH_C32(0x73e0000d), + SPH_C32(0x07804000), SPH_C32(0x5b820000), SPH_C32(0x575d0000), + SPH_C32(0xe5670dd5), SPH_C32(0xd02ecb8b), SPH_C32(0x0319abdc), + SPH_C32(0x124b8d83) }, + { SPH_C32(0x231f0009), SPH_C32(0x42f40000), SPH_C32(0x66790000), + SPH_C32(0x4ebb0000), SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), + SPH_C32(0xe2b1674a), SPH_C32(0x69505b3a), SPH_C32(0xf7750009), + SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), SPH_C32(0x04920000), + SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), SPH_C32(0x7a87f14e), + SPH_C32(0x9e16981a) }, + { SPH_C32(0x85600008), SPH_C32(0x33c38000), SPH_C32(0x7f850000), + SPH_C32(0xd8600000), SPH_C32(0xc450362e), SPH_C32(0xda961e25), + SPH_C32(0xcedc20c5), SPH_C32(0xc5de37b2), SPH_C32(0xa78a000d), + SPH_C32(0x8a488000), SPH_C32(0xfe2d0000), SPH_C32(0x1d740000), + SPH_C32(0x19294faf), SPH_C32(0x199a4de7), SPH_C32(0x9b2f3dd8), + SPH_C32(0xe50d4ea3) } +}; + +static const sph_u32 T512_15[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x75c90003), SPH_C32(0x0e10c000), SPH_C32(0xd1200000), + SPH_C32(0xbaea0000), SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), + SPH_C32(0xbb28761d), SPH_C32(0x00b72e2b), SPH_C32(0xeecf0001), + SPH_C32(0x6f564000), SPH_C32(0xf33e0000), SPH_C32(0xa79e0000), + SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), SPH_C32(0x4a3b40ba), + SPH_C32(0xfeabf254) }, + { SPH_C32(0xeecf0001), SPH_C32(0x6f564000), SPH_C32(0xf33e0000), + SPH_C32(0xa79e0000), SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), + SPH_C32(0x4a3b40ba), SPH_C32(0xfeabf254), SPH_C32(0x9b060002), + SPH_C32(0x61468000), SPH_C32(0x221e0000), SPH_C32(0x1d740000), + SPH_C32(0x36715d27), SPH_C32(0x30495c92), SPH_C32(0xf11336a7), + SPH_C32(0xfe1cdc7f) }, + { SPH_C32(0x9b060002), SPH_C32(0x61468000), SPH_C32(0x221e0000), + SPH_C32(0x1d740000), SPH_C32(0x36715d27), SPH_C32(0x30495c92), + SPH_C32(0xf11336a7), SPH_C32(0xfe1cdc7f), SPH_C32(0x75c90003), + SPH_C32(0x0e10c000), SPH_C32(0xd1200000), SPH_C32(0xbaea0000), + SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), SPH_C32(0xbb28761d), + SPH_C32(0x00b72e2b) }, + { SPH_C32(0xf6800005), SPH_C32(0x3443c000), SPH_C32(0x24070000), + SPH_C32(0x8f3d0000), SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), + SPH_C32(0xcdc58b19), SPH_C32(0xd795ba31), SPH_C32(0xa67f0001), + SPH_C32(0x71378000), SPH_C32(0x19fc0000), SPH_C32(0x96db0000), + SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), SPH_C32(0x2c6d478f), + SPH_C32(0xac8e6c88) }, + { SPH_C32(0x83490006), SPH_C32(0x3a530000), SPH_C32(0xf5270000), + SPH_C32(0x35d70000), SPH_C32(0xaaf314c5), SPH_C32(0x8de062f9), + SPH_C32(0x76edfd04), SPH_C32(0xd722941a), SPH_C32(0x48b00000), + SPH_C32(0x1e61c000), SPH_C32(0xeac20000), SPH_C32(0x31450000), + SPH_C32(0x873e1fe4), SPH_C32(0x5cdb4536), SPH_C32(0x66560735), + SPH_C32(0x52259edc) }, + { SPH_C32(0x184f0004), SPH_C32(0x5b158000), SPH_C32(0xd7390000), + SPH_C32(0x28a30000), SPH_C32(0x9c8249e2), SPH_C32(0xbda93e6b), + SPH_C32(0x87fecba3), SPH_C32(0x293e4865), SPH_C32(0x3d790003), + SPH_C32(0x10710000), SPH_C32(0x3be20000), SPH_C32(0x8baf0000), + SPH_C32(0x0cfa30da), SPH_C32(0xdb83f261), SPH_C32(0xdd7e7128), + SPH_C32(0x5292b0f7) }, + { SPH_C32(0x6d860007), SPH_C32(0x55054000), SPH_C32(0x06190000), + SPH_C32(0x92490000), SPH_C32(0x174666dc), SPH_C32(0x3af1893c), + SPH_C32(0x3cd6bdbe), SPH_C32(0x2989664e), SPH_C32(0xd3b60002), + SPH_C32(0x7f274000), SPH_C32(0xc8dc0000), SPH_C32(0x2c310000), + SPH_C32(0xb14f42c3), SPH_C32(0x6c9219a4), SPH_C32(0x97453192), + SPH_C32(0xac3942a3) } +}; + +static const sph_u32 T512_18[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xb83d0000), SPH_C32(0x16710600), SPH_C32(0x379a0000), + SPH_C32(0xf5b10000), SPH_C32(0x228161ac), SPH_C32(0xae48f145), + SPH_C32(0x66241616), SPH_C32(0xc5c1eb3e), SPH_C32(0xfd250000), + SPH_C32(0xb3c41100), SPH_C32(0xcef00000), SPH_C32(0xcef90000), + SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), SPH_C32(0x7098b0a6), + SPH_C32(0x1af21fe1) }, + { SPH_C32(0x75a40000), SPH_C32(0xc28b2700), SPH_C32(0x94a40000), + SPH_C32(0x90f50000), SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), + SPH_C32(0x1767c483), SPH_C32(0xaedf667e), SPH_C32(0xd1660000), + SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), SPH_C32(0xf6940000), + SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), SPH_C32(0xb4431b17), + SPH_C32(0x857f3c2b) }, + { SPH_C32(0xcd990000), SPH_C32(0xd4fa2100), SPH_C32(0xa33e0000), + SPH_C32(0x65440000), SPH_C32(0xd9f9364c), SPH_C32(0xe786faeb), + SPH_C32(0x7143d295), SPH_C32(0x6b1e8d40), SPH_C32(0x2c430000), + SPH_C32(0xa8781200), SPH_C32(0x501c0000), SPH_C32(0x386d0000), + SPH_C32(0x3f4f30a7), SPH_C32(0x422b9861), SPH_C32(0xc4dbabb1), + SPH_C32(0x9f8d23ca) }, + { SPH_C32(0xd1660000), SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), + SPH_C32(0xf6940000), SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), + SPH_C32(0xb4431b17), SPH_C32(0x857f3c2b), SPH_C32(0xa4c20000), + SPH_C32(0xd9372400), SPH_C32(0x0a480000), SPH_C32(0x66610000), + SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), SPH_C32(0xa324df94), + SPH_C32(0x2ba05a55) }, + { SPH_C32(0x695b0000), SPH_C32(0x0dcd0500), SPH_C32(0xa9760000), + SPH_C32(0x03250000), SPH_C32(0x2183248b), SPH_C32(0x61380db7), + SPH_C32(0xd2670d01), SPH_C32(0x40bed715), SPH_C32(0x59e70000), + SPH_C32(0x6af33500), SPH_C32(0xc4b80000), SPH_C32(0xa8980000), + SPH_C32(0xc4376747), SPH_C32(0x0be593cf), SPH_C32(0xd3bc6f32), + SPH_C32(0x315245b4) }, + { SPH_C32(0xa4c20000), SPH_C32(0xd9372400), SPH_C32(0x0a480000), + SPH_C32(0x66610000), SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), + SPH_C32(0xa324df94), SPH_C32(0x2ba05a55), SPH_C32(0x75a40000), + SPH_C32(0xc28b2700), SPH_C32(0x94a40000), SPH_C32(0x90f50000), + SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), SPH_C32(0x1767c483), + SPH_C32(0xaedf667e) }, + { SPH_C32(0x1cff0000), SPH_C32(0xcf462200), SPH_C32(0x3dd20000), + SPH_C32(0x93d00000), SPH_C32(0xdafb736b), SPH_C32(0x28f60619), + SPH_C32(0xc500c982), SPH_C32(0xee61b16b), SPH_C32(0x88810000), + SPH_C32(0x714f3600), SPH_C32(0x5a540000), SPH_C32(0x5e0c0000), + SPH_C32(0xc7352260), SPH_C32(0xc4956f3d), SPH_C32(0x67ff7425), + SPH_C32(0xb42d799f) } +}; + +static const sph_u32 T512_21[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x0c720000), SPH_C32(0x49e50f00), SPH_C32(0x42790000), + SPH_C32(0x5cea0000), SPH_C32(0x33aa301a), SPH_C32(0x15822514), + SPH_C32(0x95a34b7b), SPH_C32(0xb44b0090), SPH_C32(0xfe220000), + SPH_C32(0xa7580500), SPH_C32(0x25d10000), SPH_C32(0xf7600000), + SPH_C32(0x893178da), SPH_C32(0x1fd4f860), SPH_C32(0x4ed0a315), + SPH_C32(0xa123ff9f) }, + { SPH_C32(0xfe220000), SPH_C32(0xa7580500), SPH_C32(0x25d10000), + SPH_C32(0xf7600000), SPH_C32(0x893178da), SPH_C32(0x1fd4f860), + SPH_C32(0x4ed0a315), SPH_C32(0xa123ff9f), SPH_C32(0xf2500000), + SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), SPH_C32(0xab8a0000), + SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), SPH_C32(0xdb73e86e), + SPH_C32(0x1568ff0f) }, + { SPH_C32(0xf2500000), SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), + SPH_C32(0xab8a0000), SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), + SPH_C32(0xdb73e86e), SPH_C32(0x1568ff0f), SPH_C32(0x0c720000), + SPH_C32(0x49e50f00), SPH_C32(0x42790000), SPH_C32(0x5cea0000), + SPH_C32(0x33aa301a), SPH_C32(0x15822514), SPH_C32(0x95a34b7b), + SPH_C32(0xb44b0090) }, + { SPH_C32(0x45180000), SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), + SPH_C32(0x3b480000), SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), + SPH_C32(0x16bca6b0), SPH_C32(0xdf33f4df), SPH_C32(0xb83d0000), + SPH_C32(0x16710600), SPH_C32(0x379a0000), SPH_C32(0xf5b10000), + SPH_C32(0x228161ac), SPH_C32(0xae48f145), SPH_C32(0x66241616), + SPH_C32(0xc5c1eb3e) }, + { SPH_C32(0x496a0000), SPH_C32(0xec501800), SPH_C32(0xbb130000), + SPH_C32(0x67a20000), SPH_C32(0x2d662436), SPH_C32(0x3691b0c2), + SPH_C32(0x831fedcb), SPH_C32(0x6b78f44f), SPH_C32(0x461f0000), + SPH_C32(0xb1290300), SPH_C32(0x124b0000), SPH_C32(0x02d10000), + SPH_C32(0xabb01976), SPH_C32(0xb19c0925), SPH_C32(0x28f4b503), + SPH_C32(0x64e214a1) }, + { SPH_C32(0xbb3a0000), SPH_C32(0x02ed1200), SPH_C32(0xdcbb0000), + SPH_C32(0xcc280000), SPH_C32(0x97fd6cf6), SPH_C32(0x3cc76db6), + SPH_C32(0x586c05a5), SPH_C32(0x7e100b40), SPH_C32(0x4a6d0000), + SPH_C32(0xf8cc0c00), SPH_C32(0x50320000), SPH_C32(0x5e3b0000), + SPH_C32(0x981a296c), SPH_C32(0xa41e2c31), SPH_C32(0xbd57fe78), + SPH_C32(0xd0a91431) }, + { SPH_C32(0xb7480000), SPH_C32(0x4b081d00), SPH_C32(0x9ec20000), + SPH_C32(0x90c20000), SPH_C32(0xa4575cec), SPH_C32(0x294548a2), + SPH_C32(0xcdcf4ede), SPH_C32(0xca5b0bd0), SPH_C32(0xb44f0000), + SPH_C32(0x5f940900), SPH_C32(0x75e30000), SPH_C32(0xa95b0000), + SPH_C32(0x112b51b6), SPH_C32(0xbbcad451), SPH_C32(0xf3875d6d), + SPH_C32(0x718aebae) } +}; + +static const sph_u32 T512_24[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xbc8d0000), SPH_C32(0xfc3b0018), SPH_C32(0x19830000), + SPH_C32(0xd10b0000), SPH_C32(0xae1878c4), SPH_C32(0x42a69856), + SPH_C32(0x0012da37), SPH_C32(0x2c3b504e), SPH_C32(0xe8dd0000), + SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), SPH_C32(0xbb150000), + SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), SPH_C32(0xbfa8c2f4), + SPH_C32(0x524a0d59) }, + { SPH_C32(0x69510000), SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), + SPH_C32(0xac2f0000), SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), + SPH_C32(0x87ec287c), SPH_C32(0xbce1a3ce), SPH_C32(0xc6730000), + SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), SPH_C32(0x218d0000), + SPH_C32(0x23111587), SPH_C32(0x7913512f), SPH_C32(0x1d28ac88), + SPH_C32(0x378dd173) }, + { SPH_C32(0xd5dc0000), SPH_C32(0x28da0084), SPH_C32(0xdaa00000), + SPH_C32(0x7d240000), SPH_C32(0x4a8d736a), SPH_C32(0x8c028d8a), + SPH_C32(0x87fef24b), SPH_C32(0x90daf380), SPH_C32(0x2eae0000), + SPH_C32(0x55c70048), SPH_C32(0x98ec0000), SPH_C32(0x9a980000), + SPH_C32(0xa3ac239c), SPH_C32(0x5dfb4c6b), SPH_C32(0xa2806e7c), + SPH_C32(0x65c7dc2a) }, + { SPH_C32(0xc6730000), SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), + SPH_C32(0x218d0000), SPH_C32(0x23111587), SPH_C32(0x7913512f), + SPH_C32(0x1d28ac88), SPH_C32(0x378dd173), SPH_C32(0xaf220000), + SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), SPH_C32(0x8da20000), + SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), SPH_C32(0x9ac484f4), + SPH_C32(0x8b6c72bd) }, + { SPH_C32(0x7afe0000), SPH_C32(0x53b60014), SPH_C32(0xbd420000), + SPH_C32(0xf0860000), SPH_C32(0x8d096d43), SPH_C32(0x3bb5c979), + SPH_C32(0x1d3a76bf), SPH_C32(0x1bb6813d), SPH_C32(0x47ff0000), + SPH_C32(0x812600d4), SPH_C32(0x5bcf0000), SPH_C32(0x36b70000), + SPH_C32(0x47392832), SPH_C32(0x935f59b7), SPH_C32(0x256c4600), + SPH_C32(0xd9267fe4) }, + { SPH_C32(0xaf220000), SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), + SPH_C32(0x8da20000), SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), + SPH_C32(0x9ac484f4), SPH_C32(0x8b6c72bd), SPH_C32(0x69510000), + SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), SPH_C32(0xac2f0000), + SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), SPH_C32(0x87ec287c), + SPH_C32(0xbce1a3ce) }, + { SPH_C32(0x13af0000), SPH_C32(0x87570088), SPH_C32(0x7e610000), + SPH_C32(0x5ca90000), SPH_C32(0x699c66ed), SPH_C32(0xf511dca5), + SPH_C32(0x9ad65ec3), SPH_C32(0xa75722f3), SPH_C32(0x818c0000), + SPH_C32(0x2eab00d8), SPH_C32(0xff0e0000), SPH_C32(0x173a0000), + SPH_C32(0x64283db5), SPH_C32(0xea4c0898), SPH_C32(0x3844ea88), + SPH_C32(0xeeabae97) } +}; + +static const sph_u32 T512_27[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x14190000), SPH_C32(0x23ca003c), SPH_C32(0x50df0000), + SPH_C32(0x44b60000), SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), + SPH_C32(0x61e610b0), SPH_C32(0xdbcadb80), SPH_C32(0xe3430000), + SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), SPH_C32(0xaa4e0000), + SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), SPH_C32(0x123db156), + SPH_C32(0x3a4e99d7) }, + { SPH_C32(0xe3430000), SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), + SPH_C32(0xaa4e0000), SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), + SPH_C32(0x123db156), SPH_C32(0x3a4e99d7), SPH_C32(0xf75a0000), + SPH_C32(0x19840028), SPH_C32(0xa2190000), SPH_C32(0xeef80000), + SPH_C32(0xc0722516), SPH_C32(0x19981260), SPH_C32(0x73dba1e6), + SPH_C32(0xe1844257) }, + { SPH_C32(0xf75a0000), SPH_C32(0x19840028), SPH_C32(0xa2190000), + SPH_C32(0xeef80000), SPH_C32(0xc0722516), SPH_C32(0x19981260), + SPH_C32(0x73dba1e6), SPH_C32(0xe1844257), SPH_C32(0x14190000), + SPH_C32(0x23ca003c), SPH_C32(0x50df0000), SPH_C32(0x44b60000), + SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), SPH_C32(0x61e610b0), + SPH_C32(0xdbcadb80) }, + { SPH_C32(0x54500000), SPH_C32(0x0671005c), SPH_C32(0x25ae0000), + SPH_C32(0x6a1e0000), SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), + SPH_C32(0xbfba18c3), SPH_C32(0x7e715d17), SPH_C32(0xbc8d0000), + SPH_C32(0xfc3b0018), SPH_C32(0x19830000), SPH_C32(0xd10b0000), + SPH_C32(0xae1878c4), SPH_C32(0x42a69856), SPH_C32(0x0012da37), + SPH_C32(0x2c3b504e) }, + { SPH_C32(0x40490000), SPH_C32(0x25bb0060), SPH_C32(0x75710000), + SPH_C32(0x2ea80000), SPH_C32(0x35c9296f), SPH_C32(0x5abd2967), + SPH_C32(0xde5c0873), SPH_C32(0xa5bb49697), SPH_C32(0x5fce0000), + SPH_C32(0xc675000c), SPH_C32(0xeb450000), SPH_C32(0x7b450000), + SPH_C32(0x75063a62), SPH_C32(0x67cd2643), SPH_C32(0x122f6b61), + SPH_C32(0x1675c999) }, + { SPH_C32(0xb7130000), SPH_C32(0x3c3f0048), SPH_C32(0xd7680000), + SPH_C32(0xc0500000), SPH_C32(0xf5bb0c79), SPH_C32(0x43253b07), + SPH_C32(0xad87a995), SPH_C32(0x443fc4c0), SPH_C32(0x4bd70000), + SPH_C32(0xe5bf0030), SPH_C32(0xbb9a0000), SPH_C32(0x3ff30000), + SPH_C32(0x6e6a5dd2), SPH_C32(0x5b3e8a36), SPH_C32(0x73c97bd1), + SPH_C32(0xcdbf1219) }, + { SPH_C32(0xa30a0000), SPH_C32(0x1ff50074), SPH_C32(0x87b70000), + SPH_C32(0x84e60000), SPH_C32(0xeed76bc9), SPH_C32(0x7fd69772), + SPH_C32(0xcc61b925), SPH_C32(0x9ff51f40), SPH_C32(0xa8940000), + SPH_C32(0xdff10024), SPH_C32(0x495c0000), SPH_C32(0x95bd0000), + SPH_C32(0xb5741f74), SPH_C32(0x7e553423), SPH_C32(0x61f4ca87), + SPH_C32(0xf7f18bce) } +}; + +static const sph_u32 T512_30[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xdb250000), SPH_C32(0x09290000), SPH_C32(0x49aac000), + SPH_C32(0x81e10000), SPH_C32(0xcafe6b59), SPH_C32(0x42793431), + SPH_C32(0x43566b76), SPH_C32(0xe86cba2e), SPH_C32(0x75e60000), + SPH_C32(0x95660001), SPH_C32(0x307b2000), SPH_C32(0xadf40000), + SPH_C32(0x8f321eea), SPH_C32(0x24298307), SPH_C32(0xe8c49cf9), + SPH_C32(0x4b7eec55) }, + { SPH_C32(0x86790000), SPH_C32(0x3f390002), SPH_C32(0xe19ae000), + SPH_C32(0x98560000), SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), + SPH_C32(0xd3dd4944), SPH_C32(0x161ddab9), SPH_C32(0x30b70000), + SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), SPH_C32(0x42c40000), + SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), SPH_C32(0x21afa1ea), + SPH_C32(0xb0a51834) }, + { SPH_C32(0x5d5c0000), SPH_C32(0x36100002), SPH_C32(0xa8302000), + SPH_C32(0x19b70000), SPH_C32(0x5f9b0c57), SPH_C32(0x0cf1fcdb), + SPH_C32(0x908b2232), SPH_C32(0xfe716097), SPH_C32(0x45510000), + SPH_C32(0x70b60001), SPH_C32(0xc48f4000), SPH_C32(0xef300000), + SPH_C32(0xec8a2380), SPH_C32(0x5c931767), SPH_C32(0xc96b3d13), + SPH_C32(0xfbdbf461) }, + { SPH_C32(0x30b70000), SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), + SPH_C32(0x42c40000), SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), + SPH_C32(0x21afa1ea), SPH_C32(0xb0a51834), SPH_C32(0xb6ce0000), + SPH_C32(0xdae90002), SPH_C32(0x156e8000), SPH_C32(0xda920000), + SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), SPH_C32(0xf272e8ae), + SPH_C32(0xa6b8c28d) }, + { SPH_C32(0xeb920000), SPH_C32(0xecf90000), SPH_C32(0xbd5ea000), + SPH_C32(0xc3250000), SPH_C32(0xa9465633), SPH_C32(0x3ac3a051), + SPH_C32(0x62f9ca9c), SPH_C32(0x58c9a21a), SPH_C32(0xc3280000), + SPH_C32(0x4f8f0003), SPH_C32(0x2515a000), SPH_C32(0x77660000), + SPH_C32(0x79ef448e), SPH_C32(0x121bdf8d), SPH_C32(0x1ab67457), + SPH_C32(0xedc62ed8) }, + { SPH_C32(0xb6ce0000), SPH_C32(0xdae90002), SPH_C32(0x156e8000), + SPH_C32(0xda920000), SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), + SPH_C32(0xf272e8ae), SPH_C32(0xa6b8c28d), SPH_C32(0x86790000), + SPH_C32(0x3f390002), SPH_C32(0xe19ae000), SPH_C32(0x98560000), + SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), SPH_C32(0xd3dd4944), + SPH_C32(0x161ddab9) }, + { SPH_C32(0x6deb0000), SPH_C32(0xd3c00002), SPH_C32(0x5cc44000), + SPH_C32(0x5b730000), SPH_C32(0x3c23313d), SPH_C32(0x744b68bb), + SPH_C32(0xb12483d8), SPH_C32(0x4ed478a3), SPH_C32(0xf39f0000), + SPH_C32(0xaa5f0003), SPH_C32(0xd1e1c000), SPH_C32(0x35a20000), + SPH_C32(0x1a5779e4), SPH_C32(0x6aa14bed), SPH_C32(0x3b19d5bd), + SPH_C32(0x5d6336ec) } +}; + +static const sph_u32 T512_33[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xac480000), SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), + SPH_C32(0x03430000), SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), + SPH_C32(0xfe72c7fe), SPH_C32(0x91e478f6), SPH_C32(0x1e4e0000), + SPH_C32(0xdecf0000), SPH_C32(0x6df80180), SPH_C32(0x77240000), + SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), SPH_C32(0xcda31812), + SPH_C32(0x98aa496e) }, + { SPH_C32(0x1e4e0000), SPH_C32(0xdecf0000), SPH_C32(0x6df80180), + SPH_C32(0x77240000), SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), + SPH_C32(0xcda31812), SPH_C32(0x98aa496e), SPH_C32(0xb2060000), + SPH_C32(0xc5690000), SPH_C32(0x28031200), SPH_C32(0x74670000), + SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), SPH_C32(0x33d1dfec), + SPH_C32(0x094e3198) }, + { SPH_C32(0xb2060000), SPH_C32(0xc5690000), SPH_C32(0x28031200), + SPH_C32(0x74670000), SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), + SPH_C32(0x33d1dfec), SPH_C32(0x094e3198), SPH_C32(0xac480000), + SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), SPH_C32(0x03430000), + SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), SPH_C32(0xfe72c7fe), + SPH_C32(0x91e478f6) }, + { SPH_C32(0xaec30000), SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), + SPH_C32(0x2c150000), SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), + SPH_C32(0xab92f78f), SPH_C32(0xa312567b), SPH_C32(0xdb250000), + SPH_C32(0x09290000), SPH_C32(0x49aac000), SPH_C32(0x81e10000), + SPH_C32(0xcafe6b59), SPH_C32(0x42793431), SPH_C32(0x43566b76), + SPH_C32(0xe86cba2e) }, + { SPH_C32(0x028b0000), SPH_C32(0x87e90001), SPH_C32(0x3c2af380), + SPH_C32(0x2f560000), SPH_C32(0x1f4944d9), SPH_C32(0x79e2e780), + SPH_C32(0x55e03071), SPH_C32(0x32f62e8d), SPH_C32(0xc56b0000), + SPH_C32(0xd7e60000), SPH_C32(0x2452c180), SPH_C32(0xf6c50000), + SPH_C32(0x26b96cc7), SPH_C32(0xb6d95d7f), SPH_C32(0x8ef57364), + SPH_C32(0x70c6f340) }, + { SPH_C32(0xb08d0000), SPH_C32(0x42800001), SPH_C32(0x1429e180), + SPH_C32(0x5b310000), SPH_C32(0xa98b722d), SPH_C32(0x92f0de78), + SPH_C32(0x6631ef9d), SPH_C32(0x3bb81f15), SPH_C32(0x69230000), + SPH_C32(0xcc400000), SPH_C32(0x61a9d200), SPH_C32(0xf5860000), + SPH_C32(0x7c3c5dad), SPH_C32(0xa96b0dc9), SPH_C32(0x7087b49a), + SPH_C32(0xe1228bb6) }, + { SPH_C32(0x1cc50000), SPH_C32(0x59260001), SPH_C32(0x51d2f200), + SPH_C32(0x58720000), SPH_C32(0xf30e4347), SPH_C32(0x8d428ece), + SPH_C32(0x98432863), SPH_C32(0xaa5c67e3), SPH_C32(0x776d0000), + SPH_C32(0x128f0000), SPH_C32(0x0c51d380), SPH_C32(0x82a20000), + SPH_C32(0x907b5a33), SPH_C32(0x5dcb6487), SPH_C32(0xbd24ac88), + SPH_C32(0x7988c2d8) } +}; + +static const sph_u32 T512_36[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x819e0000), SPH_C32(0xec570000), SPH_C32(0x66320280), + SPH_C32(0x95f30000), SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), + SPH_C32(0xe65aa22d), SPH_C32(0x8e67b7fa), SPH_C32(0x4d8a0000), + SPH_C32(0x49340000), SPH_C32(0x3c8b0500), SPH_C32(0xaea30000), + SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), SPH_C32(0x8f19eaec), + SPH_C32(0x443d3004) }, + { SPH_C32(0x78230000), SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), + SPH_C32(0x90a50000), SPH_C32(0x713e2879), SPH_C32(0x7ee98924), + SPH_C32(0xf08ca062), SPH_C32(0x636f8bab), SPH_C32(0x02af0000), + SPH_C32(0xb7280000), SPH_C32(0xba1c0300), SPH_C32(0x56980000), + SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), SPH_C32(0xa95c149a), + SPH_C32(0xf4f6ea7b) }, + { SPH_C32(0xf9bd0000), SPH_C32(0xfeab0000), SPH_C32(0xcf080900), + SPH_C32(0x05560000), SPH_C32(0x2c97007b), SPH_C32(0x361db598), + SPH_C32(0x16d6024f), SPH_C32(0xed083c51), SPH_C32(0x4f250000), + SPH_C32(0xfe1c0000), SPH_C32(0x496970600), SPH_C32(0xf83b0000), + SPH_C32(0xacf47e2e), SPH_C32(0x4f27cec3), SPH_C32(0x2645fe76), + SPH_C32(0xb0cbda7f) }, + { SPH_C32(0x02af0000), SPH_C32(0xb7280000), SPH_C32(0xba1c0300), + SPH_C32(0x56980000), SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), + SPH_C32(0xa95c149a), SPH_C32(0xf4f6ea7b), SPH_C32(0x7a8c0000), + SPH_C32(0xa5d40000), SPH_C32(0x13260880), SPH_C32(0xc63d0000), + SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), SPH_C32(0x59d0b4f8), + SPH_C32(0x979961d0) }, + { SPH_C32(0x83310000), SPH_C32(0x5b7f0000), SPH_C32(0xdc2e0180), + SPH_C32(0xc36b0000), SPH_C32(0xe7246dd1), SPH_C32(0xc8bcfadb), + SPH_C32(0x4f06b6b7), SPH_C32(0x7a915d81), SPH_C32(0x37060000), + SPH_C32(0xece00000), SPH_C32(0x2fad0d80), SPH_C32(0x689e0000), + SPH_C32(0xddca5657), SPH_C32(0x31ce47e7), SPH_C32(0xd6c95e14), + SPH_C32(0xd3a451d4) }, + { SPH_C32(0x7a8c0000), SPH_C32(0xa5d40000), SPH_C32(0x13260880), + SPH_C32(0xc63d0000), SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), + SPH_C32(0x59d0b4f8), SPH_C32(0x979961d0), SPH_C32(0x78230000), + SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), SPH_C32(0x90a50000), + SPH_C32(0x713e2879), SPH_C32(0x7ee98924), SPH_C32(0xf08ca062), + SPH_C32(0x636f8bab) }, + { SPH_C32(0xfb120000), SPH_C32(0x49830000), SPH_C32(0x75140a00), + SPH_C32(0x53ce0000), SPH_C32(0x961a45a8), SPH_C32(0xb65573ff), + SPH_C32(0xbf8a16d5), SPH_C32(0x19fed62a), SPH_C32(0x35a90000), + SPH_C32(0x5bc80000), SPH_C32(0x95b10e80), SPH_C32(0x3e060000), + SPH_C32(0x67471384), SPH_C32(0xb1868180), SPH_C32(0x7f954a8e), + SPH_C32(0x2752bbaf) } +}; + +static const sph_u32 T512_39[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x52500000), SPH_C32(0x29540000), SPH_C32(0x6a61004e), + SPH_C32(0xf0ff0000), SPH_C32(0x9a317eec), SPH_C32(0x452341ce), + SPH_C32(0xcf568fe5), SPH_C32(0x5303130f), SPH_C32(0x538d0000), + SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), SPH_C32(0x56ff0000), + SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), SPH_C32(0xa9444018), + SPH_C32(0x7f975691) }, + { SPH_C32(0x538d0000), SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), + SPH_C32(0x56ff0000), SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), + SPH_C32(0xa9444018), SPH_C32(0x7f975691), SPH_C32(0x01dd0000), + SPH_C32(0x80a80000), SPH_C32(0xf4960048), SPH_C32(0xa6000000), + SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), SPH_C32(0x6612cffd), + SPH_C32(0x2c94459e) }, + { SPH_C32(0x01dd0000), SPH_C32(0x80a80000), SPH_C32(0xf4960048), + SPH_C32(0xa6000000), SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), + SPH_C32(0x6612cffd), SPH_C32(0x2c94459e), SPH_C32(0x52500000), + SPH_C32(0x29540000), SPH_C32(0x6a61004e), SPH_C32(0xf0ff0000), + SPH_C32(0x9a317eec), SPH_C32(0x452341ce), SPH_C32(0xcf568fe5), + SPH_C32(0x5303130f) }, + { SPH_C32(0xcc140000), SPH_C32(0xa5630000), SPH_C32(0x5ab90780), + SPH_C32(0x3b500000), SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), + SPH_C32(0x694348c1), SPH_C32(0xca5a87fe), SPH_C32(0x819e0000), + SPH_C32(0xec570000), SPH_C32(0x66320280), SPH_C32(0x95f30000), + SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), SPH_C32(0xe65aa22d), + SPH_C32(0x8e67b7fa) }, + { SPH_C32(0x9e440000), SPH_C32(0x8c370000), SPH_C32(0x30d807ce), + SPH_C32(0xcbaf0000), SPH_C32(0xd1e16d13), SPH_C32(0xc2b875d6), + SPH_C32(0xa615c724), SPH_C32(0x995994f1), SPH_C32(0xd2130000), + SPH_C32(0x45ab0000), SPH_C32(0xf8c50286), SPH_C32(0xc30c0000), + SPH_C32(0x574d284c), SPH_C32(0xda31f145), SPH_C32(0x4f1ee235), + SPH_C32(0xf1f0e16b) }, + { SPH_C32(0x9f990000), SPH_C32(0x0c9f0000), SPH_C32(0xc44e0786), + SPH_C32(0x6daf0000), SPH_C32(0x413413b1), SPH_C32(0x155ef9e1), + SPH_C32(0xc00708d9), SPH_C32(0xb5cdd16f), SPH_C32(0x80430000), + SPH_C32(0x6cff0000), SPH_C32(0x92a402c8), SPH_C32(0x33f30000), + SPH_C32(0xcd7c56a0), SPH_C32(0x9f12b08b), SPH_C32(0x80486dd0), + SPH_C32(0xa2f3f264) }, + { SPH_C32(0xcdc90000), SPH_C32(0x25cb0000), SPH_C32(0xae2f07c8), + SPH_C32(0x9d500000), SPH_C32(0xdb056d5d), SPH_C32(0x507db82f), + SPH_C32(0x0f51873c), SPH_C32(0xe6cec260), SPH_C32(0xd3ce0000), + SPH_C32(0xc5030000), SPH_C32(0x0c5302ce), SPH_C32(0x650c0000), + SPH_C32(0xc79856ee), SPH_C32(0x0dd77d72), SPH_C32(0x290c2dc8), + SPH_C32(0xdd64a4f5) } +}; + +static const sph_u32 T512_42[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x07ed0000), SPH_C32(0xb2500000), SPH_C32(0x8774000a), + SPH_C32(0x970d0000), SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), + SPH_C32(0xf4786222), SPH_C32(0x9075b1ce), SPH_C32(0xa2d60000), + SPH_C32(0xa6760000), SPH_C32(0xc9440014), SPH_C32(0xeba30000), + SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), SPH_C32(0x03490afa), + SPH_C32(0x9b6ef888) }, + { SPH_C32(0x88980000), SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), + SPH_C32(0xfb4e0000), SPH_C32(0xf158079a), SPH_C32(0x61ae9167), + SPH_C32(0xa895706c), SPH_C32(0xe6107494), SPH_C32(0x0bc20000), + SPH_C32(0xdb630000), SPH_C32(0x7e88000c), SPH_C32(0x15860000), + SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), SPH_C32(0xf460449e), + SPH_C32(0xd8b61463) }, + { SPH_C32(0x8f750000), SPH_C32(0xadc40000), SPH_C32(0xf8bb0024), + SPH_C32(0x6c430000), SPH_C32(0xb22a2434), SPH_C32(0x2969ffc3), + SPH_C32(0x5ced124e), SPH_C32(0x7665c55a), SPH_C32(0xa9140000), + SPH_C32(0x7d150000), SPH_C32(0xb7cc0018), SPH_C32(0xfe250000), + SPH_C32(0x5d116688), SPH_C32(0x45997fda), SPH_C32(0xf7294e64), + SPH_C32(0x43d8eceb) }, + { SPH_C32(0x0bc20000), SPH_C32(0xdb630000), SPH_C32(0x7e88000c), + SPH_C32(0x15860000), SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), + SPH_C32(0xf460449e), SPH_C32(0xd8b61463), SPH_C32(0x835a0000), + SPH_C32(0xc4f70000), SPH_C32(0x01470022), SPH_C32(0xeec80000), + SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), SPH_C32(0x5cf534f2), + SPH_C32(0x3ea660f7) }, + { SPH_C32(0x0c2f0000), SPH_C32(0x69330000), SPH_C32(0xf9fc0006), + SPH_C32(0x828b0000), SPH_C32(0xd28f6b5d), SPH_C32(0x3d46d5e7), + SPH_C32(0x001826bc), SPH_C32(0x48c3a5ad), SPH_C32(0x218c0000), + SPH_C32(0x62810000), SPH_C32(0xc8030036), SPH_C32(0x056b0000), + SPH_C32(0xac496112), SPH_C32(0x2437eebd), SPH_C32(0x5fbc3e08), + SPH_C32(0xa5c8987f) }, + { SPH_C32(0x835a0000), SPH_C32(0xc4f70000), SPH_C32(0x01470022), + SPH_C32(0xeec80000), SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), + SPH_C32(0x5cf534f2), SPH_C32(0x3ea660f7), SPH_C32(0x88980000), + SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), SPH_C32(0xfb4e0000), + SPH_C32(0xf158079a), SPH_C32(0x61ae9167), SPH_C32(0xa895706c), + SPH_C32(0xe6107494) }, + { SPH_C32(0x84b70000), SPH_C32(0x76a70000), SPH_C32(0x86330028), + SPH_C32(0x79c50000), SPH_C32(0x23d76cc7), SPH_C32(0x5ce84480), + SPH_C32(0xa88d56d0), SPH_C32(0xaed3d139), SPH_C32(0x2a4e0000), + SPH_C32(0xb9e20000), SPH_C32(0xb68b003a), SPH_C32(0x10ed0000), + SPH_C32(0x3db429e1), SPH_C32(0x51b655fe), SPH_C32(0xabdc7a96), + SPH_C32(0x7d7e8c1c) } +}; + +static const sph_u32 T512_45[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x58430000), SPH_C32(0x807e0000), SPH_C32(0x78330001), + SPH_C32(0xc66b3800), SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), + SPH_C32(0xac73fe6f), SPH_C32(0x3a4479b1), SPH_C32(0x1d5a0000), + SPH_C32(0x2b720000), SPH_C32(0x488d0000), SPH_C32(0xaf611800), + SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), SPH_C32(0x81a20429), + SPH_C32(0x1e7536a6) }, + { SPH_C32(0x1d5a0000), SPH_C32(0x2b720000), SPH_C32(0x488d0000), + SPH_C32(0xaf611800), SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), + SPH_C32(0x81a20429), SPH_C32(0x1e7536a6), SPH_C32(0x45190000), + SPH_C32(0xab0c0000), SPH_C32(0x30be0001), SPH_C32(0x690a2000), + SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), SPH_C32(0x2dd1fa46), + SPH_C32(0x24314f17) }, + { SPH_C32(0x45190000), SPH_C32(0xab0c0000), SPH_C32(0x30be0001), + SPH_C32(0x690a2000), SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), + SPH_C32(0x2dd1fa46), SPH_C32(0x24314f17), SPH_C32(0x58430000), + SPH_C32(0x807e0000), SPH_C32(0x78330001), SPH_C32(0xc66b3800), + SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), SPH_C32(0xac73fe6f), + SPH_C32(0x3a4479b1) }, + { SPH_C32(0xa53b0000), SPH_C32(0x14260000), SPH_C32(0x4e30001e), + SPH_C32(0x7cae0000), SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), + SPH_C32(0xf73168d8), SPH_C32(0x0b1b4946), SPH_C32(0x07ed0000), + SPH_C32(0xb2500000), SPH_C32(0x8774000a), SPH_C32(0x970d0000), + SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), SPH_C32(0xf4786222), + SPH_C32(0x9075b1ce) }, + { SPH_C32(0xfd780000), SPH_C32(0x94580000), SPH_C32(0x3603001f), + SPH_C32(0xbac53800), SPH_C32(0x68a95109), SPH_C32(0x017295e0), + SPH_C32(0x5b4296b7), SPH_C32(0x315f30f7), SPH_C32(0x1ab70000), + SPH_C32(0x99220000), SPH_C32(0xcff9000a), SPH_C32(0x386c1800), + SPH_C32(0x66b90d6b), SPH_C32(0x80bed174), SPH_C32(0x75da660b), + SPH_C32(0x8e008768) }, + { SPH_C32(0xb8610000), SPH_C32(0x3f540000), SPH_C32(0x06bd001e), + SPH_C32(0xd3cf1800), SPH_C32(0xaa552310), SPH_C32(0xb0a615ed), + SPH_C32(0x76936cf1), SPH_C32(0x156e7fe0), SPH_C32(0x42f40000), + SPH_C32(0x195c0000), SPH_C32(0xb7ca000b), SPH_C32(0xfe072000), + SPH_C32(0x818e51b7), SPH_C32(0xf913eea9), SPH_C32(0xd9a99864), + SPH_C32(0xb444fed9) }, + { SPH_C32(0xe0220000), SPH_C32(0xbf2a0000), SPH_C32(0x7e8e001f), + SPH_C32(0x15a42000), SPH_C32(0x4d627fcc), SPH_C32(0xc90b2a30), + SPH_C32(0xdae0929e), SPH_C32(0x2f2a0651), SPH_C32(0x5fae0000), + SPH_C32(0x322e0000), SPH_C32(0xff47000b), SPH_C32(0x51663800), + SPH_C32(0xa4457f72), SPH_C32(0x316a5179), SPH_C32(0x580b9c4d), + SPH_C32(0xaa31c87f) } +}; + +static const sph_u32 T512_48[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xbadd0000), SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), + SPH_C32(0xf7282800), SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), + SPH_C32(0xea5a8d14), SPH_C32(0x2a2c18f0), SPH_C32(0xb82f0000), + SPH_C32(0xb12c0000), SPH_C32(0x30d80000), SPH_C32(0x14445000), + SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), SPH_C32(0x2e98bf23), + SPH_C32(0x551e3d6e) }, + { SPH_C32(0x1e6c0000), SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), + SPH_C32(0xbcb6b800), SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), + SPH_C32(0x6a0c1bc8), SPH_C32(0xb99dc2eb), SPH_C32(0x92560000), + SPH_C32(0x1eda0000), SPH_C32(0xea510000), SPH_C32(0xe8b13000), + SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), SPH_C32(0xb15c2254), + SPH_C32(0x33c5244f) }, + { SPH_C32(0xa4b10000), SPH_C32(0xd7ef0000), SPH_C32(0x3dc90000), + SPH_C32(0x4b9e9000), SPH_C32(0xf30107fb), SPH_C32(0xbde710e0), + SPH_C32(0x805696dc), SPH_C32(0x93b1da1b), SPH_C32(0x2a790000), + SPH_C32(0xaff60000), SPH_C32(0xda890000), SPH_C32(0xfcf56000), + SPH_C32(0x686d3607), SPH_C32(0xdadc8975), SPH_C32(0x9fc49d77), + SPH_C32(0x66db1921) }, + { SPH_C32(0x92560000), SPH_C32(0x1eda0000), SPH_C32(0xea510000), + SPH_C32(0xe8b13000), SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), + SPH_C32(0xb15c2254), SPH_C32(0x33c5244f), SPH_C32(0x8c3a0000), + SPH_C32(0xda980000), SPH_C32(0x607f0000), SPH_C32(0x54078800), + SPH_C32(0x85714513), SPH_C32(0x6006b243), SPH_C32(0xdb50399c), + SPH_C32(0x8a58e6a4) }, + { SPH_C32(0x288b0000), SPH_C32(0x0d770000), SPH_C32(0x5db60000), + SPH_C32(0x1f991800), SPH_C32(0x767042e8), SPH_C32(0xdde1a2a3), + SPH_C32(0x5b06af40), SPH_C32(0x19e93cbf), SPH_C32(0x34150000), + SPH_C32(0x6bb40000), SPH_C32(0x50a70000), SPH_C32(0x4043d800), + SPH_C32(0x442925b1), SPH_C32(0x51215aaf), SPH_C32(0xf5c886bf), + SPH_C32(0xdf46dbca) }, + { SPH_C32(0x8c3a0000), SPH_C32(0xda980000), SPH_C32(0x607f0000), + SPH_C32(0x54078800), SPH_C32(0x85714513), SPH_C32(0x6006b243), + SPH_C32(0xdb50399c), SPH_C32(0x8a58e6a4), SPH_C32(0x1e6c0000), + SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), SPH_C32(0xbcb6b800), + SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), SPH_C32(0x6a0c1bc8), + SPH_C32(0xb99dc2eb) }, + { SPH_C32(0x36e70000), SPH_C32(0xc9350000), SPH_C32(0xd7980000), + SPH_C32(0xa32fa000), SPH_C32(0x5a34515e), SPH_C32(0x561c7179), + SPH_C32(0x310ab488), SPH_C32(0xa074fe54), SPH_C32(0xa6430000), + SPH_C32(0x756e0000), SPH_C32(0xbaf60000), SPH_C32(0xa8f2e800), + SPH_C32(0xed1c7314), SPH_C32(0xbada3b36), SPH_C32(0x4494a4eb), + SPH_C32(0xec83ff85) } +}; + +static const sph_u32 T512_51[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xb4310000), SPH_C32(0x77330000), SPH_C32(0xb15d0000), + SPH_C32(0x7fd004e0), SPH_C32(0x78a26138), SPH_C32(0xd116c35d), + SPH_C32(0xd256d489), SPH_C32(0x4e6f74de), SPH_C32(0xe3060000), + SPH_C32(0xbdc10000), SPH_C32(0x87130000), SPH_C32(0xbff20060), + SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), SPH_C32(0x73c5ab06), + SPH_C32(0x5bd61539) }, + { SPH_C32(0xe3060000), SPH_C32(0xbdc10000), SPH_C32(0x87130000), + SPH_C32(0xbff20060), SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), + SPH_C32(0x73c5ab06), SPH_C32(0x5bd61539), SPH_C32(0x57370000), + SPH_C32(0xcaf20000), SPH_C32(0x364e0000), SPH_C32(0xc0220480), + SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), SPH_C32(0xa1937f8f), + SPH_C32(0x15b961e7) }, + { SPH_C32(0x57370000), SPH_C32(0xcaf20000), SPH_C32(0x364e0000), + SPH_C32(0xc0220480), SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), + SPH_C32(0xa1937f8f), SPH_C32(0x15b961e7), SPH_C32(0xb4310000), + SPH_C32(0x77330000), SPH_C32(0xb15d0000), SPH_C32(0x7fd004e0), + SPH_C32(0x78a26138), SPH_C32(0xd116c35d), SPH_C32(0xd256d489), + SPH_C32(0x4e6f74de) }, + { SPH_C32(0x02f20000), SPH_C32(0xa2810000), SPH_C32(0x873f0000), + SPH_C32(0xe36c7800), SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), + SPH_C32(0xc4c23237), SPH_C32(0x7f32259e), SPH_C32(0xbadd0000), + SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), SPH_C32(0xf7282800), + SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), SPH_C32(0xea5a8d14), + SPH_C32(0x2a2c18f0) }, + { SPH_C32(0xb6c30000), SPH_C32(0xd5b20000), SPH_C32(0x36620000), + SPH_C32(0x9cbc7ce0), SPH_C32(0x66bf15d7), SPH_C32(0xd62be88b), + SPH_C32(0x1694e6be), SPH_C32(0x315d5140), SPH_C32(0x59db0000), + SPH_C32(0xae6c0000), SPH_C32(0x30f40000), SPH_C32(0x48da2860), + SPH_C32(0xf1ff1e57), SPH_C32(0xbbaff46b), SPH_C32(0x999f2612), + SPH_C32(0x71fa0dc9) }, + { SPH_C32(0xe1f40000), SPH_C32(0x1f400000), SPH_C32(0x002c0000), + SPH_C32(0x5c9e7860), SPH_C32(0x30a77ef5), SPH_C32(0x8a881c87), + SPH_C32(0xb7079931), SPH_C32(0x24e430a7), SPH_C32(0xedea0000), + SPH_C32(0xd95f0000), SPH_C32(0x81a90000), SPH_C32(0x370a2c80), + SPH_C32(0x895d7f6f), SPH_C32(0x6ab93736), SPH_C32(0x4bc9f29b), + SPH_C32(0x3f957917) }, + { SPH_C32(0x55c50000), SPH_C32(0x68730000), SPH_C32(0xb1710000), + SPH_C32(0x234e7c80), SPH_C32(0x48051fcd), SPH_C32(0x5b9edfda), + SPH_C32(0x65514db8), SPH_C32(0x6a8b4479), SPH_C32(0x0eec0000), + SPH_C32(0x649e0000), SPH_C32(0x06ba0000), SPH_C32(0x88f82ce0), + SPH_C32(0xa7e77575), SPH_C32(0xe70c0067), SPH_C32(0x380c599d), + SPH_C32(0x64436c2e) } +}; + +static const sph_u32 T512_54[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x7b280000), SPH_C32(0x57420000), SPH_C32(0xa9e50000), + SPH_C32(0x634300a0), SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), + SPH_C32(0x27f83b03), SPH_C32(0xc7ff60f0), SPH_C32(0x95bb0000), + SPH_C32(0x81450000), SPH_C32(0x3b240000), SPH_C32(0x48db0140), + SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), SPH_C32(0x62c91877), + SPH_C32(0xe7e00a94) }, + { SPH_C32(0xe6280000), SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), + SPH_C32(0xd3d002e0), SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), + SPH_C32(0x289506b4), SPH_C32(0xd75a4897), SPH_C32(0xf0c50000), + SPH_C32(0x59230000), SPH_C32(0x45820000), SPH_C32(0xe18d00c0), + SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), SPH_C32(0xcbe0fe1c), + SPH_C32(0x56a7b19f) }, + { SPH_C32(0x9d000000), SPH_C32(0x1b090000), SPH_C32(0x01b00000), + SPH_C32(0xb0930240), SPH_C32(0x46ba7497), SPH_C32(0xf53e2561), + SPH_C32(0x0f6d3db7), SPH_C32(0x10a52867), SPH_C32(0x657e0000), + SPH_C32(0xd8660000), SPH_C32(0x7ea60000), SPH_C32(0xa9560180), + SPH_C32(0x31e76a62), SPH_C32(0x94183875), SPH_C32(0xa929e66b), + SPH_C32(0xb147bb0b) }, + { SPH_C32(0xf0c50000), SPH_C32(0x59230000), SPH_C32(0x45820000), + SPH_C32(0xe18d00c0), SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), + SPH_C32(0xcbe0fe1c), SPH_C32(0x56a7b19f), SPH_C32(0x16ed0000), + SPH_C32(0x15680000), SPH_C32(0xedd70000), SPH_C32(0x325d0220), + SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), SPH_C32(0xe375f8a8), + SPH_C32(0x81fdf908) }, + { SPH_C32(0x8bed0000), SPH_C32(0x0e610000), SPH_C32(0xec670000), + SPH_C32(0x82ce0060), SPH_C32(0xa5b6421e), SPH_C32(0xaf74c322), + SPH_C32(0xec18c51f), SPH_C32(0x9158d16f), SPH_C32(0x83560000), + SPH_C32(0x942d0000), SPH_C32(0xd6f30000), SPH_C32(0x7a860360), + SPH_C32(0xe9865ada), SPH_C32(0x0cbf88af), SPH_C32(0x81bce0df), + SPH_C32(0x661df39c) }, + { SPH_C32(0x16ed0000), SPH_C32(0x15680000), SPH_C32(0xedd70000), + SPH_C32(0x325d0220), SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), + SPH_C32(0xe375f8a8), SPH_C32(0x81fdf908), SPH_C32(0xe6280000), + SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), SPH_C32(0xd3d002e0), + SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), SPH_C32(0x289506b4), + SPH_C32(0xd75a4897) }, + { SPH_C32(0x6dc50000), SPH_C32(0x422a0000), SPH_C32(0x44320000), + SPH_C32(0x511e0280), SPH_C32(0x7dd772a6), SPH_C32(0x37d373f8), + SPH_C32(0xc48dc3ab), SPH_C32(0x460299f8), SPH_C32(0x73930000), + SPH_C32(0xcd0e0000), SPH_C32(0x93710000), SPH_C32(0x9b0b03a0), + SPH_C32(0xd2eb5ceb), SPH_C32(0xce52de36), SPH_C32(0x4a5c1ec3), + SPH_C32(0x30ba4203) } +}; + +static const sph_u32 T512_57[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x5fa80000), SPH_C32(0x56030000), SPH_C32(0x43ae0000), + SPH_C32(0x64f30013), SPH_C32(0x257e86bf), SPH_C32(0x1311944e), + SPH_C32(0x541e95bf), SPH_C32(0x8ea4db69), SPH_C32(0x00440000), + SPH_C32(0x7f480000), SPH_C32(0xda7c0000), SPH_C32(0x2a230001), + SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), SPH_C32(0x030a9e60), + SPH_C32(0xbe0a679e) }, + { SPH_C32(0x00440000), SPH_C32(0x7f480000), SPH_C32(0xda7c0000), + SPH_C32(0x2a230001), SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), + SPH_C32(0x030a9e60), SPH_C32(0xbe0a679e), SPH_C32(0x5fec0000), + SPH_C32(0x294b0000), SPH_C32(0x99d20000), SPH_C32(0x4ed00012), + SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), SPH_C32(0x57140bdf), + SPH_C32(0x30aebcf7) }, + { SPH_C32(0x5fec0000), SPH_C32(0x294b0000), SPH_C32(0x99d20000), + SPH_C32(0x4ed00012), SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), + SPH_C32(0x57140bdf), SPH_C32(0x30aebcf7), SPH_C32(0x5fa80000), + SPH_C32(0x56030000), SPH_C32(0x43ae0000), SPH_C32(0x64f30013), + SPH_C32(0x257e86bf), SPH_C32(0x1311944e), SPH_C32(0x541e95bf), + SPH_C32(0x8ea4db69) }, + { SPH_C32(0xee930000), SPH_C32(0xd6070000), SPH_C32(0x92c10000), + SPH_C32(0x2b9801e0), SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), + SPH_C32(0x45312374), SPH_C32(0x201f6a64), SPH_C32(0x7b280000), + SPH_C32(0x57420000), SPH_C32(0xa9e50000), SPH_C32(0x634300a0), + SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), SPH_C32(0x27f83b03), + SPH_C32(0xc7ff60f0) }, + { SPH_C32(0xb13b0000), SPH_C32(0x80040000), SPH_C32(0xd16f0000), + SPH_C32(0x4f6b01f3), SPH_C32(0xb12faec3), SPH_C32(0x287d6f19), + SPH_C32(0x112fb6cb), SPH_C32(0xaebbb10d), SPH_C32(0x7b6c0000), + SPH_C32(0x280a0000), SPH_C32(0x73990000), SPH_C32(0x496000a1), + SPH_C32(0xa5768de3), SPH_C32(0xc42f093c), SPH_C32(0x24f2a563), + SPH_C32(0x79f5076e) }, + { SPH_C32(0xeed70000), SPH_C32(0xa94f0000), SPH_C32(0x48bd0000), + SPH_C32(0x01bb01e1), SPH_C32(0xaffce1b0), SPH_C32(0x92da67d0), + SPH_C32(0x463bbd14), SPH_C32(0x9e150dfa), SPH_C32(0x24c40000), + SPH_C32(0x7e090000), SPH_C32(0x30370000), SPH_C32(0x2d9300b2), + SPH_C32(0x80080b5c), SPH_C32(0xd73e9d72), SPH_C32(0x70ec30dc), + SPH_C32(0xf751dc07) }, + { SPH_C32(0xb17f0000), SPH_C32(0xff4c0000), SPH_C32(0x0b130000), + SPH_C32(0x654801f2), SPH_C32(0x8a82670f), SPH_C32(0x81cbf39e), + SPH_C32(0x122528ab), SPH_C32(0x10b1d693), SPH_C32(0x24800000), + SPH_C32(0x01410000), SPH_C32(0xea4b0000), SPH_C32(0x07b000b3), + SPH_C32(0xbba5c290), SPH_C32(0x7e8801f5), SPH_C32(0x73e6aebc), + SPH_C32(0x495bbb99) } +}; + +static const sph_u32 T512_60[8][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xa8da0000), SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), + SPH_C32(0x07da0002), SPH_C32(0x7d669583), SPH_C32(0x1f98708a), + SPH_C32(0xbb668808), SPH_C32(0xda878000), SPH_C32(0xabe70000), + SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), SPH_C32(0x3d180005), + SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), SPH_C32(0xb5c347eb), + SPH_C32(0x3c5dfffe) }, + { SPH_C32(0x01930000), SPH_C32(0xe7820000), SPH_C32(0xedfb0000), + SPH_C32(0xcf0c000b), SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), + SPH_C32(0x063661e1), SPH_C32(0x536f9e7b), SPH_C32(0x92280000), + SPH_C32(0xdc850000), SPH_C32(0x57fa0000), SPH_C32(0x56dc0003), + SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), SPH_C32(0x90cef752), + SPH_C32(0x7b1675d7) }, + { SPH_C32(0xa9490000), SPH_C32(0x713c0000), SPH_C32(0xb1e60000), + SPH_C32(0xc8d60009), SPH_C32(0xf0b618db), SPH_C32(0xa33bc4a4), + SPH_C32(0xbd50e9e9), SPH_C32(0x89e81e7b), SPH_C32(0x39cf0000), + SPH_C32(0x42880000), SPH_C32(0xf8dd0000), SPH_C32(0x6bc40006), + SPH_C32(0x96a63cc5), SPH_C32(0x2e19b599), SPH_C32(0x250db0b9), + SPH_C32(0x474b8a29) }, + { SPH_C32(0x92280000), SPH_C32(0xdc850000), SPH_C32(0x57fa0000), + SPH_C32(0x56dc0003), SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), + SPH_C32(0x90cef752), SPH_C32(0x7b1675d7), SPH_C32(0x93bb0000), + SPH_C32(0x3b070000), SPH_C32(0xba010000), SPH_C32(0x99d00008), + SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), SPH_C32(0x96f896b3), + SPH_C32(0x2879ebac) }, + { SPH_C32(0x3af20000), SPH_C32(0x4a3b0000), SPH_C32(0x0be70000), + SPH_C32(0x51060001), SPH_C32(0xc78fb695), SPH_C32(0x4577d386), + SPH_C32(0x2ba87f5a), SPH_C32(0xa191f5d7), SPH_C32(0x385c0000), + SPH_C32(0xa50a0000), SPH_C32(0x15260000), SPH_C32(0xa4c8000d), + SPH_C32(0x1b76b19d), SPH_C32(0x92ba01b7), SPH_C32(0x233bd158), + SPH_C32(0x14241452) }, + { SPH_C32(0x93bb0000), SPH_C32(0x3b070000), SPH_C32(0xba010000), + SPH_C32(0x99d00008), SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), + SPH_C32(0x96f896b3), SPH_C32(0x2879ebac), SPH_C32(0x01930000), + SPH_C32(0xe7820000), SPH_C32(0xedfb0000), SPH_C32(0xcf0c000b), + SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), SPH_C32(0x063661e1), + SPH_C32(0x536f9e7b) }, + { SPH_C32(0x3b610000), SPH_C32(0xadb90000), SPH_C32(0xe61c0000), + SPH_C32(0x9e0a000a), SPH_C32(0x4a5f3bcd), SPH_C32(0xf9d467a8), + SPH_C32(0x2d9e1ebb), SPH_C32(0xf2fe6bac), SPH_C32(0xaa740000), + SPH_C32(0x798f0000), SPH_C32(0x42dc0000), SPH_C32(0xf214000e), + SPH_C32(0xa19f928b), SPH_C32(0xc855a2bb), SPH_C32(0xb3f5260a), + SPH_C32(0x6f326185) } +}; + +static const sph_u32 T512_63[2][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x033d0000), SPH_C32(0x08b30000), SPH_C32(0xf33a0000), + SPH_C32(0x3ac20007), SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), + SPH_C32(0x0ea5cfe3), SPH_C32(0xe6da7ffe), SPH_C32(0xa8da0000), + SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), SPH_C32(0x07da0002), + SPH_C32(0x7d669583), SPH_C32(0x1f98708a), SPH_C32(0xbb668808), + SPH_C32(0xda878000) } +}; + +#define INPUT_BIG do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T512_0[acc >> 5][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + m8 = rp[8]; \ + m9 = rp[9]; \ + mA = rp[10]; \ + mB = rp[11]; \ + mC = rp[12]; \ + mD = rp[13]; \ + mE = rp[14]; \ + mF = rp[15]; \ + rp = &T512_3[(acc >> 2) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[1]; \ + rp = &T512_6[(acc >> 7) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_9[(acc >> 4) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_12[(acc >> 1) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[2]; \ + rp = &T512_15[(acc >> 6) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_18[(acc >> 3) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_21[acc & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[3]; \ + rp = &T512_24[acc >> 5][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_27[(acc >> 2) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[4]; \ + rp = &T512_30[(acc >> 7) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_33[(acc >> 4) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_36[(acc >> 1) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[5]; \ + rp = &T512_39[(acc >> 6) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_42[(acc >> 3) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_45[acc & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[6]; \ + rp = &T512_48[acc >> 5][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_51[(acc >> 2) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[7]; \ + rp = &T512_54[(acc >> 7) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_57[(acc >> 4) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_60[(acc >> 1) & 0x07][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_63[acc & 0x01][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_BIG == 4 + +static const sph_u32 T512_0[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x54285c00), SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), + SPH_C32(0xa1c50000), SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), + SPH_C32(0x6bb0419d), SPH_C32(0x551b3782), SPH_C32(0x9cbb1800), + SPH_C32(0xb0d30000), SPH_C32(0x92510000), SPH_C32(0xed930000), + SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), SPH_C32(0x430633da), + SPH_C32(0x78cace29) }, + { SPH_C32(0x9cbb1800), SPH_C32(0xb0d30000), SPH_C32(0x92510000), + SPH_C32(0xed930000), SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), + SPH_C32(0x430633da), SPH_C32(0x78cace29), SPH_C32(0xc8934400), + SPH_C32(0x5a3e0000), SPH_C32(0x57870000), SPH_C32(0x4c560000), + SPH_C32(0xea982435), SPH_C32(0x75b11115), SPH_C32(0x28b67247), + SPH_C32(0x2dd1f9ab) }, + { SPH_C32(0xc8934400), SPH_C32(0x5a3e0000), SPH_C32(0x57870000), + SPH_C32(0x4c560000), SPH_C32(0xea982435), SPH_C32(0x75b11115), + SPH_C32(0x28b67247), SPH_C32(0x2dd1f9ab), SPH_C32(0x54285c00), + SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), SPH_C32(0xa1c50000), + SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), SPH_C32(0x6bb0419d), + SPH_C32(0x551b3782) }, + { SPH_C32(0x29449c00), SPH_C32(0x64e70000), SPH_C32(0xf24b0000), + SPH_C32(0xc2f30000), SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), + SPH_C32(0xf3e04259), SPH_C32(0x8d0d9ec4), SPH_C32(0x466d0c00), + SPH_C32(0x08620000), SPH_C32(0xdd5d0000), SPH_C32(0xbadd0000), + SPH_C32(0x6a927942), SPH_C32(0x441f2b93), SPH_C32(0x218ace6f), + SPH_C32(0xbf2c0be2) }, + { SPH_C32(0x7d6cc000), SPH_C32(0x8e0a0000), SPH_C32(0x379d0000), + SPH_C32(0x63360000), SPH_C32(0xbd7c29ff), SPH_C32(0xc267f3a4), + SPH_C32(0x985003c4), SPH_C32(0xd816a946), SPH_C32(0xdad61400), + SPH_C32(0xb8b10000), SPH_C32(0x4f0c0000), SPH_C32(0x574e0000), + SPH_C32(0x33a83a07), SPH_C32(0xa50bfe67), SPH_C32(0x628cfdb5), + SPH_C32(0xc7e6c5cb) }, + { SPH_C32(0xb5ff8400), SPH_C32(0xd4340000), SPH_C32(0x601a0000), + SPH_C32(0x2f600000), SPH_C32(0x57e40dca), SPH_C32(0xb7d6e2b1), + SPH_C32(0xb0e67183), SPH_C32(0xf5c750ed), SPH_C32(0x8efe4800), + SPH_C32(0x525c0000), SPH_C32(0x8ada0000), SPH_C32(0xf68b0000), + SPH_C32(0x800a5d77), SPH_C32(0x31ae3a86), SPH_C32(0x093cbc28), + SPH_C32(0x92fdf249) }, + { SPH_C32(0xe1d7d800), SPH_C32(0x3ed90000), SPH_C32(0xa5cc0000), + SPH_C32(0x8ea50000), SPH_C32(0xe4466aba), SPH_C32(0x23732650), + SPH_C32(0xdb56301e), SPH_C32(0xa0dc676f), SPH_C32(0x12455000), + SPH_C32(0xe28f0000), SPH_C32(0x188b0000), SPH_C32(0x1b180000), + SPH_C32(0xd9301e32), SPH_C32(0xd0baef72), SPH_C32(0x4a3a8ff2), + SPH_C32(0xea373c60) }, + { SPH_C32(0x466d0c00), SPH_C32(0x08620000), SPH_C32(0xdd5d0000), + SPH_C32(0xbadd0000), SPH_C32(0x6a927942), SPH_C32(0x441f2b93), + SPH_C32(0x218ace6f), SPH_C32(0xbf2c0be2), SPH_C32(0x6f299000), + SPH_C32(0x6c850000), SPH_C32(0x2f160000), SPH_C32(0x782e0000), + SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), SPH_C32(0xd26a8c36), + SPH_C32(0x32219526) }, + { SPH_C32(0x12455000), SPH_C32(0xe28f0000), SPH_C32(0x188b0000), + SPH_C32(0x1b180000), SPH_C32(0xd9301e32), SPH_C32(0xd0baef72), + SPH_C32(0x4a3a8ff2), SPH_C32(0xea373c60), SPH_C32(0xf3928800), + SPH_C32(0xdc560000), SPH_C32(0xbd470000), SPH_C32(0x95bd0000), + SPH_C32(0x3d767488), SPH_C32(0xf3c9c922), SPH_C32(0x916cbfec), + SPH_C32(0x4aeb5b0f) }, + { SPH_C32(0xdad61400), SPH_C32(0xb8b10000), SPH_C32(0x4f0c0000), + SPH_C32(0x574e0000), SPH_C32(0x33a83a07), SPH_C32(0xa50bfe67), + SPH_C32(0x628cfdb5), SPH_C32(0xc7e6c5cb), SPH_C32(0xa7bad400), + SPH_C32(0x36bb0000), SPH_C32(0x78910000), SPH_C32(0x34780000), + SPH_C32(0x8ed413f8), SPH_C32(0x676c0dc3), SPH_C32(0xfadcfe71), + SPH_C32(0x1ff06c8d) }, + { SPH_C32(0x8efe4800), SPH_C32(0x525c0000), SPH_C32(0x8ada0000), + SPH_C32(0xf68b0000), SPH_C32(0x800a5d77), SPH_C32(0x31ae3a86), + SPH_C32(0x093cbc28), SPH_C32(0x92fdf249), SPH_C32(0x3b01cc00), + SPH_C32(0x86680000), SPH_C32(0xeac00000), SPH_C32(0xd9eb0000), + SPH_C32(0xd7ee50bd), SPH_C32(0x8678d837), SPH_C32(0xb9dacdab), + SPH_C32(0x673aa2a4) }, + { SPH_C32(0x6f299000), SPH_C32(0x6c850000), SPH_C32(0x2f160000), + SPH_C32(0x782e0000), SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), + SPH_C32(0xd26a8c36), SPH_C32(0x32219526), SPH_C32(0x29449c00), + SPH_C32(0x64e70000), SPH_C32(0xf24b0000), SPH_C32(0xc2f30000), + SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), SPH_C32(0xf3e04259), + SPH_C32(0x8d0d9ec4) }, + { SPH_C32(0x3b01cc00), SPH_C32(0x86680000), SPH_C32(0xeac00000), + SPH_C32(0xd9eb0000), SPH_C32(0xd7ee50bd), SPH_C32(0x8678d837), + SPH_C32(0xb9dacdab), SPH_C32(0x673aa2a4), SPH_C32(0xb5ff8400), + SPH_C32(0xd4340000), SPH_C32(0x601a0000), SPH_C32(0x2f600000), + SPH_C32(0x57e40dca), SPH_C32(0xb7d6e2b1), SPH_C32(0xb0e67183), + SPH_C32(0xf5c750ed) }, + { SPH_C32(0xf3928800), SPH_C32(0xdc560000), SPH_C32(0xbd470000), + SPH_C32(0x95bd0000), SPH_C32(0x3d767488), SPH_C32(0xf3c9c922), + SPH_C32(0x916cbfec), SPH_C32(0x4aeb5b0f), SPH_C32(0xe1d7d800), + SPH_C32(0x3ed90000), SPH_C32(0xa5cc0000), SPH_C32(0x8ea50000), + SPH_C32(0xe4466aba), SPH_C32(0x23732650), SPH_C32(0xdb56301e), + SPH_C32(0xa0dc676f) }, + { SPH_C32(0xa7bad400), SPH_C32(0x36bb0000), SPH_C32(0x78910000), + SPH_C32(0x34780000), SPH_C32(0x8ed413f8), SPH_C32(0x676c0dc3), + SPH_C32(0xfadcfe71), SPH_C32(0x1ff06c8d), SPH_C32(0x7d6cc000), + SPH_C32(0x8e0a0000), SPH_C32(0x379d0000), SPH_C32(0x63360000), + SPH_C32(0xbd7c29ff), SPH_C32(0xc267f3a4), SPH_C32(0x985003c4), + SPH_C32(0xd816a946) } +}; + +static const sph_u32 T512_4[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xef0b0270), SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), + SPH_C32(0x69490000), SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), + SPH_C32(0x66140a51), SPH_C32(0x924f5d0a), SPH_C32(0xc96b0030), + SPH_C32(0xe7250000), SPH_C32(0x2f840000), SPH_C32(0x264f0000), + SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), SPH_C32(0x509f6984), + SPH_C32(0x9e69af68) }, + { SPH_C32(0xc96b0030), SPH_C32(0xe7250000), SPH_C32(0x2f840000), + SPH_C32(0x264f0000), SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), + SPH_C32(0x509f6984), SPH_C32(0x9e69af68), SPH_C32(0x26600240), + SPH_C32(0xddd80000), SPH_C32(0x722a0000), SPH_C32(0x4f060000), + SPH_C32(0x936667ff), SPH_C32(0x29f944ce), SPH_C32(0x368b63d5), + SPH_C32(0x0c26f262) }, + { SPH_C32(0x26600240), SPH_C32(0xddd80000), SPH_C32(0x722a0000), + SPH_C32(0x4f060000), SPH_C32(0x936667ff), SPH_C32(0x29f944ce), + SPH_C32(0x368b63d5), SPH_C32(0x0c26f262), SPH_C32(0xef0b0270), + SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), SPH_C32(0x69490000), + SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), SPH_C32(0x66140a51), + SPH_C32(0x924f5d0a) }, + { SPH_C32(0x145a3c00), SPH_C32(0xb9e90000), SPH_C32(0x61270000), + SPH_C32(0xf1610000), SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), + SPH_C32(0x47a96720), SPH_C32(0xe18e24c5), SPH_C32(0x23671400), + SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), SPH_C32(0xfb750000), + SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), SPH_C32(0x02c40a3f), + SPH_C32(0xdc24e61f) }, + { SPH_C32(0xfb513e70), SPH_C32(0x83140000), SPH_C32(0x3c890000), + SPH_C32(0x98280000), SPH_C32(0x556e016a), SPH_C32(0xf44c8881), + SPH_C32(0x21bd6d71), SPH_C32(0x73c179cf), SPH_C32(0xea0c1430), + SPH_C32(0x2f9c0000), SPH_C32(0xdb430000), SPH_C32(0xdd3a0000), + SPH_C32(0x7ba47f9c), SPH_C32(0x955a547e), SPH_C32(0x525b63bb), + SPH_C32(0x424d4977) }, + { SPH_C32(0xdd313c30), SPH_C32(0x5ecc0000), SPH_C32(0x4ea30000), + SPH_C32(0xd72e0000), SPH_C32(0xc6086695), SPH_C32(0xddb5cc4f), + SPH_C32(0x17360ea4), SPH_C32(0x7fe78bad), SPH_C32(0x05071640), + SPH_C32(0x15610000), SPH_C32(0x86ed0000), SPH_C32(0xb4730000), + SPH_C32(0xe0ab439a), SPH_C32(0xd15fe187), SPH_C32(0x344f69ea), + SPH_C32(0xd002147d) }, + { SPH_C32(0x323a3e40), SPH_C32(0x64310000), SPH_C32(0x130d0000), + SPH_C32(0xbe670000), SPH_C32(0x5d075a93), SPH_C32(0x99b079b6), + SPH_C32(0x712204f5), SPH_C32(0xeda8d6a7), SPH_C32(0xcc6c1670), + SPH_C32(0xf2440000), SPH_C32(0xa9690000), SPH_C32(0x923c0000), + SPH_C32(0xe8c21863), SPH_C32(0xbca310b0), SPH_C32(0x64d0006e), + SPH_C32(0x4e6bbb15) }, + { SPH_C32(0x23671400), SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), + SPH_C32(0xfb750000), SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), + SPH_C32(0x02c40a3f), SPH_C32(0xdc24e61f), SPH_C32(0x373d2800), + SPH_C32(0x71500000), SPH_C32(0x95e00000), SPH_C32(0x0a140000), + SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), SPH_C32(0x456d6d1f), + SPH_C32(0x3daac2da) }, + { SPH_C32(0xcc6c1670), SPH_C32(0xf2440000), SPH_C32(0xa9690000), + SPH_C32(0x923c0000), SPH_C32(0xe8c21863), SPH_C32(0xbca310b0), + SPH_C32(0x64d0006e), SPH_C32(0x4e6bbb15), SPH_C32(0xfe562830), + SPH_C32(0x96750000), SPH_C32(0xba640000), SPH_C32(0x2c5b0000), + SPH_C32(0xb5c542f0), SPH_C32(0x25136906), SPH_C32(0x15f2049b), + SPH_C32(0xa3c36db2) }, + { SPH_C32(0xea0c1430), SPH_C32(0x2f9c0000), SPH_C32(0xdb430000), + SPH_C32(0xdd3a0000), SPH_C32(0x7ba47f9c), SPH_C32(0x955a547e), + SPH_C32(0x525b63bb), SPH_C32(0x424d4977), SPH_C32(0x115d2a40), + SPH_C32(0xac880000), SPH_C32(0xe7ca0000), SPH_C32(0x45120000), + SPH_C32(0x2eca7ef6), SPH_C32(0x6116dcff), SPH_C32(0x73e60eca), + SPH_C32(0x318c30b8) }, + { SPH_C32(0x05071640), SPH_C32(0x15610000), SPH_C32(0x86ed0000), + SPH_C32(0xb4730000), SPH_C32(0xe0ab439a), SPH_C32(0xd15fe187), + SPH_C32(0x344f69ea), SPH_C32(0xd002147d), SPH_C32(0xd8362a70), + SPH_C32(0x4bad0000), SPH_C32(0xc84e0000), SPH_C32(0x635d0000), + SPH_C32(0x26a3250f), SPH_C32(0x0cea2dc8), SPH_C32(0x2379674e), + SPH_C32(0xafe59fd0) }, + { SPH_C32(0x373d2800), SPH_C32(0x71500000), SPH_C32(0x95e00000), + SPH_C32(0x0a140000), SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), + SPH_C32(0x456d6d1f), SPH_C32(0x3daac2da), SPH_C32(0x145a3c00), + SPH_C32(0xb9e90000), SPH_C32(0x61270000), SPH_C32(0xf1610000), + SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), SPH_C32(0x47a96720), + SPH_C32(0xe18e24c5) }, + { SPH_C32(0xd8362a70), SPH_C32(0x4bad0000), SPH_C32(0xc84e0000), + SPH_C32(0x635d0000), SPH_C32(0x26a3250f), SPH_C32(0x0cea2dc8), + SPH_C32(0x2379674e), SPH_C32(0xafe59fd0), SPH_C32(0xdd313c30), + SPH_C32(0x5ecc0000), SPH_C32(0x4ea30000), SPH_C32(0xd72e0000), + SPH_C32(0xc6086695), SPH_C32(0xddb5cc4f), SPH_C32(0x17360ea4), + SPH_C32(0x7fe78bad) }, + { SPH_C32(0xfe562830), SPH_C32(0x96750000), SPH_C32(0xba640000), + SPH_C32(0x2c5b0000), SPH_C32(0xb5c542f0), SPH_C32(0x25136906), + SPH_C32(0x15f2049b), SPH_C32(0xa3c36db2), SPH_C32(0x323a3e40), + SPH_C32(0x64310000), SPH_C32(0x130d0000), SPH_C32(0xbe670000), + SPH_C32(0x5d075a93), SPH_C32(0x99b079b6), SPH_C32(0x712204f5), + SPH_C32(0xeda8d6a7) }, + { SPH_C32(0x115d2a40), SPH_C32(0xac880000), SPH_C32(0xe7ca0000), + SPH_C32(0x45120000), SPH_C32(0x2eca7ef6), SPH_C32(0x6116dcff), + SPH_C32(0x73e60eca), SPH_C32(0x318c30b8), SPH_C32(0xfb513e70), + SPH_C32(0x83140000), SPH_C32(0x3c890000), SPH_C32(0x98280000), + SPH_C32(0x556e016a), SPH_C32(0xf44c8881), SPH_C32(0x21bd6d71), + SPH_C32(0x73c179cf) } +}; + +static const sph_u32 T512_8[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x774400f0), SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), + SPH_C32(0x34140000), SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), + SPH_C32(0x0bc3cd1e), SPH_C32(0xcf3775cb), SPH_C32(0xf46c0050), + SPH_C32(0x96180000), SPH_C32(0x14a50000), SPH_C32(0x031f0000), + SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), SPH_C32(0x9ca470d2), + SPH_C32(0x8a341574) }, + { SPH_C32(0xf46c0050), SPH_C32(0x96180000), SPH_C32(0x14a50000), + SPH_C32(0x031f0000), SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), + SPH_C32(0x9ca470d2), SPH_C32(0x8a341574), SPH_C32(0x832800a0), + SPH_C32(0x67420000), SPH_C32(0xe1170000), SPH_C32(0x370b0000), + SPH_C32(0xcba30034), SPH_C32(0x3c34923c), SPH_C32(0x9767bdcc), + SPH_C32(0x450360bf) }, + { SPH_C32(0x832800a0), SPH_C32(0x67420000), SPH_C32(0xe1170000), + SPH_C32(0x370b0000), SPH_C32(0xcba30034), SPH_C32(0x3c34923c), + SPH_C32(0x9767bdcc), SPH_C32(0x450360bf), SPH_C32(0x774400f0), + SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), SPH_C32(0x34140000), + SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), SPH_C32(0x0bc3cd1e), + SPH_C32(0xcf3775cb) }, + { SPH_C32(0xe8870170), SPH_C32(0x9d720000), SPH_C32(0x12db0000), + SPH_C32(0xd4220000), SPH_C32(0xf2886b27), SPH_C32(0xa921e543), + SPH_C32(0x4ef8b518), SPH_C32(0x618813b1), SPH_C32(0xb4370060), + SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), SPH_C32(0x5cae0000), + SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), SPH_C32(0x1b365f3d), + SPH_C32(0xf3d45758) }, + { SPH_C32(0x9fc30180), SPH_C32(0x6c280000), SPH_C32(0xe7690000), + SPH_C32(0xe0360000), SPH_C32(0x7bbf15ab), SPH_C32(0xf3aa0966), + SPH_C32(0x453b7806), SPH_C32(0xaebf667a), SPH_C32(0x405b0030), + SPH_C32(0x9a540000), SPH_C32(0x42670000), SPH_C32(0x5fb10000), + SPH_C32(0xd6c06187), SPH_C32(0x5d81863c), SPH_C32(0x87922fef), + SPH_C32(0x79e0422c) }, + { SPH_C32(0x1ceb0120), SPH_C32(0x0b6a0000), SPH_C32(0x067e0000), + SPH_C32(0xd73d0000), SPH_C32(0xb01c159f), SPH_C32(0xcf9e9b5a), + SPH_C32(0xd25cc5ca), SPH_C32(0xebbc06c5), SPH_C32(0x371f00c0), + SPH_C32(0x6b0e0000), SPH_C32(0xb7d50000), SPH_C32(0x6ba50000), + SPH_C32(0x5ff71f0b), SPH_C32(0x070a6a19), SPH_C32(0x8c51e2f1), + SPH_C32(0xb6d737e7) }, + { SPH_C32(0x6baf01d0), SPH_C32(0xfa300000), SPH_C32(0xf3cc0000), + SPH_C32(0xe3290000), SPH_C32(0x392b6b13), SPH_C32(0x9515777f), + SPH_C32(0xd99f08d4), SPH_C32(0x248b730e), SPH_C32(0xc3730090), + SPH_C32(0xfd160000), SPH_C32(0xa3700000), SPH_C32(0x68ba0000), + SPH_C32(0x1d6361b3), SPH_C32(0x61b51400), SPH_C32(0x10f59223), + SPH_C32(0x3ce32293) }, + { SPH_C32(0xb4370060), SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), + SPH_C32(0x5cae0000), SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), + SPH_C32(0x1b365f3d), SPH_C32(0xf3d45758), SPH_C32(0x5cb00110), + SPH_C32(0x913e0000), SPH_C32(0x44190000), SPH_C32(0x888c0000), + SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), SPH_C32(0x55ceea25), + SPH_C32(0x925c44e9) }, + { SPH_C32(0xc3730090), SPH_C32(0xfd160000), SPH_C32(0xa3700000), + SPH_C32(0x68ba0000), SPH_C32(0x1d6361b3), SPH_C32(0x61b51400), + SPH_C32(0x10f59223), SPH_C32(0x3ce32293), SPH_C32(0xa8dc0140), + SPH_C32(0x07260000), SPH_C32(0x50bc0000), SPH_C32(0x8b930000), + SPH_C32(0x24480aa0), SPH_C32(0xf4a0637f), SPH_C32(0xc96a9af7), + SPH_C32(0x1868519d) }, + { SPH_C32(0x405b0030), SPH_C32(0x9a540000), SPH_C32(0x42670000), + SPH_C32(0x5fb10000), SPH_C32(0xd6c06187), SPH_C32(0x5d81863c), + SPH_C32(0x87922fef), SPH_C32(0x79e0422c), SPH_C32(0xdf9801b0), + SPH_C32(0xf67c0000), SPH_C32(0xa50e0000), SPH_C32(0xbf870000), + SPH_C32(0xad7f742c), SPH_C32(0xae2b8f5a), SPH_C32(0xc2a957e9), + SPH_C32(0xd75f2456) }, + { SPH_C32(0x371f00c0), SPH_C32(0x6b0e0000), SPH_C32(0xb7d50000), + SPH_C32(0x6ba50000), SPH_C32(0x5ff71f0b), SPH_C32(0x070a6a19), + SPH_C32(0x8c51e2f1), SPH_C32(0xb6d737e7), SPH_C32(0x2bf401e0), + SPH_C32(0x60640000), SPH_C32(0xb1ab0000), SPH_C32(0xbc980000), + SPH_C32(0xefeb0a94), SPH_C32(0xc894f143), SPH_C32(0x5e0d273b), + SPH_C32(0x5d6b3122) }, + { SPH_C32(0x5cb00110), SPH_C32(0x913e0000), SPH_C32(0x44190000), + SPH_C32(0x888c0000), SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), + SPH_C32(0x55ceea25), SPH_C32(0x925c44e9), SPH_C32(0xe8870170), + SPH_C32(0x9d720000), SPH_C32(0x12db0000), SPH_C32(0xd4220000), + SPH_C32(0xf2886b27), SPH_C32(0xa921e543), SPH_C32(0x4ef8b518), + SPH_C32(0x618813b1) }, + { SPH_C32(0x2bf401e0), SPH_C32(0x60640000), SPH_C32(0xb1ab0000), + SPH_C32(0xbc980000), SPH_C32(0xefeb0a94), SPH_C32(0xc894f143), + SPH_C32(0x5e0d273b), SPH_C32(0x5d6b3122), SPH_C32(0x1ceb0120), + SPH_C32(0x0b6a0000), SPH_C32(0x067e0000), SPH_C32(0xd73d0000), + SPH_C32(0xb01c159f), SPH_C32(0xcf9e9b5a), SPH_C32(0xd25cc5ca), + SPH_C32(0xebbc06c5) }, + { SPH_C32(0xa8dc0140), SPH_C32(0x07260000), SPH_C32(0x50bc0000), + SPH_C32(0x8b930000), SPH_C32(0x24480aa0), SPH_C32(0xf4a0637f), + SPH_C32(0xc96a9af7), SPH_C32(0x1868519d), SPH_C32(0x6baf01d0), + SPH_C32(0xfa300000), SPH_C32(0xf3cc0000), SPH_C32(0xe3290000), + SPH_C32(0x392b6b13), SPH_C32(0x9515777f), SPH_C32(0xd99f08d4), + SPH_C32(0x248b730e) }, + { SPH_C32(0xdf9801b0), SPH_C32(0xf67c0000), SPH_C32(0xa50e0000), + SPH_C32(0xbf870000), SPH_C32(0xad7f742c), SPH_C32(0xae2b8f5a), + SPH_C32(0xc2a957e9), SPH_C32(0xd75f2456), SPH_C32(0x9fc30180), + SPH_C32(0x6c280000), SPH_C32(0xe7690000), SPH_C32(0xe0360000), + SPH_C32(0x7bbf15ab), SPH_C32(0xf3aa0966), SPH_C32(0x453b7806), + SPH_C32(0xaebf667a) } +}; + +static const sph_u32 T512_12[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xf6800005), SPH_C32(0x3443c000), SPH_C32(0x24070000), + SPH_C32(0x8f3d0000), SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), + SPH_C32(0xcdc58b19), SPH_C32(0xd795ba31), SPH_C32(0xa67f0001), + SPH_C32(0x71378000), SPH_C32(0x19fc0000), SPH_C32(0x96db0000), + SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), SPH_C32(0x2c6d478f), + SPH_C32(0xac8e6c88) }, + { SPH_C32(0xa67f0001), SPH_C32(0x71378000), SPH_C32(0x19fc0000), + SPH_C32(0x96db0000), SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), + SPH_C32(0x2c6d478f), SPH_C32(0xac8e6c88), SPH_C32(0x50ff0004), + SPH_C32(0x45744000), SPH_C32(0x3dfb0000), SPH_C32(0x19e60000), + SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), SPH_C32(0xe1a8cc96), + SPH_C32(0x7b1bd6b9) }, + { SPH_C32(0x50ff0004), SPH_C32(0x45744000), SPH_C32(0x3dfb0000), + SPH_C32(0x19e60000), SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), + SPH_C32(0xe1a8cc96), SPH_C32(0x7b1bd6b9), SPH_C32(0xf6800005), + SPH_C32(0x3443c000), SPH_C32(0x24070000), SPH_C32(0x8f3d0000), + SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), SPH_C32(0xcdc58b19), + SPH_C32(0xd795ba31) }, + { SPH_C32(0xf7750009), SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), + SPH_C32(0x04920000), SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), + SPH_C32(0x7a87f14e), SPH_C32(0x9e16981a), SPH_C32(0xd46a0000), + SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), SPH_C32(0x4a290000), + SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), SPH_C32(0x98369604), + SPH_C32(0xf746c320) }, + { SPH_C32(0x01f5000c), SPH_C32(0xfb7f0000), SPH_C32(0xe7d10000), + SPH_C32(0x8baf0000), SPH_C32(0x23a22252), SPH_C32(0xf250e314), + SPH_C32(0xb7427a57), SPH_C32(0x4983222b), SPH_C32(0x72150001), + SPH_C32(0xfcff4000), SPH_C32(0xbc530000), SPH_C32(0xdcf20000), + SPH_C32(0xc6c52f87), SPH_C32(0x227e289f), SPH_C32(0xb45bd18b), + SPH_C32(0x5bc8afa8) }, + { SPH_C32(0x510a0008), SPH_C32(0xbe0b4000), SPH_C32(0xda2a0000), + SPH_C32(0x92490000), SPH_C32(0x381e7454), SPH_C32(0x13229849), + SPH_C32(0x56eab6c1), SPH_C32(0x3298f492), SPH_C32(0x84950004), + SPH_C32(0xc8bc8000), SPH_C32(0x98540000), SPH_C32(0x53cf0000), + SPH_C32(0xe7f2147c), SPH_C32(0x28c6fd31), SPH_C32(0x799e5a92), + SPH_C32(0x8c5d1599) }, + { SPH_C32(0xa78a000d), SPH_C32(0x8a488000), SPH_C32(0xfe2d0000), + SPH_C32(0x1d740000), SPH_C32(0x19294faf), SPH_C32(0x199a4de7), + SPH_C32(0x9b2f3dd8), SPH_C32(0xe50d4ea3), SPH_C32(0x22ea0005), + SPH_C32(0xb98b0000), SPH_C32(0x81a80000), SPH_C32(0xc5140000), + SPH_C32(0xdd797981), SPH_C32(0xc30c53c2), SPH_C32(0x55f31d1d), + SPH_C32(0x20d37911) }, + { SPH_C32(0xd46a0000), SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), + SPH_C32(0x4a290000), SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), + SPH_C32(0x98369604), SPH_C32(0xf746c320), SPH_C32(0x231f0009), + SPH_C32(0x42f40000), SPH_C32(0x66790000), SPH_C32(0x4ebb0000), + SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), SPH_C32(0xe2b1674a), + SPH_C32(0x69505b3a) }, + { SPH_C32(0x22ea0005), SPH_C32(0xb98b0000), SPH_C32(0x81a80000), + SPH_C32(0xc5140000), SPH_C32(0xdd797981), SPH_C32(0xc30c53c2), + SPH_C32(0x55f31d1d), SPH_C32(0x20d37911), SPH_C32(0x85600008), + SPH_C32(0x33c38000), SPH_C32(0x7f850000), SPH_C32(0xd8600000), + SPH_C32(0xc450362e), SPH_C32(0xda961e25), SPH_C32(0xcedc20c5), + SPH_C32(0xc5de37b2) }, + { SPH_C32(0x72150001), SPH_C32(0xfcff4000), SPH_C32(0xbc530000), + SPH_C32(0xdcf20000), SPH_C32(0xc6c52f87), SPH_C32(0x227e289f), + SPH_C32(0xb45bd18b), SPH_C32(0x5bc8afa8), SPH_C32(0x73e0000d), + SPH_C32(0x07804000), SPH_C32(0x5b820000), SPH_C32(0x575d0000), + SPH_C32(0xe5670dd5), SPH_C32(0xd02ecb8b), SPH_C32(0x0319abdc), + SPH_C32(0x124b8d83) }, + { SPH_C32(0x84950004), SPH_C32(0xc8bc8000), SPH_C32(0x98540000), + SPH_C32(0x53cf0000), SPH_C32(0xe7f2147c), SPH_C32(0x28c6fd31), + SPH_C32(0x799e5a92), SPH_C32(0x8c5d1599), SPH_C32(0xd59f000c), + SPH_C32(0x76b7c000), SPH_C32(0x427e0000), SPH_C32(0xc1860000), + SPH_C32(0xdfec6028), SPH_C32(0x3be46578), SPH_C32(0x2f74ec53), + SPH_C32(0xbec5e10b) }, + { SPH_C32(0x231f0009), SPH_C32(0x42f40000), SPH_C32(0x66790000), + SPH_C32(0x4ebb0000), SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), + SPH_C32(0xe2b1674a), SPH_C32(0x69505b3a), SPH_C32(0xf7750009), + SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), SPH_C32(0x04920000), + SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), SPH_C32(0x7a87f14e), + SPH_C32(0x9e16981a) }, + { SPH_C32(0xd59f000c), SPH_C32(0x76b7c000), SPH_C32(0x427e0000), + SPH_C32(0xc1860000), SPH_C32(0xdfec6028), SPH_C32(0x3be46578), + SPH_C32(0x2f74ec53), SPH_C32(0xbec5e10b), SPH_C32(0x510a0008), + SPH_C32(0xbe0b4000), SPH_C32(0xda2a0000), SPH_C32(0x92490000), + SPH_C32(0x381e7454), SPH_C32(0x13229849), SPH_C32(0x56eab6c1), + SPH_C32(0x3298f492) }, + { SPH_C32(0x85600008), SPH_C32(0x33c38000), SPH_C32(0x7f850000), + SPH_C32(0xd8600000), SPH_C32(0xc450362e), SPH_C32(0xda961e25), + SPH_C32(0xcedc20c5), SPH_C32(0xc5de37b2), SPH_C32(0xa78a000d), + SPH_C32(0x8a488000), SPH_C32(0xfe2d0000), SPH_C32(0x1d740000), + SPH_C32(0x19294faf), SPH_C32(0x199a4de7), SPH_C32(0x9b2f3dd8), + SPH_C32(0xe50d4ea3) }, + { SPH_C32(0x73e0000d), SPH_C32(0x07804000), SPH_C32(0x5b820000), + SPH_C32(0x575d0000), SPH_C32(0xe5670dd5), SPH_C32(0xd02ecb8b), + SPH_C32(0x0319abdc), SPH_C32(0x124b8d83), SPH_C32(0x01f5000c), + SPH_C32(0xfb7f0000), SPH_C32(0xe7d10000), SPH_C32(0x8baf0000), + SPH_C32(0x23a22252), SPH_C32(0xf250e314), SPH_C32(0xb7427a57), + SPH_C32(0x4983222b) } +}; + +static const sph_u32 T512_16[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x75a40000), SPH_C32(0xc28b2700), SPH_C32(0x94a40000), + SPH_C32(0x90f50000), SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), + SPH_C32(0x1767c483), SPH_C32(0xaedf667e), SPH_C32(0xd1660000), + SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), SPH_C32(0xf6940000), + SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), SPH_C32(0xb4431b17), + SPH_C32(0x857f3c2b) }, + { SPH_C32(0xd1660000), SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), + SPH_C32(0xf6940000), SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), + SPH_C32(0xb4431b17), SPH_C32(0x857f3c2b), SPH_C32(0xa4c20000), + SPH_C32(0xd9372400), SPH_C32(0x0a480000), SPH_C32(0x66610000), + SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), SPH_C32(0xa324df94), + SPH_C32(0x2ba05a55) }, + { SPH_C32(0xa4c20000), SPH_C32(0xd9372400), SPH_C32(0x0a480000), + SPH_C32(0x66610000), SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), + SPH_C32(0xa324df94), SPH_C32(0x2ba05a55), SPH_C32(0x75a40000), + SPH_C32(0xc28b2700), SPH_C32(0x94a40000), SPH_C32(0x90f50000), + SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), SPH_C32(0x1767c483), + SPH_C32(0xaedf667e) }, + { SPH_C32(0x75c90003), SPH_C32(0x0e10c000), SPH_C32(0xd1200000), + SPH_C32(0xbaea0000), SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), + SPH_C32(0xbb28761d), SPH_C32(0x00b72e2b), SPH_C32(0xeecf0001), + SPH_C32(0x6f564000), SPH_C32(0xf33e0000), SPH_C32(0xa79e0000), + SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), SPH_C32(0x4a3b40ba), + SPH_C32(0xfeabf254) }, + { SPH_C32(0x006d0003), SPH_C32(0xcc9be700), SPH_C32(0x45840000), + SPH_C32(0x2a1f0000), SPH_C32(0x70bc78de), SPH_C32(0xce96bcf9), + SPH_C32(0xac4fb29e), SPH_C32(0xae684855), SPH_C32(0x3fa90001), + SPH_C32(0x74ea4300), SPH_C32(0x6dd20000), SPH_C32(0x510a0000), + SPH_C32(0xbeb7373e), SPH_C32(0x78611737), SPH_C32(0xfe785bad), + SPH_C32(0x7bd4ce7f) }, + { SPH_C32(0xa4af0003), SPH_C32(0x15acc300), SPH_C32(0x4fcc0000), + SPH_C32(0x4c7e0000), SPH_C32(0x88c66a19), SPH_C32(0x48284ba5), + SPH_C32(0x0f6b6d0a), SPH_C32(0x85c81200), SPH_C32(0x4a0d0001), + SPH_C32(0xb6616400), SPH_C32(0xf9760000), SPH_C32(0xc1ff0000), + SPH_C32(0x45cf60de), SPH_C32(0x31af1c99), SPH_C32(0xe91f9f2e), + SPH_C32(0xd50ba801) }, + { SPH_C32(0xd10b0003), SPH_C32(0xd727e400), SPH_C32(0xdb680000), + SPH_C32(0xdc8b0000), SPH_C32(0x73be3df9), SPH_C32(0x01e6400b), + SPH_C32(0x180ca989), SPH_C32(0x2b17747e), SPH_C32(0x9b6b0001), + SPH_C32(0xaddd6700), SPH_C32(0x679a0000), SPH_C32(0x376b0000), + SPH_C32(0x46cd25f9), SPH_C32(0xfedfe06b), SPH_C32(0x5d5c8439), + SPH_C32(0x5074942a) }, + { SPH_C32(0xeecf0001), SPH_C32(0x6f564000), SPH_C32(0xf33e0000), + SPH_C32(0xa79e0000), SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), + SPH_C32(0x4a3b40ba), SPH_C32(0xfeabf254), SPH_C32(0x9b060002), + SPH_C32(0x61468000), SPH_C32(0x221e0000), SPH_C32(0x1d740000), + SPH_C32(0x36715d27), SPH_C32(0x30495c92), SPH_C32(0xf11336a7), + SPH_C32(0xfe1cdc7f) }, + { SPH_C32(0x9b6b0001), SPH_C32(0xaddd6700), SPH_C32(0x679a0000), + SPH_C32(0x376b0000), SPH_C32(0x46cd25f9), SPH_C32(0xfedfe06b), + SPH_C32(0x5d5c8439), SPH_C32(0x5074942a), SPH_C32(0x4a600002), + SPH_C32(0x7afa8300), SPH_C32(0xbcf20000), SPH_C32(0xebe00000), + SPH_C32(0x35731800), SPH_C32(0xff39a060), SPH_C32(0x45502db0), + SPH_C32(0x7b63e054) }, + { SPH_C32(0x3fa90001), SPH_C32(0x74ea4300), SPH_C32(0x6dd20000), + SPH_C32(0x510a0000), SPH_C32(0xbeb7373e), SPH_C32(0x78611737), + SPH_C32(0xfe785bad), SPH_C32(0x7bd4ce7f), SPH_C32(0x3fc40002), + SPH_C32(0xb871a400), SPH_C32(0x28560000), SPH_C32(0x7b150000), + SPH_C32(0xce0b4fe0), SPH_C32(0xb6f7abce), SPH_C32(0x5237e933), + SPH_C32(0xd5bc862a) }, + { SPH_C32(0x4a0d0001), SPH_C32(0xb6616400), SPH_C32(0xf9760000), + SPH_C32(0xc1ff0000), SPH_C32(0x45cf60de), SPH_C32(0x31af1c99), + SPH_C32(0xe91f9f2e), SPH_C32(0xd50ba801), SPH_C32(0xeea20002), + SPH_C32(0xa3cda700), SPH_C32(0xb6ba0000), SPH_C32(0x8d810000), + SPH_C32(0xcd090ac7), SPH_C32(0x7987573c), SPH_C32(0xe674f224), + SPH_C32(0x50c3ba01) }, + { SPH_C32(0x9b060002), SPH_C32(0x61468000), SPH_C32(0x221e0000), + SPH_C32(0x1d740000), SPH_C32(0x36715d27), SPH_C32(0x30495c92), + SPH_C32(0xf11336a7), SPH_C32(0xfe1cdc7f), SPH_C32(0x75c90003), + SPH_C32(0x0e10c000), SPH_C32(0xd1200000), SPH_C32(0xbaea0000), + SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), SPH_C32(0xbb28761d), + SPH_C32(0x00b72e2b) }, + { SPH_C32(0xeea20002), SPH_C32(0xa3cda700), SPH_C32(0xb6ba0000), + SPH_C32(0x8d810000), SPH_C32(0xcd090ac7), SPH_C32(0x7987573c), + SPH_C32(0xe674f224), SPH_C32(0x50c3ba01), SPH_C32(0xa4af0003), + SPH_C32(0x15acc300), SPH_C32(0x4fcc0000), SPH_C32(0x4c7e0000), + SPH_C32(0x88c66a19), SPH_C32(0x48284ba5), SPH_C32(0x0f6b6d0a), + SPH_C32(0x85c81200) }, + { SPH_C32(0x4a600002), SPH_C32(0x7afa8300), SPH_C32(0xbcf20000), + SPH_C32(0xebe00000), SPH_C32(0x35731800), SPH_C32(0xff39a060), + SPH_C32(0x45502db0), SPH_C32(0x7b63e054), SPH_C32(0xd10b0003), + SPH_C32(0xd727e400), SPH_C32(0xdb680000), SPH_C32(0xdc8b0000), + SPH_C32(0x73be3df9), SPH_C32(0x01e6400b), SPH_C32(0x180ca989), + SPH_C32(0x2b17747e) }, + { SPH_C32(0x3fc40002), SPH_C32(0xb871a400), SPH_C32(0x28560000), + SPH_C32(0x7b150000), SPH_C32(0xce0b4fe0), SPH_C32(0xb6f7abce), + SPH_C32(0x5237e933), SPH_C32(0xd5bc862a), SPH_C32(0x006d0003), + SPH_C32(0xcc9be700), SPH_C32(0x45840000), SPH_C32(0x2a1f0000), + SPH_C32(0x70bc78de), SPH_C32(0xce96bcf9), SPH_C32(0xac4fb29e), + SPH_C32(0xae684855) } +}; + +static const sph_u32 T512_20[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x0c720000), SPH_C32(0x49e50f00), SPH_C32(0x42790000), + SPH_C32(0x5cea0000), SPH_C32(0x33aa301a), SPH_C32(0x15822514), + SPH_C32(0x95a34b7b), SPH_C32(0xb44b0090), SPH_C32(0xfe220000), + SPH_C32(0xa7580500), SPH_C32(0x25d10000), SPH_C32(0xf7600000), + SPH_C32(0x893178da), SPH_C32(0x1fd4f860), SPH_C32(0x4ed0a315), + SPH_C32(0xa123ff9f) }, + { SPH_C32(0xfe220000), SPH_C32(0xa7580500), SPH_C32(0x25d10000), + SPH_C32(0xf7600000), SPH_C32(0x893178da), SPH_C32(0x1fd4f860), + SPH_C32(0x4ed0a315), SPH_C32(0xa123ff9f), SPH_C32(0xf2500000), + SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), SPH_C32(0xab8a0000), + SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), SPH_C32(0xdb73e86e), + SPH_C32(0x1568ff0f) }, + { SPH_C32(0xf2500000), SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), + SPH_C32(0xab8a0000), SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), + SPH_C32(0xdb73e86e), SPH_C32(0x1568ff0f), SPH_C32(0x0c720000), + SPH_C32(0x49e50f00), SPH_C32(0x42790000), SPH_C32(0x5cea0000), + SPH_C32(0x33aa301a), SPH_C32(0x15822514), SPH_C32(0x95a34b7b), + SPH_C32(0xb44b0090) }, + { SPH_C32(0x45180000), SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), + SPH_C32(0x3b480000), SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), + SPH_C32(0x16bca6b0), SPH_C32(0xdf33f4df), SPH_C32(0xb83d0000), + SPH_C32(0x16710600), SPH_C32(0x379a0000), SPH_C32(0xf5b10000), + SPH_C32(0x228161ac), SPH_C32(0xae48f145), SPH_C32(0x66241616), + SPH_C32(0xc5c1eb3e) }, + { SPH_C32(0x496a0000), SPH_C32(0xec501800), SPH_C32(0xbb130000), + SPH_C32(0x67a20000), SPH_C32(0x2d662436), SPH_C32(0x3691b0c2), + SPH_C32(0x831fedcb), SPH_C32(0x6b78f44f), SPH_C32(0x461f0000), + SPH_C32(0xb1290300), SPH_C32(0x124b0000), SPH_C32(0x02d10000), + SPH_C32(0xabb01976), SPH_C32(0xb19c0925), SPH_C32(0x28f4b503), + SPH_C32(0x64e214a1) }, + { SPH_C32(0xbb3a0000), SPH_C32(0x02ed1200), SPH_C32(0xdcbb0000), + SPH_C32(0xcc280000), SPH_C32(0x97fd6cf6), SPH_C32(0x3cc76db6), + SPH_C32(0x586c05a5), SPH_C32(0x7e100b40), SPH_C32(0x4a6d0000), + SPH_C32(0xf8cc0c00), SPH_C32(0x50320000), SPH_C32(0x5e3b0000), + SPH_C32(0x981a296c), SPH_C32(0xa41e2c31), SPH_C32(0xbd57fe78), + SPH_C32(0xd0a91431) }, + { SPH_C32(0xb7480000), SPH_C32(0x4b081d00), SPH_C32(0x9ec20000), + SPH_C32(0x90c20000), SPH_C32(0xa4575cec), SPH_C32(0x294548a2), + SPH_C32(0xcdcf4ede), SPH_C32(0xca5b0bd0), SPH_C32(0xb44f0000), + SPH_C32(0x5f940900), SPH_C32(0x75e30000), SPH_C32(0xa95b0000), + SPH_C32(0x112b51b6), SPH_C32(0xbbcad451), SPH_C32(0xf3875d6d), + SPH_C32(0x718aebae) }, + { SPH_C32(0xb83d0000), SPH_C32(0x16710600), SPH_C32(0x379a0000), + SPH_C32(0xf5b10000), SPH_C32(0x228161ac), SPH_C32(0xae48f145), + SPH_C32(0x66241616), SPH_C32(0xc5c1eb3e), SPH_C32(0xfd250000), + SPH_C32(0xb3c41100), SPH_C32(0xcef00000), SPH_C32(0xcef90000), + SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), SPH_C32(0x7098b0a6), + SPH_C32(0x1af21fe1) }, + { SPH_C32(0xb44f0000), SPH_C32(0x5f940900), SPH_C32(0x75e30000), + SPH_C32(0xa95b0000), SPH_C32(0x112b51b6), SPH_C32(0xbbcad451), + SPH_C32(0xf3875d6d), SPH_C32(0x718aebae), SPH_C32(0x03070000), + SPH_C32(0x149c1400), SPH_C32(0xeb210000), SPH_C32(0x39990000), + SPH_C32(0xb57c0d5a), SPH_C32(0x928f9cf3), SPH_C32(0x3e4813b3), + SPH_C32(0xbbd1e07e) }, + { SPH_C32(0x461f0000), SPH_C32(0xb1290300), SPH_C32(0x124b0000), + SPH_C32(0x02d10000), SPH_C32(0xabb01976), SPH_C32(0xb19c0925), + SPH_C32(0x28f4b503), SPH_C32(0x64e214a1), SPH_C32(0x0f750000), + SPH_C32(0x5d791b00), SPH_C32(0xa9580000), SPH_C32(0x65730000), + SPH_C32(0x86d63d40), SPH_C32(0x870db9e7), SPH_C32(0xabeb58c8), + SPH_C32(0x0f9ae0ee) }, + { SPH_C32(0x4a6d0000), SPH_C32(0xf8cc0c00), SPH_C32(0x50320000), + SPH_C32(0x5e3b0000), SPH_C32(0x981a296c), SPH_C32(0xa41e2c31), + SPH_C32(0xbd57fe78), SPH_C32(0xd0a91431), SPH_C32(0xf1570000), + SPH_C32(0xfa211e00), SPH_C32(0x8c890000), SPH_C32(0x92130000), + SPH_C32(0x0fe7459a), SPH_C32(0x98d94187), SPH_C32(0xe53bfbdd), + SPH_C32(0xaeb91f71) }, + { SPH_C32(0xfd250000), SPH_C32(0xb3c41100), SPH_C32(0xcef00000), + SPH_C32(0xcef90000), SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), + SPH_C32(0x7098b0a6), SPH_C32(0x1af21fe1), SPH_C32(0x45180000), + SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), SPH_C32(0x3b480000), + SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), SPH_C32(0x16bca6b0), + SPH_C32(0xdf33f4df) }, + { SPH_C32(0xf1570000), SPH_C32(0xfa211e00), SPH_C32(0x8c890000), + SPH_C32(0x92130000), SPH_C32(0x0fe7459a), SPH_C32(0x98d94187), + SPH_C32(0xe53bfbdd), SPH_C32(0xaeb91f71), SPH_C32(0xbb3a0000), + SPH_C32(0x02ed1200), SPH_C32(0xdcbb0000), SPH_C32(0xcc280000), + SPH_C32(0x97fd6cf6), SPH_C32(0x3cc76db6), SPH_C32(0x586c05a5), + SPH_C32(0x7e100b40) }, + { SPH_C32(0x03070000), SPH_C32(0x149c1400), SPH_C32(0xeb210000), + SPH_C32(0x39990000), SPH_C32(0xb57c0d5a), SPH_C32(0x928f9cf3), + SPH_C32(0x3e4813b3), SPH_C32(0xbbd1e07e), SPH_C32(0xb7480000), + SPH_C32(0x4b081d00), SPH_C32(0x9ec20000), SPH_C32(0x90c20000), + SPH_C32(0xa4575cec), SPH_C32(0x294548a2), SPH_C32(0xcdcf4ede), + SPH_C32(0xca5b0bd0) }, + { SPH_C32(0x0f750000), SPH_C32(0x5d791b00), SPH_C32(0xa9580000), + SPH_C32(0x65730000), SPH_C32(0x86d63d40), SPH_C32(0x870db9e7), + SPH_C32(0xabeb58c8), SPH_C32(0x0f9ae0ee), SPH_C32(0x496a0000), + SPH_C32(0xec501800), SPH_C32(0xbb130000), SPH_C32(0x67a20000), + SPH_C32(0x2d662436), SPH_C32(0x3691b0c2), SPH_C32(0x831fedcb), + SPH_C32(0x6b78f44f) } +}; + +static const sph_u32 T512_24[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x54500000), SPH_C32(0x0671005c), SPH_C32(0x25ae0000), + SPH_C32(0x6a1e0000), SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), + SPH_C32(0xbfba18c3), SPH_C32(0x7e715d17), SPH_C32(0xbc8d0000), + SPH_C32(0xfc3b0018), SPH_C32(0x19830000), SPH_C32(0xd10b0000), + SPH_C32(0xae1878c4), SPH_C32(0x42a69856), SPH_C32(0x0012da37), + SPH_C32(0x2c3b504e) }, + { SPH_C32(0xbc8d0000), SPH_C32(0xfc3b0018), SPH_C32(0x19830000), + SPH_C32(0xd10b0000), SPH_C32(0xae1878c4), SPH_C32(0x42a69856), + SPH_C32(0x0012da37), SPH_C32(0x2c3b504e), SPH_C32(0xe8dd0000), + SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), SPH_C32(0xbb150000), + SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), SPH_C32(0xbfa8c2f4), + SPH_C32(0x524a0d59) }, + { SPH_C32(0xe8dd0000), SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), + SPH_C32(0xbb150000), SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), + SPH_C32(0xbfa8c2f4), SPH_C32(0x524a0d59), SPH_C32(0x54500000), + SPH_C32(0x0671005c), SPH_C32(0x25ae0000), SPH_C32(0x6a1e0000), + SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), SPH_C32(0xbfba18c3), + SPH_C32(0x7e715d17) }, + { SPH_C32(0x69510000), SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), + SPH_C32(0xac2f0000), SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), + SPH_C32(0x87ec287c), SPH_C32(0xbce1a3ce), SPH_C32(0xc6730000), + SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), SPH_C32(0x218d0000), + SPH_C32(0x23111587), SPH_C32(0x7913512f), SPH_C32(0x1d28ac88), + SPH_C32(0x378dd173) }, + { SPH_C32(0x3d010000), SPH_C32(0xd29000c0), SPH_C32(0xe68d0000), + SPH_C32(0xc6310000), SPH_C32(0xca304571), SPH_C32(0xa8ea90ce), + SPH_C32(0x385630bf), SPH_C32(0xc290fed9), SPH_C32(0x7afe0000), + SPH_C32(0x53b60014), SPH_C32(0xbd420000), SPH_C32(0xf0860000), + SPH_C32(0x8d096d43), SPH_C32(0x3bb5c979), SPH_C32(0x1d3a76bf), + SPH_C32(0x1bb6813d) }, + { SPH_C32(0xd5dc0000), SPH_C32(0x28da0084), SPH_C32(0xdaa00000), + SPH_C32(0x7d240000), SPH_C32(0x4a8d736a), SPH_C32(0x8c028d8a), + SPH_C32(0x87fef24b), SPH_C32(0x90daf380), SPH_C32(0x2eae0000), + SPH_C32(0x55c70048), SPH_C32(0x98ec0000), SPH_C32(0x9a980000), + SPH_C32(0xa3ac239c), SPH_C32(0x5dfb4c6b), SPH_C32(0xa2806e7c), + SPH_C32(0x65c7dc2a) }, + { SPH_C32(0x818c0000), SPH_C32(0x2eab00d8), SPH_C32(0xff0e0000), + SPH_C32(0x173a0000), SPH_C32(0x64283db5), SPH_C32(0xea4c0898), + SPH_C32(0x3844ea88), SPH_C32(0xeeabae97), SPH_C32(0x92230000), + SPH_C32(0xa9fc0050), SPH_C32(0x816f0000), SPH_C32(0x4b930000), + SPH_C32(0x0db45b58), SPH_C32(0x1f5dd43d), SPH_C32(0xa292b44b), + SPH_C32(0x49fc8c64) }, + { SPH_C32(0xc6730000), SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), + SPH_C32(0x218d0000), SPH_C32(0x23111587), SPH_C32(0x7913512f), + SPH_C32(0x1d28ac88), SPH_C32(0x378dd173), SPH_C32(0xaf220000), + SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), SPH_C32(0x8da20000), + SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), SPH_C32(0x9ac484f4), + SPH_C32(0x8b6c72bd) }, + { SPH_C32(0x92230000), SPH_C32(0xa9fc0050), SPH_C32(0x816f0000), + SPH_C32(0x4b930000), SPH_C32(0x0db45b58), SPH_C32(0x1f5dd43d), + SPH_C32(0xa292b44b), SPH_C32(0x49fc8c64), SPH_C32(0x13af0000), + SPH_C32(0x87570088), SPH_C32(0x7e610000), SPH_C32(0x5ca90000), + SPH_C32(0x699c66ed), SPH_C32(0xf511dca5), SPH_C32(0x9ad65ec3), + SPH_C32(0xa75722f3) }, + { SPH_C32(0x7afe0000), SPH_C32(0x53b60014), SPH_C32(0xbd420000), + SPH_C32(0xf0860000), SPH_C32(0x8d096d43), SPH_C32(0x3bb5c979), + SPH_C32(0x1d3a76bf), SPH_C32(0x1bb6813d), SPH_C32(0x47ff0000), + SPH_C32(0x812600d4), SPH_C32(0x5bcf0000), SPH_C32(0x36b70000), + SPH_C32(0x47392832), SPH_C32(0x935f59b7), SPH_C32(0x256c4600), + SPH_C32(0xd9267fe4) }, + { SPH_C32(0x2eae0000), SPH_C32(0x55c70048), SPH_C32(0x98ec0000), + SPH_C32(0x9a980000), SPH_C32(0xa3ac239c), SPH_C32(0x5dfb4c6b), + SPH_C32(0xa2806e7c), SPH_C32(0x65c7dc2a), SPH_C32(0xfb720000), + SPH_C32(0x7d1d00cc), SPH_C32(0x424c0000), SPH_C32(0xe7bc0000), + SPH_C32(0xe92150f6), SPH_C32(0xd1f9c1e1), SPH_C32(0x257e9c37), + SPH_C32(0xf51d2faa) }, + { SPH_C32(0xaf220000), SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), + SPH_C32(0x8da20000), SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), + SPH_C32(0x9ac484f4), SPH_C32(0x8b6c72bd), SPH_C32(0x69510000), + SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), SPH_C32(0xac2f0000), + SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), SPH_C32(0x87ec287c), + SPH_C32(0xbce1a3ce) }, + { SPH_C32(0xfb720000), SPH_C32(0x7d1d00cc), SPH_C32(0x424c0000), + SPH_C32(0xe7bc0000), SPH_C32(0xe92150f6), SPH_C32(0xd1f9c1e1), + SPH_C32(0x257e9c37), SPH_C32(0xf51d2faa), SPH_C32(0xd5dc0000), + SPH_C32(0x28da0084), SPH_C32(0xdaa00000), SPH_C32(0x7d240000), + SPH_C32(0x4a8d736a), SPH_C32(0x8c028d8a), SPH_C32(0x87fef24b), + SPH_C32(0x90daf380) }, + { SPH_C32(0x13af0000), SPH_C32(0x87570088), SPH_C32(0x7e610000), + SPH_C32(0x5ca90000), SPH_C32(0x699c66ed), SPH_C32(0xf511dca5), + SPH_C32(0x9ad65ec3), SPH_C32(0xa75722f3), SPH_C32(0x818c0000), + SPH_C32(0x2eab00d8), SPH_C32(0xff0e0000), SPH_C32(0x173a0000), + SPH_C32(0x64283db5), SPH_C32(0xea4c0898), SPH_C32(0x3844ea88), + SPH_C32(0xeeabae97) }, + { SPH_C32(0x47ff0000), SPH_C32(0x812600d4), SPH_C32(0x5bcf0000), + SPH_C32(0x36b70000), SPH_C32(0x47392832), SPH_C32(0x935f59b7), + SPH_C32(0x256c4600), SPH_C32(0xd9267fe4), SPH_C32(0x3d010000), + SPH_C32(0xd29000c0), SPH_C32(0xe68d0000), SPH_C32(0xc6310000), + SPH_C32(0xca304571), SPH_C32(0xa8ea90ce), SPH_C32(0x385630bf), + SPH_C32(0xc290fed9) } +}; + +static const sph_u32 T512_28[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x86790000), SPH_C32(0x3f390002), SPH_C32(0xe19ae000), + SPH_C32(0x98560000), SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), + SPH_C32(0xd3dd4944), SPH_C32(0x161ddab9), SPH_C32(0x30b70000), + SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), SPH_C32(0x42c40000), + SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), SPH_C32(0x21afa1ea), + SPH_C32(0xb0a51834) }, + { SPH_C32(0x30b70000), SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), + SPH_C32(0x42c40000), SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), + SPH_C32(0x21afa1ea), SPH_C32(0xb0a51834), SPH_C32(0xb6ce0000), + SPH_C32(0xdae90002), SPH_C32(0x156e8000), SPH_C32(0xda920000), + SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), SPH_C32(0xf272e8ae), + SPH_C32(0xa6b8c28d) }, + { SPH_C32(0xb6ce0000), SPH_C32(0xdae90002), SPH_C32(0x156e8000), + SPH_C32(0xda920000), SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), + SPH_C32(0xf272e8ae), SPH_C32(0xa6b8c28d), SPH_C32(0x86790000), + SPH_C32(0x3f390002), SPH_C32(0xe19ae000), SPH_C32(0x98560000), + SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), SPH_C32(0xd3dd4944), + SPH_C32(0x161ddab9) }, + { SPH_C32(0x14190000), SPH_C32(0x23ca003c), SPH_C32(0x50df0000), + SPH_C32(0x44b60000), SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), + SPH_C32(0x61e610b0), SPH_C32(0xdbcadb80), SPH_C32(0xe3430000), + SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), SPH_C32(0xaa4e0000), + SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), SPH_C32(0x123db156), + SPH_C32(0x3a4e99d7) }, + { SPH_C32(0x92600000), SPH_C32(0x1cf3003e), SPH_C32(0xb145e000), + SPH_C32(0xdce00000), SPH_C32(0x8e0900be), SPH_C32(0x727b649f), + SPH_C32(0xb23b59f4), SPH_C32(0xcdd70139), SPH_C32(0xd3f40000), + SPH_C32(0xdf9e0014), SPH_C32(0x06326000), SPH_C32(0xe88a0000), + SPH_C32(0xb8a67fcc), SPH_C32(0x5dd12a75), SPH_C32(0x339210bc), + SPH_C32(0x8aeb81e3) }, + { SPH_C32(0x24ae0000), SPH_C32(0xc61a003c), SPH_C32(0xa42b6000), + SPH_C32(0x06720000), SPH_C32(0x78d45ada), SPH_C32(0x44493815), + SPH_C32(0x4049b15a), SPH_C32(0x6b6fc3b4), SPH_C32(0x558d0000), + SPH_C32(0xe0a70016), SPH_C32(0xe7a88000), SPH_C32(0x70dc0000), + SPH_C32(0x2dc318c2), SPH_C32(0x1359e29f), SPH_C32(0xe04f59f8), + SPH_C32(0x9cf65b5a) }, + { SPH_C32(0xa2d70000), SPH_C32(0xf923003e), SPH_C32(0x45b18000), + SPH_C32(0x9e240000), SPH_C32(0xedb13dd4), SPH_C32(0x0ac1f0ff), + SPH_C32(0x9394f81e), SPH_C32(0x7d72190d), SPH_C32(0x653a0000), + SPH_C32(0x05770016), SPH_C32(0x135ce000), SPH_C32(0x32180000), + SPH_C32(0x4e7b25a8), SPH_C32(0x6be376ff), SPH_C32(0xc1e0f812), + SPH_C32(0x2c53436e) }, + { SPH_C32(0xe3430000), SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), + SPH_C32(0xaa4e0000), SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), + SPH_C32(0x123db156), SPH_C32(0x3a4e99d7), SPH_C32(0xf75a0000), + SPH_C32(0x19840028), SPH_C32(0xa2190000), SPH_C32(0xeef80000), + SPH_C32(0xc0722516), SPH_C32(0x19981260), SPH_C32(0x73dba1e6), + SPH_C32(0xe1844257) }, + { SPH_C32(0x653a0000), SPH_C32(0x05770016), SPH_C32(0x135ce000), + SPH_C32(0x32180000), SPH_C32(0x4e7b25a8), SPH_C32(0x6be376ff), + SPH_C32(0xc1e0f812), SPH_C32(0x2c53436e), SPH_C32(0xc7ed0000), + SPH_C32(0xfc540028), SPH_C32(0x56ed6000), SPH_C32(0xac3c0000), + SPH_C32(0xa3ca187c), SPH_C32(0x61228600), SPH_C32(0x5274000c), + SPH_C32(0x51215a63) }, + { SPH_C32(0xd3f40000), SPH_C32(0xdf9e0014), SPH_C32(0x06326000), + SPH_C32(0xe88a0000), SPH_C32(0xb8a67fcc), SPH_C32(0x5dd12a75), + SPH_C32(0x339210bc), SPH_C32(0x8aeb81e3), SPH_C32(0x41940000), + SPH_C32(0xc36d002a), SPH_C32(0xb7778000), SPH_C32(0x346a0000), + SPH_C32(0x36af7f72), SPH_C32(0x2faa4eea), SPH_C32(0x81a94948), + SPH_C32(0x473c80da) }, + { SPH_C32(0x558d0000), SPH_C32(0xe0a70016), SPH_C32(0xe7a88000), + SPH_C32(0x70dc0000), SPH_C32(0x2dc318c2), SPH_C32(0x1359e29f), + SPH_C32(0xe04f59f8), SPH_C32(0x9cf65b5a), SPH_C32(0x71230000), + SPH_C32(0x26bd002a), SPH_C32(0x4383e000), SPH_C32(0x76ae0000), + SPH_C32(0x55174218), SPH_C32(0x5710da8a), SPH_C32(0xa006e8a2), + SPH_C32(0xf79998ee) }, + { SPH_C32(0xf75a0000), SPH_C32(0x19840028), SPH_C32(0xa2190000), + SPH_C32(0xeef80000), SPH_C32(0xc0722516), SPH_C32(0x19981260), + SPH_C32(0x73dba1e6), SPH_C32(0xe1844257), SPH_C32(0x14190000), + SPH_C32(0x23ca003c), SPH_C32(0x50df0000), SPH_C32(0x44b60000), + SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), SPH_C32(0x61e610b0), + SPH_C32(0xdbcadb80) }, + { SPH_C32(0x71230000), SPH_C32(0x26bd002a), SPH_C32(0x4383e000), + SPH_C32(0x76ae0000), SPH_C32(0x55174218), SPH_C32(0x5710da8a), + SPH_C32(0xa006e8a2), SPH_C32(0xf79998ee), SPH_C32(0x24ae0000), + SPH_C32(0xc61a003c), SPH_C32(0xa42b6000), SPH_C32(0x06720000), + SPH_C32(0x78d45ada), SPH_C32(0x44493815), SPH_C32(0x4049b15a), + SPH_C32(0x6b6fc3b4) }, + { SPH_C32(0xc7ed0000), SPH_C32(0xfc540028), SPH_C32(0x56ed6000), + SPH_C32(0xac3c0000), SPH_C32(0xa3ca187c), SPH_C32(0x61228600), + SPH_C32(0x5274000c), SPH_C32(0x51215a63), SPH_C32(0xa2d70000), + SPH_C32(0xf923003e), SPH_C32(0x45b18000), SPH_C32(0x9e240000), + SPH_C32(0xedb13dd4), SPH_C32(0x0ac1f0ff), SPH_C32(0x9394f81e), + SPH_C32(0x7d72190d) }, + { SPH_C32(0x41940000), SPH_C32(0xc36d002a), SPH_C32(0xb7778000), + SPH_C32(0x346a0000), SPH_C32(0x36af7f72), SPH_C32(0x2faa4eea), + SPH_C32(0x81a94948), SPH_C32(0x473c80da), SPH_C32(0x92600000), + SPH_C32(0x1cf3003e), SPH_C32(0xb145e000), SPH_C32(0xdce00000), + SPH_C32(0x8e0900be), SPH_C32(0x727b649f), SPH_C32(0xb23b59f4), + SPH_C32(0xcdd70139) } +}; + +static const sph_u32 T512_32[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xac480000), SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), + SPH_C32(0x03430000), SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), + SPH_C32(0xfe72c7fe), SPH_C32(0x91e478f6), SPH_C32(0x1e4e0000), + SPH_C32(0xdecf0000), SPH_C32(0x6df80180), SPH_C32(0x77240000), + SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), SPH_C32(0xcda31812), + SPH_C32(0x98aa496e) }, + { SPH_C32(0x1e4e0000), SPH_C32(0xdecf0000), SPH_C32(0x6df80180), + SPH_C32(0x77240000), SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), + SPH_C32(0xcda31812), SPH_C32(0x98aa496e), SPH_C32(0xb2060000), + SPH_C32(0xc5690000), SPH_C32(0x28031200), SPH_C32(0x74670000), + SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), SPH_C32(0x33d1dfec), + SPH_C32(0x094e3198) }, + { SPH_C32(0xb2060000), SPH_C32(0xc5690000), SPH_C32(0x28031200), + SPH_C32(0x74670000), SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), + SPH_C32(0x33d1dfec), SPH_C32(0x094e3198), SPH_C32(0xac480000), + SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), SPH_C32(0x03430000), + SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), SPH_C32(0xfe72c7fe), + SPH_C32(0x91e478f6) }, + { SPH_C32(0xaec30000), SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), + SPH_C32(0x2c150000), SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), + SPH_C32(0xab92f78f), SPH_C32(0xa312567b), SPH_C32(0xdb250000), + SPH_C32(0x09290000), SPH_C32(0x49aac000), SPH_C32(0x81e10000), + SPH_C32(0xcafe6b59), SPH_C32(0x42793431), SPH_C32(0x43566b76), + SPH_C32(0xe86cba2e) }, + { SPH_C32(0x028b0000), SPH_C32(0x87e90001), SPH_C32(0x3c2af380), + SPH_C32(0x2f560000), SPH_C32(0x1f4944d9), SPH_C32(0x79e2e780), + SPH_C32(0x55e03071), SPH_C32(0x32f62e8d), SPH_C32(0xc56b0000), + SPH_C32(0xd7e60000), SPH_C32(0x2452c180), SPH_C32(0xf6c50000), + SPH_C32(0x26b96cc7), SPH_C32(0xb6d95d7f), SPH_C32(0x8ef57364), + SPH_C32(0x70c6f340) }, + { SPH_C32(0xb08d0000), SPH_C32(0x42800001), SPH_C32(0x1429e180), + SPH_C32(0x5b310000), SPH_C32(0xa98b722d), SPH_C32(0x92f0de78), + SPH_C32(0x6631ef9d), SPH_C32(0x3bb81f15), SPH_C32(0x69230000), + SPH_C32(0xcc400000), SPH_C32(0x61a9d200), SPH_C32(0xf5860000), + SPH_C32(0x7c3c5dad), SPH_C32(0xa96b0dc9), SPH_C32(0x7087b49a), + SPH_C32(0xe1228bb6) }, + { SPH_C32(0x1cc50000), SPH_C32(0x59260001), SPH_C32(0x51d2f200), + SPH_C32(0x58720000), SPH_C32(0xf30e4347), SPH_C32(0x8d428ece), + SPH_C32(0x98432863), SPH_C32(0xaa5c67e3), SPH_C32(0x776d0000), + SPH_C32(0x128f0000), SPH_C32(0x0c51d380), SPH_C32(0x82a20000), + SPH_C32(0x907b5a33), SPH_C32(0x5dcb6487), SPH_C32(0xbd24ac88), + SPH_C32(0x7988c2d8) }, + { SPH_C32(0xdb250000), SPH_C32(0x09290000), SPH_C32(0x49aac000), + SPH_C32(0x81e10000), SPH_C32(0xcafe6b59), SPH_C32(0x42793431), + SPH_C32(0x43566b76), SPH_C32(0xe86cba2e), SPH_C32(0x75e60000), + SPH_C32(0x95660001), SPH_C32(0x307b2000), SPH_C32(0xadf40000), + SPH_C32(0x8f321eea), SPH_C32(0x24298307), SPH_C32(0xe8c49cf9), + SPH_C32(0x4b7eec55) }, + { SPH_C32(0x776d0000), SPH_C32(0x128f0000), SPH_C32(0x0c51d380), + SPH_C32(0x82a20000), SPH_C32(0x907b5a33), SPH_C32(0x5dcb6487), + SPH_C32(0xbd24ac88), SPH_C32(0x7988c2d8), SPH_C32(0x6ba80000), + SPH_C32(0x4ba90001), SPH_C32(0x5d832180), SPH_C32(0xdad00000), + SPH_C32(0x63751974), SPH_C32(0xd089ea49), SPH_C32(0x256784eb), + SPH_C32(0xd3d4a53b) }, + { SPH_C32(0xc56b0000), SPH_C32(0xd7e60000), SPH_C32(0x2452c180), + SPH_C32(0xf6c50000), SPH_C32(0x26b96cc7), SPH_C32(0xb6d95d7f), + SPH_C32(0x8ef57364), SPH_C32(0x70c6f340), SPH_C32(0xc7e00000), + SPH_C32(0x500f0001), SPH_C32(0x18783200), SPH_C32(0xd9930000), + SPH_C32(0x39f0281e), SPH_C32(0xcf3bbaff), SPH_C32(0xdb154315), + SPH_C32(0x4230ddcd) }, + { SPH_C32(0x69230000), SPH_C32(0xcc400000), SPH_C32(0x61a9d200), + SPH_C32(0xf5860000), SPH_C32(0x7c3c5dad), SPH_C32(0xa96b0dc9), + SPH_C32(0x7087b49a), SPH_C32(0xe1228bb6), SPH_C32(0xd9ae0000), + SPH_C32(0x8ec00001), SPH_C32(0x75803380), SPH_C32(0xaeb70000), + SPH_C32(0xd5b72f80), SPH_C32(0x3b9bd3b1), SPH_C32(0x16b65b07), + SPH_C32(0xda9a94a3) }, + { SPH_C32(0x75e60000), SPH_C32(0x95660001), SPH_C32(0x307b2000), + SPH_C32(0xadf40000), SPH_C32(0x8f321eea), SPH_C32(0x24298307), + SPH_C32(0xe8c49cf9), SPH_C32(0x4b7eec55), SPH_C32(0xaec30000), + SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), SPH_C32(0x2c150000), + SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), SPH_C32(0xab92f78f), + SPH_C32(0xa312567b) }, + { SPH_C32(0xd9ae0000), SPH_C32(0x8ec00001), SPH_C32(0x75803380), + SPH_C32(0xaeb70000), SPH_C32(0xd5b72f80), SPH_C32(0x3b9bd3b1), + SPH_C32(0x16b65b07), SPH_C32(0xda9a94a3), SPH_C32(0xb08d0000), + SPH_C32(0x42800001), SPH_C32(0x1429e180), SPH_C32(0x5b310000), + SPH_C32(0xa98b722d), SPH_C32(0x92f0de78), SPH_C32(0x6631ef9d), + SPH_C32(0x3bb81f15) }, + { SPH_C32(0x6ba80000), SPH_C32(0x4ba90001), SPH_C32(0x5d832180), + SPH_C32(0xdad00000), SPH_C32(0x63751974), SPH_C32(0xd089ea49), + SPH_C32(0x256784eb), SPH_C32(0xd3d4a53b), SPH_C32(0x1cc50000), + SPH_C32(0x59260001), SPH_C32(0x51d2f200), SPH_C32(0x58720000), + SPH_C32(0xf30e4347), SPH_C32(0x8d428ece), SPH_C32(0x98432863), + SPH_C32(0xaa5c67e3) }, + { SPH_C32(0xc7e00000), SPH_C32(0x500f0001), SPH_C32(0x18783200), + SPH_C32(0xd9930000), SPH_C32(0x39f0281e), SPH_C32(0xcf3bbaff), + SPH_C32(0xdb154315), SPH_C32(0x4230ddcd), SPH_C32(0x028b0000), + SPH_C32(0x87e90001), SPH_C32(0x3c2af380), SPH_C32(0x2f560000), + SPH_C32(0x1f4944d9), SPH_C32(0x79e2e780), SPH_C32(0x55e03071), + SPH_C32(0x32f62e8d) } +}; + +static const sph_u32 T512_36[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xcc140000), SPH_C32(0xa5630000), SPH_C32(0x5ab90780), + SPH_C32(0x3b500000), SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), + SPH_C32(0x694348c1), SPH_C32(0xca5a87fe), SPH_C32(0x819e0000), + SPH_C32(0xec570000), SPH_C32(0x66320280), SPH_C32(0x95f30000), + SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), SPH_C32(0xe65aa22d), + SPH_C32(0x8e67b7fa) }, + { SPH_C32(0x819e0000), SPH_C32(0xec570000), SPH_C32(0x66320280), + SPH_C32(0x95f30000), SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), + SPH_C32(0xe65aa22d), SPH_C32(0x8e67b7fa), SPH_C32(0x4d8a0000), + SPH_C32(0x49340000), SPH_C32(0x3c8b0500), SPH_C32(0xaea30000), + SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), SPH_C32(0x8f19eaec), + SPH_C32(0x443d3004) }, + { SPH_C32(0x4d8a0000), SPH_C32(0x49340000), SPH_C32(0x3c8b0500), + SPH_C32(0xaea30000), SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), + SPH_C32(0x8f19eaec), SPH_C32(0x443d3004), SPH_C32(0xcc140000), + SPH_C32(0xa5630000), SPH_C32(0x5ab90780), SPH_C32(0x3b500000), + SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), SPH_C32(0x694348c1), + SPH_C32(0xca5a87fe) }, + { SPH_C32(0x78230000), SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), + SPH_C32(0x90a50000), SPH_C32(0x713e2879), SPH_C32(0x7ee98924), + SPH_C32(0xf08ca062), SPH_C32(0x636f8bab), SPH_C32(0x02af0000), + SPH_C32(0xb7280000), SPH_C32(0xba1c0300), SPH_C32(0x56980000), + SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), SPH_C32(0xa95c149a), + SPH_C32(0xf4f6ea7b) }, + { SPH_C32(0xb4370000), SPH_C32(0xb79f0000), SPH_C32(0xf3830c00), + SPH_C32(0xabf50000), SPH_C32(0x3aee3b86), SPH_C32(0xf972bd3c), + SPH_C32(0x99cfe8a3), SPH_C32(0xa9350c55), SPH_C32(0x83310000), + SPH_C32(0x5b7f0000), SPH_C32(0xdc2e0180), SPH_C32(0xc36b0000), + SPH_C32(0xe7246dd1), SPH_C32(0xc8bcfadb), SPH_C32(0x4f06b6b7), + SPH_C32(0x7a915d81) }, + { SPH_C32(0xf9bd0000), SPH_C32(0xfeab0000), SPH_C32(0xcf080900), + SPH_C32(0x05560000), SPH_C32(0x2c97007b), SPH_C32(0x361db598), + SPH_C32(0x16d6024f), SPH_C32(0xed083c51), SPH_C32(0x4f250000), + SPH_C32(0xfe1c0000), SPH_C32(0x496970600), SPH_C32(0xf83b0000), + SPH_C32(0xacf47e2e), SPH_C32(0x4f27cec3), SPH_C32(0x2645fe76), + SPH_C32(0xb0cbda7f) }, + { SPH_C32(0x35a90000), SPH_C32(0x5bc80000), SPH_C32(0x95b10e80), + SPH_C32(0x3e060000), SPH_C32(0x67471384), SPH_C32(0xb1868180), + SPH_C32(0x7f954a8e), SPH_C32(0x2752bbaf), SPH_C32(0xcebb0000), + SPH_C32(0x124b0000), SPH_C32(0xe0a50480), SPH_C32(0x6dc80000), + SPH_C32(0xf15d562c), SPH_C32(0x07d3f27f), SPH_C32(0xc01f5c5b), + SPH_C32(0x3eac6d85) }, + { SPH_C32(0x02af0000), SPH_C32(0xb7280000), SPH_C32(0xba1c0300), + SPH_C32(0x56980000), SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), + SPH_C32(0xa95c149a), SPH_C32(0xf4f6ea7b), SPH_C32(0x7a8c0000), + SPH_C32(0xa5d40000), SPH_C32(0x13260880), SPH_C32(0xc63d0000), + SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), SPH_C32(0x59d0b4f8), + SPH_C32(0x979961d0) }, + { SPH_C32(0xcebb0000), SPH_C32(0x124b0000), SPH_C32(0xe0a50480), + SPH_C32(0x6dc80000), SPH_C32(0xf15d562c), SPH_C32(0x07d3f27f), + SPH_C32(0xc01f5c5b), SPH_C32(0x3eac6d85), SPH_C32(0xfb120000), + SPH_C32(0x49830000), SPH_C32(0x75140a00), SPH_C32(0x53ce0000), + SPH_C32(0x961a45a8), SPH_C32(0xb65573ff), SPH_C32(0xbf8a16d5), + SPH_C32(0x19fed62a) }, + { SPH_C32(0x83310000), SPH_C32(0x5b7f0000), SPH_C32(0xdc2e0180), + SPH_C32(0xc36b0000), SPH_C32(0xe7246dd1), SPH_C32(0xc8bcfadb), + SPH_C32(0x4f06b6b7), SPH_C32(0x7a915d81), SPH_C32(0x37060000), + SPH_C32(0xece00000), SPH_C32(0x2fad0d80), SPH_C32(0x689e0000), + SPH_C32(0xddca5657), SPH_C32(0x31ce47e7), SPH_C32(0xd6c95e14), + SPH_C32(0xd3a451d4) }, + { SPH_C32(0x4f250000), SPH_C32(0xfe1c0000), SPH_C32(0x496970600), + SPH_C32(0xf83b0000), SPH_C32(0xacf47e2e), SPH_C32(0x4f27cec3), + SPH_C32(0x2645fe76), SPH_C32(0xb0cbda7f), SPH_C32(0xb6980000), + SPH_C32(0x00b70000), SPH_C32(0x499f0f00), SPH_C32(0xfd6d0000), + SPH_C32(0x80637e55), SPH_C32(0x793a7b5b), SPH_C32(0x3093fc39), + SPH_C32(0x5dc3e62e) }, + { SPH_C32(0x7a8c0000), SPH_C32(0xa5d40000), SPH_C32(0x13260880), + SPH_C32(0xc63d0000), SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), + SPH_C32(0x59d0b4f8), SPH_C32(0x979961d0), SPH_C32(0x78230000), + SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), SPH_C32(0x90a50000), + SPH_C32(0x713e2879), SPH_C32(0x7ee98924), SPH_C32(0xf08ca062), + SPH_C32(0x636f8bab) }, + { SPH_C32(0xb6980000), SPH_C32(0x00b70000), SPH_C32(0x499f0f00), + SPH_C32(0xfd6d0000), SPH_C32(0x80637e55), SPH_C32(0x793a7b5b), + SPH_C32(0x3093fc39), SPH_C32(0x5dc3e62e), SPH_C32(0xf9bd0000), + SPH_C32(0xfeab0000), SPH_C32(0xcf080900), SPH_C32(0x05560000), + SPH_C32(0x2c97007b), SPH_C32(0x361db598), SPH_C32(0x16d6024f), + SPH_C32(0xed083c51) }, + { SPH_C32(0xfb120000), SPH_C32(0x49830000), SPH_C32(0x75140a00), + SPH_C32(0x53ce0000), SPH_C32(0x961a45a8), SPH_C32(0xb65573ff), + SPH_C32(0xbf8a16d5), SPH_C32(0x19fed62a), SPH_C32(0x35a90000), + SPH_C32(0x5bc80000), SPH_C32(0x95b10e80), SPH_C32(0x3e060000), + SPH_C32(0x67471384), SPH_C32(0xb1868180), SPH_C32(0x7f954a8e), + SPH_C32(0x2752bbaf) }, + { SPH_C32(0x37060000), SPH_C32(0xece00000), SPH_C32(0x2fad0d80), + SPH_C32(0x689e0000), SPH_C32(0xddca5657), SPH_C32(0x31ce47e7), + SPH_C32(0xd6c95e14), SPH_C32(0xd3a451d4), SPH_C32(0xb4370000), + SPH_C32(0xb79f0000), SPH_C32(0xf3830c00), SPH_C32(0xabf50000), + SPH_C32(0x3aee3b86), SPH_C32(0xf972bd3c), SPH_C32(0x99cfe8a3), + SPH_C32(0xa9350c55) } +}; + +static const sph_u32 T512_40[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x88980000), SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), + SPH_C32(0xfb4e0000), SPH_C32(0xf158079a), SPH_C32(0x61ae9167), + SPH_C32(0xa895706c), SPH_C32(0xe6107494), SPH_C32(0x0bc20000), + SPH_C32(0xdb630000), SPH_C32(0x7e88000c), SPH_C32(0x15860000), + SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), SPH_C32(0xf460449e), + SPH_C32(0xd8b61463) }, + { SPH_C32(0x0bc20000), SPH_C32(0xdb630000), SPH_C32(0x7e88000c), + SPH_C32(0x15860000), SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), + SPH_C32(0xf460449e), SPH_C32(0xd8b61463), SPH_C32(0x835a0000), + SPH_C32(0xc4f70000), SPH_C32(0x01470022), SPH_C32(0xeec80000), + SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), SPH_C32(0x5cf534f2), + SPH_C32(0x3ea660f7) }, + { SPH_C32(0x835a0000), SPH_C32(0xc4f70000), SPH_C32(0x01470022), + SPH_C32(0xeec80000), SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), + SPH_C32(0x5cf534f2), SPH_C32(0x3ea660f7), SPH_C32(0x88980000), + SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), SPH_C32(0xfb4e0000), + SPH_C32(0xf158079a), SPH_C32(0x61ae9167), SPH_C32(0xa895706c), + SPH_C32(0xe6107494) }, + { SPH_C32(0x52500000), SPH_C32(0x29540000), SPH_C32(0x6a61004e), + SPH_C32(0xf0ff0000), SPH_C32(0x9a317eec), SPH_C32(0x452341ce), + SPH_C32(0xcf568fe5), SPH_C32(0x5303130f), SPH_C32(0x538d0000), + SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), SPH_C32(0x56ff0000), + SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), SPH_C32(0xa9444018), + SPH_C32(0x7f975691) }, + { SPH_C32(0xdac80000), SPH_C32(0x36c00000), SPH_C32(0x15ae0060), + SPH_C32(0x0bb10000), SPH_C32(0x6b697976), SPH_C32(0x248dd0a9), + SPH_C32(0x67c3ff89), SPH_C32(0xb513679b), SPH_C32(0x584f0000), + SPH_C32(0x729f0000), SPH_C32(0xe07f000a), SPH_C32(0x43790000), + SPH_C32(0x9b1948bd), SPH_C32(0xe74476ba), SPH_C32(0x5d240486), + SPH_C32(0xa72142f2) }, + { SPH_C32(0x59920000), SPH_C32(0xf2370000), SPH_C32(0x14e90042), + SPH_C32(0xe5790000), SPH_C32(0x0bcc361f), SPH_C32(0x30a2fa8d), + SPH_C32(0x3b36cb7b), SPH_C32(0x8bb5076c), SPH_C32(0xd0d70000), + SPH_C32(0x6d0b0000), SPH_C32(0x9fb00024), SPH_C32(0xb8370000), + SPH_C32(0x6a414f27), SPH_C32(0x86eae7dd), SPH_C32(0xf5b174ea), + SPH_C32(0x41313666) }, + { SPH_C32(0xd10a0000), SPH_C32(0xeda30000), SPH_C32(0x6b26006c), + SPH_C32(0x1e370000), SPH_C32(0xfa943185), SPH_C32(0x510c6bea), + SPH_C32(0x93a3bb17), SPH_C32(0x6da573f8), SPH_C32(0xdb150000), + SPH_C32(0xb6680000), SPH_C32(0xe1380028), SPH_C32(0xadb10000), + SPH_C32(0xfbbc07d4), SPH_C32(0xf36b5c9e), SPH_C32(0x01d13074), + SPH_C32(0x99872205) }, + { SPH_C32(0x538d0000), SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), + SPH_C32(0x56ff0000), SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), + SPH_C32(0xa9444018), SPH_C32(0x7f975691), SPH_C32(0x01dd0000), + SPH_C32(0x80a80000), SPH_C32(0xf4960048), SPH_C32(0xa6000000), + SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), SPH_C32(0x6612cffd), + SPH_C32(0x2c94459e) }, + { SPH_C32(0xdb150000), SPH_C32(0xb6680000), SPH_C32(0xe1380028), + SPH_C32(0xadb10000), SPH_C32(0xfbbc07d4), SPH_C32(0xf36b5c9e), + SPH_C32(0x01d13074), SPH_C32(0x99872205), SPH_C32(0x0a1f0000), + SPH_C32(0x5bcb0000), SPH_C32(0x8a1e0044), SPH_C32(0xb3860000), + SPH_C32(0x01283651), SPH_C32(0xa2673774), SPH_C32(0x92728b63), + SPH_C32(0xf42251fd) }, + { SPH_C32(0x584f0000), SPH_C32(0x729f0000), SPH_C32(0xe07f000a), + SPH_C32(0x43790000), SPH_C32(0x9b1948bd), SPH_C32(0xe74476ba), + SPH_C32(0x5d240486), SPH_C32(0xa72142f2), SPH_C32(0x82870000), + SPH_C32(0x445f0000), SPH_C32(0xf5d1006a), SPH_C32(0x48c80000), + SPH_C32(0xf07031cb), SPH_C32(0xc3c9a613), SPH_C32(0x3ae7fb0f), + SPH_C32(0x12322569) }, + { SPH_C32(0xd0d70000), SPH_C32(0x6d0b0000), SPH_C32(0x9fb00024), + SPH_C32(0xb8370000), SPH_C32(0x6a414f27), SPH_C32(0x86eae7dd), + SPH_C32(0xf5b174ea), SPH_C32(0x41313666), SPH_C32(0x89450000), + SPH_C32(0x9f3c0000), SPH_C32(0x8b590066), SPH_C32(0x5d4e0000), + SPH_C32(0x618d7938), SPH_C32(0xb6481d50), SPH_C32(0xce87bf91), + SPH_C32(0xca84310a) }, + { SPH_C32(0x01dd0000), SPH_C32(0x80a80000), SPH_C32(0xf4960048), + SPH_C32(0xa6000000), SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), + SPH_C32(0x6612cffd), SPH_C32(0x2c94459e), SPH_C32(0x52500000), + SPH_C32(0x29540000), SPH_C32(0x6a61004e), SPH_C32(0xf0ff0000), + SPH_C32(0x9a317eec), SPH_C32(0x452341ce), SPH_C32(0xcf568fe5), + SPH_C32(0x5303130f) }, + { SPH_C32(0x89450000), SPH_C32(0x9f3c0000), SPH_C32(0x8b590066), + SPH_C32(0x5d4e0000), SPH_C32(0x618d7938), SPH_C32(0xb6481d50), + SPH_C32(0xce87bf91), SPH_C32(0xca84310a), SPH_C32(0x59920000), + SPH_C32(0xf2370000), SPH_C32(0x14e90042), SPH_C32(0xe5790000), + SPH_C32(0x0bcc361f), SPH_C32(0x30a2fa8d), SPH_C32(0x3b36cb7b), + SPH_C32(0x8bb5076c) }, + { SPH_C32(0x0a1f0000), SPH_C32(0x5bcb0000), SPH_C32(0x8a1e0044), + SPH_C32(0xb3860000), SPH_C32(0x01283651), SPH_C32(0xa2673774), + SPH_C32(0x92728b63), SPH_C32(0xf42251fd), SPH_C32(0xd10a0000), + SPH_C32(0xeda30000), SPH_C32(0x6b26006c), SPH_C32(0x1e370000), + SPH_C32(0xfa943185), SPH_C32(0x510c6bea), SPH_C32(0x93a3bb17), + SPH_C32(0x6da573f8) }, + { SPH_C32(0x82870000), SPH_C32(0x445f0000), SPH_C32(0xf5d1006a), + SPH_C32(0x48c80000), SPH_C32(0xf07031cb), SPH_C32(0xc3c9a613), + SPH_C32(0x3ae7fb0f), SPH_C32(0x12322569), SPH_C32(0xdac80000), + SPH_C32(0x36c00000), SPH_C32(0x15ae0060), SPH_C32(0x0bb10000), + SPH_C32(0x6b697976), SPH_C32(0x248dd0a9), SPH_C32(0x67c3ff89), + SPH_C32(0xb513679b) } +}; + +static const sph_u32 T512_44[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x58430000), SPH_C32(0x807e0000), SPH_C32(0x78330001), + SPH_C32(0xc66b3800), SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), + SPH_C32(0xac73fe6f), SPH_C32(0x3a4479b1), SPH_C32(0x1d5a0000), + SPH_C32(0x2b720000), SPH_C32(0x488d0000), SPH_C32(0xaf611800), + SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), SPH_C32(0x81a20429), + SPH_C32(0x1e7536a6) }, + { SPH_C32(0x1d5a0000), SPH_C32(0x2b720000), SPH_C32(0x488d0000), + SPH_C32(0xaf611800), SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), + SPH_C32(0x81a20429), SPH_C32(0x1e7536a6), SPH_C32(0x45190000), + SPH_C32(0xab0c0000), SPH_C32(0x30be0001), SPH_C32(0x690a2000), + SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), SPH_C32(0x2dd1fa46), + SPH_C32(0x24314f17) }, + { SPH_C32(0x45190000), SPH_C32(0xab0c0000), SPH_C32(0x30be0001), + SPH_C32(0x690a2000), SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), + SPH_C32(0x2dd1fa46), SPH_C32(0x24314f17), SPH_C32(0x58430000), + SPH_C32(0x807e0000), SPH_C32(0x78330001), SPH_C32(0xc66b3800), + SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), SPH_C32(0xac73fe6f), + SPH_C32(0x3a4479b1) }, + { SPH_C32(0xa53b0000), SPH_C32(0x14260000), SPH_C32(0x4e30001e), + SPH_C32(0x7cae0000), SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), + SPH_C32(0xf73168d8), SPH_C32(0x0b1b4946), SPH_C32(0x07ed0000), + SPH_C32(0xb2500000), SPH_C32(0x8774000a), SPH_C32(0x970d0000), + SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), SPH_C32(0xf4786222), + SPH_C32(0x9075b1ce) }, + { SPH_C32(0xfd780000), SPH_C32(0x94580000), SPH_C32(0x3603001f), + SPH_C32(0xbac53800), SPH_C32(0x68a95109), SPH_C32(0x017295e0), + SPH_C32(0x5b4296b7), SPH_C32(0x315f30f7), SPH_C32(0x1ab70000), + SPH_C32(0x99220000), SPH_C32(0xcff9000a), SPH_C32(0x386c1800), + SPH_C32(0x66b90d6b), SPH_C32(0x80bed174), SPH_C32(0x75da660b), + SPH_C32(0x8e008768) }, + { SPH_C32(0xb8610000), SPH_C32(0x3f540000), SPH_C32(0x06bd001e), + SPH_C32(0xd3cf1800), SPH_C32(0xaa552310), SPH_C32(0xb0a615ed), + SPH_C32(0x76936cf1), SPH_C32(0x156e7fe0), SPH_C32(0x42f40000), + SPH_C32(0x195c0000), SPH_C32(0xb7ca000b), SPH_C32(0xfe072000), + SPH_C32(0x818e51b7), SPH_C32(0xf913eea9), SPH_C32(0xd9a99864), + SPH_C32(0xb444fed9) }, + { SPH_C32(0xe0220000), SPH_C32(0xbf2a0000), SPH_C32(0x7e8e001f), + SPH_C32(0x15a42000), SPH_C32(0x4d627fcc), SPH_C32(0xc90b2a30), + SPH_C32(0xdae0929e), SPH_C32(0x2f2a0651), SPH_C32(0x5fae0000), + SPH_C32(0x322e0000), SPH_C32(0xff47000b), SPH_C32(0x51663800), + SPH_C32(0xa4457f72), SPH_C32(0x316a5179), SPH_C32(0x580b9c4d), + SPH_C32(0xaa31c87f) }, + { SPH_C32(0x07ed0000), SPH_C32(0xb2500000), SPH_C32(0x8774000a), + SPH_C32(0x970d0000), SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), + SPH_C32(0xf4786222), SPH_C32(0x9075b1ce), SPH_C32(0xa2d60000), + SPH_C32(0xa6760000), SPH_C32(0xc9440014), SPH_C32(0xeba30000), + SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), SPH_C32(0x03490afa), + SPH_C32(0x9b6ef888) }, + { SPH_C32(0x5fae0000), SPH_C32(0x322e0000), SPH_C32(0xff47000b), + SPH_C32(0x51663800), SPH_C32(0xa4457f72), SPH_C32(0x316a5179), + SPH_C32(0x580b9c4d), SPH_C32(0xaa31c87f), SPH_C32(0xbf8c0000), + SPH_C32(0x8d040000), SPH_C32(0x81c90014), SPH_C32(0x44c21800), + SPH_C32(0xe92700be), SPH_C32(0xf8617b49), SPH_C32(0x82eb0ed3), + SPH_C32(0x851bce2e) }, + { SPH_C32(0x1ab70000), SPH_C32(0x99220000), SPH_C32(0xcff9000a), + SPH_C32(0x386c1800), SPH_C32(0x66b90d6b), SPH_C32(0x80bed174), + SPH_C32(0x75da660b), SPH_C32(0x8e008768), SPH_C32(0xe7cf0000), + SPH_C32(0x0d7a0000), SPH_C32(0xf9fa0015), SPH_C32(0x82a92000), + SPH_C32(0x0e105c62), SPH_C32(0x81cc4494), SPH_C32(0x2e98f0bc), + SPH_C32(0xbf5fb79f) }, + { SPH_C32(0x42f40000), SPH_C32(0x195c0000), SPH_C32(0xb7ca000b), + SPH_C32(0xfe072000), SPH_C32(0x818e51b7), SPH_C32(0xf913eea9), + SPH_C32(0xd9a99864), SPH_C32(0xb444fed9), SPH_C32(0xfa950000), + SPH_C32(0x26080000), SPH_C32(0xb1770015), SPH_C32(0x2dc83800), + SPH_C32(0x2bdb72a7), SPH_C32(0x49b5fb44), SPH_C32(0xaf3af495), + SPH_C32(0xa12a8139) }, + { SPH_C32(0xa2d60000), SPH_C32(0xa6760000), SPH_C32(0xc9440014), + SPH_C32(0xeba30000), SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), + SPH_C32(0x03490afa), SPH_C32(0x9b6ef888), SPH_C32(0xa53b0000), + SPH_C32(0x14260000), SPH_C32(0x4e30001e), SPH_C32(0x7cae0000), + SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), SPH_C32(0xf73168d8), + SPH_C32(0x0b1b4946) }, + { SPH_C32(0xfa950000), SPH_C32(0x26080000), SPH_C32(0xb1770015), + SPH_C32(0x2dc83800), SPH_C32(0x2bdb72a7), SPH_C32(0x49b5fb44), + SPH_C32(0xaf3af495), SPH_C32(0xa12a8139), SPH_C32(0xb8610000), + SPH_C32(0x3f540000), SPH_C32(0x06bd001e), SPH_C32(0xd3cf1800), + SPH_C32(0xaa552310), SPH_C32(0xb0a615ed), SPH_C32(0x76936cf1), + SPH_C32(0x156e7fe0) }, + { SPH_C32(0xbf8c0000), SPH_C32(0x8d040000), SPH_C32(0x81c90014), + SPH_C32(0x44c21800), SPH_C32(0xe92700be), SPH_C32(0xf8617b49), + SPH_C32(0x82eb0ed3), SPH_C32(0x851bce2e), SPH_C32(0xe0220000), + SPH_C32(0xbf2a0000), SPH_C32(0x7e8e001f), SPH_C32(0x15a42000), + SPH_C32(0x4d627fcc), SPH_C32(0xc90b2a30), SPH_C32(0xdae0929e), + SPH_C32(0x2f2a0651) }, + { SPH_C32(0xe7cf0000), SPH_C32(0x0d7a0000), SPH_C32(0xf9fa0015), + SPH_C32(0x82a92000), SPH_C32(0x0e105c62), SPH_C32(0x81cc4494), + SPH_C32(0x2e98f0bc), SPH_C32(0xbf5fb79f), SPH_C32(0xfd780000), + SPH_C32(0x94580000), SPH_C32(0x3603001f), SPH_C32(0xbac53800), + SPH_C32(0x68a95109), SPH_C32(0x017295e0), SPH_C32(0x5b4296b7), + SPH_C32(0x315f30f7) } +}; + +static const sph_u32 T512_48[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x02f20000), SPH_C32(0xa2810000), SPH_C32(0x873f0000), + SPH_C32(0xe36c7800), SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), + SPH_C32(0xc4c23237), SPH_C32(0x7f32259e), SPH_C32(0xbadd0000), + SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), SPH_C32(0xf7282800), + SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), SPH_C32(0xea5a8d14), + SPH_C32(0x2a2c18f0) }, + { SPH_C32(0xbadd0000), SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), + SPH_C32(0xf7282800), SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), + SPH_C32(0xea5a8d14), SPH_C32(0x2a2c18f0), SPH_C32(0xb82f0000), + SPH_C32(0xb12c0000), SPH_C32(0x30d80000), SPH_C32(0x14445000), + SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), SPH_C32(0x2e98bf23), + SPH_C32(0x551e3d6e) }, + { SPH_C32(0xb82f0000), SPH_C32(0xb12c0000), SPH_C32(0x30d80000), + SPH_C32(0x14445000), SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), + SPH_C32(0x2e98bf23), SPH_C32(0x551e3d6e), SPH_C32(0x02f20000), + SPH_C32(0xa2810000), SPH_C32(0x873f0000), SPH_C32(0xe36c7800), + SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), SPH_C32(0xc4c23237), + SPH_C32(0x7f32259e) }, + { SPH_C32(0x1e6c0000), SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), + SPH_C32(0xbcb6b800), SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), + SPH_C32(0x6a0c1bc8), SPH_C32(0xb99dc2eb), SPH_C32(0x92560000), + SPH_C32(0x1eda0000), SPH_C32(0xea510000), SPH_C32(0xe8b13000), + SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), SPH_C32(0xb15c2254), + SPH_C32(0x33c5244f) }, + { SPH_C32(0x1c9e0000), SPH_C32(0x66c30000), SPH_C32(0x0d110000), + SPH_C32(0x5fdac000), SPH_C32(0x32596759), SPH_C32(0x8cc0f80c), + SPH_C32(0xaece29ff), SPH_C32(0xc6afe775), SPH_C32(0x288b0000), + SPH_C32(0x0d770000), SPH_C32(0x5db60000), SPH_C32(0x1f991800), + SPH_C32(0x767042e8), SPH_C32(0xdde1a2a3), SPH_C32(0x5b06af40), + SPH_C32(0x19e93cbf) }, + { SPH_C32(0xa4b10000), SPH_C32(0xd7ef0000), SPH_C32(0x3dc90000), + SPH_C32(0x4b9e9000), SPH_C32(0xf30107fb), SPH_C32(0xbde710e0), + SPH_C32(0x805696dc), SPH_C32(0x93b1da1b), SPH_C32(0x2a790000), + SPH_C32(0xaff60000), SPH_C32(0xda890000), SPH_C32(0xfcf56000), + SPH_C32(0x686d3607), SPH_C32(0xdadc8975), SPH_C32(0x9fc49d77), + SPH_C32(0x66db1921) }, + { SPH_C32(0xa6430000), SPH_C32(0x756e0000), SPH_C32(0xbaf60000), + SPH_C32(0xa8f2e800), SPH_C32(0xed1c7314), SPH_C32(0xbada3b36), + SPH_C32(0x4494a4eb), SPH_C32(0xec83ff85), SPH_C32(0x90a40000), + SPH_C32(0xbc5b0000), SPH_C32(0x6d6e0000), SPH_C32(0x0bdd4800), + SPH_C32(0xb728224a), SPH_C32(0xecc64a4f), SPH_C32(0x759e1063), + SPH_C32(0x4cf701d1) }, + { SPH_C32(0x92560000), SPH_C32(0x1eda0000), SPH_C32(0xea510000), + SPH_C32(0xe8b13000), SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), + SPH_C32(0xb15c2254), SPH_C32(0x33c5244f), SPH_C32(0x8c3a0000), + SPH_C32(0xda980000), SPH_C32(0x607f0000), SPH_C32(0x54078800), + SPH_C32(0x85714513), SPH_C32(0x6006b243), SPH_C32(0xdb50399c), + SPH_C32(0x8a58e6a4) }, + { SPH_C32(0x90a40000), SPH_C32(0xbc5b0000), SPH_C32(0x6d6e0000), + SPH_C32(0x0bdd4800), SPH_C32(0xb728224a), SPH_C32(0xecc64a4f), + SPH_C32(0x759e1063), SPH_C32(0x4cf701d1), SPH_C32(0x36e70000), + SPH_C32(0xc9350000), SPH_C32(0xd7980000), SPH_C32(0xa32fa000), + SPH_C32(0x5a34515e), SPH_C32(0x561c7179), SPH_C32(0x310ab488), + SPH_C32(0xa074fe54) }, + { SPH_C32(0x288b0000), SPH_C32(0x0d770000), SPH_C32(0x5db60000), + SPH_C32(0x1f991800), SPH_C32(0x767042e8), SPH_C32(0xdde1a2a3), + SPH_C32(0x5b06af40), SPH_C32(0x19e93cbf), SPH_C32(0x34150000), + SPH_C32(0x6bb40000), SPH_C32(0x50a70000), SPH_C32(0x4043d800), + SPH_C32(0x442925b1), SPH_C32(0x51215aaf), SPH_C32(0xf5c886bf), + SPH_C32(0xdf46dbca) }, + { SPH_C32(0x2a790000), SPH_C32(0xaff60000), SPH_C32(0xda890000), + SPH_C32(0xfcf56000), SPH_C32(0x686d3607), SPH_C32(0xdadc8975), + SPH_C32(0x9fc49d77), SPH_C32(0x66db1921), SPH_C32(0x8ec80000), + SPH_C32(0x78190000), SPH_C32(0xe7400000), SPH_C32(0xb76bf000), + SPH_C32(0x9b6c31fc), SPH_C32(0x673b9995), SPH_C32(0x1f920bab), + SPH_C32(0xf56ac33a) }, + { SPH_C32(0x8c3a0000), SPH_C32(0xda980000), SPH_C32(0x607f0000), + SPH_C32(0x54078800), SPH_C32(0x85714513), SPH_C32(0x6006b243), + SPH_C32(0xdb50399c), SPH_C32(0x8a58e6a4), SPH_C32(0x1e6c0000), + SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), SPH_C32(0xbcb6b800), + SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), SPH_C32(0x6a0c1bc8), + SPH_C32(0xb99dc2eb) }, + { SPH_C32(0x8ec80000), SPH_C32(0x78190000), SPH_C32(0xe7400000), + SPH_C32(0xb76bf000), SPH_C32(0x9b6c31fc), SPH_C32(0x673b9995), + SPH_C32(0x1f920bab), SPH_C32(0xf56ac33a), SPH_C32(0xa4b10000), + SPH_C32(0xd7ef0000), SPH_C32(0x3dc90000), SPH_C32(0x4b9e9000), + SPH_C32(0xf30107fb), SPH_C32(0xbde710e0), SPH_C32(0x805696dc), + SPH_C32(0x93b1da1b) }, + { SPH_C32(0x36e70000), SPH_C32(0xc9350000), SPH_C32(0xd7980000), + SPH_C32(0xa32fa000), SPH_C32(0x5a34515e), SPH_C32(0x561c7179), + SPH_C32(0x310ab488), SPH_C32(0xa074fe54), SPH_C32(0xa6430000), + SPH_C32(0x756e0000), SPH_C32(0xbaf60000), SPH_C32(0xa8f2e800), + SPH_C32(0xed1c7314), SPH_C32(0xbada3b36), SPH_C32(0x4494a4eb), + SPH_C32(0xec83ff85) }, + { SPH_C32(0x34150000), SPH_C32(0x6bb40000), SPH_C32(0x50a70000), + SPH_C32(0x4043d800), SPH_C32(0x442925b1), SPH_C32(0x51215aaf), + SPH_C32(0xf5c886bf), SPH_C32(0xdf46dbca), SPH_C32(0x1c9e0000), + SPH_C32(0x66c30000), SPH_C32(0x0d110000), SPH_C32(0x5fdac000), + SPH_C32(0x32596759), SPH_C32(0x8cc0f80c), SPH_C32(0xaece29ff), + SPH_C32(0xc6afe775) } +}; + +static const sph_u32 T512_52[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xe6280000), SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), + SPH_C32(0xd3d002e0), SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), + SPH_C32(0x289506b4), SPH_C32(0xd75a4897), SPH_C32(0xf0c50000), + SPH_C32(0x59230000), SPH_C32(0x45820000), SPH_C32(0xe18d00c0), + SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), SPH_C32(0xcbe0fe1c), + SPH_C32(0x56a7b19f) }, + { SPH_C32(0xf0c50000), SPH_C32(0x59230000), SPH_C32(0x45820000), + SPH_C32(0xe18d00c0), SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), + SPH_C32(0xcbe0fe1c), SPH_C32(0x56a7b19f), SPH_C32(0x16ed0000), + SPH_C32(0x15680000), SPH_C32(0xedd70000), SPH_C32(0x325d0220), + SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), SPH_C32(0xe375f8a8), + SPH_C32(0x81fdf908) }, + { SPH_C32(0x16ed0000), SPH_C32(0x15680000), SPH_C32(0xedd70000), + SPH_C32(0x325d0220), SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), + SPH_C32(0xe375f8a8), SPH_C32(0x81fdf908), SPH_C32(0xe6280000), + SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), SPH_C32(0xd3d002e0), + SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), SPH_C32(0x289506b4), + SPH_C32(0xd75a4897) }, + { SPH_C32(0xb4310000), SPH_C32(0x77330000), SPH_C32(0xb15d0000), + SPH_C32(0x7fd004e0), SPH_C32(0x78a26138), SPH_C32(0xd116c35d), + SPH_C32(0xd256d489), SPH_C32(0x4e6f74de), SPH_C32(0xe3060000), + SPH_C32(0xbdc10000), SPH_C32(0x87130000), SPH_C32(0xbff20060), + SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), SPH_C32(0x73c5ab06), + SPH_C32(0x5bd61539) }, + { SPH_C32(0x52190000), SPH_C32(0x3b780000), SPH_C32(0x19080000), + SPH_C32(0xac000600), SPH_C32(0xa0c35180), SPH_C32(0x49b17387), + SPH_C32(0xfac3d23d), SPH_C32(0x99353c49), SPH_C32(0x13c30000), + SPH_C32(0xe4e20000), SPH_C32(0xc2910000), SPH_C32(0x5e7f00a0), + SPH_C32(0x15d70c2b), SPH_C32(0x4f5861c8), SPH_C32(0xb825551a), + SPH_C32(0x0d71a4a6) }, + { SPH_C32(0x44f40000), SPH_C32(0x2e100000), SPH_C32(0xf4df0000), + SPH_C32(0x9e5d0420), SPH_C32(0x43cf6709), SPH_C32(0x13fb95c4), + SPH_C32(0x19b62a95), SPH_C32(0x18c8c541), SPH_C32(0xf5eb0000), + SPH_C32(0xa8a90000), SPH_C32(0x6ac40000), SPH_C32(0x8daf0240), + SPH_C32(0xcdb63c93), SPH_C32(0xd7ffd112), SPH_C32(0x90b053ae), + SPH_C32(0xda2bec31) }, + { SPH_C32(0xa2dc0000), SPH_C32(0x625b0000), SPH_C32(0x5c8a0000), + SPH_C32(0x4d8d06c0), SPH_C32(0x9bae57b1), SPH_C32(0x8b5c251e), + SPH_C32(0x31232c21), SPH_C32(0xcf928dd6), SPH_C32(0x052e0000), + SPH_C32(0xf18a0000), SPH_C32(0x2f460000), SPH_C32(0x6c220280), + SPH_C32(0xf6db3aa2), SPH_C32(0x1512878b), SPH_C32(0x5b50adb2), + SPH_C32(0x8c8c5dae) }, + { SPH_C32(0xe3060000), SPH_C32(0xbdc10000), SPH_C32(0x87130000), + SPH_C32(0xbff20060), SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), + SPH_C32(0x73c5ab06), SPH_C32(0x5bd61539), SPH_C32(0x57370000), + SPH_C32(0xcaf20000), SPH_C32(0x364e0000), SPH_C32(0xc0220480), + SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), SPH_C32(0xa1937f8f), + SPH_C32(0x15b961e7) }, + { SPH_C32(0x052e0000), SPH_C32(0xf18a0000), SPH_C32(0x2f460000), + SPH_C32(0x6c220280), SPH_C32(0xf6db3aa2), SPH_C32(0x1512878b), + SPH_C32(0x5b50adb2), SPH_C32(0x8c8c5dae), SPH_C32(0xa7f20000), + SPH_C32(0x93d10000), SPH_C32(0x73cc0000), SPH_C32(0x21af0440), + SPH_C32(0x6d756d13), SPH_C32(0x9e4ea295), SPH_C32(0x6a738193), + SPH_C32(0x431ed078) }, + { SPH_C32(0x13c30000), SPH_C32(0xe4e20000), SPH_C32(0xc2910000), + SPH_C32(0x5e7f00a0), SPH_C32(0x15d70c2b), SPH_C32(0x4f5861c8), + SPH_C32(0xb825551a), SPH_C32(0x0d71a4a6), SPH_C32(0x41da0000), + SPH_C32(0xdf9a0000), SPH_C32(0xdb990000), SPH_C32(0xf27f06a0), + SPH_C32(0xb5145dab), SPH_C32(0x06e9124f), SPH_C32(0x42e68727), + SPH_C32(0x944498ef) }, + { SPH_C32(0xf5eb0000), SPH_C32(0xa8a90000), SPH_C32(0x6ac40000), + SPH_C32(0x8daf0240), SPH_C32(0xcdb63c93), SPH_C32(0xd7ffd112), + SPH_C32(0x90b053ae), SPH_C32(0xda2bec31), SPH_C32(0xb11f0000), + SPH_C32(0x86b90000), SPH_C32(0x9e1b0000), SPH_C32(0x13f20660), + SPH_C32(0x8e795b9a), SPH_C32(0xc40444d6), SPH_C32(0x8906793b), + SPH_C32(0xc2e32970) }, + { SPH_C32(0x57370000), SPH_C32(0xcaf20000), SPH_C32(0x364e0000), + SPH_C32(0xc0220480), SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), + SPH_C32(0xa1937f8f), SPH_C32(0x15b961e7), SPH_C32(0xb4310000), + SPH_C32(0x77330000), SPH_C32(0xb15d0000), SPH_C32(0x7fd004e0), + SPH_C32(0x78a26138), SPH_C32(0xd116c35d), SPH_C32(0xd256d489), + SPH_C32(0x4e6f74de) }, + { SPH_C32(0xb11f0000), SPH_C32(0x86b90000), SPH_C32(0x9e1b0000), + SPH_C32(0x13f20660), SPH_C32(0x8e795b9a), SPH_C32(0xc40444d6), + SPH_C32(0x8906793b), SPH_C32(0xc2e32970), SPH_C32(0x44f40000), + SPH_C32(0x2e100000), SPH_C32(0xf4df0000), SPH_C32(0x9e5d0420), + SPH_C32(0x43cf6709), SPH_C32(0x13fb95c4), SPH_C32(0x19b62a95), + SPH_C32(0x18c8c541) }, + { SPH_C32(0xa7f20000), SPH_C32(0x93d10000), SPH_C32(0x73cc0000), + SPH_C32(0x21af0440), SPH_C32(0x6d756d13), SPH_C32(0x9e4ea295), + SPH_C32(0x6a738193), SPH_C32(0x431ed078), SPH_C32(0xa2dc0000), + SPH_C32(0x625b0000), SPH_C32(0x5c8a0000), SPH_C32(0x4d8d06c0), + SPH_C32(0x9bae57b1), SPH_C32(0x8b5c251e), SPH_C32(0x31232c21), + SPH_C32(0xcf928dd6) }, + { SPH_C32(0x41da0000), SPH_C32(0xdf9a0000), SPH_C32(0xdb990000), + SPH_C32(0xf27f06a0), SPH_C32(0xb5145dab), SPH_C32(0x06e9124f), + SPH_C32(0x42e68727), SPH_C32(0x944498ef), SPH_C32(0x52190000), + SPH_C32(0x3b780000), SPH_C32(0x19080000), SPH_C32(0xac000600), + SPH_C32(0xa0c35180), SPH_C32(0x49b17387), SPH_C32(0xfac3d23d), + SPH_C32(0x99353c49) } +}; + +static const sph_u32 T512_56[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x5fa80000), SPH_C32(0x56030000), SPH_C32(0x43ae0000), + SPH_C32(0x64f30013), SPH_C32(0x257e86bf), SPH_C32(0x1311944e), + SPH_C32(0x541e95bf), SPH_C32(0x8ea4db69), SPH_C32(0x00440000), + SPH_C32(0x7f480000), SPH_C32(0xda7c0000), SPH_C32(0x2a230001), + SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), SPH_C32(0x030a9e60), + SPH_C32(0xbe0a679e) }, + { SPH_C32(0x00440000), SPH_C32(0x7f480000), SPH_C32(0xda7c0000), + SPH_C32(0x2a230001), SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), + SPH_C32(0x030a9e60), SPH_C32(0xbe0a679e), SPH_C32(0x5fec0000), + SPH_C32(0x294b0000), SPH_C32(0x99d20000), SPH_C32(0x4ed00012), + SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), SPH_C32(0x57140bdf), + SPH_C32(0x30aebcf7) }, + { SPH_C32(0x5fec0000), SPH_C32(0x294b0000), SPH_C32(0x99d20000), + SPH_C32(0x4ed00012), SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), + SPH_C32(0x57140bdf), SPH_C32(0x30aebcf7), SPH_C32(0x5fa80000), + SPH_C32(0x56030000), SPH_C32(0x43ae0000), SPH_C32(0x64f30013), + SPH_C32(0x257e86bf), SPH_C32(0x1311944e), SPH_C32(0x541e95bf), + SPH_C32(0x8ea4db69) }, + { SPH_C32(0xee930000), SPH_C32(0xd6070000), SPH_C32(0x92c10000), + SPH_C32(0x2b9801e0), SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), + SPH_C32(0x45312374), SPH_C32(0x201f6a64), SPH_C32(0x7b280000), + SPH_C32(0x57420000), SPH_C32(0xa9e50000), SPH_C32(0x634300a0), + SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), SPH_C32(0x27f83b03), + SPH_C32(0xc7ff60f0) }, + { SPH_C32(0xb13b0000), SPH_C32(0x80040000), SPH_C32(0xd16f0000), + SPH_C32(0x4f6b01f3), SPH_C32(0xb12faec3), SPH_C32(0x287d6f19), + SPH_C32(0x112fb6cb), SPH_C32(0xaebbb10d), SPH_C32(0x7b6c0000), + SPH_C32(0x280a0000), SPH_C32(0x73990000), SPH_C32(0x496000a1), + SPH_C32(0xa5768de3), SPH_C32(0xc42f093c), SPH_C32(0x24f2a563), + SPH_C32(0x79f5076e) }, + { SPH_C32(0xeed70000), SPH_C32(0xa94f0000), SPH_C32(0x48bd0000), + SPH_C32(0x01bb01e1), SPH_C32(0xaffce1b0), SPH_C32(0x92da67d0), + SPH_C32(0x463bbd14), SPH_C32(0x9e150dfa), SPH_C32(0x24c40000), + SPH_C32(0x7e090000), SPH_C32(0x30370000), SPH_C32(0x2d9300b2), + SPH_C32(0x80080b5c), SPH_C32(0xd73e9d72), SPH_C32(0x70ec30dc), + SPH_C32(0xf751dc07) }, + { SPH_C32(0xb17f0000), SPH_C32(0xff4c0000), SPH_C32(0x0b130000), + SPH_C32(0x654801f2), SPH_C32(0x8a82670f), SPH_C32(0x81cbf39e), + SPH_C32(0x122528ab), SPH_C32(0x10b1d693), SPH_C32(0x24800000), + SPH_C32(0x01410000), SPH_C32(0xea4b0000), SPH_C32(0x07b000b3), + SPH_C32(0xbba5c290), SPH_C32(0x7e8801f5), SPH_C32(0x73e6aebc), + SPH_C32(0x495bbb99) }, + { SPH_C32(0x7b280000), SPH_C32(0x57420000), SPH_C32(0xa9e50000), + SPH_C32(0x634300a0), SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), + SPH_C32(0x27f83b03), SPH_C32(0xc7ff60f0), SPH_C32(0x95bb0000), + SPH_C32(0x81450000), SPH_C32(0x3b240000), SPH_C32(0x48db0140), + SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), SPH_C32(0x62c91877), + SPH_C32(0xe7e00a94) }, + { SPH_C32(0x24800000), SPH_C32(0x01410000), SPH_C32(0xea4b0000), + SPH_C32(0x07b000b3), SPH_C32(0xbba5c290), SPH_C32(0x7e8801f5), + SPH_C32(0x73e6aebc), SPH_C32(0x495bbb99), SPH_C32(0x95ff0000), + SPH_C32(0xfe0d0000), SPH_C32(0xe1580000), SPH_C32(0x62f80141), + SPH_C32(0x3127a59f), SPH_C32(0xff43f26b), SPH_C32(0x61c38617), + SPH_C32(0x59ea6d0a) }, + { SPH_C32(0x7b6c0000), SPH_C32(0x280a0000), SPH_C32(0x73990000), + SPH_C32(0x496000a1), SPH_C32(0xa5768de3), SPH_C32(0xc42f093c), + SPH_C32(0x24f2a563), SPH_C32(0x79f5076e), SPH_C32(0xca570000), + SPH_C32(0xa80e0000), SPH_C32(0xa2f60000), SPH_C32(0x060b0152), + SPH_C32(0x14592320), SPH_C32(0xec526625), SPH_C32(0x35dd13a8), + SPH_C32(0xd74eb663) }, + { SPH_C32(0x24c40000), SPH_C32(0x7e090000), SPH_C32(0x30370000), + SPH_C32(0x2d9300b2), SPH_C32(0x80080b5c), SPH_C32(0xd73e9d72), + SPH_C32(0x70ec30dc), SPH_C32(0xf751dc07), SPH_C32(0xca130000), + SPH_C32(0xd7460000), SPH_C32(0x788a0000), SPH_C32(0x2c280153), + SPH_C32(0x2ff4eaec), SPH_C32(0x45e4faa2), SPH_C32(0x36d78dc8), + SPH_C32(0x6944d1fd) }, + { SPH_C32(0x95bb0000), SPH_C32(0x81450000), SPH_C32(0x3b240000), + SPH_C32(0x48db0140), SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), + SPH_C32(0x62c91877), SPH_C32(0xe7e00a94), SPH_C32(0xee930000), + SPH_C32(0xd6070000), SPH_C32(0x92c10000), SPH_C32(0x2b9801e0), + SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), SPH_C32(0x45312374), + SPH_C32(0x201f6a64) }, + { SPH_C32(0xca130000), SPH_C32(0xd7460000), SPH_C32(0x788a0000), + SPH_C32(0x2c280153), SPH_C32(0x2ff4eaec), SPH_C32(0x45e4faa2), + SPH_C32(0x36d78dc8), SPH_C32(0x6944d1fd), SPH_C32(0xeed70000), + SPH_C32(0xa94f0000), SPH_C32(0x48bd0000), SPH_C32(0x01bb01e1), + SPH_C32(0xaffce1b0), SPH_C32(0x92da67d0), SPH_C32(0x463bbd14), + SPH_C32(0x9e150dfa) }, + { SPH_C32(0x95ff0000), SPH_C32(0xfe0d0000), SPH_C32(0xe1580000), + SPH_C32(0x62f80141), SPH_C32(0x3127a59f), SPH_C32(0xff43f26b), + SPH_C32(0x61c38617), SPH_C32(0x59ea6d0a), SPH_C32(0xb17f0000), + SPH_C32(0xff4c0000), SPH_C32(0x0b130000), SPH_C32(0x654801f2), + SPH_C32(0x8a82670f), SPH_C32(0x81cbf39e), SPH_C32(0x122528ab), + SPH_C32(0x10b1d693) }, + { SPH_C32(0xca570000), SPH_C32(0xa80e0000), SPH_C32(0xa2f60000), + SPH_C32(0x060b0152), SPH_C32(0x14592320), SPH_C32(0xec526625), + SPH_C32(0x35dd13a8), SPH_C32(0xd74eb663), SPH_C32(0xb13b0000), + SPH_C32(0x80040000), SPH_C32(0xd16f0000), SPH_C32(0x4f6b01f3), + SPH_C32(0xb12faec3), SPH_C32(0x287d6f19), SPH_C32(0x112fb6cb), + SPH_C32(0xaebbb10d) } +}; + +static const sph_u32 T512_60[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x033d0000), SPH_C32(0x08b30000), SPH_C32(0xf33a0000), + SPH_C32(0x3ac20007), SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), + SPH_C32(0x0ea5cfe3), SPH_C32(0xe6da7ffe), SPH_C32(0xa8da0000), + SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), SPH_C32(0x07da0002), + SPH_C32(0x7d669583), SPH_C32(0x1f98708a), SPH_C32(0xbb668808), + SPH_C32(0xda878000) }, + { SPH_C32(0xa8da0000), SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), + SPH_C32(0x07da0002), SPH_C32(0x7d669583), SPH_C32(0x1f98708a), + SPH_C32(0xbb668808), SPH_C32(0xda878000), SPH_C32(0xabe70000), + SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), SPH_C32(0x3d180005), + SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), SPH_C32(0xb5c347eb), + SPH_C32(0x3c5dfffe) }, + { SPH_C32(0xabe70000), SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), + SPH_C32(0x3d180005), SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), + SPH_C32(0xb5c347eb), SPH_C32(0x3c5dfffe), SPH_C32(0x033d0000), + SPH_C32(0x08b30000), SPH_C32(0xf33a0000), SPH_C32(0x3ac20007), + SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), SPH_C32(0x0ea5cfe3), + SPH_C32(0xe6da7ffe) }, + { SPH_C32(0x01930000), SPH_C32(0xe7820000), SPH_C32(0xedfb0000), + SPH_C32(0xcf0c000b), SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), + SPH_C32(0x063661e1), SPH_C32(0x536f9e7b), SPH_C32(0x92280000), + SPH_C32(0xdc850000), SPH_C32(0x57fa0000), SPH_C32(0x56dc0003), + SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), SPH_C32(0x90cef752), + SPH_C32(0x7b1675d7) }, + { SPH_C32(0x02ae0000), SPH_C32(0xef310000), SPH_C32(0x1ec10000), + SPH_C32(0xf5ce000c), SPH_C32(0xdcf90708), SPH_C32(0xd7cdd231), + SPH_C32(0x0893ae02), SPH_C32(0xb5b5e185), SPH_C32(0x3af20000), + SPH_C32(0x4a3b0000), SPH_C32(0x0be70000), SPH_C32(0x51060001), + SPH_C32(0xc78fb695), SPH_C32(0x4577d386), SPH_C32(0x2ba87f5a), + SPH_C32(0xa191f5d7) }, + { SPH_C32(0xa9490000), SPH_C32(0x713c0000), SPH_C32(0xb1e60000), + SPH_C32(0xc8d60009), SPH_C32(0xf0b618db), SPH_C32(0xa33bc4a4), + SPH_C32(0xbd50e9e9), SPH_C32(0x89e81e7b), SPH_C32(0x39cf0000), + SPH_C32(0x42880000), SPH_C32(0xf8dd0000), SPH_C32(0x6bc40006), + SPH_C32(0x96a63cc5), SPH_C32(0x2e19b599), SPH_C32(0x250db0b9), + SPH_C32(0x474b8a29) }, + { SPH_C32(0xaa740000), SPH_C32(0x798f0000), SPH_C32(0x42dc0000), + SPH_C32(0xf214000e), SPH_C32(0xa19f928b), SPH_C32(0xc855a2bb), + SPH_C32(0xb3f5260a), SPH_C32(0x6f326185), SPH_C32(0x91150000), + SPH_C32(0xd4360000), SPH_C32(0xa4c00000), SPH_C32(0x6c1e0004), + SPH_C32(0xebc0a946), SPH_C32(0x3181c513), SPH_C32(0x9e6b38b1), + SPH_C32(0x9dcc0a29) }, + { SPH_C32(0x92280000), SPH_C32(0xdc850000), SPH_C32(0x57fa0000), + SPH_C32(0x56dc0003), SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), + SPH_C32(0x90cef752), SPH_C32(0x7b1675d7), SPH_C32(0x93bb0000), + SPH_C32(0x3b070000), SPH_C32(0xba010000), SPH_C32(0x99d00008), + SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), SPH_C32(0x96f896b3), + SPH_C32(0x2879ebac) }, + { SPH_C32(0x91150000), SPH_C32(0xd4360000), SPH_C32(0xa4c00000), + SPH_C32(0x6c1e0004), SPH_C32(0xebc0a946), SPH_C32(0x3181c513), + SPH_C32(0x9e6b38b1), SPH_C32(0x9dcc0a29), SPH_C32(0x3b610000), + SPH_C32(0xadb90000), SPH_C32(0xe61c0000), SPH_C32(0x9e0a000a), + SPH_C32(0x4a5f3bcd), SPH_C32(0xf9d467a8), SPH_C32(0x2d9e1ebb), + SPH_C32(0xf2fe6bac) }, + { SPH_C32(0x3af20000), SPH_C32(0x4a3b0000), SPH_C32(0x0be70000), + SPH_C32(0x51060001), SPH_C32(0xc78fb695), SPH_C32(0x4577d386), + SPH_C32(0x2ba87f5a), SPH_C32(0xa191f5d7), SPH_C32(0x385c0000), + SPH_C32(0xa50a0000), SPH_C32(0x15260000), SPH_C32(0xa4c8000d), + SPH_C32(0x1b76b19d), SPH_C32(0x92ba01b7), SPH_C32(0x233bd158), + SPH_C32(0x14241452) }, + { SPH_C32(0x39cf0000), SPH_C32(0x42880000), SPH_C32(0xf8dd0000), + SPH_C32(0x6bc40006), SPH_C32(0x96a63cc5), SPH_C32(0x2e19b599), + SPH_C32(0x250db0b9), SPH_C32(0x474b8a29), SPH_C32(0x90860000), + SPH_C32(0x33b40000), SPH_C32(0x493b0000), SPH_C32(0xa312000f), + SPH_C32(0x6610241e), SPH_C32(0x8d22713d), SPH_C32(0x985d5950), + SPH_C32(0xcea39452) }, + { SPH_C32(0x93bb0000), SPH_C32(0x3b070000), SPH_C32(0xba010000), + SPH_C32(0x99d00008), SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), + SPH_C32(0x96f896b3), SPH_C32(0x2879ebac), SPH_C32(0x01930000), + SPH_C32(0xe7820000), SPH_C32(0xedfb0000), SPH_C32(0xcf0c000b), + SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), SPH_C32(0x063661e1), + SPH_C32(0x536f9e7b) }, + { SPH_C32(0x90860000), SPH_C32(0x33b40000), SPH_C32(0x493b0000), + SPH_C32(0xa312000f), SPH_C32(0x6610241e), SPH_C32(0x8d22713d), + SPH_C32(0x985d5950), SPH_C32(0xcea39452), SPH_C32(0xa9490000), + SPH_C32(0x713c0000), SPH_C32(0xb1e60000), SPH_C32(0xc8d60009), + SPH_C32(0xf0b618db), SPH_C32(0xa33bc4a4), SPH_C32(0xbd50e9e9), + SPH_C32(0x89e81e7b) }, + { SPH_C32(0x3b610000), SPH_C32(0xadb90000), SPH_C32(0xe61c0000), + SPH_C32(0x9e0a000a), SPH_C32(0x4a5f3bcd), SPH_C32(0xf9d467a8), + SPH_C32(0x2d9e1ebb), SPH_C32(0xf2fe6bac), SPH_C32(0xaa740000), + SPH_C32(0x798f0000), SPH_C32(0x42dc0000), SPH_C32(0xf214000e), + SPH_C32(0xa19f928b), SPH_C32(0xc855a2bb), SPH_C32(0xb3f5260a), + SPH_C32(0x6f326185) }, + { SPH_C32(0x385c0000), SPH_C32(0xa50a0000), SPH_C32(0x15260000), + SPH_C32(0xa4c8000d), SPH_C32(0x1b76b19d), SPH_C32(0x92ba01b7), + SPH_C32(0x233bd158), SPH_C32(0x14241452), SPH_C32(0x02ae0000), + SPH_C32(0xef310000), SPH_C32(0x1ec10000), SPH_C32(0xf5ce000c), + SPH_C32(0xdcf90708), SPH_C32(0xd7cdd231), SPH_C32(0x0893ae02), + SPH_C32(0xb5b5e185) } +}; + +#define INPUT_BIG do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T512_0[acc >> 4][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + m8 = rp[8]; \ + m9 = rp[9]; \ + mA = rp[10]; \ + mB = rp[11]; \ + mC = rp[12]; \ + mD = rp[13]; \ + mE = rp[14]; \ + mF = rp[15]; \ + rp = &T512_4[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[1]; \ + rp = &T512_8[acc >> 4][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_12[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[2]; \ + rp = &T512_16[acc >> 4][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_20[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[3]; \ + rp = &T512_24[acc >> 4][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_28[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[4]; \ + rp = &T512_32[acc >> 4][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_36[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[5]; \ + rp = &T512_40[acc >> 4][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_44[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[6]; \ + rp = &T512_48[acc >> 4][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_52[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[7]; \ + rp = &T512_56[acc >> 4][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_60[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_BIG == 5 + +static const sph_u32 T512_0[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x23671400), SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), + SPH_C32(0xfb750000), SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), + SPH_C32(0x02c40a3f), SPH_C32(0xdc24e61f), SPH_C32(0x373d2800), + SPH_C32(0x71500000), SPH_C32(0x95e00000), SPH_C32(0x0a140000), + SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), SPH_C32(0x456d6d1f), + SPH_C32(0x3daac2da) }, + { SPH_C32(0x54285c00), SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), + SPH_C32(0xa1c50000), SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), + SPH_C32(0x6bb0419d), SPH_C32(0x551b3782), SPH_C32(0x9cbb1800), + SPH_C32(0xb0d30000), SPH_C32(0x92510000), SPH_C32(0xed930000), + SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), SPH_C32(0x430633da), + SPH_C32(0x78cace29) }, + { SPH_C32(0x774f4800), SPH_C32(0x22540000), SPH_C32(0x31110000), + SPH_C32(0x5ab00000), SPH_C32(0xc06f4315), SPH_C32(0x6c0361a8), + SPH_C32(0x69744ba2), SPH_C32(0x893fd19d), SPH_C32(0xab863000), + SPH_C32(0xc1830000), SPH_C32(0x07b10000), SPH_C32(0xe7870000), + SPH_C32(0xe4965a4c), SPH_C32(0xa9fb4dc5), SPH_C32(0x066b5ec5), + SPH_C32(0x45600cf3) }, + { SPH_C32(0x9cbb1800), SPH_C32(0xb0d30000), SPH_C32(0x92510000), + SPH_C32(0xed930000), SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), + SPH_C32(0x430633da), SPH_C32(0x78cace29), SPH_C32(0xc8934400), + SPH_C32(0x5a3e0000), SPH_C32(0x57870000), SPH_C32(0x4c560000), + SPH_C32(0xea982435), SPH_C32(0x75b11115), SPH_C32(0x28b67247), + SPH_C32(0x2dd1f9ab) }, + { SPH_C32(0xbfdc0c00), SPH_C32(0x786a0000), SPH_C32(0x66960000), + SPH_C32(0x16e60000), SPH_C32(0x2af76720), SPH_C32(0x19b270bd), + SPH_C32(0x41c239e5), SPH_C32(0xa4ee2836), SPH_C32(0xffae6c00), + SPH_C32(0x2b6e0000), SPH_C32(0xc2670000), SPH_C32(0x46420000), + SPH_C32(0x57343d3c), SPH_C32(0x3d5e8924), SPH_C32(0x6ddb1f58), + SPH_C32(0x107b3b71) }, + { SPH_C32(0xc8934400), SPH_C32(0x5a3e0000), SPH_C32(0x57870000), + SPH_C32(0x4c560000), SPH_C32(0xea982435), SPH_C32(0x75b11115), + SPH_C32(0x28b67247), SPH_C32(0x2dd1f9ab), SPH_C32(0x54285c00), + SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), SPH_C32(0xa1c50000), + SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), SPH_C32(0x6bb0419d), + SPH_C32(0x551b3782) }, + { SPH_C32(0xebf45000), SPH_C32(0x92870000), SPH_C32(0xa3400000), + SPH_C32(0xb7230000), SPH_C32(0x99550050), SPH_C32(0x8d17b45c), + SPH_C32(0x2a727878), SPH_C32(0xf1f51fb4), SPH_C32(0x63157400), + SPH_C32(0x9bbd0000), SPH_C32(0x50360000), SPH_C32(0xabd10000), + SPH_C32(0x0e0e7e79), SPH_C32(0xdc4a5cd0), SPH_C32(0x2edd2c82), + SPH_C32(0x68b1f558) }, + { SPH_C32(0x29449c00), SPH_C32(0x64e70000), SPH_C32(0xf24b0000), + SPH_C32(0xc2f30000), SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), + SPH_C32(0xf3e04259), SPH_C32(0x8d0d9ec4), SPH_C32(0x466d0c00), + SPH_C32(0x08620000), SPH_C32(0xdd5d0000), SPH_C32(0xbadd0000), + SPH_C32(0x6a927942), SPH_C32(0x441f2b93), SPH_C32(0x218ace6f), + SPH_C32(0xbf2c0be2) }, + { SPH_C32(0x0a238800), SPH_C32(0xac5e0000), SPH_C32(0x068c0000), + SPH_C32(0x39860000), SPH_C32(0x7d136aea), SPH_C32(0xae64920c), + SPH_C32(0xf1244866), SPH_C32(0x512978db), SPH_C32(0x71502400), + SPH_C32(0x79320000), SPH_C32(0x48bd0000), SPH_C32(0xb0c90000), + SPH_C32(0xd73e604b), SPH_C32(0x0cf0b3a2), SPH_C32(0x64e7a370), + SPH_C32(0x8286c938) }, + { SPH_C32(0x7d6cc000), SPH_C32(0x8e0a0000), SPH_C32(0x379d0000), + SPH_C32(0x63360000), SPH_C32(0xbd7c29ff), SPH_C32(0xc267f3a4), + SPH_C32(0x985003c4), SPH_C32(0xd816a946), SPH_C32(0xdad61400), + SPH_C32(0xb8b10000), SPH_C32(0x4f0c0000), SPH_C32(0x574e0000), + SPH_C32(0x33a83a07), SPH_C32(0xa50bfe67), SPH_C32(0x628cfdb5), + SPH_C32(0xc7e6c5cb) }, + { SPH_C32(0x5e0bd400), SPH_C32(0x46b30000), SPH_C32(0xc35a0000), + SPH_C32(0x98430000), SPH_C32(0xceb10d9a), SPH_C32(0x3ac156ed), + SPH_C32(0x9a9409fb), SPH_C32(0x04324f59), SPH_C32(0xedeb3c00), + SPH_C32(0xc9e10000), SPH_C32(0xdaec0000), SPH_C32(0x5d5a0000), + SPH_C32(0x8e04230e), SPH_C32(0xede46656), SPH_C32(0x27e190aa), + SPH_C32(0xfa4c0711) }, + { SPH_C32(0xb5ff8400), SPH_C32(0xd4340000), SPH_C32(0x601a0000), + SPH_C32(0x2f600000), SPH_C32(0x57e40dca), SPH_C32(0xb7d6e2b1), + SPH_C32(0xb0e67183), SPH_C32(0xf5c750ed), SPH_C32(0x8efe4800), + SPH_C32(0x525c0000), SPH_C32(0x8ada0000), SPH_C32(0xf68b0000), + SPH_C32(0x800a5d77), SPH_C32(0x31ae3a86), SPH_C32(0x093cbc28), + SPH_C32(0x92fdf249) }, + { SPH_C32(0x496989000), SPH_C32(0x1c8d0000), SPH_C32(0x94dd0000), + SPH_C32(0xd4150000), SPH_C32(0x242929af), SPH_C32(0x4f7047f8), + SPH_C32(0xb2227bbc), SPH_C32(0x29e3b6f2), SPH_C32(0xb9c36000), + SPH_C32(0x230c0000), SPH_C32(0x1f3a0000), SPH_C32(0xfc9f0000), + SPH_C32(0x3da6447e), SPH_C32(0x7941a2b7), SPH_C32(0x4c51d137), + SPH_C32(0xaf573093) }, + { SPH_C32(0xe1d7d800), SPH_C32(0x3ed90000), SPH_C32(0xa5cc0000), + SPH_C32(0x8ea50000), SPH_C32(0xe4466aba), SPH_C32(0x23732650), + SPH_C32(0xdb56301e), SPH_C32(0xa0dc676f), SPH_C32(0x12455000), + SPH_C32(0xe28f0000), SPH_C32(0x188b0000), SPH_C32(0x1b180000), + SPH_C32(0xd9301e32), SPH_C32(0xd0baef72), SPH_C32(0x4a3a8ff2), + SPH_C32(0xea373c60) }, + { SPH_C32(0xc2b0cc00), SPH_C32(0xf6600000), SPH_C32(0x510b0000), + SPH_C32(0x75d00000), SPH_C32(0x978b4edf), SPH_C32(0xdbd58319), + SPH_C32(0xd9923a21), SPH_C32(0x7cf88170), SPH_C32(0x25787800), + SPH_C32(0x93df0000), SPH_C32(0x8d6b0000), SPH_C32(0x110c0000), + SPH_C32(0x649c073b), SPH_C32(0x98557743), SPH_C32(0x0f57e2ed), + SPH_C32(0xd79dfeba) }, + { SPH_C32(0x466d0c00), SPH_C32(0x08620000), SPH_C32(0xdd5d0000), + SPH_C32(0xbadd0000), SPH_C32(0x6a927942), SPH_C32(0x441f2b93), + SPH_C32(0x218ace6f), SPH_C32(0xbf2c0be2), SPH_C32(0x6f299000), + SPH_C32(0x6c850000), SPH_C32(0x2f160000), SPH_C32(0x782e0000), + SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), SPH_C32(0xd26a8c36), + SPH_C32(0x32219526) }, + { SPH_C32(0x650a1800), SPH_C32(0xc0db0000), SPH_C32(0x299a0000), + SPH_C32(0x41a80000), SPH_C32(0x195f5d27), SPH_C32(0xbcb98eda), + SPH_C32(0x234ec450), SPH_C32(0x6308edfd), SPH_C32(0x5814b800), + SPH_C32(0x1dd50000), SPH_C32(0xbaf60000), SPH_C32(0x723a0000), + SPH_C32(0xd9e02ec4), SPH_C32(0x5a3284e7), SPH_C32(0x9707e129), + SPH_C32(0x0f8b57fc) }, + { SPH_C32(0x12455000), SPH_C32(0xe28f0000), SPH_C32(0x188b0000), + SPH_C32(0x1b180000), SPH_C32(0xd9301e32), SPH_C32(0xd0baef72), + SPH_C32(0x4a3a8ff2), SPH_C32(0xea373c60), SPH_C32(0xf3928800), + SPH_C32(0xdc560000), SPH_C32(0xbd470000), SPH_C32(0x95bd0000), + SPH_C32(0x3d767488), SPH_C32(0xf3c9c922), SPH_C32(0x916cbfec), + SPH_C32(0x4aeb5b0f) }, + { SPH_C32(0x31224400), SPH_C32(0x2a360000), SPH_C32(0xec4c0000), + SPH_C32(0xe06d0000), SPH_C32(0xaafd3a57), SPH_C32(0x281c4a3b), + SPH_C32(0x48fe85cd), SPH_C32(0x3613da7f), SPH_C32(0xc4afa000), + SPH_C32(0xad060000), SPH_C32(0x28a70000), SPH_C32(0x9fa90000), + SPH_C32(0x80da6d81), SPH_C32(0xbb265113), SPH_C32(0xd401d2f3), + SPH_C32(0x774199d5) }, + { SPH_C32(0xdad61400), SPH_C32(0xb8b10000), SPH_C32(0x4f0c0000), + SPH_C32(0x574e0000), SPH_C32(0x33a83a07), SPH_C32(0xa50bfe67), + SPH_C32(0x628cfdb5), SPH_C32(0xc7e6c5cb), SPH_C32(0xa7bad400), + SPH_C32(0x36bb0000), SPH_C32(0x78910000), SPH_C32(0x34780000), + SPH_C32(0x8ed413f8), SPH_C32(0x676c0dc3), SPH_C32(0xfadcfe71), + SPH_C32(0x1ff06c8d) }, + { SPH_C32(0xf9b10000), SPH_C32(0x70080000), SPH_C32(0xbbcb0000), + SPH_C32(0xac3b0000), SPH_C32(0x40651e62), SPH_C32(0x5dad5b2e), + SPH_C32(0x6048f78a), SPH_C32(0x1bc223d4), SPH_C32(0x9087fc00), + SPH_C32(0x47eb0000), SPH_C32(0xed710000), SPH_C32(0x3e6c0000), + SPH_C32(0x33780af1), SPH_C32(0x2f8395f2), SPH_C32(0xbfb1936e), + SPH_C32(0x225aae57) }, + { SPH_C32(0x8efe4800), SPH_C32(0x525c0000), SPH_C32(0x8ada0000), + SPH_C32(0xf68b0000), SPH_C32(0x800a5d77), SPH_C32(0x31ae3a86), + SPH_C32(0x093cbc28), SPH_C32(0x92fdf249), SPH_C32(0x3b01cc00), + SPH_C32(0x86680000), SPH_C32(0xeac00000), SPH_C32(0xd9eb0000), + SPH_C32(0xd7ee50bd), SPH_C32(0x8678d837), SPH_C32(0xb9dacdab), + SPH_C32(0x673aa2a4) }, + { SPH_C32(0xad995c00), SPH_C32(0x9ae50000), SPH_C32(0x7e1d0000), + SPH_C32(0x0dfe0000), SPH_C32(0xf3c77912), SPH_C32(0xc9089fcf), + SPH_C32(0x0bf8b617), SPH_C32(0x4ed91456), SPH_C32(0x0c3ce400), + SPH_C32(0xf7380000), SPH_C32(0x7f200000), SPH_C32(0xd3ff0000), + SPH_C32(0x6a4249b4), SPH_C32(0xce974006), SPH_C32(0xfcb7a0b4), + SPH_C32(0x5a90607e) }, + { SPH_C32(0x6f299000), SPH_C32(0x6c850000), SPH_C32(0x2f160000), + SPH_C32(0x782e0000), SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), + SPH_C32(0xd26a8c36), SPH_C32(0x32219526), SPH_C32(0x29449c00), + SPH_C32(0x64e70000), SPH_C32(0xf24b0000), SPH_C32(0xc2f30000), + SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), SPH_C32(0xf3e04259), + SPH_C32(0x8d0d9ec4) }, + { SPH_C32(0x4c4e8400), SPH_C32(0xa43c0000), SPH_C32(0xdbd10000), + SPH_C32(0x835b0000), SPH_C32(0x178113a8), SPH_C32(0xea7bb99f), + SPH_C32(0xd0ae8609), SPH_C32(0xee057339), SPH_C32(0x1e79b400), + SPH_C32(0x15b70000), SPH_C32(0x67ab0000), SPH_C32(0xc8e70000), + SPH_C32(0xb3725786), SPH_C32(0x1e2daf74), SPH_C32(0xb68d2f46), + SPH_C32(0xb0a75c1e) }, + { SPH_C32(0x3b01cc00), SPH_C32(0x86680000), SPH_C32(0xeac00000), + SPH_C32(0xd9eb0000), SPH_C32(0xd7ee50bd), SPH_C32(0x8678d837), + SPH_C32(0xb9dacdab), SPH_C32(0x673aa2a4), SPH_C32(0xb5ff8400), + SPH_C32(0xd4340000), SPH_C32(0x601a0000), SPH_C32(0x2f600000), + SPH_C32(0x57e40dca), SPH_C32(0xb7d6e2b1), SPH_C32(0xb0e67183), + SPH_C32(0xf5c750ed) }, + { SPH_C32(0x1866d800), SPH_C32(0x4ed10000), SPH_C32(0x1e070000), + SPH_C32(0x229e0000), SPH_C32(0xa42374d8), SPH_C32(0x7ede7d7e), + SPH_C32(0xbb1ec794), SPH_C32(0xbb1e44bb), SPH_C32(0x82c2ac00), + SPH_C32(0xa5640000), SPH_C32(0xf5fa0000), SPH_C32(0x25740000), + SPH_C32(0xea4814c3), SPH_C32(0xff397a80), SPH_C32(0xf58b1c9c), + SPH_C32(0xc86d9237) }, + { SPH_C32(0xf3928800), SPH_C32(0xdc560000), SPH_C32(0xbd470000), + SPH_C32(0x95bd0000), SPH_C32(0x3d767488), SPH_C32(0xf3c9c922), + SPH_C32(0x916cbfec), SPH_C32(0x4aeb5b0f), SPH_C32(0xe1d7d800), + SPH_C32(0x3ed90000), SPH_C32(0xa5cc0000), SPH_C32(0x8ea50000), + SPH_C32(0xe4466aba), SPH_C32(0x23732650), SPH_C32(0xdb56301e), + SPH_C32(0xa0dc676f) }, + { SPH_C32(0xd0f59c00), SPH_C32(0x14ef0000), SPH_C32(0x49800000), + SPH_C32(0x6ec80000), SPH_C32(0x4ebb50ed), SPH_C32(0x0b6f6c6b), + SPH_C32(0x93a8b5d3), SPH_C32(0x96cfbd10), SPH_C32(0xd6eaf000), + SPH_C32(0x4f890000), SPH_C32(0x302c0000), SPH_C32(0x84b10000), + SPH_C32(0x59ea73b3), SPH_C32(0x6b9cbe61), SPH_C32(0x9e3b5d01), + SPH_C32(0x9d76a5b5) }, + { SPH_C32(0xa7bad400), SPH_C32(0x36bb0000), SPH_C32(0x78910000), + SPH_C32(0x34780000), SPH_C32(0x8ed413f8), SPH_C32(0x676c0dc3), + SPH_C32(0xfadcfe71), SPH_C32(0x1ff06c8d), SPH_C32(0x7d6cc000), + SPH_C32(0x8e0a0000), SPH_C32(0x379d0000), SPH_C32(0x63360000), + SPH_C32(0xbd7c29ff), SPH_C32(0xc267f3a4), SPH_C32(0x985003c4), + SPH_C32(0xd816a946) }, + { SPH_C32(0x84ddc000), SPH_C32(0xfe020000), SPH_C32(0x8c560000), + SPH_C32(0xcf0d0000), SPH_C32(0xfd19379d), SPH_C32(0x9fcaa88a), + SPH_C32(0xf818f44e), SPH_C32(0xc3d48a92), SPH_C32(0x4a51e800), + SPH_C32(0xff5a0000), SPH_C32(0xa27d0000), SPH_C32(0x69220000), + SPH_C32(0x00d030f6), SPH_C32(0x8a886b95), SPH_C32(0xdd3d6edb), + SPH_C32(0xe5bc6b9c) } +}; + +static const sph_u32 T512_5[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xe8870170), SPH_C32(0x9d720000), SPH_C32(0x12db0000), + SPH_C32(0xd4220000), SPH_C32(0xf2886b27), SPH_C32(0xa921e543), + SPH_C32(0x4ef8b518), SPH_C32(0x618813b1), SPH_C32(0xb4370060), + SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), SPH_C32(0x5cae0000), + SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), SPH_C32(0x1b365f3d), + SPH_C32(0xf3d45758) }, + { SPH_C32(0xb4370060), SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), + SPH_C32(0x5cae0000), SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), + SPH_C32(0x1b365f3d), SPH_C32(0xf3d45758), SPH_C32(0x5cb00110), + SPH_C32(0x913e0000), SPH_C32(0x44190000), SPH_C32(0x888c0000), + SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), SPH_C32(0x55ceea25), + SPH_C32(0x925c44e9) }, + { SPH_C32(0x5cb00110), SPH_C32(0x913e0000), SPH_C32(0x44190000), + SPH_C32(0x888c0000), SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), + SPH_C32(0x55ceea25), SPH_C32(0x925c44e9), SPH_C32(0xe8870170), + SPH_C32(0x9d720000), SPH_C32(0x12db0000), SPH_C32(0xd4220000), + SPH_C32(0xf2886b27), SPH_C32(0xa921e543), SPH_C32(0x4ef8b518), + SPH_C32(0x618813b1) }, + { SPH_C32(0xef0b0270), SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), + SPH_C32(0x69490000), SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), + SPH_C32(0x66140a51), SPH_C32(0x924f5d0a), SPH_C32(0xc96b0030), + SPH_C32(0xe7250000), SPH_C32(0x2f840000), SPH_C32(0x264f0000), + SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), SPH_C32(0x509f6984), + SPH_C32(0x9e69af68) }, + { SPH_C32(0x078c0300), SPH_C32(0xa78f0000), SPH_C32(0x4f750000), + SPH_C32(0xbd6b0000), SPH_C32(0x69875721), SPH_C32(0xed2450ba), + SPH_C32(0x28ecbf49), SPH_C32(0xf3c74ebb), SPH_C32(0x7d5c0050), + SPH_C32(0xeb690000), SPH_C32(0x79460000), SPH_C32(0x7ae10000), + SPH_C32(0x9c3d44c6), SPH_C32(0x56c20912), SPH_C32(0x4ba936b9), + SPH_C32(0x6dbdf830) }, + { SPH_C32(0x5b3c0210), SPH_C32(0x36b10000), SPH_C32(0x0b6c0000), + SPH_C32(0x35e70000), SPH_C32(0x0f5b2339), SPH_C32(0x7f3b4ddc), + SPH_C32(0x7d22556c), SPH_C32(0x619b0a52), SPH_C32(0x95db0120), + SPH_C32(0x761b0000), SPH_C32(0x6b9d0000), SPH_C32(0xaec30000), + SPH_C32(0x6eb52fe1), SPH_C32(0xffe3ec51), SPH_C32(0x055183a1), + SPH_C32(0x0c35eb81) }, + { SPH_C32(0xb3bb0360), SPH_C32(0xabc30000), SPH_C32(0x19b70000), + SPH_C32(0xe1c50000), SPH_C32(0xfdd3481e), SPH_C32(0xd61aa89f), + SPH_C32(0x33dae074), SPH_C32(0x001319e3), SPH_C32(0x21ec0140), + SPH_C32(0x7a570000), SPH_C32(0x3d5f0000), SPH_C32(0xf26d0000), + SPH_C32(0xfae130de), SPH_C32(0xc4dd1474), SPH_C32(0x1e67dc9c), + SPH_C32(0xffe1bcd9) }, + { SPH_C32(0xc96b0030), SPH_C32(0xe7250000), SPH_C32(0x2f840000), + SPH_C32(0x264f0000), SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), + SPH_C32(0x509f6984), SPH_C32(0x9e69af68), SPH_C32(0x26600240), + SPH_C32(0xddd80000), SPH_C32(0x722a0000), SPH_C32(0x4f060000), + SPH_C32(0x936667ff), SPH_C32(0x29f944ce), SPH_C32(0x368b63d5), + SPH_C32(0x0c26f262) }, + { SPH_C32(0x21ec0140), SPH_C32(0x7a570000), SPH_C32(0x3d5f0000), + SPH_C32(0xf26d0000), SPH_C32(0xfae130de), SPH_C32(0xc4dd1474), + SPH_C32(0x1e67dc9c), SPH_C32(0xffe1bcd9), SPH_C32(0x92570220), + SPH_C32(0xd1940000), SPH_C32(0x24e80000), SPH_C32(0x13a80000), + SPH_C32(0x073278c0), SPH_C32(0x12c7bceb), SPH_C32(0x2dbd3ce8), + SPH_C32(0xfff2a53a) }, + { SPH_C32(0x7d5c0050), SPH_C32(0xeb690000), SPH_C32(0x79460000), + SPH_C32(0x7ae10000), SPH_C32(0x9c3d44c6), SPH_C32(0x56c20912), + SPH_C32(0x4ba936b9), SPH_C32(0x6dbdf830), SPH_C32(0x7ad00350), + SPH_C32(0x4ce60000), SPH_C32(0x36330000), SPH_C32(0xc78a0000), + SPH_C32(0xf5ba13e7), SPH_C32(0xbbe659a8), SPH_C32(0x634589f0), + SPH_C32(0x9e7ab68b) }, + { SPH_C32(0x95db0120), SPH_C32(0x761b0000), SPH_C32(0x6b9d0000), + SPH_C32(0xaec30000), SPH_C32(0x6eb52fe1), SPH_C32(0xffe3ec51), + SPH_C32(0x055183a1), SPH_C32(0x0c35eb81), SPH_C32(0xcee70330), + SPH_C32(0x40aa0000), SPH_C32(0x60f10000), SPH_C32(0x9b240000), + SPH_C32(0x61ee0cd8), SPH_C32(0x80d8a18d), SPH_C32(0x7873d6cd), + SPH_C32(0x6daee1d3) }, + { SPH_C32(0x26600240), SPH_C32(0xddd80000), SPH_C32(0x722a0000), + SPH_C32(0x4f060000), SPH_C32(0x936667ff), SPH_C32(0x29f944ce), + SPH_C32(0x368b63d5), SPH_C32(0x0c26f262), SPH_C32(0xef0b0270), + SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), SPH_C32(0x69490000), + SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), SPH_C32(0x66140a51), + SPH_C32(0x924f5d0a) }, + { SPH_C32(0xcee70330), SPH_C32(0x40aa0000), SPH_C32(0x60f10000), + SPH_C32(0x9b240000), SPH_C32(0x61ee0cd8), SPH_C32(0x80d8a18d), + SPH_C32(0x7873d6cd), SPH_C32(0x6daee1d3), SPH_C32(0x5b3c0210), + SPH_C32(0x36b10000), SPH_C32(0x0b6c0000), SPH_C32(0x35e70000), + SPH_C32(0x0f5b2339), SPH_C32(0x7f3b4ddc), SPH_C32(0x7d22556c), + SPH_C32(0x619b0a52) }, + { SPH_C32(0x92570220), SPH_C32(0xd1940000), SPH_C32(0x24e80000), + SPH_C32(0x13a80000), SPH_C32(0x073278c0), SPH_C32(0x12c7bceb), + SPH_C32(0x2dbd3ce8), SPH_C32(0xfff2a53a), SPH_C32(0xb3bb0360), + SPH_C32(0xabc30000), SPH_C32(0x19b70000), SPH_C32(0xe1c50000), + SPH_C32(0xfdd3481e), SPH_C32(0xd61aa89f), SPH_C32(0x33dae074), + SPH_C32(0x001319e3) }, + { SPH_C32(0x7ad00350), SPH_C32(0x4ce60000), SPH_C32(0x36330000), + SPH_C32(0xc78a0000), SPH_C32(0xf5ba13e7), SPH_C32(0xbbe659a8), + SPH_C32(0x634589f0), SPH_C32(0x9e7ab68b), SPH_C32(0x078c0300), + SPH_C32(0xa78f0000), SPH_C32(0x4f750000), SPH_C32(0xbd6b0000), + SPH_C32(0x69875721), SPH_C32(0xed2450ba), SPH_C32(0x28ecbf49), + SPH_C32(0xf3c74ebb) }, + { SPH_C32(0x145a3c00), SPH_C32(0xb9e90000), SPH_C32(0x61270000), + SPH_C32(0xf1610000), SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), + SPH_C32(0x47a96720), SPH_C32(0xe18e24c5), SPH_C32(0x23671400), + SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), SPH_C32(0xfb750000), + SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), SPH_C32(0x02c40a3f), + SPH_C32(0xdc24e61f) }, + { SPH_C32(0xfcdd3d70), SPH_C32(0x249b0000), SPH_C32(0x73fc0000), + SPH_C32(0x25430000), SPH_C32(0x3ce9564b), SPH_C32(0x1968d83b), + SPH_C32(0x0951d238), SPH_C32(0x80063774), SPH_C32(0x97501460), + SPH_C32(0xc4f50000), SPH_C32(0xa2050000), SPH_C32(0xa7db0000), + SPH_C32(0xe7993b5a), SPH_C32(0xc3985d6c), SPH_C32(0x19f25502), + SPH_C32(0x2ff0b147) }, + { SPH_C32(0xa06d3c60), SPH_C32(0xb5a50000), SPH_C32(0x37e50000), + SPH_C32(0xadcf0000), SPH_C32(0x5a352253), SPH_C32(0x8b77c55d), + SPH_C32(0x5c9f381d), SPH_C32(0x125a739d), SPH_C32(0x7fd71510), + SPH_C32(0x59870000), SPH_C32(0xb0de0000), SPH_C32(0x73f90000), + SPH_C32(0x1511507d), SPH_C32(0x6ab9b82f), SPH_C32(0x570ae01a), + SPH_C32(0x4e78a2f6) }, + { SPH_C32(0x48ea3d10), SPH_C32(0x28d70000), SPH_C32(0x253e0000), + SPH_C32(0x79ed0000), SPH_C32(0xa8bd4974), SPH_C32(0x2256201e), + SPH_C32(0x12678d05), SPH_C32(0x73d2602c), SPH_C32(0xcbe01570), + SPH_C32(0x55cb0000), SPH_C32(0xe61c0000), SPH_C32(0x2f570000), + SPH_C32(0x81454f42), SPH_C32(0x5187400a), SPH_C32(0x4c3cbf27), + SPH_C32(0xbdacf5ae) }, + { SPH_C32(0xfb513e70), SPH_C32(0x83140000), SPH_C32(0x3c890000), + SPH_C32(0x98280000), SPH_C32(0x556e016a), SPH_C32(0xf44c8881), + SPH_C32(0x21bd6d71), SPH_C32(0x73c179cf), SPH_C32(0xea0c1430), + SPH_C32(0x2f9c0000), SPH_C32(0xdb430000), SPH_C32(0xdd3a0000), + SPH_C32(0x7ba47f9c), SPH_C32(0x955a547e), SPH_C32(0x525b63bb), + SPH_C32(0x424d4977) }, + { SPH_C32(0x13d63f00), SPH_C32(0x1e660000), SPH_C32(0x2e520000), + SPH_C32(0x4c0a0000), SPH_C32(0xa7e66a4d), SPH_C32(0x5d6d6dc2), + SPH_C32(0x6f45d869), SPH_C32(0x12496a7e), SPH_C32(0x5e3b1450), + SPH_C32(0x23d00000), SPH_C32(0x8d810000), SPH_C32(0x81940000), + SPH_C32(0xeff060a3), SPH_C32(0xae64ac5b), SPH_C32(0x496d3c86), + SPH_C32(0xb1991e2f) }, + { SPH_C32(0x4f663e10), SPH_C32(0x8f580000), SPH_C32(0x6a4b0000), + SPH_C32(0xc4860000), SPH_C32(0xc13a1e55), SPH_C32(0xcf7270a4), + SPH_C32(0x3a8b324c), SPH_C32(0x80152e97), SPH_C32(0xb6bc1520), + SPH_C32(0xbea20000), SPH_C32(0x9f5a0000), SPH_C32(0x55b60000), + SPH_C32(0x1d780b84), SPH_C32(0x07454918), SPH_C32(0x0795899e), + SPH_C32(0xd0110d9e) }, + { SPH_C32(0xa7e13f60), SPH_C32(0x122a0000), SPH_C32(0x78900000), + SPH_C32(0x10a40000), SPH_C32(0x33b27572), SPH_C32(0x665395e7), + SPH_C32(0x74738754), SPH_C32(0xe19d3d26), SPH_C32(0x028b1540), + SPH_C32(0xb2ee0000), SPH_C32(0xc9980000), SPH_C32(0x09180000), + SPH_C32(0x892c14bb), SPH_C32(0x3c7bb13d), SPH_C32(0x1ca3d6a3), + SPH_C32(0x23c55ac6) }, + { SPH_C32(0xdd313c30), SPH_C32(0x5ecc0000), SPH_C32(0x4ea30000), + SPH_C32(0xd72e0000), SPH_C32(0xc6086695), SPH_C32(0xddb5cc4f), + SPH_C32(0x17360ea4), SPH_C32(0x7fe78bad), SPH_C32(0x05071640), + SPH_C32(0x15610000), SPH_C32(0x86ed0000), SPH_C32(0xb4730000), + SPH_C32(0xe0ab439a), SPH_C32(0xd15fe187), SPH_C32(0x344f69ea), + SPH_C32(0xd002147d) }, + { SPH_C32(0x35b63d40), SPH_C32(0xc3be0000), SPH_C32(0x5c780000), + SPH_C32(0x030c0000), SPH_C32(0x34800db2), SPH_C32(0x7494290c), + SPH_C32(0x59cebbbc), SPH_C32(0x1e6f981c), SPH_C32(0xb1301620), + SPH_C32(0x192d0000), SPH_C32(0xd02f0000), SPH_C32(0xe8dd0000), + SPH_C32(0x74ff5ca5), SPH_C32(0xea6119a2), SPH_C32(0x2f7936d7), + SPH_C32(0x23d64325) }, + { SPH_C32(0x69063c50), SPH_C32(0x52800000), SPH_C32(0x18610000), + SPH_C32(0x8b800000), SPH_C32(0x525c79aa), SPH_C32(0xe68b346a), + SPH_C32(0x0c005199), SPH_C32(0x8c33dcf5), SPH_C32(0x59b71750), + SPH_C32(0x845f0000), SPH_C32(0xc2f40000), SPH_C32(0x3cff0000), + SPH_C32(0x86773782), SPH_C32(0x4340fce1), SPH_C32(0x618183cf), + SPH_C32(0x425e5094) }, + { SPH_C32(0x81813d20), SPH_C32(0xcff20000), SPH_C32(0x0aba0000), + SPH_C32(0x5fa20000), SPH_C32(0xa0d4128d), SPH_C32(0x4faad129), + SPH_C32(0x42f8e481), SPH_C32(0xedbbcf44), SPH_C32(0xed801730), + SPH_C32(0x88130000), SPH_C32(0x94360000), SPH_C32(0x60510000), + SPH_C32(0x122328bd), SPH_C32(0x787e04c4), SPH_C32(0x7ab7dcf2), + SPH_C32(0xb18a07cc) }, + { SPH_C32(0x323a3e40), SPH_C32(0x64310000), SPH_C32(0x130d0000), + SPH_C32(0xbe670000), SPH_C32(0x5d075a93), SPH_C32(0x99b079b6), + SPH_C32(0x712204f5), SPH_C32(0xeda8d6a7), SPH_C32(0xcc6c1670), + SPH_C32(0xf2440000), SPH_C32(0xa9690000), SPH_C32(0x923c0000), + SPH_C32(0xe8c21863), SPH_C32(0xbca310b0), SPH_C32(0x64d0006e), + SPH_C32(0x4e6bbb15) }, + { SPH_C32(0xdabd3f30), SPH_C32(0xf9430000), SPH_C32(0x01d60000), + SPH_C32(0x6a450000), SPH_C32(0xaf8f31b4), SPH_C32(0x30919cf5), + SPH_C32(0x3fdab1ed), SPH_C32(0x8c20c516), SPH_C32(0x785b1610), + SPH_C32(0xfe080000), SPH_C32(0xffab0000), SPH_C32(0xce920000), + SPH_C32(0x7c96075c), SPH_C32(0x879de895), SPH_C32(0x7fe65f53), + SPH_C32(0xbdbfec4d) }, + { SPH_C32(0x860d3e20), SPH_C32(0x687d0000), SPH_C32(0x45cf0000), + SPH_C32(0xe2c90000), SPH_C32(0xc95345ac), SPH_C32(0xa28e8193), + SPH_C32(0x6a145bc8), SPH_C32(0x1e7c81ff), SPH_C32(0x90dc1760), + SPH_C32(0x637a0000), SPH_C32(0xed700000), SPH_C32(0x1ab00000), + SPH_C32(0x8e1e6c7b), SPH_C32(0x2ebc0dd6), SPH_C32(0x311eea4b), + SPH_C32(0xdc37fffc) }, + { SPH_C32(0x6e8a3f50), SPH_C32(0xf50f0000), SPH_C32(0x57140000), + SPH_C32(0x36eb0000), SPH_C32(0x3bdb2e8b), SPH_C32(0x0baf64d0), + SPH_C32(0x24eceed0), SPH_C32(0x7ff4924e), SPH_C32(0x24eb1700), + SPH_C32(0x6f360000), SPH_C32(0xbbb20000), SPH_C32(0x461e0000), + SPH_C32(0x1a4a7344), SPH_C32(0x1582f5f3), SPH_C32(0x2a28b576), + SPH_C32(0x2fe3a8a4) } +}; + +static const sph_u32 T512_10[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xa67f0001), SPH_C32(0x71378000), SPH_C32(0x19fc0000), + SPH_C32(0x96db0000), SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), + SPH_C32(0x2c6d478f), SPH_C32(0xac8e6c88), SPH_C32(0x50ff0004), + SPH_C32(0x45744000), SPH_C32(0x3dfb0000), SPH_C32(0x19e60000), + SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), SPH_C32(0xe1a8cc96), + SPH_C32(0x7b1bd6b9) }, + { SPH_C32(0xf7750009), SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), + SPH_C32(0x04920000), SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), + SPH_C32(0x7a87f14e), SPH_C32(0x9e16981a), SPH_C32(0xd46a0000), + SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), SPH_C32(0x4a290000), + SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), SPH_C32(0x98369604), + SPH_C32(0xf746c320) }, + { SPH_C32(0x510a0008), SPH_C32(0xbe0b4000), SPH_C32(0xda2a0000), + SPH_C32(0x92490000), SPH_C32(0x381e7454), SPH_C32(0x13229849), + SPH_C32(0x56eab6c1), SPH_C32(0x3298f492), SPH_C32(0x84950004), + SPH_C32(0xc8bc8000), SPH_C32(0x98540000), SPH_C32(0x53cf0000), + SPH_C32(0xe7f2147c), SPH_C32(0x28c6fd31), SPH_C32(0x799e5a92), + SPH_C32(0x8c5d1599) }, + { SPH_C32(0xd46a0000), SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), + SPH_C32(0x4a290000), SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), + SPH_C32(0x98369604), SPH_C32(0xf746c320), SPH_C32(0x231f0009), + SPH_C32(0x42f40000), SPH_C32(0x66790000), SPH_C32(0x4ebb0000), + SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), SPH_C32(0xe2b1674a), + SPH_C32(0x69505b3a) }, + { SPH_C32(0x72150001), SPH_C32(0xfcff4000), SPH_C32(0xbc530000), + SPH_C32(0xdcf20000), SPH_C32(0xc6c52f87), SPH_C32(0x227e289f), + SPH_C32(0xb45bd18b), SPH_C32(0x5bc8afa8), SPH_C32(0x73e0000d), + SPH_C32(0x07804000), SPH_C32(0x5b820000), SPH_C32(0x575d0000), + SPH_C32(0xe5670dd5), SPH_C32(0xd02ecb8b), SPH_C32(0x0319abdc), + SPH_C32(0x124b8d83) }, + { SPH_C32(0x231f0009), SPH_C32(0x42f40000), SPH_C32(0x66790000), + SPH_C32(0x4ebb0000), SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), + SPH_C32(0xe2b1674a), SPH_C32(0x69505b3a), SPH_C32(0xf7750009), + SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), SPH_C32(0x04920000), + SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), SPH_C32(0x7a87f14e), + SPH_C32(0x9e16981a) }, + { SPH_C32(0x85600008), SPH_C32(0x33c38000), SPH_C32(0x7f850000), + SPH_C32(0xd8600000), SPH_C32(0xc450362e), SPH_C32(0xda961e25), + SPH_C32(0xcedc20c5), SPH_C32(0xc5de37b2), SPH_C32(0xa78a000d), + SPH_C32(0x8a488000), SPH_C32(0xfe2d0000), SPH_C32(0x1d740000), + SPH_C32(0x19294faf), SPH_C32(0x199a4de7), SPH_C32(0x9b2f3dd8), + SPH_C32(0xe50d4ea3) }, + { SPH_C32(0x774400f0), SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), + SPH_C32(0x34140000), SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), + SPH_C32(0x0bc3cd1e), SPH_C32(0xcf3775cb), SPH_C32(0xf46c0050), + SPH_C32(0x96180000), SPH_C32(0x14a50000), SPH_C32(0x031f0000), + SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), SPH_C32(0x9ca470d2), + SPH_C32(0x8a341574) }, + { SPH_C32(0xd13b00f1), SPH_C32(0x806d8000), SPH_C32(0xec4e0000), + SPH_C32(0xa2cf0000), SPH_C32(0xb3bc1371), SPH_C32(0xb14142d6), + SPH_C32(0x27ae8a91), SPH_C32(0x63b91943), SPH_C32(0xa4930054), + SPH_C32(0xd36c4000), SPH_C32(0x295e0000), SPH_C32(0x1af90000), + SPH_C32(0x592828be), SPH_C32(0x87cd0544), SPH_C32(0x7d0cbc44), + SPH_C32(0xf12fc3cd) }, + { SPH_C32(0x803100f9), SPH_C32(0x3e66c000), SPH_C32(0x36640000), + SPH_C32(0x30860000), SPH_C32(0x8ba26725), SPH_C32(0xa263da9f), + SPH_C32(0x71443c50), SPH_C32(0x5121edd1), SPH_C32(0x20060050), + SPH_C32(0x1bd0c000), SPH_C32(0xb10a0000), SPH_C32(0x49360000), + SPH_C32(0xbeda3cc2), SPH_C32(0xaf0bf875), SPH_C32(0x0492e6d6), + SPH_C32(0x7d72d654) }, + { SPH_C32(0x264e00f8), SPH_C32(0x4f514000), SPH_C32(0x2f980000), + SPH_C32(0xa65d0000), SPH_C32(0xb1290ad8), SPH_C32(0x49a9746c), + SPH_C32(0x5d297bdf), SPH_C32(0xfdaf8159), SPH_C32(0x70f90054), + SPH_C32(0x5ea48000), SPH_C32(0x8cf10000), SPH_C32(0x50d00000), + SPH_C32(0xa5666ac4), SPH_C32(0x4e798328), SPH_C32(0xe53a2a40), + SPH_C32(0x066900ed) }, + { SPH_C32(0xa32e00f0), SPH_C32(0x7c92c000), SPH_C32(0x501d0000), + SPH_C32(0x7e3d0000), SPH_C32(0x75793cf6), SPH_C32(0x933f6a49), + SPH_C32(0x93f55b1a), SPH_C32(0x3871b6eb), SPH_C32(0xd7730059), + SPH_C32(0xd4ec0000), SPH_C32(0x72dc0000), SPH_C32(0x4da40000), + SPH_C32(0xbc4f256b), SPH_C32(0x57e3cecf), SPH_C32(0x7e151798), + SPH_C32(0xe3644e4e) }, + { SPH_C32(0x055100f1), SPH_C32(0x0da54000), SPH_C32(0x49e10000), + SPH_C32(0xe8e60000), SPH_C32(0x4ff2510b), SPH_C32(0x78f5c4ba), + SPH_C32(0xbf981c95), SPH_C32(0x94ffda63), SPH_C32(0x878c005d), + SPH_C32(0x91984000), SPH_C32(0x4f270000), SPH_C32(0x54420000), + SPH_C32(0xa7f3736d), SPH_C32(0xb691b592), SPH_C32(0x9fbddb0e), + SPH_C32(0x987f98f7) }, + { SPH_C32(0x545b00f9), SPH_C32(0xb3ae0000), SPH_C32(0x93cb0000), + SPH_C32(0x7aaf0000), SPH_C32(0x77ec255f), SPH_C32(0x6bd75cf3), + SPH_C32(0xe972aa54), SPH_C32(0xa6672ef1), SPH_C32(0x03190059), + SPH_C32(0x5924c000), SPH_C32(0xd7730000), SPH_C32(0x078d0000), + SPH_C32(0x40016711), SPH_C32(0x9e5748a3), SPH_C32(0xe623819c), + SPH_C32(0x14228d6e) }, + { SPH_C32(0xf22400f8), SPH_C32(0xc2998000), SPH_C32(0x8a370000), + SPH_C32(0xec740000), SPH_C32(0x4d6748a2), SPH_C32(0x801df200), + SPH_C32(0xc51feddb), SPH_C32(0x0ae94279), SPH_C32(0x53e6005d), + SPH_C32(0x1c508000), SPH_C32(0xea880000), SPH_C32(0x1e6b0000), + SPH_C32(0x5bbd3117), SPH_C32(0x7f2533fe), SPH_C32(0x078b4d0a), + SPH_C32(0x6f395bd7) }, + { SPH_C32(0xf46c0050), SPH_C32(0x96180000), SPH_C32(0x14a50000), + SPH_C32(0x031f0000), SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), + SPH_C32(0x9ca470d2), SPH_C32(0x8a341574), SPH_C32(0x832800a0), + SPH_C32(0x67420000), SPH_C32(0xe1170000), SPH_C32(0x370b0000), + SPH_C32(0xcba30034), SPH_C32(0x3c34923c), SPH_C32(0x9767bdcc), + SPH_C32(0x450360bf) }, + { SPH_C32(0x52130051), SPH_C32(0xe72f8000), SPH_C32(0x0d590000), + SPH_C32(0x95c40000), SPH_C32(0x781f1345), SPH_C32(0x8d75d0ea), + SPH_C32(0xb0c9375d), SPH_C32(0x26ba79fc), SPH_C32(0xd3d700a4), + SPH_C32(0x22364000), SPH_C32(0xdcec0000), SPH_C32(0x2eed0000), + SPH_C32(0xd01f5632), SPH_C32(0xdd46e961), SPH_C32(0x76cf715a), + SPH_C32(0x3e18b606) }, + { SPH_C32(0x03190059), SPH_C32(0x5924c000), SPH_C32(0xd7730000), + SPH_C32(0x078d0000), SPH_C32(0x40016711), SPH_C32(0x9e5748a3), + SPH_C32(0xe623819c), SPH_C32(0x14228d6e), SPH_C32(0x574200a0), + SPH_C32(0xea8ac000), SPH_C32(0x44b80000), SPH_C32(0x7d220000), + SPH_C32(0x37ed424e), SPH_C32(0xf5801450), SPH_C32(0x0f512bc8), + SPH_C32(0xb245a39f) }, + { SPH_C32(0xa5660058), SPH_C32(0x28134000), SPH_C32(0xce8f0000), + SPH_C32(0x91560000), SPH_C32(0x7a8a0aec), SPH_C32(0x759de650), + SPH_C32(0xca4ec613), SPH_C32(0xb8ace1e6), SPH_C32(0x07bd00a4), + SPH_C32(0xaffe8000), SPH_C32(0x79430000), SPH_C32(0x64c40000), + SPH_C32(0x2c511448), SPH_C32(0x14f26f0d), SPH_C32(0xeef9e75e), + SPH_C32(0xc95e7526) }, + { SPH_C32(0x20060050), SPH_C32(0x1bd0c000), SPH_C32(0xb10a0000), + SPH_C32(0x49360000), SPH_C32(0xbeda3cc2), SPH_C32(0xaf0bf875), + SPH_C32(0x0492e6d6), SPH_C32(0x7d72d654), SPH_C32(0xa03700a9), + SPH_C32(0x25b60000), SPH_C32(0x876e0000), SPH_C32(0x79b00000), + SPH_C32(0x35785be7), SPH_C32(0x0d6822ea), SPH_C32(0x75d6da86), + SPH_C32(0x2c533b85) }, + { SPH_C32(0x86790051), SPH_C32(0x6ae74000), SPH_C32(0xa8f60000), + SPH_C32(0xdfed0000), SPH_C32(0x8451513f), SPH_C32(0x44c15686), + SPH_C32(0x28ffa159), SPH_C32(0xd1fcbadc), SPH_C32(0xf0c800ad), + SPH_C32(0x60c24000), SPH_C32(0xba950000), SPH_C32(0x60560000), + SPH_C32(0x2ec40de1), SPH_C32(0xec1a59b7), SPH_C32(0x947e1610), + SPH_C32(0x5748ed3c) }, + { SPH_C32(0xd7730059), SPH_C32(0xd4ec0000), SPH_C32(0x72dc0000), + SPH_C32(0x4da40000), SPH_C32(0xbc4f256b), SPH_C32(0x57e3cecf), + SPH_C32(0x7e151798), SPH_C32(0xe3644e4e), SPH_C32(0x745d00a9), + SPH_C32(0xa87ec000), SPH_C32(0x22c10000), SPH_C32(0x33990000), + SPH_C32(0xc936199d), SPH_C32(0xc4dca486), SPH_C32(0xede04c82), + SPH_C32(0xdb15f8a5) }, + { SPH_C32(0x710c0058), SPH_C32(0xa5db8000), SPH_C32(0x6b200000), + SPH_C32(0xdb7f0000), SPH_C32(0x86c44896), SPH_C32(0xbc29603c), + SPH_C32(0x52785017), SPH_C32(0x4fea22c6), SPH_C32(0x24a200ad), + SPH_C32(0xed0a8000), SPH_C32(0x1f3a0000), SPH_C32(0x2a7f0000), + SPH_C32(0xd28a4f9b), SPH_C32(0x25aedfdb), SPH_C32(0x0c488014), + SPH_C32(0xa00e2e1c) }, + { SPH_C32(0x832800a0), SPH_C32(0x67420000), SPH_C32(0xe1170000), + SPH_C32(0x370b0000), SPH_C32(0xcba30034), SPH_C32(0x3c34923c), + SPH_C32(0x9767bdcc), SPH_C32(0x450360bf), SPH_C32(0x774400f0), + SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), SPH_C32(0x34140000), + SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), SPH_C32(0x0bc3cd1e), + SPH_C32(0xcf3775cb) }, + { SPH_C32(0x255700a1), SPH_C32(0x16758000), SPH_C32(0xf8eb0000), + SPH_C32(0xa1d00000), SPH_C32(0xf1286dc9), SPH_C32(0xd7fe3ccf), + SPH_C32(0xbb0afa43), SPH_C32(0xe98d0c37), SPH_C32(0x27bb00f4), + SPH_C32(0xb42e4000), SPH_C32(0xc8490000), SPH_C32(0x2df20000), + SPH_C32(0x928b288a), SPH_C32(0xbbf99778), SPH_C32(0xea6b0188), + SPH_C32(0xb42ca372) }, + { SPH_C32(0x745d00a9), SPH_C32(0xa87ec000), SPH_C32(0x22c10000), + SPH_C32(0x33990000), SPH_C32(0xc936199d), SPH_C32(0xc4dca486), + SPH_C32(0xede04c82), SPH_C32(0xdb15f8a5), SPH_C32(0xa32e00f0), + SPH_C32(0x7c92c000), SPH_C32(0x501d0000), SPH_C32(0x7e3d0000), + SPH_C32(0x75793cf6), SPH_C32(0x933f6a49), SPH_C32(0x93f55b1a), + SPH_C32(0x3871b6eb) }, + { SPH_C32(0xd22200a8), SPH_C32(0xd9494000), SPH_C32(0x3b3d0000), + SPH_C32(0xa5420000), SPH_C32(0xf3bd7460), SPH_C32(0x2f160a75), + SPH_C32(0xc18d0b0d), SPH_C32(0x779b942d), SPH_C32(0xf3d100f4), + SPH_C32(0x39e68000), SPH_C32(0x6de60000), SPH_C32(0x67db0000), + SPH_C32(0x6ec56af0), SPH_C32(0x724d1114), SPH_C32(0x725d978c), + SPH_C32(0x436a6052) }, + { SPH_C32(0x574200a0), SPH_C32(0xea8ac000), SPH_C32(0x44b80000), + SPH_C32(0x7d220000), SPH_C32(0x37ed424e), SPH_C32(0xf5801450), + SPH_C32(0x0f512bc8), SPH_C32(0xb245a39f), SPH_C32(0x545b00f9), + SPH_C32(0xb3ae0000), SPH_C32(0x93cb0000), SPH_C32(0x7aaf0000), + SPH_C32(0x77ec255f), SPH_C32(0x6bd75cf3), SPH_C32(0xe972aa54), + SPH_C32(0xa6672ef1) }, + { SPH_C32(0xf13d00a1), SPH_C32(0x9bbd4000), SPH_C32(0x5d440000), + SPH_C32(0xebf90000), SPH_C32(0x0d662fb3), SPH_C32(0x1e4abaa3), + SPH_C32(0x233c6c47), SPH_C32(0x1ecbcf17), SPH_C32(0x04a400fd), + SPH_C32(0xf6da4000), SPH_C32(0xae300000), SPH_C32(0x63490000), + SPH_C32(0x6c507359), SPH_C32(0x8aa527ae), SPH_C32(0x08da66c2), + SPH_C32(0xdd7cf848) }, + { SPH_C32(0xa03700a9), SPH_C32(0x25b60000), SPH_C32(0x876e0000), + SPH_C32(0x79b00000), SPH_C32(0x35785be7), SPH_C32(0x0d6822ea), + SPH_C32(0x75d6da86), SPH_C32(0x2c533b85), SPH_C32(0x803100f9), + SPH_C32(0x3e66c000), SPH_C32(0x36640000), SPH_C32(0x30860000), + SPH_C32(0x8ba26725), SPH_C32(0xa263da9f), SPH_C32(0x71443c50), + SPH_C32(0x5121edd1) }, + { SPH_C32(0x064800a8), SPH_C32(0x54818000), SPH_C32(0x9e920000), + SPH_C32(0xef6b0000), SPH_C32(0x0ff3361a), SPH_C32(0xe6a28c19), + SPH_C32(0x59bb9d09), SPH_C32(0x80dd570d), SPH_C32(0xd0ce00fd), + SPH_C32(0x7b128000), SPH_C32(0x0b9f0000), SPH_C32(0x29600000), + SPH_C32(0x901e3123), SPH_C32(0x4311a1c2), SPH_C32(0x90ecf0c6), + SPH_C32(0x2a3a3b68) } +}; + +static const sph_u32 T512_15[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x75a40000), SPH_C32(0xc28b2700), SPH_C32(0x94a40000), + SPH_C32(0x90f50000), SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), + SPH_C32(0x1767c483), SPH_C32(0xaedf667e), SPH_C32(0xd1660000), + SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), SPH_C32(0xf6940000), + SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), SPH_C32(0xb4431b17), + SPH_C32(0x857f3c2b) }, + { SPH_C32(0xd1660000), SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), + SPH_C32(0xf6940000), SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), + SPH_C32(0xb4431b17), SPH_C32(0x857f3c2b), SPH_C32(0xa4c20000), + SPH_C32(0xd9372400), SPH_C32(0x0a480000), SPH_C32(0x66610000), + SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), SPH_C32(0xa324df94), + SPH_C32(0x2ba05a55) }, + { SPH_C32(0xa4c20000), SPH_C32(0xd9372400), SPH_C32(0x0a480000), + SPH_C32(0x66610000), SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), + SPH_C32(0xa324df94), SPH_C32(0x2ba05a55), SPH_C32(0x75a40000), + SPH_C32(0xc28b2700), SPH_C32(0x94a40000), SPH_C32(0x90f50000), + SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), SPH_C32(0x1767c483), + SPH_C32(0xaedf667e) }, + { SPH_C32(0x75c90003), SPH_C32(0x0e10c000), SPH_C32(0xd1200000), + SPH_C32(0xbaea0000), SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), + SPH_C32(0xbb28761d), SPH_C32(0x00b72e2b), SPH_C32(0xeecf0001), + SPH_C32(0x6f564000), SPH_C32(0xf33e0000), SPH_C32(0xa79e0000), + SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), SPH_C32(0x4a3b40ba), + SPH_C32(0xfeabf254) }, + { SPH_C32(0x006d0003), SPH_C32(0xcc9be700), SPH_C32(0x45840000), + SPH_C32(0x2a1f0000), SPH_C32(0x70bc78de), SPH_C32(0xce96bcf9), + SPH_C32(0xac4fb29e), SPH_C32(0xae684855), SPH_C32(0x3fa90001), + SPH_C32(0x74ea4300), SPH_C32(0x6dd20000), SPH_C32(0x510a0000), + SPH_C32(0xbeb7373e), SPH_C32(0x78611737), SPH_C32(0xfe785bad), + SPH_C32(0x7bd4ce7f) }, + { SPH_C32(0xa4af0003), SPH_C32(0x15acc300), SPH_C32(0x4fcc0000), + SPH_C32(0x4c7e0000), SPH_C32(0x88c66a19), SPH_C32(0x48284ba5), + SPH_C32(0x0f6b6d0a), SPH_C32(0x85c81200), SPH_C32(0x4a0d0001), + SPH_C32(0xb6616400), SPH_C32(0xf9760000), SPH_C32(0xc1ff0000), + SPH_C32(0x45cf60de), SPH_C32(0x31af1c99), SPH_C32(0xe91f9f2e), + SPH_C32(0xd50ba801) }, + { SPH_C32(0xd10b0003), SPH_C32(0xd727e400), SPH_C32(0xdb680000), + SPH_C32(0xdc8b0000), SPH_C32(0x73be3df9), SPH_C32(0x01e6400b), + SPH_C32(0x180ca989), SPH_C32(0x2b17747e), SPH_C32(0x9b6b0001), + SPH_C32(0xaddd6700), SPH_C32(0x679a0000), SPH_C32(0x376b0000), + SPH_C32(0x46cd25f9), SPH_C32(0xfedfe06b), SPH_C32(0x5d5c8439), + SPH_C32(0x5074942a) }, + { SPH_C32(0xeecf0001), SPH_C32(0x6f564000), SPH_C32(0xf33e0000), + SPH_C32(0xa79e0000), SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), + SPH_C32(0x4a3b40ba), SPH_C32(0xfeabf254), SPH_C32(0x9b060002), + SPH_C32(0x61468000), SPH_C32(0x221e0000), SPH_C32(0x1d740000), + SPH_C32(0x36715d27), SPH_C32(0x30495c92), SPH_C32(0xf11336a7), + SPH_C32(0xfe1cdc7f) }, + { SPH_C32(0x9b6b0001), SPH_C32(0xaddd6700), SPH_C32(0x679a0000), + SPH_C32(0x376b0000), SPH_C32(0x46cd25f9), SPH_C32(0xfedfe06b), + SPH_C32(0x5d5c8439), SPH_C32(0x5074942a), SPH_C32(0x4a600002), + SPH_C32(0x7afa8300), SPH_C32(0xbcf20000), SPH_C32(0xebe00000), + SPH_C32(0x35731800), SPH_C32(0xff39a060), SPH_C32(0x45502db0), + SPH_C32(0x7b63e054) }, + { SPH_C32(0x3fa90001), SPH_C32(0x74ea4300), SPH_C32(0x6dd20000), + SPH_C32(0x510a0000), SPH_C32(0xbeb7373e), SPH_C32(0x78611737), + SPH_C32(0xfe785bad), SPH_C32(0x7bd4ce7f), SPH_C32(0x3fc40002), + SPH_C32(0xb871a400), SPH_C32(0x28560000), SPH_C32(0x7b150000), + SPH_C32(0xce0b4fe0), SPH_C32(0xb6f7abce), SPH_C32(0x5237e933), + SPH_C32(0xd5bc862a) }, + { SPH_C32(0x4a0d0001), SPH_C32(0xb6616400), SPH_C32(0xf9760000), + SPH_C32(0xc1ff0000), SPH_C32(0x45cf60de), SPH_C32(0x31af1c99), + SPH_C32(0xe91f9f2e), SPH_C32(0xd50ba801), SPH_C32(0xeea20002), + SPH_C32(0xa3cda700), SPH_C32(0xb6ba0000), SPH_C32(0x8d810000), + SPH_C32(0xcd090ac7), SPH_C32(0x7987573c), SPH_C32(0xe674f224), + SPH_C32(0x50c3ba01) }, + { SPH_C32(0x9b060002), SPH_C32(0x61468000), SPH_C32(0x221e0000), + SPH_C32(0x1d740000), SPH_C32(0x36715d27), SPH_C32(0x30495c92), + SPH_C32(0xf11336a7), SPH_C32(0xfe1cdc7f), SPH_C32(0x75c90003), + SPH_C32(0x0e10c000), SPH_C32(0xd1200000), SPH_C32(0xbaea0000), + SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), SPH_C32(0xbb28761d), + SPH_C32(0x00b72e2b) }, + { SPH_C32(0xeea20002), SPH_C32(0xa3cda700), SPH_C32(0xb6ba0000), + SPH_C32(0x8d810000), SPH_C32(0xcd090ac7), SPH_C32(0x7987573c), + SPH_C32(0xe674f224), SPH_C32(0x50c3ba01), SPH_C32(0xa4af0003), + SPH_C32(0x15acc300), SPH_C32(0x4fcc0000), SPH_C32(0x4c7e0000), + SPH_C32(0x88c66a19), SPH_C32(0x48284ba5), SPH_C32(0x0f6b6d0a), + SPH_C32(0x85c81200) }, + { SPH_C32(0x4a600002), SPH_C32(0x7afa8300), SPH_C32(0xbcf20000), + SPH_C32(0xebe00000), SPH_C32(0x35731800), SPH_C32(0xff39a060), + SPH_C32(0x45502db0), SPH_C32(0x7b63e054), SPH_C32(0xd10b0003), + SPH_C32(0xd727e400), SPH_C32(0xdb680000), SPH_C32(0xdc8b0000), + SPH_C32(0x73be3df9), SPH_C32(0x01e6400b), SPH_C32(0x180ca989), + SPH_C32(0x2b17747e) }, + { SPH_C32(0x3fc40002), SPH_C32(0xb871a400), SPH_C32(0x28560000), + SPH_C32(0x7b150000), SPH_C32(0xce0b4fe0), SPH_C32(0xb6f7abce), + SPH_C32(0x5237e933), SPH_C32(0xd5bc862a), SPH_C32(0x006d0003), + SPH_C32(0xcc9be700), SPH_C32(0x45840000), SPH_C32(0x2a1f0000), + SPH_C32(0x70bc78de), SPH_C32(0xce96bcf9), SPH_C32(0xac4fb29e), + SPH_C32(0xae684855) }, + { SPH_C32(0xf6800005), SPH_C32(0x3443c000), SPH_C32(0x24070000), + SPH_C32(0x8f3d0000), SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), + SPH_C32(0xcdc58b19), SPH_C32(0xd795ba31), SPH_C32(0xa67f0001), + SPH_C32(0x71378000), SPH_C32(0x19fc0000), SPH_C32(0x96db0000), + SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), SPH_C32(0x2c6d478f), + SPH_C32(0xac8e6c88) }, + { SPH_C32(0x83240005), SPH_C32(0xf6c8e700), SPH_C32(0xb0a30000), + SPH_C32(0x1fc80000), SPH_C32(0xda4f6c1b), SPH_C32(0x4376de00), + SPH_C32(0xdaa24f9a), SPH_C32(0x794adc4f), SPH_C32(0x77190001), + SPH_C32(0x6a8b8300), SPH_C32(0x87100000), SPH_C32(0x604f0000), + SPH_C32(0x398928da), SPH_C32(0x24ba5201), SPH_C32(0x982e5c98), + SPH_C32(0x29f150a3) }, + { SPH_C32(0x27e60005), SPH_C32(0x2fffc300), SPH_C32(0xbaeb0000), + SPH_C32(0x79a90000), SPH_C32(0x22357edc), SPH_C32(0xc5c8295c), + SPH_C32(0x7986900e), SPH_C32(0x52ea861a), SPH_C32(0x02bd0001), + SPH_C32(0xa800a400), SPH_C32(0x13b40000), SPH_C32(0xf0ba0000), + SPH_C32(0xc2f17f3a), SPH_C32(0x6d7459af), SPH_C32(0x8f49981b), + SPH_C32(0x872e36dd) }, + { SPH_C32(0x52420005), SPH_C32(0xed74e400), SPH_C32(0x2e4f0000), + SPH_C32(0xe95c0000), SPH_C32(0xd94d293c), SPH_C32(0x8c0622f2), + SPH_C32(0x6ee1548d), SPH_C32(0xfc35e064), SPH_C32(0xd3db0001), + SPH_C32(0xb3bca700), SPH_C32(0x8d580000), SPH_C32(0x062e0000), + SPH_C32(0xc1f33a1d), SPH_C32(0xa204a55d), SPH_C32(0x3b0a830c), + SPH_C32(0x02510af6) }, + { SPH_C32(0x83490006), SPH_C32(0x3a530000), SPH_C32(0xf5270000), + SPH_C32(0x35d70000), SPH_C32(0xaaf314c5), SPH_C32(0x8de062f9), + SPH_C32(0x76edfd04), SPH_C32(0xd722941a), SPH_C32(0x48b00000), + SPH_C32(0x1e61c000), SPH_C32(0xeac20000), SPH_C32(0x31450000), + SPH_C32(0x873e1fe4), SPH_C32(0x5cdb4536), SPH_C32(0x66560735), + SPH_C32(0x52259edc) }, + { SPH_C32(0xf6ed0006), SPH_C32(0xf8d82700), SPH_C32(0x61830000), + SPH_C32(0xa5220000), SPH_C32(0x518b4325), SPH_C32(0xc42e6957), + SPH_C32(0x618a3987), SPH_C32(0x79fdf264), SPH_C32(0x99d60000), + SPH_C32(0x05ddc300), SPH_C32(0x742e0000), SPH_C32(0xc7d10000), + SPH_C32(0x843c5ac3), SPH_C32(0x93abb9c4), SPH_C32(0xd2151c22), + SPH_C32(0xd75aa2f7) }, + { SPH_C32(0x522f0006), SPH_C32(0x21ef0300), SPH_C32(0x6bcb0000), + SPH_C32(0xc3430000), SPH_C32(0xa9f151e2), SPH_C32(0x42909e0b), + SPH_C32(0xc2aee613), SPH_C32(0x525da831), SPH_C32(0xec720000), + SPH_C32(0xc756e400), SPH_C32(0xe08a0000), SPH_C32(0x57240000), + SPH_C32(0x7f440d23), SPH_C32(0xda65b26a), SPH_C32(0xc572d8a1), + SPH_C32(0x7985c489) }, + { SPH_C32(0x278b0006), SPH_C32(0xe3642400), SPH_C32(0xff6f0000), + SPH_C32(0x53b60000), SPH_C32(0x52890602), SPH_C32(0x0b5e95a5), + SPH_C32(0xd5c92290), SPH_C32(0xfc82ce4f), SPH_C32(0x3d140000), + SPH_C32(0xdceae700), SPH_C32(0x7e660000), SPH_C32(0xa1b00000), + SPH_C32(0x7c464804), SPH_C32(0x15154e98), SPH_C32(0x7131c3b6), + SPH_C32(0xfcfaf8a2) }, + { SPH_C32(0x184f0004), SPH_C32(0x5b158000), SPH_C32(0xd7390000), + SPH_C32(0x28a30000), SPH_C32(0x9c8249e2), SPH_C32(0xbda93e6b), + SPH_C32(0x87fecba3), SPH_C32(0x293e4865), SPH_C32(0x3d790003), + SPH_C32(0x10710000), SPH_C32(0x3be20000), SPH_C32(0x8baf0000), + SPH_C32(0x0cfa30da), SPH_C32(0xdb83f261), SPH_C32(0xdd7e7128), + SPH_C32(0x5292b0f7) }, + { SPH_C32(0x6deb0004), SPH_C32(0x999ea700), SPH_C32(0x439d0000), + SPH_C32(0xb8560000), SPH_C32(0x67fa1e02), SPH_C32(0xf46735c5), + SPH_C32(0x90990f20), SPH_C32(0x87e12e1b), SPH_C32(0xec1f0003), + SPH_C32(0x0bcd0300), SPH_C32(0xa50e0000), SPH_C32(0x7d3b0000), + SPH_C32(0x0ff875fd), SPH_C32(0x14f30e93), SPH_C32(0x693d6a3f), + SPH_C32(0xd7ed8cdc) }, + { SPH_C32(0xc9290004), SPH_C32(0x40a98300), SPH_C32(0x49d50000), + SPH_C32(0xde370000), SPH_C32(0x9f800cc5), SPH_C32(0x72d9c299), + SPH_C32(0x33bdd0b4), SPH_C32(0xac41744e), SPH_C32(0x99bb0003), + SPH_C32(0xc9462400), SPH_C32(0x31aa0000), SPH_C32(0xedce0000), + SPH_C32(0xf480221d), SPH_C32(0x5d3d053d), SPH_C32(0x7e5aaebc), + SPH_C32(0x7932eaa2) }, + { SPH_C32(0xbc8d0004), SPH_C32(0x8222a400), SPH_C32(0xdd710000), + SPH_C32(0x4ec20000), SPH_C32(0x64f85b25), SPH_C32(0x3b17c937), + SPH_C32(0x24da1437), SPH_C32(0x029e1230), SPH_C32(0x48dd0003), + SPH_C32(0xd2fa2700), SPH_C32(0xaf460000), SPH_C32(0x1b5a0000), + SPH_C32(0xf782673a), SPH_C32(0x924df9cf), SPH_C32(0xca19b5ab), + SPH_C32(0xfc4dd689) }, + { SPH_C32(0x6d860007), SPH_C32(0x55054000), SPH_C32(0x06190000), + SPH_C32(0x92490000), SPH_C32(0x174666dc), SPH_C32(0x3af1893c), + SPH_C32(0x3cd6bdbe), SPH_C32(0x2989664e), SPH_C32(0xd3b60002), + SPH_C32(0x7f274000), SPH_C32(0xc8dc0000), SPH_C32(0x2c310000), + SPH_C32(0xb14f42c3), SPH_C32(0x6c9219a4), SPH_C32(0x97453192), + SPH_C32(0xac3942a3) }, + { SPH_C32(0x18220007), SPH_C32(0x978e6700), SPH_C32(0x92bd0000), + SPH_C32(0x02bc0000), SPH_C32(0xec3e313c), SPH_C32(0x733f8292), + SPH_C32(0x2bb1793d), SPH_C32(0x87560030), SPH_C32(0x02d00002), + SPH_C32(0x649b4300), SPH_C32(0x56300000), SPH_C32(0xdaa50000), + SPH_C32(0xb24d07e4), SPH_C32(0xa3e2e556), SPH_C32(0x23062a85), + SPH_C32(0x29467e88) }, + { SPH_C32(0xbce00007), SPH_C32(0x4eb94300), SPH_C32(0x98f50000), + SPH_C32(0x64dd0000), SPH_C32(0x144423fb), SPH_C32(0xf58175ce), + SPH_C32(0x8895a6a9), SPH_C32(0xacf65a65), SPH_C32(0x77740002), + SPH_C32(0xa6106400), SPH_C32(0xc2940000), SPH_C32(0x4a500000), + SPH_C32(0x49355004), SPH_C32(0xea2ceef8), SPH_C32(0x3461ee06), + SPH_C32(0x879918f6) }, + { SPH_C32(0xc9440007), SPH_C32(0x8c326400), SPH_C32(0x0c510000), + SPH_C32(0xf4280000), SPH_C32(0xef3c741b), SPH_C32(0xbc4f7e60), + SPH_C32(0x9ff2622a), SPH_C32(0x02293c1b), SPH_C32(0xa6120002), + SPH_C32(0xbdac6700), SPH_C32(0x5c780000), SPH_C32(0xbcc40000), + SPH_C32(0x4a371523), SPH_C32(0x255c120a), SPH_C32(0x8022f511), + SPH_C32(0x02e624dd) } +}; + +static const sph_u32 T512_20[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xc6730000), SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), + SPH_C32(0x218d0000), SPH_C32(0x23111587), SPH_C32(0x7913512f), + SPH_C32(0x1d28ac88), SPH_C32(0x378dd173), SPH_C32(0xaf220000), + SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), SPH_C32(0x8da20000), + SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), SPH_C32(0x9ac484f4), + SPH_C32(0x8b6c72bd) }, + { SPH_C32(0x0c720000), SPH_C32(0x49e50f00), SPH_C32(0x42790000), + SPH_C32(0x5cea0000), SPH_C32(0x33aa301a), SPH_C32(0x15822514), + SPH_C32(0x95a34b7b), SPH_C32(0xb44b0090), SPH_C32(0xfe220000), + SPH_C32(0xa7580500), SPH_C32(0x25d10000), SPH_C32(0xf7600000), + SPH_C32(0x893178da), SPH_C32(0x1fd4f860), SPH_C32(0x4ed0a315), + SPH_C32(0xa123ff9f) }, + { SPH_C32(0xca010000), SPH_C32(0xe6680f0c), SPH_C32(0xe6b80000), + SPH_C32(0x7d670000), SPH_C32(0x10bb259d), SPH_C32(0x6c91743b), + SPH_C32(0x888be7f3), SPH_C32(0x83c6d1e3), SPH_C32(0x51000000), + SPH_C32(0xdc340590), SPH_C32(0x42330000), SPH_C32(0x7ac20000), + SPH_C32(0x4eb566f3), SPH_C32(0xa863bc93), SPH_C32(0xd41427e1), + SPH_C32(0x2a4f8d22) }, + { SPH_C32(0xfe220000), SPH_C32(0xa7580500), SPH_C32(0x25d10000), + SPH_C32(0xf7600000), SPH_C32(0x893178da), SPH_C32(0x1fd4f860), + SPH_C32(0x4ed0a315), SPH_C32(0xa123ff9f), SPH_C32(0xf2500000), + SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), SPH_C32(0xab8a0000), + SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), SPH_C32(0xdb73e86e), + SPH_C32(0x1568ff0f) }, + { SPH_C32(0x38510000), SPH_C32(0x08d5050c), SPH_C32(0x81100000), + SPH_C32(0xd6ed0000), SPH_C32(0xaa206d5d), SPH_C32(0x66c7a94f), + SPH_C32(0x53f80f9d), SPH_C32(0x96ae2eec), SPH_C32(0x5d720000), + SPH_C32(0x95d10a90), SPH_C32(0x004a0000), SPH_C32(0x26280000), + SPH_C32(0x7d1f56e9), SPH_C32(0xbde19987), SPH_C32(0x41b76c9a), + SPH_C32(0x9e048db2) }, + { SPH_C32(0xf2500000), SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), + SPH_C32(0xab8a0000), SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), + SPH_C32(0xdb73e86e), SPH_C32(0x1568ff0f), SPH_C32(0x0c720000), + SPH_C32(0x49e50f00), SPH_C32(0x42790000), SPH_C32(0x5cea0000), + SPH_C32(0x33aa301a), SPH_C32(0x15822514), SPH_C32(0x95a34b7b), + SPH_C32(0xb44b0090) }, + { SPH_C32(0x34230000), SPH_C32(0x41300a0c), SPH_C32(0xc3690000), + SPH_C32(0x8a070000), SPH_C32(0x998a5d47), SPH_C32(0x73458c5b), + SPH_C32(0xc65b44e6), SPH_C32(0x22e52e7c), SPH_C32(0xa3500000), + SPH_C32(0x32890f90), SPH_C32(0x259b0000), SPH_C32(0xd1480000), + SPH_C32(0xf42e2e33), SPH_C32(0xa23561e7), SPH_C32(0x0f67cf8f), + SPH_C32(0x3f27722d) }, + { SPH_C32(0x45180000), SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), + SPH_C32(0x3b480000), SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), + SPH_C32(0x16bca6b0), SPH_C32(0xdf33f4df), SPH_C32(0xb83d0000), + SPH_C32(0x16710600), SPH_C32(0x379a0000), SPH_C32(0xf5b10000), + SPH_C32(0x228161ac), SPH_C32(0xae48f145), SPH_C32(0x66241616), + SPH_C32(0xc5c1eb3e) }, + { SPH_C32(0x836b0000), SPH_C32(0x0a38170c), SPH_C32(0x5dab0000), + SPH_C32(0x1ac50000), SPH_C32(0x3ddd01ab), SPH_C32(0x5a00c4f9), + SPH_C32(0x0b940a38), SPH_C32(0xe8be25ac), SPH_C32(0x171f0000), + SPH_C32(0x6d1d0690), SPH_C32(0x50780000), SPH_C32(0x78130000), + SPH_C32(0xe5057f85), SPH_C32(0x19ffb5b6), SPH_C32(0xfce092e2), + SPH_C32(0x4ead9983) }, + { SPH_C32(0x496a0000), SPH_C32(0xec501800), SPH_C32(0xbb130000), + SPH_C32(0x67a20000), SPH_C32(0x2d662436), SPH_C32(0x3691b0c2), + SPH_C32(0x831fedcb), SPH_C32(0x6b78f44f), SPH_C32(0x461f0000), + SPH_C32(0xb1290300), SPH_C32(0x124b0000), SPH_C32(0x02d10000), + SPH_C32(0xabb01976), SPH_C32(0xb19c0925), SPH_C32(0x28f4b503), + SPH_C32(0x64e214a1) }, + { SPH_C32(0x8f190000), SPH_C32(0x43dd180c), SPH_C32(0x1fd20000), + SPH_C32(0x462f0000), SPH_C32(0x0e7731b1), SPH_C32(0x4f82e1ed), + SPH_C32(0x9e374143), SPH_C32(0x5cf5253c), SPH_C32(0xe93d0000), + SPH_C32(0xca450390), SPH_C32(0x75a90000), SPH_C32(0x8f730000), + SPH_C32(0x6c34075f), SPH_C32(0x062b4dd6), SPH_C32(0xb23031f7), + SPH_C32(0xef8e661c) }, + { SPH_C32(0xbb3a0000), SPH_C32(0x02ed1200), SPH_C32(0xdcbb0000), + SPH_C32(0xcc280000), SPH_C32(0x97fd6cf6), SPH_C32(0x3cc76db6), + SPH_C32(0x586c05a5), SPH_C32(0x7e100b40), SPH_C32(0x4a6d0000), + SPH_C32(0xf8cc0c00), SPH_C32(0x50320000), SPH_C32(0x5e3b0000), + SPH_C32(0x981a296c), SPH_C32(0xa41e2c31), SPH_C32(0xbd57fe78), + SPH_C32(0xd0a91431) }, + { SPH_C32(0x7d490000), SPH_C32(0xad60120c), SPH_C32(0x787a0000), + SPH_C32(0xeda50000), SPH_C32(0xb4ec7971), SPH_C32(0x45d43c99), + SPH_C32(0x4544a92d), SPH_C32(0x499dda33), SPH_C32(0xe54f0000), + SPH_C32(0x83a00c90), SPH_C32(0x37d00000), SPH_C32(0xd3990000), + SPH_C32(0x5f9e3745), SPH_C32(0x13a968c2), SPH_C32(0x27937a8c), + SPH_C32(0x5bc5668c) }, + { SPH_C32(0xb7480000), SPH_C32(0x4b081d00), SPH_C32(0x9ec20000), + SPH_C32(0x90c20000), SPH_C32(0xa4575cec), SPH_C32(0x294548a2), + SPH_C32(0xcdcf4ede), SPH_C32(0xca5b0bd0), SPH_C32(0xb44f0000), + SPH_C32(0x5f940900), SPH_C32(0x75e30000), SPH_C32(0xa95b0000), + SPH_C32(0x112b51b6), SPH_C32(0xbbcad451), SPH_C32(0xf3875d6d), + SPH_C32(0x718aebae) }, + { SPH_C32(0x713b0000), SPH_C32(0xe4851d0c), SPH_C32(0x3a030000), + SPH_C32(0xb14f0000), SPH_C32(0x8746496b), SPH_C32(0x5056198d), + SPH_C32(0xd0e7e256), SPH_C32(0xfdd6daa3), SPH_C32(0x1b6d0000), + SPH_C32(0x24f80990), SPH_C32(0x12010000), SPH_C32(0x24f90000), + SPH_C32(0xd6af4f9f), SPH_C32(0x0c7d90a2), SPH_C32(0x6943d999), + SPH_C32(0xfae69913) }, + { SPH_C32(0xb83d0000), SPH_C32(0x16710600), SPH_C32(0x379a0000), + SPH_C32(0xf5b10000), SPH_C32(0x228161ac), SPH_C32(0xae48f145), + SPH_C32(0x66241616), SPH_C32(0xc5c1eb3e), SPH_C32(0xfd250000), + SPH_C32(0xb3c41100), SPH_C32(0xcef00000), SPH_C32(0xcef90000), + SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), SPH_C32(0x7098b0a6), + SPH_C32(0x1af21fe1) }, + { SPH_C32(0x7e4e0000), SPH_C32(0xb9fc060c), SPH_C32(0x935b0000), + SPH_C32(0xd43c0000), SPH_C32(0x0190742b), SPH_C32(0xd75ba06a), + SPH_C32(0x7b0cba9e), SPH_C32(0xf24c3a4d), SPH_C32(0x52070000), + SPH_C32(0xc8a81190), SPH_C32(0xa9120000), SPH_C32(0x435b0000), + SPH_C32(0xfbc96ba9), SPH_C32(0x3aec2060), SPH_C32(0xea5c3452), + SPH_C32(0x919e6d5c) }, + { SPH_C32(0xb44f0000), SPH_C32(0x5f940900), SPH_C32(0x75e30000), + SPH_C32(0xa95b0000), SPH_C32(0x112b51b6), SPH_C32(0xbbcad451), + SPH_C32(0xf3875d6d), SPH_C32(0x718aebae), SPH_C32(0x03070000), + SPH_C32(0x149c1400), SPH_C32(0xeb210000), SPH_C32(0x39990000), + SPH_C32(0xb57c0d5a), SPH_C32(0x928f9cf3), SPH_C32(0x3e4813b3), + SPH_C32(0xbbd1e07e) }, + { SPH_C32(0x723c0000), SPH_C32(0xf019090c), SPH_C32(0xd1220000), + SPH_C32(0x88d60000), SPH_C32(0x323a4431), SPH_C32(0xc2d9857e), + SPH_C32(0xeeaff1e5), SPH_C32(0x46073add), SPH_C32(0xac250000), + SPH_C32(0x6ff01490), SPH_C32(0x8cc30000), SPH_C32(0xb43b0000), + SPH_C32(0x72f81373), SPH_C32(0x2538d800), SPH_C32(0xa48c9747), + SPH_C32(0x30bd92c3) }, + { SPH_C32(0x461f0000), SPH_C32(0xb1290300), SPH_C32(0x124b0000), + SPH_C32(0x02d10000), SPH_C32(0xabb01976), SPH_C32(0xb19c0925), + SPH_C32(0x28f4b503), SPH_C32(0x64e214a1), SPH_C32(0x0f750000), + SPH_C32(0x5d791b00), SPH_C32(0xa9580000), SPH_C32(0x65730000), + SPH_C32(0x86d63d40), SPH_C32(0x870db9e7), SPH_C32(0xabeb58c8), + SPH_C32(0x0f9ae0ee) }, + { SPH_C32(0x806c0000), SPH_C32(0x1ea4030c), SPH_C32(0xb68a0000), + SPH_C32(0x235c0000), SPH_C32(0x88a10cf1), SPH_C32(0xc88f580a), + SPH_C32(0x35dc198b), SPH_C32(0x536fc5d2), SPH_C32(0xa0570000), + SPH_C32(0x26151b90), SPH_C32(0xceba0000), SPH_C32(0xe8d10000), + SPH_C32(0x41522369), SPH_C32(0x30bafd14), SPH_C32(0x312fdc3c), + SPH_C32(0x84f69253) }, + { SPH_C32(0x4a6d0000), SPH_C32(0xf8cc0c00), SPH_C32(0x50320000), + SPH_C32(0x5e3b0000), SPH_C32(0x981a296c), SPH_C32(0xa41e2c31), + SPH_C32(0xbd57fe78), SPH_C32(0xd0a91431), SPH_C32(0xf1570000), + SPH_C32(0xfa211e00), SPH_C32(0x8c890000), SPH_C32(0x92130000), + SPH_C32(0x0fe7459a), SPH_C32(0x98d94187), SPH_C32(0xe53bfbdd), + SPH_C32(0xaeb91f71) }, + { SPH_C32(0x8c1e0000), SPH_C32(0x57410c0c), SPH_C32(0xf4f30000), + SPH_C32(0x7fb60000), SPH_C32(0xbb0b3ceb), SPH_C32(0xdd0d7d1e), + SPH_C32(0xa07f52f0), SPH_C32(0xe724c542), SPH_C32(0x5e750000), + SPH_C32(0x814d1e90), SPH_C32(0xeb6b0000), SPH_C32(0x1fb10000), + SPH_C32(0xc8635bb3), SPH_C32(0x2f6e0574), SPH_C32(0x7fff7f29), + SPH_C32(0x25d56dcc) }, + { SPH_C32(0xfd250000), SPH_C32(0xb3c41100), SPH_C32(0xcef00000), + SPH_C32(0xcef90000), SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), + SPH_C32(0x7098b0a6), SPH_C32(0x1af21fe1), SPH_C32(0x45180000), + SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), SPH_C32(0x3b480000), + SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), SPH_C32(0x16bca6b0), + SPH_C32(0xdf33f4df) }, + { SPH_C32(0x3b560000), SPH_C32(0x1c49110c), SPH_C32(0x6a310000), + SPH_C32(0xef740000), SPH_C32(0x1f5c6007), SPH_C32(0xf44835bc), + SPH_C32(0x6db01c2e), SPH_C32(0x2d7fce92), SPH_C32(0xea3a0000), + SPH_C32(0xded91790), SPH_C32(0x9e880000), SPH_C32(0xb6ea0000), + SPH_C32(0xd9480a05), SPH_C32(0x94a4d125), SPH_C32(0x8c782244), + SPH_C32(0x545f8662) }, + { SPH_C32(0xf1570000), SPH_C32(0xfa211e00), SPH_C32(0x8c890000), + SPH_C32(0x92130000), SPH_C32(0x0fe7459a), SPH_C32(0x98d94187), + SPH_C32(0xe53bfbdd), SPH_C32(0xaeb91f71), SPH_C32(0xbb3a0000), + SPH_C32(0x02ed1200), SPH_C32(0xdcbb0000), SPH_C32(0xcc280000), + SPH_C32(0x97fd6cf6), SPH_C32(0x3cc76db6), SPH_C32(0x586c05a5), + SPH_C32(0x7e100b40) }, + { SPH_C32(0x37240000), SPH_C32(0x55ac1e0c), SPH_C32(0x28480000), + SPH_C32(0xb39e0000), SPH_C32(0x2cf6501d), SPH_C32(0xe1ca10a8), + SPH_C32(0xf8135755), SPH_C32(0x9934ce02), SPH_C32(0x14180000), + SPH_C32(0x79811290), SPH_C32(0xbb590000), SPH_C32(0x418a0000), + SPH_C32(0x507972df), SPH_C32(0x8b702945), SPH_C32(0xc2a88151), + SPH_C32(0xf57c79fd) }, + { SPH_C32(0x03070000), SPH_C32(0x149c1400), SPH_C32(0xeb210000), + SPH_C32(0x39990000), SPH_C32(0xb57c0d5a), SPH_C32(0x928f9cf3), + SPH_C32(0x3e4813b3), SPH_C32(0xbbd1e07e), SPH_C32(0xb7480000), + SPH_C32(0x4b081d00), SPH_C32(0x9ec20000), SPH_C32(0x90c20000), + SPH_C32(0xa4575cec), SPH_C32(0x294548a2), SPH_C32(0xcdcf4ede), + SPH_C32(0xca5b0bd0) }, + { SPH_C32(0xc5740000), SPH_C32(0xbb11140c), SPH_C32(0x4fe00000), + SPH_C32(0x18140000), SPH_C32(0x966d18dd), SPH_C32(0xeb9ccddc), + SPH_C32(0x2360bf3b), SPH_C32(0x8c5c310d), SPH_C32(0x186a0000), + SPH_C32(0x30641d90), SPH_C32(0xf9200000), SPH_C32(0x1d600000), + SPH_C32(0x63d342c5), SPH_C32(0x9ef20c51), SPH_C32(0x570bca2a), + SPH_C32(0x4137796d) }, + { SPH_C32(0x0f750000), SPH_C32(0x5d791b00), SPH_C32(0xa9580000), + SPH_C32(0x65730000), SPH_C32(0x86d63d40), SPH_C32(0x870db9e7), + SPH_C32(0xabeb58c8), SPH_C32(0x0f9ae0ee), SPH_C32(0x496a0000), + SPH_C32(0xec501800), SPH_C32(0xbb130000), SPH_C32(0x67a20000), + SPH_C32(0x2d662436), SPH_C32(0x3691b0c2), SPH_C32(0x831fedcb), + SPH_C32(0x6b78f44f) }, + { SPH_C32(0xc9060000), SPH_C32(0xf2f41b0c), SPH_C32(0x0d990000), + SPH_C32(0x44fe0000), SPH_C32(0xa5c728c7), SPH_C32(0xfe1ee8c8), + SPH_C32(0xb6c3f440), SPH_C32(0x3817319d), SPH_C32(0xe6480000), + SPH_C32(0x973c1890), SPH_C32(0xdcf10000), SPH_C32(0xea000000), + SPH_C32(0xeae23a1f), SPH_C32(0x8126f431), SPH_C32(0x19db693f), + SPH_C32(0xe01486f2) } +}; + +static const sph_u32 T512_25[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x14190000), SPH_C32(0x23ca003c), SPH_C32(0x50df0000), + SPH_C32(0x44b60000), SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), + SPH_C32(0x61e610b0), SPH_C32(0xdbcadb80), SPH_C32(0xe3430000), + SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), SPH_C32(0xaa4e0000), + SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), SPH_C32(0x123db156), + SPH_C32(0x3a4e99d7) }, + { SPH_C32(0xe3430000), SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), + SPH_C32(0xaa4e0000), SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), + SPH_C32(0x123db156), SPH_C32(0x3a4e99d7), SPH_C32(0xf75a0000), + SPH_C32(0x19840028), SPH_C32(0xa2190000), SPH_C32(0xeef80000), + SPH_C32(0xc0722516), SPH_C32(0x19981260), SPH_C32(0x73dba1e6), + SPH_C32(0xe1844257) }, + { SPH_C32(0xf75a0000), SPH_C32(0x19840028), SPH_C32(0xa2190000), + SPH_C32(0xeef80000), SPH_C32(0xc0722516), SPH_C32(0x19981260), + SPH_C32(0x73dba1e6), SPH_C32(0xe1844257), SPH_C32(0x14190000), + SPH_C32(0x23ca003c), SPH_C32(0x50df0000), SPH_C32(0x44b60000), + SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), SPH_C32(0x61e610b0), + SPH_C32(0xdbcadb80) }, + { SPH_C32(0x54500000), SPH_C32(0x0671005c), SPH_C32(0x25ae0000), + SPH_C32(0x6a1e0000), SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), + SPH_C32(0xbfba18c3), SPH_C32(0x7e715d17), SPH_C32(0xbc8d0000), + SPH_C32(0xfc3b0018), SPH_C32(0x19830000), SPH_C32(0xd10b0000), + SPH_C32(0xae1878c4), SPH_C32(0x42a69856), SPH_C32(0x0012da37), + SPH_C32(0x2c3b504e) }, + { SPH_C32(0x40490000), SPH_C32(0x25bb0060), SPH_C32(0x75710000), + SPH_C32(0x2ea80000), SPH_C32(0x35c9296f), SPH_C32(0x5abd2967), + SPH_C32(0xde5c0873), SPH_C32(0xa5bb49697), SPH_C32(0x5fce0000), + SPH_C32(0xc675000c), SPH_C32(0xeb450000), SPH_C32(0x7b450000), + SPH_C32(0x75063a62), SPH_C32(0x67cd2643), SPH_C32(0x122f6b61), + SPH_C32(0x1675c999) }, + { SPH_C32(0xb7130000), SPH_C32(0x3c3f0048), SPH_C32(0xd7680000), + SPH_C32(0xc0500000), SPH_C32(0xf5bb0c79), SPH_C32(0x43253b07), + SPH_C32(0xad87a995), SPH_C32(0x443fc4c0), SPH_C32(0x4bd70000), + SPH_C32(0xe5bf0030), SPH_C32(0xbb9a0000), SPH_C32(0x3ff30000), + SPH_C32(0x6e6a5dd2), SPH_C32(0x5b3e8a36), SPH_C32(0x73c97bd1), + SPH_C32(0xcdbf1219) }, + { SPH_C32(0xa30a0000), SPH_C32(0x1ff50074), SPH_C32(0x87b70000), + SPH_C32(0x84e60000), SPH_C32(0xeed76bc9), SPH_C32(0x7fd69772), + SPH_C32(0xcc61b925), SPH_C32(0x9ff51f40), SPH_C32(0xa8940000), + SPH_C32(0xdff10024), SPH_C32(0x495c0000), SPH_C32(0x95bd0000), + SPH_C32(0xb5741f74), SPH_C32(0x7e553423), SPH_C32(0x61f4ca87), + SPH_C32(0xf7f18bce) }, + { SPH_C32(0xbc8d0000), SPH_C32(0xfc3b0018), SPH_C32(0x19830000), + SPH_C32(0xd10b0000), SPH_C32(0xae1878c4), SPH_C32(0x42a69856), + SPH_C32(0x0012da37), SPH_C32(0x2c3b504e), SPH_C32(0xe8dd0000), + SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), SPH_C32(0xbb150000), + SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), SPH_C32(0xbfa8c2f4), + SPH_C32(0x524a0d59) }, + { SPH_C32(0xa8940000), SPH_C32(0xdff10024), SPH_C32(0x495c0000), + SPH_C32(0x95bd0000), SPH_C32(0xb5741f74), SPH_C32(0x7e553423), + SPH_C32(0x61f4ca87), SPH_C32(0xf7f18bce), SPH_C32(0x0b9e0000), + SPH_C32(0xc0040050), SPH_C32(0xceeb0000), SPH_C32(0x115b0000), + SPH_C32(0x5ba374bd), SPH_C32(0x0183a351), SPH_C32(0xad9573a2), + SPH_C32(0x6804948e) }, + { SPH_C32(0x5fce0000), SPH_C32(0xc675000c), SPH_C32(0xeb450000), + SPH_C32(0x7b450000), SPH_C32(0x75063a62), SPH_C32(0x67cd2643), + SPH_C32(0x122f6b61), SPH_C32(0x1675c999), SPH_C32(0x1f870000), + SPH_C32(0xe3ce006c), SPH_C32(0x9e340000), SPH_C32(0x55ed0000), + SPH_C32(0x40cf130d), SPH_C32(0x3d700f24), SPH_C32(0xcc736312), + SPH_C32(0xb3ce4f0e) }, + { SPH_C32(0x4bd70000), SPH_C32(0xe5bf0030), SPH_C32(0xbb9a0000), + SPH_C32(0x3ff30000), SPH_C32(0x6e6a5dd2), SPH_C32(0x5b3e8a36), + SPH_C32(0x73c97bd1), SPH_C32(0xcdbf1219), SPH_C32(0xfcc40000), + SPH_C32(0xd9800078), SPH_C32(0x6cf20000), SPH_C32(0xffa30000), + SPH_C32(0x9bd151ab), SPH_C32(0x181bb131), SPH_C32(0xde4ed244), + SPH_C32(0x8980d6d9) }, + { SPH_C32(0xe8dd0000), SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), + SPH_C32(0xbb150000), SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), + SPH_C32(0xbfa8c2f4), SPH_C32(0x524a0d59), SPH_C32(0x54500000), + SPH_C32(0x0671005c), SPH_C32(0x25ae0000), SPH_C32(0x6a1e0000), + SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), SPH_C32(0xbfba18c3), + SPH_C32(0x7e715d17) }, + { SPH_C32(0xfcc40000), SPH_C32(0xd9800078), SPH_C32(0x6cf20000), + SPH_C32(0xffa30000), SPH_C32(0x9bd151ab), SPH_C32(0x181bb131), + SPH_C32(0xde4ed244), SPH_C32(0x8980d6d9), SPH_C32(0xb7130000), + SPH_C32(0x3c3f0048), SPH_C32(0xd7680000), SPH_C32(0xc0500000), + SPH_C32(0xf5bb0c79), SPH_C32(0x43253b07), SPH_C32(0xad87a995), + SPH_C32(0x443fc4c0) }, + { SPH_C32(0x0b9e0000), SPH_C32(0xc0040050), SPH_C32(0xceeb0000), + SPH_C32(0x115b0000), SPH_C32(0x5ba374bd), SPH_C32(0x0183a351), + SPH_C32(0xad9573a2), SPH_C32(0x6804948e), SPH_C32(0xa30a0000), + SPH_C32(0x1ff50074), SPH_C32(0x87b70000), SPH_C32(0x84e60000), + SPH_C32(0xeed76bc9), SPH_C32(0x7fd69772), SPH_C32(0xcc61b925), + SPH_C32(0x9ff51f40) }, + { SPH_C32(0x1f870000), SPH_C32(0xe3ce006c), SPH_C32(0x9e340000), + SPH_C32(0x55ed0000), SPH_C32(0x40cf130d), SPH_C32(0x3d700f24), + SPH_C32(0xcc736312), SPH_C32(0xb3ce4f0e), SPH_C32(0x40490000), + SPH_C32(0x25bb0060), SPH_C32(0x75710000), SPH_C32(0x2ea80000), + SPH_C32(0x35c9296f), SPH_C32(0x5abd2967), SPH_C32(0xde5c0873), + SPH_C32(0xa5bb49697) }, + { SPH_C32(0x69510000), SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), + SPH_C32(0xac2f0000), SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), + SPH_C32(0x87ec287c), SPH_C32(0xbce1a3ce), SPH_C32(0xc6730000), + SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), SPH_C32(0x218d0000), + SPH_C32(0x23111587), SPH_C32(0x7913512f), SPH_C32(0x1d28ac88), + SPH_C32(0x378dd173) }, + { SPH_C32(0x7d480000), SPH_C32(0xf72b00a0), SPH_C32(0x93fc0000), + SPH_C32(0xe8990000), SPH_C32(0xfff96c1e), SPH_C32(0xf257b9a9), + SPH_C32(0xe60a38cc), SPH_C32(0x672b784e), SPH_C32(0x25300000), + SPH_C32(0x95c30018), SPH_C32(0x56070000), SPH_C32(0x8bc30000), + SPH_C32(0xf80f5721), SPH_C32(0x5c78ef3a), SPH_C32(0x0f151dde), + SPH_C32(0x0dc348a4) }, + { SPH_C32(0x8a120000), SPH_C32(0xeeaf0088), SPH_C32(0x31e50000), + SPH_C32(0x06610000), SPH_C32(0x3f8b4908), SPH_C32(0xebcfabc9), + SPH_C32(0x95d1992a), SPH_C32(0x86af3a19), SPH_C32(0x31290000), + SPH_C32(0xb6090024), SPH_C32(0x06d80000), SPH_C32(0xcf750000), + SPH_C32(0xe3633091), SPH_C32(0x608b434f), SPH_C32(0x6ef30d6e), + SPH_C32(0xd6099324) }, + { SPH_C32(0x9e0b0000), SPH_C32(0xcd6500b4), SPH_C32(0x613a0000), + SPH_C32(0x42d70000), SPH_C32(0x24e72eb8), SPH_C32(0xd73c07bc), + SPH_C32(0xf437899a), SPH_C32(0x5d65e199), SPH_C32(0xd26a0000), + SPH_C32(0x8c470030), SPH_C32(0xf41e0000), SPH_C32(0x653b0000), + SPH_C32(0x387d7237), SPH_C32(0x45e0fd5a), SPH_C32(0x7ccebc38), + SPH_C32(0xec470af3) }, + { SPH_C32(0x3d010000), SPH_C32(0xd29000c0), SPH_C32(0xe68d0000), + SPH_C32(0xc6310000), SPH_C32(0xca304571), SPH_C32(0xa8ea90ce), + SPH_C32(0x385630bf), SPH_C32(0xc290fed9), SPH_C32(0x7afe0000), + SPH_C32(0x53b60014), SPH_C32(0xbd420000), SPH_C32(0xf0860000), + SPH_C32(0x8d096d43), SPH_C32(0x3bb5c979), SPH_C32(0x1d3a76bf), + SPH_C32(0x1bb6813d) }, + { SPH_C32(0x29180000), SPH_C32(0xf15a00fc), SPH_C32(0xb6520000), + SPH_C32(0x82870000), SPH_C32(0xd15c22c1), SPH_C32(0x94193cbb), + SPH_C32(0x59b0200f), SPH_C32(0x195a2559), SPH_C32(0x99bd0000), + SPH_C32(0x69f80000), SPH_C32(0x4f840000), SPH_C32(0x5ac80000), + SPH_C32(0x56172fe5), SPH_C32(0x1ede776c), SPH_C32(0x0f07c7e9), + SPH_C32(0x21f818ea) }, + { SPH_C32(0xde420000), SPH_C32(0xe8de00d4), SPH_C32(0x144b0000), + SPH_C32(0x6c7f0000), SPH_C32(0x112e07d7), SPH_C32(0x8d812edb), + SPH_C32(0x2a6b81e9), SPH_C32(0xf8de670e), SPH_C32(0x8da40000), + SPH_C32(0x4a32003c), SPH_C32(0x1f5b0000), SPH_C32(0x1e7e0000), + SPH_C32(0x4d7b4855), SPH_C32(0x222ddb19), SPH_C32(0x6ee1d759), + SPH_C32(0xfa32c36a) }, + { SPH_C32(0xca5b0000), SPH_C32(0xcb1400e8), SPH_C32(0x44940000), + SPH_C32(0x28c90000), SPH_C32(0x0a426067), SPH_C32(0xb17282ae), + SPH_C32(0x4b8d9159), SPH_C32(0x2314bc8e), SPH_C32(0x6ee70000), + SPH_C32(0x707c0028), SPH_C32(0xed9d0000), SPH_C32(0xb4300000), + SPH_C32(0x96650af3), SPH_C32(0x0746650c), SPH_C32(0x7cdc660f), + SPH_C32(0xc07c5abd) }, + { SPH_C32(0xd5dc0000), SPH_C32(0x28da0084), SPH_C32(0xdaa00000), + SPH_C32(0x7d240000), SPH_C32(0x4a8d736a), SPH_C32(0x8c028d8a), + SPH_C32(0x87fef24b), SPH_C32(0x90daf380), SPH_C32(0x2eae0000), + SPH_C32(0x55c70048), SPH_C32(0x98ec0000), SPH_C32(0x9a980000), + SPH_C32(0xa3ac239c), SPH_C32(0x5dfb4c6b), SPH_C32(0xa2806e7c), + SPH_C32(0x65c7dc2a) }, + { SPH_C32(0xc1c50000), SPH_C32(0x0b1000b8), SPH_C32(0x8a7f0000), + SPH_C32(0x39920000), SPH_C32(0x51e114da), SPH_C32(0xb0f121ff), + SPH_C32(0xe618e2fb), SPH_C32(0x4b102800), SPH_C32(0xcded0000), + SPH_C32(0x6f89005c), SPH_C32(0x6a2a0000), SPH_C32(0x30d60000), + SPH_C32(0x78b2613a), SPH_C32(0x7890f27e), SPH_C32(0xb0bddf2a), + SPH_C32(0x5f8945fd) }, + { SPH_C32(0x369f0000), SPH_C32(0x12940090), SPH_C32(0x28660000), + SPH_C32(0xd76a0000), SPH_C32(0x919331cc), SPH_C32(0xa969339f), + SPH_C32(0x95c3431d), SPH_C32(0xaa946a57), SPH_C32(0xd9f40000), + SPH_C32(0x4c430060), SPH_C32(0x3af50000), SPH_C32(0x74600000), + SPH_C32(0x63de068a), SPH_C32(0x44635e0b), SPH_C32(0xd15bcf9a), + SPH_C32(0x84439e7d) }, + { SPH_C32(0x22860000), SPH_C32(0x315e00ac), SPH_C32(0x78b90000), + SPH_C32(0x93dc0000), SPH_C32(0x8aff567c), SPH_C32(0x959a9fea), + SPH_C32(0xf42553ad), SPH_C32(0x715eb1d7), SPH_C32(0x3ab70000), + SPH_C32(0x760d0074), SPH_C32(0xc8330000), SPH_C32(0xde2e0000), + SPH_C32(0xb8c0442c), SPH_C32(0x6108e01e), SPH_C32(0xc3667ecc), + SPH_C32(0xbe0d07aa) }, + { SPH_C32(0x818c0000), SPH_C32(0x2eab00d8), SPH_C32(0xff0e0000), + SPH_C32(0x173a0000), SPH_C32(0x64283db5), SPH_C32(0xea4c0898), + SPH_C32(0x3844ea88), SPH_C32(0xeeabae97), SPH_C32(0x92230000), + SPH_C32(0xa9fc0050), SPH_C32(0x816f0000), SPH_C32(0x4b930000), + SPH_C32(0x0db45b58), SPH_C32(0x1f5dd43d), SPH_C32(0xa292b44b), + SPH_C32(0x49fc8c64) }, + { SPH_C32(0x95950000), SPH_C32(0x0d6100e4), SPH_C32(0xafd10000), + SPH_C32(0x538c0000), SPH_C32(0x7f445a05), SPH_C32(0xd6bfa4ed), + SPH_C32(0x59a2fa38), SPH_C32(0x35617517), SPH_C32(0x71600000), + SPH_C32(0x93b20044), SPH_C32(0x73a90000), SPH_C32(0xe1dd0000), + SPH_C32(0xd6aa19fe), SPH_C32(0x3a366a28), SPH_C32(0xb0af051d), + SPH_C32(0x73b215b3) }, + { SPH_C32(0x62cf0000), SPH_C32(0x14e500cc), SPH_C32(0x0dc80000), + SPH_C32(0xbd740000), SPH_C32(0xbf367f13), SPH_C32(0xcf27b68d), + SPH_C32(0x2a795bde), SPH_C32(0xd4e53740), SPH_C32(0x65790000), + SPH_C32(0xb0780078), SPH_C32(0x23760000), SPH_C32(0xa56b0000), + SPH_C32(0xcdc67e4e), SPH_C32(0x06c5c65d), SPH_C32(0xd14915ad), + SPH_C32(0xa878ce33) }, + { SPH_C32(0x76d60000), SPH_C32(0x372f00f0), SPH_C32(0x5d170000), + SPH_C32(0xf9c20000), SPH_C32(0xa45a18a3), SPH_C32(0xf3d41af8), + SPH_C32(0x4b9f4b6e), SPH_C32(0x0f2fecc0), SPH_C32(0x863a0000), + SPH_C32(0x8a36006c), SPH_C32(0xd1b00000), SPH_C32(0x0f250000), + SPH_C32(0x16d83ce8), SPH_C32(0x23ae7848), SPH_C32(0xc374a4fb), + SPH_C32(0x923657e4) } +}; + +static const sph_u32 T512_30[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x1e4e0000), SPH_C32(0xdecf0000), SPH_C32(0x6df80180), + SPH_C32(0x77240000), SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), + SPH_C32(0xcda31812), SPH_C32(0x98aa496e), SPH_C32(0xb2060000), + SPH_C32(0xc5690000), SPH_C32(0x28031200), SPH_C32(0x74670000), + SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), SPH_C32(0x33d1dfec), + SPH_C32(0x094e3198) }, + { SPH_C32(0xaec30000), SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), + SPH_C32(0x2c150000), SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), + SPH_C32(0xab92f78f), SPH_C32(0xa312567b), SPH_C32(0xdb250000), + SPH_C32(0x09290000), SPH_C32(0x49aac000), SPH_C32(0x81e10000), + SPH_C32(0xcafe6b59), SPH_C32(0x42793431), SPH_C32(0x43566b76), + SPH_C32(0xe86cba2e) }, + { SPH_C32(0xb08d0000), SPH_C32(0x42800001), SPH_C32(0x1429e180), + SPH_C32(0x5b310000), SPH_C32(0xa98b722d), SPH_C32(0x92f0de78), + SPH_C32(0x6631ef9d), SPH_C32(0x3bb81f15), SPH_C32(0x69230000), + SPH_C32(0xcc400000), SPH_C32(0x61a9d200), SPH_C32(0xf5860000), + SPH_C32(0x7c3c5dad), SPH_C32(0xa96b0dc9), SPH_C32(0x7087b49a), + SPH_C32(0xe1228bb6) }, + { SPH_C32(0xdb250000), SPH_C32(0x09290000), SPH_C32(0x49aac000), + SPH_C32(0x81e10000), SPH_C32(0xcafe6b59), SPH_C32(0x42793431), + SPH_C32(0x43566b76), SPH_C32(0xe86cba2e), SPH_C32(0x75e60000), + SPH_C32(0x95660001), SPH_C32(0x307b2000), SPH_C32(0xadf40000), + SPH_C32(0x8f321eea), SPH_C32(0x24298307), SPH_C32(0xe8c49cf9), + SPH_C32(0x4b7eec55) }, + { SPH_C32(0xc56b0000), SPH_C32(0xd7e60000), SPH_C32(0x2452c180), + SPH_C32(0xf6c50000), SPH_C32(0x26b96cc7), SPH_C32(0xb6d95d7f), + SPH_C32(0x8ef57364), SPH_C32(0x70c6f340), SPH_C32(0xc7e00000), + SPH_C32(0x500f0001), SPH_C32(0x18783200), SPH_C32(0xd9930000), + SPH_C32(0x39f0281e), SPH_C32(0xcf3bbaff), SPH_C32(0xdb154315), + SPH_C32(0x4230ddcd) }, + { SPH_C32(0x75e60000), SPH_C32(0x95660001), SPH_C32(0x307b2000), + SPH_C32(0xadf40000), SPH_C32(0x8f321eea), SPH_C32(0x24298307), + SPH_C32(0xe8c49cf9), SPH_C32(0x4b7eec55), SPH_C32(0xaec30000), + SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), SPH_C32(0x2c150000), + SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), SPH_C32(0xab92f78f), + SPH_C32(0xa312567b) }, + { SPH_C32(0x6ba80000), SPH_C32(0x4ba90001), SPH_C32(0x5d832180), + SPH_C32(0xdad00000), SPH_C32(0x63751974), SPH_C32(0xd089ea49), + SPH_C32(0x256784eb), SPH_C32(0xd3d4a53b), SPH_C32(0x1cc50000), + SPH_C32(0x59260001), SPH_C32(0x51d2f200), SPH_C32(0x58720000), + SPH_C32(0xf30e4347), SPH_C32(0x8d428ece), SPH_C32(0x98432863), + SPH_C32(0xaa5c67e3) }, + { SPH_C32(0x86790000), SPH_C32(0x3f390002), SPH_C32(0xe19ae000), + SPH_C32(0x98560000), SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), + SPH_C32(0xd3dd4944), SPH_C32(0x161ddab9), SPH_C32(0x30b70000), + SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), SPH_C32(0x42c40000), + SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), SPH_C32(0x21afa1ea), + SPH_C32(0xb0a51834) }, + { SPH_C32(0x98370000), SPH_C32(0xe1f60002), SPH_C32(0x8c62e180), + SPH_C32(0xef720000), SPH_C32(0x79226090), SPH_C32(0xba28a1a4), + SPH_C32(0x1e7e5156), SPH_C32(0x8eb793d7), SPH_C32(0x82b10000), + SPH_C32(0x20b90000), SPH_C32(0xdcf77200), SPH_C32(0x36a30000), + SPH_C32(0xd57a0b9e), SPH_C32(0x93a8ad98), SPH_C32(0x127e7e06), + SPH_C32(0xb9eb29ac) }, + { SPH_C32(0x28ba0000), SPH_C32(0xa3760003), SPH_C32(0x984b0000), + SPH_C32(0xb4430000), SPH_C32(0xd0a912bd), SPH_C32(0x28d87fdc), + SPH_C32(0x784fbecb), SPH_C32(0xb50f8cc2), SPH_C32(0xeb920000), + SPH_C32(0xecf90000), SPH_C32(0xbd5ea000), SPH_C32(0xc3250000), + SPH_C32(0xa9465633), SPH_C32(0x3ac3a051), SPH_C32(0x62f9ca9c), + SPH_C32(0x58c9a21a) }, + { SPH_C32(0x36f40000), SPH_C32(0x7db90003), SPH_C32(0xf5b30180), + SPH_C32(0xc3670000), SPH_C32(0x3cee1523), SPH_C32(0xdc781692), + SPH_C32(0xb5eca6d9), SPH_C32(0x2da5c5ac), SPH_C32(0x59940000), + SPH_C32(0x29900000), SPH_C32(0x955db200), SPH_C32(0xb7420000), + SPH_C32(0x1f8460c7), SPH_C32(0xd1d199a9), SPH_C32(0x51281570), + SPH_C32(0x51879382) }, + { SPH_C32(0x5d5c0000), SPH_C32(0x36100002), SPH_C32(0xa8302000), + SPH_C32(0x19b70000), SPH_C32(0x5f9b0c57), SPH_C32(0x0cf1fcdb), + SPH_C32(0x908b2232), SPH_C32(0xfe716097), SPH_C32(0x45510000), + SPH_C32(0x70b60001), SPH_C32(0xc48f4000), SPH_C32(0xef300000), + SPH_C32(0xec8a2380), SPH_C32(0x5c931767), SPH_C32(0xc96b3d13), + SPH_C32(0xfbdbf461) }, + { SPH_C32(0x43120000), SPH_C32(0xe8df0002), SPH_C32(0xc5c82180), + SPH_C32(0x6e930000), SPH_C32(0xb3dc0bc9), SPH_C32(0xf8519595), + SPH_C32(0x5d283a20), SPH_C32(0x66db29f9), SPH_C32(0xf7570000), + SPH_C32(0xb5df0001), SPH_C32(0xec8c5200), SPH_C32(0x9b570000), + SPH_C32(0x5a481574), SPH_C32(0xb7812e9f), SPH_C32(0xfabae2ff), + SPH_C32(0xf295c5f9) }, + { SPH_C32(0xf39f0000), SPH_C32(0xaa5f0003), SPH_C32(0xd1e1c000), + SPH_C32(0x35a20000), SPH_C32(0x1a5779e4), SPH_C32(0x6aa14bed), + SPH_C32(0x3b19d5bd), SPH_C32(0x5d6336ec), SPH_C32(0x9e740000), + SPH_C32(0x799f0001), SPH_C32(0x8d258000), SPH_C32(0x6ed10000), + SPH_C32(0x267448d9), SPH_C32(0x1eea2356), SPH_C32(0x8a3d5665), + SPH_C32(0x13b74e4f) }, + { SPH_C32(0xedd10000), SPH_C32(0x74900003), SPH_C32(0xbc19c180), + SPH_C32(0x42860000), SPH_C32(0xf6107e7a), SPH_C32(0x9e0122a3), + SPH_C32(0xf6bacdaf), SPH_C32(0xc5c97f82), SPH_C32(0x2c720000), + SPH_C32(0xbcf60001), SPH_C32(0xa5269200), SPH_C32(0x1ab60000), + SPH_C32(0x90b67e2d), SPH_C32(0xf5f81aae), SPH_C32(0xb9ec8989), + SPH_C32(0x1af97fd7) }, + { SPH_C32(0x30b70000), SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), + SPH_C32(0x42c40000), SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), + SPH_C32(0x21afa1ea), SPH_C32(0xb0a51834), SPH_C32(0xb6ce0000), + SPH_C32(0xdae90002), SPH_C32(0x156e8000), SPH_C32(0xda920000), + SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), SPH_C32(0xf272e8ae), + SPH_C32(0xa6b8c28d) }, + { SPH_C32(0x2ef90000), SPH_C32(0x3b1f0000), SPH_C32(0x990c6180), + SPH_C32(0x35e00000), SPH_C32(0x8fff3af4), SPH_C32(0x8c1afd2e), + SPH_C32(0xec0cb9f8), SPH_C32(0x280f515a), SPH_C32(0x04c80000), + SPH_C32(0x1f800002), SPH_C32(0x3d6d9200), SPH_C32(0xaef50000), + SPH_C32(0x401f6c90), SPH_C32(0xdd206572), SPH_C32(0xc1a33742), + SPH_C32(0xaff6f315) }, + { SPH_C32(0x9e740000), SPH_C32(0x799f0001), SPH_C32(0x8d258000), + SPH_C32(0x6ed10000), SPH_C32(0x267448d9), SPH_C32(0x1eea2356), + SPH_C32(0x8a3d5665), SPH_C32(0x13b74e4f), SPH_C32(0x6deb0000), + SPH_C32(0xd3c00002), SPH_C32(0x5cc44000), SPH_C32(0x5b730000), + SPH_C32(0x3c23313d), SPH_C32(0x744b68bb), SPH_C32(0xb12483d8), + SPH_C32(0x4ed478a3) }, + { SPH_C32(0x803a0000), SPH_C32(0xa7500001), SPH_C32(0xe0dd8180), + SPH_C32(0x19f50000), SPH_C32(0xca334f47), SPH_C32(0xea4a4a18), + SPH_C32(0x479e4e77), SPH_C32(0x8b1d0721), SPH_C32(0xdfed0000), + SPH_C32(0x16a90002), SPH_C32(0x74c75200), SPH_C32(0x2f140000), + SPH_C32(0x8ae107c9), SPH_C32(0x9f595143), SPH_C32(0x82f55c34), + SPH_C32(0x479a493b) }, + { SPH_C32(0xeb920000), SPH_C32(0xecf90000), SPH_C32(0xbd5ea000), + SPH_C32(0xc3250000), SPH_C32(0xa9465633), SPH_C32(0x3ac3a051), + SPH_C32(0x62f9ca9c), SPH_C32(0x58c9a21a), SPH_C32(0xc3280000), + SPH_C32(0x4f8f0003), SPH_C32(0x2515a000), SPH_C32(0x77660000), + SPH_C32(0x79ef448e), SPH_C32(0x121bdf8d), SPH_C32(0x1ab67457), + SPH_C32(0xedc62ed8) }, + { SPH_C32(0xf5dc0000), SPH_C32(0x32360000), SPH_C32(0xd0a6a180), + SPH_C32(0xb4010000), SPH_C32(0x450151ad), SPH_C32(0xce63c91f), + SPH_C32(0xaf5ad28e), SPH_C32(0xc063eb74), SPH_C32(0x712e0000), + SPH_C32(0x8ae60003), SPH_C32(0x0d16b200), SPH_C32(0x03010000), + SPH_C32(0xcf2d727a), SPH_C32(0xf909e675), SPH_C32(0x2967abbb), + SPH_C32(0xe4881f40) }, + { SPH_C32(0x45510000), SPH_C32(0x70b60001), SPH_C32(0xc48f4000), + SPH_C32(0xef300000), SPH_C32(0xec8a2380), SPH_C32(0x5c931767), + SPH_C32(0xc96b3d13), SPH_C32(0xfbdbf461), SPH_C32(0x180d0000), + SPH_C32(0x46a60003), SPH_C32(0x6cbf6000), SPH_C32(0xf6870000), + SPH_C32(0xb3112fd7), SPH_C32(0x5062ebbc), SPH_C32(0x59e01f21), + SPH_C32(0x05aa94f6) }, + { SPH_C32(0x5b1f0000), SPH_C32(0xae790001), SPH_C32(0xa9774180), + SPH_C32(0x98140000), SPH_C32(0x00cd241e), SPH_C32(0xa8337e29), + SPH_C32(0x04c82501), SPH_C32(0x6371bd0f), SPH_C32(0xaa0b0000), + SPH_C32(0x83cf0003), SPH_C32(0x44bc7200), SPH_C32(0x82e00000), + SPH_C32(0x05d31923), SPH_C32(0xbb70d244), SPH_C32(0x6a31c0cd), + SPH_C32(0x0ce4a56e) }, + { SPH_C32(0xb6ce0000), SPH_C32(0xdae90002), SPH_C32(0x156e8000), + SPH_C32(0xda920000), SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), + SPH_C32(0xf272e8ae), SPH_C32(0xa6b8c28d), SPH_C32(0x86790000), + SPH_C32(0x3f390002), SPH_C32(0xe19ae000), SPH_C32(0x98560000), + SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), SPH_C32(0xd3dd4944), + SPH_C32(0x161ddab9) }, + { SPH_C32(0xa8800000), SPH_C32(0x04260002), SPH_C32(0x78968180), + SPH_C32(0xadb60000), SPH_C32(0x1a9a5dfa), SPH_C32(0xc29235c4), + SPH_C32(0x3fd1f0bc), SPH_C32(0x3e128be3), SPH_C32(0x347f0000), + SPH_C32(0xfa500002), SPH_C32(0xc999f200), SPH_C32(0xec310000), + SPH_C32(0x23a751fa), SPH_C32(0xa59af112), SPH_C32(0xe00c96a8), + SPH_C32(0x1f53eb21) }, + { SPH_C32(0x180d0000), SPH_C32(0x46a60003), SPH_C32(0x6cbf6000), + SPH_C32(0xf6870000), SPH_C32(0xb3112fd7), SPH_C32(0x5062ebbc), + SPH_C32(0x59e01f21), SPH_C32(0x05aa94f6), SPH_C32(0x5d5c0000), + SPH_C32(0x36100002), SPH_C32(0xa8302000), SPH_C32(0x19b70000), + SPH_C32(0x5f9b0c57), SPH_C32(0x0cf1fcdb), SPH_C32(0x908b2232), + SPH_C32(0xfe716097) }, + { SPH_C32(0x06430000), SPH_C32(0x98690003), SPH_C32(0x01476180), + SPH_C32(0x81a30000), SPH_C32(0x5f562849), SPH_C32(0xa4c282f2), + SPH_C32(0x94430733), SPH_C32(0x9d00dd98), SPH_C32(0xef5a0000), + SPH_C32(0xf3790002), SPH_C32(0x80333200), SPH_C32(0x6dd00000), + SPH_C32(0xe9593aa3), SPH_C32(0xe7e3c523), SPH_C32(0xa35afdde), + SPH_C32(0xf73f510f) }, + { SPH_C32(0x6deb0000), SPH_C32(0xd3c00002), SPH_C32(0x5cc44000), + SPH_C32(0x5b730000), SPH_C32(0x3c23313d), SPH_C32(0x744b68bb), + SPH_C32(0xb12483d8), SPH_C32(0x4ed478a3), SPH_C32(0xf39f0000), + SPH_C32(0xaa5f0003), SPH_C32(0xd1e1c000), SPH_C32(0x35a20000), + SPH_C32(0x1a5779e4), SPH_C32(0x6aa14bed), SPH_C32(0x3b19d5bd), + SPH_C32(0x5d6336ec) }, + { SPH_C32(0x73a50000), SPH_C32(0x0d0f0002), SPH_C32(0x313c4180), + SPH_C32(0x2c570000), SPH_C32(0xd06436a3), SPH_C32(0x80eb01f5), + SPH_C32(0x7c879bca), SPH_C32(0xd67e31cd), SPH_C32(0x41990000), + SPH_C32(0x6f360003), SPH_C32(0xf9e2d200), SPH_C32(0x41c50000), + SPH_C32(0xac954f10), SPH_C32(0x81b37215), SPH_C32(0x08c80a51), + SPH_C32(0x542d0774) }, + { SPH_C32(0xc3280000), SPH_C32(0x4f8f0003), SPH_C32(0x2515a000), + SPH_C32(0x77660000), SPH_C32(0x79ef448e), SPH_C32(0x121bdf8d), + SPH_C32(0x1ab67457), SPH_C32(0xedc62ed8), SPH_C32(0x28ba0000), + SPH_C32(0xa3760003), SPH_C32(0x984b0000), SPH_C32(0xb4430000), + SPH_C32(0xd0a912bd), SPH_C32(0x28d87fdc), SPH_C32(0x784fbecb), + SPH_C32(0xb50f8cc2) }, + { SPH_C32(0xdd660000), SPH_C32(0x91400003), SPH_C32(0x48eda180), + SPH_C32(0x00420000), SPH_C32(0x95a84310), SPH_C32(0xe6bbb6c3), + SPH_C32(0xd7156c45), SPH_C32(0x756c67b6), SPH_C32(0x9abc0000), + SPH_C32(0x661f0003), SPH_C32(0xb0481200), SPH_C32(0xc0240000), + SPH_C32(0x666b2449), SPH_C32(0xc3ca4624), SPH_C32(0x4b9e6127), + SPH_C32(0xbc41bd5a) } +}; + +static const sph_u32 T512_35[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xcc140000), SPH_C32(0xa5630000), SPH_C32(0x5ab90780), + SPH_C32(0x3b500000), SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), + SPH_C32(0x694348c1), SPH_C32(0xca5a87fe), SPH_C32(0x819e0000), + SPH_C32(0xec570000), SPH_C32(0x66320280), SPH_C32(0x95f30000), + SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), SPH_C32(0xe65aa22d), + SPH_C32(0x8e67b7fa) }, + { SPH_C32(0x819e0000), SPH_C32(0xec570000), SPH_C32(0x66320280), + SPH_C32(0x95f30000), SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), + SPH_C32(0xe65aa22d), SPH_C32(0x8e67b7fa), SPH_C32(0x4d8a0000), + SPH_C32(0x49340000), SPH_C32(0x3c8b0500), SPH_C32(0xaea30000), + SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), SPH_C32(0x8f19eaec), + SPH_C32(0x443d3004) }, + { SPH_C32(0x4d8a0000), SPH_C32(0x49340000), SPH_C32(0x3c8b0500), + SPH_C32(0xaea30000), SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), + SPH_C32(0x8f19eaec), SPH_C32(0x443d3004), SPH_C32(0xcc140000), + SPH_C32(0xa5630000), SPH_C32(0x5ab90780), SPH_C32(0x3b500000), + SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), SPH_C32(0x694348c1), + SPH_C32(0xca5a87fe) }, + { SPH_C32(0x78230000), SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), + SPH_C32(0x90a50000), SPH_C32(0x713e2879), SPH_C32(0x7ee98924), + SPH_C32(0xf08ca062), SPH_C32(0x636f8bab), SPH_C32(0x02af0000), + SPH_C32(0xb7280000), SPH_C32(0xba1c0300), SPH_C32(0x56980000), + SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), SPH_C32(0xa95c149a), + SPH_C32(0xf4f6ea7b) }, + { SPH_C32(0xb4370000), SPH_C32(0xb79f0000), SPH_C32(0xf3830c00), + SPH_C32(0xabf50000), SPH_C32(0x3aee3b86), SPH_C32(0xf972bd3c), + SPH_C32(0x99cfe8a3), SPH_C32(0xa9350c55), SPH_C32(0x83310000), + SPH_C32(0x5b7f0000), SPH_C32(0xdc2e0180), SPH_C32(0xc36b0000), + SPH_C32(0xe7246dd1), SPH_C32(0xc8bcfadb), SPH_C32(0x4f06b6b7), + SPH_C32(0x7a915d81) }, + { SPH_C32(0xf9bd0000), SPH_C32(0xfeab0000), SPH_C32(0xcf080900), + SPH_C32(0x05560000), SPH_C32(0x2c97007b), SPH_C32(0x361db598), + SPH_C32(0x16d6024f), SPH_C32(0xed083c51), SPH_C32(0x4f250000), + SPH_C32(0xfe1c0000), SPH_C32(0x496970600), SPH_C32(0xf83b0000), + SPH_C32(0xacf47e2e), SPH_C32(0x4f27cec3), SPH_C32(0x2645fe76), + SPH_C32(0xb0cbda7f) }, + { SPH_C32(0x35a90000), SPH_C32(0x5bc80000), SPH_C32(0x95b10e80), + SPH_C32(0x3e060000), SPH_C32(0x67471384), SPH_C32(0xb1868180), + SPH_C32(0x7f954a8e), SPH_C32(0x2752bbaf), SPH_C32(0xcebb0000), + SPH_C32(0x124b0000), SPH_C32(0xe0a50480), SPH_C32(0x6dc80000), + SPH_C32(0xf15d562c), SPH_C32(0x07d3f27f), SPH_C32(0xc01f5c5b), + SPH_C32(0x3eac6d85) }, + { SPH_C32(0x02af0000), SPH_C32(0xb7280000), SPH_C32(0xba1c0300), + SPH_C32(0x56980000), SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), + SPH_C32(0xa95c149a), SPH_C32(0xf4f6ea7b), SPH_C32(0x7a8c0000), + SPH_C32(0xa5d40000), SPH_C32(0x13260880), SPH_C32(0xc63d0000), + SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), SPH_C32(0x59d0b4f8), + SPH_C32(0x979961d0) }, + { SPH_C32(0xcebb0000), SPH_C32(0x124b0000), SPH_C32(0xe0a50480), + SPH_C32(0x6dc80000), SPH_C32(0xf15d562c), SPH_C32(0x07d3f27f), + SPH_C32(0xc01f5c5b), SPH_C32(0x3eac6d85), SPH_C32(0xfb120000), + SPH_C32(0x49830000), SPH_C32(0x75140a00), SPH_C32(0x53ce0000), + SPH_C32(0x961a45a8), SPH_C32(0xb65573ff), SPH_C32(0xbf8a16d5), + SPH_C32(0x19fed62a) }, + { SPH_C32(0x83310000), SPH_C32(0x5b7f0000), SPH_C32(0xdc2e0180), + SPH_C32(0xc36b0000), SPH_C32(0xe7246dd1), SPH_C32(0xc8bcfadb), + SPH_C32(0x4f06b6b7), SPH_C32(0x7a915d81), SPH_C32(0x37060000), + SPH_C32(0xece00000), SPH_C32(0x2fad0d80), SPH_C32(0x689e0000), + SPH_C32(0xddca5657), SPH_C32(0x31ce47e7), SPH_C32(0xd6c95e14), + SPH_C32(0xd3a451d4) }, + { SPH_C32(0x4f250000), SPH_C32(0xfe1c0000), SPH_C32(0x496970600), + SPH_C32(0xf83b0000), SPH_C32(0xacf47e2e), SPH_C32(0x4f27cec3), + SPH_C32(0x2645fe76), SPH_C32(0xb0cbda7f), SPH_C32(0xb6980000), + SPH_C32(0x00b70000), SPH_C32(0x499f0f00), SPH_C32(0xfd6d0000), + SPH_C32(0x80637e55), SPH_C32(0x793a7b5b), SPH_C32(0x3093fc39), + SPH_C32(0x5dc3e62e) }, + { SPH_C32(0x7a8c0000), SPH_C32(0xa5d40000), SPH_C32(0x13260880), + SPH_C32(0xc63d0000), SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), + SPH_C32(0x59d0b4f8), SPH_C32(0x979961d0), SPH_C32(0x78230000), + SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), SPH_C32(0x90a50000), + SPH_C32(0x713e2879), SPH_C32(0x7ee98924), SPH_C32(0xf08ca062), + SPH_C32(0x636f8bab) }, + { SPH_C32(0xb6980000), SPH_C32(0x00b70000), SPH_C32(0x499f0f00), + SPH_C32(0xfd6d0000), SPH_C32(0x80637e55), SPH_C32(0x793a7b5b), + SPH_C32(0x3093fc39), SPH_C32(0x5dc3e62e), SPH_C32(0xf9bd0000), + SPH_C32(0xfeab0000), SPH_C32(0xcf080900), SPH_C32(0x05560000), + SPH_C32(0x2c97007b), SPH_C32(0x361db598), SPH_C32(0x16d6024f), + SPH_C32(0xed083c51) }, + { SPH_C32(0xfb120000), SPH_C32(0x49830000), SPH_C32(0x75140a00), + SPH_C32(0x53ce0000), SPH_C32(0x961a45a8), SPH_C32(0xb65573ff), + SPH_C32(0xbf8a16d5), SPH_C32(0x19fed62a), SPH_C32(0x35a90000), + SPH_C32(0x5bc80000), SPH_C32(0x95b10e80), SPH_C32(0x3e060000), + SPH_C32(0x67471384), SPH_C32(0xb1868180), SPH_C32(0x7f954a8e), + SPH_C32(0x2752bbaf) }, + { SPH_C32(0x37060000), SPH_C32(0xece00000), SPH_C32(0x2fad0d80), + SPH_C32(0x689e0000), SPH_C32(0xddca5657), SPH_C32(0x31ce47e7), + SPH_C32(0xd6c95e14), SPH_C32(0xd3a451d4), SPH_C32(0xb4370000), + SPH_C32(0xb79f0000), SPH_C32(0xf3830c00), SPH_C32(0xabf50000), + SPH_C32(0x3aee3b86), SPH_C32(0xf972bd3c), SPH_C32(0x99cfe8a3), + SPH_C32(0xa9350c55) }, + { SPH_C32(0xac480000), SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), + SPH_C32(0x03430000), SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), + SPH_C32(0xfe72c7fe), SPH_C32(0x91e478f6), SPH_C32(0x1e4e0000), + SPH_C32(0xdecf0000), SPH_C32(0x6df80180), SPH_C32(0x77240000), + SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), SPH_C32(0xcda31812), + SPH_C32(0x98aa496e) }, + { SPH_C32(0x605c0000), SPH_C32(0xbec50000), SPH_C32(0x1f421400), + SPH_C32(0x38130000), SPH_C32(0x11552295), SPH_C32(0x982964ae), + SPH_C32(0x97318f3f), SPH_C32(0x5bbeff08), SPH_C32(0x9fd00000), + SPH_C32(0x32980000), SPH_C32(0x0bca0300), SPH_C32(0xe2d70000), + SPH_C32(0xb1ee2f9c), SPH_C32(0xbc5455f2), SPH_C32(0x2bf9ba3f), + SPH_C32(0x16cdfe94) }, + { SPH_C32(0x2dd60000), SPH_C32(0xf7f10000), SPH_C32(0x23c91100), + SPH_C32(0x96b00000), SPH_C32(0x072c1968), SPH_C32(0x57466c0a), + SPH_C32(0x182865d3), SPH_C32(0x1f83cf0c), SPH_C32(0x53c40000), + SPH_C32(0x97fb0000), SPH_C32(0x51730480), SPH_C32(0xd9870000), + SPH_C32(0xfa3e3c63), SPH_C32(0x3bcf61ea), SPH_C32(0x42baf2fe), + SPH_C32(0xdc97796a) }, + { SPH_C32(0xe1c20000), SPH_C32(0x52920000), SPH_C32(0x79701680), + SPH_C32(0xade00000), SPH_C32(0x4cfc0a97), SPH_C32(0xd0dd5812), + SPH_C32(0x716b2d12), SPH_C32(0xd5d948f2), SPH_C32(0xd25a0000), + SPH_C32(0x7bac0000), SPH_C32(0x37410600), SPH_C32(0x4c740000), + SPH_C32(0xa7971461), SPH_C32(0x733b5d56), SPH_C32(0xa4e050d3), + SPH_C32(0x52f0ce90) }, + { SPH_C32(0xd46b0000), SPH_C32(0x095a0000), SPH_C32(0xecc11800), + SPH_C32(0x93e60000), SPH_C32(0x2bbb1913), SPH_C32(0x615bd992), + SPH_C32(0x0efe679c), SPH_C32(0xf28bf35d), SPH_C32(0x1ce10000), + SPH_C32(0x69e70000), SPH_C32(0xd7e40280), SPH_C32(0x21bc0000), + SPH_C32(0x56ca424d), SPH_C32(0x74e8af29), SPH_C32(0x64ff0c88), + SPH_C32(0x6c5ca315) }, + { SPH_C32(0x187f0000), SPH_C32(0xac390000), SPH_C32(0xb6781f80), + SPH_C32(0xa8b60000), SPH_C32(0x606b0aec), SPH_C32(0xe6c0ed8a), + SPH_C32(0x67bd2f5d), SPH_C32(0x38d174a3), SPH_C32(0x9d7f0000), + SPH_C32(0x85b00000), SPH_C32(0xb1d60000), SPH_C32(0xb44f0000), + SPH_C32(0x0b636a4f), SPH_C32(0x3c1c9395), SPH_C32(0x82a5aea5), + SPH_C32(0xe23b14ef) }, + { SPH_C32(0x55f50000), SPH_C32(0xe50d0000), SPH_C32(0x8af31a80), + SPH_C32(0x06150000), SPH_C32(0x76123111), SPH_C32(0x29afe52e), + SPH_C32(0xe8a4c5b1), SPH_C32(0x7cec44a7), SPH_C32(0x516b0000), + SPH_C32(0x20d30000), SPH_C32(0xeb6f0780), SPH_C32(0x8f1f0000), + SPH_C32(0x40b379b0), SPH_C32(0xbb87a78d), SPH_C32(0xebe6e664), + SPH_C32(0x28619311) }, + { SPH_C32(0x99e10000), SPH_C32(0x406e0000), SPH_C32(0xd04a1d00), + SPH_C32(0x3d450000), SPH_C32(0x3dc222ee), SPH_C32(0xae34d136), + SPH_C32(0x81e78d70), SPH_C32(0xb6b6c359), SPH_C32(0xd0f50000), + SPH_C32(0xcc840000), SPH_C32(0x8d5d0500), SPH_C32(0x1aec0000), + SPH_C32(0x1d1a51b2), SPH_C32(0xf3739b31), SPH_C32(0x0dbc4449), + SPH_C32(0xa60624eb) }, + { SPH_C32(0xaee70000), SPH_C32(0xac8e0000), SPH_C32(0xffe71080), + SPH_C32(0x55db0000), SPH_C32(0xe00874b9), SPH_C32(0x9ffa96d1), + SPH_C32(0x572ed364), SPH_C32(0x6512928d), SPH_C32(0x64c20000), + SPH_C32(0x7b1b0000), SPH_C32(0x7ede0900), SPH_C32(0xb1190000), + SPH_C32(0x27f46a34), SPH_C32(0x0a01260d), SPH_C32(0x9473acea), + SPH_C32(0x0f3328be) }, + { SPH_C32(0x62f30000), SPH_C32(0x09ed0000), SPH_C32(0xa55e1700), + SPH_C32(0x6e8b0000), SPH_C32(0xabd86746), SPH_C32(0x1861a2c9), + SPH_C32(0x3e6d9ba5), SPH_C32(0xaf481573), SPH_C32(0xe55c0000), + SPH_C32(0x974c0000), SPH_C32(0x18ec0b80), SPH_C32(0x24ea0000), + SPH_C32(0x7a5d4236), SPH_C32(0x42f51ab1), SPH_C32(0x72290ec7), + SPH_C32(0x81549f44) }, + { SPH_C32(0x2f790000), SPH_C32(0x40d90000), SPH_C32(0x99d51200), + SPH_C32(0xc0280000), SPH_C32(0xbda15cbb), SPH_C32(0xd70eaa6d), + SPH_C32(0xb1747149), SPH_C32(0xeb752577), SPH_C32(0x29480000), + SPH_C32(0x322f0000), SPH_C32(0x42550c00), SPH_C32(0x1fba0000), + SPH_C32(0x318d51c9), SPH_C32(0xc56e2ea9), SPH_C32(0x1b6a4606), + SPH_C32(0x4b0e18ba) }, + { SPH_C32(0xe36d0000), SPH_C32(0xe5ba0000), SPH_C32(0xc36c1580), + SPH_C32(0xfb780000), SPH_C32(0xf6714f44), SPH_C32(0x50959e75), + SPH_C32(0xd8373988), SPH_C32(0x212fa289), SPH_C32(0xa8d60000), + SPH_C32(0xde780000), SPH_C32(0x24670e80), SPH_C32(0x8a490000), + SPH_C32(0x6c2479cb), SPH_C32(0x8d9a1215), SPH_C32(0xfd30e42b), + SPH_C32(0xc569af40) }, + { SPH_C32(0xd6c40000), SPH_C32(0xbe720000), SPH_C32(0x56dd1b00), + SPH_C32(0xc57e0000), SPH_C32(0x91365cc0), SPH_C32(0xe1131ff5), + SPH_C32(0xa7a27306), SPH_C32(0x067d1926), SPH_C32(0x666d0000), + SPH_C32(0xcc330000), SPH_C32(0xc4c20a00), SPH_C32(0xe7810000), + SPH_C32(0x9d792fe7), SPH_C32(0x8a49e06a), SPH_C32(0x3d2fb870), + SPH_C32(0xfbc5c2c5) }, + { SPH_C32(0x1ad00000), SPH_C32(0x1b110000), SPH_C32(0x0c641c80), + SPH_C32(0xfe2e0000), SPH_C32(0xdae64f3f), SPH_C32(0x66882bed), + SPH_C32(0xcee13bc7), SPH_C32(0xcc279ed8), SPH_C32(0xe7f30000), + SPH_C32(0x20640000), SPH_C32(0xa2f00880), SPH_C32(0x72720000), + SPH_C32(0xc0d007e5), SPH_C32(0xc2bddcd6), SPH_C32(0xdb751a5d), + SPH_C32(0x75a2753f) }, + { SPH_C32(0x575a0000), SPH_C32(0x52250000), SPH_C32(0x30ef1980), + SPH_C32(0x508d0000), SPH_C32(0xcc9f74c2), SPH_C32(0xa9e72349), + SPH_C32(0x41f8d12b), SPH_C32(0x881aaedc), SPH_C32(0x2be70000), + SPH_C32(0x85070000), SPH_C32(0xf8490f00), SPH_C32(0x49220000), + SPH_C32(0x8b00141a), SPH_C32(0x4526e8ce), SPH_C32(0xb236529c), + SPH_C32(0xbff8f2c1) }, + { SPH_C32(0x9b4e0000), SPH_C32(0xf7460000), SPH_C32(0x6a561e00), + SPH_C32(0x6bdd0000), SPH_C32(0x874f673d), SPH_C32(0x2e7c1751), + SPH_C32(0x28bb99ea), SPH_C32(0x42402922), SPH_C32(0xaa790000), + SPH_C32(0x69500000), SPH_C32(0x9e7b0d80), SPH_C32(0xdcd10000), + SPH_C32(0xd6a93c18), SPH_C32(0x0dd2d472), SPH_C32(0x546cf0b1), + SPH_C32(0x319f453b) } +}; + +static const sph_u32 T512_40[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x07ed0000), SPH_C32(0xb2500000), SPH_C32(0x8774000a), + SPH_C32(0x970d0000), SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), + SPH_C32(0xf4786222), SPH_C32(0x9075b1ce), SPH_C32(0xa2d60000), + SPH_C32(0xa6760000), SPH_C32(0xc9440014), SPH_C32(0xeba30000), + SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), SPH_C32(0x03490afa), + SPH_C32(0x9b6ef888) }, + { SPH_C32(0x88980000), SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), + SPH_C32(0xfb4e0000), SPH_C32(0xf158079a), SPH_C32(0x61ae9167), + SPH_C32(0xa895706c), SPH_C32(0xe6107494), SPH_C32(0x0bc20000), + SPH_C32(0xdb630000), SPH_C32(0x7e88000c), SPH_C32(0x15860000), + SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), SPH_C32(0xf460449e), + SPH_C32(0xd8b61463) }, + { SPH_C32(0x8f750000), SPH_C32(0xadc40000), SPH_C32(0xf8bb0024), + SPH_C32(0x6c430000), SPH_C32(0xb22a2434), SPH_C32(0x2969ffc3), + SPH_C32(0x5ced124e), SPH_C32(0x7665c55a), SPH_C32(0xa9140000), + SPH_C32(0x7d150000), SPH_C32(0xb7cc0018), SPH_C32(0xfe250000), + SPH_C32(0x5d116688), SPH_C32(0x45997fda), SPH_C32(0xf7294e64), + SPH_C32(0x43d8eceb) }, + { SPH_C32(0x0bc20000), SPH_C32(0xdb630000), SPH_C32(0x7e88000c), + SPH_C32(0x15860000), SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), + SPH_C32(0xf460449e), SPH_C32(0xd8b61463), SPH_C32(0x835a0000), + SPH_C32(0xc4f70000), SPH_C32(0x01470022), SPH_C32(0xeec80000), + SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), SPH_C32(0x5cf534f2), + SPH_C32(0x3ea660f7) }, + { SPH_C32(0x0c2f0000), SPH_C32(0x69330000), SPH_C32(0xf9fc0006), + SPH_C32(0x828b0000), SPH_C32(0xd28f6b5d), SPH_C32(0x3d46d5e7), + SPH_C32(0x001826bc), SPH_C32(0x48c3a5ad), SPH_C32(0x218c0000), + SPH_C32(0x62810000), SPH_C32(0xc8030036), SPH_C32(0x056b0000), + SPH_C32(0xac496112), SPH_C32(0x2437eebd), SPH_C32(0x5fbc3e08), + SPH_C32(0xa5c8987f) }, + { SPH_C32(0x835a0000), SPH_C32(0xc4f70000), SPH_C32(0x01470022), + SPH_C32(0xeec80000), SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), + SPH_C32(0x5cf534f2), SPH_C32(0x3ea660f7), SPH_C32(0x88980000), + SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), SPH_C32(0xfb4e0000), + SPH_C32(0xf158079a), SPH_C32(0x61ae9167), SPH_C32(0xa895706c), + SPH_C32(0xe6107494) }, + { SPH_C32(0x84b70000), SPH_C32(0x76a70000), SPH_C32(0x86330028), + SPH_C32(0x79c50000), SPH_C32(0x23d76cc7), SPH_C32(0x5ce84480), + SPH_C32(0xa88d56d0), SPH_C32(0xaed3d139), SPH_C32(0x2a4e0000), + SPH_C32(0xb9e20000), SPH_C32(0xb68b003a), SPH_C32(0x10ed0000), + SPH_C32(0x3db429e1), SPH_C32(0x51b655fe), SPH_C32(0xabdc7a96), + SPH_C32(0x7d7e8c1c) }, + { SPH_C32(0x52500000), SPH_C32(0x29540000), SPH_C32(0x6a61004e), + SPH_C32(0xf0ff0000), SPH_C32(0x9a317eec), SPH_C32(0x452341ce), + SPH_C32(0xcf568fe5), SPH_C32(0x5303130f), SPH_C32(0x538d0000), + SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), SPH_C32(0x56ff0000), + SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), SPH_C32(0xa9444018), + SPH_C32(0x7f975691) }, + { SPH_C32(0x55bd0000), SPH_C32(0x9b040000), SPH_C32(0xed150044), + SPH_C32(0x67f20000), SPH_C32(0xd9435d42), SPH_C32(0x0de42f6a), + SPH_C32(0x3b2eedc7), SPH_C32(0xc376a2c1), SPH_C32(0xf15b0000), + SPH_C32(0x0f8a0000), SPH_C32(0x57b30012), SPH_C32(0xbd5c0000), + SPH_C32(0xc6082e35), SPH_C32(0xa2dd0960), SPH_C32(0xaa0d4ae2), + SPH_C32(0xe4f9ae19) }, + { SPH_C32(0xdac80000), SPH_C32(0x36c00000), SPH_C32(0x15ae0060), + SPH_C32(0x0bb10000), SPH_C32(0x6b697976), SPH_C32(0x248dd0a9), + SPH_C32(0x67c3ff89), SPH_C32(0xb513679b), SPH_C32(0x584f0000), + SPH_C32(0x729f0000), SPH_C32(0xe07f000a), SPH_C32(0x43790000), + SPH_C32(0x9b1948bd), SPH_C32(0xe74476ba), SPH_C32(0x5d240486), + SPH_C32(0xa72142f2) }, + { SPH_C32(0xdd250000), SPH_C32(0x84900000), SPH_C32(0x92da006a), + SPH_C32(0x9cbc0000), SPH_C32(0x281b5ad8), SPH_C32(0x6c4abe0d), + SPH_C32(0x93bb9dab), SPH_C32(0x2566d655), SPH_C32(0xfa990000), + SPH_C32(0xd4e90000), SPH_C32(0x293b001e), SPH_C32(0xa8da0000), + SPH_C32(0x57f566c6), SPH_C32(0xd75cb223), SPH_C32(0x5e6d0e7c), + SPH_C32(0x3c4fba7a) }, + { SPH_C32(0x59920000), SPH_C32(0xf2370000), SPH_C32(0x14e90042), + SPH_C32(0xe5790000), SPH_C32(0x0bcc361f), SPH_C32(0x30a2fa8d), + SPH_C32(0x3b36cb7b), SPH_C32(0x8bb5076c), SPH_C32(0xd0d70000), + SPH_C32(0x6d0b0000), SPH_C32(0x9fb00024), SPH_C32(0xb8370000), + SPH_C32(0x6a414f27), SPH_C32(0x86eae7dd), SPH_C32(0xf5b174ea), + SPH_C32(0x41313666) }, + { SPH_C32(0x5e7f0000), SPH_C32(0x40670000), SPH_C32(0x939d0048), + SPH_C32(0x72740000), SPH_C32(0x48be15b1), SPH_C32(0x78659429), + SPH_C32(0xcf4ea959), SPH_C32(0x1bc0b6a2), SPH_C32(0x72010000), + SPH_C32(0xcb7d0000), SPH_C32(0x56f40030), SPH_C32(0x53940000), + SPH_C32(0xa6ad615c), SPH_C32(0xb6f22344), SPH_C32(0xf6f87e10), + SPH_C32(0xda5fceee) }, + { SPH_C32(0xd10a0000), SPH_C32(0xeda30000), SPH_C32(0x6b26006c), + SPH_C32(0x1e370000), SPH_C32(0xfa943185), SPH_C32(0x510c6bea), + SPH_C32(0x93a3bb17), SPH_C32(0x6da573f8), SPH_C32(0xdb150000), + SPH_C32(0xb6680000), SPH_C32(0xe1380028), SPH_C32(0xadb10000), + SPH_C32(0xfbbc07d4), SPH_C32(0xf36b5c9e), SPH_C32(0x01d13074), + SPH_C32(0x99872205) }, + { SPH_C32(0xd6e70000), SPH_C32(0x5ff30000), SPH_C32(0xec520066), + SPH_C32(0x893a0000), SPH_C32(0xb9e6122b), SPH_C32(0x19cb054e), + SPH_C32(0x67dbd935), SPH_C32(0xfdd0c236), SPH_C32(0x79c30000), + SPH_C32(0x101e0000), SPH_C32(0x287c003c), SPH_C32(0x46120000), + SPH_C32(0x375029af), SPH_C32(0xc3739807), SPH_C32(0x02983a8e), + SPH_C32(0x02e9da8d) }, + { SPH_C32(0x538d0000), SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), + SPH_C32(0x56ff0000), SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), + SPH_C32(0xa9444018), SPH_C32(0x7f975691), SPH_C32(0x01dd0000), + SPH_C32(0x80a80000), SPH_C32(0xf4960048), SPH_C32(0xa6000000), + SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), SPH_C32(0x6612cffd), + SPH_C32(0x2c94459e) }, + { SPH_C32(0x54600000), SPH_C32(0x1bac0000), SPH_C32(0x1983000c), + SPH_C32(0xc1f20000), SPH_C32(0x499623e0), SPH_C32(0xda02a35d), + SPH_C32(0x5d3c223a), SPH_C32(0xefe2e75f), SPH_C32(0xa30b0000), + SPH_C32(0x26de0000), SPH_C32(0x3dd2005c), SPH_C32(0x4da30000), + SPH_C32(0x5c3950d9), SPH_C32(0xe7fe48ae), SPH_C32(0x655bc507), + SPH_C32(0xb7fabd16) }, + { SPH_C32(0xdb150000), SPH_C32(0xb6680000), SPH_C32(0xe1380028), + SPH_C32(0xadb10000), SPH_C32(0xfbbc07d4), SPH_C32(0xf36b5c9e), + SPH_C32(0x01d13074), SPH_C32(0x99872205), SPH_C32(0x0a1f0000), + SPH_C32(0x5bcb0000), SPH_C32(0x8a1e0044), SPH_C32(0xb3860000), + SPH_C32(0x01283651), SPH_C32(0xa2673774), SPH_C32(0x92728b63), + SPH_C32(0xf42251fd) }, + { SPH_C32(0xdcf80000), SPH_C32(0x04380000), SPH_C32(0x664c0022), + SPH_C32(0x3abc0000), SPH_C32(0xb8ce247a), SPH_C32(0xbbac323a), + SPH_C32(0xf5a95256), SPH_C32(0x09f293cb), SPH_C32(0xa8c90000), + SPH_C32(0xfdbd0000), SPH_C32(0x435a0050), SPH_C32(0x58250000), + SPH_C32(0xcdc4182a), SPH_C32(0x927ff3ed), SPH_C32(0x913b8199), + SPH_C32(0x6f4ca975) }, + { SPH_C32(0x584f0000), SPH_C32(0x729f0000), SPH_C32(0xe07f000a), + SPH_C32(0x43790000), SPH_C32(0x9b1948bd), SPH_C32(0xe74476ba), + SPH_C32(0x5d240486), SPH_C32(0xa72142f2), SPH_C32(0x82870000), + SPH_C32(0x445f0000), SPH_C32(0xf5d1006a), SPH_C32(0x48c80000), + SPH_C32(0xf07031cb), SPH_C32(0xc3c9a613), SPH_C32(0x3ae7fb0f), + SPH_C32(0x12322569) }, + { SPH_C32(0x5fa20000), SPH_C32(0xc0cf0000), SPH_C32(0x670b0000), + SPH_C32(0xd4740000), SPH_C32(0xd86b6b13), SPH_C32(0xaf83181e), + SPH_C32(0xa95c66a4), SPH_C32(0x3754f33c), SPH_C32(0x20510000), + SPH_C32(0xe2290000), SPH_C32(0x3c95007e), SPH_C32(0xa36b0000), + SPH_C32(0x3c9c1fb0), SPH_C32(0xf3d1628a), SPH_C32(0x39aef1f5), + SPH_C32(0x895cdde1) }, + { SPH_C32(0xd0d70000), SPH_C32(0x6d0b0000), SPH_C32(0x9fb00024), + SPH_C32(0xb8370000), SPH_C32(0x6a414f27), SPH_C32(0x86eae7dd), + SPH_C32(0xf5b174ea), SPH_C32(0x41313666), SPH_C32(0x89450000), + SPH_C32(0x9f3c0000), SPH_C32(0x8b590066), SPH_C32(0x5d4e0000), + SPH_C32(0x618d7938), SPH_C32(0xb6481d50), SPH_C32(0xce87bf91), + SPH_C32(0xca84310a) }, + { SPH_C32(0xd73a0000), SPH_C32(0xdf5b0000), SPH_C32(0x18c4002e), + SPH_C32(0x2f3a0000), SPH_C32(0x29336c89), SPH_C32(0xce2d8979), + SPH_C32(0x01c916c8), SPH_C32(0xd14487a8), SPH_C32(0x2b930000), + SPH_C32(0x394a0000), SPH_C32(0x421d0072), SPH_C32(0xb6ed0000), + SPH_C32(0xad615743), SPH_C32(0x8650d9c9), SPH_C32(0xcdceb56b), + SPH_C32(0x51eac982) }, + { SPH_C32(0x01dd0000), SPH_C32(0x80a80000), SPH_C32(0xf4960048), + SPH_C32(0xa6000000), SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), + SPH_C32(0x6612cffd), SPH_C32(0x2c94459e), SPH_C32(0x52500000), + SPH_C32(0x29540000), SPH_C32(0x6a61004e), SPH_C32(0xf0ff0000), + SPH_C32(0x9a317eec), SPH_C32(0x452341ce), SPH_C32(0xcf568fe5), + SPH_C32(0x5303130f) }, + { SPH_C32(0x06300000), SPH_C32(0x32f80000), SPH_C32(0x73e20042), + SPH_C32(0x310d0000), SPH_C32(0xd3a75d0c), SPH_C32(0x9f21e293), + SPH_C32(0x926aaddf), SPH_C32(0xbce1f450), SPH_C32(0xf0860000), + SPH_C32(0x8f220000), SPH_C32(0xa325005a), SPH_C32(0x1b5c0000), + SPH_C32(0x56dd5097), SPH_C32(0x753b8557), SPH_C32(0xcc1f851f), + SPH_C32(0xc86deb87) }, + { SPH_C32(0x89450000), SPH_C32(0x9f3c0000), SPH_C32(0x8b590066), + SPH_C32(0x5d4e0000), SPH_C32(0x618d7938), SPH_C32(0xb6481d50), + SPH_C32(0xce87bf91), SPH_C32(0xca84310a), SPH_C32(0x59920000), + SPH_C32(0xf2370000), SPH_C32(0x14e90042), SPH_C32(0xe5790000), + SPH_C32(0x0bcc361f), SPH_C32(0x30a2fa8d), SPH_C32(0x3b36cb7b), + SPH_C32(0x8bb5076c) }, + { SPH_C32(0x8ea80000), SPH_C32(0x2d6c0000), SPH_C32(0x0c2d006c), + SPH_C32(0xca430000), SPH_C32(0x22ff5a96), SPH_C32(0xfe8f73f4), + SPH_C32(0x3affddb3), SPH_C32(0x5af180c4), SPH_C32(0xfb440000), + SPH_C32(0x54410000), SPH_C32(0xddad0056), SPH_C32(0x0eda0000), + SPH_C32(0xc7201864), SPH_C32(0x00ba3e14), SPH_C32(0x387fc181), + SPH_C32(0x10dbffe4) }, + { SPH_C32(0x0a1f0000), SPH_C32(0x5bcb0000), SPH_C32(0x8a1e0044), + SPH_C32(0xb3860000), SPH_C32(0x01283651), SPH_C32(0xa2673774), + SPH_C32(0x92728b63), SPH_C32(0xf42251fd), SPH_C32(0xd10a0000), + SPH_C32(0xeda30000), SPH_C32(0x6b26006c), SPH_C32(0x1e370000), + SPH_C32(0xfa943185), SPH_C32(0x510c6bea), SPH_C32(0x93a3bb17), + SPH_C32(0x6da573f8) }, + { SPH_C32(0x0df20000), SPH_C32(0xe99b0000), SPH_C32(0x0d6a004e), + SPH_C32(0x248b0000), SPH_C32(0x425a15ff), SPH_C32(0xeaa059d0), + SPH_C32(0x660ae941), SPH_C32(0x6457e033), SPH_C32(0x73dc0000), + SPH_C32(0x4bd50000), SPH_C32(0xa2620078), SPH_C32(0xf5940000), + SPH_C32(0x36781ffe), SPH_C32(0x6114af73), SPH_C32(0x90eab1ed), + SPH_C32(0xf6cb8b70) }, + { SPH_C32(0x82870000), SPH_C32(0x445f0000), SPH_C32(0xf5d1006a), + SPH_C32(0x48c80000), SPH_C32(0xf07031cb), SPH_C32(0xc3c9a613), + SPH_C32(0x3ae7fb0f), SPH_C32(0x12322569), SPH_C32(0xdac80000), + SPH_C32(0x36c00000), SPH_C32(0x15ae0060), SPH_C32(0x0bb10000), + SPH_C32(0x6b697976), SPH_C32(0x248dd0a9), SPH_C32(0x67c3ff89), + SPH_C32(0xb513679b) }, + { SPH_C32(0x856a0000), SPH_C32(0xf60f0000), SPH_C32(0x72a50060), + SPH_C32(0xdfc50000), SPH_C32(0xb3021265), SPH_C32(0x8b0ec8b7), + SPH_C32(0xce9f992d), SPH_C32(0x824794a7), SPH_C32(0x781e0000), + SPH_C32(0x90b60000), SPH_C32(0xdcea0074), SPH_C32(0xe0120000), + SPH_C32(0xa785570d), SPH_C32(0x14951430), SPH_C32(0x648af573), + SPH_C32(0x2e7d9f13) } +}; + +static const sph_u32 T512_45[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x1e6c0000), SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), + SPH_C32(0xbcb6b800), SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), + SPH_C32(0x6a0c1bc8), SPH_C32(0xb99dc2eb), SPH_C32(0x92560000), + SPH_C32(0x1eda0000), SPH_C32(0xea510000), SPH_C32(0xe8b13000), + SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), SPH_C32(0xb15c2254), + SPH_C32(0x33c5244f) }, + { SPH_C32(0x92560000), SPH_C32(0x1eda0000), SPH_C32(0xea510000), + SPH_C32(0xe8b13000), SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), + SPH_C32(0xb15c2254), SPH_C32(0x33c5244f), SPH_C32(0x8c3a0000), + SPH_C32(0xda980000), SPH_C32(0x607f0000), SPH_C32(0x54078800), + SPH_C32(0x85714513), SPH_C32(0x6006b243), SPH_C32(0xdb50399c), + SPH_C32(0x8a58e6a4) }, + { SPH_C32(0x8c3a0000), SPH_C32(0xda980000), SPH_C32(0x607f0000), + SPH_C32(0x54078800), SPH_C32(0x85714513), SPH_C32(0x6006b243), + SPH_C32(0xdb50399c), SPH_C32(0x8a58e6a4), SPH_C32(0x1e6c0000), + SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), SPH_C32(0xbcb6b800), + SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), SPH_C32(0x6a0c1bc8), + SPH_C32(0xb99dc2eb) }, + { SPH_C32(0x58430000), SPH_C32(0x807e0000), SPH_C32(0x78330001), + SPH_C32(0xc66b3800), SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), + SPH_C32(0xac73fe6f), SPH_C32(0x3a4479b1), SPH_C32(0x1d5a0000), + SPH_C32(0x2b720000), SPH_C32(0x488d0000), SPH_C32(0xaf611800), + SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), SPH_C32(0x81a20429), + SPH_C32(0x1e7536a6) }, + { SPH_C32(0x462f0000), SPH_C32(0x443c0000), SPH_C32(0xf21d0001), + SPH_C32(0x7add8000), SPH_C32(0xcb734f6a), SPH_C32(0xf250ec07), + SPH_C32(0xc67fe5a7), SPH_C32(0x83d9bb5a), SPH_C32(0x8f0c0000), + SPH_C32(0x35a80000), SPH_C32(0xa2dc0000), SPH_C32(0x47d02800), + SPH_C32(0x8cfe7860), SPH_C32(0x2382de49), SPH_C32(0x30fe267d), + SPH_C32(0x2db012e9) }, + { SPH_C32(0xca150000), SPH_C32(0x9ea40000), SPH_C32(0x92620001), + SPH_C32(0x2eda0800), SPH_C32(0x4e020a79), SPH_C32(0x92565e44), + SPH_C32(0x1d2fdc3b), SPH_C32(0x09815dfe), SPH_C32(0x91600000), + SPH_C32(0xf1ea0000), SPH_C32(0x28f20000), SPH_C32(0xfb669000), + SPH_C32(0xa0ba6bd6), SPH_C32(0xa87f0d93), SPH_C32(0x5af23db5), + SPH_C32(0x942dd002) }, + { SPH_C32(0xd4790000), SPH_C32(0x5ae60000), SPH_C32(0x184c0001), + SPH_C32(0x926cb000), SPH_C32(0x624619cf), SPH_C32(0x19ab8d9e), + SPH_C32(0x7723c7f3), SPH_C32(0xb01c9f15), SPH_C32(0x03360000), + SPH_C32(0xef300000), SPH_C32(0xc2a30000), SPH_C32(0x13d7a000), + SPH_C32(0x098f3d73), SPH_C32(0x43846c0a), SPH_C32(0xebae1fe1), + SPH_C32(0xa7e8f44d) }, + { SPH_C32(0x1d5a0000), SPH_C32(0x2b720000), SPH_C32(0x488d0000), + SPH_C32(0xaf611800), SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), + SPH_C32(0x81a20429), SPH_C32(0x1e7536a6), SPH_C32(0x45190000), + SPH_C32(0xab0c0000), SPH_C32(0x30be0001), SPH_C32(0x690a2000), + SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), SPH_C32(0x2dd1fa46), + SPH_C32(0x24314f17) }, + { SPH_C32(0x03360000), SPH_C32(0xef300000), SPH_C32(0xc2a30000), + SPH_C32(0x13d7a000), SPH_C32(0x098f3d73), SPH_C32(0x43846c0a), + SPH_C32(0xebae1fe1), SPH_C32(0xa7e8f44d), SPH_C32(0xd74f0000), + SPH_C32(0xb5d60000), SPH_C32(0xdaef0001), SPH_C32(0x81bb1000), + SPH_C32(0x6bc924bc), SPH_C32(0x5a2fe194), SPH_C32(0x9c8dd812), + SPH_C32(0x17f46b58) }, + { SPH_C32(0x8f0c0000), SPH_C32(0x35a80000), SPH_C32(0xa2dc0000), + SPH_C32(0x47d02800), SPH_C32(0x8cfe7860), SPH_C32(0x2382de49), + SPH_C32(0x30fe267d), SPH_C32(0x2db012e9), SPH_C32(0xc9230000), + SPH_C32(0x71940000), SPH_C32(0x50c10001), SPH_C32(0x3d0da800), + SPH_C32(0x478d370a), SPH_C32(0xd1d2324e), SPH_C32(0xf681c3da), + SPH_C32(0xae69a9b3) }, + { SPH_C32(0x91600000), SPH_C32(0xf1ea0000), SPH_C32(0x28f20000), + SPH_C32(0xfb669000), SPH_C32(0xa0ba6bd6), SPH_C32(0xa87f0d93), + SPH_C32(0x5af23db5), SPH_C32(0x942dd002), SPH_C32(0x5b750000), + SPH_C32(0x6f4e0000), SPH_C32(0xba900001), SPH_C32(0xd5bc9800), + SPH_C32(0xeeb861af), SPH_C32(0x3a2953d7), SPH_C32(0x47dde18e), + SPH_C32(0x9dac8dfc) }, + { SPH_C32(0x45190000), SPH_C32(0xab0c0000), SPH_C32(0x30be0001), + SPH_C32(0x690a2000), SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), + SPH_C32(0x2dd1fa46), SPH_C32(0x24314f17), SPH_C32(0x58430000), + SPH_C32(0x807e0000), SPH_C32(0x78330001), SPH_C32(0xc66b3800), + SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), SPH_C32(0xac73fe6f), + SPH_C32(0x3a4479b1) }, + { SPH_C32(0x5b750000), SPH_C32(0x6f4e0000), SPH_C32(0xba900001), + SPH_C32(0xd5bc9800), SPH_C32(0xeeb861af), SPH_C32(0x3a2953d7), + SPH_C32(0x47dde18e), SPH_C32(0x9dac8dfc), SPH_C32(0xca150000), + SPH_C32(0x9ea40000), SPH_C32(0x92620001), SPH_C32(0x2eda0800), + SPH_C32(0x4e020a79), SPH_C32(0x92565e44), SPH_C32(0x1d2fdc3b), + SPH_C32(0x09815dfe) }, + { SPH_C32(0xd74f0000), SPH_C32(0xb5d60000), SPH_C32(0xdaef0001), + SPH_C32(0x81bb1000), SPH_C32(0x6bc924bc), SPH_C32(0x5a2fe194), + SPH_C32(0x9c8dd812), SPH_C32(0x17f46b58), SPH_C32(0xd4790000), + SPH_C32(0x5ae60000), SPH_C32(0x184c0001), SPH_C32(0x926cb000), + SPH_C32(0x624619cf), SPH_C32(0x19ab8d9e), SPH_C32(0x7723c7f3), + SPH_C32(0xb01c9f15) }, + { SPH_C32(0xc9230000), SPH_C32(0x71940000), SPH_C32(0x50c10001), + SPH_C32(0x3d0da800), SPH_C32(0x478d370a), SPH_C32(0xd1d2324e), + SPH_C32(0xf681c3da), SPH_C32(0xae69a9b3), SPH_C32(0x462f0000), + SPH_C32(0x443c0000), SPH_C32(0xf21d0001), SPH_C32(0x7add8000), + SPH_C32(0xcb734f6a), SPH_C32(0xf250ec07), SPH_C32(0xc67fe5a7), + SPH_C32(0x83d9bb5a) }, + { SPH_C32(0xa53b0000), SPH_C32(0x14260000), SPH_C32(0x4e30001e), + SPH_C32(0x7cae0000), SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), + SPH_C32(0xf73168d8), SPH_C32(0x0b1b4946), SPH_C32(0x07ed0000), + SPH_C32(0xb2500000), SPH_C32(0x8774000a), SPH_C32(0x970d0000), + SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), SPH_C32(0xf4786222), + SPH_C32(0x9075b1ce) }, + { SPH_C32(0xbb570000), SPH_C32(0xd0640000), SPH_C32(0xc41e001e), + SPH_C32(0xc018b800), SPH_C32(0xa3da1e63), SPH_C32(0xf32279e7), + SPH_C32(0x9d3d7310), SPH_C32(0xb2868bad), SPH_C32(0x95bb0000), + SPH_C32(0xac8a0000), SPH_C32(0x6d25000a), SPH_C32(0x7fbc3000), + SPH_C32(0xea47750b), SPH_C32(0xa33c0f3d), SPH_C32(0x45244076), + SPH_C32(0xa3b09581) }, + { SPH_C32(0x376d0000), SPH_C32(0x0afc0000), SPH_C32(0xa461001e), + SPH_C32(0x941f3000), SPH_C32(0x26ab5b70), SPH_C32(0x9324cba4), + SPH_C32(0x466d4a8c), SPH_C32(0x38de6d09), SPH_C32(0x8bd70000), + SPH_C32(0x68c80000), SPH_C32(0xe70b000a), SPH_C32(0xc30a8800), + SPH_C32(0xc60366bd), SPH_C32(0x28c1dce7), SPH_C32(0x2f285bbe), + SPH_C32(0x1a2d576a) }, + { SPH_C32(0x29010000), SPH_C32(0xcebe0000), SPH_C32(0x2e4f001e), + SPH_C32(0x28a98800), SPH_C32(0x0aef48c6), SPH_C32(0x18d9187e), + SPH_C32(0x2c615144), SPH_C32(0x8143afe2), SPH_C32(0x19810000), + SPH_C32(0x76120000), SPH_C32(0x0d5a000a), SPH_C32(0x2bbbb800), + SPH_C32(0x6f363018), SPH_C32(0xc33abd7e), SPH_C32(0x9e7479ea), + SPH_C32(0x29e87325) }, + { SPH_C32(0xfd780000), SPH_C32(0x94580000), SPH_C32(0x3603001f), + SPH_C32(0xbac53800), SPH_C32(0x68a95109), SPH_C32(0x017295e0), + SPH_C32(0x5b4296b7), SPH_C32(0x315f30f7), SPH_C32(0x1ab70000), + SPH_C32(0x99220000), SPH_C32(0xcff9000a), SPH_C32(0x386c1800), + SPH_C32(0x66b90d6b), SPH_C32(0x80bed174), SPH_C32(0x75da660b), + SPH_C32(0x8e008768) }, + { SPH_C32(0xe3140000), SPH_C32(0x501a0000), SPH_C32(0xbc2d001f), + SPH_C32(0x06738000), SPH_C32(0x44ed42bf), SPH_C32(0x8a8f463a), + SPH_C32(0x314e8d7f), SPH_C32(0x88c2f21c), SPH_C32(0x88e10000), + SPH_C32(0x87f80000), SPH_C32(0x25a8000a), SPH_C32(0xd0dd2800), + SPH_C32(0xcf8c5bce), SPH_C32(0x6b45b0ed), SPH_C32(0xc486445f), + SPH_C32(0xbdc5a327) }, + { SPH_C32(0x6f2e0000), SPH_C32(0x8a820000), SPH_C32(0xdc52001f), + SPH_C32(0x52740800), SPH_C32(0xc19c07ac), SPH_C32(0xea89f479), + SPH_C32(0xea1eb4e3), SPH_C32(0x029a14b8), SPH_C32(0x968d0000), + SPH_C32(0x43ba0000), SPH_C32(0xaf86000a), SPH_C32(0x6c6b9000), + SPH_C32(0xe3c84878), SPH_C32(0xe0b86337), SPH_C32(0xae8a5f97), + SPH_C32(0x045861cc) }, + { SPH_C32(0x71420000), SPH_C32(0x4ec00000), SPH_C32(0x567c001f), + SPH_C32(0xeec2b000), SPH_C32(0xedd8141a), SPH_C32(0x617427a3), + SPH_C32(0x8012af2b), SPH_C32(0xbb07d653), SPH_C32(0x04db0000), + SPH_C32(0x5d600000), SPH_C32(0x45d7000a), SPH_C32(0x84daa000), + SPH_C32(0x4afd1edd), SPH_C32(0x0b4302ae), SPH_C32(0x1fd67dc3), + SPH_C32(0x379d4583) }, + { SPH_C32(0xb8610000), SPH_C32(0x3f540000), SPH_C32(0x06bd001e), + SPH_C32(0xd3cf1800), SPH_C32(0xaa552310), SPH_C32(0xb0a615ed), + SPH_C32(0x76936cf1), SPH_C32(0x156e7fe0), SPH_C32(0x42f40000), + SPH_C32(0x195c0000), SPH_C32(0xb7ca000b), SPH_C32(0xfe072000), + SPH_C32(0x818e51b7), SPH_C32(0xf913eea9), SPH_C32(0xd9a99864), + SPH_C32(0xb444fed9) }, + { SPH_C32(0xa60d0000), SPH_C32(0xfb160000), SPH_C32(0x8c93001e), + SPH_C32(0x6f79a000), SPH_C32(0x861130a6), SPH_C32(0x3b5bc637), + SPH_C32(0x1c9f7739), SPH_C32(0xacf3bd0b), SPH_C32(0xd0a20000), + SPH_C32(0x07860000), SPH_C32(0x5d9b000b), SPH_C32(0x16b61000), + SPH_C32(0x28bb0712), SPH_C32(0x12e88f30), SPH_C32(0x68f5ba30), + SPH_C32(0x8781da96) }, + { SPH_C32(0x2a370000), SPH_C32(0x218e0000), SPH_C32(0xecec001e), + SPH_C32(0x3b7e2800), SPH_C32(0x036075b5), SPH_C32(0x5b5d7474), + SPH_C32(0xc7cf4ea5), SPH_C32(0x26ab5baf), SPH_C32(0xcece0000), + SPH_C32(0xc3c40000), SPH_C32(0xd7b5000b), SPH_C32(0xaa00a800), + SPH_C32(0x04ff14a4), SPH_C32(0x99155cea), SPH_C32(0x02f9a1f8), + SPH_C32(0x3e1c187d) }, + { SPH_C32(0x345b0000), SPH_C32(0xe5cc0000), SPH_C32(0x66c2001e), + SPH_C32(0x87c89000), SPH_C32(0x2f246603), SPH_C32(0xd0a0a7ae), + SPH_C32(0xadc3556d), SPH_C32(0x9f369944), SPH_C32(0x5c980000), + SPH_C32(0xdd1e0000), SPH_C32(0x3de4000b), SPH_C32(0x42b19800), + SPH_C32(0xadca4201), SPH_C32(0x72ee3d73), SPH_C32(0xb3a583ac), + SPH_C32(0x0dd93c32) }, + { SPH_C32(0xe0220000), SPH_C32(0xbf2a0000), SPH_C32(0x7e8e001f), + SPH_C32(0x15a42000), SPH_C32(0x4d627fcc), SPH_C32(0xc90b2a30), + SPH_C32(0xdae0929e), SPH_C32(0x2f2a0651), SPH_C32(0x5fae0000), + SPH_C32(0x322e0000), SPH_C32(0xff47000b), SPH_C32(0x51663800), + SPH_C32(0xa4457f72), SPH_C32(0x316a5179), SPH_C32(0x580b9c4d), + SPH_C32(0xaa31c87f) }, + { SPH_C32(0xfe4e0000), SPH_C32(0x7b680000), SPH_C32(0xf4a0001f), + SPH_C32(0xa9129800), SPH_C32(0x61266c7a), SPH_C32(0x42f6f9ea), + SPH_C32(0xb0ec8956), SPH_C32(0x96b7c4ba), SPH_C32(0xcdf80000), + SPH_C32(0x2cf40000), SPH_C32(0x1516000b), SPH_C32(0xb9d70800), + SPH_C32(0x0d7029d7), SPH_C32(0xda9130e0), SPH_C32(0xe957be19), + SPH_C32(0x99f4ec30) }, + { SPH_C32(0x72740000), SPH_C32(0xa1f00000), SPH_C32(0x94df001f), + SPH_C32(0xfd151000), SPH_C32(0xe4572969), SPH_C32(0x22f04ba9), + SPH_C32(0x6bbcb0ca), SPH_C32(0x1cef221e), SPH_C32(0xd3940000), + SPH_C32(0xe8b60000), SPH_C32(0x9f38000b), SPH_C32(0x0561b000), + SPH_C32(0x21343a61), SPH_C32(0x516ce33a), SPH_C32(0x835ba5d1), + SPH_C32(0x20692edb) }, + { SPH_C32(0x6c180000), SPH_C32(0x65b20000), SPH_C32(0x1ef1001f), + SPH_C32(0x41a3a800), SPH_C32(0xc8133adf), SPH_C32(0xa90d9873), + SPH_C32(0x01b0ab02), SPH_C32(0xa572e0f5), SPH_C32(0x41c20000), + SPH_C32(0xf66c0000), SPH_C32(0x7569000b), SPH_C32(0xedd08000), + SPH_C32(0x88016cc4), SPH_C32(0xba9782a3), SPH_C32(0x32078785), + SPH_C32(0x13ac0a94) } +}; + +static const sph_u32 T512_50[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xf0c50000), SPH_C32(0x59230000), SPH_C32(0x45820000), + SPH_C32(0xe18d00c0), SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), + SPH_C32(0xcbe0fe1c), SPH_C32(0x56a7b19f), SPH_C32(0x16ed0000), + SPH_C32(0x15680000), SPH_C32(0xedd70000), SPH_C32(0x325d0220), + SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), SPH_C32(0xe375f8a8), + SPH_C32(0x81fdf908) }, + { SPH_C32(0xb4310000), SPH_C32(0x77330000), SPH_C32(0xb15d0000), + SPH_C32(0x7fd004e0), SPH_C32(0x78a26138), SPH_C32(0xd116c35d), + SPH_C32(0xd256d489), SPH_C32(0x4e6f74de), SPH_C32(0xe3060000), + SPH_C32(0xbdc10000), SPH_C32(0x87130000), SPH_C32(0xbff20060), + SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), SPH_C32(0x73c5ab06), + SPH_C32(0x5bd61539) }, + { SPH_C32(0x44f40000), SPH_C32(0x2e100000), SPH_C32(0xf4df0000), + SPH_C32(0x9e5d0420), SPH_C32(0x43cf6709), SPH_C32(0x13fb95c4), + SPH_C32(0x19b62a95), SPH_C32(0x18c8c541), SPH_C32(0xf5eb0000), + SPH_C32(0xa8a90000), SPH_C32(0x6ac40000), SPH_C32(0x8daf0240), + SPH_C32(0xcdb63c93), SPH_C32(0xd7ffd112), SPH_C32(0x90b053ae), + SPH_C32(0xda2bec31) }, + { SPH_C32(0xe3060000), SPH_C32(0xbdc10000), SPH_C32(0x87130000), + SPH_C32(0xbff20060), SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), + SPH_C32(0x73c5ab06), SPH_C32(0x5bd61539), SPH_C32(0x57370000), + SPH_C32(0xcaf20000), SPH_C32(0x364e0000), SPH_C32(0xc0220480), + SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), SPH_C32(0xa1937f8f), + SPH_C32(0x15b961e7) }, + { SPH_C32(0x13c30000), SPH_C32(0xe4e20000), SPH_C32(0xc2910000), + SPH_C32(0x5e7f00a0), SPH_C32(0x15d70c2b), SPH_C32(0x4f5861c8), + SPH_C32(0xb825551a), SPH_C32(0x0d71a4a6), SPH_C32(0x41da0000), + SPH_C32(0xdf9a0000), SPH_C32(0xdb990000), SPH_C32(0xf27f06a0), + SPH_C32(0xb5145dab), SPH_C32(0x06e9124f), SPH_C32(0x42e68727), + SPH_C32(0x944498ef) }, + { SPH_C32(0x57370000), SPH_C32(0xcaf20000), SPH_C32(0x364e0000), + SPH_C32(0xc0220480), SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), + SPH_C32(0xa1937f8f), SPH_C32(0x15b961e7), SPH_C32(0xb4310000), + SPH_C32(0x77330000), SPH_C32(0xb15d0000), SPH_C32(0x7fd004e0), + SPH_C32(0x78a26138), SPH_C32(0xd116c35d), SPH_C32(0xd256d489), + SPH_C32(0x4e6f74de) }, + { SPH_C32(0xa7f20000), SPH_C32(0x93d10000), SPH_C32(0x73cc0000), + SPH_C32(0x21af0440), SPH_C32(0x6d756d13), SPH_C32(0x9e4ea295), + SPH_C32(0x6a738193), SPH_C32(0x431ed078), SPH_C32(0xa2dc0000), + SPH_C32(0x625b0000), SPH_C32(0x5c8a0000), SPH_C32(0x4d8d06c0), + SPH_C32(0x9bae57b1), SPH_C32(0x8b5c251e), SPH_C32(0x31232c21), + SPH_C32(0xcf928dd6) }, + { SPH_C32(0x02f20000), SPH_C32(0xa2810000), SPH_C32(0x873f0000), + SPH_C32(0xe36c7800), SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), + SPH_C32(0xc4c23237), SPH_C32(0x7f32259e), SPH_C32(0xbadd0000), + SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), SPH_C32(0xf7282800), + SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), SPH_C32(0xea5a8d14), + SPH_C32(0x2a2c18f0) }, + { SPH_C32(0xf2370000), SPH_C32(0xfba20000), SPH_C32(0xc2bd0000), + SPH_C32(0x02e178c0), SPH_C32(0x257072de), SPH_C32(0xc5d07d4f), + SPH_C32(0x0f22cc2b), SPH_C32(0x29959401), SPH_C32(0xac300000), + SPH_C32(0x06c50000), SPH_C32(0x5a300000), SPH_C32(0xc5752a20), + SPH_C32(0x3c4922c4), SPH_C32(0x6c502579), SPH_C32(0x092f75bc), + SPH_C32(0xabd1e1f8) }, + { SPH_C32(0xb6c30000), SPH_C32(0xd5b20000), SPH_C32(0x36620000), + SPH_C32(0x9cbc7ce0), SPH_C32(0x66bf15d7), SPH_C32(0xd62be88b), + SPH_C32(0x1694e6be), SPH_C32(0x315d5140), SPH_C32(0x59db0000), + SPH_C32(0xae6c0000), SPH_C32(0x30f40000), SPH_C32(0x48da2860), + SPH_C32(0xf1ff1e57), SPH_C32(0xbbaff46b), SPH_C32(0x999f2612), + SPH_C32(0x71fa0dc9) }, + { SPH_C32(0x46060000), SPH_C32(0x8c910000), SPH_C32(0x73e00000), + SPH_C32(0x7d317c20), SPH_C32(0x5dd213e6), SPH_C32(0x14c6be12), + SPH_C32(0xdd7418a2), SPH_C32(0x67fae0df), SPH_C32(0x4f360000), + SPH_C32(0xbb040000), SPH_C32(0xdd230000), SPH_C32(0x7a872a40), + SPH_C32(0x12f328de), SPH_C32(0xe1e51228), SPH_C32(0x7aeadeba), + SPH_C32(0xf007f4c1) }, + { SPH_C32(0xe1f40000), SPH_C32(0x1f400000), SPH_C32(0x002c0000), + SPH_C32(0x5c9e7860), SPH_C32(0x30a77ef5), SPH_C32(0x8a881c87), + SPH_C32(0xb7079931), SPH_C32(0x24e430a7), SPH_C32(0xedea0000), + SPH_C32(0xd95f0000), SPH_C32(0x81a90000), SPH_C32(0x370a2c80), + SPH_C32(0x895d7f6f), SPH_C32(0x6ab93736), SPH_C32(0x4bc9f29b), + SPH_C32(0x3f957917) }, + { SPH_C32(0x11310000), SPH_C32(0x46630000), SPH_C32(0x45ae0000), + SPH_C32(0xbd1378a0), SPH_C32(0x0bca78c4), SPH_C32(0x48654a1e), + SPH_C32(0x7ce7672d), SPH_C32(0x72438138), SPH_C32(0xfb070000), + SPH_C32(0xcc370000), SPH_C32(0x6c7e0000), SPH_C32(0x05572ea0), + SPH_C32(0x6a5149e6), SPH_C32(0x30f3d175), SPH_C32(0xa8bc0a33), + SPH_C32(0xbe68801f) }, + { SPH_C32(0x55c50000), SPH_C32(0x68730000), SPH_C32(0xb1710000), + SPH_C32(0x234e7c80), SPH_C32(0x48051fcd), SPH_C32(0x5b9edfda), + SPH_C32(0x65514db8), SPH_C32(0x6a8b4479), SPH_C32(0x0eec0000), + SPH_C32(0x649e0000), SPH_C32(0x06ba0000), SPH_C32(0x88f82ce0), + SPH_C32(0xa7e77575), SPH_C32(0xe70c0067), SPH_C32(0x380c599d), + SPH_C32(0x64436c2e) }, + { SPH_C32(0xa5000000), SPH_C32(0x31500000), SPH_C32(0xf4f30000), + SPH_C32(0xc2c37c40), SPH_C32(0x736819fc), SPH_C32(0x99738943), + SPH_C32(0xaeb1b3a4), SPH_C32(0x3c2cf5e6), SPH_C32(0x18010000), + SPH_C32(0x71f60000), SPH_C32(0xeb6d0000), SPH_C32(0xbaa52ec0), + SPH_C32(0x44eb43fc), SPH_C32(0xbd46e624), SPH_C32(0xdb79a135), + SPH_C32(0xe5be9526) }, + { SPH_C32(0xbadd0000), SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), + SPH_C32(0xf7282800), SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), + SPH_C32(0xea5a8d14), SPH_C32(0x2a2c18f0), SPH_C32(0xb82f0000), + SPH_C32(0xb12c0000), SPH_C32(0x30d80000), SPH_C32(0x14445000), + SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), SPH_C32(0x2e98bf23), + SPH_C32(0x551e3d6e) }, + { SPH_C32(0x4a180000), SPH_C32(0x4a8e0000), SPH_C32(0xf2650000), + SPH_C32(0x16a528c0), SPH_C32(0xe428127c), SPH_C32(0xf4f795a3), + SPH_C32(0x21ba7308), SPH_C32(0x7c8ba96f), SPH_C32(0xaec20000), + SPH_C32(0xa4440000), SPH_C32(0xdd0f0000), SPH_C32(0x26195220), + SPH_C32(0x2254562b), SPH_C32(0x6b6d0eaf), SPH_C32(0xcded478b), + SPH_C32(0xd4e3c466) }, + { SPH_C32(0x0eec0000), SPH_C32(0x649e0000), SPH_C32(0x06ba0000), + SPH_C32(0x88f82ce0), SPH_C32(0xa7e77575), SPH_C32(0xe70c0067), + SPH_C32(0x380c599d), SPH_C32(0x64436c2e), SPH_C32(0x5b290000), + SPH_C32(0x0ced0000), SPH_C32(0xb7cb0000), SPH_C32(0xabb65060), + SPH_C32(0xefe26ab8), SPH_C32(0xbc92dfbd), SPH_C32(0x5d5d1425), + SPH_C32(0x0ec82857) }, + { SPH_C32(0xfe290000), SPH_C32(0x3dbd0000), SPH_C32(0x43380000), + SPH_C32(0x69752c20), SPH_C32(0x9c8a7344), SPH_C32(0x25e156fe), + SPH_C32(0xf3eca781), SPH_C32(0x32e4ddb1), SPH_C32(0x4dc40000), + SPH_C32(0x19850000), SPH_C32(0x5a1c0000), SPH_C32(0x99eb5240), + SPH_C32(0x0cee5c31), SPH_C32(0xe6d839fe), SPH_C32(0xbe28ec8d), + SPH_C32(0x8f35d15f) }, + { SPH_C32(0x59db0000), SPH_C32(0xae6c0000), SPH_C32(0x30f40000), + SPH_C32(0x48da2860), SPH_C32(0xf1ff1e57), SPH_C32(0xbbaff46b), + SPH_C32(0x999f2612), SPH_C32(0x71fa0dc9), SPH_C32(0xef180000), + SPH_C32(0x7bde0000), SPH_C32(0x06960000), SPH_C32(0xd4665480), + SPH_C32(0x97400b80), SPH_C32(0x6d841ce0), SPH_C32(0x8f0bc0ac), + SPH_C32(0x40a75c89) }, + { SPH_C32(0xa91e0000), SPH_C32(0xf74f0000), SPH_C32(0x75760000), + SPH_C32(0xa95728a0), SPH_C32(0xca921866), SPH_C32(0x7942a2f2), + SPH_C32(0x527fd80e), SPH_C32(0x275dbc56), SPH_C32(0xf9f50000), + SPH_C32(0x6eb60000), SPH_C32(0xeb410000), SPH_C32(0xe63b56a0), + SPH_C32(0x744c3d09), SPH_C32(0x37cefaa3), SPH_C32(0x6c7e3804), + SPH_C32(0xc15aa581) }, + { SPH_C32(0xedea0000), SPH_C32(0xd95f0000), SPH_C32(0x81a90000), + SPH_C32(0x370a2c80), SPH_C32(0x895d7f6f), SPH_C32(0x6ab93736), + SPH_C32(0x4bc9f29b), SPH_C32(0x3f957917), SPH_C32(0x0c1e0000), + SPH_C32(0xc61f0000), SPH_C32(0x81850000), SPH_C32(0x6b9454e0), + SPH_C32(0xb9fa019a), SPH_C32(0xe0312bb1), SPH_C32(0xfcce6baa), + SPH_C32(0x1b7149b0) }, + { SPH_C32(0x1d2f0000), SPH_C32(0x807c0000), SPH_C32(0xc42b0000), + SPH_C32(0xd6872c40), SPH_C32(0xb230795e), SPH_C32(0xa85461af), + SPH_C32(0x80290c87), SPH_C32(0x6932c888), SPH_C32(0x1af30000), + SPH_C32(0xd3770000), SPH_C32(0x6c520000), SPH_C32(0x59c956c0), + SPH_C32(0x5af63713), SPH_C32(0xba7bcdf2), SPH_C32(0x1fbb9302), + SPH_C32(0x9a8cb0b8) }, + { SPH_C32(0xb82f0000), SPH_C32(0xb12c0000), SPH_C32(0x30d80000), + SPH_C32(0x14445000), SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), + SPH_C32(0x2e98bf23), SPH_C32(0x551e3d6e), SPH_C32(0x02f20000), + SPH_C32(0xa2810000), SPH_C32(0x873f0000), SPH_C32(0xe36c7800), + SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), SPH_C32(0xc4c23237), + SPH_C32(0x7f32259e) }, + { SPH_C32(0x48ea0000), SPH_C32(0xe80f0000), SPH_C32(0x755a0000), + SPH_C32(0xf5c950c0), SPH_C32(0xfa356693), SPH_C32(0xf3cabe75), + SPH_C32(0xe578413f), SPH_C32(0x03b98cf1), SPH_C32(0x141f0000), + SPH_C32(0xb7e90000), SPH_C32(0x6ae80000), SPH_C32(0xd1317a20), + SPH_C32(0xfd114266), SPH_C32(0x5d77cd95), SPH_C32(0x27b7ca9f), + SPH_C32(0xfecfdc96) }, + { SPH_C32(0x0c1e0000), SPH_C32(0xc61f0000), SPH_C32(0x81850000), + SPH_C32(0x6b9454e0), SPH_C32(0xb9fa019a), SPH_C32(0xe0312bb1), + SPH_C32(0xfcce6baa), SPH_C32(0x1b7149b0), SPH_C32(0xe1f40000), + SPH_C32(0x1f400000), SPH_C32(0x002c0000), SPH_C32(0x5c9e7860), + SPH_C32(0x30a77ef5), SPH_C32(0x8a881c87), SPH_C32(0xb7079931), + SPH_C32(0x24e430a7) }, + { SPH_C32(0xfcdb0000), SPH_C32(0x9f3c0000), SPH_C32(0xc4070000), + SPH_C32(0x8a195420), SPH_C32(0x829707ab), SPH_C32(0x22dc7d28), + SPH_C32(0x372e95b6), SPH_C32(0x4dd6f82f), SPH_C32(0xf7190000), + SPH_C32(0x0a280000), SPH_C32(0xedfb0000), SPH_C32(0x6ec37a40), + SPH_C32(0xd3ab487c), SPH_C32(0xd0c2fac4), SPH_C32(0x54726199), + SPH_C32(0xa519c9af) }, + { SPH_C32(0x5b290000), SPH_C32(0x0ced0000), SPH_C32(0xb7cb0000), + SPH_C32(0xabb65060), SPH_C32(0xefe26ab8), SPH_C32(0xbc92dfbd), + SPH_C32(0x5d5d1425), SPH_C32(0x0ec82857), SPH_C32(0x55c50000), + SPH_C32(0x68730000), SPH_C32(0xb1710000), SPH_C32(0x234e7c80), + SPH_C32(0x48051fcd), SPH_C32(0x5b9edfda), SPH_C32(0x65514db8), + SPH_C32(0x6a8b4479) }, + { SPH_C32(0xabec0000), SPH_C32(0x55ce0000), SPH_C32(0xf2490000), + SPH_C32(0x4a3b50a0), SPH_C32(0xd48f6c89), SPH_C32(0x7e7f8924), + SPH_C32(0x96bdea39), SPH_C32(0x586f99c8), SPH_C32(0x43280000), + SPH_C32(0x7d1b0000), SPH_C32(0x5ca60000), SPH_C32(0x11137ea0), + SPH_C32(0xab092944), SPH_C32(0x01d43999), SPH_C32(0x8624b510), + SPH_C32(0xeb76bd71) }, + { SPH_C32(0xef180000), SPH_C32(0x7bde0000), SPH_C32(0x06960000), + SPH_C32(0xd4665480), SPH_C32(0x97400b80), SPH_C32(0x6d841ce0), + SPH_C32(0x8f0bc0ac), SPH_C32(0x40a75c89), SPH_C32(0xb6c30000), + SPH_C32(0xd5b20000), SPH_C32(0x36620000), SPH_C32(0x9cbc7ce0), + SPH_C32(0x66bf15d7), SPH_C32(0xd62be88b), SPH_C32(0x1694e6be), + SPH_C32(0x315d5140) }, + { SPH_C32(0x1fdd0000), SPH_C32(0x22fd0000), SPH_C32(0x43140000), + SPH_C32(0x35eb5440), SPH_C32(0xac2d0db1), SPH_C32(0xaf694a79), + SPH_C32(0x44eb3eb0), SPH_C32(0x1600ed16), SPH_C32(0xa02e0000), + SPH_C32(0xc0da0000), SPH_C32(0xdbb50000), SPH_C32(0xaee17ec0), + SPH_C32(0x85b3235e), SPH_C32(0x8c610ec8), SPH_C32(0xf5e11e16), + SPH_C32(0xb0a0a848) } +}; + +static const sph_u32 T512_55[32][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x5fa80000), SPH_C32(0x56030000), SPH_C32(0x43ae0000), + SPH_C32(0x64f30013), SPH_C32(0x257e86bf), SPH_C32(0x1311944e), + SPH_C32(0x541e95bf), SPH_C32(0x8ea4db69), SPH_C32(0x00440000), + SPH_C32(0x7f480000), SPH_C32(0xda7c0000), SPH_C32(0x2a230001), + SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), SPH_C32(0x030a9e60), + SPH_C32(0xbe0a679e) }, + { SPH_C32(0x00440000), SPH_C32(0x7f480000), SPH_C32(0xda7c0000), + SPH_C32(0x2a230001), SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), + SPH_C32(0x030a9e60), SPH_C32(0xbe0a679e), SPH_C32(0x5fec0000), + SPH_C32(0x294b0000), SPH_C32(0x99d20000), SPH_C32(0x4ed00012), + SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), SPH_C32(0x57140bdf), + SPH_C32(0x30aebcf7) }, + { SPH_C32(0x5fec0000), SPH_C32(0x294b0000), SPH_C32(0x99d20000), + SPH_C32(0x4ed00012), SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), + SPH_C32(0x57140bdf), SPH_C32(0x30aebcf7), SPH_C32(0x5fa80000), + SPH_C32(0x56030000), SPH_C32(0x43ae0000), SPH_C32(0x64f30013), + SPH_C32(0x257e86bf), SPH_C32(0x1311944e), SPH_C32(0x541e95bf), + SPH_C32(0x8ea4db69) }, + { SPH_C32(0xee930000), SPH_C32(0xd6070000), SPH_C32(0x92c10000), + SPH_C32(0x2b9801e0), SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), + SPH_C32(0x45312374), SPH_C32(0x201f6a64), SPH_C32(0x7b280000), + SPH_C32(0x57420000), SPH_C32(0xa9e50000), SPH_C32(0x634300a0), + SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), SPH_C32(0x27f83b03), + SPH_C32(0xc7ff60f0) }, + { SPH_C32(0xb13b0000), SPH_C32(0x80040000), SPH_C32(0xd16f0000), + SPH_C32(0x4f6b01f3), SPH_C32(0xb12faec3), SPH_C32(0x287d6f19), + SPH_C32(0x112fb6cb), SPH_C32(0xaebbb10d), SPH_C32(0x7b6c0000), + SPH_C32(0x280a0000), SPH_C32(0x73990000), SPH_C32(0x496000a1), + SPH_C32(0xa5768de3), SPH_C32(0xc42f093c), SPH_C32(0x24f2a563), + SPH_C32(0x79f5076e) }, + { SPH_C32(0xeed70000), SPH_C32(0xa94f0000), SPH_C32(0x48bd0000), + SPH_C32(0x01bb01e1), SPH_C32(0xaffce1b0), SPH_C32(0x92da67d0), + SPH_C32(0x463bbd14), SPH_C32(0x9e150dfa), SPH_C32(0x24c40000), + SPH_C32(0x7e090000), SPH_C32(0x30370000), SPH_C32(0x2d9300b2), + SPH_C32(0x80080b5c), SPH_C32(0xd73e9d72), SPH_C32(0x70ec30dc), + SPH_C32(0xf751dc07) }, + { SPH_C32(0xb17f0000), SPH_C32(0xff4c0000), SPH_C32(0x0b130000), + SPH_C32(0x654801f2), SPH_C32(0x8a82670f), SPH_C32(0x81cbf39e), + SPH_C32(0x122528ab), SPH_C32(0x10b1d693), SPH_C32(0x24800000), + SPH_C32(0x01410000), SPH_C32(0xea4b0000), SPH_C32(0x07b000b3), + SPH_C32(0xbba5c290), SPH_C32(0x7e8801f5), SPH_C32(0x73e6aebc), + SPH_C32(0x495bbb99) }, + { SPH_C32(0x7b280000), SPH_C32(0x57420000), SPH_C32(0xa9e50000), + SPH_C32(0x634300a0), SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), + SPH_C32(0x27f83b03), SPH_C32(0xc7ff60f0), SPH_C32(0x95bb0000), + SPH_C32(0x81450000), SPH_C32(0x3b240000), SPH_C32(0x48db0140), + SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), SPH_C32(0x62c91877), + SPH_C32(0xe7e00a94) }, + { SPH_C32(0x24800000), SPH_C32(0x01410000), SPH_C32(0xea4b0000), + SPH_C32(0x07b000b3), SPH_C32(0xbba5c290), SPH_C32(0x7e8801f5), + SPH_C32(0x73e6aebc), SPH_C32(0x495bbb99), SPH_C32(0x95ff0000), + SPH_C32(0xfe0d0000), SPH_C32(0xe1580000), SPH_C32(0x62f80141), + SPH_C32(0x3127a59f), SPH_C32(0xff43f26b), SPH_C32(0x61c38617), + SPH_C32(0x59ea6d0a) }, + { SPH_C32(0x7b6c0000), SPH_C32(0x280a0000), SPH_C32(0x73990000), + SPH_C32(0x496000a1), SPH_C32(0xa5768de3), SPH_C32(0xc42f093c), + SPH_C32(0x24f2a563), SPH_C32(0x79f5076e), SPH_C32(0xca570000), + SPH_C32(0xa80e0000), SPH_C32(0xa2f60000), SPH_C32(0x060b0152), + SPH_C32(0x14592320), SPH_C32(0xec526625), SPH_C32(0x35dd13a8), + SPH_C32(0xd74eb663) }, + { SPH_C32(0x24c40000), SPH_C32(0x7e090000), SPH_C32(0x30370000), + SPH_C32(0x2d9300b2), SPH_C32(0x80080b5c), SPH_C32(0xd73e9d72), + SPH_C32(0x70ec30dc), SPH_C32(0xf751dc07), SPH_C32(0xca130000), + SPH_C32(0xd7460000), SPH_C32(0x788a0000), SPH_C32(0x2c280153), + SPH_C32(0x2ff4eaec), SPH_C32(0x45e4faa2), SPH_C32(0x36d78dc8), + SPH_C32(0x6944d1fd) }, + { SPH_C32(0x95bb0000), SPH_C32(0x81450000), SPH_C32(0x3b240000), + SPH_C32(0x48db0140), SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), + SPH_C32(0x62c91877), SPH_C32(0xe7e00a94), SPH_C32(0xee930000), + SPH_C32(0xd6070000), SPH_C32(0x92c10000), SPH_C32(0x2b9801e0), + SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), SPH_C32(0x45312374), + SPH_C32(0x201f6a64) }, + { SPH_C32(0xca130000), SPH_C32(0xd7460000), SPH_C32(0x788a0000), + SPH_C32(0x2c280153), SPH_C32(0x2ff4eaec), SPH_C32(0x45e4faa2), + SPH_C32(0x36d78dc8), SPH_C32(0x6944d1fd), SPH_C32(0xeed70000), + SPH_C32(0xa94f0000), SPH_C32(0x48bd0000), SPH_C32(0x01bb01e1), + SPH_C32(0xaffce1b0), SPH_C32(0x92da67d0), SPH_C32(0x463bbd14), + SPH_C32(0x9e150dfa) }, + { SPH_C32(0x95ff0000), SPH_C32(0xfe0d0000), SPH_C32(0xe1580000), + SPH_C32(0x62f80141), SPH_C32(0x3127a59f), SPH_C32(0xff43f26b), + SPH_C32(0x61c38617), SPH_C32(0x59ea6d0a), SPH_C32(0xb17f0000), + SPH_C32(0xff4c0000), SPH_C32(0x0b130000), SPH_C32(0x654801f2), + SPH_C32(0x8a82670f), SPH_C32(0x81cbf39e), SPH_C32(0x122528ab), + SPH_C32(0x10b1d693) }, + { SPH_C32(0xca570000), SPH_C32(0xa80e0000), SPH_C32(0xa2f60000), + SPH_C32(0x060b0152), SPH_C32(0x14592320), SPH_C32(0xec526625), + SPH_C32(0x35dd13a8), SPH_C32(0xd74eb663), SPH_C32(0xb13b0000), + SPH_C32(0x80040000), SPH_C32(0xd16f0000), SPH_C32(0x4f6b01f3), + SPH_C32(0xb12faec3), SPH_C32(0x287d6f19), SPH_C32(0x112fb6cb), + SPH_C32(0xaebbb10d) }, + { SPH_C32(0xe6280000), SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), + SPH_C32(0xd3d002e0), SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), + SPH_C32(0x289506b4), SPH_C32(0xd75a4897), SPH_C32(0xf0c50000), + SPH_C32(0x59230000), SPH_C32(0x45820000), SPH_C32(0xe18d00c0), + SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), SPH_C32(0xcbe0fe1c), + SPH_C32(0x56a7b19f) }, + { SPH_C32(0xb9800000), SPH_C32(0x1a480000), SPH_C32(0xebfb0000), + SPH_C32(0xb72302f3), SPH_C32(0xfd1fb607), SPH_C32(0x8bb62494), + SPH_C32(0x7c8b930b), SPH_C32(0x59fe93fe), SPH_C32(0xf0810000), + SPH_C32(0x266b0000), SPH_C32(0x9ffe0000), SPH_C32(0xcbae00c1), + SPH_C32(0x00c0cffd), SPH_C32(0x6b5bca1e), SPH_C32(0xc8ea607c), + SPH_C32(0xe8add601) }, + { SPH_C32(0xe66c0000), SPH_C32(0x33030000), SPH_C32(0x72290000), + SPH_C32(0xf9f302e1), SPH_C32(0xe3ccf974), SPH_C32(0x31112c5d), + SPH_C32(0x2b9f98d4), SPH_C32(0x69502f09), SPH_C32(0xaf290000), + SPH_C32(0x70680000), SPH_C32(0xdc500000), SPH_C32(0xaf5d00d2), + SPH_C32(0x25be4942), SPH_C32(0x784a5e50), SPH_C32(0x9cf4f5c3), + SPH_C32(0x66090d68) }, + { SPH_C32(0xb9c40000), SPH_C32(0x65000000), SPH_C32(0x31870000), + SPH_C32(0x9d0002f2), SPH_C32(0xc6b27fcb), SPH_C32(0x2200b813), + SPH_C32(0x7f810d6b), SPH_C32(0xe7f4f460), SPH_C32(0xaf6d0000), + SPH_C32(0x0f200000), SPH_C32(0x062c0000), SPH_C32(0x857e00d3), + SPH_C32(0x1e13808e), SPH_C32(0xd1fcc2d7), SPH_C32(0x9ffe6ba3), + SPH_C32(0xd8036af6) }, + { SPH_C32(0x08bb0000), SPH_C32(0x9a4c0000), SPH_C32(0x3a940000), + SPH_C32(0xf8480300), SPH_C32(0x4c3018c4), SPH_C32(0xa3cb4b8d), + SPH_C32(0x6da425c0), SPH_C32(0xf74522f3), SPH_C32(0x8bed0000), + SPH_C32(0x0e610000), SPH_C32(0xec670000), SPH_C32(0x82ce0060), + SPH_C32(0xa5b6421e), SPH_C32(0xaf74c322), SPH_C32(0xec18c51f), + SPH_C32(0x9158d16f) }, + { SPH_C32(0x57130000), SPH_C32(0xcc4f0000), SPH_C32(0x793a0000), + SPH_C32(0x9cbb0313), SPH_C32(0x694e9e7b), SPH_C32(0xb0dadfc3), + SPH_C32(0x39bab07f), SPH_C32(0x79e1f99a), SPH_C32(0x8ba90000), + SPH_C32(0x71290000), SPH_C32(0x361b0000), SPH_C32(0xa8ed0061), + SPH_C32(0x9e1b8bd2), SPH_C32(0x06c25fa5), SPH_C32(0xef125b7f), + SPH_C32(0x2f52b6f1) }, + { SPH_C32(0x08ff0000), SPH_C32(0xe5040000), SPH_C32(0xe0e80000), + SPH_C32(0xd26b0301), SPH_C32(0x779dd108), SPH_C32(0x0a7dd70a), + SPH_C32(0x6eaebba0), SPH_C32(0x494f456d), SPH_C32(0xd4010000), + SPH_C32(0x272a0000), SPH_C32(0x75b50000), SPH_C32(0xcc1e0072), + SPH_C32(0xbb650d6d), SPH_C32(0x15d3cbeb), SPH_C32(0xbb0ccec0), + SPH_C32(0xa1f66d98) }, + { SPH_C32(0x57570000), SPH_C32(0xb3070000), SPH_C32(0xa3460000), + SPH_C32(0xb6980312), SPH_C32(0x52e357b7), SPH_C32(0x196c4344), + SPH_C32(0x3ab02e1f), SPH_C32(0xc7eb9e04), SPH_C32(0xd4450000), + SPH_C32(0x58620000), SPH_C32(0xafc90000), SPH_C32(0xe63d0073), + SPH_C32(0x80c8c4a1), SPH_C32(0xbc65576c), SPH_C32(0xb80650a0), + SPH_C32(0x1ffc0a06) }, + { SPH_C32(0x9d000000), SPH_C32(0x1b090000), SPH_C32(0x01b00000), + SPH_C32(0xb0930240), SPH_C32(0x46ba7497), SPH_C32(0xf53e2561), + SPH_C32(0x0f6d3db7), SPH_C32(0x10a52867), SPH_C32(0x657e0000), + SPH_C32(0xd8660000), SPH_C32(0x7ea60000), SPH_C32(0xa9560180), + SPH_C32(0x31e76a62), SPH_C32(0x94183875), SPH_C32(0xa929e66b), + SPH_C32(0xb147bb0b) }, + { SPH_C32(0xc2a80000), SPH_C32(0x4d0a0000), SPH_C32(0x421e0000), + SPH_C32(0xd4600253), SPH_C32(0x63c4f228), SPH_C32(0xe62fb12f), + SPH_C32(0x5b73a808), SPH_C32(0x9e01f30e), SPH_C32(0x653a0000), + SPH_C32(0xa72e0000), SPH_C32(0xa4da0000), SPH_C32(0x83750181), + SPH_C32(0x0a4aa3ae), SPH_C32(0x3daea4f2), SPH_C32(0xaa23780b), + SPH_C32(0x0f4ddc95) }, + { SPH_C32(0x9d440000), SPH_C32(0x64410000), SPH_C32(0xdbcc0000), + SPH_C32(0x9ab00241), SPH_C32(0x7d17bd5b), SPH_C32(0x5c88b9e6), + SPH_C32(0x0c67a3d7), SPH_C32(0xaeaf4ff9), SPH_C32(0x3a920000), + SPH_C32(0xf12d0000), SPH_C32(0xe7740000), SPH_C32(0xe7860192), + SPH_C32(0x2f342511), SPH_C32(0x2ebf30bc), SPH_C32(0xfe3dedb4), + SPH_C32(0x81e907fc) }, + { SPH_C32(0xc2ec0000), SPH_C32(0x32420000), SPH_C32(0x98620000), + SPH_C32(0xfe430252), SPH_C32(0x58693be4), SPH_C32(0x4f992da8), + SPH_C32(0x58793668), SPH_C32(0x200b9490), SPH_C32(0x3ad60000), + SPH_C32(0x8e650000), SPH_C32(0x3d080000), SPH_C32(0xcda50193), + SPH_C32(0x1499ecdd), SPH_C32(0x8709ac3b), SPH_C32(0xfd3773d4), + SPH_C32(0x3fe36062) }, + { SPH_C32(0x73930000), SPH_C32(0xcd0e0000), SPH_C32(0x93710000), + SPH_C32(0x9b0b03a0), SPH_C32(0xd2eb5ceb), SPH_C32(0xce52de36), + SPH_C32(0x4a5c1ec3), SPH_C32(0x30ba4203), SPH_C32(0x1e560000), + SPH_C32(0x8f240000), SPH_C32(0xd7430000), SPH_C32(0xca150120), + SPH_C32(0xaf3c2e4d), SPH_C32(0xf981adce), SPH_C32(0x8ed1dd68), + SPH_C32(0x76b8dbfb) }, + { SPH_C32(0x2c3b0000), SPH_C32(0x9b0d0000), SPH_C32(0xd0df0000), + SPH_C32(0xfff803b3), SPH_C32(0xf795da54), SPH_C32(0xdd434a78), + SPH_C32(0x1e428b7c), SPH_C32(0xbe1e996a), SPH_C32(0x1e120000), + SPH_C32(0xf06c0000), SPH_C32(0x0d3f0000), SPH_C32(0xe0360121), + SPH_C32(0x9491e781), SPH_C32(0x50373149), SPH_C32(0x8ddb4308), + SPH_C32(0xc8b2bc65) }, + { SPH_C32(0x73d70000), SPH_C32(0xb2460000), SPH_C32(0x490d0000), + SPH_C32(0xb12803a1), SPH_C32(0xe9469527), SPH_C32(0x67e442b1), + SPH_C32(0x495680a3), SPH_C32(0x8eb0259d), SPH_C32(0x41ba0000), + SPH_C32(0xa66f0000), SPH_C32(0x4e910000), SPH_C32(0x84c50132), + SPH_C32(0xb1ef613e), SPH_C32(0x4326a507), SPH_C32(0xd9c5d6b7), + SPH_C32(0x4616670c) }, + { SPH_C32(0x2c7f0000), SPH_C32(0xe4450000), SPH_C32(0x0aa30000), + SPH_C32(0xd5db03b2), SPH_C32(0xcc381398), SPH_C32(0x74f5d6ff), + SPH_C32(0x1d48151c), SPH_C32(0x0014fef4), SPH_C32(0x41fe0000), + SPH_C32(0xd9270000), SPH_C32(0x94ed0000), SPH_C32(0xaee60133), + SPH_C32(0x8a42a8f2), SPH_C32(0xea903980), SPH_C32(0xdacf48d7), + SPH_C32(0xf81c0092) } +}; + +static const sph_u32 T512_60[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x033d0000), SPH_C32(0x08b30000), SPH_C32(0xf33a0000), + SPH_C32(0x3ac20007), SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), + SPH_C32(0x0ea5cfe3), SPH_C32(0xe6da7ffe), SPH_C32(0xa8da0000), + SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), SPH_C32(0x07da0002), + SPH_C32(0x7d669583), SPH_C32(0x1f98708a), SPH_C32(0xbb668808), + SPH_C32(0xda878000) }, + { SPH_C32(0xa8da0000), SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), + SPH_C32(0x07da0002), SPH_C32(0x7d669583), SPH_C32(0x1f98708a), + SPH_C32(0xbb668808), SPH_C32(0xda878000), SPH_C32(0xabe70000), + SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), SPH_C32(0x3d180005), + SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), SPH_C32(0xb5c347eb), + SPH_C32(0x3c5dfffe) }, + { SPH_C32(0xabe70000), SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), + SPH_C32(0x3d180005), SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), + SPH_C32(0xb5c347eb), SPH_C32(0x3c5dfffe), SPH_C32(0x033d0000), + SPH_C32(0x08b30000), SPH_C32(0xf33a0000), SPH_C32(0x3ac20007), + SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), SPH_C32(0x0ea5cfe3), + SPH_C32(0xe6da7ffe) }, + { SPH_C32(0x01930000), SPH_C32(0xe7820000), SPH_C32(0xedfb0000), + SPH_C32(0xcf0c000b), SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), + SPH_C32(0x063661e1), SPH_C32(0x536f9e7b), SPH_C32(0x92280000), + SPH_C32(0xdc850000), SPH_C32(0x57fa0000), SPH_C32(0x56dc0003), + SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), SPH_C32(0x90cef752), + SPH_C32(0x7b1675d7) }, + { SPH_C32(0x02ae0000), SPH_C32(0xef310000), SPH_C32(0x1ec10000), + SPH_C32(0xf5ce000c), SPH_C32(0xdcf90708), SPH_C32(0xd7cdd231), + SPH_C32(0x0893ae02), SPH_C32(0xb5b5e185), SPH_C32(0x3af20000), + SPH_C32(0x4a3b0000), SPH_C32(0x0be70000), SPH_C32(0x51060001), + SPH_C32(0xc78fb695), SPH_C32(0x4577d386), SPH_C32(0x2ba87f5a), + SPH_C32(0xa191f5d7) }, + { SPH_C32(0xa9490000), SPH_C32(0x713c0000), SPH_C32(0xb1e60000), + SPH_C32(0xc8d60009), SPH_C32(0xf0b618db), SPH_C32(0xa33bc4a4), + SPH_C32(0xbd50e9e9), SPH_C32(0x89e81e7b), SPH_C32(0x39cf0000), + SPH_C32(0x42880000), SPH_C32(0xf8dd0000), SPH_C32(0x6bc40006), + SPH_C32(0x96a63cc5), SPH_C32(0x2e19b599), SPH_C32(0x250db0b9), + SPH_C32(0x474b8a29) }, + { SPH_C32(0xaa740000), SPH_C32(0x798f0000), SPH_C32(0x42dc0000), + SPH_C32(0xf214000e), SPH_C32(0xa19f928b), SPH_C32(0xc855a2bb), + SPH_C32(0xb3f5260a), SPH_C32(0x6f326185), SPH_C32(0x91150000), + SPH_C32(0xd4360000), SPH_C32(0xa4c00000), SPH_C32(0x6c1e0004), + SPH_C32(0xebc0a946), SPH_C32(0x3181c513), SPH_C32(0x9e6b38b1), + SPH_C32(0x9dcc0a29) }, + { SPH_C32(0x92280000), SPH_C32(0xdc850000), SPH_C32(0x57fa0000), + SPH_C32(0x56dc0003), SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), + SPH_C32(0x90cef752), SPH_C32(0x7b1675d7), SPH_C32(0x93bb0000), + SPH_C32(0x3b070000), SPH_C32(0xba010000), SPH_C32(0x99d00008), + SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), SPH_C32(0x96f896b3), + SPH_C32(0x2879ebac) }, + { SPH_C32(0x91150000), SPH_C32(0xd4360000), SPH_C32(0xa4c00000), + SPH_C32(0x6c1e0004), SPH_C32(0xebc0a946), SPH_C32(0x3181c513), + SPH_C32(0x9e6b38b1), SPH_C32(0x9dcc0a29), SPH_C32(0x3b610000), + SPH_C32(0xadb90000), SPH_C32(0xe61c0000), SPH_C32(0x9e0a000a), + SPH_C32(0x4a5f3bcd), SPH_C32(0xf9d467a8), SPH_C32(0x2d9e1ebb), + SPH_C32(0xf2fe6bac) }, + { SPH_C32(0x3af20000), SPH_C32(0x4a3b0000), SPH_C32(0x0be70000), + SPH_C32(0x51060001), SPH_C32(0xc78fb695), SPH_C32(0x4577d386), + SPH_C32(0x2ba87f5a), SPH_C32(0xa191f5d7), SPH_C32(0x385c0000), + SPH_C32(0xa50a0000), SPH_C32(0x15260000), SPH_C32(0xa4c8000d), + SPH_C32(0x1b76b19d), SPH_C32(0x92ba01b7), SPH_C32(0x233bd158), + SPH_C32(0x14241452) }, + { SPH_C32(0x39cf0000), SPH_C32(0x42880000), SPH_C32(0xf8dd0000), + SPH_C32(0x6bc40006), SPH_C32(0x96a63cc5), SPH_C32(0x2e19b599), + SPH_C32(0x250db0b9), SPH_C32(0x474b8a29), SPH_C32(0x90860000), + SPH_C32(0x33b40000), SPH_C32(0x493b0000), SPH_C32(0xa312000f), + SPH_C32(0x6610241e), SPH_C32(0x8d22713d), SPH_C32(0x985d5950), + SPH_C32(0xcea39452) }, + { SPH_C32(0x93bb0000), SPH_C32(0x3b070000), SPH_C32(0xba010000), + SPH_C32(0x99d00008), SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), + SPH_C32(0x96f896b3), SPH_C32(0x2879ebac), SPH_C32(0x01930000), + SPH_C32(0xe7820000), SPH_C32(0xedfb0000), SPH_C32(0xcf0c000b), + SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), SPH_C32(0x063661e1), + SPH_C32(0x536f9e7b) }, + { SPH_C32(0x90860000), SPH_C32(0x33b40000), SPH_C32(0x493b0000), + SPH_C32(0xa312000f), SPH_C32(0x6610241e), SPH_C32(0x8d22713d), + SPH_C32(0x985d5950), SPH_C32(0xcea39452), SPH_C32(0xa9490000), + SPH_C32(0x713c0000), SPH_C32(0xb1e60000), SPH_C32(0xc8d60009), + SPH_C32(0xf0b618db), SPH_C32(0xa33bc4a4), SPH_C32(0xbd50e9e9), + SPH_C32(0x89e81e7b) }, + { SPH_C32(0x3b610000), SPH_C32(0xadb90000), SPH_C32(0xe61c0000), + SPH_C32(0x9e0a000a), SPH_C32(0x4a5f3bcd), SPH_C32(0xf9d467a8), + SPH_C32(0x2d9e1ebb), SPH_C32(0xf2fe6bac), SPH_C32(0xaa740000), + SPH_C32(0x798f0000), SPH_C32(0x42dc0000), SPH_C32(0xf214000e), + SPH_C32(0xa19f928b), SPH_C32(0xc855a2bb), SPH_C32(0xb3f5260a), + SPH_C32(0x6f326185) }, + { SPH_C32(0x385c0000), SPH_C32(0xa50a0000), SPH_C32(0x15260000), + SPH_C32(0xa4c8000d), SPH_C32(0x1b76b19d), SPH_C32(0x92ba01b7), + SPH_C32(0x233bd158), SPH_C32(0x14241452), SPH_C32(0x02ae0000), + SPH_C32(0xef310000), SPH_C32(0x1ec10000), SPH_C32(0xf5ce000c), + SPH_C32(0xdcf90708), SPH_C32(0xd7cdd231), SPH_C32(0x0893ae02), + SPH_C32(0xb5b5e185) } +}; + +#define INPUT_BIG do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T512_0[acc >> 3][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + m8 = rp[8]; \ + m9 = rp[9]; \ + mA = rp[10]; \ + mB = rp[11]; \ + mC = rp[12]; \ + mD = rp[13]; \ + mE = rp[14]; \ + mF = rp[15]; \ + acc = (acc << 8) | buf[1]; \ + rp = &T512_5[(acc >> 6) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_10[(acc >> 1) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[2]; \ + rp = &T512_15[(acc >> 4) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[3]; \ + rp = &T512_20[(acc >> 7) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_25[(acc >> 2) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[4]; \ + rp = &T512_30[(acc >> 5) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_35[acc & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[5]; \ + rp = &T512_40[acc >> 3][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[6]; \ + rp = &T512_45[(acc >> 6) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_50[(acc >> 1) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[7]; \ + rp = &T512_55[(acc >> 4) & 0x1f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_60[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_BIG == 6 + +static const sph_u32 T512_0[64][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x145a3c00), SPH_C32(0xb9e90000), SPH_C32(0x61270000), + SPH_C32(0xf1610000), SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), + SPH_C32(0x47a96720), SPH_C32(0xe18e24c5), SPH_C32(0x23671400), + SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), SPH_C32(0xfb750000), + SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), SPH_C32(0x02c40a3f), + SPH_C32(0xdc24e61f) }, + { SPH_C32(0x23671400), SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), + SPH_C32(0xfb750000), SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), + SPH_C32(0x02c40a3f), SPH_C32(0xdc24e61f), SPH_C32(0x373d2800), + SPH_C32(0x71500000), SPH_C32(0x95e00000), SPH_C32(0x0a140000), + SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), SPH_C32(0x456d6d1f), + SPH_C32(0x3daac2da) }, + { SPH_C32(0x373d2800), SPH_C32(0x71500000), SPH_C32(0x95e00000), + SPH_C32(0x0a140000), SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), + SPH_C32(0x456d6d1f), SPH_C32(0x3daac2da), SPH_C32(0x145a3c00), + SPH_C32(0xb9e90000), SPH_C32(0x61270000), SPH_C32(0xf1610000), + SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), SPH_C32(0x47a96720), + SPH_C32(0xe18e24c5) }, + { SPH_C32(0x54285c00), SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), + SPH_C32(0xa1c50000), SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), + SPH_C32(0x6bb0419d), SPH_C32(0x551b3782), SPH_C32(0x9cbb1800), + SPH_C32(0xb0d30000), SPH_C32(0x92510000), SPH_C32(0xed930000), + SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), SPH_C32(0x430633da), + SPH_C32(0x78cace29) }, + { SPH_C32(0x40726000), SPH_C32(0x53040000), SPH_C32(0xa4f10000), + SPH_C32(0x50a40000), SPH_C32(0x7dc35a1c), SPH_C32(0x24ecf999), + SPH_C32(0x2c1926bd), SPH_C32(0xb4951347), SPH_C32(0xbfdc0c00), + SPH_C32(0x786a0000), SPH_C32(0x66960000), SPH_C32(0x16e60000), + SPH_C32(0x2af76720), SPH_C32(0x19b270bd), SPH_C32(0x41c239e5), + SPH_C32(0xa4ee2836) }, + { SPH_C32(0x774f4800), SPH_C32(0x22540000), SPH_C32(0x31110000), + SPH_C32(0x5ab00000), SPH_C32(0xc06f4315), SPH_C32(0x6c0361a8), + SPH_C32(0x69744ba2), SPH_C32(0x893fd19d), SPH_C32(0xab863000), + SPH_C32(0xc1830000), SPH_C32(0x07b10000), SPH_C32(0xe7870000), + SPH_C32(0xe4965a4c), SPH_C32(0xa9fb4dc5), SPH_C32(0x066b5ec5), + SPH_C32(0x45600cf3) }, + { SPH_C32(0x63157400), SPH_C32(0x9bbd0000), SPH_C32(0x50360000), + SPH_C32(0xabd10000), SPH_C32(0x0e0e7e79), SPH_C32(0xdc4a5cd0), + SPH_C32(0x2edd2c82), SPH_C32(0x68b1f558), SPH_C32(0x88e12400), + SPH_C32(0x093a0000), SPH_C32(0xf3760000), SPH_C32(0x1cf20000), + SPH_C32(0x975b7e29), SPH_C32(0x515de88c), SPH_C32(0x04af54fa), + SPH_C32(0x9944eaec) }, + { SPH_C32(0x9cbb1800), SPH_C32(0xb0d30000), SPH_C32(0x92510000), + SPH_C32(0xed930000), SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), + SPH_C32(0x430633da), SPH_C32(0x78cace29), SPH_C32(0xc8934400), + SPH_C32(0x5a3e0000), SPH_C32(0x57870000), SPH_C32(0x4c560000), + SPH_C32(0xea982435), SPH_C32(0x75b11115), SPH_C32(0x28b67247), + SPH_C32(0x2dd1f9ab) }, + { SPH_C32(0x88e12400), SPH_C32(0x093a0000), SPH_C32(0xf3760000), + SPH_C32(0x1cf20000), SPH_C32(0x975b7e29), SPH_C32(0x515de88c), + SPH_C32(0x04af54fa), SPH_C32(0x9944eaec), SPH_C32(0xebf45000), + SPH_C32(0x92870000), SPH_C32(0xa3400000), SPH_C32(0xb7230000), + SPH_C32(0x99550050), SPH_C32(0x8d17b45c), SPH_C32(0x2a727878), + SPH_C32(0xf1f51fb4) }, + { SPH_C32(0xbfdc0c00), SPH_C32(0x786a0000), SPH_C32(0x66960000), + SPH_C32(0x16e60000), SPH_C32(0x2af76720), SPH_C32(0x19b270bd), + SPH_C32(0x41c239e5), SPH_C32(0xa4ee2836), SPH_C32(0xffae6c00), + SPH_C32(0x2b6e0000), SPH_C32(0xc2670000), SPH_C32(0x46420000), + SPH_C32(0x57343d3c), SPH_C32(0x3d5e8924), SPH_C32(0x6ddb1f58), + SPH_C32(0x107b3b71) }, + { SPH_C32(0xab863000), SPH_C32(0xc1830000), SPH_C32(0x07b10000), + SPH_C32(0xe7870000), SPH_C32(0xe4965a4c), SPH_C32(0xa9fb4dc5), + SPH_C32(0x066b5ec5), SPH_C32(0x45600cf3), SPH_C32(0xdcc97800), + SPH_C32(0xe3d70000), SPH_C32(0x36a00000), SPH_C32(0xbd370000), + SPH_C32(0x24f91959), SPH_C32(0xc5f82c6d), SPH_C32(0x6f1f1567), + SPH_C32(0xcc5fdd6e) }, + { SPH_C32(0xc8934400), SPH_C32(0x5a3e0000), SPH_C32(0x57870000), + SPH_C32(0x4c560000), SPH_C32(0xea982435), SPH_C32(0x75b11115), + SPH_C32(0x28b67247), SPH_C32(0x2dd1f9ab), SPH_C32(0x54285c00), + SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), SPH_C32(0xa1c50000), + SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), SPH_C32(0x6bb0419d), + SPH_C32(0x551b3782) }, + { SPH_C32(0xdcc97800), SPH_C32(0xe3d70000), SPH_C32(0x36a00000), + SPH_C32(0xbd370000), SPH_C32(0x24f91959), SPH_C32(0xc5f82c6d), + SPH_C32(0x6f1f1567), SPH_C32(0xcc5fdd6e), SPH_C32(0x774f4800), + SPH_C32(0x22540000), SPH_C32(0x31110000), SPH_C32(0x5ab00000), + SPH_C32(0xc06f4315), SPH_C32(0x6c0361a8), SPH_C32(0x69744ba2), + SPH_C32(0x893fd19d) }, + { SPH_C32(0xebf45000), SPH_C32(0x92870000), SPH_C32(0xa3400000), + SPH_C32(0xb7230000), SPH_C32(0x99550050), SPH_C32(0x8d17b45c), + SPH_C32(0x2a727878), SPH_C32(0xf1f51fb4), SPH_C32(0x63157400), + SPH_C32(0x9bbd0000), SPH_C32(0x50360000), SPH_C32(0xabd10000), + SPH_C32(0x0e0e7e79), SPH_C32(0xdc4a5cd0), SPH_C32(0x2edd2c82), + SPH_C32(0x68b1f558) }, + { SPH_C32(0xffae6c00), SPH_C32(0x2b6e0000), SPH_C32(0xc2670000), + SPH_C32(0x46420000), SPH_C32(0x57343d3c), SPH_C32(0x3d5e8924), + SPH_C32(0x6ddb1f58), SPH_C32(0x107b3b71), SPH_C32(0x40726000), + SPH_C32(0x53040000), SPH_C32(0xa4f10000), SPH_C32(0x50a40000), + SPH_C32(0x7dc35a1c), SPH_C32(0x24ecf999), SPH_C32(0x2c1926bd), + SPH_C32(0xb4951347) }, + { SPH_C32(0x29449c00), SPH_C32(0x64e70000), SPH_C32(0xf24b0000), + SPH_C32(0xc2f30000), SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), + SPH_C32(0xf3e04259), SPH_C32(0x8d0d9ec4), SPH_C32(0x466d0c00), + SPH_C32(0x08620000), SPH_C32(0xdd5d0000), SPH_C32(0xbadd0000), + SPH_C32(0x6a927942), SPH_C32(0x441f2b93), SPH_C32(0x218ace6f), + SPH_C32(0xbf2c0be2) }, + { SPH_C32(0x3d1ea000), SPH_C32(0xdd0e0000), SPH_C32(0x936c0000), + SPH_C32(0x33920000), SPH_C32(0xc0bf73e3), SPH_C32(0xe68b0a3d), + SPH_C32(0xb4492579), SPH_C32(0x6c83ba01), SPH_C32(0x650a1800), + SPH_C32(0xc0db0000), SPH_C32(0x299a0000), SPH_C32(0x41a80000), + SPH_C32(0x195f5d27), SPH_C32(0xbcb98eda), SPH_C32(0x234ec450), + SPH_C32(0x6308edfd) }, + { SPH_C32(0x0a238800), SPH_C32(0xac5e0000), SPH_C32(0x068c0000), + SPH_C32(0x39860000), SPH_C32(0x7d136aea), SPH_C32(0xae64920c), + SPH_C32(0xf1244866), SPH_C32(0x512978db), SPH_C32(0x71502400), + SPH_C32(0x79320000), SPH_C32(0x48bd0000), SPH_C32(0xb0c90000), + SPH_C32(0xd73e604b), SPH_C32(0x0cf0b3a2), SPH_C32(0x64e7a370), + SPH_C32(0x8286c938) }, + { SPH_C32(0x1e79b400), SPH_C32(0x15b70000), SPH_C32(0x67ab0000), + SPH_C32(0xc8e70000), SPH_C32(0xb3725786), SPH_C32(0x1e2daf74), + SPH_C32(0xb68d2f46), SPH_C32(0xb0a75c1e), SPH_C32(0x52373000), + SPH_C32(0xb18b0000), SPH_C32(0xbc7a0000), SPH_C32(0x4bbc0000), + SPH_C32(0xa4f3442e), SPH_C32(0xf45616eb), SPH_C32(0x6623a94f), + SPH_C32(0x5ea22f27) }, + { SPH_C32(0x7d6cc000), SPH_C32(0x8e0a0000), SPH_C32(0x379d0000), + SPH_C32(0x63360000), SPH_C32(0xbd7c29ff), SPH_C32(0xc267f3a4), + SPH_C32(0x985003c4), SPH_C32(0xd816a946), SPH_C32(0xdad61400), + SPH_C32(0xb8b10000), SPH_C32(0x4f0c0000), SPH_C32(0x574e0000), + SPH_C32(0x33a83a07), SPH_C32(0xa50bfe67), SPH_C32(0x628cfdb5), + SPH_C32(0xc7e6c5cb) }, + { SPH_C32(0x6936fc00), SPH_C32(0x37e30000), SPH_C32(0x56ba0000), + SPH_C32(0x92570000), SPH_C32(0x731d1493), SPH_C32(0x722ecedc), + SPH_C32(0xdff964e4), SPH_C32(0x39988d83), SPH_C32(0xf9b10000), + SPH_C32(0x70080000), SPH_C32(0xbbcb0000), SPH_C32(0xac3b0000), + SPH_C32(0x40651e62), SPH_C32(0x5dad5b2e), SPH_C32(0x6048f78a), + SPH_C32(0x1bc223d4) }, + { SPH_C32(0x5e0bd400), SPH_C32(0x46b30000), SPH_C32(0xc35a0000), + SPH_C32(0x98430000), SPH_C32(0xceb10d9a), SPH_C32(0x3ac156ed), + SPH_C32(0x9a9409fb), SPH_C32(0x04324f59), SPH_C32(0xedeb3c00), + SPH_C32(0xc9e10000), SPH_C32(0xdaec0000), SPH_C32(0x5d5a0000), + SPH_C32(0x8e04230e), SPH_C32(0xede46656), SPH_C32(0x27e190aa), + SPH_C32(0xfa4c0711) }, + { SPH_C32(0x4a51e800), SPH_C32(0xff5a0000), SPH_C32(0xa27d0000), + SPH_C32(0x69220000), SPH_C32(0x00d030f6), SPH_C32(0x8a886b95), + SPH_C32(0xdd3d6edb), SPH_C32(0xe5bc6b9c), SPH_C32(0xce8c2800), + SPH_C32(0x01580000), SPH_C32(0x2e2b0000), SPH_C32(0xa62f0000), + SPH_C32(0xfdc9076b), SPH_C32(0x1542c31f), SPH_C32(0x25259a95), + SPH_C32(0x2668e10e) }, + { SPH_C32(0xb5ff8400), SPH_C32(0xd4340000), SPH_C32(0x601a0000), + SPH_C32(0x2f600000), SPH_C32(0x57e40dca), SPH_C32(0xb7d6e2b1), + SPH_C32(0xb0e67183), SPH_C32(0xf5c750ed), SPH_C32(0x8efe4800), + SPH_C32(0x525c0000), SPH_C32(0x8ada0000), SPH_C32(0xf68b0000), + SPH_C32(0x800a5d77), SPH_C32(0x31ae3a86), SPH_C32(0x093cbc28), + SPH_C32(0x92fdf249) }, + { SPH_C32(0xa1a5b800), SPH_C32(0x6ddd0000), SPH_C32(0x013d0000), + SPH_C32(0xde010000), SPH_C32(0x998530a6), SPH_C32(0x079fdfc9), + SPH_C32(0xf74f16a3), SPH_C32(0x14497428), SPH_C32(0xad995c00), + SPH_C32(0x9ae50000), SPH_C32(0x7e1d0000), SPH_C32(0x0dfe0000), + SPH_C32(0xf3c77912), SPH_C32(0xc9089fcf), SPH_C32(0x0bf8b617), + SPH_C32(0x4ed91456) }, + { SPH_C32(0x496989000), SPH_C32(0x1c8d0000), SPH_C32(0x94dd0000), + SPH_C32(0xd4150000), SPH_C32(0x242929af), SPH_C32(0x4f7047f8), + SPH_C32(0xb2227bbc), SPH_C32(0x29e3b6f2), SPH_C32(0xb9c36000), + SPH_C32(0x230c0000), SPH_C32(0x1f3a0000), SPH_C32(0xfc9f0000), + SPH_C32(0x3da6447e), SPH_C32(0x7941a2b7), SPH_C32(0x4c51d137), + SPH_C32(0xaf573093) }, + { SPH_C32(0x82c2ac00), SPH_C32(0xa5640000), SPH_C32(0xf5fa0000), + SPH_C32(0x25740000), SPH_C32(0xea4814c3), SPH_C32(0xff397a80), + SPH_C32(0xf58b1c9c), SPH_C32(0xc86d9237), SPH_C32(0x9aa47400), + SPH_C32(0xebb50000), SPH_C32(0xebfd0000), SPH_C32(0x07ea0000), + SPH_C32(0x4e6b601b), SPH_C32(0x81e707fe), SPH_C32(0x4e95db08), + SPH_C32(0x7373d68c) }, + { SPH_C32(0xe1d7d800), SPH_C32(0x3ed90000), SPH_C32(0xa5cc0000), + SPH_C32(0x8ea50000), SPH_C32(0xe4466aba), SPH_C32(0x23732650), + SPH_C32(0xdb56301e), SPH_C32(0xa0dc676f), SPH_C32(0x12455000), + SPH_C32(0xe28f0000), SPH_C32(0x188b0000), SPH_C32(0x1b180000), + SPH_C32(0xd9301e32), SPH_C32(0xd0baef72), SPH_C32(0x4a3a8ff2), + SPH_C32(0xea373c60) }, + { SPH_C32(0xf58de400), SPH_C32(0x87300000), SPH_C32(0xc4eb0000), + SPH_C32(0x7fc40000), SPH_C32(0x2a2757d6), SPH_C32(0x933a1b28), + SPH_C32(0x9cff573e), SPH_C32(0x415243aa), SPH_C32(0x31224400), + SPH_C32(0x2a360000), SPH_C32(0xec4c0000), SPH_C32(0xe06d0000), + SPH_C32(0xaafd3a57), SPH_C32(0x281c4a3b), SPH_C32(0x48fe85cd), + SPH_C32(0x3613da7f) }, + { SPH_C32(0xc2b0cc00), SPH_C32(0xf6600000), SPH_C32(0x510b0000), + SPH_C32(0x75d00000), SPH_C32(0x978b4edf), SPH_C32(0xdbd58319), + SPH_C32(0xd9923a21), SPH_C32(0x7cf88170), SPH_C32(0x25787800), + SPH_C32(0x93df0000), SPH_C32(0x8d6b0000), SPH_C32(0x110c0000), + SPH_C32(0x649c073b), SPH_C32(0x98557743), SPH_C32(0x0f57e2ed), + SPH_C32(0xd79dfeba) }, + { SPH_C32(0xd6eaf000), SPH_C32(0x4f890000), SPH_C32(0x302c0000), + SPH_C32(0x84b10000), SPH_C32(0x59ea73b3), SPH_C32(0x6b9cbe61), + SPH_C32(0x9e3b5d01), SPH_C32(0x9d76a5b5), SPH_C32(0x061f6c00), + SPH_C32(0x5b660000), SPH_C32(0x79ac0000), SPH_C32(0xea790000), + SPH_C32(0x1751235e), SPH_C32(0x60f3d20a), SPH_C32(0x0d93e8d2), + SPH_C32(0x0bb918a5) }, + { SPH_C32(0x466d0c00), SPH_C32(0x08620000), SPH_C32(0xdd5d0000), + SPH_C32(0xbadd0000), SPH_C32(0x6a927942), SPH_C32(0x441f2b93), + SPH_C32(0x218ace6f), SPH_C32(0xbf2c0be2), SPH_C32(0x6f299000), + SPH_C32(0x6c850000), SPH_C32(0x2f160000), SPH_C32(0x782e0000), + SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), SPH_C32(0xd26a8c36), + SPH_C32(0x32219526) }, + { SPH_C32(0x52373000), SPH_C32(0xb18b0000), SPH_C32(0xbc7a0000), + SPH_C32(0x4bbc0000), SPH_C32(0xa4f3442e), SPH_C32(0xf45616eb), + SPH_C32(0x6623a94f), SPH_C32(0x5ea22f27), SPH_C32(0x4c4e8400), + SPH_C32(0xa43c0000), SPH_C32(0xdbd10000), SPH_C32(0x835b0000), + SPH_C32(0x178113a8), SPH_C32(0xea7bb99f), SPH_C32(0xd0ae8609), + SPH_C32(0xee057339) }, + { SPH_C32(0x650a1800), SPH_C32(0xc0db0000), SPH_C32(0x299a0000), + SPH_C32(0x41a80000), SPH_C32(0x195f5d27), SPH_C32(0xbcb98eda), + SPH_C32(0x234ec450), SPH_C32(0x6308edfd), SPH_C32(0x5814b800), + SPH_C32(0x1dd50000), SPH_C32(0xbaf60000), SPH_C32(0x723a0000), + SPH_C32(0xd9e02ec4), SPH_C32(0x5a3284e7), SPH_C32(0x9707e129), + SPH_C32(0x0f8b57fc) }, + { SPH_C32(0x71502400), SPH_C32(0x79320000), SPH_C32(0x48bd0000), + SPH_C32(0xb0c90000), SPH_C32(0xd73e604b), SPH_C32(0x0cf0b3a2), + SPH_C32(0x64e7a370), SPH_C32(0x8286c938), SPH_C32(0x7b73ac00), + SPH_C32(0xd56c0000), SPH_C32(0x4e310000), SPH_C32(0x894f0000), + SPH_C32(0xaa2d0aa1), SPH_C32(0xa29421ae), SPH_C32(0x95c3eb16), + SPH_C32(0xd3afb1e3) }, + { SPH_C32(0x12455000), SPH_C32(0xe28f0000), SPH_C32(0x188b0000), + SPH_C32(0x1b180000), SPH_C32(0xd9301e32), SPH_C32(0xd0baef72), + SPH_C32(0x4a3a8ff2), SPH_C32(0xea373c60), SPH_C32(0xf3928800), + SPH_C32(0xdc560000), SPH_C32(0xbd470000), SPH_C32(0x95bd0000), + SPH_C32(0x3d767488), SPH_C32(0xf3c9c922), SPH_C32(0x916cbfec), + SPH_C32(0x4aeb5b0f) }, + { SPH_C32(0x061f6c00), SPH_C32(0x5b660000), SPH_C32(0x79ac0000), + SPH_C32(0xea790000), SPH_C32(0x1751235e), SPH_C32(0x60f3d20a), + SPH_C32(0x0d93e8d2), SPH_C32(0x0bb918a5), SPH_C32(0xd0f59c00), + SPH_C32(0x14ef0000), SPH_C32(0x49800000), SPH_C32(0x6ec80000), + SPH_C32(0x4ebb50ed), SPH_C32(0x0b6f6c6b), SPH_C32(0x93a8b5d3), + SPH_C32(0x96cfbd10) }, + { SPH_C32(0x31224400), SPH_C32(0x2a360000), SPH_C32(0xec4c0000), + SPH_C32(0xe06d0000), SPH_C32(0xaafd3a57), SPH_C32(0x281c4a3b), + SPH_C32(0x48fe85cd), SPH_C32(0x3613da7f), SPH_C32(0xc4afa000), + SPH_C32(0xad060000), SPH_C32(0x28a70000), SPH_C32(0x9fa90000), + SPH_C32(0x80da6d81), SPH_C32(0xbb265113), SPH_C32(0xd401d2f3), + SPH_C32(0x774199d5) }, + { SPH_C32(0x25787800), SPH_C32(0x93df0000), SPH_C32(0x8d6b0000), + SPH_C32(0x110c0000), SPH_C32(0x649c073b), SPH_C32(0x98557743), + SPH_C32(0x0f57e2ed), SPH_C32(0xd79dfeba), SPH_C32(0xe7c8b400), + SPH_C32(0x65bf0000), SPH_C32(0xdc600000), SPH_C32(0x64dc0000), + SPH_C32(0xf31749e4), SPH_C32(0x4380f45a), SPH_C32(0xd6c5d8cc), + SPH_C32(0xab657fca) }, + { SPH_C32(0xdad61400), SPH_C32(0xb8b10000), SPH_C32(0x4f0c0000), + SPH_C32(0x574e0000), SPH_C32(0x33a83a07), SPH_C32(0xa50bfe67), + SPH_C32(0x628cfdb5), SPH_C32(0xc7e6c5cb), SPH_C32(0xa7bad400), + SPH_C32(0x36bb0000), SPH_C32(0x78910000), SPH_C32(0x34780000), + SPH_C32(0x8ed413f8), SPH_C32(0x676c0dc3), SPH_C32(0xfadcfe71), + SPH_C32(0x1ff06c8d) }, + { SPH_C32(0xce8c2800), SPH_C32(0x01580000), SPH_C32(0x2e2b0000), + SPH_C32(0xa62f0000), SPH_C32(0xfdc9076b), SPH_C32(0x1542c31f), + SPH_C32(0x25259a95), SPH_C32(0x2668e10e), SPH_C32(0x84ddc000), + SPH_C32(0xfe020000), SPH_C32(0x8c560000), SPH_C32(0xcf0d0000), + SPH_C32(0xfd19379d), SPH_C32(0x9fcaa88a), SPH_C32(0xf818f44e), + SPH_C32(0xc3d48a92) }, + { SPH_C32(0xf9b10000), SPH_C32(0x70080000), SPH_C32(0xbbcb0000), + SPH_C32(0xac3b0000), SPH_C32(0x40651e62), SPH_C32(0x5dad5b2e), + SPH_C32(0x6048f78a), SPH_C32(0x1bc223d4), SPH_C32(0x9087fc00), + SPH_C32(0x47eb0000), SPH_C32(0xed710000), SPH_C32(0x3e6c0000), + SPH_C32(0x33780af1), SPH_C32(0x2f8395f2), SPH_C32(0xbfb1936e), + SPH_C32(0x225aae57) }, + { SPH_C32(0xedeb3c00), SPH_C32(0xc9e10000), SPH_C32(0xdaec0000), + SPH_C32(0x5d5a0000), SPH_C32(0x8e04230e), SPH_C32(0xede46656), + SPH_C32(0x27e190aa), SPH_C32(0xfa4c0711), SPH_C32(0xb3e0e800), + SPH_C32(0x8f520000), SPH_C32(0x19b60000), SPH_C32(0xc5190000), + SPH_C32(0x40b52e94), SPH_C32(0xd72530bb), SPH_C32(0xbd759951), + SPH_C32(0xfe7e4848) }, + { SPH_C32(0x8efe4800), SPH_C32(0x525c0000), SPH_C32(0x8ada0000), + SPH_C32(0xf68b0000), SPH_C32(0x800a5d77), SPH_C32(0x31ae3a86), + SPH_C32(0x093cbc28), SPH_C32(0x92fdf249), SPH_C32(0x3b01cc00), + SPH_C32(0x86680000), SPH_C32(0xeac00000), SPH_C32(0xd9eb0000), + SPH_C32(0xd7ee50bd), SPH_C32(0x8678d837), SPH_C32(0xb9dacdab), + SPH_C32(0x673aa2a4) }, + { SPH_C32(0x9aa47400), SPH_C32(0xebb50000), SPH_C32(0xebfd0000), + SPH_C32(0x07ea0000), SPH_C32(0x4e6b601b), SPH_C32(0x81e707fe), + SPH_C32(0x4e95db08), SPH_C32(0x7373d68c), SPH_C32(0x1866d800), + SPH_C32(0x4ed10000), SPH_C32(0x1e070000), SPH_C32(0x229e0000), + SPH_C32(0xa42374d8), SPH_C32(0x7ede7d7e), SPH_C32(0xbb1ec794), + SPH_C32(0xbb1e44bb) }, + { SPH_C32(0xad995c00), SPH_C32(0x9ae50000), SPH_C32(0x7e1d0000), + SPH_C32(0x0dfe0000), SPH_C32(0xf3c77912), SPH_C32(0xc9089fcf), + SPH_C32(0x0bf8b617), SPH_C32(0x4ed91456), SPH_C32(0x0c3ce400), + SPH_C32(0xf7380000), SPH_C32(0x7f200000), SPH_C32(0xd3ff0000), + SPH_C32(0x6a4249b4), SPH_C32(0xce974006), SPH_C32(0xfcb7a0b4), + SPH_C32(0x5a90607e) }, + { SPH_C32(0xb9c36000), SPH_C32(0x230c0000), SPH_C32(0x1f3a0000), + SPH_C32(0xfc9f0000), SPH_C32(0x3da6447e), SPH_C32(0x7941a2b7), + SPH_C32(0x4c51d137), SPH_C32(0xaf573093), SPH_C32(0x2f5bf000), + SPH_C32(0x3f810000), SPH_C32(0x8be70000), SPH_C32(0x288a0000), + SPH_C32(0x198f6dd1), SPH_C32(0x3631e54f), SPH_C32(0xfe73aa8b), + SPH_C32(0x86b48661) }, + { SPH_C32(0x6f299000), SPH_C32(0x6c850000), SPH_C32(0x2f160000), + SPH_C32(0x782e0000), SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), + SPH_C32(0xd26a8c36), SPH_C32(0x32219526), SPH_C32(0x29449c00), + SPH_C32(0x64e70000), SPH_C32(0xf24b0000), SPH_C32(0xc2f30000), + SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), SPH_C32(0xf3e04259), + SPH_C32(0x8d0d9ec4) }, + { SPH_C32(0x7b73ac00), SPH_C32(0xd56c0000), SPH_C32(0x4e310000), + SPH_C32(0x894f0000), SPH_C32(0xaa2d0aa1), SPH_C32(0xa29421ae), + SPH_C32(0x95c3eb16), SPH_C32(0xd3afb1e3), SPH_C32(0x0a238800), + SPH_C32(0xac5e0000), SPH_C32(0x068c0000), SPH_C32(0x39860000), + SPH_C32(0x7d136aea), SPH_C32(0xae64920c), SPH_C32(0xf1244866), + SPH_C32(0x512978db) }, + { SPH_C32(0x4c4e8400), SPH_C32(0xa43c0000), SPH_C32(0xdbd10000), + SPH_C32(0x835b0000), SPH_C32(0x178113a8), SPH_C32(0xea7bb99f), + SPH_C32(0xd0ae8609), SPH_C32(0xee057339), SPH_C32(0x1e79b400), + SPH_C32(0x15b70000), SPH_C32(0x67ab0000), SPH_C32(0xc8e70000), + SPH_C32(0xb3725786), SPH_C32(0x1e2daf74), SPH_C32(0xb68d2f46), + SPH_C32(0xb0a75c1e) }, + { SPH_C32(0x5814b800), SPH_C32(0x1dd50000), SPH_C32(0xbaf60000), + SPH_C32(0x723a0000), SPH_C32(0xd9e02ec4), SPH_C32(0x5a3284e7), + SPH_C32(0x9707e129), SPH_C32(0x0f8b57fc), SPH_C32(0x3d1ea000), + SPH_C32(0xdd0e0000), SPH_C32(0x936c0000), SPH_C32(0x33920000), + SPH_C32(0xc0bf73e3), SPH_C32(0xe68b0a3d), SPH_C32(0xb4492579), + SPH_C32(0x6c83ba01) }, + { SPH_C32(0x3b01cc00), SPH_C32(0x86680000), SPH_C32(0xeac00000), + SPH_C32(0xd9eb0000), SPH_C32(0xd7ee50bd), SPH_C32(0x8678d837), + SPH_C32(0xb9dacdab), SPH_C32(0x673aa2a4), SPH_C32(0xb5ff8400), + SPH_C32(0xd4340000), SPH_C32(0x601a0000), SPH_C32(0x2f600000), + SPH_C32(0x57e40dca), SPH_C32(0xb7d6e2b1), SPH_C32(0xb0e67183), + SPH_C32(0xf5c750ed) }, + { SPH_C32(0x2f5bf000), SPH_C32(0x3f810000), SPH_C32(0x8be70000), + SPH_C32(0x288a0000), SPH_C32(0x198f6dd1), SPH_C32(0x3631e54f), + SPH_C32(0xfe73aa8b), SPH_C32(0x86b48661), SPH_C32(0x496989000), + SPH_C32(0x1c8d0000), SPH_C32(0x94dd0000), SPH_C32(0xd4150000), + SPH_C32(0x242929af), SPH_C32(0x4f7047f8), SPH_C32(0xb2227bbc), + SPH_C32(0x29e3b6f2) }, + { SPH_C32(0x1866d800), SPH_C32(0x4ed10000), SPH_C32(0x1e070000), + SPH_C32(0x229e0000), SPH_C32(0xa42374d8), SPH_C32(0x7ede7d7e), + SPH_C32(0xbb1ec794), SPH_C32(0xbb1e44bb), SPH_C32(0x82c2ac00), + SPH_C32(0xa5640000), SPH_C32(0xf5fa0000), SPH_C32(0x25740000), + SPH_C32(0xea4814c3), SPH_C32(0xff397a80), SPH_C32(0xf58b1c9c), + SPH_C32(0xc86d9237) }, + { SPH_C32(0x0c3ce400), SPH_C32(0xf7380000), SPH_C32(0x7f200000), + SPH_C32(0xd3ff0000), SPH_C32(0x6a4249b4), SPH_C32(0xce974006), + SPH_C32(0xfcb7a0b4), SPH_C32(0x5a90607e), SPH_C32(0xa1a5b800), + SPH_C32(0x6ddd0000), SPH_C32(0x013d0000), SPH_C32(0xde010000), + SPH_C32(0x998530a6), SPH_C32(0x079fdfc9), SPH_C32(0xf74f16a3), + SPH_C32(0x14497428) }, + { SPH_C32(0xf3928800), SPH_C32(0xdc560000), SPH_C32(0xbd470000), + SPH_C32(0x95bd0000), SPH_C32(0x3d767488), SPH_C32(0xf3c9c922), + SPH_C32(0x916cbfec), SPH_C32(0x4aeb5b0f), SPH_C32(0xe1d7d800), + SPH_C32(0x3ed90000), SPH_C32(0xa5cc0000), SPH_C32(0x8ea50000), + SPH_C32(0xe4466aba), SPH_C32(0x23732650), SPH_C32(0xdb56301e), + SPH_C32(0xa0dc676f) }, + { SPH_C32(0xe7c8b400), SPH_C32(0x65bf0000), SPH_C32(0xdc600000), + SPH_C32(0x64dc0000), SPH_C32(0xf31749e4), SPH_C32(0x4380f45a), + SPH_C32(0xd6c5d8cc), SPH_C32(0xab657fca), SPH_C32(0xc2b0cc00), + SPH_C32(0xf6600000), SPH_C32(0x510b0000), SPH_C32(0x75d00000), + SPH_C32(0x978b4edf), SPH_C32(0xdbd58319), SPH_C32(0xd9923a21), + SPH_C32(0x7cf88170) }, + { SPH_C32(0xd0f59c00), SPH_C32(0x14ef0000), SPH_C32(0x49800000), + SPH_C32(0x6ec80000), SPH_C32(0x4ebb50ed), SPH_C32(0x0b6f6c6b), + SPH_C32(0x93a8b5d3), SPH_C32(0x96cfbd10), SPH_C32(0xd6eaf000), + SPH_C32(0x4f890000), SPH_C32(0x302c0000), SPH_C32(0x84b10000), + SPH_C32(0x59ea73b3), SPH_C32(0x6b9cbe61), SPH_C32(0x9e3b5d01), + SPH_C32(0x9d76a5b5) }, + { SPH_C32(0xc4afa000), SPH_C32(0xad060000), SPH_C32(0x28a70000), + SPH_C32(0x9fa90000), SPH_C32(0x80da6d81), SPH_C32(0xbb265113), + SPH_C32(0xd401d2f3), SPH_C32(0x774199d5), SPH_C32(0xf58de400), + SPH_C32(0x87300000), SPH_C32(0xc4eb0000), SPH_C32(0x7fc40000), + SPH_C32(0x2a2757d6), SPH_C32(0x933a1b28), SPH_C32(0x9cff573e), + SPH_C32(0x415243aa) }, + { SPH_C32(0xa7bad400), SPH_C32(0x36bb0000), SPH_C32(0x78910000), + SPH_C32(0x34780000), SPH_C32(0x8ed413f8), SPH_C32(0x676c0dc3), + SPH_C32(0xfadcfe71), SPH_C32(0x1ff06c8d), SPH_C32(0x7d6cc000), + SPH_C32(0x8e0a0000), SPH_C32(0x379d0000), SPH_C32(0x63360000), + SPH_C32(0xbd7c29ff), SPH_C32(0xc267f3a4), SPH_C32(0x985003c4), + SPH_C32(0xd816a946) }, + { SPH_C32(0xb3e0e800), SPH_C32(0x8f520000), SPH_C32(0x19b60000), + SPH_C32(0xc5190000), SPH_C32(0x40b52e94), SPH_C32(0xd72530bb), + SPH_C32(0xbd759951), SPH_C32(0xfe7e4848), SPH_C32(0x5e0bd400), + SPH_C32(0x46b30000), SPH_C32(0xc35a0000), SPH_C32(0x98430000), + SPH_C32(0xceb10d9a), SPH_C32(0x3ac156ed), SPH_C32(0x9a9409fb), + SPH_C32(0x04324f59) }, + { SPH_C32(0x84ddc000), SPH_C32(0xfe020000), SPH_C32(0x8c560000), + SPH_C32(0xcf0d0000), SPH_C32(0xfd19379d), SPH_C32(0x9fcaa88a), + SPH_C32(0xf818f44e), SPH_C32(0xc3d48a92), SPH_C32(0x4a51e800), + SPH_C32(0xff5a0000), SPH_C32(0xa27d0000), SPH_C32(0x69220000), + SPH_C32(0x00d030f6), SPH_C32(0x8a886b95), SPH_C32(0xdd3d6edb), + SPH_C32(0xe5bc6b9c) }, + { SPH_C32(0x9087fc00), SPH_C32(0x47eb0000), SPH_C32(0xed710000), + SPH_C32(0x3e6c0000), SPH_C32(0x33780af1), SPH_C32(0x2f8395f2), + SPH_C32(0xbfb1936e), SPH_C32(0x225aae57), SPH_C32(0x6936fc00), + SPH_C32(0x37e30000), SPH_C32(0x56ba0000), SPH_C32(0x92570000), + SPH_C32(0x731d1493), SPH_C32(0x722ecedc), SPH_C32(0xdff964e4), + SPH_C32(0x39988d83) } +}; + +static const sph_u32 T512_6[64][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x774400f0), SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), + SPH_C32(0x34140000), SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), + SPH_C32(0x0bc3cd1e), SPH_C32(0xcf3775cb), SPH_C32(0xf46c0050), + SPH_C32(0x96180000), SPH_C32(0x14a50000), SPH_C32(0x031f0000), + SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), SPH_C32(0x9ca470d2), + SPH_C32(0x8a341574) }, + { SPH_C32(0xf46c0050), SPH_C32(0x96180000), SPH_C32(0x14a50000), + SPH_C32(0x031f0000), SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), + SPH_C32(0x9ca470d2), SPH_C32(0x8a341574), SPH_C32(0x832800a0), + SPH_C32(0x67420000), SPH_C32(0xe1170000), SPH_C32(0x370b0000), + SPH_C32(0xcba30034), SPH_C32(0x3c34923c), SPH_C32(0x9767bdcc), + SPH_C32(0x450360bf) }, + { SPH_C32(0x832800a0), SPH_C32(0x67420000), SPH_C32(0xe1170000), + SPH_C32(0x370b0000), SPH_C32(0xcba30034), SPH_C32(0x3c34923c), + SPH_C32(0x9767bdcc), SPH_C32(0x450360bf), SPH_C32(0x774400f0), + SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), SPH_C32(0x34140000), + SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), SPH_C32(0x0bc3cd1e), + SPH_C32(0xcf3775cb) }, + { SPH_C32(0xe8870170), SPH_C32(0x9d720000), SPH_C32(0x12db0000), + SPH_C32(0xd4220000), SPH_C32(0xf2886b27), SPH_C32(0xa921e543), + SPH_C32(0x4ef8b518), SPH_C32(0x618813b1), SPH_C32(0xb4370060), + SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), SPH_C32(0x5cae0000), + SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), SPH_C32(0x1b365f3d), + SPH_C32(0xf3d45758) }, + { SPH_C32(0x9fc30180), SPH_C32(0x6c280000), SPH_C32(0xe7690000), + SPH_C32(0xe0360000), SPH_C32(0x7bbf15ab), SPH_C32(0xf3aa0966), + SPH_C32(0x453b7806), SPH_C32(0xaebf667a), SPH_C32(0x405b0030), + SPH_C32(0x9a540000), SPH_C32(0x42670000), SPH_C32(0x5fb10000), + SPH_C32(0xd6c06187), SPH_C32(0x5d81863c), SPH_C32(0x87922fef), + SPH_C32(0x79e0422c) }, + { SPH_C32(0x1ceb0120), SPH_C32(0x0b6a0000), SPH_C32(0x067e0000), + SPH_C32(0xd73d0000), SPH_C32(0xb01c159f), SPH_C32(0xcf9e9b5a), + SPH_C32(0xd25cc5ca), SPH_C32(0xebbc06c5), SPH_C32(0x371f00c0), + SPH_C32(0x6b0e0000), SPH_C32(0xb7d50000), SPH_C32(0x6ba50000), + SPH_C32(0x5ff71f0b), SPH_C32(0x070a6a19), SPH_C32(0x8c51e2f1), + SPH_C32(0xb6d737e7) }, + { SPH_C32(0x6baf01d0), SPH_C32(0xfa300000), SPH_C32(0xf3cc0000), + SPH_C32(0xe3290000), SPH_C32(0x392b6b13), SPH_C32(0x9515777f), + SPH_C32(0xd99f08d4), SPH_C32(0x248b730e), SPH_C32(0xc3730090), + SPH_C32(0xfd160000), SPH_C32(0xa3700000), SPH_C32(0x68ba0000), + SPH_C32(0x1d6361b3), SPH_C32(0x61b51400), SPH_C32(0x10f59223), + SPH_C32(0x3ce32293) }, + { SPH_C32(0xb4370060), SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), + SPH_C32(0x5cae0000), SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), + SPH_C32(0x1b365f3d), SPH_C32(0xf3d45758), SPH_C32(0x5cb00110), + SPH_C32(0x913e0000), SPH_C32(0x44190000), SPH_C32(0x888c0000), + SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), SPH_C32(0x55ceea25), + SPH_C32(0x925c44e9) }, + { SPH_C32(0xc3730090), SPH_C32(0xfd160000), SPH_C32(0xa3700000), + SPH_C32(0x68ba0000), SPH_C32(0x1d6361b3), SPH_C32(0x61b51400), + SPH_C32(0x10f59223), SPH_C32(0x3ce32293), SPH_C32(0xa8dc0140), + SPH_C32(0x07260000), SPH_C32(0x50bc0000), SPH_C32(0x8b930000), + SPH_C32(0x24480aa0), SPH_C32(0xf4a0637f), SPH_C32(0xc96a9af7), + SPH_C32(0x1868519d) }, + { SPH_C32(0x405b0030), SPH_C32(0x9a540000), SPH_C32(0x42670000), + SPH_C32(0x5fb10000), SPH_C32(0xd6c06187), SPH_C32(0x5d81863c), + SPH_C32(0x87922fef), SPH_C32(0x79e0422c), SPH_C32(0xdf9801b0), + SPH_C32(0xf67c0000), SPH_C32(0xa50e0000), SPH_C32(0xbf870000), + SPH_C32(0xad7f742c), SPH_C32(0xae2b8f5a), SPH_C32(0xc2a957e9), + SPH_C32(0xd75f2456) }, + { SPH_C32(0x371f00c0), SPH_C32(0x6b0e0000), SPH_C32(0xb7d50000), + SPH_C32(0x6ba50000), SPH_C32(0x5ff71f0b), SPH_C32(0x070a6a19), + SPH_C32(0x8c51e2f1), SPH_C32(0xb6d737e7), SPH_C32(0x2bf401e0), + SPH_C32(0x60640000), SPH_C32(0xb1ab0000), SPH_C32(0xbc980000), + SPH_C32(0xefeb0a94), SPH_C32(0xc894f143), SPH_C32(0x5e0d273b), + SPH_C32(0x5d6b3122) }, + { SPH_C32(0x5cb00110), SPH_C32(0x913e0000), SPH_C32(0x44190000), + SPH_C32(0x888c0000), SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), + SPH_C32(0x55ceea25), SPH_C32(0x925c44e9), SPH_C32(0xe8870170), + SPH_C32(0x9d720000), SPH_C32(0x12db0000), SPH_C32(0xd4220000), + SPH_C32(0xf2886b27), SPH_C32(0xa921e543), SPH_C32(0x4ef8b518), + SPH_C32(0x618813b1) }, + { SPH_C32(0x2bf401e0), SPH_C32(0x60640000), SPH_C32(0xb1ab0000), + SPH_C32(0xbc980000), SPH_C32(0xefeb0a94), SPH_C32(0xc894f143), + SPH_C32(0x5e0d273b), SPH_C32(0x5d6b3122), SPH_C32(0x1ceb0120), + SPH_C32(0x0b6a0000), SPH_C32(0x067e0000), SPH_C32(0xd73d0000), + SPH_C32(0xb01c159f), SPH_C32(0xcf9e9b5a), SPH_C32(0xd25cc5ca), + SPH_C32(0xebbc06c5) }, + { SPH_C32(0xa8dc0140), SPH_C32(0x07260000), SPH_C32(0x50bc0000), + SPH_C32(0x8b930000), SPH_C32(0x24480aa0), SPH_C32(0xf4a0637f), + SPH_C32(0xc96a9af7), SPH_C32(0x1868519d), SPH_C32(0x6baf01d0), + SPH_C32(0xfa300000), SPH_C32(0xf3cc0000), SPH_C32(0xe3290000), + SPH_C32(0x392b6b13), SPH_C32(0x9515777f), SPH_C32(0xd99f08d4), + SPH_C32(0x248b730e) }, + { SPH_C32(0xdf9801b0), SPH_C32(0xf67c0000), SPH_C32(0xa50e0000), + SPH_C32(0xbf870000), SPH_C32(0xad7f742c), SPH_C32(0xae2b8f5a), + SPH_C32(0xc2a957e9), SPH_C32(0xd75f2456), SPH_C32(0x9fc30180), + SPH_C32(0x6c280000), SPH_C32(0xe7690000), SPH_C32(0xe0360000), + SPH_C32(0x7bbf15ab), SPH_C32(0xf3aa0966), SPH_C32(0x453b7806), + SPH_C32(0xaebf667a) }, + { SPH_C32(0xef0b0270), SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), + SPH_C32(0x69490000), SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), + SPH_C32(0x66140a51), SPH_C32(0x924f5d0a), SPH_C32(0xc96b0030), + SPH_C32(0xe7250000), SPH_C32(0x2f840000), SPH_C32(0x264f0000), + SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), SPH_C32(0x509f6984), + SPH_C32(0x9e69af68) }, + { SPH_C32(0x984f0280), SPH_C32(0xcba70000), SPH_C32(0xa81c0000), + SPH_C32(0x5d5d0000), SPH_C32(0x1238428a), SPH_C32(0x1e8e59dc), + SPH_C32(0x6dd7c74f), SPH_C32(0x5d7828c1), SPH_C32(0x3d070060), + SPH_C32(0x713d0000), SPH_C32(0x3b210000), SPH_C32(0x25500000), + SPH_C32(0x4afd2541), SPH_C32(0x0b438f2e), SPH_C32(0xcc3b1956), + SPH_C32(0x145dba1c) }, + { SPH_C32(0x1b670220), SPH_C32(0xace50000), SPH_C32(0x490b0000), + SPH_C32(0x6a560000), SPH_C32(0xd99b42be), SPH_C32(0x22bacbe0), + SPH_C32(0xfab07a83), SPH_C32(0x187b487e), SPH_C32(0x4a430090), + SPH_C32(0x80670000), SPH_C32(0xce930000), SPH_C32(0x11440000), + SPH_C32(0xc3ca5bcd), SPH_C32(0x51c8630b), SPH_C32(0xc7f8d448), + SPH_C32(0xdb6acfd7) }, + { SPH_C32(0x6c2302d0), SPH_C32(0x5dbf0000), SPH_C32(0xbcb90000), + SPH_C32(0x5e420000), SPH_C32(0x50ac3c32), SPH_C32(0x783127c5), + SPH_C32(0xf173b79d), SPH_C32(0xd74c3db5), SPH_C32(0xbe2f00c0), + SPH_C32(0x167f0000), SPH_C32(0xda360000), SPH_C32(0x125b0000), + SPH_C32(0x815e2575), SPH_C32(0x37771d12), SPH_C32(0x5b5ca49a), + SPH_C32(0x515edaa3) }, + { SPH_C32(0x078c0300), SPH_C32(0xa78f0000), SPH_C32(0x4f750000), + SPH_C32(0xbd6b0000), SPH_C32(0x69875721), SPH_C32(0xed2450ba), + SPH_C32(0x28ecbf49), SPH_C32(0xf3c74ebb), SPH_C32(0x7d5c0050), + SPH_C32(0xeb690000), SPH_C32(0x79460000), SPH_C32(0x7ae10000), + SPH_C32(0x9c3d44c6), SPH_C32(0x56c20912), SPH_C32(0x4ba936b9), + SPH_C32(0x6dbdf830) }, + { SPH_C32(0x70c803f0), SPH_C32(0x56d50000), SPH_C32(0xbac70000), + SPH_C32(0x897f0000), SPH_C32(0xe0b029ad), SPH_C32(0xb7afbc9f), + SPH_C32(0x232f7257), SPH_C32(0x3cf03b70), SPH_C32(0x89300000), + SPH_C32(0x7d710000), SPH_C32(0x6de30000), SPH_C32(0x79fe0000), + SPH_C32(0xdea93a7e), SPH_C32(0x307d770b), SPH_C32(0xd70d466b), + SPH_C32(0xe789ed44) }, + { SPH_C32(0xf3e00350), SPH_C32(0x31970000), SPH_C32(0x5bd00000), + SPH_C32(0xbe740000), SPH_C32(0x2b132999), SPH_C32(0x8b9b2ea3), + SPH_C32(0xb448cf9b), SPH_C32(0x79f35bcf), SPH_C32(0xfe7400f0), + SPH_C32(0x8c2b0000), SPH_C32(0x98510000), SPH_C32(0x4dea0000), + SPH_C32(0x579e44f2), SPH_C32(0x6af69b2e), SPH_C32(0xdcce8b75), + SPH_C32(0x28be988f) }, + { SPH_C32(0x84a403a0), SPH_C32(0xc0cd0000), SPH_C32(0xae620000), + SPH_C32(0x8a600000), SPH_C32(0xa2245715), SPH_C32(0xd110c286), + SPH_C32(0xbf8b0285), SPH_C32(0xb6c42e04), SPH_C32(0x0a1800a0), + SPH_C32(0x1a330000), SPH_C32(0x8cf40000), SPH_C32(0x4ef50000), + SPH_C32(0x150a3a4a), SPH_C32(0x0c49e537), SPH_C32(0x406afba7), + SPH_C32(0xa28a8dfb) }, + { SPH_C32(0x5b3c0210), SPH_C32(0x36b10000), SPH_C32(0x0b6c0000), + SPH_C32(0x35e70000), SPH_C32(0x0f5b2339), SPH_C32(0x7f3b4ddc), + SPH_C32(0x7d22556c), SPH_C32(0x619b0a52), SPH_C32(0x95db0120), + SPH_C32(0x761b0000), SPH_C32(0x6b9d0000), SPH_C32(0xaec30000), + SPH_C32(0x6eb52fe1), SPH_C32(0xffe3ec51), SPH_C32(0x055183a1), + SPH_C32(0x0c35eb81) }, + { SPH_C32(0x2c7802e0), SPH_C32(0xc7eb0000), SPH_C32(0xfede0000), + SPH_C32(0x01f30000), SPH_C32(0x866c5db5), SPH_C32(0x25b0a1f9), + SPH_C32(0x76e19872), SPH_C32(0xaeac7f99), SPH_C32(0x61b70170), + SPH_C32(0xe0030000), SPH_C32(0x7f380000), SPH_C32(0xaddc0000), + SPH_C32(0x2c215159), SPH_C32(0x995c9248), SPH_C32(0x99f5f373), + SPH_C32(0x8601fef5) }, + { SPH_C32(0xaf500240), SPH_C32(0xa0a90000), SPH_C32(0x1fc90000), + SPH_C32(0x36f80000), SPH_C32(0x4dcf5d81), SPH_C32(0x198433c5), + SPH_C32(0xe18625be), SPH_C32(0xebaf1f26), SPH_C32(0x16f30180), + SPH_C32(0x11590000), SPH_C32(0x8a8a0000), SPH_C32(0x99c80000), + SPH_C32(0xa5162fd5), SPH_C32(0xc3d77e6d), SPH_C32(0x92363e6d), + SPH_C32(0x49368b3e) }, + { SPH_C32(0xd81402b0), SPH_C32(0x51f30000), SPH_C32(0xea7b0000), + SPH_C32(0x02ec0000), SPH_C32(0xc4f8230d), SPH_C32(0x430fdfe0), + SPH_C32(0xea45e8a0), SPH_C32(0x24986aed), SPH_C32(0xe29f01d0), + SPH_C32(0x87410000), SPH_C32(0x9e2f0000), SPH_C32(0x9ad70000), + SPH_C32(0xe782516d), SPH_C32(0xa5680074), SPH_C32(0x0e924ebf), + SPH_C32(0xc3029e4a) }, + { SPH_C32(0xb3bb0360), SPH_C32(0xabc30000), SPH_C32(0x19b70000), + SPH_C32(0xe1c50000), SPH_C32(0xfdd3481e), SPH_C32(0xd61aa89f), + SPH_C32(0x33dae074), SPH_C32(0x001319e3), SPH_C32(0x21ec0140), + SPH_C32(0x7a570000), SPH_C32(0x3d5f0000), SPH_C32(0xf26d0000), + SPH_C32(0xfae130de), SPH_C32(0xc4dd1474), SPH_C32(0x1e67dc9c), + SPH_C32(0xffe1bcd9) }, + { SPH_C32(0xc4ff0390), SPH_C32(0x5a990000), SPH_C32(0xec050000), + SPH_C32(0xd5d10000), SPH_C32(0x74e43692), SPH_C32(0x8c9144ba), + SPH_C32(0x38192d6a), SPH_C32(0xcf246c28), SPH_C32(0xd5800110), + SPH_C32(0xec4f0000), SPH_C32(0x29fa0000), SPH_C32(0xf1720000), + SPH_C32(0xb8754e66), SPH_C32(0xa2626a6d), SPH_C32(0x82c3ac4e), + SPH_C32(0x75d5a9ad) }, + { SPH_C32(0x47d70330), SPH_C32(0x3ddb0000), SPH_C32(0x0d120000), + SPH_C32(0xe2da0000), SPH_C32(0xbf4736a6), SPH_C32(0xb0a5d686), + SPH_C32(0xaf7e90a6), SPH_C32(0x8a270c97), SPH_C32(0xa2c401e0), + SPH_C32(0x1d150000), SPH_C32(0xdc480000), SPH_C32(0xc5660000), + SPH_C32(0x314230ea), SPH_C32(0xf8e98648), SPH_C32(0x89006150), + SPH_C32(0xbae2dc66) }, + { SPH_C32(0x309303c0), SPH_C32(0xcc810000), SPH_C32(0xf8a00000), + SPH_C32(0xd6ce0000), SPH_C32(0x3670482a), SPH_C32(0xea2e3aa3), + SPH_C32(0xa4bd5db8), SPH_C32(0x4510795c), SPH_C32(0x56a801b0), + SPH_C32(0x8b0d0000), SPH_C32(0xc8ed0000), SPH_C32(0xc6790000), + SPH_C32(0x73d64e52), SPH_C32(0x9e56f851), SPH_C32(0x15a41182), + SPH_C32(0x30d6c912) }, + { SPH_C32(0xc96b0030), SPH_C32(0xe7250000), SPH_C32(0x2f840000), + SPH_C32(0x264f0000), SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), + SPH_C32(0x509f6984), SPH_C32(0x9e69af68), SPH_C32(0x26600240), + SPH_C32(0xddd80000), SPH_C32(0x722a0000), SPH_C32(0x4f060000), + SPH_C32(0x936667ff), SPH_C32(0x29f944ce), SPH_C32(0x368b63d5), + SPH_C32(0x0c26f262) }, + { SPH_C32(0xbe2f00c0), SPH_C32(0x167f0000), SPH_C32(0xda360000), + SPH_C32(0x125b0000), SPH_C32(0x815e2575), SPH_C32(0x37771d12), + SPH_C32(0x5b5ca49a), SPH_C32(0x515edaa3), SPH_C32(0xd20c0210), + SPH_C32(0x4bc00000), SPH_C32(0x668f0000), SPH_C32(0x4c190000), + SPH_C32(0xd1f21947), SPH_C32(0x4f463ad7), SPH_C32(0xaa2f1307), + SPH_C32(0x8612e716) }, + { SPH_C32(0x3d070060), SPH_C32(0x713d0000), SPH_C32(0x3b210000), + SPH_C32(0x25500000), SPH_C32(0x4afd2541), SPH_C32(0x0b438f2e), + SPH_C32(0xcc3b1956), SPH_C32(0x145dba1c), SPH_C32(0xa54802e0), + SPH_C32(0xba9a0000), SPH_C32(0x933d0000), SPH_C32(0x780d0000), + SPH_C32(0x58c567cb), SPH_C32(0x15cdd6f2), SPH_C32(0xa1ecde19), + SPH_C32(0x492592dd) }, + { SPH_C32(0x4a430090), SPH_C32(0x80670000), SPH_C32(0xce930000), + SPH_C32(0x11440000), SPH_C32(0xc3ca5bcd), SPH_C32(0x51c8630b), + SPH_C32(0xc7f8d448), SPH_C32(0xdb6acfd7), SPH_C32(0x512402b0), + SPH_C32(0x2c820000), SPH_C32(0x87980000), SPH_C32(0x7b120000), + SPH_C32(0x1a511973), SPH_C32(0x7372a8eb), SPH_C32(0x3d48aecb), + SPH_C32(0xc31187a9) }, + { SPH_C32(0x21ec0140), SPH_C32(0x7a570000), SPH_C32(0x3d5f0000), + SPH_C32(0xf26d0000), SPH_C32(0xfae130de), SPH_C32(0xc4dd1474), + SPH_C32(0x1e67dc9c), SPH_C32(0xffe1bcd9), SPH_C32(0x92570220), + SPH_C32(0xd1940000), SPH_C32(0x24e80000), SPH_C32(0x13a80000), + SPH_C32(0x073278c0), SPH_C32(0x12c7bceb), SPH_C32(0x2dbd3ce8), + SPH_C32(0xfff2a53a) }, + { SPH_C32(0x56a801b0), SPH_C32(0x8b0d0000), SPH_C32(0xc8ed0000), + SPH_C32(0xc6790000), SPH_C32(0x73d64e52), SPH_C32(0x9e56f851), + SPH_C32(0x15a41182), SPH_C32(0x30d6c912), SPH_C32(0x663b0270), + SPH_C32(0x478c0000), SPH_C32(0x304d0000), SPH_C32(0x10b70000), + SPH_C32(0x45a60678), SPH_C32(0x7478c2f2), SPH_C32(0xb1194c3a), + SPH_C32(0x75c6b04e) }, + { SPH_C32(0xd5800110), SPH_C32(0xec4f0000), SPH_C32(0x29fa0000), + SPH_C32(0xf1720000), SPH_C32(0xb8754e66), SPH_C32(0xa2626a6d), + SPH_C32(0x82c3ac4e), SPH_C32(0x75d5a9ad), SPH_C32(0x117f0280), + SPH_C32(0xb6d60000), SPH_C32(0xc5ff0000), SPH_C32(0x24a30000), + SPH_C32(0xcc9178f4), SPH_C32(0x2ef32ed7), SPH_C32(0xbada8124), + SPH_C32(0xbaf1c585) }, + { SPH_C32(0xa2c401e0), SPH_C32(0x1d150000), SPH_C32(0xdc480000), + SPH_C32(0xc5660000), SPH_C32(0x314230ea), SPH_C32(0xf8e98648), + SPH_C32(0x89006150), SPH_C32(0xbae2dc66), SPH_C32(0xe51302d0), + SPH_C32(0x20ce0000), SPH_C32(0xd15a0000), SPH_C32(0x27bc0000), + SPH_C32(0x8e05064c), SPH_C32(0x484c50ce), SPH_C32(0x267ef1f6), + SPH_C32(0x30c5d0f1) }, + { SPH_C32(0x7d5c0050), SPH_C32(0xeb690000), SPH_C32(0x79460000), + SPH_C32(0x7ae10000), SPH_C32(0x9c3d44c6), SPH_C32(0x56c20912), + SPH_C32(0x4ba936b9), SPH_C32(0x6dbdf830), SPH_C32(0x7ad00350), + SPH_C32(0x4ce60000), SPH_C32(0x36330000), SPH_C32(0xc78a0000), + SPH_C32(0xf5ba13e7), SPH_C32(0xbbe659a8), SPH_C32(0x634589f0), + SPH_C32(0x9e7ab68b) }, + { SPH_C32(0x0a1800a0), SPH_C32(0x1a330000), SPH_C32(0x8cf40000), + SPH_C32(0x4ef50000), SPH_C32(0x150a3a4a), SPH_C32(0x0c49e537), + SPH_C32(0x406afba7), SPH_C32(0xa28a8dfb), SPH_C32(0x8ebc0300), + SPH_C32(0xdafe0000), SPH_C32(0x22960000), SPH_C32(0xc4950000), + SPH_C32(0xb72e6d5f), SPH_C32(0xdd5927b1), SPH_C32(0xffe1f922), + SPH_C32(0x144ea3ff) }, + { SPH_C32(0x89300000), SPH_C32(0x7d710000), SPH_C32(0x6de30000), + SPH_C32(0x79fe0000), SPH_C32(0xdea93a7e), SPH_C32(0x307d770b), + SPH_C32(0xd70d466b), SPH_C32(0xe789ed44), SPH_C32(0xf9f803f0), + SPH_C32(0x2ba40000), SPH_C32(0xd7240000), SPH_C32(0xf0810000), + SPH_C32(0x3e1913d3), SPH_C32(0x87d2cb94), SPH_C32(0xf422343c), + SPH_C32(0xdb79d634) }, + { SPH_C32(0xfe7400f0), SPH_C32(0x8c2b0000), SPH_C32(0x98510000), + SPH_C32(0x4dea0000), SPH_C32(0x579e44f2), SPH_C32(0x6af69b2e), + SPH_C32(0xdcce8b75), SPH_C32(0x28be988f), SPH_C32(0x0d9403a0), + SPH_C32(0xbdbc0000), SPH_C32(0xc3810000), SPH_C32(0xf39e0000), + SPH_C32(0x7c8d6d6b), SPH_C32(0xe16db58d), SPH_C32(0x688644ee), + SPH_C32(0x514dc340) }, + { SPH_C32(0x95db0120), SPH_C32(0x761b0000), SPH_C32(0x6b9d0000), + SPH_C32(0xaec30000), SPH_C32(0x6eb52fe1), SPH_C32(0xffe3ec51), + SPH_C32(0x055183a1), SPH_C32(0x0c35eb81), SPH_C32(0xcee70330), + SPH_C32(0x40aa0000), SPH_C32(0x60f10000), SPH_C32(0x9b240000), + SPH_C32(0x61ee0cd8), SPH_C32(0x80d8a18d), SPH_C32(0x7873d6cd), + SPH_C32(0x6daee1d3) }, + { SPH_C32(0xe29f01d0), SPH_C32(0x87410000), SPH_C32(0x9e2f0000), + SPH_C32(0x9ad70000), SPH_C32(0xe782516d), SPH_C32(0xa5680074), + SPH_C32(0x0e924ebf), SPH_C32(0xc3029e4a), SPH_C32(0x3a8b0360), + SPH_C32(0xd6b20000), SPH_C32(0x74540000), SPH_C32(0x983b0000), + SPH_C32(0x237a7260), SPH_C32(0xe667df94), SPH_C32(0xe4d7a61f), + SPH_C32(0xe79af4a7) }, + { SPH_C32(0x61b70170), SPH_C32(0xe0030000), SPH_C32(0x7f380000), + SPH_C32(0xaddc0000), SPH_C32(0x2c215159), SPH_C32(0x995c9248), + SPH_C32(0x99f5f373), SPH_C32(0x8601fef5), SPH_C32(0x4dcf0390), + SPH_C32(0x27e80000), SPH_C32(0x81e60000), SPH_C32(0xac2f0000), + SPH_C32(0xaa4d0cec), SPH_C32(0xbcec33b1), SPH_C32(0xef146b01), + SPH_C32(0x28ad816c) }, + { SPH_C32(0x16f30180), SPH_C32(0x11590000), SPH_C32(0x8a8a0000), + SPH_C32(0x99c80000), SPH_C32(0xa5162fd5), SPH_C32(0xc3d77e6d), + SPH_C32(0x92363e6d), SPH_C32(0x49368b3e), SPH_C32(0xb9a303c0), + SPH_C32(0xb1f00000), SPH_C32(0x95430000), SPH_C32(0xaf300000), + SPH_C32(0xe8d97254), SPH_C32(0xda534da8), SPH_C32(0x73b01bd3), + SPH_C32(0xa2999418) }, + { SPH_C32(0x26600240), SPH_C32(0xddd80000), SPH_C32(0x722a0000), + SPH_C32(0x4f060000), SPH_C32(0x936667ff), SPH_C32(0x29f944ce), + SPH_C32(0x368b63d5), SPH_C32(0x0c26f262), SPH_C32(0xef0b0270), + SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), SPH_C32(0x69490000), + SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), SPH_C32(0x66140a51), + SPH_C32(0x924f5d0a) }, + { SPH_C32(0x512402b0), SPH_C32(0x2c820000), SPH_C32(0x87980000), + SPH_C32(0x7b120000), SPH_C32(0x1a511973), SPH_C32(0x7372a8eb), + SPH_C32(0x3d48aecb), SPH_C32(0xc31187a9), SPH_C32(0x1b670220), + SPH_C32(0xace50000), SPH_C32(0x490b0000), SPH_C32(0x6a560000), + SPH_C32(0xd99b42be), SPH_C32(0x22bacbe0), SPH_C32(0xfab07a83), + SPH_C32(0x187b487e) }, + { SPH_C32(0xd20c0210), SPH_C32(0x4bc00000), SPH_C32(0x668f0000), + SPH_C32(0x4c190000), SPH_C32(0xd1f21947), SPH_C32(0x4f463ad7), + SPH_C32(0xaa2f1307), SPH_C32(0x8612e716), SPH_C32(0x6c2302d0), + SPH_C32(0x5dbf0000), SPH_C32(0xbcb90000), SPH_C32(0x5e420000), + SPH_C32(0x50ac3c32), SPH_C32(0x783127c5), SPH_C32(0xf173b79d), + SPH_C32(0xd74c3db5) }, + { SPH_C32(0xa54802e0), SPH_C32(0xba9a0000), SPH_C32(0x933d0000), + SPH_C32(0x780d0000), SPH_C32(0x58c567cb), SPH_C32(0x15cdd6f2), + SPH_C32(0xa1ecde19), SPH_C32(0x492592dd), SPH_C32(0x984f0280), + SPH_C32(0xcba70000), SPH_C32(0xa81c0000), SPH_C32(0x5d5d0000), + SPH_C32(0x1238428a), SPH_C32(0x1e8e59dc), SPH_C32(0x6dd7c74f), + SPH_C32(0x5d7828c1) }, + { SPH_C32(0xcee70330), SPH_C32(0x40aa0000), SPH_C32(0x60f10000), + SPH_C32(0x9b240000), SPH_C32(0x61ee0cd8), SPH_C32(0x80d8a18d), + SPH_C32(0x7873d6cd), SPH_C32(0x6daee1d3), SPH_C32(0x5b3c0210), + SPH_C32(0x36b10000), SPH_C32(0x0b6c0000), SPH_C32(0x35e70000), + SPH_C32(0x0f5b2339), SPH_C32(0x7f3b4ddc), SPH_C32(0x7d22556c), + SPH_C32(0x619b0a52) }, + { SPH_C32(0xb9a303c0), SPH_C32(0xb1f00000), SPH_C32(0x95430000), + SPH_C32(0xaf300000), SPH_C32(0xe8d97254), SPH_C32(0xda534da8), + SPH_C32(0x73b01bd3), SPH_C32(0xa2999418), SPH_C32(0xaf500240), + SPH_C32(0xa0a90000), SPH_C32(0x1fc90000), SPH_C32(0x36f80000), + SPH_C32(0x4dcf5d81), SPH_C32(0x198433c5), SPH_C32(0xe18625be), + SPH_C32(0xebaf1f26) }, + { SPH_C32(0x3a8b0360), SPH_C32(0xd6b20000), SPH_C32(0x74540000), + SPH_C32(0x983b0000), SPH_C32(0x237a7260), SPH_C32(0xe667df94), + SPH_C32(0xe4d7a61f), SPH_C32(0xe79af4a7), SPH_C32(0xd81402b0), + SPH_C32(0x51f30000), SPH_C32(0xea7b0000), SPH_C32(0x02ec0000), + SPH_C32(0xc4f8230d), SPH_C32(0x430fdfe0), SPH_C32(0xea45e8a0), + SPH_C32(0x24986aed) }, + { SPH_C32(0x4dcf0390), SPH_C32(0x27e80000), SPH_C32(0x81e60000), + SPH_C32(0xac2f0000), SPH_C32(0xaa4d0cec), SPH_C32(0xbcec33b1), + SPH_C32(0xef146b01), SPH_C32(0x28ad816c), SPH_C32(0x2c7802e0), + SPH_C32(0xc7eb0000), SPH_C32(0xfede0000), SPH_C32(0x01f30000), + SPH_C32(0x866c5db5), SPH_C32(0x25b0a1f9), SPH_C32(0x76e19872), + SPH_C32(0xaeac7f99) }, + { SPH_C32(0x92570220), SPH_C32(0xd1940000), SPH_C32(0x24e80000), + SPH_C32(0x13a80000), SPH_C32(0x073278c0), SPH_C32(0x12c7bceb), + SPH_C32(0x2dbd3ce8), SPH_C32(0xfff2a53a), SPH_C32(0xb3bb0360), + SPH_C32(0xabc30000), SPH_C32(0x19b70000), SPH_C32(0xe1c50000), + SPH_C32(0xfdd3481e), SPH_C32(0xd61aa89f), SPH_C32(0x33dae074), + SPH_C32(0x001319e3) }, + { SPH_C32(0xe51302d0), SPH_C32(0x20ce0000), SPH_C32(0xd15a0000), + SPH_C32(0x27bc0000), SPH_C32(0x8e05064c), SPH_C32(0x484c50ce), + SPH_C32(0x267ef1f6), SPH_C32(0x30c5d0f1), SPH_C32(0x47d70330), + SPH_C32(0x3ddb0000), SPH_C32(0x0d120000), SPH_C32(0xe2da0000), + SPH_C32(0xbf4736a6), SPH_C32(0xb0a5d686), SPH_C32(0xaf7e90a6), + SPH_C32(0x8a270c97) }, + { SPH_C32(0x663b0270), SPH_C32(0x478c0000), SPH_C32(0x304d0000), + SPH_C32(0x10b70000), SPH_C32(0x45a60678), SPH_C32(0x7478c2f2), + SPH_C32(0xb1194c3a), SPH_C32(0x75c6b04e), SPH_C32(0x309303c0), + SPH_C32(0xcc810000), SPH_C32(0xf8a00000), SPH_C32(0xd6ce0000), + SPH_C32(0x3670482a), SPH_C32(0xea2e3aa3), SPH_C32(0xa4bd5db8), + SPH_C32(0x4510795c) }, + { SPH_C32(0x117f0280), SPH_C32(0xb6d60000), SPH_C32(0xc5ff0000), + SPH_C32(0x24a30000), SPH_C32(0xcc9178f4), SPH_C32(0x2ef32ed7), + SPH_C32(0xbada8124), SPH_C32(0xbaf1c585), SPH_C32(0xc4ff0390), + SPH_C32(0x5a990000), SPH_C32(0xec050000), SPH_C32(0xd5d10000), + SPH_C32(0x74e43692), SPH_C32(0x8c9144ba), SPH_C32(0x38192d6a), + SPH_C32(0xcf246c28) }, + { SPH_C32(0x7ad00350), SPH_C32(0x4ce60000), SPH_C32(0x36330000), + SPH_C32(0xc78a0000), SPH_C32(0xf5ba13e7), SPH_C32(0xbbe659a8), + SPH_C32(0x634589f0), SPH_C32(0x9e7ab68b), SPH_C32(0x078c0300), + SPH_C32(0xa78f0000), SPH_C32(0x4f750000), SPH_C32(0xbd6b0000), + SPH_C32(0x69875721), SPH_C32(0xed2450ba), SPH_C32(0x28ecbf49), + SPH_C32(0xf3c74ebb) }, + { SPH_C32(0x0d9403a0), SPH_C32(0xbdbc0000), SPH_C32(0xc3810000), + SPH_C32(0xf39e0000), SPH_C32(0x7c8d6d6b), SPH_C32(0xe16db58d), + SPH_C32(0x688644ee), SPH_C32(0x514dc340), SPH_C32(0xf3e00350), + SPH_C32(0x31970000), SPH_C32(0x5bd00000), SPH_C32(0xbe740000), + SPH_C32(0x2b132999), SPH_C32(0x8b9b2ea3), SPH_C32(0xb448cf9b), + SPH_C32(0x79f35bcf) }, + { SPH_C32(0x8ebc0300), SPH_C32(0xdafe0000), SPH_C32(0x22960000), + SPH_C32(0xc4950000), SPH_C32(0xb72e6d5f), SPH_C32(0xdd5927b1), + SPH_C32(0xffe1f922), SPH_C32(0x144ea3ff), SPH_C32(0x84a403a0), + SPH_C32(0xc0cd0000), SPH_C32(0xae620000), SPH_C32(0x8a600000), + SPH_C32(0xa2245715), SPH_C32(0xd110c286), SPH_C32(0xbf8b0285), + SPH_C32(0xb6c42e04) }, + { SPH_C32(0xf9f803f0), SPH_C32(0x2ba40000), SPH_C32(0xd7240000), + SPH_C32(0xf0810000), SPH_C32(0x3e1913d3), SPH_C32(0x87d2cb94), + SPH_C32(0xf422343c), SPH_C32(0xdb79d634), SPH_C32(0x70c803f0), + SPH_C32(0x56d50000), SPH_C32(0xbac70000), SPH_C32(0x897f0000), + SPH_C32(0xe0b029ad), SPH_C32(0xb7afbc9f), SPH_C32(0x232f7257), + SPH_C32(0x3cf03b70) } +}; + +static const sph_u32 T512_12[64][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x75c90003), SPH_C32(0x0e10c000), SPH_C32(0xd1200000), + SPH_C32(0xbaea0000), SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), + SPH_C32(0xbb28761d), SPH_C32(0x00b72e2b), SPH_C32(0xeecf0001), + SPH_C32(0x6f564000), SPH_C32(0xf33e0000), SPH_C32(0xa79e0000), + SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), SPH_C32(0x4a3b40ba), + SPH_C32(0xfeabf254) }, + { SPH_C32(0xeecf0001), SPH_C32(0x6f564000), SPH_C32(0xf33e0000), + SPH_C32(0xa79e0000), SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), + SPH_C32(0x4a3b40ba), SPH_C32(0xfeabf254), SPH_C32(0x9b060002), + SPH_C32(0x61468000), SPH_C32(0x221e0000), SPH_C32(0x1d740000), + SPH_C32(0x36715d27), SPH_C32(0x30495c92), SPH_C32(0xf11336a7), + SPH_C32(0xfe1cdc7f) }, + { SPH_C32(0x9b060002), SPH_C32(0x61468000), SPH_C32(0x221e0000), + SPH_C32(0x1d740000), SPH_C32(0x36715d27), SPH_C32(0x30495c92), + SPH_C32(0xf11336a7), SPH_C32(0xfe1cdc7f), SPH_C32(0x75c90003), + SPH_C32(0x0e10c000), SPH_C32(0xd1200000), SPH_C32(0xbaea0000), + SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), SPH_C32(0xbb28761d), + SPH_C32(0x00b72e2b) }, + { SPH_C32(0xf6800005), SPH_C32(0x3443c000), SPH_C32(0x24070000), + SPH_C32(0x8f3d0000), SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), + SPH_C32(0xcdc58b19), SPH_C32(0xd795ba31), SPH_C32(0xa67f0001), + SPH_C32(0x71378000), SPH_C32(0x19fc0000), SPH_C32(0x96db0000), + SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), SPH_C32(0x2c6d478f), + SPH_C32(0xac8e6c88) }, + { SPH_C32(0x83490006), SPH_C32(0x3a530000), SPH_C32(0xf5270000), + SPH_C32(0x35d70000), SPH_C32(0xaaf314c5), SPH_C32(0x8de062f9), + SPH_C32(0x76edfd04), SPH_C32(0xd722941a), SPH_C32(0x48b00000), + SPH_C32(0x1e61c000), SPH_C32(0xeac20000), SPH_C32(0x31450000), + SPH_C32(0x873e1fe4), SPH_C32(0x5cdb4536), SPH_C32(0x66560735), + SPH_C32(0x52259edc) }, + { SPH_C32(0x184f0004), SPH_C32(0x5b158000), SPH_C32(0xd7390000), + SPH_C32(0x28a30000), SPH_C32(0x9c8249e2), SPH_C32(0xbda93e6b), + SPH_C32(0x87fecba3), SPH_C32(0x293e4865), SPH_C32(0x3d790003), + SPH_C32(0x10710000), SPH_C32(0x3be20000), SPH_C32(0x8baf0000), + SPH_C32(0x0cfa30da), SPH_C32(0xdb83f261), SPH_C32(0xdd7e7128), + SPH_C32(0x5292b0f7) }, + { SPH_C32(0x6d860007), SPH_C32(0x55054000), SPH_C32(0x06190000), + SPH_C32(0x92490000), SPH_C32(0x174666dc), SPH_C32(0x3af1893c), + SPH_C32(0x3cd6bdbe), SPH_C32(0x2989664e), SPH_C32(0xd3b60002), + SPH_C32(0x7f274000), SPH_C32(0xc8dc0000), SPH_C32(0x2c310000), + SPH_C32(0xb14f42c3), SPH_C32(0x6c9219a4), SPH_C32(0x97453192), + SPH_C32(0xac3942a3) }, + { SPH_C32(0xa67f0001), SPH_C32(0x71378000), SPH_C32(0x19fc0000), + SPH_C32(0x96db0000), SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), + SPH_C32(0x2c6d478f), SPH_C32(0xac8e6c88), SPH_C32(0x50ff0004), + SPH_C32(0x45744000), SPH_C32(0x3dfb0000), SPH_C32(0x19e60000), + SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), SPH_C32(0xe1a8cc96), + SPH_C32(0x7b1bd6b9) }, + { SPH_C32(0xd3b60002), SPH_C32(0x7f274000), SPH_C32(0xc8dc0000), + SPH_C32(0x2c310000), SPH_C32(0xb14f42c3), SPH_C32(0x6c9219a4), + SPH_C32(0x97453192), SPH_C32(0xac3942a3), SPH_C32(0xbe300005), + SPH_C32(0x2a220000), SPH_C32(0xcec50000), SPH_C32(0xbe780000), + SPH_C32(0xa609241f), SPH_C32(0x56639098), SPH_C32(0xab938c2c), + SPH_C32(0x85b024ed) }, + { SPH_C32(0x48b00000), SPH_C32(0x1e61c000), SPH_C32(0xeac20000), + SPH_C32(0x31450000), SPH_C32(0x873e1fe4), SPH_C32(0x5cdb4536), + SPH_C32(0x66560735), SPH_C32(0x52259edc), SPH_C32(0xcbf90006), + SPH_C32(0x2432c000), SPH_C32(0x1fe50000), SPH_C32(0x04920000), + SPH_C32(0x2dcd0b21), SPH_C32(0xd13b27cf), SPH_C32(0x10bbfa31), + SPH_C32(0x85070ac6) }, + { SPH_C32(0x3d790003), SPH_C32(0x10710000), SPH_C32(0x3be20000), + SPH_C32(0x8baf0000), SPH_C32(0x0cfa30da), SPH_C32(0xdb83f261), + SPH_C32(0xdd7e7128), SPH_C32(0x5292b0f7), SPH_C32(0x25360007), + SPH_C32(0x4b648000), SPH_C32(0xecdb0000), SPH_C32(0xa30c0000), + SPH_C32(0x90787938), SPH_C32(0x662acc0a), SPH_C32(0x5a80ba8b), + SPH_C32(0x7bacf892) }, + { SPH_C32(0x50ff0004), SPH_C32(0x45744000), SPH_C32(0x3dfb0000), + SPH_C32(0x19e60000), SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), + SPH_C32(0xe1a8cc96), SPH_C32(0x7b1bd6b9), SPH_C32(0xf6800005), + SPH_C32(0x3443c000), SPH_C32(0x24070000), SPH_C32(0x8f3d0000), + SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), SPH_C32(0xcdc58b19), + SPH_C32(0xd795ba31) }, + { SPH_C32(0x25360007), SPH_C32(0x4b648000), SPH_C32(0xecdb0000), + SPH_C32(0xa30c0000), SPH_C32(0x90787938), SPH_C32(0x662acc0a), + SPH_C32(0x5a80ba8b), SPH_C32(0x7bacf892), SPH_C32(0x184f0004), + SPH_C32(0x5b158000), SPH_C32(0xd7390000), SPH_C32(0x28a30000), + SPH_C32(0x9c8249e2), SPH_C32(0xbda93e6b), SPH_C32(0x87fecba3), + SPH_C32(0x293e4865) }, + { SPH_C32(0xbe300005), SPH_C32(0x2a220000), SPH_C32(0xcec50000), + SPH_C32(0xbe780000), SPH_C32(0xa609241f), SPH_C32(0x56639098), + SPH_C32(0xab938c2c), SPH_C32(0x85b024ed), SPH_C32(0x6d860007), + SPH_C32(0x55054000), SPH_C32(0x06190000), SPH_C32(0x92490000), + SPH_C32(0x174666dc), SPH_C32(0x3af1893c), SPH_C32(0x3cd6bdbe), + SPH_C32(0x2989664e) }, + { SPH_C32(0xcbf90006), SPH_C32(0x2432c000), SPH_C32(0x1fe50000), + SPH_C32(0x04920000), SPH_C32(0x2dcd0b21), SPH_C32(0xd13b27cf), + SPH_C32(0x10bbfa31), SPH_C32(0x85070ac6), SPH_C32(0x83490006), + SPH_C32(0x3a530000), SPH_C32(0xf5270000), SPH_C32(0x35d70000), + SPH_C32(0xaaf314c5), SPH_C32(0x8de062f9), SPH_C32(0x76edfd04), + SPH_C32(0xd722941a) }, + { SPH_C32(0xf7750009), SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), + SPH_C32(0x04920000), SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), + SPH_C32(0x7a87f14e), SPH_C32(0x9e16981a), SPH_C32(0xd46a0000), + SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), SPH_C32(0x4a290000), + SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), SPH_C32(0x98369604), + SPH_C32(0xf746c320) }, + { SPH_C32(0x82bc000a), SPH_C32(0xc12c0000), SPH_C32(0x12f60000), + SPH_C32(0xbe780000), SPH_C32(0x89513697), SPH_C32(0x7fb081ed), + SPH_C32(0xc1af8753), SPH_C32(0x9ea1b631), SPH_C32(0x3aa50001), + SPH_C32(0xe29e8000), SPH_C32(0x56910000), SPH_C32(0xedb70000), + SPH_C32(0x41fb3063), SPH_C32(0x7ea56da9), SPH_C32(0xd20dd6be), + SPH_C32(0x09ed3174) }, + { SPH_C32(0x19ba0008), SPH_C32(0xa06a8000), SPH_C32(0x30e80000), + SPH_C32(0xa30c0000), SPH_C32(0xbf206bb0), SPH_C32(0x4ff9dd7f), + SPH_C32(0x30bcb1f4), SPH_C32(0x60bd6a4e), SPH_C32(0x4f6c0002), + SPH_C32(0xec8e4000), SPH_C32(0x87b10000), SPH_C32(0x575d0000), + SPH_C32(0xca3f1f5d), SPH_C32(0xf9fddafe), SPH_C32(0x6925a0a3), + SPH_C32(0x095a1f5f) }, + { SPH_C32(0x6c73000b), SPH_C32(0xae7a4000), SPH_C32(0xe1c80000), + SPH_C32(0x19e60000), SPH_C32(0x34e4448e), SPH_C32(0xc8a16a28), + SPH_C32(0x8b94c7e9), SPH_C32(0x600a4465), SPH_C32(0xa1a30003), + SPH_C32(0x83d80000), SPH_C32(0x748f0000), SPH_C32(0xf0c30000), + SPH_C32(0x778a6d44), SPH_C32(0x4eec313b), SPH_C32(0x231ee019), + SPH_C32(0xf7f1ed0b) }, + { SPH_C32(0x01f5000c), SPH_C32(0xfb7f0000), SPH_C32(0xe7d10000), + SPH_C32(0x8baf0000), SPH_C32(0x23a22252), SPH_C32(0xf250e314), + SPH_C32(0xb7427a57), SPH_C32(0x4983222b), SPH_C32(0x72150001), + SPH_C32(0xfcff4000), SPH_C32(0xbc530000), SPH_C32(0xdcf20000), + SPH_C32(0xc6c52f87), SPH_C32(0x227e289f), SPH_C32(0xb45bd18b), + SPH_C32(0x5bc8afa8) }, + { SPH_C32(0x743c000f), SPH_C32(0xf56fc000), SPH_C32(0x36f10000), + SPH_C32(0x31450000), SPH_C32(0xa8660d6c), SPH_C32(0x75085443), + SPH_C32(0x0c6a0c4a), SPH_C32(0x49340c00), SPH_C32(0x9cda0000), + SPH_C32(0x93a90000), SPH_C32(0x4f6d0000), SPH_C32(0x7b6c0000), + SPH_C32(0x7b705d9e), SPH_C32(0x956fc35a), SPH_C32(0xfe609131), + SPH_C32(0xa5635dfc) }, + { SPH_C32(0xef3a000d), SPH_C32(0x94294000), SPH_C32(0x14ef0000), + SPH_C32(0x2c310000), SPH_C32(0x9e17504b), SPH_C32(0x454108d1), + SPH_C32(0xfd793aed), SPH_C32(0xb728d07f), SPH_C32(0xe9130003), + SPH_C32(0x9db9c000), SPH_C32(0x9e4d0000), SPH_C32(0xc1860000), + SPH_C32(0xf0b472a0), SPH_C32(0x1237740d), SPH_C32(0x4548e72c), + SPH_C32(0xa5d473d7) }, + { SPH_C32(0x9af3000e), SPH_C32(0x9a398000), SPH_C32(0xc5cf0000), + SPH_C32(0x96db0000), SPH_C32(0x15d37f75), SPH_C32(0xc219bf86), + SPH_C32(0x46514cf0), SPH_C32(0xb79ffe54), SPH_C32(0x07dc0002), + SPH_C32(0xf2ef8000), SPH_C32(0x6d730000), SPH_C32(0x66180000), + SPH_C32(0x4d0100b9), SPH_C32(0xa5269fc8), SPH_C32(0x0f73a796), + SPH_C32(0x5b7f8183) }, + { SPH_C32(0x510a0008), SPH_C32(0xbe0b4000), SPH_C32(0xda2a0000), + SPH_C32(0x92490000), SPH_C32(0x381e7454), SPH_C32(0x13229849), + SPH_C32(0x56eab6c1), SPH_C32(0x3298f492), SPH_C32(0x84950004), + SPH_C32(0xc8bc8000), SPH_C32(0x98540000), SPH_C32(0x53cf0000), + SPH_C32(0xe7f2147c), SPH_C32(0x28c6fd31), SPH_C32(0x799e5a92), + SPH_C32(0x8c5d1599) }, + { SPH_C32(0x24c3000b), SPH_C32(0xb01b8000), SPH_C32(0x0b0a0000), + SPH_C32(0x28a30000), SPH_C32(0xb3da5b6a), SPH_C32(0x947a2f1e), + SPH_C32(0xedc2c0dc), SPH_C32(0x322fdab9), SPH_C32(0x6a5a0005), + SPH_C32(0xa7eac000), SPH_C32(0x6b6a0000), SPH_C32(0xf4510000), + SPH_C32(0x5a476665), SPH_C32(0x9fd716f4), SPH_C32(0x33a51a28), + SPH_C32(0x72f6e7cd) }, + { SPH_C32(0xbfc50009), SPH_C32(0xd15d0000), SPH_C32(0x29140000), + SPH_C32(0x35d70000), SPH_C32(0x85ab064d), SPH_C32(0xa433738c), + SPH_C32(0x1cd1f67b), SPH_C32(0xcc3306c6), SPH_C32(0x1f930006), + SPH_C32(0xa9fa0000), SPH_C32(0xba4a0000), SPH_C32(0x4ebb0000), + SPH_C32(0xd183495b), SPH_C32(0x188fa1a3), SPH_C32(0x888d6c35), + SPH_C32(0x7241c9e6) }, + { SPH_C32(0xca0c000a), SPH_C32(0xdf4dc000), SPH_C32(0xf8340000), + SPH_C32(0x8f3d0000), SPH_C32(0x0e6f2973), SPH_C32(0x236bc4db), + SPH_C32(0xa7f98066), SPH_C32(0xcc8428ed), SPH_C32(0xf15c0007), + SPH_C32(0xc6ac4000), SPH_C32(0x49740000), SPH_C32(0xe9250000), + SPH_C32(0x6c363b42), SPH_C32(0xaf9e4a66), SPH_C32(0xc2b62c8f), + SPH_C32(0x8cea3bb2) }, + { SPH_C32(0xa78a000d), SPH_C32(0x8a488000), SPH_C32(0xfe2d0000), + SPH_C32(0x1d740000), SPH_C32(0x19294faf), SPH_C32(0x199a4de7), + SPH_C32(0x9b2f3dd8), SPH_C32(0xe50d4ea3), SPH_C32(0x22ea0005), + SPH_C32(0xb98b0000), SPH_C32(0x81a80000), SPH_C32(0xc5140000), + SPH_C32(0xdd797981), SPH_C32(0xc30c53c2), SPH_C32(0x55f31d1d), + SPH_C32(0x20d37911) }, + { SPH_C32(0xd243000e), SPH_C32(0x84584000), SPH_C32(0x2f0d0000), + SPH_C32(0xa79e0000), SPH_C32(0x92ed6091), SPH_C32(0x9ec2fab0), + SPH_C32(0x20074bc5), SPH_C32(0xe5ba6088), SPH_C32(0xcc250004), + SPH_C32(0xd6dd4000), SPH_C32(0x72960000), SPH_C32(0x628a0000), + SPH_C32(0x60cc0b98), SPH_C32(0x741db807), SPH_C32(0x1fc85da7), + SPH_C32(0xde788b45) }, + { SPH_C32(0x4945000c), SPH_C32(0xe51ec000), SPH_C32(0x0d130000), + SPH_C32(0xbaea0000), SPH_C32(0xa49c3db6), SPH_C32(0xae8ba622), + SPH_C32(0xd1147d62), SPH_C32(0x1ba6bcf7), SPH_C32(0xb9ec0007), + SPH_C32(0xd8cd8000), SPH_C32(0xa3b60000), SPH_C32(0xd8600000), + SPH_C32(0xeb0824a6), SPH_C32(0xf3450f50), SPH_C32(0xa4e02bba), + SPH_C32(0xdecfa56e) }, + { SPH_C32(0x3c8c000f), SPH_C32(0xeb0e0000), SPH_C32(0xdc330000), + SPH_C32(0x00000000), SPH_C32(0x2f581288), SPH_C32(0x29d31175), + SPH_C32(0x6a3c0b7f), SPH_C32(0x1b1192dc), SPH_C32(0x57230006), + SPH_C32(0xb79bc000), SPH_C32(0x50880000), SPH_C32(0x7ffe0000), + SPH_C32(0x56bd56bf), SPH_C32(0x4454e495), SPH_C32(0xeedb6b00), + SPH_C32(0x2064573a) }, + { SPH_C32(0xd46a0000), SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), + SPH_C32(0x4a290000), SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), + SPH_C32(0x98369604), SPH_C32(0xf746c320), SPH_C32(0x231f0009), + SPH_C32(0x42f40000), SPH_C32(0x66790000), SPH_C32(0x4ebb0000), + SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), SPH_C32(0xe2b1674a), + SPH_C32(0x69505b3a) }, + { SPH_C32(0xa1a30003), SPH_C32(0x83d80000), SPH_C32(0x748f0000), + SPH_C32(0xf0c30000), SPH_C32(0x778a6d44), SPH_C32(0x4eec313b), + SPH_C32(0x231ee019), SPH_C32(0xf7f1ed0b), SPH_C32(0xcdd00008), + SPH_C32(0x2da24000), SPH_C32(0x95470000), SPH_C32(0xe9250000), + SPH_C32(0x436e29ca), SPH_C32(0x864d5b13), SPH_C32(0xa88a27f0), + SPH_C32(0x97fba96e) }, + { SPH_C32(0x3aa50001), SPH_C32(0xe29e8000), SPH_C32(0x56910000), + SPH_C32(0xedb70000), SPH_C32(0x41fb3063), SPH_C32(0x7ea56da9), + SPH_C32(0xd20dd6be), SPH_C32(0x09ed3174), SPH_C32(0xb819000b), + SPH_C32(0x23b28000), SPH_C32(0x44670000), SPH_C32(0x53cf0000), + SPH_C32(0xc8aa06f4), SPH_C32(0x0115ec44), SPH_C32(0x13a251ed), + SPH_C32(0x974c8745) }, + { SPH_C32(0x4f6c0002), SPH_C32(0xec8e4000), SPH_C32(0x87b10000), + SPH_C32(0x575d0000), SPH_C32(0xca3f1f5d), SPH_C32(0xf9fddafe), + SPH_C32(0x6925a0a3), SPH_C32(0x095a1f5f), SPH_C32(0x56d6000a), + SPH_C32(0x4ce4c000), SPH_C32(0xb7590000), SPH_C32(0xf4510000), + SPH_C32(0x751f74ed), SPH_C32(0xb6040781), SPH_C32(0x59991157), + SPH_C32(0x69e77511) }, + { SPH_C32(0x22ea0005), SPH_C32(0xb98b0000), SPH_C32(0x81a80000), + SPH_C32(0xc5140000), SPH_C32(0xdd797981), SPH_C32(0xc30c53c2), + SPH_C32(0x55f31d1d), SPH_C32(0x20d37911), SPH_C32(0x85600008), + SPH_C32(0x33c38000), SPH_C32(0x7f850000), SPH_C32(0xd8600000), + SPH_C32(0xc450362e), SPH_C32(0xda961e25), SPH_C32(0xcedc20c5), + SPH_C32(0xc5de37b2) }, + { SPH_C32(0x57230006), SPH_C32(0xb79bc000), SPH_C32(0x50880000), + SPH_C32(0x7ffe0000), SPH_C32(0x56bd56bf), SPH_C32(0x4454e495), + SPH_C32(0xeedb6b00), SPH_C32(0x2064573a), SPH_C32(0x6baf0009), + SPH_C32(0x5c95c000), SPH_C32(0x8cbb0000), SPH_C32(0x7ffe0000), + SPH_C32(0x79e54437), SPH_C32(0x6d87f5e0), SPH_C32(0x84e7607f), + SPH_C32(0x3b75c5e6) }, + { SPH_C32(0xcc250004), SPH_C32(0xd6dd4000), SPH_C32(0x72960000), + SPH_C32(0x628a0000), SPH_C32(0x60cc0b98), SPH_C32(0x741db807), + SPH_C32(0x1fc85da7), SPH_C32(0xde788b45), SPH_C32(0x1e66000a), + SPH_C32(0x52850000), SPH_C32(0x5d9b0000), SPH_C32(0xc5140000), + SPH_C32(0xf2216b09), SPH_C32(0xeadf42b7), SPH_C32(0x3fcf1662), + SPH_C32(0x3bc2ebcd) }, + { SPH_C32(0xb9ec0007), SPH_C32(0xd8cd8000), SPH_C32(0xa3b60000), + SPH_C32(0xd8600000), SPH_C32(0xeb0824a6), SPH_C32(0xf3450f50), + SPH_C32(0xa4e02bba), SPH_C32(0xdecfa56e), SPH_C32(0xf0a9000b), + SPH_C32(0x3dd34000), SPH_C32(0xaea50000), SPH_C32(0x628a0000), + SPH_C32(0x4f941910), SPH_C32(0x5dcea972), SPH_C32(0x75f456d8), + SPH_C32(0xc5691999) }, + { SPH_C32(0x72150001), SPH_C32(0xfcff4000), SPH_C32(0xbc530000), + SPH_C32(0xdcf20000), SPH_C32(0xc6c52f87), SPH_C32(0x227e289f), + SPH_C32(0xb45bd18b), SPH_C32(0x5bc8afa8), SPH_C32(0x73e0000d), + SPH_C32(0x07804000), SPH_C32(0x5b820000), SPH_C32(0x575d0000), + SPH_C32(0xe5670dd5), SPH_C32(0xd02ecb8b), SPH_C32(0x0319abdc), + SPH_C32(0x124b8d83) }, + { SPH_C32(0x07dc0002), SPH_C32(0xf2ef8000), SPH_C32(0x6d730000), + SPH_C32(0x66180000), SPH_C32(0x4d0100b9), SPH_C32(0xa5269fc8), + SPH_C32(0x0f73a796), SPH_C32(0x5b7f8183), SPH_C32(0x9d2f000c), + SPH_C32(0x68d60000), SPH_C32(0xa8bc0000), SPH_C32(0xf0c30000), + SPH_C32(0x58d27fcc), SPH_C32(0x673f204e), SPH_C32(0x4922eb66), + SPH_C32(0xece07fd7) }, + { SPH_C32(0x9cda0000), SPH_C32(0x93a90000), SPH_C32(0x4f6d0000), + SPH_C32(0x7b6c0000), SPH_C32(0x7b705d9e), SPH_C32(0x956fc35a), + SPH_C32(0xfe609131), SPH_C32(0xa5635dfc), SPH_C32(0xe8e6000f), + SPH_C32(0x66c6c000), SPH_C32(0x799c0000), SPH_C32(0x4a290000), + SPH_C32(0xd31650f2), SPH_C32(0xe0679719), SPH_C32(0xf20a9d7b), + SPH_C32(0xec5751fc) }, + { SPH_C32(0xe9130003), SPH_C32(0x9db9c000), SPH_C32(0x9e4d0000), + SPH_C32(0xc1860000), SPH_C32(0xf0b472a0), SPH_C32(0x1237740d), + SPH_C32(0x4548e72c), SPH_C32(0xa5d473d7), SPH_C32(0x0629000e), + SPH_C32(0x09908000), SPH_C32(0x8aa20000), SPH_C32(0xedb70000), + SPH_C32(0x6ea322eb), SPH_C32(0x57767cdc), SPH_C32(0xb831ddc1), + SPH_C32(0x12fca3a8) }, + { SPH_C32(0x84950004), SPH_C32(0xc8bc8000), SPH_C32(0x98540000), + SPH_C32(0x53cf0000), SPH_C32(0xe7f2147c), SPH_C32(0x28c6fd31), + SPH_C32(0x799e5a92), SPH_C32(0x8c5d1599), SPH_C32(0xd59f000c), + SPH_C32(0x76b7c000), SPH_C32(0x427e0000), SPH_C32(0xc1860000), + SPH_C32(0xdfec6028), SPH_C32(0x3be46578), SPH_C32(0x2f74ec53), + SPH_C32(0xbec5e10b) }, + { SPH_C32(0xf15c0007), SPH_C32(0xc6ac4000), SPH_C32(0x49740000), + SPH_C32(0xe9250000), SPH_C32(0x6c363b42), SPH_C32(0xaf9e4a66), + SPH_C32(0xc2b62c8f), SPH_C32(0x8cea3bb2), SPH_C32(0x3b50000d), + SPH_C32(0x19e18000), SPH_C32(0xb1400000), SPH_C32(0x66180000), + SPH_C32(0x62591231), SPH_C32(0x8cf58ebd), SPH_C32(0x654face9), + SPH_C32(0x406e135f) }, + { SPH_C32(0x6a5a0005), SPH_C32(0xa7eac000), SPH_C32(0x6b6a0000), + SPH_C32(0xf4510000), SPH_C32(0x5a476665), SPH_C32(0x9fd716f4), + SPH_C32(0x33a51a28), SPH_C32(0x72f6e7cd), SPH_C32(0x4e99000e), + SPH_C32(0x17f14000), SPH_C32(0x60600000), SPH_C32(0xdcf20000), + SPH_C32(0xe99d3d0f), SPH_C32(0x0bad39ea), SPH_C32(0xde67daf4), + SPH_C32(0x40d93d74) }, + { SPH_C32(0x1f930006), SPH_C32(0xa9fa0000), SPH_C32(0xba4a0000), + SPH_C32(0x4ebb0000), SPH_C32(0xd183495b), SPH_C32(0x188fa1a3), + SPH_C32(0x888d6c35), SPH_C32(0x7241c9e6), SPH_C32(0xa056000f), + SPH_C32(0x78a70000), SPH_C32(0x935e0000), SPH_C32(0x7b6c0000), + SPH_C32(0x54284f16), SPH_C32(0xbcbcd22f), SPH_C32(0x945c9a4e), + SPH_C32(0xbe72cf20) }, + { SPH_C32(0x231f0009), SPH_C32(0x42f40000), SPH_C32(0x66790000), + SPH_C32(0x4ebb0000), SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), + SPH_C32(0xe2b1674a), SPH_C32(0x69505b3a), SPH_C32(0xf7750009), + SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), SPH_C32(0x04920000), + SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), SPH_C32(0x7a87f14e), + SPH_C32(0x9e16981a) }, + { SPH_C32(0x56d6000a), SPH_C32(0x4ce4c000), SPH_C32(0xb7590000), + SPH_C32(0xf4510000), SPH_C32(0x751f74ed), SPH_C32(0xb6040781), + SPH_C32(0x59991157), SPH_C32(0x69e77511), SPH_C32(0x19ba0008), + SPH_C32(0xa06a8000), SPH_C32(0x30e80000), SPH_C32(0xa30c0000), + SPH_C32(0xbf206bb0), SPH_C32(0x4ff9dd7f), SPH_C32(0x30bcb1f4), + SPH_C32(0x60bd6a4e) }, + { SPH_C32(0xcdd00008), SPH_C32(0x2da24000), SPH_C32(0x95470000), + SPH_C32(0xe9250000), SPH_C32(0x436e29ca), SPH_C32(0x864d5b13), + SPH_C32(0xa88a27f0), SPH_C32(0x97fba96e), SPH_C32(0x6c73000b), + SPH_C32(0xae7a4000), SPH_C32(0xe1c80000), SPH_C32(0x19e60000), + SPH_C32(0x34e4448e), SPH_C32(0xc8a16a28), SPH_C32(0x8b94c7e9), + SPH_C32(0x600a4465) }, + { SPH_C32(0xb819000b), SPH_C32(0x23b28000), SPH_C32(0x44670000), + SPH_C32(0x53cf0000), SPH_C32(0xc8aa06f4), SPH_C32(0x0115ec44), + SPH_C32(0x13a251ed), SPH_C32(0x974c8745), SPH_C32(0x82bc000a), + SPH_C32(0xc12c0000), SPH_C32(0x12f60000), SPH_C32(0xbe780000), + SPH_C32(0x89513697), SPH_C32(0x7fb081ed), SPH_C32(0xc1af8753), + SPH_C32(0x9ea1b631) }, + { SPH_C32(0xd59f000c), SPH_C32(0x76b7c000), SPH_C32(0x427e0000), + SPH_C32(0xc1860000), SPH_C32(0xdfec6028), SPH_C32(0x3be46578), + SPH_C32(0x2f74ec53), SPH_C32(0xbec5e10b), SPH_C32(0x510a0008), + SPH_C32(0xbe0b4000), SPH_C32(0xda2a0000), SPH_C32(0x92490000), + SPH_C32(0x381e7454), SPH_C32(0x13229849), SPH_C32(0x56eab6c1), + SPH_C32(0x3298f492) }, + { SPH_C32(0xa056000f), SPH_C32(0x78a70000), SPH_C32(0x935e0000), + SPH_C32(0x7b6c0000), SPH_C32(0x54284f16), SPH_C32(0xbcbcd22f), + SPH_C32(0x945c9a4e), SPH_C32(0xbe72cf20), SPH_C32(0xbfc50009), + SPH_C32(0xd15d0000), SPH_C32(0x29140000), SPH_C32(0x35d70000), + SPH_C32(0x85ab064d), SPH_C32(0xa433738c), SPH_C32(0x1cd1f67b), + SPH_C32(0xcc3306c6) }, + { SPH_C32(0x3b50000d), SPH_C32(0x19e18000), SPH_C32(0xb1400000), + SPH_C32(0x66180000), SPH_C32(0x62591231), SPH_C32(0x8cf58ebd), + SPH_C32(0x654face9), SPH_C32(0x406e135f), SPH_C32(0xca0c000a), + SPH_C32(0xdf4dc000), SPH_C32(0xf8340000), SPH_C32(0x8f3d0000), + SPH_C32(0x0e6f2973), SPH_C32(0x236bc4db), SPH_C32(0xa7f98066), + SPH_C32(0xcc8428ed) }, + { SPH_C32(0x4e99000e), SPH_C32(0x17f14000), SPH_C32(0x60600000), + SPH_C32(0xdcf20000), SPH_C32(0xe99d3d0f), SPH_C32(0x0bad39ea), + SPH_C32(0xde67daf4), SPH_C32(0x40d93d74), SPH_C32(0x24c3000b), + SPH_C32(0xb01b8000), SPH_C32(0x0b0a0000), SPH_C32(0x28a30000), + SPH_C32(0xb3da5b6a), SPH_C32(0x947a2f1e), SPH_C32(0xedc2c0dc), + SPH_C32(0x322fdab9) }, + { SPH_C32(0x85600008), SPH_C32(0x33c38000), SPH_C32(0x7f850000), + SPH_C32(0xd8600000), SPH_C32(0xc450362e), SPH_C32(0xda961e25), + SPH_C32(0xcedc20c5), SPH_C32(0xc5de37b2), SPH_C32(0xa78a000d), + SPH_C32(0x8a488000), SPH_C32(0xfe2d0000), SPH_C32(0x1d740000), + SPH_C32(0x19294faf), SPH_C32(0x199a4de7), SPH_C32(0x9b2f3dd8), + SPH_C32(0xe50d4ea3) }, + { SPH_C32(0xf0a9000b), SPH_C32(0x3dd34000), SPH_C32(0xaea50000), + SPH_C32(0x628a0000), SPH_C32(0x4f941910), SPH_C32(0x5dcea972), + SPH_C32(0x75f456d8), SPH_C32(0xc5691999), SPH_C32(0x4945000c), + SPH_C32(0xe51ec000), SPH_C32(0x0d130000), SPH_C32(0xbaea0000), + SPH_C32(0xa49c3db6), SPH_C32(0xae8ba622), SPH_C32(0xd1147d62), + SPH_C32(0x1ba6bcf7) }, + { SPH_C32(0x6baf0009), SPH_C32(0x5c95c000), SPH_C32(0x8cbb0000), + SPH_C32(0x7ffe0000), SPH_C32(0x79e54437), SPH_C32(0x6d87f5e0), + SPH_C32(0x84e7607f), SPH_C32(0x3b75c5e6), SPH_C32(0x3c8c000f), + SPH_C32(0xeb0e0000), SPH_C32(0xdc330000), SPH_C32(0x00000000), + SPH_C32(0x2f581288), SPH_C32(0x29d31175), SPH_C32(0x6a3c0b7f), + SPH_C32(0x1b1192dc) }, + { SPH_C32(0x1e66000a), SPH_C32(0x52850000), SPH_C32(0x5d9b0000), + SPH_C32(0xc5140000), SPH_C32(0xf2216b09), SPH_C32(0xeadf42b7), + SPH_C32(0x3fcf1662), SPH_C32(0x3bc2ebcd), SPH_C32(0xd243000e), + SPH_C32(0x84584000), SPH_C32(0x2f0d0000), SPH_C32(0xa79e0000), + SPH_C32(0x92ed6091), SPH_C32(0x9ec2fab0), SPH_C32(0x20074bc5), + SPH_C32(0xe5ba6088) }, + { SPH_C32(0x73e0000d), SPH_C32(0x07804000), SPH_C32(0x5b820000), + SPH_C32(0x575d0000), SPH_C32(0xe5670dd5), SPH_C32(0xd02ecb8b), + SPH_C32(0x0319abdc), SPH_C32(0x124b8d83), SPH_C32(0x01f5000c), + SPH_C32(0xfb7f0000), SPH_C32(0xe7d10000), SPH_C32(0x8baf0000), + SPH_C32(0x23a22252), SPH_C32(0xf250e314), SPH_C32(0xb7427a57), + SPH_C32(0x4983222b) }, + { SPH_C32(0x0629000e), SPH_C32(0x09908000), SPH_C32(0x8aa20000), + SPH_C32(0xedb70000), SPH_C32(0x6ea322eb), SPH_C32(0x57767cdc), + SPH_C32(0xb831ddc1), SPH_C32(0x12fca3a8), SPH_C32(0xef3a000d), + SPH_C32(0x94294000), SPH_C32(0x14ef0000), SPH_C32(0x2c310000), + SPH_C32(0x9e17504b), SPH_C32(0x454108d1), SPH_C32(0xfd793aed), + SPH_C32(0xb728d07f) }, + { SPH_C32(0x9d2f000c), SPH_C32(0x68d60000), SPH_C32(0xa8bc0000), + SPH_C32(0xf0c30000), SPH_C32(0x58d27fcc), SPH_C32(0x673f204e), + SPH_C32(0x4922eb66), SPH_C32(0xece07fd7), SPH_C32(0x9af3000e), + SPH_C32(0x9a398000), SPH_C32(0xc5cf0000), SPH_C32(0x96db0000), + SPH_C32(0x15d37f75), SPH_C32(0xc219bf86), SPH_C32(0x46514cf0), + SPH_C32(0xb79ffe54) }, + { SPH_C32(0xe8e6000f), SPH_C32(0x66c6c000), SPH_C32(0x799c0000), + SPH_C32(0x4a290000), SPH_C32(0xd31650f2), SPH_C32(0xe0679719), + SPH_C32(0xf20a9d7b), SPH_C32(0xec5751fc), SPH_C32(0x743c000f), + SPH_C32(0xf56fc000), SPH_C32(0x36f10000), SPH_C32(0x31450000), + SPH_C32(0xa8660d6c), SPH_C32(0x75085443), SPH_C32(0x0c6a0c4a), + SPH_C32(0x49340c00) } +}; + +static const sph_u32 T512_18[64][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x0c720000), SPH_C32(0x49e50f00), SPH_C32(0x42790000), + SPH_C32(0x5cea0000), SPH_C32(0x33aa301a), SPH_C32(0x15822514), + SPH_C32(0x95a34b7b), SPH_C32(0xb44b0090), SPH_C32(0xfe220000), + SPH_C32(0xa7580500), SPH_C32(0x25d10000), SPH_C32(0xf7600000), + SPH_C32(0x893178da), SPH_C32(0x1fd4f860), SPH_C32(0x4ed0a315), + SPH_C32(0xa123ff9f) }, + { SPH_C32(0xfe220000), SPH_C32(0xa7580500), SPH_C32(0x25d10000), + SPH_C32(0xf7600000), SPH_C32(0x893178da), SPH_C32(0x1fd4f860), + SPH_C32(0x4ed0a315), SPH_C32(0xa123ff9f), SPH_C32(0xf2500000), + SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), SPH_C32(0xab8a0000), + SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), SPH_C32(0xdb73e86e), + SPH_C32(0x1568ff0f) }, + { SPH_C32(0xf2500000), SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), + SPH_C32(0xab8a0000), SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), + SPH_C32(0xdb73e86e), SPH_C32(0x1568ff0f), SPH_C32(0x0c720000), + SPH_C32(0x49e50f00), SPH_C32(0x42790000), SPH_C32(0x5cea0000), + SPH_C32(0x33aa301a), SPH_C32(0x15822514), SPH_C32(0x95a34b7b), + SPH_C32(0xb44b0090) }, + { SPH_C32(0x45180000), SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), + SPH_C32(0x3b480000), SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), + SPH_C32(0x16bca6b0), SPH_C32(0xdf33f4df), SPH_C32(0xb83d0000), + SPH_C32(0x16710600), SPH_C32(0x379a0000), SPH_C32(0xf5b10000), + SPH_C32(0x228161ac), SPH_C32(0xae48f145), SPH_C32(0x66241616), + SPH_C32(0xc5c1eb3e) }, + { SPH_C32(0x496a0000), SPH_C32(0xec501800), SPH_C32(0xbb130000), + SPH_C32(0x67a20000), SPH_C32(0x2d662436), SPH_C32(0x3691b0c2), + SPH_C32(0x831fedcb), SPH_C32(0x6b78f44f), SPH_C32(0x461f0000), + SPH_C32(0xb1290300), SPH_C32(0x124b0000), SPH_C32(0x02d10000), + SPH_C32(0xabb01976), SPH_C32(0xb19c0925), SPH_C32(0x28f4b503), + SPH_C32(0x64e214a1) }, + { SPH_C32(0xbb3a0000), SPH_C32(0x02ed1200), SPH_C32(0xdcbb0000), + SPH_C32(0xcc280000), SPH_C32(0x97fd6cf6), SPH_C32(0x3cc76db6), + SPH_C32(0x586c05a5), SPH_C32(0x7e100b40), SPH_C32(0x4a6d0000), + SPH_C32(0xf8cc0c00), SPH_C32(0x50320000), SPH_C32(0x5e3b0000), + SPH_C32(0x981a296c), SPH_C32(0xa41e2c31), SPH_C32(0xbd57fe78), + SPH_C32(0xd0a91431) }, + { SPH_C32(0xb7480000), SPH_C32(0x4b081d00), SPH_C32(0x9ec20000), + SPH_C32(0x90c20000), SPH_C32(0xa4575cec), SPH_C32(0x294548a2), + SPH_C32(0xcdcf4ede), SPH_C32(0xca5b0bd0), SPH_C32(0xb44f0000), + SPH_C32(0x5f940900), SPH_C32(0x75e30000), SPH_C32(0xa95b0000), + SPH_C32(0x112b51b6), SPH_C32(0xbbcad451), SPH_C32(0xf3875d6d), + SPH_C32(0x718aebae) }, + { SPH_C32(0xb83d0000), SPH_C32(0x16710600), SPH_C32(0x379a0000), + SPH_C32(0xf5b10000), SPH_C32(0x228161ac), SPH_C32(0xae48f145), + SPH_C32(0x66241616), SPH_C32(0xc5c1eb3e), SPH_C32(0xfd250000), + SPH_C32(0xb3c41100), SPH_C32(0xcef00000), SPH_C32(0xcef90000), + SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), SPH_C32(0x7098b0a6), + SPH_C32(0x1af21fe1) }, + { SPH_C32(0xb44f0000), SPH_C32(0x5f940900), SPH_C32(0x75e30000), + SPH_C32(0xa95b0000), SPH_C32(0x112b51b6), SPH_C32(0xbbcad451), + SPH_C32(0xf3875d6d), SPH_C32(0x718aebae), SPH_C32(0x03070000), + SPH_C32(0x149c1400), SPH_C32(0xeb210000), SPH_C32(0x39990000), + SPH_C32(0xb57c0d5a), SPH_C32(0x928f9cf3), SPH_C32(0x3e4813b3), + SPH_C32(0xbbd1e07e) }, + { SPH_C32(0x461f0000), SPH_C32(0xb1290300), SPH_C32(0x124b0000), + SPH_C32(0x02d10000), SPH_C32(0xabb01976), SPH_C32(0xb19c0925), + SPH_C32(0x28f4b503), SPH_C32(0x64e214a1), SPH_C32(0x0f750000), + SPH_C32(0x5d791b00), SPH_C32(0xa9580000), SPH_C32(0x65730000), + SPH_C32(0x86d63d40), SPH_C32(0x870db9e7), SPH_C32(0xabeb58c8), + SPH_C32(0x0f9ae0ee) }, + { SPH_C32(0x4a6d0000), SPH_C32(0xf8cc0c00), SPH_C32(0x50320000), + SPH_C32(0x5e3b0000), SPH_C32(0x981a296c), SPH_C32(0xa41e2c31), + SPH_C32(0xbd57fe78), SPH_C32(0xd0a91431), SPH_C32(0xf1570000), + SPH_C32(0xfa211e00), SPH_C32(0x8c890000), SPH_C32(0x92130000), + SPH_C32(0x0fe7459a), SPH_C32(0x98d94187), SPH_C32(0xe53bfbdd), + SPH_C32(0xaeb91f71) }, + { SPH_C32(0xfd250000), SPH_C32(0xb3c41100), SPH_C32(0xcef00000), + SPH_C32(0xcef90000), SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), + SPH_C32(0x7098b0a6), SPH_C32(0x1af21fe1), SPH_C32(0x45180000), + SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), SPH_C32(0x3b480000), + SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), SPH_C32(0x16bca6b0), + SPH_C32(0xdf33f4df) }, + { SPH_C32(0xf1570000), SPH_C32(0xfa211e00), SPH_C32(0x8c890000), + SPH_C32(0x92130000), SPH_C32(0x0fe7459a), SPH_C32(0x98d94187), + SPH_C32(0xe53bfbdd), SPH_C32(0xaeb91f71), SPH_C32(0xbb3a0000), + SPH_C32(0x02ed1200), SPH_C32(0xdcbb0000), SPH_C32(0xcc280000), + SPH_C32(0x97fd6cf6), SPH_C32(0x3cc76db6), SPH_C32(0x586c05a5), + SPH_C32(0x7e100b40) }, + { SPH_C32(0x03070000), SPH_C32(0x149c1400), SPH_C32(0xeb210000), + SPH_C32(0x39990000), SPH_C32(0xb57c0d5a), SPH_C32(0x928f9cf3), + SPH_C32(0x3e4813b3), SPH_C32(0xbbd1e07e), SPH_C32(0xb7480000), + SPH_C32(0x4b081d00), SPH_C32(0x9ec20000), SPH_C32(0x90c20000), + SPH_C32(0xa4575cec), SPH_C32(0x294548a2), SPH_C32(0xcdcf4ede), + SPH_C32(0xca5b0bd0) }, + { SPH_C32(0x0f750000), SPH_C32(0x5d791b00), SPH_C32(0xa9580000), + SPH_C32(0x65730000), SPH_C32(0x86d63d40), SPH_C32(0x870db9e7), + SPH_C32(0xabeb58c8), SPH_C32(0x0f9ae0ee), SPH_C32(0x496a0000), + SPH_C32(0xec501800), SPH_C32(0xbb130000), SPH_C32(0x67a20000), + SPH_C32(0x2d662436), SPH_C32(0x3691b0c2), SPH_C32(0x831fedcb), + SPH_C32(0x6b78f44f) }, + { SPH_C32(0x75a40000), SPH_C32(0xc28b2700), SPH_C32(0x94a40000), + SPH_C32(0x90f50000), SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), + SPH_C32(0x1767c483), SPH_C32(0xaedf667e), SPH_C32(0xd1660000), + SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), SPH_C32(0xf6940000), + SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), SPH_C32(0xb4431b17), + SPH_C32(0x857f3c2b) }, + { SPH_C32(0x79d60000), SPH_C32(0x8b6e2800), SPH_C32(0xd6dd0000), + SPH_C32(0xcc1f0000), SPH_C32(0xc8d267fa), SPH_C32(0x5c4c2eba), + SPH_C32(0x82c48ff8), SPH_C32(0x1a9466ee), SPH_C32(0x2f440000), + SPH_C32(0xbce40600), SPH_C32(0xbb3d0000), SPH_C32(0x01f40000), + SPH_C32(0x8a333dfd), SPH_C32(0xd0a40492), SPH_C32(0xfa93b802), + SPH_C32(0x245cc3b4) }, + { SPH_C32(0x8b860000), SPH_C32(0x65d32200), SPH_C32(0xb1750000), + SPH_C32(0x67950000), SPH_C32(0x72492f3a), SPH_C32(0x561af3ce), + SPH_C32(0x59b76796), SPH_C32(0x0ffc99e1), SPH_C32(0x23360000), + SPH_C32(0xf5010900), SPH_C32(0xf9440000), SPH_C32(0x5d1e0000), + SPH_C32(0xb9990de7), SPH_C32(0xc5262186), SPH_C32(0x6f30f379), + SPH_C32(0x9017c324) }, + { SPH_C32(0x87f40000), SPH_C32(0x2c362d00), SPH_C32(0xf30c0000), + SPH_C32(0x3b7f0000), SPH_C32(0x41e31f20), SPH_C32(0x4398d6da), + SPH_C32(0xcc142ced), SPH_C32(0xbbb79971), SPH_C32(0xdd140000), + SPH_C32(0x52590c00), SPH_C32(0xdc950000), SPH_C32(0xaa7e0000), + SPH_C32(0x30a8753d), SPH_C32(0xdaf2d9e6), SPH_C32(0x21e0506c), + SPH_C32(0x31343cbb) }, + { SPH_C32(0x30bc0000), SPH_C32(0x673e3000), SPH_C32(0x6dce0000), + SPH_C32(0xabbd0000), SPH_C32(0xe5b443cc), SPH_C32(0x6add9e78), + SPH_C32(0x01db6233), SPH_C32(0x71ec92a1), SPH_C32(0x695b0000), + SPH_C32(0x0dcd0500), SPH_C32(0xa9760000), SPH_C32(0x03250000), + SPH_C32(0x2183248b), SPH_C32(0x61380db7), SPH_C32(0xd2670d01), + SPH_C32(0x40bed715) }, + { SPH_C32(0x3cce0000), SPH_C32(0x2edb3f00), SPH_C32(0x2fb70000), + SPH_C32(0xf7570000), SPH_C32(0xd61e73d6), SPH_C32(0x7f5fbb6c), + SPH_C32(0x94782948), SPH_C32(0xc5a79231), SPH_C32(0x97790000), + SPH_C32(0xaa950000), SPH_C32(0x8ca70000), SPH_C32(0xf4450000), + SPH_C32(0xa8b25c51), SPH_C32(0x7eecf5d7), SPH_C32(0x9cb7ae14), + SPH_C32(0xe19d288a) }, + { SPH_C32(0xce9e0000), SPH_C32(0xc0663500), SPH_C32(0x481f0000), + SPH_C32(0x5cdd0000), SPH_C32(0x6c853b16), SPH_C32(0x75096618), + SPH_C32(0x4f0bc126), SPH_C32(0xd0cf6d3e), SPH_C32(0x9b0b0000), + SPH_C32(0xe3700f00), SPH_C32(0xcede0000), SPH_C32(0xa8af0000), + SPH_C32(0x9b186c4b), SPH_C32(0x6b6ed0c3), SPH_C32(0x0914e56f), + SPH_C32(0x55d6281a) }, + { SPH_C32(0xc2ec0000), SPH_C32(0x89833a00), SPH_C32(0x0a660000), + SPH_C32(0x00370000), SPH_C32(0x5f2f0b0c), SPH_C32(0x608b430c), + SPH_C32(0xdaa88a5d), SPH_C32(0x64846dae), SPH_C32(0x65290000), + SPH_C32(0x44280a00), SPH_C32(0xeb0f0000), SPH_C32(0x5fcf0000), + SPH_C32(0x12291491), SPH_C32(0x74ba28a3), SPH_C32(0x47c4467a), + SPH_C32(0xf4f5d785) }, + { SPH_C32(0xcd990000), SPH_C32(0xd4fa2100), SPH_C32(0xa33e0000), + SPH_C32(0x65440000), SPH_C32(0xd9f9364c), SPH_C32(0xe786faeb), + SPH_C32(0x7143d295), SPH_C32(0x6b1e8d40), SPH_C32(0x2c430000), + SPH_C32(0xa8781200), SPH_C32(0x501c0000), SPH_C32(0x386d0000), + SPH_C32(0x3f4f30a7), SPH_C32(0x422b9861), SPH_C32(0xc4dbabb1), + SPH_C32(0x9f8d23ca) }, + { SPH_C32(0xc1eb0000), SPH_C32(0x9d1f2e00), SPH_C32(0xe1470000), + SPH_C32(0x39ae0000), SPH_C32(0xea530656), SPH_C32(0xf204dfff), + SPH_C32(0xe4e099ee), SPH_C32(0xdf558dd0), SPH_C32(0xd2610000), + SPH_C32(0x0f201700), SPH_C32(0x75cd0000), SPH_C32(0xcf0d0000), + SPH_C32(0xb67e487d), SPH_C32(0x5dff6001), SPH_C32(0x8a0b08a4), + SPH_C32(0x3eaedc55) }, + { SPH_C32(0x33bb0000), SPH_C32(0x73a22400), SPH_C32(0x86ef0000), + SPH_C32(0x92240000), SPH_C32(0x50c84e96), SPH_C32(0xf852028b), + SPH_C32(0x3f937180), SPH_C32(0xca3d72df), SPH_C32(0xde130000), + SPH_C32(0x46c51800), SPH_C32(0x37b40000), SPH_C32(0x93e70000), + SPH_C32(0x85d47867), SPH_C32(0x487d4515), SPH_C32(0x1fa843df), + SPH_C32(0x8ae5dcc5) }, + { SPH_C32(0x3fc90000), SPH_C32(0x3a472b00), SPH_C32(0xc4960000), + SPH_C32(0xcece0000), SPH_C32(0x63627e8c), SPH_C32(0xedd0279f), + SPH_C32(0xaa303afb), SPH_C32(0x7e76724f), SPH_C32(0x20310000), + SPH_C32(0xe19d1d00), SPH_C32(0x12650000), SPH_C32(0x64870000), + SPH_C32(0x0ce500bd), SPH_C32(0x57a9bd75), SPH_C32(0x5178e0ca), + SPH_C32(0x2bc6235a) }, + { SPH_C32(0x88810000), SPH_C32(0x714f3600), SPH_C32(0x5a540000), + SPH_C32(0x5e0c0000), SPH_C32(0xc7352260), SPH_C32(0xc4956f3d), + SPH_C32(0x67ff7425), SPH_C32(0xb42d799f), SPH_C32(0x947e0000), + SPH_C32(0xbe091400), SPH_C32(0x67860000), SPH_C32(0xcddc0000), + SPH_C32(0x1dce510b), SPH_C32(0xec636924), SPH_C32(0xa2ffbda7), + SPH_C32(0x5a4cc8f4) }, + { SPH_C32(0x84f30000), SPH_C32(0x38aa3900), SPH_C32(0x182d0000), + SPH_C32(0x02e60000), SPH_C32(0xf49f127a), SPH_C32(0xd1174a29), + SPH_C32(0xf25c3f5e), SPH_C32(0x0066790f), SPH_C32(0x6a5c0000), + SPH_C32(0x19511100), SPH_C32(0x42570000), SPH_C32(0x3abc0000), + SPH_C32(0x94ff29d1), SPH_C32(0xf3b79144), SPH_C32(0xec2f1eb2), + SPH_C32(0xfb6f376b) }, + { SPH_C32(0x76a30000), SPH_C32(0xd6173300), SPH_C32(0x7f850000), + SPH_C32(0xa96c0000), SPH_C32(0x4e045aba), SPH_C32(0xdb41975d), + SPH_C32(0x292fd730), SPH_C32(0x150e8600), SPH_C32(0x662e0000), + SPH_C32(0x50b41e00), SPH_C32(0x002e0000), SPH_C32(0x66560000), + SPH_C32(0xa75519cb), SPH_C32(0xe635b450), SPH_C32(0x798c55c9), + SPH_C32(0x4f2437fb) }, + { SPH_C32(0x7ad10000), SPH_C32(0x9ff23c00), SPH_C32(0x3dfc0000), + SPH_C32(0xf5860000), SPH_C32(0x7dae6aa0), SPH_C32(0xcec3b249), + SPH_C32(0xbc8c9c4b), SPH_C32(0xa1458690), SPH_C32(0x980c0000), + SPH_C32(0xf7ec1b00), SPH_C32(0x25ff0000), SPH_C32(0x91360000), + SPH_C32(0x2e646111), SPH_C32(0xf9e14c30), SPH_C32(0x375cf6dc), + SPH_C32(0xee07c864) }, + { SPH_C32(0xd1660000), SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), + SPH_C32(0xf6940000), SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), + SPH_C32(0xb4431b17), SPH_C32(0x857f3c2b), SPH_C32(0xa4c20000), + SPH_C32(0xd9372400), SPH_C32(0x0a480000), SPH_C32(0x66610000), + SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), SPH_C32(0xa324df94), + SPH_C32(0x2ba05a55) }, + { SPH_C32(0xdd140000), SPH_C32(0x52590c00), SPH_C32(0xdc950000), + SPH_C32(0xaa7e0000), SPH_C32(0x30a8753d), SPH_C32(0xdaf2d9e6), + SPH_C32(0x21e0506c), SPH_C32(0x31343cbb), SPH_C32(0x5ae00000), + SPH_C32(0x7e6f2100), SPH_C32(0x2f990000), SPH_C32(0x91010000), + SPH_C32(0x714b6a1d), SPH_C32(0x996a0f3c), SPH_C32(0xedf47c81), + SPH_C32(0x8a83a5ca) }, + { SPH_C32(0x2f440000), SPH_C32(0xbce40600), SPH_C32(0xbb3d0000), + SPH_C32(0x01f40000), SPH_C32(0x8a333dfd), SPH_C32(0xd0a40492), + SPH_C32(0xfa93b802), SPH_C32(0x245cc3b4), SPH_C32(0x56920000), + SPH_C32(0x378a2e00), SPH_C32(0x6de00000), SPH_C32(0xcdeb0000), + SPH_C32(0x42e15a07), SPH_C32(0x8ce82a28), SPH_C32(0x785737fa), + SPH_C32(0x3ec8a55a) }, + { SPH_C32(0x23360000), SPH_C32(0xf5010900), SPH_C32(0xf9440000), + SPH_C32(0x5d1e0000), SPH_C32(0xb9990de7), SPH_C32(0xc5262186), + SPH_C32(0x6f30f379), SPH_C32(0x9017c324), SPH_C32(0xa8b00000), + SPH_C32(0x90d22b00), SPH_C32(0x48310000), SPH_C32(0x3a8b0000), + SPH_C32(0xcbd022dd), SPH_C32(0x933cd248), SPH_C32(0x368794ef), + SPH_C32(0x9feb5ac5) }, + { SPH_C32(0x947e0000), SPH_C32(0xbe091400), SPH_C32(0x67860000), + SPH_C32(0xcddc0000), SPH_C32(0x1dce510b), SPH_C32(0xec636924), + SPH_C32(0xa2ffbda7), SPH_C32(0x5a4cc8f4), SPH_C32(0x1cff0000), + SPH_C32(0xcf462200), SPH_C32(0x3dd20000), SPH_C32(0x93d00000), + SPH_C32(0xdafb736b), SPH_C32(0x28f60619), SPH_C32(0xc500c982), + SPH_C32(0xee61b16b) }, + { SPH_C32(0x980c0000), SPH_C32(0xf7ec1b00), SPH_C32(0x25ff0000), + SPH_C32(0x91360000), SPH_C32(0x2e646111), SPH_C32(0xf9e14c30), + SPH_C32(0x375cf6dc), SPH_C32(0xee07c864), SPH_C32(0xe2dd0000), + SPH_C32(0x681e2700), SPH_C32(0x18030000), SPH_C32(0x64b00000), + SPH_C32(0x53ca0bb1), SPH_C32(0x3722fe79), SPH_C32(0x8bd06a97), + SPH_C32(0x4f424ef4) }, + { SPH_C32(0x6a5c0000), SPH_C32(0x19511100), SPH_C32(0x42570000), + SPH_C32(0x3abc0000), SPH_C32(0x94ff29d1), SPH_C32(0xf3b79144), + SPH_C32(0xec2f1eb2), SPH_C32(0xfb6f376b), SPH_C32(0xeeaf0000), + SPH_C32(0x21fb2800), SPH_C32(0x5a7a0000), SPH_C32(0x385a0000), + SPH_C32(0x60603bab), SPH_C32(0x22a0db6d), SPH_C32(0x1e7321ec), + SPH_C32(0xfb094e64) }, + { SPH_C32(0x662e0000), SPH_C32(0x50b41e00), SPH_C32(0x002e0000), + SPH_C32(0x66560000), SPH_C32(0xa75519cb), SPH_C32(0xe635b450), + SPH_C32(0x798c55c9), SPH_C32(0x4f2437fb), SPH_C32(0x108d0000), + SPH_C32(0x86a32d00), SPH_C32(0x7fab0000), SPH_C32(0xcf3a0000), + SPH_C32(0xe9514371), SPH_C32(0x3d74230d), SPH_C32(0x50a382f9), + SPH_C32(0x5a2ab1fb) }, + { SPH_C32(0x695b0000), SPH_C32(0x0dcd0500), SPH_C32(0xa9760000), + SPH_C32(0x03250000), SPH_C32(0x2183248b), SPH_C32(0x61380db7), + SPH_C32(0xd2670d01), SPH_C32(0x40bed715), SPH_C32(0x59e70000), + SPH_C32(0x6af33500), SPH_C32(0xc4b80000), SPH_C32(0xa8980000), + SPH_C32(0xc4376747), SPH_C32(0x0be593cf), SPH_C32(0xd3bc6f32), + SPH_C32(0x315245b4) }, + { SPH_C32(0x65290000), SPH_C32(0x44280a00), SPH_C32(0xeb0f0000), + SPH_C32(0x5fcf0000), SPH_C32(0x12291491), SPH_C32(0x74ba28a3), + SPH_C32(0x47c4467a), SPH_C32(0xf4f5d785), SPH_C32(0xa7c50000), + SPH_C32(0xcdab3000), SPH_C32(0xe1690000), SPH_C32(0x5ff80000), + SPH_C32(0x4d061f9d), SPH_C32(0x14316baf), SPH_C32(0x9d6ccc27), + SPH_C32(0x9071ba2b) }, + { SPH_C32(0x97790000), SPH_C32(0xaa950000), SPH_C32(0x8ca70000), + SPH_C32(0xf4450000), SPH_C32(0xa8b25c51), SPH_C32(0x7eecf5d7), + SPH_C32(0x9cb7ae14), SPH_C32(0xe19d288a), SPH_C32(0xabb70000), + SPH_C32(0x844e3f00), SPH_C32(0xa3100000), SPH_C32(0x03120000), + SPH_C32(0x7eac2f87), SPH_C32(0x01b34ebb), SPH_C32(0x08cf875c), + SPH_C32(0x243ababb) }, + { SPH_C32(0x9b0b0000), SPH_C32(0xe3700f00), SPH_C32(0xcede0000), + SPH_C32(0xa8af0000), SPH_C32(0x9b186c4b), SPH_C32(0x6b6ed0c3), + SPH_C32(0x0914e56f), SPH_C32(0x55d6281a), SPH_C32(0x55950000), + SPH_C32(0x23163a00), SPH_C32(0x86c10000), SPH_C32(0xf4720000), + SPH_C32(0xf79d575d), SPH_C32(0x1e67b6db), SPH_C32(0x461f2449), + SPH_C32(0x85194524) }, + { SPH_C32(0x2c430000), SPH_C32(0xa8781200), SPH_C32(0x501c0000), + SPH_C32(0x386d0000), SPH_C32(0x3f4f30a7), SPH_C32(0x422b9861), + SPH_C32(0xc4dbabb1), SPH_C32(0x9f8d23ca), SPH_C32(0xe1da0000), + SPH_C32(0x7c823300), SPH_C32(0xf3220000), SPH_C32(0x5d290000), + SPH_C32(0xe6b606eb), SPH_C32(0xa5ad628a), SPH_C32(0xb5987924), + SPH_C32(0xf493ae8a) }, + { SPH_C32(0x20310000), SPH_C32(0xe19d1d00), SPH_C32(0x12650000), + SPH_C32(0x64870000), SPH_C32(0x0ce500bd), SPH_C32(0x57a9bd75), + SPH_C32(0x5178e0ca), SPH_C32(0x2bc6235a), SPH_C32(0x1ff80000), + SPH_C32(0xdbda3600), SPH_C32(0xd6f30000), SPH_C32(0xaa490000), + SPH_C32(0x6f877e31), SPH_C32(0xba799aea), SPH_C32(0xfb48da31), + SPH_C32(0x55b05115) }, + { SPH_C32(0xd2610000), SPH_C32(0x0f201700), SPH_C32(0x75cd0000), + SPH_C32(0xcf0d0000), SPH_C32(0xb67e487d), SPH_C32(0x5dff6001), + SPH_C32(0x8a0b08a4), SPH_C32(0x3eaedc55), SPH_C32(0x138a0000), + SPH_C32(0x923f3900), SPH_C32(0x948a0000), SPH_C32(0xf6a30000), + SPH_C32(0x5c2d4e2b), SPH_C32(0xaffbbffe), SPH_C32(0x6eeb914a), + SPH_C32(0xe1fb5185) }, + { SPH_C32(0xde130000), SPH_C32(0x46c51800), SPH_C32(0x37b40000), + SPH_C32(0x93e70000), SPH_C32(0x85d47867), SPH_C32(0x487d4515), + SPH_C32(0x1fa843df), SPH_C32(0x8ae5dcc5), SPH_C32(0xeda80000), + SPH_C32(0x35673c00), SPH_C32(0xb15b0000), SPH_C32(0x01c30000), + SPH_C32(0xd51c36f1), SPH_C32(0xb02f479e), SPH_C32(0x203b325f), + SPH_C32(0x40d8ae1a) }, + { SPH_C32(0xa4c20000), SPH_C32(0xd9372400), SPH_C32(0x0a480000), + SPH_C32(0x66610000), SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), + SPH_C32(0xa324df94), SPH_C32(0x2ba05a55), SPH_C32(0x75a40000), + SPH_C32(0xc28b2700), SPH_C32(0x94a40000), SPH_C32(0x90f50000), + SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), SPH_C32(0x1767c483), + SPH_C32(0xaedf667e) }, + { SPH_C32(0xa8b00000), SPH_C32(0x90d22b00), SPH_C32(0x48310000), + SPH_C32(0x3a8b0000), SPH_C32(0xcbd022dd), SPH_C32(0x933cd248), + SPH_C32(0x368794ef), SPH_C32(0x9feb5ac5), SPH_C32(0x8b860000), + SPH_C32(0x65d32200), SPH_C32(0xb1750000), SPH_C32(0x67950000), + SPH_C32(0x72492f3a), SPH_C32(0x561af3ce), SPH_C32(0x59b76796), + SPH_C32(0x0ffc99e1) }, + { SPH_C32(0x5ae00000), SPH_C32(0x7e6f2100), SPH_C32(0x2f990000), + SPH_C32(0x91010000), SPH_C32(0x714b6a1d), SPH_C32(0x996a0f3c), + SPH_C32(0xedf47c81), SPH_C32(0x8a83a5ca), SPH_C32(0x87f40000), + SPH_C32(0x2c362d00), SPH_C32(0xf30c0000), SPH_C32(0x3b7f0000), + SPH_C32(0x41e31f20), SPH_C32(0x4398d6da), SPH_C32(0xcc142ced), + SPH_C32(0xbbb79971) }, + { SPH_C32(0x56920000), SPH_C32(0x378a2e00), SPH_C32(0x6de00000), + SPH_C32(0xcdeb0000), SPH_C32(0x42e15a07), SPH_C32(0x8ce82a28), + SPH_C32(0x785737fa), SPH_C32(0x3ec8a55a), SPH_C32(0x79d60000), + SPH_C32(0x8b6e2800), SPH_C32(0xd6dd0000), SPH_C32(0xcc1f0000), + SPH_C32(0xc8d267fa), SPH_C32(0x5c4c2eba), SPH_C32(0x82c48ff8), + SPH_C32(0x1a9466ee) }, + { SPH_C32(0xe1da0000), SPH_C32(0x7c823300), SPH_C32(0xf3220000), + SPH_C32(0x5d290000), SPH_C32(0xe6b606eb), SPH_C32(0xa5ad628a), + SPH_C32(0xb5987924), SPH_C32(0xf493ae8a), SPH_C32(0xcd990000), + SPH_C32(0xd4fa2100), SPH_C32(0xa33e0000), SPH_C32(0x65440000), + SPH_C32(0xd9f9364c), SPH_C32(0xe786faeb), SPH_C32(0x7143d295), + SPH_C32(0x6b1e8d40) }, + { SPH_C32(0xeda80000), SPH_C32(0x35673c00), SPH_C32(0xb15b0000), + SPH_C32(0x01c30000), SPH_C32(0xd51c36f1), SPH_C32(0xb02f479e), + SPH_C32(0x203b325f), SPH_C32(0x40d8ae1a), SPH_C32(0x33bb0000), + SPH_C32(0x73a22400), SPH_C32(0x86ef0000), SPH_C32(0x92240000), + SPH_C32(0x50c84e96), SPH_C32(0xf852028b), SPH_C32(0x3f937180), + SPH_C32(0xca3d72df) }, + { SPH_C32(0x1ff80000), SPH_C32(0xdbda3600), SPH_C32(0xd6f30000), + SPH_C32(0xaa490000), SPH_C32(0x6f877e31), SPH_C32(0xba799aea), + SPH_C32(0xfb48da31), SPH_C32(0x55b05115), SPH_C32(0x3fc90000), + SPH_C32(0x3a472b00), SPH_C32(0xc4960000), SPH_C32(0xcece0000), + SPH_C32(0x63627e8c), SPH_C32(0xedd0279f), SPH_C32(0xaa303afb), + SPH_C32(0x7e76724f) }, + { SPH_C32(0x138a0000), SPH_C32(0x923f3900), SPH_C32(0x948a0000), + SPH_C32(0xf6a30000), SPH_C32(0x5c2d4e2b), SPH_C32(0xaffbbffe), + SPH_C32(0x6eeb914a), SPH_C32(0xe1fb5185), SPH_C32(0xc1eb0000), + SPH_C32(0x9d1f2e00), SPH_C32(0xe1470000), SPH_C32(0x39ae0000), + SPH_C32(0xea530656), SPH_C32(0xf204dfff), SPH_C32(0xe4e099ee), + SPH_C32(0xdf558dd0) }, + { SPH_C32(0x1cff0000), SPH_C32(0xcf462200), SPH_C32(0x3dd20000), + SPH_C32(0x93d00000), SPH_C32(0xdafb736b), SPH_C32(0x28f60619), + SPH_C32(0xc500c982), SPH_C32(0xee61b16b), SPH_C32(0x88810000), + SPH_C32(0x714f3600), SPH_C32(0x5a540000), SPH_C32(0x5e0c0000), + SPH_C32(0xc7352260), SPH_C32(0xc4956f3d), SPH_C32(0x67ff7425), + SPH_C32(0xb42d799f) }, + { SPH_C32(0x108d0000), SPH_C32(0x86a32d00), SPH_C32(0x7fab0000), + SPH_C32(0xcf3a0000), SPH_C32(0xe9514371), SPH_C32(0x3d74230d), + SPH_C32(0x50a382f9), SPH_C32(0x5a2ab1fb), SPH_C32(0x76a30000), + SPH_C32(0xd6173300), SPH_C32(0x7f850000), SPH_C32(0xa96c0000), + SPH_C32(0x4e045aba), SPH_C32(0xdb41975d), SPH_C32(0x292fd730), + SPH_C32(0x150e8600) }, + { SPH_C32(0xe2dd0000), SPH_C32(0x681e2700), SPH_C32(0x18030000), + SPH_C32(0x64b00000), SPH_C32(0x53ca0bb1), SPH_C32(0x3722fe79), + SPH_C32(0x8bd06a97), SPH_C32(0x4f424ef4), SPH_C32(0x7ad10000), + SPH_C32(0x9ff23c00), SPH_C32(0x3dfc0000), SPH_C32(0xf5860000), + SPH_C32(0x7dae6aa0), SPH_C32(0xcec3b249), SPH_C32(0xbc8c9c4b), + SPH_C32(0xa1458690) }, + { SPH_C32(0xeeaf0000), SPH_C32(0x21fb2800), SPH_C32(0x5a7a0000), + SPH_C32(0x385a0000), SPH_C32(0x60603bab), SPH_C32(0x22a0db6d), + SPH_C32(0x1e7321ec), SPH_C32(0xfb094e64), SPH_C32(0x84f30000), + SPH_C32(0x38aa3900), SPH_C32(0x182d0000), SPH_C32(0x02e60000), + SPH_C32(0xf49f127a), SPH_C32(0xd1174a29), SPH_C32(0xf25c3f5e), + SPH_C32(0x0066790f) }, + { SPH_C32(0x59e70000), SPH_C32(0x6af33500), SPH_C32(0xc4b80000), + SPH_C32(0xa8980000), SPH_C32(0xc4376747), SPH_C32(0x0be593cf), + SPH_C32(0xd3bc6f32), SPH_C32(0x315245b4), SPH_C32(0x30bc0000), + SPH_C32(0x673e3000), SPH_C32(0x6dce0000), SPH_C32(0xabbd0000), + SPH_C32(0xe5b443cc), SPH_C32(0x6add9e78), SPH_C32(0x01db6233), + SPH_C32(0x71ec92a1) }, + { SPH_C32(0x55950000), SPH_C32(0x23163a00), SPH_C32(0x86c10000), + SPH_C32(0xf4720000), SPH_C32(0xf79d575d), SPH_C32(0x1e67b6db), + SPH_C32(0x461f2449), SPH_C32(0x85194524), SPH_C32(0xce9e0000), + SPH_C32(0xc0663500), SPH_C32(0x481f0000), SPH_C32(0x5cdd0000), + SPH_C32(0x6c853b16), SPH_C32(0x75096618), SPH_C32(0x4f0bc126), + SPH_C32(0xd0cf6d3e) }, + { SPH_C32(0xa7c50000), SPH_C32(0xcdab3000), SPH_C32(0xe1690000), + SPH_C32(0x5ff80000), SPH_C32(0x4d061f9d), SPH_C32(0x14316baf), + SPH_C32(0x9d6ccc27), SPH_C32(0x9071ba2b), SPH_C32(0xc2ec0000), + SPH_C32(0x89833a00), SPH_C32(0x0a660000), SPH_C32(0x00370000), + SPH_C32(0x5f2f0b0c), SPH_C32(0x608b430c), SPH_C32(0xdaa88a5d), + SPH_C32(0x64846dae) }, + { SPH_C32(0xabb70000), SPH_C32(0x844e3f00), SPH_C32(0xa3100000), + SPH_C32(0x03120000), SPH_C32(0x7eac2f87), SPH_C32(0x01b34ebb), + SPH_C32(0x08cf875c), SPH_C32(0x243ababb), SPH_C32(0x3cce0000), + SPH_C32(0x2edb3f00), SPH_C32(0x2fb70000), SPH_C32(0xf7570000), + SPH_C32(0xd61e73d6), SPH_C32(0x7f5fbb6c), SPH_C32(0x94782948), + SPH_C32(0xc5a79231) } +}; + +static const sph_u32 T512_24[64][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x14190000), SPH_C32(0x23ca003c), SPH_C32(0x50df0000), + SPH_C32(0x44b60000), SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), + SPH_C32(0x61e610b0), SPH_C32(0xdbcadb80), SPH_C32(0xe3430000), + SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), SPH_C32(0xaa4e0000), + SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), SPH_C32(0x123db156), + SPH_C32(0x3a4e99d7) }, + { SPH_C32(0xe3430000), SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), + SPH_C32(0xaa4e0000), SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), + SPH_C32(0x123db156), SPH_C32(0x3a4e99d7), SPH_C32(0xf75a0000), + SPH_C32(0x19840028), SPH_C32(0xa2190000), SPH_C32(0xeef80000), + SPH_C32(0xc0722516), SPH_C32(0x19981260), SPH_C32(0x73dba1e6), + SPH_C32(0xe1844257) }, + { SPH_C32(0xf75a0000), SPH_C32(0x19840028), SPH_C32(0xa2190000), + SPH_C32(0xeef80000), SPH_C32(0xc0722516), SPH_C32(0x19981260), + SPH_C32(0x73dba1e6), SPH_C32(0xe1844257), SPH_C32(0x14190000), + SPH_C32(0x23ca003c), SPH_C32(0x50df0000), SPH_C32(0x44b60000), + SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), SPH_C32(0x61e610b0), + SPH_C32(0xdbcadb80) }, + { SPH_C32(0x54500000), SPH_C32(0x0671005c), SPH_C32(0x25ae0000), + SPH_C32(0x6a1e0000), SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), + SPH_C32(0xbfba18c3), SPH_C32(0x7e715d17), SPH_C32(0xbc8d0000), + SPH_C32(0xfc3b0018), SPH_C32(0x19830000), SPH_C32(0xd10b0000), + SPH_C32(0xae1878c4), SPH_C32(0x42a69856), SPH_C32(0x0012da37), + SPH_C32(0x2c3b504e) }, + { SPH_C32(0x40490000), SPH_C32(0x25bb0060), SPH_C32(0x75710000), + SPH_C32(0x2ea80000), SPH_C32(0x35c9296f), SPH_C32(0x5abd2967), + SPH_C32(0xde5c0873), SPH_C32(0xa5bb49697), SPH_C32(0x5fce0000), + SPH_C32(0xc675000c), SPH_C32(0xeb450000), SPH_C32(0x7b450000), + SPH_C32(0x75063a62), SPH_C32(0x67cd2643), SPH_C32(0x122f6b61), + SPH_C32(0x1675c999) }, + { SPH_C32(0xb7130000), SPH_C32(0x3c3f0048), SPH_C32(0xd7680000), + SPH_C32(0xc0500000), SPH_C32(0xf5bb0c79), SPH_C32(0x43253b07), + SPH_C32(0xad87a995), SPH_C32(0x443fc4c0), SPH_C32(0x4bd70000), + SPH_C32(0xe5bf0030), SPH_C32(0xbb9a0000), SPH_C32(0x3ff30000), + SPH_C32(0x6e6a5dd2), SPH_C32(0x5b3e8a36), SPH_C32(0x73c97bd1), + SPH_C32(0xcdbf1219) }, + { SPH_C32(0xa30a0000), SPH_C32(0x1ff50074), SPH_C32(0x87b70000), + SPH_C32(0x84e60000), SPH_C32(0xeed76bc9), SPH_C32(0x7fd69772), + SPH_C32(0xcc61b925), SPH_C32(0x9ff51f40), SPH_C32(0xa8940000), + SPH_C32(0xdff10024), SPH_C32(0x495c0000), SPH_C32(0x95bd0000), + SPH_C32(0xb5741f74), SPH_C32(0x7e553423), SPH_C32(0x61f4ca87), + SPH_C32(0xf7f18bce) }, + { SPH_C32(0xbc8d0000), SPH_C32(0xfc3b0018), SPH_C32(0x19830000), + SPH_C32(0xd10b0000), SPH_C32(0xae1878c4), SPH_C32(0x42a69856), + SPH_C32(0x0012da37), SPH_C32(0x2c3b504e), SPH_C32(0xe8dd0000), + SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), SPH_C32(0xbb150000), + SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), SPH_C32(0xbfa8c2f4), + SPH_C32(0x524a0d59) }, + { SPH_C32(0xa8940000), SPH_C32(0xdff10024), SPH_C32(0x495c0000), + SPH_C32(0x95bd0000), SPH_C32(0xb5741f74), SPH_C32(0x7e553423), + SPH_C32(0x61f4ca87), SPH_C32(0xf7f18bce), SPH_C32(0x0b9e0000), + SPH_C32(0xc0040050), SPH_C32(0xceeb0000), SPH_C32(0x115b0000), + SPH_C32(0x5ba374bd), SPH_C32(0x0183a351), SPH_C32(0xad9573a2), + SPH_C32(0x6804948e) }, + { SPH_C32(0x5fce0000), SPH_C32(0xc675000c), SPH_C32(0xeb450000), + SPH_C32(0x7b450000), SPH_C32(0x75063a62), SPH_C32(0x67cd2643), + SPH_C32(0x122f6b61), SPH_C32(0x1675c999), SPH_C32(0x1f870000), + SPH_C32(0xe3ce006c), SPH_C32(0x9e340000), SPH_C32(0x55ed0000), + SPH_C32(0x40cf130d), SPH_C32(0x3d700f24), SPH_C32(0xcc736312), + SPH_C32(0xb3ce4f0e) }, + { SPH_C32(0x4bd70000), SPH_C32(0xe5bf0030), SPH_C32(0xbb9a0000), + SPH_C32(0x3ff30000), SPH_C32(0x6e6a5dd2), SPH_C32(0x5b3e8a36), + SPH_C32(0x73c97bd1), SPH_C32(0xcdbf1219), SPH_C32(0xfcc40000), + SPH_C32(0xd9800078), SPH_C32(0x6cf20000), SPH_C32(0xffa30000), + SPH_C32(0x9bd151ab), SPH_C32(0x181bb131), SPH_C32(0xde4ed244), + SPH_C32(0x8980d6d9) }, + { SPH_C32(0xe8dd0000), SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), + SPH_C32(0xbb150000), SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), + SPH_C32(0xbfa8c2f4), SPH_C32(0x524a0d59), SPH_C32(0x54500000), + SPH_C32(0x0671005c), SPH_C32(0x25ae0000), SPH_C32(0x6a1e0000), + SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), SPH_C32(0xbfba18c3), + SPH_C32(0x7e715d17) }, + { SPH_C32(0xfcc40000), SPH_C32(0xd9800078), SPH_C32(0x6cf20000), + SPH_C32(0xffa30000), SPH_C32(0x9bd151ab), SPH_C32(0x181bb131), + SPH_C32(0xde4ed244), SPH_C32(0x8980d6d9), SPH_C32(0xb7130000), + SPH_C32(0x3c3f0048), SPH_C32(0xd7680000), SPH_C32(0xc0500000), + SPH_C32(0xf5bb0c79), SPH_C32(0x43253b07), SPH_C32(0xad87a995), + SPH_C32(0x443fc4c0) }, + { SPH_C32(0x0b9e0000), SPH_C32(0xc0040050), SPH_C32(0xceeb0000), + SPH_C32(0x115b0000), SPH_C32(0x5ba374bd), SPH_C32(0x0183a351), + SPH_C32(0xad9573a2), SPH_C32(0x6804948e), SPH_C32(0xa30a0000), + SPH_C32(0x1ff50074), SPH_C32(0x87b70000), SPH_C32(0x84e60000), + SPH_C32(0xeed76bc9), SPH_C32(0x7fd69772), SPH_C32(0xcc61b925), + SPH_C32(0x9ff51f40) }, + { SPH_C32(0x1f870000), SPH_C32(0xe3ce006c), SPH_C32(0x9e340000), + SPH_C32(0x55ed0000), SPH_C32(0x40cf130d), SPH_C32(0x3d700f24), + SPH_C32(0xcc736312), SPH_C32(0xb3ce4f0e), SPH_C32(0x40490000), + SPH_C32(0x25bb0060), SPH_C32(0x75710000), SPH_C32(0x2ea80000), + SPH_C32(0x35c9296f), SPH_C32(0x5abd2967), SPH_C32(0xde5c0873), + SPH_C32(0xa5bb49697) }, + { SPH_C32(0x69510000), SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), + SPH_C32(0xac2f0000), SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), + SPH_C32(0x87ec287c), SPH_C32(0xbce1a3ce), SPH_C32(0xc6730000), + SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), SPH_C32(0x218d0000), + SPH_C32(0x23111587), SPH_C32(0x7913512f), SPH_C32(0x1d28ac88), + SPH_C32(0x378dd173) }, + { SPH_C32(0x7d480000), SPH_C32(0xf72b00a0), SPH_C32(0x93fc0000), + SPH_C32(0xe8990000), SPH_C32(0xfff96c1e), SPH_C32(0xf257b9a9), + SPH_C32(0xe60a38cc), SPH_C32(0x672b784e), SPH_C32(0x25300000), + SPH_C32(0x95c30018), SPH_C32(0x56070000), SPH_C32(0x8bc30000), + SPH_C32(0xf80f5721), SPH_C32(0x5c78ef3a), SPH_C32(0x0f151dde), + SPH_C32(0x0dc348a4) }, + { SPH_C32(0x8a120000), SPH_C32(0xeeaf0088), SPH_C32(0x31e50000), + SPH_C32(0x06610000), SPH_C32(0x3f8b4908), SPH_C32(0xebcfabc9), + SPH_C32(0x95d1992a), SPH_C32(0x86af3a19), SPH_C32(0x31290000), + SPH_C32(0xb6090024), SPH_C32(0x06d80000), SPH_C32(0xcf750000), + SPH_C32(0xe3633091), SPH_C32(0x608b434f), SPH_C32(0x6ef30d6e), + SPH_C32(0xd6099324) }, + { SPH_C32(0x9e0b0000), SPH_C32(0xcd6500b4), SPH_C32(0x613a0000), + SPH_C32(0x42d70000), SPH_C32(0x24e72eb8), SPH_C32(0xd73c07bc), + SPH_C32(0xf437899a), SPH_C32(0x5d65e199), SPH_C32(0xd26a0000), + SPH_C32(0x8c470030), SPH_C32(0xf41e0000), SPH_C32(0x653b0000), + SPH_C32(0x387d7237), SPH_C32(0x45e0fd5a), SPH_C32(0x7ccebc38), + SPH_C32(0xec470af3) }, + { SPH_C32(0x3d010000), SPH_C32(0xd29000c0), SPH_C32(0xe68d0000), + SPH_C32(0xc6310000), SPH_C32(0xca304571), SPH_C32(0xa8ea90ce), + SPH_C32(0x385630bf), SPH_C32(0xc290fed9), SPH_C32(0x7afe0000), + SPH_C32(0x53b60014), SPH_C32(0xbd420000), SPH_C32(0xf0860000), + SPH_C32(0x8d096d43), SPH_C32(0x3bb5c979), SPH_C32(0x1d3a76bf), + SPH_C32(0x1bb6813d) }, + { SPH_C32(0x29180000), SPH_C32(0xf15a00fc), SPH_C32(0xb6520000), + SPH_C32(0x82870000), SPH_C32(0xd15c22c1), SPH_C32(0x94193cbb), + SPH_C32(0x59b0200f), SPH_C32(0x195a2559), SPH_C32(0x99bd0000), + SPH_C32(0x69f80000), SPH_C32(0x4f840000), SPH_C32(0x5ac80000), + SPH_C32(0x56172fe5), SPH_C32(0x1ede776c), SPH_C32(0x0f07c7e9), + SPH_C32(0x21f818ea) }, + { SPH_C32(0xde420000), SPH_C32(0xe8de00d4), SPH_C32(0x144b0000), + SPH_C32(0x6c7f0000), SPH_C32(0x112e07d7), SPH_C32(0x8d812edb), + SPH_C32(0x2a6b81e9), SPH_C32(0xf8de670e), SPH_C32(0x8da40000), + SPH_C32(0x4a32003c), SPH_C32(0x1f5b0000), SPH_C32(0x1e7e0000), + SPH_C32(0x4d7b4855), SPH_C32(0x222ddb19), SPH_C32(0x6ee1d759), + SPH_C32(0xfa32c36a) }, + { SPH_C32(0xca5b0000), SPH_C32(0xcb1400e8), SPH_C32(0x44940000), + SPH_C32(0x28c90000), SPH_C32(0x0a426067), SPH_C32(0xb17282ae), + SPH_C32(0x4b8d9159), SPH_C32(0x2314bc8e), SPH_C32(0x6ee70000), + SPH_C32(0x707c0028), SPH_C32(0xed9d0000), SPH_C32(0xb4300000), + SPH_C32(0x96650af3), SPH_C32(0x0746650c), SPH_C32(0x7cdc660f), + SPH_C32(0xc07c5abd) }, + { SPH_C32(0xd5dc0000), SPH_C32(0x28da0084), SPH_C32(0xdaa00000), + SPH_C32(0x7d240000), SPH_C32(0x4a8d736a), SPH_C32(0x8c028d8a), + SPH_C32(0x87fef24b), SPH_C32(0x90daf380), SPH_C32(0x2eae0000), + SPH_C32(0x55c70048), SPH_C32(0x98ec0000), SPH_C32(0x9a980000), + SPH_C32(0xa3ac239c), SPH_C32(0x5dfb4c6b), SPH_C32(0xa2806e7c), + SPH_C32(0x65c7dc2a) }, + { SPH_C32(0xc1c50000), SPH_C32(0x0b1000b8), SPH_C32(0x8a7f0000), + SPH_C32(0x39920000), SPH_C32(0x51e114da), SPH_C32(0xb0f121ff), + SPH_C32(0xe618e2fb), SPH_C32(0x4b102800), SPH_C32(0xcded0000), + SPH_C32(0x6f89005c), SPH_C32(0x6a2a0000), SPH_C32(0x30d60000), + SPH_C32(0x78b2613a), SPH_C32(0x7890f27e), SPH_C32(0xb0bddf2a), + SPH_C32(0x5f8945fd) }, + { SPH_C32(0x369f0000), SPH_C32(0x12940090), SPH_C32(0x28660000), + SPH_C32(0xd76a0000), SPH_C32(0x919331cc), SPH_C32(0xa969339f), + SPH_C32(0x95c3431d), SPH_C32(0xaa946a57), SPH_C32(0xd9f40000), + SPH_C32(0x4c430060), SPH_C32(0x3af50000), SPH_C32(0x74600000), + SPH_C32(0x63de068a), SPH_C32(0x44635e0b), SPH_C32(0xd15bcf9a), + SPH_C32(0x84439e7d) }, + { SPH_C32(0x22860000), SPH_C32(0x315e00ac), SPH_C32(0x78b90000), + SPH_C32(0x93dc0000), SPH_C32(0x8aff567c), SPH_C32(0x959a9fea), + SPH_C32(0xf42553ad), SPH_C32(0x715eb1d7), SPH_C32(0x3ab70000), + SPH_C32(0x760d0074), SPH_C32(0xc8330000), SPH_C32(0xde2e0000), + SPH_C32(0xb8c0442c), SPH_C32(0x6108e01e), SPH_C32(0xc3667ecc), + SPH_C32(0xbe0d07aa) }, + { SPH_C32(0x818c0000), SPH_C32(0x2eab00d8), SPH_C32(0xff0e0000), + SPH_C32(0x173a0000), SPH_C32(0x64283db5), SPH_C32(0xea4c0898), + SPH_C32(0x3844ea88), SPH_C32(0xeeabae97), SPH_C32(0x92230000), + SPH_C32(0xa9fc0050), SPH_C32(0x816f0000), SPH_C32(0x4b930000), + SPH_C32(0x0db45b58), SPH_C32(0x1f5dd43d), SPH_C32(0xa292b44b), + SPH_C32(0x49fc8c64) }, + { SPH_C32(0x95950000), SPH_C32(0x0d6100e4), SPH_C32(0xafd10000), + SPH_C32(0x538c0000), SPH_C32(0x7f445a05), SPH_C32(0xd6bfa4ed), + SPH_C32(0x59a2fa38), SPH_C32(0x35617517), SPH_C32(0x71600000), + SPH_C32(0x93b20044), SPH_C32(0x73a90000), SPH_C32(0xe1dd0000), + SPH_C32(0xd6aa19fe), SPH_C32(0x3a366a28), SPH_C32(0xb0af051d), + SPH_C32(0x73b215b3) }, + { SPH_C32(0x62cf0000), SPH_C32(0x14e500cc), SPH_C32(0x0dc80000), + SPH_C32(0xbd740000), SPH_C32(0xbf367f13), SPH_C32(0xcf27b68d), + SPH_C32(0x2a795bde), SPH_C32(0xd4e53740), SPH_C32(0x65790000), + SPH_C32(0xb0780078), SPH_C32(0x23760000), SPH_C32(0xa56b0000), + SPH_C32(0xcdc67e4e), SPH_C32(0x06c5c65d), SPH_C32(0xd14915ad), + SPH_C32(0xa878ce33) }, + { SPH_C32(0x76d60000), SPH_C32(0x372f00f0), SPH_C32(0x5d170000), + SPH_C32(0xf9c20000), SPH_C32(0xa45a18a3), SPH_C32(0xf3d41af8), + SPH_C32(0x4b9f4b6e), SPH_C32(0x0f2fecc0), SPH_C32(0x863a0000), + SPH_C32(0x8a36006c), SPH_C32(0xd1b00000), SPH_C32(0x0f250000), + SPH_C32(0x16d83ce8), SPH_C32(0x23ae7848), SPH_C32(0xc374a4fb), + SPH_C32(0x923657e4) }, + { SPH_C32(0xc6730000), SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), + SPH_C32(0x218d0000), SPH_C32(0x23111587), SPH_C32(0x7913512f), + SPH_C32(0x1d28ac88), SPH_C32(0x378dd173), SPH_C32(0xaf220000), + SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), SPH_C32(0x8da20000), + SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), SPH_C32(0x9ac484f4), + SPH_C32(0x8b6c72bd) }, + { SPH_C32(0xd26a0000), SPH_C32(0x8c470030), SPH_C32(0xf41e0000), + SPH_C32(0x653b0000), SPH_C32(0x387d7237), SPH_C32(0x45e0fd5a), + SPH_C32(0x7ccebc38), SPH_C32(0xec470af3), SPH_C32(0x4c610000), + SPH_C32(0x41220084), SPH_C32(0x95240000), SPH_C32(0x27ec0000), + SPH_C32(0x1c9a5c8f), SPH_C32(0x92dcfae6), SPH_C32(0x88f935a2), + SPH_C32(0xb122eb6a) }, + { SPH_C32(0x25300000), SPH_C32(0x95c30018), SPH_C32(0x56070000), + SPH_C32(0x8bc30000), SPH_C32(0xf80f5721), SPH_C32(0x5c78ef3a), + SPH_C32(0x0f151dde), SPH_C32(0x0dc348a4), SPH_C32(0x58780000), + SPH_C32(0x62e800b8), SPH_C32(0xc5fb0000), SPH_C32(0x635a0000), + SPH_C32(0x07f63b3f), SPH_C32(0xae2f5693), SPH_C32(0xe91f2512), + SPH_C32(0x6ae830ea) }, + { SPH_C32(0x31290000), SPH_C32(0xb6090024), SPH_C32(0x06d80000), + SPH_C32(0xcf750000), SPH_C32(0xe3633091), SPH_C32(0x608b434f), + SPH_C32(0x6ef30d6e), SPH_C32(0xd6099324), SPH_C32(0xbb3b0000), + SPH_C32(0x58a600ac), SPH_C32(0x373d0000), SPH_C32(0xc9140000), + SPH_C32(0xdce87999), SPH_C32(0x8b44e886), SPH_C32(0xfb229444), + SPH_C32(0x50a6a93d) }, + { SPH_C32(0x92230000), SPH_C32(0xa9fc0050), SPH_C32(0x816f0000), + SPH_C32(0x4b930000), SPH_C32(0x0db45b58), SPH_C32(0x1f5dd43d), + SPH_C32(0xa292b44b), SPH_C32(0x49fc8c64), SPH_C32(0x13af0000), + SPH_C32(0x87570088), SPH_C32(0x7e610000), SPH_C32(0x5ca90000), + SPH_C32(0x699c66ed), SPH_C32(0xf511dca5), SPH_C32(0x9ad65ec3), + SPH_C32(0xa75722f3) }, + { SPH_C32(0x863a0000), SPH_C32(0x8a36006c), SPH_C32(0xd1b00000), + SPH_C32(0x0f250000), SPH_C32(0x16d83ce8), SPH_C32(0x23ae7848), + SPH_C32(0xc374a4fb), SPH_C32(0x923657e4), SPH_C32(0xf0ec0000), + SPH_C32(0xbd19009c), SPH_C32(0x8ca70000), SPH_C32(0xf6e70000), + SPH_C32(0xb282244b), SPH_C32(0xd07a62b0), SPH_C32(0x88ebef95), + SPH_C32(0x9d19bb24) }, + { SPH_C32(0x71600000), SPH_C32(0x93b20044), SPH_C32(0x73a90000), + SPH_C32(0xe1dd0000), SPH_C32(0xd6aa19fe), SPH_C32(0x3a366a28), + SPH_C32(0xb0af051d), SPH_C32(0x73b215b3), SPH_C32(0xe4f50000), + SPH_C32(0x9ed300a0), SPH_C32(0xdc780000), SPH_C32(0xb2510000), + SPH_C32(0xa9ee43fb), SPH_C32(0xec89cec5), SPH_C32(0xe90dff25), + SPH_C32(0x46d360a4) }, + { SPH_C32(0x65790000), SPH_C32(0xb0780078), SPH_C32(0x23760000), + SPH_C32(0xa56b0000), SPH_C32(0xcdc67e4e), SPH_C32(0x06c5c65d), + SPH_C32(0xd14915ad), SPH_C32(0xa878ce33), SPH_C32(0x07b60000), + SPH_C32(0xa49d00b4), SPH_C32(0x2ebe0000), SPH_C32(0x181f0000), + SPH_C32(0x72f0015d), SPH_C32(0xc9e270d0), SPH_C32(0xfb304e73), + SPH_C32(0x7c9df973) }, + { SPH_C32(0x7afe0000), SPH_C32(0x53b60014), SPH_C32(0xbd420000), + SPH_C32(0xf0860000), SPH_C32(0x8d096d43), SPH_C32(0x3bb5c979), + SPH_C32(0x1d3a76bf), SPH_C32(0x1bb6813d), SPH_C32(0x47ff0000), + SPH_C32(0x812600d4), SPH_C32(0x5bcf0000), SPH_C32(0x36b70000), + SPH_C32(0x47392832), SPH_C32(0x935f59b7), SPH_C32(0x256c4600), + SPH_C32(0xd9267fe4) }, + { SPH_C32(0x6ee70000), SPH_C32(0x707c0028), SPH_C32(0xed9d0000), + SPH_C32(0xb4300000), SPH_C32(0x96650af3), SPH_C32(0x0746650c), + SPH_C32(0x7cdc660f), SPH_C32(0xc07c5abd), SPH_C32(0xa4bc0000), + SPH_C32(0xbb6800c0), SPH_C32(0xa9090000), SPH_C32(0x9cf90000), + SPH_C32(0x9c276a94), SPH_C32(0xb634e7a2), SPH_C32(0x3751f756), + SPH_C32(0xe368e633) }, + { SPH_C32(0x99bd0000), SPH_C32(0x69f80000), SPH_C32(0x4f840000), + SPH_C32(0x5ac80000), SPH_C32(0x56172fe5), SPH_C32(0x1ede776c), + SPH_C32(0x0f07c7e9), SPH_C32(0x21f818ea), SPH_C32(0xb0a50000), + SPH_C32(0x98a200fc), SPH_C32(0xf9d60000), SPH_C32(0xd84f0000), + SPH_C32(0x874b0d24), SPH_C32(0x8ac74bd7), SPH_C32(0x56b7e7e6), + SPH_C32(0x38a23db3) }, + { SPH_C32(0x8da40000), SPH_C32(0x4a32003c), SPH_C32(0x1f5b0000), + SPH_C32(0x1e7e0000), SPH_C32(0x4d7b4855), SPH_C32(0x222ddb19), + SPH_C32(0x6ee1d759), SPH_C32(0xfa32c36a), SPH_C32(0x53e60000), + SPH_C32(0xa2ec00e8), SPH_C32(0x0b100000), SPH_C32(0x72010000), + SPH_C32(0x5c554f82), SPH_C32(0xafacf5c2), SPH_C32(0x448a56b0), + SPH_C32(0x02eca464) }, + { SPH_C32(0x2eae0000), SPH_C32(0x55c70048), SPH_C32(0x98ec0000), + SPH_C32(0x9a980000), SPH_C32(0xa3ac239c), SPH_C32(0x5dfb4c6b), + SPH_C32(0xa2806e7c), SPH_C32(0x65c7dc2a), SPH_C32(0xfb720000), + SPH_C32(0x7d1d00cc), SPH_C32(0x424c0000), SPH_C32(0xe7bc0000), + SPH_C32(0xe92150f6), SPH_C32(0xd1f9c1e1), SPH_C32(0x257e9c37), + SPH_C32(0xf51d2faa) }, + { SPH_C32(0x3ab70000), SPH_C32(0x760d0074), SPH_C32(0xc8330000), + SPH_C32(0xde2e0000), SPH_C32(0xb8c0442c), SPH_C32(0x6108e01e), + SPH_C32(0xc3667ecc), SPH_C32(0xbe0d07aa), SPH_C32(0x18310000), + SPH_C32(0x475300d8), SPH_C32(0xb08a0000), SPH_C32(0x4df20000), + SPH_C32(0x323f1250), SPH_C32(0xf4927ff4), SPH_C32(0x37432d61), + SPH_C32(0xcf53b67d) }, + { SPH_C32(0xcded0000), SPH_C32(0x6f89005c), SPH_C32(0x6a2a0000), + SPH_C32(0x30d60000), SPH_C32(0x78b2613a), SPH_C32(0x7890f27e), + SPH_C32(0xb0bddf2a), SPH_C32(0x5f8945fd), SPH_C32(0x0c280000), + SPH_C32(0x649900e4), SPH_C32(0xe0550000), SPH_C32(0x09440000), + SPH_C32(0x295375e0), SPH_C32(0xc861d381), SPH_C32(0x56a53dd1), + SPH_C32(0x14996dfd) }, + { SPH_C32(0xd9f40000), SPH_C32(0x4c430060), SPH_C32(0x3af50000), + SPH_C32(0x74600000), SPH_C32(0x63de068a), SPH_C32(0x44635e0b), + SPH_C32(0xd15bcf9a), SPH_C32(0x84439e7d), SPH_C32(0xef6b0000), + SPH_C32(0x5ed700f0), SPH_C32(0x12930000), SPH_C32(0xa30a0000), + SPH_C32(0xf24d3746), SPH_C32(0xed0a6d94), SPH_C32(0x44988c87), + SPH_C32(0x2ed7f42a) }, + { SPH_C32(0xaf220000), SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), + SPH_C32(0x8da20000), SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), + SPH_C32(0x9ac484f4), SPH_C32(0x8b6c72bd), SPH_C32(0x69510000), + SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), SPH_C32(0xac2f0000), + SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), SPH_C32(0x87ec287c), + SPH_C32(0xbce1a3ce) }, + { SPH_C32(0xbb3b0000), SPH_C32(0x58a600ac), SPH_C32(0x373d0000), + SPH_C32(0xc9140000), SPH_C32(0xdce87999), SPH_C32(0x8b44e886), + SPH_C32(0xfb229444), SPH_C32(0x50a6a93d), SPH_C32(0x8a120000), + SPH_C32(0xeeaf0088), SPH_C32(0x31e50000), SPH_C32(0x06610000), + SPH_C32(0x3f8b4908), SPH_C32(0xebcfabc9), SPH_C32(0x95d1992a), + SPH_C32(0x86af3a19) }, + { SPH_C32(0x4c610000), SPH_C32(0x41220084), SPH_C32(0x95240000), + SPH_C32(0x27ec0000), SPH_C32(0x1c9a5c8f), SPH_C32(0x92dcfae6), + SPH_C32(0x88f935a2), SPH_C32(0xb122eb6a), SPH_C32(0x9e0b0000), + SPH_C32(0xcd6500b4), SPH_C32(0x613a0000), SPH_C32(0x42d70000), + SPH_C32(0x24e72eb8), SPH_C32(0xd73c07bc), SPH_C32(0xf437899a), + SPH_C32(0x5d65e199) }, + { SPH_C32(0x58780000), SPH_C32(0x62e800b8), SPH_C32(0xc5fb0000), + SPH_C32(0x635a0000), SPH_C32(0x07f63b3f), SPH_C32(0xae2f5693), + SPH_C32(0xe91f2512), SPH_C32(0x6ae830ea), SPH_C32(0x7d480000), + SPH_C32(0xf72b00a0), SPH_C32(0x93fc0000), SPH_C32(0xe8990000), + SPH_C32(0xfff96c1e), SPH_C32(0xf257b9a9), SPH_C32(0xe60a38cc), + SPH_C32(0x672b784e) }, + { SPH_C32(0xfb720000), SPH_C32(0x7d1d00cc), SPH_C32(0x424c0000), + SPH_C32(0xe7bc0000), SPH_C32(0xe92150f6), SPH_C32(0xd1f9c1e1), + SPH_C32(0x257e9c37), SPH_C32(0xf51d2faa), SPH_C32(0xd5dc0000), + SPH_C32(0x28da0084), SPH_C32(0xdaa00000), SPH_C32(0x7d240000), + SPH_C32(0x4a8d736a), SPH_C32(0x8c028d8a), SPH_C32(0x87fef24b), + SPH_C32(0x90daf380) }, + { SPH_C32(0xef6b0000), SPH_C32(0x5ed700f0), SPH_C32(0x12930000), + SPH_C32(0xa30a0000), SPH_C32(0xf24d3746), SPH_C32(0xed0a6d94), + SPH_C32(0x44988c87), SPH_C32(0x2ed7f42a), SPH_C32(0x369f0000), + SPH_C32(0x12940090), SPH_C32(0x28660000), SPH_C32(0xd76a0000), + SPH_C32(0x919331cc), SPH_C32(0xa969339f), SPH_C32(0x95c3431d), + SPH_C32(0xaa946a57) }, + { SPH_C32(0x18310000), SPH_C32(0x475300d8), SPH_C32(0xb08a0000), + SPH_C32(0x4df20000), SPH_C32(0x323f1250), SPH_C32(0xf4927ff4), + SPH_C32(0x37432d61), SPH_C32(0xcf53b67d), SPH_C32(0x22860000), + SPH_C32(0x315e00ac), SPH_C32(0x78b90000), SPH_C32(0x93dc0000), + SPH_C32(0x8aff567c), SPH_C32(0x959a9fea), SPH_C32(0xf42553ad), + SPH_C32(0x715eb1d7) }, + { SPH_C32(0x0c280000), SPH_C32(0x649900e4), SPH_C32(0xe0550000), + SPH_C32(0x09440000), SPH_C32(0x295375e0), SPH_C32(0xc861d381), + SPH_C32(0x56a53dd1), SPH_C32(0x14996dfd), SPH_C32(0xc1c50000), + SPH_C32(0x0b1000b8), SPH_C32(0x8a7f0000), SPH_C32(0x39920000), + SPH_C32(0x51e114da), SPH_C32(0xb0f121ff), SPH_C32(0xe618e2fb), + SPH_C32(0x4b102800) }, + { SPH_C32(0x13af0000), SPH_C32(0x87570088), SPH_C32(0x7e610000), + SPH_C32(0x5ca90000), SPH_C32(0x699c66ed), SPH_C32(0xf511dca5), + SPH_C32(0x9ad65ec3), SPH_C32(0xa75722f3), SPH_C32(0x818c0000), + SPH_C32(0x2eab00d8), SPH_C32(0xff0e0000), SPH_C32(0x173a0000), + SPH_C32(0x64283db5), SPH_C32(0xea4c0898), SPH_C32(0x3844ea88), + SPH_C32(0xeeabae97) }, + { SPH_C32(0x07b60000), SPH_C32(0xa49d00b4), SPH_C32(0x2ebe0000), + SPH_C32(0x181f0000), SPH_C32(0x72f0015d), SPH_C32(0xc9e270d0), + SPH_C32(0xfb304e73), SPH_C32(0x7c9df973), SPH_C32(0x62cf0000), + SPH_C32(0x14e500cc), SPH_C32(0x0dc80000), SPH_C32(0xbd740000), + SPH_C32(0xbf367f13), SPH_C32(0xcf27b68d), SPH_C32(0x2a795bde), + SPH_C32(0xd4e53740) }, + { SPH_C32(0xf0ec0000), SPH_C32(0xbd19009c), SPH_C32(0x8ca70000), + SPH_C32(0xf6e70000), SPH_C32(0xb282244b), SPH_C32(0xd07a62b0), + SPH_C32(0x88ebef95), SPH_C32(0x9d19bb24), SPH_C32(0x76d60000), + SPH_C32(0x372f00f0), SPH_C32(0x5d170000), SPH_C32(0xf9c20000), + SPH_C32(0xa45a18a3), SPH_C32(0xf3d41af8), SPH_C32(0x4b9f4b6e), + SPH_C32(0x0f2fecc0) }, + { SPH_C32(0xe4f50000), SPH_C32(0x9ed300a0), SPH_C32(0xdc780000), + SPH_C32(0xb2510000), SPH_C32(0xa9ee43fb), SPH_C32(0xec89cec5), + SPH_C32(0xe90dff25), SPH_C32(0x46d360a4), SPH_C32(0x95950000), + SPH_C32(0x0d6100e4), SPH_C32(0xafd10000), SPH_C32(0x538c0000), + SPH_C32(0x7f445a05), SPH_C32(0xd6bfa4ed), SPH_C32(0x59a2fa38), + SPH_C32(0x35617517) }, + { SPH_C32(0x47ff0000), SPH_C32(0x812600d4), SPH_C32(0x5bcf0000), + SPH_C32(0x36b70000), SPH_C32(0x47392832), SPH_C32(0x935f59b7), + SPH_C32(0x256c4600), SPH_C32(0xd9267fe4), SPH_C32(0x3d010000), + SPH_C32(0xd29000c0), SPH_C32(0xe68d0000), SPH_C32(0xc6310000), + SPH_C32(0xca304571), SPH_C32(0xa8ea90ce), SPH_C32(0x385630bf), + SPH_C32(0xc290fed9) }, + { SPH_C32(0x53e60000), SPH_C32(0xa2ec00e8), SPH_C32(0x0b100000), + SPH_C32(0x72010000), SPH_C32(0x5c554f82), SPH_C32(0xafacf5c2), + SPH_C32(0x448a56b0), SPH_C32(0x02eca464), SPH_C32(0xde420000), + SPH_C32(0xe8de00d4), SPH_C32(0x144b0000), SPH_C32(0x6c7f0000), + SPH_C32(0x112e07d7), SPH_C32(0x8d812edb), SPH_C32(0x2a6b81e9), + SPH_C32(0xf8de670e) }, + { SPH_C32(0xa4bc0000), SPH_C32(0xbb6800c0), SPH_C32(0xa9090000), + SPH_C32(0x9cf90000), SPH_C32(0x9c276a94), SPH_C32(0xb634e7a2), + SPH_C32(0x3751f756), SPH_C32(0xe368e633), SPH_C32(0xca5b0000), + SPH_C32(0xcb1400e8), SPH_C32(0x44940000), SPH_C32(0x28c90000), + SPH_C32(0x0a426067), SPH_C32(0xb17282ae), SPH_C32(0x4b8d9159), + SPH_C32(0x2314bc8e) }, + { SPH_C32(0xb0a50000), SPH_C32(0x98a200fc), SPH_C32(0xf9d60000), + SPH_C32(0xd84f0000), SPH_C32(0x874b0d24), SPH_C32(0x8ac74bd7), + SPH_C32(0x56b7e7e6), SPH_C32(0x38a23db3), SPH_C32(0x29180000), + SPH_C32(0xf15a00fc), SPH_C32(0xb6520000), SPH_C32(0x82870000), + SPH_C32(0xd15c22c1), SPH_C32(0x94193cbb), SPH_C32(0x59b0200f), + SPH_C32(0x195a2559) } +}; + +static const sph_u32 T512_30[64][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xac480000), SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), + SPH_C32(0x03430000), SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), + SPH_C32(0xfe72c7fe), SPH_C32(0x91e478f6), SPH_C32(0x1e4e0000), + SPH_C32(0xdecf0000), SPH_C32(0x6df80180), SPH_C32(0x77240000), + SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), SPH_C32(0xcda31812), + SPH_C32(0x98aa496e) }, + { SPH_C32(0x1e4e0000), SPH_C32(0xdecf0000), SPH_C32(0x6df80180), + SPH_C32(0x77240000), SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), + SPH_C32(0xcda31812), SPH_C32(0x98aa496e), SPH_C32(0xb2060000), + SPH_C32(0xc5690000), SPH_C32(0x28031200), SPH_C32(0x74670000), + SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), SPH_C32(0x33d1dfec), + SPH_C32(0x094e3198) }, + { SPH_C32(0xb2060000), SPH_C32(0xc5690000), SPH_C32(0x28031200), + SPH_C32(0x74670000), SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), + SPH_C32(0x33d1dfec), SPH_C32(0x094e3198), SPH_C32(0xac480000), + SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), SPH_C32(0x03430000), + SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), SPH_C32(0xfe72c7fe), + SPH_C32(0x91e478f6) }, + { SPH_C32(0xaec30000), SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), + SPH_C32(0x2c150000), SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), + SPH_C32(0xab92f78f), SPH_C32(0xa312567b), SPH_C32(0xdb250000), + SPH_C32(0x09290000), SPH_C32(0x49aac000), SPH_C32(0x81e10000), + SPH_C32(0xcafe6b59), SPH_C32(0x42793431), SPH_C32(0x43566b76), + SPH_C32(0xe86cba2e) }, + { SPH_C32(0x028b0000), SPH_C32(0x87e90001), SPH_C32(0x3c2af380), + SPH_C32(0x2f560000), SPH_C32(0x1f4944d9), SPH_C32(0x79e2e780), + SPH_C32(0x55e03071), SPH_C32(0x32f62e8d), SPH_C32(0xc56b0000), + SPH_C32(0xd7e60000), SPH_C32(0x2452c180), SPH_C32(0xf6c50000), + SPH_C32(0x26b96cc7), SPH_C32(0xb6d95d7f), SPH_C32(0x8ef57364), + SPH_C32(0x70c6f340) }, + { SPH_C32(0xb08d0000), SPH_C32(0x42800001), SPH_C32(0x1429e180), + SPH_C32(0x5b310000), SPH_C32(0xa98b722d), SPH_C32(0x92f0de78), + SPH_C32(0x6631ef9d), SPH_C32(0x3bb81f15), SPH_C32(0x69230000), + SPH_C32(0xcc400000), SPH_C32(0x61a9d200), SPH_C32(0xf5860000), + SPH_C32(0x7c3c5dad), SPH_C32(0xa96b0dc9), SPH_C32(0x7087b49a), + SPH_C32(0xe1228bb6) }, + { SPH_C32(0x1cc50000), SPH_C32(0x59260001), SPH_C32(0x51d2f200), + SPH_C32(0x58720000), SPH_C32(0xf30e4347), SPH_C32(0x8d428ece), + SPH_C32(0x98432863), SPH_C32(0xaa5c67e3), SPH_C32(0x776d0000), + SPH_C32(0x128f0000), SPH_C32(0x0c51d380), SPH_C32(0x82a20000), + SPH_C32(0x907b5a33), SPH_C32(0x5dcb6487), SPH_C32(0xbd24ac88), + SPH_C32(0x7988c2d8) }, + { SPH_C32(0xdb250000), SPH_C32(0x09290000), SPH_C32(0x49aac000), + SPH_C32(0x81e10000), SPH_C32(0xcafe6b59), SPH_C32(0x42793431), + SPH_C32(0x43566b76), SPH_C32(0xe86cba2e), SPH_C32(0x75e60000), + SPH_C32(0x95660001), SPH_C32(0x307b2000), SPH_C32(0xadf40000), + SPH_C32(0x8f321eea), SPH_C32(0x24298307), SPH_C32(0xe8c49cf9), + SPH_C32(0x4b7eec55) }, + { SPH_C32(0x776d0000), SPH_C32(0x128f0000), SPH_C32(0x0c51d380), + SPH_C32(0x82a20000), SPH_C32(0x907b5a33), SPH_C32(0x5dcb6487), + SPH_C32(0xbd24ac88), SPH_C32(0x7988c2d8), SPH_C32(0x6ba80000), + SPH_C32(0x4ba90001), SPH_C32(0x5d832180), SPH_C32(0xdad00000), + SPH_C32(0x63751974), SPH_C32(0xd089ea49), SPH_C32(0x256784eb), + SPH_C32(0xd3d4a53b) }, + { SPH_C32(0xc56b0000), SPH_C32(0xd7e60000), SPH_C32(0x2452c180), + SPH_C32(0xf6c50000), SPH_C32(0x26b96cc7), SPH_C32(0xb6d95d7f), + SPH_C32(0x8ef57364), SPH_C32(0x70c6f340), SPH_C32(0xc7e00000), + SPH_C32(0x500f0001), SPH_C32(0x18783200), SPH_C32(0xd9930000), + SPH_C32(0x39f0281e), SPH_C32(0xcf3bbaff), SPH_C32(0xdb154315), + SPH_C32(0x4230ddcd) }, + { SPH_C32(0x69230000), SPH_C32(0xcc400000), SPH_C32(0x61a9d200), + SPH_C32(0xf5860000), SPH_C32(0x7c3c5dad), SPH_C32(0xa96b0dc9), + SPH_C32(0x7087b49a), SPH_C32(0xe1228bb6), SPH_C32(0xd9ae0000), + SPH_C32(0x8ec00001), SPH_C32(0x75803380), SPH_C32(0xaeb70000), + SPH_C32(0xd5b72f80), SPH_C32(0x3b9bd3b1), SPH_C32(0x16b65b07), + SPH_C32(0xda9a94a3) }, + { SPH_C32(0x75e60000), SPH_C32(0x95660001), SPH_C32(0x307b2000), + SPH_C32(0xadf40000), SPH_C32(0x8f321eea), SPH_C32(0x24298307), + SPH_C32(0xe8c49cf9), SPH_C32(0x4b7eec55), SPH_C32(0xaec30000), + SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), SPH_C32(0x2c150000), + SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), SPH_C32(0xab92f78f), + SPH_C32(0xa312567b) }, + { SPH_C32(0xd9ae0000), SPH_C32(0x8ec00001), SPH_C32(0x75803380), + SPH_C32(0xaeb70000), SPH_C32(0xd5b72f80), SPH_C32(0x3b9bd3b1), + SPH_C32(0x16b65b07), SPH_C32(0xda9a94a3), SPH_C32(0xb08d0000), + SPH_C32(0x42800001), SPH_C32(0x1429e180), SPH_C32(0x5b310000), + SPH_C32(0xa98b722d), SPH_C32(0x92f0de78), SPH_C32(0x6631ef9d), + SPH_C32(0x3bb81f15) }, + { SPH_C32(0x6ba80000), SPH_C32(0x4ba90001), SPH_C32(0x5d832180), + SPH_C32(0xdad00000), SPH_C32(0x63751974), SPH_C32(0xd089ea49), + SPH_C32(0x256784eb), SPH_C32(0xd3d4a53b), SPH_C32(0x1cc50000), + SPH_C32(0x59260001), SPH_C32(0x51d2f200), SPH_C32(0x58720000), + SPH_C32(0xf30e4347), SPH_C32(0x8d428ece), SPH_C32(0x98432863), + SPH_C32(0xaa5c67e3) }, + { SPH_C32(0xc7e00000), SPH_C32(0x500f0001), SPH_C32(0x18783200), + SPH_C32(0xd9930000), SPH_C32(0x39f0281e), SPH_C32(0xcf3bbaff), + SPH_C32(0xdb154315), SPH_C32(0x4230ddcd), SPH_C32(0x028b0000), + SPH_C32(0x87e90001), SPH_C32(0x3c2af380), SPH_C32(0x2f560000), + SPH_C32(0x1f4944d9), SPH_C32(0x79e2e780), SPH_C32(0x55e03071), + SPH_C32(0x32f62e8d) }, + { SPH_C32(0x86790000), SPH_C32(0x3f390002), SPH_C32(0xe19ae000), + SPH_C32(0x98560000), SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), + SPH_C32(0xd3dd4944), SPH_C32(0x161ddab9), SPH_C32(0x30b70000), + SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), SPH_C32(0x42c40000), + SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), SPH_C32(0x21afa1ea), + SPH_C32(0xb0a51834) }, + { SPH_C32(0x2a310000), SPH_C32(0x249f0002), SPH_C32(0xa461f380), + SPH_C32(0x9b150000), SPH_C32(0xcfe05664), SPH_C32(0x513a985c), + SPH_C32(0x2daf8eba), SPH_C32(0x87f9a24f), SPH_C32(0x2ef90000), + SPH_C32(0x3b1f0000), SPH_C32(0x990c6180), SPH_C32(0x35e00000), + SPH_C32(0x8fff3af4), SPH_C32(0x8c1afd2e), SPH_C32(0xec0cb9f8), + SPH_C32(0x280f515a) }, + { SPH_C32(0x98370000), SPH_C32(0xe1f60002), SPH_C32(0x8c62e180), + SPH_C32(0xef720000), SPH_C32(0x79226090), SPH_C32(0xba28a1a4), + SPH_C32(0x1e7e5156), SPH_C32(0x8eb793d7), SPH_C32(0x82b10000), + SPH_C32(0x20b90000), SPH_C32(0xdcf77200), SPH_C32(0x36a30000), + SPH_C32(0xd57a0b9e), SPH_C32(0x93a8ad98), SPH_C32(0x127e7e06), + SPH_C32(0xb9eb29ac) }, + { SPH_C32(0x347f0000), SPH_C32(0xfa500002), SPH_C32(0xc999f200), + SPH_C32(0xec310000), SPH_C32(0x23a751fa), SPH_C32(0xa59af112), + SPH_C32(0xe00c96a8), SPH_C32(0x1f53eb21), SPH_C32(0x9cff0000), + SPH_C32(0xfe760000), SPH_C32(0xb10f7380), SPH_C32(0x41870000), + SPH_C32(0x393d0c00), SPH_C32(0x6708c4d6), SPH_C32(0xdfdd6614), + SPH_C32(0x214160c2) }, + { SPH_C32(0x28ba0000), SPH_C32(0xa3760003), SPH_C32(0x984b0000), + SPH_C32(0xb4430000), SPH_C32(0xd0a912bd), SPH_C32(0x28d87fdc), + SPH_C32(0x784fbecb), SPH_C32(0xb50f8cc2), SPH_C32(0xeb920000), + SPH_C32(0xecf90000), SPH_C32(0xbd5ea000), SPH_C32(0xc3250000), + SPH_C32(0xa9465633), SPH_C32(0x3ac3a051), SPH_C32(0x62f9ca9c), + SPH_C32(0x58c9a21a) }, + { SPH_C32(0x84f20000), SPH_C32(0xb8d00003), SPH_C32(0xddb01380), + SPH_C32(0xb7000000), SPH_C32(0x8a2c23d7), SPH_C32(0x376a2f6a), + SPH_C32(0x863d7935), SPH_C32(0x24ebf434), SPH_C32(0xf5dc0000), + SPH_C32(0x32360000), SPH_C32(0xd0a6a180), SPH_C32(0xb4010000), + SPH_C32(0x450151ad), SPH_C32(0xce63c91f), SPH_C32(0xaf5ad28e), + SPH_C32(0xc063eb74) }, + { SPH_C32(0x36f40000), SPH_C32(0x7db90003), SPH_C32(0xf5b30180), + SPH_C32(0xc3670000), SPH_C32(0x3cee1523), SPH_C32(0xdc781692), + SPH_C32(0xb5eca6d9), SPH_C32(0x2da5c5ac), SPH_C32(0x59940000), + SPH_C32(0x29900000), SPH_C32(0x955db200), SPH_C32(0xb7420000), + SPH_C32(0x1f8460c7), SPH_C32(0xd1d199a9), SPH_C32(0x51281570), + SPH_C32(0x51879382) }, + { SPH_C32(0x9abc0000), SPH_C32(0x661f0003), SPH_C32(0xb0481200), + SPH_C32(0xc0240000), SPH_C32(0x666b2449), SPH_C32(0xc3ca4624), + SPH_C32(0x4b9e6127), SPH_C32(0xbc41bd5a), SPH_C32(0x47da0000), + SPH_C32(0xf75f0000), SPH_C32(0xf8a5b380), SPH_C32(0xc0660000), + SPH_C32(0xf3c36759), SPH_C32(0x2571f0e7), SPH_C32(0x9c8b0d62), + SPH_C32(0xc92ddaec) }, + { SPH_C32(0x5d5c0000), SPH_C32(0x36100002), SPH_C32(0xa8302000), + SPH_C32(0x19b70000), SPH_C32(0x5f9b0c57), SPH_C32(0x0cf1fcdb), + SPH_C32(0x908b2232), SPH_C32(0xfe716097), SPH_C32(0x45510000), + SPH_C32(0x70b60001), SPH_C32(0xc48f4000), SPH_C32(0xef300000), + SPH_C32(0xec8a2380), SPH_C32(0x5c931767), SPH_C32(0xc96b3d13), + SPH_C32(0xfbdbf461) }, + { SPH_C32(0xf1140000), SPH_C32(0x2db60002), SPH_C32(0xedcb3380), + SPH_C32(0x1af40000), SPH_C32(0x051e3d3d), SPH_C32(0x1343ac6d), + SPH_C32(0x6ef9e5cc), SPH_C32(0x6f951861), SPH_C32(0x5b1f0000), + SPH_C32(0xae790001), SPH_C32(0xa9774180), SPH_C32(0x98140000), + SPH_C32(0x00cd241e), SPH_C32(0xa8337e29), SPH_C32(0x04c82501), + SPH_C32(0x6371bd0f) }, + { SPH_C32(0x43120000), SPH_C32(0xe8df0002), SPH_C32(0xc5c82180), + SPH_C32(0x6e930000), SPH_C32(0xb3dc0bc9), SPH_C32(0xf8519595), + SPH_C32(0x5d283a20), SPH_C32(0x66db29f9), SPH_C32(0xf7570000), + SPH_C32(0xb5df0001), SPH_C32(0xec8c5200), SPH_C32(0x9b570000), + SPH_C32(0x5a481574), SPH_C32(0xb7812e9f), SPH_C32(0xfabae2ff), + SPH_C32(0xf295c5f9) }, + { SPH_C32(0xef5a0000), SPH_C32(0xf3790002), SPH_C32(0x80333200), + SPH_C32(0x6dd00000), SPH_C32(0xe9593aa3), SPH_C32(0xe7e3c523), + SPH_C32(0xa35afdde), SPH_C32(0xf73f510f), SPH_C32(0xe9190000), + SPH_C32(0x6b100001), SPH_C32(0x81745380), SPH_C32(0xec730000), + SPH_C32(0xb60f12ea), SPH_C32(0x432147d1), SPH_C32(0x3719faed), + SPH_C32(0x6a3f8c97) }, + { SPH_C32(0xf39f0000), SPH_C32(0xaa5f0003), SPH_C32(0xd1e1c000), + SPH_C32(0x35a20000), SPH_C32(0x1a5779e4), SPH_C32(0x6aa14bed), + SPH_C32(0x3b19d5bd), SPH_C32(0x5d6336ec), SPH_C32(0x9e740000), + SPH_C32(0x799f0001), SPH_C32(0x8d258000), SPH_C32(0x6ed10000), + SPH_C32(0x267448d9), SPH_C32(0x1eea2356), SPH_C32(0x8a3d5665), + SPH_C32(0x13b74e4f) }, + { SPH_C32(0x5fd70000), SPH_C32(0xb1f90003), SPH_C32(0x941ad380), + SPH_C32(0x36e10000), SPH_C32(0x40d2488e), SPH_C32(0x75131b5b), + SPH_C32(0xc56b1243), SPH_C32(0xcc874e1a), SPH_C32(0x803a0000), + SPH_C32(0xa7500001), SPH_C32(0xe0dd8180), SPH_C32(0x19f50000), + SPH_C32(0xca334f47), SPH_C32(0xea4a4a18), SPH_C32(0x479e4e77), + SPH_C32(0x8b1d0721) }, + { SPH_C32(0xedd10000), SPH_C32(0x74900003), SPH_C32(0xbc19c180), + SPH_C32(0x42860000), SPH_C32(0xf6107e7a), SPH_C32(0x9e0122a3), + SPH_C32(0xf6bacdaf), SPH_C32(0xc5c97f82), SPH_C32(0x2c720000), + SPH_C32(0xbcf60001), SPH_C32(0xa5269200), SPH_C32(0x1ab60000), + SPH_C32(0x90b67e2d), SPH_C32(0xf5f81aae), SPH_C32(0xb9ec8989), + SPH_C32(0x1af97fd7) }, + { SPH_C32(0x41990000), SPH_C32(0x6f360003), SPH_C32(0xf9e2d200), + SPH_C32(0x41c50000), SPH_C32(0xac954f10), SPH_C32(0x81b37215), + SPH_C32(0x08c80a51), SPH_C32(0x542d0774), SPH_C32(0x323c0000), + SPH_C32(0x62390001), SPH_C32(0xc8de9380), SPH_C32(0x6d920000), + SPH_C32(0x7cf179b3), SPH_C32(0x015873e0), SPH_C32(0x744f919b), + SPH_C32(0x825336b9) }, + { SPH_C32(0x30b70000), SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), + SPH_C32(0x42c40000), SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), + SPH_C32(0x21afa1ea), SPH_C32(0xb0a51834), SPH_C32(0xb6ce0000), + SPH_C32(0xdae90002), SPH_C32(0x156e8000), SPH_C32(0xda920000), + SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), SPH_C32(0xf272e8ae), + SPH_C32(0xa6b8c28d) }, + { SPH_C32(0x9cff0000), SPH_C32(0xfe760000), SPH_C32(0xb10f7380), + SPH_C32(0x41870000), SPH_C32(0x393d0c00), SPH_C32(0x6708c4d6), + SPH_C32(0xdfdd6614), SPH_C32(0x214160c2), SPH_C32(0xa8800000), + SPH_C32(0x04260002), SPH_C32(0x78968180), SPH_C32(0xadb60000), + SPH_C32(0x1a9a5dfa), SPH_C32(0xc29235c4), SPH_C32(0x3fd1f0bc), + SPH_C32(0x3e128be3) }, + { SPH_C32(0x2ef90000), SPH_C32(0x3b1f0000), SPH_C32(0x990c6180), + SPH_C32(0x35e00000), SPH_C32(0x8fff3af4), SPH_C32(0x8c1afd2e), + SPH_C32(0xec0cb9f8), SPH_C32(0x280f515a), SPH_C32(0x04c80000), + SPH_C32(0x1f800002), SPH_C32(0x3d6d9200), SPH_C32(0xaef50000), + SPH_C32(0x401f6c90), SPH_C32(0xdd206572), SPH_C32(0xc1a33742), + SPH_C32(0xaff6f315) }, + { SPH_C32(0x82b10000), SPH_C32(0x20b90000), SPH_C32(0xdcf77200), + SPH_C32(0x36a30000), SPH_C32(0xd57a0b9e), SPH_C32(0x93a8ad98), + SPH_C32(0x127e7e06), SPH_C32(0xb9eb29ac), SPH_C32(0x1a860000), + SPH_C32(0xc14f0002), SPH_C32(0x50959380), SPH_C32(0xd9d10000), + SPH_C32(0xac586b0e), SPH_C32(0x29800c3c), SPH_C32(0x0c002f50), + SPH_C32(0x375cba7b) }, + { SPH_C32(0x9e740000), SPH_C32(0x799f0001), SPH_C32(0x8d258000), + SPH_C32(0x6ed10000), SPH_C32(0x267448d9), SPH_C32(0x1eea2356), + SPH_C32(0x8a3d5665), SPH_C32(0x13b74e4f), SPH_C32(0x6deb0000), + SPH_C32(0xd3c00002), SPH_C32(0x5cc44000), SPH_C32(0x5b730000), + SPH_C32(0x3c23313d), SPH_C32(0x744b68bb), SPH_C32(0xb12483d8), + SPH_C32(0x4ed478a3) }, + { SPH_C32(0x323c0000), SPH_C32(0x62390001), SPH_C32(0xc8de9380), + SPH_C32(0x6d920000), SPH_C32(0x7cf179b3), SPH_C32(0x015873e0), + SPH_C32(0x744f919b), SPH_C32(0x825336b9), SPH_C32(0x73a50000), + SPH_C32(0x0d0f0002), SPH_C32(0x313c4180), SPH_C32(0x2c570000), + SPH_C32(0xd06436a3), SPH_C32(0x80eb01f5), SPH_C32(0x7c879bca), + SPH_C32(0xd67e31cd) }, + { SPH_C32(0x803a0000), SPH_C32(0xa7500001), SPH_C32(0xe0dd8180), + SPH_C32(0x19f50000), SPH_C32(0xca334f47), SPH_C32(0xea4a4a18), + SPH_C32(0x479e4e77), SPH_C32(0x8b1d0721), SPH_C32(0xdfed0000), + SPH_C32(0x16a90002), SPH_C32(0x74c75200), SPH_C32(0x2f140000), + SPH_C32(0x8ae107c9), SPH_C32(0x9f595143), SPH_C32(0x82f55c34), + SPH_C32(0x479a493b) }, + { SPH_C32(0x2c720000), SPH_C32(0xbcf60001), SPH_C32(0xa5269200), + SPH_C32(0x1ab60000), SPH_C32(0x90b67e2d), SPH_C32(0xf5f81aae), + SPH_C32(0xb9ec8989), SPH_C32(0x1af97fd7), SPH_C32(0xc1a30000), + SPH_C32(0xc8660002), SPH_C32(0x193f5380), SPH_C32(0x58300000), + SPH_C32(0x66a60057), SPH_C32(0x6bf9380d), SPH_C32(0x4f564426), + SPH_C32(0xdf300055) }, + { SPH_C32(0xeb920000), SPH_C32(0xecf90000), SPH_C32(0xbd5ea000), + SPH_C32(0xc3250000), SPH_C32(0xa9465633), SPH_C32(0x3ac3a051), + SPH_C32(0x62f9ca9c), SPH_C32(0x58c9a21a), SPH_C32(0xc3280000), + SPH_C32(0x4f8f0003), SPH_C32(0x2515a000), SPH_C32(0x77660000), + SPH_C32(0x79ef448e), SPH_C32(0x121bdf8d), SPH_C32(0x1ab67457), + SPH_C32(0xedc62ed8) }, + { SPH_C32(0x47da0000), SPH_C32(0xf75f0000), SPH_C32(0xf8a5b380), + SPH_C32(0xc0660000), SPH_C32(0xf3c36759), SPH_C32(0x2571f0e7), + SPH_C32(0x9c8b0d62), SPH_C32(0xc92ddaec), SPH_C32(0xdd660000), + SPH_C32(0x91400003), SPH_C32(0x48eda180), SPH_C32(0x00420000), + SPH_C32(0x95a84310), SPH_C32(0xe6bbb6c3), SPH_C32(0xd7156c45), + SPH_C32(0x756c67b6) }, + { SPH_C32(0xf5dc0000), SPH_C32(0x32360000), SPH_C32(0xd0a6a180), + SPH_C32(0xb4010000), SPH_C32(0x450151ad), SPH_C32(0xce63c91f), + SPH_C32(0xaf5ad28e), SPH_C32(0xc063eb74), SPH_C32(0x712e0000), + SPH_C32(0x8ae60003), SPH_C32(0x0d16b200), SPH_C32(0x03010000), + SPH_C32(0xcf2d727a), SPH_C32(0xf909e675), SPH_C32(0x2967abbb), + SPH_C32(0xe4881f40) }, + { SPH_C32(0x59940000), SPH_C32(0x29900000), SPH_C32(0x955db200), + SPH_C32(0xb7420000), SPH_C32(0x1f8460c7), SPH_C32(0xd1d199a9), + SPH_C32(0x51281570), SPH_C32(0x51879382), SPH_C32(0x6f600000), + SPH_C32(0x54290003), SPH_C32(0x60eeb380), SPH_C32(0x74250000), + SPH_C32(0x236a75e4), SPH_C32(0x0da98f3b), SPH_C32(0xe4c4b3a9), + SPH_C32(0x7c22562e) }, + { SPH_C32(0x45510000), SPH_C32(0x70b60001), SPH_C32(0xc48f4000), + SPH_C32(0xef300000), SPH_C32(0xec8a2380), SPH_C32(0x5c931767), + SPH_C32(0xc96b3d13), SPH_C32(0xfbdbf461), SPH_C32(0x180d0000), + SPH_C32(0x46a60003), SPH_C32(0x6cbf6000), SPH_C32(0xf6870000), + SPH_C32(0xb3112fd7), SPH_C32(0x5062ebbc), SPH_C32(0x59e01f21), + SPH_C32(0x05aa94f6) }, + { SPH_C32(0xe9190000), SPH_C32(0x6b100001), SPH_C32(0x81745380), + SPH_C32(0xec730000), SPH_C32(0xb60f12ea), SPH_C32(0x432147d1), + SPH_C32(0x3719faed), SPH_C32(0x6a3f8c97), SPH_C32(0x06430000), + SPH_C32(0x98690003), SPH_C32(0x01476180), SPH_C32(0x81a30000), + SPH_C32(0x5f562849), SPH_C32(0xa4c282f2), SPH_C32(0x94430733), + SPH_C32(0x9d00dd98) }, + { SPH_C32(0x5b1f0000), SPH_C32(0xae790001), SPH_C32(0xa9774180), + SPH_C32(0x98140000), SPH_C32(0x00cd241e), SPH_C32(0xa8337e29), + SPH_C32(0x04c82501), SPH_C32(0x6371bd0f), SPH_C32(0xaa0b0000), + SPH_C32(0x83cf0003), SPH_C32(0x44bc7200), SPH_C32(0x82e00000), + SPH_C32(0x05d31923), SPH_C32(0xbb70d244), SPH_C32(0x6a31c0cd), + SPH_C32(0x0ce4a56e) }, + { SPH_C32(0xf7570000), SPH_C32(0xb5df0001), SPH_C32(0xec8c5200), + SPH_C32(0x9b570000), SPH_C32(0x5a481574), SPH_C32(0xb7812e9f), + SPH_C32(0xfabae2ff), SPH_C32(0xf295c5f9), SPH_C32(0xb4450000), + SPH_C32(0x5d000003), SPH_C32(0x29447380), SPH_C32(0xf5c40000), + SPH_C32(0xe9941ebd), SPH_C32(0x4fd0bb0a), SPH_C32(0xa792d8df), + SPH_C32(0x944eec00) }, + { SPH_C32(0xb6ce0000), SPH_C32(0xdae90002), SPH_C32(0x156e8000), + SPH_C32(0xda920000), SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), + SPH_C32(0xf272e8ae), SPH_C32(0xa6b8c28d), SPH_C32(0x86790000), + SPH_C32(0x3f390002), SPH_C32(0xe19ae000), SPH_C32(0x98560000), + SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), SPH_C32(0xd3dd4944), + SPH_C32(0x161ddab9) }, + { SPH_C32(0x1a860000), SPH_C32(0xc14f0002), SPH_C32(0x50959380), + SPH_C32(0xd9d10000), SPH_C32(0xac586b0e), SPH_C32(0x29800c3c), + SPH_C32(0x0c002f50), SPH_C32(0x375cba7b), SPH_C32(0x98370000), + SPH_C32(0xe1f60002), SPH_C32(0x8c62e180), SPH_C32(0xef720000), + SPH_C32(0x79226090), SPH_C32(0xba28a1a4), SPH_C32(0x1e7e5156), + SPH_C32(0x8eb793d7) }, + { SPH_C32(0xa8800000), SPH_C32(0x04260002), SPH_C32(0x78968180), + SPH_C32(0xadb60000), SPH_C32(0x1a9a5dfa), SPH_C32(0xc29235c4), + SPH_C32(0x3fd1f0bc), SPH_C32(0x3e128be3), SPH_C32(0x347f0000), + SPH_C32(0xfa500002), SPH_C32(0xc999f200), SPH_C32(0xec310000), + SPH_C32(0x23a751fa), SPH_C32(0xa59af112), SPH_C32(0xe00c96a8), + SPH_C32(0x1f53eb21) }, + { SPH_C32(0x04c80000), SPH_C32(0x1f800002), SPH_C32(0x3d6d9200), + SPH_C32(0xaef50000), SPH_C32(0x401f6c90), SPH_C32(0xdd206572), + SPH_C32(0xc1a33742), SPH_C32(0xaff6f315), SPH_C32(0x2a310000), + SPH_C32(0x249f0002), SPH_C32(0xa461f380), SPH_C32(0x9b150000), + SPH_C32(0xcfe05664), SPH_C32(0x513a985c), SPH_C32(0x2daf8eba), + SPH_C32(0x87f9a24f) }, + { SPH_C32(0x180d0000), SPH_C32(0x46a60003), SPH_C32(0x6cbf6000), + SPH_C32(0xf6870000), SPH_C32(0xb3112fd7), SPH_C32(0x5062ebbc), + SPH_C32(0x59e01f21), SPH_C32(0x05aa94f6), SPH_C32(0x5d5c0000), + SPH_C32(0x36100002), SPH_C32(0xa8302000), SPH_C32(0x19b70000), + SPH_C32(0x5f9b0c57), SPH_C32(0x0cf1fcdb), SPH_C32(0x908b2232), + SPH_C32(0xfe716097) }, + { SPH_C32(0xb4450000), SPH_C32(0x5d000003), SPH_C32(0x29447380), + SPH_C32(0xf5c40000), SPH_C32(0xe9941ebd), SPH_C32(0x4fd0bb0a), + SPH_C32(0xa792d8df), SPH_C32(0x944eec00), SPH_C32(0x43120000), + SPH_C32(0xe8df0002), SPH_C32(0xc5c82180), SPH_C32(0x6e930000), + SPH_C32(0xb3dc0bc9), SPH_C32(0xf8519595), SPH_C32(0x5d283a20), + SPH_C32(0x66db29f9) }, + { SPH_C32(0x06430000), SPH_C32(0x98690003), SPH_C32(0x01476180), + SPH_C32(0x81a30000), SPH_C32(0x5f562849), SPH_C32(0xa4c282f2), + SPH_C32(0x94430733), SPH_C32(0x9d00dd98), SPH_C32(0xef5a0000), + SPH_C32(0xf3790002), SPH_C32(0x80333200), SPH_C32(0x6dd00000), + SPH_C32(0xe9593aa3), SPH_C32(0xe7e3c523), SPH_C32(0xa35afdde), + SPH_C32(0xf73f510f) }, + { SPH_C32(0xaa0b0000), SPH_C32(0x83cf0003), SPH_C32(0x44bc7200), + SPH_C32(0x82e00000), SPH_C32(0x05d31923), SPH_C32(0xbb70d244), + SPH_C32(0x6a31c0cd), SPH_C32(0x0ce4a56e), SPH_C32(0xf1140000), + SPH_C32(0x2db60002), SPH_C32(0xedcb3380), SPH_C32(0x1af40000), + SPH_C32(0x051e3d3d), SPH_C32(0x1343ac6d), SPH_C32(0x6ef9e5cc), + SPH_C32(0x6f951861) }, + { SPH_C32(0x6deb0000), SPH_C32(0xd3c00002), SPH_C32(0x5cc44000), + SPH_C32(0x5b730000), SPH_C32(0x3c23313d), SPH_C32(0x744b68bb), + SPH_C32(0xb12483d8), SPH_C32(0x4ed478a3), SPH_C32(0xf39f0000), + SPH_C32(0xaa5f0003), SPH_C32(0xd1e1c000), SPH_C32(0x35a20000), + SPH_C32(0x1a5779e4), SPH_C32(0x6aa14bed), SPH_C32(0x3b19d5bd), + SPH_C32(0x5d6336ec) }, + { SPH_C32(0xc1a30000), SPH_C32(0xc8660002), SPH_C32(0x193f5380), + SPH_C32(0x58300000), SPH_C32(0x66a60057), SPH_C32(0x6bf9380d), + SPH_C32(0x4f564426), SPH_C32(0xdf300055), SPH_C32(0xedd10000), + SPH_C32(0x74900003), SPH_C32(0xbc19c180), SPH_C32(0x42860000), + SPH_C32(0xf6107e7a), SPH_C32(0x9e0122a3), SPH_C32(0xf6bacdaf), + SPH_C32(0xc5c97f82) }, + { SPH_C32(0x73a50000), SPH_C32(0x0d0f0002), SPH_C32(0x313c4180), + SPH_C32(0x2c570000), SPH_C32(0xd06436a3), SPH_C32(0x80eb01f5), + SPH_C32(0x7c879bca), SPH_C32(0xd67e31cd), SPH_C32(0x41990000), + SPH_C32(0x6f360003), SPH_C32(0xf9e2d200), SPH_C32(0x41c50000), + SPH_C32(0xac954f10), SPH_C32(0x81b37215), SPH_C32(0x08c80a51), + SPH_C32(0x542d0774) }, + { SPH_C32(0xdfed0000), SPH_C32(0x16a90002), SPH_C32(0x74c75200), + SPH_C32(0x2f140000), SPH_C32(0x8ae107c9), SPH_C32(0x9f595143), + SPH_C32(0x82f55c34), SPH_C32(0x479a493b), SPH_C32(0x5fd70000), + SPH_C32(0xb1f90003), SPH_C32(0x941ad380), SPH_C32(0x36e10000), + SPH_C32(0x40d2488e), SPH_C32(0x75131b5b), SPH_C32(0xc56b1243), + SPH_C32(0xcc874e1a) }, + { SPH_C32(0xc3280000), SPH_C32(0x4f8f0003), SPH_C32(0x2515a000), + SPH_C32(0x77660000), SPH_C32(0x79ef448e), SPH_C32(0x121bdf8d), + SPH_C32(0x1ab67457), SPH_C32(0xedc62ed8), SPH_C32(0x28ba0000), + SPH_C32(0xa3760003), SPH_C32(0x984b0000), SPH_C32(0xb4430000), + SPH_C32(0xd0a912bd), SPH_C32(0x28d87fdc), SPH_C32(0x784fbecb), + SPH_C32(0xb50f8cc2) }, + { SPH_C32(0x6f600000), SPH_C32(0x54290003), SPH_C32(0x60eeb380), + SPH_C32(0x74250000), SPH_C32(0x236a75e4), SPH_C32(0x0da98f3b), + SPH_C32(0xe4c4b3a9), SPH_C32(0x7c22562e), SPH_C32(0x36f40000), + SPH_C32(0x7db90003), SPH_C32(0xf5b30180), SPH_C32(0xc3670000), + SPH_C32(0x3cee1523), SPH_C32(0xdc781692), SPH_C32(0xb5eca6d9), + SPH_C32(0x2da5c5ac) }, + { SPH_C32(0xdd660000), SPH_C32(0x91400003), SPH_C32(0x48eda180), + SPH_C32(0x00420000), SPH_C32(0x95a84310), SPH_C32(0xe6bbb6c3), + SPH_C32(0xd7156c45), SPH_C32(0x756c67b6), SPH_C32(0x9abc0000), + SPH_C32(0x661f0003), SPH_C32(0xb0481200), SPH_C32(0xc0240000), + SPH_C32(0x666b2449), SPH_C32(0xc3ca4624), SPH_C32(0x4b9e6127), + SPH_C32(0xbc41bd5a) }, + { SPH_C32(0x712e0000), SPH_C32(0x8ae60003), SPH_C32(0x0d16b200), + SPH_C32(0x03010000), SPH_C32(0xcf2d727a), SPH_C32(0xf909e675), + SPH_C32(0x2967abbb), SPH_C32(0xe4881f40), SPH_C32(0x84f20000), + SPH_C32(0xb8d00003), SPH_C32(0xddb01380), SPH_C32(0xb7000000), + SPH_C32(0x8a2c23d7), SPH_C32(0x376a2f6a), SPH_C32(0x863d7935), + SPH_C32(0x24ebf434) } +}; + +static const sph_u32 T512_36[64][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x52500000), SPH_C32(0x29540000), SPH_C32(0x6a61004e), + SPH_C32(0xf0ff0000), SPH_C32(0x9a317eec), SPH_C32(0x452341ce), + SPH_C32(0xcf568fe5), SPH_C32(0x5303130f), SPH_C32(0x538d0000), + SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), SPH_C32(0x56ff0000), + SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), SPH_C32(0xa9444018), + SPH_C32(0x7f975691) }, + { SPH_C32(0x538d0000), SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), + SPH_C32(0x56ff0000), SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), + SPH_C32(0xa9444018), SPH_C32(0x7f975691), SPH_C32(0x01dd0000), + SPH_C32(0x80a80000), SPH_C32(0xf4960048), SPH_C32(0xa6000000), + SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), SPH_C32(0x6612cffd), + SPH_C32(0x2c94459e) }, + { SPH_C32(0x01dd0000), SPH_C32(0x80a80000), SPH_C32(0xf4960048), + SPH_C32(0xa6000000), SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), + SPH_C32(0x6612cffd), SPH_C32(0x2c94459e), SPH_C32(0x52500000), + SPH_C32(0x29540000), SPH_C32(0x6a61004e), SPH_C32(0xf0ff0000), + SPH_C32(0x9a317eec), SPH_C32(0x452341ce), SPH_C32(0xcf568fe5), + SPH_C32(0x5303130f) }, + { SPH_C32(0xcc140000), SPH_C32(0xa5630000), SPH_C32(0x5ab90780), + SPH_C32(0x3b500000), SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), + SPH_C32(0x694348c1), SPH_C32(0xca5a87fe), SPH_C32(0x819e0000), + SPH_C32(0xec570000), SPH_C32(0x66320280), SPH_C32(0x95f30000), + SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), SPH_C32(0xe65aa22d), + SPH_C32(0x8e67b7fa) }, + { SPH_C32(0x9e440000), SPH_C32(0x8c370000), SPH_C32(0x30d807ce), + SPH_C32(0xcbaf0000), SPH_C32(0xd1e16d13), SPH_C32(0xc2b875d6), + SPH_C32(0xa615c724), SPH_C32(0x995994f1), SPH_C32(0xd2130000), + SPH_C32(0x45ab0000), SPH_C32(0xf8c50286), SPH_C32(0xc30c0000), + SPH_C32(0x574d284c), SPH_C32(0xda31f145), SPH_C32(0x4f1ee235), + SPH_C32(0xf1f0e16b) }, + { SPH_C32(0x9f990000), SPH_C32(0x0c9f0000), SPH_C32(0xc44e0786), + SPH_C32(0x6daf0000), SPH_C32(0x413413b1), SPH_C32(0x155ef9e1), + SPH_C32(0xc00708d9), SPH_C32(0xb5cdd16f), SPH_C32(0x80430000), + SPH_C32(0x6cff0000), SPH_C32(0x92a402c8), SPH_C32(0x33f30000), + SPH_C32(0xcd7c56a0), SPH_C32(0x9f12b08b), SPH_C32(0x80486dd0), + SPH_C32(0xa2f3f264) }, + { SPH_C32(0xcdc90000), SPH_C32(0x25cb0000), SPH_C32(0xae2f07c8), + SPH_C32(0x9d500000), SPH_C32(0xdb056d5d), SPH_C32(0x507db82f), + SPH_C32(0x0f51873c), SPH_C32(0xe6cec260), SPH_C32(0xd3ce0000), + SPH_C32(0xc5030000), SPH_C32(0x0c5302ce), SPH_C32(0x650c0000), + SPH_C32(0xc79856ee), SPH_C32(0x0dd77d72), SPH_C32(0x290c2dc8), + SPH_C32(0xdd64a4f5) }, + { SPH_C32(0x819e0000), SPH_C32(0xec570000), SPH_C32(0x66320280), + SPH_C32(0x95f30000), SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), + SPH_C32(0xe65aa22d), SPH_C32(0x8e67b7fa), SPH_C32(0x4d8a0000), + SPH_C32(0x49340000), SPH_C32(0x3c8b0500), SPH_C32(0xaea30000), + SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), SPH_C32(0x8f19eaec), + SPH_C32(0x443d3004) }, + { SPH_C32(0xd3ce0000), SPH_C32(0xc5030000), SPH_C32(0x0c5302ce), + SPH_C32(0x650c0000), SPH_C32(0xc79856ee), SPH_C32(0x0dd77d72), + SPH_C32(0x290c2dc8), SPH_C32(0xdd64a4f5), SPH_C32(0x1e070000), + SPH_C32(0xe0c80000), SPH_C32(0xa27c0506), SPH_C32(0xf85c0000), + SPH_C32(0x1c9d3bb3), SPH_C32(0x5daac55d), SPH_C32(0x265daaf4), + SPH_C32(0x3baa6695) }, + { SPH_C32(0xd2130000), SPH_C32(0x45ab0000), SPH_C32(0xf8c50286), + SPH_C32(0xc30c0000), SPH_C32(0x574d284c), SPH_C32(0xda31f145), + SPH_C32(0x4f1ee235), SPH_C32(0xf1f0e16b), SPH_C32(0x4c570000), + SPH_C32(0xc99c0000), SPH_C32(0xc81d0548), SPH_C32(0x08a30000), + SPH_C32(0x86ac455f), SPH_C32(0x18898493), SPH_C32(0xe90b2511), + SPH_C32(0x68a9759a) }, + { SPH_C32(0x80430000), SPH_C32(0x6cff0000), SPH_C32(0x92a402c8), + SPH_C32(0x33f30000), SPH_C32(0xcd7c56a0), SPH_C32(0x9f12b08b), + SPH_C32(0x80486dd0), SPH_C32(0xa2f3f264), SPH_C32(0x1fda0000), + SPH_C32(0x60600000), SPH_C32(0x56ea054e), SPH_C32(0x5e5c0000), + SPH_C32(0x8c484511), SPH_C32(0x8a4c496a), SPH_C32(0x404f6509), + SPH_C32(0x173e230b) }, + { SPH_C32(0x4d8a0000), SPH_C32(0x49340000), SPH_C32(0x3c8b0500), + SPH_C32(0xaea30000), SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), + SPH_C32(0x8f19eaec), SPH_C32(0x443d3004), SPH_C32(0xcc140000), + SPH_C32(0xa5630000), SPH_C32(0x5ab90780), SPH_C32(0x3b500000), + SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), SPH_C32(0x694348c1), + SPH_C32(0xca5a87fe) }, + { SPH_C32(0x1fda0000), SPH_C32(0x60600000), SPH_C32(0x56ea054e), + SPH_C32(0x5e5c0000), SPH_C32(0x8c484511), SPH_C32(0x8a4c496a), + SPH_C32(0x404f6509), SPH_C32(0x173e230b), SPH_C32(0x9f990000), + SPH_C32(0x0c9f0000), SPH_C32(0xc44e0786), SPH_C32(0x6daf0000), + SPH_C32(0x413413b1), SPH_C32(0x155ef9e1), SPH_C32(0xc00708d9), + SPH_C32(0xb5cdd16f) }, + { SPH_C32(0x1e070000), SPH_C32(0xe0c80000), SPH_C32(0xa27c0506), + SPH_C32(0xf85c0000), SPH_C32(0x1c9d3bb3), SPH_C32(0x5daac55d), + SPH_C32(0x265daaf4), SPH_C32(0x3baa6695), SPH_C32(0xcdc90000), + SPH_C32(0x25cb0000), SPH_C32(0xae2f07c8), SPH_C32(0x9d500000), + SPH_C32(0xdb056d5d), SPH_C32(0x507db82f), SPH_C32(0x0f51873c), + SPH_C32(0xe6cec260) }, + { SPH_C32(0x4c570000), SPH_C32(0xc99c0000), SPH_C32(0xc81d0548), + SPH_C32(0x08a30000), SPH_C32(0x86ac455f), SPH_C32(0x18898493), + SPH_C32(0xe90b2511), SPH_C32(0x68a9759a), SPH_C32(0x9e440000), + SPH_C32(0x8c370000), SPH_C32(0x30d807ce), SPH_C32(0xcbaf0000), + SPH_C32(0xd1e16d13), SPH_C32(0xc2b875d6), SPH_C32(0xa615c724), + SPH_C32(0x995994f1) }, + { SPH_C32(0x78230000), SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), + SPH_C32(0x90a50000), SPH_C32(0x713e2879), SPH_C32(0x7ee98924), + SPH_C32(0xf08ca062), SPH_C32(0x636f8bab), SPH_C32(0x02af0000), + SPH_C32(0xb7280000), SPH_C32(0xba1c0300), SPH_C32(0x56980000), + SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), SPH_C32(0xa95c149a), + SPH_C32(0xf4f6ea7b) }, + { SPH_C32(0x2a730000), SPH_C32(0x3ba80000), SPH_C32(0xc35b0bce), + SPH_C32(0x605a0000), SPH_C32(0xeb0f5695), SPH_C32(0x3bcac8ea), + SPH_C32(0x3fda2f87), SPH_C32(0x306c98a4), SPH_C32(0x51220000), + SPH_C32(0x1ed40000), SPH_C32(0x24eb0306), SPH_C32(0x00670000), + SPH_C32(0xb069459d), SPH_C32(0x128d0b9e), SPH_C32(0x00185482), + SPH_C32(0x8b61bcea) }, + { SPH_C32(0x2bae0000), SPH_C32(0xbb000000), SPH_C32(0x37cd0b86), + SPH_C32(0xc65a0000), SPH_C32(0x7bda2837), SPH_C32(0xec2c44dd), + SPH_C32(0x59c8e07a), SPH_C32(0x1cf8dd3a), SPH_C32(0x03720000), + SPH_C32(0x37800000), SPH_C32(0x4e8a0348), SPH_C32(0xf0980000), + SPH_C32(0x2a583b71), SPH_C32(0x57ae4a50), SPH_C32(0xcf4edb67), + SPH_C32(0xd862afe5) }, + { SPH_C32(0x79fe0000), SPH_C32(0x92540000), SPH_C32(0x5dac0bc8), + SPH_C32(0x36a50000), SPH_C32(0xe1eb56db), SPH_C32(0xa90f0513), + SPH_C32(0x969e6f9f), SPH_C32(0x4ffbce35), SPH_C32(0x50ff0000), + SPH_C32(0x9e7c0000), SPH_C32(0xd07d034e), SPH_C32(0xa6670000), + SPH_C32(0x20bc3b3f), SPH_C32(0xc56b87a9), SPH_C32(0x660a9b7f), + SPH_C32(0xa7f5f974) }, + { SPH_C32(0xb4370000), SPH_C32(0xb79f0000), SPH_C32(0xf3830c00), + SPH_C32(0xabf50000), SPH_C32(0x3aee3b86), SPH_C32(0xf972bd3c), + SPH_C32(0x99cfe8a3), SPH_C32(0xa9350c55), SPH_C32(0x83310000), + SPH_C32(0x5b7f0000), SPH_C32(0xdc2e0180), SPH_C32(0xc36b0000), + SPH_C32(0xe7246dd1), SPH_C32(0xc8bcfadb), SPH_C32(0x4f06b6b7), + SPH_C32(0x7a915d81) }, + { SPH_C32(0xe6670000), SPH_C32(0x9ecb0000), SPH_C32(0x99e20c4e), + SPH_C32(0x5b0a0000), SPH_C32(0xa0df456a), SPH_C32(0xbc51fcf2), + SPH_C32(0x56996746), SPH_C32(0xfa361f5a), SPH_C32(0xd0bc0000), + SPH_C32(0xf2830000), SPH_C32(0x42d90186), SPH_C32(0x95940000), + SPH_C32(0xedc06d9f), SPH_C32(0x5a793722), SPH_C32(0xe642f6af), + SPH_C32(0x05060b10) }, + { SPH_C32(0xe7ba0000), SPH_C32(0x1e630000), SPH_C32(0x6d740c06), + SPH_C32(0xfd0a0000), SPH_C32(0x300a3bc8), SPH_C32(0x6bb770c5), + SPH_C32(0x308ba8bb), SPH_C32(0xd6a25ac4), SPH_C32(0x82ec0000), + SPH_C32(0xdbd70000), SPH_C32(0x28b801c8), SPH_C32(0x656b0000), + SPH_C32(0x77f11373), SPH_C32(0x1f5a76ec), SPH_C32(0x2914794a), + SPH_C32(0x5605181f) }, + { SPH_C32(0xb5ea0000), SPH_C32(0x37370000), SPH_C32(0x07150c48), + SPH_C32(0x0df50000), SPH_C32(0xaa3b4524), SPH_C32(0x2e94310b), + SPH_C32(0xffdd275e), SPH_C32(0x85a149cb), SPH_C32(0xd1610000), + SPH_C32(0x722b0000), SPH_C32(0xb64f01ce), SPH_C32(0x33940000), + SPH_C32(0x7d15133d), SPH_C32(0x8d9fbb15), SPH_C32(0x80503952), + SPH_C32(0x29924e8e) }, + { SPH_C32(0xf9bd0000), SPH_C32(0xfeab0000), SPH_C32(0xcf080900), + SPH_C32(0x05560000), SPH_C32(0x2c97007b), SPH_C32(0x361db598), + SPH_C32(0x16d6024f), SPH_C32(0xed083c51), SPH_C32(0x4f250000), + SPH_C32(0xfe1c0000), SPH_C32(0x496970600), SPH_C32(0xf83b0000), + SPH_C32(0xacf47e2e), SPH_C32(0x4f27cec3), SPH_C32(0x2645fe76), + SPH_C32(0xb0cbda7f) }, + { SPH_C32(0xabed0000), SPH_C32(0xd7ff0000), SPH_C32(0xa569094e), + SPH_C32(0xf5a90000), SPH_C32(0xb6a67e97), SPH_C32(0x733ef456), + SPH_C32(0xd9808daa), SPH_C32(0xbe0b2f5e), SPH_C32(0x1ca80000), + SPH_C32(0x57e00000), SPH_C32(0x18600606), SPH_C32(0xaec40000), + SPH_C32(0xa6107e60), SPH_C32(0xdde2033a), SPH_C32(0x8f01be6e), + SPH_C32(0xcf5c8cee) }, + { SPH_C32(0xaa300000), SPH_C32(0x57570000), SPH_C32(0x51ff0906), + SPH_C32(0x53a90000), SPH_C32(0x26730035), SPH_C32(0xa4d87861), + SPH_C32(0xbf924257), SPH_C32(0x929f6ac0), SPH_C32(0x4ef80000), + SPH_C32(0x7eb40000), SPH_C32(0x72010648), SPH_C32(0x5e3b0000), + SPH_C32(0x3c21008c), SPH_C32(0x98c142f4), SPH_C32(0x4057318b), + SPH_C32(0x9c5f9fe1) }, + { SPH_C32(0xf8600000), SPH_C32(0x7e030000), SPH_C32(0x3b9e0948), + SPH_C32(0xa3560000), SPH_C32(0xbc427ed9), SPH_C32(0xe1fb39af), + SPH_C32(0x70c4cdb2), SPH_C32(0xc19c79cf), SPH_C32(0x1d750000), + SPH_C32(0xd7480000), SPH_C32(0xecf6064e), SPH_C32(0x08c40000), + SPH_C32(0x36c500c2), SPH_C32(0x0a048f0d), SPH_C32(0xe9137193), + SPH_C32(0xe3c8c970) }, + { SPH_C32(0x35a90000), SPH_C32(0x5bc80000), SPH_C32(0x95b10e80), + SPH_C32(0x3e060000), SPH_C32(0x67471384), SPH_C32(0xb1868180), + SPH_C32(0x7f954a8e), SPH_C32(0x2752bbaf), SPH_C32(0xcebb0000), + SPH_C32(0x124b0000), SPH_C32(0xe0a50480), SPH_C32(0x6dc80000), + SPH_C32(0xf15d562c), SPH_C32(0x07d3f27f), SPH_C32(0xc01f5c5b), + SPH_C32(0x3eac6d85) }, + { SPH_C32(0x67f90000), SPH_C32(0x729c0000), SPH_C32(0xffd00ece), + SPH_C32(0xcef90000), SPH_C32(0xfd766d68), SPH_C32(0xf4a5c04e), + SPH_C32(0xb0c3c56b), SPH_C32(0x7451a8a0), SPH_C32(0x9d360000), + SPH_C32(0xbbb70000), SPH_C32(0x7e520486), SPH_C32(0x3b370000), + SPH_C32(0xfbb95662), SPH_C32(0x95163f86), SPH_C32(0x695b1c43), + SPH_C32(0x413b3b14) }, + { SPH_C32(0x66240000), SPH_C32(0xf2340000), SPH_C32(0x0b460e86), + SPH_C32(0x68f90000), SPH_C32(0x6da313ca), SPH_C32(0x23434c79), + SPH_C32(0xd6d10a96), SPH_C32(0x58c5ed3e), SPH_C32(0xcf660000), + SPH_C32(0x92e30000), SPH_C32(0x143304c8), SPH_C32(0xcbc80000), + SPH_C32(0x6188288e), SPH_C32(0xd0357e48), SPH_C32(0xa60d93a6), + SPH_C32(0x1238281b) }, + { SPH_C32(0x34740000), SPH_C32(0xdb600000), SPH_C32(0x61270ec8), + SPH_C32(0x98060000), SPH_C32(0xf7926d26), SPH_C32(0x66600db7), + SPH_C32(0x19878573), SPH_C32(0x0bc6fe31), SPH_C32(0x9ceb0000), + SPH_C32(0x3b1f0000), SPH_C32(0x8ac404ce), SPH_C32(0x9d370000), + SPH_C32(0x6b6c28c0), SPH_C32(0x42f0b3b1), SPH_C32(0x0f49d3be), + SPH_C32(0x6daf7e8a) }, + { SPH_C32(0x02af0000), SPH_C32(0xb7280000), SPH_C32(0xba1c0300), + SPH_C32(0x56980000), SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), + SPH_C32(0xa95c149a), SPH_C32(0xf4f6ea7b), SPH_C32(0x7a8c0000), + SPH_C32(0xa5d40000), SPH_C32(0x13260880), SPH_C32(0xc63d0000), + SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), SPH_C32(0x59d0b4f8), + SPH_C32(0x979961d0) }, + { SPH_C32(0x50ff0000), SPH_C32(0x9e7c0000), SPH_C32(0xd07d034e), + SPH_C32(0xa6670000), SPH_C32(0x20bc3b3f), SPH_C32(0xc56b87a9), + SPH_C32(0x660a9b7f), SPH_C32(0xa7f5f974), SPH_C32(0x29010000), + SPH_C32(0x0c280000), SPH_C32(0x8dd10886), SPH_C32(0x90c20000), + SPH_C32(0xc1576de4), SPH_C32(0x6c6482ba), SPH_C32(0xf094f4e0), + SPH_C32(0xe80e3741) }, + { SPH_C32(0x51220000), SPH_C32(0x1ed40000), SPH_C32(0x24eb0306), + SPH_C32(0x00670000), SPH_C32(0xb069459d), SPH_C32(0x128d0b9e), + SPH_C32(0x00185482), SPH_C32(0x8b61bcea), SPH_C32(0x7b510000), + SPH_C32(0x257c0000), SPH_C32(0xe7b008c8), SPH_C32(0x603d0000), + SPH_C32(0x5b661308), SPH_C32(0x2947c374), SPH_C32(0x3fc27b05), + SPH_C32(0xbb0d244e) }, + { SPH_C32(0x03720000), SPH_C32(0x37800000), SPH_C32(0x4e8a0348), + SPH_C32(0xf0980000), SPH_C32(0x2a583b71), SPH_C32(0x57ae4a50), + SPH_C32(0xcf4edb67), SPH_C32(0xd862afe5), SPH_C32(0x28dc0000), + SPH_C32(0x8c800000), SPH_C32(0x794708ce), SPH_C32(0x36c20000), + SPH_C32(0x51821346), SPH_C32(0xbb820e8d), SPH_C32(0x96863b1d), + SPH_C32(0xc49a72df) }, + { SPH_C32(0xcebb0000), SPH_C32(0x124b0000), SPH_C32(0xe0a50480), + SPH_C32(0x6dc80000), SPH_C32(0xf15d562c), SPH_C32(0x07d3f27f), + SPH_C32(0xc01f5c5b), SPH_C32(0x3eac6d85), SPH_C32(0xfb120000), + SPH_C32(0x49830000), SPH_C32(0x75140a00), SPH_C32(0x53ce0000), + SPH_C32(0x961a45a8), SPH_C32(0xb65573ff), SPH_C32(0xbf8a16d5), + SPH_C32(0x19fed62a) }, + { SPH_C32(0x9ceb0000), SPH_C32(0x3b1f0000), SPH_C32(0x8ac404ce), + SPH_C32(0x9d370000), SPH_C32(0x6b6c28c0), SPH_C32(0x42f0b3b1), + SPH_C32(0x0f49d3be), SPH_C32(0x6daf7e8a), SPH_C32(0xa89f0000), + SPH_C32(0xe07f0000), SPH_C32(0xebe30a06), SPH_C32(0x05310000), + SPH_C32(0x9cfe45e6), SPH_C32(0x2490be06), SPH_C32(0x16ce56cd), + SPH_C32(0x666980bb) }, + { SPH_C32(0x9d360000), SPH_C32(0xbbb70000), SPH_C32(0x7e520486), + SPH_C32(0x3b370000), SPH_C32(0xfbb95662), SPH_C32(0x95163f86), + SPH_C32(0x695b1c43), SPH_C32(0x413b3b14), SPH_C32(0xfacf0000), + SPH_C32(0xc92b0000), SPH_C32(0x81820a48), SPH_C32(0xf5ce0000), + SPH_C32(0x06cf3b0a), SPH_C32(0x61b3ffc8), SPH_C32(0xd998d928), + SPH_C32(0x356a93b4) }, + { SPH_C32(0xcf660000), SPH_C32(0x92e30000), SPH_C32(0x143304c8), + SPH_C32(0xcbc80000), SPH_C32(0x6188288e), SPH_C32(0xd0357e48), + SPH_C32(0xa60d93a6), SPH_C32(0x1238281b), SPH_C32(0xa9420000), + SPH_C32(0x60d70000), SPH_C32(0x1f750a4e), SPH_C32(0xa3310000), + SPH_C32(0x0c2b3b44), SPH_C32(0xf3763231), SPH_C32(0x70dc9930), + SPH_C32(0x4afdc525) }, + { SPH_C32(0x83310000), SPH_C32(0x5b7f0000), SPH_C32(0xdc2e0180), + SPH_C32(0xc36b0000), SPH_C32(0xe7246dd1), SPH_C32(0xc8bcfadb), + SPH_C32(0x4f06b6b7), SPH_C32(0x7a915d81), SPH_C32(0x37060000), + SPH_C32(0xece00000), SPH_C32(0x2fad0d80), SPH_C32(0x689e0000), + SPH_C32(0xddca5657), SPH_C32(0x31ce47e7), SPH_C32(0xd6c95e14), + SPH_C32(0xd3a451d4) }, + { SPH_C32(0xd1610000), SPH_C32(0x722b0000), SPH_C32(0xb64f01ce), + SPH_C32(0x33940000), SPH_C32(0x7d15133d), SPH_C32(0x8d9fbb15), + SPH_C32(0x80503952), SPH_C32(0x29924e8e), SPH_C32(0x648b0000), + SPH_C32(0x451c0000), SPH_C32(0xb15a0d86), SPH_C32(0x3e610000), + SPH_C32(0xd72e5619), SPH_C32(0xa30b8a1e), SPH_C32(0x7f8d1e0c), + SPH_C32(0xac330745) }, + { SPH_C32(0xd0bc0000), SPH_C32(0xf2830000), SPH_C32(0x42d90186), + SPH_C32(0x95940000), SPH_C32(0xedc06d9f), SPH_C32(0x5a793722), + SPH_C32(0xe642f6af), SPH_C32(0x05060b10), SPH_C32(0x36db0000), + SPH_C32(0x6c480000), SPH_C32(0xdb3b0dc8), SPH_C32(0xce9e0000), + SPH_C32(0x4d1f28f5), SPH_C32(0xe628cbd0), SPH_C32(0xb0db91e9), + SPH_C32(0xff30144a) }, + { SPH_C32(0x82ec0000), SPH_C32(0xdbd70000), SPH_C32(0x28b801c8), + SPH_C32(0x656b0000), SPH_C32(0x77f11373), SPH_C32(0x1f5a76ec), + SPH_C32(0x2914794a), SPH_C32(0x5605181f), SPH_C32(0x65560000), + SPH_C32(0xc5b40000), SPH_C32(0x45cc0dce), SPH_C32(0x98610000), + SPH_C32(0x47fb28bb), SPH_C32(0x74ed0629), SPH_C32(0x199fd1f1), + SPH_C32(0x80a742db) }, + { SPH_C32(0x4f250000), SPH_C32(0xfe1c0000), SPH_C32(0x496970600), + SPH_C32(0xf83b0000), SPH_C32(0xacf47e2e), SPH_C32(0x4f27cec3), + SPH_C32(0x2645fe76), SPH_C32(0xb0cbda7f), SPH_C32(0xb6980000), + SPH_C32(0x00b70000), SPH_C32(0x499f0f00), SPH_C32(0xfd6d0000), + SPH_C32(0x80637e55), SPH_C32(0x793a7b5b), SPH_C32(0x3093fc39), + SPH_C32(0x5dc3e62e) }, + { SPH_C32(0x1d750000), SPH_C32(0xd7480000), SPH_C32(0xecf6064e), + SPH_C32(0x08c40000), SPH_C32(0x36c500c2), SPH_C32(0x0a048f0d), + SPH_C32(0xe9137193), SPH_C32(0xe3c8c970), SPH_C32(0xe5150000), + SPH_C32(0xa94b0000), SPH_C32(0xd7680f06), SPH_C32(0xab920000), + SPH_C32(0x8a877e1b), SPH_C32(0xebffb6a2), SPH_C32(0x99d7bc21), + SPH_C32(0x2254b0bf) }, + { SPH_C32(0x1ca80000), SPH_C32(0x57e00000), SPH_C32(0x18600606), + SPH_C32(0xaec40000), SPH_C32(0xa6107e60), SPH_C32(0xdde2033a), + SPH_C32(0x8f01be6e), SPH_C32(0xcf5c8cee), SPH_C32(0xb7450000), + SPH_C32(0x801f0000), SPH_C32(0xbd090f48), SPH_C32(0x5b6d0000), + SPH_C32(0x10b600f7), SPH_C32(0xaedcf76c), SPH_C32(0x568133c4), + SPH_C32(0x7157a3b0) }, + { SPH_C32(0x4ef80000), SPH_C32(0x7eb40000), SPH_C32(0x72010648), + SPH_C32(0x5e3b0000), SPH_C32(0x3c21008c), SPH_C32(0x98c142f4), + SPH_C32(0x4057318b), SPH_C32(0x9c5f9fe1), SPH_C32(0xe4c80000), + SPH_C32(0x29e30000), SPH_C32(0x23fe0f4e), SPH_C32(0x0d920000), + SPH_C32(0x1a5200b9), SPH_C32(0x3c193a95), SPH_C32(0xffc573dc), + SPH_C32(0x0ec0f521) }, + { SPH_C32(0x7a8c0000), SPH_C32(0xa5d40000), SPH_C32(0x13260880), + SPH_C32(0xc63d0000), SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), + SPH_C32(0x59d0b4f8), SPH_C32(0x979961d0), SPH_C32(0x78230000), + SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), SPH_C32(0x90a50000), + SPH_C32(0x713e2879), SPH_C32(0x7ee98924), SPH_C32(0xf08ca062), + SPH_C32(0x636f8bab) }, + { SPH_C32(0x28dc0000), SPH_C32(0x8c800000), SPH_C32(0x794708ce), + SPH_C32(0x36c20000), SPH_C32(0x51821346), SPH_C32(0xbb820e8d), + SPH_C32(0x96863b1d), SPH_C32(0xc49a72df), SPH_C32(0x2bae0000), + SPH_C32(0xbb000000), SPH_C32(0x37cd0b86), SPH_C32(0xc65a0000), + SPH_C32(0x7bda2837), SPH_C32(0xec2c44dd), SPH_C32(0x59c8e07a), + SPH_C32(0x1cf8dd3a) }, + { SPH_C32(0x29010000), SPH_C32(0x0c280000), SPH_C32(0x8dd10886), + SPH_C32(0x90c20000), SPH_C32(0xc1576de4), SPH_C32(0x6c6482ba), + SPH_C32(0xf094f4e0), SPH_C32(0xe80e3741), SPH_C32(0x79fe0000), + SPH_C32(0x92540000), SPH_C32(0x5dac0bc8), SPH_C32(0x36a50000), + SPH_C32(0xe1eb56db), SPH_C32(0xa90f0513), SPH_C32(0x969e6f9f), + SPH_C32(0x4ffbce35) }, + { SPH_C32(0x7b510000), SPH_C32(0x257c0000), SPH_C32(0xe7b008c8), + SPH_C32(0x603d0000), SPH_C32(0x5b661308), SPH_C32(0x2947c374), + SPH_C32(0x3fc27b05), SPH_C32(0xbb0d244e), SPH_C32(0x2a730000), + SPH_C32(0x3ba80000), SPH_C32(0xc35b0bce), SPH_C32(0x605a0000), + SPH_C32(0xeb0f5695), SPH_C32(0x3bcac8ea), SPH_C32(0x3fda2f87), + SPH_C32(0x306c98a4) }, + { SPH_C32(0xb6980000), SPH_C32(0x00b70000), SPH_C32(0x499f0f00), + SPH_C32(0xfd6d0000), SPH_C32(0x80637e55), SPH_C32(0x793a7b5b), + SPH_C32(0x3093fc39), SPH_C32(0x5dc3e62e), SPH_C32(0xf9bd0000), + SPH_C32(0xfeab0000), SPH_C32(0xcf080900), SPH_C32(0x05560000), + SPH_C32(0x2c97007b), SPH_C32(0x361db598), SPH_C32(0x16d6024f), + SPH_C32(0xed083c51) }, + { SPH_C32(0xe4c80000), SPH_C32(0x29e30000), SPH_C32(0x23fe0f4e), + SPH_C32(0x0d920000), SPH_C32(0x1a5200b9), SPH_C32(0x3c193a95), + SPH_C32(0xffc573dc), SPH_C32(0x0ec0f521), SPH_C32(0xaa300000), + SPH_C32(0x57570000), SPH_C32(0x51ff0906), SPH_C32(0x53a90000), + SPH_C32(0x26730035), SPH_C32(0xa4d87861), SPH_C32(0xbf924257), + SPH_C32(0x929f6ac0) }, + { SPH_C32(0xe5150000), SPH_C32(0xa94b0000), SPH_C32(0xd7680f06), + SPH_C32(0xab920000), SPH_C32(0x8a877e1b), SPH_C32(0xebffb6a2), + SPH_C32(0x99d7bc21), SPH_C32(0x2254b0bf), SPH_C32(0xf8600000), + SPH_C32(0x7e030000), SPH_C32(0x3b9e0948), SPH_C32(0xa3560000), + SPH_C32(0xbc427ed9), SPH_C32(0xe1fb39af), SPH_C32(0x70c4cdb2), + SPH_C32(0xc19c79cf) }, + { SPH_C32(0xb7450000), SPH_C32(0x801f0000), SPH_C32(0xbd090f48), + SPH_C32(0x5b6d0000), SPH_C32(0x10b600f7), SPH_C32(0xaedcf76c), + SPH_C32(0x568133c4), SPH_C32(0x7157a3b0), SPH_C32(0xabed0000), + SPH_C32(0xd7ff0000), SPH_C32(0xa569094e), SPH_C32(0xf5a90000), + SPH_C32(0xb6a67e97), SPH_C32(0x733ef456), SPH_C32(0xd9808daa), + SPH_C32(0xbe0b2f5e) }, + { SPH_C32(0xfb120000), SPH_C32(0x49830000), SPH_C32(0x75140a00), + SPH_C32(0x53ce0000), SPH_C32(0x961a45a8), SPH_C32(0xb65573ff), + SPH_C32(0xbf8a16d5), SPH_C32(0x19fed62a), SPH_C32(0x35a90000), + SPH_C32(0x5bc80000), SPH_C32(0x95b10e80), SPH_C32(0x3e060000), + SPH_C32(0x67471384), SPH_C32(0xb1868180), SPH_C32(0x7f954a8e), + SPH_C32(0x2752bbaf) }, + { SPH_C32(0xa9420000), SPH_C32(0x60d70000), SPH_C32(0x1f750a4e), + SPH_C32(0xa3310000), SPH_C32(0x0c2b3b44), SPH_C32(0xf3763231), + SPH_C32(0x70dc9930), SPH_C32(0x4afdc525), SPH_C32(0x66240000), + SPH_C32(0xf2340000), SPH_C32(0x0b460e86), SPH_C32(0x68f90000), + SPH_C32(0x6da313ca), SPH_C32(0x23434c79), SPH_C32(0xd6d10a96), + SPH_C32(0x58c5ed3e) }, + { SPH_C32(0xa89f0000), SPH_C32(0xe07f0000), SPH_C32(0xebe30a06), + SPH_C32(0x05310000), SPH_C32(0x9cfe45e6), SPH_C32(0x2490be06), + SPH_C32(0x16ce56cd), SPH_C32(0x666980bb), SPH_C32(0x34740000), + SPH_C32(0xdb600000), SPH_C32(0x61270ec8), SPH_C32(0x98060000), + SPH_C32(0xf7926d26), SPH_C32(0x66600db7), SPH_C32(0x19878573), + SPH_C32(0x0bc6fe31) }, + { SPH_C32(0xfacf0000), SPH_C32(0xc92b0000), SPH_C32(0x81820a48), + SPH_C32(0xf5ce0000), SPH_C32(0x06cf3b0a), SPH_C32(0x61b3ffc8), + SPH_C32(0xd998d928), SPH_C32(0x356a93b4), SPH_C32(0x67f90000), + SPH_C32(0x729c0000), SPH_C32(0xffd00ece), SPH_C32(0xcef90000), + SPH_C32(0xfd766d68), SPH_C32(0xf4a5c04e), SPH_C32(0xb0c3c56b), + SPH_C32(0x7451a8a0) }, + { SPH_C32(0x37060000), SPH_C32(0xece00000), SPH_C32(0x2fad0d80), + SPH_C32(0x689e0000), SPH_C32(0xddca5657), SPH_C32(0x31ce47e7), + SPH_C32(0xd6c95e14), SPH_C32(0xd3a451d4), SPH_C32(0xb4370000), + SPH_C32(0xb79f0000), SPH_C32(0xf3830c00), SPH_C32(0xabf50000), + SPH_C32(0x3aee3b86), SPH_C32(0xf972bd3c), SPH_C32(0x99cfe8a3), + SPH_C32(0xa9350c55) }, + { SPH_C32(0x65560000), SPH_C32(0xc5b40000), SPH_C32(0x45cc0dce), + SPH_C32(0x98610000), SPH_C32(0x47fb28bb), SPH_C32(0x74ed0629), + SPH_C32(0x199fd1f1), SPH_C32(0x80a742db), SPH_C32(0xe7ba0000), + SPH_C32(0x1e630000), SPH_C32(0x6d740c06), SPH_C32(0xfd0a0000), + SPH_C32(0x300a3bc8), SPH_C32(0x6bb770c5), SPH_C32(0x308ba8bb), + SPH_C32(0xd6a25ac4) }, + { SPH_C32(0x648b0000), SPH_C32(0x451c0000), SPH_C32(0xb15a0d86), + SPH_C32(0x3e610000), SPH_C32(0xd72e5619), SPH_C32(0xa30b8a1e), + SPH_C32(0x7f8d1e0c), SPH_C32(0xac330745), SPH_C32(0xb5ea0000), + SPH_C32(0x37370000), SPH_C32(0x07150c48), SPH_C32(0x0df50000), + SPH_C32(0xaa3b4524), SPH_C32(0x2e94310b), SPH_C32(0xffdd275e), + SPH_C32(0x85a149cb) }, + { SPH_C32(0x36db0000), SPH_C32(0x6c480000), SPH_C32(0xdb3b0dc8), + SPH_C32(0xce9e0000), SPH_C32(0x4d1f28f5), SPH_C32(0xe628cbd0), + SPH_C32(0xb0db91e9), SPH_C32(0xff30144a), SPH_C32(0xe6670000), + SPH_C32(0x9ecb0000), SPH_C32(0x99e20c4e), SPH_C32(0x5b0a0000), + SPH_C32(0xa0df456a), SPH_C32(0xbc51fcf2), SPH_C32(0x56996746), + SPH_C32(0xfa361f5a) } +}; + +static const sph_u32 T512_42[64][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x58430000), SPH_C32(0x807e0000), SPH_C32(0x78330001), + SPH_C32(0xc66b3800), SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), + SPH_C32(0xac73fe6f), SPH_C32(0x3a4479b1), SPH_C32(0x1d5a0000), + SPH_C32(0x2b720000), SPH_C32(0x488d0000), SPH_C32(0xaf611800), + SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), SPH_C32(0x81a20429), + SPH_C32(0x1e7536a6) }, + { SPH_C32(0x1d5a0000), SPH_C32(0x2b720000), SPH_C32(0x488d0000), + SPH_C32(0xaf611800), SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), + SPH_C32(0x81a20429), SPH_C32(0x1e7536a6), SPH_C32(0x45190000), + SPH_C32(0xab0c0000), SPH_C32(0x30be0001), SPH_C32(0x690a2000), + SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), SPH_C32(0x2dd1fa46), + SPH_C32(0x24314f17) }, + { SPH_C32(0x45190000), SPH_C32(0xab0c0000), SPH_C32(0x30be0001), + SPH_C32(0x690a2000), SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), + SPH_C32(0x2dd1fa46), SPH_C32(0x24314f17), SPH_C32(0x58430000), + SPH_C32(0x807e0000), SPH_C32(0x78330001), SPH_C32(0xc66b3800), + SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), SPH_C32(0xac73fe6f), + SPH_C32(0x3a4479b1) }, + { SPH_C32(0xa53b0000), SPH_C32(0x14260000), SPH_C32(0x4e30001e), + SPH_C32(0x7cae0000), SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), + SPH_C32(0xf73168d8), SPH_C32(0x0b1b4946), SPH_C32(0x07ed0000), + SPH_C32(0xb2500000), SPH_C32(0x8774000a), SPH_C32(0x970d0000), + SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), SPH_C32(0xf4786222), + SPH_C32(0x9075b1ce) }, + { SPH_C32(0xfd780000), SPH_C32(0x94580000), SPH_C32(0x3603001f), + SPH_C32(0xbac53800), SPH_C32(0x68a95109), SPH_C32(0x017295e0), + SPH_C32(0x5b4296b7), SPH_C32(0x315f30f7), SPH_C32(0x1ab70000), + SPH_C32(0x99220000), SPH_C32(0xcff9000a), SPH_C32(0x386c1800), + SPH_C32(0x66b90d6b), SPH_C32(0x80bed174), SPH_C32(0x75da660b), + SPH_C32(0x8e008768) }, + { SPH_C32(0xb8610000), SPH_C32(0x3f540000), SPH_C32(0x06bd001e), + SPH_C32(0xd3cf1800), SPH_C32(0xaa552310), SPH_C32(0xb0a615ed), + SPH_C32(0x76936cf1), SPH_C32(0x156e7fe0), SPH_C32(0x42f40000), + SPH_C32(0x195c0000), SPH_C32(0xb7ca000b), SPH_C32(0xfe072000), + SPH_C32(0x818e51b7), SPH_C32(0xf913eea9), SPH_C32(0xd9a99864), + SPH_C32(0xb444fed9) }, + { SPH_C32(0xe0220000), SPH_C32(0xbf2a0000), SPH_C32(0x7e8e001f), + SPH_C32(0x15a42000), SPH_C32(0x4d627fcc), SPH_C32(0xc90b2a30), + SPH_C32(0xdae0929e), SPH_C32(0x2f2a0651), SPH_C32(0x5fae0000), + SPH_C32(0x322e0000), SPH_C32(0xff47000b), SPH_C32(0x51663800), + SPH_C32(0xa4457f72), SPH_C32(0x316a5179), SPH_C32(0x580b9c4d), + SPH_C32(0xaa31c87f) }, + { SPH_C32(0x07ed0000), SPH_C32(0xb2500000), SPH_C32(0x8774000a), + SPH_C32(0x970d0000), SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), + SPH_C32(0xf4786222), SPH_C32(0x9075b1ce), SPH_C32(0xa2d60000), + SPH_C32(0xa6760000), SPH_C32(0xc9440014), SPH_C32(0xeba30000), + SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), SPH_C32(0x03490afa), + SPH_C32(0x9b6ef888) }, + { SPH_C32(0x5fae0000), SPH_C32(0x322e0000), SPH_C32(0xff47000b), + SPH_C32(0x51663800), SPH_C32(0xa4457f72), SPH_C32(0x316a5179), + SPH_C32(0x580b9c4d), SPH_C32(0xaa31c87f), SPH_C32(0xbf8c0000), + SPH_C32(0x8d040000), SPH_C32(0x81c90014), SPH_C32(0x44c21800), + SPH_C32(0xe92700be), SPH_C32(0xf8617b49), SPH_C32(0x82eb0ed3), + SPH_C32(0x851bce2e) }, + { SPH_C32(0x1ab70000), SPH_C32(0x99220000), SPH_C32(0xcff9000a), + SPH_C32(0x386c1800), SPH_C32(0x66b90d6b), SPH_C32(0x80bed174), + SPH_C32(0x75da660b), SPH_C32(0x8e008768), SPH_C32(0xe7cf0000), + SPH_C32(0x0d7a0000), SPH_C32(0xf9fa0015), SPH_C32(0x82a92000), + SPH_C32(0x0e105c62), SPH_C32(0x81cc4494), SPH_C32(0x2e98f0bc), + SPH_C32(0xbf5fb79f) }, + { SPH_C32(0x42f40000), SPH_C32(0x195c0000), SPH_C32(0xb7ca000b), + SPH_C32(0xfe072000), SPH_C32(0x818e51b7), SPH_C32(0xf913eea9), + SPH_C32(0xd9a99864), SPH_C32(0xb444fed9), SPH_C32(0xfa950000), + SPH_C32(0x26080000), SPH_C32(0xb1770015), SPH_C32(0x2dc83800), + SPH_C32(0x2bdb72a7), SPH_C32(0x49b5fb44), SPH_C32(0xaf3af495), + SPH_C32(0xa12a8139) }, + { SPH_C32(0xa2d60000), SPH_C32(0xa6760000), SPH_C32(0xc9440014), + SPH_C32(0xeba30000), SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), + SPH_C32(0x03490afa), SPH_C32(0x9b6ef888), SPH_C32(0xa53b0000), + SPH_C32(0x14260000), SPH_C32(0x4e30001e), SPH_C32(0x7cae0000), + SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), SPH_C32(0xf73168d8), + SPH_C32(0x0b1b4946) }, + { SPH_C32(0xfa950000), SPH_C32(0x26080000), SPH_C32(0xb1770015), + SPH_C32(0x2dc83800), SPH_C32(0x2bdb72a7), SPH_C32(0x49b5fb44), + SPH_C32(0xaf3af495), SPH_C32(0xa12a8139), SPH_C32(0xb8610000), + SPH_C32(0x3f540000), SPH_C32(0x06bd001e), SPH_C32(0xd3cf1800), + SPH_C32(0xaa552310), SPH_C32(0xb0a615ed), SPH_C32(0x76936cf1), + SPH_C32(0x156e7fe0) }, + { SPH_C32(0xbf8c0000), SPH_C32(0x8d040000), SPH_C32(0x81c90014), + SPH_C32(0x44c21800), SPH_C32(0xe92700be), SPH_C32(0xf8617b49), + SPH_C32(0x82eb0ed3), SPH_C32(0x851bce2e), SPH_C32(0xe0220000), + SPH_C32(0xbf2a0000), SPH_C32(0x7e8e001f), SPH_C32(0x15a42000), + SPH_C32(0x4d627fcc), SPH_C32(0xc90b2a30), SPH_C32(0xdae0929e), + SPH_C32(0x2f2a0651) }, + { SPH_C32(0xe7cf0000), SPH_C32(0x0d7a0000), SPH_C32(0xf9fa0015), + SPH_C32(0x82a92000), SPH_C32(0x0e105c62), SPH_C32(0x81cc4494), + SPH_C32(0x2e98f0bc), SPH_C32(0xbf5fb79f), SPH_C32(0xfd780000), + SPH_C32(0x94580000), SPH_C32(0x3603001f), SPH_C32(0xbac53800), + SPH_C32(0x68a95109), SPH_C32(0x017295e0), SPH_C32(0x5b4296b7), + SPH_C32(0x315f30f7) }, + { SPH_C32(0x88980000), SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), + SPH_C32(0xfb4e0000), SPH_C32(0xf158079a), SPH_C32(0x61ae9167), + SPH_C32(0xa895706c), SPH_C32(0xe6107494), SPH_C32(0x0bc20000), + SPH_C32(0xdb630000), SPH_C32(0x7e88000c), SPH_C32(0x15860000), + SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), SPH_C32(0xf460449e), + SPH_C32(0xd8b61463) }, + { SPH_C32(0xd0db0000), SPH_C32(0x9fea0000), SPH_C32(0x07fc002f), + SPH_C32(0x3d253800), SPH_C32(0x166f5b46), SPH_C32(0x1803aeba), + SPH_C32(0x04e68e03), SPH_C32(0xdc540d25), SPH_C32(0x16980000), + SPH_C32(0xf0110000), SPH_C32(0x3605000c), SPH_C32(0xbae71800), + SPH_C32(0xb4366636), SPH_C32(0xbdf80493), SPH_C32(0x75c240b7), + SPH_C32(0xc6c322c5) }, + { SPH_C32(0x95c20000), SPH_C32(0x34e60000), SPH_C32(0x3742002e), + SPH_C32(0x542f1800), SPH_C32(0xd493295f), SPH_C32(0xa9d72eb7), + SPH_C32(0x29377445), SPH_C32(0xf8654232), SPH_C32(0x4edb0000), + SPH_C32(0x706f0000), SPH_C32(0x4e36000d), SPH_C32(0x7c8c2000), + SPH_C32(0x53013aea), SPH_C32(0xc4553b4e), SPH_C32(0xd9b1bed8), + SPH_C32(0xfc875b74) }, + { SPH_C32(0xcd810000), SPH_C32(0xb4980000), SPH_C32(0x4f71002f), + SPH_C32(0x92442000), SPH_C32(0x33a47583), SPH_C32(0xd07a116a), + SPH_C32(0x85448a2a), SPH_C32(0xc2213b83), SPH_C32(0x53810000), + SPH_C32(0x5b1d0000), SPH_C32(0x06bb000d), SPH_C32(0xd3ed3800), + SPH_C32(0x76ca142f), SPH_C32(0x0c2c849e), SPH_C32(0x5813baf1), + SPH_C32(0xe2f26dd2) }, + { SPH_C32(0x2da30000), SPH_C32(0x0bb20000), SPH_C32(0x31ff0030), + SPH_C32(0x87e00000), SPH_C32(0x7ec60a4f), SPH_C32(0x19713b5a), + SPH_C32(0x5fa418b4), SPH_C32(0xed0b3dd2), SPH_C32(0x0c2f0000), + SPH_C32(0x69330000), SPH_C32(0xf9fc0006), SPH_C32(0x828b0000), + SPH_C32(0xd28f6b5d), SPH_C32(0x3d46d5e7), SPH_C32(0x001826bc), + SPH_C32(0x48c3a5ad) }, + { SPH_C32(0x75e00000), SPH_C32(0x8bcc0000), SPH_C32(0x49cc0031), + SPH_C32(0x418b3800), SPH_C32(0x99f15693), SPH_C32(0x60dc0487), + SPH_C32(0xf3d7e6db), SPH_C32(0xd74f4463), SPH_C32(0x11750000), + SPH_C32(0x42410000), SPH_C32(0xb1710006), SPH_C32(0x2dea1800), + SPH_C32(0xf7444598), SPH_C32(0xf53f6a37), SPH_C32(0x81ba2295), + SPH_C32(0x56b6930b) }, + { SPH_C32(0x30f90000), SPH_C32(0x20c00000), SPH_C32(0x79720030), + SPH_C32(0x28811800), SPH_C32(0x5b0d248a), SPH_C32(0xd108848a), + SPH_C32(0xde061c9d), SPH_C32(0xf37e0b74), SPH_C32(0x49360000), + SPH_C32(0xc23f0000), SPH_C32(0xc9420007), SPH_C32(0xeb812000), + SPH_C32(0x10731944), SPH_C32(0x8c9255ea), SPH_C32(0x2dc9dcfa), + SPH_C32(0x6cf2eaba) }, + { SPH_C32(0x68ba0000), SPH_C32(0xa0be0000), SPH_C32(0x01410031), + SPH_C32(0xeeea2000), SPH_C32(0xbc3a7856), SPH_C32(0xa8a5bb57), + SPH_C32(0x7275e2f2), SPH_C32(0xc93a72c5), SPH_C32(0x546c0000), + SPH_C32(0xe94d0000), SPH_C32(0x81cf0007), SPH_C32(0x44e03800), + SPH_C32(0x35b83781), SPH_C32(0x44ebea3a), SPH_C32(0xac6bd8d3), + SPH_C32(0x7287dc1c) }, + { SPH_C32(0x8f750000), SPH_C32(0xadc40000), SPH_C32(0xf8bb0024), + SPH_C32(0x6c430000), SPH_C32(0xb22a2434), SPH_C32(0x2969ffc3), + SPH_C32(0x5ced124e), SPH_C32(0x7665c55a), SPH_C32(0xa9140000), + SPH_C32(0x7d150000), SPH_C32(0xb7cc0018), SPH_C32(0xfe250000), + SPH_C32(0x5d116688), SPH_C32(0x45997fda), SPH_C32(0xf7294e64), + SPH_C32(0x43d8eceb) }, + { SPH_C32(0xd7360000), SPH_C32(0x2dba0000), SPH_C32(0x80880025), + SPH_C32(0xaa283800), SPH_C32(0x551d78e8), SPH_C32(0x50c4c01e), + SPH_C32(0xf09eec21), SPH_C32(0x4c21bceb), SPH_C32(0xb44e0000), + SPH_C32(0x56670000), SPH_C32(0xff410018), SPH_C32(0x51441800), + SPH_C32(0x78da484d), SPH_C32(0x8de0c00a), SPH_C32(0x768b4a4d), + SPH_C32(0x5dadda4d) }, + { SPH_C32(0x922f0000), SPH_C32(0x86b60000), SPH_C32(0xb0360024), + SPH_C32(0xc3221800), SPH_C32(0x97e10af1), SPH_C32(0xe1104013), + SPH_C32(0xdd4f1667), SPH_C32(0x6810f3fc), SPH_C32(0xec0d0000), + SPH_C32(0xd6190000), SPH_C32(0x87720019), SPH_C32(0x972f2000), + SPH_C32(0x9fed1491), SPH_C32(0xf44dffd7), SPH_C32(0xdaf8b422), + SPH_C32(0x67e9a3fc) }, + { SPH_C32(0xca6c0000), SPH_C32(0x06c80000), SPH_C32(0xc8050025), + SPH_C32(0x05492000), SPH_C32(0x70d6562d), SPH_C32(0x98bd7fce), + SPH_C32(0x713ce808), SPH_C32(0x52548a4d), SPH_C32(0xf1570000), + SPH_C32(0xfd6b0000), SPH_C32(0xcfff0019), SPH_C32(0x384e3800), + SPH_C32(0xba263a54), SPH_C32(0x3c344007), SPH_C32(0x5b5ab00b), + SPH_C32(0x799c955a) }, + { SPH_C32(0x2a4e0000), SPH_C32(0xb9e20000), SPH_C32(0xb68b003a), + SPH_C32(0x10ed0000), SPH_C32(0x3db429e1), SPH_C32(0x51b655fe), + SPH_C32(0xabdc7a96), SPH_C32(0x7d7e8c1c), SPH_C32(0xaef90000), + SPH_C32(0xcf450000), SPH_C32(0x30b80012), SPH_C32(0x69280000), + SPH_C32(0x1e634526), SPH_C32(0x0d5e117e), SPH_C32(0x03512c46), + SPH_C32(0xd3ad5d25) }, + { SPH_C32(0x720d0000), SPH_C32(0x399c0000), SPH_C32(0xceb8003b), + SPH_C32(0xd6863800), SPH_C32(0xda83753d), SPH_C32(0x281b6a23), + SPH_C32(0x07af84f9), SPH_C32(0x473af5ad), SPH_C32(0xb3a30000), + SPH_C32(0xe4370000), SPH_C32(0x78350012), SPH_C32(0xc6491800), + SPH_C32(0x3ba86be3), SPH_C32(0xc527aeae), SPH_C32(0x82f3286f), + SPH_C32(0xcdd86b83) }, + { SPH_C32(0x37140000), SPH_C32(0x92900000), SPH_C32(0xfe06003a), + SPH_C32(0xbf8c1800), SPH_C32(0x187f0724), SPH_C32(0x99cfea2e), + SPH_C32(0x2a7e7ebf), SPH_C32(0x630bbaba), SPH_C32(0xebe00000), + SPH_C32(0x64490000), SPH_C32(0x00060013), SPH_C32(0x00222000), + SPH_C32(0xdc9f373f), SPH_C32(0xbc8a9173), SPH_C32(0x2e80d600), + SPH_C32(0xf79c1232) }, + { SPH_C32(0x6f570000), SPH_C32(0x12ee0000), SPH_C32(0x8635003b), + SPH_C32(0x79e72000), SPH_C32(0xff485bf8), SPH_C32(0xe062d5f3), + SPH_C32(0x860d80d0), SPH_C32(0x594fc30b), SPH_C32(0xf6ba0000), + SPH_C32(0x4f3b0000), SPH_C32(0x488b0013), SPH_C32(0xaf433800), + SPH_C32(0xf95419fa), SPH_C32(0x74f32ea3), SPH_C32(0xaf22d229), + SPH_C32(0xe9e92494) }, + { SPH_C32(0x0bc20000), SPH_C32(0xdb630000), SPH_C32(0x7e88000c), + SPH_C32(0x15860000), SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), + SPH_C32(0xf460449e), SPH_C32(0xd8b61463), SPH_C32(0x835a0000), + SPH_C32(0xc4f70000), SPH_C32(0x01470022), SPH_C32(0xeec80000), + SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), SPH_C32(0x5cf534f2), + SPH_C32(0x3ea660f7) }, + { SPH_C32(0x53810000), SPH_C32(0x5b1d0000), SPH_C32(0x06bb000d), + SPH_C32(0xd3ed3800), SPH_C32(0x76ca142f), SPH_C32(0x0c2c849e), + SPH_C32(0x5813baf1), SPH_C32(0xe2f26dd2), SPH_C32(0x9e000000), + SPH_C32(0xef850000), SPH_C32(0x49ca0022), SPH_C32(0x41a91800), + SPH_C32(0x456e61ac), SPH_C32(0xdc5695f4), SPH_C32(0xdd5730db), + SPH_C32(0x20d35651) }, + { SPH_C32(0x16980000), SPH_C32(0xf0110000), SPH_C32(0x3605000c), + SPH_C32(0xbae71800), SPH_C32(0xb4366636), SPH_C32(0xbdf80493), + SPH_C32(0x75c240b7), SPH_C32(0xc6c322c5), SPH_C32(0xc6430000), + SPH_C32(0x6ffb0000), SPH_C32(0x31f90023), SPH_C32(0x87c22000), + SPH_C32(0xa2593d70), SPH_C32(0xa5fbaa29), SPH_C32(0x7124ceb4), + SPH_C32(0x1a972fe0) }, + { SPH_C32(0x4edb0000), SPH_C32(0x706f0000), SPH_C32(0x4e36000d), + SPH_C32(0x7c8c2000), SPH_C32(0x53013aea), SPH_C32(0xc4553b4e), + SPH_C32(0xd9b1bed8), SPH_C32(0xfc875b74), SPH_C32(0xdb190000), + SPH_C32(0x44890000), SPH_C32(0x79740023), SPH_C32(0x28a33800), + SPH_C32(0x879213b5), SPH_C32(0x6d8215f9), SPH_C32(0xf086ca9d), + SPH_C32(0x04e21946) }, + { SPH_C32(0xaef90000), SPH_C32(0xcf450000), SPH_C32(0x30b80012), + SPH_C32(0x69280000), SPH_C32(0x1e634526), SPH_C32(0x0d5e117e), + SPH_C32(0x03512c46), SPH_C32(0xd3ad5d25), SPH_C32(0x84b70000), + SPH_C32(0x76a70000), SPH_C32(0x86330028), SPH_C32(0x79c50000), + SPH_C32(0x23d76cc7), SPH_C32(0x5ce84480), SPH_C32(0xa88d56d0), + SPH_C32(0xaed3d139) }, + { SPH_C32(0xf6ba0000), SPH_C32(0x4f3b0000), SPH_C32(0x488b0013), + SPH_C32(0xaf433800), SPH_C32(0xf95419fa), SPH_C32(0x74f32ea3), + SPH_C32(0xaf22d229), SPH_C32(0xe9e92494), SPH_C32(0x99ed0000), + SPH_C32(0x5dd50000), SPH_C32(0xcebe0028), SPH_C32(0xd6a41800), + SPH_C32(0x061c4202), SPH_C32(0x9491fb50), SPH_C32(0x292f52f9), + SPH_C32(0xb0a6e79f) }, + { SPH_C32(0xb3a30000), SPH_C32(0xe4370000), SPH_C32(0x78350012), + SPH_C32(0xc6491800), SPH_C32(0x3ba86be3), SPH_C32(0xc527aeae), + SPH_C32(0x82f3286f), SPH_C32(0xcdd86b83), SPH_C32(0xc1ae0000), + SPH_C32(0xddab0000), SPH_C32(0xb68d0029), SPH_C32(0x10cf2000), + SPH_C32(0xe12b1ede), SPH_C32(0xed3cc48d), SPH_C32(0x855cac96), + SPH_C32(0x8ae29e2e) }, + { SPH_C32(0xebe00000), SPH_C32(0x64490000), SPH_C32(0x00060013), + SPH_C32(0x00222000), SPH_C32(0xdc9f373f), SPH_C32(0xbc8a9173), + SPH_C32(0x2e80d600), SPH_C32(0xf79c1232), SPH_C32(0xdcf40000), + SPH_C32(0xf6d90000), SPH_C32(0xfe000029), SPH_C32(0xbfae3800), + SPH_C32(0xc4e0301b), SPH_C32(0x25457b5d), SPH_C32(0x04fea8bf), + SPH_C32(0x9497a888) }, + { SPH_C32(0x0c2f0000), SPH_C32(0x69330000), SPH_C32(0xf9fc0006), + SPH_C32(0x828b0000), SPH_C32(0xd28f6b5d), SPH_C32(0x3d46d5e7), + SPH_C32(0x001826bc), SPH_C32(0x48c3a5ad), SPH_C32(0x218c0000), + SPH_C32(0x62810000), SPH_C32(0xc8030036), SPH_C32(0x056b0000), + SPH_C32(0xac496112), SPH_C32(0x2437eebd), SPH_C32(0x5fbc3e08), + SPH_C32(0xa5c8987f) }, + { SPH_C32(0x546c0000), SPH_C32(0xe94d0000), SPH_C32(0x81cf0007), + SPH_C32(0x44e03800), SPH_C32(0x35b83781), SPH_C32(0x44ebea3a), + SPH_C32(0xac6bd8d3), SPH_C32(0x7287dc1c), SPH_C32(0x3cd60000), + SPH_C32(0x49f30000), SPH_C32(0x808e0036), SPH_C32(0xaa0a1800), + SPH_C32(0x89824fd7), SPH_C32(0xec4e516d), SPH_C32(0xde1e3a21), + SPH_C32(0xbbbdaed9) }, + { SPH_C32(0x11750000), SPH_C32(0x42410000), SPH_C32(0xb1710006), + SPH_C32(0x2dea1800), SPH_C32(0xf7444598), SPH_C32(0xf53f6a37), + SPH_C32(0x81ba2295), SPH_C32(0x56b6930b), SPH_C32(0x64950000), + SPH_C32(0xc98d0000), SPH_C32(0xf8bd0037), SPH_C32(0x6c612000), + SPH_C32(0x6eb5130b), SPH_C32(0x95e36eb0), SPH_C32(0x726dc44e), + SPH_C32(0x81f9d768) }, + { SPH_C32(0x49360000), SPH_C32(0xc23f0000), SPH_C32(0xc9420007), + SPH_C32(0xeb812000), SPH_C32(0x10731944), SPH_C32(0x8c9255ea), + SPH_C32(0x2dc9dcfa), SPH_C32(0x6cf2eaba), SPH_C32(0x79cf0000), + SPH_C32(0xe2ff0000), SPH_C32(0xb0300037), SPH_C32(0xc3003800), + SPH_C32(0x4b7e3dce), SPH_C32(0x5d9ad160), SPH_C32(0xf3cfc067), + SPH_C32(0x9f8ce1ce) }, + { SPH_C32(0xa9140000), SPH_C32(0x7d150000), SPH_C32(0xb7cc0018), + SPH_C32(0xfe250000), SPH_C32(0x5d116688), SPH_C32(0x45997fda), + SPH_C32(0xf7294e64), SPH_C32(0x43d8eceb), SPH_C32(0x26610000), + SPH_C32(0xd0d10000), SPH_C32(0x4f77003c), SPH_C32(0x92660000), + SPH_C32(0xef3b42bc), SPH_C32(0x6cf08019), SPH_C32(0xabc45c2a), + SPH_C32(0x35bd29b1) }, + { SPH_C32(0xf1570000), SPH_C32(0xfd6b0000), SPH_C32(0xcfff0019), + SPH_C32(0x384e3800), SPH_C32(0xba263a54), SPH_C32(0x3c344007), + SPH_C32(0x5b5ab00b), SPH_C32(0x799c955a), SPH_C32(0x3b3b0000), + SPH_C32(0xfba30000), SPH_C32(0x07fa003c), SPH_C32(0x3d071800), + SPH_C32(0xcaf06c79), SPH_C32(0xa4893fc9), SPH_C32(0x2a665803), + SPH_C32(0x2bc81f17) }, + { SPH_C32(0xb44e0000), SPH_C32(0x56670000), SPH_C32(0xff410018), + SPH_C32(0x51441800), SPH_C32(0x78da484d), SPH_C32(0x8de0c00a), + SPH_C32(0x768b4a4d), SPH_C32(0x5dadda4d), SPH_C32(0x63780000), + SPH_C32(0x7bdd0000), SPH_C32(0x7fc9003d), SPH_C32(0xfb6c2000), + SPH_C32(0x2dc730a5), SPH_C32(0xdd240014), SPH_C32(0x8615a66c), + SPH_C32(0x118c66a6) }, + { SPH_C32(0xec0d0000), SPH_C32(0xd6190000), SPH_C32(0x87720019), + SPH_C32(0x972f2000), SPH_C32(0x9fed1491), SPH_C32(0xf44dffd7), + SPH_C32(0xdaf8b422), SPH_C32(0x67e9a3fc), SPH_C32(0x7e220000), + SPH_C32(0x50af0000), SPH_C32(0x3744003d), SPH_C32(0x540d3800), + SPH_C32(0x080c1e60), SPH_C32(0x155dbfc4), SPH_C32(0x07b7a245), + SPH_C32(0x0ff95000) }, + { SPH_C32(0x835a0000), SPH_C32(0xc4f70000), SPH_C32(0x01470022), + SPH_C32(0xeec80000), SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), + SPH_C32(0x5cf534f2), SPH_C32(0x3ea660f7), SPH_C32(0x88980000), + SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), SPH_C32(0xfb4e0000), + SPH_C32(0xf158079a), SPH_C32(0x61ae9167), SPH_C32(0xa895706c), + SPH_C32(0xe6107494) }, + { SPH_C32(0xdb190000), SPH_C32(0x44890000), SPH_C32(0x79740023), + SPH_C32(0x28a33800), SPH_C32(0x879213b5), SPH_C32(0x6d8215f9), + SPH_C32(0xf086ca9d), SPH_C32(0x04e21946), SPH_C32(0x95c20000), + SPH_C32(0x34e60000), SPH_C32(0x3742002e), SPH_C32(0x542f1800), + SPH_C32(0xd493295f), SPH_C32(0xa9d72eb7), SPH_C32(0x29377445), + SPH_C32(0xf8654232) }, + { SPH_C32(0x9e000000), SPH_C32(0xef850000), SPH_C32(0x49ca0022), + SPH_C32(0x41a91800), SPH_C32(0x456e61ac), SPH_C32(0xdc5695f4), + SPH_C32(0xdd5730db), SPH_C32(0x20d35651), SPH_C32(0xcd810000), + SPH_C32(0xb4980000), SPH_C32(0x4f71002f), SPH_C32(0x92442000), + SPH_C32(0x33a47583), SPH_C32(0xd07a116a), SPH_C32(0x85448a2a), + SPH_C32(0xc2213b83) }, + { SPH_C32(0xc6430000), SPH_C32(0x6ffb0000), SPH_C32(0x31f90023), + SPH_C32(0x87c22000), SPH_C32(0xa2593d70), SPH_C32(0xa5fbaa29), + SPH_C32(0x7124ceb4), SPH_C32(0x1a972fe0), SPH_C32(0xd0db0000), + SPH_C32(0x9fea0000), SPH_C32(0x07fc002f), SPH_C32(0x3d253800), + SPH_C32(0x166f5b46), SPH_C32(0x1803aeba), SPH_C32(0x04e68e03), + SPH_C32(0xdc540d25) }, + { SPH_C32(0x26610000), SPH_C32(0xd0d10000), SPH_C32(0x4f77003c), + SPH_C32(0x92660000), SPH_C32(0xef3b42bc), SPH_C32(0x6cf08019), + SPH_C32(0xabc45c2a), SPH_C32(0x35bd29b1), SPH_C32(0x8f750000), + SPH_C32(0xadc40000), SPH_C32(0xf8bb0024), SPH_C32(0x6c430000), + SPH_C32(0xb22a2434), SPH_C32(0x2969ffc3), SPH_C32(0x5ced124e), + SPH_C32(0x7665c55a) }, + { SPH_C32(0x7e220000), SPH_C32(0x50af0000), SPH_C32(0x3744003d), + SPH_C32(0x540d3800), SPH_C32(0x080c1e60), SPH_C32(0x155dbfc4), + SPH_C32(0x07b7a245), SPH_C32(0x0ff95000), SPH_C32(0x922f0000), + SPH_C32(0x86b60000), SPH_C32(0xb0360024), SPH_C32(0xc3221800), + SPH_C32(0x97e10af1), SPH_C32(0xe1104013), SPH_C32(0xdd4f1667), + SPH_C32(0x6810f3fc) }, + { SPH_C32(0x3b3b0000), SPH_C32(0xfba30000), SPH_C32(0x07fa003c), + SPH_C32(0x3d071800), SPH_C32(0xcaf06c79), SPH_C32(0xa4893fc9), + SPH_C32(0x2a665803), SPH_C32(0x2bc81f17), SPH_C32(0xca6c0000), + SPH_C32(0x06c80000), SPH_C32(0xc8050025), SPH_C32(0x05492000), + SPH_C32(0x70d6562d), SPH_C32(0x98bd7fce), SPH_C32(0x713ce808), + SPH_C32(0x52548a4d) }, + { SPH_C32(0x63780000), SPH_C32(0x7bdd0000), SPH_C32(0x7fc9003d), + SPH_C32(0xfb6c2000), SPH_C32(0x2dc730a5), SPH_C32(0xdd240014), + SPH_C32(0x8615a66c), SPH_C32(0x118c66a6), SPH_C32(0xd7360000), + SPH_C32(0x2dba0000), SPH_C32(0x80880025), SPH_C32(0xaa283800), + SPH_C32(0x551d78e8), SPH_C32(0x50c4c01e), SPH_C32(0xf09eec21), + SPH_C32(0x4c21bceb) }, + { SPH_C32(0x84b70000), SPH_C32(0x76a70000), SPH_C32(0x86330028), + SPH_C32(0x79c50000), SPH_C32(0x23d76cc7), SPH_C32(0x5ce84480), + SPH_C32(0xa88d56d0), SPH_C32(0xaed3d139), SPH_C32(0x2a4e0000), + SPH_C32(0xb9e20000), SPH_C32(0xb68b003a), SPH_C32(0x10ed0000), + SPH_C32(0x3db429e1), SPH_C32(0x51b655fe), SPH_C32(0xabdc7a96), + SPH_C32(0x7d7e8c1c) }, + { SPH_C32(0xdcf40000), SPH_C32(0xf6d90000), SPH_C32(0xfe000029), + SPH_C32(0xbfae3800), SPH_C32(0xc4e0301b), SPH_C32(0x25457b5d), + SPH_C32(0x04fea8bf), SPH_C32(0x9497a888), SPH_C32(0x37140000), + SPH_C32(0x92900000), SPH_C32(0xfe06003a), SPH_C32(0xbf8c1800), + SPH_C32(0x187f0724), SPH_C32(0x99cfea2e), SPH_C32(0x2a7e7ebf), + SPH_C32(0x630bbaba) }, + { SPH_C32(0x99ed0000), SPH_C32(0x5dd50000), SPH_C32(0xcebe0028), + SPH_C32(0xd6a41800), SPH_C32(0x061c4202), SPH_C32(0x9491fb50), + SPH_C32(0x292f52f9), SPH_C32(0xb0a6e79f), SPH_C32(0x6f570000), + SPH_C32(0x12ee0000), SPH_C32(0x8635003b), SPH_C32(0x79e72000), + SPH_C32(0xff485bf8), SPH_C32(0xe062d5f3), SPH_C32(0x860d80d0), + SPH_C32(0x594fc30b) }, + { SPH_C32(0xc1ae0000), SPH_C32(0xddab0000), SPH_C32(0xb68d0029), + SPH_C32(0x10cf2000), SPH_C32(0xe12b1ede), SPH_C32(0xed3cc48d), + SPH_C32(0x855cac96), SPH_C32(0x8ae29e2e), SPH_C32(0x720d0000), + SPH_C32(0x399c0000), SPH_C32(0xceb8003b), SPH_C32(0xd6863800), + SPH_C32(0xda83753d), SPH_C32(0x281b6a23), SPH_C32(0x07af84f9), + SPH_C32(0x473af5ad) }, + { SPH_C32(0x218c0000), SPH_C32(0x62810000), SPH_C32(0xc8030036), + SPH_C32(0x056b0000), SPH_C32(0xac496112), SPH_C32(0x2437eebd), + SPH_C32(0x5fbc3e08), SPH_C32(0xa5c8987f), SPH_C32(0x2da30000), + SPH_C32(0x0bb20000), SPH_C32(0x31ff0030), SPH_C32(0x87e00000), + SPH_C32(0x7ec60a4f), SPH_C32(0x19713b5a), SPH_C32(0x5fa418b4), + SPH_C32(0xed0b3dd2) }, + { SPH_C32(0x79cf0000), SPH_C32(0xe2ff0000), SPH_C32(0xb0300037), + SPH_C32(0xc3003800), SPH_C32(0x4b7e3dce), SPH_C32(0x5d9ad160), + SPH_C32(0xf3cfc067), SPH_C32(0x9f8ce1ce), SPH_C32(0x30f90000), + SPH_C32(0x20c00000), SPH_C32(0x79720030), SPH_C32(0x28811800), + SPH_C32(0x5b0d248a), SPH_C32(0xd108848a), SPH_C32(0xde061c9d), + SPH_C32(0xf37e0b74) }, + { SPH_C32(0x3cd60000), SPH_C32(0x49f30000), SPH_C32(0x808e0036), + SPH_C32(0xaa0a1800), SPH_C32(0x89824fd7), SPH_C32(0xec4e516d), + SPH_C32(0xde1e3a21), SPH_C32(0xbbbdaed9), SPH_C32(0x68ba0000), + SPH_C32(0xa0be0000), SPH_C32(0x01410031), SPH_C32(0xeeea2000), + SPH_C32(0xbc3a7856), SPH_C32(0xa8a5bb57), SPH_C32(0x7275e2f2), + SPH_C32(0xc93a72c5) }, + { SPH_C32(0x64950000), SPH_C32(0xc98d0000), SPH_C32(0xf8bd0037), + SPH_C32(0x6c612000), SPH_C32(0x6eb5130b), SPH_C32(0x95e36eb0), + SPH_C32(0x726dc44e), SPH_C32(0x81f9d768), SPH_C32(0x75e00000), + SPH_C32(0x8bcc0000), SPH_C32(0x49cc0031), SPH_C32(0x418b3800), + SPH_C32(0x99f15693), SPH_C32(0x60dc0487), SPH_C32(0xf3d7e6db), + SPH_C32(0xd74f4463) } +}; + +static const sph_u32 T512_48[64][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xb4310000), SPH_C32(0x77330000), SPH_C32(0xb15d0000), + SPH_C32(0x7fd004e0), SPH_C32(0x78a26138), SPH_C32(0xd116c35d), + SPH_C32(0xd256d489), SPH_C32(0x4e6f74de), SPH_C32(0xe3060000), + SPH_C32(0xbdc10000), SPH_C32(0x87130000), SPH_C32(0xbff20060), + SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), SPH_C32(0x73c5ab06), + SPH_C32(0x5bd61539) }, + { SPH_C32(0xe3060000), SPH_C32(0xbdc10000), SPH_C32(0x87130000), + SPH_C32(0xbff20060), SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), + SPH_C32(0x73c5ab06), SPH_C32(0x5bd61539), SPH_C32(0x57370000), + SPH_C32(0xcaf20000), SPH_C32(0x364e0000), SPH_C32(0xc0220480), + SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), SPH_C32(0xa1937f8f), + SPH_C32(0x15b961e7) }, + { SPH_C32(0x57370000), SPH_C32(0xcaf20000), SPH_C32(0x364e0000), + SPH_C32(0xc0220480), SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), + SPH_C32(0xa1937f8f), SPH_C32(0x15b961e7), SPH_C32(0xb4310000), + SPH_C32(0x77330000), SPH_C32(0xb15d0000), SPH_C32(0x7fd004e0), + SPH_C32(0x78a26138), SPH_C32(0xd116c35d), SPH_C32(0xd256d489), + SPH_C32(0x4e6f74de) }, + { SPH_C32(0x02f20000), SPH_C32(0xa2810000), SPH_C32(0x873f0000), + SPH_C32(0xe36c7800), SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), + SPH_C32(0xc4c23237), SPH_C32(0x7f32259e), SPH_C32(0xbadd0000), + SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), SPH_C32(0xf7282800), + SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), SPH_C32(0xea5a8d14), + SPH_C32(0x2a2c18f0) }, + { SPH_C32(0xb6c30000), SPH_C32(0xd5b20000), SPH_C32(0x36620000), + SPH_C32(0x9cbc7ce0), SPH_C32(0x66bf15d7), SPH_C32(0xd62be88b), + SPH_C32(0x1694e6be), SPH_C32(0x315d5140), SPH_C32(0x59db0000), + SPH_C32(0xae6c0000), SPH_C32(0x30f40000), SPH_C32(0x48da2860), + SPH_C32(0xf1ff1e57), SPH_C32(0xbbaff46b), SPH_C32(0x999f2612), + SPH_C32(0x71fa0dc9) }, + { SPH_C32(0xe1f40000), SPH_C32(0x1f400000), SPH_C32(0x002c0000), + SPH_C32(0x5c9e7860), SPH_C32(0x30a77ef5), SPH_C32(0x8a881c87), + SPH_C32(0xb7079931), SPH_C32(0x24e430a7), SPH_C32(0xedea0000), + SPH_C32(0xd95f0000), SPH_C32(0x81a90000), SPH_C32(0x370a2c80), + SPH_C32(0x895d7f6f), SPH_C32(0x6ab93736), SPH_C32(0x4bc9f29b), + SPH_C32(0x3f957917) }, + { SPH_C32(0x55c50000), SPH_C32(0x68730000), SPH_C32(0xb1710000), + SPH_C32(0x234e7c80), SPH_C32(0x48051fcd), SPH_C32(0x5b9edfda), + SPH_C32(0x65514db8), SPH_C32(0x6a8b4479), SPH_C32(0x0eec0000), + SPH_C32(0x649e0000), SPH_C32(0x06ba0000), SPH_C32(0x88f82ce0), + SPH_C32(0xa7e77575), SPH_C32(0xe70c0067), SPH_C32(0x380c599d), + SPH_C32(0x64436c2e) }, + { SPH_C32(0xbadd0000), SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), + SPH_C32(0xf7282800), SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), + SPH_C32(0xea5a8d14), SPH_C32(0x2a2c18f0), SPH_C32(0xb82f0000), + SPH_C32(0xb12c0000), SPH_C32(0x30d80000), SPH_C32(0x14445000), + SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), SPH_C32(0x2e98bf23), + SPH_C32(0x551e3d6e) }, + { SPH_C32(0x0eec0000), SPH_C32(0x649e0000), SPH_C32(0x06ba0000), + SPH_C32(0x88f82ce0), SPH_C32(0xa7e77575), SPH_C32(0xe70c0067), + SPH_C32(0x380c599d), SPH_C32(0x64436c2e), SPH_C32(0x5b290000), + SPH_C32(0x0ced0000), SPH_C32(0xb7cb0000), SPH_C32(0xabb65060), + SPH_C32(0xefe26ab8), SPH_C32(0xbc92dfbd), SPH_C32(0x5d5d1425), + SPH_C32(0x0ec82857) }, + { SPH_C32(0x59db0000), SPH_C32(0xae6c0000), SPH_C32(0x30f40000), + SPH_C32(0x48da2860), SPH_C32(0xf1ff1e57), SPH_C32(0xbbaff46b), + SPH_C32(0x999f2612), SPH_C32(0x71fa0dc9), SPH_C32(0xef180000), + SPH_C32(0x7bde0000), SPH_C32(0x06960000), SPH_C32(0xd4665480), + SPH_C32(0x97400b80), SPH_C32(0x6d841ce0), SPH_C32(0x8f0bc0ac), + SPH_C32(0x40a75c89) }, + { SPH_C32(0xedea0000), SPH_C32(0xd95f0000), SPH_C32(0x81a90000), + SPH_C32(0x370a2c80), SPH_C32(0x895d7f6f), SPH_C32(0x6ab93736), + SPH_C32(0x4bc9f29b), SPH_C32(0x3f957917), SPH_C32(0x0c1e0000), + SPH_C32(0xc61f0000), SPH_C32(0x81850000), SPH_C32(0x6b9454e0), + SPH_C32(0xb9fa019a), SPH_C32(0xe0312bb1), SPH_C32(0xfcce6baa), + SPH_C32(0x1b7149b0) }, + { SPH_C32(0xb82f0000), SPH_C32(0xb12c0000), SPH_C32(0x30d80000), + SPH_C32(0x14445000), SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), + SPH_C32(0x2e98bf23), SPH_C32(0x551e3d6e), SPH_C32(0x02f20000), + SPH_C32(0xa2810000), SPH_C32(0x873f0000), SPH_C32(0xe36c7800), + SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), SPH_C32(0xc4c23237), + SPH_C32(0x7f32259e) }, + { SPH_C32(0x0c1e0000), SPH_C32(0xc61f0000), SPH_C32(0x81850000), + SPH_C32(0x6b9454e0), SPH_C32(0xb9fa019a), SPH_C32(0xe0312bb1), + SPH_C32(0xfcce6baa), SPH_C32(0x1b7149b0), SPH_C32(0xe1f40000), + SPH_C32(0x1f400000), SPH_C32(0x002c0000), SPH_C32(0x5c9e7860), + SPH_C32(0x30a77ef5), SPH_C32(0x8a881c87), SPH_C32(0xb7079931), + SPH_C32(0x24e430a7) }, + { SPH_C32(0x5b290000), SPH_C32(0x0ced0000), SPH_C32(0xb7cb0000), + SPH_C32(0xabb65060), SPH_C32(0xefe26ab8), SPH_C32(0xbc92dfbd), + SPH_C32(0x5d5d1425), SPH_C32(0x0ec82857), SPH_C32(0x55c50000), + SPH_C32(0x68730000), SPH_C32(0xb1710000), SPH_C32(0x234e7c80), + SPH_C32(0x48051fcd), SPH_C32(0x5b9edfda), SPH_C32(0x65514db8), + SPH_C32(0x6a8b4479) }, + { SPH_C32(0xef180000), SPH_C32(0x7bde0000), SPH_C32(0x06960000), + SPH_C32(0xd4665480), SPH_C32(0x97400b80), SPH_C32(0x6d841ce0), + SPH_C32(0x8f0bc0ac), SPH_C32(0x40a75c89), SPH_C32(0xb6c30000), + SPH_C32(0xd5b20000), SPH_C32(0x36620000), SPH_C32(0x9cbc7ce0), + SPH_C32(0x66bf15d7), SPH_C32(0xd62be88b), SPH_C32(0x1694e6be), + SPH_C32(0x315d5140) }, + { SPH_C32(0x1e6c0000), SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), + SPH_C32(0xbcb6b800), SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), + SPH_C32(0x6a0c1bc8), SPH_C32(0xb99dc2eb), SPH_C32(0x92560000), + SPH_C32(0x1eda0000), SPH_C32(0xea510000), SPH_C32(0xe8b13000), + SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), SPH_C32(0xb15c2254), + SPH_C32(0x33c5244f) }, + { SPH_C32(0xaa5d0000), SPH_C32(0xb3710000), SPH_C32(0x3b730000), + SPH_C32(0xc366bce0), SPH_C32(0x54e6728e), SPH_C32(0x5aeb1087), + SPH_C32(0xb85acf41), SPH_C32(0xf7f2b635), SPH_C32(0x71500000), + SPH_C32(0xa31b0000), SPH_C32(0x6d420000), SPH_C32(0x57433060), + SPH_C32(0x878f5cbf), SPH_C32(0x664e56c8), SPH_C32(0xc2998952), + SPH_C32(0x68133176) }, + { SPH_C32(0xfd6a0000), SPH_C32(0x79830000), SPH_C32(0x0d3d0000), + SPH_C32(0x0344b860), SPH_C32(0x02fe19ac), SPH_C32(0x0648e48b), + SPH_C32(0x19c9b0ce), SPH_C32(0xe24bd7d2), SPH_C32(0xc5610000), + SPH_C32(0xd4280000), SPH_C32(0xdc1f0000), SPH_C32(0x28933480), + SPH_C32(0xff2d3d87), SPH_C32(0xb7589595), SPH_C32(0x10cf5ddb), + SPH_C32(0x267c45a8) }, + { SPH_C32(0x495b0000), SPH_C32(0x0eb00000), SPH_C32(0xbc600000), + SPH_C32(0x7c94bc80), SPH_C32(0x7a5c7894), SPH_C32(0xd75e27d6), + SPH_C32(0xcb9f6447), SPH_C32(0xac24a30c), SPH_C32(0x26670000), + SPH_C32(0x69e90000), SPH_C32(0x5b0c0000), SPH_C32(0x976134e0), + SPH_C32(0xd197379d), SPH_C32(0x3aeda2c4), SPH_C32(0x630af6dd), + SPH_C32(0x7daa5091) }, + { SPH_C32(0x1c9e0000), SPH_C32(0x66c30000), SPH_C32(0x0d110000), + SPH_C32(0x5fdac000), SPH_C32(0x32596759), SPH_C32(0x8cc0f80c), + SPH_C32(0xaece29ff), SPH_C32(0xc6afe775), SPH_C32(0x288b0000), + SPH_C32(0x0d770000), SPH_C32(0x5db60000), SPH_C32(0x1f991800), + SPH_C32(0x767042e8), SPH_C32(0xdde1a2a3), SPH_C32(0x5b06af40), + SPH_C32(0x19e93cbf) }, + { SPH_C32(0xa8af0000), SPH_C32(0x11f00000), SPH_C32(0xbc4c0000), + SPH_C32(0x200ac4e0), SPH_C32(0x4afb0661), SPH_C32(0x5dd63b51), + SPH_C32(0x7c98fd76), SPH_C32(0x88c093ab), SPH_C32(0xcb8d0000), + SPH_C32(0xb0b60000), SPH_C32(0xdaa50000), SPH_C32(0xa06b1860), + SPH_C32(0x58ca48f2), SPH_C32(0x505495f2), SPH_C32(0x28c30446), + SPH_C32(0x423f2986) }, + { SPH_C32(0xff980000), SPH_C32(0xdb020000), SPH_C32(0x8a020000), + SPH_C32(0xe028c060), SPH_C32(0x1ce36d43), SPH_C32(0x0175cf5d), + SPH_C32(0xdd0b82f9), SPH_C32(0x9d79f24c), SPH_C32(0x7fbc0000), + SPH_C32(0xc7850000), SPH_C32(0x6bf80000), SPH_C32(0xdfbb1c80), + SPH_C32(0x206829ca), SPH_C32(0x814256af), SPH_C32(0xfa95d0cf), + SPH_C32(0x0c505d58) }, + { SPH_C32(0x4ba90000), SPH_C32(0xac310000), SPH_C32(0x3b5f0000), + SPH_C32(0x9ff8c480), SPH_C32(0x64410c7b), SPH_C32(0xd0630c00), + SPH_C32(0x0f5d5670), SPH_C32(0xd3168692), SPH_C32(0x9cba0000), + SPH_C32(0x7a440000), SPH_C32(0xeceb0000), SPH_C32(0x60491ce0), + SPH_C32(0x0ed223d0), SPH_C32(0x0cf761fe), SPH_C32(0x89507bc9), + SPH_C32(0x57864861) }, + { SPH_C32(0xa4b10000), SPH_C32(0xd7ef0000), SPH_C32(0x3dc90000), + SPH_C32(0x4b9e9000), SPH_C32(0xf30107fb), SPH_C32(0xbde710e0), + SPH_C32(0x805696dc), SPH_C32(0x93b1da1b), SPH_C32(0x2a790000), + SPH_C32(0xaff60000), SPH_C32(0xda890000), SPH_C32(0xfcf56000), + SPH_C32(0x686d3607), SPH_C32(0xdadc8975), SPH_C32(0x9fc49d77), + SPH_C32(0x66db1921) }, + { SPH_C32(0x10800000), SPH_C32(0xa0dc0000), SPH_C32(0x8c940000), + SPH_C32(0x344e94e0), SPH_C32(0x8ba366c3), SPH_C32(0x6cf1d3bd), + SPH_C32(0x52004255), SPH_C32(0xdddeaec5), SPH_C32(0xc97f0000), + SPH_C32(0x12370000), SPH_C32(0x5d9a0000), SPH_C32(0x43076060), + SPH_C32(0x46d73c1d), SPH_C32(0x5769be24), SPH_C32(0xec013671), + SPH_C32(0x3d0d0c18) }, + { SPH_C32(0x47b70000), SPH_C32(0x6a2e0000), SPH_C32(0xbada0000), + SPH_C32(0xf46c9060), SPH_C32(0xddbb0de1), SPH_C32(0x305227b1), + SPH_C32(0xf3933dda), SPH_C32(0xc867cf22), SPH_C32(0x7d4e0000), + SPH_C32(0x65040000), SPH_C32(0xecc70000), SPH_C32(0x3cd76480), + SPH_C32(0x3e755d25), SPH_C32(0x867f7d79), SPH_C32(0x3e57e2f8), + SPH_C32(0x736278c6) }, + { SPH_C32(0xf3860000), SPH_C32(0x1d1d0000), SPH_C32(0x0b870000), + SPH_C32(0x8bbc9480), SPH_C32(0xa5196cd9), SPH_C32(0xe144e4ec), + SPH_C32(0x21c5e953), SPH_C32(0x8608bbfc), SPH_C32(0x9e480000), + SPH_C32(0xd8c50000), SPH_C32(0x6bd40000), SPH_C32(0x832564e0), + SPH_C32(0x10cf573f), SPH_C32(0x0bca4a28), SPH_C32(0x4d9249fe), + SPH_C32(0x28b46dff) }, + { SPH_C32(0xa6430000), SPH_C32(0x756e0000), SPH_C32(0xbaf60000), + SPH_C32(0xa8f2e800), SPH_C32(0xed1c7314), SPH_C32(0xbada3b36), + SPH_C32(0x4494a4eb), SPH_C32(0xec83ff85), SPH_C32(0x90a40000), + SPH_C32(0xbc5b0000), SPH_C32(0x6d6e0000), SPH_C32(0x0bdd4800), + SPH_C32(0xb728224a), SPH_C32(0xecc64a4f), SPH_C32(0x759e1063), + SPH_C32(0x4cf701d1) }, + { SPH_C32(0x12720000), SPH_C32(0x025d0000), SPH_C32(0x0bab0000), + SPH_C32(0xd722ece0), SPH_C32(0x95be122c), SPH_C32(0x6bccf86b), + SPH_C32(0x96c27062), SPH_C32(0xa2ec8b5b), SPH_C32(0x73a20000), + SPH_C32(0x019a0000), SPH_C32(0xea7d0000), SPH_C32(0xb42f4860), + SPH_C32(0x99922850), SPH_C32(0x61737d1e), SPH_C32(0x065bbb65), + SPH_C32(0x172114e8) }, + { SPH_C32(0x45450000), SPH_C32(0xc8af0000), SPH_C32(0x3de50000), + SPH_C32(0x1700e860), SPH_C32(0xc3a6790e), SPH_C32(0x376f0c67), + SPH_C32(0x37510fed), SPH_C32(0xb755eabc), SPH_C32(0xc7930000), + SPH_C32(0x76a90000), SPH_C32(0x5b200000), SPH_C32(0xcbff4c80), + SPH_C32(0xe1304968), SPH_C32(0xb065be43), SPH_C32(0xd40d6fec), + SPH_C32(0x594e6036) }, + { SPH_C32(0xf1740000), SPH_C32(0xbf9c0000), SPH_C32(0x8cb80000), + SPH_C32(0x68d0ec80), SPH_C32(0xbb041836), SPH_C32(0xe679cf3a), + SPH_C32(0xe507db64), SPH_C32(0xf93a9e62), SPH_C32(0x24950000), + SPH_C32(0xcb680000), SPH_C32(0xdc330000), SPH_C32(0x740d4ce0), + SPH_C32(0xcf8a4372), SPH_C32(0x3dd08912), SPH_C32(0xa7c8c4ea), + SPH_C32(0x0298750f) }, + { SPH_C32(0x92560000), SPH_C32(0x1eda0000), SPH_C32(0xea510000), + SPH_C32(0xe8b13000), SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), + SPH_C32(0xb15c2254), SPH_C32(0x33c5244f), SPH_C32(0x8c3a0000), + SPH_C32(0xda980000), SPH_C32(0x607f0000), SPH_C32(0x54078800), + SPH_C32(0x85714513), SPH_C32(0x6006b243), SPH_C32(0xdb50399c), + SPH_C32(0x8a58e6a4) }, + { SPH_C32(0x26670000), SPH_C32(0x69e90000), SPH_C32(0x5b0c0000), + SPH_C32(0x976134e0), SPH_C32(0xd197379d), SPH_C32(0x3aeda2c4), + SPH_C32(0x630af6dd), SPH_C32(0x7daa5091), SPH_C32(0x6f3c0000), + SPH_C32(0x67590000), SPH_C32(0xe76c0000), SPH_C32(0xebf58860), + SPH_C32(0xabcb4f09), SPH_C32(0xedb38512), SPH_C32(0xa895929a), + SPH_C32(0xd18ef39d) }, + { SPH_C32(0x71500000), SPH_C32(0xa31b0000), SPH_C32(0x6d420000), + SPH_C32(0x57433060), SPH_C32(0x878f5cbf), SPH_C32(0x664e56c8), + SPH_C32(0xc2998952), SPH_C32(0x68133176), SPH_C32(0xdb0d0000), + SPH_C32(0x106a0000), SPH_C32(0x56310000), SPH_C32(0x94258c80), + SPH_C32(0xd3692e31), SPH_C32(0x3ca5464f), SPH_C32(0x7ac34613), + SPH_C32(0x9fe18743) }, + { SPH_C32(0xc5610000), SPH_C32(0xd4280000), SPH_C32(0xdc1f0000), + SPH_C32(0x28933480), SPH_C32(0xff2d3d87), SPH_C32(0xb7589595), + SPH_C32(0x10cf5ddb), SPH_C32(0x267c45a8), SPH_C32(0x380b0000), + SPH_C32(0xadab0000), SPH_C32(0xd1220000), SPH_C32(0x2bd78ce0), + SPH_C32(0xfdd3242b), SPH_C32(0xb110711e), SPH_C32(0x0906ed15), + SPH_C32(0xc437927a) }, + { SPH_C32(0x90a40000), SPH_C32(0xbc5b0000), SPH_C32(0x6d6e0000), + SPH_C32(0x0bdd4800), SPH_C32(0xb728224a), SPH_C32(0xecc64a4f), + SPH_C32(0x759e1063), SPH_C32(0x4cf701d1), SPH_C32(0x36e70000), + SPH_C32(0xc9350000), SPH_C32(0xd7980000), SPH_C32(0xa32fa000), + SPH_C32(0x5a34515e), SPH_C32(0x561c7179), SPH_C32(0x310ab488), + SPH_C32(0xa074fe54) }, + { SPH_C32(0x24950000), SPH_C32(0xcb680000), SPH_C32(0xdc330000), + SPH_C32(0x740d4ce0), SPH_C32(0xcf8a4372), SPH_C32(0x3dd08912), + SPH_C32(0xa7c8c4ea), SPH_C32(0x0298750f), SPH_C32(0xd5e10000), + SPH_C32(0x74f40000), SPH_C32(0x508b0000), SPH_C32(0x1cdda060), + SPH_C32(0x748e5b44), SPH_C32(0xdba94628), SPH_C32(0x42cf1f8e), + SPH_C32(0xfba2eb6d) }, + { SPH_C32(0x73a20000), SPH_C32(0x019a0000), SPH_C32(0xea7d0000), + SPH_C32(0xb42f4860), SPH_C32(0x99922850), SPH_C32(0x61737d1e), + SPH_C32(0x065bbb65), SPH_C32(0x172114e8), SPH_C32(0x61d00000), + SPH_C32(0x03c70000), SPH_C32(0xe1d60000), SPH_C32(0x630da480), + SPH_C32(0x0c2c3a7c), SPH_C32(0x0abf8575), SPH_C32(0x9099cb07), + SPH_C32(0xb5cd9fb3) }, + { SPH_C32(0xc7930000), SPH_C32(0x76a90000), SPH_C32(0x5b200000), + SPH_C32(0xcbff4c80), SPH_C32(0xe1304968), SPH_C32(0xb065be43), + SPH_C32(0xd40d6fec), SPH_C32(0x594e6036), SPH_C32(0x82d60000), + SPH_C32(0xbe060000), SPH_C32(0x66c50000), SPH_C32(0xdcffa4e0), + SPH_C32(0x22963066), SPH_C32(0x870ab224), SPH_C32(0xe35c6001), + SPH_C32(0xee1b8a8a) }, + { SPH_C32(0x288b0000), SPH_C32(0x0d770000), SPH_C32(0x5db60000), + SPH_C32(0x1f991800), SPH_C32(0x767042e8), SPH_C32(0xdde1a2a3), + SPH_C32(0x5b06af40), SPH_C32(0x19e93cbf), SPH_C32(0x34150000), + SPH_C32(0x6bb40000), SPH_C32(0x50a70000), SPH_C32(0x4043d800), + SPH_C32(0x442925b1), SPH_C32(0x51215aaf), SPH_C32(0xf5c886bf), + SPH_C32(0xdf46dbca) }, + { SPH_C32(0x9cba0000), SPH_C32(0x7a440000), SPH_C32(0xeceb0000), + SPH_C32(0x60491ce0), SPH_C32(0x0ed223d0), SPH_C32(0x0cf761fe), + SPH_C32(0x89507bc9), SPH_C32(0x57864861), SPH_C32(0xd7130000), + SPH_C32(0xd6750000), SPH_C32(0xd7b40000), SPH_C32(0xffb1d860), + SPH_C32(0x6a932fab), SPH_C32(0xdc946dfe), SPH_C32(0x860d2db9), + SPH_C32(0x8490cef3) }, + { SPH_C32(0xcb8d0000), SPH_C32(0xb0b60000), SPH_C32(0xdaa50000), + SPH_C32(0xa06b1860), SPH_C32(0x58ca48f2), SPH_C32(0x505495f2), + SPH_C32(0x28c30446), SPH_C32(0x423f2986), SPH_C32(0x63220000), + SPH_C32(0xa1460000), SPH_C32(0x66e90000), SPH_C32(0x8061dc80), + SPH_C32(0x12314e93), SPH_C32(0x0d82aea3), SPH_C32(0x545bf930), + SPH_C32(0xcaffba2d) }, + { SPH_C32(0x7fbc0000), SPH_C32(0xc7850000), SPH_C32(0x6bf80000), + SPH_C32(0xdfbb1c80), SPH_C32(0x206829ca), SPH_C32(0x814256af), + SPH_C32(0xfa95d0cf), SPH_C32(0x0c505d58), SPH_C32(0x80240000), + SPH_C32(0x1c870000), SPH_C32(0xe1fa0000), SPH_C32(0x3f93dce0), + SPH_C32(0x3c8b4489), SPH_C32(0x803799f2), SPH_C32(0x279e5236), + SPH_C32(0x9129af14) }, + { SPH_C32(0x2a790000), SPH_C32(0xaff60000), SPH_C32(0xda890000), + SPH_C32(0xfcf56000), SPH_C32(0x686d3607), SPH_C32(0xdadc8975), + SPH_C32(0x9fc49d77), SPH_C32(0x66db1921), SPH_C32(0x8ec80000), + SPH_C32(0x78190000), SPH_C32(0xe7400000), SPH_C32(0xb76bf000), + SPH_C32(0x9b6c31fc), SPH_C32(0x673b9995), SPH_C32(0x1f920bab), + SPH_C32(0xf56ac33a) }, + { SPH_C32(0x9e480000), SPH_C32(0xd8c50000), SPH_C32(0x6bd40000), + SPH_C32(0x832564e0), SPH_C32(0x10cf573f), SPH_C32(0x0bca4a28), + SPH_C32(0x4d9249fe), SPH_C32(0x28b46dff), SPH_C32(0x6dce0000), + SPH_C32(0xc5d80000), SPH_C32(0x60530000), SPH_C32(0x0899f060), + SPH_C32(0xb5d63be6), SPH_C32(0xea8eaec4), SPH_C32(0x6c57a0ad), + SPH_C32(0xaebcd603) }, + { SPH_C32(0xc97f0000), SPH_C32(0x12370000), SPH_C32(0x5d9a0000), + SPH_C32(0x43076060), SPH_C32(0x46d73c1d), SPH_C32(0x5769be24), + SPH_C32(0xec013671), SPH_C32(0x3d0d0c18), SPH_C32(0xd9ff0000), + SPH_C32(0xb2eb0000), SPH_C32(0xd10e0000), SPH_C32(0x7749f480), + SPH_C32(0xcd745ade), SPH_C32(0x3b986d99), SPH_C32(0xbe017424), + SPH_C32(0xe0d3a2dd) }, + { SPH_C32(0x7d4e0000), SPH_C32(0x65040000), SPH_C32(0xecc70000), + SPH_C32(0x3cd76480), SPH_C32(0x3e755d25), SPH_C32(0x867f7d79), + SPH_C32(0x3e57e2f8), SPH_C32(0x736278c6), SPH_C32(0x3af90000), + SPH_C32(0x0f2a0000), SPH_C32(0x561d0000), SPH_C32(0xc8bbf4e0), + SPH_C32(0xe3ce50c4), SPH_C32(0xb62d5ac8), SPH_C32(0xcdc4df22), + SPH_C32(0xbb05b7e4) }, + { SPH_C32(0x8c3a0000), SPH_C32(0xda980000), SPH_C32(0x607f0000), + SPH_C32(0x54078800), SPH_C32(0x85714513), SPH_C32(0x6006b243), + SPH_C32(0xdb50399c), SPH_C32(0x8a58e6a4), SPH_C32(0x1e6c0000), + SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), SPH_C32(0xbcb6b800), + SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), SPH_C32(0x6a0c1bc8), + SPH_C32(0xb99dc2eb) }, + { SPH_C32(0x380b0000), SPH_C32(0xadab0000), SPH_C32(0xd1220000), + SPH_C32(0x2bd78ce0), SPH_C32(0xfdd3242b), SPH_C32(0xb110711e), + SPH_C32(0x0906ed15), SPH_C32(0xc437927a), SPH_C32(0xfd6a0000), + SPH_C32(0x79830000), SPH_C32(0x0d3d0000), SPH_C32(0x0344b860), + SPH_C32(0x02fe19ac), SPH_C32(0x0648e48b), SPH_C32(0x19c9b0ce), + SPH_C32(0xe24bd7d2) }, + { SPH_C32(0x6f3c0000), SPH_C32(0x67590000), SPH_C32(0xe76c0000), + SPH_C32(0xebf58860), SPH_C32(0xabcb4f09), SPH_C32(0xedb38512), + SPH_C32(0xa895929a), SPH_C32(0xd18ef39d), SPH_C32(0x495b0000), + SPH_C32(0x0eb00000), SPH_C32(0xbc600000), SPH_C32(0x7c94bc80), + SPH_C32(0x7a5c7894), SPH_C32(0xd75e27d6), SPH_C32(0xcb9f6447), + SPH_C32(0xac24a30c) }, + { SPH_C32(0xdb0d0000), SPH_C32(0x106a0000), SPH_C32(0x56310000), + SPH_C32(0x94258c80), SPH_C32(0xd3692e31), SPH_C32(0x3ca5464f), + SPH_C32(0x7ac34613), SPH_C32(0x9fe18743), SPH_C32(0xaa5d0000), + SPH_C32(0xb3710000), SPH_C32(0x3b730000), SPH_C32(0xc366bce0), + SPH_C32(0x54e6728e), SPH_C32(0x5aeb1087), SPH_C32(0xb85acf41), + SPH_C32(0xf7f2b635) }, + { SPH_C32(0x8ec80000), SPH_C32(0x78190000), SPH_C32(0xe7400000), + SPH_C32(0xb76bf000), SPH_C32(0x9b6c31fc), SPH_C32(0x673b9995), + SPH_C32(0x1f920bab), SPH_C32(0xf56ac33a), SPH_C32(0xa4b10000), + SPH_C32(0xd7ef0000), SPH_C32(0x3dc90000), SPH_C32(0x4b9e9000), + SPH_C32(0xf30107fb), SPH_C32(0xbde710e0), SPH_C32(0x805696dc), + SPH_C32(0x93b1da1b) }, + { SPH_C32(0x3af90000), SPH_C32(0x0f2a0000), SPH_C32(0x561d0000), + SPH_C32(0xc8bbf4e0), SPH_C32(0xe3ce50c4), SPH_C32(0xb62d5ac8), + SPH_C32(0xcdc4df22), SPH_C32(0xbb05b7e4), SPH_C32(0x47b70000), + SPH_C32(0x6a2e0000), SPH_C32(0xbada0000), SPH_C32(0xf46c9060), + SPH_C32(0xddbb0de1), SPH_C32(0x305227b1), SPH_C32(0xf3933dda), + SPH_C32(0xc867cf22) }, + { SPH_C32(0x6dce0000), SPH_C32(0xc5d80000), SPH_C32(0x60530000), + SPH_C32(0x0899f060), SPH_C32(0xb5d63be6), SPH_C32(0xea8eaec4), + SPH_C32(0x6c57a0ad), SPH_C32(0xaebcd603), SPH_C32(0xf3860000), + SPH_C32(0x1d1d0000), SPH_C32(0x0b870000), SPH_C32(0x8bbc9480), + SPH_C32(0xa5196cd9), SPH_C32(0xe144e4ec), SPH_C32(0x21c5e953), + SPH_C32(0x8608bbfc) }, + { SPH_C32(0xd9ff0000), SPH_C32(0xb2eb0000), SPH_C32(0xd10e0000), + SPH_C32(0x7749f480), SPH_C32(0xcd745ade), SPH_C32(0x3b986d99), + SPH_C32(0xbe017424), SPH_C32(0xe0d3a2dd), SPH_C32(0x10800000), + SPH_C32(0xa0dc0000), SPH_C32(0x8c940000), SPH_C32(0x344e94e0), + SPH_C32(0x8ba366c3), SPH_C32(0x6cf1d3bd), SPH_C32(0x52004255), + SPH_C32(0xdddeaec5) }, + { SPH_C32(0x36e70000), SPH_C32(0xc9350000), SPH_C32(0xd7980000), + SPH_C32(0xa32fa000), SPH_C32(0x5a34515e), SPH_C32(0x561c7179), + SPH_C32(0x310ab488), SPH_C32(0xa074fe54), SPH_C32(0xa6430000), + SPH_C32(0x756e0000), SPH_C32(0xbaf60000), SPH_C32(0xa8f2e800), + SPH_C32(0xed1c7314), SPH_C32(0xbada3b36), SPH_C32(0x4494a4eb), + SPH_C32(0xec83ff85) }, + { SPH_C32(0x82d60000), SPH_C32(0xbe060000), SPH_C32(0x66c50000), + SPH_C32(0xdcffa4e0), SPH_C32(0x22963066), SPH_C32(0x870ab224), + SPH_C32(0xe35c6001), SPH_C32(0xee1b8a8a), SPH_C32(0x45450000), + SPH_C32(0xc8af0000), SPH_C32(0x3de50000), SPH_C32(0x1700e860), + SPH_C32(0xc3a6790e), SPH_C32(0x376f0c67), SPH_C32(0x37510fed), + SPH_C32(0xb755eabc) }, + { SPH_C32(0xd5e10000), SPH_C32(0x74f40000), SPH_C32(0x508b0000), + SPH_C32(0x1cdda060), SPH_C32(0x748e5b44), SPH_C32(0xdba94628), + SPH_C32(0x42cf1f8e), SPH_C32(0xfba2eb6d), SPH_C32(0xf1740000), + SPH_C32(0xbf9c0000), SPH_C32(0x8cb80000), SPH_C32(0x68d0ec80), + SPH_C32(0xbb041836), SPH_C32(0xe679cf3a), SPH_C32(0xe507db64), + SPH_C32(0xf93a9e62) }, + { SPH_C32(0x61d00000), SPH_C32(0x03c70000), SPH_C32(0xe1d60000), + SPH_C32(0x630da480), SPH_C32(0x0c2c3a7c), SPH_C32(0x0abf8575), + SPH_C32(0x9099cb07), SPH_C32(0xb5cd9fb3), SPH_C32(0x12720000), + SPH_C32(0x025d0000), SPH_C32(0x0bab0000), SPH_C32(0xd722ece0), + SPH_C32(0x95be122c), SPH_C32(0x6bccf86b), SPH_C32(0x96c27062), + SPH_C32(0xa2ec8b5b) }, + { SPH_C32(0x34150000), SPH_C32(0x6bb40000), SPH_C32(0x50a70000), + SPH_C32(0x4043d800), SPH_C32(0x442925b1), SPH_C32(0x51215aaf), + SPH_C32(0xf5c886bf), SPH_C32(0xdf46dbca), SPH_C32(0x1c9e0000), + SPH_C32(0x66c30000), SPH_C32(0x0d110000), SPH_C32(0x5fdac000), + SPH_C32(0x32596759), SPH_C32(0x8cc0f80c), SPH_C32(0xaece29ff), + SPH_C32(0xc6afe775) }, + { SPH_C32(0x80240000), SPH_C32(0x1c870000), SPH_C32(0xe1fa0000), + SPH_C32(0x3f93dce0), SPH_C32(0x3c8b4489), SPH_C32(0x803799f2), + SPH_C32(0x279e5236), SPH_C32(0x9129af14), SPH_C32(0xff980000), + SPH_C32(0xdb020000), SPH_C32(0x8a020000), SPH_C32(0xe028c060), + SPH_C32(0x1ce36d43), SPH_C32(0x0175cf5d), SPH_C32(0xdd0b82f9), + SPH_C32(0x9d79f24c) }, + { SPH_C32(0xd7130000), SPH_C32(0xd6750000), SPH_C32(0xd7b40000), + SPH_C32(0xffb1d860), SPH_C32(0x6a932fab), SPH_C32(0xdc946dfe), + SPH_C32(0x860d2db9), SPH_C32(0x8490cef3), SPH_C32(0x4ba90000), + SPH_C32(0xac310000), SPH_C32(0x3b5f0000), SPH_C32(0x9ff8c480), + SPH_C32(0x64410c7b), SPH_C32(0xd0630c00), SPH_C32(0x0f5d5670), + SPH_C32(0xd3168692) }, + { SPH_C32(0x63220000), SPH_C32(0xa1460000), SPH_C32(0x66e90000), + SPH_C32(0x8061dc80), SPH_C32(0x12314e93), SPH_C32(0x0d82aea3), + SPH_C32(0x545bf930), SPH_C32(0xcaffba2d), SPH_C32(0xa8af0000), + SPH_C32(0x11f00000), SPH_C32(0xbc4c0000), SPH_C32(0x200ac4e0), + SPH_C32(0x4afb0661), SPH_C32(0x5dd63b51), SPH_C32(0x7c98fd76), + SPH_C32(0x88c093ab) } +}; + +static const sph_u32 T512_54[64][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x5fa80000), SPH_C32(0x56030000), SPH_C32(0x43ae0000), + SPH_C32(0x64f30013), SPH_C32(0x257e86bf), SPH_C32(0x1311944e), + SPH_C32(0x541e95bf), SPH_C32(0x8ea4db69), SPH_C32(0x00440000), + SPH_C32(0x7f480000), SPH_C32(0xda7c0000), SPH_C32(0x2a230001), + SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), SPH_C32(0x030a9e60), + SPH_C32(0xbe0a679e) }, + { SPH_C32(0x00440000), SPH_C32(0x7f480000), SPH_C32(0xda7c0000), + SPH_C32(0x2a230001), SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), + SPH_C32(0x030a9e60), SPH_C32(0xbe0a679e), SPH_C32(0x5fec0000), + SPH_C32(0x294b0000), SPH_C32(0x99d20000), SPH_C32(0x4ed00012), + SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), SPH_C32(0x57140bdf), + SPH_C32(0x30aebcf7) }, + { SPH_C32(0x5fec0000), SPH_C32(0x294b0000), SPH_C32(0x99d20000), + SPH_C32(0x4ed00012), SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), + SPH_C32(0x57140bdf), SPH_C32(0x30aebcf7), SPH_C32(0x5fa80000), + SPH_C32(0x56030000), SPH_C32(0x43ae0000), SPH_C32(0x64f30013), + SPH_C32(0x257e86bf), SPH_C32(0x1311944e), SPH_C32(0x541e95bf), + SPH_C32(0x8ea4db69) }, + { SPH_C32(0xee930000), SPH_C32(0xd6070000), SPH_C32(0x92c10000), + SPH_C32(0x2b9801e0), SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), + SPH_C32(0x45312374), SPH_C32(0x201f6a64), SPH_C32(0x7b280000), + SPH_C32(0x57420000), SPH_C32(0xa9e50000), SPH_C32(0x634300a0), + SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), SPH_C32(0x27f83b03), + SPH_C32(0xc7ff60f0) }, + { SPH_C32(0xb13b0000), SPH_C32(0x80040000), SPH_C32(0xd16f0000), + SPH_C32(0x4f6b01f3), SPH_C32(0xb12faec3), SPH_C32(0x287d6f19), + SPH_C32(0x112fb6cb), SPH_C32(0xaebbb10d), SPH_C32(0x7b6c0000), + SPH_C32(0x280a0000), SPH_C32(0x73990000), SPH_C32(0x496000a1), + SPH_C32(0xa5768de3), SPH_C32(0xc42f093c), SPH_C32(0x24f2a563), + SPH_C32(0x79f5076e) }, + { SPH_C32(0xeed70000), SPH_C32(0xa94f0000), SPH_C32(0x48bd0000), + SPH_C32(0x01bb01e1), SPH_C32(0xaffce1b0), SPH_C32(0x92da67d0), + SPH_C32(0x463bbd14), SPH_C32(0x9e150dfa), SPH_C32(0x24c40000), + SPH_C32(0x7e090000), SPH_C32(0x30370000), SPH_C32(0x2d9300b2), + SPH_C32(0x80080b5c), SPH_C32(0xd73e9d72), SPH_C32(0x70ec30dc), + SPH_C32(0xf751dc07) }, + { SPH_C32(0xb17f0000), SPH_C32(0xff4c0000), SPH_C32(0x0b130000), + SPH_C32(0x654801f2), SPH_C32(0x8a82670f), SPH_C32(0x81cbf39e), + SPH_C32(0x122528ab), SPH_C32(0x10b1d693), SPH_C32(0x24800000), + SPH_C32(0x01410000), SPH_C32(0xea4b0000), SPH_C32(0x07b000b3), + SPH_C32(0xbba5c290), SPH_C32(0x7e8801f5), SPH_C32(0x73e6aebc), + SPH_C32(0x495bbb99) }, + { SPH_C32(0x7b280000), SPH_C32(0x57420000), SPH_C32(0xa9e50000), + SPH_C32(0x634300a0), SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), + SPH_C32(0x27f83b03), SPH_C32(0xc7ff60f0), SPH_C32(0x95bb0000), + SPH_C32(0x81450000), SPH_C32(0x3b240000), SPH_C32(0x48db0140), + SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), SPH_C32(0x62c91877), + SPH_C32(0xe7e00a94) }, + { SPH_C32(0x24800000), SPH_C32(0x01410000), SPH_C32(0xea4b0000), + SPH_C32(0x07b000b3), SPH_C32(0xbba5c290), SPH_C32(0x7e8801f5), + SPH_C32(0x73e6aebc), SPH_C32(0x495bbb99), SPH_C32(0x95ff0000), + SPH_C32(0xfe0d0000), SPH_C32(0xe1580000), SPH_C32(0x62f80141), + SPH_C32(0x3127a59f), SPH_C32(0xff43f26b), SPH_C32(0x61c38617), + SPH_C32(0x59ea6d0a) }, + { SPH_C32(0x7b6c0000), SPH_C32(0x280a0000), SPH_C32(0x73990000), + SPH_C32(0x496000a1), SPH_C32(0xa5768de3), SPH_C32(0xc42f093c), + SPH_C32(0x24f2a563), SPH_C32(0x79f5076e), SPH_C32(0xca570000), + SPH_C32(0xa80e0000), SPH_C32(0xa2f60000), SPH_C32(0x060b0152), + SPH_C32(0x14592320), SPH_C32(0xec526625), SPH_C32(0x35dd13a8), + SPH_C32(0xd74eb663) }, + { SPH_C32(0x24c40000), SPH_C32(0x7e090000), SPH_C32(0x30370000), + SPH_C32(0x2d9300b2), SPH_C32(0x80080b5c), SPH_C32(0xd73e9d72), + SPH_C32(0x70ec30dc), SPH_C32(0xf751dc07), SPH_C32(0xca130000), + SPH_C32(0xd7460000), SPH_C32(0x788a0000), SPH_C32(0x2c280153), + SPH_C32(0x2ff4eaec), SPH_C32(0x45e4faa2), SPH_C32(0x36d78dc8), + SPH_C32(0x6944d1fd) }, + { SPH_C32(0x95bb0000), SPH_C32(0x81450000), SPH_C32(0x3b240000), + SPH_C32(0x48db0140), SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), + SPH_C32(0x62c91877), SPH_C32(0xe7e00a94), SPH_C32(0xee930000), + SPH_C32(0xd6070000), SPH_C32(0x92c10000), SPH_C32(0x2b9801e0), + SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), SPH_C32(0x45312374), + SPH_C32(0x201f6a64) }, + { SPH_C32(0xca130000), SPH_C32(0xd7460000), SPH_C32(0x788a0000), + SPH_C32(0x2c280153), SPH_C32(0x2ff4eaec), SPH_C32(0x45e4faa2), + SPH_C32(0x36d78dc8), SPH_C32(0x6944d1fd), SPH_C32(0xeed70000), + SPH_C32(0xa94f0000), SPH_C32(0x48bd0000), SPH_C32(0x01bb01e1), + SPH_C32(0xaffce1b0), SPH_C32(0x92da67d0), SPH_C32(0x463bbd14), + SPH_C32(0x9e150dfa) }, + { SPH_C32(0x95ff0000), SPH_C32(0xfe0d0000), SPH_C32(0xe1580000), + SPH_C32(0x62f80141), SPH_C32(0x3127a59f), SPH_C32(0xff43f26b), + SPH_C32(0x61c38617), SPH_C32(0x59ea6d0a), SPH_C32(0xb17f0000), + SPH_C32(0xff4c0000), SPH_C32(0x0b130000), SPH_C32(0x654801f2), + SPH_C32(0x8a82670f), SPH_C32(0x81cbf39e), SPH_C32(0x122528ab), + SPH_C32(0x10b1d693) }, + { SPH_C32(0xca570000), SPH_C32(0xa80e0000), SPH_C32(0xa2f60000), + SPH_C32(0x060b0152), SPH_C32(0x14592320), SPH_C32(0xec526625), + SPH_C32(0x35dd13a8), SPH_C32(0xd74eb663), SPH_C32(0xb13b0000), + SPH_C32(0x80040000), SPH_C32(0xd16f0000), SPH_C32(0x4f6b01f3), + SPH_C32(0xb12faec3), SPH_C32(0x287d6f19), SPH_C32(0x112fb6cb), + SPH_C32(0xaebbb10d) }, + { SPH_C32(0xe6280000), SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), + SPH_C32(0xd3d002e0), SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), + SPH_C32(0x289506b4), SPH_C32(0xd75a4897), SPH_C32(0xf0c50000), + SPH_C32(0x59230000), SPH_C32(0x45820000), SPH_C32(0xe18d00c0), + SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), SPH_C32(0xcbe0fe1c), + SPH_C32(0x56a7b19f) }, + { SPH_C32(0xb9800000), SPH_C32(0x1a480000), SPH_C32(0xebfb0000), + SPH_C32(0xb72302f3), SPH_C32(0xfd1fb607), SPH_C32(0x8bb62494), + SPH_C32(0x7c8b930b), SPH_C32(0x59fe93fe), SPH_C32(0xf0810000), + SPH_C32(0x266b0000), SPH_C32(0x9ffe0000), SPH_C32(0xcbae00c1), + SPH_C32(0x00c0cffd), SPH_C32(0x6b5bca1e), SPH_C32(0xc8ea607c), + SPH_C32(0xe8add601) }, + { SPH_C32(0xe66c0000), SPH_C32(0x33030000), SPH_C32(0x72290000), + SPH_C32(0xf9f302e1), SPH_C32(0xe3ccf974), SPH_C32(0x31112c5d), + SPH_C32(0x2b9f98d4), SPH_C32(0x69502f09), SPH_C32(0xaf290000), + SPH_C32(0x70680000), SPH_C32(0xdc500000), SPH_C32(0xaf5d00d2), + SPH_C32(0x25be4942), SPH_C32(0x784a5e50), SPH_C32(0x9cf4f5c3), + SPH_C32(0x66090d68) }, + { SPH_C32(0xb9c40000), SPH_C32(0x65000000), SPH_C32(0x31870000), + SPH_C32(0x9d0002f2), SPH_C32(0xc6b27fcb), SPH_C32(0x2200b813), + SPH_C32(0x7f810d6b), SPH_C32(0xe7f4f460), SPH_C32(0xaf6d0000), + SPH_C32(0x0f200000), SPH_C32(0x062c0000), SPH_C32(0x857e00d3), + SPH_C32(0x1e13808e), SPH_C32(0xd1fcc2d7), SPH_C32(0x9ffe6ba3), + SPH_C32(0xd8036af6) }, + { SPH_C32(0x08bb0000), SPH_C32(0x9a4c0000), SPH_C32(0x3a940000), + SPH_C32(0xf8480300), SPH_C32(0x4c3018c4), SPH_C32(0xa3cb4b8d), + SPH_C32(0x6da425c0), SPH_C32(0xf74522f3), SPH_C32(0x8bed0000), + SPH_C32(0x0e610000), SPH_C32(0xec670000), SPH_C32(0x82ce0060), + SPH_C32(0xa5b6421e), SPH_C32(0xaf74c322), SPH_C32(0xec18c51f), + SPH_C32(0x9158d16f) }, + { SPH_C32(0x57130000), SPH_C32(0xcc4f0000), SPH_C32(0x793a0000), + SPH_C32(0x9cbb0313), SPH_C32(0x694e9e7b), SPH_C32(0xb0dadfc3), + SPH_C32(0x39bab07f), SPH_C32(0x79e1f99a), SPH_C32(0x8ba90000), + SPH_C32(0x71290000), SPH_C32(0x361b0000), SPH_C32(0xa8ed0061), + SPH_C32(0x9e1b8bd2), SPH_C32(0x06c25fa5), SPH_C32(0xef125b7f), + SPH_C32(0x2f52b6f1) }, + { SPH_C32(0x08ff0000), SPH_C32(0xe5040000), SPH_C32(0xe0e80000), + SPH_C32(0xd26b0301), SPH_C32(0x779dd108), SPH_C32(0x0a7dd70a), + SPH_C32(0x6eaebba0), SPH_C32(0x494f456d), SPH_C32(0xd4010000), + SPH_C32(0x272a0000), SPH_C32(0x75b50000), SPH_C32(0xcc1e0072), + SPH_C32(0xbb650d6d), SPH_C32(0x15d3cbeb), SPH_C32(0xbb0ccec0), + SPH_C32(0xa1f66d98) }, + { SPH_C32(0x57570000), SPH_C32(0xb3070000), SPH_C32(0xa3460000), + SPH_C32(0xb6980312), SPH_C32(0x52e357b7), SPH_C32(0x196c4344), + SPH_C32(0x3ab02e1f), SPH_C32(0xc7eb9e04), SPH_C32(0xd4450000), + SPH_C32(0x58620000), SPH_C32(0xafc90000), SPH_C32(0xe63d0073), + SPH_C32(0x80c8c4a1), SPH_C32(0xbc65576c), SPH_C32(0xb80650a0), + SPH_C32(0x1ffc0a06) }, + { SPH_C32(0x9d000000), SPH_C32(0x1b090000), SPH_C32(0x01b00000), + SPH_C32(0xb0930240), SPH_C32(0x46ba7497), SPH_C32(0xf53e2561), + SPH_C32(0x0f6d3db7), SPH_C32(0x10a52867), SPH_C32(0x657e0000), + SPH_C32(0xd8660000), SPH_C32(0x7ea60000), SPH_C32(0xa9560180), + SPH_C32(0x31e76a62), SPH_C32(0x94183875), SPH_C32(0xa929e66b), + SPH_C32(0xb147bb0b) }, + { SPH_C32(0xc2a80000), SPH_C32(0x4d0a0000), SPH_C32(0x421e0000), + SPH_C32(0xd4600253), SPH_C32(0x63c4f228), SPH_C32(0xe62fb12f), + SPH_C32(0x5b73a808), SPH_C32(0x9e01f30e), SPH_C32(0x653a0000), + SPH_C32(0xa72e0000), SPH_C32(0xa4da0000), SPH_C32(0x83750181), + SPH_C32(0x0a4aa3ae), SPH_C32(0x3daea4f2), SPH_C32(0xaa23780b), + SPH_C32(0x0f4ddc95) }, + { SPH_C32(0x9d440000), SPH_C32(0x64410000), SPH_C32(0xdbcc0000), + SPH_C32(0x9ab00241), SPH_C32(0x7d17bd5b), SPH_C32(0x5c88b9e6), + SPH_C32(0x0c67a3d7), SPH_C32(0xaeaf4ff9), SPH_C32(0x3a920000), + SPH_C32(0xf12d0000), SPH_C32(0xe7740000), SPH_C32(0xe7860192), + SPH_C32(0x2f342511), SPH_C32(0x2ebf30bc), SPH_C32(0xfe3dedb4), + SPH_C32(0x81e907fc) }, + { SPH_C32(0xc2ec0000), SPH_C32(0x32420000), SPH_C32(0x98620000), + SPH_C32(0xfe430252), SPH_C32(0x58693be4), SPH_C32(0x4f992da8), + SPH_C32(0x58793668), SPH_C32(0x200b9490), SPH_C32(0x3ad60000), + SPH_C32(0x8e650000), SPH_C32(0x3d080000), SPH_C32(0xcda50193), + SPH_C32(0x1499ecdd), SPH_C32(0x8709ac3b), SPH_C32(0xfd3773d4), + SPH_C32(0x3fe36062) }, + { SPH_C32(0x73930000), SPH_C32(0xcd0e0000), SPH_C32(0x93710000), + SPH_C32(0x9b0b03a0), SPH_C32(0xd2eb5ceb), SPH_C32(0xce52de36), + SPH_C32(0x4a5c1ec3), SPH_C32(0x30ba4203), SPH_C32(0x1e560000), + SPH_C32(0x8f240000), SPH_C32(0xd7430000), SPH_C32(0xca150120), + SPH_C32(0xaf3c2e4d), SPH_C32(0xf981adce), SPH_C32(0x8ed1dd68), + SPH_C32(0x76b8dbfb) }, + { SPH_C32(0x2c3b0000), SPH_C32(0x9b0d0000), SPH_C32(0xd0df0000), + SPH_C32(0xfff803b3), SPH_C32(0xf795da54), SPH_C32(0xdd434a78), + SPH_C32(0x1e428b7c), SPH_C32(0xbe1e996a), SPH_C32(0x1e120000), + SPH_C32(0xf06c0000), SPH_C32(0x0d3f0000), SPH_C32(0xe0360121), + SPH_C32(0x9491e781), SPH_C32(0x50373149), SPH_C32(0x8ddb4308), + SPH_C32(0xc8b2bc65) }, + { SPH_C32(0x73d70000), SPH_C32(0xb2460000), SPH_C32(0x490d0000), + SPH_C32(0xb12803a1), SPH_C32(0xe9469527), SPH_C32(0x67e442b1), + SPH_C32(0x495680a3), SPH_C32(0x8eb0259d), SPH_C32(0x41ba0000), + SPH_C32(0xa66f0000), SPH_C32(0x4e910000), SPH_C32(0x84c50132), + SPH_C32(0xb1ef613e), SPH_C32(0x4326a507), SPH_C32(0xd9c5d6b7), + SPH_C32(0x4616670c) }, + { SPH_C32(0x2c7f0000), SPH_C32(0xe4450000), SPH_C32(0x0aa30000), + SPH_C32(0xd5db03b2), SPH_C32(0xcc381398), SPH_C32(0x74f5d6ff), + SPH_C32(0x1d48151c), SPH_C32(0x0014fef4), SPH_C32(0x41fe0000), + SPH_C32(0xd9270000), SPH_C32(0x94ed0000), SPH_C32(0xaee60133), + SPH_C32(0x8a42a8f2), SPH_C32(0xea903980), SPH_C32(0xdacf48d7), + SPH_C32(0xf81c0092) }, + { SPH_C32(0xf0c50000), SPH_C32(0x59230000), SPH_C32(0x45820000), + SPH_C32(0xe18d00c0), SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), + SPH_C32(0xcbe0fe1c), SPH_C32(0x56a7b19f), SPH_C32(0x16ed0000), + SPH_C32(0x15680000), SPH_C32(0xedd70000), SPH_C32(0x325d0220), + SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), SPH_C32(0xe375f8a8), + SPH_C32(0x81fdf908) }, + { SPH_C32(0xaf6d0000), SPH_C32(0x0f200000), SPH_C32(0x062c0000), + SPH_C32(0x857e00d3), SPH_C32(0x1e13808e), SPH_C32(0xd1fcc2d7), + SPH_C32(0x9ffe6ba3), SPH_C32(0xd8036af6), SPH_C32(0x16a90000), + SPH_C32(0x6a200000), SPH_C32(0x37ab0000), SPH_C32(0x187e0221), + SPH_C32(0xd8a1ff45), SPH_C32(0xf3fc7ac4), SPH_C32(0xe07f66c8), + SPH_C32(0x3ff79e96) }, + { SPH_C32(0xf0810000), SPH_C32(0x266b0000), SPH_C32(0x9ffe0000), + SPH_C32(0xcbae00c1), SPH_C32(0x00c0cffd), SPH_C32(0x6b5bca1e), + SPH_C32(0xc8ea607c), SPH_C32(0xe8add601), SPH_C32(0x49010000), + SPH_C32(0x3c230000), SPH_C32(0x74050000), SPH_C32(0x7c8d0232), + SPH_C32(0xfddf79fa), SPH_C32(0xe0edee8a), SPH_C32(0xb461f377), + SPH_C32(0xb15345ff) }, + { SPH_C32(0xaf290000), SPH_C32(0x70680000), SPH_C32(0xdc500000), + SPH_C32(0xaf5d00d2), SPH_C32(0x25be4942), SPH_C32(0x784a5e50), + SPH_C32(0x9cf4f5c3), SPH_C32(0x66090d68), SPH_C32(0x49450000), + SPH_C32(0x436b0000), SPH_C32(0xae790000), SPH_C32(0x56ae0233), + SPH_C32(0xc672b036), SPH_C32(0x495b720d), SPH_C32(0xb76b6d17), + SPH_C32(0x0f592261) }, + { SPH_C32(0x1e560000), SPH_C32(0x8f240000), SPH_C32(0xd7430000), + SPH_C32(0xca150120), SPH_C32(0xaf3c2e4d), SPH_C32(0xf981adce), + SPH_C32(0x8ed1dd68), SPH_C32(0x76b8dbfb), SPH_C32(0x6dc50000), + SPH_C32(0x422a0000), SPH_C32(0x44320000), SPH_C32(0x511e0280), + SPH_C32(0x7dd772a6), SPH_C32(0x37d373f8), SPH_C32(0xc48dc3ab), + SPH_C32(0x460299f8) }, + { SPH_C32(0x41fe0000), SPH_C32(0xd9270000), SPH_C32(0x94ed0000), + SPH_C32(0xaee60133), SPH_C32(0x8a42a8f2), SPH_C32(0xea903980), + SPH_C32(0xdacf48d7), SPH_C32(0xf81c0092), SPH_C32(0x6d810000), + SPH_C32(0x3d620000), SPH_C32(0x9e4e0000), SPH_C32(0x7b3d0281), + SPH_C32(0x467abb6a), SPH_C32(0x9e65ef7f), SPH_C32(0xc7875dcb), + SPH_C32(0xf808fe66) }, + { SPH_C32(0x1e120000), SPH_C32(0xf06c0000), SPH_C32(0x0d3f0000), + SPH_C32(0xe0360121), SPH_C32(0x9491e781), SPH_C32(0x50373149), + SPH_C32(0x8ddb4308), SPH_C32(0xc8b2bc65), SPH_C32(0x32290000), + SPH_C32(0x6b610000), SPH_C32(0xdde00000), SPH_C32(0x1fce0292), + SPH_C32(0x63043dd5), SPH_C32(0x8d747b31), SPH_C32(0x9399c874), + SPH_C32(0x76ac250f) }, + { SPH_C32(0x41ba0000), SPH_C32(0xa66f0000), SPH_C32(0x4e910000), + SPH_C32(0x84c50132), SPH_C32(0xb1ef613e), SPH_C32(0x4326a507), + SPH_C32(0xd9c5d6b7), SPH_C32(0x4616670c), SPH_C32(0x326d0000), + SPH_C32(0x14290000), SPH_C32(0x079c0000), SPH_C32(0x35ed0293), + SPH_C32(0x58a9f419), SPH_C32(0x24c2e7b6), SPH_C32(0x90935614), + SPH_C32(0xc8a64291) }, + { SPH_C32(0x8bed0000), SPH_C32(0x0e610000), SPH_C32(0xec670000), + SPH_C32(0x82ce0060), SPH_C32(0xa5b6421e), SPH_C32(0xaf74c322), + SPH_C32(0xec18c51f), SPH_C32(0x9158d16f), SPH_C32(0x83560000), + SPH_C32(0x942d0000), SPH_C32(0xd6f30000), SPH_C32(0x7a860360), + SPH_C32(0xe9865ada), SPH_C32(0x0cbf88af), SPH_C32(0x81bce0df), + SPH_C32(0x661df39c) }, + { SPH_C32(0xd4450000), SPH_C32(0x58620000), SPH_C32(0xafc90000), + SPH_C32(0xe63d0073), SPH_C32(0x80c8c4a1), SPH_C32(0xbc65576c), + SPH_C32(0xb80650a0), SPH_C32(0x1ffc0a06), SPH_C32(0x83120000), + SPH_C32(0xeb650000), SPH_C32(0x0c8f0000), SPH_C32(0x50a50361), + SPH_C32(0xd22b9316), SPH_C32(0xa5091428), SPH_C32(0x82b67ebf), + SPH_C32(0xd8179402) }, + { SPH_C32(0x8ba90000), SPH_C32(0x71290000), SPH_C32(0x361b0000), + SPH_C32(0xa8ed0061), SPH_C32(0x9e1b8bd2), SPH_C32(0x06c25fa5), + SPH_C32(0xef125b7f), SPH_C32(0x2f52b6f1), SPH_C32(0xdcba0000), + SPH_C32(0xbd660000), SPH_C32(0x4f210000), SPH_C32(0x34560372), + SPH_C32(0xf75515a9), SPH_C32(0xb6188066), SPH_C32(0xd6a8eb00), + SPH_C32(0x56b34f6b) }, + { SPH_C32(0xd4010000), SPH_C32(0x272a0000), SPH_C32(0x75b50000), + SPH_C32(0xcc1e0072), SPH_C32(0xbb650d6d), SPH_C32(0x15d3cbeb), + SPH_C32(0xbb0ccec0), SPH_C32(0xa1f66d98), SPH_C32(0xdcfe0000), + SPH_C32(0xc22e0000), SPH_C32(0x955d0000), SPH_C32(0x1e750373), + SPH_C32(0xccf8dc65), SPH_C32(0x1fae1ce1), SPH_C32(0xd5a27560), + SPH_C32(0xe8b928f5) }, + { SPH_C32(0x657e0000), SPH_C32(0xd8660000), SPH_C32(0x7ea60000), + SPH_C32(0xa9560180), SPH_C32(0x31e76a62), SPH_C32(0x94183875), + SPH_C32(0xa929e66b), SPH_C32(0xb147bb0b), SPH_C32(0xf87e0000), + SPH_C32(0xc36f0000), SPH_C32(0x7f160000), SPH_C32(0x19c503c0), + SPH_C32(0x775d1ef5), SPH_C32(0x61261d14), SPH_C32(0xa644dbdc), + SPH_C32(0xa1e2936c) }, + { SPH_C32(0x3ad60000), SPH_C32(0x8e650000), SPH_C32(0x3d080000), + SPH_C32(0xcda50193), SPH_C32(0x1499ecdd), SPH_C32(0x8709ac3b), + SPH_C32(0xfd3773d4), SPH_C32(0x3fe36062), SPH_C32(0xf83a0000), + SPH_C32(0xbc270000), SPH_C32(0xa56a0000), SPH_C32(0x33e603c1), + SPH_C32(0x4cf0d739), SPH_C32(0xc8908193), SPH_C32(0xa54e45bc), + SPH_C32(0x1fe8f4f2) }, + { SPH_C32(0x653a0000), SPH_C32(0xa72e0000), SPH_C32(0xa4da0000), + SPH_C32(0x83750181), SPH_C32(0x0a4aa3ae), SPH_C32(0x3daea4f2), + SPH_C32(0xaa23780b), SPH_C32(0x0f4ddc95), SPH_C32(0xa7920000), + SPH_C32(0xea240000), SPH_C32(0xe6c40000), SPH_C32(0x571503d2), + SPH_C32(0x698e5186), SPH_C32(0xdb8115dd), SPH_C32(0xf150d003), + SPH_C32(0x914c2f9b) }, + { SPH_C32(0x3a920000), SPH_C32(0xf12d0000), SPH_C32(0xe7740000), + SPH_C32(0xe7860192), SPH_C32(0x2f342511), SPH_C32(0x2ebf30bc), + SPH_C32(0xfe3dedb4), SPH_C32(0x81e907fc), SPH_C32(0xa7d60000), + SPH_C32(0x956c0000), SPH_C32(0x3cb80000), SPH_C32(0x7d3603d3), + SPH_C32(0x5223984a), SPH_C32(0x7237895a), SPH_C32(0xf25a4e63), + SPH_C32(0x2f464805) }, + { SPH_C32(0x16ed0000), SPH_C32(0x15680000), SPH_C32(0xedd70000), + SPH_C32(0x325d0220), SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), + SPH_C32(0xe375f8a8), SPH_C32(0x81fdf908), SPH_C32(0xe6280000), + SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), SPH_C32(0xd3d002e0), + SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), SPH_C32(0x289506b4), + SPH_C32(0xd75a4897) }, + { SPH_C32(0x49450000), SPH_C32(0x436b0000), SPH_C32(0xae790000), + SPH_C32(0x56ae0233), SPH_C32(0xc672b036), SPH_C32(0x495b720d), + SPH_C32(0xb76b6d17), SPH_C32(0x0f592261), SPH_C32(0xe66c0000), + SPH_C32(0x33030000), SPH_C32(0x72290000), SPH_C32(0xf9f302e1), + SPH_C32(0xe3ccf974), SPH_C32(0x31112c5d), SPH_C32(0x2b9f98d4), + SPH_C32(0x69502f09) }, + { SPH_C32(0x16a90000), SPH_C32(0x6a200000), SPH_C32(0x37ab0000), + SPH_C32(0x187e0221), SPH_C32(0xd8a1ff45), SPH_C32(0xf3fc7ac4), + SPH_C32(0xe07f66c8), SPH_C32(0x3ff79e96), SPH_C32(0xb9c40000), + SPH_C32(0x65000000), SPH_C32(0x31870000), SPH_C32(0x9d0002f2), + SPH_C32(0xc6b27fcb), SPH_C32(0x2200b813), SPH_C32(0x7f810d6b), + SPH_C32(0xe7f4f460) }, + { SPH_C32(0x49010000), SPH_C32(0x3c230000), SPH_C32(0x74050000), + SPH_C32(0x7c8d0232), SPH_C32(0xfddf79fa), SPH_C32(0xe0edee8a), + SPH_C32(0xb461f377), SPH_C32(0xb15345ff), SPH_C32(0xb9800000), + SPH_C32(0x1a480000), SPH_C32(0xebfb0000), SPH_C32(0xb72302f3), + SPH_C32(0xfd1fb607), SPH_C32(0x8bb62494), SPH_C32(0x7c8b930b), + SPH_C32(0x59fe93fe) }, + { SPH_C32(0xf87e0000), SPH_C32(0xc36f0000), SPH_C32(0x7f160000), + SPH_C32(0x19c503c0), SPH_C32(0x775d1ef5), SPH_C32(0x61261d14), + SPH_C32(0xa644dbdc), SPH_C32(0xa1e2936c), SPH_C32(0x9d000000), + SPH_C32(0x1b090000), SPH_C32(0x01b00000), SPH_C32(0xb0930240), + SPH_C32(0x46ba7497), SPH_C32(0xf53e2561), SPH_C32(0x0f6d3db7), + SPH_C32(0x10a52867) }, + { SPH_C32(0xa7d60000), SPH_C32(0x956c0000), SPH_C32(0x3cb80000), + SPH_C32(0x7d3603d3), SPH_C32(0x5223984a), SPH_C32(0x7237895a), + SPH_C32(0xf25a4e63), SPH_C32(0x2f464805), SPH_C32(0x9d440000), + SPH_C32(0x64410000), SPH_C32(0xdbcc0000), SPH_C32(0x9ab00241), + SPH_C32(0x7d17bd5b), SPH_C32(0x5c88b9e6), SPH_C32(0x0c67a3d7), + SPH_C32(0xaeaf4ff9) }, + { SPH_C32(0xf83a0000), SPH_C32(0xbc270000), SPH_C32(0xa56a0000), + SPH_C32(0x33e603c1), SPH_C32(0x4cf0d739), SPH_C32(0xc8908193), + SPH_C32(0xa54e45bc), SPH_C32(0x1fe8f4f2), SPH_C32(0xc2ec0000), + SPH_C32(0x32420000), SPH_C32(0x98620000), SPH_C32(0xfe430252), + SPH_C32(0x58693be4), SPH_C32(0x4f992da8), SPH_C32(0x58793668), + SPH_C32(0x200b9490) }, + { SPH_C32(0xa7920000), SPH_C32(0xea240000), SPH_C32(0xe6c40000), + SPH_C32(0x571503d2), SPH_C32(0x698e5186), SPH_C32(0xdb8115dd), + SPH_C32(0xf150d003), SPH_C32(0x914c2f9b), SPH_C32(0xc2a80000), + SPH_C32(0x4d0a0000), SPH_C32(0x421e0000), SPH_C32(0xd4600253), + SPH_C32(0x63c4f228), SPH_C32(0xe62fb12f), SPH_C32(0x5b73a808), + SPH_C32(0x9e01f30e) }, + { SPH_C32(0x6dc50000), SPH_C32(0x422a0000), SPH_C32(0x44320000), + SPH_C32(0x511e0280), SPH_C32(0x7dd772a6), SPH_C32(0x37d373f8), + SPH_C32(0xc48dc3ab), SPH_C32(0x460299f8), SPH_C32(0x73930000), + SPH_C32(0xcd0e0000), SPH_C32(0x93710000), SPH_C32(0x9b0b03a0), + SPH_C32(0xd2eb5ceb), SPH_C32(0xce52de36), SPH_C32(0x4a5c1ec3), + SPH_C32(0x30ba4203) }, + { SPH_C32(0x326d0000), SPH_C32(0x14290000), SPH_C32(0x079c0000), + SPH_C32(0x35ed0293), SPH_C32(0x58a9f419), SPH_C32(0x24c2e7b6), + SPH_C32(0x90935614), SPH_C32(0xc8a64291), SPH_C32(0x73d70000), + SPH_C32(0xb2460000), SPH_C32(0x490d0000), SPH_C32(0xb12803a1), + SPH_C32(0xe9469527), SPH_C32(0x67e442b1), SPH_C32(0x495680a3), + SPH_C32(0x8eb0259d) }, + { SPH_C32(0x6d810000), SPH_C32(0x3d620000), SPH_C32(0x9e4e0000), + SPH_C32(0x7b3d0281), SPH_C32(0x467abb6a), SPH_C32(0x9e65ef7f), + SPH_C32(0xc7875dcb), SPH_C32(0xf808fe66), SPH_C32(0x2c7f0000), + SPH_C32(0xe4450000), SPH_C32(0x0aa30000), SPH_C32(0xd5db03b2), + SPH_C32(0xcc381398), SPH_C32(0x74f5d6ff), SPH_C32(0x1d48151c), + SPH_C32(0x0014fef4) }, + { SPH_C32(0x32290000), SPH_C32(0x6b610000), SPH_C32(0xdde00000), + SPH_C32(0x1fce0292), SPH_C32(0x63043dd5), SPH_C32(0x8d747b31), + SPH_C32(0x9399c874), SPH_C32(0x76ac250f), SPH_C32(0x2c3b0000), + SPH_C32(0x9b0d0000), SPH_C32(0xd0df0000), SPH_C32(0xfff803b3), + SPH_C32(0xf795da54), SPH_C32(0xdd434a78), SPH_C32(0x1e428b7c), + SPH_C32(0xbe1e996a) }, + { SPH_C32(0x83560000), SPH_C32(0x942d0000), SPH_C32(0xd6f30000), + SPH_C32(0x7a860360), SPH_C32(0xe9865ada), SPH_C32(0x0cbf88af), + SPH_C32(0x81bce0df), SPH_C32(0x661df39c), SPH_C32(0x08bb0000), + SPH_C32(0x9a4c0000), SPH_C32(0x3a940000), SPH_C32(0xf8480300), + SPH_C32(0x4c3018c4), SPH_C32(0xa3cb4b8d), SPH_C32(0x6da425c0), + SPH_C32(0xf74522f3) }, + { SPH_C32(0xdcfe0000), SPH_C32(0xc22e0000), SPH_C32(0x955d0000), + SPH_C32(0x1e750373), SPH_C32(0xccf8dc65), SPH_C32(0x1fae1ce1), + SPH_C32(0xd5a27560), SPH_C32(0xe8b928f5), SPH_C32(0x08ff0000), + SPH_C32(0xe5040000), SPH_C32(0xe0e80000), SPH_C32(0xd26b0301), + SPH_C32(0x779dd108), SPH_C32(0x0a7dd70a), SPH_C32(0x6eaebba0), + SPH_C32(0x494f456d) }, + { SPH_C32(0x83120000), SPH_C32(0xeb650000), SPH_C32(0x0c8f0000), + SPH_C32(0x50a50361), SPH_C32(0xd22b9316), SPH_C32(0xa5091428), + SPH_C32(0x82b67ebf), SPH_C32(0xd8179402), SPH_C32(0x57570000), + SPH_C32(0xb3070000), SPH_C32(0xa3460000), SPH_C32(0xb6980312), + SPH_C32(0x52e357b7), SPH_C32(0x196c4344), SPH_C32(0x3ab02e1f), + SPH_C32(0xc7eb9e04) }, + { SPH_C32(0xdcba0000), SPH_C32(0xbd660000), SPH_C32(0x4f210000), + SPH_C32(0x34560372), SPH_C32(0xf75515a9), SPH_C32(0xb6188066), + SPH_C32(0xd6a8eb00), SPH_C32(0x56b34f6b), SPH_C32(0x57130000), + SPH_C32(0xcc4f0000), SPH_C32(0x793a0000), SPH_C32(0x9cbb0313), + SPH_C32(0x694e9e7b), SPH_C32(0xb0dadfc3), SPH_C32(0x39bab07f), + SPH_C32(0x79e1f99a) } +}; + +static const sph_u32 T512_60[16][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x033d0000), SPH_C32(0x08b30000), SPH_C32(0xf33a0000), + SPH_C32(0x3ac20007), SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), + SPH_C32(0x0ea5cfe3), SPH_C32(0xe6da7ffe), SPH_C32(0xa8da0000), + SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), SPH_C32(0x07da0002), + SPH_C32(0x7d669583), SPH_C32(0x1f98708a), SPH_C32(0xbb668808), + SPH_C32(0xda878000) }, + { SPH_C32(0xa8da0000), SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), + SPH_C32(0x07da0002), SPH_C32(0x7d669583), SPH_C32(0x1f98708a), + SPH_C32(0xbb668808), SPH_C32(0xda878000), SPH_C32(0xabe70000), + SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), SPH_C32(0x3d180005), + SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), SPH_C32(0xb5c347eb), + SPH_C32(0x3c5dfffe) }, + { SPH_C32(0xabe70000), SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), + SPH_C32(0x3d180005), SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), + SPH_C32(0xb5c347eb), SPH_C32(0x3c5dfffe), SPH_C32(0x033d0000), + SPH_C32(0x08b30000), SPH_C32(0xf33a0000), SPH_C32(0x3ac20007), + SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), SPH_C32(0x0ea5cfe3), + SPH_C32(0xe6da7ffe) }, + { SPH_C32(0x01930000), SPH_C32(0xe7820000), SPH_C32(0xedfb0000), + SPH_C32(0xcf0c000b), SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), + SPH_C32(0x063661e1), SPH_C32(0x536f9e7b), SPH_C32(0x92280000), + SPH_C32(0xdc850000), SPH_C32(0x57fa0000), SPH_C32(0x56dc0003), + SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), SPH_C32(0x90cef752), + SPH_C32(0x7b1675d7) }, + { SPH_C32(0x02ae0000), SPH_C32(0xef310000), SPH_C32(0x1ec10000), + SPH_C32(0xf5ce000c), SPH_C32(0xdcf90708), SPH_C32(0xd7cdd231), + SPH_C32(0x0893ae02), SPH_C32(0xb5b5e185), SPH_C32(0x3af20000), + SPH_C32(0x4a3b0000), SPH_C32(0x0be70000), SPH_C32(0x51060001), + SPH_C32(0xc78fb695), SPH_C32(0x4577d386), SPH_C32(0x2ba87f5a), + SPH_C32(0xa191f5d7) }, + { SPH_C32(0xa9490000), SPH_C32(0x713c0000), SPH_C32(0xb1e60000), + SPH_C32(0xc8d60009), SPH_C32(0xf0b618db), SPH_C32(0xa33bc4a4), + SPH_C32(0xbd50e9e9), SPH_C32(0x89e81e7b), SPH_C32(0x39cf0000), + SPH_C32(0x42880000), SPH_C32(0xf8dd0000), SPH_C32(0x6bc40006), + SPH_C32(0x96a63cc5), SPH_C32(0x2e19b599), SPH_C32(0x250db0b9), + SPH_C32(0x474b8a29) }, + { SPH_C32(0xaa740000), SPH_C32(0x798f0000), SPH_C32(0x42dc0000), + SPH_C32(0xf214000e), SPH_C32(0xa19f928b), SPH_C32(0xc855a2bb), + SPH_C32(0xb3f5260a), SPH_C32(0x6f326185), SPH_C32(0x91150000), + SPH_C32(0xd4360000), SPH_C32(0xa4c00000), SPH_C32(0x6c1e0004), + SPH_C32(0xebc0a946), SPH_C32(0x3181c513), SPH_C32(0x9e6b38b1), + SPH_C32(0x9dcc0a29) }, + { SPH_C32(0x92280000), SPH_C32(0xdc850000), SPH_C32(0x57fa0000), + SPH_C32(0x56dc0003), SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), + SPH_C32(0x90cef752), SPH_C32(0x7b1675d7), SPH_C32(0x93bb0000), + SPH_C32(0x3b070000), SPH_C32(0xba010000), SPH_C32(0x99d00008), + SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), SPH_C32(0x96f896b3), + SPH_C32(0x2879ebac) }, + { SPH_C32(0x91150000), SPH_C32(0xd4360000), SPH_C32(0xa4c00000), + SPH_C32(0x6c1e0004), SPH_C32(0xebc0a946), SPH_C32(0x3181c513), + SPH_C32(0x9e6b38b1), SPH_C32(0x9dcc0a29), SPH_C32(0x3b610000), + SPH_C32(0xadb90000), SPH_C32(0xe61c0000), SPH_C32(0x9e0a000a), + SPH_C32(0x4a5f3bcd), SPH_C32(0xf9d467a8), SPH_C32(0x2d9e1ebb), + SPH_C32(0xf2fe6bac) }, + { SPH_C32(0x3af20000), SPH_C32(0x4a3b0000), SPH_C32(0x0be70000), + SPH_C32(0x51060001), SPH_C32(0xc78fb695), SPH_C32(0x4577d386), + SPH_C32(0x2ba87f5a), SPH_C32(0xa191f5d7), SPH_C32(0x385c0000), + SPH_C32(0xa50a0000), SPH_C32(0x15260000), SPH_C32(0xa4c8000d), + SPH_C32(0x1b76b19d), SPH_C32(0x92ba01b7), SPH_C32(0x233bd158), + SPH_C32(0x14241452) }, + { SPH_C32(0x39cf0000), SPH_C32(0x42880000), SPH_C32(0xf8dd0000), + SPH_C32(0x6bc40006), SPH_C32(0x96a63cc5), SPH_C32(0x2e19b599), + SPH_C32(0x250db0b9), SPH_C32(0x474b8a29), SPH_C32(0x90860000), + SPH_C32(0x33b40000), SPH_C32(0x493b0000), SPH_C32(0xa312000f), + SPH_C32(0x6610241e), SPH_C32(0x8d22713d), SPH_C32(0x985d5950), + SPH_C32(0xcea39452) }, + { SPH_C32(0x93bb0000), SPH_C32(0x3b070000), SPH_C32(0xba010000), + SPH_C32(0x99d00008), SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), + SPH_C32(0x96f896b3), SPH_C32(0x2879ebac), SPH_C32(0x01930000), + SPH_C32(0xe7820000), SPH_C32(0xedfb0000), SPH_C32(0xcf0c000b), + SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), SPH_C32(0x063661e1), + SPH_C32(0x536f9e7b) }, + { SPH_C32(0x90860000), SPH_C32(0x33b40000), SPH_C32(0x493b0000), + SPH_C32(0xa312000f), SPH_C32(0x6610241e), SPH_C32(0x8d22713d), + SPH_C32(0x985d5950), SPH_C32(0xcea39452), SPH_C32(0xa9490000), + SPH_C32(0x713c0000), SPH_C32(0xb1e60000), SPH_C32(0xc8d60009), + SPH_C32(0xf0b618db), SPH_C32(0xa33bc4a4), SPH_C32(0xbd50e9e9), + SPH_C32(0x89e81e7b) }, + { SPH_C32(0x3b610000), SPH_C32(0xadb90000), SPH_C32(0xe61c0000), + SPH_C32(0x9e0a000a), SPH_C32(0x4a5f3bcd), SPH_C32(0xf9d467a8), + SPH_C32(0x2d9e1ebb), SPH_C32(0xf2fe6bac), SPH_C32(0xaa740000), + SPH_C32(0x798f0000), SPH_C32(0x42dc0000), SPH_C32(0xf214000e), + SPH_C32(0xa19f928b), SPH_C32(0xc855a2bb), SPH_C32(0xb3f5260a), + SPH_C32(0x6f326185) }, + { SPH_C32(0x385c0000), SPH_C32(0xa50a0000), SPH_C32(0x15260000), + SPH_C32(0xa4c8000d), SPH_C32(0x1b76b19d), SPH_C32(0x92ba01b7), + SPH_C32(0x233bd158), SPH_C32(0x14241452), SPH_C32(0x02ae0000), + SPH_C32(0xef310000), SPH_C32(0x1ec10000), SPH_C32(0xf5ce000c), + SPH_C32(0xdcf90708), SPH_C32(0xd7cdd231), SPH_C32(0x0893ae02), + SPH_C32(0xb5b5e185) } +}; + +#define INPUT_BIG do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T512_0[acc >> 2][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + m8 = rp[8]; \ + m9 = rp[9]; \ + mA = rp[10]; \ + mB = rp[11]; \ + mC = rp[12]; \ + mD = rp[13]; \ + mE = rp[14]; \ + mF = rp[15]; \ + acc = (acc << 8) | buf[1]; \ + rp = &T512_6[(acc >> 4) & 0x3f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[2]; \ + rp = &T512_12[(acc >> 6) & 0x3f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_18[acc & 0x3f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[3]; \ + rp = &T512_24[acc >> 2][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[4]; \ + rp = &T512_30[(acc >> 4) & 0x3f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[5]; \ + rp = &T512_36[(acc >> 6) & 0x3f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_42[acc & 0x3f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[6]; \ + rp = &T512_48[acc >> 2][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[7]; \ + rp = &T512_54[(acc >> 4) & 0x3f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_60[acc & 0x0f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_BIG == 7 + +static const sph_u32 T512_0[128][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xc96b0030), SPH_C32(0xe7250000), SPH_C32(0x2f840000), + SPH_C32(0x264f0000), SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), + SPH_C32(0x509f6984), SPH_C32(0x9e69af68), SPH_C32(0x26600240), + SPH_C32(0xddd80000), SPH_C32(0x722a0000), SPH_C32(0x4f060000), + SPH_C32(0x936667ff), SPH_C32(0x29f944ce), SPH_C32(0x368b63d5), + SPH_C32(0x0c26f262) }, + { SPH_C32(0x145a3c00), SPH_C32(0xb9e90000), SPH_C32(0x61270000), + SPH_C32(0xf1610000), SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), + SPH_C32(0x47a96720), SPH_C32(0xe18e24c5), SPH_C32(0x23671400), + SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), SPH_C32(0xfb750000), + SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), SPH_C32(0x02c40a3f), + SPH_C32(0xdc24e61f) }, + { SPH_C32(0xdd313c30), SPH_C32(0x5ecc0000), SPH_C32(0x4ea30000), + SPH_C32(0xd72e0000), SPH_C32(0xc6086695), SPH_C32(0xddb5cc4f), + SPH_C32(0x17360ea4), SPH_C32(0x7fe78bad), SPH_C32(0x05071640), + SPH_C32(0x15610000), SPH_C32(0x86ed0000), SPH_C32(0xb4730000), + SPH_C32(0xe0ab439a), SPH_C32(0xd15fe187), SPH_C32(0x344f69ea), + SPH_C32(0xd002147d) }, + { SPH_C32(0x23671400), SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), + SPH_C32(0xfb750000), SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), + SPH_C32(0x02c40a3f), SPH_C32(0xdc24e61f), SPH_C32(0x373d2800), + SPH_C32(0x71500000), SPH_C32(0x95e00000), SPH_C32(0x0a140000), + SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), SPH_C32(0x456d6d1f), + SPH_C32(0x3daac2da) }, + { SPH_C32(0xea0c1430), SPH_C32(0x2f9c0000), SPH_C32(0xdb430000), + SPH_C32(0xdd3a0000), SPH_C32(0x7ba47f9c), SPH_C32(0x955a547e), + SPH_C32(0x525b63bb), SPH_C32(0x424d4977), SPH_C32(0x115d2a40), + SPH_C32(0xac880000), SPH_C32(0xe7ca0000), SPH_C32(0x45120000), + SPH_C32(0x2eca7ef6), SPH_C32(0x6116dcff), SPH_C32(0x73e60eca), + SPH_C32(0x318c30b8) }, + { SPH_C32(0x373d2800), SPH_C32(0x71500000), SPH_C32(0x95e00000), + SPH_C32(0x0a140000), SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), + SPH_C32(0x456d6d1f), SPH_C32(0x3daac2da), SPH_C32(0x145a3c00), + SPH_C32(0xb9e90000), SPH_C32(0x61270000), SPH_C32(0xf1610000), + SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), SPH_C32(0x47a96720), + SPH_C32(0xe18e24c5) }, + { SPH_C32(0xfe562830), SPH_C32(0x96750000), SPH_C32(0xba640000), + SPH_C32(0x2c5b0000), SPH_C32(0xb5c542f0), SPH_C32(0x25136906), + SPH_C32(0x15f2049b), SPH_C32(0xa3c36db2), SPH_C32(0x323a3e40), + SPH_C32(0x64310000), SPH_C32(0x130d0000), SPH_C32(0xbe670000), + SPH_C32(0x5d075a93), SPH_C32(0x99b079b6), SPH_C32(0x712204f5), + SPH_C32(0xeda8d6a7) }, + { SPH_C32(0x54285c00), SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), + SPH_C32(0xa1c50000), SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), + SPH_C32(0x6bb0419d), SPH_C32(0x551b3782), SPH_C32(0x9cbb1800), + SPH_C32(0xb0d30000), SPH_C32(0x92510000), SPH_C32(0xed930000), + SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), SPH_C32(0x430633da), + SPH_C32(0x78cace29) }, + { SPH_C32(0x9d435c30), SPH_C32(0x0dc80000), SPH_C32(0xea520000), + SPH_C32(0x878a0000), SPH_C32(0xbbcb3c89), SPH_C32(0xf95935d6), + SPH_C32(0x3b2f2819), SPH_C32(0xcb7298ea), SPH_C32(0xbadb1a40), + SPH_C32(0x6d0b0000), SPH_C32(0xe07b0000), SPH_C32(0xa2950000), + SPH_C32(0xca5c24ba), SPH_C32(0xc8ed913a), SPH_C32(0x758d500f), + SPH_C32(0x74ec3c4b) }, + { SPH_C32(0x40726000), SPH_C32(0x53040000), SPH_C32(0xa4f10000), + SPH_C32(0x50a40000), SPH_C32(0x7dc35a1c), SPH_C32(0x24ecf999), + SPH_C32(0x2c1926bd), SPH_C32(0xb4951347), SPH_C32(0xbfdc0c00), + SPH_C32(0x786a0000), SPH_C32(0x66960000), SPH_C32(0x16e60000), + SPH_C32(0x2af76720), SPH_C32(0x19b270bd), SPH_C32(0x41c239e5), + SPH_C32(0xa4ee2836) }, + { SPH_C32(0x89196030), SPH_C32(0xb4210000), SPH_C32(0x8b750000), + SPH_C32(0x76eb0000), SPH_C32(0x75aa01e5), SPH_C32(0x491008ae), + SPH_C32(0x7c864f39), SPH_C32(0x2afcbc2f), SPH_C32(0x99bc0e40), + SPH_C32(0xa5b20000), SPH_C32(0x14bc0000), SPH_C32(0x59e00000), + SPH_C32(0xb99100df), SPH_C32(0x304b3473), SPH_C32(0x77495a30), + SPH_C32(0xa8c8da54) }, + { SPH_C32(0x774f4800), SPH_C32(0x22540000), SPH_C32(0x31110000), + SPH_C32(0x5ab00000), SPH_C32(0xc06f4315), SPH_C32(0x6c0361a8), + SPH_C32(0x69744ba2), SPH_C32(0x893fd19d), SPH_C32(0xab863000), + SPH_C32(0xc1830000), SPH_C32(0x07b10000), SPH_C32(0xe7870000), + SPH_C32(0xe4965a4c), SPH_C32(0xa9fb4dc5), SPH_C32(0x066b5ec5), + SPH_C32(0x45600cf3) }, + { SPH_C32(0xbe244830), SPH_C32(0xc5710000), SPH_C32(0x1e950000), + SPH_C32(0x7cff0000), SPH_C32(0xc80618ec), SPH_C32(0x01ff909f), + SPH_C32(0x39eb2226), SPH_C32(0x17567ef5), SPH_C32(0x8de63240), + SPH_C32(0x1c5b0000), SPH_C32(0x759b0000), SPH_C32(0xa8810000), + SPH_C32(0x77f03db3), SPH_C32(0x8002090b), SPH_C32(0x30e03d10), + SPH_C32(0x4946fe91) }, + { SPH_C32(0x63157400), SPH_C32(0x9bbd0000), SPH_C32(0x50360000), + SPH_C32(0xabd10000), SPH_C32(0x0e0e7e79), SPH_C32(0xdc4a5cd0), + SPH_C32(0x2edd2c82), SPH_C32(0x68b1f558), SPH_C32(0x88e12400), + SPH_C32(0x093a0000), SPH_C32(0xf3760000), SPH_C32(0x1cf20000), + SPH_C32(0x975b7e29), SPH_C32(0x515de88c), SPH_C32(0x04af54fa), + SPH_C32(0x9944eaec) }, + { SPH_C32(0xaa7e7430), SPH_C32(0x7c980000), SPH_C32(0x7fb20000), + SPH_C32(0x8d9e0000), SPH_C32(0x06672580), SPH_C32(0xb1b6ade7), + SPH_C32(0x7e424506), SPH_C32(0xf6d85a30), SPH_C32(0xae812640), + SPH_C32(0xd4e20000), SPH_C32(0x815c0000), SPH_C32(0x53f40000), + SPH_C32(0x043d19d6), SPH_C32(0x78a4ac42), SPH_C32(0x3224372f), + SPH_C32(0x9562188e) }, + { SPH_C32(0x9cbb1800), SPH_C32(0xb0d30000), SPH_C32(0x92510000), + SPH_C32(0xed930000), SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), + SPH_C32(0x430633da), SPH_C32(0x78cace29), SPH_C32(0xc8934400), + SPH_C32(0x5a3e0000), SPH_C32(0x57870000), SPH_C32(0x4c560000), + SPH_C32(0xea982435), SPH_C32(0x75b11115), SPH_C32(0x28b67247), + SPH_C32(0x2dd1f9ab) }, + { SPH_C32(0x55d01830), SPH_C32(0x57f60000), SPH_C32(0xbdd50000), + SPH_C32(0xcbdc0000), SPH_C32(0x515318bc), SPH_C32(0x8ce824c3), + SPH_C32(0x13995a5e), SPH_C32(0xe6a36141), SPH_C32(0xeef34640), + SPH_C32(0x87e60000), SPH_C32(0x25ad0000), SPH_C32(0x03500000), + SPH_C32(0x79fe43ca), SPH_C32(0x5c4855db), SPH_C32(0x1e3d1192), + SPH_C32(0x21f70bc9) }, + { SPH_C32(0x88e12400), SPH_C32(0x093a0000), SPH_C32(0xf3760000), + SPH_C32(0x1cf20000), SPH_C32(0x975b7e29), SPH_C32(0x515de88c), + SPH_C32(0x04af54fa), SPH_C32(0x9944eaec), SPH_C32(0xebf45000), + SPH_C32(0x92870000), SPH_C32(0xa3400000), SPH_C32(0xb7230000), + SPH_C32(0x99550050), SPH_C32(0x8d17b45c), SPH_C32(0x2a727878), + SPH_C32(0xf1f51fb4) }, + { SPH_C32(0x418a2430), SPH_C32(0xee1f0000), SPH_C32(0xdcf20000), + SPH_C32(0x3abd0000), SPH_C32(0x9f3225d0), SPH_C32(0x3ca119bb), + SPH_C32(0x54303d7e), SPH_C32(0x072d4584), SPH_C32(0xcd945240), + SPH_C32(0x4f5f0000), SPH_C32(0xd16a0000), SPH_C32(0xf8250000), + SPH_C32(0x0a3367af), SPH_C32(0xa4eef092), SPH_C32(0x1cf91bad), + SPH_C32(0xfdd3edd6) }, + { SPH_C32(0xbfdc0c00), SPH_C32(0x786a0000), SPH_C32(0x66960000), + SPH_C32(0x16e60000), SPH_C32(0x2af76720), SPH_C32(0x19b270bd), + SPH_C32(0x41c239e5), SPH_C32(0xa4ee2836), SPH_C32(0xffae6c00), + SPH_C32(0x2b6e0000), SPH_C32(0xc2670000), SPH_C32(0x46420000), + SPH_C32(0x57343d3c), SPH_C32(0x3d5e8924), SPH_C32(0x6ddb1f58), + SPH_C32(0x107b3b71) }, + { SPH_C32(0x76b70c30), SPH_C32(0x9f4f0000), SPH_C32(0x49120000), + SPH_C32(0x30a90000), SPH_C32(0x229e3cd9), SPH_C32(0x744e818a), + SPH_C32(0x115d5061), SPH_C32(0x3a87875e), SPH_C32(0xd9ce6e40), + SPH_C32(0xf6b60000), SPH_C32(0xb04d0000), SPH_C32(0x09440000), + SPH_C32(0xc4525ac3), SPH_C32(0x14a7cdea), SPH_C32(0x5b507c8d), + SPH_C32(0x1c5dc913) }, + { SPH_C32(0xab863000), SPH_C32(0xc1830000), SPH_C32(0x07b10000), + SPH_C32(0xe7870000), SPH_C32(0xe4965a4c), SPH_C32(0xa9fb4dc5), + SPH_C32(0x066b5ec5), SPH_C32(0x45600cf3), SPH_C32(0xdcc97800), + SPH_C32(0xe3d70000), SPH_C32(0x36a00000), SPH_C32(0xbd370000), + SPH_C32(0x24f91959), SPH_C32(0xc5f82c6d), SPH_C32(0x6f1f1567), + SPH_C32(0xcc5fdd6e) }, + { SPH_C32(0x62ed3030), SPH_C32(0x26a60000), SPH_C32(0x28350000), + SPH_C32(0xc1c80000), SPH_C32(0xecff01b5), SPH_C32(0xc407bcf2), + SPH_C32(0x56f43741), SPH_C32(0xdb09a39b), SPH_C32(0xfaa97a40), + SPH_C32(0x3e0f0000), SPH_C32(0x448a0000), SPH_C32(0xf2310000), + SPH_C32(0xb79f7ea6), SPH_C32(0xec0168a3), SPH_C32(0x599476b2), + SPH_C32(0xc0792f0c) }, + { SPH_C32(0xc8934400), SPH_C32(0x5a3e0000), SPH_C32(0x57870000), + SPH_C32(0x4c560000), SPH_C32(0xea982435), SPH_C32(0x75b11115), + SPH_C32(0x28b67247), SPH_C32(0x2dd1f9ab), SPH_C32(0x54285c00), + SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), SPH_C32(0xa1c50000), + SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), SPH_C32(0x6bb0419d), + SPH_C32(0x551b3782) }, + { SPH_C32(0x01f84430), SPH_C32(0xbd1b0000), SPH_C32(0x78030000), + SPH_C32(0x6a190000), SPH_C32(0xe2f17fcc), SPH_C32(0x184de022), + SPH_C32(0x78291bc3), SPH_C32(0xb3b856c3), SPH_C32(0x72485e40), + SPH_C32(0x37350000), SPH_C32(0xb7fc0000), SPH_C32(0xeec30000), + SPH_C32(0x20c4008f), SPH_C32(0xbd5c802f), SPH_C32(0x5d3b2248), + SPH_C32(0x593dc5e0) }, + { SPH_C32(0xdcc97800), SPH_C32(0xe3d70000), SPH_C32(0x36a00000), + SPH_C32(0xbd370000), SPH_C32(0x24f91959), SPH_C32(0xc5f82c6d), + SPH_C32(0x6f1f1567), SPH_C32(0xcc5fdd6e), SPH_C32(0x774f4800), + SPH_C32(0x22540000), SPH_C32(0x31110000), SPH_C32(0x5ab00000), + SPH_C32(0xc06f4315), SPH_C32(0x6c0361a8), SPH_C32(0x69744ba2), + SPH_C32(0x893fd19d) }, + { SPH_C32(0x15a27830), SPH_C32(0x04f20000), SPH_C32(0x19240000), + SPH_C32(0x9b780000), SPH_C32(0x2c9042a0), SPH_C32(0xa804dd5a), + SPH_C32(0x3f807ce3), SPH_C32(0x52367206), SPH_C32(0x512f4a40), + SPH_C32(0xff8c0000), SPH_C32(0x433b0000), SPH_C32(0x15b60000), + SPH_C32(0x530924ea), SPH_C32(0x45fa2566), SPH_C32(0x5fff2877), + SPH_C32(0x851923ff) }, + { SPH_C32(0xebf45000), SPH_C32(0x92870000), SPH_C32(0xa3400000), + SPH_C32(0xb7230000), SPH_C32(0x99550050), SPH_C32(0x8d17b45c), + SPH_C32(0x2a727878), SPH_C32(0xf1f51fb4), SPH_C32(0x63157400), + SPH_C32(0x9bbd0000), SPH_C32(0x50360000), SPH_C32(0xabd10000), + SPH_C32(0x0e0e7e79), SPH_C32(0xdc4a5cd0), SPH_C32(0x2edd2c82), + SPH_C32(0x68b1f558) }, + { SPH_C32(0x229f5030), SPH_C32(0x75a20000), SPH_C32(0x8cc40000), + SPH_C32(0x916c0000), SPH_C32(0x913c5ba9), SPH_C32(0xe0eb456b), + SPH_C32(0x7aed11fc), SPH_C32(0x6f9cb0dc), SPH_C32(0x45757640), + SPH_C32(0x46650000), SPH_C32(0x221c0000), SPH_C32(0xe4d70000), + SPH_C32(0x9d681986), SPH_C32(0xf5b3181e), SPH_C32(0x18564f57), + SPH_C32(0x6497073a) }, + { SPH_C32(0xffae6c00), SPH_C32(0x2b6e0000), SPH_C32(0xc2670000), + SPH_C32(0x46420000), SPH_C32(0x57343d3c), SPH_C32(0x3d5e8924), + SPH_C32(0x6ddb1f58), SPH_C32(0x107b3b71), SPH_C32(0x40726000), + SPH_C32(0x53040000), SPH_C32(0xa4f10000), SPH_C32(0x50a40000), + SPH_C32(0x7dc35a1c), SPH_C32(0x24ecf999), SPH_C32(0x2c1926bd), + SPH_C32(0xb4951347) }, + { SPH_C32(0x36c56c30), SPH_C32(0xcc4b0000), SPH_C32(0xede30000), + SPH_C32(0x600d0000), SPH_C32(0x5f5d66c5), SPH_C32(0x50a27813), + SPH_C32(0x3d4476dc), SPH_C32(0x8e129419), SPH_C32(0x66126240), + SPH_C32(0x8edc0000), SPH_C32(0xd6db0000), SPH_C32(0x1fa20000), + SPH_C32(0xeea53de3), SPH_C32(0x0d15bd57), SPH_C32(0x1a924568), + SPH_C32(0xb8b3e125) }, + { SPH_C32(0x29449c00), SPH_C32(0x64e70000), SPH_C32(0xf24b0000), + SPH_C32(0xc2f30000), SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), + SPH_C32(0xf3e04259), SPH_C32(0x8d0d9ec4), SPH_C32(0x466d0c00), + SPH_C32(0x08620000), SPH_C32(0xdd5d0000), SPH_C32(0xbadd0000), + SPH_C32(0x6a927942), SPH_C32(0x441f2b93), SPH_C32(0x218ace6f), + SPH_C32(0xbf2c0be2) }, + { SPH_C32(0xe02f9c30), SPH_C32(0x83c20000), SPH_C32(0xddcf0000), + SPH_C32(0xe4bc0000), SPH_C32(0x06b71576), SPH_C32(0x3b3ec672), + SPH_C32(0xa37f2bdd), SPH_C32(0x136431ac), SPH_C32(0x600d0e40), + SPH_C32(0xd5ba0000), SPH_C32(0xaf770000), SPH_C32(0xf5db0000), + SPH_C32(0xf9f41ebd), SPH_C32(0x6de66f5d), SPH_C32(0x1701adba), + SPH_C32(0xb30af980) }, + { SPH_C32(0x3d1ea000), SPH_C32(0xdd0e0000), SPH_C32(0x936c0000), + SPH_C32(0x33920000), SPH_C32(0xc0bf73e3), SPH_C32(0xe68b0a3d), + SPH_C32(0xb4492579), SPH_C32(0x6c83ba01), SPH_C32(0x650a1800), + SPH_C32(0xc0db0000), SPH_C32(0x299a0000), SPH_C32(0x41a80000), + SPH_C32(0x195f5d27), SPH_C32(0xbcb98eda), SPH_C32(0x234ec450), + SPH_C32(0x6308edfd) }, + { SPH_C32(0xf475a030), SPH_C32(0x3a2b0000), SPH_C32(0xbce80000), + SPH_C32(0x15dd0000), SPH_C32(0xc8d6281a), SPH_C32(0x8b77fb0a), + SPH_C32(0xe4d64cfd), SPH_C32(0xf2ea1569), SPH_C32(0x436a1a40), + SPH_C32(0x1d030000), SPH_C32(0x5bb00000), SPH_C32(0x0eae0000), + SPH_C32(0x8a393ad8), SPH_C32(0x9540ca14), SPH_C32(0x15c5a785), + SPH_C32(0x6f2e1f9f) }, + { SPH_C32(0x0a238800), SPH_C32(0xac5e0000), SPH_C32(0x068c0000), + SPH_C32(0x39860000), SPH_C32(0x7d136aea), SPH_C32(0xae64920c), + SPH_C32(0xf1244866), SPH_C32(0x512978db), SPH_C32(0x71502400), + SPH_C32(0x79320000), SPH_C32(0x48bd0000), SPH_C32(0xb0c90000), + SPH_C32(0xd73e604b), SPH_C32(0x0cf0b3a2), SPH_C32(0x64e7a370), + SPH_C32(0x8286c938) }, + { SPH_C32(0xc3488830), SPH_C32(0x4b7b0000), SPH_C32(0x29080000), + SPH_C32(0x1fc90000), SPH_C32(0x757a3113), SPH_C32(0xc398633b), + SPH_C32(0xa1bb21e2), SPH_C32(0xcf40d7b3), SPH_C32(0x57302640), + SPH_C32(0xa4ea0000), SPH_C32(0x3a970000), SPH_C32(0xffcf0000), + SPH_C32(0x445807b4), SPH_C32(0x2509f76c), SPH_C32(0x526cc0a5), + SPH_C32(0x8ea03b5a) }, + { SPH_C32(0x1e79b400), SPH_C32(0x15b70000), SPH_C32(0x67ab0000), + SPH_C32(0xc8e70000), SPH_C32(0xb3725786), SPH_C32(0x1e2daf74), + SPH_C32(0xb68d2f46), SPH_C32(0xb0a75c1e), SPH_C32(0x52373000), + SPH_C32(0xb18b0000), SPH_C32(0xbc7a0000), SPH_C32(0x4bbc0000), + SPH_C32(0xa4f3442e), SPH_C32(0xf45616eb), SPH_C32(0x6623a94f), + SPH_C32(0x5ea22f27) }, + { SPH_C32(0xd712b430), SPH_C32(0xf2920000), SPH_C32(0x482f0000), + SPH_C32(0xeea80000), SPH_C32(0xbb1b0c7f), SPH_C32(0x73d15e43), + SPH_C32(0xe61246c2), SPH_C32(0x2ecef376), SPH_C32(0x74573240), + SPH_C32(0x6c530000), SPH_C32(0xce500000), SPH_C32(0x04ba0000), + SPH_C32(0x379523d1), SPH_C32(0xddaf5225), SPH_C32(0x50a8ca9a), + SPH_C32(0x5284dd45) }, + { SPH_C32(0x7d6cc000), SPH_C32(0x8e0a0000), SPH_C32(0x379d0000), + SPH_C32(0x63360000), SPH_C32(0xbd7c29ff), SPH_C32(0xc267f3a4), + SPH_C32(0x985003c4), SPH_C32(0xd816a946), SPH_C32(0xdad61400), + SPH_C32(0xb8b10000), SPH_C32(0x4f0c0000), SPH_C32(0x574e0000), + SPH_C32(0x33a83a07), SPH_C32(0xa50bfe67), SPH_C32(0x628cfdb5), + SPH_C32(0xc7e6c5cb) }, + { SPH_C32(0xb407c030), SPH_C32(0x692f0000), SPH_C32(0x18190000), + SPH_C32(0x45790000), SPH_C32(0xb5157206), SPH_C32(0xaf9b0293), + SPH_C32(0xc8cf6a40), SPH_C32(0x467f062e), SPH_C32(0xfcb61640), + SPH_C32(0x65690000), SPH_C32(0x3d260000), SPH_C32(0x18480000), + SPH_C32(0xa0ce5df8), SPH_C32(0x8cf2baa9), SPH_C32(0x54079e60), + SPH_C32(0xcbc037a9) }, + { SPH_C32(0x6936fc00), SPH_C32(0x37e30000), SPH_C32(0x56ba0000), + SPH_C32(0x92570000), SPH_C32(0x731d1493), SPH_C32(0x722ecedc), + SPH_C32(0xdff964e4), SPH_C32(0x39988d83), SPH_C32(0xf9b10000), + SPH_C32(0x70080000), SPH_C32(0xbbcb0000), SPH_C32(0xac3b0000), + SPH_C32(0x40651e62), SPH_C32(0x5dad5b2e), SPH_C32(0x6048f78a), + SPH_C32(0x1bc223d4) }, + { SPH_C32(0xa05dfc30), SPH_C32(0xd0c60000), SPH_C32(0x793e0000), + SPH_C32(0xb4180000), SPH_C32(0x7b744f6a), SPH_C32(0x1fd23feb), + SPH_C32(0x8f660d60), SPH_C32(0xa7f122eb), SPH_C32(0xdfd10240), + SPH_C32(0xadd00000), SPH_C32(0xc9e10000), SPH_C32(0xe33d0000), + SPH_C32(0xd303799d), SPH_C32(0x74541fe0), SPH_C32(0x56c3945f), + SPH_C32(0x17e4d1b6) }, + { SPH_C32(0x5e0bd400), SPH_C32(0x46b30000), SPH_C32(0xc35a0000), + SPH_C32(0x98430000), SPH_C32(0xceb10d9a), SPH_C32(0x3ac156ed), + SPH_C32(0x9a9409fb), SPH_C32(0x04324f59), SPH_C32(0xedeb3c00), + SPH_C32(0xc9e10000), SPH_C32(0xdaec0000), SPH_C32(0x5d5a0000), + SPH_C32(0x8e04230e), SPH_C32(0xede46656), SPH_C32(0x27e190aa), + SPH_C32(0xfa4c0711) }, + { SPH_C32(0x9760d430), SPH_C32(0xa1960000), SPH_C32(0xecde0000), + SPH_C32(0xbe0c0000), SPH_C32(0xc6d85663), SPH_C32(0x573da7da), + SPH_C32(0xca0b607f), SPH_C32(0x9a5be031), SPH_C32(0xcb8b3e40), + SPH_C32(0x14390000), SPH_C32(0xa8c60000), SPH_C32(0x125c0000), + SPH_C32(0x1d6244f1), SPH_C32(0xc41d2298), SPH_C32(0x116af37f), + SPH_C32(0xf66af573) }, + { SPH_C32(0x4a51e800), SPH_C32(0xff5a0000), SPH_C32(0xa27d0000), + SPH_C32(0x69220000), SPH_C32(0x00d030f6), SPH_C32(0x8a886b95), + SPH_C32(0xdd3d6edb), SPH_C32(0xe5bc6b9c), SPH_C32(0xce8c2800), + SPH_C32(0x01580000), SPH_C32(0x2e2b0000), SPH_C32(0xa62f0000), + SPH_C32(0xfdc9076b), SPH_C32(0x1542c31f), SPH_C32(0x25259a95), + SPH_C32(0x2668e10e) }, + { SPH_C32(0x833ae830), SPH_C32(0x187f0000), SPH_C32(0x8df90000), + SPH_C32(0x4f6d0000), SPH_C32(0x08b96b0f), SPH_C32(0xe7749aa2), + SPH_C32(0x8da2075f), SPH_C32(0x7bd5c4f4), SPH_C32(0xe8ec2a40), + SPH_C32(0xdc800000), SPH_C32(0x5c010000), SPH_C32(0xe9290000), + SPH_C32(0x6eaf6094), SPH_C32(0x3cbb87d1), SPH_C32(0x13aef940), + SPH_C32(0x2a4e136c) }, + { SPH_C32(0xb5ff8400), SPH_C32(0xd4340000), SPH_C32(0x601a0000), + SPH_C32(0x2f600000), SPH_C32(0x57e40dca), SPH_C32(0xb7d6e2b1), + SPH_C32(0xb0e67183), SPH_C32(0xf5c750ed), SPH_C32(0x8efe4800), + SPH_C32(0x525c0000), SPH_C32(0x8ada0000), SPH_C32(0xf68b0000), + SPH_C32(0x800a5d77), SPH_C32(0x31ae3a86), SPH_C32(0x093cbc28), + SPH_C32(0x92fdf249) }, + { SPH_C32(0x7c948430), SPH_C32(0x33110000), SPH_C32(0x4f9e0000), + SPH_C32(0x092f0000), SPH_C32(0x5f8d5633), SPH_C32(0xda2a1386), + SPH_C32(0xe0791807), SPH_C32(0x6baeff85), SPH_C32(0xa89e4a40), + SPH_C32(0x8f840000), SPH_C32(0xf8f00000), SPH_C32(0xb98d0000), + SPH_C32(0x136c3a88), SPH_C32(0x18577e48), SPH_C32(0x3fb7dffd), + SPH_C32(0x9edb002b) }, + { SPH_C32(0xa1a5b800), SPH_C32(0x6ddd0000), SPH_C32(0x013d0000), + SPH_C32(0xde010000), SPH_C32(0x998530a6), SPH_C32(0x079fdfc9), + SPH_C32(0xf74f16a3), SPH_C32(0x14497428), SPH_C32(0xad995c00), + SPH_C32(0x9ae50000), SPH_C32(0x7e1d0000), SPH_C32(0x0dfe0000), + SPH_C32(0xf3c77912), SPH_C32(0xc9089fcf), SPH_C32(0x0bf8b617), + SPH_C32(0x4ed91456) }, + { SPH_C32(0x68ceb830), SPH_C32(0x8af80000), SPH_C32(0x2eb90000), + SPH_C32(0xf84e0000), SPH_C32(0x91ec6b5f), SPH_C32(0x6a632efe), + SPH_C32(0xa7d07f27), SPH_C32(0x8a20db40), SPH_C32(0x8bf95e40), + SPH_C32(0x473d0000), SPH_C32(0x0c370000), SPH_C32(0x42f80000), + SPH_C32(0x60a11eed), SPH_C32(0xe0f1db01), SPH_C32(0x3d73d5c2), + SPH_C32(0x42ffe634) }, + { SPH_C32(0x496989000), SPH_C32(0x1c8d0000), SPH_C32(0x94dd0000), + SPH_C32(0xd4150000), SPH_C32(0x242929af), SPH_C32(0x4f7047f8), + SPH_C32(0xb2227bbc), SPH_C32(0x29e3b6f2), SPH_C32(0xb9c36000), + SPH_C32(0x230c0000), SPH_C32(0x1f3a0000), SPH_C32(0xfc9f0000), + SPH_C32(0x3da6447e), SPH_C32(0x7941a2b7), SPH_C32(0x4c51d137), + SPH_C32(0xaf573093) }, + { SPH_C32(0x5ff39030), SPH_C32(0xfba80000), SPH_C32(0xbb590000), + SPH_C32(0xf25a0000), SPH_C32(0x2c407256), SPH_C32(0x228cb6cf), + SPH_C32(0xe2bd1238), SPH_C32(0xb78a199a), SPH_C32(0x9fa36240), + SPH_C32(0xfed40000), SPH_C32(0x6d100000), SPH_C32(0xb3990000), + SPH_C32(0xaec02381), SPH_C32(0x50b8e679), SPH_C32(0x7adab2e2), + SPH_C32(0xa371c2f1) }, + { SPH_C32(0x82c2ac00), SPH_C32(0xa5640000), SPH_C32(0xf5fa0000), + SPH_C32(0x25740000), SPH_C32(0xea4814c3), SPH_C32(0xff397a80), + SPH_C32(0xf58b1c9c), SPH_C32(0xc86d9237), SPH_C32(0x9aa47400), + SPH_C32(0xebb50000), SPH_C32(0xebfd0000), SPH_C32(0x07ea0000), + SPH_C32(0x4e6b601b), SPH_C32(0x81e707fe), SPH_C32(0x4e95db08), + SPH_C32(0x7373d68c) }, + { SPH_C32(0x4ba9ac30), SPH_C32(0x42410000), SPH_C32(0xda7e0000), + SPH_C32(0x033b0000), SPH_C32(0xe2214f3a), SPH_C32(0x92c58bb7), + SPH_C32(0xa5147518), SPH_C32(0x56043d5f), SPH_C32(0xbcc47640), + SPH_C32(0x366d0000), SPH_C32(0x99d70000), SPH_C32(0x48ec0000), + SPH_C32(0xdd0d07e4), SPH_C32(0xa81e4330), SPH_C32(0x781eb8dd), + SPH_C32(0x7f5524ee) }, + { SPH_C32(0xe1d7d800), SPH_C32(0x3ed90000), SPH_C32(0xa5cc0000), + SPH_C32(0x8ea50000), SPH_C32(0xe4466aba), SPH_C32(0x23732650), + SPH_C32(0xdb56301e), SPH_C32(0xa0dc676f), SPH_C32(0x12455000), + SPH_C32(0xe28f0000), SPH_C32(0x188b0000), SPH_C32(0x1b180000), + SPH_C32(0xd9301e32), SPH_C32(0xd0baef72), SPH_C32(0x4a3a8ff2), + SPH_C32(0xea373c60) }, + { SPH_C32(0x28bcd830), SPH_C32(0xd9fc0000), SPH_C32(0x8a480000), + SPH_C32(0xa8ea0000), SPH_C32(0xec2f3143), SPH_C32(0x4e8fd767), + SPH_C32(0x8bc9599a), SPH_C32(0x3eb5c807), SPH_C32(0x34255240), + SPH_C32(0x3f570000), SPH_C32(0x6aa10000), SPH_C32(0x541e0000), + SPH_C32(0x4a5679cd), SPH_C32(0xf943abbc), SPH_C32(0x7cb1ec27), + SPH_C32(0xe611ce02) }, + { SPH_C32(0xf58de400), SPH_C32(0x87300000), SPH_C32(0xc4eb0000), + SPH_C32(0x7fc40000), SPH_C32(0x2a2757d6), SPH_C32(0x933a1b28), + SPH_C32(0x9cff573e), SPH_C32(0x415243aa), SPH_C32(0x31224400), + SPH_C32(0x2a360000), SPH_C32(0xec4c0000), SPH_C32(0xe06d0000), + SPH_C32(0xaafd3a57), SPH_C32(0x281c4a3b), SPH_C32(0x48fe85cd), + SPH_C32(0x3613da7f) }, + { SPH_C32(0x3ce6e430), SPH_C32(0x60150000), SPH_C32(0xeb6f0000), + SPH_C32(0x598b0000), SPH_C32(0x224e0c2f), SPH_C32(0xfec6ea1f), + SPH_C32(0xcc603eba), SPH_C32(0xdf3becc2), SPH_C32(0x17424640), + SPH_C32(0xf7ee0000), SPH_C32(0x9e660000), SPH_C32(0xaf6b0000), + SPH_C32(0x399b5da8), SPH_C32(0x01e50ef5), SPH_C32(0x7e75e618), + SPH_C32(0x3a35281d) }, + { SPH_C32(0xc2b0cc00), SPH_C32(0xf6600000), SPH_C32(0x510b0000), + SPH_C32(0x75d00000), SPH_C32(0x978b4edf), SPH_C32(0xdbd58319), + SPH_C32(0xd9923a21), SPH_C32(0x7cf88170), SPH_C32(0x25787800), + SPH_C32(0x93df0000), SPH_C32(0x8d6b0000), SPH_C32(0x110c0000), + SPH_C32(0x649c073b), SPH_C32(0x98557743), SPH_C32(0x0f57e2ed), + SPH_C32(0xd79dfeba) }, + { SPH_C32(0x0bdbcc30), SPH_C32(0x11450000), SPH_C32(0x7e8f0000), + SPH_C32(0x539f0000), SPH_C32(0x9fe21526), SPH_C32(0xb629722e), + SPH_C32(0x890d53a5), SPH_C32(0xe2912e18), SPH_C32(0x03187a40), + SPH_C32(0x4e070000), SPH_C32(0xff410000), SPH_C32(0x5e0a0000), + SPH_C32(0xf7fa60c4), SPH_C32(0xb1ac338d), SPH_C32(0x39dc8138), + SPH_C32(0xdbbb0cd8) }, + { SPH_C32(0xd6eaf000), SPH_C32(0x4f890000), SPH_C32(0x302c0000), + SPH_C32(0x84b10000), SPH_C32(0x59ea73b3), SPH_C32(0x6b9cbe61), + SPH_C32(0x9e3b5d01), SPH_C32(0x9d76a5b5), SPH_C32(0x061f6c00), + SPH_C32(0x5b660000), SPH_C32(0x79ac0000), SPH_C32(0xea790000), + SPH_C32(0x1751235e), SPH_C32(0x60f3d20a), SPH_C32(0x0d93e8d2), + SPH_C32(0x0bb918a5) }, + { SPH_C32(0x1f81f030), SPH_C32(0xa8ac0000), SPH_C32(0x1fa80000), + SPH_C32(0xa2fe0000), SPH_C32(0x5183284a), SPH_C32(0x06604f56), + SPH_C32(0xcea43485), SPH_C32(0x031f0add), SPH_C32(0x207f6e40), + SPH_C32(0x86be0000), SPH_C32(0x0b860000), SPH_C32(0xa57f0000), + SPH_C32(0x843744a1), SPH_C32(0x490a96c4), SPH_C32(0x3b188b07), + SPH_C32(0x079feac7) }, + { SPH_C32(0x466d0c00), SPH_C32(0x08620000), SPH_C32(0xdd5d0000), + SPH_C32(0xbadd0000), SPH_C32(0x6a927942), SPH_C32(0x441f2b93), + SPH_C32(0x218ace6f), SPH_C32(0xbf2c0be2), SPH_C32(0x6f299000), + SPH_C32(0x6c850000), SPH_C32(0x2f160000), SPH_C32(0x782e0000), + SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), SPH_C32(0xd26a8c36), + SPH_C32(0x32219526) }, + { SPH_C32(0x8f060c30), SPH_C32(0xef470000), SPH_C32(0xf2d90000), + SPH_C32(0x9c920000), SPH_C32(0x62fb22bb), SPH_C32(0x29e3daa4), + SPH_C32(0x7115a7eb), SPH_C32(0x2145a48a), SPH_C32(0x49499240), + SPH_C32(0xb15d0000), SPH_C32(0x5d3c0000), SPH_C32(0x37280000), + SPH_C32(0xf72a5032), SPH_C32(0x3b245818), SPH_C32(0xe4e1efe3), + SPH_C32(0x3e076744) }, + { SPH_C32(0x52373000), SPH_C32(0xb18b0000), SPH_C32(0xbc7a0000), + SPH_C32(0x4bbc0000), SPH_C32(0xa4f3442e), SPH_C32(0xf45616eb), + SPH_C32(0x6623a94f), SPH_C32(0x5ea22f27), SPH_C32(0x4c4e8400), + SPH_C32(0xa43c0000), SPH_C32(0xdbd10000), SPH_C32(0x835b0000), + SPH_C32(0x178113a8), SPH_C32(0xea7bb99f), SPH_C32(0xd0ae8609), + SPH_C32(0xee057339) }, + { SPH_C32(0x9b5c3030), SPH_C32(0x56ae0000), SPH_C32(0x93fe0000), + SPH_C32(0x6df30000), SPH_C32(0xac9a1fd7), SPH_C32(0x99aae7dc), + SPH_C32(0x36bcc0cb), SPH_C32(0xc0cb804f), SPH_C32(0x6a2e8640), + SPH_C32(0x79e40000), SPH_C32(0xa9fb0000), SPH_C32(0xcc5d0000), + SPH_C32(0x84e77457), SPH_C32(0xc382fd51), SPH_C32(0xe625e5dc), + SPH_C32(0xe223815b) }, + { SPH_C32(0x650a1800), SPH_C32(0xc0db0000), SPH_C32(0x299a0000), + SPH_C32(0x41a80000), SPH_C32(0x195f5d27), SPH_C32(0xbcb98eda), + SPH_C32(0x234ec450), SPH_C32(0x6308edfd), SPH_C32(0x5814b800), + SPH_C32(0x1dd50000), SPH_C32(0xbaf60000), SPH_C32(0x723a0000), + SPH_C32(0xd9e02ec4), SPH_C32(0x5a3284e7), SPH_C32(0x9707e129), + SPH_C32(0x0f8b57fc) }, + { SPH_C32(0xac611830), SPH_C32(0x27fe0000), SPH_C32(0x061e0000), + SPH_C32(0x67e70000), SPH_C32(0x113606de), SPH_C32(0xd1457fed), + SPH_C32(0x73d1add4), SPH_C32(0xfd614295), SPH_C32(0x7e74ba40), + SPH_C32(0xc00d0000), SPH_C32(0xc8dc0000), SPH_C32(0x3d3c0000), + SPH_C32(0x4a86493b), SPH_C32(0x73cbc029), SPH_C32(0xa18c82fc), + SPH_C32(0x03ada59e) }, + { SPH_C32(0x71502400), SPH_C32(0x79320000), SPH_C32(0x48bd0000), + SPH_C32(0xb0c90000), SPH_C32(0xd73e604b), SPH_C32(0x0cf0b3a2), + SPH_C32(0x64e7a370), SPH_C32(0x8286c938), SPH_C32(0x7b73ac00), + SPH_C32(0xd56c0000), SPH_C32(0x4e310000), SPH_C32(0x894f0000), + SPH_C32(0xaa2d0aa1), SPH_C32(0xa29421ae), SPH_C32(0x95c3eb16), + SPH_C32(0xd3afb1e3) }, + { SPH_C32(0xb83b2430), SPH_C32(0x9e170000), SPH_C32(0x67390000), + SPH_C32(0x96860000), SPH_C32(0xdf573bb2), SPH_C32(0x610c4295), + SPH_C32(0x3478caf4), SPH_C32(0x1cef6650), SPH_C32(0x5d13ae40), + SPH_C32(0x08b40000), SPH_C32(0x3c1b0000), SPH_C32(0xc6490000), + SPH_C32(0x394b6d5e), SPH_C32(0x8b6d6560), SPH_C32(0xa34888c3), + SPH_C32(0xdf894381) }, + { SPH_C32(0x12455000), SPH_C32(0xe28f0000), SPH_C32(0x188b0000), + SPH_C32(0x1b180000), SPH_C32(0xd9301e32), SPH_C32(0xd0baef72), + SPH_C32(0x4a3a8ff2), SPH_C32(0xea373c60), SPH_C32(0xf3928800), + SPH_C32(0xdc560000), SPH_C32(0xbd470000), SPH_C32(0x95bd0000), + SPH_C32(0x3d767488), SPH_C32(0xf3c9c922), SPH_C32(0x916cbfec), + SPH_C32(0x4aeb5b0f) }, + { SPH_C32(0xdb2e5030), SPH_C32(0x05aa0000), SPH_C32(0x370f0000), + SPH_C32(0x3d570000), SPH_C32(0xd15945cb), SPH_C32(0xbd461e45), + SPH_C32(0x1aa5e676), SPH_C32(0x745e9308), SPH_C32(0xd5f28a40), + SPH_C32(0x018e0000), SPH_C32(0xcf6d0000), SPH_C32(0xdabb0000), + SPH_C32(0xae101377), SPH_C32(0xda308dec), SPH_C32(0xa7e7dc39), + SPH_C32(0x46cda96d) }, + { SPH_C32(0x061f6c00), SPH_C32(0x5b660000), SPH_C32(0x79ac0000), + SPH_C32(0xea790000), SPH_C32(0x1751235e), SPH_C32(0x60f3d20a), + SPH_C32(0x0d93e8d2), SPH_C32(0x0bb918a5), SPH_C32(0xd0f59c00), + SPH_C32(0x14ef0000), SPH_C32(0x49800000), SPH_C32(0x6ec80000), + SPH_C32(0x4ebb50ed), SPH_C32(0x0b6f6c6b), SPH_C32(0x93a8b5d3), + SPH_C32(0x96cfbd10) }, + { SPH_C32(0xcf746c30), SPH_C32(0xbc430000), SPH_C32(0x56280000), + SPH_C32(0xcc360000), SPH_C32(0x1f3878a7), SPH_C32(0x0d0f233d), + SPH_C32(0x5d0c8156), SPH_C32(0x95d0b7cd), SPH_C32(0xf6959e40), + SPH_C32(0xc9370000), SPH_C32(0x3baa0000), SPH_C32(0x21ce0000), + SPH_C32(0xdddd3712), SPH_C32(0x229628a5), SPH_C32(0xa523d606), + SPH_C32(0x9ae94f72) }, + { SPH_C32(0x31224400), SPH_C32(0x2a360000), SPH_C32(0xec4c0000), + SPH_C32(0xe06d0000), SPH_C32(0xaafd3a57), SPH_C32(0x281c4a3b), + SPH_C32(0x48fe85cd), SPH_C32(0x3613da7f), SPH_C32(0xc4afa000), + SPH_C32(0xad060000), SPH_C32(0x28a70000), SPH_C32(0x9fa90000), + SPH_C32(0x80da6d81), SPH_C32(0xbb265113), SPH_C32(0xd401d2f3), + SPH_C32(0x774199d5) }, + { SPH_C32(0xf8494430), SPH_C32(0xcd130000), SPH_C32(0xc3c80000), + SPH_C32(0xc6220000), SPH_C32(0xa29461ae), SPH_C32(0x45e0bb0c), + SPH_C32(0x1861ec49), SPH_C32(0xa87a7517), SPH_C32(0xe2cfa240), + SPH_C32(0x70de0000), SPH_C32(0x5a8d0000), SPH_C32(0xd0af0000), + SPH_C32(0x13bc0a7e), SPH_C32(0x92df15dd), SPH_C32(0xe28ab126), + SPH_C32(0x7b676bb7) }, + { SPH_C32(0x25787800), SPH_C32(0x93df0000), SPH_C32(0x8d6b0000), + SPH_C32(0x110c0000), SPH_C32(0x649c073b), SPH_C32(0x98557743), + SPH_C32(0x0f57e2ed), SPH_C32(0xd79dfeba), SPH_C32(0xe7c8b400), + SPH_C32(0x65bf0000), SPH_C32(0xdc600000), SPH_C32(0x64dc0000), + SPH_C32(0xf31749e4), SPH_C32(0x4380f45a), SPH_C32(0xd6c5d8cc), + SPH_C32(0xab657fca) }, + { SPH_C32(0xec137830), SPH_C32(0x74fa0000), SPH_C32(0xa2ef0000), + SPH_C32(0x37430000), SPH_C32(0x6cf55cc2), SPH_C32(0xf5a98674), + SPH_C32(0x5fc88b69), SPH_C32(0x49f451d2), SPH_C32(0xc1a8b640), + SPH_C32(0xb8670000), SPH_C32(0xae4a0000), SPH_C32(0x2bda0000), + SPH_C32(0x60712e1b), SPH_C32(0x6a79b094), SPH_C32(0xe04ebb19), + SPH_C32(0xa7438da8) }, + { SPH_C32(0xdad61400), SPH_C32(0xb8b10000), SPH_C32(0x4f0c0000), + SPH_C32(0x574e0000), SPH_C32(0x33a83a07), SPH_C32(0xa50bfe67), + SPH_C32(0x628cfdb5), SPH_C32(0xc7e6c5cb), SPH_C32(0xa7bad400), + SPH_C32(0x36bb0000), SPH_C32(0x78910000), SPH_C32(0x34780000), + SPH_C32(0x8ed413f8), SPH_C32(0x676c0dc3), SPH_C32(0xfadcfe71), + SPH_C32(0x1ff06c8d) }, + { SPH_C32(0x13bd1430), SPH_C32(0x5f940000), SPH_C32(0x60880000), + SPH_C32(0x71010000), SPH_C32(0x3bc161fe), SPH_C32(0xc8f70f50), + SPH_C32(0x32139431), SPH_C32(0x598f6aa3), SPH_C32(0x81dad640), + SPH_C32(0xeb630000), SPH_C32(0x0abb0000), SPH_C32(0x7b7e0000), + SPH_C32(0x1db27407), SPH_C32(0x4e95490d), SPH_C32(0xcc579da4), + SPH_C32(0x13d69eef) }, + { SPH_C32(0xce8c2800), SPH_C32(0x01580000), SPH_C32(0x2e2b0000), + SPH_C32(0xa62f0000), SPH_C32(0xfdc9076b), SPH_C32(0x1542c31f), + SPH_C32(0x25259a95), SPH_C32(0x2668e10e), SPH_C32(0x84ddc000), + SPH_C32(0xfe020000), SPH_C32(0x8c560000), SPH_C32(0xcf0d0000), + SPH_C32(0xfd19379d), SPH_C32(0x9fcaa88a), SPH_C32(0xf818f44e), + SPH_C32(0xc3d48a92) }, + { SPH_C32(0x07e72830), SPH_C32(0xe67d0000), SPH_C32(0x01af0000), + SPH_C32(0x80600000), SPH_C32(0xf5a05c92), SPH_C32(0x78be3228), + SPH_C32(0x75baf311), SPH_C32(0xb8014e66), SPH_C32(0xa2bdc240), + SPH_C32(0x23da0000), SPH_C32(0xfe7c0000), SPH_C32(0x800b0000), + SPH_C32(0x6e7f5062), SPH_C32(0xb633ec44), SPH_C32(0xce93979b), + SPH_C32(0xcff278f0) }, + { SPH_C32(0xf9b10000), SPH_C32(0x70080000), SPH_C32(0xbbcb0000), + SPH_C32(0xac3b0000), SPH_C32(0x40651e62), SPH_C32(0x5dad5b2e), + SPH_C32(0x6048f78a), SPH_C32(0x1bc223d4), SPH_C32(0x9087fc00), + SPH_C32(0x47eb0000), SPH_C32(0xed710000), SPH_C32(0x3e6c0000), + SPH_C32(0x33780af1), SPH_C32(0x2f8395f2), SPH_C32(0xbfb1936e), + SPH_C32(0x225aae57) }, + { SPH_C32(0x30da0030), SPH_C32(0x972d0000), SPH_C32(0x944f0000), + SPH_C32(0x8a740000), SPH_C32(0x480c459b), SPH_C32(0x3051aa19), + SPH_C32(0x30d79e0e), SPH_C32(0x85ab8cbc), SPH_C32(0xb6e7fe40), + SPH_C32(0x9a330000), SPH_C32(0x9f5b0000), SPH_C32(0x716a0000), + SPH_C32(0xa01e6d0e), SPH_C32(0x067ad13c), SPH_C32(0x893af0bb), + SPH_C32(0x2e7c5c35) }, + { SPH_C32(0xedeb3c00), SPH_C32(0xc9e10000), SPH_C32(0xdaec0000), + SPH_C32(0x5d5a0000), SPH_C32(0x8e04230e), SPH_C32(0xede46656), + SPH_C32(0x27e190aa), SPH_C32(0xfa4c0711), SPH_C32(0xb3e0e800), + SPH_C32(0x8f520000), SPH_C32(0x19b60000), SPH_C32(0xc5190000), + SPH_C32(0x40b52e94), SPH_C32(0xd72530bb), SPH_C32(0xbd759951), + SPH_C32(0xfe7e4848) }, + { SPH_C32(0x24803c30), SPH_C32(0x2ec40000), SPH_C32(0xf5680000), + SPH_C32(0x7b150000), SPH_C32(0x866d78f7), SPH_C32(0x80189761), + SPH_C32(0x777ef92e), SPH_C32(0x6425a879), SPH_C32(0x9580ea40), + SPH_C32(0x528a0000), SPH_C32(0x6b9c0000), SPH_C32(0x8a1f0000), + SPH_C32(0xd3d3496b), SPH_C32(0xfedc7475), SPH_C32(0x8bfefa84), + SPH_C32(0xf258ba2a) }, + { SPH_C32(0x8efe4800), SPH_C32(0x525c0000), SPH_C32(0x8ada0000), + SPH_C32(0xf68b0000), SPH_C32(0x800a5d77), SPH_C32(0x31ae3a86), + SPH_C32(0x093cbc28), SPH_C32(0x92fdf249), SPH_C32(0x3b01cc00), + SPH_C32(0x86680000), SPH_C32(0xeac00000), SPH_C32(0xd9eb0000), + SPH_C32(0xd7ee50bd), SPH_C32(0x8678d837), SPH_C32(0xb9dacdab), + SPH_C32(0x673aa2a4) }, + { SPH_C32(0x47954830), SPH_C32(0xb5790000), SPH_C32(0xa55e0000), + SPH_C32(0xd0c40000), SPH_C32(0x8863068e), SPH_C32(0x5c52cbb1), + SPH_C32(0x59a3d5ac), SPH_C32(0x0c945d21), SPH_C32(0x1d61ce40), + SPH_C32(0x5bb00000), SPH_C32(0x98ea0000), SPH_C32(0x96ed0000), + SPH_C32(0x44883742), SPH_C32(0xaf819cf9), SPH_C32(0x8f51ae7e), + SPH_C32(0x6b1c50c6) }, + { SPH_C32(0x9aa47400), SPH_C32(0xebb50000), SPH_C32(0xebfd0000), + SPH_C32(0x07ea0000), SPH_C32(0x4e6b601b), SPH_C32(0x81e707fe), + SPH_C32(0x4e95db08), SPH_C32(0x7373d68c), SPH_C32(0x1866d800), + SPH_C32(0x4ed10000), SPH_C32(0x1e070000), SPH_C32(0x229e0000), + SPH_C32(0xa42374d8), SPH_C32(0x7ede7d7e), SPH_C32(0xbb1ec794), + SPH_C32(0xbb1e44bb) }, + { SPH_C32(0x53cf7430), SPH_C32(0x0c900000), SPH_C32(0xc4790000), + SPH_C32(0x21a50000), SPH_C32(0x46023be2), SPH_C32(0xec1bf6c9), + SPH_C32(0x1e0ab28c), SPH_C32(0xed1a79e4), SPH_C32(0x3e06da40), + SPH_C32(0x93090000), SPH_C32(0x6c2d0000), SPH_C32(0x6d980000), + SPH_C32(0x37451327), SPH_C32(0x572739b0), SPH_C32(0x8d95a441), + SPH_C32(0xb738b6d9) }, + { SPH_C32(0xad995c00), SPH_C32(0x9ae50000), SPH_C32(0x7e1d0000), + SPH_C32(0x0dfe0000), SPH_C32(0xf3c77912), SPH_C32(0xc9089fcf), + SPH_C32(0x0bf8b617), SPH_C32(0x4ed91456), SPH_C32(0x0c3ce400), + SPH_C32(0xf7380000), SPH_C32(0x7f200000), SPH_C32(0xd3ff0000), + SPH_C32(0x6a4249b4), SPH_C32(0xce974006), SPH_C32(0xfcb7a0b4), + SPH_C32(0x5a90607e) }, + { SPH_C32(0x64f25c30), SPH_C32(0x7dc00000), SPH_C32(0x51990000), + SPH_C32(0x2bb10000), SPH_C32(0xfbae22eb), SPH_C32(0xa4f46ef8), + SPH_C32(0x5b67df93), SPH_C32(0xd0b0bb3e), SPH_C32(0x2a5ce640), + SPH_C32(0x2ae00000), SPH_C32(0x0d0a0000), SPH_C32(0x9cf90000), + SPH_C32(0xf9242e4b), SPH_C32(0xe76e04c8), SPH_C32(0xca3cc361), + SPH_C32(0x56b6921c) }, + { SPH_C32(0xb9c36000), SPH_C32(0x230c0000), SPH_C32(0x1f3a0000), + SPH_C32(0xfc9f0000), SPH_C32(0x3da6447e), SPH_C32(0x7941a2b7), + SPH_C32(0x4c51d137), SPH_C32(0xaf573093), SPH_C32(0x2f5bf000), + SPH_C32(0x3f810000), SPH_C32(0x8be70000), SPH_C32(0x288a0000), + SPH_C32(0x198f6dd1), SPH_C32(0x3631e54f), SPH_C32(0xfe73aa8b), + SPH_C32(0x86b48661) }, + { SPH_C32(0x70a86030), SPH_C32(0xc4290000), SPH_C32(0x30be0000), + SPH_C32(0xdad00000), SPH_C32(0x35cf1f87), SPH_C32(0x14bd5380), + SPH_C32(0x1cceb8b3), SPH_C32(0x313e9ffb), SPH_C32(0x093bf240), + SPH_C32(0xe2590000), SPH_C32(0xf9cd0000), SPH_C32(0x678c0000), + SPH_C32(0x8ae90a2e), SPH_C32(0x1fc8a181), SPH_C32(0xc8f8c95e), + SPH_C32(0x8a927403) }, + { SPH_C32(0x6f299000), SPH_C32(0x6c850000), SPH_C32(0x2f160000), + SPH_C32(0x782e0000), SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), + SPH_C32(0xd26a8c36), SPH_C32(0x32219526), SPH_C32(0x29449c00), + SPH_C32(0x64e70000), SPH_C32(0xf24b0000), SPH_C32(0xc2f30000), + SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), SPH_C32(0xf3e04259), + SPH_C32(0x8d0d9ec4) }, + { SPH_C32(0xa6429030), SPH_C32(0x8ba00000), SPH_C32(0x00920000), + SPH_C32(0x5e610000), SPH_C32(0x6c256c34), SPH_C32(0x7f21ede1), + SPH_C32(0x82f5e5b2), SPH_C32(0xac483a4e), SPH_C32(0x0f249e40), + SPH_C32(0xb93f0000), SPH_C32(0x80610000), SPH_C32(0x8df50000), + SPH_C32(0x9db82970), SPH_C32(0x7f3b738b), SPH_C32(0xc56b218c), + SPH_C32(0x812b6ca6) }, + { SPH_C32(0x7b73ac00), SPH_C32(0xd56c0000), SPH_C32(0x4e310000), + SPH_C32(0x894f0000), SPH_C32(0xaa2d0aa1), SPH_C32(0xa29421ae), + SPH_C32(0x95c3eb16), SPH_C32(0xd3afb1e3), SPH_C32(0x0a238800), + SPH_C32(0xac5e0000), SPH_C32(0x068c0000), SPH_C32(0x39860000), + SPH_C32(0x7d136aea), SPH_C32(0xae64920c), SPH_C32(0xf1244866), + SPH_C32(0x512978db) }, + { SPH_C32(0xb218ac30), SPH_C32(0x32490000), SPH_C32(0x61b50000), + SPH_C32(0xaf000000), SPH_C32(0xa2445158), SPH_C32(0xcf68d099), + SPH_C32(0xc55c8292), SPH_C32(0x4dc61e8b), SPH_C32(0x2c438a40), + SPH_C32(0x71860000), SPH_C32(0x74a60000), SPH_C32(0x76800000), + SPH_C32(0xee750d15), SPH_C32(0x879dd6c2), SPH_C32(0xc7af2bb3), + SPH_C32(0x5d0f8ab9) }, + { SPH_C32(0x4c4e8400), SPH_C32(0xa43c0000), SPH_C32(0xdbd10000), + SPH_C32(0x835b0000), SPH_C32(0x178113a8), SPH_C32(0xea7bb99f), + SPH_C32(0xd0ae8609), SPH_C32(0xee057339), SPH_C32(0x1e79b400), + SPH_C32(0x15b70000), SPH_C32(0x67ab0000), SPH_C32(0xc8e70000), + SPH_C32(0xb3725786), SPH_C32(0x1e2daf74), SPH_C32(0xb68d2f46), + SPH_C32(0xb0a75c1e) }, + { SPH_C32(0x85258430), SPH_C32(0x43190000), SPH_C32(0xf4550000), + SPH_C32(0xa5140000), SPH_C32(0x1fe84851), SPH_C32(0x878748a8), + SPH_C32(0x8031ef8d), SPH_C32(0x706cdc51), SPH_C32(0x3819b640), + SPH_C32(0xc86f0000), SPH_C32(0x15810000), SPH_C32(0x87e10000), + SPH_C32(0x20143079), SPH_C32(0x37d4ebba), SPH_C32(0x80064c93), + SPH_C32(0xbc81ae7c) }, + { SPH_C32(0x5814b800), SPH_C32(0x1dd50000), SPH_C32(0xbaf60000), + SPH_C32(0x723a0000), SPH_C32(0xd9e02ec4), SPH_C32(0x5a3284e7), + SPH_C32(0x9707e129), SPH_C32(0x0f8b57fc), SPH_C32(0x3d1ea000), + SPH_C32(0xdd0e0000), SPH_C32(0x936c0000), SPH_C32(0x33920000), + SPH_C32(0xc0bf73e3), SPH_C32(0xe68b0a3d), SPH_C32(0xb4492579), + SPH_C32(0x6c83ba01) }, + { SPH_C32(0x917fb830), SPH_C32(0xfaf00000), SPH_C32(0x95720000), + SPH_C32(0x54750000), SPH_C32(0xd189753d), SPH_C32(0x37ce75d0), + SPH_C32(0xc79888ad), SPH_C32(0x91e2f894), SPH_C32(0x1b7ea240), + SPH_C32(0x00d60000), SPH_C32(0xe1460000), SPH_C32(0x7c940000), + SPH_C32(0x53d9141c), SPH_C32(0xcf724ef3), SPH_C32(0x82c246ac), + SPH_C32(0x60a54863) }, + { SPH_C32(0x3b01cc00), SPH_C32(0x86680000), SPH_C32(0xeac00000), + SPH_C32(0xd9eb0000), SPH_C32(0xd7ee50bd), SPH_C32(0x8678d837), + SPH_C32(0xb9dacdab), SPH_C32(0x673aa2a4), SPH_C32(0xb5ff8400), + SPH_C32(0xd4340000), SPH_C32(0x601a0000), SPH_C32(0x2f600000), + SPH_C32(0x57e40dca), SPH_C32(0xb7d6e2b1), SPH_C32(0xb0e67183), + SPH_C32(0xf5c750ed) }, + { SPH_C32(0xf26acc30), SPH_C32(0x614d0000), SPH_C32(0xc5440000), + SPH_C32(0xffa40000), SPH_C32(0xdf870b44), SPH_C32(0xeb842900), + SPH_C32(0xe945a42f), SPH_C32(0xf9530dcc), SPH_C32(0x939f8640), + SPH_C32(0x09ec0000), SPH_C32(0x12300000), SPH_C32(0x60660000), + SPH_C32(0xc4826a35), SPH_C32(0x9e2fa67f), SPH_C32(0x866d1256), + SPH_C32(0xf9e1a28f) }, + { SPH_C32(0x2f5bf000), SPH_C32(0x3f810000), SPH_C32(0x8be70000), + SPH_C32(0x288a0000), SPH_C32(0x198f6dd1), SPH_C32(0x3631e54f), + SPH_C32(0xfe73aa8b), SPH_C32(0x86b48661), SPH_C32(0x496989000), + SPH_C32(0x1c8d0000), SPH_C32(0x94dd0000), SPH_C32(0xd4150000), + SPH_C32(0x242929af), SPH_C32(0x4f7047f8), SPH_C32(0xb2227bbc), + SPH_C32(0x29e3b6f2) }, + { SPH_C32(0xe630f030), SPH_C32(0xd8a40000), SPH_C32(0xa4630000), + SPH_C32(0x0ec50000), SPH_C32(0x11e63628), SPH_C32(0x5bcd1478), + SPH_C32(0xaeecc30f), SPH_C32(0x18dd2909), SPH_C32(0xb0f89240), + SPH_C32(0xc1550000), SPH_C32(0xe6f70000), SPH_C32(0x9b130000), + SPH_C32(0xb74f4e50), SPH_C32(0x66890336), SPH_C32(0x84a91869), + SPH_C32(0x25c54490) }, + { SPH_C32(0x1866d800), SPH_C32(0x4ed10000), SPH_C32(0x1e070000), + SPH_C32(0x229e0000), SPH_C32(0xa42374d8), SPH_C32(0x7ede7d7e), + SPH_C32(0xbb1ec794), SPH_C32(0xbb1e44bb), SPH_C32(0x82c2ac00), + SPH_C32(0xa5640000), SPH_C32(0xf5fa0000), SPH_C32(0x25740000), + SPH_C32(0xea4814c3), SPH_C32(0xff397a80), SPH_C32(0xf58b1c9c), + SPH_C32(0xc86d9237) }, + { SPH_C32(0xd10dd830), SPH_C32(0xa9f40000), SPH_C32(0x31830000), + SPH_C32(0x04d10000), SPH_C32(0xac4a2f21), SPH_C32(0x13228c49), + SPH_C32(0xeb81ae10), SPH_C32(0x2577ebd3), SPH_C32(0xa4a2ae40), + SPH_C32(0x78bc0000), SPH_C32(0x87d00000), SPH_C32(0x6a720000), + SPH_C32(0x792e733c), SPH_C32(0xd6c03e4e), SPH_C32(0xc3007f49), + SPH_C32(0xc44b6055) }, + { SPH_C32(0x0c3ce400), SPH_C32(0xf7380000), SPH_C32(0x7f200000), + SPH_C32(0xd3ff0000), SPH_C32(0x6a4249b4), SPH_C32(0xce974006), + SPH_C32(0xfcb7a0b4), SPH_C32(0x5a90607e), SPH_C32(0xa1a5b800), + SPH_C32(0x6ddd0000), SPH_C32(0x013d0000), SPH_C32(0xde010000), + SPH_C32(0x998530a6), SPH_C32(0x079fdfc9), SPH_C32(0xf74f16a3), + SPH_C32(0x14497428) }, + { SPH_C32(0xc557e430), SPH_C32(0x101d0000), SPH_C32(0x50a40000), + SPH_C32(0xf5b00000), SPH_C32(0x622b124d), SPH_C32(0xa36bb131), + SPH_C32(0xac28c930), SPH_C32(0xc4f9cf16), SPH_C32(0x87c5ba40), + SPH_C32(0xb0050000), SPH_C32(0x73170000), SPH_C32(0x91070000), + SPH_C32(0x0ae35759), SPH_C32(0x2e669b07), SPH_C32(0xc1c47576), + SPH_C32(0x186f864a) }, + { SPH_C32(0xf3928800), SPH_C32(0xdc560000), SPH_C32(0xbd470000), + SPH_C32(0x95bd0000), SPH_C32(0x3d767488), SPH_C32(0xf3c9c922), + SPH_C32(0x916cbfec), SPH_C32(0x4aeb5b0f), SPH_C32(0xe1d7d800), + SPH_C32(0x3ed90000), SPH_C32(0xa5cc0000), SPH_C32(0x8ea50000), + SPH_C32(0xe4466aba), SPH_C32(0x23732650), SPH_C32(0xdb56301e), + SPH_C32(0xa0dc676f) }, + { SPH_C32(0x3af98830), SPH_C32(0x3b730000), SPH_C32(0x92c30000), + SPH_C32(0xb3f20000), SPH_C32(0x351f2f71), SPH_C32(0x9e353815), + SPH_C32(0xc1f3d668), SPH_C32(0xd482f467), SPH_C32(0xc7b7da40), + SPH_C32(0xe3010000), SPH_C32(0xd7e60000), SPH_C32(0xc1a30000), + SPH_C32(0x77200d45), SPH_C32(0x0a8a629e), SPH_C32(0xeddd53cb), + SPH_C32(0xacfa950d) }, + { SPH_C32(0xe7c8b400), SPH_C32(0x65bf0000), SPH_C32(0xdc600000), + SPH_C32(0x64dc0000), SPH_C32(0xf31749e4), SPH_C32(0x4380f45a), + SPH_C32(0xd6c5d8cc), SPH_C32(0xab657fca), SPH_C32(0xc2b0cc00), + SPH_C32(0xf6600000), SPH_C32(0x510b0000), SPH_C32(0x75d00000), + SPH_C32(0x978b4edf), SPH_C32(0xdbd58319), SPH_C32(0xd9923a21), + SPH_C32(0x7cf88170) }, + { SPH_C32(0x2ea3b430), SPH_C32(0x829a0000), SPH_C32(0xf3e40000), + SPH_C32(0x42930000), SPH_C32(0xfb7e121d), SPH_C32(0x2e7c056d), + SPH_C32(0x865ab148), SPH_C32(0x350cd0a2), SPH_C32(0xe4d0ce40), + SPH_C32(0x2bb80000), SPH_C32(0x23210000), SPH_C32(0x3ad60000), + SPH_C32(0x04ed2920), SPH_C32(0xf22cc7d7), SPH_C32(0xef1959f4), + SPH_C32(0x70de7312) }, + { SPH_C32(0xd0f59c00), SPH_C32(0x14ef0000), SPH_C32(0x49800000), + SPH_C32(0x6ec80000), SPH_C32(0x4ebb50ed), SPH_C32(0x0b6f6c6b), + SPH_C32(0x93a8b5d3), SPH_C32(0x96cfbd10), SPH_C32(0xd6eaf000), + SPH_C32(0x4f890000), SPH_C32(0x302c0000), SPH_C32(0x84b10000), + SPH_C32(0x59ea73b3), SPH_C32(0x6b9cbe61), SPH_C32(0x9e3b5d01), + SPH_C32(0x9d76a5b5) }, + { SPH_C32(0x199e9c30), SPH_C32(0xf3ca0000), SPH_C32(0x66040000), + SPH_C32(0x48870000), SPH_C32(0x46d20b14), SPH_C32(0x66939d5c), + SPH_C32(0xc337dc57), SPH_C32(0x08a61278), SPH_C32(0xf08af240), + SPH_C32(0x92510000), SPH_C32(0x42060000), SPH_C32(0xcbb70000), + SPH_C32(0xca8c144c), SPH_C32(0x4265faaf), SPH_C32(0xa8b03ed4), + SPH_C32(0x915057d7) }, + { SPH_C32(0xc4afa000), SPH_C32(0xad060000), SPH_C32(0x28a70000), + SPH_C32(0x9fa90000), SPH_C32(0x80da6d81), SPH_C32(0xbb265113), + SPH_C32(0xd401d2f3), SPH_C32(0x774199d5), SPH_C32(0xf58de400), + SPH_C32(0x87300000), SPH_C32(0xc4eb0000), SPH_C32(0x7fc40000), + SPH_C32(0x2a2757d6), SPH_C32(0x933a1b28), SPH_C32(0x9cff573e), + SPH_C32(0x415243aa) }, + { SPH_C32(0x0dc4a030), SPH_C32(0x4a230000), SPH_C32(0x07230000), + SPH_C32(0xb9e60000), SPH_C32(0x88b33678), SPH_C32(0xd6daa024), + SPH_C32(0x849ebb77), SPH_C32(0xe92836bd), SPH_C32(0xd3ede640), + SPH_C32(0x5ae80000), SPH_C32(0xb6c10000), SPH_C32(0x30c20000), + SPH_C32(0xb9413029), SPH_C32(0xbac35fe6), SPH_C32(0xaa7434eb), + SPH_C32(0x4d74b1c8) }, + { SPH_C32(0xa7bad400), SPH_C32(0x36bb0000), SPH_C32(0x78910000), + SPH_C32(0x34780000), SPH_C32(0x8ed413f8), SPH_C32(0x676c0dc3), + SPH_C32(0xfadcfe71), SPH_C32(0x1ff06c8d), SPH_C32(0x7d6cc000), + SPH_C32(0x8e0a0000), SPH_C32(0x379d0000), SPH_C32(0x63360000), + SPH_C32(0xbd7c29ff), SPH_C32(0xc267f3a4), SPH_C32(0x985003c4), + SPH_C32(0xd816a946) }, + { SPH_C32(0x6ed1d430), SPH_C32(0xd19e0000), SPH_C32(0x57150000), + SPH_C32(0x12370000), SPH_C32(0x86bd4801), SPH_C32(0x0a90fcf4), + SPH_C32(0xaa4397f5), SPH_C32(0x8199c3e5), SPH_C32(0x5b0cc240), + SPH_C32(0x53d20000), SPH_C32(0x45b70000), SPH_C32(0x2c300000), + SPH_C32(0x2e1a4e00), SPH_C32(0xeb9eb76a), SPH_C32(0xaedb6011), + SPH_C32(0xd4305b24) }, + { SPH_C32(0xb3e0e800), SPH_C32(0x8f520000), SPH_C32(0x19b60000), + SPH_C32(0xc5190000), SPH_C32(0x40b52e94), SPH_C32(0xd72530bb), + SPH_C32(0xbd759951), SPH_C32(0xfe7e4848), SPH_C32(0x5e0bd400), + SPH_C32(0x46b30000), SPH_C32(0xc35a0000), SPH_C32(0x98430000), + SPH_C32(0xceb10d9a), SPH_C32(0x3ac156ed), SPH_C32(0x9a9409fb), + SPH_C32(0x04324f59) }, + { SPH_C32(0x7a8be830), SPH_C32(0x68770000), SPH_C32(0x36320000), + SPH_C32(0xe3560000), SPH_C32(0x48dc756d), SPH_C32(0xbad9c18c), + SPH_C32(0xedeaf0d5), SPH_C32(0x6017e720), SPH_C32(0x786bd640), + SPH_C32(0x9b6b0000), SPH_C32(0xb1700000), SPH_C32(0xd7450000), + SPH_C32(0x5dd76a65), SPH_C32(0x13381223), SPH_C32(0xac1f6a2e), + SPH_C32(0x0814bd3b) }, + { SPH_C32(0x84ddc000), SPH_C32(0xfe020000), SPH_C32(0x8c560000), + SPH_C32(0xcf0d0000), SPH_C32(0xfd19379d), SPH_C32(0x9fcaa88a), + SPH_C32(0xf818f44e), SPH_C32(0xc3d48a92), SPH_C32(0x4a51e800), + SPH_C32(0xff5a0000), SPH_C32(0xa27d0000), SPH_C32(0x69220000), + SPH_C32(0x00d030f6), SPH_C32(0x8a886b95), SPH_C32(0xdd3d6edb), + SPH_C32(0xe5bc6b9c) }, + { SPH_C32(0x4db6c030), SPH_C32(0x19270000), SPH_C32(0xa3d20000), + SPH_C32(0xe9420000), SPH_C32(0xf5706c64), SPH_C32(0xf23659bd), + SPH_C32(0xa8879dca), SPH_C32(0x5dbd25fa), SPH_C32(0x6c31ea40), + SPH_C32(0x22820000), SPH_C32(0xd0570000), SPH_C32(0x26240000), + SPH_C32(0x93b65709), SPH_C32(0xa3712f5b), SPH_C32(0xebb60d0e), + SPH_C32(0xe99a99fe) }, + { SPH_C32(0x9087fc00), SPH_C32(0x47eb0000), SPH_C32(0xed710000), + SPH_C32(0x3e6c0000), SPH_C32(0x33780af1), SPH_C32(0x2f8395f2), + SPH_C32(0xbfb1936e), SPH_C32(0x225aae57), SPH_C32(0x6936fc00), + SPH_C32(0x37e30000), SPH_C32(0x56ba0000), SPH_C32(0x92570000), + SPH_C32(0x731d1493), SPH_C32(0x722ecedc), SPH_C32(0xdff964e4), + SPH_C32(0x39988d83) }, + { SPH_C32(0x59ecfc30), SPH_C32(0xa0ce0000), SPH_C32(0xc2f50000), + SPH_C32(0x18230000), SPH_C32(0x3b115108), SPH_C32(0x427f64c5), + SPH_C32(0xef2efaea), SPH_C32(0xbc33013f), SPH_C32(0x4f56fe40), + SPH_C32(0xea3b0000), SPH_C32(0x24900000), SPH_C32(0xdd510000), + SPH_C32(0xe07b736c), SPH_C32(0x5bd78a12), SPH_C32(0xe9720731), + SPH_C32(0x35be7fe1) } +}; + +static const sph_u32 T512_7[128][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xf7750009), SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), + SPH_C32(0x04920000), SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), + SPH_C32(0x7a87f14e), SPH_C32(0x9e16981a), SPH_C32(0xd46a0000), + SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), SPH_C32(0x4a290000), + SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), SPH_C32(0x98369604), + SPH_C32(0xf746c320) }, + { SPH_C32(0xd46a0000), SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), + SPH_C32(0x4a290000), SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), + SPH_C32(0x98369604), SPH_C32(0xf746c320), SPH_C32(0x231f0009), + SPH_C32(0x42f40000), SPH_C32(0x66790000), SPH_C32(0x4ebb0000), + SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), SPH_C32(0xe2b1674a), + SPH_C32(0x69505b3a) }, + { SPH_C32(0x231f0009), SPH_C32(0x42f40000), SPH_C32(0x66790000), + SPH_C32(0x4ebb0000), SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), + SPH_C32(0xe2b1674a), SPH_C32(0x69505b3a), SPH_C32(0xf7750009), + SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), SPH_C32(0x04920000), + SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), SPH_C32(0x7a87f14e), + SPH_C32(0x9e16981a) }, + { SPH_C32(0x774400f0), SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), + SPH_C32(0x34140000), SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), + SPH_C32(0x0bc3cd1e), SPH_C32(0xcf3775cb), SPH_C32(0xf46c0050), + SPH_C32(0x96180000), SPH_C32(0x14a50000), SPH_C32(0x031f0000), + SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), SPH_C32(0x9ca470d2), + SPH_C32(0x8a341574) }, + { SPH_C32(0x803100f9), SPH_C32(0x3e66c000), SPH_C32(0x36640000), + SPH_C32(0x30860000), SPH_C32(0x8ba26725), SPH_C32(0xa263da9f), + SPH_C32(0x71443c50), SPH_C32(0x5121edd1), SPH_C32(0x20060050), + SPH_C32(0x1bd0c000), SPH_C32(0xb10a0000), SPH_C32(0x49360000), + SPH_C32(0xbeda3cc2), SPH_C32(0xaf0bf875), SPH_C32(0x0492e6d6), + SPH_C32(0x7d72d654) }, + { SPH_C32(0xa32e00f0), SPH_C32(0x7c92c000), SPH_C32(0x501d0000), + SPH_C32(0x7e3d0000), SPH_C32(0x75793cf6), SPH_C32(0x933f6a49), + SPH_C32(0x93f55b1a), SPH_C32(0x3871b6eb), SPH_C32(0xd7730059), + SPH_C32(0xd4ec0000), SPH_C32(0x72dc0000), SPH_C32(0x4da40000), + SPH_C32(0xbc4f256b), SPH_C32(0x57e3cecf), SPH_C32(0x7e151798), + SPH_C32(0xe3644e4e) }, + { SPH_C32(0x545b00f9), SPH_C32(0xb3ae0000), SPH_C32(0x93cb0000), + SPH_C32(0x7aaf0000), SPH_C32(0x77ec255f), SPH_C32(0x6bd75cf3), + SPH_C32(0xe972aa54), SPH_C32(0xa6672ef1), SPH_C32(0x03190059), + SPH_C32(0x5924c000), SPH_C32(0xd7730000), SPH_C32(0x078d0000), + SPH_C32(0x40016711), SPH_C32(0x9e5748a3), SPH_C32(0xe623819c), + SPH_C32(0x14228d6e) }, + { SPH_C32(0xf46c0050), SPH_C32(0x96180000), SPH_C32(0x14a50000), + SPH_C32(0x031f0000), SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), + SPH_C32(0x9ca470d2), SPH_C32(0x8a341574), SPH_C32(0x832800a0), + SPH_C32(0x67420000), SPH_C32(0xe1170000), SPH_C32(0x370b0000), + SPH_C32(0xcba30034), SPH_C32(0x3c34923c), SPH_C32(0x9767bdcc), + SPH_C32(0x450360bf) }, + { SPH_C32(0x03190059), SPH_C32(0x5924c000), SPH_C32(0xd7730000), + SPH_C32(0x078d0000), SPH_C32(0x40016711), SPH_C32(0x9e5748a3), + SPH_C32(0xe623819c), SPH_C32(0x14228d6e), SPH_C32(0x574200a0), + SPH_C32(0xea8ac000), SPH_C32(0x44b80000), SPH_C32(0x7d220000), + SPH_C32(0x37ed424e), SPH_C32(0xf5801450), SPH_C32(0x0f512bc8), + SPH_C32(0xb245a39f) }, + { SPH_C32(0x20060050), SPH_C32(0x1bd0c000), SPH_C32(0xb10a0000), + SPH_C32(0x49360000), SPH_C32(0xbeda3cc2), SPH_C32(0xaf0bf875), + SPH_C32(0x0492e6d6), SPH_C32(0x7d72d654), SPH_C32(0xa03700a9), + SPH_C32(0x25b60000), SPH_C32(0x876e0000), SPH_C32(0x79b00000), + SPH_C32(0x35785be7), SPH_C32(0x0d6822ea), SPH_C32(0x75d6da86), + SPH_C32(0x2c533b85) }, + { SPH_C32(0xd7730059), SPH_C32(0xd4ec0000), SPH_C32(0x72dc0000), + SPH_C32(0x4da40000), SPH_C32(0xbc4f256b), SPH_C32(0x57e3cecf), + SPH_C32(0x7e151798), SPH_C32(0xe3644e4e), SPH_C32(0x745d00a9), + SPH_C32(0xa87ec000), SPH_C32(0x22c10000), SPH_C32(0x33990000), + SPH_C32(0xc936199d), SPH_C32(0xc4dca486), SPH_C32(0xede04c82), + SPH_C32(0xdb15f8a5) }, + { SPH_C32(0x832800a0), SPH_C32(0x67420000), SPH_C32(0xe1170000), + SPH_C32(0x370b0000), SPH_C32(0xcba30034), SPH_C32(0x3c34923c), + SPH_C32(0x9767bdcc), SPH_C32(0x450360bf), SPH_C32(0x774400f0), + SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), SPH_C32(0x34140000), + SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), SPH_C32(0x0bc3cd1e), + SPH_C32(0xcf3775cb) }, + { SPH_C32(0x745d00a9), SPH_C32(0xa87ec000), SPH_C32(0x22c10000), + SPH_C32(0x33990000), SPH_C32(0xc936199d), SPH_C32(0xc4dca486), + SPH_C32(0xede04c82), SPH_C32(0xdb15f8a5), SPH_C32(0xa32e00f0), + SPH_C32(0x7c92c000), SPH_C32(0x501d0000), SPH_C32(0x7e3d0000), + SPH_C32(0x75793cf6), SPH_C32(0x933f6a49), SPH_C32(0x93f55b1a), + SPH_C32(0x3871b6eb) }, + { SPH_C32(0x574200a0), SPH_C32(0xea8ac000), SPH_C32(0x44b80000), + SPH_C32(0x7d220000), SPH_C32(0x37ed424e), SPH_C32(0xf5801450), + SPH_C32(0x0f512bc8), SPH_C32(0xb245a39f), SPH_C32(0x545b00f9), + SPH_C32(0xb3ae0000), SPH_C32(0x93cb0000), SPH_C32(0x7aaf0000), + SPH_C32(0x77ec255f), SPH_C32(0x6bd75cf3), SPH_C32(0xe972aa54), + SPH_C32(0xa6672ef1) }, + { SPH_C32(0xa03700a9), SPH_C32(0x25b60000), SPH_C32(0x876e0000), + SPH_C32(0x79b00000), SPH_C32(0x35785be7), SPH_C32(0x0d6822ea), + SPH_C32(0x75d6da86), SPH_C32(0x2c533b85), SPH_C32(0x803100f9), + SPH_C32(0x3e66c000), SPH_C32(0x36640000), SPH_C32(0x30860000), + SPH_C32(0x8ba26725), SPH_C32(0xa263da9f), SPH_C32(0x71443c50), + SPH_C32(0x5121edd1) }, + { SPH_C32(0xe8870170), SPH_C32(0x9d720000), SPH_C32(0x12db0000), + SPH_C32(0xd4220000), SPH_C32(0xf2886b27), SPH_C32(0xa921e543), + SPH_C32(0x4ef8b518), SPH_C32(0x618813b1), SPH_C32(0xb4370060), + SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), SPH_C32(0x5cae0000), + SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), SPH_C32(0x1b365f3d), + SPH_C32(0xf3d45758) }, + { SPH_C32(0x1ff20179), SPH_C32(0x524ec000), SPH_C32(0xd10d0000), + SPH_C32(0xd0b00000), SPH_C32(0xf01d728e), SPH_C32(0x51c9d3f9), + SPH_C32(0x347f4456), SPH_C32(0xff9e8bab), SPH_C32(0x605d0060), + SPH_C32(0x8184c000), SPH_C32(0xf36d0000), SPH_C32(0x16870000), + SPH_C32(0x681a5d45), SPH_C32(0xf28a7e49), SPH_C32(0x8300c939), + SPH_C32(0x04929478) }, + { SPH_C32(0x3ced0170), SPH_C32(0x10bac000), SPH_C32(0xb7740000), + SPH_C32(0x9e0b0000), SPH_C32(0x0ec6295d), SPH_C32(0x6095632f), + SPH_C32(0xd6ce231c), SPH_C32(0x96ced091), SPH_C32(0x97280069), + SPH_C32(0x4eb80000), SPH_C32(0x30bb0000), SPH_C32(0x12150000), + SPH_C32(0x6a8f44ec), SPH_C32(0x0a6248f3), SPH_C32(0xf9873877), + SPH_C32(0x9a840c62) }, + { SPH_C32(0xcb980179), SPH_C32(0xdf860000), SPH_C32(0x74a20000), + SPH_C32(0x9a990000), SPH_C32(0x0c5330f4), SPH_C32(0x987d5595), + SPH_C32(0xac49d252), SPH_C32(0x08d8488b), SPH_C32(0x43420069), + SPH_C32(0xc370c000), SPH_C32(0x95140000), SPH_C32(0x583c0000), + SPH_C32(0x96c10696), SPH_C32(0xc3d6ce9f), SPH_C32(0x61b1ae73), + SPH_C32(0x6dc2cf42) }, + { SPH_C32(0x9fc30180), SPH_C32(0x6c280000), SPH_C32(0xe7690000), + SPH_C32(0xe0360000), SPH_C32(0x7bbf15ab), SPH_C32(0xf3aa0966), + SPH_C32(0x453b7806), SPH_C32(0xaebf667a), SPH_C32(0x405b0030), + SPH_C32(0x9a540000), SPH_C32(0x42670000), SPH_C32(0x5fb10000), + SPH_C32(0xd6c06187), SPH_C32(0x5d81863c), SPH_C32(0x87922fef), + SPH_C32(0x79e0422c) }, + { SPH_C32(0x68b60189), SPH_C32(0xa314c000), SPH_C32(0x24bf0000), + SPH_C32(0xe4a40000), SPH_C32(0x792a0c02), SPH_C32(0x0b423fdc), + SPH_C32(0x3fbc8948), SPH_C32(0x30a9fe60), SPH_C32(0x94310030), + SPH_C32(0x179cc000), SPH_C32(0xe7c80000), SPH_C32(0x15980000), + SPH_C32(0x2a8e23fd), SPH_C32(0x94350050), SPH_C32(0x1fa4b9eb), + SPH_C32(0x8ea6810c) }, + { SPH_C32(0x4ba90180), SPH_C32(0xe1e0c000), SPH_C32(0x42c60000), + SPH_C32(0xaa1f0000), SPH_C32(0x87f157d1), SPH_C32(0x3a1e8f0a), + SPH_C32(0xdd0dee02), SPH_C32(0x59f9a55a), SPH_C32(0x63440039), + SPH_C32(0xd8a00000), SPH_C32(0x241e0000), SPH_C32(0x110a0000), + SPH_C32(0x281b3a54), SPH_C32(0x6cdd36ea), SPH_C32(0x652348a5), + SPH_C32(0x10b01916) }, + { SPH_C32(0xbcdc0189), SPH_C32(0x2edc0000), SPH_C32(0x81100000), + SPH_C32(0xae8d0000), SPH_C32(0x85644e78), SPH_C32(0xc2f6b9b0), + SPH_C32(0xa78a1f4c), SPH_C32(0xc7ef3d40), SPH_C32(0xb72e0039), + SPH_C32(0x5568c000), SPH_C32(0x81b10000), SPH_C32(0x5b230000), + SPH_C32(0xd455782e), SPH_C32(0xa569b086), SPH_C32(0xfd15dea1), + SPH_C32(0xe7f6da36) }, + { SPH_C32(0x1ceb0120), SPH_C32(0x0b6a0000), SPH_C32(0x067e0000), + SPH_C32(0xd73d0000), SPH_C32(0xb01c159f), SPH_C32(0xcf9e9b5a), + SPH_C32(0xd25cc5ca), SPH_C32(0xebbc06c5), SPH_C32(0x371f00c0), + SPH_C32(0x6b0e0000), SPH_C32(0xb7d50000), SPH_C32(0x6ba50000), + SPH_C32(0x5ff71f0b), SPH_C32(0x070a6a19), SPH_C32(0x8c51e2f1), + SPH_C32(0xb6d737e7) }, + { SPH_C32(0xeb9e0129), SPH_C32(0xc456c000), SPH_C32(0xc5a80000), + SPH_C32(0xd3af0000), SPH_C32(0xb2890c36), SPH_C32(0x3776ade0), + SPH_C32(0xa8db3484), SPH_C32(0x75aa9edf), SPH_C32(0xe37500c0), + SPH_C32(0xe6c6c000), SPH_C32(0x127a0000), SPH_C32(0x218c0000), + SPH_C32(0xa3b95d71), SPH_C32(0xcebeec75), SPH_C32(0x146774f5), + SPH_C32(0x4191f4c7) }, + { SPH_C32(0xc8810120), SPH_C32(0x86a2c000), SPH_C32(0xa3d10000), + SPH_C32(0x9d140000), SPH_C32(0x4c5257e5), SPH_C32(0x062a1d36), + SPH_C32(0x4a6a53ce), SPH_C32(0x1cfac5e5), SPH_C32(0x140000c9), + SPH_C32(0x29fa0000), SPH_C32(0xd1ac0000), SPH_C32(0x251e0000), + SPH_C32(0xa12c44d8), SPH_C32(0x3656dacf), SPH_C32(0x6ee085bb), + SPH_C32(0xdf876cdd) }, + { SPH_C32(0x3ff40129), SPH_C32(0x499e0000), SPH_C32(0x60070000), + SPH_C32(0x99860000), SPH_C32(0x4ec74e4c), SPH_C32(0xfec22b8c), + SPH_C32(0x30eda280), SPH_C32(0x82ec5dff), SPH_C32(0xc06a00c9), + SPH_C32(0xa432c000), SPH_C32(0x74030000), SPH_C32(0x6f370000), + SPH_C32(0x5d6206a2), SPH_C32(0xffe25ca3), SPH_C32(0xf6d613bf), + SPH_C32(0x28c1affd) }, + { SPH_C32(0x6baf01d0), SPH_C32(0xfa300000), SPH_C32(0xf3cc0000), + SPH_C32(0xe3290000), SPH_C32(0x392b6b13), SPH_C32(0x9515777f), + SPH_C32(0xd99f08d4), SPH_C32(0x248b730e), SPH_C32(0xc3730090), + SPH_C32(0xfd160000), SPH_C32(0xa3700000), SPH_C32(0x68ba0000), + SPH_C32(0x1d6361b3), SPH_C32(0x61b51400), SPH_C32(0x10f59223), + SPH_C32(0x3ce32293) }, + { SPH_C32(0x9cda01d9), SPH_C32(0x350cc000), SPH_C32(0x301a0000), + SPH_C32(0xe7bb0000), SPH_C32(0x3bbe72ba), SPH_C32(0x6dfd41c5), + SPH_C32(0xa318f99a), SPH_C32(0xba9deb14), SPH_C32(0x17190090), + SPH_C32(0x70dec000), SPH_C32(0x06df0000), SPH_C32(0x22930000), + SPH_C32(0xe12d23c9), SPH_C32(0xa801926c), SPH_C32(0x88c30427), + SPH_C32(0xcba5e1b3) }, + { SPH_C32(0xbfc501d0), SPH_C32(0x77f8c000), SPH_C32(0x56630000), + SPH_C32(0xa9000000), SPH_C32(0xc5652969), SPH_C32(0x5ca1f113), + SPH_C32(0x41a99ed0), SPH_C32(0xd3cdb02e), SPH_C32(0xe06c0099), + SPH_C32(0xbfe20000), SPH_C32(0xc5090000), SPH_C32(0x26010000), + SPH_C32(0xe3b83a60), SPH_C32(0x50e9a4d6), SPH_C32(0xf244f569), + SPH_C32(0x55b379a9) }, + { SPH_C32(0x48b001d9), SPH_C32(0xb8c40000), SPH_C32(0x95b50000), + SPH_C32(0xad920000), SPH_C32(0xc7f030c0), SPH_C32(0xa449c7a9), + SPH_C32(0x3b2e6f9e), SPH_C32(0x4ddb2834), SPH_C32(0x34060099), + SPH_C32(0x322ac000), SPH_C32(0x60a60000), SPH_C32(0x6c280000), + SPH_C32(0x1ff6781a), SPH_C32(0x995d22ba), SPH_C32(0x6a72636d), + SPH_C32(0xa2f5ba89) }, + { SPH_C32(0xb4370060), SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), + SPH_C32(0x5cae0000), SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), + SPH_C32(0x1b365f3d), SPH_C32(0xf3d45758), SPH_C32(0x5cb00110), + SPH_C32(0x913e0000), SPH_C32(0x44190000), SPH_C32(0x888c0000), + SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), SPH_C32(0x55ceea25), + SPH_C32(0x925c44e9) }, + { SPH_C32(0x43420069), SPH_C32(0xc370c000), SPH_C32(0x95140000), + SPH_C32(0x583c0000), SPH_C32(0x96c10696), SPH_C32(0xc3d6ce9f), + SPH_C32(0x61b1ae73), SPH_C32(0x6dc2cf42), SPH_C32(0x88da0110), + SPH_C32(0x1cf6c000), SPH_C32(0xe1b60000), SPH_C32(0xc2a50000), + SPH_C32(0x9a923662), SPH_C32(0x5bab9b0a), SPH_C32(0xcdf87c21), + SPH_C32(0x651a87c9) }, + { SPH_C32(0x605d0060), SPH_C32(0x8184c000), SPH_C32(0xf36d0000), + SPH_C32(0x16870000), SPH_C32(0x681a5d45), SPH_C32(0xf28a7e49), + SPH_C32(0x8300c939), SPH_C32(0x04929478), SPH_C32(0x7faf0119), + SPH_C32(0xd3ca0000), SPH_C32(0x22600000), SPH_C32(0xc6370000), + SPH_C32(0x98072fcb), SPH_C32(0xa343adb0), SPH_C32(0xb77f8d6f), + SPH_C32(0xfb0c1fd3) }, + { SPH_C32(0x97280069), SPH_C32(0x4eb80000), SPH_C32(0x30bb0000), + SPH_C32(0x12150000), SPH_C32(0x6a8f44ec), SPH_C32(0x0a6248f3), + SPH_C32(0xf9873877), SPH_C32(0x9a840c62), SPH_C32(0xabc50119), + SPH_C32(0x5e02c000), SPH_C32(0x87cf0000), SPH_C32(0x8c1e0000), + SPH_C32(0x64496db1), SPH_C32(0x6af72bdc), SPH_C32(0x2f491b6b), + SPH_C32(0x0c4adcf3) }, + { SPH_C32(0xc3730090), SPH_C32(0xfd160000), SPH_C32(0xa3700000), + SPH_C32(0x68ba0000), SPH_C32(0x1d6361b3), SPH_C32(0x61b51400), + SPH_C32(0x10f59223), SPH_C32(0x3ce32293), SPH_C32(0xa8dc0140), + SPH_C32(0x07260000), SPH_C32(0x50bc0000), SPH_C32(0x8b930000), + SPH_C32(0x24480aa0), SPH_C32(0xf4a0637f), SPH_C32(0xc96a9af7), + SPH_C32(0x1868519d) }, + { SPH_C32(0x34060099), SPH_C32(0x322ac000), SPH_C32(0x60a60000), + SPH_C32(0x6c280000), SPH_C32(0x1ff6781a), SPH_C32(0x995d22ba), + SPH_C32(0x6a72636d), SPH_C32(0xa2f5ba89), SPH_C32(0x7cb60140), + SPH_C32(0x8aeec000), SPH_C32(0xf5130000), SPH_C32(0xc1ba0000), + SPH_C32(0xd80648da), SPH_C32(0x3d14e513), SPH_C32(0x515c0cf3), + SPH_C32(0xef2e92bd) }, + { SPH_C32(0x17190090), SPH_C32(0x70dec000), SPH_C32(0x06df0000), + SPH_C32(0x22930000), SPH_C32(0xe12d23c9), SPH_C32(0xa801926c), + SPH_C32(0x88c30427), SPH_C32(0xcba5e1b3), SPH_C32(0x8bc30149), + SPH_C32(0x45d20000), SPH_C32(0x36c50000), SPH_C32(0xc5280000), + SPH_C32(0xda935173), SPH_C32(0xc5fcd3a9), SPH_C32(0x2bdbfdbd), + SPH_C32(0x71380aa7) }, + { SPH_C32(0xe06c0099), SPH_C32(0xbfe20000), SPH_C32(0xc5090000), + SPH_C32(0x26010000), SPH_C32(0xe3b83a60), SPH_C32(0x50e9a4d6), + SPH_C32(0xf244f569), SPH_C32(0x55b379a9), SPH_C32(0x5fa90149), + SPH_C32(0xc81ac000), SPH_C32(0x936a0000), SPH_C32(0x8f010000), + SPH_C32(0x26dd1309), SPH_C32(0x0c4855c5), SPH_C32(0xb3ed6bb9), + SPH_C32(0x867ec987) }, + { SPH_C32(0x405b0030), SPH_C32(0x9a540000), SPH_C32(0x42670000), + SPH_C32(0x5fb10000), SPH_C32(0xd6c06187), SPH_C32(0x5d81863c), + SPH_C32(0x87922fef), SPH_C32(0x79e0422c), SPH_C32(0xdf9801b0), + SPH_C32(0xf67c0000), SPH_C32(0xa50e0000), SPH_C32(0xbf870000), + SPH_C32(0xad7f742c), SPH_C32(0xae2b8f5a), SPH_C32(0xc2a957e9), + SPH_C32(0xd75f2456) }, + { SPH_C32(0xb72e0039), SPH_C32(0x5568c000), SPH_C32(0x81b10000), + SPH_C32(0x5b230000), SPH_C32(0xd455782e), SPH_C32(0xa569b086), + SPH_C32(0xfd15dea1), SPH_C32(0xe7f6da36), SPH_C32(0x0bf201b0), + SPH_C32(0x7bb4c000), SPH_C32(0x00a10000), SPH_C32(0xf5ae0000), + SPH_C32(0x51313656), SPH_C32(0x679f0936), SPH_C32(0x5a9fc1ed), + SPH_C32(0x2019e776) }, + { SPH_C32(0x94310030), SPH_C32(0x179cc000), SPH_C32(0xe7c80000), + SPH_C32(0x15980000), SPH_C32(0x2a8e23fd), SPH_C32(0x94350050), + SPH_C32(0x1fa4b9eb), SPH_C32(0x8ea6810c), SPH_C32(0xfc8701b9), + SPH_C32(0xb4880000), SPH_C32(0xc3770000), SPH_C32(0xf13c0000), + SPH_C32(0x53a42fff), SPH_C32(0x9f773f8c), SPH_C32(0x201830a3), + SPH_C32(0xbe0f7f6c) }, + { SPH_C32(0x63440039), SPH_C32(0xd8a00000), SPH_C32(0x241e0000), + SPH_C32(0x110a0000), SPH_C32(0x281b3a54), SPH_C32(0x6cdd36ea), + SPH_C32(0x652348a5), SPH_C32(0x10b01916), SPH_C32(0x28ed01b9), + SPH_C32(0x3940c000), SPH_C32(0x66d80000), SPH_C32(0xbb150000), + SPH_C32(0xafea6d85), SPH_C32(0x56c3b9e0), SPH_C32(0xb82ea6a7), + SPH_C32(0x4949bc4c) }, + { SPH_C32(0x371f00c0), SPH_C32(0x6b0e0000), SPH_C32(0xb7d50000), + SPH_C32(0x6ba50000), SPH_C32(0x5ff71f0b), SPH_C32(0x070a6a19), + SPH_C32(0x8c51e2f1), SPH_C32(0xb6d737e7), SPH_C32(0x2bf401e0), + SPH_C32(0x60640000), SPH_C32(0xb1ab0000), SPH_C32(0xbc980000), + SPH_C32(0xefeb0a94), SPH_C32(0xc894f143), SPH_C32(0x5e0d273b), + SPH_C32(0x5d6b3122) }, + { SPH_C32(0xc06a00c9), SPH_C32(0xa432c000), SPH_C32(0x74030000), + SPH_C32(0x6f370000), SPH_C32(0x5d6206a2), SPH_C32(0xffe25ca3), + SPH_C32(0xf6d613bf), SPH_C32(0x28c1affd), SPH_C32(0xff9e01e0), + SPH_C32(0xedacc000), SPH_C32(0x14040000), SPH_C32(0xf6b10000), + SPH_C32(0x13a548ee), SPH_C32(0x0120772f), SPH_C32(0xc63bb13f), + SPH_C32(0xaa2df202) }, + { SPH_C32(0xe37500c0), SPH_C32(0xe6c6c000), SPH_C32(0x127a0000), + SPH_C32(0x218c0000), SPH_C32(0xa3b95d71), SPH_C32(0xcebeec75), + SPH_C32(0x146774f5), SPH_C32(0x4191f4c7), SPH_C32(0x08eb01e9), + SPH_C32(0x22900000), SPH_C32(0xd7d20000), SPH_C32(0xf2230000), + SPH_C32(0x11305147), SPH_C32(0xf9c84195), SPH_C32(0xbcbc4071), + SPH_C32(0x343b6a18) }, + { SPH_C32(0x140000c9), SPH_C32(0x29fa0000), SPH_C32(0xd1ac0000), + SPH_C32(0x251e0000), SPH_C32(0xa12c44d8), SPH_C32(0x3656dacf), + SPH_C32(0x6ee085bb), SPH_C32(0xdf876cdd), SPH_C32(0xdc8101e9), + SPH_C32(0xaf58c000), SPH_C32(0x727d0000), SPH_C32(0xb80a0000), + SPH_C32(0xed7e133d), SPH_C32(0x307cc7f9), SPH_C32(0x248ad675), + SPH_C32(0xc37da938) }, + { SPH_C32(0x5cb00110), SPH_C32(0x913e0000), SPH_C32(0x44190000), + SPH_C32(0x888c0000), SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), + SPH_C32(0x55ceea25), SPH_C32(0x925c44e9), SPH_C32(0xe8870170), + SPH_C32(0x9d720000), SPH_C32(0x12db0000), SPH_C32(0xd4220000), + SPH_C32(0xf2886b27), SPH_C32(0xa921e543), SPH_C32(0x4ef8b518), + SPH_C32(0x618813b1) }, + { SPH_C32(0xabc50119), SPH_C32(0x5e02c000), SPH_C32(0x87cf0000), + SPH_C32(0x8c1e0000), SPH_C32(0x64496db1), SPH_C32(0x6af72bdc), + SPH_C32(0x2f491b6b), SPH_C32(0x0c4adcf3), SPH_C32(0x3ced0170), + SPH_C32(0x10bac000), SPH_C32(0xb7740000), SPH_C32(0x9e0b0000), + SPH_C32(0x0ec6295d), SPH_C32(0x6095632f), SPH_C32(0xd6ce231c), + SPH_C32(0x96ced091) }, + { SPH_C32(0x88da0110), SPH_C32(0x1cf6c000), SPH_C32(0xe1b60000), + SPH_C32(0xc2a50000), SPH_C32(0x9a923662), SPH_C32(0x5bab9b0a), + SPH_C32(0xcdf87c21), SPH_C32(0x651a87c9), SPH_C32(0xcb980179), + SPH_C32(0xdf860000), SPH_C32(0x74a20000), SPH_C32(0x9a990000), + SPH_C32(0x0c5330f4), SPH_C32(0x987d5595), SPH_C32(0xac49d252), + SPH_C32(0x08d8488b) }, + { SPH_C32(0x7faf0119), SPH_C32(0xd3ca0000), SPH_C32(0x22600000), + SPH_C32(0xc6370000), SPH_C32(0x98072fcb), SPH_C32(0xa343adb0), + SPH_C32(0xb77f8d6f), SPH_C32(0xfb0c1fd3), SPH_C32(0x1ff20179), + SPH_C32(0x524ec000), SPH_C32(0xd10d0000), SPH_C32(0xd0b00000), + SPH_C32(0xf01d728e), SPH_C32(0x51c9d3f9), SPH_C32(0x347f4456), + SPH_C32(0xff9e8bab) }, + { SPH_C32(0x2bf401e0), SPH_C32(0x60640000), SPH_C32(0xb1ab0000), + SPH_C32(0xbc980000), SPH_C32(0xefeb0a94), SPH_C32(0xc894f143), + SPH_C32(0x5e0d273b), SPH_C32(0x5d6b3122), SPH_C32(0x1ceb0120), + SPH_C32(0x0b6a0000), SPH_C32(0x067e0000), SPH_C32(0xd73d0000), + SPH_C32(0xb01c159f), SPH_C32(0xcf9e9b5a), SPH_C32(0xd25cc5ca), + SPH_C32(0xebbc06c5) }, + { SPH_C32(0xdc8101e9), SPH_C32(0xaf58c000), SPH_C32(0x727d0000), + SPH_C32(0xb80a0000), SPH_C32(0xed7e133d), SPH_C32(0x307cc7f9), + SPH_C32(0x248ad675), SPH_C32(0xc37da938), SPH_C32(0xc8810120), + SPH_C32(0x86a2c000), SPH_C32(0xa3d10000), SPH_C32(0x9d140000), + SPH_C32(0x4c5257e5), SPH_C32(0x062a1d36), SPH_C32(0x4a6a53ce), + SPH_C32(0x1cfac5e5) }, + { SPH_C32(0xff9e01e0), SPH_C32(0xedacc000), SPH_C32(0x14040000), + SPH_C32(0xf6b10000), SPH_C32(0x13a548ee), SPH_C32(0x0120772f), + SPH_C32(0xc63bb13f), SPH_C32(0xaa2df202), SPH_C32(0x3ff40129), + SPH_C32(0x499e0000), SPH_C32(0x60070000), SPH_C32(0x99860000), + SPH_C32(0x4ec74e4c), SPH_C32(0xfec22b8c), SPH_C32(0x30eda280), + SPH_C32(0x82ec5dff) }, + { SPH_C32(0x08eb01e9), SPH_C32(0x22900000), SPH_C32(0xd7d20000), + SPH_C32(0xf2230000), SPH_C32(0x11305147), SPH_C32(0xf9c84195), + SPH_C32(0xbcbc4071), SPH_C32(0x343b6a18), SPH_C32(0xeb9e0129), + SPH_C32(0xc456c000), SPH_C32(0xc5a80000), SPH_C32(0xd3af0000), + SPH_C32(0xb2890c36), SPH_C32(0x3776ade0), SPH_C32(0xa8db3484), + SPH_C32(0x75aa9edf) }, + { SPH_C32(0xa8dc0140), SPH_C32(0x07260000), SPH_C32(0x50bc0000), + SPH_C32(0x8b930000), SPH_C32(0x24480aa0), SPH_C32(0xf4a0637f), + SPH_C32(0xc96a9af7), SPH_C32(0x1868519d), SPH_C32(0x6baf01d0), + SPH_C32(0xfa300000), SPH_C32(0xf3cc0000), SPH_C32(0xe3290000), + SPH_C32(0x392b6b13), SPH_C32(0x9515777f), SPH_C32(0xd99f08d4), + SPH_C32(0x248b730e) }, + { SPH_C32(0x5fa90149), SPH_C32(0xc81ac000), SPH_C32(0x936a0000), + SPH_C32(0x8f010000), SPH_C32(0x26dd1309), SPH_C32(0x0c4855c5), + SPH_C32(0xb3ed6bb9), SPH_C32(0x867ec987), SPH_C32(0xbfc501d0), + SPH_C32(0x77f8c000), SPH_C32(0x56630000), SPH_C32(0xa9000000), + SPH_C32(0xc5652969), SPH_C32(0x5ca1f113), SPH_C32(0x41a99ed0), + SPH_C32(0xd3cdb02e) }, + { SPH_C32(0x7cb60140), SPH_C32(0x8aeec000), SPH_C32(0xf5130000), + SPH_C32(0xc1ba0000), SPH_C32(0xd80648da), SPH_C32(0x3d14e513), + SPH_C32(0x515c0cf3), SPH_C32(0xef2e92bd), SPH_C32(0x48b001d9), + SPH_C32(0xb8c40000), SPH_C32(0x95b50000), SPH_C32(0xad920000), + SPH_C32(0xc7f030c0), SPH_C32(0xa449c7a9), SPH_C32(0x3b2e6f9e), + SPH_C32(0x4ddb2834) }, + { SPH_C32(0x8bc30149), SPH_C32(0x45d20000), SPH_C32(0x36c50000), + SPH_C32(0xc5280000), SPH_C32(0xda935173), SPH_C32(0xc5fcd3a9), + SPH_C32(0x2bdbfdbd), SPH_C32(0x71380aa7), SPH_C32(0x9cda01d9), + SPH_C32(0x350cc000), SPH_C32(0x301a0000), SPH_C32(0xe7bb0000), + SPH_C32(0x3bbe72ba), SPH_C32(0x6dfd41c5), SPH_C32(0xa318f99a), + SPH_C32(0xba9deb14) }, + { SPH_C32(0xdf9801b0), SPH_C32(0xf67c0000), SPH_C32(0xa50e0000), + SPH_C32(0xbf870000), SPH_C32(0xad7f742c), SPH_C32(0xae2b8f5a), + SPH_C32(0xc2a957e9), SPH_C32(0xd75f2456), SPH_C32(0x9fc30180), + SPH_C32(0x6c280000), SPH_C32(0xe7690000), SPH_C32(0xe0360000), + SPH_C32(0x7bbf15ab), SPH_C32(0xf3aa0966), SPH_C32(0x453b7806), + SPH_C32(0xaebf667a) }, + { SPH_C32(0x28ed01b9), SPH_C32(0x3940c000), SPH_C32(0x66d80000), + SPH_C32(0xbb150000), SPH_C32(0xafea6d85), SPH_C32(0x56c3b9e0), + SPH_C32(0xb82ea6a7), SPH_C32(0x4949bc4c), SPH_C32(0x4ba90180), + SPH_C32(0xe1e0c000), SPH_C32(0x42c60000), SPH_C32(0xaa1f0000), + SPH_C32(0x87f157d1), SPH_C32(0x3a1e8f0a), SPH_C32(0xdd0dee02), + SPH_C32(0x59f9a55a) }, + { SPH_C32(0x0bf201b0), SPH_C32(0x7bb4c000), SPH_C32(0x00a10000), + SPH_C32(0xf5ae0000), SPH_C32(0x51313656), SPH_C32(0x679f0936), + SPH_C32(0x5a9fc1ed), SPH_C32(0x2019e776), SPH_C32(0xbcdc0189), + SPH_C32(0x2edc0000), SPH_C32(0x81100000), SPH_C32(0xae8d0000), + SPH_C32(0x85644e78), SPH_C32(0xc2f6b9b0), SPH_C32(0xa78a1f4c), + SPH_C32(0xc7ef3d40) }, + { SPH_C32(0xfc8701b9), SPH_C32(0xb4880000), SPH_C32(0xc3770000), + SPH_C32(0xf13c0000), SPH_C32(0x53a42fff), SPH_C32(0x9f773f8c), + SPH_C32(0x201830a3), SPH_C32(0xbe0f7f6c), SPH_C32(0x68b60189), + SPH_C32(0xa314c000), SPH_C32(0x24bf0000), SPH_C32(0xe4a40000), + SPH_C32(0x792a0c02), SPH_C32(0x0b423fdc), SPH_C32(0x3fbc8948), + SPH_C32(0x30a9fe60) }, + { SPH_C32(0xef0b0270), SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), + SPH_C32(0x69490000), SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), + SPH_C32(0x66140a51), SPH_C32(0x924f5d0a), SPH_C32(0xc96b0030), + SPH_C32(0xe7250000), SPH_C32(0x2f840000), SPH_C32(0x264f0000), + SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), SPH_C32(0x509f6984), + SPH_C32(0x9e69af68) }, + { SPH_C32(0x187e0279), SPH_C32(0xf5c1c000), SPH_C32(0x9e780000), + SPH_C32(0x6ddb0000), SPH_C32(0x999a25af), SPH_C32(0xbced8343), + SPH_C32(0x1c93fb1f), SPH_C32(0x0c59c510), SPH_C32(0x1d010030), + SPH_C32(0x6aedc000), SPH_C32(0x8a2b0000), SPH_C32(0x6c660000), + SPH_C32(0xf4271983), SPH_C32(0xa448775b), SPH_C32(0xc8a9ff80), + SPH_C32(0x692f6c48) }, + { SPH_C32(0x3b610270), SPH_C32(0xb735c000), SPH_C32(0xf8010000), + SPH_C32(0x23600000), SPH_C32(0x67417e7c), SPH_C32(0x8db13395), + SPH_C32(0xfe229c55), SPH_C32(0x65099e2a), SPH_C32(0xea740039), + SPH_C32(0xa5d10000), SPH_C32(0x49fd0000), SPH_C32(0x68f40000), + SPH_C32(0xf6b2002a), SPH_C32(0x5ca041e1), SPH_C32(0xb22e0ece), + SPH_C32(0xf739f452) }, + { SPH_C32(0xcc140279), SPH_C32(0x78090000), SPH_C32(0x3bd70000), + SPH_C32(0x27f20000), SPH_C32(0x65d467d5), SPH_C32(0x7559052f), + SPH_C32(0x84a56d1b), SPH_C32(0xfb1f0630), SPH_C32(0x3e1e0039), + SPH_C32(0x2819c000), SPH_C32(0xec520000), SPH_C32(0x22dd0000), + SPH_C32(0x0afc4250), SPH_C32(0x9514c78d), SPH_C32(0x2a1898ca), + SPH_C32(0x007f3772) }, + { SPH_C32(0x984f0280), SPH_C32(0xcba70000), SPH_C32(0xa81c0000), + SPH_C32(0x5d5d0000), SPH_C32(0x1238428a), SPH_C32(0x1e8e59dc), + SPH_C32(0x6dd7c74f), SPH_C32(0x5d7828c1), SPH_C32(0x3d070060), + SPH_C32(0x713d0000), SPH_C32(0x3b210000), SPH_C32(0x25500000), + SPH_C32(0x4afd2541), SPH_C32(0x0b438f2e), SPH_C32(0xcc3b1956), + SPH_C32(0x145dba1c) }, + { SPH_C32(0x6f3a0289), SPH_C32(0x049bc000), SPH_C32(0x6bca0000), + SPH_C32(0x59cf0000), SPH_C32(0x10ad5b23), SPH_C32(0xe6666f66), + SPH_C32(0x17503601), SPH_C32(0xc36eb0db), SPH_C32(0xe96d0060), + SPH_C32(0xfcf5c000), SPH_C32(0x9e8e0000), SPH_C32(0x6f790000), + SPH_C32(0xb6b3673b), SPH_C32(0xc2f70942), SPH_C32(0x540d8f52), + SPH_C32(0xe31b793c) }, + { SPH_C32(0x4c250280), SPH_C32(0x466fc000), SPH_C32(0x0db30000), + SPH_C32(0x17740000), SPH_C32(0xee7600f0), SPH_C32(0xd73adfb0), + SPH_C32(0xf5e1514b), SPH_C32(0xaa3eebe1), SPH_C32(0x1e180069), + SPH_C32(0x33c90000), SPH_C32(0x5d580000), SPH_C32(0x6beb0000), + SPH_C32(0xb4267e92), SPH_C32(0x3a1f3ff8), SPH_C32(0x2e8a7e1c), + SPH_C32(0x7d0de126) }, + { SPH_C32(0xbb500289), SPH_C32(0x89530000), SPH_C32(0xce650000), + SPH_C32(0x13e60000), SPH_C32(0xece31959), SPH_C32(0x2fd2e90a), + SPH_C32(0x8f66a005), SPH_C32(0x342873fb), SPH_C32(0xca720069), + SPH_C32(0xbe01c000), SPH_C32(0xf8f70000), SPH_C32(0x21c20000), + SPH_C32(0x48683ce8), SPH_C32(0xf3abb994), SPH_C32(0xb6bce818), + SPH_C32(0x8a4b2206) }, + { SPH_C32(0x1b670220), SPH_C32(0xace50000), SPH_C32(0x490b0000), + SPH_C32(0x6a560000), SPH_C32(0xd99b42be), SPH_C32(0x22bacbe0), + SPH_C32(0xfab07a83), SPH_C32(0x187b487e), SPH_C32(0x4a430090), + SPH_C32(0x80670000), SPH_C32(0xce930000), SPH_C32(0x11440000), + SPH_C32(0xc3ca5bcd), SPH_C32(0x51c8630b), SPH_C32(0xc7f8d448), + SPH_C32(0xdb6acfd7) }, + { SPH_C32(0xec120229), SPH_C32(0x63d9c000), SPH_C32(0x8add0000), + SPH_C32(0x6ec40000), SPH_C32(0xdb0e5b17), SPH_C32(0xda52fd5a), + SPH_C32(0x80378bcd), SPH_C32(0x866dd064), SPH_C32(0x9e290090), + SPH_C32(0x0dafc000), SPH_C32(0x6b3c0000), SPH_C32(0x5b6d0000), + SPH_C32(0x3f8419b7), SPH_C32(0x987ce567), SPH_C32(0x5fce424c), + SPH_C32(0x2c2c0cf7) }, + { SPH_C32(0xcf0d0220), SPH_C32(0x212dc000), SPH_C32(0xeca40000), + SPH_C32(0x207f0000), SPH_C32(0x25d500c4), SPH_C32(0xeb0e4d8c), + SPH_C32(0x6286ec87), SPH_C32(0xef3d8b5e), SPH_C32(0x695c0099), + SPH_C32(0xc2930000), SPH_C32(0xa8ea0000), SPH_C32(0x5fff0000), + SPH_C32(0x3d11001e), SPH_C32(0x6094d3dd), SPH_C32(0x2549b302), + SPH_C32(0xb23a94ed) }, + { SPH_C32(0x38780229), SPH_C32(0xee110000), SPH_C32(0x2f720000), + SPH_C32(0x24ed0000), SPH_C32(0x2740196d), SPH_C32(0x13e67b36), + SPH_C32(0x18011dc9), SPH_C32(0x712b1344), SPH_C32(0xbd360099), + SPH_C32(0x4f5bc000), SPH_C32(0x0d450000), SPH_C32(0x15d60000), + SPH_C32(0xc15f4264), SPH_C32(0xa92055b1), SPH_C32(0xbd7f2506), + SPH_C32(0x457c57cd) }, + { SPH_C32(0x6c2302d0), SPH_C32(0x5dbf0000), SPH_C32(0xbcb90000), + SPH_C32(0x5e420000), SPH_C32(0x50ac3c32), SPH_C32(0x783127c5), + SPH_C32(0xf173b79d), SPH_C32(0xd74c3db5), SPH_C32(0xbe2f00c0), + SPH_C32(0x167f0000), SPH_C32(0xda360000), SPH_C32(0x125b0000), + SPH_C32(0x815e2575), SPH_C32(0x37771d12), SPH_C32(0x5b5ca49a), + SPH_C32(0x515edaa3) }, + { SPH_C32(0x9b5602d9), SPH_C32(0x9283c000), SPH_C32(0x7f6f0000), + SPH_C32(0x5ad00000), SPH_C32(0x5239259b), SPH_C32(0x80d9117f), + SPH_C32(0x8bf446d3), SPH_C32(0x495aa5af), SPH_C32(0x6a4500c0), + SPH_C32(0x9bb7c000), SPH_C32(0x7f990000), SPH_C32(0x58720000), + SPH_C32(0x7d10670f), SPH_C32(0xfec39b7e), SPH_C32(0xc36a329e), + SPH_C32(0xa6181983) }, + { SPH_C32(0xb84902d0), SPH_C32(0xd077c000), SPH_C32(0x19160000), + SPH_C32(0x146b0000), SPH_C32(0xace27e48), SPH_C32(0xb185a1a9), + SPH_C32(0x69452199), SPH_C32(0x200afe95), SPH_C32(0x9d3000c9), + SPH_C32(0x548b0000), SPH_C32(0xbc4f0000), SPH_C32(0x5ce00000), + SPH_C32(0x7f857ea6), SPH_C32(0x062badc4), SPH_C32(0xb9edc3d0), + SPH_C32(0x380e8199) }, + { SPH_C32(0x4f3c02d9), SPH_C32(0x1f4b0000), SPH_C32(0xdac00000), + SPH_C32(0x10f90000), SPH_C32(0xae7767e1), SPH_C32(0x496d9713), + SPH_C32(0x13c2d0d7), SPH_C32(0xbe1c668f), SPH_C32(0x495a00c9), + SPH_C32(0xd943c000), SPH_C32(0x19e00000), SPH_C32(0x16c90000), + SPH_C32(0x83cb3cdc), SPH_C32(0xcf9f2ba8), SPH_C32(0x21db55d4), + SPH_C32(0xcf4842b9) }, + { SPH_C32(0x078c0300), SPH_C32(0xa78f0000), SPH_C32(0x4f750000), + SPH_C32(0xbd6b0000), SPH_C32(0x69875721), SPH_C32(0xed2450ba), + SPH_C32(0x28ecbf49), SPH_C32(0xf3c74ebb), SPH_C32(0x7d5c0050), + SPH_C32(0xeb690000), SPH_C32(0x79460000), SPH_C32(0x7ae10000), + SPH_C32(0x9c3d44c6), SPH_C32(0x56c20912), SPH_C32(0x4ba936b9), + SPH_C32(0x6dbdf830) }, + { SPH_C32(0xf0f90309), SPH_C32(0x68b3c000), SPH_C32(0x8ca30000), + SPH_C32(0xb9f90000), SPH_C32(0x6b124e88), SPH_C32(0x15cc6600), + SPH_C32(0x526b4e07), SPH_C32(0x6dd1d6a1), SPH_C32(0xa9360050), + SPH_C32(0x66a1c000), SPH_C32(0xdce90000), SPH_C32(0x30c80000), + SPH_C32(0x607306bc), SPH_C32(0x9f768f7e), SPH_C32(0xd39fa0bd), + SPH_C32(0x9afb3b10) }, + { SPH_C32(0xd3e60300), SPH_C32(0x2a47c000), SPH_C32(0xeada0000), + SPH_C32(0xf7420000), SPH_C32(0x95c9155b), SPH_C32(0x2490d6d6), + SPH_C32(0xb0da294d), SPH_C32(0x04818d9b), SPH_C32(0x5e430059), + SPH_C32(0xa99d0000), SPH_C32(0x1f3f0000), SPH_C32(0x345a0000), + SPH_C32(0x62e61f15), SPH_C32(0x679eb9c4), SPH_C32(0xa91851f3), + SPH_C32(0x04eda30a) }, + { SPH_C32(0x24930309), SPH_C32(0xe57b0000), SPH_C32(0x290c0000), + SPH_C32(0xf3d00000), SPH_C32(0x975c0cf2), SPH_C32(0xdc78e06c), + SPH_C32(0xca5dd803), SPH_C32(0x9a971581), SPH_C32(0x8a290059), + SPH_C32(0x2455c000), SPH_C32(0xba900000), SPH_C32(0x7e730000), + SPH_C32(0x9ea85d6f), SPH_C32(0xae2a3fa8), SPH_C32(0x312ec7f7), + SPH_C32(0xf3ab602a) }, + { SPH_C32(0x70c803f0), SPH_C32(0x56d50000), SPH_C32(0xbac70000), + SPH_C32(0x897f0000), SPH_C32(0xe0b029ad), SPH_C32(0xb7afbc9f), + SPH_C32(0x232f7257), SPH_C32(0x3cf03b70), SPH_C32(0x89300000), + SPH_C32(0x7d710000), SPH_C32(0x6de30000), SPH_C32(0x79fe0000), + SPH_C32(0xdea93a7e), SPH_C32(0x307d770b), SPH_C32(0xd70d466b), + SPH_C32(0xe789ed44) }, + { SPH_C32(0x87bd03f9), SPH_C32(0x99e9c000), SPH_C32(0x79110000), + SPH_C32(0x8ded0000), SPH_C32(0xe2253004), SPH_C32(0x4f478a25), + SPH_C32(0x59a88319), SPH_C32(0xa2e6a36a), SPH_C32(0x5d5a0000), + SPH_C32(0xf0b9c000), SPH_C32(0xc84c0000), SPH_C32(0x33d70000), + SPH_C32(0x22e77804), SPH_C32(0xf9c9f167), SPH_C32(0x4f3bd06f), + SPH_C32(0x10cf2e64) }, + { SPH_C32(0xa4a203f0), SPH_C32(0xdb1dc000), SPH_C32(0x1f680000), + SPH_C32(0xc3560000), SPH_C32(0x1cfe6bd7), SPH_C32(0x7e1b3af3), + SPH_C32(0xbb19e453), SPH_C32(0xcbb6f850), SPH_C32(0xaa2f0009), + SPH_C32(0x3f850000), SPH_C32(0x0b9a0000), SPH_C32(0x37450000), + SPH_C32(0x207261ad), SPH_C32(0x0121c7dd), SPH_C32(0x35bc2121), + SPH_C32(0x8ed9b67e) }, + { SPH_C32(0x53d703f9), SPH_C32(0x14210000), SPH_C32(0xdcbe0000), + SPH_C32(0xc7c40000), SPH_C32(0x1e6b727e), SPH_C32(0x86f30c49), + SPH_C32(0xc19e151d), SPH_C32(0x55a0604a), SPH_C32(0x7e450009), + SPH_C32(0xb24dc000), SPH_C32(0xae350000), SPH_C32(0x7d6c0000), + SPH_C32(0xdc3c23d7), SPH_C32(0xc89541b1), SPH_C32(0xad8ab725), + SPH_C32(0x799f755e) }, + { SPH_C32(0xf3e00350), SPH_C32(0x31970000), SPH_C32(0x5bd00000), + SPH_C32(0xbe740000), SPH_C32(0x2b132999), SPH_C32(0x8b9b2ea3), + SPH_C32(0xb448cf9b), SPH_C32(0x79f35bcf), SPH_C32(0xfe7400f0), + SPH_C32(0x8c2b0000), SPH_C32(0x98510000), SPH_C32(0x4dea0000), + SPH_C32(0x579e44f2), SPH_C32(0x6af69b2e), SPH_C32(0xdcce8b75), + SPH_C32(0x28be988f) }, + { SPH_C32(0x04950359), SPH_C32(0xfeabc000), SPH_C32(0x98060000), + SPH_C32(0xbae60000), SPH_C32(0x29863030), SPH_C32(0x73731819), + SPH_C32(0xcecf3ed5), SPH_C32(0xe7e5c3d5), SPH_C32(0x2a1e00f0), + SPH_C32(0x01e3c000), SPH_C32(0x3dfe0000), SPH_C32(0x07c30000), + SPH_C32(0xabd00688), SPH_C32(0xa3421d42), SPH_C32(0x44f81d71), + SPH_C32(0xdff85baf) }, + { SPH_C32(0x278a0350), SPH_C32(0xbc5fc000), SPH_C32(0xfe7f0000), + SPH_C32(0xf45d0000), SPH_C32(0xd75d6be3), SPH_C32(0x422fa8cf), + SPH_C32(0x2c7e599f), SPH_C32(0x8eb598ef), SPH_C32(0xdd6b00f9), + SPH_C32(0xcedf0000), SPH_C32(0xfe280000), SPH_C32(0x03510000), + SPH_C32(0xa9451f21), SPH_C32(0x5baa2bf8), SPH_C32(0x3e7fec3f), + SPH_C32(0x41eec3b5) }, + { SPH_C32(0xd0ff0359), SPH_C32(0x73630000), SPH_C32(0x3da90000), + SPH_C32(0xf0cf0000), SPH_C32(0xd5c8724a), SPH_C32(0xbac79e75), + SPH_C32(0x56f9a8d1), SPH_C32(0x10a300f5), SPH_C32(0x090100f9), + SPH_C32(0x4317c000), SPH_C32(0x5b870000), SPH_C32(0x49780000), + SPH_C32(0x550b5d5b), SPH_C32(0x921ead94), SPH_C32(0xa6497a3b), + SPH_C32(0xb6a80095) }, + { SPH_C32(0x84a403a0), SPH_C32(0xc0cd0000), SPH_C32(0xae620000), + SPH_C32(0x8a600000), SPH_C32(0xa2245715), SPH_C32(0xd110c286), + SPH_C32(0xbf8b0285), SPH_C32(0xb6c42e04), SPH_C32(0x0a1800a0), + SPH_C32(0x1a330000), SPH_C32(0x8cf40000), SPH_C32(0x4ef50000), + SPH_C32(0x150a3a4a), SPH_C32(0x0c49e537), SPH_C32(0x406afba7), + SPH_C32(0xa28a8dfb) }, + { SPH_C32(0x73d103a9), SPH_C32(0x0ff1c000), SPH_C32(0x6db40000), + SPH_C32(0x8ef20000), SPH_C32(0xa0b14ebc), SPH_C32(0x29f8f43c), + SPH_C32(0xc50cf3cb), SPH_C32(0x28d2b61e), SPH_C32(0xde7200a0), + SPH_C32(0x97fbc000), SPH_C32(0x295b0000), SPH_C32(0x04dc0000), + SPH_C32(0xe9447830), SPH_C32(0xc5fd635b), SPH_C32(0xd85c6da3), + SPH_C32(0x55cc4edb) }, + { SPH_C32(0x50ce03a0), SPH_C32(0x4d05c000), SPH_C32(0x0bcd0000), + SPH_C32(0xc0490000), SPH_C32(0x5e6a156f), SPH_C32(0x18a444ea), + SPH_C32(0x27bd9481), SPH_C32(0x4182ed24), SPH_C32(0x290700a9), + SPH_C32(0x58c70000), SPH_C32(0xea8d0000), SPH_C32(0x004e0000), + SPH_C32(0xebd16199), SPH_C32(0x3d1555e1), SPH_C32(0xa2db9ced), + SPH_C32(0xcbdad6c1) }, + { SPH_C32(0xa7bb03a9), SPH_C32(0x82390000), SPH_C32(0xc81b0000), + SPH_C32(0xc4db0000), SPH_C32(0x5cff0cc6), SPH_C32(0xe04c7250), + SPH_C32(0x5d3a65cf), SPH_C32(0xdf94753e), SPH_C32(0xfd6d00a9), + SPH_C32(0xd50fc000), SPH_C32(0x4f220000), SPH_C32(0x4a670000), + SPH_C32(0x179f23e3), SPH_C32(0xf4a1d38d), SPH_C32(0x3aed0ae9), + SPH_C32(0x3c9c15e1) }, + { SPH_C32(0x5b3c0210), SPH_C32(0x36b10000), SPH_C32(0x0b6c0000), + SPH_C32(0x35e70000), SPH_C32(0x0f5b2339), SPH_C32(0x7f3b4ddc), + SPH_C32(0x7d22556c), SPH_C32(0x619b0a52), SPH_C32(0x95db0120), + SPH_C32(0x761b0000), SPH_C32(0x6b9d0000), SPH_C32(0xaec30000), + SPH_C32(0x6eb52fe1), SPH_C32(0xffe3ec51), SPH_C32(0x055183a1), + SPH_C32(0x0c35eb81) }, + { SPH_C32(0xac490219), SPH_C32(0xf98dc000), SPH_C32(0xc8ba0000), + SPH_C32(0x31750000), SPH_C32(0x0dce3a90), SPH_C32(0x87d37b66), + SPH_C32(0x07a5a422), SPH_C32(0xff8d9248), SPH_C32(0x41b10120), + SPH_C32(0xfbd3c000), SPH_C32(0xce320000), SPH_C32(0xe4ea0000), + SPH_C32(0x92fb6d9b), SPH_C32(0x36576a3d), SPH_C32(0x9d6715a5), + SPH_C32(0xfb7328a1) }, + { SPH_C32(0x8f560210), SPH_C32(0xbb79c000), SPH_C32(0xaec30000), + SPH_C32(0x7fce0000), SPH_C32(0xf3156143), SPH_C32(0xb68fcbb0), + SPH_C32(0xe514c368), SPH_C32(0x96ddc972), SPH_C32(0xb6c40129), + SPH_C32(0x34ef0000), SPH_C32(0x0de40000), SPH_C32(0xe0780000), + SPH_C32(0x906e7432), SPH_C32(0xcebf5c87), SPH_C32(0xe7e0e4eb), + SPH_C32(0x6565b0bb) }, + { SPH_C32(0x78230219), SPH_C32(0x74450000), SPH_C32(0x6d150000), + SPH_C32(0x7b5c0000), SPH_C32(0xf18078ea), SPH_C32(0x4e67fd0a), + SPH_C32(0x9f933226), SPH_C32(0x08cb5168), SPH_C32(0x62ae0129), + SPH_C32(0xb927c000), SPH_C32(0xa84b0000), SPH_C32(0xaa510000), + SPH_C32(0x6c203648), SPH_C32(0x070bdaeb), SPH_C32(0x7fd672ef), + SPH_C32(0x9223739b) }, + { SPH_C32(0x2c7802e0), SPH_C32(0xc7eb0000), SPH_C32(0xfede0000), + SPH_C32(0x01f30000), SPH_C32(0x866c5db5), SPH_C32(0x25b0a1f9), + SPH_C32(0x76e19872), SPH_C32(0xaeac7f99), SPH_C32(0x61b70170), + SPH_C32(0xe0030000), SPH_C32(0x7f380000), SPH_C32(0xaddc0000), + SPH_C32(0x2c215159), SPH_C32(0x995c9248), SPH_C32(0x99f5f373), + SPH_C32(0x8601fef5) }, + { SPH_C32(0xdb0d02e9), SPH_C32(0x08d7c000), SPH_C32(0x3d080000), + SPH_C32(0x05610000), SPH_C32(0x84f9441c), SPH_C32(0xdd589743), + SPH_C32(0x0c66693c), SPH_C32(0x30bae783), SPH_C32(0xb5dd0170), + SPH_C32(0x6dcbc000), SPH_C32(0xda970000), SPH_C32(0xe7f50000), + SPH_C32(0xd06f1323), SPH_C32(0x50e81424), SPH_C32(0x01c36577), + SPH_C32(0x71473dd5) }, + { SPH_C32(0xf81202e0), SPH_C32(0x4a23c000), SPH_C32(0x5b710000), + SPH_C32(0x4bda0000), SPH_C32(0x7a221fcf), SPH_C32(0xec042795), + SPH_C32(0xeed70e76), SPH_C32(0x59eabcb9), SPH_C32(0x42a80179), + SPH_C32(0xa2f70000), SPH_C32(0x19410000), SPH_C32(0xe3670000), + SPH_C32(0xd2fa0a8a), SPH_C32(0xa800229e), SPH_C32(0x7b449439), + SPH_C32(0xef51a5cf) }, + { SPH_C32(0x0f6702e9), SPH_C32(0x851f0000), SPH_C32(0x98a70000), + SPH_C32(0x4f480000), SPH_C32(0x78b70666), SPH_C32(0x14ec112f), + SPH_C32(0x9450ff38), SPH_C32(0xc7fc24a3), SPH_C32(0x96c20179), + SPH_C32(0x2f3fc000), SPH_C32(0xbcee0000), SPH_C32(0xa94e0000), + SPH_C32(0x2eb448f0), SPH_C32(0x61b4a4f2), SPH_C32(0xe372023d), + SPH_C32(0x181766ef) }, + { SPH_C32(0xaf500240), SPH_C32(0xa0a90000), SPH_C32(0x1fc90000), + SPH_C32(0x36f80000), SPH_C32(0x4dcf5d81), SPH_C32(0x198433c5), + SPH_C32(0xe18625be), SPH_C32(0xebaf1f26), SPH_C32(0x16f30180), + SPH_C32(0x11590000), SPH_C32(0x8a8a0000), SPH_C32(0x99c80000), + SPH_C32(0xa5162fd5), SPH_C32(0xc3d77e6d), SPH_C32(0x92363e6d), + SPH_C32(0x49368b3e) }, + { SPH_C32(0x58250249), SPH_C32(0x6f95c000), SPH_C32(0xdc1f0000), + SPH_C32(0x326a0000), SPH_C32(0x4f5a4428), SPH_C32(0xe16c057f), + SPH_C32(0x9b01d4f0), SPH_C32(0x75b9873c), SPH_C32(0xc2990180), + SPH_C32(0x9c91c000), SPH_C32(0x2f250000), SPH_C32(0xd3e10000), + SPH_C32(0x59586daf), SPH_C32(0x0a63f801), SPH_C32(0x0a00a869), + SPH_C32(0xbe70481e) }, + { SPH_C32(0x7b3a0240), SPH_C32(0x2d61c000), SPH_C32(0xba660000), + SPH_C32(0x7cd10000), SPH_C32(0xb1811ffb), SPH_C32(0xd030b5a9), + SPH_C32(0x79b0b3ba), SPH_C32(0x1ce9dc06), SPH_C32(0x35ec0189), + SPH_C32(0x53ad0000), SPH_C32(0xecf30000), SPH_C32(0xd7730000), + SPH_C32(0x5bcd7406), SPH_C32(0xf28bcebb), SPH_C32(0x70875927), + SPH_C32(0x2066d004) }, + { SPH_C32(0x8c4f0249), SPH_C32(0xe25d0000), SPH_C32(0x79b00000), + SPH_C32(0x78430000), SPH_C32(0xb3140652), SPH_C32(0x28d88313), + SPH_C32(0x033742f4), SPH_C32(0x82ff441c), SPH_C32(0xe1860189), + SPH_C32(0xde65c000), SPH_C32(0x495c0000), SPH_C32(0x9d5a0000), + SPH_C32(0xa783367c), SPH_C32(0x3b3f48d7), SPH_C32(0xe8b1cf23), + SPH_C32(0xd7201324) }, + { SPH_C32(0xd81402b0), SPH_C32(0x51f30000), SPH_C32(0xea7b0000), + SPH_C32(0x02ec0000), SPH_C32(0xc4f8230d), SPH_C32(0x430fdfe0), + SPH_C32(0xea45e8a0), SPH_C32(0x24986aed), SPH_C32(0xe29f01d0), + SPH_C32(0x87410000), SPH_C32(0x9e2f0000), SPH_C32(0x9ad70000), + SPH_C32(0xe782516d), SPH_C32(0xa5680074), SPH_C32(0x0e924ebf), + SPH_C32(0xc3029e4a) }, + { SPH_C32(0x2f6102b9), SPH_C32(0x9ecfc000), SPH_C32(0x29ad0000), + SPH_C32(0x067e0000), SPH_C32(0xc66d3aa4), SPH_C32(0xbbe7e95a), + SPH_C32(0x90c219ee), SPH_C32(0xba8ef2f7), SPH_C32(0x36f501d0), + SPH_C32(0x0a89c000), SPH_C32(0x3b800000), SPH_C32(0xd0fe0000), + SPH_C32(0x1bcc1317), SPH_C32(0x6cdc8618), SPH_C32(0x96a4d8bb), + SPH_C32(0x34445d6a) }, + { SPH_C32(0x0c7e02b0), SPH_C32(0xdc3bc000), SPH_C32(0x4fd40000), + SPH_C32(0x48c50000), SPH_C32(0x38b66177), SPH_C32(0x8abb598c), + SPH_C32(0x72737ea4), SPH_C32(0xd3dea9cd), SPH_C32(0xc18001d9), + SPH_C32(0xc5b50000), SPH_C32(0xf8560000), SPH_C32(0xd46c0000), + SPH_C32(0x19590abe), SPH_C32(0x9434b0a2), SPH_C32(0xec2329f5), + SPH_C32(0xaa52c570) }, + { SPH_C32(0xfb0b02b9), SPH_C32(0x13070000), SPH_C32(0x8c020000), + SPH_C32(0x4c570000), SPH_C32(0x3a2378de), SPH_C32(0x72536f36), + SPH_C32(0x08f48fea), SPH_C32(0x4dc831d7), SPH_C32(0x15ea01d9), + SPH_C32(0x487dc000), SPH_C32(0x5df90000), SPH_C32(0x9e450000), + SPH_C32(0xe51748c4), SPH_C32(0x5d8036ce), SPH_C32(0x7415bff1), + SPH_C32(0x5d140650) }, + { SPH_C32(0xb3bb0360), SPH_C32(0xabc30000), SPH_C32(0x19b70000), + SPH_C32(0xe1c50000), SPH_C32(0xfdd3481e), SPH_C32(0xd61aa89f), + SPH_C32(0x33dae074), SPH_C32(0x001319e3), SPH_C32(0x21ec0140), + SPH_C32(0x7a570000), SPH_C32(0x3d5f0000), SPH_C32(0xf26d0000), + SPH_C32(0xfae130de), SPH_C32(0xc4dd1474), SPH_C32(0x1e67dc9c), + SPH_C32(0xffe1bcd9) }, + { SPH_C32(0x44ce0369), SPH_C32(0x64ffc000), SPH_C32(0xda610000), + SPH_C32(0xe5570000), SPH_C32(0xff4651b7), SPH_C32(0x2ef29e25), + SPH_C32(0x495d113a), SPH_C32(0x9e0581f9), SPH_C32(0xf5860140), + SPH_C32(0xf79fc000), SPH_C32(0x98f00000), SPH_C32(0xb8440000), + SPH_C32(0x06af72a4), SPH_C32(0x0d699218), SPH_C32(0x86514a98), + SPH_C32(0x08a77ff9) }, + { SPH_C32(0x67d10360), SPH_C32(0x260bc000), SPH_C32(0xbc180000), + SPH_C32(0xabec0000), SPH_C32(0x019d0a64), SPH_C32(0x1fae2ef3), + SPH_C32(0xabec7670), SPH_C32(0xf755dac3), SPH_C32(0x02f30149), + SPH_C32(0x38a30000), SPH_C32(0x5b260000), SPH_C32(0xbcd60000), + SPH_C32(0x043a6b0d), SPH_C32(0xf581a4a2), SPH_C32(0xfcd6bbd6), + SPH_C32(0x96b1e7e3) }, + { SPH_C32(0x90a40369), SPH_C32(0xe9370000), SPH_C32(0x7fce0000), + SPH_C32(0xaf7e0000), SPH_C32(0x030813cd), SPH_C32(0xe7461849), + SPH_C32(0xd16b873e), SPH_C32(0x694342d9), SPH_C32(0xd6990149), + SPH_C32(0xb56bc000), SPH_C32(0xfe890000), SPH_C32(0xf6ff0000), + SPH_C32(0xf8742977), SPH_C32(0x3c3522ce), SPH_C32(0x64e02dd2), + SPH_C32(0x61f724c3) }, + { SPH_C32(0xc4ff0390), SPH_C32(0x5a990000), SPH_C32(0xec050000), + SPH_C32(0xd5d10000), SPH_C32(0x74e43692), SPH_C32(0x8c9144ba), + SPH_C32(0x38192d6a), SPH_C32(0xcf246c28), SPH_C32(0xd5800110), + SPH_C32(0xec4f0000), SPH_C32(0x29fa0000), SPH_C32(0xf1720000), + SPH_C32(0xb8754e66), SPH_C32(0xa2626a6d), SPH_C32(0x82c3ac4e), + SPH_C32(0x75d5a9ad) }, + { SPH_C32(0x338a0399), SPH_C32(0x95a5c000), SPH_C32(0x2fd30000), + SPH_C32(0xd1430000), SPH_C32(0x76712f3b), SPH_C32(0x74797200), + SPH_C32(0x429edc24), SPH_C32(0x5132f432), SPH_C32(0x01ea0110), + SPH_C32(0x6187c000), SPH_C32(0x8c550000), SPH_C32(0xbb5b0000), + SPH_C32(0x443b0c1c), SPH_C32(0x6bd6ec01), SPH_C32(0x1af53a4a), + SPH_C32(0x82936a8d) }, + { SPH_C32(0x10950390), SPH_C32(0xd751c000), SPH_C32(0x49aa0000), + SPH_C32(0x9ff80000), SPH_C32(0x88aa74e8), SPH_C32(0x4525c2d6), + SPH_C32(0xa02fbb6e), SPH_C32(0x3862af08), SPH_C32(0xf69f0119), + SPH_C32(0xaebb0000), SPH_C32(0x4f830000), SPH_C32(0xbfc90000), + SPH_C32(0x46ae15b5), SPH_C32(0x933edabb), SPH_C32(0x6072cb04), + SPH_C32(0x1c85f297) }, + { SPH_C32(0xe7e00399), SPH_C32(0x186d0000), SPH_C32(0x8a7c0000), + SPH_C32(0x9b6a0000), SPH_C32(0x8a3f6d41), SPH_C32(0xbdcdf46c), + SPH_C32(0xdaa84a20), SPH_C32(0xa6743712), SPH_C32(0x22f50119), + SPH_C32(0x2373c000), SPH_C32(0xea2c0000), SPH_C32(0xf5e00000), + SPH_C32(0xbae057cf), SPH_C32(0x5a8a5cd7), SPH_C32(0xf8445d00), + SPH_C32(0xebc331b7) }, + { SPH_C32(0x47d70330), SPH_C32(0x3ddb0000), SPH_C32(0x0d120000), + SPH_C32(0xe2da0000), SPH_C32(0xbf4736a6), SPH_C32(0xb0a5d686), + SPH_C32(0xaf7e90a6), SPH_C32(0x8a270c97), SPH_C32(0xa2c401e0), + SPH_C32(0x1d150000), SPH_C32(0xdc480000), SPH_C32(0xc5660000), + SPH_C32(0x314230ea), SPH_C32(0xf8e98648), SPH_C32(0x89006150), + SPH_C32(0xbae2dc66) }, + { SPH_C32(0xb0a20339), SPH_C32(0xf2e7c000), SPH_C32(0xcec40000), + SPH_C32(0xe6480000), SPH_C32(0xbdd22f0f), SPH_C32(0x484de03c), + SPH_C32(0xd5f961e8), SPH_C32(0x1431948d), SPH_C32(0x76ae01e0), + SPH_C32(0x90ddc000), SPH_C32(0x79e70000), SPH_C32(0x8f4f0000), + SPH_C32(0xcd0c7290), SPH_C32(0x315d0024), SPH_C32(0x1136f754), + SPH_C32(0x4da41f46) }, + { SPH_C32(0x93bd0330), SPH_C32(0xb013c000), SPH_C32(0xa8bd0000), + SPH_C32(0xa8f30000), SPH_C32(0x430974dc), SPH_C32(0x791150ea), + SPH_C32(0x374806a2), SPH_C32(0x7d61cfb7), SPH_C32(0x81db01e9), + SPH_C32(0x5fe10000), SPH_C32(0xba310000), SPH_C32(0x8bdd0000), + SPH_C32(0xcf996b39), SPH_C32(0xc9b5369e), SPH_C32(0x6bb1061a), + SPH_C32(0xd3b2875c) }, + { SPH_C32(0x64c80339), SPH_C32(0x7f2f0000), SPH_C32(0x6b6b0000), + SPH_C32(0xac610000), SPH_C32(0x419c6d75), SPH_C32(0x81f96650), + SPH_C32(0x4dcff7ec), SPH_C32(0xe37757ad), SPH_C32(0x55b101e9), + SPH_C32(0xd229c000), SPH_C32(0x1f9e0000), SPH_C32(0xc1f40000), + SPH_C32(0x33d72943), SPH_C32(0x0001b0f2), SPH_C32(0xf387901e), + SPH_C32(0x24f4447c) }, + { SPH_C32(0x309303c0), SPH_C32(0xcc810000), SPH_C32(0xf8a00000), + SPH_C32(0xd6ce0000), SPH_C32(0x3670482a), SPH_C32(0xea2e3aa3), + SPH_C32(0xa4bd5db8), SPH_C32(0x4510795c), SPH_C32(0x56a801b0), + SPH_C32(0x8b0d0000), SPH_C32(0xc8ed0000), SPH_C32(0xc6790000), + SPH_C32(0x73d64e52), SPH_C32(0x9e56f851), SPH_C32(0x15a41182), + SPH_C32(0x30d6c912) }, + { SPH_C32(0xc7e603c9), SPH_C32(0x03bdc000), SPH_C32(0x3b760000), + SPH_C32(0xd25c0000), SPH_C32(0x34e55183), SPH_C32(0x12c60c19), + SPH_C32(0xde3aacf6), SPH_C32(0xdb06e146), SPH_C32(0x82c201b0), + SPH_C32(0x06c5c000), SPH_C32(0x6d420000), SPH_C32(0x8c500000), + SPH_C32(0x8f980c28), SPH_C32(0x57e27e3d), SPH_C32(0x8d928786), + SPH_C32(0xc7900a32) }, + { SPH_C32(0xe4f903c0), SPH_C32(0x4149c000), SPH_C32(0x5d0f0000), + SPH_C32(0x9ce70000), SPH_C32(0xca3e0a50), SPH_C32(0x239abccf), + SPH_C32(0x3c8bcbbc), SPH_C32(0xb256ba7c), SPH_C32(0x75b701b9), + SPH_C32(0xc9f90000), SPH_C32(0xae940000), SPH_C32(0x88c20000), + SPH_C32(0x8d0d1581), SPH_C32(0xaf0a4887), SPH_C32(0xf71576c8), + SPH_C32(0x59869228) }, + { SPH_C32(0x138c03c9), SPH_C32(0x8e750000), SPH_C32(0x9ed90000), + SPH_C32(0x98750000), SPH_C32(0xc8ab13f9), SPH_C32(0xdb728a75), + SPH_C32(0x460c3af2), SPH_C32(0x2c402266), SPH_C32(0xa1dd01b9), + SPH_C32(0x4431c000), SPH_C32(0x0b3b0000), SPH_C32(0xc2eb0000), + SPH_C32(0x714357fb), SPH_C32(0x66beceeb), SPH_C32(0x6f23e0cc), + SPH_C32(0xaec05108) } +}; + +static const sph_u32 T512_14[128][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xb83d0000), SPH_C32(0x16710600), SPH_C32(0x379a0000), + SPH_C32(0xf5b10000), SPH_C32(0x228161ac), SPH_C32(0xae48f145), + SPH_C32(0x66241616), SPH_C32(0xc5c1eb3e), SPH_C32(0xfd250000), + SPH_C32(0xb3c41100), SPH_C32(0xcef00000), SPH_C32(0xcef90000), + SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), SPH_C32(0x7098b0a6), + SPH_C32(0x1af21fe1) }, + { SPH_C32(0x75a40000), SPH_C32(0xc28b2700), SPH_C32(0x94a40000), + SPH_C32(0x90f50000), SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), + SPH_C32(0x1767c483), SPH_C32(0xaedf667e), SPH_C32(0xd1660000), + SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), SPH_C32(0xf6940000), + SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), SPH_C32(0xb4431b17), + SPH_C32(0x857f3c2b) }, + { SPH_C32(0xcd990000), SPH_C32(0xd4fa2100), SPH_C32(0xa33e0000), + SPH_C32(0x65440000), SPH_C32(0xd9f9364c), SPH_C32(0xe786faeb), + SPH_C32(0x7143d295), SPH_C32(0x6b1e8d40), SPH_C32(0x2c430000), + SPH_C32(0xa8781200), SPH_C32(0x501c0000), SPH_C32(0x386d0000), + SPH_C32(0x3f4f30a7), SPH_C32(0x422b9861), SPH_C32(0xc4dbabb1), + SPH_C32(0x9f8d23ca) }, + { SPH_C32(0xd1660000), SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), + SPH_C32(0xf6940000), SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), + SPH_C32(0xb4431b17), SPH_C32(0x857f3c2b), SPH_C32(0xa4c20000), + SPH_C32(0xd9372400), SPH_C32(0x0a480000), SPH_C32(0x66610000), + SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), SPH_C32(0xa324df94), + SPH_C32(0x2ba05a55) }, + { SPH_C32(0x695b0000), SPH_C32(0x0dcd0500), SPH_C32(0xa9760000), + SPH_C32(0x03250000), SPH_C32(0x2183248b), SPH_C32(0x61380db7), + SPH_C32(0xd2670d01), SPH_C32(0x40bed715), SPH_C32(0x59e70000), + SPH_C32(0x6af33500), SPH_C32(0xc4b80000), SPH_C32(0xa8980000), + SPH_C32(0xc4376747), SPH_C32(0x0be593cf), SPH_C32(0xd3bc6f32), + SPH_C32(0x315245b4) }, + { SPH_C32(0xa4c20000), SPH_C32(0xd9372400), SPH_C32(0x0a480000), + SPH_C32(0x66610000), SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), + SPH_C32(0xa324df94), SPH_C32(0x2ba05a55), SPH_C32(0x75a40000), + SPH_C32(0xc28b2700), SPH_C32(0x94a40000), SPH_C32(0x90f50000), + SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), SPH_C32(0x1767c483), + SPH_C32(0xaedf667e) }, + { SPH_C32(0x1cff0000), SPH_C32(0xcf462200), SPH_C32(0x3dd20000), + SPH_C32(0x93d00000), SPH_C32(0xdafb736b), SPH_C32(0x28f60619), + SPH_C32(0xc500c982), SPH_C32(0xee61b16b), SPH_C32(0x88810000), + SPH_C32(0x714f3600), SPH_C32(0x5a540000), SPH_C32(0x5e0c0000), + SPH_C32(0xc7352260), SPH_C32(0xc4956f3d), SPH_C32(0x67ff7425), + SPH_C32(0xb42d799f) }, + { SPH_C32(0x75c90003), SPH_C32(0x0e10c000), SPH_C32(0xd1200000), + SPH_C32(0xbaea0000), SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), + SPH_C32(0xbb28761d), SPH_C32(0x00b72e2b), SPH_C32(0xeecf0001), + SPH_C32(0x6f564000), SPH_C32(0xf33e0000), SPH_C32(0xa79e0000), + SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), SPH_C32(0x4a3b40ba), + SPH_C32(0xfeabf254) }, + { SPH_C32(0xcdf40003), SPH_C32(0x1861c600), SPH_C32(0xe6ba0000), + SPH_C32(0x4f5b0000), SPH_C32(0xa9454e92), SPH_C32(0x29104612), + SPH_C32(0xdd0c600b), SPH_C32(0xc576c515), SPH_C32(0x13ea0001), + SPH_C32(0xdc925100), SPH_C32(0x3dce0000), SPH_C32(0x69670000), + SPH_C32(0x81f80799), SPH_C32(0x3a4a8f56), SPH_C32(0x3aa3f01c), + SPH_C32(0xe459edb5) }, + { SPH_C32(0x006d0003), SPH_C32(0xcc9be700), SPH_C32(0x45840000), + SPH_C32(0x2a1f0000), SPH_C32(0x70bc78de), SPH_C32(0xce96bcf9), + SPH_C32(0xac4fb29e), SPH_C32(0xae684855), SPH_C32(0x3fa90001), + SPH_C32(0x74ea4300), SPH_C32(0x6dd20000), SPH_C32(0x510a0000), + SPH_C32(0xbeb7373e), SPH_C32(0x78611737), SPH_C32(0xfe785bad), + SPH_C32(0x7bd4ce7f) }, + { SPH_C32(0xb8500003), SPH_C32(0xdaeae100), SPH_C32(0x721e0000), + SPH_C32(0xdfae0000), SPH_C32(0x523d1972), SPH_C32(0x60de4dbc), + SPH_C32(0xca6ba488), SPH_C32(0x6ba9a36b), SPH_C32(0xc28c0001), + SPH_C32(0xc72e5200), SPH_C32(0xa3220000), SPH_C32(0x9ff30000), + SPH_C32(0x82fa42be), SPH_C32(0xf53a73a4), SPH_C32(0x8ee0eb0b), + SPH_C32(0x6126d19e) }, + { SPH_C32(0xa4af0003), SPH_C32(0x15acc300), SPH_C32(0x4fcc0000), + SPH_C32(0x4c7e0000), SPH_C32(0x88c66a19), SPH_C32(0x48284ba5), + SPH_C32(0x0f6b6d0a), SPH_C32(0x85c81200), SPH_C32(0x4a0d0001), + SPH_C32(0xb6616400), SPH_C32(0xf9760000), SPH_C32(0xc1ff0000), + SPH_C32(0x45cf60de), SPH_C32(0x31af1c99), SPH_C32(0xe91f9f2e), + SPH_C32(0xd50ba801) }, + { SPH_C32(0x1c920003), SPH_C32(0x03ddc500), SPH_C32(0x78560000), + SPH_C32(0xb9cf0000), SPH_C32(0xaa470bb5), SPH_C32(0xe660bae0), + SPH_C32(0x694f7b1c), SPH_C32(0x4009f93e), SPH_C32(0xb7280001), + SPH_C32(0x05a57500), SPH_C32(0x37860000), SPH_C32(0x0f060000), + SPH_C32(0x7982155e), SPH_C32(0xbcf4780a), SPH_C32(0x99872f88), + SPH_C32(0xcff9b7e0) }, + { SPH_C32(0xd10b0003), SPH_C32(0xd727e400), SPH_C32(0xdb680000), + SPH_C32(0xdc8b0000), SPH_C32(0x73be3df9), SPH_C32(0x01e6400b), + SPH_C32(0x180ca989), SPH_C32(0x2b17747e), SPH_C32(0x9b6b0001), + SPH_C32(0xaddd6700), SPH_C32(0x679a0000), SPH_C32(0x376b0000), + SPH_C32(0x46cd25f9), SPH_C32(0xfedfe06b), SPH_C32(0x5d5c8439), + SPH_C32(0x5074942a) }, + { SPH_C32(0x69360003), SPH_C32(0xc156e200), SPH_C32(0xecf20000), + SPH_C32(0x293a0000), SPH_C32(0x513f5c55), SPH_C32(0xafaeb14e), + SPH_C32(0x7e28bf9f), SPH_C32(0xeed69f40), SPH_C32(0x664e0001), + SPH_C32(0x1e197600), SPH_C32(0xa96a0000), SPH_C32(0xf9920000), + SPH_C32(0x7a805079), SPH_C32(0x738484f8), SPH_C32(0x2dc4349f), + SPH_C32(0x4a868bcb) }, + { SPH_C32(0xeecf0001), SPH_C32(0x6f564000), SPH_C32(0xf33e0000), + SPH_C32(0xa79e0000), SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), + SPH_C32(0x4a3b40ba), SPH_C32(0xfeabf254), SPH_C32(0x9b060002), + SPH_C32(0x61468000), SPH_C32(0x221e0000), SPH_C32(0x1d740000), + SPH_C32(0x36715d27), SPH_C32(0x30495c92), SPH_C32(0xf11336a7), + SPH_C32(0xfe1cdc7f) }, + { SPH_C32(0x56f20001), SPH_C32(0x79274600), SPH_C32(0xc4a40000), + SPH_C32(0x522f0000), SPH_C32(0x9f3413b5), SPH_C32(0x19591a80), + SPH_C32(0x2c1f56ac), SPH_C32(0x3b6a196a), SPH_C32(0x66230002), + SPH_C32(0xd2829100), SPH_C32(0xecee0000), SPH_C32(0xd38d0000), + SPH_C32(0x0a3c28a7), SPH_C32(0xbd123801), SPH_C32(0x818b8601), + SPH_C32(0xe4eec39e) }, + { SPH_C32(0x9b6b0001), SPH_C32(0xaddd6700), SPH_C32(0x679a0000), + SPH_C32(0x376b0000), SPH_C32(0x46cd25f9), SPH_C32(0xfedfe06b), + SPH_C32(0x5d5c8439), SPH_C32(0x5074942a), SPH_C32(0x4a600002), + SPH_C32(0x7afa8300), SPH_C32(0xbcf20000), SPH_C32(0xebe00000), + SPH_C32(0x35731800), SPH_C32(0xff39a060), SPH_C32(0x45502db0), + SPH_C32(0x7b63e054) }, + { SPH_C32(0x23560001), SPH_C32(0xbbac6100), SPH_C32(0x50000000), + SPH_C32(0xc2da0000), SPH_C32(0x644c4455), SPH_C32(0x5097112e), + SPH_C32(0x3b78922f), SPH_C32(0x95b57f14), SPH_C32(0xb7450002), + SPH_C32(0xc93e9200), SPH_C32(0x72020000), SPH_C32(0x25190000), + SPH_C32(0x093e6d80), SPH_C32(0x7262c4f3), SPH_C32(0x35c89d16), + SPH_C32(0x6191ffb5) }, + { SPH_C32(0x3fa90001), SPH_C32(0x74ea4300), SPH_C32(0x6dd20000), + SPH_C32(0x510a0000), SPH_C32(0xbeb7373e), SPH_C32(0x78611737), + SPH_C32(0xfe785bad), SPH_C32(0x7bd4ce7f), SPH_C32(0x3fc40002), + SPH_C32(0xb871a400), SPH_C32(0x28560000), SPH_C32(0x7b150000), + SPH_C32(0xce0b4fe0), SPH_C32(0xb6f7abce), SPH_C32(0x5237e933), + SPH_C32(0xd5bc862a) }, + { SPH_C32(0x87940001), SPH_C32(0x629b4500), SPH_C32(0x5a480000), + SPH_C32(0xa4bb0000), SPH_C32(0x9c365692), SPH_C32(0xd629e672), + SPH_C32(0x985c4dbb), SPH_C32(0xbe152541), SPH_C32(0xc2e10002), + SPH_C32(0x0bb5b500), SPH_C32(0xe6a60000), SPH_C32(0xb5ec0000), + SPH_C32(0xf2463a60), SPH_C32(0x3baccf5d), SPH_C32(0x22af5995), + SPH_C32(0xcf4e99cb) }, + { SPH_C32(0x4a0d0001), SPH_C32(0xb6616400), SPH_C32(0xf9760000), + SPH_C32(0xc1ff0000), SPH_C32(0x45cf60de), SPH_C32(0x31af1c99), + SPH_C32(0xe91f9f2e), SPH_C32(0xd50ba801), SPH_C32(0xeea20002), + SPH_C32(0xa3cda700), SPH_C32(0xb6ba0000), SPH_C32(0x8d810000), + SPH_C32(0xcd090ac7), SPH_C32(0x7987573c), SPH_C32(0xe674f224), + SPH_C32(0x50c3ba01) }, + { SPH_C32(0xf2300001), SPH_C32(0xa0106200), SPH_C32(0xceec0000), + SPH_C32(0x344e0000), SPH_C32(0x674e0172), SPH_C32(0x9fe7eddc), + SPH_C32(0x8f3b8938), SPH_C32(0x10ca433f), SPH_C32(0x13870002), + SPH_C32(0x1009b600), SPH_C32(0x784a0000), SPH_C32(0x43780000), + SPH_C32(0xf1447f47), SPH_C32(0xf4dc33af), SPH_C32(0x96ec4282), + SPH_C32(0x4a31a5e0) }, + { SPH_C32(0x9b060002), SPH_C32(0x61468000), SPH_C32(0x221e0000), + SPH_C32(0x1d740000), SPH_C32(0x36715d27), SPH_C32(0x30495c92), + SPH_C32(0xf11336a7), SPH_C32(0xfe1cdc7f), SPH_C32(0x75c90003), + SPH_C32(0x0e10c000), SPH_C32(0xd1200000), SPH_C32(0xbaea0000), + SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), SPH_C32(0xbb28761d), + SPH_C32(0x00b72e2b) }, + { SPH_C32(0x233b0002), SPH_C32(0x77378600), SPH_C32(0x15840000), + SPH_C32(0xe8c50000), SPH_C32(0x14f03c8b), SPH_C32(0x9e01add7), + SPH_C32(0x973720b1), SPH_C32(0x3bdd3741), SPH_C32(0x88ec0003), + SPH_C32(0xbdd4d100), SPH_C32(0x1fd00000), SPH_C32(0x74130000), + SPH_C32(0xb7895abe), SPH_C32(0x0a03d3c4), SPH_C32(0xcbb0c6bb), + SPH_C32(0x1a4531ca) }, + { SPH_C32(0xeea20002), SPH_C32(0xa3cda700), SPH_C32(0xb6ba0000), + SPH_C32(0x8d810000), SPH_C32(0xcd090ac7), SPH_C32(0x7987573c), + SPH_C32(0xe674f224), SPH_C32(0x50c3ba01), SPH_C32(0xa4af0003), + SPH_C32(0x15acc300), SPH_C32(0x4fcc0000), SPH_C32(0x4c7e0000), + SPH_C32(0x88c66a19), SPH_C32(0x48284ba5), SPH_C32(0x0f6b6d0a), + SPH_C32(0x85c81200) }, + { SPH_C32(0x569f0002), SPH_C32(0xb5bca100), SPH_C32(0x81200000), + SPH_C32(0x78300000), SPH_C32(0xef886b6b), SPH_C32(0xd7cfa679), + SPH_C32(0x8050e432), SPH_C32(0x9502513f), SPH_C32(0x598a0003), + SPH_C32(0xa668d200), SPH_C32(0x813c0000), SPH_C32(0x82870000), + SPH_C32(0xb48b1f99), SPH_C32(0xc5732f36), SPH_C32(0x7ff3ddac), + SPH_C32(0x9f3a0de1) }, + { SPH_C32(0x4a600002), SPH_C32(0x7afa8300), SPH_C32(0xbcf20000), + SPH_C32(0xebe00000), SPH_C32(0x35731800), SPH_C32(0xff39a060), + SPH_C32(0x45502db0), SPH_C32(0x7b63e054), SPH_C32(0xd10b0003), + SPH_C32(0xd727e400), SPH_C32(0xdb680000), SPH_C32(0xdc8b0000), + SPH_C32(0x73be3df9), SPH_C32(0x01e6400b), SPH_C32(0x180ca989), + SPH_C32(0x2b17747e) }, + { SPH_C32(0xf25d0002), SPH_C32(0x6c8b8500), SPH_C32(0x8b680000), + SPH_C32(0x1e510000), SPH_C32(0x17f279ac), SPH_C32(0x51715125), + SPH_C32(0x23743ba6), SPH_C32(0xbea20b6a), SPH_C32(0x2c2e0003), + SPH_C32(0x64e3f500), SPH_C32(0x15980000), SPH_C32(0x12720000), + SPH_C32(0x4ff34879), SPH_C32(0x8cbd2498), SPH_C32(0x6894192f), + SPH_C32(0x31e56b9f) }, + { SPH_C32(0x3fc40002), SPH_C32(0xb871a400), SPH_C32(0x28560000), + SPH_C32(0x7b150000), SPH_C32(0xce0b4fe0), SPH_C32(0xb6f7abce), + SPH_C32(0x5237e933), SPH_C32(0xd5bc862a), SPH_C32(0x006d0003), + SPH_C32(0xcc9be700), SPH_C32(0x45840000), SPH_C32(0x2a1f0000), + SPH_C32(0x70bc78de), SPH_C32(0xce96bcf9), SPH_C32(0xac4fb29e), + SPH_C32(0xae684855) }, + { SPH_C32(0x87f90002), SPH_C32(0xae00a200), SPH_C32(0x1fcc0000), + SPH_C32(0x8ea40000), SPH_C32(0xec8a2e4c), SPH_C32(0x18bf5a8b), + SPH_C32(0x3413ff25), SPH_C32(0x107d6d14), SPH_C32(0xfd480003), + SPH_C32(0x7f5ff600), SPH_C32(0x8b740000), SPH_C32(0xe4e60000), + SPH_C32(0x4cf10d5e), SPH_C32(0x43cdd86a), SPH_C32(0xdcd70238), + SPH_C32(0xb49a57b4) }, + { SPH_C32(0xf6800005), SPH_C32(0x3443c000), SPH_C32(0x24070000), + SPH_C32(0x8f3d0000), SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), + SPH_C32(0xcdc58b19), SPH_C32(0xd795ba31), SPH_C32(0xa67f0001), + SPH_C32(0x71378000), SPH_C32(0x19fc0000), SPH_C32(0x96db0000), + SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), SPH_C32(0x2c6d478f), + SPH_C32(0xac8e6c88) }, + { SPH_C32(0x4ebd0005), SPH_C32(0x2232c600), SPH_C32(0x139d0000), + SPH_C32(0x7a8c0000), SPH_C32(0x03b65a57), SPH_C32(0xa4f024eb), + SPH_C32(0xabe19d0f), SPH_C32(0x1254510f), SPH_C32(0x5b5a0001), + SPH_C32(0xc2f39100), SPH_C32(0xd70c0000), SPH_C32(0x58220000), + SPH_C32(0x06c6187d), SPH_C32(0x6691ca60), SPH_C32(0x5cf5f729), + SPH_C32(0xb67c7369) }, + { SPH_C32(0x83240005), SPH_C32(0xf6c8e700), SPH_C32(0xb0a30000), + SPH_C32(0x1fc80000), SPH_C32(0xda4f6c1b), SPH_C32(0x4376de00), + SPH_C32(0xdaa24f9a), SPH_C32(0x794adc4f), SPH_C32(0x77190001), + SPH_C32(0x6a8b8300), SPH_C32(0x87100000), SPH_C32(0x604f0000), + SPH_C32(0x398928da), SPH_C32(0x24ba5201), SPH_C32(0x982e5c98), + SPH_C32(0x29f150a3) }, + { SPH_C32(0x3b190005), SPH_C32(0xe0b9e100), SPH_C32(0x87390000), + SPH_C32(0xea790000), SPH_C32(0xf8ce0db7), SPH_C32(0xed3e2f45), + SPH_C32(0xbc86598c), SPH_C32(0xbc8b3771), SPH_C32(0x8a3c0001), + SPH_C32(0xd94f9200), SPH_C32(0x49e00000), SPH_C32(0xaeb60000), + SPH_C32(0x05c45d5a), SPH_C32(0xa9e13692), SPH_C32(0xe8b6ec3e), + SPH_C32(0x33034f42) }, + { SPH_C32(0x27e60005), SPH_C32(0x2fffc300), SPH_C32(0xbaeb0000), + SPH_C32(0x79a90000), SPH_C32(0x22357edc), SPH_C32(0xc5c8295c), + SPH_C32(0x7986900e), SPH_C32(0x52ea861a), SPH_C32(0x02bd0001), + SPH_C32(0xa800a400), SPH_C32(0x13b40000), SPH_C32(0xf0ba0000), + SPH_C32(0xc2f17f3a), SPH_C32(0x6d7459af), SPH_C32(0x8f49981b), + SPH_C32(0x872e36dd) }, + { SPH_C32(0x9fdb0005), SPH_C32(0x398ec500), SPH_C32(0x8d710000), + SPH_C32(0x8c180000), SPH_C32(0x00b41f70), SPH_C32(0x6b80d819), + SPH_C32(0x1fa28618), SPH_C32(0x972b6d24), SPH_C32(0xff980001), + SPH_C32(0x1bc4b500), SPH_C32(0xdd440000), SPH_C32(0x3e430000), + SPH_C32(0xfebc0aba), SPH_C32(0xe02f3d3c), SPH_C32(0xffd128bd), + SPH_C32(0x9ddc293c) }, + { SPH_C32(0x52420005), SPH_C32(0xed74e400), SPH_C32(0x2e4f0000), + SPH_C32(0xe95c0000), SPH_C32(0xd94d293c), SPH_C32(0x8c0622f2), + SPH_C32(0x6ee1548d), SPH_C32(0xfc35e064), SPH_C32(0xd3db0001), + SPH_C32(0xb3bca700), SPH_C32(0x8d580000), SPH_C32(0x062e0000), + SPH_C32(0xc1f33a1d), SPH_C32(0xa204a55d), SPH_C32(0x3b0a830c), + SPH_C32(0x02510af6) }, + { SPH_C32(0xea7f0005), SPH_C32(0xfb05e200), SPH_C32(0x19d50000), + SPH_C32(0x1ced0000), SPH_C32(0xfbcc4890), SPH_C32(0x224ed3b7), + SPH_C32(0x08c5429b), SPH_C32(0x39f40b5a), SPH_C32(0x2efe0001), + SPH_C32(0x0078b600), SPH_C32(0x43a80000), SPH_C32(0xc8d70000), + SPH_C32(0xfdbe4f9d), SPH_C32(0x2f5fc1ce), SPH_C32(0x4b9233aa), + SPH_C32(0x18a31517) }, + { SPH_C32(0x83490006), SPH_C32(0x3a530000), SPH_C32(0xf5270000), + SPH_C32(0x35d70000), SPH_C32(0xaaf314c5), SPH_C32(0x8de062f9), + SPH_C32(0x76edfd04), SPH_C32(0xd722941a), SPH_C32(0x48b00000), + SPH_C32(0x1e61c000), SPH_C32(0xeac20000), SPH_C32(0x31450000), + SPH_C32(0x873e1fe4), SPH_C32(0x5cdb4536), SPH_C32(0x66560735), + SPH_C32(0x52259edc) }, + { SPH_C32(0x3b740006), SPH_C32(0x2c220600), SPH_C32(0xc2bd0000), + SPH_C32(0xc0660000), SPH_C32(0x88727569), SPH_C32(0x23a893bc), + SPH_C32(0x10c9eb12), SPH_C32(0x12e37f24), SPH_C32(0xb5950000), + SPH_C32(0xada5d100), SPH_C32(0x24320000), SPH_C32(0xffbc0000), + SPH_C32(0xbb736a64), SPH_C32(0xd18021a5), SPH_C32(0x16ceb793), + SPH_C32(0x48d7813d) }, + { SPH_C32(0xf6ed0006), SPH_C32(0xf8d82700), SPH_C32(0x61830000), + SPH_C32(0xa5220000), SPH_C32(0x518b4325), SPH_C32(0xc42e6957), + SPH_C32(0x618a3987), SPH_C32(0x79fdf264), SPH_C32(0x99d60000), + SPH_C32(0x05ddc300), SPH_C32(0x742e0000), SPH_C32(0xc7d10000), + SPH_C32(0x843c5ac3), SPH_C32(0x93abb9c4), SPH_C32(0xd2151c22), + SPH_C32(0xd75aa2f7) }, + { SPH_C32(0x4ed00006), SPH_C32(0xeea92100), SPH_C32(0x56190000), + SPH_C32(0x50930000), SPH_C32(0x730a2289), SPH_C32(0x6a669812), + SPH_C32(0x07ae2f91), SPH_C32(0xbc3c195a), SPH_C32(0x64f30000), + SPH_C32(0xb619d200), SPH_C32(0xbade0000), SPH_C32(0x09280000), + SPH_C32(0xb8712f43), SPH_C32(0x1ef0dd57), SPH_C32(0xa28dac84), + SPH_C32(0xcda8bd16) }, + { SPH_C32(0x522f0006), SPH_C32(0x21ef0300), SPH_C32(0x6bcb0000), + SPH_C32(0xc3430000), SPH_C32(0xa9f151e2), SPH_C32(0x42909e0b), + SPH_C32(0xc2aee613), SPH_C32(0x525da831), SPH_C32(0xec720000), + SPH_C32(0xc756e400), SPH_C32(0xe08a0000), SPH_C32(0x57240000), + SPH_C32(0x7f440d23), SPH_C32(0xda65b26a), SPH_C32(0xc572d8a1), + SPH_C32(0x7985c489) }, + { SPH_C32(0xea120006), SPH_C32(0x379e0500), SPH_C32(0x5c510000), + SPH_C32(0x36f20000), SPH_C32(0x8b70304e), SPH_C32(0xecd86f4e), + SPH_C32(0xa48af005), SPH_C32(0x979c430f), SPH_C32(0x11570000), + SPH_C32(0x7492f500), SPH_C32(0x2e7a0000), SPH_C32(0x99dd0000), + SPH_C32(0x430978a3), SPH_C32(0x573ed6f9), SPH_C32(0xb5ea6807), + SPH_C32(0x6377db68) }, + { SPH_C32(0x278b0006), SPH_C32(0xe3642400), SPH_C32(0xff6f0000), + SPH_C32(0x53b60000), SPH_C32(0x52890602), SPH_C32(0x0b5e95a5), + SPH_C32(0xd5c92290), SPH_C32(0xfc82ce4f), SPH_C32(0x3d140000), + SPH_C32(0xdceae700), SPH_C32(0x7e660000), SPH_C32(0xa1b00000), + SPH_C32(0x7c464804), SPH_C32(0x15154e98), SPH_C32(0x7131c3b6), + SPH_C32(0xfcfaf8a2) }, + { SPH_C32(0x9fb60006), SPH_C32(0xf5152200), SPH_C32(0xc8f50000), + SPH_C32(0xa6070000), SPH_C32(0x700867ae), SPH_C32(0xa51664e0), + SPH_C32(0xb3ed3486), SPH_C32(0x39432571), SPH_C32(0xc0310000), + SPH_C32(0x6f2ef600), SPH_C32(0xb0960000), SPH_C32(0x6f490000), + SPH_C32(0x400b3d84), SPH_C32(0x984e2a0b), SPH_C32(0x01a97310), + SPH_C32(0xe608e743) }, + { SPH_C32(0x184f0004), SPH_C32(0x5b158000), SPH_C32(0xd7390000), + SPH_C32(0x28a30000), SPH_C32(0x9c8249e2), SPH_C32(0xbda93e6b), + SPH_C32(0x87fecba3), SPH_C32(0x293e4865), SPH_C32(0x3d790003), + SPH_C32(0x10710000), SPH_C32(0x3be20000), SPH_C32(0x8baf0000), + SPH_C32(0x0cfa30da), SPH_C32(0xdb83f261), SPH_C32(0xdd7e7128), + SPH_C32(0x5292b0f7) }, + { SPH_C32(0xa0720004), SPH_C32(0x4d648600), SPH_C32(0xe0a30000), + SPH_C32(0xdd120000), SPH_C32(0xbe03284e), SPH_C32(0x13e1cf2e), + SPH_C32(0xe1daddb5), SPH_C32(0xecffa35b), SPH_C32(0xc05c0003), + SPH_C32(0xa3b51100), SPH_C32(0xf5120000), SPH_C32(0x45560000), + SPH_C32(0x30b7455a), SPH_C32(0x56d896f2), SPH_C32(0xade6c18e), + SPH_C32(0x4860af16) }, + { SPH_C32(0x6deb0004), SPH_C32(0x999ea700), SPH_C32(0x439d0000), + SPH_C32(0xb8560000), SPH_C32(0x67fa1e02), SPH_C32(0xf46735c5), + SPH_C32(0x90990f20), SPH_C32(0x87e12e1b), SPH_C32(0xec1f0003), + SPH_C32(0x0bcd0300), SPH_C32(0xa50e0000), SPH_C32(0x7d3b0000), + SPH_C32(0x0ff875fd), SPH_C32(0x14f30e93), SPH_C32(0x693d6a3f), + SPH_C32(0xd7ed8cdc) }, + { SPH_C32(0xd5d60004), SPH_C32(0x8fefa100), SPH_C32(0x74070000), + SPH_C32(0x4de70000), SPH_C32(0x457b7fae), SPH_C32(0x5a2fc480), + SPH_C32(0xf6bd1936), SPH_C32(0x4220c525), SPH_C32(0x113a0003), + SPH_C32(0xb8091200), SPH_C32(0x6bfe0000), SPH_C32(0xb3c20000), + SPH_C32(0x33b5007d), SPH_C32(0x99a86a00), SPH_C32(0x19a5da99), + SPH_C32(0xcd1f933d) }, + { SPH_C32(0xc9290004), SPH_C32(0x40a98300), SPH_C32(0x49d50000), + SPH_C32(0xde370000), SPH_C32(0x9f800cc5), SPH_C32(0x72d9c299), + SPH_C32(0x33bdd0b4), SPH_C32(0xac41744e), SPH_C32(0x99bb0003), + SPH_C32(0xc9462400), SPH_C32(0x31aa0000), SPH_C32(0xedce0000), + SPH_C32(0xf480221d), SPH_C32(0x5d3d053d), SPH_C32(0x7e5aaebc), + SPH_C32(0x7932eaa2) }, + { SPH_C32(0x71140004), SPH_C32(0x56d88500), SPH_C32(0x7e4f0000), + SPH_C32(0x2b860000), SPH_C32(0xbd016d69), SPH_C32(0xdc9133dc), + SPH_C32(0x5599c6a2), SPH_C32(0x69809f70), SPH_C32(0x649e0003), + SPH_C32(0x7a823500), SPH_C32(0xff5a0000), SPH_C32(0x23370000), + SPH_C32(0xc8cd579d), SPH_C32(0xd06661ae), SPH_C32(0x0ec21e1a), + SPH_C32(0x63c0f543) }, + { SPH_C32(0xbc8d0004), SPH_C32(0x8222a400), SPH_C32(0xdd710000), + SPH_C32(0x4ec20000), SPH_C32(0x64f85b25), SPH_C32(0x3b17c937), + SPH_C32(0x24da1437), SPH_C32(0x029e1230), SPH_C32(0x48dd0003), + SPH_C32(0xd2fa2700), SPH_C32(0xaf460000), SPH_C32(0x1b5a0000), + SPH_C32(0xf782673a), SPH_C32(0x924df9cf), SPH_C32(0xca19b5ab), + SPH_C32(0xfc4dd689) }, + { SPH_C32(0x04b00004), SPH_C32(0x9453a200), SPH_C32(0xeaeb0000), + SPH_C32(0xbb730000), SPH_C32(0x46793a89), SPH_C32(0x955f3872), + SPH_C32(0x42fe0221), SPH_C32(0xc75ff90e), SPH_C32(0xb5f80003), + SPH_C32(0x613e3600), SPH_C32(0x61b60000), SPH_C32(0xd5a30000), + SPH_C32(0xcbcf12ba), SPH_C32(0x1f169d5c), SPH_C32(0xba81050d), + SPH_C32(0xe6bfc968) }, + { SPH_C32(0x6d860007), SPH_C32(0x55054000), SPH_C32(0x06190000), + SPH_C32(0x92490000), SPH_C32(0x174666dc), SPH_C32(0x3af1893c), + SPH_C32(0x3cd6bdbe), SPH_C32(0x2989664e), SPH_C32(0xd3b60002), + SPH_C32(0x7f274000), SPH_C32(0xc8dc0000), SPH_C32(0x2c310000), + SPH_C32(0xb14f42c3), SPH_C32(0x6c9219a4), SPH_C32(0x97453192), + SPH_C32(0xac3942a3) }, + { SPH_C32(0xd5bb0007), SPH_C32(0x43744600), SPH_C32(0x31830000), + SPH_C32(0x67f80000), SPH_C32(0x35c70770), SPH_C32(0x94b97879), + SPH_C32(0x5af2aba8), SPH_C32(0xec488d70), SPH_C32(0x2e930002), + SPH_C32(0xcce35100), SPH_C32(0x062c0000), SPH_C32(0xe2c80000), + SPH_C32(0x8d023743), SPH_C32(0xe1c97d37), SPH_C32(0xe7dd8134), + SPH_C32(0xb6cb5d42) }, + { SPH_C32(0x18220007), SPH_C32(0x978e6700), SPH_C32(0x92bd0000), + SPH_C32(0x02bc0000), SPH_C32(0xec3e313c), SPH_C32(0x733f8292), + SPH_C32(0x2bb1793d), SPH_C32(0x87560030), SPH_C32(0x02d00002), + SPH_C32(0x649b4300), SPH_C32(0x56300000), SPH_C32(0xdaa50000), + SPH_C32(0xb24d07e4), SPH_C32(0xa3e2e556), SPH_C32(0x23062a85), + SPH_C32(0x29467e88) }, + { SPH_C32(0xa01f0007), SPH_C32(0x81ff6100), SPH_C32(0xa5270000), + SPH_C32(0xf70d0000), SPH_C32(0xcebf5090), SPH_C32(0xdd7773d7), + SPH_C32(0x4d956f2b), SPH_C32(0x4297eb0e), SPH_C32(0xfff50002), + SPH_C32(0xd75f5200), SPH_C32(0x98c00000), SPH_C32(0x145c0000), + SPH_C32(0x8e007264), SPH_C32(0x2eb981c5), SPH_C32(0x539e9a23), + SPH_C32(0x33b46169) }, + { SPH_C32(0xbce00007), SPH_C32(0x4eb94300), SPH_C32(0x98f50000), + SPH_C32(0x64dd0000), SPH_C32(0x144423fb), SPH_C32(0xf58175ce), + SPH_C32(0x8895a6a9), SPH_C32(0xacf65a65), SPH_C32(0x77740002), + SPH_C32(0xa6106400), SPH_C32(0xc2940000), SPH_C32(0x4a500000), + SPH_C32(0x49355004), SPH_C32(0xea2ceef8), SPH_C32(0x3461ee06), + SPH_C32(0x879918f6) }, + { SPH_C32(0x04dd0007), SPH_C32(0x58c84500), SPH_C32(0xaf6f0000), + SPH_C32(0x916c0000), SPH_C32(0x36c54257), SPH_C32(0x5bc9848b), + SPH_C32(0xeeb1b0bf), SPH_C32(0x6937b15b), SPH_C32(0x8a510002), + SPH_C32(0x15d47500), SPH_C32(0x0c640000), SPH_C32(0x84a90000), + SPH_C32(0x75782584), SPH_C32(0x67778a6b), SPH_C32(0x44f95ea0), + SPH_C32(0x9d6b0717) }, + { SPH_C32(0xc9440007), SPH_C32(0x8c326400), SPH_C32(0x0c510000), + SPH_C32(0xf4280000), SPH_C32(0xef3c741b), SPH_C32(0xbc4f7e60), + SPH_C32(0x9ff2622a), SPH_C32(0x02293c1b), SPH_C32(0xa6120002), + SPH_C32(0xbdac6700), SPH_C32(0x5c780000), SPH_C32(0xbcc40000), + SPH_C32(0x4a371523), SPH_C32(0x255c120a), SPH_C32(0x8022f511), + SPH_C32(0x02e624dd) }, + { SPH_C32(0x71790007), SPH_C32(0x9a436200), SPH_C32(0x3bcb0000), + SPH_C32(0x01990000), SPH_C32(0xcdbd15b7), SPH_C32(0x12078f25), + SPH_C32(0xf9d6743c), SPH_C32(0xc7e8d725), SPH_C32(0x5b370002), + SPH_C32(0x0e687600), SPH_C32(0x92880000), SPH_C32(0x723d0000), + SPH_C32(0x767a60a3), SPH_C32(0xa8077699), SPH_C32(0xf0ba45b7), + SPH_C32(0x18143b3c) }, + { SPH_C32(0xa67f0001), SPH_C32(0x71378000), SPH_C32(0x19fc0000), + SPH_C32(0x96db0000), SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), + SPH_C32(0x2c6d478f), SPH_C32(0xac8e6c88), SPH_C32(0x50ff0004), + SPH_C32(0x45744000), SPH_C32(0x3dfb0000), SPH_C32(0x19e60000), + SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), SPH_C32(0xe1a8cc96), + SPH_C32(0x7b1bd6b9) }, + { SPH_C32(0x1e420001), SPH_C32(0x67468600), SPH_C32(0x2e660000), + SPH_C32(0x636a0000), SPH_C32(0x180a0c51), SPH_C32(0x45825fb6), + SPH_C32(0x4a495199), SPH_C32(0x694f87b6), SPH_C32(0xadda0004), + SPH_C32(0xf6b05100), SPH_C32(0xf30b0000), SPH_C32(0xd71f0000), + SPH_C32(0x27f12386), SPH_C32(0x6c291fce), SPH_C32(0x91307c30), + SPH_C32(0x61e9c958) }, + { SPH_C32(0xd3db0001), SPH_C32(0xb3bca700), SPH_C32(0x8d580000), + SPH_C32(0x062e0000), SPH_C32(0xc1f33a1d), SPH_C32(0xa204a55d), + SPH_C32(0x3b0a830c), SPH_C32(0x02510af6), SPH_C32(0x81990004), + SPH_C32(0x5ec84300), SPH_C32(0xa3170000), SPH_C32(0xef720000), + SPH_C32(0x18be1321), SPH_C32(0x2e0287af), SPH_C32(0x55ebd781), + SPH_C32(0xfe64ea92) }, + { SPH_C32(0x6be60001), SPH_C32(0xa5cda100), SPH_C32(0xbac20000), + SPH_C32(0xf39f0000), SPH_C32(0xe3725bb1), SPH_C32(0x0c4c5418), + SPH_C32(0x5d2e951a), SPH_C32(0xc790e1c8), SPH_C32(0x7cbc0004), + SPH_C32(0xed0c5200), SPH_C32(0x6de70000), SPH_C32(0x218b0000), + SPH_C32(0x24f366a1), SPH_C32(0xa359e33c), SPH_C32(0x25736727), + SPH_C32(0xe496f573) }, + { SPH_C32(0x77190001), SPH_C32(0x6a8b8300), SPH_C32(0x87100000), + SPH_C32(0x604f0000), SPH_C32(0x398928da), SPH_C32(0x24ba5201), + SPH_C32(0x982e5c98), SPH_C32(0x29f150a3), SPH_C32(0xf43d0004), + SPH_C32(0x9c436400), SPH_C32(0x37b30000), SPH_C32(0x7f870000), + SPH_C32(0xe3c644c1), SPH_C32(0x67cc8c01), SPH_C32(0x428c1302), + SPH_C32(0x50bb8cec) }, + { SPH_C32(0xcf240001), SPH_C32(0x7cfa8500), SPH_C32(0xb08a0000), + SPH_C32(0x95fe0000), SPH_C32(0x1b084976), SPH_C32(0x8af2a344), + SPH_C32(0xfe0a4a8e), SPH_C32(0xec30bb9d), SPH_C32(0x09180004), + SPH_C32(0x2f877500), SPH_C32(0xf9430000), SPH_C32(0xb17e0000), + SPH_C32(0xdf8b3141), SPH_C32(0xea97e892), SPH_C32(0x3214a3a4), + SPH_C32(0x4a49930d) }, + { SPH_C32(0x02bd0001), SPH_C32(0xa800a400), SPH_C32(0x13b40000), + SPH_C32(0xf0ba0000), SPH_C32(0xc2f17f3a), SPH_C32(0x6d7459af), + SPH_C32(0x8f49981b), SPH_C32(0x872e36dd), SPH_C32(0x255b0004), + SPH_C32(0x87ff6700), SPH_C32(0xa95f0000), SPH_C32(0x89130000), + SPH_C32(0xe0c401e6), SPH_C32(0xa8bc70f3), SPH_C32(0xf6cf0815), + SPH_C32(0xd5c4b0c7) }, + { SPH_C32(0xba800001), SPH_C32(0xbe71a200), SPH_C32(0x242e0000), + SPH_C32(0x050b0000), SPH_C32(0xe0701e96), SPH_C32(0xc33ca8ea), + SPH_C32(0xe96d8e0d), SPH_C32(0x42efdde3), SPH_C32(0xd87e0004), + SPH_C32(0x343b7600), SPH_C32(0x67af0000), SPH_C32(0x47ea0000), + SPH_C32(0xdc897466), SPH_C32(0x25e71460), SPH_C32(0x8657b8b3), + SPH_C32(0xcf36af26) }, + { SPH_C32(0xd3b60002), SPH_C32(0x7f274000), SPH_C32(0xc8dc0000), + SPH_C32(0x2c310000), SPH_C32(0xb14f42c3), SPH_C32(0x6c9219a4), + SPH_C32(0x97453192), SPH_C32(0xac3942a3), SPH_C32(0xbe300005), + SPH_C32(0x2a220000), SPH_C32(0xcec50000), SPH_C32(0xbe780000), + SPH_C32(0xa609241f), SPH_C32(0x56639098), SPH_C32(0xab938c2c), + SPH_C32(0x85b024ed) }, + { SPH_C32(0x6b8b0002), SPH_C32(0x69564600), SPH_C32(0xff460000), + SPH_C32(0xd9800000), SPH_C32(0x93ce236f), SPH_C32(0xc2dae8e1), + SPH_C32(0xf1612784), SPH_C32(0x69f8a99d), SPH_C32(0x43150005), + SPH_C32(0x99e61100), SPH_C32(0x00350000), SPH_C32(0x70810000), + SPH_C32(0x9a44519f), SPH_C32(0xdb38f40b), SPH_C32(0xdb0b3c8a), + SPH_C32(0x9f423b0c) }, + { SPH_C32(0xa6120002), SPH_C32(0xbdac6700), SPH_C32(0x5c780000), + SPH_C32(0xbcc40000), SPH_C32(0x4a371523), SPH_C32(0x255c120a), + SPH_C32(0x8022f511), SPH_C32(0x02e624dd), SPH_C32(0x6f560005), + SPH_C32(0x319e0300), SPH_C32(0x50290000), SPH_C32(0x48ec0000), + SPH_C32(0xa50b6138), SPH_C32(0x99136c6a), SPH_C32(0x1fd0973b), + SPH_C32(0x00cf18c6) }, + { SPH_C32(0x1e2f0002), SPH_C32(0xabdd6100), SPH_C32(0x6be20000), + SPH_C32(0x49750000), SPH_C32(0x68b6748f), SPH_C32(0x8b14e34f), + SPH_C32(0xe606e307), SPH_C32(0xc727cfe3), SPH_C32(0x92730005), + SPH_C32(0x825a1200), SPH_C32(0x9ed90000), SPH_C32(0x86150000), + SPH_C32(0x994614b8), SPH_C32(0x144808f9), SPH_C32(0x6f48279d), + SPH_C32(0x1a3d0727) }, + { SPH_C32(0x02d00002), SPH_C32(0x649b4300), SPH_C32(0x56300000), + SPH_C32(0xdaa50000), SPH_C32(0xb24d07e4), SPH_C32(0xa3e2e556), + SPH_C32(0x23062a85), SPH_C32(0x29467e88), SPH_C32(0x1af20005), + SPH_C32(0xf3152400), SPH_C32(0xc48d0000), SPH_C32(0xd8190000), + SPH_C32(0x5e7336d8), SPH_C32(0xd0dd67c4), SPH_C32(0x08b753b8), + SPH_C32(0xae107eb8) }, + { SPH_C32(0xbaed0002), SPH_C32(0x72ea4500), SPH_C32(0x61aa0000), + SPH_C32(0x2f140000), SPH_C32(0x90cc6648), SPH_C32(0x0daa1413), + SPH_C32(0x45223c93), SPH_C32(0xec8795b6), SPH_C32(0xe7d70005), + SPH_C32(0x40d13500), SPH_C32(0x0a7d0000), SPH_C32(0x16e00000), + SPH_C32(0x623e4358), SPH_C32(0x5d860357), SPH_C32(0x782fe31e), + SPH_C32(0xb4e26159) }, + { SPH_C32(0x77740002), SPH_C32(0xa6106400), SPH_C32(0xc2940000), + SPH_C32(0x4a500000), SPH_C32(0x49355004), SPH_C32(0xea2ceef8), + SPH_C32(0x3461ee06), SPH_C32(0x879918f6), SPH_C32(0xcb940005), + SPH_C32(0xe8a92700), SPH_C32(0x5a610000), SPH_C32(0x2e8d0000), + SPH_C32(0x5d7173ff), SPH_C32(0x1fad9b36), SPH_C32(0xbcf448af), + SPH_C32(0x2b6f4293) }, + { SPH_C32(0xcf490002), SPH_C32(0xb0616200), SPH_C32(0xf50e0000), + SPH_C32(0xbfe10000), SPH_C32(0x6bb431a8), SPH_C32(0x44641fbd), + SPH_C32(0x5245f810), SPH_C32(0x4258f3c8), SPH_C32(0x36b10005), + SPH_C32(0x5b6d3600), SPH_C32(0x94910000), SPH_C32(0xe0740000), + SPH_C32(0x613c067f), SPH_C32(0x92f6ffa5), SPH_C32(0xcc6cf809), + SPH_C32(0x319d5d72) }, + { SPH_C32(0x48b00000), SPH_C32(0x1e61c000), SPH_C32(0xeac20000), + SPH_C32(0x31450000), SPH_C32(0x873e1fe4), SPH_C32(0x5cdb4536), + SPH_C32(0x66560735), SPH_C32(0x52259edc), SPH_C32(0xcbf90006), + SPH_C32(0x2432c000), SPH_C32(0x1fe50000), SPH_C32(0x04920000), + SPH_C32(0x2dcd0b21), SPH_C32(0xd13b27cf), SPH_C32(0x10bbfa31), + SPH_C32(0x85070ac6) }, + { SPH_C32(0xf08d0000), SPH_C32(0x0810c600), SPH_C32(0xdd580000), + SPH_C32(0xc4f40000), SPH_C32(0xa5bf7e48), SPH_C32(0xf293b473), + SPH_C32(0x00721123), SPH_C32(0x97e475e2), SPH_C32(0x36dc0006), + SPH_C32(0x97f6d100), SPH_C32(0xd1150000), SPH_C32(0xca6b0000), + SPH_C32(0x11807ea1), SPH_C32(0x5c60435c), SPH_C32(0x60234a97), + SPH_C32(0x9ff51527) }, + { SPH_C32(0x3d140000), SPH_C32(0xdceae700), SPH_C32(0x7e660000), + SPH_C32(0xa1b00000), SPH_C32(0x7c464804), SPH_C32(0x15154e98), + SPH_C32(0x7131c3b6), SPH_C32(0xfcfaf8a2), SPH_C32(0x1a9f0006), + SPH_C32(0x3f8ec300), SPH_C32(0x81090000), SPH_C32(0xf2060000), + SPH_C32(0x2ecf4e06), SPH_C32(0x1e4bdb3d), SPH_C32(0xa4f8e126), + SPH_C32(0x007836ed) }, + { SPH_C32(0x85290000), SPH_C32(0xca9be100), SPH_C32(0x49fc0000), + SPH_C32(0x54010000), SPH_C32(0x5ec729a8), SPH_C32(0xbb5dbfdd), + SPH_C32(0x1715d5a0), SPH_C32(0x393b139c), SPH_C32(0xe7ba0006), + SPH_C32(0x8c4ad200), SPH_C32(0x4ff90000), SPH_C32(0x3cff0000), + SPH_C32(0x12823b86), SPH_C32(0x9310bfae), SPH_C32(0xd4605180), + SPH_C32(0x1a8a290c) }, + { SPH_C32(0x99d60000), SPH_C32(0x05ddc300), SPH_C32(0x742e0000), + SPH_C32(0xc7d10000), SPH_C32(0x843c5ac3), SPH_C32(0x93abb9c4), + SPH_C32(0xd2151c22), SPH_C32(0xd75aa2f7), SPH_C32(0x6f3b0006), + SPH_C32(0xfd05e400), SPH_C32(0x15ad0000), SPH_C32(0x62f30000), + SPH_C32(0xd5b719e6), SPH_C32(0x5785d093), SPH_C32(0xb39f25a5), + SPH_C32(0xaea75093) }, + { SPH_C32(0x21eb0000), SPH_C32(0x13acc500), SPH_C32(0x43b40000), + SPH_C32(0x32600000), SPH_C32(0xa6bd3b6f), SPH_C32(0x3de34881), + SPH_C32(0xb4310a34), SPH_C32(0x129b49c9), SPH_C32(0x921e0006), + SPH_C32(0x4ec1f500), SPH_C32(0xdb5d0000), SPH_C32(0xac0a0000), + SPH_C32(0xe9fa6c66), SPH_C32(0xdadeb400), SPH_C32(0xc3079503), + SPH_C32(0xb4554f72) }, + { SPH_C32(0xec720000), SPH_C32(0xc756e400), SPH_C32(0xe08a0000), + SPH_C32(0x57240000), SPH_C32(0x7f440d23), SPH_C32(0xda65b26a), + SPH_C32(0xc572d8a1), SPH_C32(0x7985c489), SPH_C32(0xbe5d0006), + SPH_C32(0xe6b9e700), SPH_C32(0x8b410000), SPH_C32(0x94670000), + SPH_C32(0xd6b55cc1), SPH_C32(0x98f52c61), SPH_C32(0x07dc3eb2), + SPH_C32(0x2bd86cb8) }, + { SPH_C32(0x544f0000), SPH_C32(0xd127e200), SPH_C32(0xd7100000), + SPH_C32(0xa2950000), SPH_C32(0x5dc56c8f), SPH_C32(0x742d432f), + SPH_C32(0xa356ceb7), SPH_C32(0xbc442fb7), SPH_C32(0x43780006), + SPH_C32(0x557df600), SPH_C32(0x45b10000), SPH_C32(0x5a9e0000), + SPH_C32(0xeaf82941), SPH_C32(0x15ae48f2), SPH_C32(0x77448e14), + SPH_C32(0x312a7359) }, + { SPH_C32(0x3d790003), SPH_C32(0x10710000), SPH_C32(0x3be20000), + SPH_C32(0x8baf0000), SPH_C32(0x0cfa30da), SPH_C32(0xdb83f261), + SPH_C32(0xdd7e7128), SPH_C32(0x5292b0f7), SPH_C32(0x25360007), + SPH_C32(0x4b648000), SPH_C32(0xecdb0000), SPH_C32(0xa30c0000), + SPH_C32(0x90787938), SPH_C32(0x662acc0a), SPH_C32(0x5a80ba8b), + SPH_C32(0x7bacf892) }, + { SPH_C32(0x85440003), SPH_C32(0x06000600), SPH_C32(0x0c780000), + SPH_C32(0x7e1e0000), SPH_C32(0x2e7b5176), SPH_C32(0x75cb0324), + SPH_C32(0xbb5a673e), SPH_C32(0x97535bc9), SPH_C32(0xd8130007), + SPH_C32(0xf8a09100), SPH_C32(0x222b0000), SPH_C32(0x6df50000), + SPH_C32(0xac350cb8), SPH_C32(0xeb71a899), SPH_C32(0x2a180a2d), + SPH_C32(0x615ee773) }, + { SPH_C32(0x48dd0003), SPH_C32(0xd2fa2700), SPH_C32(0xaf460000), + SPH_C32(0x1b5a0000), SPH_C32(0xf782673a), SPH_C32(0x924df9cf), + SPH_C32(0xca19b5ab), SPH_C32(0xfc4dd689), SPH_C32(0xf4500007), + SPH_C32(0x50d88300), SPH_C32(0x72370000), SPH_C32(0x55980000), + SPH_C32(0x937a3c1f), SPH_C32(0xa95a30f8), SPH_C32(0xeec3a19c), + SPH_C32(0xfed3c4b9) }, + { SPH_C32(0xf0e00003), SPH_C32(0xc48b2100), SPH_C32(0x98dc0000), + SPH_C32(0xeeeb0000), SPH_C32(0xd5030696), SPH_C32(0x3c05088a), + SPH_C32(0xac3da3bd), SPH_C32(0x398c3db7), SPH_C32(0x09750007), + SPH_C32(0xe31c9200), SPH_C32(0xbcc70000), SPH_C32(0x9b610000), + SPH_C32(0xaf37499f), SPH_C32(0x2401546b), SPH_C32(0x9e5b113a), + SPH_C32(0xe421db58) }, + { SPH_C32(0xec1f0003), SPH_C32(0x0bcd0300), SPH_C32(0xa50e0000), + SPH_C32(0x7d3b0000), SPH_C32(0x0ff875fd), SPH_C32(0x14f30e93), + SPH_C32(0x693d6a3f), SPH_C32(0xd7ed8cdc), SPH_C32(0x81f40007), + SPH_C32(0x9253a400), SPH_C32(0xe6930000), SPH_C32(0xc56d0000), + SPH_C32(0x68026bff), SPH_C32(0xe0943b56), SPH_C32(0xf9a4651f), + SPH_C32(0x500ca2c7) }, + { SPH_C32(0x54220003), SPH_C32(0x1dbc0500), SPH_C32(0x92940000), + SPH_C32(0x888a0000), SPH_C32(0x2d791451), SPH_C32(0xbabbffd6), + SPH_C32(0x0f197c29), SPH_C32(0x122c67e2), SPH_C32(0x7cd10007), + SPH_C32(0x2197b500), SPH_C32(0x28630000), SPH_C32(0x0b940000), + SPH_C32(0x544f1e7f), SPH_C32(0x6dcf5fc5), SPH_C32(0x893cd5b9), + SPH_C32(0x4afebd26) }, + { SPH_C32(0x99bb0003), SPH_C32(0xc9462400), SPH_C32(0x31aa0000), + SPH_C32(0xedce0000), SPH_C32(0xf480221d), SPH_C32(0x5d3d053d), + SPH_C32(0x7e5aaebc), SPH_C32(0x7932eaa2), SPH_C32(0x50920007), + SPH_C32(0x89efa700), SPH_C32(0x787f0000), SPH_C32(0x33f90000), + SPH_C32(0x6b002ed8), SPH_C32(0x2fe4c7a4), SPH_C32(0x4de77e08), + SPH_C32(0xd5739eec) }, + { SPH_C32(0x21860003), SPH_C32(0xdf372200), SPH_C32(0x06300000), + SPH_C32(0x187f0000), SPH_C32(0xd60143b1), SPH_C32(0xf375f478), + SPH_C32(0x187eb8aa), SPH_C32(0xbcf3019c), SPH_C32(0xadb70007), + SPH_C32(0x3a2bb600), SPH_C32(0xb68f0000), SPH_C32(0xfd000000), + SPH_C32(0x574d5b58), SPH_C32(0xa2bfa337), SPH_C32(0x3d7fceae), + SPH_C32(0xcf81810d) }, + { SPH_C32(0x50ff0004), SPH_C32(0x45744000), SPH_C32(0x3dfb0000), + SPH_C32(0x19e60000), SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), + SPH_C32(0xe1a8cc96), SPH_C32(0x7b1bd6b9), SPH_C32(0xf6800005), + SPH_C32(0x3443c000), SPH_C32(0x24070000), SPH_C32(0x8f3d0000), + SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), SPH_C32(0xcdc58b19), + SPH_C32(0xd795ba31) }, + { SPH_C32(0xe8c20004), SPH_C32(0x53054600), SPH_C32(0x0a610000), + SPH_C32(0xec570000), SPH_C32(0x393d37aa), SPH_C32(0x4f3a8a18), + SPH_C32(0x878cda80), SPH_C32(0xbeda3d87), SPH_C32(0x0ba50005), + SPH_C32(0x8787d100), SPH_C32(0xeaf70000), SPH_C32(0x41c40000), + SPH_C32(0x1d7a4e7b), SPH_C32(0x87e3b13d), SPH_C32(0xbd5d3bbf), + SPH_C32(0xcd67a5d0) }, + { SPH_C32(0x255b0004), SPH_C32(0x87ff6700), SPH_C32(0xa95f0000), + SPH_C32(0x89130000), SPH_C32(0xe0c401e6), SPH_C32(0xa8bc70f3), + SPH_C32(0xf6cf0815), SPH_C32(0xd5c4b0c7), SPH_C32(0x27e60005), + SPH_C32(0x2fffc300), SPH_C32(0xbaeb0000), SPH_C32(0x79a90000), + SPH_C32(0x22357edc), SPH_C32(0xc5c8295c), SPH_C32(0x7986900e), + SPH_C32(0x52ea861a) }, + { SPH_C32(0x9d660004), SPH_C32(0x918e6100), SPH_C32(0x9ec50000), + SPH_C32(0x7ca20000), SPH_C32(0xc245604a), SPH_C32(0x06f481b6), + SPH_C32(0x90eb1e03), SPH_C32(0x10055bf9), SPH_C32(0xdac30005), + SPH_C32(0x9c3bd200), SPH_C32(0x741b0000), SPH_C32(0xb7500000), + SPH_C32(0x1e780b5c), SPH_C32(0x48934dcf), SPH_C32(0x091e20a8), + SPH_C32(0x481899fb) }, + { SPH_C32(0x81990004), SPH_C32(0x5ec84300), SPH_C32(0xa3170000), + SPH_C32(0xef720000), SPH_C32(0x18be1321), SPH_C32(0x2e0287af), + SPH_C32(0x55ebd781), SPH_C32(0xfe64ea92), SPH_C32(0x52420005), + SPH_C32(0xed74e400), SPH_C32(0x2e4f0000), SPH_C32(0xe95c0000), + SPH_C32(0xd94d293c), SPH_C32(0x8c0622f2), SPH_C32(0x6ee1548d), + SPH_C32(0xfc35e064) }, + { SPH_C32(0x39a40004), SPH_C32(0x48b94500), SPH_C32(0x948d0000), + SPH_C32(0x1ac30000), SPH_C32(0x3a3f728d), SPH_C32(0x804a76ea), + SPH_C32(0x33cfc197), SPH_C32(0x3ba501ac), SPH_C32(0xaf670005), + SPH_C32(0x5eb0f500), SPH_C32(0xe0bf0000), SPH_C32(0x27a50000), + SPH_C32(0xe5005cbc), SPH_C32(0x015d4661), SPH_C32(0x1e79e42b), + SPH_C32(0xe6c7ff85) }, + { SPH_C32(0xf43d0004), SPH_C32(0x9c436400), SPH_C32(0x37b30000), + SPH_C32(0x7f870000), SPH_C32(0xe3c644c1), SPH_C32(0x67cc8c01), + SPH_C32(0x428c1302), SPH_C32(0x50bb8cec), SPH_C32(0x83240005), + SPH_C32(0xf6c8e700), SPH_C32(0xb0a30000), SPH_C32(0x1fc80000), + SPH_C32(0xda4f6c1b), SPH_C32(0x4376de00), SPH_C32(0xdaa24f9a), + SPH_C32(0x794adc4f) }, + { SPH_C32(0x4c000004), SPH_C32(0x8a326200), SPH_C32(0x00290000), + SPH_C32(0x8a360000), SPH_C32(0xc147256d), SPH_C32(0xc9847d44), + SPH_C32(0x24a80514), SPH_C32(0x957a67d2), SPH_C32(0x7e010005), + SPH_C32(0x450cf600), SPH_C32(0x7e530000), SPH_C32(0xd1310000), + SPH_C32(0xe602199b), SPH_C32(0xce2dba93), SPH_C32(0xaa3aff3c), + SPH_C32(0x63b8c3ae) }, + { SPH_C32(0x25360007), SPH_C32(0x4b648000), SPH_C32(0xecdb0000), + SPH_C32(0xa30c0000), SPH_C32(0x90787938), SPH_C32(0x662acc0a), + SPH_C32(0x5a80ba8b), SPH_C32(0x7bacf892), SPH_C32(0x184f0004), + SPH_C32(0x5b158000), SPH_C32(0xd7390000), SPH_C32(0x28a30000), + SPH_C32(0x9c8249e2), SPH_C32(0xbda93e6b), SPH_C32(0x87fecba3), + SPH_C32(0x293e4865) }, + { SPH_C32(0x9d0b0007), SPH_C32(0x5d158600), SPH_C32(0xdb410000), + SPH_C32(0x56bd0000), SPH_C32(0xb2f91894), SPH_C32(0xc8623d4f), + SPH_C32(0x3ca4ac9d), SPH_C32(0xbe6d13ac), SPH_C32(0xe56a0004), + SPH_C32(0xe8d19100), SPH_C32(0x19c90000), SPH_C32(0xe65a0000), + SPH_C32(0xa0cf3c62), SPH_C32(0x30f25af8), SPH_C32(0xf7667b05), + SPH_C32(0x33cc5784) }, + { SPH_C32(0x50920007), SPH_C32(0x89efa700), SPH_C32(0x787f0000), + SPH_C32(0x33f90000), SPH_C32(0x6b002ed8), SPH_C32(0x2fe4c7a4), + SPH_C32(0x4de77e08), SPH_C32(0xd5739eec), SPH_C32(0xc9290004), + SPH_C32(0x40a98300), SPH_C32(0x49d50000), SPH_C32(0xde370000), + SPH_C32(0x9f800cc5), SPH_C32(0x72d9c299), SPH_C32(0x33bdd0b4), + SPH_C32(0xac41744e) }, + { SPH_C32(0xe8af0007), SPH_C32(0x9f9ea100), SPH_C32(0x4fe50000), + SPH_C32(0xc6480000), SPH_C32(0x49814f74), SPH_C32(0x81ac36e1), + SPH_C32(0x2bc3681e), SPH_C32(0x10b275d2), SPH_C32(0x340c0004), + SPH_C32(0xf36d9200), SPH_C32(0x87250000), SPH_C32(0x10ce0000), + SPH_C32(0xa3cd7945), SPH_C32(0xff82a60a), SPH_C32(0x43256012), + SPH_C32(0xb6b36baf) }, + { SPH_C32(0xf4500007), SPH_C32(0x50d88300), SPH_C32(0x72370000), + SPH_C32(0x55980000), SPH_C32(0x937a3c1f), SPH_C32(0xa95a30f8), + SPH_C32(0xeec3a19c), SPH_C32(0xfed3c4b9), SPH_C32(0xbc8d0004), + SPH_C32(0x8222a400), SPH_C32(0xdd710000), SPH_C32(0x4ec20000), + SPH_C32(0x64f85b25), SPH_C32(0x3b17c937), SPH_C32(0x24da1437), + SPH_C32(0x029e1230) }, + { SPH_C32(0x4c6d0007), SPH_C32(0x46a98500), SPH_C32(0x45ad0000), + SPH_C32(0xa0290000), SPH_C32(0xb1fb5db3), SPH_C32(0x0712c1bd), + SPH_C32(0x88e7b78a), SPH_C32(0x3b122f87), SPH_C32(0x41a80004), + SPH_C32(0x31e6b500), SPH_C32(0x13810000), SPH_C32(0x803b0000), + SPH_C32(0x58b52ea5), SPH_C32(0xb64cada4), SPH_C32(0x5442a491), + SPH_C32(0x186c0dd1) }, + { SPH_C32(0x81f40007), SPH_C32(0x9253a400), SPH_C32(0xe6930000), + SPH_C32(0xc56d0000), SPH_C32(0x68026bff), SPH_C32(0xe0943b56), + SPH_C32(0xf9a4651f), SPH_C32(0x500ca2c7), SPH_C32(0x6deb0004), + SPH_C32(0x999ea700), SPH_C32(0x439d0000), SPH_C32(0xb8560000), + SPH_C32(0x67fa1e02), SPH_C32(0xf46735c5), SPH_C32(0x90990f20), + SPH_C32(0x87e12e1b) }, + { SPH_C32(0x39c90007), SPH_C32(0x8422a200), SPH_C32(0xd1090000), + SPH_C32(0x30dc0000), SPH_C32(0x4a830a53), SPH_C32(0x4edcca13), + SPH_C32(0x9f807309), SPH_C32(0x95cd49f9), SPH_C32(0x90ce0004), + SPH_C32(0x2a5ab600), SPH_C32(0x8d6d0000), SPH_C32(0x76af0000), + SPH_C32(0x5bb76b82), SPH_C32(0x793c5156), SPH_C32(0xe001bf86), + SPH_C32(0x9d1331fa) }, + { SPH_C32(0xbe300005), SPH_C32(0x2a220000), SPH_C32(0xcec50000), + SPH_C32(0xbe780000), SPH_C32(0xa609241f), SPH_C32(0x56639098), + SPH_C32(0xab938c2c), SPH_C32(0x85b024ed), SPH_C32(0x6d860007), + SPH_C32(0x55054000), SPH_C32(0x06190000), SPH_C32(0x92490000), + SPH_C32(0x174666dc), SPH_C32(0x3af1893c), SPH_C32(0x3cd6bdbe), + SPH_C32(0x2989664e) }, + { SPH_C32(0x060d0005), SPH_C32(0x3c530600), SPH_C32(0xf95f0000), + SPH_C32(0x4bc90000), SPH_C32(0x848845b3), SPH_C32(0xf82b61dd), + SPH_C32(0xcdb79a3a), SPH_C32(0x4071cfd3), SPH_C32(0x90a30007), + SPH_C32(0xe6c15100), SPH_C32(0xc8e90000), SPH_C32(0x5cb00000), + SPH_C32(0x2b0b135c), SPH_C32(0xb7aaedaf), SPH_C32(0x4c4e0d18), + SPH_C32(0x337b79af) }, + { SPH_C32(0xcb940005), SPH_C32(0xe8a92700), SPH_C32(0x5a610000), + SPH_C32(0x2e8d0000), SPH_C32(0x5d7173ff), SPH_C32(0x1fad9b36), + SPH_C32(0xbcf448af), SPH_C32(0x2b6f4293), SPH_C32(0xbce00007), + SPH_C32(0x4eb94300), SPH_C32(0x98f50000), SPH_C32(0x64dd0000), + SPH_C32(0x144423fb), SPH_C32(0xf58175ce), SPH_C32(0x8895a6a9), + SPH_C32(0xacf65a65) }, + { SPH_C32(0x73a90005), SPH_C32(0xfed82100), SPH_C32(0x6dfb0000), + SPH_C32(0xdb3c0000), SPH_C32(0x7ff01253), SPH_C32(0xb1e56a73), + SPH_C32(0xdad05eb9), SPH_C32(0xeeaea9ad), SPH_C32(0x41c50007), + SPH_C32(0xfd7d5200), SPH_C32(0x56050000), SPH_C32(0xaa240000), + SPH_C32(0x2809567b), SPH_C32(0x78da115d), SPH_C32(0xf80d160f), + SPH_C32(0xb6044584) }, + { SPH_C32(0x6f560005), SPH_C32(0x319e0300), SPH_C32(0x50290000), + SPH_C32(0x48ec0000), SPH_C32(0xa50b6138), SPH_C32(0x99136c6a), + SPH_C32(0x1fd0973b), SPH_C32(0x00cf18c6), SPH_C32(0xc9440007), + SPH_C32(0x8c326400), SPH_C32(0x0c510000), SPH_C32(0xf4280000), + SPH_C32(0xef3c741b), SPH_C32(0xbc4f7e60), SPH_C32(0x9ff2622a), + SPH_C32(0x02293c1b) }, + { SPH_C32(0xd76b0005), SPH_C32(0x27ef0500), SPH_C32(0x67b30000), + SPH_C32(0xbd5d0000), SPH_C32(0x878a0094), SPH_C32(0x375b9d2f), + SPH_C32(0x79f4812d), SPH_C32(0xc50ef3f8), SPH_C32(0x34610007), + SPH_C32(0x3ff67500), SPH_C32(0xc2a10000), SPH_C32(0x3ad10000), + SPH_C32(0xd371019b), SPH_C32(0x31141af3), SPH_C32(0xef6ad28c), + SPH_C32(0x18db23fa) }, + { SPH_C32(0x1af20005), SPH_C32(0xf3152400), SPH_C32(0xc48d0000), + SPH_C32(0xd8190000), SPH_C32(0x5e7336d8), SPH_C32(0xd0dd67c4), + SPH_C32(0x08b753b8), SPH_C32(0xae107eb8), SPH_C32(0x18220007), + SPH_C32(0x978e6700), SPH_C32(0x92bd0000), SPH_C32(0x02bc0000), + SPH_C32(0xec3e313c), SPH_C32(0x733f8292), SPH_C32(0x2bb1793d), + SPH_C32(0x87560030) }, + { SPH_C32(0xa2cf0005), SPH_C32(0xe5642200), SPH_C32(0xf3170000), + SPH_C32(0x2da80000), SPH_C32(0x7cf25774), SPH_C32(0x7e959681), + SPH_C32(0x6e9345ae), SPH_C32(0x6bd19586), SPH_C32(0xe5070007), + SPH_C32(0x244a7600), SPH_C32(0x5c4d0000), SPH_C32(0xcc450000), + SPH_C32(0xd07344bc), SPH_C32(0xfe64e601), SPH_C32(0x5b29c99b), + SPH_C32(0x9da41fd1) }, + { SPH_C32(0xcbf90006), SPH_C32(0x2432c000), SPH_C32(0x1fe50000), + SPH_C32(0x04920000), SPH_C32(0x2dcd0b21), SPH_C32(0xd13b27cf), + SPH_C32(0x10bbfa31), SPH_C32(0x85070ac6), SPH_C32(0x83490006), + SPH_C32(0x3a530000), SPH_C32(0xf5270000), SPH_C32(0x35d70000), + SPH_C32(0xaaf314c5), SPH_C32(0x8de062f9), SPH_C32(0x76edfd04), + SPH_C32(0xd722941a) }, + { SPH_C32(0x73c40006), SPH_C32(0x3243c600), SPH_C32(0x287f0000), + SPH_C32(0xf1230000), SPH_C32(0x0f4c6a8d), SPH_C32(0x7f73d68a), + SPH_C32(0x769fec27), SPH_C32(0x40c6e1f8), SPH_C32(0x7e6c0006), + SPH_C32(0x89971100), SPH_C32(0x3bd70000), SPH_C32(0xfb2e0000), + SPH_C32(0x96be6145), SPH_C32(0x00bb066a), SPH_C32(0x06754da2), + SPH_C32(0xcdd08bfb) }, + { SPH_C32(0xbe5d0006), SPH_C32(0xe6b9e700), SPH_C32(0x8b410000), + SPH_C32(0x94670000), SPH_C32(0xd6b55cc1), SPH_C32(0x98f52c61), + SPH_C32(0x07dc3eb2), SPH_C32(0x2bd86cb8), SPH_C32(0x522f0006), + SPH_C32(0x21ef0300), SPH_C32(0x6bcb0000), SPH_C32(0xc3430000), + SPH_C32(0xa9f151e2), SPH_C32(0x42909e0b), SPH_C32(0xc2aee613), + SPH_C32(0x525da831) }, + { SPH_C32(0x06600006), SPH_C32(0xf0c8e100), SPH_C32(0xbcdb0000), + SPH_C32(0x61d60000), SPH_C32(0xf4343d6d), SPH_C32(0x36bddd24), + SPH_C32(0x61f828a4), SPH_C32(0xee198786), SPH_C32(0xaf0a0006), + SPH_C32(0x922b1200), SPH_C32(0xa53b0000), SPH_C32(0x0dba0000), + SPH_C32(0x95bc2462), SPH_C32(0xcfcbfa98), SPH_C32(0xb23656b5), + SPH_C32(0x48afb7d0) }, + { SPH_C32(0x1a9f0006), SPH_C32(0x3f8ec300), SPH_C32(0x81090000), + SPH_C32(0xf2060000), SPH_C32(0x2ecf4e06), SPH_C32(0x1e4bdb3d), + SPH_C32(0xa4f8e126), SPH_C32(0x007836ed), SPH_C32(0x278b0006), + SPH_C32(0xe3642400), SPH_C32(0xff6f0000), SPH_C32(0x53b60000), + SPH_C32(0x52890602), SPH_C32(0x0b5e95a5), SPH_C32(0xd5c92290), + SPH_C32(0xfc82ce4f) }, + { SPH_C32(0xa2a20006), SPH_C32(0x29ffc500), SPH_C32(0xb6930000), + SPH_C32(0x07b70000), SPH_C32(0x0c4e2faa), SPH_C32(0xb0032a78), + SPH_C32(0xc2dcf730), SPH_C32(0xc5b9ddd3), SPH_C32(0xdaae0006), + SPH_C32(0x50a03500), SPH_C32(0x319f0000), SPH_C32(0x9d4f0000), + SPH_C32(0x6ec47382), SPH_C32(0x8605f136), SPH_C32(0xa5519236), + SPH_C32(0xe670d1ae) }, + { SPH_C32(0x6f3b0006), SPH_C32(0xfd05e400), SPH_C32(0x15ad0000), + SPH_C32(0x62f30000), SPH_C32(0xd5b719e6), SPH_C32(0x5785d093), + SPH_C32(0xb39f25a5), SPH_C32(0xaea75093), SPH_C32(0xf6ed0006), + SPH_C32(0xf8d82700), SPH_C32(0x61830000), SPH_C32(0xa5220000), + SPH_C32(0x518b4325), SPH_C32(0xc42e6957), SPH_C32(0x618a3987), + SPH_C32(0x79fdf264) }, + { SPH_C32(0xd7060006), SPH_C32(0xeb74e200), SPH_C32(0x22370000), + SPH_C32(0x97420000), SPH_C32(0xf736784a), SPH_C32(0xf9cd21d6), + SPH_C32(0xd5bb33b3), SPH_C32(0x6b66bbad), SPH_C32(0x0bc80006), + SPH_C32(0x4b1c3600), SPH_C32(0xaf730000), SPH_C32(0x6bdb0000), + SPH_C32(0x6dc636a5), SPH_C32(0x49750dc4), SPH_C32(0x11128921), + SPH_C32(0x630fed85) } +}; + +static const sph_u32 T512_21[128][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x54500000), SPH_C32(0x0671005c), SPH_C32(0x25ae0000), + SPH_C32(0x6a1e0000), SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), + SPH_C32(0xbfba18c3), SPH_C32(0x7e715d17), SPH_C32(0xbc8d0000), + SPH_C32(0xfc3b0018), SPH_C32(0x19830000), SPH_C32(0xd10b0000), + SPH_C32(0xae1878c4), SPH_C32(0x42a69856), SPH_C32(0x0012da37), + SPH_C32(0x2c3b504e) }, + { SPH_C32(0xbc8d0000), SPH_C32(0xfc3b0018), SPH_C32(0x19830000), + SPH_C32(0xd10b0000), SPH_C32(0xae1878c4), SPH_C32(0x42a69856), + SPH_C32(0x0012da37), SPH_C32(0x2c3b504e), SPH_C32(0xe8dd0000), + SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), SPH_C32(0xbb150000), + SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), SPH_C32(0xbfa8c2f4), + SPH_C32(0x524a0d59) }, + { SPH_C32(0xe8dd0000), SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), + SPH_C32(0xbb150000), SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), + SPH_C32(0xbfa8c2f4), SPH_C32(0x524a0d59), SPH_C32(0x54500000), + SPH_C32(0x0671005c), SPH_C32(0x25ae0000), SPH_C32(0x6a1e0000), + SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), SPH_C32(0xbfba18c3), + SPH_C32(0x7e715d17) }, + { SPH_C32(0x69510000), SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), + SPH_C32(0xac2f0000), SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), + SPH_C32(0x87ec287c), SPH_C32(0xbce1a3ce), SPH_C32(0xc6730000), + SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), SPH_C32(0x218d0000), + SPH_C32(0x23111587), SPH_C32(0x7913512f), SPH_C32(0x1d28ac88), + SPH_C32(0x378dd173) }, + { SPH_C32(0x3d010000), SPH_C32(0xd29000c0), SPH_C32(0xe68d0000), + SPH_C32(0xc6310000), SPH_C32(0xca304571), SPH_C32(0xa8ea90ce), + SPH_C32(0x385630bf), SPH_C32(0xc290fed9), SPH_C32(0x7afe0000), + SPH_C32(0x53b60014), SPH_C32(0xbd420000), SPH_C32(0xf0860000), + SPH_C32(0x8d096d43), SPH_C32(0x3bb5c979), SPH_C32(0x1d3a76bf), + SPH_C32(0x1bb6813d) }, + { SPH_C32(0xd5dc0000), SPH_C32(0x28da0084), SPH_C32(0xdaa00000), + SPH_C32(0x7d240000), SPH_C32(0x4a8d736a), SPH_C32(0x8c028d8a), + SPH_C32(0x87fef24b), SPH_C32(0x90daf380), SPH_C32(0x2eae0000), + SPH_C32(0x55c70048), SPH_C32(0x98ec0000), SPH_C32(0x9a980000), + SPH_C32(0xa3ac239c), SPH_C32(0x5dfb4c6b), SPH_C32(0xa2806e7c), + SPH_C32(0x65c7dc2a) }, + { SPH_C32(0x818c0000), SPH_C32(0x2eab00d8), SPH_C32(0xff0e0000), + SPH_C32(0x173a0000), SPH_C32(0x64283db5), SPH_C32(0xea4c0898), + SPH_C32(0x3844ea88), SPH_C32(0xeeabae97), SPH_C32(0x92230000), + SPH_C32(0xa9fc0050), SPH_C32(0x816f0000), SPH_C32(0x4b930000), + SPH_C32(0x0db45b58), SPH_C32(0x1f5dd43d), SPH_C32(0xa292b44b), + SPH_C32(0x49fc8c64) }, + { SPH_C32(0xc6730000), SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), + SPH_C32(0x218d0000), SPH_C32(0x23111587), SPH_C32(0x7913512f), + SPH_C32(0x1d28ac88), SPH_C32(0x378dd173), SPH_C32(0xaf220000), + SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), SPH_C32(0x8da20000), + SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), SPH_C32(0x9ac484f4), + SPH_C32(0x8b6c72bd) }, + { SPH_C32(0x92230000), SPH_C32(0xa9fc0050), SPH_C32(0x816f0000), + SPH_C32(0x4b930000), SPH_C32(0x0db45b58), SPH_C32(0x1f5dd43d), + SPH_C32(0xa292b44b), SPH_C32(0x49fc8c64), SPH_C32(0x13af0000), + SPH_C32(0x87570088), SPH_C32(0x7e610000), SPH_C32(0x5ca90000), + SPH_C32(0x699c66ed), SPH_C32(0xf511dca5), SPH_C32(0x9ad65ec3), + SPH_C32(0xa75722f3) }, + { SPH_C32(0x7afe0000), SPH_C32(0x53b60014), SPH_C32(0xbd420000), + SPH_C32(0xf0860000), SPH_C32(0x8d096d43), SPH_C32(0x3bb5c979), + SPH_C32(0x1d3a76bf), SPH_C32(0x1bb6813d), SPH_C32(0x47ff0000), + SPH_C32(0x812600d4), SPH_C32(0x5bcf0000), SPH_C32(0x36b70000), + SPH_C32(0x47392832), SPH_C32(0x935f59b7), SPH_C32(0x256c4600), + SPH_C32(0xd9267fe4) }, + { SPH_C32(0x2eae0000), SPH_C32(0x55c70048), SPH_C32(0x98ec0000), + SPH_C32(0x9a980000), SPH_C32(0xa3ac239c), SPH_C32(0x5dfb4c6b), + SPH_C32(0xa2806e7c), SPH_C32(0x65c7dc2a), SPH_C32(0xfb720000), + SPH_C32(0x7d1d00cc), SPH_C32(0x424c0000), SPH_C32(0xe7bc0000), + SPH_C32(0xe92150f6), SPH_C32(0xd1f9c1e1), SPH_C32(0x257e9c37), + SPH_C32(0xf51d2faa) }, + { SPH_C32(0xaf220000), SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), + SPH_C32(0x8da20000), SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), + SPH_C32(0x9ac484f4), SPH_C32(0x8b6c72bd), SPH_C32(0x69510000), + SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), SPH_C32(0xac2f0000), + SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), SPH_C32(0x87ec287c), + SPH_C32(0xbce1a3ce) }, + { SPH_C32(0xfb720000), SPH_C32(0x7d1d00cc), SPH_C32(0x424c0000), + SPH_C32(0xe7bc0000), SPH_C32(0xe92150f6), SPH_C32(0xd1f9c1e1), + SPH_C32(0x257e9c37), SPH_C32(0xf51d2faa), SPH_C32(0xd5dc0000), + SPH_C32(0x28da0084), SPH_C32(0xdaa00000), SPH_C32(0x7d240000), + SPH_C32(0x4a8d736a), SPH_C32(0x8c028d8a), SPH_C32(0x87fef24b), + SPH_C32(0x90daf380) }, + { SPH_C32(0x13af0000), SPH_C32(0x87570088), SPH_C32(0x7e610000), + SPH_C32(0x5ca90000), SPH_C32(0x699c66ed), SPH_C32(0xf511dca5), + SPH_C32(0x9ad65ec3), SPH_C32(0xa75722f3), SPH_C32(0x818c0000), + SPH_C32(0x2eab00d8), SPH_C32(0xff0e0000), SPH_C32(0x173a0000), + SPH_C32(0x64283db5), SPH_C32(0xea4c0898), SPH_C32(0x3844ea88), + SPH_C32(0xeeabae97) }, + { SPH_C32(0x47ff0000), SPH_C32(0x812600d4), SPH_C32(0x5bcf0000), + SPH_C32(0x36b70000), SPH_C32(0x47392832), SPH_C32(0x935f59b7), + SPH_C32(0x256c4600), SPH_C32(0xd9267fe4), SPH_C32(0x3d010000), + SPH_C32(0xd29000c0), SPH_C32(0xe68d0000), SPH_C32(0xc6310000), + SPH_C32(0xca304571), SPH_C32(0xa8ea90ce), SPH_C32(0x385630bf), + SPH_C32(0xc290fed9) }, + { SPH_C32(0x0c720000), SPH_C32(0x49e50f00), SPH_C32(0x42790000), + SPH_C32(0x5cea0000), SPH_C32(0x33aa301a), SPH_C32(0x15822514), + SPH_C32(0x95a34b7b), SPH_C32(0xb44b0090), SPH_C32(0xfe220000), + SPH_C32(0xa7580500), SPH_C32(0x25d10000), SPH_C32(0xf7600000), + SPH_C32(0x893178da), SPH_C32(0x1fd4f860), SPH_C32(0x4ed0a315), + SPH_C32(0xa123ff9f) }, + { SPH_C32(0x58220000), SPH_C32(0x4f940f5c), SPH_C32(0x67d70000), + SPH_C32(0x36f40000), SPH_C32(0x1d0f7ec5), SPH_C32(0x73cca006), + SPH_C32(0x2a1953b8), SPH_C32(0xca3a5d87), SPH_C32(0x42af0000), + SPH_C32(0x5b630518), SPH_C32(0x3c520000), SPH_C32(0x266b0000), + SPH_C32(0x2729001e), SPH_C32(0x5d726036), SPH_C32(0x4ec27922), + SPH_C32(0x8d18afd1) }, + { SPH_C32(0xb0ff0000), SPH_C32(0xb5de0f18), SPH_C32(0x5bfa0000), + SPH_C32(0x8de10000), SPH_C32(0x9db248de), SPH_C32(0x5724bd42), + SPH_C32(0x95b1914c), SPH_C32(0x987050de), SPH_C32(0x16ff0000), + SPH_C32(0x5d120544), SPH_C32(0x19fc0000), SPH_C32(0x4c750000), + SPH_C32(0x098c4ec1), SPH_C32(0x3b3ce524), SPH_C32(0xf17861e1), + SPH_C32(0xf369f2c6) }, + { SPH_C32(0xe4af0000), SPH_C32(0xb3af0f44), SPH_C32(0x7e540000), + SPH_C32(0xe7ff0000), SPH_C32(0xb3170601), SPH_C32(0x316a3850), + SPH_C32(0x2a0b898f), SPH_C32(0xe6010dc9), SPH_C32(0xaa720000), + SPH_C32(0xa129055c), SPH_C32(0x007f0000), SPH_C32(0x9d7e0000), + SPH_C32(0xa7943605), SPH_C32(0x799a7d72), SPH_C32(0xf16abbd6), + SPH_C32(0xdf52a288) }, + { SPH_C32(0x65230000), SPH_C32(0x9d040f9c), SPH_C32(0x815a0000), + SPH_C32(0xf0c50000), SPH_C32(0xd73f3bb4), SPH_C32(0xdb2630c8), + SPH_C32(0x124f6307), SPH_C32(0x08aaa35e), SPH_C32(0x38510000), + SPH_C32(0x08d5050c), SPH_C32(0x81100000), SPH_C32(0xd6ed0000), + SPH_C32(0xaa206d5d), SPH_C32(0x66c7a94f), SPH_C32(0x53f80f9d), + SPH_C32(0x96ae2eec) }, + { SPH_C32(0x31730000), SPH_C32(0x9b750fc0), SPH_C32(0xa4f40000), + SPH_C32(0x9adb0000), SPH_C32(0xf99a756b), SPH_C32(0xbd68b5da), + SPH_C32(0xadf57bc4), SPH_C32(0x76dbfe49), SPH_C32(0x84dc0000), + SPH_C32(0xf4ee0514), SPH_C32(0x98930000), SPH_C32(0x07e60000), + SPH_C32(0x04381599), SPH_C32(0x24613119), SPH_C32(0x53ead5aa), + SPH_C32(0xba957ea2) }, + { SPH_C32(0xd9ae0000), SPH_C32(0x613f0f84), SPH_C32(0x98d90000), + SPH_C32(0x21ce0000), SPH_C32(0x79274370), SPH_C32(0x9980a89e), + SPH_C32(0x125db930), SPH_C32(0x2491f310), SPH_C32(0xd08c0000), + SPH_C32(0xf29f0548), SPH_C32(0xbd3d0000), SPH_C32(0x6df80000), + SPH_C32(0x2a9d5b46), SPH_C32(0x422fb40b), SPH_C32(0xec50cd69), + SPH_C32(0xc4e423b5) }, + { SPH_C32(0x8dfe0000), SPH_C32(0x674e0fd8), SPH_C32(0xbd770000), + SPH_C32(0x4bd00000), SPH_C32(0x57820daf), SPH_C32(0xffce2d8c), + SPH_C32(0xade7a1f3), SPH_C32(0x5ae0ae07), SPH_C32(0x6c010000), + SPH_C32(0x0ea40550), SPH_C32(0xa4be0000), SPH_C32(0xbcf30000), + SPH_C32(0x84852382), SPH_C32(0x00892c5d), SPH_C32(0xec42175e), + SPH_C32(0xe8df73fb) }, + { SPH_C32(0xca010000), SPH_C32(0xe6680f0c), SPH_C32(0xe6b80000), + SPH_C32(0x7d670000), SPH_C32(0x10bb259d), SPH_C32(0x6c91743b), + SPH_C32(0x888be7f3), SPH_C32(0x83c6d1e3), SPH_C32(0x51000000), + SPH_C32(0xdc340590), SPH_C32(0x42330000), SPH_C32(0x7ac20000), + SPH_C32(0x4eb566f3), SPH_C32(0xa863bc93), SPH_C32(0xd41427e1), + SPH_C32(0x2a4f8d22) }, + { SPH_C32(0x9e510000), SPH_C32(0xe0190f50), SPH_C32(0xc3160000), + SPH_C32(0x17790000), SPH_C32(0x3e1e6b42), SPH_C32(0x0adff129), + SPH_C32(0x3731ff30), SPH_C32(0xfdb78cf4), SPH_C32(0xed8d0000), + SPH_C32(0x200f0588), SPH_C32(0x5bb00000), SPH_C32(0xabc90000), + SPH_C32(0xe0ad1e37), SPH_C32(0xeac524c5), SPH_C32(0xd406fdd6), + SPH_C32(0x0674dd6c) }, + { SPH_C32(0x768c0000), SPH_C32(0x1a530f14), SPH_C32(0xff3b0000), + SPH_C32(0xac6c0000), SPH_C32(0xbea35d59), SPH_C32(0x2e37ec6d), + SPH_C32(0x88993dc4), SPH_C32(0xaffd81ad), SPH_C32(0xb9dd0000), + SPH_C32(0x267e05d4), SPH_C32(0x7e1e0000), SPH_C32(0xc1d70000), + SPH_C32(0xce0850e8), SPH_C32(0x8c8ba1d7), SPH_C32(0x6bbce515), + SPH_C32(0x7805807b) }, + { SPH_C32(0x22dc0000), SPH_C32(0x1c220f48), SPH_C32(0xda950000), + SPH_C32(0xc6720000), SPH_C32(0x90061386), SPH_C32(0x48749697f), + SPH_C32(0x37232507), SPH_C32(0xd18cdcba), SPH_C32(0x05500000), + SPH_C32(0xda4505cc), SPH_C32(0x679d0000), SPH_C32(0x10dc0000), + SPH_C32(0x6010282c), SPH_C32(0xce2d3981), SPH_C32(0x6bae3f22), + SPH_C32(0x543ed035) }, + { SPH_C32(0xa3500000), SPH_C32(0x32890f90), SPH_C32(0x259b0000), + SPH_C32(0xd1480000), SPH_C32(0xf42e2e33), SPH_C32(0xa23561e7), + SPH_C32(0x0f67cf8f), SPH_C32(0x3f27722d), SPH_C32(0x97730000), + SPH_C32(0x73b9059c), SPH_C32(0xe6f20000), SPH_C32(0x5b4f0000), + SPH_C32(0x6da47374), SPH_C32(0xd170edbc), SPH_C32(0xc93c8b69), + SPH_C32(0x1dc25c51) }, + { SPH_C32(0xf7000000), SPH_C32(0x34f80fcc), SPH_C32(0x00350000), + SPH_C32(0xbb560000), SPH_C32(0xda8b60ec), SPH_C32(0xc47be4f5), + SPH_C32(0xb0ddd74c), SPH_C32(0x41562f3a), SPH_C32(0x2bfe0000), + SPH_C32(0x8f820584), SPH_C32(0xff710000), SPH_C32(0x8a440000), + SPH_C32(0xc3bc0bb0), SPH_C32(0x93d675ea), SPH_C32(0xc92e515e), + SPH_C32(0x31f90c1f) }, + { SPH_C32(0x1fdd0000), SPH_C32(0xceb20f88), SPH_C32(0x3c180000), + SPH_C32(0x00430000), SPH_C32(0x5a3656f7), SPH_C32(0xe093f9b1), + SPH_C32(0x0f7515b8), SPH_C32(0x131c2263), SPH_C32(0x7fae0000), + SPH_C32(0x89f305d8), SPH_C32(0xdadf0000), SPH_C32(0xe05a0000), + SPH_C32(0xed19456f), SPH_C32(0xf598f0f8), SPH_C32(0x7694499d), + SPH_C32(0x4f885108) }, + { SPH_C32(0x4b8d0000), SPH_C32(0xc8c30fd4), SPH_C32(0x19b60000), + SPH_C32(0x6a5d0000), SPH_C32(0x74931828), SPH_C32(0x86dd7ca3), + SPH_C32(0xb0cf0d7b), SPH_C32(0x6d6d7f74), SPH_C32(0xc3230000), + SPH_C32(0x75c805c0), SPH_C32(0xc35c0000), SPH_C32(0x31510000), + SPH_C32(0x43013dab), SPH_C32(0xb73e68ae), SPH_C32(0x768693aa), + SPH_C32(0x63b30146) }, + { SPH_C32(0xfe220000), SPH_C32(0xa7580500), SPH_C32(0x25d10000), + SPH_C32(0xf7600000), SPH_C32(0x893178da), SPH_C32(0x1fd4f860), + SPH_C32(0x4ed0a315), SPH_C32(0xa123ff9f), SPH_C32(0xf2500000), + SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), SPH_C32(0xab8a0000), + SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), SPH_C32(0xdb73e86e), + SPH_C32(0x1568ff0f) }, + { SPH_C32(0xaa720000), SPH_C32(0xa129055c), SPH_C32(0x007f0000), + SPH_C32(0x9d7e0000), SPH_C32(0xa7943605), SPH_C32(0x799a7d72), + SPH_C32(0xf16abbd6), SPH_C32(0xdf52a288), SPH_C32(0x4edd0000), + SPH_C32(0x12860a18), SPH_C32(0x7e2b0000), SPH_C32(0x7a810000), + SPH_C32(0x14833004), SPH_C32(0x48f04522), SPH_C32(0xdb613259), + SPH_C32(0x3953af41) }, + { SPH_C32(0x42af0000), SPH_C32(0x5b630518), SPH_C32(0x3c520000), + SPH_C32(0x266b0000), SPH_C32(0x2729001e), SPH_C32(0x5d726036), + SPH_C32(0x4ec27922), SPH_C32(0x8d18afd1), SPH_C32(0x1a8d0000), + SPH_C32(0x14f70a44), SPH_C32(0x5b850000), SPH_C32(0x109f0000), + SPH_C32(0x3a267edb), SPH_C32(0x2ebec030), SPH_C32(0x64db2a9a), + SPH_C32(0x4722f256) }, + { SPH_C32(0x16ff0000), SPH_C32(0x5d120544), SPH_C32(0x19fc0000), + SPH_C32(0x4c750000), SPH_C32(0x098c4ec1), SPH_C32(0x3b3ce524), + SPH_C32(0xf17861e1), SPH_C32(0xf369f2c6), SPH_C32(0xa6000000), + SPH_C32(0xe8cc0a5c), SPH_C32(0x42060000), SPH_C32(0xc1940000), + SPH_C32(0x943e061f), SPH_C32(0x6c185866), SPH_C32(0x64c9f0ad), + SPH_C32(0x6b19a218) }, + { SPH_C32(0x97730000), SPH_C32(0x73b9059c), SPH_C32(0xe6f20000), + SPH_C32(0x5b4f0000), SPH_C32(0x6da47374), SPH_C32(0xd170edbc), + SPH_C32(0xc93c8b69), SPH_C32(0x1dc25c51), SPH_C32(0x34230000), + SPH_C32(0x41300a0c), SPH_C32(0xc3690000), SPH_C32(0x8a070000), + SPH_C32(0x998a5d47), SPH_C32(0x73458c5b), SPH_C32(0xc65b44e6), + SPH_C32(0x22e52e7c) }, + { SPH_C32(0xc3230000), SPH_C32(0x75c805c0), SPH_C32(0xc35c0000), + SPH_C32(0x31510000), SPH_C32(0x43013dab), SPH_C32(0xb73e68ae), + SPH_C32(0x768693aa), SPH_C32(0x63b30146), SPH_C32(0x88ae0000), + SPH_C32(0xbd0b0a14), SPH_C32(0xdaea0000), SPH_C32(0x5b0c0000), + SPH_C32(0x37922583), SPH_C32(0x31e3140d), SPH_C32(0xc6499ed1), + SPH_C32(0x0ede7e32) }, + { SPH_C32(0x2bfe0000), SPH_C32(0x8f820584), SPH_C32(0xff710000), + SPH_C32(0x8a440000), SPH_C32(0xc3bc0bb0), SPH_C32(0x93d675ea), + SPH_C32(0xc92e515e), SPH_C32(0x31f90c1f), SPH_C32(0xdcfe0000), + SPH_C32(0xbb7a0a48), SPH_C32(0xff440000), SPH_C32(0x31120000), + SPH_C32(0x19376b5c), SPH_C32(0x57ad911f), SPH_C32(0x79f38612), + SPH_C32(0x70af2325) }, + { SPH_C32(0x7fae0000), SPH_C32(0x89f305d8), SPH_C32(0xdadf0000), + SPH_C32(0xe05a0000), SPH_C32(0xed19456f), SPH_C32(0xf598f0f8), + SPH_C32(0x7694499d), SPH_C32(0x4f885108), SPH_C32(0x60730000), + SPH_C32(0x47410a50), SPH_C32(0xe6c70000), SPH_C32(0xe0190000), + SPH_C32(0xb72f1398), SPH_C32(0x150b0949), SPH_C32(0x79e15c25), + SPH_C32(0x5c94736b) }, + { SPH_C32(0x38510000), SPH_C32(0x08d5050c), SPH_C32(0x81100000), + SPH_C32(0xd6ed0000), SPH_C32(0xaa206d5d), SPH_C32(0x66c7a94f), + SPH_C32(0x53f80f9d), SPH_C32(0x96ae2eec), SPH_C32(0x5d720000), + SPH_C32(0x95d10a90), SPH_C32(0x004a0000), SPH_C32(0x26280000), + SPH_C32(0x7d1f56e9), SPH_C32(0xbde19987), SPH_C32(0x41b76c9a), + SPH_C32(0x9e048db2) }, + { SPH_C32(0x6c010000), SPH_C32(0x0ea40550), SPH_C32(0xa4be0000), + SPH_C32(0xbcf30000), SPH_C32(0x84852382), SPH_C32(0x00892c5d), + SPH_C32(0xec42175e), SPH_C32(0xe8df73fb), SPH_C32(0xe1ff0000), + SPH_C32(0x69ea0a88), SPH_C32(0x19c90000), SPH_C32(0xf7230000), + SPH_C32(0xd3072e2d), SPH_C32(0xff4701d1), SPH_C32(0x41a5b6ad), + SPH_C32(0xb23fddfc) }, + { SPH_C32(0x84dc0000), SPH_C32(0xf4ee0514), SPH_C32(0x98930000), + SPH_C32(0x07e60000), SPH_C32(0x04381599), SPH_C32(0x24613119), + SPH_C32(0x53ead5aa), SPH_C32(0xba957ea2), SPH_C32(0xb5af0000), + SPH_C32(0x6f9b0ad4), SPH_C32(0x3c670000), SPH_C32(0x9d3d0000), + SPH_C32(0xfda260f2), SPH_C32(0x990984c3), SPH_C32(0xfe1fae6e), + SPH_C32(0xcc4e80eb) }, + { SPH_C32(0xd08c0000), SPH_C32(0xf29f0548), SPH_C32(0xbd3d0000), + SPH_C32(0x6df80000), SPH_C32(0x2a9d5b46), SPH_C32(0x422fb40b), + SPH_C32(0xec50cd69), SPH_C32(0xc4e423b5), SPH_C32(0x09220000), + SPH_C32(0x93a00acc), SPH_C32(0x25e40000), SPH_C32(0x4c360000), + SPH_C32(0x53ba1836), SPH_C32(0xdbaf1c95), SPH_C32(0xfe0d7459), + SPH_C32(0xe075d0a5) }, + { SPH_C32(0x51000000), SPH_C32(0xdc340590), SPH_C32(0x42330000), + SPH_C32(0x7ac20000), SPH_C32(0x4eb566f3), SPH_C32(0xa863bc93), + SPH_C32(0xd41427e1), SPH_C32(0x2a4f8d22), SPH_C32(0x9b010000), + SPH_C32(0x3a5c0a9c), SPH_C32(0xa48b0000), SPH_C32(0x07a50000), + SPH_C32(0x5e0e436e), SPH_C32(0xc4f2c8a8), SPH_C32(0x5c9fc012), + SPH_C32(0xa9895cc1) }, + { SPH_C32(0x05500000), SPH_C32(0xda4505cc), SPH_C32(0x679d0000), + SPH_C32(0x10dc0000), SPH_C32(0x6010282c), SPH_C32(0xce2d3981), + SPH_C32(0x6bae3f22), SPH_C32(0x543ed035), SPH_C32(0x278c0000), + SPH_C32(0xc6670a84), SPH_C32(0xbd080000), SPH_C32(0xd6ae0000), + SPH_C32(0xf0163baa), SPH_C32(0x865450fe), SPH_C32(0x5c8d1a25), + SPH_C32(0x85b20c8f) }, + { SPH_C32(0xed8d0000), SPH_C32(0x200f0588), SPH_C32(0x5bb00000), + SPH_C32(0xabc90000), SPH_C32(0xe0ad1e37), SPH_C32(0xeac524c5), + SPH_C32(0xd406fdd6), SPH_C32(0x0674dd6c), SPH_C32(0x73dc0000), + SPH_C32(0xc0160ad8), SPH_C32(0x98a60000), SPH_C32(0xbcb00000), + SPH_C32(0xdeb37575), SPH_C32(0xe01ad5ec), SPH_C32(0xe33702e6), + SPH_C32(0xfbc35198) }, + { SPH_C32(0xb9dd0000), SPH_C32(0x267e05d4), SPH_C32(0x7e1e0000), + SPH_C32(0xc1d70000), SPH_C32(0xce0850e8), SPH_C32(0x8c8ba1d7), + SPH_C32(0x6bbce515), SPH_C32(0x7805807b), SPH_C32(0xcf510000), + SPH_C32(0x3c2d0ac0), SPH_C32(0x81250000), SPH_C32(0x6dbb0000), + SPH_C32(0x70ab0db1), SPH_C32(0xa2bc4dba), SPH_C32(0xe325d8d1), + SPH_C32(0xd7f801d6) }, + { SPH_C32(0xf2500000), SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), + SPH_C32(0xab8a0000), SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), + SPH_C32(0xdb73e86e), SPH_C32(0x1568ff0f), SPH_C32(0x0c720000), + SPH_C32(0x49e50f00), SPH_C32(0x42790000), SPH_C32(0x5cea0000), + SPH_C32(0x33aa301a), SPH_C32(0x15822514), SPH_C32(0x95a34b7b), + SPH_C32(0xb44b0090) }, + { SPH_C32(0xa6000000), SPH_C32(0xe8cc0a5c), SPH_C32(0x42060000), + SPH_C32(0xc1940000), SPH_C32(0x943e061f), SPH_C32(0x6c185866), + SPH_C32(0x64c9f0ad), SPH_C32(0x6b19a218), SPH_C32(0xb0ff0000), + SPH_C32(0xb5de0f18), SPH_C32(0x5bfa0000), SPH_C32(0x8de10000), + SPH_C32(0x9db248de), SPH_C32(0x5724bd42), SPH_C32(0x95b1914c), + SPH_C32(0x987050de) }, + { SPH_C32(0x4edd0000), SPH_C32(0x12860a18), SPH_C32(0x7e2b0000), + SPH_C32(0x7a810000), SPH_C32(0x14833004), SPH_C32(0x48f04522), + SPH_C32(0xdb613259), SPH_C32(0x3953af41), SPH_C32(0xe4af0000), + SPH_C32(0xb3af0f44), SPH_C32(0x7e540000), SPH_C32(0xe7ff0000), + SPH_C32(0xb3170601), SPH_C32(0x316a3850), SPH_C32(0x2a0b898f), + SPH_C32(0xe6010dc9) }, + { SPH_C32(0x1a8d0000), SPH_C32(0x14f70a44), SPH_C32(0x5b850000), + SPH_C32(0x109f0000), SPH_C32(0x3a267edb), SPH_C32(0x2ebec030), + SPH_C32(0x64db2a9a), SPH_C32(0x4722f256), SPH_C32(0x58220000), + SPH_C32(0x4f940f5c), SPH_C32(0x67d70000), SPH_C32(0x36f40000), + SPH_C32(0x1d0f7ec5), SPH_C32(0x73cca006), SPH_C32(0x2a1953b8), + SPH_C32(0xca3a5d87) }, + { SPH_C32(0x9b010000), SPH_C32(0x3a5c0a9c), SPH_C32(0xa48b0000), + SPH_C32(0x07a50000), SPH_C32(0x5e0e436e), SPH_C32(0xc4f2c8a8), + SPH_C32(0x5c9fc012), SPH_C32(0xa9895cc1), SPH_C32(0xca010000), + SPH_C32(0xe6680f0c), SPH_C32(0xe6b80000), SPH_C32(0x7d670000), + SPH_C32(0x10bb259d), SPH_C32(0x6c91743b), SPH_C32(0x888be7f3), + SPH_C32(0x83c6d1e3) }, + { SPH_C32(0xcf510000), SPH_C32(0x3c2d0ac0), SPH_C32(0x81250000), + SPH_C32(0x6dbb0000), SPH_C32(0x70ab0db1), SPH_C32(0xa2bc4dba), + SPH_C32(0xe325d8d1), SPH_C32(0xd7f801d6), SPH_C32(0x768c0000), + SPH_C32(0x1a530f14), SPH_C32(0xff3b0000), SPH_C32(0xac6c0000), + SPH_C32(0xbea35d59), SPH_C32(0x2e37ec6d), SPH_C32(0x88993dc4), + SPH_C32(0xaffd81ad) }, + { SPH_C32(0x278c0000), SPH_C32(0xc6670a84), SPH_C32(0xbd080000), + SPH_C32(0xd6ae0000), SPH_C32(0xf0163baa), SPH_C32(0x865450fe), + SPH_C32(0x5c8d1a25), SPH_C32(0x85b20c8f), SPH_C32(0x22dc0000), + SPH_C32(0x1c220f48), SPH_C32(0xda950000), SPH_C32(0xc6720000), + SPH_C32(0x90061386), SPH_C32(0x48749697f), SPH_C32(0x37232507), + SPH_C32(0xd18cdcba) }, + { SPH_C32(0x73dc0000), SPH_C32(0xc0160ad8), SPH_C32(0x98a60000), + SPH_C32(0xbcb00000), SPH_C32(0xdeb37575), SPH_C32(0xe01ad5ec), + SPH_C32(0xe33702e6), SPH_C32(0xfbc35198), SPH_C32(0x9e510000), + SPH_C32(0xe0190f50), SPH_C32(0xc3160000), SPH_C32(0x17790000), + SPH_C32(0x3e1e6b42), SPH_C32(0x0adff129), SPH_C32(0x3731ff30), + SPH_C32(0xfdb78cf4) }, + { SPH_C32(0x34230000), SPH_C32(0x41300a0c), SPH_C32(0xc3690000), + SPH_C32(0x8a070000), SPH_C32(0x998a5d47), SPH_C32(0x73458c5b), + SPH_C32(0xc65b44e6), SPH_C32(0x22e52e7c), SPH_C32(0xa3500000), + SPH_C32(0x32890f90), SPH_C32(0x259b0000), SPH_C32(0xd1480000), + SPH_C32(0xf42e2e33), SPH_C32(0xa23561e7), SPH_C32(0x0f67cf8f), + SPH_C32(0x3f27722d) }, + { SPH_C32(0x60730000), SPH_C32(0x47410a50), SPH_C32(0xe6c70000), + SPH_C32(0xe0190000), SPH_C32(0xb72f1398), SPH_C32(0x150b0949), + SPH_C32(0x79e15c25), SPH_C32(0x5c94736b), SPH_C32(0x1fdd0000), + SPH_C32(0xceb20f88), SPH_C32(0x3c180000), SPH_C32(0x00430000), + SPH_C32(0x5a3656f7), SPH_C32(0xe093f9b1), SPH_C32(0x0f7515b8), + SPH_C32(0x131c2263) }, + { SPH_C32(0x88ae0000), SPH_C32(0xbd0b0a14), SPH_C32(0xdaea0000), + SPH_C32(0x5b0c0000), SPH_C32(0x37922583), SPH_C32(0x31e3140d), + SPH_C32(0xc6499ed1), SPH_C32(0x0ede7e32), SPH_C32(0x4b8d0000), + SPH_C32(0xc8c30fd4), SPH_C32(0x19b60000), SPH_C32(0x6a5d0000), + SPH_C32(0x74931828), SPH_C32(0x86dd7ca3), SPH_C32(0xb0cf0d7b), + SPH_C32(0x6d6d7f74) }, + { SPH_C32(0xdcfe0000), SPH_C32(0xbb7a0a48), SPH_C32(0xff440000), + SPH_C32(0x31120000), SPH_C32(0x19376b5c), SPH_C32(0x57ad911f), + SPH_C32(0x79f38612), SPH_C32(0x70af2325), SPH_C32(0xf7000000), + SPH_C32(0x34f80fcc), SPH_C32(0x00350000), SPH_C32(0xbb560000), + SPH_C32(0xda8b60ec), SPH_C32(0xc47be4f5), SPH_C32(0xb0ddd74c), + SPH_C32(0x41562f3a) }, + { SPH_C32(0x5d720000), SPH_C32(0x95d10a90), SPH_C32(0x004a0000), + SPH_C32(0x26280000), SPH_C32(0x7d1f56e9), SPH_C32(0xbde19987), + SPH_C32(0x41b76c9a), SPH_C32(0x9e048db2), SPH_C32(0x65230000), + SPH_C32(0x9d040f9c), SPH_C32(0x815a0000), SPH_C32(0xf0c50000), + SPH_C32(0xd73f3bb4), SPH_C32(0xdb2630c8), SPH_C32(0x124f6307), + SPH_C32(0x08aaa35e) }, + { SPH_C32(0x09220000), SPH_C32(0x93a00acc), SPH_C32(0x25e40000), + SPH_C32(0x4c360000), SPH_C32(0x53ba1836), SPH_C32(0xdbaf1c95), + SPH_C32(0xfe0d7459), SPH_C32(0xe075d0a5), SPH_C32(0xd9ae0000), + SPH_C32(0x613f0f84), SPH_C32(0x98d90000), SPH_C32(0x21ce0000), + SPH_C32(0x79274370), SPH_C32(0x9980a89e), SPH_C32(0x125db930), + SPH_C32(0x2491f310) }, + { SPH_C32(0xe1ff0000), SPH_C32(0x69ea0a88), SPH_C32(0x19c90000), + SPH_C32(0xf7230000), SPH_C32(0xd3072e2d), SPH_C32(0xff4701d1), + SPH_C32(0x41a5b6ad), SPH_C32(0xb23fddfc), SPH_C32(0x8dfe0000), + SPH_C32(0x674e0fd8), SPH_C32(0xbd770000), SPH_C32(0x4bd00000), + SPH_C32(0x57820daf), SPH_C32(0xffce2d8c), SPH_C32(0xade7a1f3), + SPH_C32(0x5ae0ae07) }, + { SPH_C32(0xb5af0000), SPH_C32(0x6f9b0ad4), SPH_C32(0x3c670000), + SPH_C32(0x9d3d0000), SPH_C32(0xfda260f2), SPH_C32(0x990984c3), + SPH_C32(0xfe1fae6e), SPH_C32(0xcc4e80eb), SPH_C32(0x31730000), + SPH_C32(0x9b750fc0), SPH_C32(0xa4f40000), SPH_C32(0x9adb0000), + SPH_C32(0xf99a756b), SPH_C32(0xbd68b5da), SPH_C32(0xadf57bc4), + SPH_C32(0x76dbfe49) }, + { SPH_C32(0x45180000), SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), + SPH_C32(0x3b480000), SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), + SPH_C32(0x16bca6b0), SPH_C32(0xdf33f4df), SPH_C32(0xb83d0000), + SPH_C32(0x16710600), SPH_C32(0x379a0000), SPH_C32(0xf5b10000), + SPH_C32(0x228161ac), SPH_C32(0xae48f145), SPH_C32(0x66241616), + SPH_C32(0xc5c1eb3e) }, + { SPH_C32(0x11480000), SPH_C32(0xa3c4175c), SPH_C32(0xdcc40000), + SPH_C32(0x51560000), SPH_C32(0x30695af3), SPH_C32(0x455d10c4), + SPH_C32(0xa906be73), SPH_C32(0xa142a9c8), SPH_C32(0x04b00000), + SPH_C32(0xea4a0618), SPH_C32(0x2e190000), SPH_C32(0x24ba0000), + SPH_C32(0x8c991968), SPH_C32(0xecee6913), SPH_C32(0x6636cc21), + SPH_C32(0xe9fabb70) }, + { SPH_C32(0xf9950000), SPH_C32(0x598e1718), SPH_C32(0xe0e90000), + SPH_C32(0xea430000), SPH_C32(0xb0d46ce8), SPH_C32(0x61b50d80), + SPH_C32(0x16ae7c87), SPH_C32(0xf308a491), SPH_C32(0x50e00000), + SPH_C32(0xec3b0644), SPH_C32(0x0bb70000), SPH_C32(0x4ea40000), + SPH_C32(0xa23c57b7), SPH_C32(0x8aa0ec01), SPH_C32(0xd98cd4e2), + SPH_C32(0x978be667) }, + { SPH_C32(0xadc50000), SPH_C32(0x5fff1744), SPH_C32(0xc5470000), + SPH_C32(0x805d0000), SPH_C32(0x9e712237), SPH_C32(0x07fb8892), + SPH_C32(0xa9146444), SPH_C32(0x8d79f986), SPH_C32(0xec6d0000), + SPH_C32(0x1000065c), SPH_C32(0x12340000), SPH_C32(0x9faf0000), + SPH_C32(0x0c242f73), SPH_C32(0xc8067457), SPH_C32(0xd99e0ed5), + SPH_C32(0xbbb0b629) }, + { SPH_C32(0x2c490000), SPH_C32(0x7154179c), SPH_C32(0x3a490000), + SPH_C32(0x97670000), SPH_C32(0xfa591f82), SPH_C32(0xedb7800a), + SPH_C32(0x91508ecc), SPH_C32(0x63d25711), SPH_C32(0x7e4e0000), + SPH_C32(0xb9fc060c), SPH_C32(0x935b0000), SPH_C32(0xd43c0000), + SPH_C32(0x0190742b), SPH_C32(0xd75ba06a), SPH_C32(0x7b0cba9e), + SPH_C32(0xf24c3a4d) }, + { SPH_C32(0x78190000), SPH_C32(0x772517c0), SPH_C32(0x1fe70000), + SPH_C32(0xfd790000), SPH_C32(0xd4fc515d), SPH_C32(0x8bf90518), + SPH_C32(0x2eea960f), SPH_C32(0x1da30a06), SPH_C32(0xc2c30000), + SPH_C32(0x45c70614), SPH_C32(0x8ad80000), SPH_C32(0x05370000), + SPH_C32(0xaf880cef), SPH_C32(0x95fd383c), SPH_C32(0x7b1e60a9), + SPH_C32(0xde776a03) }, + { SPH_C32(0x90c40000), SPH_C32(0x8d6f1784), SPH_C32(0x23ca0000), + SPH_C32(0x466c0000), SPH_C32(0x54416746), SPH_C32(0xaf11185c), + SPH_C32(0x914254fb), SPH_C32(0x4fe9075f), SPH_C32(0x96930000), + SPH_C32(0x43b60648), SPH_C32(0xaf760000), SPH_C32(0x6f290000), + SPH_C32(0x812d4230), SPH_C32(0xf3b3bd2e), SPH_C32(0xc4a4786a), + SPH_C32(0xa0063714) }, + { SPH_C32(0xc4940000), SPH_C32(0x8b1e17d8), SPH_C32(0x06640000), + SPH_C32(0x2c720000), SPH_C32(0x7ae42999), SPH_C32(0xc95f9d4e), + SPH_C32(0x2ef84c38), SPH_C32(0x31985a48), SPH_C32(0x2a1e0000), + SPH_C32(0xbf8d0650), SPH_C32(0xb6f50000), SPH_C32(0xbe220000), + SPH_C32(0x2f353af4), SPH_C32(0xb1152578), SPH_C32(0xc4b6a25d), + SPH_C32(0x8c3d675a) }, + { SPH_C32(0x836b0000), SPH_C32(0x0a38170c), SPH_C32(0x5dab0000), + SPH_C32(0x1ac50000), SPH_C32(0x3ddd01ab), SPH_C32(0x5a00c4f9), + SPH_C32(0x0b940a38), SPH_C32(0xe8be25ac), SPH_C32(0x171f0000), + SPH_C32(0x6d1d0690), SPH_C32(0x50780000), SPH_C32(0x78130000), + SPH_C32(0xe5057f85), SPH_C32(0x19ffb5b6), SPH_C32(0xfce092e2), + SPH_C32(0x4ead9983) }, + { SPH_C32(0xd73b0000), SPH_C32(0x0c491750), SPH_C32(0x78050000), + SPH_C32(0x70db0000), SPH_C32(0x13784f74), SPH_C32(0x3c4e41eb), + SPH_C32(0xb42e12fb), SPH_C32(0x96cf78bb), SPH_C32(0xab920000), + SPH_C32(0x91260688), SPH_C32(0x49fb0000), SPH_C32(0xa9180000), + SPH_C32(0x4b1d0741), SPH_C32(0x5b592de0), SPH_C32(0xfcf248d5), + SPH_C32(0x6296c9cd) }, + { SPH_C32(0x3fe60000), SPH_C32(0xf6031714), SPH_C32(0x44280000), + SPH_C32(0xcbce0000), SPH_C32(0x93c5796f), SPH_C32(0x18a65caf), + SPH_C32(0x0b86d00f), SPH_C32(0xc48575e2), SPH_C32(0xffc20000), + SPH_C32(0x975706d4), SPH_C32(0x6c550000), SPH_C32(0xc3060000), + SPH_C32(0x65b8499e), SPH_C32(0x3d17a8f2), SPH_C32(0x43485016), + SPH_C32(0x1ce794da) }, + { SPH_C32(0x6bb60000), SPH_C32(0xf0721748), SPH_C32(0x61860000), + SPH_C32(0xa1d00000), SPH_C32(0xbd6037b0), SPH_C32(0x7ee8d9bd), + SPH_C32(0xb43cc8cc), SPH_C32(0xbaf428f5), SPH_C32(0x434f0000), + SPH_C32(0x6b6c06cc), SPH_C32(0x75d60000), SPH_C32(0x120d0000), + SPH_C32(0xcba0315a), SPH_C32(0x7fb130a4), SPH_C32(0x435a8a21), + SPH_C32(0x30dcc494) }, + { SPH_C32(0xea3a0000), SPH_C32(0xded91790), SPH_C32(0x9e880000), + SPH_C32(0xb6ea0000), SPH_C32(0xd9480a05), SPH_C32(0x94a4d125), + SPH_C32(0x8c782244), SPH_C32(0x545f8662), SPH_C32(0xd16c0000), + SPH_C32(0xc290069c), SPH_C32(0xf4b90000), SPH_C32(0x599e0000), + SPH_C32(0xc6146a02), SPH_C32(0x60ece499), SPH_C32(0xe1c83e6a), + SPH_C32(0x792048f0) }, + { SPH_C32(0xbe6a0000), SPH_C32(0xd8a817cc), SPH_C32(0xbb260000), + SPH_C32(0xdcf40000), SPH_C32(0xf7ed44da), SPH_C32(0xf2ea5437), + SPH_C32(0x33c23a87), SPH_C32(0x2a2edb75), SPH_C32(0x6de10000), + SPH_C32(0x3eab0684), SPH_C32(0xed3a0000), SPH_C32(0x88950000), + SPH_C32(0x680c12c6), SPH_C32(0x224a7ccf), SPH_C32(0xe1dae45d), + SPH_C32(0x551b18be) }, + { SPH_C32(0x56b70000), SPH_C32(0x22e21788), SPH_C32(0x870b0000), + SPH_C32(0x67e10000), SPH_C32(0x775072c1), SPH_C32(0xd6024973), + SPH_C32(0x8c6af873), SPH_C32(0x7864d62c), SPH_C32(0x39b10000), + SPH_C32(0x38da06d8), SPH_C32(0xc8940000), SPH_C32(0xe28b0000), + SPH_C32(0x46a95c19), SPH_C32(0x4404f9dd), SPH_C32(0x5e60fc9e), + SPH_C32(0x2b6a45a9) }, + { SPH_C32(0x02e70000), SPH_C32(0x249317d4), SPH_C32(0xa2a50000), + SPH_C32(0x0dff0000), SPH_C32(0x59f53c1e), SPH_C32(0xb04ccc61), + SPH_C32(0x33d0e0b0), SPH_C32(0x06158b3b), SPH_C32(0x853c0000), + SPH_C32(0xc4e106c0), SPH_C32(0xd1170000), SPH_C32(0x33800000), + SPH_C32(0xe8b124dd), SPH_C32(0x06a2618b), SPH_C32(0x5e7226a9), + SPH_C32(0x075115e7) }, + { SPH_C32(0x496a0000), SPH_C32(0xec501800), SPH_C32(0xbb130000), + SPH_C32(0x67a20000), SPH_C32(0x2d662436), SPH_C32(0x3691b0c2), + SPH_C32(0x831fedcb), SPH_C32(0x6b78f44f), SPH_C32(0x461f0000), + SPH_C32(0xb1290300), SPH_C32(0x124b0000), SPH_C32(0x02d10000), + SPH_C32(0xabb01976), SPH_C32(0xb19c0925), SPH_C32(0x28f4b503), + SPH_C32(0x64e214a1) }, + { SPH_C32(0x1d3a0000), SPH_C32(0xea21185c), SPH_C32(0x9ebd0000), + SPH_C32(0x0dbc0000), SPH_C32(0x03c36ae9), SPH_C32(0x50df35d0), + SPH_C32(0x3ca5f508), SPH_C32(0x1509a958), SPH_C32(0xfa920000), + SPH_C32(0x4d120318), SPH_C32(0x0bc80000), SPH_C32(0xd3da0000), + SPH_C32(0x05a861b2), SPH_C32(0xf33a9173), SPH_C32(0x28e66f34), + SPH_C32(0x48d944ef) }, + { SPH_C32(0xf5e70000), SPH_C32(0x106b1818), SPH_C32(0xa2900000), + SPH_C32(0xb6a90000), SPH_C32(0x837e5cf2), SPH_C32(0x74372894), + SPH_C32(0x830d37fc), SPH_C32(0x4743a401), SPH_C32(0xaec20000), + SPH_C32(0x4b630344), SPH_C32(0x2e660000), SPH_C32(0xb9c40000), + SPH_C32(0x2b0d2f6d), SPH_C32(0x95741461), SPH_C32(0x975c77f7), + SPH_C32(0x36a819f8) }, + { SPH_C32(0xa1b70000), SPH_C32(0x161a1844), SPH_C32(0x873e0000), + SPH_C32(0xdcb70000), SPH_C32(0xaddb122d), SPH_C32(0x1279ad86), + SPH_C32(0x3cb72f3f), SPH_C32(0x3932f916), SPH_C32(0x124f0000), + SPH_C32(0xb758035c), SPH_C32(0x37e50000), SPH_C32(0x68cf0000), + SPH_C32(0x851557a9), SPH_C32(0xd7d28c37), SPH_C32(0x974eadc0), + SPH_C32(0x1a9349b6) }, + { SPH_C32(0x203b0000), SPH_C32(0x38b1189c), SPH_C32(0x78300000), + SPH_C32(0xcb8d0000), SPH_C32(0xc9f32f98), SPH_C32(0xf835a51e), + SPH_C32(0x04f3c5b7), SPH_C32(0xd7995781), SPH_C32(0x806c0000), + SPH_C32(0x1ea4030c), SPH_C32(0xb68a0000), SPH_C32(0x235c0000), + SPH_C32(0x88a10cf1), SPH_C32(0xc88f580a), SPH_C32(0x35dc198b), + SPH_C32(0x536fc5d2) }, + { SPH_C32(0x746b0000), SPH_C32(0x3ec018c0), SPH_C32(0x5d9e0000), + SPH_C32(0xa1930000), SPH_C32(0xe7566147), SPH_C32(0x9e7b200c), + SPH_C32(0xbb49dd74), SPH_C32(0xa9e80a96), SPH_C32(0x3ce10000), + SPH_C32(0xe29f0314), SPH_C32(0xaf090000), SPH_C32(0xf2570000), + SPH_C32(0x26b97435), SPH_C32(0x8a29c05c), SPH_C32(0x35cec3bc), + SPH_C32(0x7f54959c) }, + { SPH_C32(0x9cb60000), SPH_C32(0xc48a1884), SPH_C32(0x61b30000), + SPH_C32(0x1a860000), SPH_C32(0x67eb575c), SPH_C32(0xba933d48), + SPH_C32(0x04e11f80), SPH_C32(0xfba207cf), SPH_C32(0x68b10000), + SPH_C32(0xe4ee0348), SPH_C32(0x8aa70000), SPH_C32(0x98490000), + SPH_C32(0x081c3aea), SPH_C32(0xec67454e), SPH_C32(0x8a74db7f), + SPH_C32(0x0125c88b) }, + { SPH_C32(0xc8e60000), SPH_C32(0xc2fb18d8), SPH_C32(0x441d0000), + SPH_C32(0x70980000), SPH_C32(0x494e1983), SPH_C32(0xdcddb85a), + SPH_C32(0xbb5b0743), SPH_C32(0x85d35ad8), SPH_C32(0xd43c0000), + SPH_C32(0x18d50350), SPH_C32(0x93240000), SPH_C32(0x49420000), + SPH_C32(0xa604422e), SPH_C32(0xaec1dd18), SPH_C32(0x8a660148), + SPH_C32(0x2d1e98c5) }, + { SPH_C32(0x8f190000), SPH_C32(0x43dd180c), SPH_C32(0x1fd20000), + SPH_C32(0x462f0000), SPH_C32(0x0e7731b1), SPH_C32(0x4f82e1ed), + SPH_C32(0x9e374143), SPH_C32(0x5cf5253c), SPH_C32(0xe93d0000), + SPH_C32(0xca450390), SPH_C32(0x75a90000), SPH_C32(0x8f730000), + SPH_C32(0x6c34075f), SPH_C32(0x062b4dd6), SPH_C32(0xb23031f7), + SPH_C32(0xef8e661c) }, + { SPH_C32(0xdb490000), SPH_C32(0x45ac1850), SPH_C32(0x3a7c0000), + SPH_C32(0x2c310000), SPH_C32(0x20d27f6e), SPH_C32(0x29cc64ff), + SPH_C32(0x218d5980), SPH_C32(0x2284782b), SPH_C32(0x55b00000), + SPH_C32(0x367e0388), SPH_C32(0x6c2a0000), SPH_C32(0x5e780000), + SPH_C32(0xc22c7f9b), SPH_C32(0x448dd580), SPH_C32(0xb222ebc0), + SPH_C32(0xc3b53652) }, + { SPH_C32(0x33940000), SPH_C32(0xbfe61814), SPH_C32(0x06510000), + SPH_C32(0x97240000), SPH_C32(0xa06f4975), SPH_C32(0x0d2479bb), + SPH_C32(0x9e259b74), SPH_C32(0x70ce7572), SPH_C32(0x01e00000), + SPH_C32(0x300f03d4), SPH_C32(0x49840000), SPH_C32(0x34660000), + SPH_C32(0xec893144), SPH_C32(0x22c35092), SPH_C32(0x0d98f303), + SPH_C32(0xbdc46b45) }, + { SPH_C32(0x67c40000), SPH_C32(0xb9971848), SPH_C32(0x23ff0000), + SPH_C32(0xfd3a0000), SPH_C32(0x8eca07aa), SPH_C32(0x6b6afca9), + SPH_C32(0x219f83b7), SPH_C32(0x0ebf2865), SPH_C32(0xbd6d0000), + SPH_C32(0xcc3403cc), SPH_C32(0x50070000), SPH_C32(0xe56d0000), + SPH_C32(0x42914980), SPH_C32(0x6065c8c4), SPH_C32(0x0d8a2934), + SPH_C32(0x91ff3b0b) }, + { SPH_C32(0xe6480000), SPH_C32(0x973c1890), SPH_C32(0xdcf10000), + SPH_C32(0xea000000), SPH_C32(0xeae23a1f), SPH_C32(0x8126f431), + SPH_C32(0x19db693f), SPH_C32(0xe01486f2), SPH_C32(0x2f4e0000), + SPH_C32(0x65c8039c), SPH_C32(0xd1680000), SPH_C32(0xaefe0000), + SPH_C32(0x4f2512d8), SPH_C32(0x7f381cf9), SPH_C32(0xaf189d7f), + SPH_C32(0xd803b76f) }, + { SPH_C32(0xb2180000), SPH_C32(0x914d18cc), SPH_C32(0xf95f0000), + SPH_C32(0x801e0000), SPH_C32(0xc44774c0), SPH_C32(0xe7687123), + SPH_C32(0xa66171fc), SPH_C32(0x9e65dbe5), SPH_C32(0x93c30000), + SPH_C32(0x99f30384), SPH_C32(0xc8eb0000), SPH_C32(0x7ff50000), + SPH_C32(0xe13d6a1c), SPH_C32(0x3d9e84af), SPH_C32(0xaf0a4748), + SPH_C32(0xf438e721) }, + { SPH_C32(0x5ac50000), SPH_C32(0x6b071888), SPH_C32(0xc5720000), + SPH_C32(0x3b0b0000), SPH_C32(0x44fa42db), SPH_C32(0xc3806c67), + SPH_C32(0x19c9b308), SPH_C32(0xcc2fd6bc), SPH_C32(0xc7930000), + SPH_C32(0x9f8203d8), SPH_C32(0xed450000), SPH_C32(0x15eb0000), + SPH_C32(0xcf9824c3), SPH_C32(0x5bd001bd), SPH_C32(0x10b05f8b), + SPH_C32(0x8a49ba36) }, + { SPH_C32(0x0e950000), SPH_C32(0x6d7618d4), SPH_C32(0xe0dc0000), + SPH_C32(0x51150000), SPH_C32(0x6a5f0c04), SPH_C32(0xa5cee975), + SPH_C32(0xa673abcb), SPH_C32(0xb25e8bab), SPH_C32(0x7b1e0000), + SPH_C32(0x63b903c0), SPH_C32(0xf4c60000), SPH_C32(0xc4e00000), + SPH_C32(0x61805c07), SPH_C32(0x197699eb), SPH_C32(0x10a285bc), + SPH_C32(0xa672ea78) }, + { SPH_C32(0xbb3a0000), SPH_C32(0x02ed1200), SPH_C32(0xdcbb0000), + SPH_C32(0xcc280000), SPH_C32(0x97fd6cf6), SPH_C32(0x3cc76db6), + SPH_C32(0x586c05a5), SPH_C32(0x7e100b40), SPH_C32(0x4a6d0000), + SPH_C32(0xf8cc0c00), SPH_C32(0x50320000), SPH_C32(0x5e3b0000), + SPH_C32(0x981a296c), SPH_C32(0xa41e2c31), SPH_C32(0xbd57fe78), + SPH_C32(0xd0a91431) }, + { SPH_C32(0xef6a0000), SPH_C32(0x049c125c), SPH_C32(0xf9150000), + SPH_C32(0xa6360000), SPH_C32(0xb9582229), SPH_C32(0x5a89e8a4), + SPH_C32(0xe7d61d66), SPH_C32(0x00615657), SPH_C32(0xf6e00000), + SPH_C32(0x04f70c18), SPH_C32(0x49b10000), SPH_C32(0x8f300000), + SPH_C32(0x360251a8), SPH_C32(0xe6b8b467), SPH_C32(0xbd45244f), + SPH_C32(0xfc92447f) }, + { SPH_C32(0x07b70000), SPH_C32(0xfed61218), SPH_C32(0xc5380000), + SPH_C32(0x1d230000), SPH_C32(0x39e51432), SPH_C32(0x7e61f5e0), + SPH_C32(0x587edf92), SPH_C32(0x522b5b0e), SPH_C32(0xa2b00000), + SPH_C32(0x02860c44), SPH_C32(0x6c1f0000), SPH_C32(0xe52e0000), + SPH_C32(0x18a71f77), SPH_C32(0x80f63175), SPH_C32(0x02ff3c8c), + SPH_C32(0x82e31968) }, + { SPH_C32(0x53e70000), SPH_C32(0xf8a71244), SPH_C32(0xe0960000), + SPH_C32(0x773d0000), SPH_C32(0x17405aed), SPH_C32(0x182f70f2), + SPH_C32(0xe7c4c751), SPH_C32(0x2c5a0619), SPH_C32(0x1e3d0000), + SPH_C32(0xfebd0c5c), SPH_C32(0x759c0000), SPH_C32(0x34250000), + SPH_C32(0xb6bf67b3), SPH_C32(0xc250a923), SPH_C32(0x02ede6bb), + SPH_C32(0xaed84926) }, + { SPH_C32(0xd26b0000), SPH_C32(0xd60c129c), SPH_C32(0x1f980000), + SPH_C32(0x60070000), SPH_C32(0x73686758), SPH_C32(0xf263786a), + SPH_C32(0xdf802dd9), SPH_C32(0xc2f1a88e), SPH_C32(0x8c1e0000), + SPH_C32(0x57410c0c), SPH_C32(0xf4f30000), SPH_C32(0x7fb60000), + SPH_C32(0xbb0b3ceb), SPH_C32(0xdd0d7d1e), SPH_C32(0xa07f52f0), + SPH_C32(0xe724c542) }, + { SPH_C32(0x863b0000), SPH_C32(0xd07d12c0), SPH_C32(0x3a360000), + SPH_C32(0x0a190000), SPH_C32(0x5dcd2987), SPH_C32(0x942dfd78), + SPH_C32(0x603a351a), SPH_C32(0xbc80f599), SPH_C32(0x30930000), + SPH_C32(0xab7a0c14), SPH_C32(0xed700000), SPH_C32(0xaebd0000), + SPH_C32(0x1513442f), SPH_C32(0x9fabe548), SPH_C32(0xa06d88c7), + SPH_C32(0xcb1f950c) }, + { SPH_C32(0x6ee60000), SPH_C32(0x2a371284), SPH_C32(0x061b0000), + SPH_C32(0xb10c0000), SPH_C32(0xdd701f9c), SPH_C32(0xb0c5e03c), + SPH_C32(0xdf92f7ee), SPH_C32(0xeecaf8c0), SPH_C32(0x64c30000), + SPH_C32(0xad0b0c48), SPH_C32(0xc8de0000), SPH_C32(0xc4a30000), + SPH_C32(0x3bb60af0), SPH_C32(0xf9e5605a), SPH_C32(0x1fd79004), + SPH_C32(0xb56ec81b) }, + { SPH_C32(0x3ab60000), SPH_C32(0x2c4612d8), SPH_C32(0x23b50000), + SPH_C32(0xdb120000), SPH_C32(0xf3d55143), SPH_C32(0xd68b652e), + SPH_C32(0x6028ef2d), SPH_C32(0x90bba5d7), SPH_C32(0xd84e0000), + SPH_C32(0x51300c50), SPH_C32(0xd15d0000), SPH_C32(0x15a80000), + SPH_C32(0x95ae7234), SPH_C32(0xbb43f80c), SPH_C32(0x1fc54a33), + SPH_C32(0x99559855) }, + { SPH_C32(0x7d490000), SPH_C32(0xad60120c), SPH_C32(0x787a0000), + SPH_C32(0xeda50000), SPH_C32(0xb4ec7971), SPH_C32(0x45d43c99), + SPH_C32(0x4544a92d), SPH_C32(0x499dda33), SPH_C32(0xe54f0000), + SPH_C32(0x83a00c90), SPH_C32(0x37d00000), SPH_C32(0xd3990000), + SPH_C32(0x5f9e3745), SPH_C32(0x13a968c2), SPH_C32(0x27937a8c), + SPH_C32(0x5bc5668c) }, + { SPH_C32(0x29190000), SPH_C32(0xab111250), SPH_C32(0x5dd40000), + SPH_C32(0x87bb0000), SPH_C32(0x9a4937ae), SPH_C32(0x239ab98b), + SPH_C32(0xfafeb1ee), SPH_C32(0x37ec8724), SPH_C32(0x59c20000), + SPH_C32(0x7f9b0c88), SPH_C32(0x2e530000), SPH_C32(0x02920000), + SPH_C32(0xf1864f81), SPH_C32(0x510ff094), SPH_C32(0x2781a0bb), + SPH_C32(0x77fe36c2) }, + { SPH_C32(0xc1c40000), SPH_C32(0x515b1214), SPH_C32(0x61f90000), + SPH_C32(0x3cae0000), SPH_C32(0x1af401b5), SPH_C32(0x0772a4cf), + SPH_C32(0x4556731a), SPH_C32(0x65a68a7d), SPH_C32(0x0d920000), + SPH_C32(0x79ea0cd4), SPH_C32(0x0bfd0000), SPH_C32(0x688c0000), + SPH_C32(0xdf23015e), SPH_C32(0x37417586), SPH_C32(0x983bb878), + SPH_C32(0x098f6bd5) }, + { SPH_C32(0x95940000), SPH_C32(0x572a1248), SPH_C32(0x44570000), + SPH_C32(0x56b00000), SPH_C32(0x34514f6a), SPH_C32(0x613c21dd), + SPH_C32(0xfaec6bd9), SPH_C32(0x1bd7d76a), SPH_C32(0xb11f0000), + SPH_C32(0x85d10ccc), SPH_C32(0x127e0000), SPH_C32(0xb9870000), + SPH_C32(0x713b799a), SPH_C32(0x75e7edd0), SPH_C32(0x9829624f), + SPH_C32(0x25b43b9b) }, + { SPH_C32(0x14180000), SPH_C32(0x79811290), SPH_C32(0xbb590000), + SPH_C32(0x418a0000), SPH_C32(0x507972df), SPH_C32(0x8b702945), + SPH_C32(0xc2a88151), SPH_C32(0xf57c79fd), SPH_C32(0x233c0000), + SPH_C32(0x2c2d0c9c), SPH_C32(0x93110000), SPH_C32(0xf2140000), + SPH_C32(0x7c8f22c2), SPH_C32(0x6aba39ed), SPH_C32(0x3abbd604), + SPH_C32(0x6c48b7ff) }, + { SPH_C32(0x40480000), SPH_C32(0x7ff012cc), SPH_C32(0x9ef70000), + SPH_C32(0x2b940000), SPH_C32(0x7edc3c00), SPH_C32(0xed3eac57), + SPH_C32(0x7d129992), SPH_C32(0x8b0d24ea), SPH_C32(0x9fb10000), + SPH_C32(0xd0160c84), SPH_C32(0x8a920000), SPH_C32(0x231f0000), + SPH_C32(0xd2975a06), SPH_C32(0x281ca1bb), SPH_C32(0x3aa90c33), + SPH_C32(0x4073e7b1) }, + { SPH_C32(0xa8950000), SPH_C32(0x85ba1288), SPH_C32(0xa2da0000), + SPH_C32(0x90810000), SPH_C32(0xfe610a1b), SPH_C32(0xc9d6b113), + SPH_C32(0xc2ba5b66), SPH_C32(0xd94729b3), SPH_C32(0xcbe10000), + SPH_C32(0xd6670cd8), SPH_C32(0xaf3c0000), SPH_C32(0x49010000), + SPH_C32(0xfc3214d9), SPH_C32(0x4e5224a9), SPH_C32(0x851314f0), + SPH_C32(0x3e02baa6) }, + { SPH_C32(0xfcc50000), SPH_C32(0x83cb12d4), SPH_C32(0x87740000), + SPH_C32(0xfa9f0000), SPH_C32(0xd0c444c4), SPH_C32(0xaf983401), + SPH_C32(0x7d0043a5), SPH_C32(0xa73674a4), SPH_C32(0x776c0000), + SPH_C32(0x2a5c0cc0), SPH_C32(0xb6bf0000), SPH_C32(0x980a0000), + SPH_C32(0x522a6c1d), SPH_C32(0x0cf4bcff), SPH_C32(0x8501cec7), + SPH_C32(0x1239eae8) }, + { SPH_C32(0xb7480000), SPH_C32(0x4b081d00), SPH_C32(0x9ec20000), + SPH_C32(0x90c20000), SPH_C32(0xa4575cec), SPH_C32(0x294548a2), + SPH_C32(0xcdcf4ede), SPH_C32(0xca5b0bd0), SPH_C32(0xb44f0000), + SPH_C32(0x5f940900), SPH_C32(0x75e30000), SPH_C32(0xa95b0000), + SPH_C32(0x112b51b6), SPH_C32(0xbbcad451), SPH_C32(0xf3875d6d), + SPH_C32(0x718aebae) }, + { SPH_C32(0xe3180000), SPH_C32(0x4d791d5c), SPH_C32(0xbb6c0000), + SPH_C32(0xfadc0000), SPH_C32(0x8af21233), SPH_C32(0x4f0bcdb0), + SPH_C32(0x7275561d), SPH_C32(0xb42a56c7), SPH_C32(0x08c20000), + SPH_C32(0xa3af0918), SPH_C32(0x6c600000), SPH_C32(0x78500000), + SPH_C32(0xbf332972), SPH_C32(0xf96c4c07), SPH_C32(0xf395875a), + SPH_C32(0x5db1bbe0) }, + { SPH_C32(0x0bc50000), SPH_C32(0xb7331d18), SPH_C32(0x87410000), + SPH_C32(0x41c90000), SPH_C32(0x0a4f2428), SPH_C32(0x6be3d0f4), + SPH_C32(0xcddd94e9), SPH_C32(0xe6605b9e), SPH_C32(0x5c920000), + SPH_C32(0xa5de0944), SPH_C32(0x49ce0000), SPH_C32(0x124e0000), + SPH_C32(0x919667ad), SPH_C32(0x9f22c915), SPH_C32(0x4c2f9f99), + SPH_C32(0x23c0e6f7) }, + { SPH_C32(0x5f950000), SPH_C32(0xb1421d44), SPH_C32(0xa2ef0000), + SPH_C32(0x2bd70000), SPH_C32(0x24ea6af7), SPH_C32(0x0dad55e6), + SPH_C32(0x72678c2a), SPH_C32(0x98110689), SPH_C32(0xe01f0000), + SPH_C32(0x59e5095c), SPH_C32(0x504d0000), SPH_C32(0xc3450000), + SPH_C32(0x3f8e1f69), SPH_C32(0xdd845143), SPH_C32(0x4c3d45ae), + SPH_C32(0x0ffbb6b9) }, + { SPH_C32(0xde190000), SPH_C32(0x9fe91d9c), SPH_C32(0x5de10000), + SPH_C32(0x3ced0000), SPH_C32(0x40c25742), SPH_C32(0xe7e15d7e), + SPH_C32(0x4a2366a2), SPH_C32(0x76baa81e), SPH_C32(0x723c0000), + SPH_C32(0xf019090c), SPH_C32(0xd1220000), SPH_C32(0x88d60000), + SPH_C32(0x323a4431), SPH_C32(0xc2d9857e), SPH_C32(0xeeaff1e5), + SPH_C32(0x46073add) }, + { SPH_C32(0x8a490000), SPH_C32(0x99981dc0), SPH_C32(0x784f0000), + SPH_C32(0x56f30000), SPH_C32(0x6e67199d), SPH_C32(0x81afd86c), + SPH_C32(0xf5997e61), SPH_C32(0x08cbf509), SPH_C32(0xceb10000), + SPH_C32(0x0c220914), SPH_C32(0xc8a10000), SPH_C32(0x59dd0000), + SPH_C32(0x9c223cf5), SPH_C32(0x807f1d28), SPH_C32(0xeebd2bd2), + SPH_C32(0x6a3c6a93) }, + { SPH_C32(0x62940000), SPH_C32(0x63d21d84), SPH_C32(0x44620000), + SPH_C32(0xede60000), SPH_C32(0xeeda2f86), SPH_C32(0xa547c528), + SPH_C32(0x4a31bc95), SPH_C32(0x5a81f850), SPH_C32(0x9ae10000), + SPH_C32(0x0a530948), SPH_C32(0xed0f0000), SPH_C32(0x33c30000), + SPH_C32(0xb287722a), SPH_C32(0xe631983a), SPH_C32(0x51073311), + SPH_C32(0x144d3784) }, + { SPH_C32(0x36c40000), SPH_C32(0x65a31dd8), SPH_C32(0x61cc0000), + SPH_C32(0x87f80000), SPH_C32(0xc07f6159), SPH_C32(0xc309403a), + SPH_C32(0xf58ba456), SPH_C32(0x24f0a547), SPH_C32(0x266c0000), + SPH_C32(0xf6680950), SPH_C32(0xf48c0000), SPH_C32(0xe2c80000), + SPH_C32(0x1c9f0aee), SPH_C32(0xa497006c), SPH_C32(0x5115e926), + SPH_C32(0x387667ca) }, + { SPH_C32(0x713b0000), SPH_C32(0xe4851d0c), SPH_C32(0x3a030000), + SPH_C32(0xb14f0000), SPH_C32(0x8746496b), SPH_C32(0x5056198d), + SPH_C32(0xd0e7e256), SPH_C32(0xfdd6daa3), SPH_C32(0x1b6d0000), + SPH_C32(0x24f80990), SPH_C32(0x12010000), SPH_C32(0x24f90000), + SPH_C32(0xd6af4f9f), SPH_C32(0x0c7d90a2), SPH_C32(0x6943d999), + SPH_C32(0xfae69913) }, + { SPH_C32(0x256b0000), SPH_C32(0xe2f41d50), SPH_C32(0x1fad0000), + SPH_C32(0xdb510000), SPH_C32(0xa9e307b4), SPH_C32(0x36189c9f), + SPH_C32(0x6f5dfa95), SPH_C32(0x83a787b4), SPH_C32(0xa7e00000), + SPH_C32(0xd8c30988), SPH_C32(0x0b820000), SPH_C32(0xf5f20000), + SPH_C32(0x78b7375b), SPH_C32(0x4edb08f4), SPH_C32(0x695103ae), + SPH_C32(0xd6ddc95d) }, + { SPH_C32(0xcdb60000), SPH_C32(0x18be1d14), SPH_C32(0x23800000), + SPH_C32(0x60440000), SPH_C32(0x295e31af), SPH_C32(0x12f081db), + SPH_C32(0xd0f53861), SPH_C32(0xd1ed8aed), SPH_C32(0xf3b00000), + SPH_C32(0xdeb209d4), SPH_C32(0x2e2c0000), SPH_C32(0x9fec0000), + SPH_C32(0x56127984), SPH_C32(0x28958de6), SPH_C32(0xd6eb1b6d), + SPH_C32(0xa8ac944a) }, + { SPH_C32(0x99e60000), SPH_C32(0x1ecf1d48), SPH_C32(0x062e0000), + SPH_C32(0x0a5a0000), SPH_C32(0x07fb7f70), SPH_C32(0x74be04c9), + SPH_C32(0x6f4f20a2), SPH_C32(0xaf9cd7fa), SPH_C32(0x4f3d0000), + SPH_C32(0x228909cc), SPH_C32(0x37af0000), SPH_C32(0x4ee70000), + SPH_C32(0xf80a0140), SPH_C32(0x6a3315b0), SPH_C32(0xd6f9c15a), + SPH_C32(0x8497c404) }, + { SPH_C32(0x186a0000), SPH_C32(0x30641d90), SPH_C32(0xf9200000), + SPH_C32(0x1d600000), SPH_C32(0x63d342c5), SPH_C32(0x9ef20c51), + SPH_C32(0x570bca2a), SPH_C32(0x4137796d), SPH_C32(0xdd1e0000), + SPH_C32(0x8b75099c), SPH_C32(0xb6c00000), SPH_C32(0x05740000), + SPH_C32(0xf5be5a18), SPH_C32(0x756ec18d), SPH_C32(0x746b7511), + SPH_C32(0xcd6b4860) }, + { SPH_C32(0x4c3a0000), SPH_C32(0x36151dcc), SPH_C32(0xdc8e0000), + SPH_C32(0x777e0000), SPH_C32(0x4d760c1a), SPH_C32(0xf8bc8943), + SPH_C32(0xe8b1d2e9), SPH_C32(0x3f46247a), SPH_C32(0x61930000), + SPH_C32(0x774e0984), SPH_C32(0xaf430000), SPH_C32(0xd47f0000), + SPH_C32(0x5ba622dc), SPH_C32(0x37c859db), SPH_C32(0x7479af26), + SPH_C32(0xe150182e) }, + { SPH_C32(0xa4e70000), SPH_C32(0xcc5f1d88), SPH_C32(0xe0a30000), + SPH_C32(0xcc6b0000), SPH_C32(0xcdcb3a01), SPH_C32(0xdc549407), + SPH_C32(0x5719101d), SPH_C32(0x6d0c2923), SPH_C32(0x35c30000), + SPH_C32(0x713f09d8), SPH_C32(0x8aed0000), SPH_C32(0xbe610000), + SPH_C32(0x75036c03), SPH_C32(0x5186dcc9), SPH_C32(0xcbc3b7e5), + SPH_C32(0x9f214539) }, + { SPH_C32(0xf0b70000), SPH_C32(0xca2e1dd4), SPH_C32(0xc50d0000), + SPH_C32(0xa6750000), SPH_C32(0xe36e74de), SPH_C32(0xba1a1115), + SPH_C32(0xe8a308de), SPH_C32(0x137d7434), SPH_C32(0x894e0000), + SPH_C32(0x8d0409c0), SPH_C32(0x936e0000), SPH_C32(0x6f6a0000), + SPH_C32(0xdb1b14c7), SPH_C32(0x1320449f), SPH_C32(0xcbd16dd2), + SPH_C32(0xb31a1577) } +}; + +static const sph_u32 T512_28[128][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x1e4e0000), SPH_C32(0xdecf0000), SPH_C32(0x6df80180), + SPH_C32(0x77240000), SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), + SPH_C32(0xcda31812), SPH_C32(0x98aa496e), SPH_C32(0xb2060000), + SPH_C32(0xc5690000), SPH_C32(0x28031200), SPH_C32(0x74670000), + SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), SPH_C32(0x33d1dfec), + SPH_C32(0x094e3198) }, + { SPH_C32(0xaec30000), SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), + SPH_C32(0x2c150000), SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), + SPH_C32(0xab92f78f), SPH_C32(0xa312567b), SPH_C32(0xdb250000), + SPH_C32(0x09290000), SPH_C32(0x49aac000), SPH_C32(0x81e10000), + SPH_C32(0xcafe6b59), SPH_C32(0x42793431), SPH_C32(0x43566b76), + SPH_C32(0xe86cba2e) }, + { SPH_C32(0xb08d0000), SPH_C32(0x42800001), SPH_C32(0x1429e180), + SPH_C32(0x5b310000), SPH_C32(0xa98b722d), SPH_C32(0x92f0de78), + SPH_C32(0x6631ef9d), SPH_C32(0x3bb81f15), SPH_C32(0x69230000), + SPH_C32(0xcc400000), SPH_C32(0x61a9d200), SPH_C32(0xf5860000), + SPH_C32(0x7c3c5dad), SPH_C32(0xa96b0dc9), SPH_C32(0x7087b49a), + SPH_C32(0xe1228bb6) }, + { SPH_C32(0xdb250000), SPH_C32(0x09290000), SPH_C32(0x49aac000), + SPH_C32(0x81e10000), SPH_C32(0xcafe6b59), SPH_C32(0x42793431), + SPH_C32(0x43566b76), SPH_C32(0xe86cba2e), SPH_C32(0x75e60000), + SPH_C32(0x95660001), SPH_C32(0x307b2000), SPH_C32(0xadf40000), + SPH_C32(0x8f321eea), SPH_C32(0x24298307), SPH_C32(0xe8c49cf9), + SPH_C32(0x4b7eec55) }, + { SPH_C32(0xc56b0000), SPH_C32(0xd7e60000), SPH_C32(0x2452c180), + SPH_C32(0xf6c50000), SPH_C32(0x26b96cc7), SPH_C32(0xb6d95d7f), + SPH_C32(0x8ef57364), SPH_C32(0x70c6f340), SPH_C32(0xc7e00000), + SPH_C32(0x500f0001), SPH_C32(0x18783200), SPH_C32(0xd9930000), + SPH_C32(0x39f0281e), SPH_C32(0xcf3bbaff), SPH_C32(0xdb154315), + SPH_C32(0x4230ddcd) }, + { SPH_C32(0x75e60000), SPH_C32(0x95660001), SPH_C32(0x307b2000), + SPH_C32(0xadf40000), SPH_C32(0x8f321eea), SPH_C32(0x24298307), + SPH_C32(0xe8c49cf9), SPH_C32(0x4b7eec55), SPH_C32(0xaec30000), + SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), SPH_C32(0x2c150000), + SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), SPH_C32(0xab92f78f), + SPH_C32(0xa312567b) }, + { SPH_C32(0x6ba80000), SPH_C32(0x4ba90001), SPH_C32(0x5d832180), + SPH_C32(0xdad00000), SPH_C32(0x63751974), SPH_C32(0xd089ea49), + SPH_C32(0x256784eb), SPH_C32(0xd3d4a53b), SPH_C32(0x1cc50000), + SPH_C32(0x59260001), SPH_C32(0x51d2f200), SPH_C32(0x58720000), + SPH_C32(0xf30e4347), SPH_C32(0x8d428ece), SPH_C32(0x98432863), + SPH_C32(0xaa5c67e3) }, + { SPH_C32(0x86790000), SPH_C32(0x3f390002), SPH_C32(0xe19ae000), + SPH_C32(0x98560000), SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), + SPH_C32(0xd3dd4944), SPH_C32(0x161ddab9), SPH_C32(0x30b70000), + SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), SPH_C32(0x42c40000), + SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), SPH_C32(0x21afa1ea), + SPH_C32(0xb0a51834) }, + { SPH_C32(0x98370000), SPH_C32(0xe1f60002), SPH_C32(0x8c62e180), + SPH_C32(0xef720000), SPH_C32(0x79226090), SPH_C32(0xba28a1a4), + SPH_C32(0x1e7e5156), SPH_C32(0x8eb793d7), SPH_C32(0x82b10000), + SPH_C32(0x20b90000), SPH_C32(0xdcf77200), SPH_C32(0x36a30000), + SPH_C32(0xd57a0b9e), SPH_C32(0x93a8ad98), SPH_C32(0x127e7e06), + SPH_C32(0xb9eb29ac) }, + { SPH_C32(0x28ba0000), SPH_C32(0xa3760003), SPH_C32(0x984b0000), + SPH_C32(0xb4430000), SPH_C32(0xd0a912bd), SPH_C32(0x28d87fdc), + SPH_C32(0x784fbecb), SPH_C32(0xb50f8cc2), SPH_C32(0xeb920000), + SPH_C32(0xecf90000), SPH_C32(0xbd5ea000), SPH_C32(0xc3250000), + SPH_C32(0xa9465633), SPH_C32(0x3ac3a051), SPH_C32(0x62f9ca9c), + SPH_C32(0x58c9a21a) }, + { SPH_C32(0x36f40000), SPH_C32(0x7db90003), SPH_C32(0xf5b30180), + SPH_C32(0xc3670000), SPH_C32(0x3cee1523), SPH_C32(0xdc781692), + SPH_C32(0xb5eca6d9), SPH_C32(0x2da5c5ac), SPH_C32(0x59940000), + SPH_C32(0x29900000), SPH_C32(0x955db200), SPH_C32(0xb7420000), + SPH_C32(0x1f8460c7), SPH_C32(0xd1d199a9), SPH_C32(0x51281570), + SPH_C32(0x51879382) }, + { SPH_C32(0x5d5c0000), SPH_C32(0x36100002), SPH_C32(0xa8302000), + SPH_C32(0x19b70000), SPH_C32(0x5f9b0c57), SPH_C32(0x0cf1fcdb), + SPH_C32(0x908b2232), SPH_C32(0xfe716097), SPH_C32(0x45510000), + SPH_C32(0x70b60001), SPH_C32(0xc48f4000), SPH_C32(0xef300000), + SPH_C32(0xec8a2380), SPH_C32(0x5c931767), SPH_C32(0xc96b3d13), + SPH_C32(0xfbdbf461) }, + { SPH_C32(0x43120000), SPH_C32(0xe8df0002), SPH_C32(0xc5c82180), + SPH_C32(0x6e930000), SPH_C32(0xb3dc0bc9), SPH_C32(0xf8519595), + SPH_C32(0x5d283a20), SPH_C32(0x66db29f9), SPH_C32(0xf7570000), + SPH_C32(0xb5df0001), SPH_C32(0xec8c5200), SPH_C32(0x9b570000), + SPH_C32(0x5a481574), SPH_C32(0xb7812e9f), SPH_C32(0xfabae2ff), + SPH_C32(0xf295c5f9) }, + { SPH_C32(0xf39f0000), SPH_C32(0xaa5f0003), SPH_C32(0xd1e1c000), + SPH_C32(0x35a20000), SPH_C32(0x1a5779e4), SPH_C32(0x6aa14bed), + SPH_C32(0x3b19d5bd), SPH_C32(0x5d6336ec), SPH_C32(0x9e740000), + SPH_C32(0x799f0001), SPH_C32(0x8d258000), SPH_C32(0x6ed10000), + SPH_C32(0x267448d9), SPH_C32(0x1eea2356), SPH_C32(0x8a3d5665), + SPH_C32(0x13b74e4f) }, + { SPH_C32(0xedd10000), SPH_C32(0x74900003), SPH_C32(0xbc19c180), + SPH_C32(0x42860000), SPH_C32(0xf6107e7a), SPH_C32(0x9e0122a3), + SPH_C32(0xf6bacdaf), SPH_C32(0xc5c97f82), SPH_C32(0x2c720000), + SPH_C32(0xbcf60001), SPH_C32(0xa5269200), SPH_C32(0x1ab60000), + SPH_C32(0x90b67e2d), SPH_C32(0xf5f81aae), SPH_C32(0xb9ec8989), + SPH_C32(0x1af97fd7) }, + { SPH_C32(0x30b70000), SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), + SPH_C32(0x42c40000), SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), + SPH_C32(0x21afa1ea), SPH_C32(0xb0a51834), SPH_C32(0xb6ce0000), + SPH_C32(0xdae90002), SPH_C32(0x156e8000), SPH_C32(0xda920000), + SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), SPH_C32(0xf272e8ae), + SPH_C32(0xa6b8c28d) }, + { SPH_C32(0x2ef90000), SPH_C32(0x3b1f0000), SPH_C32(0x990c6180), + SPH_C32(0x35e00000), SPH_C32(0x8fff3af4), SPH_C32(0x8c1afd2e), + SPH_C32(0xec0cb9f8), SPH_C32(0x280f515a), SPH_C32(0x04c80000), + SPH_C32(0x1f800002), SPH_C32(0x3d6d9200), SPH_C32(0xaef50000), + SPH_C32(0x401f6c90), SPH_C32(0xdd206572), SPH_C32(0xc1a33742), + SPH_C32(0xaff6f315) }, + { SPH_C32(0x9e740000), SPH_C32(0x799f0001), SPH_C32(0x8d258000), + SPH_C32(0x6ed10000), SPH_C32(0x267448d9), SPH_C32(0x1eea2356), + SPH_C32(0x8a3d5665), SPH_C32(0x13b74e4f), SPH_C32(0x6deb0000), + SPH_C32(0xd3c00002), SPH_C32(0x5cc44000), SPH_C32(0x5b730000), + SPH_C32(0x3c23313d), SPH_C32(0x744b68bb), SPH_C32(0xb12483d8), + SPH_C32(0x4ed478a3) }, + { SPH_C32(0x803a0000), SPH_C32(0xa7500001), SPH_C32(0xe0dd8180), + SPH_C32(0x19f50000), SPH_C32(0xca334f47), SPH_C32(0xea4a4a18), + SPH_C32(0x479e4e77), SPH_C32(0x8b1d0721), SPH_C32(0xdfed0000), + SPH_C32(0x16a90002), SPH_C32(0x74c75200), SPH_C32(0x2f140000), + SPH_C32(0x8ae107c9), SPH_C32(0x9f595143), SPH_C32(0x82f55c34), + SPH_C32(0x479a493b) }, + { SPH_C32(0xeb920000), SPH_C32(0xecf90000), SPH_C32(0xbd5ea000), + SPH_C32(0xc3250000), SPH_C32(0xa9465633), SPH_C32(0x3ac3a051), + SPH_C32(0x62f9ca9c), SPH_C32(0x58c9a21a), SPH_C32(0xc3280000), + SPH_C32(0x4f8f0003), SPH_C32(0x2515a000), SPH_C32(0x77660000), + SPH_C32(0x79ef448e), SPH_C32(0x121bdf8d), SPH_C32(0x1ab67457), + SPH_C32(0xedc62ed8) }, + { SPH_C32(0xf5dc0000), SPH_C32(0x32360000), SPH_C32(0xd0a6a180), + SPH_C32(0xb4010000), SPH_C32(0x450151ad), SPH_C32(0xce63c91f), + SPH_C32(0xaf5ad28e), SPH_C32(0xc063eb74), SPH_C32(0x712e0000), + SPH_C32(0x8ae60003), SPH_C32(0x0d16b200), SPH_C32(0x03010000), + SPH_C32(0xcf2d727a), SPH_C32(0xf909e675), SPH_C32(0x2967abbb), + SPH_C32(0xe4881f40) }, + { SPH_C32(0x45510000), SPH_C32(0x70b60001), SPH_C32(0xc48f4000), + SPH_C32(0xef300000), SPH_C32(0xec8a2380), SPH_C32(0x5c931767), + SPH_C32(0xc96b3d13), SPH_C32(0xfbdbf461), SPH_C32(0x180d0000), + SPH_C32(0x46a60003), SPH_C32(0x6cbf6000), SPH_C32(0xf6870000), + SPH_C32(0xb3112fd7), SPH_C32(0x5062ebbc), SPH_C32(0x59e01f21), + SPH_C32(0x05aa94f6) }, + { SPH_C32(0x5b1f0000), SPH_C32(0xae790001), SPH_C32(0xa9774180), + SPH_C32(0x98140000), SPH_C32(0x00cd241e), SPH_C32(0xa8337e29), + SPH_C32(0x04c82501), SPH_C32(0x6371bd0f), SPH_C32(0xaa0b0000), + SPH_C32(0x83cf0003), SPH_C32(0x44bc7200), SPH_C32(0x82e00000), + SPH_C32(0x05d31923), SPH_C32(0xbb70d244), SPH_C32(0x6a31c0cd), + SPH_C32(0x0ce4a56e) }, + { SPH_C32(0xb6ce0000), SPH_C32(0xdae90002), SPH_C32(0x156e8000), + SPH_C32(0xda920000), SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), + SPH_C32(0xf272e8ae), SPH_C32(0xa6b8c28d), SPH_C32(0x86790000), + SPH_C32(0x3f390002), SPH_C32(0xe19ae000), SPH_C32(0x98560000), + SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), SPH_C32(0xd3dd4944), + SPH_C32(0x161ddab9) }, + { SPH_C32(0xa8800000), SPH_C32(0x04260002), SPH_C32(0x78968180), + SPH_C32(0xadb60000), SPH_C32(0x1a9a5dfa), SPH_C32(0xc29235c4), + SPH_C32(0x3fd1f0bc), SPH_C32(0x3e128be3), SPH_C32(0x347f0000), + SPH_C32(0xfa500002), SPH_C32(0xc999f200), SPH_C32(0xec310000), + SPH_C32(0x23a751fa), SPH_C32(0xa59af112), SPH_C32(0xe00c96a8), + SPH_C32(0x1f53eb21) }, + { SPH_C32(0x180d0000), SPH_C32(0x46a60003), SPH_C32(0x6cbf6000), + SPH_C32(0xf6870000), SPH_C32(0xb3112fd7), SPH_C32(0x5062ebbc), + SPH_C32(0x59e01f21), SPH_C32(0x05aa94f6), SPH_C32(0x5d5c0000), + SPH_C32(0x36100002), SPH_C32(0xa8302000), SPH_C32(0x19b70000), + SPH_C32(0x5f9b0c57), SPH_C32(0x0cf1fcdb), SPH_C32(0x908b2232), + SPH_C32(0xfe716097) }, + { SPH_C32(0x06430000), SPH_C32(0x98690003), SPH_C32(0x01476180), + SPH_C32(0x81a30000), SPH_C32(0x5f562849), SPH_C32(0xa4c282f2), + SPH_C32(0x94430733), SPH_C32(0x9d00dd98), SPH_C32(0xef5a0000), + SPH_C32(0xf3790002), SPH_C32(0x80333200), SPH_C32(0x6dd00000), + SPH_C32(0xe9593aa3), SPH_C32(0xe7e3c523), SPH_C32(0xa35afdde), + SPH_C32(0xf73f510f) }, + { SPH_C32(0x6deb0000), SPH_C32(0xd3c00002), SPH_C32(0x5cc44000), + SPH_C32(0x5b730000), SPH_C32(0x3c23313d), SPH_C32(0x744b68bb), + SPH_C32(0xb12483d8), SPH_C32(0x4ed478a3), SPH_C32(0xf39f0000), + SPH_C32(0xaa5f0003), SPH_C32(0xd1e1c000), SPH_C32(0x35a20000), + SPH_C32(0x1a5779e4), SPH_C32(0x6aa14bed), SPH_C32(0x3b19d5bd), + SPH_C32(0x5d6336ec) }, + { SPH_C32(0x73a50000), SPH_C32(0x0d0f0002), SPH_C32(0x313c4180), + SPH_C32(0x2c570000), SPH_C32(0xd06436a3), SPH_C32(0x80eb01f5), + SPH_C32(0x7c879bca), SPH_C32(0xd67e31cd), SPH_C32(0x41990000), + SPH_C32(0x6f360003), SPH_C32(0xf9e2d200), SPH_C32(0x41c50000), + SPH_C32(0xac954f10), SPH_C32(0x81b37215), SPH_C32(0x08c80a51), + SPH_C32(0x542d0774) }, + { SPH_C32(0xc3280000), SPH_C32(0x4f8f0003), SPH_C32(0x2515a000), + SPH_C32(0x77660000), SPH_C32(0x79ef448e), SPH_C32(0x121bdf8d), + SPH_C32(0x1ab67457), SPH_C32(0xedc62ed8), SPH_C32(0x28ba0000), + SPH_C32(0xa3760003), SPH_C32(0x984b0000), SPH_C32(0xb4430000), + SPH_C32(0xd0a912bd), SPH_C32(0x28d87fdc), SPH_C32(0x784fbecb), + SPH_C32(0xb50f8cc2) }, + { SPH_C32(0xdd660000), SPH_C32(0x91400003), SPH_C32(0x48eda180), + SPH_C32(0x00420000), SPH_C32(0x95a84310), SPH_C32(0xe6bbb6c3), + SPH_C32(0xd7156c45), SPH_C32(0x756c67b6), SPH_C32(0x9abc0000), + SPH_C32(0x661f0003), SPH_C32(0xb0481200), SPH_C32(0xc0240000), + SPH_C32(0x666b2449), SPH_C32(0xc3ca4624), SPH_C32(0x4b9e6127), + SPH_C32(0xbc41bd5a) }, + { SPH_C32(0x14190000), SPH_C32(0x23ca003c), SPH_C32(0x50df0000), + SPH_C32(0x44b60000), SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), + SPH_C32(0x61e610b0), SPH_C32(0xdbcadb80), SPH_C32(0xe3430000), + SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), SPH_C32(0xaa4e0000), + SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), SPH_C32(0x123db156), + SPH_C32(0x3a4e99d7) }, + { SPH_C32(0x0a570000), SPH_C32(0xfd05003c), SPH_C32(0x3d270180), + SPH_C32(0x33920000), SPH_C32(0xf72b602e), SPH_C32(0xc853c53b), + SPH_C32(0xac4508a2), SPH_C32(0x436092ee), SPH_C32(0x51450000), + SPH_C32(0xff270014), SPH_C32(0xdac51200), SPH_C32(0xde290000), + SPH_C32(0x6ddc7452), SPH_C32(0xce7987ed), SPH_C32(0x21ec6eba), + SPH_C32(0x3300a84f) }, + { SPH_C32(0xbada0000), SPH_C32(0xbf85003d), SPH_C32(0x290ee000), + SPH_C32(0x68a30000), SPH_C32(0x5ea01203), SPH_C32(0x5aa31b43), + SPH_C32(0xca74e73f), SPH_C32(0x78d88dfb), SPH_C32(0x38660000), + SPH_C32(0x33670014), SPH_C32(0xbb6cc000), SPH_C32(0x2baf0000), + SPH_C32(0x11e029ff), SPH_C32(0x67128a24), SPH_C32(0x516bda20), + SPH_C32(0xd22223f9) }, + { SPH_C32(0xa4940000), SPH_C32(0x614a003d), SPH_C32(0x44f6e180), + SPH_C32(0x1f870000), SPH_C32(0xb2e7159d), SPH_C32(0xae03720d), + SPH_C32(0x07d7ff2d), SPH_C32(0xe072c495), SPH_C32(0x8a600000), + SPH_C32(0xf60e0014), SPH_C32(0x936fd200), SPH_C32(0x5fc80000), + SPH_C32(0xa7221f0b), SPH_C32(0x8c00b3dc), SPH_C32(0x62ba05cc), + SPH_C32(0xdb6c1261) }, + { SPH_C32(0xcf3c0000), SPH_C32(0x2ae3003c), SPH_C32(0x1975c000), + SPH_C32(0xc5570000), SPH_C32(0xd1920ce9), SPH_C32(0x7e8a9844), + SPH_C32(0x22b07bc6), SPH_C32(0x33a661ae), SPH_C32(0x96a50000), + SPH_C32(0xaf280015), SPH_C32(0xc2bd2000), SPH_C32(0x07ba0000), + SPH_C32(0x542c5c4c), SPH_C32(0x01423d12), SPH_C32(0xfaf92daf), + SPH_C32(0x71307582) }, + { SPH_C32(0xd1720000), SPH_C32(0xf42c003c), SPH_C32(0x748dc180), + SPH_C32(0xb2730000), SPH_C32(0x3dd50b77), SPH_C32(0x8a2af10a), + SPH_C32(0xef1363d4), SPH_C32(0xab0c28c0), SPH_C32(0x24a30000), + SPH_C32(0x6a410015), SPH_C32(0xeabe3200), SPH_C32(0x73dd0000), + SPH_C32(0xe2ee6ab8), SPH_C32(0xea5004ea), SPH_C32(0xc928f243), + SPH_C32(0x787e441a) }, + { SPH_C32(0x61ff0000), SPH_C32(0xb6ac003d), SPH_C32(0x60a42000), + SPH_C32(0xe9420000), SPH_C32(0x945e795a), SPH_C32(0x18da2f72), + SPH_C32(0x89228c49), SPH_C32(0x90b437d5), SPH_C32(0x4d800000), + SPH_C32(0xa6010015), SPH_C32(0x8b17e000), SPH_C32(0x865b0000), + SPH_C32(0x9ed23715), SPH_C32(0x433b0923), SPH_C32(0xb9af46d9), + SPH_C32(0x995ccfac) }, + { SPH_C32(0x7fb10000), SPH_C32(0x6863003d), SPH_C32(0x0d5c2180), + SPH_C32(0x9e660000), SPH_C32(0x78197ec4), SPH_C32(0xec7a463c), + SPH_C32(0x4481945b), SPH_C32(0x081e7ebb), SPH_C32(0xff860000), + SPH_C32(0x63680015), SPH_C32(0xa314f200), SPH_C32(0xf23c0000), + SPH_C32(0x281001e1), SPH_C32(0xa82930db), SPH_C32(0x8a7e9935), + SPH_C32(0x9012fe34) }, + { SPH_C32(0x92600000), SPH_C32(0x1cf3003e), SPH_C32(0xb145e000), + SPH_C32(0xdce00000), SPH_C32(0x8e0900be), SPH_C32(0x727b649f), + SPH_C32(0xb23b59f4), SPH_C32(0xcdd70139), SPH_C32(0xd3f40000), + SPH_C32(0xdf9e0014), SPH_C32(0x06326000), SPH_C32(0xe88a0000), + SPH_C32(0xb8a67fcc), SPH_C32(0x5dd12a75), SPH_C32(0x339210bc), + SPH_C32(0x8aeb81e3) }, + { SPH_C32(0x8c2e0000), SPH_C32(0xc23c003e), SPH_C32(0xdcbde180), + SPH_C32(0xabc40000), SPH_C32(0x624e0720), SPH_C32(0x86db0dd1), + SPH_C32(0x7f9841e6), SPH_C32(0x557d4857), SPH_C32(0x61f20000), + SPH_C32(0x1af70014), SPH_C32(0x2e317200), SPH_C32(0x9ced0000), + SPH_C32(0x0e644938), SPH_C32(0xb6c3138d), SPH_C32(0x0043cf50), + SPH_C32(0x83a5b07b) }, + { SPH_C32(0x3ca30000), SPH_C32(0x80bc003f), SPH_C32(0xc8940000), + SPH_C32(0xf0f50000), SPH_C32(0xcbc5750d), SPH_C32(0x142bd3a9), + SPH_C32(0x19a9ae7b), SPH_C32(0x6ec55742), SPH_C32(0x08d10000), + SPH_C32(0xd6b70014), SPH_C32(0x4f98a000), SPH_C32(0x696b0000), + SPH_C32(0x72581495), SPH_C32(0x1fa81e44), SPH_C32(0x70c47bca), + SPH_C32(0x62873bcd) }, + { SPH_C32(0x22ed0000), SPH_C32(0x5e73003f), SPH_C32(0xa56c0180), + SPH_C32(0x87d10000), SPH_C32(0x27827293), SPH_C32(0xe08bbae7), + SPH_C32(0xd40ab669), SPH_C32(0xf66f1e2c), SPH_C32(0xbad70000), + SPH_C32(0x13de0014), SPH_C32(0x679bb200), SPH_C32(0x1d0c0000), + SPH_C32(0xc49a2261), SPH_C32(0xf4ba27bc), SPH_C32(0x4315a426), + SPH_C32(0x6bc90a55) }, + { SPH_C32(0x49450000), SPH_C32(0x15da003e), SPH_C32(0xf8ef2000), + SPH_C32(0x5d010000), SPH_C32(0x44f76be7), SPH_C32(0x300250ae), + SPH_C32(0xf16d3282), SPH_C32(0x25bbbb17), SPH_C32(0xa6120000), + SPH_C32(0x4af80015), SPH_C32(0x36494000), SPH_C32(0x457e0000), + SPH_C32(0x37946126), SPH_C32(0x79f8a972), SPH_C32(0xdb568c45), + SPH_C32(0xc1956db6) }, + { SPH_C32(0x570b0000), SPH_C32(0xcb15003e), SPH_C32(0x95172180), + SPH_C32(0x2a250000), SPH_C32(0xa8b06c79), SPH_C32(0xc4a239e0), + SPH_C32(0x3cce2a90), SPH_C32(0xbd11f279), SPH_C32(0x14140000), + SPH_C32(0x8f910015), SPH_C32(0x1e4a5200), SPH_C32(0x31190000), + SPH_C32(0x815657d2), SPH_C32(0x92ea908a), SPH_C32(0xe88753a9), + SPH_C32(0xc8db5c2e) }, + { SPH_C32(0xe7860000), SPH_C32(0x8995003f), SPH_C32(0x813ec000), + SPH_C32(0x71140000), SPH_C32(0x013b1e54), SPH_C32(0x5652e798), + SPH_C32(0x5affc50d), SPH_C32(0x86a9ed6c), SPH_C32(0x7d370000), + SPH_C32(0x43d10015), SPH_C32(0x7fe38000), SPH_C32(0xc49f0000), + SPH_C32(0xfd6a0a7f), SPH_C32(0x3b819d43), SPH_C32(0x9800e733), + SPH_C32(0x29f9d798) }, + { SPH_C32(0xf9c80000), SPH_C32(0x575a003f), SPH_C32(0xecc6c180), + SPH_C32(0x06300000), SPH_C32(0xed7c19ca), SPH_C32(0xa2f28ed6), + SPH_C32(0x975cdd1f), SPH_C32(0x1e03a402), SPH_C32(0xcf310000), + SPH_C32(0x86b80015), SPH_C32(0x57e09200), SPH_C32(0xb0f80000), + SPH_C32(0x4ba83c8b), SPH_C32(0xd093a4bb), SPH_C32(0xabd138df), + SPH_C32(0x20b7e600) }, + { SPH_C32(0x24ae0000), SPH_C32(0xc61a003c), SPH_C32(0xa42b6000), + SPH_C32(0x06720000), SPH_C32(0x78d45ada), SPH_C32(0x44493815), + SPH_C32(0x4049b15a), SPH_C32(0x6b6fc3b4), SPH_C32(0x558d0000), + SPH_C32(0xe0a70016), SPH_C32(0xe7a88000), SPH_C32(0x70dc0000), + SPH_C32(0x2dc318c2), SPH_C32(0x1359e29f), SPH_C32(0xe04f59f8), + SPH_C32(0x9cf65b5a) }, + { SPH_C32(0x3ae00000), SPH_C32(0x18d5003c), SPH_C32(0xc9d36180), + SPH_C32(0x71560000), SPH_C32(0x94935d44), SPH_C32(0xb0e9515b), + SPH_C32(0x8deaa948), SPH_C32(0xf3c58ada), SPH_C32(0xe78b0000), + SPH_C32(0x25ce0016), SPH_C32(0xcfab9200), SPH_C32(0x04bb0000), + SPH_C32(0x9b012e36), SPH_C32(0xf84bdb67), SPH_C32(0xd39e8614), + SPH_C32(0x95b86ac2) }, + { SPH_C32(0x8a6d0000), SPH_C32(0x5a55003d), SPH_C32(0xddfa8000), + SPH_C32(0x2a670000), SPH_C32(0x3d182f69), SPH_C32(0x22198f23), + SPH_C32(0xebdb46d5), SPH_C32(0xc87d95cf), SPH_C32(0x8ea80000), + SPH_C32(0xe98e0016), SPH_C32(0xae024000), SPH_C32(0xf13d0000), + SPH_C32(0xe73d739b), SPH_C32(0x5120d6ae), SPH_C32(0xa319328e), + SPH_C32(0x749ae174) }, + { SPH_C32(0x94230000), SPH_C32(0x849a003d), SPH_C32(0xb0028180), + SPH_C32(0x5d430000), SPH_C32(0xd15f28f7), SPH_C32(0xd6b9e66d), + SPH_C32(0x26785ec7), SPH_C32(0x50d7dca1), SPH_C32(0x3cae0000), + SPH_C32(0x2ce70016), SPH_C32(0x86015200), SPH_C32(0x855a0000), + SPH_C32(0x51ff456f), SPH_C32(0xba32ef56), SPH_C32(0x90c8ed62), + SPH_C32(0x7dd4d0ec) }, + { SPH_C32(0xff8b0000), SPH_C32(0xcf33003c), SPH_C32(0xed81a000), + SPH_C32(0x87930000), SPH_C32(0xb22a3183), SPH_C32(0x06300c24), + SPH_C32(0x031fda2c), SPH_C32(0x8303799a), SPH_C32(0x206b0000), + SPH_C32(0x75c10017), SPH_C32(0xd7d3a000), SPH_C32(0xdd280000), + SPH_C32(0xa2f10628), SPH_C32(0x37706198), SPH_C32(0x088bc501), + SPH_C32(0xd788b70f) }, + { SPH_C32(0xe1c50000), SPH_C32(0x11fc003c), SPH_C32(0x8079a180), + SPH_C32(0xf0b70000), SPH_C32(0x5e6d361d), SPH_C32(0xf290656a), + SPH_C32(0xcebcc23e), SPH_C32(0x1ba930f4), SPH_C32(0x926d0000), + SPH_C32(0xb0a80017), SPH_C32(0xffd0b200), SPH_C32(0xa94f0000), + SPH_C32(0x143330dc), SPH_C32(0xdc625860), SPH_C32(0x3b5a1aed), + SPH_C32(0xdec649697) }, + { SPH_C32(0x51480000), SPH_C32(0x537c003d), SPH_C32(0x94504000), + SPH_C32(0xab860000), SPH_C32(0xf7e64430), SPH_C32(0x6060bb12), + SPH_C32(0xa88d2da3), SPH_C32(0x20112fe1), SPH_C32(0xfb4e0000), + SPH_C32(0x7ce80017), SPH_C32(0x9e796000), SPH_C32(0x5cc90000), + SPH_C32(0x680f6d71), SPH_C32(0x750955a9), SPH_C32(0x4bddae77), + SPH_C32(0x3fe40d21) }, + { SPH_C32(0x4f060000), SPH_C32(0x8db3003d), SPH_C32(0xf9a84180), + SPH_C32(0xdca20000), SPH_C32(0x1ba143ae), SPH_C32(0x94c0d25c), + SPH_C32(0x652e35b1), SPH_C32(0xb8bb668f), SPH_C32(0x49480000), + SPH_C32(0xb9810017), SPH_C32(0xb67a7200), SPH_C32(0x28ae0000), + SPH_C32(0xdecd5b85), SPH_C32(0x9e1b6c51), SPH_C32(0x780c719b), + SPH_C32(0x36aa3cb9) }, + { SPH_C32(0xa2d70000), SPH_C32(0xf923003e), SPH_C32(0x45b18000), + SPH_C32(0x9e240000), SPH_C32(0xedb13dd4), SPH_C32(0x0ac1f0ff), + SPH_C32(0x9394f81e), SPH_C32(0x7d72190d), SPH_C32(0x653a0000), + SPH_C32(0x05770016), SPH_C32(0x135ce000), SPH_C32(0x32180000), + SPH_C32(0x4e7b25a8), SPH_C32(0x6be376ff), SPH_C32(0xc1e0f812), + SPH_C32(0x2c53436e) }, + { SPH_C32(0xbc990000), SPH_C32(0x27ec003e), SPH_C32(0x28498180), + SPH_C32(0xe9000000), SPH_C32(0x01f63a4a), SPH_C32(0xfe6199b1), + SPH_C32(0x5e37e00c), SPH_C32(0xe5d85063), SPH_C32(0xd73c0000), + SPH_C32(0xc01e0016), SPH_C32(0x3b5ff200), SPH_C32(0x467f0000), + SPH_C32(0xf8b9135c), SPH_C32(0x80f14f07), SPH_C32(0xf23127fe), + SPH_C32(0x251d72f6) }, + { SPH_C32(0x0c140000), SPH_C32(0x656c003f), SPH_C32(0x3c606000), + SPH_C32(0xb2310000), SPH_C32(0xa87d4867), SPH_C32(0x6c9147c9), + SPH_C32(0x38060f91), SPH_C32(0xde604f76), SPH_C32(0xbe1f0000), + SPH_C32(0x0c5e0016), SPH_C32(0x5af62000), SPH_C32(0xb3f90000), + SPH_C32(0x84854ef1), SPH_C32(0x299a42ce), SPH_C32(0x82b69364), + SPH_C32(0xc43ff940) }, + { SPH_C32(0x125a0000), SPH_C32(0xbba3003f), SPH_C32(0x51986180), + SPH_C32(0xc5150000), SPH_C32(0x443a4ff9), SPH_C32(0x98312e87), + SPH_C32(0xf5a51783), SPH_C32(0x46ca0618), SPH_C32(0x0c190000), + SPH_C32(0xc9370016), SPH_C32(0x72f53200), SPH_C32(0xc79e0000), + SPH_C32(0x32477805), SPH_C32(0xc2887b36), SPH_C32(0xb1674c88), + SPH_C32(0xcd71c8d8) }, + { SPH_C32(0x79f20000), SPH_C32(0xf00a003e), SPH_C32(0x0c1b4000), + SPH_C32(0x1fc50000), SPH_C32(0x274f568d), SPH_C32(0x48b8c4ce), + SPH_C32(0xd0c29368), SPH_C32(0x951ea323), SPH_C32(0x10dc0000), + SPH_C32(0x90110017), SPH_C32(0x2327c000), SPH_C32(0x9fec0000), + SPH_C32(0xc1493b42), SPH_C32(0x4fcaf5f8), SPH_C32(0x292464eb), + SPH_C32(0x672daf3b) }, + { SPH_C32(0x67bc0000), SPH_C32(0x2ec5003e), SPH_C32(0x61e34180), + SPH_C32(0x68e10000), SPH_C32(0xcb085113), SPH_C32(0xbc18ad80), + SPH_C32(0x1d618b7a), SPH_C32(0x0db4ea4d), SPH_C32(0xa2da0000), + SPH_C32(0x55780017), SPH_C32(0x0b24d200), SPH_C32(0xeb8b0000), + SPH_C32(0x778b0db6), SPH_C32(0xa4d8cc00), SPH_C32(0x1af5bb07), + SPH_C32(0x6e639ea3) }, + { SPH_C32(0xd7310000), SPH_C32(0x6c45003f), SPH_C32(0x75caa000), + SPH_C32(0x33d00000), SPH_C32(0x6283233e), SPH_C32(0x2ee873f8), + SPH_C32(0x7b5064e7), SPH_C32(0x360cf558), SPH_C32(0xcbf90000), + SPH_C32(0x99380017), SPH_C32(0x6a8d0000), SPH_C32(0x1e0d0000), + SPH_C32(0x0bb7501b), SPH_C32(0x0db3c1c9), SPH_C32(0x6a720f9d), + SPH_C32(0x8f411515) }, + { SPH_C32(0xc97f0000), SPH_C32(0xb28a003f), SPH_C32(0x1832a180), + SPH_C32(0x44f40000), SPH_C32(0x8ec424a0), SPH_C32(0xda481ab6), + SPH_C32(0xb6f37cf5), SPH_C32(0xaea6bc36), SPH_C32(0x79ff0000), + SPH_C32(0x5c510017), SPH_C32(0x428e1200), SPH_C32(0x6a6a0000), + SPH_C32(0xbd7566ef), SPH_C32(0xe6a1f831), SPH_C32(0x59a3d071), + SPH_C32(0x860f248d) }, + { SPH_C32(0xe3430000), SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), + SPH_C32(0xaa4e0000), SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), + SPH_C32(0x123db156), SPH_C32(0x3a4e99d7), SPH_C32(0xf75a0000), + SPH_C32(0x19840028), SPH_C32(0xa2190000), SPH_C32(0xeef80000), + SPH_C32(0xc0722516), SPH_C32(0x19981260), SPH_C32(0x73dba1e6), + SPH_C32(0xe1844257) }, + { SPH_C32(0xfd0d0000), SPH_C32(0xe4810014), SPH_C32(0x9f3e0180), + SPH_C32(0xdd6a0000), SPH_C32(0x37594538), SPH_C32(0xd1cbd75b), + SPH_C32(0xdf9ea944), SPH_C32(0xa2e4d0b9), SPH_C32(0x455c0000), + SPH_C32(0xdced0028), SPH_C32(0x8a1a1200), SPH_C32(0x9a9f0000), + SPH_C32(0x76b013e2), SPH_C32(0xf28a2b98), SPH_C32(0x400a7e0a), + SPH_C32(0xe8ca73cf) }, + { SPH_C32(0x4d800000), SPH_C32(0xa6010015), SPH_C32(0x8b17e000), + SPH_C32(0x865b0000), SPH_C32(0x9ed23715), SPH_C32(0x433b0923), + SPH_C32(0xb9af46d9), SPH_C32(0x995ccfac), SPH_C32(0x2c7f0000), + SPH_C32(0x10ad0028), SPH_C32(0xebb3c000), SPH_C32(0x6f190000), + SPH_C32(0x0a8c4e4f), SPH_C32(0x5be12651), SPH_C32(0x308dca90), + SPH_C32(0x09e8f879) }, + { SPH_C32(0x53ce0000), SPH_C32(0x78ce0015), SPH_C32(0xe6efe180), + SPH_C32(0xf17f0000), SPH_C32(0x7295308b), SPH_C32(0xb79b606d), + SPH_C32(0x740c5ecb), SPH_C32(0x01f686c2), SPH_C32(0x9e790000), + SPH_C32(0xd5c40028), SPH_C32(0xc3b0d200), SPH_C32(0x1b7e0000), + SPH_C32(0xbc4e78bb), SPH_C32(0xb0f31fa9), SPH_C32(0x035c157c), + SPH_C32(0x00a6c9e1) }, + { SPH_C32(0x38660000), SPH_C32(0x33670014), SPH_C32(0xbb6cc000), + SPH_C32(0x2baf0000), SPH_C32(0x11e029ff), SPH_C32(0x67128a24), + SPH_C32(0x516bda20), SPH_C32(0xd22223f9), SPH_C32(0x82bc0000), + SPH_C32(0x8ce20029), SPH_C32(0x92622000), SPH_C32(0x430c0000), + SPH_C32(0x4f403bfc), SPH_C32(0x3db19167), SPH_C32(0x9b1f3d1f), + SPH_C32(0xaafaae02) }, + { SPH_C32(0x26280000), SPH_C32(0xeda80014), SPH_C32(0xd694c180), + SPH_C32(0x5c8b0000), SPH_C32(0xfda72e61), SPH_C32(0x93b2e36a), + SPH_C32(0x9cc8c232), SPH_C32(0x4a886a97), SPH_C32(0x30ba0000), + SPH_C32(0x498b0029), SPH_C32(0xba613200), SPH_C32(0x376b0000), + SPH_C32(0xf9820d08), SPH_C32(0xd6a3a89f), SPH_C32(0xa8cee2f3), + SPH_C32(0xa3b49f9a) }, + { SPH_C32(0x96a50000), SPH_C32(0xaf280015), SPH_C32(0xc2bd2000), + SPH_C32(0x07ba0000), SPH_C32(0x542c5c4c), SPH_C32(0x01423d12), + SPH_C32(0xfaf92daf), SPH_C32(0x71307582), SPH_C32(0x59990000), + SPH_C32(0x85cb0029), SPH_C32(0xdbc8e000), SPH_C32(0xc2ed0000), + SPH_C32(0x85be50a5), SPH_C32(0x7fc8a556), SPH_C32(0xd8495669), + SPH_C32(0x4296142c) }, + { SPH_C32(0x88eb0000), SPH_C32(0x71e70015), SPH_C32(0xaf452180), + SPH_C32(0x709e0000), SPH_C32(0xb86b5bd2), SPH_C32(0xf5e2545c), + SPH_C32(0x375a35bd), SPH_C32(0xe99a3cec), SPH_C32(0xeb9f0000), + SPH_C32(0x40a20029), SPH_C32(0xf3cbf200), SPH_C32(0xb68a0000), + SPH_C32(0x337c6651), SPH_C32(0x94da9cae), SPH_C32(0xeb988985), + SPH_C32(0x4bd825b4) }, + { SPH_C32(0x653a0000), SPH_C32(0x05770016), SPH_C32(0x135ce000), + SPH_C32(0x32180000), SPH_C32(0x4e7b25a8), SPH_C32(0x6be376ff), + SPH_C32(0xc1e0f812), SPH_C32(0x2c53436e), SPH_C32(0xc7ed0000), + SPH_C32(0xfc540028), SPH_C32(0x56ed6000), SPH_C32(0xac3c0000), + SPH_C32(0xa3ca187c), SPH_C32(0x61228600), SPH_C32(0x5274000c), + SPH_C32(0x51215a63) }, + { SPH_C32(0x7b740000), SPH_C32(0xdbb80016), SPH_C32(0x7ea4e180), + SPH_C32(0x453c0000), SPH_C32(0xa23c2236), SPH_C32(0x9f431fb1), + SPH_C32(0x0c43e000), SPH_C32(0xb4f90a00), SPH_C32(0x75eb0000), + SPH_C32(0x393d0028), SPH_C32(0x7eee7200), SPH_C32(0xd85b0000), + SPH_C32(0x15082e88), SPH_C32(0x8a30bff8), SPH_C32(0x61a5dfe0), + SPH_C32(0x586f6bfb) }, + { SPH_C32(0xcbf90000), SPH_C32(0x99380017), SPH_C32(0x6a8d0000), + SPH_C32(0x1e0d0000), SPH_C32(0x0bb7501b), SPH_C32(0x0db3c1c9), + SPH_C32(0x6a720f9d), SPH_C32(0x8f411515), SPH_C32(0x1cc80000), + SPH_C32(0xf57d0028), SPH_C32(0x1f47a000), SPH_C32(0x2ddd0000), + SPH_C32(0x69347325), SPH_C32(0x235bb231), SPH_C32(0x11226b7a), + SPH_C32(0xb94de04d) }, + { SPH_C32(0xd5b70000), SPH_C32(0x47f70017), SPH_C32(0x07750180), + SPH_C32(0x69290000), SPH_C32(0xe7f05785), SPH_C32(0xf913a887), + SPH_C32(0xa7d1178f), SPH_C32(0x17eb5c7b), SPH_C32(0xaece0000), + SPH_C32(0x30140028), SPH_C32(0x3744b200), SPH_C32(0x59ba0000), + SPH_C32(0xdff645d1), SPH_C32(0xc8498bc9), SPH_C32(0x22f3b496), + SPH_C32(0xb003d1d5) }, + { SPH_C32(0xbe1f0000), SPH_C32(0x0c5e0016), SPH_C32(0x5af62000), + SPH_C32(0xb3f90000), SPH_C32(0x84854ef1), SPH_C32(0x299a42ce), + SPH_C32(0x82b69364), SPH_C32(0xc43ff940), SPH_C32(0xb20b0000), + SPH_C32(0x69320029), SPH_C32(0x66964000), SPH_C32(0x01c80000), + SPH_C32(0x2cf80696), SPH_C32(0x450b0507), SPH_C32(0xbab09cf5), + SPH_C32(0x1a5fb636) }, + { SPH_C32(0xa0510000), SPH_C32(0xd2910016), SPH_C32(0x370e2180), + SPH_C32(0xc4dd0000), SPH_C32(0x68c2496f), SPH_C32(0xdd3a2b80), + SPH_C32(0x4f158b76), SPH_C32(0x5c95b02e), SPH_C32(0x000d0000), + SPH_C32(0xac5b0029), SPH_C32(0x4e955200), SPH_C32(0x75af0000), + SPH_C32(0x9a3a3062), SPH_C32(0xae193cff), SPH_C32(0x89614319), + SPH_C32(0x131187ae) }, + { SPH_C32(0x10dc0000), SPH_C32(0x90110017), SPH_C32(0x2327c000), + SPH_C32(0x9fec0000), SPH_C32(0xc1493b42), SPH_C32(0x4fcaf5f8), + SPH_C32(0x292464eb), SPH_C32(0x672daf3b), SPH_C32(0x692e0000), + SPH_C32(0x601b0029), SPH_C32(0x2f3c8000), SPH_C32(0x80290000), + SPH_C32(0xe6066dcf), SPH_C32(0x07723136), SPH_C32(0xf9e6f783), + SPH_C32(0xf2330c18) }, + { SPH_C32(0x0e920000), SPH_C32(0x4ede0017), SPH_C32(0x4edfc180), + SPH_C32(0xe8c80000), SPH_C32(0x2d0e3cdc), SPH_C32(0xbb6a9cb6), + SPH_C32(0xe4877cf9), SPH_C32(0xff87e655), SPH_C32(0xdb280000), + SPH_C32(0xa5720029), SPH_C32(0x073f9200), SPH_C32(0xf44e0000), + SPH_C32(0x50c45b3b), SPH_C32(0xec6008ce), SPH_C32(0xca37286f), + SPH_C32(0xfb7d3d80) }, + { SPH_C32(0xd3f40000), SPH_C32(0xdf9e0014), SPH_C32(0x06326000), + SPH_C32(0xe88a0000), SPH_C32(0xb8a67fcc), SPH_C32(0x5dd12a75), + SPH_C32(0x339210bc), SPH_C32(0x8aeb81e3), SPH_C32(0x41940000), + SPH_C32(0xc36d002a), SPH_C32(0xb7778000), SPH_C32(0x346a0000), + SPH_C32(0x36af7f72), SPH_C32(0x2faa4eea), SPH_C32(0x81a94948), + SPH_C32(0x473c80da) }, + { SPH_C32(0xcdba0000), SPH_C32(0x01510014), SPH_C32(0x6bca6180), + SPH_C32(0x9fae0000), SPH_C32(0x54e17852), SPH_C32(0xa971433b), + SPH_C32(0xfe3108ae), SPH_C32(0x1241c88d), SPH_C32(0xf3920000), + SPH_C32(0x0604002a), SPH_C32(0x9f749200), SPH_C32(0x400d0000), + SPH_C32(0x806d4986), SPH_C32(0xc4b87712), SPH_C32(0xb27896a4), + SPH_C32(0x4e72b142) }, + { SPH_C32(0x7d370000), SPH_C32(0x43d10015), SPH_C32(0x7fe38000), + SPH_C32(0xc49f0000), SPH_C32(0xfd6a0a7f), SPH_C32(0x3b819d43), + SPH_C32(0x9800e733), SPH_C32(0x29f9d798), SPH_C32(0x9ab10000), + SPH_C32(0xca44002a), SPH_C32(0xfedd4000), SPH_C32(0xb58b0000), + SPH_C32(0xfc51142b), SPH_C32(0x6dd37adb), SPH_C32(0xc2ff223e), + SPH_C32(0xaf503af4) }, + { SPH_C32(0x63790000), SPH_C32(0x9d1e0015), SPH_C32(0x121b8180), + SPH_C32(0xb3bb0000), SPH_C32(0x112d0de1), SPH_C32(0xcf21f40d), + SPH_C32(0x55a3ff21), SPH_C32(0xb1539ef6), SPH_C32(0x28b70000), + SPH_C32(0x0f2d002a), SPH_C32(0xd6de5200), SPH_C32(0xc1ec0000), + SPH_C32(0x4a9322df), SPH_C32(0x86c14323), SPH_C32(0xf12efdd2), + SPH_C32(0xa61e0b6c) }, + { SPH_C32(0x08d10000), SPH_C32(0xd6b70014), SPH_C32(0x4f98a000), + SPH_C32(0x696b0000), SPH_C32(0x72581495), SPH_C32(0x1fa81e44), + SPH_C32(0x70c47bca), SPH_C32(0x62873bcd), SPH_C32(0x34720000), + SPH_C32(0x560b002b), SPH_C32(0x870ca000), SPH_C32(0x999e0000), + SPH_C32(0xb99d6198), SPH_C32(0x0b83cded), SPH_C32(0x696dd5b1), + SPH_C32(0x0c426c8f) }, + { SPH_C32(0x169f0000), SPH_C32(0x08780014), SPH_C32(0x2260a180), + SPH_C32(0x1e4f0000), SPH_C32(0x9e1f130b), SPH_C32(0xeb08770a), + SPH_C32(0xbd6763d8), SPH_C32(0xfa2d72a3), SPH_C32(0x86740000), + SPH_C32(0x9362002b), SPH_C32(0xaf0fb200), SPH_C32(0xedf90000), + SPH_C32(0x0f5f576c), SPH_C32(0xe091f415), SPH_C32(0x5abc0a5d), + SPH_C32(0x050c5d17) }, + { SPH_C32(0xa6120000), SPH_C32(0x4af80015), SPH_C32(0x36494000), + SPH_C32(0x457e0000), SPH_C32(0x37946126), SPH_C32(0x79f8a972), + SPH_C32(0xdb568c45), SPH_C32(0xc1956db6), SPH_C32(0xef570000), + SPH_C32(0x5f22002b), SPH_C32(0xcea66000), SPH_C32(0x187f0000), + SPH_C32(0x73630ac1), SPH_C32(0x49faf9dc), SPH_C32(0x2a3bbec7), + SPH_C32(0xe42ed6a1) }, + { SPH_C32(0xb85c0000), SPH_C32(0x94370015), SPH_C32(0x5bb14180), + SPH_C32(0x325a0000), SPH_C32(0xdbd366b8), SPH_C32(0x8d58c03c), + SPH_C32(0x16f59457), SPH_C32(0x593f24d8), SPH_C32(0x5d510000), + SPH_C32(0x9a4b002b), SPH_C32(0xe6a57200), SPH_C32(0x6c180000), + SPH_C32(0xc5a13c35), SPH_C32(0xa2e8c024), SPH_C32(0x19ea612b), + SPH_C32(0xed60e739) }, + { SPH_C32(0x558d0000), SPH_C32(0xe0a70016), SPH_C32(0xe7a88000), + SPH_C32(0x70dc0000), SPH_C32(0x2dc318c2), SPH_C32(0x1359e29f), + SPH_C32(0xe04f59f8), SPH_C32(0x9cf65b5a), SPH_C32(0x71230000), + SPH_C32(0x26bd002a), SPH_C32(0x4383e000), SPH_C32(0x76ae0000), + SPH_C32(0x55174218), SPH_C32(0x5710da8a), SPH_C32(0xa006e8a2), + SPH_C32(0xf79998ee) }, + { SPH_C32(0x4bc30000), SPH_C32(0x3e680016), SPH_C32(0x8a508180), + SPH_C32(0x07f80000), SPH_C32(0xc1841f5c), SPH_C32(0xe7f98bd1), + SPH_C32(0x2dec41ea), SPH_C32(0x045c1234), SPH_C32(0xc3250000), + SPH_C32(0xe3d4002a), SPH_C32(0x6b80f200), SPH_C32(0x02c90000), + SPH_C32(0xe3d574ec), SPH_C32(0xbc02e372), SPH_C32(0x93d7374e), + SPH_C32(0xfed7a976) }, + { SPH_C32(0xfb4e0000), SPH_C32(0x7ce80017), SPH_C32(0x9e796000), + SPH_C32(0x5cc90000), SPH_C32(0x680f6d71), SPH_C32(0x750955a9), + SPH_C32(0x4bddae77), SPH_C32(0x3fe40d21), SPH_C32(0xaa060000), + SPH_C32(0x2f94002a), SPH_C32(0x0a292000), SPH_C32(0xf74f0000), + SPH_C32(0x9fe92941), SPH_C32(0x1569eebb), SPH_C32(0xe35083d4), + SPH_C32(0x1ff522c0) }, + { SPH_C32(0xe5000000), SPH_C32(0xa2270017), SPH_C32(0xf3816180), + SPH_C32(0x2bed0000), SPH_C32(0x84486aef), SPH_C32(0x81a93ce7), + SPH_C32(0x867eb665), SPH_C32(0xa74e444f), SPH_C32(0x18000000), + SPH_C32(0xeafd002a), SPH_C32(0x222a3200), SPH_C32(0x83280000), + SPH_C32(0x292b1fb5), SPH_C32(0xfe7bd743), SPH_C32(0xd0815c38), + SPH_C32(0x16bb1358) }, + { SPH_C32(0x8ea80000), SPH_C32(0xe98e0016), SPH_C32(0xae024000), + SPH_C32(0xf13d0000), SPH_C32(0xe73d739b), SPH_C32(0x5120d6ae), + SPH_C32(0xa319328e), SPH_C32(0x749ae174), SPH_C32(0x04c50000), + SPH_C32(0xb3db002b), SPH_C32(0x73f8c000), SPH_C32(0xdb5a0000), + SPH_C32(0xda255cf2), SPH_C32(0x7339598d), SPH_C32(0x48c2745b), + SPH_C32(0xbce774bb) }, + { SPH_C32(0x90e60000), SPH_C32(0x37410016), SPH_C32(0xc3fa4180), + SPH_C32(0x86190000), SPH_C32(0x0b7a7405), SPH_C32(0xa580bfe0), + SPH_C32(0x6eba2a9c), SPH_C32(0xec30a81a), SPH_C32(0xb6c30000), + SPH_C32(0x76b2002b), SPH_C32(0x5bfbd200), SPH_C32(0xaf3d0000), + SPH_C32(0x6ce76a06), SPH_C32(0x982b6075), SPH_C32(0x7b13abb7), + SPH_C32(0xb5a94523) }, + { SPH_C32(0x206b0000), SPH_C32(0x75c10017), SPH_C32(0xd7d3a000), + SPH_C32(0xdd280000), SPH_C32(0xa2f10628), SPH_C32(0x37706198), + SPH_C32(0x088bc501), SPH_C32(0xd788b70f), SPH_C32(0xdfe00000), + SPH_C32(0xbaf2002b), SPH_C32(0x3a520000), SPH_C32(0x5abb0000), + SPH_C32(0x10db37ab), SPH_C32(0x31406dbc), SPH_C32(0x0b941f2d), + SPH_C32(0x548bce95) }, + { SPH_C32(0x3e250000), SPH_C32(0xab0e0017), SPH_C32(0xba2ba180), + SPH_C32(0xaa0c0000), SPH_C32(0x4eb601b6), SPH_C32(0xc3d008d6), + SPH_C32(0xc528dd13), SPH_C32(0x4f22fe61), SPH_C32(0x6de60000), + SPH_C32(0x7f9b002b), SPH_C32(0x12511200), SPH_C32(0x2edc0000), + SPH_C32(0xa619015f), SPH_C32(0xda525444), SPH_C32(0x3845c0c1), + SPH_C32(0x5dc5ff0d) }, + { SPH_C32(0xf75a0000), SPH_C32(0x19840028), SPH_C32(0xa2190000), + SPH_C32(0xeef80000), SPH_C32(0xc0722516), SPH_C32(0x19981260), + SPH_C32(0x73dba1e6), SPH_C32(0xe1844257), SPH_C32(0x14190000), + SPH_C32(0x23ca003c), SPH_C32(0x50df0000), SPH_C32(0x44b60000), + SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), SPH_C32(0x61e610b0), + SPH_C32(0xdbcadb80) }, + { SPH_C32(0xe9140000), SPH_C32(0xc74b0028), SPH_C32(0xcfe10180), + SPH_C32(0x99dc0000), SPH_C32(0x2c352288), SPH_C32(0xed387b2e), + SPH_C32(0xbe78b9f4), SPH_C32(0x792e0b39), SPH_C32(0xa61f0000), + SPH_C32(0xe6a3003c), SPH_C32(0x78dc1200), SPH_C32(0x30d10000), + SPH_C32(0xadae5144), SPH_C32(0xd7e1958d), SPH_C32(0x5237cf5c), + SPH_C32(0xd284ea18) }, + { SPH_C32(0x59990000), SPH_C32(0x85cb0029), SPH_C32(0xdbc8e000), + SPH_C32(0xc2ed0000), SPH_C32(0x85be50a5), SPH_C32(0x7fc8a556), + SPH_C32(0xd8495669), SPH_C32(0x4296142c), SPH_C32(0xcf3c0000), + SPH_C32(0x2ae3003c), SPH_C32(0x1975c000), SPH_C32(0xc5570000), + SPH_C32(0xd1920ce9), SPH_C32(0x7e8a9844), SPH_C32(0x22b07bc6), + SPH_C32(0x33a661ae) }, + { SPH_C32(0x47d70000), SPH_C32(0x5b040029), SPH_C32(0xb630e180), + SPH_C32(0xb5c90000), SPH_C32(0x69f9573b), SPH_C32(0x8b68cc18), + SPH_C32(0x15ea4e7b), SPH_C32(0xda3c5d42), SPH_C32(0x7d3a0000), + SPH_C32(0xef8a003c), SPH_C32(0x3176d200), SPH_C32(0xb1300000), + SPH_C32(0x67503a1d), SPH_C32(0x9598a1bc), SPH_C32(0x1161a42a), + SPH_C32(0x3ae85036) }, + { SPH_C32(0x2c7f0000), SPH_C32(0x10ad0028), SPH_C32(0xebb3c000), + SPH_C32(0x6f190000), SPH_C32(0x0a8c4e4f), SPH_C32(0x5be12651), + SPH_C32(0x308dca90), SPH_C32(0x09e8f879), SPH_C32(0x61ff0000), + SPH_C32(0xb6ac003d), SPH_C32(0x60a42000), SPH_C32(0xe9420000), + SPH_C32(0x945e795a), SPH_C32(0x18da2f72), SPH_C32(0x89228c49), + SPH_C32(0x90b437d5) }, + { SPH_C32(0x32310000), SPH_C32(0xce620028), SPH_C32(0x864bc180), + SPH_C32(0x183d0000), SPH_C32(0xe6cb49d1), SPH_C32(0xaf414f1f), + SPH_C32(0xfd2ed282), SPH_C32(0x9142b117), SPH_C32(0xd3f90000), + SPH_C32(0x73c5003d), SPH_C32(0x48a73200), SPH_C32(0x9d250000), + SPH_C32(0x229c4fae), SPH_C32(0xf3c8168a), SPH_C32(0xbaf353a5), + SPH_C32(0x99fa064d) }, + { SPH_C32(0x82bc0000), SPH_C32(0x8ce20029), SPH_C32(0x92622000), + SPH_C32(0x430c0000), SPH_C32(0x4f403bfc), SPH_C32(0x3db19167), + SPH_C32(0x9b1f3d1f), SPH_C32(0xaafaae02), SPH_C32(0xbada0000), + SPH_C32(0xbf85003d), SPH_C32(0x290ee000), SPH_C32(0x68a30000), + SPH_C32(0x5ea01203), SPH_C32(0x5aa31b43), SPH_C32(0xca74e73f), + SPH_C32(0x78d88dfb) }, + { SPH_C32(0x9cf20000), SPH_C32(0x522d0029), SPH_C32(0xff9a2180), + SPH_C32(0x34280000), SPH_C32(0xa3073c62), SPH_C32(0xc911f829), + SPH_C32(0x56bc250d), SPH_C32(0x3250e76c), SPH_C32(0x08dc0000), + SPH_C32(0x7aec003d), SPH_C32(0x010df200), SPH_C32(0x1cc40000), + SPH_C32(0xe86224f7), SPH_C32(0xb1b122bb), SPH_C32(0xf9a538d3), + SPH_C32(0x7196bc63) }, + { SPH_C32(0x71230000), SPH_C32(0x26bd002a), SPH_C32(0x4383e000), + SPH_C32(0x76ae0000), SPH_C32(0x55174218), SPH_C32(0x5710da8a), + SPH_C32(0xa006e8a2), SPH_C32(0xf79998ee), SPH_C32(0x24ae0000), + SPH_C32(0xc61a003c), SPH_C32(0xa42b6000), SPH_C32(0x06720000), + SPH_C32(0x78d45ada), SPH_C32(0x44493815), SPH_C32(0x4049b15a), + SPH_C32(0x6b6fc3b4) }, + { SPH_C32(0x6f6d0000), SPH_C32(0xf872002a), SPH_C32(0x2e7be180), + SPH_C32(0x018a0000), SPH_C32(0xb9504586), SPH_C32(0xa3b0b3c4), + SPH_C32(0x6da5f0b0), SPH_C32(0x6f33d180), SPH_C32(0x96a80000), + SPH_C32(0x0373003c), SPH_C32(0x8c287200), SPH_C32(0x72150000), + SPH_C32(0xce166c2e), SPH_C32(0xaf5b01ed), SPH_C32(0x73986eb6), + SPH_C32(0x6221f22c) }, + { SPH_C32(0xdfe00000), SPH_C32(0xbaf2002b), SPH_C32(0x3a520000), + SPH_C32(0x5abb0000), SPH_C32(0x10db37ab), SPH_C32(0x31406dbc), + SPH_C32(0x0b941f2d), SPH_C32(0x548bce95), SPH_C32(0xff8b0000), + SPH_C32(0xcf33003c), SPH_C32(0xed81a000), SPH_C32(0x87930000), + SPH_C32(0xb22a3183), SPH_C32(0x06300c24), SPH_C32(0x031fda2c), + SPH_C32(0x8303799a) }, + { SPH_C32(0xc1ae0000), SPH_C32(0x643d002b), SPH_C32(0x57aa0180), + SPH_C32(0x2d9f0000), SPH_C32(0xfc9c3035), SPH_C32(0xc5e004f2), + SPH_C32(0xc637073f), SPH_C32(0xcc2187fb), SPH_C32(0x4d8d0000), + SPH_C32(0x0a5a003c), SPH_C32(0xc582b200), SPH_C32(0xf3f40000), + SPH_C32(0x04e80777), SPH_C32(0xed2235dc), SPH_C32(0x30ce05c0), + SPH_C32(0x8a4d4802) }, + { SPH_C32(0xaa060000), SPH_C32(0x2f94002a), SPH_C32(0x0a292000), + SPH_C32(0xf74f0000), SPH_C32(0x9fe92941), SPH_C32(0x1569eebb), + SPH_C32(0xe35083d4), SPH_C32(0x1ff522c0), SPH_C32(0x51480000), + SPH_C32(0x537c003d), SPH_C32(0x94504000), SPH_C32(0xab860000), + SPH_C32(0xf7e64430), SPH_C32(0x6060bb12), SPH_C32(0xa88d2da3), + SPH_C32(0x20112fe1) }, + { SPH_C32(0xb4480000), SPH_C32(0xf15b002a), SPH_C32(0x67d12180), + SPH_C32(0x806b0000), SPH_C32(0x73ae2edf), SPH_C32(0xe1c987f5), + SPH_C32(0x2ef39bc6), SPH_C32(0x875f6bae), SPH_C32(0xe34e0000), + SPH_C32(0x9615003d), SPH_C32(0xbc535200), SPH_C32(0xdfe10000), + SPH_C32(0x412472c4), SPH_C32(0x8b7282ea), SPH_C32(0x9b5cf24f), + SPH_C32(0x295f1e79) }, + { SPH_C32(0x04c50000), SPH_C32(0xb3db002b), SPH_C32(0x73f8c000), + SPH_C32(0xdb5a0000), SPH_C32(0xda255cf2), SPH_C32(0x7339598d), + SPH_C32(0x48c2745b), SPH_C32(0xbce774bb), SPH_C32(0x8a6d0000), + SPH_C32(0x5a55003d), SPH_C32(0xddfa8000), SPH_C32(0x2a670000), + SPH_C32(0x3d182f69), SPH_C32(0x22198f23), SPH_C32(0xebdb46d5), + SPH_C32(0xc87d95cf) }, + { SPH_C32(0x1a8b0000), SPH_C32(0x6d14002b), SPH_C32(0x1e00c180), + SPH_C32(0xac7e0000), SPH_C32(0x36625b6c), SPH_C32(0x879930c3), + SPH_C32(0x85616c49), SPH_C32(0x244d3dd5), SPH_C32(0x386b0000), + SPH_C32(0x9f3c003d), SPH_C32(0xf5f99200), SPH_C32(0x5e000000), + SPH_C32(0x8bda199d), SPH_C32(0xc90bb6db), SPH_C32(0xd80a9939), + SPH_C32(0xc133a457) }, + { SPH_C32(0xc7ed0000), SPH_C32(0xfc540028), SPH_C32(0x56ed6000), + SPH_C32(0xac3c0000), SPH_C32(0xa3ca187c), SPH_C32(0x61228600), + SPH_C32(0x5274000c), SPH_C32(0x51215a63), SPH_C32(0xa2d70000), + SPH_C32(0xf923003e), SPH_C32(0x45b18000), SPH_C32(0x9e240000), + SPH_C32(0xedb13dd4), SPH_C32(0x0ac1f0ff), SPH_C32(0x9394f81e), + SPH_C32(0x7d72190d) }, + { SPH_C32(0xd9a30000), SPH_C32(0x229b0028), SPH_C32(0x3b156180), + SPH_C32(0xdb180000), SPH_C32(0x4f8d1fe2), SPH_C32(0x9582ef4e), + SPH_C32(0x9fd7181e), SPH_C32(0xc98b130d), SPH_C32(0x10d10000), + SPH_C32(0x3c4a003e), SPH_C32(0x6db29200), SPH_C32(0xea430000), + SPH_C32(0x5b730b20), SPH_C32(0xe1d3c907), SPH_C32(0xa04527f2), + SPH_C32(0x743c2895) }, + { SPH_C32(0x692e0000), SPH_C32(0x601b0029), SPH_C32(0x2f3c8000), + SPH_C32(0x80290000), SPH_C32(0xe6066dcf), SPH_C32(0x07723136), + SPH_C32(0xf9e6f783), SPH_C32(0xf2330c18), SPH_C32(0x79f20000), + SPH_C32(0xf00a003e), SPH_C32(0x0c1b4000), SPH_C32(0x1fc50000), + SPH_C32(0x274f568d), SPH_C32(0x48b8c4ce), SPH_C32(0xd0c29368), + SPH_C32(0x951ea323) }, + { SPH_C32(0x77600000), SPH_C32(0xbed40029), SPH_C32(0x42c48180), + SPH_C32(0xf70d0000), SPH_C32(0x0a416a51), SPH_C32(0xf3d25878), + SPH_C32(0x3445ef91), SPH_C32(0x6a994576), SPH_C32(0xcbf40000), + SPH_C32(0x3563003e), SPH_C32(0x24185200), SPH_C32(0x6ba20000), + SPH_C32(0x918d6079), SPH_C32(0xa3aafd36), SPH_C32(0xe3134c84), + SPH_C32(0x9c5092bb) }, + { SPH_C32(0x1cc80000), SPH_C32(0xf57d0028), SPH_C32(0x1f47a000), + SPH_C32(0x2ddd0000), SPH_C32(0x69347325), SPH_C32(0x235bb231), + SPH_C32(0x11226b7a), SPH_C32(0xb94de04d), SPH_C32(0xd7310000), + SPH_C32(0x6c45003f), SPH_C32(0x75caa000), SPH_C32(0x33d00000), + SPH_C32(0x6283233e), SPH_C32(0x2ee873f8), SPH_C32(0x7b5064e7), + SPH_C32(0x360cf558) }, + { SPH_C32(0x02860000), SPH_C32(0x2bb20028), SPH_C32(0x72bfa180), + SPH_C32(0x5af90000), SPH_C32(0x857374bb), SPH_C32(0xd7fbdb7f), + SPH_C32(0xdc817368), SPH_C32(0x21e7a923), SPH_C32(0x65370000), + SPH_C32(0xa92c003f), SPH_C32(0x5dc9b200), SPH_C32(0x47b70000), + SPH_C32(0xd44115ca), SPH_C32(0xc5fa4a00), SPH_C32(0x4881bb0b), + SPH_C32(0x3f42c4c0) }, + { SPH_C32(0xb20b0000), SPH_C32(0x69320029), SPH_C32(0x66964000), + SPH_C32(0x01c80000), SPH_C32(0x2cf80696), SPH_C32(0x450b0507), + SPH_C32(0xbab09cf5), SPH_C32(0x1a5fb636), SPH_C32(0x0c140000), + SPH_C32(0x656c003f), SPH_C32(0x3c606000), SPH_C32(0xb2310000), + SPH_C32(0xa87d4867), SPH_C32(0x6c9147c9), SPH_C32(0x38060f91), + SPH_C32(0xde604f76) }, + { SPH_C32(0xac450000), SPH_C32(0xb7fd0029), SPH_C32(0x0b6e4180), + SPH_C32(0x76ec0000), SPH_C32(0xc0bf0108), SPH_C32(0xb1ab6c49), + SPH_C32(0x771384e7), SPH_C32(0x82f5ff58), SPH_C32(0xbe120000), + SPH_C32(0xa005003f), SPH_C32(0x14637200), SPH_C32(0xc6560000), + SPH_C32(0x1ebf7e93), SPH_C32(0x87837e31), SPH_C32(0x0bd7d07d), + SPH_C32(0xd72e7eee) }, + { SPH_C32(0x41940000), SPH_C32(0xc36d002a), SPH_C32(0xb7778000), + SPH_C32(0x346a0000), SPH_C32(0x36af7f72), SPH_C32(0x2faa4eea), + SPH_C32(0x81a94948), SPH_C32(0x473c80da), SPH_C32(0x92600000), + SPH_C32(0x1cf3003e), SPH_C32(0xb145e000), SPH_C32(0xdce00000), + SPH_C32(0x8e0900be), SPH_C32(0x727b649f), SPH_C32(0xb23b59f4), + SPH_C32(0xcdd70139) }, + { SPH_C32(0x5fda0000), SPH_C32(0x1da2002a), SPH_C32(0xda8f8180), + SPH_C32(0x434e0000), SPH_C32(0xdae878ec), SPH_C32(0xdb0a27a4), + SPH_C32(0x4c0a515a), SPH_C32(0xdf96c9b4), SPH_C32(0x20660000), + SPH_C32(0xd99a003e), SPH_C32(0x9946f200), SPH_C32(0xa8870000), + SPH_C32(0x38cb364a), SPH_C32(0x99695d67), SPH_C32(0x81ea8618), + SPH_C32(0xc49930a1) }, + { SPH_C32(0xef570000), SPH_C32(0x5f22002b), SPH_C32(0xcea66000), + SPH_C32(0x187f0000), SPH_C32(0x73630ac1), SPH_C32(0x49faf9dc), + SPH_C32(0x2a3bbec7), SPH_C32(0xe42ed6a1), SPH_C32(0x49450000), + SPH_C32(0x15da003e), SPH_C32(0xf8ef2000), SPH_C32(0x5d010000), + SPH_C32(0x44f76be7), SPH_C32(0x300250ae), SPH_C32(0xf16d3282), + SPH_C32(0x25bbbb17) }, + { SPH_C32(0xf1190000), SPH_C32(0x81ed002b), SPH_C32(0xa35e6180), + SPH_C32(0x6f5b0000), SPH_C32(0x9f240d5f), SPH_C32(0xbd5a9092), + SPH_C32(0xe798a6d5), SPH_C32(0x7c849fcf), SPH_C32(0xfb430000), + SPH_C32(0xd0b3003e), SPH_C32(0xd0ec3200), SPH_C32(0x29660000), + SPH_C32(0xf2355d13), SPH_C32(0xdb106956), SPH_C32(0xc2bced6e), + SPH_C32(0x2cf58a8f) }, + { SPH_C32(0x9ab10000), SPH_C32(0xca44002a), SPH_C32(0xfedd4000), + SPH_C32(0xb58b0000), SPH_C32(0xfc51142b), SPH_C32(0x6dd37adb), + SPH_C32(0xc2ff223e), SPH_C32(0xaf503af4), SPH_C32(0xe7860000), + SPH_C32(0x8995003f), SPH_C32(0x813ec000), SPH_C32(0x71140000), + SPH_C32(0x013b1e54), SPH_C32(0x5652e798), SPH_C32(0x5affc50d), + SPH_C32(0x86a9ed6c) }, + { SPH_C32(0x84ff0000), SPH_C32(0x148b002a), SPH_C32(0x93254180), + SPH_C32(0xc2af0000), SPH_C32(0x101613b5), SPH_C32(0x99731395), + SPH_C32(0x0f5c3a2c), SPH_C32(0x37fa739a), SPH_C32(0x55800000), + SPH_C32(0x4cfc003f), SPH_C32(0xa93dd200), SPH_C32(0x05730000), + SPH_C32(0xb7f928a0), SPH_C32(0xbd40de60), SPH_C32(0x692e1ae1), + SPH_C32(0x8fe7dcf4) }, + { SPH_C32(0x34720000), SPH_C32(0x560b002b), SPH_C32(0x870ca000), + SPH_C32(0x999e0000), SPH_C32(0xb99d6198), SPH_C32(0x0b83cded), + SPH_C32(0x696dd5b1), SPH_C32(0x0c426c8f), SPH_C32(0x3ca30000), + SPH_C32(0x80bc003f), SPH_C32(0xc8940000), SPH_C32(0xf0f50000), + SPH_C32(0xcbc5750d), SPH_C32(0x142bd3a9), SPH_C32(0x19a9ae7b), + SPH_C32(0x6ec55742) }, + { SPH_C32(0x2a3c0000), SPH_C32(0x88c4002b), SPH_C32(0xeaf4a180), + SPH_C32(0xeeba0000), SPH_C32(0x55da6606), SPH_C32(0xff23a4a3), + SPH_C32(0xa4cecda3), SPH_C32(0x94e825e1), SPH_C32(0x8ea50000), + SPH_C32(0x45d5003f), SPH_C32(0xe0971200), SPH_C32(0x84920000), + SPH_C32(0x7d0743f9), SPH_C32(0xff39ea51), SPH_C32(0x2a787197), + SPH_C32(0x678b66da) } +}; + +static const sph_u32 T512_35[128][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x52500000), SPH_C32(0x29540000), SPH_C32(0x6a61004e), + SPH_C32(0xf0ff0000), SPH_C32(0x9a317eec), SPH_C32(0x452341ce), + SPH_C32(0xcf568fe5), SPH_C32(0x5303130f), SPH_C32(0x538d0000), + SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), SPH_C32(0x56ff0000), + SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), SPH_C32(0xa9444018), + SPH_C32(0x7f975691) }, + { SPH_C32(0x538d0000), SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), + SPH_C32(0x56ff0000), SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), + SPH_C32(0xa9444018), SPH_C32(0x7f975691), SPH_C32(0x01dd0000), + SPH_C32(0x80a80000), SPH_C32(0xf4960048), SPH_C32(0xa6000000), + SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), SPH_C32(0x6612cffd), + SPH_C32(0x2c94459e) }, + { SPH_C32(0x01dd0000), SPH_C32(0x80a80000), SPH_C32(0xf4960048), + SPH_C32(0xa6000000), SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), + SPH_C32(0x6612cffd), SPH_C32(0x2c94459e), SPH_C32(0x52500000), + SPH_C32(0x29540000), SPH_C32(0x6a61004e), SPH_C32(0xf0ff0000), + SPH_C32(0x9a317eec), SPH_C32(0x452341ce), SPH_C32(0xcf568fe5), + SPH_C32(0x5303130f) }, + { SPH_C32(0xcc140000), SPH_C32(0xa5630000), SPH_C32(0x5ab90780), + SPH_C32(0x3b500000), SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), + SPH_C32(0x694348c1), SPH_C32(0xca5a87fe), SPH_C32(0x819e0000), + SPH_C32(0xec570000), SPH_C32(0x66320280), SPH_C32(0x95f30000), + SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), SPH_C32(0xe65aa22d), + SPH_C32(0x8e67b7fa) }, + { SPH_C32(0x9e440000), SPH_C32(0x8c370000), SPH_C32(0x30d807ce), + SPH_C32(0xcbaf0000), SPH_C32(0xd1e16d13), SPH_C32(0xc2b875d6), + SPH_C32(0xa615c724), SPH_C32(0x995994f1), SPH_C32(0xd2130000), + SPH_C32(0x45ab0000), SPH_C32(0xf8c50286), SPH_C32(0xc30c0000), + SPH_C32(0x574d284c), SPH_C32(0xda31f145), SPH_C32(0x4f1ee235), + SPH_C32(0xf1f0e16b) }, + { SPH_C32(0x9f990000), SPH_C32(0x0c9f0000), SPH_C32(0xc44e0786), + SPH_C32(0x6daf0000), SPH_C32(0x413413b1), SPH_C32(0x155ef9e1), + SPH_C32(0xc00708d9), SPH_C32(0xb5cdd16f), SPH_C32(0x80430000), + SPH_C32(0x6cff0000), SPH_C32(0x92a402c8), SPH_C32(0x33f30000), + SPH_C32(0xcd7c56a0), SPH_C32(0x9f12b08b), SPH_C32(0x80486dd0), + SPH_C32(0xa2f3f264) }, + { SPH_C32(0xcdc90000), SPH_C32(0x25cb0000), SPH_C32(0xae2f07c8), + SPH_C32(0x9d500000), SPH_C32(0xdb056d5d), SPH_C32(0x507db82f), + SPH_C32(0x0f51873c), SPH_C32(0xe6cec260), SPH_C32(0xd3ce0000), + SPH_C32(0xc5030000), SPH_C32(0x0c5302ce), SPH_C32(0x650c0000), + SPH_C32(0xc79856ee), SPH_C32(0x0dd77d72), SPH_C32(0x290c2dc8), + SPH_C32(0xdd64a4f5) }, + { SPH_C32(0x819e0000), SPH_C32(0xec570000), SPH_C32(0x66320280), + SPH_C32(0x95f30000), SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), + SPH_C32(0xe65aa22d), SPH_C32(0x8e67b7fa), SPH_C32(0x4d8a0000), + SPH_C32(0x49340000), SPH_C32(0x3c8b0500), SPH_C32(0xaea30000), + SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), SPH_C32(0x8f19eaec), + SPH_C32(0x443d3004) }, + { SPH_C32(0xd3ce0000), SPH_C32(0xc5030000), SPH_C32(0x0c5302ce), + SPH_C32(0x650c0000), SPH_C32(0xc79856ee), SPH_C32(0x0dd77d72), + SPH_C32(0x290c2dc8), SPH_C32(0xdd64a4f5), SPH_C32(0x1e070000), + SPH_C32(0xe0c80000), SPH_C32(0xa27c0506), SPH_C32(0xf85c0000), + SPH_C32(0x1c9d3bb3), SPH_C32(0x5daac55d), SPH_C32(0x265daaf4), + SPH_C32(0x3baa6695) }, + { SPH_C32(0xd2130000), SPH_C32(0x45ab0000), SPH_C32(0xf8c50286), + SPH_C32(0xc30c0000), SPH_C32(0x574d284c), SPH_C32(0xda31f145), + SPH_C32(0x4f1ee235), SPH_C32(0xf1f0e16b), SPH_C32(0x4c570000), + SPH_C32(0xc99c0000), SPH_C32(0xc81d0548), SPH_C32(0x08a30000), + SPH_C32(0x86ac455f), SPH_C32(0x18898493), SPH_C32(0xe90b2511), + SPH_C32(0x68a9759a) }, + { SPH_C32(0x80430000), SPH_C32(0x6cff0000), SPH_C32(0x92a402c8), + SPH_C32(0x33f30000), SPH_C32(0xcd7c56a0), SPH_C32(0x9f12b08b), + SPH_C32(0x80486dd0), SPH_C32(0xa2f3f264), SPH_C32(0x1fda0000), + SPH_C32(0x60600000), SPH_C32(0x56ea054e), SPH_C32(0x5e5c0000), + SPH_C32(0x8c484511), SPH_C32(0x8a4c496a), SPH_C32(0x404f6509), + SPH_C32(0x173e230b) }, + { SPH_C32(0x4d8a0000), SPH_C32(0x49340000), SPH_C32(0x3c8b0500), + SPH_C32(0xaea30000), SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), + SPH_C32(0x8f19eaec), SPH_C32(0x443d3004), SPH_C32(0xcc140000), + SPH_C32(0xa5630000), SPH_C32(0x5ab90780), SPH_C32(0x3b500000), + SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), SPH_C32(0x694348c1), + SPH_C32(0xca5a87fe) }, + { SPH_C32(0x1fda0000), SPH_C32(0x60600000), SPH_C32(0x56ea054e), + SPH_C32(0x5e5c0000), SPH_C32(0x8c484511), SPH_C32(0x8a4c496a), + SPH_C32(0x404f6509), SPH_C32(0x173e230b), SPH_C32(0x9f990000), + SPH_C32(0x0c9f0000), SPH_C32(0xc44e0786), SPH_C32(0x6daf0000), + SPH_C32(0x413413b1), SPH_C32(0x155ef9e1), SPH_C32(0xc00708d9), + SPH_C32(0xb5cdd16f) }, + { SPH_C32(0x1e070000), SPH_C32(0xe0c80000), SPH_C32(0xa27c0506), + SPH_C32(0xf85c0000), SPH_C32(0x1c9d3bb3), SPH_C32(0x5daac55d), + SPH_C32(0x265daaf4), SPH_C32(0x3baa6695), SPH_C32(0xcdc90000), + SPH_C32(0x25cb0000), SPH_C32(0xae2f07c8), SPH_C32(0x9d500000), + SPH_C32(0xdb056d5d), SPH_C32(0x507db82f), SPH_C32(0x0f51873c), + SPH_C32(0xe6cec260) }, + { SPH_C32(0x4c570000), SPH_C32(0xc99c0000), SPH_C32(0xc81d0548), + SPH_C32(0x08a30000), SPH_C32(0x86ac455f), SPH_C32(0x18898493), + SPH_C32(0xe90b2511), SPH_C32(0x68a9759a), SPH_C32(0x9e440000), + SPH_C32(0x8c370000), SPH_C32(0x30d807ce), SPH_C32(0xcbaf0000), + SPH_C32(0xd1e16d13), SPH_C32(0xc2b875d6), SPH_C32(0xa615c724), + SPH_C32(0x995994f1) }, + { SPH_C32(0x78230000), SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), + SPH_C32(0x90a50000), SPH_C32(0x713e2879), SPH_C32(0x7ee98924), + SPH_C32(0xf08ca062), SPH_C32(0x636f8bab), SPH_C32(0x02af0000), + SPH_C32(0xb7280000), SPH_C32(0xba1c0300), SPH_C32(0x56980000), + SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), SPH_C32(0xa95c149a), + SPH_C32(0xf4f6ea7b) }, + { SPH_C32(0x2a730000), SPH_C32(0x3ba80000), SPH_C32(0xc35b0bce), + SPH_C32(0x605a0000), SPH_C32(0xeb0f5695), SPH_C32(0x3bcac8ea), + SPH_C32(0x3fda2f87), SPH_C32(0x306c98a4), SPH_C32(0x51220000), + SPH_C32(0x1ed40000), SPH_C32(0x24eb0306), SPH_C32(0x00670000), + SPH_C32(0xb069459d), SPH_C32(0x128d0b9e), SPH_C32(0x00185482), + SPH_C32(0x8b61bcea) }, + { SPH_C32(0x2bae0000), SPH_C32(0xbb000000), SPH_C32(0x37cd0b86), + SPH_C32(0xc65a0000), SPH_C32(0x7bda2837), SPH_C32(0xec2c44dd), + SPH_C32(0x59c8e07a), SPH_C32(0x1cf8dd3a), SPH_C32(0x03720000), + SPH_C32(0x37800000), SPH_C32(0x4e8a0348), SPH_C32(0xf0980000), + SPH_C32(0x2a583b71), SPH_C32(0x57ae4a50), SPH_C32(0xcf4edb67), + SPH_C32(0xd862afe5) }, + { SPH_C32(0x79fe0000), SPH_C32(0x92540000), SPH_C32(0x5dac0bc8), + SPH_C32(0x36a50000), SPH_C32(0xe1eb56db), SPH_C32(0xa90f0513), + SPH_C32(0x969e6f9f), SPH_C32(0x4ffbce35), SPH_C32(0x50ff0000), + SPH_C32(0x9e7c0000), SPH_C32(0xd07d034e), SPH_C32(0xa6670000), + SPH_C32(0x20bc3b3f), SPH_C32(0xc56b87a9), SPH_C32(0x660a9b7f), + SPH_C32(0xa7f5f974) }, + { SPH_C32(0xb4370000), SPH_C32(0xb79f0000), SPH_C32(0xf3830c00), + SPH_C32(0xabf50000), SPH_C32(0x3aee3b86), SPH_C32(0xf972bd3c), + SPH_C32(0x99cfe8a3), SPH_C32(0xa9350c55), SPH_C32(0x83310000), + SPH_C32(0x5b7f0000), SPH_C32(0xdc2e0180), SPH_C32(0xc36b0000), + SPH_C32(0xe7246dd1), SPH_C32(0xc8bcfadb), SPH_C32(0x4f06b6b7), + SPH_C32(0x7a915d81) }, + { SPH_C32(0xe6670000), SPH_C32(0x9ecb0000), SPH_C32(0x99e20c4e), + SPH_C32(0x5b0a0000), SPH_C32(0xa0df456a), SPH_C32(0xbc51fcf2), + SPH_C32(0x56996746), SPH_C32(0xfa361f5a), SPH_C32(0xd0bc0000), + SPH_C32(0xf2830000), SPH_C32(0x42d90186), SPH_C32(0x95940000), + SPH_C32(0xedc06d9f), SPH_C32(0x5a793722), SPH_C32(0xe642f6af), + SPH_C32(0x05060b10) }, + { SPH_C32(0xe7ba0000), SPH_C32(0x1e630000), SPH_C32(0x6d740c06), + SPH_C32(0xfd0a0000), SPH_C32(0x300a3bc8), SPH_C32(0x6bb770c5), + SPH_C32(0x308ba8bb), SPH_C32(0xd6a25ac4), SPH_C32(0x82ec0000), + SPH_C32(0xdbd70000), SPH_C32(0x28b801c8), SPH_C32(0x656b0000), + SPH_C32(0x77f11373), SPH_C32(0x1f5a76ec), SPH_C32(0x2914794a), + SPH_C32(0x5605181f) }, + { SPH_C32(0xb5ea0000), SPH_C32(0x37370000), SPH_C32(0x07150c48), + SPH_C32(0x0df50000), SPH_C32(0xaa3b4524), SPH_C32(0x2e94310b), + SPH_C32(0xffdd275e), SPH_C32(0x85a149cb), SPH_C32(0xd1610000), + SPH_C32(0x722b0000), SPH_C32(0xb64f01ce), SPH_C32(0x33940000), + SPH_C32(0x7d15133d), SPH_C32(0x8d9fbb15), SPH_C32(0x80503952), + SPH_C32(0x29924e8e) }, + { SPH_C32(0xf9bd0000), SPH_C32(0xfeab0000), SPH_C32(0xcf080900), + SPH_C32(0x05560000), SPH_C32(0x2c97007b), SPH_C32(0x361db598), + SPH_C32(0x16d6024f), SPH_C32(0xed083c51), SPH_C32(0x4f250000), + SPH_C32(0xfe1c0000), SPH_C32(0x496970600), SPH_C32(0xf83b0000), + SPH_C32(0xacf47e2e), SPH_C32(0x4f27cec3), SPH_C32(0x2645fe76), + SPH_C32(0xb0cbda7f) }, + { SPH_C32(0xabed0000), SPH_C32(0xd7ff0000), SPH_C32(0xa569094e), + SPH_C32(0xf5a90000), SPH_C32(0xb6a67e97), SPH_C32(0x733ef456), + SPH_C32(0xd9808daa), SPH_C32(0xbe0b2f5e), SPH_C32(0x1ca80000), + SPH_C32(0x57e00000), SPH_C32(0x18600606), SPH_C32(0xaec40000), + SPH_C32(0xa6107e60), SPH_C32(0xdde2033a), SPH_C32(0x8f01be6e), + SPH_C32(0xcf5c8cee) }, + { SPH_C32(0xaa300000), SPH_C32(0x57570000), SPH_C32(0x51ff0906), + SPH_C32(0x53a90000), SPH_C32(0x26730035), SPH_C32(0xa4d87861), + SPH_C32(0xbf924257), SPH_C32(0x929f6ac0), SPH_C32(0x4ef80000), + SPH_C32(0x7eb40000), SPH_C32(0x72010648), SPH_C32(0x5e3b0000), + SPH_C32(0x3c21008c), SPH_C32(0x98c142f4), SPH_C32(0x4057318b), + SPH_C32(0x9c5f9fe1) }, + { SPH_C32(0xf8600000), SPH_C32(0x7e030000), SPH_C32(0x3b9e0948), + SPH_C32(0xa3560000), SPH_C32(0xbc427ed9), SPH_C32(0xe1fb39af), + SPH_C32(0x70c4cdb2), SPH_C32(0xc19c79cf), SPH_C32(0x1d750000), + SPH_C32(0xd7480000), SPH_C32(0xecf6064e), SPH_C32(0x08c40000), + SPH_C32(0x36c500c2), SPH_C32(0x0a048f0d), SPH_C32(0xe9137193), + SPH_C32(0xe3c8c970) }, + { SPH_C32(0x35a90000), SPH_C32(0x5bc80000), SPH_C32(0x95b10e80), + SPH_C32(0x3e060000), SPH_C32(0x67471384), SPH_C32(0xb1868180), + SPH_C32(0x7f954a8e), SPH_C32(0x2752bbaf), SPH_C32(0xcebb0000), + SPH_C32(0x124b0000), SPH_C32(0xe0a50480), SPH_C32(0x6dc80000), + SPH_C32(0xf15d562c), SPH_C32(0x07d3f27f), SPH_C32(0xc01f5c5b), + SPH_C32(0x3eac6d85) }, + { SPH_C32(0x67f90000), SPH_C32(0x729c0000), SPH_C32(0xffd00ece), + SPH_C32(0xcef90000), SPH_C32(0xfd766d68), SPH_C32(0xf4a5c04e), + SPH_C32(0xb0c3c56b), SPH_C32(0x7451a8a0), SPH_C32(0x9d360000), + SPH_C32(0xbbb70000), SPH_C32(0x7e520486), SPH_C32(0x3b370000), + SPH_C32(0xfbb95662), SPH_C32(0x95163f86), SPH_C32(0x695b1c43), + SPH_C32(0x413b3b14) }, + { SPH_C32(0x66240000), SPH_C32(0xf2340000), SPH_C32(0x0b460e86), + SPH_C32(0x68f90000), SPH_C32(0x6da313ca), SPH_C32(0x23434c79), + SPH_C32(0xd6d10a96), SPH_C32(0x58c5ed3e), SPH_C32(0xcf660000), + SPH_C32(0x92e30000), SPH_C32(0x143304c8), SPH_C32(0xcbc80000), + SPH_C32(0x6188288e), SPH_C32(0xd0357e48), SPH_C32(0xa60d93a6), + SPH_C32(0x1238281b) }, + { SPH_C32(0x34740000), SPH_C32(0xdb600000), SPH_C32(0x61270ec8), + SPH_C32(0x98060000), SPH_C32(0xf7926d26), SPH_C32(0x66600db7), + SPH_C32(0x19878573), SPH_C32(0x0bc6fe31), SPH_C32(0x9ceb0000), + SPH_C32(0x3b1f0000), SPH_C32(0x8ac404ce), SPH_C32(0x9d370000), + SPH_C32(0x6b6c28c0), SPH_C32(0x42f0b3b1), SPH_C32(0x0f49d3be), + SPH_C32(0x6daf7e8a) }, + { SPH_C32(0x02af0000), SPH_C32(0xb7280000), SPH_C32(0xba1c0300), + SPH_C32(0x56980000), SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), + SPH_C32(0xa95c149a), SPH_C32(0xf4f6ea7b), SPH_C32(0x7a8c0000), + SPH_C32(0xa5d40000), SPH_C32(0x13260880), SPH_C32(0xc63d0000), + SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), SPH_C32(0x59d0b4f8), + SPH_C32(0x979961d0) }, + { SPH_C32(0x50ff0000), SPH_C32(0x9e7c0000), SPH_C32(0xd07d034e), + SPH_C32(0xa6670000), SPH_C32(0x20bc3b3f), SPH_C32(0xc56b87a9), + SPH_C32(0x660a9b7f), SPH_C32(0xa7f5f974), SPH_C32(0x29010000), + SPH_C32(0x0c280000), SPH_C32(0x8dd10886), SPH_C32(0x90c20000), + SPH_C32(0xc1576de4), SPH_C32(0x6c6482ba), SPH_C32(0xf094f4e0), + SPH_C32(0xe80e3741) }, + { SPH_C32(0x51220000), SPH_C32(0x1ed40000), SPH_C32(0x24eb0306), + SPH_C32(0x00670000), SPH_C32(0xb069459d), SPH_C32(0x128d0b9e), + SPH_C32(0x00185482), SPH_C32(0x8b61bcea), SPH_C32(0x7b510000), + SPH_C32(0x257c0000), SPH_C32(0xe7b008c8), SPH_C32(0x603d0000), + SPH_C32(0x5b661308), SPH_C32(0x2947c374), SPH_C32(0x3fc27b05), + SPH_C32(0xbb0d244e) }, + { SPH_C32(0x03720000), SPH_C32(0x37800000), SPH_C32(0x4e8a0348), + SPH_C32(0xf0980000), SPH_C32(0x2a583b71), SPH_C32(0x57ae4a50), + SPH_C32(0xcf4edb67), SPH_C32(0xd862afe5), SPH_C32(0x28dc0000), + SPH_C32(0x8c800000), SPH_C32(0x794708ce), SPH_C32(0x36c20000), + SPH_C32(0x51821346), SPH_C32(0xbb820e8d), SPH_C32(0x96863b1d), + SPH_C32(0xc49a72df) }, + { SPH_C32(0xcebb0000), SPH_C32(0x124b0000), SPH_C32(0xe0a50480), + SPH_C32(0x6dc80000), SPH_C32(0xf15d562c), SPH_C32(0x07d3f27f), + SPH_C32(0xc01f5c5b), SPH_C32(0x3eac6d85), SPH_C32(0xfb120000), + SPH_C32(0x49830000), SPH_C32(0x75140a00), SPH_C32(0x53ce0000), + SPH_C32(0x961a45a8), SPH_C32(0xb65573ff), SPH_C32(0xbf8a16d5), + SPH_C32(0x19fed62a) }, + { SPH_C32(0x9ceb0000), SPH_C32(0x3b1f0000), SPH_C32(0x8ac404ce), + SPH_C32(0x9d370000), SPH_C32(0x6b6c28c0), SPH_C32(0x42f0b3b1), + SPH_C32(0x0f49d3be), SPH_C32(0x6daf7e8a), SPH_C32(0xa89f0000), + SPH_C32(0xe07f0000), SPH_C32(0xebe30a06), SPH_C32(0x05310000), + SPH_C32(0x9cfe45e6), SPH_C32(0x2490be06), SPH_C32(0x16ce56cd), + SPH_C32(0x666980bb) }, + { SPH_C32(0x9d360000), SPH_C32(0xbbb70000), SPH_C32(0x7e520486), + SPH_C32(0x3b370000), SPH_C32(0xfbb95662), SPH_C32(0x95163f86), + SPH_C32(0x695b1c43), SPH_C32(0x413b3b14), SPH_C32(0xfacf0000), + SPH_C32(0xc92b0000), SPH_C32(0x81820a48), SPH_C32(0xf5ce0000), + SPH_C32(0x06cf3b0a), SPH_C32(0x61b3ffc8), SPH_C32(0xd998d928), + SPH_C32(0x356a93b4) }, + { SPH_C32(0xcf660000), SPH_C32(0x92e30000), SPH_C32(0x143304c8), + SPH_C32(0xcbc80000), SPH_C32(0x6188288e), SPH_C32(0xd0357e48), + SPH_C32(0xa60d93a6), SPH_C32(0x1238281b), SPH_C32(0xa9420000), + SPH_C32(0x60d70000), SPH_C32(0x1f750a4e), SPH_C32(0xa3310000), + SPH_C32(0x0c2b3b44), SPH_C32(0xf3763231), SPH_C32(0x70dc9930), + SPH_C32(0x4afdc525) }, + { SPH_C32(0x83310000), SPH_C32(0x5b7f0000), SPH_C32(0xdc2e0180), + SPH_C32(0xc36b0000), SPH_C32(0xe7246dd1), SPH_C32(0xc8bcfadb), + SPH_C32(0x4f06b6b7), SPH_C32(0x7a915d81), SPH_C32(0x37060000), + SPH_C32(0xece00000), SPH_C32(0x2fad0d80), SPH_C32(0x689e0000), + SPH_C32(0xddca5657), SPH_C32(0x31ce47e7), SPH_C32(0xd6c95e14), + SPH_C32(0xd3a451d4) }, + { SPH_C32(0xd1610000), SPH_C32(0x722b0000), SPH_C32(0xb64f01ce), + SPH_C32(0x33940000), SPH_C32(0x7d15133d), SPH_C32(0x8d9fbb15), + SPH_C32(0x80503952), SPH_C32(0x29924e8e), SPH_C32(0x648b0000), + SPH_C32(0x451c0000), SPH_C32(0xb15a0d86), SPH_C32(0x3e610000), + SPH_C32(0xd72e5619), SPH_C32(0xa30b8a1e), SPH_C32(0x7f8d1e0c), + SPH_C32(0xac330745) }, + { SPH_C32(0xd0bc0000), SPH_C32(0xf2830000), SPH_C32(0x42d90186), + SPH_C32(0x95940000), SPH_C32(0xedc06d9f), SPH_C32(0x5a793722), + SPH_C32(0xe642f6af), SPH_C32(0x05060b10), SPH_C32(0x36db0000), + SPH_C32(0x6c480000), SPH_C32(0xdb3b0dc8), SPH_C32(0xce9e0000), + SPH_C32(0x4d1f28f5), SPH_C32(0xe628cbd0), SPH_C32(0xb0db91e9), + SPH_C32(0xff30144a) }, + { SPH_C32(0x82ec0000), SPH_C32(0xdbd70000), SPH_C32(0x28b801c8), + SPH_C32(0x656b0000), SPH_C32(0x77f11373), SPH_C32(0x1f5a76ec), + SPH_C32(0x2914794a), SPH_C32(0x5605181f), SPH_C32(0x65560000), + SPH_C32(0xc5b40000), SPH_C32(0x45cc0dce), SPH_C32(0x98610000), + SPH_C32(0x47fb28bb), SPH_C32(0x74ed0629), SPH_C32(0x199fd1f1), + SPH_C32(0x80a742db) }, + { SPH_C32(0x4f250000), SPH_C32(0xfe1c0000), SPH_C32(0x496970600), + SPH_C32(0xf83b0000), SPH_C32(0xacf47e2e), SPH_C32(0x4f27cec3), + SPH_C32(0x2645fe76), SPH_C32(0xb0cbda7f), SPH_C32(0xb6980000), + SPH_C32(0x00b70000), SPH_C32(0x499f0f00), SPH_C32(0xfd6d0000), + SPH_C32(0x80637e55), SPH_C32(0x793a7b5b), SPH_C32(0x3093fc39), + SPH_C32(0x5dc3e62e) }, + { SPH_C32(0x1d750000), SPH_C32(0xd7480000), SPH_C32(0xecf6064e), + SPH_C32(0x08c40000), SPH_C32(0x36c500c2), SPH_C32(0x0a048f0d), + SPH_C32(0xe9137193), SPH_C32(0xe3c8c970), SPH_C32(0xe5150000), + SPH_C32(0xa94b0000), SPH_C32(0xd7680f06), SPH_C32(0xab920000), + SPH_C32(0x8a877e1b), SPH_C32(0xebffb6a2), SPH_C32(0x99d7bc21), + SPH_C32(0x2254b0bf) }, + { SPH_C32(0x1ca80000), SPH_C32(0x57e00000), SPH_C32(0x18600606), + SPH_C32(0xaec40000), SPH_C32(0xa6107e60), SPH_C32(0xdde2033a), + SPH_C32(0x8f01be6e), SPH_C32(0xcf5c8cee), SPH_C32(0xb7450000), + SPH_C32(0x801f0000), SPH_C32(0xbd090f48), SPH_C32(0x5b6d0000), + SPH_C32(0x10b600f7), SPH_C32(0xaedcf76c), SPH_C32(0x568133c4), + SPH_C32(0x7157a3b0) }, + { SPH_C32(0x4ef80000), SPH_C32(0x7eb40000), SPH_C32(0x72010648), + SPH_C32(0x5e3b0000), SPH_C32(0x3c21008c), SPH_C32(0x98c142f4), + SPH_C32(0x4057318b), SPH_C32(0x9c5f9fe1), SPH_C32(0xe4c80000), + SPH_C32(0x29e30000), SPH_C32(0x23fe0f4e), SPH_C32(0x0d920000), + SPH_C32(0x1a5200b9), SPH_C32(0x3c193a95), SPH_C32(0xffc573dc), + SPH_C32(0x0ec0f521) }, + { SPH_C32(0x7a8c0000), SPH_C32(0xa5d40000), SPH_C32(0x13260880), + SPH_C32(0xc63d0000), SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), + SPH_C32(0x59d0b4f8), SPH_C32(0x979961d0), SPH_C32(0x78230000), + SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), SPH_C32(0x90a50000), + SPH_C32(0x713e2879), SPH_C32(0x7ee98924), SPH_C32(0xf08ca062), + SPH_C32(0x636f8bab) }, + { SPH_C32(0x28dc0000), SPH_C32(0x8c800000), SPH_C32(0x794708ce), + SPH_C32(0x36c20000), SPH_C32(0x51821346), SPH_C32(0xbb820e8d), + SPH_C32(0x96863b1d), SPH_C32(0xc49a72df), SPH_C32(0x2bae0000), + SPH_C32(0xbb000000), SPH_C32(0x37cd0b86), SPH_C32(0xc65a0000), + SPH_C32(0x7bda2837), SPH_C32(0xec2c44dd), SPH_C32(0x59c8e07a), + SPH_C32(0x1cf8dd3a) }, + { SPH_C32(0x29010000), SPH_C32(0x0c280000), SPH_C32(0x8dd10886), + SPH_C32(0x90c20000), SPH_C32(0xc1576de4), SPH_C32(0x6c6482ba), + SPH_C32(0xf094f4e0), SPH_C32(0xe80e3741), SPH_C32(0x79fe0000), + SPH_C32(0x92540000), SPH_C32(0x5dac0bc8), SPH_C32(0x36a50000), + SPH_C32(0xe1eb56db), SPH_C32(0xa90f0513), SPH_C32(0x969e6f9f), + SPH_C32(0x4ffbce35) }, + { SPH_C32(0x7b510000), SPH_C32(0x257c0000), SPH_C32(0xe7b008c8), + SPH_C32(0x603d0000), SPH_C32(0x5b661308), SPH_C32(0x2947c374), + SPH_C32(0x3fc27b05), SPH_C32(0xbb0d244e), SPH_C32(0x2a730000), + SPH_C32(0x3ba80000), SPH_C32(0xc35b0bce), SPH_C32(0x605a0000), + SPH_C32(0xeb0f5695), SPH_C32(0x3bcac8ea), SPH_C32(0x3fda2f87), + SPH_C32(0x306c98a4) }, + { SPH_C32(0xb6980000), SPH_C32(0x00b70000), SPH_C32(0x499f0f00), + SPH_C32(0xfd6d0000), SPH_C32(0x80637e55), SPH_C32(0x793a7b5b), + SPH_C32(0x3093fc39), SPH_C32(0x5dc3e62e), SPH_C32(0xf9bd0000), + SPH_C32(0xfeab0000), SPH_C32(0xcf080900), SPH_C32(0x05560000), + SPH_C32(0x2c97007b), SPH_C32(0x361db598), SPH_C32(0x16d6024f), + SPH_C32(0xed083c51) }, + { SPH_C32(0xe4c80000), SPH_C32(0x29e30000), SPH_C32(0x23fe0f4e), + SPH_C32(0x0d920000), SPH_C32(0x1a5200b9), SPH_C32(0x3c193a95), + SPH_C32(0xffc573dc), SPH_C32(0x0ec0f521), SPH_C32(0xaa300000), + SPH_C32(0x57570000), SPH_C32(0x51ff0906), SPH_C32(0x53a90000), + SPH_C32(0x26730035), SPH_C32(0xa4d87861), SPH_C32(0xbf924257), + SPH_C32(0x929f6ac0) }, + { SPH_C32(0xe5150000), SPH_C32(0xa94b0000), SPH_C32(0xd7680f06), + SPH_C32(0xab920000), SPH_C32(0x8a877e1b), SPH_C32(0xebffb6a2), + SPH_C32(0x99d7bc21), SPH_C32(0x2254b0bf), SPH_C32(0xf8600000), + SPH_C32(0x7e030000), SPH_C32(0x3b9e0948), SPH_C32(0xa3560000), + SPH_C32(0xbc427ed9), SPH_C32(0xe1fb39af), SPH_C32(0x70c4cdb2), + SPH_C32(0xc19c79cf) }, + { SPH_C32(0xb7450000), SPH_C32(0x801f0000), SPH_C32(0xbd090f48), + SPH_C32(0x5b6d0000), SPH_C32(0x10b600f7), SPH_C32(0xaedcf76c), + SPH_C32(0x568133c4), SPH_C32(0x7157a3b0), SPH_C32(0xabed0000), + SPH_C32(0xd7ff0000), SPH_C32(0xa569094e), SPH_C32(0xf5a90000), + SPH_C32(0xb6a67e97), SPH_C32(0x733ef456), SPH_C32(0xd9808daa), + SPH_C32(0xbe0b2f5e) }, + { SPH_C32(0xfb120000), SPH_C32(0x49830000), SPH_C32(0x75140a00), + SPH_C32(0x53ce0000), SPH_C32(0x961a45a8), SPH_C32(0xb65573ff), + SPH_C32(0xbf8a16d5), SPH_C32(0x19fed62a), SPH_C32(0x35a90000), + SPH_C32(0x5bc80000), SPH_C32(0x95b10e80), SPH_C32(0x3e060000), + SPH_C32(0x67471384), SPH_C32(0xb1868180), SPH_C32(0x7f954a8e), + SPH_C32(0x2752bbaf) }, + { SPH_C32(0xa9420000), SPH_C32(0x60d70000), SPH_C32(0x1f750a4e), + SPH_C32(0xa3310000), SPH_C32(0x0c2b3b44), SPH_C32(0xf3763231), + SPH_C32(0x70dc9930), SPH_C32(0x4afdc525), SPH_C32(0x66240000), + SPH_C32(0xf2340000), SPH_C32(0x0b460e86), SPH_C32(0x68f90000), + SPH_C32(0x6da313ca), SPH_C32(0x23434c79), SPH_C32(0xd6d10a96), + SPH_C32(0x58c5ed3e) }, + { SPH_C32(0xa89f0000), SPH_C32(0xe07f0000), SPH_C32(0xebe30a06), + SPH_C32(0x05310000), SPH_C32(0x9cfe45e6), SPH_C32(0x2490be06), + SPH_C32(0x16ce56cd), SPH_C32(0x666980bb), SPH_C32(0x34740000), + SPH_C32(0xdb600000), SPH_C32(0x61270ec8), SPH_C32(0x98060000), + SPH_C32(0xf7926d26), SPH_C32(0x66600db7), SPH_C32(0x19878573), + SPH_C32(0x0bc6fe31) }, + { SPH_C32(0xfacf0000), SPH_C32(0xc92b0000), SPH_C32(0x81820a48), + SPH_C32(0xf5ce0000), SPH_C32(0x06cf3b0a), SPH_C32(0x61b3ffc8), + SPH_C32(0xd998d928), SPH_C32(0x356a93b4), SPH_C32(0x67f90000), + SPH_C32(0x729c0000), SPH_C32(0xffd00ece), SPH_C32(0xcef90000), + SPH_C32(0xfd766d68), SPH_C32(0xf4a5c04e), SPH_C32(0xb0c3c56b), + SPH_C32(0x7451a8a0) }, + { SPH_C32(0x37060000), SPH_C32(0xece00000), SPH_C32(0x2fad0d80), + SPH_C32(0x689e0000), SPH_C32(0xddca5657), SPH_C32(0x31ce47e7), + SPH_C32(0xd6c95e14), SPH_C32(0xd3a451d4), SPH_C32(0xb4370000), + SPH_C32(0xb79f0000), SPH_C32(0xf3830c00), SPH_C32(0xabf50000), + SPH_C32(0x3aee3b86), SPH_C32(0xf972bd3c), SPH_C32(0x99cfe8a3), + SPH_C32(0xa9350c55) }, + { SPH_C32(0x65560000), SPH_C32(0xc5b40000), SPH_C32(0x45cc0dce), + SPH_C32(0x98610000), SPH_C32(0x47fb28bb), SPH_C32(0x74ed0629), + SPH_C32(0x199fd1f1), SPH_C32(0x80a742db), SPH_C32(0xe7ba0000), + SPH_C32(0x1e630000), SPH_C32(0x6d740c06), SPH_C32(0xfd0a0000), + SPH_C32(0x300a3bc8), SPH_C32(0x6bb770c5), SPH_C32(0x308ba8bb), + SPH_C32(0xd6a25ac4) }, + { SPH_C32(0x648b0000), SPH_C32(0x451c0000), SPH_C32(0xb15a0d86), + SPH_C32(0x3e610000), SPH_C32(0xd72e5619), SPH_C32(0xa30b8a1e), + SPH_C32(0x7f8d1e0c), SPH_C32(0xac330745), SPH_C32(0xb5ea0000), + SPH_C32(0x37370000), SPH_C32(0x07150c48), SPH_C32(0x0df50000), + SPH_C32(0xaa3b4524), SPH_C32(0x2e94310b), SPH_C32(0xffdd275e), + SPH_C32(0x85a149cb) }, + { SPH_C32(0x36db0000), SPH_C32(0x6c480000), SPH_C32(0xdb3b0dc8), + SPH_C32(0xce9e0000), SPH_C32(0x4d1f28f5), SPH_C32(0xe628cbd0), + SPH_C32(0xb0db91e9), SPH_C32(0xff30144a), SPH_C32(0xe6670000), + SPH_C32(0x9ecb0000), SPH_C32(0x99e20c4e), SPH_C32(0x5b0a0000), + SPH_C32(0xa0df456a), SPH_C32(0xbc51fcf2), SPH_C32(0x56996746), + SPH_C32(0xfa361f5a) }, + { SPH_C32(0xac480000), SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), + SPH_C32(0x03430000), SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), + SPH_C32(0xfe72c7fe), SPH_C32(0x91e478f6), SPH_C32(0x1e4e0000), + SPH_C32(0xdecf0000), SPH_C32(0x6df80180), SPH_C32(0x77240000), + SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), SPH_C32(0xcda31812), + SPH_C32(0x98aa496e) }, + { SPH_C32(0xfe180000), SPH_C32(0x32f20000), SPH_C32(0x2f9a13ce), + SPH_C32(0xf3bc0000), SPH_C32(0xc0b44f86), SPH_C32(0x5a911178), + SPH_C32(0x3124481b), SPH_C32(0xc2e76bf9), SPH_C32(0x4dc30000), + SPH_C32(0x77330000), SPH_C32(0xf30f0186), SPH_C32(0x21db0000), + SPH_C32(0xe6a307d0), SPH_C32(0x6665a4b7), SPH_C32(0x64e7580a), + SPH_C32(0xe73d1fff) }, + { SPH_C32(0xffc50000), SPH_C32(0xb25a0000), SPH_C32(0xdb0c1386), + SPH_C32(0x55bc0000), SPH_C32(0x50613124), SPH_C32(0x8d779d4f), + SPH_C32(0x573687e6), SPH_C32(0xee732e67), SPH_C32(0x1f930000), + SPH_C32(0x5e670000), SPH_C32(0x996e01c8), SPH_C32(0xd1240000), + SPH_C32(0x7c92793c), SPH_C32(0x2346e579), SPH_C32(0xabb1d7ef), + SPH_C32(0xb43e0cf0) }, + { SPH_C32(0xad950000), SPH_C32(0x9b0e0000), SPH_C32(0xb16d13c8), + SPH_C32(0xa5430000), SPH_C32(0xca504fc8), SPH_C32(0xc854dc81), + SPH_C32(0x98600803), SPH_C32(0xbd703d68), SPH_C32(0x4c1e0000), + SPH_C32(0xf79b0000), SPH_C32(0x079901ce), SPH_C32(0x87db0000), + SPH_C32(0x76767972), SPH_C32(0xb1832880), SPH_C32(0x02f597f7), + SPH_C32(0xcba95a61) }, + { SPH_C32(0x605c0000), SPH_C32(0xbec50000), SPH_C32(0x1f421400), + SPH_C32(0x38130000), SPH_C32(0x11552295), SPH_C32(0x982964ae), + SPH_C32(0x97318f3f), SPH_C32(0x5bbeff08), SPH_C32(0x9fd00000), + SPH_C32(0x32980000), SPH_C32(0x0bca0300), SPH_C32(0xe2d70000), + SPH_C32(0xb1ee2f9c), SPH_C32(0xbc5455f2), SPH_C32(0x2bf9ba3f), + SPH_C32(0x16cdfe94) }, + { SPH_C32(0x320c0000), SPH_C32(0x97910000), SPH_C32(0x7523144e), + SPH_C32(0xc8ec0000), SPH_C32(0x8b645c79), SPH_C32(0xdd0a2560), + SPH_C32(0x586700da), SPH_C32(0x08bdec07), SPH_C32(0xcc5d0000), + SPH_C32(0x9b640000), SPH_C32(0x953d0306), SPH_C32(0xb4280000), + SPH_C32(0xbb0a2fd2), SPH_C32(0x2e91980b), SPH_C32(0x82bdfa27), + SPH_C32(0x695aa805) }, + { SPH_C32(0x33d10000), SPH_C32(0x17390000), SPH_C32(0x81b51406), + SPH_C32(0x6eec0000), SPH_C32(0x1bb122db), SPH_C32(0x0aeca957), + SPH_C32(0x3e75cf27), SPH_C32(0x2429a999), SPH_C32(0x9e0d0000), + SPH_C32(0xb2300000), SPH_C32(0xff5c0348), SPH_C32(0x44d70000), + SPH_C32(0x213b513e), SPH_C32(0x6bb2d9c5), SPH_C32(0x4deb75c2), + SPH_C32(0x3a59bb0a) }, + { SPH_C32(0x61810000), SPH_C32(0x3e6d0000), SPH_C32(0xebd41448), + SPH_C32(0x9e130000), SPH_C32(0x81805c37), SPH_C32(0x4fcfe899), + SPH_C32(0xf12340c2), SPH_C32(0x772aba96), SPH_C32(0xcd800000), + SPH_C32(0x1bcc0000), SPH_C32(0x61ab034e), SPH_C32(0x12280000), + SPH_C32(0x2bdf5170), SPH_C32(0xf977143c), SPH_C32(0xe4af35da), + SPH_C32(0x45ceed9b) }, + { SPH_C32(0x2dd60000), SPH_C32(0xf7f10000), SPH_C32(0x23c91100), + SPH_C32(0x96b00000), SPH_C32(0x072c1968), SPH_C32(0x57466c0a), + SPH_C32(0x182865d3), SPH_C32(0x1f83cf0c), SPH_C32(0x53c40000), + SPH_C32(0x97fb0000), SPH_C32(0x51730480), SPH_C32(0xd9870000), + SPH_C32(0xfa3e3c63), SPH_C32(0x3bcf61ea), SPH_C32(0x42baf2fe), + SPH_C32(0xdc97796a) }, + { SPH_C32(0x7f860000), SPH_C32(0xdea50000), SPH_C32(0x49a8114e), + SPH_C32(0x664f0000), SPH_C32(0x9d1d6784), SPH_C32(0x12652dc4), + SPH_C32(0xd77eea36), SPH_C32(0x4c80dc03), SPH_C32(0x00490000), + SPH_C32(0x3e070000), SPH_C32(0xcf840486), SPH_C32(0x8f780000), + SPH_C32(0xf0da3c2d), SPH_C32(0xa90aac13), SPH_C32(0xebfeb2e6), + SPH_C32(0xa3002ffb) }, + { SPH_C32(0x7e5b0000), SPH_C32(0x5e0d0000), SPH_C32(0xbd3e1106), + SPH_C32(0xc04f0000), SPH_C32(0x0dc81926), SPH_C32(0xc583a1f3), + SPH_C32(0xb16c25cb), SPH_C32(0x6014999d), SPH_C32(0x52190000), + SPH_C32(0x17530000), SPH_C32(0xa5e504c8), SPH_C32(0x7f870000), + SPH_C32(0x6aeb42c1), SPH_C32(0xec29eddd), SPH_C32(0x24a83d03), + SPH_C32(0xf0033cf4) }, + { SPH_C32(0x2c0b0000), SPH_C32(0x77590000), SPH_C32(0xd75f1148), + SPH_C32(0x30b00000), SPH_C32(0x97f967ca), SPH_C32(0x80a0e03d), + SPH_C32(0x7e3aaa2e), SPH_C32(0x33178a92), SPH_C32(0x01940000), + SPH_C32(0xbeaf0000), SPH_C32(0x3b1204ce), SPH_C32(0x29780000), + SPH_C32(0x600f428f), SPH_C32(0x7eec2024), SPH_C32(0x8dec7d1b), + SPH_C32(0x8f946a65) }, + { SPH_C32(0xe1c20000), SPH_C32(0x52920000), SPH_C32(0x79701680), + SPH_C32(0xade00000), SPH_C32(0x4cfc0a97), SPH_C32(0xd0dd5812), + SPH_C32(0x716b2d12), SPH_C32(0xd5d948f2), SPH_C32(0xd25a0000), + SPH_C32(0x7bac0000), SPH_C32(0x37410600), SPH_C32(0x4c740000), + SPH_C32(0xa7971461), SPH_C32(0x733b5d56), SPH_C32(0xa4e050d3), + SPH_C32(0x52f0ce90) }, + { SPH_C32(0xb3920000), SPH_C32(0x7bc60000), SPH_C32(0x131116ce), + SPH_C32(0x5d1f0000), SPH_C32(0xd6cd747b), SPH_C32(0x95fe19dc), + SPH_C32(0xbe3da2f7), SPH_C32(0x86da5bfd), SPH_C32(0x81d70000), + SPH_C32(0xd2500000), SPH_C32(0xa9b60606), SPH_C32(0x1a8b0000), + SPH_C32(0xad73142f), SPH_C32(0xe1fe90af), SPH_C32(0x0da410cb), + SPH_C32(0x2d679801) }, + { SPH_C32(0xb24f0000), SPH_C32(0xfb6e0000), SPH_C32(0xe7871686), + SPH_C32(0xfb1f0000), SPH_C32(0x46180ad9), SPH_C32(0x421895eb), + SPH_C32(0xd82f6d0a), SPH_C32(0xaa4e1e63), SPH_C32(0xd3870000), + SPH_C32(0xfb040000), SPH_C32(0xc3d70648), SPH_C32(0xea740000), + SPH_C32(0x37426ac3), SPH_C32(0xa4ddd161), SPH_C32(0xc2f29f2e), + SPH_C32(0x7e648b0e) }, + { SPH_C32(0xe01f0000), SPH_C32(0xd23a0000), SPH_C32(0x8de616c8), + SPH_C32(0x0be00000), SPH_C32(0xdc297435), SPH_C32(0x073bd425), + SPH_C32(0x1779e2ef), SPH_C32(0xf94d0d6c), SPH_C32(0x800a0000), + SPH_C32(0x52f80000), SPH_C32(0x5d20064e), SPH_C32(0xbc8b0000), + SPH_C32(0x3da66a8d), SPH_C32(0x36181c98), SPH_C32(0x6bb6df36), + SPH_C32(0x01f3dd9f) }, + { SPH_C32(0xd46b0000), SPH_C32(0x095a0000), SPH_C32(0xecc11800), + SPH_C32(0x93e60000), SPH_C32(0x2bbb1913), SPH_C32(0x615bd992), + SPH_C32(0x0efe679c), SPH_C32(0xf28bf35d), SPH_C32(0x1ce10000), + SPH_C32(0x69e70000), SPH_C32(0xd7e40280), SPH_C32(0x21bc0000), + SPH_C32(0x56ca424d), SPH_C32(0x74e8af29), SPH_C32(0x64ff0c88), + SPH_C32(0x6c5ca315) }, + { SPH_C32(0x863b0000), SPH_C32(0x200e0000), SPH_C32(0x86a0184e), + SPH_C32(0x63190000), SPH_C32(0xb18a67ff), SPH_C32(0x2478985c), + SPH_C32(0xc1a8e879), SPH_C32(0xa188e052), SPH_C32(0x4f6c0000), + SPH_C32(0xc01b0000), SPH_C32(0x49130286), SPH_C32(0x77430000), + SPH_C32(0x5c2e4203), SPH_C32(0xe62d62d0), SPH_C32(0xcdbb4c90), + SPH_C32(0x13cbf584) }, + { SPH_C32(0x87e60000), SPH_C32(0xa0a60000), SPH_C32(0x72361806), + SPH_C32(0xc5190000), SPH_C32(0x215f195d), SPH_C32(0xf39e146b), + SPH_C32(0xa7ba2784), SPH_C32(0x8d1ca5cc), SPH_C32(0x1d3c0000), + SPH_C32(0xe94f0000), SPH_C32(0x237202c8), SPH_C32(0x87bc0000), + SPH_C32(0xc61f3cef), SPH_C32(0xa30e231e), SPH_C32(0x02edc375), + SPH_C32(0x40c8e68b) }, + { SPH_C32(0xd5b60000), SPH_C32(0x89f20000), SPH_C32(0x18571848), + SPH_C32(0x35e60000), SPH_C32(0xbb6e67b1), SPH_C32(0xb6bd55a5), + SPH_C32(0x68eca861), SPH_C32(0xde1fb6c3), SPH_C32(0x4eb10000), + SPH_C32(0x40b30000), SPH_C32(0xbd8502ce), SPH_C32(0xd1430000), + SPH_C32(0xccfb3ca1), SPH_C32(0x31cbeee7), SPH_C32(0xaba9836d), + SPH_C32(0x3f5fb01a) }, + { SPH_C32(0x187f0000), SPH_C32(0xac390000), SPH_C32(0xb6781f80), + SPH_C32(0xa8b60000), SPH_C32(0x606b0aec), SPH_C32(0xe6c0ed8a), + SPH_C32(0x67bd2f5d), SPH_C32(0x38d174a3), SPH_C32(0x9d7f0000), + SPH_C32(0x85b00000), SPH_C32(0xb1d60000), SPH_C32(0xb44f0000), + SPH_C32(0x0b636a4f), SPH_C32(0x3c1c9395), SPH_C32(0x82a5aea5), + SPH_C32(0xe23b14ef) }, + { SPH_C32(0x4a2f0000), SPH_C32(0x856d0000), SPH_C32(0xdc191fce), + SPH_C32(0x58490000), SPH_C32(0xfa5a7400), SPH_C32(0xa3e3ac44), + SPH_C32(0xa8eba0b8), SPH_C32(0x6bd267ac), SPH_C32(0xcef20000), + SPH_C32(0x2c4c0000), SPH_C32(0x2f210006), SPH_C32(0xe2b00000), + SPH_C32(0x01876a01), SPH_C32(0xaed95e6c), SPH_C32(0x2be1eebd), + SPH_C32(0x9dac427e) }, + { SPH_C32(0x4bf20000), SPH_C32(0x05c50000), SPH_C32(0x288f1f86), + SPH_C32(0xfe490000), SPH_C32(0x6a8f0aa2), SPH_C32(0x74052073), + SPH_C32(0xcef96f45), SPH_C32(0x47462232), SPH_C32(0x9ca20000), + SPH_C32(0x05180000), SPH_C32(0x45400048), SPH_C32(0x124f0000), + SPH_C32(0x9bb614ed), SPH_C32(0xebfa1fa2), SPH_C32(0xe4b76158), + SPH_C32(0xceaf5171) }, + { SPH_C32(0x19a20000), SPH_C32(0x2c910000), SPH_C32(0x42ee1fc8), + SPH_C32(0x0eb60000), SPH_C32(0xf0be744e), SPH_C32(0x312661bd), + SPH_C32(0x01afe0a0), SPH_C32(0x1445313d), SPH_C32(0xcf2f0000), + SPH_C32(0xace40000), SPH_C32(0xdbb7004e), SPH_C32(0x44b00000), + SPH_C32(0x915214a3), SPH_C32(0x793fd25b), SPH_C32(0x4df32140), + SPH_C32(0xb13807e0) }, + { SPH_C32(0x55f50000), SPH_C32(0xe50d0000), SPH_C32(0x8af31a80), + SPH_C32(0x06150000), SPH_C32(0x76123111), SPH_C32(0x29afe52e), + SPH_C32(0xe8a4c5b1), SPH_C32(0x7cec44a7), SPH_C32(0x516b0000), + SPH_C32(0x20d30000), SPH_C32(0xeb6f0780), SPH_C32(0x8f1f0000), + SPH_C32(0x40b379b0), SPH_C32(0xbb87a78d), SPH_C32(0xebe6e664), + SPH_C32(0x28619311) }, + { SPH_C32(0x07a50000), SPH_C32(0xcc590000), SPH_C32(0xe0921ace), + SPH_C32(0xf6ea0000), SPH_C32(0xec234ffd), SPH_C32(0x6c8ca4e0), + SPH_C32(0x27f24a54), SPH_C32(0x2fef57a8), SPH_C32(0x02e60000), + SPH_C32(0x892f0000), SPH_C32(0x75980786), SPH_C32(0xd9e00000), + SPH_C32(0x4a5779fe), SPH_C32(0x29426a74), SPH_C32(0x42a2a67c), + SPH_C32(0x57f6c580) }, + { SPH_C32(0x06780000), SPH_C32(0x4cf10000), SPH_C32(0x14041a86), + SPH_C32(0x50ea0000), SPH_C32(0x7cf6315f), SPH_C32(0xbb6a28d7), + SPH_C32(0x41e085a9), SPH_C32(0x037b1236), SPH_C32(0x50b60000), + SPH_C32(0xa07b0000), SPH_C32(0x1ff907c8), SPH_C32(0x291f0000), + SPH_C32(0xd0660712), SPH_C32(0x6c612bba), SPH_C32(0x8df42999), + SPH_C32(0x04f5d68f) }, + { SPH_C32(0x54280000), SPH_C32(0x65a50000), SPH_C32(0x7e651ac8), + SPH_C32(0xa0150000), SPH_C32(0xe6c74fb3), SPH_C32(0xfe496919), + SPH_C32(0x8eb60a4c), SPH_C32(0x50780139), SPH_C32(0x033b0000), + SPH_C32(0x09870000), SPH_C32(0x810e07ce), SPH_C32(0x7fe00000), + SPH_C32(0xda82075c), SPH_C32(0xfea4e643), SPH_C32(0x24b06981), + SPH_C32(0x7b62801e) }, + { SPH_C32(0x99e10000), SPH_C32(0x406e0000), SPH_C32(0xd04a1d00), + SPH_C32(0x3d450000), SPH_C32(0x3dc222ee), SPH_C32(0xae34d136), + SPH_C32(0x81e78d70), SPH_C32(0xb6b6c359), SPH_C32(0xd0f50000), + SPH_C32(0xcc840000), SPH_C32(0x8d5d0500), SPH_C32(0x1aec0000), + SPH_C32(0x1d1a51b2), SPH_C32(0xf3739b31), SPH_C32(0x0dbc4449), + SPH_C32(0xa60624eb) }, + { SPH_C32(0xcbb10000), SPH_C32(0x693a0000), SPH_C32(0xba2b1d4e), + SPH_C32(0xcdba0000), SPH_C32(0xa7f35c02), SPH_C32(0xeb1790f8), + SPH_C32(0x4eb10295), SPH_C32(0xe5b5d056), SPH_C32(0x83780000), + SPH_C32(0x65780000), SPH_C32(0x13aa0506), SPH_C32(0x4c130000), + SPH_C32(0x17fe51fc), SPH_C32(0x61b656c8), SPH_C32(0xa4f80451), + SPH_C32(0xd991727a) }, + { SPH_C32(0xca6c0000), SPH_C32(0xe9920000), SPH_C32(0x4ebd1d06), + SPH_C32(0x6bba0000), SPH_C32(0x372622a0), SPH_C32(0x3cf11ccf), + SPH_C32(0x28a3cd68), SPH_C32(0xc92195c8), SPH_C32(0xd1280000), + SPH_C32(0x4c2c0000), SPH_C32(0x79cb0548), SPH_C32(0xbcec0000), + SPH_C32(0x8dcf2f10), SPH_C32(0x24951706), SPH_C32(0x6bae8bb4), + SPH_C32(0x8a926175) }, + { SPH_C32(0x983c0000), SPH_C32(0xc0c60000), SPH_C32(0x24dc1d48), + SPH_C32(0x9b450000), SPH_C32(0xad175c4c), SPH_C32(0x79d25d01), + SPH_C32(0xe7f5428d), SPH_C32(0x9a2286c7), SPH_C32(0x82a50000), + SPH_C32(0xe5d00000), SPH_C32(0xe73c054e), SPH_C32(0xea130000), + SPH_C32(0x872b2f5e), SPH_C32(0xb650daff), SPH_C32(0xc2eacbac), + SPH_C32(0xf50537e4) }, + { SPH_C32(0xaee70000), SPH_C32(0xac8e0000), SPH_C32(0xffe71080), + SPH_C32(0x55db0000), SPH_C32(0xe00874b9), SPH_C32(0x9ffa96d1), + SPH_C32(0x572ed364), SPH_C32(0x6512928d), SPH_C32(0x64c20000), + SPH_C32(0x7b1b0000), SPH_C32(0x7ede0900), SPH_C32(0xb1190000), + SPH_C32(0x27f46a34), SPH_C32(0x0a01260d), SPH_C32(0x9473acea), + SPH_C32(0x0f3328be) }, + { SPH_C32(0xfcb70000), SPH_C32(0x85da0000), SPH_C32(0x958610ce), + SPH_C32(0xa5240000), SPH_C32(0x7a390a55), SPH_C32(0xdad9d71f), + SPH_C32(0x98785c81), SPH_C32(0x36118182), SPH_C32(0x374f0000), + SPH_C32(0xd2e70000), SPH_C32(0xe0290906), SPH_C32(0xe7e60000), + SPH_C32(0x2d106a7a), SPH_C32(0x98c4ebf4), SPH_C32(0x3d37ecf2), + SPH_C32(0x70a47e2f) }, + { SPH_C32(0xfd6a0000), SPH_C32(0x05720000), SPH_C32(0x61101086), + SPH_C32(0x03240000), SPH_C32(0xeaec74f7), SPH_C32(0x0d3f5b28), + SPH_C32(0xfe6a937c), SPH_C32(0x1a85c41c), SPH_C32(0x651f0000), + SPH_C32(0xfbb30000), SPH_C32(0x8a480948), SPH_C32(0x17190000), + SPH_C32(0xb7211496), SPH_C32(0xdde7aa3a), SPH_C32(0xf2616317), + SPH_C32(0x23a76d20) }, + { SPH_C32(0xaf3a0000), SPH_C32(0x2c260000), SPH_C32(0x0b7110c8), + SPH_C32(0xf3db0000), SPH_C32(0x70dd0a1b), SPH_C32(0x481c1ae6), + SPH_C32(0x313c1c99), SPH_C32(0x4986d713), SPH_C32(0x36920000), + SPH_C32(0x524f0000), SPH_C32(0x14bf094e), SPH_C32(0x41e60000), + SPH_C32(0xbdc514d8), SPH_C32(0x4f2267c3), SPH_C32(0x5b25230f), + SPH_C32(0x5c303bb1) }, + { SPH_C32(0x62f30000), SPH_C32(0x09ed0000), SPH_C32(0xa55e1700), + SPH_C32(0x6e8b0000), SPH_C32(0xabd86746), SPH_C32(0x1861a2c9), + SPH_C32(0x3e6d9ba5), SPH_C32(0xaf481573), SPH_C32(0xe55c0000), + SPH_C32(0x974c0000), SPH_C32(0x18ec0b80), SPH_C32(0x24ea0000), + SPH_C32(0x7a5d4236), SPH_C32(0x42f51ab1), SPH_C32(0x72290ec7), + SPH_C32(0x81549f44) }, + { SPH_C32(0x30a30000), SPH_C32(0x20b90000), SPH_C32(0xcf3f174e), + SPH_C32(0x9e740000), SPH_C32(0x31e919aa), SPH_C32(0x5d42e307), + SPH_C32(0xf13b1440), SPH_C32(0xfc4b067c), SPH_C32(0xb6d10000), + SPH_C32(0x3eb00000), SPH_C32(0x861b0b86), SPH_C32(0x72150000), + SPH_C32(0x70b94278), SPH_C32(0xd030d748), SPH_C32(0xdb6d4edf), + SPH_C32(0xfec3c9d5) }, + { SPH_C32(0x317e0000), SPH_C32(0xa0110000), SPH_C32(0x3ba91706), + SPH_C32(0x38740000), SPH_C32(0xa13c6708), SPH_C32(0x8aa46f30), + SPH_C32(0x9729dbbd), SPH_C32(0xd0df43e2), SPH_C32(0xe4810000), + SPH_C32(0x17e40000), SPH_C32(0xec7a0bc8), SPH_C32(0x82ea0000), + SPH_C32(0xea883c94), SPH_C32(0x95139686), SPH_C32(0x143bc13a), + SPH_C32(0xadc0dada) }, + { SPH_C32(0x632e0000), SPH_C32(0x89450000), SPH_C32(0x51c81748), + SPH_C32(0xc88b0000), SPH_C32(0x3b0d19e4), SPH_C32(0xcf872efe), + SPH_C32(0x587f5458), SPH_C32(0x83dc50ed), SPH_C32(0xb70c0000), + SPH_C32(0xbe180000), SPH_C32(0x728d0bce), SPH_C32(0xd4150000), + SPH_C32(0xe06c3cda), SPH_C32(0x07d65b7f), SPH_C32(0xbd7f8122), + SPH_C32(0xd2578c4b) }, + { SPH_C32(0x2f790000), SPH_C32(0x40d90000), SPH_C32(0x99d51200), + SPH_C32(0xc0280000), SPH_C32(0xbda15cbb), SPH_C32(0xd70eaa6d), + SPH_C32(0xb1747149), SPH_C32(0xeb752577), SPH_C32(0x29480000), + SPH_C32(0x322f0000), SPH_C32(0x42550c00), SPH_C32(0x1fba0000), + SPH_C32(0x318d51c9), SPH_C32(0xc56e2ea9), SPH_C32(0x1b6a4606), + SPH_C32(0x4b0e18ba) }, + { SPH_C32(0x7d290000), SPH_C32(0x698d0000), SPH_C32(0xf3b4124e), + SPH_C32(0x30d70000), SPH_C32(0x27902257), SPH_C32(0x922deba3), + SPH_C32(0x7e22feac), SPH_C32(0xb8763678), SPH_C32(0x7ac50000), + SPH_C32(0x9bd30000), SPH_C32(0xdca20c06), SPH_C32(0x49450000), + SPH_C32(0x3b695187), SPH_C32(0x57abe350), SPH_C32(0xb22e061e), + SPH_C32(0x34994e2b) }, + { SPH_C32(0x7cf40000), SPH_C32(0xe9250000), SPH_C32(0x07221206), + SPH_C32(0x96d70000), SPH_C32(0xb7455cf5), SPH_C32(0x45cb6794), + SPH_C32(0x18303151), SPH_C32(0x94e273e6), SPH_C32(0x28950000), + SPH_C32(0xb2870000), SPH_C32(0xb6c30c48), SPH_C32(0xb9ba0000), + SPH_C32(0xa1582f6b), SPH_C32(0x1288a29e), SPH_C32(0x7d7889fb), + SPH_C32(0x679a5d24) }, + { SPH_C32(0x2ea40000), SPH_C32(0xc0710000), SPH_C32(0x6d431248), + SPH_C32(0x66280000), SPH_C32(0x2d742219), SPH_C32(0x00e8265a), + SPH_C32(0xd766beb4), SPH_C32(0xc7e160e9), SPH_C32(0x7b180000), + SPH_C32(0x1b7b0000), SPH_C32(0x28340c4e), SPH_C32(0xef450000), + SPH_C32(0xabbc2f25), SPH_C32(0x804d6f67), SPH_C32(0xd43cc9e3), + SPH_C32(0x180d0bb5) }, + { SPH_C32(0xe36d0000), SPH_C32(0xe5ba0000), SPH_C32(0xc36c1580), + SPH_C32(0xfb780000), SPH_C32(0xf6714f44), SPH_C32(0x50959e75), + SPH_C32(0xd8373988), SPH_C32(0x212fa289), SPH_C32(0xa8d60000), + SPH_C32(0xde780000), SPH_C32(0x24670e80), SPH_C32(0x8a490000), + SPH_C32(0x6c2479cb), SPH_C32(0x8d9a1215), SPH_C32(0xfd30e42b), + SPH_C32(0xc569af40) }, + { SPH_C32(0xb13d0000), SPH_C32(0xccee0000), SPH_C32(0xa90d15ce), + SPH_C32(0x0b870000), SPH_C32(0x6c4031a8), SPH_C32(0x15b6dfbb), + SPH_C32(0x1761b66d), SPH_C32(0x722cb186), SPH_C32(0xfb5b0000), + SPH_C32(0x77840000), SPH_C32(0xba900e86), SPH_C32(0xdcb60000), + SPH_C32(0x66c07985), SPH_C32(0x1f5fdfec), SPH_C32(0x5474a433), + SPH_C32(0xbafef9d1) }, + { SPH_C32(0xb0e00000), SPH_C32(0x4c460000), SPH_C32(0x5d9b1586), + SPH_C32(0xad870000), SPH_C32(0xfc954f0a), SPH_C32(0xc250538c), + SPH_C32(0x71737990), SPH_C32(0x5eb8f418), SPH_C32(0xa90b0000), + SPH_C32(0x5ed00000), SPH_C32(0xd0f10ec8), SPH_C32(0x2c490000), + SPH_C32(0xfcf10769), SPH_C32(0x5a7c9e22), SPH_C32(0x9b222bd6), + SPH_C32(0xe9fdeade) }, + { SPH_C32(0xe2b00000), SPH_C32(0x65120000), SPH_C32(0x37fa15c8), + SPH_C32(0x5d780000), SPH_C32(0x66a431e6), SPH_C32(0x87731242), + SPH_C32(0xbe25f675), SPH_C32(0x0dbbe717), SPH_C32(0xfa860000), + SPH_C32(0xf72c0000), SPH_C32(0x4e060ece), SPH_C32(0x7ab60000), + SPH_C32(0xf6150727), SPH_C32(0xc8b953db), SPH_C32(0x32666bce), + SPH_C32(0x966abc4f) }, + { SPH_C32(0xd6c40000), SPH_C32(0xbe720000), SPH_C32(0x56dd1b00), + SPH_C32(0xc57e0000), SPH_C32(0x91365cc0), SPH_C32(0xe1131ff5), + SPH_C32(0xa7a27306), SPH_C32(0x067d1926), SPH_C32(0x666d0000), + SPH_C32(0xcc330000), SPH_C32(0xc4c20a00), SPH_C32(0xe7810000), + SPH_C32(0x9d792fe7), SPH_C32(0x8a49e06a), SPH_C32(0x3d2fb870), + SPH_C32(0xfbc5c2c5) }, + { SPH_C32(0x84940000), SPH_C32(0x97260000), SPH_C32(0x3cbc1b4e), + SPH_C32(0x35810000), SPH_C32(0x0b07222c), SPH_C32(0xa4305e3b), + SPH_C32(0x68f4fce3), SPH_C32(0x557e0a29), SPH_C32(0x35e00000), + SPH_C32(0x65cf0000), SPH_C32(0x5a350a06), SPH_C32(0xb17e0000), + SPH_C32(0x979d2fa9), SPH_C32(0x188c2d93), SPH_C32(0x946bf868), + SPH_C32(0x84529454) }, + { SPH_C32(0x85490000), SPH_C32(0x178e0000), SPH_C32(0xc82a1b06), + SPH_C32(0x93810000), SPH_C32(0x9bd25c8e), SPH_C32(0x73d6d20c), + SPH_C32(0x0ee6331e), SPH_C32(0x79ea4fb7), SPH_C32(0x67b00000), + SPH_C32(0x4c9b0000), SPH_C32(0x30540a48), SPH_C32(0x41810000), + SPH_C32(0x0dac5145), SPH_C32(0x5daf6c5d), SPH_C32(0x5b3d778d), + SPH_C32(0xd751875b) }, + { SPH_C32(0xd7190000), SPH_C32(0x3eda0000), SPH_C32(0xa24b1b48), + SPH_C32(0x637e0000), SPH_C32(0x01e32262), SPH_C32(0x36f593c2), + SPH_C32(0xc1b0bcfb), SPH_C32(0x2ae95cb8), SPH_C32(0x343d0000), + SPH_C32(0xe5670000), SPH_C32(0xaea30a4e), SPH_C32(0x177e0000), + SPH_C32(0x0748510b), SPH_C32(0xcf6aa1a4), SPH_C32(0xf2793795), + SPH_C32(0xa8c6d1ca) }, + { SPH_C32(0x1ad00000), SPH_C32(0x1b110000), SPH_C32(0x0c641c80), + SPH_C32(0xfe2e0000), SPH_C32(0xdae64f3f), SPH_C32(0x66882bed), + SPH_C32(0xcee13bc7), SPH_C32(0xcc279ed8), SPH_C32(0xe7f30000), + SPH_C32(0x20640000), SPH_C32(0xa2f00880), SPH_C32(0x72720000), + SPH_C32(0xc0d007e5), SPH_C32(0xc2bddcd6), SPH_C32(0xdb751a5d), + SPH_C32(0x75a2753f) }, + { SPH_C32(0x48800000), SPH_C32(0x32450000), SPH_C32(0x66051cce), + SPH_C32(0x0ed10000), SPH_C32(0x40d731d3), SPH_C32(0x23ab6a23), + SPH_C32(0x01b7b422), SPH_C32(0x9f248dd7), SPH_C32(0xb47e0000), + SPH_C32(0x89980000), SPH_C32(0x3c070886), SPH_C32(0x248d0000), + SPH_C32(0xca3407ab), SPH_C32(0x5078112f), SPH_C32(0x72315a45), + SPH_C32(0x0a3523ae) }, + { SPH_C32(0x495d0000), SPH_C32(0xb2ed0000), SPH_C32(0x92931c86), + SPH_C32(0xa8d10000), SPH_C32(0xd0024f71), SPH_C32(0xf44de614), + SPH_C32(0x67a57bdf), SPH_C32(0xb3b0c849), SPH_C32(0xe62e0000), + SPH_C32(0xa0cc0000), SPH_C32(0x566608c8), SPH_C32(0xd4720000), + SPH_C32(0x50057947), SPH_C32(0x155b50e1), SPH_C32(0xbd67d5a0), + SPH_C32(0x593630a1) }, + { SPH_C32(0x1b0d0000), SPH_C32(0x9bb90000), SPH_C32(0xf8f21cc8), + SPH_C32(0x582e0000), SPH_C32(0x4a33319d), SPH_C32(0xb16ea7da), + SPH_C32(0xa8f3f43a), SPH_C32(0xe0b3db46), SPH_C32(0xb5a30000), + SPH_C32(0x09300000), SPH_C32(0xc89108ce), SPH_C32(0x828d0000), + SPH_C32(0x5ae17909), SPH_C32(0x879e9d18), SPH_C32(0x142395b8), + SPH_C32(0x26a16630) }, + { SPH_C32(0x575a0000), SPH_C32(0x52250000), SPH_C32(0x30ef1980), + SPH_C32(0x508d0000), SPH_C32(0xcc9f74c2), SPH_C32(0xa9e72349), + SPH_C32(0x41f8d12b), SPH_C32(0x881aaedc), SPH_C32(0x2be70000), + SPH_C32(0x85070000), SPH_C32(0xf8490f00), SPH_C32(0x49220000), + SPH_C32(0x8b00141a), SPH_C32(0x4526e8ce), SPH_C32(0xb236529c), + SPH_C32(0xbff8f2c1) }, + { SPH_C32(0x050a0000), SPH_C32(0x7b710000), SPH_C32(0x5a8e19ce), + SPH_C32(0xa0720000), SPH_C32(0x56ae0a2e), SPH_C32(0xecc46287), + SPH_C32(0x8eae5ece), SPH_C32(0xdb19bdd3), SPH_C32(0x786a0000), + SPH_C32(0x2cfb0000), SPH_C32(0x66be0f06), SPH_C32(0x1fdd0000), + SPH_C32(0x81e41454), SPH_C32(0xd7e32537), SPH_C32(0x1b721284), + SPH_C32(0xc06fa450) }, + { SPH_C32(0x04d70000), SPH_C32(0xfbd90000), SPH_C32(0xae181986), + SPH_C32(0x06720000), SPH_C32(0xc67b748c), SPH_C32(0x3b22eeb0), + SPH_C32(0xe8bc9133), SPH_C32(0xf78df84d), SPH_C32(0x2a3a0000), + SPH_C32(0x05af0000), SPH_C32(0x0cdf0f48), SPH_C32(0xef220000), + SPH_C32(0x1bd56ab8), SPH_C32(0x92c064f9), SPH_C32(0xd4249d61), + SPH_C32(0x936cb75f) }, + { SPH_C32(0x56870000), SPH_C32(0xd28d0000), SPH_C32(0xc47919c8), + SPH_C32(0xf68d0000), SPH_C32(0x5c4a0a60), SPH_C32(0x7e01af7e), + SPH_C32(0x27ea1ed6), SPH_C32(0xa48eeb42), SPH_C32(0x79b70000), + SPH_C32(0xac530000), SPH_C32(0x92280f4e), SPH_C32(0xb9dd0000), + SPH_C32(0x11316af6), SPH_C32(0x0005a900), SPH_C32(0x7d60dd79), + SPH_C32(0xecfbe1ce) }, + { SPH_C32(0x9b4e0000), SPH_C32(0xf7460000), SPH_C32(0x6a561e00), + SPH_C32(0x6bdd0000), SPH_C32(0x874f673d), SPH_C32(0x2e7c1751), + SPH_C32(0x28bb99ea), SPH_C32(0x42402922), SPH_C32(0xaa790000), + SPH_C32(0x69500000), SPH_C32(0x9e7b0d80), SPH_C32(0xdcd10000), + SPH_C32(0xd6a93c18), SPH_C32(0x0dd2d472), SPH_C32(0x546cf0b1), + SPH_C32(0x319f453b) }, + { SPH_C32(0xc91e0000), SPH_C32(0xde120000), SPH_C32(0x00371e4e), + SPH_C32(0x9b220000), SPH_C32(0x1d7e19d1), SPH_C32(0x6b5f569f), + SPH_C32(0xe7ed160f), SPH_C32(0x11433a2d), SPH_C32(0xf9f40000), + SPH_C32(0xc0ac0000), SPH_C32(0x008c0d86), SPH_C32(0x8a2e0000), + SPH_C32(0xdc4d3c56), SPH_C32(0x9f17198b), SPH_C32(0xfd28b0a9), + SPH_C32(0x4e0813aa) }, + { SPH_C32(0xc8c30000), SPH_C32(0x5eba0000), SPH_C32(0xf4a11e06), + SPH_C32(0x3d220000), SPH_C32(0x8dab6773), SPH_C32(0xbcb9daa8), + SPH_C32(0x81ffd9f2), SPH_C32(0x3dd77fb3), SPH_C32(0xaba40000), + SPH_C32(0xe9f80000), SPH_C32(0x6aed0dc8), SPH_C32(0x7ad10000), + SPH_C32(0x467c42ba), SPH_C32(0xda345845), SPH_C32(0x327e3f4c), + SPH_C32(0x1d0b00a5) }, + { SPH_C32(0x9a930000), SPH_C32(0x77ee0000), SPH_C32(0x9ec01e48), + SPH_C32(0xcddd0000), SPH_C32(0x179a199f), SPH_C32(0xf99a9b66), + SPH_C32(0x4ea95617), SPH_C32(0x6ed46cbc), SPH_C32(0xf8290000), + SPH_C32(0x40040000), SPH_C32(0xf41a0dce), SPH_C32(0x2c2e0000), + SPH_C32(0x4c9842f4), SPH_C32(0x48f195bc), SPH_C32(0x9b3a7f54), + SPH_C32(0x629c5634) } +}; + +static const sph_u32 T512_42[128][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x92560000), SPH_C32(0x1eda0000), SPH_C32(0xea510000), + SPH_C32(0xe8b13000), SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), + SPH_C32(0xb15c2254), SPH_C32(0x33c5244f), SPH_C32(0x8c3a0000), + SPH_C32(0xda980000), SPH_C32(0x607f0000), SPH_C32(0x54078800), + SPH_C32(0x85714513), SPH_C32(0x6006b243), SPH_C32(0xdb50399c), + SPH_C32(0x8a58e6a4) }, + { SPH_C32(0x58430000), SPH_C32(0x807e0000), SPH_C32(0x78330001), + SPH_C32(0xc66b3800), SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), + SPH_C32(0xac73fe6f), SPH_C32(0x3a4479b1), SPH_C32(0x1d5a0000), + SPH_C32(0x2b720000), SPH_C32(0x488d0000), SPH_C32(0xaf611800), + SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), SPH_C32(0x81a20429), + SPH_C32(0x1e7536a6) }, + { SPH_C32(0xca150000), SPH_C32(0x9ea40000), SPH_C32(0x92620001), + SPH_C32(0x2eda0800), SPH_C32(0x4e020a79), SPH_C32(0x92565e44), + SPH_C32(0x1d2fdc3b), SPH_C32(0x09815dfe), SPH_C32(0x91600000), + SPH_C32(0xf1ea0000), SPH_C32(0x28f20000), SPH_C32(0xfb669000), + SPH_C32(0xa0ba6bd6), SPH_C32(0xa87f0d93), SPH_C32(0x5af23db5), + SPH_C32(0x942dd002) }, + { SPH_C32(0x1d5a0000), SPH_C32(0x2b720000), SPH_C32(0x488d0000), + SPH_C32(0xaf611800), SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), + SPH_C32(0x81a20429), SPH_C32(0x1e7536a6), SPH_C32(0x45190000), + SPH_C32(0xab0c0000), SPH_C32(0x30be0001), SPH_C32(0x690a2000), + SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), SPH_C32(0x2dd1fa46), + SPH_C32(0x24314f17) }, + { SPH_C32(0x8f0c0000), SPH_C32(0x35a80000), SPH_C32(0xa2dc0000), + SPH_C32(0x47d02800), SPH_C32(0x8cfe7860), SPH_C32(0x2382de49), + SPH_C32(0x30fe267d), SPH_C32(0x2db012e9), SPH_C32(0xc9230000), + SPH_C32(0x71940000), SPH_C32(0x50c10001), SPH_C32(0x3d0da800), + SPH_C32(0x478d370a), SPH_C32(0xd1d2324e), SPH_C32(0xf681c3da), + SPH_C32(0xae69a9b3) }, + { SPH_C32(0x45190000), SPH_C32(0xab0c0000), SPH_C32(0x30be0001), + SPH_C32(0x690a2000), SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), + SPH_C32(0x2dd1fa46), SPH_C32(0x24314f17), SPH_C32(0x58430000), + SPH_C32(0x807e0000), SPH_C32(0x78330001), SPH_C32(0xc66b3800), + SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), SPH_C32(0xac73fe6f), + SPH_C32(0x3a4479b1) }, + { SPH_C32(0xd74f0000), SPH_C32(0xb5d60000), SPH_C32(0xdaef0001), + SPH_C32(0x81bb1000), SPH_C32(0x6bc924bc), SPH_C32(0x5a2fe194), + SPH_C32(0x9c8dd812), SPH_C32(0x17f46b58), SPH_C32(0xd4790000), + SPH_C32(0x5ae60000), SPH_C32(0x184c0001), SPH_C32(0x926cb000), + SPH_C32(0x624619cf), SPH_C32(0x19ab8d9e), SPH_C32(0x7723c7f3), + SPH_C32(0xb01c9f15) }, + { SPH_C32(0xa53b0000), SPH_C32(0x14260000), SPH_C32(0x4e30001e), + SPH_C32(0x7cae0000), SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), + SPH_C32(0xf73168d8), SPH_C32(0x0b1b4946), SPH_C32(0x07ed0000), + SPH_C32(0xb2500000), SPH_C32(0x8774000a), SPH_C32(0x970d0000), + SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), SPH_C32(0xf4786222), + SPH_C32(0x9075b1ce) }, + { SPH_C32(0x376d0000), SPH_C32(0x0afc0000), SPH_C32(0xa461001e), + SPH_C32(0x941f3000), SPH_C32(0x26ab5b70), SPH_C32(0x9324cba4), + SPH_C32(0x466d4a8c), SPH_C32(0x38de6d09), SPH_C32(0x8bd70000), + SPH_C32(0x68c80000), SPH_C32(0xe70b000a), SPH_C32(0xc30a8800), + SPH_C32(0xc60366bd), SPH_C32(0x28c1dce7), SPH_C32(0x2f285bbe), + SPH_C32(0x1a2d576a) }, + { SPH_C32(0xfd780000), SPH_C32(0x94580000), SPH_C32(0x3603001f), + SPH_C32(0xbac53800), SPH_C32(0x68a95109), SPH_C32(0x017295e0), + SPH_C32(0x5b4296b7), SPH_C32(0x315f30f7), SPH_C32(0x1ab70000), + SPH_C32(0x99220000), SPH_C32(0xcff9000a), SPH_C32(0x386c1800), + SPH_C32(0x66b90d6b), SPH_C32(0x80bed174), SPH_C32(0x75da660b), + SPH_C32(0x8e008768) }, + { SPH_C32(0x6f2e0000), SPH_C32(0x8a820000), SPH_C32(0xdc52001f), + SPH_C32(0x52740800), SPH_C32(0xc19c07ac), SPH_C32(0xea89f479), + SPH_C32(0xea1eb4e3), SPH_C32(0x029a14b8), SPH_C32(0x968d0000), + SPH_C32(0x43ba0000), SPH_C32(0xaf86000a), SPH_C32(0x6c6b9000), + SPH_C32(0xe3c84878), SPH_C32(0xe0b86337), SPH_C32(0xae8a5f97), + SPH_C32(0x045861cc) }, + { SPH_C32(0xb8610000), SPH_C32(0x3f540000), SPH_C32(0x06bd001e), + SPH_C32(0xd3cf1800), SPH_C32(0xaa552310), SPH_C32(0xb0a615ed), + SPH_C32(0x76936cf1), SPH_C32(0x156e7fe0), SPH_C32(0x42f40000), + SPH_C32(0x195c0000), SPH_C32(0xb7ca000b), SPH_C32(0xfe072000), + SPH_C32(0x818e51b7), SPH_C32(0xf913eea9), SPH_C32(0xd9a99864), + SPH_C32(0xb444fed9) }, + { SPH_C32(0x2a370000), SPH_C32(0x218e0000), SPH_C32(0xecec001e), + SPH_C32(0x3b7e2800), SPH_C32(0x036075b5), SPH_C32(0x5b5d7474), + SPH_C32(0xc7cf4ea5), SPH_C32(0x26ab5baf), SPH_C32(0xcece0000), + SPH_C32(0xc3c40000), SPH_C32(0xd7b5000b), SPH_C32(0xaa00a800), + SPH_C32(0x04ff14a4), SPH_C32(0x99155cea), SPH_C32(0x02f9a1f8), + SPH_C32(0x3e1c187d) }, + { SPH_C32(0xe0220000), SPH_C32(0xbf2a0000), SPH_C32(0x7e8e001f), + SPH_C32(0x15a42000), SPH_C32(0x4d627fcc), SPH_C32(0xc90b2a30), + SPH_C32(0xdae0929e), SPH_C32(0x2f2a0651), SPH_C32(0x5fae0000), + SPH_C32(0x322e0000), SPH_C32(0xff47000b), SPH_C32(0x51663800), + SPH_C32(0xa4457f72), SPH_C32(0x316a5179), SPH_C32(0x580b9c4d), + SPH_C32(0xaa31c87f) }, + { SPH_C32(0x72740000), SPH_C32(0xa1f00000), SPH_C32(0x94df001f), + SPH_C32(0xfd151000), SPH_C32(0xe4572969), SPH_C32(0x22f04ba9), + SPH_C32(0x6bbcb0ca), SPH_C32(0x1cef221e), SPH_C32(0xd3940000), + SPH_C32(0xe8b60000), SPH_C32(0x9f38000b), SPH_C32(0x0561b000), + SPH_C32(0x21343a61), SPH_C32(0x516ce33a), SPH_C32(0x835ba5d1), + SPH_C32(0x20692edb) }, + { SPH_C32(0x07ed0000), SPH_C32(0xb2500000), SPH_C32(0x8774000a), + SPH_C32(0x970d0000), SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), + SPH_C32(0xf4786222), SPH_C32(0x9075b1ce), SPH_C32(0xa2d60000), + SPH_C32(0xa6760000), SPH_C32(0xc9440014), SPH_C32(0xeba30000), + SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), SPH_C32(0x03490afa), + SPH_C32(0x9b6ef888) }, + { SPH_C32(0x95bb0000), SPH_C32(0xac8a0000), SPH_C32(0x6d25000a), + SPH_C32(0x7fbc3000), SPH_C32(0xea47750b), SPH_C32(0xa33c0f3d), + SPH_C32(0x45244076), SPH_C32(0xa3b09581), SPH_C32(0x2eec0000), + SPH_C32(0x7cee0000), SPH_C32(0xa93b0014), SPH_C32(0xbfa48800), + SPH_C32(0x499d6b68), SPH_C32(0x501e76da), SPH_C32(0xd8193366), + SPH_C32(0x11361e2c) }, + { SPH_C32(0x5fae0000), SPH_C32(0x322e0000), SPH_C32(0xff47000b), + SPH_C32(0x51663800), SPH_C32(0xa4457f72), SPH_C32(0x316a5179), + SPH_C32(0x580b9c4d), SPH_C32(0xaa31c87f), SPH_C32(0xbf8c0000), + SPH_C32(0x8d040000), SPH_C32(0x81c90014), SPH_C32(0x44c21800), + SPH_C32(0xe92700be), SPH_C32(0xf8617b49), SPH_C32(0x82eb0ed3), + SPH_C32(0x851bce2e) }, + { SPH_C32(0xcdf80000), SPH_C32(0x2cf40000), SPH_C32(0x1516000b), + SPH_C32(0xb9d70800), SPH_C32(0x0d7029d7), SPH_C32(0xda9130e0), + SPH_C32(0xe957be19), SPH_C32(0x99f4ec30), SPH_C32(0x33b60000), + SPH_C32(0x579c0000), SPH_C32(0xe1b60014), SPH_C32(0x10c59000), + SPH_C32(0x6c5645ad), SPH_C32(0x9867c90a), SPH_C32(0x59bb374f), + SPH_C32(0x0f43288a) }, + { SPH_C32(0x1ab70000), SPH_C32(0x99220000), SPH_C32(0xcff9000a), + SPH_C32(0x386c1800), SPH_C32(0x66b90d6b), SPH_C32(0x80bed174), + SPH_C32(0x75da660b), SPH_C32(0x8e008768), SPH_C32(0xe7cf0000), + SPH_C32(0x0d7a0000), SPH_C32(0xf9fa0015), SPH_C32(0x82a92000), + SPH_C32(0x0e105c62), SPH_C32(0x81cc4494), SPH_C32(0x2e98f0bc), + SPH_C32(0xbf5fb79f) }, + { SPH_C32(0x88e10000), SPH_C32(0x87f80000), SPH_C32(0x25a8000a), + SPH_C32(0xd0dd2800), SPH_C32(0xcf8c5bce), SPH_C32(0x6b45b0ed), + SPH_C32(0xc486445f), SPH_C32(0xbdc5a327), SPH_C32(0x6bf50000), + SPH_C32(0xd7e20000), SPH_C32(0x99850015), SPH_C32(0xd6aea800), + SPH_C32(0x8b611971), SPH_C32(0xe1caf6d7), SPH_C32(0xf5c8c920), + SPH_C32(0x3507513b) }, + { SPH_C32(0x42f40000), SPH_C32(0x195c0000), SPH_C32(0xb7ca000b), + SPH_C32(0xfe072000), SPH_C32(0x818e51b7), SPH_C32(0xf913eea9), + SPH_C32(0xd9a99864), SPH_C32(0xb444fed9), SPH_C32(0xfa950000), + SPH_C32(0x26080000), SPH_C32(0xb1770015), SPH_C32(0x2dc83800), + SPH_C32(0x2bdb72a7), SPH_C32(0x49b5fb44), SPH_C32(0xaf3af495), + SPH_C32(0xa12a8139) }, + { SPH_C32(0xd0a20000), SPH_C32(0x07860000), SPH_C32(0x5d9b000b), + SPH_C32(0x16b61000), SPH_C32(0x28bb0712), SPH_C32(0x12e88f30), + SPH_C32(0x68f5ba30), SPH_C32(0x8781da96), SPH_C32(0x76af0000), + SPH_C32(0xfc900000), SPH_C32(0xd1080015), SPH_C32(0x79cfb000), + SPH_C32(0xaeaa37b4), SPH_C32(0x29b34907), SPH_C32(0x746acd09), + SPH_C32(0x2b72679d) }, + { SPH_C32(0xa2d60000), SPH_C32(0xa6760000), SPH_C32(0xc9440014), + SPH_C32(0xeba30000), SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), + SPH_C32(0x03490afa), SPH_C32(0x9b6ef888), SPH_C32(0xa53b0000), + SPH_C32(0x14260000), SPH_C32(0x4e30001e), SPH_C32(0x7cae0000), + SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), SPH_C32(0xf73168d8), + SPH_C32(0x0b1b4946) }, + { SPH_C32(0x30800000), SPH_C32(0xb8ac0000), SPH_C32(0x23150014), + SPH_C32(0x03123000), SPH_C32(0x65d978de), SPH_C32(0xdbe3a500), + SPH_C32(0xb21528ae), SPH_C32(0xa8abdcc7), SPH_C32(0x29010000), + SPH_C32(0xcebe0000), SPH_C32(0x2e4f001e), SPH_C32(0x28a98800), + SPH_C32(0x0aef48c6), SPH_C32(0x18d9187e), SPH_C32(0x2c615144), + SPH_C32(0x8143afe2) }, + { SPH_C32(0xfa950000), SPH_C32(0x26080000), SPH_C32(0xb1770015), + SPH_C32(0x2dc83800), SPH_C32(0x2bdb72a7), SPH_C32(0x49b5fb44), + SPH_C32(0xaf3af495), SPH_C32(0xa12a8139), SPH_C32(0xb8610000), + SPH_C32(0x3f540000), SPH_C32(0x06bd001e), SPH_C32(0xd3cf1800), + SPH_C32(0xaa552310), SPH_C32(0xb0a615ed), SPH_C32(0x76936cf1), + SPH_C32(0x156e7fe0) }, + { SPH_C32(0x68c30000), SPH_C32(0x38d20000), SPH_C32(0x5b260015), + SPH_C32(0xc5790800), SPH_C32(0x82ee2402), SPH_C32(0xa24e9add), + SPH_C32(0x1e66d6c1), SPH_C32(0x92efa576), SPH_C32(0x345b0000), + SPH_C32(0xe5cc0000), SPH_C32(0x66c2001e), SPH_C32(0x87c89000), + SPH_C32(0x2f246603), SPH_C32(0xd0a0a7ae), SPH_C32(0xadc3556d), + SPH_C32(0x9f369944) }, + { SPH_C32(0xbf8c0000), SPH_C32(0x8d040000), SPH_C32(0x81c90014), + SPH_C32(0x44c21800), SPH_C32(0xe92700be), SPH_C32(0xf8617b49), + SPH_C32(0x82eb0ed3), SPH_C32(0x851bce2e), SPH_C32(0xe0220000), + SPH_C32(0xbf2a0000), SPH_C32(0x7e8e001f), SPH_C32(0x15a42000), + SPH_C32(0x4d627fcc), SPH_C32(0xc90b2a30), SPH_C32(0xdae0929e), + SPH_C32(0x2f2a0651) }, + { SPH_C32(0x2dda0000), SPH_C32(0x93de0000), SPH_C32(0x6b980014), + SPH_C32(0xac732800), SPH_C32(0x4012561b), SPH_C32(0x139a1ad0), + SPH_C32(0x33b72c87), SPH_C32(0xb6deea61), SPH_C32(0x6c180000), + SPH_C32(0x65b20000), SPH_C32(0x1ef1001f), SPH_C32(0x41a3a800), + SPH_C32(0xc8133adf), SPH_C32(0xa90d9873), SPH_C32(0x01b0ab02), + SPH_C32(0xa572e0f5) }, + { SPH_C32(0xe7cf0000), SPH_C32(0x0d7a0000), SPH_C32(0xf9fa0015), + SPH_C32(0x82a92000), SPH_C32(0x0e105c62), SPH_C32(0x81cc4494), + SPH_C32(0x2e98f0bc), SPH_C32(0xbf5fb79f), SPH_C32(0xfd780000), + SPH_C32(0x94580000), SPH_C32(0x3603001f), SPH_C32(0xbac53800), + SPH_C32(0x68a95109), SPH_C32(0x017295e0), SPH_C32(0x5b4296b7), + SPH_C32(0x315f30f7) }, + { SPH_C32(0x75990000), SPH_C32(0x13a00000), SPH_C32(0x13ab0015), + SPH_C32(0x6a181000), SPH_C32(0xa7250ac7), SPH_C32(0x6a37250d), + SPH_C32(0x9fc4d2e8), SPH_C32(0x8c9a93d0), SPH_C32(0x71420000), + SPH_C32(0x4ec00000), SPH_C32(0x567c001f), SPH_C32(0xeec2b000), + SPH_C32(0xedd8141a), SPH_C32(0x617427a3), SPH_C32(0x8012af2b), + SPH_C32(0xbb07d653) }, + { SPH_C32(0x88980000), SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), + SPH_C32(0xfb4e0000), SPH_C32(0xf158079a), SPH_C32(0x61ae9167), + SPH_C32(0xa895706c), SPH_C32(0xe6107494), SPH_C32(0x0bc20000), + SPH_C32(0xdb630000), SPH_C32(0x7e88000c), SPH_C32(0x15860000), + SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), SPH_C32(0xf460449e), + SPH_C32(0xd8b61463) }, + { SPH_C32(0x1ace0000), SPH_C32(0x014e0000), SPH_C32(0x959e002e), + SPH_C32(0x13ff3000), SPH_C32(0x586d513f), SPH_C32(0x8a55f0fe), + SPH_C32(0x19c95238), SPH_C32(0xd5d550db), SPH_C32(0x87f80000), + SPH_C32(0x01fb0000), SPH_C32(0x1ef7000c), SPH_C32(0x41818800), + SPH_C32(0x148c0de0), SPH_C32(0x15870900), SPH_C32(0x2f307d02), + SPH_C32(0x52eef2c7) }, + { SPH_C32(0xd0db0000), SPH_C32(0x9fea0000), SPH_C32(0x07fc002f), + SPH_C32(0x3d253800), SPH_C32(0x166f5b46), SPH_C32(0x1803aeba), + SPH_C32(0x04e68e03), SPH_C32(0xdc540d25), SPH_C32(0x16980000), + SPH_C32(0xf0110000), SPH_C32(0x3605000c), SPH_C32(0xbae71800), + SPH_C32(0xb4366636), SPH_C32(0xbdf80493), SPH_C32(0x75c240b7), + SPH_C32(0xc6c322c5) }, + { SPH_C32(0x428d0000), SPH_C32(0x81300000), SPH_C32(0xedad002f), + SPH_C32(0xd5940800), SPH_C32(0xbf5a0de3), SPH_C32(0xf3f8cf23), + SPH_C32(0xb5baac57), SPH_C32(0xef91296a), SPH_C32(0x9aa20000), + SPH_C32(0x2a890000), SPH_C32(0x567a000c), SPH_C32(0xeee09000), + SPH_C32(0x31472325), SPH_C32(0xddfeb6d0), SPH_C32(0xae92792b), + SPH_C32(0x4c9bc461) }, + { SPH_C32(0x95c20000), SPH_C32(0x34e60000), SPH_C32(0x3742002e), + SPH_C32(0x542f1800), SPH_C32(0xd493295f), SPH_C32(0xa9d72eb7), + SPH_C32(0x29377445), SPH_C32(0xf8654232), SPH_C32(0x4edb0000), + SPH_C32(0x706f0000), SPH_C32(0x4e36000d), SPH_C32(0x7c8c2000), + SPH_C32(0x53013aea), SPH_C32(0xc4553b4e), SPH_C32(0xd9b1bed8), + SPH_C32(0xfc875b74) }, + { SPH_C32(0x07940000), SPH_C32(0x2a3c0000), SPH_C32(0xdd13002e), + SPH_C32(0xbc9e2800), SPH_C32(0x7da67ffa), SPH_C32(0x422c4f2e), + SPH_C32(0x986b5611), SPH_C32(0xcba0667d), SPH_C32(0xc2e10000), + SPH_C32(0xaaf70000), SPH_C32(0x2e49000d), SPH_C32(0x288ba800), + SPH_C32(0xd6707ff9), SPH_C32(0xa453890d), SPH_C32(0x02e18744), + SPH_C32(0x76dfbdd0) }, + { SPH_C32(0xcd810000), SPH_C32(0xb4980000), SPH_C32(0x4f71002f), + SPH_C32(0x92442000), SPH_C32(0x33a47583), SPH_C32(0xd07a116a), + SPH_C32(0x85448a2a), SPH_C32(0xc2213b83), SPH_C32(0x53810000), + SPH_C32(0x5b1d0000), SPH_C32(0x06bb000d), SPH_C32(0xd3ed3800), + SPH_C32(0x76ca142f), SPH_C32(0x0c2c849e), SPH_C32(0x5813baf1), + SPH_C32(0xe2f26dd2) }, + { SPH_C32(0x5fd70000), SPH_C32(0xaa420000), SPH_C32(0xa520002f), + SPH_C32(0x7af51000), SPH_C32(0x9a912326), SPH_C32(0x3b8170f3), + SPH_C32(0x3418a87e), SPH_C32(0xf1e41fcc), SPH_C32(0xdfbb0000), + SPH_C32(0x81850000), SPH_C32(0x66c4000d), SPH_C32(0x87eab000), + SPH_C32(0xf3bb513c), SPH_C32(0x6c2a36dd), SPH_C32(0x8343836d), + SPH_C32(0x68aa8b76) }, + { SPH_C32(0x2da30000), SPH_C32(0x0bb20000), SPH_C32(0x31ff0030), + SPH_C32(0x87e00000), SPH_C32(0x7ec60a4f), SPH_C32(0x19713b5a), + SPH_C32(0x5fa418b4), SPH_C32(0xed0b3dd2), SPH_C32(0x0c2f0000), + SPH_C32(0x69330000), SPH_C32(0xf9fc0006), SPH_C32(0x828b0000), + SPH_C32(0xd28f6b5d), SPH_C32(0x3d46d5e7), SPH_C32(0x001826bc), + SPH_C32(0x48c3a5ad) }, + { SPH_C32(0xbff50000), SPH_C32(0x15680000), SPH_C32(0xdbae0030), + SPH_C32(0x6f513000), SPH_C32(0xd7f35cea), SPH_C32(0xf28a5ac3), + SPH_C32(0xeef83ae0), SPH_C32(0xdece199d), SPH_C32(0x80150000), + SPH_C32(0xb3ab0000), SPH_C32(0x99830006), SPH_C32(0xd68c8800), + SPH_C32(0x57fe2e4e), SPH_C32(0x5d4067a4), SPH_C32(0xdb481f20), + SPH_C32(0xc29b4309) }, + { SPH_C32(0x75e00000), SPH_C32(0x8bcc0000), SPH_C32(0x49cc0031), + SPH_C32(0x418b3800), SPH_C32(0x99f15693), SPH_C32(0x60dc0487), + SPH_C32(0xf3d7e6db), SPH_C32(0xd74f4463), SPH_C32(0x11750000), + SPH_C32(0x42410000), SPH_C32(0xb1710006), SPH_C32(0x2dea1800), + SPH_C32(0xf7444598), SPH_C32(0xf53f6a37), SPH_C32(0x81ba2295), + SPH_C32(0x56b6930b) }, + { SPH_C32(0xe7b60000), SPH_C32(0x95160000), SPH_C32(0xa39d0031), + SPH_C32(0xa93a0800), SPH_C32(0x30c40036), SPH_C32(0x8b27651e), + SPH_C32(0x428bc48f), SPH_C32(0xe48a602c), SPH_C32(0x9d4f0000), + SPH_C32(0x98d90000), SPH_C32(0xd10e0006), SPH_C32(0x79ed9000), + SPH_C32(0x7235008b), SPH_C32(0x9539d874), SPH_C32(0x5aea1b09), + SPH_C32(0xdcee75af) }, + { SPH_C32(0x30f90000), SPH_C32(0x20c00000), SPH_C32(0x79720030), + SPH_C32(0x28811800), SPH_C32(0x5b0d248a), SPH_C32(0xd108848a), + SPH_C32(0xde061c9d), SPH_C32(0xf37e0b74), SPH_C32(0x49360000), + SPH_C32(0xc23f0000), SPH_C32(0xc9420007), SPH_C32(0xeb812000), + SPH_C32(0x10731944), SPH_C32(0x8c9255ea), SPH_C32(0x2dc9dcfa), + SPH_C32(0x6cf2eaba) }, + { SPH_C32(0xa2af0000), SPH_C32(0x3e1a0000), SPH_C32(0x93230030), + SPH_C32(0xc0302800), SPH_C32(0xf238722f), SPH_C32(0x3af3e513), + SPH_C32(0x6f5a3ec9), SPH_C32(0xc0bb2f3b), SPH_C32(0xc50c0000), + SPH_C32(0x18a70000), SPH_C32(0xa93d0007), SPH_C32(0xbf86a800), + SPH_C32(0x95025c57), SPH_C32(0xec94e7a9), SPH_C32(0xf699e566), + SPH_C32(0xe6aa0c1e) }, + { SPH_C32(0x68ba0000), SPH_C32(0xa0be0000), SPH_C32(0x01410031), + SPH_C32(0xeeea2000), SPH_C32(0xbc3a7856), SPH_C32(0xa8a5bb57), + SPH_C32(0x7275e2f2), SPH_C32(0xc93a72c5), SPH_C32(0x546c0000), + SPH_C32(0xe94d0000), SPH_C32(0x81cf0007), SPH_C32(0x44e03800), + SPH_C32(0x35b83781), SPH_C32(0x44ebea3a), SPH_C32(0xac6bd8d3), + SPH_C32(0x7287dc1c) }, + { SPH_C32(0xfaec0000), SPH_C32(0xbe640000), SPH_C32(0xeb100031), + SPH_C32(0x065b1000), SPH_C32(0x150f2ef3), SPH_C32(0x435edace), + SPH_C32(0xc329c0a6), SPH_C32(0xfaff568a), SPH_C32(0xd8560000), + SPH_C32(0x33d50000), SPH_C32(0xe1b00007), SPH_C32(0x10e7b000), + SPH_C32(0xb0c97292), SPH_C32(0x24ed5879), SPH_C32(0x773be14f), + SPH_C32(0xf8df3ab8) }, + { SPH_C32(0x8f750000), SPH_C32(0xadc40000), SPH_C32(0xf8bb0024), + SPH_C32(0x6c430000), SPH_C32(0xb22a2434), SPH_C32(0x2969ffc3), + SPH_C32(0x5ced124e), SPH_C32(0x7665c55a), SPH_C32(0xa9140000), + SPH_C32(0x7d150000), SPH_C32(0xb7cc0018), SPH_C32(0xfe250000), + SPH_C32(0x5d116688), SPH_C32(0x45997fda), SPH_C32(0xf7294e64), + SPH_C32(0x43d8eceb) }, + { SPH_C32(0x1d230000), SPH_C32(0xb31e0000), SPH_C32(0x12ea0024), + SPH_C32(0x84f23000), SPH_C32(0x1b1f7291), SPH_C32(0xc2929e5a), + SPH_C32(0xedb1301a), SPH_C32(0x45a0e115), SPH_C32(0x252e0000), + SPH_C32(0xa78d0000), SPH_C32(0xd7b30018), SPH_C32(0xaa228800), + SPH_C32(0xd860239b), SPH_C32(0x259fcd99), SPH_C32(0x2c7977f8), + SPH_C32(0xc9800a4f) }, + { SPH_C32(0xd7360000), SPH_C32(0x2dba0000), SPH_C32(0x80880025), + SPH_C32(0xaa283800), SPH_C32(0x551d78e8), SPH_C32(0x50c4c01e), + SPH_C32(0xf09eec21), SPH_C32(0x4c21bceb), SPH_C32(0xb44e0000), + SPH_C32(0x56670000), SPH_C32(0xff410018), SPH_C32(0x51441800), + SPH_C32(0x78da484d), SPH_C32(0x8de0c00a), SPH_C32(0x768b4a4d), + SPH_C32(0x5dadda4d) }, + { SPH_C32(0x45600000), SPH_C32(0x33600000), SPH_C32(0x6ad90025), + SPH_C32(0x42990800), SPH_C32(0xfc282e4d), SPH_C32(0xbb3fa187), + SPH_C32(0x41c2ce75), SPH_C32(0x7fe498a4), SPH_C32(0x38740000), + SPH_C32(0x8cff0000), SPH_C32(0x9f3e0018), SPH_C32(0x05439000), + SPH_C32(0xfdab0d5e), SPH_C32(0xede67249), SPH_C32(0xaddb73d1), + SPH_C32(0xd7f53ce9) }, + { SPH_C32(0x922f0000), SPH_C32(0x86b60000), SPH_C32(0xb0360024), + SPH_C32(0xc3221800), SPH_C32(0x97e10af1), SPH_C32(0xe1104013), + SPH_C32(0xdd4f1667), SPH_C32(0x6810f3fc), SPH_C32(0xec0d0000), + SPH_C32(0xd6190000), SPH_C32(0x87720019), SPH_C32(0x972f2000), + SPH_C32(0x9fed1491), SPH_C32(0xf44dffd7), SPH_C32(0xdaf8b422), + SPH_C32(0x67e9a3fc) }, + { SPH_C32(0x00790000), SPH_C32(0x986c0000), SPH_C32(0x5a670024), + SPH_C32(0x2b932800), SPH_C32(0x3ed45c54), SPH_C32(0x0aeb218a), + SPH_C32(0x6c133433), SPH_C32(0x5bd5d7b3), SPH_C32(0x60370000), + SPH_C32(0x0c810000), SPH_C32(0xe70d0019), SPH_C32(0xc328a800), + SPH_C32(0x1a9c5182), SPH_C32(0x944b4d94), SPH_C32(0x01a88dbe), + SPH_C32(0xedb14558) }, + { SPH_C32(0xca6c0000), SPH_C32(0x06c80000), SPH_C32(0xc8050025), + SPH_C32(0x05492000), SPH_C32(0x70d6562d), SPH_C32(0x98bd7fce), + SPH_C32(0x713ce808), SPH_C32(0x52548a4d), SPH_C32(0xf1570000), + SPH_C32(0xfd6b0000), SPH_C32(0xcfff0019), SPH_C32(0x384e3800), + SPH_C32(0xba263a54), SPH_C32(0x3c344007), SPH_C32(0x5b5ab00b), + SPH_C32(0x799c955a) }, + { SPH_C32(0x583a0000), SPH_C32(0x18120000), SPH_C32(0x22540025), + SPH_C32(0xedf81000), SPH_C32(0xd9e30088), SPH_C32(0x73461e57), + SPH_C32(0xc060ca5c), SPH_C32(0x6191ae02), SPH_C32(0x7d6d0000), + SPH_C32(0x27f30000), SPH_C32(0xaf800019), SPH_C32(0x6c49b000), + SPH_C32(0x3f577f47), SPH_C32(0x5c32f244), SPH_C32(0x800a8997), + SPH_C32(0xf3c473fe) }, + { SPH_C32(0x2a4e0000), SPH_C32(0xb9e20000), SPH_C32(0xb68b003a), + SPH_C32(0x10ed0000), SPH_C32(0x3db429e1), SPH_C32(0x51b655fe), + SPH_C32(0xabdc7a96), SPH_C32(0x7d7e8c1c), SPH_C32(0xaef90000), + SPH_C32(0xcf450000), SPH_C32(0x30b80012), SPH_C32(0x69280000), + SPH_C32(0x1e634526), SPH_C32(0x0d5e117e), SPH_C32(0x03512c46), + SPH_C32(0xd3ad5d25) }, + { SPH_C32(0xb8180000), SPH_C32(0xa7380000), SPH_C32(0x5cda003a), + SPH_C32(0xf85c3000), SPH_C32(0x94817f44), SPH_C32(0xba4d3467), + SPH_C32(0x1a8058c2), SPH_C32(0x4ebba853), SPH_C32(0x22c30000), + SPH_C32(0x15dd0000), SPH_C32(0x50c70012), SPH_C32(0x3d2f8800), + SPH_C32(0x9b120035), SPH_C32(0x6d58a33d), SPH_C32(0xd80115da), + SPH_C32(0x59f5bb81) }, + { SPH_C32(0x720d0000), SPH_C32(0x399c0000), SPH_C32(0xceb8003b), + SPH_C32(0xd6863800), SPH_C32(0xda83753d), SPH_C32(0x281b6a23), + SPH_C32(0x07af84f9), SPH_C32(0x473af5ad), SPH_C32(0xb3a30000), + SPH_C32(0xe4370000), SPH_C32(0x78350012), SPH_C32(0xc6491800), + SPH_C32(0x3ba86be3), SPH_C32(0xc527aeae), SPH_C32(0x82f3286f), + SPH_C32(0xcdd86b83) }, + { SPH_C32(0xe05b0000), SPH_C32(0x27460000), SPH_C32(0x24e9003b), + SPH_C32(0x3e370800), SPH_C32(0x73b62398), SPH_C32(0xc3e00bba), + SPH_C32(0xb6f3a6ad), SPH_C32(0x74ffd1e2), SPH_C32(0x3f990000), + SPH_C32(0x3eaf0000), SPH_C32(0x184a0012), SPH_C32(0x924e9000), + SPH_C32(0xbed92ef0), SPH_C32(0xa5211ced), SPH_C32(0x59a311f3), + SPH_C32(0x47808d27) }, + { SPH_C32(0x37140000), SPH_C32(0x92900000), SPH_C32(0xfe06003a), + SPH_C32(0xbf8c1800), SPH_C32(0x187f0724), SPH_C32(0x99cfea2e), + SPH_C32(0x2a7e7ebf), SPH_C32(0x630bbaba), SPH_C32(0xebe00000), + SPH_C32(0x64490000), SPH_C32(0x00060013), SPH_C32(0x00222000), + SPH_C32(0xdc9f373f), SPH_C32(0xbc8a9173), SPH_C32(0x2e80d600), + SPH_C32(0xf79c1232) }, + { SPH_C32(0xa5420000), SPH_C32(0x8c4a0000), SPH_C32(0x1457003a), + SPH_C32(0x573d2800), SPH_C32(0xb14a5181), SPH_C32(0x72348bb7), + SPH_C32(0x9b225ceb), SPH_C32(0x50ce9ef5), SPH_C32(0x67da0000), + SPH_C32(0xbed10000), SPH_C32(0x60790013), SPH_C32(0x5425a800), + SPH_C32(0x59ee722c), SPH_C32(0xdc8c2330), SPH_C32(0xf5d0ef9c), + SPH_C32(0x7dc4f496) }, + { SPH_C32(0x6f570000), SPH_C32(0x12ee0000), SPH_C32(0x8635003b), + SPH_C32(0x79e72000), SPH_C32(0xff485bf8), SPH_C32(0xe062d5f3), + SPH_C32(0x860d80d0), SPH_C32(0x594fc30b), SPH_C32(0xf6ba0000), + SPH_C32(0x4f3b0000), SPH_C32(0x488b0013), SPH_C32(0xaf433800), + SPH_C32(0xf95419fa), SPH_C32(0x74f32ea3), SPH_C32(0xaf22d229), + SPH_C32(0xe9e92494) }, + { SPH_C32(0xfd010000), SPH_C32(0x0c340000), SPH_C32(0x6c64003b), + SPH_C32(0x91561000), SPH_C32(0x567d0d5d), SPH_C32(0x0b99b46a), + SPH_C32(0x3751a284), SPH_C32(0x6a8ae744), SPH_C32(0x7a800000), + SPH_C32(0x95a30000), SPH_C32(0x28f40013), SPH_C32(0xfb44b000), + SPH_C32(0x7c255ce9), SPH_C32(0x14f59ce0), SPH_C32(0x7472ebb5), + SPH_C32(0x63b1c230) }, + { SPH_C32(0x0bc20000), SPH_C32(0xdb630000), SPH_C32(0x7e88000c), + SPH_C32(0x15860000), SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), + SPH_C32(0xf460449e), SPH_C32(0xd8b61463), SPH_C32(0x835a0000), + SPH_C32(0xc4f70000), SPH_C32(0x01470022), SPH_C32(0xeec80000), + SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), SPH_C32(0x5cf534f2), + SPH_C32(0x3ea660f7) }, + { SPH_C32(0x99940000), SPH_C32(0xc5b90000), SPH_C32(0x94d9000c), + SPH_C32(0xfd373000), SPH_C32(0x38c81e56), SPH_C32(0x9e7adada), + SPH_C32(0x453c66ca), SPH_C32(0xeb73302c), SPH_C32(0x0f600000), + SPH_C32(0x1e6f0000), SPH_C32(0x61380022), SPH_C32(0xbacf8800), + SPH_C32(0xe5d40a7a), SPH_C32(0x74299867), SPH_C32(0x87a50d6e), + SPH_C32(0xb4fe8653) }, + { SPH_C32(0x53810000), SPH_C32(0x5b1d0000), SPH_C32(0x06bb000d), + SPH_C32(0xd3ed3800), SPH_C32(0x76ca142f), SPH_C32(0x0c2c849e), + SPH_C32(0x5813baf1), SPH_C32(0xe2f26dd2), SPH_C32(0x9e000000), + SPH_C32(0xef850000), SPH_C32(0x49ca0022), SPH_C32(0x41a91800), + SPH_C32(0x456e61ac), SPH_C32(0xdc5695f4), SPH_C32(0xdd5730db), + SPH_C32(0x20d35651) }, + { SPH_C32(0xc1d70000), SPH_C32(0x45c70000), SPH_C32(0xecea000d), + SPH_C32(0x3b5c0800), SPH_C32(0xdfff428a), SPH_C32(0xe7d7e507), + SPH_C32(0xe94f98a5), SPH_C32(0xd137499d), SPH_C32(0x123a0000), + SPH_C32(0x351d0000), SPH_C32(0x29b50022), SPH_C32(0x15ae9000), + SPH_C32(0xc01f24bf), SPH_C32(0xbc5027b7), SPH_C32(0x06070947), + SPH_C32(0xaa8bb0f5) }, + { SPH_C32(0x16980000), SPH_C32(0xf0110000), SPH_C32(0x3605000c), + SPH_C32(0xbae71800), SPH_C32(0xb4366636), SPH_C32(0xbdf80493), + SPH_C32(0x75c240b7), SPH_C32(0xc6c322c5), SPH_C32(0xc6430000), + SPH_C32(0x6ffb0000), SPH_C32(0x31f90023), SPH_C32(0x87c22000), + SPH_C32(0xa2593d70), SPH_C32(0xa5fbaa29), SPH_C32(0x7124ceb4), + SPH_C32(0x1a972fe0) }, + { SPH_C32(0x84ce0000), SPH_C32(0xeecb0000), SPH_C32(0xdc54000c), + SPH_C32(0x52562800), SPH_C32(0x1d033093), SPH_C32(0x5603650a), + SPH_C32(0xc49e62e3), SPH_C32(0xf506068a), SPH_C32(0x4a790000), + SPH_C32(0xb5630000), SPH_C32(0x51860023), SPH_C32(0xd3c5a800), + SPH_C32(0x27287863), SPH_C32(0xc5fd186a), SPH_C32(0xaa74f728), + SPH_C32(0x90cfc944) }, + { SPH_C32(0x4edb0000), SPH_C32(0x706f0000), SPH_C32(0x4e36000d), + SPH_C32(0x7c8c2000), SPH_C32(0x53013aea), SPH_C32(0xc4553b4e), + SPH_C32(0xd9b1bed8), SPH_C32(0xfc875b74), SPH_C32(0xdb190000), + SPH_C32(0x44890000), SPH_C32(0x79740023), SPH_C32(0x28a33800), + SPH_C32(0x879213b5), SPH_C32(0x6d8215f9), SPH_C32(0xf086ca9d), + SPH_C32(0x04e21946) }, + { SPH_C32(0xdc8d0000), SPH_C32(0x6eb50000), SPH_C32(0xa467000d), + SPH_C32(0x943d1000), SPH_C32(0xfa346c4f), SPH_C32(0x2fae5ad7), + SPH_C32(0x68ed9c8c), SPH_C32(0xcf427f3b), SPH_C32(0x57230000), + SPH_C32(0x9e110000), SPH_C32(0x190b0023), SPH_C32(0x7ca4b000), + SPH_C32(0x02e356a6), SPH_C32(0x0d84a7ba), SPH_C32(0x2bd6f301), + SPH_C32(0x8ebaffe2) }, + { SPH_C32(0xaef90000), SPH_C32(0xcf450000), SPH_C32(0x30b80012), + SPH_C32(0x69280000), SPH_C32(0x1e634526), SPH_C32(0x0d5e117e), + SPH_C32(0x03512c46), SPH_C32(0xd3ad5d25), SPH_C32(0x84b70000), + SPH_C32(0x76a70000), SPH_C32(0x86330028), SPH_C32(0x79c50000), + SPH_C32(0x23d76cc7), SPH_C32(0x5ce84480), SPH_C32(0xa88d56d0), + SPH_C32(0xaed3d139) }, + { SPH_C32(0x3caf0000), SPH_C32(0xd19f0000), SPH_C32(0xdae90012), + SPH_C32(0x81993000), SPH_C32(0xb7561383), SPH_C32(0xe6a570e7), + SPH_C32(0xb20d0e12), SPH_C32(0xe068796a), SPH_C32(0x088d0000), + SPH_C32(0xac3f0000), SPH_C32(0xe64c0028), SPH_C32(0x2dc28800), + SPH_C32(0xa6a629d4), SPH_C32(0x3ceef6c3), SPH_C32(0x73dd6f4c), + SPH_C32(0x248b379d) }, + { SPH_C32(0xf6ba0000), SPH_C32(0x4f3b0000), SPH_C32(0x488b0013), + SPH_C32(0xaf433800), SPH_C32(0xf95419fa), SPH_C32(0x74f32ea3), + SPH_C32(0xaf22d229), SPH_C32(0xe9e92494), SPH_C32(0x99ed0000), + SPH_C32(0x5dd50000), SPH_C32(0xcebe0028), SPH_C32(0xd6a41800), + SPH_C32(0x061c4202), SPH_C32(0x9491fb50), SPH_C32(0x292f52f9), + SPH_C32(0xb0a6e79f) }, + { SPH_C32(0x64ec0000), SPH_C32(0x51e10000), SPH_C32(0xa2da0013), + SPH_C32(0x47f20800), SPH_C32(0x50614f5f), SPH_C32(0x9f084f3a), + SPH_C32(0x1e7ef07d), SPH_C32(0xda2c00db), SPH_C32(0x15d70000), + SPH_C32(0x874d0000), SPH_C32(0xaec10028), SPH_C32(0x82a39000), + SPH_C32(0x836d0711), SPH_C32(0xf4974913), SPH_C32(0xf27f6b65), + SPH_C32(0x3afe013b) }, + { SPH_C32(0xb3a30000), SPH_C32(0xe4370000), SPH_C32(0x78350012), + SPH_C32(0xc6491800), SPH_C32(0x3ba86be3), SPH_C32(0xc527aeae), + SPH_C32(0x82f3286f), SPH_C32(0xcdd86b83), SPH_C32(0xc1ae0000), + SPH_C32(0xddab0000), SPH_C32(0xb68d0029), SPH_C32(0x10cf2000), + SPH_C32(0xe12b1ede), SPH_C32(0xed3cc48d), SPH_C32(0x855cac96), + SPH_C32(0x8ae29e2e) }, + { SPH_C32(0x21f50000), SPH_C32(0xfaed0000), SPH_C32(0x92640012), + SPH_C32(0x2ef82800), SPH_C32(0x929d3d46), SPH_C32(0x2edccf37), + SPH_C32(0x33af0a3b), SPH_C32(0xfe1d4fcc), SPH_C32(0x4d940000), + SPH_C32(0x07330000), SPH_C32(0xd6f20029), SPH_C32(0x44c8a800), + SPH_C32(0x645a5bcd), SPH_C32(0x8d3a76ce), SPH_C32(0x5e0c950a), + SPH_C32(0x00ba788a) }, + { SPH_C32(0xebe00000), SPH_C32(0x64490000), SPH_C32(0x00060013), + SPH_C32(0x00222000), SPH_C32(0xdc9f373f), SPH_C32(0xbc8a9173), + SPH_C32(0x2e80d600), SPH_C32(0xf79c1232), SPH_C32(0xdcf40000), + SPH_C32(0xf6d90000), SPH_C32(0xfe000029), SPH_C32(0xbfae3800), + SPH_C32(0xc4e0301b), SPH_C32(0x25457b5d), SPH_C32(0x04fea8bf), + SPH_C32(0x9497a888) }, + { SPH_C32(0x79b60000), SPH_C32(0x7a930000), SPH_C32(0xea570013), + SPH_C32(0xe8931000), SPH_C32(0x75aa619a), SPH_C32(0x5771f0ea), + SPH_C32(0x9fdcf454), SPH_C32(0xc459367d), SPH_C32(0x50ce0000), + SPH_C32(0x2c410000), SPH_C32(0x9e7f0029), SPH_C32(0xeba9b000), + SPH_C32(0x41917508), SPH_C32(0x4543c91e), SPH_C32(0xdfae9123), + SPH_C32(0x1ecf4e2c) }, + { SPH_C32(0x0c2f0000), SPH_C32(0x69330000), SPH_C32(0xf9fc0006), + SPH_C32(0x828b0000), SPH_C32(0xd28f6b5d), SPH_C32(0x3d46d5e7), + SPH_C32(0x001826bc), SPH_C32(0x48c3a5ad), SPH_C32(0x218c0000), + SPH_C32(0x62810000), SPH_C32(0xc8030036), SPH_C32(0x056b0000), + SPH_C32(0xac496112), SPH_C32(0x2437eebd), SPH_C32(0x5fbc3e08), + SPH_C32(0xa5c8987f) }, + { SPH_C32(0x9e790000), SPH_C32(0x77e90000), SPH_C32(0x13ad0006), + SPH_C32(0x6a3a3000), SPH_C32(0x7bba3df8), SPH_C32(0xd6bdb47e), + SPH_C32(0xb14404e8), SPH_C32(0x7b0681e2), SPH_C32(0xadb60000), + SPH_C32(0xb8190000), SPH_C32(0xa87c0036), SPH_C32(0x516c8800), + SPH_C32(0x29382401), SPH_C32(0x44315cfe), SPH_C32(0x84ec0794), + SPH_C32(0x2f907edb) }, + { SPH_C32(0x546c0000), SPH_C32(0xe94d0000), SPH_C32(0x81cf0007), + SPH_C32(0x44e03800), SPH_C32(0x35b83781), SPH_C32(0x44ebea3a), + SPH_C32(0xac6bd8d3), SPH_C32(0x7287dc1c), SPH_C32(0x3cd60000), + SPH_C32(0x49f30000), SPH_C32(0x808e0036), SPH_C32(0xaa0a1800), + SPH_C32(0x89824fd7), SPH_C32(0xec4e516d), SPH_C32(0xde1e3a21), + SPH_C32(0xbbbdaed9) }, + { SPH_C32(0xc63a0000), SPH_C32(0xf7970000), SPH_C32(0x6b9e0007), + SPH_C32(0xac510800), SPH_C32(0x9c8d6124), SPH_C32(0xaf108ba3), + SPH_C32(0x1d37fa87), SPH_C32(0x4142f853), SPH_C32(0xb0ec0000), + SPH_C32(0x936b0000), SPH_C32(0xe0f10036), SPH_C32(0xfe0d9000), + SPH_C32(0x0cf30ac4), SPH_C32(0x8c48e32e), SPH_C32(0x054e03bd), + SPH_C32(0x31e5487d) }, + { SPH_C32(0x11750000), SPH_C32(0x42410000), SPH_C32(0xb1710006), + SPH_C32(0x2dea1800), SPH_C32(0xf7444598), SPH_C32(0xf53f6a37), + SPH_C32(0x81ba2295), SPH_C32(0x56b6930b), SPH_C32(0x64950000), + SPH_C32(0xc98d0000), SPH_C32(0xf8bd0037), SPH_C32(0x6c612000), + SPH_C32(0x6eb5130b), SPH_C32(0x95e36eb0), SPH_C32(0x726dc44e), + SPH_C32(0x81f9d768) }, + { SPH_C32(0x83230000), SPH_C32(0x5c9b0000), SPH_C32(0x5b200006), + SPH_C32(0xc55b2800), SPH_C32(0x5e71133d), SPH_C32(0x1ec40bae), + SPH_C32(0x30e600c1), SPH_C32(0x6573b744), SPH_C32(0xe8af0000), + SPH_C32(0x13150000), SPH_C32(0x98c20037), SPH_C32(0x3866a800), + SPH_C32(0xebc45618), SPH_C32(0xf5e5dcf3), SPH_C32(0xa93dfdd2), + SPH_C32(0x0ba131cc) }, + { SPH_C32(0x49360000), SPH_C32(0xc23f0000), SPH_C32(0xc9420007), + SPH_C32(0xeb812000), SPH_C32(0x10731944), SPH_C32(0x8c9255ea), + SPH_C32(0x2dc9dcfa), SPH_C32(0x6cf2eaba), SPH_C32(0x79cf0000), + SPH_C32(0xe2ff0000), SPH_C32(0xb0300037), SPH_C32(0xc3003800), + SPH_C32(0x4b7e3dce), SPH_C32(0x5d9ad160), SPH_C32(0xf3cfc067), + SPH_C32(0x9f8ce1ce) }, + { SPH_C32(0xdb600000), SPH_C32(0xdce50000), SPH_C32(0x23130007), + SPH_C32(0x03301000), SPH_C32(0xb9464fe1), SPH_C32(0x67693473), + SPH_C32(0x9c95feae), SPH_C32(0x5f37cef5), SPH_C32(0xf5f50000), + SPH_C32(0x38670000), SPH_C32(0xd04f0037), SPH_C32(0x9707b000), + SPH_C32(0xce0f78dd), SPH_C32(0x3d9c6323), SPH_C32(0x289ff9fb), + SPH_C32(0x15d4076a) }, + { SPH_C32(0xa9140000), SPH_C32(0x7d150000), SPH_C32(0xb7cc0018), + SPH_C32(0xfe250000), SPH_C32(0x5d116688), SPH_C32(0x45997fda), + SPH_C32(0xf7294e64), SPH_C32(0x43d8eceb), SPH_C32(0x26610000), + SPH_C32(0xd0d10000), SPH_C32(0x4f77003c), SPH_C32(0x92660000), + SPH_C32(0xef3b42bc), SPH_C32(0x6cf08019), SPH_C32(0xabc45c2a), + SPH_C32(0x35bd29b1) }, + { SPH_C32(0x3b420000), SPH_C32(0x63cf0000), SPH_C32(0x5d9d0018), + SPH_C32(0x16943000), SPH_C32(0xf424302d), SPH_C32(0xae621e43), + SPH_C32(0x46756c30), SPH_C32(0x701dc8a4), SPH_C32(0xaa5b0000), + SPH_C32(0x0a490000), SPH_C32(0x2f08003c), SPH_C32(0xc6618800), + SPH_C32(0x6a4a07af), SPH_C32(0x0cf6325a), SPH_C32(0x709465b6), + SPH_C32(0xbfe5cf15) }, + { SPH_C32(0xf1570000), SPH_C32(0xfd6b0000), SPH_C32(0xcfff0019), + SPH_C32(0x384e3800), SPH_C32(0xba263a54), SPH_C32(0x3c344007), + SPH_C32(0x5b5ab00b), SPH_C32(0x799c955a), SPH_C32(0x3b3b0000), + SPH_C32(0xfba30000), SPH_C32(0x07fa003c), SPH_C32(0x3d071800), + SPH_C32(0xcaf06c79), SPH_C32(0xa4893fc9), SPH_C32(0x2a665803), + SPH_C32(0x2bc81f17) }, + { SPH_C32(0x63010000), SPH_C32(0xe3b10000), SPH_C32(0x25ae0019), + SPH_C32(0xd0ff0800), SPH_C32(0x13136cf1), SPH_C32(0xd7cf219e), + SPH_C32(0xea06925f), SPH_C32(0x4a59b115), SPH_C32(0xb7010000), + SPH_C32(0x213b0000), SPH_C32(0x6785003c), SPH_C32(0x69009000), + SPH_C32(0x4f81296a), SPH_C32(0xc48f8d8a), SPH_C32(0xf136619f), + SPH_C32(0xa190f9b3) }, + { SPH_C32(0xb44e0000), SPH_C32(0x56670000), SPH_C32(0xff410018), + SPH_C32(0x51441800), SPH_C32(0x78da484d), SPH_C32(0x8de0c00a), + SPH_C32(0x768b4a4d), SPH_C32(0x5dadda4d), SPH_C32(0x63780000), + SPH_C32(0x7bdd0000), SPH_C32(0x7fc9003d), SPH_C32(0xfb6c2000), + SPH_C32(0x2dc730a5), SPH_C32(0xdd240014), SPH_C32(0x8615a66c), + SPH_C32(0x118c66a6) }, + { SPH_C32(0x26180000), SPH_C32(0x48bd0000), SPH_C32(0x15100018), + SPH_C32(0xb9f52800), SPH_C32(0xd1ef1ee8), SPH_C32(0x661ba193), + SPH_C32(0xc7d76819), SPH_C32(0x6e68fe02), SPH_C32(0xef420000), + SPH_C32(0xa1450000), SPH_C32(0x1fb6003d), SPH_C32(0xaf6ba800), + SPH_C32(0xa8b675b6), SPH_C32(0xbd22b257), SPH_C32(0x5d459ff0), + SPH_C32(0x9bd48002) }, + { SPH_C32(0xec0d0000), SPH_C32(0xd6190000), SPH_C32(0x87720019), + SPH_C32(0x972f2000), SPH_C32(0x9fed1491), SPH_C32(0xf44dffd7), + SPH_C32(0xdaf8b422), SPH_C32(0x67e9a3fc), SPH_C32(0x7e220000), + SPH_C32(0x50af0000), SPH_C32(0x3744003d), SPH_C32(0x540d3800), + SPH_C32(0x080c1e60), SPH_C32(0x155dbfc4), SPH_C32(0x07b7a245), + SPH_C32(0x0ff95000) }, + { SPH_C32(0x7e5b0000), SPH_C32(0xc8c30000), SPH_C32(0x6d230019), + SPH_C32(0x7f9e1000), SPH_C32(0x36d84234), SPH_C32(0x1fb69e4e), + SPH_C32(0x6ba49676), SPH_C32(0x542c87b3), SPH_C32(0xf2180000), + SPH_C32(0x8a370000), SPH_C32(0x573b003d), SPH_C32(0x000ab000), + SPH_C32(0x8d7d5b73), SPH_C32(0x755b0d87), SPH_C32(0xdce79bd9), + SPH_C32(0x85a1b6a4) }, + { SPH_C32(0x835a0000), SPH_C32(0xc4f70000), SPH_C32(0x01470022), + SPH_C32(0xeec80000), SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), + SPH_C32(0x5cf534f2), SPH_C32(0x3ea660f7), SPH_C32(0x88980000), + SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), SPH_C32(0xfb4e0000), + SPH_C32(0xf158079a), SPH_C32(0x61ae9167), SPH_C32(0xa895706c), + SPH_C32(0xe6107494) }, + { SPH_C32(0x110c0000), SPH_C32(0xda2d0000), SPH_C32(0xeb160022), + SPH_C32(0x06793000), SPH_C32(0xc99019cc), SPH_C32(0xffd44bbd), + SPH_C32(0xeda916a6), SPH_C32(0x0d6344b8), SPH_C32(0x04a20000), + SPH_C32(0xc50c0000), SPH_C32(0x1fb0002e), SPH_C32(0xaf498800), + SPH_C32(0x74294289), SPH_C32(0x01a82324), SPH_C32(0x73c549f0), + SPH_C32(0x6c489230) }, + { SPH_C32(0xdb190000), SPH_C32(0x44890000), SPH_C32(0x79740023), + SPH_C32(0x28a33800), SPH_C32(0x879213b5), SPH_C32(0x6d8215f9), + SPH_C32(0xf086ca9d), SPH_C32(0x04e21946), SPH_C32(0x95c20000), + SPH_C32(0x34e60000), SPH_C32(0x3742002e), SPH_C32(0x542f1800), + SPH_C32(0xd493295f), SPH_C32(0xa9d72eb7), SPH_C32(0x29377445), + SPH_C32(0xf8654232) }, + { SPH_C32(0x494f0000), SPH_C32(0x5a530000), SPH_C32(0x93250023), + SPH_C32(0xc0120800), SPH_C32(0x2ea74510), SPH_C32(0x86797460), + SPH_C32(0x41dae8c9), SPH_C32(0x37273d09), SPH_C32(0x19f80000), + SPH_C32(0xee7e0000), SPH_C32(0x573d002e), SPH_C32(0x00289000), + SPH_C32(0x51e26c4c), SPH_C32(0xc9d19cf4), SPH_C32(0xf2674dd9), + SPH_C32(0x723da496) }, + { SPH_C32(0x9e000000), SPH_C32(0xef850000), SPH_C32(0x49ca0022), + SPH_C32(0x41a91800), SPH_C32(0x456e61ac), SPH_C32(0xdc5695f4), + SPH_C32(0xdd5730db), SPH_C32(0x20d35651), SPH_C32(0xcd810000), + SPH_C32(0xb4980000), SPH_C32(0x4f71002f), SPH_C32(0x92442000), + SPH_C32(0x33a47583), SPH_C32(0xd07a116a), SPH_C32(0x85448a2a), + SPH_C32(0xc2213b83) }, + { SPH_C32(0x0c560000), SPH_C32(0xf15f0000), SPH_C32(0xa39b0022), + SPH_C32(0xa9182800), SPH_C32(0xec5b3709), SPH_C32(0x37adf46d), + SPH_C32(0x6c0b128f), SPH_C32(0x1316721e), SPH_C32(0x41bb0000), + SPH_C32(0x6e000000), SPH_C32(0x2f0e002f), SPH_C32(0xc643a800), + SPH_C32(0xb6d53090), SPH_C32(0xb07ca329), SPH_C32(0x5e14b3b6), + SPH_C32(0x4879dd27) }, + { SPH_C32(0xc6430000), SPH_C32(0x6ffb0000), SPH_C32(0x31f90023), + SPH_C32(0x87c22000), SPH_C32(0xa2593d70), SPH_C32(0xa5fbaa29), + SPH_C32(0x7124ceb4), SPH_C32(0x1a972fe0), SPH_C32(0xd0db0000), + SPH_C32(0x9fea0000), SPH_C32(0x07fc002f), SPH_C32(0x3d253800), + SPH_C32(0x166f5b46), SPH_C32(0x1803aeba), SPH_C32(0x04e68e03), + SPH_C32(0xdc540d25) }, + { SPH_C32(0x54150000), SPH_C32(0x71210000), SPH_C32(0xdba80023), + SPH_C32(0x6f731000), SPH_C32(0x0b6c6bd5), SPH_C32(0x4e00cbb0), + SPH_C32(0xc078ece0), SPH_C32(0x29520baf), SPH_C32(0x5ce10000), + SPH_C32(0x45720000), SPH_C32(0x6783002f), SPH_C32(0x6922b000), + SPH_C32(0x931e1e55), SPH_C32(0x78051cf9), SPH_C32(0xdfb6b79f), + SPH_C32(0x560ceb81) }, + { SPH_C32(0x26610000), SPH_C32(0xd0d10000), SPH_C32(0x4f77003c), + SPH_C32(0x92660000), SPH_C32(0xef3b42bc), SPH_C32(0x6cf08019), + SPH_C32(0xabc45c2a), SPH_C32(0x35bd29b1), SPH_C32(0x8f750000), + SPH_C32(0xadc40000), SPH_C32(0xf8bb0024), SPH_C32(0x6c430000), + SPH_C32(0xb22a2434), SPH_C32(0x2969ffc3), SPH_C32(0x5ced124e), + SPH_C32(0x7665c55a) }, + { SPH_C32(0xb4370000), SPH_C32(0xce0b0000), SPH_C32(0xa526003c), + SPH_C32(0x7ad73000), SPH_C32(0x460e1419), SPH_C32(0x870be180), + SPH_C32(0x1a987e7e), SPH_C32(0x06780dfe), SPH_C32(0x034f0000), + SPH_C32(0x775c0000), SPH_C32(0x98c40024), SPH_C32(0x38448800), + SPH_C32(0x375b6127), SPH_C32(0x496f4d80), SPH_C32(0x87bd2bd2), + SPH_C32(0xfc3d23fe) }, + { SPH_C32(0x7e220000), SPH_C32(0x50af0000), SPH_C32(0x3744003d), + SPH_C32(0x540d3800), SPH_C32(0x080c1e60), SPH_C32(0x155dbfc4), + SPH_C32(0x07b7a245), SPH_C32(0x0ff95000), SPH_C32(0x922f0000), + SPH_C32(0x86b60000), SPH_C32(0xb0360024), SPH_C32(0xc3221800), + SPH_C32(0x97e10af1), SPH_C32(0xe1104013), SPH_C32(0xdd4f1667), + SPH_C32(0x6810f3fc) }, + { SPH_C32(0xec740000), SPH_C32(0x4e750000), SPH_C32(0xdd15003d), + SPH_C32(0xbcbc0800), SPH_C32(0xa13948c5), SPH_C32(0xfea6de5d), + SPH_C32(0xb6eb8011), SPH_C32(0x3c3c744f), SPH_C32(0x1e150000), + SPH_C32(0x5c2e0000), SPH_C32(0xd0490024), SPH_C32(0x97259000), + SPH_C32(0x12904fe2), SPH_C32(0x8116f250), SPH_C32(0x061f2ffb), + SPH_C32(0xe2481558) }, + { SPH_C32(0x3b3b0000), SPH_C32(0xfba30000), SPH_C32(0x07fa003c), + SPH_C32(0x3d071800), SPH_C32(0xcaf06c79), SPH_C32(0xa4893fc9), + SPH_C32(0x2a665803), SPH_C32(0x2bc81f17), SPH_C32(0xca6c0000), + SPH_C32(0x06c80000), SPH_C32(0xc8050025), SPH_C32(0x05492000), + SPH_C32(0x70d6562d), SPH_C32(0x98bd7fce), SPH_C32(0x713ce808), + SPH_C32(0x52548a4d) }, + { SPH_C32(0xa96d0000), SPH_C32(0xe5790000), SPH_C32(0xedab003c), + SPH_C32(0xd5b62800), SPH_C32(0x63c53adc), SPH_C32(0x4f725e50), + SPH_C32(0x9b3a7a57), SPH_C32(0x180d3b58), SPH_C32(0x46560000), + SPH_C32(0xdc500000), SPH_C32(0xa87a0025), SPH_C32(0x514ea800), + SPH_C32(0xf5a7133e), SPH_C32(0xf8bbcd8d), SPH_C32(0xaa6cd194), + SPH_C32(0xd80c6ce9) }, + { SPH_C32(0x63780000), SPH_C32(0x7bdd0000), SPH_C32(0x7fc9003d), + SPH_C32(0xfb6c2000), SPH_C32(0x2dc730a5), SPH_C32(0xdd240014), + SPH_C32(0x8615a66c), SPH_C32(0x118c66a6), SPH_C32(0xd7360000), + SPH_C32(0x2dba0000), SPH_C32(0x80880025), SPH_C32(0xaa283800), + SPH_C32(0x551d78e8), SPH_C32(0x50c4c01e), SPH_C32(0xf09eec21), + SPH_C32(0x4c21bceb) }, + { SPH_C32(0xf12e0000), SPH_C32(0x65070000), SPH_C32(0x9598003d), + SPH_C32(0x13dd1000), SPH_C32(0x84f26600), SPH_C32(0x36df618d), + SPH_C32(0x37498438), SPH_C32(0x224942e9), SPH_C32(0x5b0c0000), + SPH_C32(0xf7220000), SPH_C32(0xe0f70025), SPH_C32(0xfe2fb000), + SPH_C32(0xd06c3dfb), SPH_C32(0x30c2725d), SPH_C32(0x2bced5bd), + SPH_C32(0xc6795a4f) }, + { SPH_C32(0x84b70000), SPH_C32(0x76a70000), SPH_C32(0x86330028), + SPH_C32(0x79c50000), SPH_C32(0x23d76cc7), SPH_C32(0x5ce84480), + SPH_C32(0xa88d56d0), SPH_C32(0xaed3d139), SPH_C32(0x2a4e0000), + SPH_C32(0xb9e20000), SPH_C32(0xb68b003a), SPH_C32(0x10ed0000), + SPH_C32(0x3db429e1), SPH_C32(0x51b655fe), SPH_C32(0xabdc7a96), + SPH_C32(0x7d7e8c1c) }, + { SPH_C32(0x16e10000), SPH_C32(0x687d0000), SPH_C32(0x6c620028), + SPH_C32(0x91743000), SPH_C32(0x8ae23a62), SPH_C32(0xb7132519), + SPH_C32(0x19d17484), SPH_C32(0x9d16f576), SPH_C32(0xa6740000), + SPH_C32(0x637a0000), SPH_C32(0xd6f4003a), SPH_C32(0x44ea8800), + SPH_C32(0xb8c56cf2), SPH_C32(0x31b0e7bd), SPH_C32(0x708c430a), + SPH_C32(0xf7266ab8) }, + { SPH_C32(0xdcf40000), SPH_C32(0xf6d90000), SPH_C32(0xfe000029), + SPH_C32(0xbfae3800), SPH_C32(0xc4e0301b), SPH_C32(0x25457b5d), + SPH_C32(0x04fea8bf), SPH_C32(0x9497a888), SPH_C32(0x37140000), + SPH_C32(0x92900000), SPH_C32(0xfe06003a), SPH_C32(0xbf8c1800), + SPH_C32(0x187f0724), SPH_C32(0x99cfea2e), SPH_C32(0x2a7e7ebf), + SPH_C32(0x630bbaba) }, + { SPH_C32(0x4ea20000), SPH_C32(0xe8030000), SPH_C32(0x14510029), + SPH_C32(0x571f0800), SPH_C32(0x6dd566be), SPH_C32(0xcebe1ac4), + SPH_C32(0xb5a28aeb), SPH_C32(0xa7528cc7), SPH_C32(0xbb2e0000), + SPH_C32(0x48080000), SPH_C32(0x9e79003a), SPH_C32(0xeb8b9000), + SPH_C32(0x9d0e4237), SPH_C32(0xf9c9586d), SPH_C32(0xf12e4723), + SPH_C32(0xe9535c1e) }, + { SPH_C32(0x99ed0000), SPH_C32(0x5dd50000), SPH_C32(0xcebe0028), + SPH_C32(0xd6a41800), SPH_C32(0x061c4202), SPH_C32(0x9491fb50), + SPH_C32(0x292f52f9), SPH_C32(0xb0a6e79f), SPH_C32(0x6f570000), + SPH_C32(0x12ee0000), SPH_C32(0x8635003b), SPH_C32(0x79e72000), + SPH_C32(0xff485bf8), SPH_C32(0xe062d5f3), SPH_C32(0x860d80d0), + SPH_C32(0x594fc30b) }, + { SPH_C32(0x0bbb0000), SPH_C32(0x430f0000), SPH_C32(0x24ef0028), + SPH_C32(0x3e152800), SPH_C32(0xaf2914a7), SPH_C32(0x7f6a9ac9), + SPH_C32(0x987370ad), SPH_C32(0x8363c3d0), SPH_C32(0xe36d0000), + SPH_C32(0xc8760000), SPH_C32(0xe64a003b), SPH_C32(0x2de0a800), + SPH_C32(0x7a391eeb), SPH_C32(0x806467b0), SPH_C32(0x5d5db94c), + SPH_C32(0xd31725af) }, + { SPH_C32(0xc1ae0000), SPH_C32(0xddab0000), SPH_C32(0xb68d0029), + SPH_C32(0x10cf2000), SPH_C32(0xe12b1ede), SPH_C32(0xed3cc48d), + SPH_C32(0x855cac96), SPH_C32(0x8ae29e2e), SPH_C32(0x720d0000), + SPH_C32(0x399c0000), SPH_C32(0xceb8003b), SPH_C32(0xd6863800), + SPH_C32(0xda83753d), SPH_C32(0x281b6a23), SPH_C32(0x07af84f9), + SPH_C32(0x473af5ad) }, + { SPH_C32(0x53f80000), SPH_C32(0xc3710000), SPH_C32(0x5cdc0029), + SPH_C32(0xf87e1000), SPH_C32(0x481e487b), SPH_C32(0x06c7a514), + SPH_C32(0x34008ec2), SPH_C32(0xb927ba61), SPH_C32(0xfe370000), + SPH_C32(0xe3040000), SPH_C32(0xaec7003b), SPH_C32(0x8281b000), + SPH_C32(0x5ff2302e), SPH_C32(0x481dd860), SPH_C32(0xdcffbd65), + SPH_C32(0xcd621309) }, + { SPH_C32(0x218c0000), SPH_C32(0x62810000), SPH_C32(0xc8030036), + SPH_C32(0x056b0000), SPH_C32(0xac496112), SPH_C32(0x2437eebd), + SPH_C32(0x5fbc3e08), SPH_C32(0xa5c8987f), SPH_C32(0x2da30000), + SPH_C32(0x0bb20000), SPH_C32(0x31ff0030), SPH_C32(0x87e00000), + SPH_C32(0x7ec60a4f), SPH_C32(0x19713b5a), SPH_C32(0x5fa418b4), + SPH_C32(0xed0b3dd2) }, + { SPH_C32(0xb3da0000), SPH_C32(0x7c5b0000), SPH_C32(0x22520036), + SPH_C32(0xedda3000), SPH_C32(0x057c37b7), SPH_C32(0xcfcc8f24), + SPH_C32(0xeee01c5c), SPH_C32(0x960dbc30), SPH_C32(0xa1990000), + SPH_C32(0xd12a0000), SPH_C32(0x51800030), SPH_C32(0xd3e78800), + SPH_C32(0xfbb74f5c), SPH_C32(0x79778919), SPH_C32(0x84f42128), + SPH_C32(0x6753db76) }, + { SPH_C32(0x79cf0000), SPH_C32(0xe2ff0000), SPH_C32(0xb0300037), + SPH_C32(0xc3003800), SPH_C32(0x4b7e3dce), SPH_C32(0x5d9ad160), + SPH_C32(0xf3cfc067), SPH_C32(0x9f8ce1ce), SPH_C32(0x30f90000), + SPH_C32(0x20c00000), SPH_C32(0x79720030), SPH_C32(0x28811800), + SPH_C32(0x5b0d248a), SPH_C32(0xd108848a), SPH_C32(0xde061c9d), + SPH_C32(0xf37e0b74) }, + { SPH_C32(0xeb990000), SPH_C32(0xfc250000), SPH_C32(0x5a610037), + SPH_C32(0x2bb10800), SPH_C32(0xe24b6b6b), SPH_C32(0xb661b0f9), + SPH_C32(0x4293e233), SPH_C32(0xac49c581), SPH_C32(0xbcc30000), + SPH_C32(0xfa580000), SPH_C32(0x190d0030), SPH_C32(0x7c869000), + SPH_C32(0xde7c6199), SPH_C32(0xb10e36c9), SPH_C32(0x05562501), + SPH_C32(0x7926edd0) }, + { SPH_C32(0x3cd60000), SPH_C32(0x49f30000), SPH_C32(0x808e0036), + SPH_C32(0xaa0a1800), SPH_C32(0x89824fd7), SPH_C32(0xec4e516d), + SPH_C32(0xde1e3a21), SPH_C32(0xbbbdaed9), SPH_C32(0x68ba0000), + SPH_C32(0xa0be0000), SPH_C32(0x01410031), SPH_C32(0xeeea2000), + SPH_C32(0xbc3a7856), SPH_C32(0xa8a5bb57), SPH_C32(0x7275e2f2), + SPH_C32(0xc93a72c5) }, + { SPH_C32(0xae800000), SPH_C32(0x57290000), SPH_C32(0x6adf0036), + SPH_C32(0x42bb2800), SPH_C32(0x20b71972), SPH_C32(0x07b530f4), + SPH_C32(0x6f421875), SPH_C32(0x88788a96), SPH_C32(0xe4800000), + SPH_C32(0x7a260000), SPH_C32(0x613e0031), SPH_C32(0xbaeda800), + SPH_C32(0x394b3d45), SPH_C32(0xc8a30914), SPH_C32(0xa925db6e), + SPH_C32(0x43629461) }, + { SPH_C32(0x64950000), SPH_C32(0xc98d0000), SPH_C32(0xf8bd0037), + SPH_C32(0x6c612000), SPH_C32(0x6eb5130b), SPH_C32(0x95e36eb0), + SPH_C32(0x726dc44e), SPH_C32(0x81f9d768), SPH_C32(0x75e00000), + SPH_C32(0x8bcc0000), SPH_C32(0x49cc0031), SPH_C32(0x418b3800), + SPH_C32(0x99f15693), SPH_C32(0x60dc0487), SPH_C32(0xf3d7e6db), + SPH_C32(0xd74f4463) }, + { SPH_C32(0xf6c30000), SPH_C32(0xd7570000), SPH_C32(0x12ec0037), + SPH_C32(0x84d01000), SPH_C32(0xc78045ae), SPH_C32(0x7e180f29), + SPH_C32(0xc331e61a), SPH_C32(0xb23cf327), SPH_C32(0xf9da0000), + SPH_C32(0x51540000), SPH_C32(0x29b30031), SPH_C32(0x158cb000), + SPH_C32(0x1c801380), SPH_C32(0x00dab6c4), SPH_C32(0x2887df47), + SPH_C32(0x5d17a2c7) } +}; + +static const sph_u32 T512_49[128][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xe6280000), SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), + SPH_C32(0xd3d002e0), SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), + SPH_C32(0x289506b4), SPH_C32(0xd75a4897), SPH_C32(0xf0c50000), + SPH_C32(0x59230000), SPH_C32(0x45820000), SPH_C32(0xe18d00c0), + SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), SPH_C32(0xcbe0fe1c), + SPH_C32(0x56a7b19f) }, + { SPH_C32(0xf0c50000), SPH_C32(0x59230000), SPH_C32(0x45820000), + SPH_C32(0xe18d00c0), SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), + SPH_C32(0xcbe0fe1c), SPH_C32(0x56a7b19f), SPH_C32(0x16ed0000), + SPH_C32(0x15680000), SPH_C32(0xedd70000), SPH_C32(0x325d0220), + SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), SPH_C32(0xe375f8a8), + SPH_C32(0x81fdf908) }, + { SPH_C32(0x16ed0000), SPH_C32(0x15680000), SPH_C32(0xedd70000), + SPH_C32(0x325d0220), SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), + SPH_C32(0xe375f8a8), SPH_C32(0x81fdf908), SPH_C32(0xe6280000), + SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), SPH_C32(0xd3d002e0), + SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), SPH_C32(0x289506b4), + SPH_C32(0xd75a4897) }, + { SPH_C32(0xb4310000), SPH_C32(0x77330000), SPH_C32(0xb15d0000), + SPH_C32(0x7fd004e0), SPH_C32(0x78a26138), SPH_C32(0xd116c35d), + SPH_C32(0xd256d489), SPH_C32(0x4e6f74de), SPH_C32(0xe3060000), + SPH_C32(0xbdc10000), SPH_C32(0x87130000), SPH_C32(0xbff20060), + SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), SPH_C32(0x73c5ab06), + SPH_C32(0x5bd61539) }, + { SPH_C32(0x52190000), SPH_C32(0x3b780000), SPH_C32(0x19080000), + SPH_C32(0xac000600), SPH_C32(0xa0c35180), SPH_C32(0x49b17387), + SPH_C32(0xfac3d23d), SPH_C32(0x99353c49), SPH_C32(0x13c30000), + SPH_C32(0xe4e20000), SPH_C32(0xc2910000), SPH_C32(0x5e7f00a0), + SPH_C32(0x15d70c2b), SPH_C32(0x4f5861c8), SPH_C32(0xb825551a), + SPH_C32(0x0d71a4a6) }, + { SPH_C32(0x44f40000), SPH_C32(0x2e100000), SPH_C32(0xf4df0000), + SPH_C32(0x9e5d0420), SPH_C32(0x43cf6709), SPH_C32(0x13fb95c4), + SPH_C32(0x19b62a95), SPH_C32(0x18c8c541), SPH_C32(0xf5eb0000), + SPH_C32(0xa8a90000), SPH_C32(0x6ac40000), SPH_C32(0x8daf0240), + SPH_C32(0xcdb63c93), SPH_C32(0xd7ffd112), SPH_C32(0x90b053ae), + SPH_C32(0xda2bec31) }, + { SPH_C32(0xa2dc0000), SPH_C32(0x625b0000), SPH_C32(0x5c8a0000), + SPH_C32(0x4d8d06c0), SPH_C32(0x9bae57b1), SPH_C32(0x8b5c251e), + SPH_C32(0x31232c21), SPH_C32(0xcf928dd6), SPH_C32(0x052e0000), + SPH_C32(0xf18a0000), SPH_C32(0x2f460000), SPH_C32(0x6c220280), + SPH_C32(0xf6db3aa2), SPH_C32(0x1512878b), SPH_C32(0x5b50adb2), + SPH_C32(0x8c8c5dae) }, + { SPH_C32(0xe3060000), SPH_C32(0xbdc10000), SPH_C32(0x87130000), + SPH_C32(0xbff20060), SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), + SPH_C32(0x73c5ab06), SPH_C32(0x5bd61539), SPH_C32(0x57370000), + SPH_C32(0xcaf20000), SPH_C32(0x364e0000), SPH_C32(0xc0220480), + SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), SPH_C32(0xa1937f8f), + SPH_C32(0x15b961e7) }, + { SPH_C32(0x052e0000), SPH_C32(0xf18a0000), SPH_C32(0x2f460000), + SPH_C32(0x6c220280), SPH_C32(0xf6db3aa2), SPH_C32(0x1512878b), + SPH_C32(0x5b50adb2), SPH_C32(0x8c8c5dae), SPH_C32(0xa7f20000), + SPH_C32(0x93d10000), SPH_C32(0x73cc0000), SPH_C32(0x21af0440), + SPH_C32(0x6d756d13), SPH_C32(0x9e4ea295), SPH_C32(0x6a738193), + SPH_C32(0x431ed078) }, + { SPH_C32(0x13c30000), SPH_C32(0xe4e20000), SPH_C32(0xc2910000), + SPH_C32(0x5e7f00a0), SPH_C32(0x15d70c2b), SPH_C32(0x4f5861c8), + SPH_C32(0xb825551a), SPH_C32(0x0d71a4a6), SPH_C32(0x41da0000), + SPH_C32(0xdf9a0000), SPH_C32(0xdb990000), SPH_C32(0xf27f06a0), + SPH_C32(0xb5145dab), SPH_C32(0x06e9124f), SPH_C32(0x42e68727), + SPH_C32(0x944498ef) }, + { SPH_C32(0xf5eb0000), SPH_C32(0xa8a90000), SPH_C32(0x6ac40000), + SPH_C32(0x8daf0240), SPH_C32(0xcdb63c93), SPH_C32(0xd7ffd112), + SPH_C32(0x90b053ae), SPH_C32(0xda2bec31), SPH_C32(0xb11f0000), + SPH_C32(0x86b90000), SPH_C32(0x9e1b0000), SPH_C32(0x13f20660), + SPH_C32(0x8e795b9a), SPH_C32(0xc40444d6), SPH_C32(0x8906793b), + SPH_C32(0xc2e32970) }, + { SPH_C32(0x57370000), SPH_C32(0xcaf20000), SPH_C32(0x364e0000), + SPH_C32(0xc0220480), SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), + SPH_C32(0xa1937f8f), SPH_C32(0x15b961e7), SPH_C32(0xb4310000), + SPH_C32(0x77330000), SPH_C32(0xb15d0000), SPH_C32(0x7fd004e0), + SPH_C32(0x78a26138), SPH_C32(0xd116c35d), SPH_C32(0xd256d489), + SPH_C32(0x4e6f74de) }, + { SPH_C32(0xb11f0000), SPH_C32(0x86b90000), SPH_C32(0x9e1b0000), + SPH_C32(0x13f20660), SPH_C32(0x8e795b9a), SPH_C32(0xc40444d6), + SPH_C32(0x8906793b), SPH_C32(0xc2e32970), SPH_C32(0x44f40000), + SPH_C32(0x2e100000), SPH_C32(0xf4df0000), SPH_C32(0x9e5d0420), + SPH_C32(0x43cf6709), SPH_C32(0x13fb95c4), SPH_C32(0x19b62a95), + SPH_C32(0x18c8c541) }, + { SPH_C32(0xa7f20000), SPH_C32(0x93d10000), SPH_C32(0x73cc0000), + SPH_C32(0x21af0440), SPH_C32(0x6d756d13), SPH_C32(0x9e4ea295), + SPH_C32(0x6a738193), SPH_C32(0x431ed078), SPH_C32(0xa2dc0000), + SPH_C32(0x625b0000), SPH_C32(0x5c8a0000), SPH_C32(0x4d8d06c0), + SPH_C32(0x9bae57b1), SPH_C32(0x8b5c251e), SPH_C32(0x31232c21), + SPH_C32(0xcf928dd6) }, + { SPH_C32(0x41da0000), SPH_C32(0xdf9a0000), SPH_C32(0xdb990000), + SPH_C32(0xf27f06a0), SPH_C32(0xb5145dab), SPH_C32(0x06e9124f), + SPH_C32(0x42e68727), SPH_C32(0x944498ef), SPH_C32(0x52190000), + SPH_C32(0x3b780000), SPH_C32(0x19080000), SPH_C32(0xac000600), + SPH_C32(0xa0c35180), SPH_C32(0x49b17387), SPH_C32(0xfac3d23d), + SPH_C32(0x99353c49) }, + { SPH_C32(0x02f20000), SPH_C32(0xa2810000), SPH_C32(0x873f0000), + SPH_C32(0xe36c7800), SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), + SPH_C32(0xc4c23237), SPH_C32(0x7f32259e), SPH_C32(0xbadd0000), + SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), SPH_C32(0xf7282800), + SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), SPH_C32(0xea5a8d14), + SPH_C32(0x2a2c18f0) }, + { SPH_C32(0xe4da0000), SPH_C32(0xeeca0000), SPH_C32(0x2f6a0000), + SPH_C32(0x30bc7ae0), SPH_C32(0xc67c4457), SPH_C32(0x9f9a9b0c), + SPH_C32(0xec573483), SPH_C32(0xa8686d09), SPH_C32(0x4a180000), + SPH_C32(0x4a8e0000), SPH_C32(0xf2650000), SPH_C32(0x16a528c0), + SPH_C32(0xe428127c), SPH_C32(0xf4f795a3), SPH_C32(0x21ba7308), + SPH_C32(0x7c8ba96f) }, + { SPH_C32(0xf2370000), SPH_C32(0xfba20000), SPH_C32(0xc2bd0000), + SPH_C32(0x02e178c0), SPH_C32(0x257072de), SPH_C32(0xc5d07d4f), + SPH_C32(0x0f22cc2b), SPH_C32(0x29959401), SPH_C32(0xac300000), + SPH_C32(0x06c50000), SPH_C32(0x5a300000), SPH_C32(0xc5752a20), + SPH_C32(0x3c4922c4), SPH_C32(0x6c502579), SPH_C32(0x092f75bc), + SPH_C32(0xabd1e1f8) }, + { SPH_C32(0x141f0000), SPH_C32(0xb7e90000), SPH_C32(0x6ae80000), + SPH_C32(0xd1317a20), SPH_C32(0xfd114266), SPH_C32(0x5d77cd95), + SPH_C32(0x27b7ca9f), SPH_C32(0xfecfdc96), SPH_C32(0x5cf50000), + SPH_C32(0x5fe60000), SPH_C32(0x1fb20000), SPH_C32(0x24f82ae0), + SPH_C32(0x072424f5), SPH_C32(0xaebd73e0), SPH_C32(0xc2cf8ba0), + SPH_C32(0xfd765067) }, + { SPH_C32(0xb6c30000), SPH_C32(0xd5b20000), SPH_C32(0x36620000), + SPH_C32(0x9cbc7ce0), SPH_C32(0x66bf15d7), SPH_C32(0xd62be88b), + SPH_C32(0x1694e6be), SPH_C32(0x315d5140), SPH_C32(0x59db0000), + SPH_C32(0xae6c0000), SPH_C32(0x30f40000), SPH_C32(0x48da2860), + SPH_C32(0xf1ff1e57), SPH_C32(0xbbaff46b), SPH_C32(0x999f2612), + SPH_C32(0x71fa0dc9) }, + { SPH_C32(0x50eb0000), SPH_C32(0x99f90000), SPH_C32(0x9e370000), + SPH_C32(0x4f6c7e00), SPH_C32(0xbede256f), SPH_C32(0x4e8c5851), + SPH_C32(0x3e01e00a), SPH_C32(0xe60719d7), SPH_C32(0xa91e0000), + SPH_C32(0xf74f0000), SPH_C32(0x75760000), SPH_C32(0xa95728a0), + SPH_C32(0xca921866), SPH_C32(0x7942a2f2), SPH_C32(0x527fd80e), + SPH_C32(0x275dbc56) }, + { SPH_C32(0x46060000), SPH_C32(0x8c910000), SPH_C32(0x73e00000), + SPH_C32(0x7d317c20), SPH_C32(0x5dd213e6), SPH_C32(0x14c6be12), + SPH_C32(0xdd7418a2), SPH_C32(0x67fae0df), SPH_C32(0x4f360000), + SPH_C32(0xbb040000), SPH_C32(0xdd230000), SPH_C32(0x7a872a40), + SPH_C32(0x12f328de), SPH_C32(0xe1e51228), SPH_C32(0x7aeadeba), + SPH_C32(0xf007f4c1) }, + { SPH_C32(0xa02e0000), SPH_C32(0xc0da0000), SPH_C32(0xdbb50000), + SPH_C32(0xaee17ec0), SPH_C32(0x85b3235e), SPH_C32(0x8c610ec8), + SPH_C32(0xf5e11e16), SPH_C32(0xb0a0a848), SPH_C32(0xbff30000), + SPH_C32(0xe2270000), SPH_C32(0x98a10000), SPH_C32(0x9b0a2a80), + SPH_C32(0x299e2eef), SPH_C32(0x230844b1), SPH_C32(0xb10a20a6), + SPH_C32(0xa6a0455e) }, + { SPH_C32(0xe1f40000), SPH_C32(0x1f400000), SPH_C32(0x002c0000), + SPH_C32(0x5c9e7860), SPH_C32(0x30a77ef5), SPH_C32(0x8a881c87), + SPH_C32(0xb7079931), SPH_C32(0x24e430a7), SPH_C32(0xedea0000), + SPH_C32(0xd95f0000), SPH_C32(0x81a90000), SPH_C32(0x370a2c80), + SPH_C32(0x895d7f6f), SPH_C32(0x6ab93736), SPH_C32(0x4bc9f29b), + SPH_C32(0x3f957917) }, + { SPH_C32(0x07dc0000), SPH_C32(0x530b0000), SPH_C32(0xa8790000), + SPH_C32(0x8f4e7a80), SPH_C32(0xe8c64e4d), SPH_C32(0x122fac5d), + SPH_C32(0x9f929f85), SPH_C32(0xf3be7830), SPH_C32(0x1d2f0000), + SPH_C32(0x807c0000), SPH_C32(0xc42b0000), SPH_C32(0xd6872c40), + SPH_C32(0xb230795e), SPH_C32(0xa85461af), SPH_C32(0x80290c87), + SPH_C32(0x6932c888) }, + { SPH_C32(0x11310000), SPH_C32(0x46630000), SPH_C32(0x45ae0000), + SPH_C32(0xbd1378a0), SPH_C32(0x0bca78c4), SPH_C32(0x48654a1e), + SPH_C32(0x7ce7672d), SPH_C32(0x72438138), SPH_C32(0xfb070000), + SPH_C32(0xcc370000), SPH_C32(0x6c7e0000), SPH_C32(0x05572ea0), + SPH_C32(0x6a5149e6), SPH_C32(0x30f3d175), SPH_C32(0xa8bc0a33), + SPH_C32(0xbe68801f) }, + { SPH_C32(0xf7190000), SPH_C32(0x0a280000), SPH_C32(0xedfb0000), + SPH_C32(0x6ec37a40), SPH_C32(0xd3ab487c), SPH_C32(0xd0c2fac4), + SPH_C32(0x54726199), SPH_C32(0xa519c9af), SPH_C32(0x0bc20000), + SPH_C32(0x95140000), SPH_C32(0x29fc0000), SPH_C32(0xe4da2e60), + SPH_C32(0x513c4fd7), SPH_C32(0xf21e87ec), SPH_C32(0x635cf42f), + SPH_C32(0xe8cf3180) }, + { SPH_C32(0x55c50000), SPH_C32(0x68730000), SPH_C32(0xb1710000), + SPH_C32(0x234e7c80), SPH_C32(0x48051fcd), SPH_C32(0x5b9edfda), + SPH_C32(0x65514db8), SPH_C32(0x6a8b4479), SPH_C32(0x0eec0000), + SPH_C32(0x649e0000), SPH_C32(0x06ba0000), SPH_C32(0x88f82ce0), + SPH_C32(0xa7e77575), SPH_C32(0xe70c0067), SPH_C32(0x380c599d), + SPH_C32(0x64436c2e) }, + { SPH_C32(0xb3ed0000), SPH_C32(0x24380000), SPH_C32(0x19240000), + SPH_C32(0xf09e7e60), SPH_C32(0x90642f75), SPH_C32(0xc3396f00), + SPH_C32(0x4dc44b0c), SPH_C32(0xbdd10cee), SPH_C32(0xfe290000), + SPH_C32(0x3dbd0000), SPH_C32(0x43380000), SPH_C32(0x69752c20), + SPH_C32(0x9c8a7344), SPH_C32(0x25e156fe), SPH_C32(0xf3eca781), + SPH_C32(0x32e4ddb1) }, + { SPH_C32(0xa5000000), SPH_C32(0x31500000), SPH_C32(0xf4f30000), + SPH_C32(0xc2c37c40), SPH_C32(0x736819fc), SPH_C32(0x99738943), + SPH_C32(0xaeb1b3a4), SPH_C32(0x3c2cf5e6), SPH_C32(0x18010000), + SPH_C32(0x71f60000), SPH_C32(0xeb6d0000), SPH_C32(0xbaa52ec0), + SPH_C32(0x44eb43fc), SPH_C32(0xbd46e624), SPH_C32(0xdb79a135), + SPH_C32(0xe5be9526) }, + { SPH_C32(0x43280000), SPH_C32(0x7d1b0000), SPH_C32(0x5ca60000), + SPH_C32(0x11137ea0), SPH_C32(0xab092944), SPH_C32(0x01d43999), + SPH_C32(0x8624b510), SPH_C32(0xeb76bd71), SPH_C32(0xe8c40000), + SPH_C32(0x28d50000), SPH_C32(0xaeef0000), SPH_C32(0x5b282e00), + SPH_C32(0x7f8645cd), SPH_C32(0x7fabb0bd), SPH_C32(0x10995f29), + SPH_C32(0xb31924b9) }, + { SPH_C32(0xbadd0000), SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), + SPH_C32(0xf7282800), SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), + SPH_C32(0xea5a8d14), SPH_C32(0x2a2c18f0), SPH_C32(0xb82f0000), + SPH_C32(0xb12c0000), SPH_C32(0x30d80000), SPH_C32(0x14445000), + SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), SPH_C32(0x2e98bf23), + SPH_C32(0x551e3d6e) }, + { SPH_C32(0x5cf50000), SPH_C32(0x5fe60000), SPH_C32(0x1fb20000), + SPH_C32(0x24f82ae0), SPH_C32(0x072424f5), SPH_C32(0xaebd73e0), + SPH_C32(0xc2cf8ba0), SPH_C32(0xfd765067), SPH_C32(0x48ea0000), + SPH_C32(0xe80f0000), SPH_C32(0x755a0000), SPH_C32(0xf5c950c0), + SPH_C32(0xfa356693), SPH_C32(0xf3cabe75), SPH_C32(0xe578413f), + SPH_C32(0x03b98cf1) }, + { SPH_C32(0x4a180000), SPH_C32(0x4a8e0000), SPH_C32(0xf2650000), + SPH_C32(0x16a528c0), SPH_C32(0xe428127c), SPH_C32(0xf4f795a3), + SPH_C32(0x21ba7308), SPH_C32(0x7c8ba96f), SPH_C32(0xaec20000), + SPH_C32(0xa4440000), SPH_C32(0xdd0f0000), SPH_C32(0x26195220), + SPH_C32(0x2254562b), SPH_C32(0x6b6d0eaf), SPH_C32(0xcded478b), + SPH_C32(0xd4e3c466) }, + { SPH_C32(0xac300000), SPH_C32(0x06c50000), SPH_C32(0x5a300000), + SPH_C32(0xc5752a20), SPH_C32(0x3c4922c4), SPH_C32(0x6c502579), + SPH_C32(0x092f75bc), SPH_C32(0xabd1e1f8), SPH_C32(0x5e070000), + SPH_C32(0xfd670000), SPH_C32(0x988d0000), SPH_C32(0xc79452e0), + SPH_C32(0x1939501a), SPH_C32(0xa9805836), SPH_C32(0x060db997), + SPH_C32(0x824475f9) }, + { SPH_C32(0x0eec0000), SPH_C32(0x649e0000), SPH_C32(0x06ba0000), + SPH_C32(0x88f82ce0), SPH_C32(0xa7e77575), SPH_C32(0xe70c0067), + SPH_C32(0x380c599d), SPH_C32(0x64436c2e), SPH_C32(0x5b290000), + SPH_C32(0x0ced0000), SPH_C32(0xb7cb0000), SPH_C32(0xabb65060), + SPH_C32(0xefe26ab8), SPH_C32(0xbc92dfbd), SPH_C32(0x5d5d1425), + SPH_C32(0x0ec82857) }, + { SPH_C32(0xe8c40000), SPH_C32(0x28d50000), SPH_C32(0xaeef0000), + SPH_C32(0x5b282e00), SPH_C32(0x7f8645cd), SPH_C32(0x7fabb0bd), + SPH_C32(0x10995f29), SPH_C32(0xb31924b9), SPH_C32(0xabec0000), + SPH_C32(0x55ce0000), SPH_C32(0xf2490000), SPH_C32(0x4a3b50a0), + SPH_C32(0xd48f6c89), SPH_C32(0x7e7f8924), SPH_C32(0x96bdea39), + SPH_C32(0x586f99c8) }, + { SPH_C32(0xfe290000), SPH_C32(0x3dbd0000), SPH_C32(0x43380000), + SPH_C32(0x69752c20), SPH_C32(0x9c8a7344), SPH_C32(0x25e156fe), + SPH_C32(0xf3eca781), SPH_C32(0x32e4ddb1), SPH_C32(0x4dc40000), + SPH_C32(0x19850000), SPH_C32(0x5a1c0000), SPH_C32(0x99eb5240), + SPH_C32(0x0cee5c31), SPH_C32(0xe6d839fe), SPH_C32(0xbe28ec8d), + SPH_C32(0x8f35d15f) }, + { SPH_C32(0x18010000), SPH_C32(0x71f60000), SPH_C32(0xeb6d0000), + SPH_C32(0xbaa52ec0), SPH_C32(0x44eb43fc), SPH_C32(0xbd46e624), + SPH_C32(0xdb79a135), SPH_C32(0xe5be9526), SPH_C32(0xbd010000), + SPH_C32(0x40a60000), SPH_C32(0x1f9e0000), SPH_C32(0x78665280), + SPH_C32(0x37835a00), SPH_C32(0x24356f67), SPH_C32(0x75c81291), + SPH_C32(0xd99260c0) }, + { SPH_C32(0x59db0000), SPH_C32(0xae6c0000), SPH_C32(0x30f40000), + SPH_C32(0x48da2860), SPH_C32(0xf1ff1e57), SPH_C32(0xbbaff46b), + SPH_C32(0x999f2612), SPH_C32(0x71fa0dc9), SPH_C32(0xef180000), + SPH_C32(0x7bde0000), SPH_C32(0x06960000), SPH_C32(0xd4665480), + SPH_C32(0x97400b80), SPH_C32(0x6d841ce0), SPH_C32(0x8f0bc0ac), + SPH_C32(0x40a75c89) }, + { SPH_C32(0xbff30000), SPH_C32(0xe2270000), SPH_C32(0x98a10000), + SPH_C32(0x9b0a2a80), SPH_C32(0x299e2eef), SPH_C32(0x230844b1), + SPH_C32(0xb10a20a6), SPH_C32(0xa6a0455e), SPH_C32(0x1fdd0000), + SPH_C32(0x22fd0000), SPH_C32(0x43140000), SPH_C32(0x35eb5440), + SPH_C32(0xac2d0db1), SPH_C32(0xaf694a79), SPH_C32(0x44eb3eb0), + SPH_C32(0x1600ed16) }, + { SPH_C32(0xa91e0000), SPH_C32(0xf74f0000), SPH_C32(0x75760000), + SPH_C32(0xa95728a0), SPH_C32(0xca921866), SPH_C32(0x7942a2f2), + SPH_C32(0x527fd80e), SPH_C32(0x275dbc56), SPH_C32(0xf9f50000), + SPH_C32(0x6eb60000), SPH_C32(0xeb410000), SPH_C32(0xe63b56a0), + SPH_C32(0x744c3d09), SPH_C32(0x37cefaa3), SPH_C32(0x6c7e3804), + SPH_C32(0xc15aa581) }, + { SPH_C32(0x4f360000), SPH_C32(0xbb040000), SPH_C32(0xdd230000), + SPH_C32(0x7a872a40), SPH_C32(0x12f328de), SPH_C32(0xe1e51228), + SPH_C32(0x7aeadeba), SPH_C32(0xf007f4c1), SPH_C32(0x09300000), + SPH_C32(0x37950000), SPH_C32(0xaec30000), SPH_C32(0x07b65660), + SPH_C32(0x4f213b38), SPH_C32(0xf523ac3a), SPH_C32(0xa79ec618), + SPH_C32(0x97fd141e) }, + { SPH_C32(0xedea0000), SPH_C32(0xd95f0000), SPH_C32(0x81a90000), + SPH_C32(0x370a2c80), SPH_C32(0x895d7f6f), SPH_C32(0x6ab93736), + SPH_C32(0x4bc9f29b), SPH_C32(0x3f957917), SPH_C32(0x0c1e0000), + SPH_C32(0xc61f0000), SPH_C32(0x81850000), SPH_C32(0x6b9454e0), + SPH_C32(0xb9fa019a), SPH_C32(0xe0312bb1), SPH_C32(0xfcce6baa), + SPH_C32(0x1b7149b0) }, + { SPH_C32(0x0bc20000), SPH_C32(0x95140000), SPH_C32(0x29fc0000), + SPH_C32(0xe4da2e60), SPH_C32(0x513c4fd7), SPH_C32(0xf21e87ec), + SPH_C32(0x635cf42f), SPH_C32(0xe8cf3180), SPH_C32(0xfcdb0000), + SPH_C32(0x9f3c0000), SPH_C32(0xc4070000), SPH_C32(0x8a195420), + SPH_C32(0x829707ab), SPH_C32(0x22dc7d28), SPH_C32(0x372e95b6), + SPH_C32(0x4dd6f82f) }, + { SPH_C32(0x1d2f0000), SPH_C32(0x807c0000), SPH_C32(0xc42b0000), + SPH_C32(0xd6872c40), SPH_C32(0xb230795e), SPH_C32(0xa85461af), + SPH_C32(0x80290c87), SPH_C32(0x6932c888), SPH_C32(0x1af30000), + SPH_C32(0xd3770000), SPH_C32(0x6c520000), SPH_C32(0x59c956c0), + SPH_C32(0x5af63713), SPH_C32(0xba7bcdf2), SPH_C32(0x1fbb9302), + SPH_C32(0x9a8cb0b8) }, + { SPH_C32(0xfb070000), SPH_C32(0xcc370000), SPH_C32(0x6c7e0000), + SPH_C32(0x05572ea0), SPH_C32(0x6a5149e6), SPH_C32(0x30f3d175), + SPH_C32(0xa8bc0a33), SPH_C32(0xbe68801f), SPH_C32(0xea360000), + SPH_C32(0x8a540000), SPH_C32(0x29d00000), SPH_C32(0xb8445600), + SPH_C32(0x619b3122), SPH_C32(0x78969b6b), SPH_C32(0xd45b6d1e), + SPH_C32(0xcc2b0127) }, + { SPH_C32(0xb82f0000), SPH_C32(0xb12c0000), SPH_C32(0x30d80000), + SPH_C32(0x14445000), SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), + SPH_C32(0x2e98bf23), SPH_C32(0x551e3d6e), SPH_C32(0x02f20000), + SPH_C32(0xa2810000), SPH_C32(0x873f0000), SPH_C32(0xe36c7800), + SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), SPH_C32(0xc4c23237), + SPH_C32(0x7f32259e) }, + { SPH_C32(0x5e070000), SPH_C32(0xfd670000), SPH_C32(0x988d0000), + SPH_C32(0xc79452e0), SPH_C32(0x1939501a), SPH_C32(0xa9805836), + SPH_C32(0x060db997), SPH_C32(0x824475f9), SPH_C32(0xf2370000), + SPH_C32(0xfba20000), SPH_C32(0xc2bd0000), SPH_C32(0x02e178c0), + SPH_C32(0x257072de), SPH_C32(0xc5d07d4f), SPH_C32(0x0f22cc2b), + SPH_C32(0x29959401) }, + { SPH_C32(0x48ea0000), SPH_C32(0xe80f0000), SPH_C32(0x755a0000), + SPH_C32(0xf5c950c0), SPH_C32(0xfa356693), SPH_C32(0xf3cabe75), + SPH_C32(0xe578413f), SPH_C32(0x03b98cf1), SPH_C32(0x141f0000), + SPH_C32(0xb7e90000), SPH_C32(0x6ae80000), SPH_C32(0xd1317a20), + SPH_C32(0xfd114266), SPH_C32(0x5d77cd95), SPH_C32(0x27b7ca9f), + SPH_C32(0xfecfdc96) }, + { SPH_C32(0xaec20000), SPH_C32(0xa4440000), SPH_C32(0xdd0f0000), + SPH_C32(0x26195220), SPH_C32(0x2254562b), SPH_C32(0x6b6d0eaf), + SPH_C32(0xcded478b), SPH_C32(0xd4e3c466), SPH_C32(0xe4da0000), + SPH_C32(0xeeca0000), SPH_C32(0x2f6a0000), SPH_C32(0x30bc7ae0), + SPH_C32(0xc67c4457), SPH_C32(0x9f9a9b0c), SPH_C32(0xec573483), + SPH_C32(0xa8686d09) }, + { SPH_C32(0x0c1e0000), SPH_C32(0xc61f0000), SPH_C32(0x81850000), + SPH_C32(0x6b9454e0), SPH_C32(0xb9fa019a), SPH_C32(0xe0312bb1), + SPH_C32(0xfcce6baa), SPH_C32(0x1b7149b0), SPH_C32(0xe1f40000), + SPH_C32(0x1f400000), SPH_C32(0x002c0000), SPH_C32(0x5c9e7860), + SPH_C32(0x30a77ef5), SPH_C32(0x8a881c87), SPH_C32(0xb7079931), + SPH_C32(0x24e430a7) }, + { SPH_C32(0xea360000), SPH_C32(0x8a540000), SPH_C32(0x29d00000), + SPH_C32(0xb8445600), SPH_C32(0x619b3122), SPH_C32(0x78969b6b), + SPH_C32(0xd45b6d1e), SPH_C32(0xcc2b0127), SPH_C32(0x11310000), + SPH_C32(0x46630000), SPH_C32(0x45ae0000), SPH_C32(0xbd1378a0), + SPH_C32(0x0bca78c4), SPH_C32(0x48654a1e), SPH_C32(0x7ce7672d), + SPH_C32(0x72438138) }, + { SPH_C32(0xfcdb0000), SPH_C32(0x9f3c0000), SPH_C32(0xc4070000), + SPH_C32(0x8a195420), SPH_C32(0x829707ab), SPH_C32(0x22dc7d28), + SPH_C32(0x372e95b6), SPH_C32(0x4dd6f82f), SPH_C32(0xf7190000), + SPH_C32(0x0a280000), SPH_C32(0xedfb0000), SPH_C32(0x6ec37a40), + SPH_C32(0xd3ab487c), SPH_C32(0xd0c2fac4), SPH_C32(0x54726199), + SPH_C32(0xa519c9af) }, + { SPH_C32(0x1af30000), SPH_C32(0xd3770000), SPH_C32(0x6c520000), + SPH_C32(0x59c956c0), SPH_C32(0x5af63713), SPH_C32(0xba7bcdf2), + SPH_C32(0x1fbb9302), SPH_C32(0x9a8cb0b8), SPH_C32(0x07dc0000), + SPH_C32(0x530b0000), SPH_C32(0xa8790000), SPH_C32(0x8f4e7a80), + SPH_C32(0xe8c64e4d), SPH_C32(0x122fac5d), SPH_C32(0x9f929f85), + SPH_C32(0xf3be7830) }, + { SPH_C32(0x5b290000), SPH_C32(0x0ced0000), SPH_C32(0xb7cb0000), + SPH_C32(0xabb65060), SPH_C32(0xefe26ab8), SPH_C32(0xbc92dfbd), + SPH_C32(0x5d5d1425), SPH_C32(0x0ec82857), SPH_C32(0x55c50000), + SPH_C32(0x68730000), SPH_C32(0xb1710000), SPH_C32(0x234e7c80), + SPH_C32(0x48051fcd), SPH_C32(0x5b9edfda), SPH_C32(0x65514db8), + SPH_C32(0x6a8b4479) }, + { SPH_C32(0xbd010000), SPH_C32(0x40a60000), SPH_C32(0x1f9e0000), + SPH_C32(0x78665280), SPH_C32(0x37835a00), SPH_C32(0x24356f67), + SPH_C32(0x75c81291), SPH_C32(0xd99260c0), SPH_C32(0xa5000000), + SPH_C32(0x31500000), SPH_C32(0xf4f30000), SPH_C32(0xc2c37c40), + SPH_C32(0x736819fc), SPH_C32(0x99738943), SPH_C32(0xaeb1b3a4), + SPH_C32(0x3c2cf5e6) }, + { SPH_C32(0xabec0000), SPH_C32(0x55ce0000), SPH_C32(0xf2490000), + SPH_C32(0x4a3b50a0), SPH_C32(0xd48f6c89), SPH_C32(0x7e7f8924), + SPH_C32(0x96bdea39), SPH_C32(0x586f99c8), SPH_C32(0x43280000), + SPH_C32(0x7d1b0000), SPH_C32(0x5ca60000), SPH_C32(0x11137ea0), + SPH_C32(0xab092944), SPH_C32(0x01d43999), SPH_C32(0x8624b510), + SPH_C32(0xeb76bd71) }, + { SPH_C32(0x4dc40000), SPH_C32(0x19850000), SPH_C32(0x5a1c0000), + SPH_C32(0x99eb5240), SPH_C32(0x0cee5c31), SPH_C32(0xe6d839fe), + SPH_C32(0xbe28ec8d), SPH_C32(0x8f35d15f), SPH_C32(0xb3ed0000), + SPH_C32(0x24380000), SPH_C32(0x19240000), SPH_C32(0xf09e7e60), + SPH_C32(0x90642f75), SPH_C32(0xc3396f00), SPH_C32(0x4dc44b0c), + SPH_C32(0xbdd10cee) }, + { SPH_C32(0xef180000), SPH_C32(0x7bde0000), SPH_C32(0x06960000), + SPH_C32(0xd4665480), SPH_C32(0x97400b80), SPH_C32(0x6d841ce0), + SPH_C32(0x8f0bc0ac), SPH_C32(0x40a75c89), SPH_C32(0xb6c30000), + SPH_C32(0xd5b20000), SPH_C32(0x36620000), SPH_C32(0x9cbc7ce0), + SPH_C32(0x66bf15d7), SPH_C32(0xd62be88b), SPH_C32(0x1694e6be), + SPH_C32(0x315d5140) }, + { SPH_C32(0x09300000), SPH_C32(0x37950000), SPH_C32(0xaec30000), + SPH_C32(0x07b65660), SPH_C32(0x4f213b38), SPH_C32(0xf523ac3a), + SPH_C32(0xa79ec618), SPH_C32(0x97fd141e), SPH_C32(0x46060000), + SPH_C32(0x8c910000), SPH_C32(0x73e00000), SPH_C32(0x7d317c20), + SPH_C32(0x5dd213e6), SPH_C32(0x14c6be12), SPH_C32(0xdd7418a2), + SPH_C32(0x67fae0df) }, + { SPH_C32(0x1fdd0000), SPH_C32(0x22fd0000), SPH_C32(0x43140000), + SPH_C32(0x35eb5440), SPH_C32(0xac2d0db1), SPH_C32(0xaf694a79), + SPH_C32(0x44eb3eb0), SPH_C32(0x1600ed16), SPH_C32(0xa02e0000), + SPH_C32(0xc0da0000), SPH_C32(0xdbb50000), SPH_C32(0xaee17ec0), + SPH_C32(0x85b3235e), SPH_C32(0x8c610ec8), SPH_C32(0xf5e11e16), + SPH_C32(0xb0a0a848) }, + { SPH_C32(0xf9f50000), SPH_C32(0x6eb60000), SPH_C32(0xeb410000), + SPH_C32(0xe63b56a0), SPH_C32(0x744c3d09), SPH_C32(0x37cefaa3), + SPH_C32(0x6c7e3804), SPH_C32(0xc15aa581), SPH_C32(0x50eb0000), + SPH_C32(0x99f90000), SPH_C32(0x9e370000), SPH_C32(0x4f6c7e00), + SPH_C32(0xbede256f), SPH_C32(0x4e8c5851), SPH_C32(0x3e01e00a), + SPH_C32(0xe60719d7) }, + { SPH_C32(0x1e6c0000), SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), + SPH_C32(0xbcb6b800), SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), + SPH_C32(0x6a0c1bc8), SPH_C32(0xb99dc2eb), SPH_C32(0x92560000), + SPH_C32(0x1eda0000), SPH_C32(0xea510000), SPH_C32(0xe8b13000), + SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), SPH_C32(0xb15c2254), + SPH_C32(0x33c5244f) }, + { SPH_C32(0xf8440000), SPH_C32(0x88090000), SPH_C32(0x227b0000), + SPH_C32(0x6f66bae0), SPH_C32(0xf425230e), SPH_C32(0x135a6300), + SPH_C32(0x42991d7c), SPH_C32(0x6ec78a7c), SPH_C32(0x62930000), + SPH_C32(0x47f90000), SPH_C32(0xafd30000), SPH_C32(0x093c30c0), + SPH_C32(0x92585094), SPH_C32(0x29163700), SPH_C32(0x7abcdc48), + SPH_C32(0x656295d0) }, + { SPH_C32(0xeea90000), SPH_C32(0x9d610000), SPH_C32(0xcfac0000), + SPH_C32(0x5d3bb8c0), SPH_C32(0x17291587), SPH_C32(0x49108543), + SPH_C32(0xa1ece5d4), SPH_C32(0xef3a7374), SPH_C32(0x84bb0000), + SPH_C32(0x0bb20000), SPH_C32(0x07860000), SPH_C32(0xdaec3220), + SPH_C32(0x4a39602c), SPH_C32(0xb1b187da), SPH_C32(0x5229dafc), + SPH_C32(0xb238dd47) }, + { SPH_C32(0x08810000), SPH_C32(0xd12a0000), SPH_C32(0x67f90000), + SPH_C32(0x8eebba20), SPH_C32(0xcf48253f), SPH_C32(0xd1b73599), + SPH_C32(0x8979e360), SPH_C32(0x38603be3), SPH_C32(0x747e0000), + SPH_C32(0x52910000), SPH_C32(0x42040000), SPH_C32(0x3b6132e0), + SPH_C32(0x7154661d), SPH_C32(0x735cd143), SPH_C32(0x99c924e0), + SPH_C32(0xe49f6cd8) }, + { SPH_C32(0xaa5d0000), SPH_C32(0xb3710000), SPH_C32(0x3b730000), + SPH_C32(0xc366bce0), SPH_C32(0x54e6728e), SPH_C32(0x5aeb1087), + SPH_C32(0xb85acf41), SPH_C32(0xf7f2b635), SPH_C32(0x71500000), + SPH_C32(0xa31b0000), SPH_C32(0x6d420000), SPH_C32(0x57433060), + SPH_C32(0x878f5cbf), SPH_C32(0x664e56c8), SPH_C32(0xc2998952), + SPH_C32(0x68133176) }, + { SPH_C32(0x4c750000), SPH_C32(0xff3a0000), SPH_C32(0x93260000), + SPH_C32(0x10b6be00), SPH_C32(0x8c874236), SPH_C32(0xc24ca05d), + SPH_C32(0x90cfc9f5), SPH_C32(0x20a8fea2), SPH_C32(0x81950000), + SPH_C32(0xfa380000), SPH_C32(0x28c00000), SPH_C32(0xb6ce30a0), + SPH_C32(0xbce25a8e), SPH_C32(0xa4a30051), SPH_C32(0x0979774e), + SPH_C32(0x3eb480e9) }, + { SPH_C32(0x5a980000), SPH_C32(0xea520000), SPH_C32(0x7ef10000), + SPH_C32(0x22ebbc20), SPH_C32(0x6f8b74bf), SPH_C32(0x9806461e), + SPH_C32(0x73ba315d), SPH_C32(0xa15507aa), SPH_C32(0x67bd0000), + SPH_C32(0xb6730000), SPH_C32(0x80950000), SPH_C32(0x651e3240), + SPH_C32(0x64836a36), SPH_C32(0x3c04b08b), SPH_C32(0x21ec71fa), + SPH_C32(0xe9eec87e) }, + { SPH_C32(0xbcb00000), SPH_C32(0xa6190000), SPH_C32(0xd6a40000), + SPH_C32(0xf13bbec0), SPH_C32(0xb7ea4407), SPH_C32(0x00a1f6c4), + SPH_C32(0x5b2f37e9), SPH_C32(0x760f4f3d), SPH_C32(0x97780000), + SPH_C32(0xef500000), SPH_C32(0xc5170000), SPH_C32(0x84933280), + SPH_C32(0x5fee6c07), SPH_C32(0xfee9e612), SPH_C32(0xea0c8fe6), + SPH_C32(0xbf4979e1) }, + { SPH_C32(0xfd6a0000), SPH_C32(0x79830000), SPH_C32(0x0d3d0000), + SPH_C32(0x0344b860), SPH_C32(0x02fe19ac), SPH_C32(0x0648e48b), + SPH_C32(0x19c9b0ce), SPH_C32(0xe24bd7d2), SPH_C32(0xc5610000), + SPH_C32(0xd4280000), SPH_C32(0xdc1f0000), SPH_C32(0x28933480), + SPH_C32(0xff2d3d87), SPH_C32(0xb7589595), SPH_C32(0x10cf5ddb), + SPH_C32(0x267c45a8) }, + { SPH_C32(0x1b420000), SPH_C32(0x35c80000), SPH_C32(0xa5680000), + SPH_C32(0xd094ba80), SPH_C32(0xda9f2914), SPH_C32(0x9eef5451), + SPH_C32(0x315cb67a), SPH_C32(0x35119f45), SPH_C32(0x35a40000), + SPH_C32(0x8d0b0000), SPH_C32(0x999d0000), SPH_C32(0xc91e3440), + SPH_C32(0xc4403bb6), SPH_C32(0x75b5c30c), SPH_C32(0xdb2fa3c7), + SPH_C32(0x70dbf437) }, + { SPH_C32(0x0daf0000), SPH_C32(0x20a00000), SPH_C32(0x48bf0000), + SPH_C32(0xe2c9b8a0), SPH_C32(0x39931f9d), SPH_C32(0xc4a5b212), + SPH_C32(0xd2294ed2), SPH_C32(0xb4ec664d), SPH_C32(0xd38c0000), + SPH_C32(0xc1400000), SPH_C32(0x31c80000), SPH_C32(0x1ace36a0), + SPH_C32(0x1c210b0e), SPH_C32(0xed1273d6), SPH_C32(0xf3baa573), + SPH_C32(0xa781bca0) }, + { SPH_C32(0xeb870000), SPH_C32(0x6ceb0000), SPH_C32(0xe0ea0000), + SPH_C32(0x3119ba40), SPH_C32(0xe1f22f25), SPH_C32(0x5c0202c8), + SPH_C32(0xfabc4866), SPH_C32(0x63b62eda), SPH_C32(0x23490000), + SPH_C32(0x98630000), SPH_C32(0x744a0000), SPH_C32(0xfb433660), + SPH_C32(0x274c0d3f), SPH_C32(0x2fff254f), SPH_C32(0x385a5b6f), + SPH_C32(0xf1260d3f) }, + { SPH_C32(0x495b0000), SPH_C32(0x0eb00000), SPH_C32(0xbc600000), + SPH_C32(0x7c94bc80), SPH_C32(0x7a5c7894), SPH_C32(0xd75e27d6), + SPH_C32(0xcb9f6447), SPH_C32(0xac24a30c), SPH_C32(0x26670000), + SPH_C32(0x69e90000), SPH_C32(0x5b0c0000), SPH_C32(0x976134e0), + SPH_C32(0xd197379d), SPH_C32(0x3aeda2c4), SPH_C32(0x630af6dd), + SPH_C32(0x7daa5091) }, + { SPH_C32(0xaf730000), SPH_C32(0x42fb0000), SPH_C32(0x14350000), + SPH_C32(0xaf44be60), SPH_C32(0xa23d482c), SPH_C32(0x4ff9970c), + SPH_C32(0xe30a62f3), SPH_C32(0x7b7eeb9b), SPH_C32(0xd6a20000), + SPH_C32(0x30ca0000), SPH_C32(0x1e8e0000), SPH_C32(0x76ec3420), + SPH_C32(0xeafa31ac), SPH_C32(0xf800f45d), SPH_C32(0xa8ea08c1), + SPH_C32(0x2b0de10e) }, + { SPH_C32(0xb99e0000), SPH_C32(0x57930000), SPH_C32(0xf9e20000), + SPH_C32(0x9d19bc40), SPH_C32(0x41317ea5), SPH_C32(0x15b3714f), + SPH_C32(0x007f9a5b), SPH_C32(0xfa831293), SPH_C32(0x308a0000), + SPH_C32(0x7c810000), SPH_C32(0xb6db0000), SPH_C32(0xa53c36c0), + SPH_C32(0x329b0114), SPH_C32(0x60a74487), SPH_C32(0x807f0e75), + SPH_C32(0xfc57a999) }, + { SPH_C32(0x5fb60000), SPH_C32(0x1bd80000), SPH_C32(0x51b70000), + SPH_C32(0x4ec9bea0), SPH_C32(0x99504e1d), SPH_C32(0x8d14c195), + SPH_C32(0x28ea9cef), SPH_C32(0x2dd95a04), SPH_C32(0xc04f0000), + SPH_C32(0x25a20000), SPH_C32(0xf3590000), SPH_C32(0x44b13600), + SPH_C32(0x09f60725), SPH_C32(0xa24a121e), SPH_C32(0x4b9ff069), + SPH_C32(0xaaf01806) }, + { SPH_C32(0x1c9e0000), SPH_C32(0x66c30000), SPH_C32(0x0d110000), + SPH_C32(0x5fdac000), SPH_C32(0x32596759), SPH_C32(0x8cc0f80c), + SPH_C32(0xaece29ff), SPH_C32(0xc6afe775), SPH_C32(0x288b0000), + SPH_C32(0x0d770000), SPH_C32(0x5db60000), SPH_C32(0x1f991800), + SPH_C32(0x767042e8), SPH_C32(0xdde1a2a3), SPH_C32(0x5b06af40), + SPH_C32(0x19e93cbf) }, + { SPH_C32(0xfab60000), SPH_C32(0x2a880000), SPH_C32(0xa5440000), + SPH_C32(0x8c0ac2e0), SPH_C32(0xea3857e1), SPH_C32(0x146748d6), + SPH_C32(0x865b2f4b), SPH_C32(0x11f5afe2), SPH_C32(0xd84e0000), + SPH_C32(0x54540000), SPH_C32(0x18340000), SPH_C32(0xfe1418c0), + SPH_C32(0x4d1d44d9), SPH_C32(0x1f0cf43a), SPH_C32(0x90e6515c), + SPH_C32(0x4f4e8d20) }, + { SPH_C32(0xec5b0000), SPH_C32(0x3fe00000), SPH_C32(0x48930000), + SPH_C32(0xbe57c0c0), SPH_C32(0x09346168), SPH_C32(0x4e2dae95), + SPH_C32(0x652ed7e3), SPH_C32(0x900856ea), SPH_C32(0x3e660000), + SPH_C32(0x181f0000), SPH_C32(0xb0610000), SPH_C32(0x2dc41a20), + SPH_C32(0x957c7461), SPH_C32(0x87ab44e0), SPH_C32(0xb87357e8), + SPH_C32(0x9814c5b7) }, + { SPH_C32(0x0a730000), SPH_C32(0x73ab0000), SPH_C32(0xe0c60000), + SPH_C32(0x6d87c220), SPH_C32(0xd15551d0), SPH_C32(0xd68a1e4f), + SPH_C32(0x4dbbd157), SPH_C32(0x47521e7d), SPH_C32(0xcea30000), + SPH_C32(0x413c0000), SPH_C32(0xf5e30000), SPH_C32(0xcc491ae0), + SPH_C32(0xae117250), SPH_C32(0x45461279), SPH_C32(0x7393a9f4), + SPH_C32(0xceb37428) }, + { SPH_C32(0xa8af0000), SPH_C32(0x11f00000), SPH_C32(0xbc4c0000), + SPH_C32(0x200ac4e0), SPH_C32(0x4afb0661), SPH_C32(0x5dd63b51), + SPH_C32(0x7c98fd76), SPH_C32(0x88c093ab), SPH_C32(0xcb8d0000), + SPH_C32(0xb0b60000), SPH_C32(0xdaa50000), SPH_C32(0xa06b1860), + SPH_C32(0x58ca48f2), SPH_C32(0x505495f2), SPH_C32(0x28c30446), + SPH_C32(0x423f2986) }, + { SPH_C32(0x4e870000), SPH_C32(0x5dbb0000), SPH_C32(0x14190000), + SPH_C32(0xf3dac600), SPH_C32(0x929a36d9), SPH_C32(0xc5718b8b), + SPH_C32(0x540dfbc2), SPH_C32(0x5f9adb3c), SPH_C32(0x3b480000), + SPH_C32(0xe9950000), SPH_C32(0x9f270000), SPH_C32(0x41e618a0), + SPH_C32(0x63a74ec3), SPH_C32(0x92b9c36b), SPH_C32(0xe323fa5a), + SPH_C32(0x14989819) }, + { SPH_C32(0x586a0000), SPH_C32(0x48d30000), SPH_C32(0xf9ce0000), + SPH_C32(0xc187c420), SPH_C32(0x71960050), SPH_C32(0x9f3b6dc8), + SPH_C32(0xb778036a), SPH_C32(0xde672234), SPH_C32(0xdd600000), + SPH_C32(0xa5de0000), SPH_C32(0x37720000), SPH_C32(0x92361a40), + SPH_C32(0xbbc67e7b), SPH_C32(0x0a1e73b1), SPH_C32(0xcbb6fcee), + SPH_C32(0xc3c2d08e) }, + { SPH_C32(0xbe420000), SPH_C32(0x04980000), SPH_C32(0x519b0000), + SPH_C32(0x1257c6c0), SPH_C32(0xa9f730e8), SPH_C32(0x079cdd12), + SPH_C32(0x9fed05de), SPH_C32(0x093d6aa3), SPH_C32(0x2da50000), + SPH_C32(0xfcfd0000), SPH_C32(0x72f00000), SPH_C32(0x73bb1a80), + SPH_C32(0x80ab784a), SPH_C32(0xc8f32528), SPH_C32(0x005602f2), + SPH_C32(0x95656111) }, + { SPH_C32(0xff980000), SPH_C32(0xdb020000), SPH_C32(0x8a020000), + SPH_C32(0xe028c060), SPH_C32(0x1ce36d43), SPH_C32(0x0175cf5d), + SPH_C32(0xdd0b82f9), SPH_C32(0x9d79f24c), SPH_C32(0x7fbc0000), + SPH_C32(0xc7850000), SPH_C32(0x6bf80000), SPH_C32(0xdfbb1c80), + SPH_C32(0x206829ca), SPH_C32(0x814256af), SPH_C32(0xfa95d0cf), + SPH_C32(0x0c505d58) }, + { SPH_C32(0x19b00000), SPH_C32(0x97490000), SPH_C32(0x22570000), + SPH_C32(0x33f8c280), SPH_C32(0xc4825dfb), SPH_C32(0x99d27f87), + SPH_C32(0xf59e844d), SPH_C32(0x4a23badb), SPH_C32(0x8f790000), + SPH_C32(0x9ea60000), SPH_C32(0x2e7a0000), SPH_C32(0x3e361c40), + SPH_C32(0x1b052ffb), SPH_C32(0x43af0036), SPH_C32(0x31752ed3), + SPH_C32(0x5af7ecc7) }, + { SPH_C32(0x0f5d0000), SPH_C32(0x82210000), SPH_C32(0xcf800000), + SPH_C32(0x01a5c0a0), SPH_C32(0x278e6b72), SPH_C32(0xc39899c4), + SPH_C32(0x16eb7ce5), SPH_C32(0xcbde43d3), SPH_C32(0x69510000), + SPH_C32(0xd2ed0000), SPH_C32(0x862f0000), SPH_C32(0xede61ea0), + SPH_C32(0xc3641f43), SPH_C32(0xdb08b0ec), SPH_C32(0x19e02867), + SPH_C32(0x8dada450) }, + { SPH_C32(0xe9750000), SPH_C32(0xce6a0000), SPH_C32(0x67d50000), + SPH_C32(0xd275c240), SPH_C32(0xffef5bca), SPH_C32(0x5b3f291e), + SPH_C32(0x3e7e7a51), SPH_C32(0x1c840b44), SPH_C32(0x99940000), + SPH_C32(0x8bce0000), SPH_C32(0xc3ad0000), SPH_C32(0x0c6b1e60), + SPH_C32(0xf8091972), SPH_C32(0x19e5e675), SPH_C32(0xd200d67b), + SPH_C32(0xdb0a15cf) }, + { SPH_C32(0x4ba90000), SPH_C32(0xac310000), SPH_C32(0x3b5f0000), + SPH_C32(0x9ff8c480), SPH_C32(0x64410c7b), SPH_C32(0xd0630c00), + SPH_C32(0x0f5d5670), SPH_C32(0xd3168692), SPH_C32(0x9cba0000), + SPH_C32(0x7a440000), SPH_C32(0xeceb0000), SPH_C32(0x60491ce0), + SPH_C32(0x0ed223d0), SPH_C32(0x0cf761fe), SPH_C32(0x89507bc9), + SPH_C32(0x57864861) }, + { SPH_C32(0xad810000), SPH_C32(0xe07a0000), SPH_C32(0x930a0000), + SPH_C32(0x4c28c660), SPH_C32(0xbc203cc3), SPH_C32(0x48c4bcda), + SPH_C32(0x27c850c4), SPH_C32(0x044cce05), SPH_C32(0x6c7f0000), + SPH_C32(0x23670000), SPH_C32(0xa9690000), SPH_C32(0x81c41c20), + SPH_C32(0x35bf25e1), SPH_C32(0xce1a3767), SPH_C32(0x42b085d5), + SPH_C32(0x0121f9fe) }, + { SPH_C32(0xbb6c0000), SPH_C32(0xf5120000), SPH_C32(0x7edd0000), + SPH_C32(0x7e75c440), SPH_C32(0x5f2c0a4a), SPH_C32(0x128e5a99), + SPH_C32(0xc4bda86c), SPH_C32(0x85b1370d), SPH_C32(0x8a570000), + SPH_C32(0x6f2c0000), SPH_C32(0x013c0000), SPH_C32(0x52141ec0), + SPH_C32(0xedde1559), SPH_C32(0x56bd87bd), SPH_C32(0x6a258361), + SPH_C32(0xd67bb169) }, + { SPH_C32(0x5d440000), SPH_C32(0xb9590000), SPH_C32(0xd6880000), + SPH_C32(0xada5c6a0), SPH_C32(0x874d3af2), SPH_C32(0x8a29ea43), + SPH_C32(0xec28aed8), SPH_C32(0x52eb7f9a), SPH_C32(0x7a920000), + SPH_C32(0x360f0000), SPH_C32(0x44be0000), SPH_C32(0xb3991e00), + SPH_C32(0xd6b31368), SPH_C32(0x9450d124), SPH_C32(0xa1c57d7d), + SPH_C32(0x80dc00f6) }, + { SPH_C32(0xa4b10000), SPH_C32(0xd7ef0000), SPH_C32(0x3dc90000), + SPH_C32(0x4b9e9000), SPH_C32(0xf30107fb), SPH_C32(0xbde710e0), + SPH_C32(0x805696dc), SPH_C32(0x93b1da1b), SPH_C32(0x2a790000), + SPH_C32(0xaff60000), SPH_C32(0xda890000), SPH_C32(0xfcf56000), + SPH_C32(0x686d3607), SPH_C32(0xdadc8975), SPH_C32(0x9fc49d77), + SPH_C32(0x66db1921) }, + { SPH_C32(0x42990000), SPH_C32(0x9ba40000), SPH_C32(0x959c0000), + SPH_C32(0x984e92e0), SPH_C32(0x2b603743), SPH_C32(0x2540a03a), + SPH_C32(0xa8c39068), SPH_C32(0x44eb928c), SPH_C32(0xdabc0000), + SPH_C32(0xf6d50000), SPH_C32(0x9f0b0000), SPH_C32(0x1d7860c0), + SPH_C32(0x53003036), SPH_C32(0x1831dfec), SPH_C32(0x5424636b), + SPH_C32(0x307ca8be) }, + { SPH_C32(0x54740000), SPH_C32(0x8ecc0000), SPH_C32(0x784b0000), + SPH_C32(0xaa1390c0), SPH_C32(0xc86c01ca), SPH_C32(0x7f0a4679), + SPH_C32(0x4bb668c0), SPH_C32(0xc5166b84), SPH_C32(0x3c940000), + SPH_C32(0xba9e0000), SPH_C32(0x375e0000), SPH_C32(0xcea86220), + SPH_C32(0x8b61008e), SPH_C32(0x80966f36), SPH_C32(0x7cb165df), + SPH_C32(0xe726e029) }, + { SPH_C32(0xb25c0000), SPH_C32(0xc2870000), SPH_C32(0xd01e0000), + SPH_C32(0x79c39220), SPH_C32(0x100d3172), SPH_C32(0xe7adf6a3), + SPH_C32(0x63236e74), SPH_C32(0x124c2313), SPH_C32(0xcc510000), + SPH_C32(0xe3bd0000), SPH_C32(0x72dc0000), SPH_C32(0x2f2562e0), + SPH_C32(0xb00c06bf), SPH_C32(0x427b39af), SPH_C32(0xb7519bc3), + SPH_C32(0xb18151b6) }, + { SPH_C32(0x10800000), SPH_C32(0xa0dc0000), SPH_C32(0x8c940000), + SPH_C32(0x344e94e0), SPH_C32(0x8ba366c3), SPH_C32(0x6cf1d3bd), + SPH_C32(0x52004255), SPH_C32(0xdddeaec5), SPH_C32(0xc97f0000), + SPH_C32(0x12370000), SPH_C32(0x5d9a0000), SPH_C32(0x43076060), + SPH_C32(0x46d73c1d), SPH_C32(0x5769be24), SPH_C32(0xec013671), + SPH_C32(0x3d0d0c18) }, + { SPH_C32(0xf6a80000), SPH_C32(0xec970000), SPH_C32(0x24c10000), + SPH_C32(0xe79e9600), SPH_C32(0x53c2567b), SPH_C32(0xf4566367), + SPH_C32(0x7a9544e1), SPH_C32(0x0a84e652), SPH_C32(0x39ba0000), + SPH_C32(0x4b140000), SPH_C32(0x18180000), SPH_C32(0xa28a60a0), + SPH_C32(0x7dba3a2c), SPH_C32(0x9584e8bd), SPH_C32(0x27e1c86d), + SPH_C32(0x6baabd87) }, + { SPH_C32(0xe0450000), SPH_C32(0xf9ff0000), SPH_C32(0xc9160000), + SPH_C32(0xd5c39420), SPH_C32(0xb0ce60f2), SPH_C32(0xae1c8524), + SPH_C32(0x99e0bc49), SPH_C32(0x8b791f5a), SPH_C32(0xdf920000), + SPH_C32(0x075f0000), SPH_C32(0xb04d0000), SPH_C32(0x715a6240), + SPH_C32(0xa5db0a94), SPH_C32(0x0d235867), SPH_C32(0x0f74ced9), + SPH_C32(0xbcf0f510) }, + { SPH_C32(0x066d0000), SPH_C32(0xb5b40000), SPH_C32(0x61430000), + SPH_C32(0x061396c0), SPH_C32(0x68af504a), SPH_C32(0x36bb35fe), + SPH_C32(0xb175bafd), SPH_C32(0x5c2357cd), SPH_C32(0x2f570000), + SPH_C32(0x5e7c0000), SPH_C32(0xf5cf0000), SPH_C32(0x90d76280), + SPH_C32(0x9eb60ca5), SPH_C32(0xcfce0efe), SPH_C32(0xc49430c5), + SPH_C32(0xea57448f) }, + { SPH_C32(0x47b70000), SPH_C32(0x6a2e0000), SPH_C32(0xbada0000), + SPH_C32(0xf46c9060), SPH_C32(0xddbb0de1), SPH_C32(0x305227b1), + SPH_C32(0xf3933dda), SPH_C32(0xc867cf22), SPH_C32(0x7d4e0000), + SPH_C32(0x65040000), SPH_C32(0xecc70000), SPH_C32(0x3cd76480), + SPH_C32(0x3e755d25), SPH_C32(0x867f7d79), SPH_C32(0x3e57e2f8), + SPH_C32(0x736278c6) }, + { SPH_C32(0xa19f0000), SPH_C32(0x26650000), SPH_C32(0x128f0000), + SPH_C32(0x27bc9280), SPH_C32(0x05da3d59), SPH_C32(0xa8f5976b), + SPH_C32(0xdb063b6e), SPH_C32(0x1f3d87b5), SPH_C32(0x8d8b0000), + SPH_C32(0x3c270000), SPH_C32(0xa9450000), SPH_C32(0xdd5a6440), + SPH_C32(0x05185b14), SPH_C32(0x44922be0), SPH_C32(0xf5b71ce4), + SPH_C32(0x25c5c959) }, + { SPH_C32(0xb7720000), SPH_C32(0x330d0000), SPH_C32(0xff580000), + SPH_C32(0x15e190a0), SPH_C32(0xe6d60bd0), SPH_C32(0xf2bf7128), + SPH_C32(0x3873c3c6), SPH_C32(0x9ec07ebd), SPH_C32(0x6ba30000), + SPH_C32(0x706c0000), SPH_C32(0x01100000), SPH_C32(0x0e8a66a0), + SPH_C32(0xdd796bac), SPH_C32(0xdc359b3a), SPH_C32(0xdd221a50), + SPH_C32(0xf29f81ce) }, + { SPH_C32(0x515a0000), SPH_C32(0x7f460000), SPH_C32(0x570d0000), + SPH_C32(0xc6319240), SPH_C32(0x3eb73b68), SPH_C32(0x6a18c1f2), + SPH_C32(0x10e6c572), SPH_C32(0x499a362a), SPH_C32(0x9b660000), + SPH_C32(0x294f0000), SPH_C32(0x44920000), SPH_C32(0xef076660), + SPH_C32(0xe6146d9d), SPH_C32(0x1ed8cda3), SPH_C32(0x16c2e44c), + SPH_C32(0xa4383051) }, + { SPH_C32(0xf3860000), SPH_C32(0x1d1d0000), SPH_C32(0x0b870000), + SPH_C32(0x8bbc9480), SPH_C32(0xa5196cd9), SPH_C32(0xe144e4ec), + SPH_C32(0x21c5e953), SPH_C32(0x8608bbfc), SPH_C32(0x9e480000), + SPH_C32(0xd8c50000), SPH_C32(0x6bd40000), SPH_C32(0x832564e0), + SPH_C32(0x10cf573f), SPH_C32(0x0bca4a28), SPH_C32(0x4d9249fe), + SPH_C32(0x28b46dff) }, + { SPH_C32(0x15ae0000), SPH_C32(0x51560000), SPH_C32(0xa3d20000), + SPH_C32(0x586c9660), SPH_C32(0x7d785c61), SPH_C32(0x79e35436), + SPH_C32(0x0950efe7), SPH_C32(0x5152f36b), SPH_C32(0x6e8d0000), + SPH_C32(0x81e60000), SPH_C32(0x2e560000), SPH_C32(0x62a86420), + SPH_C32(0x2ba2510e), SPH_C32(0xc9271cb1), SPH_C32(0x8672b7e2), + SPH_C32(0x7e13dc60) }, + { SPH_C32(0x03430000), SPH_C32(0x443e0000), SPH_C32(0x4e050000), + SPH_C32(0x6a319440), SPH_C32(0x9e746ae8), SPH_C32(0x23a9b275), + SPH_C32(0xea25174f), SPH_C32(0xd0af0a63), SPH_C32(0x88a50000), + SPH_C32(0xcdad0000), SPH_C32(0x86030000), SPH_C32(0xb17866c0), + SPH_C32(0xf3c361b6), SPH_C32(0x5180ac6b), SPH_C32(0xaee7b156), + SPH_C32(0xa94994f7) }, + { SPH_C32(0xe56b0000), SPH_C32(0x08750000), SPH_C32(0xe6500000), + SPH_C32(0xb9e196a0), SPH_C32(0x46155a50), SPH_C32(0xbb0e02af), + SPH_C32(0xc2b011fb), SPH_C32(0x07f542f4), SPH_C32(0x78600000), + SPH_C32(0x948e0000), SPH_C32(0xc3810000), SPH_C32(0x50f56600), + SPH_C32(0xc8ae6787), SPH_C32(0x936dfaf2), SPH_C32(0x65074f4a), + SPH_C32(0xffee2568) }, + { SPH_C32(0xa6430000), SPH_C32(0x756e0000), SPH_C32(0xbaf60000), + SPH_C32(0xa8f2e800), SPH_C32(0xed1c7314), SPH_C32(0xbada3b36), + SPH_C32(0x4494a4eb), SPH_C32(0xec83ff85), SPH_C32(0x90a40000), + SPH_C32(0xbc5b0000), SPH_C32(0x6d6e0000), SPH_C32(0x0bdd4800), + SPH_C32(0xb728224a), SPH_C32(0xecc64a4f), SPH_C32(0x759e1063), + SPH_C32(0x4cf701d1) }, + { SPH_C32(0x406b0000), SPH_C32(0x39250000), SPH_C32(0x12a30000), + SPH_C32(0x7b22eae0), SPH_C32(0x357d43ac), SPH_C32(0x227d8bec), + SPH_C32(0x6c01a25f), SPH_C32(0x3bd9b712), SPH_C32(0x60610000), + SPH_C32(0xe5780000), SPH_C32(0x28ec0000), SPH_C32(0xea5048c0), + SPH_C32(0x8c45247b), SPH_C32(0x2e2b1cd6), SPH_C32(0xbe7eee7f), + SPH_C32(0x1a50b04e) }, + { SPH_C32(0x56860000), SPH_C32(0x2c4d0000), SPH_C32(0xff740000), + SPH_C32(0x497fe8c0), SPH_C32(0xd6717525), SPH_C32(0x78376daf), + SPH_C32(0x8f745af7), SPH_C32(0xba244e1a), SPH_C32(0x86490000), + SPH_C32(0xa9330000), SPH_C32(0x80b90000), SPH_C32(0x39804a20), + SPH_C32(0x542414c3), SPH_C32(0xb68cac0c), SPH_C32(0x96ebe8cb), + SPH_C32(0xcd0af8d9) }, + { SPH_C32(0xb0ae0000), SPH_C32(0x60060000), SPH_C32(0x57210000), + SPH_C32(0x9aafea20), SPH_C32(0x0e10459d), SPH_C32(0xe090dd75), + SPH_C32(0xa7e15c43), SPH_C32(0x6d7e068d), SPH_C32(0x768c0000), + SPH_C32(0xf0100000), SPH_C32(0xc53b0000), SPH_C32(0xd80d4ae0), + SPH_C32(0x6f4912f2), SPH_C32(0x7461fa95), SPH_C32(0x5d0b16d7), + SPH_C32(0x9bad4946) }, + { SPH_C32(0x12720000), SPH_C32(0x025d0000), SPH_C32(0x0bab0000), + SPH_C32(0xd722ece0), SPH_C32(0x95be122c), SPH_C32(0x6bccf86b), + SPH_C32(0x96c27062), SPH_C32(0xa2ec8b5b), SPH_C32(0x73a20000), + SPH_C32(0x019a0000), SPH_C32(0xea7d0000), SPH_C32(0xb42f4860), + SPH_C32(0x99922850), SPH_C32(0x61737d1e), SPH_C32(0x065bbb65), + SPH_C32(0x172114e8) }, + { SPH_C32(0xf45a0000), SPH_C32(0x4e160000), SPH_C32(0xa3fe0000), + SPH_C32(0x04f2ee00), SPH_C32(0x4ddf2294), SPH_C32(0xf36b48b1), + SPH_C32(0xbe5776d6), SPH_C32(0x75b6c3cc), SPH_C32(0x83670000), + SPH_C32(0x58b90000), SPH_C32(0xafff0000), SPH_C32(0x55a248a0), + SPH_C32(0xa2ff2e61), SPH_C32(0xa39e2b87), SPH_C32(0xcdbb4579), + SPH_C32(0x4186a577) }, + { SPH_C32(0xe2b70000), SPH_C32(0x5b7e0000), SPH_C32(0x4e290000), + SPH_C32(0x36afec20), SPH_C32(0xaed3141d), SPH_C32(0xa921aef2), + SPH_C32(0x5d228e7e), SPH_C32(0xf44b3ac4), SPH_C32(0x654f0000), + SPH_C32(0x14f20000), SPH_C32(0x07aa0000), SPH_C32(0x86724a40), + SPH_C32(0x7a9e1ed9), SPH_C32(0x3b399b5d), SPH_C32(0xe52e43cd), + SPH_C32(0x96dcede0) }, + { SPH_C32(0x049f0000), SPH_C32(0x17350000), SPH_C32(0xe67c0000), + SPH_C32(0xe57feec0), SPH_C32(0x76b224a5), SPH_C32(0x31861e28), + SPH_C32(0x75b788ca), SPH_C32(0x23117253), SPH_C32(0x958a0000), + SPH_C32(0x4dd10000), SPH_C32(0x42280000), SPH_C32(0x67ff4a80), + SPH_C32(0x41f318e8), SPH_C32(0xf9d4cdc4), SPH_C32(0x2ecebdd1), + SPH_C32(0xc07b5c7f) }, + { SPH_C32(0x45450000), SPH_C32(0xc8af0000), SPH_C32(0x3de50000), + SPH_C32(0x1700e860), SPH_C32(0xc3a6790e), SPH_C32(0x376f0c67), + SPH_C32(0x37510fed), SPH_C32(0xb755eabc), SPH_C32(0xc7930000), + SPH_C32(0x76a90000), SPH_C32(0x5b200000), SPH_C32(0xcbff4c80), + SPH_C32(0xe1304968), SPH_C32(0xb065be43), SPH_C32(0xd40d6fec), + SPH_C32(0x594e6036) }, + { SPH_C32(0xa36d0000), SPH_C32(0x84e40000), SPH_C32(0x95b00000), + SPH_C32(0xc4d0ea80), SPH_C32(0x1bc749b6), SPH_C32(0xafc8bcbd), + SPH_C32(0x1fc40959), SPH_C32(0x600fa22b), SPH_C32(0x37560000), + SPH_C32(0x2f8a0000), SPH_C32(0x1ea20000), SPH_C32(0x2a724c40), + SPH_C32(0xda5d4f59), SPH_C32(0x7288e8da), SPH_C32(0x1fed91f0), + SPH_C32(0x0fe9d1a9) }, + { SPH_C32(0xb5800000), SPH_C32(0x918c0000), SPH_C32(0x78670000), + SPH_C32(0xf68de8a0), SPH_C32(0xf8cb7f3f), SPH_C32(0xf5825afe), + SPH_C32(0xfcb1f1f1), SPH_C32(0xe1f25b23), SPH_C32(0xd17e0000), + SPH_C32(0x63c10000), SPH_C32(0xb6f70000), SPH_C32(0xf9a24ea0), + SPH_C32(0x023c7fe1), SPH_C32(0xea2f5800), SPH_C32(0x37789744), + SPH_C32(0xd8b3993e) }, + { SPH_C32(0x53a80000), SPH_C32(0xddc70000), SPH_C32(0xd0320000), + SPH_C32(0x255dea40), SPH_C32(0x20aa4f87), SPH_C32(0x6d25ea24), + SPH_C32(0xd424f745), SPH_C32(0x36a813b4), SPH_C32(0x21bb0000), + SPH_C32(0x3ae20000), SPH_C32(0xf3750000), SPH_C32(0x182f4e60), + SPH_C32(0x395179d0), SPH_C32(0x28c20e99), SPH_C32(0xfc986958), + SPH_C32(0x8e1428a1) }, + { SPH_C32(0xf1740000), SPH_C32(0xbf9c0000), SPH_C32(0x8cb80000), + SPH_C32(0x68d0ec80), SPH_C32(0xbb041836), SPH_C32(0xe679cf3a), + SPH_C32(0xe507db64), SPH_C32(0xf93a9e62), SPH_C32(0x24950000), + SPH_C32(0xcb680000), SPH_C32(0xdc330000), SPH_C32(0x740d4ce0), + SPH_C32(0xcf8a4372), SPH_C32(0x3dd08912), SPH_C32(0xa7c8c4ea), + SPH_C32(0x0298750f) }, + { SPH_C32(0x175c0000), SPH_C32(0xf3d70000), SPH_C32(0x24ed0000), + SPH_C32(0xbb00ee60), SPH_C32(0x6365288e), SPH_C32(0x7ede7fe0), + SPH_C32(0xcd92ddd0), SPH_C32(0x2e60d6f5), SPH_C32(0xd4500000), + SPH_C32(0x924b0000), SPH_C32(0x99b10000), SPH_C32(0x95804c20), + SPH_C32(0xf4e74543), SPH_C32(0xff3ddf8b), SPH_C32(0x6c283af6), + SPH_C32(0x543fc490) }, + { SPH_C32(0x01b10000), SPH_C32(0xe6bf0000), SPH_C32(0xc93a0000), + SPH_C32(0x895dec40), SPH_C32(0x80691e07), SPH_C32(0x249499a3), + SPH_C32(0x2ee72578), SPH_C32(0xaf9d2ffd), SPH_C32(0x32780000), + SPH_C32(0xde000000), SPH_C32(0x31e40000), SPH_C32(0x46504ec0), + SPH_C32(0x2c8675fb), SPH_C32(0x679a6f51), SPH_C32(0x44bd3c42), + SPH_C32(0x83658c07) }, + { SPH_C32(0xe7990000), SPH_C32(0xaaf40000), SPH_C32(0x616f0000), + SPH_C32(0x5a8deea0), SPH_C32(0x58082ebf), SPH_C32(0xbc332979), + SPH_C32(0x067223cc), SPH_C32(0x78c7676a), SPH_C32(0xc2bd0000), + SPH_C32(0x87230000), SPH_C32(0x74660000), SPH_C32(0xa7dd4e00), + SPH_C32(0x17eb73ca), SPH_C32(0xa57739c8), SPH_C32(0x8f5dc25e), + SPH_C32(0xd5c23d98) } +}; + +static const sph_u32 T512_56[128][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xa8da0000), SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), + SPH_C32(0x07da0002), SPH_C32(0x7d669583), SPH_C32(0x1f98708a), + SPH_C32(0xbb668808), SPH_C32(0xda878000), SPH_C32(0xabe70000), + SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), SPH_C32(0x3d180005), + SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), SPH_C32(0xb5c347eb), + SPH_C32(0x3c5dfffe) }, + { SPH_C32(0x01930000), SPH_C32(0xe7820000), SPH_C32(0xedfb0000), + SPH_C32(0xcf0c000b), SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), + SPH_C32(0x063661e1), SPH_C32(0x536f9e7b), SPH_C32(0x92280000), + SPH_C32(0xdc850000), SPH_C32(0x57fa0000), SPH_C32(0x56dc0003), + SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), SPH_C32(0x90cef752), + SPH_C32(0x7b1675d7) }, + { SPH_C32(0xa9490000), SPH_C32(0x713c0000), SPH_C32(0xb1e60000), + SPH_C32(0xc8d60009), SPH_C32(0xf0b618db), SPH_C32(0xa33bc4a4), + SPH_C32(0xbd50e9e9), SPH_C32(0x89e81e7b), SPH_C32(0x39cf0000), + SPH_C32(0x42880000), SPH_C32(0xf8dd0000), SPH_C32(0x6bc40006), + SPH_C32(0x96a63cc5), SPH_C32(0x2e19b599), SPH_C32(0x250db0b9), + SPH_C32(0x474b8a29) }, + { SPH_C32(0x92280000), SPH_C32(0xdc850000), SPH_C32(0x57fa0000), + SPH_C32(0x56dc0003), SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), + SPH_C32(0x90cef752), SPH_C32(0x7b1675d7), SPH_C32(0x93bb0000), + SPH_C32(0x3b070000), SPH_C32(0xba010000), SPH_C32(0x99d00008), + SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), SPH_C32(0x96f896b3), + SPH_C32(0x2879ebac) }, + { SPH_C32(0x3af20000), SPH_C32(0x4a3b0000), SPH_C32(0x0be70000), + SPH_C32(0x51060001), SPH_C32(0xc78fb695), SPH_C32(0x4577d386), + SPH_C32(0x2ba87f5a), SPH_C32(0xa191f5d7), SPH_C32(0x385c0000), + SPH_C32(0xa50a0000), SPH_C32(0x15260000), SPH_C32(0xa4c8000d), + SPH_C32(0x1b76b19d), SPH_C32(0x92ba01b7), SPH_C32(0x233bd158), + SPH_C32(0x14241452) }, + { SPH_C32(0x93bb0000), SPH_C32(0x3b070000), SPH_C32(0xba010000), + SPH_C32(0x99d00008), SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), + SPH_C32(0x96f896b3), SPH_C32(0x2879ebac), SPH_C32(0x01930000), + SPH_C32(0xe7820000), SPH_C32(0xedfb0000), SPH_C32(0xcf0c000b), + SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), SPH_C32(0x063661e1), + SPH_C32(0x536f9e7b) }, + { SPH_C32(0x3b610000), SPH_C32(0xadb90000), SPH_C32(0xe61c0000), + SPH_C32(0x9e0a000a), SPH_C32(0x4a5f3bcd), SPH_C32(0xf9d467a8), + SPH_C32(0x2d9e1ebb), SPH_C32(0xf2fe6bac), SPH_C32(0xaa740000), + SPH_C32(0x798f0000), SPH_C32(0x42dc0000), SPH_C32(0xf214000e), + SPH_C32(0xa19f928b), SPH_C32(0xc855a2bb), SPH_C32(0xb3f5260a), + SPH_C32(0x6f326185) }, + { SPH_C32(0x5fa80000), SPH_C32(0x56030000), SPH_C32(0x43ae0000), + SPH_C32(0x64f30013), SPH_C32(0x257e86bf), SPH_C32(0x1311944e), + SPH_C32(0x541e95bf), SPH_C32(0x8ea4db69), SPH_C32(0x00440000), + SPH_C32(0x7f480000), SPH_C32(0xda7c0000), SPH_C32(0x2a230001), + SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), SPH_C32(0x030a9e60), + SPH_C32(0xbe0a679e) }, + { SPH_C32(0xf7720000), SPH_C32(0xc0bd0000), SPH_C32(0x1fb30000), + SPH_C32(0x63290011), SPH_C32(0x5818133c), SPH_C32(0x0c89e4c4), + SPH_C32(0xef781db7), SPH_C32(0x54235b69), SPH_C32(0xaba30000), + SPH_C32(0xe1450000), SPH_C32(0x755b0000), SPH_C32(0x173b0004), + SPH_C32(0x17e2d61f), SPH_C32(0xdd408a12), SPH_C32(0xb6c9d98b), + SPH_C32(0x82579860) }, + { SPH_C32(0x5e3b0000), SPH_C32(0xb1810000), SPH_C32(0xae550000), + SPH_C32(0xabff0018), SPH_C32(0xa8ae0be7), SPH_C32(0xafb22060), + SPH_C32(0x5228f45e), SPH_C32(0xddcb4512), SPH_C32(0x926c0000), + SPH_C32(0xa3cd0000), SPH_C32(0x8d860000), SPH_C32(0x7cff0002), + SPH_C32(0x8144eada), SPH_C32(0xf3593f8b), SPH_C32(0x93c46932), + SPH_C32(0xc51c1249) }, + { SPH_C32(0xf6e10000), SPH_C32(0x273f0000), SPH_C32(0xf2480000), + SPH_C32(0xac25001a), SPH_C32(0xd5c89e64), SPH_C32(0xb02a50ea), + SPH_C32(0xe94e7c56), SPH_C32(0x074cc512), SPH_C32(0x398b0000), + SPH_C32(0x3dc00000), SPH_C32(0x22a10000), SPH_C32(0x41e70007), + SPH_C32(0xad0bf509), SPH_C32(0x87af291e), SPH_C32(0x26072ed9), + SPH_C32(0xf941edb7) }, + { SPH_C32(0xcd800000), SPH_C32(0x8a860000), SPH_C32(0x14540000), + SPH_C32(0x322f0010), SPH_C32(0x9f97a5a9), SPH_C32(0x49fe3742), + SPH_C32(0xc4d062ed), SPH_C32(0xf5b2aebe), SPH_C32(0x93ff0000), + SPH_C32(0x444f0000), SPH_C32(0x607d0000), SPH_C32(0xb3f30009), + SPH_C32(0x0c946782), SPH_C32(0x4ffa8ba5), SPH_C32(0x95f208d3), + SPH_C32(0x96738c32) }, + { SPH_C32(0x655a0000), SPH_C32(0x1c380000), SPH_C32(0x48490000), + SPH_C32(0x35f50012), SPH_C32(0xe2f1302a), SPH_C32(0x566647c8), + SPH_C32(0x7fb6eae5), SPH_C32(0x2f352ebe), SPH_C32(0x38180000), + SPH_C32(0xda420000), SPH_C32(0xcf5a0000), SPH_C32(0x8eeb000c), + SPH_C32(0x20db7851), SPH_C32(0x3b0c9d30), SPH_C32(0x20314f38), + SPH_C32(0xaa2e73cc) }, + { SPH_C32(0xcc130000), SPH_C32(0x6d040000), SPH_C32(0xf9af0000), + SPH_C32(0xfd23001b), SPH_C32(0x124728f1), SPH_C32(0xf55d836c), + SPH_C32(0xc2e6030c), SPH_C32(0xa6dd30c5), SPH_C32(0x01d70000), + SPH_C32(0x98ca0000), SPH_C32(0x37870000), SPH_C32(0xe52f000a), + SPH_C32(0xb67d4494), SPH_C32(0x151528a9), SPH_C32(0x053cff81), + SPH_C32(0xed65f9e5) }, + { SPH_C32(0x64c90000), SPH_C32(0xfbba0000), SPH_C32(0xa5b20000), + SPH_C32(0xfaf90019), SPH_C32(0x6f21bd72), SPH_C32(0xeac5f3e6), + SPH_C32(0x79808b04), SPH_C32(0x7c5ab0c5), SPH_C32(0xaa300000), + SPH_C32(0x06c70000), SPH_C32(0x98a00000), SPH_C32(0xd837000f), + SPH_C32(0x9a325b47), SPH_C32(0x61e33e3c), SPH_C32(0xb0ffb86a), + SPH_C32(0xd138061b) }, + { SPH_C32(0x00440000), SPH_C32(0x7f480000), SPH_C32(0xda7c0000), + SPH_C32(0x2a230001), SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), + SPH_C32(0x030a9e60), SPH_C32(0xbe0a679e), SPH_C32(0x5fec0000), + SPH_C32(0x294b0000), SPH_C32(0x99d20000), SPH_C32(0x4ed00012), + SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), SPH_C32(0x57140bdf), + SPH_C32(0x30aebcf7) }, + { SPH_C32(0xa89e0000), SPH_C32(0xe9f60000), SPH_C32(0x86610000), + SPH_C32(0x2df90003), SPH_C32(0x46cb5c4f), SPH_C32(0xb62eec0d), + SPH_C32(0xb86c1668), SPH_C32(0x648de79e), SPH_C32(0xf40b0000), + SPH_C32(0xb7460000), SPH_C32(0x36f50000), SPH_C32(0x73c80017), + SPH_C32(0x329c50a0), SPH_C32(0xce511e5c), SPH_C32(0xe2d74c34), + SPH_C32(0x0cf34309) }, + { SPH_C32(0x01d70000), SPH_C32(0x98ca0000), SPH_C32(0x37870000), + SPH_C32(0xe52f000a), SPH_C32(0xb67d4494), SPH_C32(0x151528a9), + SPH_C32(0x053cff81), SPH_C32(0xed65f9e5), SPH_C32(0xcdc40000), + SPH_C32(0xf5ce0000), SPH_C32(0xce280000), SPH_C32(0x180c0011), + SPH_C32(0xa43a6c65), SPH_C32(0xe048abc5), SPH_C32(0xc7dafc8d), + SPH_C32(0x4bb8c920) }, + { SPH_C32(0xa90d0000), SPH_C32(0x0e740000), SPH_C32(0x6b9a0000), + SPH_C32(0xe2f50008), SPH_C32(0xcb1bd117), SPH_C32(0x0a8d5823), + SPH_C32(0xbe5a7789), SPH_C32(0x37e279e5), SPH_C32(0x66230000), + SPH_C32(0x6bc30000), SPH_C32(0x610f0000), SPH_C32(0x25140014), + SPH_C32(0x887573b6), SPH_C32(0x94bebd50), SPH_C32(0x7219bb66), + SPH_C32(0x77e536de) }, + { SPH_C32(0x926c0000), SPH_C32(0xa3cd0000), SPH_C32(0x8d860000), + SPH_C32(0x7cff0002), SPH_C32(0x8144eada), SPH_C32(0xf3593f8b), + SPH_C32(0x93c46932), SPH_C32(0xc51c1249), SPH_C32(0xcc570000), + SPH_C32(0x124c0000), SPH_C32(0x23d30000), SPH_C32(0xd700001a), + SPH_C32(0x29eae13d), SPH_C32(0x5ceb1feb), SPH_C32(0xc1ec9d6c), + SPH_C32(0x18d7575b) }, + { SPH_C32(0x3ab60000), SPH_C32(0x35730000), SPH_C32(0xd19b0000), + SPH_C32(0x7b250000), SPH_C32(0xfc227f59), SPH_C32(0xecc14f01), + SPH_C32(0x28a2e13a), SPH_C32(0x1f9b9249), SPH_C32(0x67b00000), + SPH_C32(0x8c410000), SPH_C32(0x8cf40000), SPH_C32(0xea18001f), + SPH_C32(0x05a5feee), SPH_C32(0x281d097e), SPH_C32(0x742fda87), + SPH_C32(0x248aa8a5) }, + { SPH_C32(0x93ff0000), SPH_C32(0x444f0000), SPH_C32(0x607d0000), + SPH_C32(0xb3f30009), SPH_C32(0x0c946782), SPH_C32(0x4ffa8ba5), + SPH_C32(0x95f208d3), SPH_C32(0x96738c32), SPH_C32(0x5e7f0000), + SPH_C32(0xcec90000), SPH_C32(0x74290000), SPH_C32(0x81dc0019), + SPH_C32(0x9303c22b), SPH_C32(0x0604bce7), SPH_C32(0x51226a3e), + SPH_C32(0x63c1228c) }, + { SPH_C32(0x3b250000), SPH_C32(0xd2f10000), SPH_C32(0x3c600000), + SPH_C32(0xb429000b), SPH_C32(0x71f2f201), SPH_C32(0x5062fb2f), + SPH_C32(0x2e9480db), SPH_C32(0x4cf40c32), SPH_C32(0xf5980000), + SPH_C32(0x50c40000), SPH_C32(0xdb0e0000), SPH_C32(0xbcc4001c), + SPH_C32(0xbf4cddf8), SPH_C32(0x72f2aa72), SPH_C32(0xe4e12dd5), + SPH_C32(0x5f9cdd72) }, + { SPH_C32(0x5fec0000), SPH_C32(0x294b0000), SPH_C32(0x99d20000), + SPH_C32(0x4ed00012), SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), + SPH_C32(0x57140bdf), SPH_C32(0x30aebcf7), SPH_C32(0x5fa80000), + SPH_C32(0x56030000), SPH_C32(0x43ae0000), SPH_C32(0x64f30013), + SPH_C32(0x257e86bf), SPH_C32(0x1311944e), SPH_C32(0x541e95bf), + SPH_C32(0x8ea4db69) }, + { SPH_C32(0xf7360000), SPH_C32(0xbff50000), SPH_C32(0xc5cf0000), + SPH_C32(0x490a0010), SPH_C32(0x63b5daf0), SPH_C32(0xa53f7843), + SPH_C32(0xec7283d7), SPH_C32(0xea293cf7), SPH_C32(0xf44f0000), + SPH_C32(0xc80e0000), SPH_C32(0xec890000), SPH_C32(0x59eb0016), + SPH_C32(0x0931996c), SPH_C32(0x67e782db), SPH_C32(0xe1ddd254), + SPH_C32(0xb2f92497) }, + { SPH_C32(0x5e7f0000), SPH_C32(0xcec90000), SPH_C32(0x74290000), + SPH_C32(0x81dc0019), SPH_C32(0x9303c22b), SPH_C32(0x0604bce7), + SPH_C32(0x51226a3e), SPH_C32(0x63c1228c), SPH_C32(0xcd800000), + SPH_C32(0x8a860000), SPH_C32(0x14540000), SPH_C32(0x322f0010), + SPH_C32(0x9f97a5a9), SPH_C32(0x49fe3742), SPH_C32(0xc4d062ed), + SPH_C32(0xf5b2aebe) }, + { SPH_C32(0xf6a50000), SPH_C32(0x58770000), SPH_C32(0x28340000), + SPH_C32(0x8606001b), SPH_C32(0xee6557a8), SPH_C32(0x199ccc6d), + SPH_C32(0xea44e236), SPH_C32(0xb946a28c), SPH_C32(0x66670000), + SPH_C32(0x148b0000), SPH_C32(0xbb730000), SPH_C32(0x0f370015), + SPH_C32(0xb3d8ba7a), SPH_C32(0x3d0821d7), SPH_C32(0x71132506), + SPH_C32(0xc9ef5140) }, + { SPH_C32(0xcdc40000), SPH_C32(0xf5ce0000), SPH_C32(0xce280000), + SPH_C32(0x180c0011), SPH_C32(0xa43a6c65), SPH_C32(0xe048abc5), + SPH_C32(0xc7dafc8d), SPH_C32(0x4bb8c920), SPH_C32(0xcc130000), + SPH_C32(0x6d040000), SPH_C32(0xf9af0000), SPH_C32(0xfd23001b), + SPH_C32(0x124728f1), SPH_C32(0xf55d836c), SPH_C32(0xc2e6030c), + SPH_C32(0xa6dd30c5) }, + { SPH_C32(0x651e0000), SPH_C32(0x63700000), SPH_C32(0x92350000), + SPH_C32(0x1fd60013), SPH_C32(0xd95cf9e6), SPH_C32(0xffd0db4f), + SPH_C32(0x7cbc7485), SPH_C32(0x913f4920), SPH_C32(0x67f40000), + SPH_C32(0xf3090000), SPH_C32(0x56880000), SPH_C32(0xc03b001e), + SPH_C32(0x3e083722), SPH_C32(0x81ab95f9), SPH_C32(0x772544e7), + SPH_C32(0x9a80cf3b) }, + { SPH_C32(0xcc570000), SPH_C32(0x124c0000), SPH_C32(0x23d30000), + SPH_C32(0xd700001a), SPH_C32(0x29eae13d), SPH_C32(0x5ceb1feb), + SPH_C32(0xc1ec9d6c), SPH_C32(0x18d7575b), SPH_C32(0x5e3b0000), + SPH_C32(0xb1810000), SPH_C32(0xae550000), SPH_C32(0xabff0018), + SPH_C32(0xa8ae0be7), SPH_C32(0xafb22060), SPH_C32(0x5228f45e), + SPH_C32(0xddcb4512) }, + { SPH_C32(0x648d0000), SPH_C32(0x84f20000), SPH_C32(0x7fce0000), + SPH_C32(0xd0da0018), SPH_C32(0x548c74be), SPH_C32(0x43736f61), + SPH_C32(0x7a8a1564), SPH_C32(0xc250d75b), SPH_C32(0xf5dc0000), + SPH_C32(0x2f8c0000), SPH_C32(0x01720000), SPH_C32(0x96e7001d), + SPH_C32(0x84e11434), SPH_C32(0xdb4436f5), SPH_C32(0xe7ebb3b5), + SPH_C32(0xe196baec) }, + { SPH_C32(0xee930000), SPH_C32(0xd6070000), SPH_C32(0x92c10000), + SPH_C32(0x2b9801e0), SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), + SPH_C32(0x45312374), SPH_C32(0x201f6a64), SPH_C32(0x7b280000), + SPH_C32(0x57420000), SPH_C32(0xa9e50000), SPH_C32(0x634300a0), + SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), SPH_C32(0x27f83b03), + SPH_C32(0xc7ff60f0) }, + { SPH_C32(0x46490000), SPH_C32(0x40b90000), SPH_C32(0xcedc0000), + SPH_C32(0x2c4201e2), SPH_C32(0xe937bdff), SPH_C32(0x24f48bdd), + SPH_C32(0xfe57ab7c), SPH_C32(0xfa98ea64), SPH_C32(0xd0cf0000), + SPH_C32(0xc94f0000), SPH_C32(0x06c20000), SPH_C32(0x5e5b00a5), + SPH_C32(0xb2945bfc), SPH_C32(0x196f832e), SPH_C32(0x923b7ce8), + SPH_C32(0xfba29f0e) }, + { SPH_C32(0xef000000), SPH_C32(0x31850000), SPH_C32(0x7f3a0000), + SPH_C32(0xe49401eb), SPH_C32(0x1981a524), SPH_C32(0x87cf4f79), + SPH_C32(0x43074295), SPH_C32(0x7370f41f), SPH_C32(0xe9000000), + SPH_C32(0x8bc70000), SPH_C32(0xfe1f0000), SPH_C32(0x359f00a3), + SPH_C32(0x24326739), SPH_C32(0x377636b7), SPH_C32(0xb736cc51), + SPH_C32(0xbce91527) }, + { SPH_C32(0x47da0000), SPH_C32(0xa73b0000), SPH_C32(0x23270000), + SPH_C32(0xe34e01e9), SPH_C32(0x64e730a7), SPH_C32(0x98573ff3), + SPH_C32(0xf861ca9d), SPH_C32(0xa9f7741f), SPH_C32(0x42e70000), + SPH_C32(0x15ca0000), SPH_C32(0x51380000), SPH_C32(0x088700a6), + SPH_C32(0x087d78ea), SPH_C32(0x43802022), SPH_C32(0x02f58bba), + SPH_C32(0x80b4ead9) }, + { SPH_C32(0x7cbb0000), SPH_C32(0x0a820000), SPH_C32(0xc53b0000), + SPH_C32(0x7d4401e3), SPH_C32(0x2eb80b6a), SPH_C32(0x6183585b), + SPH_C32(0xd5ffd426), SPH_C32(0x5b091fb3), SPH_C32(0xe8930000), + SPH_C32(0x6c450000), SPH_C32(0x13e40000), SPH_C32(0xfa9300a8), + SPH_C32(0xa9e2ea61), SPH_C32(0x8bd58299), SPH_C32(0xb100adb0), + SPH_C32(0xef868b5c) }, + { SPH_C32(0xd4610000), SPH_C32(0x9c3c0000), SPH_C32(0x99260000), + SPH_C32(0x7a9e01e1), SPH_C32(0x53de9ee9), SPH_C32(0x7e1b28d1), + SPH_C32(0x6e995c2e), SPH_C32(0x818e9fb3), SPH_C32(0x43740000), + SPH_C32(0xf2480000), SPH_C32(0xbcc30000), SPH_C32(0xc78b00ad), + SPH_C32(0x85adf5b2), SPH_C32(0xff23940c), SPH_C32(0x04c3ea5b), + SPH_C32(0xd3db74a2) }, + { SPH_C32(0x7d280000), SPH_C32(0xed000000), SPH_C32(0x28c00000), + SPH_C32(0xb24801e8), SPH_C32(0xa3688632), SPH_C32(0xdd20ec75), + SPH_C32(0xd3c9b5c7), SPH_C32(0x086681c8), SPH_C32(0x7abb0000), + SPH_C32(0xb0c00000), SPH_C32(0x441e0000), SPH_C32(0xac4f00ab), + SPH_C32(0x130bc977), SPH_C32(0xd13a2195), SPH_C32(0x21ce5ae2), + SPH_C32(0x9490fe8b) }, + { SPH_C32(0xd5f20000), SPH_C32(0x7bbe0000), SPH_C32(0x74dd0000), + SPH_C32(0xb59201ea), SPH_C32(0xde0e13b1), SPH_C32(0xc2b89cff), + SPH_C32(0x68af3dcf), SPH_C32(0xd2e101c8), SPH_C32(0xd15c0000), + SPH_C32(0x2ecd0000), SPH_C32(0xeb390000), SPH_C32(0x915700ae), + SPH_C32(0x3f44d6a4), SPH_C32(0xa5cc3700), SPH_C32(0x940d1d09), + SPH_C32(0xa8cd0175) }, + { SPH_C32(0xb13b0000), SPH_C32(0x80040000), SPH_C32(0xd16f0000), + SPH_C32(0x4f6b01f3), SPH_C32(0xb12faec3), SPH_C32(0x287d6f19), + SPH_C32(0x112fb6cb), SPH_C32(0xaebbb10d), SPH_C32(0x7b6c0000), + SPH_C32(0x280a0000), SPH_C32(0x73990000), SPH_C32(0x496000a1), + SPH_C32(0xa5768de3), SPH_C32(0xc42f093c), SPH_C32(0x24f2a563), + SPH_C32(0x79f5076e) }, + { SPH_C32(0x19e10000), SPH_C32(0x16ba0000), SPH_C32(0x8d720000), + SPH_C32(0x48b101f1), SPH_C32(0xcc493b40), SPH_C32(0x37e51f93), + SPH_C32(0xaa493ec3), SPH_C32(0x743c310d), SPH_C32(0xd08b0000), + SPH_C32(0xb6070000), SPH_C32(0xdcbe0000), SPH_C32(0x747800a4), + SPH_C32(0x89399230), SPH_C32(0xb0d91fa9), SPH_C32(0x9131e288), + SPH_C32(0x45a8f890) }, + { SPH_C32(0xb0a80000), SPH_C32(0x67860000), SPH_C32(0x3c940000), + SPH_C32(0x806701f8), SPH_C32(0x3cff239b), SPH_C32(0x94dedb37), + SPH_C32(0x1719d72a), SPH_C32(0xfdd42f76), SPH_C32(0xe9440000), + SPH_C32(0xf48f0000), SPH_C32(0x24630000), SPH_C32(0x1fbc00a2), + SPH_C32(0x1f9faef5), SPH_C32(0x9ec0aa30), SPH_C32(0xb43c5231), + SPH_C32(0x02e372b9) }, + { SPH_C32(0x18720000), SPH_C32(0xf1380000), SPH_C32(0x60890000), + SPH_C32(0x87bd01fa), SPH_C32(0x4199b618), SPH_C32(0x8b46abbd), + SPH_C32(0xac7f5f22), SPH_C32(0x2753af76), SPH_C32(0x42a30000), + SPH_C32(0x6a820000), SPH_C32(0x8b440000), SPH_C32(0x22a400a7), + SPH_C32(0x33d0b126), SPH_C32(0xea36bca5), SPH_C32(0x01ff15da), + SPH_C32(0x3ebe8d47) }, + { SPH_C32(0x23130000), SPH_C32(0x5c810000), SPH_C32(0x86950000), + SPH_C32(0x19b701f0), SPH_C32(0x0bc68dd5), SPH_C32(0x7292cc15), + SPH_C32(0x81e14199), SPH_C32(0xd5adc4da), SPH_C32(0xe8d70000), + SPH_C32(0x130d0000), SPH_C32(0xc9980000), SPH_C32(0xd0b000a9), + SPH_C32(0x924f23ad), SPH_C32(0x22631e1e), SPH_C32(0xb20a33d0), + SPH_C32(0x518cecc2) }, + { SPH_C32(0x8bc90000), SPH_C32(0xca3f0000), SPH_C32(0xda880000), + SPH_C32(0x1e6d01f2), SPH_C32(0x76a01856), SPH_C32(0x6d0abc9f), + SPH_C32(0x3a87c991), SPH_C32(0x0f2a44da), SPH_C32(0x43300000), + SPH_C32(0x8d000000), SPH_C32(0x66bf0000), SPH_C32(0xeda800ac), + SPH_C32(0xbe003c7e), SPH_C32(0x5695088b), SPH_C32(0x07c9743b), + SPH_C32(0x6dd1133c) }, + { SPH_C32(0x22800000), SPH_C32(0xbb030000), SPH_C32(0x6b6e0000), + SPH_C32(0xd6bb01fb), SPH_C32(0x8616008d), SPH_C32(0xce31783b), + SPH_C32(0x87d72078), SPH_C32(0x86c25aa1), SPH_C32(0x7aff0000), + SPH_C32(0xcf880000), SPH_C32(0x9e620000), SPH_C32(0x866c00aa), + SPH_C32(0x28a600bb), SPH_C32(0x788cbd12), SPH_C32(0x22c4c482), + SPH_C32(0x2a9a9915) }, + { SPH_C32(0x8a5a0000), SPH_C32(0x2dbd0000), SPH_C32(0x37730000), + SPH_C32(0xd16101f9), SPH_C32(0xfb70950e), SPH_C32(0xd1a908b1), + SPH_C32(0x3cb1a870), SPH_C32(0x5c45daa1), SPH_C32(0xd1180000), + SPH_C32(0x51850000), SPH_C32(0x31450000), SPH_C32(0xbb7400af), + SPH_C32(0x04e91f68), SPH_C32(0x0c7aab87), SPH_C32(0x97078369), + SPH_C32(0x16c766eb) }, + { SPH_C32(0xeed70000), SPH_C32(0xa94f0000), SPH_C32(0x48bd0000), + SPH_C32(0x01bb01e1), SPH_C32(0xaffce1b0), SPH_C32(0x92da67d0), + SPH_C32(0x463bbd14), SPH_C32(0x9e150dfa), SPH_C32(0x24c40000), + SPH_C32(0x7e090000), SPH_C32(0x30370000), SPH_C32(0x2d9300b2), + SPH_C32(0x80080b5c), SPH_C32(0xd73e9d72), SPH_C32(0x70ec30dc), + SPH_C32(0xf751dc07) }, + { SPH_C32(0x460d0000), SPH_C32(0x3ff10000), SPH_C32(0x14a00000), + SPH_C32(0x066101e3), SPH_C32(0xd29a7433), SPH_C32(0x8d42175a), + SPH_C32(0xfd5d351c), SPH_C32(0x44928dfa), SPH_C32(0x8f230000), + SPH_C32(0xe0040000), SPH_C32(0x9f100000), SPH_C32(0x108b00b7), + SPH_C32(0xac47148f), SPH_C32(0xa3c88be7), SPH_C32(0xc52f7737), + SPH_C32(0xcb0c23f9) }, + { SPH_C32(0xef440000), SPH_C32(0x4ecd0000), SPH_C32(0xa5460000), + SPH_C32(0xceb701ea), SPH_C32(0x222c6ce8), SPH_C32(0x2e79d3fe), + SPH_C32(0x400ddcf5), SPH_C32(0xcd7a9381), SPH_C32(0xb6ec0000), + SPH_C32(0xa28c0000), SPH_C32(0x67cd0000), SPH_C32(0x7b4f00b1), + SPH_C32(0x3ae1284a), SPH_C32(0x8dd13e7e), SPH_C32(0xe022c78e), + SPH_C32(0x8c47a9d0) }, + { SPH_C32(0x479e0000), SPH_C32(0xd8730000), SPH_C32(0xf95b0000), + SPH_C32(0xc96d01e8), SPH_C32(0x5f4af96b), SPH_C32(0x31e1a374), + SPH_C32(0xfb6b54fd), SPH_C32(0x17fd1381), SPH_C32(0x1d0b0000), + SPH_C32(0x3c810000), SPH_C32(0xc8ea0000), SPH_C32(0x465700b4), + SPH_C32(0x16ae3799), SPH_C32(0xf92728eb), SPH_C32(0x55e18065), + SPH_C32(0xb01a562e) }, + { SPH_C32(0x7cff0000), SPH_C32(0x75ca0000), SPH_C32(0x1f470000), + SPH_C32(0x576701e2), SPH_C32(0x1515c2a6), SPH_C32(0xc835c4dc), + SPH_C32(0xd6f54a46), SPH_C32(0xe503782d), SPH_C32(0xb77f0000), + SPH_C32(0x450e0000), SPH_C32(0x8a360000), SPH_C32(0xb44300ba), + SPH_C32(0xb731a512), SPH_C32(0x31728a50), SPH_C32(0xe614a66f), + SPH_C32(0xdf2837ab) }, + { SPH_C32(0xd4250000), SPH_C32(0xe3740000), SPH_C32(0x435a0000), + SPH_C32(0x50bd01e0), SPH_C32(0x68735725), SPH_C32(0xd7adb456), + SPH_C32(0x6d93c24e), SPH_C32(0x3f84f82d), SPH_C32(0x1c980000), + SPH_C32(0xdb030000), SPH_C32(0x25110000), SPH_C32(0x895b00bf), + SPH_C32(0x9b7ebac1), SPH_C32(0x45849cc5), SPH_C32(0x53d7e184), + SPH_C32(0xe375c855) }, + { SPH_C32(0x7d6c0000), SPH_C32(0x92480000), SPH_C32(0xf2bc0000), + SPH_C32(0x986b01e9), SPH_C32(0x98c54ffe), SPH_C32(0x749670f2), + SPH_C32(0xd0c32ba7), SPH_C32(0xb66ce656), SPH_C32(0x25570000), + SPH_C32(0x998b0000), SPH_C32(0xddcc0000), SPH_C32(0xe29f00b9), + SPH_C32(0x0dd88604), SPH_C32(0x6b9d295c), SPH_C32(0x76da513d), + SPH_C32(0xa43e427c) }, + { SPH_C32(0xd5b60000), SPH_C32(0x04f60000), SPH_C32(0xaea10000), + SPH_C32(0x9fb101eb), SPH_C32(0xe5a3da7d), SPH_C32(0x6b0e0078), + SPH_C32(0x6ba5a3af), SPH_C32(0x6ceb6656), SPH_C32(0x8eb00000), + SPH_C32(0x07860000), SPH_C32(0x72eb0000), SPH_C32(0xdf8700bc), + SPH_C32(0x219799d7), SPH_C32(0x1f6b3fc9), SPH_C32(0xc31916d6), + SPH_C32(0x9863bd82) }, + { SPH_C32(0xb17f0000), SPH_C32(0xff4c0000), SPH_C32(0x0b130000), + SPH_C32(0x654801f2), SPH_C32(0x8a82670f), SPH_C32(0x81cbf39e), + SPH_C32(0x122528ab), SPH_C32(0x10b1d693), SPH_C32(0x24800000), + SPH_C32(0x01410000), SPH_C32(0xea4b0000), SPH_C32(0x07b000b3), + SPH_C32(0xbba5c290), SPH_C32(0x7e8801f5), SPH_C32(0x73e6aebc), + SPH_C32(0x495bbb99) }, + { SPH_C32(0x19a50000), SPH_C32(0x69f20000), SPH_C32(0x570e0000), + SPH_C32(0x629201f0), SPH_C32(0xf7e4f28c), SPH_C32(0x9e538314), + SPH_C32(0xa943a0a3), SPH_C32(0xca365693), SPH_C32(0x8f670000), + SPH_C32(0x9f4c0000), SPH_C32(0x456c0000), SPH_C32(0x3aa800b6), + SPH_C32(0x97eadd43), SPH_C32(0x0a7e1760), SPH_C32(0xc625e957), + SPH_C32(0x75064467) }, + { SPH_C32(0xb0ec0000), SPH_C32(0x18ce0000), SPH_C32(0xe6e80000), + SPH_C32(0xaa4401f9), SPH_C32(0x0752ea57), SPH_C32(0x3d6847b0), + SPH_C32(0x1413494a), SPH_C32(0x43de48e8), SPH_C32(0xb6a80000), + SPH_C32(0xddc40000), SPH_C32(0xbdb10000), SPH_C32(0x516c00b0), + SPH_C32(0x014ce186), SPH_C32(0x2467a2f9), SPH_C32(0xe32859ee), + SPH_C32(0x324dce4e) }, + { SPH_C32(0x18360000), SPH_C32(0x8e700000), SPH_C32(0xbaf50000), + SPH_C32(0xad9e01fb), SPH_C32(0x7a347fd4), SPH_C32(0x22f0373a), + SPH_C32(0xaf75c142), SPH_C32(0x9959c8e8), SPH_C32(0x1d4f0000), + SPH_C32(0x43c90000), SPH_C32(0x12960000), SPH_C32(0x6c7400b5), + SPH_C32(0x2d03fe55), SPH_C32(0x5091b46c), SPH_C32(0x56eb1e05), + SPH_C32(0x0e1031b0) }, + { SPH_C32(0x23570000), SPH_C32(0x23c90000), SPH_C32(0x5ce90000), + SPH_C32(0x339401f1), SPH_C32(0x306b4419), SPH_C32(0xdb245092), + SPH_C32(0x82ebdff9), SPH_C32(0x6ba7a344), SPH_C32(0xb73b0000), + SPH_C32(0x3a460000), SPH_C32(0x504a0000), SPH_C32(0x9e6000bb), + SPH_C32(0x8c9c6cde), SPH_C32(0x98c416d7), SPH_C32(0xe51e380f), + SPH_C32(0x61225035) }, + { SPH_C32(0x8b8d0000), SPH_C32(0xb5770000), SPH_C32(0x00f40000), + SPH_C32(0x344e01f3), SPH_C32(0x4d0dd19a), SPH_C32(0xc4bc2018), + SPH_C32(0x398d57f1), SPH_C32(0xb1202344), SPH_C32(0x1cdc0000), + SPH_C32(0xa44b0000), SPH_C32(0xff6d0000), SPH_C32(0xa37800be), + SPH_C32(0xa0d3730d), SPH_C32(0xec320042), SPH_C32(0x50dd7fe4), + SPH_C32(0x5d7fafcb) }, + { SPH_C32(0x22c40000), SPH_C32(0xc44b0000), SPH_C32(0xb1120000), + SPH_C32(0xfc9801fa), SPH_C32(0xbdbbc941), SPH_C32(0x6787e4bc), + SPH_C32(0x84ddbe18), SPH_C32(0x38c83d3f), SPH_C32(0x25130000), + SPH_C32(0xe6c30000), SPH_C32(0x07b00000), SPH_C32(0xc8bc00b8), + SPH_C32(0x36754fc8), SPH_C32(0xc22bb5db), SPH_C32(0x75d0cf5d), + SPH_C32(0x1a3425e2) }, + { SPH_C32(0x8a1e0000), SPH_C32(0x52f50000), SPH_C32(0xed0f0000), + SPH_C32(0xfb4201f8), SPH_C32(0xc0dd5cc2), SPH_C32(0x781f9436), + SPH_C32(0x3fbb3610), SPH_C32(0xe24fbd3f), SPH_C32(0x8ef40000), + SPH_C32(0x78ce0000), SPH_C32(0xa8970000), SPH_C32(0xf5a400bd), + SPH_C32(0x1a3a501b), SPH_C32(0xb6dda34e), SPH_C32(0xc01388b6), + SPH_C32(0x2669da1c) }, + { SPH_C32(0x7b280000), SPH_C32(0x57420000), SPH_C32(0xa9e50000), + SPH_C32(0x634300a0), SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), + SPH_C32(0x27f83b03), SPH_C32(0xc7ff60f0), SPH_C32(0x95bb0000), + SPH_C32(0x81450000), SPH_C32(0x3b240000), SPH_C32(0x48db0140), + SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), SPH_C32(0x62c91877), + SPH_C32(0xe7e00a94) }, + { SPH_C32(0xd3f20000), SPH_C32(0xc1fc0000), SPH_C32(0xf5f80000), + SPH_C32(0x649900a2), SPH_C32(0xe3bdd1ac), SPH_C32(0x7201e531), + SPH_C32(0x9c9eb30b), SPH_C32(0x1d78e0f0), SPH_C32(0x3e5c0000), + SPH_C32(0x1f480000), SPH_C32(0x94030000), SPH_C32(0x75c30145), + SPH_C32(0x26c57380), SPH_C32(0x22037879), SPH_C32(0xd70a5f9c), + SPH_C32(0xdbbdf56a) }, + { SPH_C32(0x7abb0000), SPH_C32(0xb0c00000), SPH_C32(0x441e0000), + SPH_C32(0xac4f00ab), SPH_C32(0x130bc977), SPH_C32(0xd13a2195), + SPH_C32(0x21ce5ae2), SPH_C32(0x9490fe8b), SPH_C32(0x07930000), + SPH_C32(0x5dc00000), SPH_C32(0x6cde0000), SPH_C32(0x1e070143), + SPH_C32(0xb0634f45), SPH_C32(0x0c1acde0), SPH_C32(0xf207ef25), + SPH_C32(0x9cf67f43) }, + { SPH_C32(0xd2610000), SPH_C32(0x267e0000), SPH_C32(0x18030000), + SPH_C32(0xab9500a9), SPH_C32(0x6e6d5cf4), SPH_C32(0xcea2511f), + SPH_C32(0x9aa8d2ea), SPH_C32(0x4e177e8b), SPH_C32(0xac740000), + SPH_C32(0xc3cd0000), SPH_C32(0xc3f90000), SPH_C32(0x231f0146), + SPH_C32(0x9c2c5096), SPH_C32(0x78ecdb75), SPH_C32(0x47c4a8ce), + SPH_C32(0xa0ab80bd) }, + { SPH_C32(0xe9000000), SPH_C32(0x8bc70000), SPH_C32(0xfe1f0000), + SPH_C32(0x359f00a3), SPH_C32(0x24326739), SPH_C32(0x377636b7), + SPH_C32(0xb736cc51), SPH_C32(0xbce91527), SPH_C32(0x06000000), + SPH_C32(0xba420000), SPH_C32(0x81250000), SPH_C32(0xd10b0148), + SPH_C32(0x3db3c21d), SPH_C32(0xb0b979ce), SPH_C32(0xf4318ec4), + SPH_C32(0xcf99e138) }, + { SPH_C32(0x41da0000), SPH_C32(0x1d790000), SPH_C32(0xa2020000), + SPH_C32(0x324500a1), SPH_C32(0x5954f2ba), SPH_C32(0x28ee463d), + SPH_C32(0x0c504459), SPH_C32(0x666e9527), SPH_C32(0xade70000), + SPH_C32(0x244f0000), SPH_C32(0x2e020000), SPH_C32(0xec13014d), + SPH_C32(0x11fcddce), SPH_C32(0xc44f6f5b), SPH_C32(0x41f2c92f), + SPH_C32(0xf3c41ec6) }, + { SPH_C32(0xe8930000), SPH_C32(0x6c450000), SPH_C32(0x13e40000), + SPH_C32(0xfa9300a8), SPH_C32(0xa9e2ea61), SPH_C32(0x8bd58299), + SPH_C32(0xb100adb0), SPH_C32(0xef868b5c), SPH_C32(0x94280000), + SPH_C32(0x66c70000), SPH_C32(0xd6df0000), SPH_C32(0x87d7014b), + SPH_C32(0x875ae10b), SPH_C32(0xea56dac2), SPH_C32(0x64ff7996), + SPH_C32(0xb48f94ef) }, + { SPH_C32(0x40490000), SPH_C32(0xfafb0000), SPH_C32(0x4ff90000), + SPH_C32(0xfd4900aa), SPH_C32(0xd4847fe2), SPH_C32(0x944df213), + SPH_C32(0x0a6625b8), SPH_C32(0x35010b5c), SPH_C32(0x3fcf0000), + SPH_C32(0xf8ca0000), SPH_C32(0x79f80000), SPH_C32(0xbacf014e), + SPH_C32(0xab15fed8), SPH_C32(0x9ea0cc57), SPH_C32(0xd13c3e7d), + SPH_C32(0x88d26b11) }, + { SPH_C32(0x24800000), SPH_C32(0x01410000), SPH_C32(0xea4b0000), + SPH_C32(0x07b000b3), SPH_C32(0xbba5c290), SPH_C32(0x7e8801f5), + SPH_C32(0x73e6aebc), SPH_C32(0x495bbb99), SPH_C32(0x95ff0000), + SPH_C32(0xfe0d0000), SPH_C32(0xe1580000), SPH_C32(0x62f80141), + SPH_C32(0x3127a59f), SPH_C32(0xff43f26b), SPH_C32(0x61c38617), + SPH_C32(0x59ea6d0a) }, + { SPH_C32(0x8c5a0000), SPH_C32(0x97ff0000), SPH_C32(0xb6560000), + SPH_C32(0x006a00b1), SPH_C32(0xc6c35713), SPH_C32(0x6110717f), + SPH_C32(0xc88026b4), SPH_C32(0x93dc3b99), SPH_C32(0x3e180000), + SPH_C32(0x60000000), SPH_C32(0x4e7f0000), SPH_C32(0x5fe00144), + SPH_C32(0x1d68ba4c), SPH_C32(0x8bb5e4fe), SPH_C32(0xd400c1fc), + SPH_C32(0x65b792f4) }, + { SPH_C32(0x25130000), SPH_C32(0xe6c30000), SPH_C32(0x07b00000), + SPH_C32(0xc8bc00b8), SPH_C32(0x36754fc8), SPH_C32(0xc22bb5db), + SPH_C32(0x75d0cf5d), SPH_C32(0x1a3425e2), SPH_C32(0x07d70000), + SPH_C32(0x22880000), SPH_C32(0xb6a20000), SPH_C32(0x34240142), + SPH_C32(0x8bce8689), SPH_C32(0xa5ac5167), SPH_C32(0xf10d7145), + SPH_C32(0x22fc18dd) }, + { SPH_C32(0x8dc90000), SPH_C32(0x707d0000), SPH_C32(0x5bad0000), + SPH_C32(0xcf6600ba), SPH_C32(0x4b13da4b), SPH_C32(0xddb3c551), + SPH_C32(0xceb64755), SPH_C32(0xc0b3a5e2), SPH_C32(0xac300000), + SPH_C32(0xbc850000), SPH_C32(0x19850000), SPH_C32(0x093c0147), + SPH_C32(0xa781995a), SPH_C32(0xd15a47f2), SPH_C32(0x44ce36ae), + SPH_C32(0x1ea1e723) }, + { SPH_C32(0xb6a80000), SPH_C32(0xddc40000), SPH_C32(0xbdb10000), + SPH_C32(0x516c00b0), SPH_C32(0x014ce186), SPH_C32(0x2467a2f9), + SPH_C32(0xe32859ee), SPH_C32(0x324dce4e), SPH_C32(0x06440000), + SPH_C32(0xc50a0000), SPH_C32(0x5b590000), SPH_C32(0xfb280149), + SPH_C32(0x061e0bd1), SPH_C32(0x190fe549), SPH_C32(0xf73b10a4), + SPH_C32(0x719386a6) }, + { SPH_C32(0x1e720000), SPH_C32(0x4b7a0000), SPH_C32(0xe1ac0000), + SPH_C32(0x56b600b2), SPH_C32(0x7c2a7405), SPH_C32(0x3bffd273), + SPH_C32(0x584ed1e6), SPH_C32(0xe8ca4e4e), SPH_C32(0xada30000), + SPH_C32(0x5b070000), SPH_C32(0xf47e0000), SPH_C32(0xc630014c), + SPH_C32(0x2a511402), SPH_C32(0x6df9f3dc), SPH_C32(0x42f8574f), + SPH_C32(0x4dce7958) }, + { SPH_C32(0xb73b0000), SPH_C32(0x3a460000), SPH_C32(0x504a0000), + SPH_C32(0x9e6000bb), SPH_C32(0x8c9c6cde), SPH_C32(0x98c416d7), + SPH_C32(0xe51e380f), SPH_C32(0x61225035), SPH_C32(0x946c0000), + SPH_C32(0x198f0000), SPH_C32(0x0ca30000), SPH_C32(0xadf4014a), + SPH_C32(0xbcf728c7), SPH_C32(0x43e04645), SPH_C32(0x67f5e7f6), + SPH_C32(0x0a85f371) }, + { SPH_C32(0x1fe10000), SPH_C32(0xacf80000), SPH_C32(0x0c570000), + SPH_C32(0x99ba00b9), SPH_C32(0xf1faf95d), SPH_C32(0x875c665d), + SPH_C32(0x5e78b007), SPH_C32(0xbba5d035), SPH_C32(0x3f8b0000), + SPH_C32(0x87820000), SPH_C32(0xa3840000), SPH_C32(0x90ec014f), + SPH_C32(0x90b83714), SPH_C32(0x371650d0), SPH_C32(0xd236a01d), + SPH_C32(0x36d80c8f) }, + { SPH_C32(0x7b6c0000), SPH_C32(0x280a0000), SPH_C32(0x73990000), + SPH_C32(0x496000a1), SPH_C32(0xa5768de3), SPH_C32(0xc42f093c), + SPH_C32(0x24f2a563), SPH_C32(0x79f5076e), SPH_C32(0xca570000), + SPH_C32(0xa80e0000), SPH_C32(0xa2f60000), SPH_C32(0x060b0152), + SPH_C32(0x14592320), SPH_C32(0xec526625), SPH_C32(0x35dd13a8), + SPH_C32(0xd74eb663) }, + { SPH_C32(0xd3b60000), SPH_C32(0xbeb40000), SPH_C32(0x2f840000), + SPH_C32(0x4eba00a3), SPH_C32(0xd8101860), SPH_C32(0xdbb779b6), + SPH_C32(0x9f942d6b), SPH_C32(0xa372876e), SPH_C32(0x61b00000), + SPH_C32(0x36030000), SPH_C32(0x0dd10000), SPH_C32(0x3b130157), + SPH_C32(0x38163cf3), SPH_C32(0x98a470b0), SPH_C32(0x801e5443), + SPH_C32(0xeb13499d) }, + { SPH_C32(0x7aff0000), SPH_C32(0xcf880000), SPH_C32(0x9e620000), + SPH_C32(0x866c00aa), SPH_C32(0x28a600bb), SPH_C32(0x788cbd12), + SPH_C32(0x22c4c482), SPH_C32(0x2a9a9915), SPH_C32(0x587f0000), + SPH_C32(0x748b0000), SPH_C32(0xf50c0000), SPH_C32(0x50d70151), + SPH_C32(0xaeb00036), SPH_C32(0xb6bdc529), SPH_C32(0xa513e4fa), + SPH_C32(0xac58c3b4) }, + { SPH_C32(0xd2250000), SPH_C32(0x59360000), SPH_C32(0xc27f0000), + SPH_C32(0x81b600a8), SPH_C32(0x55c09538), SPH_C32(0x6714cd98), + SPH_C32(0x99a24c8a), SPH_C32(0xf01d1915), SPH_C32(0xf3980000), + SPH_C32(0xea860000), SPH_C32(0x5a2b0000), SPH_C32(0x6dcf0154), + SPH_C32(0x82ff1fe5), SPH_C32(0xc24bd3bc), SPH_C32(0x10d0a311), + SPH_C32(0x90053c4a) }, + { SPH_C32(0xe9440000), SPH_C32(0xf48f0000), SPH_C32(0x24630000), + SPH_C32(0x1fbc00a2), SPH_C32(0x1f9faef5), SPH_C32(0x9ec0aa30), + SPH_C32(0xb43c5231), SPH_C32(0x02e372b9), SPH_C32(0x59ec0000), + SPH_C32(0x93090000), SPH_C32(0x18f70000), SPH_C32(0x9fdb015a), + SPH_C32(0x23608d6e), SPH_C32(0x0a1e7107), SPH_C32(0xa325851b), + SPH_C32(0xff375dcf) }, + { SPH_C32(0x419e0000), SPH_C32(0x62310000), SPH_C32(0x787e0000), + SPH_C32(0x186600a0), SPH_C32(0x62f93b76), SPH_C32(0x8158daba), + SPH_C32(0x0f5ada39), SPH_C32(0xd864f2b9), SPH_C32(0xf20b0000), + SPH_C32(0x0d040000), SPH_C32(0xb7d00000), SPH_C32(0xa2c3015f), + SPH_C32(0x0f2f92bd), SPH_C32(0x7ee86792), SPH_C32(0x16e6c2f0), + SPH_C32(0xc36aa231) }, + { SPH_C32(0xe8d70000), SPH_C32(0x130d0000), SPH_C32(0xc9980000), + SPH_C32(0xd0b000a9), SPH_C32(0x924f23ad), SPH_C32(0x22631e1e), + SPH_C32(0xb20a33d0), SPH_C32(0x518cecc2), SPH_C32(0xcbc40000), + SPH_C32(0x4f8c0000), SPH_C32(0x4f0d0000), SPH_C32(0xc9070159), + SPH_C32(0x9989ae78), SPH_C32(0x50f1d20b), SPH_C32(0x33eb7249), + SPH_C32(0x84212818) }, + { SPH_C32(0x400d0000), SPH_C32(0x85b30000), SPH_C32(0x95850000), + SPH_C32(0xd76a00ab), SPH_C32(0xef29b62e), SPH_C32(0x3dfb6e94), + SPH_C32(0x096cbbd8), SPH_C32(0x8b0b6cc2), SPH_C32(0x60230000), + SPH_C32(0xd1810000), SPH_C32(0xe02a0000), SPH_C32(0xf41f015c), + SPH_C32(0xb5c6b1ab), SPH_C32(0x2407c49e), SPH_C32(0x862835a2), + SPH_C32(0xb87cd7e6) }, + { SPH_C32(0x24c40000), SPH_C32(0x7e090000), SPH_C32(0x30370000), + SPH_C32(0x2d9300b2), SPH_C32(0x80080b5c), SPH_C32(0xd73e9d72), + SPH_C32(0x70ec30dc), SPH_C32(0xf751dc07), SPH_C32(0xca130000), + SPH_C32(0xd7460000), SPH_C32(0x788a0000), SPH_C32(0x2c280153), + SPH_C32(0x2ff4eaec), SPH_C32(0x45e4faa2), SPH_C32(0x36d78dc8), + SPH_C32(0x6944d1fd) }, + { SPH_C32(0x8c1e0000), SPH_C32(0xe8b70000), SPH_C32(0x6c2a0000), + SPH_C32(0x2a4900b0), SPH_C32(0xfd6e9edf), SPH_C32(0xc8a6edf8), + SPH_C32(0xcb8ab8d4), SPH_C32(0x2dd65c07), SPH_C32(0x61f40000), + SPH_C32(0x494b0000), SPH_C32(0xd7ad0000), SPH_C32(0x11300156), + SPH_C32(0x03bbf53f), SPH_C32(0x3112ec37), SPH_C32(0x8314ca23), + SPH_C32(0x55192e03) }, + { SPH_C32(0x25570000), SPH_C32(0x998b0000), SPH_C32(0xddcc0000), + SPH_C32(0xe29f00b9), SPH_C32(0x0dd88604), SPH_C32(0x6b9d295c), + SPH_C32(0x76da513d), SPH_C32(0xa43e427c), SPH_C32(0x583b0000), + SPH_C32(0x0bc30000), SPH_C32(0x2f700000), SPH_C32(0x7af40150), + SPH_C32(0x951dc9fa), SPH_C32(0x1f0b59ae), SPH_C32(0xa6197a9a), + SPH_C32(0x1252a42a) }, + { SPH_C32(0x8d8d0000), SPH_C32(0x0f350000), SPH_C32(0x81d10000), + SPH_C32(0xe54500bb), SPH_C32(0x70be1387), SPH_C32(0x740559d6), + SPH_C32(0xcdbcd935), SPH_C32(0x7eb9c27c), SPH_C32(0xf3dc0000), + SPH_C32(0x95ce0000), SPH_C32(0x80570000), SPH_C32(0x47ec0155), + SPH_C32(0xb952d629), SPH_C32(0x6bfd4f3b), SPH_C32(0x13da3d71), + SPH_C32(0x2e0f5bd4) }, + { SPH_C32(0xb6ec0000), SPH_C32(0xa28c0000), SPH_C32(0x67cd0000), + SPH_C32(0x7b4f00b1), SPH_C32(0x3ae1284a), SPH_C32(0x8dd13e7e), + SPH_C32(0xe022c78e), SPH_C32(0x8c47a9d0), SPH_C32(0x59a80000), + SPH_C32(0xec410000), SPH_C32(0xc28b0000), SPH_C32(0xb5f8015b), + SPH_C32(0x18cd44a2), SPH_C32(0xa3a8ed80), SPH_C32(0xa02f1b7b), + SPH_C32(0x413d3a51) }, + { SPH_C32(0x1e360000), SPH_C32(0x34320000), SPH_C32(0x3bd00000), + SPH_C32(0x7c9500b3), SPH_C32(0x4787bdc9), SPH_C32(0x92494ef4), + SPH_C32(0x5b444f86), SPH_C32(0x56c029d0), SPH_C32(0xf24f0000), + SPH_C32(0x724c0000), SPH_C32(0x6dac0000), SPH_C32(0x88e0015e), + SPH_C32(0x34825b71), SPH_C32(0xd75efb15), SPH_C32(0x15ec5c90), + SPH_C32(0x7d60c5af) }, + { SPH_C32(0xb77f0000), SPH_C32(0x450e0000), SPH_C32(0x8a360000), + SPH_C32(0xb44300ba), SPH_C32(0xb731a512), SPH_C32(0x31728a50), + SPH_C32(0xe614a66f), SPH_C32(0xdf2837ab), SPH_C32(0xcb800000), + SPH_C32(0x30c40000), SPH_C32(0x95710000), SPH_C32(0xe3240158), + SPH_C32(0xa22467b4), SPH_C32(0xf9474e8c), SPH_C32(0x30e1ec29), + SPH_C32(0x3a2b4f86) }, + { SPH_C32(0x1fa50000), SPH_C32(0xd3b00000), SPH_C32(0xd62b0000), + SPH_C32(0xb39900b8), SPH_C32(0xca573091), SPH_C32(0x2eeafada), + SPH_C32(0x5d722e67), SPH_C32(0x05afb7ab), SPH_C32(0x60670000), + SPH_C32(0xaec90000), SPH_C32(0x3a560000), SPH_C32(0xde3c015d), + SPH_C32(0x8e6b7867), SPH_C32(0x8db15819), SPH_C32(0x8522abc2), + SPH_C32(0x0676b078) }, + { SPH_C32(0x95bb0000), SPH_C32(0x81450000), SPH_C32(0x3b240000), + SPH_C32(0x48db0140), SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), + SPH_C32(0x62c91877), SPH_C32(0xe7e00a94), SPH_C32(0xee930000), + SPH_C32(0xd6070000), SPH_C32(0x92c10000), SPH_C32(0x2b9801e0), + SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), SPH_C32(0x45312374), + SPH_C32(0x201f6a64) }, + { SPH_C32(0x3d610000), SPH_C32(0x17fb0000), SPH_C32(0x67390000), + SPH_C32(0x4f010142), SPH_C32(0x77ecf9d0), SPH_C32(0x496d1e66), + SPH_C32(0xd9af907f), SPH_C32(0x3d678a94), SPH_C32(0x45740000), + SPH_C32(0x480a0000), SPH_C32(0x3de60000), SPH_C32(0x168001e5), + SPH_C32(0xb81e37af), SPH_C32(0x4f9aedc2), SPH_C32(0xf0f2649f), + SPH_C32(0x1c42959a) }, + { SPH_C32(0x94280000), SPH_C32(0x66c70000), SPH_C32(0xd6df0000), + SPH_C32(0x87d7014b), SPH_C32(0x875ae10b), SPH_C32(0xea56dac2), + SPH_C32(0x64ff7996), SPH_C32(0xb48f94ef), SPH_C32(0x7cbb0000), + SPH_C32(0x0a820000), SPH_C32(0xc53b0000), SPH_C32(0x7d4401e3), + SPH_C32(0x2eb80b6a), SPH_C32(0x6183585b), SPH_C32(0xd5ffd426), + SPH_C32(0x5b091fb3) }, + { SPH_C32(0x3cf20000), SPH_C32(0xf0790000), SPH_C32(0x8ac20000), + SPH_C32(0x800d0149), SPH_C32(0xfa3c7488), SPH_C32(0xf5ceaa48), + SPH_C32(0xdf99f19e), SPH_C32(0x6e0814ef), SPH_C32(0xd75c0000), + SPH_C32(0x948f0000), SPH_C32(0x6a1c0000), SPH_C32(0x405c01e6), + SPH_C32(0x02f714b9), SPH_C32(0x15754ece), SPH_C32(0x603c93cd), + SPH_C32(0x6754e04d) }, + { SPH_C32(0x07930000), SPH_C32(0x5dc00000), SPH_C32(0x6cde0000), + SPH_C32(0x1e070143), SPH_C32(0xb0634f45), SPH_C32(0x0c1acde0), + SPH_C32(0xf207ef25), SPH_C32(0x9cf67f43), SPH_C32(0x7d280000), + SPH_C32(0xed000000), SPH_C32(0x28c00000), SPH_C32(0xb24801e8), + SPH_C32(0xa3688632), SPH_C32(0xdd20ec75), SPH_C32(0xd3c9b5c7), + SPH_C32(0x086681c8) }, + { SPH_C32(0xaf490000), SPH_C32(0xcb7e0000), SPH_C32(0x30c30000), + SPH_C32(0x19dd0141), SPH_C32(0xcd05dac6), SPH_C32(0x1382bd6a), + SPH_C32(0x4961672d), SPH_C32(0x4671ff43), SPH_C32(0xd6cf0000), + SPH_C32(0x730d0000), SPH_C32(0x87e70000), SPH_C32(0x8f5001ed), + SPH_C32(0x8f2799e1), SPH_C32(0xa9d6fae0), SPH_C32(0x660af22c), + SPH_C32(0x343b7e36) }, + { SPH_C32(0x06000000), SPH_C32(0xba420000), SPH_C32(0x81250000), + SPH_C32(0xd10b0148), SPH_C32(0x3db3c21d), SPH_C32(0xb0b979ce), + SPH_C32(0xf4318ec4), SPH_C32(0xcf99e138), SPH_C32(0xef000000), + SPH_C32(0x31850000), SPH_C32(0x7f3a0000), SPH_C32(0xe49401eb), + SPH_C32(0x1981a524), SPH_C32(0x87cf4f79), SPH_C32(0x43074295), + SPH_C32(0x7370f41f) }, + { SPH_C32(0xaeda0000), SPH_C32(0x2cfc0000), SPH_C32(0xdd380000), + SPH_C32(0xd6d1014a), SPH_C32(0x40d5579e), SPH_C32(0xaf210944), + SPH_C32(0x4f5706cc), SPH_C32(0x151e6138), SPH_C32(0x44e70000), + SPH_C32(0xaf880000), SPH_C32(0xd01d0000), SPH_C32(0xd98c01ee), + SPH_C32(0x35cebaf7), SPH_C32(0xf33959ec), SPH_C32(0xf6c4057e), + SPH_C32(0x4f2d0be1) }, + { SPH_C32(0xca130000), SPH_C32(0xd7460000), SPH_C32(0x788a0000), + SPH_C32(0x2c280153), SPH_C32(0x2ff4eaec), SPH_C32(0x45e4faa2), + SPH_C32(0x36d78dc8), SPH_C32(0x6944d1fd), SPH_C32(0xeed70000), + SPH_C32(0xa94f0000), SPH_C32(0x48bd0000), SPH_C32(0x01bb01e1), + SPH_C32(0xaffce1b0), SPH_C32(0x92da67d0), SPH_C32(0x463bbd14), + SPH_C32(0x9e150dfa) }, + { SPH_C32(0x62c90000), SPH_C32(0x41f80000), SPH_C32(0x24970000), + SPH_C32(0x2bf20151), SPH_C32(0x52927f6f), SPH_C32(0x5a7c8a28), + SPH_C32(0x8db105c0), SPH_C32(0xb3c351fd), SPH_C32(0x45300000), + SPH_C32(0x37420000), SPH_C32(0xe79a0000), SPH_C32(0x3ca301e4), + SPH_C32(0x83b3fe63), SPH_C32(0xe62c7145), SPH_C32(0xf3f8faff), + SPH_C32(0xa248f204) }, + { SPH_C32(0xcb800000), SPH_C32(0x30c40000), SPH_C32(0x95710000), + SPH_C32(0xe3240158), SPH_C32(0xa22467b4), SPH_C32(0xf9474e8c), + SPH_C32(0x30e1ec29), SPH_C32(0x3a2b4f86), SPH_C32(0x7cff0000), + SPH_C32(0x75ca0000), SPH_C32(0x1f470000), SPH_C32(0x576701e2), + SPH_C32(0x1515c2a6), SPH_C32(0xc835c4dc), SPH_C32(0xd6f54a46), + SPH_C32(0xe503782d) }, + { SPH_C32(0x635a0000), SPH_C32(0xa67a0000), SPH_C32(0xc96c0000), + SPH_C32(0xe4fe015a), SPH_C32(0xdf42f237), SPH_C32(0xe6df3e06), + SPH_C32(0x8b876421), SPH_C32(0xe0accf86), SPH_C32(0xd7180000), + SPH_C32(0xebc70000), SPH_C32(0xb0600000), SPH_C32(0x6a7f01e7), + SPH_C32(0x395add75), SPH_C32(0xbcc3d249), SPH_C32(0x63360dad), + SPH_C32(0xd95e87d3) }, + { SPH_C32(0x583b0000), SPH_C32(0x0bc30000), SPH_C32(0x2f700000), + SPH_C32(0x7af40150), SPH_C32(0x951dc9fa), SPH_C32(0x1f0b59ae), + SPH_C32(0xa6197a9a), SPH_C32(0x1252a42a), SPH_C32(0x7d6c0000), + SPH_C32(0x92480000), SPH_C32(0xf2bc0000), SPH_C32(0x986b01e9), + SPH_C32(0x98c54ffe), SPH_C32(0x749670f2), SPH_C32(0xd0c32ba7), + SPH_C32(0xb66ce656) }, + { SPH_C32(0xf0e10000), SPH_C32(0x9d7d0000), SPH_C32(0x736d0000), + SPH_C32(0x7d2e0152), SPH_C32(0xe87b5c79), SPH_C32(0x00932924), + SPH_C32(0x1d7ff292), SPH_C32(0xc8d5242a), SPH_C32(0xd68b0000), + SPH_C32(0x0c450000), SPH_C32(0x5d9b0000), SPH_C32(0xa57301ec), + SPH_C32(0xb48a502d), SPH_C32(0x00606667), SPH_C32(0x65006c4c), + SPH_C32(0x8a3119a8) }, + { SPH_C32(0x59a80000), SPH_C32(0xec410000), SPH_C32(0xc28b0000), + SPH_C32(0xb5f8015b), SPH_C32(0x18cd44a2), SPH_C32(0xa3a8ed80), + SPH_C32(0xa02f1b7b), SPH_C32(0x413d3a51), SPH_C32(0xef440000), + SPH_C32(0x4ecd0000), SPH_C32(0xa5460000), SPH_C32(0xceb701ea), + SPH_C32(0x222c6ce8), SPH_C32(0x2e79d3fe), SPH_C32(0x400ddcf5), + SPH_C32(0xcd7a9381) }, + { SPH_C32(0xf1720000), SPH_C32(0x7aff0000), SPH_C32(0x9e960000), + SPH_C32(0xb2220159), SPH_C32(0x65abd121), SPH_C32(0xbc309d0a), + SPH_C32(0x1b499373), SPH_C32(0x9bbaba51), SPH_C32(0x44a30000), + SPH_C32(0xd0c00000), SPH_C32(0x0a610000), SPH_C32(0xf3af01ef), + SPH_C32(0x0e63733b), SPH_C32(0x5a8fc56b), SPH_C32(0xf5ce9b1e), + SPH_C32(0xf1276c7f) }, + { SPH_C32(0x95ff0000), SPH_C32(0xfe0d0000), SPH_C32(0xe1580000), + SPH_C32(0x62f80141), SPH_C32(0x3127a59f), SPH_C32(0xff43f26b), + SPH_C32(0x61c38617), SPH_C32(0x59ea6d0a), SPH_C32(0xb17f0000), + SPH_C32(0xff4c0000), SPH_C32(0x0b130000), SPH_C32(0x654801f2), + SPH_C32(0x8a82670f), SPH_C32(0x81cbf39e), SPH_C32(0x122528ab), + SPH_C32(0x10b1d693) }, + { SPH_C32(0x3d250000), SPH_C32(0x68b30000), SPH_C32(0xbd450000), + SPH_C32(0x65220143), SPH_C32(0x4c41301c), SPH_C32(0xe0db82e1), + SPH_C32(0xdaa50e1f), SPH_C32(0x836ded0a), SPH_C32(0x1a980000), + SPH_C32(0x61410000), SPH_C32(0xa4340000), SPH_C32(0x585001f7), + SPH_C32(0xa6cd78dc), SPH_C32(0xf53de50b), SPH_C32(0xa7e66f40), + SPH_C32(0x2cec296d) }, + { SPH_C32(0x946c0000), SPH_C32(0x198f0000), SPH_C32(0x0ca30000), + SPH_C32(0xadf4014a), SPH_C32(0xbcf728c7), SPH_C32(0x43e04645), + SPH_C32(0x67f5e7f6), SPH_C32(0x0a85f371), SPH_C32(0x23570000), + SPH_C32(0x23c90000), SPH_C32(0x5ce90000), SPH_C32(0x339401f1), + SPH_C32(0x306b4419), SPH_C32(0xdb245092), SPH_C32(0x82ebdff9), + SPH_C32(0x6ba7a344) }, + { SPH_C32(0x3cb60000), SPH_C32(0x8f310000), SPH_C32(0x50be0000), + SPH_C32(0xaa2e0148), SPH_C32(0xc191bd44), SPH_C32(0x5c7836cf), + SPH_C32(0xdc936ffe), SPH_C32(0xd0027371), SPH_C32(0x88b00000), + SPH_C32(0xbdc40000), SPH_C32(0xf3ce0000), SPH_C32(0x0e8c01f4), + SPH_C32(0x1c245bca), SPH_C32(0xafd24607), SPH_C32(0x37289812), + SPH_C32(0x57fa5cba) }, + { SPH_C32(0x07d70000), SPH_C32(0x22880000), SPH_C32(0xb6a20000), + SPH_C32(0x34240142), SPH_C32(0x8bce8689), SPH_C32(0xa5ac5167), + SPH_C32(0xf10d7145), SPH_C32(0x22fc18dd), SPH_C32(0x22c40000), + SPH_C32(0xc44b0000), SPH_C32(0xb1120000), SPH_C32(0xfc9801fa), + SPH_C32(0xbdbbc941), SPH_C32(0x6787e4bc), SPH_C32(0x84ddbe18), + SPH_C32(0x38c83d3f) }, + { SPH_C32(0xaf0d0000), SPH_C32(0xb4360000), SPH_C32(0xeabf0000), + SPH_C32(0x33fe0140), SPH_C32(0xf6a8130a), SPH_C32(0xba3421ed), + SPH_C32(0x4a6bf94d), SPH_C32(0xf87b98dd), SPH_C32(0x89230000), + SPH_C32(0x5a460000), SPH_C32(0x1e350000), SPH_C32(0xc18001ff), + SPH_C32(0x91f4d692), SPH_C32(0x1371f229), SPH_C32(0x311ef9f3), + SPH_C32(0x0495c2c1) }, + { SPH_C32(0x06440000), SPH_C32(0xc50a0000), SPH_C32(0x5b590000), + SPH_C32(0xfb280149), SPH_C32(0x061e0bd1), SPH_C32(0x190fe549), + SPH_C32(0xf73b10a4), SPH_C32(0x719386a6), SPH_C32(0xb0ec0000), + SPH_C32(0x18ce0000), SPH_C32(0xe6e80000), SPH_C32(0xaa4401f9), + SPH_C32(0x0752ea57), SPH_C32(0x3d6847b0), SPH_C32(0x1413494a), + SPH_C32(0x43de48e8) }, + { SPH_C32(0xae9e0000), SPH_C32(0x53b40000), SPH_C32(0x07440000), + SPH_C32(0xfcf2014b), SPH_C32(0x7b789e52), SPH_C32(0x069795c3), + SPH_C32(0x4c5d98ac), SPH_C32(0xab1406a6), SPH_C32(0x1b0b0000), + SPH_C32(0x86c30000), SPH_C32(0x49cf0000), SPH_C32(0x975c01fc), + SPH_C32(0x2b1df584), SPH_C32(0x499e5125), SPH_C32(0xa1d00ea1), + SPH_C32(0x7f83b716) }, + { SPH_C32(0xca570000), SPH_C32(0xa80e0000), SPH_C32(0xa2f60000), + SPH_C32(0x060b0152), SPH_C32(0x14592320), SPH_C32(0xec526625), + SPH_C32(0x35dd13a8), SPH_C32(0xd74eb663), SPH_C32(0xb13b0000), + SPH_C32(0x80040000), SPH_C32(0xd16f0000), SPH_C32(0x4f6b01f3), + SPH_C32(0xb12faec3), SPH_C32(0x287d6f19), SPH_C32(0x112fb6cb), + SPH_C32(0xaebbb10d) }, + { SPH_C32(0x628d0000), SPH_C32(0x3eb00000), SPH_C32(0xfeeb0000), + SPH_C32(0x01d10150), SPH_C32(0x693fb6a3), SPH_C32(0xf3ca16af), + SPH_C32(0x8ebb9ba0), SPH_C32(0x0dc93663), SPH_C32(0x1adc0000), + SPH_C32(0x1e090000), SPH_C32(0x7e480000), SPH_C32(0x727301f6), + SPH_C32(0x9d60b110), SPH_C32(0x5c8b798c), SPH_C32(0xa4ecf120), + SPH_C32(0x92e64ef3) }, + { SPH_C32(0xcbc40000), SPH_C32(0x4f8c0000), SPH_C32(0x4f0d0000), + SPH_C32(0xc9070159), SPH_C32(0x9989ae78), SPH_C32(0x50f1d20b), + SPH_C32(0x33eb7249), SPH_C32(0x84212818), SPH_C32(0x23130000), + SPH_C32(0x5c810000), SPH_C32(0x86950000), SPH_C32(0x19b701f0), + SPH_C32(0x0bc68dd5), SPH_C32(0x7292cc15), SPH_C32(0x81e14199), + SPH_C32(0xd5adc4da) }, + { SPH_C32(0x631e0000), SPH_C32(0xd9320000), SPH_C32(0x13100000), + SPH_C32(0xcedd015b), SPH_C32(0xe4ef3bfb), SPH_C32(0x4f69a281), + SPH_C32(0x888dfa41), SPH_C32(0x5ea6a818), SPH_C32(0x88f40000), + SPH_C32(0xc28c0000), SPH_C32(0x29b20000), SPH_C32(0x24af01f5), + SPH_C32(0x27899206), SPH_C32(0x0664da80), SPH_C32(0x34220672), + SPH_C32(0xe9f03b24) }, + { SPH_C32(0x587f0000), SPH_C32(0x748b0000), SPH_C32(0xf50c0000), + SPH_C32(0x50d70151), SPH_C32(0xaeb00036), SPH_C32(0xb6bdc529), + SPH_C32(0xa513e4fa), SPH_C32(0xac58c3b4), SPH_C32(0x22800000), + SPH_C32(0xbb030000), SPH_C32(0x6b6e0000), SPH_C32(0xd6bb01fb), + SPH_C32(0x8616008d), SPH_C32(0xce31783b), SPH_C32(0x87d72078), + SPH_C32(0x86c25aa1) }, + { SPH_C32(0xf0a50000), SPH_C32(0xe2350000), SPH_C32(0xa9110000), + SPH_C32(0x570d0153), SPH_C32(0xd3d695b5), SPH_C32(0xa925b5a3), + SPH_C32(0x1e756cf2), SPH_C32(0x76df43b4), SPH_C32(0x89670000), + SPH_C32(0x250e0000), SPH_C32(0xc4490000), SPH_C32(0xeba301fe), + SPH_C32(0xaa591f5e), SPH_C32(0xbac76eae), SPH_C32(0x32146793), + SPH_C32(0xba9fa55f) }, + { SPH_C32(0x59ec0000), SPH_C32(0x93090000), SPH_C32(0x18f70000), + SPH_C32(0x9fdb015a), SPH_C32(0x23608d6e), SPH_C32(0x0a1e7107), + SPH_C32(0xa325851b), SPH_C32(0xff375dcf), SPH_C32(0xb0a80000), + SPH_C32(0x67860000), SPH_C32(0x3c940000), SPH_C32(0x806701f8), + SPH_C32(0x3cff239b), SPH_C32(0x94dedb37), SPH_C32(0x1719d72a), + SPH_C32(0xfdd42f76) }, + { SPH_C32(0xf1360000), SPH_C32(0x05b70000), SPH_C32(0x44ea0000), + SPH_C32(0x98010158), SPH_C32(0x5e0618ed), SPH_C32(0x1586018d), + SPH_C32(0x18430d13), SPH_C32(0x25b0ddcf), SPH_C32(0x1b4f0000), + SPH_C32(0xf98b0000), SPH_C32(0x93b30000), SPH_C32(0xbd7f01fd), + SPH_C32(0x10b03c48), SPH_C32(0xe028cda2), SPH_C32(0xa2da90c1), + SPH_C32(0xc189d088) } +}; + +static const sph_u32 T512_63[2][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x033d0000), SPH_C32(0x08b30000), SPH_C32(0xf33a0000), + SPH_C32(0x3ac20007), SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), + SPH_C32(0x0ea5cfe3), SPH_C32(0xe6da7ffe), SPH_C32(0xa8da0000), + SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), SPH_C32(0x07da0002), + SPH_C32(0x7d669583), SPH_C32(0x1f98708a), SPH_C32(0xbb668808), + SPH_C32(0xda878000) } +}; + +#define INPUT_BIG do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T512_0[acc >> 1][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + m8 = rp[8]; \ + m9 = rp[9]; \ + mA = rp[10]; \ + mB = rp[11]; \ + mC = rp[12]; \ + mD = rp[13]; \ + mE = rp[14]; \ + mF = rp[15]; \ + acc = (acc << 8) | buf[1]; \ + rp = &T512_7[(acc >> 2) & 0x7f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[2]; \ + rp = &T512_14[(acc >> 3) & 0x7f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[3]; \ + rp = &T512_21[(acc >> 4) & 0x7f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[4]; \ + rp = &T512_28[(acc >> 5) & 0x7f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[5]; \ + rp = &T512_35[(acc >> 6) & 0x7f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = (acc << 8) | buf[6]; \ + rp = &T512_42[(acc >> 7) & 0x7f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_49[acc & 0x7f][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[7]; \ + rp = &T512_56[acc >> 1][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + rp = &T512_63[acc & 0x01][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + } while (0) + +#endif + +#if SPH_HAMSI_EXPAND_BIG == 8 + +static const sph_u32 T512_0[256][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xef0b0270), SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), + SPH_C32(0x69490000), SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), + SPH_C32(0x66140a51), SPH_C32(0x924f5d0a), SPH_C32(0xc96b0030), + SPH_C32(0xe7250000), SPH_C32(0x2f840000), SPH_C32(0x264f0000), + SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), SPH_C32(0x509f6984), + SPH_C32(0x9e69af68) }, + { SPH_C32(0xc96b0030), SPH_C32(0xe7250000), SPH_C32(0x2f840000), + SPH_C32(0x264f0000), SPH_C32(0x08695bf9), SPH_C32(0x6dfcf137), + SPH_C32(0x509f6984), SPH_C32(0x9e69af68), SPH_C32(0x26600240), + SPH_C32(0xddd80000), SPH_C32(0x722a0000), SPH_C32(0x4f060000), + SPH_C32(0x936667ff), SPH_C32(0x29f944ce), SPH_C32(0x368b63d5), + SPH_C32(0x0c26f262) }, + { SPH_C32(0x26600240), SPH_C32(0xddd80000), SPH_C32(0x722a0000), + SPH_C32(0x4f060000), SPH_C32(0x936667ff), SPH_C32(0x29f944ce), + SPH_C32(0x368b63d5), SPH_C32(0x0c26f262), SPH_C32(0xef0b0270), + SPH_C32(0x3afd0000), SPH_C32(0x5dae0000), SPH_C32(0x69490000), + SPH_C32(0x9b0f3c06), SPH_C32(0x4405b5f9), SPH_C32(0x66140a51), + SPH_C32(0x924f5d0a) }, + { SPH_C32(0x145a3c00), SPH_C32(0xb9e90000), SPH_C32(0x61270000), + SPH_C32(0xf1610000), SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), + SPH_C32(0x47a96720), SPH_C32(0xe18e24c5), SPH_C32(0x23671400), + SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), SPH_C32(0xfb750000), + SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), SPH_C32(0x02c40a3f), + SPH_C32(0xdc24e61f) }, + { SPH_C32(0xfb513e70), SPH_C32(0x83140000), SPH_C32(0x3c890000), + SPH_C32(0x98280000), SPH_C32(0x556e016a), SPH_C32(0xf44c8881), + SPH_C32(0x21bd6d71), SPH_C32(0x73c179cf), SPH_C32(0xea0c1430), + SPH_C32(0x2f9c0000), SPH_C32(0xdb430000), SPH_C32(0xdd3a0000), + SPH_C32(0x7ba47f9c), SPH_C32(0x955a547e), SPH_C32(0x525b63bb), + SPH_C32(0x424d4977) }, + { SPH_C32(0xdd313c30), SPH_C32(0x5ecc0000), SPH_C32(0x4ea30000), + SPH_C32(0xd72e0000), SPH_C32(0xc6086695), SPH_C32(0xddb5cc4f), + SPH_C32(0x17360ea4), SPH_C32(0x7fe78bad), SPH_C32(0x05071640), + SPH_C32(0x15610000), SPH_C32(0x86ed0000), SPH_C32(0xb4730000), + SPH_C32(0xe0ab439a), SPH_C32(0xd15fe187), SPH_C32(0x344f69ea), + SPH_C32(0xd002147d) }, + { SPH_C32(0x323a3e40), SPH_C32(0x64310000), SPH_C32(0x130d0000), + SPH_C32(0xbe670000), SPH_C32(0x5d075a93), SPH_C32(0x99b079b6), + SPH_C32(0x712204f5), SPH_C32(0xeda8d6a7), SPH_C32(0xcc6c1670), + SPH_C32(0xf2440000), SPH_C32(0xa9690000), SPH_C32(0x923c0000), + SPH_C32(0xe8c21863), SPH_C32(0xbca310b0), SPH_C32(0x64d0006e), + SPH_C32(0x4e6bbb15) }, + { SPH_C32(0x23671400), SPH_C32(0xc8b90000), SPH_C32(0xf4c70000), + SPH_C32(0xfb750000), SPH_C32(0x73cd2465), SPH_C32(0xf8a6a549), + SPH_C32(0x02c40a3f), SPH_C32(0xdc24e61f), SPH_C32(0x373d2800), + SPH_C32(0x71500000), SPH_C32(0x95e00000), SPH_C32(0x0a140000), + SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), SPH_C32(0x456d6d1f), + SPH_C32(0x3daac2da) }, + { SPH_C32(0xcc6c1670), SPH_C32(0xf2440000), SPH_C32(0xa9690000), + SPH_C32(0x923c0000), SPH_C32(0xe8c21863), SPH_C32(0xbca310b0), + SPH_C32(0x64d0006e), SPH_C32(0x4e6bbb15), SPH_C32(0xfe562830), + SPH_C32(0x96750000), SPH_C32(0xba640000), SPH_C32(0x2c5b0000), + SPH_C32(0xb5c542f0), SPH_C32(0x25136906), SPH_C32(0x15f2049b), + SPH_C32(0xa3c36db2) }, + { SPH_C32(0xea0c1430), SPH_C32(0x2f9c0000), SPH_C32(0xdb430000), + SPH_C32(0xdd3a0000), SPH_C32(0x7ba47f9c), SPH_C32(0x955a547e), + SPH_C32(0x525b63bb), SPH_C32(0x424d4977), SPH_C32(0x115d2a40), + SPH_C32(0xac880000), SPH_C32(0xe7ca0000), SPH_C32(0x45120000), + SPH_C32(0x2eca7ef6), SPH_C32(0x6116dcff), SPH_C32(0x73e60eca), + SPH_C32(0x318c30b8) }, + { SPH_C32(0x05071640), SPH_C32(0x15610000), SPH_C32(0x86ed0000), + SPH_C32(0xb4730000), SPH_C32(0xe0ab439a), SPH_C32(0xd15fe187), + SPH_C32(0x344f69ea), SPH_C32(0xd002147d), SPH_C32(0xd8362a70), + SPH_C32(0x4bad0000), SPH_C32(0xc84e0000), SPH_C32(0x635d0000), + SPH_C32(0x26a3250f), SPH_C32(0x0cea2dc8), SPH_C32(0x2379674e), + SPH_C32(0xafe59fd0) }, + { SPH_C32(0x373d2800), SPH_C32(0x71500000), SPH_C32(0x95e00000), + SPH_C32(0x0a140000), SPH_C32(0xbdac1909), SPH_C32(0x48ef9831), + SPH_C32(0x456d6d1f), SPH_C32(0x3daac2da), SPH_C32(0x145a3c00), + SPH_C32(0xb9e90000), SPH_C32(0x61270000), SPH_C32(0xf1610000), + SPH_C32(0xce613d6c), SPH_C32(0xb0493d78), SPH_C32(0x47a96720), + SPH_C32(0xe18e24c5) }, + { SPH_C32(0xd8362a70), SPH_C32(0x4bad0000), SPH_C32(0xc84e0000), + SPH_C32(0x635d0000), SPH_C32(0x26a3250f), SPH_C32(0x0cea2dc8), + SPH_C32(0x2379674e), SPH_C32(0xafe59fd0), SPH_C32(0xdd313c30), + SPH_C32(0x5ecc0000), SPH_C32(0x4ea30000), SPH_C32(0xd72e0000), + SPH_C32(0xc6086695), SPH_C32(0xddb5cc4f), SPH_C32(0x17360ea4), + SPH_C32(0x7fe78bad) }, + { SPH_C32(0xfe562830), SPH_C32(0x96750000), SPH_C32(0xba640000), + SPH_C32(0x2c5b0000), SPH_C32(0xb5c542f0), SPH_C32(0x25136906), + SPH_C32(0x15f2049b), SPH_C32(0xa3c36db2), SPH_C32(0x323a3e40), + SPH_C32(0x64310000), SPH_C32(0x130d0000), SPH_C32(0xbe670000), + SPH_C32(0x5d075a93), SPH_C32(0x99b079b6), SPH_C32(0x712204f5), + SPH_C32(0xeda8d6a7) }, + { SPH_C32(0x115d2a40), SPH_C32(0xac880000), SPH_C32(0xe7ca0000), + SPH_C32(0x45120000), SPH_C32(0x2eca7ef6), SPH_C32(0x6116dcff), + SPH_C32(0x73e60eca), SPH_C32(0x318c30b8), SPH_C32(0xfb513e70), + SPH_C32(0x83140000), SPH_C32(0x3c890000), SPH_C32(0x98280000), + SPH_C32(0x556e016a), SPH_C32(0xf44c8881), SPH_C32(0x21bd6d71), + SPH_C32(0x73c179cf) }, + { SPH_C32(0x54285c00), SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), + SPH_C32(0xa1c50000), SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), + SPH_C32(0x6bb0419d), SPH_C32(0x551b3782), SPH_C32(0x9cbb1800), + SPH_C32(0xb0d30000), SPH_C32(0x92510000), SPH_C32(0xed930000), + SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), SPH_C32(0x430633da), + SPH_C32(0x78cace29) }, + { SPH_C32(0xbb235e70), SPH_C32(0xd0100000), SPH_C32(0x98780000), + SPH_C32(0xc88c0000), SPH_C32(0x28ad5b76), SPH_C32(0xd0a07118), + SPH_C32(0x0da44bcc), SPH_C32(0xc7546a88), SPH_C32(0x55d01830), + SPH_C32(0x57f60000), SPH_C32(0xbdd50000), SPH_C32(0xcbdc0000), + SPH_C32(0x515318bc), SPH_C32(0x8ce824c3), SPH_C32(0x13995a5e), + SPH_C32(0xe6a36141) }, + { SPH_C32(0x9d435c30), SPH_C32(0x0dc80000), SPH_C32(0xea520000), + SPH_C32(0x878a0000), SPH_C32(0xbbcb3c89), SPH_C32(0xf95935d6), + SPH_C32(0x3b2f2819), SPH_C32(0xcb7298ea), SPH_C32(0xbadb1a40), + SPH_C32(0x6d0b0000), SPH_C32(0xe07b0000), SPH_C32(0xa2950000), + SPH_C32(0xca5c24ba), SPH_C32(0xc8ed913a), SPH_C32(0x758d500f), + SPH_C32(0x74ec3c4b) }, + { SPH_C32(0x72485e40), SPH_C32(0x37350000), SPH_C32(0xb7fc0000), + SPH_C32(0xeec30000), SPH_C32(0x20c4008f), SPH_C32(0xbd5c802f), + SPH_C32(0x5d3b2248), SPH_C32(0x593dc5e0), SPH_C32(0x73b01a70), + SPH_C32(0x8a2e0000), SPH_C32(0xcfff0000), SPH_C32(0x84da0000), + SPH_C32(0xc2357f43), SPH_C32(0xa511600d), SPH_C32(0x2512398b), + SPH_C32(0xea859323) }, + { SPH_C32(0x40726000), SPH_C32(0x53040000), SPH_C32(0xa4f10000), + SPH_C32(0x50a40000), SPH_C32(0x7dc35a1c), SPH_C32(0x24ecf999), + SPH_C32(0x2c1926bd), SPH_C32(0xb4951347), SPH_C32(0xbfdc0c00), + SPH_C32(0x786a0000), SPH_C32(0x66960000), SPH_C32(0x16e60000), + SPH_C32(0x2af76720), SPH_C32(0x19b270bd), SPH_C32(0x41c239e5), + SPH_C32(0xa4ee2836) }, + { SPH_C32(0xaf796270), SPH_C32(0x69f90000), SPH_C32(0xf95f0000), + SPH_C32(0x39ed0000), SPH_C32(0xe6cc661a), SPH_C32(0x60e94c60), + SPH_C32(0x4a0d2cec), SPH_C32(0x26da4e4d), SPH_C32(0x76b70c30), + SPH_C32(0x9f4f0000), SPH_C32(0x49120000), SPH_C32(0x30a90000), + SPH_C32(0x229e3cd9), SPH_C32(0x744e818a), SPH_C32(0x115d5061), + SPH_C32(0x3a87875e) }, + { SPH_C32(0x89196030), SPH_C32(0xb4210000), SPH_C32(0x8b750000), + SPH_C32(0x76eb0000), SPH_C32(0x75aa01e5), SPH_C32(0x491008ae), + SPH_C32(0x7c864f39), SPH_C32(0x2afcbc2f), SPH_C32(0x99bc0e40), + SPH_C32(0xa5b20000), SPH_C32(0x14bc0000), SPH_C32(0x59e00000), + SPH_C32(0xb99100df), SPH_C32(0x304b3473), SPH_C32(0x77495a30), + SPH_C32(0xa8c8da54) }, + { SPH_C32(0x66126240), SPH_C32(0x8edc0000), SPH_C32(0xd6db0000), + SPH_C32(0x1fa20000), SPH_C32(0xeea53de3), SPH_C32(0x0d15bd57), + SPH_C32(0x1a924568), SPH_C32(0xb8b3e125), SPH_C32(0x50d70e70), + SPH_C32(0x42970000), SPH_C32(0x3b380000), SPH_C32(0x7faf0000), + SPH_C32(0xb1f85b26), SPH_C32(0x5db7c544), SPH_C32(0x27d633b4), + SPH_C32(0x36a1753c) }, + { SPH_C32(0x774f4800), SPH_C32(0x22540000), SPH_C32(0x31110000), + SPH_C32(0x5ab00000), SPH_C32(0xc06f4315), SPH_C32(0x6c0361a8), + SPH_C32(0x69744ba2), SPH_C32(0x893fd19d), SPH_C32(0xab863000), + SPH_C32(0xc1830000), SPH_C32(0x07b10000), SPH_C32(0xe7870000), + SPH_C32(0xe4965a4c), SPH_C32(0xa9fb4dc5), SPH_C32(0x066b5ec5), + SPH_C32(0x45600cf3) }, + { SPH_C32(0x98444a70), SPH_C32(0x18a90000), SPH_C32(0x6cbf0000), + SPH_C32(0x33f90000), SPH_C32(0x5b607f13), SPH_C32(0x2806d451), + SPH_C32(0x0f6041f3), SPH_C32(0x1b708c97), SPH_C32(0x62ed3030), + SPH_C32(0x26a60000), SPH_C32(0x28350000), SPH_C32(0xc1c80000), + SPH_C32(0xecff01b5), SPH_C32(0xc407bcf2), SPH_C32(0x56f43741), + SPH_C32(0xdb09a39b) }, + { SPH_C32(0xbe244830), SPH_C32(0xc5710000), SPH_C32(0x1e950000), + SPH_C32(0x7cff0000), SPH_C32(0xc80618ec), SPH_C32(0x01ff909f), + SPH_C32(0x39eb2226), SPH_C32(0x17567ef5), SPH_C32(0x8de63240), + SPH_C32(0x1c5b0000), SPH_C32(0x759b0000), SPH_C32(0xa8810000), + SPH_C32(0x77f03db3), SPH_C32(0x8002090b), SPH_C32(0x30e03d10), + SPH_C32(0x4946fe91) }, + { SPH_C32(0x512f4a40), SPH_C32(0xff8c0000), SPH_C32(0x433b0000), + SPH_C32(0x15b60000), SPH_C32(0x530924ea), SPH_C32(0x45fa2566), + SPH_C32(0x5fff2877), SPH_C32(0x851923ff), SPH_C32(0x448d3270), + SPH_C32(0xfb7e0000), SPH_C32(0x5a1f0000), SPH_C32(0x8ece0000), + SPH_C32(0x7f99664a), SPH_C32(0xedfef83c), SPH_C32(0x607f5494), + SPH_C32(0xd72f51f9) }, + { SPH_C32(0x63157400), SPH_C32(0x9bbd0000), SPH_C32(0x50360000), + SPH_C32(0xabd10000), SPH_C32(0x0e0e7e79), SPH_C32(0xdc4a5cd0), + SPH_C32(0x2edd2c82), SPH_C32(0x68b1f558), SPH_C32(0x88e12400), + SPH_C32(0x093a0000), SPH_C32(0xf3760000), SPH_C32(0x1cf20000), + SPH_C32(0x975b7e29), SPH_C32(0x515de88c), SPH_C32(0x04af54fa), + SPH_C32(0x9944eaec) }, + { SPH_C32(0x8c1e7670), SPH_C32(0xa1400000), SPH_C32(0x0d980000), + SPH_C32(0xc2980000), SPH_C32(0x9501427f), SPH_C32(0x984fe929), + SPH_C32(0x48c926d3), SPH_C32(0xfafea852), SPH_C32(0x418a2430), + SPH_C32(0xee1f0000), SPH_C32(0xdcf20000), SPH_C32(0x3abd0000), + SPH_C32(0x9f3225d0), SPH_C32(0x3ca119bb), SPH_C32(0x54303d7e), + SPH_C32(0x072d4584) }, + { SPH_C32(0xaa7e7430), SPH_C32(0x7c980000), SPH_C32(0x7fb20000), + SPH_C32(0x8d9e0000), SPH_C32(0x06672580), SPH_C32(0xb1b6ade7), + SPH_C32(0x7e424506), SPH_C32(0xf6d85a30), SPH_C32(0xae812640), + SPH_C32(0xd4e20000), SPH_C32(0x815c0000), SPH_C32(0x53f40000), + SPH_C32(0x043d19d6), SPH_C32(0x78a4ac42), SPH_C32(0x3224372f), + SPH_C32(0x9562188e) }, + { SPH_C32(0x45757640), SPH_C32(0x46650000), SPH_C32(0x221c0000), + SPH_C32(0xe4d70000), SPH_C32(0x9d681986), SPH_C32(0xf5b3181e), + SPH_C32(0x18564f57), SPH_C32(0x6497073a), SPH_C32(0x67ea2670), + SPH_C32(0x33c70000), SPH_C32(0xaed80000), SPH_C32(0x75bb0000), + SPH_C32(0x0c54422f), SPH_C32(0x15585d75), SPH_C32(0x62bb5eab), + SPH_C32(0x0b0bb7e6) }, + { SPH_C32(0x9cbb1800), SPH_C32(0xb0d30000), SPH_C32(0x92510000), + SPH_C32(0xed930000), SPH_C32(0x593a4345), SPH_C32(0xe114d5f4), + SPH_C32(0x430633da), SPH_C32(0x78cace29), SPH_C32(0xc8934400), + SPH_C32(0x5a3e0000), SPH_C32(0x57870000), SPH_C32(0x4c560000), + SPH_C32(0xea982435), SPH_C32(0x75b11115), SPH_C32(0x28b67247), + SPH_C32(0x2dd1f9ab) }, + { SPH_C32(0x73b01a70), SPH_C32(0x8a2e0000), SPH_C32(0xcfff0000), + SPH_C32(0x84da0000), SPH_C32(0xc2357f43), SPH_C32(0xa511600d), + SPH_C32(0x2512398b), SPH_C32(0xea859323), SPH_C32(0x01f84430), + SPH_C32(0xbd1b0000), SPH_C32(0x78030000), SPH_C32(0x6a190000), + SPH_C32(0xe2f17fcc), SPH_C32(0x184de022), SPH_C32(0x78291bc3), + SPH_C32(0xb3b856c3) }, + { SPH_C32(0x55d01830), SPH_C32(0x57f60000), SPH_C32(0xbdd50000), + SPH_C32(0xcbdc0000), SPH_C32(0x515318bc), SPH_C32(0x8ce824c3), + SPH_C32(0x13995a5e), SPH_C32(0xe6a36141), SPH_C32(0xeef34640), + SPH_C32(0x87e60000), SPH_C32(0x25ad0000), SPH_C32(0x03500000), + SPH_C32(0x79fe43ca), SPH_C32(0x5c4855db), SPH_C32(0x1e3d1192), + SPH_C32(0x21f70bc9) }, + { SPH_C32(0xbadb1a40), SPH_C32(0x6d0b0000), SPH_C32(0xe07b0000), + SPH_C32(0xa2950000), SPH_C32(0xca5c24ba), SPH_C32(0xc8ed913a), + SPH_C32(0x758d500f), SPH_C32(0x74ec3c4b), SPH_C32(0x27984670), + SPH_C32(0x60c30000), SPH_C32(0x0a290000), SPH_C32(0x251f0000), + SPH_C32(0x71971833), SPH_C32(0x31b4a4ec), SPH_C32(0x4ea27816), + SPH_C32(0xbf9ea4a1) }, + { SPH_C32(0x88e12400), SPH_C32(0x093a0000), SPH_C32(0xf3760000), + SPH_C32(0x1cf20000), SPH_C32(0x975b7e29), SPH_C32(0x515de88c), + SPH_C32(0x04af54fa), SPH_C32(0x9944eaec), SPH_C32(0xebf45000), + SPH_C32(0x92870000), SPH_C32(0xa3400000), SPH_C32(0xb7230000), + SPH_C32(0x99550050), SPH_C32(0x8d17b45c), SPH_C32(0x2a727878), + SPH_C32(0xf1f51fb4) }, + { SPH_C32(0x67ea2670), SPH_C32(0x33c70000), SPH_C32(0xaed80000), + SPH_C32(0x75bb0000), SPH_C32(0x0c54422f), SPH_C32(0x15585d75), + SPH_C32(0x62bb5eab), SPH_C32(0x0b0bb7e6), SPH_C32(0x229f5030), + SPH_C32(0x75a20000), SPH_C32(0x8cc40000), SPH_C32(0x916c0000), + SPH_C32(0x913c5ba9), SPH_C32(0xe0eb456b), SPH_C32(0x7aed11fc), + SPH_C32(0x6f9cb0dc) }, + { SPH_C32(0x418a2430), SPH_C32(0xee1f0000), SPH_C32(0xdcf20000), + SPH_C32(0x3abd0000), SPH_C32(0x9f3225d0), SPH_C32(0x3ca119bb), + SPH_C32(0x54303d7e), SPH_C32(0x072d4584), SPH_C32(0xcd945240), + SPH_C32(0x4f5f0000), SPH_C32(0xd16a0000), SPH_C32(0xf8250000), + SPH_C32(0x0a3367af), SPH_C32(0xa4eef092), SPH_C32(0x1cf91bad), + SPH_C32(0xfdd3edd6) }, + { SPH_C32(0xae812640), SPH_C32(0xd4e20000), SPH_C32(0x815c0000), + SPH_C32(0x53f40000), SPH_C32(0x043d19d6), SPH_C32(0x78a4ac42), + SPH_C32(0x3224372f), SPH_C32(0x9562188e), SPH_C32(0x04ff5270), + SPH_C32(0xa87a0000), SPH_C32(0xfeee0000), SPH_C32(0xde6a0000), + SPH_C32(0x025a3c56), SPH_C32(0xc91201a5), SPH_C32(0x4c667229), + SPH_C32(0x63ba42be) }, + { SPH_C32(0xbfdc0c00), SPH_C32(0x786a0000), SPH_C32(0x66960000), + SPH_C32(0x16e60000), SPH_C32(0x2af76720), SPH_C32(0x19b270bd), + SPH_C32(0x41c239e5), SPH_C32(0xa4ee2836), SPH_C32(0xffae6c00), + SPH_C32(0x2b6e0000), SPH_C32(0xc2670000), SPH_C32(0x46420000), + SPH_C32(0x57343d3c), SPH_C32(0x3d5e8924), SPH_C32(0x6ddb1f58), + SPH_C32(0x107b3b71) }, + { SPH_C32(0x50d70e70), SPH_C32(0x42970000), SPH_C32(0x3b380000), + SPH_C32(0x7faf0000), SPH_C32(0xb1f85b26), SPH_C32(0x5db7c544), + SPH_C32(0x27d633b4), SPH_C32(0x36a1753c), SPH_C32(0x36c56c30), + SPH_C32(0xcc4b0000), SPH_C32(0xede30000), SPH_C32(0x600d0000), + SPH_C32(0x5f5d66c5), SPH_C32(0x50a27813), SPH_C32(0x3d4476dc), + SPH_C32(0x8e129419) }, + { SPH_C32(0x76b70c30), SPH_C32(0x9f4f0000), SPH_C32(0x49120000), + SPH_C32(0x30a90000), SPH_C32(0x229e3cd9), SPH_C32(0x744e818a), + SPH_C32(0x115d5061), SPH_C32(0x3a87875e), SPH_C32(0xd9ce6e40), + SPH_C32(0xf6b60000), SPH_C32(0xb04d0000), SPH_C32(0x09440000), + SPH_C32(0xc4525ac3), SPH_C32(0x14a7cdea), SPH_C32(0x5b507c8d), + SPH_C32(0x1c5dc913) }, + { SPH_C32(0x99bc0e40), SPH_C32(0xa5b20000), SPH_C32(0x14bc0000), + SPH_C32(0x59e00000), SPH_C32(0xb99100df), SPH_C32(0x304b3473), + SPH_C32(0x77495a30), SPH_C32(0xa8c8da54), SPH_C32(0x10a56e70), + SPH_C32(0x11930000), SPH_C32(0x9fc90000), SPH_C32(0x2f0b0000), + SPH_C32(0xcc3b013a), SPH_C32(0x795b3cdd), SPH_C32(0x0bcf1509), + SPH_C32(0x8234667b) }, + { SPH_C32(0xab863000), SPH_C32(0xc1830000), SPH_C32(0x07b10000), + SPH_C32(0xe7870000), SPH_C32(0xe4965a4c), SPH_C32(0xa9fb4dc5), + SPH_C32(0x066b5ec5), SPH_C32(0x45600cf3), SPH_C32(0xdcc97800), + SPH_C32(0xe3d70000), SPH_C32(0x36a00000), SPH_C32(0xbd370000), + SPH_C32(0x24f91959), SPH_C32(0xc5f82c6d), SPH_C32(0x6f1f1567), + SPH_C32(0xcc5fdd6e) }, + { SPH_C32(0x448d3270), SPH_C32(0xfb7e0000), SPH_C32(0x5a1f0000), + SPH_C32(0x8ece0000), SPH_C32(0x7f99664a), SPH_C32(0xedfef83c), + SPH_C32(0x607f5494), SPH_C32(0xd72f51f9), SPH_C32(0x15a27830), + SPH_C32(0x04f20000), SPH_C32(0x19240000), SPH_C32(0x9b780000), + SPH_C32(0x2c9042a0), SPH_C32(0xa804dd5a), SPH_C32(0x3f807ce3), + SPH_C32(0x52367206) }, + { SPH_C32(0x62ed3030), SPH_C32(0x26a60000), SPH_C32(0x28350000), + SPH_C32(0xc1c80000), SPH_C32(0xecff01b5), SPH_C32(0xc407bcf2), + SPH_C32(0x56f43741), SPH_C32(0xdb09a39b), SPH_C32(0xfaa97a40), + SPH_C32(0x3e0f0000), SPH_C32(0x448a0000), SPH_C32(0xf2310000), + SPH_C32(0xb79f7ea6), SPH_C32(0xec0168a3), SPH_C32(0x599476b2), + SPH_C32(0xc0792f0c) }, + { SPH_C32(0x8de63240), SPH_C32(0x1c5b0000), SPH_C32(0x759b0000), + SPH_C32(0xa8810000), SPH_C32(0x77f03db3), SPH_C32(0x8002090b), + SPH_C32(0x30e03d10), SPH_C32(0x4946fe91), SPH_C32(0x33c27a70), + SPH_C32(0xd92a0000), SPH_C32(0x6b0e0000), SPH_C32(0xd47e0000), + SPH_C32(0xbff6255f), SPH_C32(0x81fd9994), SPH_C32(0x090b1f36), + SPH_C32(0x5e108064) }, + { SPH_C32(0xc8934400), SPH_C32(0x5a3e0000), SPH_C32(0x57870000), + SPH_C32(0x4c560000), SPH_C32(0xea982435), SPH_C32(0x75b11115), + SPH_C32(0x28b67247), SPH_C32(0x2dd1f9ab), SPH_C32(0x54285c00), + SPH_C32(0xeaed0000), SPH_C32(0xc5d60000), SPH_C32(0xa1c50000), + SPH_C32(0xb3a26770), SPH_C32(0x94a5c4e1), SPH_C32(0x6bb0419d), + SPH_C32(0x551b3782) }, + { SPH_C32(0x27984670), SPH_C32(0x60c30000), SPH_C32(0x0a290000), + SPH_C32(0x251f0000), SPH_C32(0x71971833), SPH_C32(0x31b4a4ec), + SPH_C32(0x4ea27816), SPH_C32(0xbf9ea4a1), SPH_C32(0x9d435c30), + SPH_C32(0x0dc80000), SPH_C32(0xea520000), SPH_C32(0x878a0000), + SPH_C32(0xbbcb3c89), SPH_C32(0xf95935d6), SPH_C32(0x3b2f2819), + SPH_C32(0xcb7298ea) }, + { SPH_C32(0x01f84430), SPH_C32(0xbd1b0000), SPH_C32(0x78030000), + SPH_C32(0x6a190000), SPH_C32(0xe2f17fcc), SPH_C32(0x184de022), + SPH_C32(0x78291bc3), SPH_C32(0xb3b856c3), SPH_C32(0x72485e40), + SPH_C32(0x37350000), SPH_C32(0xb7fc0000), SPH_C32(0xeec30000), + SPH_C32(0x20c4008f), SPH_C32(0xbd5c802f), SPH_C32(0x5d3b2248), + SPH_C32(0x593dc5e0) }, + { SPH_C32(0xeef34640), SPH_C32(0x87e60000), SPH_C32(0x25ad0000), + SPH_C32(0x03500000), SPH_C32(0x79fe43ca), SPH_C32(0x5c4855db), + SPH_C32(0x1e3d1192), SPH_C32(0x21f70bc9), SPH_C32(0xbb235e70), + SPH_C32(0xd0100000), SPH_C32(0x98780000), SPH_C32(0xc88c0000), + SPH_C32(0x28ad5b76), SPH_C32(0xd0a07118), SPH_C32(0x0da44bcc), + SPH_C32(0xc7546a88) }, + { SPH_C32(0xdcc97800), SPH_C32(0xe3d70000), SPH_C32(0x36a00000), + SPH_C32(0xbd370000), SPH_C32(0x24f91959), SPH_C32(0xc5f82c6d), + SPH_C32(0x6f1f1567), SPH_C32(0xcc5fdd6e), SPH_C32(0x774f4800), + SPH_C32(0x22540000), SPH_C32(0x31110000), SPH_C32(0x5ab00000), + SPH_C32(0xc06f4315), SPH_C32(0x6c0361a8), SPH_C32(0x69744ba2), + SPH_C32(0x893fd19d) }, + { SPH_C32(0x33c27a70), SPH_C32(0xd92a0000), SPH_C32(0x6b0e0000), + SPH_C32(0xd47e0000), SPH_C32(0xbff6255f), SPH_C32(0x81fd9994), + SPH_C32(0x090b1f36), SPH_C32(0x5e108064), SPH_C32(0xbe244830), + SPH_C32(0xc5710000), SPH_C32(0x1e950000), SPH_C32(0x7cff0000), + SPH_C32(0xc80618ec), SPH_C32(0x01ff909f), SPH_C32(0x39eb2226), + SPH_C32(0x17567ef5) }, + { SPH_C32(0x15a27830), SPH_C32(0x04f20000), SPH_C32(0x19240000), + SPH_C32(0x9b780000), SPH_C32(0x2c9042a0), SPH_C32(0xa804dd5a), + SPH_C32(0x3f807ce3), SPH_C32(0x52367206), SPH_C32(0x512f4a40), + SPH_C32(0xff8c0000), SPH_C32(0x433b0000), SPH_C32(0x15b60000), + SPH_C32(0x530924ea), SPH_C32(0x45fa2566), SPH_C32(0x5fff2877), + SPH_C32(0x851923ff) }, + { SPH_C32(0xfaa97a40), SPH_C32(0x3e0f0000), SPH_C32(0x448a0000), + SPH_C32(0xf2310000), SPH_C32(0xb79f7ea6), SPH_C32(0xec0168a3), + SPH_C32(0x599476b2), SPH_C32(0xc0792f0c), SPH_C32(0x98444a70), + SPH_C32(0x18a90000), SPH_C32(0x6cbf0000), SPH_C32(0x33f90000), + SPH_C32(0x5b607f13), SPH_C32(0x2806d451), SPH_C32(0x0f6041f3), + SPH_C32(0x1b708c97) }, + { SPH_C32(0xebf45000), SPH_C32(0x92870000), SPH_C32(0xa3400000), + SPH_C32(0xb7230000), SPH_C32(0x99550050), SPH_C32(0x8d17b45c), + SPH_C32(0x2a727878), SPH_C32(0xf1f51fb4), SPH_C32(0x63157400), + SPH_C32(0x9bbd0000), SPH_C32(0x50360000), SPH_C32(0xabd10000), + SPH_C32(0x0e0e7e79), SPH_C32(0xdc4a5cd0), SPH_C32(0x2edd2c82), + SPH_C32(0x68b1f558) }, + { SPH_C32(0x04ff5270), SPH_C32(0xa87a0000), SPH_C32(0xfeee0000), + SPH_C32(0xde6a0000), SPH_C32(0x025a3c56), SPH_C32(0xc91201a5), + SPH_C32(0x4c667229), SPH_C32(0x63ba42be), SPH_C32(0xaa7e7430), + SPH_C32(0x7c980000), SPH_C32(0x7fb20000), SPH_C32(0x8d9e0000), + SPH_C32(0x06672580), SPH_C32(0xb1b6ade7), SPH_C32(0x7e424506), + SPH_C32(0xf6d85a30) }, + { SPH_C32(0x229f5030), SPH_C32(0x75a20000), SPH_C32(0x8cc40000), + SPH_C32(0x916c0000), SPH_C32(0x913c5ba9), SPH_C32(0xe0eb456b), + SPH_C32(0x7aed11fc), SPH_C32(0x6f9cb0dc), SPH_C32(0x45757640), + SPH_C32(0x46650000), SPH_C32(0x221c0000), SPH_C32(0xe4d70000), + SPH_C32(0x9d681986), SPH_C32(0xf5b3181e), SPH_C32(0x18564f57), + SPH_C32(0x6497073a) }, + { SPH_C32(0xcd945240), SPH_C32(0x4f5f0000), SPH_C32(0xd16a0000), + SPH_C32(0xf8250000), SPH_C32(0x0a3367af), SPH_C32(0xa4eef092), + SPH_C32(0x1cf91bad), SPH_C32(0xfdd3edd6), SPH_C32(0x8c1e7670), + SPH_C32(0xa1400000), SPH_C32(0x0d980000), SPH_C32(0xc2980000), + SPH_C32(0x9501427f), SPH_C32(0x984fe929), SPH_C32(0x48c926d3), + SPH_C32(0xfafea852) }, + { SPH_C32(0xffae6c00), SPH_C32(0x2b6e0000), SPH_C32(0xc2670000), + SPH_C32(0x46420000), SPH_C32(0x57343d3c), SPH_C32(0x3d5e8924), + SPH_C32(0x6ddb1f58), SPH_C32(0x107b3b71), SPH_C32(0x40726000), + SPH_C32(0x53040000), SPH_C32(0xa4f10000), SPH_C32(0x50a40000), + SPH_C32(0x7dc35a1c), SPH_C32(0x24ecf999), SPH_C32(0x2c1926bd), + SPH_C32(0xb4951347) }, + { SPH_C32(0x10a56e70), SPH_C32(0x11930000), SPH_C32(0x9fc90000), + SPH_C32(0x2f0b0000), SPH_C32(0xcc3b013a), SPH_C32(0x795b3cdd), + SPH_C32(0x0bcf1509), SPH_C32(0x8234667b), SPH_C32(0x89196030), + SPH_C32(0xb4210000), SPH_C32(0x8b750000), SPH_C32(0x76eb0000), + SPH_C32(0x75aa01e5), SPH_C32(0x491008ae), SPH_C32(0x7c864f39), + SPH_C32(0x2afcbc2f) }, + { SPH_C32(0x36c56c30), SPH_C32(0xcc4b0000), SPH_C32(0xede30000), + SPH_C32(0x600d0000), SPH_C32(0x5f5d66c5), SPH_C32(0x50a27813), + SPH_C32(0x3d4476dc), SPH_C32(0x8e129419), SPH_C32(0x66126240), + SPH_C32(0x8edc0000), SPH_C32(0xd6db0000), SPH_C32(0x1fa20000), + SPH_C32(0xeea53de3), SPH_C32(0x0d15bd57), SPH_C32(0x1a924568), + SPH_C32(0xb8b3e125) }, + { SPH_C32(0xd9ce6e40), SPH_C32(0xf6b60000), SPH_C32(0xb04d0000), + SPH_C32(0x09440000), SPH_C32(0xc4525ac3), SPH_C32(0x14a7cdea), + SPH_C32(0x5b507c8d), SPH_C32(0x1c5dc913), SPH_C32(0xaf796270), + SPH_C32(0x69f90000), SPH_C32(0xf95f0000), SPH_C32(0x39ed0000), + SPH_C32(0xe6cc661a), SPH_C32(0x60e94c60), SPH_C32(0x4a0d2cec), + SPH_C32(0x26da4e4d) }, + { SPH_C32(0x29449c00), SPH_C32(0x64e70000), SPH_C32(0xf24b0000), + SPH_C32(0xc2f30000), SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), + SPH_C32(0xf3e04259), SPH_C32(0x8d0d9ec4), SPH_C32(0x466d0c00), + SPH_C32(0x08620000), SPH_C32(0xdd5d0000), SPH_C32(0xbadd0000), + SPH_C32(0x6a927942), SPH_C32(0x441f2b93), SPH_C32(0x218ace6f), + SPH_C32(0xbf2c0be2) }, + { SPH_C32(0xc64f9e70), SPH_C32(0x5e1a0000), SPH_C32(0xafe50000), + SPH_C32(0xabba0000), SPH_C32(0x95d17289), SPH_C32(0x12c782bc), + SPH_C32(0x95f44808), SPH_C32(0x1f42c3ce), SPH_C32(0x8f060c30), + SPH_C32(0xef470000), SPH_C32(0xf2d90000), SPH_C32(0x9c920000), + SPH_C32(0x62fb22bb), SPH_C32(0x29e3daa4), SPH_C32(0x7115a7eb), + SPH_C32(0x2145a48a) }, + { SPH_C32(0xe02f9c30), SPH_C32(0x83c20000), SPH_C32(0xddcf0000), + SPH_C32(0xe4bc0000), SPH_C32(0x06b71576), SPH_C32(0x3b3ec672), + SPH_C32(0xa37f2bdd), SPH_C32(0x136431ac), SPH_C32(0x600d0e40), + SPH_C32(0xd5ba0000), SPH_C32(0xaf770000), SPH_C32(0xf5db0000), + SPH_C32(0xf9f41ebd), SPH_C32(0x6de66f5d), SPH_C32(0x1701adba), + SPH_C32(0xb30af980) }, + { SPH_C32(0x0f249e40), SPH_C32(0xb93f0000), SPH_C32(0x80610000), + SPH_C32(0x8df50000), SPH_C32(0x9db82970), SPH_C32(0x7f3b738b), + SPH_C32(0xc56b218c), SPH_C32(0x812b6ca6), SPH_C32(0xa9660e70), + SPH_C32(0x329f0000), SPH_C32(0x80f30000), SPH_C32(0xd3940000), + SPH_C32(0xf19d4544), SPH_C32(0x001a9e6a), SPH_C32(0x479ec43e), + SPH_C32(0x2d6356e8) }, + { SPH_C32(0x3d1ea000), SPH_C32(0xdd0e0000), SPH_C32(0x936c0000), + SPH_C32(0x33920000), SPH_C32(0xc0bf73e3), SPH_C32(0xe68b0a3d), + SPH_C32(0xb4492579), SPH_C32(0x6c83ba01), SPH_C32(0x650a1800), + SPH_C32(0xc0db0000), SPH_C32(0x299a0000), SPH_C32(0x41a80000), + SPH_C32(0x195f5d27), SPH_C32(0xbcb98eda), SPH_C32(0x234ec450), + SPH_C32(0x6308edfd) }, + { SPH_C32(0xd215a270), SPH_C32(0xe7f30000), SPH_C32(0xcec20000), + SPH_C32(0x5adb0000), SPH_C32(0x5bb04fe5), SPH_C32(0xa28ebfc4), + SPH_C32(0xd25d2f28), SPH_C32(0xfecce70b), SPH_C32(0xac611830), + SPH_C32(0x27fe0000), SPH_C32(0x061e0000), SPH_C32(0x67e70000), + SPH_C32(0x113606de), SPH_C32(0xd1457fed), SPH_C32(0x73d1add4), + SPH_C32(0xfd614295) }, + { SPH_C32(0xf475a030), SPH_C32(0x3a2b0000), SPH_C32(0xbce80000), + SPH_C32(0x15dd0000), SPH_C32(0xc8d6281a), SPH_C32(0x8b77fb0a), + SPH_C32(0xe4d64cfd), SPH_C32(0xf2ea1569), SPH_C32(0x436a1a40), + SPH_C32(0x1d030000), SPH_C32(0x5bb00000), SPH_C32(0x0eae0000), + SPH_C32(0x8a393ad8), SPH_C32(0x9540ca14), SPH_C32(0x15c5a785), + SPH_C32(0x6f2e1f9f) }, + { SPH_C32(0x1b7ea240), SPH_C32(0x00d60000), SPH_C32(0xe1460000), + SPH_C32(0x7c940000), SPH_C32(0x53d9141c), SPH_C32(0xcf724ef3), + SPH_C32(0x82c246ac), SPH_C32(0x60a54863), SPH_C32(0x8a011a70), + SPH_C32(0xfa260000), SPH_C32(0x74340000), SPH_C32(0x28e10000), + SPH_C32(0x82506121), SPH_C32(0xf8bc3b23), SPH_C32(0x455ace01), + SPH_C32(0xf147b0f7) }, + { SPH_C32(0x0a238800), SPH_C32(0xac5e0000), SPH_C32(0x068c0000), + SPH_C32(0x39860000), SPH_C32(0x7d136aea), SPH_C32(0xae64920c), + SPH_C32(0xf1244866), SPH_C32(0x512978db), SPH_C32(0x71502400), + SPH_C32(0x79320000), SPH_C32(0x48bd0000), SPH_C32(0xb0c90000), + SPH_C32(0xd73e604b), SPH_C32(0x0cf0b3a2), SPH_C32(0x64e7a370), + SPH_C32(0x8286c938) }, + { SPH_C32(0xe5288a70), SPH_C32(0x96a30000), SPH_C32(0x5b220000), + SPH_C32(0x50cf0000), SPH_C32(0xe61c56ec), SPH_C32(0xea6127f5), + SPH_C32(0x97304237), SPH_C32(0xc36625d1), SPH_C32(0xb83b2430), + SPH_C32(0x9e170000), SPH_C32(0x67390000), SPH_C32(0x96860000), + SPH_C32(0xdf573bb2), SPH_C32(0x610c4295), SPH_C32(0x3478caf4), + SPH_C32(0x1cef6650) }, + { SPH_C32(0xc3488830), SPH_C32(0x4b7b0000), SPH_C32(0x29080000), + SPH_C32(0x1fc90000), SPH_C32(0x757a3113), SPH_C32(0xc398633b), + SPH_C32(0xa1bb21e2), SPH_C32(0xcf40d7b3), SPH_C32(0x57302640), + SPH_C32(0xa4ea0000), SPH_C32(0x3a970000), SPH_C32(0xffcf0000), + SPH_C32(0x445807b4), SPH_C32(0x2509f76c), SPH_C32(0x526cc0a5), + SPH_C32(0x8ea03b5a) }, + { SPH_C32(0x2c438a40), SPH_C32(0x71860000), SPH_C32(0x74a60000), + SPH_C32(0x76800000), SPH_C32(0xee750d15), SPH_C32(0x879dd6c2), + SPH_C32(0xc7af2bb3), SPH_C32(0x5d0f8ab9), SPH_C32(0x9e5b2670), + SPH_C32(0x43cf0000), SPH_C32(0x15130000), SPH_C32(0xd9800000), + SPH_C32(0x4c315c4d), SPH_C32(0x48f5065b), SPH_C32(0x02f3a921), + SPH_C32(0x10c99432) }, + { SPH_C32(0x1e79b400), SPH_C32(0x15b70000), SPH_C32(0x67ab0000), + SPH_C32(0xc8e70000), SPH_C32(0xb3725786), SPH_C32(0x1e2daf74), + SPH_C32(0xb68d2f46), SPH_C32(0xb0a75c1e), SPH_C32(0x52373000), + SPH_C32(0xb18b0000), SPH_C32(0xbc7a0000), SPH_C32(0x4bbc0000), + SPH_C32(0xa4f3442e), SPH_C32(0xf45616eb), SPH_C32(0x6623a94f), + SPH_C32(0x5ea22f27) }, + { SPH_C32(0xf172b670), SPH_C32(0x2f4a0000), SPH_C32(0x3a050000), + SPH_C32(0xa1ae0000), SPH_C32(0x287d6b80), SPH_C32(0x5a281a8d), + SPH_C32(0xd0992517), SPH_C32(0x22e80114), SPH_C32(0x9b5c3030), + SPH_C32(0x56ae0000), SPH_C32(0x93fe0000), SPH_C32(0x6df30000), + SPH_C32(0xac9a1fd7), SPH_C32(0x99aae7dc), SPH_C32(0x36bcc0cb), + SPH_C32(0xc0cb804f) }, + { SPH_C32(0xd712b430), SPH_C32(0xf2920000), SPH_C32(0x482f0000), + SPH_C32(0xeea80000), SPH_C32(0xbb1b0c7f), SPH_C32(0x73d15e43), + SPH_C32(0xe61246c2), SPH_C32(0x2ecef376), SPH_C32(0x74573240), + SPH_C32(0x6c530000), SPH_C32(0xce500000), SPH_C32(0x04ba0000), + SPH_C32(0x379523d1), SPH_C32(0xddaf5225), SPH_C32(0x50a8ca9a), + SPH_C32(0x5284dd45) }, + { SPH_C32(0x3819b640), SPH_C32(0xc86f0000), SPH_C32(0x15810000), + SPH_C32(0x87e10000), SPH_C32(0x20143079), SPH_C32(0x37d4ebba), + SPH_C32(0x80064c93), SPH_C32(0xbc81ae7c), SPH_C32(0xbd3c3270), + SPH_C32(0x8b760000), SPH_C32(0xe1d40000), SPH_C32(0x22f50000), + SPH_C32(0x3ffc7828), SPH_C32(0xb053a312), SPH_C32(0x0037a31e), + SPH_C32(0xcced722d) }, + { SPH_C32(0x7d6cc000), SPH_C32(0x8e0a0000), SPH_C32(0x379d0000), + SPH_C32(0x63360000), SPH_C32(0xbd7c29ff), SPH_C32(0xc267f3a4), + SPH_C32(0x985003c4), SPH_C32(0xd816a946), SPH_C32(0xdad61400), + SPH_C32(0xb8b10000), SPH_C32(0x4f0c0000), SPH_C32(0x574e0000), + SPH_C32(0x33a83a07), SPH_C32(0xa50bfe67), SPH_C32(0x628cfdb5), + SPH_C32(0xc7e6c5cb) }, + { SPH_C32(0x9267c270), SPH_C32(0xb4f70000), SPH_C32(0x6a330000), + SPH_C32(0x0a7f0000), SPH_C32(0x267315f9), SPH_C32(0x8662465d), + SPH_C32(0xfe440995), SPH_C32(0x4a59f44c), SPH_C32(0x13bd1430), + SPH_C32(0x5f940000), SPH_C32(0x60880000), SPH_C32(0x71010000), + SPH_C32(0x3bc161fe), SPH_C32(0xc8f70f50), SPH_C32(0x32139431), + SPH_C32(0x598f6aa3) }, + { SPH_C32(0xb407c030), SPH_C32(0x692f0000), SPH_C32(0x18190000), + SPH_C32(0x45790000), SPH_C32(0xb5157206), SPH_C32(0xaf9b0293), + SPH_C32(0xc8cf6a40), SPH_C32(0x467f062e), SPH_C32(0xfcb61640), + SPH_C32(0x65690000), SPH_C32(0x3d260000), SPH_C32(0x18480000), + SPH_C32(0xa0ce5df8), SPH_C32(0x8cf2baa9), SPH_C32(0x54079e60), + SPH_C32(0xcbc037a9) }, + { SPH_C32(0x5b0cc240), SPH_C32(0x53d20000), SPH_C32(0x45b70000), + SPH_C32(0x2c300000), SPH_C32(0x2e1a4e00), SPH_C32(0xeb9eb76a), + SPH_C32(0xaedb6011), SPH_C32(0xd4305b24), SPH_C32(0x35dd1670), + SPH_C32(0x824c0000), SPH_C32(0x12a20000), SPH_C32(0x3e070000), + SPH_C32(0xa8a70601), SPH_C32(0xe10e4b9e), SPH_C32(0x0498f7e4), + SPH_C32(0x55a998c1) }, + { SPH_C32(0x6936fc00), SPH_C32(0x37e30000), SPH_C32(0x56ba0000), + SPH_C32(0x92570000), SPH_C32(0x731d1493), SPH_C32(0x722ecedc), + SPH_C32(0xdff964e4), SPH_C32(0x39988d83), SPH_C32(0xf9b10000), + SPH_C32(0x70080000), SPH_C32(0xbbcb0000), SPH_C32(0xac3b0000), + SPH_C32(0x40651e62), SPH_C32(0x5dad5b2e), SPH_C32(0x6048f78a), + SPH_C32(0x1bc223d4) }, + { SPH_C32(0x863dfe70), SPH_C32(0x0d1e0000), SPH_C32(0x0b140000), + SPH_C32(0xfb1e0000), SPH_C32(0xe8122895), SPH_C32(0x362b7b25), + SPH_C32(0xb9ed6eb5), SPH_C32(0xabd7d089), SPH_C32(0x30da0030), + SPH_C32(0x972d0000), SPH_C32(0x944f0000), SPH_C32(0x8a740000), + SPH_C32(0x480c459b), SPH_C32(0x3051aa19), SPH_C32(0x30d79e0e), + SPH_C32(0x85ab8cbc) }, + { SPH_C32(0xa05dfc30), SPH_C32(0xd0c60000), SPH_C32(0x793e0000), + SPH_C32(0xb4180000), SPH_C32(0x7b744f6a), SPH_C32(0x1fd23feb), + SPH_C32(0x8f660d60), SPH_C32(0xa7f122eb), SPH_C32(0xdfd10240), + SPH_C32(0xadd00000), SPH_C32(0xc9e10000), SPH_C32(0xe33d0000), + SPH_C32(0xd303799d), SPH_C32(0x74541fe0), SPH_C32(0x56c3945f), + SPH_C32(0x17e4d1b6) }, + { SPH_C32(0x4f56fe40), SPH_C32(0xea3b0000), SPH_C32(0x24900000), + SPH_C32(0xdd510000), SPH_C32(0xe07b736c), SPH_C32(0x5bd78a12), + SPH_C32(0xe9720731), SPH_C32(0x35be7fe1), SPH_C32(0x16ba0270), + SPH_C32(0x4af50000), SPH_C32(0xe6650000), SPH_C32(0xc5720000), + SPH_C32(0xdb6a2264), SPH_C32(0x19a8eed7), SPH_C32(0x065cfddb), + SPH_C32(0x898d7ede) }, + { SPH_C32(0x5e0bd400), SPH_C32(0x46b30000), SPH_C32(0xc35a0000), + SPH_C32(0x98430000), SPH_C32(0xceb10d9a), SPH_C32(0x3ac156ed), + SPH_C32(0x9a9409fb), SPH_C32(0x04324f59), SPH_C32(0xedeb3c00), + SPH_C32(0xc9e10000), SPH_C32(0xdaec0000), SPH_C32(0x5d5a0000), + SPH_C32(0x8e04230e), SPH_C32(0xede46656), SPH_C32(0x27e190aa), + SPH_C32(0xfa4c0711) }, + { SPH_C32(0xb100d670), SPH_C32(0x7c4e0000), SPH_C32(0x9ef40000), + SPH_C32(0xf10a0000), SPH_C32(0x55be319c), SPH_C32(0x7ec4e314), + SPH_C32(0xfc8003aa), SPH_C32(0x967d1253), SPH_C32(0x24803c30), + SPH_C32(0x2ec40000), SPH_C32(0xf5680000), SPH_C32(0x7b150000), + SPH_C32(0x866d78f7), SPH_C32(0x80189761), SPH_C32(0x777ef92e), + SPH_C32(0x6425a879) }, + { SPH_C32(0x9760d430), SPH_C32(0xa1960000), SPH_C32(0xecde0000), + SPH_C32(0xbe0c0000), SPH_C32(0xc6d85663), SPH_C32(0x573da7da), + SPH_C32(0xca0b607f), SPH_C32(0x9a5be031), SPH_C32(0xcb8b3e40), + SPH_C32(0x14390000), SPH_C32(0xa8c60000), SPH_C32(0x125c0000), + SPH_C32(0x1d6244f1), SPH_C32(0xc41d2298), SPH_C32(0x116af37f), + SPH_C32(0xf66af573) }, + { SPH_C32(0x786bd640), SPH_C32(0x9b6b0000), SPH_C32(0xb1700000), + SPH_C32(0xd7450000), SPH_C32(0x5dd76a65), SPH_C32(0x13381223), + SPH_C32(0xac1f6a2e), SPH_C32(0x0814bd3b), SPH_C32(0x02e03e70), + SPH_C32(0xf31c0000), SPH_C32(0x87420000), SPH_C32(0x34130000), + SPH_C32(0x150b1f08), SPH_C32(0xa9e1d3af), SPH_C32(0x41f59afb), + SPH_C32(0x68035a1b) }, + { SPH_C32(0x4a51e800), SPH_C32(0xff5a0000), SPH_C32(0xa27d0000), + SPH_C32(0x69220000), SPH_C32(0x00d030f6), SPH_C32(0x8a886b95), + SPH_C32(0xdd3d6edb), SPH_C32(0xe5bc6b9c), SPH_C32(0xce8c2800), + SPH_C32(0x01580000), SPH_C32(0x2e2b0000), SPH_C32(0xa62f0000), + SPH_C32(0xfdc9076b), SPH_C32(0x1542c31f), SPH_C32(0x25259a95), + SPH_C32(0x2668e10e) }, + { SPH_C32(0xa55aea70), SPH_C32(0xc5a70000), SPH_C32(0xffd30000), + SPH_C32(0x006b0000), SPH_C32(0x9bdf0cf0), SPH_C32(0xce8dde6c), + SPH_C32(0xbb29648a), SPH_C32(0x77f33696), SPH_C32(0x07e72830), + SPH_C32(0xe67d0000), SPH_C32(0x01af0000), SPH_C32(0x80600000), + SPH_C32(0xf5a05c92), SPH_C32(0x78be3228), SPH_C32(0x75baf311), + SPH_C32(0xb8014e66) }, + { SPH_C32(0x833ae830), SPH_C32(0x187f0000), SPH_C32(0x8df90000), + SPH_C32(0x4f6d0000), SPH_C32(0x08b96b0f), SPH_C32(0xe7749aa2), + SPH_C32(0x8da2075f), SPH_C32(0x7bd5c4f4), SPH_C32(0xe8ec2a40), + SPH_C32(0xdc800000), SPH_C32(0x5c010000), SPH_C32(0xe9290000), + SPH_C32(0x6eaf6094), SPH_C32(0x3cbb87d1), SPH_C32(0x13aef940), + SPH_C32(0x2a4e136c) }, + { SPH_C32(0x6c31ea40), SPH_C32(0x22820000), SPH_C32(0xd0570000), + SPH_C32(0x26240000), SPH_C32(0x93b65709), SPH_C32(0xa3712f5b), + SPH_C32(0xebb60d0e), SPH_C32(0xe99a99fe), SPH_C32(0x21872a70), + SPH_C32(0x3ba50000), SPH_C32(0x73850000), SPH_C32(0xcf660000), + SPH_C32(0x66c63b6d), SPH_C32(0x514776e6), SPH_C32(0x433190c4), + SPH_C32(0xb427bc04) }, + { SPH_C32(0xb5ff8400), SPH_C32(0xd4340000), SPH_C32(0x601a0000), + SPH_C32(0x2f600000), SPH_C32(0x57e40dca), SPH_C32(0xb7d6e2b1), + SPH_C32(0xb0e67183), SPH_C32(0xf5c750ed), SPH_C32(0x8efe4800), + SPH_C32(0x525c0000), SPH_C32(0x8ada0000), SPH_C32(0xf68b0000), + SPH_C32(0x800a5d77), SPH_C32(0x31ae3a86), SPH_C32(0x093cbc28), + SPH_C32(0x92fdf249) }, + { SPH_C32(0x5af48670), SPH_C32(0xeec90000), SPH_C32(0x3db40000), + SPH_C32(0x46290000), SPH_C32(0xcceb31cc), SPH_C32(0xf3d35748), + SPH_C32(0xd6f27bd2), SPH_C32(0x67880de7), SPH_C32(0x47954830), + SPH_C32(0xb5790000), SPH_C32(0xa55e0000), SPH_C32(0xd0c40000), + SPH_C32(0x8863068e), SPH_C32(0x5c52cbb1), SPH_C32(0x59a3d5ac), + SPH_C32(0x0c945d21) }, + { SPH_C32(0x7c948430), SPH_C32(0x33110000), SPH_C32(0x4f9e0000), + SPH_C32(0x092f0000), SPH_C32(0x5f8d5633), SPH_C32(0xda2a1386), + SPH_C32(0xe0791807), SPH_C32(0x6baeff85), SPH_C32(0xa89e4a40), + SPH_C32(0x8f840000), SPH_C32(0xf8f00000), SPH_C32(0xb98d0000), + SPH_C32(0x136c3a88), SPH_C32(0x18577e48), SPH_C32(0x3fb7dffd), + SPH_C32(0x9edb002b) }, + { SPH_C32(0x939f8640), SPH_C32(0x09ec0000), SPH_C32(0x12300000), + SPH_C32(0x60660000), SPH_C32(0xc4826a35), SPH_C32(0x9e2fa67f), + SPH_C32(0x866d1256), SPH_C32(0xf9e1a28f), SPH_C32(0x61f54a70), + SPH_C32(0x68a10000), SPH_C32(0xd7740000), SPH_C32(0x9fc20000), + SPH_C32(0x1b056171), SPH_C32(0x75ab8f7f), SPH_C32(0x6f28b679), + SPH_C32(0x00b2af43) }, + { SPH_C32(0xa1a5b800), SPH_C32(0x6ddd0000), SPH_C32(0x013d0000), + SPH_C32(0xde010000), SPH_C32(0x998530a6), SPH_C32(0x079fdfc9), + SPH_C32(0xf74f16a3), SPH_C32(0x14497428), SPH_C32(0xad995c00), + SPH_C32(0x9ae50000), SPH_C32(0x7e1d0000), SPH_C32(0x0dfe0000), + SPH_C32(0xf3c77912), SPH_C32(0xc9089fcf), SPH_C32(0x0bf8b617), + SPH_C32(0x4ed91456) }, + { SPH_C32(0x4eaeba70), SPH_C32(0x57200000), SPH_C32(0x5c930000), + SPH_C32(0xb7480000), SPH_C32(0x028a0ca0), SPH_C32(0x439a6a30), + SPH_C32(0x915b1cf2), SPH_C32(0x86062922), SPH_C32(0x64f25c30), + SPH_C32(0x7dc00000), SPH_C32(0x51990000), SPH_C32(0x2bb10000), + SPH_C32(0xfbae22eb), SPH_C32(0xa4f46ef8), SPH_C32(0x5b67df93), + SPH_C32(0xd0b0bb3e) }, + { SPH_C32(0x68ceb830), SPH_C32(0x8af80000), SPH_C32(0x2eb90000), + SPH_C32(0xf84e0000), SPH_C32(0x91ec6b5f), SPH_C32(0x6a632efe), + SPH_C32(0xa7d07f27), SPH_C32(0x8a20db40), SPH_C32(0x8bf95e40), + SPH_C32(0x473d0000), SPH_C32(0x0c370000), SPH_C32(0x42f80000), + SPH_C32(0x60a11eed), SPH_C32(0xe0f1db01), SPH_C32(0x3d73d5c2), + SPH_C32(0x42ffe634) }, + { SPH_C32(0x87c5ba40), SPH_C32(0xb0050000), SPH_C32(0x73170000), + SPH_C32(0x91070000), SPH_C32(0x0ae35759), SPH_C32(0x2e669b07), + SPH_C32(0xc1c47576), SPH_C32(0x186f864a), SPH_C32(0x42925e70), + SPH_C32(0xa0180000), SPH_C32(0x23b30000), SPH_C32(0x64b70000), + SPH_C32(0x68c84514), SPH_C32(0x8d0d2a36), SPH_C32(0x6decbc46), + SPH_C32(0xdc96495c) }, + { SPH_C32(0x496989000), SPH_C32(0x1c8d0000), SPH_C32(0x94dd0000), + SPH_C32(0xd4150000), SPH_C32(0x242929af), SPH_C32(0x4f7047f8), + SPH_C32(0xb2227bbc), SPH_C32(0x29e3b6f2), SPH_C32(0xb9c36000), + SPH_C32(0x230c0000), SPH_C32(0x1f3a0000), SPH_C32(0xfc9f0000), + SPH_C32(0x3da6447e), SPH_C32(0x7941a2b7), SPH_C32(0x4c51d137), + SPH_C32(0xaf573093) }, + { SPH_C32(0x79939270), SPH_C32(0x26700000), SPH_C32(0xc9730000), + SPH_C32(0xbd5c0000), SPH_C32(0xbf2615a9), SPH_C32(0x0b75f201), + SPH_C32(0xd43671ed), SPH_C32(0xbbacebf8), SPH_C32(0x70a86030), + SPH_C32(0xc4290000), SPH_C32(0x30be0000), SPH_C32(0xdad00000), + SPH_C32(0x35cf1f87), SPH_C32(0x14bd5380), SPH_C32(0x1cceb8b3), + SPH_C32(0x313e9ffb) }, + { SPH_C32(0x5ff39030), SPH_C32(0xfba80000), SPH_C32(0xbb590000), + SPH_C32(0xf25a0000), SPH_C32(0x2c407256), SPH_C32(0x228cb6cf), + SPH_C32(0xe2bd1238), SPH_C32(0xb78a199a), SPH_C32(0x9fa36240), + SPH_C32(0xfed40000), SPH_C32(0x6d100000), SPH_C32(0xb3990000), + SPH_C32(0xaec02381), SPH_C32(0x50b8e679), SPH_C32(0x7adab2e2), + SPH_C32(0xa371c2f1) }, + { SPH_C32(0xb0f89240), SPH_C32(0xc1550000), SPH_C32(0xe6f70000), + SPH_C32(0x9b130000), SPH_C32(0xb74f4e50), SPH_C32(0x66890336), + SPH_C32(0x84a91869), SPH_C32(0x25c54490), SPH_C32(0x56c86270), + SPH_C32(0x19f10000), SPH_C32(0x42940000), SPH_C32(0x95d60000), + SPH_C32(0xa6a97878), SPH_C32(0x3d44174e), SPH_C32(0x2a45db66), + SPH_C32(0x3d186d99) }, + { SPH_C32(0x82c2ac00), SPH_C32(0xa5640000), SPH_C32(0xf5fa0000), + SPH_C32(0x25740000), SPH_C32(0xea4814c3), SPH_C32(0xff397a80), + SPH_C32(0xf58b1c9c), SPH_C32(0xc86d9237), SPH_C32(0x9aa47400), + SPH_C32(0xebb50000), SPH_C32(0xebfd0000), SPH_C32(0x07ea0000), + SPH_C32(0x4e6b601b), SPH_C32(0x81e707fe), SPH_C32(0x4e95db08), + SPH_C32(0x7373d68c) }, + { SPH_C32(0x6dc9ae70), SPH_C32(0x9f990000), SPH_C32(0xa8540000), + SPH_C32(0x4c3d0000), SPH_C32(0x714728c5), SPH_C32(0xbb3ccf79), + SPH_C32(0x939f16cd), SPH_C32(0x5a22cf3d), SPH_C32(0x53cf7430), + SPH_C32(0x0c900000), SPH_C32(0xc4790000), SPH_C32(0x21a50000), + SPH_C32(0x46023be2), SPH_C32(0xec1bf6c9), SPH_C32(0x1e0ab28c), + SPH_C32(0xed1a79e4) }, + { SPH_C32(0x4ba9ac30), SPH_C32(0x42410000), SPH_C32(0xda7e0000), + SPH_C32(0x033b0000), SPH_C32(0xe2214f3a), SPH_C32(0x92c58bb7), + SPH_C32(0xa5147518), SPH_C32(0x56043d5f), SPH_C32(0xbcc47640), + SPH_C32(0x366d0000), SPH_C32(0x99d70000), SPH_C32(0x48ec0000), + SPH_C32(0xdd0d07e4), SPH_C32(0xa81e4330), SPH_C32(0x781eb8dd), + SPH_C32(0x7f5524ee) }, + { SPH_C32(0xa4a2ae40), SPH_C32(0x78bc0000), SPH_C32(0x87d00000), + SPH_C32(0x6a720000), SPH_C32(0x792e733c), SPH_C32(0xd6c03e4e), + SPH_C32(0xc3007f49), SPH_C32(0xc44b6055), SPH_C32(0x75af7670), + SPH_C32(0xd1480000), SPH_C32(0xb6530000), SPH_C32(0x6ea30000), + SPH_C32(0xd5645c1d), SPH_C32(0xc5e2b207), SPH_C32(0x2881d159), + SPH_C32(0xe13c8b86) }, + { SPH_C32(0xe1d7d800), SPH_C32(0x3ed90000), SPH_C32(0xa5cc0000), + SPH_C32(0x8ea50000), SPH_C32(0xe4466aba), SPH_C32(0x23732650), + SPH_C32(0xdb56301e), SPH_C32(0xa0dc676f), SPH_C32(0x12455000), + SPH_C32(0xe28f0000), SPH_C32(0x188b0000), SPH_C32(0x1b180000), + SPH_C32(0xd9301e32), SPH_C32(0xd0baef72), SPH_C32(0x4a3a8ff2), + SPH_C32(0xea373c60) }, + { SPH_C32(0x0edcda70), SPH_C32(0x04240000), SPH_C32(0xf8620000), + SPH_C32(0xe7ec0000), SPH_C32(0x7f4956bc), SPH_C32(0x677693a9), + SPH_C32(0xbd423a4f), SPH_C32(0x32933a65), SPH_C32(0xdb2e5030), + SPH_C32(0x05aa0000), SPH_C32(0x370f0000), SPH_C32(0x3d570000), + SPH_C32(0xd15945cb), SPH_C32(0xbd461e45), SPH_C32(0x1aa5e676), + SPH_C32(0x745e9308) }, + { SPH_C32(0x28bcd830), SPH_C32(0xd9fc0000), SPH_C32(0x8a480000), + SPH_C32(0xa8ea0000), SPH_C32(0xec2f3143), SPH_C32(0x4e8fd767), + SPH_C32(0x8bc9599a), SPH_C32(0x3eb5c807), SPH_C32(0x34255240), + SPH_C32(0x3f570000), SPH_C32(0x6aa10000), SPH_C32(0x541e0000), + SPH_C32(0x4a5679cd), SPH_C32(0xf943abbc), SPH_C32(0x7cb1ec27), + SPH_C32(0xe611ce02) }, + { SPH_C32(0xc7b7da40), SPH_C32(0xe3010000), SPH_C32(0xd7e60000), + SPH_C32(0xc1a30000), SPH_C32(0x77200d45), SPH_C32(0x0a8a629e), + SPH_C32(0xeddd53cb), SPH_C32(0xacfa950d), SPH_C32(0xfd4e5270), + SPH_C32(0xd8720000), SPH_C32(0x45250000), SPH_C32(0x72510000), + SPH_C32(0x423f2234), SPH_C32(0x94bf5a8b), SPH_C32(0x2c2e85a3), + SPH_C32(0x7878616a) }, + { SPH_C32(0xf58de400), SPH_C32(0x87300000), SPH_C32(0xc4eb0000), + SPH_C32(0x7fc40000), SPH_C32(0x2a2757d6), SPH_C32(0x933a1b28), + SPH_C32(0x9cff573e), SPH_C32(0x415243aa), SPH_C32(0x31224400), + SPH_C32(0x2a360000), SPH_C32(0xec4c0000), SPH_C32(0xe06d0000), + SPH_C32(0xaafd3a57), SPH_C32(0x281c4a3b), SPH_C32(0x48fe85cd), + SPH_C32(0x3613da7f) }, + { SPH_C32(0x1a86e670), SPH_C32(0xbdcd0000), SPH_C32(0x99450000), + SPH_C32(0x168d0000), SPH_C32(0xb1286bd0), SPH_C32(0xd73faed1), + SPH_C32(0xfaeb5d6f), SPH_C32(0xd31d1ea0), SPH_C32(0xf8494430), + SPH_C32(0xcd130000), SPH_C32(0xc3c80000), SPH_C32(0xc6220000), + SPH_C32(0xa29461ae), SPH_C32(0x45e0bb0c), SPH_C32(0x1861ec49), + SPH_C32(0xa87a7517) }, + { SPH_C32(0x3ce6e430), SPH_C32(0x60150000), SPH_C32(0xeb6f0000), + SPH_C32(0x598b0000), SPH_C32(0x224e0c2f), SPH_C32(0xfec6ea1f), + SPH_C32(0xcc603eba), SPH_C32(0xdf3becc2), SPH_C32(0x17424640), + SPH_C32(0xf7ee0000), SPH_C32(0x9e660000), SPH_C32(0xaf6b0000), + SPH_C32(0x399b5da8), SPH_C32(0x01e50ef5), SPH_C32(0x7e75e618), + SPH_C32(0x3a35281d) }, + { SPH_C32(0xd3ede640), SPH_C32(0x5ae80000), SPH_C32(0xb6c10000), + SPH_C32(0x30c20000), SPH_C32(0xb9413029), SPH_C32(0xbac35fe6), + SPH_C32(0xaa7434eb), SPH_C32(0x4d74b1c8), SPH_C32(0xde294670), + SPH_C32(0x10cb0000), SPH_C32(0xb1e20000), SPH_C32(0x89240000), + SPH_C32(0x31f20651), SPH_C32(0x6c19ffc2), SPH_C32(0x2eea8f9c), + SPH_C32(0xa45c8775) }, + { SPH_C32(0xc2b0cc00), SPH_C32(0xf6600000), SPH_C32(0x510b0000), + SPH_C32(0x75d00000), SPH_C32(0x978b4edf), SPH_C32(0xdbd58319), + SPH_C32(0xd9923a21), SPH_C32(0x7cf88170), SPH_C32(0x25787800), + SPH_C32(0x93df0000), SPH_C32(0x8d6b0000), SPH_C32(0x110c0000), + SPH_C32(0x649c073b), SPH_C32(0x98557743), SPH_C32(0x0f57e2ed), + SPH_C32(0xd79dfeba) }, + { SPH_C32(0x2dbbce70), SPH_C32(0xcc9d0000), SPH_C32(0x0ca50000), + SPH_C32(0x1c990000), SPH_C32(0x0c8472d9), SPH_C32(0x9fd036e0), + SPH_C32(0xbf863070), SPH_C32(0xeeb7dc7a), SPH_C32(0xec137830), + SPH_C32(0x74fa0000), SPH_C32(0xa2ef0000), SPH_C32(0x37430000), + SPH_C32(0x6cf55cc2), SPH_C32(0xf5a98674), SPH_C32(0x5fc88b69), + SPH_C32(0x49f451d2) }, + { SPH_C32(0x0bdbcc30), SPH_C32(0x11450000), SPH_C32(0x7e8f0000), + SPH_C32(0x539f0000), SPH_C32(0x9fe21526), SPH_C32(0xb629722e), + SPH_C32(0x890d53a5), SPH_C32(0xe2912e18), SPH_C32(0x03187a40), + SPH_C32(0x4e070000), SPH_C32(0xff410000), SPH_C32(0x5e0a0000), + SPH_C32(0xf7fa60c4), SPH_C32(0xb1ac338d), SPH_C32(0x39dc8138), + SPH_C32(0xdbbb0cd8) }, + { SPH_C32(0xe4d0ce40), SPH_C32(0x2bb80000), SPH_C32(0x23210000), + SPH_C32(0x3ad60000), SPH_C32(0x04ed2920), SPH_C32(0xf22cc7d7), + SPH_C32(0xef1959f4), SPH_C32(0x70de7312), SPH_C32(0xca737a70), + SPH_C32(0xa9220000), SPH_C32(0xd0c50000), SPH_C32(0x78450000), + SPH_C32(0xff933b3d), SPH_C32(0xdc50c2ba), SPH_C32(0x6943e8bc), + SPH_C32(0x45d2a3b0) }, + { SPH_C32(0xd6eaf000), SPH_C32(0x4f890000), SPH_C32(0x302c0000), + SPH_C32(0x84b10000), SPH_C32(0x59ea73b3), SPH_C32(0x6b9cbe61), + SPH_C32(0x9e3b5d01), SPH_C32(0x9d76a5b5), SPH_C32(0x061f6c00), + SPH_C32(0x5b660000), SPH_C32(0x79ac0000), SPH_C32(0xea790000), + SPH_C32(0x1751235e), SPH_C32(0x60f3d20a), SPH_C32(0x0d93e8d2), + SPH_C32(0x0bb918a5) }, + { SPH_C32(0x39e1f270), SPH_C32(0x75740000), SPH_C32(0x6d820000), + SPH_C32(0xedf80000), SPH_C32(0xc2e54fb5), SPH_C32(0x2f990b98), + SPH_C32(0xf82f5750), SPH_C32(0x0f39f8bf), SPH_C32(0xcf746c30), + SPH_C32(0xbc430000), SPH_C32(0x56280000), SPH_C32(0xcc360000), + SPH_C32(0x1f3878a7), SPH_C32(0x0d0f233d), SPH_C32(0x5d0c8156), + SPH_C32(0x95d0b7cd) }, + { SPH_C32(0x1f81f030), SPH_C32(0xa8ac0000), SPH_C32(0x1fa80000), + SPH_C32(0xa2fe0000), SPH_C32(0x5183284a), SPH_C32(0x06604f56), + SPH_C32(0xcea43485), SPH_C32(0x031f0add), SPH_C32(0x207f6e40), + SPH_C32(0x86be0000), SPH_C32(0x0b860000), SPH_C32(0xa57f0000), + SPH_C32(0x843744a1), SPH_C32(0x490a96c4), SPH_C32(0x3b188b07), + SPH_C32(0x079feac7) }, + { SPH_C32(0xf08af240), SPH_C32(0x92510000), SPH_C32(0x42060000), + SPH_C32(0xcbb70000), SPH_C32(0xca8c144c), SPH_C32(0x4265faaf), + SPH_C32(0xa8b03ed4), SPH_C32(0x915057d7), SPH_C32(0xe9146e70), + SPH_C32(0x619b0000), SPH_C32(0x24020000), SPH_C32(0x83300000), + SPH_C32(0x8c5e1f58), SPH_C32(0x24f667f3), SPH_C32(0x6b87e283), + SPH_C32(0x99f645af) }, + { SPH_C32(0x466d0c00), SPH_C32(0x08620000), SPH_C32(0xdd5d0000), + SPH_C32(0xbadd0000), SPH_C32(0x6a927942), SPH_C32(0x441f2b93), + SPH_C32(0x218ace6f), SPH_C32(0xbf2c0be2), SPH_C32(0x6f299000), + SPH_C32(0x6c850000), SPH_C32(0x2f160000), SPH_C32(0x782e0000), + SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), SPH_C32(0xd26a8c36), + SPH_C32(0x32219526) }, + { SPH_C32(0xa9660e70), SPH_C32(0x329f0000), SPH_C32(0x80f30000), + SPH_C32(0xd3940000), SPH_C32(0xf19d4544), SPH_C32(0x001a9e6a), + SPH_C32(0x479ec43e), SPH_C32(0x2d6356e8), SPH_C32(0xa6429030), + SPH_C32(0x8ba00000), SPH_C32(0x00920000), SPH_C32(0x5e610000), + SPH_C32(0x6c256c34), SPH_C32(0x7f21ede1), SPH_C32(0x82f5e5b2), + SPH_C32(0xac483a4e) }, + { SPH_C32(0x8f060c30), SPH_C32(0xef470000), SPH_C32(0xf2d90000), + SPH_C32(0x9c920000), SPH_C32(0x62fb22bb), SPH_C32(0x29e3daa4), + SPH_C32(0x7115a7eb), SPH_C32(0x2145a48a), SPH_C32(0x49499240), + SPH_C32(0xb15d0000), SPH_C32(0x5d3c0000), SPH_C32(0x37280000), + SPH_C32(0xf72a5032), SPH_C32(0x3b245818), SPH_C32(0xe4e1efe3), + SPH_C32(0x3e076744) }, + { SPH_C32(0x600d0e40), SPH_C32(0xd5ba0000), SPH_C32(0xaf770000), + SPH_C32(0xf5db0000), SPH_C32(0xf9f41ebd), SPH_C32(0x6de66f5d), + SPH_C32(0x1701adba), SPH_C32(0xb30af980), SPH_C32(0x80229270), + SPH_C32(0x56780000), SPH_C32(0x72b80000), SPH_C32(0x11670000), + SPH_C32(0xff430bcb), SPH_C32(0x56d8a92f), SPH_C32(0xb47e8667), + SPH_C32(0xa06ec82c) }, + { SPH_C32(0x52373000), SPH_C32(0xb18b0000), SPH_C32(0xbc7a0000), + SPH_C32(0x4bbc0000), SPH_C32(0xa4f3442e), SPH_C32(0xf45616eb), + SPH_C32(0x6623a94f), SPH_C32(0x5ea22f27), SPH_C32(0x4c4e8400), + SPH_C32(0xa43c0000), SPH_C32(0xdbd10000), SPH_C32(0x835b0000), + SPH_C32(0x178113a8), SPH_C32(0xea7bb99f), SPH_C32(0xd0ae8609), + SPH_C32(0xee057339) }, + { SPH_C32(0xbd3c3270), SPH_C32(0x8b760000), SPH_C32(0xe1d40000), + SPH_C32(0x22f50000), SPH_C32(0x3ffc7828), SPH_C32(0xb053a312), + SPH_C32(0x0037a31e), SPH_C32(0xcced722d), SPH_C32(0x85258430), + SPH_C32(0x43190000), SPH_C32(0xf4550000), SPH_C32(0xa5140000), + SPH_C32(0x1fe84851), SPH_C32(0x878748a8), SPH_C32(0x8031ef8d), + SPH_C32(0x706cdc51) }, + { SPH_C32(0x9b5c3030), SPH_C32(0x56ae0000), SPH_C32(0x93fe0000), + SPH_C32(0x6df30000), SPH_C32(0xac9a1fd7), SPH_C32(0x99aae7dc), + SPH_C32(0x36bcc0cb), SPH_C32(0xc0cb804f), SPH_C32(0x6a2e8640), + SPH_C32(0x79e40000), SPH_C32(0xa9fb0000), SPH_C32(0xcc5d0000), + SPH_C32(0x84e77457), SPH_C32(0xc382fd51), SPH_C32(0xe625e5dc), + SPH_C32(0xe223815b) }, + { SPH_C32(0x74573240), SPH_C32(0x6c530000), SPH_C32(0xce500000), + SPH_C32(0x04ba0000), SPH_C32(0x379523d1), SPH_C32(0xddaf5225), + SPH_C32(0x50a8ca9a), SPH_C32(0x5284dd45), SPH_C32(0xa3458670), + SPH_C32(0x9ec10000), SPH_C32(0x867f0000), SPH_C32(0xea120000), + SPH_C32(0x8c8e2fae), SPH_C32(0xae7e0c66), SPH_C32(0xb6ba8c58), + SPH_C32(0x7c4a2e33) }, + { SPH_C32(0x650a1800), SPH_C32(0xc0db0000), SPH_C32(0x299a0000), + SPH_C32(0x41a80000), SPH_C32(0x195f5d27), SPH_C32(0xbcb98eda), + SPH_C32(0x234ec450), SPH_C32(0x6308edfd), SPH_C32(0x5814b800), + SPH_C32(0x1dd50000), SPH_C32(0xbaf60000), SPH_C32(0x723a0000), + SPH_C32(0xd9e02ec4), SPH_C32(0x5a3284e7), SPH_C32(0x9707e129), + SPH_C32(0x0f8b57fc) }, + { SPH_C32(0x8a011a70), SPH_C32(0xfa260000), SPH_C32(0x74340000), + SPH_C32(0x28e10000), SPH_C32(0x82506121), SPH_C32(0xf8bc3b23), + SPH_C32(0x455ace01), SPH_C32(0xf147b0f7), SPH_C32(0x917fb830), + SPH_C32(0xfaf00000), SPH_C32(0x95720000), SPH_C32(0x54750000), + SPH_C32(0xd189753d), SPH_C32(0x37ce75d0), SPH_C32(0xc79888ad), + SPH_C32(0x91e2f894) }, + { SPH_C32(0xac611830), SPH_C32(0x27fe0000), SPH_C32(0x061e0000), + SPH_C32(0x67e70000), SPH_C32(0x113606de), SPH_C32(0xd1457fed), + SPH_C32(0x73d1add4), SPH_C32(0xfd614295), SPH_C32(0x7e74ba40), + SPH_C32(0xc00d0000), SPH_C32(0xc8dc0000), SPH_C32(0x3d3c0000), + SPH_C32(0x4a86493b), SPH_C32(0x73cbc029), SPH_C32(0xa18c82fc), + SPH_C32(0x03ada59e) }, + { SPH_C32(0x436a1a40), SPH_C32(0x1d030000), SPH_C32(0x5bb00000), + SPH_C32(0x0eae0000), SPH_C32(0x8a393ad8), SPH_C32(0x9540ca14), + SPH_C32(0x15c5a785), SPH_C32(0x6f2e1f9f), SPH_C32(0xb71fba70), + SPH_C32(0x27280000), SPH_C32(0xe7580000), SPH_C32(0x1b730000), + SPH_C32(0x42ef12c2), SPH_C32(0x1e37311e), SPH_C32(0xf113eb78), + SPH_C32(0x9dc40af6) }, + { SPH_C32(0x71502400), SPH_C32(0x79320000), SPH_C32(0x48bd0000), + SPH_C32(0xb0c90000), SPH_C32(0xd73e604b), SPH_C32(0x0cf0b3a2), + SPH_C32(0x64e7a370), SPH_C32(0x8286c938), SPH_C32(0x7b73ac00), + SPH_C32(0xd56c0000), SPH_C32(0x4e310000), SPH_C32(0x894f0000), + SPH_C32(0xaa2d0aa1), SPH_C32(0xa29421ae), SPH_C32(0x95c3eb16), + SPH_C32(0xd3afb1e3) }, + { SPH_C32(0x9e5b2670), SPH_C32(0x43cf0000), SPH_C32(0x15130000), + SPH_C32(0xd9800000), SPH_C32(0x4c315c4d), SPH_C32(0x48f5065b), + SPH_C32(0x02f3a921), SPH_C32(0x10c99432), SPH_C32(0xb218ac30), + SPH_C32(0x32490000), SPH_C32(0x61b50000), SPH_C32(0xaf000000), + SPH_C32(0xa2445158), SPH_C32(0xcf68d099), SPH_C32(0xc55c8292), + SPH_C32(0x4dc61e8b) }, + { SPH_C32(0xb83b2430), SPH_C32(0x9e170000), SPH_C32(0x67390000), + SPH_C32(0x96860000), SPH_C32(0xdf573bb2), SPH_C32(0x610c4295), + SPH_C32(0x3478caf4), SPH_C32(0x1cef6650), SPH_C32(0x5d13ae40), + SPH_C32(0x08b40000), SPH_C32(0x3c1b0000), SPH_C32(0xc6490000), + SPH_C32(0x394b6d5e), SPH_C32(0x8b6d6560), SPH_C32(0xa34888c3), + SPH_C32(0xdf894381) }, + { SPH_C32(0x57302640), SPH_C32(0xa4ea0000), SPH_C32(0x3a970000), + SPH_C32(0xffcf0000), SPH_C32(0x445807b4), SPH_C32(0x2509f76c), + SPH_C32(0x526cc0a5), SPH_C32(0x8ea03b5a), SPH_C32(0x9478ae70), + SPH_C32(0xef910000), SPH_C32(0x139f0000), SPH_C32(0xe0060000), + SPH_C32(0x312236a7), SPH_C32(0xe6919457), SPH_C32(0xf3d7e147), + SPH_C32(0x41e0ece9) }, + { SPH_C32(0x12455000), SPH_C32(0xe28f0000), SPH_C32(0x188b0000), + SPH_C32(0x1b180000), SPH_C32(0xd9301e32), SPH_C32(0xd0baef72), + SPH_C32(0x4a3a8ff2), SPH_C32(0xea373c60), SPH_C32(0xf3928800), + SPH_C32(0xdc560000), SPH_C32(0xbd470000), SPH_C32(0x95bd0000), + SPH_C32(0x3d767488), SPH_C32(0xf3c9c922), SPH_C32(0x916cbfec), + SPH_C32(0x4aeb5b0f) }, + { SPH_C32(0xfd4e5270), SPH_C32(0xd8720000), SPH_C32(0x45250000), + SPH_C32(0x72510000), SPH_C32(0x423f2234), SPH_C32(0x94bf5a8b), + SPH_C32(0x2c2e85a3), SPH_C32(0x7878616a), SPH_C32(0x3af98830), + SPH_C32(0x3b730000), SPH_C32(0x92c30000), SPH_C32(0xb3f20000), + SPH_C32(0x351f2f71), SPH_C32(0x9e353815), SPH_C32(0xc1f3d668), + SPH_C32(0xd482f467) }, + { SPH_C32(0xdb2e5030), SPH_C32(0x05aa0000), SPH_C32(0x370f0000), + SPH_C32(0x3d570000), SPH_C32(0xd15945cb), SPH_C32(0xbd461e45), + SPH_C32(0x1aa5e676), SPH_C32(0x745e9308), SPH_C32(0xd5f28a40), + SPH_C32(0x018e0000), SPH_C32(0xcf6d0000), SPH_C32(0xdabb0000), + SPH_C32(0xae101377), SPH_C32(0xda308dec), SPH_C32(0xa7e7dc39), + SPH_C32(0x46cda96d) }, + { SPH_C32(0x34255240), SPH_C32(0x3f570000), SPH_C32(0x6aa10000), + SPH_C32(0x541e0000), SPH_C32(0x4a5679cd), SPH_C32(0xf943abbc), + SPH_C32(0x7cb1ec27), SPH_C32(0xe611ce02), SPH_C32(0x1c998a70), + SPH_C32(0xe6ab0000), SPH_C32(0xe0e90000), SPH_C32(0xfcf40000), + SPH_C32(0xa679488e), SPH_C32(0xb7cc7cdb), SPH_C32(0xf778b5bd), + SPH_C32(0xd8a40605) }, + { SPH_C32(0x061f6c00), SPH_C32(0x5b660000), SPH_C32(0x79ac0000), + SPH_C32(0xea790000), SPH_C32(0x1751235e), SPH_C32(0x60f3d20a), + SPH_C32(0x0d93e8d2), SPH_C32(0x0bb918a5), SPH_C32(0xd0f59c00), + SPH_C32(0x14ef0000), SPH_C32(0x49800000), SPH_C32(0x6ec80000), + SPH_C32(0x4ebb50ed), SPH_C32(0x0b6f6c6b), SPH_C32(0x93a8b5d3), + SPH_C32(0x96cfbd10) }, + { SPH_C32(0xe9146e70), SPH_C32(0x619b0000), SPH_C32(0x24020000), + SPH_C32(0x83300000), SPH_C32(0x8c5e1f58), SPH_C32(0x24f667f3), + SPH_C32(0x6b87e283), SPH_C32(0x99f645af), SPH_C32(0x199e9c30), + SPH_C32(0xf3ca0000), SPH_C32(0x66040000), SPH_C32(0x48870000), + SPH_C32(0x46d20b14), SPH_C32(0x66939d5c), SPH_C32(0xc337dc57), + SPH_C32(0x08a61278) }, + { SPH_C32(0xcf746c30), SPH_C32(0xbc430000), SPH_C32(0x56280000), + SPH_C32(0xcc360000), SPH_C32(0x1f3878a7), SPH_C32(0x0d0f233d), + SPH_C32(0x5d0c8156), SPH_C32(0x95d0b7cd), SPH_C32(0xf6959e40), + SPH_C32(0xc9370000), SPH_C32(0x3baa0000), SPH_C32(0x21ce0000), + SPH_C32(0xdddd3712), SPH_C32(0x229628a5), SPH_C32(0xa523d606), + SPH_C32(0x9ae94f72) }, + { SPH_C32(0x207f6e40), SPH_C32(0x86be0000), SPH_C32(0x0b860000), + SPH_C32(0xa57f0000), SPH_C32(0x843744a1), SPH_C32(0x490a96c4), + SPH_C32(0x3b188b07), SPH_C32(0x079feac7), SPH_C32(0x3ffe9e70), + SPH_C32(0x2e120000), SPH_C32(0x142e0000), SPH_C32(0x07810000), + SPH_C32(0xd5b46ceb), SPH_C32(0x4f6ad992), SPH_C32(0xf5bcbf82), + SPH_C32(0x0480e01a) }, + { SPH_C32(0x31224400), SPH_C32(0x2a360000), SPH_C32(0xec4c0000), + SPH_C32(0xe06d0000), SPH_C32(0xaafd3a57), SPH_C32(0x281c4a3b), + SPH_C32(0x48fe85cd), SPH_C32(0x3613da7f), SPH_C32(0xc4afa000), + SPH_C32(0xad060000), SPH_C32(0x28a70000), SPH_C32(0x9fa90000), + SPH_C32(0x80da6d81), SPH_C32(0xbb265113), SPH_C32(0xd401d2f3), + SPH_C32(0x774199d5) }, + { SPH_C32(0xde294670), SPH_C32(0x10cb0000), SPH_C32(0xb1e20000), + SPH_C32(0x89240000), SPH_C32(0x31f20651), SPH_C32(0x6c19ffc2), + SPH_C32(0x2eea8f9c), SPH_C32(0xa45c8775), SPH_C32(0x0dc4a030), + SPH_C32(0x4a230000), SPH_C32(0x07230000), SPH_C32(0xb9e60000), + SPH_C32(0x88b33678), SPH_C32(0xd6daa024), SPH_C32(0x849ebb77), + SPH_C32(0xe92836bd) }, + { SPH_C32(0xf8494430), SPH_C32(0xcd130000), SPH_C32(0xc3c80000), + SPH_C32(0xc6220000), SPH_C32(0xa29461ae), SPH_C32(0x45e0bb0c), + SPH_C32(0x1861ec49), SPH_C32(0xa87a7517), SPH_C32(0xe2cfa240), + SPH_C32(0x70de0000), SPH_C32(0x5a8d0000), SPH_C32(0xd0af0000), + SPH_C32(0x13bc0a7e), SPH_C32(0x92df15dd), SPH_C32(0xe28ab126), + SPH_C32(0x7b676bb7) }, + { SPH_C32(0x17424640), SPH_C32(0xf7ee0000), SPH_C32(0x9e660000), + SPH_C32(0xaf6b0000), SPH_C32(0x399b5da8), SPH_C32(0x01e50ef5), + SPH_C32(0x7e75e618), SPH_C32(0x3a35281d), SPH_C32(0x2ba4a270), + SPH_C32(0x97fb0000), SPH_C32(0x75090000), SPH_C32(0xf6e00000), + SPH_C32(0x1bd55187), SPH_C32(0xff23e4ea), SPH_C32(0xb215d8a2), + SPH_C32(0xe50ec4df) }, + { SPH_C32(0x25787800), SPH_C32(0x93df0000), SPH_C32(0x8d6b0000), + SPH_C32(0x110c0000), SPH_C32(0x649c073b), SPH_C32(0x98557743), + SPH_C32(0x0f57e2ed), SPH_C32(0xd79dfeba), SPH_C32(0xe7c8b400), + SPH_C32(0x65bf0000), SPH_C32(0xdc600000), SPH_C32(0x64dc0000), + SPH_C32(0xf31749e4), SPH_C32(0x4380f45a), SPH_C32(0xd6c5d8cc), + SPH_C32(0xab657fca) }, + { SPH_C32(0xca737a70), SPH_C32(0xa9220000), SPH_C32(0xd0c50000), + SPH_C32(0x78450000), SPH_C32(0xff933b3d), SPH_C32(0xdc50c2ba), + SPH_C32(0x6943e8bc), SPH_C32(0x45d2a3b0), SPH_C32(0x2ea3b430), + SPH_C32(0x829a0000), SPH_C32(0xf3e40000), SPH_C32(0x42930000), + SPH_C32(0xfb7e121d), SPH_C32(0x2e7c056d), SPH_C32(0x865ab148), + SPH_C32(0x350cd0a2) }, + { SPH_C32(0xec137830), SPH_C32(0x74fa0000), SPH_C32(0xa2ef0000), + SPH_C32(0x37430000), SPH_C32(0x6cf55cc2), SPH_C32(0xf5a98674), + SPH_C32(0x5fc88b69), SPH_C32(0x49f451d2), SPH_C32(0xc1a8b640), + SPH_C32(0xb8670000), SPH_C32(0xae4a0000), SPH_C32(0x2bda0000), + SPH_C32(0x60712e1b), SPH_C32(0x6a79b094), SPH_C32(0xe04ebb19), + SPH_C32(0xa7438da8) }, + { SPH_C32(0x03187a40), SPH_C32(0x4e070000), SPH_C32(0xff410000), + SPH_C32(0x5e0a0000), SPH_C32(0xf7fa60c4), SPH_C32(0xb1ac338d), + SPH_C32(0x39dc8138), SPH_C32(0xdbbb0cd8), SPH_C32(0x08c3b670), + SPH_C32(0x5f420000), SPH_C32(0x81ce0000), SPH_C32(0x0d950000), + SPH_C32(0x681875e2), SPH_C32(0x078541a3), SPH_C32(0xb0d1d29d), + SPH_C32(0x392a22c0) }, + { SPH_C32(0xdad61400), SPH_C32(0xb8b10000), SPH_C32(0x4f0c0000), + SPH_C32(0x574e0000), SPH_C32(0x33a83a07), SPH_C32(0xa50bfe67), + SPH_C32(0x628cfdb5), SPH_C32(0xc7e6c5cb), SPH_C32(0xa7bad400), + SPH_C32(0x36bb0000), SPH_C32(0x78910000), SPH_C32(0x34780000), + SPH_C32(0x8ed413f8), SPH_C32(0x676c0dc3), SPH_C32(0xfadcfe71), + SPH_C32(0x1ff06c8d) }, + { SPH_C32(0x35dd1670), SPH_C32(0x824c0000), SPH_C32(0x12a20000), + SPH_C32(0x3e070000), SPH_C32(0xa8a70601), SPH_C32(0xe10e4b9e), + SPH_C32(0x0498f7e4), SPH_C32(0x55a998c1), SPH_C32(0x6ed1d430), + SPH_C32(0xd19e0000), SPH_C32(0x57150000), SPH_C32(0x12370000), + SPH_C32(0x86bd4801), SPH_C32(0x0a90fcf4), SPH_C32(0xaa4397f5), + SPH_C32(0x8199c3e5) }, + { SPH_C32(0x13bd1430), SPH_C32(0x5f940000), SPH_C32(0x60880000), + SPH_C32(0x71010000), SPH_C32(0x3bc161fe), SPH_C32(0xc8f70f50), + SPH_C32(0x32139431), SPH_C32(0x598f6aa3), SPH_C32(0x81dad640), + SPH_C32(0xeb630000), SPH_C32(0x0abb0000), SPH_C32(0x7b7e0000), + SPH_C32(0x1db27407), SPH_C32(0x4e95490d), SPH_C32(0xcc579da4), + SPH_C32(0x13d69eef) }, + { SPH_C32(0xfcb61640), SPH_C32(0x65690000), SPH_C32(0x3d260000), + SPH_C32(0x18480000), SPH_C32(0xa0ce5df8), SPH_C32(0x8cf2baa9), + SPH_C32(0x54079e60), SPH_C32(0xcbc037a9), SPH_C32(0x48b1d670), + SPH_C32(0x0c460000), SPH_C32(0x253f0000), SPH_C32(0x5d310000), + SPH_C32(0x15db2ffe), SPH_C32(0x2369b83a), SPH_C32(0x9cc8f420), + SPH_C32(0x8dbf3187) }, + { SPH_C32(0xce8c2800), SPH_C32(0x01580000), SPH_C32(0x2e2b0000), + SPH_C32(0xa62f0000), SPH_C32(0xfdc9076b), SPH_C32(0x1542c31f), + SPH_C32(0x25259a95), SPH_C32(0x2668e10e), SPH_C32(0x84ddc000), + SPH_C32(0xfe020000), SPH_C32(0x8c560000), SPH_C32(0xcf0d0000), + SPH_C32(0xfd19379d), SPH_C32(0x9fcaa88a), SPH_C32(0xf818f44e), + SPH_C32(0xc3d48a92) }, + { SPH_C32(0x21872a70), SPH_C32(0x3ba50000), SPH_C32(0x73850000), + SPH_C32(0xcf660000), SPH_C32(0x66c63b6d), SPH_C32(0x514776e6), + SPH_C32(0x433190c4), SPH_C32(0xb427bc04), SPH_C32(0x4db6c030), + SPH_C32(0x19270000), SPH_C32(0xa3d20000), SPH_C32(0xe9420000), + SPH_C32(0xf5706c64), SPH_C32(0xf23659bd), SPH_C32(0xa8879dca), + SPH_C32(0x5dbd25fa) }, + { SPH_C32(0x07e72830), SPH_C32(0xe67d0000), SPH_C32(0x01af0000), + SPH_C32(0x80600000), SPH_C32(0xf5a05c92), SPH_C32(0x78be3228), + SPH_C32(0x75baf311), SPH_C32(0xb8014e66), SPH_C32(0xa2bdc240), + SPH_C32(0x23da0000), SPH_C32(0xfe7c0000), SPH_C32(0x800b0000), + SPH_C32(0x6e7f5062), SPH_C32(0xb633ec44), SPH_C32(0xce93979b), + SPH_C32(0xcff278f0) }, + { SPH_C32(0xe8ec2a40), SPH_C32(0xdc800000), SPH_C32(0x5c010000), + SPH_C32(0xe9290000), SPH_C32(0x6eaf6094), SPH_C32(0x3cbb87d1), + SPH_C32(0x13aef940), SPH_C32(0x2a4e136c), SPH_C32(0x6bd6c270), + SPH_C32(0xc4ff0000), SPH_C32(0xd1f80000), SPH_C32(0xa6440000), + SPH_C32(0x66160b9b), SPH_C32(0xdbcf1d73), SPH_C32(0x9e0cfe1f), + SPH_C32(0x519bd798) }, + { SPH_C32(0xf9b10000), SPH_C32(0x70080000), SPH_C32(0xbbcb0000), + SPH_C32(0xac3b0000), SPH_C32(0x40651e62), SPH_C32(0x5dad5b2e), + SPH_C32(0x6048f78a), SPH_C32(0x1bc223d4), SPH_C32(0x9087fc00), + SPH_C32(0x47eb0000), SPH_C32(0xed710000), SPH_C32(0x3e6c0000), + SPH_C32(0x33780af1), SPH_C32(0x2f8395f2), SPH_C32(0xbfb1936e), + SPH_C32(0x225aae57) }, + { SPH_C32(0x16ba0270), SPH_C32(0x4af50000), SPH_C32(0xe6650000), + SPH_C32(0xc5720000), SPH_C32(0xdb6a2264), SPH_C32(0x19a8eed7), + SPH_C32(0x065cfddb), SPH_C32(0x898d7ede), SPH_C32(0x59ecfc30), + SPH_C32(0xa0ce0000), SPH_C32(0xc2f50000), SPH_C32(0x18230000), + SPH_C32(0x3b115108), SPH_C32(0x427f64c5), SPH_C32(0xef2efaea), + SPH_C32(0xbc33013f) }, + { SPH_C32(0x30da0030), SPH_C32(0x972d0000), SPH_C32(0x944f0000), + SPH_C32(0x8a740000), SPH_C32(0x480c459b), SPH_C32(0x3051aa19), + SPH_C32(0x30d79e0e), SPH_C32(0x85ab8cbc), SPH_C32(0xb6e7fe40), + SPH_C32(0x9a330000), SPH_C32(0x9f5b0000), SPH_C32(0x716a0000), + SPH_C32(0xa01e6d0e), SPH_C32(0x067ad13c), SPH_C32(0x893af0bb), + SPH_C32(0x2e7c5c35) }, + { SPH_C32(0xdfd10240), SPH_C32(0xadd00000), SPH_C32(0xc9e10000), + SPH_C32(0xe33d0000), SPH_C32(0xd303799d), SPH_C32(0x74541fe0), + SPH_C32(0x56c3945f), SPH_C32(0x17e4d1b6), SPH_C32(0x7f8cfe70), + SPH_C32(0x7d160000), SPH_C32(0xb0df0000), SPH_C32(0x57250000), + SPH_C32(0xa87736f7), SPH_C32(0x6b86200b), SPH_C32(0xd9a5993f), + SPH_C32(0xb015f35d) }, + { SPH_C32(0xedeb3c00), SPH_C32(0xc9e10000), SPH_C32(0xdaec0000), + SPH_C32(0x5d5a0000), SPH_C32(0x8e04230e), SPH_C32(0xede46656), + SPH_C32(0x27e190aa), SPH_C32(0xfa4c0711), SPH_C32(0xb3e0e800), + SPH_C32(0x8f520000), SPH_C32(0x19b60000), SPH_C32(0xc5190000), + SPH_C32(0x40b52e94), SPH_C32(0xd72530bb), SPH_C32(0xbd759951), + SPH_C32(0xfe7e4848) }, + { SPH_C32(0x02e03e70), SPH_C32(0xf31c0000), SPH_C32(0x87420000), + SPH_C32(0x34130000), SPH_C32(0x150b1f08), SPH_C32(0xa9e1d3af), + SPH_C32(0x41f59afb), SPH_C32(0x68035a1b), SPH_C32(0x7a8be830), + SPH_C32(0x68770000), SPH_C32(0x36320000), SPH_C32(0xe3560000), + SPH_C32(0x48dc756d), SPH_C32(0xbad9c18c), SPH_C32(0xedeaf0d5), + SPH_C32(0x6017e720) }, + { SPH_C32(0x24803c30), SPH_C32(0x2ec40000), SPH_C32(0xf5680000), + SPH_C32(0x7b150000), SPH_C32(0x866d78f7), SPH_C32(0x80189761), + SPH_C32(0x777ef92e), SPH_C32(0x6425a879), SPH_C32(0x9580ea40), + SPH_C32(0x528a0000), SPH_C32(0x6b9c0000), SPH_C32(0x8a1f0000), + SPH_C32(0xd3d3496b), SPH_C32(0xfedc7475), SPH_C32(0x8bfefa84), + SPH_C32(0xf258ba2a) }, + { SPH_C32(0xcb8b3e40), SPH_C32(0x14390000), SPH_C32(0xa8c60000), + SPH_C32(0x125c0000), SPH_C32(0x1d6244f1), SPH_C32(0xc41d2298), + SPH_C32(0x116af37f), SPH_C32(0xf66af573), SPH_C32(0x5cebea70), + SPH_C32(0xb5af0000), SPH_C32(0x44180000), SPH_C32(0xac500000), + SPH_C32(0xdbba1292), SPH_C32(0x93208542), SPH_C32(0xdb619300), + SPH_C32(0x6c311542) }, + { SPH_C32(0x8efe4800), SPH_C32(0x525c0000), SPH_C32(0x8ada0000), + SPH_C32(0xf68b0000), SPH_C32(0x800a5d77), SPH_C32(0x31ae3a86), + SPH_C32(0x093cbc28), SPH_C32(0x92fdf249), SPH_C32(0x3b01cc00), + SPH_C32(0x86680000), SPH_C32(0xeac00000), SPH_C32(0xd9eb0000), + SPH_C32(0xd7ee50bd), SPH_C32(0x8678d837), SPH_C32(0xb9dacdab), + SPH_C32(0x673aa2a4) }, + { SPH_C32(0x61f54a70), SPH_C32(0x68a10000), SPH_C32(0xd7740000), + SPH_C32(0x9fc20000), SPH_C32(0x1b056171), SPH_C32(0x75ab8f7f), + SPH_C32(0x6f28b679), SPH_C32(0x00b2af43), SPH_C32(0xf26acc30), + SPH_C32(0x614d0000), SPH_C32(0xc5440000), SPH_C32(0xffa40000), + SPH_C32(0xdf870b44), SPH_C32(0xeb842900), SPH_C32(0xe945a42f), + SPH_C32(0xf9530dcc) }, + { SPH_C32(0x47954830), SPH_C32(0xb5790000), SPH_C32(0xa55e0000), + SPH_C32(0xd0c40000), SPH_C32(0x8863068e), SPH_C32(0x5c52cbb1), + SPH_C32(0x59a3d5ac), SPH_C32(0x0c945d21), SPH_C32(0x1d61ce40), + SPH_C32(0x5bb00000), SPH_C32(0x98ea0000), SPH_C32(0x96ed0000), + SPH_C32(0x44883742), SPH_C32(0xaf819cf9), SPH_C32(0x8f51ae7e), + SPH_C32(0x6b1c50c6) }, + { SPH_C32(0xa89e4a40), SPH_C32(0x8f840000), SPH_C32(0xf8f00000), + SPH_C32(0xb98d0000), SPH_C32(0x136c3a88), SPH_C32(0x18577e48), + SPH_C32(0x3fb7dffd), SPH_C32(0x9edb002b), SPH_C32(0xd40ace70), + SPH_C32(0xbc950000), SPH_C32(0xb76e0000), SPH_C32(0xb0a20000), + SPH_C32(0x4ce16cbb), SPH_C32(0xc27d6dce), SPH_C32(0xdfcec7fa), + SPH_C32(0xf575ffae) }, + { SPH_C32(0x9aa47400), SPH_C32(0xebb50000), SPH_C32(0xebfd0000), + SPH_C32(0x07ea0000), SPH_C32(0x4e6b601b), SPH_C32(0x81e707fe), + SPH_C32(0x4e95db08), SPH_C32(0x7373d68c), SPH_C32(0x1866d800), + SPH_C32(0x4ed10000), SPH_C32(0x1e070000), SPH_C32(0x229e0000), + SPH_C32(0xa42374d8), SPH_C32(0x7ede7d7e), SPH_C32(0xbb1ec794), + SPH_C32(0xbb1e44bb) }, + { SPH_C32(0x75af7670), SPH_C32(0xd1480000), SPH_C32(0xb6530000), + SPH_C32(0x6ea30000), SPH_C32(0xd5645c1d), SPH_C32(0xc5e2b207), + SPH_C32(0x2881d159), SPH_C32(0xe13c8b86), SPH_C32(0xd10dd830), + SPH_C32(0xa9f40000), SPH_C32(0x31830000), SPH_C32(0x04d10000), + SPH_C32(0xac4a2f21), SPH_C32(0x13228c49), SPH_C32(0xeb81ae10), + SPH_C32(0x2577ebd3) }, + { SPH_C32(0x53cf7430), SPH_C32(0x0c900000), SPH_C32(0xc4790000), + SPH_C32(0x21a50000), SPH_C32(0x46023be2), SPH_C32(0xec1bf6c9), + SPH_C32(0x1e0ab28c), SPH_C32(0xed1a79e4), SPH_C32(0x3e06da40), + SPH_C32(0x93090000), SPH_C32(0x6c2d0000), SPH_C32(0x6d980000), + SPH_C32(0x37451327), SPH_C32(0x572739b0), SPH_C32(0x8d95a441), + SPH_C32(0xb738b6d9) }, + { SPH_C32(0xbcc47640), SPH_C32(0x366d0000), SPH_C32(0x99d70000), + SPH_C32(0x48ec0000), SPH_C32(0xdd0d07e4), SPH_C32(0xa81e4330), + SPH_C32(0x781eb8dd), SPH_C32(0x7f5524ee), SPH_C32(0xf76dda70), + SPH_C32(0x742c0000), SPH_C32(0x43a90000), SPH_C32(0x4bd70000), + SPH_C32(0x3f2c48de), SPH_C32(0x3adbc887), SPH_C32(0xdd0acdc5), + SPH_C32(0x295119b1) }, + { SPH_C32(0xad995c00), SPH_C32(0x9ae50000), SPH_C32(0x7e1d0000), + SPH_C32(0x0dfe0000), SPH_C32(0xf3c77912), SPH_C32(0xc9089fcf), + SPH_C32(0x0bf8b617), SPH_C32(0x4ed91456), SPH_C32(0x0c3ce400), + SPH_C32(0xf7380000), SPH_C32(0x7f200000), SPH_C32(0xd3ff0000), + SPH_C32(0x6a4249b4), SPH_C32(0xce974006), SPH_C32(0xfcb7a0b4), + SPH_C32(0x5a90607e) }, + { SPH_C32(0x42925e70), SPH_C32(0xa0180000), SPH_C32(0x23b30000), + SPH_C32(0x64b70000), SPH_C32(0x68c84514), SPH_C32(0x8d0d2a36), + SPH_C32(0x6decbc46), SPH_C32(0xdc96495c), SPH_C32(0xc557e430), + SPH_C32(0x101d0000), SPH_C32(0x50a40000), SPH_C32(0xf5b00000), + SPH_C32(0x622b124d), SPH_C32(0xa36bb131), SPH_C32(0xac28c930), + SPH_C32(0xc4f9cf16) }, + { SPH_C32(0x64f25c30), SPH_C32(0x7dc00000), SPH_C32(0x51990000), + SPH_C32(0x2bb10000), SPH_C32(0xfbae22eb), SPH_C32(0xa4f46ef8), + SPH_C32(0x5b67df93), SPH_C32(0xd0b0bb3e), SPH_C32(0x2a5ce640), + SPH_C32(0x2ae00000), SPH_C32(0x0d0a0000), SPH_C32(0x9cf90000), + SPH_C32(0xf9242e4b), SPH_C32(0xe76e04c8), SPH_C32(0xca3cc361), + SPH_C32(0x56b6921c) }, + { SPH_C32(0x8bf95e40), SPH_C32(0x473d0000), SPH_C32(0x0c370000), + SPH_C32(0x42f80000), SPH_C32(0x60a11eed), SPH_C32(0xe0f1db01), + SPH_C32(0x3d73d5c2), SPH_C32(0x42ffe634), SPH_C32(0xe337e670), + SPH_C32(0xcdc50000), SPH_C32(0x228e0000), SPH_C32(0xbab60000), + SPH_C32(0xf14d75b2), SPH_C32(0x8a92f5ff), SPH_C32(0x9aa3aae5), + SPH_C32(0xc8df3d74) }, + { SPH_C32(0xb9c36000), SPH_C32(0x230c0000), SPH_C32(0x1f3a0000), + SPH_C32(0xfc9f0000), SPH_C32(0x3da6447e), SPH_C32(0x7941a2b7), + SPH_C32(0x4c51d137), SPH_C32(0xaf573093), SPH_C32(0x2f5bf000), + SPH_C32(0x3f810000), SPH_C32(0x8be70000), SPH_C32(0x288a0000), + SPH_C32(0x198f6dd1), SPH_C32(0x3631e54f), SPH_C32(0xfe73aa8b), + SPH_C32(0x86b48661) }, + { SPH_C32(0x56c86270), SPH_C32(0x19f10000), SPH_C32(0x42940000), + SPH_C32(0x95d60000), SPH_C32(0xa6a97878), SPH_C32(0x3d44174e), + SPH_C32(0x2a45db66), SPH_C32(0x3d186d99), SPH_C32(0xe630f030), + SPH_C32(0xd8a40000), SPH_C32(0xa4630000), SPH_C32(0x0ec50000), + SPH_C32(0x11e63628), SPH_C32(0x5bcd1478), SPH_C32(0xaeecc30f), + SPH_C32(0x18dd2909) }, + { SPH_C32(0x70a86030), SPH_C32(0xc4290000), SPH_C32(0x30be0000), + SPH_C32(0xdad00000), SPH_C32(0x35cf1f87), SPH_C32(0x14bd5380), + SPH_C32(0x1cceb8b3), SPH_C32(0x313e9ffb), SPH_C32(0x093bf240), + SPH_C32(0xe2590000), SPH_C32(0xf9cd0000), SPH_C32(0x678c0000), + SPH_C32(0x8ae90a2e), SPH_C32(0x1fc8a181), SPH_C32(0xc8f8c95e), + SPH_C32(0x8a927403) }, + { SPH_C32(0x9fa36240), SPH_C32(0xfed40000), SPH_C32(0x6d100000), + SPH_C32(0xb3990000), SPH_C32(0xaec02381), SPH_C32(0x50b8e679), + SPH_C32(0x7adab2e2), SPH_C32(0xa371c2f1), SPH_C32(0xc050f270), + SPH_C32(0x057c0000), SPH_C32(0xd6490000), SPH_C32(0x41c30000), + SPH_C32(0x828051d7), SPH_C32(0x723450b6), SPH_C32(0x9867a0da), + SPH_C32(0x14fbdb6b) }, + { SPH_C32(0x6f299000), SPH_C32(0x6c850000), SPH_C32(0x2f160000), + SPH_C32(0x782e0000), SPH_C32(0x644c37cd), SPH_C32(0x12dd1cd6), + SPH_C32(0xd26a8c36), SPH_C32(0x32219526), SPH_C32(0x29449c00), + SPH_C32(0x64e70000), SPH_C32(0xf24b0000), SPH_C32(0xc2f30000), + SPH_C32(0x0ede4e8f), SPH_C32(0x56c23745), SPH_C32(0xf3e04259), + SPH_C32(0x8d0d9ec4) }, + { SPH_C32(0x80229270), SPH_C32(0x56780000), SPH_C32(0x72b80000), + SPH_C32(0x11670000), SPH_C32(0xff430bcb), SPH_C32(0x56d8a92f), + SPH_C32(0xb47e8667), SPH_C32(0xa06ec82c), SPH_C32(0xe02f9c30), + SPH_C32(0x83c20000), SPH_C32(0xddcf0000), SPH_C32(0xe4bc0000), + SPH_C32(0x06b71576), SPH_C32(0x3b3ec672), SPH_C32(0xa37f2bdd), + SPH_C32(0x136431ac) }, + { SPH_C32(0xa6429030), SPH_C32(0x8ba00000), SPH_C32(0x00920000), + SPH_C32(0x5e610000), SPH_C32(0x6c256c34), SPH_C32(0x7f21ede1), + SPH_C32(0x82f5e5b2), SPH_C32(0xac483a4e), SPH_C32(0x0f249e40), + SPH_C32(0xb93f0000), SPH_C32(0x80610000), SPH_C32(0x8df50000), + SPH_C32(0x9db82970), SPH_C32(0x7f3b738b), SPH_C32(0xc56b218c), + SPH_C32(0x812b6ca6) }, + { SPH_C32(0x49499240), SPH_C32(0xb15d0000), SPH_C32(0x5d3c0000), + SPH_C32(0x37280000), SPH_C32(0xf72a5032), SPH_C32(0x3b245818), + SPH_C32(0xe4e1efe3), SPH_C32(0x3e076744), SPH_C32(0xc64f9e70), + SPH_C32(0x5e1a0000), SPH_C32(0xafe50000), SPH_C32(0xabba0000), + SPH_C32(0x95d17289), SPH_C32(0x12c782bc), SPH_C32(0x95f44808), + SPH_C32(0x1f42c3ce) }, + { SPH_C32(0x7b73ac00), SPH_C32(0xd56c0000), SPH_C32(0x4e310000), + SPH_C32(0x894f0000), SPH_C32(0xaa2d0aa1), SPH_C32(0xa29421ae), + SPH_C32(0x95c3eb16), SPH_C32(0xd3afb1e3), SPH_C32(0x0a238800), + SPH_C32(0xac5e0000), SPH_C32(0x068c0000), SPH_C32(0x39860000), + SPH_C32(0x7d136aea), SPH_C32(0xae64920c), SPH_C32(0xf1244866), + SPH_C32(0x512978db) }, + { SPH_C32(0x9478ae70), SPH_C32(0xef910000), SPH_C32(0x139f0000), + SPH_C32(0xe0060000), SPH_C32(0x312236a7), SPH_C32(0xe6919457), + SPH_C32(0xf3d7e147), SPH_C32(0x41e0ece9), SPH_C32(0xc3488830), + SPH_C32(0x4b7b0000), SPH_C32(0x29080000), SPH_C32(0x1fc90000), + SPH_C32(0x757a3113), SPH_C32(0xc398633b), SPH_C32(0xa1bb21e2), + SPH_C32(0xcf40d7b3) }, + { SPH_C32(0xb218ac30), SPH_C32(0x32490000), SPH_C32(0x61b50000), + SPH_C32(0xaf000000), SPH_C32(0xa2445158), SPH_C32(0xcf68d099), + SPH_C32(0xc55c8292), SPH_C32(0x4dc61e8b), SPH_C32(0x2c438a40), + SPH_C32(0x71860000), SPH_C32(0x74a60000), SPH_C32(0x76800000), + SPH_C32(0xee750d15), SPH_C32(0x879dd6c2), SPH_C32(0xc7af2bb3), + SPH_C32(0x5d0f8ab9) }, + { SPH_C32(0x5d13ae40), SPH_C32(0x08b40000), SPH_C32(0x3c1b0000), + SPH_C32(0xc6490000), SPH_C32(0x394b6d5e), SPH_C32(0x8b6d6560), + SPH_C32(0xa34888c3), SPH_C32(0xdf894381), SPH_C32(0xe5288a70), + SPH_C32(0x96a30000), SPH_C32(0x5b220000), SPH_C32(0x50cf0000), + SPH_C32(0xe61c56ec), SPH_C32(0xea6127f5), SPH_C32(0x97304237), + SPH_C32(0xc36625d1) }, + { SPH_C32(0x4c4e8400), SPH_C32(0xa43c0000), SPH_C32(0xdbd10000), + SPH_C32(0x835b0000), SPH_C32(0x178113a8), SPH_C32(0xea7bb99f), + SPH_C32(0xd0ae8609), SPH_C32(0xee057339), SPH_C32(0x1e79b400), + SPH_C32(0x15b70000), SPH_C32(0x67ab0000), SPH_C32(0xc8e70000), + SPH_C32(0xb3725786), SPH_C32(0x1e2daf74), SPH_C32(0xb68d2f46), + SPH_C32(0xb0a75c1e) }, + { SPH_C32(0xa3458670), SPH_C32(0x9ec10000), SPH_C32(0x867f0000), + SPH_C32(0xea120000), SPH_C32(0x8c8e2fae), SPH_C32(0xae7e0c66), + SPH_C32(0xb6ba8c58), SPH_C32(0x7c4a2e33), SPH_C32(0xd712b430), + SPH_C32(0xf2920000), SPH_C32(0x482f0000), SPH_C32(0xeea80000), + SPH_C32(0xbb1b0c7f), SPH_C32(0x73d15e43), SPH_C32(0xe61246c2), + SPH_C32(0x2ecef376) }, + { SPH_C32(0x85258430), SPH_C32(0x43190000), SPH_C32(0xf4550000), + SPH_C32(0xa5140000), SPH_C32(0x1fe84851), SPH_C32(0x878748a8), + SPH_C32(0x8031ef8d), SPH_C32(0x706cdc51), SPH_C32(0x3819b640), + SPH_C32(0xc86f0000), SPH_C32(0x15810000), SPH_C32(0x87e10000), + SPH_C32(0x20143079), SPH_C32(0x37d4ebba), SPH_C32(0x80064c93), + SPH_C32(0xbc81ae7c) }, + { SPH_C32(0x6a2e8640), SPH_C32(0x79e40000), SPH_C32(0xa9fb0000), + SPH_C32(0xcc5d0000), SPH_C32(0x84e77457), SPH_C32(0xc382fd51), + SPH_C32(0xe625e5dc), SPH_C32(0xe223815b), SPH_C32(0xf172b670), + SPH_C32(0x2f4a0000), SPH_C32(0x3a050000), SPH_C32(0xa1ae0000), + SPH_C32(0x287d6b80), SPH_C32(0x5a281a8d), SPH_C32(0xd0992517), + SPH_C32(0x22e80114) }, + { SPH_C32(0x5814b800), SPH_C32(0x1dd50000), SPH_C32(0xbaf60000), + SPH_C32(0x723a0000), SPH_C32(0xd9e02ec4), SPH_C32(0x5a3284e7), + SPH_C32(0x9707e129), SPH_C32(0x0f8b57fc), SPH_C32(0x3d1ea000), + SPH_C32(0xdd0e0000), SPH_C32(0x936c0000), SPH_C32(0x33920000), + SPH_C32(0xc0bf73e3), SPH_C32(0xe68b0a3d), SPH_C32(0xb4492579), + SPH_C32(0x6c83ba01) }, + { SPH_C32(0xb71fba70), SPH_C32(0x27280000), SPH_C32(0xe7580000), + SPH_C32(0x1b730000), SPH_C32(0x42ef12c2), SPH_C32(0x1e37311e), + SPH_C32(0xf113eb78), SPH_C32(0x9dc40af6), SPH_C32(0xf475a030), + SPH_C32(0x3a2b0000), SPH_C32(0xbce80000), SPH_C32(0x15dd0000), + SPH_C32(0xc8d6281a), SPH_C32(0x8b77fb0a), SPH_C32(0xe4d64cfd), + SPH_C32(0xf2ea1569) }, + { SPH_C32(0x917fb830), SPH_C32(0xfaf00000), SPH_C32(0x95720000), + SPH_C32(0x54750000), SPH_C32(0xd189753d), SPH_C32(0x37ce75d0), + SPH_C32(0xc79888ad), SPH_C32(0x91e2f894), SPH_C32(0x1b7ea240), + SPH_C32(0x00d60000), SPH_C32(0xe1460000), SPH_C32(0x7c940000), + SPH_C32(0x53d9141c), SPH_C32(0xcf724ef3), SPH_C32(0x82c246ac), + SPH_C32(0x60a54863) }, + { SPH_C32(0x7e74ba40), SPH_C32(0xc00d0000), SPH_C32(0xc8dc0000), + SPH_C32(0x3d3c0000), SPH_C32(0x4a86493b), SPH_C32(0x73cbc029), + SPH_C32(0xa18c82fc), SPH_C32(0x03ada59e), SPH_C32(0xd215a270), + SPH_C32(0xe7f30000), SPH_C32(0xcec20000), SPH_C32(0x5adb0000), + SPH_C32(0x5bb04fe5), SPH_C32(0xa28ebfc4), SPH_C32(0xd25d2f28), + SPH_C32(0xfecce70b) }, + { SPH_C32(0x3b01cc00), SPH_C32(0x86680000), SPH_C32(0xeac00000), + SPH_C32(0xd9eb0000), SPH_C32(0xd7ee50bd), SPH_C32(0x8678d837), + SPH_C32(0xb9dacdab), SPH_C32(0x673aa2a4), SPH_C32(0xb5ff8400), + SPH_C32(0xd4340000), SPH_C32(0x601a0000), SPH_C32(0x2f600000), + SPH_C32(0x57e40dca), SPH_C32(0xb7d6e2b1), SPH_C32(0xb0e67183), + SPH_C32(0xf5c750ed) }, + { SPH_C32(0xd40ace70), SPH_C32(0xbc950000), SPH_C32(0xb76e0000), + SPH_C32(0xb0a20000), SPH_C32(0x4ce16cbb), SPH_C32(0xc27d6dce), + SPH_C32(0xdfcec7fa), SPH_C32(0xf575ffae), SPH_C32(0x7c948430), + SPH_C32(0x33110000), SPH_C32(0x4f9e0000), SPH_C32(0x092f0000), + SPH_C32(0x5f8d5633), SPH_C32(0xda2a1386), SPH_C32(0xe0791807), + SPH_C32(0x6baeff85) }, + { SPH_C32(0xf26acc30), SPH_C32(0x614d0000), SPH_C32(0xc5440000), + SPH_C32(0xffa40000), SPH_C32(0xdf870b44), SPH_C32(0xeb842900), + SPH_C32(0xe945a42f), SPH_C32(0xf9530dcc), SPH_C32(0x939f8640), + SPH_C32(0x09ec0000), SPH_C32(0x12300000), SPH_C32(0x60660000), + SPH_C32(0xc4826a35), SPH_C32(0x9e2fa67f), SPH_C32(0x866d1256), + SPH_C32(0xf9e1a28f) }, + { SPH_C32(0x1d61ce40), SPH_C32(0x5bb00000), SPH_C32(0x98ea0000), + SPH_C32(0x96ed0000), SPH_C32(0x44883742), SPH_C32(0xaf819cf9), + SPH_C32(0x8f51ae7e), SPH_C32(0x6b1c50c6), SPH_C32(0x5af48670), + SPH_C32(0xeec90000), SPH_C32(0x3db40000), SPH_C32(0x46290000), + SPH_C32(0xcceb31cc), SPH_C32(0xf3d35748), SPH_C32(0xd6f27bd2), + SPH_C32(0x67880de7) }, + { SPH_C32(0x2f5bf000), SPH_C32(0x3f810000), SPH_C32(0x8be70000), + SPH_C32(0x288a0000), SPH_C32(0x198f6dd1), SPH_C32(0x3631e54f), + SPH_C32(0xfe73aa8b), SPH_C32(0x86b48661), SPH_C32(0x496989000), + SPH_C32(0x1c8d0000), SPH_C32(0x94dd0000), SPH_C32(0xd4150000), + SPH_C32(0x242929af), SPH_C32(0x4f7047f8), SPH_C32(0xb2227bbc), + SPH_C32(0x29e3b6f2) }, + { SPH_C32(0xc050f270), SPH_C32(0x057c0000), SPH_C32(0xd6490000), + SPH_C32(0x41c30000), SPH_C32(0x828051d7), SPH_C32(0x723450b6), + SPH_C32(0x9867a0da), SPH_C32(0x14fbdb6b), SPH_C32(0x5ff39030), + SPH_C32(0xfba80000), SPH_C32(0xbb590000), SPH_C32(0xf25a0000), + SPH_C32(0x2c407256), SPH_C32(0x228cb6cf), SPH_C32(0xe2bd1238), + SPH_C32(0xb78a199a) }, + { SPH_C32(0xe630f030), SPH_C32(0xd8a40000), SPH_C32(0xa4630000), + SPH_C32(0x0ec50000), SPH_C32(0x11e63628), SPH_C32(0x5bcd1478), + SPH_C32(0xaeecc30f), SPH_C32(0x18dd2909), SPH_C32(0xb0f89240), + SPH_C32(0xc1550000), SPH_C32(0xe6f70000), SPH_C32(0x9b130000), + SPH_C32(0xb74f4e50), SPH_C32(0x66890336), SPH_C32(0x84a91869), + SPH_C32(0x25c54490) }, + { SPH_C32(0x093bf240), SPH_C32(0xe2590000), SPH_C32(0xf9cd0000), + SPH_C32(0x678c0000), SPH_C32(0x8ae90a2e), SPH_C32(0x1fc8a181), + SPH_C32(0xc8f8c95e), SPH_C32(0x8a927403), SPH_C32(0x79939270), + SPH_C32(0x26700000), SPH_C32(0xc9730000), SPH_C32(0xbd5c0000), + SPH_C32(0xbf2615a9), SPH_C32(0x0b75f201), SPH_C32(0xd43671ed), + SPH_C32(0xbbacebf8) }, + { SPH_C32(0x1866d800), SPH_C32(0x4ed10000), SPH_C32(0x1e070000), + SPH_C32(0x229e0000), SPH_C32(0xa42374d8), SPH_C32(0x7ede7d7e), + SPH_C32(0xbb1ec794), SPH_C32(0xbb1e44bb), SPH_C32(0x82c2ac00), + SPH_C32(0xa5640000), SPH_C32(0xf5fa0000), SPH_C32(0x25740000), + SPH_C32(0xea4814c3), SPH_C32(0xff397a80), SPH_C32(0xf58b1c9c), + SPH_C32(0xc86d9237) }, + { SPH_C32(0xf76dda70), SPH_C32(0x742c0000), SPH_C32(0x43a90000), + SPH_C32(0x4bd70000), SPH_C32(0x3f2c48de), SPH_C32(0x3adbc887), + SPH_C32(0xdd0acdc5), SPH_C32(0x295119b1), SPH_C32(0x4ba9ac30), + SPH_C32(0x42410000), SPH_C32(0xda7e0000), SPH_C32(0x033b0000), + SPH_C32(0xe2214f3a), SPH_C32(0x92c58bb7), SPH_C32(0xa5147518), + SPH_C32(0x56043d5f) }, + { SPH_C32(0xd10dd830), SPH_C32(0xa9f40000), SPH_C32(0x31830000), + SPH_C32(0x04d10000), SPH_C32(0xac4a2f21), SPH_C32(0x13228c49), + SPH_C32(0xeb81ae10), SPH_C32(0x2577ebd3), SPH_C32(0xa4a2ae40), + SPH_C32(0x78bc0000), SPH_C32(0x87d00000), SPH_C32(0x6a720000), + SPH_C32(0x792e733c), SPH_C32(0xd6c03e4e), SPH_C32(0xc3007f49), + SPH_C32(0xc44b6055) }, + { SPH_C32(0x3e06da40), SPH_C32(0x93090000), SPH_C32(0x6c2d0000), + SPH_C32(0x6d980000), SPH_C32(0x37451327), SPH_C32(0x572739b0), + SPH_C32(0x8d95a441), SPH_C32(0xb738b6d9), SPH_C32(0x6dc9ae70), + SPH_C32(0x9f990000), SPH_C32(0xa8540000), SPH_C32(0x4c3d0000), + SPH_C32(0x714728c5), SPH_C32(0xbb3ccf79), SPH_C32(0x939f16cd), + SPH_C32(0x5a22cf3d) }, + { SPH_C32(0x0c3ce400), SPH_C32(0xf7380000), SPH_C32(0x7f200000), + SPH_C32(0xd3ff0000), SPH_C32(0x6a4249b4), SPH_C32(0xce974006), + SPH_C32(0xfcb7a0b4), SPH_C32(0x5a90607e), SPH_C32(0xa1a5b800), + SPH_C32(0x6ddd0000), SPH_C32(0x013d0000), SPH_C32(0xde010000), + SPH_C32(0x998530a6), SPH_C32(0x079fdfc9), SPH_C32(0xf74f16a3), + SPH_C32(0x14497428) }, + { SPH_C32(0xe337e670), SPH_C32(0xcdc50000), SPH_C32(0x228e0000), + SPH_C32(0xbab60000), SPH_C32(0xf14d75b2), SPH_C32(0x8a92f5ff), + SPH_C32(0x9aa3aae5), SPH_C32(0xc8df3d74), SPH_C32(0x68ceb830), + SPH_C32(0x8af80000), SPH_C32(0x2eb90000), SPH_C32(0xf84e0000), + SPH_C32(0x91ec6b5f), SPH_C32(0x6a632efe), SPH_C32(0xa7d07f27), + SPH_C32(0x8a20db40) }, + { SPH_C32(0xc557e430), SPH_C32(0x101d0000), SPH_C32(0x50a40000), + SPH_C32(0xf5b00000), SPH_C32(0x622b124d), SPH_C32(0xa36bb131), + SPH_C32(0xac28c930), SPH_C32(0xc4f9cf16), SPH_C32(0x87c5ba40), + SPH_C32(0xb0050000), SPH_C32(0x73170000), SPH_C32(0x91070000), + SPH_C32(0x0ae35759), SPH_C32(0x2e669b07), SPH_C32(0xc1c47576), + SPH_C32(0x186f864a) }, + { SPH_C32(0x2a5ce640), SPH_C32(0x2ae00000), SPH_C32(0x0d0a0000), + SPH_C32(0x9cf90000), SPH_C32(0xf9242e4b), SPH_C32(0xe76e04c8), + SPH_C32(0xca3cc361), SPH_C32(0x56b6921c), SPH_C32(0x4eaeba70), + SPH_C32(0x57200000), SPH_C32(0x5c930000), SPH_C32(0xb7480000), + SPH_C32(0x028a0ca0), SPH_C32(0x439a6a30), SPH_C32(0x915b1cf2), + SPH_C32(0x86062922) }, + { SPH_C32(0xf3928800), SPH_C32(0xdc560000), SPH_C32(0xbd470000), + SPH_C32(0x95bd0000), SPH_C32(0x3d767488), SPH_C32(0xf3c9c922), + SPH_C32(0x916cbfec), SPH_C32(0x4aeb5b0f), SPH_C32(0xe1d7d800), + SPH_C32(0x3ed90000), SPH_C32(0xa5cc0000), SPH_C32(0x8ea50000), + SPH_C32(0xe4466aba), SPH_C32(0x23732650), SPH_C32(0xdb56301e), + SPH_C32(0xa0dc676f) }, + { SPH_C32(0x1c998a70), SPH_C32(0xe6ab0000), SPH_C32(0xe0e90000), + SPH_C32(0xfcf40000), SPH_C32(0xa679488e), SPH_C32(0xb7cc7cdb), + SPH_C32(0xf778b5bd), SPH_C32(0xd8a40605), SPH_C32(0x28bcd830), + SPH_C32(0xd9fc0000), SPH_C32(0x8a480000), SPH_C32(0xa8ea0000), + SPH_C32(0xec2f3143), SPH_C32(0x4e8fd767), SPH_C32(0x8bc9599a), + SPH_C32(0x3eb5c807) }, + { SPH_C32(0x3af98830), SPH_C32(0x3b730000), SPH_C32(0x92c30000), + SPH_C32(0xb3f20000), SPH_C32(0x351f2f71), SPH_C32(0x9e353815), + SPH_C32(0xc1f3d668), SPH_C32(0xd482f467), SPH_C32(0xc7b7da40), + SPH_C32(0xe3010000), SPH_C32(0xd7e60000), SPH_C32(0xc1a30000), + SPH_C32(0x77200d45), SPH_C32(0x0a8a629e), SPH_C32(0xeddd53cb), + SPH_C32(0xacfa950d) }, + { SPH_C32(0xd5f28a40), SPH_C32(0x018e0000), SPH_C32(0xcf6d0000), + SPH_C32(0xdabb0000), SPH_C32(0xae101377), SPH_C32(0xda308dec), + SPH_C32(0xa7e7dc39), SPH_C32(0x46cda96d), SPH_C32(0x0edcda70), + SPH_C32(0x04240000), SPH_C32(0xf8620000), SPH_C32(0xe7ec0000), + SPH_C32(0x7f4956bc), SPH_C32(0x677693a9), SPH_C32(0xbd423a4f), + SPH_C32(0x32933a65) }, + { SPH_C32(0xe7c8b400), SPH_C32(0x65bf0000), SPH_C32(0xdc600000), + SPH_C32(0x64dc0000), SPH_C32(0xf31749e4), SPH_C32(0x4380f45a), + SPH_C32(0xd6c5d8cc), SPH_C32(0xab657fca), SPH_C32(0xc2b0cc00), + SPH_C32(0xf6600000), SPH_C32(0x510b0000), SPH_C32(0x75d00000), + SPH_C32(0x978b4edf), SPH_C32(0xdbd58319), SPH_C32(0xd9923a21), + SPH_C32(0x7cf88170) }, + { SPH_C32(0x08c3b670), SPH_C32(0x5f420000), SPH_C32(0x81ce0000), + SPH_C32(0x0d950000), SPH_C32(0x681875e2), SPH_C32(0x078541a3), + SPH_C32(0xb0d1d29d), SPH_C32(0x392a22c0), SPH_C32(0x0bdbcc30), + SPH_C32(0x11450000), SPH_C32(0x7e8f0000), SPH_C32(0x539f0000), + SPH_C32(0x9fe21526), SPH_C32(0xb629722e), SPH_C32(0x890d53a5), + SPH_C32(0xe2912e18) }, + { SPH_C32(0x2ea3b430), SPH_C32(0x829a0000), SPH_C32(0xf3e40000), + SPH_C32(0x42930000), SPH_C32(0xfb7e121d), SPH_C32(0x2e7c056d), + SPH_C32(0x865ab148), SPH_C32(0x350cd0a2), SPH_C32(0xe4d0ce40), + SPH_C32(0x2bb80000), SPH_C32(0x23210000), SPH_C32(0x3ad60000), + SPH_C32(0x04ed2920), SPH_C32(0xf22cc7d7), SPH_C32(0xef1959f4), + SPH_C32(0x70de7312) }, + { SPH_C32(0xc1a8b640), SPH_C32(0xb8670000), SPH_C32(0xae4a0000), + SPH_C32(0x2bda0000), SPH_C32(0x60712e1b), SPH_C32(0x6a79b094), + SPH_C32(0xe04ebb19), SPH_C32(0xa7438da8), SPH_C32(0x2dbbce70), + SPH_C32(0xcc9d0000), SPH_C32(0x0ca50000), SPH_C32(0x1c990000), + SPH_C32(0x0c8472d9), SPH_C32(0x9fd036e0), SPH_C32(0xbf863070), + SPH_C32(0xeeb7dc7a) }, + { SPH_C32(0xd0f59c00), SPH_C32(0x14ef0000), SPH_C32(0x49800000), + SPH_C32(0x6ec80000), SPH_C32(0x4ebb50ed), SPH_C32(0x0b6f6c6b), + SPH_C32(0x93a8b5d3), SPH_C32(0x96cfbd10), SPH_C32(0xd6eaf000), + SPH_C32(0x4f890000), SPH_C32(0x302c0000), SPH_C32(0x84b10000), + SPH_C32(0x59ea73b3), SPH_C32(0x6b9cbe61), SPH_C32(0x9e3b5d01), + SPH_C32(0x9d76a5b5) }, + { SPH_C32(0x3ffe9e70), SPH_C32(0x2e120000), SPH_C32(0x142e0000), + SPH_C32(0x07810000), SPH_C32(0xd5b46ceb), SPH_C32(0x4f6ad992), + SPH_C32(0xf5bcbf82), SPH_C32(0x0480e01a), SPH_C32(0x1f81f030), + SPH_C32(0xa8ac0000), SPH_C32(0x1fa80000), SPH_C32(0xa2fe0000), + SPH_C32(0x5183284a), SPH_C32(0x06604f56), SPH_C32(0xcea43485), + SPH_C32(0x031f0add) }, + { SPH_C32(0x199e9c30), SPH_C32(0xf3ca0000), SPH_C32(0x66040000), + SPH_C32(0x48870000), SPH_C32(0x46d20b14), SPH_C32(0x66939d5c), + SPH_C32(0xc337dc57), SPH_C32(0x08a61278), SPH_C32(0xf08af240), + SPH_C32(0x92510000), SPH_C32(0x42060000), SPH_C32(0xcbb70000), + SPH_C32(0xca8c144c), SPH_C32(0x4265faaf), SPH_C32(0xa8b03ed4), + SPH_C32(0x915057d7) }, + { SPH_C32(0xf6959e40), SPH_C32(0xc9370000), SPH_C32(0x3baa0000), + SPH_C32(0x21ce0000), SPH_C32(0xdddd3712), SPH_C32(0x229628a5), + SPH_C32(0xa523d606), SPH_C32(0x9ae94f72), SPH_C32(0x39e1f270), + SPH_C32(0x75740000), SPH_C32(0x6d820000), SPH_C32(0xedf80000), + SPH_C32(0xc2e54fb5), SPH_C32(0x2f990b98), SPH_C32(0xf82f5750), + SPH_C32(0x0f39f8bf) }, + { SPH_C32(0xc4afa000), SPH_C32(0xad060000), SPH_C32(0x28a70000), + SPH_C32(0x9fa90000), SPH_C32(0x80da6d81), SPH_C32(0xbb265113), + SPH_C32(0xd401d2f3), SPH_C32(0x774199d5), SPH_C32(0xf58de400), + SPH_C32(0x87300000), SPH_C32(0xc4eb0000), SPH_C32(0x7fc40000), + SPH_C32(0x2a2757d6), SPH_C32(0x933a1b28), SPH_C32(0x9cff573e), + SPH_C32(0x415243aa) }, + { SPH_C32(0x2ba4a270), SPH_C32(0x97fb0000), SPH_C32(0x75090000), + SPH_C32(0xf6e00000), SPH_C32(0x1bd55187), SPH_C32(0xff23e4ea), + SPH_C32(0xb215d8a2), SPH_C32(0xe50ec4df), SPH_C32(0x3ce6e430), + SPH_C32(0x60150000), SPH_C32(0xeb6f0000), SPH_C32(0x598b0000), + SPH_C32(0x224e0c2f), SPH_C32(0xfec6ea1f), SPH_C32(0xcc603eba), + SPH_C32(0xdf3becc2) }, + { SPH_C32(0x0dc4a030), SPH_C32(0x4a230000), SPH_C32(0x07230000), + SPH_C32(0xb9e60000), SPH_C32(0x88b33678), SPH_C32(0xd6daa024), + SPH_C32(0x849ebb77), SPH_C32(0xe92836bd), SPH_C32(0xd3ede640), + SPH_C32(0x5ae80000), SPH_C32(0xb6c10000), SPH_C32(0x30c20000), + SPH_C32(0xb9413029), SPH_C32(0xbac35fe6), SPH_C32(0xaa7434eb), + SPH_C32(0x4d74b1c8) }, + { SPH_C32(0xe2cfa240), SPH_C32(0x70de0000), SPH_C32(0x5a8d0000), + SPH_C32(0xd0af0000), SPH_C32(0x13bc0a7e), SPH_C32(0x92df15dd), + SPH_C32(0xe28ab126), SPH_C32(0x7b676bb7), SPH_C32(0x1a86e670), + SPH_C32(0xbdcd0000), SPH_C32(0x99450000), SPH_C32(0x168d0000), + SPH_C32(0xb1286bd0), SPH_C32(0xd73faed1), SPH_C32(0xfaeb5d6f), + SPH_C32(0xd31d1ea0) }, + { SPH_C32(0xa7bad400), SPH_C32(0x36bb0000), SPH_C32(0x78910000), + SPH_C32(0x34780000), SPH_C32(0x8ed413f8), SPH_C32(0x676c0dc3), + SPH_C32(0xfadcfe71), SPH_C32(0x1ff06c8d), SPH_C32(0x7d6cc000), + SPH_C32(0x8e0a0000), SPH_C32(0x379d0000), SPH_C32(0x63360000), + SPH_C32(0xbd7c29ff), SPH_C32(0xc267f3a4), SPH_C32(0x985003c4), + SPH_C32(0xd816a946) }, + { SPH_C32(0x48b1d670), SPH_C32(0x0c460000), SPH_C32(0x253f0000), + SPH_C32(0x5d310000), SPH_C32(0x15db2ffe), SPH_C32(0x2369b83a), + SPH_C32(0x9cc8f420), SPH_C32(0x8dbf3187), SPH_C32(0xb407c030), + SPH_C32(0x692f0000), SPH_C32(0x18190000), SPH_C32(0x45790000), + SPH_C32(0xb5157206), SPH_C32(0xaf9b0293), SPH_C32(0xc8cf6a40), + SPH_C32(0x467f062e) }, + { SPH_C32(0x6ed1d430), SPH_C32(0xd19e0000), SPH_C32(0x57150000), + SPH_C32(0x12370000), SPH_C32(0x86bd4801), SPH_C32(0x0a90fcf4), + SPH_C32(0xaa4397f5), SPH_C32(0x8199c3e5), SPH_C32(0x5b0cc240), + SPH_C32(0x53d20000), SPH_C32(0x45b70000), SPH_C32(0x2c300000), + SPH_C32(0x2e1a4e00), SPH_C32(0xeb9eb76a), SPH_C32(0xaedb6011), + SPH_C32(0xd4305b24) }, + { SPH_C32(0x81dad640), SPH_C32(0xeb630000), SPH_C32(0x0abb0000), + SPH_C32(0x7b7e0000), SPH_C32(0x1db27407), SPH_C32(0x4e95490d), + SPH_C32(0xcc579da4), SPH_C32(0x13d69eef), SPH_C32(0x9267c270), + SPH_C32(0xb4f70000), SPH_C32(0x6a330000), SPH_C32(0x0a7f0000), + SPH_C32(0x267315f9), SPH_C32(0x8662465d), SPH_C32(0xfe440995), + SPH_C32(0x4a59f44c) }, + { SPH_C32(0xb3e0e800), SPH_C32(0x8f520000), SPH_C32(0x19b60000), + SPH_C32(0xc5190000), SPH_C32(0x40b52e94), SPH_C32(0xd72530bb), + SPH_C32(0xbd759951), SPH_C32(0xfe7e4848), SPH_C32(0x5e0bd400), + SPH_C32(0x46b30000), SPH_C32(0xc35a0000), SPH_C32(0x98430000), + SPH_C32(0xceb10d9a), SPH_C32(0x3ac156ed), SPH_C32(0x9a9409fb), + SPH_C32(0x04324f59) }, + { SPH_C32(0x5cebea70), SPH_C32(0xb5af0000), SPH_C32(0x44180000), + SPH_C32(0xac500000), SPH_C32(0xdbba1292), SPH_C32(0x93208542), + SPH_C32(0xdb619300), SPH_C32(0x6c311542), SPH_C32(0x9760d430), + SPH_C32(0xa1960000), SPH_C32(0xecde0000), SPH_C32(0xbe0c0000), + SPH_C32(0xc6d85663), SPH_C32(0x573da7da), SPH_C32(0xca0b607f), + SPH_C32(0x9a5be031) }, + { SPH_C32(0x7a8be830), SPH_C32(0x68770000), SPH_C32(0x36320000), + SPH_C32(0xe3560000), SPH_C32(0x48dc756d), SPH_C32(0xbad9c18c), + SPH_C32(0xedeaf0d5), SPH_C32(0x6017e720), SPH_C32(0x786bd640), + SPH_C32(0x9b6b0000), SPH_C32(0xb1700000), SPH_C32(0xd7450000), + SPH_C32(0x5dd76a65), SPH_C32(0x13381223), SPH_C32(0xac1f6a2e), + SPH_C32(0x0814bd3b) }, + { SPH_C32(0x9580ea40), SPH_C32(0x528a0000), SPH_C32(0x6b9c0000), + SPH_C32(0x8a1f0000), SPH_C32(0xd3d3496b), SPH_C32(0xfedc7475), + SPH_C32(0x8bfefa84), SPH_C32(0xf258ba2a), SPH_C32(0xb100d670), + SPH_C32(0x7c4e0000), SPH_C32(0x9ef40000), SPH_C32(0xf10a0000), + SPH_C32(0x55be319c), SPH_C32(0x7ec4e314), SPH_C32(0xfc8003aa), + SPH_C32(0x967d1253) }, + { SPH_C32(0x84ddc000), SPH_C32(0xfe020000), SPH_C32(0x8c560000), + SPH_C32(0xcf0d0000), SPH_C32(0xfd19379d), SPH_C32(0x9fcaa88a), + SPH_C32(0xf818f44e), SPH_C32(0xc3d48a92), SPH_C32(0x4a51e800), + SPH_C32(0xff5a0000), SPH_C32(0xa27d0000), SPH_C32(0x69220000), + SPH_C32(0x00d030f6), SPH_C32(0x8a886b95), SPH_C32(0xdd3d6edb), + SPH_C32(0xe5bc6b9c) }, + { SPH_C32(0x6bd6c270), SPH_C32(0xc4ff0000), SPH_C32(0xd1f80000), + SPH_C32(0xa6440000), SPH_C32(0x66160b9b), SPH_C32(0xdbcf1d73), + SPH_C32(0x9e0cfe1f), SPH_C32(0x519bd798), SPH_C32(0x833ae830), + SPH_C32(0x187f0000), SPH_C32(0x8df90000), SPH_C32(0x4f6d0000), + SPH_C32(0x08b96b0f), SPH_C32(0xe7749aa2), SPH_C32(0x8da2075f), + SPH_C32(0x7bd5c4f4) }, + { SPH_C32(0x4db6c030), SPH_C32(0x19270000), SPH_C32(0xa3d20000), + SPH_C32(0xe9420000), SPH_C32(0xf5706c64), SPH_C32(0xf23659bd), + SPH_C32(0xa8879dca), SPH_C32(0x5dbd25fa), SPH_C32(0x6c31ea40), + SPH_C32(0x22820000), SPH_C32(0xd0570000), SPH_C32(0x26240000), + SPH_C32(0x93b65709), SPH_C32(0xa3712f5b), SPH_C32(0xebb60d0e), + SPH_C32(0xe99a99fe) }, + { SPH_C32(0xa2bdc240), SPH_C32(0x23da0000), SPH_C32(0xfe7c0000), + SPH_C32(0x800b0000), SPH_C32(0x6e7f5062), SPH_C32(0xb633ec44), + SPH_C32(0xce93979b), SPH_C32(0xcff278f0), SPH_C32(0xa55aea70), + SPH_C32(0xc5a70000), SPH_C32(0xffd30000), SPH_C32(0x006b0000), + SPH_C32(0x9bdf0cf0), SPH_C32(0xce8dde6c), SPH_C32(0xbb29648a), + SPH_C32(0x77f33696) }, + { SPH_C32(0x9087fc00), SPH_C32(0x47eb0000), SPH_C32(0xed710000), + SPH_C32(0x3e6c0000), SPH_C32(0x33780af1), SPH_C32(0x2f8395f2), + SPH_C32(0xbfb1936e), SPH_C32(0x225aae57), SPH_C32(0x6936fc00), + SPH_C32(0x37e30000), SPH_C32(0x56ba0000), SPH_C32(0x92570000), + SPH_C32(0x731d1493), SPH_C32(0x722ecedc), SPH_C32(0xdff964e4), + SPH_C32(0x39988d83) }, + { SPH_C32(0x7f8cfe70), SPH_C32(0x7d160000), SPH_C32(0xb0df0000), + SPH_C32(0x57250000), SPH_C32(0xa87736f7), SPH_C32(0x6b86200b), + SPH_C32(0xd9a5993f), SPH_C32(0xb015f35d), SPH_C32(0xa05dfc30), + SPH_C32(0xd0c60000), SPH_C32(0x793e0000), SPH_C32(0xb4180000), + SPH_C32(0x7b744f6a), SPH_C32(0x1fd23feb), SPH_C32(0x8f660d60), + SPH_C32(0xa7f122eb) }, + { SPH_C32(0x59ecfc30), SPH_C32(0xa0ce0000), SPH_C32(0xc2f50000), + SPH_C32(0x18230000), SPH_C32(0x3b115108), SPH_C32(0x427f64c5), + SPH_C32(0xef2efaea), SPH_C32(0xbc33013f), SPH_C32(0x4f56fe40), + SPH_C32(0xea3b0000), SPH_C32(0x24900000), SPH_C32(0xdd510000), + SPH_C32(0xe07b736c), SPH_C32(0x5bd78a12), SPH_C32(0xe9720731), + SPH_C32(0x35be7fe1) }, + { SPH_C32(0xb6e7fe40), SPH_C32(0x9a330000), SPH_C32(0x9f5b0000), + SPH_C32(0x716a0000), SPH_C32(0xa01e6d0e), SPH_C32(0x067ad13c), + SPH_C32(0x893af0bb), SPH_C32(0x2e7c5c35), SPH_C32(0x863dfe70), + SPH_C32(0x0d1e0000), SPH_C32(0x0b140000), SPH_C32(0xfb1e0000), + SPH_C32(0xe8122895), SPH_C32(0x362b7b25), SPH_C32(0xb9ed6eb5), + SPH_C32(0xabd7d089) } +}; + +static const sph_u32 T512_8[256][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xf6800005), SPH_C32(0x3443c000), SPH_C32(0x24070000), + SPH_C32(0x8f3d0000), SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), + SPH_C32(0xcdc58b19), SPH_C32(0xd795ba31), SPH_C32(0xa67f0001), + SPH_C32(0x71378000), SPH_C32(0x19fc0000), SPH_C32(0x96db0000), + SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), SPH_C32(0x2c6d478f), + SPH_C32(0xac8e6c88) }, + { SPH_C32(0xa67f0001), SPH_C32(0x71378000), SPH_C32(0x19fc0000), + SPH_C32(0x96db0000), SPH_C32(0x3a8b6dfd), SPH_C32(0xebcaaef3), + SPH_C32(0x2c6d478f), SPH_C32(0xac8e6c88), SPH_C32(0x50ff0004), + SPH_C32(0x45744000), SPH_C32(0x3dfb0000), SPH_C32(0x19e60000), + SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), SPH_C32(0xe1a8cc96), + SPH_C32(0x7b1bd6b9) }, + { SPH_C32(0x50ff0004), SPH_C32(0x45744000), SPH_C32(0x3dfb0000), + SPH_C32(0x19e60000), SPH_C32(0x1bbc5606), SPH_C32(0xe1727b5d), + SPH_C32(0xe1a8cc96), SPH_C32(0x7b1bd6b9), SPH_C32(0xf6800005), + SPH_C32(0x3443c000), SPH_C32(0x24070000), SPH_C32(0x8f3d0000), + SPH_C32(0x21373bfb), SPH_C32(0x0ab8d5ae), SPH_C32(0xcdc58b19), + SPH_C32(0xd795ba31) }, + { SPH_C32(0xf7750009), SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), + SPH_C32(0x04920000), SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), + SPH_C32(0x7a87f14e), SPH_C32(0x9e16981a), SPH_C32(0xd46a0000), + SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), SPH_C32(0x4a290000), + SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), SPH_C32(0x98369604), + SPH_C32(0xf746c320) }, + { SPH_C32(0x01f5000c), SPH_C32(0xfb7f0000), SPH_C32(0xe7d10000), + SPH_C32(0x8baf0000), SPH_C32(0x23a22252), SPH_C32(0xf250e314), + SPH_C32(0xb7427a57), SPH_C32(0x4983222b), SPH_C32(0x72150001), + SPH_C32(0xfcff4000), SPH_C32(0xbc530000), SPH_C32(0xdcf20000), + SPH_C32(0xc6c52f87), SPH_C32(0x227e289f), SPH_C32(0xb45bd18b), + SPH_C32(0x5bc8afa8) }, + { SPH_C32(0x510a0008), SPH_C32(0xbe0b4000), SPH_C32(0xda2a0000), + SPH_C32(0x92490000), SPH_C32(0x381e7454), SPH_C32(0x13229849), + SPH_C32(0x56eab6c1), SPH_C32(0x3298f492), SPH_C32(0x84950004), + SPH_C32(0xc8bc8000), SPH_C32(0x98540000), SPH_C32(0x53cf0000), + SPH_C32(0xe7f2147c), SPH_C32(0x28c6fd31), SPH_C32(0x799e5a92), + SPH_C32(0x8c5d1599) }, + { SPH_C32(0xa78a000d), SPH_C32(0x8a488000), SPH_C32(0xfe2d0000), + SPH_C32(0x1d740000), SPH_C32(0x19294faf), SPH_C32(0x199a4de7), + SPH_C32(0x9b2f3dd8), SPH_C32(0xe50d4ea3), SPH_C32(0x22ea0005), + SPH_C32(0xb98b0000), SPH_C32(0x81a80000), SPH_C32(0xc5140000), + SPH_C32(0xdd797981), SPH_C32(0xc30c53c2), SPH_C32(0x55f31d1d), + SPH_C32(0x20d37911) }, + { SPH_C32(0xd46a0000), SPH_C32(0x8dc8c000), SPH_C32(0xa5af0000), + SPH_C32(0x4a290000), SPH_C32(0xfc4e427a), SPH_C32(0xc9b4866c), + SPH_C32(0x98369604), SPH_C32(0xf746c320), SPH_C32(0x231f0009), + SPH_C32(0x42f40000), SPH_C32(0x66790000), SPH_C32(0x4ebb0000), + SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), SPH_C32(0xe2b1674a), + SPH_C32(0x69505b3a) }, + { SPH_C32(0x22ea0005), SPH_C32(0xb98b0000), SPH_C32(0x81a80000), + SPH_C32(0xc5140000), SPH_C32(0xdd797981), SPH_C32(0xc30c53c2), + SPH_C32(0x55f31d1d), SPH_C32(0x20d37911), SPH_C32(0x85600008), + SPH_C32(0x33c38000), SPH_C32(0x7f850000), SPH_C32(0xd8600000), + SPH_C32(0xc450362e), SPH_C32(0xda961e25), SPH_C32(0xcedc20c5), + SPH_C32(0xc5de37b2) }, + { SPH_C32(0x72150001), SPH_C32(0xfcff4000), SPH_C32(0xbc530000), + SPH_C32(0xdcf20000), SPH_C32(0xc6c52f87), SPH_C32(0x227e289f), + SPH_C32(0xb45bd18b), SPH_C32(0x5bc8afa8), SPH_C32(0x73e0000d), + SPH_C32(0x07804000), SPH_C32(0x5b820000), SPH_C32(0x575d0000), + SPH_C32(0xe5670dd5), SPH_C32(0xd02ecb8b), SPH_C32(0x0319abdc), + SPH_C32(0x124b8d83) }, + { SPH_C32(0x84950004), SPH_C32(0xc8bc8000), SPH_C32(0x98540000), + SPH_C32(0x53cf0000), SPH_C32(0xe7f2147c), SPH_C32(0x28c6fd31), + SPH_C32(0x799e5a92), SPH_C32(0x8c5d1599), SPH_C32(0xd59f000c), + SPH_C32(0x76b7c000), SPH_C32(0x427e0000), SPH_C32(0xc1860000), + SPH_C32(0xdfec6028), SPH_C32(0x3be46578), SPH_C32(0x2f74ec53), + SPH_C32(0xbec5e10b) }, + { SPH_C32(0x231f0009), SPH_C32(0x42f40000), SPH_C32(0x66790000), + SPH_C32(0x4ebb0000), SPH_C32(0xfedb5bd3), SPH_C32(0x315cb0d6), + SPH_C32(0xe2b1674a), SPH_C32(0x69505b3a), SPH_C32(0xf7750009), + SPH_C32(0xcf3cc000), SPH_C32(0xc3d60000), SPH_C32(0x04920000), + SPH_C32(0x029519a9), SPH_C32(0xf8e836ba), SPH_C32(0x7a87f14e), + SPH_C32(0x9e16981a) }, + { SPH_C32(0xd59f000c), SPH_C32(0x76b7c000), SPH_C32(0x427e0000), + SPH_C32(0xc1860000), SPH_C32(0xdfec6028), SPH_C32(0x3be46578), + SPH_C32(0x2f74ec53), SPH_C32(0xbec5e10b), SPH_C32(0x510a0008), + SPH_C32(0xbe0b4000), SPH_C32(0xda2a0000), SPH_C32(0x92490000), + SPH_C32(0x381e7454), SPH_C32(0x13229849), SPH_C32(0x56eab6c1), + SPH_C32(0x3298f492) }, + { SPH_C32(0x85600008), SPH_C32(0x33c38000), SPH_C32(0x7f850000), + SPH_C32(0xd8600000), SPH_C32(0xc450362e), SPH_C32(0xda961e25), + SPH_C32(0xcedc20c5), SPH_C32(0xc5de37b2), SPH_C32(0xa78a000d), + SPH_C32(0x8a488000), SPH_C32(0xfe2d0000), SPH_C32(0x1d740000), + SPH_C32(0x19294faf), SPH_C32(0x199a4de7), SPH_C32(0x9b2f3dd8), + SPH_C32(0xe50d4ea3) }, + { SPH_C32(0x73e0000d), SPH_C32(0x07804000), SPH_C32(0x5b820000), + SPH_C32(0x575d0000), SPH_C32(0xe5670dd5), SPH_C32(0xd02ecb8b), + SPH_C32(0x0319abdc), SPH_C32(0x124b8d83), SPH_C32(0x01f5000c), + SPH_C32(0xfb7f0000), SPH_C32(0xe7d10000), SPH_C32(0x8baf0000), + SPH_C32(0x23a22252), SPH_C32(0xf250e314), SPH_C32(0xb7427a57), + SPH_C32(0x4983222b) }, + { SPH_C32(0x774400f0), SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), + SPH_C32(0x34140000), SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), + SPH_C32(0x0bc3cd1e), SPH_C32(0xcf3775cb), SPH_C32(0xf46c0050), + SPH_C32(0x96180000), SPH_C32(0x14a50000), SPH_C32(0x031f0000), + SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), SPH_C32(0x9ca470d2), + SPH_C32(0x8a341574) }, + { SPH_C32(0x81c400f5), SPH_C32(0xc519c000), SPH_C32(0xd1b50000), + SPH_C32(0xbb290000), SPH_C32(0xa8004577), SPH_C32(0x5033398b), + SPH_C32(0xc6064607), SPH_C32(0x18a2cffa), SPH_C32(0x52130051), + SPH_C32(0xe72f8000), SPH_C32(0x0d590000), SPH_C32(0x95c40000), + SPH_C32(0x781f1345), SPH_C32(0x8d75d0ea), SPH_C32(0xb0c9375d), + SPH_C32(0x26ba79fc) }, + { SPH_C32(0xd13b00f1), SPH_C32(0x806d8000), SPH_C32(0xec4e0000), + SPH_C32(0xa2cf0000), SPH_C32(0xb3bc1371), SPH_C32(0xb14142d6), + SPH_C32(0x27ae8a91), SPH_C32(0x63b91943), SPH_C32(0xa4930054), + SPH_C32(0xd36c4000), SPH_C32(0x295e0000), SPH_C32(0x1af90000), + SPH_C32(0x592828be), SPH_C32(0x87cd0544), SPH_C32(0x7d0cbc44), + SPH_C32(0xf12fc3cd) }, + { SPH_C32(0x27bb00f4), SPH_C32(0xb42e4000), SPH_C32(0xc8490000), + SPH_C32(0x2df20000), SPH_C32(0x928b288a), SPH_C32(0xbbf99778), + SPH_C32(0xea6b0188), SPH_C32(0xb42ca372), SPH_C32(0x02ec0055), + SPH_C32(0xa25bc000), SPH_C32(0x30a20000), SPH_C32(0x8c220000), + SPH_C32(0x63a34543), SPH_C32(0x6c07abb7), SPH_C32(0x5161fbcb), + SPH_C32(0x5da1af45) }, + { SPH_C32(0x803100f9), SPH_C32(0x3e66c000), SPH_C32(0x36640000), + SPH_C32(0x30860000), SPH_C32(0x8ba26725), SPH_C32(0xa263da9f), + SPH_C32(0x71443c50), SPH_C32(0x5121edd1), SPH_C32(0x20060050), + SPH_C32(0x1bd0c000), SPH_C32(0xb10a0000), SPH_C32(0x49360000), + SPH_C32(0xbeda3cc2), SPH_C32(0xaf0bf875), SPH_C32(0x0492e6d6), + SPH_C32(0x7d72d654) }, + { SPH_C32(0x76b100fc), SPH_C32(0x0a250000), SPH_C32(0x12630000), + SPH_C32(0xbfbb0000), SPH_C32(0xaa955cde), SPH_C32(0xa8db0f31), + SPH_C32(0xbc81b749), SPH_C32(0x86b457e0), SPH_C32(0x86790051), + SPH_C32(0x6ae74000), SPH_C32(0xa8f60000), SPH_C32(0xdfed0000), + SPH_C32(0x8451513f), SPH_C32(0x44c15686), SPH_C32(0x28ffa159), + SPH_C32(0xd1fcbadc) }, + { SPH_C32(0x264e00f8), SPH_C32(0x4f514000), SPH_C32(0x2f980000), + SPH_C32(0xa65d0000), SPH_C32(0xb1290ad8), SPH_C32(0x49a9746c), + SPH_C32(0x5d297bdf), SPH_C32(0xfdaf8159), SPH_C32(0x70f90054), + SPH_C32(0x5ea48000), SPH_C32(0x8cf10000), SPH_C32(0x50d00000), + SPH_C32(0xa5666ac4), SPH_C32(0x4e798328), SPH_C32(0xe53a2a40), + SPH_C32(0x066900ed) }, + { SPH_C32(0xd0ce00fd), SPH_C32(0x7b128000), SPH_C32(0x0b9f0000), + SPH_C32(0x29600000), SPH_C32(0x901e3123), SPH_C32(0x4311a1c2), + SPH_C32(0x90ecf0c6), SPH_C32(0x2a3a3b68), SPH_C32(0xd6860055), + SPH_C32(0x2f930000), SPH_C32(0x950d0000), SPH_C32(0xc60b0000), + SPH_C32(0x9fed0739), SPH_C32(0xa5b32ddb), SPH_C32(0xc9576dcf), + SPH_C32(0xaae76c65) }, + { SPH_C32(0xa32e00f0), SPH_C32(0x7c92c000), SPH_C32(0x501d0000), + SPH_C32(0x7e3d0000), SPH_C32(0x75793cf6), SPH_C32(0x933f6a49), + SPH_C32(0x93f55b1a), SPH_C32(0x3871b6eb), SPH_C32(0xd7730059), + SPH_C32(0xd4ec0000), SPH_C32(0x72dc0000), SPH_C32(0x4da40000), + SPH_C32(0xbc4f256b), SPH_C32(0x57e3cecf), SPH_C32(0x7e151798), + SPH_C32(0xe3644e4e) }, + { SPH_C32(0x55ae00f5), SPH_C32(0x48d10000), SPH_C32(0x741a0000), + SPH_C32(0xf1000000), SPH_C32(0x544e070d), SPH_C32(0x9987bfe7), + SPH_C32(0x5e30d003), SPH_C32(0xefe40cda), SPH_C32(0x710c0058), + SPH_C32(0xa5db8000), SPH_C32(0x6b200000), SPH_C32(0xdb7f0000), + SPH_C32(0x86c44896), SPH_C32(0xbc29603c), SPH_C32(0x52785017), + SPH_C32(0x4fea22c6) }, + { SPH_C32(0x055100f1), SPH_C32(0x0da54000), SPH_C32(0x49e10000), + SPH_C32(0xe8e60000), SPH_C32(0x4ff2510b), SPH_C32(0x78f5c4ba), + SPH_C32(0xbf981c95), SPH_C32(0x94ffda63), SPH_C32(0x878c005d), + SPH_C32(0x91984000), SPH_C32(0x4f270000), SPH_C32(0x54420000), + SPH_C32(0xa7f3736d), SPH_C32(0xb691b592), SPH_C32(0x9fbddb0e), + SPH_C32(0x987f98f7) }, + { SPH_C32(0xf3d100f4), SPH_C32(0x39e68000), SPH_C32(0x6de60000), + SPH_C32(0x67db0000), SPH_C32(0x6ec56af0), SPH_C32(0x724d1114), + SPH_C32(0x725d978c), SPH_C32(0x436a6052), SPH_C32(0x21f3005c), + SPH_C32(0xe0afc000), SPH_C32(0x56db0000), SPH_C32(0xc2990000), + SPH_C32(0x9d781e90), SPH_C32(0x5d5b1b61), SPH_C32(0xb3d09c81), + SPH_C32(0x34f1f47f) }, + { SPH_C32(0x545b00f9), SPH_C32(0xb3ae0000), SPH_C32(0x93cb0000), + SPH_C32(0x7aaf0000), SPH_C32(0x77ec255f), SPH_C32(0x6bd75cf3), + SPH_C32(0xe972aa54), SPH_C32(0xa6672ef1), SPH_C32(0x03190059), + SPH_C32(0x5924c000), SPH_C32(0xd7730000), SPH_C32(0x078d0000), + SPH_C32(0x40016711), SPH_C32(0x9e5748a3), SPH_C32(0xe623819c), + SPH_C32(0x14228d6e) }, + { SPH_C32(0xa2db00fc), SPH_C32(0x87edc000), SPH_C32(0xb7cc0000), + SPH_C32(0xf5920000), SPH_C32(0x56db1ea4), SPH_C32(0x616f895d), + SPH_C32(0x24b7214d), SPH_C32(0x71f294c0), SPH_C32(0xa5660058), + SPH_C32(0x28134000), SPH_C32(0xce8f0000), SPH_C32(0x91560000), + SPH_C32(0x7a8a0aec), SPH_C32(0x759de650), SPH_C32(0xca4ec613), + SPH_C32(0xb8ace1e6) }, + { SPH_C32(0xf22400f8), SPH_C32(0xc2998000), SPH_C32(0x8a370000), + SPH_C32(0xec740000), SPH_C32(0x4d6748a2), SPH_C32(0x801df200), + SPH_C32(0xc51feddb), SPH_C32(0x0ae94279), SPH_C32(0x53e6005d), + SPH_C32(0x1c508000), SPH_C32(0xea880000), SPH_C32(0x1e6b0000), + SPH_C32(0x5bbd3117), SPH_C32(0x7f2533fe), SPH_C32(0x078b4d0a), + SPH_C32(0x6f395bd7) }, + { SPH_C32(0x04a400fd), SPH_C32(0xf6da4000), SPH_C32(0xae300000), + SPH_C32(0x63490000), SPH_C32(0x6c507359), SPH_C32(0x8aa527ae), + SPH_C32(0x08da66c2), SPH_C32(0xdd7cf848), SPH_C32(0xf599005c), + SPH_C32(0x6d670000), SPH_C32(0xf3740000), SPH_C32(0x88b00000), + SPH_C32(0x61365cea), SPH_C32(0x94ef9d0d), SPH_C32(0x2be60a85), + SPH_C32(0xc3b7375f) }, + { SPH_C32(0xf46c0050), SPH_C32(0x96180000), SPH_C32(0x14a50000), + SPH_C32(0x031f0000), SPH_C32(0x42947eb8), SPH_C32(0x66bf7e19), + SPH_C32(0x9ca470d2), SPH_C32(0x8a341574), SPH_C32(0x832800a0), + SPH_C32(0x67420000), SPH_C32(0xe1170000), SPH_C32(0x370b0000), + SPH_C32(0xcba30034), SPH_C32(0x3c34923c), SPH_C32(0x9767bdcc), + SPH_C32(0x450360bf) }, + { SPH_C32(0x02ec0055), SPH_C32(0xa25bc000), SPH_C32(0x30a20000), + SPH_C32(0x8c220000), SPH_C32(0x63a34543), SPH_C32(0x6c07abb7), + SPH_C32(0x5161fbcb), SPH_C32(0x5da1af45), SPH_C32(0x255700a1), + SPH_C32(0x16758000), SPH_C32(0xf8eb0000), SPH_C32(0xa1d00000), + SPH_C32(0xf1286dc9), SPH_C32(0xd7fe3ccf), SPH_C32(0xbb0afa43), + SPH_C32(0xe98d0c37) }, + { SPH_C32(0x52130051), SPH_C32(0xe72f8000), SPH_C32(0x0d590000), + SPH_C32(0x95c40000), SPH_C32(0x781f1345), SPH_C32(0x8d75d0ea), + SPH_C32(0xb0c9375d), SPH_C32(0x26ba79fc), SPH_C32(0xd3d700a4), + SPH_C32(0x22364000), SPH_C32(0xdcec0000), SPH_C32(0x2eed0000), + SPH_C32(0xd01f5632), SPH_C32(0xdd46e961), SPH_C32(0x76cf715a), + SPH_C32(0x3e18b606) }, + { SPH_C32(0xa4930054), SPH_C32(0xd36c4000), SPH_C32(0x295e0000), + SPH_C32(0x1af90000), SPH_C32(0x592828be), SPH_C32(0x87cd0544), + SPH_C32(0x7d0cbc44), SPH_C32(0xf12fc3cd), SPH_C32(0x75a800a5), + SPH_C32(0x5301c000), SPH_C32(0xc5100000), SPH_C32(0xb8360000), + SPH_C32(0xea943bcf), SPH_C32(0x368c4792), SPH_C32(0x5aa236d5), + SPH_C32(0x9296da8e) }, + { SPH_C32(0x03190059), SPH_C32(0x5924c000), SPH_C32(0xd7730000), + SPH_C32(0x078d0000), SPH_C32(0x40016711), SPH_C32(0x9e5748a3), + SPH_C32(0xe623819c), SPH_C32(0x14228d6e), SPH_C32(0x574200a0), + SPH_C32(0xea8ac000), SPH_C32(0x44b80000), SPH_C32(0x7d220000), + SPH_C32(0x37ed424e), SPH_C32(0xf5801450), SPH_C32(0x0f512bc8), + SPH_C32(0xb245a39f) }, + { SPH_C32(0xf599005c), SPH_C32(0x6d670000), SPH_C32(0xf3740000), + SPH_C32(0x88b00000), SPH_C32(0x61365cea), SPH_C32(0x94ef9d0d), + SPH_C32(0x2be60a85), SPH_C32(0xc3b7375f), SPH_C32(0xf13d00a1), + SPH_C32(0x9bbd4000), SPH_C32(0x5d440000), SPH_C32(0xebf90000), + SPH_C32(0x0d662fb3), SPH_C32(0x1e4abaa3), SPH_C32(0x233c6c47), + SPH_C32(0x1ecbcf17) }, + { SPH_C32(0xa5660058), SPH_C32(0x28134000), SPH_C32(0xce8f0000), + SPH_C32(0x91560000), SPH_C32(0x7a8a0aec), SPH_C32(0x759de650), + SPH_C32(0xca4ec613), SPH_C32(0xb8ace1e6), SPH_C32(0x07bd00a4), + SPH_C32(0xaffe8000), SPH_C32(0x79430000), SPH_C32(0x64c40000), + SPH_C32(0x2c511448), SPH_C32(0x14f26f0d), SPH_C32(0xeef9e75e), + SPH_C32(0xc95e7526) }, + { SPH_C32(0x53e6005d), SPH_C32(0x1c508000), SPH_C32(0xea880000), + SPH_C32(0x1e6b0000), SPH_C32(0x5bbd3117), SPH_C32(0x7f2533fe), + SPH_C32(0x078b4d0a), SPH_C32(0x6f395bd7), SPH_C32(0xa1c200a5), + SPH_C32(0xdec90000), SPH_C32(0x60bf0000), SPH_C32(0xf21f0000), + SPH_C32(0x16da79b5), SPH_C32(0xff38c1fe), SPH_C32(0xc294a0d1), + SPH_C32(0x65d019ae) }, + { SPH_C32(0x20060050), SPH_C32(0x1bd0c000), SPH_C32(0xb10a0000), + SPH_C32(0x49360000), SPH_C32(0xbeda3cc2), SPH_C32(0xaf0bf875), + SPH_C32(0x0492e6d6), SPH_C32(0x7d72d654), SPH_C32(0xa03700a9), + SPH_C32(0x25b60000), SPH_C32(0x876e0000), SPH_C32(0x79b00000), + SPH_C32(0x35785be7), SPH_C32(0x0d6822ea), SPH_C32(0x75d6da86), + SPH_C32(0x2c533b85) }, + { SPH_C32(0xd6860055), SPH_C32(0x2f930000), SPH_C32(0x950d0000), + SPH_C32(0xc60b0000), SPH_C32(0x9fed0739), SPH_C32(0xa5b32ddb), + SPH_C32(0xc9576dcf), SPH_C32(0xaae76c65), SPH_C32(0x064800a8), + SPH_C32(0x54818000), SPH_C32(0x9e920000), SPH_C32(0xef6b0000), + SPH_C32(0x0ff3361a), SPH_C32(0xe6a28c19), SPH_C32(0x59bb9d09), + SPH_C32(0x80dd570d) }, + { SPH_C32(0x86790051), SPH_C32(0x6ae74000), SPH_C32(0xa8f60000), + SPH_C32(0xdfed0000), SPH_C32(0x8451513f), SPH_C32(0x44c15686), + SPH_C32(0x28ffa159), SPH_C32(0xd1fcbadc), SPH_C32(0xf0c800ad), + SPH_C32(0x60c24000), SPH_C32(0xba950000), SPH_C32(0x60560000), + SPH_C32(0x2ec40de1), SPH_C32(0xec1a59b7), SPH_C32(0x947e1610), + SPH_C32(0x5748ed3c) }, + { SPH_C32(0x70f90054), SPH_C32(0x5ea48000), SPH_C32(0x8cf10000), + SPH_C32(0x50d00000), SPH_C32(0xa5666ac4), SPH_C32(0x4e798328), + SPH_C32(0xe53a2a40), SPH_C32(0x066900ed), SPH_C32(0x56b700ac), + SPH_C32(0x11f5c000), SPH_C32(0xa3690000), SPH_C32(0xf68d0000), + SPH_C32(0x144f601c), SPH_C32(0x07d0f744), SPH_C32(0xb813519f), + SPH_C32(0xfbc681b4) }, + { SPH_C32(0xd7730059), SPH_C32(0xd4ec0000), SPH_C32(0x72dc0000), + SPH_C32(0x4da40000), SPH_C32(0xbc4f256b), SPH_C32(0x57e3cecf), + SPH_C32(0x7e151798), SPH_C32(0xe3644e4e), SPH_C32(0x745d00a9), + SPH_C32(0xa87ec000), SPH_C32(0x22c10000), SPH_C32(0x33990000), + SPH_C32(0xc936199d), SPH_C32(0xc4dca486), SPH_C32(0xede04c82), + SPH_C32(0xdb15f8a5) }, + { SPH_C32(0x21f3005c), SPH_C32(0xe0afc000), SPH_C32(0x56db0000), + SPH_C32(0xc2990000), SPH_C32(0x9d781e90), SPH_C32(0x5d5b1b61), + SPH_C32(0xb3d09c81), SPH_C32(0x34f1f47f), SPH_C32(0xd22200a8), + SPH_C32(0xd9494000), SPH_C32(0x3b3d0000), SPH_C32(0xa5420000), + SPH_C32(0xf3bd7460), SPH_C32(0x2f160a75), SPH_C32(0xc18d0b0d), + SPH_C32(0x779b942d) }, + { SPH_C32(0x710c0058), SPH_C32(0xa5db8000), SPH_C32(0x6b200000), + SPH_C32(0xdb7f0000), SPH_C32(0x86c44896), SPH_C32(0xbc29603c), + SPH_C32(0x52785017), SPH_C32(0x4fea22c6), SPH_C32(0x24a200ad), + SPH_C32(0xed0a8000), SPH_C32(0x1f3a0000), SPH_C32(0x2a7f0000), + SPH_C32(0xd28a4f9b), SPH_C32(0x25aedfdb), SPH_C32(0x0c488014), + SPH_C32(0xa00e2e1c) }, + { SPH_C32(0x878c005d), SPH_C32(0x91984000), SPH_C32(0x4f270000), + SPH_C32(0x54420000), SPH_C32(0xa7f3736d), SPH_C32(0xb691b592), + SPH_C32(0x9fbddb0e), SPH_C32(0x987f98f7), SPH_C32(0x82dd00ac), + SPH_C32(0x9c3d0000), SPH_C32(0x06c60000), SPH_C32(0xbca40000), + SPH_C32(0xe8012266), SPH_C32(0xce647128), SPH_C32(0x2025c79b), + SPH_C32(0x0c804294) }, + { SPH_C32(0x832800a0), SPH_C32(0x67420000), SPH_C32(0xe1170000), + SPH_C32(0x370b0000), SPH_C32(0xcba30034), SPH_C32(0x3c34923c), + SPH_C32(0x9767bdcc), SPH_C32(0x450360bf), SPH_C32(0x774400f0), + SPH_C32(0xf15a0000), SPH_C32(0xf5b20000), SPH_C32(0x34140000), + SPH_C32(0x89377e8c), SPH_C32(0x5a8bec25), SPH_C32(0x0bc3cd1e), + SPH_C32(0xcf3775cb) }, + { SPH_C32(0x75a800a5), SPH_C32(0x5301c000), SPH_C32(0xc5100000), + SPH_C32(0xb8360000), SPH_C32(0xea943bcf), SPH_C32(0x368c4792), + SPH_C32(0x5aa236d5), SPH_C32(0x9296da8e), SPH_C32(0xd13b00f1), + SPH_C32(0x806d8000), SPH_C32(0xec4e0000), SPH_C32(0xa2cf0000), + SPH_C32(0xb3bc1371), SPH_C32(0xb14142d6), SPH_C32(0x27ae8a91), + SPH_C32(0x63b91943) }, + { SPH_C32(0x255700a1), SPH_C32(0x16758000), SPH_C32(0xf8eb0000), + SPH_C32(0xa1d00000), SPH_C32(0xf1286dc9), SPH_C32(0xd7fe3ccf), + SPH_C32(0xbb0afa43), SPH_C32(0xe98d0c37), SPH_C32(0x27bb00f4), + SPH_C32(0xb42e4000), SPH_C32(0xc8490000), SPH_C32(0x2df20000), + SPH_C32(0x928b288a), SPH_C32(0xbbf99778), SPH_C32(0xea6b0188), + SPH_C32(0xb42ca372) }, + { SPH_C32(0xd3d700a4), SPH_C32(0x22364000), SPH_C32(0xdcec0000), + SPH_C32(0x2eed0000), SPH_C32(0xd01f5632), SPH_C32(0xdd46e961), + SPH_C32(0x76cf715a), SPH_C32(0x3e18b606), SPH_C32(0x81c400f5), + SPH_C32(0xc519c000), SPH_C32(0xd1b50000), SPH_C32(0xbb290000), + SPH_C32(0xa8004577), SPH_C32(0x5033398b), SPH_C32(0xc6064607), + SPH_C32(0x18a2cffa) }, + { SPH_C32(0x745d00a9), SPH_C32(0xa87ec000), SPH_C32(0x22c10000), + SPH_C32(0x33990000), SPH_C32(0xc936199d), SPH_C32(0xc4dca486), + SPH_C32(0xede04c82), SPH_C32(0xdb15f8a5), SPH_C32(0xa32e00f0), + SPH_C32(0x7c92c000), SPH_C32(0x501d0000), SPH_C32(0x7e3d0000), + SPH_C32(0x75793cf6), SPH_C32(0x933f6a49), SPH_C32(0x93f55b1a), + SPH_C32(0x3871b6eb) }, + { SPH_C32(0x82dd00ac), SPH_C32(0x9c3d0000), SPH_C32(0x06c60000), + SPH_C32(0xbca40000), SPH_C32(0xe8012266), SPH_C32(0xce647128), + SPH_C32(0x2025c79b), SPH_C32(0x0c804294), SPH_C32(0x055100f1), + SPH_C32(0x0da54000), SPH_C32(0x49e10000), SPH_C32(0xe8e60000), + SPH_C32(0x4ff2510b), SPH_C32(0x78f5c4ba), SPH_C32(0xbf981c95), + SPH_C32(0x94ffda63) }, + { SPH_C32(0xd22200a8), SPH_C32(0xd9494000), SPH_C32(0x3b3d0000), + SPH_C32(0xa5420000), SPH_C32(0xf3bd7460), SPH_C32(0x2f160a75), + SPH_C32(0xc18d0b0d), SPH_C32(0x779b942d), SPH_C32(0xf3d100f4), + SPH_C32(0x39e68000), SPH_C32(0x6de60000), SPH_C32(0x67db0000), + SPH_C32(0x6ec56af0), SPH_C32(0x724d1114), SPH_C32(0x725d978c), + SPH_C32(0x436a6052) }, + { SPH_C32(0x24a200ad), SPH_C32(0xed0a8000), SPH_C32(0x1f3a0000), + SPH_C32(0x2a7f0000), SPH_C32(0xd28a4f9b), SPH_C32(0x25aedfdb), + SPH_C32(0x0c488014), SPH_C32(0xa00e2e1c), SPH_C32(0x55ae00f5), + SPH_C32(0x48d10000), SPH_C32(0x741a0000), SPH_C32(0xf1000000), + SPH_C32(0x544e070d), SPH_C32(0x9987bfe7), SPH_C32(0x5e30d003), + SPH_C32(0xefe40cda) }, + { SPH_C32(0x574200a0), SPH_C32(0xea8ac000), SPH_C32(0x44b80000), + SPH_C32(0x7d220000), SPH_C32(0x37ed424e), SPH_C32(0xf5801450), + SPH_C32(0x0f512bc8), SPH_C32(0xb245a39f), SPH_C32(0x545b00f9), + SPH_C32(0xb3ae0000), SPH_C32(0x93cb0000), SPH_C32(0x7aaf0000), + SPH_C32(0x77ec255f), SPH_C32(0x6bd75cf3), SPH_C32(0xe972aa54), + SPH_C32(0xa6672ef1) }, + { SPH_C32(0xa1c200a5), SPH_C32(0xdec90000), SPH_C32(0x60bf0000), + SPH_C32(0xf21f0000), SPH_C32(0x16da79b5), SPH_C32(0xff38c1fe), + SPH_C32(0xc294a0d1), SPH_C32(0x65d019ae), SPH_C32(0xf22400f8), + SPH_C32(0xc2998000), SPH_C32(0x8a370000), SPH_C32(0xec740000), + SPH_C32(0x4d6748a2), SPH_C32(0x801df200), SPH_C32(0xc51feddb), + SPH_C32(0x0ae94279) }, + { SPH_C32(0xf13d00a1), SPH_C32(0x9bbd4000), SPH_C32(0x5d440000), + SPH_C32(0xebf90000), SPH_C32(0x0d662fb3), SPH_C32(0x1e4abaa3), + SPH_C32(0x233c6c47), SPH_C32(0x1ecbcf17), SPH_C32(0x04a400fd), + SPH_C32(0xf6da4000), SPH_C32(0xae300000), SPH_C32(0x63490000), + SPH_C32(0x6c507359), SPH_C32(0x8aa527ae), SPH_C32(0x08da66c2), + SPH_C32(0xdd7cf848) }, + { SPH_C32(0x07bd00a4), SPH_C32(0xaffe8000), SPH_C32(0x79430000), + SPH_C32(0x64c40000), SPH_C32(0x2c511448), SPH_C32(0x14f26f0d), + SPH_C32(0xeef9e75e), SPH_C32(0xc95e7526), SPH_C32(0xa2db00fc), + SPH_C32(0x87edc000), SPH_C32(0xb7cc0000), SPH_C32(0xf5920000), + SPH_C32(0x56db1ea4), SPH_C32(0x616f895d), SPH_C32(0x24b7214d), + SPH_C32(0x71f294c0) }, + { SPH_C32(0xa03700a9), SPH_C32(0x25b60000), SPH_C32(0x876e0000), + SPH_C32(0x79b00000), SPH_C32(0x35785be7), SPH_C32(0x0d6822ea), + SPH_C32(0x75d6da86), SPH_C32(0x2c533b85), SPH_C32(0x803100f9), + SPH_C32(0x3e66c000), SPH_C32(0x36640000), SPH_C32(0x30860000), + SPH_C32(0x8ba26725), SPH_C32(0xa263da9f), SPH_C32(0x71443c50), + SPH_C32(0x5121edd1) }, + { SPH_C32(0x56b700ac), SPH_C32(0x11f5c000), SPH_C32(0xa3690000), + SPH_C32(0xf68d0000), SPH_C32(0x144f601c), SPH_C32(0x07d0f744), + SPH_C32(0xb813519f), SPH_C32(0xfbc681b4), SPH_C32(0x264e00f8), + SPH_C32(0x4f514000), SPH_C32(0x2f980000), SPH_C32(0xa65d0000), + SPH_C32(0xb1290ad8), SPH_C32(0x49a9746c), SPH_C32(0x5d297bdf), + SPH_C32(0xfdaf8159) }, + { SPH_C32(0x064800a8), SPH_C32(0x54818000), SPH_C32(0x9e920000), + SPH_C32(0xef6b0000), SPH_C32(0x0ff3361a), SPH_C32(0xe6a28c19), + SPH_C32(0x59bb9d09), SPH_C32(0x80dd570d), SPH_C32(0xd0ce00fd), + SPH_C32(0x7b128000), SPH_C32(0x0b9f0000), SPH_C32(0x29600000), + SPH_C32(0x901e3123), SPH_C32(0x4311a1c2), SPH_C32(0x90ecf0c6), + SPH_C32(0x2a3a3b68) }, + { SPH_C32(0xf0c800ad), SPH_C32(0x60c24000), SPH_C32(0xba950000), + SPH_C32(0x60560000), SPH_C32(0x2ec40de1), SPH_C32(0xec1a59b7), + SPH_C32(0x947e1610), SPH_C32(0x5748ed3c), SPH_C32(0x76b100fc), + SPH_C32(0x0a250000), SPH_C32(0x12630000), SPH_C32(0xbfbb0000), + SPH_C32(0xaa955cde), SPH_C32(0xa8db0f31), SPH_C32(0xbc81b749), + SPH_C32(0x86b457e0) }, + { SPH_C32(0xe8870170), SPH_C32(0x9d720000), SPH_C32(0x12db0000), + SPH_C32(0xd4220000), SPH_C32(0xf2886b27), SPH_C32(0xa921e543), + SPH_C32(0x4ef8b518), SPH_C32(0x618813b1), SPH_C32(0xb4370060), + SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), SPH_C32(0x5cae0000), + SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), SPH_C32(0x1b365f3d), + SPH_C32(0xf3d45758) }, + { SPH_C32(0x1e070175), SPH_C32(0xa931c000), SPH_C32(0x36dc0000), + SPH_C32(0x5b1f0000), SPH_C32(0xd3bf50dc), SPH_C32(0xa39930ed), + SPH_C32(0x833d3e01), SPH_C32(0xb61da980), SPH_C32(0x12480061), + SPH_C32(0x7d7b8000), SPH_C32(0x4f3e0000), SPH_C32(0xca750000), + SPH_C32(0xaedf72c2), SPH_C32(0xd0f456d6), SPH_C32(0x375b18b2), + SPH_C32(0x5f5a3bd0) }, + { SPH_C32(0x4ef80171), SPH_C32(0xec458000), SPH_C32(0x0b270000), + SPH_C32(0x42f90000), SPH_C32(0xc80306da), SPH_C32(0x42eb4bb0), + SPH_C32(0x6295f297), SPH_C32(0xcd067f39), SPH_C32(0xe4c80064), + SPH_C32(0x49384000), SPH_C32(0x6b390000), SPH_C32(0x45480000), + SPH_C32(0x8fe84939), SPH_C32(0xda4c8378), SPH_C32(0xfa9e93ab), + SPH_C32(0x88cf81e1) }, + { SPH_C32(0xb8780174), SPH_C32(0xd8064000), SPH_C32(0x2f200000), + SPH_C32(0xcdc40000), SPH_C32(0xe9343d21), SPH_C32(0x48539e1e), + SPH_C32(0xaf50798e), SPH_C32(0x1a93c508), SPH_C32(0x42b70065), + SPH_C32(0x380fc000), SPH_C32(0x72c50000), SPH_C32(0xd3930000), + SPH_C32(0xb56324c4), SPH_C32(0x31862d8b), SPH_C32(0xd6f3d424), + SPH_C32(0x2441ed69) }, + { SPH_C32(0x1ff20179), SPH_C32(0x524ec000), SPH_C32(0xd10d0000), + SPH_C32(0xd0b00000), SPH_C32(0xf01d728e), SPH_C32(0x51c9d3f9), + SPH_C32(0x347f4456), SPH_C32(0xff9e8bab), SPH_C32(0x605d0060), + SPH_C32(0x8184c000), SPH_C32(0xf36d0000), SPH_C32(0x16870000), + SPH_C32(0x681a5d45), SPH_C32(0xf28a7e49), SPH_C32(0x8300c939), + SPH_C32(0x04929478) }, + { SPH_C32(0xe972017c), SPH_C32(0x660d0000), SPH_C32(0xf50a0000), + SPH_C32(0x5f8d0000), SPH_C32(0xd12a4975), SPH_C32(0x5b710657), + SPH_C32(0xf9bacf4f), SPH_C32(0x280b319a), SPH_C32(0xc6220061), + SPH_C32(0xf0b34000), SPH_C32(0xea910000), SPH_C32(0x805c0000), + SPH_C32(0x529130b8), SPH_C32(0x1940d0ba), SPH_C32(0xaf6d8eb6), + SPH_C32(0xa81cf8f0) }, + { SPH_C32(0xb98d0178), SPH_C32(0x23794000), SPH_C32(0xc8f10000), + SPH_C32(0x466b0000), SPH_C32(0xca961f73), SPH_C32(0xba037d0a), + SPH_C32(0x181203d9), SPH_C32(0x5310e723), SPH_C32(0x30a20064), + SPH_C32(0xc4f08000), SPH_C32(0xce960000), SPH_C32(0x0f610000), + SPH_C32(0x73a60b43), SPH_C32(0x13f80514), SPH_C32(0x62a805af), + SPH_C32(0x7f8942c1) }, + { SPH_C32(0x4f0d017d), SPH_C32(0x173a8000), SPH_C32(0xecf60000), + SPH_C32(0xc9560000), SPH_C32(0xeba12488), SPH_C32(0xb0bba8a4), + SPH_C32(0xd5d788c0), SPH_C32(0x84855d12), SPH_C32(0x96dd0065), + SPH_C32(0xb5c70000), SPH_C32(0xd76a0000), SPH_C32(0x99ba0000), + SPH_C32(0x492d66be), SPH_C32(0xf832abe7), SPH_C32(0x4ec54220), + SPH_C32(0xd3072e49) }, + { SPH_C32(0x3ced0170), SPH_C32(0x10bac000), SPH_C32(0xb7740000), + SPH_C32(0x9e0b0000), SPH_C32(0x0ec6295d), SPH_C32(0x6095632f), + SPH_C32(0xd6ce231c), SPH_C32(0x96ced091), SPH_C32(0x97280069), + SPH_C32(0x4eb80000), SPH_C32(0x30bb0000), SPH_C32(0x12150000), + SPH_C32(0x6a8f44ec), SPH_C32(0x0a6248f3), SPH_C32(0xf9873877), + SPH_C32(0x9a840c62) }, + { SPH_C32(0xca6d0175), SPH_C32(0x24f90000), SPH_C32(0x93730000), + SPH_C32(0x11360000), SPH_C32(0x2ff112a6), SPH_C32(0x6a2db681), + SPH_C32(0x1b0ba805), SPH_C32(0x415b6aa0), SPH_C32(0x31570068), + SPH_C32(0x3f8f8000), SPH_C32(0x29470000), SPH_C32(0x84ce0000), + SPH_C32(0x50042911), SPH_C32(0xe1a8e600), SPH_C32(0xd5ea7ff8), + SPH_C32(0x360a60ea) }, + { SPH_C32(0x9a920171), SPH_C32(0x618d4000), SPH_C32(0xae880000), + SPH_C32(0x08d00000), SPH_C32(0x344d44a0), SPH_C32(0x8b5fcddc), + SPH_C32(0xfaa36493), SPH_C32(0x3a40bc19), SPH_C32(0xc7d7006d), + SPH_C32(0x0bcc4000), SPH_C32(0x0d400000), SPH_C32(0x0bf30000), + SPH_C32(0x713312ea), SPH_C32(0xeb1033ae), SPH_C32(0x182ff4e1), + SPH_C32(0xe19fdadb) }, + { SPH_C32(0x6c120174), SPH_C32(0x55ce8000), SPH_C32(0x8a8f0000), + SPH_C32(0x87ed0000), SPH_C32(0x157a7f5b), SPH_C32(0x81e71872), + SPH_C32(0x3766ef8a), SPH_C32(0xedd50628), SPH_C32(0x61a8006c), + SPH_C32(0x7afbc000), SPH_C32(0x14bc0000), SPH_C32(0x9d280000), + SPH_C32(0x4bb87f17), SPH_C32(0x00da9d5d), SPH_C32(0x3442b36e), + SPH_C32(0x4d11b653) }, + { SPH_C32(0xcb980179), SPH_C32(0xdf860000), SPH_C32(0x74a20000), + SPH_C32(0x9a990000), SPH_C32(0x0c5330f4), SPH_C32(0x987d5595), + SPH_C32(0xac49d252), SPH_C32(0x08d8488b), SPH_C32(0x43420069), + SPH_C32(0xc370c000), SPH_C32(0x95140000), SPH_C32(0x583c0000), + SPH_C32(0x96c10696), SPH_C32(0xc3d6ce9f), SPH_C32(0x61b1ae73), + SPH_C32(0x6dc2cf42) }, + { SPH_C32(0x3d18017c), SPH_C32(0xebc5c000), SPH_C32(0x50a50000), + SPH_C32(0x15a40000), SPH_C32(0x2d640b0f), SPH_C32(0x92c5803b), + SPH_C32(0x618c594b), SPH_C32(0xdf4df2ba), SPH_C32(0xe53d0068), + SPH_C32(0xb2474000), SPH_C32(0x8ce80000), SPH_C32(0xcee70000), + SPH_C32(0xac4a6b6b), SPH_C32(0x281c606c), SPH_C32(0x4ddce9fc), + SPH_C32(0xc14ca3ca) }, + { SPH_C32(0x6de70178), SPH_C32(0xaeb18000), SPH_C32(0x6d5e0000), + SPH_C32(0x0c420000), SPH_C32(0x36d85d09), SPH_C32(0x73b7fb66), + SPH_C32(0x802495dd), SPH_C32(0xa4562403), SPH_C32(0x13bd006d), + SPH_C32(0x86048000), SPH_C32(0xa8ef0000), SPH_C32(0x41da0000), + SPH_C32(0x8d7d5090), SPH_C32(0x22a4b5c2), SPH_C32(0x801962e5), + SPH_C32(0x16d919fb) }, + { SPH_C32(0x9b67017d), SPH_C32(0x9af24000), SPH_C32(0x49590000), + SPH_C32(0x837f0000), SPH_C32(0x17ef66f2), SPH_C32(0x790f2ec8), + SPH_C32(0x4de11ec4), SPH_C32(0x73c39e32), SPH_C32(0xb5c2006c), + SPH_C32(0xf7330000), SPH_C32(0xb1130000), SPH_C32(0xd7010000), + SPH_C32(0xb7f63d6d), SPH_C32(0xc96e1b31), SPH_C32(0xac74256a), + SPH_C32(0xba577573) }, + { SPH_C32(0x9fc30180), SPH_C32(0x6c280000), SPH_C32(0xe7690000), + SPH_C32(0xe0360000), SPH_C32(0x7bbf15ab), SPH_C32(0xf3aa0966), + SPH_C32(0x453b7806), SPH_C32(0xaebf667a), SPH_C32(0x405b0030), + SPH_C32(0x9a540000), SPH_C32(0x42670000), SPH_C32(0x5fb10000), + SPH_C32(0xd6c06187), SPH_C32(0x5d81863c), SPH_C32(0x87922fef), + SPH_C32(0x79e0422c) }, + { SPH_C32(0x69430185), SPH_C32(0x586bc000), SPH_C32(0xc36e0000), + SPH_C32(0x6f0b0000), SPH_C32(0x5a882e50), SPH_C32(0xf912dcc8), + SPH_C32(0x88fef31f), SPH_C32(0x792adc4b), SPH_C32(0xe6240031), + SPH_C32(0xeb638000), SPH_C32(0x5b9b0000), SPH_C32(0xc96a0000), + SPH_C32(0xec4b0c7a), SPH_C32(0xb64b28cf), SPH_C32(0xabff6860), + SPH_C32(0xd56e2ea4) }, + { SPH_C32(0x39bc0181), SPH_C32(0x1d1f8000), SPH_C32(0xfe950000), + SPH_C32(0x76ed0000), SPH_C32(0x41347856), SPH_C32(0x1860a795), + SPH_C32(0x69563f89), SPH_C32(0x02310af2), SPH_C32(0x10a40034), + SPH_C32(0xdf204000), SPH_C32(0x7f9c0000), SPH_C32(0x46570000), + SPH_C32(0xcd7c3781), SPH_C32(0xbcf3fd61), SPH_C32(0x663ae379), + SPH_C32(0x02fb9495) }, + { SPH_C32(0xcf3c0184), SPH_C32(0x295c4000), SPH_C32(0xda920000), + SPH_C32(0xf9d00000), SPH_C32(0x600343ad), SPH_C32(0x12d8723b), + SPH_C32(0xa493b490), SPH_C32(0xd5a4b0c3), SPH_C32(0xb6db0035), + SPH_C32(0xae17c000), SPH_C32(0x66600000), SPH_C32(0xd08c0000), + SPH_C32(0xf7f75a7c), SPH_C32(0x57395392), SPH_C32(0x4a57a4f6), + SPH_C32(0xae75f81d) }, + { SPH_C32(0x68b60189), SPH_C32(0xa314c000), SPH_C32(0x24bf0000), + SPH_C32(0xe4a40000), SPH_C32(0x792a0c02), SPH_C32(0x0b423fdc), + SPH_C32(0x3fbc8948), SPH_C32(0x30a9fe60), SPH_C32(0x94310030), + SPH_C32(0x179cc000), SPH_C32(0xe7c80000), SPH_C32(0x15980000), + SPH_C32(0x2a8e23fd), SPH_C32(0x94350050), SPH_C32(0x1fa4b9eb), + SPH_C32(0x8ea6810c) }, + { SPH_C32(0x9e36018c), SPH_C32(0x97570000), SPH_C32(0x00b80000), + SPH_C32(0x6b990000), SPH_C32(0x581d37f9), SPH_C32(0x01faea72), + SPH_C32(0xf2790251), SPH_C32(0xe73c4451), SPH_C32(0x324e0031), + SPH_C32(0x66ab4000), SPH_C32(0xfe340000), SPH_C32(0x83430000), + SPH_C32(0x10054e00), SPH_C32(0x7fffaea3), SPH_C32(0x33c9fe64), + SPH_C32(0x2228ed84) }, + { SPH_C32(0xcec90188), SPH_C32(0xd2234000), SPH_C32(0x3d430000), + SPH_C32(0x727f0000), SPH_C32(0x43a161ff), SPH_C32(0xe088912f), + SPH_C32(0x13d1cec7), SPH_C32(0x9c2792e8), SPH_C32(0xc4ce0034), + SPH_C32(0x52e88000), SPH_C32(0xda330000), SPH_C32(0x0c7e0000), + SPH_C32(0x313275fb), SPH_C32(0x75477b0d), SPH_C32(0xfe0c757d), + SPH_C32(0xf5bd57b5) }, + { SPH_C32(0x3849018d), SPH_C32(0xe6608000), SPH_C32(0x19440000), + SPH_C32(0xfd420000), SPH_C32(0x62965a04), SPH_C32(0xea304481), + SPH_C32(0xde1445de), SPH_C32(0x4bb228d9), SPH_C32(0x62b10035), + SPH_C32(0x23df0000), SPH_C32(0xc3cf0000), SPH_C32(0x9aa50000), + SPH_C32(0x0bb91806), SPH_C32(0x9e8dd5fe), SPH_C32(0xd26132f2), + SPH_C32(0x59333b3d) }, + { SPH_C32(0x4ba90180), SPH_C32(0xe1e0c000), SPH_C32(0x42c60000), + SPH_C32(0xaa1f0000), SPH_C32(0x87f157d1), SPH_C32(0x3a1e8f0a), + SPH_C32(0xdd0dee02), SPH_C32(0x59f9a55a), SPH_C32(0x63440039), + SPH_C32(0xd8a00000), SPH_C32(0x241e0000), SPH_C32(0x110a0000), + SPH_C32(0x281b3a54), SPH_C32(0x6cdd36ea), SPH_C32(0x652348a5), + SPH_C32(0x10b01916) }, + { SPH_C32(0xbd290185), SPH_C32(0xd5a30000), SPH_C32(0x66c10000), + SPH_C32(0x25220000), SPH_C32(0xa6c66c2a), SPH_C32(0x30a65aa4), + SPH_C32(0x10c8651b), SPH_C32(0x8e6c1f6b), SPH_C32(0xc53b0038), + SPH_C32(0xa9978000), SPH_C32(0x3de20000), SPH_C32(0x87d10000), + SPH_C32(0x129057a9), SPH_C32(0x87179819), SPH_C32(0x494e0f2a), + SPH_C32(0xbc3e759e) }, + { SPH_C32(0xedd60181), SPH_C32(0x90d74000), SPH_C32(0x5b3a0000), + SPH_C32(0x3cc40000), SPH_C32(0xbd7a3a2c), SPH_C32(0xd1d421f9), + SPH_C32(0xf160a98d), SPH_C32(0xf577c9d2), SPH_C32(0x33bb003d), + SPH_C32(0x9dd44000), SPH_C32(0x19e50000), SPH_C32(0x08ec0000), + SPH_C32(0x33a76c52), SPH_C32(0x8daf4db7), SPH_C32(0x848b8433), + SPH_C32(0x6babcfaf) }, + { SPH_C32(0x1b560184), SPH_C32(0xa4948000), SPH_C32(0x7f3d0000), + SPH_C32(0xb3f90000), SPH_C32(0x9c4d01d7), SPH_C32(0xdb6cf457), + SPH_C32(0x3ca52294), SPH_C32(0x22e273e3), SPH_C32(0x95c4003c), + SPH_C32(0xece3c000), SPH_C32(0x00190000), SPH_C32(0x9e370000), + SPH_C32(0x092c01af), SPH_C32(0x6665e344), SPH_C32(0xa8e6c3bc), + SPH_C32(0xc725a327) }, + { SPH_C32(0xbcdc0189), SPH_C32(0x2edc0000), SPH_C32(0x81100000), + SPH_C32(0xae8d0000), SPH_C32(0x85644e78), SPH_C32(0xc2f6b9b0), + SPH_C32(0xa78a1f4c), SPH_C32(0xc7ef3d40), SPH_C32(0xb72e0039), + SPH_C32(0x5568c000), SPH_C32(0x81b10000), SPH_C32(0x5b230000), + SPH_C32(0xd455782e), SPH_C32(0xa569b086), SPH_C32(0xfd15dea1), + SPH_C32(0xe7f6da36) }, + { SPH_C32(0x4a5c018c), SPH_C32(0x1a9fc000), SPH_C32(0xa5170000), + SPH_C32(0x21b00000), SPH_C32(0xa4537583), SPH_C32(0xc84e6c1e), + SPH_C32(0x6a4f9455), SPH_C32(0x107a8771), SPH_C32(0x11510038), + SPH_C32(0x245f4000), SPH_C32(0x984d0000), SPH_C32(0xcdf80000), + SPH_C32(0xeede15d3), SPH_C32(0x4ea31e75), SPH_C32(0xd178992e), + SPH_C32(0x4b78b6be) }, + { SPH_C32(0x1aa30188), SPH_C32(0x5feb8000), SPH_C32(0x98ec0000), + SPH_C32(0x38560000), SPH_C32(0xbfef2385), SPH_C32(0x293c1743), + SPH_C32(0x8be758c3), SPH_C32(0x6b6151c8), SPH_C32(0xe7d1003d), + SPH_C32(0x101c8000), SPH_C32(0xbc4a0000), SPH_C32(0x42c50000), + SPH_C32(0xcfe92e28), SPH_C32(0x441bcbdb), SPH_C32(0x1cbd1237), + SPH_C32(0x9ced0c8f) }, + { SPH_C32(0xec23018d), SPH_C32(0x6ba84000), SPH_C32(0xbceb0000), + SPH_C32(0xb76b0000), SPH_C32(0x9ed8187e), SPH_C32(0x2384c2ed), + SPH_C32(0x4622d3da), SPH_C32(0xbcf4ebf9), SPH_C32(0x41ae003c), + SPH_C32(0x612b0000), SPH_C32(0xa5b60000), SPH_C32(0xd41e0000), + SPH_C32(0xf56243d5), SPH_C32(0xafd16528), SPH_C32(0x30d055b8), + SPH_C32(0x30636007) }, + { SPH_C32(0x1ceb0120), SPH_C32(0x0b6a0000), SPH_C32(0x067e0000), + SPH_C32(0xd73d0000), SPH_C32(0xb01c159f), SPH_C32(0xcf9e9b5a), + SPH_C32(0xd25cc5ca), SPH_C32(0xebbc06c5), SPH_C32(0x371f00c0), + SPH_C32(0x6b0e0000), SPH_C32(0xb7d50000), SPH_C32(0x6ba50000), + SPH_C32(0x5ff71f0b), SPH_C32(0x070a6a19), SPH_C32(0x8c51e2f1), + SPH_C32(0xb6d737e7) }, + { SPH_C32(0xea6b0125), SPH_C32(0x3f29c000), SPH_C32(0x22790000), + SPH_C32(0x58000000), SPH_C32(0x912b2e64), SPH_C32(0xc5264ef4), + SPH_C32(0x1f994ed3), SPH_C32(0x3c29bcf4), SPH_C32(0x916000c1), + SPH_C32(0x1a398000), SPH_C32(0xae290000), SPH_C32(0xfd7e0000), + SPH_C32(0x657c72f6), SPH_C32(0xecc0c4ea), SPH_C32(0xa03ca57e), + SPH_C32(0x1a595b6f) }, + { SPH_C32(0xba940121), SPH_C32(0x7a5d8000), SPH_C32(0x1f820000), + SPH_C32(0x41e60000), SPH_C32(0x8a977862), SPH_C32(0x245435a9), + SPH_C32(0xfe318245), SPH_C32(0x47326a4d), SPH_C32(0x67e000c4), + SPH_C32(0x2e7a4000), SPH_C32(0x8a2e0000), SPH_C32(0x72430000), + SPH_C32(0x444b490d), SPH_C32(0xe6781144), SPH_C32(0x6df92e67), + SPH_C32(0xcdcce15e) }, + { SPH_C32(0x4c140124), SPH_C32(0x4e1e4000), SPH_C32(0x3b850000), + SPH_C32(0xcedb0000), SPH_C32(0xaba04399), SPH_C32(0x2eece007), + SPH_C32(0x33f4095c), SPH_C32(0x90a7d07c), SPH_C32(0xc19f00c5), + SPH_C32(0x5f4dc000), SPH_C32(0x93d20000), SPH_C32(0xe4980000), + SPH_C32(0x7ec024f0), SPH_C32(0x0db2bfb7), SPH_C32(0x419469e8), + SPH_C32(0x61428dd6) }, + { SPH_C32(0xeb9e0129), SPH_C32(0xc456c000), SPH_C32(0xc5a80000), + SPH_C32(0xd3af0000), SPH_C32(0xb2890c36), SPH_C32(0x3776ade0), + SPH_C32(0xa8db3484), SPH_C32(0x75aa9edf), SPH_C32(0xe37500c0), + SPH_C32(0xe6c6c000), SPH_C32(0x127a0000), SPH_C32(0x218c0000), + SPH_C32(0xa3b95d71), SPH_C32(0xcebeec75), SPH_C32(0x146774f5), + SPH_C32(0x4191f4c7) }, + { SPH_C32(0x1d1e012c), SPH_C32(0xf0150000), SPH_C32(0xe1af0000), + SPH_C32(0x5c920000), SPH_C32(0x93be37cd), SPH_C32(0x3dce784e), + SPH_C32(0x651ebf9d), SPH_C32(0xa23f24ee), SPH_C32(0x450a00c1), + SPH_C32(0x97f14000), SPH_C32(0x0b860000), SPH_C32(0xb7570000), + SPH_C32(0x9932308c), SPH_C32(0x25744286), SPH_C32(0x380a337a), + SPH_C32(0xed1f984f) }, + { SPH_C32(0x4de10128), SPH_C32(0xb5614000), SPH_C32(0xdc540000), + SPH_C32(0x45740000), SPH_C32(0x880261cb), SPH_C32(0xdcbc0313), + SPH_C32(0x84b6730b), SPH_C32(0xd924f257), SPH_C32(0xb38a00c4), + SPH_C32(0xa3b28000), SPH_C32(0x2f810000), SPH_C32(0x386a0000), + SPH_C32(0xb8050b77), SPH_C32(0x2fcc9728), SPH_C32(0xf5cfb863), + SPH_C32(0x3a8a227e) }, + { SPH_C32(0xbb61012d), SPH_C32(0x81228000), SPH_C32(0xf8530000), + SPH_C32(0xca490000), SPH_C32(0xa9355a30), SPH_C32(0xd604d6bd), + SPH_C32(0x4973f812), SPH_C32(0x0eb14866), SPH_C32(0x15f500c5), + SPH_C32(0xd2850000), SPH_C32(0x367d0000), SPH_C32(0xaeb10000), + SPH_C32(0x828e668a), SPH_C32(0xc40639db), SPH_C32(0xd9a2ffec), + SPH_C32(0x96044ef6) }, + { SPH_C32(0xc8810120), SPH_C32(0x86a2c000), SPH_C32(0xa3d10000), + SPH_C32(0x9d140000), SPH_C32(0x4c5257e5), SPH_C32(0x062a1d36), + SPH_C32(0x4a6a53ce), SPH_C32(0x1cfac5e5), SPH_C32(0x140000c9), + SPH_C32(0x29fa0000), SPH_C32(0xd1ac0000), SPH_C32(0x251e0000), + SPH_C32(0xa12c44d8), SPH_C32(0x3656dacf), SPH_C32(0x6ee085bb), + SPH_C32(0xdf876cdd) }, + { SPH_C32(0x3e010125), SPH_C32(0xb2e10000), SPH_C32(0x87d60000), + SPH_C32(0x12290000), SPH_C32(0x6d656c1e), SPH_C32(0x0c92c898), + SPH_C32(0x87afd8d7), SPH_C32(0xcb6f7fd4), SPH_C32(0xb27f00c8), + SPH_C32(0x58cd8000), SPH_C32(0xc8500000), SPH_C32(0xb3c50000), + SPH_C32(0x9ba72925), SPH_C32(0xdd9c743c), SPH_C32(0x428dc234), + SPH_C32(0x73090055) }, + { SPH_C32(0x6efe0121), SPH_C32(0xf7954000), SPH_C32(0xba2d0000), + SPH_C32(0x0bcf0000), SPH_C32(0x76d93a18), SPH_C32(0xede0b3c5), + SPH_C32(0x66071441), SPH_C32(0xb074a96d), SPH_C32(0x44ff00cd), + SPH_C32(0x6c8e4000), SPH_C32(0xec570000), SPH_C32(0x3cf80000), + SPH_C32(0xba9012de), SPH_C32(0xd724a192), SPH_C32(0x8f48492d), + SPH_C32(0xa49cba64) }, + { SPH_C32(0x987e0124), SPH_C32(0xc3d68000), SPH_C32(0x9e2a0000), + SPH_C32(0x84f20000), SPH_C32(0x57ee01e3), SPH_C32(0xe758666b), + SPH_C32(0xabc29f58), SPH_C32(0x67e1135c), SPH_C32(0xe28000cc), + SPH_C32(0x1db9c000), SPH_C32(0xf5ab0000), SPH_C32(0xaa230000), + SPH_C32(0x801b7f23), SPH_C32(0x3cee0f61), SPH_C32(0xa3250ea2), + SPH_C32(0x0812d6ec) }, + { SPH_C32(0x3ff40129), SPH_C32(0x499e0000), SPH_C32(0x60070000), + SPH_C32(0x99860000), SPH_C32(0x4ec74e4c), SPH_C32(0xfec22b8c), + SPH_C32(0x30eda280), SPH_C32(0x82ec5dff), SPH_C32(0xc06a00c9), + SPH_C32(0xa432c000), SPH_C32(0x74030000), SPH_C32(0x6f370000), + SPH_C32(0x5d6206a2), SPH_C32(0xffe25ca3), SPH_C32(0xf6d613bf), + SPH_C32(0x28c1affd) }, + { SPH_C32(0xc974012c), SPH_C32(0x7dddc000), SPH_C32(0x44000000), + SPH_C32(0x16bb0000), SPH_C32(0x6ff075b7), SPH_C32(0xf47afe22), + SPH_C32(0xfd282999), SPH_C32(0x5579e7ce), SPH_C32(0x661500c8), + SPH_C32(0xd5054000), SPH_C32(0x6dff0000), SPH_C32(0xf9ec0000), + SPH_C32(0x67e96b5f), SPH_C32(0x1428f250), SPH_C32(0xdabb5430), + SPH_C32(0x844fc375) }, + { SPH_C32(0x998b0128), SPH_C32(0x38a98000), SPH_C32(0x79fb0000), + SPH_C32(0x0f5d0000), SPH_C32(0x744c23b1), SPH_C32(0x1508857f), + SPH_C32(0x1c80e50f), SPH_C32(0x2e623177), SPH_C32(0x909500cd), + SPH_C32(0xe1468000), SPH_C32(0x49f80000), SPH_C32(0x76d10000), + SPH_C32(0x46de50a4), SPH_C32(0x1e9027fe), SPH_C32(0x177edf29), + SPH_C32(0x53da7944) }, + { SPH_C32(0x6f0b012d), SPH_C32(0x0cea4000), SPH_C32(0x5dfc0000), + SPH_C32(0x80600000), SPH_C32(0x557b184a), SPH_C32(0x1fb050d1), + SPH_C32(0xd1456e16), SPH_C32(0xf9f78b46), SPH_C32(0x36ea00cc), + SPH_C32(0x90710000), SPH_C32(0x50040000), SPH_C32(0xe00a0000), + SPH_C32(0x7c553d59), SPH_C32(0xf55a890d), SPH_C32(0x3b1398a6), + SPH_C32(0xff5415cc) }, + { SPH_C32(0x6baf01d0), SPH_C32(0xfa300000), SPH_C32(0xf3cc0000), + SPH_C32(0xe3290000), SPH_C32(0x392b6b13), SPH_C32(0x9515777f), + SPH_C32(0xd99f08d4), SPH_C32(0x248b730e), SPH_C32(0xc3730090), + SPH_C32(0xfd160000), SPH_C32(0xa3700000), SPH_C32(0x68ba0000), + SPH_C32(0x1d6361b3), SPH_C32(0x61b51400), SPH_C32(0x10f59223), + SPH_C32(0x3ce32293) }, + { SPH_C32(0x9d2f01d5), SPH_C32(0xce73c000), SPH_C32(0xd7cb0000), + SPH_C32(0x6c140000), SPH_C32(0x181c50e8), SPH_C32(0x9fada2d1), + SPH_C32(0x145a83cd), SPH_C32(0xf31ec93f), SPH_C32(0x650c0091), + SPH_C32(0x8c218000), SPH_C32(0xba8c0000), SPH_C32(0xfe610000), + SPH_C32(0x27e80c4e), SPH_C32(0x8a7fbaf3), SPH_C32(0x3c98d5ac), + SPH_C32(0x906d4e1b) }, + { SPH_C32(0xcdd001d1), SPH_C32(0x8b078000), SPH_C32(0xea300000), + SPH_C32(0x75f20000), SPH_C32(0x03a006ee), SPH_C32(0x7edfd98c), + SPH_C32(0xf5f24f5b), SPH_C32(0x88051f86), SPH_C32(0x938c0094), + SPH_C32(0xb8624000), SPH_C32(0x9e8b0000), SPH_C32(0x715c0000), + SPH_C32(0x06df37b5), SPH_C32(0x80c76f5d), SPH_C32(0xf15d5eb5), + SPH_C32(0x47f8f42a) }, + { SPH_C32(0x3b5001d4), SPH_C32(0xbf444000), SPH_C32(0xce370000), + SPH_C32(0xfacf0000), SPH_C32(0x22973d15), SPH_C32(0x74670c22), + SPH_C32(0x3837c442), SPH_C32(0x5f90a5b7), SPH_C32(0x35f30095), + SPH_C32(0xc955c000), SPH_C32(0x87770000), SPH_C32(0xe7870000), + SPH_C32(0x3c545a48), SPH_C32(0x6b0dc1ae), SPH_C32(0xdd30193a), + SPH_C32(0xeb7698a2) }, + { SPH_C32(0x9cda01d9), SPH_C32(0x350cc000), SPH_C32(0x301a0000), + SPH_C32(0xe7bb0000), SPH_C32(0x3bbe72ba), SPH_C32(0x6dfd41c5), + SPH_C32(0xa318f99a), SPH_C32(0xba9deb14), SPH_C32(0x17190090), + SPH_C32(0x70dec000), SPH_C32(0x06df0000), SPH_C32(0x22930000), + SPH_C32(0xe12d23c9), SPH_C32(0xa801926c), SPH_C32(0x88c30427), + SPH_C32(0xcba5e1b3) }, + { SPH_C32(0x6a5a01dc), SPH_C32(0x014f0000), SPH_C32(0x141d0000), + SPH_C32(0x68860000), SPH_C32(0x1a894941), SPH_C32(0x6745946b), + SPH_C32(0x6edd7283), SPH_C32(0x6d085125), SPH_C32(0xb1660091), + SPH_C32(0x01e94000), SPH_C32(0x1f230000), SPH_C32(0xb4480000), + SPH_C32(0xdba64e34), SPH_C32(0x43cb3c9f), SPH_C32(0xa4ae43a8), + SPH_C32(0x672b8d3b) }, + { SPH_C32(0x3aa501d8), SPH_C32(0x443b4000), SPH_C32(0x29e60000), + SPH_C32(0x71600000), SPH_C32(0x01351f47), SPH_C32(0x8637ef36), + SPH_C32(0x8f75be15), SPH_C32(0x1613879c), SPH_C32(0x47e60094), + SPH_C32(0x35aa8000), SPH_C32(0x3b240000), SPH_C32(0x3b750000), + SPH_C32(0xfa9175cf), SPH_C32(0x4973e931), SPH_C32(0x696bc8b1), + SPH_C32(0xb0be370a) }, + { SPH_C32(0xcc2501dd), SPH_C32(0x70788000), SPH_C32(0x0de10000), + SPH_C32(0xfe5d0000), SPH_C32(0x200224bc), SPH_C32(0x8c8f3a98), + SPH_C32(0x42b0350c), SPH_C32(0xc1863dad), SPH_C32(0xe1990095), + SPH_C32(0x449d0000), SPH_C32(0x22d80000), SPH_C32(0xadae0000), + SPH_C32(0xc01a1832), SPH_C32(0xa2b947c2), SPH_C32(0x45068f3e), + SPH_C32(0x1c305b82) }, + { SPH_C32(0xbfc501d0), SPH_C32(0x77f8c000), SPH_C32(0x56630000), + SPH_C32(0xa9000000), SPH_C32(0xc5652969), SPH_C32(0x5ca1f113), + SPH_C32(0x41a99ed0), SPH_C32(0xd3cdb02e), SPH_C32(0xe06c0099), + SPH_C32(0xbfe20000), SPH_C32(0xc5090000), SPH_C32(0x26010000), + SPH_C32(0xe3b83a60), SPH_C32(0x50e9a4d6), SPH_C32(0xf244f569), + SPH_C32(0x55b379a9) }, + { SPH_C32(0x494501d5), SPH_C32(0x43bb0000), SPH_C32(0x72640000), + SPH_C32(0x263d0000), SPH_C32(0xe4521292), SPH_C32(0x561924bd), + SPH_C32(0x8c6c15c9), SPH_C32(0x04580a1f), SPH_C32(0x46130098), + SPH_C32(0xced58000), SPH_C32(0xdcf50000), SPH_C32(0xb0da0000), + SPH_C32(0xd933579d), SPH_C32(0xbb230a25), SPH_C32(0xde29b2e6), + SPH_C32(0xf93d1521) }, + { SPH_C32(0x19ba01d1), SPH_C32(0x06cf4000), SPH_C32(0x4f9f0000), + SPH_C32(0x3fdb0000), SPH_C32(0xffee4494), SPH_C32(0xb76b5fe0), + SPH_C32(0x6dc4d95f), SPH_C32(0x7f43dca6), SPH_C32(0xb093009d), + SPH_C32(0xfa964000), SPH_C32(0xf8f20000), SPH_C32(0x3fe70000), + SPH_C32(0xf8046c66), SPH_C32(0xb19bdf8b), SPH_C32(0x13ec39ff), + SPH_C32(0x2ea8af10) }, + { SPH_C32(0xef3a01d4), SPH_C32(0x328c8000), SPH_C32(0x6b980000), + SPH_C32(0xb0e60000), SPH_C32(0xded97f6f), SPH_C32(0xbdd38a4e), + SPH_C32(0xa0015246), SPH_C32(0xa8d66697), SPH_C32(0x16ec009c), + SPH_C32(0x8ba1c000), SPH_C32(0xe10e0000), SPH_C32(0xa93c0000), + SPH_C32(0xc28f019b), SPH_C32(0x5a517178), SPH_C32(0x3f817e70), + SPH_C32(0x8226c398) }, + { SPH_C32(0x48b001d9), SPH_C32(0xb8c40000), SPH_C32(0x95b50000), + SPH_C32(0xad920000), SPH_C32(0xc7f030c0), SPH_C32(0xa449c7a9), + SPH_C32(0x3b2e6f9e), SPH_C32(0x4ddb2834), SPH_C32(0x34060099), + SPH_C32(0x322ac000), SPH_C32(0x60a60000), SPH_C32(0x6c280000), + SPH_C32(0x1ff6781a), SPH_C32(0x995d22ba), SPH_C32(0x6a72636d), + SPH_C32(0xa2f5ba89) }, + { SPH_C32(0xbe3001dc), SPH_C32(0x8c87c000), SPH_C32(0xb1b20000), + SPH_C32(0x22af0000), SPH_C32(0xe6c70b3b), SPH_C32(0xaef11207), + SPH_C32(0xf6ebe487), SPH_C32(0x9a4e9205), SPH_C32(0x92790098), + SPH_C32(0x431d4000), SPH_C32(0x795a0000), SPH_C32(0xfaf30000), + SPH_C32(0x257d15e7), SPH_C32(0x72978c49), SPH_C32(0x461f24e2), + SPH_C32(0x0e7bd601) }, + { SPH_C32(0xeecf01d8), SPH_C32(0xc9f38000), SPH_C32(0x8c490000), + SPH_C32(0x3b490000), SPH_C32(0xfd7b5d3d), SPH_C32(0x4f83695a), + SPH_C32(0x17432811), SPH_C32(0xe15544bc), SPH_C32(0x64f9009d), + SPH_C32(0x775e8000), SPH_C32(0x5d5d0000), SPH_C32(0x75ce0000), + SPH_C32(0x044a2e1c), SPH_C32(0x782f59e7), SPH_C32(0x8bdaaffb), + SPH_C32(0xd9ee6c30) }, + { SPH_C32(0x184f01dd), SPH_C32(0xfdb04000), SPH_C32(0xa84e0000), + SPH_C32(0xb4740000), SPH_C32(0xdc4c66c6), SPH_C32(0x453bbcf4), + SPH_C32(0xda86a308), SPH_C32(0x36c0fe8d), SPH_C32(0xc286009c), + SPH_C32(0x06690000), SPH_C32(0x44a10000), SPH_C32(0xe3150000), + SPH_C32(0x3ec143e1), SPH_C32(0x93e5f714), SPH_C32(0xa7b7e874), + SPH_C32(0x756000b8) }, + { SPH_C32(0xb4370060), SPH_C32(0x0c4c0000), SPH_C32(0x56c20000), + SPH_C32(0x5cae0000), SPH_C32(0x94541f3f), SPH_C32(0x3b3ef825), + SPH_C32(0x1b365f3d), SPH_C32(0xf3d45758), SPH_C32(0x5cb00110), + SPH_C32(0x913e0000), SPH_C32(0x44190000), SPH_C32(0x888c0000), + SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), SPH_C32(0x55ceea25), + SPH_C32(0x925c44e9) }, + { SPH_C32(0x42b70065), SPH_C32(0x380fc000), SPH_C32(0x72c50000), + SPH_C32(0xd3930000), SPH_C32(0xb56324c4), SPH_C32(0x31862d8b), + SPH_C32(0xd6f3d424), SPH_C32(0x2441ed69), SPH_C32(0xfacf0111), + SPH_C32(0xe0098000), SPH_C32(0x5de50000), SPH_C32(0x1e570000), + SPH_C32(0x5c5719e5), SPH_C32(0x79d5b395), SPH_C32(0x79a3adaa), + SPH_C32(0x3ed22861) }, + { SPH_C32(0x12480061), SPH_C32(0x7d7b8000), SPH_C32(0x4f3e0000), + SPH_C32(0xca750000), SPH_C32(0xaedf72c2), SPH_C32(0xd0f456d6), + SPH_C32(0x375b18b2), SPH_C32(0x5f5a3bd0), SPH_C32(0x0c4f0114), + SPH_C32(0xd44a4000), SPH_C32(0x79e20000), SPH_C32(0x916a0000), + SPH_C32(0x7d60221e), SPH_C32(0x736d663b), SPH_C32(0xb46626b3), + SPH_C32(0xe9479250) }, + { SPH_C32(0xe4c80064), SPH_C32(0x49384000), SPH_C32(0x6b390000), + SPH_C32(0x45480000), SPH_C32(0x8fe84939), SPH_C32(0xda4c8378), + SPH_C32(0xfa9e93ab), SPH_C32(0x88cf81e1), SPH_C32(0xaa300115), + SPH_C32(0xa57dc000), SPH_C32(0x601e0000), SPH_C32(0x07b10000), + SPH_C32(0x47eb4fe3), SPH_C32(0x98a7c8c8), SPH_C32(0x980b613c), + SPH_C32(0x45c9fed8) }, + { SPH_C32(0x43420069), SPH_C32(0xc370c000), SPH_C32(0x95140000), + SPH_C32(0x583c0000), SPH_C32(0x96c10696), SPH_C32(0xc3d6ce9f), + SPH_C32(0x61b1ae73), SPH_C32(0x6dc2cf42), SPH_C32(0x88da0110), + SPH_C32(0x1cf6c000), SPH_C32(0xe1b60000), SPH_C32(0xc2a50000), + SPH_C32(0x9a923662), SPH_C32(0x5bab9b0a), SPH_C32(0xcdf87c21), + SPH_C32(0x651a87c9) }, + { SPH_C32(0xb5c2006c), SPH_C32(0xf7330000), SPH_C32(0xb1130000), + SPH_C32(0xd7010000), SPH_C32(0xb7f63d6d), SPH_C32(0xc96e1b31), + SPH_C32(0xac74256a), SPH_C32(0xba577573), SPH_C32(0x2ea50111), + SPH_C32(0x6dc14000), SPH_C32(0xf84a0000), SPH_C32(0x547e0000), + SPH_C32(0xa0195b9f), SPH_C32(0xb06135f9), SPH_C32(0xe1953bae), + SPH_C32(0xc994eb41) }, + { SPH_C32(0xe53d0068), SPH_C32(0xb2474000), SPH_C32(0x8ce80000), + SPH_C32(0xcee70000), SPH_C32(0xac4a6b6b), SPH_C32(0x281c606c), + SPH_C32(0x4ddce9fc), SPH_C32(0xc14ca3ca), SPH_C32(0xd8250114), + SPH_C32(0x59828000), SPH_C32(0xdc4d0000), SPH_C32(0xdb430000), + SPH_C32(0x812e6064), SPH_C32(0xbad9e057), SPH_C32(0x2c50b0b7), + SPH_C32(0x1e015170) }, + { SPH_C32(0x13bd006d), SPH_C32(0x86048000), SPH_C32(0xa8ef0000), + SPH_C32(0x41da0000), SPH_C32(0x8d7d5090), SPH_C32(0x22a4b5c2), + SPH_C32(0x801962e5), SPH_C32(0x16d919fb), SPH_C32(0x7e5a0115), + SPH_C32(0x28b50000), SPH_C32(0xc5b10000), SPH_C32(0x4d980000), + SPH_C32(0xbba50d99), SPH_C32(0x51134ea4), SPH_C32(0x003df738), + SPH_C32(0xb28f3df8) }, + { SPH_C32(0x605d0060), SPH_C32(0x8184c000), SPH_C32(0xf36d0000), + SPH_C32(0x16870000), SPH_C32(0x681a5d45), SPH_C32(0xf28a7e49), + SPH_C32(0x8300c939), SPH_C32(0x04929478), SPH_C32(0x7faf0119), + SPH_C32(0xd3ca0000), SPH_C32(0x22600000), SPH_C32(0xc6370000), + SPH_C32(0x98072fcb), SPH_C32(0xa343adb0), SPH_C32(0xb77f8d6f), + SPH_C32(0xfb0c1fd3) }, + { SPH_C32(0x96dd0065), SPH_C32(0xb5c70000), SPH_C32(0xd76a0000), + SPH_C32(0x99ba0000), SPH_C32(0x492d66be), SPH_C32(0xf832abe7), + SPH_C32(0x4ec54220), SPH_C32(0xd3072e49), SPH_C32(0xd9d00118), + SPH_C32(0xa2fd8000), SPH_C32(0x3b9c0000), SPH_C32(0x50ec0000), + SPH_C32(0xa28c4236), SPH_C32(0x48890343), SPH_C32(0x9b12cae0), + SPH_C32(0x5782735b) }, + { SPH_C32(0xc6220061), SPH_C32(0xf0b34000), SPH_C32(0xea910000), + SPH_C32(0x805c0000), SPH_C32(0x529130b8), SPH_C32(0x1940d0ba), + SPH_C32(0xaf6d8eb6), SPH_C32(0xa81cf8f0), SPH_C32(0x2f50011d), + SPH_C32(0x96be4000), SPH_C32(0x1f9b0000), SPH_C32(0xdfd10000), + SPH_C32(0x83bb79cd), SPH_C32(0x4231d6ed), SPH_C32(0x56d741f9), + SPH_C32(0x8017c96a) }, + { SPH_C32(0x30a20064), SPH_C32(0xc4f08000), SPH_C32(0xce960000), + SPH_C32(0x0f610000), SPH_C32(0x73a60b43), SPH_C32(0x13f80514), + SPH_C32(0x62a805af), SPH_C32(0x7f8942c1), SPH_C32(0x892f011c), + SPH_C32(0xe789c000), SPH_C32(0x06670000), SPH_C32(0x490a0000), + SPH_C32(0xb9301430), SPH_C32(0xa9fb781e), SPH_C32(0x7aba0676), + SPH_C32(0x2c99a5e2) }, + { SPH_C32(0x97280069), SPH_C32(0x4eb80000), SPH_C32(0x30bb0000), + SPH_C32(0x12150000), SPH_C32(0x6a8f44ec), SPH_C32(0x0a6248f3), + SPH_C32(0xf9873877), SPH_C32(0x9a840c62), SPH_C32(0xabc50119), + SPH_C32(0x5e02c000), SPH_C32(0x87cf0000), SPH_C32(0x8c1e0000), + SPH_C32(0x64496db1), SPH_C32(0x6af72bdc), SPH_C32(0x2f491b6b), + SPH_C32(0x0c4adcf3) }, + { SPH_C32(0x61a8006c), SPH_C32(0x7afbc000), SPH_C32(0x14bc0000), + SPH_C32(0x9d280000), SPH_C32(0x4bb87f17), SPH_C32(0x00da9d5d), + SPH_C32(0x3442b36e), SPH_C32(0x4d11b653), SPH_C32(0x0dba0118), + SPH_C32(0x2f354000), SPH_C32(0x9e330000), SPH_C32(0x1ac50000), + SPH_C32(0x5ec2004c), SPH_C32(0x813d852f), SPH_C32(0x03245ce4), + SPH_C32(0xa0c4b07b) }, + { SPH_C32(0x31570068), SPH_C32(0x3f8f8000), SPH_C32(0x29470000), + SPH_C32(0x84ce0000), SPH_C32(0x50042911), SPH_C32(0xe1a8e600), + SPH_C32(0xd5ea7ff8), SPH_C32(0x360a60ea), SPH_C32(0xfb3a011d), + SPH_C32(0x1b768000), SPH_C32(0xba340000), SPH_C32(0x95f80000), + SPH_C32(0x7ff53bb7), SPH_C32(0x8b855081), SPH_C32(0xcee1d7fd), + SPH_C32(0x77510a4a) }, + { SPH_C32(0xc7d7006d), SPH_C32(0x0bcc4000), SPH_C32(0x0d400000), + SPH_C32(0x0bf30000), SPH_C32(0x713312ea), SPH_C32(0xeb1033ae), + SPH_C32(0x182ff4e1), SPH_C32(0xe19fdadb), SPH_C32(0x5d45011c), + SPH_C32(0x6a410000), SPH_C32(0xa3c80000), SPH_C32(0x03230000), + SPH_C32(0x457e564a), SPH_C32(0x604ffe72), SPH_C32(0xe28c9072), + SPH_C32(0xdbdf66c2) }, + { SPH_C32(0xc3730090), SPH_C32(0xfd160000), SPH_C32(0xa3700000), + SPH_C32(0x68ba0000), SPH_C32(0x1d6361b3), SPH_C32(0x61b51400), + SPH_C32(0x10f59223), SPH_C32(0x3ce32293), SPH_C32(0xa8dc0140), + SPH_C32(0x07260000), SPH_C32(0x50bc0000), SPH_C32(0x8b930000), + SPH_C32(0x24480aa0), SPH_C32(0xf4a0637f), SPH_C32(0xc96a9af7), + SPH_C32(0x1868519d) }, + { SPH_C32(0x35f30095), SPH_C32(0xc955c000), SPH_C32(0x87770000), + SPH_C32(0xe7870000), SPH_C32(0x3c545a48), SPH_C32(0x6b0dc1ae), + SPH_C32(0xdd30193a), SPH_C32(0xeb7698a2), SPH_C32(0x0ea30141), + SPH_C32(0x76118000), SPH_C32(0x49400000), SPH_C32(0x1d480000), + SPH_C32(0x1ec3675d), SPH_C32(0x1f6acd8c), SPH_C32(0xe507dd78), + SPH_C32(0xb4e63d15) }, + { SPH_C32(0x650c0091), SPH_C32(0x8c218000), SPH_C32(0xba8c0000), + SPH_C32(0xfe610000), SPH_C32(0x27e80c4e), SPH_C32(0x8a7fbaf3), + SPH_C32(0x3c98d5ac), SPH_C32(0x906d4e1b), SPH_C32(0xf8230144), + SPH_C32(0x42524000), SPH_C32(0x6d470000), SPH_C32(0x92750000), + SPH_C32(0x3ff45ca6), SPH_C32(0x15d21822), SPH_C32(0x28c25661), + SPH_C32(0x63738724) }, + { SPH_C32(0x938c0094), SPH_C32(0xb8624000), SPH_C32(0x9e8b0000), + SPH_C32(0x715c0000), SPH_C32(0x06df37b5), SPH_C32(0x80c76f5d), + SPH_C32(0xf15d5eb5), SPH_C32(0x47f8f42a), SPH_C32(0x5e5c0145), + SPH_C32(0x3365c000), SPH_C32(0x74bb0000), SPH_C32(0x04ae0000), + SPH_C32(0x057f315b), SPH_C32(0xfe18b6d1), SPH_C32(0x04af11ee), + SPH_C32(0xcffdebac) }, + { SPH_C32(0x34060099), SPH_C32(0x322ac000), SPH_C32(0x60a60000), + SPH_C32(0x6c280000), SPH_C32(0x1ff6781a), SPH_C32(0x995d22ba), + SPH_C32(0x6a72636d), SPH_C32(0xa2f5ba89), SPH_C32(0x7cb60140), + SPH_C32(0x8aeec000), SPH_C32(0xf5130000), SPH_C32(0xc1ba0000), + SPH_C32(0xd80648da), SPH_C32(0x3d14e513), SPH_C32(0x515c0cf3), + SPH_C32(0xef2e92bd) }, + { SPH_C32(0xc286009c), SPH_C32(0x06690000), SPH_C32(0x44a10000), + SPH_C32(0xe3150000), SPH_C32(0x3ec143e1), SPH_C32(0x93e5f714), + SPH_C32(0xa7b7e874), SPH_C32(0x756000b8), SPH_C32(0xdac90141), + SPH_C32(0xfbd94000), SPH_C32(0xecef0000), SPH_C32(0x57610000), + SPH_C32(0xe28d2527), SPH_C32(0xd6de4be0), SPH_C32(0x7d314b7c), + SPH_C32(0x43a0fe35) }, + { SPH_C32(0x92790098), SPH_C32(0x431d4000), SPH_C32(0x795a0000), + SPH_C32(0xfaf30000), SPH_C32(0x257d15e7), SPH_C32(0x72978c49), + SPH_C32(0x461f24e2), SPH_C32(0x0e7bd601), SPH_C32(0x2c490144), + SPH_C32(0xcf9a8000), SPH_C32(0xc8e80000), SPH_C32(0xd85c0000), + SPH_C32(0xc3ba1edc), SPH_C32(0xdc669e4e), SPH_C32(0xb0f4c065), + SPH_C32(0x94354404) }, + { SPH_C32(0x64f9009d), SPH_C32(0x775e8000), SPH_C32(0x5d5d0000), + SPH_C32(0x75ce0000), SPH_C32(0x044a2e1c), SPH_C32(0x782f59e7), + SPH_C32(0x8bdaaffb), SPH_C32(0xd9ee6c30), SPH_C32(0x8a360145), + SPH_C32(0xbead0000), SPH_C32(0xd1140000), SPH_C32(0x4e870000), + SPH_C32(0xf9317321), SPH_C32(0x37ac30bd), SPH_C32(0x9c9987ea), + SPH_C32(0x38bb288c) }, + { SPH_C32(0x17190090), SPH_C32(0x70dec000), SPH_C32(0x06df0000), + SPH_C32(0x22930000), SPH_C32(0xe12d23c9), SPH_C32(0xa801926c), + SPH_C32(0x88c30427), SPH_C32(0xcba5e1b3), SPH_C32(0x8bc30149), + SPH_C32(0x45d20000), SPH_C32(0x36c50000), SPH_C32(0xc5280000), + SPH_C32(0xda935173), SPH_C32(0xc5fcd3a9), SPH_C32(0x2bdbfdbd), + SPH_C32(0x71380aa7) }, + { SPH_C32(0xe1990095), SPH_C32(0x449d0000), SPH_C32(0x22d80000), + SPH_C32(0xadae0000), SPH_C32(0xc01a1832), SPH_C32(0xa2b947c2), + SPH_C32(0x45068f3e), SPH_C32(0x1c305b82), SPH_C32(0x2dbc0148), + SPH_C32(0x34e58000), SPH_C32(0x2f390000), SPH_C32(0x53f30000), + SPH_C32(0xe0183c8e), SPH_C32(0x2e367d5a), SPH_C32(0x07b6ba32), + SPH_C32(0xddb6662f) }, + { SPH_C32(0xb1660091), SPH_C32(0x01e94000), SPH_C32(0x1f230000), + SPH_C32(0xb4480000), SPH_C32(0xdba64e34), SPH_C32(0x43cb3c9f), + SPH_C32(0xa4ae43a8), SPH_C32(0x672b8d3b), SPH_C32(0xdb3c014d), + SPH_C32(0x00a64000), SPH_C32(0x0b3e0000), SPH_C32(0xdcce0000), + SPH_C32(0xc12f0775), SPH_C32(0x248ea8f4), SPH_C32(0xca73312b), + SPH_C32(0x0a23dc1e) }, + { SPH_C32(0x47e60094), SPH_C32(0x35aa8000), SPH_C32(0x3b240000), + SPH_C32(0x3b750000), SPH_C32(0xfa9175cf), SPH_C32(0x4973e931), + SPH_C32(0x696bc8b1), SPH_C32(0xb0be370a), SPH_C32(0x7d43014c), + SPH_C32(0x7191c000), SPH_C32(0x12c20000), SPH_C32(0x4a150000), + SPH_C32(0xfba46a88), SPH_C32(0xcf440607), SPH_C32(0xe61e76a4), + SPH_C32(0xa6adb096) }, + { SPH_C32(0xe06c0099), SPH_C32(0xbfe20000), SPH_C32(0xc5090000), + SPH_C32(0x26010000), SPH_C32(0xe3b83a60), SPH_C32(0x50e9a4d6), + SPH_C32(0xf244f569), SPH_C32(0x55b379a9), SPH_C32(0x5fa90149), + SPH_C32(0xc81ac000), SPH_C32(0x936a0000), SPH_C32(0x8f010000), + SPH_C32(0x26dd1309), SPH_C32(0x0c4855c5), SPH_C32(0xb3ed6bb9), + SPH_C32(0x867ec987) }, + { SPH_C32(0x16ec009c), SPH_C32(0x8ba1c000), SPH_C32(0xe10e0000), + SPH_C32(0xa93c0000), SPH_C32(0xc28f019b), SPH_C32(0x5a517178), + SPH_C32(0x3f817e70), SPH_C32(0x8226c398), SPH_C32(0xf9d60148), + SPH_C32(0xb92d4000), SPH_C32(0x8a960000), SPH_C32(0x19da0000), + SPH_C32(0x1c567ef4), SPH_C32(0xe782fb36), SPH_C32(0x9f802c36), + SPH_C32(0x2af0a50f) }, + { SPH_C32(0x46130098), SPH_C32(0xced58000), SPH_C32(0xdcf50000), + SPH_C32(0xb0da0000), SPH_C32(0xd933579d), SPH_C32(0xbb230a25), + SPH_C32(0xde29b2e6), SPH_C32(0xf93d1521), SPH_C32(0x0f56014d), + SPH_C32(0x8d6e8000), SPH_C32(0xae910000), SPH_C32(0x96e70000), + SPH_C32(0x3d61450f), SPH_C32(0xed3a2e98), SPH_C32(0x5245a72f), + SPH_C32(0xfd651f3e) }, + { SPH_C32(0xb093009d), SPH_C32(0xfa964000), SPH_C32(0xf8f20000), + SPH_C32(0x3fe70000), SPH_C32(0xf8046c66), SPH_C32(0xb19bdf8b), + SPH_C32(0x13ec39ff), SPH_C32(0x2ea8af10), SPH_C32(0xa929014c), + SPH_C32(0xfc590000), SPH_C32(0xb76d0000), SPH_C32(0x003c0000), + SPH_C32(0x07ea28f2), SPH_C32(0x06f0806b), SPH_C32(0x7e28e0a0), + SPH_C32(0x51eb73b6) }, + { SPH_C32(0x405b0030), SPH_C32(0x9a540000), SPH_C32(0x42670000), + SPH_C32(0x5fb10000), SPH_C32(0xd6c06187), SPH_C32(0x5d81863c), + SPH_C32(0x87922fef), SPH_C32(0x79e0422c), SPH_C32(0xdf9801b0), + SPH_C32(0xf67c0000), SPH_C32(0xa50e0000), SPH_C32(0xbf870000), + SPH_C32(0xad7f742c), SPH_C32(0xae2b8f5a), SPH_C32(0xc2a957e9), + SPH_C32(0xd75f2456) }, + { SPH_C32(0xb6db0035), SPH_C32(0xae17c000), SPH_C32(0x66600000), + SPH_C32(0xd08c0000), SPH_C32(0xf7f75a7c), SPH_C32(0x57395392), + SPH_C32(0x4a57a4f6), SPH_C32(0xae75f81d), SPH_C32(0x79e701b1), + SPH_C32(0x874b8000), SPH_C32(0xbcf20000), SPH_C32(0x295c0000), + SPH_C32(0x97f419d1), SPH_C32(0x45e121a9), SPH_C32(0xeec41066), + SPH_C32(0x7bd148de) }, + { SPH_C32(0xe6240031), SPH_C32(0xeb638000), SPH_C32(0x5b9b0000), + SPH_C32(0xc96a0000), SPH_C32(0xec4b0c7a), SPH_C32(0xb64b28cf), + SPH_C32(0xabff6860), SPH_C32(0xd56e2ea4), SPH_C32(0x8f6701b4), + SPH_C32(0xb3084000), SPH_C32(0x98f50000), SPH_C32(0xa6610000), + SPH_C32(0xb6c3222a), SPH_C32(0x4f59f407), SPH_C32(0x23019b7f), + SPH_C32(0xac44f2ef) }, + { SPH_C32(0x10a40034), SPH_C32(0xdf204000), SPH_C32(0x7f9c0000), + SPH_C32(0x46570000), SPH_C32(0xcd7c3781), SPH_C32(0xbcf3fd61), + SPH_C32(0x663ae379), SPH_C32(0x02fb9495), SPH_C32(0x291801b5), + SPH_C32(0xc23fc000), SPH_C32(0x81090000), SPH_C32(0x30ba0000), + SPH_C32(0x8c484fd7), SPH_C32(0xa4935af4), SPH_C32(0x0f6cdcf0), + SPH_C32(0x00ca9e67) }, + { SPH_C32(0xb72e0039), SPH_C32(0x5568c000), SPH_C32(0x81b10000), + SPH_C32(0x5b230000), SPH_C32(0xd455782e), SPH_C32(0xa569b086), + SPH_C32(0xfd15dea1), SPH_C32(0xe7f6da36), SPH_C32(0x0bf201b0), + SPH_C32(0x7bb4c000), SPH_C32(0x00a10000), SPH_C32(0xf5ae0000), + SPH_C32(0x51313656), SPH_C32(0x679f0936), SPH_C32(0x5a9fc1ed), + SPH_C32(0x2019e776) }, + { SPH_C32(0x41ae003c), SPH_C32(0x612b0000), SPH_C32(0xa5b60000), + SPH_C32(0xd41e0000), SPH_C32(0xf56243d5), SPH_C32(0xafd16528), + SPH_C32(0x30d055b8), SPH_C32(0x30636007), SPH_C32(0xad8d01b1), + SPH_C32(0x0a834000), SPH_C32(0x195d0000), SPH_C32(0x63750000), + SPH_C32(0x6bba5bab), SPH_C32(0x8c55a7c5), SPH_C32(0x76f28662), + SPH_C32(0x8c978bfe) }, + { SPH_C32(0x11510038), SPH_C32(0x245f4000), SPH_C32(0x984d0000), + SPH_C32(0xcdf80000), SPH_C32(0xeede15d3), SPH_C32(0x4ea31e75), + SPH_C32(0xd178992e), SPH_C32(0x4b78b6be), SPH_C32(0x5b0d01b4), + SPH_C32(0x3ec08000), SPH_C32(0x3d5a0000), SPH_C32(0xec480000), + SPH_C32(0x4a8d6050), SPH_C32(0x86ed726b), SPH_C32(0xbb370d7b), + SPH_C32(0x5b0231cf) }, + { SPH_C32(0xe7d1003d), SPH_C32(0x101c8000), SPH_C32(0xbc4a0000), + SPH_C32(0x42c50000), SPH_C32(0xcfe92e28), SPH_C32(0x441bcbdb), + SPH_C32(0x1cbd1237), SPH_C32(0x9ced0c8f), SPH_C32(0xfd7201b5), + SPH_C32(0x4ff70000), SPH_C32(0x24a60000), SPH_C32(0x7a930000), + SPH_C32(0x70060dad), SPH_C32(0x6d27dc98), SPH_C32(0x975a4af4), + SPH_C32(0xf78c5d47) }, + { SPH_C32(0x94310030), SPH_C32(0x179cc000), SPH_C32(0xe7c80000), + SPH_C32(0x15980000), SPH_C32(0x2a8e23fd), SPH_C32(0x94350050), + SPH_C32(0x1fa4b9eb), SPH_C32(0x8ea6810c), SPH_C32(0xfc8701b9), + SPH_C32(0xb4880000), SPH_C32(0xc3770000), SPH_C32(0xf13c0000), + SPH_C32(0x53a42fff), SPH_C32(0x9f773f8c), SPH_C32(0x201830a3), + SPH_C32(0xbe0f7f6c) }, + { SPH_C32(0x62b10035), SPH_C32(0x23df0000), SPH_C32(0xc3cf0000), + SPH_C32(0x9aa50000), SPH_C32(0x0bb91806), SPH_C32(0x9e8dd5fe), + SPH_C32(0xd26132f2), SPH_C32(0x59333b3d), SPH_C32(0x5af801b8), + SPH_C32(0xc5bf8000), SPH_C32(0xda8b0000), SPH_C32(0x67e70000), + SPH_C32(0x692f4202), SPH_C32(0x74bd917f), SPH_C32(0x0c75772c), + SPH_C32(0x128113e4) }, + { SPH_C32(0x324e0031), SPH_C32(0x66ab4000), SPH_C32(0xfe340000), + SPH_C32(0x83430000), SPH_C32(0x10054e00), SPH_C32(0x7fffaea3), + SPH_C32(0x33c9fe64), SPH_C32(0x2228ed84), SPH_C32(0xac7801bd), + SPH_C32(0xf1fc4000), SPH_C32(0xfe8c0000), SPH_C32(0xe8da0000), + SPH_C32(0x481879f9), SPH_C32(0x7e0544d1), SPH_C32(0xc1b0fc35), + SPH_C32(0xc514a9d5) }, + { SPH_C32(0xc4ce0034), SPH_C32(0x52e88000), SPH_C32(0xda330000), + SPH_C32(0x0c7e0000), SPH_C32(0x313275fb), SPH_C32(0x75477b0d), + SPH_C32(0xfe0c757d), SPH_C32(0xf5bd57b5), SPH_C32(0x0a0701bc), + SPH_C32(0x80cbc000), SPH_C32(0xe7700000), SPH_C32(0x7e010000), + SPH_C32(0x72931404), SPH_C32(0x95cfea22), SPH_C32(0xedddbbba), + SPH_C32(0x699ac55d) }, + { SPH_C32(0x63440039), SPH_C32(0xd8a00000), SPH_C32(0x241e0000), + SPH_C32(0x110a0000), SPH_C32(0x281b3a54), SPH_C32(0x6cdd36ea), + SPH_C32(0x652348a5), SPH_C32(0x10b01916), SPH_C32(0x28ed01b9), + SPH_C32(0x3940c000), SPH_C32(0x66d80000), SPH_C32(0xbb150000), + SPH_C32(0xafea6d85), SPH_C32(0x56c3b9e0), SPH_C32(0xb82ea6a7), + SPH_C32(0x4949bc4c) }, + { SPH_C32(0x95c4003c), SPH_C32(0xece3c000), SPH_C32(0x00190000), + SPH_C32(0x9e370000), SPH_C32(0x092c01af), SPH_C32(0x6665e344), + SPH_C32(0xa8e6c3bc), SPH_C32(0xc725a327), SPH_C32(0x8e9201b8), + SPH_C32(0x48774000), SPH_C32(0x7f240000), SPH_C32(0x2dce0000), + SPH_C32(0x95610078), SPH_C32(0xbd091713), SPH_C32(0x9443e128), + SPH_C32(0xe5c7d0c4) }, + { SPH_C32(0xc53b0038), SPH_C32(0xa9978000), SPH_C32(0x3de20000), + SPH_C32(0x87d10000), SPH_C32(0x129057a9), SPH_C32(0x87179819), + SPH_C32(0x494e0f2a), SPH_C32(0xbc3e759e), SPH_C32(0x781201bd), + SPH_C32(0x7c348000), SPH_C32(0x5b230000), SPH_C32(0xa2f30000), + SPH_C32(0xb4563b83), SPH_C32(0xb7b1c2bd), SPH_C32(0x59866a31), + SPH_C32(0x32526af5) }, + { SPH_C32(0x33bb003d), SPH_C32(0x9dd44000), SPH_C32(0x19e50000), + SPH_C32(0x08ec0000), SPH_C32(0x33a76c52), SPH_C32(0x8daf4db7), + SPH_C32(0x848b8433), SPH_C32(0x6babcfaf), SPH_C32(0xde6d01bc), + SPH_C32(0x0d030000), SPH_C32(0x42df0000), SPH_C32(0x34280000), + SPH_C32(0x8edd567e), SPH_C32(0x5c7b6c4e), SPH_C32(0x75eb2dbe), + SPH_C32(0x9edc067d) }, + { SPH_C32(0x371f00c0), SPH_C32(0x6b0e0000), SPH_C32(0xb7d50000), + SPH_C32(0x6ba50000), SPH_C32(0x5ff71f0b), SPH_C32(0x070a6a19), + SPH_C32(0x8c51e2f1), SPH_C32(0xb6d737e7), SPH_C32(0x2bf401e0), + SPH_C32(0x60640000), SPH_C32(0xb1ab0000), SPH_C32(0xbc980000), + SPH_C32(0xefeb0a94), SPH_C32(0xc894f143), SPH_C32(0x5e0d273b), + SPH_C32(0x5d6b3122) }, + { SPH_C32(0xc19f00c5), SPH_C32(0x5f4dc000), SPH_C32(0x93d20000), + SPH_C32(0xe4980000), SPH_C32(0x7ec024f0), SPH_C32(0x0db2bfb7), + SPH_C32(0x419469e8), SPH_C32(0x61428dd6), SPH_C32(0x8d8b01e1), + SPH_C32(0x11538000), SPH_C32(0xa8570000), SPH_C32(0x2a430000), + SPH_C32(0xd5606769), SPH_C32(0x235e5fb0), SPH_C32(0x726060b4), + SPH_C32(0xf1e55daa) }, + { SPH_C32(0x916000c1), SPH_C32(0x1a398000), SPH_C32(0xae290000), + SPH_C32(0xfd7e0000), SPH_C32(0x657c72f6), SPH_C32(0xecc0c4ea), + SPH_C32(0xa03ca57e), SPH_C32(0x1a595b6f), SPH_C32(0x7b0b01e4), + SPH_C32(0x25104000), SPH_C32(0x8c500000), SPH_C32(0xa57e0000), + SPH_C32(0xf4575c92), SPH_C32(0x29e68a1e), SPH_C32(0xbfa5ebad), + SPH_C32(0x2670e79b) }, + { SPH_C32(0x67e000c4), SPH_C32(0x2e7a4000), SPH_C32(0x8a2e0000), + SPH_C32(0x72430000), SPH_C32(0x444b490d), SPH_C32(0xe6781144), + SPH_C32(0x6df92e67), SPH_C32(0xcdcce15e), SPH_C32(0xdd7401e5), + SPH_C32(0x5427c000), SPH_C32(0x95ac0000), SPH_C32(0x33a50000), + SPH_C32(0xcedc316f), SPH_C32(0xc22c24ed), SPH_C32(0x93c8ac22), + SPH_C32(0x8afe8b13) }, + { SPH_C32(0xc06a00c9), SPH_C32(0xa432c000), SPH_C32(0x74030000), + SPH_C32(0x6f370000), SPH_C32(0x5d6206a2), SPH_C32(0xffe25ca3), + SPH_C32(0xf6d613bf), SPH_C32(0x28c1affd), SPH_C32(0xff9e01e0), + SPH_C32(0xedacc000), SPH_C32(0x14040000), SPH_C32(0xf6b10000), + SPH_C32(0x13a548ee), SPH_C32(0x0120772f), SPH_C32(0xc63bb13f), + SPH_C32(0xaa2df202) }, + { SPH_C32(0x36ea00cc), SPH_C32(0x90710000), SPH_C32(0x50040000), + SPH_C32(0xe00a0000), SPH_C32(0x7c553d59), SPH_C32(0xf55a890d), + SPH_C32(0x3b1398a6), SPH_C32(0xff5415cc), SPH_C32(0x59e101e1), + SPH_C32(0x9c9b4000), SPH_C32(0x0df80000), SPH_C32(0x606a0000), + SPH_C32(0x292e2513), SPH_C32(0xeaead9dc), SPH_C32(0xea56f6b0), + SPH_C32(0x06a39e8a) }, + { SPH_C32(0x661500c8), SPH_C32(0xd5054000), SPH_C32(0x6dff0000), + SPH_C32(0xf9ec0000), SPH_C32(0x67e96b5f), SPH_C32(0x1428f250), + SPH_C32(0xdabb5430), SPH_C32(0x844fc375), SPH_C32(0xaf6101e4), + SPH_C32(0xa8d88000), SPH_C32(0x29ff0000), SPH_C32(0xef570000), + SPH_C32(0x08191ee8), SPH_C32(0xe0520c72), SPH_C32(0x27937da9), + SPH_C32(0xd13624bb) }, + { SPH_C32(0x909500cd), SPH_C32(0xe1468000), SPH_C32(0x49f80000), + SPH_C32(0x76d10000), SPH_C32(0x46de50a4), SPH_C32(0x1e9027fe), + SPH_C32(0x177edf29), SPH_C32(0x53da7944), SPH_C32(0x091e01e5), + SPH_C32(0xd9ef0000), SPH_C32(0x30030000), SPH_C32(0x798c0000), + SPH_C32(0x32927315), SPH_C32(0x0b98a281), SPH_C32(0x0bfe3a26), + SPH_C32(0x7db84833) }, + { SPH_C32(0xe37500c0), SPH_C32(0xe6c6c000), SPH_C32(0x127a0000), + SPH_C32(0x218c0000), SPH_C32(0xa3b95d71), SPH_C32(0xcebeec75), + SPH_C32(0x146774f5), SPH_C32(0x4191f4c7), SPH_C32(0x08eb01e9), + SPH_C32(0x22900000), SPH_C32(0xd7d20000), SPH_C32(0xf2230000), + SPH_C32(0x11305147), SPH_C32(0xf9c84195), SPH_C32(0xbcbc4071), + SPH_C32(0x343b6a18) }, + { SPH_C32(0x15f500c5), SPH_C32(0xd2850000), SPH_C32(0x367d0000), + SPH_C32(0xaeb10000), SPH_C32(0x828e668a), SPH_C32(0xc40639db), + SPH_C32(0xd9a2ffec), SPH_C32(0x96044ef6), SPH_C32(0xae9401e8), + SPH_C32(0x53a78000), SPH_C32(0xce2e0000), SPH_C32(0x64f80000), + SPH_C32(0x2bbb3cba), SPH_C32(0x1202ef66), SPH_C32(0x90d107fe), + SPH_C32(0x98b50690) }, + { SPH_C32(0x450a00c1), SPH_C32(0x97f14000), SPH_C32(0x0b860000), + SPH_C32(0xb7570000), SPH_C32(0x9932308c), SPH_C32(0x25744286), + SPH_C32(0x380a337a), SPH_C32(0xed1f984f), SPH_C32(0x581401ed), + SPH_C32(0x67e44000), SPH_C32(0xea290000), SPH_C32(0xebc50000), + SPH_C32(0x0a8c0741), SPH_C32(0x18ba3ac8), SPH_C32(0x5d148ce7), + SPH_C32(0x4f20bca1) }, + { SPH_C32(0xb38a00c4), SPH_C32(0xa3b28000), SPH_C32(0x2f810000), + SPH_C32(0x386a0000), SPH_C32(0xb8050b77), SPH_C32(0x2fcc9728), + SPH_C32(0xf5cfb863), SPH_C32(0x3a8a227e), SPH_C32(0xfe6b01ec), + SPH_C32(0x16d3c000), SPH_C32(0xf3d50000), SPH_C32(0x7d1e0000), + SPH_C32(0x30076abc), SPH_C32(0xf370943b), SPH_C32(0x7179cb68), + SPH_C32(0xe3aed029) }, + { SPH_C32(0x140000c9), SPH_C32(0x29fa0000), SPH_C32(0xd1ac0000), + SPH_C32(0x251e0000), SPH_C32(0xa12c44d8), SPH_C32(0x3656dacf), + SPH_C32(0x6ee085bb), SPH_C32(0xdf876cdd), SPH_C32(0xdc8101e9), + SPH_C32(0xaf58c000), SPH_C32(0x727d0000), SPH_C32(0xb80a0000), + SPH_C32(0xed7e133d), SPH_C32(0x307cc7f9), SPH_C32(0x248ad675), + SPH_C32(0xc37da938) }, + { SPH_C32(0xe28000cc), SPH_C32(0x1db9c000), SPH_C32(0xf5ab0000), + SPH_C32(0xaa230000), SPH_C32(0x801b7f23), SPH_C32(0x3cee0f61), + SPH_C32(0xa3250ea2), SPH_C32(0x0812d6ec), SPH_C32(0x7afe01e8), + SPH_C32(0xde6f4000), SPH_C32(0x6b810000), SPH_C32(0x2ed10000), + SPH_C32(0xd7f57ec0), SPH_C32(0xdbb6690a), SPH_C32(0x08e791fa), + SPH_C32(0x6ff3c5b0) }, + { SPH_C32(0xb27f00c8), SPH_C32(0x58cd8000), SPH_C32(0xc8500000), + SPH_C32(0xb3c50000), SPH_C32(0x9ba72925), SPH_C32(0xdd9c743c), + SPH_C32(0x428dc234), SPH_C32(0x73090055), SPH_C32(0x8c7e01ed), + SPH_C32(0xea2c8000), SPH_C32(0x4f860000), SPH_C32(0xa1ec0000), + SPH_C32(0xf6c2453b), SPH_C32(0xd10ebca4), SPH_C32(0xc5221ae3), + SPH_C32(0xb8667f81) }, + { SPH_C32(0x44ff00cd), SPH_C32(0x6c8e4000), SPH_C32(0xec570000), + SPH_C32(0x3cf80000), SPH_C32(0xba9012de), SPH_C32(0xd724a192), + SPH_C32(0x8f48492d), SPH_C32(0xa49cba64), SPH_C32(0x2a0101ec), + SPH_C32(0x9b1b0000), SPH_C32(0x567a0000), SPH_C32(0x37370000), + SPH_C32(0xcc4928c6), SPH_C32(0x3ac41257), SPH_C32(0xe94f5d6c), + SPH_C32(0x14e81309) }, + { SPH_C32(0x5cb00110), SPH_C32(0x913e0000), SPH_C32(0x44190000), + SPH_C32(0x888c0000), SPH_C32(0x66dc7418), SPH_C32(0x921f1d66), + SPH_C32(0x55ceea25), SPH_C32(0x925c44e9), SPH_C32(0xe8870170), + SPH_C32(0x9d720000), SPH_C32(0x12db0000), SPH_C32(0xd4220000), + SPH_C32(0xf2886b27), SPH_C32(0xa921e543), SPH_C32(0x4ef8b518), + SPH_C32(0x618813b1) }, + { SPH_C32(0xaa300115), SPH_C32(0xa57dc000), SPH_C32(0x601e0000), + SPH_C32(0x07b10000), SPH_C32(0x47eb4fe3), SPH_C32(0x98a7c8c8), + SPH_C32(0x980b613c), SPH_C32(0x45c9fed8), SPH_C32(0x4ef80171), + SPH_C32(0xec458000), SPH_C32(0x0b270000), SPH_C32(0x42f90000), + SPH_C32(0xc80306da), SPH_C32(0x42eb4bb0), SPH_C32(0x6295f297), + SPH_C32(0xcd067f39) }, + { SPH_C32(0xfacf0111), SPH_C32(0xe0098000), SPH_C32(0x5de50000), + SPH_C32(0x1e570000), SPH_C32(0x5c5719e5), SPH_C32(0x79d5b395), + SPH_C32(0x79a3adaa), SPH_C32(0x3ed22861), SPH_C32(0xb8780174), + SPH_C32(0xd8064000), SPH_C32(0x2f200000), SPH_C32(0xcdc40000), + SPH_C32(0xe9343d21), SPH_C32(0x48539e1e), SPH_C32(0xaf50798e), + SPH_C32(0x1a93c508) }, + { SPH_C32(0x0c4f0114), SPH_C32(0xd44a4000), SPH_C32(0x79e20000), + SPH_C32(0x916a0000), SPH_C32(0x7d60221e), SPH_C32(0x736d663b), + SPH_C32(0xb46626b3), SPH_C32(0xe9479250), SPH_C32(0x1e070175), + SPH_C32(0xa931c000), SPH_C32(0x36dc0000), SPH_C32(0x5b1f0000), + SPH_C32(0xd3bf50dc), SPH_C32(0xa39930ed), SPH_C32(0x833d3e01), + SPH_C32(0xb61da980) }, + { SPH_C32(0xabc50119), SPH_C32(0x5e02c000), SPH_C32(0x87cf0000), + SPH_C32(0x8c1e0000), SPH_C32(0x64496db1), SPH_C32(0x6af72bdc), + SPH_C32(0x2f491b6b), SPH_C32(0x0c4adcf3), SPH_C32(0x3ced0170), + SPH_C32(0x10bac000), SPH_C32(0xb7740000), SPH_C32(0x9e0b0000), + SPH_C32(0x0ec6295d), SPH_C32(0x6095632f), SPH_C32(0xd6ce231c), + SPH_C32(0x96ced091) }, + { SPH_C32(0x5d45011c), SPH_C32(0x6a410000), SPH_C32(0xa3c80000), + SPH_C32(0x03230000), SPH_C32(0x457e564a), SPH_C32(0x604ffe72), + SPH_C32(0xe28c9072), SPH_C32(0xdbdf66c2), SPH_C32(0x9a920171), + SPH_C32(0x618d4000), SPH_C32(0xae880000), SPH_C32(0x08d00000), + SPH_C32(0x344d44a0), SPH_C32(0x8b5fcddc), SPH_C32(0xfaa36493), + SPH_C32(0x3a40bc19) }, + { SPH_C32(0x0dba0118), SPH_C32(0x2f354000), SPH_C32(0x9e330000), + SPH_C32(0x1ac50000), SPH_C32(0x5ec2004c), SPH_C32(0x813d852f), + SPH_C32(0x03245ce4), SPH_C32(0xa0c4b07b), SPH_C32(0x6c120174), + SPH_C32(0x55ce8000), SPH_C32(0x8a8f0000), SPH_C32(0x87ed0000), + SPH_C32(0x157a7f5b), SPH_C32(0x81e71872), SPH_C32(0x3766ef8a), + SPH_C32(0xedd50628) }, + { SPH_C32(0xfb3a011d), SPH_C32(0x1b768000), SPH_C32(0xba340000), + SPH_C32(0x95f80000), SPH_C32(0x7ff53bb7), SPH_C32(0x8b855081), + SPH_C32(0xcee1d7fd), SPH_C32(0x77510a4a), SPH_C32(0xca6d0175), + SPH_C32(0x24f90000), SPH_C32(0x93730000), SPH_C32(0x11360000), + SPH_C32(0x2ff112a6), SPH_C32(0x6a2db681), SPH_C32(0x1b0ba805), + SPH_C32(0x415b6aa0) }, + { SPH_C32(0x88da0110), SPH_C32(0x1cf6c000), SPH_C32(0xe1b60000), + SPH_C32(0xc2a50000), SPH_C32(0x9a923662), SPH_C32(0x5bab9b0a), + SPH_C32(0xcdf87c21), SPH_C32(0x651a87c9), SPH_C32(0xcb980179), + SPH_C32(0xdf860000), SPH_C32(0x74a20000), SPH_C32(0x9a990000), + SPH_C32(0x0c5330f4), SPH_C32(0x987d5595), SPH_C32(0xac49d252), + SPH_C32(0x08d8488b) }, + { SPH_C32(0x7e5a0115), SPH_C32(0x28b50000), SPH_C32(0xc5b10000), + SPH_C32(0x4d980000), SPH_C32(0xbba50d99), SPH_C32(0x51134ea4), + SPH_C32(0x003df738), SPH_C32(0xb28f3df8), SPH_C32(0x6de70178), + SPH_C32(0xaeb18000), SPH_C32(0x6d5e0000), SPH_C32(0x0c420000), + SPH_C32(0x36d85d09), SPH_C32(0x73b7fb66), SPH_C32(0x802495dd), + SPH_C32(0xa4562403) }, + { SPH_C32(0x2ea50111), SPH_C32(0x6dc14000), SPH_C32(0xf84a0000), + SPH_C32(0x547e0000), SPH_C32(0xa0195b9f), SPH_C32(0xb06135f9), + SPH_C32(0xe1953bae), SPH_C32(0xc994eb41), SPH_C32(0x9b67017d), + SPH_C32(0x9af24000), SPH_C32(0x49590000), SPH_C32(0x837f0000), + SPH_C32(0x17ef66f2), SPH_C32(0x790f2ec8), SPH_C32(0x4de11ec4), + SPH_C32(0x73c39e32) }, + { SPH_C32(0xd8250114), SPH_C32(0x59828000), SPH_C32(0xdc4d0000), + SPH_C32(0xdb430000), SPH_C32(0x812e6064), SPH_C32(0xbad9e057), + SPH_C32(0x2c50b0b7), SPH_C32(0x1e015170), SPH_C32(0x3d18017c), + SPH_C32(0xebc5c000), SPH_C32(0x50a50000), SPH_C32(0x15a40000), + SPH_C32(0x2d640b0f), SPH_C32(0x92c5803b), SPH_C32(0x618c594b), + SPH_C32(0xdf4df2ba) }, + { SPH_C32(0x7faf0119), SPH_C32(0xd3ca0000), SPH_C32(0x22600000), + SPH_C32(0xc6370000), SPH_C32(0x98072fcb), SPH_C32(0xa343adb0), + SPH_C32(0xb77f8d6f), SPH_C32(0xfb0c1fd3), SPH_C32(0x1ff20179), + SPH_C32(0x524ec000), SPH_C32(0xd10d0000), SPH_C32(0xd0b00000), + SPH_C32(0xf01d728e), SPH_C32(0x51c9d3f9), SPH_C32(0x347f4456), + SPH_C32(0xff9e8bab) }, + { SPH_C32(0x892f011c), SPH_C32(0xe789c000), SPH_C32(0x06670000), + SPH_C32(0x490a0000), SPH_C32(0xb9301430), SPH_C32(0xa9fb781e), + SPH_C32(0x7aba0676), SPH_C32(0x2c99a5e2), SPH_C32(0xb98d0178), + SPH_C32(0x23794000), SPH_C32(0xc8f10000), SPH_C32(0x466b0000), + SPH_C32(0xca961f73), SPH_C32(0xba037d0a), SPH_C32(0x181203d9), + SPH_C32(0x5310e723) }, + { SPH_C32(0xd9d00118), SPH_C32(0xa2fd8000), SPH_C32(0x3b9c0000), + SPH_C32(0x50ec0000), SPH_C32(0xa28c4236), SPH_C32(0x48890343), + SPH_C32(0x9b12cae0), SPH_C32(0x5782735b), SPH_C32(0x4f0d017d), + SPH_C32(0x173a8000), SPH_C32(0xecf60000), SPH_C32(0xc9560000), + SPH_C32(0xeba12488), SPH_C32(0xb0bba8a4), SPH_C32(0xd5d788c0), + SPH_C32(0x84855d12) }, + { SPH_C32(0x2f50011d), SPH_C32(0x96be4000), SPH_C32(0x1f9b0000), + SPH_C32(0xdfd10000), SPH_C32(0x83bb79cd), SPH_C32(0x4231d6ed), + SPH_C32(0x56d741f9), SPH_C32(0x8017c96a), SPH_C32(0xe972017c), + SPH_C32(0x660d0000), SPH_C32(0xf50a0000), SPH_C32(0x5f8d0000), + SPH_C32(0xd12a4975), SPH_C32(0x5b710657), SPH_C32(0xf9bacf4f), + SPH_C32(0x280b319a) }, + { SPH_C32(0x2bf401e0), SPH_C32(0x60640000), SPH_C32(0xb1ab0000), + SPH_C32(0xbc980000), SPH_C32(0xefeb0a94), SPH_C32(0xc894f143), + SPH_C32(0x5e0d273b), SPH_C32(0x5d6b3122), SPH_C32(0x1ceb0120), + SPH_C32(0x0b6a0000), SPH_C32(0x067e0000), SPH_C32(0xd73d0000), + SPH_C32(0xb01c159f), SPH_C32(0xcf9e9b5a), SPH_C32(0xd25cc5ca), + SPH_C32(0xebbc06c5) }, + { SPH_C32(0xdd7401e5), SPH_C32(0x5427c000), SPH_C32(0x95ac0000), + SPH_C32(0x33a50000), SPH_C32(0xcedc316f), SPH_C32(0xc22c24ed), + SPH_C32(0x93c8ac22), SPH_C32(0x8afe8b13), SPH_C32(0xba940121), + SPH_C32(0x7a5d8000), SPH_C32(0x1f820000), SPH_C32(0x41e60000), + SPH_C32(0x8a977862), SPH_C32(0x245435a9), SPH_C32(0xfe318245), + SPH_C32(0x47326a4d) }, + { SPH_C32(0x8d8b01e1), SPH_C32(0x11538000), SPH_C32(0xa8570000), + SPH_C32(0x2a430000), SPH_C32(0xd5606769), SPH_C32(0x235e5fb0), + SPH_C32(0x726060b4), SPH_C32(0xf1e55daa), SPH_C32(0x4c140124), + SPH_C32(0x4e1e4000), SPH_C32(0x3b850000), SPH_C32(0xcedb0000), + SPH_C32(0xaba04399), SPH_C32(0x2eece007), SPH_C32(0x33f4095c), + SPH_C32(0x90a7d07c) }, + { SPH_C32(0x7b0b01e4), SPH_C32(0x25104000), SPH_C32(0x8c500000), + SPH_C32(0xa57e0000), SPH_C32(0xf4575c92), SPH_C32(0x29e68a1e), + SPH_C32(0xbfa5ebad), SPH_C32(0x2670e79b), SPH_C32(0xea6b0125), + SPH_C32(0x3f29c000), SPH_C32(0x22790000), SPH_C32(0x58000000), + SPH_C32(0x912b2e64), SPH_C32(0xc5264ef4), SPH_C32(0x1f994ed3), + SPH_C32(0x3c29bcf4) }, + { SPH_C32(0xdc8101e9), SPH_C32(0xaf58c000), SPH_C32(0x727d0000), + SPH_C32(0xb80a0000), SPH_C32(0xed7e133d), SPH_C32(0x307cc7f9), + SPH_C32(0x248ad675), SPH_C32(0xc37da938), SPH_C32(0xc8810120), + SPH_C32(0x86a2c000), SPH_C32(0xa3d10000), SPH_C32(0x9d140000), + SPH_C32(0x4c5257e5), SPH_C32(0x062a1d36), SPH_C32(0x4a6a53ce), + SPH_C32(0x1cfac5e5) }, + { SPH_C32(0x2a0101ec), SPH_C32(0x9b1b0000), SPH_C32(0x567a0000), + SPH_C32(0x37370000), SPH_C32(0xcc4928c6), SPH_C32(0x3ac41257), + SPH_C32(0xe94f5d6c), SPH_C32(0x14e81309), SPH_C32(0x6efe0121), + SPH_C32(0xf7954000), SPH_C32(0xba2d0000), SPH_C32(0x0bcf0000), + SPH_C32(0x76d93a18), SPH_C32(0xede0b3c5), SPH_C32(0x66071441), + SPH_C32(0xb074a96d) }, + { SPH_C32(0x7afe01e8), SPH_C32(0xde6f4000), SPH_C32(0x6b810000), + SPH_C32(0x2ed10000), SPH_C32(0xd7f57ec0), SPH_C32(0xdbb6690a), + SPH_C32(0x08e791fa), SPH_C32(0x6ff3c5b0), SPH_C32(0x987e0124), + SPH_C32(0xc3d68000), SPH_C32(0x9e2a0000), SPH_C32(0x84f20000), + SPH_C32(0x57ee01e3), SPH_C32(0xe758666b), SPH_C32(0xabc29f58), + SPH_C32(0x67e1135c) }, + { SPH_C32(0x8c7e01ed), SPH_C32(0xea2c8000), SPH_C32(0x4f860000), + SPH_C32(0xa1ec0000), SPH_C32(0xf6c2453b), SPH_C32(0xd10ebca4), + SPH_C32(0xc5221ae3), SPH_C32(0xb8667f81), SPH_C32(0x3e010125), + SPH_C32(0xb2e10000), SPH_C32(0x87d60000), SPH_C32(0x12290000), + SPH_C32(0x6d656c1e), SPH_C32(0x0c92c898), SPH_C32(0x87afd8d7), + SPH_C32(0xcb6f7fd4) }, + { SPH_C32(0xff9e01e0), SPH_C32(0xedacc000), SPH_C32(0x14040000), + SPH_C32(0xf6b10000), SPH_C32(0x13a548ee), SPH_C32(0x0120772f), + SPH_C32(0xc63bb13f), SPH_C32(0xaa2df202), SPH_C32(0x3ff40129), + SPH_C32(0x499e0000), SPH_C32(0x60070000), SPH_C32(0x99860000), + SPH_C32(0x4ec74e4c), SPH_C32(0xfec22b8c), SPH_C32(0x30eda280), + SPH_C32(0x82ec5dff) }, + { SPH_C32(0x091e01e5), SPH_C32(0xd9ef0000), SPH_C32(0x30030000), + SPH_C32(0x798c0000), SPH_C32(0x32927315), SPH_C32(0x0b98a281), + SPH_C32(0x0bfe3a26), SPH_C32(0x7db84833), SPH_C32(0x998b0128), + SPH_C32(0x38a98000), SPH_C32(0x79fb0000), SPH_C32(0x0f5d0000), + SPH_C32(0x744c23b1), SPH_C32(0x1508857f), SPH_C32(0x1c80e50f), + SPH_C32(0x2e623177) }, + { SPH_C32(0x59e101e1), SPH_C32(0x9c9b4000), SPH_C32(0x0df80000), + SPH_C32(0x606a0000), SPH_C32(0x292e2513), SPH_C32(0xeaead9dc), + SPH_C32(0xea56f6b0), SPH_C32(0x06a39e8a), SPH_C32(0x6f0b012d), + SPH_C32(0x0cea4000), SPH_C32(0x5dfc0000), SPH_C32(0x80600000), + SPH_C32(0x557b184a), SPH_C32(0x1fb050d1), SPH_C32(0xd1456e16), + SPH_C32(0xf9f78b46) }, + { SPH_C32(0xaf6101e4), SPH_C32(0xa8d88000), SPH_C32(0x29ff0000), + SPH_C32(0xef570000), SPH_C32(0x08191ee8), SPH_C32(0xe0520c72), + SPH_C32(0x27937da9), SPH_C32(0xd13624bb), SPH_C32(0xc974012c), + SPH_C32(0x7dddc000), SPH_C32(0x44000000), SPH_C32(0x16bb0000), + SPH_C32(0x6ff075b7), SPH_C32(0xf47afe22), SPH_C32(0xfd282999), + SPH_C32(0x5579e7ce) }, + { SPH_C32(0x08eb01e9), SPH_C32(0x22900000), SPH_C32(0xd7d20000), + SPH_C32(0xf2230000), SPH_C32(0x11305147), SPH_C32(0xf9c84195), + SPH_C32(0xbcbc4071), SPH_C32(0x343b6a18), SPH_C32(0xeb9e0129), + SPH_C32(0xc456c000), SPH_C32(0xc5a80000), SPH_C32(0xd3af0000), + SPH_C32(0xb2890c36), SPH_C32(0x3776ade0), SPH_C32(0xa8db3484), + SPH_C32(0x75aa9edf) }, + { SPH_C32(0xfe6b01ec), SPH_C32(0x16d3c000), SPH_C32(0xf3d50000), + SPH_C32(0x7d1e0000), SPH_C32(0x30076abc), SPH_C32(0xf370943b), + SPH_C32(0x7179cb68), SPH_C32(0xe3aed029), SPH_C32(0x4de10128), + SPH_C32(0xb5614000), SPH_C32(0xdc540000), SPH_C32(0x45740000), + SPH_C32(0x880261cb), SPH_C32(0xdcbc0313), SPH_C32(0x84b6730b), + SPH_C32(0xd924f257) }, + { SPH_C32(0xae9401e8), SPH_C32(0x53a78000), SPH_C32(0xce2e0000), + SPH_C32(0x64f80000), SPH_C32(0x2bbb3cba), SPH_C32(0x1202ef66), + SPH_C32(0x90d107fe), SPH_C32(0x98b50690), SPH_C32(0xbb61012d), + SPH_C32(0x81228000), SPH_C32(0xf8530000), SPH_C32(0xca490000), + SPH_C32(0xa9355a30), SPH_C32(0xd604d6bd), SPH_C32(0x4973f812), + SPH_C32(0x0eb14866) }, + { SPH_C32(0x581401ed), SPH_C32(0x67e44000), SPH_C32(0xea290000), + SPH_C32(0xebc50000), SPH_C32(0x0a8c0741), SPH_C32(0x18ba3ac8), + SPH_C32(0x5d148ce7), SPH_C32(0x4f20bca1), SPH_C32(0x1d1e012c), + SPH_C32(0xf0150000), SPH_C32(0xe1af0000), SPH_C32(0x5c920000), + SPH_C32(0x93be37cd), SPH_C32(0x3dce784e), SPH_C32(0x651ebf9d), + SPH_C32(0xa23f24ee) }, + { SPH_C32(0xa8dc0140), SPH_C32(0x07260000), SPH_C32(0x50bc0000), + SPH_C32(0x8b930000), SPH_C32(0x24480aa0), SPH_C32(0xf4a0637f), + SPH_C32(0xc96a9af7), SPH_C32(0x1868519d), SPH_C32(0x6baf01d0), + SPH_C32(0xfa300000), SPH_C32(0xf3cc0000), SPH_C32(0xe3290000), + SPH_C32(0x392b6b13), SPH_C32(0x9515777f), SPH_C32(0xd99f08d4), + SPH_C32(0x248b730e) }, + { SPH_C32(0x5e5c0145), SPH_C32(0x3365c000), SPH_C32(0x74bb0000), + SPH_C32(0x04ae0000), SPH_C32(0x057f315b), SPH_C32(0xfe18b6d1), + SPH_C32(0x04af11ee), SPH_C32(0xcffdebac), SPH_C32(0xcdd001d1), + SPH_C32(0x8b078000), SPH_C32(0xea300000), SPH_C32(0x75f20000), + SPH_C32(0x03a006ee), SPH_C32(0x7edfd98c), SPH_C32(0xf5f24f5b), + SPH_C32(0x88051f86) }, + { SPH_C32(0x0ea30141), SPH_C32(0x76118000), SPH_C32(0x49400000), + SPH_C32(0x1d480000), SPH_C32(0x1ec3675d), SPH_C32(0x1f6acd8c), + SPH_C32(0xe507dd78), SPH_C32(0xb4e63d15), SPH_C32(0x3b5001d4), + SPH_C32(0xbf444000), SPH_C32(0xce370000), SPH_C32(0xfacf0000), + SPH_C32(0x22973d15), SPH_C32(0x74670c22), SPH_C32(0x3837c442), + SPH_C32(0x5f90a5b7) }, + { SPH_C32(0xf8230144), SPH_C32(0x42524000), SPH_C32(0x6d470000), + SPH_C32(0x92750000), SPH_C32(0x3ff45ca6), SPH_C32(0x15d21822), + SPH_C32(0x28c25661), SPH_C32(0x63738724), SPH_C32(0x9d2f01d5), + SPH_C32(0xce73c000), SPH_C32(0xd7cb0000), SPH_C32(0x6c140000), + SPH_C32(0x181c50e8), SPH_C32(0x9fada2d1), SPH_C32(0x145a83cd), + SPH_C32(0xf31ec93f) }, + { SPH_C32(0x5fa90149), SPH_C32(0xc81ac000), SPH_C32(0x936a0000), + SPH_C32(0x8f010000), SPH_C32(0x26dd1309), SPH_C32(0x0c4855c5), + SPH_C32(0xb3ed6bb9), SPH_C32(0x867ec987), SPH_C32(0xbfc501d0), + SPH_C32(0x77f8c000), SPH_C32(0x56630000), SPH_C32(0xa9000000), + SPH_C32(0xc5652969), SPH_C32(0x5ca1f113), SPH_C32(0x41a99ed0), + SPH_C32(0xd3cdb02e) }, + { SPH_C32(0xa929014c), SPH_C32(0xfc590000), SPH_C32(0xb76d0000), + SPH_C32(0x003c0000), SPH_C32(0x07ea28f2), SPH_C32(0x06f0806b), + SPH_C32(0x7e28e0a0), SPH_C32(0x51eb73b6), SPH_C32(0x19ba01d1), + SPH_C32(0x06cf4000), SPH_C32(0x4f9f0000), SPH_C32(0x3fdb0000), + SPH_C32(0xffee4494), SPH_C32(0xb76b5fe0), SPH_C32(0x6dc4d95f), + SPH_C32(0x7f43dca6) }, + { SPH_C32(0xf9d60148), SPH_C32(0xb92d4000), SPH_C32(0x8a960000), + SPH_C32(0x19da0000), SPH_C32(0x1c567ef4), SPH_C32(0xe782fb36), + SPH_C32(0x9f802c36), SPH_C32(0x2af0a50f), SPH_C32(0xef3a01d4), + SPH_C32(0x328c8000), SPH_C32(0x6b980000), SPH_C32(0xb0e60000), + SPH_C32(0xded97f6f), SPH_C32(0xbdd38a4e), SPH_C32(0xa0015246), + SPH_C32(0xa8d66697) }, + { SPH_C32(0x0f56014d), SPH_C32(0x8d6e8000), SPH_C32(0xae910000), + SPH_C32(0x96e70000), SPH_C32(0x3d61450f), SPH_C32(0xed3a2e98), + SPH_C32(0x5245a72f), SPH_C32(0xfd651f3e), SPH_C32(0x494501d5), + SPH_C32(0x43bb0000), SPH_C32(0x72640000), SPH_C32(0x263d0000), + SPH_C32(0xe4521292), SPH_C32(0x561924bd), SPH_C32(0x8c6c15c9), + SPH_C32(0x04580a1f) }, + { SPH_C32(0x7cb60140), SPH_C32(0x8aeec000), SPH_C32(0xf5130000), + SPH_C32(0xc1ba0000), SPH_C32(0xd80648da), SPH_C32(0x3d14e513), + SPH_C32(0x515c0cf3), SPH_C32(0xef2e92bd), SPH_C32(0x48b001d9), + SPH_C32(0xb8c40000), SPH_C32(0x95b50000), SPH_C32(0xad920000), + SPH_C32(0xc7f030c0), SPH_C32(0xa449c7a9), SPH_C32(0x3b2e6f9e), + SPH_C32(0x4ddb2834) }, + { SPH_C32(0x8a360145), SPH_C32(0xbead0000), SPH_C32(0xd1140000), + SPH_C32(0x4e870000), SPH_C32(0xf9317321), SPH_C32(0x37ac30bd), + SPH_C32(0x9c9987ea), SPH_C32(0x38bb288c), SPH_C32(0xeecf01d8), + SPH_C32(0xc9f38000), SPH_C32(0x8c490000), SPH_C32(0x3b490000), + SPH_C32(0xfd7b5d3d), SPH_C32(0x4f83695a), SPH_C32(0x17432811), + SPH_C32(0xe15544bc) }, + { SPH_C32(0xdac90141), SPH_C32(0xfbd94000), SPH_C32(0xecef0000), + SPH_C32(0x57610000), SPH_C32(0xe28d2527), SPH_C32(0xd6de4be0), + SPH_C32(0x7d314b7c), SPH_C32(0x43a0fe35), SPH_C32(0x184f01dd), + SPH_C32(0xfdb04000), SPH_C32(0xa84e0000), SPH_C32(0xb4740000), + SPH_C32(0xdc4c66c6), SPH_C32(0x453bbcf4), SPH_C32(0xda86a308), + SPH_C32(0x36c0fe8d) }, + { SPH_C32(0x2c490144), SPH_C32(0xcf9a8000), SPH_C32(0xc8e80000), + SPH_C32(0xd85c0000), SPH_C32(0xc3ba1edc), SPH_C32(0xdc669e4e), + SPH_C32(0xb0f4c065), SPH_C32(0x94354404), SPH_C32(0xbe3001dc), + SPH_C32(0x8c87c000), SPH_C32(0xb1b20000), SPH_C32(0x22af0000), + SPH_C32(0xe6c70b3b), SPH_C32(0xaef11207), SPH_C32(0xf6ebe487), + SPH_C32(0x9a4e9205) }, + { SPH_C32(0x8bc30149), SPH_C32(0x45d20000), SPH_C32(0x36c50000), + SPH_C32(0xc5280000), SPH_C32(0xda935173), SPH_C32(0xc5fcd3a9), + SPH_C32(0x2bdbfdbd), SPH_C32(0x71380aa7), SPH_C32(0x9cda01d9), + SPH_C32(0x350cc000), SPH_C32(0x301a0000), SPH_C32(0xe7bb0000), + SPH_C32(0x3bbe72ba), SPH_C32(0x6dfd41c5), SPH_C32(0xa318f99a), + SPH_C32(0xba9deb14) }, + { SPH_C32(0x7d43014c), SPH_C32(0x7191c000), SPH_C32(0x12c20000), + SPH_C32(0x4a150000), SPH_C32(0xfba46a88), SPH_C32(0xcf440607), + SPH_C32(0xe61e76a4), SPH_C32(0xa6adb096), SPH_C32(0x3aa501d8), + SPH_C32(0x443b4000), SPH_C32(0x29e60000), SPH_C32(0x71600000), + SPH_C32(0x01351f47), SPH_C32(0x8637ef36), SPH_C32(0x8f75be15), + SPH_C32(0x1613879c) }, + { SPH_C32(0x2dbc0148), SPH_C32(0x34e58000), SPH_C32(0x2f390000), + SPH_C32(0x53f30000), SPH_C32(0xe0183c8e), SPH_C32(0x2e367d5a), + SPH_C32(0x07b6ba32), SPH_C32(0xddb6662f), SPH_C32(0xcc2501dd), + SPH_C32(0x70788000), SPH_C32(0x0de10000), SPH_C32(0xfe5d0000), + SPH_C32(0x200224bc), SPH_C32(0x8c8f3a98), SPH_C32(0x42b0350c), + SPH_C32(0xc1863dad) }, + { SPH_C32(0xdb3c014d), SPH_C32(0x00a64000), SPH_C32(0x0b3e0000), + SPH_C32(0xdcce0000), SPH_C32(0xc12f0775), SPH_C32(0x248ea8f4), + SPH_C32(0xca73312b), SPH_C32(0x0a23dc1e), SPH_C32(0x6a5a01dc), + SPH_C32(0x014f0000), SPH_C32(0x141d0000), SPH_C32(0x68860000), + SPH_C32(0x1a894941), SPH_C32(0x6745946b), SPH_C32(0x6edd7283), + SPH_C32(0x6d085125) }, + { SPH_C32(0xdf9801b0), SPH_C32(0xf67c0000), SPH_C32(0xa50e0000), + SPH_C32(0xbf870000), SPH_C32(0xad7f742c), SPH_C32(0xae2b8f5a), + SPH_C32(0xc2a957e9), SPH_C32(0xd75f2456), SPH_C32(0x9fc30180), + SPH_C32(0x6c280000), SPH_C32(0xe7690000), SPH_C32(0xe0360000), + SPH_C32(0x7bbf15ab), SPH_C32(0xf3aa0966), SPH_C32(0x453b7806), + SPH_C32(0xaebf667a) }, + { SPH_C32(0x291801b5), SPH_C32(0xc23fc000), SPH_C32(0x81090000), + SPH_C32(0x30ba0000), SPH_C32(0x8c484fd7), SPH_C32(0xa4935af4), + SPH_C32(0x0f6cdcf0), SPH_C32(0x00ca9e67), SPH_C32(0x39bc0181), + SPH_C32(0x1d1f8000), SPH_C32(0xfe950000), SPH_C32(0x76ed0000), + SPH_C32(0x41347856), SPH_C32(0x1860a795), SPH_C32(0x69563f89), + SPH_C32(0x02310af2) }, + { SPH_C32(0x79e701b1), SPH_C32(0x874b8000), SPH_C32(0xbcf20000), + SPH_C32(0x295c0000), SPH_C32(0x97f419d1), SPH_C32(0x45e121a9), + SPH_C32(0xeec41066), SPH_C32(0x7bd148de), SPH_C32(0xcf3c0184), + SPH_C32(0x295c4000), SPH_C32(0xda920000), SPH_C32(0xf9d00000), + SPH_C32(0x600343ad), SPH_C32(0x12d8723b), SPH_C32(0xa493b490), + SPH_C32(0xd5a4b0c3) }, + { SPH_C32(0x8f6701b4), SPH_C32(0xb3084000), SPH_C32(0x98f50000), + SPH_C32(0xa6610000), SPH_C32(0xb6c3222a), SPH_C32(0x4f59f407), + SPH_C32(0x23019b7f), SPH_C32(0xac44f2ef), SPH_C32(0x69430185), + SPH_C32(0x586bc000), SPH_C32(0xc36e0000), SPH_C32(0x6f0b0000), + SPH_C32(0x5a882e50), SPH_C32(0xf912dcc8), SPH_C32(0x88fef31f), + SPH_C32(0x792adc4b) }, + { SPH_C32(0x28ed01b9), SPH_C32(0x3940c000), SPH_C32(0x66d80000), + SPH_C32(0xbb150000), SPH_C32(0xafea6d85), SPH_C32(0x56c3b9e0), + SPH_C32(0xb82ea6a7), SPH_C32(0x4949bc4c), SPH_C32(0x4ba90180), + SPH_C32(0xe1e0c000), SPH_C32(0x42c60000), SPH_C32(0xaa1f0000), + SPH_C32(0x87f157d1), SPH_C32(0x3a1e8f0a), SPH_C32(0xdd0dee02), + SPH_C32(0x59f9a55a) }, + { SPH_C32(0xde6d01bc), SPH_C32(0x0d030000), SPH_C32(0x42df0000), + SPH_C32(0x34280000), SPH_C32(0x8edd567e), SPH_C32(0x5c7b6c4e), + SPH_C32(0x75eb2dbe), SPH_C32(0x9edc067d), SPH_C32(0xedd60181), + SPH_C32(0x90d74000), SPH_C32(0x5b3a0000), SPH_C32(0x3cc40000), + SPH_C32(0xbd7a3a2c), SPH_C32(0xd1d421f9), SPH_C32(0xf160a98d), + SPH_C32(0xf577c9d2) }, + { SPH_C32(0x8e9201b8), SPH_C32(0x48774000), SPH_C32(0x7f240000), + SPH_C32(0x2dce0000), SPH_C32(0x95610078), SPH_C32(0xbd091713), + SPH_C32(0x9443e128), SPH_C32(0xe5c7d0c4), SPH_C32(0x1b560184), + SPH_C32(0xa4948000), SPH_C32(0x7f3d0000), SPH_C32(0xb3f90000), + SPH_C32(0x9c4d01d7), SPH_C32(0xdb6cf457), SPH_C32(0x3ca52294), + SPH_C32(0x22e273e3) }, + { SPH_C32(0x781201bd), SPH_C32(0x7c348000), SPH_C32(0x5b230000), + SPH_C32(0xa2f30000), SPH_C32(0xb4563b83), SPH_C32(0xb7b1c2bd), + SPH_C32(0x59866a31), SPH_C32(0x32526af5), SPH_C32(0xbd290185), + SPH_C32(0xd5a30000), SPH_C32(0x66c10000), SPH_C32(0x25220000), + SPH_C32(0xa6c66c2a), SPH_C32(0x30a65aa4), SPH_C32(0x10c8651b), + SPH_C32(0x8e6c1f6b) }, + { SPH_C32(0x0bf201b0), SPH_C32(0x7bb4c000), SPH_C32(0x00a10000), + SPH_C32(0xf5ae0000), SPH_C32(0x51313656), SPH_C32(0x679f0936), + SPH_C32(0x5a9fc1ed), SPH_C32(0x2019e776), SPH_C32(0xbcdc0189), + SPH_C32(0x2edc0000), SPH_C32(0x81100000), SPH_C32(0xae8d0000), + SPH_C32(0x85644e78), SPH_C32(0xc2f6b9b0), SPH_C32(0xa78a1f4c), + SPH_C32(0xc7ef3d40) }, + { SPH_C32(0xfd7201b5), SPH_C32(0x4ff70000), SPH_C32(0x24a60000), + SPH_C32(0x7a930000), SPH_C32(0x70060dad), SPH_C32(0x6d27dc98), + SPH_C32(0x975a4af4), SPH_C32(0xf78c5d47), SPH_C32(0x1aa30188), + SPH_C32(0x5feb8000), SPH_C32(0x98ec0000), SPH_C32(0x38560000), + SPH_C32(0xbfef2385), SPH_C32(0x293c1743), SPH_C32(0x8be758c3), + SPH_C32(0x6b6151c8) }, + { SPH_C32(0xad8d01b1), SPH_C32(0x0a834000), SPH_C32(0x195d0000), + SPH_C32(0x63750000), SPH_C32(0x6bba5bab), SPH_C32(0x8c55a7c5), + SPH_C32(0x76f28662), SPH_C32(0x8c978bfe), SPH_C32(0xec23018d), + SPH_C32(0x6ba84000), SPH_C32(0xbceb0000), SPH_C32(0xb76b0000), + SPH_C32(0x9ed8187e), SPH_C32(0x2384c2ed), SPH_C32(0x4622d3da), + SPH_C32(0xbcf4ebf9) }, + { SPH_C32(0x5b0d01b4), SPH_C32(0x3ec08000), SPH_C32(0x3d5a0000), + SPH_C32(0xec480000), SPH_C32(0x4a8d6050), SPH_C32(0x86ed726b), + SPH_C32(0xbb370d7b), SPH_C32(0x5b0231cf), SPH_C32(0x4a5c018c), + SPH_C32(0x1a9fc000), SPH_C32(0xa5170000), SPH_C32(0x21b00000), + SPH_C32(0xa4537583), SPH_C32(0xc84e6c1e), SPH_C32(0x6a4f9455), + SPH_C32(0x107a8771) }, + { SPH_C32(0xfc8701b9), SPH_C32(0xb4880000), SPH_C32(0xc3770000), + SPH_C32(0xf13c0000), SPH_C32(0x53a42fff), SPH_C32(0x9f773f8c), + SPH_C32(0x201830a3), SPH_C32(0xbe0f7f6c), SPH_C32(0x68b60189), + SPH_C32(0xa314c000), SPH_C32(0x24bf0000), SPH_C32(0xe4a40000), + SPH_C32(0x792a0c02), SPH_C32(0x0b423fdc), SPH_C32(0x3fbc8948), + SPH_C32(0x30a9fe60) }, + { SPH_C32(0x0a0701bc), SPH_C32(0x80cbc000), SPH_C32(0xe7700000), + SPH_C32(0x7e010000), SPH_C32(0x72931404), SPH_C32(0x95cfea22), + SPH_C32(0xedddbbba), SPH_C32(0x699ac55d), SPH_C32(0xcec90188), + SPH_C32(0xd2234000), SPH_C32(0x3d430000), SPH_C32(0x727f0000), + SPH_C32(0x43a161ff), SPH_C32(0xe088912f), SPH_C32(0x13d1cec7), + SPH_C32(0x9c2792e8) }, + { SPH_C32(0x5af801b8), SPH_C32(0xc5bf8000), SPH_C32(0xda8b0000), + SPH_C32(0x67e70000), SPH_C32(0x692f4202), SPH_C32(0x74bd917f), + SPH_C32(0x0c75772c), SPH_C32(0x128113e4), SPH_C32(0x3849018d), + SPH_C32(0xe6608000), SPH_C32(0x19440000), SPH_C32(0xfd420000), + SPH_C32(0x62965a04), SPH_C32(0xea304481), SPH_C32(0xde1445de), + SPH_C32(0x4bb228d9) }, + { SPH_C32(0xac7801bd), SPH_C32(0xf1fc4000), SPH_C32(0xfe8c0000), + SPH_C32(0xe8da0000), SPH_C32(0x481879f9), SPH_C32(0x7e0544d1), + SPH_C32(0xc1b0fc35), SPH_C32(0xc514a9d5), SPH_C32(0x9e36018c), + SPH_C32(0x97570000), SPH_C32(0x00b80000), SPH_C32(0x6b990000), + SPH_C32(0x581d37f9), SPH_C32(0x01faea72), SPH_C32(0xf2790251), + SPH_C32(0xe73c4451) } +}; + +static const sph_u32 T512_16[256][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x0c720000), SPH_C32(0x49e50f00), SPH_C32(0x42790000), + SPH_C32(0x5cea0000), SPH_C32(0x33aa301a), SPH_C32(0x15822514), + SPH_C32(0x95a34b7b), SPH_C32(0xb44b0090), SPH_C32(0xfe220000), + SPH_C32(0xa7580500), SPH_C32(0x25d10000), SPH_C32(0xf7600000), + SPH_C32(0x893178da), SPH_C32(0x1fd4f860), SPH_C32(0x4ed0a315), + SPH_C32(0xa123ff9f) }, + { SPH_C32(0xfe220000), SPH_C32(0xa7580500), SPH_C32(0x25d10000), + SPH_C32(0xf7600000), SPH_C32(0x893178da), SPH_C32(0x1fd4f860), + SPH_C32(0x4ed0a315), SPH_C32(0xa123ff9f), SPH_C32(0xf2500000), + SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), SPH_C32(0xab8a0000), + SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), SPH_C32(0xdb73e86e), + SPH_C32(0x1568ff0f) }, + { SPH_C32(0xf2500000), SPH_C32(0xeebd0a00), SPH_C32(0x67a80000), + SPH_C32(0xab8a0000), SPH_C32(0xba9b48c0), SPH_C32(0x0a56dd74), + SPH_C32(0xdb73e86e), SPH_C32(0x1568ff0f), SPH_C32(0x0c720000), + SPH_C32(0x49e50f00), SPH_C32(0x42790000), SPH_C32(0x5cea0000), + SPH_C32(0x33aa301a), SPH_C32(0x15822514), SPH_C32(0x95a34b7b), + SPH_C32(0xb44b0090) }, + { SPH_C32(0x45180000), SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), + SPH_C32(0x3b480000), SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), + SPH_C32(0x16bca6b0), SPH_C32(0xdf33f4df), SPH_C32(0xb83d0000), + SPH_C32(0x16710600), SPH_C32(0x379a0000), SPH_C32(0xf5b10000), + SPH_C32(0x228161ac), SPH_C32(0xae48f145), SPH_C32(0x66241616), + SPH_C32(0xc5c1eb3e) }, + { SPH_C32(0x496a0000), SPH_C32(0xec501800), SPH_C32(0xbb130000), + SPH_C32(0x67a20000), SPH_C32(0x2d662436), SPH_C32(0x3691b0c2), + SPH_C32(0x831fedcb), SPH_C32(0x6b78f44f), SPH_C32(0x461f0000), + SPH_C32(0xb1290300), SPH_C32(0x124b0000), SPH_C32(0x02d10000), + SPH_C32(0xabb01976), SPH_C32(0xb19c0925), SPH_C32(0x28f4b503), + SPH_C32(0x64e214a1) }, + { SPH_C32(0xbb3a0000), SPH_C32(0x02ed1200), SPH_C32(0xdcbb0000), + SPH_C32(0xcc280000), SPH_C32(0x97fd6cf6), SPH_C32(0x3cc76db6), + SPH_C32(0x586c05a5), SPH_C32(0x7e100b40), SPH_C32(0x4a6d0000), + SPH_C32(0xf8cc0c00), SPH_C32(0x50320000), SPH_C32(0x5e3b0000), + SPH_C32(0x981a296c), SPH_C32(0xa41e2c31), SPH_C32(0xbd57fe78), + SPH_C32(0xd0a91431) }, + { SPH_C32(0xb7480000), SPH_C32(0x4b081d00), SPH_C32(0x9ec20000), + SPH_C32(0x90c20000), SPH_C32(0xa4575cec), SPH_C32(0x294548a2), + SPH_C32(0xcdcf4ede), SPH_C32(0xca5b0bd0), SPH_C32(0xb44f0000), + SPH_C32(0x5f940900), SPH_C32(0x75e30000), SPH_C32(0xa95b0000), + SPH_C32(0x112b51b6), SPH_C32(0xbbcad451), SPH_C32(0xf3875d6d), + SPH_C32(0x718aebae) }, + { SPH_C32(0xb83d0000), SPH_C32(0x16710600), SPH_C32(0x379a0000), + SPH_C32(0xf5b10000), SPH_C32(0x228161ac), SPH_C32(0xae48f145), + SPH_C32(0x66241616), SPH_C32(0xc5c1eb3e), SPH_C32(0xfd250000), + SPH_C32(0xb3c41100), SPH_C32(0xcef00000), SPH_C32(0xcef90000), + SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), SPH_C32(0x7098b0a6), + SPH_C32(0x1af21fe1) }, + { SPH_C32(0xb44f0000), SPH_C32(0x5f940900), SPH_C32(0x75e30000), + SPH_C32(0xa95b0000), SPH_C32(0x112b51b6), SPH_C32(0xbbcad451), + SPH_C32(0xf3875d6d), SPH_C32(0x718aebae), SPH_C32(0x03070000), + SPH_C32(0x149c1400), SPH_C32(0xeb210000), SPH_C32(0x39990000), + SPH_C32(0xb57c0d5a), SPH_C32(0x928f9cf3), SPH_C32(0x3e4813b3), + SPH_C32(0xbbd1e07e) }, + { SPH_C32(0x461f0000), SPH_C32(0xb1290300), SPH_C32(0x124b0000), + SPH_C32(0x02d10000), SPH_C32(0xabb01976), SPH_C32(0xb19c0925), + SPH_C32(0x28f4b503), SPH_C32(0x64e214a1), SPH_C32(0x0f750000), + SPH_C32(0x5d791b00), SPH_C32(0xa9580000), SPH_C32(0x65730000), + SPH_C32(0x86d63d40), SPH_C32(0x870db9e7), SPH_C32(0xabeb58c8), + SPH_C32(0x0f9ae0ee) }, + { SPH_C32(0x4a6d0000), SPH_C32(0xf8cc0c00), SPH_C32(0x50320000), + SPH_C32(0x5e3b0000), SPH_C32(0x981a296c), SPH_C32(0xa41e2c31), + SPH_C32(0xbd57fe78), SPH_C32(0xd0a91431), SPH_C32(0xf1570000), + SPH_C32(0xfa211e00), SPH_C32(0x8c890000), SPH_C32(0x92130000), + SPH_C32(0x0fe7459a), SPH_C32(0x98d94187), SPH_C32(0xe53bfbdd), + SPH_C32(0xaeb91f71) }, + { SPH_C32(0xfd250000), SPH_C32(0xb3c41100), SPH_C32(0xcef00000), + SPH_C32(0xcef90000), SPH_C32(0x3c4d7580), SPH_C32(0x8d5b6493), + SPH_C32(0x7098b0a6), SPH_C32(0x1af21fe1), SPH_C32(0x45180000), + SPH_C32(0xa5b51700), SPH_C32(0xf96a0000), SPH_C32(0x3b480000), + SPH_C32(0x1ecc142c), SPH_C32(0x231395d6), SPH_C32(0x16bca6b0), + SPH_C32(0xdf33f4df) }, + { SPH_C32(0xf1570000), SPH_C32(0xfa211e00), SPH_C32(0x8c890000), + SPH_C32(0x92130000), SPH_C32(0x0fe7459a), SPH_C32(0x98d94187), + SPH_C32(0xe53bfbdd), SPH_C32(0xaeb91f71), SPH_C32(0xbb3a0000), + SPH_C32(0x02ed1200), SPH_C32(0xdcbb0000), SPH_C32(0xcc280000), + SPH_C32(0x97fd6cf6), SPH_C32(0x3cc76db6), SPH_C32(0x586c05a5), + SPH_C32(0x7e100b40) }, + { SPH_C32(0x03070000), SPH_C32(0x149c1400), SPH_C32(0xeb210000), + SPH_C32(0x39990000), SPH_C32(0xb57c0d5a), SPH_C32(0x928f9cf3), + SPH_C32(0x3e4813b3), SPH_C32(0xbbd1e07e), SPH_C32(0xb7480000), + SPH_C32(0x4b081d00), SPH_C32(0x9ec20000), SPH_C32(0x90c20000), + SPH_C32(0xa4575cec), SPH_C32(0x294548a2), SPH_C32(0xcdcf4ede), + SPH_C32(0xca5b0bd0) }, + { SPH_C32(0x0f750000), SPH_C32(0x5d791b00), SPH_C32(0xa9580000), + SPH_C32(0x65730000), SPH_C32(0x86d63d40), SPH_C32(0x870db9e7), + SPH_C32(0xabeb58c8), SPH_C32(0x0f9ae0ee), SPH_C32(0x496a0000), + SPH_C32(0xec501800), SPH_C32(0xbb130000), SPH_C32(0x67a20000), + SPH_C32(0x2d662436), SPH_C32(0x3691b0c2), SPH_C32(0x831fedcb), + SPH_C32(0x6b78f44f) }, + { SPH_C32(0x75a40000), SPH_C32(0xc28b2700), SPH_C32(0x94a40000), + SPH_C32(0x90f50000), SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), + SPH_C32(0x1767c483), SPH_C32(0xaedf667e), SPH_C32(0xd1660000), + SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), SPH_C32(0xf6940000), + SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), SPH_C32(0xb4431b17), + SPH_C32(0x857f3c2b) }, + { SPH_C32(0x79d60000), SPH_C32(0x8b6e2800), SPH_C32(0xd6dd0000), + SPH_C32(0xcc1f0000), SPH_C32(0xc8d267fa), SPH_C32(0x5c4c2eba), + SPH_C32(0x82c48ff8), SPH_C32(0x1a9466ee), SPH_C32(0x2f440000), + SPH_C32(0xbce40600), SPH_C32(0xbb3d0000), SPH_C32(0x01f40000), + SPH_C32(0x8a333dfd), SPH_C32(0xd0a40492), SPH_C32(0xfa93b802), + SPH_C32(0x245cc3b4) }, + { SPH_C32(0x8b860000), SPH_C32(0x65d32200), SPH_C32(0xb1750000), + SPH_C32(0x67950000), SPH_C32(0x72492f3a), SPH_C32(0x561af3ce), + SPH_C32(0x59b76796), SPH_C32(0x0ffc99e1), SPH_C32(0x23360000), + SPH_C32(0xf5010900), SPH_C32(0xf9440000), SPH_C32(0x5d1e0000), + SPH_C32(0xb9990de7), SPH_C32(0xc5262186), SPH_C32(0x6f30f379), + SPH_C32(0x9017c324) }, + { SPH_C32(0x87f40000), SPH_C32(0x2c362d00), SPH_C32(0xf30c0000), + SPH_C32(0x3b7f0000), SPH_C32(0x41e31f20), SPH_C32(0x4398d6da), + SPH_C32(0xcc142ced), SPH_C32(0xbbb79971), SPH_C32(0xdd140000), + SPH_C32(0x52590c00), SPH_C32(0xdc950000), SPH_C32(0xaa7e0000), + SPH_C32(0x30a8753d), SPH_C32(0xdaf2d9e6), SPH_C32(0x21e0506c), + SPH_C32(0x31343cbb) }, + { SPH_C32(0x30bc0000), SPH_C32(0x673e3000), SPH_C32(0x6dce0000), + SPH_C32(0xabbd0000), SPH_C32(0xe5b443cc), SPH_C32(0x6add9e78), + SPH_C32(0x01db6233), SPH_C32(0x71ec92a1), SPH_C32(0x695b0000), + SPH_C32(0x0dcd0500), SPH_C32(0xa9760000), SPH_C32(0x03250000), + SPH_C32(0x2183248b), SPH_C32(0x61380db7), SPH_C32(0xd2670d01), + SPH_C32(0x40bed715) }, + { SPH_C32(0x3cce0000), SPH_C32(0x2edb3f00), SPH_C32(0x2fb70000), + SPH_C32(0xf7570000), SPH_C32(0xd61e73d6), SPH_C32(0x7f5fbb6c), + SPH_C32(0x94782948), SPH_C32(0xc5a79231), SPH_C32(0x97790000), + SPH_C32(0xaa950000), SPH_C32(0x8ca70000), SPH_C32(0xf4450000), + SPH_C32(0xa8b25c51), SPH_C32(0x7eecf5d7), SPH_C32(0x9cb7ae14), + SPH_C32(0xe19d288a) }, + { SPH_C32(0xce9e0000), SPH_C32(0xc0663500), SPH_C32(0x481f0000), + SPH_C32(0x5cdd0000), SPH_C32(0x6c853b16), SPH_C32(0x75096618), + SPH_C32(0x4f0bc126), SPH_C32(0xd0cf6d3e), SPH_C32(0x9b0b0000), + SPH_C32(0xe3700f00), SPH_C32(0xcede0000), SPH_C32(0xa8af0000), + SPH_C32(0x9b186c4b), SPH_C32(0x6b6ed0c3), SPH_C32(0x0914e56f), + SPH_C32(0x55d6281a) }, + { SPH_C32(0xc2ec0000), SPH_C32(0x89833a00), SPH_C32(0x0a660000), + SPH_C32(0x00370000), SPH_C32(0x5f2f0b0c), SPH_C32(0x608b430c), + SPH_C32(0xdaa88a5d), SPH_C32(0x64846dae), SPH_C32(0x65290000), + SPH_C32(0x44280a00), SPH_C32(0xeb0f0000), SPH_C32(0x5fcf0000), + SPH_C32(0x12291491), SPH_C32(0x74ba28a3), SPH_C32(0x47c4467a), + SPH_C32(0xf4f5d785) }, + { SPH_C32(0xcd990000), SPH_C32(0xd4fa2100), SPH_C32(0xa33e0000), + SPH_C32(0x65440000), SPH_C32(0xd9f9364c), SPH_C32(0xe786faeb), + SPH_C32(0x7143d295), SPH_C32(0x6b1e8d40), SPH_C32(0x2c430000), + SPH_C32(0xa8781200), SPH_C32(0x501c0000), SPH_C32(0x386d0000), + SPH_C32(0x3f4f30a7), SPH_C32(0x422b9861), SPH_C32(0xc4dbabb1), + SPH_C32(0x9f8d23ca) }, + { SPH_C32(0xc1eb0000), SPH_C32(0x9d1f2e00), SPH_C32(0xe1470000), + SPH_C32(0x39ae0000), SPH_C32(0xea530656), SPH_C32(0xf204dfff), + SPH_C32(0xe4e099ee), SPH_C32(0xdf558dd0), SPH_C32(0xd2610000), + SPH_C32(0x0f201700), SPH_C32(0x75cd0000), SPH_C32(0xcf0d0000), + SPH_C32(0xb67e487d), SPH_C32(0x5dff6001), SPH_C32(0x8a0b08a4), + SPH_C32(0x3eaedc55) }, + { SPH_C32(0x33bb0000), SPH_C32(0x73a22400), SPH_C32(0x86ef0000), + SPH_C32(0x92240000), SPH_C32(0x50c84e96), SPH_C32(0xf852028b), + SPH_C32(0x3f937180), SPH_C32(0xca3d72df), SPH_C32(0xde130000), + SPH_C32(0x46c51800), SPH_C32(0x37b40000), SPH_C32(0x93e70000), + SPH_C32(0x85d47867), SPH_C32(0x487d4515), SPH_C32(0x1fa843df), + SPH_C32(0x8ae5dcc5) }, + { SPH_C32(0x3fc90000), SPH_C32(0x3a472b00), SPH_C32(0xc4960000), + SPH_C32(0xcece0000), SPH_C32(0x63627e8c), SPH_C32(0xedd0279f), + SPH_C32(0xaa303afb), SPH_C32(0x7e76724f), SPH_C32(0x20310000), + SPH_C32(0xe19d1d00), SPH_C32(0x12650000), SPH_C32(0x64870000), + SPH_C32(0x0ce500bd), SPH_C32(0x57a9bd75), SPH_C32(0x5178e0ca), + SPH_C32(0x2bc6235a) }, + { SPH_C32(0x88810000), SPH_C32(0x714f3600), SPH_C32(0x5a540000), + SPH_C32(0x5e0c0000), SPH_C32(0xc7352260), SPH_C32(0xc4956f3d), + SPH_C32(0x67ff7425), SPH_C32(0xb42d799f), SPH_C32(0x947e0000), + SPH_C32(0xbe091400), SPH_C32(0x67860000), SPH_C32(0xcddc0000), + SPH_C32(0x1dce510b), SPH_C32(0xec636924), SPH_C32(0xa2ffbda7), + SPH_C32(0x5a4cc8f4) }, + { SPH_C32(0x84f30000), SPH_C32(0x38aa3900), SPH_C32(0x182d0000), + SPH_C32(0x02e60000), SPH_C32(0xf49f127a), SPH_C32(0xd1174a29), + SPH_C32(0xf25c3f5e), SPH_C32(0x0066790f), SPH_C32(0x6a5c0000), + SPH_C32(0x19511100), SPH_C32(0x42570000), SPH_C32(0x3abc0000), + SPH_C32(0x94ff29d1), SPH_C32(0xf3b79144), SPH_C32(0xec2f1eb2), + SPH_C32(0xfb6f376b) }, + { SPH_C32(0x76a30000), SPH_C32(0xd6173300), SPH_C32(0x7f850000), + SPH_C32(0xa96c0000), SPH_C32(0x4e045aba), SPH_C32(0xdb41975d), + SPH_C32(0x292fd730), SPH_C32(0x150e8600), SPH_C32(0x662e0000), + SPH_C32(0x50b41e00), SPH_C32(0x002e0000), SPH_C32(0x66560000), + SPH_C32(0xa75519cb), SPH_C32(0xe635b450), SPH_C32(0x798c55c9), + SPH_C32(0x4f2437fb) }, + { SPH_C32(0x7ad10000), SPH_C32(0x9ff23c00), SPH_C32(0x3dfc0000), + SPH_C32(0xf5860000), SPH_C32(0x7dae6aa0), SPH_C32(0xcec3b249), + SPH_C32(0xbc8c9c4b), SPH_C32(0xa1458690), SPH_C32(0x980c0000), + SPH_C32(0xf7ec1b00), SPH_C32(0x25ff0000), SPH_C32(0x91360000), + SPH_C32(0x2e646111), SPH_C32(0xf9e14c30), SPH_C32(0x375cf6dc), + SPH_C32(0xee07c864) }, + { SPH_C32(0xd1660000), SPH_C32(0x1bbc0300), SPH_C32(0x9eec0000), + SPH_C32(0xf6940000), SPH_C32(0x03024527), SPH_C32(0xcf70fcf2), + SPH_C32(0xb4431b17), SPH_C32(0x857f3c2b), SPH_C32(0xa4c20000), + SPH_C32(0xd9372400), SPH_C32(0x0a480000), SPH_C32(0x66610000), + SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), SPH_C32(0xa324df94), + SPH_C32(0x2ba05a55) }, + { SPH_C32(0xdd140000), SPH_C32(0x52590c00), SPH_C32(0xdc950000), + SPH_C32(0xaa7e0000), SPH_C32(0x30a8753d), SPH_C32(0xdaf2d9e6), + SPH_C32(0x21e0506c), SPH_C32(0x31343cbb), SPH_C32(0x5ae00000), + SPH_C32(0x7e6f2100), SPH_C32(0x2f990000), SPH_C32(0x91010000), + SPH_C32(0x714b6a1d), SPH_C32(0x996a0f3c), SPH_C32(0xedf47c81), + SPH_C32(0x8a83a5ca) }, + { SPH_C32(0x2f440000), SPH_C32(0xbce40600), SPH_C32(0xbb3d0000), + SPH_C32(0x01f40000), SPH_C32(0x8a333dfd), SPH_C32(0xd0a40492), + SPH_C32(0xfa93b802), SPH_C32(0x245cc3b4), SPH_C32(0x56920000), + SPH_C32(0x378a2e00), SPH_C32(0x6de00000), SPH_C32(0xcdeb0000), + SPH_C32(0x42e15a07), SPH_C32(0x8ce82a28), SPH_C32(0x785737fa), + SPH_C32(0x3ec8a55a) }, + { SPH_C32(0x23360000), SPH_C32(0xf5010900), SPH_C32(0xf9440000), + SPH_C32(0x5d1e0000), SPH_C32(0xb9990de7), SPH_C32(0xc5262186), + SPH_C32(0x6f30f379), SPH_C32(0x9017c324), SPH_C32(0xa8b00000), + SPH_C32(0x90d22b00), SPH_C32(0x48310000), SPH_C32(0x3a8b0000), + SPH_C32(0xcbd022dd), SPH_C32(0x933cd248), SPH_C32(0x368794ef), + SPH_C32(0x9feb5ac5) }, + { SPH_C32(0x947e0000), SPH_C32(0xbe091400), SPH_C32(0x67860000), + SPH_C32(0xcddc0000), SPH_C32(0x1dce510b), SPH_C32(0xec636924), + SPH_C32(0xa2ffbda7), SPH_C32(0x5a4cc8f4), SPH_C32(0x1cff0000), + SPH_C32(0xcf462200), SPH_C32(0x3dd20000), SPH_C32(0x93d00000), + SPH_C32(0xdafb736b), SPH_C32(0x28f60619), SPH_C32(0xc500c982), + SPH_C32(0xee61b16b) }, + { SPH_C32(0x980c0000), SPH_C32(0xf7ec1b00), SPH_C32(0x25ff0000), + SPH_C32(0x91360000), SPH_C32(0x2e646111), SPH_C32(0xf9e14c30), + SPH_C32(0x375cf6dc), SPH_C32(0xee07c864), SPH_C32(0xe2dd0000), + SPH_C32(0x681e2700), SPH_C32(0x18030000), SPH_C32(0x64b00000), + SPH_C32(0x53ca0bb1), SPH_C32(0x3722fe79), SPH_C32(0x8bd06a97), + SPH_C32(0x4f424ef4) }, + { SPH_C32(0x6a5c0000), SPH_C32(0x19511100), SPH_C32(0x42570000), + SPH_C32(0x3abc0000), SPH_C32(0x94ff29d1), SPH_C32(0xf3b79144), + SPH_C32(0xec2f1eb2), SPH_C32(0xfb6f376b), SPH_C32(0xeeaf0000), + SPH_C32(0x21fb2800), SPH_C32(0x5a7a0000), SPH_C32(0x385a0000), + SPH_C32(0x60603bab), SPH_C32(0x22a0db6d), SPH_C32(0x1e7321ec), + SPH_C32(0xfb094e64) }, + { SPH_C32(0x662e0000), SPH_C32(0x50b41e00), SPH_C32(0x002e0000), + SPH_C32(0x66560000), SPH_C32(0xa75519cb), SPH_C32(0xe635b450), + SPH_C32(0x798c55c9), SPH_C32(0x4f2437fb), SPH_C32(0x108d0000), + SPH_C32(0x86a32d00), SPH_C32(0x7fab0000), SPH_C32(0xcf3a0000), + SPH_C32(0xe9514371), SPH_C32(0x3d74230d), SPH_C32(0x50a382f9), + SPH_C32(0x5a2ab1fb) }, + { SPH_C32(0x695b0000), SPH_C32(0x0dcd0500), SPH_C32(0xa9760000), + SPH_C32(0x03250000), SPH_C32(0x2183248b), SPH_C32(0x61380db7), + SPH_C32(0xd2670d01), SPH_C32(0x40bed715), SPH_C32(0x59e70000), + SPH_C32(0x6af33500), SPH_C32(0xc4b80000), SPH_C32(0xa8980000), + SPH_C32(0xc4376747), SPH_C32(0x0be593cf), SPH_C32(0xd3bc6f32), + SPH_C32(0x315245b4) }, + { SPH_C32(0x65290000), SPH_C32(0x44280a00), SPH_C32(0xeb0f0000), + SPH_C32(0x5fcf0000), SPH_C32(0x12291491), SPH_C32(0x74ba28a3), + SPH_C32(0x47c4467a), SPH_C32(0xf4f5d785), SPH_C32(0xa7c50000), + SPH_C32(0xcdab3000), SPH_C32(0xe1690000), SPH_C32(0x5ff80000), + SPH_C32(0x4d061f9d), SPH_C32(0x14316baf), SPH_C32(0x9d6ccc27), + SPH_C32(0x9071ba2b) }, + { SPH_C32(0x97790000), SPH_C32(0xaa950000), SPH_C32(0x8ca70000), + SPH_C32(0xf4450000), SPH_C32(0xa8b25c51), SPH_C32(0x7eecf5d7), + SPH_C32(0x9cb7ae14), SPH_C32(0xe19d288a), SPH_C32(0xabb70000), + SPH_C32(0x844e3f00), SPH_C32(0xa3100000), SPH_C32(0x03120000), + SPH_C32(0x7eac2f87), SPH_C32(0x01b34ebb), SPH_C32(0x08cf875c), + SPH_C32(0x243ababb) }, + { SPH_C32(0x9b0b0000), SPH_C32(0xe3700f00), SPH_C32(0xcede0000), + SPH_C32(0xa8af0000), SPH_C32(0x9b186c4b), SPH_C32(0x6b6ed0c3), + SPH_C32(0x0914e56f), SPH_C32(0x55d6281a), SPH_C32(0x55950000), + SPH_C32(0x23163a00), SPH_C32(0x86c10000), SPH_C32(0xf4720000), + SPH_C32(0xf79d575d), SPH_C32(0x1e67b6db), SPH_C32(0x461f2449), + SPH_C32(0x85194524) }, + { SPH_C32(0x2c430000), SPH_C32(0xa8781200), SPH_C32(0x501c0000), + SPH_C32(0x386d0000), SPH_C32(0x3f4f30a7), SPH_C32(0x422b9861), + SPH_C32(0xc4dbabb1), SPH_C32(0x9f8d23ca), SPH_C32(0xe1da0000), + SPH_C32(0x7c823300), SPH_C32(0xf3220000), SPH_C32(0x5d290000), + SPH_C32(0xe6b606eb), SPH_C32(0xa5ad628a), SPH_C32(0xb5987924), + SPH_C32(0xf493ae8a) }, + { SPH_C32(0x20310000), SPH_C32(0xe19d1d00), SPH_C32(0x12650000), + SPH_C32(0x64870000), SPH_C32(0x0ce500bd), SPH_C32(0x57a9bd75), + SPH_C32(0x5178e0ca), SPH_C32(0x2bc6235a), SPH_C32(0x1ff80000), + SPH_C32(0xdbda3600), SPH_C32(0xd6f30000), SPH_C32(0xaa490000), + SPH_C32(0x6f877e31), SPH_C32(0xba799aea), SPH_C32(0xfb48da31), + SPH_C32(0x55b05115) }, + { SPH_C32(0xd2610000), SPH_C32(0x0f201700), SPH_C32(0x75cd0000), + SPH_C32(0xcf0d0000), SPH_C32(0xb67e487d), SPH_C32(0x5dff6001), + SPH_C32(0x8a0b08a4), SPH_C32(0x3eaedc55), SPH_C32(0x138a0000), + SPH_C32(0x923f3900), SPH_C32(0x948a0000), SPH_C32(0xf6a30000), + SPH_C32(0x5c2d4e2b), SPH_C32(0xaffbbffe), SPH_C32(0x6eeb914a), + SPH_C32(0xe1fb5185) }, + { SPH_C32(0xde130000), SPH_C32(0x46c51800), SPH_C32(0x37b40000), + SPH_C32(0x93e70000), SPH_C32(0x85d47867), SPH_C32(0x487d4515), + SPH_C32(0x1fa843df), SPH_C32(0x8ae5dcc5), SPH_C32(0xeda80000), + SPH_C32(0x35673c00), SPH_C32(0xb15b0000), SPH_C32(0x01c30000), + SPH_C32(0xd51c36f1), SPH_C32(0xb02f479e), SPH_C32(0x203b325f), + SPH_C32(0x40d8ae1a) }, + { SPH_C32(0xa4c20000), SPH_C32(0xd9372400), SPH_C32(0x0a480000), + SPH_C32(0x66610000), SPH_C32(0xf87a12c7), SPH_C32(0x86bef75c), + SPH_C32(0xa324df94), SPH_C32(0x2ba05a55), SPH_C32(0x75a40000), + SPH_C32(0xc28b2700), SPH_C32(0x94a40000), SPH_C32(0x90f50000), + SPH_C32(0xfb7857e0), SPH_C32(0x49ce0bae), SPH_C32(0x1767c483), + SPH_C32(0xaedf667e) }, + { SPH_C32(0xa8b00000), SPH_C32(0x90d22b00), SPH_C32(0x48310000), + SPH_C32(0x3a8b0000), SPH_C32(0xcbd022dd), SPH_C32(0x933cd248), + SPH_C32(0x368794ef), SPH_C32(0x9feb5ac5), SPH_C32(0x8b860000), + SPH_C32(0x65d32200), SPH_C32(0xb1750000), SPH_C32(0x67950000), + SPH_C32(0x72492f3a), SPH_C32(0x561af3ce), SPH_C32(0x59b76796), + SPH_C32(0x0ffc99e1) }, + { SPH_C32(0x5ae00000), SPH_C32(0x7e6f2100), SPH_C32(0x2f990000), + SPH_C32(0x91010000), SPH_C32(0x714b6a1d), SPH_C32(0x996a0f3c), + SPH_C32(0xedf47c81), SPH_C32(0x8a83a5ca), SPH_C32(0x87f40000), + SPH_C32(0x2c362d00), SPH_C32(0xf30c0000), SPH_C32(0x3b7f0000), + SPH_C32(0x41e31f20), SPH_C32(0x4398d6da), SPH_C32(0xcc142ced), + SPH_C32(0xbbb79971) }, + { SPH_C32(0x56920000), SPH_C32(0x378a2e00), SPH_C32(0x6de00000), + SPH_C32(0xcdeb0000), SPH_C32(0x42e15a07), SPH_C32(0x8ce82a28), + SPH_C32(0x785737fa), SPH_C32(0x3ec8a55a), SPH_C32(0x79d60000), + SPH_C32(0x8b6e2800), SPH_C32(0xd6dd0000), SPH_C32(0xcc1f0000), + SPH_C32(0xc8d267fa), SPH_C32(0x5c4c2eba), SPH_C32(0x82c48ff8), + SPH_C32(0x1a9466ee) }, + { SPH_C32(0xe1da0000), SPH_C32(0x7c823300), SPH_C32(0xf3220000), + SPH_C32(0x5d290000), SPH_C32(0xe6b606eb), SPH_C32(0xa5ad628a), + SPH_C32(0xb5987924), SPH_C32(0xf493ae8a), SPH_C32(0xcd990000), + SPH_C32(0xd4fa2100), SPH_C32(0xa33e0000), SPH_C32(0x65440000), + SPH_C32(0xd9f9364c), SPH_C32(0xe786faeb), SPH_C32(0x7143d295), + SPH_C32(0x6b1e8d40) }, + { SPH_C32(0xeda80000), SPH_C32(0x35673c00), SPH_C32(0xb15b0000), + SPH_C32(0x01c30000), SPH_C32(0xd51c36f1), SPH_C32(0xb02f479e), + SPH_C32(0x203b325f), SPH_C32(0x40d8ae1a), SPH_C32(0x33bb0000), + SPH_C32(0x73a22400), SPH_C32(0x86ef0000), SPH_C32(0x92240000), + SPH_C32(0x50c84e96), SPH_C32(0xf852028b), SPH_C32(0x3f937180), + SPH_C32(0xca3d72df) }, + { SPH_C32(0x1ff80000), SPH_C32(0xdbda3600), SPH_C32(0xd6f30000), + SPH_C32(0xaa490000), SPH_C32(0x6f877e31), SPH_C32(0xba799aea), + SPH_C32(0xfb48da31), SPH_C32(0x55b05115), SPH_C32(0x3fc90000), + SPH_C32(0x3a472b00), SPH_C32(0xc4960000), SPH_C32(0xcece0000), + SPH_C32(0x63627e8c), SPH_C32(0xedd0279f), SPH_C32(0xaa303afb), + SPH_C32(0x7e76724f) }, + { SPH_C32(0x138a0000), SPH_C32(0x923f3900), SPH_C32(0x948a0000), + SPH_C32(0xf6a30000), SPH_C32(0x5c2d4e2b), SPH_C32(0xaffbbffe), + SPH_C32(0x6eeb914a), SPH_C32(0xe1fb5185), SPH_C32(0xc1eb0000), + SPH_C32(0x9d1f2e00), SPH_C32(0xe1470000), SPH_C32(0x39ae0000), + SPH_C32(0xea530656), SPH_C32(0xf204dfff), SPH_C32(0xe4e099ee), + SPH_C32(0xdf558dd0) }, + { SPH_C32(0x1cff0000), SPH_C32(0xcf462200), SPH_C32(0x3dd20000), + SPH_C32(0x93d00000), SPH_C32(0xdafb736b), SPH_C32(0x28f60619), + SPH_C32(0xc500c982), SPH_C32(0xee61b16b), SPH_C32(0x88810000), + SPH_C32(0x714f3600), SPH_C32(0x5a540000), SPH_C32(0x5e0c0000), + SPH_C32(0xc7352260), SPH_C32(0xc4956f3d), SPH_C32(0x67ff7425), + SPH_C32(0xb42d799f) }, + { SPH_C32(0x108d0000), SPH_C32(0x86a32d00), SPH_C32(0x7fab0000), + SPH_C32(0xcf3a0000), SPH_C32(0xe9514371), SPH_C32(0x3d74230d), + SPH_C32(0x50a382f9), SPH_C32(0x5a2ab1fb), SPH_C32(0x76a30000), + SPH_C32(0xd6173300), SPH_C32(0x7f850000), SPH_C32(0xa96c0000), + SPH_C32(0x4e045aba), SPH_C32(0xdb41975d), SPH_C32(0x292fd730), + SPH_C32(0x150e8600) }, + { SPH_C32(0xe2dd0000), SPH_C32(0x681e2700), SPH_C32(0x18030000), + SPH_C32(0x64b00000), SPH_C32(0x53ca0bb1), SPH_C32(0x3722fe79), + SPH_C32(0x8bd06a97), SPH_C32(0x4f424ef4), SPH_C32(0x7ad10000), + SPH_C32(0x9ff23c00), SPH_C32(0x3dfc0000), SPH_C32(0xf5860000), + SPH_C32(0x7dae6aa0), SPH_C32(0xcec3b249), SPH_C32(0xbc8c9c4b), + SPH_C32(0xa1458690) }, + { SPH_C32(0xeeaf0000), SPH_C32(0x21fb2800), SPH_C32(0x5a7a0000), + SPH_C32(0x385a0000), SPH_C32(0x60603bab), SPH_C32(0x22a0db6d), + SPH_C32(0x1e7321ec), SPH_C32(0xfb094e64), SPH_C32(0x84f30000), + SPH_C32(0x38aa3900), SPH_C32(0x182d0000), SPH_C32(0x02e60000), + SPH_C32(0xf49f127a), SPH_C32(0xd1174a29), SPH_C32(0xf25c3f5e), + SPH_C32(0x0066790f) }, + { SPH_C32(0x59e70000), SPH_C32(0x6af33500), SPH_C32(0xc4b80000), + SPH_C32(0xa8980000), SPH_C32(0xc4376747), SPH_C32(0x0be593cf), + SPH_C32(0xd3bc6f32), SPH_C32(0x315245b4), SPH_C32(0x30bc0000), + SPH_C32(0x673e3000), SPH_C32(0x6dce0000), SPH_C32(0xabbd0000), + SPH_C32(0xe5b443cc), SPH_C32(0x6add9e78), SPH_C32(0x01db6233), + SPH_C32(0x71ec92a1) }, + { SPH_C32(0x55950000), SPH_C32(0x23163a00), SPH_C32(0x86c10000), + SPH_C32(0xf4720000), SPH_C32(0xf79d575d), SPH_C32(0x1e67b6db), + SPH_C32(0x461f2449), SPH_C32(0x85194524), SPH_C32(0xce9e0000), + SPH_C32(0xc0663500), SPH_C32(0x481f0000), SPH_C32(0x5cdd0000), + SPH_C32(0x6c853b16), SPH_C32(0x75096618), SPH_C32(0x4f0bc126), + SPH_C32(0xd0cf6d3e) }, + { SPH_C32(0xa7c50000), SPH_C32(0xcdab3000), SPH_C32(0xe1690000), + SPH_C32(0x5ff80000), SPH_C32(0x4d061f9d), SPH_C32(0x14316baf), + SPH_C32(0x9d6ccc27), SPH_C32(0x9071ba2b), SPH_C32(0xc2ec0000), + SPH_C32(0x89833a00), SPH_C32(0x0a660000), SPH_C32(0x00370000), + SPH_C32(0x5f2f0b0c), SPH_C32(0x608b430c), SPH_C32(0xdaa88a5d), + SPH_C32(0x64846dae) }, + { SPH_C32(0xabb70000), SPH_C32(0x844e3f00), SPH_C32(0xa3100000), + SPH_C32(0x03120000), SPH_C32(0x7eac2f87), SPH_C32(0x01b34ebb), + SPH_C32(0x08cf875c), SPH_C32(0x243ababb), SPH_C32(0x3cce0000), + SPH_C32(0x2edb3f00), SPH_C32(0x2fb70000), SPH_C32(0xf7570000), + SPH_C32(0xd61e73d6), SPH_C32(0x7f5fbb6c), SPH_C32(0x94782948), + SPH_C32(0xc5a79231) }, + { SPH_C32(0x75c90003), SPH_C32(0x0e10c000), SPH_C32(0xd1200000), + SPH_C32(0xbaea0000), SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), + SPH_C32(0xbb28761d), SPH_C32(0x00b72e2b), SPH_C32(0xeecf0001), + SPH_C32(0x6f564000), SPH_C32(0xf33e0000), SPH_C32(0xa79e0000), + SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), SPH_C32(0x4a3b40ba), + SPH_C32(0xfeabf254) }, + { SPH_C32(0x79bb0003), SPH_C32(0x47f5cf00), SPH_C32(0x93590000), + SPH_C32(0xe6000000), SPH_C32(0xb86e1f24), SPH_C32(0x92da9243), + SPH_C32(0x2e8b3d66), SPH_C32(0xb4fc2ebb), SPH_C32(0x10ed0001), + SPH_C32(0xc80e4500), SPH_C32(0xd6ef0000), SPH_C32(0x50fe0000), + SPH_C32(0x34840ac3), SPH_C32(0xa8c513a5), SPH_C32(0x04ebe3af), + SPH_C32(0x5f880dcb) }, + { SPH_C32(0x8beb0003), SPH_C32(0xa948c500), SPH_C32(0xf4f10000), + SPH_C32(0x4d8a0000), SPH_C32(0x02f557e4), SPH_C32(0x988c4f37), + SPH_C32(0xf5f8d508), SPH_C32(0xa194d1b4), SPH_C32(0x1c9f0001), + SPH_C32(0x81eb4a00), SPH_C32(0x94960000), SPH_C32(0x0c140000), + SPH_C32(0x072e3ad9), SPH_C32(0xbd4736b1), SPH_C32(0x9148a8d4), + SPH_C32(0xebc30d5b) }, + { SPH_C32(0x87990003), SPH_C32(0xe0adca00), SPH_C32(0xb6880000), + SPH_C32(0x11600000), SPH_C32(0x315f67fe), SPH_C32(0x8d0e6a23), + SPH_C32(0x605b9e73), SPH_C32(0x15dfd124), SPH_C32(0xe2bd0001), + SPH_C32(0x26b34f00), SPH_C32(0xb1470000), SPH_C32(0xfb740000), + SPH_C32(0x8e1f4203), SPH_C32(0xa293ced1), SPH_C32(0xdf980bc1), + SPH_C32(0x4ae0f2c4) }, + { SPH_C32(0x30d10003), SPH_C32(0xaba5d700), SPH_C32(0x284a0000), + SPH_C32(0x81a20000), SPH_C32(0x95083b12), SPH_C32(0xa44b2281), + SPH_C32(0xad94d0ad), SPH_C32(0xdf84daf4), SPH_C32(0x56f20001), + SPH_C32(0x79274600), SPH_C32(0xc4a40000), SPH_C32(0x522f0000), + SPH_C32(0x9f3413b5), SPH_C32(0x19591a80), SPH_C32(0x2c1f56ac), + SPH_C32(0x3b6a196a) }, + { SPH_C32(0x3ca30003), SPH_C32(0xe240d800), SPH_C32(0x6a330000), + SPH_C32(0xdd480000), SPH_C32(0xa6a20b08), SPH_C32(0xb1c90795), + SPH_C32(0x38379bd6), SPH_C32(0x6bcfda64), SPH_C32(0xa8d00001), + SPH_C32(0xde7f4300), SPH_C32(0xe1750000), SPH_C32(0xa54f0000), + SPH_C32(0x16056b6f), SPH_C32(0x068de2e0), SPH_C32(0x62cff5b9), + SPH_C32(0x9a49e6f5) }, + { SPH_C32(0xcef30003), SPH_C32(0x0cfdd200), SPH_C32(0x0d9b0000), + SPH_C32(0x76c20000), SPH_C32(0x1c3943c8), SPH_C32(0xbb9fdae1), + SPH_C32(0xe34473b8), SPH_C32(0x7ea7256b), SPH_C32(0xa4a20001), + SPH_C32(0x979a4c00), SPH_C32(0xa30c0000), SPH_C32(0xf9a50000), + SPH_C32(0x25af5b75), SPH_C32(0x130fc7f4), SPH_C32(0xf76cbec2), + SPH_C32(0x2e02e665) }, + { SPH_C32(0xc2810003), SPH_C32(0x4518dd00), SPH_C32(0x4fe20000), + SPH_C32(0x2a280000), SPH_C32(0x2f9373d2), SPH_C32(0xae1dfff5), + SPH_C32(0x76e738c3), SPH_C32(0xcaec25fb), SPH_C32(0x5a800001), + SPH_C32(0x30c24900), SPH_C32(0x86dd0000), SPH_C32(0x0ec50000), + SPH_C32(0xac9e23af), SPH_C32(0x0cdb3f94), SPH_C32(0xb9bc1dd7), + SPH_C32(0x8f2119fa) }, + { SPH_C32(0xcdf40003), SPH_C32(0x1861c600), SPH_C32(0xe6ba0000), + SPH_C32(0x4f5b0000), SPH_C32(0xa9454e92), SPH_C32(0x29104612), + SPH_C32(0xdd0c600b), SPH_C32(0xc576c515), SPH_C32(0x13ea0001), + SPH_C32(0xdc925100), SPH_C32(0x3dce0000), SPH_C32(0x69670000), + SPH_C32(0x81f80799), SPH_C32(0x3a4a8f56), SPH_C32(0x3aa3f01c), + SPH_C32(0xe459edb5) }, + { SPH_C32(0xc1860003), SPH_C32(0x5184c900), SPH_C32(0xa4c30000), + SPH_C32(0x13b10000), SPH_C32(0x9aef7e88), SPH_C32(0x3c926306), + SPH_C32(0x48af2b70), SPH_C32(0x713dc585), SPH_C32(0xedc80001), + SPH_C32(0x7bca5400), SPH_C32(0x181f0000), SPH_C32(0x9e070000), + SPH_C32(0x08c97f43), SPH_C32(0x259e7736), SPH_C32(0x74735309), + SPH_C32(0x457a122a) }, + { SPH_C32(0x33d60003), SPH_C32(0xbf39c300), SPH_C32(0xc36b0000), + SPH_C32(0xb83b0000), SPH_C32(0x20743648), SPH_C32(0x36c4be72), + SPH_C32(0x93dcc31e), SPH_C32(0x64553a8a), SPH_C32(0xe1ba0001), + SPH_C32(0x322f5b00), SPH_C32(0x5a660000), SPH_C32(0xc2ed0000), + SPH_C32(0x3b634f59), SPH_C32(0x301c5222), SPH_C32(0xe1d01872), + SPH_C32(0xf13112ba) }, + { SPH_C32(0x3fa40003), SPH_C32(0xf6dccc00), SPH_C32(0x81120000), + SPH_C32(0xe4d10000), SPH_C32(0x13de0652), SPH_C32(0x23469b66), + SPH_C32(0x067f8865), SPH_C32(0xd01e3a1a), SPH_C32(0x1f980001), + SPH_C32(0x95775e00), SPH_C32(0x7fb70000), SPH_C32(0x358d0000), + SPH_C32(0xb2523783), SPH_C32(0x2fc8aa42), SPH_C32(0xaf00bb67), + SPH_C32(0x5012ed25) }, + { SPH_C32(0x88ec0003), SPH_C32(0xbdd4d100), SPH_C32(0x1fd00000), + SPH_C32(0x74130000), SPH_C32(0xb7895abe), SPH_C32(0x0a03d3c4), + SPH_C32(0xcbb0c6bb), SPH_C32(0x1a4531ca), SPH_C32(0xabd70001), + SPH_C32(0xcae35700), SPH_C32(0x0a540000), SPH_C32(0x9cd60000), + SPH_C32(0xa3796635), SPH_C32(0x94027e13), SPH_C32(0x5c87e60a), + SPH_C32(0x2198068b) }, + { SPH_C32(0x849e0003), SPH_C32(0xf431de00), SPH_C32(0x5da90000), + SPH_C32(0x28f90000), SPH_C32(0x84236aa4), SPH_C32(0x1f81f6d0), + SPH_C32(0x5e138dc0), SPH_C32(0xae0e315a), SPH_C32(0x55f50001), + SPH_C32(0x6dbb5200), SPH_C32(0x2f850000), SPH_C32(0x6bb60000), + SPH_C32(0x2a481eef), SPH_C32(0x8bd68673), SPH_C32(0x1257451f), + SPH_C32(0x80bbf914) }, + { SPH_C32(0x76ce0003), SPH_C32(0x1a8cd400), SPH_C32(0x3a010000), + SPH_C32(0x83730000), SPH_C32(0x3eb82264), SPH_C32(0x15d72ba4), + SPH_C32(0x856065ae), SPH_C32(0xbb66ce55), SPH_C32(0x59870001), + SPH_C32(0x245e5d00), SPH_C32(0x6dfc0000), SPH_C32(0x375c0000), + SPH_C32(0x19e22ef5), SPH_C32(0x9e54a367), SPH_C32(0x87f40e64), + SPH_C32(0x34f0f984) }, + { SPH_C32(0x7abc0003), SPH_C32(0x5369db00), SPH_C32(0x78780000), + SPH_C32(0xdf990000), SPH_C32(0x0d12127e), SPH_C32(0x00550eb0), + SPH_C32(0x10c32ed5), SPH_C32(0x0f2dcec5), SPH_C32(0xa7a50001), + SPH_C32(0x83065800), SPH_C32(0x482d0000), SPH_C32(0xc03c0000), + SPH_C32(0x90d3562f), SPH_C32(0x81805b07), SPH_C32(0xc924ad71), + SPH_C32(0x95d3061b) }, + { SPH_C32(0x006d0003), SPH_C32(0xcc9be700), SPH_C32(0x45840000), + SPH_C32(0x2a1f0000), SPH_C32(0x70bc78de), SPH_C32(0xce96bcf9), + SPH_C32(0xac4fb29e), SPH_C32(0xae684855), SPH_C32(0x3fa90001), + SPH_C32(0x74ea4300), SPH_C32(0x6dd20000), SPH_C32(0x510a0000), + SPH_C32(0xbeb7373e), SPH_C32(0x78611737), SPH_C32(0xfe785bad), + SPH_C32(0x7bd4ce7f) }, + { SPH_C32(0x0c1f0003), SPH_C32(0x857ee800), SPH_C32(0x07fd0000), + SPH_C32(0x76f50000), SPH_C32(0x431648c4), SPH_C32(0xdb1499ed), + SPH_C32(0x39ecf9e5), SPH_C32(0x1a2348c5), SPH_C32(0xc18b0001), + SPH_C32(0xd3b24600), SPH_C32(0x48030000), SPH_C32(0xa66a0000), + SPH_C32(0x37864fe4), SPH_C32(0x67b5ef57), SPH_C32(0xb0a8f8b8), + SPH_C32(0xdaf731e0) }, + { SPH_C32(0xfe4f0003), SPH_C32(0x6bc3e200), SPH_C32(0x60550000), + SPH_C32(0xdd7f0000), SPH_C32(0xf98d0004), SPH_C32(0xd1424499), + SPH_C32(0xe29f118b), SPH_C32(0x0f4bb7ca), SPH_C32(0xcdf90001), + SPH_C32(0x9a574900), SPH_C32(0x0a7a0000), SPH_C32(0xfa800000), + SPH_C32(0x042c7ffe), SPH_C32(0x7237ca43), SPH_C32(0x250bb3c3), + SPH_C32(0x6ebc3170) }, + { SPH_C32(0xf23d0003), SPH_C32(0x2226ed00), SPH_C32(0x222c0000), + SPH_C32(0x81950000), SPH_C32(0xca27301e), SPH_C32(0xc4c0618d), + SPH_C32(0x773c5af0), SPH_C32(0xbb00b75a), SPH_C32(0x33db0001), + SPH_C32(0x3d0f4c00), SPH_C32(0x2fab0000), SPH_C32(0x0de00000), + SPH_C32(0x8d1d0724), SPH_C32(0x6de33223), SPH_C32(0x6bdb10d6), + SPH_C32(0xcf9fceef) }, + { SPH_C32(0x45750003), SPH_C32(0x692ef000), SPH_C32(0xbcee0000), + SPH_C32(0x11570000), SPH_C32(0x6e706cf2), SPH_C32(0xed85292f), + SPH_C32(0xbaf3142e), SPH_C32(0x715bbc8a), SPH_C32(0x87940001), + SPH_C32(0x629b4500), SPH_C32(0x5a480000), SPH_C32(0xa4bb0000), + SPH_C32(0x9c365692), SPH_C32(0xd629e672), SPH_C32(0x985c4dbb), + SPH_C32(0xbe152541) }, + { SPH_C32(0x49070003), SPH_C32(0x20cbff00), SPH_C32(0xfe970000), + SPH_C32(0x4dbd0000), SPH_C32(0x5dda5ce8), SPH_C32(0xf8070c3b), + SPH_C32(0x2f505f55), SPH_C32(0xc510bc1a), SPH_C32(0x79b60001), + SPH_C32(0xc5c34000), SPH_C32(0x7f990000), SPH_C32(0x53db0000), + SPH_C32(0x15072e48), SPH_C32(0xc9fd1e12), SPH_C32(0xd68ceeae), + SPH_C32(0x1f36dade) }, + { SPH_C32(0xbb570003), SPH_C32(0xce76f500), SPH_C32(0x993f0000), + SPH_C32(0xe6370000), SPH_C32(0xe7411428), SPH_C32(0xf251d14f), + SPH_C32(0xf423b73b), SPH_C32(0xd0784315), SPH_C32(0x75c40001), + SPH_C32(0x8c264f00), SPH_C32(0x3de00000), SPH_C32(0x0f310000), + SPH_C32(0x26ad1e52), SPH_C32(0xdc7f3b06), SPH_C32(0x432fa5d5), + SPH_C32(0xab7dda4e) }, + { SPH_C32(0xb7250003), SPH_C32(0x8793fa00), SPH_C32(0xdb460000), + SPH_C32(0xbadd0000), SPH_C32(0xd4eb2432), SPH_C32(0xe7d3f45b), + SPH_C32(0x6180fc40), SPH_C32(0x64334385), SPH_C32(0x8be60001), + SPH_C32(0x2b7e4a00), SPH_C32(0x18310000), SPH_C32(0xf8510000), + SPH_C32(0xaf9c6688), SPH_C32(0xc3abc366), SPH_C32(0x0dff06c0), + SPH_C32(0x0a5e25d1) }, + { SPH_C32(0xb8500003), SPH_C32(0xdaeae100), SPH_C32(0x721e0000), + SPH_C32(0xdfae0000), SPH_C32(0x523d1972), SPH_C32(0x60de4dbc), + SPH_C32(0xca6ba488), SPH_C32(0x6ba9a36b), SPH_C32(0xc28c0001), + SPH_C32(0xc72e5200), SPH_C32(0xa3220000), SPH_C32(0x9ff30000), + SPH_C32(0x82fa42be), SPH_C32(0xf53a73a4), SPH_C32(0x8ee0eb0b), + SPH_C32(0x6126d19e) }, + { SPH_C32(0xb4220003), SPH_C32(0x930fee00), SPH_C32(0x30670000), + SPH_C32(0x83440000), SPH_C32(0x61972968), SPH_C32(0x755c68a8), + SPH_C32(0x5fc8eff3), SPH_C32(0xdfe2a3fb), SPH_C32(0x3cae0001), + SPH_C32(0x60765700), SPH_C32(0x86f30000), SPH_C32(0x68930000), + SPH_C32(0x0bcb3a64), SPH_C32(0xeaee8bc4), SPH_C32(0xc030481e), + SPH_C32(0xc0052e01) }, + { SPH_C32(0x46720003), SPH_C32(0x7db2e400), SPH_C32(0x57cf0000), + SPH_C32(0x28ce0000), SPH_C32(0xdb0c61a8), SPH_C32(0x7f0ab5dc), + SPH_C32(0x84bb079d), SPH_C32(0xca8a5cf4), SPH_C32(0x30dc0001), + SPH_C32(0x29935800), SPH_C32(0xc48a0000), SPH_C32(0x34790000), + SPH_C32(0x38610a7e), SPH_C32(0xff6caed0), SPH_C32(0x55930365), + SPH_C32(0x744e2e91) }, + { SPH_C32(0x4a000003), SPH_C32(0x3457eb00), SPH_C32(0x15b60000), + SPH_C32(0x74240000), SPH_C32(0xe8a651b2), SPH_C32(0x6a8890c8), + SPH_C32(0x11184ce6), SPH_C32(0x7ec15c64), SPH_C32(0xcefe0001), + SPH_C32(0x8ecb5d00), SPH_C32(0xe15b0000), SPH_C32(0xc3190000), + SPH_C32(0xb15072a4), SPH_C32(0xe0b856b0), SPH_C32(0x1b43a070), + SPH_C32(0xd56dd10e) }, + { SPH_C32(0xfd480003), SPH_C32(0x7f5ff600), SPH_C32(0x8b740000), + SPH_C32(0xe4e60000), SPH_C32(0x4cf10d5e), SPH_C32(0x43cdd86a), + SPH_C32(0xdcd70238), SPH_C32(0xb49a57b4), SPH_C32(0x7ab10001), + SPH_C32(0xd15f5400), SPH_C32(0x94b80000), SPH_C32(0x6a420000), + SPH_C32(0xa07b2312), SPH_C32(0x5b7282e1), SPH_C32(0xe8c4fd1d), + SPH_C32(0xa4e73aa0) }, + { SPH_C32(0xf13a0003), SPH_C32(0x36baf900), SPH_C32(0xc90d0000), + SPH_C32(0xb80c0000), SPH_C32(0x7f5b3d44), SPH_C32(0x564ffd7e), + SPH_C32(0x49744943), SPH_C32(0x00d15724), SPH_C32(0x84930001), + SPH_C32(0x76075100), SPH_C32(0xb1690000), SPH_C32(0x9d220000), + SPH_C32(0x294a5bc8), SPH_C32(0x44a67a81), SPH_C32(0xa6145e08), + SPH_C32(0x05c4c53f) }, + { SPH_C32(0x036a0003), SPH_C32(0xd807f300), SPH_C32(0xaea50000), + SPH_C32(0x13860000), SPH_C32(0xc5c07584), SPH_C32(0x5c19200a), + SPH_C32(0x9207a12d), SPH_C32(0x15b9a82b), SPH_C32(0x88e10001), + SPH_C32(0x3fe25e00), SPH_C32(0xf3100000), SPH_C32(0xc1c80000), + SPH_C32(0x1ae06bd2), SPH_C32(0x51245f95), SPH_C32(0x33b71573), + SPH_C32(0xb18fc5af) }, + { SPH_C32(0x0f180003), SPH_C32(0x91e2fc00), SPH_C32(0xecdc0000), + SPH_C32(0x4f6c0000), SPH_C32(0xf66a459e), SPH_C32(0x499b051e), + SPH_C32(0x07a4ea56), SPH_C32(0xa1f2a8bb), SPH_C32(0x76c30001), + SPH_C32(0x98ba5b00), SPH_C32(0xd6c10000), SPH_C32(0x36a80000), + SPH_C32(0x93d11308), SPH_C32(0x4ef0a7f5), SPH_C32(0x7d67b666), + SPH_C32(0x10ac3a30) }, + { SPH_C32(0xa4af0003), SPH_C32(0x15acc300), SPH_C32(0x4fcc0000), + SPH_C32(0x4c7e0000), SPH_C32(0x88c66a19), SPH_C32(0x48284ba5), + SPH_C32(0x0f6b6d0a), SPH_C32(0x85c81200), SPH_C32(0x4a0d0001), + SPH_C32(0xb6616400), SPH_C32(0xf9760000), SPH_C32(0xc1ff0000), + SPH_C32(0x45cf60de), SPH_C32(0x31af1c99), SPH_C32(0xe91f9f2e), + SPH_C32(0xd50ba801) }, + { SPH_C32(0xa8dd0003), SPH_C32(0x5c49cc00), SPH_C32(0x0db50000), + SPH_C32(0x10940000), SPH_C32(0xbb6c5a03), SPH_C32(0x5daa6eb1), + SPH_C32(0x9ac82671), SPH_C32(0x31831290), SPH_C32(0xb42f0001), + SPH_C32(0x11396100), SPH_C32(0xdca70000), SPH_C32(0x369f0000), + SPH_C32(0xccfe1804), SPH_C32(0x2e7be4f9), SPH_C32(0xa7cf3c3b), + SPH_C32(0x7428579e) }, + { SPH_C32(0x5a8d0003), SPH_C32(0xb2f4c600), SPH_C32(0x6a1d0000), + SPH_C32(0xbb1e0000), SPH_C32(0x01f712c3), SPH_C32(0x57fcb3c5), + SPH_C32(0x41bbce1f), SPH_C32(0x24ebed9f), SPH_C32(0xb85d0001), + SPH_C32(0x58dc6e00), SPH_C32(0x9ede0000), SPH_C32(0x6a750000), + SPH_C32(0xff54281e), SPH_C32(0x3bf9c1ed), SPH_C32(0x326c7740), + SPH_C32(0xc063570e) }, + { SPH_C32(0x56ff0003), SPH_C32(0xfb11c900), SPH_C32(0x28640000), + SPH_C32(0xe7f40000), SPH_C32(0x325d22d9), SPH_C32(0x427e96d1), + SPH_C32(0xd4188564), SPH_C32(0x90a0ed0f), SPH_C32(0x467f0001), + SPH_C32(0xff846b00), SPH_C32(0xbb0f0000), SPH_C32(0x9d150000), + SPH_C32(0x766550c4), SPH_C32(0x242d398d), SPH_C32(0x7cbcd455), + SPH_C32(0x6140a891) }, + { SPH_C32(0xe1b70003), SPH_C32(0xb019d400), SPH_C32(0xb6a60000), + SPH_C32(0x77360000), SPH_C32(0x960a7e35), SPH_C32(0x6b3bde73), + SPH_C32(0x19d7cbba), SPH_C32(0x5afbe6df), SPH_C32(0xf2300001), + SPH_C32(0xa0106200), SPH_C32(0xceec0000), SPH_C32(0x344e0000), + SPH_C32(0x674e0172), SPH_C32(0x9fe7eddc), SPH_C32(0x8f3b8938), + SPH_C32(0x10ca433f) }, + { SPH_C32(0xedc50003), SPH_C32(0xf9fcdb00), SPH_C32(0xf4df0000), + SPH_C32(0x2bdc0000), SPH_C32(0xa5a04e2f), SPH_C32(0x7eb9fb67), + SPH_C32(0x8c7480c1), SPH_C32(0xeeb0e64f), SPH_C32(0x0c120001), + SPH_C32(0x07486700), SPH_C32(0xeb3d0000), SPH_C32(0xc32e0000), + SPH_C32(0xee7f79a8), SPH_C32(0x803315bc), SPH_C32(0xc1eb2a2d), + SPH_C32(0xb1e9bca0) }, + { SPH_C32(0x1f950003), SPH_C32(0x1741d100), SPH_C32(0x93770000), + SPH_C32(0x80560000), SPH_C32(0x1f3b06ef), SPH_C32(0x74ef2613), + SPH_C32(0x570768af), SPH_C32(0xfbd81940), SPH_C32(0x00600001), + SPH_C32(0x4ead6800), SPH_C32(0xa9440000), SPH_C32(0x9fc40000), + SPH_C32(0xddd549b2), SPH_C32(0x95b130a8), SPH_C32(0x54486156), + SPH_C32(0x05a2bc30) }, + { SPH_C32(0x13e70003), SPH_C32(0x5ea4de00), SPH_C32(0xd10e0000), + SPH_C32(0xdcbc0000), SPH_C32(0x2c9136f5), SPH_C32(0x616d0307), + SPH_C32(0xc2a423d4), SPH_C32(0x4f9319d0), SPH_C32(0xfe420001), + SPH_C32(0xe9f56d00), SPH_C32(0x8c950000), SPH_C32(0x68a40000), + SPH_C32(0x54e43168), SPH_C32(0x8a65c8c8), SPH_C32(0x1a98c243), + SPH_C32(0xa48143af) }, + { SPH_C32(0x1c920003), SPH_C32(0x03ddc500), SPH_C32(0x78560000), + SPH_C32(0xb9cf0000), SPH_C32(0xaa470bb5), SPH_C32(0xe660bae0), + SPH_C32(0x694f7b1c), SPH_C32(0x4009f93e), SPH_C32(0xb7280001), + SPH_C32(0x05a57500), SPH_C32(0x37860000), SPH_C32(0x0f060000), + SPH_C32(0x7982155e), SPH_C32(0xbcf4780a), SPH_C32(0x99872f88), + SPH_C32(0xcff9b7e0) }, + { SPH_C32(0x10e00003), SPH_C32(0x4a38ca00), SPH_C32(0x3a2f0000), + SPH_C32(0xe5250000), SPH_C32(0x99ed3baf), SPH_C32(0xf3e29ff4), + SPH_C32(0xfcec3067), SPH_C32(0xf442f9ae), SPH_C32(0x490a0001), + SPH_C32(0xa2fd7000), SPH_C32(0x12570000), SPH_C32(0xf8660000), + SPH_C32(0xf0b36d84), SPH_C32(0xa320806a), SPH_C32(0xd7578c9d), + SPH_C32(0x6eda487f) }, + { SPH_C32(0xe2b00003), SPH_C32(0xa485c000), SPH_C32(0x5d870000), + SPH_C32(0x4eaf0000), SPH_C32(0x2376736f), SPH_C32(0xf9b44280), + SPH_C32(0x279fd809), SPH_C32(0xe12a06a1), SPH_C32(0x45780001), + SPH_C32(0xeb187f00), SPH_C32(0x502e0000), SPH_C32(0xa48c0000), + SPH_C32(0xc3195d9e), SPH_C32(0xb6a2a57e), SPH_C32(0x42f4c7e6), + SPH_C32(0xda9148ef) }, + { SPH_C32(0xeec20003), SPH_C32(0xed60cf00), SPH_C32(0x1ffe0000), + SPH_C32(0x12450000), SPH_C32(0x10dc4375), SPH_C32(0xec366794), + SPH_C32(0xb23c9372), SPH_C32(0x55610631), SPH_C32(0xbb5a0001), + SPH_C32(0x4c407a00), SPH_C32(0x75ff0000), SPH_C32(0x53ec0000), + SPH_C32(0x4a282544), SPH_C32(0xa9765d1e), SPH_C32(0x0c2464f3), + SPH_C32(0x7bb2b770) }, + { SPH_C32(0x598a0003), SPH_C32(0xa668d200), SPH_C32(0x813c0000), + SPH_C32(0x82870000), SPH_C32(0xb48b1f99), SPH_C32(0xc5732f36), + SPH_C32(0x7ff3ddac), SPH_C32(0x9f3a0de1), SPH_C32(0x0f150001), + SPH_C32(0x13d47300), SPH_C32(0x001c0000), SPH_C32(0xfab70000), + SPH_C32(0x5b0374f2), SPH_C32(0x12bc894f), SPH_C32(0xffa3399e), + SPH_C32(0x0a385cde) }, + { SPH_C32(0x55f80003), SPH_C32(0xef8ddd00), SPH_C32(0xc3450000), + SPH_C32(0xde6d0000), SPH_C32(0x87212f83), SPH_C32(0xd0f10a22), + SPH_C32(0xea5096d7), SPH_C32(0x2b710d71), SPH_C32(0xf1370001), + SPH_C32(0xb48c7600), SPH_C32(0x25cd0000), SPH_C32(0x0dd70000), + SPH_C32(0xd2320c28), SPH_C32(0x0d68712f), SPH_C32(0xb1739a8b), + SPH_C32(0xab1ba341) }, + { SPH_C32(0xa7a80003), SPH_C32(0x0130d700), SPH_C32(0xa4ed0000), + SPH_C32(0x75e70000), SPH_C32(0x3dba6743), SPH_C32(0xdaa7d756), + SPH_C32(0x31237eb9), SPH_C32(0x3e19f27e), SPH_C32(0xfd450001), + SPH_C32(0xfd697900), SPH_C32(0x67b40000), SPH_C32(0x513d0000), + SPH_C32(0xe1983c32), SPH_C32(0x18ea543b), SPH_C32(0x24d0d1f0), + SPH_C32(0x1f50a3d1) }, + { SPH_C32(0xabda0003), SPH_C32(0x48d5d800), SPH_C32(0xe6940000), + SPH_C32(0x290d0000), SPH_C32(0x0e105759), SPH_C32(0xcf25f242), + SPH_C32(0xa48035c2), SPH_C32(0x8a52f2ee), SPH_C32(0x03670001), + SPH_C32(0x5a317c00), SPH_C32(0x42650000), SPH_C32(0xa65d0000), + SPH_C32(0x68a944e8), SPH_C32(0x073eac5b), SPH_C32(0x6a0072e5), + SPH_C32(0xbe735c4e) }, + { SPH_C32(0xd10b0003), SPH_C32(0xd727e400), SPH_C32(0xdb680000), + SPH_C32(0xdc8b0000), SPH_C32(0x73be3df9), SPH_C32(0x01e6400b), + SPH_C32(0x180ca989), SPH_C32(0x2b17747e), SPH_C32(0x9b6b0001), + SPH_C32(0xaddd6700), SPH_C32(0x679a0000), SPH_C32(0x376b0000), + SPH_C32(0x46cd25f9), SPH_C32(0xfedfe06b), SPH_C32(0x5d5c8439), + SPH_C32(0x5074942a) }, + { SPH_C32(0xdd790003), SPH_C32(0x9ec2eb00), SPH_C32(0x99110000), + SPH_C32(0x80610000), SPH_C32(0x40140de3), SPH_C32(0x1464651f), + SPH_C32(0x8dafe2f2), SPH_C32(0x9f5c74ee), SPH_C32(0x65490001), + SPH_C32(0x0a856200), SPH_C32(0x424b0000), SPH_C32(0xc00b0000), + SPH_C32(0xcffc5d23), SPH_C32(0xe10b180b), SPH_C32(0x138c272c), + SPH_C32(0xf1576bb5) }, + { SPH_C32(0x2f290003), SPH_C32(0x707fe100), SPH_C32(0xfeb90000), + SPH_C32(0x2beb0000), SPH_C32(0xfa8f4523), SPH_C32(0x1e32b86b), + SPH_C32(0x56dc0a9c), SPH_C32(0x8a348be1), SPH_C32(0x693b0001), + SPH_C32(0x43606d00), SPH_C32(0x00320000), SPH_C32(0x9ce10000), + SPH_C32(0xfc566d39), SPH_C32(0xf4893d1f), SPH_C32(0x862f6c57), + SPH_C32(0x451c6b25) }, + { SPH_C32(0x235b0003), SPH_C32(0x399aee00), SPH_C32(0xbcc00000), + SPH_C32(0x77010000), SPH_C32(0xc9257539), SPH_C32(0x0bb09d7f), + SPH_C32(0xc37f41e7), SPH_C32(0x3e7f8b71), SPH_C32(0x97190001), + SPH_C32(0xe4386800), SPH_C32(0x25e30000), SPH_C32(0x6b810000), + SPH_C32(0x756715e3), SPH_C32(0xeb5dc57f), SPH_C32(0xc8ffcf42), + SPH_C32(0xe43f94ba) }, + { SPH_C32(0x94130003), SPH_C32(0x7292f300), SPH_C32(0x22020000), + SPH_C32(0xe7c30000), SPH_C32(0x6d7229d5), SPH_C32(0x22f5d5dd), + SPH_C32(0x0eb00f39), SPH_C32(0xf42480a1), SPH_C32(0x23560001), + SPH_C32(0xbbac6100), SPH_C32(0x50000000), SPH_C32(0xc2da0000), + SPH_C32(0x644c4455), SPH_C32(0x5097112e), SPH_C32(0x3b78922f), + SPH_C32(0x95b57f14) }, + { SPH_C32(0x98610003), SPH_C32(0x3b77fc00), SPH_C32(0x607b0000), + SPH_C32(0xbb290000), SPH_C32(0x5ed819cf), SPH_C32(0x3777f0c9), + SPH_C32(0x9b134442), SPH_C32(0x406f8031), SPH_C32(0xdd740001), + SPH_C32(0x1cf46400), SPH_C32(0x75d10000), SPH_C32(0x35ba0000), + SPH_C32(0xed7d3c8f), SPH_C32(0x4f43e94e), SPH_C32(0x75a8313a), + SPH_C32(0x3496808b) }, + { SPH_C32(0x6a310003), SPH_C32(0xd5caf600), SPH_C32(0x07d30000), + SPH_C32(0x10a30000), SPH_C32(0xe443510f), SPH_C32(0x3d212dbd), + SPH_C32(0x4060ac2c), SPH_C32(0x55077f3e), SPH_C32(0xd1060001), + SPH_C32(0x55116b00), SPH_C32(0x37a80000), SPH_C32(0x69500000), + SPH_C32(0xded70c95), SPH_C32(0x5ac1cc5a), SPH_C32(0xe00b7a41), + SPH_C32(0x80dd801b) }, + { SPH_C32(0x66430003), SPH_C32(0x9c2ff900), SPH_C32(0x45aa0000), + SPH_C32(0x4c490000), SPH_C32(0xd7e96115), SPH_C32(0x28a308a9), + SPH_C32(0xd5c3e757), SPH_C32(0xe14c7fae), SPH_C32(0x2f240001), + SPH_C32(0xf2496e00), SPH_C32(0x12790000), SPH_C32(0x9e300000), + SPH_C32(0x57e6744f), SPH_C32(0x4515343a), SPH_C32(0xaedbd954), + SPH_C32(0x21fe7f84) }, + { SPH_C32(0x69360003), SPH_C32(0xc156e200), SPH_C32(0xecf20000), + SPH_C32(0x293a0000), SPH_C32(0x513f5c55), SPH_C32(0xafaeb14e), + SPH_C32(0x7e28bf9f), SPH_C32(0xeed69f40), SPH_C32(0x664e0001), + SPH_C32(0x1e197600), SPH_C32(0xa96a0000), SPH_C32(0xf9920000), + SPH_C32(0x7a805079), SPH_C32(0x738484f8), SPH_C32(0x2dc4349f), + SPH_C32(0x4a868bcb) }, + { SPH_C32(0x65440003), SPH_C32(0x88b3ed00), SPH_C32(0xae8b0000), + SPH_C32(0x75d00000), SPH_C32(0x62956c4f), SPH_C32(0xba2c945a), + SPH_C32(0xeb8bf4e4), SPH_C32(0x5a9d9fd0), SPH_C32(0x986c0001), + SPH_C32(0xb9417300), SPH_C32(0x8cbb0000), SPH_C32(0x0ef20000), + SPH_C32(0xf3b128a3), SPH_C32(0x6c507c98), SPH_C32(0x6314978a), + SPH_C32(0xeba57454) }, + { SPH_C32(0x97140003), SPH_C32(0x660ee700), SPH_C32(0xc9230000), + SPH_C32(0xde5a0000), SPH_C32(0xd80e248f), SPH_C32(0xb07a492e), + SPH_C32(0x30f81c8a), SPH_C32(0x4ff560df), SPH_C32(0x941e0001), + SPH_C32(0xf0a47c00), SPH_C32(0xcec20000), SPH_C32(0x52180000), + SPH_C32(0xc01b18b9), SPH_C32(0x79d2598c), SPH_C32(0xf6b7dcf1), + SPH_C32(0x5fee74c4) }, + { SPH_C32(0x9b660003), SPH_C32(0x2febe800), SPH_C32(0x8b5a0000), + SPH_C32(0x82b00000), SPH_C32(0xeba41495), SPH_C32(0xa5f86c3a), + SPH_C32(0xa55b57f1), SPH_C32(0xfbbe604f), SPH_C32(0x6a3c0001), + SPH_C32(0x57fc7900), SPH_C32(0xeb130000), SPH_C32(0xa5780000), + SPH_C32(0x492a6063), SPH_C32(0x6606a1ec), SPH_C32(0xb8677fe4), + SPH_C32(0xfecd8b5b) }, + { SPH_C32(0x2c2e0003), SPH_C32(0x64e3f500), SPH_C32(0x15980000), + SPH_C32(0x12720000), SPH_C32(0x4ff34879), SPH_C32(0x8cbd2498), + SPH_C32(0x6894192f), SPH_C32(0x31e56b9f), SPH_C32(0xde730001), + SPH_C32(0x08687000), SPH_C32(0x9ef00000), SPH_C32(0x0c230000), + SPH_C32(0x580131d5), SPH_C32(0xddcc75bd), SPH_C32(0x4be02289), + SPH_C32(0x8f4760f5) }, + { SPH_C32(0x205c0003), SPH_C32(0x2d06fa00), SPH_C32(0x57e10000), + SPH_C32(0x4e980000), SPH_C32(0x7c597863), SPH_C32(0x993f018c), + SPH_C32(0xfd375254), SPH_C32(0x85ae6b0f), SPH_C32(0x20510001), + SPH_C32(0xaf307500), SPH_C32(0xbb210000), SPH_C32(0xfb430000), + SPH_C32(0xd130490f), SPH_C32(0xc2188ddd), SPH_C32(0x0530819c), + SPH_C32(0x2e649f6a) }, + { SPH_C32(0xd20c0003), SPH_C32(0xc3bbf000), SPH_C32(0x30490000), + SPH_C32(0xe5120000), SPH_C32(0xc6c230a3), SPH_C32(0x9369dcf8), + SPH_C32(0x2644ba3a), SPH_C32(0x90c69400), SPH_C32(0x2c230001), + SPH_C32(0xe6d57a00), SPH_C32(0xf9580000), SPH_C32(0xa7a90000), + SPH_C32(0xe29a7915), SPH_C32(0xd79aa8c9), SPH_C32(0x9093cae7), + SPH_C32(0x9a2f9ffa) }, + { SPH_C32(0xde7e0003), SPH_C32(0x8a5eff00), SPH_C32(0x72300000), + SPH_C32(0xb9f80000), SPH_C32(0xf56800b9), SPH_C32(0x86ebf9ec), + SPH_C32(0xb3e7f141), SPH_C32(0x248d9490), SPH_C32(0xd2010001), + SPH_C32(0x418d7f00), SPH_C32(0xdc890000), SPH_C32(0x50c90000), + SPH_C32(0x6bab01cf), SPH_C32(0xc84e50a9), SPH_C32(0xde4369f2), + SPH_C32(0x3b0c6065) }, + { SPH_C32(0xeecf0001), SPH_C32(0x6f564000), SPH_C32(0xf33e0000), + SPH_C32(0xa79e0000), SPH_C32(0xbdb57219), SPH_C32(0xb711ebc5), + SPH_C32(0x4a3b40ba), SPH_C32(0xfeabf254), SPH_C32(0x9b060002), + SPH_C32(0x61468000), SPH_C32(0x221e0000), SPH_C32(0x1d740000), + SPH_C32(0x36715d27), SPH_C32(0x30495c92), SPH_C32(0xf11336a7), + SPH_C32(0xfe1cdc7f) }, + { SPH_C32(0xe2bd0001), SPH_C32(0x26b34f00), SPH_C32(0xb1470000), + SPH_C32(0xfb740000), SPH_C32(0x8e1f4203), SPH_C32(0xa293ced1), + SPH_C32(0xdf980bc1), SPH_C32(0x4ae0f2c4), SPH_C32(0x65240002), + SPH_C32(0xc61e8500), SPH_C32(0x07cf0000), SPH_C32(0xea140000), + SPH_C32(0xbf4025fd), SPH_C32(0x2f9da4f2), SPH_C32(0xbfc395b2), + SPH_C32(0x5f3f23e0) }, + { SPH_C32(0x10ed0001), SPH_C32(0xc80e4500), SPH_C32(0xd6ef0000), + SPH_C32(0x50fe0000), SPH_C32(0x34840ac3), SPH_C32(0xa8c513a5), + SPH_C32(0x04ebe3af), SPH_C32(0x5f880dcb), SPH_C32(0x69560002), + SPH_C32(0x8ffb8a00), SPH_C32(0x45b60000), SPH_C32(0xb6fe0000), + SPH_C32(0x8cea15e7), SPH_C32(0x3a1f81e6), SPH_C32(0x2a60dec9), + SPH_C32(0xeb742370) }, + { SPH_C32(0x1c9f0001), SPH_C32(0x81eb4a00), SPH_C32(0x94960000), + SPH_C32(0x0c140000), SPH_C32(0x072e3ad9), SPH_C32(0xbd4736b1), + SPH_C32(0x9148a8d4), SPH_C32(0xebc30d5b), SPH_C32(0x97740002), + SPH_C32(0x28a38f00), SPH_C32(0x60670000), SPH_C32(0x419e0000), + SPH_C32(0x05db6d3d), SPH_C32(0x25cb7986), SPH_C32(0x64b07ddc), + SPH_C32(0x4a57dcef) }, + { SPH_C32(0xabd70001), SPH_C32(0xcae35700), SPH_C32(0x0a540000), + SPH_C32(0x9cd60000), SPH_C32(0xa3796635), SPH_C32(0x94027e13), + SPH_C32(0x5c87e60a), SPH_C32(0x2198068b), SPH_C32(0x233b0002), + SPH_C32(0x77378600), SPH_C32(0x15840000), SPH_C32(0xe8c50000), + SPH_C32(0x14f03c8b), SPH_C32(0x9e01add7), SPH_C32(0x973720b1), + SPH_C32(0x3bdd3741) }, + { SPH_C32(0xa7a50001), SPH_C32(0x83065800), SPH_C32(0x482d0000), + SPH_C32(0xc03c0000), SPH_C32(0x90d3562f), SPH_C32(0x81805b07), + SPH_C32(0xc924ad71), SPH_C32(0x95d3061b), SPH_C32(0xdd190002), + SPH_C32(0xd06f8300), SPH_C32(0x30550000), SPH_C32(0x1fa50000), + SPH_C32(0x9dc14451), SPH_C32(0x81d555b7), SPH_C32(0xd9e783a4), + SPH_C32(0x9afec8de) }, + { SPH_C32(0x55f50001), SPH_C32(0x6dbb5200), SPH_C32(0x2f850000), + SPH_C32(0x6bb60000), SPH_C32(0x2a481eef), SPH_C32(0x8bd68673), + SPH_C32(0x1257451f), SPH_C32(0x80bbf914), SPH_C32(0xd16b0002), + SPH_C32(0x998a8c00), SPH_C32(0x722c0000), SPH_C32(0x434f0000), + SPH_C32(0xae6b744b), SPH_C32(0x945770a3), SPH_C32(0x4c44c8df), + SPH_C32(0x2eb5c84e) }, + { SPH_C32(0x59870001), SPH_C32(0x245e5d00), SPH_C32(0x6dfc0000), + SPH_C32(0x375c0000), SPH_C32(0x19e22ef5), SPH_C32(0x9e54a367), + SPH_C32(0x87f40e64), SPH_C32(0x34f0f984), SPH_C32(0x2f490002), + SPH_C32(0x3ed28900), SPH_C32(0x57fd0000), SPH_C32(0xb42f0000), + SPH_C32(0x275a0c91), SPH_C32(0x8b8388c3), SPH_C32(0x02946bca), + SPH_C32(0x8f9637d1) }, + { SPH_C32(0x56f20001), SPH_C32(0x79274600), SPH_C32(0xc4a40000), + SPH_C32(0x522f0000), SPH_C32(0x9f3413b5), SPH_C32(0x19591a80), + SPH_C32(0x2c1f56ac), SPH_C32(0x3b6a196a), SPH_C32(0x66230002), + SPH_C32(0xd2829100), SPH_C32(0xecee0000), SPH_C32(0xd38d0000), + SPH_C32(0x0a3c28a7), SPH_C32(0xbd123801), SPH_C32(0x818b8601), + SPH_C32(0xe4eec39e) }, + { SPH_C32(0x5a800001), SPH_C32(0x30c24900), SPH_C32(0x86dd0000), + SPH_C32(0x0ec50000), SPH_C32(0xac9e23af), SPH_C32(0x0cdb3f94), + SPH_C32(0xb9bc1dd7), SPH_C32(0x8f2119fa), SPH_C32(0x98010002), + SPH_C32(0x75da9400), SPH_C32(0xc93f0000), SPH_C32(0x24ed0000), + SPH_C32(0x830d507d), SPH_C32(0xa2c6c061), SPH_C32(0xcf5b2514), + SPH_C32(0x45cd3c01) }, + { SPH_C32(0xa8d00001), SPH_C32(0xde7f4300), SPH_C32(0xe1750000), + SPH_C32(0xa54f0000), SPH_C32(0x16056b6f), SPH_C32(0x068de2e0), + SPH_C32(0x62cff5b9), SPH_C32(0x9a49e6f5), SPH_C32(0x94730002), + SPH_C32(0x3c3f9b00), SPH_C32(0x8b460000), SPH_C32(0x78070000), + SPH_C32(0xb0a76067), SPH_C32(0xb744e575), SPH_C32(0x5af86e6f), + SPH_C32(0xf1863c91) }, + { SPH_C32(0xa4a20001), SPH_C32(0x979a4c00), SPH_C32(0xa30c0000), + SPH_C32(0xf9a50000), SPH_C32(0x25af5b75), SPH_C32(0x130fc7f4), + SPH_C32(0xf76cbec2), SPH_C32(0x2e02e665), SPH_C32(0x6a510002), + SPH_C32(0x9b679e00), SPH_C32(0xae970000), SPH_C32(0x8f670000), + SPH_C32(0x399618bd), SPH_C32(0xa8901d15), SPH_C32(0x1428cd7a), + SPH_C32(0x50a5c30e) }, + { SPH_C32(0x13ea0001), SPH_C32(0xdc925100), SPH_C32(0x3dce0000), + SPH_C32(0x69670000), SPH_C32(0x81f80799), SPH_C32(0x3a4a8f56), + SPH_C32(0x3aa3f01c), SPH_C32(0xe459edb5), SPH_C32(0xde1e0002), + SPH_C32(0xc4f39700), SPH_C32(0xdb740000), SPH_C32(0x263c0000), + SPH_C32(0x28bd490b), SPH_C32(0x135ac944), SPH_C32(0xe7af9017), + SPH_C32(0x212f28a0) }, + { SPH_C32(0x1f980001), SPH_C32(0x95775e00), SPH_C32(0x7fb70000), + SPH_C32(0x358d0000), SPH_C32(0xb2523783), SPH_C32(0x2fc8aa42), + SPH_C32(0xaf00bb67), SPH_C32(0x5012ed25), SPH_C32(0x203c0002), + SPH_C32(0x63ab9200), SPH_C32(0xfea50000), SPH_C32(0xd15c0000), + SPH_C32(0xa18c31d1), SPH_C32(0x0c8e3124), SPH_C32(0xa97f3302), + SPH_C32(0x800cd73f) }, + { SPH_C32(0xedc80001), SPH_C32(0x7bca5400), SPH_C32(0x181f0000), + SPH_C32(0x9e070000), SPH_C32(0x08c97f43), SPH_C32(0x259e7736), + SPH_C32(0x74735309), SPH_C32(0x457a122a), SPH_C32(0x2c4e0002), + SPH_C32(0x2a4e9d00), SPH_C32(0xbcdc0000), SPH_C32(0x8db60000), + SPH_C32(0x922601cb), SPH_C32(0x190c1430), SPH_C32(0x3cdc7879), + SPH_C32(0x3447d7af) }, + { SPH_C32(0xe1ba0001), SPH_C32(0x322f5b00), SPH_C32(0x5a660000), + SPH_C32(0xc2ed0000), SPH_C32(0x3b634f59), SPH_C32(0x301c5222), + SPH_C32(0xe1d01872), SPH_C32(0xf13112ba), SPH_C32(0xd26c0002), + SPH_C32(0x8d169800), SPH_C32(0x990d0000), SPH_C32(0x7ad60000), + SPH_C32(0x1b177911), SPH_C32(0x06d8ec50), SPH_C32(0x720cdb6c), + SPH_C32(0x95642830) }, + { SPH_C32(0x9b6b0001), SPH_C32(0xaddd6700), SPH_C32(0x679a0000), + SPH_C32(0x376b0000), SPH_C32(0x46cd25f9), SPH_C32(0xfedfe06b), + SPH_C32(0x5d5c8439), SPH_C32(0x5074942a), SPH_C32(0x4a600002), + SPH_C32(0x7afa8300), SPH_C32(0xbcf20000), SPH_C32(0xebe00000), + SPH_C32(0x35731800), SPH_C32(0xff39a060), SPH_C32(0x45502db0), + SPH_C32(0x7b63e054) }, + { SPH_C32(0x97190001), SPH_C32(0xe4386800), SPH_C32(0x25e30000), + SPH_C32(0x6b810000), SPH_C32(0x756715e3), SPH_C32(0xeb5dc57f), + SPH_C32(0xc8ffcf42), SPH_C32(0xe43f94ba), SPH_C32(0xb4420002), + SPH_C32(0xdda28600), SPH_C32(0x99230000), SPH_C32(0x1c800000), + SPH_C32(0xbc4260da), SPH_C32(0xe0ed5800), SPH_C32(0x0b808ea5), + SPH_C32(0xda401fcb) }, + { SPH_C32(0x65490001), SPH_C32(0x0a856200), SPH_C32(0x424b0000), + SPH_C32(0xc00b0000), SPH_C32(0xcffc5d23), SPH_C32(0xe10b180b), + SPH_C32(0x138c272c), SPH_C32(0xf1576bb5), SPH_C32(0xb8300002), + SPH_C32(0x94478900), SPH_C32(0xdb5a0000), SPH_C32(0x406a0000), + SPH_C32(0x8fe850c0), SPH_C32(0xf56f7d14), SPH_C32(0x9e23c5de), + SPH_C32(0x6e0b1f5b) }, + { SPH_C32(0x693b0001), SPH_C32(0x43606d00), SPH_C32(0x00320000), + SPH_C32(0x9ce10000), SPH_C32(0xfc566d39), SPH_C32(0xf4893d1f), + SPH_C32(0x862f6c57), SPH_C32(0x451c6b25), SPH_C32(0x46120002), + SPH_C32(0x331f8c00), SPH_C32(0xfe8b0000), SPH_C32(0xb70a0000), + SPH_C32(0x06d9281a), SPH_C32(0xeabb8574), SPH_C32(0xd0f366cb), + SPH_C32(0xcf28e0c4) }, + { SPH_C32(0xde730001), SPH_C32(0x08687000), SPH_C32(0x9ef00000), + SPH_C32(0x0c230000), SPH_C32(0x580131d5), SPH_C32(0xddcc75bd), + SPH_C32(0x4be02289), SPH_C32(0x8f4760f5), SPH_C32(0xf25d0002), + SPH_C32(0x6c8b8500), SPH_C32(0x8b680000), SPH_C32(0x1e510000), + SPH_C32(0x17f279ac), SPH_C32(0x51715125), SPH_C32(0x23743ba6), + SPH_C32(0xbea20b6a) }, + { SPH_C32(0xd2010001), SPH_C32(0x418d7f00), SPH_C32(0xdc890000), + SPH_C32(0x50c90000), SPH_C32(0x6bab01cf), SPH_C32(0xc84e50a9), + SPH_C32(0xde4369f2), SPH_C32(0x3b0c6065), SPH_C32(0x0c7f0002), + SPH_C32(0xcbd38000), SPH_C32(0xaeb90000), SPH_C32(0xe9310000), + SPH_C32(0x9ec30176), SPH_C32(0x4ea5a945), SPH_C32(0x6da498b3), + SPH_C32(0x1f81f4f5) }, + { SPH_C32(0x20510001), SPH_C32(0xaf307500), SPH_C32(0xbb210000), + SPH_C32(0xfb430000), SPH_C32(0xd130490f), SPH_C32(0xc2188ddd), + SPH_C32(0x0530819c), SPH_C32(0x2e649f6a), SPH_C32(0x000d0002), + SPH_C32(0x82368f00), SPH_C32(0xecc00000), SPH_C32(0xb5db0000), + SPH_C32(0xad69316c), SPH_C32(0x5b278c51), SPH_C32(0xf807d3c8), + SPH_C32(0xabcaf465) }, + { SPH_C32(0x2c230001), SPH_C32(0xe6d57a00), SPH_C32(0xf9580000), + SPH_C32(0xa7a90000), SPH_C32(0xe29a7915), SPH_C32(0xd79aa8c9), + SPH_C32(0x9093cae7), SPH_C32(0x9a2f9ffa), SPH_C32(0xfe2f0002), + SPH_C32(0x256e8a00), SPH_C32(0xc9110000), SPH_C32(0x42bb0000), + SPH_C32(0x245849b6), SPH_C32(0x44f37431), SPH_C32(0xb6d770dd), + SPH_C32(0x0ae90bfa) }, + { SPH_C32(0x23560001), SPH_C32(0xbbac6100), SPH_C32(0x50000000), + SPH_C32(0xc2da0000), SPH_C32(0x644c4455), SPH_C32(0x5097112e), + SPH_C32(0x3b78922f), SPH_C32(0x95b57f14), SPH_C32(0xb7450002), + SPH_C32(0xc93e9200), SPH_C32(0x72020000), SPH_C32(0x25190000), + SPH_C32(0x093e6d80), SPH_C32(0x7262c4f3), SPH_C32(0x35c89d16), + SPH_C32(0x6191ffb5) }, + { SPH_C32(0x2f240001), SPH_C32(0xf2496e00), SPH_C32(0x12790000), + SPH_C32(0x9e300000), SPH_C32(0x57e6744f), SPH_C32(0x4515343a), + SPH_C32(0xaedbd954), SPH_C32(0x21fe7f84), SPH_C32(0x49670002), + SPH_C32(0x6e669700), SPH_C32(0x57d30000), SPH_C32(0xd2790000), + SPH_C32(0x800f155a), SPH_C32(0x6db63c93), SPH_C32(0x7b183e03), + SPH_C32(0xc0b2002a) }, + { SPH_C32(0xdd740001), SPH_C32(0x1cf46400), SPH_C32(0x75d10000), + SPH_C32(0x35ba0000), SPH_C32(0xed7d3c8f), SPH_C32(0x4f43e94e), + SPH_C32(0x75a8313a), SPH_C32(0x3496808b), SPH_C32(0x45150002), + SPH_C32(0x27839800), SPH_C32(0x15aa0000), SPH_C32(0x8e930000), + SPH_C32(0xb3a52540), SPH_C32(0x78341987), SPH_C32(0xeebb7578), + SPH_C32(0x74f900ba) }, + { SPH_C32(0xd1060001), SPH_C32(0x55116b00), SPH_C32(0x37a80000), + SPH_C32(0x69500000), SPH_C32(0xded70c95), SPH_C32(0x5ac1cc5a), + SPH_C32(0xe00b7a41), SPH_C32(0x80dd801b), SPH_C32(0xbb370002), + SPH_C32(0x80db9d00), SPH_C32(0x307b0000), SPH_C32(0x79f30000), + SPH_C32(0x3a945d9a), SPH_C32(0x67e0e1e7), SPH_C32(0xa06bd66d), + SPH_C32(0xd5daff25) }, + { SPH_C32(0x664e0001), SPH_C32(0x1e197600), SPH_C32(0xa96a0000), + SPH_C32(0xf9920000), SPH_C32(0x7a805079), SPH_C32(0x738484f8), + SPH_C32(0x2dc4349f), SPH_C32(0x4a868bcb), SPH_C32(0x0f780002), + SPH_C32(0xdf4f9400), SPH_C32(0x45980000), SPH_C32(0xd0a80000), + SPH_C32(0x2bbf0c2c), SPH_C32(0xdc2a35b6), SPH_C32(0x53ec8b00), + SPH_C32(0xa450148b) }, + { SPH_C32(0x6a3c0001), SPH_C32(0x57fc7900), SPH_C32(0xeb130000), + SPH_C32(0xa5780000), SPH_C32(0x492a6063), SPH_C32(0x6606a1ec), + SPH_C32(0xb8677fe4), SPH_C32(0xfecd8b5b), SPH_C32(0xf15a0002), + SPH_C32(0x78179100), SPH_C32(0x60490000), SPH_C32(0x27c80000), + SPH_C32(0xa28e74f6), SPH_C32(0xc3fecdd6), SPH_C32(0x1d3c2815), + SPH_C32(0x0573eb14) }, + { SPH_C32(0x986c0001), SPH_C32(0xb9417300), SPH_C32(0x8cbb0000), + SPH_C32(0x0ef20000), SPH_C32(0xf3b128a3), SPH_C32(0x6c507c98), + SPH_C32(0x6314978a), SPH_C32(0xeba57454), SPH_C32(0xfd280002), + SPH_C32(0x31f29e00), SPH_C32(0x22300000), SPH_C32(0x7b220000), + SPH_C32(0x912444ec), SPH_C32(0xd67ce8c2), SPH_C32(0x889f636e), + SPH_C32(0xb138eb84) }, + { SPH_C32(0x941e0001), SPH_C32(0xf0a47c00), SPH_C32(0xcec20000), + SPH_C32(0x52180000), SPH_C32(0xc01b18b9), SPH_C32(0x79d2598c), + SPH_C32(0xf6b7dcf1), SPH_C32(0x5fee74c4), SPH_C32(0x030a0002), + SPH_C32(0x96aa9b00), SPH_C32(0x07e10000), SPH_C32(0x8c420000), + SPH_C32(0x18153c36), SPH_C32(0xc9a810a2), SPH_C32(0xc64fc07b), + SPH_C32(0x101b141b) }, + { SPH_C32(0x3fa90001), SPH_C32(0x74ea4300), SPH_C32(0x6dd20000), + SPH_C32(0x510a0000), SPH_C32(0xbeb7373e), SPH_C32(0x78611737), + SPH_C32(0xfe785bad), SPH_C32(0x7bd4ce7f), SPH_C32(0x3fc40002), + SPH_C32(0xb871a400), SPH_C32(0x28560000), SPH_C32(0x7b150000), + SPH_C32(0xce0b4fe0), SPH_C32(0xb6f7abce), SPH_C32(0x5237e933), + SPH_C32(0xd5bc862a) }, + { SPH_C32(0x33db0001), SPH_C32(0x3d0f4c00), SPH_C32(0x2fab0000), + SPH_C32(0x0de00000), SPH_C32(0x8d1d0724), SPH_C32(0x6de33223), + SPH_C32(0x6bdb10d6), SPH_C32(0xcf9fceef), SPH_C32(0xc1e60002), + SPH_C32(0x1f29a100), SPH_C32(0x0d870000), SPH_C32(0x8c750000), + SPH_C32(0x473a373a), SPH_C32(0xa92353ae), SPH_C32(0x1ce74a26), + SPH_C32(0x749f79b5) }, + { SPH_C32(0xc18b0001), SPH_C32(0xd3b24600), SPH_C32(0x48030000), + SPH_C32(0xa66a0000), SPH_C32(0x37864fe4), SPH_C32(0x67b5ef57), + SPH_C32(0xb0a8f8b8), SPH_C32(0xdaf731e0), SPH_C32(0xcd940002), + SPH_C32(0x56ccae00), SPH_C32(0x4ffe0000), SPH_C32(0xd09f0000), + SPH_C32(0x74900720), SPH_C32(0xbca176ba), SPH_C32(0x8944015d), + SPH_C32(0xc0d47925) }, + { SPH_C32(0xcdf90001), SPH_C32(0x9a574900), SPH_C32(0x0a7a0000), + SPH_C32(0xfa800000), SPH_C32(0x042c7ffe), SPH_C32(0x7237ca43), + SPH_C32(0x250bb3c3), SPH_C32(0x6ebc3170), SPH_C32(0x33b60002), + SPH_C32(0xf194ab00), SPH_C32(0x6a2f0000), SPH_C32(0x27ff0000), + SPH_C32(0xfda17ffa), SPH_C32(0xa3758eda), SPH_C32(0xc794a248), + SPH_C32(0x61f786ba) }, + { SPH_C32(0x7ab10001), SPH_C32(0xd15f5400), SPH_C32(0x94b80000), + SPH_C32(0x6a420000), SPH_C32(0xa07b2312), SPH_C32(0x5b7282e1), + SPH_C32(0xe8c4fd1d), SPH_C32(0xa4e73aa0), SPH_C32(0x87f90002), + SPH_C32(0xae00a200), SPH_C32(0x1fcc0000), SPH_C32(0x8ea40000), + SPH_C32(0xec8a2e4c), SPH_C32(0x18bf5a8b), SPH_C32(0x3413ff25), + SPH_C32(0x107d6d14) }, + { SPH_C32(0x76c30001), SPH_C32(0x98ba5b00), SPH_C32(0xd6c10000), + SPH_C32(0x36a80000), SPH_C32(0x93d11308), SPH_C32(0x4ef0a7f5), + SPH_C32(0x7d67b666), SPH_C32(0x10ac3a30), SPH_C32(0x79db0002), + SPH_C32(0x0958a700), SPH_C32(0x3a1d0000), SPH_C32(0x79c40000), + SPH_C32(0x65bb5696), SPH_C32(0x076ba2eb), SPH_C32(0x7ac35c30), + SPH_C32(0xb15e928b) }, + { SPH_C32(0x84930001), SPH_C32(0x76075100), SPH_C32(0xb1690000), + SPH_C32(0x9d220000), SPH_C32(0x294a5bc8), SPH_C32(0x44a67a81), + SPH_C32(0xa6145e08), SPH_C32(0x05c4c53f), SPH_C32(0x75a90002), + SPH_C32(0x40bda800), SPH_C32(0x78640000), SPH_C32(0x252e0000), + SPH_C32(0x5611668c), SPH_C32(0x12e987ff), SPH_C32(0xef60174b), + SPH_C32(0x0515921b) }, + { SPH_C32(0x88e10001), SPH_C32(0x3fe25e00), SPH_C32(0xf3100000), + SPH_C32(0xc1c80000), SPH_C32(0x1ae06bd2), SPH_C32(0x51245f95), + SPH_C32(0x33b71573), SPH_C32(0xb18fc5af), SPH_C32(0x8b8b0002), + SPH_C32(0xe7e5ad00), SPH_C32(0x5db50000), SPH_C32(0xd24e0000), + SPH_C32(0xdf201e56), SPH_C32(0x0d3d7f9f), SPH_C32(0xa1b0b45e), + SPH_C32(0xa4366d84) }, + { SPH_C32(0x87940001), SPH_C32(0x629b4500), SPH_C32(0x5a480000), + SPH_C32(0xa4bb0000), SPH_C32(0x9c365692), SPH_C32(0xd629e672), + SPH_C32(0x985c4dbb), SPH_C32(0xbe152541), SPH_C32(0xc2e10002), + SPH_C32(0x0bb5b500), SPH_C32(0xe6a60000), SPH_C32(0xb5ec0000), + SPH_C32(0xf2463a60), SPH_C32(0x3baccf5d), SPH_C32(0x22af5995), + SPH_C32(0xcf4e99cb) }, + { SPH_C32(0x8be60001), SPH_C32(0x2b7e4a00), SPH_C32(0x18310000), + SPH_C32(0xf8510000), SPH_C32(0xaf9c6688), SPH_C32(0xc3abc366), + SPH_C32(0x0dff06c0), SPH_C32(0x0a5e25d1), SPH_C32(0x3cc30002), + SPH_C32(0xacedb000), SPH_C32(0xc3770000), SPH_C32(0x428c0000), + SPH_C32(0x7b7742ba), SPH_C32(0x2478373d), SPH_C32(0x6c7ffa80), + SPH_C32(0x6e6d6654) }, + { SPH_C32(0x79b60001), SPH_C32(0xc5c34000), SPH_C32(0x7f990000), + SPH_C32(0x53db0000), SPH_C32(0x15072e48), SPH_C32(0xc9fd1e12), + SPH_C32(0xd68ceeae), SPH_C32(0x1f36dade), SPH_C32(0x30b10002), + SPH_C32(0xe508bf00), SPH_C32(0x810e0000), SPH_C32(0x1e660000), + SPH_C32(0x48dd72a0), SPH_C32(0x31fa1229), SPH_C32(0xf9dcb1fb), + SPH_C32(0xda2666c4) }, + { SPH_C32(0x75c40001), SPH_C32(0x8c264f00), SPH_C32(0x3de00000), + SPH_C32(0x0f310000), SPH_C32(0x26ad1e52), SPH_C32(0xdc7f3b06), + SPH_C32(0x432fa5d5), SPH_C32(0xab7dda4e), SPH_C32(0xce930002), + SPH_C32(0x4250ba00), SPH_C32(0xa4df0000), SPH_C32(0xe9060000), + SPH_C32(0xc1ec0a7a), SPH_C32(0x2e2eea49), SPH_C32(0xb70c12ee), + SPH_C32(0x7b05995b) }, + { SPH_C32(0xc28c0001), SPH_C32(0xc72e5200), SPH_C32(0xa3220000), + SPH_C32(0x9ff30000), SPH_C32(0x82fa42be), SPH_C32(0xf53a73a4), + SPH_C32(0x8ee0eb0b), SPH_C32(0x6126d19e), SPH_C32(0x7adc0002), + SPH_C32(0x1dc4b300), SPH_C32(0xd13c0000), SPH_C32(0x405d0000), + SPH_C32(0xd0c75bcc), SPH_C32(0x95e43e18), SPH_C32(0x448b4f83), + SPH_C32(0x0a8f72f5) }, + { SPH_C32(0xcefe0001), SPH_C32(0x8ecb5d00), SPH_C32(0xe15b0000), + SPH_C32(0xc3190000), SPH_C32(0xb15072a4), SPH_C32(0xe0b856b0), + SPH_C32(0x1b43a070), SPH_C32(0xd56dd10e), SPH_C32(0x84fe0002), + SPH_C32(0xba9cb600), SPH_C32(0xf4ed0000), SPH_C32(0xb73d0000), + SPH_C32(0x59f62316), SPH_C32(0x8a30c678), SPH_C32(0x0a5bec96), + SPH_C32(0xabac8d6a) }, + { SPH_C32(0x3cae0001), SPH_C32(0x60765700), SPH_C32(0x86f30000), + SPH_C32(0x68930000), SPH_C32(0x0bcb3a64), SPH_C32(0xeaee8bc4), + SPH_C32(0xc030481e), SPH_C32(0xc0052e01), SPH_C32(0x888c0002), + SPH_C32(0xf379b900), SPH_C32(0xb6940000), SPH_C32(0xebd70000), + SPH_C32(0x6a5c130c), SPH_C32(0x9fb2e36c), SPH_C32(0x9ff8a7ed), + SPH_C32(0x1fe78dfa) }, + { SPH_C32(0x30dc0001), SPH_C32(0x29935800), SPH_C32(0xc48a0000), + SPH_C32(0x34790000), SPH_C32(0x38610a7e), SPH_C32(0xff6caed0), + SPH_C32(0x55930365), SPH_C32(0x744e2e91), SPH_C32(0x76ae0002), + SPH_C32(0x5421bc00), SPH_C32(0x93450000), SPH_C32(0x1cb70000), + SPH_C32(0xe36d6bd6), SPH_C32(0x80661b0c), SPH_C32(0xd12804f8), + SPH_C32(0xbec47265) }, + { SPH_C32(0x4a0d0001), SPH_C32(0xb6616400), SPH_C32(0xf9760000), + SPH_C32(0xc1ff0000), SPH_C32(0x45cf60de), SPH_C32(0x31af1c99), + SPH_C32(0xe91f9f2e), SPH_C32(0xd50ba801), SPH_C32(0xeea20002), + SPH_C32(0xa3cda700), SPH_C32(0xb6ba0000), SPH_C32(0x8d810000), + SPH_C32(0xcd090ac7), SPH_C32(0x7987573c), SPH_C32(0xe674f224), + SPH_C32(0x50c3ba01) }, + { SPH_C32(0x467f0001), SPH_C32(0xff846b00), SPH_C32(0xbb0f0000), + SPH_C32(0x9d150000), SPH_C32(0x766550c4), SPH_C32(0x242d398d), + SPH_C32(0x7cbcd455), SPH_C32(0x6140a891), SPH_C32(0x10800002), + SPH_C32(0x0495a200), SPH_C32(0x936b0000), SPH_C32(0x7ae10000), + SPH_C32(0x4438721d), SPH_C32(0x6653af5c), SPH_C32(0xa8a45131), + SPH_C32(0xf1e0459e) }, + { SPH_C32(0xb42f0001), SPH_C32(0x11396100), SPH_C32(0xdca70000), + SPH_C32(0x369f0000), SPH_C32(0xccfe1804), SPH_C32(0x2e7be4f9), + SPH_C32(0xa7cf3c3b), SPH_C32(0x7428579e), SPH_C32(0x1cf20002), + SPH_C32(0x4d70ad00), SPH_C32(0xd1120000), SPH_C32(0x260b0000), + SPH_C32(0x77924207), SPH_C32(0x73d18a48), SPH_C32(0x3d071a4a), + SPH_C32(0x45ab450e) }, + { SPH_C32(0xb85d0001), SPH_C32(0x58dc6e00), SPH_C32(0x9ede0000), + SPH_C32(0x6a750000), SPH_C32(0xff54281e), SPH_C32(0x3bf9c1ed), + SPH_C32(0x326c7740), SPH_C32(0xc063570e), SPH_C32(0xe2d00002), + SPH_C32(0xea28a800), SPH_C32(0xf4c30000), SPH_C32(0xd16b0000), + SPH_C32(0xfea33add), SPH_C32(0x6c057228), SPH_C32(0x73d7b95f), + SPH_C32(0xe488ba91) }, + { SPH_C32(0x0f150001), SPH_C32(0x13d47300), SPH_C32(0x001c0000), + SPH_C32(0xfab70000), SPH_C32(0x5b0374f2), SPH_C32(0x12bc894f), + SPH_C32(0xffa3399e), SPH_C32(0x0a385cde), SPH_C32(0x569f0002), + SPH_C32(0xb5bca100), SPH_C32(0x81200000), SPH_C32(0x78300000), + SPH_C32(0xef886b6b), SPH_C32(0xd7cfa679), SPH_C32(0x8050e432), + SPH_C32(0x9502513f) }, + { SPH_C32(0x03670001), SPH_C32(0x5a317c00), SPH_C32(0x42650000), + SPH_C32(0xa65d0000), SPH_C32(0x68a944e8), SPH_C32(0x073eac5b), + SPH_C32(0x6a0072e5), SPH_C32(0xbe735c4e), SPH_C32(0xa8bd0002), + SPH_C32(0x12e4a400), SPH_C32(0xa4f10000), SPH_C32(0x8f500000), + SPH_C32(0x66b913b1), SPH_C32(0xc81b5e19), SPH_C32(0xce804727), + SPH_C32(0x3421aea0) }, + { SPH_C32(0xf1370001), SPH_C32(0xb48c7600), SPH_C32(0x25cd0000), + SPH_C32(0x0dd70000), SPH_C32(0xd2320c28), SPH_C32(0x0d68712f), + SPH_C32(0xb1739a8b), SPH_C32(0xab1ba341), SPH_C32(0xa4cf0002), + SPH_C32(0x5b01ab00), SPH_C32(0xe6880000), SPH_C32(0xd3ba0000), + SPH_C32(0x551323ab), SPH_C32(0xdd997b0d), SPH_C32(0x5b230c5c), + SPH_C32(0x806aae30) }, + { SPH_C32(0xfd450001), SPH_C32(0xfd697900), SPH_C32(0x67b40000), + SPH_C32(0x513d0000), SPH_C32(0xe1983c32), SPH_C32(0x18ea543b), + SPH_C32(0x24d0d1f0), SPH_C32(0x1f50a3d1), SPH_C32(0x5aed0002), + SPH_C32(0xfc59ae00), SPH_C32(0xc3590000), SPH_C32(0x24da0000), + SPH_C32(0xdc225b71), SPH_C32(0xc24d836d), SPH_C32(0x15f3af49), + SPH_C32(0x214951af) }, + { SPH_C32(0xf2300001), SPH_C32(0xa0106200), SPH_C32(0xceec0000), + SPH_C32(0x344e0000), SPH_C32(0x674e0172), SPH_C32(0x9fe7eddc), + SPH_C32(0x8f3b8938), SPH_C32(0x10ca433f), SPH_C32(0x13870002), + SPH_C32(0x1009b600), SPH_C32(0x784a0000), SPH_C32(0x43780000), + SPH_C32(0xf1447f47), SPH_C32(0xf4dc33af), SPH_C32(0x96ec4282), + SPH_C32(0x4a31a5e0) }, + { SPH_C32(0xfe420001), SPH_C32(0xe9f56d00), SPH_C32(0x8c950000), + SPH_C32(0x68a40000), SPH_C32(0x54e43168), SPH_C32(0x8a65c8c8), + SPH_C32(0x1a98c243), SPH_C32(0xa48143af), SPH_C32(0xeda50002), + SPH_C32(0xb751b300), SPH_C32(0x5d9b0000), SPH_C32(0xb4180000), + SPH_C32(0x7875079d), SPH_C32(0xeb08cbcf), SPH_C32(0xd83ce197), + SPH_C32(0xeb125a7f) }, + { SPH_C32(0x0c120001), SPH_C32(0x07486700), SPH_C32(0xeb3d0000), + SPH_C32(0xc32e0000), SPH_C32(0xee7f79a8), SPH_C32(0x803315bc), + SPH_C32(0xc1eb2a2d), SPH_C32(0xb1e9bca0), SPH_C32(0xe1d70002), + SPH_C32(0xfeb4bc00), SPH_C32(0x1fe20000), SPH_C32(0xe8f20000), + SPH_C32(0x4bdf3787), SPH_C32(0xfe8aeedb), SPH_C32(0x4d9faaec), + SPH_C32(0x5f595aef) }, + { SPH_C32(0x00600001), SPH_C32(0x4ead6800), SPH_C32(0xa9440000), + SPH_C32(0x9fc40000), SPH_C32(0xddd549b2), SPH_C32(0x95b130a8), + SPH_C32(0x54486156), SPH_C32(0x05a2bc30), SPH_C32(0x1ff50002), + SPH_C32(0x59ecb900), SPH_C32(0x3a330000), SPH_C32(0x1f920000), + SPH_C32(0xc2ee4f5d), SPH_C32(0xe15e16bb), SPH_C32(0x034f09f9), + SPH_C32(0xfe7aa570) }, + { SPH_C32(0xb7280001), SPH_C32(0x05a57500), SPH_C32(0x37860000), + SPH_C32(0x0f060000), SPH_C32(0x7982155e), SPH_C32(0xbcf4780a), + SPH_C32(0x99872f88), SPH_C32(0xcff9b7e0), SPH_C32(0xabba0002), + SPH_C32(0x0678b000), SPH_C32(0x4fd00000), SPH_C32(0xb6c90000), + SPH_C32(0xd3c51eeb), SPH_C32(0x5a94c2ea), SPH_C32(0xf0c85494), + SPH_C32(0x8ff04ede) }, + { SPH_C32(0xbb5a0001), SPH_C32(0x4c407a00), SPH_C32(0x75ff0000), + SPH_C32(0x53ec0000), SPH_C32(0x4a282544), SPH_C32(0xa9765d1e), + SPH_C32(0x0c2464f3), SPH_C32(0x7bb2b770), SPH_C32(0x55980002), + SPH_C32(0xa120b500), SPH_C32(0x6a010000), SPH_C32(0x41a90000), + SPH_C32(0x5af46631), SPH_C32(0x45403a8a), SPH_C32(0xbe18f781), + SPH_C32(0x2ed3b141) }, + { SPH_C32(0x490a0001), SPH_C32(0xa2fd7000), SPH_C32(0x12570000), + SPH_C32(0xf8660000), SPH_C32(0xf0b36d84), SPH_C32(0xa320806a), + SPH_C32(0xd7578c9d), SPH_C32(0x6eda487f), SPH_C32(0x59ea0002), + SPH_C32(0xe8c5ba00), SPH_C32(0x28780000), SPH_C32(0x1d430000), + SPH_C32(0x695e562b), SPH_C32(0x50c21f9e), SPH_C32(0x2bbbbcfa), + SPH_C32(0x9a98b1d1) }, + { SPH_C32(0x45780001), SPH_C32(0xeb187f00), SPH_C32(0x502e0000), + SPH_C32(0xa48c0000), SPH_C32(0xc3195d9e), SPH_C32(0xb6a2a57e), + SPH_C32(0x42f4c7e6), SPH_C32(0xda9148ef), SPH_C32(0xa7c80002), + SPH_C32(0x4f9dbf00), SPH_C32(0x0da90000), SPH_C32(0xea230000), + SPH_C32(0xe06f2ef1), SPH_C32(0x4f16e7fe), SPH_C32(0x656b1fef), + SPH_C32(0x3bbb4e4e) }, + { SPH_C32(0x9b060002), SPH_C32(0x61468000), SPH_C32(0x221e0000), + SPH_C32(0x1d740000), SPH_C32(0x36715d27), SPH_C32(0x30495c92), + SPH_C32(0xf11336a7), SPH_C32(0xfe1cdc7f), SPH_C32(0x75c90003), + SPH_C32(0x0e10c000), SPH_C32(0xd1200000), SPH_C32(0xbaea0000), + SPH_C32(0x8bc42f3e), SPH_C32(0x8758b757), SPH_C32(0xbb28761d), + SPH_C32(0x00b72e2b) }, + { SPH_C32(0x97740002), SPH_C32(0x28a38f00), SPH_C32(0x60670000), + SPH_C32(0x419e0000), SPH_C32(0x05db6d3d), SPH_C32(0x25cb7986), + SPH_C32(0x64b07ddc), SPH_C32(0x4a57dcef), SPH_C32(0x8beb0003), + SPH_C32(0xa948c500), SPH_C32(0xf4f10000), SPH_C32(0x4d8a0000), + SPH_C32(0x02f557e4), SPH_C32(0x988c4f37), SPH_C32(0xf5f8d508), + SPH_C32(0xa194d1b4) }, + { SPH_C32(0x65240002), SPH_C32(0xc61e8500), SPH_C32(0x07cf0000), + SPH_C32(0xea140000), SPH_C32(0xbf4025fd), SPH_C32(0x2f9da4f2), + SPH_C32(0xbfc395b2), SPH_C32(0x5f3f23e0), SPH_C32(0x87990003), + SPH_C32(0xe0adca00), SPH_C32(0xb6880000), SPH_C32(0x11600000), + SPH_C32(0x315f67fe), SPH_C32(0x8d0e6a23), SPH_C32(0x605b9e73), + SPH_C32(0x15dfd124) }, + { SPH_C32(0x69560002), SPH_C32(0x8ffb8a00), SPH_C32(0x45b60000), + SPH_C32(0xb6fe0000), SPH_C32(0x8cea15e7), SPH_C32(0x3a1f81e6), + SPH_C32(0x2a60dec9), SPH_C32(0xeb742370), SPH_C32(0x79bb0003), + SPH_C32(0x47f5cf00), SPH_C32(0x93590000), SPH_C32(0xe6000000), + SPH_C32(0xb86e1f24), SPH_C32(0x92da9243), SPH_C32(0x2e8b3d66), + SPH_C32(0xb4fc2ebb) }, + { SPH_C32(0xde1e0002), SPH_C32(0xc4f39700), SPH_C32(0xdb740000), + SPH_C32(0x263c0000), SPH_C32(0x28bd490b), SPH_C32(0x135ac944), + SPH_C32(0xe7af9017), SPH_C32(0x212f28a0), SPH_C32(0xcdf40003), + SPH_C32(0x1861c600), SPH_C32(0xe6ba0000), SPH_C32(0x4f5b0000), + SPH_C32(0xa9454e92), SPH_C32(0x29104612), SPH_C32(0xdd0c600b), + SPH_C32(0xc576c515) }, + { SPH_C32(0xd26c0002), SPH_C32(0x8d169800), SPH_C32(0x990d0000), + SPH_C32(0x7ad60000), SPH_C32(0x1b177911), SPH_C32(0x06d8ec50), + SPH_C32(0x720cdb6c), SPH_C32(0x95642830), SPH_C32(0x33d60003), + SPH_C32(0xbf39c300), SPH_C32(0xc36b0000), SPH_C32(0xb83b0000), + SPH_C32(0x20743648), SPH_C32(0x36c4be72), SPH_C32(0x93dcc31e), + SPH_C32(0x64553a8a) }, + { SPH_C32(0x203c0002), SPH_C32(0x63ab9200), SPH_C32(0xfea50000), + SPH_C32(0xd15c0000), SPH_C32(0xa18c31d1), SPH_C32(0x0c8e3124), + SPH_C32(0xa97f3302), SPH_C32(0x800cd73f), SPH_C32(0x3fa40003), + SPH_C32(0xf6dccc00), SPH_C32(0x81120000), SPH_C32(0xe4d10000), + SPH_C32(0x13de0652), SPH_C32(0x23469b66), SPH_C32(0x067f8865), + SPH_C32(0xd01e3a1a) }, + { SPH_C32(0x2c4e0002), SPH_C32(0x2a4e9d00), SPH_C32(0xbcdc0000), + SPH_C32(0x8db60000), SPH_C32(0x922601cb), SPH_C32(0x190c1430), + SPH_C32(0x3cdc7879), SPH_C32(0x3447d7af), SPH_C32(0xc1860003), + SPH_C32(0x5184c900), SPH_C32(0xa4c30000), SPH_C32(0x13b10000), + SPH_C32(0x9aef7e88), SPH_C32(0x3c926306), SPH_C32(0x48af2b70), + SPH_C32(0x713dc585) }, + { SPH_C32(0x233b0002), SPH_C32(0x77378600), SPH_C32(0x15840000), + SPH_C32(0xe8c50000), SPH_C32(0x14f03c8b), SPH_C32(0x9e01add7), + SPH_C32(0x973720b1), SPH_C32(0x3bdd3741), SPH_C32(0x88ec0003), + SPH_C32(0xbdd4d100), SPH_C32(0x1fd00000), SPH_C32(0x74130000), + SPH_C32(0xb7895abe), SPH_C32(0x0a03d3c4), SPH_C32(0xcbb0c6bb), + SPH_C32(0x1a4531ca) }, + { SPH_C32(0x2f490002), SPH_C32(0x3ed28900), SPH_C32(0x57fd0000), + SPH_C32(0xb42f0000), SPH_C32(0x275a0c91), SPH_C32(0x8b8388c3), + SPH_C32(0x02946bca), SPH_C32(0x8f9637d1), SPH_C32(0x76ce0003), + SPH_C32(0x1a8cd400), SPH_C32(0x3a010000), SPH_C32(0x83730000), + SPH_C32(0x3eb82264), SPH_C32(0x15d72ba4), SPH_C32(0x856065ae), + SPH_C32(0xbb66ce55) }, + { SPH_C32(0xdd190002), SPH_C32(0xd06f8300), SPH_C32(0x30550000), + SPH_C32(0x1fa50000), SPH_C32(0x9dc14451), SPH_C32(0x81d555b7), + SPH_C32(0xd9e783a4), SPH_C32(0x9afec8de), SPH_C32(0x7abc0003), + SPH_C32(0x5369db00), SPH_C32(0x78780000), SPH_C32(0xdf990000), + SPH_C32(0x0d12127e), SPH_C32(0x00550eb0), SPH_C32(0x10c32ed5), + SPH_C32(0x0f2dcec5) }, + { SPH_C32(0xd16b0002), SPH_C32(0x998a8c00), SPH_C32(0x722c0000), + SPH_C32(0x434f0000), SPH_C32(0xae6b744b), SPH_C32(0x945770a3), + SPH_C32(0x4c44c8df), SPH_C32(0x2eb5c84e), SPH_C32(0x849e0003), + SPH_C32(0xf431de00), SPH_C32(0x5da90000), SPH_C32(0x28f90000), + SPH_C32(0x84236aa4), SPH_C32(0x1f81f6d0), SPH_C32(0x5e138dc0), + SPH_C32(0xae0e315a) }, + { SPH_C32(0x66230002), SPH_C32(0xd2829100), SPH_C32(0xecee0000), + SPH_C32(0xd38d0000), SPH_C32(0x0a3c28a7), SPH_C32(0xbd123801), + SPH_C32(0x818b8601), SPH_C32(0xe4eec39e), SPH_C32(0x30d10003), + SPH_C32(0xaba5d700), SPH_C32(0x284a0000), SPH_C32(0x81a20000), + SPH_C32(0x95083b12), SPH_C32(0xa44b2281), SPH_C32(0xad94d0ad), + SPH_C32(0xdf84daf4) }, + { SPH_C32(0x6a510002), SPH_C32(0x9b679e00), SPH_C32(0xae970000), + SPH_C32(0x8f670000), SPH_C32(0x399618bd), SPH_C32(0xa8901d15), + SPH_C32(0x1428cd7a), SPH_C32(0x50a5c30e), SPH_C32(0xcef30003), + SPH_C32(0x0cfdd200), SPH_C32(0x0d9b0000), SPH_C32(0x76c20000), + SPH_C32(0x1c3943c8), SPH_C32(0xbb9fdae1), SPH_C32(0xe34473b8), + SPH_C32(0x7ea7256b) }, + { SPH_C32(0x98010002), SPH_C32(0x75da9400), SPH_C32(0xc93f0000), + SPH_C32(0x24ed0000), SPH_C32(0x830d507d), SPH_C32(0xa2c6c061), + SPH_C32(0xcf5b2514), SPH_C32(0x45cd3c01), SPH_C32(0xc2810003), + SPH_C32(0x4518dd00), SPH_C32(0x4fe20000), SPH_C32(0x2a280000), + SPH_C32(0x2f9373d2), SPH_C32(0xae1dfff5), SPH_C32(0x76e738c3), + SPH_C32(0xcaec25fb) }, + { SPH_C32(0x94730002), SPH_C32(0x3c3f9b00), SPH_C32(0x8b460000), + SPH_C32(0x78070000), SPH_C32(0xb0a76067), SPH_C32(0xb744e575), + SPH_C32(0x5af86e6f), SPH_C32(0xf1863c91), SPH_C32(0x3ca30003), + SPH_C32(0xe240d800), SPH_C32(0x6a330000), SPH_C32(0xdd480000), + SPH_C32(0xa6a20b08), SPH_C32(0xb1c90795), SPH_C32(0x38379bd6), + SPH_C32(0x6bcfda64) }, + { SPH_C32(0xeea20002), SPH_C32(0xa3cda700), SPH_C32(0xb6ba0000), + SPH_C32(0x8d810000), SPH_C32(0xcd090ac7), SPH_C32(0x7987573c), + SPH_C32(0xe674f224), SPH_C32(0x50c3ba01), SPH_C32(0xa4af0003), + SPH_C32(0x15acc300), SPH_C32(0x4fcc0000), SPH_C32(0x4c7e0000), + SPH_C32(0x88c66a19), SPH_C32(0x48284ba5), SPH_C32(0x0f6b6d0a), + SPH_C32(0x85c81200) }, + { SPH_C32(0xe2d00002), SPH_C32(0xea28a800), SPH_C32(0xf4c30000), + SPH_C32(0xd16b0000), SPH_C32(0xfea33add), SPH_C32(0x6c057228), + SPH_C32(0x73d7b95f), SPH_C32(0xe488ba91), SPH_C32(0x5a8d0003), + SPH_C32(0xb2f4c600), SPH_C32(0x6a1d0000), SPH_C32(0xbb1e0000), + SPH_C32(0x01f712c3), SPH_C32(0x57fcb3c5), SPH_C32(0x41bbce1f), + SPH_C32(0x24ebed9f) }, + { SPH_C32(0x10800002), SPH_C32(0x0495a200), SPH_C32(0x936b0000), + SPH_C32(0x7ae10000), SPH_C32(0x4438721d), SPH_C32(0x6653af5c), + SPH_C32(0xa8a45131), SPH_C32(0xf1e0459e), SPH_C32(0x56ff0003), + SPH_C32(0xfb11c900), SPH_C32(0x28640000), SPH_C32(0xe7f40000), + SPH_C32(0x325d22d9), SPH_C32(0x427e96d1), SPH_C32(0xd4188564), + SPH_C32(0x90a0ed0f) }, + { SPH_C32(0x1cf20002), SPH_C32(0x4d70ad00), SPH_C32(0xd1120000), + SPH_C32(0x260b0000), SPH_C32(0x77924207), SPH_C32(0x73d18a48), + SPH_C32(0x3d071a4a), SPH_C32(0x45ab450e), SPH_C32(0xa8dd0003), + SPH_C32(0x5c49cc00), SPH_C32(0x0db50000), SPH_C32(0x10940000), + SPH_C32(0xbb6c5a03), SPH_C32(0x5daa6eb1), SPH_C32(0x9ac82671), + SPH_C32(0x31831290) }, + { SPH_C32(0xabba0002), SPH_C32(0x0678b000), SPH_C32(0x4fd00000), + SPH_C32(0xb6c90000), SPH_C32(0xd3c51eeb), SPH_C32(0x5a94c2ea), + SPH_C32(0xf0c85494), SPH_C32(0x8ff04ede), SPH_C32(0x1c920003), + SPH_C32(0x03ddc500), SPH_C32(0x78560000), SPH_C32(0xb9cf0000), + SPH_C32(0xaa470bb5), SPH_C32(0xe660bae0), SPH_C32(0x694f7b1c), + SPH_C32(0x4009f93e) }, + { SPH_C32(0xa7c80002), SPH_C32(0x4f9dbf00), SPH_C32(0x0da90000), + SPH_C32(0xea230000), SPH_C32(0xe06f2ef1), SPH_C32(0x4f16e7fe), + SPH_C32(0x656b1fef), SPH_C32(0x3bbb4e4e), SPH_C32(0xe2b00003), + SPH_C32(0xa485c000), SPH_C32(0x5d870000), SPH_C32(0x4eaf0000), + SPH_C32(0x2376736f), SPH_C32(0xf9b44280), SPH_C32(0x279fd809), + SPH_C32(0xe12a06a1) }, + { SPH_C32(0x55980002), SPH_C32(0xa120b500), SPH_C32(0x6a010000), + SPH_C32(0x41a90000), SPH_C32(0x5af46631), SPH_C32(0x45403a8a), + SPH_C32(0xbe18f781), SPH_C32(0x2ed3b141), SPH_C32(0xeec20003), + SPH_C32(0xed60cf00), SPH_C32(0x1ffe0000), SPH_C32(0x12450000), + SPH_C32(0x10dc4375), SPH_C32(0xec366794), SPH_C32(0xb23c9372), + SPH_C32(0x55610631) }, + { SPH_C32(0x59ea0002), SPH_C32(0xe8c5ba00), SPH_C32(0x28780000), + SPH_C32(0x1d430000), SPH_C32(0x695e562b), SPH_C32(0x50c21f9e), + SPH_C32(0x2bbbbcfa), SPH_C32(0x9a98b1d1), SPH_C32(0x10e00003), + SPH_C32(0x4a38ca00), SPH_C32(0x3a2f0000), SPH_C32(0xe5250000), + SPH_C32(0x99ed3baf), SPH_C32(0xf3e29ff4), SPH_C32(0xfcec3067), + SPH_C32(0xf442f9ae) }, + { SPH_C32(0x569f0002), SPH_C32(0xb5bca100), SPH_C32(0x81200000), + SPH_C32(0x78300000), SPH_C32(0xef886b6b), SPH_C32(0xd7cfa679), + SPH_C32(0x8050e432), SPH_C32(0x9502513f), SPH_C32(0x598a0003), + SPH_C32(0xa668d200), SPH_C32(0x813c0000), SPH_C32(0x82870000), + SPH_C32(0xb48b1f99), SPH_C32(0xc5732f36), SPH_C32(0x7ff3ddac), + SPH_C32(0x9f3a0de1) }, + { SPH_C32(0x5aed0002), SPH_C32(0xfc59ae00), SPH_C32(0xc3590000), + SPH_C32(0x24da0000), SPH_C32(0xdc225b71), SPH_C32(0xc24d836d), + SPH_C32(0x15f3af49), SPH_C32(0x214951af), SPH_C32(0xa7a80003), + SPH_C32(0x0130d700), SPH_C32(0xa4ed0000), SPH_C32(0x75e70000), + SPH_C32(0x3dba6743), SPH_C32(0xdaa7d756), SPH_C32(0x31237eb9), + SPH_C32(0x3e19f27e) }, + { SPH_C32(0xa8bd0002), SPH_C32(0x12e4a400), SPH_C32(0xa4f10000), + SPH_C32(0x8f500000), SPH_C32(0x66b913b1), SPH_C32(0xc81b5e19), + SPH_C32(0xce804727), SPH_C32(0x3421aea0), SPH_C32(0xabda0003), + SPH_C32(0x48d5d800), SPH_C32(0xe6940000), SPH_C32(0x290d0000), + SPH_C32(0x0e105759), SPH_C32(0xcf25f242), SPH_C32(0xa48035c2), + SPH_C32(0x8a52f2ee) }, + { SPH_C32(0xa4cf0002), SPH_C32(0x5b01ab00), SPH_C32(0xe6880000), + SPH_C32(0xd3ba0000), SPH_C32(0x551323ab), SPH_C32(0xdd997b0d), + SPH_C32(0x5b230c5c), SPH_C32(0x806aae30), SPH_C32(0x55f80003), + SPH_C32(0xef8ddd00), SPH_C32(0xc3450000), SPH_C32(0xde6d0000), + SPH_C32(0x87212f83), SPH_C32(0xd0f10a22), SPH_C32(0xea5096d7), + SPH_C32(0x2b710d71) }, + { SPH_C32(0x13870002), SPH_C32(0x1009b600), SPH_C32(0x784a0000), + SPH_C32(0x43780000), SPH_C32(0xf1447f47), SPH_C32(0xf4dc33af), + SPH_C32(0x96ec4282), SPH_C32(0x4a31a5e0), SPH_C32(0xe1b70003), + SPH_C32(0xb019d400), SPH_C32(0xb6a60000), SPH_C32(0x77360000), + SPH_C32(0x960a7e35), SPH_C32(0x6b3bde73), SPH_C32(0x19d7cbba), + SPH_C32(0x5afbe6df) }, + { SPH_C32(0x1ff50002), SPH_C32(0x59ecb900), SPH_C32(0x3a330000), + SPH_C32(0x1f920000), SPH_C32(0xc2ee4f5d), SPH_C32(0xe15e16bb), + SPH_C32(0x034f09f9), SPH_C32(0xfe7aa570), SPH_C32(0x1f950003), + SPH_C32(0x1741d100), SPH_C32(0x93770000), SPH_C32(0x80560000), + SPH_C32(0x1f3b06ef), SPH_C32(0x74ef2613), SPH_C32(0x570768af), + SPH_C32(0xfbd81940) }, + { SPH_C32(0xeda50002), SPH_C32(0xb751b300), SPH_C32(0x5d9b0000), + SPH_C32(0xb4180000), SPH_C32(0x7875079d), SPH_C32(0xeb08cbcf), + SPH_C32(0xd83ce197), SPH_C32(0xeb125a7f), SPH_C32(0x13e70003), + SPH_C32(0x5ea4de00), SPH_C32(0xd10e0000), SPH_C32(0xdcbc0000), + SPH_C32(0x2c9136f5), SPH_C32(0x616d0307), SPH_C32(0xc2a423d4), + SPH_C32(0x4f9319d0) }, + { SPH_C32(0xe1d70002), SPH_C32(0xfeb4bc00), SPH_C32(0x1fe20000), + SPH_C32(0xe8f20000), SPH_C32(0x4bdf3787), SPH_C32(0xfe8aeedb), + SPH_C32(0x4d9faaec), SPH_C32(0x5f595aef), SPH_C32(0xedc50003), + SPH_C32(0xf9fcdb00), SPH_C32(0xf4df0000), SPH_C32(0x2bdc0000), + SPH_C32(0xa5a04e2f), SPH_C32(0x7eb9fb67), SPH_C32(0x8c7480c1), + SPH_C32(0xeeb0e64f) }, + { SPH_C32(0x4a600002), SPH_C32(0x7afa8300), SPH_C32(0xbcf20000), + SPH_C32(0xebe00000), SPH_C32(0x35731800), SPH_C32(0xff39a060), + SPH_C32(0x45502db0), SPH_C32(0x7b63e054), SPH_C32(0xd10b0003), + SPH_C32(0xd727e400), SPH_C32(0xdb680000), SPH_C32(0xdc8b0000), + SPH_C32(0x73be3df9), SPH_C32(0x01e6400b), SPH_C32(0x180ca989), + SPH_C32(0x2b17747e) }, + { SPH_C32(0x46120002), SPH_C32(0x331f8c00), SPH_C32(0xfe8b0000), + SPH_C32(0xb70a0000), SPH_C32(0x06d9281a), SPH_C32(0xeabb8574), + SPH_C32(0xd0f366cb), SPH_C32(0xcf28e0c4), SPH_C32(0x2f290003), + SPH_C32(0x707fe100), SPH_C32(0xfeb90000), SPH_C32(0x2beb0000), + SPH_C32(0xfa8f4523), SPH_C32(0x1e32b86b), SPH_C32(0x56dc0a9c), + SPH_C32(0x8a348be1) }, + { SPH_C32(0xb4420002), SPH_C32(0xdda28600), SPH_C32(0x99230000), + SPH_C32(0x1c800000), SPH_C32(0xbc4260da), SPH_C32(0xe0ed5800), + SPH_C32(0x0b808ea5), SPH_C32(0xda401fcb), SPH_C32(0x235b0003), + SPH_C32(0x399aee00), SPH_C32(0xbcc00000), SPH_C32(0x77010000), + SPH_C32(0xc9257539), SPH_C32(0x0bb09d7f), SPH_C32(0xc37f41e7), + SPH_C32(0x3e7f8b71) }, + { SPH_C32(0xb8300002), SPH_C32(0x94478900), SPH_C32(0xdb5a0000), + SPH_C32(0x406a0000), SPH_C32(0x8fe850c0), SPH_C32(0xf56f7d14), + SPH_C32(0x9e23c5de), SPH_C32(0x6e0b1f5b), SPH_C32(0xdd790003), + SPH_C32(0x9ec2eb00), SPH_C32(0x99110000), SPH_C32(0x80610000), + SPH_C32(0x40140de3), SPH_C32(0x1464651f), SPH_C32(0x8dafe2f2), + SPH_C32(0x9f5c74ee) }, + { SPH_C32(0x0f780002), SPH_C32(0xdf4f9400), SPH_C32(0x45980000), + SPH_C32(0xd0a80000), SPH_C32(0x2bbf0c2c), SPH_C32(0xdc2a35b6), + SPH_C32(0x53ec8b00), SPH_C32(0xa450148b), SPH_C32(0x69360003), + SPH_C32(0xc156e200), SPH_C32(0xecf20000), SPH_C32(0x293a0000), + SPH_C32(0x513f5c55), SPH_C32(0xafaeb14e), SPH_C32(0x7e28bf9f), + SPH_C32(0xeed69f40) }, + { SPH_C32(0x030a0002), SPH_C32(0x96aa9b00), SPH_C32(0x07e10000), + SPH_C32(0x8c420000), SPH_C32(0x18153c36), SPH_C32(0xc9a810a2), + SPH_C32(0xc64fc07b), SPH_C32(0x101b141b), SPH_C32(0x97140003), + SPH_C32(0x660ee700), SPH_C32(0xc9230000), SPH_C32(0xde5a0000), + SPH_C32(0xd80e248f), SPH_C32(0xb07a492e), SPH_C32(0x30f81c8a), + SPH_C32(0x4ff560df) }, + { SPH_C32(0xf15a0002), SPH_C32(0x78179100), SPH_C32(0x60490000), + SPH_C32(0x27c80000), SPH_C32(0xa28e74f6), SPH_C32(0xc3fecdd6), + SPH_C32(0x1d3c2815), SPH_C32(0x0573eb14), SPH_C32(0x9b660003), + SPH_C32(0x2febe800), SPH_C32(0x8b5a0000), SPH_C32(0x82b00000), + SPH_C32(0xeba41495), SPH_C32(0xa5f86c3a), SPH_C32(0xa55b57f1), + SPH_C32(0xfbbe604f) }, + { SPH_C32(0xfd280002), SPH_C32(0x31f29e00), SPH_C32(0x22300000), + SPH_C32(0x7b220000), SPH_C32(0x912444ec), SPH_C32(0xd67ce8c2), + SPH_C32(0x889f636e), SPH_C32(0xb138eb84), SPH_C32(0x65440003), + SPH_C32(0x88b3ed00), SPH_C32(0xae8b0000), SPH_C32(0x75d00000), + SPH_C32(0x62956c4f), SPH_C32(0xba2c945a), SPH_C32(0xeb8bf4e4), + SPH_C32(0x5a9d9fd0) }, + { SPH_C32(0xf25d0002), SPH_C32(0x6c8b8500), SPH_C32(0x8b680000), + SPH_C32(0x1e510000), SPH_C32(0x17f279ac), SPH_C32(0x51715125), + SPH_C32(0x23743ba6), SPH_C32(0xbea20b6a), SPH_C32(0x2c2e0003), + SPH_C32(0x64e3f500), SPH_C32(0x15980000), SPH_C32(0x12720000), + SPH_C32(0x4ff34879), SPH_C32(0x8cbd2498), SPH_C32(0x6894192f), + SPH_C32(0x31e56b9f) }, + { SPH_C32(0xfe2f0002), SPH_C32(0x256e8a00), SPH_C32(0xc9110000), + SPH_C32(0x42bb0000), SPH_C32(0x245849b6), SPH_C32(0x44f37431), + SPH_C32(0xb6d770dd), SPH_C32(0x0ae90bfa), SPH_C32(0xd20c0003), + SPH_C32(0xc3bbf000), SPH_C32(0x30490000), SPH_C32(0xe5120000), + SPH_C32(0xc6c230a3), SPH_C32(0x9369dcf8), SPH_C32(0x2644ba3a), + SPH_C32(0x90c69400) }, + { SPH_C32(0x0c7f0002), SPH_C32(0xcbd38000), SPH_C32(0xaeb90000), + SPH_C32(0xe9310000), SPH_C32(0x9ec30176), SPH_C32(0x4ea5a945), + SPH_C32(0x6da498b3), SPH_C32(0x1f81f4f5), SPH_C32(0xde7e0003), + SPH_C32(0x8a5eff00), SPH_C32(0x72300000), SPH_C32(0xb9f80000), + SPH_C32(0xf56800b9), SPH_C32(0x86ebf9ec), SPH_C32(0xb3e7f141), + SPH_C32(0x248d9490) }, + { SPH_C32(0x000d0002), SPH_C32(0x82368f00), SPH_C32(0xecc00000), + SPH_C32(0xb5db0000), SPH_C32(0xad69316c), SPH_C32(0x5b278c51), + SPH_C32(0xf807d3c8), SPH_C32(0xabcaf465), SPH_C32(0x205c0003), + SPH_C32(0x2d06fa00), SPH_C32(0x57e10000), SPH_C32(0x4e980000), + SPH_C32(0x7c597863), SPH_C32(0x993f018c), SPH_C32(0xfd375254), + SPH_C32(0x85ae6b0f) }, + { SPH_C32(0xb7450002), SPH_C32(0xc93e9200), SPH_C32(0x72020000), + SPH_C32(0x25190000), SPH_C32(0x093e6d80), SPH_C32(0x7262c4f3), + SPH_C32(0x35c89d16), SPH_C32(0x6191ffb5), SPH_C32(0x94130003), + SPH_C32(0x7292f300), SPH_C32(0x22020000), SPH_C32(0xe7c30000), + SPH_C32(0x6d7229d5), SPH_C32(0x22f5d5dd), SPH_C32(0x0eb00f39), + SPH_C32(0xf42480a1) }, + { SPH_C32(0xbb370002), SPH_C32(0x80db9d00), SPH_C32(0x307b0000), + SPH_C32(0x79f30000), SPH_C32(0x3a945d9a), SPH_C32(0x67e0e1e7), + SPH_C32(0xa06bd66d), SPH_C32(0xd5daff25), SPH_C32(0x6a310003), + SPH_C32(0xd5caf600), SPH_C32(0x07d30000), SPH_C32(0x10a30000), + SPH_C32(0xe443510f), SPH_C32(0x3d212dbd), SPH_C32(0x4060ac2c), + SPH_C32(0x55077f3e) }, + { SPH_C32(0x49670002), SPH_C32(0x6e669700), SPH_C32(0x57d30000), + SPH_C32(0xd2790000), SPH_C32(0x800f155a), SPH_C32(0x6db63c93), + SPH_C32(0x7b183e03), SPH_C32(0xc0b2002a), SPH_C32(0x66430003), + SPH_C32(0x9c2ff900), SPH_C32(0x45aa0000), SPH_C32(0x4c490000), + SPH_C32(0xd7e96115), SPH_C32(0x28a308a9), SPH_C32(0xd5c3e757), + SPH_C32(0xe14c7fae) }, + { SPH_C32(0x45150002), SPH_C32(0x27839800), SPH_C32(0x15aa0000), + SPH_C32(0x8e930000), SPH_C32(0xb3a52540), SPH_C32(0x78341987), + SPH_C32(0xeebb7578), SPH_C32(0x74f900ba), SPH_C32(0x98610003), + SPH_C32(0x3b77fc00), SPH_C32(0x607b0000), SPH_C32(0xbb290000), + SPH_C32(0x5ed819cf), SPH_C32(0x3777f0c9), SPH_C32(0x9b134442), + SPH_C32(0x406f8031) }, + { SPH_C32(0x3fc40002), SPH_C32(0xb871a400), SPH_C32(0x28560000), + SPH_C32(0x7b150000), SPH_C32(0xce0b4fe0), SPH_C32(0xb6f7abce), + SPH_C32(0x5237e933), SPH_C32(0xd5bc862a), SPH_C32(0x006d0003), + SPH_C32(0xcc9be700), SPH_C32(0x45840000), SPH_C32(0x2a1f0000), + SPH_C32(0x70bc78de), SPH_C32(0xce96bcf9), SPH_C32(0xac4fb29e), + SPH_C32(0xae684855) }, + { SPH_C32(0x33b60002), SPH_C32(0xf194ab00), SPH_C32(0x6a2f0000), + SPH_C32(0x27ff0000), SPH_C32(0xfda17ffa), SPH_C32(0xa3758eda), + SPH_C32(0xc794a248), SPH_C32(0x61f786ba), SPH_C32(0xfe4f0003), + SPH_C32(0x6bc3e200), SPH_C32(0x60550000), SPH_C32(0xdd7f0000), + SPH_C32(0xf98d0004), SPH_C32(0xd1424499), SPH_C32(0xe29f118b), + SPH_C32(0x0f4bb7ca) }, + { SPH_C32(0xc1e60002), SPH_C32(0x1f29a100), SPH_C32(0x0d870000), + SPH_C32(0x8c750000), SPH_C32(0x473a373a), SPH_C32(0xa92353ae), + SPH_C32(0x1ce74a26), SPH_C32(0x749f79b5), SPH_C32(0xf23d0003), + SPH_C32(0x2226ed00), SPH_C32(0x222c0000), SPH_C32(0x81950000), + SPH_C32(0xca27301e), SPH_C32(0xc4c0618d), SPH_C32(0x773c5af0), + SPH_C32(0xbb00b75a) }, + { SPH_C32(0xcd940002), SPH_C32(0x56ccae00), SPH_C32(0x4ffe0000), + SPH_C32(0xd09f0000), SPH_C32(0x74900720), SPH_C32(0xbca176ba), + SPH_C32(0x8944015d), SPH_C32(0xc0d47925), SPH_C32(0x0c1f0003), + SPH_C32(0x857ee800), SPH_C32(0x07fd0000), SPH_C32(0x76f50000), + SPH_C32(0x431648c4), SPH_C32(0xdb1499ed), SPH_C32(0x39ecf9e5), + SPH_C32(0x1a2348c5) }, + { SPH_C32(0x7adc0002), SPH_C32(0x1dc4b300), SPH_C32(0xd13c0000), + SPH_C32(0x405d0000), SPH_C32(0xd0c75bcc), SPH_C32(0x95e43e18), + SPH_C32(0x448b4f83), SPH_C32(0x0a8f72f5), SPH_C32(0xb8500003), + SPH_C32(0xdaeae100), SPH_C32(0x721e0000), SPH_C32(0xdfae0000), + SPH_C32(0x523d1972), SPH_C32(0x60de4dbc), SPH_C32(0xca6ba488), + SPH_C32(0x6ba9a36b) }, + { SPH_C32(0x76ae0002), SPH_C32(0x5421bc00), SPH_C32(0x93450000), + SPH_C32(0x1cb70000), SPH_C32(0xe36d6bd6), SPH_C32(0x80661b0c), + SPH_C32(0xd12804f8), SPH_C32(0xbec47265), SPH_C32(0x46720003), + SPH_C32(0x7db2e400), SPH_C32(0x57cf0000), SPH_C32(0x28ce0000), + SPH_C32(0xdb0c61a8), SPH_C32(0x7f0ab5dc), SPH_C32(0x84bb079d), + SPH_C32(0xca8a5cf4) }, + { SPH_C32(0x84fe0002), SPH_C32(0xba9cb600), SPH_C32(0xf4ed0000), + SPH_C32(0xb73d0000), SPH_C32(0x59f62316), SPH_C32(0x8a30c678), + SPH_C32(0x0a5bec96), SPH_C32(0xabac8d6a), SPH_C32(0x4a000003), + SPH_C32(0x3457eb00), SPH_C32(0x15b60000), SPH_C32(0x74240000), + SPH_C32(0xe8a651b2), SPH_C32(0x6a8890c8), SPH_C32(0x11184ce6), + SPH_C32(0x7ec15c64) }, + { SPH_C32(0x888c0002), SPH_C32(0xf379b900), SPH_C32(0xb6940000), + SPH_C32(0xebd70000), SPH_C32(0x6a5c130c), SPH_C32(0x9fb2e36c), + SPH_C32(0x9ff8a7ed), SPH_C32(0x1fe78dfa), SPH_C32(0xb4220003), + SPH_C32(0x930fee00), SPH_C32(0x30670000), SPH_C32(0x83440000), + SPH_C32(0x61972968), SPH_C32(0x755c68a8), SPH_C32(0x5fc8eff3), + SPH_C32(0xdfe2a3fb) }, + { SPH_C32(0x87f90002), SPH_C32(0xae00a200), SPH_C32(0x1fcc0000), + SPH_C32(0x8ea40000), SPH_C32(0xec8a2e4c), SPH_C32(0x18bf5a8b), + SPH_C32(0x3413ff25), SPH_C32(0x107d6d14), SPH_C32(0xfd480003), + SPH_C32(0x7f5ff600), SPH_C32(0x8b740000), SPH_C32(0xe4e60000), + SPH_C32(0x4cf10d5e), SPH_C32(0x43cdd86a), SPH_C32(0xdcd70238), + SPH_C32(0xb49a57b4) }, + { SPH_C32(0x8b8b0002), SPH_C32(0xe7e5ad00), SPH_C32(0x5db50000), + SPH_C32(0xd24e0000), SPH_C32(0xdf201e56), SPH_C32(0x0d3d7f9f), + SPH_C32(0xa1b0b45e), SPH_C32(0xa4366d84), SPH_C32(0x036a0003), + SPH_C32(0xd807f300), SPH_C32(0xaea50000), SPH_C32(0x13860000), + SPH_C32(0xc5c07584), SPH_C32(0x5c19200a), SPH_C32(0x9207a12d), + SPH_C32(0x15b9a82b) }, + { SPH_C32(0x79db0002), SPH_C32(0x0958a700), SPH_C32(0x3a1d0000), + SPH_C32(0x79c40000), SPH_C32(0x65bb5696), SPH_C32(0x076ba2eb), + SPH_C32(0x7ac35c30), SPH_C32(0xb15e928b), SPH_C32(0x0f180003), + SPH_C32(0x91e2fc00), SPH_C32(0xecdc0000), SPH_C32(0x4f6c0000), + SPH_C32(0xf66a459e), SPH_C32(0x499b051e), SPH_C32(0x07a4ea56), + SPH_C32(0xa1f2a8bb) }, + { SPH_C32(0x75a90002), SPH_C32(0x40bda800), SPH_C32(0x78640000), + SPH_C32(0x252e0000), SPH_C32(0x5611668c), SPH_C32(0x12e987ff), + SPH_C32(0xef60174b), SPH_C32(0x0515921b), SPH_C32(0xf13a0003), + SPH_C32(0x36baf900), SPH_C32(0xc90d0000), SPH_C32(0xb80c0000), + SPH_C32(0x7f5b3d44), SPH_C32(0x564ffd7e), SPH_C32(0x49744943), + SPH_C32(0x00d15724) }, + { SPH_C32(0xc2e10002), SPH_C32(0x0bb5b500), SPH_C32(0xe6a60000), + SPH_C32(0xb5ec0000), SPH_C32(0xf2463a60), SPH_C32(0x3baccf5d), + SPH_C32(0x22af5995), SPH_C32(0xcf4e99cb), SPH_C32(0x45750003), + SPH_C32(0x692ef000), SPH_C32(0xbcee0000), SPH_C32(0x11570000), + SPH_C32(0x6e706cf2), SPH_C32(0xed85292f), SPH_C32(0xbaf3142e), + SPH_C32(0x715bbc8a) }, + { SPH_C32(0xce930002), SPH_C32(0x4250ba00), SPH_C32(0xa4df0000), + SPH_C32(0xe9060000), SPH_C32(0xc1ec0a7a), SPH_C32(0x2e2eea49), + SPH_C32(0xb70c12ee), SPH_C32(0x7b05995b), SPH_C32(0xbb570003), + SPH_C32(0xce76f500), SPH_C32(0x993f0000), SPH_C32(0xe6370000), + SPH_C32(0xe7411428), SPH_C32(0xf251d14f), SPH_C32(0xf423b73b), + SPH_C32(0xd0784315) }, + { SPH_C32(0x3cc30002), SPH_C32(0xacedb000), SPH_C32(0xc3770000), + SPH_C32(0x428c0000), SPH_C32(0x7b7742ba), SPH_C32(0x2478373d), + SPH_C32(0x6c7ffa80), SPH_C32(0x6e6d6654), SPH_C32(0xb7250003), + SPH_C32(0x8793fa00), SPH_C32(0xdb460000), SPH_C32(0xbadd0000), + SPH_C32(0xd4eb2432), SPH_C32(0xe7d3f45b), SPH_C32(0x6180fc40), + SPH_C32(0x64334385) }, + { SPH_C32(0x30b10002), SPH_C32(0xe508bf00), SPH_C32(0x810e0000), + SPH_C32(0x1e660000), SPH_C32(0x48dd72a0), SPH_C32(0x31fa1229), + SPH_C32(0xf9dcb1fb), SPH_C32(0xda2666c4), SPH_C32(0x49070003), + SPH_C32(0x20cbff00), SPH_C32(0xfe970000), SPH_C32(0x4dbd0000), + SPH_C32(0x5dda5ce8), SPH_C32(0xf8070c3b), SPH_C32(0x2f505f55), + SPH_C32(0xc510bc1a) } +}; + +static const sph_u32 T512_24[256][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x86790000), SPH_C32(0x3f390002), SPH_C32(0xe19ae000), + SPH_C32(0x98560000), SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), + SPH_C32(0xd3dd4944), SPH_C32(0x161ddab9), SPH_C32(0x30b70000), + SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), SPH_C32(0x42c40000), + SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), SPH_C32(0x21afa1ea), + SPH_C32(0xb0a51834) }, + { SPH_C32(0x30b70000), SPH_C32(0xe5d00000), SPH_C32(0xf4f46000), + SPH_C32(0x42c40000), SPH_C32(0x63b83d6a), SPH_C32(0x78ba9460), + SPH_C32(0x21afa1ea), SPH_C32(0xb0a51834), SPH_C32(0xb6ce0000), + SPH_C32(0xdae90002), SPH_C32(0x156e8000), SPH_C32(0xda920000), + SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), SPH_C32(0xf272e8ae), + SPH_C32(0xa6b8c28d) }, + { SPH_C32(0xb6ce0000), SPH_C32(0xdae90002), SPH_C32(0x156e8000), + SPH_C32(0xda920000), SPH_C32(0xf6dd5a64), SPH_C32(0x36325c8a), + SPH_C32(0xf272e8ae), SPH_C32(0xa6b8c28d), SPH_C32(0x86790000), + SPH_C32(0x3f390002), SPH_C32(0xe19ae000), SPH_C32(0x98560000), + SPH_C32(0x9565670e), SPH_C32(0x4e88c8ea), SPH_C32(0xd3dd4944), + SPH_C32(0x161ddab9) }, + { SPH_C32(0x14190000), SPH_C32(0x23ca003c), SPH_C32(0x50df0000), + SPH_C32(0x44b60000), SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), + SPH_C32(0x61e610b0), SPH_C32(0xdbcadb80), SPH_C32(0xe3430000), + SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), SPH_C32(0xaa4e0000), + SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), SPH_C32(0x123db156), + SPH_C32(0x3a4e99d7) }, + { SPH_C32(0x92600000), SPH_C32(0x1cf3003e), SPH_C32(0xb145e000), + SPH_C32(0xdce00000), SPH_C32(0x8e0900be), SPH_C32(0x727b649f), + SPH_C32(0xb23b59f4), SPH_C32(0xcdd70139), SPH_C32(0xd3f40000), + SPH_C32(0xdf9e0014), SPH_C32(0x06326000), SPH_C32(0xe88a0000), + SPH_C32(0xb8a67fcc), SPH_C32(0x5dd12a75), SPH_C32(0x339210bc), + SPH_C32(0x8aeb81e3) }, + { SPH_C32(0x24ae0000), SPH_C32(0xc61a003c), SPH_C32(0xa42b6000), + SPH_C32(0x06720000), SPH_C32(0x78d45ada), SPH_C32(0x44493815), + SPH_C32(0x4049b15a), SPH_C32(0x6b6fc3b4), SPH_C32(0x558d0000), + SPH_C32(0xe0a70016), SPH_C32(0xe7a88000), SPH_C32(0x70dc0000), + SPH_C32(0x2dc318c2), SPH_C32(0x1359e29f), SPH_C32(0xe04f59f8), + SPH_C32(0x9cf65b5a) }, + { SPH_C32(0xa2d70000), SPH_C32(0xf923003e), SPH_C32(0x45b18000), + SPH_C32(0x9e240000), SPH_C32(0xedb13dd4), SPH_C32(0x0ac1f0ff), + SPH_C32(0x9394f81e), SPH_C32(0x7d72190d), SPH_C32(0x653a0000), + SPH_C32(0x05770016), SPH_C32(0x135ce000), SPH_C32(0x32180000), + SPH_C32(0x4e7b25a8), SPH_C32(0x6be376ff), SPH_C32(0xc1e0f812), + SPH_C32(0x2c53436e) }, + { SPH_C32(0xe3430000), SPH_C32(0x3a4e0014), SPH_C32(0xf2c60000), + SPH_C32(0xaa4e0000), SPH_C32(0xdb1e42a6), SPH_C32(0x256bbe15), + SPH_C32(0x123db156), SPH_C32(0x3a4e99d7), SPH_C32(0xf75a0000), + SPH_C32(0x19840028), SPH_C32(0xa2190000), SPH_C32(0xeef80000), + SPH_C32(0xc0722516), SPH_C32(0x19981260), SPH_C32(0x73dba1e6), + SPH_C32(0xe1844257) }, + { SPH_C32(0x653a0000), SPH_C32(0x05770016), SPH_C32(0x135ce000), + SPH_C32(0x32180000), SPH_C32(0x4e7b25a8), SPH_C32(0x6be376ff), + SPH_C32(0xc1e0f812), SPH_C32(0x2c53436e), SPH_C32(0xc7ed0000), + SPH_C32(0xfc540028), SPH_C32(0x56ed6000), SPH_C32(0xac3c0000), + SPH_C32(0xa3ca187c), SPH_C32(0x61228600), SPH_C32(0x5274000c), + SPH_C32(0x51215a63) }, + { SPH_C32(0xd3f40000), SPH_C32(0xdf9e0014), SPH_C32(0x06326000), + SPH_C32(0xe88a0000), SPH_C32(0xb8a67fcc), SPH_C32(0x5dd12a75), + SPH_C32(0x339210bc), SPH_C32(0x8aeb81e3), SPH_C32(0x41940000), + SPH_C32(0xc36d002a), SPH_C32(0xb7778000), SPH_C32(0x346a0000), + SPH_C32(0x36af7f72), SPH_C32(0x2faa4eea), SPH_C32(0x81a94948), + SPH_C32(0x473c80da) }, + { SPH_C32(0x558d0000), SPH_C32(0xe0a70016), SPH_C32(0xe7a88000), + SPH_C32(0x70dc0000), SPH_C32(0x2dc318c2), SPH_C32(0x1359e29f), + SPH_C32(0xe04f59f8), SPH_C32(0x9cf65b5a), SPH_C32(0x71230000), + SPH_C32(0x26bd002a), SPH_C32(0x4383e000), SPH_C32(0x76ae0000), + SPH_C32(0x55174218), SPH_C32(0x5710da8a), SPH_C32(0xa006e8a2), + SPH_C32(0xf79998ee) }, + { SPH_C32(0xf75a0000), SPH_C32(0x19840028), SPH_C32(0xa2190000), + SPH_C32(0xeef80000), SPH_C32(0xc0722516), SPH_C32(0x19981260), + SPH_C32(0x73dba1e6), SPH_C32(0xe1844257), SPH_C32(0x14190000), + SPH_C32(0x23ca003c), SPH_C32(0x50df0000), SPH_C32(0x44b60000), + SPH_C32(0x1b6c67b0), SPH_C32(0x3cf3ac75), SPH_C32(0x61e610b0), + SPH_C32(0xdbcadb80) }, + { SPH_C32(0x71230000), SPH_C32(0x26bd002a), SPH_C32(0x4383e000), + SPH_C32(0x76ae0000), SPH_C32(0x55174218), SPH_C32(0x5710da8a), + SPH_C32(0xa006e8a2), SPH_C32(0xf79998ee), SPH_C32(0x24ae0000), + SPH_C32(0xc61a003c), SPH_C32(0xa42b6000), SPH_C32(0x06720000), + SPH_C32(0x78d45ada), SPH_C32(0x44493815), SPH_C32(0x4049b15a), + SPH_C32(0x6b6fc3b4) }, + { SPH_C32(0xc7ed0000), SPH_C32(0xfc540028), SPH_C32(0x56ed6000), + SPH_C32(0xac3c0000), SPH_C32(0xa3ca187c), SPH_C32(0x61228600), + SPH_C32(0x5274000c), SPH_C32(0x51215a63), SPH_C32(0xa2d70000), + SPH_C32(0xf923003e), SPH_C32(0x45b18000), SPH_C32(0x9e240000), + SPH_C32(0xedb13dd4), SPH_C32(0x0ac1f0ff), SPH_C32(0x9394f81e), + SPH_C32(0x7d72190d) }, + { SPH_C32(0x41940000), SPH_C32(0xc36d002a), SPH_C32(0xb7778000), + SPH_C32(0x346a0000), SPH_C32(0x36af7f72), SPH_C32(0x2faa4eea), + SPH_C32(0x81a94948), SPH_C32(0x473c80da), SPH_C32(0x92600000), + SPH_C32(0x1cf3003e), SPH_C32(0xb145e000), SPH_C32(0xdce00000), + SPH_C32(0x8e0900be), SPH_C32(0x727b649f), SPH_C32(0xb23b59f4), + SPH_C32(0xcdd70139) }, + { SPH_C32(0x54500000), SPH_C32(0x0671005c), SPH_C32(0x25ae0000), + SPH_C32(0x6a1e0000), SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), + SPH_C32(0xbfba18c3), SPH_C32(0x7e715d17), SPH_C32(0xbc8d0000), + SPH_C32(0xfc3b0018), SPH_C32(0x19830000), SPH_C32(0xd10b0000), + SPH_C32(0xae1878c4), SPH_C32(0x42a69856), SPH_C32(0x0012da37), + SPH_C32(0x2c3b504e) }, + { SPH_C32(0xd2290000), SPH_C32(0x3948005e), SPH_C32(0xc434e000), + SPH_C32(0xf2480000), SPH_C32(0xbbc029d1), SPH_C32(0x28c64df8), + SPH_C32(0x6c675187), SPH_C32(0x686c87ae), SPH_C32(0x8c3a0000), + SPH_C32(0x19eb0018), SPH_C32(0xed776000), SPH_C32(0x93cf0000), + SPH_C32(0xcda045ae), SPH_C32(0x3a1c0c36), SPH_C32(0x21bd7bdd), + SPH_C32(0x9c9e487a) }, + { SPH_C32(0x64e70000), SPH_C32(0xe3a1005c), SPH_C32(0xd15a6000), + SPH_C32(0x28da0000), SPH_C32(0x4d1d73b5), SPH_C32(0x1ef41172), + SPH_C32(0x9e15b929), SPH_C32(0xced44523), SPH_C32(0x0a430000), + SPH_C32(0x26d2001a), SPH_C32(0x0ced8000), SPH_C32(0x0b990000), + SPH_C32(0x58c522a0), SPH_C32(0x7494c4dc), SPH_C32(0xf2603299), + SPH_C32(0x8a8392c3) }, + { SPH_C32(0xe29e0000), SPH_C32(0xdc98005e), SPH_C32(0x30c08000), + SPH_C32(0xb08c0000), SPH_C32(0xd87814bb), SPH_C32(0x507cd998), + SPH_C32(0x4dc8f06d), SPH_C32(0xd8c99f9a), SPH_C32(0x3af40000), + SPH_C32(0xc302001a), SPH_C32(0xf819e000), SPH_C32(0x495d0000), + SPH_C32(0x3b7d1fca), SPH_C32(0x0c2e50bc), SPH_C32(0xd3cf9373), + SPH_C32(0x3a268af7) }, + { SPH_C32(0x40490000), SPH_C32(0x25bb0060), SPH_C32(0x75710000), + SPH_C32(0x2ea80000), SPH_C32(0x35c9296f), SPH_C32(0x5abd2967), + SPH_C32(0xde5c0873), SPH_C32(0xa5bb49697), SPH_C32(0x5fce0000), + SPH_C32(0xc675000c), SPH_C32(0xeb450000), SPH_C32(0x7b450000), + SPH_C32(0x75063a62), SPH_C32(0x67cd2643), SPH_C32(0x122f6b61), + SPH_C32(0x1675c999) }, + { SPH_C32(0xc6300000), SPH_C32(0x1a820062), SPH_C32(0x94ebe000), + SPH_C32(0xb6fe0000), SPH_C32(0xa0ac4e61), SPH_C32(0x1435e18d), + SPH_C32(0x0d814137), SPH_C32(0xb3a65c2e), SPH_C32(0x6f790000), + SPH_C32(0x23a5000c), SPH_C32(0x1fb16000), SPH_C32(0x39810000), + SPH_C32(0x16be0708), SPH_C32(0x1f77b223), SPH_C32(0x3380ca8b), + SPH_C32(0xa6d0d1ad) }, + { SPH_C32(0x70fe0000), SPH_C32(0xc06b0060), SPH_C32(0x81856000), + SPH_C32(0x6c6c0000), SPH_C32(0x56711405), SPH_C32(0x2207bd07), + SPH_C32(0xfff3a999), SPH_C32(0x151e9ea3), SPH_C32(0xe9000000), + SPH_C32(0x1c9c000e), SPH_C32(0xfe2b8000), SPH_C32(0xa1d70000), + SPH_C32(0x83db6006), SPH_C32(0x51ff7ac9), SPH_C32(0xe05d83cf), + SPH_C32(0xb0cd0b14) }, + { SPH_C32(0xf6870000), SPH_C32(0xff520062), SPH_C32(0x601f8000), + SPH_C32(0xf43a0000), SPH_C32(0xc314730b), SPH_C32(0x6c8f75ed), + SPH_C32(0x2c2ee0dd), SPH_C32(0x0303441a), SPH_C32(0xd9b70000), + SPH_C32(0xf94c000e), SPH_C32(0x0adfe000), SPH_C32(0xe3130000), + SPH_C32(0xe0635d6c), SPH_C32(0x2945eea9), SPH_C32(0xc1f22225), + SPH_C32(0x00681320) }, + { SPH_C32(0xb7130000), SPH_C32(0x3c3f0048), SPH_C32(0xd7680000), + SPH_C32(0xc0500000), SPH_C32(0xf5bb0c79), SPH_C32(0x43253b07), + SPH_C32(0xad87a995), SPH_C32(0x443fc4c0), SPH_C32(0x4bd70000), + SPH_C32(0xe5bf0030), SPH_C32(0xbb9a0000), SPH_C32(0x3ff30000), + SPH_C32(0x6e6a5dd2), SPH_C32(0x5b3e8a36), SPH_C32(0x73c97bd1), + SPH_C32(0xcdbf1219) }, + { SPH_C32(0x316a0000), SPH_C32(0x0306004a), SPH_C32(0x36f2e000), + SPH_C32(0x58060000), SPH_C32(0x60de6b77), SPH_C32(0x0dadf3ed), + SPH_C32(0x7e5ae0d1), SPH_C32(0x52221e79), SPH_C32(0x7b600000), + SPH_C32(0x006f0030), SPH_C32(0x4f6e6000), SPH_C32(0x7d370000), + SPH_C32(0x0dd260b8), SPH_C32(0x23841e56), SPH_C32(0x5266da3b), + SPH_C32(0x7d1a0a2d) }, + { SPH_C32(0x87a40000), SPH_C32(0xd9ef0048), SPH_C32(0x239c6000), + SPH_C32(0x82940000), SPH_C32(0x96033113), SPH_C32(0x3b9faf67), + SPH_C32(0x8c28087f), SPH_C32(0xf49adcf4), SPH_C32(0xfd190000), + SPH_C32(0x3f560032), SPH_C32(0xaef48000), SPH_C32(0xe5610000), + SPH_C32(0x98b707b6), SPH_C32(0x6d0cd6bc), SPH_C32(0x81bb937f), + SPH_C32(0x6b07d094) }, + { SPH_C32(0x01dd0000), SPH_C32(0xe6d6004a), SPH_C32(0xc2068000), + SPH_C32(0x1ac20000), SPH_C32(0x0366561d), SPH_C32(0x7517678d), + SPH_C32(0x5ff5413b), SPH_C32(0xe287064d), SPH_C32(0xcdae0000), + SPH_C32(0xda860032), SPH_C32(0x5a00e000), SPH_C32(0xa7a50000), + SPH_C32(0xfb0f3adc), SPH_C32(0x15b642dc), SPH_C32(0xa0143295), + SPH_C32(0xdba2c8a0) }, + { SPH_C32(0xa30a0000), SPH_C32(0x1ff50074), SPH_C32(0x87b70000), + SPH_C32(0x84e60000), SPH_C32(0xeed76bc9), SPH_C32(0x7fd69772), + SPH_C32(0xcc61b925), SPH_C32(0x9ff51f40), SPH_C32(0xa8940000), + SPH_C32(0xdff10024), SPH_C32(0x495c0000), SPH_C32(0x95bd0000), + SPH_C32(0xb5741f74), SPH_C32(0x7e553423), SPH_C32(0x61f4ca87), + SPH_C32(0xf7f18bce) }, + { SPH_C32(0x25730000), SPH_C32(0x20cc0076), SPH_C32(0x662de000), + SPH_C32(0x1cb00000), SPH_C32(0x7bb20cc7), SPH_C32(0x315e5f98), + SPH_C32(0x1fbcf061), SPH_C32(0x89e8c5f9), SPH_C32(0x98230000), + SPH_C32(0x3a210024), SPH_C32(0xbda86000), SPH_C32(0xd7790000), + SPH_C32(0xd6cc221e), SPH_C32(0x06efa043), SPH_C32(0x405b6b6d), + SPH_C32(0x475493fa) }, + { SPH_C32(0x93bd0000), SPH_C32(0xfa250074), SPH_C32(0x73436000), + SPH_C32(0xc6220000), SPH_C32(0x8d6f56a3), SPH_C32(0x076c0312), + SPH_C32(0xedce18cf), SPH_C32(0x2f500774), SPH_C32(0x1e5a0000), + SPH_C32(0x05180026), SPH_C32(0x5c328000), SPH_C32(0x4f2f0000), + SPH_C32(0x43a94510), SPH_C32(0x486768a9), SPH_C32(0x93862229), + SPH_C32(0x51494943) }, + { SPH_C32(0x15c40000), SPH_C32(0xc51c0076), SPH_C32(0x92d98000), + SPH_C32(0x5e740000), SPH_C32(0x180a31ad), SPH_C32(0x49e4cbf8), + SPH_C32(0x3e13518b), SPH_C32(0x394dddcd), SPH_C32(0x2eed0000), + SPH_C32(0xe0c80026), SPH_C32(0xa8c6e000), SPH_C32(0x0deb0000), + SPH_C32(0x2011787a), SPH_C32(0x30ddfcc9), SPH_C32(0xb22983c3), + SPH_C32(0xe1ec5177) }, + { SPH_C32(0xbc8d0000), SPH_C32(0xfc3b0018), SPH_C32(0x19830000), + SPH_C32(0xd10b0000), SPH_C32(0xae1878c4), SPH_C32(0x42a69856), + SPH_C32(0x0012da37), SPH_C32(0x2c3b504e), SPH_C32(0xe8dd0000), + SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), SPH_C32(0xbb150000), + SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), SPH_C32(0xbfa8c2f4), + SPH_C32(0x524a0d59) }, + { SPH_C32(0x3af40000), SPH_C32(0xc302001a), SPH_C32(0xf819e000), + SPH_C32(0x495d0000), SPH_C32(0x3b7d1fca), SPH_C32(0x0c2e50bc), + SPH_C32(0xd3cf9373), SPH_C32(0x3a268af7), SPH_C32(0xd86a0000), + SPH_C32(0x1f9a0044), SPH_C32(0xc8d96000), SPH_C32(0xf9d10000), + SPH_C32(0xe3050b71), SPH_C32(0x5c528924), SPH_C32(0x9e07631e), + SPH_C32(0xe2ef156d) }, + { SPH_C32(0x8c3a0000), SPH_C32(0x19eb0018), SPH_C32(0xed776000), + SPH_C32(0x93cf0000), SPH_C32(0xcda045ae), SPH_C32(0x3a1c0c36), + SPH_C32(0x21bd7bdd), SPH_C32(0x9c9e487a), SPH_C32(0x5e130000), + SPH_C32(0x20a30046), SPH_C32(0x29438000), SPH_C32(0x61870000), + SPH_C32(0x76606c7f), SPH_C32(0x12da41ce), SPH_C32(0x4dda2a5a), + SPH_C32(0xf4f2cfd4) }, + { SPH_C32(0x0a430000), SPH_C32(0x26d2001a), SPH_C32(0x0ced8000), + SPH_C32(0x0b990000), SPH_C32(0x58c522a0), SPH_C32(0x7494c4dc), + SPH_C32(0xf2603299), SPH_C32(0x8a8392c3), SPH_C32(0x6ea40000), + SPH_C32(0xc5730046), SPH_C32(0xddb7e000), SPH_C32(0x23430000), + SPH_C32(0x15d85115), SPH_C32(0x6a60d5ae), SPH_C32(0x6c758bb0), + SPH_C32(0x4457d7e0) }, + { SPH_C32(0xa8940000), SPH_C32(0xdff10024), SPH_C32(0x495c0000), + SPH_C32(0x95bd0000), SPH_C32(0xb5741f74), SPH_C32(0x7e553423), + SPH_C32(0x61f4ca87), SPH_C32(0xf7f18bce), SPH_C32(0x0b9e0000), + SPH_C32(0xc0040050), SPH_C32(0xceeb0000), SPH_C32(0x115b0000), + SPH_C32(0x5ba374bd), SPH_C32(0x0183a351), SPH_C32(0xad9573a2), + SPH_C32(0x6804948e) }, + { SPH_C32(0x2eed0000), SPH_C32(0xe0c80026), SPH_C32(0xa8c6e000), + SPH_C32(0x0deb0000), SPH_C32(0x2011787a), SPH_C32(0x30ddfcc9), + SPH_C32(0xb22983c3), SPH_C32(0xe1ec5177), SPH_C32(0x3b290000), + SPH_C32(0x25d40050), SPH_C32(0x3a1f6000), SPH_C32(0x539f0000), + SPH_C32(0x381b49d7), SPH_C32(0x79393731), SPH_C32(0x8c3ad248), + SPH_C32(0xd8a18cba) }, + { SPH_C32(0x98230000), SPH_C32(0x3a210024), SPH_C32(0xbda86000), + SPH_C32(0xd7790000), SPH_C32(0xd6cc221e), SPH_C32(0x06efa043), + SPH_C32(0x405b6b6d), SPH_C32(0x475493fa), SPH_C32(0xbd500000), + SPH_C32(0x1aed0052), SPH_C32(0xdb858000), SPH_C32(0xcbc90000), + SPH_C32(0xad7e2ed9), SPH_C32(0x37b1ffdb), SPH_C32(0x5fe79b0c), + SPH_C32(0xcebc5603) }, + { SPH_C32(0x1e5a0000), SPH_C32(0x05180026), SPH_C32(0x5c328000), + SPH_C32(0x4f2f0000), SPH_C32(0x43a94510), SPH_C32(0x486768a9), + SPH_C32(0x93862229), SPH_C32(0x51494943), SPH_C32(0x8de70000), + SPH_C32(0xff3d0052), SPH_C32(0x2f71e000), SPH_C32(0x890d0000), + SPH_C32(0xcec613b3), SPH_C32(0x4f0b6bbb), SPH_C32(0x7e483ae6), + SPH_C32(0x7e194e37) }, + { SPH_C32(0x5fce0000), SPH_C32(0xc675000c), SPH_C32(0xeb450000), + SPH_C32(0x7b450000), SPH_C32(0x75063a62), SPH_C32(0x67cd2643), + SPH_C32(0x122f6b61), SPH_C32(0x1675c999), SPH_C32(0x1f870000), + SPH_C32(0xe3ce006c), SPH_C32(0x9e340000), SPH_C32(0x55ed0000), + SPH_C32(0x40cf130d), SPH_C32(0x3d700f24), SPH_C32(0xcc736312), + SPH_C32(0xb3ce4f0e) }, + { SPH_C32(0xd9b70000), SPH_C32(0xf94c000e), SPH_C32(0x0adfe000), + SPH_C32(0xe3130000), SPH_C32(0xe0635d6c), SPH_C32(0x2945eea9), + SPH_C32(0xc1f22225), SPH_C32(0x00681320), SPH_C32(0x2f300000), + SPH_C32(0x061e006c), SPH_C32(0x6ac06000), SPH_C32(0x17290000), + SPH_C32(0x23772e67), SPH_C32(0x45ca9b44), SPH_C32(0xeddcc2f8), + SPH_C32(0x036b573a) }, + { SPH_C32(0x6f790000), SPH_C32(0x23a5000c), SPH_C32(0x1fb16000), + SPH_C32(0x39810000), SPH_C32(0x16be0708), SPH_C32(0x1f77b223), + SPH_C32(0x3380ca8b), SPH_C32(0xa6d0d1ad), SPH_C32(0xa9490000), + SPH_C32(0x3927006e), SPH_C32(0x8b5a8000), SPH_C32(0x8f7f0000), + SPH_C32(0xb6124969), SPH_C32(0x0b4253ae), SPH_C32(0x3e018bbc), + SPH_C32(0x15768d83) }, + { SPH_C32(0xe9000000), SPH_C32(0x1c9c000e), SPH_C32(0xfe2b8000), + SPH_C32(0xa1d70000), SPH_C32(0x83db6006), SPH_C32(0x51ff7ac9), + SPH_C32(0xe05d83cf), SPH_C32(0xb0cd0b14), SPH_C32(0x99fe0000), + SPH_C32(0xdcf7006e), SPH_C32(0x7faee000), SPH_C32(0xcdbb0000), + SPH_C32(0xd5aa7403), SPH_C32(0x73f8c7ce), SPH_C32(0x1fae2a56), + SPH_C32(0xa5d395b7) }, + { SPH_C32(0x4bd70000), SPH_C32(0xe5bf0030), SPH_C32(0xbb9a0000), + SPH_C32(0x3ff30000), SPH_C32(0x6e6a5dd2), SPH_C32(0x5b3e8a36), + SPH_C32(0x73c97bd1), SPH_C32(0xcdbf1219), SPH_C32(0xfcc40000), + SPH_C32(0xd9800078), SPH_C32(0x6cf20000), SPH_C32(0xffa30000), + SPH_C32(0x9bd151ab), SPH_C32(0x181bb131), SPH_C32(0xde4ed244), + SPH_C32(0x8980d6d9) }, + { SPH_C32(0xcdae0000), SPH_C32(0xda860032), SPH_C32(0x5a00e000), + SPH_C32(0xa7a50000), SPH_C32(0xfb0f3adc), SPH_C32(0x15b642dc), + SPH_C32(0xa0143295), SPH_C32(0xdba2c8a0), SPH_C32(0xcc730000), + SPH_C32(0x3c500078), SPH_C32(0x98066000), SPH_C32(0xbd670000), + SPH_C32(0xf8696cc1), SPH_C32(0x60a12551), SPH_C32(0xffe173ae), + SPH_C32(0x3925ceed) }, + { SPH_C32(0x7b600000), SPH_C32(0x006f0030), SPH_C32(0x4f6e6000), + SPH_C32(0x7d370000), SPH_C32(0x0dd260b8), SPH_C32(0x23841e56), + SPH_C32(0x5266da3b), SPH_C32(0x7d1a0a2d), SPH_C32(0x4a0a0000), + SPH_C32(0x0369007a), SPH_C32(0x799c8000), SPH_C32(0x25310000), + SPH_C32(0x6d0c0bcf), SPH_C32(0x2e29edbb), SPH_C32(0x2c3c3aea), + SPH_C32(0x2f381454) }, + { SPH_C32(0xfd190000), SPH_C32(0x3f560032), SPH_C32(0xaef48000), + SPH_C32(0xe5610000), SPH_C32(0x98b707b6), SPH_C32(0x6d0cd6bc), + SPH_C32(0x81bb937f), SPH_C32(0x6b07d094), SPH_C32(0x7abd0000), + SPH_C32(0xe6b9007a), SPH_C32(0x8d68e000), SPH_C32(0x67f50000), + SPH_C32(0x0eb436a5), SPH_C32(0x569379db), SPH_C32(0x0d939b00), + SPH_C32(0x9f9d0c60) }, + { SPH_C32(0xe8dd0000), SPH_C32(0xfa4a0044), SPH_C32(0x3c2d0000), + SPH_C32(0xbb150000), SPH_C32(0x80bd361b), SPH_C32(0x24e81d44), + SPH_C32(0xbfa8c2f4), SPH_C32(0x524a0d59), SPH_C32(0x54500000), + SPH_C32(0x0671005c), SPH_C32(0x25ae0000), SPH_C32(0x6a1e0000), + SPH_C32(0x2ea54edf), SPH_C32(0x664e8512), SPH_C32(0xbfba18c3), + SPH_C32(0x7e715d17) }, + { SPH_C32(0x6ea40000), SPH_C32(0xc5730046), SPH_C32(0xddb7e000), + SPH_C32(0x23430000), SPH_C32(0x15d85115), SPH_C32(0x6a60d5ae), + SPH_C32(0x6c758bb0), SPH_C32(0x4457d7e0), SPH_C32(0x64e70000), + SPH_C32(0xe3a1005c), SPH_C32(0xd15a6000), SPH_C32(0x28da0000), + SPH_C32(0x4d1d73b5), SPH_C32(0x1ef41172), SPH_C32(0x9e15b929), + SPH_C32(0xced44523) }, + { SPH_C32(0xd86a0000), SPH_C32(0x1f9a0044), SPH_C32(0xc8d96000), + SPH_C32(0xf9d10000), SPH_C32(0xe3050b71), SPH_C32(0x5c528924), + SPH_C32(0x9e07631e), SPH_C32(0xe2ef156d), SPH_C32(0xe29e0000), + SPH_C32(0xdc98005e), SPH_C32(0x30c08000), SPH_C32(0xb08c0000), + SPH_C32(0xd87814bb), SPH_C32(0x507cd998), SPH_C32(0x4dc8f06d), + SPH_C32(0xd8c99f9a) }, + { SPH_C32(0x5e130000), SPH_C32(0x20a30046), SPH_C32(0x29438000), + SPH_C32(0x61870000), SPH_C32(0x76606c7f), SPH_C32(0x12da41ce), + SPH_C32(0x4dda2a5a), SPH_C32(0xf4f2cfd4), SPH_C32(0xd2290000), + SPH_C32(0x3948005e), SPH_C32(0xc434e000), SPH_C32(0xf2480000), + SPH_C32(0xbbc029d1), SPH_C32(0x28c64df8), SPH_C32(0x6c675187), + SPH_C32(0x686c87ae) }, + { SPH_C32(0xfcc40000), SPH_C32(0xd9800078), SPH_C32(0x6cf20000), + SPH_C32(0xffa30000), SPH_C32(0x9bd151ab), SPH_C32(0x181bb131), + SPH_C32(0xde4ed244), SPH_C32(0x8980d6d9), SPH_C32(0xb7130000), + SPH_C32(0x3c3f0048), SPH_C32(0xd7680000), SPH_C32(0xc0500000), + SPH_C32(0xf5bb0c79), SPH_C32(0x43253b07), SPH_C32(0xad87a995), + SPH_C32(0x443fc4c0) }, + { SPH_C32(0x7abd0000), SPH_C32(0xe6b9007a), SPH_C32(0x8d68e000), + SPH_C32(0x67f50000), SPH_C32(0x0eb436a5), SPH_C32(0x569379db), + SPH_C32(0x0d939b00), SPH_C32(0x9f9d0c60), SPH_C32(0x87a40000), + SPH_C32(0xd9ef0048), SPH_C32(0x239c6000), SPH_C32(0x82940000), + SPH_C32(0x96033113), SPH_C32(0x3b9faf67), SPH_C32(0x8c28087f), + SPH_C32(0xf49adcf4) }, + { SPH_C32(0xcc730000), SPH_C32(0x3c500078), SPH_C32(0x98066000), + SPH_C32(0xbd670000), SPH_C32(0xf8696cc1), SPH_C32(0x60a12551), + SPH_C32(0xffe173ae), SPH_C32(0x3925ceed), SPH_C32(0x01dd0000), + SPH_C32(0xe6d6004a), SPH_C32(0xc2068000), SPH_C32(0x1ac20000), + SPH_C32(0x0366561d), SPH_C32(0x7517678d), SPH_C32(0x5ff5413b), + SPH_C32(0xe287064d) }, + { SPH_C32(0x4a0a0000), SPH_C32(0x0369007a), SPH_C32(0x799c8000), + SPH_C32(0x25310000), SPH_C32(0x6d0c0bcf), SPH_C32(0x2e29edbb), + SPH_C32(0x2c3c3aea), SPH_C32(0x2f381454), SPH_C32(0x316a0000), + SPH_C32(0x0306004a), SPH_C32(0x36f2e000), SPH_C32(0x58060000), + SPH_C32(0x60de6b77), SPH_C32(0x0dadf3ed), SPH_C32(0x7e5ae0d1), + SPH_C32(0x52221e79) }, + { SPH_C32(0x0b9e0000), SPH_C32(0xc0040050), SPH_C32(0xceeb0000), + SPH_C32(0x115b0000), SPH_C32(0x5ba374bd), SPH_C32(0x0183a351), + SPH_C32(0xad9573a2), SPH_C32(0x6804948e), SPH_C32(0xa30a0000), + SPH_C32(0x1ff50074), SPH_C32(0x87b70000), SPH_C32(0x84e60000), + SPH_C32(0xeed76bc9), SPH_C32(0x7fd69772), SPH_C32(0xcc61b925), + SPH_C32(0x9ff51f40) }, + { SPH_C32(0x8de70000), SPH_C32(0xff3d0052), SPH_C32(0x2f71e000), + SPH_C32(0x890d0000), SPH_C32(0xcec613b3), SPH_C32(0x4f0b6bbb), + SPH_C32(0x7e483ae6), SPH_C32(0x7e194e37), SPH_C32(0x93bd0000), + SPH_C32(0xfa250074), SPH_C32(0x73436000), SPH_C32(0xc6220000), + SPH_C32(0x8d6f56a3), SPH_C32(0x076c0312), SPH_C32(0xedce18cf), + SPH_C32(0x2f500774) }, + { SPH_C32(0x3b290000), SPH_C32(0x25d40050), SPH_C32(0x3a1f6000), + SPH_C32(0x539f0000), SPH_C32(0x381b49d7), SPH_C32(0x79393731), + SPH_C32(0x8c3ad248), SPH_C32(0xd8a18cba), SPH_C32(0x15c40000), + SPH_C32(0xc51c0076), SPH_C32(0x92d98000), SPH_C32(0x5e740000), + SPH_C32(0x180a31ad), SPH_C32(0x49e4cbf8), SPH_C32(0x3e13518b), + SPH_C32(0x394dddcd) }, + { SPH_C32(0xbd500000), SPH_C32(0x1aed0052), SPH_C32(0xdb858000), + SPH_C32(0xcbc90000), SPH_C32(0xad7e2ed9), SPH_C32(0x37b1ffdb), + SPH_C32(0x5fe79b0c), SPH_C32(0xcebc5603), SPH_C32(0x25730000), + SPH_C32(0x20cc0076), SPH_C32(0x662de000), SPH_C32(0x1cb00000), + SPH_C32(0x7bb20cc7), SPH_C32(0x315e5f98), SPH_C32(0x1fbcf061), + SPH_C32(0x89e8c5f9) }, + { SPH_C32(0x1f870000), SPH_C32(0xe3ce006c), SPH_C32(0x9e340000), + SPH_C32(0x55ed0000), SPH_C32(0x40cf130d), SPH_C32(0x3d700f24), + SPH_C32(0xcc736312), SPH_C32(0xb3ce4f0e), SPH_C32(0x40490000), + SPH_C32(0x25bb0060), SPH_C32(0x75710000), SPH_C32(0x2ea80000), + SPH_C32(0x35c9296f), SPH_C32(0x5abd2967), SPH_C32(0xde5c0873), + SPH_C32(0xa5bb49697) }, + { SPH_C32(0x99fe0000), SPH_C32(0xdcf7006e), SPH_C32(0x7faee000), + SPH_C32(0xcdbb0000), SPH_C32(0xd5aa7403), SPH_C32(0x73f8c7ce), + SPH_C32(0x1fae2a56), SPH_C32(0xa5d395b7), SPH_C32(0x70fe0000), + SPH_C32(0xc06b0060), SPH_C32(0x81856000), SPH_C32(0x6c6c0000), + SPH_C32(0x56711405), SPH_C32(0x2207bd07), SPH_C32(0xfff3a999), + SPH_C32(0x151e9ea3) }, + { SPH_C32(0x2f300000), SPH_C32(0x061e006c), SPH_C32(0x6ac06000), + SPH_C32(0x17290000), SPH_C32(0x23772e67), SPH_C32(0x45ca9b44), + SPH_C32(0xeddcc2f8), SPH_C32(0x036b573a), SPH_C32(0xf6870000), + SPH_C32(0xff520062), SPH_C32(0x601f8000), SPH_C32(0xf43a0000), + SPH_C32(0xc314730b), SPH_C32(0x6c8f75ed), SPH_C32(0x2c2ee0dd), + SPH_C32(0x0303441a) }, + { SPH_C32(0xa9490000), SPH_C32(0x3927006e), SPH_C32(0x8b5a8000), + SPH_C32(0x8f7f0000), SPH_C32(0xb6124969), SPH_C32(0x0b4253ae), + SPH_C32(0x3e018bbc), SPH_C32(0x15768d83), SPH_C32(0xc6300000), + SPH_C32(0x1a820062), SPH_C32(0x94ebe000), SPH_C32(0xb6fe0000), + SPH_C32(0xa0ac4e61), SPH_C32(0x1435e18d), SPH_C32(0x0d814137), + SPH_C32(0xb3a65c2e) }, + { SPH_C32(0x69510000), SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), + SPH_C32(0xac2f0000), SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), + SPH_C32(0x87ec287c), SPH_C32(0xbce1a3ce), SPH_C32(0xc6730000), + SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), SPH_C32(0x218d0000), + SPH_C32(0x23111587), SPH_C32(0x7913512f), SPH_C32(0x1d28ac88), + SPH_C32(0x378dd173) }, + { SPH_C32(0xef280000), SPH_C32(0xebd8009e), SPH_C32(0x22b9e000), + SPH_C32(0x34790000), SPH_C32(0x71f06ca0), SPH_C32(0x802cdd36), + SPH_C32(0x54316138), SPH_C32(0xaafc7977), SPH_C32(0xf6c40000), + SPH_C32(0x4a5d000c), SPH_C32(0x50356000), SPH_C32(0x63490000), + SPH_C32(0x40a928ed), SPH_C32(0x01a9c54f), SPH_C32(0x3c870d62), + SPH_C32(0x8728c947) }, + { SPH_C32(0x59e60000), SPH_C32(0x3131009c), SPH_C32(0x37d76000), + SPH_C32(0xeeeb0000), SPH_C32(0x872d36c4), SPH_C32(0xb61e81bc), + SPH_C32(0xa6438996), SPH_C32(0x0c44bbfa), SPH_C32(0x70bd0000), + SPH_C32(0x7564000e), SPH_C32(0xb1af8000), SPH_C32(0xfb1f0000), + SPH_C32(0xd5cc4fe3), SPH_C32(0x4f210da5), SPH_C32(0xef5a4426), + SPH_C32(0x913513fe) }, + { SPH_C32(0xdf9f0000), SPH_C32(0x0e08009e), SPH_C32(0xd64d8000), + SPH_C32(0x76bd0000), SPH_C32(0x124851ca), SPH_C32(0xf8964956), + SPH_C32(0x759ec0d2), SPH_C32(0x1a596143), SPH_C32(0x400a0000), + SPH_C32(0x90b4000e), SPH_C32(0x455be000), SPH_C32(0xb9db0000), + SPH_C32(0xb6747289), SPH_C32(0x379b99c5), SPH_C32(0xcef5e5cc), + SPH_C32(0x21900bca) }, + { SPH_C32(0x7d480000), SPH_C32(0xf72b00a0), SPH_C32(0x93fc0000), + SPH_C32(0xe8990000), SPH_C32(0xfff96c1e), SPH_C32(0xf257b9a9), + SPH_C32(0xe60a38cc), SPH_C32(0x672b784e), SPH_C32(0x25300000), + SPH_C32(0x95c30018), SPH_C32(0x56070000), SPH_C32(0x8bc30000), + SPH_C32(0xf80f5721), SPH_C32(0x5c78ef3a), SPH_C32(0x0f151dde), + SPH_C32(0x0dc348a4) }, + { SPH_C32(0xfb310000), SPH_C32(0xc81200a2), SPH_C32(0x7266e000), + SPH_C32(0x70cf0000), SPH_C32(0x6a9c0b10), SPH_C32(0xbcdf7143), + SPH_C32(0x35d77188), SPH_C32(0x7136a2f7), SPH_C32(0x15870000), + SPH_C32(0x70130018), SPH_C32(0xa2f36000), SPH_C32(0xc9070000), + SPH_C32(0x9bb76a4b), SPH_C32(0x24c27b5a), SPH_C32(0x2ebabc34), + SPH_C32(0xbd665090) }, + { SPH_C32(0x4dff0000), SPH_C32(0x12fb00a0), SPH_C32(0x67086000), + SPH_C32(0xaa5d0000), SPH_C32(0x9c415174), SPH_C32(0x8aed2dc9), + SPH_C32(0xc7a59926), SPH_C32(0xd78e607a), SPH_C32(0x93fe0000), + SPH_C32(0x4f2a001a), SPH_C32(0x43698000), SPH_C32(0x51510000), + SPH_C32(0x0ed20d45), SPH_C32(0x6a4ab3b0), SPH_C32(0xfd67f570), + SPH_C32(0xab7b8a29) }, + { SPH_C32(0xcb860000), SPH_C32(0x2dc200a2), SPH_C32(0x86928000), + SPH_C32(0x320b0000), SPH_C32(0x0924367a), SPH_C32(0xc465e523), + SPH_C32(0x1478d062), SPH_C32(0xc193bac3), SPH_C32(0xa3490000), + SPH_C32(0xaafa001a), SPH_C32(0xb79de000), SPH_C32(0x13950000), + SPH_C32(0x6d6a302f), SPH_C32(0x12f027d0), SPH_C32(0xdcc8549a), + SPH_C32(0x1bde921d) }, + { SPH_C32(0x8a120000), SPH_C32(0xeeaf0088), SPH_C32(0x31e50000), + SPH_C32(0x06610000), SPH_C32(0x3f8b4908), SPH_C32(0xebcfabc9), + SPH_C32(0x95d1992a), SPH_C32(0x86af3a19), SPH_C32(0x31290000), + SPH_C32(0xb6090024), SPH_C32(0x06d80000), SPH_C32(0xcf750000), + SPH_C32(0xe3633091), SPH_C32(0x608b434f), SPH_C32(0x6ef30d6e), + SPH_C32(0xd6099324) }, + { SPH_C32(0x0c6b0000), SPH_C32(0xd196008a), SPH_C32(0xd07fe000), + SPH_C32(0x9e370000), SPH_C32(0xaaee2e06), SPH_C32(0xa5476323), + SPH_C32(0x460cd06e), SPH_C32(0x90b2e0a0), SPH_C32(0x019e0000), + SPH_C32(0x53d90024), SPH_C32(0xf22c6000), SPH_C32(0x8db10000), + SPH_C32(0x80db0dfb), SPH_C32(0x1831d72f), SPH_C32(0x4f5cac84), + SPH_C32(0x66ac8b10) }, + { SPH_C32(0xbaa50000), SPH_C32(0x0b7f0088), SPH_C32(0xc5116000), + SPH_C32(0x44a50000), SPH_C32(0x5c337462), SPH_C32(0x93753fa9), + SPH_C32(0xb47e38c0), SPH_C32(0x360a222d), SPH_C32(0x87e70000), + SPH_C32(0x6ce00026), SPH_C32(0x13b68000), SPH_C32(0x15e70000), + SPH_C32(0x15be6af5), SPH_C32(0x56b91fc5), SPH_C32(0x9c81e5c0), + SPH_C32(0x70b151a9) }, + { SPH_C32(0x3cdc0000), SPH_C32(0x3446008a), SPH_C32(0x248b8000), + SPH_C32(0xdcf30000), SPH_C32(0xc956136c), SPH_C32(0xddfdf743), + SPH_C32(0x67a37184), SPH_C32(0x2017f894), SPH_C32(0xb7500000), + SPH_C32(0x89300026), SPH_C32(0xe742e000), SPH_C32(0x57230000), + SPH_C32(0x7606579f), SPH_C32(0x2e038ba5), SPH_C32(0xbd2e442a), + SPH_C32(0xc014499d) }, + { SPH_C32(0x9e0b0000), SPH_C32(0xcd6500b4), SPH_C32(0x613a0000), + SPH_C32(0x42d70000), SPH_C32(0x24e72eb8), SPH_C32(0xd73c07bc), + SPH_C32(0xf437899a), SPH_C32(0x5d65e199), SPH_C32(0xd26a0000), + SPH_C32(0x8c470030), SPH_C32(0xf41e0000), SPH_C32(0x653b0000), + SPH_C32(0x387d7237), SPH_C32(0x45e0fd5a), SPH_C32(0x7ccebc38), + SPH_C32(0xec470af3) }, + { SPH_C32(0x18720000), SPH_C32(0xf25c00b6), SPH_C32(0x80a0e000), + SPH_C32(0xda810000), SPH_C32(0xb18249b6), SPH_C32(0x99b4cf56), + SPH_C32(0x27eac0de), SPH_C32(0x4b783b20), SPH_C32(0xe2dd0000), + SPH_C32(0x69970030), SPH_C32(0x00ea6000), SPH_C32(0x27ff0000), + SPH_C32(0x5bc54f5d), SPH_C32(0x3d5a693a), SPH_C32(0x5d611dd2), + SPH_C32(0x5ce212c7) }, + { SPH_C32(0xaebc0000), SPH_C32(0x28b500b4), SPH_C32(0x95ce6000), + SPH_C32(0x00130000), SPH_C32(0x475f13d2), SPH_C32(0xaf8693dc), + SPH_C32(0xd5982870), SPH_C32(0xedc0f9ad), SPH_C32(0x64a40000), + SPH_C32(0x56ae0032), SPH_C32(0xe1708000), SPH_C32(0xbfa90000), + SPH_C32(0xcea02853), SPH_C32(0x73d2a1d0), SPH_C32(0x8ebc5496), + SPH_C32(0x4affc87e) }, + { SPH_C32(0x28c50000), SPH_C32(0x178c00b6), SPH_C32(0x74548000), + SPH_C32(0x98450000), SPH_C32(0xd23a74dc), SPH_C32(0xe10e5b36), + SPH_C32(0x06456134), SPH_C32(0xfbdd2314), SPH_C32(0x54130000), + SPH_C32(0xb37e0032), SPH_C32(0x1584e000), SPH_C32(0xfd6d0000), + SPH_C32(0xad181539), SPH_C32(0x0b6835b0), SPH_C32(0xaf13f57c), + SPH_C32(0xfa5ad04a) }, + { SPH_C32(0x3d010000), SPH_C32(0xd29000c0), SPH_C32(0xe68d0000), + SPH_C32(0xc6310000), SPH_C32(0xca304571), SPH_C32(0xa8ea90ce), + SPH_C32(0x385630bf), SPH_C32(0xc290fed9), SPH_C32(0x7afe0000), + SPH_C32(0x53b60014), SPH_C32(0xbd420000), SPH_C32(0xf0860000), + SPH_C32(0x8d096d43), SPH_C32(0x3bb5c979), SPH_C32(0x1d3a76bf), + SPH_C32(0x1bb6813d) }, + { SPH_C32(0xbb780000), SPH_C32(0xeda900c2), SPH_C32(0x0717e000), + SPH_C32(0x5e670000), SPH_C32(0x5f55227f), SPH_C32(0xe6625824), + SPH_C32(0xeb8b79fb), SPH_C32(0xd48d2460), SPH_C32(0x4a490000), + SPH_C32(0xb6660014), SPH_C32(0x49b66000), SPH_C32(0xb2420000), + SPH_C32(0xeeb15029), SPH_C32(0x430f5d19), SPH_C32(0x3c95d755), + SPH_C32(0xab139909) }, + { SPH_C32(0x0db60000), SPH_C32(0x374000c0), SPH_C32(0x12796000), + SPH_C32(0x84f50000), SPH_C32(0xa988781b), SPH_C32(0xd05004ae), + SPH_C32(0x19f99155), SPH_C32(0x7235e6ed), SPH_C32(0xcc300000), + SPH_C32(0x895f0016), SPH_C32(0xa82c8000), SPH_C32(0x2a140000), + SPH_C32(0x7bd43727), SPH_C32(0x0d8795f3), SPH_C32(0xef489e11), + SPH_C32(0xbd0e43b0) }, + { SPH_C32(0x8bcf0000), SPH_C32(0x087900c2), SPH_C32(0xf3e38000), + SPH_C32(0x1ca30000), SPH_C32(0x3ced1f15), SPH_C32(0x9ed8cc44), + SPH_C32(0xca24d811), SPH_C32(0x64283c54), SPH_C32(0xfc870000), + SPH_C32(0x6c8f0016), SPH_C32(0x5cd8e000), SPH_C32(0x68d00000), + SPH_C32(0x186c0a4d), SPH_C32(0x753d0193), SPH_C32(0xcee73ffb), + SPH_C32(0x0dab5b84) }, + { SPH_C32(0x29180000), SPH_C32(0xf15a00fc), SPH_C32(0xb6520000), + SPH_C32(0x82870000), SPH_C32(0xd15c22c1), SPH_C32(0x94193cbb), + SPH_C32(0x59b0200f), SPH_C32(0x195a2559), SPH_C32(0x99bd0000), + SPH_C32(0x69f80000), SPH_C32(0x4f840000), SPH_C32(0x5ac80000), + SPH_C32(0x56172fe5), SPH_C32(0x1ede776c), SPH_C32(0x0f07c7e9), + SPH_C32(0x21f818ea) }, + { SPH_C32(0xaf610000), SPH_C32(0xce6300fe), SPH_C32(0x57c8e000), + SPH_C32(0x1ad10000), SPH_C32(0x443945cf), SPH_C32(0xda91f451), + SPH_C32(0x8a6d694b), SPH_C32(0x0f47ffe0), SPH_C32(0xa90a0000), + SPH_C32(0x8c280000), SPH_C32(0xbb706000), SPH_C32(0x180c0000), + SPH_C32(0x35af128f), SPH_C32(0x6664e30c), SPH_C32(0x2ea86603), + SPH_C32(0x915d00de) }, + { SPH_C32(0x19af0000), SPH_C32(0x148a00fc), SPH_C32(0x42a66000), + SPH_C32(0xc0430000), SPH_C32(0xb2e41fab), SPH_C32(0xeca3a8db), + SPH_C32(0x781f81e5), SPH_C32(0xa9ff3d6d), SPH_C32(0x2f730000), + SPH_C32(0xb3110002), SPH_C32(0x5aea8000), SPH_C32(0x805a0000), + SPH_C32(0xa0ca7581), SPH_C32(0x28ec2be6), SPH_C32(0xfd752f47), + SPH_C32(0x8740da67) }, + { SPH_C32(0x9fd60000), SPH_C32(0x2bb300fe), SPH_C32(0xa33c8000), + SPH_C32(0x58150000), SPH_C32(0x278178a5), SPH_C32(0xa22b6031), + SPH_C32(0xabc2c8a1), SPH_C32(0xbfe2e7d4), SPH_C32(0x1fc40000), + SPH_C32(0x56c10002), SPH_C32(0xae1ee000), SPH_C32(0xc29e0000), + SPH_C32(0xc37248eb), SPH_C32(0x5056bf86), SPH_C32(0xdcda8ead), + SPH_C32(0x37e5c253) }, + { SPH_C32(0xde420000), SPH_C32(0xe8de00d4), SPH_C32(0x144b0000), + SPH_C32(0x6c7f0000), SPH_C32(0x112e07d7), SPH_C32(0x8d812edb), + SPH_C32(0x2a6b81e9), SPH_C32(0xf8de670e), SPH_C32(0x8da40000), + SPH_C32(0x4a32003c), SPH_C32(0x1f5b0000), SPH_C32(0x1e7e0000), + SPH_C32(0x4d7b4855), SPH_C32(0x222ddb19), SPH_C32(0x6ee1d759), + SPH_C32(0xfa32c36a) }, + { SPH_C32(0x583b0000), SPH_C32(0xd7e700d6), SPH_C32(0xf5d1e000), + SPH_C32(0xf4290000), SPH_C32(0x844b60d9), SPH_C32(0xc309e631), + SPH_C32(0xf9b6c8ad), SPH_C32(0xeec3bdb7), SPH_C32(0xbd130000), + SPH_C32(0xafe2003c), SPH_C32(0xebaf6000), SPH_C32(0x5cba0000), + SPH_C32(0x2ec3753f), SPH_C32(0x5a974f79), SPH_C32(0x4f4e76b3), + SPH_C32(0x4a97db5e) }, + { SPH_C32(0xeef50000), SPH_C32(0x0d0e00d4), SPH_C32(0xe0bf6000), + SPH_C32(0x2ebb0000), SPH_C32(0x72963abd), SPH_C32(0xf53bbabb), + SPH_C32(0x0bc42003), SPH_C32(0x487b7f3a), SPH_C32(0x3b6a0000), + SPH_C32(0x90db003e), SPH_C32(0x0a358000), SPH_C32(0xc4ec0000), + SPH_C32(0xbba61231), SPH_C32(0x141f8793), SPH_C32(0x9c933ff7), + SPH_C32(0x5c8a01e7) }, + { SPH_C32(0x688c0000), SPH_C32(0x323700d6), SPH_C32(0x01258000), + SPH_C32(0xb6ed0000), SPH_C32(0xe7f35db3), SPH_C32(0xbbb37251), + SPH_C32(0xd8196947), SPH_C32(0x5e66a583), SPH_C32(0x0bdd0000), + SPH_C32(0x750b003e), SPH_C32(0xfec1e000), SPH_C32(0x86280000), + SPH_C32(0xd81e2f5b), SPH_C32(0x6ca513f3), SPH_C32(0xbd3c9e1d), + SPH_C32(0xec2f19d3) }, + { SPH_C32(0xca5b0000), SPH_C32(0xcb1400e8), SPH_C32(0x44940000), + SPH_C32(0x28c90000), SPH_C32(0x0a426067), SPH_C32(0xb17282ae), + SPH_C32(0x4b8d9159), SPH_C32(0x2314bc8e), SPH_C32(0x6ee70000), + SPH_C32(0x707c0028), SPH_C32(0xed9d0000), SPH_C32(0xb4300000), + SPH_C32(0x96650af3), SPH_C32(0x0746650c), SPH_C32(0x7cdc660f), + SPH_C32(0xc07c5abd) }, + { SPH_C32(0x4c220000), SPH_C32(0xf42d00ea), SPH_C32(0xa50ee000), + SPH_C32(0xb09f0000), SPH_C32(0x9f270769), SPH_C32(0xfffa4a44), + SPH_C32(0x9850d81d), SPH_C32(0x35096637), SPH_C32(0x5e500000), + SPH_C32(0x95ac0028), SPH_C32(0x19696000), SPH_C32(0xf6f40000), + SPH_C32(0xf5dd3799), SPH_C32(0x7ffcf16c), SPH_C32(0x5d73c7e5), + SPH_C32(0x70d94289) }, + { SPH_C32(0xfaec0000), SPH_C32(0x2ec400e8), SPH_C32(0xb0606000), + SPH_C32(0x6a0d0000), SPH_C32(0x69fa5d0d), SPH_C32(0xc9c816ce), + SPH_C32(0x6a2230b3), SPH_C32(0x93b1a4ba), SPH_C32(0xd8290000), + SPH_C32(0xaa95002a), SPH_C32(0xf8f38000), SPH_C32(0x6ea20000), + SPH_C32(0x60b85097), SPH_C32(0x31743986), SPH_C32(0x8eae8ea1), + SPH_C32(0x66c49830) }, + { SPH_C32(0x7c950000), SPH_C32(0x11fd00ea), SPH_C32(0x51fa8000), + SPH_C32(0xf25b0000), SPH_C32(0xfc9f3a03), SPH_C32(0x8740de24), + SPH_C32(0xb9ff79f7), SPH_C32(0x85ac7e03), SPH_C32(0xe89e0000), + SPH_C32(0x4f45002a), SPH_C32(0x0c07e000), SPH_C32(0x2c660000), + SPH_C32(0x03006dfd), SPH_C32(0x49ceade6), SPH_C32(0xaf012f4b), + SPH_C32(0xd6618004) }, + { SPH_C32(0xd5dc0000), SPH_C32(0x28da0084), SPH_C32(0xdaa00000), + SPH_C32(0x7d240000), SPH_C32(0x4a8d736a), SPH_C32(0x8c028d8a), + SPH_C32(0x87fef24b), SPH_C32(0x90daf380), SPH_C32(0x2eae0000), + SPH_C32(0x55c70048), SPH_C32(0x98ec0000), SPH_C32(0x9a980000), + SPH_C32(0xa3ac239c), SPH_C32(0x5dfb4c6b), SPH_C32(0xa2806e7c), + SPH_C32(0x65c7dc2a) }, + { SPH_C32(0x53a50000), SPH_C32(0x17e30086), SPH_C32(0x3b3ae000), + SPH_C32(0xe5720000), SPH_C32(0xdfe81464), SPH_C32(0xc28a4560), + SPH_C32(0x5423bb0f), SPH_C32(0x86c72939), SPH_C32(0x1e190000), + SPH_C32(0xb0170048), SPH_C32(0x6c186000), SPH_C32(0xd85c0000), + SPH_C32(0xc0141ef6), SPH_C32(0x2541d80b), SPH_C32(0x832fcf96), + SPH_C32(0xd562c41e) }, + { SPH_C32(0xe56b0000), SPH_C32(0xcd0a0084), SPH_C32(0x2e546000), + SPH_C32(0x3fe00000), SPH_C32(0x29354e00), SPH_C32(0xf4b819ea), + SPH_C32(0xa65153a1), SPH_C32(0x207febb4), SPH_C32(0x98600000), + SPH_C32(0x8f2e004a), SPH_C32(0x8d828000), SPH_C32(0x400a0000), + SPH_C32(0x557179f8), SPH_C32(0x6bc910e1), SPH_C32(0x50f286d2), + SPH_C32(0xc37f1ea7) }, + { SPH_C32(0x63120000), SPH_C32(0xf2330086), SPH_C32(0xcfce8000), + SPH_C32(0xa7b60000), SPH_C32(0xbc50290e), SPH_C32(0xba30d100), + SPH_C32(0x758c1ae5), SPH_C32(0x3662310d), SPH_C32(0xa8d70000), + SPH_C32(0x6afe004a), SPH_C32(0x7976e000), SPH_C32(0x02ce0000), + SPH_C32(0x36c94492), SPH_C32(0x13738481), SPH_C32(0x715d2738), + SPH_C32(0x73da0693) }, + { SPH_C32(0xc1c50000), SPH_C32(0x0b1000b8), SPH_C32(0x8a7f0000), + SPH_C32(0x39920000), SPH_C32(0x51e114da), SPH_C32(0xb0f121ff), + SPH_C32(0xe618e2fb), SPH_C32(0x4b102800), SPH_C32(0xcded0000), + SPH_C32(0x6f89005c), SPH_C32(0x6a2a0000), SPH_C32(0x30d60000), + SPH_C32(0x78b2613a), SPH_C32(0x7890f27e), SPH_C32(0xb0bddf2a), + SPH_C32(0x5f8945fd) }, + { SPH_C32(0x47bc0000), SPH_C32(0x342900ba), SPH_C32(0x6be5e000), + SPH_C32(0xa1c40000), SPH_C32(0xc48473d4), SPH_C32(0xfe79e915), + SPH_C32(0x35c5abbf), SPH_C32(0x5d0df2b9), SPH_C32(0xfd5a0000), + SPH_C32(0x8a59005c), SPH_C32(0x9ede6000), SPH_C32(0x72120000), + SPH_C32(0x1b0a5c50), SPH_C32(0x002a661e), SPH_C32(0x91127ec0), + SPH_C32(0xef2c5dc9) }, + { SPH_C32(0xf1720000), SPH_C32(0xeec000b8), SPH_C32(0x7e8b6000), + SPH_C32(0x7b560000), SPH_C32(0x325929b0), SPH_C32(0xc84bb59f), + SPH_C32(0xc7b74311), SPH_C32(0xfbb53034), SPH_C32(0x7b230000), + SPH_C32(0xb560005e), SPH_C32(0x7f448000), SPH_C32(0xea440000), + SPH_C32(0x8e6f3b5e), SPH_C32(0x4ea2aef4), SPH_C32(0x42cf3784), + SPH_C32(0xf9318770) }, + { SPH_C32(0x770b0000), SPH_C32(0xd1f900ba), SPH_C32(0x9f118000), + SPH_C32(0xe3000000), SPH_C32(0xa73c4ebe), SPH_C32(0x86c37d75), + SPH_C32(0x146a0a55), SPH_C32(0xeda8ea8d), SPH_C32(0x4b940000), + SPH_C32(0x50b0005e), SPH_C32(0x8bb0e000), SPH_C32(0xa8800000), + SPH_C32(0xedd70634), SPH_C32(0x36183a94), SPH_C32(0x6360966e), + SPH_C32(0x49949f44) }, + { SPH_C32(0x369f0000), SPH_C32(0x12940090), SPH_C32(0x28660000), + SPH_C32(0xd76a0000), SPH_C32(0x919331cc), SPH_C32(0xa969339f), + SPH_C32(0x95c3431d), SPH_C32(0xaa946a57), SPH_C32(0xd9f40000), + SPH_C32(0x4c430060), SPH_C32(0x3af50000), SPH_C32(0x74600000), + SPH_C32(0x63de068a), SPH_C32(0x44635e0b), SPH_C32(0xd15bcf9a), + SPH_C32(0x84439e7d) }, + { SPH_C32(0xb0e60000), SPH_C32(0x2dad0092), SPH_C32(0xc9fce000), + SPH_C32(0x4f3c0000), SPH_C32(0x04f656c2), SPH_C32(0xe7e1fb75), + SPH_C32(0x461e0a59), SPH_C32(0xbc89b0ee), SPH_C32(0xe9430000), + SPH_C32(0xa9930060), SPH_C32(0xce016000), SPH_C32(0x36a40000), + SPH_C32(0x00663be0), SPH_C32(0x3cd9ca6b), SPH_C32(0xf0f46e70), + SPH_C32(0x34e68649) }, + { SPH_C32(0x06280000), SPH_C32(0xf7440090), SPH_C32(0xdc926000), + SPH_C32(0x95ae0000), SPH_C32(0xf22b0ca6), SPH_C32(0xd1d3a7ff), + SPH_C32(0xb46ce2f7), SPH_C32(0x1a317263), SPH_C32(0x6f3a0000), + SPH_C32(0x96aa0062), SPH_C32(0x2f9b8000), SPH_C32(0xaef20000), + SPH_C32(0x95035cee), SPH_C32(0x72510281), SPH_C32(0x23292734), + SPH_C32(0x22fb5cf0) }, + { SPH_C32(0x80510000), SPH_C32(0xc87d0092), SPH_C32(0x3d088000), + SPH_C32(0x0df80000), SPH_C32(0x674e6ba8), SPH_C32(0x9f5b6f15), + SPH_C32(0x67b1abb3), SPH_C32(0x0c2ca8da), SPH_C32(0x5f8d0000), + SPH_C32(0x737a0062), SPH_C32(0xdb6fe000), SPH_C32(0xec360000), + SPH_C32(0xf6bb6184), SPH_C32(0x0aeb96e1), SPH_C32(0x028686de), + SPH_C32(0x925e44c4) }, + { SPH_C32(0x22860000), SPH_C32(0x315e00ac), SPH_C32(0x78b90000), + SPH_C32(0x93dc0000), SPH_C32(0x8aff567c), SPH_C32(0x959a9fea), + SPH_C32(0xf42553ad), SPH_C32(0x715eb1d7), SPH_C32(0x3ab70000), + SPH_C32(0x760d0074), SPH_C32(0xc8330000), SPH_C32(0xde2e0000), + SPH_C32(0xb8c0442c), SPH_C32(0x6108e01e), SPH_C32(0xc3667ecc), + SPH_C32(0xbe0d07aa) }, + { SPH_C32(0xa4ff0000), SPH_C32(0x0e6700ae), SPH_C32(0x9923e000), + SPH_C32(0x0b8a0000), SPH_C32(0x1f9a3172), SPH_C32(0xdb125700), + SPH_C32(0x27f81ae9), SPH_C32(0x67436b6e), SPH_C32(0x0a000000), + SPH_C32(0x93dd0074), SPH_C32(0x3cc76000), SPH_C32(0x9cea0000), + SPH_C32(0xdb787946), SPH_C32(0x19b2747e), SPH_C32(0xe2c9df26), + SPH_C32(0x0ea81f9e) }, + { SPH_C32(0x12310000), SPH_C32(0xd48e00ac), SPH_C32(0x8c4d6000), + SPH_C32(0xd1180000), SPH_C32(0xe9476b16), SPH_C32(0xed200b8a), + SPH_C32(0xd58af247), SPH_C32(0xc1fba9e3), SPH_C32(0x8c790000), + SPH_C32(0xace40076), SPH_C32(0xdd5d8000), SPH_C32(0x04bc0000), + SPH_C32(0x4e1d1e48), SPH_C32(0x573abc94), SPH_C32(0x31149662), + SPH_C32(0x18b5c527) }, + { SPH_C32(0x94480000), SPH_C32(0xebb700ae), SPH_C32(0x6dd78000), + SPH_C32(0x494e0000), SPH_C32(0x7c220c18), SPH_C32(0xa3a8c360), + SPH_C32(0x0657bb03), SPH_C32(0xd7e6735a), SPH_C32(0xbcce0000), + SPH_C32(0x49340076), SPH_C32(0x29a9e000), SPH_C32(0x46780000), + SPH_C32(0x2da52322), SPH_C32(0x2f8028f4), SPH_C32(0x10bb3788), + SPH_C32(0xa810dd13) }, + { SPH_C32(0x818c0000), SPH_C32(0x2eab00d8), SPH_C32(0xff0e0000), + SPH_C32(0x173a0000), SPH_C32(0x64283db5), SPH_C32(0xea4c0898), + SPH_C32(0x3844ea88), SPH_C32(0xeeabae97), SPH_C32(0x92230000), + SPH_C32(0xa9fc0050), SPH_C32(0x816f0000), SPH_C32(0x4b930000), + SPH_C32(0x0db45b58), SPH_C32(0x1f5dd43d), SPH_C32(0xa292b44b), + SPH_C32(0x49fc8c64) }, + { SPH_C32(0x07f50000), SPH_C32(0x119200da), SPH_C32(0x1e94e000), + SPH_C32(0x8f6c0000), SPH_C32(0xf14d5abb), SPH_C32(0xa4c4c072), + SPH_C32(0xeb99a3cc), SPH_C32(0xf8b6742e), SPH_C32(0xa2940000), + SPH_C32(0x4c2c0050), SPH_C32(0x759b6000), SPH_C32(0x09570000), + SPH_C32(0x6e0c6632), SPH_C32(0x67e7405d), SPH_C32(0x833d15a1), + SPH_C32(0xf9599450) }, + { SPH_C32(0xb13b0000), SPH_C32(0xcb7b00d8), SPH_C32(0x0bfa6000), + SPH_C32(0x55fe0000), SPH_C32(0x079000df), SPH_C32(0x92f69cf8), + SPH_C32(0x19eb4b62), SPH_C32(0x5e0eb6a3), SPH_C32(0x24ed0000), + SPH_C32(0x73150052), SPH_C32(0x94018000), SPH_C32(0x91010000), + SPH_C32(0xfb69013c), SPH_C32(0x296f88b7), SPH_C32(0x50e05ce5), + SPH_C32(0xef444ee9) }, + { SPH_C32(0x37420000), SPH_C32(0xf44200da), SPH_C32(0xea608000), + SPH_C32(0xcda80000), SPH_C32(0x92f567d1), SPH_C32(0xdc7e5412), + SPH_C32(0xca360226), SPH_C32(0x48136c1a), SPH_C32(0x145a0000), + SPH_C32(0x96c50052), SPH_C32(0x60f5e000), SPH_C32(0xd3c50000), + SPH_C32(0x98d13c56), SPH_C32(0x51d51cd7), SPH_C32(0x714ffd0f), + SPH_C32(0x5fe156dd) }, + { SPH_C32(0x95950000), SPH_C32(0x0d6100e4), SPH_C32(0xafd10000), + SPH_C32(0x538c0000), SPH_C32(0x7f445a05), SPH_C32(0xd6bfa4ed), + SPH_C32(0x59a2fa38), SPH_C32(0x35617517), SPH_C32(0x71600000), + SPH_C32(0x93b20044), SPH_C32(0x73a90000), SPH_C32(0xe1dd0000), + SPH_C32(0xd6aa19fe), SPH_C32(0x3a366a28), SPH_C32(0xb0af051d), + SPH_C32(0x73b215b3) }, + { SPH_C32(0x13ec0000), SPH_C32(0x325800e6), SPH_C32(0x4e4be000), + SPH_C32(0xcbda0000), SPH_C32(0xea213d0b), SPH_C32(0x98376c07), + SPH_C32(0x8a7fb37c), SPH_C32(0x237cafae), SPH_C32(0x41d70000), + SPH_C32(0x76620044), SPH_C32(0x875d6000), SPH_C32(0xa3190000), + SPH_C32(0xb5122494), SPH_C32(0x428cfe48), SPH_C32(0x9100a4f7), + SPH_C32(0xc3170d87) }, + { SPH_C32(0xa5220000), SPH_C32(0xe8b100e4), SPH_C32(0x5b256000), + SPH_C32(0x11480000), SPH_C32(0x1cfc676f), SPH_C32(0xae05308d), + SPH_C32(0x780d5bd2), SPH_C32(0x85c46d23), SPH_C32(0xc7ae0000), + SPH_C32(0x495b0046), SPH_C32(0x66c78000), SPH_C32(0x3b4f0000), + SPH_C32(0x2077439a), SPH_C32(0x0c0436a2), SPH_C32(0x42ddedb3), + SPH_C32(0xd50ad73e) }, + { SPH_C32(0x235b0000), SPH_C32(0xd78800e6), SPH_C32(0xbabf8000), + SPH_C32(0x891e0000), SPH_C32(0x89990061), SPH_C32(0xe08df867), + SPH_C32(0xabd01296), SPH_C32(0x93d9b79a), SPH_C32(0xf7190000), + SPH_C32(0xac8b0046), SPH_C32(0x9233e000), SPH_C32(0x798b0000), + SPH_C32(0x43cf7ef0), SPH_C32(0x74bea2c2), SPH_C32(0x63724c59), + SPH_C32(0x65afcf0a) }, + { SPH_C32(0x62cf0000), SPH_C32(0x14e500cc), SPH_C32(0x0dc80000), + SPH_C32(0xbd740000), SPH_C32(0xbf367f13), SPH_C32(0xcf27b68d), + SPH_C32(0x2a795bde), SPH_C32(0xd4e53740), SPH_C32(0x65790000), + SPH_C32(0xb0780078), SPH_C32(0x23760000), SPH_C32(0xa56b0000), + SPH_C32(0xcdc67e4e), SPH_C32(0x06c5c65d), SPH_C32(0xd14915ad), + SPH_C32(0xa878ce33) }, + { SPH_C32(0xe4b60000), SPH_C32(0x2bdc00ce), SPH_C32(0xec52e000), + SPH_C32(0x25220000), SPH_C32(0x2a53181d), SPH_C32(0x81af7e67), + SPH_C32(0xf9a4129a), SPH_C32(0xc2f8edf9), SPH_C32(0x55ce0000), + SPH_C32(0x55a80078), SPH_C32(0xd7826000), SPH_C32(0xe7af0000), + SPH_C32(0xae7e4324), SPH_C32(0x7e7f523d), SPH_C32(0xf0e6b447), + SPH_C32(0x18ddd607) }, + { SPH_C32(0x52780000), SPH_C32(0xf13500cc), SPH_C32(0xf93c6000), + SPH_C32(0xffb00000), SPH_C32(0xdc8e4279), SPH_C32(0xb79d22ed), + SPH_C32(0x0bd6fa34), SPH_C32(0x64402f74), SPH_C32(0xd3b70000), + SPH_C32(0x6a91007a), SPH_C32(0x36188000), SPH_C32(0x7ff90000), + SPH_C32(0x3b1b242a), SPH_C32(0x30f79ad7), SPH_C32(0x233bfd03), + SPH_C32(0x0ec00cbe) }, + { SPH_C32(0xd4010000), SPH_C32(0xce0c00ce), SPH_C32(0x18a68000), + SPH_C32(0x67e60000), SPH_C32(0x49eb2577), SPH_C32(0xf915ea07), + SPH_C32(0xd80bb370), SPH_C32(0x725df5cd), SPH_C32(0xe3000000), + SPH_C32(0x8f41007a), SPH_C32(0xc2ece000), SPH_C32(0x3d3d0000), + SPH_C32(0x58a31940), SPH_C32(0x484d0eb7), SPH_C32(0x02945ce9), + SPH_C32(0xbe65148a) }, + { SPH_C32(0x76d60000), SPH_C32(0x372f00f0), SPH_C32(0x5d170000), + SPH_C32(0xf9c20000), SPH_C32(0xa45a18a3), SPH_C32(0xf3d41af8), + SPH_C32(0x4b9f4b6e), SPH_C32(0x0f2fecc0), SPH_C32(0x863a0000), + SPH_C32(0x8a36006c), SPH_C32(0xd1b00000), SPH_C32(0x0f250000), + SPH_C32(0x16d83ce8), SPH_C32(0x23ae7848), SPH_C32(0xc374a4fb), + SPH_C32(0x923657e4) }, + { SPH_C32(0xf0af0000), SPH_C32(0x081600f2), SPH_C32(0xbc8de000), + SPH_C32(0x61940000), SPH_C32(0x313f7fad), SPH_C32(0xbd5cd212), + SPH_C32(0x9842022a), SPH_C32(0x19323679), SPH_C32(0xb68d0000), + SPH_C32(0x6fe6006c), SPH_C32(0x25446000), SPH_C32(0x4de10000), + SPH_C32(0x75600182), SPH_C32(0x5b14ec28), SPH_C32(0xe2db0511), + SPH_C32(0x22934fd0) }, + { SPH_C32(0x46610000), SPH_C32(0xd2ff00f0), SPH_C32(0xa9e36000), + SPH_C32(0xbb060000), SPH_C32(0xc7e225c9), SPH_C32(0x8b6e8e98), + SPH_C32(0x6a30ea84), SPH_C32(0xbf8af4f4), SPH_C32(0x30f40000), + SPH_C32(0x50df006e), SPH_C32(0xc4de8000), SPH_C32(0xd5b70000), + SPH_C32(0xe005668c), SPH_C32(0x159c24c2), SPH_C32(0x31064c55), + SPH_C32(0x348e9569) }, + { SPH_C32(0xc0180000), SPH_C32(0xedc600f2), SPH_C32(0x48798000), + SPH_C32(0x23500000), SPH_C32(0x528742c7), SPH_C32(0xc5e64672), + SPH_C32(0xb9eda3c0), SPH_C32(0xa9972e4d), SPH_C32(0x00430000), + SPH_C32(0xb50f006e), SPH_C32(0x302ae000), SPH_C32(0x97730000), + SPH_C32(0x83bd5be6), SPH_C32(0x6d26b0a2), SPH_C32(0x10a9edbf), + SPH_C32(0x842b8d5d) }, + { SPH_C32(0xc6730000), SPH_C32(0xaf8d000c), SPH_C32(0xa4c10000), + SPH_C32(0x218d0000), SPH_C32(0x23111587), SPH_C32(0x7913512f), + SPH_C32(0x1d28ac88), SPH_C32(0x378dd173), SPH_C32(0xaf220000), + SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), SPH_C32(0x8da20000), + SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), SPH_C32(0x9ac484f4), + SPH_C32(0x8b6c72bd) }, + { SPH_C32(0x400a0000), SPH_C32(0x90b4000e), SPH_C32(0x455be000), + SPH_C32(0xb9db0000), SPH_C32(0xb6747289), SPH_C32(0x379b99c5), + SPH_C32(0xcef5e5cc), SPH_C32(0x21900bca), SPH_C32(0x9f950000), + SPH_C32(0x9ebc0090), SPH_C32(0x93166000), SPH_C32(0xcf660000), + SPH_C32(0xa43c2343), SPH_C32(0xcf0dd093), SPH_C32(0xbb6b251e), + SPH_C32(0x3bc96a89) }, + { SPH_C32(0xf6c40000), SPH_C32(0x4a5d000c), SPH_C32(0x50356000), + SPH_C32(0x63490000), SPH_C32(0x40a928ed), SPH_C32(0x01a9c54f), + SPH_C32(0x3c870d62), SPH_C32(0x8728c947), SPH_C32(0x19ec0000), + SPH_C32(0xa1850092), SPH_C32(0x728c8000), SPH_C32(0x57300000), + SPH_C32(0x3159444d), SPH_C32(0x81851879), SPH_C32(0x68b66c5a), + SPH_C32(0x2dd4b030) }, + { SPH_C32(0x70bd0000), SPH_C32(0x7564000e), SPH_C32(0xb1af8000), + SPH_C32(0xfb1f0000), SPH_C32(0xd5cc4fe3), SPH_C32(0x4f210da5), + SPH_C32(0xef5a4426), SPH_C32(0x913513fe), SPH_C32(0x295b0000), + SPH_C32(0x44550092), SPH_C32(0x8678e000), SPH_C32(0x15f40000), + SPH_C32(0x52e17927), SPH_C32(0xf93f8c19), SPH_C32(0x4919cdb0), + SPH_C32(0x9d71a804) }, + { SPH_C32(0xd26a0000), SPH_C32(0x8c470030), SPH_C32(0xf41e0000), + SPH_C32(0x653b0000), SPH_C32(0x387d7237), SPH_C32(0x45e0fd5a), + SPH_C32(0x7ccebc38), SPH_C32(0xec470af3), SPH_C32(0x4c610000), + SPH_C32(0x41220084), SPH_C32(0x95240000), SPH_C32(0x27ec0000), + SPH_C32(0x1c9a5c8f), SPH_C32(0x92dcfae6), SPH_C32(0x88f935a2), + SPH_C32(0xb122eb6a) }, + { SPH_C32(0x54130000), SPH_C32(0xb37e0032), SPH_C32(0x1584e000), + SPH_C32(0xfd6d0000), SPH_C32(0xad181539), SPH_C32(0x0b6835b0), + SPH_C32(0xaf13f57c), SPH_C32(0xfa5ad04a), SPH_C32(0x7cd60000), + SPH_C32(0xa4f20084), SPH_C32(0x61d06000), SPH_C32(0x65280000), + SPH_C32(0x7f2261e5), SPH_C32(0xea666e86), SPH_C32(0xa9569448), + SPH_C32(0x0187f35e) }, + { SPH_C32(0xe2dd0000), SPH_C32(0x69970030), SPH_C32(0x00ea6000), + SPH_C32(0x27ff0000), SPH_C32(0x5bc54f5d), SPH_C32(0x3d5a693a), + SPH_C32(0x5d611dd2), SPH_C32(0x5ce212c7), SPH_C32(0xfaaf0000), + SPH_C32(0x9bcb0086), SPH_C32(0x804a8000), SPH_C32(0xfd7e0000), + SPH_C32(0xea4706eb), SPH_C32(0xa4eea66c), SPH_C32(0x7a8bdd0c), + SPH_C32(0x179a29e7) }, + { SPH_C32(0x64a40000), SPH_C32(0x56ae0032), SPH_C32(0xe1708000), + SPH_C32(0xbfa90000), SPH_C32(0xcea02853), SPH_C32(0x73d2a1d0), + SPH_C32(0x8ebc5496), SPH_C32(0x4affc87e), SPH_C32(0xca180000), + SPH_C32(0x7e1b0086), SPH_C32(0x74bee000), SPH_C32(0xbfba0000), + SPH_C32(0x89ff3b81), SPH_C32(0xdc54320c), SPH_C32(0x5b247ce6), + SPH_C32(0xa73f31d3) }, + { SPH_C32(0x25300000), SPH_C32(0x95c30018), SPH_C32(0x56070000), + SPH_C32(0x8bc30000), SPH_C32(0xf80f5721), SPH_C32(0x5c78ef3a), + SPH_C32(0x0f151dde), SPH_C32(0x0dc348a4), SPH_C32(0x58780000), + SPH_C32(0x62e800b8), SPH_C32(0xc5fb0000), SPH_C32(0x635a0000), + SPH_C32(0x07f63b3f), SPH_C32(0xae2f5693), SPH_C32(0xe91f2512), + SPH_C32(0x6ae830ea) }, + { SPH_C32(0xa3490000), SPH_C32(0xaafa001a), SPH_C32(0xb79de000), + SPH_C32(0x13950000), SPH_C32(0x6d6a302f), SPH_C32(0x12f027d0), + SPH_C32(0xdcc8549a), SPH_C32(0x1bde921d), SPH_C32(0x68cf0000), + SPH_C32(0x873800b8), SPH_C32(0x310f6000), SPH_C32(0x219e0000), + SPH_C32(0x644e0655), SPH_C32(0xd695c2f3), SPH_C32(0xc8b084f8), + SPH_C32(0xda4d28de) }, + { SPH_C32(0x15870000), SPH_C32(0x70130018), SPH_C32(0xa2f36000), + SPH_C32(0xc9070000), SPH_C32(0x9bb76a4b), SPH_C32(0x24c27b5a), + SPH_C32(0x2ebabc34), SPH_C32(0xbd665090), SPH_C32(0xeeb60000), + SPH_C32(0xb80100ba), SPH_C32(0xd0958000), SPH_C32(0xb9c80000), + SPH_C32(0xf12b615b), SPH_C32(0x981d0a19), SPH_C32(0x1b6dcdbc), + SPH_C32(0xcc50f267) }, + { SPH_C32(0x93fe0000), SPH_C32(0x4f2a001a), SPH_C32(0x43698000), + SPH_C32(0x51510000), SPH_C32(0x0ed20d45), SPH_C32(0x6a4ab3b0), + SPH_C32(0xfd67f570), SPH_C32(0xab7b8a29), SPH_C32(0xde010000), + SPH_C32(0x5dd100ba), SPH_C32(0x2461e000), SPH_C32(0xfb0c0000), + SPH_C32(0x92935c31), SPH_C32(0xe0a79e79), SPH_C32(0x3ac26c56), + SPH_C32(0x7cf5ea53) }, + { SPH_C32(0x31290000), SPH_C32(0xb6090024), SPH_C32(0x06d80000), + SPH_C32(0xcf750000), SPH_C32(0xe3633091), SPH_C32(0x608b434f), + SPH_C32(0x6ef30d6e), SPH_C32(0xd6099324), SPH_C32(0xbb3b0000), + SPH_C32(0x58a600ac), SPH_C32(0x373d0000), SPH_C32(0xc9140000), + SPH_C32(0xdce87999), SPH_C32(0x8b44e886), SPH_C32(0xfb229444), + SPH_C32(0x50a6a93d) }, + { SPH_C32(0xb7500000), SPH_C32(0x89300026), SPH_C32(0xe742e000), + SPH_C32(0x57230000), SPH_C32(0x7606579f), SPH_C32(0x2e038ba5), + SPH_C32(0xbd2e442a), SPH_C32(0xc014499d), SPH_C32(0x8b8c0000), + SPH_C32(0xbd7600ac), SPH_C32(0xc3c96000), SPH_C32(0x8bd00000), + SPH_C32(0xbf5044f3), SPH_C32(0xf3fe7ce6), SPH_C32(0xda8d35ae), + SPH_C32(0xe003b109) }, + { SPH_C32(0x019e0000), SPH_C32(0x53d90024), SPH_C32(0xf22c6000), + SPH_C32(0x8db10000), SPH_C32(0x80db0dfb), SPH_C32(0x1831d72f), + SPH_C32(0x4f5cac84), SPH_C32(0x66ac8b10), SPH_C32(0x0df50000), + SPH_C32(0x824f00ae), SPH_C32(0x22538000), SPH_C32(0x13860000), + SPH_C32(0x2a3523fd), SPH_C32(0xbd76b40c), SPH_C32(0x09507cea), + SPH_C32(0xf61e6bb0) }, + { SPH_C32(0x87e70000), SPH_C32(0x6ce00026), SPH_C32(0x13b68000), + SPH_C32(0x15e70000), SPH_C32(0x15be6af5), SPH_C32(0x56b91fc5), + SPH_C32(0x9c81e5c0), SPH_C32(0x70b151a9), SPH_C32(0x3d420000), + SPH_C32(0x679f00ae), SPH_C32(0xd6a7e000), SPH_C32(0x51420000), + SPH_C32(0x498d1e97), SPH_C32(0xc5cc206c), SPH_C32(0x28ffdd00), + SPH_C32(0x46bb7384) }, + { SPH_C32(0x92230000), SPH_C32(0xa9fc0050), SPH_C32(0x816f0000), + SPH_C32(0x4b930000), SPH_C32(0x0db45b58), SPH_C32(0x1f5dd43d), + SPH_C32(0xa292b44b), SPH_C32(0x49fc8c64), SPH_C32(0x13af0000), + SPH_C32(0x87570088), SPH_C32(0x7e610000), SPH_C32(0x5ca90000), + SPH_C32(0x699c66ed), SPH_C32(0xf511dca5), SPH_C32(0x9ad65ec3), + SPH_C32(0xa75722f3) }, + { SPH_C32(0x145a0000), SPH_C32(0x96c50052), SPH_C32(0x60f5e000), + SPH_C32(0xd3c50000), SPH_C32(0x98d13c56), SPH_C32(0x51d51cd7), + SPH_C32(0x714ffd0f), SPH_C32(0x5fe156dd), SPH_C32(0x23180000), + SPH_C32(0x62870088), SPH_C32(0x8a956000), SPH_C32(0x1e6d0000), + SPH_C32(0x0a245b87), SPH_C32(0x8dab48c5), SPH_C32(0xbb79ff29), + SPH_C32(0x17f23ac7) }, + { SPH_C32(0xa2940000), SPH_C32(0x4c2c0050), SPH_C32(0x759b6000), + SPH_C32(0x09570000), SPH_C32(0x6e0c6632), SPH_C32(0x67e7405d), + SPH_C32(0x833d15a1), SPH_C32(0xf9599450), SPH_C32(0xa5610000), + SPH_C32(0x5dbe008a), SPH_C32(0x6b0f8000), SPH_C32(0x863b0000), + SPH_C32(0x9f413c89), SPH_C32(0xc323802f), SPH_C32(0x68a4b66d), + SPH_C32(0x01efe07e) }, + { SPH_C32(0x24ed0000), SPH_C32(0x73150052), SPH_C32(0x94018000), + SPH_C32(0x91010000), SPH_C32(0xfb69013c), SPH_C32(0x296f88b7), + SPH_C32(0x50e05ce5), SPH_C32(0xef444ee9), SPH_C32(0x95d60000), + SPH_C32(0xb86e008a), SPH_C32(0x9ffbe000), SPH_C32(0xc4ff0000), + SPH_C32(0xfcf901e3), SPH_C32(0xbb99144f), SPH_C32(0x490b1787), + SPH_C32(0xb14af84a) }, + { SPH_C32(0x863a0000), SPH_C32(0x8a36006c), SPH_C32(0xd1b00000), + SPH_C32(0x0f250000), SPH_C32(0x16d83ce8), SPH_C32(0x23ae7848), + SPH_C32(0xc374a4fb), SPH_C32(0x923657e4), SPH_C32(0xf0ec0000), + SPH_C32(0xbd19009c), SPH_C32(0x8ca70000), SPH_C32(0xf6e70000), + SPH_C32(0xb282244b), SPH_C32(0xd07a62b0), SPH_C32(0x88ebef95), + SPH_C32(0x9d19bb24) }, + { SPH_C32(0x00430000), SPH_C32(0xb50f006e), SPH_C32(0x302ae000), + SPH_C32(0x97730000), SPH_C32(0x83bd5be6), SPH_C32(0x6d26b0a2), + SPH_C32(0x10a9edbf), SPH_C32(0x842b8d5d), SPH_C32(0xc05b0000), + SPH_C32(0x58c9009c), SPH_C32(0x78536000), SPH_C32(0xb4230000), + SPH_C32(0xd13a1921), SPH_C32(0xa8c0f6d0), SPH_C32(0xa9444e7f), + SPH_C32(0x2dbca310) }, + { SPH_C32(0xb68d0000), SPH_C32(0x6fe6006c), SPH_C32(0x25446000), + SPH_C32(0x4de10000), SPH_C32(0x75600182), SPH_C32(0x5b14ec28), + SPH_C32(0xe2db0511), SPH_C32(0x22934fd0), SPH_C32(0x46220000), + SPH_C32(0x67f0009e), SPH_C32(0x99c98000), SPH_C32(0x2c750000), + SPH_C32(0x445f7e2f), SPH_C32(0xe6483e3a), SPH_C32(0x7a99073b), + SPH_C32(0x3ba179a9) }, + { SPH_C32(0x30f40000), SPH_C32(0x50df006e), SPH_C32(0xc4de8000), + SPH_C32(0xd5b70000), SPH_C32(0xe005668c), SPH_C32(0x159c24c2), + SPH_C32(0x31064c55), SPH_C32(0x348e9569), SPH_C32(0x76950000), + SPH_C32(0x8220009e), SPH_C32(0x6d3de000), SPH_C32(0x6eb10000), + SPH_C32(0x27e74345), SPH_C32(0x9ef2aa5a), SPH_C32(0x5b36a6d1), + SPH_C32(0x8b04619d) }, + { SPH_C32(0x71600000), SPH_C32(0x93b20044), SPH_C32(0x73a90000), + SPH_C32(0xe1dd0000), SPH_C32(0xd6aa19fe), SPH_C32(0x3a366a28), + SPH_C32(0xb0af051d), SPH_C32(0x73b215b3), SPH_C32(0xe4f50000), + SPH_C32(0x9ed300a0), SPH_C32(0xdc780000), SPH_C32(0xb2510000), + SPH_C32(0xa9ee43fb), SPH_C32(0xec89cec5), SPH_C32(0xe90dff25), + SPH_C32(0x46d360a4) }, + { SPH_C32(0xf7190000), SPH_C32(0xac8b0046), SPH_C32(0x9233e000), + SPH_C32(0x798b0000), SPH_C32(0x43cf7ef0), SPH_C32(0x74bea2c2), + SPH_C32(0x63724c59), SPH_C32(0x65afcf0a), SPH_C32(0xd4420000), + SPH_C32(0x7b0300a0), SPH_C32(0x288c6000), SPH_C32(0xf0950000), + SPH_C32(0xca567e91), SPH_C32(0x94335aa5), SPH_C32(0xc8a25ecf), + SPH_C32(0xf6767890) }, + { SPH_C32(0x41d70000), SPH_C32(0x76620044), SPH_C32(0x875d6000), + SPH_C32(0xa3190000), SPH_C32(0xb5122494), SPH_C32(0x428cfe48), + SPH_C32(0x9100a4f7), SPH_C32(0xc3170d87), SPH_C32(0x523b0000), + SPH_C32(0x443a00a2), SPH_C32(0xc9168000), SPH_C32(0x68c30000), + SPH_C32(0x5f33199f), SPH_C32(0xdabb924f), SPH_C32(0x1b7f178b), + SPH_C32(0xe06ba229) }, + { SPH_C32(0xc7ae0000), SPH_C32(0x495b0046), SPH_C32(0x66c78000), + SPH_C32(0x3b4f0000), SPH_C32(0x2077439a), SPH_C32(0x0c0436a2), + SPH_C32(0x42ddedb3), SPH_C32(0xd50ad73e), SPH_C32(0x628c0000), + SPH_C32(0xa1ea00a2), SPH_C32(0x3de2e000), SPH_C32(0x2a070000), + SPH_C32(0x3c8b24f5), SPH_C32(0xa201062f), SPH_C32(0x3ad0b661), + SPH_C32(0x50ceba1d) }, + { SPH_C32(0x65790000), SPH_C32(0xb0780078), SPH_C32(0x23760000), + SPH_C32(0xa56b0000), SPH_C32(0xcdc67e4e), SPH_C32(0x06c5c65d), + SPH_C32(0xd14915ad), SPH_C32(0xa878ce33), SPH_C32(0x07b60000), + SPH_C32(0xa49d00b4), SPH_C32(0x2ebe0000), SPH_C32(0x181f0000), + SPH_C32(0x72f0015d), SPH_C32(0xc9e270d0), SPH_C32(0xfb304e73), + SPH_C32(0x7c9df973) }, + { SPH_C32(0xe3000000), SPH_C32(0x8f41007a), SPH_C32(0xc2ece000), + SPH_C32(0x3d3d0000), SPH_C32(0x58a31940), SPH_C32(0x484d0eb7), + SPH_C32(0x02945ce9), SPH_C32(0xbe65148a), SPH_C32(0x37010000), + SPH_C32(0x414d00b4), SPH_C32(0xda4a6000), SPH_C32(0x5adb0000), + SPH_C32(0x11483c37), SPH_C32(0xb158e4b0), SPH_C32(0xda9fef99), + SPH_C32(0xcc38e147) }, + { SPH_C32(0x55ce0000), SPH_C32(0x55a80078), SPH_C32(0xd7826000), + SPH_C32(0xe7af0000), SPH_C32(0xae7e4324), SPH_C32(0x7e7f523d), + SPH_C32(0xf0e6b447), SPH_C32(0x18ddd607), SPH_C32(0xb1780000), + SPH_C32(0x7e7400b6), SPH_C32(0x3bd08000), SPH_C32(0xc28d0000), + SPH_C32(0x842d5b39), SPH_C32(0xffd02c5a), SPH_C32(0x0942a6dd), + SPH_C32(0xda253bfe) }, + { SPH_C32(0xd3b70000), SPH_C32(0x6a91007a), SPH_C32(0x36188000), + SPH_C32(0x7ff90000), SPH_C32(0x3b1b242a), SPH_C32(0x30f79ad7), + SPH_C32(0x233bfd03), SPH_C32(0x0ec00cbe), SPH_C32(0x81cf0000), + SPH_C32(0x9ba400b6), SPH_C32(0xcf24e000), SPH_C32(0x80490000), + SPH_C32(0xe7956653), SPH_C32(0x876ab83a), SPH_C32(0x28ed0737), + SPH_C32(0x6a8023ca) }, + { SPH_C32(0x7afe0000), SPH_C32(0x53b60014), SPH_C32(0xbd420000), + SPH_C32(0xf0860000), SPH_C32(0x8d096d43), SPH_C32(0x3bb5c979), + SPH_C32(0x1d3a76bf), SPH_C32(0x1bb6813d), SPH_C32(0x47ff0000), + SPH_C32(0x812600d4), SPH_C32(0x5bcf0000), SPH_C32(0x36b70000), + SPH_C32(0x47392832), SPH_C32(0x935f59b7), SPH_C32(0x256c4600), + SPH_C32(0xd9267fe4) }, + { SPH_C32(0xfc870000), SPH_C32(0x6c8f0016), SPH_C32(0x5cd8e000), + SPH_C32(0x68d00000), SPH_C32(0x186c0a4d), SPH_C32(0x753d0193), + SPH_C32(0xcee73ffb), SPH_C32(0x0dab5b84), SPH_C32(0x77480000), + SPH_C32(0x64f600d4), SPH_C32(0xaf3b6000), SPH_C32(0x74730000), + SPH_C32(0x24811558), SPH_C32(0xebe5cdd7), SPH_C32(0x04c3e7ea), + SPH_C32(0x698367d0) }, + { SPH_C32(0x4a490000), SPH_C32(0xb6660014), SPH_C32(0x49b66000), + SPH_C32(0xb2420000), SPH_C32(0xeeb15029), SPH_C32(0x430f5d19), + SPH_C32(0x3c95d755), SPH_C32(0xab139909), SPH_C32(0xf1310000), + SPH_C32(0x5bcf00d6), SPH_C32(0x4ea18000), SPH_C32(0xec250000), + SPH_C32(0xb1e47256), SPH_C32(0xa56d053d), SPH_C32(0xd71eaeae), + SPH_C32(0x7f9ebd69) }, + { SPH_C32(0xcc300000), SPH_C32(0x895f0016), SPH_C32(0xa82c8000), + SPH_C32(0x2a140000), SPH_C32(0x7bd43727), SPH_C32(0x0d8795f3), + SPH_C32(0xef489e11), SPH_C32(0xbd0e43b0), SPH_C32(0xc1860000), + SPH_C32(0xbe1f00d6), SPH_C32(0xba55e000), SPH_C32(0xaee10000), + SPH_C32(0xd25c4f3c), SPH_C32(0xddd7915d), SPH_C32(0xf6b10f44), + SPH_C32(0xcf3ba55d) }, + { SPH_C32(0x6ee70000), SPH_C32(0x707c0028), SPH_C32(0xed9d0000), + SPH_C32(0xb4300000), SPH_C32(0x96650af3), SPH_C32(0x0746650c), + SPH_C32(0x7cdc660f), SPH_C32(0xc07c5abd), SPH_C32(0xa4bc0000), + SPH_C32(0xbb6800c0), SPH_C32(0xa9090000), SPH_C32(0x9cf90000), + SPH_C32(0x9c276a94), SPH_C32(0xb634e7a2), SPH_C32(0x3751f756), + SPH_C32(0xe368e633) }, + { SPH_C32(0xe89e0000), SPH_C32(0x4f45002a), SPH_C32(0x0c07e000), + SPH_C32(0x2c660000), SPH_C32(0x03006dfd), SPH_C32(0x49ceade6), + SPH_C32(0xaf012f4b), SPH_C32(0xd6618004), SPH_C32(0x940b0000), + SPH_C32(0x5eb800c0), SPH_C32(0x5dfd6000), SPH_C32(0xde3d0000), + SPH_C32(0xff9f57fe), SPH_C32(0xce8e73c2), SPH_C32(0x16fe56bc), + SPH_C32(0x53cdfe07) }, + { SPH_C32(0x5e500000), SPH_C32(0x95ac0028), SPH_C32(0x19696000), + SPH_C32(0xf6f40000), SPH_C32(0xf5dd3799), SPH_C32(0x7ffcf16c), + SPH_C32(0x5d73c7e5), SPH_C32(0x70d94289), SPH_C32(0x12720000), + SPH_C32(0x618100c2), SPH_C32(0xbc678000), SPH_C32(0x466b0000), + SPH_C32(0x6afa30f0), SPH_C32(0x8006bb28), SPH_C32(0xc5231ff8), + SPH_C32(0x45d024be) }, + { SPH_C32(0xd8290000), SPH_C32(0xaa95002a), SPH_C32(0xf8f38000), + SPH_C32(0x6ea20000), SPH_C32(0x60b85097), SPH_C32(0x31743986), + SPH_C32(0x8eae8ea1), SPH_C32(0x66c49830), SPH_C32(0x22c50000), + SPH_C32(0x845100c2), SPH_C32(0x4893e000), SPH_C32(0x04af0000), + SPH_C32(0x09420d9a), SPH_C32(0xf8bc2f48), SPH_C32(0xe48cbe12), + SPH_C32(0xf5753c8a) }, + { SPH_C32(0x99bd0000), SPH_C32(0x69f80000), SPH_C32(0x4f840000), + SPH_C32(0x5ac80000), SPH_C32(0x56172fe5), SPH_C32(0x1ede776c), + SPH_C32(0x0f07c7e9), SPH_C32(0x21f818ea), SPH_C32(0xb0a50000), + SPH_C32(0x98a200fc), SPH_C32(0xf9d60000), SPH_C32(0xd84f0000), + SPH_C32(0x874b0d24), SPH_C32(0x8ac74bd7), SPH_C32(0x56b7e7e6), + SPH_C32(0x38a23db3) }, + { SPH_C32(0x1fc40000), SPH_C32(0x56c10002), SPH_C32(0xae1ee000), + SPH_C32(0xc29e0000), SPH_C32(0xc37248eb), SPH_C32(0x5056bf86), + SPH_C32(0xdcda8ead), SPH_C32(0x37e5c253), SPH_C32(0x80120000), + SPH_C32(0x7d7200fc), SPH_C32(0x0d226000), SPH_C32(0x9a8b0000), + SPH_C32(0xe4f3304e), SPH_C32(0xf27ddfb7), SPH_C32(0x7718460c), + SPH_C32(0x88072587) }, + { SPH_C32(0xa90a0000), SPH_C32(0x8c280000), SPH_C32(0xbb706000), + SPH_C32(0x180c0000), SPH_C32(0x35af128f), SPH_C32(0x6664e30c), + SPH_C32(0x2ea86603), SPH_C32(0x915d00de), SPH_C32(0x066b0000), + SPH_C32(0x424b00fe), SPH_C32(0xecb88000), SPH_C32(0x02dd0000), + SPH_C32(0x71965740), SPH_C32(0xbcf5175d), SPH_C32(0xa4c50f48), + SPH_C32(0x9e1aff3e) }, + { SPH_C32(0x2f730000), SPH_C32(0xb3110002), SPH_C32(0x5aea8000), + SPH_C32(0x805a0000), SPH_C32(0xa0ca7581), SPH_C32(0x28ec2be6), + SPH_C32(0xfd752f47), SPH_C32(0x8740da67), SPH_C32(0x36dc0000), + SPH_C32(0xa79b00fe), SPH_C32(0x184ce000), SPH_C32(0x40190000), + SPH_C32(0x122e6a2a), SPH_C32(0xc44f833d), SPH_C32(0x856aaea2), + SPH_C32(0x2ebfe70a) }, + { SPH_C32(0x8da40000), SPH_C32(0x4a32003c), SPH_C32(0x1f5b0000), + SPH_C32(0x1e7e0000), SPH_C32(0x4d7b4855), SPH_C32(0x222ddb19), + SPH_C32(0x6ee1d759), SPH_C32(0xfa32c36a), SPH_C32(0x53e60000), + SPH_C32(0xa2ec00e8), SPH_C32(0x0b100000), SPH_C32(0x72010000), + SPH_C32(0x5c554f82), SPH_C32(0xafacf5c2), SPH_C32(0x448a56b0), + SPH_C32(0x02eca464) }, + { SPH_C32(0x0bdd0000), SPH_C32(0x750b003e), SPH_C32(0xfec1e000), + SPH_C32(0x86280000), SPH_C32(0xd81e2f5b), SPH_C32(0x6ca513f3), + SPH_C32(0xbd3c9e1d), SPH_C32(0xec2f19d3), SPH_C32(0x63510000), + SPH_C32(0x473c00e8), SPH_C32(0xffe46000), SPH_C32(0x30c50000), + SPH_C32(0x3fed72e8), SPH_C32(0xd71661a2), SPH_C32(0x6525f75a), + SPH_C32(0xb249bc50) }, + { SPH_C32(0xbd130000), SPH_C32(0xafe2003c), SPH_C32(0xebaf6000), + SPH_C32(0x5cba0000), SPH_C32(0x2ec3753f), SPH_C32(0x5a974f79), + SPH_C32(0x4f4e76b3), SPH_C32(0x4a97db5e), SPH_C32(0xe5280000), + SPH_C32(0x780500ea), SPH_C32(0x1e7e8000), SPH_C32(0xa8930000), + SPH_C32(0xaa8815e6), SPH_C32(0x999ea948), SPH_C32(0xb6f8be1e), + SPH_C32(0xa45466e9) }, + { SPH_C32(0x3b6a0000), SPH_C32(0x90db003e), SPH_C32(0x0a358000), + SPH_C32(0xc4ec0000), SPH_C32(0xbba61231), SPH_C32(0x141f8793), + SPH_C32(0x9c933ff7), SPH_C32(0x5c8a01e7), SPH_C32(0xd59f0000), + SPH_C32(0x9dd500ea), SPH_C32(0xea8ae000), SPH_C32(0xea570000), + SPH_C32(0xc930288c), SPH_C32(0xe1243d28), SPH_C32(0x97571ff4), + SPH_C32(0x14f17edd) }, + { SPH_C32(0x2eae0000), SPH_C32(0x55c70048), SPH_C32(0x98ec0000), + SPH_C32(0x9a980000), SPH_C32(0xa3ac239c), SPH_C32(0x5dfb4c6b), + SPH_C32(0xa2806e7c), SPH_C32(0x65c7dc2a), SPH_C32(0xfb720000), + SPH_C32(0x7d1d00cc), SPH_C32(0x424c0000), SPH_C32(0xe7bc0000), + SPH_C32(0xe92150f6), SPH_C32(0xd1f9c1e1), SPH_C32(0x257e9c37), + SPH_C32(0xf51d2faa) }, + { SPH_C32(0xa8d70000), SPH_C32(0x6afe004a), SPH_C32(0x7976e000), + SPH_C32(0x02ce0000), SPH_C32(0x36c94492), SPH_C32(0x13738481), + SPH_C32(0x715d2738), SPH_C32(0x73da0693), SPH_C32(0xcbc50000), + SPH_C32(0x98cd00cc), SPH_C32(0xb6b86000), SPH_C32(0xa5780000), + SPH_C32(0x8a996d9c), SPH_C32(0xa9435581), SPH_C32(0x04d13ddd), + SPH_C32(0x45b8379e) }, + { SPH_C32(0x1e190000), SPH_C32(0xb0170048), SPH_C32(0x6c186000), + SPH_C32(0xd85c0000), SPH_C32(0xc0141ef6), SPH_C32(0x2541d80b), + SPH_C32(0x832fcf96), SPH_C32(0xd562c41e), SPH_C32(0x4dbc0000), + SPH_C32(0xa7f400ce), SPH_C32(0x57228000), SPH_C32(0x3d2e0000), + SPH_C32(0x1ffc0a92), SPH_C32(0xe7cb9d6b), SPH_C32(0xd70c7499), + SPH_C32(0x53a5ed27) }, + { SPH_C32(0x98600000), SPH_C32(0x8f2e004a), SPH_C32(0x8d828000), + SPH_C32(0x400a0000), SPH_C32(0x557179f8), SPH_C32(0x6bc910e1), + SPH_C32(0x50f286d2), SPH_C32(0xc37f1ea7), SPH_C32(0x7d0b0000), + SPH_C32(0x422400ce), SPH_C32(0xa3d6e000), SPH_C32(0x7fea0000), + SPH_C32(0x7c4437f8), SPH_C32(0x9f71090b), SPH_C32(0xf6a3d573), + SPH_C32(0xe300f513) }, + { SPH_C32(0x3ab70000), SPH_C32(0x760d0074), SPH_C32(0xc8330000), + SPH_C32(0xde2e0000), SPH_C32(0xb8c0442c), SPH_C32(0x6108e01e), + SPH_C32(0xc3667ecc), SPH_C32(0xbe0d07aa), SPH_C32(0x18310000), + SPH_C32(0x475300d8), SPH_C32(0xb08a0000), SPH_C32(0x4df20000), + SPH_C32(0x323f1250), SPH_C32(0xf4927ff4), SPH_C32(0x37432d61), + SPH_C32(0xcf53b67d) }, + { SPH_C32(0xbcce0000), SPH_C32(0x49340076), SPH_C32(0x29a9e000), + SPH_C32(0x46780000), SPH_C32(0x2da52322), SPH_C32(0x2f8028f4), + SPH_C32(0x10bb3788), SPH_C32(0xa810dd13), SPH_C32(0x28860000), + SPH_C32(0xa28300d8), SPH_C32(0x447e6000), SPH_C32(0x0f360000), + SPH_C32(0x51872f3a), SPH_C32(0x8c28eb94), SPH_C32(0x16ec8c8b), + SPH_C32(0x7ff6ae49) }, + { SPH_C32(0x0a000000), SPH_C32(0x93dd0074), SPH_C32(0x3cc76000), + SPH_C32(0x9cea0000), SPH_C32(0xdb787946), SPH_C32(0x19b2747e), + SPH_C32(0xe2c9df26), SPH_C32(0x0ea81f9e), SPH_C32(0xaeff0000), + SPH_C32(0x9dba00da), SPH_C32(0xa5e48000), SPH_C32(0x97600000), + SPH_C32(0xc4e24834), SPH_C32(0xc2a0237e), SPH_C32(0xc531c5cf), + SPH_C32(0x69eb74f0) }, + { SPH_C32(0x8c790000), SPH_C32(0xace40076), SPH_C32(0xdd5d8000), + SPH_C32(0x04bc0000), SPH_C32(0x4e1d1e48), SPH_C32(0x573abc94), + SPH_C32(0x31149662), SPH_C32(0x18b5c527), SPH_C32(0x9e480000), + SPH_C32(0x786a00da), SPH_C32(0x5110e000), SPH_C32(0xd5a40000), + SPH_C32(0xa75a755e), SPH_C32(0xba1ab71e), SPH_C32(0xe49e6425), + SPH_C32(0xd94e6cc4) }, + { SPH_C32(0xcded0000), SPH_C32(0x6f89005c), SPH_C32(0x6a2a0000), + SPH_C32(0x30d60000), SPH_C32(0x78b2613a), SPH_C32(0x7890f27e), + SPH_C32(0xb0bddf2a), SPH_C32(0x5f8945fd), SPH_C32(0x0c280000), + SPH_C32(0x649900e4), SPH_C32(0xe0550000), SPH_C32(0x09440000), + SPH_C32(0x295375e0), SPH_C32(0xc861d381), SPH_C32(0x56a53dd1), + SPH_C32(0x14996dfd) }, + { SPH_C32(0x4b940000), SPH_C32(0x50b0005e), SPH_C32(0x8bb0e000), + SPH_C32(0xa8800000), SPH_C32(0xedd70634), SPH_C32(0x36183a94), + SPH_C32(0x6360966e), SPH_C32(0x49949f44), SPH_C32(0x3c9f0000), + SPH_C32(0x814900e4), SPH_C32(0x14a16000), SPH_C32(0x4b800000), + SPH_C32(0x4aeb488a), SPH_C32(0xb0db47e1), SPH_C32(0x770a9c3b), + SPH_C32(0xa43c75c9) }, + { SPH_C32(0xfd5a0000), SPH_C32(0x8a59005c), SPH_C32(0x9ede6000), + SPH_C32(0x72120000), SPH_C32(0x1b0a5c50), SPH_C32(0x002a661e), + SPH_C32(0x91127ec0), SPH_C32(0xef2c5dc9), SPH_C32(0xbae60000), + SPH_C32(0xbe7000e6), SPH_C32(0xf53b8000), SPH_C32(0xd3d60000), + SPH_C32(0xdf8e2f84), SPH_C32(0xfe538f0b), SPH_C32(0xa4d7d57f), + SPH_C32(0xb221af70) }, + { SPH_C32(0x7b230000), SPH_C32(0xb560005e), SPH_C32(0x7f448000), + SPH_C32(0xea440000), SPH_C32(0x8e6f3b5e), SPH_C32(0x4ea2aef4), + SPH_C32(0x42cf3784), SPH_C32(0xf9318770), SPH_C32(0x8a510000), + SPH_C32(0x5ba000e6), SPH_C32(0x01cfe000), SPH_C32(0x91120000), + SPH_C32(0xbc3612ee), SPH_C32(0x86e91b6b), SPH_C32(0x85787495), + SPH_C32(0x0284b744) }, + { SPH_C32(0xd9f40000), SPH_C32(0x4c430060), SPH_C32(0x3af50000), + SPH_C32(0x74600000), SPH_C32(0x63de068a), SPH_C32(0x44635e0b), + SPH_C32(0xd15bcf9a), SPH_C32(0x84439e7d), SPH_C32(0xef6b0000), + SPH_C32(0x5ed700f0), SPH_C32(0x12930000), SPH_C32(0xa30a0000), + SPH_C32(0xf24d3746), SPH_C32(0xed0a6d94), SPH_C32(0x44988c87), + SPH_C32(0x2ed7f42a) }, + { SPH_C32(0x5f8d0000), SPH_C32(0x737a0062), SPH_C32(0xdb6fe000), + SPH_C32(0xec360000), SPH_C32(0xf6bb6184), SPH_C32(0x0aeb96e1), + SPH_C32(0x028686de), SPH_C32(0x925e44c4), SPH_C32(0xdfdc0000), + SPH_C32(0xbb0700f0), SPH_C32(0xe6676000), SPH_C32(0xe1ce0000), + SPH_C32(0x91f50a2c), SPH_C32(0x95b0f9f4), SPH_C32(0x65372d6d), + SPH_C32(0x9e72ec1e) }, + { SPH_C32(0xe9430000), SPH_C32(0xa9930060), SPH_C32(0xce016000), + SPH_C32(0x36a40000), SPH_C32(0x00663be0), SPH_C32(0x3cd9ca6b), + SPH_C32(0xf0f46e70), SPH_C32(0x34e68649), SPH_C32(0x59a50000), + SPH_C32(0x843e00f2), SPH_C32(0x07fd8000), SPH_C32(0x79980000), + SPH_C32(0x04906d22), SPH_C32(0xdb38311e), SPH_C32(0xb6ea6429), + SPH_C32(0x886f36a7) }, + { SPH_C32(0x6f3a0000), SPH_C32(0x96aa0062), SPH_C32(0x2f9b8000), + SPH_C32(0xaef20000), SPH_C32(0x95035cee), SPH_C32(0x72510281), + SPH_C32(0x23292734), SPH_C32(0x22fb5cf0), SPH_C32(0x69120000), + SPH_C32(0x61ee00f2), SPH_C32(0xf309e000), SPH_C32(0x3b5c0000), + SPH_C32(0x67285048), SPH_C32(0xa382a57e), SPH_C32(0x9745c5c3), + SPH_C32(0x38ca2e93) }, + { SPH_C32(0xaf220000), SPH_C32(0x7b6c0090), SPH_C32(0x67e20000), + SPH_C32(0x8da20000), SPH_C32(0xc7841e29), SPH_C32(0xb7b744f3), + SPH_C32(0x9ac484f4), SPH_C32(0x8b6c72bd), SPH_C32(0x69510000), + SPH_C32(0xd4e1009c), SPH_C32(0xc3230000), SPH_C32(0xac2f0000), + SPH_C32(0xe4950bae), SPH_C32(0xcea415dc), SPH_C32(0x87ec287c), + SPH_C32(0xbce1a3ce) }, + { SPH_C32(0x295b0000), SPH_C32(0x44550092), SPH_C32(0x8678e000), + SPH_C32(0x15f40000), SPH_C32(0x52e17927), SPH_C32(0xf93f8c19), + SPH_C32(0x4919cdb0), SPH_C32(0x9d71a804), SPH_C32(0x59e60000), + SPH_C32(0x3131009c), SPH_C32(0x37d76000), SPH_C32(0xeeeb0000), + SPH_C32(0x872d36c4), SPH_C32(0xb61e81bc), SPH_C32(0xa6438996), + SPH_C32(0x0c44bbfa) }, + { SPH_C32(0x9f950000), SPH_C32(0x9ebc0090), SPH_C32(0x93166000), + SPH_C32(0xcf660000), SPH_C32(0xa43c2343), SPH_C32(0xcf0dd093), + SPH_C32(0xbb6b251e), SPH_C32(0x3bc96a89), SPH_C32(0xdf9f0000), + SPH_C32(0x0e08009e), SPH_C32(0xd64d8000), SPH_C32(0x76bd0000), + SPH_C32(0x124851ca), SPH_C32(0xf8964956), SPH_C32(0x759ec0d2), + SPH_C32(0x1a596143) }, + { SPH_C32(0x19ec0000), SPH_C32(0xa1850092), SPH_C32(0x728c8000), + SPH_C32(0x57300000), SPH_C32(0x3159444d), SPH_C32(0x81851879), + SPH_C32(0x68b66c5a), SPH_C32(0x2dd4b030), SPH_C32(0xef280000), + SPH_C32(0xebd8009e), SPH_C32(0x22b9e000), SPH_C32(0x34790000), + SPH_C32(0x71f06ca0), SPH_C32(0x802cdd36), SPH_C32(0x54316138), + SPH_C32(0xaafc7977) }, + { SPH_C32(0xbb3b0000), SPH_C32(0x58a600ac), SPH_C32(0x373d0000), + SPH_C32(0xc9140000), SPH_C32(0xdce87999), SPH_C32(0x8b44e886), + SPH_C32(0xfb229444), SPH_C32(0x50a6a93d), SPH_C32(0x8a120000), + SPH_C32(0xeeaf0088), SPH_C32(0x31e50000), SPH_C32(0x06610000), + SPH_C32(0x3f8b4908), SPH_C32(0xebcfabc9), SPH_C32(0x95d1992a), + SPH_C32(0x86af3a19) }, + { SPH_C32(0x3d420000), SPH_C32(0x679f00ae), SPH_C32(0xd6a7e000), + SPH_C32(0x51420000), SPH_C32(0x498d1e97), SPH_C32(0xc5cc206c), + SPH_C32(0x28ffdd00), SPH_C32(0x46bb7384), SPH_C32(0xbaa50000), + SPH_C32(0x0b7f0088), SPH_C32(0xc5116000), SPH_C32(0x44a50000), + SPH_C32(0x5c337462), SPH_C32(0x93753fa9), SPH_C32(0xb47e38c0), + SPH_C32(0x360a222d) }, + { SPH_C32(0x8b8c0000), SPH_C32(0xbd7600ac), SPH_C32(0xc3c96000), + SPH_C32(0x8bd00000), SPH_C32(0xbf5044f3), SPH_C32(0xf3fe7ce6), + SPH_C32(0xda8d35ae), SPH_C32(0xe003b109), SPH_C32(0x3cdc0000), + SPH_C32(0x3446008a), SPH_C32(0x248b8000), SPH_C32(0xdcf30000), + SPH_C32(0xc956136c), SPH_C32(0xddfdf743), SPH_C32(0x67a37184), + SPH_C32(0x2017f894) }, + { SPH_C32(0x0df50000), SPH_C32(0x824f00ae), SPH_C32(0x22538000), + SPH_C32(0x13860000), SPH_C32(0x2a3523fd), SPH_C32(0xbd76b40c), + SPH_C32(0x09507cea), SPH_C32(0xf61e6bb0), SPH_C32(0x0c6b0000), + SPH_C32(0xd196008a), SPH_C32(0xd07fe000), SPH_C32(0x9e370000), + SPH_C32(0xaaee2e06), SPH_C32(0xa5476323), SPH_C32(0x460cd06e), + SPH_C32(0x90b2e0a0) }, + { SPH_C32(0x4c610000), SPH_C32(0x41220084), SPH_C32(0x95240000), + SPH_C32(0x27ec0000), SPH_C32(0x1c9a5c8f), SPH_C32(0x92dcfae6), + SPH_C32(0x88f935a2), SPH_C32(0xb122eb6a), SPH_C32(0x9e0b0000), + SPH_C32(0xcd6500b4), SPH_C32(0x613a0000), SPH_C32(0x42d70000), + SPH_C32(0x24e72eb8), SPH_C32(0xd73c07bc), SPH_C32(0xf437899a), + SPH_C32(0x5d65e199) }, + { SPH_C32(0xca180000), SPH_C32(0x7e1b0086), SPH_C32(0x74bee000), + SPH_C32(0xbfba0000), SPH_C32(0x89ff3b81), SPH_C32(0xdc54320c), + SPH_C32(0x5b247ce6), SPH_C32(0xa73f31d3), SPH_C32(0xaebc0000), + SPH_C32(0x28b500b4), SPH_C32(0x95ce6000), SPH_C32(0x00130000), + SPH_C32(0x475f13d2), SPH_C32(0xaf8693dc), SPH_C32(0xd5982870), + SPH_C32(0xedc0f9ad) }, + { SPH_C32(0x7cd60000), SPH_C32(0xa4f20084), SPH_C32(0x61d06000), + SPH_C32(0x65280000), SPH_C32(0x7f2261e5), SPH_C32(0xea666e86), + SPH_C32(0xa9569448), SPH_C32(0x0187f35e), SPH_C32(0x28c50000), + SPH_C32(0x178c00b6), SPH_C32(0x74548000), SPH_C32(0x98450000), + SPH_C32(0xd23a74dc), SPH_C32(0xe10e5b36), SPH_C32(0x06456134), + SPH_C32(0xfbdd2314) }, + { SPH_C32(0xfaaf0000), SPH_C32(0x9bcb0086), SPH_C32(0x804a8000), + SPH_C32(0xfd7e0000), SPH_C32(0xea4706eb), SPH_C32(0xa4eea66c), + SPH_C32(0x7a8bdd0c), SPH_C32(0x179a29e7), SPH_C32(0x18720000), + SPH_C32(0xf25c00b6), SPH_C32(0x80a0e000), SPH_C32(0xda810000), + SPH_C32(0xb18249b6), SPH_C32(0x99b4cf56), SPH_C32(0x27eac0de), + SPH_C32(0x4b783b20) }, + { SPH_C32(0x58780000), SPH_C32(0x62e800b8), SPH_C32(0xc5fb0000), + SPH_C32(0x635a0000), SPH_C32(0x07f63b3f), SPH_C32(0xae2f5693), + SPH_C32(0xe91f2512), SPH_C32(0x6ae830ea), SPH_C32(0x7d480000), + SPH_C32(0xf72b00a0), SPH_C32(0x93fc0000), SPH_C32(0xe8990000), + SPH_C32(0xfff96c1e), SPH_C32(0xf257b9a9), SPH_C32(0xe60a38cc), + SPH_C32(0x672b784e) }, + { SPH_C32(0xde010000), SPH_C32(0x5dd100ba), SPH_C32(0x2461e000), + SPH_C32(0xfb0c0000), SPH_C32(0x92935c31), SPH_C32(0xe0a79e79), + SPH_C32(0x3ac26c56), SPH_C32(0x7cf5ea53), SPH_C32(0x4dff0000), + SPH_C32(0x12fb00a0), SPH_C32(0x67086000), SPH_C32(0xaa5d0000), + SPH_C32(0x9c415174), SPH_C32(0x8aed2dc9), SPH_C32(0xc7a59926), + SPH_C32(0xd78e607a) }, + { SPH_C32(0x68cf0000), SPH_C32(0x873800b8), SPH_C32(0x310f6000), + SPH_C32(0x219e0000), SPH_C32(0x644e0655), SPH_C32(0xd695c2f3), + SPH_C32(0xc8b084f8), SPH_C32(0xda4d28de), SPH_C32(0xcb860000), + SPH_C32(0x2dc200a2), SPH_C32(0x86928000), SPH_C32(0x320b0000), + SPH_C32(0x0924367a), SPH_C32(0xc465e523), SPH_C32(0x1478d062), + SPH_C32(0xc193bac3) }, + { SPH_C32(0xeeb60000), SPH_C32(0xb80100ba), SPH_C32(0xd0958000), + SPH_C32(0xb9c80000), SPH_C32(0xf12b615b), SPH_C32(0x981d0a19), + SPH_C32(0x1b6dcdbc), SPH_C32(0xcc50f267), SPH_C32(0xfb310000), + SPH_C32(0xc81200a2), SPH_C32(0x7266e000), SPH_C32(0x70cf0000), + SPH_C32(0x6a9c0b10), SPH_C32(0xbcdf7143), SPH_C32(0x35d77188), + SPH_C32(0x7136a2f7) }, + { SPH_C32(0xfb720000), SPH_C32(0x7d1d00cc), SPH_C32(0x424c0000), + SPH_C32(0xe7bc0000), SPH_C32(0xe92150f6), SPH_C32(0xd1f9c1e1), + SPH_C32(0x257e9c37), SPH_C32(0xf51d2faa), SPH_C32(0xd5dc0000), + SPH_C32(0x28da0084), SPH_C32(0xdaa00000), SPH_C32(0x7d240000), + SPH_C32(0x4a8d736a), SPH_C32(0x8c028d8a), SPH_C32(0x87fef24b), + SPH_C32(0x90daf380) }, + { SPH_C32(0x7d0b0000), SPH_C32(0x422400ce), SPH_C32(0xa3d6e000), + SPH_C32(0x7fea0000), SPH_C32(0x7c4437f8), SPH_C32(0x9f71090b), + SPH_C32(0xf6a3d573), SPH_C32(0xe300f513), SPH_C32(0xe56b0000), + SPH_C32(0xcd0a0084), SPH_C32(0x2e546000), SPH_C32(0x3fe00000), + SPH_C32(0x29354e00), SPH_C32(0xf4b819ea), SPH_C32(0xa65153a1), + SPH_C32(0x207febb4) }, + { SPH_C32(0xcbc50000), SPH_C32(0x98cd00cc), SPH_C32(0xb6b86000), + SPH_C32(0xa5780000), SPH_C32(0x8a996d9c), SPH_C32(0xa9435581), + SPH_C32(0x04d13ddd), SPH_C32(0x45b8379e), SPH_C32(0x63120000), + SPH_C32(0xf2330086), SPH_C32(0xcfce8000), SPH_C32(0xa7b60000), + SPH_C32(0xbc50290e), SPH_C32(0xba30d100), SPH_C32(0x758c1ae5), + SPH_C32(0x3662310d) }, + { SPH_C32(0x4dbc0000), SPH_C32(0xa7f400ce), SPH_C32(0x57228000), + SPH_C32(0x3d2e0000), SPH_C32(0x1ffc0a92), SPH_C32(0xe7cb9d6b), + SPH_C32(0xd70c7499), SPH_C32(0x53a5ed27), SPH_C32(0x53a50000), + SPH_C32(0x17e30086), SPH_C32(0x3b3ae000), SPH_C32(0xe5720000), + SPH_C32(0xdfe81464), SPH_C32(0xc28a4560), SPH_C32(0x5423bb0f), + SPH_C32(0x86c72939) }, + { SPH_C32(0xef6b0000), SPH_C32(0x5ed700f0), SPH_C32(0x12930000), + SPH_C32(0xa30a0000), SPH_C32(0xf24d3746), SPH_C32(0xed0a6d94), + SPH_C32(0x44988c87), SPH_C32(0x2ed7f42a), SPH_C32(0x369f0000), + SPH_C32(0x12940090), SPH_C32(0x28660000), SPH_C32(0xd76a0000), + SPH_C32(0x919331cc), SPH_C32(0xa969339f), SPH_C32(0x95c3431d), + SPH_C32(0xaa946a57) }, + { SPH_C32(0x69120000), SPH_C32(0x61ee00f2), SPH_C32(0xf309e000), + SPH_C32(0x3b5c0000), SPH_C32(0x67285048), SPH_C32(0xa382a57e), + SPH_C32(0x9745c5c3), SPH_C32(0x38ca2e93), SPH_C32(0x06280000), + SPH_C32(0xf7440090), SPH_C32(0xdc926000), SPH_C32(0x95ae0000), + SPH_C32(0xf22b0ca6), SPH_C32(0xd1d3a7ff), SPH_C32(0xb46ce2f7), + SPH_C32(0x1a317263) }, + { SPH_C32(0xdfdc0000), SPH_C32(0xbb0700f0), SPH_C32(0xe6676000), + SPH_C32(0xe1ce0000), SPH_C32(0x91f50a2c), SPH_C32(0x95b0f9f4), + SPH_C32(0x65372d6d), SPH_C32(0x9e72ec1e), SPH_C32(0x80510000), + SPH_C32(0xc87d0092), SPH_C32(0x3d088000), SPH_C32(0x0df80000), + SPH_C32(0x674e6ba8), SPH_C32(0x9f5b6f15), SPH_C32(0x67b1abb3), + SPH_C32(0x0c2ca8da) }, + { SPH_C32(0x59a50000), SPH_C32(0x843e00f2), SPH_C32(0x07fd8000), + SPH_C32(0x79980000), SPH_C32(0x04906d22), SPH_C32(0xdb38311e), + SPH_C32(0xb6ea6429), SPH_C32(0x886f36a7), SPH_C32(0xb0e60000), + SPH_C32(0x2dad0092), SPH_C32(0xc9fce000), SPH_C32(0x4f3c0000), + SPH_C32(0x04f656c2), SPH_C32(0xe7e1fb75), SPH_C32(0x461e0a59), + SPH_C32(0xbc89b0ee) }, + { SPH_C32(0x18310000), SPH_C32(0x475300d8), SPH_C32(0xb08a0000), + SPH_C32(0x4df20000), SPH_C32(0x323f1250), SPH_C32(0xf4927ff4), + SPH_C32(0x37432d61), SPH_C32(0xcf53b67d), SPH_C32(0x22860000), + SPH_C32(0x315e00ac), SPH_C32(0x78b90000), SPH_C32(0x93dc0000), + SPH_C32(0x8aff567c), SPH_C32(0x959a9fea), SPH_C32(0xf42553ad), + SPH_C32(0x715eb1d7) }, + { SPH_C32(0x9e480000), SPH_C32(0x786a00da), SPH_C32(0x5110e000), + SPH_C32(0xd5a40000), SPH_C32(0xa75a755e), SPH_C32(0xba1ab71e), + SPH_C32(0xe49e6425), SPH_C32(0xd94e6cc4), SPH_C32(0x12310000), + SPH_C32(0xd48e00ac), SPH_C32(0x8c4d6000), SPH_C32(0xd1180000), + SPH_C32(0xe9476b16), SPH_C32(0xed200b8a), SPH_C32(0xd58af247), + SPH_C32(0xc1fba9e3) }, + { SPH_C32(0x28860000), SPH_C32(0xa28300d8), SPH_C32(0x447e6000), + SPH_C32(0x0f360000), SPH_C32(0x51872f3a), SPH_C32(0x8c28eb94), + SPH_C32(0x16ec8c8b), SPH_C32(0x7ff6ae49), SPH_C32(0x94480000), + SPH_C32(0xebb700ae), SPH_C32(0x6dd78000), SPH_C32(0x494e0000), + SPH_C32(0x7c220c18), SPH_C32(0xa3a8c360), SPH_C32(0x0657bb03), + SPH_C32(0xd7e6735a) }, + { SPH_C32(0xaeff0000), SPH_C32(0x9dba00da), SPH_C32(0xa5e48000), + SPH_C32(0x97600000), SPH_C32(0xc4e24834), SPH_C32(0xc2a0237e), + SPH_C32(0xc531c5cf), SPH_C32(0x69eb74f0), SPH_C32(0xa4ff0000), + SPH_C32(0x0e6700ae), SPH_C32(0x9923e000), SPH_C32(0x0b8a0000), + SPH_C32(0x1f9a3172), SPH_C32(0xdb125700), SPH_C32(0x27f81ae9), + SPH_C32(0x67436b6e) }, + { SPH_C32(0x0c280000), SPH_C32(0x649900e4), SPH_C32(0xe0550000), + SPH_C32(0x09440000), SPH_C32(0x295375e0), SPH_C32(0xc861d381), + SPH_C32(0x56a53dd1), SPH_C32(0x14996dfd), SPH_C32(0xc1c50000), + SPH_C32(0x0b1000b8), SPH_C32(0x8a7f0000), SPH_C32(0x39920000), + SPH_C32(0x51e114da), SPH_C32(0xb0f121ff), SPH_C32(0xe618e2fb), + SPH_C32(0x4b102800) }, + { SPH_C32(0x8a510000), SPH_C32(0x5ba000e6), SPH_C32(0x01cfe000), + SPH_C32(0x91120000), SPH_C32(0xbc3612ee), SPH_C32(0x86e91b6b), + SPH_C32(0x85787495), SPH_C32(0x0284b744), SPH_C32(0xf1720000), + SPH_C32(0xeec000b8), SPH_C32(0x7e8b6000), SPH_C32(0x7b560000), + SPH_C32(0x325929b0), SPH_C32(0xc84bb59f), SPH_C32(0xc7b74311), + SPH_C32(0xfbb53034) }, + { SPH_C32(0x3c9f0000), SPH_C32(0x814900e4), SPH_C32(0x14a16000), + SPH_C32(0x4b800000), SPH_C32(0x4aeb488a), SPH_C32(0xb0db47e1), + SPH_C32(0x770a9c3b), SPH_C32(0xa43c75c9), SPH_C32(0x770b0000), + SPH_C32(0xd1f900ba), SPH_C32(0x9f118000), SPH_C32(0xe3000000), + SPH_C32(0xa73c4ebe), SPH_C32(0x86c37d75), SPH_C32(0x146a0a55), + SPH_C32(0xeda8ea8d) }, + { SPH_C32(0xbae60000), SPH_C32(0xbe7000e6), SPH_C32(0xf53b8000), + SPH_C32(0xd3d60000), SPH_C32(0xdf8e2f84), SPH_C32(0xfe538f0b), + SPH_C32(0xa4d7d57f), SPH_C32(0xb221af70), SPH_C32(0x47bc0000), + SPH_C32(0x342900ba), SPH_C32(0x6be5e000), SPH_C32(0xa1c40000), + SPH_C32(0xc48473d4), SPH_C32(0xfe79e915), SPH_C32(0x35c5abbf), + SPH_C32(0x5d0df2b9) }, + { SPH_C32(0x13af0000), SPH_C32(0x87570088), SPH_C32(0x7e610000), + SPH_C32(0x5ca90000), SPH_C32(0x699c66ed), SPH_C32(0xf511dca5), + SPH_C32(0x9ad65ec3), SPH_C32(0xa75722f3), SPH_C32(0x818c0000), + SPH_C32(0x2eab00d8), SPH_C32(0xff0e0000), SPH_C32(0x173a0000), + SPH_C32(0x64283db5), SPH_C32(0xea4c0898), SPH_C32(0x3844ea88), + SPH_C32(0xeeabae97) }, + { SPH_C32(0x95d60000), SPH_C32(0xb86e008a), SPH_C32(0x9ffbe000), + SPH_C32(0xc4ff0000), SPH_C32(0xfcf901e3), SPH_C32(0xbb99144f), + SPH_C32(0x490b1787), SPH_C32(0xb14af84a), SPH_C32(0xb13b0000), + SPH_C32(0xcb7b00d8), SPH_C32(0x0bfa6000), SPH_C32(0x55fe0000), + SPH_C32(0x079000df), SPH_C32(0x92f69cf8), SPH_C32(0x19eb4b62), + SPH_C32(0x5e0eb6a3) }, + { SPH_C32(0x23180000), SPH_C32(0x62870088), SPH_C32(0x8a956000), + SPH_C32(0x1e6d0000), SPH_C32(0x0a245b87), SPH_C32(0x8dab48c5), + SPH_C32(0xbb79ff29), SPH_C32(0x17f23ac7), SPH_C32(0x37420000), + SPH_C32(0xf44200da), SPH_C32(0xea608000), SPH_C32(0xcda80000), + SPH_C32(0x92f567d1), SPH_C32(0xdc7e5412), SPH_C32(0xca360226), + SPH_C32(0x48136c1a) }, + { SPH_C32(0xa5610000), SPH_C32(0x5dbe008a), SPH_C32(0x6b0f8000), + SPH_C32(0x863b0000), SPH_C32(0x9f413c89), SPH_C32(0xc323802f), + SPH_C32(0x68a4b66d), SPH_C32(0x01efe07e), SPH_C32(0x07f50000), + SPH_C32(0x119200da), SPH_C32(0x1e94e000), SPH_C32(0x8f6c0000), + SPH_C32(0xf14d5abb), SPH_C32(0xa4c4c072), SPH_C32(0xeb99a3cc), + SPH_C32(0xf8b6742e) }, + { SPH_C32(0x07b60000), SPH_C32(0xa49d00b4), SPH_C32(0x2ebe0000), + SPH_C32(0x181f0000), SPH_C32(0x72f0015d), SPH_C32(0xc9e270d0), + SPH_C32(0xfb304e73), SPH_C32(0x7c9df973), SPH_C32(0x62cf0000), + SPH_C32(0x14e500cc), SPH_C32(0x0dc80000), SPH_C32(0xbd740000), + SPH_C32(0xbf367f13), SPH_C32(0xcf27b68d), SPH_C32(0x2a795bde), + SPH_C32(0xd4e53740) }, + { SPH_C32(0x81cf0000), SPH_C32(0x9ba400b6), SPH_C32(0xcf24e000), + SPH_C32(0x80490000), SPH_C32(0xe7956653), SPH_C32(0x876ab83a), + SPH_C32(0x28ed0737), SPH_C32(0x6a8023ca), SPH_C32(0x52780000), + SPH_C32(0xf13500cc), SPH_C32(0xf93c6000), SPH_C32(0xffb00000), + SPH_C32(0xdc8e4279), SPH_C32(0xb79d22ed), SPH_C32(0x0bd6fa34), + SPH_C32(0x64402f74) }, + { SPH_C32(0x37010000), SPH_C32(0x414d00b4), SPH_C32(0xda4a6000), + SPH_C32(0x5adb0000), SPH_C32(0x11483c37), SPH_C32(0xb158e4b0), + SPH_C32(0xda9fef99), SPH_C32(0xcc38e147), SPH_C32(0xd4010000), + SPH_C32(0xce0c00ce), SPH_C32(0x18a68000), SPH_C32(0x67e60000), + SPH_C32(0x49eb2577), SPH_C32(0xf915ea07), SPH_C32(0xd80bb370), + SPH_C32(0x725df5cd) }, + { SPH_C32(0xb1780000), SPH_C32(0x7e7400b6), SPH_C32(0x3bd08000), + SPH_C32(0xc28d0000), SPH_C32(0x842d5b39), SPH_C32(0xffd02c5a), + SPH_C32(0x0942a6dd), SPH_C32(0xda253bfe), SPH_C32(0xe4b60000), + SPH_C32(0x2bdc00ce), SPH_C32(0xec52e000), SPH_C32(0x25220000), + SPH_C32(0x2a53181d), SPH_C32(0x81af7e67), SPH_C32(0xf9a4129a), + SPH_C32(0xc2f8edf9) }, + { SPH_C32(0xf0ec0000), SPH_C32(0xbd19009c), SPH_C32(0x8ca70000), + SPH_C32(0xf6e70000), SPH_C32(0xb282244b), SPH_C32(0xd07a62b0), + SPH_C32(0x88ebef95), SPH_C32(0x9d19bb24), SPH_C32(0x76d60000), + SPH_C32(0x372f00f0), SPH_C32(0x5d170000), SPH_C32(0xf9c20000), + SPH_C32(0xa45a18a3), SPH_C32(0xf3d41af8), SPH_C32(0x4b9f4b6e), + SPH_C32(0x0f2fecc0) }, + { SPH_C32(0x76950000), SPH_C32(0x8220009e), SPH_C32(0x6d3de000), + SPH_C32(0x6eb10000), SPH_C32(0x27e74345), SPH_C32(0x9ef2aa5a), + SPH_C32(0x5b36a6d1), SPH_C32(0x8b04619d), SPH_C32(0x46610000), + SPH_C32(0xd2ff00f0), SPH_C32(0xa9e36000), SPH_C32(0xbb060000), + SPH_C32(0xc7e225c9), SPH_C32(0x8b6e8e98), SPH_C32(0x6a30ea84), + SPH_C32(0xbf8af4f4) }, + { SPH_C32(0xc05b0000), SPH_C32(0x58c9009c), SPH_C32(0x78536000), + SPH_C32(0xb4230000), SPH_C32(0xd13a1921), SPH_C32(0xa8c0f6d0), + SPH_C32(0xa9444e7f), SPH_C32(0x2dbca310), SPH_C32(0xc0180000), + SPH_C32(0xedc600f2), SPH_C32(0x48798000), SPH_C32(0x23500000), + SPH_C32(0x528742c7), SPH_C32(0xc5e64672), SPH_C32(0xb9eda3c0), + SPH_C32(0xa9972e4d) }, + { SPH_C32(0x46220000), SPH_C32(0x67f0009e), SPH_C32(0x99c98000), + SPH_C32(0x2c750000), SPH_C32(0x445f7e2f), SPH_C32(0xe6483e3a), + SPH_C32(0x7a99073b), SPH_C32(0x3ba179a9), SPH_C32(0xf0af0000), + SPH_C32(0x081600f2), SPH_C32(0xbc8de000), SPH_C32(0x61940000), + SPH_C32(0x313f7fad), SPH_C32(0xbd5cd212), SPH_C32(0x9842022a), + SPH_C32(0x19323679) }, + { SPH_C32(0xe4f50000), SPH_C32(0x9ed300a0), SPH_C32(0xdc780000), + SPH_C32(0xb2510000), SPH_C32(0xa9ee43fb), SPH_C32(0xec89cec5), + SPH_C32(0xe90dff25), SPH_C32(0x46d360a4), SPH_C32(0x95950000), + SPH_C32(0x0d6100e4), SPH_C32(0xafd10000), SPH_C32(0x538c0000), + SPH_C32(0x7f445a05), SPH_C32(0xd6bfa4ed), SPH_C32(0x59a2fa38), + SPH_C32(0x35617517) }, + { SPH_C32(0x628c0000), SPH_C32(0xa1ea00a2), SPH_C32(0x3de2e000), + SPH_C32(0x2a070000), SPH_C32(0x3c8b24f5), SPH_C32(0xa201062f), + SPH_C32(0x3ad0b661), SPH_C32(0x50ceba1d), SPH_C32(0xa5220000), + SPH_C32(0xe8b100e4), SPH_C32(0x5b256000), SPH_C32(0x11480000), + SPH_C32(0x1cfc676f), SPH_C32(0xae05308d), SPH_C32(0x780d5bd2), + SPH_C32(0x85c46d23) }, + { SPH_C32(0xd4420000), SPH_C32(0x7b0300a0), SPH_C32(0x288c6000), + SPH_C32(0xf0950000), SPH_C32(0xca567e91), SPH_C32(0x94335aa5), + SPH_C32(0xc8a25ecf), SPH_C32(0xf6767890), SPH_C32(0x235b0000), + SPH_C32(0xd78800e6), SPH_C32(0xbabf8000), SPH_C32(0x891e0000), + SPH_C32(0x89990061), SPH_C32(0xe08df867), SPH_C32(0xabd01296), + SPH_C32(0x93d9b79a) }, + { SPH_C32(0x523b0000), SPH_C32(0x443a00a2), SPH_C32(0xc9168000), + SPH_C32(0x68c30000), SPH_C32(0x5f33199f), SPH_C32(0xdabb924f), + SPH_C32(0x1b7f178b), SPH_C32(0xe06ba229), SPH_C32(0x13ec0000), + SPH_C32(0x325800e6), SPH_C32(0x4e4be000), SPH_C32(0xcbda0000), + SPH_C32(0xea213d0b), SPH_C32(0x98376c07), SPH_C32(0x8a7fb37c), + SPH_C32(0x237cafae) }, + { SPH_C32(0x47ff0000), SPH_C32(0x812600d4), SPH_C32(0x5bcf0000), + SPH_C32(0x36b70000), SPH_C32(0x47392832), SPH_C32(0x935f59b7), + SPH_C32(0x256c4600), SPH_C32(0xd9267fe4), SPH_C32(0x3d010000), + SPH_C32(0xd29000c0), SPH_C32(0xe68d0000), SPH_C32(0xc6310000), + SPH_C32(0xca304571), SPH_C32(0xa8ea90ce), SPH_C32(0x385630bf), + SPH_C32(0xc290fed9) }, + { SPH_C32(0xc1860000), SPH_C32(0xbe1f00d6), SPH_C32(0xba55e000), + SPH_C32(0xaee10000), SPH_C32(0xd25c4f3c), SPH_C32(0xddd7915d), + SPH_C32(0xf6b10f44), SPH_C32(0xcf3ba55d), SPH_C32(0x0db60000), + SPH_C32(0x374000c0), SPH_C32(0x12796000), SPH_C32(0x84f50000), + SPH_C32(0xa988781b), SPH_C32(0xd05004ae), SPH_C32(0x19f99155), + SPH_C32(0x7235e6ed) }, + { SPH_C32(0x77480000), SPH_C32(0x64f600d4), SPH_C32(0xaf3b6000), + SPH_C32(0x74730000), SPH_C32(0x24811558), SPH_C32(0xebe5cdd7), + SPH_C32(0x04c3e7ea), SPH_C32(0x698367d0), SPH_C32(0x8bcf0000), + SPH_C32(0x087900c2), SPH_C32(0xf3e38000), SPH_C32(0x1ca30000), + SPH_C32(0x3ced1f15), SPH_C32(0x9ed8cc44), SPH_C32(0xca24d811), + SPH_C32(0x64283c54) }, + { SPH_C32(0xf1310000), SPH_C32(0x5bcf00d6), SPH_C32(0x4ea18000), + SPH_C32(0xec250000), SPH_C32(0xb1e47256), SPH_C32(0xa56d053d), + SPH_C32(0xd71eaeae), SPH_C32(0x7f9ebd69), SPH_C32(0xbb780000), + SPH_C32(0xeda900c2), SPH_C32(0x0717e000), SPH_C32(0x5e670000), + SPH_C32(0x5f55227f), SPH_C32(0xe6625824), SPH_C32(0xeb8b79fb), + SPH_C32(0xd48d2460) }, + { SPH_C32(0x53e60000), SPH_C32(0xa2ec00e8), SPH_C32(0x0b100000), + SPH_C32(0x72010000), SPH_C32(0x5c554f82), SPH_C32(0xafacf5c2), + SPH_C32(0x448a56b0), SPH_C32(0x02eca464), SPH_C32(0xde420000), + SPH_C32(0xe8de00d4), SPH_C32(0x144b0000), SPH_C32(0x6c7f0000), + SPH_C32(0x112e07d7), SPH_C32(0x8d812edb), SPH_C32(0x2a6b81e9), + SPH_C32(0xf8de670e) }, + { SPH_C32(0xd59f0000), SPH_C32(0x9dd500ea), SPH_C32(0xea8ae000), + SPH_C32(0xea570000), SPH_C32(0xc930288c), SPH_C32(0xe1243d28), + SPH_C32(0x97571ff4), SPH_C32(0x14f17edd), SPH_C32(0xeef50000), + SPH_C32(0x0d0e00d4), SPH_C32(0xe0bf6000), SPH_C32(0x2ebb0000), + SPH_C32(0x72963abd), SPH_C32(0xf53bbabb), SPH_C32(0x0bc42003), + SPH_C32(0x487b7f3a) }, + { SPH_C32(0x63510000), SPH_C32(0x473c00e8), SPH_C32(0xffe46000), + SPH_C32(0x30c50000), SPH_C32(0x3fed72e8), SPH_C32(0xd71661a2), + SPH_C32(0x6525f75a), SPH_C32(0xb249bc50), SPH_C32(0x688c0000), + SPH_C32(0x323700d6), SPH_C32(0x01258000), SPH_C32(0xb6ed0000), + SPH_C32(0xe7f35db3), SPH_C32(0xbbb37251), SPH_C32(0xd8196947), + SPH_C32(0x5e66a583) }, + { SPH_C32(0xe5280000), SPH_C32(0x780500ea), SPH_C32(0x1e7e8000), + SPH_C32(0xa8930000), SPH_C32(0xaa8815e6), SPH_C32(0x999ea948), + SPH_C32(0xb6f8be1e), SPH_C32(0xa45466e9), SPH_C32(0x583b0000), + SPH_C32(0xd7e700d6), SPH_C32(0xf5d1e000), SPH_C32(0xf4290000), + SPH_C32(0x844b60d9), SPH_C32(0xc309e631), SPH_C32(0xf9b6c8ad), + SPH_C32(0xeec3bdb7) }, + { SPH_C32(0xa4bc0000), SPH_C32(0xbb6800c0), SPH_C32(0xa9090000), + SPH_C32(0x9cf90000), SPH_C32(0x9c276a94), SPH_C32(0xb634e7a2), + SPH_C32(0x3751f756), SPH_C32(0xe368e633), SPH_C32(0xca5b0000), + SPH_C32(0xcb1400e8), SPH_C32(0x44940000), SPH_C32(0x28c90000), + SPH_C32(0x0a426067), SPH_C32(0xb17282ae), SPH_C32(0x4b8d9159), + SPH_C32(0x2314bc8e) }, + { SPH_C32(0x22c50000), SPH_C32(0x845100c2), SPH_C32(0x4893e000), + SPH_C32(0x04af0000), SPH_C32(0x09420d9a), SPH_C32(0xf8bc2f48), + SPH_C32(0xe48cbe12), SPH_C32(0xf5753c8a), SPH_C32(0xfaec0000), + SPH_C32(0x2ec400e8), SPH_C32(0xb0606000), SPH_C32(0x6a0d0000), + SPH_C32(0x69fa5d0d), SPH_C32(0xc9c816ce), SPH_C32(0x6a2230b3), + SPH_C32(0x93b1a4ba) }, + { SPH_C32(0x940b0000), SPH_C32(0x5eb800c0), SPH_C32(0x5dfd6000), + SPH_C32(0xde3d0000), SPH_C32(0xff9f57fe), SPH_C32(0xce8e73c2), + SPH_C32(0x16fe56bc), SPH_C32(0x53cdfe07), SPH_C32(0x7c950000), + SPH_C32(0x11fd00ea), SPH_C32(0x51fa8000), SPH_C32(0xf25b0000), + SPH_C32(0xfc9f3a03), SPH_C32(0x8740de24), SPH_C32(0xb9ff79f7), + SPH_C32(0x85ac7e03) }, + { SPH_C32(0x12720000), SPH_C32(0x618100c2), SPH_C32(0xbc678000), + SPH_C32(0x466b0000), SPH_C32(0x6afa30f0), SPH_C32(0x8006bb28), + SPH_C32(0xc5231ff8), SPH_C32(0x45d024be), SPH_C32(0x4c220000), + SPH_C32(0xf42d00ea), SPH_C32(0xa50ee000), SPH_C32(0xb09f0000), + SPH_C32(0x9f270769), SPH_C32(0xfffa4a44), SPH_C32(0x9850d81d), + SPH_C32(0x35096637) }, + { SPH_C32(0xb0a50000), SPH_C32(0x98a200fc), SPH_C32(0xf9d60000), + SPH_C32(0xd84f0000), SPH_C32(0x874b0d24), SPH_C32(0x8ac74bd7), + SPH_C32(0x56b7e7e6), SPH_C32(0x38a23db3), SPH_C32(0x29180000), + SPH_C32(0xf15a00fc), SPH_C32(0xb6520000), SPH_C32(0x82870000), + SPH_C32(0xd15c22c1), SPH_C32(0x94193cbb), SPH_C32(0x59b0200f), + SPH_C32(0x195a2559) }, + { SPH_C32(0x36dc0000), SPH_C32(0xa79b00fe), SPH_C32(0x184ce000), + SPH_C32(0x40190000), SPH_C32(0x122e6a2a), SPH_C32(0xc44f833d), + SPH_C32(0x856aaea2), SPH_C32(0x2ebfe70a), SPH_C32(0x19af0000), + SPH_C32(0x148a00fc), SPH_C32(0x42a66000), SPH_C32(0xc0430000), + SPH_C32(0xb2e41fab), SPH_C32(0xeca3a8db), SPH_C32(0x781f81e5), + SPH_C32(0xa9ff3d6d) }, + { SPH_C32(0x80120000), SPH_C32(0x7d7200fc), SPH_C32(0x0d226000), + SPH_C32(0x9a8b0000), SPH_C32(0xe4f3304e), SPH_C32(0xf27ddfb7), + SPH_C32(0x7718460c), SPH_C32(0x88072587), SPH_C32(0x9fd60000), + SPH_C32(0x2bb300fe), SPH_C32(0xa33c8000), SPH_C32(0x58150000), + SPH_C32(0x278178a5), SPH_C32(0xa22b6031), SPH_C32(0xabc2c8a1), + SPH_C32(0xbfe2e7d4) }, + { SPH_C32(0x066b0000), SPH_C32(0x424b00fe), SPH_C32(0xecb88000), + SPH_C32(0x02dd0000), SPH_C32(0x71965740), SPH_C32(0xbcf5175d), + SPH_C32(0xa4c50f48), SPH_C32(0x9e1aff3e), SPH_C32(0xaf610000), + SPH_C32(0xce6300fe), SPH_C32(0x57c8e000), SPH_C32(0x1ad10000), + SPH_C32(0x443945cf), SPH_C32(0xda91f451), SPH_C32(0x8a6d694b), + SPH_C32(0x0f47ffe0) } +}; + +static const sph_u32 T512_32[256][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xcc140000), SPH_C32(0xa5630000), SPH_C32(0x5ab90780), + SPH_C32(0x3b500000), SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), + SPH_C32(0x694348c1), SPH_C32(0xca5a87fe), SPH_C32(0x819e0000), + SPH_C32(0xec570000), SPH_C32(0x66320280), SPH_C32(0x95f30000), + SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), SPH_C32(0xe65aa22d), + SPH_C32(0x8e67b7fa) }, + { SPH_C32(0x819e0000), SPH_C32(0xec570000), SPH_C32(0x66320280), + SPH_C32(0x95f30000), SPH_C32(0x5da92802), SPH_C32(0x48f43cbc), + SPH_C32(0xe65aa22d), SPH_C32(0x8e67b7fa), SPH_C32(0x4d8a0000), + SPH_C32(0x49340000), SPH_C32(0x3c8b0500), SPH_C32(0xaea30000), + SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), SPH_C32(0x8f19eaec), + SPH_C32(0x443d3004) }, + { SPH_C32(0x4d8a0000), SPH_C32(0x49340000), SPH_C32(0x3c8b0500), + SPH_C32(0xaea30000), SPH_C32(0x16793bfd), SPH_C32(0xcf6f08a4), + SPH_C32(0x8f19eaec), SPH_C32(0x443d3004), SPH_C32(0xcc140000), + SPH_C32(0xa5630000), SPH_C32(0x5ab90780), SPH_C32(0x3b500000), + SPH_C32(0x4bd013ff), SPH_C32(0x879b3418), SPH_C32(0x694348c1), + SPH_C32(0xca5a87fe) }, + { SPH_C32(0x78230000), SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), + SPH_C32(0x90a50000), SPH_C32(0x713e2879), SPH_C32(0x7ee98924), + SPH_C32(0xf08ca062), SPH_C32(0x636f8bab), SPH_C32(0x02af0000), + SPH_C32(0xb7280000), SPH_C32(0xba1c0300), SPH_C32(0x56980000), + SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), SPH_C32(0xa95c149a), + SPH_C32(0xf4f6ea7b) }, + { SPH_C32(0xb4370000), SPH_C32(0xb79f0000), SPH_C32(0xf3830c00), + SPH_C32(0xabf50000), SPH_C32(0x3aee3b86), SPH_C32(0xf972bd3c), + SPH_C32(0x99cfe8a3), SPH_C32(0xa9350c55), SPH_C32(0x83310000), + SPH_C32(0x5b7f0000), SPH_C32(0xdc2e0180), SPH_C32(0xc36b0000), + SPH_C32(0xe7246dd1), SPH_C32(0xc8bcfadb), SPH_C32(0x4f06b6b7), + SPH_C32(0x7a915d81) }, + { SPH_C32(0xf9bd0000), SPH_C32(0xfeab0000), SPH_C32(0xcf080900), + SPH_C32(0x05560000), SPH_C32(0x2c97007b), SPH_C32(0x361db598), + SPH_C32(0x16d6024f), SPH_C32(0xed083c51), SPH_C32(0x4f250000), + SPH_C32(0xfe1c0000), SPH_C32(0x496970600), SPH_C32(0xf83b0000), + SPH_C32(0xacf47e2e), SPH_C32(0x4f27cec3), SPH_C32(0x2645fe76), + SPH_C32(0xb0cbda7f) }, + { SPH_C32(0x35a90000), SPH_C32(0x5bc80000), SPH_C32(0x95b10e80), + SPH_C32(0x3e060000), SPH_C32(0x67471384), SPH_C32(0xb1868180), + SPH_C32(0x7f954a8e), SPH_C32(0x2752bbaf), SPH_C32(0xcebb0000), + SPH_C32(0x124b0000), SPH_C32(0xe0a50480), SPH_C32(0x6dc80000), + SPH_C32(0xf15d562c), SPH_C32(0x07d3f27f), SPH_C32(0xc01f5c5b), + SPH_C32(0x3eac6d85) }, + { SPH_C32(0x02af0000), SPH_C32(0xb7280000), SPH_C32(0xba1c0300), + SPH_C32(0x56980000), SPH_C32(0xba8d45d3), SPH_C32(0x8048c667), + SPH_C32(0xa95c149a), SPH_C32(0xf4f6ea7b), SPH_C32(0x7a8c0000), + SPH_C32(0xa5d40000), SPH_C32(0x13260880), SPH_C32(0xc63d0000), + SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), SPH_C32(0x59d0b4f8), + SPH_C32(0x979961d0) }, + { SPH_C32(0xcebb0000), SPH_C32(0x124b0000), SPH_C32(0xe0a50480), + SPH_C32(0x6dc80000), SPH_C32(0xf15d562c), SPH_C32(0x07d3f27f), + SPH_C32(0xc01f5c5b), SPH_C32(0x3eac6d85), SPH_C32(0xfb120000), + SPH_C32(0x49830000), SPH_C32(0x75140a00), SPH_C32(0x53ce0000), + SPH_C32(0x961a45a8), SPH_C32(0xb65573ff), SPH_C32(0xbf8a16d5), + SPH_C32(0x19fed62a) }, + { SPH_C32(0x83310000), SPH_C32(0x5b7f0000), SPH_C32(0xdc2e0180), + SPH_C32(0xc36b0000), SPH_C32(0xe7246dd1), SPH_C32(0xc8bcfadb), + SPH_C32(0x4f06b6b7), SPH_C32(0x7a915d81), SPH_C32(0x37060000), + SPH_C32(0xece00000), SPH_C32(0x2fad0d80), SPH_C32(0x689e0000), + SPH_C32(0xddca5657), SPH_C32(0x31ce47e7), SPH_C32(0xd6c95e14), + SPH_C32(0xd3a451d4) }, + { SPH_C32(0x4f250000), SPH_C32(0xfe1c0000), SPH_C32(0x496970600), + SPH_C32(0xf83b0000), SPH_C32(0xacf47e2e), SPH_C32(0x4f27cec3), + SPH_C32(0x2645fe76), SPH_C32(0xb0cbda7f), SPH_C32(0xb6980000), + SPH_C32(0x00b70000), SPH_C32(0x499f0f00), SPH_C32(0xfd6d0000), + SPH_C32(0x80637e55), SPH_C32(0x793a7b5b), SPH_C32(0x3093fc39), + SPH_C32(0x5dc3e62e) }, + { SPH_C32(0x7a8c0000), SPH_C32(0xa5d40000), SPH_C32(0x13260880), + SPH_C32(0xc63d0000), SPH_C32(0xcbb36daa), SPH_C32(0xfea14f43), + SPH_C32(0x59d0b4f8), SPH_C32(0x979961d0), SPH_C32(0x78230000), + SPH_C32(0x12fc0000), SPH_C32(0xa93a0b80), SPH_C32(0x90a50000), + SPH_C32(0x713e2879), SPH_C32(0x7ee98924), SPH_C32(0xf08ca062), + SPH_C32(0x636f8bab) }, + { SPH_C32(0xb6980000), SPH_C32(0x00b70000), SPH_C32(0x499f0f00), + SPH_C32(0xfd6d0000), SPH_C32(0x80637e55), SPH_C32(0x793a7b5b), + SPH_C32(0x3093fc39), SPH_C32(0x5dc3e62e), SPH_C32(0xf9bd0000), + SPH_C32(0xfeab0000), SPH_C32(0xcf080900), SPH_C32(0x05560000), + SPH_C32(0x2c97007b), SPH_C32(0x361db598), SPH_C32(0x16d6024f), + SPH_C32(0xed083c51) }, + { SPH_C32(0xfb120000), SPH_C32(0x49830000), SPH_C32(0x75140a00), + SPH_C32(0x53ce0000), SPH_C32(0x961a45a8), SPH_C32(0xb65573ff), + SPH_C32(0xbf8a16d5), SPH_C32(0x19fed62a), SPH_C32(0x35a90000), + SPH_C32(0x5bc80000), SPH_C32(0x95b10e80), SPH_C32(0x3e060000), + SPH_C32(0x67471384), SPH_C32(0xb1868180), SPH_C32(0x7f954a8e), + SPH_C32(0x2752bbaf) }, + { SPH_C32(0x37060000), SPH_C32(0xece00000), SPH_C32(0x2fad0d80), + SPH_C32(0x689e0000), SPH_C32(0xddca5657), SPH_C32(0x31ce47e7), + SPH_C32(0xd6c95e14), SPH_C32(0xd3a451d4), SPH_C32(0xb4370000), + SPH_C32(0xb79f0000), SPH_C32(0xf3830c00), SPH_C32(0xabf50000), + SPH_C32(0x3aee3b86), SPH_C32(0xf972bd3c), SPH_C32(0x99cfe8a3), + SPH_C32(0xa9350c55) }, + { SPH_C32(0xac480000), SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), + SPH_C32(0x03430000), SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), + SPH_C32(0xfe72c7fe), SPH_C32(0x91e478f6), SPH_C32(0x1e4e0000), + SPH_C32(0xdecf0000), SPH_C32(0x6df80180), SPH_C32(0x77240000), + SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), SPH_C32(0xcda31812), + SPH_C32(0x98aa496e) }, + { SPH_C32(0x605c0000), SPH_C32(0xbec50000), SPH_C32(0x1f421400), + SPH_C32(0x38130000), SPH_C32(0x11552295), SPH_C32(0x982964ae), + SPH_C32(0x97318f3f), SPH_C32(0x5bbeff08), SPH_C32(0x9fd00000), + SPH_C32(0x32980000), SPH_C32(0x0bca0300), SPH_C32(0xe2d70000), + SPH_C32(0xb1ee2f9c), SPH_C32(0xbc5455f2), SPH_C32(0x2bf9ba3f), + SPH_C32(0x16cdfe94) }, + { SPH_C32(0x2dd60000), SPH_C32(0xf7f10000), SPH_C32(0x23c91100), + SPH_C32(0x96b00000), SPH_C32(0x072c1968), SPH_C32(0x57466c0a), + SPH_C32(0x182865d3), SPH_C32(0x1f83cf0c), SPH_C32(0x53c40000), + SPH_C32(0x97fb0000), SPH_C32(0x51730480), SPH_C32(0xd9870000), + SPH_C32(0xfa3e3c63), SPH_C32(0x3bcf61ea), SPH_C32(0x42baf2fe), + SPH_C32(0xdc97796a) }, + { SPH_C32(0xe1c20000), SPH_C32(0x52920000), SPH_C32(0x79701680), + SPH_C32(0xade00000), SPH_C32(0x4cfc0a97), SPH_C32(0xd0dd5812), + SPH_C32(0x716b2d12), SPH_C32(0xd5d948f2), SPH_C32(0xd25a0000), + SPH_C32(0x7bac0000), SPH_C32(0x37410600), SPH_C32(0x4c740000), + SPH_C32(0xa7971461), SPH_C32(0x733b5d56), SPH_C32(0xa4e050d3), + SPH_C32(0x52f0ce90) }, + { SPH_C32(0xd46b0000), SPH_C32(0x095a0000), SPH_C32(0xecc11800), + SPH_C32(0x93e60000), SPH_C32(0x2bbb1913), SPH_C32(0x615bd992), + SPH_C32(0x0efe679c), SPH_C32(0xf28bf35d), SPH_C32(0x1ce10000), + SPH_C32(0x69e70000), SPH_C32(0xd7e40280), SPH_C32(0x21bc0000), + SPH_C32(0x56ca424d), SPH_C32(0x74e8af29), SPH_C32(0x64ff0c88), + SPH_C32(0x6c5ca315) }, + { SPH_C32(0x187f0000), SPH_C32(0xac390000), SPH_C32(0xb6781f80), + SPH_C32(0xa8b60000), SPH_C32(0x606b0aec), SPH_C32(0xe6c0ed8a), + SPH_C32(0x67bd2f5d), SPH_C32(0x38d174a3), SPH_C32(0x9d7f0000), + SPH_C32(0x85b00000), SPH_C32(0xb1d60000), SPH_C32(0xb44f0000), + SPH_C32(0x0b636a4f), SPH_C32(0x3c1c9395), SPH_C32(0x82a5aea5), + SPH_C32(0xe23b14ef) }, + { SPH_C32(0x55f50000), SPH_C32(0xe50d0000), SPH_C32(0x8af31a80), + SPH_C32(0x06150000), SPH_C32(0x76123111), SPH_C32(0x29afe52e), + SPH_C32(0xe8a4c5b1), SPH_C32(0x7cec44a7), SPH_C32(0x516b0000), + SPH_C32(0x20d30000), SPH_C32(0xeb6f0780), SPH_C32(0x8f1f0000), + SPH_C32(0x40b379b0), SPH_C32(0xbb87a78d), SPH_C32(0xebe6e664), + SPH_C32(0x28619311) }, + { SPH_C32(0x99e10000), SPH_C32(0x406e0000), SPH_C32(0xd04a1d00), + SPH_C32(0x3d450000), SPH_C32(0x3dc222ee), SPH_C32(0xae34d136), + SPH_C32(0x81e78d70), SPH_C32(0xb6b6c359), SPH_C32(0xd0f50000), + SPH_C32(0xcc840000), SPH_C32(0x8d5d0500), SPH_C32(0x1aec0000), + SPH_C32(0x1d1a51b2), SPH_C32(0xf3739b31), SPH_C32(0x0dbc4449), + SPH_C32(0xa60624eb) }, + { SPH_C32(0xaee70000), SPH_C32(0xac8e0000), SPH_C32(0xffe71080), + SPH_C32(0x55db0000), SPH_C32(0xe00874b9), SPH_C32(0x9ffa96d1), + SPH_C32(0x572ed364), SPH_C32(0x6512928d), SPH_C32(0x64c20000), + SPH_C32(0x7b1b0000), SPH_C32(0x7ede0900), SPH_C32(0xb1190000), + SPH_C32(0x27f46a34), SPH_C32(0x0a01260d), SPH_C32(0x9473acea), + SPH_C32(0x0f3328be) }, + { SPH_C32(0x62f30000), SPH_C32(0x09ed0000), SPH_C32(0xa55e1700), + SPH_C32(0x6e8b0000), SPH_C32(0xabd86746), SPH_C32(0x1861a2c9), + SPH_C32(0x3e6d9ba5), SPH_C32(0xaf481573), SPH_C32(0xe55c0000), + SPH_C32(0x974c0000), SPH_C32(0x18ec0b80), SPH_C32(0x24ea0000), + SPH_C32(0x7a5d4236), SPH_C32(0x42f51ab1), SPH_C32(0x72290ec7), + SPH_C32(0x81549f44) }, + { SPH_C32(0x2f790000), SPH_C32(0x40d90000), SPH_C32(0x99d51200), + SPH_C32(0xc0280000), SPH_C32(0xbda15cbb), SPH_C32(0xd70eaa6d), + SPH_C32(0xb1747149), SPH_C32(0xeb752577), SPH_C32(0x29480000), + SPH_C32(0x322f0000), SPH_C32(0x42550c00), SPH_C32(0x1fba0000), + SPH_C32(0x318d51c9), SPH_C32(0xc56e2ea9), SPH_C32(0x1b6a4606), + SPH_C32(0x4b0e18ba) }, + { SPH_C32(0xe36d0000), SPH_C32(0xe5ba0000), SPH_C32(0xc36c1580), + SPH_C32(0xfb780000), SPH_C32(0xf6714f44), SPH_C32(0x50959e75), + SPH_C32(0xd8373988), SPH_C32(0x212fa289), SPH_C32(0xa8d60000), + SPH_C32(0xde780000), SPH_C32(0x24670e80), SPH_C32(0x8a490000), + SPH_C32(0x6c2479cb), SPH_C32(0x8d9a1215), SPH_C32(0xfd30e42b), + SPH_C32(0xc569af40) }, + { SPH_C32(0xd6c40000), SPH_C32(0xbe720000), SPH_C32(0x56dd1b00), + SPH_C32(0xc57e0000), SPH_C32(0x91365cc0), SPH_C32(0xe1131ff5), + SPH_C32(0xa7a27306), SPH_C32(0x067d1926), SPH_C32(0x666d0000), + SPH_C32(0xcc330000), SPH_C32(0xc4c20a00), SPH_C32(0xe7810000), + SPH_C32(0x9d792fe7), SPH_C32(0x8a49e06a), SPH_C32(0x3d2fb870), + SPH_C32(0xfbc5c2c5) }, + { SPH_C32(0x1ad00000), SPH_C32(0x1b110000), SPH_C32(0x0c641c80), + SPH_C32(0xfe2e0000), SPH_C32(0xdae64f3f), SPH_C32(0x66882bed), + SPH_C32(0xcee13bc7), SPH_C32(0xcc279ed8), SPH_C32(0xe7f30000), + SPH_C32(0x20640000), SPH_C32(0xa2f00880), SPH_C32(0x72720000), + SPH_C32(0xc0d007e5), SPH_C32(0xc2bddcd6), SPH_C32(0xdb751a5d), + SPH_C32(0x75a2753f) }, + { SPH_C32(0x575a0000), SPH_C32(0x52250000), SPH_C32(0x30ef1980), + SPH_C32(0x508d0000), SPH_C32(0xcc9f74c2), SPH_C32(0xa9e72349), + SPH_C32(0x41f8d12b), SPH_C32(0x881aaedc), SPH_C32(0x2be70000), + SPH_C32(0x85070000), SPH_C32(0xf8490f00), SPH_C32(0x49220000), + SPH_C32(0x8b00141a), SPH_C32(0x4526e8ce), SPH_C32(0xb236529c), + SPH_C32(0xbff8f2c1) }, + { SPH_C32(0x9b4e0000), SPH_C32(0xf7460000), SPH_C32(0x6a561e00), + SPH_C32(0x6bdd0000), SPH_C32(0x874f673d), SPH_C32(0x2e7c1751), + SPH_C32(0x28bb99ea), SPH_C32(0x42402922), SPH_C32(0xaa790000), + SPH_C32(0x69500000), SPH_C32(0x9e7b0d80), SPH_C32(0xdcd10000), + SPH_C32(0xd6a93c18), SPH_C32(0x0dd2d472), SPH_C32(0x546cf0b1), + SPH_C32(0x319f453b) }, + { SPH_C32(0x1e4e0000), SPH_C32(0xdecf0000), SPH_C32(0x6df80180), + SPH_C32(0x77240000), SPH_C32(0xec47079e), SPH_C32(0xf4a0694e), + SPH_C32(0xcda31812), SPH_C32(0x98aa496e), SPH_C32(0xb2060000), + SPH_C32(0xc5690000), SPH_C32(0x28031200), SPH_C32(0x74670000), + SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), SPH_C32(0x33d1dfec), + SPH_C32(0x094e3198) }, + { SPH_C32(0xd25a0000), SPH_C32(0x7bac0000), SPH_C32(0x37410600), + SPH_C32(0x4c740000), SPH_C32(0xa7971461), SPH_C32(0x733b5d56), + SPH_C32(0xa4e050d3), SPH_C32(0x52f0ce90), SPH_C32(0x33980000), + SPH_C32(0x293e0000), SPH_C32(0x4e311080), SPH_C32(0xe1940000), + SPH_C32(0xeb6b1ef6), SPH_C32(0xa3e60544), SPH_C32(0xd58b7dc1), + SPH_C32(0x87298662) }, + { SPH_C32(0x9fd00000), SPH_C32(0x32980000), SPH_C32(0x0bca0300), + SPH_C32(0xe2d70000), SPH_C32(0xb1ee2f9c), SPH_C32(0xbc5455f2), + SPH_C32(0x2bf9ba3f), SPH_C32(0x16cdfe94), SPH_C32(0xff8c0000), + SPH_C32(0x8c5d0000), SPH_C32(0x14881700), SPH_C32(0xdac40000), + SPH_C32(0xa0bb0d09), SPH_C32(0x247d315c), SPH_C32(0xbcc83500), + SPH_C32(0x4d73019c) }, + { SPH_C32(0x53c40000), SPH_C32(0x97fb0000), SPH_C32(0x51730480), + SPH_C32(0xd9870000), SPH_C32(0xfa3e3c63), SPH_C32(0x3bcf61ea), + SPH_C32(0x42baf2fe), SPH_C32(0xdc97796a), SPH_C32(0x7e120000), + SPH_C32(0x600a0000), SPH_C32(0x72ba1580), SPH_C32(0x4f370000), + SPH_C32(0xfd12250b), SPH_C32(0x6c890de0), SPH_C32(0x5a92972d), + SPH_C32(0xc314b666) }, + { SPH_C32(0x666d0000), SPH_C32(0xcc330000), SPH_C32(0xc4c20a00), + SPH_C32(0xe7810000), SPH_C32(0x9d792fe7), SPH_C32(0x8a49e06a), + SPH_C32(0x3d2fb870), SPH_C32(0xfbc5c2c5), SPH_C32(0xb0a90000), + SPH_C32(0x72410000), SPH_C32(0x921f1100), SPH_C32(0x22ff0000), + SPH_C32(0x0c4f7327), SPH_C32(0x6b5aff9f), SPH_C32(0x9a8dcb76), + SPH_C32(0xfdb8dbe3) }, + { SPH_C32(0xaa790000), SPH_C32(0x69500000), SPH_C32(0x9e7b0d80), + SPH_C32(0xdcd10000), SPH_C32(0xd6a93c18), SPH_C32(0x0dd2d472), + SPH_C32(0x546cf0b1), SPH_C32(0x319f453b), SPH_C32(0x31370000), + SPH_C32(0x9e160000), SPH_C32(0xf42d1380), SPH_C32(0xb70c0000), + SPH_C32(0x51e65b25), SPH_C32(0x23aec323), SPH_C32(0x7cd7695b), + SPH_C32(0x73df6c19) }, + { SPH_C32(0xe7f30000), SPH_C32(0x20640000), SPH_C32(0xa2f00880), + SPH_C32(0x72720000), SPH_C32(0xc0d007e5), SPH_C32(0xc2bddcd6), + SPH_C32(0xdb751a5d), SPH_C32(0x75a2753f), SPH_C32(0xfd230000), + SPH_C32(0x3b750000), SPH_C32(0xae941400), SPH_C32(0x8c5c0000), + SPH_C32(0x1a3648da), SPH_C32(0xa435f73b), SPH_C32(0x1594219a), + SPH_C32(0xb985ebe7) }, + { SPH_C32(0x2be70000), SPH_C32(0x85070000), SPH_C32(0xf8490f00), + SPH_C32(0x49220000), SPH_C32(0x8b00141a), SPH_C32(0x4526e8ce), + SPH_C32(0xb236529c), SPH_C32(0xbff8f2c1), SPH_C32(0x7cbd0000), + SPH_C32(0xd7220000), SPH_C32(0xc8a61680), SPH_C32(0x19af0000), + SPH_C32(0x479f60d8), SPH_C32(0xecc1cb87), SPH_C32(0xf3ce83b7), + SPH_C32(0x37e25c1d) }, + { SPH_C32(0x1ce10000), SPH_C32(0x69e70000), SPH_C32(0xd7e40280), + SPH_C32(0x21bc0000), SPH_C32(0x56ca424d), SPH_C32(0x74e8af29), + SPH_C32(0x64ff0c88), SPH_C32(0x6c5ca315), SPH_C32(0xc88a0000), + SPH_C32(0x60bd0000), SPH_C32(0x3b251a80), SPH_C32(0xb25a0000), + SPH_C32(0x7d715b5e), SPH_C32(0x15b376bb), SPH_C32(0x6a016b14), + SPH_C32(0x9ed75048) }, + { SPH_C32(0xd0f50000), SPH_C32(0xcc840000), SPH_C32(0x8d5d0500), + SPH_C32(0x1aec0000), SPH_C32(0x1d1a51b2), SPH_C32(0xf3739b31), + SPH_C32(0x0dbc4449), SPH_C32(0xa60624eb), SPH_C32(0x49140000), + SPH_C32(0x8cea0000), SPH_C32(0x5d171800), SPH_C32(0x27a90000), + SPH_C32(0x20d8735c), SPH_C32(0x5d474a07), SPH_C32(0x8c5bc939), + SPH_C32(0x10b0e7b2) }, + { SPH_C32(0x9d7f0000), SPH_C32(0x85b00000), SPH_C32(0xb1d60000), + SPH_C32(0xb44f0000), SPH_C32(0x0b636a4f), SPH_C32(0x3c1c9395), + SPH_C32(0x82a5aea5), SPH_C32(0xe23b14ef), SPH_C32(0x85000000), + SPH_C32(0x29890000), SPH_C32(0x07ae1f80), SPH_C32(0x1cf90000), + SPH_C32(0x6b0860a3), SPH_C32(0xdadc7e1f), SPH_C32(0xe51881f8), + SPH_C32(0xdaea604c) }, + { SPH_C32(0x516b0000), SPH_C32(0x20d30000), SPH_C32(0xeb6f0780), + SPH_C32(0x8f1f0000), SPH_C32(0x40b379b0), SPH_C32(0xbb87a78d), + SPH_C32(0xebe6e664), SPH_C32(0x28619311), SPH_C32(0x049e0000), + SPH_C32(0xc5de0000), SPH_C32(0x619c1d00), SPH_C32(0x890a0000), + SPH_C32(0x36a148a1), SPH_C32(0x922842a3), SPH_C32(0x034223d5), + SPH_C32(0x548dd7b6) }, + { SPH_C32(0x64c20000), SPH_C32(0x7b1b0000), SPH_C32(0x7ede0900), + SPH_C32(0xb1190000), SPH_C32(0x27f46a34), SPH_C32(0x0a01260d), + SPH_C32(0x9473acea), SPH_C32(0x0f3328be), SPH_C32(0xca250000), + SPH_C32(0xd7950000), SPH_C32(0x81391980), SPH_C32(0xe4c20000), + SPH_C32(0xc7fc1e8d), SPH_C32(0x95fbb0dc), SPH_C32(0xc35d7f8e), + SPH_C32(0x6a21ba33) }, + { SPH_C32(0xa8d60000), SPH_C32(0xde780000), SPH_C32(0x24670e80), + SPH_C32(0x8a490000), SPH_C32(0x6c2479cb), SPH_C32(0x8d9a1215), + SPH_C32(0xfd30e42b), SPH_C32(0xc569af40), SPH_C32(0x4bbb0000), + SPH_C32(0x3bc20000), SPH_C32(0xe70b1b00), SPH_C32(0x71310000), + SPH_C32(0x9a55368f), SPH_C32(0xdd0f8c60), SPH_C32(0x2507dda3), + SPH_C32(0xe4460dc9) }, + { SPH_C32(0xe55c0000), SPH_C32(0x974c0000), SPH_C32(0x18ec0b80), + SPH_C32(0x24ea0000), SPH_C32(0x7a5d4236), SPH_C32(0x42f51ab1), + SPH_C32(0x72290ec7), SPH_C32(0x81549f44), SPH_C32(0x87af0000), + SPH_C32(0x9ea10000), SPH_C32(0xbdb21c80), SPH_C32(0x4a610000), + SPH_C32(0xd1852570), SPH_C32(0x5a94b878), SPH_C32(0x4c449562), + SPH_C32(0x2e1c8a37) }, + { SPH_C32(0x29480000), SPH_C32(0x322f0000), SPH_C32(0x42550c00), + SPH_C32(0x1fba0000), SPH_C32(0x318d51c9), SPH_C32(0xc56e2ea9), + SPH_C32(0x1b6a4606), SPH_C32(0x4b0e18ba), SPH_C32(0x06310000), + SPH_C32(0x72f60000), SPH_C32(0xdb801e00), SPH_C32(0xdf920000), + SPH_C32(0x8c2c0d72), SPH_C32(0x126084c4), SPH_C32(0xaa1e374f), + SPH_C32(0xa07b3dcd) }, + { SPH_C32(0xb2060000), SPH_C32(0xc5690000), SPH_C32(0x28031200), + SPH_C32(0x74670000), SPH_C32(0xb6c236f4), SPH_C32(0xeb1239f8), + SPH_C32(0x33d1dfec), SPH_C32(0x094e3198), SPH_C32(0xac480000), + SPH_C32(0x1ba60000), SPH_C32(0x45fb1380), SPH_C32(0x03430000), + SPH_C32(0x5a85316a), SPH_C32(0x1fb250b6), SPH_C32(0xfe72c7fe), + SPH_C32(0x91e478f6) }, + { SPH_C32(0x7e120000), SPH_C32(0x600a0000), SPH_C32(0x72ba1580), + SPH_C32(0x4f370000), SPH_C32(0xfd12250b), SPH_C32(0x6c890de0), + SPH_C32(0x5a92972d), SPH_C32(0xc314b666), SPH_C32(0x2dd60000), + SPH_C32(0xf7f10000), SPH_C32(0x23c91100), SPH_C32(0x96b00000), + SPH_C32(0x072c1968), SPH_C32(0x57466c0a), SPH_C32(0x182865d3), + SPH_C32(0x1f83cf0c) }, + { SPH_C32(0x33980000), SPH_C32(0x293e0000), SPH_C32(0x4e311080), + SPH_C32(0xe1940000), SPH_C32(0xeb6b1ef6), SPH_C32(0xa3e60544), + SPH_C32(0xd58b7dc1), SPH_C32(0x87298662), SPH_C32(0xe1c20000), + SPH_C32(0x52920000), SPH_C32(0x79701680), SPH_C32(0xade00000), + SPH_C32(0x4cfc0a97), SPH_C32(0xd0dd5812), SPH_C32(0x716b2d12), + SPH_C32(0xd5d948f2) }, + { SPH_C32(0xff8c0000), SPH_C32(0x8c5d0000), SPH_C32(0x14881700), + SPH_C32(0xdac40000), SPH_C32(0xa0bb0d09), SPH_C32(0x247d315c), + SPH_C32(0xbcc83500), SPH_C32(0x4d73019c), SPH_C32(0x605c0000), + SPH_C32(0xbec50000), SPH_C32(0x1f421400), SPH_C32(0x38130000), + SPH_C32(0x11552295), SPH_C32(0x982964ae), SPH_C32(0x97318f3f), + SPH_C32(0x5bbeff08) }, + { SPH_C32(0xca250000), SPH_C32(0xd7950000), SPH_C32(0x81391980), + SPH_C32(0xe4c20000), SPH_C32(0xc7fc1e8d), SPH_C32(0x95fbb0dc), + SPH_C32(0xc35d7f8e), SPH_C32(0x6a21ba33), SPH_C32(0xaee70000), + SPH_C32(0xac8e0000), SPH_C32(0xffe71080), SPH_C32(0x55db0000), + SPH_C32(0xe00874b9), SPH_C32(0x9ffa96d1), SPH_C32(0x572ed364), + SPH_C32(0x6512928d) }, + { SPH_C32(0x06310000), SPH_C32(0x72f60000), SPH_C32(0xdb801e00), + SPH_C32(0xdf920000), SPH_C32(0x8c2c0d72), SPH_C32(0x126084c4), + SPH_C32(0xaa1e374f), SPH_C32(0xa07b3dcd), SPH_C32(0x2f790000), + SPH_C32(0x40d90000), SPH_C32(0x99d51200), SPH_C32(0xc0280000), + SPH_C32(0xbda15cbb), SPH_C32(0xd70eaa6d), SPH_C32(0xb1747149), + SPH_C32(0xeb752577) }, + { SPH_C32(0x4bbb0000), SPH_C32(0x3bc20000), SPH_C32(0xe70b1b00), + SPH_C32(0x71310000), SPH_C32(0x9a55368f), SPH_C32(0xdd0f8c60), + SPH_C32(0x2507dda3), SPH_C32(0xe4460dc9), SPH_C32(0xe36d0000), + SPH_C32(0xe5ba0000), SPH_C32(0xc36c1580), SPH_C32(0xfb780000), + SPH_C32(0xf6714f44), SPH_C32(0x50959e75), SPH_C32(0xd8373988), + SPH_C32(0x212fa289) }, + { SPH_C32(0x87af0000), SPH_C32(0x9ea10000), SPH_C32(0xbdb21c80), + SPH_C32(0x4a610000), SPH_C32(0xd1852570), SPH_C32(0x5a94b878), + SPH_C32(0x4c449562), SPH_C32(0x2e1c8a37), SPH_C32(0x62f30000), + SPH_C32(0x09ed0000), SPH_C32(0xa55e1700), SPH_C32(0x6e8b0000), + SPH_C32(0xabd86746), SPH_C32(0x1861a2c9), SPH_C32(0x3e6d9ba5), + SPH_C32(0xaf481573) }, + { SPH_C32(0xb0a90000), SPH_C32(0x72410000), SPH_C32(0x921f1100), + SPH_C32(0x22ff0000), SPH_C32(0x0c4f7327), SPH_C32(0x6b5aff9f), + SPH_C32(0x9a8dcb76), SPH_C32(0xfdb8dbe3), SPH_C32(0xd6c40000), + SPH_C32(0xbe720000), SPH_C32(0x56dd1b00), SPH_C32(0xc57e0000), + SPH_C32(0x91365cc0), SPH_C32(0xe1131ff5), SPH_C32(0xa7a27306), + SPH_C32(0x067d1926) }, + { SPH_C32(0x7cbd0000), SPH_C32(0xd7220000), SPH_C32(0xc8a61680), + SPH_C32(0x19af0000), SPH_C32(0x479f60d8), SPH_C32(0xecc1cb87), + SPH_C32(0xf3ce83b7), SPH_C32(0x37e25c1d), SPH_C32(0x575a0000), + SPH_C32(0x52250000), SPH_C32(0x30ef1980), SPH_C32(0x508d0000), + SPH_C32(0xcc9f74c2), SPH_C32(0xa9e72349), SPH_C32(0x41f8d12b), + SPH_C32(0x881aaedc) }, + { SPH_C32(0x31370000), SPH_C32(0x9e160000), SPH_C32(0xf42d1380), + SPH_C32(0xb70c0000), SPH_C32(0x51e65b25), SPH_C32(0x23aec323), + SPH_C32(0x7cd7695b), SPH_C32(0x73df6c19), SPH_C32(0x9b4e0000), + SPH_C32(0xf7460000), SPH_C32(0x6a561e00), SPH_C32(0x6bdd0000), + SPH_C32(0x874f673d), SPH_C32(0x2e7c1751), SPH_C32(0x28bb99ea), + SPH_C32(0x42402922) }, + { SPH_C32(0xfd230000), SPH_C32(0x3b750000), SPH_C32(0xae941400), + SPH_C32(0x8c5c0000), SPH_C32(0x1a3648da), SPH_C32(0xa435f73b), + SPH_C32(0x1594219a), SPH_C32(0xb985ebe7), SPH_C32(0x1ad00000), + SPH_C32(0x1b110000), SPH_C32(0x0c641c80), SPH_C32(0xfe2e0000), + SPH_C32(0xdae64f3f), SPH_C32(0x66882bed), SPH_C32(0xcee13bc7), + SPH_C32(0xcc279ed8) }, + { SPH_C32(0xc88a0000), SPH_C32(0x60bd0000), SPH_C32(0x3b251a80), + SPH_C32(0xb25a0000), SPH_C32(0x7d715b5e), SPH_C32(0x15b376bb), + SPH_C32(0x6a016b14), SPH_C32(0x9ed75048), SPH_C32(0xd46b0000), + SPH_C32(0x095a0000), SPH_C32(0xecc11800), SPH_C32(0x93e60000), + SPH_C32(0x2bbb1913), SPH_C32(0x615bd992), SPH_C32(0x0efe679c), + SPH_C32(0xf28bf35d) }, + { SPH_C32(0x049e0000), SPH_C32(0xc5de0000), SPH_C32(0x619c1d00), + SPH_C32(0x890a0000), SPH_C32(0x36a148a1), SPH_C32(0x922842a3), + SPH_C32(0x034223d5), SPH_C32(0x548dd7b6), SPH_C32(0x55f50000), + SPH_C32(0xe50d0000), SPH_C32(0x8af31a80), SPH_C32(0x06150000), + SPH_C32(0x76123111), SPH_C32(0x29afe52e), SPH_C32(0xe8a4c5b1), + SPH_C32(0x7cec44a7) }, + { SPH_C32(0x49140000), SPH_C32(0x8cea0000), SPH_C32(0x5d171800), + SPH_C32(0x27a90000), SPH_C32(0x20d8735c), SPH_C32(0x5d474a07), + SPH_C32(0x8c5bc939), SPH_C32(0x10b0e7b2), SPH_C32(0x99e10000), + SPH_C32(0x406e0000), SPH_C32(0xd04a1d00), SPH_C32(0x3d450000), + SPH_C32(0x3dc222ee), SPH_C32(0xae34d136), SPH_C32(0x81e78d70), + SPH_C32(0xb6b6c359) }, + { SPH_C32(0x85000000), SPH_C32(0x29890000), SPH_C32(0x07ae1f80), + SPH_C32(0x1cf90000), SPH_C32(0x6b0860a3), SPH_C32(0xdadc7e1f), + SPH_C32(0xe51881f8), SPH_C32(0xdaea604c), SPH_C32(0x187f0000), + SPH_C32(0xac390000), SPH_C32(0xb6781f80), SPH_C32(0xa8b60000), + SPH_C32(0x606b0aec), SPH_C32(0xe6c0ed8a), SPH_C32(0x67bd2f5d), + SPH_C32(0x38d174a3) }, + { SPH_C32(0xaec30000), SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), + SPH_C32(0x2c150000), SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), + SPH_C32(0xab92f78f), SPH_C32(0xa312567b), SPH_C32(0xdb250000), + SPH_C32(0x09290000), SPH_C32(0x49aac000), SPH_C32(0x81e10000), + SPH_C32(0xcafe6b59), SPH_C32(0x42793431), SPH_C32(0x43566b76), + SPH_C32(0xe86cba2e) }, + { SPH_C32(0x62d70000), SPH_C32(0x392c0001), SPH_C32(0x2368e780), + SPH_C32(0x17450000), SPH_C32(0x0e1c664c), SPH_C32(0xe1cb832e), + SPH_C32(0xc2d1bf4e), SPH_C32(0x6948d185), SPH_C32(0x5abb0000), + SPH_C32(0xe57e0000), SPH_C32(0x2f98c280), SPH_C32(0x14120000), + SPH_C32(0x9757435b), SPH_C32(0x0a8d088d), SPH_C32(0xa50cc95b), + SPH_C32(0x660b0dd4) }, + { SPH_C32(0x2f5d0000), SPH_C32(0x70180001), SPH_C32(0x1fe3e280), + SPH_C32(0xb9e60000), SPH_C32(0x18655db1), SPH_C32(0x2ea48b8a), + SPH_C32(0x4dc855a2), SPH_C32(0x2d75e181), SPH_C32(0x96af0000), + SPH_C32(0x401d0000), SPH_C32(0x7521c500), SPH_C32(0x2f420000), + SPH_C32(0xdc8750a4), SPH_C32(0x8d163c95), SPH_C32(0xcc4f819a), + SPH_C32(0xac518a2a) }, + { SPH_C32(0xe3490000), SPH_C32(0xd57b0001), SPH_C32(0x455ae500), + SPH_C32(0x82b60000), SPH_C32(0x53b54e4e), SPH_C32(0xa93fbf92), + SPH_C32(0x248b1d63), SPH_C32(0xe72f667f), SPH_C32(0x17310000), + SPH_C32(0xac4a0000), SPH_C32(0x1313c780), SPH_C32(0xbab10000), + SPH_C32(0x812e78a6), SPH_C32(0xc5e20029), SPH_C32(0x2a1523b7), + SPH_C32(0x22363dd0) }, + { SPH_C32(0xd6e00000), SPH_C32(0x8eb30001), SPH_C32(0xd0ebeb80), + SPH_C32(0xbcb00000), SPH_C32(0x34f25dca), SPH_C32(0x18b93e12), + SPH_C32(0x5b1e57ed), SPH_C32(0xc07dddd0), SPH_C32(0xd98a0000), + SPH_C32(0xbe010000), SPH_C32(0xf3b6c300), SPH_C32(0xd7790000), + SPH_C32(0x70732e8a), SPH_C32(0xc231f256), SPH_C32(0xea0a7fec), + SPH_C32(0x1c9a5055) }, + { SPH_C32(0x1af40000), SPH_C32(0x2bd00001), SPH_C32(0x8a52ec00), + SPH_C32(0x87e00000), SPH_C32(0x7f224e35), SPH_C32(0x9f220a0a), + SPH_C32(0x325d1f2c), SPH_C32(0x0a275a2e), SPH_C32(0x58140000), + SPH_C32(0x52560000), SPH_C32(0x9584c180), SPH_C32(0x428a0000), + SPH_C32(0x2dda0688), SPH_C32(0x8ac5ceea), SPH_C32(0x0c50ddc1), + SPH_C32(0x92fde7af) }, + { SPH_C32(0x577e0000), SPH_C32(0x62e40001), SPH_C32(0xb6d9e900), + SPH_C32(0x29430000), SPH_C32(0x695b75c8), SPH_C32(0x504d02ae), + SPH_C32(0xbd44f5c0), SPH_C32(0x4e1a6a2a), SPH_C32(0x94000000), + SPH_C32(0xf7350000), SPH_C32(0xcf3dc600), SPH_C32(0x79da0000), + SPH_C32(0x660a1577), SPH_C32(0x0d5efaf2), SPH_C32(0x65139500), + SPH_C32(0x58a76051) }, + { SPH_C32(0x9b6a0000), SPH_C32(0xc7870001), SPH_C32(0xec60ee80), + SPH_C32(0x12130000), SPH_C32(0x228b6637), SPH_C32(0xd7d636b6), + SPH_C32(0xd407bd01), SPH_C32(0x8440edd4), SPH_C32(0x159e0000), + SPH_C32(0x1b620000), SPH_C32(0xa90fc480), SPH_C32(0xec290000), + SPH_C32(0x3ba33d75), SPH_C32(0x45aac64e), SPH_C32(0x8349372d), + SPH_C32(0xd6c0d7ab) }, + { SPH_C32(0xac6c0000), SPH_C32(0x2b670001), SPH_C32(0xc3cde300), + SPH_C32(0x7a8d0000), SPH_C32(0xff413060), SPH_C32(0xe6187151), + SPH_C32(0x02cee315), SPH_C32(0x57e4bc00), SPH_C32(0xa1a90000), + SPH_C32(0xacfd0000), SPH_C32(0x5a8cc880), SPH_C32(0x47dc0000), + SPH_C32(0x014d06f3), SPH_C32(0xbcd87b72), SPH_C32(0x1a86df8e), + SPH_C32(0x7ff5dbfe) }, + { SPH_C32(0x60780000), SPH_C32(0x8e040001), SPH_C32(0x9974e480), + SPH_C32(0x41dd0000), SPH_C32(0xb491239f), SPH_C32(0x61834549), + SPH_C32(0x6b8dabd4), SPH_C32(0x9dbe3bfe), SPH_C32(0x20370000), + SPH_C32(0x40aa0000), SPH_C32(0x3cbeca00), SPH_C32(0xd22f0000), + SPH_C32(0x5ce42ef1), SPH_C32(0xf42c47ce), SPH_C32(0xfcdc7da3), + SPH_C32(0xf1926c04) }, + { SPH_C32(0x2df20000), SPH_C32(0xc7300001), SPH_C32(0xa5ffe180), + SPH_C32(0xef7e0000), SPH_C32(0xa2e81862), SPH_C32(0xaeec4ded), + SPH_C32(0xe4944138), SPH_C32(0xd9830bfa), SPH_C32(0xec230000), + SPH_C32(0xe5c90000), SPH_C32(0x6607cd80), SPH_C32(0xe97f0000), + SPH_C32(0x17343d0e), SPH_C32(0x73b773d6), SPH_C32(0x959f3562), + SPH_C32(0x3bc8ebfa) }, + { SPH_C32(0xe1e60000), SPH_C32(0x62530001), SPH_C32(0xff46e600), + SPH_C32(0xd42e0000), SPH_C32(0xe9380b9d), SPH_C32(0x297779f5), + SPH_C32(0x8dd709f9), SPH_C32(0x13d98c04), SPH_C32(0x6dbd0000), + SPH_C32(0x099e0000), SPH_C32(0x0035cf00), SPH_C32(0x7c8c0000), + SPH_C32(0x4a9d150c), SPH_C32(0x3b434f6a), SPH_C32(0x73c5974f), + SPH_C32(0xb5af5c00) }, + { SPH_C32(0xd44f0000), SPH_C32(0x399b0001), SPH_C32(0x6af7e880), + SPH_C32(0xea280000), SPH_C32(0x8e7f1819), SPH_C32(0x98f1f875), + SPH_C32(0xf2424377), SPH_C32(0x348b37ab), SPH_C32(0xa3060000), + SPH_C32(0x1bd50000), SPH_C32(0xe090cb80), SPH_C32(0x11440000), + SPH_C32(0xbbc04320), SPH_C32(0x3c90bd15), SPH_C32(0xb3dacb14), + SPH_C32(0x8b033185) }, + { SPH_C32(0x185b0000), SPH_C32(0x9cf80001), SPH_C32(0x304eef00), + SPH_C32(0xd1780000), SPH_C32(0xc5af0be6), SPH_C32(0x1f6acc6d), + SPH_C32(0x9b010bb6), SPH_C32(0xfed1b055), SPH_C32(0x22980000), + SPH_C32(0xf7820000), SPH_C32(0x86a2c900), SPH_C32(0x84b70000), + SPH_C32(0xe6696b22), SPH_C32(0x746481a9), SPH_C32(0x55806939), + SPH_C32(0x0564867f) }, + { SPH_C32(0x55d10000), SPH_C32(0xd5cc0001), SPH_C32(0x0cc5ea00), + SPH_C32(0x7fdb0000), SPH_C32(0xd3d6301b), SPH_C32(0xd005c4c9), + SPH_C32(0x1418e15a), SPH_C32(0xbaec8051), SPH_C32(0xee8c0000), + SPH_C32(0x52e10000), SPH_C32(0xdc1bce80), SPH_C32(0xbfe70000), + SPH_C32(0xadb978dd), SPH_C32(0xf3ffb5b1), SPH_C32(0x3cc321f8), + SPH_C32(0xcf3e0181) }, + { SPH_C32(0x99c50000), SPH_C32(0x70af0001), SPH_C32(0x567ced80), + SPH_C32(0x448b0000), SPH_C32(0x980623e4), SPH_C32(0x579ef0d1), + SPH_C32(0x7d5ba99b), SPH_C32(0x70b607af), SPH_C32(0x6f120000), + SPH_C32(0xbeb60000), SPH_C32(0xba29cc00), SPH_C32(0x2a140000), + SPH_C32(0xf01050df), SPH_C32(0xbb0b890d), SPH_C32(0xda9983d5), + SPH_C32(0x4159b67b) }, + { SPH_C32(0x028b0000), SPH_C32(0x87e90001), SPH_C32(0x3c2af380), + SPH_C32(0x2f560000), SPH_C32(0x1f4944d9), SPH_C32(0x79e2e780), + SPH_C32(0x55e03071), SPH_C32(0x32f62e8d), SPH_C32(0xc56b0000), + SPH_C32(0xd7e60000), SPH_C32(0x2452c180), SPH_C32(0xf6c50000), + SPH_C32(0x26b96cc7), SPH_C32(0xb6d95d7f), SPH_C32(0x8ef57364), + SPH_C32(0x70c6f340) }, + { SPH_C32(0xce9f0000), SPH_C32(0x228a0001), SPH_C32(0x6693f400), + SPH_C32(0x14060000), SPH_C32(0x54995726), SPH_C32(0xfe79d398), + SPH_C32(0x3ca378b0), SPH_C32(0xf8aca973), SPH_C32(0x44f50000), + SPH_C32(0x3bb10000), SPH_C32(0x4260c300), SPH_C32(0x63360000), + SPH_C32(0x7b1044c5), SPH_C32(0xfe2d61c3), SPH_C32(0x68afd149), + SPH_C32(0xfea144ba) }, + { SPH_C32(0x83150000), SPH_C32(0x6bbe0001), SPH_C32(0x5a18f100), + SPH_C32(0xbaa50000), SPH_C32(0x42e06cdb), SPH_C32(0x3116db3c), + SPH_C32(0xb3ba925c), SPH_C32(0xbc919977), SPH_C32(0x88e10000), + SPH_C32(0x9ed20000), SPH_C32(0x18d9c480), SPH_C32(0x58660000), + SPH_C32(0x30c0573a), SPH_C32(0x79b655db), SPH_C32(0x01ec9988), + SPH_C32(0x34fbc344) }, + { SPH_C32(0x4f010000), SPH_C32(0xcedd0001), SPH_C32(0x00a1f680), + SPH_C32(0x81f50000), SPH_C32(0x09307f24), SPH_C32(0xb68def24), + SPH_C32(0xdaf9da9d), SPH_C32(0x76cb1e89), SPH_C32(0x097f0000), + SPH_C32(0x72850000), SPH_C32(0x7eebc600), SPH_C32(0xcd950000), + SPH_C32(0x6d697f38), SPH_C32(0x31426967), SPH_C32(0xe7b63ba5), + SPH_C32(0xba9c74be) }, + { SPH_C32(0x7aa80000), SPH_C32(0x95150001), SPH_C32(0x9510f800), + SPH_C32(0xbff30000), SPH_C32(0x6e776ca0), SPH_C32(0x070b6ea4), + SPH_C32(0xa56c9013), SPH_C32(0x5199a526), SPH_C32(0xc7c40000), + SPH_C32(0x60ce0000), SPH_C32(0x9e4ec280), SPH_C32(0xa05d0000), + SPH_C32(0x9c342914), SPH_C32(0x36919b18), SPH_C32(0x27a967fe), + SPH_C32(0x8430193b) }, + { SPH_C32(0xb6bc0000), SPH_C32(0x30760001), SPH_C32(0xcfa9ff80), + SPH_C32(0x84a30000), SPH_C32(0x25a77f5f), SPH_C32(0x80905abc), + SPH_C32(0xcc2fd8d2), SPH_C32(0x9bc322d8), SPH_C32(0x465a0000), + SPH_C32(0x8c990000), SPH_C32(0xf87cc000), SPH_C32(0x35ae0000), + SPH_C32(0xc19d0116), SPH_C32(0x7e65a7a4), SPH_C32(0xc1f3c5d3), + SPH_C32(0x0a57aec1) }, + { SPH_C32(0xfb360000), SPH_C32(0x79420001), SPH_C32(0xf322fa80), + SPH_C32(0x2a000000), SPH_C32(0x33de44a2), SPH_C32(0x4fff5218), + SPH_C32(0x4336323e), SPH_C32(0xdffe12dc), SPH_C32(0x8a4e0000), + SPH_C32(0x29fa0000), SPH_C32(0xa2c5c780), SPH_C32(0x0efe0000), + SPH_C32(0x8a4d12e9), SPH_C32(0xf9fe93bc), SPH_C32(0xa8b08d12), + SPH_C32(0xc00d293f) }, + { SPH_C32(0x37220000), SPH_C32(0xdc210001), SPH_C32(0xa99bfd00), + SPH_C32(0x11500000), SPH_C32(0x780e575d), SPH_C32(0xc8646600), + SPH_C32(0x2a757aff), SPH_C32(0x15a49522), SPH_C32(0x0bd00000), + SPH_C32(0xc5ad0000), SPH_C32(0xc4f7c500), SPH_C32(0x9b0d0000), + SPH_C32(0xd7e43aeb), SPH_C32(0xb10aaf00), SPH_C32(0x4eea2f3f), + SPH_C32(0x4e6a9ec5) }, + { SPH_C32(0x00240000), SPH_C32(0x30c10001), SPH_C32(0x8636f080), + SPH_C32(0x79ce0000), SPH_C32(0xa5c4010a), SPH_C32(0xf9aa21e7), + SPH_C32(0xfcbc24eb), SPH_C32(0xc600c4f6), SPH_C32(0xbfe70000), + SPH_C32(0x72320000), SPH_C32(0x3774c900), SPH_C32(0x30f80000), + SPH_C32(0xed0a016d), SPH_C32(0x4878123c), SPH_C32(0xd725c79c), + SPH_C32(0xe75f9290) }, + { SPH_C32(0xcc300000), SPH_C32(0x95a20001), SPH_C32(0xdc8ff700), + SPH_C32(0x429e0000), SPH_C32(0xee1412f5), SPH_C32(0x7e3115ff), + SPH_C32(0x95ff6c2a), SPH_C32(0x0c5a4308), SPH_C32(0x3e790000), + SPH_C32(0x9e650000), SPH_C32(0x5146cb80), SPH_C32(0xa50b0000), + SPH_C32(0xb0a3296f), SPH_C32(0x008c2e80), SPH_C32(0x317f65b1), + SPH_C32(0x6938256a) }, + { SPH_C32(0x81ba0000), SPH_C32(0xdc960001), SPH_C32(0xe004f200), + SPH_C32(0xec3d0000), SPH_C32(0xf86d2908), SPH_C32(0xb15e1d5b), + SPH_C32(0x1ae686c6), SPH_C32(0x4867730c), SPH_C32(0xf26d0000), + SPH_C32(0x3b060000), SPH_C32(0x0bffcc00), SPH_C32(0x9e5b0000), + SPH_C32(0xfb733a90), SPH_C32(0x87171a98), SPH_C32(0x583c2d70), + SPH_C32(0xa362a294) }, + { SPH_C32(0x4dae0000), SPH_C32(0x79f50001), SPH_C32(0xbabdf580), + SPH_C32(0xd76d0000), SPH_C32(0xb3bd3af7), SPH_C32(0x36c52943), + SPH_C32(0x73a5ce07), SPH_C32(0x823df4f2), SPH_C32(0x73f30000), + SPH_C32(0xd7510000), SPH_C32(0x6dcdce80), SPH_C32(0x0ba80000), + SPH_C32(0xa6da1292), SPH_C32(0xcfe32624), SPH_C32(0xbe668f5d), + SPH_C32(0x2d05156e) }, + { SPH_C32(0x78070000), SPH_C32(0x223d0001), SPH_C32(0x2f0cfb00), + SPH_C32(0xe96b0000), SPH_C32(0xd4fa2973), SPH_C32(0x8743a8c3), + SPH_C32(0x0c308489), SPH_C32(0xa56f4f5d), SPH_C32(0xbd480000), + SPH_C32(0xc51a0000), SPH_C32(0x8d68ca00), SPH_C32(0x66600000), + SPH_C32(0x578744be), SPH_C32(0xc830d45b), SPH_C32(0x7e79d306), + SPH_C32(0x13a978eb) }, + { SPH_C32(0xb4130000), SPH_C32(0x875e0001), SPH_C32(0x75b5fc80), + SPH_C32(0xd23b0000), SPH_C32(0x9f2a3a8c), SPH_C32(0x00d89cdb), + SPH_C32(0x6573cc48), SPH_C32(0x6f35c8a3), SPH_C32(0x3cd60000), + SPH_C32(0x294d0000), SPH_C32(0xeb5ac880), SPH_C32(0xf3930000), + SPH_C32(0x0a2e6cbc), SPH_C32(0x80c4e8e7), SPH_C32(0x9823712b), + SPH_C32(0x9dcecf11) }, + { SPH_C32(0xf9990000), SPH_C32(0xce6a0001), SPH_C32(0x493ef980), + SPH_C32(0x7c980000), SPH_C32(0x89530171), SPH_C32(0xcfb7947f), + SPH_C32(0xea6a26a4), SPH_C32(0x2b08f8a7), SPH_C32(0xf0c20000), + SPH_C32(0x8c2e0000), SPH_C32(0xb1e3cf00), SPH_C32(0xc8c30000), + SPH_C32(0x41fe7f43), SPH_C32(0x075fdcff), SPH_C32(0xf16039ea), + SPH_C32(0x579448ef) }, + { SPH_C32(0x358d0000), SPH_C32(0x6b090001), SPH_C32(0x1387fe00), + SPH_C32(0x47c80000), SPH_C32(0xc283128e), SPH_C32(0x482ca067), + SPH_C32(0x83296e65), SPH_C32(0xe1527f59), SPH_C32(0x715c0000), + SPH_C32(0x60790000), SPH_C32(0xd7d1cd80), SPH_C32(0x5d300000), + SPH_C32(0x1c575741), SPH_C32(0x4fabe043), SPH_C32(0x173a9bc7), + SPH_C32(0xd9f3ff15) }, + { SPH_C32(0xb08d0000), SPH_C32(0x42800001), SPH_C32(0x1429e180), + SPH_C32(0x5b310000), SPH_C32(0xa98b722d), SPH_C32(0x92f0de78), + SPH_C32(0x6631ef9d), SPH_C32(0x3bb81f15), SPH_C32(0x69230000), + SPH_C32(0xcc400000), SPH_C32(0x61a9d200), SPH_C32(0xf5860000), + SPH_C32(0x7c3c5dad), SPH_C32(0xa96b0dc9), SPH_C32(0x7087b49a), + SPH_C32(0xe1228bb6) }, + { SPH_C32(0x7c990000), SPH_C32(0xe7e30001), SPH_C32(0x4e90e600), + SPH_C32(0x60610000), SPH_C32(0xe25b61d2), SPH_C32(0x156bea60), + SPH_C32(0x0f72a75c), SPH_C32(0xf1e298eb), SPH_C32(0xe8bd0000), + SPH_C32(0x20170000), SPH_C32(0x079bd080), SPH_C32(0x60750000), + SPH_C32(0x219575af), SPH_C32(0xe19f3175), SPH_C32(0x96dd16b7), + SPH_C32(0x6f453c4c) }, + { SPH_C32(0x31130000), SPH_C32(0xaed70001), SPH_C32(0x721be300), + SPH_C32(0xcec20000), SPH_C32(0xf4225a2f), SPH_C32(0xda04e2c4), + SPH_C32(0x806b4db0), SPH_C32(0xb5dfa8ef), SPH_C32(0x24a90000), + SPH_C32(0x85740000), SPH_C32(0x5d22d700), SPH_C32(0x5b250000), + SPH_C32(0x6a456650), SPH_C32(0x6604056d), SPH_C32(0xff9e5e76), + SPH_C32(0xa51fbbb2) }, + { SPH_C32(0xfd070000), SPH_C32(0x0bb40001), SPH_C32(0x28a2e480), + SPH_C32(0xf5920000), SPH_C32(0xbff249d0), SPH_C32(0x5d9fd6dc), + SPH_C32(0xe9280571), SPH_C32(0x7f852f11), SPH_C32(0xa5370000), + SPH_C32(0x69230000), SPH_C32(0x3b10d580), SPH_C32(0xced60000), + SPH_C32(0x37ec4e52), SPH_C32(0x2ef039d1), SPH_C32(0x19c4fc5b), + SPH_C32(0x2b780c48) }, + { SPH_C32(0xc8ae0000), SPH_C32(0x507c0001), SPH_C32(0xbd13ea00), + SPH_C32(0xcb940000), SPH_C32(0xd8b55a54), SPH_C32(0xec19575c), + SPH_C32(0x96bd4fff), SPH_C32(0x58d794be), SPH_C32(0x6b8c0000), + SPH_C32(0x7b680000), SPH_C32(0xdbb5d100), SPH_C32(0xa31e0000), + SPH_C32(0xc6b1187e), SPH_C32(0x2923cbae), SPH_C32(0xd9dba000), + SPH_C32(0x15d461cd) }, + { SPH_C32(0x04ba0000), SPH_C32(0xf51f0001), SPH_C32(0xe7aaed80), + SPH_C32(0xf0c40000), SPH_C32(0x936549ab), SPH_C32(0x6b826344), + SPH_C32(0xfffe073e), SPH_C32(0x928d1340), SPH_C32(0xea120000), + SPH_C32(0x973f0000), SPH_C32(0xbd87d380), SPH_C32(0x36ed0000), + SPH_C32(0x9b18307c), SPH_C32(0x61d7f712), SPH_C32(0x3f81022d), + SPH_C32(0x9bb3d637) }, + { SPH_C32(0x49300000), SPH_C32(0xbc2b0001), SPH_C32(0xdb21e880), + SPH_C32(0x5e670000), SPH_C32(0x851c7256), SPH_C32(0xa4ed6be0), + SPH_C32(0x70e7edd2), SPH_C32(0xd6b02344), SPH_C32(0x26060000), + SPH_C32(0x325c0000), SPH_C32(0xe73ed400), SPH_C32(0x0dbd0000), + SPH_C32(0xd0c82383), SPH_C32(0xe64cc30a), SPH_C32(0x56c24aec), + SPH_C32(0x51e951c9) }, + { SPH_C32(0x85240000), SPH_C32(0x19480001), SPH_C32(0x8198ef00), + SPH_C32(0x65370000), SPH_C32(0xcecc61a9), SPH_C32(0x23765ff8), + SPH_C32(0x19a4a513), SPH_C32(0x1ceaa4ba), SPH_C32(0xa7980000), + SPH_C32(0xde0b0000), SPH_C32(0x810cd680), SPH_C32(0x984e0000), + SPH_C32(0x8d610b81), SPH_C32(0xaeb8ffb6), SPH_C32(0xb098e8c1), + SPH_C32(0xdf8ee633) }, + { SPH_C32(0xb2220000), SPH_C32(0xf5a80001), SPH_C32(0xae35e280), + SPH_C32(0x0da90000), SPH_C32(0x130637fe), SPH_C32(0x12b8181f), + SPH_C32(0xcf6dfb07), SPH_C32(0xcf4ef56e), SPH_C32(0x13af0000), + SPH_C32(0x69940000), SPH_C32(0x728fda80), SPH_C32(0x33bb0000), + SPH_C32(0xb78f3007), SPH_C32(0x57ca428a), SPH_C32(0x29570062), + SPH_C32(0x76bbea66) }, + { SPH_C32(0x7e360000), SPH_C32(0x50cb0001), SPH_C32(0xf48ce500), + SPH_C32(0x36f90000), SPH_C32(0x58d62401), SPH_C32(0x95232c07), + SPH_C32(0xa62eb3c6), SPH_C32(0x05147290), SPH_C32(0x92310000), + SPH_C32(0x85c30000), SPH_C32(0x14bdd800), SPH_C32(0xa6480000), + SPH_C32(0xea261805), SPH_C32(0x1f3e7e36), SPH_C32(0xcf0da24f), + SPH_C32(0xf8dc5d9c) }, + { SPH_C32(0x33bc0000), SPH_C32(0x19ff0001), SPH_C32(0xc807e000), + SPH_C32(0x985a0000), SPH_C32(0x4eaf1ffc), SPH_C32(0x5a4c24a3), + SPH_C32(0x2937592a), SPH_C32(0x41294294), SPH_C32(0x5e250000), + SPH_C32(0x20a00000), SPH_C32(0x4e04df80), SPH_C32(0x9d180000), + SPH_C32(0xa1f60bfa), SPH_C32(0x98a54a2e), SPH_C32(0xa64eea8e), + SPH_C32(0x3286da62) }, + { SPH_C32(0xffa80000), SPH_C32(0xbc9c0001), SPH_C32(0x92bee780), + SPH_C32(0xa30a0000), SPH_C32(0x057f0c03), SPH_C32(0xddd710bb), + SPH_C32(0x407411eb), SPH_C32(0x8b73c56a), SPH_C32(0xdfbb0000), + SPH_C32(0xccf70000), SPH_C32(0x2836dd00), SPH_C32(0x08eb0000), + SPH_C32(0xfc5f23f8), SPH_C32(0xd0517692), SPH_C32(0x401448a3), + SPH_C32(0xbce16d98) }, + { SPH_C32(0xca010000), SPH_C32(0xe7540001), SPH_C32(0x070fe900), + SPH_C32(0x9d0c0000), SPH_C32(0x62381f87), SPH_C32(0x6c51913b), + SPH_C32(0x3fe15b65), SPH_C32(0xac217ec5), SPH_C32(0x11000000), + SPH_C32(0xdebc0000), SPH_C32(0xc893d980), SPH_C32(0x65230000), + SPH_C32(0x0d0275d4), SPH_C32(0xd78284ed), SPH_C32(0x800b14f8), + SPH_C32(0x824d001d) }, + { SPH_C32(0x06150000), SPH_C32(0x42370001), SPH_C32(0x5db6ee80), + SPH_C32(0xa65c0000), SPH_C32(0x29e80c78), SPH_C32(0xebcaa523), + SPH_C32(0x56a213a4), SPH_C32(0x667bf93b), SPH_C32(0x909e0000), + SPH_C32(0x32eb0000), SPH_C32(0xaea1db00), SPH_C32(0xf0d00000), + SPH_C32(0x50ab5dd6), SPH_C32(0x9f76b851), SPH_C32(0x6651b6d5), + SPH_C32(0x0c2ab7e7) }, + { SPH_C32(0x4b9f0000), SPH_C32(0x0b030001), SPH_C32(0x613deb80), + SPH_C32(0x08ff0000), SPH_C32(0x3f913785), SPH_C32(0x24a5ad87), + SPH_C32(0xd9bbf948), SPH_C32(0x2246c93f), SPH_C32(0x5c8a0000), + SPH_C32(0x97880000), SPH_C32(0xf418dc80), SPH_C32(0xcb800000), + SPH_C32(0x1b7b4e29), SPH_C32(0x18ed8c49), SPH_C32(0x0f12fe14), + SPH_C32(0xc6703019) }, + { SPH_C32(0x878b0000), SPH_C32(0xae600001), SPH_C32(0x3b84ec00), + SPH_C32(0x33af0000), SPH_C32(0x7441247a), SPH_C32(0xa33e999f), + SPH_C32(0xb0f8b189), SPH_C32(0xe81c4ec1), SPH_C32(0xdd140000), + SPH_C32(0x7bdf0000), SPH_C32(0x922ade00), SPH_C32(0x5e730000), + SPH_C32(0x46d2662b), SPH_C32(0x5019b0f5), SPH_C32(0xe9485c39), + SPH_C32(0x481787e3) }, + { SPH_C32(0x1cc50000), SPH_C32(0x59260001), SPH_C32(0x51d2f200), + SPH_C32(0x58720000), SPH_C32(0xf30e4347), SPH_C32(0x8d428ece), + SPH_C32(0x98432863), SPH_C32(0xaa5c67e3), SPH_C32(0x776d0000), + SPH_C32(0x128f0000), SPH_C32(0x0c51d380), SPH_C32(0x82a20000), + SPH_C32(0x907b5a33), SPH_C32(0x5dcb6487), SPH_C32(0xbd24ac88), + SPH_C32(0x7988c2d8) }, + { SPH_C32(0xd0d10000), SPH_C32(0xfc450001), SPH_C32(0x0b6bf580), + SPH_C32(0x63220000), SPH_C32(0xb8de50b8), SPH_C32(0x0ad9bad6), + SPH_C32(0xf10060a2), SPH_C32(0x6006e01d), SPH_C32(0xf6f30000), + SPH_C32(0xfed80000), SPH_C32(0x6a63d100), SPH_C32(0x17510000), + SPH_C32(0xcdd27231), SPH_C32(0x153f583b), SPH_C32(0x5b7e0ea5), + SPH_C32(0xf7ef7522) }, + { SPH_C32(0x9d5b0000), SPH_C32(0xb5710001), SPH_C32(0x37e0f080), + SPH_C32(0xcd810000), SPH_C32(0xaea76b45), SPH_C32(0xc5b6b272), + SPH_C32(0x7e198a4e), SPH_C32(0x243bd019), SPH_C32(0x3ae70000), + SPH_C32(0x5bbb0000), SPH_C32(0x30dad680), SPH_C32(0x2c010000), + SPH_C32(0x860261ce), SPH_C32(0x92a46c23), SPH_C32(0x323d4664), + SPH_C32(0x3db5f2dc) }, + { SPH_C32(0x514f0000), SPH_C32(0x10120001), SPH_C32(0x6d59f700), + SPH_C32(0xf6d10000), SPH_C32(0xe57778ba), SPH_C32(0x422d866a), + SPH_C32(0x175ac28f), SPH_C32(0xee6157e7), SPH_C32(0xbb790000), + SPH_C32(0xb7ec0000), SPH_C32(0x56e8d400), SPH_C32(0xb9f20000), + SPH_C32(0xdbab49cc), SPH_C32(0xda50509f), SPH_C32(0xd467e449), + SPH_C32(0xb3d24526) }, + { SPH_C32(0x64e60000), SPH_C32(0x4bda0001), SPH_C32(0xf8e8f980), + SPH_C32(0xc8d70000), SPH_C32(0x82306b3e), SPH_C32(0xf3ab07ea), + SPH_C32(0x68cf8801), SPH_C32(0xc933ec48), SPH_C32(0x75c20000), + SPH_C32(0xa5a70000), SPH_C32(0xb64dd080), SPH_C32(0xd43a0000), + SPH_C32(0x2af61fe0), SPH_C32(0xdd83a2e0), SPH_C32(0x1478b812), + SPH_C32(0x8d7e28a3) }, + { SPH_C32(0xa8f20000), SPH_C32(0xeeb90001), SPH_C32(0xa251fe00), + SPH_C32(0xf3870000), SPH_C32(0xc9e078c1), SPH_C32(0x743033f2), + SPH_C32(0x018cc0c0), SPH_C32(0x03696bb6), SPH_C32(0xf45c0000), + SPH_C32(0x49f00000), SPH_C32(0xd07fd200), SPH_C32(0x41c90000), + SPH_C32(0x775f37e2), SPH_C32(0x95779e5c), SPH_C32(0xf2221a3f), + SPH_C32(0x03199f59) }, + { SPH_C32(0xe5780000), SPH_C32(0xa78d0001), SPH_C32(0x9edafb00), + SPH_C32(0x5d240000), SPH_C32(0xdf99433c), SPH_C32(0xbb5f3b56), + SPH_C32(0x8e952a2c), SPH_C32(0x47545bb2), SPH_C32(0x38480000), + SPH_C32(0xec930000), SPH_C32(0x8ac6d580), SPH_C32(0x7a990000), + SPH_C32(0x3c8f241d), SPH_C32(0x12ecaa44), SPH_C32(0x9b6152fe), + SPH_C32(0xc94318a7) }, + { SPH_C32(0x296c0000), SPH_C32(0x02ee0001), SPH_C32(0xc463fc80), + SPH_C32(0x66740000), SPH_C32(0x944950c3), SPH_C32(0x3cc40f4e), + SPH_C32(0xe7d662ed), SPH_C32(0x8d0edc4c), SPH_C32(0xb9d60000), + SPH_C32(0x00c40000), SPH_C32(0xecf4d700), SPH_C32(0xef6a0000), + SPH_C32(0x61260c1f), SPH_C32(0x5a1896f8), SPH_C32(0x7d3bf0d3), + SPH_C32(0x4724af5d) }, + { SPH_C32(0x1e6a0000), SPH_C32(0xee0e0001), SPH_C32(0xebcef100), + SPH_C32(0x0eea0000), SPH_C32(0x49830694), SPH_C32(0x0d0a48a9), + SPH_C32(0x311f3cf9), SPH_C32(0x5eaa8d98), SPH_C32(0x0de10000), + SPH_C32(0xb75b0000), SPH_C32(0x1f77db00), SPH_C32(0x449f0000), + SPH_C32(0x5bc83799), SPH_C32(0xa36a2bc4), SPH_C32(0xe4f41870), + SPH_C32(0xee11a308) }, + { SPH_C32(0xd27e0000), SPH_C32(0x4b6d0001), SPH_C32(0xb177f680), + SPH_C32(0x35ba0000), SPH_C32(0x0253156b), SPH_C32(0x8a917cb1), + SPH_C32(0x585c7438), SPH_C32(0x94f00a66), SPH_C32(0x8c7f0000), + SPH_C32(0x5b0c0000), SPH_C32(0x7945d980), SPH_C32(0xd16c0000), + SPH_C32(0x06611f9b), SPH_C32(0xeb9e1778), SPH_C32(0x02aeba5d), + SPH_C32(0x607614f2) }, + { SPH_C32(0x9ff40000), SPH_C32(0x02590001), SPH_C32(0x8dfcf380), + SPH_C32(0x9b190000), SPH_C32(0x142a2e96), SPH_C32(0x45fe7415), + SPH_C32(0xd7459ed4), SPH_C32(0xd0cd3a62), SPH_C32(0x406b0000), + SPH_C32(0xfe6f0000), SPH_C32(0x23fcde00), SPH_C32(0xea3c0000), + SPH_C32(0x4db10c64), SPH_C32(0x6c052360), SPH_C32(0x6bedf29c), + SPH_C32(0xaa2c930c) }, + { SPH_C32(0x53e00000), SPH_C32(0xa73a0001), SPH_C32(0xd745f400), + SPH_C32(0xa0490000), SPH_C32(0x5ffa3d69), SPH_C32(0xc265400d), + SPH_C32(0xbe06d615), SPH_C32(0x1a97bd9c), SPH_C32(0xc1f50000), + SPH_C32(0x12380000), SPH_C32(0x45cedc80), SPH_C32(0x7fcf0000), + SPH_C32(0x10182466), SPH_C32(0x24f11fdc), SPH_C32(0x8db750b1), + SPH_C32(0x244b24f6) }, + { SPH_C32(0x66490000), SPH_C32(0xfcf20001), SPH_C32(0x42f4fa80), + SPH_C32(0x9e4f0000), SPH_C32(0x38bd2eed), SPH_C32(0x73e3c18d), + SPH_C32(0xc1939c9b), SPH_C32(0x3dc50633), SPH_C32(0x0f4e0000), + SPH_C32(0x00730000), SPH_C32(0xa56bd800), SPH_C32(0x12070000), + SPH_C32(0xe145724a), SPH_C32(0x2322eda3), SPH_C32(0x4da80cea), + SPH_C32(0x1ae74973) }, + { SPH_C32(0xaa5d0000), SPH_C32(0x59910001), SPH_C32(0x184dfd00), + SPH_C32(0xa51f0000), SPH_C32(0x736d3d12), SPH_C32(0xf478f595), + SPH_C32(0xa8d0d45a), SPH_C32(0xf79f81cd), SPH_C32(0x8ed00000), + SPH_C32(0xec240000), SPH_C32(0xc359da80), SPH_C32(0x87f40000), + SPH_C32(0xbcec5a48), SPH_C32(0x6bd6d11f), SPH_C32(0xabf2aec7), + SPH_C32(0x9480fe89) }, + { SPH_C32(0xe7d70000), SPH_C32(0x10a50001), SPH_C32(0x24c6f800), + SPH_C32(0x0bbc0000), SPH_C32(0x651406ef), SPH_C32(0x3b17fd31), + SPH_C32(0x27c93eb6), SPH_C32(0xb3a2b1c9), SPH_C32(0x42c40000), + SPH_C32(0x49470000), SPH_C32(0x99e0dd00), SPH_C32(0xbca40000), + SPH_C32(0xf73c49b7), SPH_C32(0xec4de507), SPH_C32(0xc2b1e606), + SPH_C32(0x5eda7977) }, + { SPH_C32(0x2bc30000), SPH_C32(0xb5c60001), SPH_C32(0x7e7fff80), + SPH_C32(0x30ec0000), SPH_C32(0x2ec41510), SPH_C32(0xbc8cc929), + SPH_C32(0x4e8a7677), SPH_C32(0x79f83637), SPH_C32(0xc35a0000), + SPH_C32(0xa5100000), SPH_C32(0xffd2df80), SPH_C32(0x29570000), + SPH_C32(0xaa9561b5), SPH_C32(0xa4b9d9bb), SPH_C32(0x24eb442b), + SPH_C32(0xd0bdce8d) }, + { SPH_C32(0xdb250000), SPH_C32(0x09290000), SPH_C32(0x49aac000), + SPH_C32(0x81e10000), SPH_C32(0xcafe6b59), SPH_C32(0x42793431), + SPH_C32(0x43566b76), SPH_C32(0xe86cba2e), SPH_C32(0x75e60000), + SPH_C32(0x95660001), SPH_C32(0x307b2000), SPH_C32(0xadf40000), + SPH_C32(0x8f321eea), SPH_C32(0x24298307), SPH_C32(0xe8c49cf9), + SPH_C32(0x4b7eec55) }, + { SPH_C32(0x17310000), SPH_C32(0xac4a0000), SPH_C32(0x1313c780), + SPH_C32(0xbab10000), SPH_C32(0x812e78a6), SPH_C32(0xc5e20029), + SPH_C32(0x2a1523b7), SPH_C32(0x22363dd0), SPH_C32(0xf4780000), + SPH_C32(0x79310001), SPH_C32(0x56492280), SPH_C32(0x38070000), + SPH_C32(0xd29b36e8), SPH_C32(0x6cddbfbb), SPH_C32(0x0e9e3ed4), + SPH_C32(0xc5195baf) }, + { SPH_C32(0x5abb0000), SPH_C32(0xe57e0000), SPH_C32(0x2f98c280), + SPH_C32(0x14120000), SPH_C32(0x9757435b), SPH_C32(0x0a8d088d), + SPH_C32(0xa50cc95b), SPH_C32(0x660b0dd4), SPH_C32(0x386c0000), + SPH_C32(0xdc520001), SPH_C32(0x0cf02500), SPH_C32(0x03570000), + SPH_C32(0x994b2517), SPH_C32(0xeb468ba3), SPH_C32(0x67dd7615), + SPH_C32(0x0f43dc51) }, + { SPH_C32(0x96af0000), SPH_C32(0x401d0000), SPH_C32(0x7521c500), + SPH_C32(0x2f420000), SPH_C32(0xdc8750a4), SPH_C32(0x8d163c95), + SPH_C32(0xcc4f819a), SPH_C32(0xac518a2a), SPH_C32(0xb9f20000), + SPH_C32(0x30050001), SPH_C32(0x6ac22780), SPH_C32(0x96a40000), + SPH_C32(0xc4e20d15), SPH_C32(0xa3b2b71f), SPH_C32(0x8187d438), + SPH_C32(0x81246bab) }, + { SPH_C32(0xa3060000), SPH_C32(0x1bd50000), SPH_C32(0xe090cb80), + SPH_C32(0x11440000), SPH_C32(0xbbc04320), SPH_C32(0x3c90bd15), + SPH_C32(0xb3dacb14), SPH_C32(0x8b033185), SPH_C32(0x77490000), + SPH_C32(0x224e0001), SPH_C32(0x8a672300), SPH_C32(0xfb6c0000), + SPH_C32(0x35bf5b39), SPH_C32(0xa4614560), SPH_C32(0x41988863), + SPH_C32(0xbf88062e) }, + { SPH_C32(0x6f120000), SPH_C32(0xbeb60000), SPH_C32(0xba29cc00), + SPH_C32(0x2a140000), SPH_C32(0xf01050df), SPH_C32(0xbb0b890d), + SPH_C32(0xda9983d5), SPH_C32(0x4159b67b), SPH_C32(0xf6d70000), + SPH_C32(0xce190001), SPH_C32(0xec552180), SPH_C32(0x6e9f0000), + SPH_C32(0x6816733b), SPH_C32(0xec9579dc), SPH_C32(0xa7c22a4e), + SPH_C32(0x31efb1d4) }, + { SPH_C32(0x22980000), SPH_C32(0xf7820000), SPH_C32(0x86a2c900), + SPH_C32(0x84b70000), SPH_C32(0xe6696b22), SPH_C32(0x746481a9), + SPH_C32(0x55806939), SPH_C32(0x0564867f), SPH_C32(0x3ac30000), + SPH_C32(0x6b7a0001), SPH_C32(0xb6ec2600), SPH_C32(0x55cf0000), + SPH_C32(0x23c660c4), SPH_C32(0x6b0e4dc4), SPH_C32(0xce81628f), + SPH_C32(0xfbb5362a) }, + { SPH_C32(0xee8c0000), SPH_C32(0x52e10000), SPH_C32(0xdc1bce80), + SPH_C32(0xbfe70000), SPH_C32(0xadb978dd), SPH_C32(0xf3ffb5b1), + SPH_C32(0x3cc321f8), SPH_C32(0xcf3e0181), SPH_C32(0xbb5d0000), + SPH_C32(0x872d0001), SPH_C32(0xd0de2480), SPH_C32(0xc03c0000), + SPH_C32(0x7e6f48c6), SPH_C32(0x23fa7178), SPH_C32(0x28dbc0a2), + SPH_C32(0x75d281d0) }, + { SPH_C32(0xd98a0000), SPH_C32(0xbe010000), SPH_C32(0xf3b6c300), + SPH_C32(0xd7790000), SPH_C32(0x70732e8a), SPH_C32(0xc231f256), + SPH_C32(0xea0a7fec), SPH_C32(0x1c9a5055), SPH_C32(0x0f6a0000), + SPH_C32(0x30b20001), SPH_C32(0x235d2880), SPH_C32(0x6bc90000), + SPH_C32(0x44817340), SPH_C32(0xda88cc44), SPH_C32(0xb1142801), + SPH_C32(0xdce78d85) }, + { SPH_C32(0x159e0000), SPH_C32(0x1b620000), SPH_C32(0xa90fc480), + SPH_C32(0xec290000), SPH_C32(0x3ba33d75), SPH_C32(0x45aac64e), + SPH_C32(0x8349372d), SPH_C32(0xd6c0d7ab), SPH_C32(0x8ef40000), + SPH_C32(0xdce50001), SPH_C32(0x456f2a00), SPH_C32(0xfe3a0000), + SPH_C32(0x19285b42), SPH_C32(0x927cf0f8), SPH_C32(0x574e8a2c), + SPH_C32(0x52803a7f) }, + { SPH_C32(0x58140000), SPH_C32(0x52560000), SPH_C32(0x9584c180), + SPH_C32(0x428a0000), SPH_C32(0x2dda0688), SPH_C32(0x8ac5ceea), + SPH_C32(0x0c50ddc1), SPH_C32(0x92fde7af), SPH_C32(0x42e00000), + SPH_C32(0x79860001), SPH_C32(0x1fd62d80), SPH_C32(0xc56a0000), + SPH_C32(0x52f848bd), SPH_C32(0x15e7c4e0), SPH_C32(0x3e0dc2ed), + SPH_C32(0x98dabd81) }, + { SPH_C32(0x94000000), SPH_C32(0xf7350000), SPH_C32(0xcf3dc600), + SPH_C32(0x79da0000), SPH_C32(0x660a1577), SPH_C32(0x0d5efaf2), + SPH_C32(0x65139500), SPH_C32(0x58a76051), SPH_C32(0xc37e0000), + SPH_C32(0x95d10001), SPH_C32(0x79e42f00), SPH_C32(0x50990000), + SPH_C32(0x0f5160bf), SPH_C32(0x5d13f85c), SPH_C32(0xd85760c0), + SPH_C32(0x16bd0a7b) }, + { SPH_C32(0xa1a90000), SPH_C32(0xacfd0000), SPH_C32(0x5a8cc880), + SPH_C32(0x47dc0000), SPH_C32(0x014d06f3), SPH_C32(0xbcd87b72), + SPH_C32(0x1a86df8e), SPH_C32(0x7ff5dbfe), SPH_C32(0x0dc50000), + SPH_C32(0x879a0001), SPH_C32(0x99412b80), SPH_C32(0x3d510000), + SPH_C32(0xfe0c3693), SPH_C32(0x5ac00a23), SPH_C32(0x18483c9b), + SPH_C32(0x281167fe) }, + { SPH_C32(0x6dbd0000), SPH_C32(0x099e0000), SPH_C32(0x0035cf00), + SPH_C32(0x7c8c0000), SPH_C32(0x4a9d150c), SPH_C32(0x3b434f6a), + SPH_C32(0x73c5974f), SPH_C32(0xb5af5c00), SPH_C32(0x8c5b0000), + SPH_C32(0x6bcd0001), SPH_C32(0xff732900), SPH_C32(0xa8a20000), + SPH_C32(0xa3a51e91), SPH_C32(0x1234369f), SPH_C32(0xfe129eb6), + SPH_C32(0xa676d004) }, + { SPH_C32(0x20370000), SPH_C32(0x40aa0000), SPH_C32(0x3cbeca00), + SPH_C32(0xd22f0000), SPH_C32(0x5ce42ef1), SPH_C32(0xf42c47ce), + SPH_C32(0xfcdc7da3), SPH_C32(0xf1926c04), SPH_C32(0x404f0000), + SPH_C32(0xceae0001), SPH_C32(0xa5ca2e80), SPH_C32(0x93f20000), + SPH_C32(0xe8750d6e), SPH_C32(0x95af0287), SPH_C32(0x9751d677), + SPH_C32(0x6c2c57fa) }, + { SPH_C32(0xec230000), SPH_C32(0xe5c90000), SPH_C32(0x6607cd80), + SPH_C32(0xe97f0000), SPH_C32(0x17343d0e), SPH_C32(0x73b773d6), + SPH_C32(0x959f3562), SPH_C32(0x3bc8ebfa), SPH_C32(0xc1d10000), + SPH_C32(0x22f90001), SPH_C32(0xc3f82c00), SPH_C32(0x06010000), + SPH_C32(0xb5dc256c), SPH_C32(0xdd5b3e3b), SPH_C32(0x710b745a), + SPH_C32(0xe24be000) }, + { SPH_C32(0x776d0000), SPH_C32(0x128f0000), SPH_C32(0x0c51d380), + SPH_C32(0x82a20000), SPH_C32(0x907b5a33), SPH_C32(0x5dcb6487), + SPH_C32(0xbd24ac88), SPH_C32(0x7988c2d8), SPH_C32(0x6ba80000), + SPH_C32(0x4ba90001), SPH_C32(0x5d832180), SPH_C32(0xdad00000), + SPH_C32(0x63751974), SPH_C32(0xd089ea49), SPH_C32(0x256784eb), + SPH_C32(0xd3d4a53b) }, + { SPH_C32(0xbb790000), SPH_C32(0xb7ec0000), SPH_C32(0x56e8d400), + SPH_C32(0xb9f20000), SPH_C32(0xdbab49cc), SPH_C32(0xda50509f), + SPH_C32(0xd467e449), SPH_C32(0xb3d24526), SPH_C32(0xea360000), + SPH_C32(0xa7fe0001), SPH_C32(0x3bb12300), SPH_C32(0x4f230000), + SPH_C32(0x3edc3176), SPH_C32(0x987dd6f5), SPH_C32(0xc33d26c6), + SPH_C32(0x5db312c1) }, + { SPH_C32(0xf6f30000), SPH_C32(0xfed80000), SPH_C32(0x6a63d100), + SPH_C32(0x17510000), SPH_C32(0xcdd27231), SPH_C32(0x153f583b), + SPH_C32(0x5b7e0ea5), SPH_C32(0xf7ef7522), SPH_C32(0x26220000), + SPH_C32(0x029d0001), SPH_C32(0x61082480), SPH_C32(0x74730000), + SPH_C32(0x750c2289), SPH_C32(0x1fe6e2ed), SPH_C32(0xaa7e6e07), + SPH_C32(0x97e9953f) }, + { SPH_C32(0x3ae70000), SPH_C32(0x5bbb0000), SPH_C32(0x30dad680), + SPH_C32(0x2c010000), SPH_C32(0x860261ce), SPH_C32(0x92a46c23), + SPH_C32(0x323d4664), SPH_C32(0x3db5f2dc), SPH_C32(0xa7bc0000), + SPH_C32(0xeeca0001), SPH_C32(0x073a2600), SPH_C32(0xe1800000), + SPH_C32(0x28a50a8b), SPH_C32(0x5712de51), SPH_C32(0x4c24cc2a), + SPH_C32(0x198e22c5) }, + { SPH_C32(0x0f4e0000), SPH_C32(0x00730000), SPH_C32(0xa56bd800), + SPH_C32(0x12070000), SPH_C32(0xe145724a), SPH_C32(0x2322eda3), + SPH_C32(0x4da80cea), SPH_C32(0x1ae74973), SPH_C32(0x69070000), + SPH_C32(0xfc810001), SPH_C32(0xe79f2280), SPH_C32(0x8c480000), + SPH_C32(0xd9f85ca7), SPH_C32(0x50c12c2e), SPH_C32(0x8c3b9071), + SPH_C32(0x27224f40) }, + { SPH_C32(0xc35a0000), SPH_C32(0xa5100000), SPH_C32(0xffd2df80), + SPH_C32(0x29570000), SPH_C32(0xaa9561b5), SPH_C32(0xa4b9d9bb), + SPH_C32(0x24eb442b), SPH_C32(0xd0bdce8d), SPH_C32(0xe8990000), + SPH_C32(0x10d60001), SPH_C32(0x81ad2000), SPH_C32(0x19bb0000), + SPH_C32(0x845174a5), SPH_C32(0x18351092), SPH_C32(0x6a61325c), + SPH_C32(0xa945f8ba) }, + { SPH_C32(0x8ed00000), SPH_C32(0xec240000), SPH_C32(0xc359da80), + SPH_C32(0x87f40000), SPH_C32(0xbcec5a48), SPH_C32(0x6bd6d11f), + SPH_C32(0xabf2aec7), SPH_C32(0x9480fe89), SPH_C32(0x248d0000), + SPH_C32(0xb5b50001), SPH_C32(0xdb142780), SPH_C32(0x22eb0000), + SPH_C32(0xcf81675a), SPH_C32(0x9fae248a), SPH_C32(0x03227a9d), + SPH_C32(0x631f7f44) }, + { SPH_C32(0x42c40000), SPH_C32(0x49470000), SPH_C32(0x99e0dd00), + SPH_C32(0xbca40000), SPH_C32(0xf73c49b7), SPH_C32(0xec4de507), + SPH_C32(0xc2b1e606), SPH_C32(0x5eda7977), SPH_C32(0xa5130000), + SPH_C32(0x59e20001), SPH_C32(0xbd262500), SPH_C32(0xb7180000), + SPH_C32(0x92284f58), SPH_C32(0xd75a1836), SPH_C32(0xe578d8b0), + SPH_C32(0xed78c8be) }, + { SPH_C32(0x75c20000), SPH_C32(0xa5a70000), SPH_C32(0xb64dd080), + SPH_C32(0xd43a0000), SPH_C32(0x2af61fe0), SPH_C32(0xdd83a2e0), + SPH_C32(0x1478b812), SPH_C32(0x8d7e28a3), SPH_C32(0x11240000), + SPH_C32(0xee7d0001), SPH_C32(0x4ea52900), SPH_C32(0x1ced0000), + SPH_C32(0xa8c674de), SPH_C32(0x2e28a50a), SPH_C32(0x7cb73013), + SPH_C32(0x444dc4eb) }, + { SPH_C32(0xb9d60000), SPH_C32(0x00c40000), SPH_C32(0xecf4d700), + SPH_C32(0xef6a0000), SPH_C32(0x61260c1f), SPH_C32(0x5a1896f8), + SPH_C32(0x7d3bf0d3), SPH_C32(0x4724af5d), SPH_C32(0x90ba0000), + SPH_C32(0x022a0001), SPH_C32(0x28972b80), SPH_C32(0x891e0000), + SPH_C32(0xf56f5cdc), SPH_C32(0x66dc99b6), SPH_C32(0x9aed923e), + SPH_C32(0xca2a7311) }, + { SPH_C32(0xf45c0000), SPH_C32(0x49f00000), SPH_C32(0xd07fd200), + SPH_C32(0x41c90000), SPH_C32(0x775f37e2), SPH_C32(0x95779e5c), + SPH_C32(0xf2221a3f), SPH_C32(0x03199f59), SPH_C32(0x5cae0000), + SPH_C32(0xa7490001), SPH_C32(0x722e2c00), SPH_C32(0xb24e0000), + SPH_C32(0xbebf4f23), SPH_C32(0xe147adae), SPH_C32(0xf3aedaff), + SPH_C32(0x0070f4ef) }, + { SPH_C32(0x38480000), SPH_C32(0xec930000), SPH_C32(0x8ac6d580), + SPH_C32(0x7a990000), SPH_C32(0x3c8f241d), SPH_C32(0x12ecaa44), + SPH_C32(0x9b6152fe), SPH_C32(0xc94318a7), SPH_C32(0xdd300000), + SPH_C32(0x4b1e0001), SPH_C32(0x141c2e80), SPH_C32(0x27bd0000), + SPH_C32(0xe3166721), SPH_C32(0xa9b39112), SPH_C32(0x15f478d2), + SPH_C32(0x8e174315) }, + { SPH_C32(0x0de10000), SPH_C32(0xb75b0000), SPH_C32(0x1f77db00), + SPH_C32(0x449f0000), SPH_C32(0x5bc83799), SPH_C32(0xa36a2bc4), + SPH_C32(0xe4f41870), SPH_C32(0xee11a308), SPH_C32(0x138b0000), + SPH_C32(0x59550001), SPH_C32(0xf4b92a00), SPH_C32(0x4a750000), + SPH_C32(0x124b310d), SPH_C32(0xae60636d), SPH_C32(0xd5eb2489), + SPH_C32(0xb0bb2e90) }, + { SPH_C32(0xc1f50000), SPH_C32(0x12380000), SPH_C32(0x45cedc80), + SPH_C32(0x7fcf0000), SPH_C32(0x10182466), SPH_C32(0x24f11fdc), + SPH_C32(0x8db750b1), SPH_C32(0x244b24f6), SPH_C32(0x92150000), + SPH_C32(0xb5020001), SPH_C32(0x928b2880), SPH_C32(0xdf860000), + SPH_C32(0x4fe2190f), SPH_C32(0xe6945fd1), SPH_C32(0x33b186a4), + SPH_C32(0x3edc996a) }, + { SPH_C32(0x8c7f0000), SPH_C32(0x5b0c0000), SPH_C32(0x7945d980), + SPH_C32(0xd16c0000), SPH_C32(0x06611f9b), SPH_C32(0xeb9e1778), + SPH_C32(0x02aeba5d), SPH_C32(0x607614f2), SPH_C32(0x5e010000), + SPH_C32(0x10610001), SPH_C32(0xc8322f00), SPH_C32(0xe4d60000), + SPH_C32(0x04320af0), SPH_C32(0x610f6bc9), SPH_C32(0x5af2ce65), + SPH_C32(0xf4861e94) }, + { SPH_C32(0x406b0000), SPH_C32(0xfe6f0000), SPH_C32(0x23fcde00), + SPH_C32(0xea3c0000), SPH_C32(0x4db10c64), SPH_C32(0x6c052360), + SPH_C32(0x6bedf29c), SPH_C32(0xaa2c930c), SPH_C32(0xdf9f0000), + SPH_C32(0xfc360001), SPH_C32(0xae002d80), SPH_C32(0x71250000), + SPH_C32(0x599b22f2), SPH_C32(0x29fb5775), SPH_C32(0xbca86c48), + SPH_C32(0x7ae1a96e) }, + { SPH_C32(0xc56b0000), SPH_C32(0xd7e60000), SPH_C32(0x2452c180), + SPH_C32(0xf6c50000), SPH_C32(0x26b96cc7), SPH_C32(0xb6d95d7f), + SPH_C32(0x8ef57364), SPH_C32(0x70c6f340), SPH_C32(0xc7e00000), + SPH_C32(0x500f0001), SPH_C32(0x18783200), SPH_C32(0xd9930000), + SPH_C32(0x39f0281e), SPH_C32(0xcf3bbaff), SPH_C32(0xdb154315), + SPH_C32(0x4230ddcd) }, + { SPH_C32(0x097f0000), SPH_C32(0x72850000), SPH_C32(0x7eebc600), + SPH_C32(0xcd950000), SPH_C32(0x6d697f38), SPH_C32(0x31426967), + SPH_C32(0xe7b63ba5), SPH_C32(0xba9c74be), SPH_C32(0x467e0000), + SPH_C32(0xbc580001), SPH_C32(0x7e4a3080), SPH_C32(0x4c600000), + SPH_C32(0x6459001c), SPH_C32(0x87cf8643), SPH_C32(0x3d4fe138), + SPH_C32(0xcc576a37) }, + { SPH_C32(0x44f50000), SPH_C32(0x3bb10000), SPH_C32(0x4260c300), + SPH_C32(0x63360000), SPH_C32(0x7b1044c5), SPH_C32(0xfe2d61c3), + SPH_C32(0x68afd149), SPH_C32(0xfea144ba), SPH_C32(0x8a6a0000), + SPH_C32(0x193b0001), SPH_C32(0x24f33700), SPH_C32(0x77300000), + SPH_C32(0x2f8913e3), SPH_C32(0x0054b25b), SPH_C32(0x540ca9f9), + SPH_C32(0x060dedc9) }, + { SPH_C32(0x88e10000), SPH_C32(0x9ed20000), SPH_C32(0x18d9c480), + SPH_C32(0x58660000), SPH_C32(0x30c0573a), SPH_C32(0x79b655db), + SPH_C32(0x01ec9988), SPH_C32(0x34fbc344), SPH_C32(0x0bf40000), + SPH_C32(0xf56c0001), SPH_C32(0x42c13580), SPH_C32(0xe2c30000), + SPH_C32(0x72203be1), SPH_C32(0x48a08ee7), SPH_C32(0xb2560bd4), + SPH_C32(0x886a5a33) }, + { SPH_C32(0xbd480000), SPH_C32(0xc51a0000), SPH_C32(0x8d68ca00), + SPH_C32(0x66600000), SPH_C32(0x578744be), SPH_C32(0xc830d45b), + SPH_C32(0x7e79d306), SPH_C32(0x13a978eb), SPH_C32(0xc54f0000), + SPH_C32(0xe7270001), SPH_C32(0xa2643100), SPH_C32(0x8f0b0000), + SPH_C32(0x837d6dcd), SPH_C32(0x4f737c98), SPH_C32(0x7249578f), + SPH_C32(0xb6c637b6) }, + { SPH_C32(0x715c0000), SPH_C32(0x60790000), SPH_C32(0xd7d1cd80), + SPH_C32(0x5d300000), SPH_C32(0x1c575741), SPH_C32(0x4fabe043), + SPH_C32(0x173a9bc7), SPH_C32(0xd9f3ff15), SPH_C32(0x44d10000), + SPH_C32(0x0b700001), SPH_C32(0xc4563380), SPH_C32(0x1af80000), + SPH_C32(0xded445cf), SPH_C32(0x07874024), SPH_C32(0x9413f5a2), + SPH_C32(0x38a1804c) }, + { SPH_C32(0x3cd60000), SPH_C32(0x294d0000), SPH_C32(0xeb5ac880), + SPH_C32(0xf3930000), SPH_C32(0x0a2e6cbc), SPH_C32(0x80c4e8e7), + SPH_C32(0x9823712b), SPH_C32(0x9dcecf11), SPH_C32(0x88c50000), + SPH_C32(0xae130001), SPH_C32(0x9eef3400), SPH_C32(0x21a80000), + SPH_C32(0x95045630), SPH_C32(0x801c743c), SPH_C32(0xfd50bd63), + SPH_C32(0xf2fb07b2) }, + { SPH_C32(0xf0c20000), SPH_C32(0x8c2e0000), SPH_C32(0xb1e3cf00), + SPH_C32(0xc8c30000), SPH_C32(0x41fe7f43), SPH_C32(0x075fdcff), + SPH_C32(0xf16039ea), SPH_C32(0x579448ef), SPH_C32(0x095b0000), + SPH_C32(0x42440001), SPH_C32(0xf8dd3680), SPH_C32(0xb45b0000), + SPH_C32(0xc8ad7e32), SPH_C32(0xc8e84880), SPH_C32(0x1b0a1f4e), + SPH_C32(0x7c9cb048) }, + { SPH_C32(0xc7c40000), SPH_C32(0x60ce0000), SPH_C32(0x9e4ec280), + SPH_C32(0xa05d0000), SPH_C32(0x9c342914), SPH_C32(0x36919b18), + SPH_C32(0x27a967fe), SPH_C32(0x8430193b), SPH_C32(0xbd6c0000), + SPH_C32(0xf5db0001), SPH_C32(0x0b5e3a80), SPH_C32(0x1fae0000), + SPH_C32(0xf24345b4), SPH_C32(0x319af5bc), SPH_C32(0x82c5f7ed), + SPH_C32(0xd5a9bc1d) }, + { SPH_C32(0x0bd00000), SPH_C32(0xc5ad0000), SPH_C32(0xc4f7c500), + SPH_C32(0x9b0d0000), SPH_C32(0xd7e43aeb), SPH_C32(0xb10aaf00), + SPH_C32(0x4eea2f3f), SPH_C32(0x4e6a9ec5), SPH_C32(0x3cf20000), + SPH_C32(0x198c0001), SPH_C32(0x6d6c3800), SPH_C32(0x8a5d0000), + SPH_C32(0xafea6db6), SPH_C32(0x796ec900), SPH_C32(0x649f55c0), + SPH_C32(0x5bce0be7) }, + { SPH_C32(0x465a0000), SPH_C32(0x8c990000), SPH_C32(0xf87cc000), + SPH_C32(0x35ae0000), SPH_C32(0xc19d0116), SPH_C32(0x7e65a7a4), + SPH_C32(0xc1f3c5d3), SPH_C32(0x0a57aec1), SPH_C32(0xf0e60000), + SPH_C32(0xbcef0001), SPH_C32(0x37d53f80), SPH_C32(0xb10d0000), + SPH_C32(0xe43a7e49), SPH_C32(0xfef5fd18), SPH_C32(0x0ddc1d01), + SPH_C32(0x91948c19) }, + { SPH_C32(0x8a4e0000), SPH_C32(0x29fa0000), SPH_C32(0xa2c5c780), + SPH_C32(0x0efe0000), SPH_C32(0x8a4d12e9), SPH_C32(0xf9fe93bc), + SPH_C32(0xa8b08d12), SPH_C32(0xc00d293f), SPH_C32(0x71780000), + SPH_C32(0x50b80001), SPH_C32(0x51e73d00), SPH_C32(0x24fe0000), + SPH_C32(0xb993564b), SPH_C32(0xb601c1a4), SPH_C32(0xeb86bf2c), + SPH_C32(0x1ff33be3) }, + { SPH_C32(0xbfe70000), SPH_C32(0x72320000), SPH_C32(0x3774c900), + SPH_C32(0x30f80000), SPH_C32(0xed0a016d), SPH_C32(0x4878123c), + SPH_C32(0xd725c79c), SPH_C32(0xe75f9290), SPH_C32(0xbfc30000), + SPH_C32(0x42f30001), SPH_C32(0xb1423980), SPH_C32(0x49360000), + SPH_C32(0x48ce0067), SPH_C32(0xb1d233db), SPH_C32(0x2b99e377), + SPH_C32(0x215f5666) }, + { SPH_C32(0x73f30000), SPH_C32(0xd7510000), SPH_C32(0x6dcdce80), + SPH_C32(0x0ba80000), SPH_C32(0xa6da1292), SPH_C32(0xcfe32624), + SPH_C32(0xbe668f5d), SPH_C32(0x2d05156e), SPH_C32(0x3e5d0000), + SPH_C32(0xaea40001), SPH_C32(0xd7703b00), SPH_C32(0xdcc50000), + SPH_C32(0x15672865), SPH_C32(0xf9260f67), SPH_C32(0xcdc3415a), + SPH_C32(0xaf38e19c) }, + { SPH_C32(0x3e790000), SPH_C32(0x9e650000), SPH_C32(0x5146cb80), + SPH_C32(0xa50b0000), SPH_C32(0xb0a3296f), SPH_C32(0x008c2e80), + SPH_C32(0x317f65b1), SPH_C32(0x6938256a), SPH_C32(0xf2490000), + SPH_C32(0x0bc70001), SPH_C32(0x8dc93c80), SPH_C32(0xe7950000), + SPH_C32(0x5eb73b9a), SPH_C32(0x7ebd3b7f), SPH_C32(0xa480099b), + SPH_C32(0x65626662) }, + { SPH_C32(0xf26d0000), SPH_C32(0x3b060000), SPH_C32(0x0bffcc00), + SPH_C32(0x9e5b0000), SPH_C32(0xfb733a90), SPH_C32(0x87171a98), + SPH_C32(0x583c2d70), SPH_C32(0xa362a294), SPH_C32(0x73d70000), + SPH_C32(0xe7900001), SPH_C32(0xebfb3e00), SPH_C32(0x72660000), + SPH_C32(0x031e1398), SPH_C32(0x364907c3), SPH_C32(0x42daabb6), + SPH_C32(0xeb05d198) }, + { SPH_C32(0x69230000), SPH_C32(0xcc400000), SPH_C32(0x61a9d200), + SPH_C32(0xf5860000), SPH_C32(0x7c3c5dad), SPH_C32(0xa96b0dc9), + SPH_C32(0x7087b49a), SPH_C32(0xe1228bb6), SPH_C32(0xd9ae0000), + SPH_C32(0x8ec00001), SPH_C32(0x75803380), SPH_C32(0xaeb70000), + SPH_C32(0xd5b72f80), SPH_C32(0x3b9bd3b1), SPH_C32(0x16b65b07), + SPH_C32(0xda9a94a3) }, + { SPH_C32(0xa5370000), SPH_C32(0x69230000), SPH_C32(0x3b10d580), + SPH_C32(0xced60000), SPH_C32(0x37ec4e52), SPH_C32(0x2ef039d1), + SPH_C32(0x19c4fc5b), SPH_C32(0x2b780c48), SPH_C32(0x58300000), + SPH_C32(0x62970001), SPH_C32(0x13b23100), SPH_C32(0x3b440000), + SPH_C32(0x881e0782), SPH_C32(0x736fef0d), SPH_C32(0xf0ecf92a), + SPH_C32(0x54fd2359) }, + { SPH_C32(0xe8bd0000), SPH_C32(0x20170000), SPH_C32(0x079bd080), + SPH_C32(0x60750000), SPH_C32(0x219575af), SPH_C32(0xe19f3175), + SPH_C32(0x96dd16b7), SPH_C32(0x6f453c4c), SPH_C32(0x94240000), + SPH_C32(0xc7f40001), SPH_C32(0x490b3680), SPH_C32(0x00140000), + SPH_C32(0xc3ce147d), SPH_C32(0xf4f4db15), SPH_C32(0x99afb1eb), + SPH_C32(0x9ea7a4a7) }, + { SPH_C32(0x24a90000), SPH_C32(0x85740000), SPH_C32(0x5d22d700), + SPH_C32(0x5b250000), SPH_C32(0x6a456650), SPH_C32(0x6604056d), + SPH_C32(0xff9e5e76), SPH_C32(0xa51fbbb2), SPH_C32(0x15ba0000), + SPH_C32(0x2ba30001), SPH_C32(0x2f393400), SPH_C32(0x95e70000), + SPH_C32(0x9e673c7f), SPH_C32(0xbc00e7a9), SPH_C32(0x7ff513c6), + SPH_C32(0x10c0135d) }, + { SPH_C32(0x11000000), SPH_C32(0xdebc0000), SPH_C32(0xc893d980), + SPH_C32(0x65230000), SPH_C32(0x0d0275d4), SPH_C32(0xd78284ed), + SPH_C32(0x800b14f8), SPH_C32(0x824d001d), SPH_C32(0xdb010000), + SPH_C32(0x39e80001), SPH_C32(0xcf9c3080), SPH_C32(0xf82f0000), + SPH_C32(0x6f3a6a53), SPH_C32(0xbbd315d6), SPH_C32(0xbfea4f9d), + SPH_C32(0x2e6c7ed8) }, + { SPH_C32(0xdd140000), SPH_C32(0x7bdf0000), SPH_C32(0x922ade00), + SPH_C32(0x5e730000), SPH_C32(0x46d2662b), SPH_C32(0x5019b0f5), + SPH_C32(0xe9485c39), SPH_C32(0x481787e3), SPH_C32(0x5a9f0000), + SPH_C32(0xd5bf0001), SPH_C32(0xa9ae3200), SPH_C32(0x6ddc0000), + SPH_C32(0x32934251), SPH_C32(0xf327296a), SPH_C32(0x59b0edb0), + SPH_C32(0xa00bc922) }, + { SPH_C32(0x909e0000), SPH_C32(0x32eb0000), SPH_C32(0xaea1db00), + SPH_C32(0xf0d00000), SPH_C32(0x50ab5dd6), SPH_C32(0x9f76b851), + SPH_C32(0x6651b6d5), SPH_C32(0x0c2ab7e7), SPH_C32(0x968b0000), + SPH_C32(0x70dc0001), SPH_C32(0xf3173580), SPH_C32(0x568c0000), + SPH_C32(0x794351ae), SPH_C32(0x74bc1d72), SPH_C32(0x30f3a571), + SPH_C32(0x6a514edc) }, + { SPH_C32(0x5c8a0000), SPH_C32(0x97880000), SPH_C32(0xf418dc80), + SPH_C32(0xcb800000), SPH_C32(0x1b7b4e29), SPH_C32(0x18ed8c49), + SPH_C32(0x0f12fe14), SPH_C32(0xc6703019), SPH_C32(0x17150000), + SPH_C32(0x9c8b0001), SPH_C32(0x95253700), SPH_C32(0xc37f0000), + SPH_C32(0x24ea79ac), SPH_C32(0x3c4821ce), SPH_C32(0xd6a9075c), + SPH_C32(0xe436f926) }, + { SPH_C32(0x6b8c0000), SPH_C32(0x7b680000), SPH_C32(0xdbb5d100), + SPH_C32(0xa31e0000), SPH_C32(0xc6b1187e), SPH_C32(0x2923cbae), + SPH_C32(0xd9dba000), SPH_C32(0x15d461cd), SPH_C32(0xa3220000), + SPH_C32(0x2b140001), SPH_C32(0x66a63b00), SPH_C32(0x688a0000), + SPH_C32(0x1e04422a), SPH_C32(0xc53a9cf2), SPH_C32(0x4f66efff), + SPH_C32(0x4d03f573) }, + { SPH_C32(0xa7980000), SPH_C32(0xde0b0000), SPH_C32(0x810cd680), + SPH_C32(0x984e0000), SPH_C32(0x8d610b81), SPH_C32(0xaeb8ffb6), + SPH_C32(0xb098e8c1), SPH_C32(0xdf8ee633), SPH_C32(0x22bc0000), + SPH_C32(0xc7430001), SPH_C32(0x00943980), SPH_C32(0xfd790000), + SPH_C32(0x43ad6a28), SPH_C32(0x8dcea04e), SPH_C32(0xa93c4dd2), + SPH_C32(0xc3644289) }, + { SPH_C32(0xea120000), SPH_C32(0x973f0000), SPH_C32(0xbd87d380), + SPH_C32(0x36ed0000), SPH_C32(0x9b18307c), SPH_C32(0x61d7f712), + SPH_C32(0x3f81022d), SPH_C32(0x9bb3d637), SPH_C32(0xeea80000), + SPH_C32(0x62200001), SPH_C32(0x5a2d3e00), SPH_C32(0xc6290000), + SPH_C32(0x087d79d7), SPH_C32(0x0a559456), SPH_C32(0xc07f0513), + SPH_C32(0x093ec577) }, + { SPH_C32(0x26060000), SPH_C32(0x325c0000), SPH_C32(0xe73ed400), + SPH_C32(0x0dbd0000), SPH_C32(0xd0c82383), SPH_C32(0xe64cc30a), + SPH_C32(0x56c24aec), SPH_C32(0x51e951c9), SPH_C32(0x6f360000), + SPH_C32(0x8e770001), SPH_C32(0x3c1f3c80), SPH_C32(0x53da0000), + SPH_C32(0x55d451d5), SPH_C32(0x42a1a8ea), SPH_C32(0x2625a73e), + SPH_C32(0x8759728d) }, + { SPH_C32(0x13af0000), SPH_C32(0x69940000), SPH_C32(0x728fda80), + SPH_C32(0x33bb0000), SPH_C32(0xb78f3007), SPH_C32(0x57ca428a), + SPH_C32(0x29570062), SPH_C32(0x76bbea66), SPH_C32(0xa18d0000), + SPH_C32(0x9c3c0001), SPH_C32(0xdcba3800), SPH_C32(0x3e120000), + SPH_C32(0xa48907f9), SPH_C32(0x45725a95), SPH_C32(0xe63afb65), + SPH_C32(0xb9f51f08) }, + { SPH_C32(0xdfbb0000), SPH_C32(0xccf70000), SPH_C32(0x2836dd00), + SPH_C32(0x08eb0000), SPH_C32(0xfc5f23f8), SPH_C32(0xd0517692), + SPH_C32(0x401448a3), SPH_C32(0xbce16d98), SPH_C32(0x20130000), + SPH_C32(0x706b0001), SPH_C32(0xba883a80), SPH_C32(0xabe10000), + SPH_C32(0xf9202ffb), SPH_C32(0x0d866629), SPH_C32(0x00605948), + SPH_C32(0x3792a8f2) }, + { SPH_C32(0x92310000), SPH_C32(0x85c30000), SPH_C32(0x14bdd800), + SPH_C32(0xa6480000), SPH_C32(0xea261805), SPH_C32(0x1f3e7e36), + SPH_C32(0xcf0da24f), SPH_C32(0xf8dc5d9c), SPH_C32(0xec070000), + SPH_C32(0xd5080001), SPH_C32(0xe0313d00), SPH_C32(0x90b10000), + SPH_C32(0xb2f03c04), SPH_C32(0x8a1d5231), SPH_C32(0x69231189), + SPH_C32(0xfdc82f0c) }, + { SPH_C32(0x5e250000), SPH_C32(0x20a00000), SPH_C32(0x4e04df80), + SPH_C32(0x9d180000), SPH_C32(0xa1f60bfa), SPH_C32(0x98a54a2e), + SPH_C32(0xa64eea8e), SPH_C32(0x3286da62), SPH_C32(0x6d990000), + SPH_C32(0x395f0001), SPH_C32(0x86033f80), SPH_C32(0x05420000), + SPH_C32(0xef591406), SPH_C32(0xc2e96e8d), SPH_C32(0x8f79b3a4), + SPH_C32(0x73af98f6) }, + { SPH_C32(0x75e60000), SPH_C32(0x95660001), SPH_C32(0x307b2000), + SPH_C32(0xadf40000), SPH_C32(0x8f321eea), SPH_C32(0x24298307), + SPH_C32(0xe8c49cf9), SPH_C32(0x4b7eec55), SPH_C32(0xaec30000), + SPH_C32(0x9c4f0001), SPH_C32(0x79d1e000), SPH_C32(0x2c150000), + SPH_C32(0x45cc75b3), SPH_C32(0x6650b736), SPH_C32(0xab92f78f), + SPH_C32(0xa312567b) }, + { SPH_C32(0xb9f20000), SPH_C32(0x30050001), SPH_C32(0x6ac22780), + SPH_C32(0x96a40000), SPH_C32(0xc4e20d15), SPH_C32(0xa3b2b71f), + SPH_C32(0x8187d438), SPH_C32(0x81246bab), SPH_C32(0x2f5d0000), + SPH_C32(0x70180001), SPH_C32(0x1fe3e280), SPH_C32(0xb9e60000), + SPH_C32(0x18655db1), SPH_C32(0x2ea48b8a), SPH_C32(0x4dc855a2), + SPH_C32(0x2d75e181) }, + { SPH_C32(0xf4780000), SPH_C32(0x79310001), SPH_C32(0x56492280), + SPH_C32(0x38070000), SPH_C32(0xd29b36e8), SPH_C32(0x6cddbfbb), + SPH_C32(0x0e9e3ed4), SPH_C32(0xc5195baf), SPH_C32(0xe3490000), + SPH_C32(0xd57b0001), SPH_C32(0x455ae500), SPH_C32(0x82b60000), + SPH_C32(0x53b54e4e), SPH_C32(0xa93fbf92), SPH_C32(0x248b1d63), + SPH_C32(0xe72f667f) }, + { SPH_C32(0x386c0000), SPH_C32(0xdc520001), SPH_C32(0x0cf02500), + SPH_C32(0x03570000), SPH_C32(0x994b2517), SPH_C32(0xeb468ba3), + SPH_C32(0x67dd7615), SPH_C32(0x0f43dc51), SPH_C32(0x62d70000), + SPH_C32(0x392c0001), SPH_C32(0x2368e780), SPH_C32(0x17450000), + SPH_C32(0x0e1c664c), SPH_C32(0xe1cb832e), SPH_C32(0xc2d1bf4e), + SPH_C32(0x6948d185) }, + { SPH_C32(0x0dc50000), SPH_C32(0x879a0001), SPH_C32(0x99412b80), + SPH_C32(0x3d510000), SPH_C32(0xfe0c3693), SPH_C32(0x5ac00a23), + SPH_C32(0x18483c9b), SPH_C32(0x281167fe), SPH_C32(0xac6c0000), + SPH_C32(0x2b670001), SPH_C32(0xc3cde300), SPH_C32(0x7a8d0000), + SPH_C32(0xff413060), SPH_C32(0xe6187151), SPH_C32(0x02cee315), + SPH_C32(0x57e4bc00) }, + { SPH_C32(0xc1d10000), SPH_C32(0x22f90001), SPH_C32(0xc3f82c00), + SPH_C32(0x06010000), SPH_C32(0xb5dc256c), SPH_C32(0xdd5b3e3b), + SPH_C32(0x710b745a), SPH_C32(0xe24be000), SPH_C32(0x2df20000), + SPH_C32(0xc7300001), SPH_C32(0xa5ffe180), SPH_C32(0xef7e0000), + SPH_C32(0xa2e81862), SPH_C32(0xaeec4ded), SPH_C32(0xe4944138), + SPH_C32(0xd9830bfa) }, + { SPH_C32(0x8c5b0000), SPH_C32(0x6bcd0001), SPH_C32(0xff732900), + SPH_C32(0xa8a20000), SPH_C32(0xa3a51e91), SPH_C32(0x1234369f), + SPH_C32(0xfe129eb6), SPH_C32(0xa676d004), SPH_C32(0xe1e60000), + SPH_C32(0x62530001), SPH_C32(0xff46e600), SPH_C32(0xd42e0000), + SPH_C32(0xe9380b9d), SPH_C32(0x297779f5), SPH_C32(0x8dd709f9), + SPH_C32(0x13d98c04) }, + { SPH_C32(0x404f0000), SPH_C32(0xceae0001), SPH_C32(0xa5ca2e80), + SPH_C32(0x93f20000), SPH_C32(0xe8750d6e), SPH_C32(0x95af0287), + SPH_C32(0x9751d677), SPH_C32(0x6c2c57fa), SPH_C32(0x60780000), + SPH_C32(0x8e040001), SPH_C32(0x9974e480), SPH_C32(0x41dd0000), + SPH_C32(0xb491239f), SPH_C32(0x61834549), SPH_C32(0x6b8dabd4), + SPH_C32(0x9dbe3bfe) }, + { SPH_C32(0x77490000), SPH_C32(0x224e0001), SPH_C32(0x8a672300), + SPH_C32(0xfb6c0000), SPH_C32(0x35bf5b39), SPH_C32(0xa4614560), + SPH_C32(0x41988863), SPH_C32(0xbf88062e), SPH_C32(0xd44f0000), + SPH_C32(0x399b0001), SPH_C32(0x6af7e880), SPH_C32(0xea280000), + SPH_C32(0x8e7f1819), SPH_C32(0x98f1f875), SPH_C32(0xf2424377), + SPH_C32(0x348b37ab) }, + { SPH_C32(0xbb5d0000), SPH_C32(0x872d0001), SPH_C32(0xd0de2480), + SPH_C32(0xc03c0000), SPH_C32(0x7e6f48c6), SPH_C32(0x23fa7178), + SPH_C32(0x28dbc0a2), SPH_C32(0x75d281d0), SPH_C32(0x55d10000), + SPH_C32(0xd5cc0001), SPH_C32(0x0cc5ea00), SPH_C32(0x7fdb0000), + SPH_C32(0xd3d6301b), SPH_C32(0xd005c4c9), SPH_C32(0x1418e15a), + SPH_C32(0xbaec8051) }, + { SPH_C32(0xf6d70000), SPH_C32(0xce190001), SPH_C32(0xec552180), + SPH_C32(0x6e9f0000), SPH_C32(0x6816733b), SPH_C32(0xec9579dc), + SPH_C32(0xa7c22a4e), SPH_C32(0x31efb1d4), SPH_C32(0x99c50000), + SPH_C32(0x70af0001), SPH_C32(0x567ced80), SPH_C32(0x448b0000), + SPH_C32(0x980623e4), SPH_C32(0x579ef0d1), SPH_C32(0x7d5ba99b), + SPH_C32(0x70b607af) }, + { SPH_C32(0x3ac30000), SPH_C32(0x6b7a0001), SPH_C32(0xb6ec2600), + SPH_C32(0x55cf0000), SPH_C32(0x23c660c4), SPH_C32(0x6b0e4dc4), + SPH_C32(0xce81628f), SPH_C32(0xfbb5362a), SPH_C32(0x185b0000), + SPH_C32(0x9cf80001), SPH_C32(0x304eef00), SPH_C32(0xd1780000), + SPH_C32(0xc5af0be6), SPH_C32(0x1f6acc6d), SPH_C32(0x9b010bb6), + SPH_C32(0xfed1b055) }, + { SPH_C32(0x0f6a0000), SPH_C32(0x30b20001), SPH_C32(0x235d2880), + SPH_C32(0x6bc90000), SPH_C32(0x44817340), SPH_C32(0xda88cc44), + SPH_C32(0xb1142801), SPH_C32(0xdce78d85), SPH_C32(0xd6e00000), + SPH_C32(0x8eb30001), SPH_C32(0xd0ebeb80), SPH_C32(0xbcb00000), + SPH_C32(0x34f25dca), SPH_C32(0x18b93e12), SPH_C32(0x5b1e57ed), + SPH_C32(0xc07dddd0) }, + { SPH_C32(0xc37e0000), SPH_C32(0x95d10001), SPH_C32(0x79e42f00), + SPH_C32(0x50990000), SPH_C32(0x0f5160bf), SPH_C32(0x5d13f85c), + SPH_C32(0xd85760c0), SPH_C32(0x16bd0a7b), SPH_C32(0x577e0000), + SPH_C32(0x62e40001), SPH_C32(0xb6d9e900), SPH_C32(0x29430000), + SPH_C32(0x695b75c8), SPH_C32(0x504d02ae), SPH_C32(0xbd44f5c0), + SPH_C32(0x4e1a6a2a) }, + { SPH_C32(0x8ef40000), SPH_C32(0xdce50001), SPH_C32(0x456f2a00), + SPH_C32(0xfe3a0000), SPH_C32(0x19285b42), SPH_C32(0x927cf0f8), + SPH_C32(0x574e8a2c), SPH_C32(0x52803a7f), SPH_C32(0x9b6a0000), + SPH_C32(0xc7870001), SPH_C32(0xec60ee80), SPH_C32(0x12130000), + SPH_C32(0x228b6637), SPH_C32(0xd7d636b6), SPH_C32(0xd407bd01), + SPH_C32(0x8440edd4) }, + { SPH_C32(0x42e00000), SPH_C32(0x79860001), SPH_C32(0x1fd62d80), + SPH_C32(0xc56a0000), SPH_C32(0x52f848bd), SPH_C32(0x15e7c4e0), + SPH_C32(0x3e0dc2ed), SPH_C32(0x98dabd81), SPH_C32(0x1af40000), + SPH_C32(0x2bd00001), SPH_C32(0x8a52ec00), SPH_C32(0x87e00000), + SPH_C32(0x7f224e35), SPH_C32(0x9f220a0a), SPH_C32(0x325d1f2c), + SPH_C32(0x0a275a2e) }, + { SPH_C32(0xd9ae0000), SPH_C32(0x8ec00001), SPH_C32(0x75803380), + SPH_C32(0xaeb70000), SPH_C32(0xd5b72f80), SPH_C32(0x3b9bd3b1), + SPH_C32(0x16b65b07), SPH_C32(0xda9a94a3), SPH_C32(0xb08d0000), + SPH_C32(0x42800001), SPH_C32(0x1429e180), SPH_C32(0x5b310000), + SPH_C32(0xa98b722d), SPH_C32(0x92f0de78), SPH_C32(0x6631ef9d), + SPH_C32(0x3bb81f15) }, + { SPH_C32(0x15ba0000), SPH_C32(0x2ba30001), SPH_C32(0x2f393400), + SPH_C32(0x95e70000), SPH_C32(0x9e673c7f), SPH_C32(0xbc00e7a9), + SPH_C32(0x7ff513c6), SPH_C32(0x10c0135d), SPH_C32(0x31130000), + SPH_C32(0xaed70001), SPH_C32(0x721be300), SPH_C32(0xcec20000), + SPH_C32(0xf4225a2f), SPH_C32(0xda04e2c4), SPH_C32(0x806b4db0), + SPH_C32(0xb5dfa8ef) }, + { SPH_C32(0x58300000), SPH_C32(0x62970001), SPH_C32(0x13b23100), + SPH_C32(0x3b440000), SPH_C32(0x881e0782), SPH_C32(0x736fef0d), + SPH_C32(0xf0ecf92a), SPH_C32(0x54fd2359), SPH_C32(0xfd070000), + SPH_C32(0x0bb40001), SPH_C32(0x28a2e480), SPH_C32(0xf5920000), + SPH_C32(0xbff249d0), SPH_C32(0x5d9fd6dc), SPH_C32(0xe9280571), + SPH_C32(0x7f852f11) }, + { SPH_C32(0x94240000), SPH_C32(0xc7f40001), SPH_C32(0x490b3680), + SPH_C32(0x00140000), SPH_C32(0xc3ce147d), SPH_C32(0xf4f4db15), + SPH_C32(0x99afb1eb), SPH_C32(0x9ea7a4a7), SPH_C32(0x7c990000), + SPH_C32(0xe7e30001), SPH_C32(0x4e90e600), SPH_C32(0x60610000), + SPH_C32(0xe25b61d2), SPH_C32(0x156bea60), SPH_C32(0x0f72a75c), + SPH_C32(0xf1e298eb) }, + { SPH_C32(0xa18d0000), SPH_C32(0x9c3c0001), SPH_C32(0xdcba3800), + SPH_C32(0x3e120000), SPH_C32(0xa48907f9), SPH_C32(0x45725a95), + SPH_C32(0xe63afb65), SPH_C32(0xb9f51f08), SPH_C32(0xb2220000), + SPH_C32(0xf5a80001), SPH_C32(0xae35e280), SPH_C32(0x0da90000), + SPH_C32(0x130637fe), SPH_C32(0x12b8181f), SPH_C32(0xcf6dfb07), + SPH_C32(0xcf4ef56e) }, + { SPH_C32(0x6d990000), SPH_C32(0x395f0001), SPH_C32(0x86033f80), + SPH_C32(0x05420000), SPH_C32(0xef591406), SPH_C32(0xc2e96e8d), + SPH_C32(0x8f79b3a4), SPH_C32(0x73af98f6), SPH_C32(0x33bc0000), + SPH_C32(0x19ff0001), SPH_C32(0xc807e000), SPH_C32(0x985a0000), + SPH_C32(0x4eaf1ffc), SPH_C32(0x5a4c24a3), SPH_C32(0x2937592a), + SPH_C32(0x41294294) }, + { SPH_C32(0x20130000), SPH_C32(0x706b0001), SPH_C32(0xba883a80), + SPH_C32(0xabe10000), SPH_C32(0xf9202ffb), SPH_C32(0x0d866629), + SPH_C32(0x00605948), SPH_C32(0x3792a8f2), SPH_C32(0xffa80000), + SPH_C32(0xbc9c0001), SPH_C32(0x92bee780), SPH_C32(0xa30a0000), + SPH_C32(0x057f0c03), SPH_C32(0xddd710bb), SPH_C32(0x407411eb), + SPH_C32(0x8b73c56a) }, + { SPH_C32(0xec070000), SPH_C32(0xd5080001), SPH_C32(0xe0313d00), + SPH_C32(0x90b10000), SPH_C32(0xb2f03c04), SPH_C32(0x8a1d5231), + SPH_C32(0x69231189), SPH_C32(0xfdc82f0c), SPH_C32(0x7e360000), + SPH_C32(0x50cb0001), SPH_C32(0xf48ce500), SPH_C32(0x36f90000), + SPH_C32(0x58d62401), SPH_C32(0x95232c07), SPH_C32(0xa62eb3c6), + SPH_C32(0x05147290) }, + { SPH_C32(0xdb010000), SPH_C32(0x39e80001), SPH_C32(0xcf9c3080), + SPH_C32(0xf82f0000), SPH_C32(0x6f3a6a53), SPH_C32(0xbbd315d6), + SPH_C32(0xbfea4f9d), SPH_C32(0x2e6c7ed8), SPH_C32(0xca010000), + SPH_C32(0xe7540001), SPH_C32(0x070fe900), SPH_C32(0x9d0c0000), + SPH_C32(0x62381f87), SPH_C32(0x6c51913b), SPH_C32(0x3fe15b65), + SPH_C32(0xac217ec5) }, + { SPH_C32(0x17150000), SPH_C32(0x9c8b0001), SPH_C32(0x95253700), + SPH_C32(0xc37f0000), SPH_C32(0x24ea79ac), SPH_C32(0x3c4821ce), + SPH_C32(0xd6a9075c), SPH_C32(0xe436f926), SPH_C32(0x4b9f0000), + SPH_C32(0x0b030001), SPH_C32(0x613deb80), SPH_C32(0x08ff0000), + SPH_C32(0x3f913785), SPH_C32(0x24a5ad87), SPH_C32(0xd9bbf948), + SPH_C32(0x2246c93f) }, + { SPH_C32(0x5a9f0000), SPH_C32(0xd5bf0001), SPH_C32(0xa9ae3200), + SPH_C32(0x6ddc0000), SPH_C32(0x32934251), SPH_C32(0xf327296a), + SPH_C32(0x59b0edb0), SPH_C32(0xa00bc922), SPH_C32(0x878b0000), + SPH_C32(0xae600001), SPH_C32(0x3b84ec00), SPH_C32(0x33af0000), + SPH_C32(0x7441247a), SPH_C32(0xa33e999f), SPH_C32(0xb0f8b189), + SPH_C32(0xe81c4ec1) }, + { SPH_C32(0x968b0000), SPH_C32(0x70dc0001), SPH_C32(0xf3173580), + SPH_C32(0x568c0000), SPH_C32(0x794351ae), SPH_C32(0x74bc1d72), + SPH_C32(0x30f3a571), SPH_C32(0x6a514edc), SPH_C32(0x06150000), + SPH_C32(0x42370001), SPH_C32(0x5db6ee80), SPH_C32(0xa65c0000), + SPH_C32(0x29e80c78), SPH_C32(0xebcaa523), SPH_C32(0x56a213a4), + SPH_C32(0x667bf93b) }, + { SPH_C32(0xa3220000), SPH_C32(0x2b140001), SPH_C32(0x66a63b00), + SPH_C32(0x688a0000), SPH_C32(0x1e04422a), SPH_C32(0xc53a9cf2), + SPH_C32(0x4f66efff), SPH_C32(0x4d03f573), SPH_C32(0xc8ae0000), + SPH_C32(0x507c0001), SPH_C32(0xbd13ea00), SPH_C32(0xcb940000), + SPH_C32(0xd8b55a54), SPH_C32(0xec19575c), SPH_C32(0x96bd4fff), + SPH_C32(0x58d794be) }, + { SPH_C32(0x6f360000), SPH_C32(0x8e770001), SPH_C32(0x3c1f3c80), + SPH_C32(0x53da0000), SPH_C32(0x55d451d5), SPH_C32(0x42a1a8ea), + SPH_C32(0x2625a73e), SPH_C32(0x8759728d), SPH_C32(0x49300000), + SPH_C32(0xbc2b0001), SPH_C32(0xdb21e880), SPH_C32(0x5e670000), + SPH_C32(0x851c7256), SPH_C32(0xa4ed6be0), SPH_C32(0x70e7edd2), + SPH_C32(0xd6b02344) }, + { SPH_C32(0x22bc0000), SPH_C32(0xc7430001), SPH_C32(0x00943980), + SPH_C32(0xfd790000), SPH_C32(0x43ad6a28), SPH_C32(0x8dcea04e), + SPH_C32(0xa93c4dd2), SPH_C32(0xc3644289), SPH_C32(0x85240000), + SPH_C32(0x19480001), SPH_C32(0x8198ef00), SPH_C32(0x65370000), + SPH_C32(0xcecc61a9), SPH_C32(0x23765ff8), SPH_C32(0x19a4a513), + SPH_C32(0x1ceaa4ba) }, + { SPH_C32(0xeea80000), SPH_C32(0x62200001), SPH_C32(0x5a2d3e00), + SPH_C32(0xc6290000), SPH_C32(0x087d79d7), SPH_C32(0x0a559456), + SPH_C32(0xc07f0513), SPH_C32(0x093ec577), SPH_C32(0x04ba0000), + SPH_C32(0xf51f0001), SPH_C32(0xe7aaed80), SPH_C32(0xf0c40000), + SPH_C32(0x936549ab), SPH_C32(0x6b826344), SPH_C32(0xfffe073e), + SPH_C32(0x928d1340) }, + { SPH_C32(0x6ba80000), SPH_C32(0x4ba90001), SPH_C32(0x5d832180), + SPH_C32(0xdad00000), SPH_C32(0x63751974), SPH_C32(0xd089ea49), + SPH_C32(0x256784eb), SPH_C32(0xd3d4a53b), SPH_C32(0x1cc50000), + SPH_C32(0x59260001), SPH_C32(0x51d2f200), SPH_C32(0x58720000), + SPH_C32(0xf30e4347), SPH_C32(0x8d428ece), SPH_C32(0x98432863), + SPH_C32(0xaa5c67e3) }, + { SPH_C32(0xa7bc0000), SPH_C32(0xeeca0001), SPH_C32(0x073a2600), + SPH_C32(0xe1800000), SPH_C32(0x28a50a8b), SPH_C32(0x5712de51), + SPH_C32(0x4c24cc2a), SPH_C32(0x198e22c5), SPH_C32(0x9d5b0000), + SPH_C32(0xb5710001), SPH_C32(0x37e0f080), SPH_C32(0xcd810000), + SPH_C32(0xaea76b45), SPH_C32(0xc5b6b272), SPH_C32(0x7e198a4e), + SPH_C32(0x243bd019) }, + { SPH_C32(0xea360000), SPH_C32(0xa7fe0001), SPH_C32(0x3bb12300), + SPH_C32(0x4f230000), SPH_C32(0x3edc3176), SPH_C32(0x987dd6f5), + SPH_C32(0xc33d26c6), SPH_C32(0x5db312c1), SPH_C32(0x514f0000), + SPH_C32(0x10120001), SPH_C32(0x6d59f700), SPH_C32(0xf6d10000), + SPH_C32(0xe57778ba), SPH_C32(0x422d866a), SPH_C32(0x175ac28f), + SPH_C32(0xee6157e7) }, + { SPH_C32(0x26220000), SPH_C32(0x029d0001), SPH_C32(0x61082480), + SPH_C32(0x74730000), SPH_C32(0x750c2289), SPH_C32(0x1fe6e2ed), + SPH_C32(0xaa7e6e07), SPH_C32(0x97e9953f), SPH_C32(0xd0d10000), + SPH_C32(0xfc450001), SPH_C32(0x0b6bf580), SPH_C32(0x63220000), + SPH_C32(0xb8de50b8), SPH_C32(0x0ad9bad6), SPH_C32(0xf10060a2), + SPH_C32(0x6006e01d) }, + { SPH_C32(0x138b0000), SPH_C32(0x59550001), SPH_C32(0xf4b92a00), + SPH_C32(0x4a750000), SPH_C32(0x124b310d), SPH_C32(0xae60636d), + SPH_C32(0xd5eb2489), SPH_C32(0xb0bb2e90), SPH_C32(0x1e6a0000), + SPH_C32(0xee0e0001), SPH_C32(0xebcef100), SPH_C32(0x0eea0000), + SPH_C32(0x49830694), SPH_C32(0x0d0a48a9), SPH_C32(0x311f3cf9), + SPH_C32(0x5eaa8d98) }, + { SPH_C32(0xdf9f0000), SPH_C32(0xfc360001), SPH_C32(0xae002d80), + SPH_C32(0x71250000), SPH_C32(0x599b22f2), SPH_C32(0x29fb5775), + SPH_C32(0xbca86c48), SPH_C32(0x7ae1a96e), SPH_C32(0x9ff40000), + SPH_C32(0x02590001), SPH_C32(0x8dfcf380), SPH_C32(0x9b190000), + SPH_C32(0x142a2e96), SPH_C32(0x45fe7415), SPH_C32(0xd7459ed4), + SPH_C32(0xd0cd3a62) }, + { SPH_C32(0x92150000), SPH_C32(0xb5020001), SPH_C32(0x928b2880), + SPH_C32(0xdf860000), SPH_C32(0x4fe2190f), SPH_C32(0xe6945fd1), + SPH_C32(0x33b186a4), SPH_C32(0x3edc996a), SPH_C32(0x53e00000), + SPH_C32(0xa73a0001), SPH_C32(0xd745f400), SPH_C32(0xa0490000), + SPH_C32(0x5ffa3d69), SPH_C32(0xc265400d), SPH_C32(0xbe06d615), + SPH_C32(0x1a97bd9c) }, + { SPH_C32(0x5e010000), SPH_C32(0x10610001), SPH_C32(0xc8322f00), + SPH_C32(0xe4d60000), SPH_C32(0x04320af0), SPH_C32(0x610f6bc9), + SPH_C32(0x5af2ce65), SPH_C32(0xf4861e94), SPH_C32(0xd27e0000), + SPH_C32(0x4b6d0001), SPH_C32(0xb177f680), SPH_C32(0x35ba0000), + SPH_C32(0x0253156b), SPH_C32(0x8a917cb1), SPH_C32(0x585c7438), + SPH_C32(0x94f00a66) }, + { SPH_C32(0x69070000), SPH_C32(0xfc810001), SPH_C32(0xe79f2280), + SPH_C32(0x8c480000), SPH_C32(0xd9f85ca7), SPH_C32(0x50c12c2e), + SPH_C32(0x8c3b9071), SPH_C32(0x27224f40), SPH_C32(0x66490000), + SPH_C32(0xfcf20001), SPH_C32(0x42f4fa80), SPH_C32(0x9e4f0000), + SPH_C32(0x38bd2eed), SPH_C32(0x73e3c18d), SPH_C32(0xc1939c9b), + SPH_C32(0x3dc50633) }, + { SPH_C32(0xa5130000), SPH_C32(0x59e20001), SPH_C32(0xbd262500), + SPH_C32(0xb7180000), SPH_C32(0x92284f58), SPH_C32(0xd75a1836), + SPH_C32(0xe578d8b0), SPH_C32(0xed78c8be), SPH_C32(0xe7d70000), + SPH_C32(0x10a50001), SPH_C32(0x24c6f800), SPH_C32(0x0bbc0000), + SPH_C32(0x651406ef), SPH_C32(0x3b17fd31), SPH_C32(0x27c93eb6), + SPH_C32(0xb3a2b1c9) }, + { SPH_C32(0xe8990000), SPH_C32(0x10d60001), SPH_C32(0x81ad2000), + SPH_C32(0x19bb0000), SPH_C32(0x845174a5), SPH_C32(0x18351092), + SPH_C32(0x6a61325c), SPH_C32(0xa945f8ba), SPH_C32(0x2bc30000), + SPH_C32(0xb5c60001), SPH_C32(0x7e7fff80), SPH_C32(0x30ec0000), + SPH_C32(0x2ec41510), SPH_C32(0xbc8cc929), SPH_C32(0x4e8a7677), + SPH_C32(0x79f83637) }, + { SPH_C32(0x248d0000), SPH_C32(0xb5b50001), SPH_C32(0xdb142780), + SPH_C32(0x22eb0000), SPH_C32(0xcf81675a), SPH_C32(0x9fae248a), + SPH_C32(0x03227a9d), SPH_C32(0x631f7f44), SPH_C32(0xaa5d0000), + SPH_C32(0x59910001), SPH_C32(0x184dfd00), SPH_C32(0xa51f0000), + SPH_C32(0x736d3d12), SPH_C32(0xf478f595), SPH_C32(0xa8d0d45a), + SPH_C32(0xf79f81cd) }, + { SPH_C32(0x11240000), SPH_C32(0xee7d0001), SPH_C32(0x4ea52900), + SPH_C32(0x1ced0000), SPH_C32(0xa8c674de), SPH_C32(0x2e28a50a), + SPH_C32(0x7cb73013), SPH_C32(0x444dc4eb), SPH_C32(0x64e60000), + SPH_C32(0x4bda0001), SPH_C32(0xf8e8f980), SPH_C32(0xc8d70000), + SPH_C32(0x82306b3e), SPH_C32(0xf3ab07ea), SPH_C32(0x68cf8801), + SPH_C32(0xc933ec48) }, + { SPH_C32(0xdd300000), SPH_C32(0x4b1e0001), SPH_C32(0x141c2e80), + SPH_C32(0x27bd0000), SPH_C32(0xe3166721), SPH_C32(0xa9b39112), + SPH_C32(0x15f478d2), SPH_C32(0x8e174315), SPH_C32(0xe5780000), + SPH_C32(0xa78d0001), SPH_C32(0x9edafb00), SPH_C32(0x5d240000), + SPH_C32(0xdf99433c), SPH_C32(0xbb5f3b56), SPH_C32(0x8e952a2c), + SPH_C32(0x47545bb2) }, + { SPH_C32(0x90ba0000), SPH_C32(0x022a0001), SPH_C32(0x28972b80), + SPH_C32(0x891e0000), SPH_C32(0xf56f5cdc), SPH_C32(0x66dc99b6), + SPH_C32(0x9aed923e), SPH_C32(0xca2a7311), SPH_C32(0x296c0000), + SPH_C32(0x02ee0001), SPH_C32(0xc463fc80), SPH_C32(0x66740000), + SPH_C32(0x944950c3), SPH_C32(0x3cc40f4e), SPH_C32(0xe7d662ed), + SPH_C32(0x8d0edc4c) }, + { SPH_C32(0x5cae0000), SPH_C32(0xa7490001), SPH_C32(0x722e2c00), + SPH_C32(0xb24e0000), SPH_C32(0xbebf4f23), SPH_C32(0xe147adae), + SPH_C32(0xf3aedaff), SPH_C32(0x0070f4ef), SPH_C32(0xa8f20000), + SPH_C32(0xeeb90001), SPH_C32(0xa251fe00), SPH_C32(0xf3870000), + SPH_C32(0xc9e078c1), SPH_C32(0x743033f2), SPH_C32(0x018cc0c0), + SPH_C32(0x03696bb6) }, + { SPH_C32(0xc7e00000), SPH_C32(0x500f0001), SPH_C32(0x18783200), + SPH_C32(0xd9930000), SPH_C32(0x39f0281e), SPH_C32(0xcf3bbaff), + SPH_C32(0xdb154315), SPH_C32(0x4230ddcd), SPH_C32(0x028b0000), + SPH_C32(0x87e90001), SPH_C32(0x3c2af380), SPH_C32(0x2f560000), + SPH_C32(0x1f4944d9), SPH_C32(0x79e2e780), SPH_C32(0x55e03071), + SPH_C32(0x32f62e8d) }, + { SPH_C32(0x0bf40000), SPH_C32(0xf56c0001), SPH_C32(0x42c13580), + SPH_C32(0xe2c30000), SPH_C32(0x72203be1), SPH_C32(0x48a08ee7), + SPH_C32(0xb2560bd4), SPH_C32(0x886a5a33), SPH_C32(0x83150000), + SPH_C32(0x6bbe0001), SPH_C32(0x5a18f100), SPH_C32(0xbaa50000), + SPH_C32(0x42e06cdb), SPH_C32(0x3116db3c), SPH_C32(0xb3ba925c), + SPH_C32(0xbc919977) }, + { SPH_C32(0x467e0000), SPH_C32(0xbc580001), SPH_C32(0x7e4a3080), + SPH_C32(0x4c600000), SPH_C32(0x6459001c), SPH_C32(0x87cf8643), + SPH_C32(0x3d4fe138), SPH_C32(0xcc576a37), SPH_C32(0x4f010000), + SPH_C32(0xcedd0001), SPH_C32(0x00a1f680), SPH_C32(0x81f50000), + SPH_C32(0x09307f24), SPH_C32(0xb68def24), SPH_C32(0xdaf9da9d), + SPH_C32(0x76cb1e89) }, + { SPH_C32(0x8a6a0000), SPH_C32(0x193b0001), SPH_C32(0x24f33700), + SPH_C32(0x77300000), SPH_C32(0x2f8913e3), SPH_C32(0x0054b25b), + SPH_C32(0x540ca9f9), SPH_C32(0x060dedc9), SPH_C32(0xce9f0000), + SPH_C32(0x228a0001), SPH_C32(0x6693f400), SPH_C32(0x14060000), + SPH_C32(0x54995726), SPH_C32(0xfe79d398), SPH_C32(0x3ca378b0), + SPH_C32(0xf8aca973) }, + { SPH_C32(0xbfc30000), SPH_C32(0x42f30001), SPH_C32(0xb1423980), + SPH_C32(0x49360000), SPH_C32(0x48ce0067), SPH_C32(0xb1d233db), + SPH_C32(0x2b99e377), SPH_C32(0x215f5666), SPH_C32(0x00240000), + SPH_C32(0x30c10001), SPH_C32(0x8636f080), SPH_C32(0x79ce0000), + SPH_C32(0xa5c4010a), SPH_C32(0xf9aa21e7), SPH_C32(0xfcbc24eb), + SPH_C32(0xc600c4f6) }, + { SPH_C32(0x73d70000), SPH_C32(0xe7900001), SPH_C32(0xebfb3e00), + SPH_C32(0x72660000), SPH_C32(0x031e1398), SPH_C32(0x364907c3), + SPH_C32(0x42daabb6), SPH_C32(0xeb05d198), SPH_C32(0x81ba0000), + SPH_C32(0xdc960001), SPH_C32(0xe004f200), SPH_C32(0xec3d0000), + SPH_C32(0xf86d2908), SPH_C32(0xb15e1d5b), SPH_C32(0x1ae686c6), + SPH_C32(0x4867730c) }, + { SPH_C32(0x3e5d0000), SPH_C32(0xaea40001), SPH_C32(0xd7703b00), + SPH_C32(0xdcc50000), SPH_C32(0x15672865), SPH_C32(0xf9260f67), + SPH_C32(0xcdc3415a), SPH_C32(0xaf38e19c), SPH_C32(0x4dae0000), + SPH_C32(0x79f50001), SPH_C32(0xbabdf580), SPH_C32(0xd76d0000), + SPH_C32(0xb3bd3af7), SPH_C32(0x36c52943), SPH_C32(0x73a5ce07), + SPH_C32(0x823df4f2) }, + { SPH_C32(0xf2490000), SPH_C32(0x0bc70001), SPH_C32(0x8dc93c80), + SPH_C32(0xe7950000), SPH_C32(0x5eb73b9a), SPH_C32(0x7ebd3b7f), + SPH_C32(0xa480099b), SPH_C32(0x65626662), SPH_C32(0xcc300000), + SPH_C32(0x95a20001), SPH_C32(0xdc8ff700), SPH_C32(0x429e0000), + SPH_C32(0xee1412f5), SPH_C32(0x7e3115ff), SPH_C32(0x95ff6c2a), + SPH_C32(0x0c5a4308) }, + { SPH_C32(0xc54f0000), SPH_C32(0xe7270001), SPH_C32(0xa2643100), + SPH_C32(0x8f0b0000), SPH_C32(0x837d6dcd), SPH_C32(0x4f737c98), + SPH_C32(0x7249578f), SPH_C32(0xb6c637b6), SPH_C32(0x78070000), + SPH_C32(0x223d0001), SPH_C32(0x2f0cfb00), SPH_C32(0xe96b0000), + SPH_C32(0xd4fa2973), SPH_C32(0x8743a8c3), SPH_C32(0x0c308489), + SPH_C32(0xa56f4f5d) }, + { SPH_C32(0x095b0000), SPH_C32(0x42440001), SPH_C32(0xf8dd3680), + SPH_C32(0xb45b0000), SPH_C32(0xc8ad7e32), SPH_C32(0xc8e84880), + SPH_C32(0x1b0a1f4e), SPH_C32(0x7c9cb048), SPH_C32(0xf9990000), + SPH_C32(0xce6a0001), SPH_C32(0x493ef980), SPH_C32(0x7c980000), + SPH_C32(0x89530171), SPH_C32(0xcfb7947f), SPH_C32(0xea6a26a4), + SPH_C32(0x2b08f8a7) }, + { SPH_C32(0x44d10000), SPH_C32(0x0b700001), SPH_C32(0xc4563380), + SPH_C32(0x1af80000), SPH_C32(0xded445cf), SPH_C32(0x07874024), + SPH_C32(0x9413f5a2), SPH_C32(0x38a1804c), SPH_C32(0x358d0000), + SPH_C32(0x6b090001), SPH_C32(0x1387fe00), SPH_C32(0x47c80000), + SPH_C32(0xc283128e), SPH_C32(0x482ca067), SPH_C32(0x83296e65), + SPH_C32(0xe1527f59) }, + { SPH_C32(0x88c50000), SPH_C32(0xae130001), SPH_C32(0x9eef3400), + SPH_C32(0x21a80000), SPH_C32(0x95045630), SPH_C32(0x801c743c), + SPH_C32(0xfd50bd63), SPH_C32(0xf2fb07b2), SPH_C32(0xb4130000), + SPH_C32(0x875e0001), SPH_C32(0x75b5fc80), SPH_C32(0xd23b0000), + SPH_C32(0x9f2a3a8c), SPH_C32(0x00d89cdb), SPH_C32(0x6573cc48), + SPH_C32(0x6f35c8a3) }, + { SPH_C32(0xbd6c0000), SPH_C32(0xf5db0001), SPH_C32(0x0b5e3a80), + SPH_C32(0x1fae0000), SPH_C32(0xf24345b4), SPH_C32(0x319af5bc), + SPH_C32(0x82c5f7ed), SPH_C32(0xd5a9bc1d), SPH_C32(0x7aa80000), + SPH_C32(0x95150001), SPH_C32(0x9510f800), SPH_C32(0xbff30000), + SPH_C32(0x6e776ca0), SPH_C32(0x070b6ea4), SPH_C32(0xa56c9013), + SPH_C32(0x5199a526) }, + { SPH_C32(0x71780000), SPH_C32(0x50b80001), SPH_C32(0x51e73d00), + SPH_C32(0x24fe0000), SPH_C32(0xb993564b), SPH_C32(0xb601c1a4), + SPH_C32(0xeb86bf2c), SPH_C32(0x1ff33be3), SPH_C32(0xfb360000), + SPH_C32(0x79420001), SPH_C32(0xf322fa80), SPH_C32(0x2a000000), + SPH_C32(0x33de44a2), SPH_C32(0x4fff5218), SPH_C32(0x4336323e), + SPH_C32(0xdffe12dc) }, + { SPH_C32(0x3cf20000), SPH_C32(0x198c0001), SPH_C32(0x6d6c3800), + SPH_C32(0x8a5d0000), SPH_C32(0xafea6db6), SPH_C32(0x796ec900), + SPH_C32(0x649f55c0), SPH_C32(0x5bce0be7), SPH_C32(0x37220000), + SPH_C32(0xdc210001), SPH_C32(0xa99bfd00), SPH_C32(0x11500000), + SPH_C32(0x780e575d), SPH_C32(0xc8646600), SPH_C32(0x2a757aff), + SPH_C32(0x15a49522) }, + { SPH_C32(0xf0e60000), SPH_C32(0xbcef0001), SPH_C32(0x37d53f80), + SPH_C32(0xb10d0000), SPH_C32(0xe43a7e49), SPH_C32(0xfef5fd18), + SPH_C32(0x0ddc1d01), SPH_C32(0x91948c19), SPH_C32(0xb6bc0000), + SPH_C32(0x30760001), SPH_C32(0xcfa9ff80), SPH_C32(0x84a30000), + SPH_C32(0x25a77f5f), SPH_C32(0x80905abc), SPH_C32(0xcc2fd8d2), + SPH_C32(0x9bc322d8) } +}; + +static const sph_u32 T512_40[256][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x58430000), SPH_C32(0x807e0000), SPH_C32(0x78330001), + SPH_C32(0xc66b3800), SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), + SPH_C32(0xac73fe6f), SPH_C32(0x3a4479b1), SPH_C32(0x1d5a0000), + SPH_C32(0x2b720000), SPH_C32(0x488d0000), SPH_C32(0xaf611800), + SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), SPH_C32(0x81a20429), + SPH_C32(0x1e7536a6) }, + { SPH_C32(0x1d5a0000), SPH_C32(0x2b720000), SPH_C32(0x488d0000), + SPH_C32(0xaf611800), SPH_C32(0x25cb2ec5), SPH_C32(0xc879bfd0), + SPH_C32(0x81a20429), SPH_C32(0x1e7536a6), SPH_C32(0x45190000), + SPH_C32(0xab0c0000), SPH_C32(0x30be0001), SPH_C32(0x690a2000), + SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), SPH_C32(0x2dd1fa46), + SPH_C32(0x24314f17) }, + { SPH_C32(0x45190000), SPH_C32(0xab0c0000), SPH_C32(0x30be0001), + SPH_C32(0x690a2000), SPH_C32(0xc2fc7219), SPH_C32(0xb1d4800d), + SPH_C32(0x2dd1fa46), SPH_C32(0x24314f17), SPH_C32(0x58430000), + SPH_C32(0x807e0000), SPH_C32(0x78330001), SPH_C32(0xc66b3800), + SPH_C32(0xe7375cdc), SPH_C32(0x79ad3fdd), SPH_C32(0xac73fe6f), + SPH_C32(0x3a4479b1) }, + { SPH_C32(0xa53b0000), SPH_C32(0x14260000), SPH_C32(0x4e30001e), + SPH_C32(0x7cae0000), SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), + SPH_C32(0xf73168d8), SPH_C32(0x0b1b4946), SPH_C32(0x07ed0000), + SPH_C32(0xb2500000), SPH_C32(0x8774000a), SPH_C32(0x970d0000), + SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), SPH_C32(0xf4786222), + SPH_C32(0x9075b1ce) }, + { SPH_C32(0xfd780000), SPH_C32(0x94580000), SPH_C32(0x3603001f), + SPH_C32(0xbac53800), SPH_C32(0x68a95109), SPH_C32(0x017295e0), + SPH_C32(0x5b4296b7), SPH_C32(0x315f30f7), SPH_C32(0x1ab70000), + SPH_C32(0x99220000), SPH_C32(0xcff9000a), SPH_C32(0x386c1800), + SPH_C32(0x66b90d6b), SPH_C32(0x80bed174), SPH_C32(0x75da660b), + SPH_C32(0x8e008768) }, + { SPH_C32(0xb8610000), SPH_C32(0x3f540000), SPH_C32(0x06bd001e), + SPH_C32(0xd3cf1800), SPH_C32(0xaa552310), SPH_C32(0xb0a615ed), + SPH_C32(0x76936cf1), SPH_C32(0x156e7fe0), SPH_C32(0x42f40000), + SPH_C32(0x195c0000), SPH_C32(0xb7ca000b), SPH_C32(0xfe072000), + SPH_C32(0x818e51b7), SPH_C32(0xf913eea9), SPH_C32(0xd9a99864), + SPH_C32(0xb444fed9) }, + { SPH_C32(0xe0220000), SPH_C32(0xbf2a0000), SPH_C32(0x7e8e001f), + SPH_C32(0x15a42000), SPH_C32(0x4d627fcc), SPH_C32(0xc90b2a30), + SPH_C32(0xdae0929e), SPH_C32(0x2f2a0651), SPH_C32(0x5fae0000), + SPH_C32(0x322e0000), SPH_C32(0xff47000b), SPH_C32(0x51663800), + SPH_C32(0xa4457f72), SPH_C32(0x316a5179), SPH_C32(0x580b9c4d), + SPH_C32(0xaa31c87f) }, + { SPH_C32(0x07ed0000), SPH_C32(0xb2500000), SPH_C32(0x8774000a), + SPH_C32(0x970d0000), SPH_C32(0x437223ae), SPH_C32(0x48c76ea4), + SPH_C32(0xf4786222), SPH_C32(0x9075b1ce), SPH_C32(0xa2d60000), + SPH_C32(0xa6760000), SPH_C32(0xc9440014), SPH_C32(0xeba30000), + SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), SPH_C32(0x03490afa), + SPH_C32(0x9b6ef888) }, + { SPH_C32(0x5fae0000), SPH_C32(0x322e0000), SPH_C32(0xff47000b), + SPH_C32(0x51663800), SPH_C32(0xa4457f72), SPH_C32(0x316a5179), + SPH_C32(0x580b9c4d), SPH_C32(0xaa31c87f), SPH_C32(0xbf8c0000), + SPH_C32(0x8d040000), SPH_C32(0x81c90014), SPH_C32(0x44c21800), + SPH_C32(0xe92700be), SPH_C32(0xf8617b49), SPH_C32(0x82eb0ed3), + SPH_C32(0x851bce2e) }, + { SPH_C32(0x1ab70000), SPH_C32(0x99220000), SPH_C32(0xcff9000a), + SPH_C32(0x386c1800), SPH_C32(0x66b90d6b), SPH_C32(0x80bed174), + SPH_C32(0x75da660b), SPH_C32(0x8e008768), SPH_C32(0xe7cf0000), + SPH_C32(0x0d7a0000), SPH_C32(0xf9fa0015), SPH_C32(0x82a92000), + SPH_C32(0x0e105c62), SPH_C32(0x81cc4494), SPH_C32(0x2e98f0bc), + SPH_C32(0xbf5fb79f) }, + { SPH_C32(0x42f40000), SPH_C32(0x195c0000), SPH_C32(0xb7ca000b), + SPH_C32(0xfe072000), SPH_C32(0x818e51b7), SPH_C32(0xf913eea9), + SPH_C32(0xd9a99864), SPH_C32(0xb444fed9), SPH_C32(0xfa950000), + SPH_C32(0x26080000), SPH_C32(0xb1770015), SPH_C32(0x2dc83800), + SPH_C32(0x2bdb72a7), SPH_C32(0x49b5fb44), SPH_C32(0xaf3af495), + SPH_C32(0xa12a8139) }, + { SPH_C32(0xa2d60000), SPH_C32(0xa6760000), SPH_C32(0xc9440014), + SPH_C32(0xeba30000), SPH_C32(0xccec2e7b), SPH_C32(0x3018c499), + SPH_C32(0x03490afa), SPH_C32(0x9b6ef888), SPH_C32(0xa53b0000), + SPH_C32(0x14260000), SPH_C32(0x4e30001e), SPH_C32(0x7cae0000), + SPH_C32(0x8f9e0dd5), SPH_C32(0x78dfaa3d), SPH_C32(0xf73168d8), + SPH_C32(0x0b1b4946) }, + { SPH_C32(0xfa950000), SPH_C32(0x26080000), SPH_C32(0xb1770015), + SPH_C32(0x2dc83800), SPH_C32(0x2bdb72a7), SPH_C32(0x49b5fb44), + SPH_C32(0xaf3af495), SPH_C32(0xa12a8139), SPH_C32(0xb8610000), + SPH_C32(0x3f540000), SPH_C32(0x06bd001e), SPH_C32(0xd3cf1800), + SPH_C32(0xaa552310), SPH_C32(0xb0a615ed), SPH_C32(0x76936cf1), + SPH_C32(0x156e7fe0) }, + { SPH_C32(0xbf8c0000), SPH_C32(0x8d040000), SPH_C32(0x81c90014), + SPH_C32(0x44c21800), SPH_C32(0xe92700be), SPH_C32(0xf8617b49), + SPH_C32(0x82eb0ed3), SPH_C32(0x851bce2e), SPH_C32(0xe0220000), + SPH_C32(0xbf2a0000), SPH_C32(0x7e8e001f), SPH_C32(0x15a42000), + SPH_C32(0x4d627fcc), SPH_C32(0xc90b2a30), SPH_C32(0xdae0929e), + SPH_C32(0x2f2a0651) }, + { SPH_C32(0xe7cf0000), SPH_C32(0x0d7a0000), SPH_C32(0xf9fa0015), + SPH_C32(0x82a92000), SPH_C32(0x0e105c62), SPH_C32(0x81cc4494), + SPH_C32(0x2e98f0bc), SPH_C32(0xbf5fb79f), SPH_C32(0xfd780000), + SPH_C32(0x94580000), SPH_C32(0x3603001f), SPH_C32(0xbac53800), + SPH_C32(0x68a95109), SPH_C32(0x017295e0), SPH_C32(0x5b4296b7), + SPH_C32(0x315f30f7) }, + { SPH_C32(0x88980000), SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), + SPH_C32(0xfb4e0000), SPH_C32(0xf158079a), SPH_C32(0x61ae9167), + SPH_C32(0xa895706c), SPH_C32(0xe6107494), SPH_C32(0x0bc20000), + SPH_C32(0xdb630000), SPH_C32(0x7e88000c), SPH_C32(0x15860000), + SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), SPH_C32(0xf460449e), + SPH_C32(0xd8b61463) }, + { SPH_C32(0xd0db0000), SPH_C32(0x9fea0000), SPH_C32(0x07fc002f), + SPH_C32(0x3d253800), SPH_C32(0x166f5b46), SPH_C32(0x1803aeba), + SPH_C32(0x04e68e03), SPH_C32(0xdc540d25), SPH_C32(0x16980000), + SPH_C32(0xf0110000), SPH_C32(0x3605000c), SPH_C32(0xbae71800), + SPH_C32(0xb4366636), SPH_C32(0xbdf80493), SPH_C32(0x75c240b7), + SPH_C32(0xc6c322c5) }, + { SPH_C32(0x95c20000), SPH_C32(0x34e60000), SPH_C32(0x3742002e), + SPH_C32(0x542f1800), SPH_C32(0xd493295f), SPH_C32(0xa9d72eb7), + SPH_C32(0x29377445), SPH_C32(0xf8654232), SPH_C32(0x4edb0000), + SPH_C32(0x706f0000), SPH_C32(0x4e36000d), SPH_C32(0x7c8c2000), + SPH_C32(0x53013aea), SPH_C32(0xc4553b4e), SPH_C32(0xd9b1bed8), + SPH_C32(0xfc875b74) }, + { SPH_C32(0xcd810000), SPH_C32(0xb4980000), SPH_C32(0x4f71002f), + SPH_C32(0x92442000), SPH_C32(0x33a47583), SPH_C32(0xd07a116a), + SPH_C32(0x85448a2a), SPH_C32(0xc2213b83), SPH_C32(0x53810000), + SPH_C32(0x5b1d0000), SPH_C32(0x06bb000d), SPH_C32(0xd3ed3800), + SPH_C32(0x76ca142f), SPH_C32(0x0c2c849e), SPH_C32(0x5813baf1), + SPH_C32(0xe2f26dd2) }, + { SPH_C32(0x2da30000), SPH_C32(0x0bb20000), SPH_C32(0x31ff0030), + SPH_C32(0x87e00000), SPH_C32(0x7ec60a4f), SPH_C32(0x19713b5a), + SPH_C32(0x5fa418b4), SPH_C32(0xed0b3dd2), SPH_C32(0x0c2f0000), + SPH_C32(0x69330000), SPH_C32(0xf9fc0006), SPH_C32(0x828b0000), + SPH_C32(0xd28f6b5d), SPH_C32(0x3d46d5e7), SPH_C32(0x001826bc), + SPH_C32(0x48c3a5ad) }, + { SPH_C32(0x75e00000), SPH_C32(0x8bcc0000), SPH_C32(0x49cc0031), + SPH_C32(0x418b3800), SPH_C32(0x99f15693), SPH_C32(0x60dc0487), + SPH_C32(0xf3d7e6db), SPH_C32(0xd74f4463), SPH_C32(0x11750000), + SPH_C32(0x42410000), SPH_C32(0xb1710006), SPH_C32(0x2dea1800), + SPH_C32(0xf7444598), SPH_C32(0xf53f6a37), SPH_C32(0x81ba2295), + SPH_C32(0x56b6930b) }, + { SPH_C32(0x30f90000), SPH_C32(0x20c00000), SPH_C32(0x79720030), + SPH_C32(0x28811800), SPH_C32(0x5b0d248a), SPH_C32(0xd108848a), + SPH_C32(0xde061c9d), SPH_C32(0xf37e0b74), SPH_C32(0x49360000), + SPH_C32(0xc23f0000), SPH_C32(0xc9420007), SPH_C32(0xeb812000), + SPH_C32(0x10731944), SPH_C32(0x8c9255ea), SPH_C32(0x2dc9dcfa), + SPH_C32(0x6cf2eaba) }, + { SPH_C32(0x68ba0000), SPH_C32(0xa0be0000), SPH_C32(0x01410031), + SPH_C32(0xeeea2000), SPH_C32(0xbc3a7856), SPH_C32(0xa8a5bb57), + SPH_C32(0x7275e2f2), SPH_C32(0xc93a72c5), SPH_C32(0x546c0000), + SPH_C32(0xe94d0000), SPH_C32(0x81cf0007), SPH_C32(0x44e03800), + SPH_C32(0x35b83781), SPH_C32(0x44ebea3a), SPH_C32(0xac6bd8d3), + SPH_C32(0x7287dc1c) }, + { SPH_C32(0x8f750000), SPH_C32(0xadc40000), SPH_C32(0xf8bb0024), + SPH_C32(0x6c430000), SPH_C32(0xb22a2434), SPH_C32(0x2969ffc3), + SPH_C32(0x5ced124e), SPH_C32(0x7665c55a), SPH_C32(0xa9140000), + SPH_C32(0x7d150000), SPH_C32(0xb7cc0018), SPH_C32(0xfe250000), + SPH_C32(0x5d116688), SPH_C32(0x45997fda), SPH_C32(0xf7294e64), + SPH_C32(0x43d8eceb) }, + { SPH_C32(0xd7360000), SPH_C32(0x2dba0000), SPH_C32(0x80880025), + SPH_C32(0xaa283800), SPH_C32(0x551d78e8), SPH_C32(0x50c4c01e), + SPH_C32(0xf09eec21), SPH_C32(0x4c21bceb), SPH_C32(0xb44e0000), + SPH_C32(0x56670000), SPH_C32(0xff410018), SPH_C32(0x51441800), + SPH_C32(0x78da484d), SPH_C32(0x8de0c00a), SPH_C32(0x768b4a4d), + SPH_C32(0x5dadda4d) }, + { SPH_C32(0x922f0000), SPH_C32(0x86b60000), SPH_C32(0xb0360024), + SPH_C32(0xc3221800), SPH_C32(0x97e10af1), SPH_C32(0xe1104013), + SPH_C32(0xdd4f1667), SPH_C32(0x6810f3fc), SPH_C32(0xec0d0000), + SPH_C32(0xd6190000), SPH_C32(0x87720019), SPH_C32(0x972f2000), + SPH_C32(0x9fed1491), SPH_C32(0xf44dffd7), SPH_C32(0xdaf8b422), + SPH_C32(0x67e9a3fc) }, + { SPH_C32(0xca6c0000), SPH_C32(0x06c80000), SPH_C32(0xc8050025), + SPH_C32(0x05492000), SPH_C32(0x70d6562d), SPH_C32(0x98bd7fce), + SPH_C32(0x713ce808), SPH_C32(0x52548a4d), SPH_C32(0xf1570000), + SPH_C32(0xfd6b0000), SPH_C32(0xcfff0019), SPH_C32(0x384e3800), + SPH_C32(0xba263a54), SPH_C32(0x3c344007), SPH_C32(0x5b5ab00b), + SPH_C32(0x799c955a) }, + { SPH_C32(0x2a4e0000), SPH_C32(0xb9e20000), SPH_C32(0xb68b003a), + SPH_C32(0x10ed0000), SPH_C32(0x3db429e1), SPH_C32(0x51b655fe), + SPH_C32(0xabdc7a96), SPH_C32(0x7d7e8c1c), SPH_C32(0xaef90000), + SPH_C32(0xcf450000), SPH_C32(0x30b80012), SPH_C32(0x69280000), + SPH_C32(0x1e634526), SPH_C32(0x0d5e117e), SPH_C32(0x03512c46), + SPH_C32(0xd3ad5d25) }, + { SPH_C32(0x720d0000), SPH_C32(0x399c0000), SPH_C32(0xceb8003b), + SPH_C32(0xd6863800), SPH_C32(0xda83753d), SPH_C32(0x281b6a23), + SPH_C32(0x07af84f9), SPH_C32(0x473af5ad), SPH_C32(0xb3a30000), + SPH_C32(0xe4370000), SPH_C32(0x78350012), SPH_C32(0xc6491800), + SPH_C32(0x3ba86be3), SPH_C32(0xc527aeae), SPH_C32(0x82f3286f), + SPH_C32(0xcdd86b83) }, + { SPH_C32(0x37140000), SPH_C32(0x92900000), SPH_C32(0xfe06003a), + SPH_C32(0xbf8c1800), SPH_C32(0x187f0724), SPH_C32(0x99cfea2e), + SPH_C32(0x2a7e7ebf), SPH_C32(0x630bbaba), SPH_C32(0xebe00000), + SPH_C32(0x64490000), SPH_C32(0x00060013), SPH_C32(0x00222000), + SPH_C32(0xdc9f373f), SPH_C32(0xbc8a9173), SPH_C32(0x2e80d600), + SPH_C32(0xf79c1232) }, + { SPH_C32(0x6f570000), SPH_C32(0x12ee0000), SPH_C32(0x8635003b), + SPH_C32(0x79e72000), SPH_C32(0xff485bf8), SPH_C32(0xe062d5f3), + SPH_C32(0x860d80d0), SPH_C32(0x594fc30b), SPH_C32(0xf6ba0000), + SPH_C32(0x4f3b0000), SPH_C32(0x488b0013), SPH_C32(0xaf433800), + SPH_C32(0xf95419fa), SPH_C32(0x74f32ea3), SPH_C32(0xaf22d229), + SPH_C32(0xe9e92494) }, + { SPH_C32(0x0bc20000), SPH_C32(0xdb630000), SPH_C32(0x7e88000c), + SPH_C32(0x15860000), SPH_C32(0x91fd48f3), SPH_C32(0x7581bb43), + SPH_C32(0xf460449e), SPH_C32(0xd8b61463), SPH_C32(0x835a0000), + SPH_C32(0xc4f70000), SPH_C32(0x01470022), SPH_C32(0xeec80000), + SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), SPH_C32(0x5cf534f2), + SPH_C32(0x3ea660f7) }, + { SPH_C32(0x53810000), SPH_C32(0x5b1d0000), SPH_C32(0x06bb000d), + SPH_C32(0xd3ed3800), SPH_C32(0x76ca142f), SPH_C32(0x0c2c849e), + SPH_C32(0x5813baf1), SPH_C32(0xe2f26dd2), SPH_C32(0x9e000000), + SPH_C32(0xef850000), SPH_C32(0x49ca0022), SPH_C32(0x41a91800), + SPH_C32(0x456e61ac), SPH_C32(0xdc5695f4), SPH_C32(0xdd5730db), + SPH_C32(0x20d35651) }, + { SPH_C32(0x16980000), SPH_C32(0xf0110000), SPH_C32(0x3605000c), + SPH_C32(0xbae71800), SPH_C32(0xb4366636), SPH_C32(0xbdf80493), + SPH_C32(0x75c240b7), SPH_C32(0xc6c322c5), SPH_C32(0xc6430000), + SPH_C32(0x6ffb0000), SPH_C32(0x31f90023), SPH_C32(0x87c22000), + SPH_C32(0xa2593d70), SPH_C32(0xa5fbaa29), SPH_C32(0x7124ceb4), + SPH_C32(0x1a972fe0) }, + { SPH_C32(0x4edb0000), SPH_C32(0x706f0000), SPH_C32(0x4e36000d), + SPH_C32(0x7c8c2000), SPH_C32(0x53013aea), SPH_C32(0xc4553b4e), + SPH_C32(0xd9b1bed8), SPH_C32(0xfc875b74), SPH_C32(0xdb190000), + SPH_C32(0x44890000), SPH_C32(0x79740023), SPH_C32(0x28a33800), + SPH_C32(0x879213b5), SPH_C32(0x6d8215f9), SPH_C32(0xf086ca9d), + SPH_C32(0x04e21946) }, + { SPH_C32(0xaef90000), SPH_C32(0xcf450000), SPH_C32(0x30b80012), + SPH_C32(0x69280000), SPH_C32(0x1e634526), SPH_C32(0x0d5e117e), + SPH_C32(0x03512c46), SPH_C32(0xd3ad5d25), SPH_C32(0x84b70000), + SPH_C32(0x76a70000), SPH_C32(0x86330028), SPH_C32(0x79c50000), + SPH_C32(0x23d76cc7), SPH_C32(0x5ce84480), SPH_C32(0xa88d56d0), + SPH_C32(0xaed3d139) }, + { SPH_C32(0xf6ba0000), SPH_C32(0x4f3b0000), SPH_C32(0x488b0013), + SPH_C32(0xaf433800), SPH_C32(0xf95419fa), SPH_C32(0x74f32ea3), + SPH_C32(0xaf22d229), SPH_C32(0xe9e92494), SPH_C32(0x99ed0000), + SPH_C32(0x5dd50000), SPH_C32(0xcebe0028), SPH_C32(0xd6a41800), + SPH_C32(0x061c4202), SPH_C32(0x9491fb50), SPH_C32(0x292f52f9), + SPH_C32(0xb0a6e79f) }, + { SPH_C32(0xb3a30000), SPH_C32(0xe4370000), SPH_C32(0x78350012), + SPH_C32(0xc6491800), SPH_C32(0x3ba86be3), SPH_C32(0xc527aeae), + SPH_C32(0x82f3286f), SPH_C32(0xcdd86b83), SPH_C32(0xc1ae0000), + SPH_C32(0xddab0000), SPH_C32(0xb68d0029), SPH_C32(0x10cf2000), + SPH_C32(0xe12b1ede), SPH_C32(0xed3cc48d), SPH_C32(0x855cac96), + SPH_C32(0x8ae29e2e) }, + { SPH_C32(0xebe00000), SPH_C32(0x64490000), SPH_C32(0x00060013), + SPH_C32(0x00222000), SPH_C32(0xdc9f373f), SPH_C32(0xbc8a9173), + SPH_C32(0x2e80d600), SPH_C32(0xf79c1232), SPH_C32(0xdcf40000), + SPH_C32(0xf6d90000), SPH_C32(0xfe000029), SPH_C32(0xbfae3800), + SPH_C32(0xc4e0301b), SPH_C32(0x25457b5d), SPH_C32(0x04fea8bf), + SPH_C32(0x9497a888) }, + { SPH_C32(0x0c2f0000), SPH_C32(0x69330000), SPH_C32(0xf9fc0006), + SPH_C32(0x828b0000), SPH_C32(0xd28f6b5d), SPH_C32(0x3d46d5e7), + SPH_C32(0x001826bc), SPH_C32(0x48c3a5ad), SPH_C32(0x218c0000), + SPH_C32(0x62810000), SPH_C32(0xc8030036), SPH_C32(0x056b0000), + SPH_C32(0xac496112), SPH_C32(0x2437eebd), SPH_C32(0x5fbc3e08), + SPH_C32(0xa5c8987f) }, + { SPH_C32(0x546c0000), SPH_C32(0xe94d0000), SPH_C32(0x81cf0007), + SPH_C32(0x44e03800), SPH_C32(0x35b83781), SPH_C32(0x44ebea3a), + SPH_C32(0xac6bd8d3), SPH_C32(0x7287dc1c), SPH_C32(0x3cd60000), + SPH_C32(0x49f30000), SPH_C32(0x808e0036), SPH_C32(0xaa0a1800), + SPH_C32(0x89824fd7), SPH_C32(0xec4e516d), SPH_C32(0xde1e3a21), + SPH_C32(0xbbbdaed9) }, + { SPH_C32(0x11750000), SPH_C32(0x42410000), SPH_C32(0xb1710006), + SPH_C32(0x2dea1800), SPH_C32(0xf7444598), SPH_C32(0xf53f6a37), + SPH_C32(0x81ba2295), SPH_C32(0x56b6930b), SPH_C32(0x64950000), + SPH_C32(0xc98d0000), SPH_C32(0xf8bd0037), SPH_C32(0x6c612000), + SPH_C32(0x6eb5130b), SPH_C32(0x95e36eb0), SPH_C32(0x726dc44e), + SPH_C32(0x81f9d768) }, + { SPH_C32(0x49360000), SPH_C32(0xc23f0000), SPH_C32(0xc9420007), + SPH_C32(0xeb812000), SPH_C32(0x10731944), SPH_C32(0x8c9255ea), + SPH_C32(0x2dc9dcfa), SPH_C32(0x6cf2eaba), SPH_C32(0x79cf0000), + SPH_C32(0xe2ff0000), SPH_C32(0xb0300037), SPH_C32(0xc3003800), + SPH_C32(0x4b7e3dce), SPH_C32(0x5d9ad160), SPH_C32(0xf3cfc067), + SPH_C32(0x9f8ce1ce) }, + { SPH_C32(0xa9140000), SPH_C32(0x7d150000), SPH_C32(0xb7cc0018), + SPH_C32(0xfe250000), SPH_C32(0x5d116688), SPH_C32(0x45997fda), + SPH_C32(0xf7294e64), SPH_C32(0x43d8eceb), SPH_C32(0x26610000), + SPH_C32(0xd0d10000), SPH_C32(0x4f77003c), SPH_C32(0x92660000), + SPH_C32(0xef3b42bc), SPH_C32(0x6cf08019), SPH_C32(0xabc45c2a), + SPH_C32(0x35bd29b1) }, + { SPH_C32(0xf1570000), SPH_C32(0xfd6b0000), SPH_C32(0xcfff0019), + SPH_C32(0x384e3800), SPH_C32(0xba263a54), SPH_C32(0x3c344007), + SPH_C32(0x5b5ab00b), SPH_C32(0x799c955a), SPH_C32(0x3b3b0000), + SPH_C32(0xfba30000), SPH_C32(0x07fa003c), SPH_C32(0x3d071800), + SPH_C32(0xcaf06c79), SPH_C32(0xa4893fc9), SPH_C32(0x2a665803), + SPH_C32(0x2bc81f17) }, + { SPH_C32(0xb44e0000), SPH_C32(0x56670000), SPH_C32(0xff410018), + SPH_C32(0x51441800), SPH_C32(0x78da484d), SPH_C32(0x8de0c00a), + SPH_C32(0x768b4a4d), SPH_C32(0x5dadda4d), SPH_C32(0x63780000), + SPH_C32(0x7bdd0000), SPH_C32(0x7fc9003d), SPH_C32(0xfb6c2000), + SPH_C32(0x2dc730a5), SPH_C32(0xdd240014), SPH_C32(0x8615a66c), + SPH_C32(0x118c66a6) }, + { SPH_C32(0xec0d0000), SPH_C32(0xd6190000), SPH_C32(0x87720019), + SPH_C32(0x972f2000), SPH_C32(0x9fed1491), SPH_C32(0xf44dffd7), + SPH_C32(0xdaf8b422), SPH_C32(0x67e9a3fc), SPH_C32(0x7e220000), + SPH_C32(0x50af0000), SPH_C32(0x3744003d), SPH_C32(0x540d3800), + SPH_C32(0x080c1e60), SPH_C32(0x155dbfc4), SPH_C32(0x07b7a245), + SPH_C32(0x0ff95000) }, + { SPH_C32(0x835a0000), SPH_C32(0xc4f70000), SPH_C32(0x01470022), + SPH_C32(0xeec80000), SPH_C32(0x60a54f69), SPH_C32(0x142f2a24), + SPH_C32(0x5cf534f2), SPH_C32(0x3ea660f7), SPH_C32(0x88980000), + SPH_C32(0x1f940000), SPH_C32(0x7fcf002e), SPH_C32(0xfb4e0000), + SPH_C32(0xf158079a), SPH_C32(0x61ae9167), SPH_C32(0xa895706c), + SPH_C32(0xe6107494) }, + { SPH_C32(0xdb190000), SPH_C32(0x44890000), SPH_C32(0x79740023), + SPH_C32(0x28a33800), SPH_C32(0x879213b5), SPH_C32(0x6d8215f9), + SPH_C32(0xf086ca9d), SPH_C32(0x04e21946), SPH_C32(0x95c20000), + SPH_C32(0x34e60000), SPH_C32(0x3742002e), SPH_C32(0x542f1800), + SPH_C32(0xd493295f), SPH_C32(0xa9d72eb7), SPH_C32(0x29377445), + SPH_C32(0xf8654232) }, + { SPH_C32(0x9e000000), SPH_C32(0xef850000), SPH_C32(0x49ca0022), + SPH_C32(0x41a91800), SPH_C32(0x456e61ac), SPH_C32(0xdc5695f4), + SPH_C32(0xdd5730db), SPH_C32(0x20d35651), SPH_C32(0xcd810000), + SPH_C32(0xb4980000), SPH_C32(0x4f71002f), SPH_C32(0x92442000), + SPH_C32(0x33a47583), SPH_C32(0xd07a116a), SPH_C32(0x85448a2a), + SPH_C32(0xc2213b83) }, + { SPH_C32(0xc6430000), SPH_C32(0x6ffb0000), SPH_C32(0x31f90023), + SPH_C32(0x87c22000), SPH_C32(0xa2593d70), SPH_C32(0xa5fbaa29), + SPH_C32(0x7124ceb4), SPH_C32(0x1a972fe0), SPH_C32(0xd0db0000), + SPH_C32(0x9fea0000), SPH_C32(0x07fc002f), SPH_C32(0x3d253800), + SPH_C32(0x166f5b46), SPH_C32(0x1803aeba), SPH_C32(0x04e68e03), + SPH_C32(0xdc540d25) }, + { SPH_C32(0x26610000), SPH_C32(0xd0d10000), SPH_C32(0x4f77003c), + SPH_C32(0x92660000), SPH_C32(0xef3b42bc), SPH_C32(0x6cf08019), + SPH_C32(0xabc45c2a), SPH_C32(0x35bd29b1), SPH_C32(0x8f750000), + SPH_C32(0xadc40000), SPH_C32(0xf8bb0024), SPH_C32(0x6c430000), + SPH_C32(0xb22a2434), SPH_C32(0x2969ffc3), SPH_C32(0x5ced124e), + SPH_C32(0x7665c55a) }, + { SPH_C32(0x7e220000), SPH_C32(0x50af0000), SPH_C32(0x3744003d), + SPH_C32(0x540d3800), SPH_C32(0x080c1e60), SPH_C32(0x155dbfc4), + SPH_C32(0x07b7a245), SPH_C32(0x0ff95000), SPH_C32(0x922f0000), + SPH_C32(0x86b60000), SPH_C32(0xb0360024), SPH_C32(0xc3221800), + SPH_C32(0x97e10af1), SPH_C32(0xe1104013), SPH_C32(0xdd4f1667), + SPH_C32(0x6810f3fc) }, + { SPH_C32(0x3b3b0000), SPH_C32(0xfba30000), SPH_C32(0x07fa003c), + SPH_C32(0x3d071800), SPH_C32(0xcaf06c79), SPH_C32(0xa4893fc9), + SPH_C32(0x2a665803), SPH_C32(0x2bc81f17), SPH_C32(0xca6c0000), + SPH_C32(0x06c80000), SPH_C32(0xc8050025), SPH_C32(0x05492000), + SPH_C32(0x70d6562d), SPH_C32(0x98bd7fce), SPH_C32(0x713ce808), + SPH_C32(0x52548a4d) }, + { SPH_C32(0x63780000), SPH_C32(0x7bdd0000), SPH_C32(0x7fc9003d), + SPH_C32(0xfb6c2000), SPH_C32(0x2dc730a5), SPH_C32(0xdd240014), + SPH_C32(0x8615a66c), SPH_C32(0x118c66a6), SPH_C32(0xd7360000), + SPH_C32(0x2dba0000), SPH_C32(0x80880025), SPH_C32(0xaa283800), + SPH_C32(0x551d78e8), SPH_C32(0x50c4c01e), SPH_C32(0xf09eec21), + SPH_C32(0x4c21bceb) }, + { SPH_C32(0x84b70000), SPH_C32(0x76a70000), SPH_C32(0x86330028), + SPH_C32(0x79c50000), SPH_C32(0x23d76cc7), SPH_C32(0x5ce84480), + SPH_C32(0xa88d56d0), SPH_C32(0xaed3d139), SPH_C32(0x2a4e0000), + SPH_C32(0xb9e20000), SPH_C32(0xb68b003a), SPH_C32(0x10ed0000), + SPH_C32(0x3db429e1), SPH_C32(0x51b655fe), SPH_C32(0xabdc7a96), + SPH_C32(0x7d7e8c1c) }, + { SPH_C32(0xdcf40000), SPH_C32(0xf6d90000), SPH_C32(0xfe000029), + SPH_C32(0xbfae3800), SPH_C32(0xc4e0301b), SPH_C32(0x25457b5d), + SPH_C32(0x04fea8bf), SPH_C32(0x9497a888), SPH_C32(0x37140000), + SPH_C32(0x92900000), SPH_C32(0xfe06003a), SPH_C32(0xbf8c1800), + SPH_C32(0x187f0724), SPH_C32(0x99cfea2e), SPH_C32(0x2a7e7ebf), + SPH_C32(0x630bbaba) }, + { SPH_C32(0x99ed0000), SPH_C32(0x5dd50000), SPH_C32(0xcebe0028), + SPH_C32(0xd6a41800), SPH_C32(0x061c4202), SPH_C32(0x9491fb50), + SPH_C32(0x292f52f9), SPH_C32(0xb0a6e79f), SPH_C32(0x6f570000), + SPH_C32(0x12ee0000), SPH_C32(0x8635003b), SPH_C32(0x79e72000), + SPH_C32(0xff485bf8), SPH_C32(0xe062d5f3), SPH_C32(0x860d80d0), + SPH_C32(0x594fc30b) }, + { SPH_C32(0xc1ae0000), SPH_C32(0xddab0000), SPH_C32(0xb68d0029), + SPH_C32(0x10cf2000), SPH_C32(0xe12b1ede), SPH_C32(0xed3cc48d), + SPH_C32(0x855cac96), SPH_C32(0x8ae29e2e), SPH_C32(0x720d0000), + SPH_C32(0x399c0000), SPH_C32(0xceb8003b), SPH_C32(0xd6863800), + SPH_C32(0xda83753d), SPH_C32(0x281b6a23), SPH_C32(0x07af84f9), + SPH_C32(0x473af5ad) }, + { SPH_C32(0x218c0000), SPH_C32(0x62810000), SPH_C32(0xc8030036), + SPH_C32(0x056b0000), SPH_C32(0xac496112), SPH_C32(0x2437eebd), + SPH_C32(0x5fbc3e08), SPH_C32(0xa5c8987f), SPH_C32(0x2da30000), + SPH_C32(0x0bb20000), SPH_C32(0x31ff0030), SPH_C32(0x87e00000), + SPH_C32(0x7ec60a4f), SPH_C32(0x19713b5a), SPH_C32(0x5fa418b4), + SPH_C32(0xed0b3dd2) }, + { SPH_C32(0x79cf0000), SPH_C32(0xe2ff0000), SPH_C32(0xb0300037), + SPH_C32(0xc3003800), SPH_C32(0x4b7e3dce), SPH_C32(0x5d9ad160), + SPH_C32(0xf3cfc067), SPH_C32(0x9f8ce1ce), SPH_C32(0x30f90000), + SPH_C32(0x20c00000), SPH_C32(0x79720030), SPH_C32(0x28811800), + SPH_C32(0x5b0d248a), SPH_C32(0xd108848a), SPH_C32(0xde061c9d), + SPH_C32(0xf37e0b74) }, + { SPH_C32(0x3cd60000), SPH_C32(0x49f30000), SPH_C32(0x808e0036), + SPH_C32(0xaa0a1800), SPH_C32(0x89824fd7), SPH_C32(0xec4e516d), + SPH_C32(0xde1e3a21), SPH_C32(0xbbbdaed9), SPH_C32(0x68ba0000), + SPH_C32(0xa0be0000), SPH_C32(0x01410031), SPH_C32(0xeeea2000), + SPH_C32(0xbc3a7856), SPH_C32(0xa8a5bb57), SPH_C32(0x7275e2f2), + SPH_C32(0xc93a72c5) }, + { SPH_C32(0x64950000), SPH_C32(0xc98d0000), SPH_C32(0xf8bd0037), + SPH_C32(0x6c612000), SPH_C32(0x6eb5130b), SPH_C32(0x95e36eb0), + SPH_C32(0x726dc44e), SPH_C32(0x81f9d768), SPH_C32(0x75e00000), + SPH_C32(0x8bcc0000), SPH_C32(0x49cc0031), SPH_C32(0x418b3800), + SPH_C32(0x99f15693), SPH_C32(0x60dc0487), SPH_C32(0xf3d7e6db), + SPH_C32(0xd74f4463) }, + { SPH_C32(0x52500000), SPH_C32(0x29540000), SPH_C32(0x6a61004e), + SPH_C32(0xf0ff0000), SPH_C32(0x9a317eec), SPH_C32(0x452341ce), + SPH_C32(0xcf568fe5), SPH_C32(0x5303130f), SPH_C32(0x538d0000), + SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), SPH_C32(0x56ff0000), + SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), SPH_C32(0xa9444018), + SPH_C32(0x7f975691) }, + { SPH_C32(0x0a130000), SPH_C32(0xa92a0000), SPH_C32(0x1252004f), + SPH_C32(0x36943800), SPH_C32(0x7d062230), SPH_C32(0x3c8e7e13), + SPH_C32(0x6325718a), SPH_C32(0x69476abe), SPH_C32(0x4ed70000), + SPH_C32(0x828e0000), SPH_C32(0xd67a0006), SPH_C32(0xf99e1800), + SPH_C32(0x2f2f2e8b), SPH_C32(0x5abc7229), SPH_C32(0x28e64431), + SPH_C32(0x61e26037) }, + { SPH_C32(0x4f0a0000), SPH_C32(0x02260000), SPH_C32(0x22ec004e), + SPH_C32(0x5f9e1800), SPH_C32(0xbffa5029), SPH_C32(0x8d5afe1e), + SPH_C32(0x4ef48bcc), SPH_C32(0x4d7625a9), SPH_C32(0x16940000), + SPH_C32(0x02f00000), SPH_C32(0xae490007), SPH_C32(0x3ff52000), + SPH_C32(0xc8187257), SPH_C32(0x23114df4), SPH_C32(0x8495ba5e), + SPH_C32(0x5ba61986) }, + { SPH_C32(0x17490000), SPH_C32(0x82580000), SPH_C32(0x5adf004f), + SPH_C32(0x99f52000), SPH_C32(0x58cd0cf5), SPH_C32(0xf4f7c1c3), + SPH_C32(0xe28775a3), SPH_C32(0x77325c18), SPH_C32(0x0bce0000), + SPH_C32(0x29820000), SPH_C32(0xe6c40007), SPH_C32(0x90943800), + SPH_C32(0xedd35c92), SPH_C32(0xeb68f224), SPH_C32(0x0537be77), + SPH_C32(0x45d32f20) }, + { SPH_C32(0xf76b0000), SPH_C32(0x3d720000), SPH_C32(0x24510050), + SPH_C32(0x8c510000), SPH_C32(0x15af7339), SPH_C32(0x3dfcebf3), + SPH_C32(0x3867e73d), SPH_C32(0x58185a49), SPH_C32(0x54600000), + SPH_C32(0x1bac0000), SPH_C32(0x1983000c), SPH_C32(0xc1f20000), + SPH_C32(0x499623e0), SPH_C32(0xda02a35d), SPH_C32(0x5d3c223a), + SPH_C32(0xefe2e75f) }, + { SPH_C32(0xaf280000), SPH_C32(0xbd0c0000), SPH_C32(0x5c620051), + SPH_C32(0x4a3a3800), SPH_C32(0xf2982fe5), SPH_C32(0x4451d42e), + SPH_C32(0x94141952), SPH_C32(0x625c23f8), SPH_C32(0x493a0000), + SPH_C32(0x30de0000), SPH_C32(0x510e000c), SPH_C32(0x6e931800), + SPH_C32(0x6c5d0d25), SPH_C32(0x127b1c8d), SPH_C32(0xdc9e2613), + SPH_C32(0xf197d1f9) }, + { SPH_C32(0xea310000), SPH_C32(0x16000000), SPH_C32(0x6cdc0050), + SPH_C32(0x23301800), SPH_C32(0x30645dfc), SPH_C32(0xf5855423), + SPH_C32(0xb9c5e314), SPH_C32(0x466d6cef), SPH_C32(0x11790000), + SPH_C32(0xb0a00000), SPH_C32(0x293d000d), SPH_C32(0xa8f82000), + SPH_C32(0x8b6a51f9), SPH_C32(0x6bd62350), SPH_C32(0x70edd87c), + SPH_C32(0xcbd3a848) }, + { SPH_C32(0xb2720000), SPH_C32(0x967e0000), SPH_C32(0x14ef0051), + SPH_C32(0xe55b2000), SPH_C32(0xd7530120), SPH_C32(0x8c286bfe), + SPH_C32(0x15b61d7b), SPH_C32(0x7c29155e), SPH_C32(0x0c230000), + SPH_C32(0x9bd20000), SPH_C32(0x61b0000d), SPH_C32(0x07993800), + SPH_C32(0xaea17f3c), SPH_C32(0xa3af9c80), SPH_C32(0xf14fdc55), + SPH_C32(0xd5a69eee) }, + { SPH_C32(0x55bd0000), SPH_C32(0x9b040000), SPH_C32(0xed150044), + SPH_C32(0x67f20000), SPH_C32(0xd9435d42), SPH_C32(0x0de42f6a), + SPH_C32(0x3b2eedc7), SPH_C32(0xc376a2c1), SPH_C32(0xf15b0000), + SPH_C32(0x0f8a0000), SPH_C32(0x57b30012), SPH_C32(0xbd5c0000), + SPH_C32(0xc6082e35), SPH_C32(0xa2dd0960), SPH_C32(0xaa0d4ae2), + SPH_C32(0xe4f9ae19) }, + { SPH_C32(0x0dfe0000), SPH_C32(0x1b7a0000), SPH_C32(0x95260045), + SPH_C32(0xa1993800), SPH_C32(0x3e74019e), SPH_C32(0x744910b7), + SPH_C32(0x975d13a8), SPH_C32(0xf932db70), SPH_C32(0xec010000), + SPH_C32(0x24f80000), SPH_C32(0x1f3e0012), SPH_C32(0x123d1800), + SPH_C32(0xe3c300f0), SPH_C32(0x6aa4b6b0), SPH_C32(0x2baf4ecb), + SPH_C32(0xfa8c98bf) }, + { SPH_C32(0x48e70000), SPH_C32(0xb0760000), SPH_C32(0xa5980044), + SPH_C32(0xc8931800), SPH_C32(0xfc887387), SPH_C32(0xc59d90ba), + SPH_C32(0xba8ce9ee), SPH_C32(0xdd039467), SPH_C32(0xb4420000), + SPH_C32(0xa4860000), SPH_C32(0x670d0013), SPH_C32(0xd4562000), + SPH_C32(0x04f45c2c), SPH_C32(0x1309896d), SPH_C32(0x87dcb0a4), + SPH_C32(0xc0c8e10e) }, + { SPH_C32(0x10a40000), SPH_C32(0x30080000), SPH_C32(0xddab0045), + SPH_C32(0x0ef82000), SPH_C32(0x1bbf2f5b), SPH_C32(0xbc30af67), + SPH_C32(0x16ff1781), SPH_C32(0xe747edd6), SPH_C32(0xa9180000), + SPH_C32(0x8ff40000), SPH_C32(0x2f800013), SPH_C32(0x7b373800), + SPH_C32(0x213f72e9), SPH_C32(0xdb7036bd), SPH_C32(0x067eb48d), + SPH_C32(0xdebdd7a8) }, + { SPH_C32(0xf0860000), SPH_C32(0x8f220000), SPH_C32(0xa325005a), + SPH_C32(0x1b5c0000), SPH_C32(0x56dd5097), SPH_C32(0x753b8557), + SPH_C32(0xcc1f851f), SPH_C32(0xc86deb87), SPH_C32(0xf6b60000), + SPH_C32(0xbdda0000), SPH_C32(0xd0c70018), SPH_C32(0x2a510000), + SPH_C32(0x857a0d9b), SPH_C32(0xea1a67c4), SPH_C32(0x5e7528c0), + SPH_C32(0x748c1fd7) }, + { SPH_C32(0xa8c50000), SPH_C32(0x0f5c0000), SPH_C32(0xdb16005b), + SPH_C32(0xdd373800), SPH_C32(0xb1ea0c4b), SPH_C32(0x0c96ba8a), + SPH_C32(0x606c7b70), SPH_C32(0xf2299236), SPH_C32(0xebec0000), + SPH_C32(0x96a80000), SPH_C32(0x984a0018), SPH_C32(0x85301800), + SPH_C32(0xa0b1235e), SPH_C32(0x2263d814), SPH_C32(0xdfd72ce9), + SPH_C32(0x6af92971) }, + { SPH_C32(0xeddc0000), SPH_C32(0xa4500000), SPH_C32(0xeba8005a), + SPH_C32(0xb43d1800), SPH_C32(0x73167e52), SPH_C32(0xbd423a87), + SPH_C32(0x4dbd8136), SPH_C32(0xd618dd21), SPH_C32(0xb3af0000), + SPH_C32(0x16d60000), SPH_C32(0xe0790019), SPH_C32(0x435b2000), + SPH_C32(0x47867f82), SPH_C32(0x5bcee7c9), SPH_C32(0x73a4d286), + SPH_C32(0x50bd50c0) }, + { SPH_C32(0xb59f0000), SPH_C32(0x242e0000), SPH_C32(0x939b005b), + SPH_C32(0x72562000), SPH_C32(0x9421228e), SPH_C32(0xc4ef055a), + SPH_C32(0xe1ce7f59), SPH_C32(0xec5ca490), SPH_C32(0xaef50000), + SPH_C32(0x3da40000), SPH_C32(0xa8f40019), SPH_C32(0xec3a3800), + SPH_C32(0x624d5147), SPH_C32(0x93b75819), SPH_C32(0xf206d6af), + SPH_C32(0x4ec86666) }, + { SPH_C32(0xdac80000), SPH_C32(0x36c00000), SPH_C32(0x15ae0060), + SPH_C32(0x0bb10000), SPH_C32(0x6b697976), SPH_C32(0x248dd0a9), + SPH_C32(0x67c3ff89), SPH_C32(0xb513679b), SPH_C32(0x584f0000), + SPH_C32(0x729f0000), SPH_C32(0xe07f000a), SPH_C32(0x43790000), + SPH_C32(0x9b1948bd), SPH_C32(0xe74476ba), SPH_C32(0x5d240486), + SPH_C32(0xa72142f2) }, + { SPH_C32(0x828b0000), SPH_C32(0xb6be0000), SPH_C32(0x6d9d0061), + SPH_C32(0xcdda3800), SPH_C32(0x8c5e25aa), SPH_C32(0x5d20ef74), + SPH_C32(0xcbb001e6), SPH_C32(0x8f571e2a), SPH_C32(0x45150000), + SPH_C32(0x59ed0000), SPH_C32(0xa8f2000a), SPH_C32(0xec181800), + SPH_C32(0xbed26678), SPH_C32(0x2f3dc96a), SPH_C32(0xdc8600af), + SPH_C32(0xb9547454) }, + { SPH_C32(0xc7920000), SPH_C32(0x1db20000), SPH_C32(0x5d230060), + SPH_C32(0xa4d01800), SPH_C32(0x4ea257b3), SPH_C32(0xecf46f79), + SPH_C32(0xe661fba0), SPH_C32(0xab66513d), SPH_C32(0x1d560000), + SPH_C32(0xd9930000), SPH_C32(0xd0c1000b), SPH_C32(0x2a732000), + SPH_C32(0x59e53aa4), SPH_C32(0x5690f6b7), SPH_C32(0x70f5fec0), + SPH_C32(0x83100de5) }, + { SPH_C32(0x9fd10000), SPH_C32(0x9dcc0000), SPH_C32(0x25100061), + SPH_C32(0x62bb2000), SPH_C32(0xa9950b6f), SPH_C32(0x955950a4), + SPH_C32(0x4a1205cf), SPH_C32(0x9122288c), SPH_C32(0x000c0000), + SPH_C32(0xf2e10000), SPH_C32(0x984c000b), SPH_C32(0x85123800), + SPH_C32(0x7c2e1461), SPH_C32(0x9ee94967), SPH_C32(0xf157fae9), + SPH_C32(0x9d653b43) }, + { SPH_C32(0x7ff30000), SPH_C32(0x22e60000), SPH_C32(0x5b9e007e), + SPH_C32(0x771f0000), SPH_C32(0xe4f774a3), SPH_C32(0x5c527a94), + SPH_C32(0x90f29751), SPH_C32(0xbe082edd), SPH_C32(0x5fa20000), + SPH_C32(0xc0cf0000), SPH_C32(0x670b0000), SPH_C32(0xd4740000), + SPH_C32(0xd86b6b13), SPH_C32(0xaf83181e), SPH_C32(0xa95c66a4), + SPH_C32(0x3754f33c) }, + { SPH_C32(0x27b00000), SPH_C32(0xa2980000), SPH_C32(0x23ad007f), + SPH_C32(0xb1743800), SPH_C32(0x03c0287f), SPH_C32(0x25ff4549), + SPH_C32(0x3c81693e), SPH_C32(0x844c576c), SPH_C32(0x42f80000), + SPH_C32(0xebbd0000), SPH_C32(0x2f860000), SPH_C32(0x7b151800), + SPH_C32(0xfda045d6), SPH_C32(0x67faa7ce), SPH_C32(0x28fe628d), + SPH_C32(0x2921c59a) }, + { SPH_C32(0x62a90000), SPH_C32(0x09940000), SPH_C32(0x1313007e), + SPH_C32(0xd87e1800), SPH_C32(0xc13c5a66), SPH_C32(0x942bc544), + SPH_C32(0x11509378), SPH_C32(0xa07d187b), SPH_C32(0x1abb0000), + SPH_C32(0x6bc30000), SPH_C32(0x57b50001), SPH_C32(0xbd7e2000), + SPH_C32(0x1a97190a), SPH_C32(0x1e579813), SPH_C32(0x848d9ce2), + SPH_C32(0x1365bc2b) }, + { SPH_C32(0x3aea0000), SPH_C32(0x89ea0000), SPH_C32(0x6b20007f), + SPH_C32(0x1e152000), SPH_C32(0x260b06ba), SPH_C32(0xed86fa99), + SPH_C32(0xbd236d17), SPH_C32(0x9a3961ca), SPH_C32(0x07e10000), + SPH_C32(0x40b10000), SPH_C32(0x1f380001), SPH_C32(0x121f3800), + SPH_C32(0x3f5c37cf), SPH_C32(0xd62e27c3), SPH_C32(0x052f98cb), + SPH_C32(0x0d108a8d) }, + { SPH_C32(0xdd250000), SPH_C32(0x84900000), SPH_C32(0x92da006a), + SPH_C32(0x9cbc0000), SPH_C32(0x281b5ad8), SPH_C32(0x6c4abe0d), + SPH_C32(0x93bb9dab), SPH_C32(0x2566d655), SPH_C32(0xfa990000), + SPH_C32(0xd4e90000), SPH_C32(0x293b001e), SPH_C32(0xa8da0000), + SPH_C32(0x57f566c6), SPH_C32(0xd75cb223), SPH_C32(0x5e6d0e7c), + SPH_C32(0x3c4fba7a) }, + { SPH_C32(0x85660000), SPH_C32(0x04ee0000), SPH_C32(0xeae9006b), + SPH_C32(0x5ad73800), SPH_C32(0xcf2c0604), SPH_C32(0x15e781d0), + SPH_C32(0x3fc863c4), SPH_C32(0x1f22afe4), SPH_C32(0xe7c30000), + SPH_C32(0xff9b0000), SPH_C32(0x61b6001e), SPH_C32(0x07bb1800), + SPH_C32(0x723e4803), SPH_C32(0x1f250df3), SPH_C32(0xdfcf0a55), + SPH_C32(0x223a8cdc) }, + { SPH_C32(0xc07f0000), SPH_C32(0xafe20000), SPH_C32(0xda57006a), + SPH_C32(0x33dd1800), SPH_C32(0x0dd0741d), SPH_C32(0xa43301dd), + SPH_C32(0x12199982), SPH_C32(0x3b13e0f3), SPH_C32(0xbf800000), + SPH_C32(0x7fe50000), SPH_C32(0x1985001f), SPH_C32(0xc1d02000), + SPH_C32(0x950914df), SPH_C32(0x6688322e), SPH_C32(0x73bcf43a), + SPH_C32(0x187ef56d) }, + { SPH_C32(0x983c0000), SPH_C32(0x2f9c0000), SPH_C32(0xa264006b), + SPH_C32(0xf5b62000), SPH_C32(0xeae728c1), SPH_C32(0xdd9e3e00), + SPH_C32(0xbe6a67ed), SPH_C32(0x01579942), SPH_C32(0xa2da0000), + SPH_C32(0x54970000), SPH_C32(0x5108001f), SPH_C32(0x6eb13800), + SPH_C32(0xb0c23a1a), SPH_C32(0xaef18dfe), SPH_C32(0xf21ef013), + SPH_C32(0x060bc3cb) }, + { SPH_C32(0x781e0000), SPH_C32(0x90b60000), SPH_C32(0xdcea0074), + SPH_C32(0xe0120000), SPH_C32(0xa785570d), SPH_C32(0x14951430), + SPH_C32(0x648af573), SPH_C32(0x2e7d9f13), SPH_C32(0xfd740000), + SPH_C32(0x66b90000), SPH_C32(0xae4f0014), SPH_C32(0x3fd70000), + SPH_C32(0x14874568), SPH_C32(0x9f9bdc87), SPH_C32(0xaa156c5e), + SPH_C32(0xac3a0bb4) }, + { SPH_C32(0x205d0000), SPH_C32(0x10c80000), SPH_C32(0xa4d90075), + SPH_C32(0x26793800), SPH_C32(0x40b20bd1), SPH_C32(0x6d382bed), + SPH_C32(0xc8f90b1c), SPH_C32(0x1439e6a2), SPH_C32(0xe02e0000), + SPH_C32(0x4dcb0000), SPH_C32(0xe6c20014), SPH_C32(0x90b61800), + SPH_C32(0x314c6bad), SPH_C32(0x57e26357), SPH_C32(0x2bb76877), + SPH_C32(0xb24f3d12) }, + { SPH_C32(0x65440000), SPH_C32(0xbbc40000), SPH_C32(0x94670074), + SPH_C32(0x4f731800), SPH_C32(0x824e79c8), SPH_C32(0xdcecabe0), + SPH_C32(0xe528f15a), SPH_C32(0x3008a9b5), SPH_C32(0xb86d0000), + SPH_C32(0xcdb50000), SPH_C32(0x9ef10015), SPH_C32(0x56dd2000), + SPH_C32(0xd67b3771), SPH_C32(0x2e4f5c8a), SPH_C32(0x87c49618), + SPH_C32(0x880b44a3) }, + { SPH_C32(0x3d070000), SPH_C32(0x3bba0000), SPH_C32(0xec540075), + SPH_C32(0x89182000), SPH_C32(0x65792514), SPH_C32(0xa541943d), + SPH_C32(0x495b0f35), SPH_C32(0x0a4cd004), SPH_C32(0xa5370000), + SPH_C32(0xe6c70000), SPH_C32(0xd67c0015), SPH_C32(0xf9bc3800), + SPH_C32(0xf3b019b4), SPH_C32(0xe636e35a), SPH_C32(0x06669231), + SPH_C32(0x967e7205) }, + { SPH_C32(0x59920000), SPH_C32(0xf2370000), SPH_C32(0x14e90042), + SPH_C32(0xe5790000), SPH_C32(0x0bcc361f), SPH_C32(0x30a2fa8d), + SPH_C32(0x3b36cb7b), SPH_C32(0x8bb5076c), SPH_C32(0xd0d70000), + SPH_C32(0x6d0b0000), SPH_C32(0x9fb00024), SPH_C32(0xb8370000), + SPH_C32(0x6a414f27), SPH_C32(0x86eae7dd), SPH_C32(0xf5b174ea), + SPH_C32(0x41313666) }, + { SPH_C32(0x01d10000), SPH_C32(0x72490000), SPH_C32(0x6cda0043), + SPH_C32(0x23123800), SPH_C32(0xecfb6ac3), SPH_C32(0x490fc550), + SPH_C32(0x97453514), SPH_C32(0xb1f17edd), SPH_C32(0xcd8d0000), + SPH_C32(0x46790000), SPH_C32(0xd73d0024), SPH_C32(0x17561800), + SPH_C32(0x4f8a61e2), SPH_C32(0x4e93580d), SPH_C32(0x741370c3), + SPH_C32(0x5f4400c0) }, + { SPH_C32(0x44c80000), SPH_C32(0xd9450000), SPH_C32(0x5c640042), + SPH_C32(0x4a181800), SPH_C32(0x2e0718da), SPH_C32(0xf8db455d), + SPH_C32(0xba94cf52), SPH_C32(0x95c031ca), SPH_C32(0x95ce0000), + SPH_C32(0xc6070000), SPH_C32(0xaf0e0025), SPH_C32(0xd13d2000), + SPH_C32(0xa8bd3d3e), SPH_C32(0x373e67d0), SPH_C32(0xd8608eac), + SPH_C32(0x65007971) }, + { SPH_C32(0x1c8b0000), SPH_C32(0x593b0000), SPH_C32(0x24570043), + SPH_C32(0x8c732000), SPH_C32(0xc9304406), SPH_C32(0x81767a80), + SPH_C32(0x16e7313d), SPH_C32(0xaf84487b), SPH_C32(0x88940000), + SPH_C32(0xed750000), SPH_C32(0xe7830025), SPH_C32(0x7e5c3800), + SPH_C32(0x8d7613fb), SPH_C32(0xff47d800), SPH_C32(0x59c28a85), + SPH_C32(0x7b754fd7) }, + { SPH_C32(0xfca90000), SPH_C32(0xe6110000), SPH_C32(0x5ad9005c), + SPH_C32(0x99d70000), SPH_C32(0x84523bca), SPH_C32(0x487d50b0), + SPH_C32(0xcc07a3a3), SPH_C32(0x80ae4e2a), SPH_C32(0xd73a0000), + SPH_C32(0xdf5b0000), SPH_C32(0x18c4002e), SPH_C32(0x2f3a0000), + SPH_C32(0x29336c89), SPH_C32(0xce2d8979), SPH_C32(0x01c916c8), + SPH_C32(0xd14487a8) }, + { SPH_C32(0xa4ea0000), SPH_C32(0x666f0000), SPH_C32(0x22ea005d), + SPH_C32(0x5fbc3800), SPH_C32(0x63656716), SPH_C32(0x31d06f6d), + SPH_C32(0x60745dcc), SPH_C32(0xbaea379b), SPH_C32(0xca600000), + SPH_C32(0xf4290000), SPH_C32(0x5049002e), SPH_C32(0x805b1800), + SPH_C32(0x0cf8424c), SPH_C32(0x065436a9), SPH_C32(0x806b12e1), + SPH_C32(0xcf31b10e) }, + { SPH_C32(0xe1f30000), SPH_C32(0xcd630000), SPH_C32(0x1254005c), + SPH_C32(0x36b61800), SPH_C32(0xa199150f), SPH_C32(0x8004ef60), + SPH_C32(0x4da5a78a), SPH_C32(0x9edb788c), SPH_C32(0x92230000), + SPH_C32(0x74570000), SPH_C32(0x287a002f), SPH_C32(0x46302000), + SPH_C32(0xebcf1e90), SPH_C32(0x7ff90974), SPH_C32(0x2c18ec8e), + SPH_C32(0xf575c8bf) }, + { SPH_C32(0xb9b00000), SPH_C32(0x4d1d0000), SPH_C32(0x6a67005d), + SPH_C32(0xf0dd2000), SPH_C32(0x46ae49d3), SPH_C32(0xf9a9d0bd), + SPH_C32(0xe1d659e5), SPH_C32(0xa49f013d), SPH_C32(0x8f790000), + SPH_C32(0x5f250000), SPH_C32(0x60f7002f), SPH_C32(0xe9513800), + SPH_C32(0xce043055), SPH_C32(0xb780b6a4), SPH_C32(0xadbae8a7), + SPH_C32(0xeb00fe19) }, + { SPH_C32(0x5e7f0000), SPH_C32(0x40670000), SPH_C32(0x939d0048), + SPH_C32(0x72740000), SPH_C32(0x48be15b1), SPH_C32(0x78659429), + SPH_C32(0xcf4ea959), SPH_C32(0x1bc0b6a2), SPH_C32(0x72010000), + SPH_C32(0xcb7d0000), SPH_C32(0x56f40030), SPH_C32(0x53940000), + SPH_C32(0xa6ad615c), SPH_C32(0xb6f22344), SPH_C32(0xf6f87e10), + SPH_C32(0xda5fceee) }, + { SPH_C32(0x063c0000), SPH_C32(0xc0190000), SPH_C32(0xebae0049), + SPH_C32(0xb41f3800), SPH_C32(0xaf89496d), SPH_C32(0x01c8abf4), + SPH_C32(0x633d5736), SPH_C32(0x2184cf13), SPH_C32(0x6f5b0000), + SPH_C32(0xe00f0000), SPH_C32(0x1e790030), SPH_C32(0xfcf51800), + SPH_C32(0x83664f99), SPH_C32(0x7e8b9c94), SPH_C32(0x775a7a39), + SPH_C32(0xc42af848) }, + { SPH_C32(0x43250000), SPH_C32(0x6b150000), SPH_C32(0xdb100048), + SPH_C32(0xdd151800), SPH_C32(0x6d753b74), SPH_C32(0xb01c2bf9), + SPH_C32(0x4eecad70), SPH_C32(0x05b58004), SPH_C32(0x37180000), + SPH_C32(0x60710000), SPH_C32(0x664a0031), SPH_C32(0x3a9e2000), + SPH_C32(0x64511345), SPH_C32(0x0726a349), SPH_C32(0xdb298456), + SPH_C32(0xfe6e81f9) }, + { SPH_C32(0x1b660000), SPH_C32(0xeb6b0000), SPH_C32(0xa3230049), + SPH_C32(0x1b7e2000), SPH_C32(0x8a4267a8), SPH_C32(0xc9b11424), + SPH_C32(0xe29f531f), SPH_C32(0x3ff1f9b5), SPH_C32(0x2a420000), + SPH_C32(0x4b030000), SPH_C32(0x2ec70031), SPH_C32(0x95ff3800), + SPH_C32(0x419a3d80), SPH_C32(0xcf5f1c99), SPH_C32(0x5a8b807f), + SPH_C32(0xe01bb75f) }, + { SPH_C32(0xfb440000), SPH_C32(0x54410000), SPH_C32(0xddad0056), + SPH_C32(0x0eda0000), SPH_C32(0xc7201864), SPH_C32(0x00ba3e14), + SPH_C32(0x387fc181), SPH_C32(0x10dbffe4), SPH_C32(0x75ec0000), + SPH_C32(0x792d0000), SPH_C32(0xd180003a), SPH_C32(0xc4990000), + SPH_C32(0xe5df42f2), SPH_C32(0xfe354de0), SPH_C32(0x02801c32), + SPH_C32(0x4a2a7f20) }, + { SPH_C32(0xa3070000), SPH_C32(0xd43f0000), SPH_C32(0xa59e0057), + SPH_C32(0xc8b13800), SPH_C32(0x201744b8), SPH_C32(0x791701c9), + SPH_C32(0x940c3fee), SPH_C32(0x2a9f8655), SPH_C32(0x68b60000), + SPH_C32(0x525f0000), SPH_C32(0x990d003a), SPH_C32(0x6bf81800), + SPH_C32(0xc0146c37), SPH_C32(0x364cf230), SPH_C32(0x8322181b), + SPH_C32(0x545f4986) }, + { SPH_C32(0xe61e0000), SPH_C32(0x7f330000), SPH_C32(0x95200056), + SPH_C32(0xa1bb1800), SPH_C32(0xe2eb36a1), SPH_C32(0xc8c381c4), + SPH_C32(0xb9ddc5a8), SPH_C32(0x0eaec942), SPH_C32(0x30f50000), + SPH_C32(0xd2210000), SPH_C32(0xe13e003b), SPH_C32(0xad932000), + SPH_C32(0x272330eb), SPH_C32(0x4fe1cded), SPH_C32(0x2f51e674), + SPH_C32(0x6e1b3037) }, + { SPH_C32(0xbe5d0000), SPH_C32(0xff4d0000), SPH_C32(0xed130057), + SPH_C32(0x67d02000), SPH_C32(0x05dc6a7d), SPH_C32(0xb16ebe19), + SPH_C32(0x15ae3bc7), SPH_C32(0x34eab0f3), SPH_C32(0x2daf0000), + SPH_C32(0xf9530000), SPH_C32(0xa9b3003b), SPH_C32(0x02f23800), + SPH_C32(0x02e81e2e), SPH_C32(0x8798723d), SPH_C32(0xaef3e25d), + SPH_C32(0x706e0691) }, + { SPH_C32(0xd10a0000), SPH_C32(0xeda30000), SPH_C32(0x6b26006c), + SPH_C32(0x1e370000), SPH_C32(0xfa943185), SPH_C32(0x510c6bea), + SPH_C32(0x93a3bb17), SPH_C32(0x6da573f8), SPH_C32(0xdb150000), + SPH_C32(0xb6680000), SPH_C32(0xe1380028), SPH_C32(0xadb10000), + SPH_C32(0xfbbc07d4), SPH_C32(0xf36b5c9e), SPH_C32(0x01d13074), + SPH_C32(0x99872205) }, + { SPH_C32(0x89490000), SPH_C32(0x6ddd0000), SPH_C32(0x1315006d), + SPH_C32(0xd85c3800), SPH_C32(0x1da36d59), SPH_C32(0x28a15437), + SPH_C32(0x3fd04578), SPH_C32(0x57e10a49), SPH_C32(0xc64f0000), + SPH_C32(0x9d1a0000), SPH_C32(0xa9b50028), SPH_C32(0x02d01800), + SPH_C32(0xde772911), SPH_C32(0x3b12e34e), SPH_C32(0x8073345d), + SPH_C32(0x87f214a3) }, + { SPH_C32(0xcc500000), SPH_C32(0xc6d10000), SPH_C32(0x23ab006c), + SPH_C32(0xb1561800), SPH_C32(0xdf5f1f40), SPH_C32(0x9975d43a), + SPH_C32(0x1201bf3e), SPH_C32(0x73d0455e), SPH_C32(0x9e0c0000), + SPH_C32(0x1d640000), SPH_C32(0xd1860029), SPH_C32(0xc4bb2000), + SPH_C32(0x394075cd), SPH_C32(0x42bfdc93), SPH_C32(0x2c00ca32), + SPH_C32(0xbdb66d12) }, + { SPH_C32(0x94130000), SPH_C32(0x46af0000), SPH_C32(0x5b98006d), + SPH_C32(0x773d2000), SPH_C32(0x3868439c), SPH_C32(0xe0d8ebe7), + SPH_C32(0xbe724151), SPH_C32(0x49943cef), SPH_C32(0x83560000), + SPH_C32(0x36160000), SPH_C32(0x990b0029), SPH_C32(0x6bda3800), + SPH_C32(0x1c8b5b08), SPH_C32(0x8ac66343), SPH_C32(0xada2ce1b), + SPH_C32(0xa3c35bb4) }, + { SPH_C32(0x74310000), SPH_C32(0xf9850000), SPH_C32(0x25160072), + SPH_C32(0x62990000), SPH_C32(0x750a3c50), SPH_C32(0x29d3c1d7), + SPH_C32(0x6492d3cf), SPH_C32(0x66be3abe), SPH_C32(0xdcf80000), + SPH_C32(0x04380000), SPH_C32(0x664c0022), SPH_C32(0x3abc0000), + SPH_C32(0xb8ce247a), SPH_C32(0xbbac323a), SPH_C32(0xf5a95256), + SPH_C32(0x09f293cb) }, + { SPH_C32(0x2c720000), SPH_C32(0x79fb0000), SPH_C32(0x5d250073), + SPH_C32(0xa4f23800), SPH_C32(0x923d608c), SPH_C32(0x507efe0a), + SPH_C32(0xc8e12da0), SPH_C32(0x5cfa430f), SPH_C32(0xc1a20000), + SPH_C32(0x2f4a0000), SPH_C32(0x2ec10022), SPH_C32(0x95dd1800), + SPH_C32(0x9d050abf), SPH_C32(0x73d58dea), SPH_C32(0x740b567f), + SPH_C32(0x1787a56d) }, + { SPH_C32(0x696b0000), SPH_C32(0xd2f70000), SPH_C32(0x6d9b0072), + SPH_C32(0xcdf81800), SPH_C32(0x50c11295), SPH_C32(0xe1aa7e07), + SPH_C32(0xe530d7e6), SPH_C32(0x78cb0c18), SPH_C32(0x99e10000), + SPH_C32(0xaf340000), SPH_C32(0x56f20023), SPH_C32(0x53b62000), + SPH_C32(0x7a325663), SPH_C32(0x0a78b237), SPH_C32(0xd878a810), + SPH_C32(0x2dc3dcdc) }, + { SPH_C32(0x31280000), SPH_C32(0x52890000), SPH_C32(0x15a80073), + SPH_C32(0x0b932000), SPH_C32(0xb7f64e49), SPH_C32(0x980741da), + SPH_C32(0x49432989), SPH_C32(0x428f75a9), SPH_C32(0x84bb0000), + SPH_C32(0x84460000), SPH_C32(0x1e7f0023), SPH_C32(0xfcd73800), + SPH_C32(0x5ff978a6), SPH_C32(0xc2010de7), SPH_C32(0x59daac39), + SPH_C32(0x33b6ea7a) }, + { SPH_C32(0xd6e70000), SPH_C32(0x5ff30000), SPH_C32(0xec520066), + SPH_C32(0x893a0000), SPH_C32(0xb9e6122b), SPH_C32(0x19cb054e), + SPH_C32(0x67dbd935), SPH_C32(0xfdd0c236), SPH_C32(0x79c30000), + SPH_C32(0x101e0000), SPH_C32(0x287c003c), SPH_C32(0x46120000), + SPH_C32(0x375029af), SPH_C32(0xc3739807), SPH_C32(0x02983a8e), + SPH_C32(0x02e9da8d) }, + { SPH_C32(0x8ea40000), SPH_C32(0xdf8d0000), SPH_C32(0x94610067), + SPH_C32(0x4f513800), SPH_C32(0x5ed14ef7), SPH_C32(0x60663a93), + SPH_C32(0xcba8275a), SPH_C32(0xc794bb87), SPH_C32(0x64990000), + SPH_C32(0x3b6c0000), SPH_C32(0x60f1003c), SPH_C32(0xe9731800), + SPH_C32(0x129b076a), SPH_C32(0x0b0a27d7), SPH_C32(0x833a3ea7), + SPH_C32(0x1c9cec2b) }, + { SPH_C32(0xcbbd0000), SPH_C32(0x74810000), SPH_C32(0xa4df0066), + SPH_C32(0x265b1800), SPH_C32(0x9c2d3cee), SPH_C32(0xd1b2ba9e), + SPH_C32(0xe679dd1c), SPH_C32(0xe3a5f490), SPH_C32(0x3cda0000), + SPH_C32(0xbb120000), SPH_C32(0x18c2003d), SPH_C32(0x2f182000), + SPH_C32(0xf5ac5bb6), SPH_C32(0x72a7180a), SPH_C32(0x2f49c0c8), + SPH_C32(0x26d8959a) }, + { SPH_C32(0x93fe0000), SPH_C32(0xf4ff0000), SPH_C32(0xdcec0067), + SPH_C32(0xe0302000), SPH_C32(0x7b1a6032), SPH_C32(0xa81f8543), + SPH_C32(0x4a0a2373), SPH_C32(0xd9e18d21), SPH_C32(0x21800000), + SPH_C32(0x90600000), SPH_C32(0x504f003d), SPH_C32(0x80793800), + SPH_C32(0xd0677573), SPH_C32(0xbadea7da), SPH_C32(0xaeebc4e1), + SPH_C32(0x38ada33c) }, + { SPH_C32(0x73dc0000), SPH_C32(0x4bd50000), SPH_C32(0xa2620078), + SPH_C32(0xf5940000), SPH_C32(0x36781ffe), SPH_C32(0x6114af73), + SPH_C32(0x90eab1ed), SPH_C32(0xf6cb8b70), SPH_C32(0x7e2e0000), + SPH_C32(0xa24e0000), SPH_C32(0xaf080036), SPH_C32(0xd11f0000), + SPH_C32(0x74220a01), SPH_C32(0x8bb4f6a3), SPH_C32(0xf6e058ac), + SPH_C32(0x929c6b43) }, + { SPH_C32(0x2b9f0000), SPH_C32(0xcbab0000), SPH_C32(0xda510079), + SPH_C32(0x33ff3800), SPH_C32(0xd14f4322), SPH_C32(0x18b990ae), + SPH_C32(0x3c994f82), SPH_C32(0xcc8ff2c1), SPH_C32(0x63740000), + SPH_C32(0x893c0000), SPH_C32(0xe7850036), SPH_C32(0x7e7e1800), + SPH_C32(0x51e924c4), SPH_C32(0x43cd4973), SPH_C32(0x77425c85), + SPH_C32(0x8ce95de5) }, + { SPH_C32(0x6e860000), SPH_C32(0x60a70000), SPH_C32(0xeaef0078), + SPH_C32(0x5af51800), SPH_C32(0x13b3313b), SPH_C32(0xa96d10a3), + SPH_C32(0x1148b5c4), SPH_C32(0xe8bebdd6), SPH_C32(0x3b370000), + SPH_C32(0x09420000), SPH_C32(0x9fb60037), SPH_C32(0xb8152000), + SPH_C32(0xb6de7818), SPH_C32(0x3a6076ae), SPH_C32(0xdb31a2ea), + SPH_C32(0xb6ad2454) }, + { SPH_C32(0x36c50000), SPH_C32(0xe0d90000), SPH_C32(0x92dc0079), + SPH_C32(0x9c9e2000), SPH_C32(0xf4846de7), SPH_C32(0xd0c02f7e), + SPH_C32(0xbd3b4bab), SPH_C32(0xd2fac467), SPH_C32(0x266d0000), + SPH_C32(0x22300000), SPH_C32(0xd73b0037), SPH_C32(0x17743800), + SPH_C32(0x931556dd), SPH_C32(0xf219c97e), SPH_C32(0x5a93a6c3), + SPH_C32(0xa8d812f2) }, + { SPH_C32(0x538d0000), SPH_C32(0xa9fc0000), SPH_C32(0x9ef70006), + SPH_C32(0x56ff0000), SPH_C32(0x0ae4004e), SPH_C32(0x92c5cdf9), + SPH_C32(0xa9444018), SPH_C32(0x7f975691), SPH_C32(0x01dd0000), + SPH_C32(0x80a80000), SPH_C32(0xf4960048), SPH_C32(0xa6000000), + SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), SPH_C32(0x6612cffd), + SPH_C32(0x2c94459e) }, + { SPH_C32(0x0bce0000), SPH_C32(0x29820000), SPH_C32(0xe6c40007), + SPH_C32(0x90943800), SPH_C32(0xedd35c92), SPH_C32(0xeb68f224), + SPH_C32(0x0537be77), SPH_C32(0x45d32f20), SPH_C32(0x1c870000), + SPH_C32(0xabda0000), SPH_C32(0xbc1b0048), SPH_C32(0x09611800), + SPH_C32(0xb51e5067), SPH_C32(0x1f9f33e7), SPH_C32(0xe7b0cbd4), + SPH_C32(0x32e17338) }, + { SPH_C32(0x4ed70000), SPH_C32(0x828e0000), SPH_C32(0xd67a0006), + SPH_C32(0xf99e1800), SPH_C32(0x2f2f2e8b), SPH_C32(0x5abc7229), + SPH_C32(0x28e64431), SPH_C32(0x61e26037), SPH_C32(0x44c40000), + SPH_C32(0x2ba40000), SPH_C32(0xc4280049), SPH_C32(0xcf0a2000), + SPH_C32(0x52290cbb), SPH_C32(0x66320c3a), SPH_C32(0x4bc335bb), + SPH_C32(0x08a50a89) }, + { SPH_C32(0x16940000), SPH_C32(0x02f00000), SPH_C32(0xae490007), + SPH_C32(0x3ff52000), SPH_C32(0xc8187257), SPH_C32(0x23114df4), + SPH_C32(0x8495ba5e), SPH_C32(0x5ba61986), SPH_C32(0x599e0000), + SPH_C32(0x00d60000), SPH_C32(0x8ca50049), SPH_C32(0x606b3800), + SPH_C32(0x77e2227e), SPH_C32(0xae4bb3ea), SPH_C32(0xca613192), + SPH_C32(0x16d03c2f) }, + { SPH_C32(0xf6b60000), SPH_C32(0xbdda0000), SPH_C32(0xd0c70018), + SPH_C32(0x2a510000), SPH_C32(0x857a0d9b), SPH_C32(0xea1a67c4), + SPH_C32(0x5e7528c0), SPH_C32(0x748c1fd7), SPH_C32(0x06300000), + SPH_C32(0x32f80000), SPH_C32(0x73e20042), SPH_C32(0x310d0000), + SPH_C32(0xd3a75d0c), SPH_C32(0x9f21e293), SPH_C32(0x926aaddf), + SPH_C32(0xbce1f450) }, + { SPH_C32(0xaef50000), SPH_C32(0x3da40000), SPH_C32(0xa8f40019), + SPH_C32(0xec3a3800), SPH_C32(0x624d5147), SPH_C32(0x93b75819), + SPH_C32(0xf206d6af), SPH_C32(0x4ec86666), SPH_C32(0x1b6a0000), + SPH_C32(0x198a0000), SPH_C32(0x3b6f0042), SPH_C32(0x9e6c1800), + SPH_C32(0xf66c73c9), SPH_C32(0x57585d43), SPH_C32(0x13c8a9f6), + SPH_C32(0xa294c2f6) }, + { SPH_C32(0xebec0000), SPH_C32(0x96a80000), SPH_C32(0x984a0018), + SPH_C32(0x85301800), SPH_C32(0xa0b1235e), SPH_C32(0x2263d814), + SPH_C32(0xdfd72ce9), SPH_C32(0x6af92971), SPH_C32(0x43290000), + SPH_C32(0x99f40000), SPH_C32(0x435c0043), SPH_C32(0x58072000), + SPH_C32(0x115b2f15), SPH_C32(0x2ef5629e), SPH_C32(0xbfbb5799), + SPH_C32(0x98d0bb47) }, + { SPH_C32(0xb3af0000), SPH_C32(0x16d60000), SPH_C32(0xe0790019), + SPH_C32(0x435b2000), SPH_C32(0x47867f82), SPH_C32(0x5bcee7c9), + SPH_C32(0x73a4d286), SPH_C32(0x50bd50c0), SPH_C32(0x5e730000), + SPH_C32(0xb2860000), SPH_C32(0x0bd10043), SPH_C32(0xf7663800), + SPH_C32(0x349001d0), SPH_C32(0xe68cdd4e), SPH_C32(0x3e1953b0), + SPH_C32(0x86a58de1) }, + { SPH_C32(0x54600000), SPH_C32(0x1bac0000), SPH_C32(0x1983000c), + SPH_C32(0xc1f20000), SPH_C32(0x499623e0), SPH_C32(0xda02a35d), + SPH_C32(0x5d3c223a), SPH_C32(0xefe2e75f), SPH_C32(0xa30b0000), + SPH_C32(0x26de0000), SPH_C32(0x3dd2005c), SPH_C32(0x4da30000), + SPH_C32(0x5c3950d9), SPH_C32(0xe7fe48ae), SPH_C32(0x655bc507), + SPH_C32(0xb7fabd16) }, + { SPH_C32(0x0c230000), SPH_C32(0x9bd20000), SPH_C32(0x61b0000d), + SPH_C32(0x07993800), SPH_C32(0xaea17f3c), SPH_C32(0xa3af9c80), + SPH_C32(0xf14fdc55), SPH_C32(0xd5a69eee), SPH_C32(0xbe510000), + SPH_C32(0x0dac0000), SPH_C32(0x755f005c), SPH_C32(0xe2c21800), + SPH_C32(0x79f27e1c), SPH_C32(0x2f87f77e), SPH_C32(0xe4f9c12e), + SPH_C32(0xa98f8bb0) }, + { SPH_C32(0x493a0000), SPH_C32(0x30de0000), SPH_C32(0x510e000c), + SPH_C32(0x6e931800), SPH_C32(0x6c5d0d25), SPH_C32(0x127b1c8d), + SPH_C32(0xdc9e2613), SPH_C32(0xf197d1f9), SPH_C32(0xe6120000), + SPH_C32(0x8dd20000), SPH_C32(0x0d6c005d), SPH_C32(0x24a92000), + SPH_C32(0x9ec522c0), SPH_C32(0x562ac8a3), SPH_C32(0x488a3f41), + SPH_C32(0x93cbf201) }, + { SPH_C32(0x11790000), SPH_C32(0xb0a00000), SPH_C32(0x293d000d), + SPH_C32(0xa8f82000), SPH_C32(0x8b6a51f9), SPH_C32(0x6bd62350), + SPH_C32(0x70edd87c), SPH_C32(0xcbd3a848), SPH_C32(0xfb480000), + SPH_C32(0xa6a00000), SPH_C32(0x45e1005d), SPH_C32(0x8bc83800), + SPH_C32(0xbb0e0c05), SPH_C32(0x9e537773), SPH_C32(0xc9283b68), + SPH_C32(0x8dbec4a7) }, + { SPH_C32(0xf15b0000), SPH_C32(0x0f8a0000), SPH_C32(0x57b30012), + SPH_C32(0xbd5c0000), SPH_C32(0xc6082e35), SPH_C32(0xa2dd0960), + SPH_C32(0xaa0d4ae2), SPH_C32(0xe4f9ae19), SPH_C32(0xa4e60000), + SPH_C32(0x948e0000), SPH_C32(0xbaa60056), SPH_C32(0xdaae0000), + SPH_C32(0x1f4b7377), SPH_C32(0xaf39260a), SPH_C32(0x9123a725), + SPH_C32(0x278f0cd8) }, + { SPH_C32(0xa9180000), SPH_C32(0x8ff40000), SPH_C32(0x2f800013), + SPH_C32(0x7b373800), SPH_C32(0x213f72e9), SPH_C32(0xdb7036bd), + SPH_C32(0x067eb48d), SPH_C32(0xdebdd7a8), SPH_C32(0xb9bc0000), + SPH_C32(0xbffc0000), SPH_C32(0xf22b0056), SPH_C32(0x75cf1800), + SPH_C32(0x3a805db2), SPH_C32(0x674099da), SPH_C32(0x1081a30c), + SPH_C32(0x39fa3a7e) }, + { SPH_C32(0xec010000), SPH_C32(0x24f80000), SPH_C32(0x1f3e0012), + SPH_C32(0x123d1800), SPH_C32(0xe3c300f0), SPH_C32(0x6aa4b6b0), + SPH_C32(0x2baf4ecb), SPH_C32(0xfa8c98bf), SPH_C32(0xe1ff0000), + SPH_C32(0x3f820000), SPH_C32(0x8a180057), SPH_C32(0xb3a42000), + SPH_C32(0xddb7016e), SPH_C32(0x1eeda607), SPH_C32(0xbcf25d63), + SPH_C32(0x03be43cf) }, + { SPH_C32(0xb4420000), SPH_C32(0xa4860000), SPH_C32(0x670d0013), + SPH_C32(0xd4562000), SPH_C32(0x04f45c2c), SPH_C32(0x1309896d), + SPH_C32(0x87dcb0a4), SPH_C32(0xc0c8e10e), SPH_C32(0xfca50000), + SPH_C32(0x14f00000), SPH_C32(0xc2950057), SPH_C32(0x1cc53800), + SPH_C32(0xf87c2fab), SPH_C32(0xd69419d7), SPH_C32(0x3d50594a), + SPH_C32(0x1dcb7569) }, + { SPH_C32(0xdb150000), SPH_C32(0xb6680000), SPH_C32(0xe1380028), + SPH_C32(0xadb10000), SPH_C32(0xfbbc07d4), SPH_C32(0xf36b5c9e), + SPH_C32(0x01d13074), SPH_C32(0x99872205), SPH_C32(0x0a1f0000), + SPH_C32(0x5bcb0000), SPH_C32(0x8a1e0044), SPH_C32(0xb3860000), + SPH_C32(0x01283651), SPH_C32(0xa2673774), SPH_C32(0x92728b63), + SPH_C32(0xf42251fd) }, + { SPH_C32(0x83560000), SPH_C32(0x36160000), SPH_C32(0x990b0029), + SPH_C32(0x6bda3800), SPH_C32(0x1c8b5b08), SPH_C32(0x8ac66343), + SPH_C32(0xada2ce1b), SPH_C32(0xa3c35bb4), SPH_C32(0x17450000), + SPH_C32(0x70b90000), SPH_C32(0xc2930044), SPH_C32(0x1ce71800), + SPH_C32(0x24e31894), SPH_C32(0x6a1e88a4), SPH_C32(0x13d08f4a), + SPH_C32(0xea57675b) }, + { SPH_C32(0xc64f0000), SPH_C32(0x9d1a0000), SPH_C32(0xa9b50028), + SPH_C32(0x02d01800), SPH_C32(0xde772911), SPH_C32(0x3b12e34e), + SPH_C32(0x8073345d), SPH_C32(0x87f214a3), SPH_C32(0x4f060000), + SPH_C32(0xf0c70000), SPH_C32(0xbaa00045), SPH_C32(0xda8c2000), + SPH_C32(0xc3d44448), SPH_C32(0x13b3b779), SPH_C32(0xbfa37125), + SPH_C32(0xd0131eea) }, + { SPH_C32(0x9e0c0000), SPH_C32(0x1d640000), SPH_C32(0xd1860029), + SPH_C32(0xc4bb2000), SPH_C32(0x394075cd), SPH_C32(0x42bfdc93), + SPH_C32(0x2c00ca32), SPH_C32(0xbdb66d12), SPH_C32(0x525c0000), + SPH_C32(0xdbb50000), SPH_C32(0xf22d0045), SPH_C32(0x75ed3800), + SPH_C32(0xe61f6a8d), SPH_C32(0xdbca08a9), SPH_C32(0x3e01750c), + SPH_C32(0xce66284c) }, + { SPH_C32(0x7e2e0000), SPH_C32(0xa24e0000), SPH_C32(0xaf080036), + SPH_C32(0xd11f0000), SPH_C32(0x74220a01), SPH_C32(0x8bb4f6a3), + SPH_C32(0xf6e058ac), SPH_C32(0x929c6b43), SPH_C32(0x0df20000), + SPH_C32(0xe99b0000), SPH_C32(0x0d6a004e), SPH_C32(0x248b0000), + SPH_C32(0x425a15ff), SPH_C32(0xeaa059d0), SPH_C32(0x660ae941), + SPH_C32(0x6457e033) }, + { SPH_C32(0x266d0000), SPH_C32(0x22300000), SPH_C32(0xd73b0037), + SPH_C32(0x17743800), SPH_C32(0x931556dd), SPH_C32(0xf219c97e), + SPH_C32(0x5a93a6c3), SPH_C32(0xa8d812f2), SPH_C32(0x10a80000), + SPH_C32(0xc2e90000), SPH_C32(0x45e7004e), SPH_C32(0x8bea1800), + SPH_C32(0x67913b3a), SPH_C32(0x22d9e600), SPH_C32(0xe7a8ed68), + SPH_C32(0x7a22d695) }, + { SPH_C32(0x63740000), SPH_C32(0x893c0000), SPH_C32(0xe7850036), + SPH_C32(0x7e7e1800), SPH_C32(0x51e924c4), SPH_C32(0x43cd4973), + SPH_C32(0x77425c85), SPH_C32(0x8ce95de5), SPH_C32(0x48eb0000), + SPH_C32(0x42970000), SPH_C32(0x3dd4004f), SPH_C32(0x4d812000), + SPH_C32(0x80a667e6), SPH_C32(0x5b74d9dd), SPH_C32(0x4bdb1307), + SPH_C32(0x4066af24) }, + { SPH_C32(0x3b370000), SPH_C32(0x09420000), SPH_C32(0x9fb60037), + SPH_C32(0xb8152000), SPH_C32(0xb6de7818), SPH_C32(0x3a6076ae), + SPH_C32(0xdb31a2ea), SPH_C32(0xb6ad2454), SPH_C32(0x55b10000), + SPH_C32(0x69e50000), SPH_C32(0x7559004f), SPH_C32(0xe2e03800), + SPH_C32(0xa56d4923), SPH_C32(0x930d660d), SPH_C32(0xca79172e), + SPH_C32(0x5e139982) }, + { SPH_C32(0xdcf80000), SPH_C32(0x04380000), SPH_C32(0x664c0022), + SPH_C32(0x3abc0000), SPH_C32(0xb8ce247a), SPH_C32(0xbbac323a), + SPH_C32(0xf5a95256), SPH_C32(0x09f293cb), SPH_C32(0xa8c90000), + SPH_C32(0xfdbd0000), SPH_C32(0x435a0050), SPH_C32(0x58250000), + SPH_C32(0xcdc4182a), SPH_C32(0x927ff3ed), SPH_C32(0x913b8199), + SPH_C32(0x6f4ca975) }, + { SPH_C32(0x84bb0000), SPH_C32(0x84460000), SPH_C32(0x1e7f0023), + SPH_C32(0xfcd73800), SPH_C32(0x5ff978a6), SPH_C32(0xc2010de7), + SPH_C32(0x59daac39), SPH_C32(0x33b6ea7a), SPH_C32(0xb5930000), + SPH_C32(0xd6cf0000), SPH_C32(0x0bd70050), SPH_C32(0xf7441800), + SPH_C32(0xe80f36ef), SPH_C32(0x5a064c3d), SPH_C32(0x109985b0), + SPH_C32(0x71399fd3) }, + { SPH_C32(0xc1a20000), SPH_C32(0x2f4a0000), SPH_C32(0x2ec10022), + SPH_C32(0x95dd1800), SPH_C32(0x9d050abf), SPH_C32(0x73d58dea), + SPH_C32(0x740b567f), SPH_C32(0x1787a56d), SPH_C32(0xedd00000), + SPH_C32(0x56b10000), SPH_C32(0x73e40051), SPH_C32(0x312f2000), + SPH_C32(0x0f386a33), SPH_C32(0x23ab73e0), SPH_C32(0xbcea7bdf), + SPH_C32(0x4b7de662) }, + { SPH_C32(0x99e10000), SPH_C32(0xaf340000), SPH_C32(0x56f20023), + SPH_C32(0x53b62000), SPH_C32(0x7a325663), SPH_C32(0x0a78b237), + SPH_C32(0xd878a810), SPH_C32(0x2dc3dcdc), SPH_C32(0xf08a0000), + SPH_C32(0x7dc30000), SPH_C32(0x3b690051), SPH_C32(0x9e4e3800), + SPH_C32(0x2af344f6), SPH_C32(0xebd2cc30), SPH_C32(0x3d487ff6), + SPH_C32(0x5508d0c4) }, + { SPH_C32(0x79c30000), SPH_C32(0x101e0000), SPH_C32(0x287c003c), + SPH_C32(0x46120000), SPH_C32(0x375029af), SPH_C32(0xc3739807), + SPH_C32(0x02983a8e), SPH_C32(0x02e9da8d), SPH_C32(0xaf240000), + SPH_C32(0x4fed0000), SPH_C32(0xc42e005a), SPH_C32(0xcf280000), + SPH_C32(0x8eb63b84), SPH_C32(0xdab89d49), SPH_C32(0x6543e3bb), + SPH_C32(0xff3918bb) }, + { SPH_C32(0x21800000), SPH_C32(0x90600000), SPH_C32(0x504f003d), + SPH_C32(0x80793800), SPH_C32(0xd0677573), SPH_C32(0xbadea7da), + SPH_C32(0xaeebc4e1), SPH_C32(0x38ada33c), SPH_C32(0xb27e0000), + SPH_C32(0x649f0000), SPH_C32(0x8ca3005a), SPH_C32(0x60491800), + SPH_C32(0xab7d1541), SPH_C32(0x12c12299), SPH_C32(0xe4e1e792), + SPH_C32(0xe14c2e1d) }, + { SPH_C32(0x64990000), SPH_C32(0x3b6c0000), SPH_C32(0x60f1003c), + SPH_C32(0xe9731800), SPH_C32(0x129b076a), SPH_C32(0x0b0a27d7), + SPH_C32(0x833a3ea7), SPH_C32(0x1c9cec2b), SPH_C32(0xea3d0000), + SPH_C32(0xe4e10000), SPH_C32(0xf490005b), SPH_C32(0xa6222000), + SPH_C32(0x4c4a499d), SPH_C32(0x6b6c1d44), SPH_C32(0x489219fd), + SPH_C32(0xdb0857ac) }, + { SPH_C32(0x3cda0000), SPH_C32(0xbb120000), SPH_C32(0x18c2003d), + SPH_C32(0x2f182000), SPH_C32(0xf5ac5bb6), SPH_C32(0x72a7180a), + SPH_C32(0x2f49c0c8), SPH_C32(0x26d8959a), SPH_C32(0xf7670000), + SPH_C32(0xcf930000), SPH_C32(0xbc1d005b), SPH_C32(0x09433800), + SPH_C32(0x69816758), SPH_C32(0xa315a294), SPH_C32(0xc9301dd4), + SPH_C32(0xc57d610a) }, + { SPH_C32(0x584f0000), SPH_C32(0x729f0000), SPH_C32(0xe07f000a), + SPH_C32(0x43790000), SPH_C32(0x9b1948bd), SPH_C32(0xe74476ba), + SPH_C32(0x5d240486), SPH_C32(0xa72142f2), SPH_C32(0x82870000), + SPH_C32(0x445f0000), SPH_C32(0xf5d1006a), SPH_C32(0x48c80000), + SPH_C32(0xf07031cb), SPH_C32(0xc3c9a613), SPH_C32(0x3ae7fb0f), + SPH_C32(0x12322569) }, + { SPH_C32(0x000c0000), SPH_C32(0xf2e10000), SPH_C32(0x984c000b), + SPH_C32(0x85123800), SPH_C32(0x7c2e1461), SPH_C32(0x9ee94967), + SPH_C32(0xf157fae9), SPH_C32(0x9d653b43), SPH_C32(0x9fdd0000), + SPH_C32(0x6f2d0000), SPH_C32(0xbd5c006a), SPH_C32(0xe7a91800), + SPH_C32(0xd5bb1f0e), SPH_C32(0x0bb019c3), SPH_C32(0xbb45ff26), + SPH_C32(0x0c4713cf) }, + { SPH_C32(0x45150000), SPH_C32(0x59ed0000), SPH_C32(0xa8f2000a), + SPH_C32(0xec181800), SPH_C32(0xbed26678), SPH_C32(0x2f3dc96a), + SPH_C32(0xdc8600af), SPH_C32(0xb9547454), SPH_C32(0xc79e0000), + SPH_C32(0xef530000), SPH_C32(0xc56f006b), SPH_C32(0x21c22000), + SPH_C32(0x328c43d2), SPH_C32(0x721d261e), SPH_C32(0x17360149), + SPH_C32(0x36036a7e) }, + { SPH_C32(0x1d560000), SPH_C32(0xd9930000), SPH_C32(0xd0c1000b), + SPH_C32(0x2a732000), SPH_C32(0x59e53aa4), SPH_C32(0x5690f6b7), + SPH_C32(0x70f5fec0), SPH_C32(0x83100de5), SPH_C32(0xdac40000), + SPH_C32(0xc4210000), SPH_C32(0x8de2006b), SPH_C32(0x8ea33800), + SPH_C32(0x17476d17), SPH_C32(0xba6499ce), SPH_C32(0x96940560), + SPH_C32(0x28765cd8) }, + { SPH_C32(0xfd740000), SPH_C32(0x66b90000), SPH_C32(0xae4f0014), + SPH_C32(0x3fd70000), SPH_C32(0x14874568), SPH_C32(0x9f9bdc87), + SPH_C32(0xaa156c5e), SPH_C32(0xac3a0bb4), SPH_C32(0x856a0000), + SPH_C32(0xf60f0000), SPH_C32(0x72a50060), SPH_C32(0xdfc50000), + SPH_C32(0xb3021265), SPH_C32(0x8b0ec8b7), SPH_C32(0xce9f992d), + SPH_C32(0x824794a7) }, + { SPH_C32(0xa5370000), SPH_C32(0xe6c70000), SPH_C32(0xd67c0015), + SPH_C32(0xf9bc3800), SPH_C32(0xf3b019b4), SPH_C32(0xe636e35a), + SPH_C32(0x06669231), SPH_C32(0x967e7205), SPH_C32(0x98300000), + SPH_C32(0xdd7d0000), SPH_C32(0x3a280060), SPH_C32(0x70a41800), + SPH_C32(0x96c93ca0), SPH_C32(0x43777767), SPH_C32(0x4f3d9d04), + SPH_C32(0x9c32a201) }, + { SPH_C32(0xe02e0000), SPH_C32(0x4dcb0000), SPH_C32(0xe6c20014), + SPH_C32(0x90b61800), SPH_C32(0x314c6bad), SPH_C32(0x57e26357), + SPH_C32(0x2bb76877), SPH_C32(0xb24f3d12), SPH_C32(0xc0730000), + SPH_C32(0x5d030000), SPH_C32(0x421b0061), SPH_C32(0xb6cf2000), + SPH_C32(0x71fe607c), SPH_C32(0x3ada48ba), SPH_C32(0xe34e636b), + SPH_C32(0xa676dbb0) }, + { SPH_C32(0xb86d0000), SPH_C32(0xcdb50000), SPH_C32(0x9ef10015), + SPH_C32(0x56dd2000), SPH_C32(0xd67b3771), SPH_C32(0x2e4f5c8a), + SPH_C32(0x87c49618), SPH_C32(0x880b44a3), SPH_C32(0xdd290000), + SPH_C32(0x76710000), SPH_C32(0x0a960061), SPH_C32(0x19ae3800), + SPH_C32(0x54354eb9), SPH_C32(0xf2a3f76a), SPH_C32(0x62ec6742), + SPH_C32(0xb803ed16) }, + { SPH_C32(0x5fa20000), SPH_C32(0xc0cf0000), SPH_C32(0x670b0000), + SPH_C32(0xd4740000), SPH_C32(0xd86b6b13), SPH_C32(0xaf83181e), + SPH_C32(0xa95c66a4), SPH_C32(0x3754f33c), SPH_C32(0x20510000), + SPH_C32(0xe2290000), SPH_C32(0x3c95007e), SPH_C32(0xa36b0000), + SPH_C32(0x3c9c1fb0), SPH_C32(0xf3d1628a), SPH_C32(0x39aef1f5), + SPH_C32(0x895cdde1) }, + { SPH_C32(0x07e10000), SPH_C32(0x40b10000), SPH_C32(0x1f380001), + SPH_C32(0x121f3800), SPH_C32(0x3f5c37cf), SPH_C32(0xd62e27c3), + SPH_C32(0x052f98cb), SPH_C32(0x0d108a8d), SPH_C32(0x3d0b0000), + SPH_C32(0xc95b0000), SPH_C32(0x7418007e), SPH_C32(0x0c0a1800), + SPH_C32(0x19573175), SPH_C32(0x3ba8dd5a), SPH_C32(0xb80cf5dc), + SPH_C32(0x9729eb47) }, + { SPH_C32(0x42f80000), SPH_C32(0xebbd0000), SPH_C32(0x2f860000), + SPH_C32(0x7b151800), SPH_C32(0xfda045d6), SPH_C32(0x67faa7ce), + SPH_C32(0x28fe628d), SPH_C32(0x2921c59a), SPH_C32(0x65480000), + SPH_C32(0x49250000), SPH_C32(0x0c2b007f), SPH_C32(0xca612000), + SPH_C32(0xfe606da9), SPH_C32(0x4205e287), SPH_C32(0x147f0bb3), + SPH_C32(0xad6d92f6) }, + { SPH_C32(0x1abb0000), SPH_C32(0x6bc30000), SPH_C32(0x57b50001), + SPH_C32(0xbd7e2000), SPH_C32(0x1a97190a), SPH_C32(0x1e579813), + SPH_C32(0x848d9ce2), SPH_C32(0x1365bc2b), SPH_C32(0x78120000), + SPH_C32(0x62570000), SPH_C32(0x44a6007f), SPH_C32(0x65003800), + SPH_C32(0xdbab436c), SPH_C32(0x8a7c5d57), SPH_C32(0x95dd0f9a), + SPH_C32(0xb318a450) }, + { SPH_C32(0xfa990000), SPH_C32(0xd4e90000), SPH_C32(0x293b001e), + SPH_C32(0xa8da0000), SPH_C32(0x57f566c6), SPH_C32(0xd75cb223), + SPH_C32(0x5e6d0e7c), SPH_C32(0x3c4fba7a), SPH_C32(0x27bc0000), + SPH_C32(0x50790000), SPH_C32(0xbbe10074), SPH_C32(0x34660000), + SPH_C32(0x7fee3c1e), SPH_C32(0xbb160c2e), SPH_C32(0xcdd693d7), + SPH_C32(0x19296c2f) }, + { SPH_C32(0xa2da0000), SPH_C32(0x54970000), SPH_C32(0x5108001f), + SPH_C32(0x6eb13800), SPH_C32(0xb0c23a1a), SPH_C32(0xaef18dfe), + SPH_C32(0xf21ef013), SPH_C32(0x060bc3cb), SPH_C32(0x3ae60000), + SPH_C32(0x7b0b0000), SPH_C32(0xf36c0074), SPH_C32(0x9b071800), + SPH_C32(0x5a2512db), SPH_C32(0x736fb3fe), SPH_C32(0x4c7497fe), + SPH_C32(0x075c5a89) }, + { SPH_C32(0xe7c30000), SPH_C32(0xff9b0000), SPH_C32(0x61b6001e), + SPH_C32(0x07bb1800), SPH_C32(0x723e4803), SPH_C32(0x1f250df3), + SPH_C32(0xdfcf0a55), SPH_C32(0x223a8cdc), SPH_C32(0x62a50000), + SPH_C32(0xfb750000), SPH_C32(0x8b5f0075), SPH_C32(0x5d6c2000), + SPH_C32(0xbd124e07), SPH_C32(0x0ac28c23), SPH_C32(0xe0076991), + SPH_C32(0x3d182338) }, + { SPH_C32(0xbf800000), SPH_C32(0x7fe50000), SPH_C32(0x1985001f), + SPH_C32(0xc1d02000), SPH_C32(0x950914df), SPH_C32(0x6688322e), + SPH_C32(0x73bcf43a), SPH_C32(0x187ef56d), SPH_C32(0x7fff0000), + SPH_C32(0xd0070000), SPH_C32(0xc3d20075), SPH_C32(0xf20d3800), + SPH_C32(0x98d960c2), SPH_C32(0xc2bb33f3), SPH_C32(0x61a56db8), + SPH_C32(0x236d159e) }, + { SPH_C32(0xd0d70000), SPH_C32(0x6d0b0000), SPH_C32(0x9fb00024), + SPH_C32(0xb8370000), SPH_C32(0x6a414f27), SPH_C32(0x86eae7dd), + SPH_C32(0xf5b174ea), SPH_C32(0x41313666), SPH_C32(0x89450000), + SPH_C32(0x9f3c0000), SPH_C32(0x8b590066), SPH_C32(0x5d4e0000), + SPH_C32(0x618d7938), SPH_C32(0xb6481d50), SPH_C32(0xce87bf91), + SPH_C32(0xca84310a) }, + { SPH_C32(0x88940000), SPH_C32(0xed750000), SPH_C32(0xe7830025), + SPH_C32(0x7e5c3800), SPH_C32(0x8d7613fb), SPH_C32(0xff47d800), + SPH_C32(0x59c28a85), SPH_C32(0x7b754fd7), SPH_C32(0x941f0000), + SPH_C32(0xb44e0000), SPH_C32(0xc3d40066), SPH_C32(0xf22f1800), + SPH_C32(0x444657fd), SPH_C32(0x7e31a280), SPH_C32(0x4f25bbb8), + SPH_C32(0xd4f107ac) }, + { SPH_C32(0xcd8d0000), SPH_C32(0x46790000), SPH_C32(0xd73d0024), + SPH_C32(0x17561800), SPH_C32(0x4f8a61e2), SPH_C32(0x4e93580d), + SPH_C32(0x741370c3), SPH_C32(0x5f4400c0), SPH_C32(0xcc5c0000), + SPH_C32(0x34300000), SPH_C32(0xbbe70067), SPH_C32(0x34442000), + SPH_C32(0xa3710b21), SPH_C32(0x079c9d5d), SPH_C32(0xe35645d7), + SPH_C32(0xeeb57e1d) }, + { SPH_C32(0x95ce0000), SPH_C32(0xc6070000), SPH_C32(0xaf0e0025), + SPH_C32(0xd13d2000), SPH_C32(0xa8bd3d3e), SPH_C32(0x373e67d0), + SPH_C32(0xd8608eac), SPH_C32(0x65007971), SPH_C32(0xd1060000), + SPH_C32(0x1f420000), SPH_C32(0xf36a0067), SPH_C32(0x9b253800), + SPH_C32(0x86ba25e4), SPH_C32(0xcfe5228d), SPH_C32(0x62f441fe), + SPH_C32(0xf0c048bb) }, + { SPH_C32(0x75ec0000), SPH_C32(0x792d0000), SPH_C32(0xd180003a), + SPH_C32(0xc4990000), SPH_C32(0xe5df42f2), SPH_C32(0xfe354de0), + SPH_C32(0x02801c32), SPH_C32(0x4a2a7f20), SPH_C32(0x8ea80000), + SPH_C32(0x2d6c0000), SPH_C32(0x0c2d006c), SPH_C32(0xca430000), + SPH_C32(0x22ff5a96), SPH_C32(0xfe8f73f4), SPH_C32(0x3affddb3), + SPH_C32(0x5af180c4) }, + { SPH_C32(0x2daf0000), SPH_C32(0xf9530000), SPH_C32(0xa9b3003b), + SPH_C32(0x02f23800), SPH_C32(0x02e81e2e), SPH_C32(0x8798723d), + SPH_C32(0xaef3e25d), SPH_C32(0x706e0691), SPH_C32(0x93f20000), + SPH_C32(0x061e0000), SPH_C32(0x44a0006c), SPH_C32(0x65221800), + SPH_C32(0x07347453), SPH_C32(0x36f6cc24), SPH_C32(0xbb5dd99a), + SPH_C32(0x4484b662) }, + { SPH_C32(0x68b60000), SPH_C32(0x525f0000), SPH_C32(0x990d003a), + SPH_C32(0x6bf81800), SPH_C32(0xc0146c37), SPH_C32(0x364cf230), + SPH_C32(0x8322181b), SPH_C32(0x545f4986), SPH_C32(0xcbb10000), + SPH_C32(0x86600000), SPH_C32(0x3c93006d), SPH_C32(0xa3492000), + SPH_C32(0xe003288f), SPH_C32(0x4f5bf3f9), SPH_C32(0x172e27f5), + SPH_C32(0x7ec0cfd3) }, + { SPH_C32(0x30f50000), SPH_C32(0xd2210000), SPH_C32(0xe13e003b), + SPH_C32(0xad932000), SPH_C32(0x272330eb), SPH_C32(0x4fe1cded), + SPH_C32(0x2f51e674), SPH_C32(0x6e1b3037), SPH_C32(0xd6eb0000), + SPH_C32(0xad120000), SPH_C32(0x741e006d), SPH_C32(0x0c283800), + SPH_C32(0xc5c8064a), SPH_C32(0x87224c29), SPH_C32(0x968c23dc), + SPH_C32(0x60b5f975) }, + { SPH_C32(0xd73a0000), SPH_C32(0xdf5b0000), SPH_C32(0x18c4002e), + SPH_C32(0x2f3a0000), SPH_C32(0x29336c89), SPH_C32(0xce2d8979), + SPH_C32(0x01c916c8), SPH_C32(0xd14487a8), SPH_C32(0x2b930000), + SPH_C32(0x394a0000), SPH_C32(0x421d0072), SPH_C32(0xb6ed0000), + SPH_C32(0xad615743), SPH_C32(0x8650d9c9), SPH_C32(0xcdceb56b), + SPH_C32(0x51eac982) }, + { SPH_C32(0x8f790000), SPH_C32(0x5f250000), SPH_C32(0x60f7002f), + SPH_C32(0xe9513800), SPH_C32(0xce043055), SPH_C32(0xb780b6a4), + SPH_C32(0xadbae8a7), SPH_C32(0xeb00fe19), SPH_C32(0x36c90000), + SPH_C32(0x12380000), SPH_C32(0x0a900072), SPH_C32(0x198c1800), + SPH_C32(0x88aa7986), SPH_C32(0x4e296619), SPH_C32(0x4c6cb142), + SPH_C32(0x4f9fff24) }, + { SPH_C32(0xca600000), SPH_C32(0xf4290000), SPH_C32(0x5049002e), + SPH_C32(0x805b1800), SPH_C32(0x0cf8424c), SPH_C32(0x065436a9), + SPH_C32(0x806b12e1), SPH_C32(0xcf31b10e), SPH_C32(0x6e8a0000), + SPH_C32(0x92460000), SPH_C32(0x72a30073), SPH_C32(0xdfe72000), + SPH_C32(0x6f9d255a), SPH_C32(0x378459c4), SPH_C32(0xe01f4f2d), + SPH_C32(0x75db8695) }, + { SPH_C32(0x92230000), SPH_C32(0x74570000), SPH_C32(0x287a002f), + SPH_C32(0x46302000), SPH_C32(0xebcf1e90), SPH_C32(0x7ff90974), + SPH_C32(0x2c18ec8e), SPH_C32(0xf575c8bf), SPH_C32(0x73d00000), + SPH_C32(0xb9340000), SPH_C32(0x3a2e0073), SPH_C32(0x70863800), + SPH_C32(0x4a560b9f), SPH_C32(0xfffde614), SPH_C32(0x61bd4b04), + SPH_C32(0x6baeb033) }, + { SPH_C32(0x72010000), SPH_C32(0xcb7d0000), SPH_C32(0x56f40030), + SPH_C32(0x53940000), SPH_C32(0xa6ad615c), SPH_C32(0xb6f22344), + SPH_C32(0xf6f87e10), SPH_C32(0xda5fceee), SPH_C32(0x2c7e0000), + SPH_C32(0x8b1a0000), SPH_C32(0xc5690078), SPH_C32(0x21e00000), + SPH_C32(0xee1374ed), SPH_C32(0xce97b76d), SPH_C32(0x39b6d749), + SPH_C32(0xc19f784c) }, + { SPH_C32(0x2a420000), SPH_C32(0x4b030000), SPH_C32(0x2ec70031), + SPH_C32(0x95ff3800), SPH_C32(0x419a3d80), SPH_C32(0xcf5f1c99), + SPH_C32(0x5a8b807f), SPH_C32(0xe01bb75f), SPH_C32(0x31240000), + SPH_C32(0xa0680000), SPH_C32(0x8de40078), SPH_C32(0x8e811800), + SPH_C32(0xcbd85a28), SPH_C32(0x06ee08bd), SPH_C32(0xb814d360), + SPH_C32(0xdfea4eea) }, + { SPH_C32(0x6f5b0000), SPH_C32(0xe00f0000), SPH_C32(0x1e790030), + SPH_C32(0xfcf51800), SPH_C32(0x83664f99), SPH_C32(0x7e8b9c94), + SPH_C32(0x775a7a39), SPH_C32(0xc42af848), SPH_C32(0x69670000), + SPH_C32(0x20160000), SPH_C32(0xf5d70079), SPH_C32(0x48ea2000), + SPH_C32(0x2cef06f4), SPH_C32(0x7f433760), SPH_C32(0x14672d0f), + SPH_C32(0xe5ae375b) }, + { SPH_C32(0x37180000), SPH_C32(0x60710000), SPH_C32(0x664a0031), + SPH_C32(0x3a9e2000), SPH_C32(0x64511345), SPH_C32(0x0726a349), + SPH_C32(0xdb298456), SPH_C32(0xfe6e81f9), SPH_C32(0x743d0000), + SPH_C32(0x0b640000), SPH_C32(0xbd5a0079), SPH_C32(0xe78b3800), + SPH_C32(0x09242831), SPH_C32(0xb73a88b0), SPH_C32(0x95c52926), + SPH_C32(0xfbdb01fd) }, + { SPH_C32(0x01dd0000), SPH_C32(0x80a80000), SPH_C32(0xf4960048), + SPH_C32(0xa6000000), SPH_C32(0x90d57ea2), SPH_C32(0xd7e68c37), + SPH_C32(0x6612cffd), SPH_C32(0x2c94459e), SPH_C32(0x52500000), + SPH_C32(0x29540000), SPH_C32(0x6a61004e), SPH_C32(0xf0ff0000), + SPH_C32(0x9a317eec), SPH_C32(0x452341ce), SPH_C32(0xcf568fe5), + SPH_C32(0x5303130f) }, + { SPH_C32(0x599e0000), SPH_C32(0x00d60000), SPH_C32(0x8ca50049), + SPH_C32(0x606b3800), SPH_C32(0x77e2227e), SPH_C32(0xae4bb3ea), + SPH_C32(0xca613192), SPH_C32(0x16d03c2f), SPH_C32(0x4f0a0000), + SPH_C32(0x02260000), SPH_C32(0x22ec004e), SPH_C32(0x5f9e1800), + SPH_C32(0xbffa5029), SPH_C32(0x8d5afe1e), SPH_C32(0x4ef48bcc), + SPH_C32(0x4d7625a9) }, + { SPH_C32(0x1c870000), SPH_C32(0xabda0000), SPH_C32(0xbc1b0048), + SPH_C32(0x09611800), SPH_C32(0xb51e5067), SPH_C32(0x1f9f33e7), + SPH_C32(0xe7b0cbd4), SPH_C32(0x32e17338), SPH_C32(0x17490000), + SPH_C32(0x82580000), SPH_C32(0x5adf004f), SPH_C32(0x99f52000), + SPH_C32(0x58cd0cf5), SPH_C32(0xf4f7c1c3), SPH_C32(0xe28775a3), + SPH_C32(0x77325c18) }, + { SPH_C32(0x44c40000), SPH_C32(0x2ba40000), SPH_C32(0xc4280049), + SPH_C32(0xcf0a2000), SPH_C32(0x52290cbb), SPH_C32(0x66320c3a), + SPH_C32(0x4bc335bb), SPH_C32(0x08a50a89), SPH_C32(0x0a130000), + SPH_C32(0xa92a0000), SPH_C32(0x1252004f), SPH_C32(0x36943800), + SPH_C32(0x7d062230), SPH_C32(0x3c8e7e13), SPH_C32(0x6325718a), + SPH_C32(0x69476abe) }, + { SPH_C32(0xa4e60000), SPH_C32(0x948e0000), SPH_C32(0xbaa60056), + SPH_C32(0xdaae0000), SPH_C32(0x1f4b7377), SPH_C32(0xaf39260a), + SPH_C32(0x9123a725), SPH_C32(0x278f0cd8), SPH_C32(0x55bd0000), + SPH_C32(0x9b040000), SPH_C32(0xed150044), SPH_C32(0x67f20000), + SPH_C32(0xd9435d42), SPH_C32(0x0de42f6a), SPH_C32(0x3b2eedc7), + SPH_C32(0xc376a2c1) }, + { SPH_C32(0xfca50000), SPH_C32(0x14f00000), SPH_C32(0xc2950057), + SPH_C32(0x1cc53800), SPH_C32(0xf87c2fab), SPH_C32(0xd69419d7), + SPH_C32(0x3d50594a), SPH_C32(0x1dcb7569), SPH_C32(0x48e70000), + SPH_C32(0xb0760000), SPH_C32(0xa5980044), SPH_C32(0xc8931800), + SPH_C32(0xfc887387), SPH_C32(0xc59d90ba), SPH_C32(0xba8ce9ee), + SPH_C32(0xdd039467) }, + { SPH_C32(0xb9bc0000), SPH_C32(0xbffc0000), SPH_C32(0xf22b0056), + SPH_C32(0x75cf1800), SPH_C32(0x3a805db2), SPH_C32(0x674099da), + SPH_C32(0x1081a30c), SPH_C32(0x39fa3a7e), SPH_C32(0x10a40000), + SPH_C32(0x30080000), SPH_C32(0xddab0045), SPH_C32(0x0ef82000), + SPH_C32(0x1bbf2f5b), SPH_C32(0xbc30af67), SPH_C32(0x16ff1781), + SPH_C32(0xe747edd6) }, + { SPH_C32(0xe1ff0000), SPH_C32(0x3f820000), SPH_C32(0x8a180057), + SPH_C32(0xb3a42000), SPH_C32(0xddb7016e), SPH_C32(0x1eeda607), + SPH_C32(0xbcf25d63), SPH_C32(0x03be43cf), SPH_C32(0x0dfe0000), + SPH_C32(0x1b7a0000), SPH_C32(0x95260045), SPH_C32(0xa1993800), + SPH_C32(0x3e74019e), SPH_C32(0x744910b7), SPH_C32(0x975d13a8), + SPH_C32(0xf932db70) }, + { SPH_C32(0x06300000), SPH_C32(0x32f80000), SPH_C32(0x73e20042), + SPH_C32(0x310d0000), SPH_C32(0xd3a75d0c), SPH_C32(0x9f21e293), + SPH_C32(0x926aaddf), SPH_C32(0xbce1f450), SPH_C32(0xf0860000), + SPH_C32(0x8f220000), SPH_C32(0xa325005a), SPH_C32(0x1b5c0000), + SPH_C32(0x56dd5097), SPH_C32(0x753b8557), SPH_C32(0xcc1f851f), + SPH_C32(0xc86deb87) }, + { SPH_C32(0x5e730000), SPH_C32(0xb2860000), SPH_C32(0x0bd10043), + SPH_C32(0xf7663800), SPH_C32(0x349001d0), SPH_C32(0xe68cdd4e), + SPH_C32(0x3e1953b0), SPH_C32(0x86a58de1), SPH_C32(0xeddc0000), + SPH_C32(0xa4500000), SPH_C32(0xeba8005a), SPH_C32(0xb43d1800), + SPH_C32(0x73167e52), SPH_C32(0xbd423a87), SPH_C32(0x4dbd8136), + SPH_C32(0xd618dd21) }, + { SPH_C32(0x1b6a0000), SPH_C32(0x198a0000), SPH_C32(0x3b6f0042), + SPH_C32(0x9e6c1800), SPH_C32(0xf66c73c9), SPH_C32(0x57585d43), + SPH_C32(0x13c8a9f6), SPH_C32(0xa294c2f6), SPH_C32(0xb59f0000), + SPH_C32(0x242e0000), SPH_C32(0x939b005b), SPH_C32(0x72562000), + SPH_C32(0x9421228e), SPH_C32(0xc4ef055a), SPH_C32(0xe1ce7f59), + SPH_C32(0xec5ca490) }, + { SPH_C32(0x43290000), SPH_C32(0x99f40000), SPH_C32(0x435c0043), + SPH_C32(0x58072000), SPH_C32(0x115b2f15), SPH_C32(0x2ef5629e), + SPH_C32(0xbfbb5799), SPH_C32(0x98d0bb47), SPH_C32(0xa8c50000), + SPH_C32(0x0f5c0000), SPH_C32(0xdb16005b), SPH_C32(0xdd373800), + SPH_C32(0xb1ea0c4b), SPH_C32(0x0c96ba8a), SPH_C32(0x606c7b70), + SPH_C32(0xf2299236) }, + { SPH_C32(0xa30b0000), SPH_C32(0x26de0000), SPH_C32(0x3dd2005c), + SPH_C32(0x4da30000), SPH_C32(0x5c3950d9), SPH_C32(0xe7fe48ae), + SPH_C32(0x655bc507), SPH_C32(0xb7fabd16), SPH_C32(0xf76b0000), + SPH_C32(0x3d720000), SPH_C32(0x24510050), SPH_C32(0x8c510000), + SPH_C32(0x15af7339), SPH_C32(0x3dfcebf3), SPH_C32(0x3867e73d), + SPH_C32(0x58185a49) }, + { SPH_C32(0xfb480000), SPH_C32(0xa6a00000), SPH_C32(0x45e1005d), + SPH_C32(0x8bc83800), SPH_C32(0xbb0e0c05), SPH_C32(0x9e537773), + SPH_C32(0xc9283b68), SPH_C32(0x8dbec4a7), SPH_C32(0xea310000), + SPH_C32(0x16000000), SPH_C32(0x6cdc0050), SPH_C32(0x23301800), + SPH_C32(0x30645dfc), SPH_C32(0xf5855423), SPH_C32(0xb9c5e314), + SPH_C32(0x466d6cef) }, + { SPH_C32(0xbe510000), SPH_C32(0x0dac0000), SPH_C32(0x755f005c), + SPH_C32(0xe2c21800), SPH_C32(0x79f27e1c), SPH_C32(0x2f87f77e), + SPH_C32(0xe4f9c12e), SPH_C32(0xa98f8bb0), SPH_C32(0xb2720000), + SPH_C32(0x967e0000), SPH_C32(0x14ef0051), SPH_C32(0xe55b2000), + SPH_C32(0xd7530120), SPH_C32(0x8c286bfe), SPH_C32(0x15b61d7b), + SPH_C32(0x7c29155e) }, + { SPH_C32(0xe6120000), SPH_C32(0x8dd20000), SPH_C32(0x0d6c005d), + SPH_C32(0x24a92000), SPH_C32(0x9ec522c0), SPH_C32(0x562ac8a3), + SPH_C32(0x488a3f41), SPH_C32(0x93cbf201), SPH_C32(0xaf280000), + SPH_C32(0xbd0c0000), SPH_C32(0x5c620051), SPH_C32(0x4a3a3800), + SPH_C32(0xf2982fe5), SPH_C32(0x4451d42e), SPH_C32(0x94141952), + SPH_C32(0x625c23f8) }, + { SPH_C32(0x89450000), SPH_C32(0x9f3c0000), SPH_C32(0x8b590066), + SPH_C32(0x5d4e0000), SPH_C32(0x618d7938), SPH_C32(0xb6481d50), + SPH_C32(0xce87bf91), SPH_C32(0xca84310a), SPH_C32(0x59920000), + SPH_C32(0xf2370000), SPH_C32(0x14e90042), SPH_C32(0xe5790000), + SPH_C32(0x0bcc361f), SPH_C32(0x30a2fa8d), SPH_C32(0x3b36cb7b), + SPH_C32(0x8bb5076c) }, + { SPH_C32(0xd1060000), SPH_C32(0x1f420000), SPH_C32(0xf36a0067), + SPH_C32(0x9b253800), SPH_C32(0x86ba25e4), SPH_C32(0xcfe5228d), + SPH_C32(0x62f441fe), SPH_C32(0xf0c048bb), SPH_C32(0x44c80000), + SPH_C32(0xd9450000), SPH_C32(0x5c640042), SPH_C32(0x4a181800), + SPH_C32(0x2e0718da), SPH_C32(0xf8db455d), SPH_C32(0xba94cf52), + SPH_C32(0x95c031ca) }, + { SPH_C32(0x941f0000), SPH_C32(0xb44e0000), SPH_C32(0xc3d40066), + SPH_C32(0xf22f1800), SPH_C32(0x444657fd), SPH_C32(0x7e31a280), + SPH_C32(0x4f25bbb8), SPH_C32(0xd4f107ac), SPH_C32(0x1c8b0000), + SPH_C32(0x593b0000), SPH_C32(0x24570043), SPH_C32(0x8c732000), + SPH_C32(0xc9304406), SPH_C32(0x81767a80), SPH_C32(0x16e7313d), + SPH_C32(0xaf84487b) }, + { SPH_C32(0xcc5c0000), SPH_C32(0x34300000), SPH_C32(0xbbe70067), + SPH_C32(0x34442000), SPH_C32(0xa3710b21), SPH_C32(0x079c9d5d), + SPH_C32(0xe35645d7), SPH_C32(0xeeb57e1d), SPH_C32(0x01d10000), + SPH_C32(0x72490000), SPH_C32(0x6cda0043), SPH_C32(0x23123800), + SPH_C32(0xecfb6ac3), SPH_C32(0x490fc550), SPH_C32(0x97453514), + SPH_C32(0xb1f17edd) }, + { SPH_C32(0x2c7e0000), SPH_C32(0x8b1a0000), SPH_C32(0xc5690078), + SPH_C32(0x21e00000), SPH_C32(0xee1374ed), SPH_C32(0xce97b76d), + SPH_C32(0x39b6d749), SPH_C32(0xc19f784c), SPH_C32(0x5e7f0000), + SPH_C32(0x40670000), SPH_C32(0x939d0048), SPH_C32(0x72740000), + SPH_C32(0x48be15b1), SPH_C32(0x78659429), SPH_C32(0xcf4ea959), + SPH_C32(0x1bc0b6a2) }, + { SPH_C32(0x743d0000), SPH_C32(0x0b640000), SPH_C32(0xbd5a0079), + SPH_C32(0xe78b3800), SPH_C32(0x09242831), SPH_C32(0xb73a88b0), + SPH_C32(0x95c52926), SPH_C32(0xfbdb01fd), SPH_C32(0x43250000), + SPH_C32(0x6b150000), SPH_C32(0xdb100048), SPH_C32(0xdd151800), + SPH_C32(0x6d753b74), SPH_C32(0xb01c2bf9), SPH_C32(0x4eecad70), + SPH_C32(0x05b58004) }, + { SPH_C32(0x31240000), SPH_C32(0xa0680000), SPH_C32(0x8de40078), + SPH_C32(0x8e811800), SPH_C32(0xcbd85a28), SPH_C32(0x06ee08bd), + SPH_C32(0xb814d360), SPH_C32(0xdfea4eea), SPH_C32(0x1b660000), + SPH_C32(0xeb6b0000), SPH_C32(0xa3230049), SPH_C32(0x1b7e2000), + SPH_C32(0x8a4267a8), SPH_C32(0xc9b11424), SPH_C32(0xe29f531f), + SPH_C32(0x3ff1f9b5) }, + { SPH_C32(0x69670000), SPH_C32(0x20160000), SPH_C32(0xf5d70079), + SPH_C32(0x48ea2000), SPH_C32(0x2cef06f4), SPH_C32(0x7f433760), + SPH_C32(0x14672d0f), SPH_C32(0xe5ae375b), SPH_C32(0x063c0000), + SPH_C32(0xc0190000), SPH_C32(0xebae0049), SPH_C32(0xb41f3800), + SPH_C32(0xaf89496d), SPH_C32(0x01c8abf4), SPH_C32(0x633d5736), + SPH_C32(0x2184cf13) }, + { SPH_C32(0x8ea80000), SPH_C32(0x2d6c0000), SPH_C32(0x0c2d006c), + SPH_C32(0xca430000), SPH_C32(0x22ff5a96), SPH_C32(0xfe8f73f4), + SPH_C32(0x3affddb3), SPH_C32(0x5af180c4), SPH_C32(0xfb440000), + SPH_C32(0x54410000), SPH_C32(0xddad0056), SPH_C32(0x0eda0000), + SPH_C32(0xc7201864), SPH_C32(0x00ba3e14), SPH_C32(0x387fc181), + SPH_C32(0x10dbffe4) }, + { SPH_C32(0xd6eb0000), SPH_C32(0xad120000), SPH_C32(0x741e006d), + SPH_C32(0x0c283800), SPH_C32(0xc5c8064a), SPH_C32(0x87224c29), + SPH_C32(0x968c23dc), SPH_C32(0x60b5f975), SPH_C32(0xe61e0000), + SPH_C32(0x7f330000), SPH_C32(0x95200056), SPH_C32(0xa1bb1800), + SPH_C32(0xe2eb36a1), SPH_C32(0xc8c381c4), SPH_C32(0xb9ddc5a8), + SPH_C32(0x0eaec942) }, + { SPH_C32(0x93f20000), SPH_C32(0x061e0000), SPH_C32(0x44a0006c), + SPH_C32(0x65221800), SPH_C32(0x07347453), SPH_C32(0x36f6cc24), + SPH_C32(0xbb5dd99a), SPH_C32(0x4484b662), SPH_C32(0xbe5d0000), + SPH_C32(0xff4d0000), SPH_C32(0xed130057), SPH_C32(0x67d02000), + SPH_C32(0x05dc6a7d), SPH_C32(0xb16ebe19), SPH_C32(0x15ae3bc7), + SPH_C32(0x34eab0f3) }, + { SPH_C32(0xcbb10000), SPH_C32(0x86600000), SPH_C32(0x3c93006d), + SPH_C32(0xa3492000), SPH_C32(0xe003288f), SPH_C32(0x4f5bf3f9), + SPH_C32(0x172e27f5), SPH_C32(0x7ec0cfd3), SPH_C32(0xa3070000), + SPH_C32(0xd43f0000), SPH_C32(0xa59e0057), SPH_C32(0xc8b13800), + SPH_C32(0x201744b8), SPH_C32(0x791701c9), SPH_C32(0x940c3fee), + SPH_C32(0x2a9f8655) }, + { SPH_C32(0x2b930000), SPH_C32(0x394a0000), SPH_C32(0x421d0072), + SPH_C32(0xb6ed0000), SPH_C32(0xad615743), SPH_C32(0x8650d9c9), + SPH_C32(0xcdceb56b), SPH_C32(0x51eac982), SPH_C32(0xfca90000), + SPH_C32(0xe6110000), SPH_C32(0x5ad9005c), SPH_C32(0x99d70000), + SPH_C32(0x84523bca), SPH_C32(0x487d50b0), SPH_C32(0xcc07a3a3), + SPH_C32(0x80ae4e2a) }, + { SPH_C32(0x73d00000), SPH_C32(0xb9340000), SPH_C32(0x3a2e0073), + SPH_C32(0x70863800), SPH_C32(0x4a560b9f), SPH_C32(0xfffde614), + SPH_C32(0x61bd4b04), SPH_C32(0x6baeb033), SPH_C32(0xe1f30000), + SPH_C32(0xcd630000), SPH_C32(0x1254005c), SPH_C32(0x36b61800), + SPH_C32(0xa199150f), SPH_C32(0x8004ef60), SPH_C32(0x4da5a78a), + SPH_C32(0x9edb788c) }, + { SPH_C32(0x36c90000), SPH_C32(0x12380000), SPH_C32(0x0a900072), + SPH_C32(0x198c1800), SPH_C32(0x88aa7986), SPH_C32(0x4e296619), + SPH_C32(0x4c6cb142), SPH_C32(0x4f9fff24), SPH_C32(0xb9b00000), + SPH_C32(0x4d1d0000), SPH_C32(0x6a67005d), SPH_C32(0xf0dd2000), + SPH_C32(0x46ae49d3), SPH_C32(0xf9a9d0bd), SPH_C32(0xe1d659e5), + SPH_C32(0xa49f013d) }, + { SPH_C32(0x6e8a0000), SPH_C32(0x92460000), SPH_C32(0x72a30073), + SPH_C32(0xdfe72000), SPH_C32(0x6f9d255a), SPH_C32(0x378459c4), + SPH_C32(0xe01f4f2d), SPH_C32(0x75db8695), SPH_C32(0xa4ea0000), + SPH_C32(0x666f0000), SPH_C32(0x22ea005d), SPH_C32(0x5fbc3800), + SPH_C32(0x63656716), SPH_C32(0x31d06f6d), SPH_C32(0x60745dcc), + SPH_C32(0xbaea379b) }, + { SPH_C32(0x0a1f0000), SPH_C32(0x5bcb0000), SPH_C32(0x8a1e0044), + SPH_C32(0xb3860000), SPH_C32(0x01283651), SPH_C32(0xa2673774), + SPH_C32(0x92728b63), SPH_C32(0xf42251fd), SPH_C32(0xd10a0000), + SPH_C32(0xeda30000), SPH_C32(0x6b26006c), SPH_C32(0x1e370000), + SPH_C32(0xfa943185), SPH_C32(0x510c6bea), SPH_C32(0x93a3bb17), + SPH_C32(0x6da573f8) }, + { SPH_C32(0x525c0000), SPH_C32(0xdbb50000), SPH_C32(0xf22d0045), + SPH_C32(0x75ed3800), SPH_C32(0xe61f6a8d), SPH_C32(0xdbca08a9), + SPH_C32(0x3e01750c), SPH_C32(0xce66284c), SPH_C32(0xcc500000), + SPH_C32(0xc6d10000), SPH_C32(0x23ab006c), SPH_C32(0xb1561800), + SPH_C32(0xdf5f1f40), SPH_C32(0x9975d43a), SPH_C32(0x1201bf3e), + SPH_C32(0x73d0455e) }, + { SPH_C32(0x17450000), SPH_C32(0x70b90000), SPH_C32(0xc2930044), + SPH_C32(0x1ce71800), SPH_C32(0x24e31894), SPH_C32(0x6a1e88a4), + SPH_C32(0x13d08f4a), SPH_C32(0xea57675b), SPH_C32(0x94130000), + SPH_C32(0x46af0000), SPH_C32(0x5b98006d), SPH_C32(0x773d2000), + SPH_C32(0x3868439c), SPH_C32(0xe0d8ebe7), SPH_C32(0xbe724151), + SPH_C32(0x49943cef) }, + { SPH_C32(0x4f060000), SPH_C32(0xf0c70000), SPH_C32(0xbaa00045), + SPH_C32(0xda8c2000), SPH_C32(0xc3d44448), SPH_C32(0x13b3b779), + SPH_C32(0xbfa37125), SPH_C32(0xd0131eea), SPH_C32(0x89490000), + SPH_C32(0x6ddd0000), SPH_C32(0x1315006d), SPH_C32(0xd85c3800), + SPH_C32(0x1da36d59), SPH_C32(0x28a15437), SPH_C32(0x3fd04578), + SPH_C32(0x57e10a49) }, + { SPH_C32(0xaf240000), SPH_C32(0x4fed0000), SPH_C32(0xc42e005a), + SPH_C32(0xcf280000), SPH_C32(0x8eb63b84), SPH_C32(0xdab89d49), + SPH_C32(0x6543e3bb), SPH_C32(0xff3918bb), SPH_C32(0xd6e70000), + SPH_C32(0x5ff30000), SPH_C32(0xec520066), SPH_C32(0x893a0000), + SPH_C32(0xb9e6122b), SPH_C32(0x19cb054e), SPH_C32(0x67dbd935), + SPH_C32(0xfdd0c236) }, + { SPH_C32(0xf7670000), SPH_C32(0xcf930000), SPH_C32(0xbc1d005b), + SPH_C32(0x09433800), SPH_C32(0x69816758), SPH_C32(0xa315a294), + SPH_C32(0xc9301dd4), SPH_C32(0xc57d610a), SPH_C32(0xcbbd0000), + SPH_C32(0x74810000), SPH_C32(0xa4df0066), SPH_C32(0x265b1800), + SPH_C32(0x9c2d3cee), SPH_C32(0xd1b2ba9e), SPH_C32(0xe679dd1c), + SPH_C32(0xe3a5f490) }, + { SPH_C32(0xb27e0000), SPH_C32(0x649f0000), SPH_C32(0x8ca3005a), + SPH_C32(0x60491800), SPH_C32(0xab7d1541), SPH_C32(0x12c12299), + SPH_C32(0xe4e1e792), SPH_C32(0xe14c2e1d), SPH_C32(0x93fe0000), + SPH_C32(0xf4ff0000), SPH_C32(0xdcec0067), SPH_C32(0xe0302000), + SPH_C32(0x7b1a6032), SPH_C32(0xa81f8543), SPH_C32(0x4a0a2373), + SPH_C32(0xd9e18d21) }, + { SPH_C32(0xea3d0000), SPH_C32(0xe4e10000), SPH_C32(0xf490005b), + SPH_C32(0xa6222000), SPH_C32(0x4c4a499d), SPH_C32(0x6b6c1d44), + SPH_C32(0x489219fd), SPH_C32(0xdb0857ac), SPH_C32(0x8ea40000), + SPH_C32(0xdf8d0000), SPH_C32(0x94610067), SPH_C32(0x4f513800), + SPH_C32(0x5ed14ef7), SPH_C32(0x60663a93), SPH_C32(0xcba8275a), + SPH_C32(0xc794bb87) }, + { SPH_C32(0x0df20000), SPH_C32(0xe99b0000), SPH_C32(0x0d6a004e), + SPH_C32(0x248b0000), SPH_C32(0x425a15ff), SPH_C32(0xeaa059d0), + SPH_C32(0x660ae941), SPH_C32(0x6457e033), SPH_C32(0x73dc0000), + SPH_C32(0x4bd50000), SPH_C32(0xa2620078), SPH_C32(0xf5940000), + SPH_C32(0x36781ffe), SPH_C32(0x6114af73), SPH_C32(0x90eab1ed), + SPH_C32(0xf6cb8b70) }, + { SPH_C32(0x55b10000), SPH_C32(0x69e50000), SPH_C32(0x7559004f), + SPH_C32(0xe2e03800), SPH_C32(0xa56d4923), SPH_C32(0x930d660d), + SPH_C32(0xca79172e), SPH_C32(0x5e139982), SPH_C32(0x6e860000), + SPH_C32(0x60a70000), SPH_C32(0xeaef0078), SPH_C32(0x5af51800), + SPH_C32(0x13b3313b), SPH_C32(0xa96d10a3), SPH_C32(0x1148b5c4), + SPH_C32(0xe8bebdd6) }, + { SPH_C32(0x10a80000), SPH_C32(0xc2e90000), SPH_C32(0x45e7004e), + SPH_C32(0x8bea1800), SPH_C32(0x67913b3a), SPH_C32(0x22d9e600), + SPH_C32(0xe7a8ed68), SPH_C32(0x7a22d695), SPH_C32(0x36c50000), + SPH_C32(0xe0d90000), SPH_C32(0x92dc0079), SPH_C32(0x9c9e2000), + SPH_C32(0xf4846de7), SPH_C32(0xd0c02f7e), SPH_C32(0xbd3b4bab), + SPH_C32(0xd2fac467) }, + { SPH_C32(0x48eb0000), SPH_C32(0x42970000), SPH_C32(0x3dd4004f), + SPH_C32(0x4d812000), SPH_C32(0x80a667e6), SPH_C32(0x5b74d9dd), + SPH_C32(0x4bdb1307), SPH_C32(0x4066af24), SPH_C32(0x2b9f0000), + SPH_C32(0xcbab0000), SPH_C32(0xda510079), SPH_C32(0x33ff3800), + SPH_C32(0xd14f4322), SPH_C32(0x18b990ae), SPH_C32(0x3c994f82), + SPH_C32(0xcc8ff2c1) }, + { SPH_C32(0xa8c90000), SPH_C32(0xfdbd0000), SPH_C32(0x435a0050), + SPH_C32(0x58250000), SPH_C32(0xcdc4182a), SPH_C32(0x927ff3ed), + SPH_C32(0x913b8199), SPH_C32(0x6f4ca975), SPH_C32(0x74310000), + SPH_C32(0xf9850000), SPH_C32(0x25160072), SPH_C32(0x62990000), + SPH_C32(0x750a3c50), SPH_C32(0x29d3c1d7), SPH_C32(0x6492d3cf), + SPH_C32(0x66be3abe) }, + { SPH_C32(0xf08a0000), SPH_C32(0x7dc30000), SPH_C32(0x3b690051), + SPH_C32(0x9e4e3800), SPH_C32(0x2af344f6), SPH_C32(0xebd2cc30), + SPH_C32(0x3d487ff6), SPH_C32(0x5508d0c4), SPH_C32(0x696b0000), + SPH_C32(0xd2f70000), SPH_C32(0x6d9b0072), SPH_C32(0xcdf81800), + SPH_C32(0x50c11295), SPH_C32(0xe1aa7e07), SPH_C32(0xe530d7e6), + SPH_C32(0x78cb0c18) }, + { SPH_C32(0xb5930000), SPH_C32(0xd6cf0000), SPH_C32(0x0bd70050), + SPH_C32(0xf7441800), SPH_C32(0xe80f36ef), SPH_C32(0x5a064c3d), + SPH_C32(0x109985b0), SPH_C32(0x71399fd3), SPH_C32(0x31280000), + SPH_C32(0x52890000), SPH_C32(0x15a80073), SPH_C32(0x0b932000), + SPH_C32(0xb7f64e49), SPH_C32(0x980741da), SPH_C32(0x49432989), + SPH_C32(0x428f75a9) }, + { SPH_C32(0xedd00000), SPH_C32(0x56b10000), SPH_C32(0x73e40051), + SPH_C32(0x312f2000), SPH_C32(0x0f386a33), SPH_C32(0x23ab73e0), + SPH_C32(0xbcea7bdf), SPH_C32(0x4b7de662), SPH_C32(0x2c720000), + SPH_C32(0x79fb0000), SPH_C32(0x5d250073), SPH_C32(0xa4f23800), + SPH_C32(0x923d608c), SPH_C32(0x507efe0a), SPH_C32(0xc8e12da0), + SPH_C32(0x5cfa430f) }, + { SPH_C32(0x82870000), SPH_C32(0x445f0000), SPH_C32(0xf5d1006a), + SPH_C32(0x48c80000), SPH_C32(0xf07031cb), SPH_C32(0xc3c9a613), + SPH_C32(0x3ae7fb0f), SPH_C32(0x12322569), SPH_C32(0xdac80000), + SPH_C32(0x36c00000), SPH_C32(0x15ae0060), SPH_C32(0x0bb10000), + SPH_C32(0x6b697976), SPH_C32(0x248dd0a9), SPH_C32(0x67c3ff89), + SPH_C32(0xb513679b) }, + { SPH_C32(0xdac40000), SPH_C32(0xc4210000), SPH_C32(0x8de2006b), + SPH_C32(0x8ea33800), SPH_C32(0x17476d17), SPH_C32(0xba6499ce), + SPH_C32(0x96940560), SPH_C32(0x28765cd8), SPH_C32(0xc7920000), + SPH_C32(0x1db20000), SPH_C32(0x5d230060), SPH_C32(0xa4d01800), + SPH_C32(0x4ea257b3), SPH_C32(0xecf46f79), SPH_C32(0xe661fba0), + SPH_C32(0xab66513d) }, + { SPH_C32(0x9fdd0000), SPH_C32(0x6f2d0000), SPH_C32(0xbd5c006a), + SPH_C32(0xe7a91800), SPH_C32(0xd5bb1f0e), SPH_C32(0x0bb019c3), + SPH_C32(0xbb45ff26), SPH_C32(0x0c4713cf), SPH_C32(0x9fd10000), + SPH_C32(0x9dcc0000), SPH_C32(0x25100061), SPH_C32(0x62bb2000), + SPH_C32(0xa9950b6f), SPH_C32(0x955950a4), SPH_C32(0x4a1205cf), + SPH_C32(0x9122288c) }, + { SPH_C32(0xc79e0000), SPH_C32(0xef530000), SPH_C32(0xc56f006b), + SPH_C32(0x21c22000), SPH_C32(0x328c43d2), SPH_C32(0x721d261e), + SPH_C32(0x17360149), SPH_C32(0x36036a7e), SPH_C32(0x828b0000), + SPH_C32(0xb6be0000), SPH_C32(0x6d9d0061), SPH_C32(0xcdda3800), + SPH_C32(0x8c5e25aa), SPH_C32(0x5d20ef74), SPH_C32(0xcbb001e6), + SPH_C32(0x8f571e2a) }, + { SPH_C32(0x27bc0000), SPH_C32(0x50790000), SPH_C32(0xbbe10074), + SPH_C32(0x34660000), SPH_C32(0x7fee3c1e), SPH_C32(0xbb160c2e), + SPH_C32(0xcdd693d7), SPH_C32(0x19296c2f), SPH_C32(0xdd250000), + SPH_C32(0x84900000), SPH_C32(0x92da006a), SPH_C32(0x9cbc0000), + SPH_C32(0x281b5ad8), SPH_C32(0x6c4abe0d), SPH_C32(0x93bb9dab), + SPH_C32(0x2566d655) }, + { SPH_C32(0x7fff0000), SPH_C32(0xd0070000), SPH_C32(0xc3d20075), + SPH_C32(0xf20d3800), SPH_C32(0x98d960c2), SPH_C32(0xc2bb33f3), + SPH_C32(0x61a56db8), SPH_C32(0x236d159e), SPH_C32(0xc07f0000), + SPH_C32(0xafe20000), SPH_C32(0xda57006a), SPH_C32(0x33dd1800), + SPH_C32(0x0dd0741d), SPH_C32(0xa43301dd), SPH_C32(0x12199982), + SPH_C32(0x3b13e0f3) }, + { SPH_C32(0x3ae60000), SPH_C32(0x7b0b0000), SPH_C32(0xf36c0074), + SPH_C32(0x9b071800), SPH_C32(0x5a2512db), SPH_C32(0x736fb3fe), + SPH_C32(0x4c7497fe), SPH_C32(0x075c5a89), SPH_C32(0x983c0000), + SPH_C32(0x2f9c0000), SPH_C32(0xa264006b), SPH_C32(0xf5b62000), + SPH_C32(0xeae728c1), SPH_C32(0xdd9e3e00), SPH_C32(0xbe6a67ed), + SPH_C32(0x01579942) }, + { SPH_C32(0x62a50000), SPH_C32(0xfb750000), SPH_C32(0x8b5f0075), + SPH_C32(0x5d6c2000), SPH_C32(0xbd124e07), SPH_C32(0x0ac28c23), + SPH_C32(0xe0076991), SPH_C32(0x3d182338), SPH_C32(0x85660000), + SPH_C32(0x04ee0000), SPH_C32(0xeae9006b), SPH_C32(0x5ad73800), + SPH_C32(0xcf2c0604), SPH_C32(0x15e781d0), SPH_C32(0x3fc863c4), + SPH_C32(0x1f22afe4) }, + { SPH_C32(0x856a0000), SPH_C32(0xf60f0000), SPH_C32(0x72a50060), + SPH_C32(0xdfc50000), SPH_C32(0xb3021265), SPH_C32(0x8b0ec8b7), + SPH_C32(0xce9f992d), SPH_C32(0x824794a7), SPH_C32(0x781e0000), + SPH_C32(0x90b60000), SPH_C32(0xdcea0074), SPH_C32(0xe0120000), + SPH_C32(0xa785570d), SPH_C32(0x14951430), SPH_C32(0x648af573), + SPH_C32(0x2e7d9f13) }, + { SPH_C32(0xdd290000), SPH_C32(0x76710000), SPH_C32(0x0a960061), + SPH_C32(0x19ae3800), SPH_C32(0x54354eb9), SPH_C32(0xf2a3f76a), + SPH_C32(0x62ec6742), SPH_C32(0xb803ed16), SPH_C32(0x65440000), + SPH_C32(0xbbc40000), SPH_C32(0x94670074), SPH_C32(0x4f731800), + SPH_C32(0x824e79c8), SPH_C32(0xdcecabe0), SPH_C32(0xe528f15a), + SPH_C32(0x3008a9b5) }, + { SPH_C32(0x98300000), SPH_C32(0xdd7d0000), SPH_C32(0x3a280060), + SPH_C32(0x70a41800), SPH_C32(0x96c93ca0), SPH_C32(0x43777767), + SPH_C32(0x4f3d9d04), SPH_C32(0x9c32a201), SPH_C32(0x3d070000), + SPH_C32(0x3bba0000), SPH_C32(0xec540075), SPH_C32(0x89182000), + SPH_C32(0x65792514), SPH_C32(0xa541943d), SPH_C32(0x495b0f35), + SPH_C32(0x0a4cd004) }, + { SPH_C32(0xc0730000), SPH_C32(0x5d030000), SPH_C32(0x421b0061), + SPH_C32(0xb6cf2000), SPH_C32(0x71fe607c), SPH_C32(0x3ada48ba), + SPH_C32(0xe34e636b), SPH_C32(0xa676dbb0), SPH_C32(0x205d0000), + SPH_C32(0x10c80000), SPH_C32(0xa4d90075), SPH_C32(0x26793800), + SPH_C32(0x40b20bd1), SPH_C32(0x6d382bed), SPH_C32(0xc8f90b1c), + SPH_C32(0x1439e6a2) }, + { SPH_C32(0x20510000), SPH_C32(0xe2290000), SPH_C32(0x3c95007e), + SPH_C32(0xa36b0000), SPH_C32(0x3c9c1fb0), SPH_C32(0xf3d1628a), + SPH_C32(0x39aef1f5), SPH_C32(0x895cdde1), SPH_C32(0x7ff30000), + SPH_C32(0x22e60000), SPH_C32(0x5b9e007e), SPH_C32(0x771f0000), + SPH_C32(0xe4f774a3), SPH_C32(0x5c527a94), SPH_C32(0x90f29751), + SPH_C32(0xbe082edd) }, + { SPH_C32(0x78120000), SPH_C32(0x62570000), SPH_C32(0x44a6007f), + SPH_C32(0x65003800), SPH_C32(0xdbab436c), SPH_C32(0x8a7c5d57), + SPH_C32(0x95dd0f9a), SPH_C32(0xb318a450), SPH_C32(0x62a90000), + SPH_C32(0x09940000), SPH_C32(0x1313007e), SPH_C32(0xd87e1800), + SPH_C32(0xc13c5a66), SPH_C32(0x942bc544), SPH_C32(0x11509378), + SPH_C32(0xa07d187b) }, + { SPH_C32(0x3d0b0000), SPH_C32(0xc95b0000), SPH_C32(0x7418007e), + SPH_C32(0x0c0a1800), SPH_C32(0x19573175), SPH_C32(0x3ba8dd5a), + SPH_C32(0xb80cf5dc), SPH_C32(0x9729eb47), SPH_C32(0x3aea0000), + SPH_C32(0x89ea0000), SPH_C32(0x6b20007f), SPH_C32(0x1e152000), + SPH_C32(0x260b06ba), SPH_C32(0xed86fa99), SPH_C32(0xbd236d17), + SPH_C32(0x9a3961ca) }, + { SPH_C32(0x65480000), SPH_C32(0x49250000), SPH_C32(0x0c2b007f), + SPH_C32(0xca612000), SPH_C32(0xfe606da9), SPH_C32(0x4205e287), + SPH_C32(0x147f0bb3), SPH_C32(0xad6d92f6), SPH_C32(0x27b00000), + SPH_C32(0xa2980000), SPH_C32(0x23ad007f), SPH_C32(0xb1743800), + SPH_C32(0x03c0287f), SPH_C32(0x25ff4549), SPH_C32(0x3c81693e), + SPH_C32(0x844c576c) } +}; + +static const sph_u32 T512_48[256][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0xe6280000), SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), + SPH_C32(0xd3d002e0), SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), + SPH_C32(0x289506b4), SPH_C32(0xd75a4897), SPH_C32(0xf0c50000), + SPH_C32(0x59230000), SPH_C32(0x45820000), SPH_C32(0xe18d00c0), + SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), SPH_C32(0xcbe0fe1c), + SPH_C32(0x56a7b19f) }, + { SPH_C32(0xf0c50000), SPH_C32(0x59230000), SPH_C32(0x45820000), + SPH_C32(0xe18d00c0), SPH_C32(0x3b6d0631), SPH_C32(0xc2ed5699), + SPH_C32(0xcbe0fe1c), SPH_C32(0x56a7b19f), SPH_C32(0x16ed0000), + SPH_C32(0x15680000), SPH_C32(0xedd70000), SPH_C32(0x325d0220), + SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), SPH_C32(0xe375f8a8), + SPH_C32(0x81fdf908) }, + { SPH_C32(0x16ed0000), SPH_C32(0x15680000), SPH_C32(0xedd70000), + SPH_C32(0x325d0220), SPH_C32(0xe30c3689), SPH_C32(0x5a4ae643), + SPH_C32(0xe375f8a8), SPH_C32(0x81fdf908), SPH_C32(0xe6280000), + SPH_C32(0x4c4b0000), SPH_C32(0xa8550000), SPH_C32(0xd3d002e0), + SPH_C32(0xd86130b8), SPH_C32(0x98a7b0da), SPH_C32(0x289506b4), + SPH_C32(0xd75a4897) }, + { SPH_C32(0xb4310000), SPH_C32(0x77330000), SPH_C32(0xb15d0000), + SPH_C32(0x7fd004e0), SPH_C32(0x78a26138), SPH_C32(0xd116c35d), + SPH_C32(0xd256d489), SPH_C32(0x4e6f74de), SPH_C32(0xe3060000), + SPH_C32(0xbdc10000), SPH_C32(0x87130000), SPH_C32(0xbff20060), + SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), SPH_C32(0x73c5ab06), + SPH_C32(0x5bd61539) }, + { SPH_C32(0x52190000), SPH_C32(0x3b780000), SPH_C32(0x19080000), + SPH_C32(0xac000600), SPH_C32(0xa0c35180), SPH_C32(0x49b17387), + SPH_C32(0xfac3d23d), SPH_C32(0x99353c49), SPH_C32(0x13c30000), + SPH_C32(0xe4e20000), SPH_C32(0xc2910000), SPH_C32(0x5e7f00a0), + SPH_C32(0x15d70c2b), SPH_C32(0x4f5861c8), SPH_C32(0xb825551a), + SPH_C32(0x0d71a4a6) }, + { SPH_C32(0x44f40000), SPH_C32(0x2e100000), SPH_C32(0xf4df0000), + SPH_C32(0x9e5d0420), SPH_C32(0x43cf6709), SPH_C32(0x13fb95c4), + SPH_C32(0x19b62a95), SPH_C32(0x18c8c541), SPH_C32(0xf5eb0000), + SPH_C32(0xa8a90000), SPH_C32(0x6ac40000), SPH_C32(0x8daf0240), + SPH_C32(0xcdb63c93), SPH_C32(0xd7ffd112), SPH_C32(0x90b053ae), + SPH_C32(0xda2bec31) }, + { SPH_C32(0xa2dc0000), SPH_C32(0x625b0000), SPH_C32(0x5c8a0000), + SPH_C32(0x4d8d06c0), SPH_C32(0x9bae57b1), SPH_C32(0x8b5c251e), + SPH_C32(0x31232c21), SPH_C32(0xcf928dd6), SPH_C32(0x052e0000), + SPH_C32(0xf18a0000), SPH_C32(0x2f460000), SPH_C32(0x6c220280), + SPH_C32(0xf6db3aa2), SPH_C32(0x1512878b), SPH_C32(0x5b50adb2), + SPH_C32(0x8c8c5dae) }, + { SPH_C32(0xe3060000), SPH_C32(0xbdc10000), SPH_C32(0x87130000), + SPH_C32(0xbff20060), SPH_C32(0x2eba0a1a), SPH_C32(0x8db53751), + SPH_C32(0x73c5ab06), SPH_C32(0x5bd61539), SPH_C32(0x57370000), + SPH_C32(0xcaf20000), SPH_C32(0x364e0000), SPH_C32(0xc0220480), + SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), SPH_C32(0xa1937f8f), + SPH_C32(0x15b961e7) }, + { SPH_C32(0x052e0000), SPH_C32(0xf18a0000), SPH_C32(0x2f460000), + SPH_C32(0x6c220280), SPH_C32(0xf6db3aa2), SPH_C32(0x1512878b), + SPH_C32(0x5b50adb2), SPH_C32(0x8c8c5dae), SPH_C32(0xa7f20000), + SPH_C32(0x93d10000), SPH_C32(0x73cc0000), SPH_C32(0x21af0440), + SPH_C32(0x6d756d13), SPH_C32(0x9e4ea295), SPH_C32(0x6a738193), + SPH_C32(0x431ed078) }, + { SPH_C32(0x13c30000), SPH_C32(0xe4e20000), SPH_C32(0xc2910000), + SPH_C32(0x5e7f00a0), SPH_C32(0x15d70c2b), SPH_C32(0x4f5861c8), + SPH_C32(0xb825551a), SPH_C32(0x0d71a4a6), SPH_C32(0x41da0000), + SPH_C32(0xdf9a0000), SPH_C32(0xdb990000), SPH_C32(0xf27f06a0), + SPH_C32(0xb5145dab), SPH_C32(0x06e9124f), SPH_C32(0x42e68727), + SPH_C32(0x944498ef) }, + { SPH_C32(0xf5eb0000), SPH_C32(0xa8a90000), SPH_C32(0x6ac40000), + SPH_C32(0x8daf0240), SPH_C32(0xcdb63c93), SPH_C32(0xd7ffd112), + SPH_C32(0x90b053ae), SPH_C32(0xda2bec31), SPH_C32(0xb11f0000), + SPH_C32(0x86b90000), SPH_C32(0x9e1b0000), SPH_C32(0x13f20660), + SPH_C32(0x8e795b9a), SPH_C32(0xc40444d6), SPH_C32(0x8906793b), + SPH_C32(0xc2e32970) }, + { SPH_C32(0x57370000), SPH_C32(0xcaf20000), SPH_C32(0x364e0000), + SPH_C32(0xc0220480), SPH_C32(0x56186b22), SPH_C32(0x5ca3f40c), + SPH_C32(0xa1937f8f), SPH_C32(0x15b961e7), SPH_C32(0xb4310000), + SPH_C32(0x77330000), SPH_C32(0xb15d0000), SPH_C32(0x7fd004e0), + SPH_C32(0x78a26138), SPH_C32(0xd116c35d), SPH_C32(0xd256d489), + SPH_C32(0x4e6f74de) }, + { SPH_C32(0xb11f0000), SPH_C32(0x86b90000), SPH_C32(0x9e1b0000), + SPH_C32(0x13f20660), SPH_C32(0x8e795b9a), SPH_C32(0xc40444d6), + SPH_C32(0x8906793b), SPH_C32(0xc2e32970), SPH_C32(0x44f40000), + SPH_C32(0x2e100000), SPH_C32(0xf4df0000), SPH_C32(0x9e5d0420), + SPH_C32(0x43cf6709), SPH_C32(0x13fb95c4), SPH_C32(0x19b62a95), + SPH_C32(0x18c8c541) }, + { SPH_C32(0xa7f20000), SPH_C32(0x93d10000), SPH_C32(0x73cc0000), + SPH_C32(0x21af0440), SPH_C32(0x6d756d13), SPH_C32(0x9e4ea295), + SPH_C32(0x6a738193), SPH_C32(0x431ed078), SPH_C32(0xa2dc0000), + SPH_C32(0x625b0000), SPH_C32(0x5c8a0000), SPH_C32(0x4d8d06c0), + SPH_C32(0x9bae57b1), SPH_C32(0x8b5c251e), SPH_C32(0x31232c21), + SPH_C32(0xcf928dd6) }, + { SPH_C32(0x41da0000), SPH_C32(0xdf9a0000), SPH_C32(0xdb990000), + SPH_C32(0xf27f06a0), SPH_C32(0xb5145dab), SPH_C32(0x06e9124f), + SPH_C32(0x42e68727), SPH_C32(0x944498ef), SPH_C32(0x52190000), + SPH_C32(0x3b780000), SPH_C32(0x19080000), SPH_C32(0xac000600), + SPH_C32(0xa0c35180), SPH_C32(0x49b17387), SPH_C32(0xfac3d23d), + SPH_C32(0x99353c49) }, + { SPH_C32(0x02f20000), SPH_C32(0xa2810000), SPH_C32(0x873f0000), + SPH_C32(0xe36c7800), SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), + SPH_C32(0xc4c23237), SPH_C32(0x7f32259e), SPH_C32(0xbadd0000), + SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), SPH_C32(0xf7282800), + SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), SPH_C32(0xea5a8d14), + SPH_C32(0x2a2c18f0) }, + { SPH_C32(0xe4da0000), SPH_C32(0xeeca0000), SPH_C32(0x2f6a0000), + SPH_C32(0x30bc7ae0), SPH_C32(0xc67c4457), SPH_C32(0x9f9a9b0c), + SPH_C32(0xec573483), SPH_C32(0xa8686d09), SPH_C32(0x4a180000), + SPH_C32(0x4a8e0000), SPH_C32(0xf2650000), SPH_C32(0x16a528c0), + SPH_C32(0xe428127c), SPH_C32(0xf4f795a3), SPH_C32(0x21ba7308), + SPH_C32(0x7c8ba96f) }, + { SPH_C32(0xf2370000), SPH_C32(0xfba20000), SPH_C32(0xc2bd0000), + SPH_C32(0x02e178c0), SPH_C32(0x257072de), SPH_C32(0xc5d07d4f), + SPH_C32(0x0f22cc2b), SPH_C32(0x29959401), SPH_C32(0xac300000), + SPH_C32(0x06c50000), SPH_C32(0x5a300000), SPH_C32(0xc5752a20), + SPH_C32(0x3c4922c4), SPH_C32(0x6c502579), SPH_C32(0x092f75bc), + SPH_C32(0xabd1e1f8) }, + { SPH_C32(0x141f0000), SPH_C32(0xb7e90000), SPH_C32(0x6ae80000), + SPH_C32(0xd1317a20), SPH_C32(0xfd114266), SPH_C32(0x5d77cd95), + SPH_C32(0x27b7ca9f), SPH_C32(0xfecfdc96), SPH_C32(0x5cf50000), + SPH_C32(0x5fe60000), SPH_C32(0x1fb20000), SPH_C32(0x24f82ae0), + SPH_C32(0x072424f5), SPH_C32(0xaebd73e0), SPH_C32(0xc2cf8ba0), + SPH_C32(0xfd765067) }, + { SPH_C32(0xb6c30000), SPH_C32(0xd5b20000), SPH_C32(0x36620000), + SPH_C32(0x9cbc7ce0), SPH_C32(0x66bf15d7), SPH_C32(0xd62be88b), + SPH_C32(0x1694e6be), SPH_C32(0x315d5140), SPH_C32(0x59db0000), + SPH_C32(0xae6c0000), SPH_C32(0x30f40000), SPH_C32(0x48da2860), + SPH_C32(0xf1ff1e57), SPH_C32(0xbbaff46b), SPH_C32(0x999f2612), + SPH_C32(0x71fa0dc9) }, + { SPH_C32(0x50eb0000), SPH_C32(0x99f90000), SPH_C32(0x9e370000), + SPH_C32(0x4f6c7e00), SPH_C32(0xbede256f), SPH_C32(0x4e8c5851), + SPH_C32(0x3e01e00a), SPH_C32(0xe60719d7), SPH_C32(0xa91e0000), + SPH_C32(0xf74f0000), SPH_C32(0x75760000), SPH_C32(0xa95728a0), + SPH_C32(0xca921866), SPH_C32(0x7942a2f2), SPH_C32(0x527fd80e), + SPH_C32(0x275dbc56) }, + { SPH_C32(0x46060000), SPH_C32(0x8c910000), SPH_C32(0x73e00000), + SPH_C32(0x7d317c20), SPH_C32(0x5dd213e6), SPH_C32(0x14c6be12), + SPH_C32(0xdd7418a2), SPH_C32(0x67fae0df), SPH_C32(0x4f360000), + SPH_C32(0xbb040000), SPH_C32(0xdd230000), SPH_C32(0x7a872a40), + SPH_C32(0x12f328de), SPH_C32(0xe1e51228), SPH_C32(0x7aeadeba), + SPH_C32(0xf007f4c1) }, + { SPH_C32(0xa02e0000), SPH_C32(0xc0da0000), SPH_C32(0xdbb50000), + SPH_C32(0xaee17ec0), SPH_C32(0x85b3235e), SPH_C32(0x8c610ec8), + SPH_C32(0xf5e11e16), SPH_C32(0xb0a0a848), SPH_C32(0xbff30000), + SPH_C32(0xe2270000), SPH_C32(0x98a10000), SPH_C32(0x9b0a2a80), + SPH_C32(0x299e2eef), SPH_C32(0x230844b1), SPH_C32(0xb10a20a6), + SPH_C32(0xa6a0455e) }, + { SPH_C32(0xe1f40000), SPH_C32(0x1f400000), SPH_C32(0x002c0000), + SPH_C32(0x5c9e7860), SPH_C32(0x30a77ef5), SPH_C32(0x8a881c87), + SPH_C32(0xb7079931), SPH_C32(0x24e430a7), SPH_C32(0xedea0000), + SPH_C32(0xd95f0000), SPH_C32(0x81a90000), SPH_C32(0x370a2c80), + SPH_C32(0x895d7f6f), SPH_C32(0x6ab93736), SPH_C32(0x4bc9f29b), + SPH_C32(0x3f957917) }, + { SPH_C32(0x07dc0000), SPH_C32(0x530b0000), SPH_C32(0xa8790000), + SPH_C32(0x8f4e7a80), SPH_C32(0xe8c64e4d), SPH_C32(0x122fac5d), + SPH_C32(0x9f929f85), SPH_C32(0xf3be7830), SPH_C32(0x1d2f0000), + SPH_C32(0x807c0000), SPH_C32(0xc42b0000), SPH_C32(0xd6872c40), + SPH_C32(0xb230795e), SPH_C32(0xa85461af), SPH_C32(0x80290c87), + SPH_C32(0x6932c888) }, + { SPH_C32(0x11310000), SPH_C32(0x46630000), SPH_C32(0x45ae0000), + SPH_C32(0xbd1378a0), SPH_C32(0x0bca78c4), SPH_C32(0x48654a1e), + SPH_C32(0x7ce7672d), SPH_C32(0x72438138), SPH_C32(0xfb070000), + SPH_C32(0xcc370000), SPH_C32(0x6c7e0000), SPH_C32(0x05572ea0), + SPH_C32(0x6a5149e6), SPH_C32(0x30f3d175), SPH_C32(0xa8bc0a33), + SPH_C32(0xbe68801f) }, + { SPH_C32(0xf7190000), SPH_C32(0x0a280000), SPH_C32(0xedfb0000), + SPH_C32(0x6ec37a40), SPH_C32(0xd3ab487c), SPH_C32(0xd0c2fac4), + SPH_C32(0x54726199), SPH_C32(0xa519c9af), SPH_C32(0x0bc20000), + SPH_C32(0x95140000), SPH_C32(0x29fc0000), SPH_C32(0xe4da2e60), + SPH_C32(0x513c4fd7), SPH_C32(0xf21e87ec), SPH_C32(0x635cf42f), + SPH_C32(0xe8cf3180) }, + { SPH_C32(0x55c50000), SPH_C32(0x68730000), SPH_C32(0xb1710000), + SPH_C32(0x234e7c80), SPH_C32(0x48051fcd), SPH_C32(0x5b9edfda), + SPH_C32(0x65514db8), SPH_C32(0x6a8b4479), SPH_C32(0x0eec0000), + SPH_C32(0x649e0000), SPH_C32(0x06ba0000), SPH_C32(0x88f82ce0), + SPH_C32(0xa7e77575), SPH_C32(0xe70c0067), SPH_C32(0x380c599d), + SPH_C32(0x64436c2e) }, + { SPH_C32(0xb3ed0000), SPH_C32(0x24380000), SPH_C32(0x19240000), + SPH_C32(0xf09e7e60), SPH_C32(0x90642f75), SPH_C32(0xc3396f00), + SPH_C32(0x4dc44b0c), SPH_C32(0xbdd10cee), SPH_C32(0xfe290000), + SPH_C32(0x3dbd0000), SPH_C32(0x43380000), SPH_C32(0x69752c20), + SPH_C32(0x9c8a7344), SPH_C32(0x25e156fe), SPH_C32(0xf3eca781), + SPH_C32(0x32e4ddb1) }, + { SPH_C32(0xa5000000), SPH_C32(0x31500000), SPH_C32(0xf4f30000), + SPH_C32(0xc2c37c40), SPH_C32(0x736819fc), SPH_C32(0x99738943), + SPH_C32(0xaeb1b3a4), SPH_C32(0x3c2cf5e6), SPH_C32(0x18010000), + SPH_C32(0x71f60000), SPH_C32(0xeb6d0000), SPH_C32(0xbaa52ec0), + SPH_C32(0x44eb43fc), SPH_C32(0xbd46e624), SPH_C32(0xdb79a135), + SPH_C32(0xe5be9526) }, + { SPH_C32(0x43280000), SPH_C32(0x7d1b0000), SPH_C32(0x5ca60000), + SPH_C32(0x11137ea0), SPH_C32(0xab092944), SPH_C32(0x01d43999), + SPH_C32(0x8624b510), SPH_C32(0xeb76bd71), SPH_C32(0xe8c40000), + SPH_C32(0x28d50000), SPH_C32(0xaeef0000), SPH_C32(0x5b282e00), + SPH_C32(0x7f8645cd), SPH_C32(0x7fabb0bd), SPH_C32(0x10995f29), + SPH_C32(0xb31924b9) }, + { SPH_C32(0xbadd0000), SPH_C32(0x13ad0000), SPH_C32(0xb7e70000), + SPH_C32(0xf7282800), SPH_C32(0xdf45144d), SPH_C32(0x361ac33a), + SPH_C32(0xea5a8d14), SPH_C32(0x2a2c18f0), SPH_C32(0xb82f0000), + SPH_C32(0xb12c0000), SPH_C32(0x30d80000), SPH_C32(0x14445000), + SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), SPH_C32(0x2e98bf23), + SPH_C32(0x551e3d6e) }, + { SPH_C32(0x5cf50000), SPH_C32(0x5fe60000), SPH_C32(0x1fb20000), + SPH_C32(0x24f82ae0), SPH_C32(0x072424f5), SPH_C32(0xaebd73e0), + SPH_C32(0xc2cf8ba0), SPH_C32(0xfd765067), SPH_C32(0x48ea0000), + SPH_C32(0xe80f0000), SPH_C32(0x755a0000), SPH_C32(0xf5c950c0), + SPH_C32(0xfa356693), SPH_C32(0xf3cabe75), SPH_C32(0xe578413f), + SPH_C32(0x03b98cf1) }, + { SPH_C32(0x4a180000), SPH_C32(0x4a8e0000), SPH_C32(0xf2650000), + SPH_C32(0x16a528c0), SPH_C32(0xe428127c), SPH_C32(0xf4f795a3), + SPH_C32(0x21ba7308), SPH_C32(0x7c8ba96f), SPH_C32(0xaec20000), + SPH_C32(0xa4440000), SPH_C32(0xdd0f0000), SPH_C32(0x26195220), + SPH_C32(0x2254562b), SPH_C32(0x6b6d0eaf), SPH_C32(0xcded478b), + SPH_C32(0xd4e3c466) }, + { SPH_C32(0xac300000), SPH_C32(0x06c50000), SPH_C32(0x5a300000), + SPH_C32(0xc5752a20), SPH_C32(0x3c4922c4), SPH_C32(0x6c502579), + SPH_C32(0x092f75bc), SPH_C32(0xabd1e1f8), SPH_C32(0x5e070000), + SPH_C32(0xfd670000), SPH_C32(0x988d0000), SPH_C32(0xc79452e0), + SPH_C32(0x1939501a), SPH_C32(0xa9805836), SPH_C32(0x060db997), + SPH_C32(0x824475f9) }, + { SPH_C32(0x0eec0000), SPH_C32(0x649e0000), SPH_C32(0x06ba0000), + SPH_C32(0x88f82ce0), SPH_C32(0xa7e77575), SPH_C32(0xe70c0067), + SPH_C32(0x380c599d), SPH_C32(0x64436c2e), SPH_C32(0x5b290000), + SPH_C32(0x0ced0000), SPH_C32(0xb7cb0000), SPH_C32(0xabb65060), + SPH_C32(0xefe26ab8), SPH_C32(0xbc92dfbd), SPH_C32(0x5d5d1425), + SPH_C32(0x0ec82857) }, + { SPH_C32(0xe8c40000), SPH_C32(0x28d50000), SPH_C32(0xaeef0000), + SPH_C32(0x5b282e00), SPH_C32(0x7f8645cd), SPH_C32(0x7fabb0bd), + SPH_C32(0x10995f29), SPH_C32(0xb31924b9), SPH_C32(0xabec0000), + SPH_C32(0x55ce0000), SPH_C32(0xf2490000), SPH_C32(0x4a3b50a0), + SPH_C32(0xd48f6c89), SPH_C32(0x7e7f8924), SPH_C32(0x96bdea39), + SPH_C32(0x586f99c8) }, + { SPH_C32(0xfe290000), SPH_C32(0x3dbd0000), SPH_C32(0x43380000), + SPH_C32(0x69752c20), SPH_C32(0x9c8a7344), SPH_C32(0x25e156fe), + SPH_C32(0xf3eca781), SPH_C32(0x32e4ddb1), SPH_C32(0x4dc40000), + SPH_C32(0x19850000), SPH_C32(0x5a1c0000), SPH_C32(0x99eb5240), + SPH_C32(0x0cee5c31), SPH_C32(0xe6d839fe), SPH_C32(0xbe28ec8d), + SPH_C32(0x8f35d15f) }, + { SPH_C32(0x18010000), SPH_C32(0x71f60000), SPH_C32(0xeb6d0000), + SPH_C32(0xbaa52ec0), SPH_C32(0x44eb43fc), SPH_C32(0xbd46e624), + SPH_C32(0xdb79a135), SPH_C32(0xe5be9526), SPH_C32(0xbd010000), + SPH_C32(0x40a60000), SPH_C32(0x1f9e0000), SPH_C32(0x78665280), + SPH_C32(0x37835a00), SPH_C32(0x24356f67), SPH_C32(0x75c81291), + SPH_C32(0xd99260c0) }, + { SPH_C32(0x59db0000), SPH_C32(0xae6c0000), SPH_C32(0x30f40000), + SPH_C32(0x48da2860), SPH_C32(0xf1ff1e57), SPH_C32(0xbbaff46b), + SPH_C32(0x999f2612), SPH_C32(0x71fa0dc9), SPH_C32(0xef180000), + SPH_C32(0x7bde0000), SPH_C32(0x06960000), SPH_C32(0xd4665480), + SPH_C32(0x97400b80), SPH_C32(0x6d841ce0), SPH_C32(0x8f0bc0ac), + SPH_C32(0x40a75c89) }, + { SPH_C32(0xbff30000), SPH_C32(0xe2270000), SPH_C32(0x98a10000), + SPH_C32(0x9b0a2a80), SPH_C32(0x299e2eef), SPH_C32(0x230844b1), + SPH_C32(0xb10a20a6), SPH_C32(0xa6a0455e), SPH_C32(0x1fdd0000), + SPH_C32(0x22fd0000), SPH_C32(0x43140000), SPH_C32(0x35eb5440), + SPH_C32(0xac2d0db1), SPH_C32(0xaf694a79), SPH_C32(0x44eb3eb0), + SPH_C32(0x1600ed16) }, + { SPH_C32(0xa91e0000), SPH_C32(0xf74f0000), SPH_C32(0x75760000), + SPH_C32(0xa95728a0), SPH_C32(0xca921866), SPH_C32(0x7942a2f2), + SPH_C32(0x527fd80e), SPH_C32(0x275dbc56), SPH_C32(0xf9f50000), + SPH_C32(0x6eb60000), SPH_C32(0xeb410000), SPH_C32(0xe63b56a0), + SPH_C32(0x744c3d09), SPH_C32(0x37cefaa3), SPH_C32(0x6c7e3804), + SPH_C32(0xc15aa581) }, + { SPH_C32(0x4f360000), SPH_C32(0xbb040000), SPH_C32(0xdd230000), + SPH_C32(0x7a872a40), SPH_C32(0x12f328de), SPH_C32(0xe1e51228), + SPH_C32(0x7aeadeba), SPH_C32(0xf007f4c1), SPH_C32(0x09300000), + SPH_C32(0x37950000), SPH_C32(0xaec30000), SPH_C32(0x07b65660), + SPH_C32(0x4f213b38), SPH_C32(0xf523ac3a), SPH_C32(0xa79ec618), + SPH_C32(0x97fd141e) }, + { SPH_C32(0xedea0000), SPH_C32(0xd95f0000), SPH_C32(0x81a90000), + SPH_C32(0x370a2c80), SPH_C32(0x895d7f6f), SPH_C32(0x6ab93736), + SPH_C32(0x4bc9f29b), SPH_C32(0x3f957917), SPH_C32(0x0c1e0000), + SPH_C32(0xc61f0000), SPH_C32(0x81850000), SPH_C32(0x6b9454e0), + SPH_C32(0xb9fa019a), SPH_C32(0xe0312bb1), SPH_C32(0xfcce6baa), + SPH_C32(0x1b7149b0) }, + { SPH_C32(0x0bc20000), SPH_C32(0x95140000), SPH_C32(0x29fc0000), + SPH_C32(0xe4da2e60), SPH_C32(0x513c4fd7), SPH_C32(0xf21e87ec), + SPH_C32(0x635cf42f), SPH_C32(0xe8cf3180), SPH_C32(0xfcdb0000), + SPH_C32(0x9f3c0000), SPH_C32(0xc4070000), SPH_C32(0x8a195420), + SPH_C32(0x829707ab), SPH_C32(0x22dc7d28), SPH_C32(0x372e95b6), + SPH_C32(0x4dd6f82f) }, + { SPH_C32(0x1d2f0000), SPH_C32(0x807c0000), SPH_C32(0xc42b0000), + SPH_C32(0xd6872c40), SPH_C32(0xb230795e), SPH_C32(0xa85461af), + SPH_C32(0x80290c87), SPH_C32(0x6932c888), SPH_C32(0x1af30000), + SPH_C32(0xd3770000), SPH_C32(0x6c520000), SPH_C32(0x59c956c0), + SPH_C32(0x5af63713), SPH_C32(0xba7bcdf2), SPH_C32(0x1fbb9302), + SPH_C32(0x9a8cb0b8) }, + { SPH_C32(0xfb070000), SPH_C32(0xcc370000), SPH_C32(0x6c7e0000), + SPH_C32(0x05572ea0), SPH_C32(0x6a5149e6), SPH_C32(0x30f3d175), + SPH_C32(0xa8bc0a33), SPH_C32(0xbe68801f), SPH_C32(0xea360000), + SPH_C32(0x8a540000), SPH_C32(0x29d00000), SPH_C32(0xb8445600), + SPH_C32(0x619b3122), SPH_C32(0x78969b6b), SPH_C32(0xd45b6d1e), + SPH_C32(0xcc2b0127) }, + { SPH_C32(0xb82f0000), SPH_C32(0xb12c0000), SPH_C32(0x30d80000), + SPH_C32(0x14445000), SPH_C32(0xc15860a2), SPH_C32(0x3127e8ec), + SPH_C32(0x2e98bf23), SPH_C32(0x551e3d6e), SPH_C32(0x02f20000), + SPH_C32(0xa2810000), SPH_C32(0x873f0000), SPH_C32(0xe36c7800), + SPH_C32(0x1e1d74ef), SPH_C32(0x073d2bd6), SPH_C32(0xc4c23237), + SPH_C32(0x7f32259e) }, + { SPH_C32(0x5e070000), SPH_C32(0xfd670000), SPH_C32(0x988d0000), + SPH_C32(0xc79452e0), SPH_C32(0x1939501a), SPH_C32(0xa9805836), + SPH_C32(0x060db997), SPH_C32(0x824475f9), SPH_C32(0xf2370000), + SPH_C32(0xfba20000), SPH_C32(0xc2bd0000), SPH_C32(0x02e178c0), + SPH_C32(0x257072de), SPH_C32(0xc5d07d4f), SPH_C32(0x0f22cc2b), + SPH_C32(0x29959401) }, + { SPH_C32(0x48ea0000), SPH_C32(0xe80f0000), SPH_C32(0x755a0000), + SPH_C32(0xf5c950c0), SPH_C32(0xfa356693), SPH_C32(0xf3cabe75), + SPH_C32(0xe578413f), SPH_C32(0x03b98cf1), SPH_C32(0x141f0000), + SPH_C32(0xb7e90000), SPH_C32(0x6ae80000), SPH_C32(0xd1317a20), + SPH_C32(0xfd114266), SPH_C32(0x5d77cd95), SPH_C32(0x27b7ca9f), + SPH_C32(0xfecfdc96) }, + { SPH_C32(0xaec20000), SPH_C32(0xa4440000), SPH_C32(0xdd0f0000), + SPH_C32(0x26195220), SPH_C32(0x2254562b), SPH_C32(0x6b6d0eaf), + SPH_C32(0xcded478b), SPH_C32(0xd4e3c466), SPH_C32(0xe4da0000), + SPH_C32(0xeeca0000), SPH_C32(0x2f6a0000), SPH_C32(0x30bc7ae0), + SPH_C32(0xc67c4457), SPH_C32(0x9f9a9b0c), SPH_C32(0xec573483), + SPH_C32(0xa8686d09) }, + { SPH_C32(0x0c1e0000), SPH_C32(0xc61f0000), SPH_C32(0x81850000), + SPH_C32(0x6b9454e0), SPH_C32(0xb9fa019a), SPH_C32(0xe0312bb1), + SPH_C32(0xfcce6baa), SPH_C32(0x1b7149b0), SPH_C32(0xe1f40000), + SPH_C32(0x1f400000), SPH_C32(0x002c0000), SPH_C32(0x5c9e7860), + SPH_C32(0x30a77ef5), SPH_C32(0x8a881c87), SPH_C32(0xb7079931), + SPH_C32(0x24e430a7) }, + { SPH_C32(0xea360000), SPH_C32(0x8a540000), SPH_C32(0x29d00000), + SPH_C32(0xb8445600), SPH_C32(0x619b3122), SPH_C32(0x78969b6b), + SPH_C32(0xd45b6d1e), SPH_C32(0xcc2b0127), SPH_C32(0x11310000), + SPH_C32(0x46630000), SPH_C32(0x45ae0000), SPH_C32(0xbd1378a0), + SPH_C32(0x0bca78c4), SPH_C32(0x48654a1e), SPH_C32(0x7ce7672d), + SPH_C32(0x72438138) }, + { SPH_C32(0xfcdb0000), SPH_C32(0x9f3c0000), SPH_C32(0xc4070000), + SPH_C32(0x8a195420), SPH_C32(0x829707ab), SPH_C32(0x22dc7d28), + SPH_C32(0x372e95b6), SPH_C32(0x4dd6f82f), SPH_C32(0xf7190000), + SPH_C32(0x0a280000), SPH_C32(0xedfb0000), SPH_C32(0x6ec37a40), + SPH_C32(0xd3ab487c), SPH_C32(0xd0c2fac4), SPH_C32(0x54726199), + SPH_C32(0xa519c9af) }, + { SPH_C32(0x1af30000), SPH_C32(0xd3770000), SPH_C32(0x6c520000), + SPH_C32(0x59c956c0), SPH_C32(0x5af63713), SPH_C32(0xba7bcdf2), + SPH_C32(0x1fbb9302), SPH_C32(0x9a8cb0b8), SPH_C32(0x07dc0000), + SPH_C32(0x530b0000), SPH_C32(0xa8790000), SPH_C32(0x8f4e7a80), + SPH_C32(0xe8c64e4d), SPH_C32(0x122fac5d), SPH_C32(0x9f929f85), + SPH_C32(0xf3be7830) }, + { SPH_C32(0x5b290000), SPH_C32(0x0ced0000), SPH_C32(0xb7cb0000), + SPH_C32(0xabb65060), SPH_C32(0xefe26ab8), SPH_C32(0xbc92dfbd), + SPH_C32(0x5d5d1425), SPH_C32(0x0ec82857), SPH_C32(0x55c50000), + SPH_C32(0x68730000), SPH_C32(0xb1710000), SPH_C32(0x234e7c80), + SPH_C32(0x48051fcd), SPH_C32(0x5b9edfda), SPH_C32(0x65514db8), + SPH_C32(0x6a8b4479) }, + { SPH_C32(0xbd010000), SPH_C32(0x40a60000), SPH_C32(0x1f9e0000), + SPH_C32(0x78665280), SPH_C32(0x37835a00), SPH_C32(0x24356f67), + SPH_C32(0x75c81291), SPH_C32(0xd99260c0), SPH_C32(0xa5000000), + SPH_C32(0x31500000), SPH_C32(0xf4f30000), SPH_C32(0xc2c37c40), + SPH_C32(0x736819fc), SPH_C32(0x99738943), SPH_C32(0xaeb1b3a4), + SPH_C32(0x3c2cf5e6) }, + { SPH_C32(0xabec0000), SPH_C32(0x55ce0000), SPH_C32(0xf2490000), + SPH_C32(0x4a3b50a0), SPH_C32(0xd48f6c89), SPH_C32(0x7e7f8924), + SPH_C32(0x96bdea39), SPH_C32(0x586f99c8), SPH_C32(0x43280000), + SPH_C32(0x7d1b0000), SPH_C32(0x5ca60000), SPH_C32(0x11137ea0), + SPH_C32(0xab092944), SPH_C32(0x01d43999), SPH_C32(0x8624b510), + SPH_C32(0xeb76bd71) }, + { SPH_C32(0x4dc40000), SPH_C32(0x19850000), SPH_C32(0x5a1c0000), + SPH_C32(0x99eb5240), SPH_C32(0x0cee5c31), SPH_C32(0xe6d839fe), + SPH_C32(0xbe28ec8d), SPH_C32(0x8f35d15f), SPH_C32(0xb3ed0000), + SPH_C32(0x24380000), SPH_C32(0x19240000), SPH_C32(0xf09e7e60), + SPH_C32(0x90642f75), SPH_C32(0xc3396f00), SPH_C32(0x4dc44b0c), + SPH_C32(0xbdd10cee) }, + { SPH_C32(0xef180000), SPH_C32(0x7bde0000), SPH_C32(0x06960000), + SPH_C32(0xd4665480), SPH_C32(0x97400b80), SPH_C32(0x6d841ce0), + SPH_C32(0x8f0bc0ac), SPH_C32(0x40a75c89), SPH_C32(0xb6c30000), + SPH_C32(0xd5b20000), SPH_C32(0x36620000), SPH_C32(0x9cbc7ce0), + SPH_C32(0x66bf15d7), SPH_C32(0xd62be88b), SPH_C32(0x1694e6be), + SPH_C32(0x315d5140) }, + { SPH_C32(0x09300000), SPH_C32(0x37950000), SPH_C32(0xaec30000), + SPH_C32(0x07b65660), SPH_C32(0x4f213b38), SPH_C32(0xf523ac3a), + SPH_C32(0xa79ec618), SPH_C32(0x97fd141e), SPH_C32(0x46060000), + SPH_C32(0x8c910000), SPH_C32(0x73e00000), SPH_C32(0x7d317c20), + SPH_C32(0x5dd213e6), SPH_C32(0x14c6be12), SPH_C32(0xdd7418a2), + SPH_C32(0x67fae0df) }, + { SPH_C32(0x1fdd0000), SPH_C32(0x22fd0000), SPH_C32(0x43140000), + SPH_C32(0x35eb5440), SPH_C32(0xac2d0db1), SPH_C32(0xaf694a79), + SPH_C32(0x44eb3eb0), SPH_C32(0x1600ed16), SPH_C32(0xa02e0000), + SPH_C32(0xc0da0000), SPH_C32(0xdbb50000), SPH_C32(0xaee17ec0), + SPH_C32(0x85b3235e), SPH_C32(0x8c610ec8), SPH_C32(0xf5e11e16), + SPH_C32(0xb0a0a848) }, + { SPH_C32(0xf9f50000), SPH_C32(0x6eb60000), SPH_C32(0xeb410000), + SPH_C32(0xe63b56a0), SPH_C32(0x744c3d09), SPH_C32(0x37cefaa3), + SPH_C32(0x6c7e3804), SPH_C32(0xc15aa581), SPH_C32(0x50eb0000), + SPH_C32(0x99f90000), SPH_C32(0x9e370000), SPH_C32(0x4f6c7e00), + SPH_C32(0xbede256f), SPH_C32(0x4e8c5851), SPH_C32(0x3e01e00a), + SPH_C32(0xe60719d7) }, + { SPH_C32(0x1e6c0000), SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), + SPH_C32(0xbcb6b800), SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), + SPH_C32(0x6a0c1bc8), SPH_C32(0xb99dc2eb), SPH_C32(0x92560000), + SPH_C32(0x1eda0000), SPH_C32(0xea510000), SPH_C32(0xe8b13000), + SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), SPH_C32(0xb15c2254), + SPH_C32(0x33c5244f) }, + { SPH_C32(0xf8440000), SPH_C32(0x88090000), SPH_C32(0x227b0000), + SPH_C32(0x6f66bae0), SPH_C32(0xf425230e), SPH_C32(0x135a6300), + SPH_C32(0x42991d7c), SPH_C32(0x6ec78a7c), SPH_C32(0x62930000), + SPH_C32(0x47f90000), SPH_C32(0xafd30000), SPH_C32(0x093c30c0), + SPH_C32(0x92585094), SPH_C32(0x29163700), SPH_C32(0x7abcdc48), + SPH_C32(0x656295d0) }, + { SPH_C32(0xeea90000), SPH_C32(0x9d610000), SPH_C32(0xcfac0000), + SPH_C32(0x5d3bb8c0), SPH_C32(0x17291587), SPH_C32(0x49108543), + SPH_C32(0xa1ece5d4), SPH_C32(0xef3a7374), SPH_C32(0x84bb0000), + SPH_C32(0x0bb20000), SPH_C32(0x07860000), SPH_C32(0xdaec3220), + SPH_C32(0x4a39602c), SPH_C32(0xb1b187da), SPH_C32(0x5229dafc), + SPH_C32(0xb238dd47) }, + { SPH_C32(0x08810000), SPH_C32(0xd12a0000), SPH_C32(0x67f90000), + SPH_C32(0x8eebba20), SPH_C32(0xcf48253f), SPH_C32(0xd1b73599), + SPH_C32(0x8979e360), SPH_C32(0x38603be3), SPH_C32(0x747e0000), + SPH_C32(0x52910000), SPH_C32(0x42040000), SPH_C32(0x3b6132e0), + SPH_C32(0x7154661d), SPH_C32(0x735cd143), SPH_C32(0x99c924e0), + SPH_C32(0xe49f6cd8) }, + { SPH_C32(0xaa5d0000), SPH_C32(0xb3710000), SPH_C32(0x3b730000), + SPH_C32(0xc366bce0), SPH_C32(0x54e6728e), SPH_C32(0x5aeb1087), + SPH_C32(0xb85acf41), SPH_C32(0xf7f2b635), SPH_C32(0x71500000), + SPH_C32(0xa31b0000), SPH_C32(0x6d420000), SPH_C32(0x57433060), + SPH_C32(0x878f5cbf), SPH_C32(0x664e56c8), SPH_C32(0xc2998952), + SPH_C32(0x68133176) }, + { SPH_C32(0x4c750000), SPH_C32(0xff3a0000), SPH_C32(0x93260000), + SPH_C32(0x10b6be00), SPH_C32(0x8c874236), SPH_C32(0xc24ca05d), + SPH_C32(0x90cfc9f5), SPH_C32(0x20a8fea2), SPH_C32(0x81950000), + SPH_C32(0xfa380000), SPH_C32(0x28c00000), SPH_C32(0xb6ce30a0), + SPH_C32(0xbce25a8e), SPH_C32(0xa4a30051), SPH_C32(0x0979774e), + SPH_C32(0x3eb480e9) }, + { SPH_C32(0x5a980000), SPH_C32(0xea520000), SPH_C32(0x7ef10000), + SPH_C32(0x22ebbc20), SPH_C32(0x6f8b74bf), SPH_C32(0x9806461e), + SPH_C32(0x73ba315d), SPH_C32(0xa15507aa), SPH_C32(0x67bd0000), + SPH_C32(0xb6730000), SPH_C32(0x80950000), SPH_C32(0x651e3240), + SPH_C32(0x64836a36), SPH_C32(0x3c04b08b), SPH_C32(0x21ec71fa), + SPH_C32(0xe9eec87e) }, + { SPH_C32(0xbcb00000), SPH_C32(0xa6190000), SPH_C32(0xd6a40000), + SPH_C32(0xf13bbec0), SPH_C32(0xb7ea4407), SPH_C32(0x00a1f6c4), + SPH_C32(0x5b2f37e9), SPH_C32(0x760f4f3d), SPH_C32(0x97780000), + SPH_C32(0xef500000), SPH_C32(0xc5170000), SPH_C32(0x84933280), + SPH_C32(0x5fee6c07), SPH_C32(0xfee9e612), SPH_C32(0xea0c8fe6), + SPH_C32(0xbf4979e1) }, + { SPH_C32(0xfd6a0000), SPH_C32(0x79830000), SPH_C32(0x0d3d0000), + SPH_C32(0x0344b860), SPH_C32(0x02fe19ac), SPH_C32(0x0648e48b), + SPH_C32(0x19c9b0ce), SPH_C32(0xe24bd7d2), SPH_C32(0xc5610000), + SPH_C32(0xd4280000), SPH_C32(0xdc1f0000), SPH_C32(0x28933480), + SPH_C32(0xff2d3d87), SPH_C32(0xb7589595), SPH_C32(0x10cf5ddb), + SPH_C32(0x267c45a8) }, + { SPH_C32(0x1b420000), SPH_C32(0x35c80000), SPH_C32(0xa5680000), + SPH_C32(0xd094ba80), SPH_C32(0xda9f2914), SPH_C32(0x9eef5451), + SPH_C32(0x315cb67a), SPH_C32(0x35119f45), SPH_C32(0x35a40000), + SPH_C32(0x8d0b0000), SPH_C32(0x999d0000), SPH_C32(0xc91e3440), + SPH_C32(0xc4403bb6), SPH_C32(0x75b5c30c), SPH_C32(0xdb2fa3c7), + SPH_C32(0x70dbf437) }, + { SPH_C32(0x0daf0000), SPH_C32(0x20a00000), SPH_C32(0x48bf0000), + SPH_C32(0xe2c9b8a0), SPH_C32(0x39931f9d), SPH_C32(0xc4a5b212), + SPH_C32(0xd2294ed2), SPH_C32(0xb4ec664d), SPH_C32(0xd38c0000), + SPH_C32(0xc1400000), SPH_C32(0x31c80000), SPH_C32(0x1ace36a0), + SPH_C32(0x1c210b0e), SPH_C32(0xed1273d6), SPH_C32(0xf3baa573), + SPH_C32(0xa781bca0) }, + { SPH_C32(0xeb870000), SPH_C32(0x6ceb0000), SPH_C32(0xe0ea0000), + SPH_C32(0x3119ba40), SPH_C32(0xe1f22f25), SPH_C32(0x5c0202c8), + SPH_C32(0xfabc4866), SPH_C32(0x63b62eda), SPH_C32(0x23490000), + SPH_C32(0x98630000), SPH_C32(0x744a0000), SPH_C32(0xfb433660), + SPH_C32(0x274c0d3f), SPH_C32(0x2fff254f), SPH_C32(0x385a5b6f), + SPH_C32(0xf1260d3f) }, + { SPH_C32(0x495b0000), SPH_C32(0x0eb00000), SPH_C32(0xbc600000), + SPH_C32(0x7c94bc80), SPH_C32(0x7a5c7894), SPH_C32(0xd75e27d6), + SPH_C32(0xcb9f6447), SPH_C32(0xac24a30c), SPH_C32(0x26670000), + SPH_C32(0x69e90000), SPH_C32(0x5b0c0000), SPH_C32(0x976134e0), + SPH_C32(0xd197379d), SPH_C32(0x3aeda2c4), SPH_C32(0x630af6dd), + SPH_C32(0x7daa5091) }, + { SPH_C32(0xaf730000), SPH_C32(0x42fb0000), SPH_C32(0x14350000), + SPH_C32(0xaf44be60), SPH_C32(0xa23d482c), SPH_C32(0x4ff9970c), + SPH_C32(0xe30a62f3), SPH_C32(0x7b7eeb9b), SPH_C32(0xd6a20000), + SPH_C32(0x30ca0000), SPH_C32(0x1e8e0000), SPH_C32(0x76ec3420), + SPH_C32(0xeafa31ac), SPH_C32(0xf800f45d), SPH_C32(0xa8ea08c1), + SPH_C32(0x2b0de10e) }, + { SPH_C32(0xb99e0000), SPH_C32(0x57930000), SPH_C32(0xf9e20000), + SPH_C32(0x9d19bc40), SPH_C32(0x41317ea5), SPH_C32(0x15b3714f), + SPH_C32(0x007f9a5b), SPH_C32(0xfa831293), SPH_C32(0x308a0000), + SPH_C32(0x7c810000), SPH_C32(0xb6db0000), SPH_C32(0xa53c36c0), + SPH_C32(0x329b0114), SPH_C32(0x60a74487), SPH_C32(0x807f0e75), + SPH_C32(0xfc57a999) }, + { SPH_C32(0x5fb60000), SPH_C32(0x1bd80000), SPH_C32(0x51b70000), + SPH_C32(0x4ec9bea0), SPH_C32(0x99504e1d), SPH_C32(0x8d14c195), + SPH_C32(0x28ea9cef), SPH_C32(0x2dd95a04), SPH_C32(0xc04f0000), + SPH_C32(0x25a20000), SPH_C32(0xf3590000), SPH_C32(0x44b13600), + SPH_C32(0x09f60725), SPH_C32(0xa24a121e), SPH_C32(0x4b9ff069), + SPH_C32(0xaaf01806) }, + { SPH_C32(0x1c9e0000), SPH_C32(0x66c30000), SPH_C32(0x0d110000), + SPH_C32(0x5fdac000), SPH_C32(0x32596759), SPH_C32(0x8cc0f80c), + SPH_C32(0xaece29ff), SPH_C32(0xc6afe775), SPH_C32(0x288b0000), + SPH_C32(0x0d770000), SPH_C32(0x5db60000), SPH_C32(0x1f991800), + SPH_C32(0x767042e8), SPH_C32(0xdde1a2a3), SPH_C32(0x5b06af40), + SPH_C32(0x19e93cbf) }, + { SPH_C32(0xfab60000), SPH_C32(0x2a880000), SPH_C32(0xa5440000), + SPH_C32(0x8c0ac2e0), SPH_C32(0xea3857e1), SPH_C32(0x146748d6), + SPH_C32(0x865b2f4b), SPH_C32(0x11f5afe2), SPH_C32(0xd84e0000), + SPH_C32(0x54540000), SPH_C32(0x18340000), SPH_C32(0xfe1418c0), + SPH_C32(0x4d1d44d9), SPH_C32(0x1f0cf43a), SPH_C32(0x90e6515c), + SPH_C32(0x4f4e8d20) }, + { SPH_C32(0xec5b0000), SPH_C32(0x3fe00000), SPH_C32(0x48930000), + SPH_C32(0xbe57c0c0), SPH_C32(0x09346168), SPH_C32(0x4e2dae95), + SPH_C32(0x652ed7e3), SPH_C32(0x900856ea), SPH_C32(0x3e660000), + SPH_C32(0x181f0000), SPH_C32(0xb0610000), SPH_C32(0x2dc41a20), + SPH_C32(0x957c7461), SPH_C32(0x87ab44e0), SPH_C32(0xb87357e8), + SPH_C32(0x9814c5b7) }, + { SPH_C32(0x0a730000), SPH_C32(0x73ab0000), SPH_C32(0xe0c60000), + SPH_C32(0x6d87c220), SPH_C32(0xd15551d0), SPH_C32(0xd68a1e4f), + SPH_C32(0x4dbbd157), SPH_C32(0x47521e7d), SPH_C32(0xcea30000), + SPH_C32(0x413c0000), SPH_C32(0xf5e30000), SPH_C32(0xcc491ae0), + SPH_C32(0xae117250), SPH_C32(0x45461279), SPH_C32(0x7393a9f4), + SPH_C32(0xceb37428) }, + { SPH_C32(0xa8af0000), SPH_C32(0x11f00000), SPH_C32(0xbc4c0000), + SPH_C32(0x200ac4e0), SPH_C32(0x4afb0661), SPH_C32(0x5dd63b51), + SPH_C32(0x7c98fd76), SPH_C32(0x88c093ab), SPH_C32(0xcb8d0000), + SPH_C32(0xb0b60000), SPH_C32(0xdaa50000), SPH_C32(0xa06b1860), + SPH_C32(0x58ca48f2), SPH_C32(0x505495f2), SPH_C32(0x28c30446), + SPH_C32(0x423f2986) }, + { SPH_C32(0x4e870000), SPH_C32(0x5dbb0000), SPH_C32(0x14190000), + SPH_C32(0xf3dac600), SPH_C32(0x929a36d9), SPH_C32(0xc5718b8b), + SPH_C32(0x540dfbc2), SPH_C32(0x5f9adb3c), SPH_C32(0x3b480000), + SPH_C32(0xe9950000), SPH_C32(0x9f270000), SPH_C32(0x41e618a0), + SPH_C32(0x63a74ec3), SPH_C32(0x92b9c36b), SPH_C32(0xe323fa5a), + SPH_C32(0x14989819) }, + { SPH_C32(0x586a0000), SPH_C32(0x48d30000), SPH_C32(0xf9ce0000), + SPH_C32(0xc187c420), SPH_C32(0x71960050), SPH_C32(0x9f3b6dc8), + SPH_C32(0xb778036a), SPH_C32(0xde672234), SPH_C32(0xdd600000), + SPH_C32(0xa5de0000), SPH_C32(0x37720000), SPH_C32(0x92361a40), + SPH_C32(0xbbc67e7b), SPH_C32(0x0a1e73b1), SPH_C32(0xcbb6fcee), + SPH_C32(0xc3c2d08e) }, + { SPH_C32(0xbe420000), SPH_C32(0x04980000), SPH_C32(0x519b0000), + SPH_C32(0x1257c6c0), SPH_C32(0xa9f730e8), SPH_C32(0x079cdd12), + SPH_C32(0x9fed05de), SPH_C32(0x093d6aa3), SPH_C32(0x2da50000), + SPH_C32(0xfcfd0000), SPH_C32(0x72f00000), SPH_C32(0x73bb1a80), + SPH_C32(0x80ab784a), SPH_C32(0xc8f32528), SPH_C32(0x005602f2), + SPH_C32(0x95656111) }, + { SPH_C32(0xff980000), SPH_C32(0xdb020000), SPH_C32(0x8a020000), + SPH_C32(0xe028c060), SPH_C32(0x1ce36d43), SPH_C32(0x0175cf5d), + SPH_C32(0xdd0b82f9), SPH_C32(0x9d79f24c), SPH_C32(0x7fbc0000), + SPH_C32(0xc7850000), SPH_C32(0x6bf80000), SPH_C32(0xdfbb1c80), + SPH_C32(0x206829ca), SPH_C32(0x814256af), SPH_C32(0xfa95d0cf), + SPH_C32(0x0c505d58) }, + { SPH_C32(0x19b00000), SPH_C32(0x97490000), SPH_C32(0x22570000), + SPH_C32(0x33f8c280), SPH_C32(0xc4825dfb), SPH_C32(0x99d27f87), + SPH_C32(0xf59e844d), SPH_C32(0x4a23badb), SPH_C32(0x8f790000), + SPH_C32(0x9ea60000), SPH_C32(0x2e7a0000), SPH_C32(0x3e361c40), + SPH_C32(0x1b052ffb), SPH_C32(0x43af0036), SPH_C32(0x31752ed3), + SPH_C32(0x5af7ecc7) }, + { SPH_C32(0x0f5d0000), SPH_C32(0x82210000), SPH_C32(0xcf800000), + SPH_C32(0x01a5c0a0), SPH_C32(0x278e6b72), SPH_C32(0xc39899c4), + SPH_C32(0x16eb7ce5), SPH_C32(0xcbde43d3), SPH_C32(0x69510000), + SPH_C32(0xd2ed0000), SPH_C32(0x862f0000), SPH_C32(0xede61ea0), + SPH_C32(0xc3641f43), SPH_C32(0xdb08b0ec), SPH_C32(0x19e02867), + SPH_C32(0x8dada450) }, + { SPH_C32(0xe9750000), SPH_C32(0xce6a0000), SPH_C32(0x67d50000), + SPH_C32(0xd275c240), SPH_C32(0xffef5bca), SPH_C32(0x5b3f291e), + SPH_C32(0x3e7e7a51), SPH_C32(0x1c840b44), SPH_C32(0x99940000), + SPH_C32(0x8bce0000), SPH_C32(0xc3ad0000), SPH_C32(0x0c6b1e60), + SPH_C32(0xf8091972), SPH_C32(0x19e5e675), SPH_C32(0xd200d67b), + SPH_C32(0xdb0a15cf) }, + { SPH_C32(0x4ba90000), SPH_C32(0xac310000), SPH_C32(0x3b5f0000), + SPH_C32(0x9ff8c480), SPH_C32(0x64410c7b), SPH_C32(0xd0630c00), + SPH_C32(0x0f5d5670), SPH_C32(0xd3168692), SPH_C32(0x9cba0000), + SPH_C32(0x7a440000), SPH_C32(0xeceb0000), SPH_C32(0x60491ce0), + SPH_C32(0x0ed223d0), SPH_C32(0x0cf761fe), SPH_C32(0x89507bc9), + SPH_C32(0x57864861) }, + { SPH_C32(0xad810000), SPH_C32(0xe07a0000), SPH_C32(0x930a0000), + SPH_C32(0x4c28c660), SPH_C32(0xbc203cc3), SPH_C32(0x48c4bcda), + SPH_C32(0x27c850c4), SPH_C32(0x044cce05), SPH_C32(0x6c7f0000), + SPH_C32(0x23670000), SPH_C32(0xa9690000), SPH_C32(0x81c41c20), + SPH_C32(0x35bf25e1), SPH_C32(0xce1a3767), SPH_C32(0x42b085d5), + SPH_C32(0x0121f9fe) }, + { SPH_C32(0xbb6c0000), SPH_C32(0xf5120000), SPH_C32(0x7edd0000), + SPH_C32(0x7e75c440), SPH_C32(0x5f2c0a4a), SPH_C32(0x128e5a99), + SPH_C32(0xc4bda86c), SPH_C32(0x85b1370d), SPH_C32(0x8a570000), + SPH_C32(0x6f2c0000), SPH_C32(0x013c0000), SPH_C32(0x52141ec0), + SPH_C32(0xedde1559), SPH_C32(0x56bd87bd), SPH_C32(0x6a258361), + SPH_C32(0xd67bb169) }, + { SPH_C32(0x5d440000), SPH_C32(0xb9590000), SPH_C32(0xd6880000), + SPH_C32(0xada5c6a0), SPH_C32(0x874d3af2), SPH_C32(0x8a29ea43), + SPH_C32(0xec28aed8), SPH_C32(0x52eb7f9a), SPH_C32(0x7a920000), + SPH_C32(0x360f0000), SPH_C32(0x44be0000), SPH_C32(0xb3991e00), + SPH_C32(0xd6b31368), SPH_C32(0x9450d124), SPH_C32(0xa1c57d7d), + SPH_C32(0x80dc00f6) }, + { SPH_C32(0xa4b10000), SPH_C32(0xd7ef0000), SPH_C32(0x3dc90000), + SPH_C32(0x4b9e9000), SPH_C32(0xf30107fb), SPH_C32(0xbde710e0), + SPH_C32(0x805696dc), SPH_C32(0x93b1da1b), SPH_C32(0x2a790000), + SPH_C32(0xaff60000), SPH_C32(0xda890000), SPH_C32(0xfcf56000), + SPH_C32(0x686d3607), SPH_C32(0xdadc8975), SPH_C32(0x9fc49d77), + SPH_C32(0x66db1921) }, + { SPH_C32(0x42990000), SPH_C32(0x9ba40000), SPH_C32(0x959c0000), + SPH_C32(0x984e92e0), SPH_C32(0x2b603743), SPH_C32(0x2540a03a), + SPH_C32(0xa8c39068), SPH_C32(0x44eb928c), SPH_C32(0xdabc0000), + SPH_C32(0xf6d50000), SPH_C32(0x9f0b0000), SPH_C32(0x1d7860c0), + SPH_C32(0x53003036), SPH_C32(0x1831dfec), SPH_C32(0x5424636b), + SPH_C32(0x307ca8be) }, + { SPH_C32(0x54740000), SPH_C32(0x8ecc0000), SPH_C32(0x784b0000), + SPH_C32(0xaa1390c0), SPH_C32(0xc86c01ca), SPH_C32(0x7f0a4679), + SPH_C32(0x4bb668c0), SPH_C32(0xc5166b84), SPH_C32(0x3c940000), + SPH_C32(0xba9e0000), SPH_C32(0x375e0000), SPH_C32(0xcea86220), + SPH_C32(0x8b61008e), SPH_C32(0x80966f36), SPH_C32(0x7cb165df), + SPH_C32(0xe726e029) }, + { SPH_C32(0xb25c0000), SPH_C32(0xc2870000), SPH_C32(0xd01e0000), + SPH_C32(0x79c39220), SPH_C32(0x100d3172), SPH_C32(0xe7adf6a3), + SPH_C32(0x63236e74), SPH_C32(0x124c2313), SPH_C32(0xcc510000), + SPH_C32(0xe3bd0000), SPH_C32(0x72dc0000), SPH_C32(0x2f2562e0), + SPH_C32(0xb00c06bf), SPH_C32(0x427b39af), SPH_C32(0xb7519bc3), + SPH_C32(0xb18151b6) }, + { SPH_C32(0x10800000), SPH_C32(0xa0dc0000), SPH_C32(0x8c940000), + SPH_C32(0x344e94e0), SPH_C32(0x8ba366c3), SPH_C32(0x6cf1d3bd), + SPH_C32(0x52004255), SPH_C32(0xdddeaec5), SPH_C32(0xc97f0000), + SPH_C32(0x12370000), SPH_C32(0x5d9a0000), SPH_C32(0x43076060), + SPH_C32(0x46d73c1d), SPH_C32(0x5769be24), SPH_C32(0xec013671), + SPH_C32(0x3d0d0c18) }, + { SPH_C32(0xf6a80000), SPH_C32(0xec970000), SPH_C32(0x24c10000), + SPH_C32(0xe79e9600), SPH_C32(0x53c2567b), SPH_C32(0xf4566367), + SPH_C32(0x7a9544e1), SPH_C32(0x0a84e652), SPH_C32(0x39ba0000), + SPH_C32(0x4b140000), SPH_C32(0x18180000), SPH_C32(0xa28a60a0), + SPH_C32(0x7dba3a2c), SPH_C32(0x9584e8bd), SPH_C32(0x27e1c86d), + SPH_C32(0x6baabd87) }, + { SPH_C32(0xe0450000), SPH_C32(0xf9ff0000), SPH_C32(0xc9160000), + SPH_C32(0xd5c39420), SPH_C32(0xb0ce60f2), SPH_C32(0xae1c8524), + SPH_C32(0x99e0bc49), SPH_C32(0x8b791f5a), SPH_C32(0xdf920000), + SPH_C32(0x075f0000), SPH_C32(0xb04d0000), SPH_C32(0x715a6240), + SPH_C32(0xa5db0a94), SPH_C32(0x0d235867), SPH_C32(0x0f74ced9), + SPH_C32(0xbcf0f510) }, + { SPH_C32(0x066d0000), SPH_C32(0xb5b40000), SPH_C32(0x61430000), + SPH_C32(0x061396c0), SPH_C32(0x68af504a), SPH_C32(0x36bb35fe), + SPH_C32(0xb175bafd), SPH_C32(0x5c2357cd), SPH_C32(0x2f570000), + SPH_C32(0x5e7c0000), SPH_C32(0xf5cf0000), SPH_C32(0x90d76280), + SPH_C32(0x9eb60ca5), SPH_C32(0xcfce0efe), SPH_C32(0xc49430c5), + SPH_C32(0xea57448f) }, + { SPH_C32(0x47b70000), SPH_C32(0x6a2e0000), SPH_C32(0xbada0000), + SPH_C32(0xf46c9060), SPH_C32(0xddbb0de1), SPH_C32(0x305227b1), + SPH_C32(0xf3933dda), SPH_C32(0xc867cf22), SPH_C32(0x7d4e0000), + SPH_C32(0x65040000), SPH_C32(0xecc70000), SPH_C32(0x3cd76480), + SPH_C32(0x3e755d25), SPH_C32(0x867f7d79), SPH_C32(0x3e57e2f8), + SPH_C32(0x736278c6) }, + { SPH_C32(0xa19f0000), SPH_C32(0x26650000), SPH_C32(0x128f0000), + SPH_C32(0x27bc9280), SPH_C32(0x05da3d59), SPH_C32(0xa8f5976b), + SPH_C32(0xdb063b6e), SPH_C32(0x1f3d87b5), SPH_C32(0x8d8b0000), + SPH_C32(0x3c270000), SPH_C32(0xa9450000), SPH_C32(0xdd5a6440), + SPH_C32(0x05185b14), SPH_C32(0x44922be0), SPH_C32(0xf5b71ce4), + SPH_C32(0x25c5c959) }, + { SPH_C32(0xb7720000), SPH_C32(0x330d0000), SPH_C32(0xff580000), + SPH_C32(0x15e190a0), SPH_C32(0xe6d60bd0), SPH_C32(0xf2bf7128), + SPH_C32(0x3873c3c6), SPH_C32(0x9ec07ebd), SPH_C32(0x6ba30000), + SPH_C32(0x706c0000), SPH_C32(0x01100000), SPH_C32(0x0e8a66a0), + SPH_C32(0xdd796bac), SPH_C32(0xdc359b3a), SPH_C32(0xdd221a50), + SPH_C32(0xf29f81ce) }, + { SPH_C32(0x515a0000), SPH_C32(0x7f460000), SPH_C32(0x570d0000), + SPH_C32(0xc6319240), SPH_C32(0x3eb73b68), SPH_C32(0x6a18c1f2), + SPH_C32(0x10e6c572), SPH_C32(0x499a362a), SPH_C32(0x9b660000), + SPH_C32(0x294f0000), SPH_C32(0x44920000), SPH_C32(0xef076660), + SPH_C32(0xe6146d9d), SPH_C32(0x1ed8cda3), SPH_C32(0x16c2e44c), + SPH_C32(0xa4383051) }, + { SPH_C32(0xf3860000), SPH_C32(0x1d1d0000), SPH_C32(0x0b870000), + SPH_C32(0x8bbc9480), SPH_C32(0xa5196cd9), SPH_C32(0xe144e4ec), + SPH_C32(0x21c5e953), SPH_C32(0x8608bbfc), SPH_C32(0x9e480000), + SPH_C32(0xd8c50000), SPH_C32(0x6bd40000), SPH_C32(0x832564e0), + SPH_C32(0x10cf573f), SPH_C32(0x0bca4a28), SPH_C32(0x4d9249fe), + SPH_C32(0x28b46dff) }, + { SPH_C32(0x15ae0000), SPH_C32(0x51560000), SPH_C32(0xa3d20000), + SPH_C32(0x586c9660), SPH_C32(0x7d785c61), SPH_C32(0x79e35436), + SPH_C32(0x0950efe7), SPH_C32(0x5152f36b), SPH_C32(0x6e8d0000), + SPH_C32(0x81e60000), SPH_C32(0x2e560000), SPH_C32(0x62a86420), + SPH_C32(0x2ba2510e), SPH_C32(0xc9271cb1), SPH_C32(0x8672b7e2), + SPH_C32(0x7e13dc60) }, + { SPH_C32(0x03430000), SPH_C32(0x443e0000), SPH_C32(0x4e050000), + SPH_C32(0x6a319440), SPH_C32(0x9e746ae8), SPH_C32(0x23a9b275), + SPH_C32(0xea25174f), SPH_C32(0xd0af0a63), SPH_C32(0x88a50000), + SPH_C32(0xcdad0000), SPH_C32(0x86030000), SPH_C32(0xb17866c0), + SPH_C32(0xf3c361b6), SPH_C32(0x5180ac6b), SPH_C32(0xaee7b156), + SPH_C32(0xa94994f7) }, + { SPH_C32(0xe56b0000), SPH_C32(0x08750000), SPH_C32(0xe6500000), + SPH_C32(0xb9e196a0), SPH_C32(0x46155a50), SPH_C32(0xbb0e02af), + SPH_C32(0xc2b011fb), SPH_C32(0x07f542f4), SPH_C32(0x78600000), + SPH_C32(0x948e0000), SPH_C32(0xc3810000), SPH_C32(0x50f56600), + SPH_C32(0xc8ae6787), SPH_C32(0x936dfaf2), SPH_C32(0x65074f4a), + SPH_C32(0xffee2568) }, + { SPH_C32(0xa6430000), SPH_C32(0x756e0000), SPH_C32(0xbaf60000), + SPH_C32(0xa8f2e800), SPH_C32(0xed1c7314), SPH_C32(0xbada3b36), + SPH_C32(0x4494a4eb), SPH_C32(0xec83ff85), SPH_C32(0x90a40000), + SPH_C32(0xbc5b0000), SPH_C32(0x6d6e0000), SPH_C32(0x0bdd4800), + SPH_C32(0xb728224a), SPH_C32(0xecc64a4f), SPH_C32(0x759e1063), + SPH_C32(0x4cf701d1) }, + { SPH_C32(0x406b0000), SPH_C32(0x39250000), SPH_C32(0x12a30000), + SPH_C32(0x7b22eae0), SPH_C32(0x357d43ac), SPH_C32(0x227d8bec), + SPH_C32(0x6c01a25f), SPH_C32(0x3bd9b712), SPH_C32(0x60610000), + SPH_C32(0xe5780000), SPH_C32(0x28ec0000), SPH_C32(0xea5048c0), + SPH_C32(0x8c45247b), SPH_C32(0x2e2b1cd6), SPH_C32(0xbe7eee7f), + SPH_C32(0x1a50b04e) }, + { SPH_C32(0x56860000), SPH_C32(0x2c4d0000), SPH_C32(0xff740000), + SPH_C32(0x497fe8c0), SPH_C32(0xd6717525), SPH_C32(0x78376daf), + SPH_C32(0x8f745af7), SPH_C32(0xba244e1a), SPH_C32(0x86490000), + SPH_C32(0xa9330000), SPH_C32(0x80b90000), SPH_C32(0x39804a20), + SPH_C32(0x542414c3), SPH_C32(0xb68cac0c), SPH_C32(0x96ebe8cb), + SPH_C32(0xcd0af8d9) }, + { SPH_C32(0xb0ae0000), SPH_C32(0x60060000), SPH_C32(0x57210000), + SPH_C32(0x9aafea20), SPH_C32(0x0e10459d), SPH_C32(0xe090dd75), + SPH_C32(0xa7e15c43), SPH_C32(0x6d7e068d), SPH_C32(0x768c0000), + SPH_C32(0xf0100000), SPH_C32(0xc53b0000), SPH_C32(0xd80d4ae0), + SPH_C32(0x6f4912f2), SPH_C32(0x7461fa95), SPH_C32(0x5d0b16d7), + SPH_C32(0x9bad4946) }, + { SPH_C32(0x12720000), SPH_C32(0x025d0000), SPH_C32(0x0bab0000), + SPH_C32(0xd722ece0), SPH_C32(0x95be122c), SPH_C32(0x6bccf86b), + SPH_C32(0x96c27062), SPH_C32(0xa2ec8b5b), SPH_C32(0x73a20000), + SPH_C32(0x019a0000), SPH_C32(0xea7d0000), SPH_C32(0xb42f4860), + SPH_C32(0x99922850), SPH_C32(0x61737d1e), SPH_C32(0x065bbb65), + SPH_C32(0x172114e8) }, + { SPH_C32(0xf45a0000), SPH_C32(0x4e160000), SPH_C32(0xa3fe0000), + SPH_C32(0x04f2ee00), SPH_C32(0x4ddf2294), SPH_C32(0xf36b48b1), + SPH_C32(0xbe5776d6), SPH_C32(0x75b6c3cc), SPH_C32(0x83670000), + SPH_C32(0x58b90000), SPH_C32(0xafff0000), SPH_C32(0x55a248a0), + SPH_C32(0xa2ff2e61), SPH_C32(0xa39e2b87), SPH_C32(0xcdbb4579), + SPH_C32(0x4186a577) }, + { SPH_C32(0xe2b70000), SPH_C32(0x5b7e0000), SPH_C32(0x4e290000), + SPH_C32(0x36afec20), SPH_C32(0xaed3141d), SPH_C32(0xa921aef2), + SPH_C32(0x5d228e7e), SPH_C32(0xf44b3ac4), SPH_C32(0x654f0000), + SPH_C32(0x14f20000), SPH_C32(0x07aa0000), SPH_C32(0x86724a40), + SPH_C32(0x7a9e1ed9), SPH_C32(0x3b399b5d), SPH_C32(0xe52e43cd), + SPH_C32(0x96dcede0) }, + { SPH_C32(0x049f0000), SPH_C32(0x17350000), SPH_C32(0xe67c0000), + SPH_C32(0xe57feec0), SPH_C32(0x76b224a5), SPH_C32(0x31861e28), + SPH_C32(0x75b788ca), SPH_C32(0x23117253), SPH_C32(0x958a0000), + SPH_C32(0x4dd10000), SPH_C32(0x42280000), SPH_C32(0x67ff4a80), + SPH_C32(0x41f318e8), SPH_C32(0xf9d4cdc4), SPH_C32(0x2ecebdd1), + SPH_C32(0xc07b5c7f) }, + { SPH_C32(0x45450000), SPH_C32(0xc8af0000), SPH_C32(0x3de50000), + SPH_C32(0x1700e860), SPH_C32(0xc3a6790e), SPH_C32(0x376f0c67), + SPH_C32(0x37510fed), SPH_C32(0xb755eabc), SPH_C32(0xc7930000), + SPH_C32(0x76a90000), SPH_C32(0x5b200000), SPH_C32(0xcbff4c80), + SPH_C32(0xe1304968), SPH_C32(0xb065be43), SPH_C32(0xd40d6fec), + SPH_C32(0x594e6036) }, + { SPH_C32(0xa36d0000), SPH_C32(0x84e40000), SPH_C32(0x95b00000), + SPH_C32(0xc4d0ea80), SPH_C32(0x1bc749b6), SPH_C32(0xafc8bcbd), + SPH_C32(0x1fc40959), SPH_C32(0x600fa22b), SPH_C32(0x37560000), + SPH_C32(0x2f8a0000), SPH_C32(0x1ea20000), SPH_C32(0x2a724c40), + SPH_C32(0xda5d4f59), SPH_C32(0x7288e8da), SPH_C32(0x1fed91f0), + SPH_C32(0x0fe9d1a9) }, + { SPH_C32(0xb5800000), SPH_C32(0x918c0000), SPH_C32(0x78670000), + SPH_C32(0xf68de8a0), SPH_C32(0xf8cb7f3f), SPH_C32(0xf5825afe), + SPH_C32(0xfcb1f1f1), SPH_C32(0xe1f25b23), SPH_C32(0xd17e0000), + SPH_C32(0x63c10000), SPH_C32(0xb6f70000), SPH_C32(0xf9a24ea0), + SPH_C32(0x023c7fe1), SPH_C32(0xea2f5800), SPH_C32(0x37789744), + SPH_C32(0xd8b3993e) }, + { SPH_C32(0x53a80000), SPH_C32(0xddc70000), SPH_C32(0xd0320000), + SPH_C32(0x255dea40), SPH_C32(0x20aa4f87), SPH_C32(0x6d25ea24), + SPH_C32(0xd424f745), SPH_C32(0x36a813b4), SPH_C32(0x21bb0000), + SPH_C32(0x3ae20000), SPH_C32(0xf3750000), SPH_C32(0x182f4e60), + SPH_C32(0x395179d0), SPH_C32(0x28c20e99), SPH_C32(0xfc986958), + SPH_C32(0x8e1428a1) }, + { SPH_C32(0xf1740000), SPH_C32(0xbf9c0000), SPH_C32(0x8cb80000), + SPH_C32(0x68d0ec80), SPH_C32(0xbb041836), SPH_C32(0xe679cf3a), + SPH_C32(0xe507db64), SPH_C32(0xf93a9e62), SPH_C32(0x24950000), + SPH_C32(0xcb680000), SPH_C32(0xdc330000), SPH_C32(0x740d4ce0), + SPH_C32(0xcf8a4372), SPH_C32(0x3dd08912), SPH_C32(0xa7c8c4ea), + SPH_C32(0x0298750f) }, + { SPH_C32(0x175c0000), SPH_C32(0xf3d70000), SPH_C32(0x24ed0000), + SPH_C32(0xbb00ee60), SPH_C32(0x6365288e), SPH_C32(0x7ede7fe0), + SPH_C32(0xcd92ddd0), SPH_C32(0x2e60d6f5), SPH_C32(0xd4500000), + SPH_C32(0x924b0000), SPH_C32(0x99b10000), SPH_C32(0x95804c20), + SPH_C32(0xf4e74543), SPH_C32(0xff3ddf8b), SPH_C32(0x6c283af6), + SPH_C32(0x543fc490) }, + { SPH_C32(0x01b10000), SPH_C32(0xe6bf0000), SPH_C32(0xc93a0000), + SPH_C32(0x895dec40), SPH_C32(0x80691e07), SPH_C32(0x249499a3), + SPH_C32(0x2ee72578), SPH_C32(0xaf9d2ffd), SPH_C32(0x32780000), + SPH_C32(0xde000000), SPH_C32(0x31e40000), SPH_C32(0x46504ec0), + SPH_C32(0x2c8675fb), SPH_C32(0x679a6f51), SPH_C32(0x44bd3c42), + SPH_C32(0x83658c07) }, + { SPH_C32(0xe7990000), SPH_C32(0xaaf40000), SPH_C32(0x616f0000), + SPH_C32(0x5a8deea0), SPH_C32(0x58082ebf), SPH_C32(0xbc332979), + SPH_C32(0x067223cc), SPH_C32(0x78c7676a), SPH_C32(0xc2bd0000), + SPH_C32(0x87230000), SPH_C32(0x74660000), SPH_C32(0xa7dd4e00), + SPH_C32(0x17eb73ca), SPH_C32(0xa57739c8), SPH_C32(0x8f5dc25e), + SPH_C32(0xd5c23d98) }, + { SPH_C32(0x92560000), SPH_C32(0x1eda0000), SPH_C32(0xea510000), + SPH_C32(0xe8b13000), SPH_C32(0xa93556a5), SPH_C32(0xebfb6199), + SPH_C32(0xb15c2254), SPH_C32(0x33c5244f), SPH_C32(0x8c3a0000), + SPH_C32(0xda980000), SPH_C32(0x607f0000), SPH_C32(0x54078800), + SPH_C32(0x85714513), SPH_C32(0x6006b243), SPH_C32(0xdb50399c), + SPH_C32(0x8a58e6a4) }, + { SPH_C32(0x747e0000), SPH_C32(0x52910000), SPH_C32(0x42040000), + SPH_C32(0x3b6132e0), SPH_C32(0x7154661d), SPH_C32(0x735cd143), + SPH_C32(0x99c924e0), SPH_C32(0xe49f6cd8), SPH_C32(0x7cff0000), + SPH_C32(0x83bb0000), SPH_C32(0x25fd0000), SPH_C32(0xb58a88c0), + SPH_C32(0xbe1c4322), SPH_C32(0xa2ebe4da), SPH_C32(0x10b0c780), + SPH_C32(0xdcff573b) }, + { SPH_C32(0x62930000), SPH_C32(0x47f90000), SPH_C32(0xafd30000), + SPH_C32(0x093c30c0), SPH_C32(0x92585094), SPH_C32(0x29163700), + SPH_C32(0x7abcdc48), SPH_C32(0x656295d0), SPH_C32(0x9ad70000), + SPH_C32(0xcff00000), SPH_C32(0x8da80000), SPH_C32(0x665a8a20), + SPH_C32(0x667d739a), SPH_C32(0x3a4c5400), SPH_C32(0x3825c134), + SPH_C32(0x0ba51fac) }, + { SPH_C32(0x84bb0000), SPH_C32(0x0bb20000), SPH_C32(0x07860000), + SPH_C32(0xdaec3220), SPH_C32(0x4a39602c), SPH_C32(0xb1b187da), + SPH_C32(0x5229dafc), SPH_C32(0xb238dd47), SPH_C32(0x6a120000), + SPH_C32(0x96d30000), SPH_C32(0xc82a0000), SPH_C32(0x87d78ae0), + SPH_C32(0x5d1075ab), SPH_C32(0xf8a10299), SPH_C32(0xf3c53f28), + SPH_C32(0x5d02ae33) }, + { SPH_C32(0x26670000), SPH_C32(0x69e90000), SPH_C32(0x5b0c0000), + SPH_C32(0x976134e0), SPH_C32(0xd197379d), SPH_C32(0x3aeda2c4), + SPH_C32(0x630af6dd), SPH_C32(0x7daa5091), SPH_C32(0x6f3c0000), + SPH_C32(0x67590000), SPH_C32(0xe76c0000), SPH_C32(0xebf58860), + SPH_C32(0xabcb4f09), SPH_C32(0xedb38512), SPH_C32(0xa895929a), + SPH_C32(0xd18ef39d) }, + { SPH_C32(0xc04f0000), SPH_C32(0x25a20000), SPH_C32(0xf3590000), + SPH_C32(0x44b13600), SPH_C32(0x09f60725), SPH_C32(0xa24a121e), + SPH_C32(0x4b9ff069), SPH_C32(0xaaf01806), SPH_C32(0x9ff90000), + SPH_C32(0x3e7a0000), SPH_C32(0xa2ee0000), SPH_C32(0x0a7888a0), + SPH_C32(0x90a64938), SPH_C32(0x2f5ed38b), SPH_C32(0x63756c86), + SPH_C32(0x87294202) }, + { SPH_C32(0xd6a20000), SPH_C32(0x30ca0000), SPH_C32(0x1e8e0000), + SPH_C32(0x76ec3420), SPH_C32(0xeafa31ac), SPH_C32(0xf800f45d), + SPH_C32(0xa8ea08c1), SPH_C32(0x2b0de10e), SPH_C32(0x79d10000), + SPH_C32(0x72310000), SPH_C32(0x0abb0000), SPH_C32(0xd9a88a40), + SPH_C32(0x48c77980), SPH_C32(0xb7f96351), SPH_C32(0x4be06a32), + SPH_C32(0x50730a95) }, + { SPH_C32(0x308a0000), SPH_C32(0x7c810000), SPH_C32(0xb6db0000), + SPH_C32(0xa53c36c0), SPH_C32(0x329b0114), SPH_C32(0x60a74487), + SPH_C32(0x807f0e75), SPH_C32(0xfc57a999), SPH_C32(0x89140000), + SPH_C32(0x2b120000), SPH_C32(0x4f390000), SPH_C32(0x38258a80), + SPH_C32(0x73aa7fb1), SPH_C32(0x751435c8), SPH_C32(0x8000942e), + SPH_C32(0x06d4bb0a) }, + { SPH_C32(0x71500000), SPH_C32(0xa31b0000), SPH_C32(0x6d420000), + SPH_C32(0x57433060), SPH_C32(0x878f5cbf), SPH_C32(0x664e56c8), + SPH_C32(0xc2998952), SPH_C32(0x68133176), SPH_C32(0xdb0d0000), + SPH_C32(0x106a0000), SPH_C32(0x56310000), SPH_C32(0x94258c80), + SPH_C32(0xd3692e31), SPH_C32(0x3ca5464f), SPH_C32(0x7ac34613), + SPH_C32(0x9fe18743) }, + { SPH_C32(0x97780000), SPH_C32(0xef500000), SPH_C32(0xc5170000), + SPH_C32(0x84933280), SPH_C32(0x5fee6c07), SPH_C32(0xfee9e612), + SPH_C32(0xea0c8fe6), SPH_C32(0xbf4979e1), SPH_C32(0x2bc80000), + SPH_C32(0x49490000), SPH_C32(0x13b30000), SPH_C32(0x75a88c40), + SPH_C32(0xe8042800), SPH_C32(0xfe4810d6), SPH_C32(0xb123b80f), + SPH_C32(0xc94636dc) }, + { SPH_C32(0x81950000), SPH_C32(0xfa380000), SPH_C32(0x28c00000), + SPH_C32(0xb6ce30a0), SPH_C32(0xbce25a8e), SPH_C32(0xa4a30051), + SPH_C32(0x0979774e), SPH_C32(0x3eb480e9), SPH_C32(0xcde00000), + SPH_C32(0x05020000), SPH_C32(0xbbe60000), SPH_C32(0xa6788ea0), + SPH_C32(0x306518b8), SPH_C32(0x66efa00c), SPH_C32(0x99b6bebb), + SPH_C32(0x1e1c7e4b) }, + { SPH_C32(0x67bd0000), SPH_C32(0xb6730000), SPH_C32(0x80950000), + SPH_C32(0x651e3240), SPH_C32(0x64836a36), SPH_C32(0x3c04b08b), + SPH_C32(0x21ec71fa), SPH_C32(0xe9eec87e), SPH_C32(0x3d250000), + SPH_C32(0x5c210000), SPH_C32(0xfe640000), SPH_C32(0x47f58e60), + SPH_C32(0x0b081e89), SPH_C32(0xa402f695), SPH_C32(0x525640a7), + SPH_C32(0x48bbcfd4) }, + { SPH_C32(0xc5610000), SPH_C32(0xd4280000), SPH_C32(0xdc1f0000), + SPH_C32(0x28933480), SPH_C32(0xff2d3d87), SPH_C32(0xb7589595), + SPH_C32(0x10cf5ddb), SPH_C32(0x267c45a8), SPH_C32(0x380b0000), + SPH_C32(0xadab0000), SPH_C32(0xd1220000), SPH_C32(0x2bd78ce0), + SPH_C32(0xfdd3242b), SPH_C32(0xb110711e), SPH_C32(0x0906ed15), + SPH_C32(0xc437927a) }, + { SPH_C32(0x23490000), SPH_C32(0x98630000), SPH_C32(0x744a0000), + SPH_C32(0xfb433660), SPH_C32(0x274c0d3f), SPH_C32(0x2fff254f), + SPH_C32(0x385a5b6f), SPH_C32(0xf1260d3f), SPH_C32(0xc8ce0000), + SPH_C32(0xf4880000), SPH_C32(0x94a00000), SPH_C32(0xca5a8c20), + SPH_C32(0xc6be221a), SPH_C32(0x73fd2787), SPH_C32(0xc2e61309), + SPH_C32(0x929023e5) }, + { SPH_C32(0x35a40000), SPH_C32(0x8d0b0000), SPH_C32(0x999d0000), + SPH_C32(0xc91e3440), SPH_C32(0xc4403bb6), SPH_C32(0x75b5c30c), + SPH_C32(0xdb2fa3c7), SPH_C32(0x70dbf437), SPH_C32(0x2ee60000), + SPH_C32(0xb8c30000), SPH_C32(0x3cf50000), SPH_C32(0x198a8ec0), + SPH_C32(0x1edf12a2), SPH_C32(0xeb5a975d), SPH_C32(0xea7315bd), + SPH_C32(0x45ca6b72) }, + { SPH_C32(0xd38c0000), SPH_C32(0xc1400000), SPH_C32(0x31c80000), + SPH_C32(0x1ace36a0), SPH_C32(0x1c210b0e), SPH_C32(0xed1273d6), + SPH_C32(0xf3baa573), SPH_C32(0xa781bca0), SPH_C32(0xde230000), + SPH_C32(0xe1e00000), SPH_C32(0x79770000), SPH_C32(0xf8078e00), + SPH_C32(0x25b21493), SPH_C32(0x29b7c1c4), SPH_C32(0x2193eba1), + SPH_C32(0x136ddaed) }, + { SPH_C32(0x90a40000), SPH_C32(0xbc5b0000), SPH_C32(0x6d6e0000), + SPH_C32(0x0bdd4800), SPH_C32(0xb728224a), SPH_C32(0xecc64a4f), + SPH_C32(0x759e1063), SPH_C32(0x4cf701d1), SPH_C32(0x36e70000), + SPH_C32(0xc9350000), SPH_C32(0xd7980000), SPH_C32(0xa32fa000), + SPH_C32(0x5a34515e), SPH_C32(0x561c7179), SPH_C32(0x310ab488), + SPH_C32(0xa074fe54) }, + { SPH_C32(0x768c0000), SPH_C32(0xf0100000), SPH_C32(0xc53b0000), + SPH_C32(0xd80d4ae0), SPH_C32(0x6f4912f2), SPH_C32(0x7461fa95), + SPH_C32(0x5d0b16d7), SPH_C32(0x9bad4946), SPH_C32(0xc6220000), + SPH_C32(0x90160000), SPH_C32(0x921a0000), SPH_C32(0x42a2a0c0), + SPH_C32(0x6159576f), SPH_C32(0x94f127e0), SPH_C32(0xfaea4a94), + SPH_C32(0xf6d34fcb) }, + { SPH_C32(0x60610000), SPH_C32(0xe5780000), SPH_C32(0x28ec0000), + SPH_C32(0xea5048c0), SPH_C32(0x8c45247b), SPH_C32(0x2e2b1cd6), + SPH_C32(0xbe7eee7f), SPH_C32(0x1a50b04e), SPH_C32(0x200a0000), + SPH_C32(0xdc5d0000), SPH_C32(0x3a4f0000), SPH_C32(0x9172a220), + SPH_C32(0xb93867d7), SPH_C32(0x0c56973a), SPH_C32(0xd27f4c20), + SPH_C32(0x2189075c) }, + { SPH_C32(0x86490000), SPH_C32(0xa9330000), SPH_C32(0x80b90000), + SPH_C32(0x39804a20), SPH_C32(0x542414c3), SPH_C32(0xb68cac0c), + SPH_C32(0x96ebe8cb), SPH_C32(0xcd0af8d9), SPH_C32(0xd0cf0000), + SPH_C32(0x857e0000), SPH_C32(0x7fcd0000), SPH_C32(0x70ffa2e0), + SPH_C32(0x825561e6), SPH_C32(0xcebbc1a3), SPH_C32(0x199fb23c), + SPH_C32(0x772eb6c3) }, + { SPH_C32(0x24950000), SPH_C32(0xcb680000), SPH_C32(0xdc330000), + SPH_C32(0x740d4ce0), SPH_C32(0xcf8a4372), SPH_C32(0x3dd08912), + SPH_C32(0xa7c8c4ea), SPH_C32(0x0298750f), SPH_C32(0xd5e10000), + SPH_C32(0x74f40000), SPH_C32(0x508b0000), SPH_C32(0x1cdda060), + SPH_C32(0x748e5b44), SPH_C32(0xdba94628), SPH_C32(0x42cf1f8e), + SPH_C32(0xfba2eb6d) }, + { SPH_C32(0xc2bd0000), SPH_C32(0x87230000), SPH_C32(0x74660000), + SPH_C32(0xa7dd4e00), SPH_C32(0x17eb73ca), SPH_C32(0xa57739c8), + SPH_C32(0x8f5dc25e), SPH_C32(0xd5c23d98), SPH_C32(0x25240000), + SPH_C32(0x2dd70000), SPH_C32(0x15090000), SPH_C32(0xfd50a0a0), + SPH_C32(0x4fe35d75), SPH_C32(0x194410b1), SPH_C32(0x892fe192), + SPH_C32(0xad055af2) }, + { SPH_C32(0xd4500000), SPH_C32(0x924b0000), SPH_C32(0x99b10000), + SPH_C32(0x95804c20), SPH_C32(0xf4e74543), SPH_C32(0xff3ddf8b), + SPH_C32(0x6c283af6), SPH_C32(0x543fc490), SPH_C32(0xc30c0000), + SPH_C32(0x619c0000), SPH_C32(0xbd5c0000), SPH_C32(0x2e80a240), + SPH_C32(0x97826dcd), SPH_C32(0x81e3a06b), SPH_C32(0xa1bae726), + SPH_C32(0x7a5f1265) }, + { SPH_C32(0x32780000), SPH_C32(0xde000000), SPH_C32(0x31e40000), + SPH_C32(0x46504ec0), SPH_C32(0x2c8675fb), SPH_C32(0x679a6f51), + SPH_C32(0x44bd3c42), SPH_C32(0x83658c07), SPH_C32(0x33c90000), + SPH_C32(0x38bf0000), SPH_C32(0xf8de0000), SPH_C32(0xcf0da280), + SPH_C32(0xacef6bfc), SPH_C32(0x430ef6f2), SPH_C32(0x6a5a193a), + SPH_C32(0x2cf8a3fa) }, + { SPH_C32(0x73a20000), SPH_C32(0x019a0000), SPH_C32(0xea7d0000), + SPH_C32(0xb42f4860), SPH_C32(0x99922850), SPH_C32(0x61737d1e), + SPH_C32(0x065bbb65), SPH_C32(0x172114e8), SPH_C32(0x61d00000), + SPH_C32(0x03c70000), SPH_C32(0xe1d60000), SPH_C32(0x630da480), + SPH_C32(0x0c2c3a7c), SPH_C32(0x0abf8575), SPH_C32(0x9099cb07), + SPH_C32(0xb5cd9fb3) }, + { SPH_C32(0x958a0000), SPH_C32(0x4dd10000), SPH_C32(0x42280000), + SPH_C32(0x67ff4a80), SPH_C32(0x41f318e8), SPH_C32(0xf9d4cdc4), + SPH_C32(0x2ecebdd1), SPH_C32(0xc07b5c7f), SPH_C32(0x91150000), + SPH_C32(0x5ae40000), SPH_C32(0xa4540000), SPH_C32(0x8280a440), + SPH_C32(0x37413c4d), SPH_C32(0xc852d3ec), SPH_C32(0x5b79351b), + SPH_C32(0xe36a2e2c) }, + { SPH_C32(0x83670000), SPH_C32(0x58b90000), SPH_C32(0xafff0000), + SPH_C32(0x55a248a0), SPH_C32(0xa2ff2e61), SPH_C32(0xa39e2b87), + SPH_C32(0xcdbb4579), SPH_C32(0x4186a577), SPH_C32(0x773d0000), + SPH_C32(0x16af0000), SPH_C32(0x0c010000), SPH_C32(0x5150a6a0), + SPH_C32(0xef200cf5), SPH_C32(0x50f56336), SPH_C32(0x73ec33af), + SPH_C32(0x343066bb) }, + { SPH_C32(0x654f0000), SPH_C32(0x14f20000), SPH_C32(0x07aa0000), + SPH_C32(0x86724a40), SPH_C32(0x7a9e1ed9), SPH_C32(0x3b399b5d), + SPH_C32(0xe52e43cd), SPH_C32(0x96dcede0), SPH_C32(0x87f80000), + SPH_C32(0x4f8c0000), SPH_C32(0x49830000), SPH_C32(0xb0dda660), + SPH_C32(0xd44d0ac4), SPH_C32(0x921835af), SPH_C32(0xb80ccdb3), + SPH_C32(0x6297d724) }, + { SPH_C32(0xc7930000), SPH_C32(0x76a90000), SPH_C32(0x5b200000), + SPH_C32(0xcbff4c80), SPH_C32(0xe1304968), SPH_C32(0xb065be43), + SPH_C32(0xd40d6fec), SPH_C32(0x594e6036), SPH_C32(0x82d60000), + SPH_C32(0xbe060000), SPH_C32(0x66c50000), SPH_C32(0xdcffa4e0), + SPH_C32(0x22963066), SPH_C32(0x870ab224), SPH_C32(0xe35c6001), + SPH_C32(0xee1b8a8a) }, + { SPH_C32(0x21bb0000), SPH_C32(0x3ae20000), SPH_C32(0xf3750000), + SPH_C32(0x182f4e60), SPH_C32(0x395179d0), SPH_C32(0x28c20e99), + SPH_C32(0xfc986958), SPH_C32(0x8e1428a1), SPH_C32(0x72130000), + SPH_C32(0xe7250000), SPH_C32(0x23470000), SPH_C32(0x3d72a420), + SPH_C32(0x19fb3657), SPH_C32(0x45e7e4bd), SPH_C32(0x28bc9e1d), + SPH_C32(0xb8bc3b15) }, + { SPH_C32(0x37560000), SPH_C32(0x2f8a0000), SPH_C32(0x1ea20000), + SPH_C32(0x2a724c40), SPH_C32(0xda5d4f59), SPH_C32(0x7288e8da), + SPH_C32(0x1fed91f0), SPH_C32(0x0fe9d1a9), SPH_C32(0x943b0000), + SPH_C32(0xab6e0000), SPH_C32(0x8b120000), SPH_C32(0xeea2a6c0), + SPH_C32(0xc19a06ef), SPH_C32(0xdd405467), SPH_C32(0x002998a9), + SPH_C32(0x6fe67382) }, + { SPH_C32(0xd17e0000), SPH_C32(0x63c10000), SPH_C32(0xb6f70000), + SPH_C32(0xf9a24ea0), SPH_C32(0x023c7fe1), SPH_C32(0xea2f5800), + SPH_C32(0x37789744), SPH_C32(0xd8b3993e), SPH_C32(0x64fe0000), + SPH_C32(0xf24d0000), SPH_C32(0xce900000), SPH_C32(0x0f2fa600), + SPH_C32(0xfaf700de), SPH_C32(0x1fad02fe), SPH_C32(0xcbc966b5), + SPH_C32(0x3941c21d) }, + { SPH_C32(0x288b0000), SPH_C32(0x0d770000), SPH_C32(0x5db60000), + SPH_C32(0x1f991800), SPH_C32(0x767042e8), SPH_C32(0xdde1a2a3), + SPH_C32(0x5b06af40), SPH_C32(0x19e93cbf), SPH_C32(0x34150000), + SPH_C32(0x6bb40000), SPH_C32(0x50a70000), SPH_C32(0x4043d800), + SPH_C32(0x442925b1), SPH_C32(0x51215aaf), SPH_C32(0xf5c886bf), + SPH_C32(0xdf46dbca) }, + { SPH_C32(0xcea30000), SPH_C32(0x413c0000), SPH_C32(0xf5e30000), + SPH_C32(0xcc491ae0), SPH_C32(0xae117250), SPH_C32(0x45461279), + SPH_C32(0x7393a9f4), SPH_C32(0xceb37428), SPH_C32(0xc4d00000), + SPH_C32(0x32970000), SPH_C32(0x15250000), SPH_C32(0xa1ced8c0), + SPH_C32(0x7f442380), SPH_C32(0x93cc0c36), SPH_C32(0x3e2878a3), + SPH_C32(0x89e16a55) }, + { SPH_C32(0xd84e0000), SPH_C32(0x54540000), SPH_C32(0x18340000), + SPH_C32(0xfe1418c0), SPH_C32(0x4d1d44d9), SPH_C32(0x1f0cf43a), + SPH_C32(0x90e6515c), SPH_C32(0x4f4e8d20), SPH_C32(0x22f80000), + SPH_C32(0x7edc0000), SPH_C32(0xbd700000), SPH_C32(0x721eda20), + SPH_C32(0xa7251338), SPH_C32(0x0b6bbcec), SPH_C32(0x16bd7e17), + SPH_C32(0x5ebb22c2) }, + { SPH_C32(0x3e660000), SPH_C32(0x181f0000), SPH_C32(0xb0610000), + SPH_C32(0x2dc41a20), SPH_C32(0x957c7461), SPH_C32(0x87ab44e0), + SPH_C32(0xb87357e8), SPH_C32(0x9814c5b7), SPH_C32(0xd23d0000), + SPH_C32(0x27ff0000), SPH_C32(0xf8f20000), SPH_C32(0x9393dae0), + SPH_C32(0x9c481509), SPH_C32(0xc986ea75), SPH_C32(0xdd5d800b), + SPH_C32(0x081c935d) }, + { SPH_C32(0x9cba0000), SPH_C32(0x7a440000), SPH_C32(0xeceb0000), + SPH_C32(0x60491ce0), SPH_C32(0x0ed223d0), SPH_C32(0x0cf761fe), + SPH_C32(0x89507bc9), SPH_C32(0x57864861), SPH_C32(0xd7130000), + SPH_C32(0xd6750000), SPH_C32(0xd7b40000), SPH_C32(0xffb1d860), + SPH_C32(0x6a932fab), SPH_C32(0xdc946dfe), SPH_C32(0x860d2db9), + SPH_C32(0x8490cef3) }, + { SPH_C32(0x7a920000), SPH_C32(0x360f0000), SPH_C32(0x44be0000), + SPH_C32(0xb3991e00), SPH_C32(0xd6b31368), SPH_C32(0x9450d124), + SPH_C32(0xa1c57d7d), SPH_C32(0x80dc00f6), SPH_C32(0x27d60000), + SPH_C32(0x8f560000), SPH_C32(0x92360000), SPH_C32(0x1e3cd8a0), + SPH_C32(0x51fe299a), SPH_C32(0x1e793b67), SPH_C32(0x4dedd3a5), + SPH_C32(0xd2377f6c) }, + { SPH_C32(0x6c7f0000), SPH_C32(0x23670000), SPH_C32(0xa9690000), + SPH_C32(0x81c41c20), SPH_C32(0x35bf25e1), SPH_C32(0xce1a3767), + SPH_C32(0x42b085d5), SPH_C32(0x0121f9fe), SPH_C32(0xc1fe0000), + SPH_C32(0xc31d0000), SPH_C32(0x3a630000), SPH_C32(0xcdecda40), + SPH_C32(0x899f1922), SPH_C32(0x86de8bbd), SPH_C32(0x6578d511), + SPH_C32(0x056d37fb) }, + { SPH_C32(0x8a570000), SPH_C32(0x6f2c0000), SPH_C32(0x013c0000), + SPH_C32(0x52141ec0), SPH_C32(0xedde1559), SPH_C32(0x56bd87bd), + SPH_C32(0x6a258361), SPH_C32(0xd67bb169), SPH_C32(0x313b0000), + SPH_C32(0x9a3e0000), SPH_C32(0x7fe10000), SPH_C32(0x2c61da80), + SPH_C32(0xb2f21f13), SPH_C32(0x4433dd24), SPH_C32(0xae982b0d), + SPH_C32(0x53ca8664) }, + { SPH_C32(0xcb8d0000), SPH_C32(0xb0b60000), SPH_C32(0xdaa50000), + SPH_C32(0xa06b1860), SPH_C32(0x58ca48f2), SPH_C32(0x505495f2), + SPH_C32(0x28c30446), SPH_C32(0x423f2986), SPH_C32(0x63220000), + SPH_C32(0xa1460000), SPH_C32(0x66e90000), SPH_C32(0x8061dc80), + SPH_C32(0x12314e93), SPH_C32(0x0d82aea3), SPH_C32(0x545bf930), + SPH_C32(0xcaffba2d) }, + { SPH_C32(0x2da50000), SPH_C32(0xfcfd0000), SPH_C32(0x72f00000), + SPH_C32(0x73bb1a80), SPH_C32(0x80ab784a), SPH_C32(0xc8f32528), + SPH_C32(0x005602f2), SPH_C32(0x95656111), SPH_C32(0x93e70000), + SPH_C32(0xf8650000), SPH_C32(0x236b0000), SPH_C32(0x61ecdc40), + SPH_C32(0x295c48a2), SPH_C32(0xcf6ff83a), SPH_C32(0x9fbb072c), + SPH_C32(0x9c580bb2) }, + { SPH_C32(0x3b480000), SPH_C32(0xe9950000), SPH_C32(0x9f270000), + SPH_C32(0x41e618a0), SPH_C32(0x63a74ec3), SPH_C32(0x92b9c36b), + SPH_C32(0xe323fa5a), SPH_C32(0x14989819), SPH_C32(0x75cf0000), + SPH_C32(0xb42e0000), SPH_C32(0x8b3e0000), SPH_C32(0xb23cdea0), + SPH_C32(0xf13d781a), SPH_C32(0x57c848e0), SPH_C32(0xb72e0198), + SPH_C32(0x4b024325) }, + { SPH_C32(0xdd600000), SPH_C32(0xa5de0000), SPH_C32(0x37720000), + SPH_C32(0x92361a40), SPH_C32(0xbbc67e7b), SPH_C32(0x0a1e73b1), + SPH_C32(0xcbb6fcee), SPH_C32(0xc3c2d08e), SPH_C32(0x850a0000), + SPH_C32(0xed0d0000), SPH_C32(0xcebc0000), SPH_C32(0x53b1de60), + SPH_C32(0xca507e2b), SPH_C32(0x95251e79), SPH_C32(0x7cceff84), + SPH_C32(0x1da5f2ba) }, + { SPH_C32(0x7fbc0000), SPH_C32(0xc7850000), SPH_C32(0x6bf80000), + SPH_C32(0xdfbb1c80), SPH_C32(0x206829ca), SPH_C32(0x814256af), + SPH_C32(0xfa95d0cf), SPH_C32(0x0c505d58), SPH_C32(0x80240000), + SPH_C32(0x1c870000), SPH_C32(0xe1fa0000), SPH_C32(0x3f93dce0), + SPH_C32(0x3c8b4489), SPH_C32(0x803799f2), SPH_C32(0x279e5236), + SPH_C32(0x9129af14) }, + { SPH_C32(0x99940000), SPH_C32(0x8bce0000), SPH_C32(0xc3ad0000), + SPH_C32(0x0c6b1e60), SPH_C32(0xf8091972), SPH_C32(0x19e5e675), + SPH_C32(0xd200d67b), SPH_C32(0xdb0a15cf), SPH_C32(0x70e10000), + SPH_C32(0x45a40000), SPH_C32(0xa4780000), SPH_C32(0xde1edc20), + SPH_C32(0x07e642b8), SPH_C32(0x42dacf6b), SPH_C32(0xec7eac2a), + SPH_C32(0xc78e1e8b) }, + { SPH_C32(0x8f790000), SPH_C32(0x9ea60000), SPH_C32(0x2e7a0000), + SPH_C32(0x3e361c40), SPH_C32(0x1b052ffb), SPH_C32(0x43af0036), + SPH_C32(0x31752ed3), SPH_C32(0x5af7ecc7), SPH_C32(0x96c90000), + SPH_C32(0x09ef0000), SPH_C32(0x0c2d0000), SPH_C32(0x0dcedec0), + SPH_C32(0xdf877200), SPH_C32(0xda7d7fb1), SPH_C32(0xc4ebaa9e), + SPH_C32(0x10d4561c) }, + { SPH_C32(0x69510000), SPH_C32(0xd2ed0000), SPH_C32(0x862f0000), + SPH_C32(0xede61ea0), SPH_C32(0xc3641f43), SPH_C32(0xdb08b0ec), + SPH_C32(0x19e02867), SPH_C32(0x8dada450), SPH_C32(0x660c0000), + SPH_C32(0x50cc0000), SPH_C32(0x49af0000), SPH_C32(0xec43de00), + SPH_C32(0xe4ea7431), SPH_C32(0x18902928), SPH_C32(0x0f0b5482), + SPH_C32(0x4673e783) }, + { SPH_C32(0x2a790000), SPH_C32(0xaff60000), SPH_C32(0xda890000), + SPH_C32(0xfcf56000), SPH_C32(0x686d3607), SPH_C32(0xdadc8975), + SPH_C32(0x9fc49d77), SPH_C32(0x66db1921), SPH_C32(0x8ec80000), + SPH_C32(0x78190000), SPH_C32(0xe7400000), SPH_C32(0xb76bf000), + SPH_C32(0x9b6c31fc), SPH_C32(0x673b9995), SPH_C32(0x1f920bab), + SPH_C32(0xf56ac33a) }, + { SPH_C32(0xcc510000), SPH_C32(0xe3bd0000), SPH_C32(0x72dc0000), + SPH_C32(0x2f2562e0), SPH_C32(0xb00c06bf), SPH_C32(0x427b39af), + SPH_C32(0xb7519bc3), SPH_C32(0xb18151b6), SPH_C32(0x7e0d0000), + SPH_C32(0x213a0000), SPH_C32(0xa2c20000), SPH_C32(0x56e6f0c0), + SPH_C32(0xa00137cd), SPH_C32(0xa5d6cf0c), SPH_C32(0xd472f5b7), + SPH_C32(0xa3cd72a5) }, + { SPH_C32(0xdabc0000), SPH_C32(0xf6d50000), SPH_C32(0x9f0b0000), + SPH_C32(0x1d7860c0), SPH_C32(0x53003036), SPH_C32(0x1831dfec), + SPH_C32(0x5424636b), SPH_C32(0x307ca8be), SPH_C32(0x98250000), + SPH_C32(0x6d710000), SPH_C32(0x0a970000), SPH_C32(0x8536f220), + SPH_C32(0x78600775), SPH_C32(0x3d717fd6), SPH_C32(0xfce7f303), + SPH_C32(0x74973a32) }, + { SPH_C32(0x3c940000), SPH_C32(0xba9e0000), SPH_C32(0x375e0000), + SPH_C32(0xcea86220), SPH_C32(0x8b61008e), SPH_C32(0x80966f36), + SPH_C32(0x7cb165df), SPH_C32(0xe726e029), SPH_C32(0x68e00000), + SPH_C32(0x34520000), SPH_C32(0x4f150000), SPH_C32(0x64bbf2e0), + SPH_C32(0x430d0144), SPH_C32(0xff9c294f), SPH_C32(0x37070d1f), + SPH_C32(0x22308bad) }, + { SPH_C32(0x9e480000), SPH_C32(0xd8c50000), SPH_C32(0x6bd40000), + SPH_C32(0x832564e0), SPH_C32(0x10cf573f), SPH_C32(0x0bca4a28), + SPH_C32(0x4d9249fe), SPH_C32(0x28b46dff), SPH_C32(0x6dce0000), + SPH_C32(0xc5d80000), SPH_C32(0x60530000), SPH_C32(0x0899f060), + SPH_C32(0xb5d63be6), SPH_C32(0xea8eaec4), SPH_C32(0x6c57a0ad), + SPH_C32(0xaebcd603) }, + { SPH_C32(0x78600000), SPH_C32(0x948e0000), SPH_C32(0xc3810000), + SPH_C32(0x50f56600), SPH_C32(0xc8ae6787), SPH_C32(0x936dfaf2), + SPH_C32(0x65074f4a), SPH_C32(0xffee2568), SPH_C32(0x9d0b0000), + SPH_C32(0x9cfb0000), SPH_C32(0x25d10000), SPH_C32(0xe914f0a0), + SPH_C32(0x8ebb3dd7), SPH_C32(0x2863f85d), SPH_C32(0xa7b75eb1), + SPH_C32(0xf81b679c) }, + { SPH_C32(0x6e8d0000), SPH_C32(0x81e60000), SPH_C32(0x2e560000), + SPH_C32(0x62a86420), SPH_C32(0x2ba2510e), SPH_C32(0xc9271cb1), + SPH_C32(0x8672b7e2), SPH_C32(0x7e13dc60), SPH_C32(0x7b230000), + SPH_C32(0xd0b00000), SPH_C32(0x8d840000), SPH_C32(0x3ac4f240), + SPH_C32(0x56da0d6f), SPH_C32(0xb0c44887), SPH_C32(0x8f225805), + SPH_C32(0x2f412f0b) }, + { SPH_C32(0x88a50000), SPH_C32(0xcdad0000), SPH_C32(0x86030000), + SPH_C32(0xb17866c0), SPH_C32(0xf3c361b6), SPH_C32(0x5180ac6b), + SPH_C32(0xaee7b156), SPH_C32(0xa94994f7), SPH_C32(0x8be60000), + SPH_C32(0x89930000), SPH_C32(0xc8060000), SPH_C32(0xdb49f280), + SPH_C32(0x6db70b5e), SPH_C32(0x72291e1e), SPH_C32(0x44c2a619), + SPH_C32(0x79e69e94) }, + { SPH_C32(0xc97f0000), SPH_C32(0x12370000), SPH_C32(0x5d9a0000), + SPH_C32(0x43076060), SPH_C32(0x46d73c1d), SPH_C32(0x5769be24), + SPH_C32(0xec013671), SPH_C32(0x3d0d0c18), SPH_C32(0xd9ff0000), + SPH_C32(0xb2eb0000), SPH_C32(0xd10e0000), SPH_C32(0x7749f480), + SPH_C32(0xcd745ade), SPH_C32(0x3b986d99), SPH_C32(0xbe017424), + SPH_C32(0xe0d3a2dd) }, + { SPH_C32(0x2f570000), SPH_C32(0x5e7c0000), SPH_C32(0xf5cf0000), + SPH_C32(0x90d76280), SPH_C32(0x9eb60ca5), SPH_C32(0xcfce0efe), + SPH_C32(0xc49430c5), SPH_C32(0xea57448f), SPH_C32(0x293a0000), + SPH_C32(0xebc80000), SPH_C32(0x948c0000), SPH_C32(0x96c4f440), + SPH_C32(0xf6195cef), SPH_C32(0xf9753b00), SPH_C32(0x75e18a38), + SPH_C32(0xb6741342) }, + { SPH_C32(0x39ba0000), SPH_C32(0x4b140000), SPH_C32(0x18180000), + SPH_C32(0xa28a60a0), SPH_C32(0x7dba3a2c), SPH_C32(0x9584e8bd), + SPH_C32(0x27e1c86d), SPH_C32(0x6baabd87), SPH_C32(0xcf120000), + SPH_C32(0xa7830000), SPH_C32(0x3cd90000), SPH_C32(0x4514f6a0), + SPH_C32(0x2e786c57), SPH_C32(0x61d28bda), SPH_C32(0x5d748c8c), + SPH_C32(0x612e5bd5) }, + { SPH_C32(0xdf920000), SPH_C32(0x075f0000), SPH_C32(0xb04d0000), + SPH_C32(0x715a6240), SPH_C32(0xa5db0a94), SPH_C32(0x0d235867), + SPH_C32(0x0f74ced9), SPH_C32(0xbcf0f510), SPH_C32(0x3fd70000), + SPH_C32(0xfea00000), SPH_C32(0x795b0000), SPH_C32(0xa499f660), + SPH_C32(0x15156a66), SPH_C32(0xa33fdd43), SPH_C32(0x96947290), + SPH_C32(0x3789ea4a) }, + { SPH_C32(0x7d4e0000), SPH_C32(0x65040000), SPH_C32(0xecc70000), + SPH_C32(0x3cd76480), SPH_C32(0x3e755d25), SPH_C32(0x867f7d79), + SPH_C32(0x3e57e2f8), SPH_C32(0x736278c6), SPH_C32(0x3af90000), + SPH_C32(0x0f2a0000), SPH_C32(0x561d0000), SPH_C32(0xc8bbf4e0), + SPH_C32(0xe3ce50c4), SPH_C32(0xb62d5ac8), SPH_C32(0xcdc4df22), + SPH_C32(0xbb05b7e4) }, + { SPH_C32(0x9b660000), SPH_C32(0x294f0000), SPH_C32(0x44920000), + SPH_C32(0xef076660), SPH_C32(0xe6146d9d), SPH_C32(0x1ed8cda3), + SPH_C32(0x16c2e44c), SPH_C32(0xa4383051), SPH_C32(0xca3c0000), + SPH_C32(0x56090000), SPH_C32(0x139f0000), SPH_C32(0x2936f420), + SPH_C32(0xd8a356f5), SPH_C32(0x74c00c51), SPH_C32(0x0624213e), + SPH_C32(0xeda2067b) }, + { SPH_C32(0x8d8b0000), SPH_C32(0x3c270000), SPH_C32(0xa9450000), + SPH_C32(0xdd5a6440), SPH_C32(0x05185b14), SPH_C32(0x44922be0), + SPH_C32(0xf5b71ce4), SPH_C32(0x25c5c959), SPH_C32(0x2c140000), + SPH_C32(0x1a420000), SPH_C32(0xbbca0000), SPH_C32(0xfae6f6c0), + SPH_C32(0x00c2664d), SPH_C32(0xec67bc8b), SPH_C32(0x2eb1278a), + SPH_C32(0x3af84eec) }, + { SPH_C32(0x6ba30000), SPH_C32(0x706c0000), SPH_C32(0x01100000), + SPH_C32(0x0e8a66a0), SPH_C32(0xdd796bac), SPH_C32(0xdc359b3a), + SPH_C32(0xdd221a50), SPH_C32(0xf29f81ce), SPH_C32(0xdcd10000), + SPH_C32(0x43610000), SPH_C32(0xfe480000), SPH_C32(0x1b6bf600), + SPH_C32(0x3baf607c), SPH_C32(0x2e8aea12), SPH_C32(0xe551d996), + SPH_C32(0x6c5fff73) }, + { SPH_C32(0x8c3a0000), SPH_C32(0xda980000), SPH_C32(0x607f0000), + SPH_C32(0x54078800), SPH_C32(0x85714513), SPH_C32(0x6006b243), + SPH_C32(0xdb50399c), SPH_C32(0x8a58e6a4), SPH_C32(0x1e6c0000), + SPH_C32(0xc4420000), SPH_C32(0x8a2e0000), SPH_C32(0xbcb6b800), + SPH_C32(0x2c4413b6), SPH_C32(0x8bfdd3da), SPH_C32(0x6a0c1bc8), + SPH_C32(0xb99dc2eb) }, + { SPH_C32(0x6a120000), SPH_C32(0x96d30000), SPH_C32(0xc82a0000), + SPH_C32(0x87d78ae0), SPH_C32(0x5d1075ab), SPH_C32(0xf8a10299), + SPH_C32(0xf3c53f28), SPH_C32(0x5d02ae33), SPH_C32(0xeea90000), + SPH_C32(0x9d610000), SPH_C32(0xcfac0000), SPH_C32(0x5d3bb8c0), + SPH_C32(0x17291587), SPH_C32(0x49108543), SPH_C32(0xa1ece5d4), + SPH_C32(0xef3a7374) }, + { SPH_C32(0x7cff0000), SPH_C32(0x83bb0000), SPH_C32(0x25fd0000), + SPH_C32(0xb58a88c0), SPH_C32(0xbe1c4322), SPH_C32(0xa2ebe4da), + SPH_C32(0x10b0c780), SPH_C32(0xdcff573b), SPH_C32(0x08810000), + SPH_C32(0xd12a0000), SPH_C32(0x67f90000), SPH_C32(0x8eebba20), + SPH_C32(0xcf48253f), SPH_C32(0xd1b73599), SPH_C32(0x8979e360), + SPH_C32(0x38603be3) }, + { SPH_C32(0x9ad70000), SPH_C32(0xcff00000), SPH_C32(0x8da80000), + SPH_C32(0x665a8a20), SPH_C32(0x667d739a), SPH_C32(0x3a4c5400), + SPH_C32(0x3825c134), SPH_C32(0x0ba51fac), SPH_C32(0xf8440000), + SPH_C32(0x88090000), SPH_C32(0x227b0000), SPH_C32(0x6f66bae0), + SPH_C32(0xf425230e), SPH_C32(0x135a6300), SPH_C32(0x42991d7c), + SPH_C32(0x6ec78a7c) }, + { SPH_C32(0x380b0000), SPH_C32(0xadab0000), SPH_C32(0xd1220000), + SPH_C32(0x2bd78ce0), SPH_C32(0xfdd3242b), SPH_C32(0xb110711e), + SPH_C32(0x0906ed15), SPH_C32(0xc437927a), SPH_C32(0xfd6a0000), + SPH_C32(0x79830000), SPH_C32(0x0d3d0000), SPH_C32(0x0344b860), + SPH_C32(0x02fe19ac), SPH_C32(0x0648e48b), SPH_C32(0x19c9b0ce), + SPH_C32(0xe24bd7d2) }, + { SPH_C32(0xde230000), SPH_C32(0xe1e00000), SPH_C32(0x79770000), + SPH_C32(0xf8078e00), SPH_C32(0x25b21493), SPH_C32(0x29b7c1c4), + SPH_C32(0x2193eba1), SPH_C32(0x136ddaed), SPH_C32(0x0daf0000), + SPH_C32(0x20a00000), SPH_C32(0x48bf0000), SPH_C32(0xe2c9b8a0), + SPH_C32(0x39931f9d), SPH_C32(0xc4a5b212), SPH_C32(0xd2294ed2), + SPH_C32(0xb4ec664d) }, + { SPH_C32(0xc8ce0000), SPH_C32(0xf4880000), SPH_C32(0x94a00000), + SPH_C32(0xca5a8c20), SPH_C32(0xc6be221a), SPH_C32(0x73fd2787), + SPH_C32(0xc2e61309), SPH_C32(0x929023e5), SPH_C32(0xeb870000), + SPH_C32(0x6ceb0000), SPH_C32(0xe0ea0000), SPH_C32(0x3119ba40), + SPH_C32(0xe1f22f25), SPH_C32(0x5c0202c8), SPH_C32(0xfabc4866), + SPH_C32(0x63b62eda) }, + { SPH_C32(0x2ee60000), SPH_C32(0xb8c30000), SPH_C32(0x3cf50000), + SPH_C32(0x198a8ec0), SPH_C32(0x1edf12a2), SPH_C32(0xeb5a975d), + SPH_C32(0xea7315bd), SPH_C32(0x45ca6b72), SPH_C32(0x1b420000), + SPH_C32(0x35c80000), SPH_C32(0xa5680000), SPH_C32(0xd094ba80), + SPH_C32(0xda9f2914), SPH_C32(0x9eef5451), SPH_C32(0x315cb67a), + SPH_C32(0x35119f45) }, + { SPH_C32(0x6f3c0000), SPH_C32(0x67590000), SPH_C32(0xe76c0000), + SPH_C32(0xebf58860), SPH_C32(0xabcb4f09), SPH_C32(0xedb38512), + SPH_C32(0xa895929a), SPH_C32(0xd18ef39d), SPH_C32(0x495b0000), + SPH_C32(0x0eb00000), SPH_C32(0xbc600000), SPH_C32(0x7c94bc80), + SPH_C32(0x7a5c7894), SPH_C32(0xd75e27d6), SPH_C32(0xcb9f6447), + SPH_C32(0xac24a30c) }, + { SPH_C32(0x89140000), SPH_C32(0x2b120000), SPH_C32(0x4f390000), + SPH_C32(0x38258a80), SPH_C32(0x73aa7fb1), SPH_C32(0x751435c8), + SPH_C32(0x8000942e), SPH_C32(0x06d4bb0a), SPH_C32(0xb99e0000), + SPH_C32(0x57930000), SPH_C32(0xf9e20000), SPH_C32(0x9d19bc40), + SPH_C32(0x41317ea5), SPH_C32(0x15b3714f), SPH_C32(0x007f9a5b), + SPH_C32(0xfa831293) }, + { SPH_C32(0x9ff90000), SPH_C32(0x3e7a0000), SPH_C32(0xa2ee0000), + SPH_C32(0x0a7888a0), SPH_C32(0x90a64938), SPH_C32(0x2f5ed38b), + SPH_C32(0x63756c86), SPH_C32(0x87294202), SPH_C32(0x5fb60000), + SPH_C32(0x1bd80000), SPH_C32(0x51b70000), SPH_C32(0x4ec9bea0), + SPH_C32(0x99504e1d), SPH_C32(0x8d14c195), SPH_C32(0x28ea9cef), + SPH_C32(0x2dd95a04) }, + { SPH_C32(0x79d10000), SPH_C32(0x72310000), SPH_C32(0x0abb0000), + SPH_C32(0xd9a88a40), SPH_C32(0x48c77980), SPH_C32(0xb7f96351), + SPH_C32(0x4be06a32), SPH_C32(0x50730a95), SPH_C32(0xaf730000), + SPH_C32(0x42fb0000), SPH_C32(0x14350000), SPH_C32(0xaf44be60), + SPH_C32(0xa23d482c), SPH_C32(0x4ff9970c), SPH_C32(0xe30a62f3), + SPH_C32(0x7b7eeb9b) }, + { SPH_C32(0xdb0d0000), SPH_C32(0x106a0000), SPH_C32(0x56310000), + SPH_C32(0x94258c80), SPH_C32(0xd3692e31), SPH_C32(0x3ca5464f), + SPH_C32(0x7ac34613), SPH_C32(0x9fe18743), SPH_C32(0xaa5d0000), + SPH_C32(0xb3710000), SPH_C32(0x3b730000), SPH_C32(0xc366bce0), + SPH_C32(0x54e6728e), SPH_C32(0x5aeb1087), SPH_C32(0xb85acf41), + SPH_C32(0xf7f2b635) }, + { SPH_C32(0x3d250000), SPH_C32(0x5c210000), SPH_C32(0xfe640000), + SPH_C32(0x47f58e60), SPH_C32(0x0b081e89), SPH_C32(0xa402f695), + SPH_C32(0x525640a7), SPH_C32(0x48bbcfd4), SPH_C32(0x5a980000), + SPH_C32(0xea520000), SPH_C32(0x7ef10000), SPH_C32(0x22ebbc20), + SPH_C32(0x6f8b74bf), SPH_C32(0x9806461e), SPH_C32(0x73ba315d), + SPH_C32(0xa15507aa) }, + { SPH_C32(0x2bc80000), SPH_C32(0x49490000), SPH_C32(0x13b30000), + SPH_C32(0x75a88c40), SPH_C32(0xe8042800), SPH_C32(0xfe4810d6), + SPH_C32(0xb123b80f), SPH_C32(0xc94636dc), SPH_C32(0xbcb00000), + SPH_C32(0xa6190000), SPH_C32(0xd6a40000), SPH_C32(0xf13bbec0), + SPH_C32(0xb7ea4407), SPH_C32(0x00a1f6c4), SPH_C32(0x5b2f37e9), + SPH_C32(0x760f4f3d) }, + { SPH_C32(0xcde00000), SPH_C32(0x05020000), SPH_C32(0xbbe60000), + SPH_C32(0xa6788ea0), SPH_C32(0x306518b8), SPH_C32(0x66efa00c), + SPH_C32(0x99b6bebb), SPH_C32(0x1e1c7e4b), SPH_C32(0x4c750000), + SPH_C32(0xff3a0000), SPH_C32(0x93260000), SPH_C32(0x10b6be00), + SPH_C32(0x8c874236), SPH_C32(0xc24ca05d), SPH_C32(0x90cfc9f5), + SPH_C32(0x20a8fea2) }, + { SPH_C32(0x8ec80000), SPH_C32(0x78190000), SPH_C32(0xe7400000), + SPH_C32(0xb76bf000), SPH_C32(0x9b6c31fc), SPH_C32(0x673b9995), + SPH_C32(0x1f920bab), SPH_C32(0xf56ac33a), SPH_C32(0xa4b10000), + SPH_C32(0xd7ef0000), SPH_C32(0x3dc90000), SPH_C32(0x4b9e9000), + SPH_C32(0xf30107fb), SPH_C32(0xbde710e0), SPH_C32(0x805696dc), + SPH_C32(0x93b1da1b) }, + { SPH_C32(0x68e00000), SPH_C32(0x34520000), SPH_C32(0x4f150000), + SPH_C32(0x64bbf2e0), SPH_C32(0x430d0144), SPH_C32(0xff9c294f), + SPH_C32(0x37070d1f), SPH_C32(0x22308bad), SPH_C32(0x54740000), + SPH_C32(0x8ecc0000), SPH_C32(0x784b0000), SPH_C32(0xaa1390c0), + SPH_C32(0xc86c01ca), SPH_C32(0x7f0a4679), SPH_C32(0x4bb668c0), + SPH_C32(0xc5166b84) }, + { SPH_C32(0x7e0d0000), SPH_C32(0x213a0000), SPH_C32(0xa2c20000), + SPH_C32(0x56e6f0c0), SPH_C32(0xa00137cd), SPH_C32(0xa5d6cf0c), + SPH_C32(0xd472f5b7), SPH_C32(0xa3cd72a5), SPH_C32(0xb25c0000), + SPH_C32(0xc2870000), SPH_C32(0xd01e0000), SPH_C32(0x79c39220), + SPH_C32(0x100d3172), SPH_C32(0xe7adf6a3), SPH_C32(0x63236e74), + SPH_C32(0x124c2313) }, + { SPH_C32(0x98250000), SPH_C32(0x6d710000), SPH_C32(0x0a970000), + SPH_C32(0x8536f220), SPH_C32(0x78600775), SPH_C32(0x3d717fd6), + SPH_C32(0xfce7f303), SPH_C32(0x74973a32), SPH_C32(0x42990000), + SPH_C32(0x9ba40000), SPH_C32(0x959c0000), SPH_C32(0x984e92e0), + SPH_C32(0x2b603743), SPH_C32(0x2540a03a), SPH_C32(0xa8c39068), + SPH_C32(0x44eb928c) }, + { SPH_C32(0x3af90000), SPH_C32(0x0f2a0000), SPH_C32(0x561d0000), + SPH_C32(0xc8bbf4e0), SPH_C32(0xe3ce50c4), SPH_C32(0xb62d5ac8), + SPH_C32(0xcdc4df22), SPH_C32(0xbb05b7e4), SPH_C32(0x47b70000), + SPH_C32(0x6a2e0000), SPH_C32(0xbada0000), SPH_C32(0xf46c9060), + SPH_C32(0xddbb0de1), SPH_C32(0x305227b1), SPH_C32(0xf3933dda), + SPH_C32(0xc867cf22) }, + { SPH_C32(0xdcd10000), SPH_C32(0x43610000), SPH_C32(0xfe480000), + SPH_C32(0x1b6bf600), SPH_C32(0x3baf607c), SPH_C32(0x2e8aea12), + SPH_C32(0xe551d996), SPH_C32(0x6c5fff73), SPH_C32(0xb7720000), + SPH_C32(0x330d0000), SPH_C32(0xff580000), SPH_C32(0x15e190a0), + SPH_C32(0xe6d60bd0), SPH_C32(0xf2bf7128), SPH_C32(0x3873c3c6), + SPH_C32(0x9ec07ebd) }, + { SPH_C32(0xca3c0000), SPH_C32(0x56090000), SPH_C32(0x139f0000), + SPH_C32(0x2936f420), SPH_C32(0xd8a356f5), SPH_C32(0x74c00c51), + SPH_C32(0x0624213e), SPH_C32(0xeda2067b), SPH_C32(0x515a0000), + SPH_C32(0x7f460000), SPH_C32(0x570d0000), SPH_C32(0xc6319240), + SPH_C32(0x3eb73b68), SPH_C32(0x6a18c1f2), SPH_C32(0x10e6c572), + SPH_C32(0x499a362a) }, + { SPH_C32(0x2c140000), SPH_C32(0x1a420000), SPH_C32(0xbbca0000), + SPH_C32(0xfae6f6c0), SPH_C32(0x00c2664d), SPH_C32(0xec67bc8b), + SPH_C32(0x2eb1278a), SPH_C32(0x3af84eec), SPH_C32(0xa19f0000), + SPH_C32(0x26650000), SPH_C32(0x128f0000), SPH_C32(0x27bc9280), + SPH_C32(0x05da3d59), SPH_C32(0xa8f5976b), SPH_C32(0xdb063b6e), + SPH_C32(0x1f3d87b5) }, + { SPH_C32(0x6dce0000), SPH_C32(0xc5d80000), SPH_C32(0x60530000), + SPH_C32(0x0899f060), SPH_C32(0xb5d63be6), SPH_C32(0xea8eaec4), + SPH_C32(0x6c57a0ad), SPH_C32(0xaebcd603), SPH_C32(0xf3860000), + SPH_C32(0x1d1d0000), SPH_C32(0x0b870000), SPH_C32(0x8bbc9480), + SPH_C32(0xa5196cd9), SPH_C32(0xe144e4ec), SPH_C32(0x21c5e953), + SPH_C32(0x8608bbfc) }, + { SPH_C32(0x8be60000), SPH_C32(0x89930000), SPH_C32(0xc8060000), + SPH_C32(0xdb49f280), SPH_C32(0x6db70b5e), SPH_C32(0x72291e1e), + SPH_C32(0x44c2a619), SPH_C32(0x79e69e94), SPH_C32(0x03430000), + SPH_C32(0x443e0000), SPH_C32(0x4e050000), SPH_C32(0x6a319440), + SPH_C32(0x9e746ae8), SPH_C32(0x23a9b275), SPH_C32(0xea25174f), + SPH_C32(0xd0af0a63) }, + { SPH_C32(0x9d0b0000), SPH_C32(0x9cfb0000), SPH_C32(0x25d10000), + SPH_C32(0xe914f0a0), SPH_C32(0x8ebb3dd7), SPH_C32(0x2863f85d), + SPH_C32(0xa7b75eb1), SPH_C32(0xf81b679c), SPH_C32(0xe56b0000), + SPH_C32(0x08750000), SPH_C32(0xe6500000), SPH_C32(0xb9e196a0), + SPH_C32(0x46155a50), SPH_C32(0xbb0e02af), SPH_C32(0xc2b011fb), + SPH_C32(0x07f542f4) }, + { SPH_C32(0x7b230000), SPH_C32(0xd0b00000), SPH_C32(0x8d840000), + SPH_C32(0x3ac4f240), SPH_C32(0x56da0d6f), SPH_C32(0xb0c44887), + SPH_C32(0x8f225805), SPH_C32(0x2f412f0b), SPH_C32(0x15ae0000), + SPH_C32(0x51560000), SPH_C32(0xa3d20000), SPH_C32(0x586c9660), + SPH_C32(0x7d785c61), SPH_C32(0x79e35436), SPH_C32(0x0950efe7), + SPH_C32(0x5152f36b) }, + { SPH_C32(0xd9ff0000), SPH_C32(0xb2eb0000), SPH_C32(0xd10e0000), + SPH_C32(0x7749f480), SPH_C32(0xcd745ade), SPH_C32(0x3b986d99), + SPH_C32(0xbe017424), SPH_C32(0xe0d3a2dd), SPH_C32(0x10800000), + SPH_C32(0xa0dc0000), SPH_C32(0x8c940000), SPH_C32(0x344e94e0), + SPH_C32(0x8ba366c3), SPH_C32(0x6cf1d3bd), SPH_C32(0x52004255), + SPH_C32(0xdddeaec5) }, + { SPH_C32(0x3fd70000), SPH_C32(0xfea00000), SPH_C32(0x795b0000), + SPH_C32(0xa499f660), SPH_C32(0x15156a66), SPH_C32(0xa33fdd43), + SPH_C32(0x96947290), SPH_C32(0x3789ea4a), SPH_C32(0xe0450000), + SPH_C32(0xf9ff0000), SPH_C32(0xc9160000), SPH_C32(0xd5c39420), + SPH_C32(0xb0ce60f2), SPH_C32(0xae1c8524), SPH_C32(0x99e0bc49), + SPH_C32(0x8b791f5a) }, + { SPH_C32(0x293a0000), SPH_C32(0xebc80000), SPH_C32(0x948c0000), + SPH_C32(0x96c4f440), SPH_C32(0xf6195cef), SPH_C32(0xf9753b00), + SPH_C32(0x75e18a38), SPH_C32(0xb6741342), SPH_C32(0x066d0000), + SPH_C32(0xb5b40000), SPH_C32(0x61430000), SPH_C32(0x061396c0), + SPH_C32(0x68af504a), SPH_C32(0x36bb35fe), SPH_C32(0xb175bafd), + SPH_C32(0x5c2357cd) }, + { SPH_C32(0xcf120000), SPH_C32(0xa7830000), SPH_C32(0x3cd90000), + SPH_C32(0x4514f6a0), SPH_C32(0x2e786c57), SPH_C32(0x61d28bda), + SPH_C32(0x5d748c8c), SPH_C32(0x612e5bd5), SPH_C32(0xf6a80000), + SPH_C32(0xec970000), SPH_C32(0x24c10000), SPH_C32(0xe79e9600), + SPH_C32(0x53c2567b), SPH_C32(0xf4566367), SPH_C32(0x7a9544e1), + SPH_C32(0x0a84e652) }, + { SPH_C32(0x36e70000), SPH_C32(0xc9350000), SPH_C32(0xd7980000), + SPH_C32(0xa32fa000), SPH_C32(0x5a34515e), SPH_C32(0x561c7179), + SPH_C32(0x310ab488), SPH_C32(0xa074fe54), SPH_C32(0xa6430000), + SPH_C32(0x756e0000), SPH_C32(0xbaf60000), SPH_C32(0xa8f2e800), + SPH_C32(0xed1c7314), SPH_C32(0xbada3b36), SPH_C32(0x4494a4eb), + SPH_C32(0xec83ff85) }, + { SPH_C32(0xd0cf0000), SPH_C32(0x857e0000), SPH_C32(0x7fcd0000), + SPH_C32(0x70ffa2e0), SPH_C32(0x825561e6), SPH_C32(0xcebbc1a3), + SPH_C32(0x199fb23c), SPH_C32(0x772eb6c3), SPH_C32(0x56860000), + SPH_C32(0x2c4d0000), SPH_C32(0xff740000), SPH_C32(0x497fe8c0), + SPH_C32(0xd6717525), SPH_C32(0x78376daf), SPH_C32(0x8f745af7), + SPH_C32(0xba244e1a) }, + { SPH_C32(0xc6220000), SPH_C32(0x90160000), SPH_C32(0x921a0000), + SPH_C32(0x42a2a0c0), SPH_C32(0x6159576f), SPH_C32(0x94f127e0), + SPH_C32(0xfaea4a94), SPH_C32(0xf6d34fcb), SPH_C32(0xb0ae0000), + SPH_C32(0x60060000), SPH_C32(0x57210000), SPH_C32(0x9aafea20), + SPH_C32(0x0e10459d), SPH_C32(0xe090dd75), SPH_C32(0xa7e15c43), + SPH_C32(0x6d7e068d) }, + { SPH_C32(0x200a0000), SPH_C32(0xdc5d0000), SPH_C32(0x3a4f0000), + SPH_C32(0x9172a220), SPH_C32(0xb93867d7), SPH_C32(0x0c56973a), + SPH_C32(0xd27f4c20), SPH_C32(0x2189075c), SPH_C32(0x406b0000), + SPH_C32(0x39250000), SPH_C32(0x12a30000), SPH_C32(0x7b22eae0), + SPH_C32(0x357d43ac), SPH_C32(0x227d8bec), SPH_C32(0x6c01a25f), + SPH_C32(0x3bd9b712) }, + { SPH_C32(0x82d60000), SPH_C32(0xbe060000), SPH_C32(0x66c50000), + SPH_C32(0xdcffa4e0), SPH_C32(0x22963066), SPH_C32(0x870ab224), + SPH_C32(0xe35c6001), SPH_C32(0xee1b8a8a), SPH_C32(0x45450000), + SPH_C32(0xc8af0000), SPH_C32(0x3de50000), SPH_C32(0x1700e860), + SPH_C32(0xc3a6790e), SPH_C32(0x376f0c67), SPH_C32(0x37510fed), + SPH_C32(0xb755eabc) }, + { SPH_C32(0x64fe0000), SPH_C32(0xf24d0000), SPH_C32(0xce900000), + SPH_C32(0x0f2fa600), SPH_C32(0xfaf700de), SPH_C32(0x1fad02fe), + SPH_C32(0xcbc966b5), SPH_C32(0x3941c21d), SPH_C32(0xb5800000), + SPH_C32(0x918c0000), SPH_C32(0x78670000), SPH_C32(0xf68de8a0), + SPH_C32(0xf8cb7f3f), SPH_C32(0xf5825afe), SPH_C32(0xfcb1f1f1), + SPH_C32(0xe1f25b23) }, + { SPH_C32(0x72130000), SPH_C32(0xe7250000), SPH_C32(0x23470000), + SPH_C32(0x3d72a420), SPH_C32(0x19fb3657), SPH_C32(0x45e7e4bd), + SPH_C32(0x28bc9e1d), SPH_C32(0xb8bc3b15), SPH_C32(0x53a80000), + SPH_C32(0xddc70000), SPH_C32(0xd0320000), SPH_C32(0x255dea40), + SPH_C32(0x20aa4f87), SPH_C32(0x6d25ea24), SPH_C32(0xd424f745), + SPH_C32(0x36a813b4) }, + { SPH_C32(0x943b0000), SPH_C32(0xab6e0000), SPH_C32(0x8b120000), + SPH_C32(0xeea2a6c0), SPH_C32(0xc19a06ef), SPH_C32(0xdd405467), + SPH_C32(0x002998a9), SPH_C32(0x6fe67382), SPH_C32(0xa36d0000), + SPH_C32(0x84e40000), SPH_C32(0x95b00000), SPH_C32(0xc4d0ea80), + SPH_C32(0x1bc749b6), SPH_C32(0xafc8bcbd), SPH_C32(0x1fc40959), + SPH_C32(0x600fa22b) }, + { SPH_C32(0xd5e10000), SPH_C32(0x74f40000), SPH_C32(0x508b0000), + SPH_C32(0x1cdda060), SPH_C32(0x748e5b44), SPH_C32(0xdba94628), + SPH_C32(0x42cf1f8e), SPH_C32(0xfba2eb6d), SPH_C32(0xf1740000), + SPH_C32(0xbf9c0000), SPH_C32(0x8cb80000), SPH_C32(0x68d0ec80), + SPH_C32(0xbb041836), SPH_C32(0xe679cf3a), SPH_C32(0xe507db64), + SPH_C32(0xf93a9e62) }, + { SPH_C32(0x33c90000), SPH_C32(0x38bf0000), SPH_C32(0xf8de0000), + SPH_C32(0xcf0da280), SPH_C32(0xacef6bfc), SPH_C32(0x430ef6f2), + SPH_C32(0x6a5a193a), SPH_C32(0x2cf8a3fa), SPH_C32(0x01b10000), + SPH_C32(0xe6bf0000), SPH_C32(0xc93a0000), SPH_C32(0x895dec40), + SPH_C32(0x80691e07), SPH_C32(0x249499a3), SPH_C32(0x2ee72578), + SPH_C32(0xaf9d2ffd) }, + { SPH_C32(0x25240000), SPH_C32(0x2dd70000), SPH_C32(0x15090000), + SPH_C32(0xfd50a0a0), SPH_C32(0x4fe35d75), SPH_C32(0x194410b1), + SPH_C32(0x892fe192), SPH_C32(0xad055af2), SPH_C32(0xe7990000), + SPH_C32(0xaaf40000), SPH_C32(0x616f0000), SPH_C32(0x5a8deea0), + SPH_C32(0x58082ebf), SPH_C32(0xbc332979), SPH_C32(0x067223cc), + SPH_C32(0x78c7676a) }, + { SPH_C32(0xc30c0000), SPH_C32(0x619c0000), SPH_C32(0xbd5c0000), + SPH_C32(0x2e80a240), SPH_C32(0x97826dcd), SPH_C32(0x81e3a06b), + SPH_C32(0xa1bae726), SPH_C32(0x7a5f1265), SPH_C32(0x175c0000), + SPH_C32(0xf3d70000), SPH_C32(0x24ed0000), SPH_C32(0xbb00ee60), + SPH_C32(0x6365288e), SPH_C32(0x7ede7fe0), SPH_C32(0xcd92ddd0), + SPH_C32(0x2e60d6f5) }, + { SPH_C32(0x61d00000), SPH_C32(0x03c70000), SPH_C32(0xe1d60000), + SPH_C32(0x630da480), SPH_C32(0x0c2c3a7c), SPH_C32(0x0abf8575), + SPH_C32(0x9099cb07), SPH_C32(0xb5cd9fb3), SPH_C32(0x12720000), + SPH_C32(0x025d0000), SPH_C32(0x0bab0000), SPH_C32(0xd722ece0), + SPH_C32(0x95be122c), SPH_C32(0x6bccf86b), SPH_C32(0x96c27062), + SPH_C32(0xa2ec8b5b) }, + { SPH_C32(0x87f80000), SPH_C32(0x4f8c0000), SPH_C32(0x49830000), + SPH_C32(0xb0dda660), SPH_C32(0xd44d0ac4), SPH_C32(0x921835af), + SPH_C32(0xb80ccdb3), SPH_C32(0x6297d724), SPH_C32(0xe2b70000), + SPH_C32(0x5b7e0000), SPH_C32(0x4e290000), SPH_C32(0x36afec20), + SPH_C32(0xaed3141d), SPH_C32(0xa921aef2), SPH_C32(0x5d228e7e), + SPH_C32(0xf44b3ac4) }, + { SPH_C32(0x91150000), SPH_C32(0x5ae40000), SPH_C32(0xa4540000), + SPH_C32(0x8280a440), SPH_C32(0x37413c4d), SPH_C32(0xc852d3ec), + SPH_C32(0x5b79351b), SPH_C32(0xe36a2e2c), SPH_C32(0x049f0000), + SPH_C32(0x17350000), SPH_C32(0xe67c0000), SPH_C32(0xe57feec0), + SPH_C32(0x76b224a5), SPH_C32(0x31861e28), SPH_C32(0x75b788ca), + SPH_C32(0x23117253) }, + { SPH_C32(0x773d0000), SPH_C32(0x16af0000), SPH_C32(0x0c010000), + SPH_C32(0x5150a6a0), SPH_C32(0xef200cf5), SPH_C32(0x50f56336), + SPH_C32(0x73ec33af), SPH_C32(0x343066bb), SPH_C32(0xf45a0000), + SPH_C32(0x4e160000), SPH_C32(0xa3fe0000), SPH_C32(0x04f2ee00), + SPH_C32(0x4ddf2294), SPH_C32(0xf36b48b1), SPH_C32(0xbe5776d6), + SPH_C32(0x75b6c3cc) }, + { SPH_C32(0x34150000), SPH_C32(0x6bb40000), SPH_C32(0x50a70000), + SPH_C32(0x4043d800), SPH_C32(0x442925b1), SPH_C32(0x51215aaf), + SPH_C32(0xf5c886bf), SPH_C32(0xdf46dbca), SPH_C32(0x1c9e0000), + SPH_C32(0x66c30000), SPH_C32(0x0d110000), SPH_C32(0x5fdac000), + SPH_C32(0x32596759), SPH_C32(0x8cc0f80c), SPH_C32(0xaece29ff), + SPH_C32(0xc6afe775) }, + { SPH_C32(0xd23d0000), SPH_C32(0x27ff0000), SPH_C32(0xf8f20000), + SPH_C32(0x9393dae0), SPH_C32(0x9c481509), SPH_C32(0xc986ea75), + SPH_C32(0xdd5d800b), SPH_C32(0x081c935d), SPH_C32(0xec5b0000), + SPH_C32(0x3fe00000), SPH_C32(0x48930000), SPH_C32(0xbe57c0c0), + SPH_C32(0x09346168), SPH_C32(0x4e2dae95), SPH_C32(0x652ed7e3), + SPH_C32(0x900856ea) }, + { SPH_C32(0xc4d00000), SPH_C32(0x32970000), SPH_C32(0x15250000), + SPH_C32(0xa1ced8c0), SPH_C32(0x7f442380), SPH_C32(0x93cc0c36), + SPH_C32(0x3e2878a3), SPH_C32(0x89e16a55), SPH_C32(0x0a730000), + SPH_C32(0x73ab0000), SPH_C32(0xe0c60000), SPH_C32(0x6d87c220), + SPH_C32(0xd15551d0), SPH_C32(0xd68a1e4f), SPH_C32(0x4dbbd157), + SPH_C32(0x47521e7d) }, + { SPH_C32(0x22f80000), SPH_C32(0x7edc0000), SPH_C32(0xbd700000), + SPH_C32(0x721eda20), SPH_C32(0xa7251338), SPH_C32(0x0b6bbcec), + SPH_C32(0x16bd7e17), SPH_C32(0x5ebb22c2), SPH_C32(0xfab60000), + SPH_C32(0x2a880000), SPH_C32(0xa5440000), SPH_C32(0x8c0ac2e0), + SPH_C32(0xea3857e1), SPH_C32(0x146748d6), SPH_C32(0x865b2f4b), + SPH_C32(0x11f5afe2) }, + { SPH_C32(0x80240000), SPH_C32(0x1c870000), SPH_C32(0xe1fa0000), + SPH_C32(0x3f93dce0), SPH_C32(0x3c8b4489), SPH_C32(0x803799f2), + SPH_C32(0x279e5236), SPH_C32(0x9129af14), SPH_C32(0xff980000), + SPH_C32(0xdb020000), SPH_C32(0x8a020000), SPH_C32(0xe028c060), + SPH_C32(0x1ce36d43), SPH_C32(0x0175cf5d), SPH_C32(0xdd0b82f9), + SPH_C32(0x9d79f24c) }, + { SPH_C32(0x660c0000), SPH_C32(0x50cc0000), SPH_C32(0x49af0000), + SPH_C32(0xec43de00), SPH_C32(0xe4ea7431), SPH_C32(0x18902928), + SPH_C32(0x0f0b5482), SPH_C32(0x4673e783), SPH_C32(0x0f5d0000), + SPH_C32(0x82210000), SPH_C32(0xcf800000), SPH_C32(0x01a5c0a0), + SPH_C32(0x278e6b72), SPH_C32(0xc39899c4), SPH_C32(0x16eb7ce5), + SPH_C32(0xcbde43d3) }, + { SPH_C32(0x70e10000), SPH_C32(0x45a40000), SPH_C32(0xa4780000), + SPH_C32(0xde1edc20), SPH_C32(0x07e642b8), SPH_C32(0x42dacf6b), + SPH_C32(0xec7eac2a), SPH_C32(0xc78e1e8b), SPH_C32(0xe9750000), + SPH_C32(0xce6a0000), SPH_C32(0x67d50000), SPH_C32(0xd275c240), + SPH_C32(0xffef5bca), SPH_C32(0x5b3f291e), SPH_C32(0x3e7e7a51), + SPH_C32(0x1c840b44) }, + { SPH_C32(0x96c90000), SPH_C32(0x09ef0000), SPH_C32(0x0c2d0000), + SPH_C32(0x0dcedec0), SPH_C32(0xdf877200), SPH_C32(0xda7d7fb1), + SPH_C32(0xc4ebaa9e), SPH_C32(0x10d4561c), SPH_C32(0x19b00000), + SPH_C32(0x97490000), SPH_C32(0x22570000), SPH_C32(0x33f8c280), + SPH_C32(0xc4825dfb), SPH_C32(0x99d27f87), SPH_C32(0xf59e844d), + SPH_C32(0x4a23badb) }, + { SPH_C32(0xd7130000), SPH_C32(0xd6750000), SPH_C32(0xd7b40000), + SPH_C32(0xffb1d860), SPH_C32(0x6a932fab), SPH_C32(0xdc946dfe), + SPH_C32(0x860d2db9), SPH_C32(0x8490cef3), SPH_C32(0x4ba90000), + SPH_C32(0xac310000), SPH_C32(0x3b5f0000), SPH_C32(0x9ff8c480), + SPH_C32(0x64410c7b), SPH_C32(0xd0630c00), SPH_C32(0x0f5d5670), + SPH_C32(0xd3168692) }, + { SPH_C32(0x313b0000), SPH_C32(0x9a3e0000), SPH_C32(0x7fe10000), + SPH_C32(0x2c61da80), SPH_C32(0xb2f21f13), SPH_C32(0x4433dd24), + SPH_C32(0xae982b0d), SPH_C32(0x53ca8664), SPH_C32(0xbb6c0000), + SPH_C32(0xf5120000), SPH_C32(0x7edd0000), SPH_C32(0x7e75c440), + SPH_C32(0x5f2c0a4a), SPH_C32(0x128e5a99), SPH_C32(0xc4bda86c), + SPH_C32(0x85b1370d) }, + { SPH_C32(0x27d60000), SPH_C32(0x8f560000), SPH_C32(0x92360000), + SPH_C32(0x1e3cd8a0), SPH_C32(0x51fe299a), SPH_C32(0x1e793b67), + SPH_C32(0x4dedd3a5), SPH_C32(0xd2377f6c), SPH_C32(0x5d440000), + SPH_C32(0xb9590000), SPH_C32(0xd6880000), SPH_C32(0xada5c6a0), + SPH_C32(0x874d3af2), SPH_C32(0x8a29ea43), SPH_C32(0xec28aed8), + SPH_C32(0x52eb7f9a) }, + { SPH_C32(0xc1fe0000), SPH_C32(0xc31d0000), SPH_C32(0x3a630000), + SPH_C32(0xcdecda40), SPH_C32(0x899f1922), SPH_C32(0x86de8bbd), + SPH_C32(0x6578d511), SPH_C32(0x056d37fb), SPH_C32(0xad810000), + SPH_C32(0xe07a0000), SPH_C32(0x930a0000), SPH_C32(0x4c28c660), + SPH_C32(0xbc203cc3), SPH_C32(0x48c4bcda), SPH_C32(0x27c850c4), + SPH_C32(0x044cce05) }, + { SPH_C32(0x63220000), SPH_C32(0xa1460000), SPH_C32(0x66e90000), + SPH_C32(0x8061dc80), SPH_C32(0x12314e93), SPH_C32(0x0d82aea3), + SPH_C32(0x545bf930), SPH_C32(0xcaffba2d), SPH_C32(0xa8af0000), + SPH_C32(0x11f00000), SPH_C32(0xbc4c0000), SPH_C32(0x200ac4e0), + SPH_C32(0x4afb0661), SPH_C32(0x5dd63b51), SPH_C32(0x7c98fd76), + SPH_C32(0x88c093ab) }, + { SPH_C32(0x850a0000), SPH_C32(0xed0d0000), SPH_C32(0xcebc0000), + SPH_C32(0x53b1de60), SPH_C32(0xca507e2b), SPH_C32(0x95251e79), + SPH_C32(0x7cceff84), SPH_C32(0x1da5f2ba), SPH_C32(0x586a0000), + SPH_C32(0x48d30000), SPH_C32(0xf9ce0000), SPH_C32(0xc187c420), + SPH_C32(0x71960050), SPH_C32(0x9f3b6dc8), SPH_C32(0xb778036a), + SPH_C32(0xde672234) }, + { SPH_C32(0x93e70000), SPH_C32(0xf8650000), SPH_C32(0x236b0000), + SPH_C32(0x61ecdc40), SPH_C32(0x295c48a2), SPH_C32(0xcf6ff83a), + SPH_C32(0x9fbb072c), SPH_C32(0x9c580bb2), SPH_C32(0xbe420000), + SPH_C32(0x04980000), SPH_C32(0x519b0000), SPH_C32(0x1257c6c0), + SPH_C32(0xa9f730e8), SPH_C32(0x079cdd12), SPH_C32(0x9fed05de), + SPH_C32(0x093d6aa3) }, + { SPH_C32(0x75cf0000), SPH_C32(0xb42e0000), SPH_C32(0x8b3e0000), + SPH_C32(0xb23cdea0), SPH_C32(0xf13d781a), SPH_C32(0x57c848e0), + SPH_C32(0xb72e0198), SPH_C32(0x4b024325), SPH_C32(0x4e870000), + SPH_C32(0x5dbb0000), SPH_C32(0x14190000), SPH_C32(0xf3dac600), + SPH_C32(0x929a36d9), SPH_C32(0xc5718b8b), SPH_C32(0x540dfbc2), + SPH_C32(0x5f9adb3c) } +}; + +static const sph_u32 T512_56[256][16] = { + { SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000), SPH_C32(0x00000000), SPH_C32(0x00000000), + SPH_C32(0x00000000) }, + { SPH_C32(0x033d0000), SPH_C32(0x08b30000), SPH_C32(0xf33a0000), + SPH_C32(0x3ac20007), SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), + SPH_C32(0x0ea5cfe3), SPH_C32(0xe6da7ffe), SPH_C32(0xa8da0000), + SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), SPH_C32(0x07da0002), + SPH_C32(0x7d669583), SPH_C32(0x1f98708a), SPH_C32(0xbb668808), + SPH_C32(0xda878000) }, + { SPH_C32(0xa8da0000), SPH_C32(0x96be0000), SPH_C32(0x5c1d0000), + SPH_C32(0x07da0002), SPH_C32(0x7d669583), SPH_C32(0x1f98708a), + SPH_C32(0xbb668808), SPH_C32(0xda878000), SPH_C32(0xabe70000), + SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), SPH_C32(0x3d180005), + SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), SPH_C32(0xb5c347eb), + SPH_C32(0x3c5dfffe) }, + { SPH_C32(0xabe70000), SPH_C32(0x9e0d0000), SPH_C32(0xaf270000), + SPH_C32(0x3d180005), SPH_C32(0x2c4f1fd3), SPH_C32(0x74f61695), + SPH_C32(0xb5c347eb), SPH_C32(0x3c5dfffe), SPH_C32(0x033d0000), + SPH_C32(0x08b30000), SPH_C32(0xf33a0000), SPH_C32(0x3ac20007), + SPH_C32(0x51298a50), SPH_C32(0x6b6e661f), SPH_C32(0x0ea5cfe3), + SPH_C32(0xe6da7ffe) }, + { SPH_C32(0x01930000), SPH_C32(0xe7820000), SPH_C32(0xedfb0000), + SPH_C32(0xcf0c000b), SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), + SPH_C32(0x063661e1), SPH_C32(0x536f9e7b), SPH_C32(0x92280000), + SPH_C32(0xdc850000), SPH_C32(0x57fa0000), SPH_C32(0x56dc0003), + SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), SPH_C32(0x90cef752), + SPH_C32(0x7b1675d7) }, + { SPH_C32(0x02ae0000), SPH_C32(0xef310000), SPH_C32(0x1ec10000), + SPH_C32(0xf5ce000c), SPH_C32(0xdcf90708), SPH_C32(0xd7cdd231), + SPH_C32(0x0893ae02), SPH_C32(0xb5b5e185), SPH_C32(0x3af20000), + SPH_C32(0x4a3b0000), SPH_C32(0x0be70000), SPH_C32(0x51060001), + SPH_C32(0xc78fb695), SPH_C32(0x4577d386), SPH_C32(0x2ba87f5a), + SPH_C32(0xa191f5d7) }, + { SPH_C32(0xa9490000), SPH_C32(0x713c0000), SPH_C32(0xb1e60000), + SPH_C32(0xc8d60009), SPH_C32(0xf0b618db), SPH_C32(0xa33bc4a4), + SPH_C32(0xbd50e9e9), SPH_C32(0x89e81e7b), SPH_C32(0x39cf0000), + SPH_C32(0x42880000), SPH_C32(0xf8dd0000), SPH_C32(0x6bc40006), + SPH_C32(0x96a63cc5), SPH_C32(0x2e19b599), SPH_C32(0x250db0b9), + SPH_C32(0x474b8a29) }, + { SPH_C32(0xaa740000), SPH_C32(0x798f0000), SPH_C32(0x42dc0000), + SPH_C32(0xf214000e), SPH_C32(0xa19f928b), SPH_C32(0xc855a2bb), + SPH_C32(0xb3f5260a), SPH_C32(0x6f326185), SPH_C32(0x91150000), + SPH_C32(0xd4360000), SPH_C32(0xa4c00000), SPH_C32(0x6c1e0004), + SPH_C32(0xebc0a946), SPH_C32(0x3181c513), SPH_C32(0x9e6b38b1), + SPH_C32(0x9dcc0a29) }, + { SPH_C32(0x92280000), SPH_C32(0xdc850000), SPH_C32(0x57fa0000), + SPH_C32(0x56dc0003), SPH_C32(0xbae92316), SPH_C32(0x5aefa30c), + SPH_C32(0x90cef752), SPH_C32(0x7b1675d7), SPH_C32(0x93bb0000), + SPH_C32(0x3b070000), SPH_C32(0xba010000), SPH_C32(0x99d00008), + SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), SPH_C32(0x96f896b3), + SPH_C32(0x2879ebac) }, + { SPH_C32(0x91150000), SPH_C32(0xd4360000), SPH_C32(0xa4c00000), + SPH_C32(0x6c1e0004), SPH_C32(0xebc0a946), SPH_C32(0x3181c513), + SPH_C32(0x9e6b38b1), SPH_C32(0x9dcc0a29), SPH_C32(0x3b610000), + SPH_C32(0xadb90000), SPH_C32(0xe61c0000), SPH_C32(0x9e0a000a), + SPH_C32(0x4a5f3bcd), SPH_C32(0xf9d467a8), SPH_C32(0x2d9e1ebb), + SPH_C32(0xf2fe6bac) }, + { SPH_C32(0x3af20000), SPH_C32(0x4a3b0000), SPH_C32(0x0be70000), + SPH_C32(0x51060001), SPH_C32(0xc78fb695), SPH_C32(0x4577d386), + SPH_C32(0x2ba87f5a), SPH_C32(0xa191f5d7), SPH_C32(0x385c0000), + SPH_C32(0xa50a0000), SPH_C32(0x15260000), SPH_C32(0xa4c8000d), + SPH_C32(0x1b76b19d), SPH_C32(0x92ba01b7), SPH_C32(0x233bd158), + SPH_C32(0x14241452) }, + { SPH_C32(0x39cf0000), SPH_C32(0x42880000), SPH_C32(0xf8dd0000), + SPH_C32(0x6bc40006), SPH_C32(0x96a63cc5), SPH_C32(0x2e19b599), + SPH_C32(0x250db0b9), SPH_C32(0x474b8a29), SPH_C32(0x90860000), + SPH_C32(0x33b40000), SPH_C32(0x493b0000), SPH_C32(0xa312000f), + SPH_C32(0x6610241e), SPH_C32(0x8d22713d), SPH_C32(0x985d5950), + SPH_C32(0xcea39452) }, + { SPH_C32(0x93bb0000), SPH_C32(0x3b070000), SPH_C32(0xba010000), + SPH_C32(0x99d00008), SPH_C32(0x3739ae4e), SPH_C32(0xe64c1722), + SPH_C32(0x96f896b3), SPH_C32(0x2879ebac), SPH_C32(0x01930000), + SPH_C32(0xe7820000), SPH_C32(0xedfb0000), SPH_C32(0xcf0c000b), + SPH_C32(0x8dd08d58), SPH_C32(0xbca3b42e), SPH_C32(0x063661e1), + SPH_C32(0x536f9e7b) }, + { SPH_C32(0x90860000), SPH_C32(0x33b40000), SPH_C32(0x493b0000), + SPH_C32(0xa312000f), SPH_C32(0x6610241e), SPH_C32(0x8d22713d), + SPH_C32(0x985d5950), SPH_C32(0xcea39452), SPH_C32(0xa9490000), + SPH_C32(0x713c0000), SPH_C32(0xb1e60000), SPH_C32(0xc8d60009), + SPH_C32(0xf0b618db), SPH_C32(0xa33bc4a4), SPH_C32(0xbd50e9e9), + SPH_C32(0x89e81e7b) }, + { SPH_C32(0x3b610000), SPH_C32(0xadb90000), SPH_C32(0xe61c0000), + SPH_C32(0x9e0a000a), SPH_C32(0x4a5f3bcd), SPH_C32(0xf9d467a8), + SPH_C32(0x2d9e1ebb), SPH_C32(0xf2fe6bac), SPH_C32(0xaa740000), + SPH_C32(0x798f0000), SPH_C32(0x42dc0000), SPH_C32(0xf214000e), + SPH_C32(0xa19f928b), SPH_C32(0xc855a2bb), SPH_C32(0xb3f5260a), + SPH_C32(0x6f326185) }, + { SPH_C32(0x385c0000), SPH_C32(0xa50a0000), SPH_C32(0x15260000), + SPH_C32(0xa4c8000d), SPH_C32(0x1b76b19d), SPH_C32(0x92ba01b7), + SPH_C32(0x233bd158), SPH_C32(0x14241452), SPH_C32(0x02ae0000), + SPH_C32(0xef310000), SPH_C32(0x1ec10000), SPH_C32(0xf5ce000c), + SPH_C32(0xdcf90708), SPH_C32(0xd7cdd231), SPH_C32(0x0893ae02), + SPH_C32(0xb5b5e185) }, + { SPH_C32(0x5fa80000), SPH_C32(0x56030000), SPH_C32(0x43ae0000), + SPH_C32(0x64f30013), SPH_C32(0x257e86bf), SPH_C32(0x1311944e), + SPH_C32(0x541e95bf), SPH_C32(0x8ea4db69), SPH_C32(0x00440000), + SPH_C32(0x7f480000), SPH_C32(0xda7c0000), SPH_C32(0x2a230001), + SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), SPH_C32(0x030a9e60), + SPH_C32(0xbe0a679e) }, + { SPH_C32(0x5c950000), SPH_C32(0x5eb00000), SPH_C32(0xb0940000), + SPH_C32(0x5e310014), SPH_C32(0x74570cef), SPH_C32(0x787ff251), + SPH_C32(0x5abb5a5c), SPH_C32(0x687ea497), SPH_C32(0xa89e0000), + SPH_C32(0xe9f60000), SPH_C32(0x86610000), SPH_C32(0x2df90003), + SPH_C32(0x46cb5c4f), SPH_C32(0xb62eec0d), SPH_C32(0xb86c1668), + SPH_C32(0x648de79e) }, + { SPH_C32(0xf7720000), SPH_C32(0xc0bd0000), SPH_C32(0x1fb30000), + SPH_C32(0x63290011), SPH_C32(0x5818133c), SPH_C32(0x0c89e4c4), + SPH_C32(0xef781db7), SPH_C32(0x54235b69), SPH_C32(0xaba30000), + SPH_C32(0xe1450000), SPH_C32(0x755b0000), SPH_C32(0x173b0004), + SPH_C32(0x17e2d61f), SPH_C32(0xdd408a12), SPH_C32(0xb6c9d98b), + SPH_C32(0x82579860) }, + { SPH_C32(0xf44f0000), SPH_C32(0xc80e0000), SPH_C32(0xec890000), + SPH_C32(0x59eb0016), SPH_C32(0x0931996c), SPH_C32(0x67e782db), + SPH_C32(0xe1ddd254), SPH_C32(0xb2f92497), SPH_C32(0x03790000), + SPH_C32(0x77fb0000), SPH_C32(0x29460000), SPH_C32(0x10e10006), + SPH_C32(0x6a84439c), SPH_C32(0xc2d8fa98), SPH_C32(0x0daf5183), + SPH_C32(0x58d01860) }, + { SPH_C32(0x5e3b0000), SPH_C32(0xb1810000), SPH_C32(0xae550000), + SPH_C32(0xabff0018), SPH_C32(0xa8ae0be7), SPH_C32(0xafb22060), + SPH_C32(0x5228f45e), SPH_C32(0xddcb4512), SPH_C32(0x926c0000), + SPH_C32(0xa3cd0000), SPH_C32(0x8d860000), SPH_C32(0x7cff0002), + SPH_C32(0x8144eada), SPH_C32(0xf3593f8b), SPH_C32(0x93c46932), + SPH_C32(0xc51c1249) }, + { SPH_C32(0x5d060000), SPH_C32(0xb9320000), SPH_C32(0x5d6f0000), + SPH_C32(0x913d001f), SPH_C32(0xf98781b7), SPH_C32(0xc4dc467f), + SPH_C32(0x5c8d3bbd), SPH_C32(0x3b113aec), SPH_C32(0x3ab60000), + SPH_C32(0x35730000), SPH_C32(0xd19b0000), SPH_C32(0x7b250000), + SPH_C32(0xfc227f59), SPH_C32(0xecc14f01), SPH_C32(0x28a2e13a), + SPH_C32(0x1f9b9249) }, + { SPH_C32(0xf6e10000), SPH_C32(0x273f0000), SPH_C32(0xf2480000), + SPH_C32(0xac25001a), SPH_C32(0xd5c89e64), SPH_C32(0xb02a50ea), + SPH_C32(0xe94e7c56), SPH_C32(0x074cc512), SPH_C32(0x398b0000), + SPH_C32(0x3dc00000), SPH_C32(0x22a10000), SPH_C32(0x41e70007), + SPH_C32(0xad0bf509), SPH_C32(0x87af291e), SPH_C32(0x26072ed9), + SPH_C32(0xf941edb7) }, + { SPH_C32(0xf5dc0000), SPH_C32(0x2f8c0000), SPH_C32(0x01720000), + SPH_C32(0x96e7001d), SPH_C32(0x84e11434), SPH_C32(0xdb4436f5), + SPH_C32(0xe7ebb3b5), SPH_C32(0xe196baec), SPH_C32(0x91510000), + SPH_C32(0xab7e0000), SPH_C32(0x7ebc0000), SPH_C32(0x463d0005), + SPH_C32(0xd06d608a), SPH_C32(0x98375994), SPH_C32(0x9d61a6d1), + SPH_C32(0x23c66db7) }, + { SPH_C32(0xcd800000), SPH_C32(0x8a860000), SPH_C32(0x14540000), + SPH_C32(0x322f0010), SPH_C32(0x9f97a5a9), SPH_C32(0x49fe3742), + SPH_C32(0xc4d062ed), SPH_C32(0xf5b2aebe), SPH_C32(0x93ff0000), + SPH_C32(0x444f0000), SPH_C32(0x607d0000), SPH_C32(0xb3f30009), + SPH_C32(0x0c946782), SPH_C32(0x4ffa8ba5), SPH_C32(0x95f208d3), + SPH_C32(0x96738c32) }, + { SPH_C32(0xcebd0000), SPH_C32(0x82350000), SPH_C32(0xe76e0000), + SPH_C32(0x08ed0017), SPH_C32(0xcebe2ff9), SPH_C32(0x2290515d), + SPH_C32(0xca75ad0e), SPH_C32(0x1368d140), SPH_C32(0x3b250000), + SPH_C32(0xd2f10000), SPH_C32(0x3c600000), SPH_C32(0xb429000b), + SPH_C32(0x71f2f201), SPH_C32(0x5062fb2f), SPH_C32(0x2e9480db), + SPH_C32(0x4cf40c32) }, + { SPH_C32(0x655a0000), SPH_C32(0x1c380000), SPH_C32(0x48490000), + SPH_C32(0x35f50012), SPH_C32(0xe2f1302a), SPH_C32(0x566647c8), + SPH_C32(0x7fb6eae5), SPH_C32(0x2f352ebe), SPH_C32(0x38180000), + SPH_C32(0xda420000), SPH_C32(0xcf5a0000), SPH_C32(0x8eeb000c), + SPH_C32(0x20db7851), SPH_C32(0x3b0c9d30), SPH_C32(0x20314f38), + SPH_C32(0xaa2e73cc) }, + { SPH_C32(0x66670000), SPH_C32(0x148b0000), SPH_C32(0xbb730000), + SPH_C32(0x0f370015), SPH_C32(0xb3d8ba7a), SPH_C32(0x3d0821d7), + SPH_C32(0x71132506), SPH_C32(0xc9ef5140), SPH_C32(0x90c20000), + SPH_C32(0x4cfc0000), SPH_C32(0x93470000), SPH_C32(0x8931000e), + SPH_C32(0x5dbdedd2), SPH_C32(0x2494edba), SPH_C32(0x9b57c730), + SPH_C32(0x70a9f3cc) }, + { SPH_C32(0xcc130000), SPH_C32(0x6d040000), SPH_C32(0xf9af0000), + SPH_C32(0xfd23001b), SPH_C32(0x124728f1), SPH_C32(0xf55d836c), + SPH_C32(0xc2e6030c), SPH_C32(0xa6dd30c5), SPH_C32(0x01d70000), + SPH_C32(0x98ca0000), SPH_C32(0x37870000), SPH_C32(0xe52f000a), + SPH_C32(0xb67d4494), SPH_C32(0x151528a9), SPH_C32(0x053cff81), + SPH_C32(0xed65f9e5) }, + { SPH_C32(0xcf2e0000), SPH_C32(0x65b70000), SPH_C32(0x0a950000), + SPH_C32(0xc7e1001c), SPH_C32(0x436ea2a1), SPH_C32(0x9e33e573), + SPH_C32(0xcc43ccef), SPH_C32(0x40074f3b), SPH_C32(0xa90d0000), + SPH_C32(0x0e740000), SPH_C32(0x6b9a0000), SPH_C32(0xe2f50008), + SPH_C32(0xcb1bd117), SPH_C32(0x0a8d5823), SPH_C32(0xbe5a7789), + SPH_C32(0x37e279e5) }, + { SPH_C32(0x64c90000), SPH_C32(0xfbba0000), SPH_C32(0xa5b20000), + SPH_C32(0xfaf90019), SPH_C32(0x6f21bd72), SPH_C32(0xeac5f3e6), + SPH_C32(0x79808b04), SPH_C32(0x7c5ab0c5), SPH_C32(0xaa300000), + SPH_C32(0x06c70000), SPH_C32(0x98a00000), SPH_C32(0xd837000f), + SPH_C32(0x9a325b47), SPH_C32(0x61e33e3c), SPH_C32(0xb0ffb86a), + SPH_C32(0xd138061b) }, + { SPH_C32(0x67f40000), SPH_C32(0xf3090000), SPH_C32(0x56880000), + SPH_C32(0xc03b001e), SPH_C32(0x3e083722), SPH_C32(0x81ab95f9), + SPH_C32(0x772544e7), SPH_C32(0x9a80cf3b), SPH_C32(0x02ea0000), + SPH_C32(0x90790000), SPH_C32(0xc4bd0000), SPH_C32(0xdfed000d), + SPH_C32(0xe754cec4), SPH_C32(0x7e7b4eb6), SPH_C32(0x0b993062), + SPH_C32(0x0bbf861b) }, + { SPH_C32(0x00440000), SPH_C32(0x7f480000), SPH_C32(0xda7c0000), + SPH_C32(0x2a230001), SPH_C32(0x3badc9cc), SPH_C32(0xa9b69c87), + SPH_C32(0x030a9e60), SPH_C32(0xbe0a679e), SPH_C32(0x5fec0000), + SPH_C32(0x294b0000), SPH_C32(0x99d20000), SPH_C32(0x4ed00012), + SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), SPH_C32(0x57140bdf), + SPH_C32(0x30aebcf7) }, + { SPH_C32(0x03790000), SPH_C32(0x77fb0000), SPH_C32(0x29460000), + SPH_C32(0x10e10006), SPH_C32(0x6a84439c), SPH_C32(0xc2d8fa98), + SPH_C32(0x0daf5183), SPH_C32(0x58d01860), SPH_C32(0xf7360000), + SPH_C32(0xbff50000), SPH_C32(0xc5cf0000), SPH_C32(0x490a0010), + SPH_C32(0x63b5daf0), SPH_C32(0xa53f7843), SPH_C32(0xec7283d7), + SPH_C32(0xea293cf7) }, + { SPH_C32(0xa89e0000), SPH_C32(0xe9f60000), SPH_C32(0x86610000), + SPH_C32(0x2df90003), SPH_C32(0x46cb5c4f), SPH_C32(0xb62eec0d), + SPH_C32(0xb86c1668), SPH_C32(0x648de79e), SPH_C32(0xf40b0000), + SPH_C32(0xb7460000), SPH_C32(0x36f50000), SPH_C32(0x73c80017), + SPH_C32(0x329c50a0), SPH_C32(0xce511e5c), SPH_C32(0xe2d74c34), + SPH_C32(0x0cf34309) }, + { SPH_C32(0xaba30000), SPH_C32(0xe1450000), SPH_C32(0x755b0000), + SPH_C32(0x173b0004), SPH_C32(0x17e2d61f), SPH_C32(0xdd408a12), + SPH_C32(0xb6c9d98b), SPH_C32(0x82579860), SPH_C32(0x5cd10000), + SPH_C32(0x21f80000), SPH_C32(0x6ae80000), SPH_C32(0x74120015), + SPH_C32(0x4ffac523), SPH_C32(0xd1c96ed6), SPH_C32(0x59b1c43c), + SPH_C32(0xd674c309) }, + { SPH_C32(0x01d70000), SPH_C32(0x98ca0000), SPH_C32(0x37870000), + SPH_C32(0xe52f000a), SPH_C32(0xb67d4494), SPH_C32(0x151528a9), + SPH_C32(0x053cff81), SPH_C32(0xed65f9e5), SPH_C32(0xcdc40000), + SPH_C32(0xf5ce0000), SPH_C32(0xce280000), SPH_C32(0x180c0011), + SPH_C32(0xa43a6c65), SPH_C32(0xe048abc5), SPH_C32(0xc7dafc8d), + SPH_C32(0x4bb8c920) }, + { SPH_C32(0x02ea0000), SPH_C32(0x90790000), SPH_C32(0xc4bd0000), + SPH_C32(0xdfed000d), SPH_C32(0xe754cec4), SPH_C32(0x7e7b4eb6), + SPH_C32(0x0b993062), SPH_C32(0x0bbf861b), SPH_C32(0x651e0000), + SPH_C32(0x63700000), SPH_C32(0x92350000), SPH_C32(0x1fd60013), + SPH_C32(0xd95cf9e6), SPH_C32(0xffd0db4f), SPH_C32(0x7cbc7485), + SPH_C32(0x913f4920) }, + { SPH_C32(0xa90d0000), SPH_C32(0x0e740000), SPH_C32(0x6b9a0000), + SPH_C32(0xe2f50008), SPH_C32(0xcb1bd117), SPH_C32(0x0a8d5823), + SPH_C32(0xbe5a7789), SPH_C32(0x37e279e5), SPH_C32(0x66230000), + SPH_C32(0x6bc30000), SPH_C32(0x610f0000), SPH_C32(0x25140014), + SPH_C32(0x887573b6), SPH_C32(0x94bebd50), SPH_C32(0x7219bb66), + SPH_C32(0x77e536de) }, + { SPH_C32(0xaa300000), SPH_C32(0x06c70000), SPH_C32(0x98a00000), + SPH_C32(0xd837000f), SPH_C32(0x9a325b47), SPH_C32(0x61e33e3c), + SPH_C32(0xb0ffb86a), SPH_C32(0xd138061b), SPH_C32(0xcef90000), + SPH_C32(0xfd7d0000), SPH_C32(0x3d120000), SPH_C32(0x22ce0016), + SPH_C32(0xf513e635), SPH_C32(0x8b26cdda), SPH_C32(0xc97f336e), + SPH_C32(0xad62b6de) }, + { SPH_C32(0x926c0000), SPH_C32(0xa3cd0000), SPH_C32(0x8d860000), + SPH_C32(0x7cff0002), SPH_C32(0x8144eada), SPH_C32(0xf3593f8b), + SPH_C32(0x93c46932), SPH_C32(0xc51c1249), SPH_C32(0xcc570000), + SPH_C32(0x124c0000), SPH_C32(0x23d30000), SPH_C32(0xd700001a), + SPH_C32(0x29eae13d), SPH_C32(0x5ceb1feb), SPH_C32(0xc1ec9d6c), + SPH_C32(0x18d7575b) }, + { SPH_C32(0x91510000), SPH_C32(0xab7e0000), SPH_C32(0x7ebc0000), + SPH_C32(0x463d0005), SPH_C32(0xd06d608a), SPH_C32(0x98375994), + SPH_C32(0x9d61a6d1), SPH_C32(0x23c66db7), SPH_C32(0x648d0000), + SPH_C32(0x84f20000), SPH_C32(0x7fce0000), SPH_C32(0xd0da0018), + SPH_C32(0x548c74be), SPH_C32(0x43736f61), SPH_C32(0x7a8a1564), + SPH_C32(0xc250d75b) }, + { SPH_C32(0x3ab60000), SPH_C32(0x35730000), SPH_C32(0xd19b0000), + SPH_C32(0x7b250000), SPH_C32(0xfc227f59), SPH_C32(0xecc14f01), + SPH_C32(0x28a2e13a), SPH_C32(0x1f9b9249), SPH_C32(0x67b00000), + SPH_C32(0x8c410000), SPH_C32(0x8cf40000), SPH_C32(0xea18001f), + SPH_C32(0x05a5feee), SPH_C32(0x281d097e), SPH_C32(0x742fda87), + SPH_C32(0x248aa8a5) }, + { SPH_C32(0x398b0000), SPH_C32(0x3dc00000), SPH_C32(0x22a10000), + SPH_C32(0x41e70007), SPH_C32(0xad0bf509), SPH_C32(0x87af291e), + SPH_C32(0x26072ed9), SPH_C32(0xf941edb7), SPH_C32(0xcf6a0000), + SPH_C32(0x1aff0000), SPH_C32(0xd0e90000), SPH_C32(0xedc2001d), + SPH_C32(0x78c36b6d), SPH_C32(0x378579f4), SPH_C32(0xcf49528f), + SPH_C32(0xfe0d28a5) }, + { SPH_C32(0x93ff0000), SPH_C32(0x444f0000), SPH_C32(0x607d0000), + SPH_C32(0xb3f30009), SPH_C32(0x0c946782), SPH_C32(0x4ffa8ba5), + SPH_C32(0x95f208d3), SPH_C32(0x96738c32), SPH_C32(0x5e7f0000), + SPH_C32(0xcec90000), SPH_C32(0x74290000), SPH_C32(0x81dc0019), + SPH_C32(0x9303c22b), SPH_C32(0x0604bce7), SPH_C32(0x51226a3e), + SPH_C32(0x63c1228c) }, + { SPH_C32(0x90c20000), SPH_C32(0x4cfc0000), SPH_C32(0x93470000), + SPH_C32(0x8931000e), SPH_C32(0x5dbdedd2), SPH_C32(0x2494edba), + SPH_C32(0x9b57c730), SPH_C32(0x70a9f3cc), SPH_C32(0xf6a50000), + SPH_C32(0x58770000), SPH_C32(0x28340000), SPH_C32(0x8606001b), + SPH_C32(0xee6557a8), SPH_C32(0x199ccc6d), SPH_C32(0xea44e236), + SPH_C32(0xb946a28c) }, + { SPH_C32(0x3b250000), SPH_C32(0xd2f10000), SPH_C32(0x3c600000), + SPH_C32(0xb429000b), SPH_C32(0x71f2f201), SPH_C32(0x5062fb2f), + SPH_C32(0x2e9480db), SPH_C32(0x4cf40c32), SPH_C32(0xf5980000), + SPH_C32(0x50c40000), SPH_C32(0xdb0e0000), SPH_C32(0xbcc4001c), + SPH_C32(0xbf4cddf8), SPH_C32(0x72f2aa72), SPH_C32(0xe4e12dd5), + SPH_C32(0x5f9cdd72) }, + { SPH_C32(0x38180000), SPH_C32(0xda420000), SPH_C32(0xcf5a0000), + SPH_C32(0x8eeb000c), SPH_C32(0x20db7851), SPH_C32(0x3b0c9d30), + SPH_C32(0x20314f38), SPH_C32(0xaa2e73cc), SPH_C32(0x5d420000), + SPH_C32(0xc67a0000), SPH_C32(0x87130000), SPH_C32(0xbb1e001e), + SPH_C32(0xc22a487b), SPH_C32(0x6d6adaf8), SPH_C32(0x5f87a5dd), + SPH_C32(0x851b5d72) }, + { SPH_C32(0x5fec0000), SPH_C32(0x294b0000), SPH_C32(0x99d20000), + SPH_C32(0x4ed00012), SPH_C32(0x1ed34f73), SPH_C32(0xbaa708c9), + SPH_C32(0x57140bdf), SPH_C32(0x30aebcf7), SPH_C32(0x5fa80000), + SPH_C32(0x56030000), SPH_C32(0x43ae0000), SPH_C32(0x64f30013), + SPH_C32(0x257e86bf), SPH_C32(0x1311944e), SPH_C32(0x541e95bf), + SPH_C32(0x8ea4db69) }, + { SPH_C32(0x5cd10000), SPH_C32(0x21f80000), SPH_C32(0x6ae80000), + SPH_C32(0x74120015), SPH_C32(0x4ffac523), SPH_C32(0xd1c96ed6), + SPH_C32(0x59b1c43c), SPH_C32(0xd674c309), SPH_C32(0xf7720000), + SPH_C32(0xc0bd0000), SPH_C32(0x1fb30000), SPH_C32(0x63290011), + SPH_C32(0x5818133c), SPH_C32(0x0c89e4c4), SPH_C32(0xef781db7), + SPH_C32(0x54235b69) }, + { SPH_C32(0xf7360000), SPH_C32(0xbff50000), SPH_C32(0xc5cf0000), + SPH_C32(0x490a0010), SPH_C32(0x63b5daf0), SPH_C32(0xa53f7843), + SPH_C32(0xec7283d7), SPH_C32(0xea293cf7), SPH_C32(0xf44f0000), + SPH_C32(0xc80e0000), SPH_C32(0xec890000), SPH_C32(0x59eb0016), + SPH_C32(0x0931996c), SPH_C32(0x67e782db), SPH_C32(0xe1ddd254), + SPH_C32(0xb2f92497) }, + { SPH_C32(0xf40b0000), SPH_C32(0xb7460000), SPH_C32(0x36f50000), + SPH_C32(0x73c80017), SPH_C32(0x329c50a0), SPH_C32(0xce511e5c), + SPH_C32(0xe2d74c34), SPH_C32(0x0cf34309), SPH_C32(0x5c950000), + SPH_C32(0x5eb00000), SPH_C32(0xb0940000), SPH_C32(0x5e310014), + SPH_C32(0x74570cef), SPH_C32(0x787ff251), SPH_C32(0x5abb5a5c), + SPH_C32(0x687ea497) }, + { SPH_C32(0x5e7f0000), SPH_C32(0xcec90000), SPH_C32(0x74290000), + SPH_C32(0x81dc0019), SPH_C32(0x9303c22b), SPH_C32(0x0604bce7), + SPH_C32(0x51226a3e), SPH_C32(0x63c1228c), SPH_C32(0xcd800000), + SPH_C32(0x8a860000), SPH_C32(0x14540000), SPH_C32(0x322f0010), + SPH_C32(0x9f97a5a9), SPH_C32(0x49fe3742), SPH_C32(0xc4d062ed), + SPH_C32(0xf5b2aebe) }, + { SPH_C32(0x5d420000), SPH_C32(0xc67a0000), SPH_C32(0x87130000), + SPH_C32(0xbb1e001e), SPH_C32(0xc22a487b), SPH_C32(0x6d6adaf8), + SPH_C32(0x5f87a5dd), SPH_C32(0x851b5d72), SPH_C32(0x655a0000), + SPH_C32(0x1c380000), SPH_C32(0x48490000), SPH_C32(0x35f50012), + SPH_C32(0xe2f1302a), SPH_C32(0x566647c8), SPH_C32(0x7fb6eae5), + SPH_C32(0x2f352ebe) }, + { SPH_C32(0xf6a50000), SPH_C32(0x58770000), SPH_C32(0x28340000), + SPH_C32(0x8606001b), SPH_C32(0xee6557a8), SPH_C32(0x199ccc6d), + SPH_C32(0xea44e236), SPH_C32(0xb946a28c), SPH_C32(0x66670000), + SPH_C32(0x148b0000), SPH_C32(0xbb730000), SPH_C32(0x0f370015), + SPH_C32(0xb3d8ba7a), SPH_C32(0x3d0821d7), SPH_C32(0x71132506), + SPH_C32(0xc9ef5140) }, + { SPH_C32(0xf5980000), SPH_C32(0x50c40000), SPH_C32(0xdb0e0000), + SPH_C32(0xbcc4001c), SPH_C32(0xbf4cddf8), SPH_C32(0x72f2aa72), + SPH_C32(0xe4e12dd5), SPH_C32(0x5f9cdd72), SPH_C32(0xcebd0000), + SPH_C32(0x82350000), SPH_C32(0xe76e0000), SPH_C32(0x08ed0017), + SPH_C32(0xcebe2ff9), SPH_C32(0x2290515d), SPH_C32(0xca75ad0e), + SPH_C32(0x1368d140) }, + { SPH_C32(0xcdc40000), SPH_C32(0xf5ce0000), SPH_C32(0xce280000), + SPH_C32(0x180c0011), SPH_C32(0xa43a6c65), SPH_C32(0xe048abc5), + SPH_C32(0xc7dafc8d), SPH_C32(0x4bb8c920), SPH_C32(0xcc130000), + SPH_C32(0x6d040000), SPH_C32(0xf9af0000), SPH_C32(0xfd23001b), + SPH_C32(0x124728f1), SPH_C32(0xf55d836c), SPH_C32(0xc2e6030c), + SPH_C32(0xa6dd30c5) }, + { SPH_C32(0xcef90000), SPH_C32(0xfd7d0000), SPH_C32(0x3d120000), + SPH_C32(0x22ce0016), SPH_C32(0xf513e635), SPH_C32(0x8b26cdda), + SPH_C32(0xc97f336e), SPH_C32(0xad62b6de), SPH_C32(0x64c90000), + SPH_C32(0xfbba0000), SPH_C32(0xa5b20000), SPH_C32(0xfaf90019), + SPH_C32(0x6f21bd72), SPH_C32(0xeac5f3e6), SPH_C32(0x79808b04), + SPH_C32(0x7c5ab0c5) }, + { SPH_C32(0x651e0000), SPH_C32(0x63700000), SPH_C32(0x92350000), + SPH_C32(0x1fd60013), SPH_C32(0xd95cf9e6), SPH_C32(0xffd0db4f), + SPH_C32(0x7cbc7485), SPH_C32(0x913f4920), SPH_C32(0x67f40000), + SPH_C32(0xf3090000), SPH_C32(0x56880000), SPH_C32(0xc03b001e), + SPH_C32(0x3e083722), SPH_C32(0x81ab95f9), SPH_C32(0x772544e7), + SPH_C32(0x9a80cf3b) }, + { SPH_C32(0x66230000), SPH_C32(0x6bc30000), SPH_C32(0x610f0000), + SPH_C32(0x25140014), SPH_C32(0x887573b6), SPH_C32(0x94bebd50), + SPH_C32(0x7219bb66), SPH_C32(0x77e536de), SPH_C32(0xcf2e0000), + SPH_C32(0x65b70000), SPH_C32(0x0a950000), SPH_C32(0xc7e1001c), + SPH_C32(0x436ea2a1), SPH_C32(0x9e33e573), SPH_C32(0xcc43ccef), + SPH_C32(0x40074f3b) }, + { SPH_C32(0xcc570000), SPH_C32(0x124c0000), SPH_C32(0x23d30000), + SPH_C32(0xd700001a), SPH_C32(0x29eae13d), SPH_C32(0x5ceb1feb), + SPH_C32(0xc1ec9d6c), SPH_C32(0x18d7575b), SPH_C32(0x5e3b0000), + SPH_C32(0xb1810000), SPH_C32(0xae550000), SPH_C32(0xabff0018), + SPH_C32(0xa8ae0be7), SPH_C32(0xafb22060), SPH_C32(0x5228f45e), + SPH_C32(0xddcb4512) }, + { SPH_C32(0xcf6a0000), SPH_C32(0x1aff0000), SPH_C32(0xd0e90000), + SPH_C32(0xedc2001d), SPH_C32(0x78c36b6d), SPH_C32(0x378579f4), + SPH_C32(0xcf49528f), SPH_C32(0xfe0d28a5), SPH_C32(0xf6e10000), + SPH_C32(0x273f0000), SPH_C32(0xf2480000), SPH_C32(0xac25001a), + SPH_C32(0xd5c89e64), SPH_C32(0xb02a50ea), SPH_C32(0xe94e7c56), + SPH_C32(0x074cc512) }, + { SPH_C32(0x648d0000), SPH_C32(0x84f20000), SPH_C32(0x7fce0000), + SPH_C32(0xd0da0018), SPH_C32(0x548c74be), SPH_C32(0x43736f61), + SPH_C32(0x7a8a1564), SPH_C32(0xc250d75b), SPH_C32(0xf5dc0000), + SPH_C32(0x2f8c0000), SPH_C32(0x01720000), SPH_C32(0x96e7001d), + SPH_C32(0x84e11434), SPH_C32(0xdb4436f5), SPH_C32(0xe7ebb3b5), + SPH_C32(0xe196baec) }, + { SPH_C32(0x67b00000), SPH_C32(0x8c410000), SPH_C32(0x8cf40000), + SPH_C32(0xea18001f), SPH_C32(0x05a5feee), SPH_C32(0x281d097e), + SPH_C32(0x742fda87), SPH_C32(0x248aa8a5), SPH_C32(0x5d060000), + SPH_C32(0xb9320000), SPH_C32(0x5d6f0000), SPH_C32(0x913d001f), + SPH_C32(0xf98781b7), SPH_C32(0xc4dc467f), SPH_C32(0x5c8d3bbd), + SPH_C32(0x3b113aec) }, + { SPH_C32(0xee930000), SPH_C32(0xd6070000), SPH_C32(0x92c10000), + SPH_C32(0x2b9801e0), SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), + SPH_C32(0x45312374), SPH_C32(0x201f6a64), SPH_C32(0x7b280000), + SPH_C32(0x57420000), SPH_C32(0xa9e50000), SPH_C32(0x634300a0), + SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), SPH_C32(0x27f83b03), + SPH_C32(0xc7ff60f0) }, + { SPH_C32(0xedae0000), SPH_C32(0xdeb40000), SPH_C32(0x61fb0000), + SPH_C32(0x115a01e7), SPH_C32(0xc578a22c), SPH_C32(0x50029d48), + SPH_C32(0x4b94ec97), SPH_C32(0xc6c5159a), SPH_C32(0xd3f20000), + SPH_C32(0xc1fc0000), SPH_C32(0xf5f80000), SPH_C32(0x649900a2), + SPH_C32(0xe3bdd1ac), SPH_C32(0x7201e531), SPH_C32(0x9c9eb30b), + SPH_C32(0x1d78e0f0) }, + { SPH_C32(0x46490000), SPH_C32(0x40b90000), SPH_C32(0xcedc0000), + SPH_C32(0x2c4201e2), SPH_C32(0xe937bdff), SPH_C32(0x24f48bdd), + SPH_C32(0xfe57ab7c), SPH_C32(0xfa98ea64), SPH_C32(0xd0cf0000), + SPH_C32(0xc94f0000), SPH_C32(0x06c20000), SPH_C32(0x5e5b00a5), + SPH_C32(0xb2945bfc), SPH_C32(0x196f832e), SPH_C32(0x923b7ce8), + SPH_C32(0xfba29f0e) }, + { SPH_C32(0x45740000), SPH_C32(0x480a0000), SPH_C32(0x3de60000), + SPH_C32(0x168001e5), SPH_C32(0xb81e37af), SPH_C32(0x4f9aedc2), + SPH_C32(0xf0f2649f), SPH_C32(0x1c42959a), SPH_C32(0x78150000), + SPH_C32(0x5ff10000), SPH_C32(0x5adf0000), SPH_C32(0x598100a7), + SPH_C32(0xcff2ce7f), SPH_C32(0x06f7f3a4), SPH_C32(0x295df4e0), + SPH_C32(0x21251f0e) }, + { SPH_C32(0xef000000), SPH_C32(0x31850000), SPH_C32(0x7f3a0000), + SPH_C32(0xe49401eb), SPH_C32(0x1981a524), SPH_C32(0x87cf4f79), + SPH_C32(0x43074295), SPH_C32(0x7370f41f), SPH_C32(0xe9000000), + SPH_C32(0x8bc70000), SPH_C32(0xfe1f0000), SPH_C32(0x359f00a3), + SPH_C32(0x24326739), SPH_C32(0x377636b7), SPH_C32(0xb736cc51), + SPH_C32(0xbce91527) }, + { SPH_C32(0xec3d0000), SPH_C32(0x39360000), SPH_C32(0x8c000000), + SPH_C32(0xde5601ec), SPH_C32(0x48a82f74), SPH_C32(0xeca12966), + SPH_C32(0x4da28d76), SPH_C32(0x95aa8be1), SPH_C32(0x41da0000), + SPH_C32(0x1d790000), SPH_C32(0xa2020000), SPH_C32(0x324500a1), + SPH_C32(0x5954f2ba), SPH_C32(0x28ee463d), SPH_C32(0x0c504459), + SPH_C32(0x666e9527) }, + { SPH_C32(0x47da0000), SPH_C32(0xa73b0000), SPH_C32(0x23270000), + SPH_C32(0xe34e01e9), SPH_C32(0x64e730a7), SPH_C32(0x98573ff3), + SPH_C32(0xf861ca9d), SPH_C32(0xa9f7741f), SPH_C32(0x42e70000), + SPH_C32(0x15ca0000), SPH_C32(0x51380000), SPH_C32(0x088700a6), + SPH_C32(0x087d78ea), SPH_C32(0x43802022), SPH_C32(0x02f58bba), + SPH_C32(0x80b4ead9) }, + { SPH_C32(0x44e70000), SPH_C32(0xaf880000), SPH_C32(0xd01d0000), + SPH_C32(0xd98c01ee), SPH_C32(0x35cebaf7), SPH_C32(0xf33959ec), + SPH_C32(0xf6c4057e), SPH_C32(0x4f2d0be1), SPH_C32(0xea3d0000), + SPH_C32(0x83740000), SPH_C32(0x0d250000), SPH_C32(0x0f5d00a4), + SPH_C32(0x751bed69), SPH_C32(0x5c1850a8), SPH_C32(0xb99303b2), + SPH_C32(0x5a336ad9) }, + { SPH_C32(0x7cbb0000), SPH_C32(0x0a820000), SPH_C32(0xc53b0000), + SPH_C32(0x7d4401e3), SPH_C32(0x2eb80b6a), SPH_C32(0x6183585b), + SPH_C32(0xd5ffd426), SPH_C32(0x5b091fb3), SPH_C32(0xe8930000), + SPH_C32(0x6c450000), SPH_C32(0x13e40000), SPH_C32(0xfa9300a8), + SPH_C32(0xa9e2ea61), SPH_C32(0x8bd58299), SPH_C32(0xb100adb0), + SPH_C32(0xef868b5c) }, + { SPH_C32(0x7f860000), SPH_C32(0x02310000), SPH_C32(0x36010000), + SPH_C32(0x478601e4), SPH_C32(0x7f91813a), SPH_C32(0x0aed3e44), + SPH_C32(0xdb5a1bc5), SPH_C32(0xbdd3604d), SPH_C32(0x40490000), + SPH_C32(0xfafb0000), SPH_C32(0x4ff90000), SPH_C32(0xfd4900aa), + SPH_C32(0xd4847fe2), SPH_C32(0x944df213), SPH_C32(0x0a6625b8), + SPH_C32(0x35010b5c) }, + { SPH_C32(0xd4610000), SPH_C32(0x9c3c0000), SPH_C32(0x99260000), + SPH_C32(0x7a9e01e1), SPH_C32(0x53de9ee9), SPH_C32(0x7e1b28d1), + SPH_C32(0x6e995c2e), SPH_C32(0x818e9fb3), SPH_C32(0x43740000), + SPH_C32(0xf2480000), SPH_C32(0xbcc30000), SPH_C32(0xc78b00ad), + SPH_C32(0x85adf5b2), SPH_C32(0xff23940c), SPH_C32(0x04c3ea5b), + SPH_C32(0xd3db74a2) }, + { SPH_C32(0xd75c0000), SPH_C32(0x948f0000), SPH_C32(0x6a1c0000), + SPH_C32(0x405c01e6), SPH_C32(0x02f714b9), SPH_C32(0x15754ece), + SPH_C32(0x603c93cd), SPH_C32(0x6754e04d), SPH_C32(0xebae0000), + SPH_C32(0x64f60000), SPH_C32(0xe0de0000), SPH_C32(0xc05100af), + SPH_C32(0xf8cb6031), SPH_C32(0xe0bbe486), SPH_C32(0xbfa56253), + SPH_C32(0x095cf4a2) }, + { SPH_C32(0x7d280000), SPH_C32(0xed000000), SPH_C32(0x28c00000), + SPH_C32(0xb24801e8), SPH_C32(0xa3688632), SPH_C32(0xdd20ec75), + SPH_C32(0xd3c9b5c7), SPH_C32(0x086681c8), SPH_C32(0x7abb0000), + SPH_C32(0xb0c00000), SPH_C32(0x441e0000), SPH_C32(0xac4f00ab), + SPH_C32(0x130bc977), SPH_C32(0xd13a2195), SPH_C32(0x21ce5ae2), + SPH_C32(0x9490fe8b) }, + { SPH_C32(0x7e150000), SPH_C32(0xe5b30000), SPH_C32(0xdbfa0000), + SPH_C32(0x888a01ef), SPH_C32(0xf2410c62), SPH_C32(0xb64e8a6a), + SPH_C32(0xdd6c7a24), SPH_C32(0xeebcfe36), SPH_C32(0xd2610000), + SPH_C32(0x267e0000), SPH_C32(0x18030000), SPH_C32(0xab9500a9), + SPH_C32(0x6e6d5cf4), SPH_C32(0xcea2511f), SPH_C32(0x9aa8d2ea), + SPH_C32(0x4e177e8b) }, + { SPH_C32(0xd5f20000), SPH_C32(0x7bbe0000), SPH_C32(0x74dd0000), + SPH_C32(0xb59201ea), SPH_C32(0xde0e13b1), SPH_C32(0xc2b89cff), + SPH_C32(0x68af3dcf), SPH_C32(0xd2e101c8), SPH_C32(0xd15c0000), + SPH_C32(0x2ecd0000), SPH_C32(0xeb390000), SPH_C32(0x915700ae), + SPH_C32(0x3f44d6a4), SPH_C32(0xa5cc3700), SPH_C32(0x940d1d09), + SPH_C32(0xa8cd0175) }, + { SPH_C32(0xd6cf0000), SPH_C32(0x730d0000), SPH_C32(0x87e70000), + SPH_C32(0x8f5001ed), SPH_C32(0x8f2799e1), SPH_C32(0xa9d6fae0), + SPH_C32(0x660af22c), SPH_C32(0x343b7e36), SPH_C32(0x79860000), + SPH_C32(0xb8730000), SPH_C32(0xb7240000), SPH_C32(0x968d00ac), + SPH_C32(0x42224327), SPH_C32(0xba54478a), SPH_C32(0x2f6b9501), + SPH_C32(0x724a8175) }, + { SPH_C32(0xb13b0000), SPH_C32(0x80040000), SPH_C32(0xd16f0000), + SPH_C32(0x4f6b01f3), SPH_C32(0xb12faec3), SPH_C32(0x287d6f19), + SPH_C32(0x112fb6cb), SPH_C32(0xaebbb10d), SPH_C32(0x7b6c0000), + SPH_C32(0x280a0000), SPH_C32(0x73990000), SPH_C32(0x496000a1), + SPH_C32(0xa5768de3), SPH_C32(0xc42f093c), SPH_C32(0x24f2a563), + SPH_C32(0x79f5076e) }, + { SPH_C32(0xb2060000), SPH_C32(0x88b70000), SPH_C32(0x22550000), + SPH_C32(0x75a901f4), SPH_C32(0xe0062493), SPH_C32(0x43130906), + SPH_C32(0x1f8a7928), SPH_C32(0x4861cef3), SPH_C32(0xd3b60000), + SPH_C32(0xbeb40000), SPH_C32(0x2f840000), SPH_C32(0x4eba00a3), + SPH_C32(0xd8101860), SPH_C32(0xdbb779b6), SPH_C32(0x9f942d6b), + SPH_C32(0xa372876e) }, + { SPH_C32(0x19e10000), SPH_C32(0x16ba0000), SPH_C32(0x8d720000), + SPH_C32(0x48b101f1), SPH_C32(0xcc493b40), SPH_C32(0x37e51f93), + SPH_C32(0xaa493ec3), SPH_C32(0x743c310d), SPH_C32(0xd08b0000), + SPH_C32(0xb6070000), SPH_C32(0xdcbe0000), SPH_C32(0x747800a4), + SPH_C32(0x89399230), SPH_C32(0xb0d91fa9), SPH_C32(0x9131e288), + SPH_C32(0x45a8f890) }, + { SPH_C32(0x1adc0000), SPH_C32(0x1e090000), SPH_C32(0x7e480000), + SPH_C32(0x727301f6), SPH_C32(0x9d60b110), SPH_C32(0x5c8b798c), + SPH_C32(0xa4ecf120), SPH_C32(0x92e64ef3), SPH_C32(0x78510000), + SPH_C32(0x20b90000), SPH_C32(0x80a30000), SPH_C32(0x73a200a6), + SPH_C32(0xf45f07b3), SPH_C32(0xaf416f23), SPH_C32(0x2a576a80), + SPH_C32(0x9f2f7890) }, + { SPH_C32(0xb0a80000), SPH_C32(0x67860000), SPH_C32(0x3c940000), + SPH_C32(0x806701f8), SPH_C32(0x3cff239b), SPH_C32(0x94dedb37), + SPH_C32(0x1719d72a), SPH_C32(0xfdd42f76), SPH_C32(0xe9440000), + SPH_C32(0xf48f0000), SPH_C32(0x24630000), SPH_C32(0x1fbc00a2), + SPH_C32(0x1f9faef5), SPH_C32(0x9ec0aa30), SPH_C32(0xb43c5231), + SPH_C32(0x02e372b9) }, + { SPH_C32(0xb3950000), SPH_C32(0x6f350000), SPH_C32(0xcfae0000), + SPH_C32(0xbaa501ff), SPH_C32(0x6dd6a9cb), SPH_C32(0xffb0bd28), + SPH_C32(0x19bc18c9), SPH_C32(0x1b0e5088), SPH_C32(0x419e0000), + SPH_C32(0x62310000), SPH_C32(0x787e0000), SPH_C32(0x186600a0), + SPH_C32(0x62f93b76), SPH_C32(0x8158daba), SPH_C32(0x0f5ada39), + SPH_C32(0xd864f2b9) }, + { SPH_C32(0x18720000), SPH_C32(0xf1380000), SPH_C32(0x60890000), + SPH_C32(0x87bd01fa), SPH_C32(0x4199b618), SPH_C32(0x8b46abbd), + SPH_C32(0xac7f5f22), SPH_C32(0x2753af76), SPH_C32(0x42a30000), + SPH_C32(0x6a820000), SPH_C32(0x8b440000), SPH_C32(0x22a400a7), + SPH_C32(0x33d0b126), SPH_C32(0xea36bca5), SPH_C32(0x01ff15da), + SPH_C32(0x3ebe8d47) }, + { SPH_C32(0x1b4f0000), SPH_C32(0xf98b0000), SPH_C32(0x93b30000), + SPH_C32(0xbd7f01fd), SPH_C32(0x10b03c48), SPH_C32(0xe028cda2), + SPH_C32(0xa2da90c1), SPH_C32(0xc189d088), SPH_C32(0xea790000), + SPH_C32(0xfc3c0000), SPH_C32(0xd7590000), SPH_C32(0x257e00a5), + SPH_C32(0x4eb624a5), SPH_C32(0xf5aecc2f), SPH_C32(0xba999dd2), + SPH_C32(0xe4390d47) }, + { SPH_C32(0x23130000), SPH_C32(0x5c810000), SPH_C32(0x86950000), + SPH_C32(0x19b701f0), SPH_C32(0x0bc68dd5), SPH_C32(0x7292cc15), + SPH_C32(0x81e14199), SPH_C32(0xd5adc4da), SPH_C32(0xe8d70000), + SPH_C32(0x130d0000), SPH_C32(0xc9980000), SPH_C32(0xd0b000a9), + SPH_C32(0x924f23ad), SPH_C32(0x22631e1e), SPH_C32(0xb20a33d0), + SPH_C32(0x518cecc2) }, + { SPH_C32(0x202e0000), SPH_C32(0x54320000), SPH_C32(0x75af0000), + SPH_C32(0x237501f7), SPH_C32(0x5aef0785), SPH_C32(0x19fcaa0a), + SPH_C32(0x8f448e7a), SPH_C32(0x3377bb24), SPH_C32(0x400d0000), + SPH_C32(0x85b30000), SPH_C32(0x95850000), SPH_C32(0xd76a00ab), + SPH_C32(0xef29b62e), SPH_C32(0x3dfb6e94), SPH_C32(0x096cbbd8), + SPH_C32(0x8b0b6cc2) }, + { SPH_C32(0x8bc90000), SPH_C32(0xca3f0000), SPH_C32(0xda880000), + SPH_C32(0x1e6d01f2), SPH_C32(0x76a01856), SPH_C32(0x6d0abc9f), + SPH_C32(0x3a87c991), SPH_C32(0x0f2a44da), SPH_C32(0x43300000), + SPH_C32(0x8d000000), SPH_C32(0x66bf0000), SPH_C32(0xeda800ac), + SPH_C32(0xbe003c7e), SPH_C32(0x5695088b), SPH_C32(0x07c9743b), + SPH_C32(0x6dd1133c) }, + { SPH_C32(0x88f40000), SPH_C32(0xc28c0000), SPH_C32(0x29b20000), + SPH_C32(0x24af01f5), SPH_C32(0x27899206), SPH_C32(0x0664da80), + SPH_C32(0x34220672), SPH_C32(0xe9f03b24), SPH_C32(0xebea0000), + SPH_C32(0x1bbe0000), SPH_C32(0x3aa20000), SPH_C32(0xea7200ae), + SPH_C32(0xc366a9fd), SPH_C32(0x490d7801), SPH_C32(0xbcaffc33), + SPH_C32(0xb756933c) }, + { SPH_C32(0x22800000), SPH_C32(0xbb030000), SPH_C32(0x6b6e0000), + SPH_C32(0xd6bb01fb), SPH_C32(0x8616008d), SPH_C32(0xce31783b), + SPH_C32(0x87d72078), SPH_C32(0x86c25aa1), SPH_C32(0x7aff0000), + SPH_C32(0xcf880000), SPH_C32(0x9e620000), SPH_C32(0x866c00aa), + SPH_C32(0x28a600bb), SPH_C32(0x788cbd12), SPH_C32(0x22c4c482), + SPH_C32(0x2a9a9915) }, + { SPH_C32(0x21bd0000), SPH_C32(0xb3b00000), SPH_C32(0x98540000), + SPH_C32(0xec7901fc), SPH_C32(0xd73f8add), SPH_C32(0xa55f1e24), + SPH_C32(0x8972ef9b), SPH_C32(0x6018255f), SPH_C32(0xd2250000), + SPH_C32(0x59360000), SPH_C32(0xc27f0000), SPH_C32(0x81b600a8), + SPH_C32(0x55c09538), SPH_C32(0x6714cd98), SPH_C32(0x99a24c8a), + SPH_C32(0xf01d1915) }, + { SPH_C32(0x8a5a0000), SPH_C32(0x2dbd0000), SPH_C32(0x37730000), + SPH_C32(0xd16101f9), SPH_C32(0xfb70950e), SPH_C32(0xd1a908b1), + SPH_C32(0x3cb1a870), SPH_C32(0x5c45daa1), SPH_C32(0xd1180000), + SPH_C32(0x51850000), SPH_C32(0x31450000), SPH_C32(0xbb7400af), + SPH_C32(0x04e91f68), SPH_C32(0x0c7aab87), SPH_C32(0x97078369), + SPH_C32(0x16c766eb) }, + { SPH_C32(0x89670000), SPH_C32(0x250e0000), SPH_C32(0xc4490000), + SPH_C32(0xeba301fe), SPH_C32(0xaa591f5e), SPH_C32(0xbac76eae), + SPH_C32(0x32146793), SPH_C32(0xba9fa55f), SPH_C32(0x79c20000), + SPH_C32(0xc73b0000), SPH_C32(0x6d580000), SPH_C32(0xbcae00ad), + SPH_C32(0x798f8aeb), SPH_C32(0x13e2db0d), SPH_C32(0x2c610b61), + SPH_C32(0xcc40e6eb) }, + { SPH_C32(0xeed70000), SPH_C32(0xa94f0000), SPH_C32(0x48bd0000), + SPH_C32(0x01bb01e1), SPH_C32(0xaffce1b0), SPH_C32(0x92da67d0), + SPH_C32(0x463bbd14), SPH_C32(0x9e150dfa), SPH_C32(0x24c40000), + SPH_C32(0x7e090000), SPH_C32(0x30370000), SPH_C32(0x2d9300b2), + SPH_C32(0x80080b5c), SPH_C32(0xd73e9d72), SPH_C32(0x70ec30dc), + SPH_C32(0xf751dc07) }, + { SPH_C32(0xedea0000), SPH_C32(0xa1fc0000), SPH_C32(0xbb870000), + SPH_C32(0x3b7901e6), SPH_C32(0xfed56be0), SPH_C32(0xf9b401cf), + SPH_C32(0x489e72f7), SPH_C32(0x78cf7204), SPH_C32(0x8c1e0000), + SPH_C32(0xe8b70000), SPH_C32(0x6c2a0000), SPH_C32(0x2a4900b0), + SPH_C32(0xfd6e9edf), SPH_C32(0xc8a6edf8), SPH_C32(0xcb8ab8d4), + SPH_C32(0x2dd65c07) }, + { SPH_C32(0x460d0000), SPH_C32(0x3ff10000), SPH_C32(0x14a00000), + SPH_C32(0x066101e3), SPH_C32(0xd29a7433), SPH_C32(0x8d42175a), + SPH_C32(0xfd5d351c), SPH_C32(0x44928dfa), SPH_C32(0x8f230000), + SPH_C32(0xe0040000), SPH_C32(0x9f100000), SPH_C32(0x108b00b7), + SPH_C32(0xac47148f), SPH_C32(0xa3c88be7), SPH_C32(0xc52f7737), + SPH_C32(0xcb0c23f9) }, + { SPH_C32(0x45300000), SPH_C32(0x37420000), SPH_C32(0xe79a0000), + SPH_C32(0x3ca301e4), SPH_C32(0x83b3fe63), SPH_C32(0xe62c7145), + SPH_C32(0xf3f8faff), SPH_C32(0xa248f204), SPH_C32(0x27f90000), + SPH_C32(0x76ba0000), SPH_C32(0xc30d0000), SPH_C32(0x175100b5), + SPH_C32(0xd121810c), SPH_C32(0xbc50fb6d), SPH_C32(0x7e49ff3f), + SPH_C32(0x118ba3f9) }, + { SPH_C32(0xef440000), SPH_C32(0x4ecd0000), SPH_C32(0xa5460000), + SPH_C32(0xceb701ea), SPH_C32(0x222c6ce8), SPH_C32(0x2e79d3fe), + SPH_C32(0x400ddcf5), SPH_C32(0xcd7a9381), SPH_C32(0xb6ec0000), + SPH_C32(0xa28c0000), SPH_C32(0x67cd0000), SPH_C32(0x7b4f00b1), + SPH_C32(0x3ae1284a), SPH_C32(0x8dd13e7e), SPH_C32(0xe022c78e), + SPH_C32(0x8c47a9d0) }, + { SPH_C32(0xec790000), SPH_C32(0x467e0000), SPH_C32(0x567c0000), + SPH_C32(0xf47501ed), SPH_C32(0x7305e6b8), SPH_C32(0x4517b5e1), + SPH_C32(0x4ea81316), SPH_C32(0x2ba0ec7f), SPH_C32(0x1e360000), + SPH_C32(0x34320000), SPH_C32(0x3bd00000), SPH_C32(0x7c9500b3), + SPH_C32(0x4787bdc9), SPH_C32(0x92494ef4), SPH_C32(0x5b444f86), + SPH_C32(0x56c029d0) }, + { SPH_C32(0x479e0000), SPH_C32(0xd8730000), SPH_C32(0xf95b0000), + SPH_C32(0xc96d01e8), SPH_C32(0x5f4af96b), SPH_C32(0x31e1a374), + SPH_C32(0xfb6b54fd), SPH_C32(0x17fd1381), SPH_C32(0x1d0b0000), + SPH_C32(0x3c810000), SPH_C32(0xc8ea0000), SPH_C32(0x465700b4), + SPH_C32(0x16ae3799), SPH_C32(0xf92728eb), SPH_C32(0x55e18065), + SPH_C32(0xb01a562e) }, + { SPH_C32(0x44a30000), SPH_C32(0xd0c00000), SPH_C32(0x0a610000), + SPH_C32(0xf3af01ef), SPH_C32(0x0e63733b), SPH_C32(0x5a8fc56b), + SPH_C32(0xf5ce9b1e), SPH_C32(0xf1276c7f), SPH_C32(0xb5d10000), + SPH_C32(0xaa3f0000), SPH_C32(0x94f70000), SPH_C32(0x418d00b6), + SPH_C32(0x6bc8a21a), SPH_C32(0xe6bf5861), SPH_C32(0xee87086d), + SPH_C32(0x6a9dd62e) }, + { SPH_C32(0x7cff0000), SPH_C32(0x75ca0000), SPH_C32(0x1f470000), + SPH_C32(0x576701e2), SPH_C32(0x1515c2a6), SPH_C32(0xc835c4dc), + SPH_C32(0xd6f54a46), SPH_C32(0xe503782d), SPH_C32(0xb77f0000), + SPH_C32(0x450e0000), SPH_C32(0x8a360000), SPH_C32(0xb44300ba), + SPH_C32(0xb731a512), SPH_C32(0x31728a50), SPH_C32(0xe614a66f), + SPH_C32(0xdf2837ab) }, + { SPH_C32(0x7fc20000), SPH_C32(0x7d790000), SPH_C32(0xec7d0000), + SPH_C32(0x6da501e5), SPH_C32(0x443c48f6), SPH_C32(0xa35ba2c3), + SPH_C32(0xd85085a5), SPH_C32(0x03d907d3), SPH_C32(0x1fa50000), + SPH_C32(0xd3b00000), SPH_C32(0xd62b0000), SPH_C32(0xb39900b8), + SPH_C32(0xca573091), SPH_C32(0x2eeafada), SPH_C32(0x5d722e67), + SPH_C32(0x05afb7ab) }, + { SPH_C32(0xd4250000), SPH_C32(0xe3740000), SPH_C32(0x435a0000), + SPH_C32(0x50bd01e0), SPH_C32(0x68735725), SPH_C32(0xd7adb456), + SPH_C32(0x6d93c24e), SPH_C32(0x3f84f82d), SPH_C32(0x1c980000), + SPH_C32(0xdb030000), SPH_C32(0x25110000), SPH_C32(0x895b00bf), + SPH_C32(0x9b7ebac1), SPH_C32(0x45849cc5), SPH_C32(0x53d7e184), + SPH_C32(0xe375c855) }, + { SPH_C32(0xd7180000), SPH_C32(0xebc70000), SPH_C32(0xb0600000), + SPH_C32(0x6a7f01e7), SPH_C32(0x395add75), SPH_C32(0xbcc3d249), + SPH_C32(0x63360dad), SPH_C32(0xd95e87d3), SPH_C32(0xb4420000), + SPH_C32(0x4dbd0000), SPH_C32(0x790c0000), SPH_C32(0x8e8100bd), + SPH_C32(0xe6182f42), SPH_C32(0x5a1cec4f), SPH_C32(0xe8b1698c), + SPH_C32(0x39f24855) }, + { SPH_C32(0x7d6c0000), SPH_C32(0x92480000), SPH_C32(0xf2bc0000), + SPH_C32(0x986b01e9), SPH_C32(0x98c54ffe), SPH_C32(0x749670f2), + SPH_C32(0xd0c32ba7), SPH_C32(0xb66ce656), SPH_C32(0x25570000), + SPH_C32(0x998b0000), SPH_C32(0xddcc0000), SPH_C32(0xe29f00b9), + SPH_C32(0x0dd88604), SPH_C32(0x6b9d295c), SPH_C32(0x76da513d), + SPH_C32(0xa43e427c) }, + { SPH_C32(0x7e510000), SPH_C32(0x9afb0000), SPH_C32(0x01860000), + SPH_C32(0xa2a901ee), SPH_C32(0xc9ecc5ae), SPH_C32(0x1ff816ed), + SPH_C32(0xde66e444), SPH_C32(0x50b699a8), SPH_C32(0x8d8d0000), + SPH_C32(0x0f350000), SPH_C32(0x81d10000), SPH_C32(0xe54500bb), + SPH_C32(0x70be1387), SPH_C32(0x740559d6), SPH_C32(0xcdbcd935), + SPH_C32(0x7eb9c27c) }, + { SPH_C32(0xd5b60000), SPH_C32(0x04f60000), SPH_C32(0xaea10000), + SPH_C32(0x9fb101eb), SPH_C32(0xe5a3da7d), SPH_C32(0x6b0e0078), + SPH_C32(0x6ba5a3af), SPH_C32(0x6ceb6656), SPH_C32(0x8eb00000), + SPH_C32(0x07860000), SPH_C32(0x72eb0000), SPH_C32(0xdf8700bc), + SPH_C32(0x219799d7), SPH_C32(0x1f6b3fc9), SPH_C32(0xc31916d6), + SPH_C32(0x9863bd82) }, + { SPH_C32(0xd68b0000), SPH_C32(0x0c450000), SPH_C32(0x5d9b0000), + SPH_C32(0xa57301ec), SPH_C32(0xb48a502d), SPH_C32(0x00606667), + SPH_C32(0x65006c4c), SPH_C32(0x8a3119a8), SPH_C32(0x266a0000), + SPH_C32(0x91380000), SPH_C32(0x2ef60000), SPH_C32(0xd85d00be), + SPH_C32(0x5cf10c54), SPH_C32(0x00f34f43), SPH_C32(0x787f9ede), + SPH_C32(0x42e43d82) }, + { SPH_C32(0xb17f0000), SPH_C32(0xff4c0000), SPH_C32(0x0b130000), + SPH_C32(0x654801f2), SPH_C32(0x8a82670f), SPH_C32(0x81cbf39e), + SPH_C32(0x122528ab), SPH_C32(0x10b1d693), SPH_C32(0x24800000), + SPH_C32(0x01410000), SPH_C32(0xea4b0000), SPH_C32(0x07b000b3), + SPH_C32(0xbba5c290), SPH_C32(0x7e8801f5), SPH_C32(0x73e6aebc), + SPH_C32(0x495bbb99) }, + { SPH_C32(0xb2420000), SPH_C32(0xf7ff0000), SPH_C32(0xf8290000), + SPH_C32(0x5f8a01f5), SPH_C32(0xdbabed5f), SPH_C32(0xeaa59581), + SPH_C32(0x1c80e748), SPH_C32(0xf66ba96d), SPH_C32(0x8c5a0000), + SPH_C32(0x97ff0000), SPH_C32(0xb6560000), SPH_C32(0x006a00b1), + SPH_C32(0xc6c35713), SPH_C32(0x6110717f), SPH_C32(0xc88026b4), + SPH_C32(0x93dc3b99) }, + { SPH_C32(0x19a50000), SPH_C32(0x69f20000), SPH_C32(0x570e0000), + SPH_C32(0x629201f0), SPH_C32(0xf7e4f28c), SPH_C32(0x9e538314), + SPH_C32(0xa943a0a3), SPH_C32(0xca365693), SPH_C32(0x8f670000), + SPH_C32(0x9f4c0000), SPH_C32(0x456c0000), SPH_C32(0x3aa800b6), + SPH_C32(0x97eadd43), SPH_C32(0x0a7e1760), SPH_C32(0xc625e957), + SPH_C32(0x75064467) }, + { SPH_C32(0x1a980000), SPH_C32(0x61410000), SPH_C32(0xa4340000), + SPH_C32(0x585001f7), SPH_C32(0xa6cd78dc), SPH_C32(0xf53de50b), + SPH_C32(0xa7e66f40), SPH_C32(0x2cec296d), SPH_C32(0x27bd0000), + SPH_C32(0x09f20000), SPH_C32(0x19710000), SPH_C32(0x3d7200b4), + SPH_C32(0xea8c48c0), SPH_C32(0x15e667ea), SPH_C32(0x7d43615f), + SPH_C32(0xaf81c467) }, + { SPH_C32(0xb0ec0000), SPH_C32(0x18ce0000), SPH_C32(0xe6e80000), + SPH_C32(0xaa4401f9), SPH_C32(0x0752ea57), SPH_C32(0x3d6847b0), + SPH_C32(0x1413494a), SPH_C32(0x43de48e8), SPH_C32(0xb6a80000), + SPH_C32(0xddc40000), SPH_C32(0xbdb10000), SPH_C32(0x516c00b0), + SPH_C32(0x014ce186), SPH_C32(0x2467a2f9), SPH_C32(0xe32859ee), + SPH_C32(0x324dce4e) }, + { SPH_C32(0xb3d10000), SPH_C32(0x107d0000), SPH_C32(0x15d20000), + SPH_C32(0x908601fe), SPH_C32(0x567b6007), SPH_C32(0x560621af), + SPH_C32(0x1ab686a9), SPH_C32(0xa5043716), SPH_C32(0x1e720000), + SPH_C32(0x4b7a0000), SPH_C32(0xe1ac0000), SPH_C32(0x56b600b2), + SPH_C32(0x7c2a7405), SPH_C32(0x3bffd273), SPH_C32(0x584ed1e6), + SPH_C32(0xe8ca4e4e) }, + { SPH_C32(0x18360000), SPH_C32(0x8e700000), SPH_C32(0xbaf50000), + SPH_C32(0xad9e01fb), SPH_C32(0x7a347fd4), SPH_C32(0x22f0373a), + SPH_C32(0xaf75c142), SPH_C32(0x9959c8e8), SPH_C32(0x1d4f0000), + SPH_C32(0x43c90000), SPH_C32(0x12960000), SPH_C32(0x6c7400b5), + SPH_C32(0x2d03fe55), SPH_C32(0x5091b46c), SPH_C32(0x56eb1e05), + SPH_C32(0x0e1031b0) }, + { SPH_C32(0x1b0b0000), SPH_C32(0x86c30000), SPH_C32(0x49cf0000), + SPH_C32(0x975c01fc), SPH_C32(0x2b1df584), SPH_C32(0x499e5125), + SPH_C32(0xa1d00ea1), SPH_C32(0x7f83b716), SPH_C32(0xb5950000), + SPH_C32(0xd5770000), SPH_C32(0x4e8b0000), SPH_C32(0x6bae00b7), + SPH_C32(0x50656bd6), SPH_C32(0x4f09c4e6), SPH_C32(0xed8d960d), + SPH_C32(0xd497b1b0) }, + { SPH_C32(0x23570000), SPH_C32(0x23c90000), SPH_C32(0x5ce90000), + SPH_C32(0x339401f1), SPH_C32(0x306b4419), SPH_C32(0xdb245092), + SPH_C32(0x82ebdff9), SPH_C32(0x6ba7a344), SPH_C32(0xb73b0000), + SPH_C32(0x3a460000), SPH_C32(0x504a0000), SPH_C32(0x9e6000bb), + SPH_C32(0x8c9c6cde), SPH_C32(0x98c416d7), SPH_C32(0xe51e380f), + SPH_C32(0x61225035) }, + { SPH_C32(0x206a0000), SPH_C32(0x2b7a0000), SPH_C32(0xafd30000), + SPH_C32(0x095601f6), SPH_C32(0x6142ce49), SPH_C32(0xb04a368d), + SPH_C32(0x8c4e101a), SPH_C32(0x8d7ddcba), SPH_C32(0x1fe10000), + SPH_C32(0xacf80000), SPH_C32(0x0c570000), SPH_C32(0x99ba00b9), + SPH_C32(0xf1faf95d), SPH_C32(0x875c665d), SPH_C32(0x5e78b007), + SPH_C32(0xbba5d035) }, + { SPH_C32(0x8b8d0000), SPH_C32(0xb5770000), SPH_C32(0x00f40000), + SPH_C32(0x344e01f3), SPH_C32(0x4d0dd19a), SPH_C32(0xc4bc2018), + SPH_C32(0x398d57f1), SPH_C32(0xb1202344), SPH_C32(0x1cdc0000), + SPH_C32(0xa44b0000), SPH_C32(0xff6d0000), SPH_C32(0xa37800be), + SPH_C32(0xa0d3730d), SPH_C32(0xec320042), SPH_C32(0x50dd7fe4), + SPH_C32(0x5d7fafcb) }, + { SPH_C32(0x88b00000), SPH_C32(0xbdc40000), SPH_C32(0xf3ce0000), + SPH_C32(0x0e8c01f4), SPH_C32(0x1c245bca), SPH_C32(0xafd24607), + SPH_C32(0x37289812), SPH_C32(0x57fa5cba), SPH_C32(0xb4060000), + SPH_C32(0x32f50000), SPH_C32(0xa3700000), SPH_C32(0xa4a200bc), + SPH_C32(0xddb5e68e), SPH_C32(0xf3aa70c8), SPH_C32(0xebbbf7ec), + SPH_C32(0x87f82fcb) }, + { SPH_C32(0x22c40000), SPH_C32(0xc44b0000), SPH_C32(0xb1120000), + SPH_C32(0xfc9801fa), SPH_C32(0xbdbbc941), SPH_C32(0x6787e4bc), + SPH_C32(0x84ddbe18), SPH_C32(0x38c83d3f), SPH_C32(0x25130000), + SPH_C32(0xe6c30000), SPH_C32(0x07b00000), SPH_C32(0xc8bc00b8), + SPH_C32(0x36754fc8), SPH_C32(0xc22bb5db), SPH_C32(0x75d0cf5d), + SPH_C32(0x1a3425e2) }, + { SPH_C32(0x21f90000), SPH_C32(0xccf80000), SPH_C32(0x42280000), + SPH_C32(0xc65a01fd), SPH_C32(0xec924311), SPH_C32(0x0ce982a3), + SPH_C32(0x8a7871fb), SPH_C32(0xde1242c1), SPH_C32(0x8dc90000), + SPH_C32(0x707d0000), SPH_C32(0x5bad0000), SPH_C32(0xcf6600ba), + SPH_C32(0x4b13da4b), SPH_C32(0xddb3c551), SPH_C32(0xceb64755), + SPH_C32(0xc0b3a5e2) }, + { SPH_C32(0x8a1e0000), SPH_C32(0x52f50000), SPH_C32(0xed0f0000), + SPH_C32(0xfb4201f8), SPH_C32(0xc0dd5cc2), SPH_C32(0x781f9436), + SPH_C32(0x3fbb3610), SPH_C32(0xe24fbd3f), SPH_C32(0x8ef40000), + SPH_C32(0x78ce0000), SPH_C32(0xa8970000), SPH_C32(0xf5a400bd), + SPH_C32(0x1a3a501b), SPH_C32(0xb6dda34e), SPH_C32(0xc01388b6), + SPH_C32(0x2669da1c) }, + { SPH_C32(0x89230000), SPH_C32(0x5a460000), SPH_C32(0x1e350000), + SPH_C32(0xc18001ff), SPH_C32(0x91f4d692), SPH_C32(0x1371f229), + SPH_C32(0x311ef9f3), SPH_C32(0x0495c2c1), SPH_C32(0x262e0000), + SPH_C32(0xee700000), SPH_C32(0xf48a0000), SPH_C32(0xf27e00bf), + SPH_C32(0x675cc598), SPH_C32(0xa945d3c4), SPH_C32(0x7b7500be), + SPH_C32(0xfcee5a1c) }, + { SPH_C32(0x7b280000), SPH_C32(0x57420000), SPH_C32(0xa9e50000), + SPH_C32(0x634300a0), SPH_C32(0x9edb442f), SPH_C32(0x6d9995bb), + SPH_C32(0x27f83b03), SPH_C32(0xc7ff60f0), SPH_C32(0x95bb0000), + SPH_C32(0x81450000), SPH_C32(0x3b240000), SPH_C32(0x48db0140), + SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), SPH_C32(0x62c91877), + SPH_C32(0xe7e00a94) }, + { SPH_C32(0x78150000), SPH_C32(0x5ff10000), SPH_C32(0x5adf0000), + SPH_C32(0x598100a7), SPH_C32(0xcff2ce7f), SPH_C32(0x06f7f3a4), + SPH_C32(0x295df4e0), SPH_C32(0x21251f0e), SPH_C32(0x3d610000), + SPH_C32(0x17fb0000), SPH_C32(0x67390000), SPH_C32(0x4f010142), + SPH_C32(0x77ecf9d0), SPH_C32(0x496d1e66), SPH_C32(0xd9af907f), + SPH_C32(0x3d678a94) }, + { SPH_C32(0xd3f20000), SPH_C32(0xc1fc0000), SPH_C32(0xf5f80000), + SPH_C32(0x649900a2), SPH_C32(0xe3bdd1ac), SPH_C32(0x7201e531), + SPH_C32(0x9c9eb30b), SPH_C32(0x1d78e0f0), SPH_C32(0x3e5c0000), + SPH_C32(0x1f480000), SPH_C32(0x94030000), SPH_C32(0x75c30145), + SPH_C32(0x26c57380), SPH_C32(0x22037879), SPH_C32(0xd70a5f9c), + SPH_C32(0xdbbdf56a) }, + { SPH_C32(0xd0cf0000), SPH_C32(0xc94f0000), SPH_C32(0x06c20000), + SPH_C32(0x5e5b00a5), SPH_C32(0xb2945bfc), SPH_C32(0x196f832e), + SPH_C32(0x923b7ce8), SPH_C32(0xfba29f0e), SPH_C32(0x96860000), + SPH_C32(0x89f60000), SPH_C32(0xc81e0000), SPH_C32(0x72190147), + SPH_C32(0x5ba3e603), SPH_C32(0x3d9b08f3), SPH_C32(0x6c6cd794), + SPH_C32(0x013a756a) }, + { SPH_C32(0x7abb0000), SPH_C32(0xb0c00000), SPH_C32(0x441e0000), + SPH_C32(0xac4f00ab), SPH_C32(0x130bc977), SPH_C32(0xd13a2195), + SPH_C32(0x21ce5ae2), SPH_C32(0x9490fe8b), SPH_C32(0x07930000), + SPH_C32(0x5dc00000), SPH_C32(0x6cde0000), SPH_C32(0x1e070143), + SPH_C32(0xb0634f45), SPH_C32(0x0c1acde0), SPH_C32(0xf207ef25), + SPH_C32(0x9cf67f43) }, + { SPH_C32(0x79860000), SPH_C32(0xb8730000), SPH_C32(0xb7240000), + SPH_C32(0x968d00ac), SPH_C32(0x42224327), SPH_C32(0xba54478a), + SPH_C32(0x2f6b9501), SPH_C32(0x724a8175), SPH_C32(0xaf490000), + SPH_C32(0xcb7e0000), SPH_C32(0x30c30000), SPH_C32(0x19dd0141), + SPH_C32(0xcd05dac6), SPH_C32(0x1382bd6a), SPH_C32(0x4961672d), + SPH_C32(0x4671ff43) }, + { SPH_C32(0xd2610000), SPH_C32(0x267e0000), SPH_C32(0x18030000), + SPH_C32(0xab9500a9), SPH_C32(0x6e6d5cf4), SPH_C32(0xcea2511f), + SPH_C32(0x9aa8d2ea), SPH_C32(0x4e177e8b), SPH_C32(0xac740000), + SPH_C32(0xc3cd0000), SPH_C32(0xc3f90000), SPH_C32(0x231f0146), + SPH_C32(0x9c2c5096), SPH_C32(0x78ecdb75), SPH_C32(0x47c4a8ce), + SPH_C32(0xa0ab80bd) }, + { SPH_C32(0xd15c0000), SPH_C32(0x2ecd0000), SPH_C32(0xeb390000), + SPH_C32(0x915700ae), SPH_C32(0x3f44d6a4), SPH_C32(0xa5cc3700), + SPH_C32(0x940d1d09), SPH_C32(0xa8cd0175), SPH_C32(0x04ae0000), + SPH_C32(0x55730000), SPH_C32(0x9fe40000), SPH_C32(0x24c50144), + SPH_C32(0xe14ac515), SPH_C32(0x6774abff), SPH_C32(0xfca220c6), + SPH_C32(0x7a2c00bd) }, + { SPH_C32(0xe9000000), SPH_C32(0x8bc70000), SPH_C32(0xfe1f0000), + SPH_C32(0x359f00a3), SPH_C32(0x24326739), SPH_C32(0x377636b7), + SPH_C32(0xb736cc51), SPH_C32(0xbce91527), SPH_C32(0x06000000), + SPH_C32(0xba420000), SPH_C32(0x81250000), SPH_C32(0xd10b0148), + SPH_C32(0x3db3c21d), SPH_C32(0xb0b979ce), SPH_C32(0xf4318ec4), + SPH_C32(0xcf99e138) }, + { SPH_C32(0xea3d0000), SPH_C32(0x83740000), SPH_C32(0x0d250000), + SPH_C32(0x0f5d00a4), SPH_C32(0x751bed69), SPH_C32(0x5c1850a8), + SPH_C32(0xb99303b2), SPH_C32(0x5a336ad9), SPH_C32(0xaeda0000), + SPH_C32(0x2cfc0000), SPH_C32(0xdd380000), SPH_C32(0xd6d1014a), + SPH_C32(0x40d5579e), SPH_C32(0xaf210944), SPH_C32(0x4f5706cc), + SPH_C32(0x151e6138) }, + { SPH_C32(0x41da0000), SPH_C32(0x1d790000), SPH_C32(0xa2020000), + SPH_C32(0x324500a1), SPH_C32(0x5954f2ba), SPH_C32(0x28ee463d), + SPH_C32(0x0c504459), SPH_C32(0x666e9527), SPH_C32(0xade70000), + SPH_C32(0x244f0000), SPH_C32(0x2e020000), SPH_C32(0xec13014d), + SPH_C32(0x11fcddce), SPH_C32(0xc44f6f5b), SPH_C32(0x41f2c92f), + SPH_C32(0xf3c41ec6) }, + { SPH_C32(0x42e70000), SPH_C32(0x15ca0000), SPH_C32(0x51380000), + SPH_C32(0x088700a6), SPH_C32(0x087d78ea), SPH_C32(0x43802022), + SPH_C32(0x02f58bba), SPH_C32(0x80b4ead9), SPH_C32(0x053d0000), + SPH_C32(0xb2f10000), SPH_C32(0x721f0000), SPH_C32(0xebc9014f), + SPH_C32(0x6c9a484d), SPH_C32(0xdbd71fd1), SPH_C32(0xfa944127), + SPH_C32(0x29439ec6) }, + { SPH_C32(0xe8930000), SPH_C32(0x6c450000), SPH_C32(0x13e40000), + SPH_C32(0xfa9300a8), SPH_C32(0xa9e2ea61), SPH_C32(0x8bd58299), + SPH_C32(0xb100adb0), SPH_C32(0xef868b5c), SPH_C32(0x94280000), + SPH_C32(0x66c70000), SPH_C32(0xd6df0000), SPH_C32(0x87d7014b), + SPH_C32(0x875ae10b), SPH_C32(0xea56dac2), SPH_C32(0x64ff7996), + SPH_C32(0xb48f94ef) }, + { SPH_C32(0xebae0000), SPH_C32(0x64f60000), SPH_C32(0xe0de0000), + SPH_C32(0xc05100af), SPH_C32(0xf8cb6031), SPH_C32(0xe0bbe486), + SPH_C32(0xbfa56253), SPH_C32(0x095cf4a2), SPH_C32(0x3cf20000), + SPH_C32(0xf0790000), SPH_C32(0x8ac20000), SPH_C32(0x800d0149), + SPH_C32(0xfa3c7488), SPH_C32(0xf5ceaa48), SPH_C32(0xdf99f19e), + SPH_C32(0x6e0814ef) }, + { SPH_C32(0x40490000), SPH_C32(0xfafb0000), SPH_C32(0x4ff90000), + SPH_C32(0xfd4900aa), SPH_C32(0xd4847fe2), SPH_C32(0x944df213), + SPH_C32(0x0a6625b8), SPH_C32(0x35010b5c), SPH_C32(0x3fcf0000), + SPH_C32(0xf8ca0000), SPH_C32(0x79f80000), SPH_C32(0xbacf014e), + SPH_C32(0xab15fed8), SPH_C32(0x9ea0cc57), SPH_C32(0xd13c3e7d), + SPH_C32(0x88d26b11) }, + { SPH_C32(0x43740000), SPH_C32(0xf2480000), SPH_C32(0xbcc30000), + SPH_C32(0xc78b00ad), SPH_C32(0x85adf5b2), SPH_C32(0xff23940c), + SPH_C32(0x04c3ea5b), SPH_C32(0xd3db74a2), SPH_C32(0x97150000), + SPH_C32(0x6e740000), SPH_C32(0x25e50000), SPH_C32(0xbd15014c), + SPH_C32(0xd6736b5b), SPH_C32(0x8138bcdd), SPH_C32(0x6a5ab675), + SPH_C32(0x5255eb11) }, + { SPH_C32(0x24800000), SPH_C32(0x01410000), SPH_C32(0xea4b0000), + SPH_C32(0x07b000b3), SPH_C32(0xbba5c290), SPH_C32(0x7e8801f5), + SPH_C32(0x73e6aebc), SPH_C32(0x495bbb99), SPH_C32(0x95ff0000), + SPH_C32(0xfe0d0000), SPH_C32(0xe1580000), SPH_C32(0x62f80141), + SPH_C32(0x3127a59f), SPH_C32(0xff43f26b), SPH_C32(0x61c38617), + SPH_C32(0x59ea6d0a) }, + { SPH_C32(0x27bd0000), SPH_C32(0x09f20000), SPH_C32(0x19710000), + SPH_C32(0x3d7200b4), SPH_C32(0xea8c48c0), SPH_C32(0x15e667ea), + SPH_C32(0x7d43615f), SPH_C32(0xaf81c467), SPH_C32(0x3d250000), + SPH_C32(0x68b30000), SPH_C32(0xbd450000), SPH_C32(0x65220143), + SPH_C32(0x4c41301c), SPH_C32(0xe0db82e1), SPH_C32(0xdaa50e1f), + SPH_C32(0x836ded0a) }, + { SPH_C32(0x8c5a0000), SPH_C32(0x97ff0000), SPH_C32(0xb6560000), + SPH_C32(0x006a00b1), SPH_C32(0xc6c35713), SPH_C32(0x6110717f), + SPH_C32(0xc88026b4), SPH_C32(0x93dc3b99), SPH_C32(0x3e180000), + SPH_C32(0x60000000), SPH_C32(0x4e7f0000), SPH_C32(0x5fe00144), + SPH_C32(0x1d68ba4c), SPH_C32(0x8bb5e4fe), SPH_C32(0xd400c1fc), + SPH_C32(0x65b792f4) }, + { SPH_C32(0x8f670000), SPH_C32(0x9f4c0000), SPH_C32(0x456c0000), + SPH_C32(0x3aa800b6), SPH_C32(0x97eadd43), SPH_C32(0x0a7e1760), + SPH_C32(0xc625e957), SPH_C32(0x75064467), SPH_C32(0x96c20000), + SPH_C32(0xf6be0000), SPH_C32(0x12620000), SPH_C32(0x583a0146), + SPH_C32(0x600e2fcf), SPH_C32(0x942d9474), SPH_C32(0x6f6649f4), + SPH_C32(0xbf3012f4) }, + { SPH_C32(0x25130000), SPH_C32(0xe6c30000), SPH_C32(0x07b00000), + SPH_C32(0xc8bc00b8), SPH_C32(0x36754fc8), SPH_C32(0xc22bb5db), + SPH_C32(0x75d0cf5d), SPH_C32(0x1a3425e2), SPH_C32(0x07d70000), + SPH_C32(0x22880000), SPH_C32(0xb6a20000), SPH_C32(0x34240142), + SPH_C32(0x8bce8689), SPH_C32(0xa5ac5167), SPH_C32(0xf10d7145), + SPH_C32(0x22fc18dd) }, + { SPH_C32(0x262e0000), SPH_C32(0xee700000), SPH_C32(0xf48a0000), + SPH_C32(0xf27e00bf), SPH_C32(0x675cc598), SPH_C32(0xa945d3c4), + SPH_C32(0x7b7500be), SPH_C32(0xfcee5a1c), SPH_C32(0xaf0d0000), + SPH_C32(0xb4360000), SPH_C32(0xeabf0000), SPH_C32(0x33fe0140), + SPH_C32(0xf6a8130a), SPH_C32(0xba3421ed), SPH_C32(0x4a6bf94d), + SPH_C32(0xf87b98dd) }, + { SPH_C32(0x8dc90000), SPH_C32(0x707d0000), SPH_C32(0x5bad0000), + SPH_C32(0xcf6600ba), SPH_C32(0x4b13da4b), SPH_C32(0xddb3c551), + SPH_C32(0xceb64755), SPH_C32(0xc0b3a5e2), SPH_C32(0xac300000), + SPH_C32(0xbc850000), SPH_C32(0x19850000), SPH_C32(0x093c0147), + SPH_C32(0xa781995a), SPH_C32(0xd15a47f2), SPH_C32(0x44ce36ae), + SPH_C32(0x1ea1e723) }, + { SPH_C32(0x8ef40000), SPH_C32(0x78ce0000), SPH_C32(0xa8970000), + SPH_C32(0xf5a400bd), SPH_C32(0x1a3a501b), SPH_C32(0xb6dda34e), + SPH_C32(0xc01388b6), SPH_C32(0x2669da1c), SPH_C32(0x04ea0000), + SPH_C32(0x2a3b0000), SPH_C32(0x45980000), SPH_C32(0x0ee60145), + SPH_C32(0xdae70cd9), SPH_C32(0xcec23778), SPH_C32(0xffa8bea6), + SPH_C32(0xc4266723) }, + { SPH_C32(0xb6a80000), SPH_C32(0xddc40000), SPH_C32(0xbdb10000), + SPH_C32(0x516c00b0), SPH_C32(0x014ce186), SPH_C32(0x2467a2f9), + SPH_C32(0xe32859ee), SPH_C32(0x324dce4e), SPH_C32(0x06440000), + SPH_C32(0xc50a0000), SPH_C32(0x5b590000), SPH_C32(0xfb280149), + SPH_C32(0x061e0bd1), SPH_C32(0x190fe549), SPH_C32(0xf73b10a4), + SPH_C32(0x719386a6) }, + { SPH_C32(0xb5950000), SPH_C32(0xd5770000), SPH_C32(0x4e8b0000), + SPH_C32(0x6bae00b7), SPH_C32(0x50656bd6), SPH_C32(0x4f09c4e6), + SPH_C32(0xed8d960d), SPH_C32(0xd497b1b0), SPH_C32(0xae9e0000), + SPH_C32(0x53b40000), SPH_C32(0x07440000), SPH_C32(0xfcf2014b), + SPH_C32(0x7b789e52), SPH_C32(0x069795c3), SPH_C32(0x4c5d98ac), + SPH_C32(0xab1406a6) }, + { SPH_C32(0x1e720000), SPH_C32(0x4b7a0000), SPH_C32(0xe1ac0000), + SPH_C32(0x56b600b2), SPH_C32(0x7c2a7405), SPH_C32(0x3bffd273), + SPH_C32(0x584ed1e6), SPH_C32(0xe8ca4e4e), SPH_C32(0xada30000), + SPH_C32(0x5b070000), SPH_C32(0xf47e0000), SPH_C32(0xc630014c), + SPH_C32(0x2a511402), SPH_C32(0x6df9f3dc), SPH_C32(0x42f8574f), + SPH_C32(0x4dce7958) }, + { SPH_C32(0x1d4f0000), SPH_C32(0x43c90000), SPH_C32(0x12960000), + SPH_C32(0x6c7400b5), SPH_C32(0x2d03fe55), SPH_C32(0x5091b46c), + SPH_C32(0x56eb1e05), SPH_C32(0x0e1031b0), SPH_C32(0x05790000), + SPH_C32(0xcdb90000), SPH_C32(0xa8630000), SPH_C32(0xc1ea014e), + SPH_C32(0x57378181), SPH_C32(0x72618356), SPH_C32(0xf99edf47), + SPH_C32(0x9749f958) }, + { SPH_C32(0xb73b0000), SPH_C32(0x3a460000), SPH_C32(0x504a0000), + SPH_C32(0x9e6000bb), SPH_C32(0x8c9c6cde), SPH_C32(0x98c416d7), + SPH_C32(0xe51e380f), SPH_C32(0x61225035), SPH_C32(0x946c0000), + SPH_C32(0x198f0000), SPH_C32(0x0ca30000), SPH_C32(0xadf4014a), + SPH_C32(0xbcf728c7), SPH_C32(0x43e04645), SPH_C32(0x67f5e7f6), + SPH_C32(0x0a85f371) }, + { SPH_C32(0xb4060000), SPH_C32(0x32f50000), SPH_C32(0xa3700000), + SPH_C32(0xa4a200bc), SPH_C32(0xddb5e68e), SPH_C32(0xf3aa70c8), + SPH_C32(0xebbbf7ec), SPH_C32(0x87f82fcb), SPH_C32(0x3cb60000), + SPH_C32(0x8f310000), SPH_C32(0x50be0000), SPH_C32(0xaa2e0148), + SPH_C32(0xc191bd44), SPH_C32(0x5c7836cf), SPH_C32(0xdc936ffe), + SPH_C32(0xd0027371) }, + { SPH_C32(0x1fe10000), SPH_C32(0xacf80000), SPH_C32(0x0c570000), + SPH_C32(0x99ba00b9), SPH_C32(0xf1faf95d), SPH_C32(0x875c665d), + SPH_C32(0x5e78b007), SPH_C32(0xbba5d035), SPH_C32(0x3f8b0000), + SPH_C32(0x87820000), SPH_C32(0xa3840000), SPH_C32(0x90ec014f), + SPH_C32(0x90b83714), SPH_C32(0x371650d0), SPH_C32(0xd236a01d), + SPH_C32(0x36d80c8f) }, + { SPH_C32(0x1cdc0000), SPH_C32(0xa44b0000), SPH_C32(0xff6d0000), + SPH_C32(0xa37800be), SPH_C32(0xa0d3730d), SPH_C32(0xec320042), + SPH_C32(0x50dd7fe4), SPH_C32(0x5d7fafcb), SPH_C32(0x97510000), + SPH_C32(0x113c0000), SPH_C32(0xff990000), SPH_C32(0x9736014d), + SPH_C32(0xeddea297), SPH_C32(0x288e205a), SPH_C32(0x69502815), + SPH_C32(0xec5f8c8f) }, + { SPH_C32(0x7b6c0000), SPH_C32(0x280a0000), SPH_C32(0x73990000), + SPH_C32(0x496000a1), SPH_C32(0xa5768de3), SPH_C32(0xc42f093c), + SPH_C32(0x24f2a563), SPH_C32(0x79f5076e), SPH_C32(0xca570000), + SPH_C32(0xa80e0000), SPH_C32(0xa2f60000), SPH_C32(0x060b0152), + SPH_C32(0x14592320), SPH_C32(0xec526625), SPH_C32(0x35dd13a8), + SPH_C32(0xd74eb663) }, + { SPH_C32(0x78510000), SPH_C32(0x20b90000), SPH_C32(0x80a30000), + SPH_C32(0x73a200a6), SPH_C32(0xf45f07b3), SPH_C32(0xaf416f23), + SPH_C32(0x2a576a80), SPH_C32(0x9f2f7890), SPH_C32(0x628d0000), + SPH_C32(0x3eb00000), SPH_C32(0xfeeb0000), SPH_C32(0x01d10150), + SPH_C32(0x693fb6a3), SPH_C32(0xf3ca16af), SPH_C32(0x8ebb9ba0), + SPH_C32(0x0dc93663) }, + { SPH_C32(0xd3b60000), SPH_C32(0xbeb40000), SPH_C32(0x2f840000), + SPH_C32(0x4eba00a3), SPH_C32(0xd8101860), SPH_C32(0xdbb779b6), + SPH_C32(0x9f942d6b), SPH_C32(0xa372876e), SPH_C32(0x61b00000), + SPH_C32(0x36030000), SPH_C32(0x0dd10000), SPH_C32(0x3b130157), + SPH_C32(0x38163cf3), SPH_C32(0x98a470b0), SPH_C32(0x801e5443), + SPH_C32(0xeb13499d) }, + { SPH_C32(0xd08b0000), SPH_C32(0xb6070000), SPH_C32(0xdcbe0000), + SPH_C32(0x747800a4), SPH_C32(0x89399230), SPH_C32(0xb0d91fa9), + SPH_C32(0x9131e288), SPH_C32(0x45a8f890), SPH_C32(0xc96a0000), + SPH_C32(0xa0bd0000), SPH_C32(0x51cc0000), SPH_C32(0x3cc90155), + SPH_C32(0x4570a970), SPH_C32(0x873c003a), SPH_C32(0x3b78dc4b), + SPH_C32(0x3194c99d) }, + { SPH_C32(0x7aff0000), SPH_C32(0xcf880000), SPH_C32(0x9e620000), + SPH_C32(0x866c00aa), SPH_C32(0x28a600bb), SPH_C32(0x788cbd12), + SPH_C32(0x22c4c482), SPH_C32(0x2a9a9915), SPH_C32(0x587f0000), + SPH_C32(0x748b0000), SPH_C32(0xf50c0000), SPH_C32(0x50d70151), + SPH_C32(0xaeb00036), SPH_C32(0xb6bdc529), SPH_C32(0xa513e4fa), + SPH_C32(0xac58c3b4) }, + { SPH_C32(0x79c20000), SPH_C32(0xc73b0000), SPH_C32(0x6d580000), + SPH_C32(0xbcae00ad), SPH_C32(0x798f8aeb), SPH_C32(0x13e2db0d), + SPH_C32(0x2c610b61), SPH_C32(0xcc40e6eb), SPH_C32(0xf0a50000), + SPH_C32(0xe2350000), SPH_C32(0xa9110000), SPH_C32(0x570d0153), + SPH_C32(0xd3d695b5), SPH_C32(0xa925b5a3), SPH_C32(0x1e756cf2), + SPH_C32(0x76df43b4) }, + { SPH_C32(0xd2250000), SPH_C32(0x59360000), SPH_C32(0xc27f0000), + SPH_C32(0x81b600a8), SPH_C32(0x55c09538), SPH_C32(0x6714cd98), + SPH_C32(0x99a24c8a), SPH_C32(0xf01d1915), SPH_C32(0xf3980000), + SPH_C32(0xea860000), SPH_C32(0x5a2b0000), SPH_C32(0x6dcf0154), + SPH_C32(0x82ff1fe5), SPH_C32(0xc24bd3bc), SPH_C32(0x10d0a311), + SPH_C32(0x90053c4a) }, + { SPH_C32(0xd1180000), SPH_C32(0x51850000), SPH_C32(0x31450000), + SPH_C32(0xbb7400af), SPH_C32(0x04e91f68), SPH_C32(0x0c7aab87), + SPH_C32(0x97078369), SPH_C32(0x16c766eb), SPH_C32(0x5b420000), + SPH_C32(0x7c380000), SPH_C32(0x06360000), SPH_C32(0x6a150156), + SPH_C32(0xff998a66), SPH_C32(0xddd3a336), SPH_C32(0xabb62b19), + SPH_C32(0x4a82bc4a) }, + { SPH_C32(0xe9440000), SPH_C32(0xf48f0000), SPH_C32(0x24630000), + SPH_C32(0x1fbc00a2), SPH_C32(0x1f9faef5), SPH_C32(0x9ec0aa30), + SPH_C32(0xb43c5231), SPH_C32(0x02e372b9), SPH_C32(0x59ec0000), + SPH_C32(0x93090000), SPH_C32(0x18f70000), SPH_C32(0x9fdb015a), + SPH_C32(0x23608d6e), SPH_C32(0x0a1e7107), SPH_C32(0xa325851b), + SPH_C32(0xff375dcf) }, + { SPH_C32(0xea790000), SPH_C32(0xfc3c0000), SPH_C32(0xd7590000), + SPH_C32(0x257e00a5), SPH_C32(0x4eb624a5), SPH_C32(0xf5aecc2f), + SPH_C32(0xba999dd2), SPH_C32(0xe4390d47), SPH_C32(0xf1360000), + SPH_C32(0x05b70000), SPH_C32(0x44ea0000), SPH_C32(0x98010158), + SPH_C32(0x5e0618ed), SPH_C32(0x1586018d), SPH_C32(0x18430d13), + SPH_C32(0x25b0ddcf) }, + { SPH_C32(0x419e0000), SPH_C32(0x62310000), SPH_C32(0x787e0000), + SPH_C32(0x186600a0), SPH_C32(0x62f93b76), SPH_C32(0x8158daba), + SPH_C32(0x0f5ada39), SPH_C32(0xd864f2b9), SPH_C32(0xf20b0000), + SPH_C32(0x0d040000), SPH_C32(0xb7d00000), SPH_C32(0xa2c3015f), + SPH_C32(0x0f2f92bd), SPH_C32(0x7ee86792), SPH_C32(0x16e6c2f0), + SPH_C32(0xc36aa231) }, + { SPH_C32(0x42a30000), SPH_C32(0x6a820000), SPH_C32(0x8b440000), + SPH_C32(0x22a400a7), SPH_C32(0x33d0b126), SPH_C32(0xea36bca5), + SPH_C32(0x01ff15da), SPH_C32(0x3ebe8d47), SPH_C32(0x5ad10000), + SPH_C32(0x9bba0000), SPH_C32(0xebcd0000), SPH_C32(0xa519015d), + SPH_C32(0x7249073e), SPH_C32(0x61701718), SPH_C32(0xad804af8), + SPH_C32(0x19ed2231) }, + { SPH_C32(0xe8d70000), SPH_C32(0x130d0000), SPH_C32(0xc9980000), + SPH_C32(0xd0b000a9), SPH_C32(0x924f23ad), SPH_C32(0x22631e1e), + SPH_C32(0xb20a33d0), SPH_C32(0x518cecc2), SPH_C32(0xcbc40000), + SPH_C32(0x4f8c0000), SPH_C32(0x4f0d0000), SPH_C32(0xc9070159), + SPH_C32(0x9989ae78), SPH_C32(0x50f1d20b), SPH_C32(0x33eb7249), + SPH_C32(0x84212818) }, + { SPH_C32(0xebea0000), SPH_C32(0x1bbe0000), SPH_C32(0x3aa20000), + SPH_C32(0xea7200ae), SPH_C32(0xc366a9fd), SPH_C32(0x490d7801), + SPH_C32(0xbcaffc33), SPH_C32(0xb756933c), SPH_C32(0x631e0000), + SPH_C32(0xd9320000), SPH_C32(0x13100000), SPH_C32(0xcedd015b), + SPH_C32(0xe4ef3bfb), SPH_C32(0x4f69a281), SPH_C32(0x888dfa41), + SPH_C32(0x5ea6a818) }, + { SPH_C32(0x400d0000), SPH_C32(0x85b30000), SPH_C32(0x95850000), + SPH_C32(0xd76a00ab), SPH_C32(0xef29b62e), SPH_C32(0x3dfb6e94), + SPH_C32(0x096cbbd8), SPH_C32(0x8b0b6cc2), SPH_C32(0x60230000), + SPH_C32(0xd1810000), SPH_C32(0xe02a0000), SPH_C32(0xf41f015c), + SPH_C32(0xb5c6b1ab), SPH_C32(0x2407c49e), SPH_C32(0x862835a2), + SPH_C32(0xb87cd7e6) }, + { SPH_C32(0x43300000), SPH_C32(0x8d000000), SPH_C32(0x66bf0000), + SPH_C32(0xeda800ac), SPH_C32(0xbe003c7e), SPH_C32(0x5695088b), + SPH_C32(0x07c9743b), SPH_C32(0x6dd1133c), SPH_C32(0xc8f90000), + SPH_C32(0x473f0000), SPH_C32(0xbc370000), SPH_C32(0xf3c5015e), + SPH_C32(0xc8a02428), SPH_C32(0x3b9fb414), SPH_C32(0x3d4ebdaa), + SPH_C32(0x62fb57e6) }, + { SPH_C32(0x24c40000), SPH_C32(0x7e090000), SPH_C32(0x30370000), + SPH_C32(0x2d9300b2), SPH_C32(0x80080b5c), SPH_C32(0xd73e9d72), + SPH_C32(0x70ec30dc), SPH_C32(0xf751dc07), SPH_C32(0xca130000), + SPH_C32(0xd7460000), SPH_C32(0x788a0000), SPH_C32(0x2c280153), + SPH_C32(0x2ff4eaec), SPH_C32(0x45e4faa2), SPH_C32(0x36d78dc8), + SPH_C32(0x6944d1fd) }, + { SPH_C32(0x27f90000), SPH_C32(0x76ba0000), SPH_C32(0xc30d0000), + SPH_C32(0x175100b5), SPH_C32(0xd121810c), SPH_C32(0xbc50fb6d), + SPH_C32(0x7e49ff3f), SPH_C32(0x118ba3f9), SPH_C32(0x62c90000), + SPH_C32(0x41f80000), SPH_C32(0x24970000), SPH_C32(0x2bf20151), + SPH_C32(0x52927f6f), SPH_C32(0x5a7c8a28), SPH_C32(0x8db105c0), + SPH_C32(0xb3c351fd) }, + { SPH_C32(0x8c1e0000), SPH_C32(0xe8b70000), SPH_C32(0x6c2a0000), + SPH_C32(0x2a4900b0), SPH_C32(0xfd6e9edf), SPH_C32(0xc8a6edf8), + SPH_C32(0xcb8ab8d4), SPH_C32(0x2dd65c07), SPH_C32(0x61f40000), + SPH_C32(0x494b0000), SPH_C32(0xd7ad0000), SPH_C32(0x11300156), + SPH_C32(0x03bbf53f), SPH_C32(0x3112ec37), SPH_C32(0x8314ca23), + SPH_C32(0x55192e03) }, + { SPH_C32(0x8f230000), SPH_C32(0xe0040000), SPH_C32(0x9f100000), + SPH_C32(0x108b00b7), SPH_C32(0xac47148f), SPH_C32(0xa3c88be7), + SPH_C32(0xc52f7737), SPH_C32(0xcb0c23f9), SPH_C32(0xc92e0000), + SPH_C32(0xdff50000), SPH_C32(0x8bb00000), SPH_C32(0x16ea0154), + SPH_C32(0x7edd60bc), SPH_C32(0x2e8a9cbd), SPH_C32(0x3872422b), + SPH_C32(0x8f9eae03) }, + { SPH_C32(0x25570000), SPH_C32(0x998b0000), SPH_C32(0xddcc0000), + SPH_C32(0xe29f00b9), SPH_C32(0x0dd88604), SPH_C32(0x6b9d295c), + SPH_C32(0x76da513d), SPH_C32(0xa43e427c), SPH_C32(0x583b0000), + SPH_C32(0x0bc30000), SPH_C32(0x2f700000), SPH_C32(0x7af40150), + SPH_C32(0x951dc9fa), SPH_C32(0x1f0b59ae), SPH_C32(0xa6197a9a), + SPH_C32(0x1252a42a) }, + { SPH_C32(0x266a0000), SPH_C32(0x91380000), SPH_C32(0x2ef60000), + SPH_C32(0xd85d00be), SPH_C32(0x5cf10c54), SPH_C32(0x00f34f43), + SPH_C32(0x787f9ede), SPH_C32(0x42e43d82), SPH_C32(0xf0e10000), + SPH_C32(0x9d7d0000), SPH_C32(0x736d0000), SPH_C32(0x7d2e0152), + SPH_C32(0xe87b5c79), SPH_C32(0x00932924), SPH_C32(0x1d7ff292), + SPH_C32(0xc8d5242a) }, + { SPH_C32(0x8d8d0000), SPH_C32(0x0f350000), SPH_C32(0x81d10000), + SPH_C32(0xe54500bb), SPH_C32(0x70be1387), SPH_C32(0x740559d6), + SPH_C32(0xcdbcd935), SPH_C32(0x7eb9c27c), SPH_C32(0xf3dc0000), + SPH_C32(0x95ce0000), SPH_C32(0x80570000), SPH_C32(0x47ec0155), + SPH_C32(0xb952d629), SPH_C32(0x6bfd4f3b), SPH_C32(0x13da3d71), + SPH_C32(0x2e0f5bd4) }, + { SPH_C32(0x8eb00000), SPH_C32(0x07860000), SPH_C32(0x72eb0000), + SPH_C32(0xdf8700bc), SPH_C32(0x219799d7), SPH_C32(0x1f6b3fc9), + SPH_C32(0xc31916d6), SPH_C32(0x9863bd82), SPH_C32(0x5b060000), + SPH_C32(0x03700000), SPH_C32(0xdc4a0000), SPH_C32(0x40360157), + SPH_C32(0xc43443aa), SPH_C32(0x74653fb1), SPH_C32(0xa8bcb579), + SPH_C32(0xf488dbd4) }, + { SPH_C32(0xb6ec0000), SPH_C32(0xa28c0000), SPH_C32(0x67cd0000), + SPH_C32(0x7b4f00b1), SPH_C32(0x3ae1284a), SPH_C32(0x8dd13e7e), + SPH_C32(0xe022c78e), SPH_C32(0x8c47a9d0), SPH_C32(0x59a80000), + SPH_C32(0xec410000), SPH_C32(0xc28b0000), SPH_C32(0xb5f8015b), + SPH_C32(0x18cd44a2), SPH_C32(0xa3a8ed80), SPH_C32(0xa02f1b7b), + SPH_C32(0x413d3a51) }, + { SPH_C32(0xb5d10000), SPH_C32(0xaa3f0000), SPH_C32(0x94f70000), + SPH_C32(0x418d00b6), SPH_C32(0x6bc8a21a), SPH_C32(0xe6bf5861), + SPH_C32(0xee87086d), SPH_C32(0x6a9dd62e), SPH_C32(0xf1720000), + SPH_C32(0x7aff0000), SPH_C32(0x9e960000), SPH_C32(0xb2220159), + SPH_C32(0x65abd121), SPH_C32(0xbc309d0a), SPH_C32(0x1b499373), + SPH_C32(0x9bbaba51) }, + { SPH_C32(0x1e360000), SPH_C32(0x34320000), SPH_C32(0x3bd00000), + SPH_C32(0x7c9500b3), SPH_C32(0x4787bdc9), SPH_C32(0x92494ef4), + SPH_C32(0x5b444f86), SPH_C32(0x56c029d0), SPH_C32(0xf24f0000), + SPH_C32(0x724c0000), SPH_C32(0x6dac0000), SPH_C32(0x88e0015e), + SPH_C32(0x34825b71), SPH_C32(0xd75efb15), SPH_C32(0x15ec5c90), + SPH_C32(0x7d60c5af) }, + { SPH_C32(0x1d0b0000), SPH_C32(0x3c810000), SPH_C32(0xc8ea0000), + SPH_C32(0x465700b4), SPH_C32(0x16ae3799), SPH_C32(0xf92728eb), + SPH_C32(0x55e18065), SPH_C32(0xb01a562e), SPH_C32(0x5a950000), + SPH_C32(0xe4f20000), SPH_C32(0x31b10000), SPH_C32(0x8f3a015c), + SPH_C32(0x49e4cef2), SPH_C32(0xc8c68b9f), SPH_C32(0xae8ad498), + SPH_C32(0xa7e745af) }, + { SPH_C32(0xb77f0000), SPH_C32(0x450e0000), SPH_C32(0x8a360000), + SPH_C32(0xb44300ba), SPH_C32(0xb731a512), SPH_C32(0x31728a50), + SPH_C32(0xe614a66f), SPH_C32(0xdf2837ab), SPH_C32(0xcb800000), + SPH_C32(0x30c40000), SPH_C32(0x95710000), SPH_C32(0xe3240158), + SPH_C32(0xa22467b4), SPH_C32(0xf9474e8c), SPH_C32(0x30e1ec29), + SPH_C32(0x3a2b4f86) }, + { SPH_C32(0xb4420000), SPH_C32(0x4dbd0000), SPH_C32(0x790c0000), + SPH_C32(0x8e8100bd), SPH_C32(0xe6182f42), SPH_C32(0x5a1cec4f), + SPH_C32(0xe8b1698c), SPH_C32(0x39f24855), SPH_C32(0x635a0000), + SPH_C32(0xa67a0000), SPH_C32(0xc96c0000), SPH_C32(0xe4fe015a), + SPH_C32(0xdf42f237), SPH_C32(0xe6df3e06), SPH_C32(0x8b876421), + SPH_C32(0xe0accf86) }, + { SPH_C32(0x1fa50000), SPH_C32(0xd3b00000), SPH_C32(0xd62b0000), + SPH_C32(0xb39900b8), SPH_C32(0xca573091), SPH_C32(0x2eeafada), + SPH_C32(0x5d722e67), SPH_C32(0x05afb7ab), SPH_C32(0x60670000), + SPH_C32(0xaec90000), SPH_C32(0x3a560000), SPH_C32(0xde3c015d), + SPH_C32(0x8e6b7867), SPH_C32(0x8db15819), SPH_C32(0x8522abc2), + SPH_C32(0x0676b078) }, + { SPH_C32(0x1c980000), SPH_C32(0xdb030000), SPH_C32(0x25110000), + SPH_C32(0x895b00bf), SPH_C32(0x9b7ebac1), SPH_C32(0x45849cc5), + SPH_C32(0x53d7e184), SPH_C32(0xe375c855), SPH_C32(0xc8bd0000), + SPH_C32(0x38770000), SPH_C32(0x664b0000), SPH_C32(0xd9e6015f), + SPH_C32(0xf30dede4), SPH_C32(0x92292893), SPH_C32(0x3e4423ca), + SPH_C32(0xdcf13078) }, + { SPH_C32(0x95bb0000), SPH_C32(0x81450000), SPH_C32(0x3b240000), + SPH_C32(0x48db0140), SPH_C32(0x0a8a6c53), SPH_C32(0x56f56eec), + SPH_C32(0x62c91877), SPH_C32(0xe7e00a94), SPH_C32(0xee930000), + SPH_C32(0xd6070000), SPH_C32(0x92c10000), SPH_C32(0x2b9801e0), + SPH_C32(0x9451287c), SPH_C32(0x3b6cfb57), SPH_C32(0x45312374), + SPH_C32(0x201f6a64) }, + { SPH_C32(0x96860000), SPH_C32(0x89f60000), SPH_C32(0xc81e0000), + SPH_C32(0x72190147), SPH_C32(0x5ba3e603), SPH_C32(0x3d9b08f3), + SPH_C32(0x6c6cd794), SPH_C32(0x013a756a), SPH_C32(0x46490000), + SPH_C32(0x40b90000), SPH_C32(0xcedc0000), SPH_C32(0x2c4201e2), + SPH_C32(0xe937bdff), SPH_C32(0x24f48bdd), SPH_C32(0xfe57ab7c), + SPH_C32(0xfa98ea64) }, + { SPH_C32(0x3d610000), SPH_C32(0x17fb0000), SPH_C32(0x67390000), + SPH_C32(0x4f010142), SPH_C32(0x77ecf9d0), SPH_C32(0x496d1e66), + SPH_C32(0xd9af907f), SPH_C32(0x3d678a94), SPH_C32(0x45740000), + SPH_C32(0x480a0000), SPH_C32(0x3de60000), SPH_C32(0x168001e5), + SPH_C32(0xb81e37af), SPH_C32(0x4f9aedc2), SPH_C32(0xf0f2649f), + SPH_C32(0x1c42959a) }, + { SPH_C32(0x3e5c0000), SPH_C32(0x1f480000), SPH_C32(0x94030000), + SPH_C32(0x75c30145), SPH_C32(0x26c57380), SPH_C32(0x22037879), + SPH_C32(0xd70a5f9c), SPH_C32(0xdbbdf56a), SPH_C32(0xedae0000), + SPH_C32(0xdeb40000), SPH_C32(0x61fb0000), SPH_C32(0x115a01e7), + SPH_C32(0xc578a22c), SPH_C32(0x50029d48), SPH_C32(0x4b94ec97), + SPH_C32(0xc6c5159a) }, + { SPH_C32(0x94280000), SPH_C32(0x66c70000), SPH_C32(0xd6df0000), + SPH_C32(0x87d7014b), SPH_C32(0x875ae10b), SPH_C32(0xea56dac2), + SPH_C32(0x64ff7996), SPH_C32(0xb48f94ef), SPH_C32(0x7cbb0000), + SPH_C32(0x0a820000), SPH_C32(0xc53b0000), SPH_C32(0x7d4401e3), + SPH_C32(0x2eb80b6a), SPH_C32(0x6183585b), SPH_C32(0xd5ffd426), + SPH_C32(0x5b091fb3) }, + { SPH_C32(0x97150000), SPH_C32(0x6e740000), SPH_C32(0x25e50000), + SPH_C32(0xbd15014c), SPH_C32(0xd6736b5b), SPH_C32(0x8138bcdd), + SPH_C32(0x6a5ab675), SPH_C32(0x5255eb11), SPH_C32(0xd4610000), + SPH_C32(0x9c3c0000), SPH_C32(0x99260000), SPH_C32(0x7a9e01e1), + SPH_C32(0x53de9ee9), SPH_C32(0x7e1b28d1), SPH_C32(0x6e995c2e), + SPH_C32(0x818e9fb3) }, + { SPH_C32(0x3cf20000), SPH_C32(0xf0790000), SPH_C32(0x8ac20000), + SPH_C32(0x800d0149), SPH_C32(0xfa3c7488), SPH_C32(0xf5ceaa48), + SPH_C32(0xdf99f19e), SPH_C32(0x6e0814ef), SPH_C32(0xd75c0000), + SPH_C32(0x948f0000), SPH_C32(0x6a1c0000), SPH_C32(0x405c01e6), + SPH_C32(0x02f714b9), SPH_C32(0x15754ece), SPH_C32(0x603c93cd), + SPH_C32(0x6754e04d) }, + { SPH_C32(0x3fcf0000), SPH_C32(0xf8ca0000), SPH_C32(0x79f80000), + SPH_C32(0xbacf014e), SPH_C32(0xab15fed8), SPH_C32(0x9ea0cc57), + SPH_C32(0xd13c3e7d), SPH_C32(0x88d26b11), SPH_C32(0x7f860000), + SPH_C32(0x02310000), SPH_C32(0x36010000), SPH_C32(0x478601e4), + SPH_C32(0x7f91813a), SPH_C32(0x0aed3e44), SPH_C32(0xdb5a1bc5), + SPH_C32(0xbdd3604d) }, + { SPH_C32(0x07930000), SPH_C32(0x5dc00000), SPH_C32(0x6cde0000), + SPH_C32(0x1e070143), SPH_C32(0xb0634f45), SPH_C32(0x0c1acde0), + SPH_C32(0xf207ef25), SPH_C32(0x9cf67f43), SPH_C32(0x7d280000), + SPH_C32(0xed000000), SPH_C32(0x28c00000), SPH_C32(0xb24801e8), + SPH_C32(0xa3688632), SPH_C32(0xdd20ec75), SPH_C32(0xd3c9b5c7), + SPH_C32(0x086681c8) }, + { SPH_C32(0x04ae0000), SPH_C32(0x55730000), SPH_C32(0x9fe40000), + SPH_C32(0x24c50144), SPH_C32(0xe14ac515), SPH_C32(0x6774abff), + SPH_C32(0xfca220c6), SPH_C32(0x7a2c00bd), SPH_C32(0xd5f20000), + SPH_C32(0x7bbe0000), SPH_C32(0x74dd0000), SPH_C32(0xb59201ea), + SPH_C32(0xde0e13b1), SPH_C32(0xc2b89cff), SPH_C32(0x68af3dcf), + SPH_C32(0xd2e101c8) }, + { SPH_C32(0xaf490000), SPH_C32(0xcb7e0000), SPH_C32(0x30c30000), + SPH_C32(0x19dd0141), SPH_C32(0xcd05dac6), SPH_C32(0x1382bd6a), + SPH_C32(0x4961672d), SPH_C32(0x4671ff43), SPH_C32(0xd6cf0000), + SPH_C32(0x730d0000), SPH_C32(0x87e70000), SPH_C32(0x8f5001ed), + SPH_C32(0x8f2799e1), SPH_C32(0xa9d6fae0), SPH_C32(0x660af22c), + SPH_C32(0x343b7e36) }, + { SPH_C32(0xac740000), SPH_C32(0xc3cd0000), SPH_C32(0xc3f90000), + SPH_C32(0x231f0146), SPH_C32(0x9c2c5096), SPH_C32(0x78ecdb75), + SPH_C32(0x47c4a8ce), SPH_C32(0xa0ab80bd), SPH_C32(0x7e150000), + SPH_C32(0xe5b30000), SPH_C32(0xdbfa0000), SPH_C32(0x888a01ef), + SPH_C32(0xf2410c62), SPH_C32(0xb64e8a6a), SPH_C32(0xdd6c7a24), + SPH_C32(0xeebcfe36) }, + { SPH_C32(0x06000000), SPH_C32(0xba420000), SPH_C32(0x81250000), + SPH_C32(0xd10b0148), SPH_C32(0x3db3c21d), SPH_C32(0xb0b979ce), + SPH_C32(0xf4318ec4), SPH_C32(0xcf99e138), SPH_C32(0xef000000), + SPH_C32(0x31850000), SPH_C32(0x7f3a0000), SPH_C32(0xe49401eb), + SPH_C32(0x1981a524), SPH_C32(0x87cf4f79), SPH_C32(0x43074295), + SPH_C32(0x7370f41f) }, + { SPH_C32(0x053d0000), SPH_C32(0xb2f10000), SPH_C32(0x721f0000), + SPH_C32(0xebc9014f), SPH_C32(0x6c9a484d), SPH_C32(0xdbd71fd1), + SPH_C32(0xfa944127), SPH_C32(0x29439ec6), SPH_C32(0x47da0000), + SPH_C32(0xa73b0000), SPH_C32(0x23270000), SPH_C32(0xe34e01e9), + SPH_C32(0x64e730a7), SPH_C32(0x98573ff3), SPH_C32(0xf861ca9d), + SPH_C32(0xa9f7741f) }, + { SPH_C32(0xaeda0000), SPH_C32(0x2cfc0000), SPH_C32(0xdd380000), + SPH_C32(0xd6d1014a), SPH_C32(0x40d5579e), SPH_C32(0xaf210944), + SPH_C32(0x4f5706cc), SPH_C32(0x151e6138), SPH_C32(0x44e70000), + SPH_C32(0xaf880000), SPH_C32(0xd01d0000), SPH_C32(0xd98c01ee), + SPH_C32(0x35cebaf7), SPH_C32(0xf33959ec), SPH_C32(0xf6c4057e), + SPH_C32(0x4f2d0be1) }, + { SPH_C32(0xade70000), SPH_C32(0x244f0000), SPH_C32(0x2e020000), + SPH_C32(0xec13014d), SPH_C32(0x11fcddce), SPH_C32(0xc44f6f5b), + SPH_C32(0x41f2c92f), SPH_C32(0xf3c41ec6), SPH_C32(0xec3d0000), + SPH_C32(0x39360000), SPH_C32(0x8c000000), SPH_C32(0xde5601ec), + SPH_C32(0x48a82f74), SPH_C32(0xeca12966), SPH_C32(0x4da28d76), + SPH_C32(0x95aa8be1) }, + { SPH_C32(0xca130000), SPH_C32(0xd7460000), SPH_C32(0x788a0000), + SPH_C32(0x2c280153), SPH_C32(0x2ff4eaec), SPH_C32(0x45e4faa2), + SPH_C32(0x36d78dc8), SPH_C32(0x6944d1fd), SPH_C32(0xeed70000), + SPH_C32(0xa94f0000), SPH_C32(0x48bd0000), SPH_C32(0x01bb01e1), + SPH_C32(0xaffce1b0), SPH_C32(0x92da67d0), SPH_C32(0x463bbd14), + SPH_C32(0x9e150dfa) }, + { SPH_C32(0xc92e0000), SPH_C32(0xdff50000), SPH_C32(0x8bb00000), + SPH_C32(0x16ea0154), SPH_C32(0x7edd60bc), SPH_C32(0x2e8a9cbd), + SPH_C32(0x3872422b), SPH_C32(0x8f9eae03), SPH_C32(0x460d0000), + SPH_C32(0x3ff10000), SPH_C32(0x14a00000), SPH_C32(0x066101e3), + SPH_C32(0xd29a7433), SPH_C32(0x8d42175a), SPH_C32(0xfd5d351c), + SPH_C32(0x44928dfa) }, + { SPH_C32(0x62c90000), SPH_C32(0x41f80000), SPH_C32(0x24970000), + SPH_C32(0x2bf20151), SPH_C32(0x52927f6f), SPH_C32(0x5a7c8a28), + SPH_C32(0x8db105c0), SPH_C32(0xb3c351fd), SPH_C32(0x45300000), + SPH_C32(0x37420000), SPH_C32(0xe79a0000), SPH_C32(0x3ca301e4), + SPH_C32(0x83b3fe63), SPH_C32(0xe62c7145), SPH_C32(0xf3f8faff), + SPH_C32(0xa248f204) }, + { SPH_C32(0x61f40000), SPH_C32(0x494b0000), SPH_C32(0xd7ad0000), + SPH_C32(0x11300156), SPH_C32(0x03bbf53f), SPH_C32(0x3112ec37), + SPH_C32(0x8314ca23), SPH_C32(0x55192e03), SPH_C32(0xedea0000), + SPH_C32(0xa1fc0000), SPH_C32(0xbb870000), SPH_C32(0x3b7901e6), + SPH_C32(0xfed56be0), SPH_C32(0xf9b401cf), SPH_C32(0x489e72f7), + SPH_C32(0x78cf7204) }, + { SPH_C32(0xcb800000), SPH_C32(0x30c40000), SPH_C32(0x95710000), + SPH_C32(0xe3240158), SPH_C32(0xa22467b4), SPH_C32(0xf9474e8c), + SPH_C32(0x30e1ec29), SPH_C32(0x3a2b4f86), SPH_C32(0x7cff0000), + SPH_C32(0x75ca0000), SPH_C32(0x1f470000), SPH_C32(0x576701e2), + SPH_C32(0x1515c2a6), SPH_C32(0xc835c4dc), SPH_C32(0xd6f54a46), + SPH_C32(0xe503782d) }, + { SPH_C32(0xc8bd0000), SPH_C32(0x38770000), SPH_C32(0x664b0000), + SPH_C32(0xd9e6015f), SPH_C32(0xf30dede4), SPH_C32(0x92292893), + SPH_C32(0x3e4423ca), SPH_C32(0xdcf13078), SPH_C32(0xd4250000), + SPH_C32(0xe3740000), SPH_C32(0x435a0000), SPH_C32(0x50bd01e0), + SPH_C32(0x68735725), SPH_C32(0xd7adb456), SPH_C32(0x6d93c24e), + SPH_C32(0x3f84f82d) }, + { SPH_C32(0x635a0000), SPH_C32(0xa67a0000), SPH_C32(0xc96c0000), + SPH_C32(0xe4fe015a), SPH_C32(0xdf42f237), SPH_C32(0xe6df3e06), + SPH_C32(0x8b876421), SPH_C32(0xe0accf86), SPH_C32(0xd7180000), + SPH_C32(0xebc70000), SPH_C32(0xb0600000), SPH_C32(0x6a7f01e7), + SPH_C32(0x395add75), SPH_C32(0xbcc3d249), SPH_C32(0x63360dad), + SPH_C32(0xd95e87d3) }, + { SPH_C32(0x60670000), SPH_C32(0xaec90000), SPH_C32(0x3a560000), + SPH_C32(0xde3c015d), SPH_C32(0x8e6b7867), SPH_C32(0x8db15819), + SPH_C32(0x8522abc2), SPH_C32(0x0676b078), SPH_C32(0x7fc20000), + SPH_C32(0x7d790000), SPH_C32(0xec7d0000), SPH_C32(0x6da501e5), + SPH_C32(0x443c48f6), SPH_C32(0xa35ba2c3), SPH_C32(0xd85085a5), + SPH_C32(0x03d907d3) }, + { SPH_C32(0x583b0000), SPH_C32(0x0bc30000), SPH_C32(0x2f700000), + SPH_C32(0x7af40150), SPH_C32(0x951dc9fa), SPH_C32(0x1f0b59ae), + SPH_C32(0xa6197a9a), SPH_C32(0x1252a42a), SPH_C32(0x7d6c0000), + SPH_C32(0x92480000), SPH_C32(0xf2bc0000), SPH_C32(0x986b01e9), + SPH_C32(0x98c54ffe), SPH_C32(0x749670f2), SPH_C32(0xd0c32ba7), + SPH_C32(0xb66ce656) }, + { SPH_C32(0x5b060000), SPH_C32(0x03700000), SPH_C32(0xdc4a0000), + SPH_C32(0x40360157), SPH_C32(0xc43443aa), SPH_C32(0x74653fb1), + SPH_C32(0xa8bcb579), SPH_C32(0xf488dbd4), SPH_C32(0xd5b60000), + SPH_C32(0x04f60000), SPH_C32(0xaea10000), SPH_C32(0x9fb101eb), + SPH_C32(0xe5a3da7d), SPH_C32(0x6b0e0078), SPH_C32(0x6ba5a3af), + SPH_C32(0x6ceb6656) }, + { SPH_C32(0xf0e10000), SPH_C32(0x9d7d0000), SPH_C32(0x736d0000), + SPH_C32(0x7d2e0152), SPH_C32(0xe87b5c79), SPH_C32(0x00932924), + SPH_C32(0x1d7ff292), SPH_C32(0xc8d5242a), SPH_C32(0xd68b0000), + SPH_C32(0x0c450000), SPH_C32(0x5d9b0000), SPH_C32(0xa57301ec), + SPH_C32(0xb48a502d), SPH_C32(0x00606667), SPH_C32(0x65006c4c), + SPH_C32(0x8a3119a8) }, + { SPH_C32(0xf3dc0000), SPH_C32(0x95ce0000), SPH_C32(0x80570000), + SPH_C32(0x47ec0155), SPH_C32(0xb952d629), SPH_C32(0x6bfd4f3b), + SPH_C32(0x13da3d71), SPH_C32(0x2e0f5bd4), SPH_C32(0x7e510000), + SPH_C32(0x9afb0000), SPH_C32(0x01860000), SPH_C32(0xa2a901ee), + SPH_C32(0xc9ecc5ae), SPH_C32(0x1ff816ed), SPH_C32(0xde66e444), + SPH_C32(0x50b699a8) }, + { SPH_C32(0x59a80000), SPH_C32(0xec410000), SPH_C32(0xc28b0000), + SPH_C32(0xb5f8015b), SPH_C32(0x18cd44a2), SPH_C32(0xa3a8ed80), + SPH_C32(0xa02f1b7b), SPH_C32(0x413d3a51), SPH_C32(0xef440000), + SPH_C32(0x4ecd0000), SPH_C32(0xa5460000), SPH_C32(0xceb701ea), + SPH_C32(0x222c6ce8), SPH_C32(0x2e79d3fe), SPH_C32(0x400ddcf5), + SPH_C32(0xcd7a9381) }, + { SPH_C32(0x5a950000), SPH_C32(0xe4f20000), SPH_C32(0x31b10000), + SPH_C32(0x8f3a015c), SPH_C32(0x49e4cef2), SPH_C32(0xc8c68b9f), + SPH_C32(0xae8ad498), SPH_C32(0xa7e745af), SPH_C32(0x479e0000), + SPH_C32(0xd8730000), SPH_C32(0xf95b0000), SPH_C32(0xc96d01e8), + SPH_C32(0x5f4af96b), SPH_C32(0x31e1a374), SPH_C32(0xfb6b54fd), + SPH_C32(0x17fd1381) }, + { SPH_C32(0xf1720000), SPH_C32(0x7aff0000), SPH_C32(0x9e960000), + SPH_C32(0xb2220159), SPH_C32(0x65abd121), SPH_C32(0xbc309d0a), + SPH_C32(0x1b499373), SPH_C32(0x9bbaba51), SPH_C32(0x44a30000), + SPH_C32(0xd0c00000), SPH_C32(0x0a610000), SPH_C32(0xf3af01ef), + SPH_C32(0x0e63733b), SPH_C32(0x5a8fc56b), SPH_C32(0xf5ce9b1e), + SPH_C32(0xf1276c7f) }, + { SPH_C32(0xf24f0000), SPH_C32(0x724c0000), SPH_C32(0x6dac0000), + SPH_C32(0x88e0015e), SPH_C32(0x34825b71), SPH_C32(0xd75efb15), + SPH_C32(0x15ec5c90), SPH_C32(0x7d60c5af), SPH_C32(0xec790000), + SPH_C32(0x467e0000), SPH_C32(0x567c0000), SPH_C32(0xf47501ed), + SPH_C32(0x7305e6b8), SPH_C32(0x4517b5e1), SPH_C32(0x4ea81316), + SPH_C32(0x2ba0ec7f) }, + { SPH_C32(0x95ff0000), SPH_C32(0xfe0d0000), SPH_C32(0xe1580000), + SPH_C32(0x62f80141), SPH_C32(0x3127a59f), SPH_C32(0xff43f26b), + SPH_C32(0x61c38617), SPH_C32(0x59ea6d0a), SPH_C32(0xb17f0000), + SPH_C32(0xff4c0000), SPH_C32(0x0b130000), SPH_C32(0x654801f2), + SPH_C32(0x8a82670f), SPH_C32(0x81cbf39e), SPH_C32(0x122528ab), + SPH_C32(0x10b1d693) }, + { SPH_C32(0x96c20000), SPH_C32(0xf6be0000), SPH_C32(0x12620000), + SPH_C32(0x583a0146), SPH_C32(0x600e2fcf), SPH_C32(0x942d9474), + SPH_C32(0x6f6649f4), SPH_C32(0xbf3012f4), SPH_C32(0x19a50000), + SPH_C32(0x69f20000), SPH_C32(0x570e0000), SPH_C32(0x629201f0), + SPH_C32(0xf7e4f28c), SPH_C32(0x9e538314), SPH_C32(0xa943a0a3), + SPH_C32(0xca365693) }, + { SPH_C32(0x3d250000), SPH_C32(0x68b30000), SPH_C32(0xbd450000), + SPH_C32(0x65220143), SPH_C32(0x4c41301c), SPH_C32(0xe0db82e1), + SPH_C32(0xdaa50e1f), SPH_C32(0x836ded0a), SPH_C32(0x1a980000), + SPH_C32(0x61410000), SPH_C32(0xa4340000), SPH_C32(0x585001f7), + SPH_C32(0xa6cd78dc), SPH_C32(0xf53de50b), SPH_C32(0xa7e66f40), + SPH_C32(0x2cec296d) }, + { SPH_C32(0x3e180000), SPH_C32(0x60000000), SPH_C32(0x4e7f0000), + SPH_C32(0x5fe00144), SPH_C32(0x1d68ba4c), SPH_C32(0x8bb5e4fe), + SPH_C32(0xd400c1fc), SPH_C32(0x65b792f4), SPH_C32(0xb2420000), + SPH_C32(0xf7ff0000), SPH_C32(0xf8290000), SPH_C32(0x5f8a01f5), + SPH_C32(0xdbabed5f), SPH_C32(0xeaa59581), SPH_C32(0x1c80e748), + SPH_C32(0xf66ba96d) }, + { SPH_C32(0x946c0000), SPH_C32(0x198f0000), SPH_C32(0x0ca30000), + SPH_C32(0xadf4014a), SPH_C32(0xbcf728c7), SPH_C32(0x43e04645), + SPH_C32(0x67f5e7f6), SPH_C32(0x0a85f371), SPH_C32(0x23570000), + SPH_C32(0x23c90000), SPH_C32(0x5ce90000), SPH_C32(0x339401f1), + SPH_C32(0x306b4419), SPH_C32(0xdb245092), SPH_C32(0x82ebdff9), + SPH_C32(0x6ba7a344) }, + { SPH_C32(0x97510000), SPH_C32(0x113c0000), SPH_C32(0xff990000), + SPH_C32(0x9736014d), SPH_C32(0xeddea297), SPH_C32(0x288e205a), + SPH_C32(0x69502815), SPH_C32(0xec5f8c8f), SPH_C32(0x8b8d0000), + SPH_C32(0xb5770000), SPH_C32(0x00f40000), SPH_C32(0x344e01f3), + SPH_C32(0x4d0dd19a), SPH_C32(0xc4bc2018), SPH_C32(0x398d57f1), + SPH_C32(0xb1202344) }, + { SPH_C32(0x3cb60000), SPH_C32(0x8f310000), SPH_C32(0x50be0000), + SPH_C32(0xaa2e0148), SPH_C32(0xc191bd44), SPH_C32(0x5c7836cf), + SPH_C32(0xdc936ffe), SPH_C32(0xd0027371), SPH_C32(0x88b00000), + SPH_C32(0xbdc40000), SPH_C32(0xf3ce0000), SPH_C32(0x0e8c01f4), + SPH_C32(0x1c245bca), SPH_C32(0xafd24607), SPH_C32(0x37289812), + SPH_C32(0x57fa5cba) }, + { SPH_C32(0x3f8b0000), SPH_C32(0x87820000), SPH_C32(0xa3840000), + SPH_C32(0x90ec014f), SPH_C32(0x90b83714), SPH_C32(0x371650d0), + SPH_C32(0xd236a01d), SPH_C32(0x36d80c8f), SPH_C32(0x206a0000), + SPH_C32(0x2b7a0000), SPH_C32(0xafd30000), SPH_C32(0x095601f6), + SPH_C32(0x6142ce49), SPH_C32(0xb04a368d), SPH_C32(0x8c4e101a), + SPH_C32(0x8d7ddcba) }, + { SPH_C32(0x07d70000), SPH_C32(0x22880000), SPH_C32(0xb6a20000), + SPH_C32(0x34240142), SPH_C32(0x8bce8689), SPH_C32(0xa5ac5167), + SPH_C32(0xf10d7145), SPH_C32(0x22fc18dd), SPH_C32(0x22c40000), + SPH_C32(0xc44b0000), SPH_C32(0xb1120000), SPH_C32(0xfc9801fa), + SPH_C32(0xbdbbc941), SPH_C32(0x6787e4bc), SPH_C32(0x84ddbe18), + SPH_C32(0x38c83d3f) }, + { SPH_C32(0x04ea0000), SPH_C32(0x2a3b0000), SPH_C32(0x45980000), + SPH_C32(0x0ee60145), SPH_C32(0xdae70cd9), SPH_C32(0xcec23778), + SPH_C32(0xffa8bea6), SPH_C32(0xc4266723), SPH_C32(0x8a1e0000), + SPH_C32(0x52f50000), SPH_C32(0xed0f0000), SPH_C32(0xfb4201f8), + SPH_C32(0xc0dd5cc2), SPH_C32(0x781f9436), SPH_C32(0x3fbb3610), + SPH_C32(0xe24fbd3f) }, + { SPH_C32(0xaf0d0000), SPH_C32(0xb4360000), SPH_C32(0xeabf0000), + SPH_C32(0x33fe0140), SPH_C32(0xf6a8130a), SPH_C32(0xba3421ed), + SPH_C32(0x4a6bf94d), SPH_C32(0xf87b98dd), SPH_C32(0x89230000), + SPH_C32(0x5a460000), SPH_C32(0x1e350000), SPH_C32(0xc18001ff), + SPH_C32(0x91f4d692), SPH_C32(0x1371f229), SPH_C32(0x311ef9f3), + SPH_C32(0x0495c2c1) }, + { SPH_C32(0xac300000), SPH_C32(0xbc850000), SPH_C32(0x19850000), + SPH_C32(0x093c0147), SPH_C32(0xa781995a), SPH_C32(0xd15a47f2), + SPH_C32(0x44ce36ae), SPH_C32(0x1ea1e723), SPH_C32(0x21f90000), + SPH_C32(0xccf80000), SPH_C32(0x42280000), SPH_C32(0xc65a01fd), + SPH_C32(0xec924311), SPH_C32(0x0ce982a3), SPH_C32(0x8a7871fb), + SPH_C32(0xde1242c1) }, + { SPH_C32(0x06440000), SPH_C32(0xc50a0000), SPH_C32(0x5b590000), + SPH_C32(0xfb280149), SPH_C32(0x061e0bd1), SPH_C32(0x190fe549), + SPH_C32(0xf73b10a4), SPH_C32(0x719386a6), SPH_C32(0xb0ec0000), + SPH_C32(0x18ce0000), SPH_C32(0xe6e80000), SPH_C32(0xaa4401f9), + SPH_C32(0x0752ea57), SPH_C32(0x3d6847b0), SPH_C32(0x1413494a), + SPH_C32(0x43de48e8) }, + { SPH_C32(0x05790000), SPH_C32(0xcdb90000), SPH_C32(0xa8630000), + SPH_C32(0xc1ea014e), SPH_C32(0x57378181), SPH_C32(0x72618356), + SPH_C32(0xf99edf47), SPH_C32(0x9749f958), SPH_C32(0x18360000), + SPH_C32(0x8e700000), SPH_C32(0xbaf50000), SPH_C32(0xad9e01fb), + SPH_C32(0x7a347fd4), SPH_C32(0x22f0373a), SPH_C32(0xaf75c142), + SPH_C32(0x9959c8e8) }, + { SPH_C32(0xae9e0000), SPH_C32(0x53b40000), SPH_C32(0x07440000), + SPH_C32(0xfcf2014b), SPH_C32(0x7b789e52), SPH_C32(0x069795c3), + SPH_C32(0x4c5d98ac), SPH_C32(0xab1406a6), SPH_C32(0x1b0b0000), + SPH_C32(0x86c30000), SPH_C32(0x49cf0000), SPH_C32(0x975c01fc), + SPH_C32(0x2b1df584), SPH_C32(0x499e5125), SPH_C32(0xa1d00ea1), + SPH_C32(0x7f83b716) }, + { SPH_C32(0xada30000), SPH_C32(0x5b070000), SPH_C32(0xf47e0000), + SPH_C32(0xc630014c), SPH_C32(0x2a511402), SPH_C32(0x6df9f3dc), + SPH_C32(0x42f8574f), SPH_C32(0x4dce7958), SPH_C32(0xb3d10000), + SPH_C32(0x107d0000), SPH_C32(0x15d20000), SPH_C32(0x908601fe), + SPH_C32(0x567b6007), SPH_C32(0x560621af), SPH_C32(0x1ab686a9), + SPH_C32(0xa5043716) }, + { SPH_C32(0xca570000), SPH_C32(0xa80e0000), SPH_C32(0xa2f60000), + SPH_C32(0x060b0152), SPH_C32(0x14592320), SPH_C32(0xec526625), + SPH_C32(0x35dd13a8), SPH_C32(0xd74eb663), SPH_C32(0xb13b0000), + SPH_C32(0x80040000), SPH_C32(0xd16f0000), SPH_C32(0x4f6b01f3), + SPH_C32(0xb12faec3), SPH_C32(0x287d6f19), SPH_C32(0x112fb6cb), + SPH_C32(0xaebbb10d) }, + { SPH_C32(0xc96a0000), SPH_C32(0xa0bd0000), SPH_C32(0x51cc0000), + SPH_C32(0x3cc90155), SPH_C32(0x4570a970), SPH_C32(0x873c003a), + SPH_C32(0x3b78dc4b), SPH_C32(0x3194c99d), SPH_C32(0x19e10000), + SPH_C32(0x16ba0000), SPH_C32(0x8d720000), SPH_C32(0x48b101f1), + SPH_C32(0xcc493b40), SPH_C32(0x37e51f93), SPH_C32(0xaa493ec3), + SPH_C32(0x743c310d) }, + { SPH_C32(0x628d0000), SPH_C32(0x3eb00000), SPH_C32(0xfeeb0000), + SPH_C32(0x01d10150), SPH_C32(0x693fb6a3), SPH_C32(0xf3ca16af), + SPH_C32(0x8ebb9ba0), SPH_C32(0x0dc93663), SPH_C32(0x1adc0000), + SPH_C32(0x1e090000), SPH_C32(0x7e480000), SPH_C32(0x727301f6), + SPH_C32(0x9d60b110), SPH_C32(0x5c8b798c), SPH_C32(0xa4ecf120), + SPH_C32(0x92e64ef3) }, + { SPH_C32(0x61b00000), SPH_C32(0x36030000), SPH_C32(0x0dd10000), + SPH_C32(0x3b130157), SPH_C32(0x38163cf3), SPH_C32(0x98a470b0), + SPH_C32(0x801e5443), SPH_C32(0xeb13499d), SPH_C32(0xb2060000), + SPH_C32(0x88b70000), SPH_C32(0x22550000), SPH_C32(0x75a901f4), + SPH_C32(0xe0062493), SPH_C32(0x43130906), SPH_C32(0x1f8a7928), + SPH_C32(0x4861cef3) }, + { SPH_C32(0xcbc40000), SPH_C32(0x4f8c0000), SPH_C32(0x4f0d0000), + SPH_C32(0xc9070159), SPH_C32(0x9989ae78), SPH_C32(0x50f1d20b), + SPH_C32(0x33eb7249), SPH_C32(0x84212818), SPH_C32(0x23130000), + SPH_C32(0x5c810000), SPH_C32(0x86950000), SPH_C32(0x19b701f0), + SPH_C32(0x0bc68dd5), SPH_C32(0x7292cc15), SPH_C32(0x81e14199), + SPH_C32(0xd5adc4da) }, + { SPH_C32(0xc8f90000), SPH_C32(0x473f0000), SPH_C32(0xbc370000), + SPH_C32(0xf3c5015e), SPH_C32(0xc8a02428), SPH_C32(0x3b9fb414), + SPH_C32(0x3d4ebdaa), SPH_C32(0x62fb57e6), SPH_C32(0x8bc90000), + SPH_C32(0xca3f0000), SPH_C32(0xda880000), SPH_C32(0x1e6d01f2), + SPH_C32(0x76a01856), SPH_C32(0x6d0abc9f), SPH_C32(0x3a87c991), + SPH_C32(0x0f2a44da) }, + { SPH_C32(0x631e0000), SPH_C32(0xd9320000), SPH_C32(0x13100000), + SPH_C32(0xcedd015b), SPH_C32(0xe4ef3bfb), SPH_C32(0x4f69a281), + SPH_C32(0x888dfa41), SPH_C32(0x5ea6a818), SPH_C32(0x88f40000), + SPH_C32(0xc28c0000), SPH_C32(0x29b20000), SPH_C32(0x24af01f5), + SPH_C32(0x27899206), SPH_C32(0x0664da80), SPH_C32(0x34220672), + SPH_C32(0xe9f03b24) }, + { SPH_C32(0x60230000), SPH_C32(0xd1810000), SPH_C32(0xe02a0000), + SPH_C32(0xf41f015c), SPH_C32(0xb5c6b1ab), SPH_C32(0x2407c49e), + SPH_C32(0x862835a2), SPH_C32(0xb87cd7e6), SPH_C32(0x202e0000), + SPH_C32(0x54320000), SPH_C32(0x75af0000), SPH_C32(0x237501f7), + SPH_C32(0x5aef0785), SPH_C32(0x19fcaa0a), SPH_C32(0x8f448e7a), + SPH_C32(0x3377bb24) }, + { SPH_C32(0x587f0000), SPH_C32(0x748b0000), SPH_C32(0xf50c0000), + SPH_C32(0x50d70151), SPH_C32(0xaeb00036), SPH_C32(0xb6bdc529), + SPH_C32(0xa513e4fa), SPH_C32(0xac58c3b4), SPH_C32(0x22800000), + SPH_C32(0xbb030000), SPH_C32(0x6b6e0000), SPH_C32(0xd6bb01fb), + SPH_C32(0x8616008d), SPH_C32(0xce31783b), SPH_C32(0x87d72078), + SPH_C32(0x86c25aa1) }, + { SPH_C32(0x5b420000), SPH_C32(0x7c380000), SPH_C32(0x06360000), + SPH_C32(0x6a150156), SPH_C32(0xff998a66), SPH_C32(0xddd3a336), + SPH_C32(0xabb62b19), SPH_C32(0x4a82bc4a), SPH_C32(0x8a5a0000), + SPH_C32(0x2dbd0000), SPH_C32(0x37730000), SPH_C32(0xd16101f9), + SPH_C32(0xfb70950e), SPH_C32(0xd1a908b1), SPH_C32(0x3cb1a870), + SPH_C32(0x5c45daa1) }, + { SPH_C32(0xf0a50000), SPH_C32(0xe2350000), SPH_C32(0xa9110000), + SPH_C32(0x570d0153), SPH_C32(0xd3d695b5), SPH_C32(0xa925b5a3), + SPH_C32(0x1e756cf2), SPH_C32(0x76df43b4), SPH_C32(0x89670000), + SPH_C32(0x250e0000), SPH_C32(0xc4490000), SPH_C32(0xeba301fe), + SPH_C32(0xaa591f5e), SPH_C32(0xbac76eae), SPH_C32(0x32146793), + SPH_C32(0xba9fa55f) }, + { SPH_C32(0xf3980000), SPH_C32(0xea860000), SPH_C32(0x5a2b0000), + SPH_C32(0x6dcf0154), SPH_C32(0x82ff1fe5), SPH_C32(0xc24bd3bc), + SPH_C32(0x10d0a311), SPH_C32(0x90053c4a), SPH_C32(0x21bd0000), + SPH_C32(0xb3b00000), SPH_C32(0x98540000), SPH_C32(0xec7901fc), + SPH_C32(0xd73f8add), SPH_C32(0xa55f1e24), SPH_C32(0x8972ef9b), + SPH_C32(0x6018255f) }, + { SPH_C32(0x59ec0000), SPH_C32(0x93090000), SPH_C32(0x18f70000), + SPH_C32(0x9fdb015a), SPH_C32(0x23608d6e), SPH_C32(0x0a1e7107), + SPH_C32(0xa325851b), SPH_C32(0xff375dcf), SPH_C32(0xb0a80000), + SPH_C32(0x67860000), SPH_C32(0x3c940000), SPH_C32(0x806701f8), + SPH_C32(0x3cff239b), SPH_C32(0x94dedb37), SPH_C32(0x1719d72a), + SPH_C32(0xfdd42f76) }, + { SPH_C32(0x5ad10000), SPH_C32(0x9bba0000), SPH_C32(0xebcd0000), + SPH_C32(0xa519015d), SPH_C32(0x7249073e), SPH_C32(0x61701718), + SPH_C32(0xad804af8), SPH_C32(0x19ed2231), SPH_C32(0x18720000), + SPH_C32(0xf1380000), SPH_C32(0x60890000), SPH_C32(0x87bd01fa), + SPH_C32(0x4199b618), SPH_C32(0x8b46abbd), SPH_C32(0xac7f5f22), + SPH_C32(0x2753af76) }, + { SPH_C32(0xf1360000), SPH_C32(0x05b70000), SPH_C32(0x44ea0000), + SPH_C32(0x98010158), SPH_C32(0x5e0618ed), SPH_C32(0x1586018d), + SPH_C32(0x18430d13), SPH_C32(0x25b0ddcf), SPH_C32(0x1b4f0000), + SPH_C32(0xf98b0000), SPH_C32(0x93b30000), SPH_C32(0xbd7f01fd), + SPH_C32(0x10b03c48), SPH_C32(0xe028cda2), SPH_C32(0xa2da90c1), + SPH_C32(0xc189d088) }, + { SPH_C32(0xf20b0000), SPH_C32(0x0d040000), SPH_C32(0xb7d00000), + SPH_C32(0xa2c3015f), SPH_C32(0x0f2f92bd), SPH_C32(0x7ee86792), + SPH_C32(0x16e6c2f0), SPH_C32(0xc36aa231), SPH_C32(0xb3950000), + SPH_C32(0x6f350000), SPH_C32(0xcfae0000), SPH_C32(0xbaa501ff), + SPH_C32(0x6dd6a9cb), SPH_C32(0xffb0bd28), SPH_C32(0x19bc18c9), + SPH_C32(0x1b0e5088) } +}; + +#define INPUT_BIG do { \ + unsigned acc = buf[0]; \ + const sph_u32 *rp; \ + rp = &T512_0[acc][0]; \ + m0 = rp[0]; \ + m1 = rp[1]; \ + m2 = rp[2]; \ + m3 = rp[3]; \ + m4 = rp[4]; \ + m5 = rp[5]; \ + m6 = rp[6]; \ + m7 = rp[7]; \ + m8 = rp[8]; \ + m9 = rp[9]; \ + mA = rp[10]; \ + mB = rp[11]; \ + mC = rp[12]; \ + mD = rp[13]; \ + mE = rp[14]; \ + mF = rp[15]; \ + acc = buf[1]; \ + rp = &T512_8[acc][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[2]; \ + rp = &T512_16[acc][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[3]; \ + rp = &T512_24[acc][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[4]; \ + rp = &T512_32[acc][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[5]; \ + rp = &T512_40[acc][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[6]; \ + rp = &T512_48[acc][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + acc = buf[7]; \ + rp = &T512_56[acc][0]; \ + m0 ^= rp[0]; \ + m1 ^= rp[1]; \ + m2 ^= rp[2]; \ + m3 ^= rp[3]; \ + m4 ^= rp[4]; \ + m5 ^= rp[5]; \ + m6 ^= rp[6]; \ + m7 ^= rp[7]; \ + m8 ^= rp[8]; \ + m9 ^= rp[9]; \ + mA ^= rp[10]; \ + mB ^= rp[11]; \ + mC ^= rp[12]; \ + mD ^= rp[13]; \ + mE ^= rp[14]; \ + mF ^= rp[15]; \ + } while (0) + +#endif + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/src/obj/skunkhash/raptor.h b/src/obj/skunkhash/raptor.h new file mode 100644 index 0000000..50e2232 --- /dev/null +++ b/src/obj/skunkhash/raptor.h @@ -0,0 +1,29 @@ +#ifndef RAPTOR_H +#define RAPTOR_H + +class RaptorFuck{ + + + unsigned char keyStream[16]; + unsigned long long int blockCounter; + int byteCounter;; + + unsigned long long int nonce; + + + public: + + RaptorFuck(); + + int keySize(); + + void setNonce( unsigned long long int nonce ); + + void setKey(unsigned char * key); + + unsigned int encrypt(unsigned int byte); + + +}; + +#endif \ No newline at end of file diff --git a/src/obj/skunkhash/skein.c b/src/obj/skunkhash/skein.c new file mode 100644 index 0000000..7e47e35 --- /dev/null +++ b/src/obj/skunkhash/skein.c @@ -0,0 +1,1254 @@ +/* $Id: skein.c 254 2011-06-07 19:38:58Z tp $ */ +/* + * Skein implementation. + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @author Thomas Pornin + */ + +#include +#include + +#include "sph_skein.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +#if SPH_SMALL_FOOTPRINT && !defined SPH_SMALL_FOOTPRINT_SKEIN +#define SPH_SMALL_FOOTPRINT_SKEIN 1 +#endif + +#ifdef _MSC_VER +#pragma warning (disable: 4146) +#endif + +#if SPH_64 + +#if 0 +/* obsolete */ +/* + * M5_ ## s ## _ ## i evaluates to s+i mod 5 (0 <= s <= 18, 0 <= i <= 3). + */ + +#define M5_0_0 0 +#define M5_0_1 1 +#define M5_0_2 2 +#define M5_0_3 3 + +#define M5_1_0 1 +#define M5_1_1 2 +#define M5_1_2 3 +#define M5_1_3 4 + +#define M5_2_0 2 +#define M5_2_1 3 +#define M5_2_2 4 +#define M5_2_3 0 + +#define M5_3_0 3 +#define M5_3_1 4 +#define M5_3_2 0 +#define M5_3_3 1 + +#define M5_4_0 4 +#define M5_4_1 0 +#define M5_4_2 1 +#define M5_4_3 2 + +#define M5_5_0 0 +#define M5_5_1 1 +#define M5_5_2 2 +#define M5_5_3 3 + +#define M5_6_0 1 +#define M5_6_1 2 +#define M5_6_2 3 +#define M5_6_3 4 + +#define M5_7_0 2 +#define M5_7_1 3 +#define M5_7_2 4 +#define M5_7_3 0 + +#define M5_8_0 3 +#define M5_8_1 4 +#define M5_8_2 0 +#define M5_8_3 1 + +#define M5_9_0 4 +#define M5_9_1 0 +#define M5_9_2 1 +#define M5_9_3 2 + +#define M5_10_0 0 +#define M5_10_1 1 +#define M5_10_2 2 +#define M5_10_3 3 + +#define M5_11_0 1 +#define M5_11_1 2 +#define M5_11_2 3 +#define M5_11_3 4 + +#define M5_12_0 2 +#define M5_12_1 3 +#define M5_12_2 4 +#define M5_12_3 0 + +#define M5_13_0 3 +#define M5_13_1 4 +#define M5_13_2 0 +#define M5_13_3 1 + +#define M5_14_0 4 +#define M5_14_1 0 +#define M5_14_2 1 +#define M5_14_3 2 + +#define M5_15_0 0 +#define M5_15_1 1 +#define M5_15_2 2 +#define M5_15_3 3 + +#define M5_16_0 1 +#define M5_16_1 2 +#define M5_16_2 3 +#define M5_16_3 4 + +#define M5_17_0 2 +#define M5_17_1 3 +#define M5_17_2 4 +#define M5_17_3 0 + +#define M5_18_0 3 +#define M5_18_1 4 +#define M5_18_2 0 +#define M5_18_3 1 +#endif + +/* + * M9_ ## s ## _ ## i evaluates to s+i mod 9 (0 <= s <= 18, 0 <= i <= 7). + */ + +#define M9_0_0 0 +#define M9_0_1 1 +#define M9_0_2 2 +#define M9_0_3 3 +#define M9_0_4 4 +#define M9_0_5 5 +#define M9_0_6 6 +#define M9_0_7 7 + +#define M9_1_0 1 +#define M9_1_1 2 +#define M9_1_2 3 +#define M9_1_3 4 +#define M9_1_4 5 +#define M9_1_5 6 +#define M9_1_6 7 +#define M9_1_7 8 + +#define M9_2_0 2 +#define M9_2_1 3 +#define M9_2_2 4 +#define M9_2_3 5 +#define M9_2_4 6 +#define M9_2_5 7 +#define M9_2_6 8 +#define M9_2_7 0 + +#define M9_3_0 3 +#define M9_3_1 4 +#define M9_3_2 5 +#define M9_3_3 6 +#define M9_3_4 7 +#define M9_3_5 8 +#define M9_3_6 0 +#define M9_3_7 1 + +#define M9_4_0 4 +#define M9_4_1 5 +#define M9_4_2 6 +#define M9_4_3 7 +#define M9_4_4 8 +#define M9_4_5 0 +#define M9_4_6 1 +#define M9_4_7 2 + +#define M9_5_0 5 +#define M9_5_1 6 +#define M9_5_2 7 +#define M9_5_3 8 +#define M9_5_4 0 +#define M9_5_5 1 +#define M9_5_6 2 +#define M9_5_7 3 + +#define M9_6_0 6 +#define M9_6_1 7 +#define M9_6_2 8 +#define M9_6_3 0 +#define M9_6_4 1 +#define M9_6_5 2 +#define M9_6_6 3 +#define M9_6_7 4 + +#define M9_7_0 7 +#define M9_7_1 8 +#define M9_7_2 0 +#define M9_7_3 1 +#define M9_7_4 2 +#define M9_7_5 3 +#define M9_7_6 4 +#define M9_7_7 5 + +#define M9_8_0 8 +#define M9_8_1 0 +#define M9_8_2 1 +#define M9_8_3 2 +#define M9_8_4 3 +#define M9_8_5 4 +#define M9_8_6 5 +#define M9_8_7 6 + +#define M9_9_0 0 +#define M9_9_1 1 +#define M9_9_2 2 +#define M9_9_3 3 +#define M9_9_4 4 +#define M9_9_5 5 +#define M9_9_6 6 +#define M9_9_7 7 + +#define M9_10_0 1 +#define M9_10_1 2 +#define M9_10_2 3 +#define M9_10_3 4 +#define M9_10_4 5 +#define M9_10_5 6 +#define M9_10_6 7 +#define M9_10_7 8 + +#define M9_11_0 2 +#define M9_11_1 3 +#define M9_11_2 4 +#define M9_11_3 5 +#define M9_11_4 6 +#define M9_11_5 7 +#define M9_11_6 8 +#define M9_11_7 0 + +#define M9_12_0 3 +#define M9_12_1 4 +#define M9_12_2 5 +#define M9_12_3 6 +#define M9_12_4 7 +#define M9_12_5 8 +#define M9_12_6 0 +#define M9_12_7 1 + +#define M9_13_0 4 +#define M9_13_1 5 +#define M9_13_2 6 +#define M9_13_3 7 +#define M9_13_4 8 +#define M9_13_5 0 +#define M9_13_6 1 +#define M9_13_7 2 + +#define M9_14_0 5 +#define M9_14_1 6 +#define M9_14_2 7 +#define M9_14_3 8 +#define M9_14_4 0 +#define M9_14_5 1 +#define M9_14_6 2 +#define M9_14_7 3 + +#define M9_15_0 6 +#define M9_15_1 7 +#define M9_15_2 8 +#define M9_15_3 0 +#define M9_15_4 1 +#define M9_15_5 2 +#define M9_15_6 3 +#define M9_15_7 4 + +#define M9_16_0 7 +#define M9_16_1 8 +#define M9_16_2 0 +#define M9_16_3 1 +#define M9_16_4 2 +#define M9_16_5 3 +#define M9_16_6 4 +#define M9_16_7 5 + +#define M9_17_0 8 +#define M9_17_1 0 +#define M9_17_2 1 +#define M9_17_3 2 +#define M9_17_4 3 +#define M9_17_5 4 +#define M9_17_6 5 +#define M9_17_7 6 + +#define M9_18_0 0 +#define M9_18_1 1 +#define M9_18_2 2 +#define M9_18_3 3 +#define M9_18_4 4 +#define M9_18_5 5 +#define M9_18_6 6 +#define M9_18_7 7 + +/* + * M3_ ## s ## _ ## i evaluates to s+i mod 3 (0 <= s <= 18, 0 <= i <= 1). + */ + +#define M3_0_0 0 +#define M3_0_1 1 +#define M3_1_0 1 +#define M3_1_1 2 +#define M3_2_0 2 +#define M3_2_1 0 +#define M3_3_0 0 +#define M3_3_1 1 +#define M3_4_0 1 +#define M3_4_1 2 +#define M3_5_0 2 +#define M3_5_1 0 +#define M3_6_0 0 +#define M3_6_1 1 +#define M3_7_0 1 +#define M3_7_1 2 +#define M3_8_0 2 +#define M3_8_1 0 +#define M3_9_0 0 +#define M3_9_1 1 +#define M3_10_0 1 +#define M3_10_1 2 +#define M3_11_0 2 +#define M3_11_1 0 +#define M3_12_0 0 +#define M3_12_1 1 +#define M3_13_0 1 +#define M3_13_1 2 +#define M3_14_0 2 +#define M3_14_1 0 +#define M3_15_0 0 +#define M3_15_1 1 +#define M3_16_0 1 +#define M3_16_1 2 +#define M3_17_0 2 +#define M3_17_1 0 +#define M3_18_0 0 +#define M3_18_1 1 + +#define XCAT(x, y) XCAT_(x, y) +#define XCAT_(x, y) x ## y + +#if 0 +/* obsolete */ +#define SKSI(k, s, i) XCAT(k, XCAT(XCAT(XCAT(M5_, s), _), i)) +#define SKST(t, s, v) XCAT(t, XCAT(XCAT(XCAT(M3_, s), _), v)) +#endif + +#define SKBI(k, s, i) XCAT(k, XCAT(XCAT(XCAT(M9_, s), _), i)) +#define SKBT(t, s, v) XCAT(t, XCAT(XCAT(XCAT(M3_, s), _), v)) + +#if 0 +/* obsolete */ +#define TFSMALL_KINIT(k0, k1, k2, k3, k4, t0, t1, t2) do { \ + k4 = (k0 ^ k1) ^ (k2 ^ k3) ^ SPH_C64(0x1BD11BDAA9FC1A22); \ + t2 = t0 ^ t1; \ + } while (0) +#endif + +#define TFBIG_KINIT(k0, k1, k2, k3, k4, k5, k6, k7, k8, t0, t1, t2) do { \ + k8 = ((k0 ^ k1) ^ (k2 ^ k3)) ^ ((k4 ^ k5) ^ (k6 ^ k7)) \ + ^ SPH_C64(0x1BD11BDAA9FC1A22); \ + t2 = t0 ^ t1; \ + } while (0) + +#if 0 +/* obsolete */ +#define TFSMALL_ADDKEY(w0, w1, w2, w3, k, t, s) do { \ + w0 = SPH_T64(w0 + SKSI(k, s, 0)); \ + w1 = SPH_T64(w1 + SKSI(k, s, 1) + SKST(t, s, 0)); \ + w2 = SPH_T64(w2 + SKSI(k, s, 2) + SKST(t, s, 1)); \ + w3 = SPH_T64(w3 + SKSI(k, s, 3) + (sph_u64)s); \ + } while (0) +#endif + +#if SPH_SMALL_FOOTPRINT_SKEIN + +#define TFBIG_ADDKEY(s, tt0, tt1) do { \ + p0 = SPH_T64(p0 + h[s + 0]); \ + p1 = SPH_T64(p1 + h[s + 1]); \ + p2 = SPH_T64(p2 + h[s + 2]); \ + p3 = SPH_T64(p3 + h[s + 3]); \ + p4 = SPH_T64(p4 + h[s + 4]); \ + p5 = SPH_T64(p5 + h[s + 5] + tt0); \ + p6 = SPH_T64(p6 + h[s + 6] + tt1); \ + p7 = SPH_T64(p7 + h[s + 7] + (sph_u64)s); \ + } while (0) + +#else + +#define TFBIG_ADDKEY(w0, w1, w2, w3, w4, w5, w6, w7, k, t, s) do { \ + w0 = SPH_T64(w0 + SKBI(k, s, 0)); \ + w1 = SPH_T64(w1 + SKBI(k, s, 1)); \ + w2 = SPH_T64(w2 + SKBI(k, s, 2)); \ + w3 = SPH_T64(w3 + SKBI(k, s, 3)); \ + w4 = SPH_T64(w4 + SKBI(k, s, 4)); \ + w5 = SPH_T64(w5 + SKBI(k, s, 5) + SKBT(t, s, 0)); \ + w6 = SPH_T64(w6 + SKBI(k, s, 6) + SKBT(t, s, 1)); \ + w7 = SPH_T64(w7 + SKBI(k, s, 7) + (sph_u64)s); \ + } while (0) + +#endif + +#if 0 +/* obsolete */ +#define TFSMALL_MIX(x0, x1, rc) do { \ + x0 = SPH_T64(x0 + x1); \ + x1 = SPH_ROTL64(x1, rc) ^ x0; \ + } while (0) +#endif + +#define TFBIG_MIX(x0, x1, rc) do { \ + x0 = SPH_T64(x0 + x1); \ + x1 = SPH_ROTL64(x1, rc) ^ x0; \ + } while (0) + +#if 0 +/* obsolete */ +#define TFSMALL_MIX4(w0, w1, w2, w3, rc0, rc1) do { \ + TFSMALL_MIX(w0, w1, rc0); \ + TFSMALL_MIX(w2, w3, rc1); \ + } while (0) +#endif + +#define TFBIG_MIX8(w0, w1, w2, w3, w4, w5, w6, w7, rc0, rc1, rc2, rc3) do { \ + TFBIG_MIX(w0, w1, rc0); \ + TFBIG_MIX(w2, w3, rc1); \ + TFBIG_MIX(w4, w5, rc2); \ + TFBIG_MIX(w6, w7, rc3); \ + } while (0) + +#if 0 +/* obsolete */ +#define TFSMALL_4e(s) do { \ + TFSMALL_ADDKEY(p0, p1, p2, p3, h, t, s); \ + TFSMALL_MIX4(p0, p1, p2, p3, 14, 16); \ + TFSMALL_MIX4(p0, p3, p2, p1, 52, 57); \ + TFSMALL_MIX4(p0, p1, p2, p3, 23, 40); \ + TFSMALL_MIX4(p0, p3, p2, p1, 5, 37); \ + } while (0) + +#define TFSMALL_4o(s) do { \ + TFSMALL_ADDKEY(p0, p1, p2, p3, h, t, s); \ + TFSMALL_MIX4(p0, p1, p2, p3, 25, 33); \ + TFSMALL_MIX4(p0, p3, p2, p1, 46, 12); \ + TFSMALL_MIX4(p0, p1, p2, p3, 58, 22); \ + TFSMALL_MIX4(p0, p3, p2, p1, 32, 32); \ + } while (0) +#endif + +#if SPH_SMALL_FOOTPRINT_SKEIN + +#define TFBIG_4e(s) do { \ + TFBIG_ADDKEY(s, t0, t1); \ + TFBIG_MIX8(p0, p1, p2, p3, p4, p5, p6, p7, 46, 36, 19, 37); \ + TFBIG_MIX8(p2, p1, p4, p7, p6, p5, p0, p3, 33, 27, 14, 42); \ + TFBIG_MIX8(p4, p1, p6, p3, p0, p5, p2, p7, 17, 49, 36, 39); \ + TFBIG_MIX8(p6, p1, p0, p7, p2, p5, p4, p3, 44, 9, 54, 56); \ + } while (0) + +#define TFBIG_4o(s) do { \ + TFBIG_ADDKEY(s, t1, t2); \ + TFBIG_MIX8(p0, p1, p2, p3, p4, p5, p6, p7, 39, 30, 34, 24); \ + TFBIG_MIX8(p2, p1, p4, p7, p6, p5, p0, p3, 13, 50, 10, 17); \ + TFBIG_MIX8(p4, p1, p6, p3, p0, p5, p2, p7, 25, 29, 39, 43); \ + TFBIG_MIX8(p6, p1, p0, p7, p2, p5, p4, p3, 8, 35, 56, 22); \ + } while (0) + +#else + +#define TFBIG_4e(s) do { \ + TFBIG_ADDKEY(p0, p1, p2, p3, p4, p5, p6, p7, h, t, s); \ + TFBIG_MIX8(p0, p1, p2, p3, p4, p5, p6, p7, 46, 36, 19, 37); \ + TFBIG_MIX8(p2, p1, p4, p7, p6, p5, p0, p3, 33, 27, 14, 42); \ + TFBIG_MIX8(p4, p1, p6, p3, p0, p5, p2, p7, 17, 49, 36, 39); \ + TFBIG_MIX8(p6, p1, p0, p7, p2, p5, p4, p3, 44, 9, 54, 56); \ + } while (0) + +#define TFBIG_4o(s) do { \ + TFBIG_ADDKEY(p0, p1, p2, p3, p4, p5, p6, p7, h, t, s); \ + TFBIG_MIX8(p0, p1, p2, p3, p4, p5, p6, p7, 39, 30, 34, 24); \ + TFBIG_MIX8(p2, p1, p4, p7, p6, p5, p0, p3, 13, 50, 10, 17); \ + TFBIG_MIX8(p4, p1, p6, p3, p0, p5, p2, p7, 25, 29, 39, 43); \ + TFBIG_MIX8(p6, p1, p0, p7, p2, p5, p4, p3, 8, 35, 56, 22); \ + } while (0) + +#endif + +#if 0 +/* obsolete */ +#define UBI_SMALL(etype, extra) do { \ + sph_u64 h4, t0, t1, t2; \ + sph_u64 m0 = sph_dec64le(buf + 0); \ + sph_u64 m1 = sph_dec64le(buf + 8); \ + sph_u64 m2 = sph_dec64le(buf + 16); \ + sph_u64 m3 = sph_dec64le(buf + 24); \ + sph_u64 p0 = m0; \ + sph_u64 p1 = m1; \ + sph_u64 p2 = m2; \ + sph_u64 p3 = m3; \ + t0 = SPH_T64(bcount << 5) + (sph_u64)(extra); \ + t1 = (bcount >> 59) + ((sph_u64)(etype) << 55); \ + TFSMALL_KINIT(h0, h1, h2, h3, h4, t0, t1, t2); \ + TFSMALL_4e(0); \ + TFSMALL_4o(1); \ + TFSMALL_4e(2); \ + TFSMALL_4o(3); \ + TFSMALL_4e(4); \ + TFSMALL_4o(5); \ + TFSMALL_4e(6); \ + TFSMALL_4o(7); \ + TFSMALL_4e(8); \ + TFSMALL_4o(9); \ + TFSMALL_4e(10); \ + TFSMALL_4o(11); \ + TFSMALL_4e(12); \ + TFSMALL_4o(13); \ + TFSMALL_4e(14); \ + TFSMALL_4o(15); \ + TFSMALL_4e(16); \ + TFSMALL_4o(17); \ + TFSMALL_ADDKEY(p0, p1, p2, p3, h, t, 18); \ + h0 = m0 ^ p0; \ + h1 = m1 ^ p1; \ + h2 = m2 ^ p2; \ + h3 = m3 ^ p3; \ + } while (0) +#endif + +#if SPH_SMALL_FOOTPRINT_SKEIN + +#define UBI_BIG(etype, extra) do { \ + sph_u64 t0, t1, t2; \ + unsigned u; \ + sph_u64 m0 = sph_dec64le_aligned(buf + 0); \ + sph_u64 m1 = sph_dec64le_aligned(buf + 8); \ + sph_u64 m2 = sph_dec64le_aligned(buf + 16); \ + sph_u64 m3 = sph_dec64le_aligned(buf + 24); \ + sph_u64 m4 = sph_dec64le_aligned(buf + 32); \ + sph_u64 m5 = sph_dec64le_aligned(buf + 40); \ + sph_u64 m6 = sph_dec64le_aligned(buf + 48); \ + sph_u64 m7 = sph_dec64le_aligned(buf + 56); \ + sph_u64 p0 = m0; \ + sph_u64 p1 = m1; \ + sph_u64 p2 = m2; \ + sph_u64 p3 = m3; \ + sph_u64 p4 = m4; \ + sph_u64 p5 = m5; \ + sph_u64 p6 = m6; \ + sph_u64 p7 = m7; \ + t0 = SPH_T64(bcount << 6) + (sph_u64)(extra); \ + t1 = (bcount >> 58) + ((sph_u64)(etype) << 55); \ + TFBIG_KINIT(h[0], h[1], h[2], h[3], h[4], h[5], \ + h[6], h[7], h[8], t0, t1, t2); \ + for (u = 0; u <= 15; u += 3) { \ + h[u + 9] = h[u + 0]; \ + h[u + 10] = h[u + 1]; \ + h[u + 11] = h[u + 2]; \ + } \ + for (u = 0; u < 9; u ++) { \ + sph_u64 s = u << 1; \ + sph_u64 tmp; \ + TFBIG_4e(s); \ + TFBIG_4o(s + 1); \ + tmp = t2; \ + t2 = t1; \ + t1 = t0; \ + t0 = tmp; \ + } \ + TFBIG_ADDKEY(18, t0, t1); \ + h[0] = m0 ^ p0; \ + h[1] = m1 ^ p1; \ + h[2] = m2 ^ p2; \ + h[3] = m3 ^ p3; \ + h[4] = m4 ^ p4; \ + h[5] = m5 ^ p5; \ + h[6] = m6 ^ p6; \ + h[7] = m7 ^ p7; \ + } while (0) + +#else + +#define UBI_BIG(etype, extra) do { \ + sph_u64 h8, t0, t1, t2; \ + sph_u64 m0 = sph_dec64le_aligned(buf + 0); \ + sph_u64 m1 = sph_dec64le_aligned(buf + 8); \ + sph_u64 m2 = sph_dec64le_aligned(buf + 16); \ + sph_u64 m3 = sph_dec64le_aligned(buf + 24); \ + sph_u64 m4 = sph_dec64le_aligned(buf + 32); \ + sph_u64 m5 = sph_dec64le_aligned(buf + 40); \ + sph_u64 m6 = sph_dec64le_aligned(buf + 48); \ + sph_u64 m7 = sph_dec64le_aligned(buf + 56); \ + sph_u64 p0 = m0; \ + sph_u64 p1 = m1; \ + sph_u64 p2 = m2; \ + sph_u64 p3 = m3; \ + sph_u64 p4 = m4; \ + sph_u64 p5 = m5; \ + sph_u64 p6 = m6; \ + sph_u64 p7 = m7; \ + t0 = SPH_T64(bcount << 6) + (sph_u64)(extra); \ + t1 = (bcount >> 58) + ((sph_u64)(etype) << 55); \ + TFBIG_KINIT(h0, h1, h2, h3, h4, h5, h6, h7, h8, t0, t1, t2); \ + TFBIG_4e(0); \ + TFBIG_4o(1); \ + TFBIG_4e(2); \ + TFBIG_4o(3); \ + TFBIG_4e(4); \ + TFBIG_4o(5); \ + TFBIG_4e(6); \ + TFBIG_4o(7); \ + TFBIG_4e(8); \ + TFBIG_4o(9); \ + TFBIG_4e(10); \ + TFBIG_4o(11); \ + TFBIG_4e(12); \ + TFBIG_4o(13); \ + TFBIG_4e(14); \ + TFBIG_4o(15); \ + TFBIG_4e(16); \ + TFBIG_4o(17); \ + TFBIG_ADDKEY(p0, p1, p2, p3, p4, p5, p6, p7, h, t, 18); \ + h0 = m0 ^ p0; \ + h1 = m1 ^ p1; \ + h2 = m2 ^ p2; \ + h3 = m3 ^ p3; \ + h4 = m4 ^ p4; \ + h5 = m5 ^ p5; \ + h6 = m6 ^ p6; \ + h7 = m7 ^ p7; \ + } while (0) + +#endif + +#if 0 +/* obsolete */ +#define DECL_STATE_SMALL \ + sph_u64 h0, h1, h2, h3; \ + sph_u64 bcount; + +#define READ_STATE_SMALL(sc) do { \ + h0 = (sc)->h0; \ + h1 = (sc)->h1; \ + h2 = (sc)->h2; \ + h3 = (sc)->h3; \ + bcount = sc->bcount; \ + } while (0) + +#define WRITE_STATE_SMALL(sc) do { \ + (sc)->h0 = h0; \ + (sc)->h1 = h1; \ + (sc)->h2 = h2; \ + (sc)->h3 = h3; \ + sc->bcount = bcount; \ + } while (0) +#endif + +#if SPH_SMALL_FOOTPRINT_SKEIN + +#define DECL_STATE_BIG \ + sph_u64 h[27]; \ + sph_u64 bcount; + +#define READ_STATE_BIG(sc) do { \ + h[0] = (sc)->h0; \ + h[1] = (sc)->h1; \ + h[2] = (sc)->h2; \ + h[3] = (sc)->h3; \ + h[4] = (sc)->h4; \ + h[5] = (sc)->h5; \ + h[6] = (sc)->h6; \ + h[7] = (sc)->h7; \ + bcount = sc->bcount; \ + } while (0) + +#define WRITE_STATE_BIG(sc) do { \ + (sc)->h0 = h[0]; \ + (sc)->h1 = h[1]; \ + (sc)->h2 = h[2]; \ + (sc)->h3 = h[3]; \ + (sc)->h4 = h[4]; \ + (sc)->h5 = h[5]; \ + (sc)->h6 = h[6]; \ + (sc)->h7 = h[7]; \ + sc->bcount = bcount; \ + } while (0) + +#else + +#define DECL_STATE_BIG \ + sph_u64 h0, h1, h2, h3, h4, h5, h6, h7; \ + sph_u64 bcount; + +#define READ_STATE_BIG(sc) do { \ + h0 = (sc)->h0; \ + h1 = (sc)->h1; \ + h2 = (sc)->h2; \ + h3 = (sc)->h3; \ + h4 = (sc)->h4; \ + h5 = (sc)->h5; \ + h6 = (sc)->h6; \ + h7 = (sc)->h7; \ + bcount = sc->bcount; \ + } while (0) + +#define WRITE_STATE_BIG(sc) do { \ + (sc)->h0 = h0; \ + (sc)->h1 = h1; \ + (sc)->h2 = h2; \ + (sc)->h3 = h3; \ + (sc)->h4 = h4; \ + (sc)->h5 = h5; \ + (sc)->h6 = h6; \ + (sc)->h7 = h7; \ + sc->bcount = bcount; \ + } while (0) + +#endif + +#if 0 +/* obsolete */ +static void +skein_small_init(sph_skein_small_context *sc, const sph_u64 *iv) +{ + sc->h0 = iv[0]; + sc->h1 = iv[1]; + sc->h2 = iv[2]; + sc->h3 = iv[3]; + sc->bcount = 0; + sc->ptr = 0; +} +#endif + +static void +skein_big_init(sph_skein_big_context *sc, const sph_u64 *iv) +{ + sc->h0 = iv[0]; + sc->h1 = iv[1]; + sc->h2 = iv[2]; + sc->h3 = iv[3]; + sc->h4 = iv[4]; + sc->h5 = iv[5]; + sc->h6 = iv[6]; + sc->h7 = iv[7]; + sc->bcount = 0; + sc->ptr = 0; +} + +#if 0 +/* obsolete */ +static void +skein_small_core(sph_skein_small_context *sc, const void *data, size_t len) +{ + unsigned char *buf; + size_t ptr, clen; + unsigned first; + DECL_STATE_SMALL + + buf = sc->buf; + ptr = sc->ptr; + clen = (sizeof sc->buf) - ptr; + if (len <= clen) { + memcpy(buf + ptr, data, len); + sc->ptr = ptr + len; + return; + } + if (clen != 0) { + memcpy(buf + ptr, data, clen); + data = (const unsigned char *)data + clen; + len -= clen; + } + +#if SPH_SMALL_FOOTPRINT_SKEIN + + READ_STATE_SMALL(sc); + first = (bcount == 0) << 7; + for (;;) { + bcount ++; + UBI_SMALL(96 + first, 0); + if (len <= sizeof sc->buf) + break; + first = 0; + memcpy(buf, data, sizeof sc->buf); + data = (const unsigned char *)data + sizeof sc->buf; + len -= sizeof sc->buf; + } + WRITE_STATE_SMALL(sc); + sc->ptr = len; + memcpy(buf, data, len); + +#else + + /* + * Unrolling the loop yields a slight performance boost, while + * keeping the code size aorund 24 kB on 32-bit x86. + */ + READ_STATE_SMALL(sc); + first = (bcount == 0) << 7; + for (;;) { + bcount ++; + UBI_SMALL(96 + first, 0); + if (len <= sizeof sc->buf) + break; + buf = (unsigned char *)data; + bcount ++; + UBI_SMALL(96, 0); + if (len <= 2 * sizeof sc->buf) { + data = buf + sizeof sc->buf; + len -= sizeof sc->buf; + break; + } + buf += sizeof sc->buf; + data = buf + sizeof sc->buf; + first = 0; + len -= 2 * sizeof sc->buf; + } + WRITE_STATE_SMALL(sc); + sc->ptr = len; + memcpy(sc->buf, data, len); + +#endif +} +#endif + +static void +skein_big_core(sph_skein_big_context *sc, const void *data, size_t len) +{ + /* + * The Skein "final bit" in the tweak is troublesome here, + * because if the input has a length which is a multiple of the + * block size (512 bits) then that bit must be set for the + * final block, which is full of message bits (padding in + * Skein can be reduced to no extra bit at all). However, this + * function cannot know whether it processes the last chunks of + * the message or not. Hence we may keep a full block of buffered + * data (64 bytes). + */ + unsigned char *buf; + size_t ptr; + unsigned first; + DECL_STATE_BIG + + buf = sc->buf; + ptr = sc->ptr; + if (len <= (sizeof sc->buf) - ptr) { + memcpy(buf + ptr, data, len); + ptr += len; + sc->ptr = ptr; + return; + } + + READ_STATE_BIG(sc); + first = (bcount == 0) << 7; + do { + size_t clen; + + if (ptr == sizeof sc->buf) { + bcount ++; + UBI_BIG(96 + first, 0); + first = 0; + ptr = 0; + } + clen = (sizeof sc->buf) - ptr; + if (clen > len) + clen = len; + memcpy(buf + ptr, data, clen); + ptr += clen; + data = (const unsigned char *)data + clen; + len -= clen; + } while (len > 0); + WRITE_STATE_BIG(sc); + sc->ptr = ptr; +} + +#if 0 +/* obsolete */ +static void +skein_small_close(sph_skein_small_context *sc, unsigned ub, unsigned n, + void *dst, size_t out_len) +{ + unsigned char *buf; + size_t ptr; + unsigned et; + int i; + DECL_STATE_SMALL + + if (n != 0) { + unsigned z; + unsigned char x; + + z = 0x80 >> n; + x = ((ub & -z) | z) & 0xFF; + skein_small_core(sc, &x, 1); + } + + buf = sc->buf; + ptr = sc->ptr; + READ_STATE_SMALL(sc); + memset(buf + ptr, 0, (sizeof sc->buf) - ptr); + et = 352 + ((bcount == 0) << 7) + (n != 0); + for (i = 0; i < 2; i ++) { + UBI_SMALL(et, ptr); + if (i == 0) { + memset(buf, 0, sizeof sc->buf); + bcount = 0; + et = 510; + ptr = 8; + } + } + + sph_enc64le_aligned(buf + 0, h0); + sph_enc64le_aligned(buf + 8, h1); + sph_enc64le_aligned(buf + 16, h2); + sph_enc64le_aligned(buf + 24, h3); + memcpy(dst, buf, out_len); +} +#endif + +static void +skein_big_close(sph_skein_big_context *sc, unsigned ub, unsigned n, + void *dst, size_t out_len) +{ + unsigned char *buf; + size_t ptr; + unsigned et; + int i; +#if SPH_SMALL_FOOTPRINT_SKEIN + size_t u; +#endif + DECL_STATE_BIG + + /* + * Add bit padding if necessary. + */ + if (n != 0) { + unsigned z; + unsigned char x; + + z = 0x80 >> n; + x = ((ub & -z) | z) & 0xFF; + skein_big_core(sc, &x, 1); + } + + buf = sc->buf; + ptr = sc->ptr; + + /* + * At that point, if ptr == 0, then the message was empty; + * otherwise, there is between 1 and 64 bytes (inclusive) which + * are yet to be processed. Either way, we complete the buffer + * to a full block with zeros (the Skein specification mandates + * that an empty message is padded so that there is at least + * one block to process). + * + * Once this block has been processed, we do it again, with + * a block full of zeros, for the output (that block contains + * the encoding of "0", over 8 bytes, then padded with zeros). + */ + READ_STATE_BIG(sc); + memset(buf + ptr, 0, (sizeof sc->buf) - ptr); + et = 352 + ((bcount == 0) << 7) + (n != 0); + for (i = 0; i < 2; i ++) { + UBI_BIG(et, ptr); + if (i == 0) { + memset(buf, 0, sizeof sc->buf); + bcount = 0; + et = 510; + ptr = 8; + } + } + +#if SPH_SMALL_FOOTPRINT_SKEIN + + /* + * We use a temporary buffer because we must support the case + * where output size is not a multiple of 64 (namely, a 224-bit + * output). + */ + for (u = 0; u < out_len; u += 8) + sph_enc64le_aligned(buf + u, h[u >> 3]); + memcpy(dst, buf, out_len); + +#else + + sph_enc64le_aligned(buf + 0, h0); + sph_enc64le_aligned(buf + 8, h1); + sph_enc64le_aligned(buf + 16, h2); + sph_enc64le_aligned(buf + 24, h3); + sph_enc64le_aligned(buf + 32, h4); + sph_enc64le_aligned(buf + 40, h5); + sph_enc64le_aligned(buf + 48, h6); + sph_enc64le_aligned(buf + 56, h7); + memcpy(dst, buf, out_len); + +#endif +} + +#if 0 +/* obsolete */ +static const sph_u64 IV224[] = { + SPH_C64(0xC6098A8C9AE5EA0B), SPH_C64(0x876D568608C5191C), + SPH_C64(0x99CB88D7D7F53884), SPH_C64(0x384BDDB1AEDDB5DE) +}; + +static const sph_u64 IV256[] = { + SPH_C64(0xFC9DA860D048B449), SPH_C64(0x2FCA66479FA7D833), + SPH_C64(0xB33BC3896656840F), SPH_C64(0x6A54E920FDE8DA69) +}; +#endif + +static const sph_u64 IV224[] = { + SPH_C64(0xCCD0616248677224), SPH_C64(0xCBA65CF3A92339EF), + SPH_C64(0x8CCD69D652FF4B64), SPH_C64(0x398AED7B3AB890B4), + SPH_C64(0x0F59D1B1457D2BD0), SPH_C64(0x6776FE6575D4EB3D), + SPH_C64(0x99FBC70E997413E9), SPH_C64(0x9E2CFCCFE1C41EF7) +}; + +static const sph_u64 IV256[] = { + SPH_C64(0xCCD044A12FDB3E13), SPH_C64(0xE83590301A79A9EB), + SPH_C64(0x55AEA0614F816E6F), SPH_C64(0x2A2767A4AE9B94DB), + SPH_C64(0xEC06025E74DD7683), SPH_C64(0xE7A436CDC4746251), + SPH_C64(0xC36FBAF9393AD185), SPH_C64(0x3EEDBA1833EDFC13) +}; + +static const sph_u64 IV384[] = { + SPH_C64(0xA3F6C6BF3A75EF5F), SPH_C64(0xB0FEF9CCFD84FAA4), + SPH_C64(0x9D77DD663D770CFE), SPH_C64(0xD798CBF3B468FDDA), + SPH_C64(0x1BC4A6668A0E4465), SPH_C64(0x7ED7D434E5807407), + SPH_C64(0x548FC1ACD4EC44D6), SPH_C64(0x266E17546AA18FF8) +}; + +static const sph_u64 IV512[] = { + SPH_C64(0x4903ADFF749C51CE), SPH_C64(0x0D95DE399746DF03), + SPH_C64(0x8FD1934127C79BCE), SPH_C64(0x9A255629FF352CB1), + SPH_C64(0x5DB62599DF6CA7B0), SPH_C64(0xEABE394CA9D5C3F4), + SPH_C64(0x991112C71A75B523), SPH_C64(0xAE18A40B660FCC33) +}; + +#if 0 +/* obsolete */ +/* see sph_skein.h */ +void +sph_skein224_init(void *cc) +{ + skein_small_init(cc, IV224); +} + +/* see sph_skein.h */ +void +sph_skein224(void *cc, const void *data, size_t len) +{ + skein_small_core(cc, data, len); +} + +/* see sph_skein.h */ +void +sph_skein224_close(void *cc, void *dst) +{ + sph_skein224_addbits_and_close(cc, 0, 0, dst); +} + +/* see sph_skein.h */ +void +sph_skein224_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + skein_small_close(cc, ub, n, dst, 28); + sph_skein224_init(cc); +} + +/* see sph_skein.h */ +void +sph_skein256_init(void *cc) +{ + skein_small_init(cc, IV256); +} + +/* see sph_skein.h */ +void +sph_skein256(void *cc, const void *data, size_t len) +{ + skein_small_core(cc, data, len); +} + +/* see sph_skein.h */ +void +sph_skein256_close(void *cc, void *dst) +{ + sph_skein256_addbits_and_close(cc, 0, 0, dst); +} + +/* see sph_skein.h */ +void +sph_skein256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + skein_small_close(cc, ub, n, dst, 32); + sph_skein256_init(cc); +} +#endif + +/* see sph_skein.h */ +void +sph_skein224_init(void *cc) +{ + skein_big_init(cc, IV224); +} + +/* see sph_skein.h */ +void +sph_skein224(void *cc, const void *data, size_t len) +{ + skein_big_core(cc, data, len); +} + +/* see sph_skein.h */ +void +sph_skein224_close(void *cc, void *dst) +{ + sph_skein224_addbits_and_close(cc, 0, 0, dst); +} + +/* see sph_skein.h */ +void +sph_skein224_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + skein_big_close(cc, ub, n, dst, 28); + sph_skein224_init(cc); +} + +/* see sph_skein.h */ +void +sph_skein256_init(void *cc) +{ + skein_big_init(cc, IV256); +} + +/* see sph_skein.h */ +void +sph_skein256(void *cc, const void *data, size_t len) +{ + skein_big_core(cc, data, len); +} + +/* see sph_skein.h */ +void +sph_skein256_close(void *cc, void *dst) +{ + sph_skein256_addbits_and_close(cc, 0, 0, dst); +} + +/* see sph_skein.h */ +void +sph_skein256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + skein_big_close(cc, ub, n, dst, 32); + sph_skein256_init(cc); +} + +/* see sph_skein.h */ +void +sph_skein384_init(void *cc) +{ + skein_big_init(cc, IV384); +} + +/* see sph_skein.h */ +void +sph_skein384(void *cc, const void *data, size_t len) +{ + skein_big_core(cc, data, len); +} + +/* see sph_skein.h */ +void +sph_skein384_close(void *cc, void *dst) +{ + sph_skein384_addbits_and_close(cc, 0, 0, dst); +} + +/* see sph_skein.h */ +void +sph_skein384_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + skein_big_close(cc, ub, n, dst, 48); + sph_skein384_init(cc); +} + +/* see sph_skein.h */ +void +sph_skein512_init(void *cc) +{ + skein_big_init(cc, IV512); +} + +/* see sph_skein.h */ +void +sph_skein512(void *cc, const void *data, size_t len) +{ + skein_big_core(cc, data, len); +} + +/* see sph_skein.h */ +void +sph_skein512_close(void *cc, void *dst) +{ + sph_skein512_addbits_and_close(cc, 0, 0, dst); +} + +/* see sph_skein.h */ +void +sph_skein512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) +{ + skein_big_close(cc, ub, n, dst, 64); + sph_skein512_init(cc); +} + +#endif + + +#ifdef __cplusplus +} +#endif diff --git a/src/obj/skunkhash/skein.o b/src/obj/skunkhash/skein.o new file mode 100644 index 0000000..f2bfb86 Binary files /dev/null and b/src/obj/skunkhash/skein.o differ diff --git a/src/obj/skunkhash/sph_cubehash.h b/src/obj/skunkhash/sph_cubehash.h new file mode 100644 index 0000000..487a194 --- /dev/null +++ b/src/obj/skunkhash/sph_cubehash.h @@ -0,0 +1,292 @@ +/* $Id: sph_cubehash.h 180 2010-05-08 02:29:25Z tp $ */ +/** + * CubeHash interface. CubeHash is a family of functions which differ by + * their output size; this implementation defines CubeHash for output + * sizes 224, 256, 384 and 512 bits, with the "standard parameters" + * (CubeHash16/32 with the CubeHash specification notations). + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @file sph_cubehash.h + * @author Thomas Pornin + */ + +#ifndef SPH_CUBEHASH_H__ +#define SPH_CUBEHASH_H__ + +#ifdef __cplusplus +extern "C"{ +#endif + +#include +#include "sph_types.h" + +/** + * Output size (in bits) for CubeHash-224. + */ +#define SPH_SIZE_cubehash224 224 + +/** + * Output size (in bits) for CubeHash-256. + */ +#define SPH_SIZE_cubehash256 256 + +/** + * Output size (in bits) for CubeHash-384. + */ +#define SPH_SIZE_cubehash384 384 + +/** + * Output size (in bits) for CubeHash-512. + */ +#define SPH_SIZE_cubehash512 512 + +/** + * This structure is a context for CubeHash computations: it contains the + * intermediate values and some data from the last entered block. Once + * a CubeHash computation has been performed, the context can be reused for + * another computation. + * + * The contents of this structure are private. A running CubeHash computation + * can be cloned by copying the context (e.g. with a simple + * memcpy()). + */ +typedef struct { +#ifndef DOXYGEN_IGNORE + unsigned char buf[32]; /* first field, for alignment */ + size_t ptr; + sph_u32 state[32]; +#endif +} sph_cubehash_context; + +/** + * Type for a CubeHash-224 context (identical to the common context). + */ +typedef sph_cubehash_context sph_cubehash224_context; + +/** + * Type for a CubeHash-256 context (identical to the common context). + */ +typedef sph_cubehash_context sph_cubehash256_context; + +/** + * Type for a CubeHash-384 context (identical to the common context). + */ +typedef sph_cubehash_context sph_cubehash384_context; + +/** + * Type for a CubeHash-512 context (identical to the common context). + */ +typedef sph_cubehash_context sph_cubehash512_context; + +/** + * Initialize a CubeHash-224 context. This process performs no memory + * allocation. + * + * @param cc the CubeHash-224 context (pointer to a + * sph_cubehash224_context) + */ +void sph_cubehash224_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the CubeHash-224 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_cubehash224(void *cc, const void *data, size_t len); + +/** + * Terminate the current CubeHash-224 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (28 bytes). The context is automatically + * reinitialized. + * + * @param cc the CubeHash-224 context + * @param dst the destination buffer + */ +void sph_cubehash224_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (28 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the CubeHash-224 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_cubehash224_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +/** + * Initialize a CubeHash-256 context. This process performs no memory + * allocation. + * + * @param cc the CubeHash-256 context (pointer to a + * sph_cubehash256_context) + */ +void sph_cubehash256_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the CubeHash-256 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_cubehash256(void *cc, const void *data, size_t len); + +/** + * Terminate the current CubeHash-256 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (32 bytes). The context is automatically + * reinitialized. + * + * @param cc the CubeHash-256 context + * @param dst the destination buffer + */ +void sph_cubehash256_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (32 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the CubeHash-256 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_cubehash256_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +/** + * Initialize a CubeHash-384 context. This process performs no memory + * allocation. + * + * @param cc the CubeHash-384 context (pointer to a + * sph_cubehash384_context) + */ +void sph_cubehash384_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the CubeHash-384 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_cubehash384(void *cc, const void *data, size_t len); + +/** + * Terminate the current CubeHash-384 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (48 bytes). The context is automatically + * reinitialized. + * + * @param cc the CubeHash-384 context + * @param dst the destination buffer + */ +void sph_cubehash384_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (48 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the CubeHash-384 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_cubehash384_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +/** + * Initialize a CubeHash-512 context. This process performs no memory + * allocation. + * + * @param cc the CubeHash-512 context (pointer to a + * sph_cubehash512_context) + */ +void sph_cubehash512_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the CubeHash-512 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_cubehash512(void *cc, const void *data, size_t len); + +/** + * Terminate the current CubeHash-512 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (64 bytes). The context is automatically + * reinitialized. + * + * @param cc the CubeHash-512 context + * @param dst the destination buffer + */ +void sph_cubehash512_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (64 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the CubeHash-512 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_cubehash512_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/obj/skunkhash/sph_fugue.h b/src/obj/skunkhash/sph_fugue.h new file mode 100644 index 0000000..c8ff395 --- /dev/null +++ b/src/obj/skunkhash/sph_fugue.h @@ -0,0 +1,81 @@ +#ifndef SPH_FUGUE_H__ +#define SPH_FUGUE_H__ + +#include +#include "sph_types.h" + +#ifdef __cplusplus +extern "C"{ +#endif + +#define SPH_SIZE_fugue224 224 + +#define SPH_SIZE_fugue256 256 + +#define SPH_SIZE_fugue384 384 + +#define SPH_SIZE_fugue512 512 + +typedef struct { +#ifndef DOXYGEN_IGNORE + sph_u32 partial; + unsigned partial_len; + unsigned round_shift; + sph_u32 S[36]; +#if SPH_64 + sph_u64 bit_count; +#else + sph_u32 bit_count_high, bit_count_low; +#endif +#endif +} sph_fugue_context; + +typedef sph_fugue_context sph_fugue224_context; + +typedef sph_fugue_context sph_fugue256_context; + +typedef sph_fugue_context sph_fugue384_context; + +typedef sph_fugue_context sph_fugue512_context; + +void sph_fugue224_init(void *cc); + +void sph_fugue224(void *cc, const void *data, size_t len); + +void sph_fugue224_close(void *cc, void *dst); + +void sph_fugue224_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +void sph_fugue256_init(void *cc); + +void sph_fugue256(void *cc, const void *data, size_t len); + +void sph_fugue256_close(void *cc, void *dst); + +void sph_fugue256_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +void sph_fugue384_init(void *cc); + +void sph_fugue384(void *cc, const void *data, size_t len); + +void sph_fugue384_close(void *cc, void *dst); + +void sph_fugue384_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +void sph_fugue512_init(void *cc); + +void sph_fugue512(void *cc, const void *data, size_t len); + +void sph_fugue512_close(void *cc, void *dst); + +void sph_fugue512_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/obj/skunkhash/sph_gost.h b/src/obj/skunkhash/sph_gost.h new file mode 100644 index 0000000..c0a4ab7 --- /dev/null +++ b/src/obj/skunkhash/sph_gost.h @@ -0,0 +1,185 @@ +/* $Id: sph_gost.h 216 2010-06-08 09:46:57Z tp $ */ +/** + * GOST interface. This is the interface for GOST R 12 with the + * recommended parameters for SHA-3, with output lengths 256 + * and 512 bits. + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @file sph_gost.h + * @author ivan + */ + +#ifndef SPH_GOST_H__ +#define SPH_GOST_H__ + +#ifdef __cplusplus +extern "C"{ +#endif + +#include +#include "sph_types.h" + +/** + * Output size (in bits) for GOST-256. + */ +#define SPH_SIZE_gost256 256 + +/** + * Output size (in bits) for GOST-512. + */ +#define SPH_SIZE_gost512 512 + +/** + * This structure is a context for Keccak computations: it contains the + * intermediate values and some data from the last entered block. Once a + * GOST computation has been performed, the context can be reused for + * another computation. + * + * The contents of this structure are private. A running GOST computation + * can be cloned by copying the context (e.g. with a simple + * memcpy()). + */ + +/** + * This structure is a context for Gost-256 computations. + */ + +typedef struct { +#ifndef DOXYGEN_IGNORE + unsigned char buf[32]; /* first field, for alignment */ + size_t ptr; + sph_u32 V[3][8]; +#endif +} sph_gost256_context; + +/** + * This structure is a context for Gost-512 computations. + */ +typedef struct { +#ifndef DOXYGEN_IGNORE + unsigned char buf[64]; /* first field, for alignment */ + size_t ptr; + sph_u32 V[5][8]; +#endif +} sph_gost512_context; + + +/** + * Initialize a GOST-256 context. This process performs no memory allocation. + * + * @param cc the GOST-256 context (pointer to a + * sph_gost256_context) + */ +void sph_gost256_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the Gost-256 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_gost256(void *cc, const void *data, size_t len); + +/** + * Terminate the current GOST-256 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (32 bytes). The context is automatically + * reinitialized. + * + * @param cc the GOST-256 context + * @param dst the destination buffer + */ +void sph_gost256_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (32 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the GOST-256 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_gost256_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +/** + * Initialize a Gost-512 context. This process performs no memory allocation. + * + * @param cc the GOST-512 context (pointer to a + * sph_gost512_context) + */ +void sph_gost512_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the GOST-512 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_gost512(void *cc, const void *data, size_t len); + +/** + * Terminate the current GOST-512 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (64 bytes). The context is automatically + * reinitialized. + * + * @param cc the GOST-512 context + * @param dst the destination buffer + */ +void sph_gost512_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (64 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the GOST-512 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_gost512_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/obj/skunkhash/sph_hamsi.h b/src/obj/skunkhash/sph_hamsi.h new file mode 100644 index 0000000..56314de --- /dev/null +++ b/src/obj/skunkhash/sph_hamsi.h @@ -0,0 +1,321 @@ +/* $Id: sph_hamsi.h 216 2010-06-08 09:46:57Z tp $ */ +/** + * Hamsi interface. This code implements Hamsi with the recommended + * parameters for SHA-3, with outputs of 224, 256, 384 and 512 bits. + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @file sph_hamsi.h + * @author Thomas Pornin + */ + +#ifndef SPH_HAMSI_H__ +#define SPH_HAMSI_H__ + +#include +#include "sph_types.h" + +#ifdef __cplusplus +extern "C"{ +#endif + +/** + * Output size (in bits) for Hamsi-224. + */ +#define SPH_SIZE_hamsi224 224 + +/** + * Output size (in bits) for Hamsi-256. + */ +#define SPH_SIZE_hamsi256 256 + +/** + * Output size (in bits) for Hamsi-384. + */ +#define SPH_SIZE_hamsi384 384 + +/** + * Output size (in bits) for Hamsi-512. + */ +#define SPH_SIZE_hamsi512 512 + +/** + * This structure is a context for Hamsi-224 and Hamsi-256 computations: + * it contains the intermediate values and some data from the last + * entered block. Once a Hamsi computation has been performed, the + * context can be reused for another computation. + * + * The contents of this structure are private. A running Hamsi + * computation can be cloned by copying the context (e.g. with a simple + * memcpy()). + */ +typedef struct { +#ifndef DOXYGEN_IGNORE + unsigned char partial[4]; + size_t partial_len; + sph_u32 h[8]; +#if SPH_64 + sph_u64 count; +#else + sph_u32 count_high, count_low; +#endif +#endif +} sph_hamsi_small_context; + +/** + * This structure is a context for Hamsi-224 computations. It is + * identical to the common sph_hamsi_small_context. + */ +typedef sph_hamsi_small_context sph_hamsi224_context; + +/** + * This structure is a context for Hamsi-256 computations. It is + * identical to the common sph_hamsi_small_context. + */ +typedef sph_hamsi_small_context sph_hamsi256_context; + +/** + * This structure is a context for Hamsi-384 and Hamsi-512 computations: + * it contains the intermediate values and some data from the last + * entered block. Once a Hamsi computation has been performed, the + * context can be reused for another computation. + * + * The contents of this structure are private. A running Hamsi + * computation can be cloned by copying the context (e.g. with a simple + * memcpy()). + */ +typedef struct { +#ifndef DOXYGEN_IGNORE + unsigned char partial[8]; + size_t partial_len; + sph_u32 h[16]; +#if SPH_64 + sph_u64 count; +#else + sph_u32 count_high, count_low; +#endif +#endif +} sph_hamsi_big_context; + +/** + * This structure is a context for Hamsi-384 computations. It is + * identical to the common sph_hamsi_small_context. + */ +typedef sph_hamsi_big_context sph_hamsi384_context; + +/** + * This structure is a context for Hamsi-512 computations. It is + * identical to the common sph_hamsi_small_context. + */ +typedef sph_hamsi_big_context sph_hamsi512_context; + +/** + * Initialize a Hamsi-224 context. This process performs no memory allocation. + * + * @param cc the Hamsi-224 context (pointer to a + * sph_hamsi224_context) + */ +void sph_hamsi224_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the Hamsi-224 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_hamsi224(void *cc, const void *data, size_t len); + +/** + * Terminate the current Hamsi-224 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (28 bytes). The context is automatically + * reinitialized. + * + * @param cc the Hamsi-224 context + * @param dst the destination buffer + */ +void sph_hamsi224_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (28 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the Hamsi-224 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_hamsi224_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +/** + * Initialize a Hamsi-256 context. This process performs no memory allocation. + * + * @param cc the Hamsi-256 context (pointer to a + * sph_hamsi256_context) + */ +void sph_hamsi256_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the Hamsi-256 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_hamsi256(void *cc, const void *data, size_t len); + +/** + * Terminate the current Hamsi-256 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (32 bytes). The context is automatically + * reinitialized. + * + * @param cc the Hamsi-256 context + * @param dst the destination buffer + */ +void sph_hamsi256_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (32 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the Hamsi-256 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_hamsi256_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +/** + * Initialize a Hamsi-384 context. This process performs no memory allocation. + * + * @param cc the Hamsi-384 context (pointer to a + * sph_hamsi384_context) + */ +void sph_hamsi384_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the Hamsi-384 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_hamsi384(void *cc, const void *data, size_t len); + +/** + * Terminate the current Hamsi-384 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (48 bytes). The context is automatically + * reinitialized. + * + * @param cc the Hamsi-384 context + * @param dst the destination buffer + */ +void sph_hamsi384_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (48 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the Hamsi-384 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_hamsi384_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +/** + * Initialize a Hamsi-512 context. This process performs no memory allocation. + * + * @param cc the Hamsi-512 context (pointer to a + * sph_hamsi512_context) + */ +void sph_hamsi512_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the Hamsi-512 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_hamsi512(void *cc, const void *data, size_t len); + +/** + * Terminate the current Hamsi-512 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (64 bytes). The context is automatically + * reinitialized. + * + * @param cc the Hamsi-512 context + * @param dst the destination buffer + */ +void sph_hamsi512_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (64 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the Hamsi-512 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_hamsi512_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + + + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/src/obj/skunkhash/sph_skein.h b/src/obj/skunkhash/sph_skein.h new file mode 100644 index 0000000..bddbc86 --- /dev/null +++ b/src/obj/skunkhash/sph_skein.h @@ -0,0 +1,298 @@ +/* $Id: sph_skein.h 253 2011-06-07 18:33:10Z tp $ */ +/** + * Skein interface. The Skein specification defines three main + * functions, called Skein-256, Skein-512 and Skein-1024, which can be + * further parameterized with an output length. For the SHA-3 + * competition, Skein-512 is used for output sizes of 224, 256, 384 and + * 512 bits; this is what this code implements. Thus, we hereafter call + * Skein-224, Skein-256, Skein-384 and Skein-512 what the Skein + * specification defines as Skein-512-224, Skein-512-256, Skein-512-384 + * and Skein-512-512, respectively. + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @file sph_skein.h + * @author Thomas Pornin + */ + +#ifndef SPH_SKEIN_H__ +#define SPH_SKEIN_H__ + +#ifdef __cplusplus +extern "C"{ +#endif + +#include +#include "sph_types.h" + +#if SPH_64 + +/** + * Output size (in bits) for Skein-224. + */ +#define SPH_SIZE_skein224 224 + +/** + * Output size (in bits) for Skein-256. + */ +#define SPH_SIZE_skein256 256 + +/** + * Output size (in bits) for Skein-384. + */ +#define SPH_SIZE_skein384 384 + +/** + * Output size (in bits) for Skein-512. + */ +#define SPH_SIZE_skein512 512 + +/** + * This structure is a context for Skein computations (with a 384- or + * 512-bit output): it contains the intermediate values and some data + * from the last entered block. Once a Skein computation has been + * performed, the context can be reused for another computation. + * + * The contents of this structure are private. A running Skein computation + * can be cloned by copying the context (e.g. with a simple + * memcpy()). + */ +typedef struct { +#ifndef DOXYGEN_IGNORE + unsigned char buf[64]; /* first field, for alignment */ + size_t ptr; + sph_u64 h0, h1, h2, h3, h4, h5, h6, h7; + sph_u64 bcount; +#endif +} sph_skein_big_context; + +/** + * Type for a Skein-224 context (identical to the common "big" context). + */ +typedef sph_skein_big_context sph_skein224_context; + +/** + * Type for a Skein-256 context (identical to the common "big" context). + */ +typedef sph_skein_big_context sph_skein256_context; + +/** + * Type for a Skein-384 context (identical to the common "big" context). + */ +typedef sph_skein_big_context sph_skein384_context; + +/** + * Type for a Skein-512 context (identical to the common "big" context). + */ +typedef sph_skein_big_context sph_skein512_context; + +/** + * Initialize a Skein-224 context. This process performs no memory allocation. + * + * @param cc the Skein-224 context (pointer to a + * sph_skein224_context) + */ +void sph_skein224_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the Skein-224 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_skein224(void *cc, const void *data, size_t len); + +/** + * Terminate the current Skein-224 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (28 bytes). The context is automatically + * reinitialized. + * + * @param cc the Skein-224 context + * @param dst the destination buffer + */ +void sph_skein224_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (28 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the Skein-224 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_skein224_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +/** + * Initialize a Skein-256 context. This process performs no memory allocation. + * + * @param cc the Skein-256 context (pointer to a + * sph_skein256_context) + */ +void sph_skein256_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the Skein-256 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_skein256(void *cc, const void *data, size_t len); + +/** + * Terminate the current Skein-256 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (32 bytes). The context is automatically + * reinitialized. + * + * @param cc the Skein-256 context + * @param dst the destination buffer + */ +void sph_skein256_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (32 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the Skein-256 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_skein256_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +/** + * Initialize a Skein-384 context. This process performs no memory allocation. + * + * @param cc the Skein-384 context (pointer to a + * sph_skein384_context) + */ +void sph_skein384_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the Skein-384 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_skein384(void *cc, const void *data, size_t len); + +/** + * Terminate the current Skein-384 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (48 bytes). The context is automatically + * reinitialized. + * + * @param cc the Skein-384 context + * @param dst the destination buffer + */ +void sph_skein384_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (48 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the Skein-384 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_skein384_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +/** + * Initialize a Skein-512 context. This process performs no memory allocation. + * + * @param cc the Skein-512 context (pointer to a + * sph_skein512_context) + */ +void sph_skein512_init(void *cc); + +/** + * Process some data bytes. It is acceptable that len is zero + * (in which case this function does nothing). + * + * @param cc the Skein-512 context + * @param data the input data + * @param len the input data length (in bytes) + */ +void sph_skein512(void *cc, const void *data, size_t len); + +/** + * Terminate the current Skein-512 computation and output the result into + * the provided buffer. The destination buffer must be wide enough to + * accomodate the result (64 bytes). The context is automatically + * reinitialized. + * + * @param cc the Skein-512 context + * @param dst the destination buffer + */ +void sph_skein512_close(void *cc, void *dst); + +/** + * Add a few additional bits (0 to 7) to the current computation, then + * terminate it and output the result in the provided buffer, which must + * be wide enough to accomodate the result (64 bytes). If bit number i + * in ub has value 2^i, then the extra bits are those + * numbered 7 downto 8-n (this is the big-endian convention at the byte + * level). The context is automatically reinitialized. + * + * @param cc the Skein-512 context + * @param ub the extra bits + * @param n the number of extra bits (0 to 7) + * @param dst the destination buffer + */ +void sph_skein512_addbits_and_close( + void *cc, unsigned ub, unsigned n, void *dst); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/obj/skunkhash/sph_types.h b/src/obj/skunkhash/sph_types.h new file mode 100644 index 0000000..7295b0b --- /dev/null +++ b/src/obj/skunkhash/sph_types.h @@ -0,0 +1,1976 @@ +/* $Id: sph_types.h 260 2011-07-21 01:02:38Z tp $ */ +/** + * Basic type definitions. + * + * This header file defines the generic integer types that will be used + * for the implementation of hash functions; it also contains helper + * functions which encode and decode multi-byte integer values, using + * either little-endian or big-endian conventions. + * + * This file contains a compile-time test on the size of a byte + * (the unsigned char C type). If bytes are not octets, + * i.e. if they do not have a size of exactly 8 bits, then compilation + * is aborted. Architectures where bytes are not octets are relatively + * rare, even in the embedded devices market. We forbid non-octet bytes + * because there is no clear convention on how octet streams are encoded + * on such systems. + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @file sph_types.h + * @author Thomas Pornin + */ + +#ifndef SPH_TYPES_H__ +#define SPH_TYPES_H__ + +#include + +/* + * All our I/O functions are defined over octet streams. We do not know + * how to handle input data if bytes are not octets. + */ +#if CHAR_BIT != 8 +#error This code requires 8-bit bytes +#endif + +/* ============= BEGIN documentation block for Doxygen ============ */ + +#ifdef DOXYGEN_IGNORE + +/** @mainpage sphlib C code documentation + * + * @section overview Overview + * + * sphlib is a library which contains implementations of + * various cryptographic hash functions. These pages have been generated + * with doxygen and + * document the API for the C implementations. + * + * The API is described in appropriate header files, which are available + * in the "Files" section. Each hash function family has its own header, + * whose name begins with "sph_" and contains the family + * name. For instance, the API for the RIPEMD hash functions is available + * in the header file sph_ripemd.h. + * + * @section principles API structure and conventions + * + * @subsection io Input/output conventions + * + * In all generality, hash functions operate over strings of bits. + * Individual bits are rarely encountered in C programming or actual + * communication protocols; most protocols converge on the ubiquitous + * "octet" which is a group of eight bits. Data is thus expressed as a + * stream of octets. The C programming language contains the notion of a + * "byte", which is a data unit managed under the type "unsigned + * char". The C standard prescribes that a byte should hold at + * least eight bits, but possibly more. Most modern architectures, even + * in the embedded world, feature eight-bit bytes, i.e. map bytes to + * octets. + * + * Nevertheless, for some of the implemented hash functions, an extra + * API has been added, which allows the input of arbitrary sequences of + * bits: when the computation is about to be closed, 1 to 7 extra bits + * can be added. The functions for which this API is implemented include + * the SHA-2 functions and all SHA-3 candidates. + * + * sphlib defines hash function which may hash octet streams, + * i.e. streams of bits where the number of bits is a multiple of eight. + * The data input functions in the sphlib API expect data + * as anonymous pointers ("const void *") with a length + * (of type "size_t") which gives the input data chunk length + * in bytes. A byte is assumed to be an octet; the sph_types.h + * header contains a compile-time test which prevents compilation on + * architectures where this property is not met. + * + * The hash function output is also converted into bytes. All currently + * implemented hash functions have an output width which is a multiple of + * eight, and this is likely to remain true for new designs. + * + * Most hash functions internally convert input data into 32-bit of 64-bit + * words, using either little-endian or big-endian conversion. The hash + * output also often consists of such words, which are encoded into output + * bytes with a similar endianness convention. Some hash functions have + * been only loosely specified on that subject; when necessary, + * sphlib has been tested against published "reference" + * implementations in order to use the same conventions. + * + * @subsection shortname Function short name + * + * Each implemented hash function has a "short name" which is used + * internally to derive the identifiers for the functions and context + * structures which the function uses. For instance, MD5 has the short + * name "md5". Short names are listed in the next section, + * for the implemented hash functions. In subsequent sections, the + * short name will be assumed to be "XXX": replace with the + * actual hash function name to get the C identifier. + * + * Note: some functions within the same family share the same core + * elements, such as update function or context structure. Correspondingly, + * some of the defined types or functions may actually be macros which + * transparently evaluate to another type or function name. + * + * @subsection context Context structure + * + * Each implemented hash fonction has its own context structure, available + * under the type name "sph_XXX_context" for the hash function + * with short name "XXX". This structure holds all needed + * state for a running hash computation. + * + * The contents of these structures are meant to be opaque, and private + * to the implementation. However, these contents are specified in the + * header files so that application code which uses sphlib + * may access the size of those structures. + * + * The caller is responsible for allocating the context structure, + * whether by dynamic allocation (malloc() or equivalent), + * static allocation (a global permanent variable), as an automatic + * variable ("on the stack"), or by any other mean which ensures proper + * structure alignment. sphlib code performs no dynamic + * allocation by itself. + * + * The context must be initialized before use, using the + * sph_XXX_init() function. This function sets the context + * state to proper initial values for hashing. + * + * Since all state data is contained within the context structure, + * sphlib is thread-safe and reentrant: several hash + * computations may be performed in parallel, provided that they do not + * operate on the same context. Moreover, a running computation can be + * cloned by copying the context (with a simple memcpy()): + * the context and its clone are then independant and may be updated + * with new data and/or closed without interfering with each other. + * Similarly, a context structure can be moved in memory at will: + * context structures contain no pointer, in particular no pointer to + * themselves. + * + * @subsection dataio Data input + * + * Hashed data is input with the sph_XXX() fonction, which + * takes as parameters a pointer to the context, a pointer to the data + * to hash, and the number of data bytes to hash. The context is updated + * with the new data. + * + * Data can be input in one or several calls, with arbitrary input lengths. + * However, it is best, performance wise, to input data by relatively big + * chunks (say a few kilobytes), because this allows sphlib to + * optimize things and avoid internal copying. + * + * When all data has been input, the context can be closed with + * sph_XXX_close(). The hash output is computed and written + * into the provided buffer. The caller must take care to provide a + * buffer of appropriate length; e.g., when using SHA-1, the output is + * a 20-byte word, therefore the output buffer must be at least 20-byte + * long. + * + * For some hash functions, the sph_XXX_addbits_and_close() + * function can be used instead of sph_XXX_close(). This + * function can take a few extra bits to be added at + * the end of the input message. This allows hashing messages with a + * bit length which is not a multiple of 8. The extra bits are provided + * as an unsigned integer value, and a bit count. The bit count must be + * between 0 and 7, inclusive. The extra bits are provided as bits 7 to + * 0 (bits of numerical value 128, 64, 32... downto 0), in that order. + * For instance, to add three bits of value 1, 1 and 0, the unsigned + * integer will have value 192 (1*128 + 1*64 + 0*32) and the bit count + * will be 3. + * + * The SPH_SIZE_XXX macro is defined for each hash function; + * it evaluates to the function output size, expressed in bits. For instance, + * SPH_SIZE_sha1 evaluates to 160. + * + * When closed, the context is automatically reinitialized and can be + * immediately used for another computation. It is not necessary to call + * sph_XXX_init() after a close. Note that + * sph_XXX_init() can still be called to "reset" a context, + * i.e. forget previously input data, and get back to the initial state. + * + * @subsection alignment Data alignment + * + * "Alignment" is a property of data, which is said to be "properly + * aligned" when its emplacement in memory is such that the data can + * be optimally read by full words. This depends on the type of access; + * basically, some hash functions will read data by 32-bit or 64-bit + * words. sphlib does not mandate such alignment for input + * data, but using aligned data can substantially improve performance. + * + * As a rule, it is best to input data by chunks whose length (in bytes) + * is a multiple of eight, and which begins at "generally aligned" + * addresses, such as the base address returned by a call to + * malloc(). + * + * @section functions Implemented functions + * + * We give here the list of implemented functions. They are grouped by + * family; to each family corresponds a specific header file. Each + * individual function has its associated "short name". Please refer to + * the documentation for that header file to get details on the hash + * function denomination and provenance. + * + * Note: the functions marked with a '(64)' in the list below are + * available only if the C compiler provides an integer type of length + * 64 bits or more. Such a type is mandatory in the latest C standard + * (ISO 9899:1999, aka "C99") and is present in several older compilers + * as well, so chances are that such a type is available. + * + * - HAVAL family: file sph_haval.h + * - HAVAL-128/3 (128-bit, 3 passes): short name: haval128_3 + * - HAVAL-128/4 (128-bit, 4 passes): short name: haval128_4 + * - HAVAL-128/5 (128-bit, 5 passes): short name: haval128_5 + * - HAVAL-160/3 (160-bit, 3 passes): short name: haval160_3 + * - HAVAL-160/4 (160-bit, 4 passes): short name: haval160_4 + * - HAVAL-160/5 (160-bit, 5 passes): short name: haval160_5 + * - HAVAL-192/3 (192-bit, 3 passes): short name: haval192_3 + * - HAVAL-192/4 (192-bit, 4 passes): short name: haval192_4 + * - HAVAL-192/5 (192-bit, 5 passes): short name: haval192_5 + * - HAVAL-224/3 (224-bit, 3 passes): short name: haval224_3 + * - HAVAL-224/4 (224-bit, 4 passes): short name: haval224_4 + * - HAVAL-224/5 (224-bit, 5 passes): short name: haval224_5 + * - HAVAL-256/3 (256-bit, 3 passes): short name: haval256_3 + * - HAVAL-256/4 (256-bit, 4 passes): short name: haval256_4 + * - HAVAL-256/5 (256-bit, 5 passes): short name: haval256_5 + * - MD2: file sph_md2.h, short name: md2 + * - MD4: file sph_md4.h, short name: md4 + * - MD5: file sph_md5.h, short name: md5 + * - PANAMA: file sph_panama.h, short name: panama + * - RadioGatun family: file sph_radiogatun.h + * - RadioGatun[32]: short name: radiogatun32 + * - RadioGatun[64]: short name: radiogatun64 (64) + * - RIPEMD family: file sph_ripemd.h + * - RIPEMD: short name: ripemd + * - RIPEMD-128: short name: ripemd128 + * - RIPEMD-160: short name: ripemd160 + * - SHA-0: file sph_sha0.h, short name: sha0 + * - SHA-1: file sph_sha1.h, short name: sha1 + * - SHA-2 family, 32-bit hashes: file sph_sha2.h + * - SHA-224: short name: sha224 + * - SHA-256: short name: sha256 + * - SHA-384: short name: sha384 (64) + * - SHA-512: short name: sha512 (64) + * - Tiger family: file sph_tiger.h + * - Tiger: short name: tiger (64) + * - Tiger2: short name: tiger2 (64) + * - WHIRLPOOL family: file sph_whirlpool.h + * - WHIRLPOOL-0: short name: whirlpool0 (64) + * - WHIRLPOOL-1: short name: whirlpool1 (64) + * - WHIRLPOOL: short name: whirlpool (64) + * + * The fourteen second-round SHA-3 candidates are also implemented; + * when applicable, the implementations follow the "final" specifications + * as published for the third round of the SHA-3 competition (BLAKE, + * Groestl, JH, Keccak and Skein have been tweaked for third round). + * + * - BLAKE family: file sph_blake.h + * - BLAKE-224: short name: blake224 + * - BLAKE-256: short name: blake256 + * - BLAKE-384: short name: blake384 + * - BLAKE-512: short name: blake512 + * - BMW (Blue Midnight Wish) family: file sph_bmw.h + * - BMW-224: short name: bmw224 + * - BMW-256: short name: bmw256 + * - BMW-384: short name: bmw384 (64) + * - BMW-512: short name: bmw512 (64) + * - CubeHash family: file sph_cubehash.h (specified as + * CubeHash16/32 in the CubeHash specification) + * - CubeHash-224: short name: cubehash224 + * - CubeHash-256: short name: cubehash256 + * - CubeHash-384: short name: cubehash384 + * - CubeHash-512: short name: cubehash512 + * - ECHO family: file sph_echo.h + * - ECHO-224: short name: echo224 + * - ECHO-256: short name: echo256 + * - ECHO-384: short name: echo384 + * - ECHO-512: short name: echo512 + * - Fugue family: file sph_fugue.h + * - Fugue-224: short name: fugue224 + * - Fugue-256: short name: fugue256 + * - Fugue-384: short name: fugue384 + * - Fugue-512: short name: fugue512 + * - Groestl family: file sph_groestl.h + * - Groestl-224: short name: groestl224 + * - Groestl-256: short name: groestl256 + * - Groestl-384: short name: groestl384 + * - Groestl-512: short name: groestl512 + * - Hamsi family: file sph_hamsi.h + * - Hamsi-224: short name: hamsi224 + * - Hamsi-256: short name: hamsi256 + * - Hamsi-384: short name: hamsi384 + * - Hamsi-512: short name: hamsi512 + * - JH family: file sph_jh.h + * - JH-224: short name: jh224 + * - JH-256: short name: jh256 + * - JH-384: short name: jh384 + * - JH-512: short name: jh512 + * - Keccak family: file sph_keccak.h + * - Keccak-224: short name: keccak224 + * - Keccak-256: short name: keccak256 + * - Keccak-384: short name: keccak384 + * - Keccak-512: short name: keccak512 + * - Luffa family: file sph_luffa.h + * - Luffa-224: short name: luffa224 + * - Luffa-256: short name: luffa256 + * - Luffa-384: short name: luffa384 + * - Luffa-512: short name: luffa512 + * - Shabal family: file sph_shabal.h + * - Shabal-192: short name: shabal192 + * - Shabal-224: short name: shabal224 + * - Shabal-256: short name: shabal256 + * - Shabal-384: short name: shabal384 + * - Shabal-512: short name: shabal512 + * - SHAvite-3 family: file sph_shavite.h + * - SHAvite-224 (nominally "SHAvite-3 with 224-bit output"): + * short name: shabal224 + * - SHAvite-256 (nominally "SHAvite-3 with 256-bit output"): + * short name: shabal256 + * - SHAvite-384 (nominally "SHAvite-3 with 384-bit output"): + * short name: shabal384 + * - SHAvite-512 (nominally "SHAvite-3 with 512-bit output"): + * short name: shabal512 + * - SIMD family: file sph_simd.h + * - SIMD-224: short name: simd224 + * - SIMD-256: short name: simd256 + * - SIMD-384: short name: simd384 + * - SIMD-512: short name: simd512 + * - Skein family: file sph_skein.h + * - Skein-224 (nominally specified as Skein-512-224): short name: + * skein224 (64) + * - Skein-256 (nominally specified as Skein-512-256): short name: + * skein256 (64) + * - Skein-384 (nominally specified as Skein-512-384): short name: + * skein384 (64) + * - Skein-512 (nominally specified as Skein-512-512): short name: + * skein512 (64) + * + * For the second-round SHA-3 candidates, the functions are as specified + * for round 2, i.e. with the "tweaks" that some candidates added + * between round 1 and round 2. Also, some of the submitted packages for + * round 2 contained errors, in the specification, reference code, or + * both. sphlib implements the corrected versions. + */ + +/** @hideinitializer + * Unsigned integer type whose length is at least 32 bits; on most + * architectures, it will have a width of exactly 32 bits. Unsigned C + * types implement arithmetics modulo a power of 2; use the + * SPH_T32() macro to ensure that the value is truncated + * to exactly 32 bits. Unless otherwise specified, all macros and + * functions which accept sph_u32 values assume that these + * values fit on 32 bits, i.e. do not exceed 2^32-1, even on architectures + * where sph_u32 is larger than that. + */ +typedef __arch_dependant__ sph_u32; + +/** @hideinitializer + * Signed integer type corresponding to sph_u32; it has + * width 32 bits or more. + */ +typedef __arch_dependant__ sph_s32; + +/** @hideinitializer + * Unsigned integer type whose length is at least 64 bits; on most + * architectures which feature such a type, it will have a width of + * exactly 64 bits. C99-compliant platform will have this type; it + * is also defined when the GNU compiler (gcc) is used, and on + * platforms where unsigned long is large enough. If this + * type is not available, then some hash functions which depends on + * a 64-bit type will not be available (most notably SHA-384, SHA-512, + * Tiger and WHIRLPOOL). + */ +typedef __arch_dependant__ sph_u64; + +/** @hideinitializer + * Signed integer type corresponding to sph_u64; it has + * width 64 bits or more. + */ +typedef __arch_dependant__ sph_s64; + +/** + * This macro expands the token x into a suitable + * constant expression of type sph_u32. Depending on + * how this type is defined, a suffix such as UL may + * be appended to the argument. + * + * @param x the token to expand into a suitable constant expression + */ +#define SPH_C32(x) + +/** + * Truncate a 32-bit value to exactly 32 bits. On most systems, this is + * a no-op, recognized as such by the compiler. + * + * @param x the value to truncate (of type sph_u32) + */ +#define SPH_T32(x) + +/** + * Rotate a 32-bit value by a number of bits to the left. The rotate + * count must reside between 1 and 31. This macro assumes that its + * first argument fits in 32 bits (no extra bit allowed on machines where + * sph_u32 is wider); both arguments may be evaluated + * several times. + * + * @param x the value to rotate (of type sph_u32) + * @param n the rotation count (between 1 and 31, inclusive) + */ +#define SPH_ROTL32(x, n) + +/** + * Rotate a 32-bit value by a number of bits to the left. The rotate + * count must reside between 1 and 31. This macro assumes that its + * first argument fits in 32 bits (no extra bit allowed on machines where + * sph_u32 is wider); both arguments may be evaluated + * several times. + * + * @param x the value to rotate (of type sph_u32) + * @param n the rotation count (between 1 and 31, inclusive) + */ +#define SPH_ROTR32(x, n) + +/** + * This macro is defined on systems for which a 64-bit type has been + * detected, and is used for sph_u64. + */ +#define SPH_64 + +/** + * This macro is defined on systems for the "native" integer size is + * 64 bits (64-bit values fit in one register). + */ +#define SPH_64_TRUE + +/** + * This macro expands the token x into a suitable + * constant expression of type sph_u64. Depending on + * how this type is defined, a suffix such as ULL may + * be appended to the argument. This macro is defined only if a + * 64-bit type was detected and used for sph_u64. + * + * @param x the token to expand into a suitable constant expression + */ +#define SPH_C64(x) + +/** + * Truncate a 64-bit value to exactly 64 bits. On most systems, this is + * a no-op, recognized as such by the compiler. This macro is defined only + * if a 64-bit type was detected and used for sph_u64. + * + * @param x the value to truncate (of type sph_u64) + */ +#define SPH_T64(x) + +/** + * Rotate a 64-bit value by a number of bits to the left. The rotate + * count must reside between 1 and 63. This macro assumes that its + * first argument fits in 64 bits (no extra bit allowed on machines where + * sph_u64 is wider); both arguments may be evaluated + * several times. This macro is defined only if a 64-bit type was detected + * and used for sph_u64. + * + * @param x the value to rotate (of type sph_u64) + * @param n the rotation count (between 1 and 63, inclusive) + */ +#define SPH_ROTL64(x, n) + +/** + * Rotate a 64-bit value by a number of bits to the left. The rotate + * count must reside between 1 and 63. This macro assumes that its + * first argument fits in 64 bits (no extra bit allowed on machines where + * sph_u64 is wider); both arguments may be evaluated + * several times. This macro is defined only if a 64-bit type was detected + * and used for sph_u64. + * + * @param x the value to rotate (of type sph_u64) + * @param n the rotation count (between 1 and 63, inclusive) + */ +#define SPH_ROTR64(x, n) + +/** + * This macro evaluates to inline or an equivalent construction, + * if available on the compilation platform, or to nothing otherwise. This + * is used to declare inline functions, for which the compiler should + * endeavour to include the code directly in the caller. Inline functions + * are typically defined in header files as replacement for macros. + */ +#define SPH_INLINE + +/** + * This macro is defined if the platform has been detected as using + * little-endian convention. This implies that the sph_u32 + * type (and the sph_u64 type also, if it is defined) has + * an exact width (i.e. exactly 32-bit, respectively 64-bit). + */ +#define SPH_LITTLE_ENDIAN + +/** + * This macro is defined if the platform has been detected as using + * big-endian convention. This implies that the sph_u32 + * type (and the sph_u64 type also, if it is defined) has + * an exact width (i.e. exactly 32-bit, respectively 64-bit). + */ +#define SPH_BIG_ENDIAN + +/** + * This macro is defined if 32-bit words (and 64-bit words, if defined) + * can be read from and written to memory efficiently in little-endian + * convention. This is the case for little-endian platforms, and also + * for the big-endian platforms which have special little-endian access + * opcodes (e.g. Ultrasparc). + */ +#define SPH_LITTLE_FAST + +/** + * This macro is defined if 32-bit words (and 64-bit words, if defined) + * can be read from and written to memory efficiently in big-endian + * convention. This is the case for little-endian platforms, and also + * for the little-endian platforms which have special big-endian access + * opcodes. + */ +#define SPH_BIG_FAST + +/** + * On some platforms, this macro is defined to an unsigned integer type + * into which pointer values may be cast. The resulting value can then + * be tested for being a multiple of 2, 4 or 8, indicating an aligned + * pointer for, respectively, 16-bit, 32-bit or 64-bit memory accesses. + */ +#define SPH_UPTR + +/** + * When defined, this macro indicates that unaligned memory accesses + * are possible with only a minor penalty, and thus should be prefered + * over strategies which first copy data to an aligned buffer. + */ +#define SPH_UNALIGNED + +/** + * Byte-swap a 32-bit word (i.e. 0x12345678 becomes + * 0x78563412). This is an inline function which resorts + * to inline assembly on some platforms, for better performance. + * + * @param x the 32-bit value to byte-swap + * @return the byte-swapped value + */ +static inline sph_u32 sph_bswap32(sph_u32 x); + +/** + * Byte-swap a 64-bit word. This is an inline function which resorts + * to inline assembly on some platforms, for better performance. This + * function is defined only if a suitable 64-bit type was found for + * sph_u64 + * + * @param x the 64-bit value to byte-swap + * @return the byte-swapped value + */ +static inline sph_u64 sph_bswap64(sph_u64 x); + +/** + * Decode a 16-bit unsigned value from memory, in little-endian convention + * (least significant byte comes first). + * + * @param src the source address + * @return the decoded value + */ +static inline unsigned sph_dec16le(const void *src); + +/** + * Encode a 16-bit unsigned value into memory, in little-endian convention + * (least significant byte comes first). + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc16le(void *dst, unsigned val); + +/** + * Decode a 16-bit unsigned value from memory, in big-endian convention + * (most significant byte comes first). + * + * @param src the source address + * @return the decoded value + */ +static inline unsigned sph_dec16be(const void *src); + +/** + * Encode a 16-bit unsigned value into memory, in big-endian convention + * (most significant byte comes first). + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc16be(void *dst, unsigned val); + +/** + * Decode a 32-bit unsigned value from memory, in little-endian convention + * (least significant byte comes first). + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u32 sph_dec32le(const void *src); + +/** + * Decode a 32-bit unsigned value from memory, in little-endian convention + * (least significant byte comes first). This function assumes that the + * source address is suitably aligned for a direct access, if the platform + * supports such things; it can thus be marginally faster than the generic + * sph_dec32le() function. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u32 sph_dec32le_aligned(const void *src); + +/** + * Encode a 32-bit unsigned value into memory, in little-endian convention + * (least significant byte comes first). + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc32le(void *dst, sph_u32 val); + +/** + * Encode a 32-bit unsigned value into memory, in little-endian convention + * (least significant byte comes first). This function assumes that the + * destination address is suitably aligned for a direct access, if the + * platform supports such things; it can thus be marginally faster than + * the generic sph_enc32le() function. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc32le_aligned(void *dst, sph_u32 val); + +/** + * Decode a 32-bit unsigned value from memory, in big-endian convention + * (most significant byte comes first). + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u32 sph_dec32be(const void *src); + +/** + * Decode a 32-bit unsigned value from memory, in big-endian convention + * (most significant byte comes first). This function assumes that the + * source address is suitably aligned for a direct access, if the platform + * supports such things; it can thus be marginally faster than the generic + * sph_dec32be() function. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u32 sph_dec32be_aligned(const void *src); + +/** + * Encode a 32-bit unsigned value into memory, in big-endian convention + * (most significant byte comes first). + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc32be(void *dst, sph_u32 val); + +/** + * Encode a 32-bit unsigned value into memory, in big-endian convention + * (most significant byte comes first). This function assumes that the + * destination address is suitably aligned for a direct access, if the + * platform supports such things; it can thus be marginally faster than + * the generic sph_enc32be() function. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc32be_aligned(void *dst, sph_u32 val); + +/** + * Decode a 64-bit unsigned value from memory, in little-endian convention + * (least significant byte comes first). This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u64 sph_dec64le(const void *src); + +/** + * Decode a 64-bit unsigned value from memory, in little-endian convention + * (least significant byte comes first). This function assumes that the + * source address is suitably aligned for a direct access, if the platform + * supports such things; it can thus be marginally faster than the generic + * sph_dec64le() function. This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u64 sph_dec64le_aligned(const void *src); + +/** + * Encode a 64-bit unsigned value into memory, in little-endian convention + * (least significant byte comes first). This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc64le(void *dst, sph_u64 val); + +/** + * Encode a 64-bit unsigned value into memory, in little-endian convention + * (least significant byte comes first). This function assumes that the + * destination address is suitably aligned for a direct access, if the + * platform supports such things; it can thus be marginally faster than + * the generic sph_enc64le() function. This function is defined + * only if a suitable 64-bit type was detected and used for + * sph_u64. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc64le_aligned(void *dst, sph_u64 val); + +/** + * Decode a 64-bit unsigned value from memory, in big-endian convention + * (most significant byte comes first). This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u64 sph_dec64be(const void *src); + +/** + * Decode a 64-bit unsigned value from memory, in big-endian convention + * (most significant byte comes first). This function assumes that the + * source address is suitably aligned for a direct access, if the platform + * supports such things; it can thus be marginally faster than the generic + * sph_dec64be() function. This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u64 sph_dec64be_aligned(const void *src); + +/** + * Encode a 64-bit unsigned value into memory, in big-endian convention + * (most significant byte comes first). This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc64be(void *dst, sph_u64 val); + +/** + * Encode a 64-bit unsigned value into memory, in big-endian convention + * (most significant byte comes first). This function assumes that the + * destination address is suitably aligned for a direct access, if the + * platform supports such things; it can thus be marginally faster than + * the generic sph_enc64be() function. This function is defined + * only if a suitable 64-bit type was detected and used for + * sph_u64. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc64be_aligned(void *dst, sph_u64 val); + +#endif + +/* ============== END documentation block for Doxygen ============= */ + +#ifndef DOXYGEN_IGNORE + +/* + * We want to define the types "sph_u32" and "sph_u64" which hold + * unsigned values of at least, respectively, 32 and 64 bits. These + * tests should select appropriate types for most platforms. The + * macro "SPH_64" is defined if the 64-bit is supported. + */ + +#undef SPH_64 +#undef SPH_64_TRUE + +#if defined __STDC__ && __STDC_VERSION__ >= 199901L + +/* + * On C99 implementations, we can use to get an exact 64-bit + * type, if any, or otherwise use a wider type (which must exist, for + * C99 conformance). + */ + +#include + +#ifdef UINT32_MAX +typedef uint32_t sph_u32; +typedef int32_t sph_s32; +#else +typedef uint_fast32_t sph_u32; +typedef int_fast32_t sph_s32; +#endif +#if !SPH_NO_64 +#ifdef UINT64_MAX +typedef uint64_t sph_u64; +typedef int64_t sph_s64; +#else +typedef uint_fast64_t sph_u64; +typedef int_fast64_t sph_s64; +#endif +#endif + +#define SPH_C32(x) ((sph_u32)(x)) +#if !SPH_NO_64 +#define SPH_C64(x) ((sph_u64)(x)) +#define SPH_64 1 +#endif + +#else + +/* + * On non-C99 systems, we use "unsigned int" if it is wide enough, + * "unsigned long" otherwise. This supports all "reasonable" architectures. + * We have to be cautious: pre-C99 preprocessors handle constants + * differently in '#if' expressions. Hence the shifts to test UINT_MAX. + */ + +#if ((UINT_MAX >> 11) >> 11) >= 0x3FF + +typedef unsigned int sph_u32; +typedef int sph_s32; + +#define SPH_C32(x) ((sph_u32)(x ## U)) + +#else + +typedef unsigned long sph_u32; +typedef long sph_s32; + +#define SPH_C32(x) ((sph_u32)(x ## UL)) + +#endif + +#if !SPH_NO_64 + +/* + * We want a 64-bit type. We use "unsigned long" if it is wide enough (as + * is common on 64-bit architectures such as AMD64, Alpha or Sparcv9), + * "unsigned long long" otherwise, if available. We use ULLONG_MAX to + * test whether "unsigned long long" is available; we also know that + * gcc features this type, even if the libc header do not know it. + */ + +#if ((ULONG_MAX >> 31) >> 31) >= 3 + +typedef unsigned long sph_u64; +typedef long sph_s64; + +#define SPH_C64(x) ((sph_u64)(x ## UL)) + +#define SPH_64 1 + +#elif ((ULLONG_MAX >> 31) >> 31) >= 3 || defined __GNUC__ + +typedef unsigned long long sph_u64; +typedef long long sph_s64; + +#define SPH_C64(x) ((sph_u64)(x ## ULL)) + +#define SPH_64 1 + +#else + +/* + * No 64-bit type... + */ + +#endif + +#endif + +#endif + +/* + * If the "unsigned long" type has length 64 bits or more, then this is + * a "true" 64-bit architectures. This is also true with Visual C on + * amd64, even though the "long" type is limited to 32 bits. + */ +#if SPH_64 && (((ULONG_MAX >> 31) >> 31) >= 3 || defined _M_X64) +#define SPH_64_TRUE 1 +#endif + +/* + * Implementation note: some processors have specific opcodes to perform + * a rotation. Recent versions of gcc recognize the expression above and + * use the relevant opcodes, when appropriate. + */ + +#define SPH_T32(x) ((x) & SPH_C32(0xFFFFFFFF)) +#define SPH_ROTL32(x, n) SPH_T32(((x) << (n)) | ((x) >> (32 - (n)))) +#define SPH_ROTR32(x, n) SPH_ROTL32(x, (32 - (n))) + +#if SPH_64 + +#define SPH_T64(x) ((x) & SPH_C64(0xFFFFFFFFFFFFFFFF)) +#define SPH_ROTL64(x, n) SPH_T64(((x) << (n)) | ((x) >> (64 - (n)))) +#define SPH_ROTR64(x, n) SPH_ROTL64(x, (64 - (n))) + +#endif + +#ifndef DOXYGEN_IGNORE +/* + * Define SPH_INLINE to be an "inline" qualifier, if available. We define + * some small macro-like functions which benefit greatly from being inlined. + */ +#if (defined __STDC__ && __STDC_VERSION__ >= 199901L) || defined __GNUC__ +#define SPH_INLINE inline +#elif defined _MSC_VER +#define SPH_INLINE __inline +#else +#define SPH_INLINE +#endif +#endif + +/* + * We define some macros which qualify the architecture. These macros + * may be explicit set externally (e.g. as compiler parameters). The + * code below sets those macros if they are not already defined. + * + * Most macros are boolean, thus evaluate to either zero or non-zero. + * The SPH_UPTR macro is special, in that it evaluates to a C type, + * or is not defined. + * + * SPH_UPTR if defined: unsigned type to cast pointers into + * + * SPH_UNALIGNED non-zero if unaligned accesses are efficient + * SPH_LITTLE_ENDIAN non-zero if architecture is known to be little-endian + * SPH_BIG_ENDIAN non-zero if architecture is known to be big-endian + * SPH_LITTLE_FAST non-zero if little-endian decoding is fast + * SPH_BIG_FAST non-zero if big-endian decoding is fast + * + * If SPH_UPTR is defined, then encoding and decoding of 32-bit and 64-bit + * values will try to be "smart". Either SPH_LITTLE_ENDIAN or SPH_BIG_ENDIAN + * _must_ be non-zero in those situations. The 32-bit and 64-bit types + * _must_ also have an exact width. + * + * SPH_SPARCV9_GCC_32 UltraSPARC-compatible with gcc, 32-bit mode + * SPH_SPARCV9_GCC_64 UltraSPARC-compatible with gcc, 64-bit mode + * SPH_SPARCV9_GCC UltraSPARC-compatible with gcc + * SPH_I386_GCC x86-compatible (32-bit) with gcc + * SPH_I386_MSVC x86-compatible (32-bit) with Microsoft Visual C + * SPH_AMD64_GCC x86-compatible (64-bit) with gcc + * SPH_AMD64_MSVC x86-compatible (64-bit) with Microsoft Visual C + * SPH_PPC32_GCC PowerPC, 32-bit, with gcc + * SPH_PPC64_GCC PowerPC, 64-bit, with gcc + * + * TODO: enhance automatic detection, for more architectures and compilers. + * Endianness is the most important. SPH_UNALIGNED and SPH_UPTR help with + * some very fast functions (e.g. MD4) when using unaligned input data. + * The CPU-specific-with-GCC macros are useful only for inline assembly, + * normally restrained to this header file. + */ + +/* + * 32-bit x86, aka "i386 compatible". + */ +#if defined __i386__ || defined _M_IX86 + +#define SPH_DETECT_UNALIGNED 1 +#define SPH_DETECT_LITTLE_ENDIAN 1 +#define SPH_DETECT_UPTR sph_u32 +#ifdef __GNUC__ +#define SPH_DETECT_I386_GCC 1 +#endif +#ifdef _MSC_VER +#define SPH_DETECT_I386_MSVC 1 +#endif + +/* + * 64-bit x86, hereafter known as "amd64". + */ +#elif defined __x86_64 || defined _M_X64 + +#define SPH_DETECT_UNALIGNED 1 +#define SPH_DETECT_LITTLE_ENDIAN 1 +#define SPH_DETECT_UPTR sph_u64 +#ifdef __GNUC__ +#define SPH_DETECT_AMD64_GCC 1 +#endif +#ifdef _MSC_VER +#define SPH_DETECT_AMD64_MSVC 1 +#endif + +/* + * 64-bit Sparc architecture (implies v9). + */ +#elif ((defined __sparc__ || defined __sparc) && defined __arch64__) \ + || defined __sparcv9 + +#define SPH_DETECT_BIG_ENDIAN 1 +#define SPH_DETECT_UPTR sph_u64 +#ifdef __GNUC__ +#define SPH_DETECT_SPARCV9_GCC_64 1 +#define SPH_DETECT_LITTLE_FAST 1 +#endif + +/* + * 32-bit Sparc. + */ +#elif (defined __sparc__ || defined __sparc) \ + && !(defined __sparcv9 || defined __arch64__) + +#define SPH_DETECT_BIG_ENDIAN 1 +#define SPH_DETECT_UPTR sph_u32 +#if defined __GNUC__ && defined __sparc_v9__ +#define SPH_DETECT_SPARCV9_GCC_32 1 +#define SPH_DETECT_LITTLE_FAST 1 +#endif + +/* + * ARM, little-endian. + */ +#elif defined __arm__ && __ARMEL__ + +#define SPH_DETECT_LITTLE_ENDIAN 1 + +/* + * MIPS, little-endian. + */ +#elif MIPSEL || _MIPSEL || __MIPSEL || __MIPSEL__ + +#define SPH_DETECT_LITTLE_ENDIAN 1 + +/* + * MIPS, big-endian. + */ +#elif MIPSEB || _MIPSEB || __MIPSEB || __MIPSEB__ + +#define SPH_DETECT_BIG_ENDIAN 1 + +/* + * PowerPC. + */ +#elif defined __powerpc__ || defined __POWERPC__ || defined __ppc__ \ + || defined _ARCH_PPC + +/* + * Note: we do not declare cross-endian access to be "fast": even if + * using inline assembly, implementation should still assume that + * keeping the decoded word in a temporary is faster than decoding + * it again. + */ +#if defined __GNUC__ +#if SPH_64_TRUE +#define SPH_DETECT_PPC64_GCC 1 +#else +#define SPH_DETECT_PPC32_GCC 1 +#endif +#endif + +#if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN +#define SPH_DETECT_BIG_ENDIAN 1 +#elif defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN +#define SPH_DETECT_LITTLE_ENDIAN 1 +#endif + +/* + * Itanium, 64-bit. + */ +#elif defined __ia64 || defined __ia64__ \ + || defined __itanium__ || defined _M_IA64 + +#if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN +#define SPH_DETECT_BIG_ENDIAN 1 +#else +#define SPH_DETECT_LITTLE_ENDIAN 1 +#endif +#if defined __LP64__ || defined _LP64 +#define SPH_DETECT_UPTR sph_u64 +#else +#define SPH_DETECT_UPTR sph_u32 +#endif + +#endif + +#if defined SPH_DETECT_SPARCV9_GCC_32 || defined SPH_DETECT_SPARCV9_GCC_64 +#define SPH_DETECT_SPARCV9_GCC 1 +#endif + +#if defined SPH_DETECT_UNALIGNED && !defined SPH_UNALIGNED +#define SPH_UNALIGNED SPH_DETECT_UNALIGNED +#endif +#if defined SPH_DETECT_UPTR && !defined SPH_UPTR +#define SPH_UPTR SPH_DETECT_UPTR +#endif +#if defined SPH_DETECT_LITTLE_ENDIAN && !defined SPH_LITTLE_ENDIAN +#define SPH_LITTLE_ENDIAN SPH_DETECT_LITTLE_ENDIAN +#endif +#if defined SPH_DETECT_BIG_ENDIAN && !defined SPH_BIG_ENDIAN +#define SPH_BIG_ENDIAN SPH_DETECT_BIG_ENDIAN +#endif +#if defined SPH_DETECT_LITTLE_FAST && !defined SPH_LITTLE_FAST +#define SPH_LITTLE_FAST SPH_DETECT_LITTLE_FAST +#endif +#if defined SPH_DETECT_BIG_FAST && !defined SPH_BIG_FAST +#define SPH_BIG_FAST SPH_DETECT_BIG_FAST +#endif +#if defined SPH_DETECT_SPARCV9_GCC_32 && !defined SPH_SPARCV9_GCC_32 +#define SPH_SPARCV9_GCC_32 SPH_DETECT_SPARCV9_GCC_32 +#endif +#if defined SPH_DETECT_SPARCV9_GCC_64 && !defined SPH_SPARCV9_GCC_64 +#define SPH_SPARCV9_GCC_64 SPH_DETECT_SPARCV9_GCC_64 +#endif +#if defined SPH_DETECT_SPARCV9_GCC && !defined SPH_SPARCV9_GCC +#define SPH_SPARCV9_GCC SPH_DETECT_SPARCV9_GCC +#endif +#if defined SPH_DETECT_I386_GCC && !defined SPH_I386_GCC +#define SPH_I386_GCC SPH_DETECT_I386_GCC +#endif +#if defined SPH_DETECT_I386_MSVC && !defined SPH_I386_MSVC +#define SPH_I386_MSVC SPH_DETECT_I386_MSVC +#endif +#if defined SPH_DETECT_AMD64_GCC && !defined SPH_AMD64_GCC +#define SPH_AMD64_GCC SPH_DETECT_AMD64_GCC +#endif +#if defined SPH_DETECT_AMD64_MSVC && !defined SPH_AMD64_MSVC +#define SPH_AMD64_MSVC SPH_DETECT_AMD64_MSVC +#endif +#if defined SPH_DETECT_PPC32_GCC && !defined SPH_PPC32_GCC +#define SPH_PPC32_GCC SPH_DETECT_PPC32_GCC +#endif +#if defined SPH_DETECT_PPC64_GCC && !defined SPH_PPC64_GCC +#define SPH_PPC64_GCC SPH_DETECT_PPC64_GCC +#endif + +#if SPH_LITTLE_ENDIAN && !defined SPH_LITTLE_FAST +#define SPH_LITTLE_FAST 1 +#endif +#if SPH_BIG_ENDIAN && !defined SPH_BIG_FAST +#define SPH_BIG_FAST 1 +#endif + +#if defined SPH_UPTR && !(SPH_LITTLE_ENDIAN || SPH_BIG_ENDIAN) +#error SPH_UPTR defined, but endianness is not known. +#endif + +#if SPH_I386_GCC && !SPH_NO_ASM + +/* + * On x86 32-bit, with gcc, we use the bswapl opcode to byte-swap 32-bit + * values. + */ + +static SPH_INLINE sph_u32 +sph_bswap32(sph_u32 x) +{ + __asm__ __volatile__ ("bswapl %0" : "=r" (x) : "0" (x)); + return x; +} + +#if SPH_64 + +static SPH_INLINE sph_u64 +sph_bswap64(sph_u64 x) +{ + return ((sph_u64)sph_bswap32((sph_u32)x) << 32) + | (sph_u64)sph_bswap32((sph_u32)(x >> 32)); +} + +#endif + +#elif SPH_AMD64_GCC && !SPH_NO_ASM + +/* + * On x86 64-bit, with gcc, we use the bswapl opcode to byte-swap 32-bit + * and 64-bit values. + */ + +static SPH_INLINE sph_u32 +sph_bswap32(sph_u32 x) +{ + __asm__ __volatile__ ("bswapl %0" : "=r" (x) : "0" (x)); + return x; +} + +#if SPH_64 + +static SPH_INLINE sph_u64 +sph_bswap64(sph_u64 x) +{ + __asm__ __volatile__ ("bswapq %0" : "=r" (x) : "0" (x)); + return x; +} + +#endif + +/* + * Disabled code. Apparently, Microsoft Visual C 2005 is smart enough + * to generate proper opcodes for endianness swapping with the pure C + * implementation below. + * + +#elif SPH_I386_MSVC && !SPH_NO_ASM + +static __inline sph_u32 __declspec(naked) __fastcall +sph_bswap32(sph_u32 x) +{ + __asm { + bswap ecx + mov eax,ecx + ret + } +} + +#if SPH_64 + +static SPH_INLINE sph_u64 +sph_bswap64(sph_u64 x) +{ + return ((sph_u64)sph_bswap32((sph_u32)x) << 32) + | (sph_u64)sph_bswap32((sph_u32)(x >> 32)); +} + +#endif + + * + * [end of disabled code] + */ + +#else + +static SPH_INLINE sph_u32 +sph_bswap32(sph_u32 x) +{ + x = SPH_T32((x << 16) | (x >> 16)); + x = ((x & SPH_C32(0xFF00FF00)) >> 8) + | ((x & SPH_C32(0x00FF00FF)) << 8); + return x; +} + +#if SPH_64 + +/** + * Byte-swap a 64-bit value. + * + * @param x the input value + * @return the byte-swapped value + */ +static SPH_INLINE sph_u64 +sph_bswap64(sph_u64 x) +{ + x = SPH_T64((x << 32) | (x >> 32)); + x = ((x & SPH_C64(0xFFFF0000FFFF0000)) >> 16) + | ((x & SPH_C64(0x0000FFFF0000FFFF)) << 16); + x = ((x & SPH_C64(0xFF00FF00FF00FF00)) >> 8) + | ((x & SPH_C64(0x00FF00FF00FF00FF)) << 8); + return x; +} + +#endif + +#endif + +#if SPH_SPARCV9_GCC && !SPH_NO_ASM + +/* + * On UltraSPARC systems, native ordering is big-endian, but it is + * possible to perform little-endian read accesses by specifying the + * address space 0x88 (ASI_PRIMARY_LITTLE). Basically, either we use + * the opcode "lda [%reg]0x88,%dst", where %reg is the register which + * contains the source address and %dst is the destination register, + * or we use "lda [%reg+imm]%asi,%dst", which uses the %asi register + * to get the address space name. The latter format is better since it + * combines an addition and the actual access in a single opcode; but + * it requires the setting (and subsequent resetting) of %asi, which is + * slow. Some operations (i.e. MD5 compression function) combine many + * successive little-endian read accesses, which may share the same + * %asi setting. The macros below contain the appropriate inline + * assembly. + */ + +#define SPH_SPARCV9_SET_ASI \ + sph_u32 sph_sparcv9_asi; \ + __asm__ __volatile__ ( \ + "rd %%asi,%0\n\twr %%g0,0x88,%%asi" : "=r" (sph_sparcv9_asi)); + +#define SPH_SPARCV9_RESET_ASI \ + __asm__ __volatile__ ("wr %%g0,%0,%%asi" : : "r" (sph_sparcv9_asi)); + +#define SPH_SPARCV9_DEC32LE(base, idx) ({ \ + sph_u32 sph_sparcv9_tmp; \ + __asm__ __volatile__ ("lda [%1+" #idx "*4]%%asi,%0" \ + : "=r" (sph_sparcv9_tmp) : "r" (base)); \ + sph_sparcv9_tmp; \ + }) + +#endif + +static SPH_INLINE void +sph_enc16be(void *dst, unsigned val) +{ + ((unsigned char *)dst)[0] = (val >> 8); + ((unsigned char *)dst)[1] = val; +} + +static SPH_INLINE unsigned +sph_dec16be(const void *src) +{ + return ((unsigned)(((const unsigned char *)src)[0]) << 8) + | (unsigned)(((const unsigned char *)src)[1]); +} + +static SPH_INLINE void +sph_enc16le(void *dst, unsigned val) +{ + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = val >> 8; +} + +static SPH_INLINE unsigned +sph_dec16le(const void *src) +{ + return (unsigned)(((const unsigned char *)src)[0]) + | ((unsigned)(((const unsigned char *)src)[1]) << 8); +} + +/** + * Encode a 32-bit value into the provided buffer (big endian convention). + * + * @param dst the destination buffer + * @param val the 32-bit value to encode + */ +static SPH_INLINE void +sph_enc32be(void *dst, sph_u32 val) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_LITTLE_ENDIAN + val = sph_bswap32(val); +#endif + *(sph_u32 *)dst = val; +#else + if (((SPH_UPTR)dst & 3) == 0) { +#if SPH_LITTLE_ENDIAN + val = sph_bswap32(val); +#endif + *(sph_u32 *)dst = val; + } else { + ((unsigned char *)dst)[0] = (val >> 24); + ((unsigned char *)dst)[1] = (val >> 16); + ((unsigned char *)dst)[2] = (val >> 8); + ((unsigned char *)dst)[3] = val; + } +#endif +#else + ((unsigned char *)dst)[0] = (val >> 24); + ((unsigned char *)dst)[1] = (val >> 16); + ((unsigned char *)dst)[2] = (val >> 8); + ((unsigned char *)dst)[3] = val; +#endif +} + +/** + * Encode a 32-bit value into the provided buffer (big endian convention). + * The destination buffer must be properly aligned. + * + * @param dst the destination buffer (32-bit aligned) + * @param val the value to encode + */ +static SPH_INLINE void +sph_enc32be_aligned(void *dst, sph_u32 val) +{ +#if SPH_LITTLE_ENDIAN + *(sph_u32 *)dst = sph_bswap32(val); +#elif SPH_BIG_ENDIAN + *(sph_u32 *)dst = val; +#else + ((unsigned char *)dst)[0] = (val >> 24); + ((unsigned char *)dst)[1] = (val >> 16); + ((unsigned char *)dst)[2] = (val >> 8); + ((unsigned char *)dst)[3] = val; +#endif +} + +/** + * Decode a 32-bit value from the provided buffer (big endian convention). + * + * @param src the source buffer + * @return the decoded value + */ +static SPH_INLINE sph_u32 +sph_dec32be(const void *src) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_LITTLE_ENDIAN + return sph_bswap32(*(const sph_u32 *)src); +#else + return *(const sph_u32 *)src; +#endif +#else + if (((SPH_UPTR)src & 3) == 0) { +#if SPH_LITTLE_ENDIAN + return sph_bswap32(*(const sph_u32 *)src); +#else + return *(const sph_u32 *)src; +#endif + } else { + return ((sph_u32)(((const unsigned char *)src)[0]) << 24) + | ((sph_u32)(((const unsigned char *)src)[1]) << 16) + | ((sph_u32)(((const unsigned char *)src)[2]) << 8) + | (sph_u32)(((const unsigned char *)src)[3]); + } +#endif +#else + return ((sph_u32)(((const unsigned char *)src)[0]) << 24) + | ((sph_u32)(((const unsigned char *)src)[1]) << 16) + | ((sph_u32)(((const unsigned char *)src)[2]) << 8) + | (sph_u32)(((const unsigned char *)src)[3]); +#endif +} + +/** + * Decode a 32-bit value from the provided buffer (big endian convention). + * The source buffer must be properly aligned. + * + * @param src the source buffer (32-bit aligned) + * @return the decoded value + */ +static SPH_INLINE sph_u32 +sph_dec32be_aligned(const void *src) +{ +#if SPH_LITTLE_ENDIAN + return sph_bswap32(*(const sph_u32 *)src); +#elif SPH_BIG_ENDIAN + return *(const sph_u32 *)src; +#else + return ((sph_u32)(((const unsigned char *)src)[0]) << 24) + | ((sph_u32)(((const unsigned char *)src)[1]) << 16) + | ((sph_u32)(((const unsigned char *)src)[2]) << 8) + | (sph_u32)(((const unsigned char *)src)[3]); +#endif +} + +/** + * Encode a 32-bit value into the provided buffer (little endian convention). + * + * @param dst the destination buffer + * @param val the 32-bit value to encode + */ +static SPH_INLINE void +sph_enc32le(void *dst, sph_u32 val) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_BIG_ENDIAN + val = sph_bswap32(val); +#endif + *(sph_u32 *)dst = val; +#else + if (((SPH_UPTR)dst & 3) == 0) { +#if SPH_BIG_ENDIAN + val = sph_bswap32(val); +#endif + *(sph_u32 *)dst = val; + } else { + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); + } +#endif +#else + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); +#endif +} + +/** + * Encode a 32-bit value into the provided buffer (little endian convention). + * The destination buffer must be properly aligned. + * + * @param dst the destination buffer (32-bit aligned) + * @param val the value to encode + */ +static SPH_INLINE void +sph_enc32le_aligned(void *dst, sph_u32 val) +{ +#if SPH_LITTLE_ENDIAN + *(sph_u32 *)dst = val; +#elif SPH_BIG_ENDIAN + *(sph_u32 *)dst = sph_bswap32(val); +#else + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); +#endif +} + +/** + * Decode a 32-bit value from the provided buffer (little endian convention). + * + * @param src the source buffer + * @return the decoded value + */ +static SPH_INLINE sph_u32 +sph_dec32le(const void *src) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_BIG_ENDIAN + return sph_bswap32(*(const sph_u32 *)src); +#else + return *(const sph_u32 *)src; +#endif +#else + if (((SPH_UPTR)src & 3) == 0) { +#if SPH_BIG_ENDIAN +#if SPH_SPARCV9_GCC && !SPH_NO_ASM + sph_u32 tmp; + + /* + * "__volatile__" is needed here because without it, + * gcc-3.4.3 miscompiles the code and performs the + * access before the test on the address, thus triggering + * a bus error... + */ + __asm__ __volatile__ ( + "lda [%1]0x88,%0" : "=r" (tmp) : "r" (src)); + return tmp; +/* + * On PowerPC, this turns out not to be worth the effort: the inline + * assembly makes GCC optimizer uncomfortable, which tends to nullify + * the decoding gains. + * + * For most hash functions, using this inline assembly trick changes + * hashing speed by less than 5% and often _reduces_ it. The biggest + * gains are for MD4 (+11%) and CubeHash (+30%). For all others, it is + * less then 10%. The speed gain on CubeHash is probably due to the + * chronic shortage of registers that CubeHash endures; for the other + * functions, the generic code appears to be efficient enough already. + * +#elif (SPH_PPC32_GCC || SPH_PPC64_GCC) && !SPH_NO_ASM + sph_u32 tmp; + + __asm__ __volatile__ ( + "lwbrx %0,0,%1" : "=r" (tmp) : "r" (src)); + return tmp; + */ +#else + return sph_bswap32(*(const sph_u32 *)src); +#endif +#else + return *(const sph_u32 *)src; +#endif + } else { + return (sph_u32)(((const unsigned char *)src)[0]) + | ((sph_u32)(((const unsigned char *)src)[1]) << 8) + | ((sph_u32)(((const unsigned char *)src)[2]) << 16) + | ((sph_u32)(((const unsigned char *)src)[3]) << 24); + } +#endif +#else + return (sph_u32)(((const unsigned char *)src)[0]) + | ((sph_u32)(((const unsigned char *)src)[1]) << 8) + | ((sph_u32)(((const unsigned char *)src)[2]) << 16) + | ((sph_u32)(((const unsigned char *)src)[3]) << 24); +#endif +} + +/** + * Decode a 32-bit value from the provided buffer (little endian convention). + * The source buffer must be properly aligned. + * + * @param src the source buffer (32-bit aligned) + * @return the decoded value + */ +static SPH_INLINE sph_u32 +sph_dec32le_aligned(const void *src) +{ +#if SPH_LITTLE_ENDIAN + return *(const sph_u32 *)src; +#elif SPH_BIG_ENDIAN +#if SPH_SPARCV9_GCC && !SPH_NO_ASM + sph_u32 tmp; + + __asm__ __volatile__ ("lda [%1]0x88,%0" : "=r" (tmp) : "r" (src)); + return tmp; +/* + * Not worth it generally. + * +#elif (SPH_PPC32_GCC || SPH_PPC64_GCC) && !SPH_NO_ASM + sph_u32 tmp; + + __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (tmp) : "r" (src)); + return tmp; + */ +#else + return sph_bswap32(*(const sph_u32 *)src); +#endif +#else + return (sph_u32)(((const unsigned char *)src)[0]) + | ((sph_u32)(((const unsigned char *)src)[1]) << 8) + | ((sph_u32)(((const unsigned char *)src)[2]) << 16) + | ((sph_u32)(((const unsigned char *)src)[3]) << 24); +#endif +} + +#if SPH_64 + +/** + * Encode a 64-bit value into the provided buffer (big endian convention). + * + * @param dst the destination buffer + * @param val the 64-bit value to encode + */ +static SPH_INLINE void +sph_enc64be(void *dst, sph_u64 val) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_LITTLE_ENDIAN + val = sph_bswap64(val); +#endif + *(sph_u64 *)dst = val; +#else + if (((SPH_UPTR)dst & 7) == 0) { +#if SPH_LITTLE_ENDIAN + val = sph_bswap64(val); +#endif + *(sph_u64 *)dst = val; + } else { + ((unsigned char *)dst)[0] = (val >> 56); + ((unsigned char *)dst)[1] = (val >> 48); + ((unsigned char *)dst)[2] = (val >> 40); + ((unsigned char *)dst)[3] = (val >> 32); + ((unsigned char *)dst)[4] = (val >> 24); + ((unsigned char *)dst)[5] = (val >> 16); + ((unsigned char *)dst)[6] = (val >> 8); + ((unsigned char *)dst)[7] = val; + } +#endif +#else + ((unsigned char *)dst)[0] = (val >> 56); + ((unsigned char *)dst)[1] = (val >> 48); + ((unsigned char *)dst)[2] = (val >> 40); + ((unsigned char *)dst)[3] = (val >> 32); + ((unsigned char *)dst)[4] = (val >> 24); + ((unsigned char *)dst)[5] = (val >> 16); + ((unsigned char *)dst)[6] = (val >> 8); + ((unsigned char *)dst)[7] = val; +#endif +} + +/** + * Encode a 64-bit value into the provided buffer (big endian convention). + * The destination buffer must be properly aligned. + * + * @param dst the destination buffer (64-bit aligned) + * @param val the value to encode + */ +static SPH_INLINE void +sph_enc64be_aligned(void *dst, sph_u64 val) +{ +#if SPH_LITTLE_ENDIAN + *(sph_u64 *)dst = sph_bswap64(val); +#elif SPH_BIG_ENDIAN + *(sph_u64 *)dst = val; +#else + ((unsigned char *)dst)[0] = (val >> 56); + ((unsigned char *)dst)[1] = (val >> 48); + ((unsigned char *)dst)[2] = (val >> 40); + ((unsigned char *)dst)[3] = (val >> 32); + ((unsigned char *)dst)[4] = (val >> 24); + ((unsigned char *)dst)[5] = (val >> 16); + ((unsigned char *)dst)[6] = (val >> 8); + ((unsigned char *)dst)[7] = val; +#endif +} + +/** + * Decode a 64-bit value from the provided buffer (big endian convention). + * + * @param src the source buffer + * @return the decoded value + */ +static SPH_INLINE sph_u64 +sph_dec64be(const void *src) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_LITTLE_ENDIAN + return sph_bswap64(*(const sph_u64 *)src); +#else + return *(const sph_u64 *)src; +#endif +#else + if (((SPH_UPTR)src & 7) == 0) { +#if SPH_LITTLE_ENDIAN + return sph_bswap64(*(const sph_u64 *)src); +#else + return *(const sph_u64 *)src; +#endif + } else { + return ((sph_u64)(((const unsigned char *)src)[0]) << 56) + | ((sph_u64)(((const unsigned char *)src)[1]) << 48) + | ((sph_u64)(((const unsigned char *)src)[2]) << 40) + | ((sph_u64)(((const unsigned char *)src)[3]) << 32) + | ((sph_u64)(((const unsigned char *)src)[4]) << 24) + | ((sph_u64)(((const unsigned char *)src)[5]) << 16) + | ((sph_u64)(((const unsigned char *)src)[6]) << 8) + | (sph_u64)(((const unsigned char *)src)[7]); + } +#endif +#else + return ((sph_u64)(((const unsigned char *)src)[0]) << 56) + | ((sph_u64)(((const unsigned char *)src)[1]) << 48) + | ((sph_u64)(((const unsigned char *)src)[2]) << 40) + | ((sph_u64)(((const unsigned char *)src)[3]) << 32) + | ((sph_u64)(((const unsigned char *)src)[4]) << 24) + | ((sph_u64)(((const unsigned char *)src)[5]) << 16) + | ((sph_u64)(((const unsigned char *)src)[6]) << 8) + | (sph_u64)(((const unsigned char *)src)[7]); +#endif +} + +/** + * Decode a 64-bit value from the provided buffer (big endian convention). + * The source buffer must be properly aligned. + * + * @param src the source buffer (64-bit aligned) + * @return the decoded value + */ +static SPH_INLINE sph_u64 +sph_dec64be_aligned(const void *src) +{ +#if SPH_LITTLE_ENDIAN + return sph_bswap64(*(const sph_u64 *)src); +#elif SPH_BIG_ENDIAN + return *(const sph_u64 *)src; +#else + return ((sph_u64)(((const unsigned char *)src)[0]) << 56) + | ((sph_u64)(((const unsigned char *)src)[1]) << 48) + | ((sph_u64)(((const unsigned char *)src)[2]) << 40) + | ((sph_u64)(((const unsigned char *)src)[3]) << 32) + | ((sph_u64)(((const unsigned char *)src)[4]) << 24) + | ((sph_u64)(((const unsigned char *)src)[5]) << 16) + | ((sph_u64)(((const unsigned char *)src)[6]) << 8) + | (sph_u64)(((const unsigned char *)src)[7]); +#endif +} + +/** + * Encode a 64-bit value into the provided buffer (little endian convention). + * + * @param dst the destination buffer + * @param val the 64-bit value to encode + */ +static SPH_INLINE void +sph_enc64le(void *dst, sph_u64 val) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_BIG_ENDIAN + val = sph_bswap64(val); +#endif + *(sph_u64 *)dst = val; +#else + if (((SPH_UPTR)dst & 7) == 0) { +#if SPH_BIG_ENDIAN + val = sph_bswap64(val); +#endif + *(sph_u64 *)dst = val; + } else { + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); + ((unsigned char *)dst)[4] = (val >> 32); + ((unsigned char *)dst)[5] = (val >> 40); + ((unsigned char *)dst)[6] = (val >> 48); + ((unsigned char *)dst)[7] = (val >> 56); + } +#endif +#else + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); + ((unsigned char *)dst)[4] = (val >> 32); + ((unsigned char *)dst)[5] = (val >> 40); + ((unsigned char *)dst)[6] = (val >> 48); + ((unsigned char *)dst)[7] = (val >> 56); +#endif +} + +/** + * Encode a 64-bit value into the provided buffer (little endian convention). + * The destination buffer must be properly aligned. + * + * @param dst the destination buffer (64-bit aligned) + * @param val the value to encode + */ +static SPH_INLINE void +sph_enc64le_aligned(void *dst, sph_u64 val) +{ +#if SPH_LITTLE_ENDIAN + *(sph_u64 *)dst = val; +#elif SPH_BIG_ENDIAN + *(sph_u64 *)dst = sph_bswap64(val); +#else + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); + ((unsigned char *)dst)[4] = (val >> 32); + ((unsigned char *)dst)[5] = (val >> 40); + ((unsigned char *)dst)[6] = (val >> 48); + ((unsigned char *)dst)[7] = (val >> 56); +#endif +} + +/** + * Decode a 64-bit value from the provided buffer (little endian convention). + * + * @param src the source buffer + * @return the decoded value + */ +static SPH_INLINE sph_u64 +sph_dec64le(const void *src) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_BIG_ENDIAN + return sph_bswap64(*(const sph_u64 *)src); +#else + return *(const sph_u64 *)src; +#endif +#else + if (((SPH_UPTR)src & 7) == 0) { +#if SPH_BIG_ENDIAN +#if SPH_SPARCV9_GCC_64 && !SPH_NO_ASM + sph_u64 tmp; + + __asm__ __volatile__ ( + "ldxa [%1]0x88,%0" : "=r" (tmp) : "r" (src)); + return tmp; +/* + * Not worth it generally. + * +#elif SPH_PPC32_GCC && !SPH_NO_ASM + return (sph_u64)sph_dec32le_aligned(src) + | ((sph_u64)sph_dec32le_aligned( + (const char *)src + 4) << 32); +#elif SPH_PPC64_GCC && !SPH_NO_ASM + sph_u64 tmp; + + __asm__ __volatile__ ( + "ldbrx %0,0,%1" : "=r" (tmp) : "r" (src)); + return tmp; + */ +#else + return sph_bswap64(*(const sph_u64 *)src); +#endif +#else + return *(const sph_u64 *)src; +#endif + } else { + return (sph_u64)(((const unsigned char *)src)[0]) + | ((sph_u64)(((const unsigned char *)src)[1]) << 8) + | ((sph_u64)(((const unsigned char *)src)[2]) << 16) + | ((sph_u64)(((const unsigned char *)src)[3]) << 24) + | ((sph_u64)(((const unsigned char *)src)[4]) << 32) + | ((sph_u64)(((const unsigned char *)src)[5]) << 40) + | ((sph_u64)(((const unsigned char *)src)[6]) << 48) + | ((sph_u64)(((const unsigned char *)src)[7]) << 56); + } +#endif +#else + return (sph_u64)(((const unsigned char *)src)[0]) + | ((sph_u64)(((const unsigned char *)src)[1]) << 8) + | ((sph_u64)(((const unsigned char *)src)[2]) << 16) + | ((sph_u64)(((const unsigned char *)src)[3]) << 24) + | ((sph_u64)(((const unsigned char *)src)[4]) << 32) + | ((sph_u64)(((const unsigned char *)src)[5]) << 40) + | ((sph_u64)(((const unsigned char *)src)[6]) << 48) + | ((sph_u64)(((const unsigned char *)src)[7]) << 56); +#endif +} + +/** + * Decode a 64-bit value from the provided buffer (little endian convention). + * The source buffer must be properly aligned. + * + * @param src the source buffer (64-bit aligned) + * @return the decoded value + */ +static SPH_INLINE sph_u64 +sph_dec64le_aligned(const void *src) +{ +#if SPH_LITTLE_ENDIAN + return *(const sph_u64 *)src; +#elif SPH_BIG_ENDIAN +#if SPH_SPARCV9_GCC_64 && !SPH_NO_ASM + sph_u64 tmp; + + __asm__ __volatile__ ("ldxa [%1]0x88,%0" : "=r" (tmp) : "r" (src)); + return tmp; +/* + * Not worth it generally. + * +#elif SPH_PPC32_GCC && !SPH_NO_ASM + return (sph_u64)sph_dec32le_aligned(src) + | ((sph_u64)sph_dec32le_aligned((const char *)src + 4) << 32); +#elif SPH_PPC64_GCC && !SPH_NO_ASM + sph_u64 tmp; + + __asm__ __volatile__ ("ldbrx %0,0,%1" : "=r" (tmp) : "r" (src)); + return tmp; + */ +#else + return sph_bswap64(*(const sph_u64 *)src); +#endif +#else + return (sph_u64)(((const unsigned char *)src)[0]) + | ((sph_u64)(((const unsigned char *)src)[1]) << 8) + | ((sph_u64)(((const unsigned char *)src)[2]) << 16) + | ((sph_u64)(((const unsigned char *)src)[3]) << 24) + | ((sph_u64)(((const unsigned char *)src)[4]) << 32) + | ((sph_u64)(((const unsigned char *)src)[5]) << 40) + | ((sph_u64)(((const unsigned char *)src)[6]) << 48) + | ((sph_u64)(((const unsigned char *)src)[7]) << 56); +#endif +} + +#endif + +#endif /* Doxygen excluded block */ + +#endif diff --git a/src/pbkdf2.cpp b/src/pbkdf2.cpp new file mode 100644 index 0000000..6d3f3dc --- /dev/null +++ b/src/pbkdf2.cpp @@ -0,0 +1,148 @@ +// Copyright (c) 2013 NovaCoin Developers + +#include +#include "pbkdf2.h" + +static inline uint32_t +be32dec(const void *pp) +{ + const uint8_t *p = (uint8_t const *)pp; + + return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) + + ((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24)); +} + +static inline void +be32enc(void *pp, uint32_t x) +{ + uint8_t * p = (uint8_t *)pp; + + p[3] = x & 0xff; + p[2] = (x >> 8) & 0xff; + p[1] = (x >> 16) & 0xff; + p[0] = (x >> 24) & 0xff; +} + + + +/* Initialize an HMAC-SHA256 operation with the given key. */ +void +HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen) +{ + unsigned char pad[64]; + unsigned char khash[32]; + const unsigned char * K = (const unsigned char *)_K; + size_t i; + + /* If Klen > 64, the key is really SHA256(K). */ + if (Klen > 64) { + SHA256_Init(&ctx->ictx); + SHA256_Update(&ctx->ictx, K, Klen); + SHA256_Final(khash, &ctx->ictx); + K = khash; + Klen = 32; + } + + /* Inner SHA256 operation is SHA256(K xor [block of 0x36] || data). */ + SHA256_Init(&ctx->ictx); + memset(pad, 0x36, 64); + for (i = 0; i < Klen; i++) + pad[i] ^= K[i]; + SHA256_Update(&ctx->ictx, pad, 64); + + /* Outer SHA256 operation is SHA256(K xor [block of 0x5c] || hash). */ + SHA256_Init(&ctx->octx); + memset(pad, 0x5c, 64); + for (i = 0; i < Klen; i++) + pad[i] ^= K[i]; + SHA256_Update(&ctx->octx, pad, 64); + + /* Clean the stack. */ + memset(khash, 0, 32); +} + +/* Add bytes to the HMAC-SHA256 operation. */ +void +HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void *in, size_t len) +{ + + /* Feed data to the inner SHA256 operation. */ + SHA256_Update(&ctx->ictx, in, len); +} + +/* Finish an HMAC-SHA256 operation. */ +void +HMAC_SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX * ctx) +{ + unsigned char ihash[32]; + + /* Finish the inner SHA256 operation. */ + SHA256_Final(ihash, &ctx->ictx); + + /* Feed the inner hash to the outer SHA256 operation. */ + SHA256_Update(&ctx->octx, ihash, 32); + + /* Finish the outer SHA256 operation. */ + SHA256_Final(digest, &ctx->octx); + + /* Clean the stack. */ + memset(ihash, 0, 32); +} + +/** + * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): + * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and + * write the output to buf. The value dkLen must be at most 32 * (2^32 - 1). + */ +void +PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt, + size_t saltlen, uint64_t c, uint8_t * buf, size_t dkLen) +{ + HMAC_SHA256_CTX PShctx, hctx; + size_t i; + uint8_t ivec[4]; + uint8_t U[32]; + uint8_t T[32]; + uint64_t j; + int k; + size_t clen; + + /* Compute HMAC state after processing P and S. */ + HMAC_SHA256_Init(&PShctx, passwd, passwdlen); + HMAC_SHA256_Update(&PShctx, salt, saltlen); + + /* Iterate through the blocks. */ + for (i = 0; i * 32 < dkLen; i++) { + /* Generate INT(i + 1). */ + be32enc(ivec, (uint32_t)(i + 1)); + + /* Compute U_1 = PRF(P, S || INT(i)). */ + memcpy(&hctx, &PShctx, sizeof(HMAC_SHA256_CTX)); + HMAC_SHA256_Update(&hctx, ivec, 4); + HMAC_SHA256_Final(U, &hctx); + + /* T_i = U_1 ... */ + memcpy(T, U, 32); + + for (j = 2; j <= c; j++) { + /* Compute U_j. */ + HMAC_SHA256_Init(&hctx, passwd, passwdlen); + HMAC_SHA256_Update(&hctx, U, 32); + HMAC_SHA256_Final(U, &hctx); + + /* ... xor U_j ... */ + for (k = 0; k < 32; k++) + T[k] ^= U[k]; + } + + /* Copy as many bytes as necessary into buf. */ + clen = dkLen - i * 32; + if (clen > 32) + clen = 32; + memcpy(&buf[i * 32], T, clen); + } + + /* Clean PShctx, since we never called _Final on it. */ + memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX)); +} + diff --git a/src/pbkdf2.h b/src/pbkdf2.h new file mode 100644 index 0000000..4c55fd9 --- /dev/null +++ b/src/pbkdf2.h @@ -0,0 +1,27 @@ +// Copyright (c) 2013 NovaCoin Developers + +#ifndef PBKDF2_H +#define PBKDF2_H + +#include +#include + +typedef struct HMAC_SHA256Context { + SHA256_CTX ictx; + SHA256_CTX octx; +} HMAC_SHA256_CTX; + +void +HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen); + +void +HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void *in, size_t len); + +void +HMAC_SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX * ctx); + +void +PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt, + size_t saltlen, uint64_t c, uint8_t * buf, size_t dkLen); + +#endif // PBKDF2_H diff --git a/src/protocol.cpp b/src/protocol.cpp new file mode 100644 index 0000000..d48dfab --- /dev/null +++ b/src/protocol.cpp @@ -0,0 +1,141 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "protocol.h" +#include "util.h" +#include "netbase.h" + +#ifndef WIN32 +# include +#endif + +static const char* ppszTypeName[] = +{ + "ERROR", + "tx", + "block", +}; + +CMessageHeader::CMessageHeader() +{ + memcpy(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE); + memset(pchCommand, 0, sizeof(pchCommand)); + nMessageSize = -1; + nChecksum = 0; +} + +CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn) +{ + memcpy(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE); + memset(pchCommand, 0, sizeof(pchCommand)); + strncpy(pchCommand, pszCommand, COMMAND_SIZE); + nMessageSize = nMessageSizeIn; + nChecksum = 0; +} + +std::string CMessageHeader::GetCommand() const +{ + return std::string(pchCommand, pchCommand + strnlen(pchCommand, COMMAND_SIZE)); +} + +bool CMessageHeader::IsValid() const +{ + // Check start string + if (memcmp(pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE) != 0) + return false; + + // Check the command string for errors + for (const char* p1 = pchCommand; p1 < pchCommand + COMMAND_SIZE; p1++) + { + if (*p1 == 0) + { + // Must be all zeros after the first zero + for (; p1 < pchCommand + COMMAND_SIZE; p1++) + if (*p1 != 0) + return false; + } + else if (*p1 < ' ' || *p1 > 0x7E) + return false; + } + + // Message size + if (nMessageSize > MAX_SIZE) + { + LogPrintf("CMessageHeader::IsValid() : (%s, %u bytes) nMessageSize > MAX_SIZE\n", GetCommand(), nMessageSize); + return false; + } + + return true; +} + + + +CAddress::CAddress() : CService() +{ + Init(); +} + +CAddress::CAddress(CService ipIn, uint64_t nServicesIn) : CService(ipIn) +{ + Init(); + nServices = nServicesIn; +} + +void CAddress::Init() +{ + nServices = NODE_NETWORK; + nTime = 100000000; + nLastTry = 0; +} + +CInv::CInv() +{ + type = 0; + hash = 0; +} + +CInv::CInv(int typeIn, const uint256& hashIn) +{ + type = typeIn; + hash = hashIn; +} + +CInv::CInv(const std::string& strType, const uint256& hashIn) +{ + unsigned int i; + for (i = 1; i < ARRAYLEN(ppszTypeName); i++) + { + if (strType == ppszTypeName[i]) + { + type = i; + break; + } + } + if (i == ARRAYLEN(ppszTypeName)) + throw std::out_of_range(strprintf("CInv::CInv(string, uint256) : unknown type '%s'", strType)); + hash = hashIn; +} + +bool operator<(const CInv& a, const CInv& b) +{ + return (a.type < b.type || (a.type == b.type && a.hash < b.hash)); +} + +bool CInv::IsKnownType() const +{ + return (type >= 1 && type < (int)ARRAYLEN(ppszTypeName)); +} + +const char* CInv::GetCommand() const +{ + if (!IsKnownType()) + throw std::out_of_range(strprintf("CInv::GetCommand() : type=%d unknown type", type)); + return ppszTypeName[type]; +} + +std::string CInv::ToString() const +{ + return strprintf("%s %s", GetCommand(), hash.ToString()); +} diff --git a/src/protocol.h b/src/protocol.h new file mode 100644 index 0000000..df6d4d6 --- /dev/null +++ b/src/protocol.h @@ -0,0 +1,129 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef __cplusplus +# error This header can only be compiled as C++. +#endif + +#ifndef __INCLUDED_PROTOCOL_H__ +#define __INCLUDED_PROTOCOL_H__ + +#include "chainparams.h" +#include "serialize.h" +#include "netbase.h" +#include +#include "uint256.h" + +/** Message header. + * (4) message start. + * (12) command. + * (4) size. + * (4) checksum. + */ +class CMessageHeader +{ + public: + CMessageHeader(); + CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn); + + std::string GetCommand() const; + bool IsValid() const; + + IMPLEMENT_SERIALIZE + ( + READWRITE(FLATDATA(pchMessageStart)); + READWRITE(FLATDATA(pchCommand)); + READWRITE(nMessageSize); + READWRITE(nChecksum); + ) + + // TODO: make private (improves encapsulation) + public: + enum { + COMMAND_SIZE=12, + MESSAGE_SIZE_SIZE=sizeof(int), + CHECKSUM_SIZE=sizeof(int), + + MESSAGE_SIZE_OFFSET=MESSAGE_START_SIZE+COMMAND_SIZE, + CHECKSUM_OFFSET=MESSAGE_SIZE_OFFSET+MESSAGE_SIZE_SIZE, + HEADER_SIZE=MESSAGE_START_SIZE+COMMAND_SIZE+MESSAGE_SIZE_SIZE+CHECKSUM_SIZE + }; + char pchMessageStart[MESSAGE_START_SIZE]; + char pchCommand[COMMAND_SIZE]; + unsigned int nMessageSize; + unsigned int nChecksum; +}; + +/** nServices flags */ +enum +{ + NODE_NETWORK = (1 << 0), +}; + +/** A CService with information about it as peer */ +class CAddress : public CService +{ + public: + CAddress(); + explicit CAddress(CService ipIn, uint64_t nServicesIn=NODE_NETWORK); + + void Init(); + + IMPLEMENT_SERIALIZE + ( + CAddress* pthis = const_cast(this); + CService* pip = (CService*)pthis; + if (fRead) + pthis->Init(); + if (nType & SER_DISK) + READWRITE(nVersion); + if ((nType & SER_DISK) || + (nVersion >= CADDR_TIME_VERSION && !(nType & SER_GETHASH))) + READWRITE(nTime); + READWRITE(nServices); + READWRITE(*pip); + ) + + + // TODO: make private (improves encapsulation) + public: + uint64_t nServices; + + // disk and network only + unsigned int nTime; + + // memory only + int64_t nLastTry; +}; + +/** inv message data */ +class CInv +{ + public: + CInv(); + CInv(int typeIn, const uint256& hashIn); + CInv(const std::string& strType, const uint256& hashIn); + + IMPLEMENT_SERIALIZE + ( + READWRITE(type); + READWRITE(hash); + ) + + friend bool operator<(const CInv& a, const CInv& b); + + bool IsKnownType() const; + const char* GetCommand() const; + std::string ToString() const; + + // TODO: make private (improves encapsulation) + public: + int type; + uint256 hash; +}; + + + +#endif // __INCLUDED_PROTOCOL_H__ diff --git a/src/qt/aboutdialog.cpp b/src/qt/aboutdialog.cpp new file mode 100644 index 0000000..fb68579 --- /dev/null +++ b/src/qt/aboutdialog.cpp @@ -0,0 +1,30 @@ +#include "aboutdialog.h" +#include "ui_aboutdialog.h" +#include "clientmodel.h" + +#include "version.h" + +AboutDialog::AboutDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::AboutDialog) +{ + ui->setupUi(this); +} + +void AboutDialog::setModel(ClientModel *model) +{ + if(model) + { + ui->versionLabel->setText(model->formatFullVersion()); + } +} + +AboutDialog::~AboutDialog() +{ + delete ui; +} + +void AboutDialog::on_buttonBox_accepted() +{ + close(); +} diff --git a/src/qt/aboutdialog.h b/src/qt/aboutdialog.h new file mode 100644 index 0000000..ad71f93 --- /dev/null +++ b/src/qt/aboutdialog.h @@ -0,0 +1,28 @@ +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include + +namespace Ui { + class AboutDialog; +} +class ClientModel; + +/** "About" dialog box */ +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget *parent = 0); + ~AboutDialog(); + + void setModel(ClientModel *model); +private: + Ui::AboutDialog *ui; + +private slots: + void on_buttonBox_accepted(); +}; + +#endif // ABOUTDIALOG_H diff --git a/src/qt/addeditadrenalinenode.cpp b/src/qt/addeditadrenalinenode.cpp new file mode 100644 index 0000000..513b841 --- /dev/null +++ b/src/qt/addeditadrenalinenode.cpp @@ -0,0 +1,103 @@ +#include "addeditadrenalinenode.h" +#include "ui_addeditadrenalinenode.h" + +#include "walletdb.h" +#include "wallet.h" +#include "ui_interface.h" +#include "util.h" +#include "key.h" +#include "script.h" +#include "init.h" +#include "base58.h" +#include + +AddEditAdrenalineNode::AddEditAdrenalineNode(QWidget *parent) : + QDialog(parent), + ui(new Ui::AddEditAdrenalineNode) +{ + ui->setupUi(this); + +} + +AddEditAdrenalineNode::~AddEditAdrenalineNode() +{ + delete ui; +} + + +void AddEditAdrenalineNode::on_okButton_clicked() +{ + if(ui->aliasLineEdit->text() == "") + { + QMessageBox msg; + msg.setText("Please enter an alias."); + msg.exec(); + return; + } + else if(ui->addressLineEdit->text() == "") + { + QMessageBox msg; + msg.setText("Please enter an address."); + msg.exec(); + return; + } + else + { + CAdrenalineNodeConfig c; + c.sAlias = ui->aliasLineEdit->text().toStdString(); + c.sAddress = ui->addressLineEdit->text().toStdString(); + CKey secret; + secret.MakeNewKey(false); + c.sMasternodePrivKey = CBitcoinSecret(secret).ToString(); + + CWalletDB walletdb(pwalletMain->strWalletFile); + CAccount account; + walletdb.ReadAccount(c.sAlias, account); + bool bKeyUsed = false; + bool bForceNew = false; + + // Check if the current key has been used + if (account.vchPubKey.IsValid()) + { + CScript scriptPubKey; + scriptPubKey.SetDestination(account.vchPubKey.GetID()); + for (map::iterator it = pwalletMain->mapWallet.begin(); + it != pwalletMain->mapWallet.end() && account.vchPubKey.IsValid(); + ++it) + { + const CWalletTx& wtx = (*it).second; + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + if (txout.scriptPubKey == scriptPubKey) + bKeyUsed = true; + } + } + + // Generate a new key + if (!account.vchPubKey.IsValid() || bForceNew || bKeyUsed) + { + if (!pwalletMain->GetKeyFromPool(account.vchPubKey)) + { + QMessageBox msg; + msg.setText("Keypool ran out, please call keypoolrefill first."); + msg.exec(); + return; + } + pwalletMain->SetAddressBookName(account.vchPubKey.GetID(), c.sAlias); + walletdb.WriteAccount(c.sAlias, account); + } + + c.sCollateralAddress = CBitcoinAddress(account.vchPubKey.GetID()).ToString(); + + pwalletMain->mapMyAdrenalineNodes.insert(make_pair(c.sAddress, c)); + walletdb.WriteAdrenalineNodeConfig(c.sAddress, c); + uiInterface.NotifyAdrenalineNodeChanged(c); + + accept(); + } +} + +void AddEditAdrenalineNode::on_cancelButton_clicked() +{ + reject(); +} + diff --git a/src/qt/addeditadrenalinenode.h b/src/qt/addeditadrenalinenode.h new file mode 100644 index 0000000..488540f --- /dev/null +++ b/src/qt/addeditadrenalinenode.h @@ -0,0 +1,31 @@ +#ifndef ADDEDITADRENALINENODE_H +#define ADDEDITADRENALINENODE_H + +#include + +namespace Ui { +class AddEditAdrenalineNode; +} + + +class AddEditAdrenalineNode : public QDialog +{ + Q_OBJECT + +public: + explicit AddEditAdrenalineNode(QWidget *parent = 0); + ~AddEditAdrenalineNode(); + +protected: + +private slots: + void on_okButton_clicked(); + void on_cancelButton_clicked(); + +signals: + +private: + Ui::AddEditAdrenalineNode *ui; +}; + +#endif // ADDEDITADRENALINENODE_H diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp new file mode 100644 index 0000000..e9e9f12 --- /dev/null +++ b/src/qt/addressbookpage.cpp @@ -0,0 +1,374 @@ +#include "addressbookpage.h" +#include "ui_addressbookpage.h" + +#include "addresstablemodel.h" +#include "optionsmodel.h" +#include "bitcoingui.h" +#include "editaddressdialog.h" +#include "csvmodelwriter.h" +#include "guiutil.h" + +#ifdef USE_QRCODE +#include "qrcodedialog.h" +#endif + +#include +#include +#include +#include + +AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) : + QDialog(parent), + ui(new Ui::AddressBookPage), + model(0), + optionsModel(0), + mode(mode), + tab(tab) +{ + ui->setupUi(this); + +#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac + ui->newAddressButton->setIcon(QIcon()); + ui->copyToClipboard->setIcon(QIcon()); + ui->deleteButton->setIcon(QIcon()); +#endif + +#ifndef USE_QRCODE + ui->showQRCode->setVisible(false); +#endif + + switch(mode) + { + case ForSending: + connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept())); + ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); + ui->tableView->setFocus(); + break; + case ForEditing: + ui->buttonBox->setVisible(false); + break; + } + switch(tab) + { + case SendingTab: + ui->labelExplanation->setVisible(false); + ui->deleteButton->setVisible(true); + ui->signMessage->setVisible(false); + break; + case ReceivingTab: + ui->deleteButton->setVisible(false); + ui->signMessage->setVisible(true); + break; + } + + // Context menu actions + QAction *copyLabelAction = new QAction(tr("Copy &Label"), this); + QAction *copyAddressAction = new QAction(ui->copyToClipboard->text(), this); + QAction *editAction = new QAction(tr("&Edit"), this); + QAction *showQRCodeAction = new QAction(ui->showQRCode->text(), this); + QAction *signMessageAction = new QAction(ui->signMessage->text(), this); + QAction *verifyMessageAction = new QAction(ui->verifyMessage->text(), this); + deleteAction = new QAction(ui->deleteButton->text(), this); + + // Build context menu + contextMenu = new QMenu(); + contextMenu->addAction(copyAddressAction); + contextMenu->addAction(copyLabelAction); + contextMenu->addAction(editAction); + if(tab == SendingTab) + contextMenu->addAction(deleteAction); + contextMenu->addSeparator(); + contextMenu->addAction(showQRCodeAction); + if(tab == ReceivingTab) + contextMenu->addAction(signMessageAction); + else if(tab == SendingTab) + contextMenu->addAction(verifyMessageAction); + + // Connect signals for context menu actions + connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyToClipboard_clicked())); + connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction())); + connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction())); + connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteButton_clicked())); + connect(showQRCodeAction, SIGNAL(triggered()), this, SLOT(on_showQRCode_clicked())); + connect(signMessageAction, SIGNAL(triggered()), this, SLOT(on_signMessage_clicked())); + connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(on_verifyMessage_clicked())); + + connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); + + // Pass through accept action from button box + connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); +} + +AddressBookPage::~AddressBookPage() +{ + delete ui; +} + +void AddressBookPage::setModel(AddressTableModel *model) +{ + this->model = model; + if(!model) + return; + + proxyModel = new QSortFilterProxyModel(this); + proxyModel->setSourceModel(model); + proxyModel->setDynamicSortFilter(true); + proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + switch(tab) + { + case ReceivingTab: + // Receive filter + proxyModel->setFilterRole(AddressTableModel::TypeRole); + proxyModel->setFilterFixedString(AddressTableModel::Receive); + break; + case SendingTab: + // Send filter + proxyModel->setFilterRole(AddressTableModel::TypeRole); + proxyModel->setFilterFixedString(AddressTableModel::Send); + break; + } + ui->tableView->setModel(proxyModel); + ui->tableView->sortByColumn(0, Qt::AscendingOrder); + + // Set column widths + ui->tableView->horizontalHeader()->resizeSection( + AddressTableModel::Address, 320); + ui->tableView->horizontalHeader()->setResizeMode( + AddressTableModel::Label, QHeaderView::Stretch); + + connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + this, SLOT(selectionChanged())); + + // Select row for newly created address + connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(selectNewAddress(QModelIndex,int,int))); + + selectionChanged(); +} + +void AddressBookPage::setOptionsModel(OptionsModel *optionsModel) +{ + this->optionsModel = optionsModel; +} + +void AddressBookPage::on_copyToClipboard_clicked() +{ + GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address); +} + +void AddressBookPage::onCopyLabelAction() +{ + GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Label); +} + +void AddressBookPage::onEditAction() +{ + if(!ui->tableView->selectionModel()) + return; + QModelIndexList indexes = ui->tableView->selectionModel()->selectedRows(); + if(indexes.isEmpty()) + return; + + EditAddressDialog dlg( + tab == SendingTab ? + EditAddressDialog::EditSendingAddress : + EditAddressDialog::EditReceivingAddress); + dlg.setModel(model); + QModelIndex origIndex = proxyModel->mapToSource(indexes.at(0)); + dlg.loadRow(origIndex.row()); + dlg.exec(); +} + +void AddressBookPage::on_signMessage_clicked() +{ + QTableView *table = ui->tableView; + QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); + QString addr; + + foreach (QModelIndex index, indexes) + { + QVariant address = index.data(); + addr = address.toString(); + } + + emit signMessage(addr); +} + +void AddressBookPage::on_verifyMessage_clicked() +{ + QTableView *table = ui->tableView; + QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); + QString addr; + + foreach (QModelIndex index, indexes) + { + QVariant address = index.data(); + addr = address.toString(); + } + + emit verifyMessage(addr); +} + +void AddressBookPage::on_newAddressButton_clicked() +{ + if(!model) + return; + EditAddressDialog dlg( + tab == SendingTab ? + EditAddressDialog::NewSendingAddress : + EditAddressDialog::NewReceivingAddress, this); + dlg.setModel(model); + if(dlg.exec()) + { + newAddressToSelect = dlg.getAddress(); + } +} + +void AddressBookPage::on_deleteButton_clicked() +{ + QTableView *table = ui->tableView; + if(!table->selectionModel()) + return; + QModelIndexList indexes = table->selectionModel()->selectedRows(); + if(!indexes.isEmpty()) + { + table->model()->removeRow(indexes.at(0).row()); + } +} + +void AddressBookPage::selectionChanged() +{ + // Set button states based on selected tab and selection + QTableView *table = ui->tableView; + if(!table->selectionModel()) + return; + + if(table->selectionModel()->hasSelection()) + { + switch(tab) + { + case SendingTab: + // In sending tab, allow deletion of selection + ui->deleteButton->setEnabled(true); + ui->deleteButton->setVisible(true); + deleteAction->setEnabled(true); + ui->signMessage->setEnabled(false); + ui->signMessage->setVisible(false); + ui->verifyMessage->setEnabled(true); + ui->verifyMessage->setVisible(true); + break; + case ReceivingTab: + // Deleting receiving addresses, however, is not allowed + ui->deleteButton->setEnabled(false); + ui->deleteButton->setVisible(false); + deleteAction->setEnabled(false); + ui->signMessage->setEnabled(true); + ui->signMessage->setVisible(true); + ui->verifyMessage->setEnabled(false); + ui->verifyMessage->setVisible(false); + break; + } + ui->copyToClipboard->setEnabled(true); + ui->showQRCode->setEnabled(true); + } + else + { + ui->deleteButton->setEnabled(false); + ui->showQRCode->setEnabled(false); + ui->copyToClipboard->setEnabled(false); + ui->signMessage->setEnabled(false); + ui->verifyMessage->setEnabled(false); + } +} + +void AddressBookPage::done(int retval) +{ + QTableView *table = ui->tableView; + if(!table->selectionModel() || !table->model()) + return; + // When this is a tab/widget and not a model dialog, ignore "done" + if(mode == ForEditing) + return; + + // Figure out which address was selected, and return it + QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); + + foreach (QModelIndex index, indexes) + { + QVariant address = table->model()->data(index); + returnValue = address.toString(); + } + + if(returnValue.isEmpty()) + { + // If no address entry selected, return rejected + retval = Rejected; + } + + QDialog::done(retval); +} + +void AddressBookPage::exportClicked() +{ + // CSV is currently the only supported format + QString filename = GUIUtil::getSaveFileName( + this, + tr("Export Address Book Data"), QString(), + tr("Comma separated file (*.csv)")); + + if (filename.isNull()) return; + + CSVModelWriter writer(filename); + + // name, column, role + writer.setModel(proxyModel); + writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole); + writer.addColumn("Address", AddressTableModel::Address, Qt::EditRole); + + if(!writer.write()) + { + QMessageBox::critical(this, tr("Error exporting"), tr("Could not write to file %1.").arg(filename), + QMessageBox::Abort, QMessageBox::Abort); + } +} + +void AddressBookPage::on_showQRCode_clicked() +{ +#ifdef USE_QRCODE + QTableView *table = ui->tableView; + QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); + + foreach (QModelIndex index, indexes) + { + QString address = index.data().toString(), label = index.sibling(index.row(), 0).data(Qt::EditRole).toString(); + + QRCodeDialog *dialog = new QRCodeDialog(address, label, tab == ReceivingTab, this); + if(optionsModel) + dialog->setModel(optionsModel); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); + } +#endif +} + +void AddressBookPage::contextualMenu(const QPoint &point) +{ + QModelIndex index = ui->tableView->indexAt(point); + if(index.isValid()) + { + contextMenu->exec(QCursor::pos()); + } +} + +void AddressBookPage::selectNewAddress(const QModelIndex &parent, int begin, int end) +{ + QModelIndex idx = proxyModel->mapFromSource(model->index(begin, AddressTableModel::Address, parent)); + if(idx.isValid() && (idx.data(Qt::EditRole).toString() == newAddressToSelect)) + { + // Select row of newly created address, once + ui->tableView->setFocus(); + ui->tableView->selectRow(idx.row()); + newAddressToSelect.clear(); + } +} diff --git a/src/qt/addressbookpage.h b/src/qt/addressbookpage.h new file mode 100644 index 0000000..7cd43cc --- /dev/null +++ b/src/qt/addressbookpage.h @@ -0,0 +1,85 @@ +#ifndef ADDRESSBOOKPAGE_H +#define ADDRESSBOOKPAGE_H + +#include + +namespace Ui { + class AddressBookPage; +} +class AddressTableModel; +class OptionsModel; + +QT_BEGIN_NAMESPACE +class QTableView; +class QItemSelection; +class QSortFilterProxyModel; +class QMenu; +class QModelIndex; +QT_END_NAMESPACE + +/** Widget that shows a list of sending or receiving addresses. + */ +class AddressBookPage : public QDialog +{ + Q_OBJECT + +public: + enum Tabs { + SendingTab = 0, + ReceivingTab = 1 + }; + + enum Mode { + ForSending, /**< Open address book to pick address for sending */ + ForEditing /**< Open address book for editing */ + }; + + explicit AddressBookPage(Mode mode, Tabs tab, QWidget *parent = 0); + ~AddressBookPage(); + + void setModel(AddressTableModel *model); + void setOptionsModel(OptionsModel *optionsModel); + const QString &getReturnValue() const { return returnValue; } + +public slots: + void done(int retval); + void exportClicked(); + +private: + Ui::AddressBookPage *ui; + AddressTableModel *model; + OptionsModel *optionsModel; + Mode mode; + Tabs tab; + QString returnValue; + QSortFilterProxyModel *proxyModel; + QMenu *contextMenu; + QAction *deleteAction; + QString newAddressToSelect; + +private slots: + void on_deleteButton_clicked(); + void on_newAddressButton_clicked(); + /** Copy address of currently selected address entry to clipboard */ + void on_copyToClipboard_clicked(); + void on_signMessage_clicked(); + void on_verifyMessage_clicked(); + void selectionChanged(); + void on_showQRCode_clicked(); + /** Spawn contextual menu (right mouse menu) for address book entry */ + void contextualMenu(const QPoint &point); + + /** Copy label of currently selected address entry to clipboard */ + void onCopyLabelAction(); + /** Edit currently selected address entry */ + void onEditAction(); + + /** New entry/entries were added to address table */ + void selectNewAddress(const QModelIndex &parent, int begin, int end); + +signals: + void signMessage(QString addr); + void verifyMessage(QString addr); +}; + +#endif // ADDRESSBOOKPAGE_H diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp new file mode 100644 index 0000000..8ea09c4 --- /dev/null +++ b/src/qt/addresstablemodel.cpp @@ -0,0 +1,516 @@ +#include "addresstablemodel.h" + +#include "guiutil.h" +#include "walletmodel.h" + +#include "wallet.h" +#include "base58.h" + +#include +#include + +const QString AddressTableModel::Send = "S"; +const QString AddressTableModel::Receive = "R"; + +struct AddressTableEntry +{ + enum Type { + Sending, + Receiving + }; + + Type type; + QString label; + QString address; + bool stealth; + + AddressTableEntry() {} + AddressTableEntry(Type type, const QString &label, const QString &address, const bool &stealth = false): + type(type), label(label), address(address), stealth(stealth) {} +}; + +struct AddressTableEntryLessThan +{ + bool operator()(const AddressTableEntry &a, const AddressTableEntry &b) const + { + return a.address < b.address; + } + bool operator()(const AddressTableEntry &a, const QString &b) const + { + return a.address < b; + } + bool operator()(const QString &a, const AddressTableEntry &b) const + { + return a < b.address; + } +}; + +// Private implementation +class AddressTablePriv +{ +public: + CWallet *wallet; + QList cachedAddressTable; + AddressTableModel *parent; + + AddressTablePriv(CWallet *wallet, AddressTableModel *parent): + wallet(wallet), parent(parent) {} + + void refreshAddressTable() + { + cachedAddressTable.clear(); + { + LOCK(wallet->cs_wallet); + BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& item, wallet->mapAddressBook) + { + const CBitcoinAddress& address = item.first; + const std::string& strName = item.second; + bool fMine = IsMine(*wallet, address.Get()); + cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending, + QString::fromStdString(strName), + QString::fromStdString(address.ToString()))); + } + + std::set::iterator it; + for (it = wallet->stealthAddresses.begin(); it != wallet->stealthAddresses.end(); ++it) + { + bool fMine = !(it->scan_secret.size() < 1); + cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending, + QString::fromStdString(it->label), + QString::fromStdString(it->Encoded()), + true)); + }; + } + // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order + qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan()); + } + + void updateEntry(const QString &address, const QString &label, bool isMine, int status) + { + // Find address / label in model + QList::iterator lower = qLowerBound( + cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan()); + QList::iterator upper = qUpperBound( + cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan()); + int lowerIndex = (lower - cachedAddressTable.begin()); + int upperIndex = (upper - cachedAddressTable.begin()); + bool inModel = (lower != upper); + AddressTableEntry::Type newEntryType = isMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending; + + switch(status) + { + case CT_NEW: + if(inModel) + { + qDebug() << "AddressTablePriv::updateEntry : Warning: Got CT_NEW, but entry is already in model"; + break; + } + parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex); + cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address)); + parent->endInsertRows(); + break; + case CT_UPDATED: + if(!inModel) + { + qDebug() << "AddressTablePriv::updateEntry : Warning: Got CT_UPDATED, but entry is not in model"; + break; + } + lower->type = newEntryType; + lower->label = label; + parent->emitDataChanged(lowerIndex); + break; + case CT_DELETED: + if(!inModel) + { + qDebug() << "AddressTablePriv::updateEntry : Warning: Got CT_DELETED, but entry is not in model"; + break; + } + parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1); + cachedAddressTable.erase(lower, upper); + parent->endRemoveRows(); + break; + } + } + + int size() + { + return cachedAddressTable.size(); + } + + AddressTableEntry *index(int idx) + { + if(idx >= 0 && idx < cachedAddressTable.size()) + { + return &cachedAddressTable[idx]; + } + else + { + return 0; + } + } +}; + +AddressTableModel::AddressTableModel(CWallet *wallet, WalletModel *parent) : + QAbstractTableModel(parent),walletModel(parent),wallet(wallet),priv(0) +{ + columns << tr("Label") << tr("Address"); + priv = new AddressTablePriv(wallet, this); + priv->refreshAddressTable(); +} + +AddressTableModel::~AddressTableModel() +{ + delete priv; +} + +int AddressTableModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return priv->size(); +} + +int AddressTableModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return columns.length(); +} + +QVariant AddressTableModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid()) + return QVariant(); + + AddressTableEntry *rec = static_cast(index.internalPointer()); + + if(role == Qt::DisplayRole || role == Qt::EditRole) + { + switch(index.column()) + { + case Label: + if(rec->label.isEmpty() && role == Qt::DisplayRole) + { + return tr("(no label)"); + } + else + { + return rec->label; + } + case Address: + return rec->address; + } + } + else if (role == Qt::FontRole) + { + QFont font; + if(index.column() == Address) + { + font = GUIUtil::bitcoinAddressFont(); + } + return font; + } + else if (role == TypeRole) + { + switch(rec->type) + { + case AddressTableEntry::Sending: + return Send; + case AddressTableEntry::Receiving: + return Receive; + default: break; + } + } + return QVariant(); +} + +bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if(!index.isValid()) + return false; + AddressTableEntry *rec = static_cast(index.internalPointer()); + + editStatus = OK; + std::string strTemp, strValue; + if(role == Qt::EditRole) + { + switch(index.column()) + { + case Label: + // Do nothing, if old label == new label + if(rec->label == value.toString()) + { + editStatus = NO_CHANGES; + return false; + } + + strTemp = rec->address.toStdString(); + if (IsStealthAddress(strTemp)) + { + strValue = value.toString().toStdString(); + wallet->UpdateStealthAddress(strTemp, strValue, false); + } else + { + wallet->SetAddressBookName(CBitcoinAddress(strTemp).Get(), value.toString().toStdString()); + } + break; + case Address: + std::string sTemp = value.toString().toStdString(); + if (IsStealthAddress(sTemp)) + { + printf("TODO\n"); + editStatus = INVALID_ADDRESS; + return false; + } + // Do nothing, if old address == new address + if(CBitcoinAddress(rec->address.toStdString()) == CBitcoinAddress(value.toString().toStdString())) + { + editStatus = NO_CHANGES; + return false; + } + // Refuse to set invalid address, set error status and return false + else if(!walletModel->validateAddress(value.toString())) + { + editStatus = INVALID_ADDRESS; + return false; + } + // Check for duplicate addresses to prevent accidental deletion of addresses, if you try + // to paste an existing address over another address (with a different label) + else if(wallet->mapAddressBook.count(CBitcoinAddress(value.toString().toStdString()).Get())) + { + editStatus = DUPLICATE_ADDRESS; + return false; + } + // Double-check that we're not overwriting a receiving address + else if(rec->type == AddressTableEntry::Sending) + { + { + LOCK(wallet->cs_wallet); + // Remove old entry + wallet->DelAddressBookName(CBitcoinAddress(rec->address.toStdString()).Get()); + // Add new entry with new address + wallet->SetAddressBookName(CBitcoinAddress(value.toString().toStdString()).Get(), rec->label.toStdString()); + } + } + break; + } + return true; + } + return false; +} + +QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(orientation == Qt::Horizontal) + { + if(role == Qt::DisplayRole) + { + return columns[section]; + } + } + return QVariant(); +} + +Qt::ItemFlags AddressTableModel::flags(const QModelIndex &index) const +{ + if(!index.isValid()) + return 0; + AddressTableEntry *rec = static_cast(index.internalPointer()); + + Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled; + // Can edit address and label for sending addresses, + // and only label for receiving addresses. + if(rec->type == AddressTableEntry::Sending || + (rec->type == AddressTableEntry::Receiving && index.column()==Label)) + { + retval |= Qt::ItemIsEditable; + } + return retval; +} + +QModelIndex AddressTableModel::index(int row, int column, const QModelIndex &parent) const +{ + Q_UNUSED(parent); + AddressTableEntry *data = priv->index(row); + if(data) + { + return createIndex(row, column, priv->index(row)); + } + else + { + return QModelIndex(); + } +} + +void AddressTableModel::updateEntry(const QString &address, const QString &label, bool isMine, int status) +{ + // Update address book model from Bitcoin core + priv->updateEntry(address, label, isMine, status); +} + +QString AddressTableModel::addRow(const QString &type, const QString &label, const QString &address, int addressType) +{ + std::string strLabel = label.toStdString(); + std::string strAddress = address.toStdString(); + + editStatus = OK; + + if(type == Send) + { + if (strAddress.length() > 75) + { + CStealthAddress sxAddr; + if (!sxAddr.SetEncoded(strAddress)) + { + editStatus = INVALID_ADDRESS; + return QString(); + } + + // -- Check for duplicate addresses + { + LOCK(wallet->cs_wallet); + + if (wallet->stealthAddresses.count(sxAddr)) + { + editStatus = DUPLICATE_ADDRESS; + return QString(); + }; + + sxAddr.label = strLabel; + wallet->AddStealthAddress(sxAddr); + } + + } else + { + if (!walletModel->validateAddress(address)) + { + editStatus = INVALID_ADDRESS; + return QString(); + }; + // Check for duplicate addresses + { + LOCK(wallet->cs_wallet); + if (wallet->mapAddressBook.count(CBitcoinAddress(strAddress).Get())) + { + editStatus = DUPLICATE_ADDRESS; + return QString(); + }; + + wallet->SetAddressBookName(CBitcoinAddress(strAddress).Get(), strLabel); + } + } + } + else if(type == Receive) + { + // Generate a new address to associate with given label + WalletModel::UnlockContext ctx(walletModel->requestUnlock()); + + if(!ctx.isValid()) + { + // Unlock wallet failed or was cancelled + editStatus = WALLET_UNLOCK_FAILURE; + return QString(); + } + + if (addressType == AT_Stealth) + { + CStealthAddress newStealthAddr; + std::string sError; + if (!wallet->NewStealthAddress(sError, strLabel, newStealthAddr) + || !wallet->AddStealthAddress(newStealthAddr)) + { + editStatus = KEY_GENERATION_FAILURE; + return QString(); + } + strAddress = newStealthAddr.Encoded(); + } else + { + CPubKey newKey; + if(!wallet->GetKeyFromPool(newKey)) + { + editStatus = KEY_GENERATION_FAILURE; + return QString(); + } + strAddress = CBitcoinAddress(newKey.GetID()).ToString(); + + { + LOCK(wallet->cs_wallet); + wallet->SetAddressBookName(CBitcoinAddress(strAddress).Get(), strLabel); + } + } + } + else + { + return QString(); + } + + + return QString::fromStdString(strAddress); +} + +bool AddressTableModel::removeRows(int row, int count, const QModelIndex &parent) +{ + Q_UNUSED(parent); + AddressTableEntry *rec = priv->index(row); + if(count != 1 || !rec || rec->type == AddressTableEntry::Receiving) + { + // Can only remove one row at a time, and cannot remove rows not in model. + // Also refuse to remove receiving addresses. + return false; + } + { + LOCK(wallet->cs_wallet); + wallet->DelAddressBookName(CBitcoinAddress(rec->address.toStdString()).Get()); + } + return true; +} + +/* Look up label for address in address book, if not found return empty string. + */ +QString AddressTableModel::labelForAddress(const QString &address) const +{ + { + LOCK(wallet->cs_wallet); + std::string sAddr = address.toStdString(); + + if (sAddr.length() > 75) + { + CStealthAddress sxAddr; + if (!sxAddr.SetEncoded(sAddr)) + return QString(); + + std::set::iterator it; + it = wallet->stealthAddresses.find(sxAddr); + if (it == wallet->stealthAddresses.end()) + return QString(); + + return QString::fromStdString(it->label); + } else + { + CBitcoinAddress address_parsed(sAddr); + std::map::iterator mi = wallet->mapAddressBook.find(address_parsed.Get()); + if (mi != wallet->mapAddressBook.end()) + { + return QString::fromStdString(mi->second); + } + } + } + return QString(); +} + +int AddressTableModel::lookupAddress(const QString &address) const +{ + QModelIndexList lst = match(index(0, Address, QModelIndex()), + Qt::EditRole, address, 1, Qt::MatchExactly); + if(lst.isEmpty()) + { + return -1; + } + else + { + return lst.at(0).row(); + } +} + +void AddressTableModel::emitDataChanged(int idx) +{ + emit dataChanged(index(idx, 0, QModelIndex()), index(idx, columns.length()-1, QModelIndex())); +} diff --git a/src/qt/addresstablemodel.h b/src/qt/addresstablemodel.h new file mode 100644 index 0000000..639e6c9 --- /dev/null +++ b/src/qt/addresstablemodel.h @@ -0,0 +1,100 @@ +#ifndef ADDRESSTABLEMODEL_H +#define ADDRESSTABLEMODEL_H + +#include +#include + +class AddressTablePriv; +class CWallet; +class WalletModel; + +/** + Qt model of the address book in the core. This allows views to access and modify the address book. + */ +class AddressTableModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + explicit AddressTableModel(CWallet *wallet, WalletModel *parent = 0); + ~AddressTableModel(); + + enum AddressType { + AT_Unknown = 0, /**< User specified label */ + AT_Normal = 1, /**< Bitcoin address */ + AT_Stealth = 2 /**< Stealth address */ + }; + + enum ColumnIndex { + Label = 0, /**< User specified label */ + Address = 1, /**< Bitcoin address */ + Type = 2 /**< Address type */ + }; + + enum RoleIndex { + TypeRole = Qt::UserRole /**< Type of address (#Send or #Receive) */ + }; + + /** Return status of edit/insert operation */ + enum EditStatus { + OK, /**< Everything ok */ + NO_CHANGES, /**< No changes were made during edit operation */ + INVALID_ADDRESS, /**< Unparseable address */ + DUPLICATE_ADDRESS, /**< Address already in address book */ + WALLET_UNLOCK_FAILURE, /**< Wallet could not be unlocked to create new receiving address */ + KEY_GENERATION_FAILURE /**< Generating a new public key for a receiving address failed */ + }; + + static const QString Send; /**< Specifies send address */ + static const QString Receive; /**< Specifies receive address */ + + /** @name Methods overridden from QAbstractTableModel + @{*/ + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + bool setData(const QModelIndex &index, const QVariant &value, int role); + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QModelIndex index(int row, int column, const QModelIndex &parent) const; + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); + Qt::ItemFlags flags(const QModelIndex &index) const; + /*@}*/ + + /* Add an address to the model. + Returns the added address on success, and an empty string otherwise. + */ + QString addRow(const QString &type, const QString &label, const QString &address, int addressType); + + /* Look up label for address in address book, if not found return empty string. + */ + QString labelForAddress(const QString &address) const; + + /* Look up row index of an address in the model. + Return -1 if not found. + */ + int lookupAddress(const QString &address) const; + + EditStatus getEditStatus() const { return editStatus; } + +private: + WalletModel *walletModel; + CWallet *wallet; + AddressTablePriv *priv; + QStringList columns; + EditStatus editStatus; + + /** Notify listeners that data changed. */ + void emitDataChanged(int index); + +signals: + void defaultAddressChanged(const QString &address); + +public slots: + /* Update address list from core. + */ + void updateEntry(const QString &address, const QString &label, bool isMine, int status); + + friend class AddressTablePriv; +}; + +#endif // ADDRESSTABLEMODEL_H diff --git a/src/qt/adrenalinenodeconfigdialog.cpp b/src/qt/adrenalinenodeconfigdialog.cpp new file mode 100644 index 0000000..af6bb6c --- /dev/null +++ b/src/qt/adrenalinenodeconfigdialog.cpp @@ -0,0 +1,18 @@ +#include "adrenalinenodeconfigdialog.h" +#include "ui_adrenalinenodeconfigdialog.h" + +#include + +AdrenalineNodeConfigDialog::AdrenalineNodeConfigDialog(QWidget *parent, QString nodeAddress, QString privkey) : + QDialog(parent), + ui(new Ui::AdrenalineNodeConfigDialog) +{ + ui->setupUi(this); + QString desc = "rpcallowip=127.0.0.1
rpcuser=REPLACEME
rpcpassword=REPLACEME
staking=0
server=1
listen=1
port=REPLACEMEWITHYOURPORT
masternode=1
masternodeaddr=" + nodeAddress + "
masternodeprivkey=" + privkey + "
"; + ui->detailText->setHtml(desc); +} + +AdrenalineNodeConfigDialog::~AdrenalineNodeConfigDialog() +{ + delete ui; +} diff --git a/src/qt/adrenalinenodeconfigdialog.h b/src/qt/adrenalinenodeconfigdialog.h new file mode 100644 index 0000000..e8f76b7 --- /dev/null +++ b/src/qt/adrenalinenodeconfigdialog.h @@ -0,0 +1,27 @@ +#ifndef ADRENALINENODECONFIGDIALOG_H +#define ADRENALINENODECONFIGDIALOG_H + +#include + +namespace Ui { + class AdrenalineNodeConfigDialog; +} + +QT_BEGIN_NAMESPACE +class QModelIndex; +QT_END_NAMESPACE + +/** Dialog showing transaction details. */ +class AdrenalineNodeConfigDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AdrenalineNodeConfigDialog(QWidget *parent = 0, QString nodeAddress = "123.456.789.123:32111", QString privkey="MASTERNODEPRIVKEY"); + ~AdrenalineNodeConfigDialog(); + +private: + Ui::AdrenalineNodeConfigDialog *ui; +}; + +#endif // ADRENALINENODECONFIGDIALOG_H diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp new file mode 100644 index 0000000..13e1732 --- /dev/null +++ b/src/qt/askpassphrasedialog.cpp @@ -0,0 +1,270 @@ +#include "askpassphrasedialog.h" +#include "ui_askpassphrasedialog.h" + +#include "guiconstants.h" +#include "walletmodel.h" + +#include +#include +#include + +extern bool fWalletUnlockStakingOnly; + +AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) : + QDialog(parent), + ui(new Ui::AskPassphraseDialog), + mode(mode), + model(0), + fCapsLock(false) +{ + ui->setupUi(this); + ui->passEdit1->setMaxLength(MAX_PASSPHRASE_SIZE); + ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE); + ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE); + + // Setup Caps Lock detection. + ui->passEdit1->installEventFilter(this); + ui->passEdit2->installEventFilter(this); + ui->passEdit3->installEventFilter(this); + + ui->stakingCheckBox->setChecked(fWalletUnlockStakingOnly); + + switch(mode) + { + case Encrypt: // Ask passphrase x2 + ui->passLabel1->hide(); + ui->passEdit1->hide(); + ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.
Please use a passphrase of ten or more random characters, or eight or more words.")); + setWindowTitle(tr("Encrypt wallet")); + break; + case UnlockStaking: + ui->stakingCheckBox->setChecked(true); + ui->stakingCheckBox->show(); + // fallthru + case Unlock: // Ask passphrase + ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet.")); + ui->passLabel2->hide(); + ui->passEdit2->hide(); + ui->passLabel3->hide(); + ui->passEdit3->hide(); + setWindowTitle(tr("Unlock wallet")); + break; + case Decrypt: // Ask passphrase + ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet.")); + ui->passLabel2->hide(); + ui->passEdit2->hide(); + ui->passLabel3->hide(); + ui->passEdit3->hide(); + setWindowTitle(tr("Decrypt wallet")); + break; + case ChangePass: // Ask old passphrase + new passphrase x2 + setWindowTitle(tr("Change passphrase")); + ui->warningLabel->setText(tr("Enter the old and new passphrase to the wallet.")); + break; + } + + textChanged(); + connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); + connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); + connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); +} + +AskPassphraseDialog::~AskPassphraseDialog() +{ + secureClearPassFields(); + delete ui; +} + +void AskPassphraseDialog::setModel(WalletModel *model) +{ + this->model = model; +} + +void AskPassphraseDialog::accept() +{ + SecureString oldpass, newpass1, newpass2; + if(!model) + return; + oldpass.reserve(MAX_PASSPHRASE_SIZE); + newpass1.reserve(MAX_PASSPHRASE_SIZE); + newpass2.reserve(MAX_PASSPHRASE_SIZE); + // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) + // Alternately, find a way to make this input mlock()'d to begin with. + oldpass.assign(ui->passEdit1->text().toStdString().c_str()); + newpass1.assign(ui->passEdit2->text().toStdString().c_str()); + newpass2.assign(ui->passEdit3->text().toStdString().c_str()); + + secureClearPassFields(); + + switch(mode) + { + case Encrypt: { + if(newpass1.empty() || newpass2.empty()) + { + // Cannot encrypt with empty passphrase + break; + } + QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wallet encryption"), + tr("Warning: If you encrypt your wallet and lose your passphrase, you will LOSE ALL OF YOUR COINS!") + "

" + tr("Are you sure you wish to encrypt your wallet?"), + QMessageBox::Yes|QMessageBox::Cancel, + QMessageBox::Cancel); + if(retval == QMessageBox::Yes) + { + if(newpass1 == newpass2) + { + if(model->setWalletEncrypted(true, newpass1)) + { + QMessageBox::warning(this, tr("Wallet encrypted"), + "" + + tr("SONO will close now to finish the encryption process. " + "Remember that encrypting your wallet cannot fully protect " + "your coins from being stolen by malware infecting your computer.") + + "

" + + tr("IMPORTANT: Any previous backups you have made of your wallet file " + "should be replaced with the newly generated, encrypted wallet file. " + "For security reasons, previous backups of the unencrypted wallet file " + "will become useless as soon as you start using the new, encrypted wallet.") + + "
"); + QApplication::quit(); + } + else + { + QMessageBox::critical(this, tr("Wallet encryption failed"), + tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted.")); + } + QDialog::accept(); // Success + } + else + { + QMessageBox::critical(this, tr("Wallet encryption failed"), + tr("The supplied passphrases do not match.")); + } + } + else + { + QDialog::reject(); // Cancelled + } + } break; + case UnlockStaking: + case Unlock: + if(!model->setWalletLocked(false, oldpass)) + { + QMessageBox::critical(this, tr("Wallet unlock failed"), + tr("The passphrase entered for the wallet decryption was incorrect.")); + } + else + { + fWalletUnlockStakingOnly = ui->stakingCheckBox->isChecked(); + QDialog::accept(); // Success + } + break; + case Decrypt: + if(!model->setWalletEncrypted(false, oldpass)) + { + QMessageBox::critical(this, tr("Wallet decryption failed"), + tr("The passphrase entered for the wallet decryption was incorrect.")); + } + else + { + QDialog::accept(); // Success + } + break; + case ChangePass: + if(newpass1 == newpass2) + { + if(model->changePassphrase(oldpass, newpass1)) + { + QMessageBox::information(this, tr("Wallet encrypted"), + tr("Wallet passphrase was successfully changed.")); + QDialog::accept(); // Success + } + else + { + QMessageBox::critical(this, tr("Wallet encryption failed"), + tr("The passphrase entered for the wallet decryption was incorrect.")); + } + } + else + { + QMessageBox::critical(this, tr("Wallet encryption failed"), + tr("The supplied passphrases do not match.")); + } + break; + } +} + +void AskPassphraseDialog::textChanged() +{ + // Validate input, set Ok button to enabled when acceptable + bool acceptable = false; + switch(mode) + { + case Encrypt: // New passphrase x2 + acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty(); + break; + case UnlockStaking: + case Unlock: // Old passphrase x1 + case Decrypt: + acceptable = !ui->passEdit1->text().isEmpty(); + break; + case ChangePass: // Old passphrase x1, new passphrase x2 + acceptable = !ui->passEdit1->text().isEmpty() && !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty(); + break; + } + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable); +} + +bool AskPassphraseDialog::event(QEvent *event) +{ + // Detect Caps Lock key press. + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast(event); + if (ke->key() == Qt::Key_CapsLock) { + fCapsLock = !fCapsLock; + } + if (fCapsLock) { + ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!")); + } else { + ui->capsLabel->clear(); + } + } + return QWidget::event(event); +} + +bool AskPassphraseDialog::eventFilter(QObject *object, QEvent *event) +{ + /* Detect Caps Lock. + * There is no good OS-independent way to check a key state in Qt, but we + * can detect Caps Lock by checking for the following condition: + * Shift key is down and the result is a lower case character, or + * Shift key is not down and the result is an upper case character. + */ + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast(event); + QString str = ke->text(); + if (str.length() != 0) { + const QChar *psz = str.unicode(); + bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0; + if ((fShift && psz->isLower()) || (!fShift && psz->isUpper())) { + fCapsLock = true; + ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!")); + } else if (psz->isLetter()) { + fCapsLock = false; + ui->capsLabel->clear(); + } + } + } + return QDialog::eventFilter(object, event); +} + +void AskPassphraseDialog::secureClearPassFields() +{ + // Attempt to overwrite text so that they do not linger around in memory + ui->passEdit1->setText(QString(" ").repeated(ui->passEdit1->text().size())); + ui->passEdit2->setText(QString(" ").repeated(ui->passEdit2->text().size())); + ui->passEdit3->setText(QString(" ").repeated(ui->passEdit3->text().size())); + + ui->passEdit1->clear(); + ui->passEdit2->clear(); + ui->passEdit3->clear(); +} diff --git a/src/qt/askpassphrasedialog.h b/src/qt/askpassphrasedialog.h new file mode 100644 index 0000000..5cde735 --- /dev/null +++ b/src/qt/askpassphrasedialog.h @@ -0,0 +1,46 @@ +#ifndef ASKPASSPHRASEDIALOG_H +#define ASKPASSPHRASEDIALOG_H + +#include + +namespace Ui { + class AskPassphraseDialog; +} +class WalletModel; + +/** Multifunctional dialog to ask for passphrases. Used for encryption, unlocking, and changing the passphrase. + */ +class AskPassphraseDialog : public QDialog +{ + Q_OBJECT + +public: + enum Mode { + Encrypt, /**< Ask passphrase twice and encrypt */ + UnlockStaking, /**< Ask passphrase and unlock */ + Unlock, /**< Ask passphrase and unlock */ + ChangePass, /**< Ask old passphrase + new passphrase twice */ + Decrypt /**< Ask passphrase and decrypt wallet */ + }; + + explicit AskPassphraseDialog(Mode mode, QWidget *parent = 0); + ~AskPassphraseDialog(); + + void accept(); + + void setModel(WalletModel *model); + +private: + Ui::AskPassphraseDialog *ui; + Mode mode; + WalletModel *model; + bool fCapsLock; + +private slots: + void textChanged(); + bool event(QEvent *event); + bool eventFilter(QObject *, QEvent *event); + void secureClearPassFields(); +}; + +#endif // ASKPASSPHRASEDIALOG_H diff --git a/src/qt/bitcoin-qt.rc b/src/qt/bitcoin-qt.rc new file mode 100644 index 0000000..158f8a4 --- /dev/null +++ b/src/qt/bitcoin-qt.rc @@ -0,0 +1,37 @@ +IDI_ICON1 ICON DISCARDABLE "icons/SONO.ico" + +#include // needed for VERSIONINFO +#include "../../clientversion.h" // holds the needed client version information + +#define VER_PRODUCTVERSION CLIENT_VERSION_MAJOR,CLIENT_VERSION_MINOR,CLIENT_VERSION_REVISION,CLIENT_VERSION_BUILD +#define VER_PRODUCTVERSION_STR STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE(CLIENT_VERSION_MINOR) "." STRINGIZE(CLIENT_VERSION_REVISION) "." STRINGIZE(CLIENT_VERSION_BUILD) +#define VER_FILEVERSION VER_PRODUCTVERSION +#define VER_FILEVERSION_STR VER_PRODUCTVERSION_STR + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_FILEVERSION +PRODUCTVERSION VER_PRODUCTVERSION +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "216k155" // U.S. English - multilingual (hex) + BEGIN + VALUE "CompanyName", "SONO" + VALUE "FileDescription", "SONO-Qt (OSS GUI client for SONO)" + VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "InternalName", "SONO-qt" + VALUE "LegalCopyright", "Copyright © 2017 by 216k155 @Dra" + VALUE "LegalTrademarks1", "Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." + VALUE "OriginalFilename", "SONO-qt.exe" + VALUE "ProductName", "SONO-Qt" + VALUE "ProductVersion", VER_PRODUCTVERSION_STR + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1252 // language neutral - multilingual (decimal) + END +END diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp new file mode 100644 index 0000000..63388ff --- /dev/null +++ b/src/qt/bitcoin.cpp @@ -0,0 +1,322 @@ +/* + * W.J. van der Laan 2011-2012 + */ + +#include +#include "masternodeconfig.h" +#include "bitcoingui.h" +#include "clientmodel.h" +#include "walletmodel.h" +#include "optionsmodel.h" +#include "messagemodel.h" +#include "guiutil.h" +#include "guiconstants.h" +#include "init.h" +#include "util.h" +#include "wallet.h" +#include "ui_interface.h" +#include "paymentserver.h" +#ifdef Q_OS_MAC +#include "macdockiconhandler.h" +#endif + +#include +#include +#include +#include +#include +#include +#include + +#if defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED) +#define _BITCOIN_QT_PLUGINS_INCLUDED +#define __INSURE__ +#include +Q_IMPORT_PLUGIN(qcncodecs) +Q_IMPORT_PLUGIN(qjpcodecs) +Q_IMPORT_PLUGIN(qtwcodecs) +Q_IMPORT_PLUGIN(qkrcodecs) +Q_IMPORT_PLUGIN(qtaccessiblewidgets) +#endif + +// Need a global reference for the notifications to find the GUI +static BitcoinGUI *guiref; +static QSplashScreen *splashref; + +static void ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style) +{ + // Message from network thread + if(guiref) + { + bool modal = (style & CClientUIInterface::MODAL); + // In case of modal message, use blocking connection to wait for user to click a button + QMetaObject::invokeMethod(guiref, "message", + modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection, + Q_ARG(QString, QString::fromStdString(caption)), + Q_ARG(QString, QString::fromStdString(message)), + Q_ARG(bool, modal), + Q_ARG(unsigned int, style)); + } + else + { + LogPrintf("%s: %s\n", caption, message); + fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str()); + } +} + +static bool ThreadSafeAskFee(int64_t nFeeRequired, const std::string& strCaption) +{ + if(!guiref) + return false; + if(nFeeRequired < MIN_TX_FEE || nFeeRequired <= nTransactionFee || fDaemon) + return true; + bool payFee = false; + + QMetaObject::invokeMethod(guiref, "askFee", GUIUtil::blockingGUIThreadConnection(), + Q_ARG(qint64, nFeeRequired), + Q_ARG(bool*, &payFee)); + + return payFee; +} + +static void InitMessage(const std::string &message) +{ + if(splashref) + { + splashref->showMessage(QString::fromStdString(message), Qt::AlignBottom|Qt::AlignHCenter, QColor(197,31,38)); + QApplication::instance()->processEvents(); + } + LogPrintf("init message: %s\n", message); +} + +/* + Translate string to current locale using Qt. + */ +static std::string Translate(const char* psz) +{ + return QCoreApplication::translate("bitcoin-core", psz).toStdString(); +} + +/* Handle runaway exceptions. Shows a message box with the problem and quits the program. + */ +static void handleRunawayException(std::exception *e) +{ + PrintExceptionContinue(e, "Runaway exception"); + QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. SONO can no longer continue safely and will quit.") + QString("\n\n") + QString::fromStdString(strMiscWarning)); + exit(1); +} + +/* qDebug() message handler --> debug.log */ +#if QT_VERSION < 0x050000 +void DebugMessageHandler(QtMsgType type, const char * msg) +{ + const char *category = (type == QtDebugMsg) ? "qt" : NULL; + LogPrint(category, "GUI: %s\n", msg); +} +#else +void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg) +{ + const char *category = (type == QtDebugMsg) ? "qt" : NULL; + LogPrint(category, "GUI: %s\n", msg.toStdString()); +} +#endif + +#ifndef BITCOIN_QT_TEST +int main(int argc, char *argv[]) +{ + fHaveGUI = true; + + // Command-line options take precedence: + ParseParameters(argc, argv); + +#if QT_VERSION < 0x050000 + // Internal string conversion is all UTF-8 + QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); + QTextCodec::setCodecForCStrings(QTextCodec::codecForTr()); +#endif + + Q_INIT_RESOURCE(bitcoin); + QApplication app(argc, argv); + + // Do this early as we don't want to bother initializing if we are just calling IPC + // ... but do it after creating app, so QCoreApplication::arguments is initialized: + if (PaymentServer::ipcSendCommandLine()) + exit(0); + PaymentServer* paymentServer = new PaymentServer(&app); + + // Install global event filter that makes sure that long tooltips can be word-wrapped + app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app)); + // Install qDebug() message handler to route to debug.log +#if QT_VERSION < 0x050000 + qInstallMsgHandler(DebugMessageHandler); +#else + qInstallMessageHandler(DebugMessageHandler); +#endif + + // Command-line options take precedence: + ParseParameters(argc, argv); + + // ... then bitcoin.conf: + if (!boost::filesystem::is_directory(GetDataDir(false))) + { + // This message can not be translated, as translation is not initialized yet + // (which not yet possible because lang=XX can be overridden in bitcoin.conf in the data directory) + QMessageBox::critical(0, "SONO", + QString("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"]))); + return 1; + } + ReadConfigFile(mapArgs, mapMultiArgs); + //masternodeConfig.read(GetMasternodeConfigFile()); + // Application identification (must be set before OptionsModel is initialized, + // as it is used to locate QSettings) + app.setOrganizationName("SONO"); + //XXX app.setOrganizationDomain(""); + if(GetBoolArg("-testnet", false)) // Separate UI settings for testnet + app.setApplicationName("SONO-Qt-testnet"); + else + app.setApplicationName("SONO-Qt"); + + // ... then GUI settings: + OptionsModel optionsModel; + + // Get desired locale (e.g. "de_DE") from command line or use system locale + QString lang_territory = QString::fromStdString(GetArg("-lang", QLocale::system().name().toStdString())); + QString lang = lang_territory; + // Convert to "de" only by truncating "_DE" + lang.truncate(lang_territory.lastIndexOf('_')); + + QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator; + // Load language files for configured locale: + // - First load the translator for the base language, without territory + // - Then load the more specific locale translator + + // Load e.g. qt_de.qm + if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + app.installTranslator(&qtTranslatorBase); + + // Load e.g. qt_de_DE.qm + if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + app.installTranslator(&qtTranslator); + + // Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc) + if (translatorBase.load(lang, ":/translations/")) + app.installTranslator(&translatorBase); + + // Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc) + if (translator.load(lang_territory, ":/translations/")) + app.installTranslator(&translator); + + // Subscribe to global signals from core + uiInterface.ThreadSafeMessageBox.connect(ThreadSafeMessageBox); + uiInterface.ThreadSafeAskFee.connect(ThreadSafeAskFee); + uiInterface.InitMessage.connect(InitMessage); + uiInterface.Translate.connect(Translate); + + // Show help message immediately after parsing command-line options (for "-lang") and setting locale, + // but before showing splash screen. + if (mapArgs.count("-?") || mapArgs.count("--help")) + { + GUIUtil::HelpMessageBox help; + help.showOrPrint(); + return 1; + } + +#ifdef Q_OS_MAC + // on mac, also change the icon now because it would look strange to have a testnet splash (green) and a std app icon (orange) + if(GetBoolArg("-testnet", false)) + { + MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet")); + } +#endif + + QSplashScreen splash(QPixmap(":/images/splash"), 0); + if (GetBoolArg("-splash", true) && !GetBoolArg("-min", false)) + { + splash.show(); + splashref = &splash; + } + + app.processEvents(); + + app.setQuitOnLastWindowClosed(false); + + try + { + if (fUseBlackTheme) + GUIUtil::SetBlackThemeQSS(app); + + // Regenerate startup link, to fix links to old versions + if (GUIUtil::GetStartOnSystemStartup()) + GUIUtil::SetStartOnSystemStartup(true); + + boost::thread_group threadGroup; + + BitcoinGUI window; + guiref = &window; + + QTimer* pollShutdownTimer = new QTimer(guiref); + QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown())); + pollShutdownTimer->start(200); + + if(AppInit2(threadGroup)) + { + { + // Put this in a block, so that the Model objects are cleaned up before + // calling Shutdown(). + + paymentServer->setOptionsModel(&optionsModel); + + if (splashref) + splash.finish(&window); + + ClientModel clientModel(&optionsModel); + WalletModel walletModel(pwalletMain, &optionsModel); + MessageModel messageModel(pwalletMain, &walletModel); + + window.setClientModel(&clientModel); + window.setWalletModel(&walletModel); + window.setMessageModel(&messageModel); + + // If -min option passed, start window minimized. + if(GetBoolArg("-min", false)) + { + window.showMinimized(); + } + else + { + window.show(); + } + + // Now that initialization/startup is done, process any command-line + // bitcoin: URIs + QObject::connect(paymentServer, SIGNAL(receivedURI(QString)), &window, SLOT(handleURI(QString))); + QTimer::singleShot(100, paymentServer, SLOT(uiReady())); + + app.exec(); + + window.hide(); + window.setClientModel(0); + window.setWalletModel(0); + window.setMessageModel(0); + guiref = 0; + } + // Shutdown the core and its threads, but don't exit Bitcoin-Qt here + threadGroup.interrupt_all(); + threadGroup.join_all(); + Shutdown(); + } + else + { + threadGroup.interrupt_all(); + threadGroup.join_all(); + Shutdown(); + return 1; + } + } catch (std::exception& e) { + handleRunawayException(&e); + } catch (...) { + handleRunawayException(NULL); + } + return 0; +} +#endif // BITCOIN_QT_TEST diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc new file mode 100644 index 0000000..0f8d38d --- /dev/null +++ b/src/qt/bitcoin.qrc @@ -0,0 +1,80 @@ + + + res/icons/SONO-80.png + res/icons/address-book.png + res/icons/quit.png + res/icons/send.png + res/icons/SONO-16.png + res/icons/connect0_16.png + res/icons/connect1_16.png + res/icons/connect2_16.png + res/icons/connect3_16.png + res/icons/connect4_16.png + res/icons/transaction0.png + res/icons/transaction2.png + res/icons/transaction_conflicted.png + res/icons/clock1.png + res/icons/clock2.png + res/icons/clock3.png + res/icons/clock4.png + res/icons/clock5.png + res/icons/configure.png + res/icons/receive.png + res/icons/editpaste.png + res/icons/editcopy.png + res/icons/add.png + res/icons/SONO-80.png + res/icons/SONO-16.png + res/icons/edit.png + res/icons/history.png + res/icons/overview.png + res/icons/export.png + res/icons/synced.png + res/icons/remove.png + res/icons/tx_mined.png + res/icons/tx_input.png + res/icons/tx_output.png + res/icons/tx_inout.png + res/icons/lock_closed.png + res/icons/lock_open.png + res/icons/key.png + res/icons/filesave.png + res/icons/qrcode.png + res/icons/debugwindow.png + res/icons/staking_off.png + res/icons/staking_on.png + res/icons/onion.png + res/icons/onion-black.png + res/icons/worker.png + res/icons/update.png + + + res/icons/black/connect0_16.png + res/icons/black/connect1_16.png + res/icons/black/connect2_16.png + res/icons/black/connect3_16.png + res/icons/black/connect4_16.png + res/icons/black/synced.png + res/icons/black/tx_mined.png + res/icons/black/tx_input.png + res/icons/black/tx_output.png + res/icons/black/tx_inout.png + res/icons/black/lock_closed.png + res/icons/black/lock_open.png + res/icons/black/staking_off.png + res/icons/black/staking_on.png + + + res/images/about.png + res/images/splash.png + res/images/header.png + + + res/movies/update_spinner.mng + res/movies/update_spinner_black.mng + + + locale/bitcoin_en.qm + + + diff --git a/src/qt/bitcoinaddressvalidator.cpp b/src/qt/bitcoinaddressvalidator.cpp new file mode 100644 index 0000000..5d2cd67 --- /dev/null +++ b/src/qt/bitcoinaddressvalidator.cpp @@ -0,0 +1,77 @@ +#include "bitcoinaddressvalidator.h" + +/* Base58 characters are: + "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" + + This is: + - All numbers except for '0' + - All upper-case letters except for 'I' and 'O' + - All lower-case letters except for 'l' + + User friendly Base58 input can map + - 'l' and 'I' to '1' + - '0' and 'O' to 'o' +*/ + +BitcoinAddressValidator::BitcoinAddressValidator(QObject *parent) : + QValidator(parent) +{ +} + +QValidator::State BitcoinAddressValidator::validate(QString &input, int &pos) const +{ + // Correction + for(int idx=0; idx= '0' && ch<='9') || + (ch >= 'a' && ch<='z') || + (ch >= 'A' && ch<='Z')) && + ch != 'l' && ch != 'I' && ch != '0' && ch != 'O') + { + // Alphanumeric and not a 'forbidden' character + } + else + { + state = QValidator::Invalid; + } + } + + // Empty address is "intermediate" input + if(input.isEmpty()) + { + state = QValidator::Intermediate; + } + + return state; +} diff --git a/src/qt/bitcoinaddressvalidator.h b/src/qt/bitcoinaddressvalidator.h new file mode 100644 index 0000000..325fa2f --- /dev/null +++ b/src/qt/bitcoinaddressvalidator.h @@ -0,0 +1,21 @@ +#ifndef BITCOINADDRESSVALIDATOR_H +#define BITCOINADDRESSVALIDATOR_H + +#include + +/** Base48 entry widget validator. + Corrects near-miss characters and refuses characters that are no part of base48. + */ +class BitcoinAddressValidator : public QValidator +{ + Q_OBJECT + +public: + explicit BitcoinAddressValidator(QObject *parent = 0); + + State validate(QString &input, int &pos) const; + + static const int MaxAddressLength = 128; +}; + +#endif // BITCOINADDRESSVALIDATOR_H diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp new file mode 100644 index 0000000..f4348ce --- /dev/null +++ b/src/qt/bitcoinamountfield.cpp @@ -0,0 +1,164 @@ +#include "bitcoinamountfield.h" + +#include "qvaluecombobox.h" +#include "bitcoinunits.h" +#include "guiconstants.h" + +#include +#include +#include +#include +#include // for qPow() + +BitcoinAmountField::BitcoinAmountField(QWidget *parent): + QWidget(parent), amount(0), currentUnit(-1) +{ + amount = new QDoubleSpinBox(this); + amount->setLocale(QLocale::c()); + amount->setDecimals(8); + amount->installEventFilter(this); + amount->setMaximumWidth(170); + amount->setSingleStep(0.001); + + QHBoxLayout *layout = new QHBoxLayout(this); + layout->addWidget(amount); + unit = new QValueComboBox(this); + unit->setModel(new BitcoinUnits(this)); + layout->addWidget(unit); + layout->addStretch(1); + layout->setContentsMargins(0,0,0,0); + + setLayout(layout); + + setFocusPolicy(Qt::TabFocus); + setFocusProxy(amount); + + // If one if the widgets changes, the combined content changes as well + connect(amount, SIGNAL(valueChanged(QString)), this, SIGNAL(textChanged())); + connect(unit, SIGNAL(currentIndexChanged(int)), this, SLOT(unitChanged(int))); + + // Set default based on configuration + unitChanged(unit->currentIndex()); +} + +void BitcoinAmountField::setText(const QString &text) +{ + if (text.isEmpty()) + amount->clear(); + else + amount->setValue(text.toDouble()); +} + +void BitcoinAmountField::clear() +{ + amount->clear(); + unit->setCurrentIndex(0); +} + +bool BitcoinAmountField::validate() +{ + bool valid = true; + if (amount->value() == 0.0) + valid = false; + if (valid && !BitcoinUnits::parse(currentUnit, text(), 0)) + valid = false; + + setValid(valid); + + return valid; +} + +void BitcoinAmountField::setValid(bool valid) +{ + if (valid) + amount->setStyleSheet(""); + else + amount->setStyleSheet(STYLE_INVALID); +} + +QString BitcoinAmountField::text() const +{ + if (amount->text().isEmpty()) + return QString(); + else + return amount->text(); +} + +bool BitcoinAmountField::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::FocusIn) + { + // Clear invalid flag on focus + setValid(true); + } + else if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) + { + QKeyEvent *keyEvent = static_cast(event); + if (keyEvent->key() == Qt::Key_Comma) + { + // Translate a comma into a period + QKeyEvent periodKeyEvent(event->type(), Qt::Key_Period, keyEvent->modifiers(), ".", keyEvent->isAutoRepeat(), keyEvent->count()); + qApp->sendEvent(object, &periodKeyEvent); + return true; + } + } + return QWidget::eventFilter(object, event); +} + +QWidget *BitcoinAmountField::setupTabChain(QWidget *prev) +{ + QWidget::setTabOrder(prev, amount); + return amount; +} + +qint64 BitcoinAmountField::value(bool *valid_out) const +{ + qint64 val_out = 0; + bool valid = BitcoinUnits::parse(currentUnit, text(), &val_out); + if(valid_out) + { + *valid_out = valid; + } + return val_out; +} + +void BitcoinAmountField::setValue(qint64 value) +{ + setText(BitcoinUnits::format(currentUnit, value)); +} + +void BitcoinAmountField::unitChanged(int idx) +{ + // Use description tooltip for current unit for the combobox + unit->setToolTip(unit->itemData(idx, Qt::ToolTipRole).toString()); + + // Determine new unit ID + int newUnit = unit->itemData(idx, BitcoinUnits::UnitRole).toInt(); + + // Parse current value and convert to new unit + bool valid = false; + qint64 currentValue = value(&valid); + + currentUnit = newUnit; + + // Set max length after retrieving the value, to prevent truncation + amount->setDecimals(BitcoinUnits::decimals(currentUnit)); + amount->setMaximum(qPow(10, BitcoinUnits::amountDigits(currentUnit)) - qPow(10, -amount->decimals())); + + if(valid) + { + // If value was valid, re-place it in the widget with the new unit + setValue(currentValue); + } + else + { + // If current value is invalid, just clear field + setText(""); + } + setValid(true); +} + +void BitcoinAmountField::setDisplayUnit(int newUnit) +{ + unit->setValue(newUnit); +} diff --git a/src/qt/bitcoinamountfield.h b/src/qt/bitcoinamountfield.h new file mode 100644 index 0000000..fe18df1 --- /dev/null +++ b/src/qt/bitcoinamountfield.h @@ -0,0 +1,61 @@ +#ifndef BITCOINAMOUNTFIELD_H +#define BITCOINAMOUNTFIELD_H + +#include + +QT_BEGIN_NAMESPACE +class QDoubleSpinBox; +class QValueComboBox; +QT_END_NAMESPACE + +/** Widget for entering bitcoin amounts. + */ +class BitcoinAmountField: public QWidget +{ + Q_OBJECT + + Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY textChanged USER true) + +public: + explicit BitcoinAmountField(QWidget *parent = 0); + + qint64 value(bool *valid=0) const; + void setValue(qint64 value); + + /** Mark current value as invalid in UI. */ + void setValid(bool valid); + /** Perform input validation, mark field as invalid if entered value is not valid. */ + bool validate(); + + /** Change unit used to display amount. */ + void setDisplayUnit(int unit); + + /** Make field empty and ready for new input. */ + void clear(); + + /** Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907), + in these cases we have to set it up manually. + */ + QWidget *setupTabChain(QWidget *prev); + +signals: + void textChanged(); + +protected: + /** Intercept focus-in event and ',' key presses */ + bool eventFilter(QObject *object, QEvent *event); + +private: + QDoubleSpinBox *amount; + QValueComboBox *unit; + int currentUnit; + + void setText(const QString &text); + QString text() const; + +private slots: + void unitChanged(int idx); + +}; + +#endif // BITCOINAMOUNTFIELD_H diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp new file mode 100644 index 0000000..6963b96 --- /dev/null +++ b/src/qt/bitcoingui.cpp @@ -0,0 +1,1278 @@ +/* + * Qt4 bitcoin GUI. + * + * W.J. van der Laan 2011-2012 + * The Bitcoin Developers 2011-2012 + */ + +#include + +#include "bitcoingui.h" + +#include "transactiontablemodel.h" +#include "addressbookpage.h" +#include "sendcoinsdialog.h" +#include "signverifymessagedialog.h" +#include "optionsdialog.h" +#include "aboutdialog.h" +#include "clientmodel.h" +#include "walletmodel.h" +#include "editaddressdialog.h" +#include "optionsmodel.h" +#include "transactiondescdialog.h" +#include "addresstablemodel.h" +#include "transactionview.h" +#include "overviewpage.h" +//#include "clientcontrolpage.h" +#include "bitcoinunits.h" +#include "guiconstants.h" +#include "askpassphrasedialog.h" +#include "notificator.h" +#include "guiutil.h" +#include "rpcconsole.h" +#include "wallet.h" +#include "init.h" +#include "ui_interface.h" +#include "masternodemanager.h" +#include "messagemodel.h" +#include "messagepage.h" +#include "blockbrowser.h" +#include "forms/sidetoolbar.h" + + +#ifdef Q_OS_MAC +#include "macdockiconhandler.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +extern bool fOnlyTor; +extern CWallet* pwalletMain; +extern int64_t nLastCoinStakeSearchInterval; +double GetPoSKernelPS(); + +BitcoinGUI::BitcoinGUI(QWidget *parent): + QMainWindow(parent), + clientModel(0), + walletModel(0), + toolbar(0), + encryptWalletAction(0), + changePassphraseAction(0), + unlockWalletAction(0), + lockWalletAction(0), + aboutQtAction(0), + trayIcon(0), + notificator(0), + rpcConsole(0), + prevBlocks(0), + nWeight(0) +{ + //resize(970, 570); + resize(1080, 662); + setWindowTitle(tr("SONO") + " - " + tr("Wallet")); +#ifndef Q_OS_MAC + qApp->setWindowIcon(QIcon(":icons/bitcoin")); + setWindowIcon(QIcon(":icons/bitcoin")); +#else + //setUnifiedTitleAndToolBarOnMac(true); + QApplication::setAttribute(Qt::AA_DontShowIconsInMenus); +#endif + setObjectName("SONO"); + setStyleSheet("#SONO {background-image: url(:/images/qt) }"); + // Accept D&D of URIs + setAcceptDrops(true); + + // Create actions for the toolbar, menu bar and tray/dock icon + createActions(); + + // Create application menu bar + createMenuBar(); + + // Create the toolbars + createToolBars(); + + // Create the tray icon (or setup the dock icon) + createTrayIcon(); + + // Create tabs + overviewPage = new OverviewPage(); + // Create trading page + // tradingDialogPage = new tradingDialog(this); + // tradingDialogPage->setObjectName("tradingDialog"); + + transactionsPage = new QWidget(this); + QVBoxLayout *vbox = new QVBoxLayout(); + transactionView = new TransactionView(this); + vbox->addWidget(transactionView); + transactionsPage->setLayout(vbox); + + blockBrowser = new BlockBrowser(this); + + addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab); + + receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab); + + sendCoinsPage = new SendCoinsDialog(this); + + signVerifyMessageDialog = new SignVerifyMessageDialog(this); + + masternodeManagerPage = new MasternodeManager(this); + + messagePage = new MessagePage(this); + + //clientcontrolPage = new ClientControlPage(this); + + //multisigPage = new MultisigDialog(this); + + centralStackedWidget = new QStackedWidget(this); + + centralStackedWidget->setContentsMargins(0, 0, 0, 0); + centralStackedWidget->addWidget(overviewPage); + centralStackedWidget->addWidget(transactionsPage); + centralStackedWidget->addWidget(addressBookPage); + centralStackedWidget->addWidget(receiveCoinsPage); + centralStackedWidget->addWidget(sendCoinsPage); + centralStackedWidget->addWidget(masternodeManagerPage); + centralStackedWidget->addWidget(messagePage); + centralStackedWidget->addWidget(blockBrowser); + // centralStackedWidget->addWidget(clientcontrolPage); + //TradingAction->setChecked(true); + // centralStackedWidget->addWidget(tradingDialogPage); + + QWidget *centralWidget = new QWidget(); + QVBoxLayout *centralLayout = new QVBoxLayout(centralWidget); + centralLayout->setContentsMargins(0,0,0,0); + centralWidget->setContentsMargins(0,0,0,0); + centralLayout->addWidget(centralStackedWidget); +#ifndef Q_OS_MAC + centralLayout->addWidget(appMenuBar); +#endif + setCentralWidget(centralWidget); + + // Create status bar + statusBar(); + + // Disable size grip because it looks ugly and nobody needs it + statusBar()->setSizeGripEnabled(false); + + // Status bar notification icons + QWidget *frameBlocks = new QWidget(); + frameBlocks->setContentsMargins(0,0,0,0); + frameBlocks->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + frameBlocks->setStyleSheet("QWidget { background: none; margin-bottom: 5px; }"); + QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks); + frameBlocksLayout->setContentsMargins(3,0,3,0); + frameBlocksLayout->setSpacing(3); + frameBlocksLayout->setAlignment(Qt::AlignHCenter); + labelEncryptionIcon = new QLabel(); + labelStakingIcon = new QLabel(); + labelConnectionsIcon = new QLabel(); + labelBlocksIcon = new QLabel(); + frameBlocksLayout->addStretch(); + frameBlocksLayout->addWidget(labelEncryptionIcon); + frameBlocksLayout->addStretch(); + frameBlocksLayout->addWidget(labelStakingIcon); + frameBlocksLayout->addStretch(); + frameBlocksLayout->addWidget(labelConnectionsIcon); + frameBlocksLayout->addStretch(); + frameBlocksLayout->addWidget(labelBlocksIcon); + frameBlocksLayout->addStretch(); + //frameBlocksLayout->addWidget(netLabel); + //frameBlocksLayout->addStretch(); + + + if (GetBoolArg("-staking", true)) + { + QTimer *timerStakingIcon = new QTimer(labelStakingIcon); + connect(timerStakingIcon, SIGNAL(timeout()), this, SLOT(updateStakingIcon())); + timerStakingIcon->start(20 * 1000); + updateStakingIcon(); + } + + // Progress bar and label for blocks download + progressBarLabel = new QLabel(); + progressBarLabel->setVisible(false); + progressBar = new QProgressBar(); + progressBar->setAlignment(Qt::AlignCenter); + progressBar->setVisible(false); + + if (!fUseBlackTheme) + { + // Override style sheet for progress bar for styles that have a segmented progress bar, + // as they make the text unreadable (workaround for issue #1071) + // See https://qt-project.org/doc/qt-4.8/gallery.html + QString curStyle = qApp->style()->metaObject()->className(); + if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle") + { + progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }"); + } + } + + statusBar()->addWidget(progressBarLabel); + statusBar()->addWidget(progressBar); + statusBar()->addPermanentWidget(frameBlocks); + statusBar()->setObjectName("statusBar"); + statusBar()->setStyleSheet("#statusBar { color: #101010; background-color: #f9f9f9); }"); + + syncIconMovie = new QMovie(fUseBlackTheme ? ":/movies/update_spinner_black" : ":/movies/update_spinner", "mng", this); + + // Clicking on a transaction on the overview page simply sends you to transaction history page + connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage())); + connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); + + // Double-clicking on a transaction on the transaction history page shows details + connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails())); + + rpcConsole = new RPCConsole(this); + connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show())); + // prevents an oben debug window from becoming stuck/unusable on client shutdown + connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide())); + + // Clicking on "Verify Message" in the address book sends you to the verify message tab + connect(addressBookPage, SIGNAL(verifyMessage(QString)), this, SLOT(gotoVerifyMessageTab(QString))); + // Clicking on "Sign Message" in the receive coins page sends you to the sign message tab + connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString))); + + gotoOverviewPage(); +} + +BitcoinGUI::~BitcoinGUI() +{ + if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu) + trayIcon->hide(); +#ifdef Q_OS_MAC + delete appMenuBar; +#endif +} + +void BitcoinGUI::createActions() +{ + QActionGroup *tabGroup = new QActionGroup(this); + + overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Dashboard"), this); + overviewAction->setToolTip(tr("Show general overview of wallet")); + overviewAction->setCheckable(true); + overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1)); + tabGroup->addAction(overviewAction); + + receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive"), this); + receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments")); + receiveCoinsAction->setCheckable(true); + receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2)); + tabGroup->addAction(receiveCoinsAction); + + sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send"), this); + sendCoinsAction->setToolTip(tr("Send coins to a SONO address")); + sendCoinsAction->setCheckable(true); + sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3)); + tabGroup->addAction(sendCoinsAction); + + historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this); + historyAction->setToolTip(tr("Browse transaction history")); + historyAction->setCheckable(true); + historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4)); + tabGroup->addAction(historyAction); + + addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Addresses"), this); + addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels")); + addressBookAction->setCheckable(true); + addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5)); + tabGroup->addAction(addressBookAction); + + masternodeManagerAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Masternodes"), this); + masternodeManagerAction->setToolTip(tr("Show SONO Masternodes status and configure your nodes.")); + masternodeManagerAction->setCheckable(true); + tabGroup->addAction(masternodeManagerAction); + + messageAction = new QAction(QIcon(":/icons/edit"), tr("&Messages"), this); + messageAction->setToolTip(tr("View and Send Encrypted messages")); + messageAction->setCheckable(true); + tabGroup->addAction(messageAction); + + blockAction = new QAction(QIcon(":/icons/statistics"), tr("&Block Explorer"), this); + blockAction->setToolTip(tr("Explore the BlockChain")); + blockAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6)); + blockAction->setCheckable(true); + tabGroup->addAction(blockAction); + + // clientcontrolAction = new QAction(QIcon(":/icons/update"), tr("&Client Update"), this); + // clientcontrolAction->setToolTip(tr("Client control and management Page")); + // clientcontrolAction->setCheckable(true); + // clientcontrolAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6)); + // tabGroup->addAction(clientcontrolAction); + +/* + generateAction = new QAction(QIcon(":/icons/worker"), tr("&Worker"), this); + generateAction->setToolTip(tr("SONO mining and staking management")); + generateAction->setCheckable(true); + generateAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_7)); + tabGroup->addAction(generateAction); +*/ + //multisigAction = new QAction(QIcon(":/icons/send"), tr("Multisig"), this); + //tabGroup->addAction(multisigAction); + + /* TradingAction = new QAction(tr("&Trade"), this); + TradingAction ->setToolTip(tr("Start Trading")); + TradingAction ->setCheckable(true); + TradingAction ->setShortcut(QKeySequence(Qt::ALT + Qt::Key_8)); + TradingAction->setProperty("objectName","TradingAction"); + tabGroup->addAction(TradingAction);*/ + + // connect(TradingAction, SIGNAL(triggered()), this, SLOT(gotoTradingPage())); + connect(blockAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(blockAction, SIGNAL(triggered()), this, SLOT(gotoBlockBrowser())); + connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage())); + connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); + connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage())); + connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); + connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage())); + connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + //connect(generateAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(masternodeManagerAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(masternodeManagerAction, SIGNAL(triggered()), this, SLOT(gotoMasternodeManagerPage())); + connect(messageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(messageAction, SIGNAL(triggered()), this, SLOT(gotoMessagePage())); + // connect(clientcontrolAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + // connect(clientcontrolAction, SIGNAL(triggered()), this, SLOT(gotoClientControlPage())); + + //connect(multisigAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + //connect(multisigAction, SIGNAL(triggered()), this, SLOT(gotoMultisigPage())); + + quitAction = new QAction(tr("E&xit"), this); + quitAction->setToolTip(tr("Quit application")); + quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); + quitAction->setMenuRole(QAction::QuitRole); + aboutAction = new QAction(tr("&About SONO"), this); + aboutAction->setToolTip(tr("Show information about SONO")); + aboutAction->setMenuRole(QAction::AboutRole); + aboutQtAction = new QAction(tr("About &Qt"), this); + aboutQtAction->setToolTip(tr("Show information about Qt")); + aboutQtAction->setMenuRole(QAction::AboutQtRole); + optionsAction = new QAction(tr("&Options..."), this); + optionsAction->setToolTip(tr("Modify configuration options for SONO")); + optionsAction->setMenuRole(QAction::PreferencesRole); + toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this); + encryptWalletAction = new QAction(tr("&Encrypt Wallet..."), this); + encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet")); + backupWalletAction = new QAction(tr("&Backup Wallet..."), this); + backupWalletAction->setToolTip(tr("Backup wallet to another location")); + changePassphraseAction = new QAction(tr("&Change Passphrase..."), this); + changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption")); + unlockWalletAction = new QAction(tr("&Unlock Wallet..."), this); + unlockWalletAction->setToolTip(tr("Unlock wallet")); + lockWalletAction = new QAction(tr("&Lock Wallet"), this); + lockWalletAction->setToolTip(tr("Lock wallet")); + signMessageAction = new QAction(tr("Sign &message..."), this); + verifyMessageAction = new QAction(tr("&Verify message..."), this); + + exportAction = new QAction(tr("&Export..."), this); + exportAction->setToolTip(tr("Export the data in the current tab to a file")); + openRPCConsoleAction = new QAction(tr("&Debug window"), this); + openRPCConsoleAction->setToolTip(tr("Open debugging and diagnostic console")); + + connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); + connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked())); + connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden())); + connect(encryptWalletAction, SIGNAL(triggered()), this, SLOT(encryptWallet())); + connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet())); + connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase())); + connect(unlockWalletAction, SIGNAL(triggered()), this, SLOT(unlockWallet())); + connect(lockWalletAction, SIGNAL(triggered()), this, SLOT(lockWallet())); + connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab())); + connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab())); +} + +void BitcoinGUI::createMenuBar() +{ +#ifdef Q_OS_MAC + appMenuBar = new QMenuBar(); +#else + appMenuBar = menuBar(); +#endif + + // Configure the menus + QMenu *file = appMenuBar->addMenu(tr("&File")); + file->addAction(backupWalletAction); + file->addAction(exportAction); + file->addAction(signMessageAction); + file->addAction(verifyMessageAction); + file->addSeparator(); + file->addAction(quitAction); + //file->addAction(multisigAction); + + QMenu *settings = appMenuBar->addMenu(tr("&Settings")); + settings->addAction(encryptWalletAction); + settings->addAction(changePassphraseAction); + settings->addAction(unlockWalletAction); + settings->addAction(lockWalletAction); + settings->addSeparator(); + settings->addAction(optionsAction); + + QMenu *help = appMenuBar->addMenu(tr("&Help")); + help->addAction(openRPCConsoleAction); + help->addSeparator(); + help->addAction(aboutAction); + help->addAction(aboutQtAction); +} + +static QWidget* makeToolBarSpacer() +{ + QWidget* spacer = new QWidget(); + spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + spacer->setStyleSheet("QWidget { background: none; }"); + return spacer; +} + +void BitcoinGUI::createToolBars() +{ + fLiteMode = GetBoolArg("-litemode", false); + + toolbar = new QToolBar(tr("Tabs toolbar")); + + toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + + toolbar->setContextMenuPolicy(Qt::PreventContextMenu); + + toolbar->setObjectName("tabs"); + toolbar->setStyleSheet("QToolButton { color: #101010; font-weight:bold;} QToolButton:hover { background-color: #c1cbcb } QToolButton:checked { background-color: #c1cbcb } QToolButton:pressed { background-color: none } #tabs { color: #101010; background-color: #f9f9f9); }"); + + QLabel* header = new QLabel(); + header->setMinimumSize(142, 142); + header->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + header->setPixmap(QPixmap(":/images/header")); + header->setMaximumSize(180,180); + header->setScaledContents(true); + + header->setObjectName("headerLogo"); + header->setStyleSheet("#headerLogo {margin-bottom:20px;}"); + + + toolbar->addWidget(header); + + //QMenu *toolbarMenu = new QMenu(); + toolbar->addAction(overviewAction); + toolbar->addAction(receiveCoinsAction); + toolbar->addAction(sendCoinsAction); + toolbar->addAction(historyAction); + toolbar->addAction(addressBookAction); + toolbar->addAction(masternodeManagerAction); + // toolbar->addAction(clientcontrolAction); + toolbar->addAction(blockAction); + + if (!fLiteMode){ + toolbar->addAction(messageAction); + } + + QWidget *spacer = makeToolBarSpacer(); + + toolbar->addWidget(spacer); + toolbar->setOrientation(Qt::Vertical); + toolbar->setMovable(false); + + addToolBar(Qt::LeftToolBarArea, toolbar); +} + +void BitcoinGUI::setClientModel(ClientModel *clientModel) +{ + this->clientModel = clientModel; + if(clientModel) + { + // Replace some strings and icons, when using the testnet + if(clientModel->isTestNet()) + { + setWindowTitle(windowTitle() + QString(" ") + tr("[testnet]")); +#ifndef Q_OS_MAC + qApp->setWindowIcon(QIcon(":icons/bitcoin_testnet")); + setWindowIcon(QIcon(":icons/bitcoin_testnet")); +#else + MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet")); +#endif + if(trayIcon) + { + trayIcon->setToolTip(tr("SONO client") + QString(" ") + tr("[testnet]")); + trayIcon->setIcon(QIcon(":/icons/toolbar_testnet")); + toggleHideAction->setIcon(QIcon(":/icons/toolbar_testnet")); + } + } + + // Keep up to date with client + setNumConnections(clientModel->getNumConnections()); + connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); + + setNumBlocks(clientModel->getNumBlocks()); + connect(clientModel, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int))); + + // Receive and report messages from network/worker thread + connect(clientModel, SIGNAL(message(QString,QString,bool,unsigned int)), this, SLOT(message(QString,QString,bool,unsigned int))); + + overviewPage->setClientModel(clientModel); + rpcConsole->setClientModel(clientModel); + addressBookPage->setOptionsModel(clientModel->getOptionsModel()); + receiveCoinsPage->setOptionsModel(clientModel->getOptionsModel()); + } +} + +void BitcoinGUI::setWalletModel(WalletModel *walletModel) +{ + this->walletModel = walletModel; + if(walletModel) + { + // Receive and report messages from wallet thread + connect(walletModel, SIGNAL(message(QString,QString,bool,unsigned int)), this, SLOT(message(QString,QString,bool,unsigned int))); + + // Put transaction list in tabs + transactionView->setModel(walletModel); + overviewPage->setWalletModel(walletModel); + addressBookPage->setModel(walletModel->getAddressTableModel()); + receiveCoinsPage->setModel(walletModel->getAddressTableModel()); + sendCoinsPage->setModel(walletModel); + signVerifyMessageDialog->setModel(walletModel); + blockBrowser->setModel(walletModel); + //multisigPage->setModel(walletModel); + + setEncryptionStatus(walletModel->getEncryptionStatus()); + connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); + + // Balloon pop-up for new transaction + connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(incomingTransaction(QModelIndex,int,int))); + + // Ask for passphrase if needed + connect(walletModel, SIGNAL(requireUnlock()), this, SLOT(unlockWallet())); + } +} + +void BitcoinGUI::setMessageModel(MessageModel *messageModel) +{ + this->messageModel = messageModel; + if(messageModel) + { + // Report errors from message thread + connect(messageModel, SIGNAL(error(QString,QString,bool)), this, SLOT(error(QString,QString,bool))); + + // Put transaction list in tabs + messagePage->setModel(messageModel); + + // Balloon pop-up for new message + connect(messageModel, SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(incomingMessage(QModelIndex,int,int))); + } +} + +void BitcoinGUI::createTrayIcon() +{ + QMenu *trayIconMenu; +#ifndef Q_OS_MAC + trayIcon = new QSystemTrayIcon(this); + trayIconMenu = new QMenu(this); + trayIcon->setContextMenu(trayIconMenu); + trayIcon->setToolTip(tr("SONO client")); + trayIcon->setIcon(QIcon(":/icons/toolbar")); + connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), + this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); + trayIcon->show(); +#else + // Note: On Mac, the dock icon is used to provide the tray's functionality. + MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); + dockIconHandler->setMainWindow((QMainWindow *)this); + trayIconMenu = dockIconHandler->dockMenu(); +#endif + + // Configuration of the tray icon (or dock icon) icon menu + trayIconMenu->addAction(toggleHideAction); + trayIconMenu->addSeparator(); + trayIconMenu->addAction(receiveCoinsAction); + trayIconMenu->addAction(sendCoinsAction); + trayIconMenu->addSeparator(); + trayIconMenu->addAction(signMessageAction); + trayIconMenu->addAction(verifyMessageAction); + trayIconMenu->addSeparator(); + trayIconMenu->addAction(optionsAction); + trayIconMenu->addAction(openRPCConsoleAction); +#ifndef Q_OS_MAC // This is built-in on Mac + trayIconMenu->addSeparator(); + trayIconMenu->addAction(quitAction); +#endif + //trayIconMenu->addAction(multisigAction); + + notificator = new Notificator(qApp->applicationName(), trayIcon); +} + +#ifndef Q_OS_MAC +void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) +{ + if(reason == QSystemTrayIcon::Trigger) + { + // Click on system tray icon triggers show/hide of the main window + toggleHideAction->trigger(); + } +} +#endif + +void BitcoinGUI::optionsClicked() +{ + if(!clientModel || !clientModel->getOptionsModel()) + return; + OptionsDialog dlg; + dlg.setModel(clientModel->getOptionsModel()); + dlg.exec(); +} + +void BitcoinGUI::aboutClicked() +{ + AboutDialog dlg; + dlg.setModel(clientModel); + dlg.exec(); +} + +void BitcoinGUI::setNumConnections(int count) +{ + QString icon; + switch(count) + { + case 0: icon = fUseBlackTheme ? ":/icons/black/connect_0" : ":/icons/connect_0"; break; + case 1: case 2: case 3: icon = fUseBlackTheme ? ":/icons/black/connect_1" : ":/icons/connect_1"; break; + case 4: case 5: case 6: icon = fUseBlackTheme ? ":/icons/black/connect_2" : ":/icons/connect_2"; break; + case 7: case 8: case 9: icon = fUseBlackTheme ? ":/icons/black/connect_3" : ":/icons/connect_3"; break; + default: icon = fUseBlackTheme ? ":/icons/black/connect_4" : ":/icons/connect_4"; break; + } + labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); + labelConnectionsIcon->setToolTip(tr("%n active connection(s) to SONO network", "", count)); +} + +/*void BitcoinGUI::gotoMultisigPage() +{ + multisigPage->show(); + multisigPage->setFocus(); +}*/ + +void BitcoinGUI::setNumBlocks(int count) +{ + QString tooltip; + + QDateTime lastBlockDate = clientModel->getLastBlockDate(); + QDateTime currentDate = QDateTime::currentDateTime(); + int totalSecs = GetTime() - Params().GenesisBlock().GetBlockTime(); + int secs = lastBlockDate.secsTo(currentDate); + + tooltip = tr("Processed %1 blocks of transaction history.").arg(count); + + // Set icon state: spinning if catching up, tick otherwise + if(secs < 90*60) + { + tooltip = tr("Up to date") + QString(".
") + tooltip; + labelBlocksIcon->setPixmap(QIcon(fUseBlackTheme ? ":/icons/black/synced" : ":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); + + overviewPage->showOutOfSyncWarning(false); + + progressBarLabel->setVisible(false); + progressBar->setVisible(false); + } + else + { + // Represent time from last generated block in human readable text + QString timeBehindText; + const int HOUR_IN_SECONDS = 60*60; + const int DAY_IN_SECONDS = 24*60*60; + const int WEEK_IN_SECONDS = 7*24*60*60; + const int YEAR_IN_SECONDS = 31556952; // Average length of year + if(secs < 2*DAY_IN_SECONDS) + { + timeBehindText = tr("%n hour(s)","",secs/HOUR_IN_SECONDS); + } + else if(secs < 2*WEEK_IN_SECONDS) + { + timeBehindText = tr("%n day(s)","",secs/DAY_IN_SECONDS); + } + else if(secs < YEAR_IN_SECONDS) + { + timeBehindText = tr("%n week(s)","",secs/WEEK_IN_SECONDS); + } + else + { + int years = secs / YEAR_IN_SECONDS; + int remainder = secs % YEAR_IN_SECONDS; + timeBehindText = tr("%1 and %2").arg(tr("%n year(s)", "", years)).arg(tr("%n week(s)","", remainder/WEEK_IN_SECONDS)); + } + + progressBarLabel->setText(tr(clientModel->isImporting() ? "Importing blocks..." : "Synchronizing with network...")); + progressBarLabel->setVisible(true); + progressBar->setFormat(tr("%1 behind").arg(timeBehindText)); + progressBar->setMaximum(totalSecs); + progressBar->setValue(totalSecs - secs); + progressBar->setVisible(true); + + tooltip = tr("Catching up...") + QString("
") + tooltip; + labelBlocksIcon->setMovie(syncIconMovie); + if(count != prevBlocks) + syncIconMovie->jumpToNextFrame(); + prevBlocks = count; + + overviewPage->showOutOfSyncWarning(true); + + tooltip += QString("
"); + tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText); + tooltip += QString("
"); + tooltip += tr("Transactions after this will not yet be visible."); + } + + // Don't word-wrap this (fixed-width) tooltip + tooltip = QString("") + tooltip + QString(""); + + labelBlocksIcon->setToolTip(tooltip); + progressBarLabel->setToolTip(tooltip); + progressBar->setToolTip(tooltip); + + statusBar()->setVisible(true); +} + +void BitcoinGUI::message(const QString &title, const QString &message, bool modal, unsigned int style) +{ + QString strTitle = tr("SONO") + " - "; + // Default to information icon + int nMBoxIcon = QMessageBox::Information; + int nNotifyIcon = Notificator::Information; + + // Check for usage of predefined title + switch (style) { + case CClientUIInterface::MSG_ERROR: + strTitle += tr("Error"); + break; + case CClientUIInterface::MSG_WARNING: + strTitle += tr("Warning"); + break; + case CClientUIInterface::MSG_INFORMATION: + strTitle += tr("Information"); + break; + default: + strTitle += title; // Use supplied title + } + + // Check for error/warning icon + if (style & CClientUIInterface::ICON_ERROR) { + nMBoxIcon = QMessageBox::Critical; + nNotifyIcon = Notificator::Critical; + } + else if (style & CClientUIInterface::ICON_WARNING) { + nMBoxIcon = QMessageBox::Warning; + nNotifyIcon = Notificator::Warning; + } + + // Display message + if (modal) { + // Check for buttons, use OK as default, if none was supplied + QMessageBox::StandardButton buttons; + if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK))) + buttons = QMessageBox::Ok; + + QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons); + mBox.exec(); + } + else + notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message); +} + +void BitcoinGUI::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); +#ifndef Q_OS_MAC // Ignored on Mac + if(e->type() == QEvent::WindowStateChange) + { + if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray()) + { + QWindowStateChangeEvent *wsevt = static_cast(e); + if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized()) + { + QTimer::singleShot(0, this, SLOT(hide())); + e->ignore(); + } + } + } +#endif +} + +void BitcoinGUI::closeEvent(QCloseEvent *event) +{ + if(clientModel) + { +#ifndef Q_OS_MAC // Ignored on Mac + if(!clientModel->getOptionsModel()->getMinimizeToTray() && + !clientModel->getOptionsModel()->getMinimizeOnClose()) + { + qApp->quit(); + } +#endif + } + QMainWindow::closeEvent(event); +} + +void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee) +{ + if (!clientModel || !clientModel->getOptionsModel()) + return; + + QString strMessage = tr("This transaction is over the size limit. You can still send it for a fee of %1, " + "which goes to the nodes that process your transaction and helps to support the network. " + "Do you want to pay the fee?").arg(BitcoinUnits::formatWithUnit(clientModel->getOptionsModel()->getDisplayUnit(), nFeeRequired)); + QMessageBox::StandardButton retval = QMessageBox::question( + this, tr("Confirm transaction fee"), strMessage, + QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes); + *payFee = (retval == QMessageBox::Yes); +} + +void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int end) +{ + if(!walletModel || !clientModel) + return; + TransactionTableModel *ttm = walletModel->getTransactionTableModel(); + qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent) + .data(Qt::EditRole).toULongLong(); + if(!clientModel->inInitialBlockDownload()) + { + // On new transaction, make an info balloon + // Unless the initial block download is in progress, to prevent balloon-spam + QString date = ttm->index(start, TransactionTableModel::Date, parent) + .data().toString(); + QString type = ttm->index(start, TransactionTableModel::Type, parent) + .data().toString(); + QString address = ttm->index(start, TransactionTableModel::ToAddress, parent) + .data().toString(); + QIcon icon = qvariant_cast(ttm->index(start, + TransactionTableModel::ToAddress, parent) + .data(Qt::DecorationRole)); + + notificator->notify(Notificator::Information, + (amount)<0 ? tr("Sent transaction") : + tr("Incoming transaction"), + tr("Date: %1\n" + "Amount: %2\n" + "Type: %3\n" + "Address: %4\n") + .arg(date) + .arg(BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), amount, true)) + .arg(type) + .arg(address), icon); + } +} + +void BitcoinGUI::incomingMessage(const QModelIndex & parent, int start, int end) +{ + if(!messageModel) + return; + + MessageModel *mm = messageModel; + + if (mm->index(start, MessageModel::TypeInt, parent).data().toInt() == MessageTableEntry::Received) + { + QString sent_datetime = mm->index(start, MessageModel::ReceivedDateTime, parent).data().toString(); + QString from_address = mm->index(start, MessageModel::FromAddress, parent).data().toString(); + QString to_address = mm->index(start, MessageModel::ToAddress, parent).data().toString(); + QString message = mm->index(start, MessageModel::Message, parent).data().toString(); + QTextDocument html; + html.setHtml(message); + QString messageText(html.toPlainText()); + notificator->notify(Notificator::Information, + tr("Incoming Message"), + tr("Date: %1\n" + "From Address: %2\n" + "To Address: %3\n" + "Message: %4\n") + .arg(sent_datetime) + .arg(from_address) + .arg(to_address) + .arg(messageText)); + }; +} + +void BitcoinGUI::clearWidgets() +{ + centralStackedWidget->setCurrentWidget(centralStackedWidget->widget(0)); + for(int i = centralStackedWidget->count(); i>0; i--){ + QWidget* widget = centralStackedWidget->widget(i); + centralStackedWidget->removeWidget(widget); + widget->deleteLater(); + } +} + +void BitcoinGUI::gotoMasternodeManagerPage() +{ + masternodeManagerAction->setChecked(true); + centralStackedWidget->setCurrentWidget(masternodeManagerPage); + + exportAction->setEnabled(false); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); +} + +void BitcoinGUI::gotoBlockBrowser() +{ + blockAction->setChecked(true); + centralStackedWidget->setCurrentWidget(blockBrowser); + + exportAction->setEnabled(false); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); +} + + +void BitcoinGUI::gotoOverviewPage() +{ + overviewAction->setChecked(true); + centralStackedWidget->setCurrentWidget(overviewPage); + + exportAction->setEnabled(false); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); +} + +void BitcoinGUI::gotoHistoryPage() +{ + historyAction->setChecked(true); + centralStackedWidget->setCurrentWidget(transactionsPage); + + exportAction->setEnabled(true); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); + connect(exportAction, SIGNAL(triggered()), transactionView, SLOT(exportClicked())); +} + +void BitcoinGUI::gotoAddressBookPage() +{ + addressBookAction->setChecked(true); + centralStackedWidget->setCurrentWidget(addressBookPage); + + exportAction->setEnabled(true); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); + connect(exportAction, SIGNAL(triggered()), addressBookPage, SLOT(exportClicked())); +} + +void BitcoinGUI::gotoReceiveCoinsPage() +{ + receiveCoinsAction->setChecked(true); + centralStackedWidget->setCurrentWidget(receiveCoinsPage); + + exportAction->setEnabled(true); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); + connect(exportAction, SIGNAL(triggered()), receiveCoinsPage, SLOT(exportClicked())); +} + +void BitcoinGUI::gotoSendCoinsPage() +{ + sendCoinsAction->setChecked(true); + centralStackedWidget->setCurrentWidget(sendCoinsPage); + + exportAction->setEnabled(false); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); +} + +void BitcoinGUI::gotoSignMessageTab(QString addr) +{ + // call show() in showTab_SM() + signVerifyMessageDialog->showTab_SM(true); + + if(!addr.isEmpty()) + signVerifyMessageDialog->setAddress_SM(addr); +} + +void BitcoinGUI::gotoVerifyMessageTab(QString addr) +{ + // call show() in showTab_VM() + signVerifyMessageDialog->showTab_VM(true); + + if(!addr.isEmpty()) + signVerifyMessageDialog->setAddress_VM(addr); +} + +/*void BitcoinGUI::gotoClientControlPage() +{ + clientcontrolAction->setChecked(true); + centralStackedWidget->setCurrentWidget(clientcontrolPage); + + exportAction->setEnabled(true); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); +} +*/ +/*void BitcoinGUI::gotoTradingPage() +{ + + TradingAction->setChecked(true); + centralStackedWidget->setCurrentWidget(tradingDialogPage); + + // exportAction->setEnabled(false); + // disconnect(exportAction, SIGNAL(triggered()), 0, 0); +}*/ + +void BitcoinGUI::gotoMessagePage() +{ + messageAction->setChecked(true); + centralStackedWidget->setCurrentWidget(messagePage); + + exportAction->setEnabled(true); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); + connect(exportAction, SIGNAL(triggered()), messagePage, SLOT(exportClicked())); +} + +void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event) +{ + // Accept only URIs + if(event->mimeData()->hasUrls()) + event->acceptProposedAction(); +} + +void BitcoinGUI::dropEvent(QDropEvent *event) +{ + if(event->mimeData()->hasUrls()) + { + int nValidUrisFound = 0; + QList uris = event->mimeData()->urls(); + foreach(const QUrl &uri, uris) + { + if (sendCoinsPage->handleURI(uri.toString())) + nValidUrisFound++; + } + + // if valid URIs were found + if (nValidUrisFound) + gotoSendCoinsPage(); + else + notificator->notify(Notificator::Warning, tr("URI handling"), tr("URI can not be parsed! This can be caused by an invalid SONO address or malformed URI parameters.")); + } + + event->acceptProposedAction(); +} + +void BitcoinGUI::handleURI(QString strURI) +{ + // URI has to be valid + if (sendCoinsPage->handleURI(strURI)) + { + showNormalIfMinimized(); + gotoSendCoinsPage(); + } + else + notificator->notify(Notificator::Warning, tr("URI handling"), tr("URI can not be parsed! This can be caused by an invalid SONO address or malformed URI parameters.")); +} + +void BitcoinGUI::setEncryptionStatus(int status) +{ + if(fWalletUnlockStakingOnly) + { + labelEncryptionIcon->setPixmap(QIcon(fUseBlackTheme ? ":/icons/black/lock_open" : ":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); + labelEncryptionIcon->setToolTip(tr("Wallet is encrypted and currently unlocked for staking only")); + changePassphraseAction->setEnabled(false); + unlockWalletAction->setVisible(true); + lockWalletAction->setVisible(true); + encryptWalletAction->setEnabled(false); + + } + else + { + + switch(status) + { + case WalletModel::Unencrypted: + labelEncryptionIcon->setPixmap(QIcon(fUseBlackTheme ? ":/icons/black/lock_open" : ":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); + labelEncryptionIcon->setToolTip(tr("Wallet is not encrypted")); + changePassphraseAction->setEnabled(false); + unlockWalletAction->setVisible(false); + lockWalletAction->setVisible(false); + encryptWalletAction->setEnabled(true); + break; + case WalletModel::Unlocked: + labelEncryptionIcon->setPixmap(QIcon(fUseBlackTheme ? ":/icons/black/lock_open" : ":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); + labelEncryptionIcon->setToolTip(tr("Wallet is encrypted and currently unlocked")); + changePassphraseAction->setEnabled(true); + unlockWalletAction->setVisible(false); + lockWalletAction->setVisible(true); + encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported + break; + case WalletModel::Locked: + labelEncryptionIcon->setPixmap(QIcon(fUseBlackTheme ? ":/icons/black/lock_closed" : ":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); + labelEncryptionIcon->setToolTip(tr("Wallet is encrypted and currently locked")); + changePassphraseAction->setEnabled(true); + unlockWalletAction->setVisible(true); + lockWalletAction->setVisible(false); + encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported + break; + } + + } +} + +void BitcoinGUI::encryptWallet() +{ + if(!walletModel) + return; + + AskPassphraseDialog dlg(AskPassphraseDialog::Encrypt, this); + dlg.setModel(walletModel); + dlg.exec(); + + setEncryptionStatus(walletModel->getEncryptionStatus()); +} + +void BitcoinGUI::backupWallet() +{ + QString saveDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); + QString filename = QFileDialog::getSaveFileName(this, tr("Backup Wallet"), saveDir, tr("Wallet Data (*.dat)")); + if(!filename.isEmpty()) { + if(!walletModel->backupWallet(filename)) { + QMessageBox::warning(this, tr("Backup Failed"), tr("There was an error trying to save the wallet data to the new location.")); + } + } +} + +void BitcoinGUI::changePassphrase() +{ + AskPassphraseDialog dlg(AskPassphraseDialog::ChangePass, this); + dlg.setModel(walletModel); + dlg.exec(); +} + +void BitcoinGUI::unlockWallet() +{ + if(!walletModel) + return; + // Unlock wallet when requested by wallet model + if(walletModel->getEncryptionStatus() == WalletModel::Locked) + { + AskPassphraseDialog::Mode mode = sender() == unlockWalletAction ? + AskPassphraseDialog::UnlockStaking : AskPassphraseDialog::Unlock; + AskPassphraseDialog dlg(mode, this); + dlg.setModel(walletModel); + dlg.exec(); + } +} + +void BitcoinGUI::lockWallet() +{ + if(!walletModel) + return; + + walletModel->setWalletLocked(true); +} + +void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) +{ + // activateWindow() (sometimes) helps with keyboard focus on Windows + if (isHidden()) + { + show(); + activateWindow(); + } + else if (isMinimized()) + { + showNormal(); + activateWindow(); + } + else if (GUIUtil::isObscured(this)) + { + raise(); + activateWindow(); + } + else if(fToggleHidden) + hide(); +} + +void BitcoinGUI::toggleHidden() +{ + showNormalIfMinimized(true); +} + +void BitcoinGUI::updateWeight() +{ + if (!pwalletMain) + return; + + TRY_LOCK(cs_main, lockMain); + if (!lockMain) + return; + + TRY_LOCK(pwalletMain->cs_wallet, lockWallet); + if (!lockWallet) + return; + + nWeight = pwalletMain->GetStakeWeight(); +} + +void BitcoinGUI::updateStakingIcon() +{ + updateWeight(); + + if (nLastCoinStakeSearchInterval && nWeight) + { + uint64_t nWeight = this->nWeight; + uint64_t nNetworkWeight = GetPoSKernelPS(); + unsigned nEstimateTime = GetTargetSpacing(nBestHeight) * nNetworkWeight / nWeight; + + QString text; + if (nEstimateTime < 60) + { + text = tr("%n second(s)", "", nEstimateTime); + } + else if (nEstimateTime < 60*60) + { + text = tr("%n minute(s)", "", nEstimateTime/60); + } + else if (nEstimateTime < 24*60*60) + { + text = tr("%n hour(s)", "", nEstimateTime/(60*60)); + } + else + { + text = tr("%n day(s)", "", nEstimateTime/(60*60*24)); + } + + nWeight /= COIN; + nNetworkWeight /= COIN; + + labelStakingIcon->setPixmap(QIcon(fUseBlackTheme ? ":/icons/black/staking_on" : ":/icons/staking_on").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); + labelStakingIcon->setToolTip(tr("Staking.
Your weight is %1
Network weight is %2
Expected time to earn reward is %3").arg(nWeight).arg(nNetworkWeight).arg(text)); + } + else + { + labelStakingIcon->setPixmap(QIcon(fUseBlackTheme ? ":/icons/black/staking_off" : ":/icons/staking_off").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); + if (pwalletMain && pwalletMain->IsLocked()) + labelStakingIcon->setToolTip(tr("Not staking because wallet is locked")); + else if (vNodes.empty()) + labelStakingIcon->setToolTip(tr("Not staking because wallet is offline")); + else if (IsInitialBlockDownload()) + labelStakingIcon->setToolTip(tr("Not staking because wallet is syncing")); + else if (!nWeight) + labelStakingIcon->setToolTip(tr("Not staking because you don't have mature coins")); + else + labelStakingIcon->setToolTip(tr("Not staking")); + } +} + +void BitcoinGUI::detectShutdown() +{ + if (ShutdownRequested()) + QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection); +} diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h new file mode 100644 index 0000000..b6bd769 --- /dev/null +++ b/src/qt/bitcoingui.h @@ -0,0 +1,236 @@ +#ifndef BITCOINGUI_H +#define BITCOINGUI_H + +#include +#include + +#include + +class TransactionTableModel; +class ClientModel; +class WalletModel; +class TransactionView; +class OverviewPage; +//class ClientControlPage; +class AddressBookPage; +class SendCoinsDialog; +class SignVerifyMessageDialog; +class Notificator; +class RPCConsole; +class MasternodeManager; +class MessagePage; +class MessageModel; +class BlockBrowser; + + +QT_BEGIN_NAMESPACE +class QLabel; +class QModelIndex; +class QProgressBar; +class QStackedWidget; +class QScrollArea; +QT_END_NAMESPACE + +/** + Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and + wallet models to give the user an up-to-date view of the current core state. +*/ +class BitcoinGUI : public QMainWindow +{ + Q_OBJECT + +public: + explicit BitcoinGUI(QWidget *parent = 0); + ~BitcoinGUI(); + + /** Set the client model. + The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic. + */ + void setClientModel(ClientModel *clientModel); + /** Set the wallet model. + The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending + functionality. + */ + void setWalletModel(WalletModel *walletModel); + void setMessageModel(MessageModel *messageModel); + +protected: + void changeEvent(QEvent *e); + void closeEvent(QCloseEvent *event); + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); + +private: + ClientModel *clientModel; + WalletModel *walletModel; + MessageModel *messageModel; + + QToolBar *toolbar; + + QStackedWidget *centralStackedWidget; + + QWidget *overviewWidget; + QScrollArea *overviewScroll; + OverviewPage *overviewPage; + QWidget *transactionsPage; + AddressBookPage *addressBookPage; + AddressBookPage *receiveCoinsPage; + SendCoinsDialog *sendCoinsPage; + //ClientControlPage *clientcontrolPage; + SignVerifyMessageDialog *signVerifyMessageDialog; + MasternodeManager *masternodeManagerPage; + MessagePage *messagePage; + BlockBrowser *blockBrowser; + + + //----------QLable---------// + + QLabel *labelEncryptionIcon; + QLabel *labelStakingIcon; + QLabel *labelConnectionsIcon; + QLabel *labelBlocksIcon; + QLabel *progressBarLabel; + QProgressBar *progressBar; + //----------QAction---------// + + QMenuBar *appMenuBar; + QAction *overviewAction; + // QAction *clientcontrolAction; + //QAction *generateAction; + QAction *historyAction; + QAction *quitAction; + QAction *sendCoinsAction; + QAction *addressBookAction; + QAction *signMessageAction; + QAction *verifyMessageAction; + QAction *aboutAction; + QAction *receiveCoinsAction; + QAction *optionsAction; + QAction *toggleHideAction; + QAction *exportAction; + QAction *encryptWalletAction; + QAction *backupWalletAction; + QAction *changePassphraseAction; + QAction *unlockWalletAction; + QAction *lockWalletAction; + QAction *aboutQtAction; + QAction *openRPCConsoleAction; + QAction *masternodeManagerAction; + QAction *messageAction; + QAction *blockAction; + QSystemTrayIcon *trayIcon; + Notificator *notificator; + TransactionView *transactionView; + RPCConsole *rpcConsole; + + QMovie *syncIconMovie; + /** Keep track of previous number of blocks, to detect progress */ + int prevBlocks; + + uint64_t nWeight; + + /** Create the main UI actions. */ + void createActions(); + /** Create the menu bar and sub-menus. */ + void createMenuBar(); + /** Create the toolbars */ + void createToolBars(); + /** Create system tray (notification) icon */ + void createTrayIcon(); + + void clearWidgets(); + +public slots: + /** Set number of connections shown in the UI */ + void setNumConnections(int count); + /** Set number of blocks shown in the UI */ + void setNumBlocks(int count); + /** Set the encryption status as shown in the UI. + @param[in] status current encryption status + @see WalletModel::EncryptionStatus + */ + void setEncryptionStatus(int status); + + /** Notify the user of an event from the core network or transaction handling code. + @param[in] title the message box / notification title + @param[in] message the displayed text + @param[in] modal true to use a message box, false to use a notification + @param[in] style style definitions (icon and used buttons - buttons only for message boxes) + @see CClientUIInterface::MessageBoxFlags + */ + void message(const QString &title, const QString &message, bool modal, unsigned int style); + /** Asks the user whether to pay the transaction fee or to cancel the transaction. + It is currently not possible to pass a return value to another thread through + BlockingQueuedConnection, so an indirected pointer is used. + https://bugreports.qt-project.org/browse/QTBUG-10440 + + @param[in] nFeeRequired the required fee + @param[out] payFee true to pay the fee, false to not pay the fee + */ + void askFee(qint64 nFeeRequired, bool *payFee); + void handleURI(QString strURI); + +private slots: + /** Switch to overview (home) page */ + void gotoOverviewPage(); + + // void gotoClientControlPage(); + /** Switch to history (transactions) page */ + void gotoHistoryPage(); + /** Switch to address book page */ + void gotoAddressBookPage(); + /** Switch to receive coins page */ + void gotoReceiveCoinsPage(); + /** Switch to send coins page */ + void gotoSendCoinsPage(); + /** Switch to block explorer*/ + void gotoBlockBrowser(); + + /** Switch to masternodemanagerpage */ + void gotoMasternodeManagerPage(); + + /** Show Sign/Verify Message dialog and switch to sign message tab */ + void gotoSignMessageTab(QString addr = ""); + /** Show Sign/Verify Message dialog and switch to verify message tab */ + void gotoVerifyMessageTab(QString addr = ""); + + void gotoMessagePage(); + + /** Show configuration dialog */ + void optionsClicked(); + /** Show about dialog */ + void aboutClicked(); +#ifndef Q_OS_MAC + /** Handle tray icon clicked */ + void trayIconActivated(QSystemTrayIcon::ActivationReason reason); +#endif + /** Show incoming transaction notification for new transactions. + + The new items are those between start and end inclusive, under the given parent item. + */ + void incomingTransaction(const QModelIndex & parent, int start, int end); + void incomingMessage(const QModelIndex & parent, int start, int end); + /** Encrypt the wallet */ + void encryptWallet(); + /** Backup the wallet */ + void backupWallet(); + /** Change encrypted wallet passphrase */ + void changePassphrase(); + /** Ask for passphrase to unlock wallet temporarily */ + void unlockWallet(); + + void lockWallet(); + + /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */ + void showNormalIfMinimized(bool fToggleHidden = false); + /** simply calls showNormalIfMinimized(true) for use in SLOT() macro */ + void toggleHidden(); + + void updateWeight(); + void updateStakingIcon(); + + /** called by a timer to check if fRequestShutdown has been set **/ + void detectShutdown(); +}; + +#endif // BITCOINGUI_H diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp new file mode 100644 index 0000000..05be682 --- /dev/null +++ b/src/qt/bitcoinstrings.cpp @@ -0,0 +1,207 @@ +#include +// Automatically generated by extract_strings.py +#ifdef __GNUC__ +#define UNUSED __attribute__((unused)) +#else +#define UNUSED +#endif +static const char UNUSED *bitcoin_strings[] = {QT_TRANSLATE_NOOP("bitcoin-core", "To use the %s option"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"%s, you must set a rpcpassword in the configuration file:\n" +"%s\n" +"It is recommended you use the following random password:\n" +"rpcuser=SONOrpc\n" +"rpcpassword=%s\n" +"(you do not need to remember this password)\n" +"The username and password MUST NOT be the same.\n" +"If the file does not exist, create it with owner-readable-only file " +"permissions.\n" +"It is also recommended to set alertnotify so you are notified of problems;\n" +"for example: alertnotify=echo %%s | mail -s \"SONO Alert\" admin@foo." +"com\n"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"An error occurred while setting up the RPC port %u for listening on IPv6, " +"falling back to IPv4: %s"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"An error occurred while setting up the RPC port %u for listening on IPv4: %s"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Warning: Please check that your computer's date and time are correct! If " +"your clock is wrong SONO will not work properly."), +QT_TRANSLATE_NOOP("bitcoin-core", "Options:"), +QT_TRANSLATE_NOOP("bitcoin-core", "This help message"), +QT_TRANSLATE_NOOP("bitcoin-core", "Specify configuration file (default: SONO.conf)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Specify pid file (default: SONOd.pid)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Specify data directory"), +QT_TRANSLATE_NOOP("bitcoin-core", "Specify wallet file (within data directory)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Set database cache size in megabytes (default: 25)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Set database disk log size in megabytes (default: 100)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Specify connection timeout in milliseconds (default: 5000)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Connect through socks proxy"), +QT_TRANSLATE_NOOP("bitcoin-core", "Select the version of socks proxy to use (4-5, default: 5)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Use proxy to reach tor hidden services (default: same as -proxy)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Allow DNS lookups for -addnode, -seednode and -connect"), +QT_TRANSLATE_NOOP("bitcoin-core", "Listen for connections on (default: 15714 or testnet: 25714)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Maintain at most connections to peers (default: 125)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Add a node to connect to and attempt to keep the connection open"), +QT_TRANSLATE_NOOP("bitcoin-core", "Connect only to the specified node(s)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Connect to a node to retrieve peer addresses, and disconnect"), +QT_TRANSLATE_NOOP("bitcoin-core", "Specify your own public address"), +QT_TRANSLATE_NOOP("bitcoin-core", "Only connect to nodes in network (IPv4, IPv6 or Tor)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Discover own IP address (default: 1 when listening and no -externalip)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Accept connections from outside (default: 1 if no -proxy or -connect)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Bind to given address. Use [host]:port notation for IPv6"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Query for peer addresses via DNS lookup, if low on addresses (default: 1 " +"unless -connect)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Always query for peer addresses via DNS lookup (default: 0)"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Sync time with other nodes. Disable if time on your system is precise e.g. " +"syncing with NTP (default: 1)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Sync checkpoints policy (default: strict)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Threshold for disconnecting misbehaving peers (default: 100)"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Number of seconds to keep misbehaving peers from reconnecting (default: " +"86400)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Maximum per-connection receive buffer, *1000 bytes (default: 5000)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Maximum per-connection send buffer, *1000 bytes (default: 1000)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Use UPnP to map the listening port (default: 1 when listening)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Use UPnP to map the listening port (default: 0)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Fee per KB to add to transactions you send"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"When creating transactions, ignore inputs with value less than this " +"(default: 0.01)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Accept command line and JSON-RPC commands"), +QT_TRANSLATE_NOOP("bitcoin-core", "Run in the background as a daemon and accept commands"), +QT_TRANSLATE_NOOP("bitcoin-core", "Use the test network"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Output debugging information (default: 0, supplying is optional)"), +QT_TRANSLATE_NOOP("bitcoin-core", "If is not supplied, output all debugging information."), +QT_TRANSLATE_NOOP("bitcoin-core", " can be:"), +QT_TRANSLATE_NOOP("bitcoin-core", "Prepend debug output with timestamp"), +QT_TRANSLATE_NOOP("bitcoin-core", "Shrink debug.log file on client startup (default: 1 when no -debug)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Send trace/debug info to console instead of debug.log file"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Enter regression test mode, which uses a special chain in which blocks can " +"be solved instantly. This is intended for regression testing tools and app " +"development."), +QT_TRANSLATE_NOOP("bitcoin-core", "Username for JSON-RPC connections"), +QT_TRANSLATE_NOOP("bitcoin-core", "Password for JSON-RPC connections"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Listen for JSON-RPC connections on (default: 15715 or testnet: 25715)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Allow JSON-RPC connections from specified IP address"), +QT_TRANSLATE_NOOP("bitcoin-core", "Send commands to node running on (default: 127.0.0.1)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Wait for RPC server to start"), +QT_TRANSLATE_NOOP("bitcoin-core", "Set the number of threads to service RPC calls (default: 4)"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Execute command when the best block changes (%s in cmd is replaced by block " +"hash)"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Execute command when a wallet transaction changes (%s in cmd is replaced by " +"TxID)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Require a confirmations for change (default: 0)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Minimize weight consumption (experimental) (default: 0)"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Execute command when a relevant alert is received (%s in cmd is replaced by " +"message)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Upgrade wallet to latest format"), +QT_TRANSLATE_NOOP("bitcoin-core", "Set key pool size to (default: 100)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Rescan the block chain for missing wallet transactions"), +QT_TRANSLATE_NOOP("bitcoin-core", "Attempt to recover private keys from a corrupt wallet.dat"), +QT_TRANSLATE_NOOP("bitcoin-core", "How many blocks to check at startup (default: 500, 0 = all)"), +QT_TRANSLATE_NOOP("bitcoin-core", "How thorough the block verification is (0-6, default: 1)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Imports blocks from external blk000?.dat file"), +QT_TRANSLATE_NOOP("bitcoin-core", "Keep at most unconnectable blocks in memory (default: %u)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Block creation options:"), +QT_TRANSLATE_NOOP("bitcoin-core", "Set minimum block size in bytes (default: 0)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Set maximum block size in bytes (default: 250000)"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Set maximum size of high-priority/low-fee transactions in bytes (default: " +"27000)"), +QT_TRANSLATE_NOOP("bitcoin-core", "SSL options: (see the Bitcoin Wiki for SSL setup instructions)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Use OpenSSL (https) for JSON-RPC connections"), +QT_TRANSLATE_NOOP("bitcoin-core", "Server certificate file (default: server.cert)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Server private key (default: server.pem)"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Acceptable ciphers (default: TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!" +"3DES:@STRENGTH)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Warning: Deprecated argument -debugnet ignored, use -debug=net"), +QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount for -paytxfee=: '%s'"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Warning: -paytxfee is set very high! This is the transaction fee you will " +"pay if you send a transaction."), +QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount for -mininput=: '%s'"), +QT_TRANSLATE_NOOP("bitcoin-core", "Initialization sanity check failed. SONO is shutting down."), +QT_TRANSLATE_NOOP("bitcoin-core", "Wallet %s resides outside data directory %s."), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Cannot obtain a lock on data directory %s. SONO is probably already " +"running."), +QT_TRANSLATE_NOOP("bitcoin-core", "Verifying database integrity..."), +QT_TRANSLATE_NOOP("bitcoin-core", "Error initializing wallet database environment %s!"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Warning: wallet.dat corrupt, data salvaged! Original wallet.dat saved as " +"wallet.{timestamp}.bak in %s; if your balance or transactions are incorrect " +"you should restore from a backup."), +QT_TRANSLATE_NOOP("bitcoin-core", "wallet.dat corrupt, salvage failed"), +QT_TRANSLATE_NOOP("bitcoin-core", "Unknown -socks proxy version requested: %i"), +QT_TRANSLATE_NOOP("bitcoin-core", "Unknown network specified in -onlynet: '%s'"), +QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -proxy address: '%s'"), +QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -tor address: '%s'"), +QT_TRANSLATE_NOOP("bitcoin-core", "Cannot resolve -bind address: '%s'"), +QT_TRANSLATE_NOOP("bitcoin-core", "Failed to listen on any port. Use -listen=0 if you want this."), +QT_TRANSLATE_NOOP("bitcoin-core", "Cannot resolve -externalip address: '%s'"), +QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount for -reservebalance="), +QT_TRANSLATE_NOOP("bitcoin-core", "Unable to sign checkpoint, wrong checkpointkey?\n"), +QT_TRANSLATE_NOOP("bitcoin-core", "Loading block index..."), +QT_TRANSLATE_NOOP("bitcoin-core", "Error loading blkindex.dat"), +QT_TRANSLATE_NOOP("bitcoin-core", "Loading wallet..."), +QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet corrupted"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Warning: error reading wallet.dat! All keys read correctly, but transaction " +"data or address book entries might be missing or incorrect."), +QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet requires newer version of SONO"), +QT_TRANSLATE_NOOP("bitcoin-core", "Wallet needed to be rewritten: restart SONO to complete"), +QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat"), +QT_TRANSLATE_NOOP("bitcoin-core", "Cannot downgrade wallet"), +QT_TRANSLATE_NOOP("bitcoin-core", "Cannot write default address"), +QT_TRANSLATE_NOOP("bitcoin-core", "Rescanning..."), +QT_TRANSLATE_NOOP("bitcoin-core", "Loading addresses..."), +QT_TRANSLATE_NOOP("bitcoin-core", "Done loading"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Unable to bind to %s on this computer. SONO is probably already running."), +QT_TRANSLATE_NOOP("bitcoin-core", "Unable to bind to %s on this computer (bind returned error %d, %s)"), +QT_TRANSLATE_NOOP("bitcoin-core", "SONO version"), +QT_TRANSLATE_NOOP("bitcoin-core", "Usage:"), +QT_TRANSLATE_NOOP("bitcoin-core", "Send command to -server or SONOd"), +QT_TRANSLATE_NOOP("bitcoin-core", "List commands"), +QT_TRANSLATE_NOOP("bitcoin-core", "Get help for a command"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"You must set rpcpassword= in the configuration file:\n" +"%s\n" +"If the file does not exist, create it with owner-readable-only file " +"permissions."), +QT_TRANSLATE_NOOP("bitcoin-core", "Error: Wallet locked, unable to create transaction!"), +QT_TRANSLATE_NOOP("bitcoin-core", "Error: Wallet unlocked for staking only, unable to create transaction."), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Error: This transaction requires a transaction fee of at least %s because of " +"its amount, complexity, or use of recently received funds!"), +QT_TRANSLATE_NOOP("bitcoin-core", "Error: Transaction creation failed!"), +QT_TRANSLATE_NOOP("bitcoin-core", "Sending..."), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Error: The transaction was rejected! This might happen if some of the coins " +"in your wallet were already spent, such as if you used a copy of wallet.dat " +"and coins were spent in the copy but not marked as spent here."), +QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount"), +QT_TRANSLATE_NOOP("bitcoin-core", "Insufficient funds"), +QT_TRANSLATE_NOOP("bitcoin-core", "Error"), +QT_TRANSLATE_NOOP("bitcoin-core", "Warning"), +QT_TRANSLATE_NOOP("bitcoin-core", "Information"), +QT_TRANSLATE_NOOP("bitcoin-core", "Warning: This version is obsolete, upgrade required!"), +QT_TRANSLATE_NOOP("bitcoin-core", "WARNING: syncronized checkpoint violation detected, but skipped!"), +QT_TRANSLATE_NOOP("bitcoin-core", "Error: Disk space is low!"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"This is a pre-release test build - use at your own risk - do not use for " +"mining or merchant applications"), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"WARNING: Invalid checkpoint found! Displayed transactions may not be " +"correct! You may need to upgrade, or notify developers."), +}; \ No newline at end of file diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp new file mode 100644 index 0000000..71475b5 --- /dev/null +++ b/src/qt/bitcoinunits.cpp @@ -0,0 +1,181 @@ +#include "bitcoinunits.h" + +#include + +BitcoinUnits::BitcoinUnits(QObject *parent): + QAbstractListModel(parent), + unitlist(availableUnits()) +{ +} + +QList BitcoinUnits::availableUnits() +{ + QList unitlist; + unitlist.append(BTC); + unitlist.append(mBTC); + unitlist.append(uBTC); + return unitlist; +} + +bool BitcoinUnits::valid(int unit) +{ + switch(unit) + { + case BTC: + case mBTC: + case uBTC: + return true; + default: + return false; + } +} + +QString BitcoinUnits::name(int unit) +{ + switch(unit) + { + case BTC: return QString("SONO"); + case mBTC: return QString("mSONO"); + case uBTC: return QString::fromUtf8("μSONO"); + default: return QString("???"); + } +} + +QString BitcoinUnits::description(int unit) +{ + switch(unit) + { + case BTC: return QString("SONOs"); + case mBTC: return QString("Milli-SONOs (1 / 1,000)"); + case uBTC: return QString("Micro-SONOs (1 / 1,000,000)"); + default: return QString("???"); + } +} + +qint64 BitcoinUnits::factor(int unit) +{ + switch(unit) + { + case BTC: return 100000000; + case mBTC: return 100000; + case uBTC: return 100; + default: return 100000000; + } +} + +int BitcoinUnits::amountDigits(int unit) +{ + switch(unit) + { + case BTC: return 8; // 21,000,000 (# digits, without commas) + case mBTC: return 11; // 21,000,000,000 + case uBTC: return 14; // 21,000,000,000,000 + default: return 0; + } +} + +int BitcoinUnits::decimals(int unit) +{ + switch(unit) + { + case BTC: return 8; + case mBTC: return 5; + case uBTC: return 2; + default: return 0; + } +} + +QString BitcoinUnits::format(int unit, qint64 n, bool fPlus) +{ + // Note: not using straight sprintf here because we do NOT want + // localized number formatting. + if(!valid(unit)) + return QString(); // Refuse to format invalid unit + qint64 coin = factor(unit); + int num_decimals = decimals(unit); + qint64 n_abs = (n > 0 ? n : -n); + qint64 quotient = n_abs / coin; + qint64 remainder = n_abs % coin; + QString quotient_str = QString::number(quotient); + QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0'); + + // Right-trim excess zeros after the decimal point + int nTrim = 0; + for (int i = remainder_str.size()-1; i>=2 && (remainder_str.at(i) == '0'); --i) + ++nTrim; + remainder_str.chop(nTrim); + + if (n < 0) + quotient_str.insert(0, '-'); + else if (fPlus && n > 0) + quotient_str.insert(0, '+'); + return quotient_str + QString(".") + remainder_str; +} + +QString BitcoinUnits::formatWithUnit(int unit, qint64 amount, bool plussign) +{ + return format(unit, amount, plussign) + QString(" ") + name(unit); +} + +bool BitcoinUnits::parse(int unit, const QString &value, qint64 *val_out) +{ + if(!valid(unit) || value.isEmpty()) + return false; // Refuse to parse invalid unit or empty string + int num_decimals = decimals(unit); + QStringList parts = value.split("."); + + if(parts.size() > 2) + { + return false; // More than one dot + } + QString whole = parts[0]; + QString decimals; + + if(parts.size() > 1) + { + decimals = parts[1]; + } + if(decimals.size() > num_decimals) + { + return false; // Exceeds max precision + } + bool ok = false; + QString str = whole + decimals.leftJustified(num_decimals, '0'); + + if(str.size() > 18) + { + return false; // Longer numbers will exceed 63 bits + } + qint64 retvalue = str.toLongLong(&ok); + if(val_out) + { + *val_out = retvalue; + } + return ok; +} + +int BitcoinUnits::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return unitlist.size(); +} + +QVariant BitcoinUnits::data(const QModelIndex &index, int role) const +{ + int row = index.row(); + if(row >= 0 && row < unitlist.size()) + { + Unit unit = unitlist.at(row); + switch(role) + { + case Qt::EditRole: + case Qt::DisplayRole: + return QVariant(name(unit)); + case Qt::ToolTipRole: + return QVariant(description(unit)); + case UnitRole: + return QVariant(static_cast(unit)); + } + } + return QVariant(); +} diff --git a/src/qt/bitcoinunits.h b/src/qt/bitcoinunits.h new file mode 100644 index 0000000..fa1bf0d --- /dev/null +++ b/src/qt/bitcoinunits.h @@ -0,0 +1,69 @@ +#ifndef BITCOINUNITS_H +#define BITCOINUNITS_H + +#include +#include + +/** Bitcoin unit definitions. Encapsulates parsing and formatting + and serves as list model for drop-down selection boxes. +*/ +class BitcoinUnits: public QAbstractListModel +{ + Q_OBJECT + +public: + explicit BitcoinUnits(QObject *parent); + + /** Bitcoin units. + @note Source: https://en.bitcoin.it/wiki/Units . Please add only sensible ones + */ + enum Unit + { + BTC, + mBTC, + uBTC + }; + + //! @name Static API + //! Unit conversion and formatting + ///@{ + + //! Get list of units, for drop-down box + static QList availableUnits(); + //! Is unit ID valid? + static bool valid(int unit); + //! Short name + static QString name(int unit); + //! Longer description + static QString description(int unit); + //! Number of Satoshis (1e-8) per unit + static qint64 factor(int unit); + //! Number of amount digits (to represent max number of coins) + static int amountDigits(int unit); + //! Number of decimals left + static int decimals(int unit); + //! Format as string + static QString format(int unit, qint64 amount, bool plussign=false); + //! Format as string (with unit) + static QString formatWithUnit(int unit, qint64 amount, bool plussign=false); + //! Parse string to coin amount + static bool parse(int unit, const QString &value, qint64 *val_out); + ///@} + + //! @name AbstractListModel implementation + //! List model for unit drop-down selection box. + ///@{ + enum RoleIndex { + /** Unit identifier */ + UnitRole = Qt::UserRole + }; + int rowCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + ///@} + +private: + QList unitlist; +}; +typedef BitcoinUnits::Unit BitcoinUnit; + +#endif // BITCOINUNITS_H diff --git a/src/qt/blockbrowser.cpp b/src/qt/blockbrowser.cpp new file mode 100644 index 0000000..330601f --- /dev/null +++ b/src/qt/blockbrowser.cpp @@ -0,0 +1,575 @@ +#include "blockbrowser.h" +#include "ui_blockbrowser.h" + +#include "main.h" +#include "wallet.h" +#include "base58.h" +#include "clientmodel.h" +#include "walletmodel.h" +#include "rpcconsole.h" +#include "transactionrecord.h" +#include "optionsmodel.h" +#include "guiutil.h" +#include "guiconstants.h" +#include "init.h" +#include "rpcserver.h" + +using namespace json_spirit; + +#include +#include + +#include +#include + +#define DECORATION_SIZE 48 +#define NUM_ITEMS 10 + +BlockBrowser::BlockBrowser(QWidget *parent) : + ui(new Ui::BlockBrowser), + model(0) +{ + ui->setupUi(this); + + connect(ui->blockButton, SIGNAL(pressed()), this, SLOT(blockClicked())); + connect(ui->txButton, SIGNAL(pressed()), this, SLOT(txClicked())); + + // Statistics + connect(ui->startButton, SIGNAL(pressed()), this, SLOT(updateStatistics())); +} +//Statistics +int heightPrevious = -1; +int connectionPrevious = -1; +int volumePrevious = -1; +double rewardPrevious = -1; +double netPawratePrevious = -1; +double pawratePrevious = -1; +double hardnessPrevious = -1; +double hardnessPrevious2 = -1; +int stakeminPrevious = -1; +int stakemaxPrevious = -1; +QString stakecPrevious = ""; + +BlockBrowser::~BlockBrowser() +{ + delete ui; +} + +double getBlockHardness(int height) +{ + const CBlockIndex* blockindex = getBlockIndex(height); + + int nShift = (blockindex->nBits >> 24) & 0xff; + + double dDiff = + (double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff); + + while (nShift < 29) + { + dDiff *= 256.0; + nShift++; + } + while (nShift > 29) + { + dDiff /= 256.0; + nShift--; + } + + return dDiff; +} + +int getBlockHashrate(int height) +{ + int lookup = height; + + double timeDiff = getBlockTime(height) - getBlockTime(1); + double timePerBlock = timeDiff / lookup; + + return (boost::int64_t)(((double)getBlockHardness(height) * pow(2.0, 32)) / timePerBlock); +} + +const CBlockIndex* getBlockIndex(int height) +{ + std::string hex = getBlockHash(height); + uint256 hash(hex); + return mapBlockIndex[hash]; +} + +std::string getBlockHash(int Height) +{ + if(Height > pindexBest->nHeight) { return "00000f14896ba98013ed07e0ecf6e29b360a20898aab5c23238fd08c17ac1b10"; } + if(Height < 0) { return "00000f14896ba98013ed07e0ecf6e29b360a20898aab5c23238fd08c17ac1b10"; } + int desiredheight; + desiredheight = Height; + if (desiredheight < 0 || desiredheight > nBestHeight) + return 0; + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hashBestChain]; + while (pblockindex->nHeight > desiredheight) + pblockindex = pblockindex->pprev; + return pblockindex->phashBlock->GetHex(); +} + +int getBlockTime(int Height) +{ + std::string strHash = getBlockHash(Height); + uint256 hash(strHash); + + if (mapBlockIndex.count(hash) == 0) + return 0; + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + return pblockindex->nTime; +} + +std::string getBlockMerkle(int Height) +{ + std::string strHash = getBlockHash(Height); + uint256 hash(strHash); + + if (mapBlockIndex.count(hash) == 0) + return 0; + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + return pblockindex->hashMerkleRoot.ToString().substr(0,10).c_str(); +} + +int getBlocknBits(int Height) +{ + std::string strHash = getBlockHash(Height); + uint256 hash(strHash); + + if (mapBlockIndex.count(hash) == 0) + return 0; + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + return pblockindex->nBits; +} + +int getBlockNonce(int Height) +{ + std::string strHash = getBlockHash(Height); + uint256 hash(strHash); + + if (mapBlockIndex.count(hash) == 0) + return 0; + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + return pblockindex->nNonce; +} + +std::string getBlockDebug(int Height) +{ + std::string strHash = getBlockHash(Height); + uint256 hash(strHash); + + if (mapBlockIndex.count(hash) == 0) + return 0; + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + return pblockindex->ToString(); +} + +int blocksInPastHours(int hours) +{ + int wayback = hours * 3600; + bool check = true; + int height = pindexBest->nHeight; + int heightHour = pindexBest->nHeight; + int utime = (int)time(NULL); + int target = utime - wayback; + + while(check) + { + if(getBlockTime(heightHour) < target) + { + check = false; + return height - heightHour; + } else { + heightHour = heightHour - 1; + } + } + + return 0; +} + +double getTxTotalValue(std::string txid) +{ + uint256 hash; + hash.SetHex(txid); + + CTransaction tx; + uint256 hashBlock = 0; + if (!GetTransaction(hash, tx, hashBlock)) + return 1000; + + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << tx; + + double value = 0; + double buffer = 0; + for (unsigned int i = 0; i < tx.vout.size(); i++) + { + const CTxOut& txout = tx.vout[i]; + + buffer = value + convertCoins(txout.nValue); + value = buffer; + } + + return value; +} + +double convertCoins(int64_t amount) +{ + return (double)amount / (double)COIN; +} + +std::string getOutputs(std::string txid) +{ + uint256 hash; + hash.SetHex(txid); + + CTransaction tx; + uint256 hashBlock = 0; + if (!GetTransaction(hash, tx, hashBlock)) + return "fail"; + + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << tx; + + std::string str = ""; + for (unsigned int i = 0; i < tx.vout.size(); i++) + + + return str; +} + +std::string getInputs(std::string txid) +{ + uint256 hash; + hash.SetHex(txid); + + CTransaction tx; + uint256 hashBlock = 0; + if (!GetTransaction(hash, tx, hashBlock)) + return "fail"; + + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << tx; + + std::string str = ""; + for (unsigned int i = 0; i < tx.vin.size(); i++) + + return str; +} + +int64_t getInputValue(CTransaction tx, CScript target) +{ + for (unsigned int i = 0; i < tx.vin.size(); i++) + { + const CTxOut& txout = tx.vout[i]; + if(txout.scriptPubKey == target) + { + return txout.nValue; + } + } + return 0; +} + +double getTxFees(std::string txid) +{ + uint256 hash; + hash.SetHex(txid); + + + CTransaction tx; + uint256 hashBlock = 0; + if (!GetTransaction(hash, tx, hashBlock)) + return 51; + + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << tx; + + double value = 0; + double buffer = 0; + for (unsigned int i = 0; i < tx.vout.size(); i++) + { + const CTxOut& txout = tx.vout[i]; + + buffer = value + convertCoins(txout.nValue); + value = buffer; + } + + double value0 = 0; + double buffer0 = 0; + for (unsigned int i = 0; i < tx.vin.size(); i++) + { + uint256 hash0; + const CTxIn& vin = tx.vin[i]; + hash0.SetHex(vin.prevout.hash.ToString()); + CTransaction wtxPrev; + uint256 hashBlock0 = 0; + if (!GetTransaction(hash0, wtxPrev, hashBlock0)) + return 0; + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << wtxPrev; + const CScript target = wtxPrev.vout[vin.prevout.n].scriptPubKey; + buffer0 = value0 + convertCoins(getInputValue(wtxPrev, target)); + value0 = buffer0; + } + + return value0 - value; +} + +void BlockBrowser::updateExplorer(bool block) +{ + if(block) + { + ui->heightLabel->show(); + ui->heightLabel_2->show(); + ui->hashLabel->show(); + ui->hashBox->show(); + ui->merkleLabel->show(); + ui->merkleBox->show(); + ui->nonceLabel->show(); + ui->nonceBox->show(); + ui->bitsLabel->show(); + ui->bitsBox->show(); + ui->timeLabel->show(); + ui->timeBox->show(); + ui->hardLabel->show(); + ui->hardBox->show();; + ui->pawLabel->show(); + int height = ui->heightBox->value(); + if (height > pindexBest->nHeight) + { + ui->heightBox->setValue(pindexBest->nHeight); + height = pindexBest->nHeight; + } + int Pawrate = getBlockHashrate(height); + double Pawrate2 = 0.000; + Pawrate2 = ((double)Pawrate / 1000); + std::string hash = getBlockHash(height); + std::string merkle = getBlockMerkle(height);ui->pawLabel->show(); + int nBits = getBlocknBits(height); + int nNonce = getBlockNonce(height); + int atime = getBlockTime(height); + double hardness = getBlockHardness(height); + QString QHeight = QString::number(height); + QString QHash = QString::fromUtf8(hash.c_str()); + QString QMerkle = QString::fromUtf8(merkle.c_str()); + QString QBits = QString::number(nBits); + QString QNonce = QString::number(nNonce); + QString QTime = QString::number(atime); + QString QHardness = QString::number(hardness, 'f', 6); + ui->heightLabel->setText(QHeight); + ui->hashBox->setText(QHash); + ui->merkleBox->setText(QMerkle); + ui->bitsBox->setText(QBits); + ui->nonceBox->setText(QNonce); + ui->timeBox->setText(QTime); + ui->hardBox->setText(QHardness); + } + + if(block == false) { + ui->txID->show(); + ui->txLabel->show(); + ui->valueLabel->show(); + ui->valueBox->show(); + ui->inputLabel->show(); + ui->inputBox->show(); + ui->outputLabel->show(); + ui->outputBox->show(); + ui->feesLabel->show(); + ui->feesBox->show(); + std::string txid = ui->txBox->text().toUtf8().constData(); + double value = getTxTotalValue(txid); + double fees = getTxFees(txid); + std::string outputs = getOutputs(txid); + std::string inputs = getInputs(txid); + QString QValue = QString::number(value, 'f', 6); + QString QID = QString::fromUtf8(txid.c_str()); + QString QOutputs = QString::fromUtf8(outputs.c_str()); + QString QInputs = QString::fromUtf8(inputs.c_str()); + QString QFees = QString::number(fees, 'f', 6); + ui->valueBox->setText(QValue + " SONO"); + ui->txID->setText(QID); + ui->outputBox->setText(QOutputs); + ui->inputBox->setText(QInputs); + ui->feesBox->setText(QFees + " SONO"); + } +} + + +void BlockBrowser::txClicked() +{ + updateExplorer(false); +} + +void BlockBrowser::blockClicked() +{ + updateExplorer(true); +} + + +//Statistics Section +void BlockBrowser::updateStatistics() +{ + double pHardness = GetDifficulty(); + double pHardness2 = GetDifficulty(GetLastBlockIndex(pindexBest, true)); + int pPawrate = GetPoWMHashPS(); + double pPawrate2 = 0.000; + int nHeight = pindexBest->nHeight; + double nSubsidy = 1; + if(pindexBest->nHeight < 240000 && pindexBest->nHeight > 500) + { + nSubsidy = 1; + } + else if(pindexBest->nHeight > 240001) + { + nSubsidy = 2; + } + uint64_t nMinWeight = 0; //, nMaxWeight = 0, nWeight = 0 + //pwalletMain->GetStakeWeight(*pwalletMain, nMinWeight, nMaxWeight, nWeight); + pwalletMain->GetStakeWeight(); + uint64_t nNetworkWeight = GetPoSKernelPS(); + int64_t volume = ((pindexBest->nMoneySupply)/COIN); + int peers = this->clientModel->getNumConnections(); + pPawrate2 = (double)pPawrate; + QString height = QString::number(nHeight); + QString stakemin = QString::number(nMinWeight); + QString stakemax = QString::number(nNetworkWeight); + QString phase = ""; + if (pindexBest->nHeight < 240000) + { + phase = "PoW + PoS Stage 1 "; + } + else if (pindexBest->nHeight > 240000) + { + phase = "PoW + PoS Stage 2 "; + } + + QString subsidy = QString::number(nSubsidy, 'f', 6); + QString hardness = QString::number(pHardness, 'f', 6); + QString hardness2 = QString::number(pHardness2, 'f', 6); + QString pawrate = QString::number(pPawrate2, 'f', 3); + QString Qlpawrate = clientModel->getLastBlockDate().toString(); + + QString QPeers = QString::number(peers); + // QString qVolume = QLocale(QLocale::English).toString(volume); + QString qVolume = QString::number(volume); + + if(nHeight > heightPrevious) + { + ui->heightBox_3->setText("" + height + ""); + } else { + ui->heightBox_3->setText(height); + } + + if(0 > stakeminPrevious) + { + ui->minBox_2->setText("" + stakemin + ""); + } else { + ui->minBox_2->setText(stakemin); + } + if(0 > stakemaxPrevious) + { + ui->maxBox_2->setText("" + stakemax + ""); + } else { + ui->maxBox_2->setText(stakemax); + } + + if(phase != stakecPrevious) + { + ui->cBox_2->setText("" + phase + ""); + } else { + ui->cBox_2->setText(phase); + } + + + if(nSubsidy < rewardPrevious) + { + ui->rewardBox_2->setText("" + subsidy + ""); + } else { + ui->rewardBox_2->setText(subsidy); + } + + if(pHardness > hardnessPrevious) + { + ui->diffBox_2->setText("" + hardness + ""); + } else if(pHardness < hardnessPrevious) { + ui->diffBox_2->setText("" + hardness + ""); + } else { + ui->diffBox_2->setText(hardness); + } + + if(pHardness2 > hardnessPrevious2) + { + ui->diffBox2_2->setText("" + hardness2 + ""); + } else if(pHardness2 < hardnessPrevious2) { + ui->diffBox2_2->setText("" + hardness2 + ""); + } else { + ui->diffBox2_2->setText(hardness2); + } + + if(pPawrate2 > netPawratePrevious) + { + ui->pawrateBox_2->setText("" + pawrate + " MH/s"); + } else if(pPawrate2 < netPawratePrevious) { + ui->pawrateBox_2->setText("" + pawrate + " MH/s"); + } else { + ui->pawrateBox_2->setText(pawrate + " GH/s"); + } + + if(Qlpawrate != pawratePrevious) + { + ui->localBox_2->setText("" + Qlpawrate + ""); + } else { + ui->localBox_2->setText(Qlpawrate); + } + + if(peers > connectionPrevious) + { + ui->connectionBox_2->setText("" + QPeers + ""); + } else if(peers < connectionPrevious) { + ui->connectionBox_2->setText("" + QPeers + ""); + } else { + ui->connectionBox_2->setText(QPeers); + } + + if(volume > volumePrevious) + { + ui->volumeBox_2->setText("" + qVolume + " SONO" + ""); + } else if(volume < volumePrevious) { + ui->volumeBox_2->setText("" + qVolume + " SONO" + ""); + } else { + ui->volumeBox_2->setText(qVolume + " SONO"); + } + updatePrevious(nHeight, nMinWeight, nNetworkWeight, phase, nSubsidy, pHardness, pHardness2, pPawrate2, Qlpawrate, peers, volume); +} + +void BlockBrowser::updatePrevious(int nHeight, int nMinWeight, int nNetworkWeight, QString phase, double nSubsidy, double pHardness, double pHardness2, double pPawrate2, QString Qlpawrate, int peers, int volume) +{ + heightPrevious = nHeight; + stakeminPrevious = nMinWeight; + stakemaxPrevious = nNetworkWeight; + stakecPrevious = phase; + rewardPrevious = nSubsidy; + hardnessPrevious = pHardness; + hardnessPrevious2 = pHardness2; + netPawratePrevious = pPawrate2; + pawratePrevious = Qlpawrate; + connectionPrevious = peers; + volumePrevious = volume; +} + +void BlockBrowser::setModel(WalletModel *model) +{ + this->model = model; +} diff --git a/src/qt/blockbrowser.h b/src/qt/blockbrowser.h new file mode 100644 index 0000000..9a861e5 --- /dev/null +++ b/src/qt/blockbrowser.h @@ -0,0 +1,91 @@ +#ifndef BLOCKBROWSER_H +#define BLOCKBROWSER_H + +#include "clientmodel.h" +#include "walletmodel.h" +#include "main.h" +#include "wallet.h" +#include "base58.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +double getBlockHardness(int); +double getTxTotalValue(std::string); +double convertCoins(int64_t); +double getTxFees(std::string); +int getBlockTime(int); +int getBlocknBits(int); +int getBlockNonce(int); +int blocksInPastHours(int); +int getBlockHashrate(int); +std::string getInputs(std::string); +std::string getOutputs(std::string); +std::string getBlockHash(int); +std::string getBlockMerkle(int); +bool addnode(std::string); +const CBlockIndex* getBlockIndex(int); +int64_t getInputValue(CTransaction, CScript); + + +namespace Ui { +class BlockBrowser; +} +class ClientModel; +class WalletModel; + +QT_BEGIN_NAMESPACE +class QModelIndex; +QT_END_NAMESPACE + +class BlockBrowser : public QWidget +{ + Q_OBJECT + +public: + explicit BlockBrowser(QWidget *parent = 0); + ~BlockBrowser(); + + void setModel(WalletModel *model); + + //Statistics + int heightPrevious; + int connectionPrevious; + int volumePrevious; + int stakeminPrevious; + int stakemaxPrevious; + QString stakecPrevious; + double rewardPrevious; + double netPawratePrevious; + QString pawratePrevious; + double hardnessPrevious; + double hardnessPrevious2; + + +public slots: + + void blockClicked(); + void txClicked(); + void updateExplorer(bool); + void updateStatistics(); + void updatePrevious(int, int, int, QString, double, double, double, double, QString, int, int); + +signals: + +private slots: + +private: + Ui::BlockBrowser *ui; + WalletModel *model; + ClientModel *clientModel; +}; + +#endif // BLOCKBROWSER_H diff --git a/src/qt/clientcontrolpage.cpp b/src/qt/clientcontrolpage.cpp new file mode 100644 index 0000000..2bd38ed --- /dev/null +++ b/src/qt/clientcontrolpage.cpp @@ -0,0 +1,211 @@ +#include "clientcontrolpage.h" +#include "ui_clientcontrolpage.h" + +#include "clientmodel.h" +#include "walletmodel.h" +#include "optionsmodel.h" +#include "guiutil.h" +#include "guiconstants.h" + +#include +#include +#include +#include +#include +#include + +// Identify client version +#include +#include +#include + +#define DECORATION_SIZE 48 +#define NUM_ITEMS 10 + +ClientControlPage::ClientControlPage(QWidget *parent) : + ui(new Ui::ClientControlPage), + model(0) +{ + ui->setupUi(this); + + QFileInfo check_standalone(QDir::currentPath()); + if(!check_standalone.exists()) + { + /*Client Update + ui->chck4_upd8->setEnabled(false); + ui->dwngrd_opt->setEnabled(false); + ui->checkBoxupd8->setEnabled(false); + ui->minCLIE->setEnabled(false); + ui->CS_submit->setEnabled(false); + ui->br_input->setEnabled(false); + ui->BR_submit->setEnabled(false); + ui->optin_test->setEnabled(false); + ui->AU_apply->setEnabled(false); + + QMessageBox::warning(this, "Error", + "Local directory not found ---> Error 54", + QMessageBox::Ok ); + } + else if(check_standalone.exists()) + {*/ + // TODO: Fix this up for OS porting +#ifdef Q_OS_WIN + // READ INSTALLED VERSION + QFile file(":/version"); + if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) + // error out if not accesable + QMessageBox::information(0,"info",file.errorString()); + QTextStream in(&file); + ui->instVER->setPlainText(in.readLine()); + + // READ LIVE (CURRENT) VERSION + //open a file + QFile iniFILE(QDir::currentPath() + "/SONO.cfg"); + // if(!iniFILE.open(QIODevice::ReadOnly | QIODevice::Text)) + // error out if not accesable + // QMessageBox::information(0,"info",iniFILE.errorString()); + QTextStream streamINI(&iniFILE); + ui->dDIR->setPlainText(streamINI.readLine()); + + QDir directory(ui->dDIR->toPlainText()); + QString curtxt = directory.filePath("version.check"); + iniFILE.close(); + + QFile fileV(curtxt); + //if(!fileV.open(QIODevice::ReadOnly | QIODevice::Text)) + // error out if not accesable + //QMessageBox::information(0,"info",fileV.errorString()); + QTextStream inV(&fileV); + ui->liveVER->setPlainText(inV.readAll()); + + QFileInfo check_call(directory.filePath("upd8.skip")); + if (check_call.exists() && check_call.isFile()) + { + ui->checkBoxupd8->setChecked(false); + } + + // Non-client Call + else if(!check_call.exists()) + { + ui->checkBoxupd8->setChecked(true); + } +#endif + } + +} + +ClientControlPage::~ClientControlPage() +{ + delete ui; +} + + +void ClientControlPage::on_chck4_upd8_clicked() +{ + QFile iniFILE(QDir::currentPath() + "/SONO.cfg"); + if(!iniFILE.open(QIODevice::ReadOnly | QIODevice::Text)) + // error out if not accesable + QMessageBox::information(0,"info",iniFILE.errorString()); + QTextStream streamINI(&iniFILE); + ui->dDIR->setPlainText(streamINI.readLine()); + + QDir directory(ui->dDIR->toPlainText()); + QString genCheck = directory.filePath("version.call"); + iniFILE.close(); + + QFile genCall(genCheck); + if(genCall.open(QIODevice::ReadWrite)) + { + QTextStream saturate(&genCall); + saturate << "Temp File that flags verCheck.exe" << endl; + } + + QProcess *process = new QProcess(); + QString fileX = QDir::currentPath() + "/SONO-qt.exe"; + process->start(fileX); +} + +void ClientControlPage::on_dwngrd_opt_clicked() +{ + QMessageBox::information(this, "Unavailable Versions", + "V4.0.0 is the minimum version, cannot be downgraded,", + QMessageBox::Ok ); +} + +void ClientControlPage::on_CS_submit_clicked() +{ + if(ui->minCLIE->isChecked()) + { + QMessageBox::information(this, "Already Installed", + "You are already running the Minimal Client", + QMessageBox::Ok ); + this->ui->cliePREV->setText("Select a Client to Preview"); + + // if(ui->radioButtonViewLocalData->isChecked()) + // { + ui->minCLIE->setChecked(true); + ui->minCLIE->setCheckable(true); + ui->minCLIE->update(); + ui->minCLIE->setCheckable(true); + // } + + } + else + { + QMessageBox::information(this, "You haven't selected anything yet", + "Please make a selection first.", + QMessageBox::Ok ); + } +} + +void ClientControlPage::on_BR_submit_clicked() +{ + QMessageBox::information(this, "Coming in v4.0.0", + "Please email your error to contact@SONO.tech", + QMessageBox::Ok ); +} + +void ClientControlPage::on_AU_apply_clicked() +{ + QFile iniFILE(QDir::currentPath() + "/SONO.cfg"); + if(!iniFILE.open(QIODevice::ReadOnly | QIODevice::Text)) + // error out if not accesable + QMessageBox::information(0,"info",iniFILE.errorString()); + QTextStream streamINI(&iniFILE); + ui->dDIR->setPlainText(streamINI.readLine()); + + QDir directory(ui->dDIR->toPlainText()); + QString upSkip = directory.filePath("upd8.skip"); + QString rmSKIP = directory.filePath("upd8.skip"); + iniFILE.close(); + + if(ui->checkBoxupd8->isChecked()) + { + if (QFile::exists(rmSKIP)) { + QFile::remove(rmSKIP); + } + } + else + { + // Skip Updating + QFile skipCall(upSkip); + if(skipCall.open(QIODevice::ReadWrite)) + { + QTextStream saturate(&skipCall); + saturate << "Temp File that flags verCheck.exe" << endl; + } + } +} + +void ClientControlPage::on_minCLIE_clicked() +{ + if(ui->minCLIE->isChecked()) + { + QPixmap pix(":/images/cliecked"); + this->ui->cliePREV->setPixmap(pix); + } + else + { + //Do Nothing + } +} diff --git a/src/qt/clientcontrolpage.h b/src/qt/clientcontrolpage.h new file mode 100644 index 0000000..948c7b7 --- /dev/null +++ b/src/qt/clientcontrolpage.h @@ -0,0 +1,43 @@ +#ifndef CLIENTCONTROLPAGE_H +#define CLIENTCONTROLPAGE_H + +#include + +namespace Ui { + class ClientControlPage; +} +class ClientModel; +class WalletModel; + +QT_BEGIN_NAMESPACE +class QModelIndex; +QT_END_NAMESPACE + +/** Overview ("home") page widget */ +class ClientControlPage : public QWidget +{ + Q_OBJECT + +public: + explicit ClientControlPage(QWidget *parent = 0); + ~ClientControlPage(); + void setModel(WalletModel *model); + +public slots: + +signals: + +private: + Ui::ClientControlPage *ui; + WalletModel *model; + +private slots: + void on_chck4_upd8_clicked(); + void on_dwngrd_opt_clicked(); + void on_CS_submit_clicked(); + void on_BR_submit_clicked(); + void on_AU_apply_clicked(); + void on_minCLIE_clicked(); +}; + +#endif // CLIENTCONTROLPAGE_H diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp new file mode 100644 index 0000000..76568fd --- /dev/null +++ b/src/qt/clientmodel.cpp @@ -0,0 +1,194 @@ +#include "clientmodel.h" + +#include "guiconstants.h" +#include "optionsmodel.h" +#include "addresstablemodel.h" +#include "transactiontablemodel.h" + +#include "chainparams.h" +#include "alert.h" +#include "main.h" +#include "ui_interface.h" + +#include +#include +#include + +static const int64_t nClientStartupTime = GetTime(); + +ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : + QObject(parent), optionsModel(optionsModel), + cachedNumBlocks(0), numBlocksAtStartup(-1), pollTimer(0) +{ + pollTimer = new QTimer(this); + pollTimer->setInterval(MODEL_UPDATE_DELAY); + pollTimer->start(); + connect(pollTimer, SIGNAL(timeout()), this, SLOT(updateTimer())); + + subscribeToCoreSignals(); +} + +ClientModel::~ClientModel() +{ + unsubscribeFromCoreSignals(); +} + +int ClientModel::getNumConnections() const +{ + return vNodes.size(); +} + +int ClientModel::getNumBlocks() const +{ + LOCK(cs_main); + return nBestHeight; +} + +int ClientModel::getNumBlocksAtStartup() +{ + if (numBlocksAtStartup == -1) numBlocksAtStartup = getNumBlocks(); + return numBlocksAtStartup; +} + +quint64 ClientModel::getTotalBytesRecv() const +{ + return CNode::GetTotalBytesRecv(); +} + +quint64 ClientModel::getTotalBytesSent() const +{ + return CNode::GetTotalBytesSent(); +} + +QDateTime ClientModel::getLastBlockDate() const +{ + LOCK(cs_main); + if (pindexBest) + return QDateTime::fromTime_t(pindexBest->GetBlockTime()); + else + return QDateTime::fromTime_t(Params().GenesisBlock().nTime); // Genesis block's time of current network +} + + +void ClientModel::updateTimer() +{ + // Get required lock upfront. This avoids the GUI from getting stuck on + // periodical polls if the core is holding the locks for a longer time - + // for example, during a wallet rescan. + TRY_LOCK(cs_main, lockMain); + if(!lockMain) + return; + // Some quantities (such as number of blocks) change so fast that we don't want to be notified for each change. + // Periodically check and update with a timer. + int newNumBlocks = getNumBlocks(); + + if(cachedNumBlocks != newNumBlocks) + { + cachedNumBlocks = newNumBlocks; + + emit numBlocksChanged(newNumBlocks); + } + + emit bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); +} + +void ClientModel::updateNumConnections(int numConnections) +{ + emit numConnectionsChanged(numConnections); +} + +void ClientModel::updateAlert(const QString &hash, int status) +{ + // Show error message notification for new alert + if(status == CT_NEW) + { + uint256 hash_256; + hash_256.SetHex(hash.toStdString()); + CAlert alert = CAlert::getAlertByHash(hash_256); + if(!alert.IsNull()) + { + emit message(tr("Network Alert"), QString::fromStdString(alert.strStatusBar), false, CClientUIInterface::ICON_ERROR); + } + } + + emit alertsChanged(getStatusBarWarnings()); +} + +bool ClientModel::isTestNet() const +{ + return TestNet(); +} + +bool ClientModel::inInitialBlockDownload() const +{ + return IsInitialBlockDownload(); +} + +bool ClientModel::isImporting() const +{ + return fImporting; +} + +QString ClientModel::getStatusBarWarnings() const +{ + return QString::fromStdString(GetWarnings("statusbar")); +} + +OptionsModel *ClientModel::getOptionsModel() +{ + return optionsModel; +} + +QString ClientModel::formatFullVersion() const +{ + return QString::fromStdString(FormatFullVersion()); +} + +QString ClientModel::formatBuildDate() const +{ + return QString::fromStdString(CLIENT_DATE); +} + +bool ClientModel::isReleaseVersion() const +{ + return CLIENT_VERSION_IS_RELEASE; +} + +QString ClientModel::clientName() const +{ + return QString::fromStdString(CLIENT_NAME); +} + +QString ClientModel::formatClientStartupTime() const +{ + return QDateTime::fromTime_t(nClientStartupTime).toString(); +} + +static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConnections) +{ + // Too noisy: qDebug() << "NotifyNumConnectionsChanged : " + QString::number(newNumConnections); + QMetaObject::invokeMethod(clientmodel, "updateNumConnections", Qt::QueuedConnection, + Q_ARG(int, newNumConnections)); +} + +static void NotifyAlertChanged(ClientModel *clientmodel, const uint256 &hash, ChangeType status) +{ + qDebug() << "NotifyAlertChanged : " + QString::fromStdString(hash.GetHex()) + " status=" + QString::number(status); + QMetaObject::invokeMethod(clientmodel, "updateAlert", Qt::QueuedConnection, + Q_ARG(QString, QString::fromStdString(hash.GetHex())), + Q_ARG(int, status)); +} + +void ClientModel::subscribeToCoreSignals() +{ + // Connect signals to client + uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1)); + uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2)); +} + +void ClientModel::unsubscribeFromCoreSignals() +{ + // Disconnect signals from client + uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1)); + uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2)); +} diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h new file mode 100644 index 0000000..1a92a7d --- /dev/null +++ b/src/qt/clientmodel.h @@ -0,0 +1,78 @@ +#ifndef CLIENTMODEL_H +#define CLIENTMODEL_H + +#include + +class OptionsModel; +class AddressTableModel; +class TransactionTableModel; +class CWallet; + +QT_BEGIN_NAMESPACE +class QDateTime; +class QTimer; +QT_END_NAMESPACE + +/** Model for Bitcoin network client. */ +class ClientModel : public QObject +{ + Q_OBJECT + +public: + explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0); + ~ClientModel(); + + OptionsModel *getOptionsModel(); + + int getNumConnections() const; + int getNumBlocks() const; + int getNumBlocksAtStartup(); + + quint64 getTotalBytesRecv() const; + quint64 getTotalBytesSent() const; + + QDateTime getLastBlockDate() const; + + //! Return true if client connected to testnet + bool isTestNet() const; + //! Return true if core is doing initial block download + bool inInitialBlockDownload() const; + //! Return true if core is importing blocks + bool isImporting() const; + //! Return warnings to be displayed in status bar + QString getStatusBarWarnings() const; + + QString formatFullVersion() const; + QString formatBuildDate() const; + bool isReleaseVersion() const; + QString clientName() const; + QString formatClientStartupTime() const; + +private: + OptionsModel *optionsModel; + + int cachedNumBlocks; + + int numBlocksAtStartup; + + QTimer *pollTimer; + + void subscribeToCoreSignals(); + void unsubscribeFromCoreSignals(); + +signals: + void numConnectionsChanged(int count); + void numBlocksChanged(int count); + void alertsChanged(const QString &warnings); + void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut); + + //! Asynchronous message notification + void message(const QString &title, const QString &message, bool modal, unsigned int style); + +public slots: + void updateTimer(); + void updateNumConnections(int numConnections); + void updateAlert(const QString &hash, int status); +}; + +#endif // CLIENTMODEL_H diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp new file mode 100644 index 0000000..68ce073 --- /dev/null +++ b/src/qt/coincontroldialog.cpp @@ -0,0 +1,717 @@ +#include "coincontroldialog.h" +#include "ui_coincontroldialog.h" + +#include "init.h" +#include "base58.h" +#include "bitcoinunits.h" +#include "walletmodel.h" +#include "addresstablemodel.h" +#include "optionsmodel.h" +#include "coincontrol.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +QList CoinControlDialog::payAmounts; +CCoinControl* CoinControlDialog::coinControl = new CCoinControl(); + +CoinControlDialog::CoinControlDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::CoinControlDialog), + model(0) +{ + ui->setupUi(this); + + // context menu actions + QAction *copyAddressAction = new QAction(tr("Copy address"), this); + QAction *copyLabelAction = new QAction(tr("Copy label"), this); + QAction *copyAmountAction = new QAction(tr("Copy amount"), this); + copyTransactionHashAction = new QAction(tr("Copy transaction ID"), this); // we need to enable/disable this + //lockAction = new QAction(tr("Lock unspent"), this); // we need to enable/disable this + //unlockAction = new QAction(tr("Unlock unspent"), this); // we need to enable/disable this + + // context menu + contextMenu = new QMenu(); + contextMenu->addAction(copyAddressAction); + contextMenu->addAction(copyLabelAction); + contextMenu->addAction(copyAmountAction); + contextMenu->addAction(copyTransactionHashAction); + //contextMenu->addSeparator(); + //contextMenu->addAction(lockAction); + //contextMenu->addAction(unlockAction); + + // context menu signals + connect(ui->treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu(QPoint))); + connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); + connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); + connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); + connect(copyTransactionHashAction, SIGNAL(triggered()), this, SLOT(copyTransactionHash())); + //connect(lockAction, SIGNAL(triggered()), this, SLOT(lockCoin())); + //connect(unlockAction, SIGNAL(triggered()), this, SLOT(unlockCoin())); + + // clipboard actions + QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); + QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this); + QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this); + QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this); + QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); + QAction *clipboardPriorityAction = new QAction(tr("Copy priority"), this); + QAction *clipboardLowOutputAction = new QAction(tr("Copy low output"), this); + QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); + + connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(clipboardQuantity())); + connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(clipboardAmount())); + connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(clipboardFee())); + connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(clipboardAfterFee())); + connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(clipboardBytes())); + connect(clipboardPriorityAction, SIGNAL(triggered()), this, SLOT(clipboardPriority())); + connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(clipboardLowOutput())); + connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(clipboardChange())); + + ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); + ui->labelCoinControlAmount->addAction(clipboardAmountAction); + ui->labelCoinControlFee->addAction(clipboardFeeAction); + ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction); + ui->labelCoinControlBytes->addAction(clipboardBytesAction); + ui->labelCoinControlPriority->addAction(clipboardPriorityAction); + ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction); + ui->labelCoinControlChange->addAction(clipboardChangeAction); + + // toggle tree/list mode + connect(ui->radioTreeMode, SIGNAL(toggled(bool)), this, SLOT(radioTreeMode(bool))); + connect(ui->radioListMode, SIGNAL(toggled(bool)), this, SLOT(radioListMode(bool))); + + // click on checkbox + connect(ui->treeWidget, SIGNAL(itemChanged( QTreeWidgetItem*, int)), this, SLOT(viewItemChanged( QTreeWidgetItem*, int))); + + // click on header + ui->treeWidget->header()->setClickable(true); + connect(ui->treeWidget->header(), SIGNAL(sectionClicked(int)), this, SLOT(headerSectionClicked(int))); + + // ok button + connect(ui->buttonBox, SIGNAL(clicked( QAbstractButton*)), this, SLOT(buttonBoxClicked(QAbstractButton*))); + + // (un)select all + connect(ui->pushButtonSelectAll, SIGNAL(clicked()), this, SLOT(buttonSelectAllClicked())); + + ui->treeWidget->setColumnWidth(COLUMN_CHECKBOX, 84); + ui->treeWidget->setColumnWidth(COLUMN_AMOUNT, 100); + ui->treeWidget->setColumnWidth(COLUMN_LABEL, 170); + ui->treeWidget->setColumnWidth(COLUMN_ADDRESS, 290); + ui->treeWidget->setColumnWidth(COLUMN_DATE, 110); + ui->treeWidget->setColumnWidth(COLUMN_CONFIRMATIONS, 100); + ui->treeWidget->setColumnWidth(COLUMN_PRIORITY, 100); + ui->treeWidget->setColumnHidden(COLUMN_TXHASH, true); // store transacton hash in this column, but dont show it + ui->treeWidget->setColumnHidden(COLUMN_VOUT_INDEX, true); // store vout index in this column, but dont show it + ui->treeWidget->setColumnHidden(COLUMN_AMOUNT_INT64, true); // store amount int64_t in this column, but dont show it + ui->treeWidget->setColumnHidden(COLUMN_PRIORITY_INT64, true); // store priority int64_t in this column, but dont show it + + // default view is sorted by amount desc + sortView(COLUMN_AMOUNT_INT64, Qt::DescendingOrder); +} + +CoinControlDialog::~CoinControlDialog() +{ + delete ui; +} + +void CoinControlDialog::setModel(WalletModel *model) +{ + this->model = model; + + if(model && model->getOptionsModel() && model->getAddressTableModel()) + { + updateView(); + //updateLabelLocked(); + CoinControlDialog::updateLabels(model, this); + } +} + +// helper function str_pad +QString CoinControlDialog::strPad(QString s, int nPadLength, QString sPadding) +{ + while (s.length() < nPadLength) + s = sPadding + s; + + return s; +} + +// ok button +void CoinControlDialog::buttonBoxClicked(QAbstractButton* button) +{ + if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) + done(QDialog::Accepted); // closes the dialog +} + +// (un)select all +void CoinControlDialog::buttonSelectAllClicked() +{ + Qt::CheckState state = Qt::Checked; + for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) + { + if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != Qt::Unchecked) + { + state = Qt::Unchecked; + break; + } + } + ui->treeWidget->setEnabled(false); + for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) + if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != state) + ui->treeWidget->topLevelItem(i)->setCheckState(COLUMN_CHECKBOX, state); + ui->treeWidget->setEnabled(true); + CoinControlDialog::updateLabels(model, this); +} + +// context menu +void CoinControlDialog::showMenu(const QPoint &point) +{ + QTreeWidgetItem *item = ui->treeWidget->itemAt(point); + if(item) + { + contextMenuItem = item; + + // disable some items (like Copy Transaction ID, lock, unlock) for tree roots in context menu + if (item->text(COLUMN_TXHASH).length() == 64) // transaction hash is 64 characters (this means its a child node, so its not a parent node in tree mode) + { + copyTransactionHashAction->setEnabled(true); + //if (model->isLockedCoin(uint256(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt())) + //{ + // lockAction->setEnabled(false); + // unlockAction->setEnabled(true); + //} + //else + //{ + // lockAction->setEnabled(true); + // unlockAction->setEnabled(false); + //} + } + else // this means click on parent node in tree mode -> disable all + { + copyTransactionHashAction->setEnabled(false); + //lockAction->setEnabled(false); + //unlockAction->setEnabled(false); + } + + // show context menu + contextMenu->exec(QCursor::pos()); + } +} + +// context menu action: copy amount +void CoinControlDialog::copyAmount() +{ + QApplication::clipboard()->setText(contextMenuItem->text(COLUMN_AMOUNT)); +} + +// context menu action: copy label +void CoinControlDialog::copyLabel() +{ + if (ui->radioTreeMode->isChecked() && contextMenuItem->text(COLUMN_LABEL).length() == 0 && contextMenuItem->parent()) + QApplication::clipboard()->setText(contextMenuItem->parent()->text(COLUMN_LABEL)); + else + QApplication::clipboard()->setText(contextMenuItem->text(COLUMN_LABEL)); +} + +// context menu action: copy address +void CoinControlDialog::copyAddress() +{ + if (ui->radioTreeMode->isChecked() && contextMenuItem->text(COLUMN_ADDRESS).length() == 0 && contextMenuItem->parent()) + QApplication::clipboard()->setText(contextMenuItem->parent()->text(COLUMN_ADDRESS)); + else + QApplication::clipboard()->setText(contextMenuItem->text(COLUMN_ADDRESS)); +} + +// context menu action: copy transaction id +void CoinControlDialog::copyTransactionHash() +{ + QApplication::clipboard()->setText(contextMenuItem->text(COLUMN_TXHASH)); +} + +// context menu action: lock coin +/*void CoinControlDialog::lockCoin() +{ + if (contextMenuItem->checkState(COLUMN_CHECKBOX) == Qt::Checked) + contextMenuItem->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); + + COutPoint outpt(uint256(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); + model->lockCoin(outpt); + contextMenuItem->setDisabled(true); + contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon(":/icons/lock_closed")); + updateLabelLocked(); +}*/ + +// context menu action: unlock coin +/*void CoinControlDialog::unlockCoin() +{ + COutPoint outpt(uint256(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); + model->unlockCoin(outpt); + contextMenuItem->setDisabled(false); + contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon()); + updateLabelLocked(); +}*/ + +// copy label "Quantity" to clipboard +void CoinControlDialog::clipboardQuantity() +{ + QApplication::clipboard()->setText(ui->labelCoinControlQuantity->text()); +} + +// copy label "Amount" to clipboard +void CoinControlDialog::clipboardAmount() +{ + QApplication::clipboard()->setText(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" "))); +} + +// copy label "Fee" to clipboard +void CoinControlDialog::clipboardFee() +{ + QApplication::clipboard()->setText(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" "))); +} + +// copy label "After fee" to clipboard +void CoinControlDialog::clipboardAfterFee() +{ + QApplication::clipboard()->setText(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" "))); +} + +// copy label "Bytes" to clipboard +void CoinControlDialog::clipboardBytes() +{ + QApplication::clipboard()->setText(ui->labelCoinControlBytes->text()); +} + +// copy label "Priority" to clipboard +void CoinControlDialog::clipboardPriority() +{ + QApplication::clipboard()->setText(ui->labelCoinControlPriority->text()); +} + +// copy label "Low output" to clipboard +void CoinControlDialog::clipboardLowOutput() +{ + QApplication::clipboard()->setText(ui->labelCoinControlLowOutput->text()); +} + +// copy label "Change" to clipboard +void CoinControlDialog::clipboardChange() +{ + QApplication::clipboard()->setText(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" "))); +} + +// treeview: sort +void CoinControlDialog::sortView(int column, Qt::SortOrder order) +{ + sortColumn = column; + sortOrder = order; + ui->treeWidget->sortItems(column, order); + ui->treeWidget->header()->setSortIndicator((sortColumn == COLUMN_AMOUNT_INT64 ? COLUMN_AMOUNT : (sortColumn == COLUMN_PRIORITY_INT64 ? COLUMN_PRIORITY : sortColumn)), sortOrder); +} + +// treeview: clicked on header +void CoinControlDialog::headerSectionClicked(int logicalIndex) +{ + if (logicalIndex == COLUMN_CHECKBOX) // click on most left column -> do nothing + { + ui->treeWidget->header()->setSortIndicator((sortColumn == COLUMN_AMOUNT_INT64 ? COLUMN_AMOUNT : (sortColumn == COLUMN_PRIORITY_INT64 ? COLUMN_PRIORITY : sortColumn)), sortOrder); + } + else + { + if (logicalIndex == COLUMN_AMOUNT) // sort by amount + logicalIndex = COLUMN_AMOUNT_INT64; + + if (logicalIndex == COLUMN_PRIORITY) // sort by priority + logicalIndex = COLUMN_PRIORITY_INT64; + + if (sortColumn == logicalIndex) + sortOrder = ((sortOrder == Qt::AscendingOrder) ? Qt::DescendingOrder : Qt::AscendingOrder); + else + { + sortColumn = logicalIndex; + sortOrder = ((sortColumn == COLUMN_AMOUNT_INT64 || sortColumn == COLUMN_PRIORITY_INT64 || sortColumn == COLUMN_DATE || sortColumn == COLUMN_CONFIRMATIONS) ? Qt::DescendingOrder : Qt::AscendingOrder); // if amount,date,conf,priority then default => desc, else default => asc + } + + sortView(sortColumn, sortOrder); + } +} + +// toggle tree mode +void CoinControlDialog::radioTreeMode(bool checked) +{ + if (checked && model) + updateView(); +} + +// toggle list mode +void CoinControlDialog::radioListMode(bool checked) +{ + if (checked && model) + updateView(); +} + +// checkbox clicked by user +void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column) +{ + if (column == COLUMN_CHECKBOX && item->text(COLUMN_TXHASH).length() == 64) // transaction hash is 64 characters (this means its a child node, so its not a parent node in tree mode) + { + COutPoint outpt(uint256(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt()); + + if (item->checkState(COLUMN_CHECKBOX) == Qt::Unchecked) + coinControl->UnSelect(outpt); + else if (item->isDisabled()) // locked (this happens if "check all" through parent node) + item->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); + else + coinControl->Select(outpt); + + // selection changed -> update labels + if (ui->treeWidget->isEnabled()) // do not update on every click for (un)select all + CoinControlDialog::updateLabels(model, this); + } +} + +// helper function, return human readable label for priority number +QString CoinControlDialog::getPriorityLabel(double dPriority) +{ + if (dPriority > 576000ULL) // at least medium, this number is from AllowFree(), the other thresholds are kinda random + { + if (dPriority > 5760000000ULL) return tr("highest"); + else if (dPriority > 576000000ULL) return tr("high"); + else if (dPriority > 57600000ULL) return tr("medium-high"); + else return tr("medium"); + } + else + { + if (dPriority > 5760ULL) return tr("low-medium"); + else if (dPriority > 58ULL) return tr("low"); + else return tr("lowest"); + } +} + +// shows count of locked unspent outputs +/*void CoinControlDialog::updateLabelLocked() +{ + vector vOutpts; + model->listLockedCoins(vOutpts); + if (vOutpts.size() > 0) + { + ui->labelLocked->setText(tr("(%1 locked)").arg(vOutpts.size())); + ui->labelLocked->setVisible(true); + } + else ui->labelLocked->setVisible(false); +}*/ + +void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) +{ + if (!model) return; + + // nPayAmount + qint64 nPayAmount = 0; + bool fLowOutput = false; + bool fDust = false; + CTransaction txDummy; + foreach(const qint64 &amount, CoinControlDialog::payAmounts) + { + nPayAmount += amount; + + if (amount > 0) + { + if (amount < CENT) + fLowOutput = true; + + CTxOut txout(amount, (CScript)vector(24, 0)); + txDummy.vout.push_back(txout); + } + } + + QString sPriorityLabel = ""; + int64_t nAmount = 0; + int64_t nPayFee = 0; + int64_t nAfterFee = 0; + int64_t nChange = 0; + unsigned int nBytes = 0; + unsigned int nBytesInputs = 0; + double dPriority = 0; + double dPriorityInputs = 0; + unsigned int nQuantity = 0; + + vector vCoinControl; + vector vOutputs; + coinControl->ListSelected(vCoinControl); + model->getOutputs(vCoinControl, vOutputs); + + BOOST_FOREACH(const COutput& out, vOutputs) + { + // Quantity + nQuantity++; + + // Amount + nAmount += out.tx->vout[out.i].nValue; + + // Priority + dPriorityInputs += (double)out.tx->vout[out.i].nValue * (out.nDepth+1); + + // Bytes + CTxDestination address; + if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) + { + CPubKey pubkey; + CKeyID *keyid = boost::get< CKeyID >(&address); + if (keyid && model->getPubKey(*keyid, pubkey)) + nBytesInputs += (pubkey.IsCompressed() ? 148 : 180); + else + nBytesInputs += 148; // in all error cases, simply assume 148 here + } + else nBytesInputs += 148; + } + + // calculation + if (nQuantity > 0) + { + // Bytes + nBytes = nBytesInputs + ((CoinControlDialog::payAmounts.size() > 0 ? CoinControlDialog::payAmounts.size() + 1 : 2) * 34) + 10; // always assume +1 output for change here + + // Priority + dPriority = dPriorityInputs / nBytes; + sPriorityLabel = CoinControlDialog::getPriorityLabel(dPriority); + + // Fee + int64_t nFee = nTransactionFee * (1 + (int64_t)nBytes / 1000); + + // Min Fee + int64_t nMinFee = GetMinFee(txDummy, 1, GMF_SEND, nBytes); + + nPayFee = max(nFee, nMinFee); + + if (nPayAmount > 0) + { + nChange = nAmount - nPayFee - nPayAmount; + + if (nChange == 0) + nBytes -= 34; + } + + // after fee + nAfterFee = nAmount - nPayFee; + if (nAfterFee < 0) + nAfterFee = 0; + } + + // actually update labels + int nDisplayUnit = BitcoinUnits::BTC; + if (model && model->getOptionsModel()) + nDisplayUnit = model->getOptionsModel()->getDisplayUnit(); + + QLabel *l1 = dialog->findChild("labelCoinControlQuantity"); + QLabel *l2 = dialog->findChild("labelCoinControlAmount"); + QLabel *l3 = dialog->findChild("labelCoinControlFee"); + QLabel *l4 = dialog->findChild("labelCoinControlAfterFee"); + QLabel *l5 = dialog->findChild("labelCoinControlBytes"); + QLabel *l6 = dialog->findChild("labelCoinControlPriority"); + QLabel *l7 = dialog->findChild("labelCoinControlLowOutput"); + QLabel *l8 = dialog->findChild("labelCoinControlChange"); + + // enable/disable "low output" and "change" + dialog->findChild("labelCoinControlLowOutputText")->setEnabled(nPayAmount > 0); + dialog->findChild("labelCoinControlLowOutput") ->setEnabled(nPayAmount > 0); + dialog->findChild("labelCoinControlChangeText") ->setEnabled(nPayAmount > 0); + dialog->findChild("labelCoinControlChange") ->setEnabled(nPayAmount > 0); + + // stats + l1->setText(QString::number(nQuantity)); // Quantity + l2->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAmount)); // Amount + l3->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nPayFee)); // Fee + l4->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee)); // After Fee + l5->setText(((nBytes > 0) ? "~" : "") + QString::number(nBytes)); // Bytes + l6->setText(sPriorityLabel); // Priority + l7->setText((fLowOutput ? (fDust ? tr("DUST") : tr("yes")) : tr("no"))); // Low Output / Dust + l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); // Change + + // turn labels "red" + l5->setStyleSheet((nBytes >= 10000) ? "color:red;" : ""); // Bytes >= 10000 + l6->setStyleSheet((dPriority <= 576000) ? "color:red;" : ""); // Priority < "medium" + l7->setStyleSheet((fLowOutput) ? "color:red;" : ""); // Low Output = "yes" + l8->setStyleSheet((nChange > 0 && nChange < CENT) ? "color:red;" : ""); // Change < 0.01BTC + + // tool tips + l5->setToolTip(tr("This label turns red, if the transaction size is bigger than 10000 bytes.\n\n This means a fee of at least %1 per kb is required.\n\n Can vary +/- 1 Byte per input.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT))); + l6->setToolTip(tr("Transactions with higher priority get more likely into a block.\n\nThis label turns red, if the priority is smaller than \"medium\".\n\n This means a fee of at least %1 per kb is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT))); + l7->setToolTip(tr("This label turns red, if any recipient receives an amount smaller than %1.\n\n This means a fee of at least %2 is required. \n\n Amounts below 0.546 times the minimum relay fee are shown as DUST.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT))); + l8->setToolTip(tr("This label turns red, if the change is smaller than %1.\n\n This means a fee of at least %2 is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT))); + dialog->findChild("labelCoinControlBytesText") ->setToolTip(l5->toolTip()); + dialog->findChild("labelCoinControlPriorityText") ->setToolTip(l6->toolTip()); + dialog->findChild("labelCoinControlLowOutputText")->setToolTip(l7->toolTip()); + dialog->findChild("labelCoinControlChangeText") ->setToolTip(l8->toolTip()); + + // Insufficient funds + QLabel *label = dialog->findChild("labelCoinControlInsuffFunds"); + if (label) + label->setVisible(nChange < 0); +} + +void CoinControlDialog::updateView() +{ + bool treeMode = ui->radioTreeMode->isChecked(); + + ui->treeWidget->clear(); + ui->treeWidget->setEnabled(false); // performance, otherwise updateLabels would be called for every checked checkbox + QFlags flgCheckbox=Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; + QFlags flgTristate=Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate; + + int nDisplayUnit = BitcoinUnits::BTC; + if (model && model->getOptionsModel()) + nDisplayUnit = model->getOptionsModel()->getDisplayUnit(); + + map > mapCoins; + model->listCoins(mapCoins); + + BOOST_FOREACH(PAIRTYPE(QString, vector) coins, mapCoins) + { + QTreeWidgetItem *itemWalletAddress = new QTreeWidgetItem(); + QString sWalletAddress = coins.first; + QString sWalletLabel = ""; + if (model->getAddressTableModel()) + sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress); + if (sWalletLabel.length() == 0) + sWalletLabel = tr("(no label)"); + + if (treeMode) + { + // wallet address + ui->treeWidget->addTopLevelItem(itemWalletAddress); + + itemWalletAddress->setFlags(flgTristate); + itemWalletAddress->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked); + + for (int i = 0; i < ui->treeWidget->columnCount(); i++) + itemWalletAddress->setBackground(i, QColor(248, 247, 246)); + + // label + itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel); + + // address + itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress); + } + + int64_t nSum = 0; + double dPrioritySum = 0; + int nChildren = 0; + int nInputSum = 0; + BOOST_FOREACH(const COutput& out, coins.second) + { + int nInputSize = 148; // 180 if uncompressed public key + nSum += out.tx->vout[out.i].nValue; + nChildren++; + + QTreeWidgetItem *itemOutput; + if (treeMode) itemOutput = new QTreeWidgetItem(itemWalletAddress); + else itemOutput = new QTreeWidgetItem(ui->treeWidget); + itemOutput->setFlags(flgCheckbox); + itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked); + + // address + CTxDestination outputAddress; + QString sAddress = ""; + if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, outputAddress)) + { + sAddress = CBitcoinAddress(outputAddress).ToString().c_str(); + + // if listMode or change => show bitcoin address. In tree mode, address is not shown again for direct wallet address outputs + if (!treeMode || (!(sAddress == sWalletAddress))) + itemOutput->setText(COLUMN_ADDRESS, sAddress); + + CPubKey pubkey; + CKeyID *keyid = boost::get< CKeyID >(&outputAddress); + if (keyid && model->getPubKey(*keyid, pubkey) && !pubkey.IsCompressed()) + nInputSize = 180; + } + + // label + if (!(sAddress == sWalletAddress)) // change + { + // tooltip from where the change comes from + itemOutput->setToolTip(COLUMN_LABEL, tr("change from %1 (%2)").arg(sWalletLabel).arg(sWalletAddress)); + itemOutput->setText(COLUMN_LABEL, tr("(change)")); + } + else if (!treeMode) + { + QString sLabel = ""; + if (model->getAddressTableModel()) + sLabel = model->getAddressTableModel()->labelForAddress(sAddress); + if (sLabel.length() == 0) + sLabel = tr("(no label)"); + itemOutput->setText(COLUMN_LABEL, sLabel); + } + + // amount + itemOutput->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, out.tx->vout[out.i].nValue)); + itemOutput->setText(COLUMN_AMOUNT_INT64, strPad(QString::number(out.tx->vout[out.i].nValue), 15, " ")); // padding so that sorting works correctly + + // date + itemOutput->setText(COLUMN_DATE, QDateTime::fromTime_t(out.tx->GetTxTime()).toUTC().toString("yy-MM-dd hh:mm")); + + // confirmations + itemOutput->setText(COLUMN_CONFIRMATIONS, strPad(QString::number(out.nDepth), 8, " ")); + + // priority + double dPriority = ((double)out.tx->vout[out.i].nValue / (nInputSize + 78)) * (out.nDepth+1); // 78 = 2 * 34 + 10 + itemOutput->setText(COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel(dPriority)); + itemOutput->setText(COLUMN_PRIORITY_INT64, strPad(QString::number((int64_t)dPriority), 20, " ")); + dPrioritySum += (double)out.tx->vout[out.i].nValue * (out.nDepth+1); + nInputSum += nInputSize; + + // transaction hash + uint256 txhash = out.tx->GetHash(); + itemOutput->setText(COLUMN_TXHASH, txhash.GetHex().c_str()); + + // vout index + itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i)); + + // disable locked coins + /*if (model->isLockedCoin(txhash, out.i)) + { + COutPoint outpt(txhash, out.i); + coinControl->UnSelect(outpt); // just to be sure + itemOutput->setDisabled(true); + itemOutput->setIcon(COLUMN_CHECKBOX, QIcon(":/icons/lock_closed")); + }*/ + + // set checkbox + if (coinControl->IsSelected(txhash, out.i)) + itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Checked); + } + + // amount + if (treeMode) + { + dPrioritySum = dPrioritySum / (nInputSum + 78); + itemWalletAddress->setText(COLUMN_CHECKBOX, "(" + QString::number(nChildren) + ")"); + itemWalletAddress->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, nSum)); + itemWalletAddress->setText(COLUMN_AMOUNT_INT64, strPad(QString::number(nSum), 15, " ")); + itemWalletAddress->setText(COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel(dPrioritySum)); + itemWalletAddress->setText(COLUMN_PRIORITY_INT64, strPad(QString::number((int64_t)dPrioritySum), 20, " ")); + } + } + + // expand all partially selected + if (treeMode) + { + for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) + if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) == Qt::PartiallyChecked) + ui->treeWidget->topLevelItem(i)->setExpanded(true); + } + + // sort view + sortView(sortColumn, sortOrder); + ui->treeWidget->setEnabled(true); +} diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h new file mode 100644 index 0000000..4d2cb82 --- /dev/null +++ b/src/qt/coincontroldialog.h @@ -0,0 +1,92 @@ +#ifndef COINCONTROLDIALOG_H +#define COINCONTROLDIALOG_H + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Ui { + class CoinControlDialog; +} +class WalletModel; +class CCoinControl; + +class CoinControlDialog : public QDialog +{ + Q_OBJECT + +public: + explicit CoinControlDialog(QWidget *parent = 0); + ~CoinControlDialog(); + + void setModel(WalletModel *model); + + // static because also called from sendcoinsdialog + static void updateLabels(WalletModel*, QDialog*); + static QString getPriorityLabel(double); + + static QList payAmounts; + static CCoinControl *coinControl; + +private: + Ui::CoinControlDialog *ui; + WalletModel *model; + int sortColumn; + Qt::SortOrder sortOrder; + + QMenu *contextMenu; + QTreeWidgetItem *contextMenuItem; + QAction *copyTransactionHashAction; + //QAction *lockAction; + //QAction *unlockAction; + + QString strPad(QString, int, QString); + void sortView(int, Qt::SortOrder); + void updateView(); + + enum + { + COLUMN_CHECKBOX, + COLUMN_AMOUNT, + COLUMN_LABEL, + COLUMN_ADDRESS, + COLUMN_DATE, + COLUMN_CONFIRMATIONS, + COLUMN_PRIORITY, + COLUMN_TXHASH, + COLUMN_VOUT_INDEX, + COLUMN_AMOUNT_INT64, + COLUMN_PRIORITY_INT64 + }; + +private slots: + void showMenu(const QPoint &); + void copyAmount(); + void copyLabel(); + void copyAddress(); + void copyTransactionHash(); + //void lockCoin(); + //void unlockCoin(); + void clipboardQuantity(); + void clipboardAmount(); + void clipboardFee(); + void clipboardAfterFee(); + void clipboardBytes(); + void clipboardPriority(); + void clipboardLowOutput(); + void clipboardChange(); + void radioTreeMode(bool); + void radioListMode(bool); + void viewItemChanged(QTreeWidgetItem*, int); + void headerSectionClicked(int); + void buttonBoxClicked(QAbstractButton*); + void buttonSelectAllClicked(); + //void updateLabelLocked(); +}; + +#endif // COINCONTROLDIALOG_H diff --git a/src/qt/coincontroltreewidget.cpp b/src/qt/coincontroltreewidget.cpp new file mode 100644 index 0000000..0759f67 --- /dev/null +++ b/src/qt/coincontroltreewidget.cpp @@ -0,0 +1,28 @@ +#include "coincontroltreewidget.h" +#include "coincontroldialog.h" + +CoinControlTreeWidget::CoinControlTreeWidget(QWidget *parent) : + QTreeWidget(parent) +{ + +} + +void CoinControlTreeWidget::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Space) // press spacebar -> select checkbox + { + event->ignore(); + int COLUMN_CHECKBOX = 0; + this->currentItem()->setCheckState(COLUMN_CHECKBOX, ((this->currentItem()->checkState(COLUMN_CHECKBOX) == Qt::Checked) ? Qt::Unchecked : Qt::Checked)); + } + else if (event->key() == Qt::Key_Escape) // press esc -> close dialog + { + event->ignore(); + CoinControlDialog *coinControlDialog = (CoinControlDialog*)this->parentWidget(); + coinControlDialog->done(QDialog::Accepted); + } + else + { + this->QTreeWidget::keyPressEvent(event); + } +} \ No newline at end of file diff --git a/src/qt/coincontroltreewidget.h b/src/qt/coincontroltreewidget.h new file mode 100644 index 0000000..9f36d9e --- /dev/null +++ b/src/qt/coincontroltreewidget.h @@ -0,0 +1,17 @@ +#ifndef COINCONTROLTREEWIDGET_H +#define COINCONTROLTREEWIDGET_H + +#include +#include + +class CoinControlTreeWidget : public QTreeWidget { +Q_OBJECT + +public: + explicit CoinControlTreeWidget(QWidget *parent = 0); + +protected: + virtual void keyPressEvent(QKeyEvent *event); +}; + +#endif // COINCONTROLTREEWIDGET_H \ No newline at end of file diff --git a/src/qt/csvmodelwriter.cpp b/src/qt/csvmodelwriter.cpp new file mode 100644 index 0000000..8170f82 --- /dev/null +++ b/src/qt/csvmodelwriter.cpp @@ -0,0 +1,88 @@ +#include "csvmodelwriter.h" + +#include +#include +#include + +CSVModelWriter::CSVModelWriter(const QString &filename, QObject *parent) : + QObject(parent), + filename(filename), model(0) +{ +} + +void CSVModelWriter::setModel(const QAbstractItemModel *model) +{ + this->model = model; +} + +void CSVModelWriter::addColumn(const QString &title, int column, int role) +{ + Column col; + col.title = title; + col.column = column; + col.role = role; + + columns.append(col); +} + +static void writeValue(QTextStream &f, const QString &value) +{ + QString escaped = value; + escaped.replace('"', "\"\""); + f << "\"" << escaped << "\""; +} + +static void writeSep(QTextStream &f) +{ + f << ","; +} + +static void writeNewline(QTextStream &f) +{ + f << "\n"; +} + +bool CSVModelWriter::write() +{ + QFile file(filename); + if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) + return false; + QTextStream out(&file); + + int numRows = 0; + if(model) + { + numRows = model->rowCount(); + } + + // Header row + for(int i=0; iindex(j, columns[i].column).data(columns[i].role); + writeValue(out, data.toString()); + } + writeNewline(out); + } + + file.close(); + + return file.error() == QFile::NoError; +} + diff --git a/src/qt/csvmodelwriter.h b/src/qt/csvmodelwriter.h new file mode 100644 index 0000000..95a8931 --- /dev/null +++ b/src/qt/csvmodelwriter.h @@ -0,0 +1,42 @@ +#ifndef CSVMODELWRITER_H +#define CSVMODELWRITER_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QAbstractItemModel; +QT_END_NAMESPACE + +/** Export a Qt table model to a CSV file. This is useful for analyzing or post-processing the data in + a spreadsheet. + */ +class CSVModelWriter : public QObject +{ + Q_OBJECT + +public: + explicit CSVModelWriter(const QString &filename, QObject *parent = 0); + + void setModel(const QAbstractItemModel *model); + void addColumn(const QString &title, int column, int role=Qt::EditRole); + + /** Perform export of the model to CSV. + @returns true on success, false otherwise + */ + bool write(); + +private: + QString filename; + const QAbstractItemModel *model; + + struct Column + { + QString title; + int column; + int role; + }; + QList columns; +}; + +#endif // CSVMODELWRITER_H diff --git a/src/qt/darksendconfig.cpp b/src/qt/darksendconfig.cpp new file mode 100644 index 0000000..edffc7f --- /dev/null +++ b/src/qt/darksendconfig.cpp @@ -0,0 +1,92 @@ +#include "darksendconfig.h" +#include "ui_darksendconfig.h" + +#include "bitcoinunits.h" +#include "guiconstants.h" +#include "optionsmodel.h" +#include "walletmodel.h" +#include "init.h" + +#include +#include +#include +#include + +luxsendConfig::luxsendConfig(QWidget *parent) : + QDialog(parent), + ui(new Ui::luxsendConfig), + model(0) +{ + ui->setupUi(this); + + connect(ui->buttonBasic, SIGNAL(clicked()), this, SLOT(clickBasic())); + connect(ui->buttonHigh, SIGNAL(clicked()), this, SLOT(clickHigh())); + connect(ui->buttonMax, SIGNAL(clicked()), this, SLOT(clickMax())); +} + +luxsendConfig::~luxsendConfig() +{ + delete ui; +} + +void luxsendConfig::setModel(WalletModel *model) +{ + this->model = model; +} + +void luxsendConfig::clickBasic() +{ + configure(true, 1000, 2); + + QString strAmount(BitcoinUnits::formatWithUnit( + model->getOptionsModel()->getDisplayUnit(), 1000 * COIN)); + QMessageBox::information(this, tr("darksend Configuration"), + tr( + "darksend was successfully set to basic (%1 and 2 rounds). You can change this at any time by opening SONO's configuration screen." + ).arg(strAmount) + ); + + close(); +} + +void luxsendConfig::clickHigh() +{ + configure(true, 1000, 8); + + QString strAmount(BitcoinUnits::formatWithUnit( + model->getOptionsModel()->getDisplayUnit(), 1000 * COIN)); + QMessageBox::information(this, tr("darksend Configuration"), + tr( + "darksend was successfully set to high (%1 and 8 rounds). You can change this at any time by opening SONO's configuration screen." + ).arg(strAmount) + ); + + close(); +} + +void luxsendConfig::clickMax() +{ + configure(true, 1000, 16); + + QString strAmount(BitcoinUnits::formatWithUnit( + model->getOptionsModel()->getDisplayUnit(), 1000 * COIN)); + QMessageBox::information(this, tr("darksend Configuration"), + tr( + "darksend was successfully set to maximum (%1 and 16 rounds). You can change this at any time by opening Bitcoin's configuration screen." + ).arg(strAmount) + ); + + close(); +} + +void luxsendConfig::configure(bool enabled, int coins, int rounds) { + + QSettings settings; + + settings.setValue("nDarksendRounds", rounds); + settings.setValue("nAnonymizeSONOAmount", coins); + + nDarksendRounds = rounds; + nAnonymizeSONOAmount = coins; +} + diff --git a/src/qt/darksendconfig.h b/src/qt/darksendconfig.h new file mode 100644 index 0000000..6a08327 --- /dev/null +++ b/src/qt/darksendconfig.h @@ -0,0 +1,38 @@ +#ifndef DARKSENDCONFIG_H +#define DARKSENDCONFIG_H + +#include + +namespace Ui { + class luxsendConfig; +} +class WalletModel; + +/** Multifunctional dialog to ask for passphrases. Used for encryption, unlocking, and changing the passphrase. + */ +class luxsendConfig : public QDialog +{ + Q_OBJECT + +public: + + luxsendConfig(QWidget *parent = 0); + ~luxsendConfig(); + + void setModel(WalletModel *model); + + +private: + Ui::luxsendConfig *ui; + WalletModel *model; + void configure(bool enabled, int coins, int rounds); + +private slots: + + void clickBasic(); + void clickHigh(); + void clickMax(); +}; + +#endif // DARKSENDCONFIG_H + diff --git a/src/qt/editaddressdialog.cpp b/src/qt/editaddressdialog.cpp new file mode 100644 index 0000000..56a0ac2 --- /dev/null +++ b/src/qt/editaddressdialog.cpp @@ -0,0 +1,150 @@ +#include "editaddressdialog.h" +#include "ui_editaddressdialog.h" + +#include "addresstablemodel.h" +#include "guiutil.h" + +#include +#include + +EditAddressDialog::EditAddressDialog(Mode mode, QWidget *parent) : + QDialog(parent), + ui(new Ui::EditAddressDialog), mapper(0), mode(mode), model(0) +{ + ui->setupUi(this); + + GUIUtil::setupAddressWidget(ui->addressEdit, this); + + switch(mode) + { + case NewReceivingAddress: + setWindowTitle(tr("New receiving address")); + ui->addressEdit->setEnabled(false); + ui->addressEdit->setVisible(false); + ui->stealthCB->setEnabled(true); + ui->stealthCB->setVisible(true); + break; + case NewSendingAddress: + setWindowTitle(tr("New sending address")); + ui->stealthCB->setVisible(false); + break; + case EditReceivingAddress: + setWindowTitle(tr("Edit receiving address")); + ui->addressEdit->setEnabled(false); + ui->addressEdit->setVisible(true); + ui->stealthCB->setEnabled(false); + ui->stealthCB->setVisible(true); + break; + case EditSendingAddress: + setWindowTitle(tr("Edit sending address")); + ui->stealthCB->setVisible(false); + break; + } + + mapper = new QDataWidgetMapper(this); + mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); +} + +EditAddressDialog::~EditAddressDialog() +{ + delete ui; +} + +void EditAddressDialog::setModel(AddressTableModel *model) +{ + this->model = model; + if(!model) + return; + + mapper->setModel(model); + mapper->addMapping(ui->labelEdit, AddressTableModel::Label); + mapper->addMapping(ui->addressEdit, AddressTableModel::Address); + mapper->addMapping(ui->stealthCB, AddressTableModel::Type); +} + +void EditAddressDialog::loadRow(int row) +{ + mapper->setCurrentIndex(row); +} + +bool EditAddressDialog::saveCurrentRow() +{ + if(!model) + return false; + + switch(mode) + { + case NewReceivingAddress: + case NewSendingAddress: + { + int typeInd = ui->stealthCB->isChecked() ? AddressTableModel::AT_Stealth : AddressTableModel::AT_Normal; + address = model->addRow( + mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive, + ui->labelEdit->text(), + ui->addressEdit->text(), + typeInd); + } + break; + case EditReceivingAddress: + case EditSendingAddress: + if(mapper->submit()) + { + address = ui->addressEdit->text(); + } + break; + } + return !address.isEmpty(); +} + +void EditAddressDialog::accept() +{ + if(!model) + return; + + if(!saveCurrentRow()) + { + switch(model->getEditStatus()) + { + case AddressTableModel::OK: + // Failed with unknown reason. Just reject. + break; + case AddressTableModel::NO_CHANGES: + // No changes were made during edit operation. Just reject. + break; + case AddressTableModel::INVALID_ADDRESS: + QMessageBox::warning(this, windowTitle(), + tr("The entered address \"%1\" is not a valid SONO address.").arg(ui->addressEdit->text()), + QMessageBox::Ok, QMessageBox::Ok); + break; + case AddressTableModel::DUPLICATE_ADDRESS: + QMessageBox::warning(this, windowTitle(), + tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()), + QMessageBox::Ok, QMessageBox::Ok); + break; + case AddressTableModel::WALLET_UNLOCK_FAILURE: + QMessageBox::critical(this, windowTitle(), + tr("Could not unlock wallet."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case AddressTableModel::KEY_GENERATION_FAILURE: + QMessageBox::critical(this, windowTitle(), + tr("New key generation failed."), + QMessageBox::Ok, QMessageBox::Ok); + break; + + } + return; + } + QDialog::accept(); +} + +QString EditAddressDialog::getAddress() const +{ + return address; +} + +void EditAddressDialog::setAddress(const QString &address) +{ + this->address = address; + ui->addressEdit->setText(address); +} diff --git a/src/qt/editaddressdialog.h b/src/qt/editaddressdialog.h new file mode 100644 index 0000000..95f7222 --- /dev/null +++ b/src/qt/editaddressdialog.h @@ -0,0 +1,52 @@ +#ifndef EDITADDRESSDIALOG_H +#define EDITADDRESSDIALOG_H + +#include + +namespace Ui { + class EditAddressDialog; +} +class AddressTableModel; + +QT_BEGIN_NAMESPACE +class QDataWidgetMapper; +QT_END_NAMESPACE + +/** Dialog for editing an address and associated information. + */ +class EditAddressDialog : public QDialog +{ + Q_OBJECT + +public: + enum Mode { + NewReceivingAddress, + NewSendingAddress, + EditReceivingAddress, + EditSendingAddress + }; + + explicit EditAddressDialog(Mode mode, QWidget *parent = 0); + ~EditAddressDialog(); + + void setModel(AddressTableModel *model); + void loadRow(int row); + + QString getAddress() const; + void setAddress(const QString &address); + +public slots: + void accept(); + +private: + bool saveCurrentRow(); + + Ui::EditAddressDialog *ui; + QDataWidgetMapper *mapper; + Mode mode; + AddressTableModel *model; + + QString address; +}; + +#endif // EDITADDRESSDIALOG_H diff --git a/src/qt/flowlayout.cpp b/src/qt/flowlayout.cpp new file mode 100644 index 0000000..050fc9a --- /dev/null +++ b/src/qt/flowlayout.cpp @@ -0,0 +1,215 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include "flowlayout.h" +//! [1] +FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) + : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) +{ + setContentsMargins(margin, margin, margin, margin); +} + +FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing) + : m_hSpace(hSpacing), m_vSpace(vSpacing) +{ + setContentsMargins(margin, margin, margin, margin); +} +//! [1] + +//! [2] +FlowLayout::~FlowLayout() +{ + QLayoutItem *item; + while ((item = takeAt(0))) + delete item; +} +//! [2] + +//! [3] +void FlowLayout::addItem(QLayoutItem *item) +{ + itemList.append(item); +} +//! [3] + +//! [4] +int FlowLayout::horizontalSpacing() const +{ + if (m_hSpace >= 0) { + return m_hSpace; + } else { + return smartSpacing(QStyle::PM_LayoutHorizontalSpacing); + } +} + +int FlowLayout::verticalSpacing() const +{ + if (m_vSpace >= 0) { + return m_vSpace; + } else { + return smartSpacing(QStyle::PM_LayoutVerticalSpacing); + } +} +//! [4] + +//! [5] +int FlowLayout::count() const +{ + return itemList.size(); +} + +QLayoutItem *FlowLayout::itemAt(int index) const +{ + return itemList.value(index); +} + +QLayoutItem *FlowLayout::takeAt(int index) +{ + if (index >= 0 && index < itemList.size()) + return itemList.takeAt(index); + else + return 0; +} +//! [5] + +//! [6] +Qt::Orientations FlowLayout::expandingDirections() const +{ + return 0; +} +//! [6] + +//! [7] +bool FlowLayout::hasHeightForWidth() const +{ + return true; +} + +int FlowLayout::heightForWidth(int width) const +{ + int height = doLayout(QRect(0, 0, width, 0), true); + return height; +} +//! [7] + +//! [8] +void FlowLayout::setGeometry(const QRect &rect) +{ + QLayout::setGeometry(rect); + doLayout(rect, false); +} + +QSize FlowLayout::sizeHint() const +{ + return minimumSize(); +} + +QSize FlowLayout::minimumSize() const +{ + QSize size; + QLayoutItem *item; + foreach (item, itemList) + size = size.expandedTo(item->minimumSize()); + + size += QSize(2*margin(), 2*margin()); + return size; +} +//! [8] + +//! [9] +int FlowLayout::doLayout(const QRect &rect, bool testOnly) const +{ + int left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom); + int x = effectiveRect.x(); + int y = effectiveRect.y(); + int lineHeight = 0; +//! [9] + +//! [10] + QLayoutItem *item; + foreach (item, itemList) { + QWidget *wid = item->widget(); + int spaceX = horizontalSpacing(); + if (spaceX == -1) + spaceX = wid->style()->layoutSpacing( + QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal); + int spaceY = verticalSpacing(); + if (spaceY == -1) + spaceY = wid->style()->layoutSpacing( + QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); +//! [10] +//! [11] + int nextX = x + item->sizeHint().width() + spaceX; + if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) { + x = effectiveRect.x(); + y = y + lineHeight + spaceY; + nextX = x + item->sizeHint().width() + spaceX; + lineHeight = 0; + } + + if (!testOnly) + item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); + + x = nextX; + lineHeight = qMax(lineHeight, item->sizeHint().height()); + } + return y + lineHeight - rect.y() + bottom; +} +//! [11] +//! [12] +int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const +{ + QObject *parent = this->parent(); + if (!parent) { + return -1; + } else if (parent->isWidgetType()) { + QWidget *pw = static_cast(parent); + return pw->style()->pixelMetric(pm, 0, pw); + } else { + return static_cast(parent)->spacing(); + } +} +//! [12] diff --git a/src/qt/flowlayout.h b/src/qt/flowlayout.h new file mode 100644 index 0000000..5381b4f --- /dev/null +++ b/src/qt/flowlayout.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FLOWLAYOUT_H +#define FLOWLAYOUT_H + +#include +#include +#include +//! [0] +class FlowLayout : public QLayout +{ +public: + FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); + FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); + ~FlowLayout(); + + void addItem(QLayoutItem *item); + int horizontalSpacing() const; + int verticalSpacing() const; + Qt::Orientations expandingDirections() const; + bool hasHeightForWidth() const; + int heightForWidth(int) const; + int count() const; + QLayoutItem *itemAt(int index) const; + QSize minimumSize() const; + void setGeometry(const QRect &rect); + QSize sizeHint() const; + QLayoutItem *takeAt(int index); + +private: + int doLayout(const QRect &rect, bool testOnly) const; + int smartSpacing(QStyle::PixelMetric pm) const; + + QList itemList; + int m_hSpace; + int m_vSpace; +}; +//! [0] + +#endif diff --git a/src/qt/forms/aboutdialog.ui b/src/qt/forms/aboutdialog.ui new file mode 100644 index 0000000..5ad4ce3 --- /dev/null +++ b/src/qt/forms/aboutdialog.ui @@ -0,0 +1,191 @@ + + + AboutDialog + + + + 0 + 0 + 593 + 319 + + + + About SONO + + + + + + + 0 + 0 + + + + :/images/about + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + IBeamCursor + + + <b>SONO</b> version + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + IBeamCursor + + + 3.0.4 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + IBeamCursor + + + Copyright © 2009-2017 The Bitcoin developers +Copyright © 2012-2017 The NovaCoin developers +Copyright © 2017 The SONO developers + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + IBeamCursor + + + +This is experimental software. + +Distributed under the MIT/X11 software license, see the accompanying file COPYING or <a href="http://www.opensource.org/licenses/mit-license.php">http://www.opensource.org/licenses/mit-license.php</a>. + +This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="https://www.openssl.org/">https://www.openssl.org/</a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com">eay@cryptsoft.com</a>) and UPnP software written by Thomas Bernard. + + + Qt::RichText + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + + + + + buttonBox + accepted() + AboutDialog + accept() + + + 360 + 308 + + + 157 + 274 + + + + + buttonBox + rejected() + AboutDialog + reject() + + + 428 + 308 + + + 286 + 274 + + + + + diff --git a/src/qt/forms/addeditadrenalinenode.ui b/src/qt/forms/addeditadrenalinenode.ui new file mode 100644 index 0000000..d1ff099 --- /dev/null +++ b/src/qt/forms/addeditadrenalinenode.ui @@ -0,0 +1,157 @@ + + + AddEditAdrenalineNode + + + + 0 + 0 + 540 + 256 + + + + Add/Edit SONONodes Node + + + true + + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + <html><head/><body><p>Enter an Alias (friendly name) for your SONO Masternode and its address (either clearnet IP and port or Tor onion address and port). The address should be in the format 123.456.789.123:9999 or akjdsafxjkhasdf.onion:9999. A masternode private key and a collateral address will both be automatically generated for you. You must send exactly 1000 SONO to the collateral address.</p></body></html> + + + true + + + + + + + 0 + + + + + Alias + + + + + + + + + + + + 0 + + + + + Address + + + + + + + + + + + + 0 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + 75 + true + + + + + + + Qt::PlainText + + + true + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + &OK + + + + + + + &Cancel + + + false + + + + + + + + + + diff --git a/src/qt/forms/addressbookpage.ui b/src/qt/forms/addressbookpage.ui new file mode 100644 index 0000000..9b3f863 --- /dev/null +++ b/src/qt/forms/addressbookpage.ui @@ -0,0 +1,148 @@ + + + AddressBookPage + + + + 0 + 0 + 760 + 380 + + + + Address Book + + + + + + These are your SONO addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. + + + Qt::PlainText + + + true + + + + + + + Qt::CustomContextMenu + + + Double-click to edit address or label + + + false + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + false + + + + + + + + + Create a new address + + + &New Address + + + + + + + Copy the currently selected address to the system clipboard + + + &Copy Address + + + + + + + Show &QR Code + + + + + + + Sign a message to prove you own a SONO address + + + Sign &Message + + + + + + + Verify a message to ensure it was signed with a specified SONO address + + + &Verify Message + + + + + + + Delete the currently selected address from the list + + + &Delete + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + QDialogButtonBox::Ok + + + + + + + + + + + + diff --git a/src/qt/forms/adrenalinenodeconfigdialog.ui b/src/qt/forms/adrenalinenodeconfigdialog.ui new file mode 100644 index 0000000..67119de --- /dev/null +++ b/src/qt/forms/adrenalinenodeconfigdialog.ui @@ -0,0 +1,74 @@ + + + AdrenalineNodeConfigDialog + + + + 0 + 0 + 620 + 250 + + + + SONONodes Node Configuration Template + + + + + + <html><head/><body><p>This pane shows an example SONO.conf template with the necessary masternode settings.</p></body></html> + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + accepted() + AdrenalineNodeConfigDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AdrenalineNodeConfigDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qt/forms/askpassphrasedialog.ui b/src/qt/forms/askpassphrasedialog.ui new file mode 100644 index 0000000..a60b730 --- /dev/null +++ b/src/qt/forms/askpassphrasedialog.ui @@ -0,0 +1,167 @@ + + + AskPassphraseDialog + + + + 0 + 0 + 598 + 198 + + + + + 0 + 0 + + + + + 550 + 0 + + + + Passphrase Dialog + + + + + + Qt::RichText + + + true + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Enter passphrase + + + + + + + QLineEdit::Password + + + + + + + New passphrase + + + + + + + QLineEdit::Password + + + + + + + Repeat new passphrase + + + + + + + QLineEdit::Password + + + + + + + + 75 + true + + + + + + + Qt::AlignCenter + + + + + + + true + + + Serves to disable the trivial sendmoney when OS account compromised. Provides no real security. + + + For staking only + + + false + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + AskPassphraseDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AskPassphraseDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qt/forms/blockbrowser.ui b/src/qt/forms/blockbrowser.ui new file mode 100644 index 0000000..6de5a7a --- /dev/null +++ b/src/qt/forms/blockbrowser.ui @@ -0,0 +1,699 @@ + + + BlockBrowser + + + Qt::NonModal + + + true + + + + 0 + 0 + 852 + 495 + + + + + 0 + 0 + + + + + 0 + 0 + + + + false + + + Form + + + + QLayout::SetMaximumSize + + + 21 + + + 21 + + + 10 + + + + + + + 0 + 0 + 501 + 27 + + + + + 7 + + + + + + Open Sans,sans-serif + + + + <html><head/><body><p><span style=" font-size:20px; font-weight:600; color:#000000;">SONO Block Explorer </span></p></body></html> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + 50 + 501 + 400 + + + + + QLayout::SetDefaultConstraint + + + 7 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Decode Transaction + + + + + + + Inputs: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + 0000 KH/s + + + + + + + Value out: + + + + + + + Transaction ID: + + + + + + + 0.00 + + + + + + + 000 + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + + + + + Block Difficulty: + + + + + + + + 0 + 0 + + + + 99999999 + + + + + + + Block Height: + + + + + + + 0 + + + + + + + Jump to Block + + + + + + + Block Merkle: + + + + + + + Block Hash: + + + + + + + + + + + + + + Block Hashrate: + + + + + + + 0 + + + + + + + Fees: + + + + + + + Block nBits: + + + + + + + 0 + + + + + + + + 187 + 0 + + + + 0x0 + + + + + + + Outputs: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Block nNonce: + + + + + + + 0 + + + + + + + Block Timestamp: + + + + + + + true + + + + 0 + 0 + + + + + 0 + 0 + + + + 0x0 + + + + + + + + 0 + 0 + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 500 + 40 + 580 + 351 + + + + + + + QLayout::SetMinimumSize + + + QFormLayout::FieldsStayAtSizeHint + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + 50 + + + 15 + + + 0 + + + 0 + + + + + <html><head/><body><p><span style=" font-weight:600;">Block Height</span></p></body></html> + + + + + + + 00000 + + + + + + + <html><head/><body><p><span style=" font-weight:600;">POW Block Reward</span></p></body></html> + + + + + + + 00000 + + + + + + + <html><head/><body><p><span style=" font-weight:600;">POW difficulty</span></p></body></html> + + + + + + + 0.0002 + + + + + + + <html><head/><body><p><span style=" font-weight:600;">POS difficulty</span></p></body></html> + + + + + + + 0.0002 + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Net Hashrate</span></p></body></html> + + + + + + + 0 MH/s + + + + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-weight:600;">Last block time</span></p></body></html> + + + + + + + 0 KH/s + + + + + + + true + + + + 12 + true + + + + <html><head/><body><p><span style=" font-weight:600;">Connections</span></p></body></html> + + + + + + + 0 + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Total Volume</span></p></body></html> + + + + + + + 000 + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Total stake weight</span></p></body></html> + + + + + + + 0 + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Network stake weight</span></p></body></html> + + + + + + + 0 + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Mining Phase</span></p></body></html> + + + + + + + PoW + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 505 + 0 + 321 + 26 + + + + + 7 + + + + + + Open Sans,sans-serif + + + + <html><head/><body><p><span style=" font-size:20px; font-weight:600; color:#000000;">SONO Network Statistics</span></p></body></html> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 510 + 390 + 120 + 60 + + + + + 0 + 0 + + + + + 120 + 60 + + + + background:lightgrey; + + + Update Statistics + + + false + + + false + + + false + + + + + + + + + diff --git a/src/qt/forms/clientcontrolpage.ui b/src/qt/forms/clientcontrolpage.ui new file mode 100644 index 0000000..5995157 --- /dev/null +++ b/src/qt/forms/clientcontrolpage.ui @@ -0,0 +1,568 @@ + + + ClientControlPage + + + + 0 + 0 + 822 + 344 + + + + Address Book + + + + + + + + + 75 + true + + + + Update Settings + + + + + 9 + 19 + 251 + 301 + + + + + + + + 0 + 120 + + + + + 16777215 + 110 + + + + + 50 + false + + + + Auto Update + + + + + 7 + 19 + 231 + 51 + + + + + + + Check for Updates on Startup + + + false + + + + + + + Apply + + + + + + + + + 80 + 80 + 161 + 31 + + + + true + + + + + + 10 + 84 + 71 + 20 + + + + Data + + + + + + + + + 0 + 150 + + + + + 50 + false + + + + Manual Update + + + + + 9 + 19 + 231 + 151 + + + + + + + Check for Update + + + + + + + Downgrade Current Client + + + + + + + + 0 + 85 + + + + Version + + + + + 10 + 40 + 211 + 31 + + + + + + + false + + + + 0 + 0 + + + + + 91 + 25 + + + + + + + + false + + + + 0 + 0 + + + + + 91 + 25 + + + + + + + + + + 40 + 20 + 61 + 21 + + + + Installed + + + + + + 150 + 20 + 61 + 20 + + + + Latest + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + 75 + true + + + + Interface Options + + + + + 9 + 19 + 251 + 301 + + + + + + + + 50 + false + + + + select + + + + + 9 + 19 + 231 + 271 + + + + + + + + + Minimal + + + + + + + false + + + Plus + + + + + + + false + + + Lite + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Submit + + + + + + + Preview + + + + + + + + + + 0 + 144 + + + + + + + + + + + + + + + + + + + + + + 75 + true + + + + Testing/Bug + + + + + 9 + 19 + 251 + 301 + + + + + + + + 50 + false + + + + Pre-Release Test + + + + + 10 + 20 + 231 + 121 + + + + + + + color: rgb(255, 0, 0); + + + (For Developer) + + + + + + + false + + + Pre-Release and Test versions + + + + + + + false + + + + 16777215 + 75 + + + + false + + + Update preRelease/Test version available + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + 50 + false + + + + Bug-Reporting + + + + + 10 + 20 + 231 + 115 + + + + + + + Input Issues + + + + + + + false + + + + 0 + 65 + + + + + 16777215 + 65 + + + + Please send your error to contact@SONO.tech + + + + + + + true + + + Submit + + + + + + + + + + + + + + + + + + diff --git a/src/qt/forms/coincontroldialog.ui b/src/qt/forms/coincontroldialog.ui new file mode 100644 index 0000000..6cb437b --- /dev/null +++ b/src/qt/forms/coincontroldialog.ui @@ -0,0 +1,549 @@ + + + CoinControlDialog + + + + 0 + 0 + 1000 + 500 + + + + Coin Control + + + + + + 0 + + + 10 + + + + + 10 + + + 10 + + + 6 + + + 6 + + + + + font-weight:bold; + + + Quantity: + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + font-weight:bold; + + + Bytes: + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + 10 + + + 10 + + + 6 + + + 6 + + + + + font-weight:bold; + + + Amount: + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0.00 BC + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + font-weight:bold; + + + Priority: + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + 10 + + + 10 + + + 6 + + + 6 + + + + + font-weight:bold; + + + Fee: + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0.00 BC + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + false + + + font-weight:bold; + + + Low Output: + + + + + + + false + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + no + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + 10 + + + 10 + + + 6 + + + 6 + + + + + font-weight:bold; + + + After Fee: + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0.00 BC + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + false + + + font-weight:bold; + + + Change: + + + + + + + false + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0.00 BC + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + + + 0 + 40 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + + 10 + 0 + 781 + 41 + + + + + 14 + + + + + + 0 + 0 + + + + (un)select all + + + + + + + + 0 + 0 + + + + Tree mode + + + true + + + + + + + + 0 + 0 + + + + List mode + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::CustomContextMenu + + + false + + + 11 + + + true + + + false + + + + + + + + + Amount + + + + + Label + + + + + Address + + + + + Date + + + + + Confirmations + + + Confirmed + + + + + Priority + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + CoinControlTreeWidget + QTreeWidget +
coincontroltreewidget.h
+
+
+ + +
diff --git a/src/qt/forms/darksendconfig.ui b/src/qt/forms/darksendconfig.ui new file mode 100644 index 0000000..44166f5 --- /dev/null +++ b/src/qt/forms/darksendconfig.ui @@ -0,0 +1,189 @@ + + + luxsendConfig + + + + 0 + 0 + 630 + 307 + + + + Configure luxsend + + + + + 20 + 70 + 151 + 27 + + + + Basic Privacy + + + + + + 20 + 140 + 151 + 27 + + + + High Privacy + + + + + + 20 + 210 + 151 + 27 + + + + Maximum Privacy + + + + + + 30 + 20 + 571 + 31 + + + + Please select a privacy level. + + + + + + 190 + 70 + 421 + 21 + + + + Use 2 separate masternodes to mix funds up to 1000 SONO + + + + + + 190 + 140 + 411 + 21 + + + + Use 8 separate masternodes to mix funds up to 1000 SONO + + + + + + 190 + 210 + 421 + 21 + + + + Use 16 separate masternodes + + + + + + 40 + 100 + 561 + 21 + + + + This option is the quickest and will cost about ~0.025 SONO to anonymize 1000 SONO + + + + + + 40 + 170 + 561 + 21 + + + + This option is moderately fast and will cost about 0.05 SONO to anonymize 1000 SONO + + + + + + 40 + 240 + 561 + 21 + + + + This is the slowest and most secure option. Using maximum anonymity will cost + + + + + + 40 + 260 + 561 + 21 + + + + 0.1 SONO per 1000 SONO you anonymize. + + + + + + 10 + 120 + 601 + 16 + + + + Qt::Horizontal + + + + + + 10 + 190 + 601 + 16 + + + + Qt::Horizontal + + + + + + + diff --git a/src/qt/forms/editaddressdialog.ui b/src/qt/forms/editaddressdialog.ui new file mode 100644 index 0000000..a170737 --- /dev/null +++ b/src/qt/forms/editaddressdialog.ui @@ -0,0 +1,112 @@ + + + EditAddressDialog + + + + 0 + 0 + 457 + 126 + + + + Edit Address + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + &Label + + + labelEdit + + + + + + + The label associated with this address book entry + + + + + + + &Address + + + addressEdit + + + + + + + The address associated with this address book entry. This can only be modified for sending addresses. + + + + + + + &Stealth Address + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + EditAddressDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + EditAddressDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qt/forms/generatepage.ui b/src/qt/forms/generatepage.ui new file mode 100644 index 0000000..b2d5040 --- /dev/null +++ b/src/qt/forms/generatepage.ui @@ -0,0 +1,1201 @@ + + + GeneratePage + + + + 0 + 0 + 879 + 499 + + + + Address Book + + + + + + + + + + + 75 + true + + + + PoW + + + + + 10 + 20 + 262 + 451 + + + + + + + + 0 + 65 + + + + + 16777215 + 75 + + + + + 50 + false + + + + CPU + + + + + 10 + 20 + 241 + 51 + + + + + + + + + + 50 + false + + + + CPU Cores + + + + + + + + 50 + false + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + 260 + 135 + + + + + 16777215 + 145 + + + + + 50 + false + + + + GPU + + + + + 10 + 20 + 241 + 111 + + + + + + + + + + 50 + false + + + + GPU Quantity + + + + + + + + 50 + false + + + + + + + + + + + + + + + + 50 + false + + + + GPU Model Select + + + + + + + + 50 + false + + + + + + + + + + + + + + + + 50 + false + + + + Manual GPU Config + + + + + + + true + + + + 0 + 0 + + + + + 256 + 26 + + + + + 50 + false + + + + background-color: rgb(34, 34, 34); +selection-background-color: rgb(0, 85, 127); +color: rgb(255, 255, 255); + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + 16777215 + 225 + + + + + 50 + false + + + + Start + + + + + 10 + 20 + 241 + 191 + + + + + + + + + + 50 + false + + + + Solo + + + + + + + true + + + + 0 + 0 + + + + + 110 + 0 + + + + + 256 + 26 + + + + + 50 + false + + + + background-color: rgb(34, 34, 34); +selection-background-color: rgb(0, 85, 127); +color: rgb(255, 255, 255); + + + Pool URL + + + + + + + + true + + + + 0 + 0 + + + + + 256 + 26 + + + + + 50 + false + + + + background-color: rgb(34, 34, 34); +selection-background-color: rgb(0, 85, 127); +color: rgb(255, 255, 255); + + + Port + + + + + + + + + + + + 50 + false + + + + Worker/User + + + + + + + + 50 + false + + + + Password + + + + + + + + + + + true + + + + 0 + 0 + + + + + 256 + 26 + + + + + 50 + false + + + + background-color: rgb(34, 34, 34); +selection-background-color: rgb(0, 85, 127); +color: rgb(255, 255, 255); + + + + + + + + + + true + + + + 0 + 0 + + + + + 256 + 26 + + + + + 50 + false + + + + background-color: rgb(34, 34, 34); +selection-background-color: rgb(0, 85, 127); +color: rgb(255, 255, 255); + + + + + + + + + + + + + + true + + + + 0 + 26 + + + + + 50 + false + + + + PointingHandCursor + + + background-color: rgb(34, 34, 34); +selection-background-color: rgb(0, 85, 127); +color: rgb(255, 255, 255); + + + Get Hash/s + + + + + + + false + + + + 0 + 0 + + + + + 256 + 26 + + + + + 50 + false + + + + background-color: rgb(34, 34, 34); +selection-background-color: rgb(0, 85, 127); +color: rgb(255, 255, 255); + + + 0 Hash/s + + + + + + + + + true + + + + 0 + 26 + + + + + 50 + false + + + + PointingHandCursor + + + background-color: rgb(34, 34, 34); +selection-background-color: rgb(0, 85, 127); +color: rgb(255, 255, 255); + + + Apply Settings + + + + + + + + 0 + 26 + + + + + 8 + 75 + true + + + + PointingHandCursor + + + background-color: rgb(34, 34, 34); +selection-background-color: rgb(0, 85, 127); +color: rgb(255, 255, 255); + + + Start Mining + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + + + + + 75 + true + + + + PoS + + + + + 10 + 20 + 261 + 451 + + + + + + + + 50 + false + + + + Overview + + + + + 10 + 20 + 241 + 421 + + + + + + + Status + + + + + 10 + 20 + 221 + 21 + + + + + + + Coins are: + + + + + + + NOT STAKING + + + + + + + + + 10 + 40 + 221 + 21 + + + + + + + Est. Next Stake: + + + + + + + UNKNOWN + + + + + + + + + 10 + 60 + 221 + 21 + + + + + + + Net Total Stake: + + + + + + + 0 + + + + + + + + + 10 + 80 + 221 + 21 + + + + + + + Difficulty: + + + + + + + 0 + + + + + + + + + 10 + 100 + 221 + 21 + + + + + + + Staking is: + + + + + + + DISABLED + + + + + + + + + 20 + 20 + 221 + 21 + + + + + + + Coins are: + + + + + + + NOT STAKING + + + + + + + + + 20 + 100 + 221 + 21 + + + + + + + Staking is: + + + + + + + DISABLED + + + + + + + + + 20 + 40 + 221 + 21 + + + + + + + Est. Next Stake: + + + + + + + UNKNOWN + + + + + + + + + + + Weight + + + + + 10 + 20 + 231 + 113 + + + + + + + You: + + + + + + + 0 + + + + + + + Network: + + + + + + + 0 + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Staking Statistics + + + + + 10 + 20 + 231 + 21 + + + + + + + + 100 + 16777215 + + + + Hourly: + + + + + + + 0 + + + + + + + + + 10 + 60 + 231 + 21 + + + + + + + + 100 + 16777215 + + + + Weekly: + + + + + + + 0 + + + + + + + + + 10 + 80 + 231 + 21 + + + + + + + + 100 + 16777215 + + + + Monthly: + + + + + + + 0 + + + + + + + + + 10 + 40 + 231 + 21 + + + + + + + + 100 + 16777215 + + + + Daily + + + + + + + 0 + + + + + + + + + 10 + 100 + 231 + 21 + + + + + + + + 100 + 16777215 + + + + Last Block Time: + + + + + + + 00:00 + + + + + + + + + + + + + + + + + + + + + + + + 75 + true + + + + PoR Generation + + + + + 10 + 20 + 244 + 301 + + + + + + + + 20 + 50 + false + + + + COMING - SOON + + + Qt::AlignCenter + + + + + + + + + + + + + + + + diff --git a/src/qt/forms/masternodemanager.ui b/src/qt/forms/masternodemanager.ui new file mode 100644 index 0000000..9ad6e47 --- /dev/null +++ b/src/qt/forms/masternodemanager.ui @@ -0,0 +1,376 @@ + + + MasternodeManager + + + + 0 + 0 + 723 + 457 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 0 + + + + + 1 + + + + SONO Masternodes Network + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::SelectRows + + + true + + + + Address + + + + + Rank + + + + + Active + + + + + Active (secs) + + + + + Last Seen + + + + + Pubkey + + + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::SelectRows + + + true + + + true + + + + Address + + + + + Rank + + + + + Active + + + + + Active (secs) + + + + + Last Seen + + + + + Pubkey + + + + + + + + 0 + + + + + SONO Masternodes Activated: + + + + + + + 0 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + My SONO Masternode + + + + + + 0 + + + + + + + &Create... + + + + + + + Copy &Address + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + + Alias + + + + + IP/Onion + + + + + Status + + + + + Collateral Address + + + + + + + + 0 + + + + + &Edit + + + + + + + &Get Config + + + + + + + &Remove + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + &Start + + + + + + + Sto&p + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + S&tart All + + + + + + + St&op All + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + + diff --git a/src/qt/forms/messagepage.ui b/src/qt/forms/messagepage.ui new file mode 100644 index 0000000..cdbc715 --- /dev/null +++ b/src/qt/forms/messagepage.ui @@ -0,0 +1,246 @@ + + + MessagePage + + + + 0 + 0 + 793 + 419 + + + + Address Book + + + + + + These are your sent and received encrypted messages. Click on an item to read it. + + + Qt::PlainText + + + true + + + + + + + Qt::CustomContextMenu + + + Click on a message to view it + + + false + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + false + + + + + + + + + + + + + 2 + + + 0 + + + 6 + + + 0 + + + 0 + + + + + + + &Back + + + + :/icons/quit:/icons/quit + + + + + + + Contact: + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + #listConversation { color: #000000; } + + + + + + + + + + + + + + 0 + 100 + + + + + + + + + + &Conversation + + + + :/icons/add:/icons/add + + + + + + + Sign a message to prove you own a SONO address + + + &Send + + + + :/icons/send:/icons/send + + + + + + + Copy the currently selected address to the system clipboard + + + &Copy From Address + + + + :/icons/editcopy:/icons/editcopy + + + + + + + Copy the currently selected address to the system clipboard + + + Copy To &Address + + + + :/icons/editcopy:/icons/editcopy + + + + + + + Delete the currently selected address from the list + + + &Delete + + + + :/icons/remove:/icons/remove + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + MRichTextEdit + QWidget +
mrichtextedit.h
+ 1 +
+
+ + + + +
diff --git a/src/qt/forms/multisigaddressentry.ui b/src/qt/forms/multisigaddressentry.ui new file mode 100644 index 0000000..6324c38 --- /dev/null +++ b/src/qt/forms/multisigaddressentry.ui @@ -0,0 +1,170 @@ + + + MultisigAddressEntry + + + + 0 + 0 + 729 + 136 + + + + Form + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + + + Public &key: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + pubkey + + + + + + + 0 + + + + + The public key of an address + + + Enter a public key + + + + + + + Paste public key from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + Remove this public key + + + + + + + :/icons/remove:/icons/remove + + + + + + + + + &Address: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + address + + + + + + + 0 + + + + + true + + + Address associated to the public key + + + Enter one of your addresses to get its public key + + + + + + + Choose address from address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + + + + + + + Label: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + Address associated to the public key + + + true + + + + + + + + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+
+ + + + +
\ No newline at end of file diff --git a/src/qt/forms/multisigdialog.ui b/src/qt/forms/multisigdialog.ui new file mode 100644 index 0000000..c488ee5 --- /dev/null +++ b/src/qt/forms/multisigdialog.ui @@ -0,0 +1,773 @@ + + + MultisigDialog + + + + 0 + 0 + 1327 + 595 + + + + Multisig + + + + + + 0 + + + + &Create Address + + + + + + true + + + + + 0 + 0 + 1283 + 345 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Add a member to the signing pool + + + &Add public key... + + + + :/icons/add:/icons/add + + + + + + + + 0 + 0 + + + + Remove all public key fields + + + Clear all + + + + :/icons/remove:/icons/remove + + + 300 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Required signatures: + + + + + + + + 0 + 0 + + + + + 127 + 0 + + + + + + + 2 + + + true + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Enter a number + + + + + + + / 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Create multisig address + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Multisig address: + + + + + + + true + + + + + + + Copy the multisig address to the system clipboard + + + + + + + :/icons/editcopy:/icons/editcopy + + + false + + + + + + + + + + + Redeem script: + + + + + + + true + + + + + + + Copy the redeem script to the system clipboard + + + + + + + :/icons/editcopy:/icons/editcopy + + + false + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + &Spend Funds + + + + + + + + + + Inputs + + + + + + + 0 + 0 + + + + true + + + + + 0 + 0 + 616 + 271 + + + + + + + + + + Qt::Vertical + + + + 20 + 42 + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Inputs amount: + + + + + + + 123.456 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + SONO + + + + + + + + + + + Add input... + + + + :/icons/add:/icons/add + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Outputs + + + + + + + 0 + 0 + + + + true + + + + + 0 + 0 + 615 + 243 + + + + + + + + + + Qt::Vertical + + + + 20 + 42 + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Outputs amount: + + + + + + + 123.456 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + SONO + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Fee: + + + + + + + 123.456 + + + + + + + SONO + + + + + + + + + + + Add output... + + + + :/icons/add:/icons/add + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + Create transaction + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + 0 + 0 + + + + Enter a raw transaction or create a new one + + + + + + + + + + + + + + :/icons/editcopy:/icons/editcopy + + + false + + + + + + + Paste address from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + false + + + + + + + + + + + Sign transaction + + + + :/icons/edit:/icons/edit + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + 0 + 0 + + + + true + + + + + + + + + + + + + + :/icons/editcopy:/icons/editcopy + + + false + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Send transaction + + + + :/icons/send:/icons/send + + + + + + + + + + + + + + + + + + diff --git a/src/qt/forms/multisiginputentry.ui b/src/qt/forms/multisiginputentry.ui new file mode 100644 index 0000000..3dcffc7 --- /dev/null +++ b/src/qt/forms/multisiginputentry.ui @@ -0,0 +1,160 @@ + + +MultisigInputEntry + + + +0 +0 +729 +136 + + + +Form + + +QFrame::StyledPanel + + +QFrame::Sunken + + + + + +0 + + + + + + + +Enter a transaction id + + + + + + + + + + + + + +:/icons/editpaste:/icons/editpaste + + +Alt+P + + + + + + + + + + + + + +:/icons/remove:/icons/remove + + + + + + + + +Transaction id: + + +Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + +transactionId + + + + + + +Transaction output: + + +Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + +Redeem script: + + +Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + +redeemScript + + + + + + +0 + + + + +true + + + + + +Enter the redeem script of the address in the transaction output + + + + + + + + + + + + + +:/icons/editpaste:/icons/editpaste + + +Alt+A + + + + + + + + + + + + +QValidatedLineEdit +QLineEdit +
qvalidatedlineedit.h
+
+
+ + + + +
\ No newline at end of file diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui new file mode 100644 index 0000000..d6ad5b5 --- /dev/null +++ b/src/qt/forms/optionsdialog.ui @@ -0,0 +1,494 @@ + + + OptionsDialog + + + + 0 + 0 + 540 + 380 + + + + Options + + + true + + + + + + QTabWidget::North + + + 3 + + + + &Main + + + + + + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended. + + + Qt::PlainText + + + true + + + + + + + + + Pay transaction &fee + + + Qt::PlainText + + + transactionFee + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Reserved amount does not participate in staking and is therefore spendable at any time. + + + Qt::PlainText + + + true + + + + + + + + + Reserve + + + Qt::PlainText + + + reserveBalance + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Automatically start SONO after logging in to the system. + + + &Start SONO on system login + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + &Network + + + + + + Automatically open the SONO client port on the router. This only works when your router supports UPnP and it is enabled. + + + Map port using &UPnP + + + + + + + Connect to the SONO network through a SOCKS5 proxy (e.g. when connecting through Tor). + + + &Connect through SOCKS5 proxy: + + + + + + + + + Proxy &IP: + + + Qt::PlainText + + + proxyIp + + + + + + + + 140 + 16777215 + + + + IP address of the proxy (e.g. 127.0.0.1) + + + + + + + &Port: + + + Qt::PlainText + + + proxyPort + + + + + + + + 55 + 16777215 + + + + Port of the proxy (e.g. 9050) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + &Window + + + + + + Show only a tray icon after minimizing the window. + + + &Minimize to the tray instead of the taskbar + + + + + + + Minimize instead of exit the application when the window is closed. When this option is enabled, the application will be closed only after selecting Quit in the menu. + + + M&inimize on close + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + &Display + + + + + + + + User Interface &language: + + + Qt::PlainText + + + lang + + + + + + + The user interface language can be set here. This setting will take effect after restarting SONO. + + + + + + + + + + + &Unit to show amounts in: + + + Qt::PlainText + + + unit + + + + + + + Choose the default subdivision unit to show in the interface and when sending coins. + + + + + + + + + Whether to show coin control features or not. + + + Display coin &control features (experts only!) + + + + + + + Whether to select the coin outputs randomly or with minimal coin age. + + + Minimize weight consumption (experimental) + + + + + + + Use black visual theme (requires restart) + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + 75 + true + + + + + + + Qt::PlainText + + + true + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + &OK + + + + + + + &Cancel + + + false + + + + + + + &Apply + + + false + + + + + + + + + + BitcoinAmountField + QSpinBox +
bitcoinamountfield.h
+ 1 +
+ + QValueComboBox + QComboBox +
qvaluecombobox.h
+
+ + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+
+ + +
diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui new file mode 100644 index 0000000..d64ea15 --- /dev/null +++ b/src/qt/forms/overviewpage.ui @@ -0,0 +1,1171 @@ + + + OverviewPage + + + + 0 + 0 + 972 + 594 + + + + + 960 + 0 + + + + Form + + + + + + false + + + background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop:0 #F0D0A0, stop:1 #F8D488); color:#000000; + + + true + + + 3 + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + 75 + true + + + + Balances + + + + + + + WhatsThisCursor + + + The displayed information may be out of date. Your wallet automatically synchronizes with the Transfer network after a connection is established, but this process has not completed yet. + + + QLabel { color: red; } + + + () + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 12 + + + + + + 75 + true + + + + IBeamCursor + + + Total of transactions that have yet to be confirmed, and do not yet count toward the spendable balance + + + 0.000 000 00 BTC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 140 + 0 + + + + Qt::Horizontal + + + + + + + Total: + + + + + + + + 75 + true + + + + IBeamCursor + + + Mined balance that has not yet matured + + + 0.000 000 00 BTC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Immature: + + + + + + + + 75 + true + + + + IBeamCursor + + + Your current total balance + + + 0.000 000 00 BTC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Available: + + + + + + + + 75 + true + + + + IBeamCursor + + + Your current spendable balance + + + 0.000 000 00 BTC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Stake: + + + + + + + + 75 + true + + + + IBeamCursor + + + Total of coins that was staked, and do not yet count toward the current balance + + + 0.000 000 00 BTC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Pending: + + + + + + + Spendable: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 350 + + + + Qt::LeftToRight + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + 75 + true + + + + darksend + + + + + + + The displayed information may be out of date. Your wallet automatically synchronizes with the SONO network after a connection is established, but this process has not completed yet. + + + QLabel { color: red; } + + + (out of sync) + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 239 + 238 + 238 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 246 + 246 + + + + + + + 119 + 119 + 119 + + + + + + + 159 + 159 + 159 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 239 + 238 + 238 + + + + + + + 0 + 0 + 0 + + + + + + + 247 + 246 + 246 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 239 + 238 + 238 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 246 + 246 + + + + + + + 119 + 119 + 119 + + + + + + + 159 + 159 + 159 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 239 + 238 + 238 + + + + + + + 0 + 0 + 0 + + + + + + + 247 + 246 + 246 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 119 + 119 + 119 + + + + + + + 239 + 238 + 238 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 246 + 246 + + + + + + + 119 + 119 + 119 + + + + + + + 159 + 159 + 159 + + + + + + + 119 + 119 + 119 + + + + + + + 255 + 255 + 255 + + + + + + + 119 + 119 + 119 + + + + + + + 239 + 238 + 238 + + + + + + + 239 + 238 + 238 + + + + + + + 0 + 0 + 0 + + + + + + + 239 + 238 + 238 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + Qt::NoFocus + + + true + + + + + + true + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 11 + + + 12 + + + + + Status: + + + + + + + Completion: + + + + + + + + 154 + 16777215 + + + + 0 + + + + + + + darksend Balance: + + + + + + + + 75 + true + + + + 0 SONO + + + + + + + Amount and Rounds: + + + + + + + 0 SONO / 0 Rounds + + + + + + + Submitted Denom: + + + + + + + The denominations you submitted to the Masternode.<br>To mix, other users must submit the exact same denominations. + + + n/a + + + + + + + Enabled/Disabled + + + + + + + + + Qt::Horizontal + + + + + + + + 288 + 43 + + + + (Last Message) + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + 0 + 0 + + + + Try to manually submit a luxsend request. + + + Try Mix + + + + + + + + 0 + 0 + + + + Start/Stop Mixing + + + + + + + + 0 + 0 + + + + Reset the current status of luxsend (can interrupt luxsend if it's in the process of Mixing, which can cost you money!) + + + false + + + Reset + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + 75 + true + + + + Recent transactions + + + + + + + WhatsThisCursor + + + The displayed information may be out of date. Your wallet automatically synchronizes with the SONO network after a connection is established, but this process has not completed yet. + + + QLabel { color: red; } + + + (out of sync) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + QListView { background: transparent; } + + + QFrame::NoFrame + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QAbstractItemView::NoSelection + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 1 + + + 1 + + + 1 + + + 1 + + + + + + + + 0 + 0 + + + + + 700 + 180 + + + + + 1000 + 1000 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + QCustomPlot + QWidget +
qcustomplot.h
+
+
+ + +
diff --git a/src/qt/forms/qrcodedialog.ui b/src/qt/forms/qrcodedialog.ui new file mode 100644 index 0000000..723f61b --- /dev/null +++ b/src/qt/forms/qrcodedialog.ui @@ -0,0 +1,212 @@ + + + QRCodeDialog + + + + 0 + 0 + 340 + 530 + + + + QR Code Dialog + + + + + + + 0 + 0 + + + + + 300 + 300 + + + + Qt::PlainText + + + Qt::AlignCenter + + + true + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + true + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + true + + + Request Payment + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Label: + + + Qt::PlainText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + lnLabel + + + + + + + + + + Message: + + + Qt::PlainText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + lnMessage + + + + + + + + + + + 0 + 0 + + + + Amount: + + + Qt::PlainText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + lnReqAmount + + + + + + + false + + + + 80 + 0 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + &Save As... + + + + + + + + + + + + + BitcoinAmountField + QSpinBox +
bitcoinamountfield.h
+
+
+ + + + chkReqPayment + clicked(bool) + lnReqAmount + setEnabled(bool) + + + 92 + 285 + + + 98 + 311 + + + + +
diff --git a/src/qt/forms/rpcconsole.ui b/src/qt/forms/rpcconsole.ui new file mode 100644 index 0000000..af5b5ac --- /dev/null +++ b/src/qt/forms/rpcconsole.ui @@ -0,0 +1,694 @@ + + + RPCConsole + + + + 0 + 0 + 740 + 450 + + + + SONO - Debug window + + + + + + 0 + + + + &Information + + + + 12 + + + + + + 75 + true + + + + SONO Core + + + + + + + Client name + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Client version + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Using OpenSSL version + + + 10 + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Build date + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Startup time + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + Network + + + + + + + Number of connections + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + On testnet + + + + + + + false + + + + + + + + + + + 75 + true + + + + Block chain + + + + + + + Current number of blocks + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Last block time + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + 75 + true + + + + Debug log file + + + + + + + Open the SONO debug log file from the current data directory. This can take a few seconds for large log files. + + + &Open + + + false + + + + + + + + 75 + true + + + + Command-line options + + + + + + + Show the SONO-Qt help message to get a list with possible SONO command-line options. + + + &Show + + + false + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + &Console + + + + 3 + + + + + + 0 + 100 + + + + true + + + false + + + 2 + + + + + + + 3 + + + + + > + + + + + + + + + + + 24 + 24 + + + + Clear console + + + + + + + :/icons/remove:/icons/remove + + + Ctrl+L + + + false + + + + + + + + + + &Network Traffic + + + + + + + + + 0 + 0 + + + + + + + + + + 1 + + + 288 + + + 12 + + + 6 + + + Qt::Horizontal + + + + + + + + 100 + 0 + + + + Qt::AlignCenter + + + + + + + &Clear + + + + + + + + + + + + + Totals + + + + + + + + + 0 + 0 + + + + + 10 + 0 + + + + + + + + + 0 + 255 + 0 + + + + + + + + + 0 + 255 + 0 + + + + + + + + + 0 + 255 + 0 + + + + + + + + Qt::Horizontal + + + + + + + In: + + + + + + + + 50 + 0 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + 0 + 0 + + + + + 10 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + Qt::Horizontal + + + + + + + Out: + + + + + + + + 50 + 0 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + Qt::Vertical + + + + 20 + 407 + + + + + + + + + + + + + + + + + + TrafficGraphWidget + QWidget +
trafficgraphwidget.h
+ 1 + + clear() + +
+
+ + + + +
diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui new file mode 100644 index 0000000..e531c42 --- /dev/null +++ b/src/qt/forms/sendcoinsdialog.ui @@ -0,0 +1,780 @@ + + + SendCoinsDialog + + + + 0 + 0 + 850 + 400 + + + + Send Coins + + + + 8 + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + -1 + + + 0 + + + 0 + + + 0 + + + 6 + + + + + 0 + + + 10 + + + 10 + + + + + 15 + + + + + + 0 + 0 + + + + + 75 + true + + + + font-weight:bold; + + + Coin Control Features + + + + + + + + + 8 + + + 10 + + + + + + + + Inputs... + + + + + + + automatically selected + + + 5 + + + + + + + + 75 + true + + + + color:red;font-weight:bold; + + + Insufficient funds! + + + 5 + + + + + + + Qt::Horizontal + + + + 40 + 1 + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + 0 + + + + + 20 + + + 0 + + + 10 + + + + + 10 + + + 14 + + + 10 + + + 4 + + + 6 + + + + + font-weight:bold; + + + Quantity: + + + 0 + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0 + + + 0 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + font-weight:bold; + + + Bytes: + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + 10 + + + 14 + + + 6 + + + 4 + + + 6 + + + + + font-weight:bold; + + + Amount: + + + 0 + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0.00 BC + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + font-weight:bold; + + + Priority: + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + medium + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + 10 + + + 14 + + + 6 + + + 4 + + + 6 + + + + + font-weight:bold; + + + Fee: + + + 0 + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0.00 BC + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + font-weight:bold; + + + Low Output: + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + no + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + 10 + + + 14 + + + 6 + + + 4 + + + 6 + + + + + font-weight:bold; + + + After Fee: + + + 0 + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0.00 BC + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + font-weight:bold; + + + Change + + + + + + + + Monospace + 10 + + + + IBeamCursor + + + Qt::ActionsContextMenu + + + 0.00 BC + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + + + + + 12 + + + QLayout::SetDefaultConstraint + + + 5 + + + 5 + + + + + custom change address + + + + + + + false + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + 3 + + + + + + + + + Qt::Vertical + + + + 800 + 1 + + + + + + + + + + + + + true + + + + + 0 + 0 + 830 + 165 + + + + + 0 + + + + + 6 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Send to multiple recipients at once + + + Add &Recipient + + + false + + + + + + + + 0 + 0 + + + + Remove all transaction fields + + + Clear &All + + + 300 + + + false + + + + + + + 3 + + + + + + 0 + 0 + + + + Balance: + + + + + + + + 0 + 0 + + + + IBeamCursor + + + 123.456 BC + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 150 + 0 + + + + Confirm the send action + + + S&end + + + + :/icons/send:/icons/send + + + true + + + + + + + + + + + + diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui new file mode 100644 index 0000000..bdd0138 --- /dev/null +++ b/src/qt/forms/sendcoinsentry.ui @@ -0,0 +1,159 @@ + + + SendCoinsEntry + + + + 0 + 0 + 350 + 136 + + + + Form + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + 12 + + + + + A&mount: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + payAmount + + + + + + + Pay &To: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + payTo + + + + + + + + + + &Label: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + addAsLabel + + + + + + + 0 + + + + + The address to send the payment to (e.g. C8gZqgY4r2RoEdqYk3QsAqFckyf9pRHN6i) + + + 80 + + + + + + + Choose address from address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + + + + + Paste address from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + Remove this recipient + + + + + + + :/icons/remove:/icons/remove + + + + + + + + + Enter a label for this address to add it to your address book + + + + + + + + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+ + BitcoinAmountField + QLineEdit +
bitcoinamountfield.h
+ 1 +
+
+ + + + +
diff --git a/src/qt/forms/sendmessagesdialog.ui b/src/qt/forms/sendmessagesdialog.ui new file mode 100644 index 0000000..6716bc2 --- /dev/null +++ b/src/qt/forms/sendmessagesdialog.ui @@ -0,0 +1,262 @@ + + + SendMessagesDialog + + + + 0 + 0 + 850 + 400 + + + + Send Messages + + + #SendMessagesDialog { background-color: #383838; } + + + + 8 + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + + + color: #ffffff; + + + Address &From: + + + addressFrom + + + + + + + 1 + + + + + + + + Choose address from address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + + + + + Paste address from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + + + + + + true + + + + + 0 + 0 + 830 + 298 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 6 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Send to multiple recipients at once + + + Add &Recipient + + + + :/icons/add:/icons/add + + + false + + + + + + + + 0 + 0 + + + + Remove all transaction fields + + + Clear &All + + + + :/icons/remove:/icons/remove + + + 300 + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 150 + 0 + + + + Confirm the send action + + + S&end + + + + :/icons/send:/icons/send + + + true + + + + + + + &Close + + + + :/icons/quit:/icons/quit + + + + + + + + + + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+
+ + + + +
diff --git a/src/qt/forms/sendmessagesentry.ui b/src/qt/forms/sendmessagesentry.ui new file mode 100644 index 0000000..d59fda3 --- /dev/null +++ b/src/qt/forms/sendmessagesentry.ui @@ -0,0 +1,184 @@ + + + SendMessagesEntry + + + + 0 + 0 + 729 + 236 + + + + Form + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + 12 + + + + + 0 + + + + + The address to send the payment to (e.g. CKPnZKDzaDXqEgKJ4GdUg58gXxgzA7mkny) + + + 34 + + + + + + + Choose address from address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + + + + + Paste address from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + Remove this recipient + + + + + + + :/icons/remove:/icons/remove + + + + + + + + + &Message: + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing + + + messageText + + + + + + + Send &To: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + sendTo + + + + + + + true + + + Qt::WheelFocus + + + false + + + + + + + true + + + Enter a label for this address to add it to your address book + + + + + + + &Label: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + addAsLabel + + + + + + + &Public Key: + + + publicKey + + + + + + + + + + + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+ + QValidatedTextEdit + QPlainTextEdit +
qvalidatedtextedit.h
+
+
+ + + + +
diff --git a/src/qt/forms/sidetoolbar.cpp b/src/qt/forms/sidetoolbar.cpp new file mode 100644 index 0000000..5cf3494 --- /dev/null +++ b/src/qt/forms/sidetoolbar.cpp @@ -0,0 +1,19 @@ +#include "sidetoolbar.h" +#include "ui_sidetoolbar.h" + +sidetoolbar::sidetoolbar(QWidget *parent) : + QWidget(parent), + ui(new Ui::sidetoolbar) +{ + ui->setupUi(this); +} + +sidetoolbar::~sidetoolbar() +{ + delete ui; +} + +void sidetoolbar::on_sidetoolbar_destroyed() +{ + +} diff --git a/src/qt/forms/sidetoolbar.h b/src/qt/forms/sidetoolbar.h new file mode 100644 index 0000000..c40a5c7 --- /dev/null +++ b/src/qt/forms/sidetoolbar.h @@ -0,0 +1,25 @@ +#ifndef SIDETOOLBAR_H +#define SIDETOOLBAR_H + +#include + +namespace Ui { +class sidetoolbar; +} + +class sidetoolbar : public QWidget +{ + Q_OBJECT + +public: + explicit sidetoolbar(QWidget *parent = 0); + ~sidetoolbar(); + +private slots: + void on_sidetoolbar_destroyed(); + +private: + Ui::sidetoolbar *ui; +}; + +#endif // SIDETOOLBAR_H diff --git a/src/qt/forms/sidetoolbar.ui b/src/qt/forms/sidetoolbar.ui new file mode 100644 index 0000000..52e9a35 --- /dev/null +++ b/src/qt/forms/sidetoolbar.ui @@ -0,0 +1,31 @@ + + + sidetoolbar + + + + 0 + 0 + 100 + 415 + + + + + 0 + 0 + + + + + 16777215 + 415 + + + + Form + + + + + diff --git a/src/qt/forms/signverifymessagedialog.ui b/src/qt/forms/signverifymessagedialog.ui new file mode 100644 index 0000000..5f80501 --- /dev/null +++ b/src/qt/forms/signverifymessagedialog.ui @@ -0,0 +1,386 @@ + + + SignVerifyMessageDialog + + + + 0 + 0 + 700 + 380 + + + + Signatures - Sign / Verify a Message + + + true + + + + + + 1 + + + + &Sign Message + + + + + + You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to. + + + Qt::PlainText + + + true + + + + + + + 0 + + + + + The address to sign the message with (e.g. CKPnZKDzaDXqEgKJ4GdUg58gXxgzA7mkny) + + + 34 + + + + + + + Choose an address from the address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + false + + + + + + + Paste address from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + false + + + + + + + + + Enter the message you want to sign here + + + + + + + 0 + + + + + + true + + + + true + + + + + + + Copy the current signature to the system clipboard + + + + + + + :/icons/editcopy:/icons/editcopy + + + false + + + + + + + + + + + Sign the message to prove you own this SONO address + + + &Sign Message + + + + :/icons/edit:/icons/edit + + + false + + + + + + + Reset all sign message fields + + + Clear &All + + + + :/icons/remove:/icons/remove + + + false + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + 75 + true + + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + + + &Verify Message + + + + + + Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack. + + + Qt::PlainText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + 0 + + + + + The address the message was signed with (e.g. CKPnZKDzaDXqEgKJ4GdUg58gXxgzA7mkny) + + + 34 + + + + + + + Choose an address from the address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + false + + + + + + + + + + + + + + + + + Verify the message to ensure it was signed with the specified SONO address + + + &Verify Message + + + + :/icons/transaction_0:/icons/transaction_0 + + + false + + + + + + + Reset all verify message fields + + + Clear &All + + + + :/icons/remove:/icons/remove + + + false + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + 75 + true + + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + + + + + + + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+
+ + + + +
diff --git a/src/qt/forms/tradingdialog.ui b/src/qt/forms/tradingdialog.ui new file mode 100644 index 0000000..7483998 --- /dev/null +++ b/src/qt/forms/tradingdialog.ui @@ -0,0 +1,5595 @@ + + + tradingDialog + + + + 0 + 0 + 1031 + 594 + + + + Dialog + + + + + + + 0 + 0 + + + + + 849 + 40 + + + + + 16777215 + 220 + + + + QFrame::NoFrame + + + QFrame::Raised + + + 0 + + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.000000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + + + true + + + + 50 + false + + + + QTabWidget::North + + + QTabWidget::Rounded + + + 6 + + + + Trade + + + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 9 + 50 + false + + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + true + + + false + + + QAbstractItemView::NoSelection + + + + + + + + 75 + true + + + + Qt::LeftToRight + + + false + + + Units + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + + + 75 + true + + + + BTC Available: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + BTC + + + + + + + + + + + + 75 + true + + + + SONO Available: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + SONO + + + + + + + + + + 10 + + + + Max + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + SONO + + + + + + + + 10 + + + + Max + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + SONO + + + + + + + + 75 + true + + + + Bid + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 10 + + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + BTC + + + + + + + + 10 + + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + BTC + + + + + + + + + + 75 + true + + + + Total w/ 0.25% Fee + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 50 + false + + + + BTC + + + + + + + + + + + + 75 + true + + + + Total w/ 0.25% Fee + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 50 + false + + + + BTC + + + + + + + + + Buy SONO + + + + + + + Sell SONO + + + + + + + + 0 + 0 + + + + + 9 + 50 + false + + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + true + + + false + + + QAbstractItemView::NoSelection + + + + + + + 0.00000000 BTC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Asks: 0000 + + + + + + + 0.00000000 BTC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 8 + + + + Demand: 0.00000000 SONO + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Supply: 0.00000000 SONO + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Bids: 0000 + + + + + + + + Send + + + + + + + + + 10 + 75 + true + + + + Lowest price: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + BTC + + + + + + + + + + + + 10 + 75 + true + + + + Amount in SONO: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + SONO + + + + + + + + + + + + 10 + 75 + true + + + + Total w/ Fees : + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + BTC + + + + + + + + + Send + + + + + + + + 10 + 50 + false + + + + + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p><span style=" font-size:9pt; font-weight:600;">Warning:</span><span style=" font-size:9pt;"> This feature is in </span><span style=" font-size:9pt; font-weight:600;">ALPHA ! USE AT OWN RISK !</span></p></body></html> + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p align="center"><span style=" font-weight:600; text-decoration: underline;">Instructions:</span></p><p align="center">To use the cross sending feature you need to have </p><p align="center">SONO available to spend on Cryptopia. If you don't have any </p><p align="center">you can find your deposit address on the &quot;Balance&quot; tab.</p><p align="center">1. Enter the amount you want to receive in Bitcoin.</p><p align="center">2. Enter the Bitcoin address you are sending to.</p><p align="center">3. Check that the Total with fee's is correct.</p><p align="center">4. Press send and watch the magic happen.</p><p align="center"><span style=" font-weight:600; text-decoration: underline;">Notes.</span></p><p align="center"><span style=" font-size:7pt;">Total w/ fees: N/A means you dont have enough SONO to sell !</span></p><p align="center"><span style=" font-size:7pt;">All trades are done through Cryptopia using your own balance and API keys.</span></p><p align="center"><span style=" font-size:7pt;">Encrypt and backup your wallet when using this feature.</span></p><p align="center"><span style=" font-size:7pt;">If you don't have a password you Cryptopia account will be accessible 24/7</span></p><p align="center"><span style=" font-size:7pt;">Withdrawal fee of 0.002 and 0.25% taken by Cryptopia.</span></p></body></html> + + + + + + + + 10 + 75 + true + + + + Amount: + + + + + + + Qt::Horizontal + + + + 212 + 368 + + + + + + + + + 10 + 75 + true + + + + + + + + + 10 + 75 + true + + + + Address: + + + + + + + + + + 10 + 75 + true + + + + SONO Balance: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + SONO + + + + + + + + + + + + 10 + 75 + true + + + + BTC Balance: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + BTC + + + + + + + + + + 10 + + + + Max + + + + + + + + 10 + 75 + true + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + + 18 + 75 + true + + + + Cross-Send + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 915 + 73 + + + + + + CSUnitsInput + label232_4 + CSUnitsAddress + label_8 + CSUnitsBtn + label232_8 + label_27 + label232_13 + label232_15 + CS_Max_Amount + verticalSpacer_3 + horizontalSpacer_6 + CSPasteButton + + + + Market History + + + + + + + + + + Open Orders + + + + + + + + + + Trade history + + + + + + + + + + Balance + + + + + + + 10 + 75 + true + + + + SONO Balance: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + BTC Balance: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + + 478 + 488 + + + + + + + + + 10 + 75 + true + + + + SONO Available: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + BTC Available: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + SONO Pending: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + BTC Pending: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + + + + Generate SONO Deposit Address + + + + + + + + 10 + 75 + true + + + + Deposit Address: + + + + + + + + 300 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + + + 120 + 120 + 120 + + + + + + + 120 + 120 + 120 + + + + + + + + + 10 + 75 + true + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Copy to clipboard + + + + + + + :/icons/editcopy:/icons/editcopy + + + Alt+P + + + + + + + + 10 + 75 + true + + + + Withdraw SONO: + + + + + + + + 10 + 75 + true + + + + Amount: + + + + + + + + 9 + 75 + true + + + + + + + + + + + + 10 + + + + Max + + + + + + + + 10 + 75 + true + + + + Address: + + + + + + + + 9 + 75 + true + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + + 10 + + + + Withdraw + + + + + + + Qt::Vertical + + + + 428 + 262 + + + + + + label_31 + label_15 + label_12 + label_14 + label_13 + label_11 + BitcoinBalanceLabel + SONOBalanceLabel + SONOAvailableLabel_2 + SONOPendingLabel + BitcoinAvailableLabel + BitcoinPendingLabel + label_33 + GenDepositBTN + DepositAddressLabel + Withdraw_Max_Amount + label_34 + WithdrawUnitsInput + label_10 + label_26 + WithdrawAddress + WithdrawUnitsBtn + horizontalSpacer_4 + verticalSpacer + WithdrawPasteButton + DepositCopyButton + + + + Settings + + + + + + + 75 + true + + + + API Key + + + + + + + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + Qt::Horizontal + + + + 519 + 488 + + + + + + + + + 75 + true + + + + Secret Key + + + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + + 75 + true + + + + Password + + + + + + + QLineEdit::Password + + + + + + + + 115 + 0 + + + + Load API Keys + + + + + + + + 125 + 0 + + + + Update API Keys + + + + + + + + 115 + 0 + + + + Save API Keys + + + + + + + Qt::Vertical + + + + 358 + 247 + + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p>Loading keys:</p><p>1) Enter Password</p><p>2) Load API Keys</p><p>3) Start trading on Cryptopia</p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p>Saving keys:</p><p>1) Enter in API Keys found at <a href="https://Cryptopia.com/Account/ManageApiKey"><span style=" text-decoration: underline; color:#0000ff;">Cryptopia</span></a></p><p>2) Enter Password</p><p>3) Save API Keys</p><p>4) Start trading on Cryptopia</p></body></html> + + + + + label + ApiKeyInput + label_2 + SecretKeyInput + UpdateKeys + SaveKeys + LoadKeys + label232_16 + label232_17 + label_28 + PasswordInput + horizontalSpacer_3 + verticalSpacer_2 + KeyPasteButton + SecretPasteButton + + + + + + + + + + diff --git a/src/qt/forms/transactiondescdialog.ui b/src/qt/forms/transactiondescdialog.ui new file mode 100644 index 0000000..97287f5 --- /dev/null +++ b/src/qt/forms/transactiondescdialog.ui @@ -0,0 +1,74 @@ + + + TransactionDescDialog + + + + 0 + 0 + 620 + 250 + + + + Transaction details + + + + + + This pane shows a detailed description of the transaction + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + accepted() + TransactionDescDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + TransactionDescDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h new file mode 100644 index 0000000..0409777 --- /dev/null +++ b/src/qt/guiconstants.h @@ -0,0 +1,34 @@ +#ifndef GUICONSTANTS_H +#define GUICONSTANTS_H + +/* Milliseconds between model updates */ +static const int MODEL_UPDATE_DELAY = 250; + +/* AskPassphraseDialog -- Maximum passphrase length */ +static const int MAX_PASSPHRASE_SIZE = 1024; + +/* BitcoinGUI -- Size of icons in status bar */ +static const int STATUSBAR_ICONSIZE = 16; + +/* Invalid field background style */ +#define STYLE_INVALID "background:#FF8080" + +/* Transaction list -- unconfirmed transaction */ +#define COLOR_UNCONFIRMED QColor(128, 128, 128) +/* Transaction list -- negative amount */ +#define COLOR_NEGATIVE QColor(255, 0, 0) +/* Transaction list -- bare address (without label) */ +#define COLOR_BAREADDRESS QColor(140, 140, 140) + +/* Tooltips longer than this (in characters) are converted into rich text, + so that they can be word-wrapped. + */ +static const int TOOLTIP_WRAP_THRESHOLD = 80; + +/* Maximum allowed URI length */ +static const int MAX_URI_LENGTH = 255; + +/* QRCodeDialog -- size of exported QR Code image */ +#define EXPORT_IMAGE_SIZE 256 + +#endif // GUICONSTANTS_H diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp new file mode 100644 index 0000000..8b1c84f --- /dev/null +++ b/src/qt/guiutil.cpp @@ -0,0 +1,499 @@ +#include + +#include "guiutil.h" + +#include "bitcoinaddressvalidator.h" +#include "walletmodel.h" +#include "bitcoinunits.h" + +#include "util.h" +#include "init.h" + +#include +#include +#include +#include +#include +#include // For Qt::escape +#include +#include +#include +#include +#include + +#include +#include + +#ifdef WIN32 +#ifdef _WIN32_WINNT +#undef _WIN32_WINNT +#endif +#define _WIN32_WINNT 0x0501 +#ifdef _WIN32_IE +#undef _WIN32_IE +#endif +#define _WIN32_IE 0x0501 +#define WIN32_LEAN_AND_MEAN 1 +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include "shlwapi.h" +#include "shlobj.h" +#include "shellapi.h" +#endif + +namespace GUIUtil { + +QString dateTimeStr(const QDateTime &date) +{ + return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + date.toString("hh:mm"); +} + +QString dateTimeStr(qint64 nTime) +{ + return dateTimeStr(QDateTime::fromTime_t((qint32)nTime)); +} + +QFont bitcoinAddressFont() +{ + QFont font("Monospace"); +#if QT_VERSION >= 0x040800 + font.setStyleHint(QFont::Monospace); +#else + font.setStyleHint(QFont::TypeWriter); +#endif + return font; +} + +void setupAddressWidget(QLineEdit *widget, QWidget *parent) +{ + widget->setMaxLength(BitcoinAddressValidator::MaxAddressLength); + widget->setValidator(new BitcoinAddressValidator(parent)); + widget->setFont(bitcoinAddressFont()); +} + +void setupAmountWidget(QLineEdit *widget, QWidget *parent) +{ + QDoubleValidator *amountValidator = new QDoubleValidator(parent); + amountValidator->setDecimals(8); + amountValidator->setBottom(0.0); + widget->setValidator(amountValidator); + widget->setAlignment(Qt::AlignRight|Qt::AlignVCenter); +} + +bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) +{ + // NovaCoin: check prefix + if(uri.scheme() != QString("SONO")) + return false; + + SendCoinsRecipient rv; + rv.address = uri.path(); + rv.amount = 0; + QList > items = uri.queryItems(); + for (QList >::iterator i = items.begin(); i != items.end(); i++) + { + bool fShouldReturnFalse = false; + if (i->first.startsWith("req-")) + { + i->first.remove(0, 4); + fShouldReturnFalse = true; + } + + if (i->first == "label") + { + rv.label = i->second; + fShouldReturnFalse = false; + } + else if (i->first == "amount") + { + if(!i->second.isEmpty()) + { + if(!BitcoinUnits::parse(BitcoinUnits::BTC, i->second, &rv.amount)) + { + return false; + } + } + fShouldReturnFalse = false; + } + + if (fShouldReturnFalse) + return false; + } + if(out) + { + *out = rv; + } + return true; +} + +bool parseBitcoinURI(QString uri, SendCoinsRecipient *out) +{ + // Convert SONO:// to SONO: + // + // Cannot handle this later, because bitcoin:// will cause Qt to see the part after // as host, + // which will lower-case it (and thus invalidate the address). + if(uri.startsWith("SONO://")) + { + uri.replace(0, 12, "SONO:"); + } + QUrl uriInstance(uri); + return parseBitcoinURI(uriInstance, out); +} + +QString HtmlEscape(const QString& str, bool fMultiLine) +{ + QString escaped = Qt::escape(str); + if(fMultiLine) + { + escaped = escaped.replace("\n", "
\n"); + } + return escaped; +} + +QString HtmlEscape(const std::string& str, bool fMultiLine) +{ + return HtmlEscape(QString::fromStdString(str), fMultiLine); +} + +void copyEntryData(QAbstractItemView *view, int column, int role) +{ + if(!view || !view->selectionModel()) + return; + QModelIndexList selection = view->selectionModel()->selectedRows(column); + + if(!selection.isEmpty()) + { + // Copy first item + QApplication::clipboard()->setText(selection.at(0).data(role).toString()); + } +} + +QString getSaveFileName(QWidget *parent, const QString &caption, + const QString &dir, + const QString &filter, + QString *selectedSuffixOut) +{ + QString selectedFilter; + QString myDir; + if(dir.isEmpty()) // Default to user documents location + { + myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); + } + else + { + myDir = dir; + } + QString result = QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter); + + /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */ + QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]"); + QString selectedSuffix; + if(filter_re.exactMatch(selectedFilter)) + { + selectedSuffix = filter_re.cap(1); + } + + /* Add suffix if needed */ + QFileInfo info(result); + if(!result.isEmpty()) + { + if(info.suffix().isEmpty() && !selectedSuffix.isEmpty()) + { + /* No suffix specified, add selected suffix */ + if(!result.endsWith(".")) + result.append("."); + result.append(selectedSuffix); + } + } + + /* Return selected suffix if asked to */ + if(selectedSuffixOut) + { + *selectedSuffixOut = selectedSuffix; + } + return result; +} + +Qt::ConnectionType blockingGUIThreadConnection() +{ + if(QThread::currentThread() != QCoreApplication::instance()->thread()) + { + return Qt::BlockingQueuedConnection; + } + else + { + return Qt::DirectConnection; + } +} + +bool checkPoint(const QPoint &p, const QWidget *w) +{ + QWidget *atW = qApp->widgetAt(w->mapToGlobal(p)); + if (!atW) return false; + return atW->topLevelWidget() == w; +} + +bool isObscured(QWidget *w) +{ + return !(checkPoint(QPoint(0, 0), w) + && checkPoint(QPoint(w->width() - 1, 0), w) + && checkPoint(QPoint(0, w->height() - 1), w) + && checkPoint(QPoint(w->width() - 1, w->height() - 1), w) + && checkPoint(QPoint(w->width() / 2, w->height() / 2), w)); +} + +void openDebugLogfile() +{ + boost::filesystem::path pathDebug = GetDataDir() / "debug.log"; + + /* Open debug.log with the associated application */ + if (boost::filesystem::exists(pathDebug)) + QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(pathDebug.string()))); +} + +ToolTipToRichTextFilter::ToolTipToRichTextFilter(int size_threshold, QObject *parent) : + QObject(parent), size_threshold(size_threshold) +{ + +} + +bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt) +{ + if(evt->type() == QEvent::ToolTipChange) + { + QWidget *widget = static_cast(obj); + QString tooltip = widget->toolTip(); + if(tooltip.size() > size_threshold && !tooltip.startsWith("") && !Qt::mightBeRichText(tooltip)) + { + // Prefix to make sure Qt detects this as rich text + // Escape the current message as HTML and replace \n by
+ tooltip = "" + HtmlEscape(tooltip, true) + ""; + widget->setToolTip(tooltip); + return true; + } + } + return QObject::eventFilter(obj, evt); +} + +#ifdef WIN32 +boost::filesystem::path static StartupShortcutPath() +{ + return GetSpecialFolderPath(CSIDL_STARTUP) / "SONO.lnk"; +} + +bool GetStartOnSystemStartup() +{ + // check for Bitcoin.lnk + return boost::filesystem::exists(StartupShortcutPath()); +} + +bool SetStartOnSystemStartup(bool fAutoStart) +{ + // If the shortcut exists already, remove it for updating + boost::filesystem::remove(StartupShortcutPath()); + + if (fAutoStart) + { + CoInitialize(NULL); + + // Get a pointer to the IShellLink interface. + IShellLink* psl = NULL; + HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, + CLSCTX_INPROC_SERVER, IID_IShellLink, + reinterpret_cast(&psl)); + + if (SUCCEEDED(hres)) + { + // Get the current executable path + TCHAR pszExePath[MAX_PATH]; + GetModuleFileName(NULL, pszExePath, sizeof(pszExePath)); + + TCHAR pszArgs[5] = TEXT("-min"); + + // Set the path to the shortcut target + psl->SetPath(pszExePath); + PathRemoveFileSpec(pszExePath); + psl->SetWorkingDirectory(pszExePath); + psl->SetShowCmd(SW_SHOWMINNOACTIVE); + psl->SetArguments(pszArgs); + + // Query IShellLink for the IPersistFile interface for + // saving the shortcut in persistent storage. + IPersistFile* ppf = NULL; + hres = psl->QueryInterface(IID_IPersistFile, + reinterpret_cast(&ppf)); + if (SUCCEEDED(hres)) + { + WCHAR pwsz[MAX_PATH]; + // Ensure that the string is ANSI. + MultiByteToWideChar(CP_ACP, 0, StartupShortcutPath().string().c_str(), -1, pwsz, MAX_PATH); + // Save the link by calling IPersistFile::Save. + hres = ppf->Save(pwsz, TRUE); + ppf->Release(); + psl->Release(); + CoUninitialize(); + return true; + } + psl->Release(); + } + CoUninitialize(); + return false; + } + return true; +} + +#elif defined(Q_OS_LINUX) + +// Follow the Desktop Application Autostart Spec: +// http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html + +boost::filesystem::path static GetAutostartDir() +{ + namespace fs = boost::filesystem; + + char* pszConfigHome = getenv("SONO_CONFIG_HOME"); + if (pszConfigHome) return fs::path(pszConfigHome) / "autostart"; + char* pszHome = getenv("HOME"); + if (pszHome) return fs::path(pszHome) / ".config" / "autostart"; + return fs::path(); +} + +boost::filesystem::path static GetAutostartFilePath() +{ + return GetAutostartDir() / "SONO.desktop"; +} + +bool GetStartOnSystemStartup() +{ + boost::filesystem::ifstream optionFile(GetAutostartFilePath()); + if (!optionFile.good()) + return false; + // Scan through file for "Hidden=true": + std::string line; + while (!optionFile.eof()) + { + getline(optionFile, line); + if (line.find("Hidden") != std::string::npos && + line.find("true") != std::string::npos) + return false; + } + optionFile.close(); + + return true; +} + +bool SetStartOnSystemStartup(bool fAutoStart) +{ + if (!fAutoStart) + boost::filesystem::remove(GetAutostartFilePath()); + else + { + char pszExePath[MAX_PATH+1]; + memset(pszExePath, 0, sizeof(pszExePath)); + if (readlink("/proc/self/exe", pszExePath, sizeof(pszExePath)-1) == -1) + return false; + + boost::filesystem::create_directories(GetAutostartDir()); + + boost::filesystem::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out|std::ios_base::trunc); + if (!optionFile.good()) + return false; + // Write a bitcoin.desktop file to the autostart directory: + optionFile << "[Desktop Entry]\n"; + optionFile << "Type=Application\n"; + optionFile << "Name=SONO\n"; + optionFile << "Exec=" << pszExePath << " -min\n"; + optionFile << "Terminal=false\n"; + optionFile << "Hidden=false\n"; + optionFile.close(); + } + return true; +} +#else + +// TODO: OSX startup stuff; see: +// https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Articles/CustomLogin.html + +bool GetStartOnSystemStartup() { return false; } +bool SetStartOnSystemStartup(bool fAutoStart) { return false; } + +#endif + +HelpMessageBox::HelpMessageBox(QWidget *parent) : + QMessageBox(parent) +{ + header = tr("SONO-Qt") + " " + tr("version") + " " + + QString::fromStdString(FormatFullVersion()) + "\n\n" + + tr("Usage:") + "\n" + + " SONO-qt [" + tr("command-line options") + "] " + "\n"; + + coreOptions = QString::fromStdString(HelpMessage()); + + uiOptions = tr("UI options") + ":\n" + + " -lang= " + tr("Set language, for example \"de_DE\" (default: system locale)") + "\n" + + " -min " + tr("Start minimized") + "\n" + + " -splash " + tr("Show splash screen on startup (default: 1)") + "\n"; + + setWindowTitle(tr("SONO-Qt")); + setTextFormat(Qt::PlainText); + // setMinimumWidth is ignored for QMessageBox so put in non-breaking spaces to make it wider. + setText(header + QString(QChar(0x2003)).repeated(50)); + setDetailedText(coreOptions + "\n" + uiOptions); +} + +void HelpMessageBox::printToConsole() +{ + // On other operating systems, the expected action is to print the message to the console. + QString strUsage = header + "\n" + coreOptions + "\n" + uiOptions; + fprintf(stdout, "%s", strUsage.toStdString().c_str()); +} + +void HelpMessageBox::showOrPrint() +{ +#if defined(WIN32) + // On Windows, show a message box, as there is no stderr/stdout in windowed applications + exec(); +#else + // On other operating systems, print help text to console + printToConsole(); +#endif +} + +void SetBlackThemeQSS(QApplication& app) +{ + app.setStyleSheet("QWidget { background: rgb(41,44,48); }" + "QFrame { border: none; }" + "QComboBox { color: rgb(255,255,255); }" + "QComboBox QAbstractItemView::item { color: rgb(255,255,255); }" + "QPushButton { background: rgb(224,55,63); color: rgb(21,21,21); }" + "QDoubleSpinBox { background: rgb(63,67,72); color: rgb(255,255,255); border-color: rgb(194,194,194); }" + "QLineEdit { background: rgb(63,67,72); color: rgb(255,255,255); border-color: rgb(194,194,194); }" + "QTextEdit { background: rgb(63,67,72); color: rgb(255,255,255); }" + "QPlainTextEdit { background: rgb(63,67,72); color: rgb(255,255,255); }" + "QMenuBar { background: rgb(41,44,48); color: rgb(110,116,126); }" + "QMenu { background: rgb(30,32,36); color: rgb(222,222,222); }" + "QMenu::item:selected { background-color: rgb(48,140,198); }" + "QLabel { color: rgb(120,127,139); }" + "QScrollBar { color: rgb(255,255,255); }" + "QCheckBox { color: rgb(120,127,139); }" + "QRadioButton { color: rgb(120,127,139); }" + "QTabBar::tab { color: rgb(120,127,139); border: 1px solid rgb(78,79,83); border-bottom: none; padding: 5px; }" + "QTabBar::tab:selected { background: rgb(41,44,48); }" + "QTabBar::tab:!selected { background: rgb(24,26,30); margin-top: 2px; }" + "QTabWidget::pane { border: 1px solid rgb(78,79,83); }" + "QToolButton { background: rgb(30,32,36); color: rgb(116,122,134); border: none; border-left-color: rgb(30,32,36); border-left-style: solid; border-left-width: 6px; margin-top: 8px; margin-bottom: 8px; }" + "QToolButton:checked { color: rgb(255,255,255); border: none; border-left-color: rgb(224,55,63); border-left-style: solid; border-left-width: 6px; }" + "QProgressBar { color: rgb(149,148,148); border-color: rgb(255,255,255); border-width: 3px; border-style: solid; }" + "QProgressBar::chunk { background: rgb(255,255,255); }" + "QTreeView::item { background: rgb(41,44,48); color: rgb(212,213,213); }" + "QTreeView::item:selected { background-color: rgb(48,140,198); }" + "QTableView { background: rgb(66,71,78); color: rgb(212,213,213); gridline-color: rgb(157,160,165); }" + "QHeaderView::section { background: rgb(29,34,39); color: rgb(255,255,255); }" + "QToolBar { background: rgb(30,32,36); border: none; }"); +} + +} // namespace GUIUtil + +//QPushButton { background: rgb(224,55,63); //red color +//QToolButton:checked: rgb(224,55,63); //red color diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h new file mode 100644 index 0000000..1e71e6c --- /dev/null +++ b/src/qt/guiutil.h @@ -0,0 +1,123 @@ +#ifndef GUIUTIL_H +#define GUIUTIL_H + +#include +#include +#include + +class SendCoinsRecipient; + +QT_BEGIN_NAMESPACE +class QFont; +class QLineEdit; +class QWidget; +class QDateTime; +class QUrl; +class QAbstractItemView; +QT_END_NAMESPACE + +/** Utility functions used by the Bitcoin Qt UI. + */ +namespace GUIUtil +{ + // Create human-readable string from date + QString dateTimeStr(const QDateTime &datetime); + QString dateTimeStr(qint64 nTime); + + // Render Bitcoin addresses in monospace font + QFont bitcoinAddressFont(); + + // Set up widgets for address and amounts + void setupAddressWidget(QLineEdit *widget, QWidget *parent); + void setupAmountWidget(QLineEdit *widget, QWidget *parent); + + // Parse "SONO:" URI into recipient object, return true on successful parsing + // See Bitcoin URI definition discussion here: https://bitcointalk.org/index.php?topic=33490.0 + bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out); + bool parseBitcoinURI(QString uri, SendCoinsRecipient *out); + + // HTML escaping for rich text controls + QString HtmlEscape(const QString& str, bool fMultiLine=false); + QString HtmlEscape(const std::string& str, bool fMultiLine=false); + + /** Copy a field of the currently selected entry of a view to the clipboard. Does nothing if nothing + is selected. + @param[in] column Data column to extract from the model + @param[in] role Data role to extract from the model + @see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress + */ + void copyEntryData(QAbstractItemView *view, int column, int role=Qt::EditRole); + + /** Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix + when no suffix is provided by the user. + + @param[in] parent Parent window (or 0) + @param[in] caption Window caption (or empty, for default) + @param[in] dir Starting directory (or empty, to default to documents directory) + @param[in] filter Filter specification such as "Comma Separated Files (*.csv)" + @param[out] selectedSuffixOut Pointer to return the suffix (file type) that was selected (or 0). + Can be useful when choosing the save file format based on suffix. + */ + QString getSaveFileName(QWidget *parent=0, const QString &caption=QString(), + const QString &dir=QString(), const QString &filter=QString(), + QString *selectedSuffixOut=0); + + /** Get connection type to call object slot in GUI thread with invokeMethod. The call will be blocking. + + @returns If called from the GUI thread, return a Qt::DirectConnection. + If called from another thread, return a Qt::BlockingQueuedConnection. + */ + Qt::ConnectionType blockingGUIThreadConnection(); + + // Determine whether a widget is hidden behind other windows + bool isObscured(QWidget *w); + + // Open debug.log + void openDebugLogfile(); + + /** Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text + representation if needed. This assures that Qt can word-wrap long tooltip messages. + Tooltips longer than the provided size threshold (in characters) are wrapped. + */ + class ToolTipToRichTextFilter : public QObject + { + Q_OBJECT + + public: + explicit ToolTipToRichTextFilter(int size_threshold, QObject *parent = 0); + + protected: + bool eventFilter(QObject *obj, QEvent *evt); + + private: + int size_threshold; + }; + + bool GetStartOnSystemStartup(); + bool SetStartOnSystemStartup(bool fAutoStart); + + /** Help message for Bitcoin-Qt, shown with --help. */ + class HelpMessageBox : public QMessageBox + { + Q_OBJECT + + public: + HelpMessageBox(QWidget *parent = 0); + + /** Show message box or print help message to standard output, based on operating system. */ + void showOrPrint(); + + /** Print help message to console */ + void printToConsole(); + + private: + QString header; + QString coreOptions; + QString uiOptions; + }; + + void SetBlackThemeQSS(QApplication& app); + +} // namespace GUIUtil + +#endif // GUIUTIL_H diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts new file mode 100644 index 0000000..30ca8d9 --- /dev/null +++ b/src/qt/locale/bitcoin_en.ts @@ -0,0 +1,3350 @@ + + + + + AboutDialog + + + About Bhcoin + About Bhcoin + + + + <b>Bhcoin</b> version + <b>Bhcoin</b> version + + + + Copyright © 2009-2014 The Bitcoin developers +Copyright © 2012-2014 The NovaCoin developers +Copyright © 2014 The Bhcoin developers + + + + + +This is experimental software. + +Distributed under the MIT/X11 software license, see the accompanying file COPYING or <a href="http://www.opensource.org/licenses/mit-license.php">http://www.opensource.org/licenses/mit-license.php</a>. + +This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="https://www.openssl.org/">https://www.openssl.org/</a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com">eay@cryptsoft.com</a>) and UPnP software written by Thomas Bernard. + + + + + AddressBookPage + + + Address Book + Address Book + + + + Double-click to edit address or label + Double-click to edit address or label + + + + Create a new address + Create a new address + + + + Copy the currently selected address to the system clipboard + Copy the currently selected address to the system clipboard + + + + &New Address + &New Address + + + + These are your Bhcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. + These are your Bhcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. + + + + &Copy Address + &Copy Address + + + + Show &QR Code + Show &QR Code + + + + Sign a message to prove you own a Bhcoin address + Sign a message to prove you own a Bhcoin address + + + + Sign &Message + + + + + Delete the currently selected address from the list + + + + + Verify a message to ensure it was signed with a specified Bhcoin address + Verify a message to ensure it was signed with a specified Bhcoin address + + + + &Verify Message + &Verify Message + + + + &Delete + &Delete + + + + Copy &Label + Copy &Label + + + + &Edit + &Edit + + + + Export Address Book Data + Export Address Book Data + + + + Comma separated file (*.csv) + Comma separated file (*.csv) + + + + Error exporting + Error exporting + + + + Could not write to file %1. + Could not write to file %1. + + + + AddressTableModel + + + Label + Label + + + + Address + Address + + + + (no label) + (no label) + + + + AskPassphraseDialog + + + Passphrase Dialog + Passphrase Dialog + + + + Enter passphrase + Enter passphrase + + + + New passphrase + New passphrase + + + + Repeat new passphrase + Repeat new passphrase + + + + Serves to disable the trivial sendmoney when OS account compromised. Provides no real security. + + + + + For staking only + + + + + Encrypt wallet + Encrypt wallet + + + + This operation needs your wallet passphrase to unlock the wallet. + This operation needs your wallet passphrase to unlock the wallet. + + + + Unlock wallet + Unlock wallet + + + + This operation needs your wallet passphrase to decrypt the wallet. + This operation needs your wallet passphrase to decrypt the wallet. + + + + Decrypt wallet + Decrypt wallet + + + + Change passphrase + Change passphrase + + + + Enter the old and new passphrase to the wallet. + Enter the old and new passphrase to the wallet. + + + + Confirm wallet encryption + Confirm wallet encryption + + + + Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR COINS</b>! + Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR COINS</b>! + + + + Are you sure you wish to encrypt your wallet? + Are you sure you wish to encrypt your wallet? + + + + IMPORTANT: Any previous backups you have made of your wallet file should be replaced with the newly generated, encrypted wallet file. For security reasons, previous backups of the unencrypted wallet file will become useless as soon as you start using the new, encrypted wallet. + + + + + + Warning: The Caps Lock key is on! + Warning: The Caps Lock key is on! + + + + + Wallet encrypted + Wallet encrypted + + + + Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>. + + + + + Bhcoin will close now to finish the encryption process. Remember that encrypting your wallet cannot fully protect your coins from being stolen by malware infecting your computer. + Bhcoin will close now to finish the encryption process. Remember that encrypting your wallet cannot fully protect your coins from being stolen by malware infecting your computer. + + + + + + + Wallet encryption failed + Wallet encryption failed + + + + Wallet encryption failed due to an internal error. Your wallet was not encrypted. + Wallet encryption failed due to an internal error. Your wallet was not encrypted. + + + + + The supplied passphrases do not match. + The supplied passphrases do not match. + + + + Wallet unlock failed + Wallet unlock failed + + + + + + The passphrase entered for the wallet decryption was incorrect. + The passphrase entered for the wallet decryption was incorrect. + + + + Wallet decryption failed + Wallet decryption failed + + + + Wallet passphrase was successfully changed. + Wallet passphrase was successfully changed. + + + + BitcoinGUI + + + Sign &message... + Sign &message... + + + + Show general overview of wallet + Show general overview of wallet + + + + &Transactions + &Transactions + + + + Browse transaction history + Browse transaction history + + + + &Address Book + &Address Book + + + + Edit the list of stored addresses and labels + Edit the list of stored addresses and labels + + + + Show the list of addresses for receiving payments + Show the list of addresses for receiving payments + + + + E&xit + E&xit + + + + Quit application + Quit application + + + + Show information about Bhcoin + Show information about Bhcoin + + + + About &Qt + About &Qt + + + + Show information about Qt + Show information about Qt + + + + &Options... + &Options... + + + + &Encrypt Wallet... + &Encrypt Wallet... + + + + &Backup Wallet... + &Backup Wallet... + + + + &Change Passphrase... + &Change Passphrase... + + + + &Export... + &Export... + + + + Send coins to a Bhcoin address + Send coins to a Bhcoin address + + + + Modify configuration options for Bhcoin + Modify configuration options for Bhcoin + + + + Export the data in the current tab to a file + Export the data in the current tab to a file + + + + Encrypt or decrypt wallet + Encrypt or decrypt wallet + + + + Backup wallet to another location + Backup wallet to another location + + + + Change the passphrase used for wallet encryption + Change the passphrase used for wallet encryption + + + + &Debug window + &Debug window + + + + Open debugging and diagnostic console + Open debugging and diagnostic console + + + + &Verify message... + &Verify message... + + + + + Bhcoin + Bhcoin + + + + Wallet + Wallet + + + + &About Bhcoin + &About Bhcoin + + + + &Show / Hide + &Show / Hide + + + + Unlock wallet + Unlock wallet + + + + &Lock Wallet + + + + + Lock wallet + + + + + &File + &File + + + + &Settings + &Settings + + + + &Help + &Help + + + + Tabs toolbar + Tabs toolbar + + + + + [testnet] + [testnet] + + + + + Bhcoin client + Bhcoin client + + + + %n active connection(s) to Bhcoin network + + %n active connection to Bhcoin network + %n active connections to Bhcoin network + + + + + Staking.<br>Your weight is %1<br>Network weight is %2<br>Expected time to earn reward is %3 + + + + + Not staking because wallet is locked + + + + + Not staking because wallet is offline + + + + + Not staking because wallet is syncing + + + + + Not staking because you don't have mature coins + + + + + &Dashboard + + + + + &Receive + + + + + &Send + + + + + &Unlock Wallet... + + + + + Up to date + Up to date + + + + Catching up... + Catching up... + + + + Confirm transaction fee + Confirm transaction fee + + + + Sent transaction + Sent transaction + + + + Incoming transaction + Incoming transaction + + + + Date: %1 +Amount: %2 +Type: %3 +Address: %4 + + Date: %1 +Amount: %2 +Type: %3 +Address: %4 + + + + + + URI handling + URI handling + + + + + URI can not be parsed! This can be caused by an invalid Bhcoin address or malformed URI parameters. + URI can not be parsed! This can be caused by an invalid Bhcoin address or malformed URI parameters. + + + + Wallet is <b>not encrypted</b> + + + + + Wallet is <b>encrypted</b> and currently <b>unlocked</b> + Wallet is <b>encrypted</b> and currently <b>unlocked</b> + + + + Wallet is <b>encrypted</b> and currently <b>locked</b> + Wallet is <b>encrypted</b> and currently <b>locked</b> + + + + Backup Wallet + Backup Wallet + + + + Wallet Data (*.dat) + Wallet Data (*.dat) + + + + Backup Failed + Backup Failed + + + + There was an error trying to save the wallet data to the new location. + There was an error trying to save the wallet data to the new location. + + + + %n second(s) + + %n second + %n seconds + + + + + %n minute(s) + + %n minute + %n minutes + + + + + + %n hour(s) + + %n hour + %n hours + + + + + Processed %1 blocks of transaction history. + + + + + + %n day(s) + + %n day + %n days + + + + + + %n week(s) + + %n week + %n weeks + + + + + %1 and %2 + + + + + %n year(s) + + %n year + %n years + + + + + %1 behind + + + + + Last received block was generated %1 ago. + + + + + Transactions after this will not yet be visible. + + + + + Error + Error + + + + Warning + Warning + + + + Information + + + + + This transaction is over the size limit. You can still send it for a fee of %1, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee? + + + + + Not staking + + + + + A fatal error occurred. Bhcoin can no longer continue safely and will quit. + A fatal error occurred. Bhcoin can no longer continue safely and will quit. + + + + ClientModel + + + Network Alert + Network Alert + + + + CoinControlDialog + + + Coin Control + + + + + Quantity: + + + + + Bytes: + + + + + Amount: + Amount: + + + + Priority: + + + + + Fee: + + + + + Low Output: + + + + + no + + + + + After Fee: + + + + + Change: + + + + + (un)select all + + + + + Tree mode + + + + + List mode + + + + + Amount + Amount + + + + Label + Label + + + + Address + Address + + + + Date + Date + + + + Confirmations + + + + + Confirmed + Confirmed + + + + Priority + + + + + Copy address + Copy address + + + + Copy label + Copy label + + + + + Copy amount + Copy amount + + + + Copy transaction ID + Copy transaction ID + + + + Copy quantity + + + + + Copy fee + + + + + Copy after fee + + + + + Copy bytes + + + + + Copy priority + + + + + Copy low output + + + + + Copy change + + + + + highest + + + + + high + + + + + medium-high + + + + + medium + + + + + low-medium + + + + + low + + + + + lowest + + + + + DUST + + + + + yes + + + + + This label turns red, if the transaction size is bigger than 10000 bytes. + + This means a fee of at least %1 per kb is required. + + Can vary +/- 1 Byte per input. + + + + + Transactions with higher priority get more likely into a block. + +This label turns red, if the priority is smaller than "medium". + + This means a fee of at least %1 per kb is required. + + + + + This label turns red, if any recipient receives an amount smaller than %1. + + This means a fee of at least %2 is required. + + Amounts below 0.546 times the minimum relay fee are shown as DUST. + + + + + This label turns red, if the change is smaller than %1. + + This means a fee of at least %2 is required. + + + + + + (no label) + (no label) + + + + change from %1 (%2) + + + + + (change) + + + + + EditAddressDialog + + + Edit Address + Edit Address + + + + &Label + &Label + + + + The label associated with this address book entry + The label associated with this address book entry + + + + &Address + &Address + + + + The address associated with this address book entry. This can only be modified for sending addresses. + The address associated with this address book entry. This can only be modified for sending addresses. + + + + New receiving address + New receiving address + + + + New sending address + New sending address + + + + Edit receiving address + Edit receiving address + + + + Edit sending address + Edit sending address + + + + The entered address "%1" is already in the address book. + The entered address "%1" is already in the address book. + + + + The entered address "%1" is not a valid Bhcoin address. + The entered address "%1" is not a valid Bhcoin address. + + + + Could not unlock wallet. + Could not unlock wallet. + + + + New key generation failed. + New key generation failed. + + + + GUIUtil::HelpMessageBox + + + + Bhcoin-Qt + Bhcoin-Qt + + + + version + version + + + + Usage: + Usage: + + + + command-line options + command-line options + + + + UI options + UI options + + + + Set language, for example "de_DE" (default: system locale) + Set language, for example "de_DE" (default: system locale) + + + + Start minimized + Start minimized + + + + Show splash screen on startup (default: 1) + Show splash screen on startup (default: 1) + + + + OptionsDialog + + + Options + Options + + + + &Main + &Main + + + + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended. + + + + Pay transaction &fee + Pay transaction &fee + + + + Reserved amount does not participate in staking and is therefore spendable at any time. + + + + + Reserve + + + + + Automatically start Bhcoin after logging in to the system. + Automatically start Bhcoin after logging in to the system. + + + + &Start Bhcoin on system login + &Start Bhcoin on system login + + + + &Network + &Network + + + + Automatically open the Bhcoin client port on the router. This only works when your router supports UPnP and it is enabled. + Automatically open the Bhcoin client port on the router. This only works when your router supports UPnP and it is enabled. + + + + Map port using &UPnP + Map port using &UPnP + + + + Proxy &IP: + Proxy &IP: + + + + IP address of the proxy (e.g. 127.0.0.1) + IP address of the proxy (e.g. 127.0.0.1) + + + + &Port: + &Port: + + + + Port of the proxy (e.g. 9050) + Port of the proxy (e.g. 9050) + + + + Connect to the Bhcoin network through a SOCKS5 proxy (e.g. when connecting through Tor). + + + + + &Connect through SOCKS5 proxy: + + + + + &Window + &Window + + + + Show only a tray icon after minimizing the window. + Show only a tray icon after minimizing the window. + + + + &Minimize to the tray instead of the taskbar + &Minimize to the tray instead of the taskbar + + + + Minimize instead of exit the application when the window is closed. When this option is enabled, the application will be closed only after selecting Quit in the menu. + Minimize instead of exit the application when the window is closed. When this option is enabled, the application will be closed only after selecting Quit in the menu. + + + + M&inimize on close + M&inimize on close + + + + &Display + &Display + + + + User Interface &language: + User Interface &language: + + + + The user interface language can be set here. This setting will take effect after restarting Bhcoin. + The user interface language can be set here. This setting will take effect after restarting Bhcoin. + + + + &Unit to show amounts in: + &Unit to show amounts in: + + + + Choose the default subdivision unit to show in the interface and when sending coins. + Choose the default subdivision unit to show in the interface and when sending coins. + + + + Whether to show coin control features or not. + + + + + Display coin &control features (experts only!) + + + + + Whether to select the coin outputs randomly or with minimal coin age. + + + + + Minimize weight consumption (experimental) + + + + + Use black visual theme (requires restart) + + + + + &OK + &OK + + + + &Cancel + &Cancel + + + + &Apply + &Apply + + + + default + default + + + + + Warning + Warning + + + + + This setting will take effect after restarting Bhcoin. + This setting will take effect after restarting Bhcoin. + + + + The supplied proxy address is invalid. + The supplied proxy address is invalid. + + + + OverviewPage + + + Form + Form + + + + + The displayed information may be out of date. Your wallet automatically synchronizes with the Bhcoin network after a connection is established, but this process has not completed yet. + The displayed information may be out of date. Your wallet automatically synchronizes with the Bhcoin network after a connection is established, but this process has not completed yet. + + + + Stake: + Stake: + + + + Unconfirmed: + Unconfirmed: + + + + Wallet + Wallet + + + + Spendable: + + + + + Your current spendable balance + + + + + Immature: + Immature: + + + + Mined balance that has not yet matured + Mined balance that has not yet matured + + + + Total: + + + + + Your current total balance + + + + + <b>Recent transactions</b> + <b>Recent transactions</b> + + + + Total of transactions that have yet to be confirmed, and do not yet count toward the current balance + Total of transactions that have yet to be confirmed, and do not yet count toward the current balance + + + + Total of coins that was staked, and do not yet count toward the current balance + Total of coins that was staked, and do not yet count toward the current balance + + + + + out of sync + out of sync + + + + PaymentServer + + + Cannot start bhcoin: click-to-pay handler + + + + + QRCodeDialog + + + QR Code Dialog + QR Code Dialog + + + + Request Payment + Request Payment + + + + Amount: + Amount: + + + + Label: + Label: + + + + Message: + Message: + + + + &Save As... + &Save As... + + + + Error encoding URI into QR Code. + Error encoding URI into QR Code. + + + + The entered amount is invalid, please check. + The entered amount is invalid, please check. + + + + Resulting URI too long, try to reduce the text for label / message. + Resulting URI too long, try to reduce the text for label / message. + + + + Save QR Code + Save QR Code + + + + PNG Images (*.png) + PNG Images (*.png) + + + + RPCConsole + + + Client name + Client name + + + + + + + + + + + N/A + N/A + + + + Client version + Client version + + + + &Information + &Information + + + + Using OpenSSL version + Using OpenSSL version + + + + Startup time + Startup time + + + + Network + Network + + + + Number of connections + Number of connections + + + + On testnet + On testnet + + + + Block chain + Block chain + + + + Current number of blocks + Current number of blocks + + + + &Network Traffic + + + + + &Clear + + + + + Totals + + + + + In: + + + + + Out: + + + + + Last block time + Last block time + + + + &Open + &Open + + + + Command-line options + Command-line options + + + + Show the Bhcoin-Qt help message to get a list with possible Bhcoin command-line options. + Show the Bhcoin-Qt help message to get a list with possible Bhcoin command-line options. + + + + &Show + &Show + + + + &Console + &Console + + + + Build date + Build date + + + + Bhcoin - Debug window + Bhcoin - Debug window + + + + Bhcoin Core + Bhcoin Core + + + + Debug log file + Debug log file + + + + Open the Bhcoin debug log file from the current data directory. This can take a few seconds for large log files. + Open the Bhcoin debug log file from the current data directory. This can take a few seconds for large log files. + + + + Clear console + Clear console + + + + Welcome to the Bhcoin RPC console. + Welcome to the Bhcoin RPC console. + + + + Use up and down arrows to navigate history, and <b>Ctrl-L</b> to clear screen. + Use up and down arrows to navigate history, and <b>Ctrl-L</b> to clear screen. + + + + Type <b>help</b> for an overview of available commands. + Type <b>help</b> for an overview of available commands. + + + + %1 B + + + + + %1 KB + + + + + %1 MB + + + + + %1 GB + + + + + %1 m + + + + + %1 h + + + + + %1 h %2 m + + + + + SendCoinsDialog + + + + + + + + + + Send Coins + Send Coins + + + + Coin Control Features + + + + + Inputs... + + + + + automatically selected + + + + + Insufficient funds! + + + + + Quantity: + + + + + + 0 + + + + + Bytes: + + + + + Amount: + Amount: + + + + Priority: + + + + + medium + + + + + Fee: + + + + + Low Output: + + + + + no + + + + + After Fee: + + + + + Change + + + + + custom change address + + + + + Send to multiple recipients at once + Send to multiple recipients at once + + + + Add &Recipient + + + + + Remove all transaction fields + Remove all transaction fields + + + + Clear &All + Clear &All + + + + Balance: + Balance: + + + + Confirm the send action + Confirm the send action + + + + S&end + + + + + Enter a Bhcoin address (e.g. SjBj1QvJvsAkU5EBKggdZ8gWc4oK2F5AMY) + Enter a Bhcoin address (e.g. SjBj1QvJvsAkU5EBKggdZ8gWc4oK2F5AMY) + + + + Copy quantity + + + + + Copy amount + Copy amount + + + + Copy fee + + + + + Copy after fee + + + + + Copy bytes + + + + + Copy priority + + + + + Copy low output + + + + + Copy change + + + + + <b>%1</b> to %2 (%3) + <b>%1</b> to %2 (%3) + + + + Confirm send coins + Confirm send coins + + + + Are you sure you want to send %1? + Are you sure you want to send %1? + + + + and + and + + + + The recipient address is not valid, please recheck. + The recipient address is not valid, please recheck. + + + + The amount to pay must be larger than 0. + The amount to pay must be larger than 0. + + + + The amount exceeds your balance. + The amount exceeds your balance. + + + + The total exceeds your balance when the %1 transaction fee is included. + The total exceeds your balance when the %1 transaction fee is included. + + + + Duplicate address found, can only send to each address once per send operation. + Duplicate address found, can only send to each address once per send operation. + + + + Error: Transaction creation failed! + + + + + Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here. + Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here. + + + + WARNING: Invalid Bhcoin address + + + + + (no label) + (no label) + + + + WARNING: unknown change address + + + + + SendCoinsEntry + + + Form + Form + + + + A&mount: + A&mount: + + + + Pay &To: + Pay &To: + + + + The address to send the payment to (e.g. SjBj1QvJvsAkU5EBKggdZ8gWc4oK2F5AMY) + + + + + + Enter a label for this address to add it to your address book + Enter a label for this address to add it to your address book + + + + &Label: + &Label: + + + + Choose address from address book + Choose address from address book + + + + Alt+A + Alt+A + + + + Paste address from clipboard + Paste address from clipboard + + + + Alt+P + Alt+P + + + + Remove this recipient + Remove this recipient + + + + Enter a Bhcoin address (e.g. SjBj1QvJvsAkU5EBKggdZ8gWc4oK2F5AMY) + Enter a Bhcoin address (e.g. SjBj1QvJvsAkU5EBKggdZ8gWc4oK2F5AMY) + + + + SignVerifyMessageDialog + + + Signatures - Sign / Verify a Message + Signatures - Sign / Verify a Message + + + + + &Sign Message + &Sign Message + + + + You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to. + You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to. + + + + The address to sign the message with (e.g. SjBj1QvJvsAkU5EBKggdZ8gWc4oK2F5AMY) + The address to sign the message with (e.g. SjBj1QvJvsAkU5EBKggdZ8gWc4oK2F5AMY) + + + + + Choose an address from the address book + Choose an address from the address book + + + + + Alt+A + Alt+A + + + + Paste address from clipboard + Paste address from clipboard + + + + Alt+P + Alt+P + + + + Enter the message you want to sign here + Enter the message you want to sign here + + + + Copy the current signature to the system clipboard + Copy the current signature to the system clipboard + + + + Sign the message to prove you own this Bhcoin address + Sign the message to prove you own this Bhcoin address + + + + Reset all sign message fields + Reset all sign message fields + + + + + Clear &All + Clear &All + + + + + &Verify Message + &Verify Message + + + + Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack. + Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack. + + + + The address the message was signed with (e.g. SjBj1QvJvsAkU5EBKggdZ8gWc4oK2F5AMY) + The address the message was signed with (e.g. SjBj1QvJvsAkU5EBKggdZ8gWc4oK2F5AMY) + + + + Verify the message to ensure it was signed with the specified Bhcoin address + Verify the message to ensure it was signed with the specified Bhcoin address + + + + Reset all verify message fields + Reset all verify message fields + + + + + Enter a Bhcoin address (e.g. SjBj1QvJvsAkU5EBKggdZ8gWc4oK2F5AMY) + Enter a Bhcoin address (e.g. SjBj1QvJvsAkU5EBKggdZ8gWc4oK2F5AMY) + + + + Click "Sign Message" to generate signature + Click "Sign Message" to generate signature + + + + Enter Bhcoin signature + Enter Bhcoin signature + + + + + The entered address is invalid. + The entered address is invalid. + + + + + + + Please check the address and try again. + Please check the address and try again. + + + + + The entered address does not refer to a key. + The entered address does not refer to a key. + + + + Wallet unlock was cancelled. + Wallet unlock was cancelled. + + + + Private key for the entered address is not available. + Private key for the entered address is not available. + + + + Message signing failed. + Message signing failed. + + + + Message signed. + Message signed. + + + + The signature could not be decoded. + The signature could not be decoded. + + + + + Please check the signature and try again. + Please check the signature and try again. + + + + The signature did not match the message digest. + The signature did not match the message digest. + + + + Message verification failed. + Message verification failed. + + + + Message verified. + Message verified. + + + + TrafficGraphWidget + + + KB/s + + + + + TransactionDesc + + + Open until %1 + Open until %1 + + + + conflicted + + + + + %1/offline + %1/offline + + + + %1/unconfirmed + %1/unconfirmed + + + + %1 confirmations + %1 confirmations + + + + Status + Status + + + + , broadcast through %n node(s) + + , broadcast through %n node + , broadcast through %n nodes + + + + + Date + Date + + + + Source + Source + + + + Generated + Generated + + + + + From + From + + + + + + To + To + + + + + own address + own address + + + + label + label + + + + + + + + Credit + Credit + + + + matures in %n more block(s) + + matures in %n more block + matures in %n more blocks + + + + + not accepted + not accepted + + + + + + + Debit + Debit + + + + Transaction fee + Transaction fee + + + + Net amount + Net amount + + + + Message + Message + + + + Comment + Comment + + + + Transaction ID + Transaction ID + + + + Generated coins must mature 510 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to "not accepted" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours. + Generated coins must mature 510 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to "not accepted" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours. + + + + Debug information + Debug information + + + + Transaction + Transaction + + + + Inputs + Inputs + + + + Amount + Amount + + + + true + true + + + + false + false + + + + , has not been successfully broadcast yet + , has not been successfully broadcast yet + + + + Open for %n more block(s) + + Open for %n more block + Open for %n more blocks + + + + + unknown + unknown + + + + TransactionDescDialog + + + Transaction details + Transaction details + + + + This pane shows a detailed description of the transaction + This pane shows a detailed description of the transaction + + + + TransactionTableModel + + + Date + Date + + + + Type + Type + + + + Address + Address + + + + Amount + Amount + + + + Open until %1 + Open until %1 + + + + Confirmed (%1 confirmations) + Confirmed (%1 confirmations) + + + + Open for %n more block(s) + + Open for %n more block + Open for %n more blocks + + + + + Offline + + + + + Unconfirmed + + + + + Confirming (%1 of %2 recommended confirmations) + + + + + Conflicted + + + + + Immature (%1 confirmations, will be available after %2) + + + + + This block was not received by any other nodes and will probably not be accepted! + This block was not received by any other nodes and will probably not be accepted! + + + + Generated but not accepted + Generated but not accepted + + + + Received with + Received with + + + + Received from + Received from + + + + Sent to + Sent to + + + + Payment to yourself + Payment to yourself + + + + Mined + Mined + + + + (n/a) + (n/a) + + + + Transaction status. Hover over this field to show number of confirmations. + Transaction status. Hover over this field to show number of confirmations. + + + + Date and time that the transaction was received. + Date and time that the transaction was received. + + + + Type of transaction. + Type of transaction. + + + + Destination address of transaction. + Destination address of transaction. + + + + Amount removed from or added to balance. + Amount removed from or added to balance. + + + + TransactionView + + + + All + All + + + + Today + Today + + + + This week + This week + + + + This month + This month + + + + Last month + Last month + + + + This year + This year + + + + Range... + Range... + + + + Received with + Received with + + + + Sent to + Sent to + + + + To yourself + To yourself + + + + Mined + Mined + + + + Other + Other + + + + Enter address or label to search + Enter address or label to search + + + + Min amount + Min amount + + + + Copy address + Copy address + + + + Copy label + Copy label + + + + Copy amount + Copy amount + + + + Copy transaction ID + Copy transaction ID + + + + Edit label + Edit label + + + + Show transaction details + Show transaction details + + + + Export Transaction Data + Export Transaction Data + + + + Comma separated file (*.csv) + Comma separated file (*.csv) + + + + Confirmed + Confirmed + + + + Date + Date + + + + Type + Type + + + + Label + Label + + + + Address + Address + + + + Amount + Amount + + + + ID + ID + + + + Error exporting + Error exporting + + + + Could not write to file %1. + Could not write to file %1. + + + + Range: + Range: + + + + to + to + + + + WalletModel + + + Sending... + Sending... + + + + bitcoin-core + + + Bhcoin version + Bhcoin version + + + + Usage: + Usage: + + + + Send command to -server or bhcoind + Send command to -server or bhcoind + + + + List commands + List commands + + + + Get help for a command + Get help for a command + + + + Options: + Options: + + + + Specify configuration file (default: bhcoin.conf) + Specify configuration file (default: bhcoin.conf) + + + + Specify pid file (default: bhcoind.pid) + Specify pid file (default: bhcoind.pid) + + + + Specify wallet file (within data directory) + Specify wallet file (within data directory) + + + + Specify data directory + Specify data directory + + + + %s, you must set a rpcpassword in the configuration file: +%s +It is recommended you use the following random password: +rpcuser=bhcoinrpc +rpcpassword=%s +(you do not need to remember this password) +The username and password MUST NOT be the same. +If the file does not exist, create it with owner-readable-only file permissions. +It is also recommended to set alertnotify so you are notified of problems; +for example: alertnotify=echo %%s | mail -s "Bhcoin Alert" admin@foo.com + + + + + + Set database cache size in megabytes (default: 25) + Set database cache size in megabytes (default: 25) + + + + Set database disk log size in megabytes (default: 100) + Set database disk log size in megabytes (default: 100) + + + + Listen for connections on <port> (default: 16178 or testnet: 25714) + Listen for connections on <port> (default: 16178 or testnet: 25714) + + + + Maintain at most <n> connections to peers (default: 125) + Maintain at most <n> connections to peers (default: 125) + + + + Connect to a node to retrieve peer addresses, and disconnect + Connect to a node to retrieve peer addresses, and disconnect + + + + Specify your own public address + Specify your own public address + + + + Bind to given address. Use [host]:port notation for IPv6 + Bind to given address. Use [host]:port notation for IPv6 + + + + Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect) + + + + + Always query for peer addresses via DNS lookup (default: 0) + + + + + Threshold for disconnecting misbehaving peers (default: 100) + Threshold for disconnecting misbehaving peers (default: 100) + + + + Number of seconds to keep misbehaving peers from reconnecting (default: 86400) + Number of seconds to keep misbehaving peers from reconnecting (default: 86400) + + + + An error occurred while setting up the RPC port %u for listening on IPv4: %s + + + + + Listen for JSON-RPC connections on <port> (default: 16174 or testnet: 25715) + + + + + Accept command line and JSON-RPC commands + Accept command line and JSON-RPC commands + + + + Run in the background as a daemon and accept commands + Run in the background as a daemon and accept commands + + + + Use the test network + Use the test network + + + + Accept connections from outside (default: 1 if no -proxy or -connect) + Accept connections from outside (default: 1 if no -proxy or -connect) + + + + An error occurred while setting up the RPC port %u for listening on IPv6, falling back to IPv4: %s + + + + + Set maximum size of high-priority/low-fee transactions in bytes (default: 27000) + Set maximum size of high-priority/low-fee transactions in bytes (default: 27000) + + + + Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction. + Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction. + + + + Warning: Please check that your computer's date and time are correct! If your clock is wrong Bhcoin will not work properly. + Warning: Please check that your computer's date and time are correct! If your clock is wrong Bhcoin will not work properly. + + + + Warning: error reading wallet.dat! All keys read correctly, but transaction data or address book entries might be missing or incorrect. + Warning: error reading wallet.dat! All keys read correctly, but transaction data or address book entries might be missing or incorrect. + + + + Warning: wallet.dat corrupt, data salvaged! Original wallet.dat saved as wallet.{timestamp}.bak in %s; if your balance or transactions are incorrect you should restore from a backup. + Warning: wallet.dat corrupt, data salvaged! Original wallet.dat saved as wallet.{timestamp}.bak in %s; if your balance or transactions are incorrect you should restore from a backup. + + + + Attempt to recover private keys from a corrupt wallet.dat + Attempt to recover private keys from a corrupt wallet.dat + + + + Block creation options: + Block creation options: + + + + Connect only to the specified node(s) + Connect only to the specified node(s) + + + + Discover own IP address (default: 1 when listening and no -externalip) + Discover own IP address (default: 1 when listening and no -externalip) + + + + Failed to listen on any port. Use -listen=0 if you want this. + Failed to listen on any port. Use -listen=0 if you want this. + + + + Invalid -tor address: '%s' + Invalid -tor address: '%s' + + + + Invalid amount for -reservebalance=<amount> + + + + + Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000) + Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000) + + + + Maximum per-connection send buffer, <n>*1000 bytes (default: 1000) + Maximum per-connection send buffer, <n>*1000 bytes (default: 1000) + + + + Only connect to nodes in network <net> (IPv4, IPv6 or Tor) + Only connect to nodes in network <net> (IPv4, IPv6 or Tor) + + + + Prepend debug output with timestamp + Prepend debug output with timestamp + + + + SSL options: (see the Bitcoin Wiki for SSL setup instructions) + SSL options: (see the Bitcoin Wiki for SSL setup instructions) + + + + Send trace/debug info to console instead of debug.log file + Send trace/debug info to console instead of debug.log file + + + + Set maximum block size in bytes (default: 250000) + Set maximum block size in bytes (default: 250000) + + + + Set minimum block size in bytes (default: 0) + Set minimum block size in bytes (default: 0) + + + + Shrink debug.log file on client startup (default: 1 when no -debug) + Shrink debug.log file on client startup (default: 1 when no -debug) + + + + Specify connection timeout in milliseconds (default: 5000) + Specify connection timeout in milliseconds (default: 5000) + + + + Use UPnP to map the listening port (default: 0) + Use UPnP to map the listening port (default: 0) + + + + Use UPnP to map the listening port (default: 1 when listening) + Use UPnP to map the listening port (default: 1 when listening) + + + + Use proxy to reach tor hidden services (default: same as -proxy) + Use proxy to reach tor hidden services (default: same as -proxy) + + + + Username for JSON-RPC connections + Username for JSON-RPC connections + + + + Verifying database integrity... + + + + + Error: Wallet locked, unable to create transaction! + + + + + Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds! + + + + + Error: Transaction creation failed! + + + + + Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here. + + + + + Warning + Warning + + + + Information + + + + + Warning: This version is obsolete, upgrade required! + Warning: This version is obsolete, upgrade required! + + + + wallet.dat corrupt, salvage failed + + + + + Password for JSON-RPC connections + Password for JSON-RPC connections + + + + Connect through SOCKS5 proxy + + + + + Sync time with other nodes. Disable if time on your system is precise e.g. syncing with NTP (default: 1) + + + + + When creating transactions, ignore inputs with value less than this (default: 0.01) + + + + + Output debugging information (default: 0, supplying <category> is optional) + + + + + If <category> is not supplied, output all debugging information. + + + + + <category> can be: + + + + + Enter regression test mode, which uses a special chain in which blocks can be solved instantly. This is intended for regression testing tools and app development. + + + + + Allow JSON-RPC connections from specified IP address + Allow JSON-RPC connections from specified IP address + + + + Send commands to node running on <ip> (default: 127.0.0.1) + Send commands to node running on <ip> (default: 127.0.0.1) + + + + Wait for RPC server to start + + + + + Set the number of threads to service RPC calls (default: 4) + + + + + Execute command when the best block changes (%s in cmd is replaced by block hash) + Execute command when the best block changes (%s in cmd is replaced by block hash) + + + + Execute command when a wallet transaction changes (%s in cmd is replaced by TxID) + Execute command when a wallet transaction changes (%s in cmd is replaced by TxID) + + + + Require a confirmations for change (default: 0) + + + + + Execute command when a relevant alert is received (%s in cmd is replaced by message) + + + + + Upgrade wallet to latest format + Upgrade wallet to latest format + + + + Set key pool size to <n> (default: 100) + Set key pool size to <n> (default: 100) + + + + Rescan the block chain for missing wallet transactions + Rescan the block chain for missing wallet transactions + + + + How thorough the block verification is (0-6, default: 1) + How thorough the block verification is (0-6, default: 1) + + + + Imports blocks from external blk000?.dat file + Imports blocks from external blk000?.dat file + + + + Keep at most <n> MiB of unconnectable blocks in memory (default: %u) + + + + + Use OpenSSL (https) for JSON-RPC connections + Use OpenSSL (https) for JSON-RPC connections + + + + Server certificate file (default: server.cert) + Server certificate file (default: server.cert) + + + + Server private key (default: server.pem) + Server private key (default: server.pem) + + + + Error: Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported. + + + + + Initialization sanity check failed. Bhcoin is shutting down. + + + + + Error loading block database + + + + + Error: Wallet unlocked for staking only, unable to create transaction. + + + + + Error: Disk space is low! + + + + + This is a pre-release test build - use at your own risk - do not use for mining or merchant applications + + + + + This help message + This help message + + + + Wallet %s resides outside data directory %s. + Wallet %s resides outside data directory %s. + + + + Unable to bind to %s on this computer (bind returned error %d, %s) + Unable to bind to %s on this computer (bind returned error %d, %s) + + + + Allow DNS lookups for -addnode, -seednode and -connect + Allow DNS lookups for -addnode, -seednode and -connect + + + + Loading addresses... + Loading addresses... + + + + Error loading wallet.dat: Wallet corrupted + Error loading wallet.dat: Wallet corrupted + + + + Error loading wallet.dat: Wallet requires newer version of Bhcoin + Error loading wallet.dat: Wallet requires newer version of Bhcoin + + + + Wallet needed to be rewritten: restart Bhcoin to complete + Wallet needed to be rewritten: restart Bhcoin to complete + + + + Error loading wallet.dat + Error loading wallet.dat + + + + Invalid -proxy address: '%s' + Invalid -proxy address: '%s' + + + + Unknown network specified in -onlynet: '%s' + Unknown network specified in -onlynet: '%s' + + + + Cannot resolve -bind address: '%s' + Cannot resolve -bind address: '%s' + + + + Cannot resolve -externalip address: '%s' + Cannot resolve -externalip address: '%s' + + + + Invalid amount for -paytxfee=<amount>: '%s' + Invalid amount for -paytxfee=<amount>: '%s' + + + + Sending... + Sending... + + + + Invalid amount + Invalid amount + + + + Insufficient funds + Insufficient funds + + + + Loading block index... + Loading block index... + + + + Add a node to connect to and attempt to keep the connection open + Add a node to connect to and attempt to keep the connection open + + + + Unable to bind to %s on this computer. Bhcoin is probably already running. + Unable to bind to %s on this computer. Bhcoin is probably already running. + + + + Fee per KB to add to transactions you send + Fee per KB to add to transactions you send + + + + Minimize weight consumption (experimental) (default: 0) + + + + + How many blocks to check at startup (default: 500, 0 = all) + + + + + Acceptable ciphers (default: TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH) + + + + + Warning: Deprecated argument -debugnet ignored, use -debug=net + + + + + Invalid amount for -mininput=<amount>: '%s' + + + + + Cannot obtain a lock on data directory %s. Bhcoin is probably already running. + + + + + Error initializing wallet database environment %s! + + + + + Loading wallet... + Loading wallet... + + + + Cannot downgrade wallet + Cannot downgrade wallet + + + + Cannot write default address + Cannot write default address + + + + Rescanning... + Rescanning... + + + + Done loading + Done loading + + + + To use the %s option + To use the %s option + + + + Error + Error + + + + You must set rpcpassword=<password> in the configuration file: +%s +If the file does not exist, create it with owner-readable-only file permissions. + You must set rpcpassword=<password> in the configuration file: +%s +If the file does not exist, create it with owner-readable-only file permissions. + + + diff --git a/src/qt/macdockiconhandler.h b/src/qt/macdockiconhandler.h new file mode 100644 index 0000000..f9c2ec7 --- /dev/null +++ b/src/qt/macdockiconhandler.h @@ -0,0 +1,47 @@ +#ifndef MACDOCKICONHANDLER_H +#define MACDOCKICONHANDLER_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QIcon; +class QMenu; +class QWidget; +QT_END_NAMESPACE + +#ifdef __OBJC__ +@class DockIconClickEventHandler; +#else +class DockIconClickEventHandler; +#endif + +/** Macintosh-specific dock icon handler. + */ +class MacDockIconHandler : public QObject +{ + Q_OBJECT + +public: + ~MacDockIconHandler(); + + QMenu *dockMenu(); + void setIcon(const QIcon &icon); + void setMainWindow(QMainWindow *window); + static MacDockIconHandler *instance(); + + void handleDockIconClickEvent(); + +signals: + void dockIconClicked(); + +private: + MacDockIconHandler(); + + DockIconClickEventHandler *m_dockIconClickEventHandler; + QWidget *m_dummyWidget; + QMenu *m_dockMenu; + QMainWindow *mainWindow; +}; + +#endif // MACDOCKICONCLICKHANDLER_H diff --git a/src/qt/macdockiconhandler.mm b/src/qt/macdockiconhandler.mm new file mode 100644 index 0000000..45e4bd1 --- /dev/null +++ b/src/qt/macdockiconhandler.mm @@ -0,0 +1,131 @@ +#include "macdockiconhandler.h" + +#include +#include +#include +#include + +#undef slots +#include + +#if QT_VERSION < 0x050000 +extern void qt_mac_set_dock_menu(QMenu *); +#endif + +@interface DockIconClickEventHandler : NSObject +{ + MacDockIconHandler* dockIconHandler; +} + +@end + +@implementation DockIconClickEventHandler + +- (id)initWithDockIconHandler:(MacDockIconHandler *)aDockIconHandler +{ + self = [super init]; + if (self) { + dockIconHandler = aDockIconHandler; + + [[NSAppleEventManager sharedAppleEventManager] + setEventHandler:self + andSelector:@selector(handleDockClickEvent:withReplyEvent:) + forEventClass:kCoreEventClass + andEventID:kAEReopenApplication]; + } + return self; +} + +- (void)handleDockClickEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent +{ + Q_UNUSED(event) + Q_UNUSED(replyEvent) + + if (dockIconHandler) { + dockIconHandler->handleDockIconClickEvent(); + } +} + +@end + +MacDockIconHandler::MacDockIconHandler() : QObject() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + this->m_dockIconClickEventHandler = [[DockIconClickEventHandler alloc] initWithDockIconHandler:this]; + this->m_dummyWidget = new QWidget(); + this->m_dockMenu = new QMenu(this->m_dummyWidget); + this->setMainWindow(NULL); +#if QT_VERSION < 0x050000 + qt_mac_set_dock_menu(this->m_dockMenu); +#endif + [pool release]; +} + +void MacDockIconHandler::setMainWindow(QMainWindow *window) { + this->mainWindow = window; +} + +MacDockIconHandler::~MacDockIconHandler() +{ + [this->m_dockIconClickEventHandler release]; + delete this->m_dummyWidget; + this->setMainWindow(NULL); +} + +QMenu *MacDockIconHandler::dockMenu() +{ + return this->m_dockMenu; +} + +void MacDockIconHandler::setIcon(const QIcon &icon) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSImage *image = nil; + if (icon.isNull()) + image = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; + else { + // generate NSImage from QIcon and use this as dock icon. + QSize size = icon.actualSize(QSize(128, 128)); + QPixmap pixmap = icon.pixmap(size); + + // Write image into a R/W buffer from raw pixmap, then save the image. + QBuffer notificationBuffer; + if (!pixmap.isNull() && notificationBuffer.open(QIODevice::ReadWrite)) { + QImageWriter writer(¬ificationBuffer, "PNG"); + if (writer.write(pixmap.toImage())) { + NSData* macImgData = [NSData dataWithBytes:notificationBuffer.buffer().data() + length:notificationBuffer.buffer().size()]; + image = [[NSImage alloc] initWithData:macImgData]; + } + } + + if(!image) { + // if testnet image could not be created, load std. app icon + image = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; + } + } + + [NSApp setApplicationIconImage:image]; + [image release]; + [pool release]; +} + +MacDockIconHandler *MacDockIconHandler::instance() +{ + static MacDockIconHandler *s_instance = NULL; + if (!s_instance) + s_instance = new MacDockIconHandler(); + return s_instance; +} + +void MacDockIconHandler::handleDockIconClickEvent() +{ + if (this->mainWindow) + { + this->mainWindow->activateWindow(); + this->mainWindow->show(); + } + + emit this->dockIconClicked(); +} diff --git a/src/qt/macnotificationhandler.h b/src/qt/macnotificationhandler.h new file mode 100644 index 0000000..52fb5b1 --- /dev/null +++ b/src/qt/macnotificationhandler.h @@ -0,0 +1,30 @@ +// Copyright (c) 2011-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef MACNOTIFICATIONHANDLER_H +#define MACNOTIFICATIONHANDLER_H + +#include + +/** Macintosh-specific notification handler (supports UserNotificationCenter and Growl). + */ +class MacNotificationHandler : public QObject +{ + Q_OBJECT + +public: + /** shows a 10.8+ UserNotification in the UserNotificationCenter + */ + void showNotification(const QString &title, const QString &text); + + /** executes AppleScript */ + void sendAppleScript(const QString &script); + + /** check if OS can handle UserNotifications */ + bool hasUserNotificationCenterSupport(void); + static MacNotificationHandler *instance(); +}; + + +#endif // MACNOTIFICATIONHANDLER_H \ No newline at end of file diff --git a/src/qt/macnotificationhandler.mm b/src/qt/macnotificationhandler.mm new file mode 100644 index 0000000..f33d331 --- /dev/null +++ b/src/qt/macnotificationhandler.mm @@ -0,0 +1,69 @@ +// Copyright (c) 2011-2013 The Bitcoin Core developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "macnotificationhandler.h" + +#undef slots +#include + +void MacNotificationHandler::showNotification(const QString &title, const QString &text) +{ + // check if users OS has support for NSUserNotification + if(this->hasUserNotificationCenterSupport()) { + // okay, seems like 10.8+ + QByteArray utf8 = title.toUtf8(); + char* cString = (char *)utf8.constData(); + NSString *titleMac = [[NSString alloc] initWithUTF8String:cString]; + + utf8 = text.toUtf8(); + cString = (char *)utf8.constData(); + NSString *textMac = [[NSString alloc] initWithUTF8String:cString]; + + // do everything weak linked (because we will keep <10.8 compatibility) + id userNotification = [[NSClassFromString(@"NSUserNotification") alloc] init]; + [userNotification performSelector:@selector(setTitle:) withObject:titleMac]; + [userNotification performSelector:@selector(setInformativeText:) withObject:textMac]; + + id notificationCenterInstance = [NSClassFromString(@"NSUserNotificationCenter") performSelector:@selector(defaultUserNotificationCenter)]; + [notificationCenterInstance performSelector:@selector(deliverNotification:) withObject:userNotification]; + + [titleMac release]; + [textMac release]; + [userNotification release]; + } +} + +// sendAppleScript just take a QString and executes it as apple script +void MacNotificationHandler::sendAppleScript(const QString &script) +{ + QByteArray utf8 = script.toUtf8(); + char* cString = (char *)utf8.constData(); + NSString *scriptApple = [[NSString alloc] initWithUTF8String:cString]; + + NSAppleScript *as = [[NSAppleScript alloc] initWithSource:scriptApple]; + NSDictionary *err = nil; + [as executeAndReturnError:&err]; + [as release]; + [scriptApple release]; +} + +bool MacNotificationHandler::hasUserNotificationCenterSupport(void) +{ + Class possibleClass = NSClassFromString(@"NSUserNotificationCenter"); + + // check if users OS has support for NSUserNotification + if(possibleClass!=nil) { + return true; + } + return false; +} + + +MacNotificationHandler *MacNotificationHandler::instance() +{ + static MacNotificationHandler *s_instance = NULL; + if (!s_instance) + s_instance = new MacNotificationHandler(); + return s_instance; +} \ No newline at end of file diff --git a/src/qt/masternodemanager.cpp b/src/qt/masternodemanager.cpp new file mode 100644 index 0000000..77ae715 --- /dev/null +++ b/src/qt/masternodemanager.cpp @@ -0,0 +1,388 @@ +#include "masternodemanager.h" +#include "ui_masternodemanager.h" +#include "addeditadrenalinenode.h" +#include "adrenalinenodeconfigdialog.h" + +#include "sync.h" +#include "clientmodel.h" +#include "walletmodel.h" +#include "activemasternode.h" +#include "masternodeconfig.h" +#include "masternode.h" +#include "walletdb.h" +#include "wallet.h" +#include "init.h" +#include "rpcserver.h" +#include +#include + +using namespace json_spirit; +using namespace std; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MasternodeManager::MasternodeManager(QWidget *parent) : + QWidget(parent), + ui(new Ui::MasternodeManager), + clientModel(0), + walletModel(0) +{ + ui->setupUi(this); + + ui->editButton->setEnabled(false); + ui->getConfigButton->setEnabled(false); + ui->startButton->setEnabled(false); + ui->stopButton->setEnabled(false); + ui->copyAddressButton->setEnabled(false); + + + subscribeToCoreSignals(); + + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(updateNodeList())); + if(!GetBoolArg("-reindexaddr", false)) + timer->start(1000); + fFilterUpdated = true; + nTimeFilterUpdated = GetTime(); + + updateNodeList(); +} + +MasternodeManager::~MasternodeManager() +{ + delete ui; +} + +static void NotifyAdrenalineNodeUpdated(MasternodeManager *page, CAdrenalineNodeConfig nodeConfig) +{ + // alias, address, privkey, collateral address + QString alias = QString::fromStdString(nodeConfig.sAlias); + QString addr = QString::fromStdString(nodeConfig.sAddress); + QString privkey = QString::fromStdString(nodeConfig.sMasternodePrivKey); + QString collateral = QString::fromStdString(nodeConfig.sCollateralAddress); + + QMetaObject::invokeMethod(page, "updateAdrenalineNode", Qt::QueuedConnection, + Q_ARG(QString, alias), + Q_ARG(QString, addr), + Q_ARG(QString, privkey), + Q_ARG(QString, collateral) + ); +} + +void MasternodeManager::subscribeToCoreSignals() +{ + // Connect signals to core + uiInterface.NotifyAdrenalineNodeChanged.connect(boost::bind(&NotifyAdrenalineNodeUpdated, this, _1)); +} + +void MasternodeManager::on_tableWidget_2_itemSelectionChanged() +{ + if(ui->tableWidget_2->selectedItems().count() > 0) + { + ui->editButton->setEnabled(true); + ui->getConfigButton->setEnabled(true); + ui->startButton->setEnabled(true); + ui->stopButton->setEnabled(true); + ui->copyAddressButton->setEnabled(true); + } +} + +void MasternodeManager::updateAdrenalineNode(QString alias, QString addr, QString privkey, QString collateral) +{ + LOCK(cs_adrenaline); + bool bFound = false; + int nodeRow = 0; + for(int i=0; i < ui->tableWidget_2->rowCount(); i++) + { + if(ui->tableWidget_2->item(i, 0)->text() == alias) + { + bFound = true; + nodeRow = i; + break; + } + } + + if(nodeRow == 0 && !bFound) + ui->tableWidget_2->insertRow(0); + + QTableWidgetItem *aliasItem = new QTableWidgetItem(alias); + QTableWidgetItem *addrItem = new QTableWidgetItem(addr); + QTableWidgetItem *statusItem = new QTableWidgetItem(""); + QTableWidgetItem *collateralItem = new QTableWidgetItem(collateral); + + ui->tableWidget_2->setItem(nodeRow, 0, aliasItem); + ui->tableWidget_2->setItem(nodeRow, 1, addrItem); + ui->tableWidget_2->setItem(nodeRow, 2, statusItem); + ui->tableWidget_2->setItem(nodeRow, 3, collateralItem); +} + +static QString seconds_to_DHMS(quint32 duration) +{ + QString res; + int seconds = (int) (duration % 60); + duration /= 60; + int minutes = (int) (duration % 60); + duration /= 60; + int hours = (int) (duration % 24); + int days = (int) (duration / 24); + if((hours == 0)&&(days == 0)) + return res.sprintf("%02dm:%02ds", minutes, seconds); + if (days == 0) + return res.sprintf("%02dh:%02dm:%02ds", hours, minutes, seconds); + return res.sprintf("%dd %02dh:%02dm:%02ds", days, hours, minutes, seconds); +} + +void MasternodeManager::updateNodeList() +{ + TRY_LOCK(cs_masternodes, lockMasternodes); + if(!lockMasternodes) + return; + + ui->countLabel->setText("Updating..."); + ui->tableWidget->clearContents(); + ui->tableWidget->setRowCount(0); + BOOST_FOREACH(CMasterNode mn, vecMasternodes) + { + int mnRow = 0; + ui->tableWidget->insertRow(0); + + // populate list + // Address, Rank, Active, Active Seconds, Last Seen, Pub Key + QTableWidgetItem *activeItem = new QTableWidgetItem(QString::number(mn.IsEnabled())); + QTableWidgetItem *addressItem = new QTableWidgetItem(QString::fromStdString(mn.addr.ToString())); + QTableWidgetItem *rankItem = new QTableWidgetItem(QString::number(GetMasternodeRank(mn.vin, pindexBest->nHeight))); + QTableWidgetItem *activeSecondsItem = new QTableWidgetItem(seconds_to_DHMS((qint64)(mn.lastTimeSeen - mn.now))); + QTableWidgetItem *lastSeenItem = new QTableWidgetItem(QString::fromStdString(DateTimeStrFormat(mn.lastTimeSeen))); + + CScript pubkey; + pubkey =GetScriptForDestination(mn.pubkey.GetID()); + CTxDestination address1; + ExtractDestination(pubkey, address1); + CBitcoinAddress address2(address1); + QTableWidgetItem *pubkeyItem = new QTableWidgetItem(QString::fromStdString(address2.ToString())); + + ui->tableWidget->setItem(mnRow, 0, addressItem); + ui->tableWidget->setItem(mnRow, 1, rankItem); + ui->tableWidget->setItem(mnRow, 2, activeItem); + ui->tableWidget->setItem(mnRow, 3, activeSecondsItem); + ui->tableWidget->setItem(mnRow, 4, lastSeenItem); + ui->tableWidget->setItem(mnRow, 5, pubkeyItem); + } + + ui->countLabel->setText(QString::number(ui->tableWidget->rowCount())); + + if(pwalletMain) + { + LOCK(cs_adrenaline); + BOOST_FOREACH(PAIRTYPE(std::string, CAdrenalineNodeConfig) adrenaline, pwalletMain->mapMyAdrenalineNodes) + { + updateAdrenalineNode(QString::fromStdString(adrenaline.second.sAlias), QString::fromStdString(adrenaline.second.sAddress), QString::fromStdString(adrenaline.second.sMasternodePrivKey), QString::fromStdString(adrenaline.second.sCollateralAddress)); + } + } +} + +void MasternodeManager::setClientModel(ClientModel *model) +{ + this->clientModel = model; + if(model) + { + } +} + +void MasternodeManager::setWalletModel(WalletModel *model) +{ + this->walletModel = model; + if(model && model->getOptionsModel()) + { + } + +} + +void MasternodeManager::on_createButton_clicked() +{ + AddEditAdrenalineNode* aenode = new AddEditAdrenalineNode(); + aenode->exec(); +} + +void MasternodeManager::on_copyAddressButton_clicked() +{ + QItemSelectionModel* selectionModel = ui->tableWidget_2->selectionModel(); + QModelIndexList selected = selectionModel->selectedRows(); + if(selected.count() == 0) + return; + + QModelIndex index = selected.at(0); + int r = index.row(); + std::string sCollateralAddress = ui->tableWidget_2->item(r, 3)->text().toStdString(); + + QApplication::clipboard()->setText(QString::fromStdString(sCollateralAddress)); +} + +void MasternodeManager::on_editButton_clicked() +{ + QItemSelectionModel* selectionModel = ui->tableWidget_2->selectionModel(); + QModelIndexList selected = selectionModel->selectedRows(); + if(selected.count() == 0) + return; + + QModelIndex index = selected.at(0); + int r = index.row(); + std::string sAddress = ui->tableWidget_2->item(r, 1)->text().toStdString(); + + // get existing config entry + +} + +void MasternodeManager::on_getConfigButton_clicked() +{ + QItemSelectionModel* selectionModel = ui->tableWidget_2->selectionModel(); + QModelIndexList selected = selectionModel->selectedRows(); + if(selected.count() == 0) + return; + + QModelIndex index = selected.at(0); + int r = index.row(); + std::string sAddress = ui->tableWidget_2->item(r, 1)->text().toStdString(); + CAdrenalineNodeConfig c = pwalletMain->mapMyAdrenalineNodes[sAddress]; + std::string sPrivKey = c.sMasternodePrivKey; + AdrenalineNodeConfigDialog* d = new AdrenalineNodeConfigDialog(this, QString::fromStdString(sAddress), QString::fromStdString(sPrivKey)); + d->exec(); +} + +void MasternodeManager::on_removeButton_clicked() +{ + QItemSelectionModel* selectionModel = ui->tableWidget_2->selectionModel(); + QModelIndexList selected = selectionModel->selectedRows(); + if(selected.count() == 0) + return; + + QMessageBox::StandardButton confirm; + confirm = QMessageBox::question(this, "Delete Adrenaline Node?", "Are you sure you want to delete this adrenaline node configuration?", QMessageBox::Yes|QMessageBox::No); + + if(confirm == QMessageBox::Yes) + { + QModelIndex index = selected.at(0); + int r = index.row(); + std::string sAddress = ui->tableWidget_2->item(r, 1)->text().toStdString(); + CAdrenalineNodeConfig c = pwalletMain->mapMyAdrenalineNodes[sAddress]; + CWalletDB walletdb(pwalletMain->strWalletFile); + pwalletMain->mapMyAdrenalineNodes.erase(sAddress); + walletdb.EraseAdrenalineNodeConfig(c.sAddress); + ui->tableWidget_2->clearContents(); + ui->tableWidget_2->setRowCount(0); + BOOST_FOREACH(PAIRTYPE(std::string, CAdrenalineNodeConfig) adrenaline, pwalletMain->mapMyAdrenalineNodes) + { + updateAdrenalineNode(QString::fromStdString(adrenaline.second.sAlias), QString::fromStdString(adrenaline.second.sAddress), QString::fromStdString(adrenaline.second.sMasternodePrivKey), QString::fromStdString(adrenaline.second.sCollateralAddress)); + } + } +} + +void MasternodeManager::on_startButton_clicked() +{ + // start the node + QItemSelectionModel* selectionModel = ui->tableWidget_2->selectionModel(); + QModelIndexList selected = selectionModel->selectedRows(); + if(selected.count() == 0) + return; + + QModelIndex index = selected.at(0); + int r = index.row(); + std::string sAddress = ui->tableWidget_2->item(r, 1)->text().toStdString(); + CAdrenalineNodeConfig c = pwalletMain->mapMyAdrenalineNodes[sAddress]; + + std::string errorMessage; + bool result = activeMasternode.RegisterByPubKey(c.sAddress, c.sMasternodePrivKey, c.sCollateralAddress, errorMessage); + + QMessageBox msg; + if(result) + msg.setText("Adrenaline Node at " + QString::fromStdString(c.sAddress) + " started."); + else + msg.setText("Error: " + QString::fromStdString(errorMessage)); + + msg.exec(); +} + +void MasternodeManager::on_stopButton_clicked() +{ + // start the node + QItemSelectionModel* selectionModel = ui->tableWidget_2->selectionModel(); + QModelIndexList selected = selectionModel->selectedRows(); + if(selected.count() == 0) + return; + + QModelIndex index = selected.at(0); + int r = index.row(); + std::string sAddress = ui->tableWidget_2->item(r, 1)->text().toStdString(); + CAdrenalineNodeConfig c = pwalletMain->mapMyAdrenalineNodes[sAddress]; + + std::string errorMessage; + bool result = activeMasternode.StopMasterNode(c.sAddress, c.sMasternodePrivKey, errorMessage); + QMessageBox msg; + if(result) + { + msg.setText("Adrenaline Node at " + QString::fromStdString(c.sAddress) + " stopped."); + } + else + { + msg.setText("Error: " + QString::fromStdString(errorMessage)); + } + msg.exec(); +} + +void MasternodeManager::on_startAllButton_clicked() +{ + std::string results; + BOOST_FOREACH(PAIRTYPE(std::string, CAdrenalineNodeConfig) adrenaline, pwalletMain->mapMyAdrenalineNodes) + { + CAdrenalineNodeConfig c = adrenaline.second; + std::string errorMessage; + bool result = activeMasternode.RegisterByPubKey(c.sAddress, c.sMasternodePrivKey, c.sCollateralAddress, errorMessage); + if(result) + { + results += c.sAddress + ": STARTED\n"; + } + else + { + results += c.sAddress + ": ERROR: " + errorMessage + "\n"; + } + } + + QMessageBox msg; + msg.setText(QString::fromStdString(results)); + msg.exec(); +} + +void MasternodeManager::on_stopAllButton_clicked() +{ + std::string results; + BOOST_FOREACH(PAIRTYPE(std::string, CAdrenalineNodeConfig) adrenaline, pwalletMain->mapMyAdrenalineNodes) + { + CAdrenalineNodeConfig c = adrenaline.second; + std::string errorMessage; + bool result = activeMasternode.StopMasterNode(c.sAddress, c.sMasternodePrivKey, errorMessage); + if(result) + { + results += c.sAddress + ": STOPPED\n"; + } + else + { + results += c.sAddress + ": ERROR: " + errorMessage + "\n"; + } + } + + QMessageBox msg; + msg.setText(QString::fromStdString(results)); + msg.exec(); +} + + diff --git a/src/qt/masternodemanager.h b/src/qt/masternodemanager.h new file mode 100644 index 0000000..bbd12d3 --- /dev/null +++ b/src/qt/masternodemanager.h @@ -0,0 +1,68 @@ +#ifndef MASTERNODEMANAGER_H +#define MASTERNODEMANAGER_H + +#include "util.h" +#include "sync.h" + +#include +#include +#include + +#define MASTERNODELIST_UPDATE_SECONDS 15 +#define MASTERNODELIST_FILTER_COOLDOWN_SECONDS 3 + +namespace Ui { + class MasternodeManager; +} +class ClientModel; +class WalletModel; + +QT_BEGIN_NAMESPACE +class QModelIndex; +QT_END_NAMESPACE + +/** Masternode Manager page widget */ +class MasternodeManager : public QWidget +{ + Q_OBJECT + +public: + explicit MasternodeManager(QWidget *parent = 0); + ~MasternodeManager(); + + void setClientModel(ClientModel *clientModel); + void setWalletModel(WalletModel *walletModel); + void updateListConc(); + +public slots: + void updateNodeList(); + void updateAdrenalineNode(QString alias, QString addr, QString privkey, QString collateral); + +signals: + +private: + QTimer *timer; + Ui::MasternodeManager *ui; + ClientModel *clientModel; + WalletModel *walletModel; + CCriticalSection cs_adrenaline; + int64_t nTimeFilterUpdated; + bool fFilterUpdated; + QFuture f1; + void subscribeToCoreSignals(); + void unsubscribeFromCoreSignals(); + +private slots: + void on_copyAddressButton_clicked(); + void on_createButton_clicked(); + void on_editButton_clicked(); + void on_getConfigButton_clicked(); + void on_startButton_clicked(); + void on_stopButton_clicked(); + void on_startAllButton_clicked(); + void on_stopAllButton_clicked(); + void on_removeButton_clicked(); + void on_tableWidget_2_itemSelectionChanged(); +}; + +#endif // MASTERNODEMANAGER_H diff --git a/src/qt/messagemodel.cpp b/src/qt/messagemodel.cpp new file mode 100644 index 0000000..a273613 --- /dev/null +++ b/src/qt/messagemodel.cpp @@ -0,0 +1,619 @@ +#include "guiutil.h" +#include "guiconstants.h" +#include "bitcoinunits.h" +#include "optionsmodel.h" +#include "walletmodel.h" +#include "messagemodel.h" +#include "addresstablemodel.h" + +#include "ui_interface.h" +#include "base58.h" +#include "json_spirit.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +Q_DECLARE_METATYPE(std::vector); + +QList ambiguous; /**< Specifies Ambiguous addresses */ + +const QString MessageModel::Sent = "Sent"; +const QString MessageModel::Received = "Received"; + +struct MessageTableEntryLessThan +{ + bool operator()(const MessageTableEntry &a, const MessageTableEntry &b) const {return a.received_datetime < b.received_datetime;}; + bool operator()(const MessageTableEntry &a, const QDateTime &b) const {return a.received_datetime < b;} + bool operator()(const QDateTime &a, const MessageTableEntry &b) const {return a < b.received_datetime;} +}; + +// Private implementation +class MessageTablePriv +{ +public: + QList cachedMessageTable; + MessageModel *parent; + + MessageTablePriv(MessageModel *parent): + parent(parent) {} + + void refreshMessageTable() + { + cachedMessageTable.clear(); + + if (parent->getWalletModel()->getEncryptionStatus() == WalletModel::Locked) + { + // -- messages are stored encrypted, can't load them without the private keys + return; + }; + + { + LOCK(cs_smsgDB); + + SecMsgDB dbSmsg; + + if (!dbSmsg.Open("cr+")) + //throw runtime_error("Could not open DB."); + return; + + unsigned char chKey[18]; + std::vector vchKey; + vchKey.resize(18); + + SecMsgStored smsgStored; + MessageData msg; + QString label; + QDateTime sent_datetime; + QDateTime received_datetime; + + std::string sPrefix("im"); + leveldb::Iterator* it = dbSmsg.pdb->NewIterator(leveldb::ReadOptions()); + while (dbSmsg.NextSmesg(it, sPrefix, chKey, smsgStored)) + { + uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; + if (SecureMsgDecrypt(false, smsgStored.sAddrTo, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) + { + label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(msg.sFromAddress)); + + sent_datetime .setTime_t(msg.timestamp); + received_datetime.setTime_t(smsgStored.timeReceived); + + memcpy(&vchKey[0], chKey, 18); + + addMessageEntry(MessageTableEntry(vchKey, + MessageTableEntry::Received, + label, + QString::fromStdString(smsgStored.sAddrTo), + QString::fromStdString(msg.sFromAddress), + sent_datetime, + received_datetime, + (char*)&msg.vchMessage[0]), + true); + } + }; + + delete it; + + sPrefix = "sm"; + it = dbSmsg.pdb->NewIterator(leveldb::ReadOptions()); + while (dbSmsg.NextSmesg(it, sPrefix, chKey, smsgStored)) + { + uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; + if (SecureMsgDecrypt(false, smsgStored.sAddrOutbox, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) + { + label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(smsgStored.sAddrTo)); + + sent_datetime .setTime_t(msg.timestamp); + received_datetime.setTime_t(smsgStored.timeReceived); + + memcpy(&vchKey[0], chKey, 18); + + addMessageEntry(MessageTableEntry(vchKey, + MessageTableEntry::Sent, + label, + QString::fromStdString(smsgStored.sAddrTo), + QString::fromStdString(msg.sFromAddress), + sent_datetime, + received_datetime, + (char*)&msg.vchMessage[0]), + true); + } + }; + + delete it; + } + } + + void newMessage(const SecMsgStored& inboxHdr) + { + // we have to copy it, because it doesn't like constants going into Decrypt + SecMsgStored smsgStored = inboxHdr; + MessageData msg; + QString label; + QDateTime sent_datetime; + QDateTime received_datetime; + + uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; + if (SecureMsgDecrypt(false, smsgStored.sAddrTo, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) + { + label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(msg.sFromAddress)); + + sent_datetime .setTime_t(msg.timestamp); + received_datetime.setTime_t(smsgStored.timeReceived); + + std::string sPrefix("im"); + SecureMessage* psmsg = (SecureMessage*) &smsgStored.vchMessage[0]; + + std::vector vchKey; + vchKey.resize(18); + memcpy(&vchKey[0], sPrefix.data(), 2); + memcpy(&vchKey[2], &psmsg->timestamp, 8); + memcpy(&vchKey[10], &smsgStored.vchMessage[SMSG_HDR_LEN], 8); // sample + + addMessageEntry(MessageTableEntry(vchKey, + MessageTableEntry::Received, + label, + QString::fromStdString(smsgStored.sAddrTo), + QString::fromStdString(msg.sFromAddress), + sent_datetime, + received_datetime, + (char*)&msg.vchMessage[0]), + false); + } + } + + void newOutboxMessage(const SecMsgStored& outboxHdr) + { + + SecMsgStored smsgStored = outboxHdr; + MessageData msg; + QString label; + QDateTime sent_datetime; + QDateTime received_datetime; + + uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; + if (SecureMsgDecrypt(false, smsgStored.sAddrOutbox, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) + { + label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(smsgStored.sAddrTo)); + + sent_datetime .setTime_t(msg.timestamp); + received_datetime.setTime_t(smsgStored.timeReceived); + + std::string sPrefix("sm"); + SecureMessage* psmsg = (SecureMessage*) &smsgStored.vchMessage[0]; + std::vector vchKey; + vchKey.resize(18); + memcpy(&vchKey[0], sPrefix.data(), 2); + memcpy(&vchKey[2], &psmsg->timestamp, 8); + memcpy(&vchKey[10], &smsgStored.vchMessage[SMSG_HDR_LEN], 8); // sample + + addMessageEntry(MessageTableEntry(vchKey, + MessageTableEntry::Sent, + label, + QString::fromStdString(smsgStored.sAddrTo), + QString::fromStdString(msg.sFromAddress), + sent_datetime, + received_datetime, + (char*)&msg.vchMessage[0]), + false); + } + } + + void walletUnlocked() + { + // -- wallet is unlocked, can get at the private keys now + refreshMessageTable(); + + parent->reset(); // reload table view + + if (parent->proxyModel) + { + parent->proxyModel->setFilterRole(false); + parent->proxyModel->setFilterFixedString(""); + parent->resetFilter(); + parent->proxyModel->setFilterRole(MessageModel::Ambiguous); + parent->proxyModel->setFilterFixedString("true"); + } + + //invalidateFilter() + } + + void setEncryptionStatus(int status) + { + if (status == WalletModel::Locked) + { + // -- Wallet is locked, clear secure message display. + cachedMessageTable.clear(); + + parent->reset(); // reload table view + }; + }; + + MessageTableEntry *index(int idx) + { + if(idx >= 0 && idx < cachedMessageTable.size()) + return &cachedMessageTable[idx]; + else + return 0; + } + +private: + // Get the json value + const json_spirit::mValue & find_value(json_spirit::mObject & obj, const char * key) + { + std::string newKey = key; + + json_spirit::mObject::const_iterator i = obj.find(newKey); + + if(i != obj.end() && i->first == newKey) + return i->second; + else + return json_spirit::mValue::null; + } + + const std::string get_value(json_spirit::mObject & obj, const char * key) + { + json_spirit::mValue val = find_value(obj, key); + + if(val.is_null()) + return ""; + else + return val.get_str(); + } + + // Determine if it is a special message, i.e.: Invoice, Receipt, etc... + void handleMessageEntry(const MessageTableEntry & message, const bool append) + { + addMessageEntry(message, append); + json_spirit::mValue mVal; + json_spirit::read(message.message.toStdString(), mVal); + + if(mVal.is_null()) + { + addMessageEntry(message, append); + return; + } + + json_spirit::mObject mObj(mVal.get_obj()); + json_spirit::mValue mvType = find_value(mObj, "type"); + + } + + void addMessageEntry(const MessageTableEntry & message, const bool & append) + { + if(append) + { + cachedMessageTable.append(message); + } else + { + int index = qLowerBound(cachedMessageTable.begin(), cachedMessageTable.end(), message.received_datetime, MessageTableEntryLessThan()) - cachedMessageTable.begin(); + parent->beginInsertRows(QModelIndex(), index, index); + cachedMessageTable.insert( + index, + message); + parent->endInsertRows(); + } + } + +}; + +MessageModel::MessageModel(CWallet *wallet, WalletModel *walletModel, QObject *parent) : + QAbstractTableModel(parent), wallet(wallet), walletModel(walletModel), optionsModel(0), priv(0) +{ + columns << tr("Type") << tr("Sent Date Time") << tr("Received Date Time") << tr("Label") << tr("To Address") << tr("From Address") << tr("Message"); + + proxyModel = NULL; + + optionsModel = walletModel->getOptionsModel(); + + priv = new MessageTablePriv(this); + priv->refreshMessageTable(); + + subscribeToCoreSignals(); +} + +MessageModel::~MessageModel() +{ + if (proxyModel) + delete proxyModel; + + delete priv; + unsubscribeFromCoreSignals(); +} + +bool MessageModel::getAddressOrPubkey(QString &address, QString &pubkey) const +{ + CBitcoinAddress addressParsed(address.toStdString()); + + if(addressParsed.IsValid()) { + CKeyID destinationAddress; + CPubKey destinationKey; + + addressParsed.GetKeyID(destinationAddress); + + if (SecureMsgGetStoredKey(destinationAddress, destinationKey) != 0 + && SecureMsgGetLocalKey(destinationAddress, destinationKey) != 0) // test if it's a local key + return false; + + address = destinationAddress.ToString().c_str(); + pubkey = EncodeBase58(destinationKey.Raw()).c_str(); + + return true; + } + + return false; +} + +WalletModel *MessageModel::getWalletModel() +{ + return walletModel; +} + +OptionsModel *MessageModel::getOptionsModel() +{ + return optionsModel; +} + +MessageModel::StatusCode MessageModel::sendMessages(const QList &recipients, const QString &addressFrom) +{ + + QSet setAddress; + + if(recipients.empty()) + return OK; + + // Pre-check input data for validity + foreach(const SendMessagesRecipient &rcp, recipients) + { + if(!walletModel->validateAddress(rcp.address)) + return InvalidAddress; + + if(rcp.message == "") + return MessageCreationFailed; + + std::string sendTo = rcp.address.toStdString(); + std::string pubkey = rcp.pubkey.toStdString(); + std::string message = rcp.message.toStdString(); + std::string addFrom = addressFrom.toStdString(); + + SecureMsgAddAddress(sendTo, pubkey); + setAddress.insert(rcp.address); + + std::string sError; + if (SecureMsgSend(addFrom, sendTo, message, sError) != 0) + { + QMessageBox::warning(NULL, tr("Send Secure Message"), + tr("Send failed: %1.").arg(sError.c_str()), + QMessageBox::Ok, QMessageBox::Ok); + + return FailedErrorShown; + }; + + // Add addresses / update labels that we've sent to to the address book + std::string strAddress = rcp.address.toStdString(); + CTxDestination dest = CBitcoinAddress(strAddress).Get(); + std::string strLabel = rcp.label.toStdString(); + { + LOCK(wallet->cs_wallet); + + std::map::iterator mi = wallet->mapAddressBook.find(dest); + + // Check if we have a new address or an updated label + if (mi == wallet->mapAddressBook.end() || mi->second != strLabel) + { + wallet->SetAddressBookName(dest, strLabel); + } + } + } + + if(recipients.size() > setAddress.size()) + return DuplicateAddress; + + return OK; +} + +MessageModel::StatusCode MessageModel::sendMessages(const QList &recipients) +{ + return sendMessages(recipients, "anon"); +} + +int MessageModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return priv->cachedMessageTable.size(); +} + +int MessageModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return columns.length(); +} + +QVariant MessageModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid()) + return QVariant(); + + MessageTableEntry *rec = static_cast(index.internalPointer()); + + switch(role) + { + /* + case Qt::DecorationRole: + switch(index.column()) + { + return txStatusDecoration(rec); + case ToAddress: + return txAddressDecoration(rec); + } + break;*/ + case Qt::DisplayRole: + switch(index.column()) + { + case Label: return (rec->label.isEmpty() ? tr("(no label)") : rec->label); + case ToAddress: return rec->to_address; + case FromAddress: return rec->from_address; + case SentDateTime: return rec->sent_datetime; + case ReceivedDateTime: return rec->received_datetime; + case Message: return rec->message; + case TypeInt: return rec->type; + case HTML: return rec->received_datetime.toString() + "
" + (rec->label.isEmpty() ? rec->from_address : rec->label) + "
" + rec->message; + case Type: + switch(rec->type) + { + case MessageTableEntry::Sent: return Sent; + case MessageTableEntry::Received: return Received; + default: break; + } + case Key: return QVariant::fromValue(rec->chKey); + } + break; + + case KeyRole: return QVariant::fromValue(rec->chKey); + case TypeRole: return rec->type; + case SentDateRole: return rec->sent_datetime; + case ReceivedDateRole: return rec->received_datetime; + case FromAddressRole: return rec->from_address; + case ToAddressRole: return rec->to_address; + case FilterAddressRole: return (rec->type == MessageTableEntry::Sent ? rec->to_address + rec->from_address : rec->from_address + rec->to_address); + case LabelRole: return rec->label; + case MessageRole: return rec->message; + case ShortMessageRole: return rec->message; // TODO: Short message + case HTMLRole: return rec->received_datetime.toString() + "
" + (rec->label.isEmpty() ? rec->from_address : rec->label) + "
" + rec->message; + case Ambiguous: + int it; + + for (it = 0; ittype == MessageTableEntry::Sent ? rec->to_address + rec->from_address : rec->from_address + rec->to_address)) + return false; + } + QString address = (rec->type == MessageTableEntry::Sent ? rec->to_address + rec->from_address : rec->from_address + rec->to_address); + ambiguous.append(address); + + return "true"; + break; + } + + return QVariant(); +} + +QVariant MessageModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + return (orientation == Qt::Horizontal && role == Qt::DisplayRole ? columns[section] : QVariant()); +} + +Qt::ItemFlags MessageModel::flags(const QModelIndex & index) const +{ + if(index.isValid()) + return Qt::ItemIsSelectable | Qt::ItemIsEnabled; + + return 0; +} + +QModelIndex MessageModel::index(int row, int column, const QModelIndex & parent) const +{ + Q_UNUSED(parent); + MessageTableEntry *data = priv->index(row); + return (data ? createIndex(row, column, priv->index(row)) : QModelIndex()); +} + +bool MessageModel::removeRows(int row, int count, const QModelIndex & parent) +{ + MessageTableEntry *rec = priv->index(row); + if(count != 1 || !rec) + // Can only remove one row at a time, and cannot remove rows not in model. + // Also refuse to remove receiving addresses. + return false; + + { + LOCK(cs_smsgDB); + SecMsgDB dbSmsg; + + if (!dbSmsg.Open("cr+")) + //throw runtime_error("Could not open DB."); + return false; + + dbSmsg.EraseSmesg(&rec->chKey[0]); + } + + beginRemoveRows(parent, row, row); + priv->cachedMessageTable.removeAt(row); + endRemoveRows(); + + return true; +} + +void MessageModel::resetFilter() +{ + ambiguous.clear(); +} + +void MessageModel::newMessage(const SecMsgStored &smsg) +{ + priv->newMessage(smsg); +} + + +void MessageModel::newOutboxMessage(const SecMsgStored &smsgOutbox) +{ + priv->newOutboxMessage(smsgOutbox); +} + + +void MessageModel::walletUnlocked() +{ + priv->walletUnlocked(); +} + +void MessageModel::setEncryptionStatus(int status) +{ + priv->setEncryptionStatus(status); +} + + +static void NotifySecMsgInbox(MessageModel *messageModel, SecMsgStored inboxHdr) +{ + // Too noisy: OutputDebugStringF("NotifySecMsgInboxChanged %s\n", message); + QMetaObject::invokeMethod(messageModel, "newMessage", Qt::QueuedConnection, + Q_ARG(SecMsgStored, inboxHdr)); +} + +static void NotifySecMsgOutbox(MessageModel *messageModel, SecMsgStored outboxHdr) +{ + QMetaObject::invokeMethod(messageModel, "newOutboxMessage", Qt::QueuedConnection, + Q_ARG(SecMsgStored, outboxHdr)); +} + +static void NotifySecMsgWallet(MessageModel *messageModel) +{ + QMetaObject::invokeMethod(messageModel, "walletUnlocked", Qt::QueuedConnection); +} + +void MessageModel::subscribeToCoreSignals() +{ + qRegisterMetaType("SecMsgStored"); + + // Connect signals + NotifySecMsgInboxChanged.connect(boost::bind(NotifySecMsgInbox, this, _1)); + NotifySecMsgOutboxChanged.connect(boost::bind(NotifySecMsgOutbox, this, _1)); + NotifySecMsgWalletUnlocked.connect(boost::bind(NotifySecMsgWallet, this)); + + connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); +} + +void MessageModel::unsubscribeFromCoreSignals() +{ + // Disconnect signals + NotifySecMsgInboxChanged.disconnect(boost::bind(NotifySecMsgInbox, this, _1)); + NotifySecMsgOutboxChanged.disconnect(boost::bind(NotifySecMsgOutbox, this, _1)); + NotifySecMsgWalletUnlocked.disconnect(boost::bind(NotifySecMsgWallet, this)); + + disconnect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); +} diff --git a/src/qt/messagemodel.h b/src/qt/messagemodel.h new file mode 100644 index 0000000..002a82c --- /dev/null +++ b/src/qt/messagemodel.h @@ -0,0 +1,195 @@ +#ifndef MESSAGEMODEL_H +#define MESSAGEMODEL_H + +#include "uint256.h" + +#include +#include "allocators.h" /* for SecureString */ +#include "smessage.h" +#include +#include +#include +#include +#include + + +class MessageTablePriv; +class InvoiceTableModel; +class InvoiceItemTableModel; +class ReceiptTableModel; +class CWallet; +class WalletModel; +class OptionsModel; + +class SendMessagesRecipient +{ +public: + QString address; + QString label; + QString pubkey; + QString message; +}; + +struct MessageTableEntry +{ + enum Type { + Sent, + Received + }; + + std::vector chKey; + Type type; + QString label; + QString to_address; + QString from_address; + QDateTime sent_datetime; + QDateTime received_datetime; + QString message; + + MessageTableEntry() {} + MessageTableEntry(std::vector &chKey, + Type type, + const QString &label, + const QString &to_address, + const QString &from_address, + const QDateTime &sent_datetime, + const QDateTime &received_datetime, + const QString &message): + chKey(chKey), + type(type), + label(label), + to_address(to_address), + from_address(from_address), + sent_datetime(sent_datetime), + received_datetime(received_datetime), + message(message) + { + } +}; + +/** Interface to SONO Secure Messaging from Qt view code. */ +class MessageModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + explicit MessageModel(CWallet *wallet, WalletModel *walletModel, QObject *parent = 0); + ~MessageModel(); + + enum StatusCode // Returned by sendMessages + { + OK, + InvalidAddress, + InvalidMessage, + DuplicateAddress, + MessageCreationFailed, // Error returned when DB is still locked + MessageCommitFailed, + Aborted, + FailedErrorShown + }; + + enum ColumnIndex { + Type = 0, /**< Sent/Received */ + SentDateTime = 1, /**< Time Sent */ + ReceivedDateTime = 2, /**< Time Received */ + Label = 3, /**< User specified label */ + ToAddress = 4, /**< To Bitcoin address */ + FromAddress = 5, /**< From Bitcoin address */ + Message = 6, /**< Plaintext */ + TypeInt = 7, /**< Plaintext */ + Key = 8, /**< chKey */ + HTML = 9, /**< HTML Formatted Data */ + }; + + /** Roles to get specific information from a message row. + These are independent of column. + */ + enum RoleIndex { + /** Type of message */ + TypeRole = Qt::UserRole, + /** Date and time this message was sent */ + /** message key */ + KeyRole, + SentDateRole, + /** Date and time this message was received */ + ReceivedDateRole, + /** From Address of message */ + FromAddressRole, + /** To Address of message */ + ToAddressRole, + /** Filter address related to message */ + FilterAddressRole, + /** Label of address related to message */ + LabelRole, + /** Full Message */ + MessageRole, + /** Short Message */ + ShortMessageRole, + /** HTML Formatted */ + HTMLRole, + /** Ambiguous bool */ + Ambiguous + }; + + static const QString Sent; /**< Specifies sent message */ + static const QString Received; /**< Specifies sent message */ + + //QList ambiguous; /**< Specifies Ambiguous addresses */ + + /** @name Methods overridden from QAbstractTableModel + @{*/ + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QModelIndex index(int row, int column, const QModelIndex & parent) const; + bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); + Qt::ItemFlags flags(const QModelIndex & index) const; + /*@}*/ + + /* Look up row index of a message in the model. + Return -1 if not found. + */ + int lookupMessage(const QString &message) const; + + WalletModel *getWalletModel(); + OptionsModel *getOptionsModel(); + + void resetFilter(); + + bool getAddressOrPubkey( QString &Address, QString &Pubkey) const; + + // Send messages to a list of recipients + StatusCode sendMessages(const QList &recipients); + StatusCode sendMessages(const QList &recipients, const QString &addressFrom); + + QSortFilterProxyModel *proxyModel; + +private: + CWallet *wallet; + WalletModel *walletModel; + OptionsModel *optionsModel; + MessageTablePriv *priv; + QStringList columns; + + void subscribeToCoreSignals(); + void unsubscribeFromCoreSignals(); + +public slots: + + /* Check for new messages */ + void newMessage(const SecMsgStored& smsg); + void newOutboxMessage(const SecMsgStored& smsg); + + void walletUnlocked(); + + void setEncryptionStatus(int status); + + friend class MessageTablePriv; + +signals: + // Asynchronous error notification + void error(const QString &title, const QString &message, bool modal); +}; + +#endif // MESSAGEMODEL_H diff --git a/src/qt/messagepage.cpp b/src/qt/messagepage.cpp new file mode 100644 index 0000000..9ee2bf0 --- /dev/null +++ b/src/qt/messagepage.cpp @@ -0,0 +1,429 @@ +#include "messagepage.h" +#include "ui_messagepage.h" + +#include "sendmessagesdialog.h" +#include "mrichtextedit.h" +#include "messagemodel.h" +#include "bitcoingui.h" +#include "csvmodelwriter.h" +#include "guiutil.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define DECORATION_SIZE 64 +#define NUM_ITEMS 3 + +class MessageViewDelegate : public QStyledItemDelegate +{ +protected: + void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const; + QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const; +}; + +void MessageViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QStyleOptionViewItemV4 optionV4 = option; + initStyleOption(&optionV4, index); + + QStyle *style = optionV4.widget? optionV4.widget->style() : QApplication::style(); + + QTextDocument doc; + QString align(index.data(MessageModel::TypeRole) == 1 ? "left" : "right"); + QString html = "

" + index.data(MessageModel::HTMLRole).toString() + "

"; + doc.setHtml(html); + + /// Painting item without text + optionV4.text = QString(); + style->drawControl(QStyle::CE_ItemViewItem, &optionV4, painter); + + QAbstractTextDocumentLayout::PaintContext ctx; + + // Highlighting text if item is selected + if (optionV4.state & QStyle::State_Selected) + ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText)); + + QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4); + doc.setTextWidth( textRect.width() ); + painter->save(); + painter->translate(textRect.topLeft()); + painter->setClipRect(textRect.translated(-textRect.topLeft())); + doc.documentLayout()->draw(painter, ctx); + painter->restore(); +} + +QSize MessageViewDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const +{ + QStyleOptionViewItemV4 options = option; + initStyleOption(&options, index); + + QTextDocument doc; + doc.setHtml(index.data(MessageModel::HTMLRole).toString()); + doc.setTextWidth(options.rect.width()); + return QSize(doc.idealWidth(), doc.size().height() + 20); +} + + +MessagePage::MessagePage(QWidget *parent) : + QWidget(parent), + ui(new Ui::MessagePage), + model(0), + msgdelegate(new MessageViewDelegate()), + messageTextEdit(new MRichTextEdit()) +{ + ui->setupUi(this); + + +#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac + ui->deleteButton->setIcon(QIcon()); +#endif + // Context menu actions + replyAction = new QAction(ui->sendButton->text(), this); + copyFromAddressAction = new QAction(ui->copyFromAddressButton->text(), this); + copyToAddressAction = new QAction(ui->copyToAddressButton->text(), this); + deleteAction = new QAction(ui->deleteButton->text(), this); + + // Build context menu + contextMenu = new QMenu(); + + contextMenu->addAction(replyAction); + contextMenu->addAction(copyFromAddressAction); + contextMenu->addAction(copyToAddressAction); + contextMenu->addAction(deleteAction); + + connect(replyAction, SIGNAL(triggered()), this, SLOT(on_sendButton_clicked())); + connect(copyFromAddressAction, SIGNAL(triggered()), this, SLOT(on_copyFromAddressButton_clicked())); + connect(copyToAddressAction, SIGNAL(triggered()), this, SLOT(on_copyToAddressButton_clicked())); + connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteButton_clicked())); + + connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); + + // Show Messages + ui->listConversation->setItemDelegate(msgdelegate); + ui->listConversation->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE)); + ui->listConversation->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2)); + ui->listConversation->setAttribute(Qt::WA_MacShowFocusRect, false); +} + +MessagePage::~MessagePage() +{ + delete ui; +} + +void MessagePage::setModel(MessageModel *model) +{ + this->model = model; + if(!model) + return; + + //if (model->proxyModel) + // delete model->proxyModel; + model->proxyModel = new QSortFilterProxyModel(this); + model->proxyModel->setSourceModel(model); + model->proxyModel->setDynamicSortFilter(true); + model->proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + model->proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + model->proxyModel->sort(MessageModel::ReceivedDateTime); + model->proxyModel->setFilterRole(MessageModel::Ambiguous); + model->proxyModel->setFilterFixedString("true"); + + ui->tableView->setModel(model->proxyModel); + ui->tableView->sortByColumn(MessageModel::ReceivedDateTime, Qt::DescendingOrder); + + ui->listConversation->setModel(model->proxyModel); + ui->listConversation->setModelColumn(MessageModel::HTML); + + // Set column widths + ui->tableView->horizontalHeader()->resizeSection(MessageModel::Type, 100); + ui->tableView->horizontalHeader()->resizeSection(MessageModel::Label, 100); + ui->tableView->horizontalHeader()->setResizeMode(MessageModel::Label, QHeaderView::Stretch); + ui->tableView->horizontalHeader()->resizeSection(MessageModel::FromAddress, 320); + ui->tableView->horizontalHeader()->resizeSection(MessageModel::ToAddress, 320); + ui->tableView->horizontalHeader()->resizeSection(MessageModel::SentDateTime, 170); + ui->tableView->horizontalHeader()->resizeSection(MessageModel::ReceivedDateTime, 170); + + //ui->messageEdit->setMinimumHeight(100); + + // Hidden columns + ui->tableView->setColumnHidden(MessageModel::Message, true); + + connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged())); + connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectionChanged())); + connect(ui->listConversation->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(itemSelectionChanged())); + connect(ui->listConversation, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(itemSelectionChanged())); + //connect(ui->messageEdit, SIGNAL(textChanged()), this, SLOT(messageTextChanged())); + + // Scroll to bottom + connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(incomingMessage())); + + selectionChanged(); +} + +void MessagePage::on_sendButton_clicked() +{ + if(!model) + return; + + std::string sError; + std::string sendTo = replyToAddress.toStdString(); + std::string message = ui->messageEdit->toHtml().toStdString(); + std::string addFrom = replyFromAddress.toStdString(); + + if (SecureMsgSend(addFrom, sendTo, message, sError) != 0) + { + QMessageBox::warning(NULL, tr("Send Secure Message"), + tr("Send failed: %1.").arg(sError.c_str()), + QMessageBox::Ok, QMessageBox::Ok); + + return; + }; + + //ui->messageEdit->setMaximumHeight(30); + ui->messageEdit->clear(); + ui->listConversation->scrollToBottom(); +} + +void MessagePage::on_newButton_clicked() +{ + if(!model) + return; + + SendMessagesDialog dlg(SendMessagesDialog::Encrypted, SendMessagesDialog::Dialog, this); + + dlg.setModel(model); + dlg.exec(); +} + +void MessagePage::on_copyFromAddressButton_clicked() +{ + GUIUtil::copyEntryData(ui->tableView, MessageModel::FromAddress, Qt::DisplayRole); +} + +void MessagePage::on_copyToAddressButton_clicked() +{ + GUIUtil::copyEntryData(ui->tableView, MessageModel::ToAddress, Qt::DisplayRole); +} + +void MessagePage::on_deleteButton_clicked() +{ + QListView *list = ui->listConversation; + + if(!list->selectionModel()) + return; + + QModelIndexList indexes = list->selectionModel()->selectedIndexes(); + + if(!indexes.isEmpty()) + { + list->model()->removeRow(indexes.at(0).row()); + indexes = list->selectionModel()->selectedIndexes(); + + if(indexes.isEmpty()) + on_backButton_clicked(); + } +} + +void MessagePage::on_backButton_clicked() +{ + model->proxyModel->setFilterRole(false); + model->proxyModel->setFilterFixedString(""); + model->resetFilter(); + model->proxyModel->setFilterRole(MessageModel::Ambiguous); + model->proxyModel->setFilterFixedString("true"); + + ui->tableView->clearSelection(); + ui->listConversation->clearSelection(); + itemSelectionChanged(); + selectionChanged(); + + ui->messageDetails->hide(); + ui->tableView->show(); + ui->newButton->setEnabled(true); + ui->newButton->setVisible(true); + ui->sendButton->setEnabled(false); + ui->sendButton->setVisible(false); + ui->messageEdit->setVisible(false); +} + +void MessagePage::selectionChanged() +{ + // Set button states based on selected tab and selection + QTableView *table = ui->tableView; + if(!table->selectionModel()) + return; + + if(table->selectionModel()->hasSelection()) + { + replyAction->setEnabled(true); + copyFromAddressAction->setEnabled(true); + copyToAddressAction->setEnabled(true); + deleteAction->setEnabled(true); + + ui->copyFromAddressButton->setEnabled(true); + ui->copyToAddressButton->setEnabled(true); + ui->deleteButton->setEnabled(true); + + ui->newButton->setEnabled(false); + ui->newButton->setVisible(false); + ui->sendButton->setEnabled(true); + ui->sendButton->setVisible(true); + ui->messageEdit->setVisible(true); + + ui->tableView->hide(); + + // Figure out which message was selected + QModelIndexList labelColumn = table->selectionModel()->selectedRows(MessageModel::Label); + QModelIndexList addressFromColumn = table->selectionModel()->selectedRows(MessageModel::FromAddress); + QModelIndexList addressToColumn = table->selectionModel()->selectedRows(MessageModel::ToAddress); + QModelIndexList typeColumn = table->selectionModel()->selectedRows(MessageModel::Type); + + int type; + + foreach (QModelIndex index, typeColumn) + type = (table->model()->data(index).toString() == MessageModel::Sent ? MessageTableEntry::Sent : MessageTableEntry::Received); + + foreach (QModelIndex index, labelColumn) + ui->contactLabel->setText(table->model()->data(index).toString()); + + foreach (QModelIndex index, addressFromColumn) + if(type == MessageTableEntry::Sent) + replyFromAddress = table->model()->data(index).toString(); + else + replyToAddress = table->model()->data(index).toString(); + + foreach (QModelIndex index, addressToColumn) + if(type == MessageTableEntry::Sent) + replyToAddress = table->model()->data(index).toString(); + else + replyFromAddress = table->model()->data(index).toString(); + + QString filter = (type == MessageTableEntry::Sent ? replyToAddress + replyFromAddress : replyToAddress + replyFromAddress); + + model->proxyModel->setFilterRole(false); + model->proxyModel->setFilterFixedString(""); + model->proxyModel->sort(MessageModel::ReceivedDateTime); + model->proxyModel->setFilterRole(MessageModel::FilterAddressRole); + model->proxyModel->setFilterFixedString(filter); + ui->messageDetails->show(); + ui->listConversation->setCurrentIndex(model->proxyModel->index(0, 0, QModelIndex())); + } + else + { + ui->newButton->setEnabled(true); + ui->newButton->setVisible(true); + ui->sendButton->setEnabled(false); + ui->sendButton->setVisible(false); + ui->copyFromAddressButton->setEnabled(false); + ui->copyToAddressButton->setEnabled(false); + ui->deleteButton->setEnabled(false); + ui->messageEdit->hide(); + ui->messageDetails->hide(); + ui->messageEdit->clear(); + } +} + +void MessagePage::itemSelectionChanged() +{ + // Set button states based on selected tab and selection + QListView *list = ui->listConversation; + if(!list->selectionModel()) + return; + + if(list->selectionModel()->hasSelection()) + { + replyAction->setEnabled(true); + copyFromAddressAction->setEnabled(true); + copyToAddressAction->setEnabled(true); + deleteAction->setEnabled(true); + + ui->copyFromAddressButton->setEnabled(true); + ui->copyToAddressButton->setEnabled(true); + ui->deleteButton->setEnabled(true); + + ui->newButton->setEnabled(false); + ui->newButton->setVisible(false); + ui->sendButton->setEnabled(true); + ui->sendButton->setVisible(true); + ui->messageEdit->setVisible(true); + + ui->tableView->hide(); + + } + else + { + ui->newButton->setEnabled(true); + ui->newButton->setVisible(true); + ui->sendButton->setEnabled(false); + ui->sendButton->setVisible(false); + ui->copyFromAddressButton->setEnabled(false); + ui->copyToAddressButton->setEnabled(false); + ui->deleteButton->setEnabled(false); + ui->messageEdit->hide(); + ui->messageDetails->hide(); + ui->messageEdit->clear(); + } +} + +void MessagePage::incomingMessage() +{ + ui->listConversation->scrollToBottom(); +} + +void MessagePage::messageTextChanged() +{ + /* + if(ui->messageEdit->toPlainText().endsWith("\n")) + { + ui->messageEdit->setMaximumHeight(80); + ui->messageEdit->resize(256, ui->messageEdit->document()->size().height() + 10); + }*/ + +} + +void MessagePage::exportClicked() +{ + // CSV is currently the only supported format + QString filename = GUIUtil::getSaveFileName( + this, + tr("Export Messages"), QString(), + tr("Comma separated file (*.csv)")); + + if (filename.isNull()) return; + + CSVModelWriter writer(filename); + + // name, column, role + writer.setModel(model->proxyModel); + writer.addColumn("Type", MessageModel::Type, Qt::DisplayRole); + writer.addColumn("Label", MessageModel::Label, Qt::DisplayRole); + writer.addColumn("FromAddress", MessageModel::FromAddress, Qt::DisplayRole); + writer.addColumn("ToAddress", MessageModel::ToAddress, Qt::DisplayRole); + writer.addColumn("SentDateTime", MessageModel::SentDateTime, Qt::DisplayRole); + writer.addColumn("ReceivedDateTime", MessageModel::ReceivedDateTime, Qt::DisplayRole); + writer.addColumn("Message", MessageModel::Message, Qt::DisplayRole); + + if(!writer.write()) + { + QMessageBox::critical(this, tr("Error exporting"), tr("Could not write to file %1.").arg(filename), + QMessageBox::Abort, QMessageBox::Abort); + } +} + + +void MessagePage::contextualMenu(const QPoint &point) +{ + QModelIndex index = ui->tableView->indexAt(point); + if(index.isValid()) + { + contextMenu->exec(QCursor::pos()); + } +} + diff --git a/src/qt/messagepage.h b/src/qt/messagepage.h new file mode 100644 index 0000000..8b20fc0 --- /dev/null +++ b/src/qt/messagepage.h @@ -0,0 +1,73 @@ +#ifndef MESSAGEPAGE_H +#define MESSAGEPAGE_H + +#include + +namespace Ui { + class MessagePage; +} +class MessageModel; +//class OptionsModel; + +QT_BEGIN_NAMESPACE +class QTableView; +class QItemSelection; +class QSortFilterProxyModel; +class QMenu; +class QModelIndex; +class MessageViewDelegate; +class MRichTextEdit; +QT_END_NAMESPACE + + +/** Widget that shows a list of sending or receiving addresses. + */ +class MessagePage : public QWidget +{ + Q_OBJECT + +public: + + explicit MessagePage(QWidget *parent = 0); + ~MessagePage(); + + void setModel(MessageModel *model); + +private: + void setupTextActions(); + +public slots: + void exportClicked(); + +private: + Ui::MessagePage *ui; + MessageModel *model; + + QMenu *contextMenu; + QAction *replyAction; + QAction *copyFromAddressAction; + QAction *copyToAddressAction; + QAction *deleteAction; + QString replyFromAddress; + QString replyToAddress; + MessageViewDelegate *msgdelegate; + MRichTextEdit *messageTextEdit; + +private slots: + void on_sendButton_clicked(); + void on_newButton_clicked(); + void on_copyFromAddressButton_clicked(); + void on_copyToAddressButton_clicked(); + void on_deleteButton_clicked(); + void on_backButton_clicked(); + void messageTextChanged(); + void selectionChanged(); + void itemSelectionChanged(); + void incomingMessage(); + /** Spawn contextual menu (right mouse menu) for address book entry */ + void contextualMenu(const QPoint &point); + +signals: +}; + +#endif // MESSAGEPAGE_H diff --git a/src/qt/monitoreddatamapper.cpp b/src/qt/monitoreddatamapper.cpp new file mode 100644 index 0000000..efc0cbe --- /dev/null +++ b/src/qt/monitoreddatamapper.cpp @@ -0,0 +1,35 @@ +#include "monitoreddatamapper.h" + +#include +#include +#include + +MonitoredDataMapper::MonitoredDataMapper(QObject *parent) : + QDataWidgetMapper(parent) +{ +} + +void MonitoredDataMapper::addMapping(QWidget *widget, int section) +{ + QDataWidgetMapper::addMapping(widget, section); + addChangeMonitor(widget); +} + +void MonitoredDataMapper::addMapping(QWidget *widget, int section, const QByteArray &propertyName) +{ + QDataWidgetMapper::addMapping(widget, section, propertyName); + addChangeMonitor(widget); +} + +void MonitoredDataMapper::addChangeMonitor(QWidget *widget) +{ + // Watch user property of widget for changes, and connect + // the signal to our viewModified signal. + QMetaProperty prop = widget->metaObject()->userProperty(); + int signal = prop.notifySignalIndex(); + int method = this->metaObject()->indexOfMethod("viewModified()"); + if(signal != -1 && method != -1) + { + QMetaObject::connect(widget, signal, this, method); + } +} diff --git a/src/qt/monitoreddatamapper.h b/src/qt/monitoreddatamapper.h new file mode 100644 index 0000000..3938463 --- /dev/null +++ b/src/qt/monitoreddatamapper.h @@ -0,0 +1,30 @@ +#ifndef MONITOREDDATAMAPPER_H +#define MONITOREDDATAMAPPER_H + +#include + +QT_BEGIN_NAMESPACE +class QWidget; +QT_END_NAMESPACE + +/** Data to Widget mapper that watches for edits and notifies listeners when a field is edited. + This can be used, for example, to enable a commit/apply button in a configuration dialog. + */ +class MonitoredDataMapper : public QDataWidgetMapper +{ + Q_OBJECT + +public: + explicit MonitoredDataMapper(QObject *parent=0); + + void addMapping(QWidget *widget, int section); + void addMapping(QWidget *widget, int section, const QByteArray &propertyName); + +private: + void addChangeMonitor(QWidget *widget); + +signals: + void viewModified(); +}; + +#endif // MONITOREDDATAMAPPER_H diff --git a/src/qt/multisigaddressentry.cpp b/src/qt/multisigaddressentry.cpp new file mode 100644 index 0000000..e6f9cb9 --- /dev/null +++ b/src/qt/multisigaddressentry.cpp @@ -0,0 +1,120 @@ +#include +#include +#include +#include + +#include "addressbookpage.h" +#include "addresstablemodel.h" +#include "base58.h" +#include "guiutil.h" +#include "key.h" +#include "multisigaddressentry.h" +#include "ui_multisigaddressentry.h" +#include "walletmodel.h" + + +MultisigAddressEntry::MultisigAddressEntry(QWidget *parent) : QFrame(parent), ui(new Ui::MultisigAddressEntry), model(0) +{ + ui->setupUi(this); + GUIUtil::setupAddressWidget(ui->address, this); +} + +MultisigAddressEntry::~MultisigAddressEntry() +{ + delete ui; +} + +void MultisigAddressEntry::setModel(WalletModel *model) +{ + this->model = model; + clear(); +} + +void MultisigAddressEntry::clear() +{ + ui->pubkey->clear(); + ui->address->clear(); + ui->label->clear(); + ui->pubkey->setFocus(); +} + +bool MultisigAddressEntry::validate() +{ + return !ui->pubkey->text().isEmpty(); +} + +QString MultisigAddressEntry::getPubkey() +{ + return ui->pubkey->text(); +} + +void MultisigAddressEntry::setRemoveEnabled(bool enabled) +{ + ui->deleteButton->setEnabled(enabled); +} + +void MultisigAddressEntry::on_pasteButton_clicked() +{ + ui->address->setText(QApplication::clipboard()->text()); +} + +void MultisigAddressEntry::on_deleteButton_clicked() +{ + emit removeEntry(this); +} + +void MultisigAddressEntry::on_addressBookButton_clicked() +{ + if(!model) + return; + + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this); + dlg.setModel(model->getAddressTableModel()); + if(dlg.exec()) + { + ui->address->setText(dlg.getReturnValue()); + } +} + +void MultisigAddressEntry::on_pubkey_textChanged(const QString &pubkey) +{ + // Compute address from public key + std::vector vchPubKey(ParseHex(pubkey.toStdString().c_str())); + CPubKey pkey(vchPubKey); + CKeyID keyID = pkey.GetID(); + CBitcoinAddress address(keyID); + ui->address->setText(address.ToString().c_str()); + + if(!model) + return; + + // Get label of address + QString associatedLabel = model->getAddressTableModel()->labelForAddress(address.ToString().c_str()); + if(!associatedLabel.isEmpty()) + ui->label->setText(associatedLabel); + else + ui->label->setText(QString()); +} + +void MultisigAddressEntry::on_address_textChanged(const QString &address) +{ + if(!model) + return; + + // Get public key of address + CBitcoinAddress addr(address.toStdString().c_str()); + CKeyID keyID; + if(addr.GetKeyID(keyID)) + { + CPubKey vchPubKey; + model->getPubKey(keyID, vchPubKey); + std::string pubkey = HexStr(vchPubKey.Raw()); + if(!pubkey.empty()) + ui->pubkey->setText(pubkey.c_str()); + } + + // Get label of address + QString associatedLabel = model->getAddressTableModel()->labelForAddress(address); + if(!associatedLabel.isEmpty()) + ui->label->setText(associatedLabel); +} diff --git a/src/qt/multisigaddressentry.h b/src/qt/multisigaddressentry.h new file mode 100644 index 0000000..951b191 --- /dev/null +++ b/src/qt/multisigaddressentry.h @@ -0,0 +1,44 @@ +#ifndef MULTISIGADDRESSENTRY_H +#define MULTISIGADDRESSENTRY_H + +#include + + +class WalletModel; + +namespace Ui +{ + class MultisigAddressEntry; +} + +class MultisigAddressEntry : public QFrame +{ + Q_OBJECT; + + public: + explicit MultisigAddressEntry(QWidget *parent = 0); + ~MultisigAddressEntry(); + void setModel(WalletModel *model); + bool validate(); + QString getPubkey(); + + public slots: + void setRemoveEnabled(bool enabled); + void clear(); + + signals: + void removeEntry(MultisigAddressEntry *entry); + + private: + Ui::MultisigAddressEntry *ui; + WalletModel *model; + + private slots: + void on_pubkey_textChanged(const QString &pubkey); + void on_pasteButton_clicked(); + void on_deleteButton_clicked(); + void on_address_textChanged(const QString &address); + void on_addressBookButton_clicked(); +}; + +#endif // MULTISIGADDRESSENTRY_H diff --git a/src/qt/multisigdialog.cpp b/src/qt/multisigdialog.cpp new file mode 100644 index 0000000..6b43b12 --- /dev/null +++ b/src/qt/multisigdialog.cpp @@ -0,0 +1,590 @@ +#include +#include +#include +#include +#include + +#include "addresstablemodel.h" +#include "base58.h" +#include "key.h" +#include "main.h" +#include "multisigaddressentry.h" +#include "multisiginputentry.h" +#include "multisigdialog.h" +#include "ui_multisigdialog.h" +#include "script.h" +#include "sendcoinsentry.h" +#include "util.h" +#include "wallet.h" +#include "walletmodel.h" + +#include "txdb-leveldb.h" + +MultisigDialog::MultisigDialog(QWidget *parent) : QDialog(parent), ui(new Ui::MultisigDialog), model(0) +{ + ui->setupUi(this); + +#ifdef Q_WS_MAC // Icons on push buttons are very uncommon on Mac + ui->addPubKeyButton->setIcon(QIcon()); + ui->clearButton->setIcon(QIcon()); + ui->addInputButton->setIcon(QIcon()); + ui->addOutputButton->setIcon(QIcon()); + ui->signTransactionButton->setIcon(QIcon()); + ui->sendTransactionButton->setIcon(QIcon()); +#endif + + addPubKey(); + addPubKey(); + + connect(ui->addPubKeyButton, SIGNAL(clicked()), this, SLOT(addPubKey())); + connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); + + addInput(); + addOutput(); + updateAmounts(); + + connect(ui->addInputButton, SIGNAL(clicked()), this, SLOT(addInput())); + connect(ui->addOutputButton, SIGNAL(clicked()), this, SLOT(addOutput())); + + ui->signTransactionButton->setEnabled(false); + ui->sendTransactionButton->setEnabled(false); +} + +MultisigDialog::~MultisigDialog() +{ + delete ui; +} + +void MultisigDialog::setModel(WalletModel *model) +{ + this->model = model; + + for(int i = 0; i < ui->pubkeyEntries->count(); i++) + { + MultisigAddressEntry *entry = qobject_cast(ui->pubkeyEntries->itemAt(i)->widget()); + if(entry) + entry->setModel(model); + } + + + for(int i = 0; i < ui->inputs->count(); i++) + { + MultisigInputEntry *entry = qobject_cast(ui->inputs->itemAt(i)->widget()); + if(entry) + entry->setModel(model); + } + + + for(int i = 0; i < ui->outputs->count(); i++) + { + SendCoinsEntry *entry = qobject_cast(ui->outputs->itemAt(i)->widget()); + if(entry) + entry->setModel(model); + } +} + +void MultisigDialog::updateRemoveEnabled() +{ + bool enabled = (ui->pubkeyEntries->count() > 2); + + for(int i = 0; i < ui->pubkeyEntries->count(); i++) + { + MultisigAddressEntry *entry = qobject_cast(ui->pubkeyEntries->itemAt(i)->widget()); + if(entry) + entry->setRemoveEnabled(enabled); + } + + QString maxSigsStr; + maxSigsStr.setNum(ui->pubkeyEntries->count()); + ui->maxSignaturesLabel->setText(QString("/ ") + maxSigsStr); + + + enabled = (ui->inputs->count() > 1); + for(int i = 0; i < ui->inputs->count(); i++) + { + MultisigInputEntry *entry = qobject_cast(ui->inputs->itemAt(i)->widget()); + if(entry) + entry->setRemoveEnabled(enabled); + } + + + enabled = (ui->outputs->count() > 1); + for(int i = 0; i < ui->outputs->count(); i++) + { + SendCoinsEntry *entry = qobject_cast(ui->outputs->itemAt(i)->widget()); + if(entry) + entry->setRemoveEnabled(enabled); + } +} + +void MultisigDialog::on_createAddressButton_clicked() +{ + ui->multisigAddress->clear(); + ui->redeemScript->clear(); + + if(!model) + return; + + std::vector pubkeys; + pubkeys.resize(ui->pubkeyEntries->count()); + unsigned int required = ui->requiredSignatures->text().toUInt(); + CWallet *pwalletMain = model->getWallet(); + + for(int i = 0; i < ui->pubkeyEntries->count(); i++) + { + MultisigAddressEntry *entry = qobject_cast(ui->pubkeyEntries->itemAt(i)->widget()); + std::string strAddressEntered = entry->getPubkey().toUtf8().constData(); + CBitcoinAddress address(strAddressEntered); + if(pwalletMain && address.IsValid()) + { + bool fError = false; + CKeyID keyID; + if (!address.GetKeyID(keyID)) + QMessageBox::critical(this, tr("Multisig: Public key does not refer to a key!"), tr("Invalid public key: %1").arg(strAddressEntered.c_str())); + CPubKey vchPubKey; + if (!pwalletMain->GetPubKey(keyID, vchPubKey)) + QMessageBox::critical(this, tr("Multisig: No full public key for this address!"), tr("Invalid public key: %1").arg(strAddressEntered.c_str())); + if (!vchPubKey.IsFullyValid()) + { + QMessageBox::critical(this, tr("Multisig: Invalid Public Key Entered 1!"), tr("Invalid public key: %1").arg(strAddressEntered.c_str())); + fError = true; + } + if (fError) + return; + else + pubkeys[i] = vchPubKey; + } else { + if (IsHex(strAddressEntered)) + { + CPubKey vchPubKey(ParseHex(strAddressEntered)); + if (!vchPubKey.IsFullyValid()) + QMessageBox::critical(this, tr("Multisig: Invalid Public Key Entered 2!"), tr("Invalid public key: %1").arg(strAddressEntered.c_str())); + pubkeys[i] = vchPubKey; + } else { + QMessageBox::critical(this, tr("Multisig: Invalid Public Key Entered 3!"), tr("Invalid public key: %1").arg(strAddressEntered.c_str())); + } + } + } + + if((required == 0) || (required > pubkeys.size())) + return; + + CScript script = GetScriptForMultisig(required, pubkeys); + CScriptID scriptID = script.GetID(); + CBitcoinAddress address(scriptID); + std::string label("multisig"); + + LOCK(pwalletMain->cs_wallet); + if(!pwalletMain->HaveCScript(scriptID)) + pwalletMain->AddCScript(script); + if(!pwalletMain->mapAddressBook.count(address.Get())) + pwalletMain->SetAddressBookName(address.Get(), label); + + ui->multisigAddress->setText(address.ToString().c_str()); + ui->redeemScript->setText(HexStr(script.begin(), script.end()).c_str()); +} + +void MultisigDialog::on_copyMultisigAddressButton_clicked() +{ + QApplication::clipboard()->setText(ui->multisigAddress->text()); +} + +void MultisigDialog::on_copyRedeemScriptButton_clicked() +{ + QApplication::clipboard()->setText(ui->redeemScript->text()); +} + +void MultisigDialog::clear() +{ + while(ui->pubkeyEntries->count()) + delete ui->pubkeyEntries->takeAt(0)->widget(); + + addPubKey(); + addPubKey(); + updateRemoveEnabled(); +} + +MultisigAddressEntry * MultisigDialog::addPubKey() +{ + MultisigAddressEntry *entry = new MultisigAddressEntry(this); + + entry->setModel(model); + ui->pubkeyEntries->addWidget(entry); + connect(entry, SIGNAL(removeEntry(MultisigAddressEntry *)), this, SLOT(removeEntry(MultisigAddressEntry *))); + updateRemoveEnabled(); + entry->clear(); + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); + QScrollBar *bar = ui->scrollArea->verticalScrollBar(); + if(bar) + bar->setSliderPosition(bar->maximum()); + + return entry; +} + +void MultisigDialog::removeEntry(MultisigAddressEntry *entry) +{ + delete entry; + updateRemoveEnabled(); +} + +void MultisigDialog::on_createTransactionButton_clicked() +{ + CTransaction transaction; + + // Get inputs + for(int i = 0; i < ui->inputs->count(); i++) + { + MultisigInputEntry *entry = qobject_cast(ui->inputs->itemAt(i)->widget()); + if(entry) + { + if(entry->validate()) + { + CTxIn input = entry->getInput(); + transaction.vin.push_back(input); + } + else + return; + } + } + + // Get outputs + for(int i = 0; i < ui->outputs->count(); i++) + { + SendCoinsEntry *entry = qobject_cast(ui->outputs->itemAt(i)->widget()); + + if(entry) + { + if(entry->validate()) + { + SendCoinsRecipient recipient = entry->getValue(); + CBitcoinAddress address(recipient.address.toStdString()); + CScript scriptPubKey; + scriptPubKey.SetDestination(address.Get()); + CAmount amount = recipient.amount; + CTxOut output(amount, scriptPubKey); + transaction.vout.push_back(output); + } + else + return; + } + } + + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss << transaction; + ui->transaction->setText(HexStr(ss.begin(), ss.end()).c_str()); +} + +void MultisigDialog::on_transaction_textChanged() +{ + while(ui->inputs->count()) + delete ui->inputs->takeAt(0)->widget(); + while(ui->outputs->count()) + delete ui->outputs->takeAt(0)->widget(); + + if(ui->transaction->text().size() > 0) + ui->signTransactionButton->setEnabled(true); + else + ui->signTransactionButton->setEnabled(false); + + // Decode the raw transaction + std::vector txData(ParseHex(ui->transaction->text().toStdString())); + CDataStream ss(txData, SER_NETWORK, PROTOCOL_VERSION); + CTransaction tx; + try + { + ss >> tx; + } + catch(std::exception &e) + { + return; + } + + // Fill input list + int index = -1; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + uint256 prevoutHash = txin.prevout.hash; + addInput(); + index++; + MultisigInputEntry *entry = qobject_cast(ui->inputs->itemAt(index)->widget()); + if(entry) + { + entry->setTransactionId(QString(prevoutHash.GetHex().c_str())); + entry->setTransactionOutputIndex(txin.prevout.n); + } + } + + // Fill output list + index = -1; + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + CScript scriptPubKey = txout.scriptPubKey; + CTxDestination addr; + ExtractDestination(scriptPubKey, addr); + CBitcoinAddress address(addr); + SendCoinsRecipient recipient; + recipient.address = QString(address.ToString().c_str()); + recipient.amount = txout.nValue; + addOutput(); + index++; + SendCoinsEntry *entry = qobject_cast(ui->outputs->itemAt(index)->widget()); + if(entry) + { + entry->setValue(recipient); + } + } + + updateRemoveEnabled(); +} + +void MultisigDialog::on_copyTransactionButton_clicked() +{ + QApplication::clipboard()->setText(ui->transaction->text()); +} + +void MultisigDialog::on_pasteTransactionButton_clicked() +{ + ui->transaction->setText(QApplication::clipboard()->text()); +} + +void MultisigDialog::on_signTransactionButton_clicked() +{ + ui->signedTransaction->clear(); + + if(!model) + return; + + CWallet *wallet = model->getWallet(); + + // Decode the raw transaction + std::vector txData(ParseHex(ui->transaction->text().toStdString())); + CDataStream ss(txData, SER_NETWORK, PROTOCOL_VERSION); + CTransaction tx; + try + { + ss >> tx; + } + catch(std::exception &e) + { + return; + } + CTransaction mergedTx(tx); + + // Fetch previous transactions (inputs) + std::map mapPrevOut; + for(unsigned int i = 0; i < mergedTx.vin.size(); i++) + { + CTransaction tempTx; + MapPrevTx mapPrevTx; + CTxDB txdb("r"); + std::map unused; + bool fInvalid; + + tempTx.vin.push_back(mergedTx.vin[i]); + tempTx.FetchInputs(txdb, unused, false, false, mapPrevTx, fInvalid); + + BOOST_FOREACH(const CTxIn& txin, tempTx.vin) + { + const uint256& prevHash = txin.prevout.hash; + if(mapPrevTx.count(prevHash) && mapPrevTx[prevHash].second.vout.size() > txin.prevout.n) + mapPrevOut[txin.prevout] = mapPrevTx[prevHash].second.vout[txin.prevout.n].scriptPubKey; + } + } + + // Add the redeem scripts to the wallet keystore + for(int i = 0; i < ui->inputs->count(); i++) + { + MultisigInputEntry *entry = qobject_cast(ui->inputs->itemAt(i)->widget()); + if(entry) + { + QString redeemScriptStr = entry->getRedeemScript(); + if(redeemScriptStr.size() > 0) + { + std::vector scriptData(ParseHex(redeemScriptStr.toStdString())); + CScript redeemScript(scriptData.begin(), scriptData.end()); + wallet->AddCScript(redeemScript); + } + } + } + + WalletModel::UnlockContext ctx(model->requestUnlock()); + if(!ctx.isValid()) + return; + + // Sign what we can + bool fComplete = true; + for(unsigned int i = 0; i < mergedTx.vin.size(); i++) + { + CTxIn& txin = mergedTx.vin[i]; + if(mapPrevOut.count(txin.prevout) == 0) + { + fComplete = false; + continue; + } + const CScript& prevPubKey = mapPrevOut[txin.prevout]; + + txin.scriptSig.clear(); + SignSignature(*wallet, prevPubKey, mergedTx, i, SIGHASH_ALL); + txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, tx.vin[i].scriptSig); + if(!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, true, 0)) + { + fComplete = false; + } + } + + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << mergedTx; + ui->signedTransaction->setText(HexStr(ssTx.begin(), ssTx.end()).c_str()); + + if(fComplete) + { + ui->statusLabel->setText(tr("Transaction signature is complete")); + ui->sendTransactionButton->setEnabled(true); + } + else + { + ui->statusLabel->setText(tr("Transaction is NOT completely signed")); + ui->sendTransactionButton->setEnabled(false); + } +} + +void MultisigDialog::on_copySignedTransactionButton_clicked() +{ + QApplication::clipboard()->setText(ui->signedTransaction->text()); +} + +void MultisigDialog::on_sendTransactionButton_clicked() +{ + CAmount transactionSize = ui->signedTransaction->text().size() / 2; + if(transactionSize == 0) + return; + + // Check the fee + CAmount fee = (CAmount ) (ui->fee->text().toDouble() * COIN); + CAmount minFee = MIN_TX_FEE * (1 + (CAmount) transactionSize / 1000); + if(fee < minFee) + { + QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Confirm send transaction"), tr("The fee of the transaction (%1 TX) is smaller than the expected fee (%2 TX). Do you want to send the transaction anyway?").arg((double) fee / COIN).arg((double) minFee / COIN), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); + if(ret != QMessageBox::Yes) + return; + } + else if(fee > minFee) + { + QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Confirm send transaction"), tr("The fee of the transaction (%1 SONO) is bigger than the expected fee (%2 SONO). Do you want to send the transaction anyway?").arg((double) fee / COIN).arg((double) minFee / COIN), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); + if(ret != QMessageBox::Yes) + return; + } + + // Decode the raw transaction + std::vector txData(ParseHex(ui->signedTransaction->text().toStdString())); + CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); + CTransaction tx; + try + { + ssData >> tx; + } + catch(std::exception &e) + { + return; + } + uint256 txHash = tx.GetHash(); + + // Check if the transaction is already in the blockchain + CTransaction existingTx; + uint256 blockHash = 0; + if(GetTransaction(txHash, existingTx, blockHash)) + { + if(blockHash != 0) + return; + } + + // Send the transaction to the local node + //CTxDB txdb("r"); + bool fMissingInputs = false; + if(!AcceptToMemoryPool(mempool, tx, true, &fMissingInputs)) + return; + SyncWithWallets(tx, NULL, true); + //(CInv(MSG_TX, txHash), tx); + RelayTransaction(tx, txHash); +} + +MultisigInputEntry * MultisigDialog::addInput() +{ + MultisigInputEntry *entry = new MultisigInputEntry(this); + + entry->setModel(model); + ui->inputs->addWidget(entry); + connect(entry, SIGNAL(removeEntry(MultisigInputEntry *)), this, SLOT(removeEntry(MultisigInputEntry *))); + connect(entry, SIGNAL(updateAmount()), this, SLOT(updateAmounts())); + updateRemoveEnabled(); + entry->clear(); + ui->scrollAreaWidgetContents_2->resize(ui->scrollAreaWidgetContents_2->sizeHint()); + QScrollBar *bar = ui->scrollArea_2->verticalScrollBar(); + if(bar) + bar->setSliderPosition(bar->maximum()); + + return entry; +} + +void MultisigDialog::removeEntry(MultisigInputEntry *entry) +{ + delete entry; + updateRemoveEnabled(); +} + +SendCoinsEntry * MultisigDialog::addOutput() +{ + SendCoinsEntry *entry = new SendCoinsEntry(this); + + entry->setModel(model); + ui->outputs->addWidget(entry); + connect(entry, SIGNAL(removeEntry(SendCoinsEntry *)), this, SLOT(removeEntry(SendCoinsEntry *))); + connect(entry, SIGNAL(payAmountChanged()), this, SLOT(updateAmounts())); + updateRemoveEnabled(); + entry->clear(); + ui->scrollAreaWidgetContents_3->resize(ui->scrollAreaWidgetContents_3->sizeHint()); + QScrollBar *bar = ui->scrollArea_3->verticalScrollBar(); + if(bar) + bar->setSliderPosition(bar->maximum()); + + return entry; +} + +void MultisigDialog::removeEntry(SendCoinsEntry *entry) +{ + delete entry; + updateRemoveEnabled(); +} + +void MultisigDialog::updateAmounts() +{ + // Update inputs amount + CAmount inputsAmount = 0; + for(int i = 0; i < ui->inputs->count(); i++) + { + MultisigInputEntry *entry = qobject_cast(ui->inputs->itemAt(i)->widget()); + if(entry) + inputsAmount += entry->getAmount(); + } + QString inputsAmountStr; + inputsAmountStr.sprintf("%.6f", (double) inputsAmount / COIN); + ui->inputsAmount->setText(inputsAmountStr); + + // Update outputs amount + CAmount outputsAmount = 0; + for(int i = 0; i < ui->outputs->count(); i++) + { + SendCoinsEntry *entry = qobject_cast(ui->outputs->itemAt(i)->widget()); + if(entry) + outputsAmount += entry->getValue().amount; + } + QString outputsAmountStr; + outputsAmountStr.sprintf("%.6f", (double) outputsAmount / COIN); + ui->outputsAmount->setText(outputsAmountStr); + + // Update Fee amount + CAmount fee = inputsAmount - outputsAmount; + QString feeStr; + feeStr.sprintf("%.6f", (double) fee / COIN); + ui->fee->setText(feeStr); +} diff --git a/src/qt/multisigdialog.h b/src/qt/multisigdialog.h new file mode 100644 index 0000000..1fb0fa6 --- /dev/null +++ b/src/qt/multisigdialog.h @@ -0,0 +1,55 @@ +#ifndef MULTISIGDIALOG_H +#define MULTISIGDIALOG_H + +#include + +#include "multisigaddressentry.h" +#include "multisiginputentry.h" +#include "sendcoinsentry.h" +#include "walletmodel.h" + + +namespace Ui +{ + class MultisigDialog; +} + +class MultisigDialog : public QDialog +{ + Q_OBJECT; + + public: + explicit MultisigDialog(QWidget *parent); + MultisigDialog(); + void setModel(WalletModel *model); + + public slots: + MultisigAddressEntry * addPubKey(); + void clear(); + void updateRemoveEnabled(); + MultisigInputEntry * addInput(); + SendCoinsEntry * addOutput(); + + private: + Ui::MultisigDialog *ui; + WalletModel *model; + ~MultisigDialog(); + + private slots: + void on_createAddressButton_clicked(); + void on_copyMultisigAddressButton_clicked(); + void on_copyRedeemScriptButton_clicked(); + void removeEntry(MultisigAddressEntry *entry); + void on_createTransactionButton_clicked(); + void on_transaction_textChanged(); + void on_copyTransactionButton_clicked(); + void on_pasteTransactionButton_clicked(); + void on_signTransactionButton_clicked(); + void on_copySignedTransactionButton_clicked(); + void on_sendTransactionButton_clicked(); + void removeEntry(MultisigInputEntry *entry); + void removeEntry(SendCoinsEntry *entry); + void updateAmounts(); +}; + +#endif // MULTISIGDIALOG_H diff --git a/src/qt/multisiginputentry.cpp b/src/qt/multisiginputentry.cpp new file mode 100644 index 0000000..0d2b03a --- /dev/null +++ b/src/qt/multisiginputentry.cpp @@ -0,0 +1,174 @@ +#include +#include +#include +#include + +#include "base58.h" +#include "multisiginputentry.h" +#include "ui_multisiginputentry.h" +#include "main.h" +#include "script.h" +#include "util.h" +#include "wallet.h" +#include "walletmodel.h" + + +MultisigInputEntry::MultisigInputEntry(QWidget *parent) : QFrame(parent), ui(new Ui::MultisigInputEntry), model(0) +{ + ui->setupUi(this); +} + +MultisigInputEntry::~MultisigInputEntry() +{ + delete ui; +} + +void MultisigInputEntry::setModel(WalletModel *model) +{ + this->model = model; + clear(); +} + +void MultisigInputEntry::clear() +{ + ui->transactionId->clear(); + ui->transactionOutput->clear(); + ui->redeemScript->clear(); +} + +bool MultisigInputEntry::validate() +{ + return (ui->transactionOutput->count() > 0); +} + +CTxIn MultisigInputEntry::getInput() +{ + int nOutput = ui->transactionOutput->currentIndex(); + CTxIn input(COutPoint(txHash, nOutput)); + + return input; +} + +CAmount MultisigInputEntry::getAmount() +{ + CAmount amount = 0; + unsigned int nOutput = ui->transactionOutput->currentIndex(); + CTransaction tx; + uint256 blockHash = 0; + + if(GetTransaction(txHash, tx, blockHash)) + { + if(nOutput < tx.vout.size()) + { + const CTxOut& txOut = tx.vout[nOutput]; + amount = txOut.nValue; + } + } + + return amount; +} + +QString MultisigInputEntry::getRedeemScript() +{ + return ui->redeemScript->text(); +} + +void MultisigInputEntry::setTransactionId(QString transactionId) +{ + ui->transactionId->setText(transactionId); +} + +void MultisigInputEntry::setTransactionOutputIndex(int index) +{ + ui->transactionOutput->setCurrentIndex(index); +} + +void MultisigInputEntry::setRemoveEnabled(bool enabled) +{ + ui->deleteButton->setEnabled(enabled); +} + +void MultisigInputEntry::on_pasteTransactionIdButton_clicked() +{ + ui->transactionId->setText(QApplication::clipboard()->text()); +} + +void MultisigInputEntry::on_deleteButton_clicked() +{ + emit removeEntry(this); +} + +void MultisigInputEntry::on_pasteRedeemScriptButton_clicked() +{ + ui->redeemScript->setText(QApplication::clipboard()->text()); +} + +void MultisigInputEntry::on_transactionId_textChanged(const QString &transactionId) +{ + ui->transactionOutput->clear(); + if(transactionId.isEmpty()) + return; + + // Make list of transaction outputs + txHash.SetHex(transactionId.toStdString().c_str()); + CTransaction tx; + uint256 blockHash = 0; + if(!GetTransaction(txHash, tx, blockHash)) + return; + for(unsigned int i = 0; i < tx.vout.size(); i++) + { + QString idStr; + idStr.setNum(i); + const CTxOut& txOut = tx.vout[i]; + CAmount amount = txOut.nValue; + QString amountStr; + amountStr.sprintf("%.6f", (double) amount / COIN); + CScript script = txOut.scriptPubKey; + CTxDestination addr; + if(ExtractDestination(script, addr)) + { + CBitcoinAddress address(addr); + QString addressStr(address.ToString().c_str()); + ui->transactionOutput->addItem(idStr + QString(" - ") + addressStr + QString(" - ") + amountStr + QString(" SONO")); + } + else + ui->transactionOutput->addItem(idStr + QString(" - ") + amountStr + QString(" SONO")); + } +} + +void MultisigInputEntry::on_transactionOutput_currentIndexChanged(int index) +{ + if(ui->transactionOutput->itemText(index).isEmpty()) + return; + + CTransaction tx; + uint256 blockHash = 0; + if(!GetTransaction(txHash, tx, blockHash)) + return; + const CTxOut& txOut = tx.vout[index]; + CScript script = txOut.scriptPubKey; + + if(script.IsPayToScriptHash()) + { + ui->redeemScript->setEnabled(true); + + if(model) + { + // Try to find the redeem script + CTxDestination dest; + if(ExtractDestination(script, dest)) + { + CScriptID scriptID = boost::get(dest); + CScript redeemScript; + if(model->getWallet()->GetCScript(scriptID, redeemScript)) + ui->redeemScript->setText(HexStr(redeemScript.begin(), redeemScript.end()).c_str()); + } + } + } + else + { + ui->redeemScript->setEnabled(false); + } + + emit updateAmount(); +} diff --git a/src/qt/multisiginputentry.h b/src/qt/multisiginputentry.h new file mode 100644 index 0000000..0c9eb4c --- /dev/null +++ b/src/qt/multisiginputentry.h @@ -0,0 +1,54 @@ +#ifndef MULTISIGINPUTENTRY_H +#define MULTISIGINPUTENTRY_H + +#include + +#include "uint256.h" +#include "util.h" + + +class CTxIn; +class WalletModel; + +namespace Ui +{ + class MultisigInputEntry; +} + +class MultisigInputEntry : public QFrame +{ + Q_OBJECT; + + public: + explicit MultisigInputEntry(QWidget *parent = 0); + ~MultisigInputEntry(); + void setModel(WalletModel *model); + bool validate(); + CTxIn getInput(); + CAmount getAmount(); + QString getRedeemScript(); + void setTransactionId(QString transactionId); + void setTransactionOutputIndex(int index); + + public slots: + void setRemoveEnabled(bool enabled); + void clear(); + + signals: + void removeEntry(MultisigInputEntry *entry); + void updateAmount(); + + private: + Ui::MultisigInputEntry *ui; + WalletModel *model; + uint256 txHash; + + private slots: + void on_transactionId_textChanged(const QString &transactionId); + void on_pasteTransactionIdButton_clicked(); + void on_deleteButton_clicked(); + void on_transactionOutput_currentIndexChanged(int index); + void on_pasteRedeemScriptButton_clicked(); +}; + +#endif // MULTISIGINPUTENTRY_H diff --git a/src/qt/notificator.cpp b/src/qt/notificator.cpp new file mode 100644 index 0000000..5e7d45b --- /dev/null +++ b/src/qt/notificator.cpp @@ -0,0 +1,304 @@ +#include "notificator.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef USE_DBUS +#include +#include +#endif + +#ifdef Q_OS_MAC +#include +extern bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret); +#endif + +#ifdef USE_DBUS +// https://wiki.ubuntu.com/NotificationDevelopmentGuidelines recommends at least 128 +const int FREEDESKTOP_NOTIFICATION_ICON_SIZE = 128; +#endif + +Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon, QWidget *parent): + QObject(parent), + parent(parent), + programName(programName), + mode(None), + trayIcon(trayicon) +#ifdef USE_DBUS + ,interface(0) +#endif +{ + if(trayicon && trayicon->supportsMessages()) + { + mode = QSystemTray; + } +#ifdef USE_DBUS + interface = new QDBusInterface("org.freedesktop.Notifications", + "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); + if(interface->isValid()) + { + mode = Freedesktop; + } +#endif +#ifdef Q_OS_MAC + // Check if Growl is installed (based on Qt's tray icon implementation) + CFURLRef cfurl; + OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl); + if (status != kLSApplicationNotFoundErr) { + CFBundleRef bundle = CFBundleCreate(0, cfurl); + if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) { + if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/"))) + mode = Growl13; + else + mode = Growl12; + } + CFRelease(cfurl); + CFRelease(bundle); + } +#endif +} + +Notificator::~Notificator() +{ +#ifdef USE_DBUS + delete interface; +#endif +} + +#ifdef USE_DBUS + +// Loosely based on http://www.qtcentre.org/archive/index.php/t-25879.html +class FreedesktopImage +{ +public: + FreedesktopImage() {} + FreedesktopImage(const QImage &img); + + static int metaType(); + + // Image to variant that can be marshalled over DBus + static QVariant toVariant(const QImage &img); + +private: + int width, height, stride; + bool hasAlpha; + int channels; + int bitsPerSample; + QByteArray image; + + friend QDBusArgument &operator<<(QDBusArgument &a, const FreedesktopImage &i); + friend const QDBusArgument &operator>>(const QDBusArgument &a, FreedesktopImage &i); +}; + +Q_DECLARE_METATYPE(FreedesktopImage); + +// Image configuration settings +const int CHANNELS = 4; +const int BYTES_PER_PIXEL = 4; +const int BITS_PER_SAMPLE = 8; + +FreedesktopImage::FreedesktopImage(const QImage &img): + width(img.width()), + height(img.height()), + stride(img.width() * BYTES_PER_PIXEL), + hasAlpha(true), + channels(CHANNELS), + bitsPerSample(BITS_PER_SAMPLE) +{ + // Convert 00xAARRGGBB to RGBA bytewise (endian-independent) format + QImage tmp = img.convertToFormat(QImage::Format_ARGB32); + const uint32_t *data = reinterpret_cast(tmp.bits()); + + unsigned int num_pixels = width * height; + image.resize(num_pixels * BYTES_PER_PIXEL); + + for(unsigned int ptr = 0; ptr < num_pixels; ++ptr) + { + image[ptr*BYTES_PER_PIXEL+0] = data[ptr] >> 16; // R + image[ptr*BYTES_PER_PIXEL+1] = data[ptr] >> 8; // G + image[ptr*BYTES_PER_PIXEL+2] = data[ptr]; // B + image[ptr*BYTES_PER_PIXEL+3] = data[ptr] >> 24; // A + } +} + +QDBusArgument &operator<<(QDBusArgument &a, const FreedesktopImage &i) +{ + a.beginStructure(); + a << i.width << i.height << i.stride << i.hasAlpha << i.bitsPerSample << i.channels << i.image; + a.endStructure(); + return a; +} + +const QDBusArgument &operator>>(const QDBusArgument &a, FreedesktopImage &i) +{ + a.beginStructure(); + a >> i.width >> i.height >> i.stride >> i.hasAlpha >> i.bitsPerSample >> i.channels >> i.image; + a.endStructure(); + return a; +} + +int FreedesktopImage::metaType() +{ + return qDBusRegisterMetaType(); +} + +QVariant FreedesktopImage::toVariant(const QImage &img) +{ + FreedesktopImage fimg(img); + return QVariant(FreedesktopImage::metaType(), &fimg); +} + +void Notificator::notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout) +{ + Q_UNUSED(cls); + // Arguments for DBus call: + QList args; + + // Program Name: + args.append(programName); + + // Unique ID of this notification type: + args.append(0U); + + // Application Icon, empty string + args.append(QString()); + + // Summary + args.append(title); + + // Body + args.append(text); + + // Actions (none, actions are deprecated) + QStringList actions; + args.append(actions); + + // Hints + QVariantMap hints; + + // If no icon specified, set icon based on class + QIcon tmpicon; + if(icon.isNull()) + { + QStyle::StandardPixmap sicon = QStyle::SP_MessageBoxQuestion; + switch(cls) + { + case Information: sicon = QStyle::SP_MessageBoxInformation; break; + case Warning: sicon = QStyle::SP_MessageBoxWarning; break; + case Critical: sicon = QStyle::SP_MessageBoxCritical; break; + default: break; + } + tmpicon = QApplication::style()->standardIcon(sicon); + } + else + { + tmpicon = icon; + } + hints["icon_data"] = FreedesktopImage::toVariant(tmpicon.pixmap(FREEDESKTOP_NOTIFICATION_ICON_SIZE).toImage()); + args.append(hints); + + // Timeout (in msec) + args.append(millisTimeout); + + // "Fire and forget" + interface->callWithArgumentList(QDBus::NoBlock, "Notify", args); +} +#endif + +void Notificator::notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout) +{ + Q_UNUSED(icon); + QSystemTrayIcon::MessageIcon sicon = QSystemTrayIcon::NoIcon; + switch(cls) // Set icon based on class + { + case Information: sicon = QSystemTrayIcon::Information; break; + case Warning: sicon = QSystemTrayIcon::Warning; break; + case Critical: sicon = QSystemTrayIcon::Critical; break; + } + trayIcon->showMessage(title, text, sicon, millisTimeout); +} + +// Based on Qt's tray icon implementation +#ifdef Q_OS_MAC +void Notificator::notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon) +{ + const QString script( + "tell application \"%5\"\n" + " set the allNotificationsList to {\"Notification\"}\n" // -- Make a list of all the notification types (all) + " set the enabledNotificationsList to {\"Notification\"}\n" // -- Make a list of the notifications (enabled) + " register as application \"%1\" all notifications allNotificationsList default notifications enabledNotificationsList\n" // -- Register our script with Growl + " notify with name \"Notification\" title \"%2\" description \"%3\" application name \"%1\"%4\n" // -- Send a Notification + "end tell" + ); + + QString notificationApp(QApplication::applicationName()); + if (notificationApp.isEmpty()) + notificationApp = "Application"; + + QPixmap notificationIconPixmap; + if (icon.isNull()) { // If no icon specified, set icon based on class + QStyle::StandardPixmap sicon = QStyle::SP_MessageBoxQuestion; + switch (cls) + { + case Information: sicon = QStyle::SP_MessageBoxInformation; break; + case Warning: sicon = QStyle::SP_MessageBoxWarning; break; + case Critical: sicon = QStyle::SP_MessageBoxCritical; break; + } + notificationIconPixmap = QApplication::style()->standardPixmap(sicon); + } + else { + QSize size = icon.actualSize(QSize(48, 48)); + notificationIconPixmap = icon.pixmap(size); + } + + QString notificationIcon; + QTemporaryFile notificationIconFile; + if (!notificationIconPixmap.isNull() && notificationIconFile.open()) { + QImageWriter writer(¬ificationIconFile, "PNG"); + if (writer.write(notificationIconPixmap.toImage())) + notificationIcon = QString(" image from location \"file://%1\"").arg(notificationIconFile.fileName()); + } + + QString quotedTitle(title), quotedText(text); + quotedTitle.replace("\\", "\\\\").replace("\"", "\\"); + quotedText.replace("\\", "\\\\").replace("\"", "\\"); + QString growlApp(this->mode == Notificator::Growl13 ? "Growl" : "GrowlHelperApp"); + qt_mac_execute_apple_script(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon, growlApp), 0); +} +#endif + +void Notificator::notify(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout) +{ + switch(mode) + { +#ifdef USE_DBUS + case Freedesktop: + notifyDBus(cls, title, text, icon, millisTimeout); + break; +#endif + case QSystemTray: + notifySystray(cls, title, text, icon, millisTimeout); + break; +#ifdef Q_OS_MAC + case Growl12: + case Growl13: + notifyGrowl(cls, title, text, icon); + break; +#endif + default: + if(cls == Critical) + { + // Fall back to old fashioned pop-up dialog if critical and no other notification available + QMessageBox::critical(parent, title, text, QMessageBox::Ok, QMessageBox::Ok); + } + break; + } +} diff --git a/src/qt/notificator.h b/src/qt/notificator.h new file mode 100644 index 0000000..d8d3609 --- /dev/null +++ b/src/qt/notificator.h @@ -0,0 +1,69 @@ +#ifndef NOTIFICATOR_H +#define NOTIFICATOR_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QSystemTrayIcon; +#ifdef USE_DBUS +class QDBusInterface; +#endif +QT_END_NAMESPACE + +/** Cross-platform desktop notification client. */ +class Notificator: public QObject +{ + Q_OBJECT + +public: + /** Create a new notificator. + @note Ownership of trayIcon is not transferred to this object. + */ + Notificator(const QString &programName=QString(), QSystemTrayIcon *trayIcon=0, QWidget *parent=0); + ~Notificator(); + + // Message class + enum Class + { + Information, /**< Informational message */ + Warning, /**< Notify user of potential problem */ + Critical /**< An error occurred */ + }; + +public slots: + /** Show notification message. + @param[in] cls general message class + @param[in] title title shown with message + @param[in] text message content + @param[in] icon optional icon to show with message + @param[in] millisTimeout notification timeout in milliseconds (defaults to 10 seconds) + @note Platform implementations are free to ignore any of the provided fields except for \a text. + */ + void notify(Class cls, const QString &title, const QString &text, + const QIcon &icon = QIcon(), int millisTimeout = 10000); + +private: + QWidget *parent; + enum Mode { + None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */ + Freedesktop, /**< Use DBus org.freedesktop.Notifications */ + QSystemTray, /**< Use QSystemTray::showMessage */ + Growl12, /**< Use the Growl 1.2 notification system (Mac only) */ + Growl13 /**< Use the Growl 1.3 notification system (Mac only) */ + }; + QString programName; + Mode mode; + QSystemTrayIcon *trayIcon; +#ifdef USE_DBUS + QDBusInterface *interface; + + void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout); +#endif + void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout); +#ifdef Q_OS_MAC + void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon); +#endif +}; + +#endif // NOTIFICATOR_H diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp new file mode 100644 index 0000000..e1386b5 --- /dev/null +++ b/src/qt/optionsdialog.cpp @@ -0,0 +1,249 @@ +#include "optionsdialog.h" +#include "ui_optionsdialog.h" + +#include "bitcoinunits.h" +#include "monitoreddatamapper.h" +#include "netbase.h" +#include "optionsmodel.h" + +#include +#include +#include +#include + +OptionsDialog::OptionsDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::OptionsDialog), + model(0), + mapper(0), + fRestartWarningDisplayed_Proxy(false), + fRestartWarningDisplayed_Lang(false), + fProxyIpValid(true) +{ + ui->setupUi(this); + + /* Network elements init */ +#ifndef USE_UPNP + ui->mapPortUpnp->setEnabled(false); +#endif + + ui->proxyIp->setEnabled(false); + ui->proxyPort->setEnabled(false); + ui->proxyPort->setValidator(new QIntValidator(1, 65535, this)); + + connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool))); + connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool))); + connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning_Proxy())); + + ui->proxyIp->installEventFilter(this); + + /* Window elements init */ +#ifdef Q_OS_MAC + ui->tabWindow->setVisible(false); +#endif + + /* Display elements init */ + QDir translations(":translations"); + ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant("")); + foreach(const QString &langStr, translations.entryList()) + { + QLocale locale(langStr); + + /** check if the locale name consists of 2 parts (language_country) */ + if(langStr.contains("_")) + { +#if QT_VERSION >= 0x040800 + /** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */ + ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr)); +#else + /** display language strings as "language - country (locale name)", e.g. "German - Germany (de)" */ + ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" - ") + QLocale::countryToString(locale.country()) + QString(" (") + langStr + QString(")"), QVariant(langStr)); +#endif + } + else + { +#if QT_VERSION >= 0x040800 + /** display language strings as "native language (locale name)", e.g. "Deutsch (de)" */ + ui->lang->addItem(locale.nativeLanguageName() + QString(" (") + langStr + QString(")"), QVariant(langStr)); +#else + /** display language strings as "language (locale name)", e.g. "German (de)" */ + ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" (") + langStr + QString(")"), QVariant(langStr)); +#endif + } + } + + ui->unit->setModel(new BitcoinUnits(this)); + + /* Widget-to-option mapper */ + mapper = new MonitoredDataMapper(this); + mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); + mapper->setOrientation(Qt::Vertical); + + /* enable apply button when data modified */ + connect(mapper, SIGNAL(viewModified()), this, SLOT(enableApplyButton())); + /* disable apply button when new data loaded */ + connect(mapper, SIGNAL(currentIndexChanged(int)), this, SLOT(disableApplyButton())); + /* setup/change UI elements when proxy IP is invalid/valid */ + connect(this, SIGNAL(proxyIpValid(QValidatedLineEdit *, bool)), this, SLOT(handleProxyIpValid(QValidatedLineEdit *, bool))); +} + +OptionsDialog::~OptionsDialog() +{ + delete ui; +} + +void OptionsDialog::setModel(OptionsModel *model) +{ + this->model = model; + + if(model) + { + connect(model, SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); + + mapper->setModel(model); + setMapper(); + mapper->toFirst(); + } + + /* update the display unit, to not use the default ("BTC") */ + updateDisplayUnit(); + + /* warn only when language selection changes by user action (placed here so init via mapper doesn't trigger this) */ + connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning_Lang())); + + /* disable apply button after settings are loaded as there is nothing to save */ + disableApplyButton(); +} + +void OptionsDialog::setMapper() +{ + /* Main */ + mapper->addMapping(ui->transactionFee, OptionsModel::Fee); + mapper->addMapping(ui->reserveBalance, OptionsModel::ReserveBalance); + mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup); + + /* Network */ + mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP); + + mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse); + mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP); + mapper->addMapping(ui->proxyPort, OptionsModel::ProxyPort); + + /* Window */ +#ifndef Q_OS_MAC + mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray); + mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose); +#endif + + /* Display */ + mapper->addMapping(ui->lang, OptionsModel::Language); + mapper->addMapping(ui->unit, OptionsModel::DisplayUnit); + mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures); + mapper->addMapping(ui->minimizeCoinAge, OptionsModel::MinimizeCoinAge); + mapper->addMapping(ui->useBlackTheme, OptionsModel::UseBlackTheme); +} + +void OptionsDialog::enableApplyButton() +{ + ui->applyButton->setEnabled(true); +} + +void OptionsDialog::disableApplyButton() +{ + ui->applyButton->setEnabled(false); +} + +void OptionsDialog::enableSaveButtons() +{ + /* prevent enabling of the save buttons when data modified, if there is an invalid proxy address present */ + if(fProxyIpValid) + setSaveButtonState(true); +} + +void OptionsDialog::disableSaveButtons() +{ + setSaveButtonState(false); +} + +void OptionsDialog::setSaveButtonState(bool fState) +{ + ui->applyButton->setEnabled(fState); + ui->okButton->setEnabled(fState); +} + +void OptionsDialog::on_okButton_clicked() +{ + mapper->submit(); + accept(); +} + +void OptionsDialog::on_cancelButton_clicked() +{ + reject(); +} + +void OptionsDialog::on_applyButton_clicked() +{ + mapper->submit(); + disableApplyButton(); +} + +void OptionsDialog::showRestartWarning_Proxy() +{ + if(!fRestartWarningDisplayed_Proxy) + { + QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting SONO."), QMessageBox::Ok); + fRestartWarningDisplayed_Proxy = true; + } +} + +void OptionsDialog::showRestartWarning_Lang() +{ + if(!fRestartWarningDisplayed_Lang) + { + QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting SONO."), QMessageBox::Ok); + fRestartWarningDisplayed_Lang = true; + } +} + +void OptionsDialog::updateDisplayUnit() +{ + if(model) + { + /* Update transactionFee with the current unit */ + ui->transactionFee->setDisplayUnit(model->getDisplayUnit()); + } +} + +void OptionsDialog::handleProxyIpValid(QValidatedLineEdit *object, bool fState) +{ + // this is used in a check before re-enabling the save buttons + fProxyIpValid = fState; + + if(fProxyIpValid) + { + enableSaveButtons(); + ui->statusLabel->clear(); + } + else + { + disableSaveButtons(); + object->setValid(fProxyIpValid); + ui->statusLabel->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel->setText(tr("The supplied proxy address is invalid.")); + } +} + +bool OptionsDialog::eventFilter(QObject *object, QEvent *event) +{ + if(event->type() == QEvent::FocusOut) + { + if(object == ui->proxyIp) + { + CService addr; + /* Check proxyIp for a valid IPv4/IPv6 address and emit the proxyIpValid signal */ + emit proxyIpValid(ui->proxyIp, LookupNumeric(ui->proxyIp->text().toStdString().c_str(), addr)); + } + } + return QDialog::eventFilter(object, event); +} diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h new file mode 100644 index 0000000..d614339 --- /dev/null +++ b/src/qt/optionsdialog.h @@ -0,0 +1,60 @@ +#ifndef OPTIONSDIALOG_H +#define OPTIONSDIALOG_H + +#include + +namespace Ui { +class OptionsDialog; +} +class OptionsModel; +class MonitoredDataMapper; +class QValidatedLineEdit; + +/** Preferences dialog. */ +class OptionsDialog : public QDialog +{ + Q_OBJECT + +public: + explicit OptionsDialog(QWidget *parent = 0); + ~OptionsDialog(); + + void setModel(OptionsModel *model); + void setMapper(); + +protected: + bool eventFilter(QObject *object, QEvent *event); + +private slots: + /* enable only apply button */ + void enableApplyButton(); + /* disable only apply button */ + void disableApplyButton(); + /* enable apply button and OK button */ + void enableSaveButtons(); + /* disable apply button and OK button */ + void disableSaveButtons(); + /* set apply button and OK button state (enabled / disabled) */ + void setSaveButtonState(bool fState); + void on_okButton_clicked(); + void on_cancelButton_clicked(); + void on_applyButton_clicked(); + + void showRestartWarning_Proxy(); + void showRestartWarning_Lang(); + void updateDisplayUnit(); + void handleProxyIpValid(QValidatedLineEdit *object, bool fState); + +signals: + void proxyIpValid(QValidatedLineEdit *object, bool fValid); + +private: + Ui::OptionsDialog *ui; + OptionsModel *model; + MonitoredDataMapper *mapper; + bool fRestartWarningDisplayed_Proxy; + bool fRestartWarningDisplayed_Lang; + bool fProxyIpValid; +}; + +#endif // OPTIONSDIALOG_H diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp new file mode 100644 index 0000000..1ca0acf --- /dev/null +++ b/src/qt/optionsmodel.cpp @@ -0,0 +1,261 @@ +#include "optionsmodel.h" + +#include "bitcoinunits.h" +#include "init.h" +#include "wallet.h" +#include "walletdb.h" +#include "guiutil.h" + +#include + +bool fUseBlackTheme; + +OptionsModel::OptionsModel(QObject *parent) : + QAbstractListModel(parent) +{ + Init(); +} + +bool static ApplyProxySettings() +{ + QSettings settings; + CService addrProxy(settings.value("addrProxy", "127.0.0.1:9050").toString().toStdString()); + if (!settings.value("fUseProxy", false).toBool()) { + addrProxy = CService(); + return false; + } + if (!addrProxy.IsValid()) + return false; + if (!IsLimited(NET_IPV4)) + SetProxy(NET_IPV4, addrProxy); + if (!IsLimited(NET_IPV6)) + SetProxy(NET_IPV6, addrProxy); + SetNameProxy(addrProxy); + return true; +} + +void OptionsModel::Init() +{ + QSettings settings; + + // These are Qt-only settings: + nDisplayUnit = settings.value("nDisplayUnit", BitcoinUnits::BTC).toInt(); + fMinimizeToTray = settings.value("fMinimizeToTray", false).toBool(); + fMinimizeOnClose = settings.value("fMinimizeOnClose", false).toBool(); + fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool(); + nTransactionFee = settings.value("nTransactionFee").toLongLong(); + nReserveBalance = settings.value("nReserveBalance").toLongLong(); + language = settings.value("language", "").toString(); + fUseBlackTheme = settings.value("fUseBlackTheme", false).toBool(); + + if (!settings.contains("nDarksendRounds")) + settings.setValue("nDarksendRounds", 2); + + if (!settings.contains("nAnonymizeSONOAmount")) + settings.setValue("nAnonymizeSONOAmount", 1000); + + nDarksendRounds = settings.value("nDarksendRounds").toLongLong(); + nAnonymizeSONOAmount = settings.value("nAnonymizeSONOAmount").toLongLong(); + + // These are shared with core Bitcoin; we want + // command-line options to override the GUI settings: + if (settings.contains("fUseUPnP")) + SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool()); + if (settings.contains("addrProxy") && settings.value("fUseProxy").toBool()) + SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()); + if (settings.contains("fMinimizeCoinAge")) + SoftSetBoolArg("-minimizecoinage", settings.value("fMinimizeCoinAge").toBool()); + if (!language.isEmpty()) + SoftSetArg("-lang", language.toStdString()); + + if (settings.contains("nDarksendRounds")) + SoftSetArg("-darksendrounds", settings.value("nDarksendRounds").toString().toStdString()); + if (settings.contains("nAnonymizeSONOAmount")) + SoftSetArg("-anonymizeSONOamount", settings.value("nAnonymizeSONOAmount").toString().toStdString()); +} + +int OptionsModel::rowCount(const QModelIndex & parent) const +{ + return OptionIDRowCount; +} + +QVariant OptionsModel::data(const QModelIndex & index, int role) const +{ + if(role == Qt::EditRole) + { + QSettings settings; + switch(index.row()) + { + case StartAtStartup: + return QVariant(GUIUtil::GetStartOnSystemStartup()); + case MinimizeToTray: + return QVariant(fMinimizeToTray); + case MapPortUPnP: + return settings.value("fUseUPnP", GetBoolArg("-upnp", true)); + case MinimizeOnClose: + return QVariant(fMinimizeOnClose); + case ProxyUse: + return settings.value("fUseProxy", false); + case ProxyIP: { + proxyType proxy; + if (GetProxy(NET_IPV4, proxy)) + return QVariant(QString::fromStdString(proxy.ToStringIP())); + else + return QVariant(QString::fromStdString("127.0.0.1")); + } + case ProxyPort: { + proxyType proxy; + if (GetProxy(NET_IPV4, proxy)) + return QVariant(proxy.GetPort()); + else + return QVariant(9050); + } + case Fee: + return QVariant((qint64) nTransactionFee); + case ReserveBalance: + return QVariant((qint64) nReserveBalance); + case DisplayUnit: + return QVariant(nDisplayUnit); + case Language: + return settings.value("language", ""); + case CoinControlFeatures: + return QVariant(fCoinControlFeatures); + case MinimizeCoinAge: + return settings.value("fMinimizeCoinAge", GetBoolArg("-minimizecoinage", false)); + case UseBlackTheme: + return QVariant(fUseBlackTheme); + default: + return QVariant(); + } + } + return QVariant(); +} + +bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role) +{ + bool successful = true; /* set to false on parse error */ + if(role == Qt::EditRole) + { + QSettings settings; + switch(index.row()) + { + case StartAtStartup: + successful = GUIUtil::SetStartOnSystemStartup(value.toBool()); + break; + case MinimizeToTray: + fMinimizeToTray = value.toBool(); + settings.setValue("fMinimizeToTray", fMinimizeToTray); + break; + case MapPortUPnP: + settings.setValue("fUseUPnP", value.toBool()); + MapPort(value.toBool()); + break; + case MinimizeOnClose: + fMinimizeOnClose = value.toBool(); + settings.setValue("fMinimizeOnClose", fMinimizeOnClose); + break; + case ProxyUse: + settings.setValue("fUseProxy", value.toBool()); + ApplyProxySettings(); + break; + case ProxyIP: { + proxyType proxy; + proxy = CService("127.0.0.1", 9050); + GetProxy(NET_IPV4, proxy); + + CNetAddr addr(value.toString().toStdString()); + proxy.SetIP(addr); + settings.setValue("addrProxy", proxy.ToStringIPPort().c_str()); + successful = ApplyProxySettings(); + } + break; + case ProxyPort: { + proxyType proxy; + proxy = CService("127.0.0.1", 9050); + GetProxy(NET_IPV4, proxy); + + proxy.SetPort(value.toInt()); + settings.setValue("addrProxy", proxy.ToStringIPPort().c_str()); + successful = ApplyProxySettings(); + } + break; + case Fee: + nTransactionFee = value.toLongLong(); + settings.setValue("nTransactionFee", (qint64) nTransactionFee); + emit transactionFeeChanged(nTransactionFee); + break; + case ReserveBalance: + nReserveBalance = value.toLongLong(); + settings.setValue("nReserveBalance", (qint64) nReserveBalance); + emit reserveBalanceChanged(nReserveBalance); + break; + case DisplayUnit: + nDisplayUnit = value.toInt(); + settings.setValue("nDisplayUnit", nDisplayUnit); + emit displayUnitChanged(nDisplayUnit); + break; + case Language: + settings.setValue("language", value); + break; + case CoinControlFeatures: { + fCoinControlFeatures = value.toBool(); + settings.setValue("fCoinControlFeatures", fCoinControlFeatures); + emit coinControlFeaturesChanged(fCoinControlFeatures); + } + break; + case MinimizeCoinAge: + fMinimizeCoinAge = value.toBool(); + settings.setValue("fMinimizeCoinAge", fMinimizeCoinAge); + break; + case UseBlackTheme: + fUseBlackTheme = value.toBool(); + settings.setValue("fUseBlackTheme", fUseBlackTheme); + break; + case luxsendRounds: + nDarksendRounds = value.toInt(); + settings.setValue("nDarksendRounds", nDarksendRounds); + emit darksendRoundsChanged(nDarksendRounds); + break; + case anonymizeSONOAmount: + nAnonymizeSONOAmount = value.toInt(); + settings.setValue("nAnonymizeSONOAmount", nAnonymizeSONOAmount); + emit anonymizeSONOAmountChanged(nAnonymizeSONOAmount); + break; + default: + break; + } + } + emit dataChanged(index, index); + + return successful; +} + +qint64 OptionsModel::getTransactionFee() +{ + return nTransactionFee; +} + +qint64 OptionsModel::getReserveBalance() +{ + return nReserveBalance; +} + +bool OptionsModel::getCoinControlFeatures() +{ + return fCoinControlFeatures; +} + +bool OptionsModel::getMinimizeToTray() +{ + return fMinimizeToTray; +} + +bool OptionsModel::getMinimizeOnClose() +{ + return fMinimizeOnClose; +} + +int OptionsModel::getDisplayUnit() +{ + return nDisplayUnit; +} diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h new file mode 100644 index 0000000..13ef5f8 --- /dev/null +++ b/src/qt/optionsmodel.h @@ -0,0 +1,72 @@ +#ifndef OPTIONSMODEL_H +#define OPTIONSMODEL_H + +#include + +extern bool fUseBlackTheme; + +/** Interface from Qt to configuration data structure for Bitcoin client. + To Qt, the options are presented as a list with the different options + laid out vertically. + This can be changed to a tree once the settings become sufficiently + complex. + */ +class OptionsModel : public QAbstractListModel +{ + Q_OBJECT + +public: + explicit OptionsModel(QObject *parent = 0); + + enum OptionID { + StartAtStartup, // bool + MinimizeToTray, // bool + MapPortUPnP, // bool + MinimizeOnClose, // bool + ProxyUse, // bool + ProxyIP, // QString + ProxyPort, // int + Fee, // qint64 + ReserveBalance, // qint64 + DisplayUnit, // BitcoinUnits::Unit + Language, // QString + CoinControlFeatures, // bool + MinimizeCoinAge, // bool + UseBlackTheme, // bool + luxsendRounds, // int + anonymizeSONOAmount, //int + OptionIDRowCount, + }; + + void Init(); + + int rowCount(const QModelIndex & parent = QModelIndex()) const; + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); + + /* Explicit getters */ + qint64 getTransactionFee(); + qint64 getReserveBalance(); + bool getMinimizeToTray(); + bool getMinimizeOnClose(); + int getDisplayUnit(); + bool getCoinControlFeatures(); + QString getLanguage() { return language; } + +private: + int nDisplayUnit; + bool fMinimizeToTray; + bool fMinimizeOnClose; + bool fCoinControlFeatures; + QString language; + +signals: + void displayUnitChanged(int unit); + void transactionFeeChanged(qint64); + void reserveBalanceChanged(qint64); + void coinControlFeaturesChanged(bool); + void darksendRoundsChanged(int); + void anonymizeSONOAmountChanged(int); +}; + +#endif // OPTIONSMODEL_H diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp new file mode 100644 index 0000000..ed9f148 --- /dev/null +++ b/src/qt/overviewpage.cpp @@ -0,0 +1,550 @@ +#include "overviewpage.h" +#include "ui_overviewpage.h" + +#include "clientmodel.h" +#include "darksend.h" +#include "darksendconfig.h" +#include "walletmodel.h" +#include "bitcoinunits.h" +#include "optionsmodel.h" +#include "transactiontablemodel.h" +#include "transactionfilterproxy.h" +#include "txviewdelegate.h" +#include "guiutil.h" +#include "guiconstants.h" +#include "rpcserver.h" +#include "main.h" +#include "util.h" + +#include +#include +#include +#include + +#define NUM_ITEMS 6 + +OverviewPage::OverviewPage(QWidget *parent) : + QWidget(parent), + ui(new Ui::OverviewPage), + clientModel(0), + walletModel(0), + currentBalance(-1), + currentStake(0), + currentUnconfirmedBalance(-1), + currentImmatureBalance(-1), + txdelegate(new TxViewDelegate()), + filter(0) +{ + ui->setupUi(this); + + ui->frameluxsend->setVisible(true); // Hide darksend features + + //QScroller::grabGesture(ui->scrollArea, QScroller::LeftMouseButtonGesture); + //ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + // ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + // ui->columnTwoWidget->setContentsMargins(0,0,0,0); + // ui->columnTwoWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + // ui->columnTwoWidget->setMinimumWidth(300); + + // Recent transactions + ui->listTransactions->setItemDelegate(txdelegate); + ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE)); + ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2)); + ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, true); + ui->listTransactions->setMinimumWidth(350); + + connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex))); + + // init "out of sync" warning labels + ui->labelWalletStatus->setText("(" + tr("out of sync") + ")"); + ui->labelTransactionsStatus->setText("(" + tr("out of sync") + ")"); + // start with displaying the "out of sync" warnings + showOutOfSyncWarning(false); + if(GetBoolArg("-chart", true)) + { + // setup Plot + // create graph + ui->diffplot->addGraph(); + + // Argh can't get the background to work. + //QPixmap background = QPixmap(":/images/splash_testnet"); + //ui->diffplot->setBackground(background); + //ui->diffplot->setBackground(QBrush(QWidget::palette().color(this->backgroundRole()))); + + // give the axes some labels: + ui->diffplot->xAxis->setLabel("Blocks"); + ui->diffplot->yAxis->setLabel("Difficulty"); + + // set the pens + ui->diffplot->graph(0)->setPen(QPen(QColor(255, 165, 18))); + ui->diffplot->graph(0)->setLineStyle(QCPGraph::lsLine); + + // set axes label fonts: + QFont label = font(); + ui->diffplot->xAxis->setLabelFont(label); + ui->diffplot->yAxis->setLabelFont(label); + } + else + { + ui->diffplot->setVisible(true); + } + showingDarkSendMessage = 0; + darksendActionCheck = 0; + lastNewBlock = 0; + + if(fLiteMode){ + ui->frameluxsend->setVisible(false); + } else { + qDebug() << "Dark Send Status Timer"; + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(darkSendStatus())); + if(!GetBoolArg("-reindexaddr", false)) + timer->start(60000); + } + + if(fMasterNode || fLiteMode){ + ui->toggleluxsend->setText("(" + tr("Disabled") + ")"); + ui->toggleluxsend->setEnabled(false); + }else if(!fEnableluxsend){ + ui->toggleluxsend->setText(tr("Start darksend")); + } else { + ui->toggleluxsend->setText(tr("Stop darksend")); + } + + // start with displaying the "out of sync" warnings + showOutOfSyncWarning(false); + + if (fUseBlackTheme) + { + const char* whiteLabelQSS = "QLabel { color: rgb(255,255,255); }"; + ui->labelBalance->setStyleSheet(whiteLabelQSS); + ui->labelStake->setStyleSheet(whiteLabelQSS); + ui->labelUnconfirmed->setStyleSheet(whiteLabelQSS); + ui->labelImmature->setStyleSheet(whiteLabelQSS); + ui->labelTotal->setStyleSheet(whiteLabelQSS); + } +} + +void OverviewPage::updatePlot(int count) +{ + // Double Check to make sure we don't try to update the plot when it is disabled + if(!GetBoolArg("-chart", true)) { return; } + + // if(fDebug) { printf("Plot: Getting Ready: pidnexBest: %p\n", pindexBest); } + + int numLookBack = 200; + double diffMax = 0; + CBlockIndex* pindex = pindexBest; + int height = nBestHeight; + int xStart = std::max(height-numLookBack, 0) + 1; + int xEnd = height; + + // Start at the end and walk backwards + int i = numLookBack-1; + int x = xEnd; + + // This should be a noop if the size is already 2000 + vX.resize(numLookBack); + vY.resize(numLookBack); + + + if(fDebug) { + if(height != pindex->nHeight) { + printf("Plot: Warning: nBestHeight and pindexBest->nHeight don't match: %d:%d:\n", height, pindex->nHeight); + } + } + + if(fDebug) { printf("Plot: Reading blockchain\n"); } + + CBlockIndex* itr = pindex; + while(i >= 0 && itr != NULL) + { + if(fDebug) { printf("Plot: Processing block: %d - pprev: %p\n", itr->nHeight, itr->pprev); } + vX[i] = itr->nHeight; + vY[i] = GetDifficulty(itr); + diffMax = std::max(diffMax, vY[i]); + + itr = itr->pprev; + i--; + x--; + } + + if(fDebug) { printf("Plot: Drawing plot\n"); } + + ui->diffplot->graph(0)->setData(vX, vY); + + // set axes ranges, so we see all data: + ui->diffplot->xAxis->setRange((double)xStart, (double)xEnd); + ui->diffplot->yAxis->setRange(0, diffMax+(diffMax/10)); + + ui->diffplot->xAxis->setAutoSubTicks(true); + ui->diffplot->yAxis->setAutoSubTicks(true); + ui->diffplot->xAxis->setSubTickCount(0); + ui->diffplot->yAxis->setSubTickCount(0); + + ui->diffplot->replot(); + + if(fDebug) { printf("Plot: Done!\n"); } +} + + +void OverviewPage::handleTransactionClicked(const QModelIndex &index) +{ + if(filter) + emit transactionClicked(filter->mapToSource(index)); +} + +OverviewPage::~OverviewPage() +{ + delete ui; +} + +void OverviewPage::setBalance(qint64 balance, qint64 stake, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance) +{ + int unit = walletModel->getOptionsModel()->getDisplayUnit(); + currentBalance = balance; + currentStake = stake; + currentUnconfirmedBalance = unconfirmedBalance; + currentImmatureBalance = immatureBalance; + currentAnonymizedBalance = anonymizedBalance; + ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance)); + ui->labelStake->setText(BitcoinUnits::formatWithUnit(unit, stake)); + ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, unconfirmedBalance)); + ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, immatureBalance)); + ui->labelTotal->setText(BitcoinUnits::formatWithUnit(unit, balance + stake + unconfirmedBalance + immatureBalance)); + ui->labelAnonymized->setText(BitcoinUnits::formatWithUnit(unit, anonymizedBalance)); + + // only show immature (newly mined) balance if it's non-zero, so as not to complicate things + // for the non-mining users + bool showImmature = immatureBalance != 0; + ui->labelImmature->setVisible(showImmature); + ui->labelImmatureText->setVisible(showImmature); + + if(cachedTxLocks != nCompleteTXLocks){ + cachedTxLocks = nCompleteTXLocks; + ui->listTransactions->update(); + } +} + +void OverviewPage::setClientModel(ClientModel *model) +{ + this->clientModel = model; + if(model) + { + // Show warning if this is a prerelease version + connect(model, SIGNAL(alertsChanged(QString)), this, SLOT(updateAlerts(QString))); + connect(model, SIGNAL(numBlocksChanged(int)), this, SLOT(updatePlot(int))); + updateAlerts(model->getStatusBarWarnings()); + } +} + +void OverviewPage::setWalletModel(WalletModel *model) +{ + this->walletModel = model; + if(model && model->getOptionsModel()) + { + // Set up transaction list + filter = new TransactionFilterProxy(); + filter->setSourceModel(model->getTransactionTableModel()); + filter->setLimit(NUM_ITEMS); + filter->setDynamicSortFilter(true); + filter->setSortRole(Qt::EditRole); + filter->setShowInactive(false); + filter->sort(TransactionTableModel::Status, Qt::DescendingOrder); + + ui->listTransactions->setModel(filter); + ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress); + + // Keep up to date with wallet + setBalance(model->getBalance(), model->getStake(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance()); + connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64, qint64))); + + connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); + + connect(ui->darksendAuto, SIGNAL(clicked()), this, SLOT(darksendAuto())); + connect(ui->darksendReset, SIGNAL(clicked()), this, SLOT(darksendReset())); + connect(ui->toggleluxsend, SIGNAL(clicked()), this, SLOT(toggleluxsend())); + } + + // update the display unit, to not use the default ("BTC") + updateDisplayUnit(); +} + +void OverviewPage::updateDisplayUnit() +{ + if(walletModel && walletModel->getOptionsModel()) + { + if(currentBalance != -1) + setBalance(currentBalance, walletModel->getStake(), currentUnconfirmedBalance, currentImmatureBalance, currentAnonymizedBalance); + + // Update txdelegate->unit with the current unit + txdelegate->unit = walletModel->getOptionsModel()->getDisplayUnit(); + + ui->listTransactions->update(); + } +} + +void OverviewPage::updateAlerts(const QString &warnings) +{ + this->ui->labelAlerts->setVisible(!warnings.isEmpty()); + this->ui->labelAlerts->setText(warnings); +} + +void OverviewPage::showOutOfSyncWarning(bool fShow) +{ + ui->labelWalletStatus->setVisible(fShow); + ui->labelTransactionsStatus->setVisible(fShow); +} + + + +void OverviewPage::updateluxsendProgress() +{ + qDebug() << "updateluxsendProgress()"; + if(IsInitialBlockDownload()) return; + + qDebug() << "updateluxsendProgress() getbalance"; + int64_t nBalance = pwalletMain->GetBalance(); + if(nBalance == 0) + { + ui->darksendProgress->setValue(0); + QString s(tr("No inputs detected")); + ui->darksendProgress->setToolTip(s); + return; + } + + //get denominated unconfirmed inputs + if(pwalletMain->GetDenominatedBalance(true, true) > 0) + { + QString s(tr("Found unconfirmed denominated outputs, will wait till they confirm to recalculate.")); + ui->darksendProgress->setToolTip(s); + return; + } + + //Get the anon threshold + int64_t nMaxToAnonymize = nAnonymizeSONOAmount*COIN; + + // If it's more than the wallet amount, limit to that. + if(nMaxToAnonymize > nBalance) nMaxToAnonymize = nBalance; + + if(nMaxToAnonymize == 0) return; + + // calculate parts of the progress, each of them shouldn't be higher than 1: + // mixing progress of denominated balance + int64_t denominatedBalance = pwalletMain->GetDenominatedBalance(); + float denomPart = 0; + if(denominatedBalance > 0) + { + denomPart = (float)pwalletMain->GetNormalizedAnonymizedBalance() / pwalletMain->GetDenominatedBalance(); + denomPart = denomPart > 1 ? 1 : denomPart; + } + + // % of fully anonymized balance + float anonPart = 0; + if(nMaxToAnonymize > 0) + { + anonPart = (float)pwalletMain->GetAnonymizedBalance() / nMaxToAnonymize; + // if anonPart is > 1 then we are done, make denomPart equal 1 too + anonPart = anonPart > 1 ? (denomPart = 1, 1) : anonPart; + } + + // apply some weights to them (sum should be <=100) and calculate the whole progress + int progress = 80 * denomPart + 20 * anonPart; + if(progress > 100) progress = 100; + + ui->darksendProgress->setValue(progress); + + std::ostringstream convert; + convert << "Progress: " << progress << "%, inputs have an average of " << pwalletMain->GetAverageAnonymizedRounds() << " of " << nDarksendRounds << " rounds"; + QString s(convert.str().c_str()); + ui->darksendProgress->setToolTip(s); +} + + +void OverviewPage::darkSendStatus() +{ + int nBestHeight = pindexBest->nHeight; + + if(nBestHeight != darkSendPool.cachedNumBlocks) + { + //we we're processing lots of blocks, we'll just leave + if(GetTime() - lastNewBlock < 10) return; + lastNewBlock = GetTime(); + + updateluxsendProgress(); + + QString strSettings(" " + tr("Rounds")); + strSettings.prepend(QString::number(nDarksendRounds)).prepend(" / "); + strSettings.prepend(BitcoinUnits::formatWithUnit( + walletModel->getOptionsModel()->getDisplayUnit(), + nAnonymizeSONOAmount * COIN) + ); + + ui->labelAmountRounds->setText(strSettings); + } + + if(!fEnableluxsend) { + if(nBestHeight != darkSendPool.cachedNumBlocks) + { + darkSendPool.cachedNumBlocks = nBestHeight; + + ui->darksendEnabled->setText(tr("Disabled")); + ui->darksendStatus->setText(""); + ui->toggleluxsend->setText(tr("Start darksend")); + } + + return; + } + + // check darksend status and unlock if needed + if(nBestHeight != darkSendPool.cachedNumBlocks) + { + // Balance and number of transactions might have changed + darkSendPool.cachedNumBlocks = nBestHeight; + + /* *******************************************************/ + + ui->darksendEnabled->setText(tr("Enabled")); + } + + int state = darkSendPool.GetState(); + int entries = darkSendPool.GetEntriesCount(); + int accepted = darkSendPool.GetLastEntryAccepted(); + + /* ** @TODO this string creation really needs some clean ups ---vertoe ** */ + std::ostringstream convert; + + if(state == POOL_STATUS_ACCEPTING_ENTRIES) { + if(entries == 0) { + if(darkSendPool.strAutoDenomResult.size() == 0){ + convert << tr("darksend is idle.").toStdString(); + } else { + convert << darkSendPool.strAutoDenomResult; + } + showingDarkSendMessage = 0; + } else if (accepted == 1) { + convert << tr("darksend request complete: Your transaction was accepted into the pool!").toStdString(); + if(showingDarkSendMessage % 10 > 8) { + darkSendPool.lastEntryAccepted = 0; + showingDarkSendMessage = 0; + } + } else { + if(showingDarkSendMessage % 70 <= 40) convert << tr("Submitted following entries to masternode:").toStdString() << " " << entries << "/" << darkSendPool.GetMaxPoolTransactions(); + else if(showingDarkSendMessage % 70 <= 50) convert << tr("Submitted to masternode, Waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) ."; + else if(showingDarkSendMessage % 70 <= 60) convert << tr("Submitted to masternode, Waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) .."; + else if(showingDarkSendMessage % 70 <= 70) convert << tr("Submitted to masternode, Waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) ..."; + } + } else if(state == POOL_STATUS_SIGNING) { + if(showingDarkSendMessage % 70 <= 10) convert << tr("Found enough users, signing ...").toStdString(); + else if(showingDarkSendMessage % 70 <= 20) convert << tr("Found enough users, signing ( waiting. )").toStdString(); + else if(showingDarkSendMessage % 70 <= 30) convert << tr("Found enough users, signing ( waiting.. )").toStdString(); + else if(showingDarkSendMessage % 70 <= 40) convert << tr("Found enough users, signing ( waiting... )").toStdString(); + } else if(state == POOL_STATUS_TRANSMISSION) { + convert << tr("Transmitting final transaction.").toStdString(); + } else if (state == POOL_STATUS_IDLE) { + convert << tr("darksend is idle.").toStdString(); + } else if (state == POOL_STATUS_FINALIZE_TRANSACTION) { + convert << tr("Finalizing transaction.").toStdString(); + } else if(state == POOL_STATUS_ERROR) { + convert << tr("darksend request incomplete:").toStdString() << " " << darkSendPool.lastMessage << ". " << tr("Will retry...").toStdString(); + } else if(state == POOL_STATUS_SUCCESS) { + convert << tr("darksend request complete:").toStdString() << " " << darkSendPool.lastMessage; + } else if(state == POOL_STATUS_QUEUE) { + if(showingDarkSendMessage % 70 <= 50) convert << tr("Submitted to masternode, waiting in queue .").toStdString(); + else if(showingDarkSendMessage % 70 <= 60) convert << tr("Submitted to masternode, waiting in queue ..").toStdString(); + else if(showingDarkSendMessage % 70 <= 70) convert << tr("Submitted to masternode, waiting in queue ...").toStdString(); + } else { + convert << tr("Unknown state:").toStdString() << " id = " << state; + } + + if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) darkSendPool.Check(); + + QString s(convert.str().c_str()); + s = tr("Last darksend message:\n") + s; + + if(s != ui->darksendStatus->text()) + LogPrintf("Last darksend message: %s\n", convert.str().c_str()); + + ui->darksendStatus->setText(s); + + if(darkSendPool.sessionDenom == 0){ + ui->labelSubmittedDenom->setText(tr("N/A")); + } else { + std::string out; + darkSendPool.GetDenominationsToString(darkSendPool.sessionDenom, out); + QString s2(out.c_str()); + ui->labelSubmittedDenom->setText(s2); + } + + showingDarkSendMessage++; + darksendActionCheck++; + + // Get DarkSend Denomination Status +} + +void OverviewPage::darksendAuto(){ + darkSendPool.DoAutomaticDenominating(); +} + +void OverviewPage::darksendReset(){ + darkSendPool.Reset(); + + QMessageBox::warning(this, tr("darksend"), + tr("darksend was successfully reset."), + QMessageBox::Ok, QMessageBox::Ok); +} + +void OverviewPage::toggleluxsend(){ + if(!fEnableluxsend){ + int64_t balance = pwalletMain->GetBalance(); + float minAmount = 1 * COIN; + if(balance < minAmount){ + QString strMinAmount( + BitcoinUnits::formatWithUnit( + walletModel->getOptionsModel()->getDisplayUnit(), + minAmount)); + QMessageBox::warning(this, tr("darksend"), + tr("darksend requires at least %1 to use.").arg(strMinAmount), + QMessageBox::Ok, QMessageBox::Ok); + return; + } + + // if wallet is locked, ask for a passphrase + if (walletModel->getEncryptionStatus() == WalletModel::Locked) + { + WalletModel::UnlockContext ctx(walletModel->requestUnlock()); + if(!ctx.isValid()) + { + //unlock was cancelled + darkSendPool.cachedNumBlocks = 0; + QMessageBox::warning(this, tr("darksend"), + tr("Wallet is locked and user declined to unlock. Disabling darksend."), + QMessageBox::Ok, QMessageBox::Ok); + if (fDebug) LogPrintf("Wallet is locked and user declined to unlock. Disabling darksend.\n"); + return; + } + } + + } + + darkSendPool.cachedNumBlocks = 0; + fEnableluxsend = !fEnableluxsend; + + if(!fEnableluxsend){ + ui->toggleluxsend->setText(tr("Start darksend")); + } else { + ui->toggleluxsend->setText(tr("Stop darksend")); + + /* show darksend configuration if client has defaults set */ + + if(nAnonymizeSONOAmount == 0){ + luxsendConfig dlg(this); + dlg.setModel(walletModel); + dlg.exec(); + } + + darkSendPool.DoAutomaticDenominating(); + } +} + diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h new file mode 100644 index 0000000..248d41b --- /dev/null +++ b/src/qt/overviewpage.h @@ -0,0 +1,72 @@ +#ifndef OVERVIEWPAGE_H +#define OVERVIEWPAGE_H + +#include +#include + +namespace Ui { + class OverviewPage; +} +class ClientModel; +class WalletModel; +class TxViewDelegate; +class TransactionFilterProxy; + +QT_BEGIN_NAMESPACE +class QModelIndex; +QT_END_NAMESPACE + +/** Overview ("home") page widget */ +class OverviewPage : public QWidget +{ + Q_OBJECT + +public: + explicit OverviewPage(QWidget *parent = 0); + ~OverviewPage(); + + void setClientModel(ClientModel *clientModel); + void setWalletModel(WalletModel *walletModel); + void showOutOfSyncWarning(bool fShow); + void updateluxsendProgress(); + +public slots: + void darkSendStatus(); + void setBalance(qint64 balance, qint64 stake, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance); + void updatePlot(int count); + +signals: + void transactionClicked(const QModelIndex &index); + +private: + QTimer *timer; + Ui::OverviewPage *ui; + ClientModel *clientModel; + WalletModel *walletModel; + qint64 currentBalance; + qint64 currentStake; + qint64 currentUnconfirmedBalance; + qint64 currentImmatureBalance; + qint64 currentAnonymizedBalance; + qint64 cachedTxLocks; + qint64 lastNewBlock; + QVector vX; + QVector vY; + + int showingDarkSendMessage; + int darksendActionCheck; + int cachedNumBlocks; + TxViewDelegate *txdelegate; + TransactionFilterProxy *filter; + +private slots: + void toggleluxsend(); + void darksendAuto(); + void darksendReset(); + void updateDisplayUnit(); + void handleTransactionClicked(const QModelIndex &index); + void updateAlerts(const QString &warnings); +}; + +#endif // OVERVIEWPAGE_H + diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp new file mode 100644 index 0000000..ffdffd1 --- /dev/null +++ b/src/qt/paymentserver.cpp @@ -0,0 +1,165 @@ +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include "paymentserver.h" + +#include "guiconstants.h" +#include "ui_interface.h" +#include "util.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace boost; + +const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds +const QString BITCOIN_IPC_PREFIX("SONO:"); + +// +// Create a name that is unique for: +// testnet / non-testnet +// data directory +// +static QString ipcServerName() +{ + QString name("SONOQt"); + + // Append a simple hash of the datadir + // Note that GetDataDir(true) returns a different path + // for -testnet versus main net + QString ddir(GetDataDir(true).string().c_str()); + name.append(QString::number(qHash(ddir))); + + return name; +} + +// +// This stores payment requests received before +// the main GUI window is up and ready to ask the user +// to send payment. +// +static QStringList savedPaymentRequests; + +// +// Sending to the server is done synchronously, at startup. +// If the server isn't already running, startup continues, +// and the items in savedPaymentRequest will be handled +// when uiReady() is called. +// +bool PaymentServer::ipcSendCommandLine() +{ + bool fResult = false; + + const QStringList& args = qApp->arguments(); + for (int i = 1; i < args.size(); i++) + { + if (!args[i].startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) + continue; + savedPaymentRequests.append(args[i]); + } + + foreach (const QString& arg, savedPaymentRequests) + { + QLocalSocket* socket = new QLocalSocket(); + socket->connectToServer(ipcServerName(), QIODevice::WriteOnly); + if (!socket->waitForConnected(BITCOIN_IPC_CONNECT_TIMEOUT)) + return false; + + QByteArray block; + QDataStream out(&block, QIODevice::WriteOnly); + out.setVersion(QDataStream::Qt_4_0); + out << arg; + out.device()->seek(0); + socket->write(block); + socket->flush(); + + socket->waitForBytesWritten(BITCOIN_IPC_CONNECT_TIMEOUT); + socket->disconnectFromServer(); + delete socket; + fResult = true; + } + return fResult; +} + +PaymentServer::PaymentServer(QApplication* parent) : QObject(parent), saveURIs(true) +{ + // Install global event filter to catch QFileOpenEvents on the mac (sent when you click bitcoin: links) + parent->installEventFilter(this); + + QString name = ipcServerName(); + + // Clean up old socket leftover from a crash: + QLocalServer::removeServer(name); + + uriServer = new QLocalServer(this); + + if (!uriServer->listen(name)) + qDebug() << tr("Cannot start SONO: click-to-pay handler"); + else + connect(uriServer, SIGNAL(newConnection()), this, SLOT(handleURIConnection())); +} + +bool PaymentServer::eventFilter(QObject *object, QEvent *event) +{ + // clicking on bitcoin: URLs creates FileOpen events on the Mac: + if (event->type() == QEvent::FileOpen) + { + QFileOpenEvent* fileEvent = static_cast(event); + if (!fileEvent->url().isEmpty()) + { + if (saveURIs) // Before main window is ready: + savedPaymentRequests.append(fileEvent->url().toString()); + else + emit receivedURI(fileEvent->url().toString()); + return true; + } + } + return false; +} + +void PaymentServer::uiReady() +{ + saveURIs = false; + foreach (const QString& s, savedPaymentRequests) + emit receivedURI(s); + savedPaymentRequests.clear(); +} + +void PaymentServer::handleURIConnection() +{ + QLocalSocket *clientConnection = uriServer->nextPendingConnection(); + + while (clientConnection->bytesAvailable() < (int)sizeof(quint32)) + clientConnection->waitForReadyRead(); + + connect(clientConnection, SIGNAL(disconnected()), + clientConnection, SLOT(deleteLater())); + + QDataStream in(clientConnection); + in.setVersion(QDataStream::Qt_4_0); + if (clientConnection->bytesAvailable() < (int)sizeof(quint16)) { + return; + } + QString message; + in >> message; + + if (saveURIs) + savedPaymentRequests.append(message); + else + emit receivedURI(message); +} + +void PaymentServer::setOptionsModel(OptionsModel *optionsModel) +{ + this->optionsModel = optionsModel; +} diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h new file mode 100644 index 0000000..921d9b2 --- /dev/null +++ b/src/qt/paymentserver.h @@ -0,0 +1,74 @@ +#ifndef PAYMENTSERVER_H +#define PAYMENTSERVER_H + +// +// This class handles payment requests from clicking on +// bitcoin: URIs +// +// This is somewhat tricky, because we have to deal with +// the situation where the user clicks on a link during +// startup/initialization, when the splash-screen is up +// but the main window (and the Send Coins tab) is not. +// +// So, the strategy is: +// +// Create the server, and register the event handler, +// when the application is created. Save any URIs +// received at or during startup in a list. +// +// When startup is finished and the main window is +// shown, a signal is sent to slot uiReady(), which +// emits a receivedURL() signal for any payment +// requests that happened during startup. +// +// After startup, receivedURL() happens as usual. +// +// This class has one more feature: a static +// method that finds URIs passed in the command line +// and, if a server is running in another process, +// sends them to the server. +// +#include +#include + +class OptionsModel; + +class QApplication; +class QLocalServer; + +class PaymentServer : public QObject +{ + Q_OBJECT +private: + bool saveURIs; + QLocalServer* uriServer; + +public: + // Returns true if there were URIs on the command line + // which were successfully sent to an already-running + // process. + static bool ipcSendCommandLine(); + + PaymentServer(QApplication* parent); + + bool eventFilter(QObject *object, QEvent *event); + + // OptionsModel is used for getting proxy settings and display unit + void setOptionsModel(OptionsModel *optionsModel); + +signals: + void receivedURI(QString); + +public slots: + // Signal this when the main window's UI is ready + // to display payment requests to the user + void uiReady(); + +private slots: + void handleURIConnection(); + +private: + OptionsModel *optionsModel; +}; + +#endif // PAYMENTSERVER_H diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp new file mode 100644 index 0000000..d0d0bba --- /dev/null +++ b/src/qt/peertablemodel.cpp @@ -0,0 +1,242 @@ +// Copyright (c) 2011-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "peertablemodel.h" + +#include "clientmodel.h" +#include "guiconstants.h" +#include "guiutil.h" + +#include "net.h" +#include "sync.h" + +#include +#include +#include + +bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const +{ + const CNodeStats *pLeft = &(left.nodeStats); + const CNodeStats *pRight = &(right.nodeStats); + + if (order == Qt::DescendingOrder) + std::swap(pLeft, pRight); + + switch(column) + { + case PeerTableModel::Address: + return pLeft->addrName.compare(pRight->addrName) < 0; + case PeerTableModel::Subversion: + return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0; + case PeerTableModel::Ping: + return pLeft->dPingTime < pRight->dPingTime; + } + + return false; +} + +// private implementation +class PeerTablePriv +{ +public: + /** Local cache of peer information */ + QList cachedNodeStats; + /** Column to sort nodes by */ + int sortColumn; + /** Order (ascending or descending) to sort nodes by */ + Qt::SortOrder sortOrder; + /** Index of rows by node ID */ + std::map mapNodeRows; + + /** Pull a full list of peers from vNodes into our cache */ + void refreshPeers() + { + { + TRY_LOCK(cs_vNodes, lockNodes); + if (!lockNodes) + { + // skip the refresh if we can't immediately get the lock + return; + } + cachedNodeStats.clear(); +#if QT_VERSION >= 0x040700 + cachedNodeStats.reserve(vNodes.size()); +#endif + BOOST_FOREACH(CNode* pnode, vNodes) + { + CNodeCombinedStats stats; + stats.nodeStateStats.nMisbehavior = 0; + stats.fNodeStateStatsAvailable = false; + pnode->copyStats(stats.nodeStats); + cachedNodeStats.append(stats); + } + } + + // if we can, retrieve the CNodeStateStats for each node. + { + TRY_LOCK(cs_main, lockMain); + if (lockMain) + { + BOOST_FOREACH(CNodeCombinedStats &stats, cachedNodeStats) + { + stats.fNodeStateStatsAvailable = GetNodeStateStats(stats.nodeStats.nodeid, stats.nodeStateStats); + } + } + } + + + if (sortColumn >= 0) // sort cacheNodeStats (use stable sort to prevent rows jumping around unneceesarily) + qStableSort(cachedNodeStats.begin(), cachedNodeStats.end(), NodeLessThan(sortColumn, sortOrder)); + + // build index map + mapNodeRows.clear(); + int row = 0; + BOOST_FOREACH(CNodeCombinedStats &stats, cachedNodeStats) + { + mapNodeRows.insert(std::pair(stats.nodeStats.nodeid, row++)); + } + } + + int size() + { + return cachedNodeStats.size(); + } + + CNodeCombinedStats *index(int idx) + { + if(idx >= 0 && idx < cachedNodeStats.size()) { + return &cachedNodeStats[idx]; + } else { + return 0; + } + } + +}; + +PeerTableModel::PeerTableModel(ClientModel *parent) : + QAbstractTableModel(parent), + clientModel(parent), + timer(0) +{ + columns << tr("Address/Hostname") << tr("User Agent") << tr("Ping Time"); + priv = new PeerTablePriv(); + // default to unsorted + priv->sortColumn = -1; + + // set up timer for auto refresh + timer = new QTimer(); + connect(timer, SIGNAL(timeout()), SLOT(refresh())); + timer->setInterval(MODEL_UPDATE_DELAY); + + // load initial data + refresh(); +} + +void PeerTableModel::startAutoRefresh() +{ + timer->start(); +} + +void PeerTableModel::stopAutoRefresh() +{ + timer->stop(); +} + +int PeerTableModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return priv->size(); +} + +int PeerTableModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return columns.length(); +} + +QVariant PeerTableModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid()) + return QVariant(); + + CNodeCombinedStats *rec = static_cast(index.internalPointer()); + + if(role == Qt::DisplayRole) + { + switch(index.column()) + { + case Address: + return QString::fromStdString(rec->nodeStats.addrName); + case Subversion: + return QString::fromStdString(rec->nodeStats.cleanSubVer); + case Ping: + return GUIUtil::formatPingTime(rec->nodeStats.dPingTime); + } + } + return QVariant(); +} + +QVariant PeerTableModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(orientation == Qt::Horizontal) + { + if(role == Qt::DisplayRole && section < columns.size()) + { + return columns[section]; + } + } + return QVariant(); +} + +Qt::ItemFlags PeerTableModel::flags(const QModelIndex &index) const +{ + if(!index.isValid()) + return 0; + + Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled; + return retval; +} + +QModelIndex PeerTableModel::index(int row, int column, const QModelIndex &parent) const +{ + Q_UNUSED(parent); + CNodeCombinedStats *data = priv->index(row); + + if (data) + { + return createIndex(row, column, data); + } + else + { + return QModelIndex(); + } +} + +const CNodeCombinedStats *PeerTableModel::getNodeStats(int idx) +{ + return priv->index(idx); +} + +void PeerTableModel::refresh() +{ + emit layoutAboutToBeChanged(); + priv->refreshPeers(); + emit layoutChanged(); +} + +int PeerTableModel::getRowByNodeId(NodeId nodeid) +{ + std::map::iterator it = priv->mapNodeRows.find(nodeid); + if (it == priv->mapNodeRows.end()) + return -1; + + return it->second; +} + +void PeerTableModel::sort(int column, Qt::SortOrder order) +{ + priv->sortColumn = column; + priv->sortOrder = order; + refresh(); +} diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h new file mode 100644 index 0000000..cf2e499 --- /dev/null +++ b/src/qt/peertablemodel.h @@ -0,0 +1,80 @@ +// Copyright (c) 2011-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef PEERTABLEMODEL_H +#define PEERTABLEMODEL_H + +#include "main.h" +#include "net.h" + +#include +#include + +class PeerTablePriv; +class ClientModel; + +class QTimer; + +struct CNodeCombinedStats { + CNodeStats nodeStats; + CNodeStateStats nodeStateStats; + bool fNodeStateStatsAvailable; +}; + +class NodeLessThan +{ +public: + NodeLessThan(int nColumn, Qt::SortOrder fOrder): + column(nColumn), order(fOrder) {} + bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const; + +private: + int column; + Qt::SortOrder order; +}; + +/** + Qt model providing information about connected peers, similar to the + "getpeerinfo" RPC call. Used by the rpc console UI. + */ +class PeerTableModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + explicit PeerTableModel(ClientModel *parent = 0); + const CNodeCombinedStats *getNodeStats(int idx); + int getRowByNodeId(NodeId nodeid); + void startAutoRefresh(); + void stopAutoRefresh(); + + enum ColumnIndex { + Address = 0, + Subversion = 1, + Ping = 2 + }; + + /** @name Methods overridden from QAbstractTableModel + @{*/ + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QModelIndex index(int row, int column, const QModelIndex &parent) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + void sort(int column, Qt::SortOrder order); + /*@}*/ + +public slots: + void refresh(); + +private: + ClientModel *clientModel; + QStringList columns; + PeerTablePriv *priv; + QTimer *timer; + +}; + +#endif // PEERTABLEMODEL_H \ No newline at end of file diff --git a/src/qt/plugins/mrichtexteditor/LGPL_EXCEPTION.txt b/src/qt/plugins/mrichtexteditor/LGPL_EXCEPTION.txt new file mode 100644 index 0000000..91f7f6c --- /dev/null +++ b/src/qt/plugins/mrichtexteditor/LGPL_EXCEPTION.txt @@ -0,0 +1,23 @@ +Digia Qt LGPL Exception version 1.1 + +As an additional permission to the GNU Lesser General Public License version +2.1, the object code form of a "work that uses the Library" may incorporate +material from a header file that is part of the Library. You may distribute +such object code under terms of your choice, provided that: + (i) the header files of the Library have not been modified; and + (ii) the incorporated material is limited to numerical parameters, data + structure layouts, accessors, macros, inline functions and + templates; and + (iii) you comply with the terms of Section 6 of the GNU Lesser General + Public License version 2.1. + +Moreover, you may apply this exception to a modified version of the Library, +provided that such modification does not involve copying material from the +Library into the modified Library's header files unless such material is +limited to (i) numerical parameters; (ii) data structure layouts; +(iii) accessors; and (iv) small macros, templates and inline functions of +five lines or less in length. + +Furthermore, you are not required to apply this additional permission to a +modified version of the Library. + diff --git a/src/qt/plugins/mrichtexteditor/LICENSE.LGPL b/src/qt/plugins/mrichtexteditor/LICENSE.LGPL new file mode 100644 index 0000000..1133440 --- /dev/null +++ b/src/qt/plugins/mrichtexteditor/LICENSE.LGPL @@ -0,0 +1,505 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + + diff --git a/src/qt/plugins/mrichtexteditor/README.md b/src/qt/plugins/mrichtexteditor/README.md new file mode 100644 index 0000000..e919ee2 --- /dev/null +++ b/src/qt/plugins/mrichtexteditor/README.md @@ -0,0 +1,11 @@ +# MRichTextEdit + +A simple Qt rich-text editor widget, easy to use in any Qt project. + +![Screenshot](https://github.com/Anchakor/MRichTextEditor/raw/master/example.png) + +The icons used are standard icons from theme as defined by [freedesktop.org Icon Naming Specification](http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html) (which lacks button/ordered list icons). + +The editor automatically converts plain text http(s) links and emails to html links in toHtml(). + +Courtesy of [Hobrasoft](http://www.hobrasoft.cz/). diff --git a/src/qt/plugins/mrichtexteditor/example.png b/src/qt/plugins/mrichtexteditor/example.png new file mode 100644 index 0000000..2bc545a Binary files /dev/null and b/src/qt/plugins/mrichtexteditor/example.png differ diff --git a/src/qt/plugins/mrichtexteditor/mrichtextedit.cpp b/src/qt/plugins/mrichtexteditor/mrichtextedit.cpp new file mode 100644 index 0000000..f5e99c4 --- /dev/null +++ b/src/qt/plugins/mrichtexteditor/mrichtextedit.cpp @@ -0,0 +1,468 @@ +/* +** Copyright (C) 2013 Jiří Procházka (Hobrasoft) +** Contact: http://www.hobrasoft.cz/ +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file is under the terms of the GNU Lesser General Public License +** version 2.1 as published by the Free Software Foundation and appearing +** in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the +** GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +*/ + +#include "mrichtextedit.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MRichTextEdit::MRichTextEdit(QWidget *parent) : QWidget(parent) { + setupUi(this); + m_lastBlockList = 0; + f_textedit->setTabStopWidth(40); + + connect(f_textedit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), + this, SLOT(slotCurrentCharFormatChanged(QTextCharFormat))); + connect(f_textedit, SIGNAL(cursorPositionChanged()), + this, SLOT(slotCursorPositionChanged())); + + m_fontsize_h1 = 18; + m_fontsize_h2 = 16; + m_fontsize_h3 = 14; + m_fontsize_h4 = 12; + + fontChanged(f_textedit->font()); + bgColorChanged(f_textedit->textColor()); + + // paragraph formatting + + m_paragraphItems << tr("Standard") + << tr("Heading 1") + << tr("Heading 2") + << tr("Heading 3") + << tr("Heading 4") + << tr("Monospace"); + f_paragraph->addItems(m_paragraphItems); + + connect(f_paragraph, SIGNAL(activated(int)), + this, SLOT(textStyle(int))); + + // undo & redo + + f_undo->setShortcut(QKeySequence::Undo); + f_redo->setShortcut(QKeySequence::Redo); + + connect(f_textedit->document(), SIGNAL(undoAvailable(bool)), + f_undo, SLOT(setEnabled(bool))); + connect(f_textedit->document(), SIGNAL(redoAvailable(bool)), + f_redo, SLOT(setEnabled(bool))); + + f_undo->setEnabled(f_textedit->document()->isUndoAvailable()); + f_redo->setEnabled(f_textedit->document()->isRedoAvailable()); + + connect(f_undo, SIGNAL(clicked()), f_textedit, SLOT(undo())); + connect(f_redo, SIGNAL(clicked()), f_textedit, SLOT(redo())); + + // cut, copy & paste + + f_cut->setShortcut(QKeySequence::Cut); + f_copy->setShortcut(QKeySequence::Copy); + f_paste->setShortcut(QKeySequence::Paste); + + f_cut->setEnabled(false); + f_copy->setEnabled(false); + + connect(f_cut, SIGNAL(clicked()), f_textedit, SLOT(cut())); + connect(f_copy, SIGNAL(clicked()), f_textedit, SLOT(copy())); + connect(f_paste, SIGNAL(clicked()), f_textedit, SLOT(paste())); + + connect(f_textedit, SIGNAL(copyAvailable(bool)), f_cut, SLOT(setEnabled(bool))); + connect(f_textedit, SIGNAL(copyAvailable(bool)), f_copy, SLOT(setEnabled(bool))); + +#ifndef QT_NO_CLIPBOARD + connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slotClipboardDataChanged())); +#endif + + // link + + f_link->setShortcut(Qt::CTRL + Qt::Key_L); + + connect(f_link, SIGNAL(clicked(bool)), this, SLOT(textLink(bool))); + + // bold, italic & underline + + f_bold->setShortcut(Qt::CTRL + Qt::Key_B); + f_italic->setShortcut(Qt::CTRL + Qt::Key_I); + f_underline->setShortcut(Qt::CTRL + Qt::Key_U); + + connect(f_bold, SIGNAL(clicked()), this, SLOT(textBold())); + connect(f_italic, SIGNAL(clicked()), this, SLOT(textItalic())); + connect(f_underline, SIGNAL(clicked()), this, SLOT(textUnderline())); + connect(f_strikeout, SIGNAL(clicked()), this, SLOT(textStrikeout())); + + // lists + + f_list_bullet->setShortcut(Qt::CTRL + Qt::Key_Minus); + f_list_ordered->setShortcut(Qt::CTRL + Qt::Key_Equal); + + connect(f_list_bullet, SIGNAL(clicked(bool)), this, SLOT(listBullet(bool))); + connect(f_list_ordered, SIGNAL(clicked(bool)), this, SLOT(listOrdered(bool))); + + // indentation + + f_indent_dec->setShortcut(Qt::CTRL + Qt::Key_Comma); + f_indent_inc->setShortcut(Qt::CTRL + Qt::Key_Period); + + connect(f_indent_inc, SIGNAL(clicked()), this, SLOT(increaseIndentation())); + connect(f_indent_dec, SIGNAL(clicked()), this, SLOT(decreaseIndentation())); + + // font size + + QFontDatabase db; + foreach(int size, db.standardSizes()) + f_fontsize->addItem(QString::number(size)); + + connect(f_fontsize, SIGNAL(activated(QString)), + this, SLOT(textSize(QString))); + f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(QApplication::font() + .pointSize()))); + + // text background color + + QPixmap pix(16, 16); + pix.fill(QApplication::palette().background().color()); + f_bgcolor->setIcon(pix); + + connect(f_bgcolor, SIGNAL(clicked()), this, SLOT(textBgColor())); + + // images + //connect(f_image, SIGNAL(clicked()), this, SLOT(insertImage())); +} + +void MRichTextEdit::textBold() { + QTextCharFormat fmt; + fmt.setFontWeight(f_bold->isChecked() ? QFont::Bold : QFont::Normal); + mergeFormatOnWordOrSelection(fmt); +} + + +void MRichTextEdit::focusInEvent(QFocusEvent *) { + f_textedit->setFocus(Qt::TabFocusReason); +} + + +void MRichTextEdit::textUnderline() { + QTextCharFormat fmt; + fmt.setFontUnderline(f_underline->isChecked()); + mergeFormatOnWordOrSelection(fmt); +} + +void MRichTextEdit::textItalic() { + QTextCharFormat fmt; + fmt.setFontItalic(f_italic->isChecked()); + mergeFormatOnWordOrSelection(fmt); +} + +void MRichTextEdit::textStrikeout() { + QTextCharFormat fmt; + fmt.setFontStrikeOut(f_strikeout->isChecked()); + mergeFormatOnWordOrSelection(fmt); +} + +void MRichTextEdit::textSize(const QString &p) { + qreal pointSize = p.toFloat(); + if (p.toFloat() > 0) { + QTextCharFormat fmt; + fmt.setFontPointSize(pointSize); + mergeFormatOnWordOrSelection(fmt); + } +} + +void MRichTextEdit::textLink(bool checked) { + bool unlink = false; + QTextCharFormat fmt; + if (checked) { + QString url = f_textedit->currentCharFormat().anchorHref(); + bool ok; + QString newUrl = QInputDialog::getText(this, tr("Create a link"), + tr("Link URL:"), QLineEdit::Normal, + url, + &ok); + if (ok) { + fmt.setAnchor(true); + fmt.setAnchorHref(newUrl); + fmt.setForeground(QApplication::palette().color(QPalette::Link)); + fmt.setFontUnderline(true); + } else { + unlink = true; + } + } else { + unlink = true; + } + if (unlink) { + fmt.setAnchor(false); + fmt.setForeground(QApplication::palette().color(QPalette::Text)); + fmt.setFontUnderline(false); + } + mergeFormatOnWordOrSelection(fmt); +} + +void MRichTextEdit::textStyle(int index) { + QTextCursor cursor = f_textedit->textCursor(); + cursor.beginEditBlock(); + + // standard + if (!cursor.hasSelection()) { + cursor.select(QTextCursor::BlockUnderCursor); + } + QTextCharFormat fmt; + cursor.setCharFormat(fmt); + f_textedit->setCurrentCharFormat(fmt); + + if (index == ParagraphHeading1 + || index == ParagraphHeading2 + || index == ParagraphHeading3 + || index == ParagraphHeading4 ) { + if (index == ParagraphHeading1) { + fmt.setFontPointSize(m_fontsize_h1); + } + if (index == ParagraphHeading2) { + fmt.setFontPointSize(m_fontsize_h2); + } + if (index == ParagraphHeading3) { + fmt.setFontPointSize(m_fontsize_h3); + } + if (index == ParagraphHeading4) { + fmt.setFontPointSize(m_fontsize_h4); + } + if (index == ParagraphHeading2 || index == ParagraphHeading4) { + fmt.setFontItalic(true); + } + + fmt.setFontWeight(QFont::Bold); + } + if (index == ParagraphMonospace) { + fmt = cursor.charFormat(); + fmt.setFontFamily("Monospace"); + fmt.setFontStyleHint(QFont::Monospace); + fmt.setFontFixedPitch(true); + } + cursor.setCharFormat(fmt); + f_textedit->setCurrentCharFormat(fmt); + + cursor.endEditBlock(); +} + +void MRichTextEdit::textBgColor() { + QColor col = QColorDialog::getColor(f_textedit->textBackgroundColor(), this); + QTextCursor cursor = f_textedit->textCursor(); + if (!cursor.hasSelection()) { + cursor.select(QTextCursor::WordUnderCursor); + } + QTextCharFormat fmt = cursor.charFormat(); + if (col.isValid()) { + fmt.setBackground(col); + } else { + fmt.clearBackground(); + } + cursor.setCharFormat(fmt); + f_textedit->setCurrentCharFormat(fmt); + bgColorChanged(col); +} + +void MRichTextEdit::listBullet(bool checked) { + if (checked) { + f_list_ordered->setChecked(false); + } + list(checked, QTextListFormat::ListDisc); +} + +void MRichTextEdit::listOrdered(bool checked) { + if (checked) { + f_list_bullet->setChecked(false); + } + list(checked, QTextListFormat::ListDecimal); +} + +void MRichTextEdit::list(bool checked, QTextListFormat::Style style) { + QTextCursor cursor = f_textedit->textCursor(); + cursor.beginEditBlock(); + if (!checked) { + QTextBlockFormat obfmt = cursor.blockFormat(); + QTextBlockFormat bfmt; + bfmt.setIndent(obfmt.indent()); + cursor.setBlockFormat(bfmt); + } else { + QTextListFormat listFmt; + if (cursor.currentList()) { + listFmt = cursor.currentList()->format(); + } + listFmt.setStyle(style); + cursor.createList(listFmt); + } + cursor.endEditBlock(); +} + +void MRichTextEdit::mergeFormatOnWordOrSelection(const QTextCharFormat &format) { + QTextCursor cursor = f_textedit->textCursor(); + if (!cursor.hasSelection()) { + cursor.select(QTextCursor::WordUnderCursor); + } + cursor.mergeCharFormat(format); + f_textedit->mergeCurrentCharFormat(format); +} + +void MRichTextEdit::slotCursorPositionChanged() { + QTextList *l = f_textedit->textCursor().currentList(); + if (m_lastBlockList && (l == m_lastBlockList || (l != 0 && m_lastBlockList != 0 + && l->format().style() == m_lastBlockList->format().style()))) { + return; + } + m_lastBlockList = l; + if (l) { + QTextListFormat lfmt = l->format(); + if (lfmt.style() == QTextListFormat::ListDisc) { + f_list_bullet->setChecked(true); + f_list_ordered->setChecked(false); + } else if (lfmt.style() == QTextListFormat::ListDecimal) { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(true); + } else { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(false); + } + } else { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(false); + } +} + +void MRichTextEdit::fontChanged(const QFont &f) { + f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(f.pointSize()))); + f_bold->setChecked(f.bold()); + f_italic->setChecked(f.italic()); + f_underline->setChecked(f.underline()); + f_strikeout->setChecked(f.strikeOut()); + if (f.pointSize() == m_fontsize_h1) { + f_paragraph->setCurrentIndex(ParagraphHeading1); + } else if (f.pointSize() == m_fontsize_h2) { + f_paragraph->setCurrentIndex(ParagraphHeading2); + } else if (f.pointSize() == m_fontsize_h3) { + f_paragraph->setCurrentIndex(ParagraphHeading3); + } else if (f.pointSize() == m_fontsize_h4) { + f_paragraph->setCurrentIndex(ParagraphHeading4); + } else { + if (f.fixedPitch() && f.family() == "Monospace") { + f_paragraph->setCurrentIndex(ParagraphMonospace); + } else { + f_paragraph->setCurrentIndex(ParagraphStandard); + } + } + if (f_textedit->textCursor().currentList()) { + QTextListFormat lfmt = f_textedit->textCursor().currentList()->format(); + if (lfmt.style() == QTextListFormat::ListDisc) { + f_list_bullet->setChecked(true); + f_list_ordered->setChecked(false); + } else if (lfmt.style() == QTextListFormat::ListDecimal) { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(true); + } else { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(false); + } + } else { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(false); + } +} + +void MRichTextEdit::bgColorChanged(const QColor &c) { + QPixmap pix(16, 16); + if (c.isValid()) { + pix.fill(c); + } else { + pix.fill(QApplication::palette().background().color()); + } + f_bgcolor->setIcon(pix); +} + +void MRichTextEdit::slotCurrentCharFormatChanged(const QTextCharFormat &format) { + fontChanged(format.font()); + bgColorChanged((format.background().isOpaque()) ? format.background().color() : QColor()); + f_link->setChecked(format.isAnchor()); +} + +void MRichTextEdit::slotClipboardDataChanged() { +#ifndef QT_NO_CLIPBOARD + if (const QMimeData *md = QApplication::clipboard()->mimeData()) + f_paste->setEnabled(md->hasText()); +#endif +} + +QString MRichTextEdit::toHtml() const { + QString s = f_textedit->toHtml(); + // convert emails to links + s = s.replace(QRegExp("(<[^a][^>]+>(?:]+>)?|\\s)([a-zA-Z\\d]+@[a-zA-Z\\d]+\\.[a-zA-Z]+)"), "\\1\\2"); + // convert links + s = s.replace(QRegExp("(<[^a][^>]+>(?:]+>)?|\\s)((?:https?|ftp|file)://[^\\s'\"<>]+)"), "\\1\\2"); + // see also: Utils::linkify() + return s; +} + +void MRichTextEdit::increaseIndentation() { + indent(+1); +} + +void MRichTextEdit::decreaseIndentation() { + indent(-1); +} + +void MRichTextEdit::indent(int delta) { + QTextCursor cursor = f_textedit->textCursor(); + cursor.beginEditBlock(); + QTextBlockFormat bfmt = cursor.blockFormat(); + int ind = bfmt.indent(); + if (ind + delta >= 0) { + bfmt.setIndent(ind + delta); + } + cursor.setBlockFormat(bfmt); + cursor.endEditBlock(); +} + +void MRichTextEdit::setText(const QString& text) { + if (text.isEmpty()) { + setPlainText(text); + return; + } + if (text[0] == '<') { + setHtml(text); + } else { + setPlainText(text); + } +} + +void MRichTextEdit::clear() { + f_textedit->clear(); +} + + diff --git a/src/qt/plugins/mrichtexteditor/mrichtextedit.h b/src/qt/plugins/mrichtexteditor/mrichtextedit.h new file mode 100644 index 0000000..bb7c2eb --- /dev/null +++ b/src/qt/plugins/mrichtexteditor/mrichtextedit.h @@ -0,0 +1,92 @@ +/* +** Copyright (C) 2013 Jiří Procházka (Hobrasoft) +** Contact: http://www.hobrasoft.cz/ +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file is under the terms of the GNU Lesser General Public License +** version 2.1 as published by the Free Software Foundation and appearing +** in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the +** GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +*/ + +#ifndef _MRICHTEXTEDIT_H_ +#define _MRICHTEXTEDIT_H_ + +#include +#include "ui_mrichtextedit.h" + +/** + * @Brief A simple rich-text editor + */ +class MRichTextEdit : public QWidget, protected Ui::MRichTextEdit { + Q_OBJECT + public: + MRichTextEdit(QWidget *parent = 0); + + QString toPlainText() const { return f_textedit->toPlainText(); } + QString toHtml() const; + QTextDocument *document() { return f_textedit->document(); } + QTextCursor textCursor() const { return f_textedit->textCursor(); } + void setTextCursor(const QTextCursor& cursor) { f_textedit->setTextCursor(cursor); } + + + public slots: + void setText(const QString &text); + void clear(); + + protected slots: + void setPlainText(const QString &text) { f_textedit->setPlainText(text); } + void setHtml(const QString &text) { f_textedit->setHtml(text); } + void textBold(); + void textUnderline(); + void textStrikeout(); + void textItalic(); + void textSize(const QString &p); + void textLink(bool checked); + void textStyle(int index); + void textBgColor(); + void listBullet(bool checked); + void listOrdered(bool checked); + void slotCurrentCharFormatChanged(const QTextCharFormat &format); + void slotCursorPositionChanged(); + void slotClipboardDataChanged(); + void increaseIndentation(); + void decreaseIndentation(); + + protected: + void mergeFormatOnWordOrSelection(const QTextCharFormat &format); + void fontChanged(const QFont &f); + void bgColorChanged(const QColor &c); + void list(bool checked, QTextListFormat::Style style); + void indent(int delta); + void focusInEvent(QFocusEvent *event); + + QStringList m_paragraphItems; + int m_fontsize_h1; + int m_fontsize_h2; + int m_fontsize_h3; + int m_fontsize_h4; + + enum ParagraphItems { ParagraphStandard = 0, + ParagraphHeading1, + ParagraphHeading2, + ParagraphHeading3, + ParagraphHeading4, + ParagraphMonospace }; + + QPointer m_lastBlockList; +}; + +#endif diff --git a/src/qt/plugins/mrichtexteditor/mrichtextedit.ui b/src/qt/plugins/mrichtexteditor/mrichtextedit.ui new file mode 100644 index 0000000..c3b0520 --- /dev/null +++ b/src/qt/plugins/mrichtexteditor/mrichtextedit.ui @@ -0,0 +1,538 @@ + + + MRichTextEdit + + + + 0 + 0 + 819 + 312 + + + + + + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + + + + 2 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::ClickFocus + + + Paragraph formatting + + + true + + + + + + + Qt::Vertical + + + + + + + false + + + Qt::ClickFocus + + + Undo (CTRL+Z) + + + Undo + + + + + + + + + 16 + 16 + + + + + + + + false + + + Qt::ClickFocus + + + Redo + + + Redo + + + + + + + + + 16 + 16 + + + + + + + + Qt::ClickFocus + + + Cut (CTRL+X) + + + Cut + + + + + + + + + 16 + 16 + + + + + + + + Qt::ClickFocus + + + Copy (CTRL+C) + + + Copy + + + + + + + + + 16 + 16 + + + + + + + + Qt::ClickFocus + + + Paste (CTRL+V) + + + Paste + + + + + + + + + 16 + 16 + + + + + + + + Qt::Vertical + + + + + + + Qt::ClickFocus + + + Link (CTRL+L) + + + Link + + + + + + + + + 16 + 16 + + + + true + + + + + + + Qt::Vertical + + + + + + + Qt::ClickFocus + + + Bold (CTRL+B) + + + Bold + + + + + + + + + 16 + 16 + + + + true + + + + + + + Qt::ClickFocus + + + Italic (CTRL+I) + + + Italic + + + + + + + + + 16 + 16 + + + + true + + + + + + + Qt::ClickFocus + + + Underline (CTRL+U) + + + Underline + + + + + + + + + 16 + 16 + + + + true + + + + + + + Strike Out + + + true + + + + + + + Qt::Vertical + + + + + + + Qt::ClickFocus + + + Bullet list (CTRL+-) + + + Bullet list + + + + 16 + 16 + + + + true + + + + + + + Qt::ClickFocus + + + Ordered list (CTRL+=) + + + Ordered list + + + + 16 + 16 + + + + true + + + + + + + Qt::ClickFocus + + + Decrease indentation (CTRL+,) + + + Decrease indentation + + + + + + + + + 16 + 16 + + + + + + + + Qt::ClickFocus + + + Increase indentation (CTRL+.) + + + Increase indentation + + + + + + + + + 16 + 16 + + + + + + + + Qt::Vertical + + + + + + + + 16 + 16 + + + + + 16 + 16 + + + + Qt::ClickFocus + + + Text background color + + + . + + + + 16 + 16 + + + + + + + + Qt::ClickFocus + + + Font size + + + true + + + + + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + f_paragraph + line_4 + f_undo + f_redo + f_cut + f_copy + f_paste + line + f_link + line_3 + f_italic + f_underline + line_2 + f_fontsize + line_5 + f_list_bullet + f_list_ordered + f_indent_dec + f_indent_inc + f_bold + f_bgcolor + f_strikeout + line_6 + + + + + + QTextEdit::AutoNone + + + true + + + + + + + + diff --git a/src/qt/qcustomplot.cpp b/src/qt/qcustomplot.cpp new file mode 100644 index 0000000..38a7815 --- /dev/null +++ b/src/qt/qcustomplot.cpp @@ -0,0 +1,23710 @@ +/*************************************************************************** +** ** +** QCustomPlot, an easy to use, modern plotting widget for Qt ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** +** ** +** This program is free software: you can redistribute it and/or modify ** +** it under the terms of the GNU General Public License as published by ** +** the Free Software Foundation, either version 3 of the License, or ** +** (at your option) any later version. ** +** ** +** This program is distributed in the hope that it will be useful, ** +** but WITHOUT ANY WARRANTY; without even the implied warranty of ** +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** +** GNU General Public License for more details. ** +** ** +** You should have received a copy of the GNU General Public License ** +** along with this program. If not, see http://www.gnu.org/licenses/. ** +** ** +**************************************************************************** +** Author: Emanuel Eichhammer ** +** Website/Contact: http://www.qcustomplot.com/ ** +** Date: 11.10.14 ** +** Version: 1.3.0-beta ** +****************************************************************************/ + +#include "qcustomplot.h" + + + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPPainter +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPPainter + \brief QPainter subclass used internally + + This QPainter subclass is used to provide some extended functionality e.g. for tweaking position + consistency between antialiased and non-antialiased painting. Further it provides workarounds + for QPainter quirks. + + \warning This class intentionally hides non-virtual functions of QPainter, e.g. setPen, save and + restore. So while it is possible to pass a QCPPainter instance to a function that expects a + QPainter pointer, some of the workarounds and tweaks will be unavailable to the function (because + it will call the base class implementations of the functions actually hidden by QCPPainter). +*/ + +/*! + Creates a new QCPPainter instance and sets default values +*/ +QCPPainter::QCPPainter() : + QPainter(), + mModes(pmDefault), + mIsAntialiasing(false) +{ + // don't setRenderHint(QPainter::NonCosmeticDefautPen) here, because painter isn't active yet and + // a call to begin() will follow +} + +/*! + Creates a new QCPPainter instance on the specified paint \a device and sets default values. Just + like the analogous QPainter constructor, begins painting on \a device immediately. + + Like \ref begin, this method sets QPainter::NonCosmeticDefaultPen in Qt versions before Qt5. +*/ +QCPPainter::QCPPainter(QPaintDevice *device) : + QPainter(device), + mModes(pmDefault), + mIsAntialiasing(false) +{ +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions. + if (isActive()) + setRenderHint(QPainter::NonCosmeticDefaultPen); +#endif +} + +QCPPainter::~QCPPainter() +{ +} + +/*! + Sets the pen of the painter and applies certain fixes to it, depending on the mode of this + QCPPainter. + + \note this function hides the non-virtual base class implementation. +*/ +void QCPPainter::setPen(const QPen &pen) +{ + QPainter::setPen(pen); + if (mModes.testFlag(pmNonCosmetic)) + makeNonCosmetic(); +} + +/*! \overload + + Sets the pen (by color) of the painter and applies certain fixes to it, depending on the mode of + this QCPPainter. + + \note this function hides the non-virtual base class implementation. +*/ +void QCPPainter::setPen(const QColor &color) +{ + QPainter::setPen(color); + if (mModes.testFlag(pmNonCosmetic)) + makeNonCosmetic(); +} + +/*! \overload + + Sets the pen (by style) of the painter and applies certain fixes to it, depending on the mode of + this QCPPainter. + + \note this function hides the non-virtual base class implementation. +*/ +void QCPPainter::setPen(Qt::PenStyle penStyle) +{ + QPainter::setPen(penStyle); + if (mModes.testFlag(pmNonCosmetic)) + makeNonCosmetic(); +} + +/*! \overload + + Works around a Qt bug introduced with Qt 4.8 which makes drawing QLineF unpredictable when + antialiasing is disabled. Thus when antialiasing is disabled, it rounds the \a line to + integer coordinates and then passes it to the original drawLine. + + \note this function hides the non-virtual base class implementation. +*/ +void QCPPainter::drawLine(const QLineF &line) +{ + if (mIsAntialiasing || mModes.testFlag(pmVectorized)) + QPainter::drawLine(line); + else + QPainter::drawLine(line.toLine()); +} + +/*! + Sets whether painting uses antialiasing or not. Use this method instead of using setRenderHint + with QPainter::Antialiasing directly, as it allows QCPPainter to regain pixel exactness between + antialiased and non-antialiased painting (Since Qt < 5.0 uses slightly different coordinate systems for + AA/Non-AA painting). +*/ +void QCPPainter::setAntialiasing(bool enabled) +{ + setRenderHint(QPainter::Antialiasing, enabled); + if (mIsAntialiasing != enabled) + { + mIsAntialiasing = enabled; + if (!mModes.testFlag(pmVectorized)) // antialiasing half-pixel shift only needed for rasterized outputs + { + if (mIsAntialiasing) + translate(0.5, 0.5); + else + translate(-0.5, -0.5); + } + } +} + +/*! + Sets the mode of the painter. This controls whether the painter shall adjust its + fixes/workarounds optimized for certain output devices. +*/ +void QCPPainter::setModes(QCPPainter::PainterModes modes) +{ + mModes = modes; +} + +/*! + Sets the QPainter::NonCosmeticDefaultPen in Qt versions before Qt5 after beginning painting on \a + device. This is necessary to get cosmetic pen consistency across Qt versions, because since Qt5, + all pens are non-cosmetic by default, and in Qt4 this render hint must be set to get that + behaviour. + + The Constructor \ref QCPPainter(QPaintDevice *device) which directly starts painting also sets + the render hint as appropriate. + + \note this function hides the non-virtual base class implementation. +*/ +bool QCPPainter::begin(QPaintDevice *device) +{ + bool result = QPainter::begin(device); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions. + if (result) + setRenderHint(QPainter::NonCosmeticDefaultPen); +#endif + return result; +} + +/*! \overload + + Sets the mode of the painter. This controls whether the painter shall adjust its + fixes/workarounds optimized for certain output devices. +*/ +void QCPPainter::setMode(QCPPainter::PainterMode mode, bool enabled) +{ + if (!enabled && mModes.testFlag(mode)) + mModes &= ~mode; + else if (enabled && !mModes.testFlag(mode)) + mModes |= mode; +} + +/*! + Saves the painter (see QPainter::save). Since QCPPainter adds some new internal state to + QPainter, the save/restore functions are reimplemented to also save/restore those members. + + \note this function hides the non-virtual base class implementation. + + \see restore +*/ +void QCPPainter::save() +{ + mAntialiasingStack.push(mIsAntialiasing); + QPainter::save(); +} + +/*! + Restores the painter (see QPainter::restore). Since QCPPainter adds some new internal state to + QPainter, the save/restore functions are reimplemented to also save/restore those members. + + \note this function hides the non-virtual base class implementation. + + \see save +*/ +void QCPPainter::restore() +{ + if (!mAntialiasingStack.isEmpty()) + mIsAntialiasing = mAntialiasingStack.pop(); + else + qDebug() << Q_FUNC_INFO << "Unbalanced save/restore"; + QPainter::restore(); +} + +/*! + Changes the pen width to 1 if it currently is 0. This function is called in the \ref setPen + overrides when the \ref pmNonCosmetic mode is set. +*/ +void QCPPainter::makeNonCosmetic() +{ + if (qFuzzyIsNull(pen().widthF())) + { + QPen p = pen(); + p.setWidth(1); + QPainter::setPen(p); + } +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPScatterStyle +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPScatterStyle + \brief Represents the visual appearance of scatter points + + This class holds information about shape, color and size of scatter points. In plottables like + QCPGraph it is used to store how scatter points shall be drawn. For example, \ref + QCPGraph::setScatterStyle takes a QCPScatterStyle instance. + + A scatter style consists of a shape (\ref setShape), a line color (\ref setPen) and possibly a + fill (\ref setBrush), if the shape provides a fillable area. Further, the size of the shape can + be controlled with \ref setSize. + + \section QCPScatterStyle-defining Specifying a scatter style + + You can set all these configurations either by calling the respective functions on an instance: + \code + QCPScatterStyle myScatter; + myScatter.setShape(QCPScatterStyle::ssCircle); + myScatter.setPen(Qt::blue); + myScatter.setBrush(Qt::white); + myScatter.setSize(5); + customPlot->graph(0)->setScatterStyle(myScatter); + \endcode + + Or you can use one of the various constructors that take different parameter combinations, making + it easy to specify a scatter style in a single call, like so: + \code + customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::blue, Qt::white, 5)); + \endcode + + \section QCPScatterStyle-undefinedpen Leaving the color/pen up to the plottable + + There are two constructors which leave the pen undefined: \ref QCPScatterStyle() and \ref + QCPScatterStyle(ScatterShape shape, double size). If those constructors are used, a call to \ref + isPenDefined will return false. It leads to scatter points that inherit the pen from the + plottable that uses the scatter style. Thus, if such a scatter style is passed to QCPGraph, the line + color of the graph (\ref QCPGraph::setPen) will be used by the scatter points. This makes + it very convenient to set up typical scatter settings: + + \code + customPlot->graph(0)->setScatterStyle(QCPScatterStyle::ssPlus); + \endcode + + Notice that it wasn't even necessary to explicitly call a QCPScatterStyle constructor. This works + because QCPScatterStyle provides a constructor that can transform a \ref ScatterShape directly + into a QCPScatterStyle instance (that's the \ref QCPScatterStyle(ScatterShape shape, double size) + constructor with a default for \a size). In those cases, C++ allows directly supplying a \ref + ScatterShape, where actually a QCPScatterStyle is expected. + + \section QCPScatterStyle-custompath-and-pixmap Custom shapes and pixmaps + + QCPScatterStyle supports drawing custom shapes and arbitrary pixmaps as scatter points. + + For custom shapes, you can provide a QPainterPath with the desired shape to the \ref + setCustomPath function or call the constructor that takes a painter path. The scatter shape will + automatically be set to \ref ssCustom. + + For pixmaps, you call \ref setPixmap with the desired QPixmap. Alternatively you can use the + constructor that takes a QPixmap. The scatter shape will automatically be set to \ref ssPixmap. + Note that \ref setSize does not influence the appearance of the pixmap. +*/ + +/* start documentation of inline functions */ + +/*! \fn bool QCPScatterStyle::isNone() const + + Returns whether the scatter shape is \ref ssNone. + + \see setShape +*/ + +/*! \fn bool QCPScatterStyle::isPenDefined() const + + Returns whether a pen has been defined for this scatter style. + + The pen is undefined if a constructor is called that does not carry \a pen as parameter. Those are + \ref QCPScatterStyle() and \ref QCPScatterStyle(ScatterShape shape, double size). If the pen is + left undefined, the scatter color will be inherited from the plottable that uses this scatter + style. + + \see setPen +*/ + +/* end documentation of inline functions */ + +/*! + Creates a new QCPScatterStyle instance with size set to 6. No shape, pen or brush is defined. + + Since the pen is undefined (\ref isPenDefined returns false), the scatter color will be inherited + from the plottable that uses this scatter style. +*/ +QCPScatterStyle::QCPScatterStyle() : + mSize(6), + mShape(ssNone), + mPen(Qt::NoPen), + mBrush(Qt::NoBrush), + mPenDefined(false) +{ +} + +/*! + Creates a new QCPScatterStyle instance with shape set to \a shape and size to \a size. No pen or + brush is defined. + + Since the pen is undefined (\ref isPenDefined returns false), the scatter color will be inherited + from the plottable that uses this scatter style. +*/ +QCPScatterStyle::QCPScatterStyle(ScatterShape shape, double size) : + mSize(size), + mShape(shape), + mPen(Qt::NoPen), + mBrush(Qt::NoBrush), + mPenDefined(false) +{ +} + +/*! + Creates a new QCPScatterStyle instance with shape set to \a shape, the pen color set to \a color, + and size to \a size. No brush is defined, i.e. the scatter point will not be filled. +*/ +QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QColor &color, double size) : + mSize(size), + mShape(shape), + mPen(QPen(color)), + mBrush(Qt::NoBrush), + mPenDefined(true) +{ +} + +/*! + Creates a new QCPScatterStyle instance with shape set to \a shape, the pen color set to \a color, + the brush color to \a fill (with a solid pattern), and size to \a size. +*/ +QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, double size) : + mSize(size), + mShape(shape), + mPen(QPen(color)), + mBrush(QBrush(fill)), + mPenDefined(true) +{ +} + +/*! + Creates a new QCPScatterStyle instance with shape set to \a shape, the pen set to \a pen, the + brush to \a brush, and size to \a size. + + \warning In some cases it might be tempting to directly use a pen style like Qt::NoPen as \a pen + and a color like Qt::blue as \a brush. Notice however, that the corresponding call\n + QCPScatterStyle(QCPScatterShape::ssCircle, Qt::NoPen, Qt::blue, 5)\n + doesn't necessarily lead C++ to use this constructor in some cases, but might mistake + Qt::NoPen for a QColor and use the + \ref QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, double size) + constructor instead (which will lead to an unexpected look of the scatter points). To prevent + this, be more explicit with the parameter types. For example, use QBrush(Qt::blue) + instead of just Qt::blue, to clearly point out to the compiler that this constructor is + wanted. +*/ +QCPScatterStyle::QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBrush &brush, double size) : + mSize(size), + mShape(shape), + mPen(pen), + mBrush(brush), + mPenDefined(pen.style() != Qt::NoPen) +{ +} + +/*! + Creates a new QCPScatterStyle instance which will show the specified \a pixmap. The scatter shape + is set to \ref ssPixmap. +*/ +QCPScatterStyle::QCPScatterStyle(const QPixmap &pixmap) : + mSize(5), + mShape(ssPixmap), + mPen(Qt::NoPen), + mBrush(Qt::NoBrush), + mPixmap(pixmap), + mPenDefined(false) +{ +} + +/*! + Creates a new QCPScatterStyle instance with a custom shape that is defined via \a customPath. The + scatter shape is set to \ref ssCustom. + + The custom shape line will be drawn with \a pen and filled with \a brush. The size has a slightly + different meaning than for built-in scatter points: The custom path will be drawn scaled by a + factor of \a size/6.0. Since the default \a size is 6, the custom path will appear at a its + natural size by default. To double the size of the path for example, set \a size to 12. +*/ +QCPScatterStyle::QCPScatterStyle(const QPainterPath &customPath, const QPen &pen, const QBrush &brush, double size) : + mSize(size), + mShape(ssCustom), + mPen(pen), + mBrush(brush), + mCustomPath(customPath), + mPenDefined(pen.style() != Qt::NoPen) +{ +} + +/*! + Sets the size (pixel diameter) of the drawn scatter points to \a size. + + \see setShape +*/ +void QCPScatterStyle::setSize(double size) +{ + mSize = size; +} + +/*! + Sets the shape to \a shape. + + Note that the calls \ref setPixmap and \ref setCustomPath automatically set the shape to \ref + ssPixmap and \ref ssCustom, respectively. + + \see setSize +*/ +void QCPScatterStyle::setShape(QCPScatterStyle::ScatterShape shape) +{ + mShape = shape; +} + +/*! + Sets the pen that will be used to draw scatter points to \a pen. + + If the pen was previously undefined (see \ref isPenDefined), the pen is considered defined after + a call to this function, even if \a pen is Qt::NoPen. + + \see setBrush +*/ +void QCPScatterStyle::setPen(const QPen &pen) +{ + mPenDefined = true; + mPen = pen; +} + +/*! + Sets the brush that will be used to fill scatter points to \a brush. Note that not all scatter + shapes have fillable areas. For example, \ref ssPlus does not while \ref ssCircle does. + + \see setPen +*/ +void QCPScatterStyle::setBrush(const QBrush &brush) +{ + mBrush = brush; +} + +/*! + Sets the pixmap that will be drawn as scatter point to \a pixmap. + + Note that \ref setSize does not influence the appearance of the pixmap. + + The scatter shape is automatically set to \ref ssPixmap. +*/ +void QCPScatterStyle::setPixmap(const QPixmap &pixmap) +{ + setShape(ssPixmap); + mPixmap = pixmap; +} + +/*! + Sets the custom shape that will be drawn as scatter point to \a customPath. + + The scatter shape is automatically set to \ref ssCustom. +*/ +void QCPScatterStyle::setCustomPath(const QPainterPath &customPath) +{ + setShape(ssCustom); + mCustomPath = customPath; +} + +/*! + Applies the pen and the brush of this scatter style to \a painter. If this scatter style has an + undefined pen (\ref isPenDefined), sets the pen of \a painter to \a defaultPen instead. + + This function is used by plottables (or any class that wants to draw scatters) just before a + number of scatters with this style shall be drawn with the \a painter. + + \see drawShape +*/ +void QCPScatterStyle::applyTo(QCPPainter *painter, const QPen &defaultPen) const +{ + painter->setPen(mPenDefined ? mPen : defaultPen); + painter->setBrush(mBrush); +} + +/*! + Draws the scatter shape with \a painter at position \a pos. + + This function does not modify the pen or the brush on the painter, as \ref applyTo is meant to be + called before scatter points are drawn with \ref drawShape. + + \see applyTo +*/ +void QCPScatterStyle::drawShape(QCPPainter *painter, QPointF pos) const +{ + drawShape(painter, pos.x(), pos.y()); +} + +/*! \overload + Draws the scatter shape with \a painter at position \a x and \a y. +*/ +void QCPScatterStyle::drawShape(QCPPainter *painter, double x, double y) const +{ + double w = mSize/2.0; + switch (mShape) + { + case ssNone: break; + case ssDot: + { + painter->drawLine(QPointF(x, y), QPointF(x+0.0001, y)); + break; + } + case ssCross: + { + painter->drawLine(QLineF(x-w, y-w, x+w, y+w)); + painter->drawLine(QLineF(x-w, y+w, x+w, y-w)); + break; + } + case ssPlus: + { + painter->drawLine(QLineF(x-w, y, x+w, y)); + painter->drawLine(QLineF( x, y+w, x, y-w)); + break; + } + case ssCircle: + { + painter->drawEllipse(QPointF(x , y), w, w); + break; + } + case ssDisc: + { + QBrush b = painter->brush(); + painter->setBrush(painter->pen().color()); + painter->drawEllipse(QPointF(x , y), w, w); + painter->setBrush(b); + break; + } + case ssSquare: + { + painter->drawRect(QRectF(x-w, y-w, mSize, mSize)); + break; + } + case ssDiamond: + { + painter->drawLine(QLineF(x-w, y, x, y-w)); + painter->drawLine(QLineF( x, y-w, x+w, y)); + painter->drawLine(QLineF(x+w, y, x, y+w)); + painter->drawLine(QLineF( x, y+w, x-w, y)); + break; + } + case ssStar: + { + painter->drawLine(QLineF(x-w, y, x+w, y)); + painter->drawLine(QLineF( x, y+w, x, y-w)); + painter->drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.707, y+w*0.707)); + painter->drawLine(QLineF(x-w*0.707, y+w*0.707, x+w*0.707, y-w*0.707)); + break; + } + case ssTriangle: + { + painter->drawLine(QLineF(x-w, y+0.755*w, x+w, y+0.755*w)); + painter->drawLine(QLineF(x+w, y+0.755*w, x, y-0.977*w)); + painter->drawLine(QLineF( x, y-0.977*w, x-w, y+0.755*w)); + break; + } + case ssTriangleInverted: + { + painter->drawLine(QLineF(x-w, y-0.755*w, x+w, y-0.755*w)); + painter->drawLine(QLineF(x+w, y-0.755*w, x, y+0.977*w)); + painter->drawLine(QLineF( x, y+0.977*w, x-w, y-0.755*w)); + break; + } + case ssCrossSquare: + { + painter->drawLine(QLineF(x-w, y-w, x+w*0.95, y+w*0.95)); + painter->drawLine(QLineF(x-w, y+w*0.95, x+w*0.95, y-w)); + painter->drawRect(QRectF(x-w, y-w, mSize, mSize)); + break; + } + case ssPlusSquare: + { + painter->drawLine(QLineF(x-w, y, x+w*0.95, y)); + painter->drawLine(QLineF( x, y+w, x, y-w)); + painter->drawRect(QRectF(x-w, y-w, mSize, mSize)); + break; + } + case ssCrossCircle: + { + painter->drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.670, y+w*0.670)); + painter->drawLine(QLineF(x-w*0.707, y+w*0.670, x+w*0.670, y-w*0.707)); + painter->drawEllipse(QPointF(x, y), w, w); + break; + } + case ssPlusCircle: + { + painter->drawLine(QLineF(x-w, y, x+w, y)); + painter->drawLine(QLineF( x, y+w, x, y-w)); + painter->drawEllipse(QPointF(x, y), w, w); + break; + } + case ssPeace: + { + painter->drawLine(QLineF(x, y-w, x, y+w)); + painter->drawLine(QLineF(x, y, x-w*0.707, y+w*0.707)); + painter->drawLine(QLineF(x, y, x+w*0.707, y+w*0.707)); + painter->drawEllipse(QPointF(x, y), w, w); + break; + } + case ssPixmap: + { + painter->drawPixmap(x-mPixmap.width()*0.5, y-mPixmap.height()*0.5, mPixmap); + break; + } + case ssCustom: + { + QTransform oldTransform = painter->transform(); + painter->translate(x, y); + painter->scale(mSize/6.0, mSize/6.0); + painter->drawPath(mCustomPath); + painter->setTransform(oldTransform); + break; + } + } +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPLayer +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPLayer + \brief A layer that may contain objects, to control the rendering order + + The Layering system of QCustomPlot is the mechanism to control the rendering order of the + elements inside the plot. + + It is based on the two classes QCPLayer and QCPLayerable. QCustomPlot holds an ordered list of + one or more instances of QCPLayer (see QCustomPlot::addLayer, QCustomPlot::layer, + QCustomPlot::moveLayer, etc.). When replotting, QCustomPlot goes through the list of layers + bottom to top and successively draws the layerables of the layers. + + A QCPLayer contains an ordered list of QCPLayerable instances. QCPLayerable is an abstract base + class from which almost all visible objects derive, like axes, grids, graphs, items, etc. + + Initially, QCustomPlot has five layers: "background", "grid", "main", "axes" and "legend" (in + that order). The top two layers "axes" and "legend" contain the default axes and legend, so they + will be drawn on top. In the middle, there is the "main" layer. It is initially empty and set as + the current layer (see QCustomPlot::setCurrentLayer). This means, all new plottables, items etc. + are created on this layer by default. Then comes the "grid" layer which contains the QCPGrid + instances (which belong tightly to QCPAxis, see \ref QCPAxis::grid). The Axis rect background + shall be drawn behind everything else, thus the default QCPAxisRect instance is placed on the + "background" layer. Of course, the layer affiliation of the individual objects can be changed as + required (\ref QCPLayerable::setLayer). + + Controlling the ordering of objects is easy: Create a new layer in the position you want it to + be, e.g. above "main", with QCustomPlot::addLayer. Then set the current layer with + QCustomPlot::setCurrentLayer to that new layer and finally create the objects normally. They will + be placed on the new layer automatically, due to the current layer setting. Alternatively you + could have also ignored the current layer setting and just moved the objects with + QCPLayerable::setLayer to the desired layer after creating them. + + It is also possible to move whole layers. For example, If you want the grid to be shown in front + of all plottables/items on the "main" layer, just move it above "main" with + QCustomPlot::moveLayer. + + The rendering order within one layer is simply by order of creation or insertion. The item + created last (or added last to the layer), is drawn on top of all other objects on that layer. + + When a layer is deleted, the objects on it are not deleted with it, but fall on the layer below + the deleted layer, see QCustomPlot::removeLayer. +*/ + +/* start documentation of inline functions */ + +/*! \fn QList QCPLayer::children() const + + Returns a list of all layerables on this layer. The order corresponds to the rendering order: + layerables with higher indices are drawn above layerables with lower indices. +*/ + +/*! \fn int QCPLayer::index() const + + Returns the index this layer has in the QCustomPlot. The index is the integer number by which this layer can be + accessed via \ref QCustomPlot::layer. + + Layers with higher indices will be drawn above layers with lower indices. +*/ + +/* end documentation of inline functions */ + +/*! + Creates a new QCPLayer instance. + + Normally you shouldn't directly instantiate layers, use \ref QCustomPlot::addLayer instead. + + \warning It is not checked that \a layerName is actually a unique layer name in \a parentPlot. + This check is only performed by \ref QCustomPlot::addLayer. +*/ +QCPLayer::QCPLayer(QCustomPlot *parentPlot, const QString &layerName) : + QObject(parentPlot), + mParentPlot(parentPlot), + mName(layerName), + mIndex(-1), // will be set to a proper value by the QCustomPlot layer creation function + mVisible(true) +{ + // Note: no need to make sure layerName is unique, because layer + // management is done with QCustomPlot functions. +} + +QCPLayer::~QCPLayer() +{ + // If child layerables are still on this layer, detach them, so they don't try to reach back to this + // then invalid layer once they get deleted/moved themselves. This only happens when layers are deleted + // directly, like in the QCustomPlot destructor. (The regular layer removal procedure for the user is to + // call QCustomPlot::removeLayer, which moves all layerables off this layer before deleting it.) + + while (!mChildren.isEmpty()) + mChildren.last()->setLayer(0); // removes itself from mChildren via removeChild() + + if (mParentPlot->currentLayer() == this) + qDebug() << Q_FUNC_INFO << "The parent plot's mCurrentLayer will be a dangling pointer. Should have been set to a valid layer or 0 beforehand."; +} + +/*! + Sets whether this layer is visible or not. If \a visible is set to false, all layerables on this + layer will be invisible. + + This function doesn't change the visibility property of the layerables (\ref + QCPLayerable::setVisible), but the \ref QCPLayerable::realVisibility of each layerable takes the + visibility of the parent layer into account. +*/ +void QCPLayer::setVisible(bool visible) +{ + mVisible = visible; +} + +/*! \internal + + Adds the \a layerable to the list of this layer. If \a prepend is set to true, the layerable will + be prepended to the list, i.e. be drawn beneath the other layerables already in the list. + + This function does not change the \a mLayer member of \a layerable to this layer. (Use + QCPLayerable::setLayer to change the layer of an object, not this function.) + + \see removeChild +*/ +void QCPLayer::addChild(QCPLayerable *layerable, bool prepend) +{ + if (!mChildren.contains(layerable)) + { + if (prepend) + mChildren.prepend(layerable); + else + mChildren.append(layerable); + } else + qDebug() << Q_FUNC_INFO << "layerable is already child of this layer" << reinterpret_cast(layerable); +} + +/*! \internal + + Removes the \a layerable from the list of this layer. + + This function does not change the \a mLayer member of \a layerable. (Use QCPLayerable::setLayer + to change the layer of an object, not this function.) + + \see addChild +*/ +void QCPLayer::removeChild(QCPLayerable *layerable) +{ + if (!mChildren.removeOne(layerable)) + qDebug() << Q_FUNC_INFO << "layerable is not child of this layer" << reinterpret_cast(layerable); +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPLayerable +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPLayerable + \brief Base class for all drawable objects + + This is the abstract base class most visible objects derive from, e.g. plottables, axes, grid + etc. + + Every layerable is on a layer (QCPLayer) which allows controlling the rendering order by stacking + the layers accordingly. + + For details about the layering mechanism, see the QCPLayer documentation. +*/ + +/* start documentation of inline functions */ + +/*! \fn QCPLayerable *QCPLayerable::parentLayerable() const + + Returns the parent layerable of this layerable. The parent layerable is used to provide + visibility hierarchies in conjunction with the method \ref realVisibility. This way, layerables + only get drawn if their parent layerables are visible, too. + + Note that a parent layerable is not necessarily also the QObject parent for memory management. + Further, a layerable doesn't always have a parent layerable, so this function may return 0. + + A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be + set manually by the user. +*/ + +/* end documentation of inline functions */ +/* start documentation of pure virtual functions */ + +/*! \fn virtual void QCPLayerable::applyDefaultAntialiasingHint(QCPPainter *painter) const = 0 + \internal + + This function applies the default antialiasing setting to the specified \a painter, using the + function \ref applyAntialiasingHint. It is the antialiasing state the painter is put in, when + \ref draw is called on the layerable. If the layerable has multiple entities whose antialiasing + setting may be specified individually, this function should set the antialiasing state of the + most prominent entity. In this case however, the \ref draw function usually calls the specialized + versions of this function before drawing each entity, effectively overriding the setting of the + default antialiasing hint. + + First example: QCPGraph has multiple entities that have an antialiasing setting: The graph + line, fills, scatters and error bars. Those can be configured via QCPGraph::setAntialiased, + QCPGraph::setAntialiasedFill, QCPGraph::setAntialiasedScatters etc. Consequently, there isn't + only the QCPGraph::applyDefaultAntialiasingHint function (which corresponds to the graph line's + antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and + QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw + calls the respective specialized applyAntialiasingHint function. + + Second example: QCPItemLine consists only of a line so there is only one antialiasing + setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by + all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the + respective layerable subclass.) Consequently it only has the normal + QCPItemLine::applyDefaultAntialiasingHint. The \ref QCPItemLine::draw function doesn't need to + care about setting any antialiasing states, because the default antialiasing hint is already set + on the painter when the \ref draw function is called, and that's the state it wants to draw the + line with. +*/ + +/*! \fn virtual void QCPLayerable::draw(QCPPainter *painter) const = 0 + \internal + + This function draws the layerable with the specified \a painter. It is only called by + QCustomPlot, if the layerable is visible (\ref setVisible). + + Before this function is called, the painter's antialiasing state is set via \ref + applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was + set to \ref clipRect. +*/ + +/* end documentation of pure virtual functions */ +/* start documentation of signals */ + +/*! \fn void QCPLayerable::layerChanged(QCPLayer *newLayer); + + This signal is emitted when the layer of this layerable changes, i.e. this layerable is moved to + a different layer. + + \see setLayer +*/ + +/* end documentation of signals */ + +/*! + Creates a new QCPLayerable instance. + + Since QCPLayerable is an abstract base class, it can't be instantiated directly. Use one of the + derived classes. + + If \a plot is provided, it automatically places itself on the layer named \a targetLayer. If \a + targetLayer is an empty string, it places itself on the current layer of the plot (see \ref + QCustomPlot::setCurrentLayer). + + It is possible to provide 0 as \a plot. In that case, you should assign a parent plot at a later + time with \ref initializeParentPlot. + + The layerable's parent layerable is set to \a parentLayerable, if provided. Direct layerable parents + are mainly used to control visibility in a hierarchy of layerables. This means a layerable is + only drawn, if all its ancestor layerables are also visible. Note that \a parentLayerable does + not become the QObject-parent (for memory management) of this layerable, \a plot does. +*/ +QCPLayerable::QCPLayerable(QCustomPlot *plot, QString targetLayer, QCPLayerable *parentLayerable) : + QObject(plot), + mVisible(true), + mParentPlot(plot), + mParentLayerable(parentLayerable), + mLayer(0), + mAntialiased(true) +{ + if (mParentPlot) + { + if (targetLayer.isEmpty()) + setLayer(mParentPlot->currentLayer()); + else if (!setLayer(targetLayer)) + qDebug() << Q_FUNC_INFO << "setting QCPlayerable initial layer to" << targetLayer << "failed."; + } +} + +QCPLayerable::~QCPLayerable() +{ + if (mLayer) + { + mLayer->removeChild(this); + mLayer = 0; + } +} + +/*! + Sets the visibility of this layerable object. If an object is not visible, it will not be drawn + on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not + possible. +*/ +void QCPLayerable::setVisible(bool on) +{ + mVisible = on; +} + +/*! + Sets the \a layer of this layerable object. The object will be placed on top of the other objects + already on \a layer. + + Returns true on success, i.e. if \a layer is a valid layer. +*/ +bool QCPLayerable::setLayer(QCPLayer *layer) +{ + return moveToLayer(layer, false); +} + +/*! \overload + Sets the layer of this layerable object by name + + Returns true on success, i.e. if \a layerName is a valid layer name. +*/ +bool QCPLayerable::setLayer(const QString &layerName) +{ + if (!mParentPlot) + { + qDebug() << Q_FUNC_INFO << "no parent QCustomPlot set"; + return false; + } + if (QCPLayer *layer = mParentPlot->layer(layerName)) + { + return setLayer(layer); + } else + { + qDebug() << Q_FUNC_INFO << "there is no layer with name" << layerName; + return false; + } +} + +/*! + Sets whether this object will be drawn antialiased or not. + + Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and + QCustomPlot::setNotAntialiasedElements. +*/ +void QCPLayerable::setAntialiased(bool enabled) +{ + mAntialiased = enabled; +} + +/*! + Returns whether this layerable is visible, taking the visibility of the layerable parent and the + visibility of the layer this layerable is on into account. This is the method that is consulted + to decide whether a layerable shall be drawn or not. + + If this layerable has a direct layerable parent (usually set via hierarchies implemented in + subclasses, like in the case of QCPLayoutElement), this function returns true only if this + layerable has its visibility set to true and the parent layerable's \ref realVisibility returns + true. + + If this layerable doesn't have a direct layerable parent, returns the state of this layerable's + visibility. +*/ +bool QCPLayerable::realVisibility() const +{ + return mVisible && (!mLayer || mLayer->visible()) && (!mParentLayerable || mParentLayerable.data()->realVisibility()); +} + +/*! + This function is used to decide whether a click hits a layerable object or not. + + \a pos is a point in pixel coordinates on the QCustomPlot surface. This function returns the + shortest pixel distance of this point to the object. If the object is either invisible or the + distance couldn't be determined, -1.0 is returned. Further, if \a onlySelectable is true and the + object is not selectable, -1.0 is returned, too. + + If the item is represented not by single lines but by an area like QCPItemRect or QCPItemText, a + click inside the area returns a constant value greater zero (typically the selectionTolerance of + the parent QCustomPlot multiplied by 0.99). If the click lies outside the area, this function + returns -1.0. + + Providing a constant value for area objects allows selecting line objects even when they are + obscured by such area objects, by clicking close to the lines (i.e. closer than + 0.99*selectionTolerance). + + The actual setting of the selection state is not done by this function. This is handled by the + parent QCustomPlot when the mouseReleaseEvent occurs, and the finally selected object is notified + via the selectEvent/deselectEvent methods. + + \a details is an optional output parameter. Every layerable subclass may place any information + in \a details. This information will be passed to \ref selectEvent when the parent QCustomPlot + decides on the basis of this selectTest call, that the object was successfully selected. The + subsequent call to \ref selectEvent will carry the \a details. This is useful for multi-part + objects (like QCPAxis). This way, a possibly complex calculation to decide which part was clicked + is only done once in \ref selectTest. The result (i.e. the actually clicked part) can then be + placed in \a details. So in the subsequent \ref selectEvent, the decision which part was + selected doesn't have to be done a second time for a single selection operation. + + You may pass 0 as \a details to indicate that you are not interested in those selection details. + + \see selectEvent, deselectEvent, QCustomPlot::setInteractions +*/ +double QCPLayerable::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(pos) + Q_UNUSED(onlySelectable) + Q_UNUSED(details) + return -1.0; +} + +/*! \internal + + Sets the parent plot of this layerable. Use this function once to set the parent plot if you have + passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to + another one. + + Note that, unlike when passing a non-null parent plot in the constructor, this function does not + make \a parentPlot the QObject-parent of this layerable. If you want this, call + QObject::setParent(\a parentPlot) in addition to this function. + + Further, you will probably want to set a layer (\ref setLayer) after calling this function, to + make the layerable appear on the QCustomPlot. + + The parent plot change will be propagated to subclasses via a call to \ref parentPlotInitialized + so they can react accordingly (e.g. also initialize the parent plot of child layerables, like + QCPLayout does). +*/ +void QCPLayerable::initializeParentPlot(QCustomPlot *parentPlot) +{ + if (mParentPlot) + { + qDebug() << Q_FUNC_INFO << "called with mParentPlot already initialized"; + return; + } + + if (!parentPlot) + qDebug() << Q_FUNC_INFO << "called with parentPlot zero"; + + mParentPlot = parentPlot; + parentPlotInitialized(mParentPlot); +} + +/*! \internal + + Sets the parent layerable of this layerable to \a parentLayerable. Note that \a parentLayerable does not + become the QObject-parent (for memory management) of this layerable. + + The parent layerable has influence on the return value of the \ref realVisibility method. Only + layerables with a fully visible parent tree will return true for \ref realVisibility, and thus be + drawn. + + \see realVisibility +*/ +void QCPLayerable::setParentLayerable(QCPLayerable *parentLayerable) +{ + mParentLayerable = parentLayerable; +} + +/*! \internal + + Moves this layerable object to \a layer. If \a prepend is true, this object will be prepended to + the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is + false, the object will be appended. + + Returns true on success, i.e. if \a layer is a valid layer. +*/ +bool QCPLayerable::moveToLayer(QCPLayer *layer, bool prepend) +{ + if (layer && !mParentPlot) + { + qDebug() << Q_FUNC_INFO << "no parent QCustomPlot set"; + return false; + } + if (layer && layer->parentPlot() != mParentPlot) + { + qDebug() << Q_FUNC_INFO << "layer" << layer->name() << "is not in same QCustomPlot as this layerable"; + return false; + } + + QCPLayer *oldLayer = mLayer; + if (mLayer) + mLayer->removeChild(this); + mLayer = layer; + if (mLayer) + mLayer->addChild(this, prepend); + if (mLayer != oldLayer) + emit layerChanged(mLayer); + return true; +} + +/*! \internal + + Sets the QCPainter::setAntialiasing state on the provided \a painter, depending on the \a + localAntialiased value as well as the overrides \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is + controlled via \a overrideElement. +*/ +void QCPLayerable::applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const +{ + if (mParentPlot && mParentPlot->notAntialiasedElements().testFlag(overrideElement)) + painter->setAntialiasing(false); + else if (mParentPlot && mParentPlot->antialiasedElements().testFlag(overrideElement)) + painter->setAntialiasing(true); + else + painter->setAntialiasing(localAntialiased); +} + +/*! \internal + + This function is called by \ref initializeParentPlot, to allow subclasses to react on the setting + of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the + parent plot is set at a later time. + + For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any + QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level + element of the hierarchy gets its parent plot initialized with \ref initializeParentPlot. To + propagate the parent plot to all the children of the hierarchy, the top level element then uses + this function to pass the parent plot on to its child elements. + + The default implementation does nothing. + + \see initializeParentPlot +*/ +void QCPLayerable::parentPlotInitialized(QCustomPlot *parentPlot) +{ + Q_UNUSED(parentPlot) +} + +/*! \internal + + Returns the selection category this layerable shall belong to. The selection category is used in + conjunction with \ref QCustomPlot::setInteractions to control which objects are selectable and + which aren't. + + Subclasses that don't fit any of the normal \ref QCP::Interaction values can use \ref + QCP::iSelectOther. This is what the default implementation returns. + + \see QCustomPlot::setInteractions +*/ +QCP::Interaction QCPLayerable::selectionCategory() const +{ + return QCP::iSelectOther; +} + +/*! \internal + + Returns the clipping rectangle of this layerable object. By default, this is the viewport of the + parent QCustomPlot. Specific subclasses may reimplement this function to provide different + clipping rects. + + The returned clipping rect is set on the painter before the draw function of the respective + object is called. +*/ +QRect QCPLayerable::clipRect() const +{ + if (mParentPlot) + return mParentPlot->viewport(); + else + return QRect(); +} + +/*! \internal + + This event is called when the layerable shall be selected, as a consequence of a click by the + user. Subclasses should react to it by setting their selection state appropriately. The default + implementation does nothing. + + \a event is the mouse event that caused the selection. \a additive indicates, whether the user + was holding the multi-select-modifier while performing the selection (see \ref + QCustomPlot::setMultiSelectModifier). if \a additive is true, the selection state must be toggled + (i.e. become selected when unselected and unselected when selected). + + Every selectEvent is preceded by a call to \ref selectTest, which has returned positively (i.e. + returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). + The \a details data you output from \ref selectTest is fed back via \a details here. You may + use it to transport any kind of information from the selectTest to the possibly subsequent + selectEvent. Usually \a details is used to transfer which part was clicked, if it is a layerable + that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need + to do the calculation again to find out which part was actually clicked. + + \a selectionStateChanged is an output parameter. If the pointer is non-null, this function must + set the value either to true or false, depending on whether the selection state of this layerable + was actually changed. For layerables that only are selectable as a whole and not in parts, this + is simple: if \a additive is true, \a selectionStateChanged must also be set to true, because the + selection toggles. If \a additive is false, \a selectionStateChanged is only set to true, if the + layerable was previously unselected and now is switched to the selected state. + + \see selectTest, deselectEvent +*/ +void QCPLayerable::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) +{ + Q_UNUSED(event) + Q_UNUSED(additive) + Q_UNUSED(details) + Q_UNUSED(selectionStateChanged) +} + +/*! \internal + + This event is called when the layerable shall be deselected, either as consequence of a user + interaction or a call to \ref QCustomPlot::deselectAll. Subclasses should react to it by + unsetting their selection appropriately. + + just as in \ref selectEvent, the output parameter \a selectionStateChanged (if non-null), must + return true or false when the selection state of this layerable has changed or not changed, + respectively. + + \see selectTest, selectEvent +*/ +void QCPLayerable::deselectEvent(bool *selectionStateChanged) +{ + Q_UNUSED(selectionStateChanged) +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPRange +//////////////////////////////////////////////////////////////////////////////////////////////////// +/*! \class QCPRange + \brief Represents the range an axis is encompassing. + + contains a \a lower and \a upper double value and provides convenience input, output and + modification functions. + + \see QCPAxis::setRange +*/ + +/*! + Minimum range size (\a upper - \a lower) the range changing functions will accept. Smaller + intervals would cause errors due to the 11-bit exponent of double precision numbers, + corresponding to a minimum magnitude of roughly 1e-308. + \see validRange, maxRange +*/ +const double QCPRange::minRange = 1e-280; + +/*! + Maximum values (negative and positive) the range will accept in range-changing functions. + Larger absolute values would cause errors due to the 11-bit exponent of double precision numbers, + corresponding to a maximum magnitude of roughly 1e308. + Since the number of planck-volumes in the entire visible universe is only ~1e183, this should + be enough. + \see validRange, minRange +*/ +const double QCPRange::maxRange = 1e250; + +/*! + Constructs a range with \a lower and \a upper set to zero. +*/ +QCPRange::QCPRange() : + lower(0), + upper(0) +{ +} + +/*! \overload + Constructs a range with the specified \a lower and \a upper values. +*/ +QCPRange::QCPRange(double lower, double upper) : + lower(lower), + upper(upper) +{ + normalize(); +} + +/*! + Returns the size of the range, i.e. \a upper-\a lower +*/ +double QCPRange::size() const +{ + return upper-lower; +} + +/*! + Returns the center of the range, i.e. (\a upper+\a lower)*0.5 +*/ +double QCPRange::center() const +{ + return (upper+lower)*0.5; +} + +/*! + Makes sure \a lower is numerically smaller than \a upper. If this is not the case, the values + are swapped. +*/ +void QCPRange::normalize() +{ + if (lower > upper) + qSwap(lower, upper); +} + +/*! + Expands this range such that \a otherRange is contained in the new range. It is assumed that both + this range and \a otherRange are normalized (see \ref normalize). + + If \a otherRange is already inside the current range, this function does nothing. + + \see expanded +*/ +void QCPRange::expand(const QCPRange &otherRange) +{ + if (lower > otherRange.lower) + lower = otherRange.lower; + if (upper < otherRange.upper) + upper = otherRange.upper; +} + + +/*! + Returns an expanded range that contains this and \a otherRange. It is assumed that both this + range and \a otherRange are normalized (see \ref normalize). + + \see expand +*/ +QCPRange QCPRange::expanded(const QCPRange &otherRange) const +{ + QCPRange result = *this; + result.expand(otherRange); + return result; +} + +/*! + Returns a sanitized version of the range. Sanitized means for logarithmic scales, that + the range won't span the positive and negative sign domain, i.e. contain zero. Further + \a lower will always be numerically smaller (or equal) to \a upper. + + If the original range does span positive and negative sign domains or contains zero, + the returned range will try to approximate the original range as good as possible. + If the positive interval of the original range is wider than the negative interval, the + returned range will only contain the positive interval, with lower bound set to \a rangeFac or + \a rangeFac *\a upper, whichever is closer to zero. Same procedure is used if the negative interval + is wider than the positive interval, this time by changing the \a upper bound. +*/ +QCPRange QCPRange::sanitizedForLogScale() const +{ + double rangeFac = 1e-3; + QCPRange sanitizedRange(lower, upper); + sanitizedRange.normalize(); + // can't have range spanning negative and positive values in log plot, so change range to fix it + //if (qFuzzyCompare(sanitizedRange.lower+1, 1) && !qFuzzyCompare(sanitizedRange.upper+1, 1)) + if (sanitizedRange.lower == 0.0 && sanitizedRange.upper != 0.0) + { + // case lower is 0 + if (rangeFac < sanitizedRange.upper*rangeFac) + sanitizedRange.lower = rangeFac; + else + sanitizedRange.lower = sanitizedRange.upper*rangeFac; + } //else if (!qFuzzyCompare(lower+1, 1) && qFuzzyCompare(upper+1, 1)) + else if (sanitizedRange.lower != 0.0 && sanitizedRange.upper == 0.0) + { + // case upper is 0 + if (-rangeFac > sanitizedRange.lower*rangeFac) + sanitizedRange.upper = -rangeFac; + else + sanitizedRange.upper = sanitizedRange.lower*rangeFac; + } else if (sanitizedRange.lower < 0 && sanitizedRange.upper > 0) + { + // find out whether negative or positive interval is wider to decide which sign domain will be chosen + if (-sanitizedRange.lower > sanitizedRange.upper) + { + // negative is wider, do same as in case upper is 0 + if (-rangeFac > sanitizedRange.lower*rangeFac) + sanitizedRange.upper = -rangeFac; + else + sanitizedRange.upper = sanitizedRange.lower*rangeFac; + } else + { + // positive is wider, do same as in case lower is 0 + if (rangeFac < sanitizedRange.upper*rangeFac) + sanitizedRange.lower = rangeFac; + else + sanitizedRange.lower = sanitizedRange.upper*rangeFac; + } + } + // due to normalization, case lower>0 && upper<0 should never occur, because that implies upper= lower && value <= upper; +} + +/*! + Checks, whether the specified range is within valid bounds, which are defined + as QCPRange::maxRange and QCPRange::minRange. + A valid range means: + \li range bounds within -maxRange and maxRange + \li range size above minRange + \li range size below maxRange +*/ +bool QCPRange::validRange(double lower, double upper) +{ + /* + return (lower > -maxRange && + upper < maxRange && + qAbs(lower-upper) > minRange && + (lower < -minRange || lower > minRange) && + (upper < -minRange || upper > minRange)); + */ + return (lower > -maxRange && + upper < maxRange && + qAbs(lower-upper) > minRange && + qAbs(lower-upper) < maxRange); +} + +/*! + \overload + Checks, whether the specified range is within valid bounds, which are defined + as QCPRange::maxRange and QCPRange::minRange. + A valid range means: + \li range bounds within -maxRange and maxRange + \li range size above minRange + \li range size below maxRange +*/ +bool QCPRange::validRange(const QCPRange &range) +{ + /* + return (range.lower > -maxRange && + range.upper < maxRange && + qAbs(range.lower-range.upper) > minRange && + qAbs(range.lower-range.upper) < maxRange && + (range.lower < -minRange || range.lower > minRange) && + (range.upper < -minRange || range.upper > minRange)); + */ + return (range.lower > -maxRange && + range.upper < maxRange && + qAbs(range.lower-range.upper) > minRange && + qAbs(range.lower-range.upper) < maxRange); +} + + +/*! \page thelayoutsystem The Layout System + + The layout system is responsible for positioning and scaling layout elements such as axis rects, + legends and plot titles in a QCustomPlot. + + \section layoutsystem-classesandmechanisms Classes and mechanisms + + The layout system is based on the abstract base class \ref QCPLayoutElement. All objects that + take part in the layout system derive from this class, either directly or indirectly. + + Since QCPLayoutElement itself derives from \ref QCPLayerable, a layout element may draw its own + content. However, it is perfectly possible for a layout element to only serve as a structuring + and/or positioning element, not drawing anything on its own. + + \subsection layoutsystem-rects Rects of a layout element + + A layout element is a rectangular object described by two rects: the inner rect (\ref + QCPLayoutElement::rect) and the outer rect (\ref QCPLayoutElement::setOuterRect). The inner rect + is calculated automatically by applying the margin (\ref QCPLayoutElement::setMargins) inward + from the outer rect. The inner rect is meant for main content while the margin area may either be + left blank or serve for displaying peripheral graphics. For example, \ref QCPAxisRect positions + the four main axes at the sides of the inner rect, so graphs end up inside it and the axis labels + and tick labels are in the margin area. + + \subsection layoutsystem-margins Margins + + Each layout element may provide a mechanism to automatically determine its margins. Internally, + this is realized with the \ref QCPLayoutElement::calculateAutoMargin function which takes a \ref + QCP::MarginSide and returns an integer value which represents the ideal margin for the specified + side. The automatic margin will be used on the sides specified in \ref + QCPLayoutElement::setAutoMargins. By default, it is set to \ref QCP::msAll meaning automatic + margin calculation is enabled for all four sides. In this case, a minimum margin may be set with + \ref QCPLayoutElement::setMinimumMargins, to prevent the automatic margin mechanism from setting + margins smaller than desired for a specific situation. If automatic margin calculation is unset + for a specific side, the margin of that side can be controlled directy via \ref + QCPLayoutElement::setMargins. + + If multiple layout ements are arranged next to or beneath each other, it may be desirable to + align their inner rects on certain sides. Since they all might have different automatic margins, + this usually isn't the case. The class \ref QCPMarginGroup and \ref + QCPLayoutElement::setMarginGroup fix this by allowing to synchronize multiple margins. See the + documentation there for details. + + \subsection layoutsystem-layout Layouts + + As mentioned, a QCPLayoutElement may have an arbitrary number of child layout elements and in + princple can have the only purpose to manage/arrange those child elements. This is what the + subclass \ref QCPLayout specializes on. It is a QCPLayoutElement itself but has no visual + representation. It defines an interface to add, remove and manage child layout elements. + QCPLayout isn't a usable layout though, it's an abstract base class that concrete layouts derive + from, like \ref QCPLayoutGrid which arranges its child elements in a grid and \ref QCPLayoutInset + which allows placing child elements freely inside its rect. + + Since a QCPLayout is a layout element itself, it may be placed inside other layouts. This way, + complex hierarchies may be created, offering very flexible arrangements. + + Below is a sketch of the default \ref QCPLayoutGrid accessible via \ref QCustomPlot::plotLayout. + It shows how two child layout elements are placed inside the grid layout next to each other in + cells (0, 0) and (0, 1). + + \image html LayoutsystemSketch.png + + \subsection layoutsystem-plotlayout The top level plot layout + + Every QCustomPlot has one top level layout of type \ref QCPLayoutGrid. It is accessible via \ref + QCustomPlot::plotLayout and contains (directly or indirectly via other sub-layouts) all layout + elements in the QCustomPlot. By default, this top level grid layout contains a single cell which + holds the main axis rect. + + \subsection layoutsystem-examples Examples + + Adding a plot title is a typical and simple case to demonstrate basic workings of the layout system. + \code + // first we create and prepare a plot title layout element: + QCPPlotTitle *title = new QCPPlotTitle(customPlot); + title->setText("Plot Title Example"); + title->setFont(QFont("sans", 12, QFont::Bold)); + // then we add it to the main plot layout: + customPlot->plotLayout()->insertRow(0); // insert an empty row above the axis rect + customPlot->plotLayout()->addElement(0, 0, title); // place the title in the empty cell we've just created + \endcode + \image html layoutsystem-addingplottitle.png + + Arranging multiple axis rects actually is the central purpose of the layout system. + \code + customPlot->plotLayout()->clear(); // let's start from scratch and remove the default axis rect + // add the first axis rect in second row (row index 1): + QCPAxisRect *bottomAxisRect = new QCPAxisRect(customPlot); + customPlot->plotLayout()->addElement(1, 0, bottomAxisRect); + // create a sub layout that we'll place in first row: + QCPLayoutGrid *subLayout = new QCPLayoutGrid; + customPlot->plotLayout()->addElement(0, 0, subLayout); + // add two axis rects in the sub layout next to each other: + QCPAxisRect *leftAxisRect = new QCPAxisRect(customPlot); + QCPAxisRect *rightAxisRect = new QCPAxisRect(customPlot); + subLayout->addElement(0, 0, leftAxisRect); + subLayout->addElement(0, 1, rightAxisRect); + subLayout->setColumnStretchFactor(0, 3); // left axis rect shall have 60% of width + subLayout->setColumnStretchFactor(1, 2); // right one only 40% (3:2 = 60:40) + // since we've created the axis rects and axes from scratch, we need to place them on + // according layers, if we don't want the grid to be drawn above the axes etc. + // place the axis on "axes" layer and grids on the "grid" layer, which is below "axes": + QList allAxes; + allAxes << bottomAxisRect->axes() << leftAxisRect->axes() << rightAxisRect->axes(); + foreach (QCPAxis *axis, allAxes) + { + axis->setLayer("axes"); + axis->grid()->setLayer("grid"); + } + \endcode + \image html layoutsystem-multipleaxisrects.png + +*/ + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPMarginGroup +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPMarginGroup + \brief A margin group allows synchronization of margin sides if working with multiple layout elements. + + QCPMarginGroup allows you to tie a margin side of two or more layout elements together, such that + they will all have the same size, based on the largest required margin in the group. + + \n + \image html QCPMarginGroup.png "Demonstration of QCPMarginGroup" + \n + + In certain situations it is desirable that margins at specific sides are synchronized across + layout elements. For example, if one QCPAxisRect is below another one in a grid layout, it will + provide a cleaner look to the user if the left and right margins of the two axis rects are of the + same size. The left axis of the top axis rect will then be at the same horizontal position as the + left axis of the lower axis rect, making them appear aligned. The same applies for the right + axes. This is what QCPMarginGroup makes possible. + + To add/remove a specific side of a layout element to/from a margin group, use the \ref + QCPLayoutElement::setMarginGroup method. To completely break apart the margin group, either call + \ref clear, or just delete the margin group. + + \section QCPMarginGroup-example Example + + First create a margin group: + \code + QCPMarginGroup *group = new QCPMarginGroup(customPlot); + \endcode + Then set this group on the layout element sides: + \code + customPlot->axisRect(0)->setMarginGroup(QCP::msLeft|QCP::msRight, group); + customPlot->axisRect(1)->setMarginGroup(QCP::msLeft|QCP::msRight, group); + \endcode + Here, we've used the first two axis rects of the plot and synchronized their left margins with + each other and their right margins with each other. +*/ + +/* start documentation of inline functions */ + +/*! \fn QList QCPMarginGroup::elements(QCP::MarginSide side) const + + Returns a list of all layout elements that have their margin \a side associated with this margin + group. +*/ + +/* end documentation of inline functions */ + +/*! + Creates a new QCPMarginGroup instance in \a parentPlot. +*/ +QCPMarginGroup::QCPMarginGroup(QCustomPlot *parentPlot) : + QObject(parentPlot), + mParentPlot(parentPlot) +{ + mChildren.insert(QCP::msLeft, QList()); + mChildren.insert(QCP::msRight, QList()); + mChildren.insert(QCP::msTop, QList()); + mChildren.insert(QCP::msBottom, QList()); +} + +QCPMarginGroup::~QCPMarginGroup() +{ + clear(); +} + +/*! + Returns whether this margin group is empty. If this function returns true, no layout elements use + this margin group to synchronize margin sides. +*/ +bool QCPMarginGroup::isEmpty() const +{ + QHashIterator > it(mChildren); + while (it.hasNext()) + { + it.next(); + if (!it.value().isEmpty()) + return false; + } + return true; +} + +/*! + Clears this margin group. The synchronization of the margin sides that use this margin group is + lifted and they will use their individual margin sizes again. +*/ +void QCPMarginGroup::clear() +{ + // make all children remove themselves from this margin group: + QHashIterator > it(mChildren); + while (it.hasNext()) + { + it.next(); + const QList elements = it.value(); + for (int i=elements.size()-1; i>=0; --i) + elements.at(i)->setMarginGroup(it.key(), 0); // removes itself from mChildren via removeChild + } +} + +/*! \internal + + Returns the synchronized common margin for \a side. This is the margin value that will be used by + the layout element on the respective side, if it is part of this margin group. + + The common margin is calculated by requesting the automatic margin (\ref + QCPLayoutElement::calculateAutoMargin) of each element associated with \a side in this margin + group, and choosing the largest returned value. (QCPLayoutElement::minimumMargins is taken into + account, too.) +*/ +int QCPMarginGroup::commonMargin(QCP::MarginSide side) const +{ + // query all automatic margins of the layout elements in this margin group side and find maximum: + int result = 0; + const QList elements = mChildren.value(side); + for (int i=0; iautoMargins().testFlag(side)) + continue; + int m = qMax(elements.at(i)->calculateAutoMargin(side), QCP::getMarginValue(elements.at(i)->minimumMargins(), side)); + if (m > result) + result = m; + } + return result; +} + +/*! \internal + + Adds \a element to the internal list of child elements, for the margin \a side. + + This function does not modify the margin group property of \a element. +*/ +void QCPMarginGroup::addChild(QCP::MarginSide side, QCPLayoutElement *element) +{ + if (!mChildren[side].contains(element)) + mChildren[side].append(element); + else + qDebug() << Q_FUNC_INFO << "element is already child of this margin group side" << reinterpret_cast(element); +} + +/*! \internal + + Removes \a element from the internal list of child elements, for the margin \a side. + + This function does not modify the margin group property of \a element. +*/ +void QCPMarginGroup::removeChild(QCP::MarginSide side, QCPLayoutElement *element) +{ + if (!mChildren[side].removeOne(element)) + qDebug() << Q_FUNC_INFO << "element is not child of this margin group side" << reinterpret_cast(element); +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPLayoutElement +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPLayoutElement + \brief The abstract base class for all objects that form \ref thelayoutsystem "the layout system". + + This is an abstract base class. As such, it can't be instantiated directly, rather use one of its subclasses. + + A Layout element is a rectangular object which can be placed in layouts. It has an outer rect + (QCPLayoutElement::outerRect) and an inner rect (\ref QCPLayoutElement::rect). The difference + between outer and inner rect is called its margin. The margin can either be set to automatic or + manual (\ref setAutoMargins) on a per-side basis. If a side is set to manual, that margin can be + set explicitly with \ref setMargins and will stay fixed at that value. If it's set to automatic, + the layout element subclass will control the value itself (via \ref calculateAutoMargin). + + Layout elements can be placed in layouts (base class QCPLayout) like QCPLayoutGrid. The top level + layout is reachable via \ref QCustomPlot::plotLayout, and is a \ref QCPLayoutGrid. Since \ref + QCPLayout itself derives from \ref QCPLayoutElement, layouts can be nested. + + Thus in QCustomPlot one can divide layout elements into two categories: The ones that are + invisible by themselves, because they don't draw anything. Their only purpose is to manage the + position and size of other layout elements. This category of layout elements usually use + QCPLayout as base class. Then there is the category of layout elements which actually draw + something. For example, QCPAxisRect, QCPLegend and QCPPlotTitle are of this category. This does + not necessarily mean that the latter category can't have child layout elements. QCPLegend for + instance, actually derives from QCPLayoutGrid and the individual legend items are child layout + elements in the grid layout. +*/ + +/* start documentation of inline functions */ + +/*! \fn QCPLayout *QCPLayoutElement::layout() const + + Returns the parent layout of this layout element. +*/ + +/*! \fn QRect QCPLayoutElement::rect() const + + Returns the inner rect of this layout element. The inner rect is the outer rect (\ref + setOuterRect) shrinked by the margins (\ref setMargins, \ref setAutoMargins). + + In some cases, the area between outer and inner rect is left blank. In other cases the margin + area is used to display peripheral graphics while the main content is in the inner rect. This is + where automatic margin calculation becomes interesting because it allows the layout element to + adapt the margins to the peripheral graphics it wants to draw. For example, \ref QCPAxisRect + draws the axis labels and tick labels in the margin area, thus needs to adjust the margins (if + \ref setAutoMargins is enabled) according to the space required by the labels of the axes. +*/ + +/*! \fn virtual void QCPLayoutElement::mousePressEvent(QMouseEvent *event) + + This event is called, if the mouse was pressed while being inside the outer rect of this layout + element. +*/ + +/*! \fn virtual void QCPLayoutElement::mouseMoveEvent(QMouseEvent *event) + + This event is called, if the mouse is moved inside the outer rect of this layout element. +*/ + +/*! \fn virtual void QCPLayoutElement::mouseReleaseEvent(QMouseEvent *event) + + This event is called, if the mouse was previously pressed inside the outer rect of this layout + element and is now released. +*/ + +/*! \fn virtual void QCPLayoutElement::mouseDoubleClickEvent(QMouseEvent *event) + + This event is called, if the mouse is double-clicked inside the outer rect of this layout + element. +*/ + +/*! \fn virtual void QCPLayoutElement::wheelEvent(QWheelEvent *event) + + This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this + layout element. +*/ + +/* end documentation of inline functions */ + +/*! + Creates an instance of QCPLayoutElement and sets default values. +*/ +QCPLayoutElement::QCPLayoutElement(QCustomPlot *parentPlot) : + QCPLayerable(parentPlot), // parenthood is changed as soon as layout element gets inserted into a layout (except for top level layout) + mParentLayout(0), + mMinimumSize(), + mMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX), + mRect(0, 0, 0, 0), + mOuterRect(0, 0, 0, 0), + mMargins(0, 0, 0, 0), + mMinimumMargins(0, 0, 0, 0), + mAutoMargins(QCP::msAll) +{ +} + +QCPLayoutElement::~QCPLayoutElement() +{ + setMarginGroup(QCP::msAll, 0); // unregister at margin groups, if there are any + // unregister at layout: + if (qobject_cast(mParentLayout)) // the qobject_cast is just a safeguard in case the layout forgets to call clear() in its dtor and this dtor is called by QObject dtor + mParentLayout->take(this); +} + +/*! + Sets the outer rect of this layout element. If the layout element is inside a layout, the layout + sets the position and size of this layout element using this function. + + Calling this function externally has no effect, since the layout will overwrite any changes to + the outer rect upon the next replot. + + The layout element will adapt its inner \ref rect by applying the margins inward to the outer rect. + + \see rect +*/ +void QCPLayoutElement::setOuterRect(const QRect &rect) +{ + if (mOuterRect != rect) + { + mOuterRect = rect; + mRect = mOuterRect.adjusted(mMargins.left(), mMargins.top(), -mMargins.right(), -mMargins.bottom()); + } +} + +/*! + Sets the margins of this layout element. If \ref setAutoMargins is disabled for some or all + sides, this function is used to manually set the margin on those sides. Sides that are still set + to be handled automatically are ignored and may have any value in \a margins. + + The margin is the distance between the outer rect (controlled by the parent layout via \ref + setOuterRect) and the inner \ref rect (which usually contains the main content of this layout + element). + + \see setAutoMargins +*/ +void QCPLayoutElement::setMargins(const QMargins &margins) +{ + if (mMargins != margins) + { + mMargins = margins; + mRect = mOuterRect.adjusted(mMargins.left(), mMargins.top(), -mMargins.right(), -mMargins.bottom()); + } +} + +/*! + If \ref setAutoMargins is enabled on some or all margins, this function is used to provide + minimum values for those margins. + + The minimum values are not enforced on margin sides that were set to be under manual control via + \ref setAutoMargins. + + \see setAutoMargins +*/ +void QCPLayoutElement::setMinimumMargins(const QMargins &margins) +{ + if (mMinimumMargins != margins) + { + mMinimumMargins = margins; + } +} + +/*! + Sets on which sides the margin shall be calculated automatically. If a side is calculated + automatically, a minimum margin value may be provided with \ref setMinimumMargins. If a side is + set to be controlled manually, the value may be specified with \ref setMargins. + + Margin sides that are under automatic control may participate in a \ref QCPMarginGroup (see \ref + setMarginGroup), to synchronize (align) it with other layout elements in the plot. + + \see setMinimumMargins, setMargins +*/ +void QCPLayoutElement::setAutoMargins(QCP::MarginSides sides) +{ + mAutoMargins = sides; +} + +/*! + Sets the minimum size for the inner \ref rect of this layout element. A parent layout tries to + respect the \a size here by changing row/column sizes in the layout accordingly. + + If the parent layout size is not sufficient to satisfy all minimum size constraints of its child + layout elements, the layout may set a size that is actually smaller than \a size. QCustomPlot + propagates the layout's size constraints to the outside by setting its own minimum QWidget size + accordingly, so violations of \a size should be exceptions. +*/ +void QCPLayoutElement::setMinimumSize(const QSize &size) +{ + if (mMinimumSize != size) + { + mMinimumSize = size; + if (mParentLayout) + mParentLayout->sizeConstraintsChanged(); + } +} + +/*! \overload + + Sets the minimum size for the inner \ref rect of this layout element. +*/ +void QCPLayoutElement::setMinimumSize(int width, int height) +{ + setMinimumSize(QSize(width, height)); +} + +/*! + Sets the maximum size for the inner \ref rect of this layout element. A parent layout tries to + respect the \a size here by changing row/column sizes in the layout accordingly. +*/ +void QCPLayoutElement::setMaximumSize(const QSize &size) +{ + if (mMaximumSize != size) + { + mMaximumSize = size; + if (mParentLayout) + mParentLayout->sizeConstraintsChanged(); + } +} + +/*! \overload + + Sets the maximum size for the inner \ref rect of this layout element. +*/ +void QCPLayoutElement::setMaximumSize(int width, int height) +{ + setMaximumSize(QSize(width, height)); +} + +/*! + Sets the margin \a group of the specified margin \a sides. + + Margin groups allow synchronizing specified margins across layout elements, see the documentation + of \ref QCPMarginGroup. + + To unset the margin group of \a sides, set \a group to 0. + + Note that margin groups only work for margin sides that are set to automatic (\ref + setAutoMargins). +*/ +void QCPLayoutElement::setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group) +{ + QVector sideVector; + if (sides.testFlag(QCP::msLeft)) sideVector.append(QCP::msLeft); + if (sides.testFlag(QCP::msRight)) sideVector.append(QCP::msRight); + if (sides.testFlag(QCP::msTop)) sideVector.append(QCP::msTop); + if (sides.testFlag(QCP::msBottom)) sideVector.append(QCP::msBottom); + + for (int i=0; iremoveChild(side, this); + + if (!group) // if setting to 0, remove hash entry. Else set hash entry to new group and register there + { + mMarginGroups.remove(side); + } else // setting to a new group + { + mMarginGroups[side] = group; + group->addChild(side, this); + } + } + } +} + +/*! + Updates the layout element and sub-elements. This function is automatically called before every + replot by the parent layout element. It is called multiple times, once for every \ref + UpdatePhase. The phases are run through in the order of the enum values. For details about what + happens at the different phases, see the documentation of \ref UpdatePhase. + + Layout elements that have child elements should call the \ref update method of their child + elements, and pass the current \a phase unchanged. + + The default implementation executes the automatic margin mechanism in the \ref upMargins phase. + Subclasses should make sure to call the base class implementation. +*/ +void QCPLayoutElement::update(UpdatePhase phase) +{ + if (phase == upMargins) + { + if (mAutoMargins != QCP::msNone) + { + // set the margins of this layout element according to automatic margin calculation, either directly or via a margin group: + QMargins newMargins = mMargins; + foreach (QCP::MarginSide side, QList() << QCP::msLeft << QCP::msRight << QCP::msTop << QCP::msBottom) + { + if (mAutoMargins.testFlag(side)) // this side's margin shall be calculated automatically + { + if (mMarginGroups.contains(side)) + QCP::setMarginValue(newMargins, side, mMarginGroups[side]->commonMargin(side)); // this side is part of a margin group, so get the margin value from that group + else + QCP::setMarginValue(newMargins, side, calculateAutoMargin(side)); // this side is not part of a group, so calculate the value directly + // apply minimum margin restrictions: + if (QCP::getMarginValue(newMargins, side) < QCP::getMarginValue(mMinimumMargins, side)) + QCP::setMarginValue(newMargins, side, QCP::getMarginValue(mMinimumMargins, side)); + } + } + setMargins(newMargins); + } + } +} + +/*! + Returns the minimum size this layout element (the inner \ref rect) may be compressed to. + + if a minimum size (\ref setMinimumSize) was not set manually, parent layouts consult this + function to determine the minimum allowed size of this layout element. (A manual minimum size is + considered set if it is non-zero.) +*/ +QSize QCPLayoutElement::minimumSizeHint() const +{ + return mMinimumSize; +} + +/*! + Returns the maximum size this layout element (the inner \ref rect) may be expanded to. + + if a maximum size (\ref setMaximumSize) was not set manually, parent layouts consult this + function to determine the maximum allowed size of this layout element. (A manual maximum size is + considered set if it is smaller than Qt's QWIDGETSIZE_MAX.) +*/ +QSize QCPLayoutElement::maximumSizeHint() const +{ + return mMaximumSize; +} + +/*! + Returns a list of all child elements in this layout element. If \a recursive is true, all + sub-child elements are included in the list, too. + + \warning There may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have + empty cells which yield 0 at the respective index.) +*/ +QList QCPLayoutElement::elements(bool recursive) const +{ + Q_UNUSED(recursive) + return QList(); +} + +/*! + Layout elements are sensitive to events inside their outer rect. If \a pos is within the outer + rect, this method returns a value corresponding to 0.99 times the parent plot's selection + tolerance. However, layout elements are not selectable by default. So if \a onlySelectable is + true, -1.0 is returned. + + See \ref QCPLayerable::selectTest for a general explanation of this virtual method. + + QCPLayoutElement subclasses may reimplement this method to provide more specific selection test + behaviour. +*/ +double QCPLayoutElement::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + + if (onlySelectable) + return -1; + + if (QRectF(mOuterRect).contains(pos)) + { + if (mParentPlot) + return mParentPlot->selectionTolerance()*0.99; + else + { + qDebug() << Q_FUNC_INFO << "parent plot not defined"; + return -1; + } + } else + return -1; +} + +/*! \internal + + propagates the parent plot initialization to all child elements, by calling \ref + QCPLayerable::initializeParentPlot on them. +*/ +void QCPLayoutElement::parentPlotInitialized(QCustomPlot *parentPlot) +{ + foreach (QCPLayoutElement* el, elements(false)) + { + if (!el->parentPlot()) + el->initializeParentPlot(parentPlot); + } +} + +/*! \internal + + Returns the margin size for this \a side. It is used if automatic margins is enabled for this \a + side (see \ref setAutoMargins). If a minimum margin was set with \ref setMinimumMargins, the + returned value will not be smaller than the specified minimum margin. + + The default implementation just returns the respective manual margin (\ref setMargins) or the + minimum margin, whichever is larger. +*/ +int QCPLayoutElement::calculateAutoMargin(QCP::MarginSide side) +{ + return qMax(QCP::getMarginValue(mMargins, side), QCP::getMarginValue(mMinimumMargins, side)); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPLayout +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPLayout + \brief The abstract base class for layouts + + This is an abstract base class for layout elements whose main purpose is to define the position + and size of other child layout elements. In most cases, layouts don't draw anything themselves + (but there are exceptions to this, e.g. QCPLegend). + + QCPLayout derives from QCPLayoutElement, and thus can itself be nested in other layouts. + + QCPLayout introduces a common interface for accessing and manipulating the child elements. Those + functions are most notably \ref elementCount, \ref elementAt, \ref takeAt, \ref take, \ref + simplify, \ref removeAt, \ref remove and \ref clear. Individual subclasses may add more functions + to this interface which are more specialized to the form of the layout. For example, \ref + QCPLayoutGrid adds functions that take row and column indices to access cells of the layout grid + more conveniently. + + Since this is an abstract base class, you can't instantiate it directly. Rather use one of its + subclasses like QCPLayoutGrid or QCPLayoutInset. + + For a general introduction to the layout system, see the dedicated documentation page \ref + thelayoutsystem "The Layout System". +*/ + +/* start documentation of pure virtual functions */ + +/*! \fn virtual int QCPLayout::elementCount() const = 0 + + Returns the number of elements/cells in the layout. + + \see elements, elementAt +*/ + +/*! \fn virtual QCPLayoutElement* QCPLayout::elementAt(int index) const = 0 + + Returns the element in the cell with the given \a index. If \a index is invalid, returns 0. + + Note that even if \a index is valid, the respective cell may be empty in some layouts (e.g. + QCPLayoutGrid), so this function may return 0 in those cases. You may use this function to check + whether a cell is empty or not. + + \see elements, elementCount, takeAt +*/ + +/*! \fn virtual QCPLayoutElement* QCPLayout::takeAt(int index) = 0 + + Removes the element with the given \a index from the layout and returns it. + + If the \a index is invalid or the cell with that index is empty, returns 0. + + Note that some layouts don't remove the respective cell right away but leave an empty cell after + successful removal of the layout element. To collapse empty cells, use \ref simplify. + + \see elementAt, take +*/ + +/*! \fn virtual bool QCPLayout::take(QCPLayoutElement* element) = 0 + + Removes the specified \a element from the layout and returns true on success. + + If the \a element isn't in this layout, returns false. + + Note that some layouts don't remove the respective cell right away but leave an empty cell after + successful removal of the layout element. To collapse empty cells, use \ref simplify. + + \see takeAt +*/ + +/* end documentation of pure virtual functions */ + +/*! + Creates an instance of QCPLayout and sets default values. Note that since QCPLayout + is an abstract base class, it can't be instantiated directly. +*/ +QCPLayout::QCPLayout() +{ +} + +/*! + First calls the QCPLayoutElement::update base class implementation to update the margins on this + layout. + + Then calls \ref updateLayout which subclasses reimplement to reposition and resize their cells. + + Finally, \ref update is called on all child elements. +*/ +void QCPLayout::update(UpdatePhase phase) +{ + QCPLayoutElement::update(phase); + + // set child element rects according to layout: + if (phase == upLayout) + updateLayout(); + + // propagate update call to child elements: + const int elCount = elementCount(); + for (int i=0; iupdate(phase); + } +} + +/* inherits documentation from base class */ +QList QCPLayout::elements(bool recursive) const +{ + const int c = elementCount(); + QList result; +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + result.reserve(c); +#endif + for (int i=0; ielements(recursive); + } + } + return result; +} + +/*! + Simplifies the layout by collapsing empty cells. The exact behavior depends on subclasses, the + default implementation does nothing. + + Not all layouts need simplification. For example, QCPLayoutInset doesn't use explicit + simplification while QCPLayoutGrid does. +*/ +void QCPLayout::simplify() +{ +} + +/*! + Removes and deletes the element at the provided \a index. Returns true on success. If \a index is + invalid or points to an empty cell, returns false. + + This function internally uses \ref takeAt to remove the element from the layout and then deletes + the returned element. + + \see remove, takeAt +*/ +bool QCPLayout::removeAt(int index) +{ + if (QCPLayoutElement *el = takeAt(index)) + { + delete el; + return true; + } else + return false; +} + +/*! + Removes and deletes the provided \a element. Returns true on success. If \a element is not in the + layout, returns false. + + This function internally uses \ref takeAt to remove the element from the layout and then deletes + the element. + + \see removeAt, take +*/ +bool QCPLayout::remove(QCPLayoutElement *element) +{ + if (take(element)) + { + delete element; + return true; + } else + return false; +} + +/*! + Removes and deletes all layout elements in this layout. + + \see remove, removeAt +*/ +void QCPLayout::clear() +{ + for (int i=elementCount()-1; i>=0; --i) + { + if (elementAt(i)) + removeAt(i); + } + simplify(); +} + +/*! + Subclasses call this method to report changed (minimum/maximum) size constraints. + + If the parent of this layout is again a QCPLayout, forwards the call to the parent's \ref + sizeConstraintsChanged. If the parent is a QWidget (i.e. is the \ref QCustomPlot::plotLayout of + QCustomPlot), calls QWidget::updateGeometry, so if the QCustomPlot widget is inside a Qt QLayout, + it may update itself and resize cells accordingly. +*/ +void QCPLayout::sizeConstraintsChanged() const +{ + if (QWidget *w = qobject_cast(parent())) + w->updateGeometry(); + else if (QCPLayout *l = qobject_cast(parent())) + l->sizeConstraintsChanged(); +} + +/*! \internal + + Subclasses reimplement this method to update the position and sizes of the child elements/cells + via calling their \ref QCPLayoutElement::setOuterRect. The default implementation does nothing. + + The geometry used as a reference is the inner \ref rect of this layout. Child elements should stay + within that rect. + + \ref getSectionSizes may help with the reimplementation of this function. + + \see update +*/ +void QCPLayout::updateLayout() +{ +} + + +/*! \internal + + Associates \a el with this layout. This is done by setting the \ref QCPLayoutElement::layout, the + \ref QCPLayerable::parentLayerable and the QObject parent to this layout. + + Further, if \a el didn't previously have a parent plot, calls \ref + QCPLayerable::initializeParentPlot on \a el to set the paret plot. + + This method is used by subclass specific methods that add elements to the layout. Note that this + method only changes properties in \a el. The removal from the old layout and the insertion into + the new layout must be done additionally. +*/ +void QCPLayout::adoptElement(QCPLayoutElement *el) +{ + if (el) + { + el->mParentLayout = this; + el->setParentLayerable(this); + el->setParent(this); + if (!el->parentPlot()) + el->initializeParentPlot(mParentPlot); + } else + qDebug() << Q_FUNC_INFO << "Null element passed"; +} + +/*! \internal + + Disassociates \a el from this layout. This is done by setting the \ref QCPLayoutElement::layout + and the \ref QCPLayerable::parentLayerable to zero. The QObject parent is set to the parent + QCustomPlot. + + This method is used by subclass specific methods that remove elements from the layout (e.g. \ref + take or \ref takeAt). Note that this method only changes properties in \a el. The removal from + the old layout must be done additionally. +*/ +void QCPLayout::releaseElement(QCPLayoutElement *el) +{ + if (el) + { + el->mParentLayout = 0; + el->setParentLayerable(0); + el->setParent(mParentPlot); + // Note: Don't initializeParentPlot(0) here, because layout element will stay in same parent plot + } else + qDebug() << Q_FUNC_INFO << "Null element passed"; +} + +/*! \internal + + This is a helper function for the implementation of \ref updateLayout in subclasses. + + It calculates the sizes of one-dimensional sections with provided constraints on maximum section + sizes, minimum section sizes, relative stretch factors and the final total size of all sections. + + The QVector entries refer to the sections. Thus all QVectors must have the same size. + + \a maxSizes gives the maximum allowed size of each section. If there shall be no maximum size + imposed, set all vector values to Qt's QWIDGETSIZE_MAX. + + \a minSizes gives the minimum allowed size of each section. If there shall be no minimum size + imposed, set all vector values to zero. If the \a minSizes entries add up to a value greater than + \a totalSize, sections will be scaled smaller than the proposed minimum sizes. (In other words, + not exceeding the allowed total size is taken to be more important than not going below minimum + section sizes.) + + \a stretchFactors give the relative proportions of the sections to each other. If all sections + shall be scaled equally, set all values equal. If the first section shall be double the size of + each individual other section, set the first number of \a stretchFactors to double the value of + the other individual values (e.g. {2, 1, 1, 1}). + + \a totalSize is the value that the final section sizes will add up to. Due to rounding, the + actual sum may differ slightly. If you want the section sizes to sum up to exactly that value, + you could distribute the remaining difference on the sections. + + The return value is a QVector containing the section sizes. +*/ +QVector QCPLayout::getSectionSizes(QVector maxSizes, QVector minSizes, QVector stretchFactors, int totalSize) const +{ + if (maxSizes.size() != minSizes.size() || minSizes.size() != stretchFactors.size()) + { + qDebug() << Q_FUNC_INFO << "Passed vector sizes aren't equal:" << maxSizes << minSizes << stretchFactors; + return QVector(); + } + if (stretchFactors.isEmpty()) + return QVector(); + int sectionCount = stretchFactors.size(); + QVector sectionSizes(sectionCount); + // if provided total size is forced smaller than total minimum size, ignore minimum sizes (squeeze sections): + int minSizeSum = 0; + for (int i=0; i minimumLockedSections; + QList unfinishedSections; + for (int i=0; i result(sectionCount); + for (int i=0; i= 0 && row < mElements.size()) + { + if (column >= 0 && column < mElements.first().size()) + { + if (QCPLayoutElement *result = mElements.at(row).at(column)) + return result; + else + qDebug() << Q_FUNC_INFO << "Requested cell is empty. Row:" << row << "Column:" << column; + } else + qDebug() << Q_FUNC_INFO << "Invalid column. Row:" << row << "Column:" << column; + } else + qDebug() << Q_FUNC_INFO << "Invalid row. Row:" << row << "Column:" << column; + return 0; +} + +/*! + Returns the number of rows in the layout. + + \see columnCount +*/ +int QCPLayoutGrid::rowCount() const +{ + return mElements.size(); +} + +/*! + Returns the number of columns in the layout. + + \see rowCount +*/ +int QCPLayoutGrid::columnCount() const +{ + if (mElements.size() > 0) + return mElements.first().size(); + else + return 0; +} + +/*! + Adds the \a element to cell with \a row and \a column. If \a element is already in a layout, it + is first removed from there. If \a row or \a column don't exist yet, the layout is expanded + accordingly. + + Returns true if the element was added successfully, i.e. if the cell at \a row and \a column + didn't already have an element. + + \see element, hasElement, take, remove +*/ +bool QCPLayoutGrid::addElement(int row, int column, QCPLayoutElement *element) +{ + if (element) + { + if (!hasElement(row, column)) + { + if (element->layout()) // remove from old layout first + element->layout()->take(element); + expandTo(row+1, column+1); + mElements[row][column] = element; + adoptElement(element); + return true; + } else + qDebug() << Q_FUNC_INFO << "There is already an element in the specified row/column:" << row << column; + } else + qDebug() << Q_FUNC_INFO << "Can't add null element to row/column:" << row << column; + return false; +} + +/*! + Returns whether the cell at \a row and \a column exists and contains a valid element, i.e. isn't + empty. + + \see element +*/ +bool QCPLayoutGrid::hasElement(int row, int column) +{ + if (row >= 0 && row < rowCount() && column >= 0 && column < columnCount()) + return mElements.at(row).at(column); + else + return false; +} + +/*! + Sets the stretch \a factor of \a column. + + Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond + their minimum and maximum widths/heights (\ref QCPLayoutElement::setMinimumSize, \ref + QCPLayoutElement::setMaximumSize), regardless of the stretch factor. + + The default stretch factor of newly created rows/columns is 1. + + \see setColumnStretchFactors, setRowStretchFactor +*/ +void QCPLayoutGrid::setColumnStretchFactor(int column, double factor) +{ + if (column >= 0 && column < columnCount()) + { + if (factor > 0) + mColumnStretchFactors[column] = factor; + else + qDebug() << Q_FUNC_INFO << "Invalid stretch factor, must be positive:" << factor; + } else + qDebug() << Q_FUNC_INFO << "Invalid column:" << column; +} + +/*! + Sets the stretch \a factors of all columns. \a factors must have the size \ref columnCount. + + Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond + their minimum and maximum widths/heights (\ref QCPLayoutElement::setMinimumSize, \ref + QCPLayoutElement::setMaximumSize), regardless of the stretch factor. + + The default stretch factor of newly created rows/columns is 1. + + \see setColumnStretchFactor, setRowStretchFactors +*/ +void QCPLayoutGrid::setColumnStretchFactors(const QList &factors) +{ + if (factors.size() == mColumnStretchFactors.size()) + { + mColumnStretchFactors = factors; + for (int i=0; i= 0 && row < rowCount()) + { + if (factor > 0) + mRowStretchFactors[row] = factor; + else + qDebug() << Q_FUNC_INFO << "Invalid stretch factor, must be positive:" << factor; + } else + qDebug() << Q_FUNC_INFO << "Invalid row:" << row; +} + +/*! + Sets the stretch \a factors of all rows. \a factors must have the size \ref rowCount. + + Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond + their minimum and maximum widths/heights (\ref QCPLayoutElement::setMinimumSize, \ref + QCPLayoutElement::setMaximumSize), regardless of the stretch factor. + + The default stretch factor of newly created rows/columns is 1. + + \see setRowStretchFactor, setColumnStretchFactors +*/ +void QCPLayoutGrid::setRowStretchFactors(const QList &factors) +{ + if (factors.size() == mRowStretchFactors.size()) + { + mRowStretchFactors = factors; + for (int i=0; i()); + mRowStretchFactors.append(1); + } + // go through rows and expand columns as necessary: + int newColCount = qMax(columnCount(), newColumnCount); + for (int i=0; i rowCount()) + newIndex = rowCount(); + + mRowStretchFactors.insert(newIndex, 1); + QList newRow; + for (int col=0; col columnCount()) + newIndex = columnCount(); + + mColumnStretchFactors.insert(newIndex, 1); + for (int row=0; row minColWidths, minRowHeights, maxColWidths, maxRowHeights; + getMinimumRowColSizes(&minColWidths, &minRowHeights); + getMaximumRowColSizes(&maxColWidths, &maxRowHeights); + + int totalRowSpacing = (rowCount()-1) * mRowSpacing; + int totalColSpacing = (columnCount()-1) * mColumnSpacing; + QVector colWidths = getSectionSizes(maxColWidths, minColWidths, mColumnStretchFactors.toVector(), mRect.width()-totalColSpacing); + QVector rowHeights = getSectionSizes(maxRowHeights, minRowHeights, mRowStretchFactors.toVector(), mRect.height()-totalRowSpacing); + + // go through cells and set rects accordingly: + int yOffset = mRect.top(); + for (int row=0; row 0) + yOffset += rowHeights.at(row-1)+mRowSpacing; + int xOffset = mRect.left(); + for (int col=0; col 0) + xOffset += colWidths.at(col-1)+mColumnSpacing; + if (mElements.at(row).at(col)) + mElements.at(row).at(col)->setOuterRect(QRect(xOffset, yOffset, colWidths.at(col), rowHeights.at(row))); + } + } +} + +/* inherits documentation from base class */ +int QCPLayoutGrid::elementCount() const +{ + return rowCount()*columnCount(); +} + +/* inherits documentation from base class */ +QCPLayoutElement *QCPLayoutGrid::elementAt(int index) const +{ + if (index >= 0 && index < elementCount()) + return mElements.at(index / columnCount()).at(index % columnCount()); + else + return 0; +} + +/* inherits documentation from base class */ +QCPLayoutElement *QCPLayoutGrid::takeAt(int index) +{ + if (QCPLayoutElement *el = elementAt(index)) + { + releaseElement(el); + mElements[index / columnCount()][index % columnCount()] = 0; + return el; + } else + { + qDebug() << Q_FUNC_INFO << "Attempt to take invalid index:" << index; + return 0; + } +} + +/* inherits documentation from base class */ +bool QCPLayoutGrid::take(QCPLayoutElement *element) +{ + if (element) + { + for (int i=0; i QCPLayoutGrid::elements(bool recursive) const +{ + QList result; + int colC = columnCount(); + int rowC = rowCount(); +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + result.reserve(colC*rowC); +#endif + for (int row=0; rowelements(recursive); + } + } + return result; +} + +/*! + Simplifies the layout by collapsing rows and columns which only contain empty cells. +*/ +void QCPLayoutGrid::simplify() +{ + // remove rows with only empty cells: + for (int row=rowCount()-1; row>=0; --row) + { + bool hasElements = false; + for (int col=0; col=0; --col) + { + bool hasElements = false; + for (int row=0; row minColWidths, minRowHeights; + getMinimumRowColSizes(&minColWidths, &minRowHeights); + QSize result(0, 0); + for (int i=0; i maxColWidths, maxRowHeights; + getMaximumRowColSizes(&maxColWidths, &maxRowHeights); + + QSize result(0, 0); + for (int i=0; i *minColWidths, QVector *minRowHeights) const +{ + *minColWidths = QVector(columnCount(), 0); + *minRowHeights = QVector(rowCount(), 0); + for (int row=0; rowminimumSizeHint(); + QSize min = mElements.at(row).at(col)->minimumSize(); + QSize final(min.width() > 0 ? min.width() : minHint.width(), min.height() > 0 ? min.height() : minHint.height()); + if (minColWidths->at(col) < final.width()) + (*minColWidths)[col] = final.width(); + if (minRowHeights->at(row) < final.height()) + (*minRowHeights)[row] = final.height(); + } + } + } +} + +/*! \internal + + Places the maximum column widths and row heights into \a maxColWidths and \a maxRowHeights + respectively. + + The maximum height of a row is the smallest maximum height of any element in that row. The + maximum width of a column is the smallest maximum width of any element in that column. + + This is a helper function for \ref updateLayout. + + \see getMinimumRowColSizes +*/ +void QCPLayoutGrid::getMaximumRowColSizes(QVector *maxColWidths, QVector *maxRowHeights) const +{ + *maxColWidths = QVector(columnCount(), QWIDGETSIZE_MAX); + *maxRowHeights = QVector(rowCount(), QWIDGETSIZE_MAX); + for (int row=0; rowmaximumSizeHint(); + QSize max = mElements.at(row).at(col)->maximumSize(); + QSize final(max.width() < QWIDGETSIZE_MAX ? max.width() : maxHint.width(), max.height() < QWIDGETSIZE_MAX ? max.height() : maxHint.height()); + if (maxColWidths->at(col) > final.width()) + (*maxColWidths)[col] = final.width(); + if (maxRowHeights->at(row) > final.height()) + (*maxRowHeights)[row] = final.height(); + } + } + } +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPLayoutInset +//////////////////////////////////////////////////////////////////////////////////////////////////// +/*! \class QCPLayoutInset + \brief A layout that places child elements aligned to the border or arbitrarily positioned + + Elements are placed either aligned to the border or at arbitrary position in the area of the + layout. Which placement applies is controlled with the \ref InsetPlacement (\ref + setInsetPlacement). + + Elements are added via \ref addElement(QCPLayoutElement *element, Qt::Alignment alignment) or + addElement(QCPLayoutElement *element, const QRectF &rect). If the first method is used, the inset + placement will default to \ref ipBorderAligned and the element will be aligned according to the + \a alignment parameter. The second method defaults to \ref ipFree and allows placing elements at + arbitrary position and size, defined by \a rect. + + The alignment or rect can be set via \ref setInsetAlignment or \ref setInsetRect, respectively. + + This is the layout that every QCPAxisRect has as \ref QCPAxisRect::insetLayout. +*/ + +/* start documentation of inline functions */ + +/*! \fn virtual void QCPLayoutInset::simplify() + + The QCPInsetLayout does not need simplification since it can never have empty cells due to its + linear index structure. This method does nothing. +*/ + +/* end documentation of inline functions */ + +/*! + Creates an instance of QCPLayoutInset and sets default values. +*/ +QCPLayoutInset::QCPLayoutInset() +{ +} + +QCPLayoutInset::~QCPLayoutInset() +{ + // clear all child layout elements. This is important because only the specific layouts know how + // to handle removing elements (clear calls virtual removeAt method to do that). + clear(); +} + +/*! + Returns the placement type of the element with the specified \a index. +*/ +QCPLayoutInset::InsetPlacement QCPLayoutInset::insetPlacement(int index) const +{ + if (elementAt(index)) + return mInsetPlacement.at(index); + else + { + qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; + return ipFree; + } +} + +/*! + Returns the alignment of the element with the specified \a index. The alignment only has a + meaning, if the inset placement (\ref setInsetPlacement) is \ref ipBorderAligned. +*/ +Qt::Alignment QCPLayoutInset::insetAlignment(int index) const +{ + if (elementAt(index)) + return mInsetAlignment.at(index); + else + { + qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; + return 0; + } +} + +/*! + Returns the rect of the element with the specified \a index. The rect only has a + meaning, if the inset placement (\ref setInsetPlacement) is \ref ipFree. +*/ +QRectF QCPLayoutInset::insetRect(int index) const +{ + if (elementAt(index)) + return mInsetRect.at(index); + else + { + qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; + return QRectF(); + } +} + +/*! + Sets the inset placement type of the element with the specified \a index to \a placement. + + \see InsetPlacement +*/ +void QCPLayoutInset::setInsetPlacement(int index, QCPLayoutInset::InsetPlacement placement) +{ + if (elementAt(index)) + mInsetPlacement[index] = placement; + else + qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; +} + +/*! + If the inset placement (\ref setInsetPlacement) is \ref ipBorderAligned, this function + is used to set the alignment of the element with the specified \a index to \a alignment. + + \a alignment is an or combination of the following alignment flags: Qt::AlignLeft, + Qt::AlignHCenter, Qt::AlighRight, Qt::AlignTop, Qt::AlignVCenter, Qt::AlignBottom. Any other + alignment flags will be ignored. +*/ +void QCPLayoutInset::setInsetAlignment(int index, Qt::Alignment alignment) +{ + if (elementAt(index)) + mInsetAlignment[index] = alignment; + else + qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; +} + +/*! + If the inset placement (\ref setInsetPlacement) is \ref ipFree, this function is used to set the + position and size of the element with the specified \a index to \a rect. + + \a rect is given in fractions of the whole inset layout rect. So an inset with rect (0, 0, 1, 1) + will span the entire layout. An inset with rect (0.6, 0.1, 0.35, 0.35) will be in the top right + corner of the layout, with 35% width and height of the parent layout. + + Note that the minimum and maximum sizes of the embedded element (\ref + QCPLayoutElement::setMinimumSize, \ref QCPLayoutElement::setMaximumSize) are enforced. +*/ +void QCPLayoutInset::setInsetRect(int index, const QRectF &rect) +{ + if (elementAt(index)) + mInsetRect[index] = rect; + else + qDebug() << Q_FUNC_INFO << "Invalid element index:" << index; +} + +/* inherits documentation from base class */ +void QCPLayoutInset::updateLayout() +{ + for (int i=0; iminimumSizeHint(); + QSize maxSizeHint = mElements.at(i)->maximumSizeHint(); + finalMinSize.setWidth(mElements.at(i)->minimumSize().width() > 0 ? mElements.at(i)->minimumSize().width() : minSizeHint.width()); + finalMinSize.setHeight(mElements.at(i)->minimumSize().height() > 0 ? mElements.at(i)->minimumSize().height() : minSizeHint.height()); + finalMaxSize.setWidth(mElements.at(i)->maximumSize().width() < QWIDGETSIZE_MAX ? mElements.at(i)->maximumSize().width() : maxSizeHint.width()); + finalMaxSize.setHeight(mElements.at(i)->maximumSize().height() < QWIDGETSIZE_MAX ? mElements.at(i)->maximumSize().height() : maxSizeHint.height()); + if (mInsetPlacement.at(i) == ipFree) + { + insetRect = QRect(rect().x()+rect().width()*mInsetRect.at(i).x(), + rect().y()+rect().height()*mInsetRect.at(i).y(), + rect().width()*mInsetRect.at(i).width(), + rect().height()*mInsetRect.at(i).height()); + if (insetRect.size().width() < finalMinSize.width()) + insetRect.setWidth(finalMinSize.width()); + if (insetRect.size().height() < finalMinSize.height()) + insetRect.setHeight(finalMinSize.height()); + if (insetRect.size().width() > finalMaxSize.width()) + insetRect.setWidth(finalMaxSize.width()); + if (insetRect.size().height() > finalMaxSize.height()) + insetRect.setHeight(finalMaxSize.height()); + } else if (mInsetPlacement.at(i) == ipBorderAligned) + { + insetRect.setSize(finalMinSize); + Qt::Alignment al = mInsetAlignment.at(i); + if (al.testFlag(Qt::AlignLeft)) insetRect.moveLeft(rect().x()); + else if (al.testFlag(Qt::AlignRight)) insetRect.moveRight(rect().x()+rect().width()); + else insetRect.moveLeft(rect().x()+rect().width()*0.5-finalMinSize.width()*0.5); // default to Qt::AlignHCenter + if (al.testFlag(Qt::AlignTop)) insetRect.moveTop(rect().y()); + else if (al.testFlag(Qt::AlignBottom)) insetRect.moveBottom(rect().y()+rect().height()); + else insetRect.moveTop(rect().y()+rect().height()*0.5-finalMinSize.height()*0.5); // default to Qt::AlignVCenter + } + mElements.at(i)->setOuterRect(insetRect); + } +} + +/* inherits documentation from base class */ +int QCPLayoutInset::elementCount() const +{ + return mElements.size(); +} + +/* inherits documentation from base class */ +QCPLayoutElement *QCPLayoutInset::elementAt(int index) const +{ + if (index >= 0 && index < mElements.size()) + return mElements.at(index); + else + return 0; +} + +/* inherits documentation from base class */ +QCPLayoutElement *QCPLayoutInset::takeAt(int index) +{ + if (QCPLayoutElement *el = elementAt(index)) + { + releaseElement(el); + mElements.removeAt(index); + mInsetPlacement.removeAt(index); + mInsetAlignment.removeAt(index); + mInsetRect.removeAt(index); + return el; + } else + { + qDebug() << Q_FUNC_INFO << "Attempt to take invalid index:" << index; + return 0; + } +} + +/* inherits documentation from base class */ +bool QCPLayoutInset::take(QCPLayoutElement *element) +{ + if (element) + { + for (int i=0; irealVisibility() && mElements.at(i)->selectTest(pos, onlySelectable) >= 0) + return mParentPlot->selectionTolerance()*0.99; + } + return -1; +} + +/*! + Adds the specified \a element to the layout as an inset aligned at the border (\ref + setInsetAlignment is initialized with \ref ipBorderAligned). The alignment is set to \a + alignment. + + \a alignment is an or combination of the following alignment flags: Qt::AlignLeft, + Qt::AlignHCenter, Qt::AlighRight, Qt::AlignTop, Qt::AlignVCenter, Qt::AlignBottom. Any other + alignment flags will be ignored. + + \see addElement(QCPLayoutElement *element, const QRectF &rect) +*/ +void QCPLayoutInset::addElement(QCPLayoutElement *element, Qt::Alignment alignment) +{ + if (element) + { + if (element->layout()) // remove from old layout first + element->layout()->take(element); + mElements.append(element); + mInsetPlacement.append(ipBorderAligned); + mInsetAlignment.append(alignment); + mInsetRect.append(QRectF(0.6, 0.6, 0.4, 0.4)); + adoptElement(element); + } else + qDebug() << Q_FUNC_INFO << "Can't add null element"; +} + +/*! + Adds the specified \a element to the layout as an inset with free positioning/sizing (\ref + setInsetAlignment is initialized with \ref ipFree). The position and size is set to \a + rect. + + \a rect is given in fractions of the whole inset layout rect. So an inset with rect (0, 0, 1, 1) + will span the entire layout. An inset with rect (0.6, 0.1, 0.35, 0.35) will be in the top right + corner of the layout, with 35% width and height of the parent layout. + + \see addElement(QCPLayoutElement *element, Qt::Alignment alignment) +*/ +void QCPLayoutInset::addElement(QCPLayoutElement *element, const QRectF &rect) +{ + if (element) + { + if (element->layout()) // remove from old layout first + element->layout()->take(element); + mElements.append(element); + mInsetPlacement.append(ipFree); + mInsetAlignment.append(Qt::AlignRight|Qt::AlignTop); + mInsetRect.append(rect); + adoptElement(element); + } else + qDebug() << Q_FUNC_INFO << "Can't add null element"; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPLineEnding +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPLineEnding + \brief Handles the different ending decorations for line-like items + + \image html QCPLineEnding.png "The various ending styles currently supported" + + For every ending a line-like item has, an instance of this class exists. For example, QCPItemLine + has two endings which can be set with QCPItemLine::setHead and QCPItemLine::setTail. + + The styles themselves are defined via the enum QCPLineEnding::EndingStyle. Most decorations can + be modified regarding width and length, see \ref setWidth and \ref setLength. The direction of + the ending decoration (e.g. direction an arrow is pointing) is controlled by the line-like item. + For example, when both endings of a QCPItemLine are set to be arrows, they will point to opposite + directions, e.g. "outward". This can be changed by \ref setInverted, which would make the + respective arrow point inward. + + Note that due to the overloaded QCPLineEnding constructor, you may directly specify a + QCPLineEnding::EndingStyle where actually a QCPLineEnding is expected, e.g. \code + myItemLine->setHead(QCPLineEnding::esSpikeArrow) \endcode +*/ + +/*! + Creates a QCPLineEnding instance with default values (style \ref esNone). +*/ +QCPLineEnding::QCPLineEnding() : + mStyle(esNone), + mWidth(8), + mLength(10), + mInverted(false) +{ +} + +/*! + Creates a QCPLineEnding instance with the specified values. +*/ +QCPLineEnding::QCPLineEnding(QCPLineEnding::EndingStyle style, double width, double length, bool inverted) : + mStyle(style), + mWidth(width), + mLength(length), + mInverted(inverted) +{ +} + +/*! + Sets the style of the ending decoration. +*/ +void QCPLineEnding::setStyle(QCPLineEnding::EndingStyle style) +{ + mStyle = style; +} + +/*! + Sets the width of the ending decoration, if the style supports it. On arrows, for example, the + width defines the size perpendicular to the arrow's pointing direction. + + \see setLength +*/ +void QCPLineEnding::setWidth(double width) +{ + mWidth = width; +} + +/*! + Sets the length of the ending decoration, if the style supports it. On arrows, for example, the + length defines the size in pointing direction. + + \see setWidth +*/ +void QCPLineEnding::setLength(double length) +{ + mLength = length; +} + +/*! + Sets whether the ending decoration shall be inverted. For example, an arrow decoration will point + inward when \a inverted is set to true. + + Note that also the \a width direction is inverted. For symmetrical ending styles like arrows or + discs, this doesn't make a difference. However, asymmetric styles like \ref esHalfBar are + affected by it, which can be used to control to which side the half bar points to. +*/ +void QCPLineEnding::setInverted(bool inverted) +{ + mInverted = inverted; +} + +/*! \internal + + Returns the maximum pixel radius the ending decoration might cover, starting from the position + the decoration is drawn at (typically a line ending/\ref QCPItemPosition of an item). + + This is relevant for clipping. Only omit painting of the decoration when the position where the + decoration is supposed to be drawn is farther away from the clipping rect than the returned + distance. +*/ +double QCPLineEnding::boundingDistance() const +{ + switch (mStyle) + { + case esNone: + return 0; + + case esFlatArrow: + case esSpikeArrow: + case esLineArrow: + case esSkewedBar: + return qSqrt(mWidth*mWidth+mLength*mLength); // items that have width and length + + case esDisc: + case esSquare: + case esDiamond: + case esBar: + case esHalfBar: + return mWidth*1.42; // items that only have a width -> width*sqrt(2) + + } + return 0; +} + +/*! + Starting from the origin of this line ending (which is style specific), returns the length + covered by the line ending symbol, in backward direction. + + For example, the \ref esSpikeArrow has a shorter real length than a \ref esFlatArrow, even if + both have the same \ref setLength value, because the spike arrow has an inward curved back, which + reduces the length along its center axis (the drawing origin for arrows is at the tip). + + This function is used for precise, style specific placement of line endings, for example in + QCPAxes. +*/ +double QCPLineEnding::realLength() const +{ + switch (mStyle) + { + case esNone: + case esLineArrow: + case esSkewedBar: + case esBar: + case esHalfBar: + return 0; + + case esFlatArrow: + return mLength; + + case esDisc: + case esSquare: + case esDiamond: + return mWidth*0.5; + + case esSpikeArrow: + return mLength*0.8; + } + return 0; +} + +/*! \internal + + Draws the line ending with the specified \a painter at the position \a pos. The direction of the + line ending is controlled with \a dir. +*/ +void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, const QVector2D &dir) const +{ + if (mStyle == esNone) + return; + + QVector2D lengthVec(dir.normalized()); + if (lengthVec.isNull()) + lengthVec = QVector2D(1, 0); + QVector2D widthVec(-lengthVec.y(), lengthVec.x()); + lengthVec *= (float)(mLength*(mInverted ? -1 : 1)); + widthVec *= (float)(mWidth*0.5*(mInverted ? -1 : 1)); + + QPen penBackup = painter->pen(); + QBrush brushBackup = painter->brush(); + QPen miterPen = penBackup; + miterPen.setJoinStyle(Qt::MiterJoin); // to make arrow heads spikey + QBrush brush(painter->pen().color(), Qt::SolidPattern); + switch (mStyle) + { + case esNone: break; + case esFlatArrow: + { + QPointF points[3] = {pos.toPointF(), + (pos-lengthVec+widthVec).toPointF(), + (pos-lengthVec-widthVec).toPointF() + }; + painter->setPen(miterPen); + painter->setBrush(brush); + painter->drawConvexPolygon(points, 3); + painter->setBrush(brushBackup); + painter->setPen(penBackup); + break; + } + case esSpikeArrow: + { + QPointF points[4] = {pos.toPointF(), + (pos-lengthVec+widthVec).toPointF(), + (pos-lengthVec*0.8f).toPointF(), + (pos-lengthVec-widthVec).toPointF() + }; + painter->setPen(miterPen); + painter->setBrush(brush); + painter->drawConvexPolygon(points, 4); + painter->setBrush(brushBackup); + painter->setPen(penBackup); + break; + } + case esLineArrow: + { + QPointF points[3] = {(pos-lengthVec+widthVec).toPointF(), + pos.toPointF(), + (pos-lengthVec-widthVec).toPointF() + }; + painter->setPen(miterPen); + painter->drawPolyline(points, 3); + painter->setPen(penBackup); + break; + } + case esDisc: + { + painter->setBrush(brush); + painter->drawEllipse(pos.toPointF(), mWidth*0.5, mWidth*0.5); + painter->setBrush(brushBackup); + break; + } + case esSquare: + { + QVector2D widthVecPerp(-widthVec.y(), widthVec.x()); + QPointF points[4] = {(pos-widthVecPerp+widthVec).toPointF(), + (pos-widthVecPerp-widthVec).toPointF(), + (pos+widthVecPerp-widthVec).toPointF(), + (pos+widthVecPerp+widthVec).toPointF() + }; + painter->setPen(miterPen); + painter->setBrush(brush); + painter->drawConvexPolygon(points, 4); + painter->setBrush(brushBackup); + painter->setPen(penBackup); + break; + } + case esDiamond: + { + QVector2D widthVecPerp(-widthVec.y(), widthVec.x()); + QPointF points[4] = {(pos-widthVecPerp).toPointF(), + (pos-widthVec).toPointF(), + (pos+widthVecPerp).toPointF(), + (pos+widthVec).toPointF() + }; + painter->setPen(miterPen); + painter->setBrush(brush); + painter->drawConvexPolygon(points, 4); + painter->setBrush(brushBackup); + painter->setPen(penBackup); + break; + } + case esBar: + { + painter->drawLine((pos+widthVec).toPointF(), (pos-widthVec).toPointF()); + break; + } + case esHalfBar: + { + painter->drawLine((pos+widthVec).toPointF(), pos.toPointF()); + break; + } + case esSkewedBar: + { + if (qFuzzyIsNull(painter->pen().widthF()) && !painter->modes().testFlag(QCPPainter::pmNonCosmetic)) + { + // if drawing with cosmetic pen (perfectly thin stroke, happens only in vector exports), draw bar exactly on tip of line + painter->drawLine((pos+widthVec+lengthVec*0.2f*(mInverted?-1:1)).toPointF(), + (pos-widthVec-lengthVec*0.2f*(mInverted?-1:1)).toPointF()); + } else + { + // if drawing with thick (non-cosmetic) pen, shift bar a little in line direction to prevent line from sticking through bar slightly + painter->drawLine((pos+widthVec+lengthVec*0.2f*(mInverted?-1:1)+dir.normalized()*qMax(1.0f, (float)painter->pen().widthF())*0.5f).toPointF(), + (pos-widthVec-lengthVec*0.2f*(mInverted?-1:1)+dir.normalized()*qMax(1.0f, (float)painter->pen().widthF())*0.5f).toPointF()); + } + break; + } + } +} + +/*! \internal + \overload + + Draws the line ending. The direction is controlled with the \a angle parameter in radians. +*/ +void QCPLineEnding::draw(QCPPainter *painter, const QVector2D &pos, double angle) const +{ + draw(painter, pos, QVector2D(qCos(angle), qSin(angle))); +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPGrid +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPGrid + \brief Responsible for drawing the grid of a QCPAxis. + + This class is tightly bound to QCPAxis. Every axis owns a grid instance and uses it to draw the + grid lines, sub grid lines and zero-line. You can interact with the grid of an axis via \ref + QCPAxis::grid. Normally, you don't need to create an instance of QCPGrid yourself. + + The axis and grid drawing was split into two classes to allow them to be placed on different + layers (both QCPAxis and QCPGrid inherit from QCPLayerable). Thus it is possible to have the grid + in the background and the axes in the foreground, and any plottables/items in between. This + described situation is the default setup, see the QCPLayer documentation. +*/ + +/*! + Creates a QCPGrid instance and sets default values. + + You shouldn't instantiate grids on their own, since every QCPAxis brings its own QCPGrid. +*/ +QCPGrid::QCPGrid(QCPAxis *parentAxis) : + QCPLayerable(parentAxis->parentPlot(), "", parentAxis), + mParentAxis(parentAxis) +{ + // warning: this is called in QCPAxis constructor, so parentAxis members should not be accessed/called + setParent(parentAxis); + setPen(QPen(QColor(200,200,200), 0, Qt::DotLine)); + setSubGridPen(QPen(QColor(220,220,220), 0, Qt::DotLine)); + setZeroLinePen(QPen(QColor(200,200,200), 0, Qt::SolidLine)); + setSubGridVisible(false); + setAntialiased(false); + setAntialiasedSubGrid(false); + setAntialiasedZeroLine(false); +} + +/*! + Sets whether grid lines at sub tick marks are drawn. + + \see setSubGridPen +*/ +void QCPGrid::setSubGridVisible(bool visible) +{ + mSubGridVisible = visible; +} + +/*! + Sets whether sub grid lines are drawn antialiased. +*/ +void QCPGrid::setAntialiasedSubGrid(bool enabled) +{ + mAntialiasedSubGrid = enabled; +} + +/*! + Sets whether zero lines are drawn antialiased. +*/ +void QCPGrid::setAntialiasedZeroLine(bool enabled) +{ + mAntialiasedZeroLine = enabled; +} + +/*! + Sets the pen with which (major) grid lines are drawn. +*/ +void QCPGrid::setPen(const QPen &pen) +{ + mPen = pen; +} + +/*! + Sets the pen with which sub grid lines are drawn. +*/ +void QCPGrid::setSubGridPen(const QPen &pen) +{ + mSubGridPen = pen; +} + +/*! + Sets the pen with which zero lines are drawn. + + Zero lines are lines at value coordinate 0 which may be drawn with a different pen than other grid + lines. To disable zero lines and just draw normal grid lines at zero, set \a pen to Qt::NoPen. +*/ +void QCPGrid::setZeroLinePen(const QPen &pen) +{ + mZeroLinePen = pen; +} + +/*! \internal + + A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter + before drawing the major grid lines. + + This is the antialiasing state the painter passed to the \ref draw method is in by default. + + This function takes into account the local setting of the antialiasing flag as well as the + overrides set with \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. + + \see setAntialiased +*/ +void QCPGrid::applyDefaultAntialiasingHint(QCPPainter *painter) const +{ + applyAntialiasingHint(painter, mAntialiased, QCP::aeGrid); +} + +/*! \internal + + Draws grid lines and sub grid lines at the positions of (sub) ticks of the parent axis, spanning + over the complete axis rect. Also draws the zero line, if appropriate (\ref setZeroLinePen). +*/ +void QCPGrid::draw(QCPPainter *painter) +{ + if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; } + + if (mSubGridVisible) + drawSubGridLines(painter); + drawGridLines(painter); +} + +/*! \internal + + Draws the main grid lines and possibly a zero line with the specified painter. + + This is a helper function called by \ref draw. +*/ +void QCPGrid::drawGridLines(QCPPainter *painter) const +{ + if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; } + + int lowTick = mParentAxis->mLowestVisibleTick; + int highTick = mParentAxis->mHighestVisibleTick; + double t; // helper variable, result of coordinate-to-pixel transforms + if (mParentAxis->orientation() == Qt::Horizontal) + { + // draw zeroline: + int zeroLineIndex = -1; + if (mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0) + { + applyAntialiasingHint(painter, mAntialiasedZeroLine, QCP::aeZeroLine); + painter->setPen(mZeroLinePen); + double epsilon = mParentAxis->range().size()*1E-6; // for comparing double to zero + for (int i=lowTick; i <= highTick; ++i) + { + if (qAbs(mParentAxis->mTickVector.at(i)) < epsilon) + { + zeroLineIndex = i; + t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // x + painter->drawLine(QLineF(t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top())); + break; + } + } + } + // draw grid lines: + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + for (int i=lowTick; i <= highTick; ++i) + { + if (i == zeroLineIndex) continue; // don't draw a gridline on top of the zeroline + t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // x + painter->drawLine(QLineF(t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top())); + } + } else + { + // draw zeroline: + int zeroLineIndex = -1; + if (mZeroLinePen.style() != Qt::NoPen && mParentAxis->mRange.lower < 0 && mParentAxis->mRange.upper > 0) + { + applyAntialiasingHint(painter, mAntialiasedZeroLine, QCP::aeZeroLine); + painter->setPen(mZeroLinePen); + double epsilon = mParentAxis->mRange.size()*1E-6; // for comparing double to zero + for (int i=lowTick; i <= highTick; ++i) + { + if (qAbs(mParentAxis->mTickVector.at(i)) < epsilon) + { + zeroLineIndex = i; + t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // y + painter->drawLine(QLineF(mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t)); + break; + } + } + } + // draw grid lines: + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + for (int i=lowTick; i <= highTick; ++i) + { + if (i == zeroLineIndex) continue; // don't draw a gridline on top of the zeroline + t = mParentAxis->coordToPixel(mParentAxis->mTickVector.at(i)); // y + painter->drawLine(QLineF(mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t)); + } + } +} + +/*! \internal + + Draws the sub grid lines with the specified painter. + + This is a helper function called by \ref draw. +*/ +void QCPGrid::drawSubGridLines(QCPPainter *painter) const +{ + if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; } + + applyAntialiasingHint(painter, mAntialiasedSubGrid, QCP::aeSubGrid); + double t; // helper variable, result of coordinate-to-pixel transforms + painter->setPen(mSubGridPen); + if (mParentAxis->orientation() == Qt::Horizontal) + { + for (int i=0; imSubTickVector.size(); ++i) + { + t = mParentAxis->coordToPixel(mParentAxis->mSubTickVector.at(i)); // x + painter->drawLine(QLineF(t, mParentAxis->mAxisRect->bottom(), t, mParentAxis->mAxisRect->top())); + } + } else + { + for (int i=0; imSubTickVector.size(); ++i) + { + t = mParentAxis->coordToPixel(mParentAxis->mSubTickVector.at(i)); // y + painter->drawLine(QLineF(mParentAxis->mAxisRect->left(), t, mParentAxis->mAxisRect->right(), t)); + } + } +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPAxis +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPAxis + \brief Manages a single axis inside a QCustomPlot. + + Usually doesn't need to be instantiated externally. Access %QCustomPlot's default four axes via + QCustomPlot::xAxis (bottom), QCustomPlot::yAxis (left), QCustomPlot::xAxis2 (top) and + QCustomPlot::yAxis2 (right). + + Axes are always part of an axis rect, see QCPAxisRect. + \image html AxisNamesOverview.png +
Naming convention of axis parts
+ \n + + \image html AxisRectSpacingOverview.png +
Overview of the spacings and paddings that define the geometry of an axis. The dashed gray line + on the left represents the QCustomPlot widget border.
+ +*/ + +/* start of documentation of inline functions */ + +/*! \fn Qt::Orientation QCPAxis::orientation() const + + Returns the orientation of this axis. The axis orientation (horizontal or vertical) is deduced + from the axis type (left, top, right or bottom). + + \see orientation(AxisType type) +*/ + +/*! \fn QCPGrid *QCPAxis::grid() const + + Returns the \ref QCPGrid instance belonging to this axis. Access it to set details about the way the + grid is displayed. +*/ + +/*! \fn static Qt::Orientation QCPAxis::orientation(AxisType type) + + Returns the orientation of the specified axis type + + \see orientation() +*/ + +/* end of documentation of inline functions */ +/* start of documentation of signals */ + +/*! \fn void QCPAxis::ticksRequest() + + This signal is emitted when \ref setAutoTicks is false and the axis is about to generate tick + labels for a replot. + + Modifying the tick positions can be done with \ref setTickVector. If you also want to control the + tick labels, set \ref setAutoTickLabels to false and also provide the labels with \ref + setTickVectorLabels. + + If you only want static ticks you probably don't need this signal, since you can just set the + tick vector (and possibly tick label vector) once. However, if you want to provide ticks (and + maybe labels) dynamically, e.g. depending on the current axis range, connect a slot to this + signal and set the vector/vectors there. +*/ + +/*! \fn void QCPAxis::rangeChanged(const QCPRange &newRange) + + This signal is emitted when the range of this axis has changed. You can connect it to the \ref + setRange slot of another axis to communicate the new range to the other axis, in order for it to + be synchronized. +*/ + +/*! \fn void QCPAxis::rangeChanged(const QCPRange &newRange, const QCPRange &oldRange) + \overload + + Additionally to the new range, this signal also provides the previous range held by the axis as + \a oldRange. +*/ + +/*! \fn void QCPAxis::scaleTypeChanged(QCPAxis::ScaleType scaleType); + + This signal is emitted when the scale type changes, by calls to \ref setScaleType +*/ + +/*! \fn void QCPAxis::selectionChanged(QCPAxis::SelectableParts selection) + + This signal is emitted when the selection state of this axis has changed, either by user interaction + or by a direct call to \ref setSelectedParts. +*/ + +/*! \fn void QCPAxis::selectableChanged(const QCPAxis::SelectableParts &parts); + + This signal is emitted when the selectability changes, by calls to \ref setSelectableParts +*/ + +/* end of documentation of signals */ + +/*! + Constructs an Axis instance of Type \a type for the axis rect \a parent. + You shouldn't instantiate axes directly, rather use \ref QCPAxisRect::addAxis. +*/ +QCPAxis::QCPAxis(QCPAxisRect *parent, AxisType type) : + QCPLayerable(parent->parentPlot(), "", parent), + // axis base: + mAxisType(type), + mAxisRect(parent), + mPadding(5), + mOrientation(orientation(type)), + mSelectableParts(spAxis | spTickLabels | spAxisLabel), + mSelectedParts(spNone), + mBasePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + mSelectedBasePen(QPen(Qt::blue, 2)), + // axis label: + mLabel(""), + mLabelFont(mParentPlot->font()), + mSelectedLabelFont(QFont(mLabelFont.family(), mLabelFont.pointSize(), QFont::Bold)), + mLabelColor(Qt::black), + mSelectedLabelColor(Qt::blue), + // tick labels: + mTickLabels(true), + mAutoTickLabels(true), + mTickLabelType(ltNumber), + mTickLabelFont(mParentPlot->font()), + mSelectedTickLabelFont(QFont(mTickLabelFont.family(), mTickLabelFont.pointSize(), QFont::Bold)), + mTickLabelColor(Qt::black), + mSelectedTickLabelColor(Qt::blue), + mDateTimeFormat("hh:mm:ss\ndd.MM.yy"), + mDateTimeSpec(Qt::LocalTime), + mNumberPrecision(6), + mNumberFormatChar('g'), + mNumberBeautifulPowers(true), + // ticks and subticks: + mTicks(true), + mTickStep(1), + mSubTickCount(4), + mAutoTickCount(6), + mAutoTicks(true), + mAutoTickStep(true), + mAutoSubTicks(true), + mTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + mSelectedTickPen(QPen(Qt::blue, 2)), + mSubTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + mSelectedSubTickPen(QPen(Qt::blue, 2)), + // scale and range: + mRange(0, 5), + mRangeReversed(false), + mScaleType(stLinear), + mScaleLogBase(10), + mScaleLogBaseLogInv(1.0/qLn(mScaleLogBase)), + // internal members: + mGrid(new QCPGrid(this)), + mAxisPainter(new QCPAxisPainterPrivate(parent->parentPlot())), + mLowestVisibleTick(0), + mHighestVisibleTick(-1), + mCachedMarginValid(false), + mCachedMargin(0) +{ + mGrid->setVisible(false); + setAntialiased(false); + setLayer(mParentPlot->currentLayer()); // it's actually on that layer already, but we want it in front of the grid, so we place it on there again + + if (type == atTop) + { + setTickLabelPadding(3); + setLabelPadding(6); + } else if (type == atRight) + { + setTickLabelPadding(7); + setLabelPadding(12); + } else if (type == atBottom) + { + setTickLabelPadding(3); + setLabelPadding(3); + } else if (type == atLeft) + { + setTickLabelPadding(5); + setLabelPadding(10); + } +} + +QCPAxis::~QCPAxis() +{ + delete mAxisPainter; +} + +/* No documentation as it is a property getter */ +int QCPAxis::tickLabelPadding() const +{ + return mAxisPainter->tickLabelPadding; +} + +/* No documentation as it is a property getter */ +double QCPAxis::tickLabelRotation() const +{ + return mAxisPainter->tickLabelRotation; +} + +/* No documentation as it is a property getter */ +QCPAxis::LabelSide QCPAxis::tickLabelSide() const +{ + return mAxisPainter->tickLabelSide; +} + +/* No documentation as it is a property getter */ +QString QCPAxis::numberFormat() const +{ + QString result; + result.append(mNumberFormatChar); + if (mNumberBeautifulPowers) + { + result.append("b"); + if (mAxisPainter->numberMultiplyCross) + result.append("c"); + } + return result; +} + +/* No documentation as it is a property getter */ +int QCPAxis::tickLengthIn() const +{ + return mAxisPainter->tickLengthIn; +} + +/* No documentation as it is a property getter */ +int QCPAxis::tickLengthOut() const +{ + return mAxisPainter->tickLengthOut; +} + +/* No documentation as it is a property getter */ +int QCPAxis::subTickLengthIn() const +{ + return mAxisPainter->subTickLengthIn; +} + +/* No documentation as it is a property getter */ +int QCPAxis::subTickLengthOut() const +{ + return mAxisPainter->subTickLengthOut; +} + +/* No documentation as it is a property getter */ +int QCPAxis::labelPadding() const +{ + return mAxisPainter->labelPadding; +} + +/* No documentation as it is a property getter */ +int QCPAxis::offset() const +{ + return mAxisPainter->offset; +} + +/* No documentation as it is a property getter */ +QCPLineEnding QCPAxis::lowerEnding() const +{ + return mAxisPainter->lowerEnding; +} + +/* No documentation as it is a property getter */ +QCPLineEnding QCPAxis::upperEnding() const +{ + return mAxisPainter->upperEnding; +} + +/*! + Sets whether the axis uses a linear scale or a logarithmic scale. If \a type is set to \ref + stLogarithmic, the logarithm base can be set with \ref setScaleLogBase. In logarithmic axis + scaling, major tick marks appear at all powers of the logarithm base. Properties like tick step + (\ref setTickStep) don't apply in logarithmic scaling. If you wish a decimal base but less major + ticks, consider choosing a logarithm base of 100, 1000 or even higher. + + If \a type is \ref stLogarithmic and the number format (\ref setNumberFormat) uses the 'b' option + (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 + [superscript] n", which looks unnatural for logarithmic scaling (the "1 [multiplication sign]" + part). To only display the decimal power, set the number precision to zero with + \ref setNumberPrecision. +*/ +void QCPAxis::setScaleType(QCPAxis::ScaleType type) +{ + if (mScaleType != type) + { + mScaleType = type; + if (mScaleType == stLogarithmic) + setRange(mRange.sanitizedForLogScale()); + mCachedMarginValid = false; + emit scaleTypeChanged(mScaleType); + } +} + +/*! + If \ref setScaleType is set to \ref stLogarithmic, \a base will be the logarithm base of the + scaling. In logarithmic axis scaling, major tick marks appear at all powers of \a base. + + Properties like tick step (\ref setTickStep) don't apply in logarithmic scaling. If you wish a decimal base but + less major ticks, consider choosing \a base 100, 1000 or even higher. +*/ +void QCPAxis::setScaleLogBase(double base) +{ + if (base > 1) + { + mScaleLogBase = base; + mScaleLogBaseLogInv = 1.0/qLn(mScaleLogBase); // buffer for faster baseLog() calculation + mCachedMarginValid = false; + } else + qDebug() << Q_FUNC_INFO << "Invalid logarithmic scale base (must be greater 1):" << base; +} + +/*! + Sets the range of the axis. + + This slot may be connected with the \ref rangeChanged signal of another axis so this axis + is always synchronized with the other axis range, when it changes. + + To invert the direction of an axis, use \ref setRangeReversed. +*/ +void QCPAxis::setRange(const QCPRange &range) +{ + if (range.lower == mRange.lower && range.upper == mRange.upper) + return; + + if (!QCPRange::validRange(range)) return; + QCPRange oldRange = mRange; + if (mScaleType == stLogarithmic) + { + mRange = range.sanitizedForLogScale(); + } else + { + mRange = range.sanitizedForLinScale(); + } + mCachedMarginValid = false; + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); +} + +/*! + Sets whether the user can (de-)select the parts in \a selectable by clicking on the QCustomPlot surface. + (When \ref QCustomPlot::setInteractions contains iSelectAxes.) + + However, even when \a selectable is set to a value not allowing the selection of a specific part, + it is still possible to set the selection of this part manually, by calling \ref setSelectedParts + directly. + + \see SelectablePart, setSelectedParts +*/ +void QCPAxis::setSelectableParts(const SelectableParts &selectable) +{ + if (mSelectableParts != selectable) + { + mSelectableParts = selectable; + emit selectableChanged(mSelectableParts); + } +} + +/*! + Sets the selected state of the respective axis parts described by \ref SelectablePart. When a part + is selected, it uses a different pen/font. + + The entire selection mechanism for axes is handled automatically when \ref + QCustomPlot::setInteractions contains iSelectAxes. You only need to call this function when you + wish to change the selection state manually. + + This function can change the selection state of a part, independent of the \ref setSelectableParts setting. + + emits the \ref selectionChanged signal when \a selected is different from the previous selection state. + + \see SelectablePart, setSelectableParts, selectTest, setSelectedBasePen, setSelectedTickPen, setSelectedSubTickPen, + setSelectedTickLabelFont, setSelectedLabelFont, setSelectedTickLabelColor, setSelectedLabelColor +*/ +void QCPAxis::setSelectedParts(const SelectableParts &selected) +{ + if (mSelectedParts != selected) + { + mSelectedParts = selected; + emit selectionChanged(mSelectedParts); + } +} + +/*! + \overload + + Sets the lower and upper bound of the axis range. + + To invert the direction of an axis, use \ref setRangeReversed. + + There is also a slot to set a range, see \ref setRange(const QCPRange &range). +*/ +void QCPAxis::setRange(double lower, double upper) +{ + if (lower == mRange.lower && upper == mRange.upper) + return; + + if (!QCPRange::validRange(lower, upper)) return; + QCPRange oldRange = mRange; + mRange.lower = lower; + mRange.upper = upper; + if (mScaleType == stLogarithmic) + { + mRange = mRange.sanitizedForLogScale(); + } else + { + mRange = mRange.sanitizedForLinScale(); + } + mCachedMarginValid = false; + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); +} + +/*! + \overload + + Sets the range of the axis. + + The \a position coordinate indicates together with the \a alignment parameter, where the new + range will be positioned. \a size defines the size of the new axis range. \a alignment may be + Qt::AlignLeft, Qt::AlignRight or Qt::AlignCenter. This will cause the left border, right border, + or center of the range to be aligned with \a position. Any other values of \a alignment will + default to Qt::AlignCenter. +*/ +void QCPAxis::setRange(double position, double size, Qt::AlignmentFlag alignment) +{ + if (alignment == Qt::AlignLeft) + setRange(position, position+size); + else if (alignment == Qt::AlignRight) + setRange(position-size, position); + else // alignment == Qt::AlignCenter + setRange(position-size/2.0, position+size/2.0); +} + +/*! + Sets the lower bound of the axis range. The upper bound is not changed. + \see setRange +*/ +void QCPAxis::setRangeLower(double lower) +{ + if (mRange.lower == lower) + return; + + QCPRange oldRange = mRange; + mRange.lower = lower; + if (mScaleType == stLogarithmic) + { + mRange = mRange.sanitizedForLogScale(); + } else + { + mRange = mRange.sanitizedForLinScale(); + } + mCachedMarginValid = false; + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); +} + +/*! + Sets the upper bound of the axis range. The lower bound is not changed. + \see setRange +*/ +void QCPAxis::setRangeUpper(double upper) +{ + if (mRange.upper == upper) + return; + + QCPRange oldRange = mRange; + mRange.upper = upper; + if (mScaleType == stLogarithmic) + { + mRange = mRange.sanitizedForLogScale(); + } else + { + mRange = mRange.sanitizedForLinScale(); + } + mCachedMarginValid = false; + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); +} + +/*! + Sets whether the axis range (direction) is displayed reversed. Normally, the values on horizontal + axes increase left to right, on vertical axes bottom to top. When \a reversed is set to true, the + direction of increasing values is inverted. + + Note that the range and data interface stays the same for reversed axes, e.g. the \a lower part + of the \ref setRange interface will still reference the mathematically smaller number than the \a + upper part. +*/ +void QCPAxis::setRangeReversed(bool reversed) +{ + if (mRangeReversed != reversed) + { + mRangeReversed = reversed; + mCachedMarginValid = false; + } +} + +/*! + Sets whether the tick positions should be calculated automatically (either from an automatically + generated tick step or a tick step provided manually via \ref setTickStep, see \ref setAutoTickStep). + + If \a on is set to false, you must provide the tick positions manually via \ref setTickVector. + For these manual ticks you may let QCPAxis generate the appropriate labels automatically by + leaving \ref setAutoTickLabels set to true. If you also wish to control the displayed labels + manually, set \ref setAutoTickLabels to false and provide the label strings with \ref + setTickVectorLabels. + + If you need dynamically calculated tick vectors (and possibly tick label vectors), set the + vectors in a slot connected to the \ref ticksRequest signal. + + \see setAutoTickLabels, setAutoSubTicks, setAutoTickCount, setAutoTickStep +*/ +void QCPAxis::setAutoTicks(bool on) +{ + if (mAutoTicks != on) + { + mAutoTicks = on; + mCachedMarginValid = false; + } +} + +/*! + When \ref setAutoTickStep is true, \a approximateCount determines how many ticks should be + generated in the visible range, approximately. + + It's not guaranteed that this number of ticks is met exactly, but approximately within a + tolerance of about two. + + Only values greater than zero are accepted as \a approximateCount. + + \see setAutoTickStep, setAutoTicks, setAutoSubTicks +*/ +void QCPAxis::setAutoTickCount(int approximateCount) +{ + if (mAutoTickCount != approximateCount) + { + if (approximateCount > 0) + { + mAutoTickCount = approximateCount; + mCachedMarginValid = false; + } else + qDebug() << Q_FUNC_INFO << "approximateCount must be greater than zero:" << approximateCount; + } +} + +/*! + Sets whether the tick labels are generated automatically. Depending on the tick label type (\ref + ltNumber or \ref ltDateTime), the labels will either show the coordinate as floating point + number (\ref setNumberFormat), or a date/time formatted according to \ref setDateTimeFormat. + + If \a on is set to false, you should provide the tick labels via \ref setTickVectorLabels. This + is usually used in a combination with \ref setAutoTicks set to false for complete control over + tick positions and labels, e.g. when the ticks should be at multiples of pi and show "2pi", "3pi" + etc. as tick labels. + + If you need dynamically calculated tick vectors (and possibly tick label vectors), set the + vectors in a slot connected to the \ref ticksRequest signal. + + \see setAutoTicks +*/ +void QCPAxis::setAutoTickLabels(bool on) +{ + if (mAutoTickLabels != on) + { + mAutoTickLabels = on; + mCachedMarginValid = false; + } +} + +/*! + Sets whether the tick step, i.e. the interval between two (major) ticks, is calculated + automatically. If \a on is set to true, the axis finds a tick step that is reasonable for human + readable plots. + + The number of ticks the algorithm aims for within the visible range can be specified with \ref + setAutoTickCount. + + If \a on is set to false, you may set the tick step manually with \ref setTickStep. + + \see setAutoTicks, setAutoSubTicks, setAutoTickCount +*/ +void QCPAxis::setAutoTickStep(bool on) +{ + if (mAutoTickStep != on) + { + mAutoTickStep = on; + mCachedMarginValid = false; + } +} + +/*! + Sets whether the number of sub ticks in one tick interval is determined automatically. This + works, as long as the tick step mantissa is a multiple of 0.5. When \ref setAutoTickStep is + enabled, this is always the case. + + When \a on is set to false, you may set the sub tick count with \ref setSubTickCount manually. + + \see setAutoTickCount, setAutoTicks, setAutoTickStep +*/ +void QCPAxis::setAutoSubTicks(bool on) +{ + if (mAutoSubTicks != on) + { + mAutoSubTicks = on; + mCachedMarginValid = false; + } +} + +/*! + Sets whether tick marks are displayed. + + Note that setting \a show to false does not imply that tick labels are invisible, too. To achieve + that, see \ref setTickLabels. +*/ +void QCPAxis::setTicks(bool show) +{ + if (mTicks != show) + { + mTicks = show; + mCachedMarginValid = false; + } +} + +/*! + Sets whether tick labels are displayed. Tick labels are the numbers drawn next to tick marks. +*/ +void QCPAxis::setTickLabels(bool show) +{ + if (mTickLabels != show) + { + mTickLabels = show; + mCachedMarginValid = false; + } +} + +/*! + Sets the distance between the axis base line (including any outward ticks) and the tick labels. + \see setLabelPadding, setPadding +*/ +void QCPAxis::setTickLabelPadding(int padding) +{ + if (mAxisPainter->tickLabelPadding != padding) + { + mAxisPainter->tickLabelPadding = padding; + mCachedMarginValid = false; + } +} + +/*! + Sets whether the tick labels display numbers or dates/times. + + If \a type is set to \ref ltNumber, the format specifications of \ref setNumberFormat apply. + + If \a type is set to \ref ltDateTime, the format specifications of \ref setDateTimeFormat apply. + + In QCustomPlot, date/time coordinates are double numbers representing the seconds since + 1970-01-01T00:00:00 UTC. This format can be retrieved from QDateTime objects with the + QDateTime::toTime_t() function. Since this only gives a resolution of one second, there is also + the QDateTime::toMSecsSinceEpoch() function which returns the timespan described above in + milliseconds. Divide its return value by 1000.0 to get a value with the format needed for + date/time plotting, with a resolution of one millisecond. + + Using the toMSecsSinceEpoch function allows dates that go back to 2nd January 4713 B.C. + (represented by a negative number), unlike the toTime_t function, which works with unsigned + integers and thus only goes back to 1st January 1970. So both for range and accuracy, use of + toMSecsSinceEpoch()/1000.0 should be preferred as key coordinate for date/time axes. + + \see setTickLabels +*/ +void QCPAxis::setTickLabelType(LabelType type) +{ + if (mTickLabelType != type) + { + mTickLabelType = type; + mCachedMarginValid = false; + } +} + +/*! + Sets the font of the tick labels. + + \see setTickLabels, setTickLabelColor +*/ +void QCPAxis::setTickLabelFont(const QFont &font) +{ + if (font != mTickLabelFont) + { + mTickLabelFont = font; + mCachedMarginValid = false; + } +} + +/*! + Sets the color of the tick labels. + + \see setTickLabels, setTickLabelFont +*/ +void QCPAxis::setTickLabelColor(const QColor &color) +{ + if (color != mTickLabelColor) + { + mTickLabelColor = color; + mCachedMarginValid = false; + } +} + +/*! + Sets the rotation of the tick labels. If \a degrees is zero, the labels are drawn normally. Else, + the tick labels are drawn rotated by \a degrees clockwise. The specified angle is bound to values + from -90 to 90 degrees. + + If \a degrees is exactly -90, 0 or 90, the tick labels are centered on the tick coordinate. For + other angles, the label is drawn with an offset such that it seems to point toward or away from + the tick mark. +*/ +void QCPAxis::setTickLabelRotation(double degrees) +{ + if (!qFuzzyIsNull(degrees-mAxisPainter->tickLabelRotation)) + { + mAxisPainter->tickLabelRotation = qBound(-90.0, degrees, 90.0); + mCachedMarginValid = false; + } +} + +/*! + Sets whether the tick labels (numbers) shall appear inside or outside the axis rect. + + The usual and default setting is \ref lsOutside. Very compact plots sometimes require tick labels + to be inside the axis rect, to save space. If \a side is set to \ref lsInside, the tick labels + appear on the inside are additionally clipped to the axis rect. +*/ +void QCPAxis::setTickLabelSide(LabelSide side) +{ + mAxisPainter->tickLabelSide = side; + mCachedMarginValid = false; +} + +/*! + Sets the format in which dates and times are displayed as tick labels, if \ref setTickLabelType is \ref ltDateTime. + for details about the \a format string, see the documentation of QDateTime::toString(). + + Newlines can be inserted with "\n". + + \see setDateTimeSpec +*/ +void QCPAxis::setDateTimeFormat(const QString &format) +{ + if (mDateTimeFormat != format) + { + mDateTimeFormat = format; + mCachedMarginValid = false; + } +} + +/*! + Sets the time spec that is used for the date time values when \ref setTickLabelType is \ref + ltDateTime. + + The default value of QDateTime objects (and also QCustomPlot) is Qt::LocalTime. However, + if the date time values passed to QCustomPlot are given in the UTC spec, set \a + timeSpec to Qt::UTC to get the correct axis labels. + + \see setDateTimeFormat +*/ +void QCPAxis::setDateTimeSpec(const Qt::TimeSpec &timeSpec) +{ + mDateTimeSpec = timeSpec; +} + +/*! + Sets the number format for the numbers drawn as tick labels (if tick label type is \ref + ltNumber). This \a formatCode is an extended version of the format code used e.g. by + QString::number() and QLocale::toString(). For reference about that, see the "Argument Formats" + section in the detailed description of the QString class. \a formatCode is a string of one, two + or three characters. The first character is identical to the normal format code used by Qt. In + short, this means: 'e'/'E' scientific format, 'f' fixed format, 'g'/'G' scientific or fixed, + whichever is shorter. + + The second and third characters are optional and specific to QCustomPlot:\n + If the first char was 'e' or 'g', numbers are/might be displayed in the scientific format, e.g. + "5.5e9", which is ugly in a plot. So when the second char of \a formatCode is set to 'b' (for + "beautiful"), those exponential numbers are formatted in a more natural way, i.e. "5.5 + [multiplication sign] 10 [superscript] 9". By default, the multiplication sign is a centered dot. + If instead a cross should be shown (as is usual in the USA), the third char of \a formatCode can + be set to 'c'. The inserted multiplication signs are the UTF-8 characters 215 (0xD7) for the + cross and 183 (0xB7) for the dot. + + If the scale type (\ref setScaleType) is \ref stLogarithmic and the \a formatCode uses the 'b' + option (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 + [superscript] n", which looks unnatural for logarithmic scaling (the "1 [multiplication sign]" + part). To only display the decimal power, set the number precision to zero with \ref + setNumberPrecision. + + Examples for \a formatCode: + \li \c g normal format code behaviour. If number is small, fixed format is used, if number is large, + normal scientific format is used + \li \c gb If number is small, fixed format is used, if number is large, scientific format is used with + beautifully typeset decimal powers and a dot as multiplication sign + \li \c ebc All numbers are in scientific format with beautifully typeset decimal power and a cross as + multiplication sign + \li \c fb illegal format code, since fixed format doesn't support (or need) beautifully typeset decimal + powers. Format code will be reduced to 'f'. + \li \c hello illegal format code, since first char is not 'e', 'E', 'f', 'g' or 'G'. Current format + code will not be changed. +*/ +void QCPAxis::setNumberFormat(const QString &formatCode) +{ + if (formatCode.isEmpty()) + { + qDebug() << Q_FUNC_INFO << "Passed formatCode is empty"; + return; + } + mCachedMarginValid = false; + + // interpret first char as number format char: + QString allowedFormatChars = "eEfgG"; + if (allowedFormatChars.contains(formatCode.at(0))) + { + mNumberFormatChar = formatCode.at(0).toLatin1(); + } else + { + qDebug() << Q_FUNC_INFO << "Invalid number format code (first char not in 'eEfgG'):" << formatCode; + return; + } + if (formatCode.length() < 2) + { + mNumberBeautifulPowers = false; + mAxisPainter->numberMultiplyCross = false; + return; + } + + // interpret second char as indicator for beautiful decimal powers: + if (formatCode.at(1) == 'b' && (mNumberFormatChar == 'e' || mNumberFormatChar == 'g')) + { + mNumberBeautifulPowers = true; + } else + { + qDebug() << Q_FUNC_INFO << "Invalid number format code (second char not 'b' or first char neither 'e' nor 'g'):" << formatCode; + return; + } + if (formatCode.length() < 3) + { + mAxisPainter->numberMultiplyCross = false; + return; + } + + // interpret third char as indicator for dot or cross multiplication symbol: + if (formatCode.at(2) == 'c') + { + mAxisPainter->numberMultiplyCross = true; + } else if (formatCode.at(2) == 'd') + { + mAxisPainter->numberMultiplyCross = false; + } else + { + qDebug() << Q_FUNC_INFO << "Invalid number format code (third char neither 'c' nor 'd'):" << formatCode; + return; + } +} + +/*! + Sets the precision of the tick label numbers. See QLocale::toString(double i, char f, int prec) + for details. The effect of precisions are most notably for number Formats starting with 'e', see + \ref setNumberFormat + + If the scale type (\ref setScaleType) is \ref stLogarithmic and the number format (\ref + setNumberFormat) uses the 'b' format code (beautifully typeset decimal powers), the display + usually is "1 [multiplication sign] 10 [superscript] n", which looks unnatural for logarithmic + scaling (the redundant "1 [multiplication sign]" part). To only display the decimal power "10 + [superscript] n", set \a precision to zero. +*/ +void QCPAxis::setNumberPrecision(int precision) +{ + if (mNumberPrecision != precision) + { + mNumberPrecision = precision; + mCachedMarginValid = false; + } +} + +/*! + If \ref setAutoTickStep is set to false, use this function to set the tick step manually. + The tick step is the interval between (major) ticks, in plot coordinates. + \see setSubTickCount +*/ +void QCPAxis::setTickStep(double step) +{ + if (mTickStep != step) + { + mTickStep = step; + mCachedMarginValid = false; + } +} + +/*! + If you want full control over what ticks (and possibly labels) the axes show, this function is + used to set the coordinates at which ticks will appear.\ref setAutoTicks must be disabled, else + the provided tick vector will be overwritten with automatically generated tick coordinates upon + replot. The labels of the ticks can be generated automatically when \ref setAutoTickLabels is + left enabled. If it is disabled, you can set the labels manually with \ref setTickVectorLabels. + + \a vec is a vector containing the positions of the ticks, in plot coordinates. + + \warning \a vec must be sorted in ascending order, no additional checks are made to ensure this. + + \see setTickVectorLabels +*/ +void QCPAxis::setTickVector(const QVector &vec) +{ + // don't check whether mTickVector != vec here, because it takes longer than we would save + mTickVector = vec; + mCachedMarginValid = false; +} + +/*! + If you want full control over what ticks and labels the axes show, this function is used to set a + number of QStrings that will be displayed at the tick positions which you need to provide with + \ref setTickVector. These two vectors should have the same size. (Note that you need to disable + \ref setAutoTicks and \ref setAutoTickLabels first.) + + \a vec is a vector containing the labels of the ticks. The entries correspond to the respective + indices in the tick vector, passed via \ref setTickVector. + + \see setTickVector +*/ +void QCPAxis::setTickVectorLabels(const QVector &vec) +{ + // don't check whether mTickVectorLabels != vec here, because it takes longer than we would save + mTickVectorLabels = vec; + mCachedMarginValid = false; +} + +/*! + Sets the length of the ticks in pixels. \a inside is the length the ticks will reach inside the + plot and \a outside is the length they will reach outside the plot. If \a outside is greater than + zero, the tick labels and axis label will increase their distance to the axis accordingly, so + they won't collide with the ticks. + + \see setSubTickLength, setTickLengthIn, setTickLengthOut +*/ +void QCPAxis::setTickLength(int inside, int outside) +{ + setTickLengthIn(inside); + setTickLengthOut(outside); +} + +/*! + Sets the length of the inward ticks in pixels. \a inside is the length the ticks will reach + inside the plot. + + \see setTickLengthOut, setTickLength, setSubTickLength +*/ +void QCPAxis::setTickLengthIn(int inside) +{ + if (mAxisPainter->tickLengthIn != inside) + { + mAxisPainter->tickLengthIn = inside; + } +} + +/*! + Sets the length of the outward ticks in pixels. \a outside is the length the ticks will reach + outside the plot. If \a outside is greater than zero, the tick labels and axis label will + increase their distance to the axis accordingly, so they won't collide with the ticks. + + \see setTickLengthIn, setTickLength, setSubTickLength +*/ +void QCPAxis::setTickLengthOut(int outside) +{ + if (mAxisPainter->tickLengthOut != outside) + { + mAxisPainter->tickLengthOut = outside; + mCachedMarginValid = false; // only outside tick length can change margin + } +} + +/*! + Sets the number of sub ticks in one (major) tick step. A sub tick count of three for example, + divides the tick intervals in four sub intervals. + + By default, the number of sub ticks is chosen automatically in a reasonable manner as long as the + mantissa of the tick step is a multiple of 0.5. When \ref setAutoTickStep is enabled, this is + always the case. + + If you want to disable automatic sub tick count and use this function to set the count manually, + see \ref setAutoSubTicks. +*/ +void QCPAxis::setSubTickCount(int count) +{ + mSubTickCount = count; +} + +/*! + Sets the length of the subticks in pixels. \a inside is the length the subticks will reach inside + the plot and \a outside is the length they will reach outside the plot. If \a outside is greater + than zero, the tick labels and axis label will increase their distance to the axis accordingly, + so they won't collide with the ticks. + + \see setTickLength, setSubTickLengthIn, setSubTickLengthOut +*/ +void QCPAxis::setSubTickLength(int inside, int outside) +{ + setSubTickLengthIn(inside); + setSubTickLengthOut(outside); +} + +/*! + Sets the length of the inward subticks in pixels. \a inside is the length the subticks will reach inside + the plot. + + \see setSubTickLengthOut, setSubTickLength, setTickLength +*/ +void QCPAxis::setSubTickLengthIn(int inside) +{ + if (mAxisPainter->subTickLengthIn != inside) + { + mAxisPainter->subTickLengthIn = inside; + } +} + +/*! + Sets the length of the outward subticks in pixels. \a outside is the length the subticks will reach + outside the plot. If \a outside is greater than zero, the tick labels will increase their + distance to the axis accordingly, so they won't collide with the ticks. + + \see setSubTickLengthIn, setSubTickLength, setTickLength +*/ +void QCPAxis::setSubTickLengthOut(int outside) +{ + if (mAxisPainter->subTickLengthOut != outside) + { + mAxisPainter->subTickLengthOut = outside; + mCachedMarginValid = false; // only outside tick length can change margin + } +} + +/*! + Sets the pen, the axis base line is drawn with. + + \see setTickPen, setSubTickPen +*/ +void QCPAxis::setBasePen(const QPen &pen) +{ + mBasePen = pen; +} + +/*! + Sets the pen, tick marks will be drawn with. + + \see setTickLength, setBasePen +*/ +void QCPAxis::setTickPen(const QPen &pen) +{ + mTickPen = pen; +} + +/*! + Sets the pen, subtick marks will be drawn with. + + \see setSubTickCount, setSubTickLength, setBasePen +*/ +void QCPAxis::setSubTickPen(const QPen &pen) +{ + mSubTickPen = pen; +} + +/*! + Sets the font of the axis label. + + \see setLabelColor +*/ +void QCPAxis::setLabelFont(const QFont &font) +{ + if (mLabelFont != font) + { + mLabelFont = font; + mCachedMarginValid = false; + } +} + +/*! + Sets the color of the axis label. + + \see setLabelFont +*/ +void QCPAxis::setLabelColor(const QColor &color) +{ + mLabelColor = color; +} + +/*! + Sets the text of the axis label that will be shown below/above or next to the axis, depending on + its orientation. To disable axis labels, pass an empty string as \a str. +*/ +void QCPAxis::setLabel(const QString &str) +{ + if (mLabel != str) + { + mLabel = str; + mCachedMarginValid = false; + } +} + +/*! + Sets the distance between the tick labels and the axis label. + + \see setTickLabelPadding, setPadding +*/ +void QCPAxis::setLabelPadding(int padding) +{ + if (mAxisPainter->labelPadding != padding) + { + mAxisPainter->labelPadding = padding; + mCachedMarginValid = false; + } +} + +/*! + Sets the padding of the axis. + + When \ref QCPAxisRect::setAutoMargins is enabled, the padding is the additional outer most space, + that is left blank. + + The axis padding has no meaning if \ref QCPAxisRect::setAutoMargins is disabled. + + \see setLabelPadding, setTickLabelPadding +*/ +void QCPAxis::setPadding(int padding) +{ + if (mPadding != padding) + { + mPadding = padding; + mCachedMarginValid = false; + } +} + +/*! + Sets the offset the axis has to its axis rect side. + + If an axis rect side has multiple axes and automatic margin calculation is enabled for that side, + only the offset of the inner most axis has meaning (even if it is set to be invisible). The + offset of the other, outer axes is controlled automatically, to place them at appropriate + positions. +*/ +void QCPAxis::setOffset(int offset) +{ + mAxisPainter->offset = offset; +} + +/*! + Sets the font that is used for tick labels when they are selected. + + \see setTickLabelFont, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions +*/ +void QCPAxis::setSelectedTickLabelFont(const QFont &font) +{ + if (font != mSelectedTickLabelFont) + { + mSelectedTickLabelFont = font; + // don't set mCachedMarginValid to false here because margin calculation is always done with non-selected fonts + } +} + +/*! + Sets the font that is used for the axis label when it is selected. + + \see setLabelFont, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions +*/ +void QCPAxis::setSelectedLabelFont(const QFont &font) +{ + mSelectedLabelFont = font; + // don't set mCachedMarginValid to false here because margin calculation is always done with non-selected fonts +} + +/*! + Sets the color that is used for tick labels when they are selected. + + \see setTickLabelColor, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions +*/ +void QCPAxis::setSelectedTickLabelColor(const QColor &color) +{ + if (color != mSelectedTickLabelColor) + { + mSelectedTickLabelColor = color; + } +} + +/*! + Sets the color that is used for the axis label when it is selected. + + \see setLabelColor, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions +*/ +void QCPAxis::setSelectedLabelColor(const QColor &color) +{ + mSelectedLabelColor = color; +} + +/*! + Sets the pen that is used to draw the axis base line when selected. + + \see setBasePen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions +*/ +void QCPAxis::setSelectedBasePen(const QPen &pen) +{ + mSelectedBasePen = pen; +} + +/*! + Sets the pen that is used to draw the (major) ticks when selected. + + \see setTickPen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions +*/ +void QCPAxis::setSelectedTickPen(const QPen &pen) +{ + mSelectedTickPen = pen; +} + +/*! + Sets the pen that is used to draw the subticks when selected. + + \see setSubTickPen, setSelectableParts, setSelectedParts, QCustomPlot::setInteractions +*/ +void QCPAxis::setSelectedSubTickPen(const QPen &pen) +{ + mSelectedSubTickPen = pen; +} + +/*! + Sets the style for the lower axis ending. See the documentation of QCPLineEnding for available + styles. + + For horizontal axes, this method refers to the left ending, for vertical axes the bottom ending. + Note that this meaning does not change when the axis range is reversed with \ref + setRangeReversed. + + \see setUpperEnding +*/ +void QCPAxis::setLowerEnding(const QCPLineEnding &ending) +{ + mAxisPainter->lowerEnding = ending; +} + +/*! + Sets the style for the upper axis ending. See the documentation of QCPLineEnding for available + styles. + + For horizontal axes, this method refers to the right ending, for vertical axes the top ending. + Note that this meaning does not change when the axis range is reversed with \ref + setRangeReversed. + + \see setLowerEnding +*/ +void QCPAxis::setUpperEnding(const QCPLineEnding &ending) +{ + mAxisPainter->upperEnding = ending; +} + +/*! + If the scale type (\ref setScaleType) is \ref stLinear, \a diff is added to the lower and upper + bounds of the range. The range is simply moved by \a diff. + + If the scale type is \ref stLogarithmic, the range bounds are multiplied by \a diff. This + corresponds to an apparent "linear" move in logarithmic scaling by a distance of log(diff). +*/ +void QCPAxis::moveRange(double diff) +{ + QCPRange oldRange = mRange; + if (mScaleType == stLinear) + { + mRange.lower += diff; + mRange.upper += diff; + } else // mScaleType == stLogarithmic + { + mRange.lower *= diff; + mRange.upper *= diff; + } + mCachedMarginValid = false; + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); +} + +/*! + Scales the range of this axis by \a factor around the coordinate \a center. For example, if \a + factor is 2.0, \a center is 1.0, then the axis range will double its size, and the point at + coordinate 1.0 won't have changed its position in the QCustomPlot widget (i.e. coordinates + around 1.0 will have moved symmetrically closer to 1.0). +*/ +void QCPAxis::scaleRange(double factor, double center) +{ + QCPRange oldRange = mRange; + if (mScaleType == stLinear) + { + QCPRange newRange; + newRange.lower = (mRange.lower-center)*factor + center; + newRange.upper = (mRange.upper-center)*factor + center; + if (QCPRange::validRange(newRange)) + mRange = newRange.sanitizedForLinScale(); + } else // mScaleType == stLogarithmic + { + if ((mRange.upper < 0 && center < 0) || (mRange.upper > 0 && center > 0)) // make sure center has same sign as range + { + QCPRange newRange; + newRange.lower = qPow(mRange.lower/center, factor)*center; + newRange.upper = qPow(mRange.upper/center, factor)*center; + if (QCPRange::validRange(newRange)) + mRange = newRange.sanitizedForLogScale(); + } else + qDebug() << Q_FUNC_INFO << "Center of scaling operation doesn't lie in same logarithmic sign domain as range:" << center; + } + mCachedMarginValid = false; + emit rangeChanged(mRange); + emit rangeChanged(mRange, oldRange); +} + +/*! + Scales the range of this axis to have a certain scale \a ratio to \a otherAxis. The scaling will + be done around the center of the current axis range. + + For example, if \a ratio is 1, this axis is the \a yAxis and \a otherAxis is \a xAxis, graphs + plotted with those axes will appear in a 1:1 aspect ratio, independent of the aspect ratio the + axis rect has. + + This is an operation that changes the range of this axis once, it doesn't fix the scale ratio + indefinitely. Note that calling this function in the constructor of the QCustomPlot's parent + won't have the desired effect, since the widget dimensions aren't defined yet, and a resizeEvent + will follow. +*/ +void QCPAxis::setScaleRatio(const QCPAxis *otherAxis, double ratio) +{ + int otherPixelSize, ownPixelSize; + + if (otherAxis->orientation() == Qt::Horizontal) + otherPixelSize = otherAxis->axisRect()->width(); + else + otherPixelSize = otherAxis->axisRect()->height(); + + if (orientation() == Qt::Horizontal) + ownPixelSize = axisRect()->width(); + else + ownPixelSize = axisRect()->height(); + + double newRangeSize = ratio*otherAxis->range().size()*ownPixelSize/(double)otherPixelSize; + setRange(range().center(), newRangeSize, Qt::AlignCenter); +} + +/*! + Changes the axis range such that all plottables associated with this axis are fully visible in + that dimension. + + \see QCPAbstractPlottable::rescaleAxes, QCustomPlot::rescaleAxes +*/ +void QCPAxis::rescale(bool onlyVisiblePlottables) +{ + QList p = plottables(); + QCPRange newRange; + bool haveRange = false; + for (int i=0; irealVisibility() && onlyVisiblePlottables) + continue; + QCPRange plottableRange; + bool currentFoundRange; + QCPAbstractPlottable::SignDomain signDomain = QCPAbstractPlottable::sdBoth; + if (mScaleType == stLogarithmic) + signDomain = (mRange.upper < 0 ? QCPAbstractPlottable::sdNegative : QCPAbstractPlottable::sdPositive); + if (p.at(i)->keyAxis() == this) + plottableRange = p.at(i)->getKeyRange(currentFoundRange, signDomain); + else + plottableRange = p.at(i)->getValueRange(currentFoundRange, signDomain); + if (currentFoundRange) + { + if (!haveRange) + newRange = plottableRange; + else + newRange.expand(plottableRange); + haveRange = true; + } + } + if (haveRange) + { + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable + { + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (mScaleType == stLinear) + { + newRange.lower = center-mRange.size()/2.0; + newRange.upper = center+mRange.size()/2.0; + } else // mScaleType == stLogarithmic + { + newRange.lower = center/qSqrt(mRange.upper/mRange.lower); + newRange.upper = center*qSqrt(mRange.upper/mRange.lower); + } + } + setRange(newRange); + } +} + +/*! + Transforms \a value, in pixel coordinates of the QCustomPlot widget, to axis coordinates. +*/ +double QCPAxis::pixelToCoord(double value) const +{ + if (orientation() == Qt::Horizontal) + { + if (mScaleType == stLinear) + { + if (!mRangeReversed) + return (value-mAxisRect->left())/(double)mAxisRect->width()*mRange.size()+mRange.lower; + else + return -(value-mAxisRect->left())/(double)mAxisRect->width()*mRange.size()+mRange.upper; + } else // mScaleType == stLogarithmic + { + if (!mRangeReversed) + return qPow(mRange.upper/mRange.lower, (value-mAxisRect->left())/(double)mAxisRect->width())*mRange.lower; + else + return qPow(mRange.upper/mRange.lower, (mAxisRect->left()-value)/(double)mAxisRect->width())*mRange.upper; + } + } else // orientation() == Qt::Vertical + { + if (mScaleType == stLinear) + { + if (!mRangeReversed) + return (mAxisRect->bottom()-value)/(double)mAxisRect->height()*mRange.size()+mRange.lower; + else + return -(mAxisRect->bottom()-value)/(double)mAxisRect->height()*mRange.size()+mRange.upper; + } else // mScaleType == stLogarithmic + { + if (!mRangeReversed) + return qPow(mRange.upper/mRange.lower, (mAxisRect->bottom()-value)/(double)mAxisRect->height())*mRange.lower; + else + return qPow(mRange.upper/mRange.lower, (value-mAxisRect->bottom())/(double)mAxisRect->height())*mRange.upper; + } + } +} + +/*! + Transforms \a value, in coordinates of the axis, to pixel coordinates of the QCustomPlot widget. +*/ +double QCPAxis::coordToPixel(double value) const +{ + if (orientation() == Qt::Horizontal) + { + if (mScaleType == stLinear) + { + if (!mRangeReversed) + return (value-mRange.lower)/mRange.size()*mAxisRect->width()+mAxisRect->left(); + else + return (mRange.upper-value)/mRange.size()*mAxisRect->width()+mAxisRect->left(); + } else // mScaleType == stLogarithmic + { + if (value >= 0 && mRange.upper < 0) // invalid value for logarithmic scale, just draw it outside visible range + return !mRangeReversed ? mAxisRect->right()+200 : mAxisRect->left()-200; + else if (value <= 0 && mRange.upper > 0) // invalid value for logarithmic scale, just draw it outside visible range + return !mRangeReversed ? mAxisRect->left()-200 : mAxisRect->right()+200; + else + { + if (!mRangeReversed) + return baseLog(value/mRange.lower)/baseLog(mRange.upper/mRange.lower)*mAxisRect->width()+mAxisRect->left(); + else + return baseLog(mRange.upper/value)/baseLog(mRange.upper/mRange.lower)*mAxisRect->width()+mAxisRect->left(); + } + } + } else // orientation() == Qt::Vertical + { + if (mScaleType == stLinear) + { + if (!mRangeReversed) + return mAxisRect->bottom()-(value-mRange.lower)/mRange.size()*mAxisRect->height(); + else + return mAxisRect->bottom()-(mRange.upper-value)/mRange.size()*mAxisRect->height(); + } else // mScaleType == stLogarithmic + { + if (value >= 0 && mRange.upper < 0) // invalid value for logarithmic scale, just draw it outside visible range + return !mRangeReversed ? mAxisRect->top()-200 : mAxisRect->bottom()+200; + else if (value <= 0 && mRange.upper > 0) // invalid value for logarithmic scale, just draw it outside visible range + return !mRangeReversed ? mAxisRect->bottom()+200 : mAxisRect->top()-200; + else + { + if (!mRangeReversed) + return mAxisRect->bottom()-baseLog(value/mRange.lower)/baseLog(mRange.upper/mRange.lower)*mAxisRect->height(); + else + return mAxisRect->bottom()-baseLog(mRange.upper/value)/baseLog(mRange.upper/mRange.lower)*mAxisRect->height(); + } + } + } +} + +/*! + Returns the part of the axis that is hit by \a pos (in pixels). The return value of this function + is independent of the user-selectable parts defined with \ref setSelectableParts. Further, this + function does not change the current selection state of the axis. + + If the axis is not visible (\ref setVisible), this function always returns \ref spNone. + + \see setSelectedParts, setSelectableParts, QCustomPlot::setInteractions +*/ +QCPAxis::SelectablePart QCPAxis::getPartAt(const QPointF &pos) const +{ + if (!mVisible) + return spNone; + + if (mAxisPainter->axisSelectionBox().contains(pos.toPoint())) + return spAxis; + else if (mAxisPainter->tickLabelsSelectionBox().contains(pos.toPoint())) + return spTickLabels; + else if (mAxisPainter->labelSelectionBox().contains(pos.toPoint())) + return spAxisLabel; + else + return spNone; +} + +/* inherits documentation from base class */ +double QCPAxis::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + if (!mParentPlot) return -1; + SelectablePart part = getPartAt(pos); + if ((onlySelectable && !mSelectableParts.testFlag(part)) || part == spNone) + return -1; + + if (details) + details->setValue(part); + return mParentPlot->selectionTolerance()*0.99; +} + +/*! + Returns a list of all the plottables that have this axis as key or value axis. + + If you are only interested in plottables of type QCPGraph, see \ref graphs. + + \see graphs, items +*/ +QList QCPAxis::plottables() const +{ + QList result; + if (!mParentPlot) return result; + + for (int i=0; imPlottables.size(); ++i) + { + if (mParentPlot->mPlottables.at(i)->keyAxis() == this ||mParentPlot->mPlottables.at(i)->valueAxis() == this) + result.append(mParentPlot->mPlottables.at(i)); + } + return result; +} + +/*! + Returns a list of all the graphs that have this axis as key or value axis. + + \see plottables, items +*/ +QList QCPAxis::graphs() const +{ + QList result; + if (!mParentPlot) return result; + + for (int i=0; imGraphs.size(); ++i) + { + if (mParentPlot->mGraphs.at(i)->keyAxis() == this || mParentPlot->mGraphs.at(i)->valueAxis() == this) + result.append(mParentPlot->mGraphs.at(i)); + } + return result; +} + +/*! + Returns a list of all the items that are associated with this axis. An item is considered + associated with an axis if at least one of its positions uses the axis as key or value axis. + + \see plottables, graphs +*/ +QList QCPAxis::items() const +{ + QList result; + if (!mParentPlot) return result; + + for (int itemId=0; itemIdmItems.size(); ++itemId) + { + QList positions = mParentPlot->mItems.at(itemId)->positions(); + for (int posId=0; posIdkeyAxis() == this || positions.at(posId)->valueAxis() == this) + { + result.append(mParentPlot->mItems.at(itemId)); + break; + } + } + } + return result; +} + +/*! + Transforms a margin side to the logically corresponding axis type. (QCP::msLeft to + QCPAxis::atLeft, QCP::msRight to QCPAxis::atRight, etc.) +*/ +QCPAxis::AxisType QCPAxis::marginSideToAxisType(QCP::MarginSide side) +{ + switch (side) + { + case QCP::msLeft: return atLeft; + case QCP::msRight: return atRight; + case QCP::msTop: return atTop; + case QCP::msBottom: return atBottom; + default: break; + } + qDebug() << Q_FUNC_INFO << "Invalid margin side passed:" << (int)side; + return atLeft; +} + +/*! + Returns the axis type that describes the opposite axis of an axis with the specified \a type. +*/ +QCPAxis::AxisType QCPAxis::opposite(QCPAxis::AxisType type) +{ + switch (type) + { + case atLeft: return atRight; break; + case atRight: return atLeft; break; + case atBottom: return atTop; break; + case atTop: return atBottom; break; + default: qDebug() << Q_FUNC_INFO << "invalid axis type"; return atLeft; break; + } +} + +/*! \internal + + This function is called to prepare the tick vector, sub tick vector and tick label vector. If + \ref setAutoTicks is set to true, appropriate tick values are determined automatically via \ref + generateAutoTicks. If it's set to false, the signal ticksRequest is emitted, which can be used to + provide external tick positions. Then the sub tick vectors and tick label vectors are created. +*/ +void QCPAxis::setupTickVectors() +{ + if (!mParentPlot) return; + if ((!mTicks && !mTickLabels && !mGrid->visible()) || mRange.size() <= 0) return; + + // fill tick vectors, either by auto generating or by notifying user to fill the vectors himself + if (mAutoTicks) + { + generateAutoTicks(); + } else + { + emit ticksRequest(); + } + + visibleTickBounds(mLowestVisibleTick, mHighestVisibleTick); + if (mTickVector.isEmpty()) + { + mSubTickVector.clear(); + return; + } + + // generate subticks between ticks: + mSubTickVector.resize((mTickVector.size()-1)*mSubTickCount); + if (mSubTickCount > 0) + { + double subTickStep = 0; + double subTickPosition = 0; + int subTickIndex = 0; + bool done = false; + int lowTick = mLowestVisibleTick > 0 ? mLowestVisibleTick-1 : mLowestVisibleTick; + int highTick = mHighestVisibleTick < mTickVector.size()-1 ? mHighestVisibleTick+1 : mHighestVisibleTick; + for (int i=lowTick+1; i<=highTick; ++i) + { + subTickStep = (mTickVector.at(i)-mTickVector.at(i-1))/(double)(mSubTickCount+1); + for (int k=1; k<=mSubTickCount; ++k) + { + subTickPosition = mTickVector.at(i-1) + k*subTickStep; + if (subTickPosition < mRange.lower) + continue; + if (subTickPosition > mRange.upper) + { + done = true; + break; + } + mSubTickVector[subTickIndex] = subTickPosition; + subTickIndex++; + } + if (done) break; + } + mSubTickVector.resize(subTickIndex); + } + + // generate tick labels according to tick positions: + if (mAutoTickLabels) + { + int vecsize = mTickVector.size(); + mTickVectorLabels.resize(vecsize); + if (mTickLabelType == ltNumber) + { + for (int i=mLowestVisibleTick; i<=mHighestVisibleTick; ++i) + mTickVectorLabels[i] = mParentPlot->locale().toString(mTickVector.at(i), mNumberFormatChar, mNumberPrecision); + } else if (mTickLabelType == ltDateTime) + { + for (int i=mLowestVisibleTick; i<=mHighestVisibleTick; ++i) + { +#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) // use fromMSecsSinceEpoch function if available, to gain sub-second accuracy on tick labels (e.g. for format "hh:mm:ss:zzz") + mTickVectorLabels[i] = mParentPlot->locale().toString(QDateTime::fromTime_t(mTickVector.at(i)).toTimeSpec(mDateTimeSpec), mDateTimeFormat); +#else + mTickVectorLabels[i] = mParentPlot->locale().toString(QDateTime::fromMSecsSinceEpoch(mTickVector.at(i)*1000).toTimeSpec(mDateTimeSpec), mDateTimeFormat); +#endif + } + } + } else // mAutoTickLabels == false + { + if (mAutoTicks) // ticks generated automatically, but not ticklabels, so emit ticksRequest here for labels + { + emit ticksRequest(); + } + // make sure provided tick label vector has correct (minimal) length: + if (mTickVectorLabels.size() < mTickVector.size()) + mTickVectorLabels.resize(mTickVector.size()); + } +} + +/*! \internal + + If \ref setAutoTicks is set to true, this function is called by \ref setupTickVectors to + generate reasonable tick positions (and subtick count). The algorithm tries to create + approximately mAutoTickCount ticks (set via \ref setAutoTickCount). + + If the scale is logarithmic, \ref setAutoTickCount is ignored, and one tick is generated at every + power of the current logarithm base, set via \ref setScaleLogBase. +*/ +void QCPAxis::generateAutoTicks() +{ + if (mScaleType == stLinear) + { + if (mAutoTickStep) + { + // Generate tick positions according to linear scaling: + mTickStep = mRange.size()/(double)(mAutoTickCount+1e-10); // mAutoTickCount ticks on average, the small addition is to prevent jitter on exact integers + double magnitudeFactor = qPow(10.0, qFloor(qLn(mTickStep)/qLn(10.0))); // get magnitude factor e.g. 0.01, 1, 10, 1000 etc. + double tickStepMantissa = mTickStep/magnitudeFactor; + if (tickStepMantissa < 5) + { + // round digit after decimal point to 0.5 + mTickStep = (int)(tickStepMantissa*2)/2.0*magnitudeFactor; + } else + { + // round to first digit in multiples of 2 + mTickStep = (int)(tickStepMantissa/2.0)*2.0*magnitudeFactor; + } + } + if (mAutoSubTicks) + mSubTickCount = calculateAutoSubTickCount(mTickStep); + // Generate tick positions according to mTickStep: + qint64 firstStep = floor(mRange.lower/mTickStep); // do not use qFloor here, or we'll lose 64 bit precision + qint64 lastStep = ceil(mRange.upper/mTickStep); // do not use qCeil here, or we'll lose 64 bit precision + int tickcount = lastStep-firstStep+1; + if (tickcount < 0) tickcount = 0; + mTickVector.resize(tickcount); + for (int i=0; i 0 && mRange.upper > 0) // positive range + { + double lowerMag = basePow(qFloor(baseLog(mRange.lower))); + double currentMag = lowerMag; + mTickVector.clear(); + mTickVector.append(currentMag); + while (currentMag < mRange.upper && currentMag > 0) // currentMag might be zero for ranges ~1e-300, just cancel in that case + { + currentMag *= mScaleLogBase; + mTickVector.append(currentMag); + } + } else if (mRange.lower < 0 && mRange.upper < 0) // negative range + { + double lowerMag = -basePow(qCeil(baseLog(-mRange.lower))); + double currentMag = lowerMag; + mTickVector.clear(); + mTickVector.append(currentMag); + while (currentMag < mRange.upper && currentMag < 0) // currentMag might be zero for ranges ~1e-300, just cancel in that case + { + currentMag /= mScaleLogBase; + mTickVector.append(currentMag); + } + } else // invalid range for logarithmic scale, because lower and upper have different sign + { + mTickVector.clear(); + qDebug() << Q_FUNC_INFO << "Invalid range for logarithmic plot: " << mRange.lower << "-" << mRange.upper; + } + } +} + +/*! \internal + + Called by generateAutoTicks when \ref setAutoSubTicks is set to true. Depending on the \a + tickStep between two major ticks on the axis, a different number of sub ticks is appropriate. For + Example taking 4 sub ticks for a \a tickStep of 1 makes more sense than taking 5 sub ticks, + because this corresponds to a sub tick step of 0.2, instead of the less intuitive 0.16667. Note + that a subtick count of 4 means dividing the major tick step into 5 sections. + + This is implemented by a hand made lookup for integer tick steps as well as fractional tick steps + with a fractional part of (approximately) 0.5. If a tick step is different (i.e. has no + fractional part close to 0.5), the currently set sub tick count (\ref setSubTickCount) is + returned. +*/ +int QCPAxis::calculateAutoSubTickCount(double tickStep) const +{ + int result = mSubTickCount; // default to current setting, if no proper value can be found + + // get mantissa of tickstep: + double magnitudeFactor = qPow(10.0, qFloor(qLn(tickStep)/qLn(10.0))); // get magnitude factor e.g. 0.01, 1, 10, 1000 etc. + double tickStepMantissa = tickStep/magnitudeFactor; + + // separate integer and fractional part of mantissa: + double epsilon = 0.01; + double intPartf; + int intPart; + double fracPart = modf(tickStepMantissa, &intPartf); + intPart = intPartf; + + // handle cases with (almost) integer mantissa: + if (fracPart < epsilon || 1.0-fracPart < epsilon) + { + if (1.0-fracPart < epsilon) + ++intPart; + switch (intPart) + { + case 1: result = 4; break; // 1.0 -> 0.2 substep + case 2: result = 3; break; // 2.0 -> 0.5 substep + case 3: result = 2; break; // 3.0 -> 1.0 substep + case 4: result = 3; break; // 4.0 -> 1.0 substep + case 5: result = 4; break; // 5.0 -> 1.0 substep + case 6: result = 2; break; // 6.0 -> 2.0 substep + case 7: result = 6; break; // 7.0 -> 1.0 substep + case 8: result = 3; break; // 8.0 -> 2.0 substep + case 9: result = 2; break; // 9.0 -> 3.0 substep + } + } else + { + // handle cases with significantly fractional mantissa: + if (qAbs(fracPart-0.5) < epsilon) // *.5 mantissa + { + switch (intPart) + { + case 1: result = 2; break; // 1.5 -> 0.5 substep + case 2: result = 4; break; // 2.5 -> 0.5 substep + case 3: result = 4; break; // 3.5 -> 0.7 substep + case 4: result = 2; break; // 4.5 -> 1.5 substep + case 5: result = 4; break; // 5.5 -> 1.1 substep (won't occur with autoTickStep from here on) + case 6: result = 4; break; // 6.5 -> 1.3 substep + case 7: result = 2; break; // 7.5 -> 2.5 substep + case 8: result = 4; break; // 8.5 -> 1.7 substep + case 9: result = 4; break; // 9.5 -> 1.9 substep + } + } + // if mantissa fraction isnt 0.0 or 0.5, don't bother finding good sub tick marks, leave default + } + + return result; +} + +/* inherits documentation from base class */ +void QCPAxis::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) +{ + Q_UNUSED(event) + SelectablePart part = details.value(); + if (mSelectableParts.testFlag(part)) + { + SelectableParts selBefore = mSelectedParts; + setSelectedParts(additive ? mSelectedParts^part : part); + if (selectionStateChanged) + *selectionStateChanged = mSelectedParts != selBefore; + } +} + +/* inherits documentation from base class */ +void QCPAxis::deselectEvent(bool *selectionStateChanged) +{ + SelectableParts selBefore = mSelectedParts; + setSelectedParts(mSelectedParts & ~mSelectableParts); + if (selectionStateChanged) + *selectionStateChanged = mSelectedParts != selBefore; +} + +/*! \internal + + A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter + before drawing axis lines. + + This is the antialiasing state the painter passed to the \ref draw method is in by default. + + This function takes into account the local setting of the antialiasing flag as well as the + overrides set with \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. + + \see setAntialiased +*/ +void QCPAxis::applyDefaultAntialiasingHint(QCPPainter *painter) const +{ + applyAntialiasingHint(painter, mAntialiased, QCP::aeAxes); +} + +/*! \internal + + Draws the axis with the specified \a painter, using the internal QCPAxisPainterPrivate instance. + +*/ +void QCPAxis::draw(QCPPainter *painter) +{ + const int lowTick = mLowestVisibleTick; + const int highTick = mHighestVisibleTick; + QVector subTickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter + QVector tickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter + QVector tickLabels; // the final vector passed to QCPAxisPainter + tickPositions.reserve(highTick-lowTick+1); + tickLabels.reserve(highTick-lowTick+1); + subTickPositions.reserve(mSubTickVector.size()); + + if (mTicks) + { + for (int i=lowTick; i<=highTick; ++i) + { + tickPositions.append(coordToPixel(mTickVector.at(i))); + if (mTickLabels) + tickLabels.append(mTickVectorLabels.at(i)); + } + + if (mSubTickCount > 0) + { + const int subTickCount = mSubTickVector.size(); + for (int i=0; itype = mAxisType; + mAxisPainter->basePen = getBasePen(); + mAxisPainter->labelFont = getLabelFont(); + mAxisPainter->labelColor = getLabelColor(); + mAxisPainter->label = mLabel; + mAxisPainter->substituteExponent = mAutoTickLabels && mNumberBeautifulPowers && mTickLabelType == ltNumber; + mAxisPainter->tickPen = getTickPen(); + mAxisPainter->subTickPen = getSubTickPen(); + mAxisPainter->tickLabelFont = getTickLabelFont(); + mAxisPainter->tickLabelColor = getTickLabelColor(); + mAxisPainter->axisRect = mAxisRect->rect(); + mAxisPainter->viewportRect = mParentPlot->viewport(); + mAxisPainter->abbreviateDecimalPowers = mScaleType == stLogarithmic; + mAxisPainter->reversedEndings = mRangeReversed; + mAxisPainter->tickPositions = tickPositions; + mAxisPainter->tickLabels = tickLabels; + mAxisPainter->subTickPositions = subTickPositions; + mAxisPainter->draw(painter); +} + +/*! \internal + + Returns via \a lowIndex and \a highIndex, which ticks in the current tick vector are visible in + the current range. The return values are indices of the tick vector, not the positions of the + ticks themselves. + + The actual use of this function is when an external tick vector is provided, since it might + exceed far beyond the currently displayed range, and would cause unnecessary calculations e.g. of + subticks. + + If all ticks are outside the axis range, an inverted range is returned, i.e. highIndex will be + smaller than lowIndex. There is one case, where this function returns indices that are not really + visible in the current axis range: When the tick spacing is larger than the axis range size and + one tick is below the axis range and the next tick is already above the axis range. Because in + such cases it is usually desirable to know the tick pair, to draw proper subticks. +*/ +void QCPAxis::visibleTickBounds(int &lowIndex, int &highIndex) const +{ + bool lowFound = false; + bool highFound = false; + lowIndex = 0; + highIndex = -1; + + for (int i=0; i < mTickVector.size(); ++i) + { + if (mTickVector.at(i) >= mRange.lower) + { + lowFound = true; + lowIndex = i; + break; + } + } + for (int i=mTickVector.size()-1; i >= 0; --i) + { + if (mTickVector.at(i) <= mRange.upper) + { + highFound = true; + highIndex = i; + break; + } + } + + if (!lowFound && highFound) + lowIndex = highIndex+1; + else if (lowFound && !highFound) + highIndex = lowIndex-1; +} + +/*! \internal + + A log function with the base mScaleLogBase, used mostly for coordinate transforms in logarithmic + scales with arbitrary log base. Uses the buffered mScaleLogBaseLogInv for faster calculation. + This is set to 1.0/qLn(mScaleLogBase) in \ref setScaleLogBase. + + \see basePow, setScaleLogBase, setScaleType +*/ +double QCPAxis::baseLog(double value) const +{ + return qLn(value)*mScaleLogBaseLogInv; +} + +/*! \internal + + A power function with the base mScaleLogBase, used mostly for coordinate transforms in + logarithmic scales with arbitrary log base. + + \see baseLog, setScaleLogBase, setScaleType +*/ +double QCPAxis::basePow(double value) const +{ + return qPow(mScaleLogBase, value); +} + +/*! \internal + + Returns the pen that is used to draw the axis base line. Depending on the selection state, this + is either mSelectedBasePen or mBasePen. +*/ +QPen QCPAxis::getBasePen() const +{ + return mSelectedParts.testFlag(spAxis) ? mSelectedBasePen : mBasePen; +} + +/*! \internal + + Returns the pen that is used to draw the (major) ticks. Depending on the selection state, this + is either mSelectedTickPen or mTickPen. +*/ +QPen QCPAxis::getTickPen() const +{ + return mSelectedParts.testFlag(spAxis) ? mSelectedTickPen : mTickPen; +} + +/*! \internal + + Returns the pen that is used to draw the subticks. Depending on the selection state, this + is either mSelectedSubTickPen or mSubTickPen. +*/ +QPen QCPAxis::getSubTickPen() const +{ + return mSelectedParts.testFlag(spAxis) ? mSelectedSubTickPen : mSubTickPen; +} + +/*! \internal + + Returns the font that is used to draw the tick labels. Depending on the selection state, this + is either mSelectedTickLabelFont or mTickLabelFont. +*/ +QFont QCPAxis::getTickLabelFont() const +{ + return mSelectedParts.testFlag(spTickLabels) ? mSelectedTickLabelFont : mTickLabelFont; +} + +/*! \internal + + Returns the font that is used to draw the axis label. Depending on the selection state, this + is either mSelectedLabelFont or mLabelFont. +*/ +QFont QCPAxis::getLabelFont() const +{ + return mSelectedParts.testFlag(spAxisLabel) ? mSelectedLabelFont : mLabelFont; +} + +/*! \internal + + Returns the color that is used to draw the tick labels. Depending on the selection state, this + is either mSelectedTickLabelColor or mTickLabelColor. +*/ +QColor QCPAxis::getTickLabelColor() const +{ + return mSelectedParts.testFlag(spTickLabels) ? mSelectedTickLabelColor : mTickLabelColor; +} + +/*! \internal + + Returns the color that is used to draw the axis label. Depending on the selection state, this + is either mSelectedLabelColor or mLabelColor. +*/ +QColor QCPAxis::getLabelColor() const +{ + return mSelectedParts.testFlag(spAxisLabel) ? mSelectedLabelColor : mLabelColor; +} + +/*! \internal + + Returns the appropriate outward margin for this axis. It is needed if \ref + QCPAxisRect::setAutoMargins is set to true on the parent axis rect. An axis with axis type \ref + atLeft will return an appropriate left margin, \ref atBottom will return an appropriate bottom + margin and so forth. For the calculation, this function goes through similar steps as \ref draw, + so changing one function likely requires the modification of the other one as well. + + The margin consists of the outward tick length, tick label padding, tick label size, label + padding, label size, and padding. + + The margin is cached internally, so repeated calls while leaving the axis range, fonts, etc. + unchanged are very fast. +*/ +int QCPAxis::calculateMargin() +{ + if (!mVisible) // if not visible, directly return 0, don't cache 0 because we can't react to setVisible in QCPAxis + return 0; + + if (mCachedMarginValid) + return mCachedMargin; + + // run through similar steps as QCPAxis::draw, and caluclate margin needed to fit axis and its labels + int margin = 0; + + int lowTick, highTick; + visibleTickBounds(lowTick, highTick); + QVector tickPositions; // the final coordToPixel transformed vector passed to QCPAxisPainter + QVector tickLabels; // the final vector passed to QCPAxisPainter + tickPositions.reserve(highTick-lowTick+1); + tickLabels.reserve(highTick-lowTick+1); + if (mTicks) + { + for (int i=lowTick; i<=highTick; ++i) + { + tickPositions.append(coordToPixel(mTickVector.at(i))); + if (mTickLabels) + tickLabels.append(mTickVectorLabels.at(i)); + } + } + // transfer all properties of this axis to QCPAxisPainterPrivate which it needs to calculate the size. + // Note that some axis painter properties are already set by direct feed-through with QCPAxis setters + mAxisPainter->type = mAxisType; + mAxisPainter->labelFont = getLabelFont(); + mAxisPainter->label = mLabel; + mAxisPainter->tickLabelFont = mTickLabelFont; + mAxisPainter->axisRect = mAxisRect->rect(); + mAxisPainter->viewportRect = mParentPlot->viewport(); + mAxisPainter->tickPositions = tickPositions; + mAxisPainter->tickLabels = tickLabels; + margin += mAxisPainter->size(); + margin += mPadding; + + mCachedMargin = margin; + mCachedMarginValid = true; + return margin; +} + +/* inherits documentation from base class */ +QCP::Interaction QCPAxis::selectionCategory() const +{ + return QCP::iSelectAxes; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPAxisPainterPrivate +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPAxisPainterPrivate + + \internal + \brief (Private) + + This is a private class and not part of the public QCustomPlot interface. + + It is used by QCPAxis to do the low-level drawing of axis backbone, tick marks, tick labels and + axis label. It also buffers the labels to reduce replot times. The parameters are configured by + directly accessing the public member variables. +*/ + +/*! + Constructs a QCPAxisPainterPrivate instance. Make sure to not create a new instance on every + redraw, to utilize the caching mechanisms. +*/ +QCPAxisPainterPrivate::QCPAxisPainterPrivate(QCustomPlot *parentPlot) : + type(QCPAxis::atLeft), + basePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + lowerEnding(QCPLineEnding::esNone), + upperEnding(QCPLineEnding::esNone), + labelPadding(0), + tickLabelPadding(0), + tickLabelRotation(0), + tickLabelSide(QCPAxis::lsOutside), + substituteExponent(true), + numberMultiplyCross(false), + tickLengthIn(5), + tickLengthOut(0), + subTickLengthIn(2), + subTickLengthOut(0), + tickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + subTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)), + offset(0), + abbreviateDecimalPowers(false), + reversedEndings(false), + mParentPlot(parentPlot), + mLabelCache(16) // cache at most 16 (tick) labels +{ +} + +QCPAxisPainterPrivate::~QCPAxisPainterPrivate() +{ +} + +/*! \internal + + Draws the axis with the specified \a painter. + + The selection boxes (mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox) are set + here, too. +*/ +void QCPAxisPainterPrivate::draw(QCPPainter *painter) +{ + QByteArray newHash = generateLabelParameterHash(); + if (newHash != mLabelParameterHash) + { + mLabelCache.clear(); + mLabelParameterHash = newHash; + } + + QPoint origin; + switch (type) + { + case QCPAxis::atLeft: origin = axisRect.bottomLeft() +QPoint(-offset, 0); break; + case QCPAxis::atRight: origin = axisRect.bottomRight()+QPoint(+offset, 0); break; + case QCPAxis::atTop: origin = axisRect.topLeft() +QPoint(0, -offset); break; + case QCPAxis::atBottom: origin = axisRect.bottomLeft() +QPoint(0, +offset); break; + } + + double xCor = 0, yCor = 0; // paint system correction, for pixel exact matches (affects baselines and ticks of top/right axes) + switch (type) + { + case QCPAxis::atTop: yCor = -1; break; + case QCPAxis::atRight: xCor = 1; break; + default: break; + } + + int margin = 0; + // draw baseline: + QLineF baseLine; + painter->setPen(basePen); + if (QCPAxis::orientation(type) == Qt::Horizontal) + baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(axisRect.width()+xCor, yCor)); + else + baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(xCor, -axisRect.height()+yCor)); + if (reversedEndings) + baseLine = QLineF(baseLine.p2(), baseLine.p1()); // won't make a difference for line itself, but for line endings later + painter->drawLine(baseLine); + + // draw ticks: + if (!tickPositions.isEmpty()) + { + painter->setPen(tickPen); + int tickDir = (type == QCPAxis::atBottom || type == QCPAxis::atRight) ? -1 : 1; // direction of ticks ("inward" is right for left axis and left for right axis) + if (QCPAxis::orientation(type) == Qt::Horizontal) + { + for (int i=0; idrawLine(QLineF(tickPositions.at(i)+xCor, origin.y()-tickLengthOut*tickDir+yCor, tickPositions.at(i)+xCor, origin.y()+tickLengthIn*tickDir+yCor)); + } else + { + for (int i=0; idrawLine(QLineF(origin.x()-tickLengthOut*tickDir+xCor, tickPositions.at(i)+yCor, origin.x()+tickLengthIn*tickDir+xCor, tickPositions.at(i)+yCor)); + } + } + + // draw subticks: + if (!subTickPositions.isEmpty()) + { + painter->setPen(subTickPen); + // direction of ticks ("inward" is right for left axis and left for right axis) + int tickDir = (type == QCPAxis::atBottom || type == QCPAxis::atRight) ? -1 : 1; + if (QCPAxis::orientation(type) == Qt::Horizontal) + { + for (int i=0; idrawLine(QLineF(subTickPositions.at(i)+xCor, origin.y()-subTickLengthOut*tickDir+yCor, subTickPositions.at(i)+xCor, origin.y()+subTickLengthIn*tickDir+yCor)); + } else + { + for (int i=0; idrawLine(QLineF(origin.x()-subTickLengthOut*tickDir+xCor, subTickPositions.at(i)+yCor, origin.x()+subTickLengthIn*tickDir+xCor, subTickPositions.at(i)+yCor)); + } + } + margin += qMax(0, qMax(tickLengthOut, subTickLengthOut)); + + // draw axis base endings: + bool antialiasingBackup = painter->antialiasing(); + painter->setAntialiasing(true); // always want endings to be antialiased, even if base and ticks themselves aren't + painter->setBrush(QBrush(basePen.color())); + QVector2D baseLineVector(baseLine.dx(), baseLine.dy()); + if (lowerEnding.style() != QCPLineEnding::esNone) + lowerEnding.draw(painter, QVector2D(baseLine.p1())-baseLineVector.normalized()*lowerEnding.realLength()*(lowerEnding.inverted()?-1:1), -baseLineVector); + if (upperEnding.style() != QCPLineEnding::esNone) + upperEnding.draw(painter, QVector2D(baseLine.p2())+baseLineVector.normalized()*upperEnding.realLength()*(upperEnding.inverted()?-1:1), baseLineVector); + painter->setAntialiasing(antialiasingBackup); + + // tick labels: + QRect oldClipRect; + if (tickLabelSide == QCPAxis::lsInside) // if using inside labels, clip them to the axis rect + { + oldClipRect = painter->clipRegion().boundingRect(); + painter->setClipRect(axisRect); + } + QSize tickLabelsSize(0, 0); // size of largest tick label, for offset calculation of axis label + if (!tickLabels.isEmpty()) + { + if (tickLabelSide == QCPAxis::lsOutside) + margin += tickLabelPadding; + painter->setFont(tickLabelFont); + painter->setPen(QPen(tickLabelColor)); + const int maxLabelIndex = qMin(tickPositions.size(), tickLabels.size()); + int distanceToAxis = margin; + if (tickLabelSide == QCPAxis::lsInside) + distanceToAxis = -(qMax(tickLengthIn, subTickLengthIn)+tickLabelPadding); + for (int i=0; isetClipRect(oldClipRect); + + // axis label: + QRect labelBounds; + if (!label.isEmpty()) + { + margin += labelPadding; + painter->setFont(labelFont); + painter->setPen(QPen(labelColor)); + labelBounds = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip, label); + if (type == QCPAxis::atLeft) + { + QTransform oldTransform = painter->transform(); + painter->translate((origin.x()-margin-labelBounds.height()), origin.y()); + painter->rotate(-90); + painter->drawText(0, 0, axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); + painter->setTransform(oldTransform); + } + else if (type == QCPAxis::atRight) + { + QTransform oldTransform = painter->transform(); + painter->translate((origin.x()+margin+labelBounds.height()), origin.y()-axisRect.height()); + painter->rotate(90); + painter->drawText(0, 0, axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); + painter->setTransform(oldTransform); + } + else if (type == QCPAxis::atTop) + painter->drawText(origin.x(), origin.y()-margin-labelBounds.height(), axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); + else if (type == QCPAxis::atBottom) + painter->drawText(origin.x(), origin.y()+margin, axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter, label); + } + + // set selection boxes: + int selectionTolerance = 0; + if (mParentPlot) + selectionTolerance = mParentPlot->selectionTolerance(); + else + qDebug() << Q_FUNC_INFO << "mParentPlot is null"; + int selAxisOutSize = qMax(qMax(tickLengthOut, subTickLengthOut), selectionTolerance); + int selAxisInSize = selectionTolerance; + int selTickLabelSize; + int selTickLabelOffset; + if (tickLabelSide == QCPAxis::lsOutside) + { + selTickLabelSize = (QCPAxis::orientation(type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width()); + selTickLabelOffset = qMax(tickLengthOut, subTickLengthOut)+tickLabelPadding; + } else + { + selTickLabelSize = -(QCPAxis::orientation(type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width()); + selTickLabelOffset = -(qMax(tickLengthIn, subTickLengthIn)+tickLabelPadding); + } + int selLabelSize = labelBounds.height(); + int selLabelOffset = qMax(tickLengthOut, subTickLengthOut)+(!tickLabels.isEmpty() && tickLabelSide == QCPAxis::lsOutside ? tickLabelPadding+selTickLabelSize : 0)+labelPadding; + if (type == QCPAxis::atLeft) + { + mAxisSelectionBox.setCoords(origin.x()-selAxisOutSize, axisRect.top(), origin.x()+selAxisInSize, axisRect.bottom()); + mTickLabelsSelectionBox.setCoords(origin.x()-selTickLabelOffset-selTickLabelSize, axisRect.top(), origin.x()-selTickLabelOffset, axisRect.bottom()); + mLabelSelectionBox.setCoords(origin.x()-selLabelOffset-selLabelSize, axisRect.top(), origin.x()-selLabelOffset, axisRect.bottom()); + } else if (type == QCPAxis::atRight) + { + mAxisSelectionBox.setCoords(origin.x()-selAxisInSize, axisRect.top(), origin.x()+selAxisOutSize, axisRect.bottom()); + mTickLabelsSelectionBox.setCoords(origin.x()+selTickLabelOffset+selTickLabelSize, axisRect.top(), origin.x()+selTickLabelOffset, axisRect.bottom()); + mLabelSelectionBox.setCoords(origin.x()+selLabelOffset+selLabelSize, axisRect.top(), origin.x()+selLabelOffset, axisRect.bottom()); + } else if (type == QCPAxis::atTop) + { + mAxisSelectionBox.setCoords(axisRect.left(), origin.y()-selAxisOutSize, axisRect.right(), origin.y()+selAxisInSize); + mTickLabelsSelectionBox.setCoords(axisRect.left(), origin.y()-selTickLabelOffset-selTickLabelSize, axisRect.right(), origin.y()-selTickLabelOffset); + mLabelSelectionBox.setCoords(axisRect.left(), origin.y()-selLabelOffset-selLabelSize, axisRect.right(), origin.y()-selLabelOffset); + } else if (type == QCPAxis::atBottom) + { + mAxisSelectionBox.setCoords(axisRect.left(), origin.y()-selAxisInSize, axisRect.right(), origin.y()+selAxisOutSize); + mTickLabelsSelectionBox.setCoords(axisRect.left(), origin.y()+selTickLabelOffset+selTickLabelSize, axisRect.right(), origin.y()+selTickLabelOffset); + mLabelSelectionBox.setCoords(axisRect.left(), origin.y()+selLabelOffset+selLabelSize, axisRect.right(), origin.y()+selLabelOffset); + } + mAxisSelectionBox = mAxisSelectionBox.normalized(); + mTickLabelsSelectionBox = mTickLabelsSelectionBox.normalized(); + mLabelSelectionBox = mLabelSelectionBox.normalized(); + // draw hitboxes for debug purposes: + //painter->setBrush(Qt::NoBrush); + //painter->drawRects(QVector() << mAxisSelectionBox << mTickLabelsSelectionBox << mLabelSelectionBox); +} + +/*! \internal + + Returns the size ("margin" in QCPAxisRect context, so measured perpendicular to the axis backbone + direction) needed to fit the axis. +*/ +int QCPAxisPainterPrivate::size() const +{ + int result = 0; + + // get length of tick marks pointing outwards: + if (!tickPositions.isEmpty()) + result += qMax(0, qMax(tickLengthOut, subTickLengthOut)); + + // calculate size of tick labels: + if (tickLabelSide == QCPAxis::lsOutside) + { + QSize tickLabelsSize(0, 0); + if (!tickLabels.isEmpty()) + { + for (int i=0; iplottingHints().testFlag(QCP::phCacheLabels) && !painter->modes().testFlag(QCPPainter::pmNoCaching)) // label caching enabled + { + if (!mLabelCache.contains(text)) // no cached label exists, create it + { + CachedLabel *newCachedLabel = new CachedLabel; + TickLabelData labelData = getTickLabelData(painter->font(), text); + newCachedLabel->offset = getTickLabelDrawOffset(labelData)+labelData.rotatedTotalBounds.topLeft(); + newCachedLabel->pixmap = QPixmap(labelData.rotatedTotalBounds.size()); + newCachedLabel->pixmap.fill(Qt::transparent); + QCPPainter cachePainter(&newCachedLabel->pixmap); + cachePainter.setPen(painter->pen()); + drawTickLabel(&cachePainter, -labelData.rotatedTotalBounds.topLeft().x(), -labelData.rotatedTotalBounds.topLeft().y(), labelData); + mLabelCache.insert(text, newCachedLabel, 1); + } + // draw cached label: + const CachedLabel *cachedLabel = mLabelCache.object(text); + // if label would be partly clipped by widget border on sides, don't draw it (only for outside tick labels): + if (tickLabelSide == QCPAxis::lsOutside) + { + if (QCPAxis::orientation(type) == Qt::Horizontal) + { + if (labelAnchor.x()+cachedLabel->offset.x()+cachedLabel->pixmap.width() > viewportRect.right() || + labelAnchor.x()+cachedLabel->offset.x() < viewportRect.left()) + return; + } else + { + if (labelAnchor.y()+cachedLabel->offset.y()+cachedLabel->pixmap.height() >viewportRect.bottom() || + labelAnchor.y()+cachedLabel->offset.y() < viewportRect.top()) + return; + } + } + painter->drawPixmap(labelAnchor+cachedLabel->offset, cachedLabel->pixmap); + finalSize = cachedLabel->pixmap.size(); + } else // label caching disabled, draw text directly on surface: + { + TickLabelData labelData = getTickLabelData(painter->font(), text); + QPointF finalPosition = labelAnchor + getTickLabelDrawOffset(labelData); + // if label would be partly clipped by widget border on sides, don't draw it (only for outside tick labels): + if (tickLabelSide == QCPAxis::lsOutside) + { + if (QCPAxis::orientation(type) == Qt::Horizontal) + { + if (finalPosition.x()+(labelData.rotatedTotalBounds.width()+labelData.rotatedTotalBounds.left()) > viewportRect.right() || + finalPosition.x()+labelData.rotatedTotalBounds.left() < viewportRect.left()) + return; + } else + { + if (finalPosition.y()+(labelData.rotatedTotalBounds.height()+labelData.rotatedTotalBounds.top()) > viewportRect.bottom() || + finalPosition.y()+labelData.rotatedTotalBounds.top() < viewportRect.top()) + return; + } + } + drawTickLabel(painter, finalPosition.x(), finalPosition.y(), labelData); + finalSize = labelData.rotatedTotalBounds.size(); + } + + // expand passed tickLabelsSize if current tick label is larger: + if (finalSize.width() > tickLabelsSize->width()) + tickLabelsSize->setWidth(finalSize.width()); + if (finalSize.height() > tickLabelsSize->height()) + tickLabelsSize->setHeight(finalSize.height()); +} + +/*! \internal + + This is a \ref placeTickLabel helper function. + + Draws the tick label specified in \a labelData with \a painter at the pixel positions \a x and \a + y. This function is used by \ref placeTickLabel to create new tick labels for the cache, or to + directly draw the labels on the QCustomPlot surface when label caching is disabled, i.e. when + QCP::phCacheLabels plotting hint is not set. +*/ +void QCPAxisPainterPrivate::drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const +{ + // backup painter settings that we're about to change: + QTransform oldTransform = painter->transform(); + QFont oldFont = painter->font(); + + // transform painter to position/rotation: + painter->translate(x, y); + if (!qFuzzyIsNull(tickLabelRotation)) + painter->rotate(tickLabelRotation); + + // draw text: + if (!labelData.expPart.isEmpty()) // indicator that beautiful powers must be used + { + painter->setFont(labelData.baseFont); + painter->drawText(0, 0, 0, 0, Qt::TextDontClip, labelData.basePart); + painter->setFont(labelData.expFont); + painter->drawText(labelData.baseBounds.width()+1, 0, labelData.expBounds.width(), labelData.expBounds.height(), Qt::TextDontClip, labelData.expPart); + } else + { + painter->setFont(labelData.baseFont); + painter->drawText(0, 0, labelData.totalBounds.width(), labelData.totalBounds.height(), Qt::TextDontClip | Qt::AlignHCenter, labelData.basePart); + } + + // reset painter settings to what it was before: + painter->setTransform(oldTransform); + painter->setFont(oldFont); +} + +/*! \internal + + This is a \ref placeTickLabel helper function. + + Transforms the passed \a text and \a font to a tickLabelData structure that can then be further + processed by \ref getTickLabelDrawOffset and \ref drawTickLabel. It splits the text into base and + exponent if necessary (member substituteExponent) and calculates appropriate bounding boxes. +*/ +QCPAxisPainterPrivate::TickLabelData QCPAxisPainterPrivate::getTickLabelData(const QFont &font, const QString &text) const +{ + TickLabelData result; + + // determine whether beautiful decimal powers should be used + bool useBeautifulPowers = false; + int ePos = -1; + if (substituteExponent) + { + ePos = text.indexOf('e'); + if (ePos > -1) + useBeautifulPowers = true; + } + + // calculate text bounding rects and do string preparation for beautiful decimal powers: + result.baseFont = font; + if (result.baseFont.pointSizeF() > 0) // On some rare systems, this sometimes is initialized with -1 (Qt bug?), so we check here before possibly setting a negative value in the next line + result.baseFont.setPointSizeF(result.baseFont.pointSizeF()+0.05); // QFontMetrics.boundingRect has a bug for exact point sizes that make the results oscillate due to internal rounding + if (useBeautifulPowers) + { + // split text into parts of number/symbol that will be drawn normally and part that will be drawn as exponent: + result.basePart = text.left(ePos); + // in log scaling, we want to turn "1*10^n" into "10^n", else add multiplication sign and decimal base: + if (abbreviateDecimalPowers && result.basePart == "1") + result.basePart = "10"; + else + result.basePart += (numberMultiplyCross ? QString(QChar(215)) : QString(QChar(183))) + "10"; + result.expPart = text.mid(ePos+1); + // clip "+" and leading zeros off expPart: + while (result.expPart.length() > 2 && result.expPart.at(1) == '0') // length > 2 so we leave one zero when numberFormatChar is 'e' + result.expPart.remove(1, 1); + if (!result.expPart.isEmpty() && result.expPart.at(0) == '+') + result.expPart.remove(0, 1); + // prepare smaller font for exponent: + result.expFont = font; + result.expFont.setPointSize(result.expFont.pointSize()*0.75); + // calculate bounding rects of base part, exponent part and total one: + result.baseBounds = QFontMetrics(result.baseFont).boundingRect(0, 0, 0, 0, Qt::TextDontClip, result.basePart); + result.expBounds = QFontMetrics(result.expFont).boundingRect(0, 0, 0, 0, Qt::TextDontClip, result.expPart); + result.totalBounds = result.baseBounds.adjusted(0, 0, result.expBounds.width()+2, 0); // +2 consists of the 1 pixel spacing between base and exponent (see drawTickLabel) and an extra pixel to include AA + } else // useBeautifulPowers == false + { + result.basePart = text; + result.totalBounds = QFontMetrics(result.baseFont).boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter, result.basePart); + } + result.totalBounds.moveTopLeft(QPoint(0, 0)); // want bounding box aligned top left at origin, independent of how it was created, to make further processing simpler + + // calculate possibly different bounding rect after rotation: + result.rotatedTotalBounds = result.totalBounds; + if (!qFuzzyIsNull(tickLabelRotation)) + { + QTransform transform; + transform.rotate(tickLabelRotation); + result.rotatedTotalBounds = transform.mapRect(result.rotatedTotalBounds); + } + + return result; +} + +/*! \internal + + This is a \ref placeTickLabel helper function. + + Calculates the offset at which the top left corner of the specified tick label shall be drawn. + The offset is relative to a point right next to the tick the label belongs to. + + This function is thus responsible for e.g. centering tick labels under ticks and positioning them + appropriately when they are rotated. +*/ +QPointF QCPAxisPainterPrivate::getTickLabelDrawOffset(const TickLabelData &labelData) const +{ + /* + calculate label offset from base point at tick (non-trivial, for best visual appearance): short + explanation for bottom axis: The anchor, i.e. the point in the label that is placed + horizontally under the corresponding tick is always on the label side that is closer to the + axis (e.g. the left side of the text when we're rotating clockwise). On that side, the height + is halved and the resulting point is defined the anchor. This way, a 90 degree rotated text + will be centered under the tick (i.e. displaced horizontally by half its height). At the same + time, a 45 degree rotated text will "point toward" its tick, as is typical for rotated tick + labels. + */ + bool doRotation = !qFuzzyIsNull(tickLabelRotation); + bool flip = qFuzzyCompare(qAbs(tickLabelRotation), 90.0); // perfect +/-90 degree flip. Indicates vertical label centering on vertical axes. + double radians = tickLabelRotation/180.0*M_PI; + int x=0, y=0; + if ((type == QCPAxis::atLeft && tickLabelSide == QCPAxis::lsOutside) || (type == QCPAxis::atRight && tickLabelSide == QCPAxis::lsInside)) // Anchor at right side of tick label + { + if (doRotation) + { + if (tickLabelRotation > 0) + { + x = -qCos(radians)*labelData.totalBounds.width(); + y = flip ? -labelData.totalBounds.width()/2.0 : -qSin(radians)*labelData.totalBounds.width()-qCos(radians)*labelData.totalBounds.height()/2.0; + } else + { + x = -qCos(-radians)*labelData.totalBounds.width()-qSin(-radians)*labelData.totalBounds.height(); + y = flip ? +labelData.totalBounds.width()/2.0 : +qSin(-radians)*labelData.totalBounds.width()-qCos(-radians)*labelData.totalBounds.height()/2.0; + } + } else + { + x = -labelData.totalBounds.width(); + y = -labelData.totalBounds.height()/2.0; + } + } else if ((type == QCPAxis::atRight && tickLabelSide == QCPAxis::lsOutside) || (type == QCPAxis::atLeft && tickLabelSide == QCPAxis::lsInside)) // Anchor at left side of tick label + { + if (doRotation) + { + if (tickLabelRotation > 0) + { + x = +qSin(radians)*labelData.totalBounds.height(); + y = flip ? -labelData.totalBounds.width()/2.0 : -qCos(radians)*labelData.totalBounds.height()/2.0; + } else + { + x = 0; + y = flip ? +labelData.totalBounds.width()/2.0 : -qCos(-radians)*labelData.totalBounds.height()/2.0; + } + } else + { + x = 0; + y = -labelData.totalBounds.height()/2.0; + } + } else if ((type == QCPAxis::atTop && tickLabelSide == QCPAxis::lsOutside) || (type == QCPAxis::atBottom && tickLabelSide == QCPAxis::lsInside)) // Anchor at bottom side of tick label + { + if (doRotation) + { + if (tickLabelRotation > 0) + { + x = -qCos(radians)*labelData.totalBounds.width()+qSin(radians)*labelData.totalBounds.height()/2.0; + y = -qSin(radians)*labelData.totalBounds.width()-qCos(radians)*labelData.totalBounds.height(); + } else + { + x = -qSin(-radians)*labelData.totalBounds.height()/2.0; + y = -qCos(-radians)*labelData.totalBounds.height(); + } + } else + { + x = -labelData.totalBounds.width()/2.0; + y = -labelData.totalBounds.height(); + } + } else if ((type == QCPAxis::atBottom && tickLabelSide == QCPAxis::lsOutside) || (type == QCPAxis::atTop && tickLabelSide == QCPAxis::lsInside)) // Anchor at top side of tick label + { + if (doRotation) + { + if (tickLabelRotation > 0) + { + x = +qSin(radians)*labelData.totalBounds.height()/2.0; + y = 0; + } else + { + x = -qCos(-radians)*labelData.totalBounds.width()-qSin(-radians)*labelData.totalBounds.height()/2.0; + y = +qSin(-radians)*labelData.totalBounds.width(); + } + } else + { + x = -labelData.totalBounds.width()/2.0; + y = 0; + } + } + + return QPointF(x, y); +} + +/*! \internal + + Simulates the steps done by \ref placeTickLabel by calculating bounding boxes of the text label + to be drawn, depending on number format etc. Since only the largest tick label is wanted for the + margin calculation, the passed \a tickLabelsSize is only expanded, if it's currently set to a + smaller width/height. +*/ +void QCPAxisPainterPrivate::getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const +{ + // note: this function must return the same tick label sizes as the placeTickLabel function. + QSize finalSize; + if (mParentPlot->plottingHints().testFlag(QCP::phCacheLabels) && mLabelCache.contains(text)) // label caching enabled and have cached label + { + const CachedLabel *cachedLabel = mLabelCache.object(text); + finalSize = cachedLabel->pixmap.size(); + } else // label caching disabled or no label with this text cached: + { + TickLabelData labelData = getTickLabelData(font, text); + finalSize = labelData.rotatedTotalBounds.size(); + } + + // expand passed tickLabelsSize if current tick label is larger: + if (finalSize.width() > tickLabelsSize->width()) + tickLabelsSize->setWidth(finalSize.width()); + if (finalSize.height() > tickLabelsSize->height()) + tickLabelsSize->setHeight(finalSize.height()); +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPAbstractPlottable +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPAbstractPlottable + \brief The abstract base class for all data representing objects in a plot. + + It defines a very basic interface like name, pen, brush, visibility etc. Since this class is + abstract, it can't be instantiated. Use one of the subclasses or create a subclass yourself to + create new ways of displaying data (see "Creating own plottables" below). + + All further specifics are in the subclasses, for example: + \li A normal graph with possibly a line, scatter points and error bars: \ref QCPGraph + (typically created with \ref QCustomPlot::addGraph) + \li A parametric curve: \ref QCPCurve + \li A bar chart: \ref QCPBars + \li A statistical box plot: \ref QCPStatisticalBox + \li A color encoded two-dimensional map: \ref QCPColorMap + \li An OHLC/Candlestick chart: \ref QCPFinancial + + \section plottables-subclassing Creating own plottables + + To create an own plottable, you implement a subclass of QCPAbstractPlottable. These are the pure + virtual functions, you must implement: + \li \ref clearData + \li \ref selectTest + \li \ref draw + \li \ref drawLegendIcon + \li \ref getKeyRange + \li \ref getValueRange + + See the documentation of those functions for what they need to do. + + For drawing your plot, you can use the \ref coordsToPixels functions to translate a point in plot + coordinates to pixel coordinates. This function is quite convenient, because it takes the + orientation of the key and value axes into account for you (x and y are swapped when the key axis + is vertical and the value axis horizontal). If you are worried about performance (i.e. you need + to translate many points in a loop like QCPGraph), you can directly use \ref + QCPAxis::coordToPixel. However, you must then take care about the orientation of the axis + yourself. + + Here are some important members you inherit from QCPAbstractPlottable: + + + + + + + + + + + + + + + + + + + + + + + + + + +
QCustomPlot *\b mParentPlotA pointer to the parent QCustomPlot instance. The parent plot is inferred from the axes that are passed in the constructor.
QString \b mNameThe name of the plottable.
QPen \b mPenThe generic pen of the plottable. You should use this pen for the most prominent data representing lines in the plottable (e.g QCPGraph uses this pen for its graph lines and scatters)
QPen \b mSelectedPenThe generic pen that should be used when the plottable is selected (hint: \ref mainPen gives you the right pen, depending on selection state).
QBrush \b mBrushThe generic brush of the plottable. You should use this brush for the most prominent fillable structures in the plottable (e.g. QCPGraph uses this brush to control filling under the graph)
QBrush \b mSelectedBrushThe generic brush that should be used when the plottable is selected (hint: \ref mainBrush gives you the right brush, depending on selection state).
QPointer\b mKeyAxis, \b mValueAxisThe key and value axes this plottable is attached to. Call their QCPAxis::coordToPixel functions to translate coordinates to pixels in either the key or value dimension. + Make sure to check whether the pointer is null before using it. If one of the axes is null, don't draw the plottable.
bool \b mSelectedindicates whether the plottable is selected or not.
+*/ + +/* start of documentation of pure virtual functions */ + +/*! \fn void QCPAbstractPlottable::clearData() = 0 + Clears all data in the plottable. +*/ + +/*! \fn void QCPAbstractPlottable::drawLegendIcon(QCPPainter *painter, const QRect &rect) const = 0 + \internal + + called by QCPLegend::draw (via QCPPlottableLegendItem::draw) to create a graphical representation + of this plottable inside \a rect, next to the plottable name. +*/ + +/*! \fn QCPRange QCPAbstractPlottable::getKeyRange(bool &foundRange, SignDomain inSignDomain) const = 0 + \internal + + called by rescaleAxes functions to get the full data key bounds. For logarithmic plots, one can + set \a inSignDomain to either \ref sdNegative or \ref sdPositive in order to restrict the + returned range to that sign domain. E.g. when only negative range is wanted, set \a inSignDomain + to \ref sdNegative and all positive points will be ignored for range calculation. For no + restriction, just set \a inSignDomain to \ref sdBoth (default). \a foundRange is an output + parameter that indicates whether a range could be found or not. If this is false, you shouldn't + use the returned range (e.g. no points in data). + + Note that \a foundRange is not the same as \ref QCPRange::validRange, since the range returned by + this function may have size zero, which wouldn't count as a valid range. + + \see rescaleAxes, getValueRange +*/ + +/*! \fn QCPRange QCPAbstractPlottable::getValueRange(bool &foundRange, SignDomain inSignDomain) const = 0 + \internal + + called by rescaleAxes functions to get the full data value bounds. For logarithmic plots, one can + set \a inSignDomain to either \ref sdNegative or \ref sdPositive in order to restrict the + returned range to that sign domain. E.g. when only negative range is wanted, set \a inSignDomain + to \ref sdNegative and all positive points will be ignored for range calculation. For no + restriction, just set \a inSignDomain to \ref sdBoth (default). \a foundRange is an output + parameter that indicates whether a range could be found or not. If this is false, you shouldn't + use the returned range (e.g. no points in data). + + Note that \a foundRange is not the same as \ref QCPRange::validRange, since the range returned by + this function may have size zero, which wouldn't count as a valid range. + + \see rescaleAxes, getKeyRange +*/ + +/* end of documentation of pure virtual functions */ +/* start of documentation of signals */ + +/*! \fn void QCPAbstractPlottable::selectionChanged(bool selected) + + This signal is emitted when the selection state of this plottable has changed, either by user + interaction or by a direct call to \ref setSelected. +*/ + +/*! \fn void QCPAbstractPlottable::selectableChanged(bool selectable); + + This signal is emitted when the selectability of this plottable has changed. + + \see setSelectable +*/ + +/* end of documentation of signals */ + +/*! + Constructs an abstract plottable which uses \a keyAxis as its key axis ("x") and \a valueAxis as + its value axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance + and have perpendicular orientations. If either of these restrictions is violated, a corresponding + message is printed to the debug output (qDebug), the construction is not aborted, though. + + Since QCPAbstractPlottable is an abstract class that defines the basic interface to plottables, + it can't be directly instantiated. + + You probably want one of the subclasses like \ref QCPGraph or \ref QCPCurve instead. +*/ +QCPAbstractPlottable::QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPLayerable(keyAxis->parentPlot(), "", keyAxis->axisRect()), + mName(""), + mAntialiasedFill(true), + mAntialiasedScatters(true), + mAntialiasedErrorBars(false), + mPen(Qt::black), + mSelectedPen(Qt::black), + mBrush(Qt::NoBrush), + mSelectedBrush(Qt::NoBrush), + mKeyAxis(keyAxis), + mValueAxis(valueAxis), + mSelectable(true), + mSelected(false) +{ + if (keyAxis->parentPlot() != valueAxis->parentPlot()) + qDebug() << Q_FUNC_INFO << "Parent plot of keyAxis is not the same as that of valueAxis."; + if (keyAxis->orientation() == valueAxis->orientation()) + qDebug() << Q_FUNC_INFO << "keyAxis and valueAxis must be orthogonal to each other."; +} + +/*! + The name is the textual representation of this plottable as it is displayed in the legend + (\ref QCPLegend). It may contain any UTF-8 characters, including newlines. +*/ +void QCPAbstractPlottable::setName(const QString &name) +{ + mName = name; +} + +/*! + Sets whether fills of this plottable is drawn antialiased or not. + + Note that this setting may be overridden by \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. +*/ +void QCPAbstractPlottable::setAntialiasedFill(bool enabled) +{ + mAntialiasedFill = enabled; +} + +/*! + Sets whether the scatter symbols of this plottable are drawn antialiased or not. + + Note that this setting may be overridden by \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. +*/ +void QCPAbstractPlottable::setAntialiasedScatters(bool enabled) +{ + mAntialiasedScatters = enabled; +} + +/*! + Sets whether the error bars of this plottable are drawn antialiased or not. + + Note that this setting may be overridden by \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. +*/ +void QCPAbstractPlottable::setAntialiasedErrorBars(bool enabled) +{ + mAntialiasedErrorBars = enabled; +} + + +/*! + The pen is used to draw basic lines that make up the plottable representation in the + plot. + + For example, the \ref QCPGraph subclass draws its graph lines and scatter points + with this pen. + + \see setBrush +*/ +void QCPAbstractPlottable::setPen(const QPen &pen) +{ + mPen = pen; +} + +/*! + When the plottable is selected, this pen is used to draw basic lines instead of the normal + pen set via \ref setPen. + + \see setSelected, setSelectable, setSelectedBrush, selectTest +*/ +void QCPAbstractPlottable::setSelectedPen(const QPen &pen) +{ + mSelectedPen = pen; +} + +/*! + The brush is used to draw basic fills of the plottable representation in the + plot. The Fill can be a color, gradient or texture, see the usage of QBrush. + + For example, the \ref QCPGraph subclass draws the fill under the graph with this brush, when + it's not set to Qt::NoBrush. + + \see setPen +*/ +void QCPAbstractPlottable::setBrush(const QBrush &brush) +{ + mBrush = brush; +} + +/*! + When the plottable is selected, this brush is used to draw fills instead of the normal + brush set via \ref setBrush. + + \see setSelected, setSelectable, setSelectedPen, selectTest +*/ +void QCPAbstractPlottable::setSelectedBrush(const QBrush &brush) +{ + mSelectedBrush = brush; +} + +/*! + The key axis of a plottable can be set to any axis of a QCustomPlot, as long as it is orthogonal + to the plottable's value axis. This function performs no checks to make sure this is the case. + The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and the + y-axis (QCustomPlot::yAxis) as value axis. + + Normally, the key and value axes are set in the constructor of the plottable (or \ref + QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface). + + \see setValueAxis +*/ +void QCPAbstractPlottable::setKeyAxis(QCPAxis *axis) +{ + mKeyAxis = axis; +} + +/*! + The value axis of a plottable can be set to any axis of a QCustomPlot, as long as it is + orthogonal to the plottable's key axis. This function performs no checks to make sure this is the + case. The typical mathematical choice is to use the x-axis (QCustomPlot::xAxis) as key axis and + the y-axis (QCustomPlot::yAxis) as value axis. + + Normally, the key and value axes are set in the constructor of the plottable (or \ref + QCustomPlot::addGraph when working with QCPGraphs through the dedicated graph interface). + + \see setKeyAxis +*/ +void QCPAbstractPlottable::setValueAxis(QCPAxis *axis) +{ + mValueAxis = axis; +} + +/*! + Sets whether the user can (de-)select this plottable by clicking on the QCustomPlot surface. + (When \ref QCustomPlot::setInteractions contains iSelectPlottables.) + + However, even when \a selectable was set to false, it is possible to set the selection manually, + by calling \ref setSelected directly. + + \see setSelected +*/ +void QCPAbstractPlottable::setSelectable(bool selectable) +{ + if (mSelectable != selectable) + { + mSelectable = selectable; + emit selectableChanged(mSelectable); + } +} + +/*! + Sets whether this plottable is selected or not. When selected, it uses a different pen and brush + to draw its lines and fills, see \ref setSelectedPen and \ref setSelectedBrush. + + The entire selection mechanism for plottables is handled automatically when \ref + QCustomPlot::setInteractions contains iSelectPlottables. You only need to call this function when + you wish to change the selection state manually. + + This function can change the selection state even when \ref setSelectable was set to false. + + emits the \ref selectionChanged signal when \a selected is different from the previous selection state. + + \see setSelectable, selectTest +*/ +void QCPAbstractPlottable::setSelected(bool selected) +{ + if (mSelected != selected) + { + mSelected = selected; + emit selectionChanged(mSelected); + } +} + +/*! + Rescales the key and value axes associated with this plottable to contain all displayed data, so + the whole plottable is visible. If the scaling of an axis is logarithmic, rescaleAxes will make + sure not to rescale to an illegal range i.e. a range containing different signs and/or zero. + Instead it will stay in the current sign domain and ignore all parts of the plottable that lie + outside of that domain. + + \a onlyEnlarge makes sure the ranges are only expanded, never reduced. So it's possible to show + multiple plottables in their entirety by multiple calls to rescaleAxes where the first call has + \a onlyEnlarge set to false (the default), and all subsequent set to true. + + \see rescaleKeyAxis, rescaleValueAxis, QCustomPlot::rescaleAxes, QCPAxis::rescale +*/ +void QCPAbstractPlottable::rescaleAxes(bool onlyEnlarge) const +{ + rescaleKeyAxis(onlyEnlarge); + rescaleValueAxis(onlyEnlarge); +} + +/*! + Rescales the key axis of the plottable so the whole plottable is visible. + + See \ref rescaleAxes for detailed behaviour. +*/ +void QCPAbstractPlottable::rescaleKeyAxis(bool onlyEnlarge) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + if (!keyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } + + SignDomain signDomain = sdBoth; + if (keyAxis->scaleType() == QCPAxis::stLogarithmic) + signDomain = (keyAxis->range().upper < 0 ? sdNegative : sdPositive); + + bool foundRange; + QCPRange newRange = getKeyRange(foundRange, signDomain); + if (foundRange) + { + if (onlyEnlarge) + newRange.expand(keyAxis->range()); + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable + { + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (keyAxis->scaleType() == QCPAxis::stLinear) + { + newRange.lower = center-keyAxis->range().size()/2.0; + newRange.upper = center+keyAxis->range().size()/2.0; + } else // scaleType() == stLogarithmic + { + newRange.lower = center/qSqrt(keyAxis->range().upper/keyAxis->range().lower); + newRange.upper = center*qSqrt(keyAxis->range().upper/keyAxis->range().lower); + } + } + keyAxis->setRange(newRange); + } +} + +/*! + Rescales the value axis of the plottable so the whole plottable is visible. + + Returns true if the axis was actually scaled. This might not be the case if this plottable has an + invalid range, e.g. because it has no data points. + + See \ref rescaleAxes for detailed behaviour. +*/ +void QCPAbstractPlottable::rescaleValueAxis(bool onlyEnlarge) const +{ + QCPAxis *valueAxis = mValueAxis.data(); + if (!valueAxis) { qDebug() << Q_FUNC_INFO << "invalid value axis"; return; } + + SignDomain signDomain = sdBoth; + if (valueAxis->scaleType() == QCPAxis::stLogarithmic) + signDomain = (valueAxis->range().upper < 0 ? sdNegative : sdPositive); + + bool foundRange; + QCPRange newRange = getValueRange(foundRange, signDomain); + if (foundRange) + { + if (onlyEnlarge) + newRange.expand(valueAxis->range()); + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable + { + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (valueAxis->scaleType() == QCPAxis::stLinear) + { + newRange.lower = center-valueAxis->range().size()/2.0; + newRange.upper = center+valueAxis->range().size()/2.0; + } else // scaleType() == stLogarithmic + { + newRange.lower = center/qSqrt(valueAxis->range().upper/valueAxis->range().lower); + newRange.upper = center*qSqrt(valueAxis->range().upper/valueAxis->range().lower); + } + } + valueAxis->setRange(newRange); + } +} + +/*! + Adds this plottable to the legend of the parent QCustomPlot (QCustomPlot::legend). + + Normally, a QCPPlottableLegendItem is created and inserted into the legend. If the plottable + needs a more specialized representation in the legend, this function will take this into account + and instead create the specialized subclass of QCPAbstractLegendItem. + + Returns true on success, i.e. when the legend exists and a legend item associated with this plottable isn't already in + the legend. + + \see removeFromLegend, QCPLegend::addItem +*/ +bool QCPAbstractPlottable::addToLegend() +{ + if (!mParentPlot || !mParentPlot->legend) + return false; + + if (!mParentPlot->legend->hasItemWithPlottable(this)) + { + mParentPlot->legend->addItem(new QCPPlottableLegendItem(mParentPlot->legend, this)); + return true; + } else + return false; +} + +/*! + Removes the plottable from the legend of the parent QCustomPlot. This means the + QCPAbstractLegendItem (usually a QCPPlottableLegendItem) that is associated with this plottable + is removed. + + Returns true on success, i.e. if the legend exists and a legend item associated with this + plottable was found and removed. + + \see addToLegend, QCPLegend::removeItem +*/ +bool QCPAbstractPlottable::removeFromLegend() const +{ + if (!mParentPlot->legend) + return false; + + if (QCPPlottableLegendItem *lip = mParentPlot->legend->itemWithPlottable(this)) + return mParentPlot->legend->removeItem(lip); + else + return false; +} + +/* inherits documentation from base class */ +QRect QCPAbstractPlottable::clipRect() const +{ + if (mKeyAxis && mValueAxis) + return mKeyAxis.data()->axisRect()->rect() & mValueAxis.data()->axisRect()->rect(); + else + return QRect(); +} + +/* inherits documentation from base class */ +QCP::Interaction QCPAbstractPlottable::selectionCategory() const +{ + return QCP::iSelectPlottables; +} + +/*! \internal + + Convenience function for transforming a key/value pair to pixels on the QCustomPlot surface, + taking the orientations of the axes associated with this plottable into account (e.g. whether key + represents x or y). + + \a key and \a value are transformed to the coodinates in pixels and are written to \a x and \a y. + + \see pixelsToCoords, QCPAxis::coordToPixel +*/ +void QCPAbstractPlottable::coordsToPixels(double key, double value, double &x, double &y) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + if (keyAxis->orientation() == Qt::Horizontal) + { + x = keyAxis->coordToPixel(key); + y = valueAxis->coordToPixel(value); + } else + { + y = keyAxis->coordToPixel(key); + x = valueAxis->coordToPixel(value); + } +} + +/*! \internal + \overload + + Returns the input as pixel coordinates in a QPointF. +*/ +const QPointF QCPAbstractPlottable::coordsToPixels(double key, double value) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(); } + + if (keyAxis->orientation() == Qt::Horizontal) + return QPointF(keyAxis->coordToPixel(key), valueAxis->coordToPixel(value)); + else + return QPointF(valueAxis->coordToPixel(value), keyAxis->coordToPixel(key)); +} + +/*! \internal + + Convenience function for transforming a x/y pixel pair on the QCustomPlot surface to plot coordinates, + taking the orientations of the axes associated with this plottable into account (e.g. whether key + represents x or y). + + \a x and \a y are transformed to the plot coodinates and are written to \a key and \a value. + + \see coordsToPixels, QCPAxis::coordToPixel +*/ +void QCPAbstractPlottable::pixelsToCoords(double x, double y, double &key, double &value) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + if (keyAxis->orientation() == Qt::Horizontal) + { + key = keyAxis->pixelToCoord(x); + value = valueAxis->pixelToCoord(y); + } else + { + key = keyAxis->pixelToCoord(y); + value = valueAxis->pixelToCoord(x); + } +} + +/*! \internal + \overload + + Returns the pixel input \a pixelPos as plot coordinates \a key and \a value. +*/ +void QCPAbstractPlottable::pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const +{ + pixelsToCoords(pixelPos.x(), pixelPos.y(), key, value); +} + +/*! \internal + + Returns the pen that should be used for drawing lines of the plottable. Returns mPen when the + graph is not selected and mSelectedPen when it is. +*/ +QPen QCPAbstractPlottable::mainPen() const +{ + return mSelected ? mSelectedPen : mPen; +} + +/*! \internal + + Returns the brush that should be used for drawing fills of the plottable. Returns mBrush when the + graph is not selected and mSelectedBrush when it is. +*/ +QBrush QCPAbstractPlottable::mainBrush() const +{ + return mSelected ? mSelectedBrush : mBrush; +} + +/*! \internal + + A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter + before drawing plottable lines. + + This is the antialiasing state the painter passed to the \ref draw method is in by default. + + This function takes into account the local setting of the antialiasing flag as well as the + overrides set with \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. + + \see setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint +*/ +void QCPAbstractPlottable::applyDefaultAntialiasingHint(QCPPainter *painter) const +{ + applyAntialiasingHint(painter, mAntialiased, QCP::aePlottables); +} + +/*! \internal + + A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter + before drawing plottable fills. + + This function takes into account the local setting of the antialiasing flag as well as the + overrides set with \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. + + \see setAntialiased, applyDefaultAntialiasingHint, applyScattersAntialiasingHint, applyErrorBarsAntialiasingHint +*/ +void QCPAbstractPlottable::applyFillAntialiasingHint(QCPPainter *painter) const +{ + applyAntialiasingHint(painter, mAntialiasedFill, QCP::aeFills); +} + +/*! \internal + + A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter + before drawing plottable scatter points. + + This function takes into account the local setting of the antialiasing flag as well as the + overrides set with \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. + + \see setAntialiased, applyFillAntialiasingHint, applyDefaultAntialiasingHint, applyErrorBarsAntialiasingHint +*/ +void QCPAbstractPlottable::applyScattersAntialiasingHint(QCPPainter *painter) const +{ + applyAntialiasingHint(painter, mAntialiasedScatters, QCP::aeScatters); +} + +/*! \internal + + A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter + before drawing plottable error bars. + + This function takes into account the local setting of the antialiasing flag as well as the + overrides set with \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. + + \see setAntialiased, applyFillAntialiasingHint, applyScattersAntialiasingHint, applyDefaultAntialiasingHint +*/ +void QCPAbstractPlottable::applyErrorBarsAntialiasingHint(QCPPainter *painter) const +{ + applyAntialiasingHint(painter, mAntialiasedErrorBars, QCP::aeErrorBars); +} + +/*! \internal + + Finds the shortest squared distance of \a point to the line segment defined by \a start and \a + end. + + This function may be used to help with the implementation of the \ref selectTest function for + specific plottables. + + \note This function is identical to QCPAbstractItem::distSqrToLine +*/ +double QCPAbstractPlottable::distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const +{ + QVector2D a(start); + QVector2D b(end); + QVector2D p(point); + QVector2D v(b-a); + + double vLengthSqr = v.lengthSquared(); + if (!qFuzzyIsNull(vLengthSqr)) + { + double mu = QVector2D::dotProduct(p-a, v)/vLengthSqr; + if (mu < 0) + return (a-p).lengthSquared(); + else if (mu > 1) + return (b-p).lengthSquared(); + else + return ((a + mu*v)-p).lengthSquared(); + } else + return (a-p).lengthSquared(); +} + +/* inherits documentation from base class */ +void QCPAbstractPlottable::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) +{ + Q_UNUSED(event) + Q_UNUSED(details) + if (mSelectable) + { + bool selBefore = mSelected; + setSelected(additive ? !mSelected : true); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; + } +} + +/* inherits documentation from base class */ +void QCPAbstractPlottable::deselectEvent(bool *selectionStateChanged) +{ + if (mSelectable) + { + bool selBefore = mSelected; + setSelected(false); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; + } +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemAnchor +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemAnchor + \brief An anchor of an item to which positions can be attached to. + + An item (QCPAbstractItem) may have one or more anchors. Unlike QCPItemPosition, an anchor doesn't + control anything on its item, but provides a way to tie other items via their positions to the + anchor. + + For example, a QCPItemRect is defined by its positions \a topLeft and \a bottomRight. + Additionally it has various anchors like \a top, \a topRight or \a bottomLeft etc. So you can + attach the \a start (which is a QCPItemPosition) of a QCPItemLine to one of the anchors by + calling QCPItemPosition::setParentAnchor on \a start, passing the wanted anchor of the + QCPItemRect. This way the start of the line will now always follow the respective anchor location + on the rect item. + + Note that QCPItemPosition derives from QCPItemAnchor, so every position can also serve as an + anchor to other positions. + + To learn how to provide anchors in your own item subclasses, see the subclassing section of the + QCPAbstractItem documentation. +*/ + +/* start documentation of inline functions */ + +/*! \fn virtual QCPItemPosition *QCPItemAnchor::toQCPItemPosition() + + Returns 0 if this instance is merely a QCPItemAnchor, and a valid pointer of type QCPItemPosition* if + it actually is a QCPItemPosition (which is a subclass of QCPItemAnchor). + + This safe downcast functionality could also be achieved with a dynamic_cast. However, QCustomPlot avoids + dynamic_cast to work with projects that don't have RTTI support enabled (e.g. -fno-rtti flag with + gcc compiler). +*/ + +/* end documentation of inline functions */ + +/*! + Creates a new QCPItemAnchor. You shouldn't create QCPItemAnchor instances directly, even if + you want to make a new item subclass. Use \ref QCPAbstractItem::createAnchor instead, as + explained in the subclassing section of the QCPAbstractItem documentation. +*/ +QCPItemAnchor::QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name, int anchorId) : + mName(name), + mParentPlot(parentPlot), + mParentItem(parentItem), + mAnchorId(anchorId) +{ +} + +QCPItemAnchor::~QCPItemAnchor() +{ + // unregister as parent at children: + foreach (QCPItemPosition *child, mChildrenX.toList()) + { + if (child->parentAnchorX() == this) + child->setParentAnchorX(0); // this acts back on this anchor and child removes itself from mChildrenX + } + foreach (QCPItemPosition *child, mChildrenY.toList()) + { + if (child->parentAnchorY() == this) + child->setParentAnchorY(0); // this acts back on this anchor and child removes itself from mChildrenY + } +} + +/*! + Returns the final absolute pixel position of the QCPItemAnchor on the QCustomPlot surface. + + The pixel information is internally retrieved via QCPAbstractItem::anchorPixelPosition of the + parent item, QCPItemAnchor is just an intermediary. +*/ +QPointF QCPItemAnchor::pixelPoint() const +{ + if (mParentItem) + { + if (mAnchorId > -1) + { + return mParentItem->anchorPixelPoint(mAnchorId); + } else + { + qDebug() << Q_FUNC_INFO << "no valid anchor id set:" << mAnchorId; + return QPointF(); + } + } else + { + qDebug() << Q_FUNC_INFO << "no parent item set"; + return QPointF(); + } +} + +/*! \internal + + Adds \a pos to the childX list of this anchor, which keeps track of which children use this + anchor as parent anchor for the respective coordinate. This is necessary to notify the children + prior to destruction of the anchor. + + Note that this function does not change the parent setting in \a pos. +*/ +void QCPItemAnchor::addChildX(QCPItemPosition *pos) +{ + if (!mChildrenX.contains(pos)) + mChildrenX.insert(pos); + else + qDebug() << Q_FUNC_INFO << "provided pos is child already" << reinterpret_cast(pos); +} + +/*! \internal + + Removes \a pos from the childX list of this anchor. + + Note that this function does not change the parent setting in \a pos. +*/ +void QCPItemAnchor::removeChildX(QCPItemPosition *pos) +{ + if (!mChildrenX.remove(pos)) + qDebug() << Q_FUNC_INFO << "provided pos isn't child" << reinterpret_cast(pos); +} + +/*! \internal + + Adds \a pos to the childY list of this anchor, which keeps track of which children use this + anchor as parent anchor for the respective coordinate. This is necessary to notify the children + prior to destruction of the anchor. + + Note that this function does not change the parent setting in \a pos. +*/ +void QCPItemAnchor::addChildY(QCPItemPosition *pos) +{ + if (!mChildrenY.contains(pos)) + mChildrenY.insert(pos); + else + qDebug() << Q_FUNC_INFO << "provided pos is child already" << reinterpret_cast(pos); +} + +/*! \internal + + Removes \a pos from the childY list of this anchor. + + Note that this function does not change the parent setting in \a pos. +*/ +void QCPItemAnchor::removeChildY(QCPItemPosition *pos) +{ + if (!mChildrenY.remove(pos)) + qDebug() << Q_FUNC_INFO << "provided pos isn't child" << reinterpret_cast(pos); +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemPosition +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemPosition + \brief Manages the position of an item. + + Every item has at least one public QCPItemPosition member pointer which provides ways to position the + item on the QCustomPlot surface. Some items have multiple positions, for example QCPItemRect has two: + \a topLeft and \a bottomRight. + + QCPItemPosition has a type (\ref PositionType) that can be set with \ref setType. This type + defines how coordinates passed to \ref setCoords are to be interpreted, e.g. as absolute pixel + coordinates, as plot coordinates of certain axes, etc. For more advanced plots it is also + possible to assign different types per X/Y coordinate of the position (see \ref setTypeX, \ref + setTypeY). This way an item could be positioned at a fixed pixel distance from the top in the Y + direction, while following a plot coordinate in the X direction. + + A QCPItemPosition may have a parent QCPItemAnchor, see \ref setParentAnchor. This way you can tie + multiple items together. If the QCPItemPosition has a parent, its coordinates (\ref setCoords) + are considered to be absolute pixels in the reference frame of the parent anchor, where (0, 0) + means directly ontop of the parent anchor. For example, You could attach the \a start position of + a QCPItemLine to the \a bottom anchor of a QCPItemText to make the starting point of the line + always be centered under the text label, no matter where the text is moved to. For more advanced + plots, it is possible to assign different parent anchors per X/Y coordinate of the position, see + \ref setParentAnchorX, \ref setParentAnchorY. This way an item could follow another item in the X + direction but stay at a fixed position in the Y direction. Or even follow item A in X, and item B + in Y. + + Note that every QCPItemPosition inherits from QCPItemAnchor and thus can itself be used as parent + anchor for other positions. + + To set the apparent pixel position on the QCustomPlot surface directly, use \ref setPixelPoint. This + works no matter what type this QCPItemPosition is or what parent-child situation it is in, as \ref + setPixelPoint transforms the coordinates appropriately, to make the position appear at the specified + pixel values. +*/ + +/* start documentation of inline functions */ + +/*! \fn QCPItemPosition::PositionType *QCPItemPosition::type() const + + Returns the current position type. + + If different types were set for X and Y (\ref setTypeX, \ref setTypeY), this method returns the + type of the X coordinate. In that case rather use \a typeX() and \a typeY(). + + \see setType +*/ + +/*! \fn QCPItemAnchor *QCPItemPosition::parentAnchor() const + + Returns the current parent anchor. + + If different parent anchors were set for X and Y (\ref setParentAnchorX, \ref setParentAnchorY), + this method returns the parent anchor of the Y coordinate. In that case rather use \a + parentAnchorX() and \a parentAnchorY(). + + \see setParentAnchor +*/ + +/* end documentation of inline functions */ + +/*! + Creates a new QCPItemPosition. You shouldn't create QCPItemPosition instances directly, even if + you want to make a new item subclass. Use \ref QCPAbstractItem::createPosition instead, as + explained in the subclassing section of the QCPAbstractItem documentation. +*/ +QCPItemPosition::QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name) : + QCPItemAnchor(parentPlot, parentItem, name), + mPositionTypeX(ptAbsolute), + mPositionTypeY(ptAbsolute), + mKey(0), + mValue(0), + mParentAnchorX(0), + mParentAnchorY(0) +{ +} + +QCPItemPosition::~QCPItemPosition() +{ + // unregister as parent at children: + // Note: this is done in ~QCPItemAnchor again, but it's important QCPItemPosition does it itself, because only then + // the setParentAnchor(0) call the correct QCPItemPosition::pixelPoint function instead of QCPItemAnchor::pixelPoint + foreach (QCPItemPosition *child, mChildrenX.toList()) + { + if (child->parentAnchorX() == this) + child->setParentAnchorX(0); // this acts back on this anchor and child removes itself from mChildrenX + } + foreach (QCPItemPosition *child, mChildrenY.toList()) + { + if (child->parentAnchorY() == this) + child->setParentAnchorY(0); // this acts back on this anchor and child removes itself from mChildrenY + } + // unregister as child in parent: + if (mParentAnchorX) + mParentAnchorX->removeChildX(this); + if (mParentAnchorY) + mParentAnchorY->removeChildY(this); +} + +/* can't make this a header inline function, because QPointer breaks with forward declared types, see QTBUG-29588 */ +QCPAxisRect *QCPItemPosition::axisRect() const +{ + return mAxisRect.data(); +} + +/*! + Sets the type of the position. The type defines how the coordinates passed to \ref setCoords + should be handled and how the QCPItemPosition should behave in the plot. + + The possible values for \a type can be separated in two main categories: + + \li The position is regarded as a point in plot coordinates. This corresponds to \ref ptPlotCoords + and requires two axes that define the plot coordinate system. They can be specified with \ref setAxes. + By default, the QCustomPlot's x- and yAxis are used. + + \li The position is fixed on the QCustomPlot surface, i.e. independent of axis ranges. This + corresponds to all other types, i.e. \ref ptAbsolute, \ref ptViewportRatio and \ref + ptAxisRectRatio. They differ only in the way the absolute position is described, see the + documentation of \ref PositionType for details. For \ref ptAxisRectRatio, note that you can specify + the axis rect with \ref setAxisRect. By default this is set to the main axis rect. + + Note that the position type \ref ptPlotCoords is only available (and sensible) when the position + has no parent anchor (\ref setParentAnchor). + + If the type is changed, the apparent pixel position on the plot is preserved. This means + the coordinates as retrieved with coords() and set with \ref setCoords may change in the process. + + This method sets the type for both X and Y directions. It is also possible to set different types + for X and Y, see \ref setTypeX, \ref setTypeY. +*/ +void QCPItemPosition::setType(QCPItemPosition::PositionType type) +{ + setTypeX(type); + setTypeY(type); +} + +/*! + This method sets the position type of the X coordinate to \a type. + + For a detailed description of what a position type is, see the documentation of \ref setType. + + \see setType, setTypeY +*/ +void QCPItemPosition::setTypeX(QCPItemPosition::PositionType type) +{ + if (mPositionTypeX != type) + { + // if switching from or to coordinate type that isn't valid (e.g. because axes or axis rect + // were deleted), don't try to recover the pixelPoint() because it would output a qDebug warning. + bool retainPixelPosition = true; + if ((mPositionTypeX == ptPlotCoords || type == ptPlotCoords) && (!mKeyAxis || !mValueAxis)) + retainPixelPosition = false; + if ((mPositionTypeX == ptAxisRectRatio || type == ptAxisRectRatio) && (!mAxisRect)) + retainPixelPosition = false; + + QPointF pixel; + if (retainPixelPosition) + pixel = pixelPoint(); + + mPositionTypeX = type; + + if (retainPixelPosition) + setPixelPoint(pixel); + } +} + +/*! + This method sets the position type of the Y coordinate to \a type. + + For a detailed description of what a position type is, see the documentation of \ref setType. + + \see setType, setTypeX +*/ +void QCPItemPosition::setTypeY(QCPItemPosition::PositionType type) +{ + if (mPositionTypeY != type) + { + // if switching from or to coordinate type that isn't valid (e.g. because axes or axis rect + // were deleted), don't try to recover the pixelPoint() because it would output a qDebug warning. + bool retainPixelPosition = true; + if ((mPositionTypeY == ptPlotCoords || type == ptPlotCoords) && (!mKeyAxis || !mValueAxis)) + retainPixelPosition = false; + if ((mPositionTypeY == ptAxisRectRatio || type == ptAxisRectRatio) && (!mAxisRect)) + retainPixelPosition = false; + + QPointF pixel; + if (retainPixelPosition) + pixel = pixelPoint(); + + mPositionTypeY = type; + + if (retainPixelPosition) + setPixelPoint(pixel); + } +} + +/*! + Sets the parent of this QCPItemPosition to \a parentAnchor. This means the position will now + follow any position changes of the anchor. The local coordinate system of positions with a parent + anchor always is absolute pixels, with (0, 0) being exactly on top of the parent anchor. (Hence + the type shouldn't be set to \ref ptPlotCoords for positions with parent anchors.) + + if \a keepPixelPosition is true, the current pixel position of the QCPItemPosition is preserved + during reparenting. If it's set to false, the coordinates are set to (0, 0), i.e. the position + will be exactly on top of the parent anchor. + + To remove this QCPItemPosition from any parent anchor, set \a parentAnchor to 0. + + If the QCPItemPosition previously had no parent and the type is \ref ptPlotCoords, the type is + set to \ref ptAbsolute, to keep the position in a valid state. + + This method sets the parent anchor for both X and Y directions. It is also possible to set + different parents for X and Y, see \ref setParentAnchorX, \ref setParentAnchorY. +*/ +bool QCPItemPosition::setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition) +{ + bool successX = setParentAnchorX(parentAnchor, keepPixelPosition); + bool successY = setParentAnchorY(parentAnchor, keepPixelPosition); + return successX && successY; +} + +/*! + This method sets the parent anchor of the X coordinate to \a parentAnchor. + + For a detailed description of what a parent anchor is, see the documentation of \ref setParentAnchor. + + \see setParentAnchor, setParentAnchorY +*/ +bool QCPItemPosition::setParentAnchorX(QCPItemAnchor *parentAnchor, bool keepPixelPosition) +{ + // make sure self is not assigned as parent: + if (parentAnchor == this) + { + qDebug() << Q_FUNC_INFO << "can't set self as parent anchor" << reinterpret_cast(parentAnchor); + return false; + } + // make sure no recursive parent-child-relationships are created: + QCPItemAnchor *currentParent = parentAnchor; + while (currentParent) + { + if (QCPItemPosition *currentParentPos = currentParent->toQCPItemPosition()) + { + // is a QCPItemPosition, might have further parent, so keep iterating + if (currentParentPos == this) + { + qDebug() << Q_FUNC_INFO << "can't create recursive parent-child-relationship" << reinterpret_cast(parentAnchor); + return false; + } + currentParent = currentParentPos->parentAnchorX(); + } else + { + // is a QCPItemAnchor, can't have further parent. Now make sure the parent items aren't the + // same, to prevent a position being child of an anchor which itself depends on the position, + // because they're both on the same item: + if (currentParent->mParentItem == mParentItem) + { + qDebug() << Q_FUNC_INFO << "can't set parent to be an anchor which itself depends on this position" << reinterpret_cast(parentAnchor); + return false; + } + break; + } + } + + // if previously no parent set and PosType is still ptPlotCoords, set to ptAbsolute: + if (!mParentAnchorX && mPositionTypeX == ptPlotCoords) + setTypeX(ptAbsolute); + + // save pixel position: + QPointF pixelP; + if (keepPixelPosition) + pixelP = pixelPoint(); + // unregister at current parent anchor: + if (mParentAnchorX) + mParentAnchorX->removeChildX(this); + // register at new parent anchor: + if (parentAnchor) + parentAnchor->addChildX(this); + mParentAnchorX = parentAnchor; + // restore pixel position under new parent: + if (keepPixelPosition) + setPixelPoint(pixelP); + else + setCoords(0, coords().y()); + return true; +} + +/*! + This method sets the parent anchor of the Y coordinate to \a parentAnchor. + + For a detailed description of what a parent anchor is, see the documentation of \ref setParentAnchor. + + \see setParentAnchor, setParentAnchorX +*/ +bool QCPItemPosition::setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition) +{ + // make sure self is not assigned as parent: + if (parentAnchor == this) + { + qDebug() << Q_FUNC_INFO << "can't set self as parent anchor" << reinterpret_cast(parentAnchor); + return false; + } + // make sure no recursive parent-child-relationships are created: + QCPItemAnchor *currentParent = parentAnchor; + while (currentParent) + { + if (QCPItemPosition *currentParentPos = currentParent->toQCPItemPosition()) + { + // is a QCPItemPosition, might have further parent, so keep iterating + if (currentParentPos == this) + { + qDebug() << Q_FUNC_INFO << "can't create recursive parent-child-relationship" << reinterpret_cast(parentAnchor); + return false; + } + currentParent = currentParentPos->parentAnchorY(); + } else + { + // is a QCPItemAnchor, can't have further parent. Now make sure the parent items aren't the + // same, to prevent a position being child of an anchor which itself depends on the position, + // because they're both on the same item: + if (currentParent->mParentItem == mParentItem) + { + qDebug() << Q_FUNC_INFO << "can't set parent to be an anchor which itself depends on this position" << reinterpret_cast(parentAnchor); + return false; + } + break; + } + } + + // if previously no parent set and PosType is still ptPlotCoords, set to ptAbsolute: + if (!mParentAnchorY && mPositionTypeY == ptPlotCoords) + setTypeY(ptAbsolute); + + // save pixel position: + QPointF pixelP; + if (keepPixelPosition) + pixelP = pixelPoint(); + // unregister at current parent anchor: + if (mParentAnchorY) + mParentAnchorY->removeChildY(this); + // register at new parent anchor: + if (parentAnchor) + parentAnchor->addChildY(this); + mParentAnchorY = parentAnchor; + // restore pixel position under new parent: + if (keepPixelPosition) + setPixelPoint(pixelP); + else + setCoords(coords().x(), 0); + return true; +} + +/*! + Sets the coordinates of this QCPItemPosition. What the coordinates mean, is defined by the type + (\ref setType, \ref setTypeX, \ref setTypeY). + + For example, if the type is \ref ptAbsolute, \a key and \a value mean the x and y pixel position + on the QCustomPlot surface. In that case the origin (0, 0) is in the top left corner of the + QCustomPlot viewport. If the type is \ref ptPlotCoords, \a key and \a value mean a point in the + plot coordinate system defined by the axes set by \ref setAxes. By default those are the + QCustomPlot's xAxis and yAxis. See the documentation of \ref setType for other available + coordinate types and their meaning. + + If different types were configured for X and Y (\ref setTypeX, \ref setTypeY), \a key and \a + value must also be provided in the different coordinate systems. Here, the X type refers to \a + key, and the Y type refers to \a value. + + \see setPixelPoint +*/ +void QCPItemPosition::setCoords(double key, double value) +{ + mKey = key; + mValue = value; +} + +/*! \overload + + Sets the coordinates as a QPointF \a pos where pos.x has the meaning of \a key and pos.y the + meaning of \a value of the \ref setCoords(double key, double value) method. +*/ +void QCPItemPosition::setCoords(const QPointF &pos) +{ + setCoords(pos.x(), pos.y()); +} + +/*! + Returns the final absolute pixel position of the QCPItemPosition on the QCustomPlot surface. It + includes all effects of type (\ref setType) and possible parent anchors (\ref setParentAnchor). + + \see setPixelPoint +*/ +QPointF QCPItemPosition::pixelPoint() const +{ + QPointF result; + + // determine X: + switch (mPositionTypeX) + { + case ptAbsolute: + { + result.rx() = mKey; + if (mParentAnchorX) + result.rx() += mParentAnchorX->pixelPoint().x(); + break; + } + case ptViewportRatio: + { + result.rx() = mKey*mParentPlot->viewport().width(); + if (mParentAnchorX) + result.rx() += mParentAnchorX->pixelPoint().x(); + else + result.rx() += mParentPlot->viewport().left(); + break; + } + case ptAxisRectRatio: + { + if (mAxisRect) + { + result.rx() = mKey*mAxisRect.data()->width(); + if (mParentAnchorX) + result.rx() += mParentAnchorX->pixelPoint().x(); + else + result.rx() += mAxisRect.data()->left(); + } else + qDebug() << Q_FUNC_INFO << "Item position type x is ptAxisRectRatio, but no axis rect was defined"; + break; + } + case ptPlotCoords: + { + if (mKeyAxis && mKeyAxis.data()->orientation() == Qt::Horizontal) + result.rx() = mKeyAxis.data()->coordToPixel(mKey); + else if (mValueAxis && mValueAxis.data()->orientation() == Qt::Horizontal) + result.rx() = mValueAxis.data()->coordToPixel(mValue); + else + qDebug() << Q_FUNC_INFO << "Item position type x is ptPlotCoords, but no axes were defined"; + break; + } + } + + // determine Y: + switch (mPositionTypeY) + { + case ptAbsolute: + { + result.ry() = mValue; + if (mParentAnchorY) + result.ry() += mParentAnchorY->pixelPoint().y(); + break; + } + case ptViewportRatio: + { + result.ry() = mValue*mParentPlot->viewport().height(); + if (mParentAnchorY) + result.ry() += mParentAnchorY->pixelPoint().y(); + else + result.ry() += mParentPlot->viewport().top(); + break; + } + case ptAxisRectRatio: + { + if (mAxisRect) + { + result.ry() = mValue*mAxisRect.data()->height(); + if (mParentAnchorY) + result.ry() += mParentAnchorY->pixelPoint().y(); + else + result.ry() += mAxisRect.data()->top(); + } else + qDebug() << Q_FUNC_INFO << "Item position type y is ptAxisRectRatio, but no axis rect was defined"; + break; + } + case ptPlotCoords: + { + if (mKeyAxis && mKeyAxis.data()->orientation() == Qt::Vertical) + result.ry() = mKeyAxis.data()->coordToPixel(mKey); + else if (mValueAxis && mValueAxis.data()->orientation() == Qt::Vertical) + result.ry() = mValueAxis.data()->coordToPixel(mValue); + else + qDebug() << Q_FUNC_INFO << "Item position type y is ptPlotCoords, but no axes were defined"; + break; + } + } + + return result; +} + +/*! + When \ref setType is \ref ptPlotCoords, this function may be used to specify the axes the + coordinates set with \ref setCoords relate to. By default they are set to the initial xAxis and + yAxis of the QCustomPlot. +*/ +void QCPItemPosition::setAxes(QCPAxis *keyAxis, QCPAxis *valueAxis) +{ + mKeyAxis = keyAxis; + mValueAxis = valueAxis; +} + +/*! + When \ref setType is \ref ptAxisRectRatio, this function may be used to specify the axis rect the + coordinates set with \ref setCoords relate to. By default this is set to the main axis rect of + the QCustomPlot. +*/ +void QCPItemPosition::setAxisRect(QCPAxisRect *axisRect) +{ + mAxisRect = axisRect; +} + +/*! + Sets the apparent pixel position. This works no matter what type (\ref setType) this + QCPItemPosition is or what parent-child situation it is in, as coordinates are transformed + appropriately, to make the position finally appear at the specified pixel values. + + Only if the type is \ref ptAbsolute and no parent anchor is set, this function's effect is + identical to that of \ref setCoords. + + \see pixelPoint, setCoords +*/ +void QCPItemPosition::setPixelPoint(const QPointF &pixelPoint) +{ + double x = pixelPoint.x(); + double y = pixelPoint.y(); + + switch (mPositionTypeX) + { + case ptAbsolute: + { + if (mParentAnchorX) + x -= mParentAnchorX->pixelPoint().x(); + break; + } + case ptViewportRatio: + { + if (mParentAnchorX) + x -= mParentAnchorX->pixelPoint().x(); + else + x -= mParentPlot->viewport().left(); + x /= (double)mParentPlot->viewport().width(); + break; + } + case ptAxisRectRatio: + { + if (mAxisRect) + { + if (mParentAnchorX) + x -= mParentAnchorX->pixelPoint().x(); + else + x -= mAxisRect.data()->left(); + x /= (double)mAxisRect.data()->width(); + } else + qDebug() << Q_FUNC_INFO << "Item position type x is ptAxisRectRatio, but no axis rect was defined"; + break; + } + case ptPlotCoords: + { + if (mKeyAxis && mKeyAxis.data()->orientation() == Qt::Horizontal) + x = mKeyAxis.data()->pixelToCoord(x); + else if (mValueAxis && mValueAxis.data()->orientation() == Qt::Horizontal) + y = mValueAxis.data()->pixelToCoord(x); + else + qDebug() << Q_FUNC_INFO << "Item position type x is ptPlotCoords, but no axes were defined"; + break; + } + } + + switch (mPositionTypeY) + { + case ptAbsolute: + { + if (mParentAnchorY) + y -= mParentAnchorY->pixelPoint().y(); + break; + } + case ptViewportRatio: + { + if (mParentAnchorY) + y -= mParentAnchorY->pixelPoint().y(); + else + y -= mParentPlot->viewport().top(); + y /= (double)mParentPlot->viewport().height(); + break; + } + case ptAxisRectRatio: + { + if (mAxisRect) + { + if (mParentAnchorY) + y -= mParentAnchorY->pixelPoint().y(); + else + y -= mAxisRect.data()->top(); + y /= (double)mAxisRect.data()->height(); + } else + qDebug() << Q_FUNC_INFO << "Item position type y is ptAxisRectRatio, but no axis rect was defined"; + break; + } + case ptPlotCoords: + { + if (mKeyAxis && mKeyAxis.data()->orientation() == Qt::Vertical) + x = mKeyAxis.data()->pixelToCoord(y); + else if (mValueAxis && mValueAxis.data()->orientation() == Qt::Vertical) + y = mValueAxis.data()->pixelToCoord(y); + else + qDebug() << Q_FUNC_INFO << "Item position type y is ptPlotCoords, but no axes were defined"; + break; + } + } + + setCoords(x, y); +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPAbstractItem +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPAbstractItem + \brief The abstract base class for all items in a plot. + + In QCustomPlot, items are supplemental graphical elements that are neither plottables + (QCPAbstractPlottable) nor axes (QCPAxis). While plottables are always tied to two axes and thus + plot coordinates, items can also be placed in absolute coordinates independent of any axes. Each + specific item has at least one QCPItemPosition member which controls the positioning. Some items + are defined by more than one coordinate and thus have two or more QCPItemPosition members (For + example, QCPItemRect has \a topLeft and \a bottomRight). + + This abstract base class defines a very basic interface like visibility and clipping. Since this + class is abstract, it can't be instantiated. Use one of the subclasses or create a subclass + yourself to create new items. + + The built-in items are: + + + + + + + + + + +
QCPItemLineA line defined by a start and an end point. May have different ending styles on each side (e.g. arrows).
QCPItemStraightLineA straight line defined by a start and a direction point. Unlike QCPItemLine, the straight line is infinitely long and has no endings.
QCPItemCurveA curve defined by start, end and two intermediate control points. May have different ending styles on each side (e.g. arrows).
QCPItemRectA rectangle
QCPItemEllipseAn ellipse
QCPItemPixmapAn arbitrary pixmap
QCPItemTextA text label
QCPItemBracketA bracket which may be used to reference/highlight certain parts in the plot.
QCPItemTracerAn item that can be attached to a QCPGraph and sticks to its data points, given a key coordinate.
+ + \section items-clipping Clipping + + Items are by default clipped to the main axis rect (they are only visible inside the axis rect). + To make an item visible outside that axis rect, disable clipping via \ref setClipToAxisRect + "setClipToAxisRect(false)". + + On the other hand if you want the item to be clipped to a different axis rect, specify it via + \ref setClipAxisRect. This clipAxisRect property of an item is only used for clipping behaviour, and + in principle is independent of the coordinate axes the item might be tied to via its position + members (\ref QCPItemPosition::setAxes). However, it is common that the axis rect for clipping + also contains the axes used for the item positions. + + \section items-using Using items + + First you instantiate the item you want to use and add it to the plot: + \code + QCPItemLine *line = new QCPItemLine(customPlot); + customPlot->addItem(line); + \endcode + by default, the positions of the item are bound to the x- and y-Axis of the plot. So we can just + set the plot coordinates where the line should start/end: + \code + line->start->setCoords(-0.1, 0.8); + line->end->setCoords(1.1, 0.2); + \endcode + If we don't want the line to be positioned in plot coordinates but a different coordinate system, + e.g. absolute pixel positions on the QCustomPlot surface, we need to change the position type like this: + \code + line->start->setType(QCPItemPosition::ptAbsolute); + line->end->setType(QCPItemPosition::ptAbsolute); + \endcode + Then we can set the coordinates, this time in pixels: + \code + line->start->setCoords(100, 200); + line->end->setCoords(450, 320); + \endcode + and make the line visible on the entire QCustomPlot, by disabling clipping to the axis rect: + \code + line->setClipToAxisRect(false); + \endcode + + For more advanced plots, it is even possible to set different types and parent anchors per X/Y + coordinate of an item position, using for example \ref QCPItemPosition::setTypeX or \ref + QCPItemPosition::setParentAnchorX. For details, see the documentation of \ref QCPItemPosition. + + \section items-subclassing Creating own items + + To create an own item, you implement a subclass of QCPAbstractItem. These are the pure + virtual functions, you must implement: + \li \ref selectTest + \li \ref draw + + See the documentation of those functions for what they need to do. + + \subsection items-positioning Allowing the item to be positioned + + As mentioned, item positions are represented by QCPItemPosition members. Let's assume the new item shall + have only one point as its position (as opposed to two like a rect or multiple like a polygon). You then add + a public member of type QCPItemPosition like so: + + \code QCPItemPosition * const myPosition;\endcode + + the const makes sure the pointer itself can't be modified from the user of your new item (the QCPItemPosition + instance it points to, can be modified, of course). + The initialization of this pointer is made easy with the \ref createPosition function. Just assign + the return value of this function to each QCPItemPosition in the constructor of your item. \ref createPosition + takes a string which is the name of the position, typically this is identical to the variable name. + For example, the constructor of QCPItemExample could look like this: + + \code + QCPItemExample::QCPItemExample(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + myPosition(createPosition("myPosition")) + { + // other constructor code + } + \endcode + + \subsection items-drawing The draw function + + To give your item a visual representation, reimplement the \ref draw function and use the passed + QCPPainter to draw the item. You can retrieve the item position in pixel coordinates from the + position member(s) via \ref QCPItemPosition::pixelPoint. + + To optimize performance you should calculate a bounding rect first (don't forget to take the pen + width into account), check whether it intersects the \ref clipRect, and only draw the item at all + if this is the case. + + \subsection items-selection The selectTest function + + Your implementation of the \ref selectTest function may use the helpers \ref distSqrToLine and + \ref rectSelectTest. With these, the implementation of the selection test becomes significantly + simpler for most items. See the documentation of \ref selectTest for what the function parameters + mean and what the function should return. + + \subsection anchors Providing anchors + + Providing anchors (QCPItemAnchor) starts off like adding a position. First you create a public + member, e.g. + + \code QCPItemAnchor * const bottom;\endcode + + and create it in the constructor with the \ref createAnchor function, assigning it a name and an + anchor id (an integer enumerating all anchors on the item, you may create an own enum for this). + Since anchors can be placed anywhere, relative to the item's position(s), your item needs to + provide the position of every anchor with the reimplementation of the \ref anchorPixelPoint(int + anchorId) function. + + In essence the QCPItemAnchor is merely an intermediary that itself asks your item for the pixel + position when anything attached to the anchor needs to know the coordinates. +*/ + +/* start of documentation of inline functions */ + +/*! \fn QList QCPAbstractItem::positions() const + + Returns all positions of the item in a list. + + \see anchors, position +*/ + +/*! \fn QList QCPAbstractItem::anchors() const + + Returns all anchors of the item in a list. Note that since a position (QCPItemPosition) is always + also an anchor, the list will also contain the positions of this item. + + \see positions, anchor +*/ + +/* end of documentation of inline functions */ +/* start documentation of pure virtual functions */ + +/*! \fn void QCPAbstractItem::draw(QCPPainter *painter) = 0 + \internal + + Draws this item with the provided \a painter. + + The cliprect of the provided painter is set to the rect returned by \ref clipRect before this + function is called. The clipRect depends on the clipping settings defined by \ref + setClipToAxisRect and \ref setClipAxisRect. +*/ + +/* end documentation of pure virtual functions */ +/* start documentation of signals */ + +/*! \fn void QCPAbstractItem::selectionChanged(bool selected) + This signal is emitted when the selection state of this item has changed, either by user interaction + or by a direct call to \ref setSelected. +*/ + +/* end documentation of signals */ + +/*! + Base class constructor which initializes base class members. +*/ +QCPAbstractItem::QCPAbstractItem(QCustomPlot *parentPlot) : + QCPLayerable(parentPlot), + mClipToAxisRect(false), + mSelectable(true), + mSelected(false) +{ + QList rects = parentPlot->axisRects(); + if (rects.size() > 0) + { + setClipToAxisRect(true); + setClipAxisRect(rects.first()); + } +} + +QCPAbstractItem::~QCPAbstractItem() +{ + // don't delete mPositions because every position is also an anchor and thus in mAnchors + qDeleteAll(mAnchors); +} + +/* can't make this a header inline function, because QPointer breaks with forward declared types, see QTBUG-29588 */ +QCPAxisRect *QCPAbstractItem::clipAxisRect() const +{ + return mClipAxisRect.data(); +} + +/*! + Sets whether the item shall be clipped to an axis rect or whether it shall be visible on the + entire QCustomPlot. The axis rect can be set with \ref setClipAxisRect. + + \see setClipAxisRect +*/ +void QCPAbstractItem::setClipToAxisRect(bool clip) +{ + mClipToAxisRect = clip; + if (mClipToAxisRect) + setParentLayerable(mClipAxisRect.data()); +} + +/*! + Sets the clip axis rect. It defines the rect that will be used to clip the item when \ref + setClipToAxisRect is set to true. + + \see setClipToAxisRect +*/ +void QCPAbstractItem::setClipAxisRect(QCPAxisRect *rect) +{ + mClipAxisRect = rect; + if (mClipToAxisRect) + setParentLayerable(mClipAxisRect.data()); +} + +/*! + Sets whether the user can (de-)select this item by clicking on the QCustomPlot surface. + (When \ref QCustomPlot::setInteractions contains QCustomPlot::iSelectItems.) + + However, even when \a selectable was set to false, it is possible to set the selection manually, + by calling \ref setSelected. + + \see QCustomPlot::setInteractions, setSelected +*/ +void QCPAbstractItem::setSelectable(bool selectable) +{ + if (mSelectable != selectable) + { + mSelectable = selectable; + emit selectableChanged(mSelectable); + } +} + +/*! + Sets whether this item is selected or not. When selected, it might use a different visual + appearance (e.g. pen and brush), this depends on the specific item though. + + The entire selection mechanism for items is handled automatically when \ref + QCustomPlot::setInteractions contains QCustomPlot::iSelectItems. You only need to call this + function when you wish to change the selection state manually. + + This function can change the selection state even when \ref setSelectable was set to false. + + emits the \ref selectionChanged signal when \a selected is different from the previous selection state. + + \see setSelectable, selectTest +*/ +void QCPAbstractItem::setSelected(bool selected) +{ + if (mSelected != selected) + { + mSelected = selected; + emit selectionChanged(mSelected); + } +} + +/*! + Returns the QCPItemPosition with the specified \a name. If this item doesn't have a position by + that name, returns 0. + + This function provides an alternative way to access item positions. Normally, you access + positions direcly by their member pointers (which typically have the same variable name as \a + name). + + \see positions, anchor +*/ +QCPItemPosition *QCPAbstractItem::position(const QString &name) const +{ + for (int i=0; iname() == name) + return mPositions.at(i); + } + qDebug() << Q_FUNC_INFO << "position with name not found:" << name; + return 0; +} + +/*! + Returns the QCPItemAnchor with the specified \a name. If this item doesn't have an anchor by + that name, returns 0. + + This function provides an alternative way to access item anchors. Normally, you access + anchors direcly by their member pointers (which typically have the same variable name as \a + name). + + \see anchors, position +*/ +QCPItemAnchor *QCPAbstractItem::anchor(const QString &name) const +{ + for (int i=0; iname() == name) + return mAnchors.at(i); + } + qDebug() << Q_FUNC_INFO << "anchor with name not found:" << name; + return 0; +} + +/*! + Returns whether this item has an anchor with the specified \a name. + + Note that you can check for positions with this function, too. This is because every position is + also an anchor (QCPItemPosition inherits from QCPItemAnchor). + + \see anchor, position +*/ +bool QCPAbstractItem::hasAnchor(const QString &name) const +{ + for (int i=0; iname() == name) + return true; + } + return false; +} + +/*! \internal + + Returns the rect the visual representation of this item is clipped to. This depends on the + current setting of \ref setClipToAxisRect as well as the axis rect set with \ref setClipAxisRect. + + If the item is not clipped to an axis rect, the \ref QCustomPlot::viewport rect is returned. + + \see draw +*/ +QRect QCPAbstractItem::clipRect() const +{ + if (mClipToAxisRect && mClipAxisRect) + return mClipAxisRect.data()->rect(); + else + return mParentPlot->viewport(); +} + +/*! \internal + + A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter + before drawing item lines. + + This is the antialiasing state the painter passed to the \ref draw method is in by default. + + This function takes into account the local setting of the antialiasing flag as well as the + overrides set with \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. + + \see setAntialiased +*/ +void QCPAbstractItem::applyDefaultAntialiasingHint(QCPPainter *painter) const +{ + applyAntialiasingHint(painter, mAntialiased, QCP::aeItems); +} + +/*! \internal + + Finds the shortest squared distance of \a point to the line segment defined by \a start and \a + end. + + This function may be used to help with the implementation of the \ref selectTest function for + specific items. + + \note This function is identical to QCPAbstractPlottable::distSqrToLine + + \see rectSelectTest +*/ +double QCPAbstractItem::distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const +{ + QVector2D a(start); + QVector2D b(end); + QVector2D p(point); + QVector2D v(b-a); + + double vLengthSqr = v.lengthSquared(); + if (!qFuzzyIsNull(vLengthSqr)) + { + double mu = QVector2D::dotProduct(p-a, v)/vLengthSqr; + if (mu < 0) + return (a-p).lengthSquared(); + else if (mu > 1) + return (b-p).lengthSquared(); + else + return ((a + mu*v)-p).lengthSquared(); + } else + return (a-p).lengthSquared(); +} + +/*! \internal + + A convenience function which returns the selectTest value for a specified \a rect and a specified + click position \a pos. \a filledRect defines whether a click inside the rect should also be + considered a hit or whether only the rect border is sensitive to hits. + + This function may be used to help with the implementation of the \ref selectTest function for + specific items. + + For example, if your item consists of four rects, call this function four times, once for each + rect, in your \ref selectTest reimplementation. Finally, return the minimum of all four returned + values which were greater or equal to zero. (Because this function may return -1.0 when \a pos + doesn't hit \a rect at all). If all calls returned -1.0, return -1.0, too, because your item + wasn't hit. + + \see distSqrToLine +*/ +double QCPAbstractItem::rectSelectTest(const QRectF &rect, const QPointF &pos, bool filledRect) const +{ + double result = -1; + + // distance to border: + QList lines; + lines << QLineF(rect.topLeft(), rect.topRight()) << QLineF(rect.bottomLeft(), rect.bottomRight()) + << QLineF(rect.topLeft(), rect.bottomLeft()) << QLineF(rect.topRight(), rect.bottomRight()); + double minDistSqr = std::numeric_limits::max(); + for (int i=0; i mParentPlot->selectionTolerance()*0.99) + { + if (rect.contains(pos)) + result = mParentPlot->selectionTolerance()*0.99; + } + return result; +} + +/*! \internal + + Returns the pixel position of the anchor with Id \a anchorId. This function must be reimplemented in + item subclasses if they want to provide anchors (QCPItemAnchor). + + For example, if the item has two anchors with id 0 and 1, this function takes one of these anchor + ids and returns the respective pixel points of the specified anchor. + + \see createAnchor +*/ +QPointF QCPAbstractItem::anchorPixelPoint(int anchorId) const +{ + qDebug() << Q_FUNC_INFO << "called on item which shouldn't have any anchors (this method not reimplemented). anchorId" << anchorId; + return QPointF(); +} + +/*! \internal + + Creates a QCPItemPosition, registers it with this item and returns a pointer to it. The specified + \a name must be a unique string that is usually identical to the variable name of the position + member (This is needed to provide the name-based \ref position access to positions). + + Don't delete positions created by this function manually, as the item will take care of it. + + Use this function in the constructor (initialization list) of the specific item subclass to + create each position member. Don't create QCPItemPositions with \b new yourself, because they + won't be registered with the item properly. + + \see createAnchor +*/ +QCPItemPosition *QCPAbstractItem::createPosition(const QString &name) +{ + if (hasAnchor(name)) + qDebug() << Q_FUNC_INFO << "anchor/position with name exists already:" << name; + QCPItemPosition *newPosition = new QCPItemPosition(mParentPlot, this, name); + mPositions.append(newPosition); + mAnchors.append(newPosition); // every position is also an anchor + newPosition->setAxes(mParentPlot->xAxis, mParentPlot->yAxis); + newPosition->setType(QCPItemPosition::ptPlotCoords); + if (mParentPlot->axisRect()) + newPosition->setAxisRect(mParentPlot->axisRect()); + newPosition->setCoords(0, 0); + return newPosition; +} + +/*! \internal + + Creates a QCPItemAnchor, registers it with this item and returns a pointer to it. The specified + \a name must be a unique string that is usually identical to the variable name of the anchor + member (This is needed to provide the name based \ref anchor access to anchors). + + The \a anchorId must be a number identifying the created anchor. It is recommended to create an + enum (e.g. "AnchorIndex") for this on each item that uses anchors. This id is used by the anchor + to identify itself when it calls QCPAbstractItem::anchorPixelPoint. That function then returns + the correct pixel coordinates for the passed anchor id. + + Don't delete anchors created by this function manually, as the item will take care of it. + + Use this function in the constructor (initialization list) of the specific item subclass to + create each anchor member. Don't create QCPItemAnchors with \b new yourself, because then they + won't be registered with the item properly. + + \see createPosition +*/ +QCPItemAnchor *QCPAbstractItem::createAnchor(const QString &name, int anchorId) +{ + if (hasAnchor(name)) + qDebug() << Q_FUNC_INFO << "anchor/position with name exists already:" << name; + QCPItemAnchor *newAnchor = new QCPItemAnchor(mParentPlot, this, name, anchorId); + mAnchors.append(newAnchor); + return newAnchor; +} + +/* inherits documentation from base class */ +void QCPAbstractItem::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) +{ + Q_UNUSED(event) + Q_UNUSED(details) + if (mSelectable) + { + bool selBefore = mSelected; + setSelected(additive ? !mSelected : true); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; + } +} + +/* inherits documentation from base class */ +void QCPAbstractItem::deselectEvent(bool *selectionStateChanged) +{ + if (mSelectable) + { + bool selBefore = mSelected; + setSelected(false); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; + } +} + +/* inherits documentation from base class */ +QCP::Interaction QCPAbstractItem::selectionCategory() const +{ + return QCP::iSelectItems; +} + + +/*! \file */ + + + +/*! \mainpage %QCustomPlot 1.3.0-beta Documentation + + \image html qcp-doc-logo.png + + Below is a brief overview of and guide to the classes and their relations. If you are new to + QCustomPlot and just want to start using it, it's recommended to look at the tutorials and + examples at + + http://www.qcustomplot.com/ + + This documentation is especially helpful as a reference, when you're familiar with the basic + concept of how to use %QCustomPlot and you wish to learn more about specific functionality. + See the \ref classoverview "class overview" for diagrams explaining the relationships between + the most important classes of the QCustomPlot library. + + The central widget which displays the plottables and axes on its surface is QCustomPlot. Every + QCustomPlot contains four axes by default. They can be accessed via the members \ref + QCustomPlot::xAxis "xAxis", \ref QCustomPlot::yAxis "yAxis", \ref QCustomPlot::xAxis2 "xAxis2" + and \ref QCustomPlot::yAxis2 "yAxis2", and are of type QCPAxis. QCustomPlot supports an arbitrary + number of axes and axis rects, see the documentation of QCPAxisRect for details. + + \section mainpage-plottables Plottables + + \a Plottables are classes that display any kind of data inside the QCustomPlot. They all derive + from QCPAbstractPlottable. For example, the QCPGraph class is a plottable that displays a graph + inside the plot with different line styles, scatter styles, filling etc. + + Since plotting graphs is such a dominant use case, QCustomPlot has a special interface for working + with QCPGraph plottables, that makes it very easy to handle them:\n + You create a new graph with QCustomPlot::addGraph and access them with QCustomPlot::graph. + + For all other plottables, you need to use the normal plottable interface:\n + First, you create an instance of the plottable you want, e.g. + \code + QCPCurve *newCurve = new QCPCurve(customPlot->xAxis, customPlot->yAxis);\endcode + add it to the customPlot: + \code + customPlot->addPlottable(newCurve);\endcode + and then modify the properties of the newly created plottable via the newCurve pointer. + + Plottables (including graphs) can be retrieved via QCustomPlot::plottable. Since the return type + of that function is the abstract base class of all plottables, QCPAbstractPlottable, you will + probably want to qobject_cast the returned pointer to the respective plottable subclass. (As + usual, if the cast returns zero, the plottable wasn't of that specific subclass.) + + All further interfacing with plottables (e.g how to set data) is specific to the plottable type. + See the documentations of the subclasses: QCPGraph, QCPCurve, QCPBars, QCPStatisticalBox, + QCPColorMap, QCPFinancial. + + \section mainpage-axes Controlling the Axes + + As mentioned, QCustomPlot has four axes by default: \a xAxis (bottom), \a yAxis (left), \a xAxis2 + (top), \a yAxis2 (right). + + Their range is handled by the simple QCPRange class. You can set the range with the + QCPAxis::setRange function. By default, the axes represent a linear scale. To set a logarithmic + scale, set \ref QCPAxis::setScaleType to \ref QCPAxis::stLogarithmic. The logarithm base can be set freely + with \ref QCPAxis::setScaleLogBase. + + By default, an axis automatically creates and labels ticks in a sensible manner. See the + following functions for tick manipulation:\n QCPAxis::setTicks, QCPAxis::setAutoTicks, + QCPAxis::setAutoTickCount, QCPAxis::setAutoTickStep, QCPAxis::setTickLabels, + QCPAxis::setTickLabelType, QCPAxis::setTickLabelRotation, QCPAxis::setTickStep, + QCPAxis::setTickLength,... + + Each axis can be given an axis label (e.g. "Voltage (mV)") with QCPAxis::setLabel. + + The distance of an axis backbone to the respective viewport border is called its margin. + Normally, the margins are calculated automatically. To change this, set + \ref QCPAxisRect::setAutoMargins to exclude the respective margin sides, set the margins manually with + \ref QCPAxisRect::setMargins. The main axis rect can be reached with \ref QCustomPlot::axisRect(). + + \section mainpage-legend Plot Legend + + Every QCustomPlot has one QCPLegend (as \ref QCustomPlot::legend) by default. A legend is a small + layout element inside the plot which lists the plottables with an icon of the plottable + line/symbol and a name (QCPAbstractPlottable::setName). Plottables can be added and removed from + the main legend via \ref QCPAbstractPlottable::addToLegend and \ref + QCPAbstractPlottable::removeFromLegend. By default, adding a plottable to QCustomPlot + automatically adds it to the legend, too. This behaviour can be modified with the + QCustomPlot::setAutoAddPlottableToLegend property. + + The QCPLegend provides an interface to access, add and remove legend items directly, too. See + QCPLegend::item, QCPLegend::itemWithPlottable, QCPLegend::addItem, QCPLegend::removeItem for + example. + + Multiple legends are supported via the \link thelayoutsystem layout system\endlink (as a + QCPLegend simply is a normal layout element). + + \section mainpage-userinteraction User Interactions + + QCustomPlot supports dragging axis ranges with the mouse (\ref + QCPAxisRect::setRangeDrag), zooming axis ranges with the mouse wheel (\ref + QCPAxisRect::setRangeZoom) and a complete selection mechanism. + + The availability of these interactions is controlled with \ref QCustomPlot::setInteractions. For + details about the interaction system, see the documentation there. + + Further, QCustomPlot always emits corresponding signals, when objects are clicked or + doubleClicked. See \ref QCustomPlot::plottableClick, \ref QCustomPlot::plottableDoubleClick + and \ref QCustomPlot::axisClick for example. + + \section mainpage-items Items + + Apart from plottables there is another category of plot objects that are important: Items. The + base class of all items is QCPAbstractItem. An item sets itself apart from plottables in that + it's not necessarily bound to any axes. This means it may also be positioned in absolute pixel + coordinates or placed at a relative position on an axis rect. Further, it usually doesn't + represent data directly, but acts as decoration, emphasis, description etc. + + Multiple items can be arranged in a parent-child-hierarchy allowing for dynamical behaviour. For + example, you could place the head of an arrow at a fixed plot coordinate, so it always points to + some important area in the plot. The tail of the arrow can be anchored to a text item which + always resides in the top center of the axis rect, independent of where the user drags the axis + ranges. This way the arrow stretches and turns so it always points from the label to the + specified plot coordinate, without any further code necessary. + + For a more detailed introduction, see the QCPAbstractItem documentation, and from there the + documentations of the individual built-in items, to find out how to use them. + + \section mainpage-layoutelements Layout elements and layouts + + QCustomPlot uses an internal layout system to provide dynamic sizing and positioning of objects like + the axis rect(s), legends and the plot title. They are all based on \ref QCPLayoutElement and are arranged by + placing them inside a \ref QCPLayout. + + Details on this topic are given on the dedicated page about \link thelayoutsystem the layout system\endlink. + + \section mainpage-performancetweaks Performance Tweaks + + Although QCustomPlot is quite fast, some features like translucent fills, antialiasing and thick + lines can cause a significant slow down. If you notice this in your application, here are some + thoughts on how to increase performance. By far the most time is spent in the drawing functions, + specifically the drawing of graphs. For maximum performance, consider the following (most + recommended/effective measures first): + + \li use Qt 4.8.0 and up. Performance has doubled or tripled with respect to Qt 4.7.4. However + QPainter was broken and drawing pixel precise things, e.g. scatters, isn't possible with Qt >= + 4.8.0. So it's a performance vs. plot quality tradeoff when switching to Qt 4.8. + \li To increase responsiveness during dragging, consider setting \ref QCustomPlot::setNoAntialiasingOnDrag to true. + \li On X11 (GNU/Linux), avoid the slow native drawing system, use raster by supplying + "-graphicssystem raster" as command line argument or calling QApplication::setGraphicsSystem("raster") + before creating the QApplication object. (Only available for Qt versions before 5.0) + \li On all operating systems, use OpenGL hardware acceleration by supplying "-graphicssystem + opengl" as command line argument or calling QApplication::setGraphicsSystem("opengl") (Only + available for Qt versions before 5.0). If OpenGL is available, this will slightly decrease the + quality of antialiasing, but extremely increase performance especially with alpha + (semi-transparent) fills, much antialiasing and a large QCustomPlot drawing surface. Note + however, that the maximum frame rate might be constrained by the vertical sync frequency of your + monitor (VSync can be disabled in the graphics card driver configuration). So for simple plots + (where the potential framerate is far above 60 frames per second), OpenGL acceleration might + achieve numerically lower frame rates than the other graphics systems, because they are not + capped at the VSync frequency. + \li Avoid any kind of alpha (transparency), especially in fills + \li Avoid lines with a pen width greater than one + \li Avoid any kind of antialiasing, especially in graph lines (see \ref QCustomPlot::setNotAntialiasedElements) + \li Avoid repeatedly setting the complete data set with \ref QCPGraph::setData. Use \ref QCPGraph::addData instead, if most + data points stay unchanged, e.g. in a running measurement. + \li Set the \a copy parameter of the setData functions to false, so only pointers get + transferred. (Relevant only if preparing data maps with a large number of points, i.e. over 10000) + + \section mainpage-flags Preprocessor Define Flags + + QCustomPlot understands some preprocessor defines that are useful for debugging and compilation: +
+
\c QCUSTOMPLOT_COMPILE_LIBRARY +
Define this flag when you compile QCustomPlot as a shared library (.so/.dll) +
\c QCUSTOMPLOT_USE_LIBRARY +
Define this flag before including the header, when using QCustomPlot as a shared library +
\c QCUSTOMPLOT_CHECK_DATA +
If this flag is defined, the QCustomPlot plottables will perform data validity checks on every redraw. + This means they will give qDebug output when you plot \e inf or \e nan values, they will not + fix your data. +
+ +*/ + +/*! \page classoverview Class Overview + + The following diagrams may help to gain a deeper understanding of the relationships between classes that make up + the QCustomPlot library. The diagrams are not exhaustive, so only the classes deemed most relevant are shown. + + \section classoverview-relations Class Relationship Diagram + \image html RelationOverview.png "Overview of most important classes and their relations" + \section classoverview-inheritance Class Inheritance Tree + \image html InheritanceOverview.png "Inheritance tree of most important classes" + +*/ + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCustomPlot +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCustomPlot + + \brief The central class of the library. This is the QWidget which displays the plot and + interacts with the user. + + For tutorials on how to use QCustomPlot, see the website\n + http://www.qcustomplot.com/ +*/ + +/* start of documentation of inline functions */ + +/*! \fn QRect QCustomPlot::viewport() const + + Returns the viewport rect of this QCustomPlot instance. The viewport is the area the plot is + drawn in, all mechanisms, e.g. margin caluclation take the viewport to be the outer border of the + plot. The viewport normally is the rect() of the QCustomPlot widget, i.e. a rect with top left + (0, 0) and size of the QCustomPlot widget. + + Don't confuse the viewport with the axis rect (QCustomPlot::axisRect). An axis rect is typically + an area enclosed by four axes, where the graphs/plottables are drawn in. The viewport is larger + and contains also the axes themselves, their tick numbers, their labels, the plot title etc. + + Only when saving to a file (see \ref savePng, \ref savePdf etc.) the viewport is temporarily + modified to allow saving plots with sizes independent of the current widget size. +*/ + +/*! \fn QCPLayoutGrid *QCustomPlot::plotLayout() const + + Returns the top level layout of this QCustomPlot instance. It is a \ref QCPLayoutGrid, initially containing just + one cell with the main QCPAxisRect inside. +*/ + +/* end of documentation of inline functions */ +/* start of documentation of signals */ + +/*! \fn void QCustomPlot::mouseDoubleClick(QMouseEvent *event) + + This signal is emitted when the QCustomPlot receives a mouse double click event. +*/ + +/*! \fn void QCustomPlot::mousePress(QMouseEvent *event) + + This signal is emitted when the QCustomPlot receives a mouse press event. + + It is emitted before QCustomPlot handles any other mechanism like range dragging. So a slot + connected to this signal can still influence the behaviour e.g. with \ref QCPAxisRect::setRangeDrag or \ref + QCPAxisRect::setRangeDragAxes. +*/ + +/*! \fn void QCustomPlot::mouseMove(QMouseEvent *event) + + This signal is emitted when the QCustomPlot receives a mouse move event. + + It is emitted before QCustomPlot handles any other mechanism like range dragging. So a slot + connected to this signal can still influence the behaviour e.g. with \ref QCPAxisRect::setRangeDrag or \ref + QCPAxisRect::setRangeDragAxes. + + \warning It is discouraged to change the drag-axes with \ref QCPAxisRect::setRangeDragAxes here, + because the dragging starting point was saved the moment the mouse was pressed. Thus it only has + a meaning for the range drag axes that were set at that moment. If you want to change the drag + axes, consider doing this in the \ref mousePress signal instead. +*/ + +/*! \fn void QCustomPlot::mouseRelease(QMouseEvent *event) + + This signal is emitted when the QCustomPlot receives a mouse release event. + + It is emitted before QCustomPlot handles any other mechanisms like object selection. So a + slot connected to this signal can still influence the behaviour e.g. with \ref setInteractions or + \ref QCPAbstractPlottable::setSelectable. +*/ + +/*! \fn void QCustomPlot::mouseWheel(QMouseEvent *event) + + This signal is emitted when the QCustomPlot receives a mouse wheel event. + + It is emitted before QCustomPlot handles any other mechanisms like range zooming. So a slot + connected to this signal can still influence the behaviour e.g. with \ref QCPAxisRect::setRangeZoom, \ref + QCPAxisRect::setRangeZoomAxes or \ref QCPAxisRect::setRangeZoomFactor. +*/ + +/*! \fn void QCustomPlot::plottableClick(QCPAbstractPlottable *plottable, QMouseEvent *event) + + This signal is emitted when a plottable is clicked. + + \a event is the mouse event that caused the click and \a plottable is the plottable that received + the click. + + \see plottableDoubleClick +*/ + +/*! \fn void QCustomPlot::plottableDoubleClick(QCPAbstractPlottable *plottable, QMouseEvent *event) + + This signal is emitted when a plottable is double clicked. + + \a event is the mouse event that caused the click and \a plottable is the plottable that received + the click. + + \see plottableClick +*/ + +/*! \fn void QCustomPlot::itemClick(QCPAbstractItem *item, QMouseEvent *event) + + This signal is emitted when an item is clicked. + + \a event is the mouse event that caused the click and \a item is the item that received the + click. + + \see itemDoubleClick +*/ + +/*! \fn void QCustomPlot::itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event) + + This signal is emitted when an item is double clicked. + + \a event is the mouse event that caused the click and \a item is the item that received the + click. + + \see itemClick +*/ + +/*! \fn void QCustomPlot::axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event) + + This signal is emitted when an axis is clicked. + + \a event is the mouse event that caused the click, \a axis is the axis that received the click and + \a part indicates the part of the axis that was clicked. + + \see axisDoubleClick +*/ + +/*! \fn void QCustomPlot::axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event) + + This signal is emitted when an axis is double clicked. + + \a event is the mouse event that caused the click, \a axis is the axis that received the click and + \a part indicates the part of the axis that was clicked. + + \see axisClick +*/ + +/*! \fn void QCustomPlot::legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event) + + This signal is emitted when a legend (item) is clicked. + + \a event is the mouse event that caused the click, \a legend is the legend that received the + click and \a item is the legend item that received the click. If only the legend and no item is + clicked, \a item is 0. This happens for a click inside the legend padding or the space between + two items. + + \see legendDoubleClick +*/ + +/*! \fn void QCustomPlot::legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event) + + This signal is emitted when a legend (item) is double clicked. + + \a event is the mouse event that caused the click, \a legend is the legend that received the + click and \a item is the legend item that received the click. If only the legend and no item is + clicked, \a item is 0. This happens for a click inside the legend padding or the space between + two items. + + \see legendClick +*/ + +/*! \fn void QCustomPlot:: titleClick(QMouseEvent *event, QCPPlotTitle *title) + + This signal is emitted when a plot title is clicked. + + \a event is the mouse event that caused the click and \a title is the plot title that received + the click. + + \see titleDoubleClick +*/ + +/*! \fn void QCustomPlot::titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title) + + This signal is emitted when a plot title is double clicked. + + \a event is the mouse event that caused the click and \a title is the plot title that received + the click. + + \see titleClick +*/ + +/*! \fn void QCustomPlot::selectionChangedByUser() + + This signal is emitted after the user has changed the selection in the QCustomPlot, e.g. by + clicking. It is not emitted when the selection state of an object has changed programmatically by + a direct call to setSelected() on an object or by calling \ref deselectAll. + + In addition to this signal, selectable objects also provide individual signals, for example + QCPAxis::selectionChanged or QCPAbstractPlottable::selectionChanged. Note that those signals are + emitted even if the selection state is changed programmatically. + + See the documentation of \ref setInteractions for details about the selection mechanism. + + \see selectedPlottables, selectedGraphs, selectedItems, selectedAxes, selectedLegends +*/ + +/*! \fn void QCustomPlot::beforeReplot() + + This signal is emitted immediately before a replot takes place (caused by a call to the slot \ref + replot). + + It is safe to mutually connect the replot slot with this signal on two QCustomPlots to make them + replot synchronously, it won't cause an infinite recursion. + + \see replot, afterReplot +*/ + +/*! \fn void QCustomPlot::afterReplot() + + This signal is emitted immediately after a replot has taken place (caused by a call to the slot \ref + replot). + + It is safe to mutually connect the replot slot with this signal on two QCustomPlots to make them + replot synchronously, it won't cause an infinite recursion. + + \see replot, beforeReplot +*/ + +/* end of documentation of signals */ +/* start of documentation of public members */ + +/*! \var QCPAxis *QCustomPlot::xAxis + + A pointer to the primary x Axis (bottom) of the main axis rect of the plot. + + QCustomPlot offers convenient pointers to the axes (\ref xAxis, \ref yAxis, \ref xAxis2, \ref + yAxis2) and the \ref legend. They make it very easy working with plots that only have a single + axis rect and at most one axis at each axis rect side. If you use \link thelayoutsystem the + layout system\endlink to add multiple axis rects or multiple axes to one side, use the \ref + QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the + default legend is removed due to manipulation of the layout system (e.g. by removing the main + axis rect), the corresponding pointers become 0. +*/ + +/*! \var QCPAxis *QCustomPlot::yAxis + + A pointer to the primary y Axis (left) of the main axis rect of the plot. + + QCustomPlot offers convenient pointers to the axes (\ref xAxis, \ref yAxis, \ref xAxis2, \ref + yAxis2) and the \ref legend. They make it very easy working with plots that only have a single + axis rect and at most one axis at each axis rect side. If you use \link thelayoutsystem the + layout system\endlink to add multiple axis rects or multiple axes to one side, use the \ref + QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the + default legend is removed due to manipulation of the layout system (e.g. by removing the main + axis rect), the corresponding pointers become 0. +*/ + +/*! \var QCPAxis *QCustomPlot::xAxis2 + + A pointer to the secondary x Axis (top) of the main axis rect of the plot. Secondary axes are + invisible by default. Use QCPAxis::setVisible to change this (or use \ref + QCPAxisRect::setupFullAxesBox). + + QCustomPlot offers convenient pointers to the axes (\ref xAxis, \ref yAxis, \ref xAxis2, \ref + yAxis2) and the \ref legend. They make it very easy working with plots that only have a single + axis rect and at most one axis at each axis rect side. If you use \link thelayoutsystem the + layout system\endlink to add multiple axis rects or multiple axes to one side, use the \ref + QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the + default legend is removed due to manipulation of the layout system (e.g. by removing the main + axis rect), the corresponding pointers become 0. +*/ + +/*! \var QCPAxis *QCustomPlot::yAxis2 + + A pointer to the secondary y Axis (right) of the main axis rect of the plot. Secondary axes are + invisible by default. Use QCPAxis::setVisible to change this (or use \ref + QCPAxisRect::setupFullAxesBox). + + QCustomPlot offers convenient pointers to the axes (\ref xAxis, \ref yAxis, \ref xAxis2, \ref + yAxis2) and the \ref legend. They make it very easy working with plots that only have a single + axis rect and at most one axis at each axis rect side. If you use \link thelayoutsystem the + layout system\endlink to add multiple axis rects or multiple axes to one side, use the \ref + QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the + default legend is removed due to manipulation of the layout system (e.g. by removing the main + axis rect), the corresponding pointers become 0. +*/ + +/*! \var QCPLegend *QCustomPlot::legend + + A pointer to the default legend of the main axis rect. The legend is invisible by default. Use + QCPLegend::setVisible to change this. + + QCustomPlot offers convenient pointers to the axes (\ref xAxis, \ref yAxis, \ref xAxis2, \ref + yAxis2) and the \ref legend. They make it very easy working with plots that only have a single + axis rect and at most one axis at each axis rect side. If you use \link thelayoutsystem the + layout system\endlink to add multiple legends to the plot, use the layout system interface to + access the new legend. For example, legends can be placed inside an axis rect's \ref + QCPAxisRect::insetLayout "inset layout", and must then also be accessed via the inset layout. If + the default legend is removed due to manipulation of the layout system (e.g. by removing the main + axis rect), the corresponding pointer becomes 0. +*/ + +/* end of documentation of public members */ + +/*! + Constructs a QCustomPlot and sets reasonable default values. +*/ +QCustomPlot::QCustomPlot(QWidget *parent) : + QWidget(parent), + xAxis(0), + yAxis(0), + xAxis2(0), + yAxis2(0), + legend(0), + mPlotLayout(0), + mAutoAddPlottableToLegend(true), + mAntialiasedElements(QCP::aeNone), + mNotAntialiasedElements(QCP::aeNone), + mInteractions(0), + mSelectionTolerance(8), + mNoAntialiasingOnDrag(false), + mBackgroundBrush(Qt::white, Qt::SolidPattern), + mBackgroundScaled(true), + mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding), + mCurrentLayer(0), + mPlottingHints(QCP::phCacheLabels|QCP::phForceRepaint), + mMultiSelectModifier(Qt::ControlModifier), + mPaintBuffer(size()), + mMouseEventElement(0), + mReplotting(false) +{ + setAttribute(Qt::WA_NoMousePropagation); + setAttribute(Qt::WA_OpaquePaintEvent); + setMouseTracking(true); + QLocale currentLocale = locale(); + currentLocale.setNumberOptions(QLocale::OmitGroupSeparator); + setLocale(currentLocale); + + // create initial layers: + mLayers.append(new QCPLayer(this, "background")); + mLayers.append(new QCPLayer(this, "grid")); + mLayers.append(new QCPLayer(this, "main")); + mLayers.append(new QCPLayer(this, "axes")); + mLayers.append(new QCPLayer(this, "legend")); + updateLayerIndices(); + setCurrentLayer("main"); + + // create initial layout, axis rect and legend: + mPlotLayout = new QCPLayoutGrid; + mPlotLayout->initializeParentPlot(this); + mPlotLayout->setParent(this); // important because if parent is QWidget, QCPLayout::sizeConstraintsChanged will call QWidget::updateGeometry + mPlotLayout->setLayer("main"); + QCPAxisRect *defaultAxisRect = new QCPAxisRect(this, true); + mPlotLayout->addElement(0, 0, defaultAxisRect); + xAxis = defaultAxisRect->axis(QCPAxis::atBottom); + yAxis = defaultAxisRect->axis(QCPAxis::atLeft); + xAxis2 = defaultAxisRect->axis(QCPAxis::atTop); + yAxis2 = defaultAxisRect->axis(QCPAxis::atRight); + legend = new QCPLegend; + legend->setVisible(false); + defaultAxisRect->insetLayout()->addElement(legend, Qt::AlignRight|Qt::AlignTop); + defaultAxisRect->insetLayout()->setMargins(QMargins(12, 12, 12, 12)); + + defaultAxisRect->setLayer("background"); + xAxis->setLayer("axes"); + yAxis->setLayer("axes"); + xAxis2->setLayer("axes"); + yAxis2->setLayer("axes"); + xAxis->grid()->setLayer("grid"); + yAxis->grid()->setLayer("grid"); + xAxis2->grid()->setLayer("grid"); + yAxis2->grid()->setLayer("grid"); + legend->setLayer("legend"); + + setViewport(rect()); // needs to be called after mPlotLayout has been created + + replot(); +} + +QCustomPlot::~QCustomPlot() +{ + try + { + + clearPlottables(); + clearItems(); + + if (mPlotLayout) + { + delete mPlotLayout; + mPlotLayout = 0; + } + + mCurrentLayer = 0; + qDeleteAll(mLayers); // don't use removeLayer, because it would prevent the last layer to be removed + mLayers.clear(); + } + catch(std::exception& e) + { + } +} + +/*! + Sets which elements are forcibly drawn antialiased as an \a or combination of QCP::AntialiasedElement. + + This overrides the antialiasing settings for whole element groups, normally controlled with the + \a setAntialiasing function on the individual elements. If an element is neither specified in + \ref setAntialiasedElements nor in \ref setNotAntialiasedElements, the antialiasing setting on + each individual element instance is used. + + For example, if \a antialiasedElements contains \ref QCP::aePlottables, all plottables will be + drawn antialiased, no matter what the specific QCPAbstractPlottable::setAntialiased value was set + to. + + if an element in \a antialiasedElements is already set in \ref setNotAntialiasedElements, it is + removed from there. + + \see setNotAntialiasedElements +*/ +void QCustomPlot::setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements) +{ + mAntialiasedElements = antialiasedElements; + + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: + if ((mNotAntialiasedElements & mAntialiasedElements) != 0) + mNotAntialiasedElements |= ~mAntialiasedElements; +} + +/*! + Sets whether the specified \a antialiasedElement is forcibly drawn antialiased. + + See \ref setAntialiasedElements for details. + + \see setNotAntialiasedElement +*/ +void QCustomPlot::setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled) +{ + if (!enabled && mAntialiasedElements.testFlag(antialiasedElement)) + mAntialiasedElements &= ~antialiasedElement; + else if (enabled && !mAntialiasedElements.testFlag(antialiasedElement)) + mAntialiasedElements |= antialiasedElement; + + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: + if ((mNotAntialiasedElements & mAntialiasedElements) != 0) + mNotAntialiasedElements |= ~mAntialiasedElements; +} + +/*! + Sets which elements are forcibly drawn not antialiased as an \a or combination of + QCP::AntialiasedElement. + + This overrides the antialiasing settings for whole element groups, normally controlled with the + \a setAntialiasing function on the individual elements. If an element is neither specified in + \ref setAntialiasedElements nor in \ref setNotAntialiasedElements, the antialiasing setting on + each individual element instance is used. + + For example, if \a notAntialiasedElements contains \ref QCP::aePlottables, no plottables will be + drawn antialiased, no matter what the specific QCPAbstractPlottable::setAntialiased value was set + to. + + if an element in \a notAntialiasedElements is already set in \ref setAntialiasedElements, it is + removed from there. + + \see setAntialiasedElements +*/ +void QCustomPlot::setNotAntialiasedElements(const QCP::AntialiasedElements ¬AntialiasedElements) +{ + mNotAntialiasedElements = notAntialiasedElements; + + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: + if ((mNotAntialiasedElements & mAntialiasedElements) != 0) + mAntialiasedElements |= ~mNotAntialiasedElements; +} + +/*! + Sets whether the specified \a notAntialiasedElement is forcibly drawn not antialiased. + + See \ref setNotAntialiasedElements for details. + + \see setAntialiasedElement +*/ +void QCustomPlot::setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled) +{ + if (!enabled && mNotAntialiasedElements.testFlag(notAntialiasedElement)) + mNotAntialiasedElements &= ~notAntialiasedElement; + else if (enabled && !mNotAntialiasedElements.testFlag(notAntialiasedElement)) + mNotAntialiasedElements |= notAntialiasedElement; + + // make sure elements aren't in mNotAntialiasedElements and mAntialiasedElements simultaneously: + if ((mNotAntialiasedElements & mAntialiasedElements) != 0) + mAntialiasedElements |= ~mNotAntialiasedElements; +} + +/*! + If set to true, adding a plottable (e.g. a graph) to the QCustomPlot automatically also adds the + plottable to the legend (QCustomPlot::legend). + + \see addPlottable, addGraph, QCPLegend::addItem +*/ +void QCustomPlot::setAutoAddPlottableToLegend(bool on) +{ + mAutoAddPlottableToLegend = on; +} + +/*! + Sets the possible interactions of this QCustomPlot as an or-combination of \ref QCP::Interaction + enums. There are the following types of interactions: + + Axis range manipulation is controlled via \ref QCP::iRangeDrag and \ref QCP::iRangeZoom. When the + respective interaction is enabled, the user may drag axes ranges and zoom with the mouse wheel. + For details how to control which axes the user may drag/zoom and in what orientations, see \ref + QCPAxisRect::setRangeDrag, \ref QCPAxisRect::setRangeZoom, \ref QCPAxisRect::setRangeDragAxes, + \ref QCPAxisRect::setRangeZoomAxes. + + Plottable selection is controlled by \ref QCP::iSelectPlottables. If \ref QCP::iSelectPlottables is + set, the user may select plottables (graphs, curves, bars,...) by clicking on them or in their + vicinity (\ref setSelectionTolerance). Whether the user can actually select a plottable can + further be restricted with the \ref QCPAbstractPlottable::setSelectable function on the specific + plottable. To find out whether a specific plottable is selected, call + QCPAbstractPlottable::selected(). To retrieve a list of all currently selected plottables, call + \ref selectedPlottables. If you're only interested in QCPGraphs, you may use the convenience + function \ref selectedGraphs. + + Item selection is controlled by \ref QCP::iSelectItems. If \ref QCP::iSelectItems is set, the user + may select items (QCPItemLine, QCPItemText,...) by clicking on them or in their vicinity. To find + out whether a specific item is selected, call QCPAbstractItem::selected(). To retrieve a list of + all currently selected items, call \ref selectedItems. + + Axis selection is controlled with \ref QCP::iSelectAxes. If \ref QCP::iSelectAxes is set, the user + may select parts of the axes by clicking on them. What parts exactly (e.g. Axis base line, tick + labels, axis label) are selectable can be controlled via \ref QCPAxis::setSelectableParts for + each axis. To retrieve a list of all axes that currently contain selected parts, call \ref + selectedAxes. Which parts of an axis are selected, can be retrieved with QCPAxis::selectedParts(). + + Legend selection is controlled with \ref QCP::iSelectLegend. If this is set, the user may + select the legend itself or individual items by clicking on them. What parts exactly are + selectable can be controlled via \ref QCPLegend::setSelectableParts. To find out whether the + legend or any of its child items are selected, check the value of QCPLegend::selectedParts. To + find out which child items are selected, call \ref QCPLegend::selectedItems. + + All other selectable elements The selection of all other selectable objects (e.g. + QCPPlotTitle, or your own layerable subclasses) is controlled with \ref QCP::iSelectOther. If set, the + user may select those objects by clicking on them. To find out which are currently selected, you + need to check their selected state explicitly. + + If the selection state has changed by user interaction, the \ref selectionChangedByUser signal is + emitted. Each selectable object additionally emits an individual selectionChanged signal whenever + their selection state has changed, i.e. not only by user interaction. + + To allow multiple objects to be selected by holding the selection modifier (\ref + setMultiSelectModifier), set the flag \ref QCP::iMultiSelect. + + \note In addition to the selection mechanism presented here, QCustomPlot always emits + corresponding signals, when an object is clicked or double clicked. see \ref plottableClick and + \ref plottableDoubleClick for example. + + \see setInteraction, setSelectionTolerance +*/ +void QCustomPlot::setInteractions(const QCP::Interactions &interactions) +{ + mInteractions = interactions; +} + +/*! + Sets the single \a interaction of this QCustomPlot to \a enabled. + + For details about the interaction system, see \ref setInteractions. + + \see setInteractions +*/ +void QCustomPlot::setInteraction(const QCP::Interaction &interaction, bool enabled) +{ + if (!enabled && mInteractions.testFlag(interaction)) + mInteractions &= ~interaction; + else if (enabled && !mInteractions.testFlag(interaction)) + mInteractions |= interaction; +} + +/*! + Sets the tolerance that is used to decide whether a click selects an object (e.g. a plottable) or + not. + + If the user clicks in the vicinity of the line of e.g. a QCPGraph, it's only regarded as a + potential selection when the minimum distance between the click position and the graph line is + smaller than \a pixels. Objects that are defined by an area (e.g. QCPBars) only react to clicks + directly inside the area and ignore this selection tolerance. In other words, it only has meaning + for parts of objects that are too thin to exactly hit with a click and thus need such a + tolerance. + + \see setInteractions, QCPLayerable::selectTest +*/ +void QCustomPlot::setSelectionTolerance(int pixels) +{ + mSelectionTolerance = pixels; +} + +/*! + Sets whether antialiasing is disabled for this QCustomPlot while the user is dragging axes + ranges. If many objects, especially plottables, are drawn antialiased, this greatly improves + performance during dragging. Thus it creates a more responsive user experience. As soon as the + user stops dragging, the last replot is done with normal antialiasing, to restore high image + quality. + + \see setAntialiasedElements, setNotAntialiasedElements +*/ +void QCustomPlot::setNoAntialiasingOnDrag(bool enabled) +{ + mNoAntialiasingOnDrag = enabled; +} + +/*! + Sets the plotting hints for this QCustomPlot instance as an \a or combination of QCP::PlottingHint. + + \see setPlottingHint +*/ +void QCustomPlot::setPlottingHints(const QCP::PlottingHints &hints) +{ + mPlottingHints = hints; +} + +/*! + Sets the specified plotting \a hint to \a enabled. + + \see setPlottingHints +*/ +void QCustomPlot::setPlottingHint(QCP::PlottingHint hint, bool enabled) +{ + QCP::PlottingHints newHints = mPlottingHints; + if (!enabled) + newHints &= ~hint; + else + newHints |= hint; + + if (newHints != mPlottingHints) + setPlottingHints(newHints); +} + +/*! + Sets the keyboard modifier that will be recognized as multi-select-modifier. + + If \ref QCP::iMultiSelect is specified in \ref setInteractions, the user may select multiple objects + by clicking on them one after the other while holding down \a modifier. + + By default the multi-select-modifier is set to Qt::ControlModifier. + + \see setInteractions +*/ +void QCustomPlot::setMultiSelectModifier(Qt::KeyboardModifier modifier) +{ + mMultiSelectModifier = modifier; +} + +/*! + Sets the viewport of this QCustomPlot. The Viewport is the area that the top level layout + (QCustomPlot::plotLayout()) uses as its rect. Normally, the viewport is the entire widget rect. + + This function is used to allow arbitrary size exports with \ref toPixmap, \ref savePng, \ref + savePdf, etc. by temporarily changing the viewport size. +*/ +void QCustomPlot::setViewport(const QRect &rect) +{ + mViewport = rect; + if (mPlotLayout) + mPlotLayout->setOuterRect(mViewport); +} + +/*! + Sets \a pm as the viewport background pixmap (see \ref setViewport). The pixmap is always drawn + below all other objects in the plot. + + For cases where the provided pixmap doesn't have the same size as the viewport, scaling can be + enabled with \ref setBackgroundScaled and the scaling mode (whether and how the aspect ratio is + preserved) can be set with \ref setBackgroundScaledMode. To set all these options in one call, + consider using the overloaded version of this function. + + If a background brush was set with \ref setBackground(const QBrush &brush), the viewport will + first be filled with that brush, before drawing the background pixmap. This can be useful for + background pixmaps with translucent areas. + + \see setBackgroundScaled, setBackgroundScaledMode +*/ +void QCustomPlot::setBackground(const QPixmap &pm) +{ + mBackgroundPixmap = pm; + mScaledBackgroundPixmap = QPixmap(); +} + +/*! + Sets the background brush of the viewport (see \ref setViewport). + + Before drawing everything else, the background is filled with \a brush. If a background pixmap + was set with \ref setBackground(const QPixmap &pm), this brush will be used to fill the viewport + before the background pixmap is drawn. This can be useful for background pixmaps with translucent + areas. + + Set \a brush to Qt::NoBrush or Qt::Transparent to leave background transparent. This can be + useful for exporting to image formats which support transparency, e.g. \ref savePng. + + \see setBackgroundScaled, setBackgroundScaledMode +*/ +void QCustomPlot::setBackground(const QBrush &brush) +{ + mBackgroundBrush = brush; +} + +/*! \overload + + Allows setting the background pixmap of the viewport, whether it shall be scaled and how it + shall be scaled in one call. + + \see setBackground(const QPixmap &pm), setBackgroundScaled, setBackgroundScaledMode +*/ +void QCustomPlot::setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode) +{ + mBackgroundPixmap = pm; + mScaledBackgroundPixmap = QPixmap(); + mBackgroundScaled = scaled; + mBackgroundScaledMode = mode; +} + +/*! + Sets whether the viewport background pixmap shall be scaled to fit the viewport. If \a scaled is + set to true, control whether and how the aspect ratio of the original pixmap is preserved with + \ref setBackgroundScaledMode. + + Note that the scaled version of the original pixmap is buffered, so there is no performance + penalty on replots. (Except when the viewport dimensions are changed continuously.) + + \see setBackground, setBackgroundScaledMode +*/ +void QCustomPlot::setBackgroundScaled(bool scaled) +{ + mBackgroundScaled = scaled; +} + +/*! + If scaling of the viewport background pixmap is enabled (\ref setBackgroundScaled), use this + function to define whether and how the aspect ratio of the original pixmap is preserved. + + \see setBackground, setBackgroundScaled +*/ +void QCustomPlot::setBackgroundScaledMode(Qt::AspectRatioMode mode) +{ + mBackgroundScaledMode = mode; +} + +/*! + Returns the plottable with \a index. If the index is invalid, returns 0. + + There is an overloaded version of this function with no parameter which returns the last added + plottable, see QCustomPlot::plottable() + + \see plottableCount, addPlottable +*/ +QCPAbstractPlottable *QCustomPlot::plottable(int index) +{ + if (index >= 0 && index < mPlottables.size()) + { + return mPlottables.at(index); + } else + { + qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; + return 0; + } +} + +/*! \overload + + Returns the last plottable that was added with \ref addPlottable. If there are no plottables in + the plot, returns 0. + + \see plottableCount, addPlottable +*/ +QCPAbstractPlottable *QCustomPlot::plottable() +{ + if (!mPlottables.isEmpty()) + { + return mPlottables.last(); + } else + return 0; +} + +/*! + Adds the specified plottable to the plot and, if \ref setAutoAddPlottableToLegend is enabled, to + the legend (QCustomPlot::legend). QCustomPlot takes ownership of the plottable. + + Returns true on success, i.e. when \a plottable isn't already in the plot and the parent plot of + \a plottable is this QCustomPlot (the latter is controlled by what axes were passed in the + plottable's constructor). + + \see plottable, plottableCount, removePlottable, clearPlottables +*/ +bool QCustomPlot::addPlottable(QCPAbstractPlottable *plottable) +{ + if (mPlottables.contains(plottable)) + { + qDebug() << Q_FUNC_INFO << "plottable already added to this QCustomPlot:" << reinterpret_cast(plottable); + return false; + } + if (plottable->parentPlot() != this) + { + qDebug() << Q_FUNC_INFO << "plottable not created with this QCustomPlot as parent:" << reinterpret_cast(plottable); + return false; + } + + mPlottables.append(plottable); + // possibly add plottable to legend: + if (mAutoAddPlottableToLegend) + plottable->addToLegend(); + // special handling for QCPGraphs to maintain the simple graph interface: + if (QCPGraph *graph = qobject_cast(plottable)) + mGraphs.append(graph); + if (!plottable->layer()) // usually the layer is already set in the constructor of the plottable (via QCPLayerable constructor) + plottable->setLayer(currentLayer()); + return true; +} + +/*! + Removes the specified plottable from the plot and, if necessary, from the legend (QCustomPlot::legend). + + Returns true on success. + + \see addPlottable, clearPlottables +*/ +bool QCustomPlot::removePlottable(QCPAbstractPlottable *plottable) +{ + if (!mPlottables.contains(plottable)) + { + qDebug() << Q_FUNC_INFO << "plottable not in list:" << reinterpret_cast(plottable); + return false; + } + + // remove plottable from legend: + plottable->removeFromLegend(); + // special handling for QCPGraphs to maintain the simple graph interface: + if (QCPGraph *graph = qobject_cast(plottable)) + mGraphs.removeOne(graph); + // remove plottable: + delete plottable; + mPlottables.removeOne(plottable); + return true; +} + +/*! \overload + + Removes the plottable by its \a index. +*/ +bool QCustomPlot::removePlottable(int index) +{ + if (index >= 0 && index < mPlottables.size()) + return removePlottable(mPlottables[index]); + else + { + qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; + return false; + } +} + +/*! + Removes all plottables from the plot (and the QCustomPlot::legend, if necessary). + + Returns the number of plottables removed. + + \see removePlottable +*/ +int QCustomPlot::clearPlottables() +{ + int c = mPlottables.size(); + for (int i=c-1; i >= 0; --i) + removePlottable(mPlottables[i]); + return c; +} + +/*! + Returns the number of currently existing plottables in the plot + + \see plottable, addPlottable +*/ +int QCustomPlot::plottableCount() const +{ + return mPlottables.size(); +} + +/*! + Returns a list of the selected plottables. If no plottables are currently selected, the list is empty. + + There is a convenience function if you're only interested in selected graphs, see \ref selectedGraphs. + + \see setInteractions, QCPAbstractPlottable::setSelectable, QCPAbstractPlottable::setSelected +*/ +QList QCustomPlot::selectedPlottables() const +{ + QList result; + foreach (QCPAbstractPlottable *plottable, mPlottables) + { + if (plottable->selected()) + result.append(plottable); + } + return result; +} + +/*! + Returns the plottable at the pixel position \a pos. Plottables that only consist of single lines + (like graphs) have a tolerance band around them, see \ref setSelectionTolerance. If multiple + plottables come into consideration, the one closest to \a pos is returned. + + If \a onlySelectable is true, only plottables that are selectable + (QCPAbstractPlottable::setSelectable) are considered. + + If there is no plottable at \a pos, the return value is 0. + + \see itemAt, layoutElementAt +*/ +QCPAbstractPlottable *QCustomPlot::plottableAt(const QPointF &pos, bool onlySelectable) const +{ + QCPAbstractPlottable *resultPlottable = 0; + double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value + + foreach (QCPAbstractPlottable *plottable, mPlottables) + { + if (onlySelectable && !plottable->selectable()) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPabstractPlottable::selectable + continue; + if ((plottable->keyAxis()->axisRect()->rect() & plottable->valueAxis()->axisRect()->rect()).contains(pos.toPoint())) // only consider clicks inside the rect that is spanned by the plottable's key/value axes + { + double currentDistance = plottable->selectTest(pos, false); + if (currentDistance >= 0 && currentDistance < resultDistance) + { + resultPlottable = plottable; + resultDistance = currentDistance; + } + } + } + + return resultPlottable; +} + +/*! + Returns whether this QCustomPlot instance contains the \a plottable. + + \see addPlottable +*/ +bool QCustomPlot::hasPlottable(QCPAbstractPlottable *plottable) const +{ + return mPlottables.contains(plottable); +} + +/*! + Returns the graph with \a index. If the index is invalid, returns 0. + + There is an overloaded version of this function with no parameter which returns the last created + graph, see QCustomPlot::graph() + + \see graphCount, addGraph +*/ +QCPGraph *QCustomPlot::graph(int index) const +{ + if (index >= 0 && index < mGraphs.size()) + { + return mGraphs.at(index); + } else + { + qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; + return 0; + } +} + +/*! \overload + + Returns the last graph, that was created with \ref addGraph. If there are no graphs in the plot, + returns 0. + + \see graphCount, addGraph +*/ +QCPGraph *QCustomPlot::graph() const +{ + if (!mGraphs.isEmpty()) + { + return mGraphs.last(); + } else + return 0; +} + +/*! + Creates a new graph inside the plot. If \a keyAxis and \a valueAxis are left unspecified (0), the + bottom (xAxis) is used as key and the left (yAxis) is used as value axis. If specified, \a + keyAxis and \a valueAxis must reside in this QCustomPlot. + + \a keyAxis will be used as key axis (typically "x") and \a valueAxis as value axis (typically + "y") for the graph. + + Returns a pointer to the newly created graph, or 0 if adding the graph failed. + + \see graph, graphCount, removeGraph, clearGraphs +*/ +QCPGraph *QCustomPlot::addGraph(QCPAxis *keyAxis, QCPAxis *valueAxis) +{ + if (!keyAxis) keyAxis = xAxis; + if (!valueAxis) valueAxis = yAxis; + if (!keyAxis || !valueAxis) + { + qDebug() << Q_FUNC_INFO << "can't use default QCustomPlot xAxis or yAxis, because at least one is invalid (has been deleted)"; + return 0; + } + if (keyAxis->parentPlot() != this || valueAxis->parentPlot() != this) + { + qDebug() << Q_FUNC_INFO << "passed keyAxis or valueAxis doesn't have this QCustomPlot as parent"; + return 0; + } + + QCPGraph *newGraph = new QCPGraph(keyAxis, valueAxis); + if (addPlottable(newGraph)) + { + newGraph->setName("Graph "+QString::number(mGraphs.size())); + return newGraph; + } else + { + delete newGraph; + return 0; + } +} + +/*! + Removes the specified \a graph from the plot and, if necessary, from the QCustomPlot::legend. If + any other graphs in the plot have a channel fill set towards the removed graph, the channel fill + property of those graphs is reset to zero (no channel fill). + + Returns true on success. + + \see clearGraphs +*/ +bool QCustomPlot::removeGraph(QCPGraph *graph) +{ + return removePlottable(graph); +} + +/*! \overload + + Removes the graph by its \a index. +*/ +bool QCustomPlot::removeGraph(int index) +{ + if (index >= 0 && index < mGraphs.size()) + return removeGraph(mGraphs[index]); + else + return false; +} + +/*! + Removes all graphs from the plot (and the QCustomPlot::legend, if necessary). + + Returns the number of graphs removed. + + \see removeGraph +*/ +int QCustomPlot::clearGraphs() +{ + int c = mGraphs.size(); + for (int i=c-1; i >= 0; --i) + removeGraph(mGraphs[i]); + return c; +} + +/*! + Returns the number of currently existing graphs in the plot + + \see graph, addGraph +*/ +int QCustomPlot::graphCount() const +{ + return mGraphs.size(); +} + +/*! + Returns a list of the selected graphs. If no graphs are currently selected, the list is empty. + + If you are not only interested in selected graphs but other plottables like QCPCurve, QCPBars, + etc., use \ref selectedPlottables. + + \see setInteractions, selectedPlottables, QCPAbstractPlottable::setSelectable, QCPAbstractPlottable::setSelected +*/ +QList QCustomPlot::selectedGraphs() const +{ + QList result; + foreach (QCPGraph *graph, mGraphs) + { + if (graph->selected()) + result.append(graph); + } + return result; +} + +/*! + Returns the item with \a index. If the index is invalid, returns 0. + + There is an overloaded version of this function with no parameter which returns the last added + item, see QCustomPlot::item() + + \see itemCount, addItem +*/ +QCPAbstractItem *QCustomPlot::item(int index) const +{ + if (index >= 0 && index < mItems.size()) + { + return mItems.at(index); + } else + { + qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; + return 0; + } +} + +/*! \overload + + Returns the last item, that was added with \ref addItem. If there are no items in the plot, + returns 0. + + \see itemCount, addItem +*/ +QCPAbstractItem *QCustomPlot::item() const +{ + if (!mItems.isEmpty()) + { + return mItems.last(); + } else + return 0; +} + +/*! + Adds the specified item to the plot. QCustomPlot takes ownership of the item. + + Returns true on success, i.e. when \a item wasn't already in the plot and the parent plot of \a + item is this QCustomPlot. + + \see item, itemCount, removeItem, clearItems +*/ +bool QCustomPlot::addItem(QCPAbstractItem *item) +{ + if (!mItems.contains(item) && item->parentPlot() == this) + { + mItems.append(item); + return true; + } else + { + qDebug() << Q_FUNC_INFO << "item either already in list or not created with this QCustomPlot as parent:" << reinterpret_cast(item); + return false; + } +} + +/*! + Removes the specified item from the plot. + + Returns true on success. + + \see addItem, clearItems +*/ +bool QCustomPlot::removeItem(QCPAbstractItem *item) +{ + if (mItems.contains(item)) + { + delete item; + mItems.removeOne(item); + return true; + } else + { + qDebug() << Q_FUNC_INFO << "item not in list:" << reinterpret_cast(item); + return false; + } +} + +/*! \overload + + Removes the item by its \a index. +*/ +bool QCustomPlot::removeItem(int index) +{ + if (index >= 0 && index < mItems.size()) + return removeItem(mItems[index]); + else + { + qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; + return false; + } +} + +/*! + Removes all items from the plot. + + Returns the number of items removed. + + \see removeItem +*/ +int QCustomPlot::clearItems() +{ + int c = mItems.size(); + for (int i=c-1; i >= 0; --i) + removeItem(mItems[i]); + return c; +} + +/*! + Returns the number of currently existing items in the plot + + \see item, addItem +*/ +int QCustomPlot::itemCount() const +{ + return mItems.size(); +} + +/*! + Returns a list of the selected items. If no items are currently selected, the list is empty. + + \see setInteractions, QCPAbstractItem::setSelectable, QCPAbstractItem::setSelected +*/ +QList QCustomPlot::selectedItems() const +{ + QList result; + foreach (QCPAbstractItem *item, mItems) + { + if (item->selected()) + result.append(item); + } + return result; +} + +/*! + Returns the item at the pixel position \a pos. Items that only consist of single lines (e.g. \ref + QCPItemLine or \ref QCPItemCurve) have a tolerance band around them, see \ref + setSelectionTolerance. If multiple items come into consideration, the one closest to \a pos is + returned. + + If \a onlySelectable is true, only items that are selectable (QCPAbstractItem::setSelectable) are + considered. + + If there is no item at \a pos, the return value is 0. + + \see plottableAt, layoutElementAt +*/ +QCPAbstractItem *QCustomPlot::itemAt(const QPointF &pos, bool onlySelectable) const +{ + QCPAbstractItem *resultItem = 0; + double resultDistance = mSelectionTolerance; // only regard clicks with distances smaller than mSelectionTolerance as selections, so initialize with that value + + foreach (QCPAbstractItem *item, mItems) + { + if (onlySelectable && !item->selectable()) // we could have also passed onlySelectable to the selectTest function, but checking here is faster, because we have access to QCPAbstractItem::selectable + continue; + if (!item->clipToAxisRect() || item->clipRect().contains(pos.toPoint())) // only consider clicks inside axis cliprect of the item if actually clipped to it + { + double currentDistance = item->selectTest(pos, false); + if (currentDistance >= 0 && currentDistance < resultDistance) + { + resultItem = item; + resultDistance = currentDistance; + } + } + } + + return resultItem; +} + +/*! + Returns whether this QCustomPlot contains the \a item. + + \see addItem +*/ +bool QCustomPlot::hasItem(QCPAbstractItem *item) const +{ + return mItems.contains(item); +} + +/*! + Returns the layer with the specified \a name. If there is no layer with the specified name, 0 is + returned. + + Layer names are case-sensitive. + + \see addLayer, moveLayer, removeLayer +*/ +QCPLayer *QCustomPlot::layer(const QString &name) const +{ + foreach (QCPLayer *layer, mLayers) + { + if (layer->name() == name) + return layer; + } + return 0; +} + +/*! \overload + + Returns the layer by \a index. If the index is invalid, 0 is returned. + + \see addLayer, moveLayer, removeLayer +*/ +QCPLayer *QCustomPlot::layer(int index) const +{ + if (index >= 0 && index < mLayers.size()) + { + return mLayers.at(index); + } else + { + qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; + return 0; + } +} + +/*! + Returns the layer that is set as current layer (see \ref setCurrentLayer). +*/ +QCPLayer *QCustomPlot::currentLayer() const +{ + return mCurrentLayer; +} + +/*! + Sets the layer with the specified \a name to be the current layer. All layerables (\ref + QCPLayerable), e.g. plottables and items, are created on the current layer. + + Returns true on success, i.e. if there is a layer with the specified \a name in the QCustomPlot. + + Layer names are case-sensitive. + + \see addLayer, moveLayer, removeLayer, QCPLayerable::setLayer +*/ +bool QCustomPlot::setCurrentLayer(const QString &name) +{ + if (QCPLayer *newCurrentLayer = layer(name)) + { + return setCurrentLayer(newCurrentLayer); + } else + { + qDebug() << Q_FUNC_INFO << "layer with name doesn't exist:" << name; + return false; + } +} + +/*! \overload + + Sets the provided \a layer to be the current layer. + + Returns true on success, i.e. when \a layer is a valid layer in the QCustomPlot. + + \see addLayer, moveLayer, removeLayer +*/ +bool QCustomPlot::setCurrentLayer(QCPLayer *layer) +{ + if (!mLayers.contains(layer)) + { + qDebug() << Q_FUNC_INFO << "layer not a layer of this QCustomPlot:" << reinterpret_cast(layer); + return false; + } + + mCurrentLayer = layer; + return true; +} + +/*! + Returns the number of currently existing layers in the plot + + \see layer, addLayer +*/ +int QCustomPlot::layerCount() const +{ + return mLayers.size(); +} + +/*! + Adds a new layer to this QCustomPlot instance. The new layer will have the name \a name, which + must be unique. Depending on \a insertMode, it is positioned either below or above \a otherLayer. + + Returns true on success, i.e. if there is no other layer named \a name and \a otherLayer is a + valid layer inside this QCustomPlot. + + If \a otherLayer is 0, the highest layer in the QCustomPlot will be used. + + For an explanation of what layers are in QCustomPlot, see the documentation of \ref QCPLayer. + + \see layer, moveLayer, removeLayer +*/ +bool QCustomPlot::addLayer(const QString &name, QCPLayer *otherLayer, QCustomPlot::LayerInsertMode insertMode) +{ + if (!otherLayer) + otherLayer = mLayers.last(); + if (!mLayers.contains(otherLayer)) + { + qDebug() << Q_FUNC_INFO << "otherLayer not a layer of this QCustomPlot:" << reinterpret_cast(otherLayer); + return false; + } + if (layer(name)) + { + qDebug() << Q_FUNC_INFO << "A layer exists already with the name" << name; + return false; + } + + QCPLayer *newLayer = new QCPLayer(this, name); + mLayers.insert(otherLayer->index() + (insertMode==limAbove ? 1:0), newLayer); + updateLayerIndices(); + return true; +} + +/*! + Removes the specified \a layer and returns true on success. + + All layerables (e.g. plottables and items) on the removed layer will be moved to the layer below + \a layer. If \a layer is the bottom layer, the layerables are moved to the layer above. In both + cases, the total rendering order of all layerables in the QCustomPlot is preserved. + + If \a layer is the current layer (\ref setCurrentLayer), the layer below (or above, if bottom + layer) becomes the new current layer. + + It is not possible to remove the last layer of the plot. + + \see layer, addLayer, moveLayer +*/ +bool QCustomPlot::removeLayer(QCPLayer *layer) +{ + if (!mLayers.contains(layer)) + { + qDebug() << Q_FUNC_INFO << "layer not a layer of this QCustomPlot:" << reinterpret_cast(layer); + return false; + } + if (mLayers.size() < 2) + { + qDebug() << Q_FUNC_INFO << "can't remove last layer"; + return false; + } + + // append all children of this layer to layer below (if this is lowest layer, prepend to layer above) + int removedIndex = layer->index(); + bool isFirstLayer = removedIndex==0; + QCPLayer *targetLayer = isFirstLayer ? mLayers.at(removedIndex+1) : mLayers.at(removedIndex-1); + QList children = layer->children(); + if (isFirstLayer) // prepend in reverse order (so order relative to each other stays the same) + { + for (int i=children.size()-1; i>=0; --i) + children.at(i)->moveToLayer(targetLayer, true); + } else // append normally + { + for (int i=0; imoveToLayer(targetLayer, false); + } + // if removed layer is current layer, change current layer to layer below/above: + if (layer == mCurrentLayer) + setCurrentLayer(targetLayer); + // remove layer: + delete layer; + mLayers.removeOne(layer); + updateLayerIndices(); + return true; +} + +/*! + Moves the specified \a layer either above or below \a otherLayer. Whether it's placed above or + below is controlled with \a insertMode. + + Returns true on success, i.e. when both \a layer and \a otherLayer are valid layers in the + QCustomPlot. + + \see layer, addLayer, moveLayer +*/ +bool QCustomPlot::moveLayer(QCPLayer *layer, QCPLayer *otherLayer, QCustomPlot::LayerInsertMode insertMode) +{ + if (!mLayers.contains(layer)) + { + qDebug() << Q_FUNC_INFO << "layer not a layer of this QCustomPlot:" << reinterpret_cast(layer); + return false; + } + if (!mLayers.contains(otherLayer)) + { + qDebug() << Q_FUNC_INFO << "otherLayer not a layer of this QCustomPlot:" << reinterpret_cast(otherLayer); + return false; + } + + mLayers.move(layer->index(), otherLayer->index() + (insertMode==limAbove ? 1:0)); + updateLayerIndices(); + return true; +} + +/*! + Returns the number of axis rects in the plot. + + All axis rects can be accessed via QCustomPlot::axisRect(). + + Initially, only one axis rect exists in the plot. + + \see axisRect, axisRects +*/ +int QCustomPlot::axisRectCount() const +{ + return axisRects().size(); +} + +/*! + Returns the axis rect with \a index. + + Initially, only one axis rect (with index 0) exists in the plot. If multiple axis rects were + added, all of them may be accessed with this function in a linear fashion (even when they are + nested in a layout hierarchy or inside other axis rects via QCPAxisRect::insetLayout). + + \see axisRectCount, axisRects +*/ +QCPAxisRect *QCustomPlot::axisRect(int index) const +{ + const QList rectList = axisRects(); + if (index >= 0 && index < rectList.size()) + { + return rectList.at(index); + } else + { + qDebug() << Q_FUNC_INFO << "invalid axis rect index" << index; + return 0; + } +} + +/*! + Returns all axis rects in the plot. + + \see axisRectCount, axisRect +*/ +QList QCustomPlot::axisRects() const +{ + QList result; + QStack elementStack; + if (mPlotLayout) + elementStack.push(mPlotLayout); + + while (!elementStack.isEmpty()) + { + foreach (QCPLayoutElement *element, elementStack.pop()->elements(false)) + { + if (element) + { + elementStack.push(element); + if (QCPAxisRect *ar = qobject_cast(element)) + result.append(ar); + } + } + } + + return result; +} + +/*! + Returns the layout element at pixel position \a pos. If there is no element at that position, + returns 0. + + Only visible elements are used. If \ref QCPLayoutElement::setVisible on the element itself or on + any of its parent elements is set to false, it will not be considered. + + \see itemAt, plottableAt +*/ +QCPLayoutElement *QCustomPlot::layoutElementAt(const QPointF &pos) const +{ + QCPLayoutElement *currentElement = mPlotLayout; + bool searchSubElements = true; + while (searchSubElements && currentElement) + { + searchSubElements = false; + foreach (QCPLayoutElement *subElement, currentElement->elements(false)) + { + if (subElement && subElement->realVisibility() && subElement->selectTest(pos, false) >= 0) + { + currentElement = subElement; + searchSubElements = true; + break; + } + } + } + return currentElement; +} + +/*! + Returns the axes that currently have selected parts, i.e. whose selection state is not \ref + QCPAxis::spNone. + + \see selectedPlottables, selectedLegends, setInteractions, QCPAxis::setSelectedParts, + QCPAxis::setSelectableParts +*/ +QList QCustomPlot::selectedAxes() const +{ + QList result, allAxes; + foreach (QCPAxisRect *rect, axisRects()) + allAxes << rect->axes(); + + foreach (QCPAxis *axis, allAxes) + { + if (axis->selectedParts() != QCPAxis::spNone) + result.append(axis); + } + + return result; +} + +/*! + Returns the legends that currently have selected parts, i.e. whose selection state is not \ref + QCPLegend::spNone. + + \see selectedPlottables, selectedAxes, setInteractions, QCPLegend::setSelectedParts, + QCPLegend::setSelectableParts, QCPLegend::selectedItems +*/ +QList QCustomPlot::selectedLegends() const +{ + QList result; + + QStack elementStack; + if (mPlotLayout) + elementStack.push(mPlotLayout); + + while (!elementStack.isEmpty()) + { + foreach (QCPLayoutElement *subElement, elementStack.pop()->elements(false)) + { + if (subElement) + { + elementStack.push(subElement); + if (QCPLegend *leg = qobject_cast(subElement)) + { + if (leg->selectedParts() != QCPLegend::spNone) + result.append(leg); + } + } + } + } + + return result; +} + +/*! + Deselects all layerables (plottables, items, axes, legends,...) of the QCustomPlot. + + Since calling this function is not a user interaction, this does not emit the \ref + selectionChangedByUser signal. The individual selectionChanged signals are emitted though, if the + objects were previously selected. + + \see setInteractions, selectedPlottables, selectedItems, selectedAxes, selectedLegends +*/ +void QCustomPlot::deselectAll() +{ + foreach (QCPLayer *layer, mLayers) + { + foreach (QCPLayerable *layerable, layer->children()) + layerable->deselectEvent(0); + } +} + +/*! + Causes a complete replot into the internal buffer. Finally, update() is called, to redraw the + buffer on the QCustomPlot widget surface. This is the method that must be called to make changes, + for example on the axis ranges or data points of graphs, visible. + + Under a few circumstances, QCustomPlot causes a replot by itself. Those are resize events of the + QCustomPlot widget and user interactions (object selection and range dragging/zooming). + + Before the replot happens, the signal \ref beforeReplot is emitted. After the replot, \ref + afterReplot is emitted. It is safe to mutually connect the replot slot with any of those two + signals on two QCustomPlots to make them replot synchronously, it won't cause an infinite + recursion. +*/ +void QCustomPlot::replot(QCustomPlot::RefreshPriority refreshPriority) +{ + if (mReplotting) // incase signals loop back to replot slot + return; + mReplotting = true; + emit beforeReplot(); + + mPaintBuffer.fill(mBackgroundBrush.style() == Qt::SolidPattern ? mBackgroundBrush.color() : Qt::transparent); + QCPPainter painter; + painter.begin(&mPaintBuffer); + if (painter.isActive()) + { + painter.setRenderHint(QPainter::HighQualityAntialiasing); // to make Antialiasing look good if using the OpenGL graphicssystem + if (mBackgroundBrush.style() != Qt::SolidPattern && mBackgroundBrush.style() != Qt::NoBrush) + painter.fillRect(mViewport, mBackgroundBrush); + draw(&painter); + painter.end(); + if ((refreshPriority == rpHint && mPlottingHints.testFlag(QCP::phForceRepaint)) || refreshPriority==rpImmediate) + repaint(); + else + update(); + } else // might happen if QCustomPlot has width or height zero + qDebug() << Q_FUNC_INFO << "Couldn't activate painter on buffer. This usually happens because QCustomPlot has width or height zero."; + + emit afterReplot(); + mReplotting = false; +} + +/*! + Rescales the axes such that all plottables (like graphs) in the plot are fully visible. + + if \a onlyVisiblePlottables is set to true, only the plottables that have their visibility set to true + (QCPLayerable::setVisible), will be used to rescale the axes. + + \see QCPAbstractPlottable::rescaleAxes, QCPAxis::rescale +*/ +void QCustomPlot::rescaleAxes(bool onlyVisiblePlottables) +{ + QList allAxes; + foreach (QCPAxisRect *rect, axisRects()) + allAxes << rect->axes(); + + foreach (QCPAxis *axis, allAxes) + axis->rescale(onlyVisiblePlottables); +} + +/*! + Saves a PDF with the vectorized plot to the file \a fileName. The axis ratio as well as the scale + of texts and lines will be derived from the specified \a width and \a height. This means, the + output will look like the normal on-screen output of a QCustomPlot widget with the corresponding + pixel width and height. If either \a width or \a height is zero, the exported image will have the + same dimensions as the QCustomPlot widget currently has. + + \a noCosmeticPen disables the use of cosmetic pens when drawing to the PDF file. Cosmetic pens + are pens with numerical width 0, which are always drawn as a one pixel wide line, no matter what + zoom factor is set in the PDF-Viewer. For more information about cosmetic pens, see the QPainter + and QPen documentation. + + The objects of the plot will appear in the current selection state. If you don't want any + selected objects to be painted in their selected look, deselect everything with \ref deselectAll + before calling this function. + + Returns true on success. + + \warning + \li If you plan on editing the exported PDF file with a vector graphics editor like + Inkscape, it is advised to set \a noCosmeticPen to true to avoid losing those cosmetic lines + (which might be quite many, because cosmetic pens are the default for e.g. axes and tick marks). + \li If calling this function inside the constructor of the parent of the QCustomPlot widget + (i.e. the MainWindow constructor, if QCustomPlot is inside the MainWindow), always provide + explicit non-zero widths and heights. If you leave \a width or \a height as 0 (default), this + function uses the current width and height of the QCustomPlot widget. However, in Qt, these + aren't defined yet inside the constructor, so you would get an image that has strange + widths/heights. + + \a pdfCreator and \a pdfTitle may be used to set the according metadata fields in the resulting + PDF file. + + \note On Android systems, this method does nothing and issues an according qDebug warning + message. This is also the case if for other reasons the define flag QT_NO_PRINTER is set. + + \see savePng, saveBmp, saveJpg, saveRastered +*/ +bool QCustomPlot::savePdf(const QString &fileName, bool noCosmeticPen, int width, int height, const QString &pdfCreator, const QString &pdfTitle) +{ + bool success = false; +#ifdef QT_NO_PRINTER + Q_UNUSED(fileName) + Q_UNUSED(noCosmeticPen) + Q_UNUSED(width) + Q_UNUSED(height) + qDebug() << Q_FUNC_INFO << "Qt was built without printer support (QT_NO_PRINTER). PDF not created."; +#else + int newWidth, newHeight; + if (width == 0 || height == 0) + { + newWidth = this->width(); + newHeight = this->height(); + } else + { + newWidth = width; + newHeight = height; + } + + QPrinter printer(QPrinter::ScreenResolution); + printer.setOutputFileName(fileName); + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setColorMode(QPrinter::Color); + printer.printEngine()->setProperty(QPrintEngine::PPK_Creator, pdfCreator); + printer.printEngine()->setProperty(QPrintEngine::PPK_DocumentName, pdfTitle); + QRect oldViewport = viewport(); + setViewport(QRect(0, 0, newWidth, newHeight)); +#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) + printer.setFullPage(true); + printer.setPaperSize(viewport().size(), QPrinter::DevicePixel); +#else + QPageLayout pageLayout; + pageLayout.setMode(QPageLayout::FullPageMode); + pageLayout.setOrientation(QPageLayout::Portrait); + pageLayout.setMargins(QMarginsF(0, 0, 0, 0)); + pageLayout.setPageSize(QPageSize(viewport().size(), QPageSize::Point, QString(), QPageSize::ExactMatch)); + printer.setPageLayout(pageLayout); +#endif + QCPPainter printpainter; + if (printpainter.begin(&printer)) + { + printpainter.setMode(QCPPainter::pmVectorized); + printpainter.setMode(QCPPainter::pmNoCaching); + printpainter.setMode(QCPPainter::pmNonCosmetic, noCosmeticPen); + printpainter.setWindow(mViewport); + if (mBackgroundBrush.style() != Qt::NoBrush && + mBackgroundBrush.color() != Qt::white && + mBackgroundBrush.color() != Qt::transparent && + mBackgroundBrush.color().alpha() > 0) // draw pdf background color if not white/transparent + printpainter.fillRect(viewport(), mBackgroundBrush); + draw(&printpainter); + printpainter.end(); + success = true; + } + setViewport(oldViewport); +#endif // QT_NO_PRINTER + return success; +} + +/*! + Saves a PNG image file to \a fileName on disc. The output plot will have the dimensions \a width + and \a height in pixels. If either \a width or \a height is zero, the exported image will have + the same dimensions as the QCustomPlot widget currently has. Line widths and texts etc. are not + scaled up when larger widths/heights are used. If you want that effect, use the \a scale parameter. + + For example, if you set both \a width and \a height to 100 and \a scale to 2, you will end up with an + image file of size 200*200 in which all graphical elements are scaled up by factor 2 (line widths, + texts, etc.). This scaling is not done by stretching a 100*100 image, the result will have full + 200*200 pixel resolution. + + If you use a high scaling factor, it is recommended to enable antialiasing for all elements via + temporarily setting \ref QCustomPlot::setAntialiasedElements to \ref QCP::aeAll as this allows + QCustomPlot to place objects with sub-pixel accuracy. + + \warning If calling this function inside the constructor of the parent of the QCustomPlot widget + (i.e. the MainWindow constructor, if QCustomPlot is inside the MainWindow), always provide + explicit non-zero widths and heights. If you leave \a width or \a height as 0 (default), this + function uses the current width and height of the QCustomPlot widget. However, in Qt, these + aren't defined yet inside the constructor, so you would get an image that has strange + widths/heights. + + The objects of the plot will appear in the current selection state. If you don't want any selected + objects to be painted in their selected look, deselect everything with \ref deselectAll before calling + this function. + + If you want the PNG to have a transparent background, call \ref setBackground(const QBrush + &brush) with no brush (Qt::NoBrush) or a transparent color (Qt::transparent), before saving. + + PNG compression can be controlled with the \a quality parameter which must be between 0 and 100 or + -1 to use the default setting. + + Returns true on success. If this function fails, most likely the PNG format isn't supported by + the system, see Qt docs about QImageWriter::supportedImageFormats(). + + \see savePdf, saveBmp, saveJpg, saveRastered +*/ +bool QCustomPlot::savePng(const QString &fileName, int width, int height, double scale, int quality) +{ + return saveRastered(fileName, width, height, scale, "PNG", quality); +} + +/*! + Saves a JPG image file to \a fileName on disc. The output plot will have the dimensions \a width + and \a height in pixels. If either \a width or \a height is zero, the exported image will have + the same dimensions as the QCustomPlot widget currently has. Line widths and texts etc. are not + scaled up when larger widths/heights are used. If you want that effect, use the \a scale parameter. + + For example, if you set both \a width and \a height to 100 and \a scale to 2, you will end up with an + image file of size 200*200 in which all graphical elements are scaled up by factor 2 (line widths, + texts, etc.). This scaling is not done by stretching a 100*100 image, the result will have full + 200*200 pixel resolution. + + If you use a high scaling factor, it is recommended to enable antialiasing for all elements via + temporarily setting \ref QCustomPlot::setAntialiasedElements to \ref QCP::aeAll as this allows + QCustomPlot to place objects with sub-pixel accuracy. + + \warning If calling this function inside the constructor of the parent of the QCustomPlot widget + (i.e. the MainWindow constructor, if QCustomPlot is inside the MainWindow), always provide + explicit non-zero widths and heights. If you leave \a width or \a height as 0 (default), this + function uses the current width and height of the QCustomPlot widget. However, in Qt, these + aren't defined yet inside the constructor, so you would get an image that has strange + widths/heights. + + The objects of the plot will appear in the current selection state. If you don't want any selected + objects to be painted in their selected look, deselect everything with \ref deselectAll before calling + this function. + + JPG compression can be controlled with the \a quality parameter which must be between 0 and 100 or + -1 to use the default setting. + + Returns true on success. If this function fails, most likely the JPG format isn't supported by + the system, see Qt docs about QImageWriter::supportedImageFormats(). + + \see savePdf, savePng, saveBmp, saveRastered +*/ +bool QCustomPlot::saveJpg(const QString &fileName, int width, int height, double scale, int quality) +{ + return saveRastered(fileName, width, height, scale, "JPG", quality); +} + +/*! + Saves a BMP image file to \a fileName on disc. The output plot will have the dimensions \a width + and \a height in pixels. If either \a width or \a height is zero, the exported image will have + the same dimensions as the QCustomPlot widget currently has. Line widths and texts etc. are not + scaled up when larger widths/heights are used. If you want that effect, use the \a scale parameter. + + For example, if you set both \a width and \a height to 100 and \a scale to 2, you will end up with an + image file of size 200*200 in which all graphical elements are scaled up by factor 2 (line widths, + texts, etc.). This scaling is not done by stretching a 100*100 image, the result will have full + 200*200 pixel resolution. + + If you use a high scaling factor, it is recommended to enable antialiasing for all elements via + temporarily setting \ref QCustomPlot::setAntialiasedElements to \ref QCP::aeAll as this allows + QCustomPlot to place objects with sub-pixel accuracy. + + \warning If calling this function inside the constructor of the parent of the QCustomPlot widget + (i.e. the MainWindow constructor, if QCustomPlot is inside the MainWindow), always provide + explicit non-zero widths and heights. If you leave \a width or \a height as 0 (default), this + function uses the current width and height of the QCustomPlot widget. However, in Qt, these + aren't defined yet inside the constructor, so you would get an image that has strange + widths/heights. + + The objects of the plot will appear in the current selection state. If you don't want any selected + objects to be painted in their selected look, deselect everything with \ref deselectAll before calling + this function. + + Returns true on success. If this function fails, most likely the BMP format isn't supported by + the system, see Qt docs about QImageWriter::supportedImageFormats(). + + \see savePdf, savePng, saveJpg, saveRastered +*/ +bool QCustomPlot::saveBmp(const QString &fileName, int width, int height, double scale) +{ + return saveRastered(fileName, width, height, scale, "BMP"); +} + +/*! \internal + + Returns a minimum size hint that corresponds to the minimum size of the top level layout + (\ref plotLayout). To prevent QCustomPlot from being collapsed to size/width zero, set a minimum + size (setMinimumSize) either on the whole QCustomPlot or on any layout elements inside the plot. + This is especially important, when placed in a QLayout where other components try to take in as + much space as possible (e.g. QMdiArea). +*/ +QSize QCustomPlot::minimumSizeHint() const +{ + return mPlotLayout->minimumSizeHint(); +} + +/*! \internal + + Returns a size hint that is the same as \ref minimumSizeHint. + +*/ +QSize QCustomPlot::sizeHint() const +{ + return mPlotLayout->minimumSizeHint(); +} + +/*! \internal + + Event handler for when the QCustomPlot widget needs repainting. This does not cause a \ref replot, but + draws the internal buffer on the widget surface. +*/ +void QCustomPlot::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + QPainter painter(this); + painter.drawPixmap(0, 0, mPaintBuffer); +} + +/*! \internal + + Event handler for a resize of the QCustomPlot widget. Causes the internal buffer to be resized to + the new size. The viewport (which becomes the outer rect of mPlotLayout) is resized + appropriately. Finally a \ref replot is performed. +*/ +void QCustomPlot::resizeEvent(QResizeEvent *event) +{ + // resize and repaint the buffer: + mPaintBuffer = QPixmap(event->size()); + setViewport(rect()); + replot(rpQueued); // queued update is important here, to prevent painting issues in some contexts +} + +/*! \internal + + Event handler for when a double click occurs. Emits the \ref mouseDoubleClick signal, then emits + the specialized signals when certain objecs are clicked (e.g. \ref plottableDoubleClick, \ref + axisDoubleClick, etc.). Finally determines the affected layout element and forwards the event to + it. + + \see mousePressEvent, mouseReleaseEvent +*/ +void QCustomPlot::mouseDoubleClickEvent(QMouseEvent *event) +{ + emit mouseDoubleClick(event); + + QVariant details; + QCPLayerable *clickedLayerable = layerableAt(event->pos(), false, &details); + + // emit specialized object double click signals: + if (QCPAbstractPlottable *ap = qobject_cast(clickedLayerable)) + emit plottableDoubleClick(ap, event); + else if (QCPAxis *ax = qobject_cast(clickedLayerable)) + emit axisDoubleClick(ax, details.value(), event); + else if (QCPAbstractItem *ai = qobject_cast(clickedLayerable)) + emit itemDoubleClick(ai, event); + else if (QCPLegend *lg = qobject_cast(clickedLayerable)) + emit legendDoubleClick(lg, 0, event); + else if (QCPAbstractLegendItem *li = qobject_cast(clickedLayerable)) + emit legendDoubleClick(li->parentLegend(), li, event); + else if (QCPPlotTitle *pt = qobject_cast(clickedLayerable)) + emit titleDoubleClick(event, pt); + + // call double click event of affected layout element: + if (QCPLayoutElement *el = layoutElementAt(event->pos())) + el->mouseDoubleClickEvent(event); + + // call release event of affected layout element (as in mouseReleaseEvent, since the mouseDoubleClick replaces the second release event in double click case): + if (mMouseEventElement) + { + mMouseEventElement->mouseReleaseEvent(event); + mMouseEventElement = 0; + } + + //QWidget::mouseDoubleClickEvent(event); don't call base class implementation because it would just cause a mousePress/ReleaseEvent, which we don't want. +} + +/*! \internal + + Event handler for when a mouse button is pressed. Emits the mousePress signal. Then determines + the affected layout element and forwards the event to it. + + \see mouseMoveEvent, mouseReleaseEvent +*/ +void QCustomPlot::mousePressEvent(QMouseEvent *event) +{ + emit mousePress(event); + mMousePressPos = event->pos(); // need this to determine in releaseEvent whether it was a click (no position change between press and release) + + // call event of affected layout element: + mMouseEventElement = layoutElementAt(event->pos()); + if (mMouseEventElement) + mMouseEventElement->mousePressEvent(event); + + QWidget::mousePressEvent(event); +} + +/*! \internal + + Event handler for when the cursor is moved. Emits the \ref mouseMove signal. + + If a layout element has mouse capture focus (a mousePressEvent happened on top of the layout + element before), the mouseMoveEvent is forwarded to that element. + + \see mousePressEvent, mouseReleaseEvent +*/ +void QCustomPlot::mouseMoveEvent(QMouseEvent *event) +{ + emit mouseMove(event); + + // call event of affected layout element: + if (mMouseEventElement) + mMouseEventElement->mouseMoveEvent(event); + + QWidget::mouseMoveEvent(event); +} + +/*! \internal + + Event handler for when a mouse button is released. Emits the \ref mouseRelease signal. + + If the mouse was moved less than a certain threshold in any direction since the \ref + mousePressEvent, it is considered a click which causes the selection mechanism (if activated via + \ref setInteractions) to possibly change selection states accordingly. Further, specialized mouse + click signals are emitted (e.g. \ref plottableClick, \ref axisClick, etc.) + + If a layout element has mouse capture focus (a \ref mousePressEvent happened on top of the layout + element before), the \ref mouseReleaseEvent is forwarded to that element. + + \see mousePressEvent, mouseMoveEvent +*/ +void QCustomPlot::mouseReleaseEvent(QMouseEvent *event) +{ + emit mouseRelease(event); + bool doReplot = false; + + if ((mMousePressPos-event->pos()).manhattanLength() < 5) // determine whether it was a click operation + { + if (event->button() == Qt::LeftButton) + { + // handle selection mechanism: + QVariant details; + QCPLayerable *clickedLayerable = layerableAt(event->pos(), true, &details); + bool selectionStateChanged = false; + bool additive = mInteractions.testFlag(QCP::iMultiSelect) && event->modifiers().testFlag(mMultiSelectModifier); + // deselect all other layerables if not additive selection: + if (!additive) + { + foreach (QCPLayer *layer, mLayers) + { + foreach (QCPLayerable *layerable, layer->children()) + { + if (layerable != clickedLayerable && mInteractions.testFlag(layerable->selectionCategory())) + { + bool selChanged = false; + layerable->deselectEvent(&selChanged); + selectionStateChanged |= selChanged; + } + } + } + } + if (clickedLayerable && mInteractions.testFlag(clickedLayerable->selectionCategory())) + { + // a layerable was actually clicked, call its selectEvent: + bool selChanged = false; + clickedLayerable->selectEvent(event, additive, details, &selChanged); + selectionStateChanged |= selChanged; + } + doReplot = true; + if (selectionStateChanged) + emit selectionChangedByUser(); + } + + // emit specialized object click signals: + QVariant details; + QCPLayerable *clickedLayerable = layerableAt(event->pos(), false, &details); // for these signals, selectability is ignored, that's why we call this again with onlySelectable set to false + if (QCPAbstractPlottable *ap = qobject_cast(clickedLayerable)) + emit plottableClick(ap, event); + else if (QCPAxis *ax = qobject_cast(clickedLayerable)) + emit axisClick(ax, details.value(), event); + else if (QCPAbstractItem *ai = qobject_cast(clickedLayerable)) + emit itemClick(ai, event); + else if (QCPLegend *lg = qobject_cast(clickedLayerable)) + emit legendClick(lg, 0, event); + else if (QCPAbstractLegendItem *li = qobject_cast(clickedLayerable)) + emit legendClick(li->parentLegend(), li, event); + else if (QCPPlotTitle *pt = qobject_cast(clickedLayerable)) + emit titleClick(event, pt); + } + + // call event of affected layout element: + if (mMouseEventElement) + { + mMouseEventElement->mouseReleaseEvent(event); + mMouseEventElement = 0; + } + + if (doReplot || noAntialiasingOnDrag()) + replot(); + + QWidget::mouseReleaseEvent(event); +} + +/*! \internal + + Event handler for mouse wheel events. First, the \ref mouseWheel signal is emitted. Then + determines the affected layout element and forwards the event to it. + +*/ +void QCustomPlot::wheelEvent(QWheelEvent *event) +{ + emit mouseWheel(event); + + // call event of affected layout element: + if (QCPLayoutElement *el = layoutElementAt(event->pos())) + el->wheelEvent(event); + + QWidget::wheelEvent(event); +} + +/*! \internal + + This is the main draw function. It draws the entire plot, including background pixmap, with the + specified \a painter. Note that it does not fill the background with the background brush (as the + user may specify with \ref setBackground(const QBrush &brush)), this is up to the respective + functions calling this method (e.g. \ref replot, \ref toPixmap and \ref toPainter). +*/ +void QCustomPlot::draw(QCPPainter *painter) +{ + // run through layout phases: + mPlotLayout->update(QCPLayoutElement::upPreparation); + mPlotLayout->update(QCPLayoutElement::upMargins); + mPlotLayout->update(QCPLayoutElement::upLayout); + + // draw viewport background pixmap: + drawBackground(painter); + + // draw all layered objects (grid, axes, plottables, items, legend,...): + foreach (QCPLayer *layer, mLayers) + { + foreach (QCPLayerable *child, layer->children()) + { + if (child->realVisibility()) + { + painter->save(); + painter->setClipRect(child->clipRect().translated(0, -1)); + child->applyDefaultAntialiasingHint(painter); + child->draw(painter); + painter->restore(); + } + } + } + + /* Debug code to draw all layout element rects + foreach (QCPLayoutElement* el, findChildren()) + { + painter->setBrush(Qt::NoBrush); + painter->setPen(QPen(QColor(0, 0, 0, 100), 0, Qt::DashLine)); + painter->drawRect(el->rect()); + painter->setPen(QPen(QColor(255, 0, 0, 100), 0, Qt::DashLine)); + painter->drawRect(el->outerRect()); + } + */ +} + +/*! \internal + + Draws the viewport background pixmap of the plot. + + If a pixmap was provided via \ref setBackground, this function buffers the scaled version + depending on \ref setBackgroundScaled and \ref setBackgroundScaledMode and then draws it inside + the viewport with the provided \a painter. The scaled version is buffered in + mScaledBackgroundPixmap to prevent expensive rescaling at every redraw. It is only updated, when + the axis rect has changed in a way that requires a rescale of the background pixmap (this is + dependent on the \ref setBackgroundScaledMode), or when a differend axis background pixmap was + set. + + Note that this function does not draw a fill with the background brush (\ref setBackground(const + QBrush &brush)) beneath the pixmap. + + \see setBackground, setBackgroundScaled, setBackgroundScaledMode +*/ +void QCustomPlot::drawBackground(QCPPainter *painter) +{ + // Note: background color is handled in individual replot/save functions + + // draw background pixmap (on top of fill, if brush specified): + if (!mBackgroundPixmap.isNull()) + { + if (mBackgroundScaled) + { + // check whether mScaledBackground needs to be updated: + QSize scaledSize(mBackgroundPixmap.size()); + scaledSize.scale(mViewport.size(), mBackgroundScaledMode); + if (mScaledBackgroundPixmap.size() != scaledSize) + mScaledBackgroundPixmap = mBackgroundPixmap.scaled(mViewport.size(), mBackgroundScaledMode, Qt::SmoothTransformation); + painter->drawPixmap(mViewport.topLeft(), mScaledBackgroundPixmap, QRect(0, 0, mViewport.width(), mViewport.height()) & mScaledBackgroundPixmap.rect()); + } else + { + painter->drawPixmap(mViewport.topLeft(), mBackgroundPixmap, QRect(0, 0, mViewport.width(), mViewport.height())); + } + } +} + + +/*! \internal + + This method is used by \ref QCPAxisRect::removeAxis to report removed axes to the QCustomPlot + so it may clear its QCustomPlot::xAxis, yAxis, xAxis2 and yAxis2 members accordingly. +*/ +void QCustomPlot::axisRemoved(QCPAxis *axis) +{ + if (xAxis == axis) + xAxis = 0; + if (xAxis2 == axis) + xAxis2 = 0; + if (yAxis == axis) + yAxis = 0; + if (yAxis2 == axis) + yAxis2 = 0; + + // Note: No need to take care of range drag axes and range zoom axes, because they are stored in smart pointers +} + +/*! \internal + + This method is used by the QCPLegend destructor to report legend removal to the QCustomPlot so + it may clear its QCustomPlot::legend member accordingly. +*/ +void QCustomPlot::legendRemoved(QCPLegend *legend) +{ + if (this->legend == legend) + this->legend = 0; +} + +/*! \internal + + Assigns all layers their index (QCPLayer::mIndex) in the mLayers list. This method is thus called + after every operation that changes the layer indices, like layer removal, layer creation, layer + moving. +*/ +void QCustomPlot::updateLayerIndices() const +{ + for (int i=0; imIndex = i; +} + +/*! \internal + + Returns the layerable at pixel position \a pos. If \a onlySelectable is set to true, only those + layerables that are selectable will be considered. (Layerable subclasses communicate their + selectability via the QCPLayerable::selectTest method, by returning -1.) + + \a selectionDetails is an output parameter that contains selection specifics of the affected + layerable. This is useful if the respective layerable shall be given a subsequent + QCPLayerable::selectEvent (like in \ref mouseReleaseEvent). \a selectionDetails usually contains + information about which part of the layerable was hit, in multi-part layerables (e.g. + QCPAxis::SelectablePart). +*/ +QCPLayerable *QCustomPlot::layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails) const +{ + for (int layerIndex=mLayers.size()-1; layerIndex>=0; --layerIndex) + { + const QList layerables = mLayers.at(layerIndex)->children(); + double minimumDistance = selectionTolerance()*1.1; + QCPLayerable *minimumDistanceLayerable = 0; + for (int i=layerables.size()-1; i>=0; --i) + { + if (!layerables.at(i)->realVisibility()) + continue; + QVariant details; + double dist = layerables.at(i)->selectTest(pos, onlySelectable, &details); + if (dist >= 0 && dist < minimumDistance) + { + minimumDistance = dist; + minimumDistanceLayerable = layerables.at(i); + if (selectionDetails) *selectionDetails = details; + } + } + if (minimumDistance < selectionTolerance()) + return minimumDistanceLayerable; + } + return 0; +} + +/*! + Saves the plot to a rastered image file \a fileName in the image format \a format. The plot is + sized to \a width and \a height in pixels and scaled with \a scale. (width 100 and scale 2.0 lead + to a full resolution file with width 200.) If the \a format supports compression, \a quality may + be between 0 and 100 to control it. + + Returns true on success. If this function fails, most likely the given \a format isn't supported + by the system, see Qt docs about QImageWriter::supportedImageFormats(). + + \see saveBmp, saveJpg, savePng, savePdf +*/ +bool QCustomPlot::saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality) +{ + QPixmap buffer = toPixmap(width, height, scale); + if (!buffer.isNull()) + return buffer.save(fileName, format, quality); + else + return false; +} + +/*! + Renders the plot to a pixmap and returns it. + + The plot is sized to \a width and \a height in pixels and scaled with \a scale. (width 100 and + scale 2.0 lead to a full resolution pixmap with width 200.) + + \see toPainter, saveRastered, saveBmp, savePng, saveJpg, savePdf +*/ +QPixmap QCustomPlot::toPixmap(int width, int height, double scale) +{ + // this method is somewhat similar to toPainter. Change something here, and a change in toPainter might be necessary, too. + int newWidth, newHeight; + if (width == 0 || height == 0) + { + newWidth = this->width(); + newHeight = this->height(); + } else + { + newWidth = width; + newHeight = height; + } + int scaledWidth = qRound(scale*newWidth); + int scaledHeight = qRound(scale*newHeight); + + QPixmap result(scaledWidth, scaledHeight); + result.fill(mBackgroundBrush.style() == Qt::SolidPattern ? mBackgroundBrush.color() : Qt::transparent); // if using non-solid pattern, make transparent now and draw brush pattern later + QCPPainter painter; + painter.begin(&result); + if (painter.isActive()) + { + QRect oldViewport = viewport(); + setViewport(QRect(0, 0, newWidth, newHeight)); + painter.setMode(QCPPainter::pmNoCaching); + if (!qFuzzyCompare(scale, 1.0)) + { + if (scale > 1.0) // for scale < 1 we always want cosmetic pens where possible, because else lines might disappear for very small scales + painter.setMode(QCPPainter::pmNonCosmetic); + painter.scale(scale, scale); + } + if (mBackgroundBrush.style() != Qt::SolidPattern && mBackgroundBrush.style() != Qt::NoBrush) + painter.fillRect(mViewport, mBackgroundBrush); + draw(&painter); + setViewport(oldViewport); + painter.end(); + } else // might happen if pixmap has width or height zero + { + qDebug() << Q_FUNC_INFO << "Couldn't activate painter on pixmap"; + return QPixmap(); + } + return result; +} + +/*! + Renders the plot using the passed \a painter. + + The plot is sized to \a width and \a height in pixels. If the \a painter's scale is not 1.0, the resulting plot will + appear scaled accordingly. + + \note If you are restricted to using a QPainter (instead of QCPPainter), create a temporary QPicture and open a QCPPainter + on it. Then call \ref toPainter with this QCPPainter. After ending the paint operation on the picture, draw it with + the QPainter. This will reproduce the painter actions the QCPPainter took, with a QPainter. + + \see toPixmap +*/ +void QCustomPlot::toPainter(QCPPainter *painter, int width, int height) +{ + // this method is somewhat similar to toPixmap. Change something here, and a change in toPixmap might be necessary, too. + int newWidth, newHeight; + if (width == 0 || height == 0) + { + newWidth = this->width(); + newHeight = this->height(); + } else + { + newWidth = width; + newHeight = height; + } + + if (painter->isActive()) + { + QRect oldViewport = viewport(); + setViewport(QRect(0, 0, newWidth, newHeight)); + painter->setMode(QCPPainter::pmNoCaching); + // warning: the following is different in toPixmap, because a solid background color is applied there via QPixmap::fill + // here, we need to do this via QPainter::fillRect. + if (mBackgroundBrush.style() != Qt::NoBrush) + painter->fillRect(mViewport, mBackgroundBrush); + draw(painter); + setViewport(oldViewport); + } else + qDebug() << Q_FUNC_INFO << "Passed painter is not active"; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPColorGradient +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPColorGradient + \brief Defines a color gradient for use with e.g. \ref QCPColorMap + + This class describes a color gradient which can be used to encode data with color. For example, + QCPColorMap and QCPColorScale have \ref QCPColorMap::setGradient "setGradient" methods which + take an instance of this class. Colors are set with \ref setColorStopAt(double position, const QColor &color) + with a \a position from 0 to 1. In between these defined color positions, the + color will be interpolated linearly either in RGB or HSV space, see \ref setColorInterpolation. + + Alternatively, load one of the preset color gradients shown in the image below, with \ref + loadPreset, or by directly specifying the preset in the constructor. + + \image html QCPColorGradient.png + + The fact that the \ref QCPColorGradient(GradientPreset preset) constructor allows directly + converting a \ref GradientPreset to a QCPColorGradient, you can also directly pass \ref + GradientPreset to all the \a setGradient methods, e.g.: + \code + colorMap->setGradient(QCPColorGradient::gpHot); + \endcode + + The total number of levels used in the gradient can be set with \ref setLevelCount. Whether the + color gradient shall be applied periodically (wrapping around) to data values that lie outside + the data range specified on the plottable instance can be controlled with \ref setPeriodic. +*/ + +/*! + Constructs a new QCPColorGradient initialized with the colors and color interpolation according + to \a preset. + + The color level count is initialized to 350. +*/ +QCPColorGradient::QCPColorGradient(GradientPreset preset) : + mLevelCount(350), + mColorInterpolation(ciRGB), + mPeriodic(false), + mColorBufferInvalidated(true) +{ + mColorBuffer.fill(qRgb(0, 0, 0), mLevelCount); + loadPreset(preset); +} + +/* undocumented operator */ +bool QCPColorGradient::operator==(const QCPColorGradient &other) const +{ + return ((other.mLevelCount == this->mLevelCount) && + (other.mColorInterpolation == this->mColorInterpolation) && + (other.mPeriodic == this->mPeriodic) && + (other.mColorStops == this->mColorStops)); +} + +/*! + Sets the number of discretization levels of the color gradient to \a n. The default is 350 which + is typically enough to create a smooth appearance. + + \image html QCPColorGradient-levelcount.png +*/ +void QCPColorGradient::setLevelCount(int n) +{ + if (n < 2) + { + qDebug() << Q_FUNC_INFO << "n must be greater or equal 2 but was" << n; + n = 2; + } + if (n != mLevelCount) + { + mLevelCount = n; + mColorBufferInvalidated = true; + } +} + +/*! + Sets at which positions from 0 to 1 which color shall occur. The positions are the keys, the + colors are the values of the passed QMap \a colorStops. In between these color stops, the color + is interpolated according to \ref setColorInterpolation. + + A more convenient way to create a custom gradient may be to clear all color stops with \ref + clearColorStops and then adding them one by one with \ref setColorStopAt. + + \see clearColorStops +*/ +void QCPColorGradient::setColorStops(const QMap &colorStops) +{ + mColorStops = colorStops; + mColorBufferInvalidated = true; +} + +/*! + Sets the \a color the gradient will have at the specified \a position (from 0 to 1). In between + these color stops, the color is interpolated according to \ref setColorInterpolation. + + \see setColorStops, clearColorStops +*/ +void QCPColorGradient::setColorStopAt(double position, const QColor &color) +{ + mColorStops.insert(position, color); + mColorBufferInvalidated = true; +} + +/*! + Sets whether the colors in between the configured color stops (see \ref setColorStopAt) shall be + interpolated linearly in RGB or in HSV color space. + + For example, a sweep in RGB space from red to green will have a muddy brown intermediate color, + whereas in HSV space the intermediate color is yellow. +*/ +void QCPColorGradient::setColorInterpolation(QCPColorGradient::ColorInterpolation interpolation) +{ + if (interpolation != mColorInterpolation) + { + mColorInterpolation = interpolation; + mColorBufferInvalidated = true; + } +} + +/*! + Sets whether data points that are outside the configured data range (e.g. \ref + QCPColorMap::setDataRange) are colored by periodically repeating the color gradient or whether + they all have the same color, corresponding to the respective gradient boundary color. + + \image html QCPColorGradient-periodic.png + + As shown in the image above, gradients that have the same start and end color are especially + suitable for a periodic gradient mapping, since they produce smooth color transitions throughout + the color map. A preset that has this property is \ref gpHues. + + In practice, using periodic color gradients makes sense when the data corresponds to a periodic + dimension, such as an angle or a phase. If this is not the case, the color encoding might become + ambiguous, because multiple different data values are shown as the same color. +*/ +void QCPColorGradient::setPeriodic(bool enabled) +{ + mPeriodic = enabled; +} + +/*! + This method is used to quickly convert a \a data array to colors. The colors will be output in + the array \a scanLine. Both \a data and \a scanLine must have the length \a n when passed to this + function. The data range that shall be used for mapping the data value to the gradient is passed + in \a range. \a logarithmic indicates whether the data values shall be mapped to colors + logarithmically. + + if \a data actually contains 2D-data linearized via [row*columnCount + column], you can + set \a dataIndexFactor to columnCount to convert a column instead of a row of the data + array, in \a scanLine. \a scanLine will remain a regular (1D) array. This works because \a data + is addressed data[i*dataIndexFactor]. +*/ +void QCPColorGradient::colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor, bool logarithmic) +{ + // If you change something here, make sure to also adapt ::color() + if (!data) + { + qDebug() << Q_FUNC_INFO << "null pointer given as data"; + return; + } + if (!scanLine) + { + qDebug() << Q_FUNC_INFO << "null pointer given as scanLine"; + return; + } + if (mColorBufferInvalidated) + updateColorBuffer(); + + if (!logarithmic) + { + const double posToIndexFactor = mLevelCount/range.size(); + if (mPeriodic) + { + for (int i=0; i= mLevelCount) + index = mLevelCount-1; + scanLine[i] = mColorBuffer.at(index); + } + } + } else // logarithmic == true + { + if (mPeriodic) + { + for (int i=0; i= mLevelCount) + index = mLevelCount-1; + scanLine[i] = mColorBuffer.at(index); + } + } + } +} + +/*! \internal + + This method is used to colorize a single data value given in \a position, to colors. The data + range that shall be used for mapping the data value to the gradient is passed in \a range. \a + logarithmic indicates whether the data value shall be mapped to a color logarithmically. + + If an entire array of data values shall be converted, rather use \ref colorize, for better + performance. +*/ +QRgb QCPColorGradient::color(double position, const QCPRange &range, bool logarithmic) +{ + // If you change something here, make sure to also adapt ::colorize() + if (mColorBufferInvalidated) + updateColorBuffer(); + int index = 0; + if (!logarithmic) + index = (position-range.lower)*mLevelCount/range.size(); + else + index = qLn(position/range.lower)/qLn(range.upper/range.lower)*mLevelCount; + if (mPeriodic) + { + index = index % mLevelCount; + if (index < 0) + index += mLevelCount; + } else + { + if (index < 0) + index = 0; + else if (index >= mLevelCount) + index = mLevelCount-1; + } + return mColorBuffer.at(index); +} + +/*! + Clears the current color stops and loads the specified \a preset. A preset consists of predefined + color stops and the corresponding color interpolation method. + + The available presets are: + \image html QCPColorGradient.png +*/ +void QCPColorGradient::loadPreset(GradientPreset preset) +{ + clearColorStops(); + switch (preset) + { + case gpGrayscale: + setColorInterpolation(ciRGB); + setColorStopAt(0, Qt::black); + setColorStopAt(1, Qt::white); + break; + case gpHot: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(50, 0, 0)); + setColorStopAt(0.2, QColor(180, 10, 0)); + setColorStopAt(0.4, QColor(245, 50, 0)); + setColorStopAt(0.6, QColor(255, 150, 10)); + setColorStopAt(0.8, QColor(255, 255, 50)); + setColorStopAt(1, QColor(255, 255, 255)); + break; + case gpCold: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(0, 0, 50)); + setColorStopAt(0.2, QColor(0, 10, 180)); + setColorStopAt(0.4, QColor(0, 50, 245)); + setColorStopAt(0.6, QColor(10, 150, 255)); + setColorStopAt(0.8, QColor(50, 255, 255)); + setColorStopAt(1, QColor(255, 255, 255)); + break; + case gpNight: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(10, 20, 30)); + setColorStopAt(1, QColor(250, 255, 250)); + break; + case gpCandy: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(0, 0, 255)); + setColorStopAt(1, QColor(255, 250, 250)); + break; + case gpGeography: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(70, 170, 210)); + setColorStopAt(0.20, QColor(90, 160, 180)); + setColorStopAt(0.25, QColor(45, 130, 175)); + setColorStopAt(0.30, QColor(100, 140, 125)); + setColorStopAt(0.5, QColor(100, 140, 100)); + setColorStopAt(0.6, QColor(130, 145, 120)); + setColorStopAt(0.7, QColor(140, 130, 120)); + setColorStopAt(0.9, QColor(180, 190, 190)); + setColorStopAt(1, QColor(210, 210, 230)); + break; + case gpIon: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(50, 10, 10)); + setColorStopAt(0.45, QColor(0, 0, 255)); + setColorStopAt(0.8, QColor(0, 255, 255)); + setColorStopAt(1, QColor(0, 255, 0)); + break; + case gpThermal: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(0, 0, 50)); + setColorStopAt(0.15, QColor(20, 0, 120)); + setColorStopAt(0.33, QColor(200, 30, 140)); + setColorStopAt(0.6, QColor(255, 100, 0)); + setColorStopAt(0.85, QColor(255, 255, 40)); + setColorStopAt(1, QColor(255, 255, 255)); + break; + case gpPolar: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(50, 255, 255)); + setColorStopAt(0.18, QColor(10, 70, 255)); + setColorStopAt(0.28, QColor(10, 10, 190)); + setColorStopAt(0.5, QColor(0, 0, 0)); + setColorStopAt(0.72, QColor(190, 10, 10)); + setColorStopAt(0.82, QColor(255, 70, 10)); + setColorStopAt(1, QColor(255, 255, 50)); + break; + case gpSpectrum: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(50, 0, 50)); + setColorStopAt(0.15, QColor(0, 0, 255)); + setColorStopAt(0.35, QColor(0, 255, 255)); + setColorStopAt(0.6, QColor(255, 255, 0)); + setColorStopAt(0.75, QColor(255, 30, 0)); + setColorStopAt(1, QColor(50, 0, 0)); + break; + case gpJet: + setColorInterpolation(ciRGB); + setColorStopAt(0, QColor(0, 0, 100)); + setColorStopAt(0.15, QColor(0, 50, 255)); + setColorStopAt(0.35, QColor(0, 255, 255)); + setColorStopAt(0.65, QColor(255, 255, 0)); + setColorStopAt(0.85, QColor(255, 30, 0)); + setColorStopAt(1, QColor(100, 0, 0)); + break; + case gpHues: + setColorInterpolation(ciHSV); + setColorStopAt(0, QColor(255, 0, 0)); + setColorStopAt(1.0/3.0, QColor(0, 0, 255)); + setColorStopAt(2.0/3.0, QColor(0, 255, 0)); + setColorStopAt(1, QColor(255, 0, 0)); + break; + } +} + +/*! + Clears all color stops. + + \see setColorStops, setColorStopAt +*/ +void QCPColorGradient::clearColorStops() +{ + mColorStops.clear(); + mColorBufferInvalidated = true; +} + +/*! + Returns an inverted gradient. The inverted gradient has all properties as this \ref + QCPColorGradient, but the order of the color stops is inverted. + + \see setColorStops, setColorStopAt +*/ +QCPColorGradient QCPColorGradient::inverted() const +{ + QCPColorGradient result(*this); + result.clearColorStops(); + for (QMap::const_iterator it=mColorStops.constBegin(); it!=mColorStops.constEnd(); ++it) + result.setColorStopAt(1.0-it.key(), it.value()); + return result; +} + +/*! \internal + + Updates the internal color buffer which will be used by \ref colorize and \ref color, to quickly + convert positions to colors. This is where the interpolation between color stops is calculated. +*/ +void QCPColorGradient::updateColorBuffer() +{ + if (mColorBuffer.size() != mLevelCount) + mColorBuffer.resize(mLevelCount); + if (mColorStops.size() > 1) + { + double indexToPosFactor = 1.0/(double)(mLevelCount-1); + for (int i=0; i::const_iterator it = mColorStops.lowerBound(position); + if (it == mColorStops.constEnd()) // position is on or after last stop, use color of last stop + { + mColorBuffer[i] = (it-1).value().rgb(); + } else if (it == mColorStops.constBegin()) // position is on or before first stop, use color of first stop + { + mColorBuffer[i] = it.value().rgb(); + } else // position is in between stops (or on an intermediate stop), interpolate color + { + QMap::const_iterator high = it; + QMap::const_iterator low = it-1; + double t = (position-low.key())/(high.key()-low.key()); // interpolation factor 0..1 + switch (mColorInterpolation) + { + case ciRGB: + { + mColorBuffer[i] = qRgb((1-t)*low.value().red() + t*high.value().red(), + (1-t)*low.value().green() + t*high.value().green(), + (1-t)*low.value().blue() + t*high.value().blue()); + break; + } + case ciHSV: + { + QColor lowHsv = low.value().toHsv(); + QColor highHsv = high.value().toHsv(); + double hue = 0; + double hueDiff = highHsv.hueF()-lowHsv.hueF(); + if (hueDiff > 0.5) + hue = lowHsv.hueF() - t*(1.0-hueDiff); + else if (hueDiff < -0.5) + hue = lowHsv.hueF() + t*(1.0+hueDiff); + else + hue = lowHsv.hueF() + t*hueDiff; + if (hue < 0) hue += 1.0; + else if (hue >= 1.0) hue -= 1.0; + mColorBuffer[i] = QColor::fromHsvF(hue, (1-t)*lowHsv.saturationF() + t*highHsv.saturationF(), (1-t)*lowHsv.valueF() + t*highHsv.valueF()).rgb(); + break; + } + } + } + } + } else if (mColorStops.size() == 1) + { + mColorBuffer.fill(mColorStops.constBegin().value().rgb()); + } else // mColorStops is empty, fill color buffer with black + { + mColorBuffer.fill(qRgb(0, 0, 0)); + } + mColorBufferInvalidated = false; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPAxisRect +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPAxisRect + \brief Holds multiple axes and arranges them in a rectangular shape. + + This class represents an axis rect, a rectangular area that is bounded on all sides with an + arbitrary number of axes. + + Initially QCustomPlot has one axis rect, accessible via QCustomPlot::axisRect(). However, the + layout system allows to have multiple axis rects, e.g. arranged in a grid layout + (QCustomPlot::plotLayout). + + By default, QCPAxisRect comes with four axes, at bottom, top, left and right. They can be + accessed via \ref axis by providing the respective axis type (\ref QCPAxis::AxisType) and index. + If you need all axes in the axis rect, use \ref axes. The top and right axes are set to be + invisible initially (QCPAxis::setVisible). To add more axes to a side, use \ref addAxis or \ref + addAxes. To remove an axis, use \ref removeAxis. + + The axis rect layerable itself only draws a background pixmap or color, if specified (\ref + setBackground). It is placed on the "background" layer initially (see \ref QCPLayer for an + explanation of the QCustomPlot layer system). The axes that are held by the axis rect can be + placed on other layers, independently of the axis rect. + + Every axis rect has a child layout of type \ref QCPLayoutInset. It is accessible via \ref + insetLayout and can be used to have other layout elements (or even other layouts with multiple + elements) hovering inside the axis rect. + + If an axis rect is clicked and dragged, it processes this by moving certain axis ranges. The + behaviour can be controlled with \ref setRangeDrag and \ref setRangeDragAxes. If the mouse wheel + is scrolled while the cursor is on the axis rect, certain axes are scaled. This is controllable + via \ref setRangeZoom, \ref setRangeZoomAxes and \ref setRangeZoomFactor. These interactions are + only enabled if \ref QCustomPlot::setInteractions contains \ref QCP::iRangeDrag and \ref + QCP::iRangeZoom. + + \image html AxisRectSpacingOverview.png +
Overview of the spacings and paddings that define the geometry of an axis. The dashed + line on the far left indicates the viewport/widget border.
+*/ + +/* start documentation of inline functions */ + +/*! \fn QCPLayoutInset *QCPAxisRect::insetLayout() const + + Returns the inset layout of this axis rect. It can be used to place other layout elements (or + even layouts with multiple other elements) inside/on top of an axis rect. + + \see QCPLayoutInset +*/ + +/*! \fn int QCPAxisRect::left() const + + Returns the pixel position of the left border of this axis rect. Margins are not taken into + account here, so the returned value is with respect to the inner \ref rect. +*/ + +/*! \fn int QCPAxisRect::right() const + + Returns the pixel position of the right border of this axis rect. Margins are not taken into + account here, so the returned value is with respect to the inner \ref rect. +*/ + +/*! \fn int QCPAxisRect::top() const + + Returns the pixel position of the top border of this axis rect. Margins are not taken into + account here, so the returned value is with respect to the inner \ref rect. +*/ + +/*! \fn int QCPAxisRect::bottom() const + + Returns the pixel position of the bottom border of this axis rect. Margins are not taken into + account here, so the returned value is with respect to the inner \ref rect. +*/ + +/*! \fn int QCPAxisRect::width() const + + Returns the pixel width of this axis rect. Margins are not taken into account here, so the + returned value is with respect to the inner \ref rect. +*/ + +/*! \fn int QCPAxisRect::height() const + + Returns the pixel height of this axis rect. Margins are not taken into account here, so the + returned value is with respect to the inner \ref rect. +*/ + +/*! \fn QSize QCPAxisRect::size() const + + Returns the pixel size of this axis rect. Margins are not taken into account here, so the + returned value is with respect to the inner \ref rect. +*/ + +/*! \fn QPoint QCPAxisRect::topLeft() const + + Returns the top left corner of this axis rect in pixels. Margins are not taken into account here, + so the returned value is with respect to the inner \ref rect. +*/ + +/*! \fn QPoint QCPAxisRect::topRight() const + + Returns the top right corner of this axis rect in pixels. Margins are not taken into account + here, so the returned value is with respect to the inner \ref rect. +*/ + +/*! \fn QPoint QCPAxisRect::bottomLeft() const + + Returns the bottom left corner of this axis rect in pixels. Margins are not taken into account + here, so the returned value is with respect to the inner \ref rect. +*/ + +/*! \fn QPoint QCPAxisRect::bottomRight() const + + Returns the bottom right corner of this axis rect in pixels. Margins are not taken into account + here, so the returned value is with respect to the inner \ref rect. +*/ + +/*! \fn QPoint QCPAxisRect::center() const + + Returns the center of this axis rect in pixels. Margins are not taken into account here, so the + returned value is with respect to the inner \ref rect. +*/ + +/* end documentation of inline functions */ + +/*! + Creates a QCPAxisRect instance and sets default values. An axis is added for each of the four + sides, the top and right axes are set invisible initially. +*/ +QCPAxisRect::QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes) : + QCPLayoutElement(parentPlot), + mBackgroundBrush(Qt::NoBrush), + mBackgroundScaled(true), + mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding), + mInsetLayout(new QCPLayoutInset), + mRangeDrag(Qt::Horizontal|Qt::Vertical), + mRangeZoom(Qt::Horizontal|Qt::Vertical), + mRangeZoomFactorHorz(0.85), + mRangeZoomFactorVert(0.85), + mDragging(false) +{ + mInsetLayout->initializeParentPlot(mParentPlot); + mInsetLayout->setParentLayerable(this); + mInsetLayout->setParent(this); + + setMinimumSize(50, 50); + setMinimumMargins(QMargins(15, 15, 15, 15)); + mAxes.insert(QCPAxis::atLeft, QList()); + mAxes.insert(QCPAxis::atRight, QList()); + mAxes.insert(QCPAxis::atTop, QList()); + mAxes.insert(QCPAxis::atBottom, QList()); + + if (setupDefaultAxes) + { + QCPAxis *xAxis = addAxis(QCPAxis::atBottom); + QCPAxis *yAxis = addAxis(QCPAxis::atLeft); + QCPAxis *xAxis2 = addAxis(QCPAxis::atTop); + QCPAxis *yAxis2 = addAxis(QCPAxis::atRight); + setRangeDragAxes(xAxis, yAxis); + setRangeZoomAxes(xAxis, yAxis); + xAxis2->setVisible(false); + yAxis2->setVisible(false); + xAxis->grid()->setVisible(true); + yAxis->grid()->setVisible(true); + xAxis2->grid()->setVisible(false); + yAxis2->grid()->setVisible(false); + xAxis2->grid()->setZeroLinePen(Qt::NoPen); + yAxis2->grid()->setZeroLinePen(Qt::NoPen); + xAxis2->grid()->setVisible(false); + yAxis2->grid()->setVisible(false); + } +} + +QCPAxisRect::~QCPAxisRect() +{ +// delete mInsetLayout; +// mInsetLayout = 0; + +// QList axesList = axes(); +// for (int i=0; i ax(mAxes.value(type)); + if (index >= 0 && index < ax.size()) + { + return ax.at(index); + } else + { + qDebug() << Q_FUNC_INFO << "Axis index out of bounds:" << index; + return 0; + } +} + +/*! + Returns all axes on the axis rect sides specified with \a types. + + \a types may be a single \ref QCPAxis::AxisType or an or-combination, to get the axes of + multiple sides. + + \see axis +*/ +QList QCPAxisRect::axes(QCPAxis::AxisTypes types) const +{ + QList result; + if (types.testFlag(QCPAxis::atLeft)) + result << mAxes.value(QCPAxis::atLeft); + if (types.testFlag(QCPAxis::atRight)) + result << mAxes.value(QCPAxis::atRight); + if (types.testFlag(QCPAxis::atTop)) + result << mAxes.value(QCPAxis::atTop); + if (types.testFlag(QCPAxis::atBottom)) + result << mAxes.value(QCPAxis::atBottom); + return result; +} + +/*! \overload + + Returns all axes of this axis rect. +*/ +QList QCPAxisRect::axes() const +{ + QList result; + QHashIterator > it(mAxes); + while (it.hasNext()) + { + it.next(); + result << it.value(); + } + return result; +} + +/*! + Adds a new axis to the axis rect side specified with \a type, and returns it. + + If an axis rect side already contains one or more axes, the lower and upper endings of the new + axis (\ref QCPAxis::setLowerEnding, \ref QCPAxis::setUpperEnding) are initialized to \ref + QCPLineEnding::esHalfBar. + + \see addAxes, setupFullAxesBox +*/ +QCPAxis *QCPAxisRect::addAxis(QCPAxis::AxisType type) +{ + QCPAxis *newAxis = new QCPAxis(this, type); + if (mAxes[type].size() > 0) // multiple axes on one side, add half-bar axis ending to additional axes with offset + { + bool invert = (type == QCPAxis::atRight) || (type == QCPAxis::atBottom); + newAxis->setLowerEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, !invert)); + newAxis->setUpperEnding(QCPLineEnding(QCPLineEnding::esHalfBar, 6, 10, invert)); + } + mAxes[type].append(newAxis); + return newAxis; +} + +/*! + Adds a new axis with \ref addAxis to each axis rect side specified in \a types. This may be an + or-combination of QCPAxis::AxisType, so axes can be added to multiple sides at once. + + Returns a list of the added axes. + + \see addAxis, setupFullAxesBox +*/ +QList QCPAxisRect::addAxes(QCPAxis::AxisTypes types) +{ + QList result; + if (types.testFlag(QCPAxis::atLeft)) + result << addAxis(QCPAxis::atLeft); + if (types.testFlag(QCPAxis::atRight)) + result << addAxis(QCPAxis::atRight); + if (types.testFlag(QCPAxis::atTop)) + result << addAxis(QCPAxis::atTop); + if (types.testFlag(QCPAxis::atBottom)) + result << addAxis(QCPAxis::atBottom); + return result; +} + +/*! + Removes the specified \a axis from the axis rect and deletes it. + + Returns true on success, i.e. if \a axis was a valid axis in this axis rect. + + \see addAxis +*/ +bool QCPAxisRect::removeAxis(QCPAxis *axis) +{ + // don't access axis->axisType() to provide safety when axis is an invalid pointer, rather go through all axis containers: + QHashIterator > it(mAxes); + while (it.hasNext()) + { + it.next(); + if (it.value().contains(axis)) + { + mAxes[it.key()].removeOne(axis); + if (qobject_cast(parentPlot())) // make sure this isn't called from QObject dtor when QCustomPlot is already destructed (happens when the axis rect is not in any layout and thus QObject-child of QCustomPlot) + parentPlot()->axisRemoved(axis); + delete axis; + return true; + } + } + qDebug() << Q_FUNC_INFO << "Axis isn't in axis rect:" << reinterpret_cast(axis); + return false; +} + +/*! + Convenience function to create an axis on each side that doesn't have any axes yet and set their + visibility to true. Further, the top/right axes are assigned the following properties of the + bottom/left axes: + + \li range (\ref QCPAxis::setRange) + \li range reversed (\ref QCPAxis::setRangeReversed) + \li scale type (\ref QCPAxis::setScaleType) + \li scale log base (\ref QCPAxis::setScaleLogBase) + \li ticks (\ref QCPAxis::setTicks) + \li auto (major) tick count (\ref QCPAxis::setAutoTickCount) + \li sub tick count (\ref QCPAxis::setSubTickCount) + \li auto sub ticks (\ref QCPAxis::setAutoSubTicks) + \li tick step (\ref QCPAxis::setTickStep) + \li auto tick step (\ref QCPAxis::setAutoTickStep) + \li number format (\ref QCPAxis::setNumberFormat) + \li number precision (\ref QCPAxis::setNumberPrecision) + \li tick label type (\ref QCPAxis::setTickLabelType) + \li date time format (\ref QCPAxis::setDateTimeFormat) + \li date time spec (\ref QCPAxis::setDateTimeSpec) + + Tick labels (\ref QCPAxis::setTickLabels) of the right and top axes are set to false. + + If \a connectRanges is true, the \ref QCPAxis::rangeChanged "rangeChanged" signals of the bottom + and left axes are connected to the \ref QCPAxis::setRange slots of the top and right axes. +*/ +void QCPAxisRect::setupFullAxesBox(bool connectRanges) +{ + QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2; + if (axisCount(QCPAxis::atBottom) == 0) + xAxis = addAxis(QCPAxis::atBottom); + else + xAxis = axis(QCPAxis::atBottom); + + if (axisCount(QCPAxis::atLeft) == 0) + yAxis = addAxis(QCPAxis::atLeft); + else + yAxis = axis(QCPAxis::atLeft); + + if (axisCount(QCPAxis::atTop) == 0) + xAxis2 = addAxis(QCPAxis::atTop); + else + xAxis2 = axis(QCPAxis::atTop); + + if (axisCount(QCPAxis::atRight) == 0) + yAxis2 = addAxis(QCPAxis::atRight); + else + yAxis2 = axis(QCPAxis::atRight); + + xAxis->setVisible(true); + yAxis->setVisible(true); + xAxis2->setVisible(true); + yAxis2->setVisible(true); + xAxis2->setTickLabels(false); + yAxis2->setTickLabels(false); + + xAxis2->setRange(xAxis->range()); + xAxis2->setRangeReversed(xAxis->rangeReversed()); + xAxis2->setScaleType(xAxis->scaleType()); + xAxis2->setScaleLogBase(xAxis->scaleLogBase()); + xAxis2->setTicks(xAxis->ticks()); + xAxis2->setAutoTickCount(xAxis->autoTickCount()); + xAxis2->setSubTickCount(xAxis->subTickCount()); + xAxis2->setAutoSubTicks(xAxis->autoSubTicks()); + xAxis2->setTickStep(xAxis->tickStep()); + xAxis2->setAutoTickStep(xAxis->autoTickStep()); + xAxis2->setNumberFormat(xAxis->numberFormat()); + xAxis2->setNumberPrecision(xAxis->numberPrecision()); + xAxis2->setTickLabelType(xAxis->tickLabelType()); + xAxis2->setDateTimeFormat(xAxis->dateTimeFormat()); + xAxis2->setDateTimeSpec(xAxis->dateTimeSpec()); + + yAxis2->setRange(yAxis->range()); + yAxis2->setRangeReversed(yAxis->rangeReversed()); + yAxis2->setScaleType(yAxis->scaleType()); + yAxis2->setScaleLogBase(yAxis->scaleLogBase()); + yAxis2->setTicks(yAxis->ticks()); + yAxis2->setAutoTickCount(yAxis->autoTickCount()); + yAxis2->setSubTickCount(yAxis->subTickCount()); + yAxis2->setAutoSubTicks(yAxis->autoSubTicks()); + yAxis2->setTickStep(yAxis->tickStep()); + yAxis2->setAutoTickStep(yAxis->autoTickStep()); + yAxis2->setNumberFormat(yAxis->numberFormat()); + yAxis2->setNumberPrecision(yAxis->numberPrecision()); + yAxis2->setTickLabelType(yAxis->tickLabelType()); + yAxis2->setDateTimeFormat(yAxis->dateTimeFormat()); + yAxis2->setDateTimeSpec(yAxis->dateTimeSpec()); + + if (connectRanges) + { + connect(xAxis, SIGNAL(rangeChanged(QCPRange)), xAxis2, SLOT(setRange(QCPRange))); + connect(yAxis, SIGNAL(rangeChanged(QCPRange)), yAxis2, SLOT(setRange(QCPRange))); + } +} + +/*! + Returns a list of all the plottables that are associated with this axis rect. + + A plottable is considered associated with an axis rect if its key or value axis (or both) is in + this axis rect. + + \see graphs, items +*/ +QList QCPAxisRect::plottables() const +{ + // Note: don't append all QCPAxis::plottables() into a list, because we might get duplicate entries + QList result; + for (int i=0; imPlottables.size(); ++i) + { + if (mParentPlot->mPlottables.at(i)->keyAxis()->axisRect() == this ||mParentPlot->mPlottables.at(i)->valueAxis()->axisRect() == this) + result.append(mParentPlot->mPlottables.at(i)); + } + return result; +} + +/*! + Returns a list of all the graphs that are associated with this axis rect. + + A graph is considered associated with an axis rect if its key or value axis (or both) is in + this axis rect. + + \see plottables, items +*/ +QList QCPAxisRect::graphs() const +{ + // Note: don't append all QCPAxis::graphs() into a list, because we might get duplicate entries + QList result; + for (int i=0; imGraphs.size(); ++i) + { + if (mParentPlot->mGraphs.at(i)->keyAxis()->axisRect() == this || mParentPlot->mGraphs.at(i)->valueAxis()->axisRect() == this) + result.append(mParentPlot->mGraphs.at(i)); + } + return result; +} + +/*! + Returns a list of all the items that are associated with this axis rect. + + An item is considered associated with an axis rect if any of its positions has key or value axis + set to an axis that is in this axis rect, or if any of its positions has \ref + QCPItemPosition::setAxisRect set to the axis rect, or if the clip axis rect (\ref + QCPAbstractItem::setClipAxisRect) is set to this axis rect. + + \see plottables, graphs +*/ +QList QCPAxisRect::items() const +{ + // Note: don't just append all QCPAxis::items() into a list, because we might get duplicate entries + // and miss those items that have this axis rect as clipAxisRect. + QList result; + for (int itemId=0; itemIdmItems.size(); ++itemId) + { + if (mParentPlot->mItems.at(itemId)->clipAxisRect() == this) + { + result.append(mParentPlot->mItems.at(itemId)); + continue; + } + QList positions = mParentPlot->mItems.at(itemId)->positions(); + for (int posId=0; posIdaxisRect() == this || + positions.at(posId)->keyAxis()->axisRect() == this || + positions.at(posId)->valueAxis()->axisRect() == this) + { + result.append(mParentPlot->mItems.at(itemId)); + break; + } + } + } + return result; +} + +/*! + This method is called automatically upon replot and doesn't need to be called by users of + QCPAxisRect. + + Calls the base class implementation to update the margins (see \ref QCPLayoutElement::update), + and finally passes the \ref rect to the inset layout (\ref insetLayout) and calls its + QCPInsetLayout::update function. +*/ +void QCPAxisRect::update(UpdatePhase phase) +{ + QCPLayoutElement::update(phase); + + switch (phase) + { + case upPreparation: + { + QList allAxes = axes(); + for (int i=0; isetupTickVectors(); + break; + } + case upLayout: + { + mInsetLayout->setOuterRect(rect()); + break; + } + default: break; + } + + // pass update call on to inset layout (doesn't happen automatically, because QCPAxisRect doesn't derive from QCPLayout): + mInsetLayout->update(phase); +} + +/* inherits documentation from base class */ +QList QCPAxisRect::elements(bool recursive) const +{ + QList result; + if (mInsetLayout) + { + result << mInsetLayout; + if (recursive) + result << mInsetLayout->elements(recursive); + } + return result; +} + +/* inherits documentation from base class */ +void QCPAxisRect::applyDefaultAntialiasingHint(QCPPainter *painter) const +{ + painter->setAntialiasing(false); +} + +/* inherits documentation from base class */ +void QCPAxisRect::draw(QCPPainter *painter) +{ + drawBackground(painter); +} + +/*! + Sets \a pm as the axis background pixmap. The axis background pixmap will be drawn inside the + axis rect. Since axis rects place themselves on the "background" layer by default, the axis rect + backgrounds are usually drawn below everything else. + + For cases where the provided pixmap doesn't have the same size as the axis rect, scaling can be + enabled with \ref setBackgroundScaled and the scaling mode (i.e. whether and how the aspect ratio + is preserved) can be set with \ref setBackgroundScaledMode. To set all these options in one call, + consider using the overloaded version of this function. + + Below the pixmap, the axis rect may be optionally filled with a brush, if specified with \ref + setBackground(const QBrush &brush). + + \see setBackgroundScaled, setBackgroundScaledMode, setBackground(const QBrush &brush) +*/ +void QCPAxisRect::setBackground(const QPixmap &pm) +{ + mBackgroundPixmap = pm; + mScaledBackgroundPixmap = QPixmap(); +} + +/*! \overload + + Sets \a brush as the background brush. The axis rect background will be filled with this brush. + Since axis rects place themselves on the "background" layer by default, the axis rect backgrounds + are usually drawn below everything else. + + The brush will be drawn before (under) any background pixmap, which may be specified with \ref + setBackground(const QPixmap &pm). + + To disable drawing of a background brush, set \a brush to Qt::NoBrush. + + \see setBackground(const QPixmap &pm) +*/ +void QCPAxisRect::setBackground(const QBrush &brush) +{ + mBackgroundBrush = brush; +} + +/*! \overload + + Allows setting the background pixmap of the axis rect, whether it shall be scaled and how it + shall be scaled in one call. + + \see setBackground(const QPixmap &pm), setBackgroundScaled, setBackgroundScaledMode +*/ +void QCPAxisRect::setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode) +{ + mBackgroundPixmap = pm; + mScaledBackgroundPixmap = QPixmap(); + mBackgroundScaled = scaled; + mBackgroundScaledMode = mode; +} + +/*! + Sets whether the axis background pixmap shall be scaled to fit the axis rect or not. If \a scaled + is set to true, you may control whether and how the aspect ratio of the original pixmap is + preserved with \ref setBackgroundScaledMode. + + Note that the scaled version of the original pixmap is buffered, so there is no performance + penalty on replots. (Except when the axis rect dimensions are changed continuously.) + + \see setBackground, setBackgroundScaledMode +*/ +void QCPAxisRect::setBackgroundScaled(bool scaled) +{ + mBackgroundScaled = scaled; +} + +/*! + If scaling of the axis background pixmap is enabled (\ref setBackgroundScaled), use this function to + define whether and how the aspect ratio of the original pixmap passed to \ref setBackground is preserved. + \see setBackground, setBackgroundScaled +*/ +void QCPAxisRect::setBackgroundScaledMode(Qt::AspectRatioMode mode) +{ + mBackgroundScaledMode = mode; +} + +/*! + Returns the range drag axis of the \a orientation provided. + + \see setRangeDragAxes +*/ +QCPAxis *QCPAxisRect::rangeDragAxis(Qt::Orientation orientation) +{ + return (orientation == Qt::Horizontal ? mRangeDragHorzAxis.data() : mRangeDragVertAxis.data()); +} + +/*! + Returns the range zoom axis of the \a orientation provided. + + \see setRangeZoomAxes +*/ +QCPAxis *QCPAxisRect::rangeZoomAxis(Qt::Orientation orientation) +{ + return (orientation == Qt::Horizontal ? mRangeZoomHorzAxis.data() : mRangeZoomVertAxis.data()); +} + +/*! + Returns the range zoom factor of the \a orientation provided. + + \see setRangeZoomFactor +*/ +double QCPAxisRect::rangeZoomFactor(Qt::Orientation orientation) +{ + return (orientation == Qt::Horizontal ? mRangeZoomFactorHorz : mRangeZoomFactorVert); +} + +/*! + Sets which axis orientation may be range dragged by the user with mouse interaction. + What orientation corresponds to which specific axis can be set with + \ref setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical). By + default, the horizontal axis is the bottom axis (xAxis) and the vertical axis + is the left axis (yAxis). + + To disable range dragging entirely, pass 0 as \a orientations or remove \ref QCP::iRangeDrag from \ref + QCustomPlot::setInteractions. To enable range dragging for both directions, pass Qt::Horizontal | + Qt::Vertical as \a orientations. + + In addition to setting \a orientations to a non-zero value, make sure \ref QCustomPlot::setInteractions + contains \ref QCP::iRangeDrag to enable the range dragging interaction. + + \see setRangeZoom, setRangeDragAxes, setNoAntialiasingOnDrag +*/ +void QCPAxisRect::setRangeDrag(Qt::Orientations orientations) +{ + mRangeDrag = orientations; +} + +/*! + Sets which axis orientation may be zoomed by the user with the mouse wheel. What orientation + corresponds to which specific axis can be set with \ref setRangeZoomAxes(QCPAxis *horizontal, + QCPAxis *vertical). By default, the horizontal axis is the bottom axis (xAxis) and the vertical + axis is the left axis (yAxis). + + To disable range zooming entirely, pass 0 as \a orientations or remove \ref QCP::iRangeZoom from \ref + QCustomPlot::setInteractions. To enable range zooming for both directions, pass Qt::Horizontal | + Qt::Vertical as \a orientations. + + In addition to setting \a orientations to a non-zero value, make sure \ref QCustomPlot::setInteractions + contains \ref QCP::iRangeZoom to enable the range zooming interaction. + + \see setRangeZoomFactor, setRangeZoomAxes, setRangeDrag +*/ +void QCPAxisRect::setRangeZoom(Qt::Orientations orientations) +{ + mRangeZoom = orientations; +} + +/*! + Sets the axes whose range will be dragged when \ref setRangeDrag enables mouse range dragging + on the QCustomPlot widget. + + \see setRangeZoomAxes +*/ +void QCPAxisRect::setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical) +{ + mRangeDragHorzAxis = horizontal; + mRangeDragVertAxis = vertical; +} + +/*! + Sets the axes whose range will be zoomed when \ref setRangeZoom enables mouse wheel zooming on the + QCustomPlot widget. The two axes can be zoomed with different strengths, when different factors + are passed to \ref setRangeZoomFactor(double horizontalFactor, double verticalFactor). + + \see setRangeDragAxes +*/ +void QCPAxisRect::setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical) +{ + mRangeZoomHorzAxis = horizontal; + mRangeZoomVertAxis = vertical; +} + +/*! + Sets how strong one rotation step of the mouse wheel zooms, when range zoom was activated with + \ref setRangeZoom. The two parameters \a horizontalFactor and \a verticalFactor provide a way to + let the horizontal axis zoom at different rates than the vertical axis. Which axis is horizontal + and which is vertical, can be set with \ref setRangeZoomAxes. + + When the zoom factor is greater than one, scrolling the mouse wheel backwards (towards the user) + will zoom in (make the currently visible range smaller). For zoom factors smaller than one, the + same scrolling direction will zoom out. +*/ +void QCPAxisRect::setRangeZoomFactor(double horizontalFactor, double verticalFactor) +{ + mRangeZoomFactorHorz = horizontalFactor; + mRangeZoomFactorVert = verticalFactor; +} + +/*! \overload + + Sets both the horizontal and vertical zoom \a factor. +*/ +void QCPAxisRect::setRangeZoomFactor(double factor) +{ + mRangeZoomFactorHorz = factor; + mRangeZoomFactorVert = factor; +} + +/*! \internal + + Draws the background of this axis rect. It may consist of a background fill (a QBrush) and a + pixmap. + + If a brush was given via \ref setBackground(const QBrush &brush), this function first draws an + according filling inside the axis rect with the provided \a painter. + + Then, if a pixmap was provided via \ref setBackground, this function buffers the scaled version + depending on \ref setBackgroundScaled and \ref setBackgroundScaledMode and then draws it inside + the axis rect with the provided \a painter. The scaled version is buffered in + mScaledBackgroundPixmap to prevent expensive rescaling at every redraw. It is only updated, when + the axis rect has changed in a way that requires a rescale of the background pixmap (this is + dependant on the \ref setBackgroundScaledMode), or when a differend axis backgroud pixmap was + set. + + \see setBackground, setBackgroundScaled, setBackgroundScaledMode +*/ +void QCPAxisRect::drawBackground(QCPPainter *painter) +{ + // draw background fill: + if (mBackgroundBrush != Qt::NoBrush) + painter->fillRect(mRect, mBackgroundBrush); + + // draw background pixmap (on top of fill, if brush specified): + if (!mBackgroundPixmap.isNull()) + { + if (mBackgroundScaled) + { + // check whether mScaledBackground needs to be updated: + QSize scaledSize(mBackgroundPixmap.size()); + scaledSize.scale(mRect.size(), mBackgroundScaledMode); + if (mScaledBackgroundPixmap.size() != scaledSize) + mScaledBackgroundPixmap = mBackgroundPixmap.scaled(mRect.size(), mBackgroundScaledMode, Qt::SmoothTransformation); + painter->drawPixmap(mRect.topLeft(), mScaledBackgroundPixmap, QRect(0, 0, mRect.width(), mRect.height()) & mScaledBackgroundPixmap.rect()); + } else + { + painter->drawPixmap(mRect.topLeft(), mBackgroundPixmap, QRect(0, 0, mRect.width(), mRect.height())); + } + } +} + +/*! \internal + + This function makes sure multiple axes on the side specified with \a type don't collide, but are + distributed according to their respective space requirement (QCPAxis::calculateMargin). + + It does this by setting an appropriate offset (\ref QCPAxis::setOffset) on all axes except the + one with index zero. + + This function is called by \ref calculateAutoMargin. +*/ +void QCPAxisRect::updateAxesOffset(QCPAxis::AxisType type) +{ + const QList axesList = mAxes.value(type); + if (axesList.isEmpty()) + return; + + bool isFirstVisible = !axesList.first()->visible(); // if the first axis is visible, the second axis (which is where the loop starts) isn't the first visible axis, so initialize with false + for (int i=1; ioffset() + axesList.at(i-1)->calculateMargin(); + if (axesList.at(i)->visible()) // only add inner tick length to offset if this axis is visible and it's not the first visible one (might happen if true first axis is invisible) + { + if (!isFirstVisible) + offset += axesList.at(i)->tickLengthIn(); + isFirstVisible = false; + } + axesList.at(i)->setOffset(offset); + } +} + +/* inherits documentation from base class */ +int QCPAxisRect::calculateAutoMargin(QCP::MarginSide side) +{ + if (!mAutoMargins.testFlag(side)) + qDebug() << Q_FUNC_INFO << "Called with side that isn't specified as auto margin"; + + updateAxesOffset(QCPAxis::marginSideToAxisType(side)); + + // note: only need to look at the last (outer most) axis to determine the total margin, due to updateAxisOffset call + const QList axesList = mAxes.value(QCPAxis::marginSideToAxisType(side)); + if (axesList.size() > 0) + return axesList.last()->offset() + axesList.last()->calculateMargin(); + else + return 0; +} + +/*! \internal + + Event handler for when a mouse button is pressed on the axis rect. If the left mouse button is + pressed, the range dragging interaction is initialized (the actual range manipulation happens in + the \ref mouseMoveEvent). + + The mDragging flag is set to true and some anchor points are set that are needed to determine the + distance the mouse was dragged in the mouse move/release events later. + + \see mouseMoveEvent, mouseReleaseEvent +*/ +void QCPAxisRect::mousePressEvent(QMouseEvent *event) +{ + mDragStart = event->pos(); // need this even when not LeftButton is pressed, to determine in releaseEvent whether it was a full click (no position change between press and release) + if (event->buttons() & Qt::LeftButton) + { + mDragging = true; + // initialize antialiasing backup in case we start dragging: + if (mParentPlot->noAntialiasingOnDrag()) + { + mAADragBackup = mParentPlot->antialiasedElements(); + mNotAADragBackup = mParentPlot->notAntialiasedElements(); + } + // Mouse range dragging interaction: + if (mParentPlot->interactions().testFlag(QCP::iRangeDrag)) + { + if (mRangeDragHorzAxis) + mDragStartHorzRange = mRangeDragHorzAxis.data()->range(); + if (mRangeDragVertAxis) + mDragStartVertRange = mRangeDragVertAxis.data()->range(); + } + } +} + +/*! \internal + + Event handler for when the mouse is moved on the axis rect. If range dragging was activated in a + preceding \ref mousePressEvent, the range is moved accordingly. + + \see mousePressEvent, mouseReleaseEvent +*/ +void QCPAxisRect::mouseMoveEvent(QMouseEvent *event) +{ + // Mouse range dragging interaction: + if (mDragging && mParentPlot->interactions().testFlag(QCP::iRangeDrag)) + { + if (mRangeDrag.testFlag(Qt::Horizontal)) + { + if (QCPAxis *rangeDragHorzAxis = mRangeDragHorzAxis.data()) + { + if (rangeDragHorzAxis->mScaleType == QCPAxis::stLinear) + { + double diff = rangeDragHorzAxis->pixelToCoord(mDragStart.x()) - rangeDragHorzAxis->pixelToCoord(event->pos().x()); + rangeDragHorzAxis->setRange(mDragStartHorzRange.lower+diff, mDragStartHorzRange.upper+diff); + } else if (rangeDragHorzAxis->mScaleType == QCPAxis::stLogarithmic) + { + double diff = rangeDragHorzAxis->pixelToCoord(mDragStart.x()) / rangeDragHorzAxis->pixelToCoord(event->pos().x()); + rangeDragHorzAxis->setRange(mDragStartHorzRange.lower*diff, mDragStartHorzRange.upper*diff); + } + } + } + if (mRangeDrag.testFlag(Qt::Vertical)) + { + if (QCPAxis *rangeDragVertAxis = mRangeDragVertAxis.data()) + { + if (rangeDragVertAxis->mScaleType == QCPAxis::stLinear) + { + double diff = rangeDragVertAxis->pixelToCoord(mDragStart.y()) - rangeDragVertAxis->pixelToCoord(event->pos().y()); + rangeDragVertAxis->setRange(mDragStartVertRange.lower+diff, mDragStartVertRange.upper+diff); + } else if (rangeDragVertAxis->mScaleType == QCPAxis::stLogarithmic) + { + double diff = rangeDragVertAxis->pixelToCoord(mDragStart.y()) / rangeDragVertAxis->pixelToCoord(event->pos().y()); + rangeDragVertAxis->setRange(mDragStartVertRange.lower*diff, mDragStartVertRange.upper*diff); + } + } + } + if (mRangeDrag != 0) // if either vertical or horizontal drag was enabled, do a replot + { + if (mParentPlot->noAntialiasingOnDrag()) + mParentPlot->setNotAntialiasedElements(QCP::aeAll); + mParentPlot->replot(); + } + } +} + +/* inherits documentation from base class */ +void QCPAxisRect::mouseReleaseEvent(QMouseEvent *event) +{ + Q_UNUSED(event) + mDragging = false; + if (mParentPlot->noAntialiasingOnDrag()) + { + mParentPlot->setAntialiasedElements(mAADragBackup); + mParentPlot->setNotAntialiasedElements(mNotAADragBackup); + } +} + +/*! \internal + + Event handler for mouse wheel events. If rangeZoom is Qt::Horizontal, Qt::Vertical or both, the + ranges of the axes defined as rangeZoomHorzAxis and rangeZoomVertAxis are scaled. The center of + the scaling operation is the current cursor position inside the axis rect. The scaling factor is + dependant on the mouse wheel delta (which direction the wheel was rotated) to provide a natural + zooming feel. The Strength of the zoom can be controlled via \ref setRangeZoomFactor. + + Note, that event->delta() is usually +/-120 for single rotation steps. However, if the mouse + wheel is turned rapidly, many steps may bunch up to one event, so the event->delta() may then be + multiples of 120. This is taken into account here, by calculating \a wheelSteps and using it as + exponent of the range zoom factor. This takes care of the wheel direction automatically, by + inverting the factor, when the wheel step is negative (f^-1 = 1/f). +*/ +void QCPAxisRect::wheelEvent(QWheelEvent *event) +{ + // Mouse range zooming interaction: + if (mParentPlot->interactions().testFlag(QCP::iRangeZoom)) + { + if (mRangeZoom != 0) + { + double factor; + double wheelSteps = event->delta()/120.0; // a single step delta is +/-120 usually + if (mRangeZoom.testFlag(Qt::Horizontal)) + { + factor = qPow(mRangeZoomFactorHorz, wheelSteps); + if (mRangeZoomHorzAxis.data()) + mRangeZoomHorzAxis.data()->scaleRange(factor, mRangeZoomHorzAxis.data()->pixelToCoord(event->pos().x())); + } + if (mRangeZoom.testFlag(Qt::Vertical)) + { + factor = qPow(mRangeZoomFactorVert, wheelSteps); + if (mRangeZoomVertAxis.data()) + mRangeZoomVertAxis.data()->scaleRange(factor, mRangeZoomVertAxis.data()->pixelToCoord(event->pos().y())); + } + mParentPlot->replot(); + } + } +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPAbstractLegendItem +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPAbstractLegendItem + \brief The abstract base class for all entries in a QCPLegend. + + It defines a very basic interface for entries in a QCPLegend. For representing plottables in the + legend, the subclass \ref QCPPlottableLegendItem is more suitable. + + Only derive directly from this class when you need absolute freedom (e.g. a custom legend entry + that's not even associated with a plottable). + + You must implement the following pure virtual functions: + \li \ref draw (from QCPLayerable) + + You inherit the following members you may use: + + + + + + + + +
QCPLegend *\b mParentLegendA pointer to the parent QCPLegend.
QFont \b mFontThe generic font of the item. You should use this font for all or at least the most prominent text of the item.
+*/ + +/* start of documentation of signals */ + +/*! \fn void QCPAbstractLegendItem::selectionChanged(bool selected) + + This signal is emitted when the selection state of this legend item has changed, either by user + interaction or by a direct call to \ref setSelected. +*/ + +/* end of documentation of signals */ + +/*! + Constructs a QCPAbstractLegendItem and associates it with the QCPLegend \a parent. This does not + cause the item to be added to \a parent, so \ref QCPLegend::addItem must be called separately. +*/ +QCPAbstractLegendItem::QCPAbstractLegendItem(QCPLegend *parent) : + QCPLayoutElement(parent->parentPlot()), + mParentLegend(parent), + mFont(parent->font()), + mTextColor(parent->textColor()), + mSelectedFont(parent->selectedFont()), + mSelectedTextColor(parent->selectedTextColor()), + mSelectable(true), + mSelected(false) +{ + setLayer("legend"); + setMargins(QMargins(8, 2, 8, 2)); +} + +/*! + Sets the default font of this specific legend item to \a font. + + \see setTextColor, QCPLegend::setFont +*/ +void QCPAbstractLegendItem::setFont(const QFont &font) +{ + mFont = font; +} + +/*! + Sets the default text color of this specific legend item to \a color. + + \see setFont, QCPLegend::setTextColor +*/ +void QCPAbstractLegendItem::setTextColor(const QColor &color) +{ + mTextColor = color; +} + +/*! + When this legend item is selected, \a font is used to draw generic text, instead of the normal + font set with \ref setFont. + + \see setFont, QCPLegend::setSelectedFont +*/ +void QCPAbstractLegendItem::setSelectedFont(const QFont &font) +{ + mSelectedFont = font; +} + +/*! + When this legend item is selected, \a color is used to draw generic text, instead of the normal + color set with \ref setTextColor. + + \see setTextColor, QCPLegend::setSelectedTextColor +*/ +void QCPAbstractLegendItem::setSelectedTextColor(const QColor &color) +{ + mSelectedTextColor = color; +} + +/*! + Sets whether this specific legend item is selectable. + + \see setSelectedParts, QCustomPlot::setInteractions +*/ +void QCPAbstractLegendItem::setSelectable(bool selectable) +{ + if (mSelectable != selectable) + { + mSelectable = selectable; + emit selectableChanged(mSelectable); + } +} + +/*! + Sets whether this specific legend item is selected. + + It is possible to set the selection state of this item by calling this function directly, even if + setSelectable is set to false. + + \see setSelectableParts, QCustomPlot::setInteractions +*/ +void QCPAbstractLegendItem::setSelected(bool selected) +{ + if (mSelected != selected) + { + mSelected = selected; + emit selectionChanged(mSelected); + } +} + +/* inherits documentation from base class */ +double QCPAbstractLegendItem::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (!mParentPlot) return -1; + if (onlySelectable && (!mSelectable || !mParentLegend->selectableParts().testFlag(QCPLegend::spItems))) + return -1; + + if (mRect.contains(pos.toPoint())) + return mParentPlot->selectionTolerance()*0.99; + else + return -1; +} + +/* inherits documentation from base class */ +void QCPAbstractLegendItem::applyDefaultAntialiasingHint(QCPPainter *painter) const +{ + applyAntialiasingHint(painter, mAntialiased, QCP::aeLegendItems); +} + +/* inherits documentation from base class */ +QRect QCPAbstractLegendItem::clipRect() const +{ + return mOuterRect; +} + +/* inherits documentation from base class */ +void QCPAbstractLegendItem::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) +{ + Q_UNUSED(event) + Q_UNUSED(details) + if (mSelectable && mParentLegend->selectableParts().testFlag(QCPLegend::spItems)) + { + bool selBefore = mSelected; + setSelected(additive ? !mSelected : true); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; + } +} + +/* inherits documentation from base class */ +void QCPAbstractLegendItem::deselectEvent(bool *selectionStateChanged) +{ + if (mSelectable && mParentLegend->selectableParts().testFlag(QCPLegend::spItems)) + { + bool selBefore = mSelected; + setSelected(false); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPPlottableLegendItem +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPPlottableLegendItem + \brief A legend item representing a plottable with an icon and the plottable name. + + This is the standard legend item for plottables. It displays an icon of the plottable next to the + plottable name. The icon is drawn by the respective plottable itself (\ref + QCPAbstractPlottable::drawLegendIcon), and tries to give an intuitive symbol for the plottable. + For example, the QCPGraph draws a centered horizontal line and/or a single scatter point in the + middle. + + Legend items of this type are always associated with one plottable (retrievable via the + plottable() function and settable with the constructor). You may change the font of the plottable + name with \ref setFont. Icon padding and border pen is taken from the parent QCPLegend, see \ref + QCPLegend::setIconBorderPen and \ref QCPLegend::setIconTextPadding. + + The function \ref QCPAbstractPlottable::addToLegend/\ref QCPAbstractPlottable::removeFromLegend + creates/removes legend items of this type in the default implementation. However, these functions + may be reimplemented such that a different kind of legend item (e.g a direct subclass of + QCPAbstractLegendItem) is used for that plottable. + + Since QCPLegend is based on QCPLayoutGrid, a legend item itself is just a subclass of + QCPLayoutElement. While it could be added to a legend (or any other layout) via the normal layout + interface, QCPLegend has specialized functions for handling legend items conveniently, see the + documentation of \ref QCPLegend. +*/ + +/*! + Creates a new legend item associated with \a plottable. + + Once it's created, it can be added to the legend via \ref QCPLegend::addItem. + + A more convenient way of adding/removing a plottable to/from the legend is via the functions \ref + QCPAbstractPlottable::addToLegend and \ref QCPAbstractPlottable::removeFromLegend. +*/ +QCPPlottableLegendItem::QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable) : + QCPAbstractLegendItem(parent), + mPlottable(plottable) +{ +} + +/*! \internal + + Returns the pen that shall be used to draw the icon border, taking into account the selection + state of this item. +*/ +QPen QCPPlottableLegendItem::getIconBorderPen() const +{ + return mSelected ? mParentLegend->selectedIconBorderPen() : mParentLegend->iconBorderPen(); +} + +/*! \internal + + Returns the text color that shall be used to draw text, taking into account the selection state + of this item. +*/ +QColor QCPPlottableLegendItem::getTextColor() const +{ + return mSelected ? mSelectedTextColor : mTextColor; +} + +/*! \internal + + Returns the font that shall be used to draw text, taking into account the selection state of this + item. +*/ +QFont QCPPlottableLegendItem::getFont() const +{ + return mSelected ? mSelectedFont : mFont; +} + +/*! \internal + + Draws the item with \a painter. The size and position of the drawn legend item is defined by the + parent layout (typically a \ref QCPLegend) and the \ref minimumSizeHint and \ref maximumSizeHint + of this legend item. +*/ +void QCPPlottableLegendItem::draw(QCPPainter *painter) +{ + if (!mPlottable) return; + painter->setFont(getFont()); + painter->setPen(QPen(getTextColor())); + QSizeF iconSize = mParentLegend->iconSize(); + QRectF textRect = painter->fontMetrics().boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip, mPlottable->name()); + QRectF iconRect(mRect.topLeft(), iconSize); + int textHeight = qMax(textRect.height(), iconSize.height()); // if text has smaller height than icon, center text vertically in icon height, else align tops + painter->drawText(mRect.x()+iconSize.width()+mParentLegend->iconTextPadding(), mRect.y(), textRect.width(), textHeight, Qt::TextDontClip, mPlottable->name()); + // draw icon: + painter->save(); + painter->setClipRect(iconRect, Qt::IntersectClip); + mPlottable->drawLegendIcon(painter, iconRect); + painter->restore(); + // draw icon border: + if (getIconBorderPen().style() != Qt::NoPen) + { + painter->setPen(getIconBorderPen()); + painter->setBrush(Qt::NoBrush); + painter->drawRect(iconRect); + } +} + +/*! \internal + + Calculates and returns the size of this item. This includes the icon, the text and the padding in + between. +*/ +QSize QCPPlottableLegendItem::minimumSizeHint() const +{ + if (!mPlottable) return QSize(); + QSize result(0, 0); + QRect textRect; + QFontMetrics fontMetrics(getFont()); + QSize iconSize = mParentLegend->iconSize(); + textRect = fontMetrics.boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip, mPlottable->name()); + result.setWidth(iconSize.width() + mParentLegend->iconTextPadding() + textRect.width() + mMargins.left() + mMargins.right()); + result.setHeight(qMax(textRect.height(), iconSize.height()) + mMargins.top() + mMargins.bottom()); + return result; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPLegend +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPLegend + \brief Manages a legend inside a QCustomPlot. + + A legend is a small box somewhere in the plot which lists plottables with their name and icon. + + Normally, the legend is populated by calling \ref QCPAbstractPlottable::addToLegend. The + respective legend item can be removed with \ref QCPAbstractPlottable::removeFromLegend. However, + QCPLegend also offers an interface to add and manipulate legend items directly: \ref item, \ref + itemWithPlottable, \ref itemCount, \ref addItem, \ref removeItem, etc. + + The QCPLegend derives from QCPLayoutGrid and as such can be placed in any position a + QCPLayoutElement may be positioned. The legend items are themselves QCPLayoutElements which are + placed in the grid layout of the legend. QCPLegend only adds an interface specialized for + handling child elements of type QCPAbstractLegendItem, as mentioned above. In principle, any + other layout elements may also be added to a legend via the normal \ref QCPLayoutGrid interface. + However, the QCPAbstractLegendItem-Interface will ignore those elements (e.g. \ref itemCount will + only return the number of items with QCPAbstractLegendItems type). + + By default, every QCustomPlot has one legend (QCustomPlot::legend) which is placed in the inset + layout of the main axis rect (\ref QCPAxisRect::insetLayout). To move the legend to another + position inside the axis rect, use the methods of the \ref QCPLayoutInset. To move the legend + outside of the axis rect, place it anywhere else with the QCPLayout/QCPLayoutElement interface. +*/ + +/* start of documentation of signals */ + +/*! \fn void QCPLegend::selectionChanged(QCPLegend::SelectableParts selection); + + This signal is emitted when the selection state of this legend has changed. + + \see setSelectedParts, setSelectableParts +*/ + +/* end of documentation of signals */ + +/*! + Constructs a new QCPLegend instance with \a parentPlot as the containing plot and default values. + + Note that by default, QCustomPlot already contains a legend ready to be used as + QCustomPlot::legend +*/ +QCPLegend::QCPLegend() +{ + setRowSpacing(0); + setColumnSpacing(10); + setMargins(QMargins(2, 3, 2, 2)); + setAntialiased(false); + setIconSize(32, 18); + + setIconTextPadding(7); + + setSelectableParts(spLegendBox | spItems); + setSelectedParts(spNone); + + setBorderPen(QPen(Qt::black)); + setSelectedBorderPen(QPen(Qt::blue, 2)); + setIconBorderPen(Qt::NoPen); + setSelectedIconBorderPen(QPen(Qt::blue, 2)); + setBrush(Qt::white); + setSelectedBrush(Qt::white); + setTextColor(Qt::black); + setSelectedTextColor(Qt::blue); +} + +QCPLegend::~QCPLegend() +{ + clearItems(); + if (qobject_cast(mParentPlot)) // make sure this isn't called from QObject dtor when QCustomPlot is already destructed (happens when the legend is not in any layout and thus QObject-child of QCustomPlot) + mParentPlot->legendRemoved(this); +} + +/* no doc for getter, see setSelectedParts */ +QCPLegend::SelectableParts QCPLegend::selectedParts() const +{ + // check whether any legend elements selected, if yes, add spItems to return value + bool hasSelectedItems = false; + for (int i=0; iselected()) + { + hasSelectedItems = true; + break; + } + } + if (hasSelectedItems) + return mSelectedParts | spItems; + else + return mSelectedParts & ~spItems; +} + +/*! + Sets the pen, the border of the entire legend is drawn with. +*/ +void QCPLegend::setBorderPen(const QPen &pen) +{ + mBorderPen = pen; +} + +/*! + Sets the brush of the legend background. +*/ +void QCPLegend::setBrush(const QBrush &brush) +{ + mBrush = brush; +} + +/*! + Sets the default font of legend text. Legend items that draw text (e.g. the name of a graph) will + use this font by default. However, a different font can be specified on a per-item-basis by + accessing the specific legend item. + + This function will also set \a font on all already existing legend items. + + \see QCPAbstractLegendItem::setFont +*/ +void QCPLegend::setFont(const QFont &font) +{ + mFont = font; + for (int i=0; isetFont(mFont); + } +} + +/*! + Sets the default color of legend text. Legend items that draw text (e.g. the name of a graph) + will use this color by default. However, a different colors can be specified on a per-item-basis + by accessing the specific legend item. + + This function will also set \a color on all already existing legend items. + + \see QCPAbstractLegendItem::setTextColor +*/ +void QCPLegend::setTextColor(const QColor &color) +{ + mTextColor = color; + for (int i=0; isetTextColor(color); + } +} + +/*! + Sets the size of legend icons. Legend items that draw an icon (e.g. a visual + representation of the graph) will use this size by default. +*/ +void QCPLegend::setIconSize(const QSize &size) +{ + mIconSize = size; +} + +/*! \overload +*/ +void QCPLegend::setIconSize(int width, int height) +{ + mIconSize.setWidth(width); + mIconSize.setHeight(height); +} + +/*! + Sets the horizontal space in pixels between the legend icon and the text next to it. + Legend items that draw an icon (e.g. a visual representation of the graph) and text (e.g. the + name of the graph) will use this space by default. +*/ +void QCPLegend::setIconTextPadding(int padding) +{ + mIconTextPadding = padding; +} + +/*! + Sets the pen used to draw a border around each legend icon. Legend items that draw an + icon (e.g. a visual representation of the graph) will use this pen by default. + + If no border is wanted, set this to \a Qt::NoPen. +*/ +void QCPLegend::setIconBorderPen(const QPen &pen) +{ + mIconBorderPen = pen; +} + +/*! + Sets whether the user can (de-)select the parts in \a selectable by clicking on the QCustomPlot surface. + (When \ref QCustomPlot::setInteractions contains \ref QCP::iSelectLegend.) + + However, even when \a selectable is set to a value not allowing the selection of a specific part, + it is still possible to set the selection of this part manually, by calling \ref setSelectedParts + directly. + + \see SelectablePart, setSelectedParts +*/ +void QCPLegend::setSelectableParts(const SelectableParts &selectable) +{ + if (mSelectableParts != selectable) + { + mSelectableParts = selectable; + emit selectableChanged(mSelectableParts); + } +} + +/*! + Sets the selected state of the respective legend parts described by \ref SelectablePart. When a part + is selected, it uses a different pen/font and brush. If some legend items are selected and \a selected + doesn't contain \ref spItems, those items become deselected. + + The entire selection mechanism is handled automatically when \ref QCustomPlot::setInteractions + contains iSelectLegend. You only need to call this function when you wish to change the selection + state manually. + + This function can change the selection state of a part even when \ref setSelectableParts was set to a + value that actually excludes the part. + + emits the \ref selectionChanged signal when \a selected is different from the previous selection state. + + Note that it doesn't make sense to set the selected state \ref spItems here when it wasn't set + before, because there's no way to specify which exact items to newly select. Do this by calling + \ref QCPAbstractLegendItem::setSelected directly on the legend item you wish to select. + + \see SelectablePart, setSelectableParts, selectTest, setSelectedBorderPen, setSelectedIconBorderPen, setSelectedBrush, + setSelectedFont +*/ +void QCPLegend::setSelectedParts(const SelectableParts &selected) +{ + SelectableParts newSelected = selected; + mSelectedParts = this->selectedParts(); // update mSelectedParts in case item selection changed + + if (mSelectedParts != newSelected) + { + if (!mSelectedParts.testFlag(spItems) && newSelected.testFlag(spItems)) // attempt to set spItems flag (can't do that) + { + qDebug() << Q_FUNC_INFO << "spItems flag can not be set, it can only be unset with this function"; + newSelected &= ~spItems; + } + if (mSelectedParts.testFlag(spItems) && !newSelected.testFlag(spItems)) // spItems flag was unset, so clear item selection + { + for (int i=0; isetSelected(false); + } + } + mSelectedParts = newSelected; + emit selectionChanged(mSelectedParts); + } +} + +/*! + When the legend box is selected, this pen is used to draw the border instead of the normal pen + set via \ref setBorderPen. + + \see setSelectedParts, setSelectableParts, setSelectedBrush +*/ +void QCPLegend::setSelectedBorderPen(const QPen &pen) +{ + mSelectedBorderPen = pen; +} + +/*! + Sets the pen legend items will use to draw their icon borders, when they are selected. + + \see setSelectedParts, setSelectableParts, setSelectedFont +*/ +void QCPLegend::setSelectedIconBorderPen(const QPen &pen) +{ + mSelectedIconBorderPen = pen; +} + +/*! + When the legend box is selected, this brush is used to draw the legend background instead of the normal brush + set via \ref setBrush. + + \see setSelectedParts, setSelectableParts, setSelectedBorderPen +*/ +void QCPLegend::setSelectedBrush(const QBrush &brush) +{ + mSelectedBrush = brush; +} + +/*! + Sets the default font that is used by legend items when they are selected. + + This function will also set \a font on all already existing legend items. + + \see setFont, QCPAbstractLegendItem::setSelectedFont +*/ +void QCPLegend::setSelectedFont(const QFont &font) +{ + mSelectedFont = font; + for (int i=0; isetSelectedFont(font); + } +} + +/*! + Sets the default text color that is used by legend items when they are selected. + + This function will also set \a color on all already existing legend items. + + \see setTextColor, QCPAbstractLegendItem::setSelectedTextColor +*/ +void QCPLegend::setSelectedTextColor(const QColor &color) +{ + mSelectedTextColor = color; + for (int i=0; isetSelectedTextColor(color); + } +} + +/*! + Returns the item with index \a i. + + \see itemCount +*/ +QCPAbstractLegendItem *QCPLegend::item(int index) const +{ + return qobject_cast(elementAt(index)); +} + +/*! + Returns the QCPPlottableLegendItem which is associated with \a plottable (e.g. a \ref QCPGraph*). + If such an item isn't in the legend, returns 0. + + \see hasItemWithPlottable +*/ +QCPPlottableLegendItem *QCPLegend::itemWithPlottable(const QCPAbstractPlottable *plottable) const +{ + for (int i=0; i(item(i))) + { + if (pli->plottable() == plottable) + return pli; + } + } + return 0; +} + +/*! + Returns the number of items currently in the legend. + \see item +*/ +int QCPLegend::itemCount() const +{ + return elementCount(); +} + +/*! + Returns whether the legend contains \a itm. +*/ +bool QCPLegend::hasItem(QCPAbstractLegendItem *item) const +{ + for (int i=0; iitem(i)) + return true; + } + return false; +} + +/*! + Returns whether the legend contains a QCPPlottableLegendItem which is associated with \a plottable (e.g. a \ref QCPGraph*). + If such an item isn't in the legend, returns false. + + \see itemWithPlottable +*/ +bool QCPLegend::hasItemWithPlottable(const QCPAbstractPlottable *plottable) const +{ + return itemWithPlottable(plottable); +} + +/*! + Adds \a item to the legend, if it's not present already. + + Returns true on sucess, i.e. if the item wasn't in the list already and has been successfuly added. + + The legend takes ownership of the item. +*/ +bool QCPLegend::addItem(QCPAbstractLegendItem *item) +{ + if (!hasItem(item)) + { + return addElement(rowCount(), 0, item); + } else + return false; +} + +/*! + Removes the item with index \a index from the legend. + + Returns true, if successful. + + \see itemCount, clearItems +*/ +bool QCPLegend::removeItem(int index) +{ + if (QCPAbstractLegendItem *ali = item(index)) + { + bool success = remove(ali); + simplify(); + return success; + } else + return false; +} + +/*! \overload + + Removes \a item from the legend. + + Returns true, if successful. + + \see clearItems +*/ +bool QCPLegend::removeItem(QCPAbstractLegendItem *item) +{ + bool success = remove(item); + simplify(); + return success; +} + +/*! + Removes all items from the legend. +*/ +void QCPLegend::clearItems() +{ + for (int i=itemCount()-1; i>=0; --i) + removeItem(i); +} + +/*! + Returns the legend items that are currently selected. If no items are selected, + the list is empty. + + \see QCPAbstractLegendItem::setSelected, setSelectable +*/ +QList QCPLegend::selectedItems() const +{ + QList result; + for (int i=0; iselected()) + result.append(ali); + } + } + return result; +} + +/*! \internal + + A convenience function to easily set the QPainter::Antialiased hint on the provided \a painter + before drawing main legend elements. + + This is the antialiasing state the painter passed to the \ref draw method is in by default. + + This function takes into account the local setting of the antialiasing flag as well as the + overrides set with \ref QCustomPlot::setAntialiasedElements and \ref + QCustomPlot::setNotAntialiasedElements. + + \see setAntialiased +*/ +void QCPLegend::applyDefaultAntialiasingHint(QCPPainter *painter) const +{ + applyAntialiasingHint(painter, mAntialiased, QCP::aeLegend); +} + +/*! \internal + + Returns the pen used to paint the border of the legend, taking into account the selection state + of the legend box. +*/ +QPen QCPLegend::getBorderPen() const +{ + return mSelectedParts.testFlag(spLegendBox) ? mSelectedBorderPen : mBorderPen; +} + +/*! \internal + + Returns the brush used to paint the background of the legend, taking into account the selection + state of the legend box. +*/ +QBrush QCPLegend::getBrush() const +{ + return mSelectedParts.testFlag(spLegendBox) ? mSelectedBrush : mBrush; +} + +/*! \internal + + Draws the legend box with the provided \a painter. The individual legend items are layerables + themselves, thus are drawn independently. +*/ +void QCPLegend::draw(QCPPainter *painter) +{ + // draw background rect: + painter->setBrush(getBrush()); + painter->setPen(getBorderPen()); + painter->drawRect(mOuterRect); +} + +/* inherits documentation from base class */ +double QCPLegend::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + if (!mParentPlot) return -1; + if (onlySelectable && !mSelectableParts.testFlag(spLegendBox)) + return -1; + + if (mOuterRect.contains(pos.toPoint())) + { + if (details) details->setValue(spLegendBox); + return mParentPlot->selectionTolerance()*0.99; + } + return -1; +} + +/* inherits documentation from base class */ +void QCPLegend::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) +{ + Q_UNUSED(event) + mSelectedParts = selectedParts(); // in case item selection has changed + if (details.value() == spLegendBox && mSelectableParts.testFlag(spLegendBox)) + { + SelectableParts selBefore = mSelectedParts; + setSelectedParts(additive ? mSelectedParts^spLegendBox : mSelectedParts|spLegendBox); // no need to unset spItems in !additive case, because they will be deselected by QCustomPlot (they're normal QCPLayerables with own deselectEvent) + if (selectionStateChanged) + *selectionStateChanged = mSelectedParts != selBefore; + } +} + +/* inherits documentation from base class */ +void QCPLegend::deselectEvent(bool *selectionStateChanged) +{ + mSelectedParts = selectedParts(); // in case item selection has changed + if (mSelectableParts.testFlag(spLegendBox)) + { + SelectableParts selBefore = mSelectedParts; + setSelectedParts(selectedParts() & ~spLegendBox); + if (selectionStateChanged) + *selectionStateChanged = mSelectedParts != selBefore; + } +} + +/* inherits documentation from base class */ +QCP::Interaction QCPLegend::selectionCategory() const +{ + return QCP::iSelectLegend; +} + +/* inherits documentation from base class */ +QCP::Interaction QCPAbstractLegendItem::selectionCategory() const +{ + return QCP::iSelectLegend; +} + +/* inherits documentation from base class */ +void QCPLegend::parentPlotInitialized(QCustomPlot *parentPlot) +{ + Q_UNUSED(parentPlot) +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPPlotTitle +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPPlotTitle + \brief A layout element displaying a plot title text + + The text may be specified with \ref setText, theformatting can be controlled with \ref setFont + and \ref setTextColor. + + A plot title can be added as follows: + \code + customPlot->plotLayout()->insertRow(0); // inserts an empty row above the default axis rect + customPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(customPlot, "Your Plot Title")); + \endcode + + Since a plot title is a common requirement, QCustomPlot offers specialized selection signals for + easy interaction with QCPPlotTitle. If a layout element of type QCPPlotTitle is clicked, the + signal \ref QCustomPlot::titleClick is emitted. A double click emits the \ref + QCustomPlot::titleDoubleClick signal. +*/ + +/* start documentation of signals */ + +/*! \fn void QCPPlotTitle::selectionChanged(bool selected) + + This signal is emitted when the selection state has changed to \a selected, either by user + interaction or by a direct call to \ref setSelected. + + \see setSelected, setSelectable +*/ + +/* end documentation of signals */ + +/*! + Creates a new QCPPlotTitle instance and sets default values. The initial text is empty (\ref setText). + + To set the title text in the constructor, rather use \ref QCPPlotTitle(QCustomPlot *parentPlot, const QString &text). +*/ +QCPPlotTitle::QCPPlotTitle(QCustomPlot *parentPlot) : + QCPLayoutElement(parentPlot), + mFont(QFont("sans serif", 13*1.5, QFont::Bold)), + mTextColor(Qt::black), + mSelectedFont(QFont("sans serif", 13*1.6, QFont::Bold)), + mSelectedTextColor(Qt::blue), + mSelectable(false), + mSelected(false) +{ + if (parentPlot) + { + setLayer(parentPlot->currentLayer()); + mFont = QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.5, QFont::Bold); + mSelectedFont = QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.6, QFont::Bold); + } + setMargins(QMargins(5, 5, 5, 0)); +} + +/*! \overload + + Creates a new QCPPlotTitle instance and sets default values. The initial text is set to \a text. +*/ +QCPPlotTitle::QCPPlotTitle(QCustomPlot *parentPlot, const QString &text) : + QCPLayoutElement(parentPlot), + mText(text), + mFont(QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.5, QFont::Bold)), + mTextColor(Qt::black), + mSelectedFont(QFont(parentPlot->font().family(), parentPlot->font().pointSize()*1.6, QFont::Bold)), + mSelectedTextColor(Qt::blue), + mSelectable(false), + mSelected(false) +{ + setLayer("axes"); + setMargins(QMargins(5, 5, 5, 0)); +} + +/*! + Sets the text that will be displayed to \a text. Multiple lines can be created by insertion of "\n". + + \see setFont, setTextColor +*/ +void QCPPlotTitle::setText(const QString &text) +{ + mText = text; +} + +/*! + Sets the \a font of the title text. + + \see setTextColor, setSelectedFont +*/ +void QCPPlotTitle::setFont(const QFont &font) +{ + mFont = font; +} + +/*! + Sets the \a color of the title text. + + \see setFont, setSelectedTextColor +*/ +void QCPPlotTitle::setTextColor(const QColor &color) +{ + mTextColor = color; +} + +/*! + Sets the \a font of the title text that will be used if the plot title is selected (\ref setSelected). + + \see setFont +*/ +void QCPPlotTitle::setSelectedFont(const QFont &font) +{ + mSelectedFont = font; +} + +/*! + Sets the \a color of the title text that will be used if the plot title is selected (\ref setSelected). + + \see setTextColor +*/ +void QCPPlotTitle::setSelectedTextColor(const QColor &color) +{ + mSelectedTextColor = color; +} + +/*! + Sets whether the user may select this plot title to \a selectable. + + Note that even when \a selectable is set to false, the selection state may be changed + programmatically via \ref setSelected. +*/ +void QCPPlotTitle::setSelectable(bool selectable) +{ + if (mSelectable != selectable) + { + mSelectable = selectable; + emit selectableChanged(mSelectable); + } +} + +/*! + Sets the selection state of this plot title to \a selected. If the selection has changed, \ref + selectionChanged is emitted. + + Note that this function can change the selection state independently of the current \ref + setSelectable state. +*/ +void QCPPlotTitle::setSelected(bool selected) +{ + if (mSelected != selected) + { + mSelected = selected; + emit selectionChanged(mSelected); + } +} + +/* inherits documentation from base class */ +void QCPPlotTitle::applyDefaultAntialiasingHint(QCPPainter *painter) const +{ + applyAntialiasingHint(painter, mAntialiased, QCP::aeNone); +} + +/* inherits documentation from base class */ +void QCPPlotTitle::draw(QCPPainter *painter) +{ + painter->setFont(mainFont()); + painter->setPen(QPen(mainTextColor())); + painter->drawText(mRect, Qt::AlignCenter, mText, &mTextBoundingRect); +} + +/* inherits documentation from base class */ +QSize QCPPlotTitle::minimumSizeHint() const +{ + QFontMetrics metrics(mFont); + QSize result = metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter, mText).size(); + result.rwidth() += mMargins.left() + mMargins.right(); + result.rheight() += mMargins.top() + mMargins.bottom(); + return result; +} + +/* inherits documentation from base class */ +QSize QCPPlotTitle::maximumSizeHint() const +{ + QFontMetrics metrics(mFont); + QSize result = metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter, mText).size(); + result.rheight() += mMargins.top() + mMargins.bottom(); + result.setWidth(QWIDGETSIZE_MAX); + return result; +} + +/* inherits documentation from base class */ +void QCPPlotTitle::selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) +{ + Q_UNUSED(event) + Q_UNUSED(details) + if (mSelectable) + { + bool selBefore = mSelected; + setSelected(additive ? !mSelected : true); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; + } +} + +/* inherits documentation from base class */ +void QCPPlotTitle::deselectEvent(bool *selectionStateChanged) +{ + if (mSelectable) + { + bool selBefore = mSelected; + setSelected(false); + if (selectionStateChanged) + *selectionStateChanged = mSelected != selBefore; + } +} + +/* inherits documentation from base class */ +double QCPPlotTitle::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + if (mTextBoundingRect.contains(pos.toPoint())) + return mParentPlot->selectionTolerance()*0.99; + else + return -1; +} + +/*! \internal + + Returns the main font to be used. This is mSelectedFont if \ref setSelected is set to + true, else mFont is returned. +*/ +QFont QCPPlotTitle::mainFont() const +{ + return mSelected ? mSelectedFont : mFont; +} + +/*! \internal + + Returns the main color to be used. This is mSelectedTextColor if \ref setSelected is set to + true, else mTextColor is returned. +*/ +QColor QCPPlotTitle::mainTextColor() const +{ + return mSelected ? mSelectedTextColor : mTextColor; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPColorScale +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPColorScale + \brief A color scale for use with color coding data such as QCPColorMap + + This layout element can be placed on the plot to correlate a color gradient with data values. It + is usually used in combination with one or multiple \ref QCPColorMap "QCPColorMaps". + + \image html QCPColorScale.png + + The color scale can be either horizontal or vertical, as shown in the image above. The + orientation and the side where the numbers appear is controlled with \ref setType. + + Use \ref QCPColorMap::setColorScale to connect a color map with a color scale. Once they are + connected, they share their gradient, data range and data scale type (\ref setGradient, \ref + setDataRange, \ref setDataScaleType). Multiple color maps may be associated with a single color + scale, to make them all synchronize these properties. + + To have finer control over the number display and axis behaviour, you can directly access the + \ref axis. See the documentation of QCPAxis for details about configuring axes. For example, if + you want to change the number of automatically generated ticks, call + \code + colorScale->axis()->setAutoTickCount(3); + \endcode + + Placing a color scale next to the main axis rect works like with any other layout element: + \code + QCPColorScale *colorScale = new QCPColorScale(customPlot); + customPlot->plotLayout()->addElement(0, 1, colorScale); + colorScale->setLabel("Some Label Text"); + \endcode + In this case we have placed it to the right of the default axis rect, so it wasn't necessary to + call \ref setType, since \ref QCPAxis::atRight is already the default. The text next to the color + scale can be set with \ref setLabel. + + For optimum appearance (like in the image above), it may be desirable to line up the axis rect and + the borders of the color scale. Use a \ref QCPMarginGroup to achieve this: + \code + QCPMarginGroup *group = new QCPMarginGroup(customPlot); + colorScale->setMarginGroup(QCP::msTop|QCP::msBottom, group); + customPlot->axisRect()->setMarginGroup(QCP::msTop|QCP::msBottom, group); + \endcode + + Color scales are initialized with a non-zero minimum top and bottom margin (\ref + setMinimumMargins), because vertical color scales are most common and the minimum top/bottom + margin makes sure it keeps some distance to the top/bottom widget border. So if you change to a + horizontal color scale by setting \ref setType to \ref QCPAxis::atBottom or \ref QCPAxis::atTop, you + might want to also change the minimum margins accordingly, e.g. \ref + setMinimumMargins(QMargins(6, 0, 6, 0)). +*/ + +/* start documentation of inline functions */ + +/*! \fn QCPAxis *QCPColorScale::axis() const + + Returns the internal \ref QCPAxis instance of this color scale. You can access it to alter the + appearance and behaviour of the axis. \ref QCPColorScale duplicates some properties in its + interface for convenience. Those are \ref setDataRange (\ref QCPAxis::setRange), \ref + setDataScaleType (\ref QCPAxis::setScaleType), and the method \ref setLabel (\ref + QCPAxis::setLabel). As they each are connected, it does not matter whether you use the method on + the QCPColorScale or on its QCPAxis. + + If the type of the color scale is changed with \ref setType, the axis returned by this method + will change, too, to either the left, right, bottom or top axis, depending on which type was set. +*/ + +/* end documentation of signals */ +/* start documentation of signals */ + +/*! \fn void QCPColorScale::dataRangeChanged(QCPRange newRange); + + This signal is emitted when the data range changes. + + \see setDataRange +*/ + +/*! \fn void QCPColorScale::dataScaleTypeChanged(QCPAxis::ScaleType scaleType); + + This signal is emitted when the data scale type changes. + + \see setDataScaleType +*/ + +/*! \fn void QCPColorScale::gradientChanged(QCPColorGradient newGradient); + + This signal is emitted when the gradient changes. + + \see setGradient +*/ + +/* end documentation of signals */ + +/*! + Constructs a new QCPColorScale. +*/ +QCPColorScale::QCPColorScale(QCustomPlot *parentPlot) : + QCPLayoutElement(parentPlot), + mType(QCPAxis::atTop), // set to atTop such that setType(QCPAxis::atRight) below doesn't skip work because it thinks it's already atRight + mDataScaleType(QCPAxis::stLinear), + mBarWidth(20), + mAxisRect(new QCPColorScaleAxisRectPrivate(this)) +{ + setMinimumMargins(QMargins(0, 6, 0, 6)); // for default right color scale types, keep some room at bottom and top (important if no margin group is used) + setType(QCPAxis::atRight); + setDataRange(QCPRange(0, 6)); +} + +QCPColorScale::~QCPColorScale() +{ + delete mAxisRect; +} + +/* undocumented getter */ +QString QCPColorScale::label() const +{ + if (!mColorAxis) + { + qDebug() << Q_FUNC_INFO << "internal color axis undefined"; + return QString(); + } + + return mColorAxis.data()->label(); +} + +/* undocumented getter */ +bool QCPColorScale::rangeDrag() const +{ + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return false; + } + + return mAxisRect.data()->rangeDrag().testFlag(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeDragAxis(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeDragAxis(QCPAxis::orientation(mType))->orientation() == QCPAxis::orientation(mType); +} + +/* undocumented getter */ +bool QCPColorScale::rangeZoom() const +{ + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return false; + } + + return mAxisRect.data()->rangeZoom().testFlag(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeZoomAxis(QCPAxis::orientation(mType)) && + mAxisRect.data()->rangeZoomAxis(QCPAxis::orientation(mType))->orientation() == QCPAxis::orientation(mType); +} + +/*! + Sets at which side of the color scale the axis is placed, and thus also its orientation. + + Note that after setting \a type to a different value, the axis returned by \ref axis() will + be a different one. The new axis will adopt the following properties from the previous axis: The + range, scale type, log base and label. +*/ +void QCPColorScale::setType(QCPAxis::AxisType type) +{ + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + if (mType != type) + { + mType = type; + QCPRange rangeTransfer(0, 6); + double logBaseTransfer = 10; + QString labelTransfer; + // revert some settings on old axis: + if (mColorAxis) + { + rangeTransfer = mColorAxis.data()->range(); + labelTransfer = mColorAxis.data()->label(); + logBaseTransfer = mColorAxis.data()->scaleLogBase(); + mColorAxis.data()->setLabel(""); + disconnect(mColorAxis.data(), SIGNAL(rangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + disconnect(mColorAxis.data(), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); + } + foreach (QCPAxis::AxisType atype, QList() << QCPAxis::atLeft << QCPAxis::atRight << QCPAxis::atBottom << QCPAxis::atTop) + { + mAxisRect.data()->axis(atype)->setTicks(atype == mType); + mAxisRect.data()->axis(atype)->setTickLabels(atype== mType); + } + // set new mColorAxis pointer: + mColorAxis = mAxisRect.data()->axis(mType); + // transfer settings to new axis: + mColorAxis.data()->setRange(rangeTransfer); // transfer range of old axis to new one (necessary if axis changes from vertical to horizontal or vice versa) + mColorAxis.data()->setLabel(labelTransfer); + mColorAxis.data()->setScaleLogBase(logBaseTransfer); // scaleType is synchronized among axes in realtime via signals (connected in QCPColorScale ctor), so we only need to take care of log base here + connect(mColorAxis.data(), SIGNAL(rangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + connect(mColorAxis.data(), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); + mAxisRect.data()->setRangeDragAxes(QCPAxis::orientation(mType) == Qt::Horizontal ? mColorAxis.data() : 0, + QCPAxis::orientation(mType) == Qt::Vertical ? mColorAxis.data() : 0); + } +} + +/*! + Sets the range spanned by the color gradient and that is shown by the axis in the color scale. + + It is equivalent to calling QCPColorMap::setDataRange on any of the connected color maps. It is + also equivalent to directly accessing the \ref axis and setting its range with \ref + QCPAxis::setRange. + + \see setDataScaleType, setGradient, rescaleDataRange +*/ +void QCPColorScale::setDataRange(const QCPRange &dataRange) +{ + if (mDataRange.lower != dataRange.lower || mDataRange.upper != dataRange.upper) + { + mDataRange = dataRange; + if (mColorAxis) + mColorAxis.data()->setRange(mDataRange); + emit dataRangeChanged(mDataRange); + } +} + +/*! + Sets the scale type of the color scale, i.e. whether values are linearly associated with colors + or logarithmically. + + It is equivalent to calling QCPColorMap::setDataScaleType on any of the connected color maps. It is + also equivalent to directly accessing the \ref axis and setting its scale type with \ref + QCPAxis::setScaleType. + + \see setDataRange, setGradient +*/ +void QCPColorScale::setDataScaleType(QCPAxis::ScaleType scaleType) +{ + if (mDataScaleType != scaleType) + { + mDataScaleType = scaleType; + if (mColorAxis) + mColorAxis.data()->setScaleType(mDataScaleType); + if (mDataScaleType == QCPAxis::stLogarithmic) + setDataRange(mDataRange.sanitizedForLogScale()); + emit dataScaleTypeChanged(mDataScaleType); + } +} + +/*! + Sets the color gradient that will be used to represent data values. + + It is equivalent to calling QCPColorMap::setGradient on any of the connected color maps. + + \see setDataRange, setDataScaleType +*/ +void QCPColorScale::setGradient(const QCPColorGradient &gradient) +{ + if (mGradient != gradient) + { + mGradient = gradient; + if (mAxisRect) + mAxisRect.data()->mGradientImageInvalidated = true; + emit gradientChanged(mGradient); + } +} + +/*! + Sets the axis label of the color scale. This is equivalent to calling \ref QCPAxis::setLabel on + the internal \ref axis. +*/ +void QCPColorScale::setLabel(const QString &str) +{ + if (!mColorAxis) + { + qDebug() << Q_FUNC_INFO << "internal color axis undefined"; + return; + } + + mColorAxis.data()->setLabel(str); +} + +/*! + Sets the width (or height, for horizontal color scales) the bar where the gradient is displayed + will have. +*/ +void QCPColorScale::setBarWidth(int width) +{ + mBarWidth = width; +} + +/*! + Sets whether the user can drag the data range (\ref setDataRange). + + Note that \ref QCP::iRangeDrag must be in the QCustomPlot's interactions (\ref + QCustomPlot::setInteractions) to allow range dragging. +*/ +void QCPColorScale::setRangeDrag(bool enabled) +{ + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + + if (enabled) + mAxisRect.data()->setRangeDrag(QCPAxis::orientation(mType)); + else + mAxisRect.data()->setRangeDrag(0); +} + +/*! + Sets whether the user can zoom the data range (\ref setDataRange) by scrolling the mouse wheel. + + Note that \ref QCP::iRangeZoom must be in the QCustomPlot's interactions (\ref + QCustomPlot::setInteractions) to allow range dragging. +*/ +void QCPColorScale::setRangeZoom(bool enabled) +{ + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + + if (enabled) + mAxisRect.data()->setRangeZoom(QCPAxis::orientation(mType)); + else + mAxisRect.data()->setRangeZoom(0); +} + +/*! + Returns a list of all the color maps associated with this color scale. +*/ +QList QCPColorScale::colorMaps() const +{ + QList result; + for (int i=0; iplottableCount(); ++i) + { + if (QCPColorMap *cm = qobject_cast(mParentPlot->plottable(i))) + if (cm->colorScale() == this) + result.append(cm); + } + return result; +} + +/*! + Changes the data range such that all color maps associated with this color scale are fully mapped + to the gradient in the data dimension. + + \see setDataRange +*/ +void QCPColorScale::rescaleDataRange(bool onlyVisibleMaps) +{ + QList maps = colorMaps(); + QCPRange newRange; + bool haveRange = false; + int sign = 0; // TODO: should change this to QCPAbstractPlottable::SignDomain later (currently is protected, maybe move to QCP namespace) + if (mDataScaleType == QCPAxis::stLogarithmic) + sign = (mDataRange.upper < 0 ? -1 : 1); + for (int i=0; irealVisibility() && onlyVisibleMaps) + continue; + QCPRange mapRange; + if (maps.at(i)->colorScale() == this) + { + bool currentFoundRange = true; + mapRange = maps.at(i)->data()->dataBounds(); + if (sign == 1) + { + if (mapRange.lower <= 0 && mapRange.upper > 0) + mapRange.lower = mapRange.upper*1e-3; + else if (mapRange.lower <= 0 && mapRange.upper <= 0) + currentFoundRange = false; + } else if (sign == -1) + { + if (mapRange.upper >= 0 && mapRange.lower < 0) + mapRange.upper = mapRange.lower*1e-3; + else if (mapRange.upper >= 0 && mapRange.lower >= 0) + currentFoundRange = false; + } + if (currentFoundRange) + { + if (!haveRange) + newRange = mapRange; + else + newRange.expand(mapRange); + haveRange = true; + } + } + } + if (haveRange) + { + if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this dimension), shift current range to at least center the data + { + double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason + if (mDataScaleType == QCPAxis::stLinear) + { + newRange.lower = center-mDataRange.size()/2.0; + newRange.upper = center+mDataRange.size()/2.0; + } else // mScaleType == stLogarithmic + { + newRange.lower = center/qSqrt(mDataRange.upper/mDataRange.lower); + newRange.upper = center*qSqrt(mDataRange.upper/mDataRange.lower); + } + } + setDataRange(newRange); + } +} + +/* inherits documentation from base class */ +void QCPColorScale::update(UpdatePhase phase) +{ + QCPLayoutElement::update(phase); + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + + mAxisRect.data()->update(phase); + + switch (phase) + { + case upMargins: + { + if (mType == QCPAxis::atBottom || mType == QCPAxis::atTop) + { + setMaximumSize(QWIDGETSIZE_MAX, mBarWidth+mAxisRect.data()->margins().top()+mAxisRect.data()->margins().bottom()+margins().top()+margins().bottom()); + setMinimumSize(0, mBarWidth+mAxisRect.data()->margins().top()+mAxisRect.data()->margins().bottom()+margins().top()+margins().bottom()); + } else + { + setMaximumSize(mBarWidth+mAxisRect.data()->margins().left()+mAxisRect.data()->margins().right()+margins().left()+margins().right(), QWIDGETSIZE_MAX); + setMinimumSize(mBarWidth+mAxisRect.data()->margins().left()+mAxisRect.data()->margins().right()+margins().left()+margins().right(), 0); + } + break; + } + case upLayout: + { + mAxisRect.data()->setOuterRect(rect()); + break; + } + default: break; + } +} + +/* inherits documentation from base class */ +void QCPColorScale::applyDefaultAntialiasingHint(QCPPainter *painter) const +{ + painter->setAntialiasing(false); +} + +/* inherits documentation from base class */ +void QCPColorScale::mousePressEvent(QMouseEvent *event) +{ + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + mAxisRect.data()->mousePressEvent(event); +} + +/* inherits documentation from base class */ +void QCPColorScale::mouseMoveEvent(QMouseEvent *event) +{ + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + mAxisRect.data()->mouseMoveEvent(event); +} + +/* inherits documentation from base class */ +void QCPColorScale::mouseReleaseEvent(QMouseEvent *event) +{ + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + mAxisRect.data()->mouseReleaseEvent(event); +} + +/* inherits documentation from base class */ +void QCPColorScale::wheelEvent(QWheelEvent *event) +{ + if (!mAxisRect) + { + qDebug() << Q_FUNC_INFO << "internal axis rect was deleted"; + return; + } + mAxisRect.data()->wheelEvent(event); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPColorScaleAxisRectPrivate +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPColorScaleAxisRectPrivate + + \internal + \brief An axis rect subclass for use in a QCPColorScale + + This is a private class and not part of the public QCustomPlot interface. + + It provides the axis rect functionality for the QCPColorScale class. +*/ + + +/*! + Creates a new instance, as a child of \a parentColorScale. +*/ +QCPColorScaleAxisRectPrivate::QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale) : + QCPAxisRect(parentColorScale->parentPlot(), true), + mParentColorScale(parentColorScale), + mGradientImageInvalidated(true) +{ + setParentLayerable(parentColorScale); + setMinimumMargins(QMargins(0, 0, 0, 0)); + foreach (QCPAxis::AxisType type, QList() << QCPAxis::atBottom << QCPAxis::atTop << QCPAxis::atLeft << QCPAxis::atRight) + { + axis(type)->setVisible(true); + axis(type)->grid()->setVisible(false); + axis(type)->setPadding(0); + connect(axis(type), SIGNAL(selectionChanged(QCPAxis::SelectableParts)), this, SLOT(axisSelectionChanged(QCPAxis::SelectableParts))); + connect(axis(type), SIGNAL(selectableChanged(QCPAxis::SelectableParts)), this, SLOT(axisSelectableChanged(QCPAxis::SelectableParts))); + } + + connect(axis(QCPAxis::atLeft), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atRight), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atRight), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atLeft), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atBottom), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atTop), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atTop), SIGNAL(rangeChanged(QCPRange)), axis(QCPAxis::atBottom), SLOT(setRange(QCPRange))); + connect(axis(QCPAxis::atLeft), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atRight), SLOT(setScaleType(QCPAxis::ScaleType))); + connect(axis(QCPAxis::atRight), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atLeft), SLOT(setScaleType(QCPAxis::ScaleType))); + connect(axis(QCPAxis::atBottom), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atTop), SLOT(setScaleType(QCPAxis::ScaleType))); + connect(axis(QCPAxis::atTop), SIGNAL(scaleTypeChanged(QCPAxis::ScaleType)), axis(QCPAxis::atBottom), SLOT(setScaleType(QCPAxis::ScaleType))); + + // make layer transfers of color scale transfer to axis rect and axes + // the axes must be set after axis rect, such that they appear above color gradient drawn by axis rect: + connect(parentColorScale, SIGNAL(layerChanged(QCPLayer*)), this, SLOT(setLayer(QCPLayer*))); + foreach (QCPAxis::AxisType type, QList() << QCPAxis::atBottom << QCPAxis::atTop << QCPAxis::atLeft << QCPAxis::atRight) + connect(parentColorScale, SIGNAL(layerChanged(QCPLayer*)), axis(type), SLOT(setLayer(QCPLayer*))); +} + +/*! \internal + Updates the color gradient image if necessary, by calling \ref updateGradientImage, then draws + it. Then the axes are drawn by calling the \ref QCPAxisRect::draw base class implementation. +*/ +void QCPColorScaleAxisRectPrivate::draw(QCPPainter *painter) +{ + if (mGradientImageInvalidated) + updateGradientImage(); + + bool mirrorHorz = false; + bool mirrorVert = false; + if (mParentColorScale->mColorAxis) + { + mirrorHorz = mParentColorScale->mColorAxis.data()->rangeReversed() && (mParentColorScale->type() == QCPAxis::atBottom || mParentColorScale->type() == QCPAxis::atTop); + mirrorVert = mParentColorScale->mColorAxis.data()->rangeReversed() && (mParentColorScale->type() == QCPAxis::atLeft || mParentColorScale->type() == QCPAxis::atRight); + } + + painter->drawImage(rect(), mGradientImage.mirrored(mirrorHorz, mirrorVert)); + QCPAxisRect::draw(painter); +} + +/*! \internal + + Uses the current gradient of the parent \ref QCPColorScale (specified in the constructor) to + generate a gradient image. This gradient image will be used in the \ref draw method. +*/ +void QCPColorScaleAxisRectPrivate::updateGradientImage() +{ + if (rect().isEmpty()) + return; + + int n = mParentColorScale->mGradient.levelCount(); + int w, h; + QVector data(n); + for (int i=0; imType == QCPAxis::atBottom || mParentColorScale->mType == QCPAxis::atTop) + { + w = n; + h = rect().height(); + mGradientImage = QImage(w, h, QImage::Format_RGB32); + QVector pixels; + for (int y=0; y(mGradientImage.scanLine(y))); + mParentColorScale->mGradient.colorize(data.constData(), QCPRange(0, n-1), pixels.first(), n); + for (int y=1; y(mGradientImage.scanLine(y)); + const QRgb lineColor = mParentColorScale->mGradient.color(data[h-1-y], QCPRange(0, n-1)); + for (int x=0; x() << QCPAxis::atBottom << QCPAxis::atTop << QCPAxis::atLeft << QCPAxis::atRight) + { + if (QCPAxis *senderAxis = qobject_cast(sender())) + if (senderAxis->axisType() == type) + continue; + + if (axis(type)->selectableParts().testFlag(QCPAxis::spAxis)) + { + if (selectedParts.testFlag(QCPAxis::spAxis)) + axis(type)->setSelectedParts(axis(type)->selectedParts() | QCPAxis::spAxis); + else + axis(type)->setSelectedParts(axis(type)->selectedParts() & ~QCPAxis::spAxis); + } + } +} + +/*! \internal + + This slot is connected to the selectableChanged signals of the four axes in the constructor. It + synchronizes the selectability of the axes. +*/ +void QCPColorScaleAxisRectPrivate::axisSelectableChanged(QCPAxis::SelectableParts selectableParts) +{ + // synchronize axis base selectability: + foreach (QCPAxis::AxisType type, QList() << QCPAxis::atBottom << QCPAxis::atTop << QCPAxis::atLeft << QCPAxis::atRight) + { + if (QCPAxis *senderAxis = qobject_cast(sender())) + if (senderAxis->axisType() == type) + continue; + + if (axis(type)->selectableParts().testFlag(QCPAxis::spAxis)) + { + if (selectableParts.testFlag(QCPAxis::spAxis)) + axis(type)->setSelectableParts(axis(type)->selectableParts() | QCPAxis::spAxis); + else + axis(type)->setSelectableParts(axis(type)->selectableParts() & ~QCPAxis::spAxis); + } + } +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPData +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPData + \brief Holds the data of one single data point for QCPGraph. + + The container for storing multiple data points is \ref QCPDataMap. + + The stored data is: + \li \a key: coordinate on the key axis of this data point + \li \a value: coordinate on the value axis of this data point + \li \a keyErrorMinus: negative error in the key dimension (for error bars) + \li \a keyErrorPlus: positive error in the key dimension (for error bars) + \li \a valueErrorMinus: negative error in the value dimension (for error bars) + \li \a valueErrorPlus: positive error in the value dimension (for error bars) + + \see QCPDataMap +*/ + +/*! + Constructs a data point with key, value and all errors set to zero. +*/ +QCPData::QCPData() : + key(0), + value(0), + keyErrorPlus(0), + keyErrorMinus(0), + valueErrorPlus(0), + valueErrorMinus(0) +{ +} + +/*! + Constructs a data point with the specified \a key and \a value. All errors are set to zero. +*/ +QCPData::QCPData(double key, double value) : + key(key), + value(value), + keyErrorPlus(0), + keyErrorMinus(0), + valueErrorPlus(0), + valueErrorMinus(0) +{ +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPGraph +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPGraph + \brief A plottable representing a graph in a plot. + + \image html QCPGraph.png + + Usually QCustomPlot creates graphs internally via QCustomPlot::addGraph and the resulting + instance is accessed via QCustomPlot::graph. + + To plot data, assign it with the \ref setData or \ref addData functions. Alternatively, you can + also access and modify the graph's data via the \ref data method, which returns a pointer to the + internal \ref QCPDataMap. + + Graphs are used to display single-valued data. Single-valued means that there should only be one + data point per unique key coordinate. In other words, the graph can't have \a loops. If you do + want to plot non-single-valued curves, rather use the QCPCurve plottable. + + \section appearance Changing the appearance + + The appearance of the graph is mainly determined by the line style, scatter style, brush and pen + of the graph (\ref setLineStyle, \ref setScatterStyle, \ref setBrush, \ref setPen). + + \subsection filling Filling under or between graphs + + QCPGraph knows two types of fills: Normal graph fills towards the zero-value-line parallel to + the key axis of the graph, and fills between two graphs, called channel fills. To enable a fill, + just set a brush with \ref setBrush which is neither Qt::NoBrush nor fully transparent. + + By default, a normal fill towards the zero-value-line will be drawn. To set up a channel fill + between this graph and another one, call \ref setChannelFillGraph with the other graph as + parameter. + + \see QCustomPlot::addGraph, QCustomPlot::graph, QCPLegend::addGraph +*/ + +/* start of documentation of inline functions */ + +/*! \fn QCPDataMap *QCPGraph::data() const + + Returns a pointer to the internal data storage of type \ref QCPDataMap. You may use it to + directly manipulate the data, which may be more convenient and faster than using the regular \ref + setData or \ref addData methods, in certain situations. +*/ + +/* end of documentation of inline functions */ + +/*! + Constructs a graph which uses \a keyAxis as its key axis ("x") and \a valueAxis as its value + axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and not have + the same orientation. If either of these restrictions is violated, a corresponding message is + printed to the debug output (qDebug), the construction is not aborted, though. + + The constructed QCPGraph can be added to the plot with QCustomPlot::addPlottable, QCustomPlot + then takes ownership of the graph. + + To directly create a graph inside a plot, you can also use the simpler QCustomPlot::addGraph function. +*/ +QCPGraph::QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis) +{ + mData = new QCPDataMap; + + setPen(QPen(Qt::blue, 0)); + setErrorPen(QPen(Qt::black)); + setBrush(Qt::NoBrush); + setSelectedPen(QPen(QColor(80, 80, 255), 2.5)); + setSelectedBrush(Qt::NoBrush); + + setLineStyle(lsLine); + setErrorType(etNone); + setErrorBarSize(6); + setErrorBarSkipSymbol(true); + setChannelFillGraph(0); + setAdaptiveSampling(true); +} + +QCPGraph::~QCPGraph() +{ + delete mData; +} + +/*! + Replaces the current data with the provided \a data. + + If \a copy is set to true, data points in \a data will only be copied. if false, the graph + takes ownership of the passed data and replaces the internal data pointer with it. This is + significantly faster than copying for large datasets. + + Alternatively, you can also access and modify the graph's data via the \ref data method, which + returns a pointer to the internal \ref QCPDataMap. +*/ +void QCPGraph::setData(QCPDataMap *data, bool copy) +{ + if (copy) + { + *mData = *data; + } else + { + delete mData; + mData = data; + } +} + +/*! \overload + + Replaces the current data with the provided points in \a key and \a value pairs. The provided + vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. +*/ +void QCPGraph::setData(const QVector &key, const QVector &value) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + QCPData newData; + for (int i=0; iinsertMulti(newData.key, newData); + } +} + +/*! + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + symmetrical value error of the data points are set to the values in \a valueError. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. + + For asymmetrical errors (plus different from minus), see the overloaded version of this function. +*/ +void QCPGraph::setDataValueError(const QVector &key, const QVector &value, const QVector &valueError) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, valueError.size()); + QCPData newData; + for (int i=0; iinsertMulti(key[i], newData); + } +} + +/*! + \overload + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + negative value error of the data points are set to the values in \a valueErrorMinus, the positive + value error to \a valueErrorPlus. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. +*/ +void QCPGraph::setDataValueError(const QVector &key, const QVector &value, const QVector &valueErrorMinus, const QVector &valueErrorPlus) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, valueErrorMinus.size()); + n = qMin(n, valueErrorPlus.size()); + QCPData newData; + for (int i=0; iinsertMulti(key[i], newData); + } +} + +/*! + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + symmetrical key error of the data points are set to the values in \a keyError. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. + + For asymmetrical errors (plus different from minus), see the overloaded version of this function. +*/ +void QCPGraph::setDataKeyError(const QVector &key, const QVector &value, const QVector &keyError) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, keyError.size()); + QCPData newData; + for (int i=0; iinsertMulti(key[i], newData); + } +} + +/*! + \overload + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + negative key error of the data points are set to the values in \a keyErrorMinus, the positive + key error to \a keyErrorPlus. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. +*/ +void QCPGraph::setDataKeyError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, keyErrorMinus.size()); + n = qMin(n, keyErrorPlus.size()); + QCPData newData; + for (int i=0; iinsertMulti(key[i], newData); + } +} + +/*! + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + symmetrical key and value errors of the data points are set to the values in \a keyError and \a valueError. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. + + For asymmetrical errors (plus different from minus), see the overloaded version of this function. +*/ +void QCPGraph::setDataBothError(const QVector &key, const QVector &value, const QVector &keyError, const QVector &valueError) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, valueError.size()); + n = qMin(n, keyError.size()); + QCPData newData; + for (int i=0; iinsertMulti(key[i], newData); + } +} + +/*! + \overload + Replaces the current data with the provided points in \a key and \a value pairs. Additionally the + negative key and value errors of the data points are set to the values in \a keyErrorMinus and \a valueErrorMinus. The positive + key and value errors are set to the values in \a keyErrorPlus \a valueErrorPlus. + For error bars to show appropriately, see \ref setErrorType. + The provided vectors should have equal length. Else, the number of added points will be the size of the + smallest vector. +*/ +void QCPGraph::setDataBothError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus, const QVector &valueErrorMinus, const QVector &valueErrorPlus) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + n = qMin(n, valueErrorMinus.size()); + n = qMin(n, valueErrorPlus.size()); + n = qMin(n, keyErrorMinus.size()); + n = qMin(n, keyErrorPlus.size()); + QCPData newData; + for (int i=0; iinsertMulti(key[i], newData); + } +} + + +/*! + Sets how the single data points are connected in the plot. For scatter-only plots, set \a ls to + \ref lsNone and \ref setScatterStyle to the desired scatter style. + + \see setScatterStyle +*/ +void QCPGraph::setLineStyle(LineStyle ls) +{ + mLineStyle = ls; +} + +/*! + Sets the visual appearance of single data points in the plot. If set to \ref QCPScatterStyle::ssNone, no scatter points + are drawn (e.g. for line-only-plots with appropriate line style). + + \see QCPScatterStyle, setLineStyle +*/ +void QCPGraph::setScatterStyle(const QCPScatterStyle &style) +{ + mScatterStyle = style; +} + +/*! + Sets which kind of error bars (Key Error, Value Error or both) should be drawn on each data + point. If you set \a errorType to something other than \ref etNone, make sure to actually pass + error data via the specific setData functions along with the data points (e.g. \ref + setDataValueError, \ref setDataKeyError, \ref setDataBothError). + + \see ErrorType +*/ +void QCPGraph::setErrorType(ErrorType errorType) +{ + mErrorType = errorType; +} + +/*! + Sets the pen with which the error bars will be drawn. + \see setErrorBarSize, setErrorType +*/ +void QCPGraph::setErrorPen(const QPen &pen) +{ + mErrorPen = pen; +} + +/*! + Sets the width of the handles at both ends of an error bar in pixels. +*/ +void QCPGraph::setErrorBarSize(double size) +{ + mErrorBarSize = size; +} + +/*! + If \a enabled is set to true, the error bar will not be drawn as a solid line under the scatter symbol but + leave some free space around the symbol. + + This feature uses the current scatter size (\ref QCPScatterStyle::setSize) to determine the size + of the area to leave blank. So when drawing Pixmaps as scatter points (\ref + QCPScatterStyle::ssPixmap), the scatter size must be set manually to a value corresponding to the + size of the Pixmap, if the error bars should leave gaps to its boundaries. + + \ref setErrorType, setErrorBarSize, setScatterStyle +*/ +void QCPGraph::setErrorBarSkipSymbol(bool enabled) +{ + mErrorBarSkipSymbol = enabled; +} + +/*! + Sets the target graph for filling the area between this graph and \a targetGraph with the current + brush (\ref setBrush). + + When \a targetGraph is set to 0, a normal graph fill to the zero-value-line will be shown. To + disable any filling, set the brush to Qt::NoBrush. + + \see setBrush +*/ +void QCPGraph::setChannelFillGraph(QCPGraph *targetGraph) +{ + // prevent setting channel target to this graph itself: + if (targetGraph == this) + { + qDebug() << Q_FUNC_INFO << "targetGraph is this graph itself"; + mChannelFillGraph = 0; + return; + } + // prevent setting channel target to a graph not in the plot: + if (targetGraph && targetGraph->mParentPlot != mParentPlot) + { + qDebug() << Q_FUNC_INFO << "targetGraph not in same plot"; + mChannelFillGraph = 0; + return; + } + + mChannelFillGraph = targetGraph; +} + +/*! + Sets whether adaptive sampling shall be used when plotting this graph. QCustomPlot's adaptive + sampling technique can drastically improve the replot performance for graphs with a larger number + of points (e.g. above 10,000), without notably changing the appearance of the graph. + + By default, adaptive sampling is enabled. Even if enabled, QCustomPlot decides whether adaptive + sampling shall actually be used on a per-graph basis. So leaving adaptive sampling enabled has no + disadvantage in almost all cases. + + \image html adaptive-sampling-line.png "A line plot of 500,000 points without and with adaptive sampling" + + As can be seen, line plots experience no visual degradation from adaptive sampling. Outliers are + reproduced reliably, as well as the overall shape of the data set. The replot time reduces + dramatically though. This allows QCustomPlot to display large amounts of data in realtime. + + \image html adaptive-sampling-scatter.png "A scatter plot of 100,000 points without and with adaptive sampling" + + Care must be taken when using high-density scatter plots in combination with adaptive sampling. + The adaptive sampling algorithm treats scatter plots more carefully than line plots which still + gives a significant reduction of replot times, but not quite as much as for line plots. This is + because scatter plots inherently need more data points to be preserved in order to still resemble + the original, non-adaptive-sampling plot. As shown above, the results still aren't quite + identical, as banding occurs for the outer data points. This is in fact intentional, such that + the boundaries of the data cloud stay visible to the viewer. How strong the banding appears, + depends on the point density, i.e. the number of points in the plot. + + For some situations with scatter plots it might thus be desirable to manually turn adaptive + sampling off. For example, when saving the plot to disk. This can be achieved by setting \a + enabled to false before issuing a command like \ref QCustomPlot::savePng, and setting \a enabled + back to true afterwards. +*/ +void QCPGraph::setAdaptiveSampling(bool enabled) +{ + mAdaptiveSampling = enabled; +} + +/*! + Adds the provided data points in \a dataMap to the current data. + + Alternatively, you can also access and modify the graph's data via the \ref data method, which + returns a pointer to the internal \ref QCPDataMap. + + \see removeData +*/ +void QCPGraph::addData(const QCPDataMap &dataMap) +{ + mData->unite(dataMap); +} + +/*! \overload + Adds the provided single data point in \a data to the current data. + + Alternatively, you can also access and modify the graph's data via the \ref data method, which + returns a pointer to the internal \ref QCPDataMap. + + \see removeData +*/ +void QCPGraph::addData(const QCPData &data) +{ + mData->insertMulti(data.key, data); +} + +/*! \overload + Adds the provided single data point as \a key and \a value pair to the current data. + + Alternatively, you can also access and modify the graph's data via the \ref data method, which + returns a pointer to the internal \ref QCPDataMap. + + \see removeData +*/ +void QCPGraph::addData(double key, double value) +{ + QCPData newData; + newData.key = key; + newData.value = value; + mData->insertMulti(newData.key, newData); +} + +/*! \overload + Adds the provided data points as \a key and \a value pairs to the current data. + + Alternatively, you can also access and modify the graph's data via the \ref data method, which + returns a pointer to the internal \ref QCPDataMap. + + \see removeData +*/ +void QCPGraph::addData(const QVector &keys, const QVector &values) +{ + int n = qMin(keys.size(), values.size()); + QCPData newData; + for (int i=0; iinsertMulti(newData.key, newData); + } +} + +/*! + Removes all data points with keys smaller than \a key. + \see addData, clearData +*/ +void QCPGraph::removeDataBefore(double key) +{ + QCPDataMap::iterator it = mData->begin(); + while (it != mData->end() && it.key() < key) + it = mData->erase(it); +} + +/*! + Removes all data points with keys greater than \a key. + \see addData, clearData +*/ +void QCPGraph::removeDataAfter(double key) +{ + if (mData->isEmpty()) return; + QCPDataMap::iterator it = mData->upperBound(key); + while (it != mData->end()) + it = mData->erase(it); +} + +/*! + Removes all data points with keys between \a fromKey and \a toKey. + if \a fromKey is greater or equal to \a toKey, the function does nothing. To remove + a single data point with known key, use \ref removeData(double key). + + \see addData, clearData +*/ +void QCPGraph::removeData(double fromKey, double toKey) +{ + if (fromKey >= toKey || mData->isEmpty()) return; + QCPDataMap::iterator it = mData->upperBound(fromKey); + QCPDataMap::iterator itEnd = mData->upperBound(toKey); + while (it != itEnd) + it = mData->erase(it); +} + +/*! \overload + + Removes a single data point at \a key. If the position is not known with absolute precision, + consider using \ref removeData(double fromKey, double toKey) with a small fuzziness interval around + the suspected position, depeding on the precision with which the key is known. + + \see addData, clearData +*/ +void QCPGraph::removeData(double key) +{ + mData->remove(key); +} + +/*! + Removes all data points. + \see removeData, removeDataAfter, removeDataBefore +*/ +void QCPGraph::clearData() +{ + mData->clear(); +} + +/* inherits documentation from base class */ +double QCPGraph::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if ((onlySelectable && !mSelectable) || mData->isEmpty()) + return -1; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) + return pointDistance(pos); + else + return -1; +} + +/*! \overload + + Allows to define whether error bars are taken into consideration when determining the new axis + range. + + \see rescaleKeyAxis, rescaleValueAxis, QCPAbstractPlottable::rescaleAxes, QCustomPlot::rescaleAxes +*/ +void QCPGraph::rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const +{ + rescaleKeyAxis(onlyEnlarge, includeErrorBars); + rescaleValueAxis(onlyEnlarge, includeErrorBars); +} + +/*! \overload + + Allows to define whether error bars (of kind \ref QCPGraph::etKey) are taken into consideration + when determining the new axis range. + + \see rescaleAxes, QCPAbstractPlottable::rescaleKeyAxis +*/ +void QCPGraph::rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const +{ + // this code is a copy of QCPAbstractPlottable::rescaleKeyAxis with the only change + // that getKeyRange is passed the includeErrorBars value. + if (mData->isEmpty()) return; + + QCPAxis *keyAxis = mKeyAxis.data(); + if (!keyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } + + SignDomain signDomain = sdBoth; + if (keyAxis->scaleType() == QCPAxis::stLogarithmic) + signDomain = (keyAxis->range().upper < 0 ? sdNegative : sdPositive); + + bool foundRange; + QCPRange newRange = getKeyRange(foundRange, signDomain, includeErrorBars); + + if (foundRange) + { + if (onlyEnlarge) + { + if (keyAxis->range().lower < newRange.lower) + newRange.lower = keyAxis->range().lower; + if (keyAxis->range().upper > newRange.upper) + newRange.upper = keyAxis->range().upper; + } + keyAxis->setRange(newRange); + } +} + +/*! \overload + + Allows to define whether error bars (of kind \ref QCPGraph::etValue) are taken into consideration + when determining the new axis range. + + \see rescaleAxes, QCPAbstractPlottable::rescaleValueAxis +*/ +void QCPGraph::rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) const +{ + // this code is a copy of QCPAbstractPlottable::rescaleValueAxis with the only change + // is that getValueRange is passed the includeErrorBars value. + if (mData->isEmpty()) return; + + QCPAxis *valueAxis = mValueAxis.data(); + if (!valueAxis) { qDebug() << Q_FUNC_INFO << "invalid value axis"; return; } + + SignDomain signDomain = sdBoth; + if (valueAxis->scaleType() == QCPAxis::stLogarithmic) + signDomain = (valueAxis->range().upper < 0 ? sdNegative : sdPositive); + + bool foundRange; + QCPRange newRange = getValueRange(foundRange, signDomain, includeErrorBars); + + if (foundRange) + { + if (onlyEnlarge) + { + if (valueAxis->range().lower < newRange.lower) + newRange.lower = valueAxis->range().lower; + if (valueAxis->range().upper > newRange.upper) + newRange.upper = valueAxis->range().upper; + } + valueAxis->setRange(newRange); + } +} + +/* inherits documentation from base class */ +void QCPGraph::draw(QCPPainter *painter) +{ + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (mKeyAxis.data()->range().size() <= 0 || mData->isEmpty()) return; + if (mLineStyle == lsNone && mScatterStyle.isNone()) return; + + // allocate line and (if necessary) point vectors: + QVector *lineData = new QVector; + QVector *scatterData = 0; + if (!mScatterStyle.isNone()) + scatterData = new QVector; + + // fill vectors with data appropriate to plot style: + getPlotData(lineData, scatterData); + + // check data validity if flag set: +#ifdef QCUSTOMPLOT_CHECK_DATA + QCPDataMap::const_iterator it; + for (it = mData->constBegin(); it != mData->constEnd(); ++it) + { + if (QCP::isInvalidData(it.value().key, it.value().value) || + QCP::isInvalidData(it.value().keyErrorPlus, it.value().keyErrorMinus) || + QCP::isInvalidData(it.value().valueErrorPlus, it.value().valueErrorPlus)) + qDebug() << Q_FUNC_INFO << "Data point at" << it.key() << "invalid." << "Plottable name:" << name(); + } +#endif + + // draw fill of graph: + drawFill(painter, lineData); + + // draw line: + if (mLineStyle == lsImpulse) + drawImpulsePlot(painter, lineData); + else if (mLineStyle != lsNone) + drawLinePlot(painter, lineData); // also step plots can be drawn as a line plot + + // draw scatters: + if (scatterData) + drawScatterPlot(painter, scatterData); + + // free allocated line and point vectors: + delete lineData; + if (scatterData) + delete scatterData; +} + +/* inherits documentation from base class */ +void QCPGraph::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +{ + // draw fill: + if (mBrush.style() != Qt::NoBrush) + { + applyFillAntialiasingHint(painter); + painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0), mBrush); + } + // draw line vertically centered: + if (mLineStyle != lsNone) + { + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + painter->drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0)); // +5 on x2 else last segment is missing from dashed/dotted pens + } + // draw scatter symbol: + if (!mScatterStyle.isNone()) + { + applyScattersAntialiasingHint(painter); + // scale scatter pixmap if it's too large to fit in legend icon rect: + if (mScatterStyle.shape() == QCPScatterStyle::ssPixmap && (mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height())) + { + QCPScatterStyle scaledStyle(mScatterStyle); + scaledStyle.setPixmap(scaledStyle.pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); + scaledStyle.applyTo(painter, mPen); + scaledStyle.drawShape(painter, QRectF(rect).center()); + } else + { + mScatterStyle.applyTo(painter, mPen); + mScatterStyle.drawShape(painter, QRectF(rect).center()); + } + } +} + +/*! \internal + + This function branches out to the line style specific "get(...)PlotData" functions, according to + the line style of the graph. + + \a lineData will be filled with raw points that will be drawn with the according draw functions, + e.g. \ref drawLinePlot and \ref drawImpulsePlot. These aren't necessarily the original data + points, since for step plots for example, additional points are needed for drawing lines that + make up steps. If the line style of the graph is \ref lsNone, the \a lineData vector will be left + untouched. + + \a scatterData will be filled with the original data points so \ref drawScatterPlot can draw the + scatter symbols accordingly. If no scatters need to be drawn, i.e. the scatter style's shape is + \ref QCPScatterStyle::ssNone, pass 0 as \a scatterData, and this step will be skipped. + + \see getScatterPlotData, getLinePlotData, getStepLeftPlotData, getStepRightPlotData, + getStepCenterPlotData, getImpulsePlotData +*/ +void QCPGraph::getPlotData(QVector *lineData, QVector *scatterData) const +{ + switch(mLineStyle) + { + case lsNone: getScatterPlotData(scatterData); break; + case lsLine: getLinePlotData(lineData, scatterData); break; + case lsStepLeft: getStepLeftPlotData(lineData, scatterData); break; + case lsStepRight: getStepRightPlotData(lineData, scatterData); break; + case lsStepCenter: getStepCenterPlotData(lineData, scatterData); break; + case lsImpulse: getImpulsePlotData(lineData, scatterData); break; + } +} + +/*! \internal + + If line style is \ref lsNone and the scatter style's shape is not \ref QCPScatterStyle::ssNone, + this function serves at providing the visible data points in \a scatterData, so the \ref + drawScatterPlot function can draw the scatter points accordingly. + + If line style is not \ref lsNone, this function is not called and the data for the scatter points + are (if needed) calculated inside the corresponding other "get(...)PlotData" functions. + + \see drawScatterPlot +*/ +void QCPGraph::getScatterPlotData(QVector *scatterData) const +{ + getPreparedData(0, scatterData); +} + +/*! \internal + + Places the raw data points needed for a normal linearly connected graph in \a linePixelData. + + As for all plot data retrieval functions, \a scatterData just contains all unaltered data (scatter) + points that are visible for drawing scatter points, if necessary. If drawing scatter points is + disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a + scatterData, and the function will skip filling the vector. + + \see drawLinePlot +*/ +void QCPGraph::getLinePlotData(QVector *linePixelData, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (!linePixelData) { qDebug() << Q_FUNC_INFO << "null pointer passed as linePixelData"; return; } + + QVector lineData; + getPreparedData(&lineData, scatterData); + linePixelData->reserve(lineData.size()+2); // added 2 to reserve memory for lower/upper fill base points that might be needed for fill + linePixelData->resize(lineData.size()); + + // transform lineData points to pixels: + if (keyAxis->orientation() == Qt::Vertical) + { + for (int i=0; icoordToPixel(lineData.at(i).value)); + (*linePixelData)[i].setY(keyAxis->coordToPixel(lineData.at(i).key)); + } + } else // key axis is horizontal + { + for (int i=0; icoordToPixel(lineData.at(i).key)); + (*linePixelData)[i].setY(valueAxis->coordToPixel(lineData.at(i).value)); + } + } +} + +/*! + \internal + Places the raw data points needed for a step plot with left oriented steps in \a lineData. + + As for all plot data retrieval functions, \a scatterData just contains all unaltered data (scatter) + points that are visible for drawing scatter points, if necessary. If drawing scatter points is + disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a + scatterData, and the function will skip filling the vector. + + \see drawLinePlot +*/ +void QCPGraph::getStepLeftPlotData(QVector *linePixelData, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (!linePixelData) { qDebug() << Q_FUNC_INFO << "null pointer passed as lineData"; return; } + + QVector lineData; + getPreparedData(&lineData, scatterData); + linePixelData->reserve(lineData.size()*2+2); // added 2 to reserve memory for lower/upper fill base points that might be needed for fill + linePixelData->resize(lineData.size()*2); + + // calculate steps from lineData and transform to pixel coordinates: + if (keyAxis->orientation() == Qt::Vertical) + { + double lastValue = valueAxis->coordToPixel(lineData.first().value); + double key; + for (int i=0; icoordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(lastValue); + (*linePixelData)[i*2+0].setY(key); + lastValue = valueAxis->coordToPixel(lineData.at(i).value); + (*linePixelData)[i*2+1].setX(lastValue); + (*linePixelData)[i*2+1].setY(key); + } + } else // key axis is horizontal + { + double lastValue = valueAxis->coordToPixel(lineData.first().value); + double key; + for (int i=0; icoordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(key); + (*linePixelData)[i*2+0].setY(lastValue); + lastValue = valueAxis->coordToPixel(lineData.at(i).value); + (*linePixelData)[i*2+1].setX(key); + (*linePixelData)[i*2+1].setY(lastValue); + } + } +} + +/*! + \internal + Places the raw data points needed for a step plot with right oriented steps in \a lineData. + + As for all plot data retrieval functions, \a scatterData just contains all unaltered data (scatter) + points that are visible for drawing scatter points, if necessary. If drawing scatter points is + disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a + scatterData, and the function will skip filling the vector. + + \see drawLinePlot +*/ +void QCPGraph::getStepRightPlotData(QVector *linePixelData, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (!linePixelData) { qDebug() << Q_FUNC_INFO << "null pointer passed as lineData"; return; } + + QVector lineData; + getPreparedData(&lineData, scatterData); + linePixelData->reserve(lineData.size()*2+2); // added 2 to reserve memory for lower/upper fill base points that might be needed for fill + linePixelData->resize(lineData.size()*2); + + // calculate steps from lineData and transform to pixel coordinates: + if (keyAxis->orientation() == Qt::Vertical) + { + double lastKey = keyAxis->coordToPixel(lineData.first().key); + double value; + for (int i=0; icoordToPixel(lineData.at(i).value); + (*linePixelData)[i*2+0].setX(value); + (*linePixelData)[i*2+0].setY(lastKey); + lastKey = keyAxis->coordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+1].setX(value); + (*linePixelData)[i*2+1].setY(lastKey); + } + } else // key axis is horizontal + { + double lastKey = keyAxis->coordToPixel(lineData.first().key); + double value; + for (int i=0; icoordToPixel(lineData.at(i).value); + (*linePixelData)[i*2+0].setX(lastKey); + (*linePixelData)[i*2+0].setY(value); + lastKey = keyAxis->coordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+1].setX(lastKey); + (*linePixelData)[i*2+1].setY(value); + } + } +} + +/*! + \internal + Places the raw data points needed for a step plot with centered steps in \a lineData. + + As for all plot data retrieval functions, \a scatterData just contains all unaltered data (scatter) + points that are visible for drawing scatter points, if necessary. If drawing scatter points is + disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a + scatterData, and the function will skip filling the vector. + + \see drawLinePlot +*/ +void QCPGraph::getStepCenterPlotData(QVector *linePixelData, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (!linePixelData) { qDebug() << Q_FUNC_INFO << "null pointer passed as lineData"; return; } + + QVector lineData; + getPreparedData(&lineData, scatterData); + linePixelData->reserve(lineData.size()*2+2); // added 2 to reserve memory for lower/upper fill base points that might be needed for fill + linePixelData->resize(lineData.size()*2); + // calculate steps from lineData and transform to pixel coordinates: + if (keyAxis->orientation() == Qt::Vertical) + { + double lastKey = keyAxis->coordToPixel(lineData.first().key); + double lastValue = valueAxis->coordToPixel(lineData.first().value); + double key; + (*linePixelData)[0].setX(lastValue); + (*linePixelData)[0].setY(lastKey); + for (int i=1; icoordToPixel(lineData.at(i).key)+lastKey)*0.5; + (*linePixelData)[i*2-1].setX(lastValue); + (*linePixelData)[i*2-1].setY(key); + lastValue = valueAxis->coordToPixel(lineData.at(i).value); + lastKey = keyAxis->coordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(lastValue); + (*linePixelData)[i*2+0].setY(key); + } + (*linePixelData)[lineData.size()*2-1].setX(lastValue); + (*linePixelData)[lineData.size()*2-1].setY(lastKey); + } else // key axis is horizontal + { + double lastKey = keyAxis->coordToPixel(lineData.first().key); + double lastValue = valueAxis->coordToPixel(lineData.first().value); + double key; + (*linePixelData)[0].setX(lastKey); + (*linePixelData)[0].setY(lastValue); + for (int i=1; icoordToPixel(lineData.at(i).key)+lastKey)*0.5; + (*linePixelData)[i*2-1].setX(key); + (*linePixelData)[i*2-1].setY(lastValue); + lastValue = valueAxis->coordToPixel(lineData.at(i).value); + lastKey = keyAxis->coordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(key); + (*linePixelData)[i*2+0].setY(lastValue); + } + (*linePixelData)[lineData.size()*2-1].setX(lastKey); + (*linePixelData)[lineData.size()*2-1].setY(lastValue); + } + +} + +/*! + \internal + Places the raw data points needed for an impulse plot in \a lineData. + + As for all plot data retrieval functions, \a scatterData just contains all unaltered data (scatter) + points that are visible for drawing scatter points, if necessary. If drawing scatter points is + disabled (i.e. the scatter style's shape is \ref QCPScatterStyle::ssNone), pass 0 as \a + scatterData, and the function will skip filling the vector. + + \see drawImpulsePlot +*/ +void QCPGraph::getImpulsePlotData(QVector *linePixelData, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (!linePixelData) { qDebug() << Q_FUNC_INFO << "null pointer passed as linePixelData"; return; } + + QVector lineData; + getPreparedData(&lineData, scatterData); + linePixelData->resize(lineData.size()*2); // no need to reserve 2 extra points because impulse plot has no fill + + // transform lineData points to pixels: + if (keyAxis->orientation() == Qt::Vertical) + { + double zeroPointX = valueAxis->coordToPixel(0); + double key; + for (int i=0; icoordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(zeroPointX); + (*linePixelData)[i*2+0].setY(key); + (*linePixelData)[i*2+1].setX(valueAxis->coordToPixel(lineData.at(i).value)); + (*linePixelData)[i*2+1].setY(key); + } + } else // key axis is horizontal + { + double zeroPointY = valueAxis->coordToPixel(0); + double key; + for (int i=0; icoordToPixel(lineData.at(i).key); + (*linePixelData)[i*2+0].setX(key); + (*linePixelData)[i*2+0].setY(zeroPointY); + (*linePixelData)[i*2+1].setX(key); + (*linePixelData)[i*2+1].setY(valueAxis->coordToPixel(lineData.at(i).value)); + } + } +} + +/*! \internal + + Draws the fill of the graph with the specified brush. + + If the fill is a normal fill towards the zero-value-line, only the \a lineData is required (and + two extra points at the zero-value-line, which are added by \ref addFillBasePoints and removed by + \ref removeFillBasePoints after the fill drawing is done). + + If the fill is a channel fill between this QCPGraph and another QCPGraph (mChannelFillGraph), the + more complex polygon is calculated with the \ref getChannelFillPolygon function. + + \see drawLinePlot +*/ +void QCPGraph::drawFill(QCPPainter *painter, QVector *lineData) const +{ + if (mLineStyle == lsImpulse) return; // fill doesn't make sense for impulse plot + if (mainBrush().style() == Qt::NoBrush || mainBrush().color().alpha() == 0) return; + + applyFillAntialiasingHint(painter); + if (!mChannelFillGraph) + { + // draw base fill under graph, fill goes all the way to the zero-value-line: + addFillBasePoints(lineData); + painter->setPen(Qt::NoPen); + painter->setBrush(mainBrush()); + painter->drawPolygon(QPolygonF(*lineData)); + removeFillBasePoints(lineData); + } else + { + // draw channel fill between this graph and mChannelFillGraph: + painter->setPen(Qt::NoPen); + painter->setBrush(mainBrush()); + painter->drawPolygon(getChannelFillPolygon(lineData)); + } +} + +/*! \internal + + Draws scatter symbols at every data point passed in \a scatterData. scatter symbols are independent + of the line style and are always drawn if the scatter style's shape is not \ref + QCPScatterStyle::ssNone. Hence, the \a scatterData vector is outputted by all "get(...)PlotData" + functions, together with the (line style dependent) line data. + + \see drawLinePlot, drawImpulsePlot +*/ +void QCPGraph::drawScatterPlot(QCPPainter *painter, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + // draw error bars: + if (mErrorType != etNone) + { + applyErrorBarsAntialiasingHint(painter); + painter->setPen(mErrorPen); + if (keyAxis->orientation() == Qt::Vertical) + { + for (int i=0; isize(); ++i) + drawError(painter, valueAxis->coordToPixel(scatterData->at(i).value), keyAxis->coordToPixel(scatterData->at(i).key), scatterData->at(i)); + } else + { + for (int i=0; isize(); ++i) + drawError(painter, keyAxis->coordToPixel(scatterData->at(i).key), valueAxis->coordToPixel(scatterData->at(i).value), scatterData->at(i)); + } + } + + // draw scatter point symbols: + applyScattersAntialiasingHint(painter); + mScatterStyle.applyTo(painter, mPen); + if (keyAxis->orientation() == Qt::Vertical) + { + for (int i=0; isize(); ++i) + if (!qIsNaN(scatterData->at(i).value)) + mScatterStyle.drawShape(painter, valueAxis->coordToPixel(scatterData->at(i).value), keyAxis->coordToPixel(scatterData->at(i).key)); + } else + { + for (int i=0; isize(); ++i) + if (!qIsNaN(scatterData->at(i).value)) + mScatterStyle.drawShape(painter, keyAxis->coordToPixel(scatterData->at(i).key), valueAxis->coordToPixel(scatterData->at(i).value)); + } +} + +/*! \internal + + Draws line graphs from the provided data. It connects all points in \a lineData, which was + created by one of the "get(...)PlotData" functions for line styles that require simple line + connections between the point vector they create. These are for example \ref getLinePlotData, + \ref getStepLeftPlotData, \ref getStepRightPlotData and \ref getStepCenterPlotData. + + \see drawScatterPlot, drawImpulsePlot +*/ +void QCPGraph::drawLinePlot(QCPPainter *painter, QVector *lineData) const +{ + // draw line of graph: + if (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) + { + applyDefaultAntialiasingHint(painter); + painter->setPen(mainPen()); + painter->setBrush(Qt::NoBrush); + + /* Draws polyline in batches, currently not used: + int p = 0; + while (p < lineData->size()) + { + int batch = qMin(25, lineData->size()-p); + if (p != 0) + { + ++batch; + --p; // to draw the connection lines between two batches + } + painter->drawPolyline(lineData->constData()+p, batch); + p += batch; + } + */ + + // if drawing solid line and not in PDF, use much faster line drawing instead of polyline: + if (mParentPlot->plottingHints().testFlag(QCP::phFastPolylines) && + painter->pen().style() == Qt::SolidLine && + !painter->modes().testFlag(QCPPainter::pmVectorized)&& + !painter->modes().testFlag(QCPPainter::pmNoCaching)) + { + int i = 1; + int lineDataSize = lineData->size(); + while (i < lineDataSize) + { + if (!qIsNaN(lineData->at(i).y()) && !qIsNaN(lineData->at(i).x())) // NaNs create a gap in the line + painter->drawLine(lineData->at(i-1), lineData->at(i)); + else + ++i; + ++i; + } + } else + { + int segmentStart = 0; + int i = 0; + int lineDataSize = lineData->size(); + while (i < lineDataSize) + { + if (qIsNaN(lineData->at(i).y()) || qIsNaN(lineData->at(i).x())) // NaNs create a gap in the line + { + painter->drawPolyline(lineData->constData()+segmentStart, i-segmentStart); // i, because we don't want to include the current NaN point + segmentStart = i+1; + } + ++i; + } + // draw last segment: + painter->drawPolyline(lineData->constData()+segmentStart, lineDataSize-segmentStart); // lineDataSize, because we do want to include the last point + } + } +} + +/*! \internal + + Draws impulses from the provided data, i.e. it connects all line pairs in \a lineData, which was + created by \ref getImpulsePlotData. + + \see drawScatterPlot, drawLinePlot +*/ +void QCPGraph::drawImpulsePlot(QCPPainter *painter, QVector *lineData) const +{ + // draw impulses: + if (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) + { + applyDefaultAntialiasingHint(painter); + QPen pen = mainPen(); + pen.setCapStyle(Qt::FlatCap); // so impulse line doesn't reach beyond zero-line + painter->setPen(pen); + painter->setBrush(Qt::NoBrush); + painter->drawLines(*lineData); + } +} + +/*! \internal + + Returns the \a lineData and \a scatterData that need to be plotted for this graph taking into + consideration the current axis ranges and, if \ref setAdaptiveSampling is enabled, local point + densities. + + 0 may be passed as \a lineData or \a scatterData to indicate that the respective dataset isn't + needed. For example, if the scatter style (\ref setScatterStyle) is \ref QCPScatterStyle::ssNone, \a + scatterData should be 0 to prevent unnecessary calculations. + + This method is used by the various "get(...)PlotData" methods to get the basic working set of data. +*/ +void QCPGraph::getPreparedData(QVector *lineData, QVector *scatterData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + // get visible data range: + QCPDataMap::const_iterator lower, upper; // note that upper is the actual upper point, and not 1 step after the upper point + getVisibleDataBounds(lower, upper); + if (lower == mData->constEnd() || upper == mData->constEnd()) + return; + + // count points in visible range, taking into account that we only need to count to the limit maxCount if using adaptive sampling: + int maxCount = std::numeric_limits::max(); + if (mAdaptiveSampling) + { + int keyPixelSpan = qAbs(keyAxis->coordToPixel(lower.key())-keyAxis->coordToPixel(upper.key())); + maxCount = 2*keyPixelSpan+2; + } + int dataCount = countDataInBounds(lower, upper, maxCount); + + if (mAdaptiveSampling && dataCount >= maxCount) // use adaptive sampling only if there are at least two points per pixel on average + { + if (lineData) + { + QCPDataMap::const_iterator it = lower; + QCPDataMap::const_iterator upperEnd = upper+1; + double minValue = it.value().value; + double maxValue = it.value().value; + QCPDataMap::const_iterator currentIntervalFirstPoint = it; + int reversedFactor = keyAxis->rangeReversed() ? -1 : 1; // is used to calculate keyEpsilon pixel into the correct direction + int reversedRound = keyAxis->rangeReversed() ? 1 : 0; // is used to switch between floor (normal) and ceil (reversed) rounding of currentIntervalStartKey + double currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(lower.key())+reversedRound)); + double lastIntervalEndKey = currentIntervalStartKey; + double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); // interval of one pixel on screen when mapped to plot key coordinates + bool keyEpsilonVariable = keyAxis->scaleType() == QCPAxis::stLogarithmic; // indicates whether keyEpsilon needs to be updated after every interval (for log axes) + int intervalDataCount = 1; + ++it; // advance iterator to second data point because adaptive sampling works in 1 point retrospect + while (it != upperEnd) + { + if (it.key() < currentIntervalStartKey+keyEpsilon) // data point is still within same pixel, so skip it and expand value span of this cluster if necessary + { + if (it.value().value < minValue) + minValue = it.value().value; + else if (it.value().value > maxValue) + maxValue = it.value().value; + ++intervalDataCount; + } else // new pixel interval started + { + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them to a cluster + { + if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon) // last point is further away, so first point of this cluster must be at a real data point + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint.value().value)); + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.25, minValue)); + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.75, maxValue)); + if (it.key() > currentIntervalStartKey+keyEpsilon*2) // new pixel started further away from previous cluster, so make sure the last point of the cluster is at a real data point + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.8, (it-1).value().value)); + } else + lineData->append(QCPData(currentIntervalFirstPoint.key(), currentIntervalFirstPoint.value().value)); + lastIntervalEndKey = (it-1).value().key; + minValue = it.value().value; + maxValue = it.value().value; + currentIntervalFirstPoint = it; + currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(it.key())+reversedRound)); + if (keyEpsilonVariable) + keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); + intervalDataCount = 1; + } + ++it; + } + // handle last interval: + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them to a cluster + { + if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon) // last point wasn't a cluster, so first point of this cluster must be at a real data point + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint.value().value)); + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.25, minValue)); + lineData->append(QCPData(currentIntervalStartKey+keyEpsilon*0.75, maxValue)); + } else + lineData->append(QCPData(currentIntervalFirstPoint.key(), currentIntervalFirstPoint.value().value)); + } + + if (scatterData) + { + double valueMaxRange = valueAxis->range().upper; + double valueMinRange = valueAxis->range().lower; + QCPDataMap::const_iterator it = lower; + QCPDataMap::const_iterator upperEnd = upper+1; + double minValue = it.value().value; + double maxValue = it.value().value; + QCPDataMap::const_iterator minValueIt = it; + QCPDataMap::const_iterator maxValueIt = it; + QCPDataMap::const_iterator currentIntervalStart = it; + int reversedFactor = keyAxis->rangeReversed() ? -1 : 1; // is used to calculate keyEpsilon pixel into the correct direction + int reversedRound = keyAxis->rangeReversed() ? 1 : 0; // is used to switch between floor (normal) and ceil (reversed) rounding of currentIntervalStartKey + double currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(lower.key())+reversedRound)); + double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); // interval of one pixel on screen when mapped to plot key coordinates + bool keyEpsilonVariable = keyAxis->scaleType() == QCPAxis::stLogarithmic; // indicates whether keyEpsilon needs to be updated after every interval (for log axes) + int intervalDataCount = 1; + ++it; // advance iterator to second data point because adaptive sampling works in 1 point retrospect + while (it != upperEnd) + { + if (it.key() < currentIntervalStartKey+keyEpsilon) // data point is still within same pixel, so skip it and expand value span of this pixel if necessary + { + if (it.value().value < minValue && it.value().value > valueMinRange && it.value().value < valueMaxRange) + { + minValue = it.value().value; + minValueIt = it; + } else if (it.value().value > maxValue && it.value().value > valueMinRange && it.value().value < valueMaxRange) + { + maxValue = it.value().value; + maxValueIt = it; + } + ++intervalDataCount; + } else // new pixel started + { + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them + { + // determine value pixel span and add as many points in interval to maintain certain vertical data density (this is specific to scatter plot): + double valuePixelSpan = qAbs(valueAxis->coordToPixel(minValue)-valueAxis->coordToPixel(maxValue)); + int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0))); // approximately every 4 value pixels one data point on average + QCPDataMap::const_iterator intervalIt = currentIntervalStart; + int c = 0; + while (intervalIt != it) + { + if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt.value().value > valueMinRange && intervalIt.value().value < valueMaxRange) + scatterData->append(intervalIt.value()); + ++c; + ++intervalIt; + } + } else if (currentIntervalStart.value().value > valueMinRange && currentIntervalStart.value().value < valueMaxRange) + scatterData->append(currentIntervalStart.value()); + minValue = it.value().value; + maxValue = it.value().value; + currentIntervalStart = it; + currentIntervalStartKey = keyAxis->pixelToCoord((int)(keyAxis->coordToPixel(it.key())+reversedRound)); + if (keyEpsilonVariable) + keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->pixelToCoord(keyAxis->coordToPixel(currentIntervalStartKey)+1.0*reversedFactor)); + intervalDataCount = 1; + } + ++it; + } + // handle last interval: + if (intervalDataCount >= 2) // last pixel had multiple data points, consolidate them + { + // determine value pixel span and add as many points in interval to maintain certain vertical data density (this is specific to scatter plot): + double valuePixelSpan = qAbs(valueAxis->coordToPixel(minValue)-valueAxis->coordToPixel(maxValue)); + int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0))); // approximately every 4 value pixels one data point on average + QCPDataMap::const_iterator intervalIt = currentIntervalStart; + int c = 0; + while (intervalIt != it) + { + if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt.value().value > valueMinRange && intervalIt.value().value < valueMaxRange) + scatterData->append(intervalIt.value()); + ++c; + ++intervalIt; + } + } else if (currentIntervalStart.value().value > valueMinRange && currentIntervalStart.value().value < valueMaxRange) + scatterData->append(currentIntervalStart.value()); + } + } else // don't use adaptive sampling algorithm, transfer points one-to-one from the map into the output parameters + { + QVector *dataVector = 0; + if (lineData) + dataVector = lineData; + else if (scatterData) + dataVector = scatterData; + if (dataVector) + { + QCPDataMap::const_iterator it = lower; + QCPDataMap::const_iterator upperEnd = upper+1; + dataVector->reserve(dataCount+2); // +2 for possible fill end points + while (it != upperEnd) + { + dataVector->append(it.value()); + ++it; + } + } + if (lineData && scatterData) + *scatterData = *dataVector; + } +} + +/*! \internal + + called by the scatter drawing function (\ref drawScatterPlot) to draw the error bars on one data + point. \a x and \a y pixel positions of the data point are passed since they are already known in + pixel coordinates in the drawing function, so we save some extra coordToPixel transforms here. \a + data is therefore only used for the errors, not key and value. +*/ +void QCPGraph::drawError(QCPPainter *painter, double x, double y, const QCPData &data) const +{ + if (qIsNaN(data.value)) + return; + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + double a, b; // positions of error bar bounds in pixels + double barWidthHalf = mErrorBarSize*0.5; + double skipSymbolMargin = mScatterStyle.size(); // pixels left blank per side, when mErrorBarSkipSymbol is true + + if (keyAxis->orientation() == Qt::Vertical) + { + // draw key error vertically and value error horizontally + if (mErrorType == etKey || mErrorType == etBoth) + { + a = keyAxis->coordToPixel(data.key-data.keyErrorMinus); + b = keyAxis->coordToPixel(data.key+data.keyErrorPlus); + if (keyAxis->rangeReversed()) + qSwap(a,b); + // draw spine: + if (mErrorBarSkipSymbol) + { + if (a-y > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin + painter->drawLine(QLineF(x, a, x, y+skipSymbolMargin)); + if (y-b > skipSymbolMargin) + painter->drawLine(QLineF(x, y-skipSymbolMargin, x, b)); + } else + painter->drawLine(QLineF(x, a, x, b)); + // draw handles: + painter->drawLine(QLineF(x-barWidthHalf, a, x+barWidthHalf, a)); + painter->drawLine(QLineF(x-barWidthHalf, b, x+barWidthHalf, b)); + } + if (mErrorType == etValue || mErrorType == etBoth) + { + a = valueAxis->coordToPixel(data.value-data.valueErrorMinus); + b = valueAxis->coordToPixel(data.value+data.valueErrorPlus); + if (valueAxis->rangeReversed()) + qSwap(a,b); + // draw spine: + if (mErrorBarSkipSymbol) + { + if (x-a > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin + painter->drawLine(QLineF(a, y, x-skipSymbolMargin, y)); + if (b-x > skipSymbolMargin) + painter->drawLine(QLineF(x+skipSymbolMargin, y, b, y)); + } else + painter->drawLine(QLineF(a, y, b, y)); + // draw handles: + painter->drawLine(QLineF(a, y-barWidthHalf, a, y+barWidthHalf)); + painter->drawLine(QLineF(b, y-barWidthHalf, b, y+barWidthHalf)); + } + } else // mKeyAxis->orientation() is Qt::Horizontal + { + // draw value error vertically and key error horizontally + if (mErrorType == etKey || mErrorType == etBoth) + { + a = keyAxis->coordToPixel(data.key-data.keyErrorMinus); + b = keyAxis->coordToPixel(data.key+data.keyErrorPlus); + if (keyAxis->rangeReversed()) + qSwap(a,b); + // draw spine: + if (mErrorBarSkipSymbol) + { + if (x-a > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin + painter->drawLine(QLineF(a, y, x-skipSymbolMargin, y)); + if (b-x > skipSymbolMargin) + painter->drawLine(QLineF(x+skipSymbolMargin, y, b, y)); + } else + painter->drawLine(QLineF(a, y, b, y)); + // draw handles: + painter->drawLine(QLineF(a, y-barWidthHalf, a, y+barWidthHalf)); + painter->drawLine(QLineF(b, y-barWidthHalf, b, y+barWidthHalf)); + } + if (mErrorType == etValue || mErrorType == etBoth) + { + a = valueAxis->coordToPixel(data.value-data.valueErrorMinus); + b = valueAxis->coordToPixel(data.value+data.valueErrorPlus); + if (valueAxis->rangeReversed()) + qSwap(a,b); + // draw spine: + if (mErrorBarSkipSymbol) + { + if (a-y > skipSymbolMargin) // don't draw spine if error is so small it's within skipSymbolmargin + painter->drawLine(QLineF(x, a, x, y+skipSymbolMargin)); + if (y-b > skipSymbolMargin) + painter->drawLine(QLineF(x, y-skipSymbolMargin, x, b)); + } else + painter->drawLine(QLineF(x, a, x, b)); + // draw handles: + painter->drawLine(QLineF(x-barWidthHalf, a, x+barWidthHalf, a)); + painter->drawLine(QLineF(x-barWidthHalf, b, x+barWidthHalf, b)); + } + } +} + +/*! \internal + + called by \ref getPreparedData to determine which data (key) range is visible at the current key + axis range setting, so only that needs to be processed. + + \a lower returns an iterator to the lowest data point that needs to be taken into account when + plotting. Note that in order to get a clean plot all the way to the edge of the axis rect, \a + lower may still be just outside the visible range. + + \a upper returns an iterator to the highest data point. Same as before, \a upper may also lie + just outside of the visible range. + + if the graph contains no data, both \a lower and \a upper point to constEnd. +*/ +void QCPGraph::getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper) const +{ + if (!mKeyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } + if (mData->isEmpty()) + { + lower = mData->constEnd(); + upper = mData->constEnd(); + return; + } + + // get visible data range as QMap iterators + QCPDataMap::const_iterator lbound = mData->lowerBound(mKeyAxis.data()->range().lower); + QCPDataMap::const_iterator ubound = mData->upperBound(mKeyAxis.data()->range().upper); + bool lowoutlier = lbound != mData->constBegin(); // indicates whether there exist points below axis range + bool highoutlier = ubound != mData->constEnd(); // indicates whether there exist points above axis range + + lower = (lowoutlier ? lbound-1 : lbound); // data point range that will be actually drawn + upper = (highoutlier ? ubound : ubound-1); // data point range that will be actually drawn +} + +/*! \internal + + Counts the number of data points between \a lower and \a upper (including them), up to a maximum + of \a maxCount. + + This function is used by \ref getPreparedData to determine whether adaptive sampling shall be + used (if enabled via \ref setAdaptiveSampling) or not. This is also why counting of data points + only needs to be done until \a maxCount is reached, which should be set to the number of data + points at which adaptive sampling sets in. +*/ +int QCPGraph::countDataInBounds(const QCPDataMap::const_iterator &lower, const QCPDataMap::const_iterator &upper, int maxCount) const +{ + if (upper == mData->constEnd() && lower == mData->constEnd()) + return 0; + QCPDataMap::const_iterator it = lower; + int count = 1; + while (it != upper && count < maxCount) + { + ++it; + ++count; + } + return count; +} + +/*! \internal + + The line data vector generated by e.g. getLinePlotData contains only the line that connects the + data points. If the graph needs to be filled, two additional points need to be added at the + value-zero-line in the lower and upper key positions of the graph. This function calculates these + points and adds them to the end of \a lineData. Since the fill is typically drawn before the line + stroke, these added points need to be removed again after the fill is done, with the + removeFillBasePoints function. + + The expanding of \a lineData by two points will not cause unnecessary memory reallocations, + because the data vector generation functions (getLinePlotData etc.) reserve two extra points when + they allocate memory for \a lineData. + + \see removeFillBasePoints, lowerFillBasePoint, upperFillBasePoint +*/ +void QCPGraph::addFillBasePoints(QVector *lineData) const +{ + if (!mKeyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } + + // append points that close the polygon fill at the key axis: + if (mKeyAxis.data()->orientation() == Qt::Vertical) + { + *lineData << upperFillBasePoint(lineData->last().y()); + *lineData << lowerFillBasePoint(lineData->first().y()); + } else + { + *lineData << upperFillBasePoint(lineData->last().x()); + *lineData << lowerFillBasePoint(lineData->first().x()); + } +} + +/*! \internal + + removes the two points from \a lineData that were added by \ref addFillBasePoints. + + \see addFillBasePoints, lowerFillBasePoint, upperFillBasePoint +*/ +void QCPGraph::removeFillBasePoints(QVector *lineData) const +{ + lineData->remove(lineData->size()-2, 2); +} + +/*! \internal + + called by \ref addFillBasePoints to conveniently assign the point which closes the fill polygon + on the lower side of the zero-value-line parallel to the key axis. The logarithmic axis scale + case is a bit special, since the zero-value-line in pixel coordinates is in positive or negative + infinity. So this case is handled separately by just closing the fill polygon on the axis which + lies in the direction towards the zero value. + + \a lowerKey will be the the key (in pixels) of the returned point. Depending on whether the key + axis is horizontal or vertical, \a lowerKey will end up as the x or y value of the returned + point, respectively. + + \see upperFillBasePoint, addFillBasePoints +*/ +QPointF QCPGraph::lowerFillBasePoint(double lowerKey) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(); } + + QPointF point; + if (valueAxis->scaleType() == QCPAxis::stLinear) + { + if (keyAxis->axisType() == QCPAxis::atLeft) + { + point.setX(valueAxis->coordToPixel(0)); + point.setY(lowerKey); + } else if (keyAxis->axisType() == QCPAxis::atRight) + { + point.setX(valueAxis->coordToPixel(0)); + point.setY(lowerKey); + } else if (keyAxis->axisType() == QCPAxis::atTop) + { + point.setX(lowerKey); + point.setY(valueAxis->coordToPixel(0)); + } else if (keyAxis->axisType() == QCPAxis::atBottom) + { + point.setX(lowerKey); + point.setY(valueAxis->coordToPixel(0)); + } + } else // valueAxis->mScaleType == QCPAxis::stLogarithmic + { + // In logarithmic scaling we can't just draw to value zero so we just fill all the way + // to the axis which is in the direction towards zero + if (keyAxis->orientation() == Qt::Vertical) + { + if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || + (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis + point.setX(keyAxis->axisRect()->right()); + else + point.setX(keyAxis->axisRect()->left()); + point.setY(lowerKey); + } else if (keyAxis->axisType() == QCPAxis::atTop || keyAxis->axisType() == QCPAxis::atBottom) + { + point.setX(lowerKey); + if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || + (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis + point.setY(keyAxis->axisRect()->top()); + else + point.setY(keyAxis->axisRect()->bottom()); + } + } + return point; +} + +/*! \internal + + called by \ref addFillBasePoints to conveniently assign the point which closes the fill + polygon on the upper side of the zero-value-line parallel to the key axis. The logarithmic axis + scale case is a bit special, since the zero-value-line in pixel coordinates is in positive or + negative infinity. So this case is handled separately by just closing the fill polygon on the + axis which lies in the direction towards the zero value. + + \a upperKey will be the the key (in pixels) of the returned point. Depending on whether the key + axis is horizontal or vertical, \a upperKey will end up as the x or y value of the returned + point, respectively. + + \see lowerFillBasePoint, addFillBasePoints +*/ +QPointF QCPGraph::upperFillBasePoint(double upperKey) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPointF(); } + + QPointF point; + if (valueAxis->scaleType() == QCPAxis::stLinear) + { + if (keyAxis->axisType() == QCPAxis::atLeft) + { + point.setX(valueAxis->coordToPixel(0)); + point.setY(upperKey); + } else if (keyAxis->axisType() == QCPAxis::atRight) + { + point.setX(valueAxis->coordToPixel(0)); + point.setY(upperKey); + } else if (keyAxis->axisType() == QCPAxis::atTop) + { + point.setX(upperKey); + point.setY(valueAxis->coordToPixel(0)); + } else if (keyAxis->axisType() == QCPAxis::atBottom) + { + point.setX(upperKey); + point.setY(valueAxis->coordToPixel(0)); + } + } else // valueAxis->mScaleType == QCPAxis::stLogarithmic + { + // In logarithmic scaling we can't just draw to value 0 so we just fill all the way + // to the axis which is in the direction towards 0 + if (keyAxis->orientation() == Qt::Vertical) + { + if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || + (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis + point.setX(keyAxis->axisRect()->right()); + else + point.setX(keyAxis->axisRect()->left()); + point.setY(upperKey); + } else if (keyAxis->axisType() == QCPAxis::atTop || keyAxis->axisType() == QCPAxis::atBottom) + { + point.setX(upperKey); + if ((valueAxis->range().upper < 0 && !valueAxis->rangeReversed()) || + (valueAxis->range().upper > 0 && valueAxis->rangeReversed())) // if range is negative, zero is on opposite side of key axis + point.setY(keyAxis->axisRect()->top()); + else + point.setY(keyAxis->axisRect()->bottom()); + } + } + return point; +} + +/*! \internal + + Generates the polygon needed for drawing channel fills between this graph (data passed via \a + lineData) and the graph specified by mChannelFillGraph (data generated by calling its \ref + getPlotData function). May return an empty polygon if the key ranges have no overlap or fill + target graph and this graph don't have same orientation (i.e. both key axes horizontal or both + key axes vertical). For increased performance (due to implicit sharing), keep the returned + QPolygonF const. +*/ +const QPolygonF QCPGraph::getChannelFillPolygon(const QVector *lineData) const +{ + if (!mChannelFillGraph) + return QPolygonF(); + + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPolygonF(); } + if (!mChannelFillGraph.data()->mKeyAxis) { qDebug() << Q_FUNC_INFO << "channel fill target key axis invalid"; return QPolygonF(); } + + if (mChannelFillGraph.data()->mKeyAxis.data()->orientation() != keyAxis->orientation()) + return QPolygonF(); // don't have same axis orientation, can't fill that (Note: if keyAxis fits, valueAxis will fit too, because it's always orthogonal to keyAxis) + + if (lineData->isEmpty()) return QPolygonF(); + QVector otherData; + mChannelFillGraph.data()->getPlotData(&otherData, 0); + if (otherData.isEmpty()) return QPolygonF(); + QVector thisData; + thisData.reserve(lineData->size()+otherData.size()); // because we will join both vectors at end of this function + for (int i=0; isize(); ++i) // don't use the vector<<(vector), it squeezes internally, which ruins the performance tuning with reserve() + thisData << lineData->at(i); + + // pointers to be able to swap them, depending which data range needs cropping: + QVector *staticData = &thisData; + QVector *croppedData = &otherData; + + // crop both vectors to ranges in which the keys overlap (which coord is key, depends on axisType): + if (keyAxis->orientation() == Qt::Horizontal) + { + // x is key + // if an axis range is reversed, the data point keys will be descending. Reverse them, since following algorithm assumes ascending keys: + if (staticData->first().x() > staticData->last().x()) + { + int size = staticData->size(); + for (int i=0; ifirst().x() > croppedData->last().x()) + { + int size = croppedData->size(); + for (int i=0; ifirst().x() < croppedData->first().x()) // other one must be cropped + qSwap(staticData, croppedData); + int lowBound = findIndexBelowX(croppedData, staticData->first().x()); + if (lowBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(0, lowBound); + // set lowest point of cropped data to fit exactly key position of first static data + // point via linear interpolation: + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation + double slope; + if (croppedData->at(1).x()-croppedData->at(0).x() != 0) + slope = (croppedData->at(1).y()-croppedData->at(0).y())/(croppedData->at(1).x()-croppedData->at(0).x()); + else + slope = 0; + (*croppedData)[0].setY(croppedData->at(0).y()+slope*(staticData->first().x()-croppedData->at(0).x())); + (*croppedData)[0].setX(staticData->first().x()); + + // crop upper bound: + if (staticData->last().x() > croppedData->last().x()) // other one must be cropped + qSwap(staticData, croppedData); + int highBound = findIndexAboveX(croppedData, staticData->last().x()); + if (highBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(highBound+1, croppedData->size()-(highBound+1)); + // set highest point of cropped data to fit exactly key position of last static data + // point via linear interpolation: + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation + int li = croppedData->size()-1; // last index + if (croppedData->at(li).x()-croppedData->at(li-1).x() != 0) + slope = (croppedData->at(li).y()-croppedData->at(li-1).y())/(croppedData->at(li).x()-croppedData->at(li-1).x()); + else + slope = 0; + (*croppedData)[li].setY(croppedData->at(li-1).y()+slope*(staticData->last().x()-croppedData->at(li-1).x())); + (*croppedData)[li].setX(staticData->last().x()); + } else // mKeyAxis->orientation() == Qt::Vertical + { + // y is key + // similar to "x is key" but switched x,y. Further, lower/upper meaning is inverted compared to x, + // because in pixel coordinates, y increases from top to bottom, not bottom to top like data coordinate. + // if an axis range is reversed, the data point keys will be descending. Reverse them, since following algorithm assumes ascending keys: + if (staticData->first().y() < staticData->last().y()) + { + int size = staticData->size(); + for (int i=0; ifirst().y() < croppedData->last().y()) + { + int size = croppedData->size(); + for (int i=0; ifirst().y() > croppedData->first().y()) // other one must be cropped + qSwap(staticData, croppedData); + int lowBound = findIndexAboveY(croppedData, staticData->first().y()); + if (lowBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(0, lowBound); + // set lowest point of cropped data to fit exactly key position of first static data + // point via linear interpolation: + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation + double slope; + if (croppedData->at(1).y()-croppedData->at(0).y() != 0) // avoid division by zero in step plots + slope = (croppedData->at(1).x()-croppedData->at(0).x())/(croppedData->at(1).y()-croppedData->at(0).y()); + else + slope = 0; + (*croppedData)[0].setX(croppedData->at(0).x()+slope*(staticData->first().y()-croppedData->at(0).y())); + (*croppedData)[0].setY(staticData->first().y()); + + // crop upper bound: + if (staticData->last().y() < croppedData->last().y()) // other one must be cropped + qSwap(staticData, croppedData); + int highBound = findIndexBelowY(croppedData, staticData->last().y()); + if (highBound == -1) return QPolygonF(); // key ranges have no overlap + croppedData->remove(highBound+1, croppedData->size()-(highBound+1)); + // set highest point of cropped data to fit exactly key position of last static data + // point via linear interpolation: + if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation + int li = croppedData->size()-1; // last index + if (croppedData->at(li).y()-croppedData->at(li-1).y() != 0) // avoid division by zero in step plots + slope = (croppedData->at(li).x()-croppedData->at(li-1).x())/(croppedData->at(li).y()-croppedData->at(li-1).y()); + else + slope = 0; + (*croppedData)[li].setX(croppedData->at(li-1).x()+slope*(staticData->last().y()-croppedData->at(li-1).y())); + (*croppedData)[li].setY(staticData->last().y()); + } + + // return joined: + for (int i=otherData.size()-1; i>=0; --i) // insert reversed, otherwise the polygon will be twisted + thisData << otherData.at(i); + return QPolygonF(thisData); +} + +/*! \internal + + Finds the smallest index of \a data, whose points x value is just above \a x. Assumes x values in + \a data points are ordered ascending, as is the case when plotting with horizontal key axis. + + Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. +*/ +int QCPGraph::findIndexAboveX(const QVector *data, double x) const +{ + for (int i=data->size()-1; i>=0; --i) + { + if (data->at(i).x() < x) + { + if (isize()-1) + return i+1; + else + return data->size()-1; + } + } + return -1; +} + +/*! \internal + + Finds the highest index of \a data, whose points x value is just below \a x. Assumes x values in + \a data points are ordered ascending, as is the case when plotting with horizontal key axis. + + Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. +*/ +int QCPGraph::findIndexBelowX(const QVector *data, double x) const +{ + for (int i=0; isize(); ++i) + { + if (data->at(i).x() > x) + { + if (i>0) + return i-1; + else + return 0; + } + } + return -1; +} + +/*! \internal + + Finds the smallest index of \a data, whose points y value is just above \a y. Assumes y values in + \a data points are ordered descending, as is the case when plotting with vertical key axis. + + Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. +*/ +int QCPGraph::findIndexAboveY(const QVector *data, double y) const +{ + for (int i=0; isize(); ++i) + { + if (data->at(i).y() < y) + { + if (i>0) + return i-1; + else + return 0; + } + } + return -1; +} + +/*! \internal + + Calculates the (minimum) distance (in pixels) the graph's representation has from the given \a + pixelPoint in pixels. This is used to determine whether the graph was clicked or not, e.g. in + \ref selectTest. + + If either the graph has no data or if the line style is \ref lsNone and the scatter style's shape + is \ref QCPScatterStyle::ssNone (i.e. there is no visual representation of the graph), returns + 500. +*/ +double QCPGraph::pointDistance(const QPointF &pixelPoint) const +{ + if (mData->isEmpty()) + { + qDebug() << Q_FUNC_INFO << "requested point distance on graph" << mName << "without data"; + return 500; + } + if (mData->size() == 1) + { + QPointF dataPoint = coordsToPixels(mData->constBegin().key(), mData->constBegin().value().value); + return QVector2D(dataPoint-pixelPoint).length(); + } + + if (mLineStyle == lsNone && mScatterStyle.isNone()) + return 500; + + // calculate minimum distances to graph representation: + if (mLineStyle == lsNone) + { + // no line displayed, only calculate distance to scatter points: + QVector *scatterData = new QVector; + getScatterPlotData(scatterData); + double minDistSqr = std::numeric_limits::max(); + QPointF ptA; + QPointF ptB = coordsToPixels(scatterData->at(0).key, scatterData->at(0).value); // getScatterPlotData returns in plot coordinates, so transform to pixels + for (int i=1; isize(); ++i) + { + ptA = ptB; + ptB = coordsToPixels(scatterData->at(i).key, scatterData->at(i).value); + double currentDistSqr = distSqrToLine(ptA, ptB, pixelPoint); + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + delete scatterData; + return qSqrt(minDistSqr); + } else + { + // line displayed calculate distance to line segments: + QVector *lineData = new QVector; + getPlotData(lineData, 0); // unlike with getScatterPlotData we get pixel coordinates here + double minDistSqr = std::numeric_limits::max(); + if (mLineStyle == lsImpulse) + { + // impulse plot differs from other line styles in that the lineData points are only pairwise connected: + for (int i=0; isize()-1; i+=2) // iterate pairs + { + double currentDistSqr = distSqrToLine(lineData->at(i), lineData->at(i+1), pixelPoint); + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + } else + { + // all other line plots (line and step) connect points directly: + for (int i=0; isize()-1; ++i) + { + double currentDistSqr = distSqrToLine(lineData->at(i), lineData->at(i+1), pixelPoint); + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + } + delete lineData; + return qSqrt(minDistSqr); + } +} + +/*! \internal + + Finds the highest index of \a data, whose points y value is just below \a y. Assumes y values in + \a data points are ordered descending, as is the case when plotting with vertical key axis (since + keys are ordered ascending). + + Used to calculate the channel fill polygon, see \ref getChannelFillPolygon. +*/ +int QCPGraph::findIndexBelowY(const QVector *data, double y) const +{ + for (int i=data->size()-1; i>=0; --i) + { + if (data->at(i).y() > y) + { + if (isize()-1) + return i+1; + else + return data->size()-1; + } + } + return -1; +} + +/* inherits documentation from base class */ +QCPRange QCPGraph::getKeyRange(bool &foundRange, SignDomain inSignDomain) const +{ + // just call the specialized version which takes an additional argument whether error bars + // should also be taken into consideration for range calculation. We set this to true here. + return getKeyRange(foundRange, inSignDomain, true); +} + +/* inherits documentation from base class */ +QCPRange QCPGraph::getValueRange(bool &foundRange, SignDomain inSignDomain) const +{ + // just call the specialized version which takes an additional argument whether error bars + // should also be taken into consideration for range calculation. We set this to true here. + return getValueRange(foundRange, inSignDomain, true); +} + +/*! \overload + + Allows to specify whether the error bars should be included in the range calculation. + + \see getKeyRange(bool &foundRange, SignDomain inSignDomain) +*/ +QCPRange QCPGraph::getKeyRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const +{ + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + double current, currentErrorMinus, currentErrorPlus; + + if (inSignDomain == sdBoth) // range may be anywhere + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().key; + currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0); + if (current-currentErrorMinus < range.lower || !haveLower) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if (current+currentErrorPlus > range.upper || !haveUpper) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + ++it; + } + } else if (inSignDomain == sdNegative) // range may only be in the negative sign domain + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().key; + currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0); + if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus < 0) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus < 0) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to geht that point. + { + if ((current < range.lower || !haveLower) && current < 0) + { + range.lower = current; + haveLower = true; + } + if ((current > range.upper || !haveUpper) && current < 0) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + } else if (inSignDomain == sdPositive) // range may only be in the positive sign domain + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().key; + currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0); + if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus > 0) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus > 0) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to get that point. + { + if ((current < range.lower || !haveLower) && current > 0) + { + range.lower = current; + haveLower = true; + } + if ((current > range.upper || !haveUpper) && current > 0) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + } + + foundRange = haveLower && haveUpper; + return range; +} + +/*! \overload + + Allows to specify whether the error bars should be included in the range calculation. + + \see getValueRange(bool &foundRange, SignDomain inSignDomain) +*/ +QCPRange QCPGraph::getValueRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const +{ + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + double current, currentErrorMinus, currentErrorPlus; + + if (inSignDomain == sdBoth) // range may be anywhere + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().value; + currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0); + if (current-currentErrorMinus < range.lower || !haveLower) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if (current+currentErrorPlus > range.upper || !haveUpper) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + ++it; + } + } else if (inSignDomain == sdNegative) // range may only be in the negative sign domain + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().value; + currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0); + if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus < 0) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus < 0) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to get that point. + { + if ((current < range.lower || !haveLower) && current < 0) + { + range.lower = current; + haveLower = true; + } + if ((current > range.upper || !haveUpper) && current < 0) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + } else if (inSignDomain == sdPositive) // range may only be in the positive sign domain + { + QCPDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().value; + currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0); + currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0); + if ((current-currentErrorMinus < range.lower || !haveLower) && current-currentErrorMinus > 0) + { + range.lower = current-currentErrorMinus; + haveLower = true; + } + if ((current+currentErrorPlus > range.upper || !haveUpper) && current+currentErrorPlus > 0) + { + range.upper = current+currentErrorPlus; + haveUpper = true; + } + if (includeErrors) // in case point is in valid sign domain but errobars stretch beyond it, we still want to geht that point. + { + if ((current < range.lower || !haveLower) && current > 0) + { + range.lower = current; + haveLower = true; + } + if ((current > range.upper || !haveUpper) && current > 0) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + } + + foundRange = haveLower && haveUpper; + return range; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPCurveData +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPCurveData + \brief Holds the data of one single data point for QCPCurve. + + The container for storing multiple data points is \ref QCPCurveDataMap. + + The stored data is: + \li \a t: the free parameter of the curve at this curve point (cp. the mathematical vector (x(t), y(t))) + \li \a key: coordinate on the key axis of this curve point + \li \a value: coordinate on the value axis of this curve point + + \see QCPCurveDataMap +*/ + +/*! + Constructs a curve data point with t, key and value set to zero. +*/ +QCPCurveData::QCPCurveData() : + t(0), + key(0), + value(0) +{ +} + +/*! + Constructs a curve data point with the specified \a t, \a key and \a value. +*/ +QCPCurveData::QCPCurveData(double t, double key, double value) : + t(t), + key(key), + value(value) +{ +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPCurve +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPCurve + \brief A plottable representing a parametric curve in a plot. + + \image html QCPCurve.png + + Unlike QCPGraph, plottables of this type may have multiple points with the same key coordinate, + so their visual representation can have \a loops. This is realized by introducing a third + coordinate \a t, which defines the order of the points described by the other two coordinates \a + x and \a y. + + To plot data, assign it with the \ref setData or \ref addData functions. + + \section appearance Changing the appearance + + The appearance of the curve is determined by the pen and the brush (\ref setPen, \ref setBrush). + \section usage Usage + + Like all data representing objects in QCustomPlot, the QCPCurve is a plottable (QCPAbstractPlottable). So + the plottable-interface of QCustomPlot applies (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.) + + Usually, you first create an instance: + \code + QCPCurve *newCurve = new QCPCurve(customPlot->xAxis, customPlot->yAxis);\endcode + add it to the customPlot with QCustomPlot::addPlottable: + \code + customPlot->addPlottable(newCurve);\endcode + and then modify the properties of the newly created plottable, e.g.: + \code + newCurve->setName("Fermat's Spiral"); + newCurve->setData(tData, xData, yData);\endcode +*/ + +/*! + Constructs a curve which uses \a keyAxis as its key axis ("x") and \a valueAxis as its value + axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and not have + the same orientation. If either of these restrictions is violated, a corresponding message is + printed to the debug output (qDebug), the construction is not aborted, though. + + The constructed QCPCurve can be added to the plot with QCustomPlot::addPlottable, QCustomPlot + then takes ownership of the graph. +*/ +QCPCurve::QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis) +{ + mData = new QCPCurveDataMap; + mPen.setColor(Qt::blue); + mPen.setStyle(Qt::SolidLine); + mBrush.setColor(Qt::blue); + mBrush.setStyle(Qt::NoBrush); + mSelectedPen = mPen; + mSelectedPen.setWidthF(2.5); + mSelectedPen.setColor(QColor(80, 80, 255)); // lighter than Qt::blue of mPen + mSelectedBrush = mBrush; + + setScatterStyle(QCPScatterStyle()); + setLineStyle(lsLine); +} + +QCPCurve::~QCPCurve() +{ + delete mData; +} + +/*! + Replaces the current data with the provided \a data. + + If \a copy is set to true, data points in \a data will only be copied. if false, the plottable + takes ownership of the passed data and replaces the internal data pointer with it. This is + significantly faster than copying for large datasets. +*/ +void QCPCurve::setData(QCPCurveDataMap *data, bool copy) +{ + if (copy) + { + *mData = *data; + } else + { + delete mData; + mData = data; + } +} + +/*! \overload + + Replaces the current data with the provided points in \a t, \a key and \a value tuples. The + provided vectors should have equal length. Else, the number of added points will be the size of + the smallest vector. +*/ +void QCPCurve::setData(const QVector &t, const QVector &key, const QVector &value) +{ + mData->clear(); + int n = t.size(); + n = qMin(n, key.size()); + n = qMin(n, value.size()); + QCPCurveData newData; + for (int i=0; iinsertMulti(newData.t, newData); + } +} + +/*! \overload + + Replaces the current data with the provided \a key and \a value pairs. The t parameter + of each data point will be set to the integer index of the respective key/value pair. +*/ +void QCPCurve::setData(const QVector &key, const QVector &value) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + QCPCurveData newData; + for (int i=0; iinsertMulti(newData.t, newData); + } +} + +/*! + Sets the visual appearance of single data points in the plot. If set to \ref + QCPScatterStyle::ssNone, no scatter points are drawn (e.g. for line-only plots with appropriate + line style). + + \see QCPScatterStyle, setLineStyle +*/ +void QCPCurve::setScatterStyle(const QCPScatterStyle &style) +{ + mScatterStyle = style; +} + +/*! + Sets how the single data points are connected in the plot or how they are represented visually + apart from the scatter symbol. For scatter-only plots, set \a style to \ref lsNone and \ref + setScatterStyle to the desired scatter style. + + \see setScatterStyle +*/ +void QCPCurve::setLineStyle(QCPCurve::LineStyle style) +{ + mLineStyle = style; +} + +/*! + Adds the provided data points in \a dataMap to the current data. + \see removeData +*/ +void QCPCurve::addData(const QCPCurveDataMap &dataMap) +{ + mData->unite(dataMap); +} + +/*! \overload + Adds the provided single data point in \a data to the current data. + \see removeData +*/ +void QCPCurve::addData(const QCPCurveData &data) +{ + mData->insertMulti(data.t, data); +} + +/*! \overload + Adds the provided single data point as \a t, \a key and \a value tuple to the current data + \see removeData +*/ +void QCPCurve::addData(double t, double key, double value) +{ + QCPCurveData newData; + newData.t = t; + newData.key = key; + newData.value = value; + mData->insertMulti(newData.t, newData); +} + +/*! \overload + + Adds the provided single data point as \a key and \a value pair to the current data The t + parameter of the data point is set to the t of the last data point plus 1. If there is no last + data point, t will be set to 0. + + \see removeData +*/ +void QCPCurve::addData(double key, double value) +{ + QCPCurveData newData; + if (!mData->isEmpty()) + newData.t = (mData->constEnd()-1).key()+1; + else + newData.t = 0; + newData.key = key; + newData.value = value; + mData->insertMulti(newData.t, newData); +} + +/*! \overload + Adds the provided data points as \a t, \a key and \a value tuples to the current data. + \see removeData +*/ +void QCPCurve::addData(const QVector &ts, const QVector &keys, const QVector &values) +{ + int n = ts.size(); + n = qMin(n, keys.size()); + n = qMin(n, values.size()); + QCPCurveData newData; + for (int i=0; iinsertMulti(newData.t, newData); + } +} + +/*! + Removes all data points with curve parameter t smaller than \a t. + \see addData, clearData +*/ +void QCPCurve::removeDataBefore(double t) +{ + QCPCurveDataMap::iterator it = mData->begin(); + while (it != mData->end() && it.key() < t) + it = mData->erase(it); +} + +/*! + Removes all data points with curve parameter t greater than \a t. + \see addData, clearData +*/ +void QCPCurve::removeDataAfter(double t) +{ + if (mData->isEmpty()) return; + QCPCurveDataMap::iterator it = mData->upperBound(t); + while (it != mData->end()) + it = mData->erase(it); +} + +/*! + Removes all data points with curve parameter t between \a fromt and \a tot. if \a fromt is + greater or equal to \a tot, the function does nothing. To remove a single data point with known + t, use \ref removeData(double t). + + \see addData, clearData +*/ +void QCPCurve::removeData(double fromt, double tot) +{ + if (fromt >= tot || mData->isEmpty()) return; + QCPCurveDataMap::iterator it = mData->upperBound(fromt); + QCPCurveDataMap::iterator itEnd = mData->upperBound(tot); + while (it != itEnd) + it = mData->erase(it); +} + +/*! \overload + + Removes a single data point at curve parameter \a t. If the position is not known with absolute + precision, consider using \ref removeData(double fromt, double tot) with a small fuzziness + interval around the suspected position, depeding on the precision with which the curve parameter + is known. + + \see addData, clearData +*/ +void QCPCurve::removeData(double t) +{ + mData->remove(t); +} + +/*! + Removes all data points. + \see removeData, removeDataAfter, removeDataBefore +*/ +void QCPCurve::clearData() +{ + mData->clear(); +} + +/* inherits documentation from base class */ +double QCPCurve::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if ((onlySelectable && !mSelectable) || mData->isEmpty()) + return -1; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) + return pointDistance(pos); + else + return -1; +} + +/* inherits documentation from base class */ +void QCPCurve::draw(QCPPainter *painter) +{ + if (mData->isEmpty()) return; + + // allocate line vector: + QVector *lineData = new QVector; + + // fill with curve data: + getCurveData(lineData); + + // check data validity if flag set: +#ifdef QCUSTOMPLOT_CHECK_DATA + QCPCurveDataMap::const_iterator it; + for (it = mData->constBegin(); it != mData->constEnd(); ++it) + { + if (QCP::isInvalidData(it.value().t) || + QCP::isInvalidData(it.value().key, it.value().value)) + qDebug() << Q_FUNC_INFO << "Data point at" << it.key() << "invalid." << "Plottable name:" << name(); + } +#endif + + // draw curve fill: + if (mainBrush().style() != Qt::NoBrush && mainBrush().color().alpha() != 0) + { + applyFillAntialiasingHint(painter); + painter->setPen(Qt::NoPen); + painter->setBrush(mainBrush()); + painter->drawPolygon(QPolygonF(*lineData)); + } + + // draw curve line: + if (mLineStyle != lsNone && mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) + { + applyDefaultAntialiasingHint(painter); + painter->setPen(mainPen()); + painter->setBrush(Qt::NoBrush); + // if drawing solid line and not in PDF, use much faster line drawing instead of polyline: + if (mParentPlot->plottingHints().testFlag(QCP::phFastPolylines) && + painter->pen().style() == Qt::SolidLine && + !painter->modes().testFlag(QCPPainter::pmVectorized) && + !painter->modes().testFlag(QCPPainter::pmNoCaching)) + { + int i = 1; + int lineDataSize = lineData->size(); + while (i < lineDataSize) + { + if (!qIsNaN(lineData->at(i).y()) && !qIsNaN(lineData->at(i).x())) // NaNs create a gap in the line + painter->drawLine(lineData->at(i-1), lineData->at(i)); + else + ++i; + ++i; + } + } else + { + int segmentStart = 0; + int i = 0; + int lineDataSize = lineData->size(); + while (i < lineDataSize) + { + if (qIsNaN(lineData->at(i).y()) || qIsNaN(lineData->at(i).x())) // NaNs create a gap in the line + { + painter->drawPolyline(lineData->constData()+segmentStart, i-segmentStart); // i, because we don't want to include the current NaN point + segmentStart = i+1; + } + ++i; + } + // draw last segment: + painter->drawPolyline(lineData->constData()+segmentStart, lineDataSize-segmentStart); // lineDataSize, because we do want to include the last point + } + } + + // draw scatters: + if (!mScatterStyle.isNone()) + drawScatterPlot(painter, lineData); + + // free allocated line data: + delete lineData; +} + +/* inherits documentation from base class */ +void QCPCurve::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +{ + // draw fill: + if (mBrush.style() != Qt::NoBrush) + { + applyFillAntialiasingHint(painter); + painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0), mBrush); + } + // draw line vertically centered: + if (mLineStyle != lsNone) + { + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + painter->drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0)); // +5 on x2 else last segment is missing from dashed/dotted pens + } + // draw scatter symbol: + if (!mScatterStyle.isNone()) + { + applyScattersAntialiasingHint(painter); + // scale scatter pixmap if it's too large to fit in legend icon rect: + if (mScatterStyle.shape() == QCPScatterStyle::ssPixmap && (mScatterStyle.pixmap().size().width() > rect.width() || mScatterStyle.pixmap().size().height() > rect.height())) + { + QCPScatterStyle scaledStyle(mScatterStyle); + scaledStyle.setPixmap(scaledStyle.pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); + scaledStyle.applyTo(painter, mPen); + scaledStyle.drawShape(painter, QRectF(rect).center()); + } else + { + mScatterStyle.applyTo(painter, mPen); + mScatterStyle.drawShape(painter, QRectF(rect).center()); + } + } +} + +/*! \internal + + Draws scatter symbols at every data point passed in \a pointData. scatter symbols are independent of + the line style and are always drawn if scatter shape is not \ref QCPScatterStyle::ssNone. +*/ +void QCPCurve::drawScatterPlot(QCPPainter *painter, const QVector *pointData) const +{ + // draw scatter point symbols: + applyScattersAntialiasingHint(painter); + mScatterStyle.applyTo(painter, mPen); + for (int i=0; isize(); ++i) + if (!qIsNaN(pointData->at(i).x()) && !qIsNaN(pointData->at(i).y())) + mScatterStyle.drawShape(painter, pointData->at(i)); +} + +/*! \internal + + called by QCPCurve::draw to generate a point vector (in pixel coordinates) which represents the + line of the curve. + + Line segments that aren't visible in the current axis rect are handled in an optimized way. They + are projected onto a rectangle slightly larger than the visible axis rect and simplified + regarding point count. The algorithm makes sure to preserve appearance of lines and fills inside + the visible axis rect by generating new temporary points on the outer rect if necessary. + + Methods that are also involved in the algorithm are: \ref getRegion, \ref getOptimizedPoint, \ref + getOptimizedCornerPoints \ref mayTraverse, \ref getTraverse, \ref getTraverseCornerPoints. +*/ +void QCPCurve::getCurveData(QVector *lineData) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + // add margins to rect to compensate for stroke width + double strokeMargin = qMax(qreal(1.0), qreal(mainPen().widthF()*0.75)); // stroke radius + 50% safety + if (!mScatterStyle.isNone()) + strokeMargin = qMax(strokeMargin, mScatterStyle.size()); + double rectLeft = keyAxis->pixelToCoord(keyAxis->coordToPixel(keyAxis->range().lower)-strokeMargin*((keyAxis->orientation()==Qt::Vertical)!=keyAxis->rangeReversed()?-1:1)); + double rectRight = keyAxis->pixelToCoord(keyAxis->coordToPixel(keyAxis->range().upper)+strokeMargin*((keyAxis->orientation()==Qt::Vertical)!=keyAxis->rangeReversed()?-1:1)); + double rectBottom = valueAxis->pixelToCoord(valueAxis->coordToPixel(valueAxis->range().lower)+strokeMargin*((valueAxis->orientation()==Qt::Horizontal)!=valueAxis->rangeReversed()?-1:1)); + double rectTop = valueAxis->pixelToCoord(valueAxis->coordToPixel(valueAxis->range().upper)-strokeMargin*((valueAxis->orientation()==Qt::Horizontal)!=valueAxis->rangeReversed()?-1:1)); + int currentRegion; + QCPCurveDataMap::const_iterator it = mData->constBegin(); + QCPCurveDataMap::const_iterator prevIt = mData->constEnd()-1; + int prevRegion = getRegion(prevIt.value().key, prevIt.value().value, rectLeft, rectTop, rectRight, rectBottom); + QVector trailingPoints; // points that must be applied after all other points (are generated only when handling first point to get virtual segment between last and first point right) + while (it != mData->constEnd()) + { + currentRegion = getRegion(it.value().key, it.value().value, rectLeft, rectTop, rectRight, rectBottom); + if (currentRegion != prevRegion) // changed region, possibly need to add some optimized edge points or original points if entering R + { + if (currentRegion != 5) // segment doesn't end in R, so it's a candidate for removal + { + QPointF crossA, crossB; + if (prevRegion == 5) // we're coming from R, so add this point optimized + { + lineData->append(getOptimizedPoint(currentRegion, it.value().key, it.value().value, prevIt.value().key, prevIt.value().value, rectLeft, rectTop, rectRight, rectBottom)); + // in the situations 5->1/7/9/3 the segment may leave R and directly cross through two outer regions. In these cases we need to add an additional corner point + *lineData << getOptimizedCornerPoints(prevRegion, currentRegion, prevIt.value().key, prevIt.value().value, it.value().key, it.value().value, rectLeft, rectTop, rectRight, rectBottom); + } else if (mayTraverse(prevRegion, currentRegion) && + getTraverse(prevIt.value().key, prevIt.value().value, it.value().key, it.value().value, rectLeft, rectTop, rectRight, rectBottom, crossA, crossB)) + { + // add the two cross points optimized if segment crosses R and if segment isn't virtual zeroth segment between last and first curve point: + QVector beforeTraverseCornerPoints, afterTraverseCornerPoints; + getTraverseCornerPoints(prevRegion, currentRegion, rectLeft, rectTop, rectRight, rectBottom, beforeTraverseCornerPoints, afterTraverseCornerPoints); + if (it != mData->constBegin()) + { + *lineData << beforeTraverseCornerPoints; + lineData->append(crossA); + lineData->append(crossB); + *lineData << afterTraverseCornerPoints; + } else + { + lineData->append(crossB); + *lineData << afterTraverseCornerPoints; + trailingPoints << beforeTraverseCornerPoints << crossA ; + } + } else // doesn't cross R, line is just moving around in outside regions, so only need to add optimized point(s) at the boundary corner(s) + { + *lineData << getOptimizedCornerPoints(prevRegion, currentRegion, prevIt.value().key, prevIt.value().value, it.value().key, it.value().value, rectLeft, rectTop, rectRight, rectBottom); + } + } else // segment does end in R, so we add previous point optimized and this point at original position + { + if (it == mData->constBegin()) // it is first point in curve and prevIt is last one. So save optimized point for adding it to the lineData in the end + trailingPoints << getOptimizedPoint(prevRegion, prevIt.value().key, prevIt.value().value, it.value().key, it.value().value, rectLeft, rectTop, rectRight, rectBottom); + else + lineData->append(getOptimizedPoint(prevRegion, prevIt.value().key, prevIt.value().value, it.value().key, it.value().value, rectLeft, rectTop, rectRight, rectBottom)); + lineData->append(coordsToPixels(it.value().key, it.value().value)); + } + } else // region didn't change + { + if (currentRegion == 5) // still in R, keep adding original points + { + lineData->append(coordsToPixels(it.value().key, it.value().value)); + } else // still outside R, no need to add anything + { + // see how this is not doing anything? That's the main optimization... + } + } + prevIt = it; + prevRegion = currentRegion; + ++it; + } + *lineData << trailingPoints; +} + +/*! \internal + + This function is part of the curve optimization algorithm of \ref getCurveData. + + It returns the region of the given point (\a x, \a y) with respect to a rectangle defined by \a + rectLeft, \a rectTop, \a rectRight, and \a rectBottom. + + The regions are enumerated from top to bottom and left to right: + + + + + +
147
258
369
+ + With the rectangle being region 5, and the outer regions extending infinitely outwards. In the + curve optimization algorithm, region 5 is considered to be the visible portion of the plot. +*/ +int QCPCurve::getRegion(double x, double y, double rectLeft, double rectTop, double rectRight, double rectBottom) const +{ + if (x < rectLeft) // region 123 + { + if (y > rectTop) + return 1; + else if (y < rectBottom) + return 3; + else + return 2; + } else if (x > rectRight) // region 789 + { + if (y > rectTop) + return 7; + else if (y < rectBottom) + return 9; + else + return 8; + } else // region 456 + { + if (y > rectTop) + return 4; + else if (y < rectBottom) + return 6; + else + return 5; + } +} + +/*! \internal + + This function is part of the curve optimization algorithm of \ref getCurveData. + + This method is used in case the current segment passes from inside the visible rect (region 5, + see \ref getRegion) to any of the outer regions (\a otherRegion). The current segment is given by + the line connecting (\a key, \a value) with (\a otherKey, \a otherValue). + + It returns the intersection point of the segment with the border of region 5. + + For this function it doesn't matter whether (\a key, \a value) is the point inside region 5 or + whether it's (\a otherKey, \a otherValue), i.e. whether the segment is coming from region 5 or + leaving it. It is important though that \a otherRegion correctly identifies the other region not + equal to 5. +*/ +QPointF QCPCurve::getOptimizedPoint(int otherRegion, double otherKey, double otherValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom) const +{ + double intersectKey = rectLeft; // initial value is just fail-safe + double intersectValue = rectTop; // initial value is just fail-safe + switch (otherRegion) + { + case 1: // top and left edge + { + intersectValue = rectTop; + intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue); + if (intersectKey < rectLeft || intersectKey > rectRight) // doesn't intersect, so must intersect other: + { + intersectKey = rectLeft; + intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey); + } + break; + } + case 2: // left edge + { + intersectKey = rectLeft; + intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey); + break; + } + case 3: // bottom and left edge + { + intersectValue = rectBottom; + intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue); + if (intersectKey < rectLeft || intersectKey > rectRight) // doesn't intersect, so must intersect other: + { + intersectKey = rectLeft; + intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey); + } + break; + } + case 4: // top edge + { + intersectValue = rectTop; + intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue); + break; + } + case 5: + { + break; // case 5 shouldn't happen for this function but we add it anyway to prevent potential discontinuity in branch table + } + case 6: // bottom edge + { + intersectValue = rectBottom; + intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue); + break; + } + case 7: // top and right edge + { + intersectValue = rectTop; + intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue); + if (intersectKey < rectLeft || intersectKey > rectRight) // doesn't intersect, so must intersect other: + { + intersectKey = rectRight; + intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey); + } + break; + } + case 8: // right edge + { + intersectKey = rectRight; + intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey); + break; + } + case 9: // bottom and right edge + { + intersectValue = rectBottom; + intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue); + if (intersectKey < rectLeft || intersectKey > rectRight) // doesn't intersect, so must intersect other: + { + intersectKey = rectRight; + intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey); + } + break; + } + } + return coordsToPixels(intersectKey, intersectValue); +} + +/*! \internal + + This function is part of the curve optimization algorithm of \ref getCurveData. + + In situations where a single segment skips over multiple regions it might become necessary to add + extra points at the corners of region 5 (see \ref getRegion) such that the optimized segment + doesn't unintentionally cut through the visible area of the axis rect and create plot artifacts. + This method provides these points that must be added, assuming the original segment doesn't + start, end, or traverse region 5. (Corner points where region 5 is traversed are calculated by + \ref getTraverseCornerPoints.) + + For example, consider a segment which directly goes from region 4 to 2 but originally is far out + to the top left such that it doesn't cross region 5. Naively optimizing these points by + projecting them on the top and left borders of region 5 will create a segment that surely crosses + 5, creating a visual artifact in the plot. This method prevents this by providing extra points at + the top left corner, making the optimized curve correctly pass from region 4 to 1 to 2 without + traversing 5. +*/ +QVector QCPCurve::getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom) const +{ + QVector result; + switch (prevRegion) + { + case 1: + { + switch (currentRegion) + { + case 2: { result << coordsToPixels(rectLeft, rectTop); break; } + case 4: { result << coordsToPixels(rectLeft, rectTop); break; } + case 3: { result << coordsToPixels(rectLeft, rectTop) << coordsToPixels(rectLeft, rectBottom); break; } + case 7: { result << coordsToPixels(rectLeft, rectTop) << coordsToPixels(rectRight, rectTop); break; } + case 6: { result << coordsToPixels(rectLeft, rectTop) << coordsToPixels(rectLeft, rectBottom); result.append(result.last()); break; } + case 8: { result << coordsToPixels(rectLeft, rectTop) << coordsToPixels(rectRight, rectTop); result.append(result.last()); break; } + case 9: { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points + if ((value-prevValue)/(key-prevKey)*(rectLeft-key)+value < rectBottom) // segment passes below R + { result << coordsToPixels(rectLeft, rectTop) << coordsToPixels(rectLeft, rectBottom); result.append(result.last()); result << coordsToPixels(rectRight, rectBottom); } + else + { result << coordsToPixels(rectLeft, rectTop) << coordsToPixels(rectRight, rectTop); result.append(result.last()); result << coordsToPixels(rectRight, rectBottom); } + break; + } + } + break; + } + case 2: + { + switch (currentRegion) + { + case 1: { result << coordsToPixels(rectLeft, rectTop); break; } + case 3: { result << coordsToPixels(rectLeft, rectBottom); break; } + case 4: { result << coordsToPixels(rectLeft, rectTop); result.append(result.last()); break; } + case 6: { result << coordsToPixels(rectLeft, rectBottom); result.append(result.last()); break; } + case 7: { result << coordsToPixels(rectLeft, rectTop); result.append(result.last()); result << coordsToPixels(rectRight, rectTop); break; } + case 9: { result << coordsToPixels(rectLeft, rectBottom); result.append(result.last()); result << coordsToPixels(rectRight, rectBottom); break; } + } + break; + } + case 3: + { + switch (currentRegion) + { + case 2: { result << coordsToPixels(rectLeft, rectBottom); break; } + case 6: { result << coordsToPixels(rectLeft, rectBottom); break; } + case 1: { result << coordsToPixels(rectLeft, rectBottom) << coordsToPixels(rectLeft, rectTop); break; } + case 9: { result << coordsToPixels(rectLeft, rectBottom) << coordsToPixels(rectRight, rectBottom); break; } + case 4: { result << coordsToPixels(rectLeft, rectBottom) << coordsToPixels(rectLeft, rectTop); result.append(result.last()); break; } + case 8: { result << coordsToPixels(rectLeft, rectBottom) << coordsToPixels(rectRight, rectBottom); result.append(result.last()); break; } + case 7: { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points + if ((value-prevValue)/(key-prevKey)*(rectRight-key)+value < rectBottom) // segment passes below R + { result << coordsToPixels(rectLeft, rectBottom) << coordsToPixels(rectRight, rectBottom); result.append(result.last()); result << coordsToPixels(rectRight, rectTop); } + else + { result << coordsToPixels(rectLeft, rectBottom) << coordsToPixels(rectLeft, rectTop); result.append(result.last()); result << coordsToPixels(rectRight, rectTop); } + break; + } + } + break; + } + case 4: + { + switch (currentRegion) + { + case 1: { result << coordsToPixels(rectLeft, rectTop); break; } + case 7: { result << coordsToPixels(rectRight, rectTop); break; } + case 2: { result << coordsToPixels(rectLeft, rectTop); result.append(result.last()); break; } + case 8: { result << coordsToPixels(rectRight, rectTop); result.append(result.last()); break; } + case 3: { result << coordsToPixels(rectLeft, rectTop); result.append(result.last()); result << coordsToPixels(rectLeft, rectBottom); break; } + case 9: { result << coordsToPixels(rectRight, rectTop); result.append(result.last()); result << coordsToPixels(rectRight, rectBottom); break; } + } + break; + } + case 5: + { + switch (currentRegion) + { + case 1: { result << coordsToPixels(rectLeft, rectTop); break; } + case 7: { result << coordsToPixels(rectRight, rectTop); break; } + case 9: { result << coordsToPixels(rectRight, rectBottom); break; } + case 3: { result << coordsToPixels(rectLeft, rectBottom); break; } + } + break; + } + case 6: + { + switch (currentRegion) + { + case 3: { result << coordsToPixels(rectLeft, rectBottom); break; } + case 9: { result << coordsToPixels(rectRight, rectBottom); break; } + case 2: { result << coordsToPixels(rectLeft, rectBottom); result.append(result.last()); break; } + case 8: { result << coordsToPixels(rectRight, rectBottom); result.append(result.last()); break; } + case 1: { result << coordsToPixels(rectLeft, rectBottom); result.append(result.last()); result << coordsToPixels(rectLeft, rectTop); break; } + case 7: { result << coordsToPixels(rectRight, rectBottom); result.append(result.last()); result << coordsToPixels(rectRight, rectTop); break; } + } + break; + } + case 7: + { + switch (currentRegion) + { + case 4: { result << coordsToPixels(rectRight, rectTop); break; } + case 8: { result << coordsToPixels(rectRight, rectTop); break; } + case 1: { result << coordsToPixels(rectRight, rectTop) << coordsToPixels(rectLeft, rectTop); break; } + case 9: { result << coordsToPixels(rectRight, rectTop) << coordsToPixels(rectRight, rectBottom); break; } + case 2: { result << coordsToPixels(rectRight, rectTop) << coordsToPixels(rectLeft, rectTop); result.append(result.last()); break; } + case 6: { result << coordsToPixels(rectRight, rectTop) << coordsToPixels(rectRight, rectBottom); result.append(result.last()); break; } + case 3: { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points + if ((value-prevValue)/(key-prevKey)*(rectRight-key)+value < rectBottom) // segment passes below R + { result << coordsToPixels(rectRight, rectTop) << coordsToPixels(rectRight, rectBottom); result.append(result.last()); result << coordsToPixels(rectLeft, rectBottom); } + else + { result << coordsToPixels(rectRight, rectTop) << coordsToPixels(rectLeft, rectTop); result.append(result.last()); result << coordsToPixels(rectLeft, rectBottom); } + break; + } + } + break; + } + case 8: + { + switch (currentRegion) + { + case 7: { result << coordsToPixels(rectRight, rectTop); break; } + case 9: { result << coordsToPixels(rectRight, rectBottom); break; } + case 4: { result << coordsToPixels(rectRight, rectTop); result.append(result.last()); break; } + case 6: { result << coordsToPixels(rectRight, rectBottom); result.append(result.last()); break; } + case 1: { result << coordsToPixels(rectRight, rectTop); result.append(result.last()); result << coordsToPixels(rectLeft, rectTop); break; } + case 3: { result << coordsToPixels(rectRight, rectBottom); result.append(result.last()); result << coordsToPixels(rectLeft, rectBottom); break; } + } + break; + } + case 9: + { + switch (currentRegion) + { + case 6: { result << coordsToPixels(rectRight, rectBottom); break; } + case 8: { result << coordsToPixels(rectRight, rectBottom); break; } + case 3: { result << coordsToPixels(rectRight, rectBottom) << coordsToPixels(rectLeft, rectBottom); break; } + case 7: { result << coordsToPixels(rectRight, rectBottom) << coordsToPixels(rectRight, rectTop); break; } + case 2: { result << coordsToPixels(rectRight, rectBottom) << coordsToPixels(rectLeft, rectBottom); result.append(result.last()); break; } + case 4: { result << coordsToPixels(rectRight, rectBottom) << coordsToPixels(rectRight, rectTop); result.append(result.last()); break; } + case 1: { // in this case we need another distinction of cases: segment may pass below or above rect, requiring either bottom right or top left corner points + if ((value-prevValue)/(key-prevKey)*(rectLeft-key)+value < rectBottom) // segment passes below R + { result << coordsToPixels(rectRight, rectBottom) << coordsToPixels(rectLeft, rectBottom); result.append(result.last()); result << coordsToPixels(rectLeft, rectTop); } + else + { result << coordsToPixels(rectRight, rectBottom) << coordsToPixels(rectRight, rectTop); result.append(result.last()); result << coordsToPixels(rectLeft, rectTop); } + break; + } + } + break; + } + } + return result; +} + +/*! \internal + + This function is part of the curve optimization algorithm of \ref getCurveData. + + This method returns whether a segment going from \a prevRegion to \a currentRegion (see \ref + getRegion) may traverse the visible region 5. This function assumes that neither \a prevRegion + nor \a currentRegion is 5 itself. + + If this method returns false, the segment for sure doesn't pass region 5. If it returns true, the + segment may or may not pass region 5 and a more fine-grained calculation must be used (\ref + getTraverse). +*/ +bool QCPCurve::mayTraverse(int prevRegion, int currentRegion) const +{ + switch (prevRegion) + { + case 1: + { + switch (currentRegion) + { + case 4: + case 7: + case 2: + case 3: return false; + default: return true; + } + } + case 2: + { + switch (currentRegion) + { + case 1: + case 3: return false; + default: return true; + } + } + case 3: + { + switch (currentRegion) + { + case 1: + case 2: + case 6: + case 9: return false; + default: return true; + } + } + case 4: + { + switch (currentRegion) + { + case 1: + case 7: return false; + default: return true; + } + } + case 5: return false; // should never occur + case 6: + { + switch (currentRegion) + { + case 3: + case 9: return false; + default: return true; + } + } + case 7: + { + switch (currentRegion) + { + case 1: + case 4: + case 8: + case 9: return false; + default: return true; + } + } + case 8: + { + switch (currentRegion) + { + case 7: + case 9: return false; + default: return true; + } + } + case 9: + { + switch (currentRegion) + { + case 3: + case 6: + case 8: + case 7: return false; + default: return true; + } + } + default: return true; + } +} + + +/*! \internal + + This function is part of the curve optimization algorithm of \ref getCurveData. + + This method assumes that the \ref mayTraverse test has returned true, so there is a chance the + segment defined by (\a prevKey, \a prevValue) and (\a key, \a value) goes through the visible + region 5. + + The return value of this method indicates whether the segment actually traverses region 5 or not. + + If the segment traverses 5, the output parameters \a crossA and \a crossB indicate the entry and + exit points of region 5. They will become the optimized points for that segment. +*/ +bool QCPCurve::getTraverse(double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom, QPointF &crossA, QPointF &crossB) const +{ + QList intersections; // x of QVector2D corresponds to key and y to value + if (qFuzzyIsNull(key-prevKey)) // line is parallel to value axis + { + // due to region filter in mayTraverseR(), if line is parallel to value or key axis, R is traversed here + intersections.append(QVector2D(key, rectBottom)); // direction will be taken care of at end of method + intersections.append(QVector2D(key, rectTop)); + } else if (qFuzzyIsNull(value-prevValue)) // line is parallel to key axis + { + // due to region filter in mayTraverseR(), if line is parallel to value or key axis, R is traversed here + intersections.append(QVector2D(rectLeft, value)); // direction will be taken care of at end of method + intersections.append(QVector2D(rectRight, value)); + } else // line is skewed + { + double gamma; + double keyPerValue = (key-prevKey)/(value-prevValue); + // check top of rect: + gamma = prevKey + (rectTop-prevValue)*keyPerValue; + if (gamma >= rectLeft && gamma <= rectRight) + intersections.append(QVector2D(gamma, rectTop)); + // check bottom of rect: + gamma = prevKey + (rectBottom-prevValue)*keyPerValue; + if (gamma >= rectLeft && gamma <= rectRight) + intersections.append(QVector2D(gamma, rectBottom)); + double valuePerKey = 1.0/keyPerValue; + // check left of rect: + gamma = prevValue + (rectLeft-prevKey)*valuePerKey; + if (gamma >= rectBottom && gamma <= rectTop) + intersections.append(QVector2D(rectLeft, gamma)); + // check right of rect: + gamma = prevValue + (rectRight-prevKey)*valuePerKey; + if (gamma >= rectBottom && gamma <= rectTop) + intersections.append(QVector2D(rectRight, gamma)); + } + + // handle cases where found points isn't exactly 2: + if (intersections.size() > 2) + { + // line probably goes through corner of rect, and we got duplicate points there. single out the point pair with greatest distance in between: + double distSqrMax = 0; + QVector2D pv1, pv2; + for (int i=0; i distSqrMax) + { + pv1 = intersections.at(i); + pv2 = intersections.at(k); + distSqrMax = distSqr; + } + } + } + intersections = QList() << pv1 << pv2; + } else if (intersections.size() != 2) + { + // one or even zero points found (shouldn't happen unless line perfectly tangent to corner), no need to draw segment + return false; + } + + // possibly re-sort points so optimized point segment has same direction as original segment: + if ((key-prevKey)*(intersections.at(1).x()-intersections.at(0).x()) + (value-prevValue)*(intersections.at(1).y()-intersections.at(0).y()) < 0) // scalar product of both segments < 0 -> opposite direction + intersections.swap(0, 1); + crossA = coordsToPixels(intersections.at(0).x(), intersections.at(0).y()); + crossB = coordsToPixels(intersections.at(1).x(), intersections.at(1).y()); + return true; +} + +/*! \internal + + This function is part of the curve optimization algorithm of \ref getCurveData. + + This method assumes that the \ref getTraverse test has returned true, so the segment definitely + traverses the visible region 5 when going from \a prevRegion to \a currentRegion. + + In certain situations it is not sufficient to merely generate the entry and exit points of the + segment into/out of region 5, as \ref getTraverse provides. It may happen that a single segment, in + addition to traversing region 5, skips another region outside of region 5, which makes it + necessary to add an optimized corner point there (very similar to the job \ref + getOptimizedCornerPoints does for segments that are completely in outside regions and don't + traverse 5). + + As an example, consider a segment going from region 1 to region 6, traversing the lower left + corner of region 5. In this configuration, the segment additionally crosses the border between + region 1 and 2 before entering region 5. This makes it necessary to add an additional point in + the top left corner, before adding the optimized traverse points. So in this case, the output + parameter \a beforeTraverse will contain the top left corner point, and \a afterTraverse will be + empty. + + In some cases, such as when going from region 1 to 9, it may even be necessary to add additional + corner points before and after the traverse. Then both \a beforeTraverse and \a afterTraverse + return the respective corner points. +*/ +void QCPCurve::getTraverseCornerPoints(int prevRegion, int currentRegion, double rectLeft, double rectTop, double rectRight, double rectBottom, QVector &beforeTraverse, QVector &afterTraverse) const +{ + switch (prevRegion) + { + case 1: + { + switch (currentRegion) + { + case 6: { beforeTraverse << coordsToPixels(rectLeft, rectTop); break; } + case 9: { beforeTraverse << coordsToPixels(rectLeft, rectTop); afterTraverse << coordsToPixels(rectRight, rectBottom); break; } + case 8: { beforeTraverse << coordsToPixels(rectLeft, rectTop); break; } + } + break; + } + case 2: + { + switch (currentRegion) + { + case 7: { afterTraverse << coordsToPixels(rectRight, rectTop); break; } + case 9: { afterTraverse << coordsToPixels(rectRight, rectBottom); break; } + } + break; + } + case 3: + { + switch (currentRegion) + { + case 4: { beforeTraverse << coordsToPixels(rectLeft, rectBottom); break; } + case 7: { beforeTraverse << coordsToPixels(rectLeft, rectBottom); afterTraverse << coordsToPixels(rectRight, rectTop); break; } + case 8: { beforeTraverse << coordsToPixels(rectLeft, rectBottom); break; } + } + break; + } + case 4: + { + switch (currentRegion) + { + case 3: { afterTraverse << coordsToPixels(rectLeft, rectBottom); break; } + case 9: { afterTraverse << coordsToPixels(rectRight, rectBottom); break; } + } + break; + } + case 5: { break; } // shouldn't happen because this method only handles full traverses + case 6: + { + switch (currentRegion) + { + case 1: { afterTraverse << coordsToPixels(rectLeft, rectTop); break; } + case 7: { afterTraverse << coordsToPixels(rectRight, rectTop); break; } + } + break; + } + case 7: + { + switch (currentRegion) + { + case 2: { beforeTraverse << coordsToPixels(rectRight, rectTop); break; } + case 3: { beforeTraverse << coordsToPixels(rectRight, rectTop); afterTraverse << coordsToPixels(rectLeft, rectBottom); break; } + case 6: { beforeTraverse << coordsToPixels(rectRight, rectTop); break; } + } + break; + } + case 8: + { + switch (currentRegion) + { + case 1: { afterTraverse << coordsToPixels(rectLeft, rectTop); break; } + case 3: { afterTraverse << coordsToPixels(rectLeft, rectBottom); break; } + } + break; + } + case 9: + { + switch (currentRegion) + { + case 2: { beforeTraverse << coordsToPixels(rectRight, rectBottom); break; } + case 1: { beforeTraverse << coordsToPixels(rectRight, rectBottom); afterTraverse << coordsToPixels(rectLeft, rectTop); break; } + case 4: { beforeTraverse << coordsToPixels(rectRight, rectBottom); break; } + } + break; + } + } +} + +/*! \internal + + Calculates the (minimum) distance (in pixels) the curve's representation has from the given \a + pixelPoint in pixels. This is used to determine whether the curve was clicked or not, e.g. in + \ref selectTest. +*/ +double QCPCurve::pointDistance(const QPointF &pixelPoint) const +{ + if (mData->isEmpty()) + { + qDebug() << Q_FUNC_INFO << "requested point distance on curve" << mName << "without data"; + return 500; + } + if (mData->size() == 1) + { + QPointF dataPoint = coordsToPixels(mData->constBegin().key(), mData->constBegin().value().value); + return QVector2D(dataPoint-pixelPoint).length(); + } + + // calculate minimum distance to line segments: + QVector *lineData = new QVector; + getCurveData(lineData); + double minDistSqr = std::numeric_limits::max(); + for (int i=0; isize()-1; ++i) + { + double currentDistSqr = distSqrToLine(lineData->at(i), lineData->at(i+1), pixelPoint); + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + delete lineData; + return qSqrt(minDistSqr); +} + +/* inherits documentation from base class */ +QCPRange QCPCurve::getKeyRange(bool &foundRange, SignDomain inSignDomain) const +{ + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + double current; + + QCPCurveDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().key; + if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current < 0) || (inSignDomain == sdPositive && current > 0)) + { + if (current < range.lower || !haveLower) + { + range.lower = current; + haveLower = true; + } + if (current > range.upper || !haveUpper) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + + foundRange = haveLower && haveUpper; + return range; +} + +/* inherits documentation from base class */ +QCPRange QCPCurve::getValueRange(bool &foundRange, SignDomain inSignDomain) const +{ + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + double current; + + QCPCurveDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().value; + if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current < 0) || (inSignDomain == sdPositive && current > 0)) + { + if (current < range.lower || !haveLower) + { + range.lower = current; + haveLower = true; + } + if (current > range.upper || !haveUpper) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + + foundRange = haveLower && haveUpper; + return range; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPBarsGroup +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPBarsGroup + \brief Groups multiple QCPBars together so they appear side by side + + \image html QCPBarsGroup.png + + When showing multiple QCPBars in one plot which have bars at identical keys, it may be desirable + to have them appearing next to each other at each key. This is what adding the respective QCPBars + plottables to a QCPBarsGroup achieves. (An alternative approach is to stack them on top of each + other, see \ref QCPBars::moveAbove.) + + \section qcpbarsgroup-usage Usage + + To add a QCPBars plottable to the group, create a new group and then add the respective bars + intances: + \code + QCPBarsGroup *group = new QCPBarsGroup(customPlot); + group->append(bars1); + group->append(bars2); + \endcode + Alternatively to appending to the group like shown above, you can also set the group on the + QCPBars plottable via \ref QCPBars::setBarsGroup. + + The spacing between the bars can be configured via \ref setSpacingType and \ref setSpacing. The + bars in this group appear in the plot in the order they were appended. To insert a bars plottable + at a certain index position, or to reposition a bars plottable which is already in the group, use + \ref insert. + + To remove specific bars from the group, use either \ref remove or call \ref + QCPBars::setBarsGroup "QCPBars::setBarsGroup(0)" on the respective bars plottable. + + To clear the entire group, call \ref clear, or simply delete the group. +*/ + +/* start of documentation of inline functions */ + +/*! \fn QList QCPBarsGroup::bars() const + + Returns all bars currently in this group. + + \see bars(int index) +*/ + +/*! \fn int QCPBarsGroup::size() const + + Returns the number of QCPBars plottables that are part of this group. + +*/ + +/*! \fn bool QCPBarsGroup::isEmpty() const + + Returns whether this bars group is empty. + + \see size +*/ + +/*! \fn bool QCPBarsGroup::contains(QCPBars *bars) + + Returns whether the specified \a bars plottable is part of this group. + +*/ + +/* end of documentation of inline functions */ + +/*! + Constructs a new bars group for the specified QCustomPlot instance. +*/ +QCPBarsGroup::QCPBarsGroup(QCustomPlot *parentPlot) : + QObject(parentPlot), + mParentPlot(parentPlot), + mSpacingType(stAbsolute), + mSpacing(4) +{ +} + +QCPBarsGroup::~QCPBarsGroup() +{ + clear(); +} + +/*! + Sets how the spacing between adjacent bars is interpreted. See \ref SpacingType. + + The actual spacing can then be specified with \ref setSpacing. + + \see setSpacing +*/ +void QCPBarsGroup::setSpacingType(SpacingType spacingType) +{ + mSpacingType = spacingType; +} + +/*! + Sets the spacing between adjacent bars. What the number passed as \a spacing actually means, is + defined by the current \ref SpacingType, which can be set with \ref setSpacingType. + + \see setSpacingType +*/ +void QCPBarsGroup::setSpacing(double spacing) +{ + mSpacing = spacing; +} + +/*! + Returns the QCPBars instance with the specified \a index in this group. If no such QCPBars + exists, returns 0. + + \see bars(), size +*/ +QCPBars *QCPBarsGroup::bars(int index) const +{ + if (index >= 0 && index < mBars.size()) + { + return mBars.at(index); + } else + { + qDebug() << Q_FUNC_INFO << "index out of bounds:" << index; + return 0; + } +} + +/*! + Removes all QCPBars plottables from this group. + + \see isEmpty +*/ +void QCPBarsGroup::clear() +{ + foreach (QCPBars *bars, mBars) // since foreach takes a copy, removing bars in the loop is okay + bars->setBarsGroup(0); // removes itself via removeBars +} + +/*! + Adds the specified \a bars plottable to this group. Alternatively, you can also use \ref + QCPBars::setBarsGroup on the \a bars instance. + + \see insert, remove +*/ +void QCPBarsGroup::append(QCPBars *bars) +{ + if (!bars) + { + qDebug() << Q_FUNC_INFO << "bars is 0"; + return; + } + + if (!mBars.contains(bars)) + bars->setBarsGroup(this); + else + qDebug() << Q_FUNC_INFO << "bars plottable is already in this bars group:" << reinterpret_cast(bars); +} + +/*! + Inserts the specified \a bars plottable into this group at the specified index position \a i. + This gives you full control over the ordering of the bars. + + \a bars may already be part of this group. In that case, \a bars is just moved to the new index + position. + + \see append, remove +*/ +void QCPBarsGroup::insert(int i, QCPBars *bars) +{ + if (!bars) + { + qDebug() << Q_FUNC_INFO << "bars is 0"; + return; + } + + // first append to bars list normally: + if (!mBars.contains(bars)) + bars->setBarsGroup(this); + // then move to according position: + mBars.move(mBars.indexOf(bars), qBound(0, i, mBars.size()-1)); +} + +/*! + Removes the specified \a bars plottable from this group. + + \see contains, clear +*/ +void QCPBarsGroup::remove(QCPBars *bars) +{ + if (!bars) + { + qDebug() << Q_FUNC_INFO << "bars is 0"; + return; + } + + if (mBars.contains(bars)) + bars->setBarsGroup(0); + else + qDebug() << Q_FUNC_INFO << "bars plottable is not in this bars group:" << reinterpret_cast(bars); +} + +/*! \internal + + Adds the specified \a bars to the internal mBars list of bars. This method does not change the + barsGroup property on \a bars. + + \see unregisterBars +*/ +void QCPBarsGroup::registerBars(QCPBars *bars) +{ + if (!mBars.contains(bars)) + mBars.append(bars); +} + +/*! \internal + + Removes the specified \a bars from the internal mBars list of bars. This method does not change + the barsGroup property on \a bars. + + \see registerBars +*/ +void QCPBarsGroup::unregisterBars(QCPBars *bars) +{ + mBars.removeOne(bars); +} + +/*! \internal + + Returns the pixel offset in the key dimension the specified \a bars plottable should have at the + given key coordinate \a keyCoord. The offset is relative to the pixel position of the key + coordinate \a keyCoord. +*/ +double QCPBarsGroup::keyPixelOffset(const QCPBars *bars, double keyCoord) +{ + // find list of all base bars in case some mBars are stacked: + QList baseBars; + foreach (const QCPBars *b, mBars) + { + while (b->barBelow()) + b = b->barBelow(); + if (!baseBars.contains(b)) + baseBars.append(b); + } + // find base bar this "bars" is stacked on: + const QCPBars *thisBase = bars; + while (thisBase->barBelow()) + thisBase = thisBase->barBelow(); + + // determine key pixel offset of this base bars considering all other base bars in this barsgroup: + double result = 0; + int index = baseBars.indexOf(thisBase); + if (index >= 0) + { + int startIndex; + double lowerPixelWidth, upperPixelWidth; + if (baseBars.size() % 2 == 1 && index == (baseBars.size()-1)/2) // is center bar (int division on purpose) + { + return result; + } else if (index < (baseBars.size()-1)/2.0) // bar is to the left of center + { + if (baseBars.size() % 2 == 0) // even number of bars + { + startIndex = baseBars.size()/2-1; + result -= getPixelSpacing(baseBars.at(startIndex), keyCoord)*0.5; // half of middle spacing + } else // uneven number of bars + { + startIndex = (baseBars.size()-1)/2-1; + baseBars.at((baseBars.size()-1)/2)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth); + result -= qAbs(upperPixelWidth-lowerPixelWidth)*0.5; // half of center bar + result -= getPixelSpacing(baseBars.at((baseBars.size()-1)/2), keyCoord); // center bar spacing + } + for (int i=startIndex; i>index; --i) // add widths and spacings of bars in between center and our bars + { + baseBars.at(i)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth); + result -= qAbs(upperPixelWidth-lowerPixelWidth); + result -= getPixelSpacing(baseBars.at(i), keyCoord); + } + // finally half of our bars width: + baseBars.at(index)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth); + result -= qAbs(upperPixelWidth-lowerPixelWidth)*0.5; + } else // bar is to the right of center + { + if (baseBars.size() % 2 == 0) // even number of bars + { + startIndex = baseBars.size()/2; + result += getPixelSpacing(baseBars.at(startIndex), keyCoord)*0.5; // half of middle spacing + } else // uneven number of bars + { + startIndex = (baseBars.size()-1)/2+1; + baseBars.at((baseBars.size()-1)/2)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth); + result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5; // half of center bar + result += getPixelSpacing(baseBars.at((baseBars.size()-1)/2), keyCoord); // center bar spacing + } + for (int i=startIndex; igetPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth); + result += qAbs(upperPixelWidth-lowerPixelWidth); + result += getPixelSpacing(baseBars.at(i), keyCoord); + } + // finally half of our bars width: + baseBars.at(index)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth); + result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5; + } + } + return result; +} + +/*! \internal + + Returns the spacing in pixels which is between this \a bars and the following one, both at the + key coordinate \a keyCoord. + + \note Typically the returned value doesn't depend on \a bars or \a keyCoord. \a bars is only + needed to get acces to the key axis transformation and axis rect for the modes \ref + stAxisRectRatio and \ref stPlotCoords. The \a keyCoord is only relevant for spacings given in + \ref stPlotCoords on a logarithmic axis. +*/ +double QCPBarsGroup::getPixelSpacing(const QCPBars *bars, double keyCoord) +{ + switch (mSpacingType) + { + case stAbsolute: + { + return mSpacing; + } + case stAxisRectRatio: + { + if (bars->keyAxis()->orientation() == Qt::Horizontal) + return bars->keyAxis()->axisRect()->width()*mSpacing; + else + return bars->keyAxis()->axisRect()->height()*mSpacing; + } + case stPlotCoords: + { + double keyPixel = bars->keyAxis()->coordToPixel(keyCoord); + return bars->keyAxis()->coordToPixel(keyCoord+mSpacing)-keyPixel; + } + } + return 0; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPBarData +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPBarData + \brief Holds the data of one single data point (one bar) for QCPBars. + + The container for storing multiple data points is \ref QCPBarDataMap. + + The stored data is: + \li \a key: coordinate on the key axis of this bar + \li \a value: height coordinate on the value axis of this bar + + \see QCPBarDataaMap +*/ + +/*! + Constructs a bar data point with key and value set to zero. +*/ +QCPBarData::QCPBarData() : + key(0), + value(0) +{ +} + +/*! + Constructs a bar data point with the specified \a key and \a value. +*/ +QCPBarData::QCPBarData(double key, double value) : + key(key), + value(value) +{ +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPBars +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPBars + \brief A plottable representing a bar chart in a plot. + + \image html QCPBars.png + + To plot data, assign it with the \ref setData or \ref addData functions. + + \section appearance Changing the appearance + + The appearance of the bars is determined by the pen and the brush (\ref setPen, \ref setBrush). + The width of the individual bars can be controlled with \ref setWidthType and \ref setWidth. + + Bar charts are stackable. This means, two QCPBars plottables can be placed on top of each other + (see \ref QCPBars::moveAbove). So when two bars are at the same key position, they will appear + stacked. + + If you would like to group multiple QCPBars plottables together so they appear side by side as + shown below, use QCPBarsGroup. + + \image html QCPBarsGroup.png + + \section usage Usage + + Like all data representing objects in QCustomPlot, the QCPBars is a plottable + (QCPAbstractPlottable). So the plottable-interface of QCustomPlot applies + (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.) + + Usually, you first create an instance: + \code + QCPBars *newBars = new QCPBars(customPlot->xAxis, customPlot->yAxis);\endcode + add it to the customPlot with QCustomPlot::addPlottable: + \code + customPlot->addPlottable(newBars);\endcode + and then modify the properties of the newly created plottable, e.g.: + \code + newBars->setName("Country population"); + newBars->setData(xData, yData);\endcode +*/ + +/* start of documentation of inline functions */ + +/*! \fn QCPBars *QCPBars::barBelow() const + Returns the bars plottable that is directly below this bars plottable. + If there is no such plottable, returns 0. + + \see barAbove, moveBelow, moveAbove +*/ + +/*! \fn QCPBars *QCPBars::barAbove() const + Returns the bars plottable that is directly above this bars plottable. + If there is no such plottable, returns 0. + + \see barBelow, moveBelow, moveAbove +*/ + +/* end of documentation of inline functions */ + +/*! + Constructs a bar chart which uses \a keyAxis as its key axis ("x") and \a valueAxis as its value + axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and not have + the same orientation. If either of these restrictions is violated, a corresponding message is + printed to the debug output (qDebug), the construction is not aborted, though. + + The constructed QCPBars can be added to the plot with QCustomPlot::addPlottable, QCustomPlot + then takes ownership of the bar chart. +*/ +QCPBars::QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis), + mData(new QCPBarDataMap), + mWidth(0.75), + mWidthType(wtPlotCoords), + mBarsGroup(0), + mBaseValue(0) +{ + // modify inherited properties from abstract plottable: + mPen.setColor(Qt::blue); + mPen.setStyle(Qt::SolidLine); + mBrush.setColor(QColor(40, 50, 255, 30)); + mBrush.setStyle(Qt::SolidPattern); + mSelectedPen = mPen; + mSelectedPen.setWidthF(2.5); + mSelectedPen.setColor(QColor(80, 80, 255)); // lighter than Qt::blue of mPen + mSelectedBrush = mBrush; +} + +QCPBars::~QCPBars() +{ + setBarsGroup(0); + if (mBarBelow || mBarAbove) + connectBars(mBarBelow.data(), mBarAbove.data()); // take this bar out of any stacking + delete mData; +} + +/*! + Sets the width of the bars. + + How the number passed as \a width is interpreted (e.g. screen pixels, plot coordinates,...), + depends on the currently set width type, see \ref setWidthType and \ref WidthType. +*/ +void QCPBars::setWidth(double width) +{ + mWidth = width; +} + +/*! + Sets how the width of the bars is defined. See the documentation of \ref WidthType for an + explanation of the possible values for \a widthType. + + The default value is \ref wtPlotCoords. + + \see setWidth +*/ +void QCPBars::setWidthType(QCPBars::WidthType widthType) +{ + mWidthType = widthType; +} + +/*! + Sets to which QCPBarsGroup this QCPBars instance belongs to. Alternatively, you can also use \ref + QCPBarsGroup::append. + + To remove this QCPBars from any group, set \a barsGroup to 0. +*/ +void QCPBars::setBarsGroup(QCPBarsGroup *barsGroup) +{ + // deregister at old group: + if (mBarsGroup) + mBarsGroup->unregisterBars(this); + mBarsGroup = barsGroup; + // register at new group: + if (mBarsGroup) + mBarsGroup->registerBars(this); +} + +/*! + Sets the base value of this bars plottable. + + The base value defines where on the value coordinate the bars start. How far the bars extend from + the base value is given by their individual value data. For example, if the base value is set to + 1, a bar with data value 2 will have its lowest point at value coordinate 1 and highest point at + 3. + + For stacked bars, only the base value of the bottom-most QCPBars has meaning. + + The default base value is 0. +*/ +void QCPBars::setBaseValue(double baseValue) +{ + mBaseValue = baseValue; +} + +/*! + Replaces the current data with the provided \a data. + + If \a copy is set to true, data points in \a data will only be copied. if false, the plottable + takes ownership of the passed data and replaces the internal data pointer with it. This is + significantly faster than copying for large datasets. +*/ +void QCPBars::setData(QCPBarDataMap *data, bool copy) +{ + if (copy) + { + *mData = *data; + } else + { + delete mData; + mData = data; + } +} + +/*! \overload + + Replaces the current data with the provided points in \a key and \a value tuples. The + provided vectors should have equal length. Else, the number of added points will be the size of + the smallest vector. +*/ +void QCPBars::setData(const QVector &key, const QVector &value) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, value.size()); + QCPBarData newData; + for (int i=0; iinsertMulti(newData.key, newData); + } +} + +/*! + Moves this bars plottable below \a bars. In other words, the bars of this plottable will appear + below the bars of \a bars. The move target \a bars must use the same key and value axis as this + plottable. + + Inserting into and removing from existing bar stacking is handled gracefully. If \a bars already + has a bars object below itself, this bars object is inserted between the two. If this bars object + is already between two other bars, the two other bars will be stacked on top of each other after + the operation. + + To remove this bars plottable from any stacking, set \a bars to 0. + + \see moveBelow, barAbove, barBelow +*/ +void QCPBars::moveBelow(QCPBars *bars) +{ + if (bars == this) return; + if (bars && (bars->keyAxis() != mKeyAxis.data() || bars->valueAxis() != mValueAxis.data())) + { + qDebug() << Q_FUNC_INFO << "passed QCPBars* doesn't have same key and value axis as this QCPBars"; + return; + } + // remove from stacking: + connectBars(mBarBelow.data(), mBarAbove.data()); // Note: also works if one (or both) of them is 0 + // if new bar given, insert this bar below it: + if (bars) + { + if (bars->mBarBelow) + connectBars(bars->mBarBelow.data(), this); + connectBars(this, bars); + } +} + +/*! + Moves this bars plottable above \a bars. In other words, the bars of this plottable will appear + above the bars of \a bars. The move target \a bars must use the same key and value axis as this + plottable. + + Inserting into and removing from existing bar stacking is handled gracefully. If \a bars already + has a bars object below itself, this bars object is inserted between the two. If this bars object + is already between two other bars, the two other bars will be stacked on top of each other after + the operation. + + To remove this bars plottable from any stacking, set \a bars to 0. + + \see moveBelow, barBelow, barAbove +*/ +void QCPBars::moveAbove(QCPBars *bars) +{ + if (bars == this) return; + if (bars && (bars->keyAxis() != mKeyAxis.data() || bars->valueAxis() != mValueAxis.data())) + { + qDebug() << Q_FUNC_INFO << "passed QCPBars* doesn't have same key and value axis as this QCPBars"; + return; + } + // remove from stacking: + connectBars(mBarBelow.data(), mBarAbove.data()); // Note: also works if one (or both) of them is 0 + // if new bar given, insert this bar above it: + if (bars) + { + if (bars->mBarAbove) + connectBars(this, bars->mBarAbove.data()); + connectBars(bars, this); + } +} + +/*! + Adds the provided data points in \a dataMap to the current data. + \see removeData +*/ +void QCPBars::addData(const QCPBarDataMap &dataMap) +{ + mData->unite(dataMap); +} + +/*! \overload + Adds the provided single data point in \a data to the current data. + \see removeData +*/ +void QCPBars::addData(const QCPBarData &data) +{ + mData->insertMulti(data.key, data); +} + +/*! \overload + Adds the provided single data point as \a key and \a value tuple to the current data + \see removeData +*/ +void QCPBars::addData(double key, double value) +{ + QCPBarData newData; + newData.key = key; + newData.value = value; + mData->insertMulti(newData.key, newData); +} + +/*! \overload + Adds the provided data points as \a key and \a value tuples to the current data. + \see removeData +*/ +void QCPBars::addData(const QVector &keys, const QVector &values) +{ + int n = keys.size(); + n = qMin(n, values.size()); + QCPBarData newData; + for (int i=0; iinsertMulti(newData.key, newData); + } +} + +/*! + Removes all data points with key smaller than \a key. + \see addData, clearData +*/ +void QCPBars::removeDataBefore(double key) +{ + QCPBarDataMap::iterator it = mData->begin(); + while (it != mData->end() && it.key() < key) + it = mData->erase(it); +} + +/*! + Removes all data points with key greater than \a key. + \see addData, clearData +*/ +void QCPBars::removeDataAfter(double key) +{ + if (mData->isEmpty()) return; + QCPBarDataMap::iterator it = mData->upperBound(key); + while (it != mData->end()) + it = mData->erase(it); +} + +/*! + Removes all data points with key between \a fromKey and \a toKey. if \a fromKey is + greater or equal to \a toKey, the function does nothing. To remove a single data point with known + key, use \ref removeData(double key). + + \see addData, clearData +*/ +void QCPBars::removeData(double fromKey, double toKey) +{ + if (fromKey >= toKey || mData->isEmpty()) return; + QCPBarDataMap::iterator it = mData->upperBound(fromKey); + QCPBarDataMap::iterator itEnd = mData->upperBound(toKey); + while (it != itEnd) + it = mData->erase(it); +} + +/*! \overload + + Removes a single data point at \a key. If the position is not known with absolute precision, + consider using \ref removeData(double fromKey, double toKey) with a small fuzziness interval + around the suspected position, depeding on the precision with which the key is known. + + \see addData, clearData +*/ +void QCPBars::removeData(double key) +{ + mData->remove(key); +} + +/*! + Removes all data points. + \see removeData, removeDataAfter, removeDataBefore +*/ +void QCPBars::clearData() +{ + mData->clear(); +} + +/* inherits documentation from base class */ +double QCPBars::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) + { + QCPBarDataMap::ConstIterator it; + for (it = mData->constBegin(); it != mData->constEnd(); ++it) + { + if (getBarPolygon(it.value().key, it.value().value).boundingRect().contains(pos)) + return mParentPlot->selectionTolerance()*0.99; + } + } + return -1; +} + +/* inherits documentation from base class */ +void QCPBars::draw(QCPPainter *painter) +{ + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + if (mData->isEmpty()) return; + + QCPBarDataMap::const_iterator it, lower, upperEnd; + getVisibleDataBounds(lower, upperEnd); + for (it = lower; it != upperEnd; ++it) + { + // check data validity if flag set: +#ifdef QCUSTOMPLOT_CHECK_DATA + if (QCP::isInvalidData(it.value().key, it.value().value)) + qDebug() << Q_FUNC_INFO << "Data point at" << it.key() << "of drawn range invalid." << "Plottable name:" << name(); +#endif + QPolygonF barPolygon = getBarPolygon(it.key(), it.value().value); + // draw bar fill: + if (mainBrush().style() != Qt::NoBrush && mainBrush().color().alpha() != 0) + { + applyFillAntialiasingHint(painter); + painter->setPen(Qt::NoPen); + painter->setBrush(mainBrush()); + painter->drawPolygon(barPolygon); + } + // draw bar line: + if (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) + { + applyDefaultAntialiasingHint(painter); + painter->setPen(mainPen()); + painter->setBrush(Qt::NoBrush); + painter->drawPolyline(barPolygon); + } + } +} + +/* inherits documentation from base class */ +void QCPBars::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +{ + // draw filled rect: + applyDefaultAntialiasingHint(painter); + painter->setBrush(mBrush); + painter->setPen(mPen); + QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67); + r.moveCenter(rect.center()); + painter->drawRect(r); +} + +/*! \internal + + called by \ref draw to determine which data (key) range is visible at the current key axis range + setting, so only that needs to be processed. It also takes into account the bar width. + + \a lower returns an iterator to the lowest data point that needs to be taken into account when + plotting. Note that in order to get a clean plot all the way to the edge of the axis rect, \a + lower may still be just outside the visible range. + + \a upperEnd returns an iterator one higher than the highest visible data point. Same as before, \a + upperEnd may also lie just outside of the visible range. + + if the bars plottable contains no data, both \a lower and \a upperEnd point to constEnd. +*/ +void QCPBars::getVisibleDataBounds(QCPBarDataMap::const_iterator &lower, QCPBarDataMap::const_iterator &upperEnd) const +{ + if (!mKeyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } + if (mData->isEmpty()) + { + lower = mData->constEnd(); + upperEnd = mData->constEnd(); + return; + } + + // get visible data range as QMap iterators + lower = mData->lowerBound(mKeyAxis.data()->range().lower); + upperEnd = mData->upperBound(mKeyAxis.data()->range().upper); + double lowerPixelBound = mKeyAxis.data()->coordToPixel(mKeyAxis.data()->range().lower); + double upperPixelBound = mKeyAxis.data()->coordToPixel(mKeyAxis.data()->range().upper); + bool isVisible = false; + // walk left from lbound to find lower bar that actually is completely outside visible pixel range: + QCPBarDataMap::const_iterator it = lower; + while (it != mData->constBegin()) + { + --it; + QRectF barBounds = getBarPolygon(it.value().key, it.value().value).boundingRect(); + if (mKeyAxis.data()->orientation() == Qt::Horizontal) + isVisible = ((!mKeyAxis.data()->rangeReversed() && barBounds.right() >= lowerPixelBound) || (mKeyAxis.data()->rangeReversed() && barBounds.left() <= lowerPixelBound)); + else // keyaxis is vertical + isVisible = ((!mKeyAxis.data()->rangeReversed() && barBounds.top() <= lowerPixelBound) || (mKeyAxis.data()->rangeReversed() && barBounds.bottom() >= lowerPixelBound)); + if (isVisible) + lower = it; + else + break; + } + // walk right from ubound to find upper bar that actually is completely outside visible pixel range: + it = upperEnd; + while (it != mData->constEnd()) + { + QRectF barBounds = getBarPolygon(upperEnd.value().key, upperEnd.value().value).boundingRect(); + if (mKeyAxis.data()->orientation() == Qt::Horizontal) + isVisible = ((!mKeyAxis.data()->rangeReversed() && barBounds.left() <= upperPixelBound) || (mKeyAxis.data()->rangeReversed() && barBounds.right() >= upperPixelBound)); + else // keyaxis is vertical + isVisible = ((!mKeyAxis.data()->rangeReversed() && barBounds.bottom() >= upperPixelBound) || (mKeyAxis.data()->rangeReversed() && barBounds.top() <= upperPixelBound)); + if (isVisible) + upperEnd = it+1; + else + break; + ++it; + } +} + +/*! \internal + + Returns the polygon of a single bar with \a key and \a value. The Polygon is open at the bottom + and shifted according to the bar stacking (see \ref moveAbove) and base value (see \ref + setBaseValue). +*/ +QPolygonF QCPBars::getBarPolygon(double key, double value) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return QPolygonF(); } + + QPolygonF result; + double lowerPixelWidth, upperPixelWidth; + getPixelWidth(key, lowerPixelWidth, upperPixelWidth); + double base = getStackedBaseValue(key, value >= 0); + double basePixel = valueAxis->coordToPixel(base); + double valuePixel = valueAxis->coordToPixel(base+value); + double keyPixel = keyAxis->coordToPixel(key); + if (mBarsGroup) + keyPixel += mBarsGroup->keyPixelOffset(this, key); + if (keyAxis->orientation() == Qt::Horizontal) + { + result << QPointF(keyPixel+lowerPixelWidth, basePixel); + result << QPointF(keyPixel+lowerPixelWidth, valuePixel); + result << QPointF(keyPixel+upperPixelWidth, valuePixel); + result << QPointF(keyPixel+upperPixelWidth, basePixel); + } else + { + result << QPointF(basePixel, keyPixel+lowerPixelWidth); + result << QPointF(valuePixel, keyPixel+lowerPixelWidth); + result << QPointF(valuePixel, keyPixel+upperPixelWidth); + result << QPointF(basePixel, keyPixel+upperPixelWidth); + } + return result; +} + +/*! \internal + + This function is used to determine the width of the bar at coordinate \a key, according to the + specified width (\ref setWidth) and width type (\ref setWidthType). + + The output parameters \a lower and \a upper return the number of pixels the bar extends to lower + and higher keys, relative to the \a key coordinate (so with a non-reversed horizontal axis, \a + lower is negative and \a upper positive). +*/ +void QCPBars::getPixelWidth(double key, double &lower, double &upper) const +{ + switch (mWidthType) + { + case wtAbsolute: + { + upper = mWidth*0.5; + lower = -upper; + if (mKeyAxis && (mKeyAxis.data()->rangeReversed() ^ (mKeyAxis.data()->orientation() == Qt::Vertical))) + qSwap(lower, upper); + break; + } + case wtAxisRectRatio: + { + if (mKeyAxis && mKeyAxis.data()->axisRect()) + { + if (mKeyAxis.data()->orientation() == Qt::Horizontal) + upper = mKeyAxis.data()->axisRect()->width()*mWidth*0.5; + else + upper = mKeyAxis.data()->axisRect()->height()*mWidth*0.5; + lower = -upper; + if (mKeyAxis && (mKeyAxis.data()->rangeReversed() ^ (mKeyAxis.data()->orientation() == Qt::Vertical))) + qSwap(lower, upper); + } else + qDebug() << Q_FUNC_INFO << "No key axis or axis rect defined"; + break; + } + case wtPlotCoords: + { + if (mKeyAxis) + { + double keyPixel = mKeyAxis.data()->coordToPixel(key); + upper = mKeyAxis.data()->coordToPixel(key+mWidth*0.5)-keyPixel; + lower = mKeyAxis.data()->coordToPixel(key-mWidth*0.5)-keyPixel; + // no need to qSwap(lower, higher) when range reversed, because higher/lower are gained by + // coordinate transform which includes range direction + } else + qDebug() << Q_FUNC_INFO << "No key axis defined"; + break; + } + } +} + +/*! \internal + + This function is called to find at which value to start drawing the base of a bar at \a key, when + it is stacked on top of another QCPBars (e.g. with \ref moveAbove). + + positive and negative bars are separated per stack (positive are stacked above baseValue upwards, + negative are stacked below baseValue downwards). This can be indicated with \a positive. So if the + bar for which we need the base value is negative, set \a positive to false. +*/ +double QCPBars::getStackedBaseValue(double key, bool positive) const +{ + if (mBarBelow) + { + double max = 0; // don't use mBaseValue here because only base value of bottom-most bar has meaning in a bar stack + // find bars of mBarBelow that are approximately at key and find largest one: + double epsilon = qAbs(key)*1e-6; // should be safe even when changed to use float at some point + if (key == 0) + epsilon = 1e-6; + QCPBarDataMap::const_iterator it = mBarBelow.data()->mData->lowerBound(key-epsilon); + QCPBarDataMap::const_iterator itEnd = mBarBelow.data()->mData->upperBound(key+epsilon); + while (it != itEnd) + { + if ((positive && it.value().value > max) || + (!positive && it.value().value < max)) + max = it.value().value; + ++it; + } + // recurse down the bar-stack to find the total height: + return max + mBarBelow.data()->getStackedBaseValue(key, positive); + } else + return mBaseValue; +} + +/*! \internal + + Connects \a below and \a above to each other via their mBarAbove/mBarBelow properties. The bar(s) + currently above lower and below upper will become disconnected to lower/upper. + + If lower is zero, upper will be disconnected at the bottom. + If upper is zero, lower will be disconnected at the top. +*/ +void QCPBars::connectBars(QCPBars *lower, QCPBars *upper) +{ + if (!lower && !upper) return; + + if (!lower) // disconnect upper at bottom + { + // disconnect old bar below upper: + if (upper->mBarBelow && upper->mBarBelow.data()->mBarAbove.data() == upper) + upper->mBarBelow.data()->mBarAbove = 0; + upper->mBarBelow = 0; + } else if (!upper) // disconnect lower at top + { + // disconnect old bar above lower: + if (lower->mBarAbove && lower->mBarAbove.data()->mBarBelow.data() == lower) + lower->mBarAbove.data()->mBarBelow = 0; + lower->mBarAbove = 0; + } else // connect lower and upper + { + // disconnect old bar above lower: + if (lower->mBarAbove && lower->mBarAbove.data()->mBarBelow.data() == lower) + lower->mBarAbove.data()->mBarBelow = 0; + // disconnect old bar below upper: + if (upper->mBarBelow && upper->mBarBelow.data()->mBarAbove.data() == upper) + upper->mBarBelow.data()->mBarAbove = 0; + lower->mBarAbove = upper; + upper->mBarBelow = lower; + } +} + +/* inherits documentation from base class */ +QCPRange QCPBars::getKeyRange(bool &foundRange, SignDomain inSignDomain) const +{ + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + double current; + QCPBarDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().key; + if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current < 0) || (inSignDomain == sdPositive && current > 0)) + { + if (current < range.lower || !haveLower) + { + range.lower = current; + haveLower = true; + } + if (current > range.upper || !haveUpper) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + // determine exact range of bars by including bar width and barsgroup offset: + if (haveLower && mKeyAxis) + { + double lowerPixelWidth, upperPixelWidth, keyPixel; + getPixelWidth(range.lower, lowerPixelWidth, upperPixelWidth); + keyPixel = mKeyAxis.data()->coordToPixel(range.lower) + lowerPixelWidth; + if (mBarsGroup) + keyPixel += mBarsGroup->keyPixelOffset(this, range.lower); + range.lower = mKeyAxis.data()->pixelToCoord(keyPixel); + } + if (haveUpper && mKeyAxis) + { + double lowerPixelWidth, upperPixelWidth, keyPixel; + getPixelWidth(range.upper, lowerPixelWidth, upperPixelWidth); + keyPixel = mKeyAxis.data()->coordToPixel(range.upper) + upperPixelWidth; + if (mBarsGroup) + keyPixel += mBarsGroup->keyPixelOffset(this, range.upper); + range.upper = mKeyAxis.data()->pixelToCoord(keyPixel); + } + foundRange = haveLower && haveUpper; + return range; +} + +/* inherits documentation from base class */ +QCPRange QCPBars::getValueRange(bool &foundRange, SignDomain inSignDomain) const +{ + QCPRange range; + range.lower = mBaseValue; + range.upper = mBaseValue; + bool haveLower = true; // set to true, because baseValue should always be visible in bar charts + bool haveUpper = true; // set to true, because baseValue should always be visible in bar charts + double current; + + QCPBarDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().value + getStackedBaseValue(it.value().key, it.value().value >= 0); + if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current < 0) || (inSignDomain == sdPositive && current > 0)) + { + if (current < range.lower || !haveLower) + { + range.lower = current; + haveLower = true; + } + if (current > range.upper || !haveUpper) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + + foundRange = true; // return true because bar charts always have the 0-line visible + return range; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPStatisticalBox +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPStatisticalBox + \brief A plottable representing a single statistical box in a plot. + + \image html QCPStatisticalBox.png + + To plot data, assign it with the individual parameter functions or use \ref setData to set all + parameters at once. The individual functions are: + \li \ref setMinimum + \li \ref setLowerQuartile + \li \ref setMedian + \li \ref setUpperQuartile + \li \ref setMaximum + + Additionally you can define a list of outliers, drawn as scatter datapoints: + \li \ref setOutliers + + \section appearance Changing the appearance + + The appearance of the box itself is controlled via \ref setPen and \ref setBrush. You may change + the width of the box with \ref setWidth in plot coordinates (not pixels). + + Analog functions exist for the minimum/maximum-whiskers: \ref setWhiskerPen, \ref + setWhiskerBarPen, \ref setWhiskerWidth. The whisker width is the width of the bar at the top + (maximum) and bottom (minimum). + + The median indicator line has its own pen, \ref setMedianPen. + + If the whisker backbone pen is changed, make sure to set the capStyle to Qt::FlatCap. Else, the + backbone line might exceed the whisker bars by a few pixels due to the pen cap being not + perfectly flat. + + The Outlier data points are drawn as normal scatter points. Their look can be controlled with + \ref setOutlierStyle + + \section usage Usage + + Like all data representing objects in QCustomPlot, the QCPStatisticalBox is a plottable + (QCPAbstractPlottable). So the plottable-interface of QCustomPlot applies + (QCustomPlot::plottable, QCustomPlot::addPlottable, QCustomPlot::removePlottable, etc.) + + Usually, you first create an instance: + \code + QCPStatisticalBox *newBox = new QCPStatisticalBox(customPlot->xAxis, customPlot->yAxis);\endcode + add it to the customPlot with QCustomPlot::addPlottable: + \code + customPlot->addPlottable(newBox);\endcode + and then modify the properties of the newly created plottable, e.g.: + \code + newBox->setName("Measurement Series 1"); + newBox->setData(1, 3, 4, 5, 7); + newBox->setOutliers(QVector() << 0.5 << 0.64 << 7.2 << 7.42);\endcode +*/ + +/*! + Constructs a statistical box which uses \a keyAxis as its key axis ("x") and \a valueAxis as its + value axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and + not have the same orientation. If either of these restrictions is violated, a corresponding + message is printed to the debug output (qDebug), the construction is not aborted, though. + + The constructed statistical box can be added to the plot with QCustomPlot::addPlottable, + QCustomPlot then takes ownership of the statistical box. +*/ +QCPStatisticalBox::QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis), + mKey(0), + mMinimum(0), + mLowerQuartile(0), + mMedian(0), + mUpperQuartile(0), + mMaximum(0) +{ + setOutlierStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::blue, 6)); + setWhiskerWidth(0.2); + setWidth(0.5); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue, 2.5)); + setMedianPen(QPen(Qt::black, 3, Qt::SolidLine, Qt::FlatCap)); + setWhiskerPen(QPen(Qt::black, 0, Qt::DashLine, Qt::FlatCap)); + setWhiskerBarPen(QPen(Qt::black)); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); +} + +/*! + Sets the key coordinate of the statistical box. +*/ +void QCPStatisticalBox::setKey(double key) +{ + mKey = key; +} + +/*! + Sets the parameter "minimum" of the statistical box plot. This is the position of the lower + whisker, typically the minimum measurement of the sample that's not considered an outlier. + + \see setMaximum, setWhiskerPen, setWhiskerBarPen, setWhiskerWidth +*/ +void QCPStatisticalBox::setMinimum(double value) +{ + mMinimum = value; +} + +/*! + Sets the parameter "lower Quartile" of the statistical box plot. This is the lower end of the + box. The lower and the upper quartiles are the two statistical quartiles around the median of the + sample, they contain 50% of the sample data. + + \see setUpperQuartile, setPen, setBrush, setWidth +*/ +void QCPStatisticalBox::setLowerQuartile(double value) +{ + mLowerQuartile = value; +} + +/*! + Sets the parameter "median" of the statistical box plot. This is the value of the median mark + inside the quartile box. The median separates the sample data in half (50% of the sample data is + below/above the median). + + \see setMedianPen +*/ +void QCPStatisticalBox::setMedian(double value) +{ + mMedian = value; +} + +/*! + Sets the parameter "upper Quartile" of the statistical box plot. This is the upper end of the + box. The lower and the upper quartiles are the two statistical quartiles around the median of the + sample, they contain 50% of the sample data. + + \see setLowerQuartile, setPen, setBrush, setWidth +*/ +void QCPStatisticalBox::setUpperQuartile(double value) +{ + mUpperQuartile = value; +} + +/*! + Sets the parameter "maximum" of the statistical box plot. This is the position of the upper + whisker, typically the maximum measurement of the sample that's not considered an outlier. + + \see setMinimum, setWhiskerPen, setWhiskerBarPen, setWhiskerWidth +*/ +void QCPStatisticalBox::setMaximum(double value) +{ + mMaximum = value; +} + +/*! + Sets a vector of outlier values that will be drawn as scatters. Any data points in the sample + that are not within the whiskers (\ref setMinimum, \ref setMaximum) should be considered outliers + and displayed as such. + + \see setOutlierStyle +*/ +void QCPStatisticalBox::setOutliers(const QVector &values) +{ + mOutliers = values; +} + +/*! + Sets all parameters of the statistical box plot at once. + + \see setKey, setMinimum, setLowerQuartile, setMedian, setUpperQuartile, setMaximum +*/ +void QCPStatisticalBox::setData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum) +{ + setKey(key); + setMinimum(minimum); + setLowerQuartile(lowerQuartile); + setMedian(median); + setUpperQuartile(upperQuartile); + setMaximum(maximum); +} + +/*! + Sets the width of the box in key coordinates. + + \see setWhiskerWidth +*/ +void QCPStatisticalBox::setWidth(double width) +{ + mWidth = width; +} + +/*! + Sets the width of the whiskers (\ref setMinimum, \ref setMaximum) in key coordinates. + + \see setWidth +*/ +void QCPStatisticalBox::setWhiskerWidth(double width) +{ + mWhiskerWidth = width; +} + +/*! + Sets the pen used for drawing the whisker backbone (That's the line parallel to the value axis). + + Make sure to set the \a pen capStyle to Qt::FlatCap to prevent the whisker backbone from reaching + a few pixels past the whisker bars, when using a non-zero pen width. + + \see setWhiskerBarPen +*/ +void QCPStatisticalBox::setWhiskerPen(const QPen &pen) +{ + mWhiskerPen = pen; +} + +/*! + Sets the pen used for drawing the whisker bars (Those are the lines parallel to the key axis at + each end of the whisker backbone). + + \see setWhiskerPen +*/ +void QCPStatisticalBox::setWhiskerBarPen(const QPen &pen) +{ + mWhiskerBarPen = pen; +} + +/*! + Sets the pen used for drawing the median indicator line inside the statistical box. +*/ +void QCPStatisticalBox::setMedianPen(const QPen &pen) +{ + mMedianPen = pen; +} + +/*! + Sets the appearance of the outlier data points. + + \see setOutliers +*/ +void QCPStatisticalBox::setOutlierStyle(const QCPScatterStyle &style) +{ + mOutlierStyle = style; +} + +/* inherits documentation from base class */ +void QCPStatisticalBox::clearData() +{ + setOutliers(QVector()); + setKey(0); + setMinimum(0); + setLowerQuartile(0); + setMedian(0); + setUpperQuartile(0); + setMaximum(0); +} + +/* inherits documentation from base class */ +double QCPStatisticalBox::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) + { + double posKey, posValue; + pixelsToCoords(pos, posKey, posValue); + // quartile box: + QCPRange keyRange(mKey-mWidth*0.5, mKey+mWidth*0.5); + QCPRange valueRange(mLowerQuartile, mUpperQuartile); + if (keyRange.contains(posKey) && valueRange.contains(posValue)) + return mParentPlot->selectionTolerance()*0.99; + + // min/max whiskers: + if (QCPRange(mMinimum, mMaximum).contains(posValue)) + return qAbs(mKeyAxis.data()->coordToPixel(mKey)-mKeyAxis.data()->coordToPixel(posKey)); + } + return -1; +} + +/* inherits documentation from base class */ +void QCPStatisticalBox::draw(QCPPainter *painter) +{ + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + // check data validity if flag set: +#ifdef QCUSTOMPLOT_CHECK_DATA + if (QCP::isInvalidData(mKey, mMedian) || + QCP::isInvalidData(mLowerQuartile, mUpperQuartile) || + QCP::isInvalidData(mMinimum, mMaximum)) + qDebug() << Q_FUNC_INFO << "Data point at" << mKey << "of drawn range has invalid data." << "Plottable name:" << name(); + for (int i=0; isave(); + painter->setClipRect(quartileBox, Qt::IntersectClip); + drawMedian(painter); + painter->restore(); + + drawWhiskers(painter); + drawOutliers(painter); +} + +/* inherits documentation from base class */ +void QCPStatisticalBox::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +{ + // draw filled rect: + applyDefaultAntialiasingHint(painter); + painter->setPen(mPen); + painter->setBrush(mBrush); + QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67); + r.moveCenter(rect.center()); + painter->drawRect(r); +} + +/*! \internal + + Draws the quartile box. \a box is an output parameter that returns the quartile box (in pixel + coordinates) which is used to set the clip rect of the painter before calling \ref drawMedian (so + the median doesn't draw outside the quartile box). +*/ +void QCPStatisticalBox::drawQuartileBox(QCPPainter *painter, QRectF *quartileBox) const +{ + QRectF box; + box.setTopLeft(coordsToPixels(mKey-mWidth*0.5, mUpperQuartile)); + box.setBottomRight(coordsToPixels(mKey+mWidth*0.5, mLowerQuartile)); + applyDefaultAntialiasingHint(painter); + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); + painter->drawRect(box); + if (quartileBox) + *quartileBox = box; +} + +/*! \internal + + Draws the median line inside the quartile box. +*/ +void QCPStatisticalBox::drawMedian(QCPPainter *painter) const +{ + QLineF medianLine; + medianLine.setP1(coordsToPixels(mKey-mWidth*0.5, mMedian)); + medianLine.setP2(coordsToPixels(mKey+mWidth*0.5, mMedian)); + applyDefaultAntialiasingHint(painter); + painter->setPen(mMedianPen); + painter->drawLine(medianLine); +} + +/*! \internal + + Draws both whisker backbones and bars. +*/ +void QCPStatisticalBox::drawWhiskers(QCPPainter *painter) const +{ + QLineF backboneMin, backboneMax, barMin, barMax; + backboneMax.setPoints(coordsToPixels(mKey, mUpperQuartile), coordsToPixels(mKey, mMaximum)); + backboneMin.setPoints(coordsToPixels(mKey, mLowerQuartile), coordsToPixels(mKey, mMinimum)); + barMax.setPoints(coordsToPixels(mKey-mWhiskerWidth*0.5, mMaximum), coordsToPixels(mKey+mWhiskerWidth*0.5, mMaximum)); + barMin.setPoints(coordsToPixels(mKey-mWhiskerWidth*0.5, mMinimum), coordsToPixels(mKey+mWhiskerWidth*0.5, mMinimum)); + applyErrorBarsAntialiasingHint(painter); + painter->setPen(mWhiskerPen); + painter->drawLine(backboneMin); + painter->drawLine(backboneMax); + painter->setPen(mWhiskerBarPen); + painter->drawLine(barMin); + painter->drawLine(barMax); +} + +/*! \internal + + Draws the outlier scatter points. +*/ +void QCPStatisticalBox::drawOutliers(QCPPainter *painter) const +{ + applyScattersAntialiasingHint(painter); + mOutlierStyle.applyTo(painter, mPen); + for (int i=0; i 0) + return QCPRange(mKey-mWidth*0.5, mKey+mWidth*0.5); + else if (mKey > 0) + return QCPRange(mKey, mKey+mWidth*0.5); + else + { + foundRange = false; + return QCPRange(); + } + } + foundRange = false; + return QCPRange(); +} + +/* inherits documentation from base class */ +QCPRange QCPStatisticalBox::getValueRange(bool &foundRange, SignDomain inSignDomain) const +{ + QVector values; // values that must be considered (i.e. all outliers and the five box-parameters) + values.reserve(mOutliers.size() + 5); + values << mMaximum << mUpperQuartile << mMedian << mLowerQuartile << mMinimum; + values << mOutliers; + // go through values and find the ones in legal range: + bool haveUpper = false; + bool haveLower = false; + double upper = 0; + double lower = 0; + for (int i=0; i 0) || + (inSignDomain == sdBoth)) + { + if (values.at(i) > upper || !haveUpper) + { + upper = values.at(i); + haveUpper = true; + } + if (values.at(i) < lower || !haveLower) + { + lower = values.at(i); + haveLower = true; + } + } + } + // return the bounds if we found some sensible values: + if (haveLower && haveUpper) + { + foundRange = true; + return QCPRange(lower, upper); + } else // might happen if all values are in other sign domain + { + foundRange = false; + return QCPRange(); + } +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPColorMapData +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPColorMapData + \brief Holds the two-dimensional data of a QCPColorMap plottable. + + This class is a data storage for \ref QCPColorMap. It holds a two-dimensional array, which \ref + QCPColorMap then displays as a 2D image in the plot, where the array values are represented by a + color, depending on the value. + + The size of the array can be controlled via \ref setSize (or \ref setKeySize, \ref setValueSize). + Which plot coordinates these cells correspond to can be configured with \ref setRange (or \ref + setKeyRange, \ref setValueRange). + + The data cells can be accessed in two ways: They can be directly addressed by an integer index + with \ref setCell. This is the fastest method. Alternatively, they can be addressed by their plot + coordinate with \ref setData. plot coordinate to cell index transformations and vice versa are + provided by the functions \ref coordToCell and \ref cellToCoord. + + This class also buffers the minimum and maximum values that are in the data set, to provide + QCPColorMap::rescaleDataRange with the necessary information quickly. Setting a cell to a value + that is greater than the current maximum increases this maximum to the new value. However, + setting the cell that currently holds the maximum value to a smaller value doesn't decrease the + maximum again, because finding the true new maximum would require going through the entire data + array, which might be time consuming. The same holds for the data minimum. This functionality is + given by \ref recalculateDataBounds, such that you can decide when it is sensible to find the + true current minimum and maximum. The method QCPColorMap::rescaleDataRange offers a convenience + parameter \a recalculateDataBounds which may be set to true to automatically call \ref + recalculateDataBounds internally. +*/ + +/* start of documentation of inline functions */ + +/*! \fn bool QCPColorMapData::isEmpty() const + + Returns whether this instance carries no data. This is equivalent to having a size where at least + one of the dimensions is 0 (see \ref setSize). +*/ + +/* end of documentation of inline functions */ + +/*! + Constructs a new QCPColorMapData instance. The instance has \a keySize cells in the key direction + and \a valueSize cells in the value direction. These cells will be displayed by the \ref QCPColorMap + at the coordinates \a keyRange and \a valueRange. + + \see setSize, setKeySize, setValueSize, setRange, setKeyRange, setValueRange +*/ +QCPColorMapData::QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange) : + mKeySize(0), + mValueSize(0), + mKeyRange(keyRange), + mValueRange(valueRange), + mIsEmpty(true), + mData(0), + mDataModified(true) +{ + setSize(keySize, valueSize); + fill(0); +} + +QCPColorMapData::~QCPColorMapData() +{ + if (mData) + delete[] mData; +} + +/*! + Constructs a new QCPColorMapData instance copying the data and range of \a other. +*/ +QCPColorMapData::QCPColorMapData(const QCPColorMapData &other) : + mKeySize(0), + mValueSize(0), + mIsEmpty(true), + mData(0), + mDataModified(true) +{ + *this = other; +} + +/*! + Overwrites this color map data instance with the data stored in \a other. +*/ +QCPColorMapData &QCPColorMapData::operator=(const QCPColorMapData &other) +{ + if (&other != this) + { + const int keySize = other.keySize(); + const int valueSize = other.valueSize(); + setSize(keySize, valueSize); + setRange(other.keyRange(), other.valueRange()); + if (!mIsEmpty) + memcpy(mData, other.mData, sizeof(mData[0])*keySize*valueSize); + mDataBounds = other.mDataBounds; + mDataModified = true; + } + return *this; +} + +/* undocumented getter */ +double QCPColorMapData::data(double key, double value) +{ + int keyCell = (key-mKeyRange.lower)/(mKeyRange.upper-mKeyRange.lower)*(mKeySize-1)+0.5; + int valueCell = (1.0-(value-mValueRange.lower)/(mValueRange.upper-mValueRange.lower))*(mValueSize-1)+0.5; + if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell < mValueSize) + return mData[valueCell*mKeySize + keyCell]; + else + return 0; +} + +/* undocumented getter */ +double QCPColorMapData::cell(int keyIndex, int valueIndex) +{ + if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize) + return mData[valueIndex*mKeySize + keyIndex]; + else + return 0; +} + +/*! + Resizes the data array to have \a keySize cells in the key dimension and \a valueSize cells in + the value dimension. + + The current data is discarded and the map cells are set to 0, unless the map had already the + requested size. + + Setting at least one of \a keySize or \a valueSize to zero frees the internal data array and \ref + isEmpty returns true. + + \see setRange, setKeySize, setValueSize +*/ +void QCPColorMapData::setSize(int keySize, int valueSize) +{ + if (keySize != mKeySize || valueSize != mValueSize) + { + mKeySize = keySize; + mValueSize = valueSize; + if (mData) + delete[] mData; + mIsEmpty = mKeySize == 0 || mValueSize == 0; + if (!mIsEmpty) + { +#ifdef __EXCEPTIONS + try { // 2D arrays get memory intensive fast. So if the allocation fails, at least output debug message +#endif + mData = new double[mKeySize*mValueSize]; +#ifdef __EXCEPTIONS + } catch (...) { mData = 0; } +#endif + if (mData) + fill(0); + else + qDebug() << Q_FUNC_INFO << "out of memory for data dimensions "<< mKeySize << "*" << mValueSize; + } else + mData = 0; + mDataModified = true; + } +} + +/*! + Resizes the data array to have \a keySize cells in the key dimension. + + The current data is discarded and the map cells are set to 0, unless the map had already the + requested size. + + Setting \a keySize to zero frees the internal data array and \ref isEmpty returns true. + + \see setKeyRange, setSize, setValueSize +*/ +void QCPColorMapData::setKeySize(int keySize) +{ + setSize(keySize, mValueSize); +} + +/*! + Resizes the data array to have \a valueSize cells in the value dimension. + + The current data is discarded and the map cells are set to 0, unless the map had already the + requested size. + + Setting \a valueSize to zero frees the internal data array and \ref isEmpty returns true. + + \see setValueRange, setSize, setKeySize +*/ +void QCPColorMapData::setValueSize(int valueSize) +{ + setSize(mKeySize, valueSize); +} + +/*! + Sets the coordinate ranges the data shall be distributed over. This defines the rectangular area + covered by the color map in plot coordinates. + + The outer cells will be centered on the range boundaries given to this function. For example, if + the key size (\ref setKeySize) is 3 and \a keyRange is set to QCPRange(2, 3) there will + be cells centered on the key coordinates 2, 2.5 and 3. + + \see setSize +*/ +void QCPColorMapData::setRange(const QCPRange &keyRange, const QCPRange &valueRange) +{ + setKeyRange(keyRange); + setValueRange(valueRange); +} + +/*! + Sets the coordinate range the data shall be distributed over in the key dimension. Together with + the value range, This defines the rectangular area covered by the color map in plot coordinates. + + The outer cells will be centered on the range boundaries given to this function. For example, if + the key size (\ref setKeySize) is 3 and \a keyRange is set to QCPRange(2, 3) there will + be cells centered on the key coordinates 2, 2.5 and 3. + + \see setRange, setValueRange, setSize +*/ +void QCPColorMapData::setKeyRange(const QCPRange &keyRange) +{ + mKeyRange = keyRange; +} + +/*! + Sets the coordinate range the data shall be distributed over in the value dimension. Together with + the key range, This defines the rectangular area covered by the color map in plot coordinates. + + The outer cells will be centered on the range boundaries given to this function. For example, if + the value size (\ref setValueSize) is 3 and \a valueRange is set to QCPRange(2, 3) there + will be cells centered on the value coordinates 2, 2.5 and 3. + + \see setRange, setKeyRange, setSize +*/ +void QCPColorMapData::setValueRange(const QCPRange &valueRange) +{ + mValueRange = valueRange; +} + +/*! + Sets the data of the cell, which lies at the plot coordinates given by \a key and \a value, to \a + z. + + \see setCell, setRange +*/ +void QCPColorMapData::setData(double key, double value, double z) +{ + int keyCell = (key-mKeyRange.lower)/(mKeyRange.upper-mKeyRange.lower)*(mKeySize-1)+0.5; + int valueCell = (value-mValueRange.lower)/(mValueRange.upper-mValueRange.lower)*(mValueSize-1)+0.5; + if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell < mValueSize) + { + mData[valueCell*mKeySize + keyCell] = z; + if (z < mDataBounds.lower) + mDataBounds.lower = z; + if (z > mDataBounds.upper) + mDataBounds.upper = z; + mDataModified = true; + } +} + +/*! + Sets the data of the cell with indices \a keyIndex and \a valueIndex to \a z. The indices + enumerate the cells starting from zero, up to the map's size-1 in the respective dimension (see + \ref setSize). + + In the standard plot configuration (horizontal key axis and vertical value axis, both not + range-reversed), the cell with indices (0, 0) is in the bottom left corner and the cell with + indices (keySize-1, valueSize-1) is in the top right corner of the color map. + + \see setData, setSize +*/ +void QCPColorMapData::setCell(int keyIndex, int valueIndex, double z) +{ + if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex < mValueSize) + { + mData[valueIndex*mKeySize + keyIndex] = z; + if (z < mDataBounds.lower) + mDataBounds.lower = z; + if (z > mDataBounds.upper) + mDataBounds.upper = z; + mDataModified = true; + } +} + +/*! + Goes through the data and updates the buffered minimum and maximum data values. + + Calling this method is only advised if you are about to call \ref QCPColorMap::rescaleDataRange + and can not guarantee that the cells holding the maximum or minimum data haven't been overwritten + with a smaller or larger value respectively, since the buffered maximum/minimum values have been + updated the last time. Why this is the case is explained in the class description (\ref + QCPColorMapData). + + Note that the method \ref QCPColorMap::rescaleDataRange provides a parameter \a + recalculateDataBounds for convenience. Setting this to true will call this method for you, before + doing the rescale. +*/ +void QCPColorMapData::recalculateDataBounds() +{ + if (mKeySize > 0 && mValueSize > 0) + { + double minHeight = mData[0]; + double maxHeight = mData[0]; + const int dataCount = mValueSize*mKeySize; + for (int i=0; i maxHeight) + maxHeight = mData[i]; + if (mData[i] < minHeight) + minHeight = mData[i]; + } + mDataBounds.lower = minHeight; + mDataBounds.upper = maxHeight; + } +} + +/*! + Frees the internal data memory. + + This is equivalent to calling \ref setSize "setSize(0, 0)". +*/ +void QCPColorMapData::clear() +{ + setSize(0, 0); +} + +/*! + Sets all cells to the value \a z. +*/ +void QCPColorMapData::fill(double z) +{ + const int dataCount = mValueSize*mKeySize; + for (int i=0; ixAxis, customPlot->yAxis);\endcode + add it to the customPlot with QCustomPlot::addPlottable: + \code + customPlot->addPlottable(colorMap);\endcode + and then modify the properties of the newly created color map, e.g.: + \code + colorMap->data()->setSize(50, 50); + colorMap->data()->setRange(QCPRange(0, 2), QCPRange(0, 2)); + for (int x=0; x<50; ++x) + for (int y=0; y<50; ++y) + colorMap->data()->setCell(x, y, qCos(x/10.0)+qSin(y/10.0)); + colorMap->setGradient(QCPColorGradient::gpPolar); + colorMap->rescaleDataRange(true); + customPlot->rescaleAxes(); + customPlot->replot(); + \endcode + + \note The QCPColorMap always displays the data at equal key/value intervals, even if the key or + value axis is set to a logarithmic scaling. If you want to use QCPColorMap with logarithmic axes, + you shouldn't use the \ref QCPColorMapData::setData method as it uses a linear transformation to + determine the cell index. Rather directly access the cell index with \ref + QCPColorMapData::setCell. +*/ + +/* start documentation of inline functions */ + +/*! \fn QCPColorMapData *QCPColorMap::data() const + + Returns a pointer to the internal data storage of type \ref QCPColorMapData. Access this to + modify data points (cells) and the color map key/value range. + + \see setData +*/ + +/* end documentation of inline functions */ + +/* start documentation of signals */ + +/*! \fn void QCPColorMap::dataRangeChanged(QCPRange newRange); + + This signal is emitted when the data range changes. + + \see setDataRange +*/ + +/*! \fn void QCPColorMap::dataScaleTypeChanged(QCPAxis::ScaleType scaleType); + + This signal is emitted when the data scale type changes. + + \see setDataScaleType +*/ + +/*! \fn void QCPColorMap::gradientChanged(QCPColorGradient newGradient); + + This signal is emitted when the gradient changes. + + \see setGradient +*/ + +/* end documentation of signals */ + +/*! + Constructs a color map with the specified \a keyAxis and \a valueAxis. + + The constructed QCPColorMap can be added to the plot with QCustomPlot::addPlottable, QCustomPlot + then takes ownership of the color map. +*/ +QCPColorMap::QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis), + mDataScaleType(QCPAxis::stLinear), + mMapData(new QCPColorMapData(10, 10, QCPRange(0, 5), QCPRange(0, 5))), + mInterpolate(true), + mTightBoundary(false), + mMapImageInvalidated(true) +{ +} + +QCPColorMap::~QCPColorMap() +{ + delete mMapData; +} + +/*! + Replaces the current \ref data with the provided \a data. + + If \a copy is set to true, the \a data object will only be copied. if false, the color map + takes ownership of the passed data and replaces the internal data pointer with it. This is + significantly faster than copying for large datasets. +*/ +void QCPColorMap::setData(QCPColorMapData *data, bool copy) +{ + if (copy) + { + *mMapData = *data; + } else + { + delete mMapData; + mMapData = data; + } + mMapImageInvalidated = true; +} + +/*! + Sets the data range of this color map to \a dataRange. The data range defines which data values + are mapped to the color gradient. + + To make the data range span the full range of the data set, use \ref rescaleDataRange. + + \see QCPColorScale::setDataRange +*/ +void QCPColorMap::setDataRange(const QCPRange &dataRange) +{ + if (!QCPRange::validRange(dataRange)) return; + if (mDataRange.lower != dataRange.lower || mDataRange.upper != dataRange.upper) + { + if (mDataScaleType == QCPAxis::stLogarithmic) + mDataRange = dataRange.sanitizedForLogScale(); + else + mDataRange = dataRange.sanitizedForLinScale(); + mMapImageInvalidated = true; + emit dataRangeChanged(mDataRange); + } +} + +/*! + Sets whether the data is correlated with the color gradient linearly or logarithmically. + + \see QCPColorScale::setDataScaleType +*/ +void QCPColorMap::setDataScaleType(QCPAxis::ScaleType scaleType) +{ + if (mDataScaleType != scaleType) + { + mDataScaleType = scaleType; + mMapImageInvalidated = true; + emit dataScaleTypeChanged(mDataScaleType); + if (mDataScaleType == QCPAxis::stLogarithmic) + setDataRange(mDataRange.sanitizedForLogScale()); + } +} + +/*! + Sets the color gradient that is used to represent the data. For more details on how to create an + own gradient or use one of the preset gradients, see \ref QCPColorGradient. + + The colors defined by the gradient will be used to represent data values in the currently set + data range, see \ref setDataRange. Data points that are outside this data range will either be + colored uniformly with the respective gradient boundary color, or the gradient will repeat, + depending on \ref QCPColorGradient::setPeriodic. + + \see QCPColorScale::setGradient +*/ +void QCPColorMap::setGradient(const QCPColorGradient &gradient) +{ + if (mGradient != gradient) + { + mGradient = gradient; + mMapImageInvalidated = true; + emit gradientChanged(mGradient); + } +} + +/*! + Sets whether the color map image shall use bicubic interpolation when displaying the color map + shrinked or expanded, and not at a 1:1 pixel-to-data scale. + + \image html QCPColorMap-interpolate.png "A 10*10 color map, with interpolation and without interpolation enabled" +*/ +void QCPColorMap::setInterpolate(bool enabled) +{ + mInterpolate = enabled; +} + +/*! + Sets whether the outer most data rows and columns are clipped to the specified key and value + range (see \ref QCPColorMapData::setKeyRange, \ref QCPColorMapData::setValueRange). + + if \a enabled is set to false, the data points at the border of the color map are drawn with the + same width and height as all other data points. Since the data points are represented by + rectangles of one color centered on the data coordinate, this means that the shown color map + extends by half a data point over the specified key/value range in each direction. + + \image html QCPColorMap-tightboundary.png "A color map, with tight boundary enabled and disabled" +*/ +void QCPColorMap::setTightBoundary(bool enabled) +{ + mTightBoundary = enabled; +} + +/*! + Associates the color scale \a colorScale with this color map. + + This means that both the color scale and the color map synchronize their gradient, data range and + data scale type (\ref setGradient, \ref setDataRange, \ref setDataScaleType). Multiple color maps + can be associated with one single color scale. This causes the color maps to also synchronize + those properties, via the mutual color scale. + + This function causes the color map to adopt the current color gradient, data range and data scale + type of \a colorScale. After this call, you may change these properties at either the color map + or the color scale, and the setting will be applied to both. + + Pass 0 as \a colorScale to disconnect the color scale from this color map again. +*/ +void QCPColorMap::setColorScale(QCPColorScale *colorScale) +{ + if (mColorScale) // unconnect signals from old color scale + { + disconnect(this, SIGNAL(dataRangeChanged(QCPRange)), mColorScale.data(), SLOT(setDataRange(QCPRange))); + disconnect(this, SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), mColorScale.data(), SLOT(setDataScaleType(QCPAxis::ScaleType))); + disconnect(this, SIGNAL(gradientChanged(QCPColorGradient)), mColorScale.data(), SLOT(setGradient(QCPColorGradient))); + disconnect(mColorScale.data(), SIGNAL(dataRangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + disconnect(mColorScale.data(), SIGNAL(gradientChanged(QCPColorGradient)), this, SLOT(setGradient(QCPColorGradient))); + disconnect(mColorScale.data(), SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); + } + mColorScale = colorScale; + if (mColorScale) // connect signals to new color scale + { + setGradient(mColorScale.data()->gradient()); + setDataRange(mColorScale.data()->dataRange()); + setDataScaleType(mColorScale.data()->dataScaleType()); + connect(this, SIGNAL(dataRangeChanged(QCPRange)), mColorScale.data(), SLOT(setDataRange(QCPRange))); + connect(this, SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), mColorScale.data(), SLOT(setDataScaleType(QCPAxis::ScaleType))); + connect(this, SIGNAL(gradientChanged(QCPColorGradient)), mColorScale.data(), SLOT(setGradient(QCPColorGradient))); + connect(mColorScale.data(), SIGNAL(dataRangeChanged(QCPRange)), this, SLOT(setDataRange(QCPRange))); + connect(mColorScale.data(), SIGNAL(gradientChanged(QCPColorGradient)), this, SLOT(setGradient(QCPColorGradient))); + connect(mColorScale.data(), SIGNAL(dataScaleTypeChanged(QCPAxis::ScaleType)), this, SLOT(setDataScaleType(QCPAxis::ScaleType))); + } +} + +/*! + Sets the data range (\ref setDataRange) to span the minimum and maximum values that occur in the + current data set. This corresponds to the \ref rescaleKeyAxis or \ref rescaleValueAxis methods, + only for the third data dimension of the color map. + + The minimum and maximum values of the data set are buffered in the internal QCPColorMapData + instance (\ref data). As data is updated via its \ref QCPColorMapData::setCell or \ref + QCPColorMapData::setData, the buffered minimum and maximum values are updated, too. For + performance reasons, however, they are only updated in an expanding fashion. So the buffered + maximum can only increase and the buffered minimum can only decrease. In consequence, changes to + the data that actually lower the maximum of the data set (by overwriting the cell holding the + current maximum with a smaller value), aren't recognized and the buffered maximum overestimates + the true maximum of the data set. The same happens for the buffered minimum. To recalculate the + true minimum and maximum by explicitly looking at each cell, the method + QCPColorMapData::recalculateDataBounds can be used. For convenience, setting the parameter \a + recalculateDataBounds calls this method before setting the data range to the buffered minimum and + maximum. + + \see setDataRange +*/ +void QCPColorMap::rescaleDataRange(bool recalculateDataBounds) +{ + if (recalculateDataBounds) + mMapData->recalculateDataBounds(); + setDataRange(mMapData->dataBounds()); +} + +/*! + Takes the current appearance of the color map and updates the legend icon, which is used to + represent this color map in the legend (see \ref QCPLegend). + + The \a transformMode specifies whether the rescaling is done by a faster, low quality image + scaling algorithm (Qt::FastTransformation) or by a slower, higher quality algorithm + (Qt::SmoothTransformation). + + The current color map appearance is scaled down to \a thumbSize. Ideally, this should be equal to + the size of the legend icon (see \ref QCPLegend::setIconSize). If it isn't exactly the configured + legend icon size, the thumb will be rescaled during drawing of the legend item. + + \see setDataRange +*/ +void QCPColorMap::updateLegendIcon(Qt::TransformationMode transformMode, const QSize &thumbSize) +{ + if (mMapImage.isNull() && !data()->isEmpty()) + updateMapImage(); // try to update map image if it's null (happens if no draw has happened yet) + + if (!mMapImage.isNull()) // might still be null, e.g. if data is empty, so check here again + { + bool mirrorX = (keyAxis()->orientation() == Qt::Horizontal ? keyAxis() : valueAxis())->rangeReversed(); + bool mirrorY = (valueAxis()->orientation() == Qt::Vertical ? valueAxis() : keyAxis())->rangeReversed(); + mLegendIcon = QPixmap::fromImage(mMapImage.mirrored(mirrorX, mirrorY)).scaled(thumbSize, Qt::KeepAspectRatio, transformMode); + } +} + +/*! + Clears the colormap data by calling \ref QCPColorMapData::clear() on the internal data. This also + resizes the map to 0x0 cells. +*/ +void QCPColorMap::clearData() +{ + mMapData->clear(); +} + +/* inherits documentation from base class */ +double QCPColorMap::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) + { + double posKey, posValue; + pixelsToCoords(pos, posKey, posValue); + if (mMapData->keyRange().contains(posKey) && mMapData->valueRange().contains(posValue)) + return mParentPlot->selectionTolerance()*0.99; + } + return -1; +} + +/*! \internal + + Updates the internal map image buffer by going through the internal \ref QCPColorMapData and + turning the data values into color pixels with \ref QCPColorGradient::colorize. + + This method is called by \ref QCPColorMap::draw if either the data has been modified or the map image + has been invalidated for a different reason (e.g. a change of the data range with \ref + setDataRange). +*/ +void QCPColorMap::updateMapImage() +{ + QCPAxis *keyAxis = mKeyAxis.data(); + if (!keyAxis) return; + + // resize mMapImage to correct dimensions, according to key/value axes orientation: + if (keyAxis->orientation() == Qt::Horizontal && (mMapImage.size().width() != mMapData->keySize() || mMapImage.size().height() != mMapData->valueSize())) + mMapImage = QImage(QSize(mMapData->keySize(), mMapData->valueSize()), QImage::Format_RGB32); + else if (keyAxis->orientation() == Qt::Vertical && (mMapImage.size().width() != mMapData->valueSize() || mMapImage.size().height() != mMapData->keySize())) + mMapImage = QImage(QSize(mMapData->valueSize(), mMapData->keySize()), QImage::Format_RGB32); + + const int keySize = mMapData->keySize(); + const int valueSize = mMapData->valueSize(); + const double *rawData = mMapData->mData; + + if (keyAxis->orientation() == Qt::Horizontal) + { + const int lineCount = valueSize; + const int rowCount = keySize; + for (int line=0; line(mMapImage.scanLine(lineCount-1-line)); // invert scanline index because QImage counts scanlines from top, but our vertical index counts from bottom (mathematical coordinate system) + mGradient.colorize(rawData+line*rowCount, mDataRange, pixels, rowCount, 1, mDataScaleType==QCPAxis::stLogarithmic); + } + } else // keyAxis->orientation() == Qt::Vertical + { + const int lineCount = keySize; + const int rowCount = valueSize; + for (int line=0; line(mMapImage.scanLine(lineCount-1-line)); // invert scanline index because QImage counts scanlines from top, but our vertical index counts from bottom (mathematical coordinate system) + mGradient.colorize(rawData+line, mDataRange, pixels, rowCount, lineCount, mDataScaleType==QCPAxis::stLogarithmic); + } + } + + mMapData->mDataModified = false; + mMapImageInvalidated = false; +} + +/* inherits documentation from base class */ +void QCPColorMap::draw(QCPPainter *painter) +{ + if (mMapData->isEmpty()) return; + if (!mKeyAxis || !mValueAxis) return; + applyDefaultAntialiasingHint(painter); + + if (mMapData->mDataModified || mMapImageInvalidated) + updateMapImage(); + + double halfSampleKey = 0; + double halfSampleValue = 0; + if (mMapData->keySize() > 1) + halfSampleKey = 0.5*mMapData->keyRange().size()/(double)(mMapData->keySize()-1); + if (mMapData->valueSize() > 1) + halfSampleValue = 0.5*mMapData->valueRange().size()/(double)(mMapData->valueSize()-1); + QRectF imageRect(coordsToPixels(mMapData->keyRange().lower-halfSampleKey, mMapData->valueRange().lower-halfSampleValue), + coordsToPixels(mMapData->keyRange().upper+halfSampleKey, mMapData->valueRange().upper+halfSampleValue)); + imageRect = imageRect.normalized(); + bool mirrorX = (keyAxis()->orientation() == Qt::Horizontal ? keyAxis() : valueAxis())->rangeReversed(); + bool mirrorY = (valueAxis()->orientation() == Qt::Vertical ? valueAxis() : keyAxis())->rangeReversed(); + bool smoothBackup = painter->renderHints().testFlag(QPainter::SmoothPixmapTransform); + painter->setRenderHint(QPainter::SmoothPixmapTransform, mInterpolate); + QRegion clipBackup; + if (mTightBoundary) + { + clipBackup = painter->clipRegion(); + painter->setClipRect(QRectF(coordsToPixels(mMapData->keyRange().lower, mMapData->valueRange().lower), + coordsToPixels(mMapData->keyRange().upper, mMapData->valueRange().upper)).normalized(), Qt::IntersectClip); + } + painter->drawImage(imageRect, mMapImage.mirrored(mirrorX, mirrorY)); + if (mTightBoundary) + painter->setClipRegion(clipBackup); + painter->setRenderHint(QPainter::SmoothPixmapTransform, smoothBackup); +} + +/* inherits documentation from base class */ +void QCPColorMap::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +{ + applyDefaultAntialiasingHint(painter); + // draw map thumbnail: + if (!mLegendIcon.isNull()) + { + QPixmap scaledIcon = mLegendIcon.scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::FastTransformation); + QRectF iconRect = QRectF(0, 0, scaledIcon.width(), scaledIcon.height()); + iconRect.moveCenter(rect.center()); + painter->drawPixmap(iconRect.topLeft(), scaledIcon); + } + /* + // draw frame: + painter->setBrush(Qt::NoBrush); + painter->setPen(Qt::black); + painter->drawRect(rect.adjusted(1, 1, 0, 0)); + */ +} + +/* inherits documentation from base class */ +QCPRange QCPColorMap::getKeyRange(bool &foundRange, SignDomain inSignDomain) const +{ + foundRange = true; + QCPRange result = mMapData->keyRange(); + result.normalize(); + if (inSignDomain == QCPAbstractPlottable::sdPositive) + { + if (result.lower <= 0 && result.upper > 0) + result.lower = result.upper*1e-3; + else if (result.lower <= 0 && result.upper <= 0) + foundRange = false; + } else if (inSignDomain == QCPAbstractPlottable::sdNegative) + { + if (result.upper >= 0 && result.lower < 0) + result.upper = result.lower*1e-3; + else if (result.upper >= 0 && result.lower >= 0) + foundRange = false; + } + return result; +} + +/* inherits documentation from base class */ +QCPRange QCPColorMap::getValueRange(bool &foundRange, SignDomain inSignDomain) const +{ + foundRange = true; + QCPRange result = mMapData->valueRange(); + result.normalize(); + if (inSignDomain == QCPAbstractPlottable::sdPositive) + { + if (result.lower <= 0 && result.upper > 0) + result.lower = result.upper*1e-3; + else if (result.lower <= 0 && result.upper <= 0) + foundRange = false; + } else if (inSignDomain == QCPAbstractPlottable::sdNegative) + { + if (result.upper >= 0 && result.lower < 0) + result.upper = result.lower*1e-3; + else if (result.upper >= 0 && result.lower >= 0) + foundRange = false; + } + return result; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPFinancialData +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPFinancialData + \brief Holds the data of one single data point for QCPFinancial. + + The container for storing multiple data points is \ref QCPFinancialDataMap. + + The stored data is: + \li \a key: coordinate on the key axis of this data point + \li \a open: The opening value at the data point + \li \a high: The high/maximum value at the data point + \li \a low: The low/minimum value at the data point + \li \a close: The closing value at the data point + + \see QCPFinancialDataMap +*/ + +/*! + Constructs a data point with key and all values set to zero. +*/ +QCPFinancialData::QCPFinancialData() : + key(0), + open(0), + high(0), + low(0), + close(0) +{ +} + +/*! + Constructs a data point with the specified \a key and OHLC values. +*/ +QCPFinancialData::QCPFinancialData(double key, double open, double high, double low, double close) : + key(key), + open(open), + high(high), + low(low), + close(close) +{ +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPFinancial +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPFinancial + \brief A plottable representing a financial stock chart + + \image html QCPFinancial.png + + This plottable represents time series data binned to certain intervals, mainly used for stock + charts. The two common representations OHLC (Open-High-Low-Close) bars and Candlesticks can be + set via \ref setChartStyle. + + The data is passed via \ref setData as a set of open/high/low/close values at certain keys + (typically times). This means the data must be already binned appropriately. If data is only + available as a series of values (e.g. \a price against \a time), you can use the static + convenience function \ref timeSeriesToOhlc to generate binned OHLC-data which can then be passed + to \ref setData. + + The width of the OHLC bars/candlesticks can be controlled with \ref setWidth and is given in plot + key coordinates. A typical choice is to set it to (or slightly less than) one bin interval width. + + \section appearance Changing the appearance + + Charts can be either single- or two-colored (\ref setTwoColored). If set to be single-colored, + lines are drawn with the plottable's pen (\ref setPen) and fills with the brush (\ref setBrush). + + If set to two-colored, positive changes of the value during an interval (\a close >= \a open) are + represented with a different pen and brush than negative changes (\a close < \a open). These can + be configured with \ref setPenPositive, \ref setPenNegative, \ref setBrushPositive, and \ref + setBrushNegative. In two-colored mode, the normal plottable pen/brush is ignored. Upon selection + however, the normal selected pen/brush (\ref setSelectedPen, \ref setSelectedBrush) is used, + irrespective of whether the chart is single- or two-colored. + +*/ + +/* start of documentation of inline functions */ + +/*! \fn QCPFinancialDataMap *QCPFinancial::data() const + + Returns a pointer to the internal data storage of type \ref QCPFinancialDataMap. You may use it to + directly manipulate the data, which may be more convenient and faster than using the regular \ref + setData or \ref addData methods, in certain situations. +*/ + +/* end of documentation of inline functions */ + +/*! + Constructs a financial chart which uses \a keyAxis as its key axis ("x") and \a valueAxis as its value + axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and not have + the same orientation. If either of these restrictions is violated, a corresponding message is + printed to the debug output (qDebug), the construction is not aborted, though. + + The constructed QCPFinancial can be added to the plot with QCustomPlot::addPlottable, QCustomPlot + then takes ownership of the financial chart. +*/ +QCPFinancial::QCPFinancial(QCPAxis *keyAxis, QCPAxis *valueAxis) : + QCPAbstractPlottable(keyAxis, valueAxis), + mData(0), + mChartStyle(csOhlc), + mWidth(0.5), + mTwoColored(false), + mBrushPositive(QBrush(QColor(210, 210, 255))), + mBrushNegative(QBrush(QColor(255, 210, 210))), + mPenPositive(QPen(QColor(10, 40, 180))), + mPenNegative(QPen(QColor(180, 40, 10))) +{ + mData = new QCPFinancialDataMap; + + setSelectedPen(QPen(QColor(80, 80, 255), 2.5)); + setSelectedBrush(QBrush(QColor(80, 80, 255))); +} + +QCPFinancial::~QCPFinancial() +{ + delete mData; +} + +/*! + Replaces the current data with the provided \a data. + + If \a copy is set to true, data points in \a data will only be copied. if false, the plottable + takes ownership of the passed data and replaces the internal data pointer with it. This is + significantly faster than copying for large datasets. + + Alternatively, you can also access and modify the plottable's data via the \ref data method, which + returns a pointer to the internal \ref QCPFinancialDataMap. + + \see timeSeriesToOhlc +*/ +void QCPFinancial::setData(QCPFinancialDataMap *data, bool copy) +{ + if (copy) + { + *mData = *data; + } else + { + delete mData; + mData = data; + } +} + +/*! \overload + + Replaces the current data with the provided open/high/low/close data. The provided vectors should + have equal length. Else, the number of added points will be the size of the smallest vector. + + \see timeSeriesToOhlc +*/ +void QCPFinancial::setData(const QVector &key, const QVector &open, const QVector &high, const QVector &low, const QVector &close) +{ + mData->clear(); + int n = key.size(); + n = qMin(n, open.size()); + n = qMin(n, high.size()); + n = qMin(n, low.size()); + n = qMin(n, close.size()); + for (int i=0; iinsertMulti(key[i], QCPFinancialData(key[i], open[i], high[i], low[i], close[i])); + } +} + +/*! + Sets which representation style shall be used to display the OHLC data. +*/ +void QCPFinancial::setChartStyle(QCPFinancial::ChartStyle style) +{ + mChartStyle = style; +} + +/*! + Sets the width of the individual bars/candlesticks to \a width in plot key coordinates. + + A typical choice is to set it to (or slightly less than) one bin interval width. +*/ +void QCPFinancial::setWidth(double width) +{ + mWidth = width; +} + +/*! + Sets whether this chart shall contrast positive from negative trends per data point by using two + separate colors to draw the respective bars/candlesticks. + + If \a twoColored is false, the normal plottable's pen and brush are used (\ref setPen, \ref + setBrush). + + \see setPenPositive, setPenNegative, setBrushPositive, setBrushNegative +*/ +void QCPFinancial::setTwoColored(bool twoColored) +{ + mTwoColored = twoColored; +} + +/*! + If \ref setTwoColored is set to true, this function controls the brush that is used to draw fills + of data points with a positive trend (i.e. bars/candlesticks with close >= open). + + If \a twoColored is false, the normal plottable's pen and brush are used (\ref setPen, \ref + setBrush). + + \see setBrushNegative, setPenPositive, setPenNegative +*/ +void QCPFinancial::setBrushPositive(const QBrush &brush) +{ + mBrushPositive = brush; +} + +/*! + If \ref setTwoColored is set to true, this function controls the brush that is used to draw fills + of data points with a negative trend (i.e. bars/candlesticks with close < open). + + If \a twoColored is false, the normal plottable's pen and brush are used (\ref setPen, \ref + setBrush). + + \see setBrushPositive, setPenNegative, setPenPositive +*/ +void QCPFinancial::setBrushNegative(const QBrush &brush) +{ + mBrushNegative = brush; +} + +/*! + If \ref setTwoColored is set to true, this function controls the pen that is used to draw + outlines of data points with a positive trend (i.e. bars/candlesticks with close >= open). + + If \a twoColored is false, the normal plottable's pen and brush are used (\ref setPen, \ref + setBrush). + + \see setPenNegative, setBrushPositive, setBrushNegative +*/ +void QCPFinancial::setPenPositive(const QPen &pen) +{ + mPenPositive = pen; +} + +/*! + If \ref setTwoColored is set to true, this function controls the pen that is used to draw + outlines of data points with a negative trend (i.e. bars/candlesticks with close < open). + + If \a twoColored is false, the normal plottable's pen and brush are used (\ref setPen, \ref + setBrush). + + \see setPenPositive, setBrushNegative, setBrushPositive +*/ +void QCPFinancial::setPenNegative(const QPen &pen) +{ + mPenNegative = pen; +} + +/*! + Adds the provided data points in \a dataMap to the current data. + + Alternatively, you can also access and modify the data via the \ref data method, which returns a + pointer to the internal \ref QCPFinancialDataMap. + + \see removeData +*/ +void QCPFinancial::addData(const QCPFinancialDataMap &dataMap) +{ + mData->unite(dataMap); +} + +/*! \overload + + Adds the provided single data point in \a data to the current data. + + Alternatively, you can also access and modify the data via the \ref data method, which returns a + pointer to the internal \ref QCPFinancialData. + + \see removeData +*/ +void QCPFinancial::addData(const QCPFinancialData &data) +{ + mData->insertMulti(data.key, data); +} + +/*! \overload + + Adds the provided single data point given by \a key, \a open, \a high, \a low, and \a close to + the current data. + + Alternatively, you can also access and modify the data via the \ref data method, which returns a + pointer to the internal \ref QCPFinancialData. + + \see removeData +*/ +void QCPFinancial::addData(double key, double open, double high, double low, double close) +{ + mData->insertMulti(key, QCPFinancialData(key, open, high, low, close)); +} + +/*! \overload + + Adds the provided open/high/low/close data to the current data. + + Alternatively, you can also access and modify the data via the \ref data method, which returns a + pointer to the internal \ref QCPFinancialData. + + \see removeData +*/ +void QCPFinancial::addData(const QVector &key, const QVector &open, const QVector &high, const QVector &low, const QVector &close) +{ + int n = key.size(); + n = qMin(n, open.size()); + n = qMin(n, high.size()); + n = qMin(n, low.size()); + n = qMin(n, close.size()); + for (int i=0; iinsertMulti(key[i], QCPFinancialData(key[i], open[i], high[i], low[i], close[i])); + } +} + +/*! + Removes all data points with keys smaller than \a key. + + \see addData, clearData +*/ +void QCPFinancial::removeDataBefore(double key) +{ + QCPFinancialDataMap::iterator it = mData->begin(); + while (it != mData->end() && it.key() < key) + it = mData->erase(it); +} + +/*! + Removes all data points with keys greater than \a key. + + \see addData, clearData +*/ +void QCPFinancial::removeDataAfter(double key) +{ + if (mData->isEmpty()) return; + QCPFinancialDataMap::iterator it = mData->upperBound(key); + while (it != mData->end()) + it = mData->erase(it); +} + +/*! + Removes all data points with keys between \a fromKey and \a toKey. if \a fromKey is greater or + equal to \a toKey, the function does nothing. To remove a single data point with known key, use + \ref removeData(double key). + + \see addData, clearData +*/ +void QCPFinancial::removeData(double fromKey, double toKey) +{ + if (fromKey >= toKey || mData->isEmpty()) return; + QCPFinancialDataMap::iterator it = mData->upperBound(fromKey); + QCPFinancialDataMap::iterator itEnd = mData->upperBound(toKey); + while (it != itEnd) + it = mData->erase(it); +} + +/*! \overload + + Removes a single data point at \a key. If the position is not known with absolute precision, + consider using \ref removeData(double fromKey, double toKey) with a small fuzziness interval + around the suspected position, depeding on the precision with which the key is known. + + \see addData, clearData +*/ +void QCPFinancial::removeData(double key) +{ + mData->remove(key); +} + +/*! + Removes all data points. + + \see removeData, removeDataAfter, removeDataBefore +*/ +void QCPFinancial::clearData() +{ + mData->clear(); +} + +/* inherits documentation from base class */ +double QCPFinancial::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + if (!mKeyAxis || !mValueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } + + if (mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint())) + { + // get visible data range: + QCPFinancialDataMap::const_iterator lower, upper; // note that upper is the actual upper point, and not 1 step after the upper point + getVisibleDataBounds(lower, upper); + if (lower == mData->constEnd() || upper == mData->constEnd()) + return -1; + // perform select test according to configured style: + switch (mChartStyle) + { + case QCPFinancial::csOhlc: + return ohlcSelectTest(pos, lower, upper+1); break; + case QCPFinancial::csCandlestick: + return candlestickSelectTest(pos, lower, upper+1); break; + } + } + return -1; +} + +/*! + A convenience function that converts time series data (\a value against \a time) to OHLC binned + data points. The return value can then be passed on to \ref setData. + + The size of the bins can be controlled with \a timeBinSize in the same units as \a time is given. + For example, if the unit of \a time is seconds and single OHLC/Candlesticks should span an hour + each, set \a timeBinSize to 3600. + + \a timeBinOffset allows to control precisely at what \a time coordinate a bin should start. The + value passed as \a timeBinOffset doesn't need to be in the range encompassed by the \a time keys. + It merely defines the mathematical offset/phase of the bins that will be used to process the + data. +*/ +QCPFinancialDataMap QCPFinancial::timeSeriesToOhlc(const QVector &time, const QVector &value, double timeBinSize, double timeBinOffset) +{ + QCPFinancialDataMap map; + int count = qMin(time.size(), value.size()); + if (count == 0) + return QCPFinancialDataMap(); + + QCPFinancialData currentBinData(0, value.first(), value.first(), value.first(), value.first()); + int currentBinIndex = qFloor((time.first()-timeBinOffset)/timeBinSize+0.5); + for (int i=0; i currentBinData.high) currentBinData.high = value.at(i); + if (i == count-1) // last data point is in current bin, finalize bin: + { + currentBinData.close = value.at(i); + currentBinData.key = timeBinOffset+(index)*timeBinSize; + map.insert(currentBinData.key, currentBinData); + } + } else // data point not anymore in current bin, set close of old and open of new bin, and add old to map: + { + // finalize current bin: + currentBinData.close = value.at(i-1); + currentBinData.key = timeBinOffset+(index-1)*timeBinSize; + map.insert(currentBinData.key, currentBinData); + // start next bin: + currentBinIndex = index; + currentBinData.open = value.at(i); + currentBinData.high = value.at(i); + currentBinData.low = value.at(i); + } + } + + return map; +} + +/* inherits documentation from base class */ +void QCPFinancial::draw(QCPPainter *painter) +{ + // get visible data range: + QCPFinancialDataMap::const_iterator lower, upper; // note that upper is the actual upper point, and not 1 step after the upper point + getVisibleDataBounds(lower, upper); + if (lower == mData->constEnd() || upper == mData->constEnd()) + return; + + // draw visible data range according to configured style: + switch (mChartStyle) + { + case QCPFinancial::csOhlc: + drawOhlcPlot(painter, lower, upper+1); break; + case QCPFinancial::csCandlestick: + drawCandlestickPlot(painter, lower, upper+1); break; + } +} + +/* inherits documentation from base class */ +void QCPFinancial::drawLegendIcon(QCPPainter *painter, const QRectF &rect) const +{ + painter->setAntialiasing(false); // legend icon especially of csCandlestick looks better without antialiasing + if (mChartStyle == csOhlc) + { + if (mTwoColored) + { + // draw upper left half icon with positive color: + painter->setBrush(mBrushPositive); + painter->setPen(mPenPositive); + painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint())); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft())); + // draw bottom right hald icon with negative color: + painter->setBrush(mBrushNegative); + painter->setPen(mPenNegative); + painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint())); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft())); + } else + { + painter->setBrush(mBrush); + painter->setPen(mPen); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft())); + } + } else if (mChartStyle == csCandlestick) + { + if (mTwoColored) + { + // draw upper left half icon with positive color: + painter->setBrush(mBrushPositive); + painter->setPen(mPenPositive); + painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint())); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft())); + // draw bottom right hald icon with negative color: + painter->setBrush(mBrushNegative); + painter->setPen(mPenNegative); + painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint())); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft())); + } else + { + painter->setBrush(mBrush); + painter->setPen(mPen); + painter->drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft())); + painter->drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft())); + painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft())); + } + } +} + +/* inherits documentation from base class */ +QCPRange QCPFinancial::getKeyRange(bool &foundRange, QCPAbstractPlottable::SignDomain inSignDomain) const +{ + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + double current; + QCPFinancialDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + current = it.value().key; + if (inSignDomain == sdBoth || (inSignDomain == sdNegative && current < 0) || (inSignDomain == sdPositive && current > 0)) + { + if (current < range.lower || !haveLower) + { + range.lower = current; + haveLower = true; + } + if (current > range.upper || !haveUpper) + { + range.upper = current; + haveUpper = true; + } + } + ++it; + } + // determine exact range by including width of bars/flags: + if (haveLower && mKeyAxis) + range.lower = range.lower-mWidth*0.5; + if (haveUpper && mKeyAxis) + range.upper = range.upper+mWidth*0.5; + foundRange = haveLower && haveUpper; + return range; +} + +/* inherits documentation from base class */ +QCPRange QCPFinancial::getValueRange(bool &foundRange, QCPAbstractPlottable::SignDomain inSignDomain) const +{ + QCPRange range; + bool haveLower = false; + bool haveUpper = false; + + QCPFinancialDataMap::const_iterator it = mData->constBegin(); + while (it != mData->constEnd()) + { + // high: + if (inSignDomain == sdBoth || (inSignDomain == sdNegative && it.value().high < 0) || (inSignDomain == sdPositive && it.value().high > 0)) + { + if (it.value().high < range.lower || !haveLower) + { + range.lower = it.value().high; + haveLower = true; + } + if (it.value().high > range.upper || !haveUpper) + { + range.upper = it.value().high; + haveUpper = true; + } + } + // low: + if (inSignDomain == sdBoth || (inSignDomain == sdNegative && it.value().low < 0) || (inSignDomain == sdPositive && it.value().low > 0)) + { + if (it.value().low < range.lower || !haveLower) + { + range.lower = it.value().low; + haveLower = true; + } + if (it.value().low > range.upper || !haveUpper) + { + range.upper = it.value().low; + haveUpper = true; + } + } + ++it; + } + + foundRange = haveLower && haveUpper; + return range; +} + +/*! \internal + + Draws the data from \a begin to \a end as OHLC bars with the provided \a painter. + + This method is a helper function for \ref draw. It is used when the chart style is \ref csOhlc. +*/ +void QCPFinancial::drawOhlcPlot(QCPPainter *painter, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end) +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + QPen linePen; + + if (keyAxis->orientation() == Qt::Horizontal) + { + for (QCPFinancialDataMap::const_iterator it = begin; it != end; ++it) + { + if (mSelected) + linePen = mSelectedPen; + else if (mTwoColored) + linePen = it.value().close >= it.value().open ? mPenPositive : mPenNegative; + else + linePen = mPen; + painter->setPen(linePen); + double keyPixel = keyAxis->coordToPixel(it.value().key); + double openPixel = valueAxis->coordToPixel(it.value().open); + double closePixel = valueAxis->coordToPixel(it.value().close); + // draw backbone: + painter->drawLine(QPointF(keyPixel, valueAxis->coordToPixel(it.value().high)), QPointF(keyPixel, valueAxis->coordToPixel(it.value().low))); + // draw open: + double keyWidthPixels = keyPixel-keyAxis->coordToPixel(it.value().key-mWidth*0.5); // sign of this makes sure open/close are on correct sides + painter->drawLine(QPointF(keyPixel-keyWidthPixels, openPixel), QPointF(keyPixel, openPixel)); + // draw close: + painter->drawLine(QPointF(keyPixel, closePixel), QPointF(keyPixel+keyWidthPixels, closePixel)); + } + } else + { + for (QCPFinancialDataMap::const_iterator it = begin; it != end; ++it) + { + if (mSelected) + linePen = mSelectedPen; + else if (mTwoColored) + linePen = it.value().close >= it.value().open ? mPenPositive : mPenNegative; + else + linePen = mPen; + painter->setPen(linePen); + double keyPixel = keyAxis->coordToPixel(it.value().key); + double openPixel = valueAxis->coordToPixel(it.value().open); + double closePixel = valueAxis->coordToPixel(it.value().close); + // draw backbone: + painter->drawLine(QPointF(valueAxis->coordToPixel(it.value().high), keyPixel), QPointF(valueAxis->coordToPixel(it.value().low), keyPixel)); + // draw open: + double keyWidthPixels = keyPixel-keyAxis->coordToPixel(it.value().key-mWidth*0.5); // sign of this makes sure open/close are on correct sides + painter->drawLine(QPointF(openPixel, keyPixel-keyWidthPixels), QPointF(openPixel, keyPixel)); + // draw close: + painter->drawLine(QPointF(closePixel, keyPixel), QPointF(closePixel, keyPixel+keyWidthPixels)); + } + } +} + +/*! \internal + + Draws the data from \a begin to \a end as Candlesticks with the provided \a painter. + + This method is a helper function for \ref draw. It is used when the chart style is \ref csCandlestick. +*/ +void QCPFinancial::drawCandlestickPlot(QCPPainter *painter, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end) +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return; } + + QPen linePen; + QBrush boxBrush; + + if (keyAxis->orientation() == Qt::Horizontal) + { + for (QCPFinancialDataMap::const_iterator it = begin; it != end; ++it) + { + if (mSelected) + { + linePen = mSelectedPen; + boxBrush = mSelectedBrush; + } else if (mTwoColored) + { + if (it.value().close >= it.value().open) + { + linePen = mPenPositive; + boxBrush = mBrushPositive; + } else + { + linePen = mPenNegative; + boxBrush = mBrushNegative; + } + } else + { + linePen = mPen; + boxBrush = mBrush; + } + painter->setPen(linePen); + painter->setBrush(boxBrush); + double keyPixel = keyAxis->coordToPixel(it.value().key); + double openPixel = valueAxis->coordToPixel(it.value().open); + double closePixel = valueAxis->coordToPixel(it.value().close); + // draw high: + painter->drawLine(QPointF(keyPixel, valueAxis->coordToPixel(it.value().high)), QPointF(keyPixel, valueAxis->coordToPixel(qMax(it.value().open, it.value().close)))); + // draw low: + painter->drawLine(QPointF(keyPixel, valueAxis->coordToPixel(it.value().low)), QPointF(keyPixel, valueAxis->coordToPixel(qMin(it.value().open, it.value().close)))); + // draw open-close box: + double keyWidthPixels = keyPixel-keyAxis->coordToPixel(it.value().key-mWidth*0.5); + painter->drawRect(QRectF(QPointF(keyPixel-keyWidthPixels, closePixel), QPointF(keyPixel+keyWidthPixels, openPixel))); + } + } else // keyAxis->orientation() == Qt::Vertical + { + for (QCPFinancialDataMap::const_iterator it = begin; it != end; ++it) + { + if (mSelected) + { + linePen = mSelectedPen; + boxBrush = mSelectedBrush; + } else if (mTwoColored) + { + if (it.value().close >= it.value().open) + { + linePen = mPenPositive; + boxBrush = mBrushPositive; + } else + { + linePen = mPenNegative; + boxBrush = mBrushNegative; + } + } else + { + linePen = mPen; + boxBrush = mBrush; + } + painter->setPen(linePen); + painter->setBrush(boxBrush); + double keyPixel = keyAxis->coordToPixel(it.value().key); + double openPixel = valueAxis->coordToPixel(it.value().open); + double closePixel = valueAxis->coordToPixel(it.value().close); + // draw high: + painter->drawLine(QPointF(valueAxis->coordToPixel(it.value().high), keyPixel), QPointF(valueAxis->coordToPixel(qMax(it.value().open, it.value().close)), keyPixel)); + // draw low: + painter->drawLine(QPointF(valueAxis->coordToPixel(it.value().low), keyPixel), QPointF(valueAxis->coordToPixel(qMin(it.value().open, it.value().close)), keyPixel)); + // draw open-close box: + double keyWidthPixels = keyPixel-keyAxis->coordToPixel(it.value().key-mWidth*0.5); + painter->drawRect(QRectF(QPointF(closePixel, keyPixel-keyWidthPixels), QPointF(openPixel, keyPixel+keyWidthPixels))); + } + } +} + +/*! \internal + + This method is a helper function for \ref selectTest. It is used to test for selection when the + chart style is \ref csOhlc. It only tests against the data points between \a begin and \a end. +*/ +double QCPFinancial::ohlcSelectTest(const QPointF &pos, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } + + double minDistSqr = std::numeric_limits::max(); + QCPFinancialDataMap::const_iterator it; + if (keyAxis->orientation() == Qt::Horizontal) + { + for (it = begin; it != end; ++it) + { + double keyPixel = keyAxis->coordToPixel(it.value().key); + // calculate distance to backbone: + double currentDistSqr = distSqrToLine(QPointF(keyPixel, valueAxis->coordToPixel(it.value().high)), QPointF(keyPixel, valueAxis->coordToPixel(it.value().low)), pos); + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + } else // keyAxis->orientation() == Qt::Vertical + { + for (it = begin; it != end; ++it) + { + double keyPixel = keyAxis->coordToPixel(it.value().key); + // calculate distance to backbone: + double currentDistSqr = distSqrToLine(QPointF(valueAxis->coordToPixel(it.value().high), keyPixel), QPointF(valueAxis->coordToPixel(it.value().low), keyPixel), pos); + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + } + return qSqrt(minDistSqr); +} + +/*! \internal + + This method is a helper function for \ref selectTest. It is used to test for selection when the + chart style is \ref csCandlestick. It only tests against the data points between \a begin and \a + end. +*/ +double QCPFinancial::candlestickSelectTest(const QPointF &pos, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end) const +{ + QCPAxis *keyAxis = mKeyAxis.data(); + QCPAxis *valueAxis = mValueAxis.data(); + if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO << "invalid key or value axis"; return -1; } + + double minDistSqr = std::numeric_limits::max(); + QCPFinancialDataMap::const_iterator it; + if (keyAxis->orientation() == Qt::Horizontal) + { + for (it = begin; it != end; ++it) + { + double currentDistSqr; + // determine whether pos is in open-close-box: + QCPRange boxKeyRange(it.value().key-mWidth*0.5, it.value().key+mWidth*0.5); + QCPRange boxValueRange(it.value().close, it.value().open); + double posKey, posValue; + pixelsToCoords(pos, posKey, posValue); + if (boxKeyRange.contains(posKey) && boxValueRange.contains(posValue)) // is in open-close-box + { + currentDistSqr = mParentPlot->selectionTolerance()*0.99 * mParentPlot->selectionTolerance()*0.99; + } else + { + // calculate distance to high/low lines: + double keyPixel = keyAxis->coordToPixel(it.value().key); + double highLineDistSqr = distSqrToLine(QPointF(keyPixel, valueAxis->coordToPixel(it.value().high)), QPointF(keyPixel, valueAxis->coordToPixel(qMax(it.value().open, it.value().close))), pos); + double lowLineDistSqr = distSqrToLine(QPointF(keyPixel, valueAxis->coordToPixel(it.value().low)), QPointF(keyPixel, valueAxis->coordToPixel(qMin(it.value().open, it.value().close))), pos); + currentDistSqr = qMin(highLineDistSqr, lowLineDistSqr); + } + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + } else // keyAxis->orientation() == Qt::Vertical + { + for (it = begin; it != end; ++it) + { + double currentDistSqr; + // determine whether pos is in open-close-box: + QCPRange boxKeyRange(it.value().key-mWidth*0.5, it.value().key+mWidth*0.5); + QCPRange boxValueRange(it.value().close, it.value().open); + double posKey, posValue; + pixelsToCoords(pos, posKey, posValue); + if (boxKeyRange.contains(posKey) && boxValueRange.contains(posValue)) // is in open-close-box + { + currentDistSqr = mParentPlot->selectionTolerance()*0.99 * mParentPlot->selectionTolerance()*0.99; + } else + { + // calculate distance to high/low lines: + double keyPixel = keyAxis->coordToPixel(it.value().key); + double highLineDistSqr = distSqrToLine(QPointF(valueAxis->coordToPixel(it.value().high), keyPixel), QPointF(valueAxis->coordToPixel(qMax(it.value().open, it.value().close)), keyPixel), pos); + double lowLineDistSqr = distSqrToLine(QPointF(valueAxis->coordToPixel(it.value().low), keyPixel), QPointF(valueAxis->coordToPixel(qMin(it.value().open, it.value().close)), keyPixel), pos); + currentDistSqr = qMin(highLineDistSqr, lowLineDistSqr); + } + if (currentDistSqr < minDistSqr) + minDistSqr = currentDistSqr; + } + } + return qSqrt(minDistSqr); +} + +/*! \internal + + called by the drawing methods to determine which data (key) range is visible at the current key + axis range setting, so only that needs to be processed. + + \a lower returns an iterator to the lowest data point that needs to be taken into account when + plotting. Note that in order to get a clean plot all the way to the edge of the axis rect, \a + lower may still be just outside the visible range. + + \a upper returns an iterator to the highest data point. Same as before, \a upper may also lie + just outside of the visible range. + + if the plottable contains no data, both \a lower and \a upper point to constEnd. + + \see QCPGraph::getVisibleDataBounds +*/ +void QCPFinancial::getVisibleDataBounds(QCPFinancialDataMap::const_iterator &lower, QCPFinancialDataMap::const_iterator &upper) const +{ + if (!mKeyAxis) { qDebug() << Q_FUNC_INFO << "invalid key axis"; return; } + if (mData->isEmpty()) + { + lower = mData->constEnd(); + upper = mData->constEnd(); + return; + } + + // get visible data range as QMap iterators + QCPFinancialDataMap::const_iterator lbound = mData->lowerBound(mKeyAxis.data()->range().lower); + QCPFinancialDataMap::const_iterator ubound = mData->upperBound(mKeyAxis.data()->range().upper); + bool lowoutlier = lbound != mData->constBegin(); // indicates whether there exist points below axis range + bool highoutlier = ubound != mData->constEnd(); // indicates whether there exist points above axis range + + lower = (lowoutlier ? lbound-1 : lbound); // data point range that will be actually drawn + upper = (highoutlier ? ubound : ubound-1); // data point range that will be actually drawn +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemStraightLine +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemStraightLine + \brief A straight line that spans infinitely in both directions + + \image html QCPItemStraightLine.png "Straight line example. Blue dotted circles are anchors, solid blue discs are positions." + + It has two positions, \a point1 and \a point2, which define the straight line. +*/ + +/*! + Creates a straight line item and sets default values. + + The constructed item can be added to the plot with QCustomPlot::addItem. +*/ +QCPItemStraightLine::QCPItemStraightLine(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + point1(createPosition("point1")), + point2(createPosition("point2")) +{ + point1->setCoords(0, 0); + point2->setCoords(1, 1); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue,2)); +} + +QCPItemStraightLine::~QCPItemStraightLine() +{ +} + +/*! + Sets the pen that will be used to draw the line + + \see setSelectedPen +*/ +void QCPItemStraightLine::setPen(const QPen &pen) +{ + mPen = pen; +} + +/*! + Sets the pen that will be used to draw the line when selected + + \see setPen, setSelected +*/ +void QCPItemStraightLine::setSelectedPen(const QPen &pen) +{ + mSelectedPen = pen; +} + +/* inherits documentation from base class */ +double QCPItemStraightLine::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + return distToStraightLine(QVector2D(point1->pixelPoint()), QVector2D(point2->pixelPoint()-point1->pixelPoint()), QVector2D(pos)); +} + +/* inherits documentation from base class */ +void QCPItemStraightLine::draw(QCPPainter *painter) +{ + QVector2D start(point1->pixelPoint()); + QVector2D end(point2->pixelPoint()); + // get visible segment of straight line inside clipRect: + double clipPad = mainPen().widthF(); + QLineF line = getRectClippedStraightLine(start, end-start, clipRect().adjusted(-clipPad, -clipPad, clipPad, clipPad)); + // paint visible segment, if existent: + if (!line.isNull()) + { + painter->setPen(mainPen()); + painter->drawLine(line); + } +} + +/*! \internal + + finds the shortest distance of \a point to the straight line defined by the base point \a + base and the direction vector \a vec. + + This is a helper function for \ref selectTest. +*/ +double QCPItemStraightLine::distToStraightLine(const QVector2D &base, const QVector2D &vec, const QVector2D &point) const +{ + return qAbs((base.y()-point.y())*vec.x()-(base.x()-point.x())*vec.y())/vec.length(); +} + +/*! \internal + + Returns the section of the straight line defined by \a base and direction vector \a + vec, that is visible in the specified \a rect. + + This is a helper function for \ref draw. +*/ +QLineF QCPItemStraightLine::getRectClippedStraightLine(const QVector2D &base, const QVector2D &vec, const QRect &rect) const +{ + double bx, by; + double gamma; + QLineF result; + if (vec.x() == 0 && vec.y() == 0) + return result; + if (qFuzzyIsNull(vec.x())) // line is vertical + { + // check top of rect: + bx = rect.left(); + by = rect.top(); + gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); + if (gamma >= 0 && gamma <= rect.width()) + result.setLine(bx+gamma, rect.top(), bx+gamma, rect.bottom()); // no need to check bottom because we know line is vertical + } else if (qFuzzyIsNull(vec.y())) // line is horizontal + { + // check left of rect: + bx = rect.left(); + by = rect.top(); + gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); + if (gamma >= 0 && gamma <= rect.height()) + result.setLine(rect.left(), by+gamma, rect.right(), by+gamma); // no need to check right because we know line is horizontal + } else // line is skewed + { + QList pointVectors; + // check top of rect: + bx = rect.left(); + by = rect.top(); + gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QVector2D(bx+gamma, by)); + // check bottom of rect: + bx = rect.left(); + by = rect.bottom(); + gamma = base.x()-bx + (by-base.y())*vec.x()/vec.y(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QVector2D(bx+gamma, by)); + // check left of rect: + bx = rect.left(); + by = rect.top(); + gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QVector2D(bx, by+gamma)); + // check right of rect: + bx = rect.right(); + by = rect.top(); + gamma = base.y()-by + (bx-base.x())*vec.y()/vec.x(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QVector2D(bx, by+gamma)); + + // evaluate points: + if (pointVectors.size() == 2) + { + result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF()); + } else if (pointVectors.size() > 2) + { + // line probably goes through corner of rect, and we got two points there. single out the point pair with greatest distance: + double distSqrMax = 0; + QVector2D pv1, pv2; + for (int i=0; i distSqrMax) + { + pv1 = pointVectors.at(i); + pv2 = pointVectors.at(k); + distSqrMax = distSqr; + } + } + } + result.setPoints(pv1.toPointF(), pv2.toPointF()); + } + } + return result; +} + +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the + item is not selected and mSelectedPen when it is. +*/ +QPen QCPItemStraightLine::mainPen() const +{ + return mSelected ? mSelectedPen : mPen; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemLine +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemLine + \brief A line from one point to another + + \image html QCPItemLine.png "Line example. Blue dotted circles are anchors, solid blue discs are positions." + + It has two positions, \a start and \a end, which define the end points of the line. + + With \ref setHead and \ref setTail you may set different line ending styles, e.g. to create an arrow. +*/ + +/*! + Creates a line item and sets default values. + + The constructed item can be added to the plot with QCustomPlot::addItem. +*/ +QCPItemLine::QCPItemLine(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + start(createPosition("start")), + end(createPosition("end")) +{ + start->setCoords(0, 0); + end->setCoords(1, 1); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue,2)); +} + +QCPItemLine::~QCPItemLine() +{ +} + +/*! + Sets the pen that will be used to draw the line + + \see setSelectedPen +*/ +void QCPItemLine::setPen(const QPen &pen) +{ + mPen = pen; +} + +/*! + Sets the pen that will be used to draw the line when selected + + \see setPen, setSelected +*/ +void QCPItemLine::setSelectedPen(const QPen &pen) +{ + mSelectedPen = pen; +} + +/*! + Sets the line ending style of the head. The head corresponds to the \a end position. + + Note that due to the overloaded QCPLineEnding constructor, you may directly specify + a QCPLineEnding::EndingStyle here, e.g. \code setHead(QCPLineEnding::esSpikeArrow) \endcode + + \see setTail +*/ +void QCPItemLine::setHead(const QCPLineEnding &head) +{ + mHead = head; +} + +/*! + Sets the line ending style of the tail. The tail corresponds to the \a start position. + + Note that due to the overloaded QCPLineEnding constructor, you may directly specify + a QCPLineEnding::EndingStyle here, e.g. \code setTail(QCPLineEnding::esSpikeArrow) \endcode + + \see setHead +*/ +void QCPItemLine::setTail(const QCPLineEnding &tail) +{ + mTail = tail; +} + +/* inherits documentation from base class */ +double QCPItemLine::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + return qSqrt(distSqrToLine(start->pixelPoint(), end->pixelPoint(), pos)); +} + +/* inherits documentation from base class */ +void QCPItemLine::draw(QCPPainter *painter) +{ + QVector2D startVec(start->pixelPoint()); + QVector2D endVec(end->pixelPoint()); + if (startVec.toPoint() == endVec.toPoint()) + return; + // get visible segment of straight line inside clipRect: + double clipPad = qMax(mHead.boundingDistance(), mTail.boundingDistance()); + clipPad = qMax(clipPad, (double)mainPen().widthF()); + QLineF line = getRectClippedLine(startVec, endVec, clipRect().adjusted(-clipPad, -clipPad, clipPad, clipPad)); + // paint visible segment, if existent: + if (!line.isNull()) + { + painter->setPen(mainPen()); + painter->drawLine(line); + painter->setBrush(Qt::SolidPattern); + if (mTail.style() != QCPLineEnding::esNone) + mTail.draw(painter, startVec, startVec-endVec); + if (mHead.style() != QCPLineEnding::esNone) + mHead.draw(painter, endVec, endVec-startVec); + } +} + +/*! \internal + + Returns the section of the line defined by \a start and \a end, that is visible in the specified + \a rect. + + This is a helper function for \ref draw. +*/ +QLineF QCPItemLine::getRectClippedLine(const QVector2D &start, const QVector2D &end, const QRect &rect) const +{ + bool containsStart = rect.contains(start.x(), start.y()); + bool containsEnd = rect.contains(end.x(), end.y()); + if (containsStart && containsEnd) + return QLineF(start.toPointF(), end.toPointF()); + + QVector2D base = start; + QVector2D vec = end-start; + double bx, by; + double gamma, mu; + QLineF result; + QList pointVectors; + + if (!qFuzzyIsNull(vec.y())) // line is not horizontal + { + // check top of rect: + bx = rect.left(); + by = rect.top(); + mu = (by-base.y())/vec.y(); + if (mu >= 0 && mu <= 1) + { + gamma = base.x()-bx + mu*vec.x(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QVector2D(bx+gamma, by)); + } + // check bottom of rect: + bx = rect.left(); + by = rect.bottom(); + mu = (by-base.y())/vec.y(); + if (mu >= 0 && mu <= 1) + { + gamma = base.x()-bx + mu*vec.x(); + if (gamma >= 0 && gamma <= rect.width()) + pointVectors.append(QVector2D(bx+gamma, by)); + } + } + if (!qFuzzyIsNull(vec.x())) // line is not vertical + { + // check left of rect: + bx = rect.left(); + by = rect.top(); + mu = (bx-base.x())/vec.x(); + if (mu >= 0 && mu <= 1) + { + gamma = base.y()-by + mu*vec.y(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QVector2D(bx, by+gamma)); + } + // check right of rect: + bx = rect.right(); + by = rect.top(); + mu = (bx-base.x())/vec.x(); + if (mu >= 0 && mu <= 1) + { + gamma = base.y()-by + mu*vec.y(); + if (gamma >= 0 && gamma <= rect.height()) + pointVectors.append(QVector2D(bx, by+gamma)); + } + } + + if (containsStart) + pointVectors.append(start); + if (containsEnd) + pointVectors.append(end); + + // evaluate points: + if (pointVectors.size() == 2) + { + result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF()); + } else if (pointVectors.size() > 2) + { + // line probably goes through corner of rect, and we got two points there. single out the point pair with greatest distance: + double distSqrMax = 0; + QVector2D pv1, pv2; + for (int i=0; i distSqrMax) + { + pv1 = pointVectors.at(i); + pv2 = pointVectors.at(k); + distSqrMax = distSqr; + } + } + } + result.setPoints(pv1.toPointF(), pv2.toPointF()); + } + return result; +} + +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the + item is not selected and mSelectedPen when it is. +*/ +QPen QCPItemLine::mainPen() const +{ + return mSelected ? mSelectedPen : mPen; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemCurve +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemCurve + \brief A curved line from one point to another + + \image html QCPItemCurve.png "Curve example. Blue dotted circles are anchors, solid blue discs are positions." + + It has four positions, \a start and \a end, which define the end points of the line, and two + control points which define the direction the line exits from the start and the direction from + which it approaches the end: \a startDir and \a endDir. + + With \ref setHead and \ref setTail you may set different line ending styles, e.g. to create an + arrow. + + Often it is desirable for the control points to stay at fixed relative positions to the start/end + point. This can be achieved by setting the parent anchor e.g. of \a startDir simply to \a start, + and then specify the desired pixel offset with QCPItemPosition::setCoords on \a startDir. +*/ + +/*! + Creates a curve item and sets default values. + + The constructed item can be added to the plot with QCustomPlot::addItem. +*/ +QCPItemCurve::QCPItemCurve(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + start(createPosition("start")), + startDir(createPosition("startDir")), + endDir(createPosition("endDir")), + end(createPosition("end")) +{ + start->setCoords(0, 0); + startDir->setCoords(0.5, 0); + endDir->setCoords(0, 0.5); + end->setCoords(1, 1); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue,2)); +} + +QCPItemCurve::~QCPItemCurve() +{ +} + +/*! + Sets the pen that will be used to draw the line + + \see setSelectedPen +*/ +void QCPItemCurve::setPen(const QPen &pen) +{ + mPen = pen; +} + +/*! + Sets the pen that will be used to draw the line when selected + + \see setPen, setSelected +*/ +void QCPItemCurve::setSelectedPen(const QPen &pen) +{ + mSelectedPen = pen; +} + +/*! + Sets the line ending style of the head. The head corresponds to the \a end position. + + Note that due to the overloaded QCPLineEnding constructor, you may directly specify + a QCPLineEnding::EndingStyle here, e.g. \code setHead(QCPLineEnding::esSpikeArrow) \endcode + + \see setTail +*/ +void QCPItemCurve::setHead(const QCPLineEnding &head) +{ + mHead = head; +} + +/*! + Sets the line ending style of the tail. The tail corresponds to the \a start position. + + Note that due to the overloaded QCPLineEnding constructor, you may directly specify + a QCPLineEnding::EndingStyle here, e.g. \code setTail(QCPLineEnding::esSpikeArrow) \endcode + + \see setHead +*/ +void QCPItemCurve::setTail(const QCPLineEnding &tail) +{ + mTail = tail; +} + +/* inherits documentation from base class */ +double QCPItemCurve::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + QPointF startVec(start->pixelPoint()); + QPointF startDirVec(startDir->pixelPoint()); + QPointF endDirVec(endDir->pixelPoint()); + QPointF endVec(end->pixelPoint()); + + QPainterPath cubicPath(startVec); + cubicPath.cubicTo(startDirVec, endDirVec, endVec); + + QPolygonF polygon = cubicPath.toSubpathPolygons().first(); + double minDistSqr = std::numeric_limits::max(); + for (int i=1; ipixelPoint()); + QPointF startDirVec(startDir->pixelPoint()); + QPointF endDirVec(endDir->pixelPoint()); + QPointF endVec(end->pixelPoint()); + if (QVector2D(endVec-startVec).length() > 1e10f) // too large curves cause crash + return; + + QPainterPath cubicPath(startVec); + cubicPath.cubicTo(startDirVec, endDirVec, endVec); + + // paint visible segment, if existent: + QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); + QRect cubicRect = cubicPath.controlPointRect().toRect(); + if (cubicRect.isEmpty()) // may happen when start and end exactly on same x or y position + cubicRect.adjust(0, 0, 1, 1); + if (clip.intersects(cubicRect)) + { + painter->setPen(mainPen()); + painter->drawPath(cubicPath); + painter->setBrush(Qt::SolidPattern); + if (mTail.style() != QCPLineEnding::esNone) + mTail.draw(painter, QVector2D(startVec), M_PI-cubicPath.angleAtPercent(0)/180.0*M_PI); + if (mHead.style() != QCPLineEnding::esNone) + mHead.draw(painter, QVector2D(endVec), -cubicPath.angleAtPercent(1)/180.0*M_PI); + } +} + +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the + item is not selected and mSelectedPen when it is. +*/ +QPen QCPItemCurve::mainPen() const +{ + return mSelected ? mSelectedPen : mPen; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemRect +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemRect + \brief A rectangle + + \image html QCPItemRect.png "Rectangle example. Blue dotted circles are anchors, solid blue discs are positions." + + It has two positions, \a topLeft and \a bottomRight, which define the rectangle. +*/ + +/*! + Creates a rectangle item and sets default values. + + The constructed item can be added to the plot with QCustomPlot::addItem. +*/ +QCPItemRect::QCPItemRect(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + topLeft(createPosition("topLeft")), + bottomRight(createPosition("bottomRight")), + top(createAnchor("top", aiTop)), + topRight(createAnchor("topRight", aiTopRight)), + right(createAnchor("right", aiRight)), + bottom(createAnchor("bottom", aiBottom)), + bottomLeft(createAnchor("bottomLeft", aiBottomLeft)), + left(createAnchor("left", aiLeft)) +{ + topLeft->setCoords(0, 1); + bottomRight->setCoords(1, 0); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue,2)); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); +} + +QCPItemRect::~QCPItemRect() +{ +} + +/*! + Sets the pen that will be used to draw the line of the rectangle + + \see setSelectedPen, setBrush +*/ +void QCPItemRect::setPen(const QPen &pen) +{ + mPen = pen; +} + +/*! + Sets the pen that will be used to draw the line of the rectangle when selected + + \see setPen, setSelected +*/ +void QCPItemRect::setSelectedPen(const QPen &pen) +{ + mSelectedPen = pen; +} + +/*! + Sets the brush that will be used to fill the rectangle. To disable filling, set \a brush to + Qt::NoBrush. + + \see setSelectedBrush, setPen +*/ +void QCPItemRect::setBrush(const QBrush &brush) +{ + mBrush = brush; +} + +/*! + Sets the brush that will be used to fill the rectangle when selected. To disable filling, set \a + brush to Qt::NoBrush. + + \see setBrush +*/ +void QCPItemRect::setSelectedBrush(const QBrush &brush) +{ + mSelectedBrush = brush; +} + +/* inherits documentation from base class */ +double QCPItemRect::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + QRectF rect = QRectF(topLeft->pixelPoint(), bottomRight->pixelPoint()).normalized(); + bool filledRect = mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0; + return rectSelectTest(rect, pos, filledRect); +} + +/* inherits documentation from base class */ +void QCPItemRect::draw(QCPPainter *painter) +{ + QPointF p1 = topLeft->pixelPoint(); + QPointF p2 = bottomRight->pixelPoint(); + if (p1.toPoint() == p2.toPoint()) + return; + QRectF rect = QRectF(p1, p2).normalized(); + double clipPad = mainPen().widthF(); + QRectF boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad); + if (boundingRect.intersects(clipRect())) // only draw if bounding rect of rect item is visible in cliprect + { + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); + painter->drawRect(rect); + } +} + +/* inherits documentation from base class */ +QPointF QCPItemRect::anchorPixelPoint(int anchorId) const +{ + QRectF rect = QRectF(topLeft->pixelPoint(), bottomRight->pixelPoint()); + switch (anchorId) + { + case aiTop: return (rect.topLeft()+rect.topRight())*0.5; + case aiTopRight: return rect.topRight(); + case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; + case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; + case aiBottomLeft: return rect.bottomLeft(); + case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5; + } + + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; + return QPointF(); +} + +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected + and mSelectedPen when it is. +*/ +QPen QCPItemRect::mainPen() const +{ + return mSelected ? mSelectedPen : mPen; +} + +/*! \internal + + Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item + is not selected and mSelectedBrush when it is. +*/ +QBrush QCPItemRect::mainBrush() const +{ + return mSelected ? mSelectedBrush : mBrush; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemText +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemText + \brief A text label + + \image html QCPItemText.png "Text example. Blue dotted circles are anchors, solid blue discs are positions." + + Its position is defined by the member \a position and the setting of \ref setPositionAlignment. + The latter controls which part of the text rect shall be aligned with \a position. + + The text alignment itself (i.e. left, center, right) can be controlled with \ref + setTextAlignment. + + The text may be rotated around the \a position point with \ref setRotation. +*/ + +/*! + Creates a text item and sets default values. + + The constructed item can be added to the plot with QCustomPlot::addItem. +*/ +QCPItemText::QCPItemText(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + position(createPosition("position")), + topLeft(createAnchor("topLeft", aiTopLeft)), + top(createAnchor("top", aiTop)), + topRight(createAnchor("topRight", aiTopRight)), + right(createAnchor("right", aiRight)), + bottomRight(createAnchor("bottomRight", aiBottomRight)), + bottom(createAnchor("bottom", aiBottom)), + bottomLeft(createAnchor("bottomLeft", aiBottomLeft)), + left(createAnchor("left", aiLeft)) +{ + position->setCoords(0, 0); + + setRotation(0); + setTextAlignment(Qt::AlignTop|Qt::AlignHCenter); + setPositionAlignment(Qt::AlignCenter); + setText("text"); + + setPen(Qt::NoPen); + setSelectedPen(Qt::NoPen); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); + setColor(Qt::black); + setSelectedColor(Qt::blue); +} + +QCPItemText::~QCPItemText() +{ +} + +/*! + Sets the color of the text. +*/ +void QCPItemText::setColor(const QColor &color) +{ + mColor = color; +} + +/*! + Sets the color of the text that will be used when the item is selected. +*/ +void QCPItemText::setSelectedColor(const QColor &color) +{ + mSelectedColor = color; +} + +/*! + Sets the pen that will be used do draw a rectangular border around the text. To disable the + border, set \a pen to Qt::NoPen. + + \see setSelectedPen, setBrush, setPadding +*/ +void QCPItemText::setPen(const QPen &pen) +{ + mPen = pen; +} + +/*! + Sets the pen that will be used do draw a rectangular border around the text, when the item is + selected. To disable the border, set \a pen to Qt::NoPen. + + \see setPen +*/ +void QCPItemText::setSelectedPen(const QPen &pen) +{ + mSelectedPen = pen; +} + +/*! + Sets the brush that will be used do fill the background of the text. To disable the + background, set \a brush to Qt::NoBrush. + + \see setSelectedBrush, setPen, setPadding +*/ +void QCPItemText::setBrush(const QBrush &brush) +{ + mBrush = brush; +} + +/*! + Sets the brush that will be used do fill the background of the text, when the item is selected. To disable the + background, set \a brush to Qt::NoBrush. + + \see setBrush +*/ +void QCPItemText::setSelectedBrush(const QBrush &brush) +{ + mSelectedBrush = brush; +} + +/*! + Sets the font of the text. + + \see setSelectedFont, setColor +*/ +void QCPItemText::setFont(const QFont &font) +{ + mFont = font; +} + +/*! + Sets the font of the text that will be used when the item is selected. + + \see setFont +*/ +void QCPItemText::setSelectedFont(const QFont &font) +{ + mSelectedFont = font; +} + +/*! + Sets the text that will be displayed. Multi-line texts are supported by inserting a line break + character, e.g. '\n'. + + \see setFont, setColor, setTextAlignment +*/ +void QCPItemText::setText(const QString &text) +{ + mText = text; +} + +/*! + Sets which point of the text rect shall be aligned with \a position. + + Examples: + \li If \a alignment is Qt::AlignHCenter | Qt::AlignTop, the text will be positioned such + that the top of the text rect will be horizontally centered on \a position. + \li If \a alignment is Qt::AlignLeft | Qt::AlignBottom, \a position will indicate the + bottom left corner of the text rect. + + If you want to control the alignment of (multi-lined) text within the text rect, use \ref + setTextAlignment. +*/ +void QCPItemText::setPositionAlignment(Qt::Alignment alignment) +{ + mPositionAlignment = alignment; +} + +/*! + Controls how (multi-lined) text is aligned inside the text rect (typically Qt::AlignLeft, Qt::AlignCenter or Qt::AlignRight). +*/ +void QCPItemText::setTextAlignment(Qt::Alignment alignment) +{ + mTextAlignment = alignment; +} + +/*! + Sets the angle in degrees by which the text (and the text rectangle, if visible) will be rotated + around \a position. +*/ +void QCPItemText::setRotation(double degrees) +{ + mRotation = degrees; +} + +/*! + Sets the distance between the border of the text rectangle and the text. The appearance (and + visibility) of the text rectangle can be controlled with \ref setPen and \ref setBrush. +*/ +void QCPItemText::setPadding(const QMargins &padding) +{ + mPadding = padding; +} + +/* inherits documentation from base class */ +double QCPItemText::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + // The rect may be rotated, so we transform the actual clicked pos to the rotated + // coordinate system, so we can use the normal rectSelectTest function for non-rotated rects: + QPointF positionPixels(position->pixelPoint()); + QTransform inputTransform; + inputTransform.translate(positionPixels.x(), positionPixels.y()); + inputTransform.rotate(-mRotation); + inputTransform.translate(-positionPixels.x(), -positionPixels.y()); + QPointF rotatedPos = inputTransform.map(pos); + QFontMetrics fontMetrics(mFont); + QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); + QRect textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); + QPointF textPos = getTextDrawPoint(positionPixels, textBoxRect, mPositionAlignment); + textBoxRect.moveTopLeft(textPos.toPoint()); + + return rectSelectTest(textBoxRect, rotatedPos, true); +} + +/* inherits documentation from base class */ +void QCPItemText::draw(QCPPainter *painter) +{ + QPointF pos(position->pixelPoint()); + QTransform transform = painter->transform(); + transform.translate(pos.x(), pos.y()); + if (!qFuzzyIsNull(mRotation)) + transform.rotate(mRotation); + painter->setFont(mainFont()); + QRect textRect = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); + QRect textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); + QPointF textPos = getTextDrawPoint(QPointF(0, 0), textBoxRect, mPositionAlignment); // 0, 0 because the transform does the translation + textRect.moveTopLeft(textPos.toPoint()+QPoint(mPadding.left(), mPadding.top())); + textBoxRect.moveTopLeft(textPos.toPoint()); + double clipPad = mainPen().widthF(); + QRect boundingRect = textBoxRect.adjusted(-clipPad, -clipPad, clipPad, clipPad); + if (transform.mapRect(boundingRect).intersects(painter->transform().mapRect(clipRect()))) + { + painter->setTransform(transform); + if ((mainBrush().style() != Qt::NoBrush && mainBrush().color().alpha() != 0) || + (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0)) + { + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); + painter->drawRect(textBoxRect); + } + painter->setBrush(Qt::NoBrush); + painter->setPen(QPen(mainColor())); + painter->drawText(textRect, Qt::TextDontClip|mTextAlignment, mText); + } +} + +/* inherits documentation from base class */ +QPointF QCPItemText::anchorPixelPoint(int anchorId) const +{ + // get actual rect points (pretty much copied from draw function): + QPointF pos(position->pixelPoint()); + QTransform transform; + transform.translate(pos.x(), pos.y()); + if (!qFuzzyIsNull(mRotation)) + transform.rotate(mRotation); + QFontMetrics fontMetrics(mainFont()); + QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText); + QRectF textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom()); + QPointF textPos = getTextDrawPoint(QPointF(0, 0), textBoxRect, mPositionAlignment); // 0, 0 because the transform does the translation + textBoxRect.moveTopLeft(textPos.toPoint()); + QPolygonF rectPoly = transform.map(QPolygonF(textBoxRect)); + + switch (anchorId) + { + case aiTopLeft: return rectPoly.at(0); + case aiTop: return (rectPoly.at(0)+rectPoly.at(1))*0.5; + case aiTopRight: return rectPoly.at(1); + case aiRight: return (rectPoly.at(1)+rectPoly.at(2))*0.5; + case aiBottomRight: return rectPoly.at(2); + case aiBottom: return (rectPoly.at(2)+rectPoly.at(3))*0.5; + case aiBottomLeft: return rectPoly.at(3); + case aiLeft: return (rectPoly.at(3)+rectPoly.at(0))*0.5; + } + + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; + return QPointF(); +} + +/*! \internal + + Returns the point that must be given to the QPainter::drawText function (which expects the top + left point of the text rect), according to the position \a pos, the text bounding box \a rect and + the requested \a positionAlignment. + + For example, if \a positionAlignment is Qt::AlignLeft | Qt::AlignBottom the returned point + will be shifted upward by the height of \a rect, starting from \a pos. So if the text is finally + drawn at that point, the lower left corner of the resulting text rect is at \a pos. +*/ +QPointF QCPItemText::getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const +{ + if (positionAlignment == 0 || positionAlignment == (Qt::AlignLeft|Qt::AlignTop)) + return pos; + + QPointF result = pos; // start at top left + if (positionAlignment.testFlag(Qt::AlignHCenter)) + result.rx() -= rect.width()/2.0; + else if (positionAlignment.testFlag(Qt::AlignRight)) + result.rx() -= rect.width(); + if (positionAlignment.testFlag(Qt::AlignVCenter)) + result.ry() -= rect.height()/2.0; + else if (positionAlignment.testFlag(Qt::AlignBottom)) + result.ry() -= rect.height(); + return result; +} + +/*! \internal + + Returns the font that should be used for drawing text. Returns mFont when the item is not selected + and mSelectedFont when it is. +*/ +QFont QCPItemText::mainFont() const +{ + return mSelected ? mSelectedFont : mFont; +} + +/*! \internal + + Returns the color that should be used for drawing text. Returns mColor when the item is not + selected and mSelectedColor when it is. +*/ +QColor QCPItemText::mainColor() const +{ + return mSelected ? mSelectedColor : mColor; +} + +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected + and mSelectedPen when it is. +*/ +QPen QCPItemText::mainPen() const +{ + return mSelected ? mSelectedPen : mPen; +} + +/*! \internal + + Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item + is not selected and mSelectedBrush when it is. +*/ +QBrush QCPItemText::mainBrush() const +{ + return mSelected ? mSelectedBrush : mBrush; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemEllipse +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemEllipse + \brief An ellipse + + \image html QCPItemEllipse.png "Ellipse example. Blue dotted circles are anchors, solid blue discs are positions." + + It has two positions, \a topLeft and \a bottomRight, which define the rect the ellipse will be drawn in. +*/ + +/*! + Creates an ellipse item and sets default values. + + The constructed item can be added to the plot with QCustomPlot::addItem. +*/ +QCPItemEllipse::QCPItemEllipse(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + topLeft(createPosition("topLeft")), + bottomRight(createPosition("bottomRight")), + topLeftRim(createAnchor("topLeftRim", aiTopLeftRim)), + top(createAnchor("top", aiTop)), + topRightRim(createAnchor("topRightRim", aiTopRightRim)), + right(createAnchor("right", aiRight)), + bottomRightRim(createAnchor("bottomRightRim", aiBottomRightRim)), + bottom(createAnchor("bottom", aiBottom)), + bottomLeftRim(createAnchor("bottomLeftRim", aiBottomLeftRim)), + left(createAnchor("left", aiLeft)), + center(createAnchor("center", aiCenter)) +{ + topLeft->setCoords(0, 1); + bottomRight->setCoords(1, 0); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue, 2)); + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); +} + +QCPItemEllipse::~QCPItemEllipse() +{ +} + +/*! + Sets the pen that will be used to draw the line of the ellipse + + \see setSelectedPen, setBrush +*/ +void QCPItemEllipse::setPen(const QPen &pen) +{ + mPen = pen; +} + +/*! + Sets the pen that will be used to draw the line of the ellipse when selected + + \see setPen, setSelected +*/ +void QCPItemEllipse::setSelectedPen(const QPen &pen) +{ + mSelectedPen = pen; +} + +/*! + Sets the brush that will be used to fill the ellipse. To disable filling, set \a brush to + Qt::NoBrush. + + \see setSelectedBrush, setPen +*/ +void QCPItemEllipse::setBrush(const QBrush &brush) +{ + mBrush = brush; +} + +/*! + Sets the brush that will be used to fill the ellipse when selected. To disable filling, set \a + brush to Qt::NoBrush. + + \see setBrush +*/ +void QCPItemEllipse::setSelectedBrush(const QBrush &brush) +{ + mSelectedBrush = brush; +} + +/* inherits documentation from base class */ +double QCPItemEllipse::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + double result = -1; + QPointF p1 = topLeft->pixelPoint(); + QPointF p2 = bottomRight->pixelPoint(); + QPointF center((p1+p2)/2.0); + double a = qAbs(p1.x()-p2.x())/2.0; + double b = qAbs(p1.y()-p2.y())/2.0; + double x = pos.x()-center.x(); + double y = pos.y()-center.y(); + + // distance to border: + double c = 1.0/qSqrt(x*x/(a*a)+y*y/(b*b)); + result = qAbs(c-1)*qSqrt(x*x+y*y); + // filled ellipse, allow click inside to count as hit: + if (result > mParentPlot->selectionTolerance()*0.99 && mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0) + { + if (x*x/(a*a) + y*y/(b*b) <= 1) + result = mParentPlot->selectionTolerance()*0.99; + } + return result; +} + +/* inherits documentation from base class */ +void QCPItemEllipse::draw(QCPPainter *painter) +{ + QPointF p1 = topLeft->pixelPoint(); + QPointF p2 = bottomRight->pixelPoint(); + if (p1.toPoint() == p2.toPoint()) + return; + QRectF ellipseRect = QRectF(p1, p2).normalized(); + QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); + if (ellipseRect.intersects(clip)) // only draw if bounding rect of ellipse is visible in cliprect + { + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); +#ifdef __EXCEPTIONS + try // drawEllipse sometimes throws exceptions if ellipse is too big + { +#endif + painter->drawEllipse(ellipseRect); +#ifdef __EXCEPTIONS + } catch (...) + { + qDebug() << Q_FUNC_INFO << "Item too large for memory, setting invisible"; + setVisible(false); + } +#endif + } +} + +/* inherits documentation from base class */ +QPointF QCPItemEllipse::anchorPixelPoint(int anchorId) const +{ + QRectF rect = QRectF(topLeft->pixelPoint(), bottomRight->pixelPoint()); + switch (anchorId) + { + case aiTopLeftRim: return rect.center()+(rect.topLeft()-rect.center())*1/qSqrt(2); + case aiTop: return (rect.topLeft()+rect.topRight())*0.5; + case aiTopRightRim: return rect.center()+(rect.topRight()-rect.center())*1/qSqrt(2); + case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; + case aiBottomRightRim: return rect.center()+(rect.bottomRight()-rect.center())*1/qSqrt(2); + case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; + case aiBottomLeftRim: return rect.center()+(rect.bottomLeft()-rect.center())*1/qSqrt(2); + case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5; + case aiCenter: return (rect.topLeft()+rect.bottomRight())*0.5; + } + + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; + return QPointF(); +} + +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected + and mSelectedPen when it is. +*/ +QPen QCPItemEllipse::mainPen() const +{ + return mSelected ? mSelectedPen : mPen; +} + +/*! \internal + + Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item + is not selected and mSelectedBrush when it is. +*/ +QBrush QCPItemEllipse::mainBrush() const +{ + return mSelected ? mSelectedBrush : mBrush; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemPixmap +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemPixmap + \brief An arbitrary pixmap + + \image html QCPItemPixmap.png "Pixmap example. Blue dotted circles are anchors, solid blue discs are positions." + + It has two positions, \a topLeft and \a bottomRight, which define the rectangle the pixmap will + be drawn in. Depending on the scale setting (\ref setScaled), the pixmap will be either scaled to + fit the rectangle or be drawn aligned to the topLeft position. + + If scaling is enabled and \a topLeft is further to the bottom/right than \a bottomRight (as shown + on the right side of the example image), the pixmap will be flipped in the respective + orientations. +*/ + +/*! + Creates a rectangle item and sets default values. + + The constructed item can be added to the plot with QCustomPlot::addItem. +*/ +QCPItemPixmap::QCPItemPixmap(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + topLeft(createPosition("topLeft")), + bottomRight(createPosition("bottomRight")), + top(createAnchor("top", aiTop)), + topRight(createAnchor("topRight", aiTopRight)), + right(createAnchor("right", aiRight)), + bottom(createAnchor("bottom", aiBottom)), + bottomLeft(createAnchor("bottomLeft", aiBottomLeft)), + left(createAnchor("left", aiLeft)) +{ + topLeft->setCoords(0, 1); + bottomRight->setCoords(1, 0); + + setPen(Qt::NoPen); + setSelectedPen(QPen(Qt::blue)); + setScaled(false, Qt::KeepAspectRatio); +} + +QCPItemPixmap::~QCPItemPixmap() +{ +} + +/*! + Sets the pixmap that will be displayed. +*/ +void QCPItemPixmap::setPixmap(const QPixmap &pixmap) +{ + mPixmap = pixmap; + if (mPixmap.isNull()) + qDebug() << Q_FUNC_INFO << "pixmap is null"; +} + +/*! + Sets whether the pixmap will be scaled to fit the rectangle defined by the \a topLeft and \a + bottomRight positions. +*/ +void QCPItemPixmap::setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode) +{ + mScaled = scaled; + mAspectRatioMode = aspectRatioMode; + updateScaledPixmap(); +} + +/*! + Sets the pen that will be used to draw a border around the pixmap. + + \see setSelectedPen, setBrush +*/ +void QCPItemPixmap::setPen(const QPen &pen) +{ + mPen = pen; +} + +/*! + Sets the pen that will be used to draw a border around the pixmap when selected + + \see setPen, setSelected +*/ +void QCPItemPixmap::setSelectedPen(const QPen &pen) +{ + mSelectedPen = pen; +} + +/* inherits documentation from base class */ +double QCPItemPixmap::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + return rectSelectTest(getFinalRect(), pos, true); +} + +/* inherits documentation from base class */ +void QCPItemPixmap::draw(QCPPainter *painter) +{ + bool flipHorz = false; + bool flipVert = false; + QRect rect = getFinalRect(&flipHorz, &flipVert); + double clipPad = mainPen().style() == Qt::NoPen ? 0 : mainPen().widthF(); + QRect boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad); + if (boundingRect.intersects(clipRect())) + { + updateScaledPixmap(rect, flipHorz, flipVert); + painter->drawPixmap(rect.topLeft(), mScaled ? mScaledPixmap : mPixmap); + QPen pen = mainPen(); + if (pen.style() != Qt::NoPen) + { + painter->setPen(pen); + painter->setBrush(Qt::NoBrush); + painter->drawRect(rect); + } + } +} + +/* inherits documentation from base class */ +QPointF QCPItemPixmap::anchorPixelPoint(int anchorId) const +{ + bool flipHorz; + bool flipVert; + QRect rect = getFinalRect(&flipHorz, &flipVert); + // we actually want denormal rects (negative width/height) here, so restore + // the flipped state: + if (flipHorz) + rect.adjust(rect.width(), 0, -rect.width(), 0); + if (flipVert) + rect.adjust(0, rect.height(), 0, -rect.height()); + + switch (anchorId) + { + case aiTop: return (rect.topLeft()+rect.topRight())*0.5; + case aiTopRight: return rect.topRight(); + case aiRight: return (rect.topRight()+rect.bottomRight())*0.5; + case aiBottom: return (rect.bottomLeft()+rect.bottomRight())*0.5; + case aiBottomLeft: return rect.bottomLeft(); + case aiLeft: return (rect.topLeft()+rect.bottomLeft())*0.5;; + } + + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; + return QPointF(); +} + +/*! \internal + + Creates the buffered scaled image (\a mScaledPixmap) to fit the specified \a finalRect. The + parameters \a flipHorz and \a flipVert control whether the resulting image shall be flipped + horizontally or vertically. (This is used when \a topLeft is further to the bottom/right than \a + bottomRight.) + + This function only creates the scaled pixmap when the buffered pixmap has a different size than + the expected result, so calling this function repeatedly, e.g. in the \ref draw function, does + not cause expensive rescaling every time. + + If scaling is disabled, sets mScaledPixmap to a null QPixmap. +*/ +void QCPItemPixmap::updateScaledPixmap(QRect finalRect, bool flipHorz, bool flipVert) +{ + if (mPixmap.isNull()) + return; + + if (mScaled) + { + if (finalRect.isNull()) + finalRect = getFinalRect(&flipHorz, &flipVert); + if (finalRect.size() != mScaledPixmap.size()) + { + mScaledPixmap = mPixmap.scaled(finalRect.size(), mAspectRatioMode, Qt::SmoothTransformation); + if (flipHorz || flipVert) + mScaledPixmap = QPixmap::fromImage(mScaledPixmap.toImage().mirrored(flipHorz, flipVert)); + } + } else if (!mScaledPixmap.isNull()) + mScaledPixmap = QPixmap(); +} + +/*! \internal + + Returns the final (tight) rect the pixmap is drawn in, depending on the current item positions + and scaling settings. + + The output parameters \a flippedHorz and \a flippedVert return whether the pixmap should be drawn + flipped horizontally or vertically in the returned rect. (The returned rect itself is always + normalized, i.e. the top left corner of the rect is actually further to the top/left than the + bottom right corner). This is the case when the item position \a topLeft is further to the + bottom/right than \a bottomRight. + + If scaling is disabled, returns a rect with size of the original pixmap and the top left corner + aligned with the item position \a topLeft. The position \a bottomRight is ignored. +*/ +QRect QCPItemPixmap::getFinalRect(bool *flippedHorz, bool *flippedVert) const +{ + QRect result; + bool flipHorz = false; + bool flipVert = false; + QPoint p1 = topLeft->pixelPoint().toPoint(); + QPoint p2 = bottomRight->pixelPoint().toPoint(); + if (p1 == p2) + return QRect(p1, QSize(0, 0)); + if (mScaled) + { + QSize newSize = QSize(p2.x()-p1.x(), p2.y()-p1.y()); + QPoint topLeft = p1; + if (newSize.width() < 0) + { + flipHorz = true; + newSize.rwidth() *= -1; + topLeft.setX(p2.x()); + } + if (newSize.height() < 0) + { + flipVert = true; + newSize.rheight() *= -1; + topLeft.setY(p2.y()); + } + QSize scaledSize = mPixmap.size(); + scaledSize.scale(newSize, mAspectRatioMode); + result = QRect(topLeft, scaledSize); + } else + { + result = QRect(p1, mPixmap.size()); + } + if (flippedHorz) + *flippedHorz = flipHorz; + if (flippedVert) + *flippedVert = flipVert; + return result; +} + +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected + and mSelectedPen when it is. +*/ +QPen QCPItemPixmap::mainPen() const +{ + return mSelected ? mSelectedPen : mPen; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemTracer +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemTracer + \brief Item that sticks to QCPGraph data points + + \image html QCPItemTracer.png "Tracer example. Blue dotted circles are anchors, solid blue discs are positions." + + The tracer can be connected with a QCPGraph via \ref setGraph. Then it will automatically adopt + the coordinate axes of the graph and update its \a position to be on the graph's data. This means + the key stays controllable via \ref setGraphKey, but the value will follow the graph data. If a + QCPGraph is connected, note that setting the coordinates of the tracer item directly via \a + position will have no effect because they will be overriden in the next redraw (this is when the + coordinate update happens). + + If the specified key in \ref setGraphKey is outside the key bounds of the graph, the tracer will + stay at the corresponding end of the graph. + + With \ref setInterpolating you may specify whether the tracer may only stay exactly on data + points or whether it interpolates data points linearly, if given a key that lies between two data + points of the graph. + + The tracer has different visual styles, see \ref setStyle. It is also possible to make the tracer + have no own visual appearance (set the style to \ref tsNone), and just connect other item + positions to the tracer \a position (used as an anchor) via \ref + QCPItemPosition::setParentAnchor. + + \note The tracer position is only automatically updated upon redraws. So when the data of the + graph changes and immediately afterwards (without a redraw) the a position coordinates of the + tracer are retrieved, they will not reflect the updated data of the graph. In this case \ref + updatePosition must be called manually, prior to reading the tracer coordinates. +*/ + +/*! + Creates a tracer item and sets default values. + + The constructed item can be added to the plot with QCustomPlot::addItem. +*/ +QCPItemTracer::QCPItemTracer(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + position(createPosition("position")), + mGraph(0) +{ + position->setCoords(0, 0); + + setBrush(Qt::NoBrush); + setSelectedBrush(Qt::NoBrush); + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue, 2)); + setStyle(tsCrosshair); + setSize(6); + setInterpolating(false); + setGraphKey(0); +} + +QCPItemTracer::~QCPItemTracer() +{ +} + +/*! + Sets the pen that will be used to draw the line of the tracer + + \see setSelectedPen, setBrush +*/ +void QCPItemTracer::setPen(const QPen &pen) +{ + mPen = pen; +} + +/*! + Sets the pen that will be used to draw the line of the tracer when selected + + \see setPen, setSelected +*/ +void QCPItemTracer::setSelectedPen(const QPen &pen) +{ + mSelectedPen = pen; +} + +/*! + Sets the brush that will be used to draw any fills of the tracer + + \see setSelectedBrush, setPen +*/ +void QCPItemTracer::setBrush(const QBrush &brush) +{ + mBrush = brush; +} + +/*! + Sets the brush that will be used to draw any fills of the tracer, when selected. + + \see setBrush, setSelected +*/ +void QCPItemTracer::setSelectedBrush(const QBrush &brush) +{ + mSelectedBrush = brush; +} + +/*! + Sets the size of the tracer in pixels, if the style supports setting a size (e.g. \ref tsSquare + does, \ref tsCrosshair does not). +*/ +void QCPItemTracer::setSize(double size) +{ + mSize = size; +} + +/*! + Sets the style/visual appearance of the tracer. + + If you only want to use the tracer \a position as an anchor for other items, set \a style to + \ref tsNone. +*/ +void QCPItemTracer::setStyle(QCPItemTracer::TracerStyle style) +{ + mStyle = style; +} + +/*! + Sets the QCPGraph this tracer sticks to. The tracer \a position will be set to type + QCPItemPosition::ptPlotCoords and the axes will be set to the axes of \a graph. + + To free the tracer from any graph, set \a graph to 0. The tracer \a position can then be placed + freely like any other item position. This is the state the tracer will assume when its graph gets + deleted while still attached to it. + + \see setGraphKey +*/ +void QCPItemTracer::setGraph(QCPGraph *graph) +{ + if (graph) + { + if (graph->parentPlot() == mParentPlot) + { + position->setType(QCPItemPosition::ptPlotCoords); + position->setAxes(graph->keyAxis(), graph->valueAxis()); + mGraph = graph; + updatePosition(); + } else + qDebug() << Q_FUNC_INFO << "graph isn't in same QCustomPlot instance as this item"; + } else + { + mGraph = 0; + } +} + +/*! + Sets the key of the graph's data point the tracer will be positioned at. This is the only free + coordinate of a tracer when attached to a graph. + + Depending on \ref setInterpolating, the tracer will be either positioned on the data point + closest to \a key, or will stay exactly at \a key and interpolate the value linearly. + + \see setGraph, setInterpolating +*/ +void QCPItemTracer::setGraphKey(double key) +{ + mGraphKey = key; +} + +/*! + Sets whether the value of the graph's data points shall be interpolated, when positioning the + tracer. + + If \a enabled is set to false and a key is given with \ref setGraphKey, the tracer is placed on + the data point of the graph which is closest to the key, but which is not necessarily exactly + there. If \a enabled is true, the tracer will be positioned exactly at the specified key, and + the appropriate value will be interpolated from the graph's data points linearly. + + \see setGraph, setGraphKey +*/ +void QCPItemTracer::setInterpolating(bool enabled) +{ + mInterpolating = enabled; +} + +/* inherits documentation from base class */ +double QCPItemTracer::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + QPointF center(position->pixelPoint()); + double w = mSize/2.0; + QRect clip = clipRect(); + switch (mStyle) + { + case tsNone: return -1; + case tsPlus: + { + if (clipRect().intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + return qSqrt(qMin(distSqrToLine(center+QPointF(-w, 0), center+QPointF(w, 0), pos), + distSqrToLine(center+QPointF(0, -w), center+QPointF(0, w), pos))); + break; + } + case tsCrosshair: + { + return qSqrt(qMin(distSqrToLine(QPointF(clip.left(), center.y()), QPointF(clip.right(), center.y()), pos), + distSqrToLine(QPointF(center.x(), clip.top()), QPointF(center.x(), clip.bottom()), pos))); + } + case tsCircle: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + { + // distance to border: + double centerDist = QVector2D(center-pos).length(); + double circleLine = w; + double result = qAbs(centerDist-circleLine); + // filled ellipse, allow click inside to count as hit: + if (result > mParentPlot->selectionTolerance()*0.99 && mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0) + { + if (centerDist <= circleLine) + result = mParentPlot->selectionTolerance()*0.99; + } + return result; + } + break; + } + case tsSquare: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + { + QRectF rect = QRectF(center-QPointF(w, w), center+QPointF(w, w)); + bool filledRect = mBrush.style() != Qt::NoBrush && mBrush.color().alpha() != 0; + return rectSelectTest(rect, pos, filledRect); + } + break; + } + } + return -1; +} + +/* inherits documentation from base class */ +void QCPItemTracer::draw(QCPPainter *painter) +{ + updatePosition(); + if (mStyle == tsNone) + return; + + painter->setPen(mainPen()); + painter->setBrush(mainBrush()); + QPointF center(position->pixelPoint()); + double w = mSize/2.0; + QRect clip = clipRect(); + switch (mStyle) + { + case tsNone: return; + case tsPlus: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + { + painter->drawLine(QLineF(center+QPointF(-w, 0), center+QPointF(w, 0))); + painter->drawLine(QLineF(center+QPointF(0, -w), center+QPointF(0, w))); + } + break; + } + case tsCrosshair: + { + if (center.y() > clip.top() && center.y() < clip.bottom()) + painter->drawLine(QLineF(clip.left(), center.y(), clip.right(), center.y())); + if (center.x() > clip.left() && center.x() < clip.right()) + painter->drawLine(QLineF(center.x(), clip.top(), center.x(), clip.bottom())); + break; + } + case tsCircle: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + painter->drawEllipse(center, w, w); + break; + } + case tsSquare: + { + if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect())) + painter->drawRect(QRectF(center-QPointF(w, w), center+QPointF(w, w))); + break; + } + } +} + +/*! + If the tracer is connected with a graph (\ref setGraph), this function updates the tracer's \a + position to reside on the graph data, depending on the configured key (\ref setGraphKey). + + It is called automatically on every redraw and normally doesn't need to be called manually. One + exception is when you want to read the tracer coordinates via \a position and are not sure that + the graph's data (or the tracer key with \ref setGraphKey) hasn't changed since the last redraw. + In that situation, call this function before accessing \a position, to make sure you don't get + out-of-date coordinates. + + If there is no graph set on this tracer, this function does nothing. +*/ +void QCPItemTracer::updatePosition() +{ + if (mGraph) + { + if (mParentPlot->hasPlottable(mGraph)) + { + if (mGraph->data()->size() > 1) + { + QCPDataMap::const_iterator first = mGraph->data()->constBegin(); + QCPDataMap::const_iterator last = mGraph->data()->constEnd()-1; + if (mGraphKey < first.key()) + position->setCoords(first.key(), first.value().value); + else if (mGraphKey > last.key()) + position->setCoords(last.key(), last.value().value); + else + { + QCPDataMap::const_iterator it = mGraph->data()->lowerBound(mGraphKey); + if (it != first) // mGraphKey is somewhere between iterators + { + QCPDataMap::const_iterator prevIt = it-1; + if (mInterpolating) + { + // interpolate between iterators around mGraphKey: + double slope = 0; + if (!qFuzzyCompare((double)it.key(), (double)prevIt.key())) + slope = (it.value().value-prevIt.value().value)/(it.key()-prevIt.key()); + position->setCoords(mGraphKey, (mGraphKey-prevIt.key())*slope+prevIt.value().value); + } else + { + // find iterator with key closest to mGraphKey: + if (mGraphKey < (prevIt.key()+it.key())*0.5) + it = prevIt; + position->setCoords(it.key(), it.value().value); + } + } else // mGraphKey is exactly on first iterator + position->setCoords(it.key(), it.value().value); + } + } else if (mGraph->data()->size() == 1) + { + QCPDataMap::const_iterator it = mGraph->data()->constBegin(); + position->setCoords(it.key(), it.value().value); + } else + qDebug() << Q_FUNC_INFO << "graph has no data"; + } else + qDebug() << Q_FUNC_INFO << "graph not contained in QCustomPlot instance (anymore)"; + } +} + +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the item is not selected + and mSelectedPen when it is. +*/ +QPen QCPItemTracer::mainPen() const +{ + return mSelected ? mSelectedPen : mPen; +} + +/*! \internal + + Returns the brush that should be used for drawing fills of the item. Returns mBrush when the item + is not selected and mSelectedBrush when it is. +*/ +QBrush QCPItemTracer::mainBrush() const +{ + return mSelected ? mSelectedBrush : mBrush; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////// QCPItemBracket +//////////////////////////////////////////////////////////////////////////////////////////////////// + +/*! \class QCPItemBracket + \brief A bracket for referencing/highlighting certain parts in the plot. + + \image html QCPItemBracket.png "Bracket example. Blue dotted circles are anchors, solid blue discs are positions." + + It has two positions, \a left and \a right, which define the span of the bracket. If \a left is + actually farther to the left than \a right, the bracket is opened to the bottom, as shown in the + example image. + + The bracket supports multiple styles via \ref setStyle. The length, i.e. how far the bracket + stretches away from the embraced span, can be controlled with \ref setLength. + + \image html QCPItemBracket-length.png +
Demonstrating the effect of different values for \ref setLength, for styles \ref + bsCalligraphic and \ref bsSquare. Anchors and positions are displayed for reference.
+ + It provides an anchor \a center, to allow connection of other items, e.g. an arrow (QCPItemLine + or QCPItemCurve) or a text label (QCPItemText), to the bracket. +*/ + +/*! + Creates a bracket item and sets default values. + + The constructed item can be added to the plot with QCustomPlot::addItem. +*/ +QCPItemBracket::QCPItemBracket(QCustomPlot *parentPlot) : + QCPAbstractItem(parentPlot), + left(createPosition("left")), + right(createPosition("right")), + center(createAnchor("center", aiCenter)) +{ + left->setCoords(0, 0); + right->setCoords(1, 1); + + setPen(QPen(Qt::black)); + setSelectedPen(QPen(Qt::blue, 2)); + setLength(8); + setStyle(bsCalligraphic); +} + +QCPItemBracket::~QCPItemBracket() +{ +} + +/*! + Sets the pen that will be used to draw the bracket. + + Note that when the style is \ref bsCalligraphic, only the color will be taken from the pen, the + stroke and width are ignored. To change the apparent stroke width of a calligraphic bracket, use + \ref setLength, which has a similar effect. + + \see setSelectedPen +*/ +void QCPItemBracket::setPen(const QPen &pen) +{ + mPen = pen; +} + +/*! + Sets the pen that will be used to draw the bracket when selected + + \see setPen, setSelected +*/ +void QCPItemBracket::setSelectedPen(const QPen &pen) +{ + mSelectedPen = pen; +} + +/*! + Sets the \a length in pixels how far the bracket extends in the direction towards the embraced + span of the bracket (i.e. perpendicular to the left-right-direction) + + \image html QCPItemBracket-length.png +
Demonstrating the effect of different values for \ref setLength, for styles \ref + bsCalligraphic and \ref bsSquare. Anchors and positions are displayed for reference.
+*/ +void QCPItemBracket::setLength(double length) +{ + mLength = length; +} + +/*! + Sets the style of the bracket, i.e. the shape/visual appearance. + + \see setPen +*/ +void QCPItemBracket::setStyle(QCPItemBracket::BracketStyle style) +{ + mStyle = style; +} + +/* inherits documentation from base class */ +double QCPItemBracket::selectTest(const QPointF &pos, bool onlySelectable, QVariant *details) const +{ + Q_UNUSED(details) + if (onlySelectable && !mSelectable) + return -1; + + QVector2D leftVec(left->pixelPoint()); + QVector2D rightVec(right->pixelPoint()); + if (leftVec.toPoint() == rightVec.toPoint()) + return -1; + + QVector2D widthVec = (rightVec-leftVec)*0.5f; + QVector2D lengthVec(-widthVec.y(), widthVec.x()); + lengthVec = lengthVec.normalized()*mLength; + QVector2D centerVec = (rightVec+leftVec)*0.5f-lengthVec; + + return qSqrt(distSqrToLine((centerVec-widthVec).toPointF(), (centerVec+widthVec).toPointF(), pos)); +} + +/* inherits documentation from base class */ +void QCPItemBracket::draw(QCPPainter *painter) +{ + QVector2D leftVec(left->pixelPoint()); + QVector2D rightVec(right->pixelPoint()); + if (leftVec.toPoint() == rightVec.toPoint()) + return; + + QVector2D widthVec = (rightVec-leftVec)*0.5f; + QVector2D lengthVec(-widthVec.y(), widthVec.x()); + lengthVec = lengthVec.normalized()*mLength; + QVector2D centerVec = (rightVec+leftVec)*0.5f-lengthVec; + + QPolygon boundingPoly; + boundingPoly << leftVec.toPoint() << rightVec.toPoint() + << (rightVec-lengthVec).toPoint() << (leftVec-lengthVec).toPoint(); + QRect clip = clipRect().adjusted(-mainPen().widthF(), -mainPen().widthF(), mainPen().widthF(), mainPen().widthF()); + if (clip.intersects(boundingPoly.boundingRect())) + { + painter->setPen(mainPen()); + switch (mStyle) + { + case bsSquare: + { + painter->drawLine((centerVec+widthVec).toPointF(), (centerVec-widthVec).toPointF()); + painter->drawLine((centerVec+widthVec).toPointF(), (centerVec+widthVec+lengthVec).toPointF()); + painter->drawLine((centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + break; + } + case bsRound: + { + painter->setBrush(Qt::NoBrush); + QPainterPath path; + path.moveTo((centerVec+widthVec+lengthVec).toPointF()); + path.cubicTo((centerVec+widthVec).toPointF(), (centerVec+widthVec).toPointF(), centerVec.toPointF()); + path.cubicTo((centerVec-widthVec).toPointF(), (centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + painter->drawPath(path); + break; + } + case bsCurly: + { + painter->setBrush(Qt::NoBrush); + QPainterPath path; + path.moveTo((centerVec+widthVec+lengthVec).toPointF()); + path.cubicTo((centerVec+widthVec-lengthVec*0.8f).toPointF(), (centerVec+0.4f*widthVec+lengthVec).toPointF(), centerVec.toPointF()); + path.cubicTo((centerVec-0.4f*widthVec+lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8f).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + painter->drawPath(path); + break; + } + case bsCalligraphic: + { + painter->setPen(Qt::NoPen); + painter->setBrush(QBrush(mainPen().color())); + QPainterPath path; + path.moveTo((centerVec+widthVec+lengthVec).toPointF()); + + path.cubicTo((centerVec+widthVec-lengthVec*0.8f).toPointF(), (centerVec+0.4f*widthVec+0.8f*lengthVec).toPointF(), centerVec.toPointF()); + path.cubicTo((centerVec-0.4f*widthVec+0.8f*lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8f).toPointF(), (centerVec-widthVec+lengthVec).toPointF()); + + path.cubicTo((centerVec-widthVec-lengthVec*0.5f).toPointF(), (centerVec-0.2f*widthVec+1.2f*lengthVec).toPointF(), (centerVec+lengthVec*0.2f).toPointF()); + path.cubicTo((centerVec+0.2f*widthVec+1.2f*lengthVec).toPointF(), (centerVec+widthVec-lengthVec*0.5f).toPointF(), (centerVec+widthVec+lengthVec).toPointF()); + + painter->drawPath(path); + break; + } + } + } +} + +/* inherits documentation from base class */ +QPointF QCPItemBracket::anchorPixelPoint(int anchorId) const +{ + QVector2D leftVec(left->pixelPoint()); + QVector2D rightVec(right->pixelPoint()); + if (leftVec.toPoint() == rightVec.toPoint()) + return leftVec.toPointF(); + + QVector2D widthVec = (rightVec-leftVec)*0.5f; + QVector2D lengthVec(-widthVec.y(), widthVec.x()); + lengthVec = lengthVec.normalized()*mLength; + QVector2D centerVec = (rightVec+leftVec)*0.5f-lengthVec; + + switch (anchorId) + { + case aiCenter: + return centerVec.toPointF(); + } + qDebug() << Q_FUNC_INFO << "invalid anchorId" << anchorId; + return QPointF(); +} + +/*! \internal + + Returns the pen that should be used for drawing lines. Returns mPen when the + item is not selected and mSelectedPen when it is. +*/ +QPen QCPItemBracket::mainPen() const +{ + return mSelected ? mSelectedPen : mPen; +} + diff --git a/src/qt/qcustomplot.h b/src/qt/qcustomplot.h new file mode 100644 index 0000000..f595515 --- /dev/null +++ b/src/qt/qcustomplot.h @@ -0,0 +1,3764 @@ +/*************************************************************************** +** ** +** QCustomPlot, an easy to use, modern plotting widget for Qt ** +** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer ** +** ** +** This program is free software: you can redistribute it and/or modify ** +** it under the terms of the GNU General Public License as published by ** +** the Free Software Foundation, either version 3 of the License, or ** +** (at your option) any later version. ** +** ** +** This program is distributed in the hope that it will be useful, ** +** but WITHOUT ANY WARRANTY; without even the implied warranty of ** +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** +** GNU General Public License for more details. ** +** ** +** You should have received a copy of the GNU General Public License ** +** along with this program. If not, see http://www.gnu.org/licenses/. ** +** ** +**************************************************************************** +** Author: Emanuel Eichhammer ** +** Website/Contact: http://www.qcustomplot.com/ ** +** Date: 11.10.14 ** +** Version: 1.3.0-beta ** +****************************************************************************/ + +#ifndef QCUSTOMPLOT_H +#define QCUSTOMPLOT_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +# include +# include +# include +#else +# include +# include +#endif + +class QCPPainter; +class QCustomPlot; +class QCPLayerable; +class QCPLayoutElement; +class QCPLayout; +class QCPAxis; +class QCPAxisRect; +class QCPAxisPainterPrivate; +class QCPAbstractPlottable; +class QCPGraph; +class QCPAbstractItem; +class QCPItemPosition; +class QCPLayer; +class QCPPlotTitle; +class QCPLegend; +class QCPAbstractLegendItem; +class QCPColorMap; +class QCPColorScale; +class QCPBars; + + +/*! \file */ + + +// decl definitions for shared library compilation/usage: +#if defined(QCUSTOMPLOT_COMPILE_LIBRARY) +# define QCP_LIB_DECL Q_DECL_EXPORT +#elif defined(QCUSTOMPLOT_USE_LIBRARY) +# define QCP_LIB_DECL Q_DECL_IMPORT +#else +# define QCP_LIB_DECL +#endif + +/*! + The QCP Namespace contains general enums and QFlags used throughout the QCustomPlot library +*/ +namespace QCP +{ +/*! + Defines the sides of a rectangular entity to which margins can be applied. + + \see QCPLayoutElement::setAutoMargins, QCPAxisRect::setAutoMargins +*/ +enum MarginSide { msLeft = 0x01 ///< 0x01 left margin + ,msRight = 0x02 ///< 0x02 right margin + ,msTop = 0x04 ///< 0x04 top margin + ,msBottom = 0x08 ///< 0x08 bottom margin + ,msAll = 0xFF ///< 0xFF all margins + ,msNone = 0x00 ///< 0x00 no margin + }; +Q_DECLARE_FLAGS(MarginSides, MarginSide) + +/*! + Defines what objects of a plot can be forcibly drawn antialiased/not antialiased. If an object is + neither forcibly drawn antialiased nor forcibly drawn not antialiased, it is up to the respective + element how it is drawn. Typically it provides a \a setAntialiased function for this. + + \c AntialiasedElements is a flag of or-combined elements of this enum type. + + \see QCustomPlot::setAntialiasedElements, QCustomPlot::setNotAntialiasedElements +*/ +enum AntialiasedElement { aeAxes = 0x0001 ///< 0x0001 Axis base line and tick marks + ,aeGrid = 0x0002 ///< 0x0002 Grid lines + ,aeSubGrid = 0x0004 ///< 0x0004 Sub grid lines + ,aeLegend = 0x0008 ///< 0x0008 Legend box + ,aeLegendItems = 0x0010 ///< 0x0010 Legend items + ,aePlottables = 0x0020 ///< 0x0020 Main lines of plottables (excluding error bars, see element \ref aeErrorBars) + ,aeItems = 0x0040 ///< 0x0040 Main lines of items + ,aeScatters = 0x0080 ///< 0x0080 Scatter symbols of plottables (excluding scatter symbols of type ssPixmap) + ,aeErrorBars = 0x0100 ///< 0x0100 Error bars + ,aeFills = 0x0200 ///< 0x0200 Borders of fills (e.g. under or between graphs) + ,aeZeroLine = 0x0400 ///< 0x0400 Zero-lines, see \ref QCPGrid::setZeroLinePen + ,aeAll = 0xFFFF ///< 0xFFFF All elements + ,aeNone = 0x0000 ///< 0x0000 No elements + }; +Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement) + +/*! + Defines plotting hints that control various aspects of the quality and speed of plotting. + + \see QCustomPlot::setPlottingHints +*/ +enum PlottingHint { phNone = 0x000 ///< 0x000 No hints are set + ,phFastPolylines = 0x001 ///< 0x001 Graph/Curve lines are drawn with a faster method. This reduces the quality + ///< especially of the line segment joins. (Only relevant for solid line pens.) + ,phForceRepaint = 0x002 ///< 0x002 causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called with parameter \ref QCustomPlot::rpHint. + ///< This is set by default to prevent the plot from freezing on fast consecutive replots (e.g. user drags ranges with mouse). + ,phCacheLabels = 0x004 ///< 0x004 axis (tick) labels will be cached as pixmaps, increasing replot performance. + }; +Q_DECLARE_FLAGS(PlottingHints, PlottingHint) + +/*! + Defines the mouse interactions possible with QCustomPlot. + + \c Interactions is a flag of or-combined elements of this enum type. + + \see QCustomPlot::setInteractions +*/ +enum Interaction { iRangeDrag = 0x001 ///< 0x001 Axis ranges are draggable (see \ref QCPAxisRect::setRangeDrag, \ref QCPAxisRect::setRangeDragAxes) + ,iRangeZoom = 0x002 ///< 0x002 Axis ranges are zoomable with the mouse wheel (see \ref QCPAxisRect::setRangeZoom, \ref QCPAxisRect::setRangeZoomAxes) + ,iMultiSelect = 0x004 ///< 0x004 The user can select multiple objects by holding the modifier set by \ref QCustomPlot::setMultiSelectModifier while clicking + ,iSelectPlottables = 0x008 ///< 0x008 Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable) + ,iSelectAxes = 0x010 ///< 0x010 Axes are selectable (or parts of them, see QCPAxis::setSelectableParts) + ,iSelectLegend = 0x020 ///< 0x020 Legends are selectable (or their child items, see QCPLegend::setSelectableParts) + ,iSelectItems = 0x040 ///< 0x040 Items are selectable (Rectangles, Arrows, Textitems, etc. see \ref QCPAbstractItem) + ,iSelectOther = 0x080 ///< 0x080 All other objects are selectable (e.g. your own derived layerables, the plot title,...) + }; +Q_DECLARE_FLAGS(Interactions, Interaction) + +/*! \internal + + Returns whether the specified \a value is considered an invalid data value for plottables (i.e. + is \e nan or \e +/-inf). This function is used to check data validity upon replots, when the + compiler flag \c QCUSTOMPLOT_CHECK_DATA is set. +*/ +inline bool isInvalidData(double value) +{ + return qIsNaN(value) || qIsInf(value); +} + +/*! \internal + \overload + + Checks two arguments instead of one. +*/ +inline bool isInvalidData(double value1, double value2) +{ + return isInvalidData(value1) || isInvalidData(value2); +} + +/*! \internal + + Sets the specified \a side of \a margins to \a value + + \see getMarginValue +*/ +inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value) +{ + switch (side) + { + case QCP::msLeft: margins.setLeft(value); break; + case QCP::msRight: margins.setRight(value); break; + case QCP::msTop: margins.setTop(value); break; + case QCP::msBottom: margins.setBottom(value); break; + case QCP::msAll: margins = QMargins(value, value, value, value); break; + default: break; + } +} + +/*! \internal + + Returns the value of the specified \a side of \a margins. If \a side is \ref QCP::msNone or + \ref QCP::msAll, returns 0. + + \see setMarginValue +*/ +inline int getMarginValue(const QMargins &margins, QCP::MarginSide side) +{ + switch (side) + { + case QCP::msLeft: return margins.left(); + case QCP::msRight: return margins.right(); + case QCP::msTop: return margins.top(); + case QCP::msBottom: return margins.bottom(); + default: break; + } + return 0; +} + +} // end of namespace QCP + +Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements) +Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints) +Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides) +Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions) + + +class QCP_LIB_DECL QCPScatterStyle +{ + Q_GADGET +public: + /*! + Defines the shape used for scatter points. + + On plottables/items that draw scatters, the sizes of these visualizations (with exception of + \ref ssDot and \ref ssPixmap) can be controlled with the \ref setSize function. Scatters are + drawn with the pen and brush specified with \ref setPen and \ref setBrush. + */ + Q_ENUMS(ScatterShape) + enum ScatterShape { ssNone ///< no scatter symbols are drawn (e.g. in QCPGraph, data only represented with lines) + ,ssDot ///< \enumimage{ssDot.png} a single pixel (use \ref ssDisc or \ref ssCircle if you want a round shape with a certain radius) + ,ssCross ///< \enumimage{ssCross.png} a cross + ,ssPlus ///< \enumimage{ssPlus.png} a plus + ,ssCircle ///< \enumimage{ssCircle.png} a circle + ,ssDisc ///< \enumimage{ssDisc.png} a circle which is filled with the pen's color (not the brush as with ssCircle) + ,ssSquare ///< \enumimage{ssSquare.png} a square + ,ssDiamond ///< \enumimage{ssDiamond.png} a diamond + ,ssStar ///< \enumimage{ssStar.png} a star with eight arms, i.e. a combination of cross and plus + ,ssTriangle ///< \enumimage{ssTriangle.png} an equilateral triangle, standing on baseline + ,ssTriangleInverted ///< \enumimage{ssTriangleInverted.png} an equilateral triangle, standing on corner + ,ssCrossSquare ///< \enumimage{ssCrossSquare.png} a square with a cross inside + ,ssPlusSquare ///< \enumimage{ssPlusSquare.png} a square with a plus inside + ,ssCrossCircle ///< \enumimage{ssCrossCircle.png} a circle with a cross inside + ,ssPlusCircle ///< \enumimage{ssPlusCircle.png} a circle with a plus inside + ,ssPeace ///< \enumimage{ssPeace.png} a circle, with one vertical and two downward diagonal lines + ,ssPixmap ///< a custom pixmap specified by \ref setPixmap, centered on the data point coordinates + ,ssCustom ///< custom painter operations are performed per scatter (As QPainterPath, see \ref setCustomPath) + }; + + QCPScatterStyle(); + QCPScatterStyle(ScatterShape shape, double size=6); + QCPScatterStyle(ScatterShape shape, const QColor &color, double size); + QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, double size); + QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBrush &brush, double size); + QCPScatterStyle(const QPixmap &pixmap); + QCPScatterStyle(const QPainterPath &customPath, const QPen &pen, const QBrush &brush=Qt::NoBrush, double size=6); + + // getters: + double size() const { return mSize; } + ScatterShape shape() const { return mShape; } + QPen pen() const { return mPen; } + QBrush brush() const { return mBrush; } + QPixmap pixmap() const { return mPixmap; } + QPainterPath customPath() const { return mCustomPath; } + + // setters: + void setSize(double size); + void setShape(ScatterShape shape); + void setPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setPixmap(const QPixmap &pixmap); + void setCustomPath(const QPainterPath &customPath); + + // non-property methods: + bool isNone() const { return mShape == ssNone; } + bool isPenDefined() const { return mPenDefined; } + void applyTo(QCPPainter *painter, const QPen &defaultPen) const; + void drawShape(QCPPainter *painter, QPointF pos) const; + void drawShape(QCPPainter *painter, double x, double y) const; + +protected: + // property members: + double mSize; + ScatterShape mShape; + QPen mPen; + QBrush mBrush; + QPixmap mPixmap; + QPainterPath mCustomPath; + + // non-property members: + bool mPenDefined; +}; +Q_DECLARE_TYPEINFO(QCPScatterStyle, Q_MOVABLE_TYPE); + + +class QCP_LIB_DECL QCPPainter : public QPainter +{ + Q_GADGET +public: + /*! + Defines special modes the painter can operate in. They disable or enable certain subsets of features/fixes/workarounds, + depending on whether they are wanted on the respective output device. + */ + enum PainterMode { pmDefault = 0x00 ///< 0x00 Default mode for painting on screen devices + ,pmVectorized = 0x01 ///< 0x01 Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fixes. + ,pmNoCaching = 0x02 ///< 0x02 Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixmap labels + ,pmNonCosmetic = 0x04 ///< 0x04 Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width 1 pixel in the vector image/pdf viewer, independent of zoom.) + }; + Q_FLAGS(PainterMode PainterModes) + Q_DECLARE_FLAGS(PainterModes, PainterMode) + + QCPPainter(); + QCPPainter(QPaintDevice *device); + ~QCPPainter(); + + // getters: + bool antialiasing() const { return testRenderHint(QPainter::Antialiasing); } + PainterModes modes() const { return mModes; } + + // setters: + void setAntialiasing(bool enabled); + void setMode(PainterMode mode, bool enabled=true); + void setModes(PainterModes modes); + + // methods hiding non-virtual base class functions (QPainter bug workarounds): + bool begin(QPaintDevice *device); + void setPen(const QPen &pen); + void setPen(const QColor &color); + void setPen(Qt::PenStyle penStyle); + void drawLine(const QLineF &line); + void drawLine(const QPointF &p1, const QPointF &p2) {drawLine(QLineF(p1, p2));} + void save(); + void restore(); + + // non-virtual methods: + void makeNonCosmetic(); + +protected: + // property members: + PainterModes mModes; + bool mIsAntialiasing; + + // non-property members: + QStack mAntialiasingStack; +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPainter::PainterModes) + + +class QCP_LIB_DECL QCPLayer : public QObject +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot) + Q_PROPERTY(QString name READ name) + Q_PROPERTY(int index READ index) + Q_PROPERTY(QList children READ children) + Q_PROPERTY(bool visible READ visible WRITE setVisible) + /// \endcond +public: + QCPLayer(QCustomPlot* parentPlot, const QString &layerName); + ~QCPLayer(); + + // getters: + QCustomPlot *parentPlot() const { return mParentPlot; } + QString name() const { return mName; } + int index() const { return mIndex; } + QList children() const { return mChildren; } + bool visible() const { return mVisible; } + + // setters: + void setVisible(bool visible); + +protected: + // property members: + QCustomPlot *mParentPlot; + QString mName; + int mIndex; + QList mChildren; + bool mVisible; + + // non-virtual methods: + void addChild(QCPLayerable *layerable, bool prepend); + void removeChild(QCPLayerable *layerable); + +private: + Q_DISABLE_COPY(QCPLayer) + + friend class QCustomPlot; + friend class QCPLayerable; +}; + +class QCP_LIB_DECL QCPLayerable : public QObject +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(bool visible READ visible WRITE setVisible) + Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot) + Q_PROPERTY(QCPLayerable* parentLayerable READ parentLayerable) + Q_PROPERTY(QCPLayer* layer READ layer WRITE setLayer NOTIFY layerChanged) + Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased) + /// \endcond +public: + QCPLayerable(QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0); + ~QCPLayerable(); + + // getters: + bool visible() const { return mVisible; } + QCustomPlot *parentPlot() const { return mParentPlot; } + QCPLayerable *parentLayerable() const { return mParentLayerable.data(); } + QCPLayer *layer() const { return mLayer; } + bool antialiased() const { return mAntialiased; } + + // setters: + void setVisible(bool on); + Q_SLOT bool setLayer(QCPLayer *layer); + bool setLayer(const QString &layerName); + void setAntialiased(bool enabled); + + // introduced virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + // non-property methods: + bool realVisibility() const; + +signals: + void layerChanged(QCPLayer *newLayer); + +protected: + // property members: + bool mVisible; + QCustomPlot *mParentPlot; + QPointer mParentLayerable; + QCPLayer *mLayer; + bool mAntialiased; + + // introduced virtual methods: + virtual void parentPlotInitialized(QCustomPlot *parentPlot); + virtual QCP::Interaction selectionCategory() const; + virtual QRect clipRect() const; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const = 0; + virtual void draw(QCPPainter *painter) = 0; + // events: + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); + virtual void deselectEvent(bool *selectionStateChanged); + + // non-property methods: + void initializeParentPlot(QCustomPlot *parentPlot); + void setParentLayerable(QCPLayerable* parentLayerable); + bool moveToLayer(QCPLayer *layer, bool prepend); + void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const; + +private: + Q_DISABLE_COPY(QCPLayerable) + + friend class QCustomPlot; + friend class QCPAxisRect; +}; + + +class QCP_LIB_DECL QCPRange +{ +public: + double lower, upper; + + QCPRange(); + QCPRange(double lower, double upper); + + bool operator==(const QCPRange& other) const { return lower == other.lower && upper == other.upper; } + bool operator!=(const QCPRange& other) const { return !(*this == other); } + + QCPRange &operator+=(const double& value) { lower+=value; upper+=value; return *this; } + QCPRange &operator-=(const double& value) { lower-=value; upper-=value; return *this; } + QCPRange &operator*=(const double& value) { lower*=value; upper*=value; return *this; } + QCPRange &operator/=(const double& value) { lower/=value; upper/=value; return *this; } + friend inline const QCPRange operator+(const QCPRange&, double); + friend inline const QCPRange operator+(double, const QCPRange&); + friend inline const QCPRange operator-(const QCPRange& range, double value); + friend inline const QCPRange operator*(const QCPRange& range, double value); + friend inline const QCPRange operator*(double value, const QCPRange& range); + friend inline const QCPRange operator/(const QCPRange& range, double value); + + double size() const; + double center() const; + void normalize(); + void expand(const QCPRange &otherRange); + QCPRange expanded(const QCPRange &otherRange) const; + QCPRange sanitizedForLogScale() const; + QCPRange sanitizedForLinScale() const; + bool contains(double value) const; + + static bool validRange(double lower, double upper); + static bool validRange(const QCPRange &range); + static const double minRange; //1e-280; + static const double maxRange; //1e280; + +}; +Q_DECLARE_TYPEINFO(QCPRange, Q_MOVABLE_TYPE); + +/* documentation of inline functions */ + +/*! \fn QCPRange &QCPRange::operator+=(const double& value) + + Adds \a value to both boundaries of the range. +*/ + +/*! \fn QCPRange &QCPRange::operator-=(const double& value) + + Subtracts \a value from both boundaries of the range. +*/ + +/*! \fn QCPRange &QCPRange::operator*=(const double& value) + + Multiplies both boundaries of the range by \a value. +*/ + +/*! \fn QCPRange &QCPRange::operator/=(const double& value) + + Divides both boundaries of the range by \a value. +*/ + +/* end documentation of inline functions */ + +/*! + Adds \a value to both boundaries of the range. +*/ +inline const QCPRange operator+(const QCPRange& range, double value) +{ + QCPRange result(range); + result += value; + return result; +} + +/*! + Adds \a value to both boundaries of the range. +*/ +inline const QCPRange operator+(double value, const QCPRange& range) +{ + QCPRange result(range); + result += value; + return result; +} + +/*! + Subtracts \a value from both boundaries of the range. +*/ +inline const QCPRange operator-(const QCPRange& range, double value) +{ + QCPRange result(range); + result -= value; + return result; +} + +/*! + Multiplies both boundaries of the range by \a value. +*/ +inline const QCPRange operator*(const QCPRange& range, double value) +{ + QCPRange result(range); + result *= value; + return result; +} + +/*! + Multiplies both boundaries of the range by \a value. +*/ +inline const QCPRange operator*(double value, const QCPRange& range) +{ + QCPRange result(range); + result *= value; + return result; +} + +/*! + Divides both boundaries of the range by \a value. +*/ +inline const QCPRange operator/(const QCPRange& range, double value) +{ + QCPRange result(range); + result /= value; + return result; +} + + +class QCP_LIB_DECL QCPMarginGroup : public QObject +{ + Q_OBJECT +public: + QCPMarginGroup(QCustomPlot *parentPlot); + ~QCPMarginGroup(); + + // non-virtual methods: + QList elements(QCP::MarginSide side) const { return mChildren.value(side); } + bool isEmpty() const; + void clear(); + +protected: + // non-property members: + QCustomPlot *mParentPlot; + QHash > mChildren; + + // non-virtual methods: + int commonMargin(QCP::MarginSide side) const; + void addChild(QCP::MarginSide side, QCPLayoutElement *element); + void removeChild(QCP::MarginSide side, QCPLayoutElement *element); + +private: + Q_DISABLE_COPY(QCPMarginGroup) + + friend class QCPLayoutElement; +}; + + +class QCP_LIB_DECL QCPLayoutElement : public QCPLayerable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QCPLayout* layout READ layout) + Q_PROPERTY(QRect rect READ rect) + Q_PROPERTY(QRect outerRect READ outerRect WRITE setOuterRect) + Q_PROPERTY(QMargins margins READ margins WRITE setMargins) + Q_PROPERTY(QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins) + Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize) + Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize) + /// \endcond +public: + /*! + Defines the phases of the update process, that happens just before a replot. At each phase, + \ref update is called with the according UpdatePhase value. + */ + enum UpdatePhase { upPreparation ///< Phase used for any type of preparation that needs to be done before margin calculation and layout + ,upMargins ///< Phase in which the margins are calculated and set + ,upLayout ///< Final phase in which the layout system places the rects of the elements + }; + Q_ENUMS(UpdatePhase) + + explicit QCPLayoutElement(QCustomPlot *parentPlot=0); + virtual ~QCPLayoutElement(); + + // getters: + QCPLayout *layout() const { return mParentLayout; } + QRect rect() const { return mRect; } + QRect outerRect() const { return mOuterRect; } + QMargins margins() const { return mMargins; } + QMargins minimumMargins() const { return mMinimumMargins; } + QCP::MarginSides autoMargins() const { return mAutoMargins; } + QSize minimumSize() const { return mMinimumSize; } + QSize maximumSize() const { return mMaximumSize; } + QCPMarginGroup *marginGroup(QCP::MarginSide side) const { return mMarginGroups.value(side, (QCPMarginGroup*)0); } + QHash marginGroups() const { return mMarginGroups; } + + // setters: + void setOuterRect(const QRect &rect); + void setMargins(const QMargins &margins); + void setMinimumMargins(const QMargins &margins); + void setAutoMargins(QCP::MarginSides sides); + void setMinimumSize(const QSize &size); + void setMinimumSize(int width, int height); + void setMaximumSize(const QSize &size); + void setMaximumSize(int width, int height); + void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group); + + // introduced virtual methods: + virtual void update(UpdatePhase phase); + virtual QSize minimumSizeHint() const; + virtual QSize maximumSizeHint() const; + virtual QList elements(bool recursive) const; + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + +protected: + // property members: + QCPLayout *mParentLayout; + QSize mMinimumSize, mMaximumSize; + QRect mRect, mOuterRect; + QMargins mMargins, mMinimumMargins; + QCP::MarginSides mAutoMargins; + QHash mMarginGroups; + + // introduced virtual methods: + virtual int calculateAutoMargin(QCP::MarginSide side); + // events: + virtual void mousePressEvent(QMouseEvent *event) {Q_UNUSED(event)} + virtual void mouseMoveEvent(QMouseEvent *event) {Q_UNUSED(event)} + virtual void mouseReleaseEvent(QMouseEvent *event) {Q_UNUSED(event)} + virtual void mouseDoubleClickEvent(QMouseEvent *event) {Q_UNUSED(event)} + virtual void wheelEvent(QWheelEvent *event) {Q_UNUSED(event)} + + // reimplemented virtual methods: + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const { Q_UNUSED(painter) } + virtual void draw(QCPPainter *painter) { Q_UNUSED(painter) } + virtual void parentPlotInitialized(QCustomPlot *parentPlot); + +private: + Q_DISABLE_COPY(QCPLayoutElement) + + friend class QCustomPlot; + friend class QCPLayout; + friend class QCPMarginGroup; +}; + + +class QCP_LIB_DECL QCPLayout : public QCPLayoutElement +{ + Q_OBJECT +public: + explicit QCPLayout(); + + // reimplemented virtual methods: + virtual void update(UpdatePhase phase); + virtual QList elements(bool recursive) const; + + // introduced virtual methods: + virtual int elementCount() const = 0; + virtual QCPLayoutElement* elementAt(int index) const = 0; + virtual QCPLayoutElement* takeAt(int index) = 0; + virtual bool take(QCPLayoutElement* element) = 0; + virtual void simplify(); + + // non-virtual methods: + bool removeAt(int index); + bool remove(QCPLayoutElement* element); + void clear(); + +protected: + // introduced virtual methods: + virtual void updateLayout(); + + // non-virtual methods: + void sizeConstraintsChanged() const; + void adoptElement(QCPLayoutElement *el); + void releaseElement(QCPLayoutElement *el); + QVector getSectionSizes(QVector maxSizes, QVector minSizes, QVector stretchFactors, int totalSize) const; + +private: + Q_DISABLE_COPY(QCPLayout) + friend class QCPLayoutElement; +}; + + +class QCP_LIB_DECL QCPLayoutGrid : public QCPLayout +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(int rowCount READ rowCount) + Q_PROPERTY(int columnCount READ columnCount) + Q_PROPERTY(QList columnStretchFactors READ columnStretchFactors WRITE setColumnStretchFactors) + Q_PROPERTY(QList rowStretchFactors READ rowStretchFactors WRITE setRowStretchFactors) + Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing) + Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing) + /// \endcond +public: + explicit QCPLayoutGrid(); + virtual ~QCPLayoutGrid(); + + // getters: + int rowCount() const; + int columnCount() const; + QList columnStretchFactors() const { return mColumnStretchFactors; } + QList rowStretchFactors() const { return mRowStretchFactors; } + int columnSpacing() const { return mColumnSpacing; } + int rowSpacing() const { return mRowSpacing; } + + // setters: + void setColumnStretchFactor(int column, double factor); + void setColumnStretchFactors(const QList &factors); + void setRowStretchFactor(int row, double factor); + void setRowStretchFactors(const QList &factors); + void setColumnSpacing(int pixels); + void setRowSpacing(int pixels); + + // reimplemented virtual methods: + virtual void updateLayout(); + virtual int elementCount() const; + virtual QCPLayoutElement* elementAt(int index) const; + virtual QCPLayoutElement* takeAt(int index); + virtual bool take(QCPLayoutElement* element); + virtual QList elements(bool recursive) const; + virtual void simplify(); + virtual QSize minimumSizeHint() const; + virtual QSize maximumSizeHint() const; + + // non-virtual methods: + QCPLayoutElement *element(int row, int column) const; + bool addElement(int row, int column, QCPLayoutElement *element); + bool hasElement(int row, int column); + void expandTo(int newRowCount, int newColumnCount); + void insertRow(int newIndex); + void insertColumn(int newIndex); + +protected: + // property members: + QList > mElements; + QList mColumnStretchFactors; + QList mRowStretchFactors; + int mColumnSpacing, mRowSpacing; + + // non-virtual methods: + void getMinimumRowColSizes(QVector *minColWidths, QVector *minRowHeights) const; + void getMaximumRowColSizes(QVector *maxColWidths, QVector *maxRowHeights) const; + +private: + Q_DISABLE_COPY(QCPLayoutGrid) +}; + + +class QCP_LIB_DECL QCPLayoutInset : public QCPLayout +{ + Q_OBJECT +public: + /*! + Defines how the placement and sizing is handled for a certain element in a QCPLayoutInset. + */ + enum InsetPlacement { ipFree ///< The element may be positioned/sized arbitrarily, see \ref setInsetRect + ,ipBorderAligned ///< The element is aligned to one of the layout sides, see \ref setInsetAlignment + }; + + explicit QCPLayoutInset(); + virtual ~QCPLayoutInset(); + + // getters: + InsetPlacement insetPlacement(int index) const; + Qt::Alignment insetAlignment(int index) const; + QRectF insetRect(int index) const; + + // setters: + void setInsetPlacement(int index, InsetPlacement placement); + void setInsetAlignment(int index, Qt::Alignment alignment); + void setInsetRect(int index, const QRectF &rect); + + // reimplemented virtual methods: + virtual void updateLayout(); + virtual int elementCount() const; + virtual QCPLayoutElement* elementAt(int index) const; + virtual QCPLayoutElement* takeAt(int index); + virtual bool take(QCPLayoutElement* element); + virtual void simplify() {} + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + // non-virtual methods: + void addElement(QCPLayoutElement *element, Qt::Alignment alignment); + void addElement(QCPLayoutElement *element, const QRectF &rect); + +protected: + // property members: + QList mElements; + QList mInsetPlacement; + QList mInsetAlignment; + QList mInsetRect; + +private: + Q_DISABLE_COPY(QCPLayoutInset) +}; + + +class QCP_LIB_DECL QCPLineEnding +{ + Q_GADGET +public: + /*! + Defines the type of ending decoration for line-like items, e.g. an arrow. + + \image html QCPLineEnding.png + + The width and length of these decorations can be controlled with the functions \ref setWidth + and \ref setLength. Some decorations like \ref esDisc, \ref esSquare, \ref esDiamond and \ref esBar only + support a width, the length property is ignored. + + \see QCPItemLine::setHead, QCPItemLine::setTail, QCPItemCurve::setHead, QCPItemCurve::setTail, QCPAxis::setLowerEnding, QCPAxis::setUpperEnding + */ + Q_ENUMS(EndingStyle) + enum EndingStyle { esNone ///< No ending decoration + ,esFlatArrow ///< A filled arrow head with a straight/flat back (a triangle) + ,esSpikeArrow ///< A filled arrow head with an indented back + ,esLineArrow ///< A non-filled arrow head with open back + ,esDisc ///< A filled circle + ,esSquare ///< A filled square + ,esDiamond ///< A filled diamond (45° rotated square) + ,esBar ///< A bar perpendicular to the line + ,esHalfBar ///< A bar perpendicular to the line, pointing out to only one side (to which side can be changed with \ref setInverted) + ,esSkewedBar ///< A bar that is skewed (skew controllable via \ref setLength) + }; + + QCPLineEnding(); + QCPLineEnding(EndingStyle style, double width=8, double length=10, bool inverted=false); + + // getters: + EndingStyle style() const { return mStyle; } + double width() const { return mWidth; } + double length() const { return mLength; } + bool inverted() const { return mInverted; } + + // setters: + void setStyle(EndingStyle style); + void setWidth(double width); + void setLength(double length); + void setInverted(bool inverted); + + // non-property methods: + double boundingDistance() const; + double realLength() const; + void draw(QCPPainter *painter, const QVector2D &pos, const QVector2D &dir) const; + void draw(QCPPainter *painter, const QVector2D &pos, double angle) const; + +protected: + // property members: + EndingStyle mStyle; + double mWidth, mLength; + bool mInverted; +}; +Q_DECLARE_TYPEINFO(QCPLineEnding, Q_MOVABLE_TYPE); + + +class QCP_LIB_DECL QCPGrid :public QCPLayerable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible) + Q_PROPERTY(bool antialiasedSubGrid READ antialiasedSubGrid WRITE setAntialiasedSubGrid) + Q_PROPERTY(bool antialiasedZeroLine READ antialiasedZeroLine WRITE setAntialiasedZeroLine) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen) + Q_PROPERTY(QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen) + /// \endcond +public: + QCPGrid(QCPAxis *parentAxis); + + // getters: + bool subGridVisible() const { return mSubGridVisible; } + bool antialiasedSubGrid() const { return mAntialiasedSubGrid; } + bool antialiasedZeroLine() const { return mAntialiasedZeroLine; } + QPen pen() const { return mPen; } + QPen subGridPen() const { return mSubGridPen; } + QPen zeroLinePen() const { return mZeroLinePen; } + + // setters: + void setSubGridVisible(bool visible); + void setAntialiasedSubGrid(bool enabled); + void setAntialiasedZeroLine(bool enabled); + void setPen(const QPen &pen); + void setSubGridPen(const QPen &pen); + void setZeroLinePen(const QPen &pen); + +protected: + // property members: + bool mSubGridVisible; + bool mAntialiasedSubGrid, mAntialiasedZeroLine; + QPen mPen, mSubGridPen, mZeroLinePen; + // non-property members: + QCPAxis *mParentAxis; + + // reimplemented virtual methods: + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + virtual void draw(QCPPainter *painter); + + // non-virtual methods: + void drawGridLines(QCPPainter *painter) const; + void drawSubGridLines(QCPPainter *painter) const; + + friend class QCPAxis; +}; + + +class QCP_LIB_DECL QCPAxis : public QCPLayerable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(AxisType axisType READ axisType) + Q_PROPERTY(QCPAxisRect* axisRect READ axisRect) + Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged) + Q_PROPERTY(double scaleLogBase READ scaleLogBase WRITE setScaleLogBase) + Q_PROPERTY(QCPRange range READ range WRITE setRange NOTIFY rangeChanged) + Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed) + Q_PROPERTY(bool autoTicks READ autoTicks WRITE setAutoTicks) + Q_PROPERTY(int autoTickCount READ autoTickCount WRITE setAutoTickCount) + Q_PROPERTY(bool autoTickLabels READ autoTickLabels WRITE setAutoTickLabels) + Q_PROPERTY(bool autoTickStep READ autoTickStep WRITE setAutoTickStep) + Q_PROPERTY(bool autoSubTicks READ autoSubTicks WRITE setAutoSubTicks) + Q_PROPERTY(bool ticks READ ticks WRITE setTicks) + Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels) + Q_PROPERTY(int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding) + Q_PROPERTY(LabelType tickLabelType READ tickLabelType WRITE setTickLabelType) + Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont) + Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor) + Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation) + Q_PROPERTY(LabelSide tickLabelSide READ tickLabelSide WRITE setTickLabelSide) + Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat) + Q_PROPERTY(Qt::TimeSpec dateTimeSpec READ dateTimeSpec WRITE setDateTimeSpec) + Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat) + Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision) + Q_PROPERTY(double tickStep READ tickStep WRITE setTickStep) + Q_PROPERTY(QVector tickVector READ tickVector WRITE setTickVector) + Q_PROPERTY(QVector tickVectorLabels READ tickVectorLabels WRITE setTickVectorLabels) + Q_PROPERTY(int tickLengthIn READ tickLengthIn WRITE setTickLengthIn) + Q_PROPERTY(int tickLengthOut READ tickLengthOut WRITE setTickLengthOut) + Q_PROPERTY(int subTickCount READ subTickCount WRITE setSubTickCount) + Q_PROPERTY(int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn) + Q_PROPERTY(int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut) + Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen) + Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen) + Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen) + Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont) + Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor) + Q_PROPERTY(QString label READ label WRITE setLabel) + Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding) + Q_PROPERTY(int padding READ padding WRITE setPadding) + Q_PROPERTY(int offset READ offset WRITE setOffset) + Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectionChanged) + Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectableChanged) + Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE setSelectedTickLabelFont) + Q_PROPERTY(QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont) + Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE setSelectedTickLabelColor) + Q_PROPERTY(QColor selectedLabelColor READ selectedLabelColor WRITE setSelectedLabelColor) + Q_PROPERTY(QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen) + Q_PROPERTY(QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen) + Q_PROPERTY(QPen selectedSubTickPen READ selectedSubTickPen WRITE setSelectedSubTickPen) + Q_PROPERTY(QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding) + Q_PROPERTY(QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding) + Q_PROPERTY(QCPGrid* grid READ grid) + /// \endcond +public: + /*! + Defines at which side of the axis rect the axis will appear. This also affects how the tick + marks are drawn, on which side the labels are placed etc. + */ + enum AxisType { atLeft = 0x01 ///< 0x01 Axis is vertical and on the left side of the axis rect + ,atRight = 0x02 ///< 0x02 Axis is vertical and on the right side of the axis rect + ,atTop = 0x04 ///< 0x04 Axis is horizontal and on the top side of the axis rect + ,atBottom = 0x08 ///< 0x08 Axis is horizontal and on the bottom side of the axis rect + }; + Q_FLAGS(AxisType AxisTypes) + Q_DECLARE_FLAGS(AxisTypes, AxisType) + /*! + When automatic tick label generation is enabled (\ref setAutoTickLabels), defines how the + coordinate of the tick is interpreted, i.e. translated into a string. + + \see setTickLabelType + */ + enum LabelType { ltNumber ///< Tick coordinate is regarded as normal number and will be displayed as such. (see \ref setNumberFormat) + ,ltDateTime ///< Tick coordinate is regarded as a date/time (seconds since 1970-01-01T00:00:00 UTC) and will be displayed and formatted as such. (for details, see \ref setDateTimeFormat) + }; + Q_ENUMS(LabelType) + /*! + Defines on which side of the axis the tick labels (numbers) shall appear. + + \see setTickLabelSide + */ + enum LabelSide { lsInside ///< Tick labels will be displayed inside the axis rect and clipped to the inner axis rect + ,lsOutside ///< Tick labels will be displayed outside the axis rect + }; + Q_ENUMS(LabelSide) + /*! + Defines the scale of an axis. + \see setScaleType + */ + enum ScaleType { stLinear ///< Linear scaling + ,stLogarithmic ///< Logarithmic scaling with correspondingly transformed plots and (major) tick marks at every base power (see \ref setScaleLogBase). + }; + Q_ENUMS(ScaleType) + /*! + Defines the selectable parts of an axis. + \see setSelectableParts, setSelectedParts + */ + enum SelectablePart { spNone = 0 ///< None of the selectable parts + ,spAxis = 0x001 ///< The axis backbone and tick marks + ,spTickLabels = 0x002 ///< Tick labels (numbers) of this axis (as a whole, not individually) + ,spAxisLabel = 0x004 ///< The axis label + }; + Q_FLAGS(SelectablePart SelectableParts) + Q_DECLARE_FLAGS(SelectableParts, SelectablePart) + + explicit QCPAxis(QCPAxisRect *parent, AxisType type); + virtual ~QCPAxis(); + + // getters: + AxisType axisType() const { return mAxisType; } + QCPAxisRect *axisRect() const { return mAxisRect; } + ScaleType scaleType() const { return mScaleType; } + double scaleLogBase() const { return mScaleLogBase; } + const QCPRange range() const { return mRange; } + bool rangeReversed() const { return mRangeReversed; } + bool autoTicks() const { return mAutoTicks; } + int autoTickCount() const { return mAutoTickCount; } + bool autoTickLabels() const { return mAutoTickLabels; } + bool autoTickStep() const { return mAutoTickStep; } + bool autoSubTicks() const { return mAutoSubTicks; } + bool ticks() const { return mTicks; } + bool tickLabels() const { return mTickLabels; } + int tickLabelPadding() const; + LabelType tickLabelType() const { return mTickLabelType; } + QFont tickLabelFont() const { return mTickLabelFont; } + QColor tickLabelColor() const { return mTickLabelColor; } + double tickLabelRotation() const; + LabelSide tickLabelSide() const; + QString dateTimeFormat() const { return mDateTimeFormat; } + Qt::TimeSpec dateTimeSpec() const { return mDateTimeSpec; } + QString numberFormat() const; + int numberPrecision() const { return mNumberPrecision; } + double tickStep() const { return mTickStep; } + QVector tickVector() const { return mTickVector; } + QVector tickVectorLabels() const { return mTickVectorLabels; } + int tickLengthIn() const; + int tickLengthOut() const; + int subTickCount() const { return mSubTickCount; } + int subTickLengthIn() const; + int subTickLengthOut() const; + QPen basePen() const { return mBasePen; } + QPen tickPen() const { return mTickPen; } + QPen subTickPen() const { return mSubTickPen; } + QFont labelFont() const { return mLabelFont; } + QColor labelColor() const { return mLabelColor; } + QString label() const { return mLabel; } + int labelPadding() const; + int padding() const { return mPadding; } + int offset() const; + SelectableParts selectedParts() const { return mSelectedParts; } + SelectableParts selectableParts() const { return mSelectableParts; } + QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; } + QFont selectedLabelFont() const { return mSelectedLabelFont; } + QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; } + QColor selectedLabelColor() const { return mSelectedLabelColor; } + QPen selectedBasePen() const { return mSelectedBasePen; } + QPen selectedTickPen() const { return mSelectedTickPen; } + QPen selectedSubTickPen() const { return mSelectedSubTickPen; } + QCPLineEnding lowerEnding() const; + QCPLineEnding upperEnding() const; + QCPGrid *grid() const { return mGrid; } + + // setters: + Q_SLOT void setScaleType(QCPAxis::ScaleType type); + void setScaleLogBase(double base); + Q_SLOT void setRange(const QCPRange &range); + void setRange(double lower, double upper); + void setRange(double position, double size, Qt::AlignmentFlag alignment); + void setRangeLower(double lower); + void setRangeUpper(double upper); + void setRangeReversed(bool reversed); + void setAutoTicks(bool on); + void setAutoTickCount(int approximateCount); + void setAutoTickLabels(bool on); + void setAutoTickStep(bool on); + void setAutoSubTicks(bool on); + void setTicks(bool show); + void setTickLabels(bool show); + void setTickLabelPadding(int padding); + void setTickLabelType(LabelType type); + void setTickLabelFont(const QFont &font); + void setTickLabelColor(const QColor &color); + void setTickLabelRotation(double degrees); + void setTickLabelSide(LabelSide side); + void setDateTimeFormat(const QString &format); + void setDateTimeSpec(const Qt::TimeSpec &timeSpec); + void setNumberFormat(const QString &formatCode); + void setNumberPrecision(int precision); + void setTickStep(double step); + void setTickVector(const QVector &vec); + void setTickVectorLabels(const QVector &vec); + void setTickLength(int inside, int outside=0); + void setTickLengthIn(int inside); + void setTickLengthOut(int outside); + void setSubTickCount(int count); + void setSubTickLength(int inside, int outside=0); + void setSubTickLengthIn(int inside); + void setSubTickLengthOut(int outside); + void setBasePen(const QPen &pen); + void setTickPen(const QPen &pen); + void setSubTickPen(const QPen &pen); + void setLabelFont(const QFont &font); + void setLabelColor(const QColor &color); + void setLabel(const QString &str); + void setLabelPadding(int padding); + void setPadding(int padding); + void setOffset(int offset); + void setSelectedTickLabelFont(const QFont &font); + void setSelectedLabelFont(const QFont &font); + void setSelectedTickLabelColor(const QColor &color); + void setSelectedLabelColor(const QColor &color); + void setSelectedBasePen(const QPen &pen); + void setSelectedTickPen(const QPen &pen); + void setSelectedSubTickPen(const QPen &pen); + Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts); + Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts); + void setLowerEnding(const QCPLineEnding &ending); + void setUpperEnding(const QCPLineEnding &ending); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + // non-property methods: + Qt::Orientation orientation() const { return mOrientation; } + void moveRange(double diff); + void scaleRange(double factor, double center); + void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0); + void rescale(bool onlyVisiblePlottables=false); + double pixelToCoord(double value) const; + double coordToPixel(double value) const; + SelectablePart getPartAt(const QPointF &pos) const; + QList plottables() const; + QList graphs() const; + QList items() const; + + static AxisType marginSideToAxisType(QCP::MarginSide side); + static Qt::Orientation orientation(AxisType type) { return type==atBottom||type==atTop ? Qt::Horizontal : Qt::Vertical; } + static AxisType opposite(AxisType type); + +signals: + void ticksRequest(); + void rangeChanged(const QCPRange &newRange); + void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange); + void scaleTypeChanged(QCPAxis::ScaleType scaleType); + void selectionChanged(const QCPAxis::SelectableParts &parts); + void selectableChanged(const QCPAxis::SelectableParts &parts); + +protected: + // property members: + // axis base: + AxisType mAxisType; + QCPAxisRect *mAxisRect; + //int mOffset; // in QCPAxisPainter + int mPadding; + Qt::Orientation mOrientation; + SelectableParts mSelectableParts, mSelectedParts; + QPen mBasePen, mSelectedBasePen; + //QCPLineEnding mLowerEnding, mUpperEnding; // in QCPAxisPainter + // axis label: + //int mLabelPadding; // in QCPAxisPainter + QString mLabel; + QFont mLabelFont, mSelectedLabelFont; + QColor mLabelColor, mSelectedLabelColor; + // tick labels: + //int mTickLabelPadding; // in QCPAxisPainter + bool mTickLabels, mAutoTickLabels; + //double mTickLabelRotation; // in QCPAxisPainter + LabelType mTickLabelType; + QFont mTickLabelFont, mSelectedTickLabelFont; + QColor mTickLabelColor, mSelectedTickLabelColor; + QString mDateTimeFormat; + Qt::TimeSpec mDateTimeSpec; + int mNumberPrecision; + char mNumberFormatChar; + bool mNumberBeautifulPowers; + //bool mNumberMultiplyCross; // QCPAxisPainter + // ticks and subticks: + bool mTicks; + double mTickStep; + int mSubTickCount, mAutoTickCount; + bool mAutoTicks, mAutoTickStep, mAutoSubTicks; + //int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut; // QCPAxisPainter + QPen mTickPen, mSelectedTickPen; + QPen mSubTickPen, mSelectedSubTickPen; + // scale and range: + QCPRange mRange; + bool mRangeReversed; + ScaleType mScaleType; + double mScaleLogBase, mScaleLogBaseLogInv; + + // non-property members: + QCPGrid *mGrid; + QCPAxisPainterPrivate *mAxisPainter; + int mLowestVisibleTick, mHighestVisibleTick; + QVector mTickVector; + QVector mTickVectorLabels; + QVector mSubTickVector; + bool mCachedMarginValid; + int mCachedMargin; + + // introduced virtual methods: + virtual void setupTickVectors(); + virtual void generateAutoTicks(); + virtual int calculateAutoSubTickCount(double tickStep) const; + virtual int calculateMargin(); + + // reimplemented virtual methods: + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + virtual void draw(QCPPainter *painter); + virtual QCP::Interaction selectionCategory() const; + // events: + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); + virtual void deselectEvent(bool *selectionStateChanged); + + // non-virtual methods: + void visibleTickBounds(int &lowIndex, int &highIndex) const; + double baseLog(double value) const; + double basePow(double value) const; + QPen getBasePen() const; + QPen getTickPen() const; + QPen getSubTickPen() const; + QFont getTickLabelFont() const; + QFont getLabelFont() const; + QColor getTickLabelColor() const; + QColor getLabelColor() const; + +private: + Q_DISABLE_COPY(QCPAxis) + + friend class QCustomPlot; + friend class QCPGrid; + friend class QCPAxisRect; +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::SelectableParts) +Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::AxisTypes) +Q_DECLARE_METATYPE(QCPAxis::SelectablePart) + + +class QCPAxisPainterPrivate +{ +public: + explicit QCPAxisPainterPrivate(QCustomPlot *parentPlot); + virtual ~QCPAxisPainterPrivate(); + + virtual void draw(QCPPainter *painter); + virtual int size() const; + void clearCache(); + + QRect axisSelectionBox() const { return mAxisSelectionBox; } + QRect tickLabelsSelectionBox() const { return mTickLabelsSelectionBox; } + QRect labelSelectionBox() const { return mLabelSelectionBox; } + + // public property members: + QCPAxis::AxisType type; + QPen basePen; + QCPLineEnding lowerEnding, upperEnding; // directly accessed by QCPAxis setters/getters + int labelPadding; // directly accessed by QCPAxis setters/getters + QFont labelFont; + QColor labelColor; + QString label; + int tickLabelPadding; // directly accessed by QCPAxis setters/getters + double tickLabelRotation; // directly accessed by QCPAxis setters/getters + QCPAxis::LabelSide tickLabelSide; // directly accessed by QCPAxis setters/getters + bool substituteExponent; + bool numberMultiplyCross; // directly accessed by QCPAxis setters/getters + int tickLengthIn, tickLengthOut, subTickLengthIn, subTickLengthOut; // directly accessed by QCPAxis setters/getters + QPen tickPen, subTickPen; + QFont tickLabelFont; + QColor tickLabelColor; + QRect axisRect, viewportRect; + double offset; // directly accessed by QCPAxis setters/getters + bool abbreviateDecimalPowers; + bool reversedEndings; + + QVector subTickPositions; + QVector tickPositions; + QVector tickLabels; + +protected: + struct CachedLabel + { + QPointF offset; + QPixmap pixmap; + }; + struct TickLabelData + { + QString basePart, expPart; + QRect baseBounds, expBounds, totalBounds, rotatedTotalBounds; + QFont baseFont, expFont; + }; + QCustomPlot *mParentPlot; + QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to be cleared due to changed parameters + QCache mLabelCache; + QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox; + + virtual QByteArray generateLabelParameterHash() const; + + virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize); + virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const; + virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const; + virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const; + virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const; +}; + + +class QCP_LIB_DECL QCPAbstractPlottable : public QCPLayerable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(bool antialiasedFill READ antialiasedFill WRITE setAntialiasedFill) + Q_PROPERTY(bool antialiasedScatters READ antialiasedScatters WRITE setAntialiasedScatters) + Q_PROPERTY(bool antialiasedErrorBars READ antialiasedErrorBars WRITE setAntialiasedErrorBars) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) + Q_PROPERTY(QCPAxis* keyAxis READ keyAxis WRITE setKeyAxis) + Q_PROPERTY(QCPAxis* valueAxis READ valueAxis WRITE setValueAxis) + Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged) + Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged) + /// \endcond +public: + QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis); + + // getters: + QString name() const { return mName; } + bool antialiasedFill() const { return mAntialiasedFill; } + bool antialiasedScatters() const { return mAntialiasedScatters; } + bool antialiasedErrorBars() const { return mAntialiasedErrorBars; } + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + QBrush brush() const { return mBrush; } + QBrush selectedBrush() const { return mSelectedBrush; } + QCPAxis *keyAxis() const { return mKeyAxis.data(); } + QCPAxis *valueAxis() const { return mValueAxis.data(); } + bool selectable() const { return mSelectable; } + bool selected() const { return mSelected; } + + // setters: + void setName(const QString &name); + void setAntialiasedFill(bool enabled); + void setAntialiasedScatters(bool enabled); + void setAntialiasedErrorBars(bool enabled); + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); + void setKeyAxis(QCPAxis *axis); + void setValueAxis(QCPAxis *axis); + Q_SLOT void setSelectable(bool selectable); + Q_SLOT void setSelected(bool selected); + + // introduced virtual methods: + virtual void clearData() = 0; + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0; + virtual bool addToLegend(); + virtual bool removeFromLegend() const; + + // non-property methods: + void rescaleAxes(bool onlyEnlarge=false) const; + void rescaleKeyAxis(bool onlyEnlarge=false) const; + void rescaleValueAxis(bool onlyEnlarge=false) const; + +signals: + void selectionChanged(bool selected); + void selectableChanged(bool selectable); + +protected: + /*! + Represents negative and positive sign domain for passing to \ref getKeyRange and \ref getValueRange. + */ + enum SignDomain { sdNegative ///< The negative sign domain, i.e. numbers smaller than zero + ,sdBoth ///< Both sign domains, including zero, i.e. all (rational) numbers + ,sdPositive ///< The positive sign domain, i.e. numbers greater than zero + }; + + // property members: + QString mName; + bool mAntialiasedFill, mAntialiasedScatters, mAntialiasedErrorBars; + QPen mPen, mSelectedPen; + QBrush mBrush, mSelectedBrush; + QPointer mKeyAxis, mValueAxis; + bool mSelectable, mSelected; + + // reimplemented virtual methods: + virtual QRect clipRect() const; + virtual void draw(QCPPainter *painter) = 0; + virtual QCP::Interaction selectionCategory() const; + void applyDefaultAntialiasingHint(QCPPainter *painter) const; + // events: + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); + virtual void deselectEvent(bool *selectionStateChanged); + + // introduced virtual methods: + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const = 0; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0; + + // non-virtual methods: + void coordsToPixels(double key, double value, double &x, double &y) const; + const QPointF coordsToPixels(double key, double value) const; + void pixelsToCoords(double x, double y, double &key, double &value) const; + void pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const; + QPen mainPen() const; + QBrush mainBrush() const; + void applyFillAntialiasingHint(QCPPainter *painter) const; + void applyScattersAntialiasingHint(QCPPainter *painter) const; + void applyErrorBarsAntialiasingHint(QCPPainter *painter) const; + double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const; + +private: + Q_DISABLE_COPY(QCPAbstractPlottable) + + friend class QCustomPlot; + friend class QCPAxis; + friend class QCPPlottableLegendItem; +}; + + +class QCP_LIB_DECL QCPItemAnchor +{ +public: + QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name, int anchorId=-1); + virtual ~QCPItemAnchor(); + + // getters: + QString name() const { return mName; } + virtual QPointF pixelPoint() const; + +protected: + // property members: + QString mName; + + // non-property members: + QCustomPlot *mParentPlot; + QCPAbstractItem *mParentItem; + int mAnchorId; + QSet mChildrenX, mChildrenY; + + // introduced virtual methods: + virtual QCPItemPosition *toQCPItemPosition() { return 0; } + + // non-virtual methods: + void addChildX(QCPItemPosition* pos); // called from pos when this anchor is set as parent + void removeChildX(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted + void addChildY(QCPItemPosition* pos); // called from pos when this anchor is set as parent + void removeChildY(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted + +private: + Q_DISABLE_COPY(QCPItemAnchor) + + friend class QCPItemPosition; +}; + + + +class QCP_LIB_DECL QCPItemPosition : public QCPItemAnchor +{ +public: + /*! + Defines the ways an item position can be specified. Thus it defines what the numbers passed to + \ref setCoords actually mean. + + \see setType + */ + enum PositionType { ptAbsolute ///< Static positioning in pixels, starting from the top left corner of the viewport/widget. + ,ptViewportRatio ///< Static positioning given by a fraction of the viewport size. For example, if you call setCoords(0, 0), the position will be at the top + ///< left corner of the viewport/widget. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and + ///< vertically at the top of the viewport/widget, etc. + ,ptAxisRectRatio ///< Static positioning given by a fraction of the axis rect size (see \ref setAxisRect). For example, if you call setCoords(0, 0), the position will be at the top + ///< left corner of the axis rect. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and + ///< vertically at the top of the axis rect, etc. You can also go beyond the axis rect by providing negative coordinates or coordinates larger than 1. + ,ptPlotCoords ///< Dynamic positioning at a plot coordinate defined by two axes (see \ref setAxes). + }; + + QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name); + virtual ~QCPItemPosition(); + + // getters: + PositionType type() const { return typeX(); } + PositionType typeX() const { return mPositionTypeX; } + PositionType typeY() const { return mPositionTypeY; } + QCPItemAnchor *parentAnchor() const { return parentAnchorX(); } + QCPItemAnchor *parentAnchorX() const { return mParentAnchorX; } + QCPItemAnchor *parentAnchorY() const { return mParentAnchorY; } + double key() const { return mKey; } + double value() const { return mValue; } + QPointF coords() const { return QPointF(mKey, mValue); } + QCPAxis *keyAxis() const { return mKeyAxis.data(); } + QCPAxis *valueAxis() const { return mValueAxis.data(); } + QCPAxisRect *axisRect() const; + virtual QPointF pixelPoint() const; + + // setters: + void setType(PositionType type); + void setTypeX(PositionType type); + void setTypeY(PositionType type); + bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false); + bool setParentAnchorX(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false); + bool setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false); + void setCoords(double key, double value); + void setCoords(const QPointF &coords); + void setAxes(QCPAxis* keyAxis, QCPAxis* valueAxis); + void setAxisRect(QCPAxisRect *axisRect); + void setPixelPoint(const QPointF &pixelPoint); + +protected: + // property members: + PositionType mPositionTypeX, mPositionTypeY; + QPointer mKeyAxis, mValueAxis; + QPointer mAxisRect; + double mKey, mValue; + QCPItemAnchor *mParentAnchorX, *mParentAnchorY; + + // reimplemented virtual methods: + virtual QCPItemPosition *toQCPItemPosition() { return this; } + +private: + Q_DISABLE_COPY(QCPItemPosition) + +}; + + +class QCP_LIB_DECL QCPAbstractItem : public QCPLayerable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect) + Q_PROPERTY(QCPAxisRect* clipAxisRect READ clipAxisRect WRITE setClipAxisRect) + Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged) + Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged) + /// \endcond +public: + QCPAbstractItem(QCustomPlot *parentPlot); + virtual ~QCPAbstractItem(); + + // getters: + bool clipToAxisRect() const { return mClipToAxisRect; } + QCPAxisRect *clipAxisRect() const; + bool selectable() const { return mSelectable; } + bool selected() const { return mSelected; } + + // setters: + void setClipToAxisRect(bool clip); + void setClipAxisRect(QCPAxisRect *rect); + Q_SLOT void setSelectable(bool selectable); + Q_SLOT void setSelected(bool selected); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0; + + // non-virtual methods: + QList positions() const { return mPositions; } + QList anchors() const { return mAnchors; } + QCPItemPosition *position(const QString &name) const; + QCPItemAnchor *anchor(const QString &name) const; + bool hasAnchor(const QString &name) const; + +signals: + void selectionChanged(bool selected); + void selectableChanged(bool selectable); + +protected: + // property members: + bool mClipToAxisRect; + QPointer mClipAxisRect; + QList mPositions; + QList mAnchors; + bool mSelectable, mSelected; + + // reimplemented virtual methods: + virtual QCP::Interaction selectionCategory() const; + virtual QRect clipRect() const; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + virtual void draw(QCPPainter *painter) = 0; + // events: + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); + virtual void deselectEvent(bool *selectionStateChanged); + + // introduced virtual methods: + virtual QPointF anchorPixelPoint(int anchorId) const; + + // non-virtual methods: + double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const; + double rectSelectTest(const QRectF &rect, const QPointF &pos, bool filledRect) const; + QCPItemPosition *createPosition(const QString &name); + QCPItemAnchor *createAnchor(const QString &name, int anchorId); + +private: + Q_DISABLE_COPY(QCPAbstractItem) + + friend class QCustomPlot; + friend class QCPItemAnchor; +}; + + +class QCP_LIB_DECL QCustomPlot : public QWidget +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QRect viewport READ viewport WRITE setViewport) + Q_PROPERTY(QPixmap background READ background WRITE setBackground) + Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled) + Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode) + Q_PROPERTY(QCPLayoutGrid* plotLayout READ plotLayout) + Q_PROPERTY(bool autoAddPlottableToLegend READ autoAddPlottableToLegend WRITE setAutoAddPlottableToLegend) + Q_PROPERTY(int selectionTolerance READ selectionTolerance WRITE setSelectionTolerance) + Q_PROPERTY(bool noAntialiasingOnDrag READ noAntialiasingOnDrag WRITE setNoAntialiasingOnDrag) + Q_PROPERTY(Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier WRITE setMultiSelectModifier) + /// \endcond +public: + /*! + Defines how a layer should be inserted relative to an other layer. + + \see addLayer, moveLayer + */ + enum LayerInsertMode { limBelow ///< Layer is inserted below other layer + ,limAbove ///< Layer is inserted above other layer + }; + Q_ENUMS(LayerInsertMode) + + /*! + Defines with what timing the QCustomPlot surface is refreshed after a replot. + + \see replot + */ + enum RefreshPriority { rpImmediate ///< The QCustomPlot surface is immediately refreshed, by calling QWidget::repaint() after the replot + ,rpQueued ///< Queues the refresh such that it is performed at a slightly delayed point in time after the replot, by calling QWidget::update() after the replot + ,rpHint ///< Whether to use immediate repaint or queued update depends on whether the plotting hint \ref QCP::phForceRepaint is set, see \ref setPlottingHints. + }; + + explicit QCustomPlot(QWidget *parent = 0); + virtual ~QCustomPlot(); + + // getters: + QRect viewport() const { return mViewport; } + QPixmap background() const { return mBackgroundPixmap; } + bool backgroundScaled() const { return mBackgroundScaled; } + Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; } + QCPLayoutGrid *plotLayout() const { return mPlotLayout; } + QCP::AntialiasedElements antialiasedElements() const { return mAntialiasedElements; } + QCP::AntialiasedElements notAntialiasedElements() const { return mNotAntialiasedElements; } + bool autoAddPlottableToLegend() const { return mAutoAddPlottableToLegend; } + const QCP::Interactions interactions() const { return mInteractions; } + int selectionTolerance() const { return mSelectionTolerance; } + bool noAntialiasingOnDrag() const { return mNoAntialiasingOnDrag; } + QCP::PlottingHints plottingHints() const { return mPlottingHints; } + Qt::KeyboardModifier multiSelectModifier() const { return mMultiSelectModifier; } + + // setters: + void setViewport(const QRect &rect); + void setBackground(const QPixmap &pm); + void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding); + void setBackground(const QBrush &brush); + void setBackgroundScaled(bool scaled); + void setBackgroundScaledMode(Qt::AspectRatioMode mode); + void setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements); + void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled=true); + void setNotAntialiasedElements(const QCP::AntialiasedElements ¬AntialiasedElements); + void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled=true); + void setAutoAddPlottableToLegend(bool on); + void setInteractions(const QCP::Interactions &interactions); + void setInteraction(const QCP::Interaction &interaction, bool enabled=true); + void setSelectionTolerance(int pixels); + void setNoAntialiasingOnDrag(bool enabled); + void setPlottingHints(const QCP::PlottingHints &hints); + void setPlottingHint(QCP::PlottingHint hint, bool enabled=true); + void setMultiSelectModifier(Qt::KeyboardModifier modifier); + + // non-property methods: + // plottable interface: + QCPAbstractPlottable *plottable(int index); + QCPAbstractPlottable *plottable(); + bool addPlottable(QCPAbstractPlottable *plottable); + bool removePlottable(QCPAbstractPlottable *plottable); + bool removePlottable(int index); + int clearPlottables(); + int plottableCount() const; + QList selectedPlottables() const; + QCPAbstractPlottable *plottableAt(const QPointF &pos, bool onlySelectable=false) const; + bool hasPlottable(QCPAbstractPlottable *plottable) const; + + // specialized interface for QCPGraph: + QCPGraph *graph(int index) const; + QCPGraph *graph() const; + QCPGraph *addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0); + bool removeGraph(QCPGraph *graph); + bool removeGraph(int index); + int clearGraphs(); + int graphCount() const; + QList selectedGraphs() const; + + // item interface: + QCPAbstractItem *item(int index) const; + QCPAbstractItem *item() const; + bool addItem(QCPAbstractItem* item); + bool removeItem(QCPAbstractItem *item); + bool removeItem(int index); + int clearItems(); + int itemCount() const; + QList selectedItems() const; + QCPAbstractItem *itemAt(const QPointF &pos, bool onlySelectable=false) const; + bool hasItem(QCPAbstractItem *item) const; + + // layer interface: + QCPLayer *layer(const QString &name) const; + QCPLayer *layer(int index) const; + QCPLayer *currentLayer() const; + bool setCurrentLayer(const QString &name); + bool setCurrentLayer(QCPLayer *layer); + int layerCount() const; + bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove); + bool removeLayer(QCPLayer *layer); + bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove); + + // axis rect/layout interface: + int axisRectCount() const; + QCPAxisRect* axisRect(int index=0) const; + QList axisRects() const; + QCPLayoutElement* layoutElementAt(const QPointF &pos) const; + Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false); + + QList selectedAxes() const; + QList selectedLegends() const; + Q_SLOT void deselectAll(); + + bool savePdf(const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0, const QString &pdfCreator="", const QString &pdfTitle=""); + bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1); + bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1); + bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0); + bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1); + QPixmap toPixmap(int width=0, int height=0, double scale=1.0); + void toPainter(QCPPainter *painter, int width=0, int height=0); + Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpHint); + + QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2; + QCPLegend *legend; + +signals: + void mouseDoubleClick(QMouseEvent *event); + void mousePress(QMouseEvent *event); + void mouseMove(QMouseEvent *event); + void mouseRelease(QMouseEvent *event); + void mouseWheel(QWheelEvent *event); + + void plottableClick(QCPAbstractPlottable *plottable, QMouseEvent *event); + void plottableDoubleClick(QCPAbstractPlottable *plottable, QMouseEvent *event); + void itemClick(QCPAbstractItem *item, QMouseEvent *event); + void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event); + void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event); + void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event); + void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event); + void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event); + void titleClick(QMouseEvent *event, QCPPlotTitle *title); + void titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title); + + void selectionChangedByUser(); + void beforeReplot(); + void afterReplot(); + +protected: + // property members: + QRect mViewport; + QCPLayoutGrid *mPlotLayout; + bool mAutoAddPlottableToLegend; + QList mPlottables; + QList mGraphs; // extra list of plottables also in mPlottables that are of type QCPGraph + QList mItems; + QList mLayers; + QCP::AntialiasedElements mAntialiasedElements, mNotAntialiasedElements; + QCP::Interactions mInteractions; + int mSelectionTolerance; + bool mNoAntialiasingOnDrag; + QBrush mBackgroundBrush; + QPixmap mBackgroundPixmap; + QPixmap mScaledBackgroundPixmap; + bool mBackgroundScaled; + Qt::AspectRatioMode mBackgroundScaledMode; + QCPLayer *mCurrentLayer; + QCP::PlottingHints mPlottingHints; + Qt::KeyboardModifier mMultiSelectModifier; + + // non-property members: + QPixmap mPaintBuffer; + QPoint mMousePressPos; + QPointer mMouseEventElement; + bool mReplotting; + + // reimplemented virtual methods: + virtual QSize minimumSizeHint() const; + virtual QSize sizeHint() const; + virtual void paintEvent(QPaintEvent *event); + virtual void resizeEvent(QResizeEvent *event); + virtual void mouseDoubleClickEvent(QMouseEvent *event); + virtual void mousePressEvent(QMouseEvent *event); + virtual void mouseMoveEvent(QMouseEvent *event); + virtual void mouseReleaseEvent(QMouseEvent *event); + virtual void wheelEvent(QWheelEvent *event); + + // introduced virtual methods: + virtual void draw(QCPPainter *painter); + virtual void axisRemoved(QCPAxis *axis); + virtual void legendRemoved(QCPLegend *legend); + + // non-virtual methods: + void updateLayerIndices() const; + QCPLayerable *layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const; + void drawBackground(QCPPainter *painter); + + friend class QCPLegend; + friend class QCPAxis; + friend class QCPLayer; + friend class QCPAxisRect; +}; + + +class QCP_LIB_DECL QCPColorGradient +{ + Q_GADGET +public: + /*! + Defines the color spaces in which color interpolation between gradient stops can be performed. + + \see setColorInterpolation + */ + enum ColorInterpolation { ciRGB ///< Color channels red, green and blue are linearly interpolated + ,ciHSV ///< Color channels hue, saturation and value are linearly interpolated (The hue is interpolated over the shortest angle distance) + }; + Q_ENUMS(ColorInterpolation) + + /*! + Defines the available presets that can be loaded with \ref loadPreset. See the documentation + there for an image of the presets. + */ + enum GradientPreset { gpGrayscale ///< Continuous lightness from black to white (suited for non-biased data representation) + ,gpHot ///< Continuous lightness from black over firey colors to white (suited for non-biased data representation) + ,gpCold ///< Continuous lightness from black over icey colors to white (suited for non-biased data representation) + ,gpNight ///< Continuous lightness from black over weak blueish colors to white (suited for non-biased data representation) + ,gpCandy ///< Blue over pink to white + ,gpGeography ///< Colors suitable to represent different elevations on geographical maps + ,gpIon ///< Half hue spectrum from black over purple to blue and finally green (creates banding illusion but allows more precise magnitude estimates) + ,gpThermal ///< Colors suitable for thermal imaging, ranging from dark blue over purple to orange, yellow and white + ,gpPolar ///< Colors suitable to emphasize polarity around the center, with blue for negative, black in the middle and red for positive values + ,gpSpectrum ///< An approximation of the visible light spectrum (creates banding illusion but allows more precise magnitude estimates) + ,gpJet ///< Hue variation similar to a spectrum, often used in numerical visualization (creates banding illusion but allows more precise magnitude estimates) + ,gpHues ///< Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and phases, see \ref setPeriodic) + }; + Q_ENUMS(GradientPreset) + + QCPColorGradient(GradientPreset preset=gpCold); + bool operator==(const QCPColorGradient &other) const; + bool operator!=(const QCPColorGradient &other) const { return !(*this == other); } + + // getters: + int levelCount() const { return mLevelCount; } + QMap colorStops() const { return mColorStops; } + ColorInterpolation colorInterpolation() const { return mColorInterpolation; } + bool periodic() const { return mPeriodic; } + + // setters: + void setLevelCount(int n); + void setColorStops(const QMap &colorStops); + void setColorStopAt(double position, const QColor &color); + void setColorInterpolation(ColorInterpolation interpolation); + void setPeriodic(bool enabled); + + // non-property methods: + void colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false); + QRgb color(double position, const QCPRange &range, bool logarithmic=false); + void loadPreset(GradientPreset preset); + void clearColorStops(); + QCPColorGradient inverted() const; + +protected: + void updateColorBuffer(); + + // property members: + int mLevelCount; + QMap mColorStops; + ColorInterpolation mColorInterpolation; + bool mPeriodic; + + // non-property members: + QVector mColorBuffer; + bool mColorBufferInvalidated; +}; + + +class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPixmap background READ background WRITE setBackground) + Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled) + Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode) + Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag) + Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom) + /// \endcond +public: + explicit QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true); + virtual ~QCPAxisRect(); + + // getters: + QPixmap background() const { return mBackgroundPixmap; } + bool backgroundScaled() const { return mBackgroundScaled; } + Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; } + Qt::Orientations rangeDrag() const { return mRangeDrag; } + Qt::Orientations rangeZoom() const { return mRangeZoom; } + QCPAxis *rangeDragAxis(Qt::Orientation orientation); + QCPAxis *rangeZoomAxis(Qt::Orientation orientation); + double rangeZoomFactor(Qt::Orientation orientation); + + // setters: + void setBackground(const QPixmap &pm); + void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding); + void setBackground(const QBrush &brush); + void setBackgroundScaled(bool scaled); + void setBackgroundScaledMode(Qt::AspectRatioMode mode); + void setRangeDrag(Qt::Orientations orientations); + void setRangeZoom(Qt::Orientations orientations); + void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical); + void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical); + void setRangeZoomFactor(double horizontalFactor, double verticalFactor); + void setRangeZoomFactor(double factor); + + // non-property methods: + int axisCount(QCPAxis::AxisType type) const; + QCPAxis *axis(QCPAxis::AxisType type, int index=0) const; + QList axes(QCPAxis::AxisTypes types) const; + QList axes() const; + QCPAxis *addAxis(QCPAxis::AxisType type); + QList addAxes(QCPAxis::AxisTypes types); + bool removeAxis(QCPAxis *axis); + QCPLayoutInset *insetLayout() const { return mInsetLayout; } + + void setupFullAxesBox(bool connectRanges=false); + QList plottables() const; + QList graphs() const; + QList items() const; + + // read-only interface imitating a QRect: + int left() const { return mRect.left(); } + int right() const { return mRect.right(); } + int top() const { return mRect.top(); } + int bottom() const { return mRect.bottom(); } + int width() const { return mRect.width(); } + int height() const { return mRect.height(); } + QSize size() const { return mRect.size(); } + QPoint topLeft() const { return mRect.topLeft(); } + QPoint topRight() const { return mRect.topRight(); } + QPoint bottomLeft() const { return mRect.bottomLeft(); } + QPoint bottomRight() const { return mRect.bottomRight(); } + QPoint center() const { return mRect.center(); } + + // reimplemented virtual methods: + virtual void update(UpdatePhase phase); + virtual QList elements(bool recursive) const; + +protected: + // property members: + QBrush mBackgroundBrush; + QPixmap mBackgroundPixmap; + QPixmap mScaledBackgroundPixmap; + bool mBackgroundScaled; + Qt::AspectRatioMode mBackgroundScaledMode; + QCPLayoutInset *mInsetLayout; + Qt::Orientations mRangeDrag, mRangeZoom; + QPointer mRangeDragHorzAxis, mRangeDragVertAxis, mRangeZoomHorzAxis, mRangeZoomVertAxis; + double mRangeZoomFactorHorz, mRangeZoomFactorVert; + // non-property members: + QCPRange mDragStartHorzRange, mDragStartVertRange; + QCP::AntialiasedElements mAADragBackup, mNotAADragBackup; + QPoint mDragStart; + bool mDragging; + QHash > mAxes; + + // reimplemented virtual methods: + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + virtual void draw(QCPPainter *painter); + virtual int calculateAutoMargin(QCP::MarginSide side); + // events: + virtual void mousePressEvent(QMouseEvent *event); + virtual void mouseMoveEvent(QMouseEvent *event); + virtual void mouseReleaseEvent(QMouseEvent *event); + virtual void wheelEvent(QWheelEvent *event); + + // non-property methods: + void drawBackground(QCPPainter *painter); + void updateAxesOffset(QCPAxis::AxisType type); + +private: + Q_DISABLE_COPY(QCPAxisRect) + + friend class QCustomPlot; +}; + + +class QCP_LIB_DECL QCPAbstractLegendItem : public QCPLayoutElement +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QCPLegend* parentLegend READ parentLegend) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) + Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectionChanged) + Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectableChanged) + /// \endcond +public: + explicit QCPAbstractLegendItem(QCPLegend *parent); + + // getters: + QCPLegend *parentLegend() const { return mParentLegend; } + QFont font() const { return mFont; } + QColor textColor() const { return mTextColor; } + QFont selectedFont() const { return mSelectedFont; } + QColor selectedTextColor() const { return mSelectedTextColor; } + bool selectable() const { return mSelectable; } + bool selected() const { return mSelected; } + + // setters: + void setFont(const QFont &font); + void setTextColor(const QColor &color); + void setSelectedFont(const QFont &font); + void setSelectedTextColor(const QColor &color); + Q_SLOT void setSelectable(bool selectable); + Q_SLOT void setSelected(bool selected); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + +signals: + void selectionChanged(bool selected); + void selectableChanged(bool selectable); + +protected: + // property members: + QCPLegend *mParentLegend; + QFont mFont; + QColor mTextColor; + QFont mSelectedFont; + QColor mSelectedTextColor; + bool mSelectable, mSelected; + + // reimplemented virtual methods: + virtual QCP::Interaction selectionCategory() const; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + virtual QRect clipRect() const; + virtual void draw(QCPPainter *painter) = 0; + // events: + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); + virtual void deselectEvent(bool *selectionStateChanged); + +private: + Q_DISABLE_COPY(QCPAbstractLegendItem) + + friend class QCPLegend; +}; + + +class QCP_LIB_DECL QCPPlottableLegendItem : public QCPAbstractLegendItem +{ + Q_OBJECT +public: + QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable); + + // getters: + QCPAbstractPlottable *plottable() { return mPlottable; } + +protected: + // property members: + QCPAbstractPlottable *mPlottable; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual QSize minimumSizeHint() const; + + // non-virtual methods: + QPen getIconBorderPen() const; + QColor getTextColor() const; + QFont getFont() const; +}; + + +class QCP_LIB_DECL QCPLegend : public QCPLayoutGrid +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) + Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) + Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding) + Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen) + Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectionChanged) + Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectableChanged) + Q_PROPERTY(QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen) + Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) + /// \endcond +public: + /*! + Defines the selectable parts of a legend + + \see setSelectedParts, setSelectableParts + */ + enum SelectablePart { spNone = 0x000 ///< 0x000 None + ,spLegendBox = 0x001 ///< 0x001 The legend box (frame) + ,spItems = 0x002 ///< 0x002 Legend items individually (see \ref selectedItems) + }; + Q_FLAGS(SelectablePart SelectableParts) + Q_DECLARE_FLAGS(SelectableParts, SelectablePart) + + explicit QCPLegend(); + virtual ~QCPLegend(); + + // getters: + QPen borderPen() const { return mBorderPen; } + QBrush brush() const { return mBrush; } + QFont font() const { return mFont; } + QColor textColor() const { return mTextColor; } + QSize iconSize() const { return mIconSize; } + int iconTextPadding() const { return mIconTextPadding; } + QPen iconBorderPen() const { return mIconBorderPen; } + SelectableParts selectableParts() const { return mSelectableParts; } + SelectableParts selectedParts() const; + QPen selectedBorderPen() const { return mSelectedBorderPen; } + QPen selectedIconBorderPen() const { return mSelectedIconBorderPen; } + QBrush selectedBrush() const { return mSelectedBrush; } + QFont selectedFont() const { return mSelectedFont; } + QColor selectedTextColor() const { return mSelectedTextColor; } + + // setters: + void setBorderPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setFont(const QFont &font); + void setTextColor(const QColor &color); + void setIconSize(const QSize &size); + void setIconSize(int width, int height); + void setIconTextPadding(int padding); + void setIconBorderPen(const QPen &pen); + Q_SLOT void setSelectableParts(const SelectableParts &selectableParts); + Q_SLOT void setSelectedParts(const SelectableParts &selectedParts); + void setSelectedBorderPen(const QPen &pen); + void setSelectedIconBorderPen(const QPen &pen); + void setSelectedBrush(const QBrush &brush); + void setSelectedFont(const QFont &font); + void setSelectedTextColor(const QColor &color); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + // non-virtual methods: + QCPAbstractLegendItem *item(int index) const; + QCPPlottableLegendItem *itemWithPlottable(const QCPAbstractPlottable *plottable) const; + int itemCount() const; + bool hasItem(QCPAbstractLegendItem *item) const; + bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const; + bool addItem(QCPAbstractLegendItem *item); + bool removeItem(int index); + bool removeItem(QCPAbstractLegendItem *item); + void clearItems(); + QList selectedItems() const; + +signals: + void selectionChanged(QCPLegend::SelectableParts parts); + void selectableChanged(QCPLegend::SelectableParts parts); + +protected: + // property members: + QPen mBorderPen, mIconBorderPen; + QBrush mBrush; + QFont mFont; + QColor mTextColor; + QSize mIconSize; + int mIconTextPadding; + SelectableParts mSelectedParts, mSelectableParts; + QPen mSelectedBorderPen, mSelectedIconBorderPen; + QBrush mSelectedBrush; + QFont mSelectedFont; + QColor mSelectedTextColor; + + // reimplemented virtual methods: + virtual void parentPlotInitialized(QCustomPlot *parentPlot); + virtual QCP::Interaction selectionCategory() const; + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + virtual void draw(QCPPainter *painter); + // events: + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); + virtual void deselectEvent(bool *selectionStateChanged); + + // non-virtual methods: + QPen getBorderPen() const; + QBrush getBrush() const; + +private: + Q_DISABLE_COPY(QCPLegend) + + friend class QCustomPlot; + friend class QCPAbstractLegendItem; +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts) +Q_DECLARE_METATYPE(QCPLegend::SelectablePart) + + +class QCP_LIB_DECL QCPPlotTitle : public QCPLayoutElement +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor) + Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged) + Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged) + /// \endcond +public: + explicit QCPPlotTitle(QCustomPlot *parentPlot); + explicit QCPPlotTitle(QCustomPlot *parentPlot, const QString &text); + + // getters: + QString text() const { return mText; } + QFont font() const { return mFont; } + QColor textColor() const { return mTextColor; } + QFont selectedFont() const { return mSelectedFont; } + QColor selectedTextColor() const { return mSelectedTextColor; } + bool selectable() const { return mSelectable; } + bool selected() const { return mSelected; } + + // setters: + void setText(const QString &text); + void setFont(const QFont &font); + void setTextColor(const QColor &color); + void setSelectedFont(const QFont &font); + void setSelectedTextColor(const QColor &color); + Q_SLOT void setSelectable(bool selectable); + Q_SLOT void setSelected(bool selected); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + +signals: + void selectionChanged(bool selected); + void selectableChanged(bool selectable); + +protected: + // property members: + QString mText; + QFont mFont; + QColor mTextColor; + QFont mSelectedFont; + QColor mSelectedTextColor; + QRect mTextBoundingRect; + bool mSelectable, mSelected; + + // reimplemented virtual methods: + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + virtual void draw(QCPPainter *painter); + virtual QSize minimumSizeHint() const; + virtual QSize maximumSizeHint() const; + // events: + virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged); + virtual void deselectEvent(bool *selectionStateChanged); + + // non-virtual methods: + QFont mainFont() const; + QColor mainTextColor() const; + +private: + Q_DISABLE_COPY(QCPPlotTitle) +}; + + +class QCPColorScaleAxisRectPrivate : public QCPAxisRect +{ + Q_OBJECT +public: + explicit QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale); +protected: + QCPColorScale *mParentColorScale; + QImage mGradientImage; + bool mGradientImageInvalidated; + // re-using some methods of QCPAxisRect to make them available to friend class QCPColorScale + using QCPAxisRect::calculateAutoMargin; + using QCPAxisRect::mousePressEvent; + using QCPAxisRect::mouseMoveEvent; + using QCPAxisRect::mouseReleaseEvent; + using QCPAxisRect::wheelEvent; + using QCPAxisRect::update; + virtual void draw(QCPPainter *painter); + void updateGradientImage(); + Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts); + Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts); + friend class QCPColorScale; +}; + + +class QCP_LIB_DECL QCPColorScale : public QCPLayoutElement +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QCPAxis::AxisType type READ type WRITE setType) + Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged) + Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged) + Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged) + Q_PROPERTY(QString label READ label WRITE setLabel) + Q_PROPERTY(int barWidth READ barWidth WRITE setBarWidth) + Q_PROPERTY(bool rangeDrag READ rangeDrag WRITE setRangeDrag) + Q_PROPERTY(bool rangeZoom READ rangeZoom WRITE setRangeZoom) + /// \endcond +public: + explicit QCPColorScale(QCustomPlot *parentPlot); + virtual ~QCPColorScale(); + + // getters: + QCPAxis *axis() const { return mColorAxis.data(); } + QCPAxis::AxisType type() const { return mType; } + QCPRange dataRange() const { return mDataRange; } + QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; } + QCPColorGradient gradient() const { return mGradient; } + QString label() const; + int barWidth () const { return mBarWidth; } + bool rangeDrag() const; + bool rangeZoom() const; + + // setters: + void setType(QCPAxis::AxisType type); + Q_SLOT void setDataRange(const QCPRange &dataRange); + Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType); + Q_SLOT void setGradient(const QCPColorGradient &gradient); + void setLabel(const QString &str); + void setBarWidth(int width); + void setRangeDrag(bool enabled); + void setRangeZoom(bool enabled); + + // non-property methods: + QList colorMaps() const; + void rescaleDataRange(bool onlyVisibleMaps); + + // reimplemented virtual methods: + virtual void update(UpdatePhase phase); + +signals: + void dataRangeChanged(QCPRange newRange); + void dataScaleTypeChanged(QCPAxis::ScaleType scaleType); + void gradientChanged(QCPColorGradient newGradient); + +protected: + // property members: + QCPAxis::AxisType mType; + QCPRange mDataRange; + QCPAxis::ScaleType mDataScaleType; + QCPColorGradient mGradient; + int mBarWidth; + + // non-property members: + QPointer mAxisRect; + QPointer mColorAxis; + + // reimplemented virtual methods: + virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const; + // events: + virtual void mousePressEvent(QMouseEvent *event); + virtual void mouseMoveEvent(QMouseEvent *event); + virtual void mouseReleaseEvent(QMouseEvent *event); + virtual void wheelEvent(QWheelEvent *event); + +private: + Q_DISABLE_COPY(QCPColorScale) + + friend class QCPColorScaleAxisRectPrivate; +}; + + +/*! \file */ + + + +class QCP_LIB_DECL QCPData +{ +public: + QCPData(); + QCPData(double key, double value); + double key, value; + double keyErrorPlus, keyErrorMinus; + double valueErrorPlus, valueErrorMinus; +}; +Q_DECLARE_TYPEINFO(QCPData, Q_MOVABLE_TYPE); + +/*! \typedef QCPDataMap + Container for storing \ref QCPData items in a sorted fashion. The key of the map + is the key member of the QCPData instance. + + This is the container in which QCPGraph holds its data. + \see QCPData, QCPGraph::setData +*/ +typedef QMap QCPDataMap; +typedef QMapIterator QCPDataMapIterator; +typedef QMutableMapIterator QCPDataMutableMapIterator; + + +class QCP_LIB_DECL QCPGraph : public QCPAbstractPlottable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle) + Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle) + Q_PROPERTY(ErrorType errorType READ errorType WRITE setErrorType) + Q_PROPERTY(QPen errorPen READ errorPen WRITE setErrorPen) + Q_PROPERTY(double errorBarSize READ errorBarSize WRITE setErrorBarSize) + Q_PROPERTY(bool errorBarSkipSymbol READ errorBarSkipSymbol WRITE setErrorBarSkipSymbol) + Q_PROPERTY(QCPGraph* channelFillGraph READ channelFillGraph WRITE setChannelFillGraph) + Q_PROPERTY(bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling) + /// \endcond +public: + /*! + Defines how the graph's line is represented visually in the plot. The line is drawn with the + current pen of the graph (\ref setPen). + \see setLineStyle + */ + enum LineStyle { lsNone ///< data points are not connected with any lines (e.g. data only represented + ///< with symbols according to the scatter style, see \ref setScatterStyle) + ,lsLine ///< data points are connected by a straight line + ,lsStepLeft ///< line is drawn as steps where the step height is the value of the left data point + ,lsStepRight ///< line is drawn as steps where the step height is the value of the right data point + ,lsStepCenter ///< line is drawn as steps where the step is in between two data points + ,lsImpulse ///< each data point is represented by a line parallel to the value axis, which reaches from the data point to the zero-value-line + }; + Q_ENUMS(LineStyle) + /*! + Defines what kind of error bars are drawn for each data point + */ + enum ErrorType { etNone ///< No error bars are shown + ,etKey ///< Error bars for the key dimension of the data point are shown + ,etValue ///< Error bars for the value dimension of the data point are shown + ,etBoth ///< Error bars for both key and value dimensions of the data point are shown + }; + Q_ENUMS(ErrorType) + + explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis); + virtual ~QCPGraph(); + + // getters: + QCPDataMap *data() const { return mData; } + LineStyle lineStyle() const { return mLineStyle; } + QCPScatterStyle scatterStyle() const { return mScatterStyle; } + ErrorType errorType() const { return mErrorType; } + QPen errorPen() const { return mErrorPen; } + double errorBarSize() const { return mErrorBarSize; } + bool errorBarSkipSymbol() const { return mErrorBarSkipSymbol; } + QCPGraph *channelFillGraph() const { return mChannelFillGraph.data(); } + bool adaptiveSampling() const { return mAdaptiveSampling; } + + // setters: + void setData(QCPDataMap *data, bool copy=false); + void setData(const QVector &key, const QVector &value); + void setDataKeyError(const QVector &key, const QVector &value, const QVector &keyError); + void setDataKeyError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus); + void setDataValueError(const QVector &key, const QVector &value, const QVector &valueError); + void setDataValueError(const QVector &key, const QVector &value, const QVector &valueErrorMinus, const QVector &valueErrorPlus); + void setDataBothError(const QVector &key, const QVector &value, const QVector &keyError, const QVector &valueError); + void setDataBothError(const QVector &key, const QVector &value, const QVector &keyErrorMinus, const QVector &keyErrorPlus, const QVector &valueErrorMinus, const QVector &valueErrorPlus); + void setLineStyle(LineStyle ls); + void setScatterStyle(const QCPScatterStyle &style); + void setErrorType(ErrorType errorType); + void setErrorPen(const QPen &pen); + void setErrorBarSize(double size); + void setErrorBarSkipSymbol(bool enabled); + void setChannelFillGraph(QCPGraph *targetGraph); + void setAdaptiveSampling(bool enabled); + + // non-property methods: + void addData(const QCPDataMap &dataMap); + void addData(const QCPData &data); + void addData(double key, double value); + void addData(const QVector &keys, const QVector &values); + void removeDataBefore(double key); + void removeDataAfter(double key); + void removeData(double fromKey, double toKey); + void removeData(double key); + + // reimplemented virtual methods: + virtual void clearData(); + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + using QCPAbstractPlottable::rescaleAxes; + using QCPAbstractPlottable::rescaleKeyAxis; + using QCPAbstractPlottable::rescaleValueAxis; + void rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface + void rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface + void rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface + +protected: + // property members: + QCPDataMap *mData; + QPen mErrorPen; + LineStyle mLineStyle; + QCPScatterStyle mScatterStyle; + ErrorType mErrorType; + double mErrorBarSize; + bool mErrorBarSkipSymbol; + QPointer mChannelFillGraph; + bool mAdaptiveSampling; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface + + // introduced virtual methods: + virtual void drawFill(QCPPainter *painter, QVector *lineData) const; + virtual void drawScatterPlot(QCPPainter *painter, QVector *scatterData) const; + virtual void drawLinePlot(QCPPainter *painter, QVector *lineData) const; + virtual void drawImpulsePlot(QCPPainter *painter, QVector *lineData) const; + + // non-virtual methods: + void getPreparedData(QVector *lineData, QVector *scatterData) const; + void getPlotData(QVector *lineData, QVector *scatterData) const; + void getScatterPlotData(QVector *scatterData) const; + void getLinePlotData(QVector *linePixelData, QVector *scatterData) const; + void getStepLeftPlotData(QVector *linePixelData, QVector *scatterData) const; + void getStepRightPlotData(QVector *linePixelData, QVector *scatterData) const; + void getStepCenterPlotData(QVector *linePixelData, QVector *scatterData) const; + void getImpulsePlotData(QVector *linePixelData, QVector *scatterData) const; + void drawError(QCPPainter *painter, double x, double y, const QCPData &data) const; + void getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper) const; + int countDataInBounds(const QCPDataMap::const_iterator &lower, const QCPDataMap::const_iterator &upper, int maxCount) const; + void addFillBasePoints(QVector *lineData) const; + void removeFillBasePoints(QVector *lineData) const; + QPointF lowerFillBasePoint(double lowerKey) const; + QPointF upperFillBasePoint(double upperKey) const; + const QPolygonF getChannelFillPolygon(const QVector *lineData) const; + int findIndexBelowX(const QVector *data, double x) const; + int findIndexAboveX(const QVector *data, double x) const; + int findIndexBelowY(const QVector *data, double y) const; + int findIndexAboveY(const QVector *data, double y) const; + double pointDistance(const QPointF &pixelPoint) const; + + friend class QCustomPlot; + friend class QCPLegend; +}; + + +/*! \file */ + + + +class QCP_LIB_DECL QCPCurveData +{ +public: + QCPCurveData(); + QCPCurveData(double t, double key, double value); + double t, key, value; +}; +Q_DECLARE_TYPEINFO(QCPCurveData, Q_MOVABLE_TYPE); + +/*! \typedef QCPCurveDataMap + Container for storing \ref QCPCurveData items in a sorted fashion. The key of the map + is the t member of the QCPCurveData instance. + + This is the container in which QCPCurve holds its data. + \see QCPCurveData, QCPCurve::setData +*/ + +typedef QMap QCPCurveDataMap; +typedef QMapIterator QCPCurveDataMapIterator; +typedef QMutableMapIterator QCPCurveDataMutableMapIterator; + + +class QCP_LIB_DECL QCPCurve : public QCPAbstractPlottable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle) + Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle) + /// \endcond +public: + /*! + Defines how the curve's line is represented visually in the plot. The line is drawn with the + current pen of the curve (\ref setPen). + \see setLineStyle + */ + enum LineStyle { lsNone ///< No line is drawn between data points (e.g. only scatters) + ,lsLine ///< Data points are connected with a straight line + }; + explicit QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis); + virtual ~QCPCurve(); + + // getters: + QCPCurveDataMap *data() const { return mData; } + QCPScatterStyle scatterStyle() const { return mScatterStyle; } + LineStyle lineStyle() const { return mLineStyle; } + + // setters: + void setData(QCPCurveDataMap *data, bool copy=false); + void setData(const QVector &t, const QVector &key, const QVector &value); + void setData(const QVector &key, const QVector &value); + void setScatterStyle(const QCPScatterStyle &style); + void setLineStyle(LineStyle style); + + // non-property methods: + void addData(const QCPCurveDataMap &dataMap); + void addData(const QCPCurveData &data); + void addData(double t, double key, double value); + void addData(double key, double value); + void addData(const QVector &ts, const QVector &keys, const QVector &values); + void removeDataBefore(double t); + void removeDataAfter(double t); + void removeData(double fromt, double tot); + void removeData(double t); + + // reimplemented virtual methods: + virtual void clearData(); + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + +protected: + // property members: + QCPCurveDataMap *mData; + QCPScatterStyle mScatterStyle; + LineStyle mLineStyle; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + + // introduced virtual methods: + virtual void drawScatterPlot(QCPPainter *painter, const QVector *pointData) const; + + // non-virtual methods: + void getCurveData(QVector *lineData) const; + int getRegion(double x, double y, double rectLeft, double rectTop, double rectRight, double rectBottom) const; + QPointF getOptimizedPoint(int prevRegion, double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom) const; + QVector getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom) const; + bool mayTraverse(int prevRegion, int currentRegion) const; + bool getTraverse(double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom, QPointF &crossA, QPointF &crossB) const; + void getTraverseCornerPoints(int prevRegion, int currentRegion, double rectLeft, double rectTop, double rectRight, double rectBottom, QVector &beforeTraverse, QVector &afterTraverse) const; + double pointDistance(const QPointF &pixelPoint) const; + + friend class QCustomPlot; + friend class QCPLegend; +}; + + +/*! \file */ + + + +class QCP_LIB_DECL QCPBarsGroup : public QObject +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(SpacingType spacingType READ spacingType WRITE setSpacingType) + Q_PROPERTY(double spacing READ spacing WRITE setSpacing) + /// \endcond +public: + /*! + Defines the ways the spacing between bars in the group can be specified. Thus it defines what + the number passed to \ref setSpacing actually means. + + \see setSpacingType, setSpacing + */ + enum SpacingType { stAbsolute ///< Bar spacing is in absolute pixels + ,stAxisRectRatio ///< Bar spacing is given by a fraction of the axis rect size + ,stPlotCoords ///< Bar spacing is in key coordinates and thus scales with the key axis range + }; + QCPBarsGroup(QCustomPlot *parentPlot); + ~QCPBarsGroup(); + + // getters: + SpacingType spacingType() const { return mSpacingType; } + double spacing() const { return mSpacing; } + + // setters: + void setSpacingType(SpacingType spacingType); + void setSpacing(double spacing); + + // non-virtual methods: + QList bars() const { return mBars; } + QCPBars* bars(int index) const; + int size() const { return mBars.size(); } + bool isEmpty() const { return mBars.isEmpty(); } + void clear(); + bool contains(QCPBars *bars) const { return mBars.contains(bars); } + void append(QCPBars *bars); + void insert(int i, QCPBars *bars); + void remove(QCPBars *bars); + +protected: + // non-property members: + QCustomPlot *mParentPlot; + SpacingType mSpacingType; + double mSpacing; + QList mBars; + + // non-virtual methods: + void registerBars(QCPBars *bars); + void unregisterBars(QCPBars *bars); + + // virtual methods: + double keyPixelOffset(const QCPBars *bars, double keyCoord); + double getPixelSpacing(const QCPBars *bars, double keyCoord); + +private: + Q_DISABLE_COPY(QCPBarsGroup) + + friend class QCPBars; +}; + + +class QCP_LIB_DECL QCPBarData +{ +public: + QCPBarData(); + QCPBarData(double key, double value); + double key, value; +}; +Q_DECLARE_TYPEINFO(QCPBarData, Q_MOVABLE_TYPE); + +/*! \typedef QCPBarDataMap + Container for storing \ref QCPBarData items in a sorted fashion. The key of the map + is the key member of the QCPBarData instance. + + This is the container in which QCPBars holds its data. + \see QCPBarData, QCPBars::setData +*/ +typedef QMap QCPBarDataMap; +typedef QMapIterator QCPBarDataMapIterator; +typedef QMutableMapIterator QCPBarDataMutableMapIterator; + + +class QCP_LIB_DECL QCPBars : public QCPAbstractPlottable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(double width READ width WRITE setWidth) + Q_PROPERTY(WidthType widthType READ widthType WRITE setWidthType) + Q_PROPERTY(QCPBarsGroup* barsGroup READ barsGroup WRITE setBarsGroup) + Q_PROPERTY(double baseValue READ baseValue WRITE setBaseValue) + Q_PROPERTY(QCPBars* barBelow READ barBelow) + Q_PROPERTY(QCPBars* barAbove READ barAbove) + /// \endcond +public: + /*! + Defines the ways the width of the bar can be specified. Thus it defines what the number passed + to \ref setWidth actually means. + + \see setWidthType, setWidth + */ + enum WidthType { wtAbsolute ///< Bar width is in absolute pixels + ,wtAxisRectRatio ///< Bar width is given by a fraction of the axis rect size + ,wtPlotCoords ///< Bar width is in key coordinates and thus scales with the key axis range + }; + Q_ENUMS(WidthType) + + explicit QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis); + virtual ~QCPBars(); + + // getters: + double width() const { return mWidth; } + WidthType widthType() const { return mWidthType; } + QCPBarsGroup *barsGroup() const { return mBarsGroup; } + double baseValue() const { return mBaseValue; } + QCPBars *barBelow() const { return mBarBelow.data(); } + QCPBars *barAbove() const { return mBarAbove.data(); } + QCPBarDataMap *data() const { return mData; } + + // setters: + void setWidth(double width); + void setWidthType(WidthType widthType); + void setBarsGroup(QCPBarsGroup *barsGroup); + void setBaseValue(double baseValue); + void setData(QCPBarDataMap *data, bool copy=false); + void setData(const QVector &key, const QVector &value); + + // non-property methods: + void moveBelow(QCPBars *bars); + void moveAbove(QCPBars *bars); + void addData(const QCPBarDataMap &dataMap); + void addData(const QCPBarData &data); + void addData(double key, double value); + void addData(const QVector &keys, const QVector &values); + void removeDataBefore(double key); + void removeDataAfter(double key); + void removeData(double fromKey, double toKey); + void removeData(double key); + + // reimplemented virtual methods: + virtual void clearData(); + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + +protected: + // property members: + QCPBarDataMap *mData; + double mWidth; + WidthType mWidthType; + QCPBarsGroup *mBarsGroup; + double mBaseValue; + QPointer mBarBelow, mBarAbove; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + + // non-virtual methods: + void getVisibleDataBounds(QCPBarDataMap::const_iterator &lower, QCPBarDataMap::const_iterator &upperEnd) const; + QPolygonF getBarPolygon(double key, double value) const; + void getPixelWidth(double key, double &lower, double &upper) const; + double getStackedBaseValue(double key, bool positive) const; + static void connectBars(QCPBars* lower, QCPBars* upper); + + friend class QCustomPlot; + friend class QCPLegend; + friend class QCPBarsGroup; +}; + + +/*! \file */ + + + +class QCP_LIB_DECL QCPStatisticalBox : public QCPAbstractPlottable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(double key READ key WRITE setKey) + Q_PROPERTY(double minimum READ minimum WRITE setMinimum) + Q_PROPERTY(double lowerQuartile READ lowerQuartile WRITE setLowerQuartile) + Q_PROPERTY(double median READ median WRITE setMedian) + Q_PROPERTY(double upperQuartile READ upperQuartile WRITE setUpperQuartile) + Q_PROPERTY(double maximum READ maximum WRITE setMaximum) + Q_PROPERTY(QVector outliers READ outliers WRITE setOutliers) + Q_PROPERTY(double width READ width WRITE setWidth) + Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth) + Q_PROPERTY(QPen whiskerPen READ whiskerPen WRITE setWhiskerPen) + Q_PROPERTY(QPen whiskerBarPen READ whiskerBarPen WRITE setWhiskerBarPen) + Q_PROPERTY(QPen medianPen READ medianPen WRITE setMedianPen) + Q_PROPERTY(QCPScatterStyle outlierStyle READ outlierStyle WRITE setOutlierStyle) + /// \endcond +public: + explicit QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis); + + // getters: + double key() const { return mKey; } + double minimum() const { return mMinimum; } + double lowerQuartile() const { return mLowerQuartile; } + double median() const { return mMedian; } + double upperQuartile() const { return mUpperQuartile; } + double maximum() const { return mMaximum; } + QVector outliers() const { return mOutliers; } + double width() const { return mWidth; } + double whiskerWidth() const { return mWhiskerWidth; } + QPen whiskerPen() const { return mWhiskerPen; } + QPen whiskerBarPen() const { return mWhiskerBarPen; } + QPen medianPen() const { return mMedianPen; } + QCPScatterStyle outlierStyle() const { return mOutlierStyle; } + + // setters: + void setKey(double key); + void setMinimum(double value); + void setLowerQuartile(double value); + void setMedian(double value); + void setUpperQuartile(double value); + void setMaximum(double value); + void setOutliers(const QVector &values); + void setData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum); + void setWidth(double width); + void setWhiskerWidth(double width); + void setWhiskerPen(const QPen &pen); + void setWhiskerBarPen(const QPen &pen); + void setMedianPen(const QPen &pen); + void setOutlierStyle(const QCPScatterStyle &style); + + // non-property methods: + virtual void clearData(); + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + +protected: + // property members: + QVector mOutliers; + double mKey, mMinimum, mLowerQuartile, mMedian, mUpperQuartile, mMaximum; + double mWidth; + double mWhiskerWidth; + QPen mWhiskerPen, mWhiskerBarPen, mMedianPen; + QCPScatterStyle mOutlierStyle; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + + // introduced virtual methods: + virtual void drawQuartileBox(QCPPainter *painter, QRectF *quartileBox=0) const; + virtual void drawMedian(QCPPainter *painter) const; + virtual void drawWhiskers(QCPPainter *painter) const; + virtual void drawOutliers(QCPPainter *painter) const; + + friend class QCustomPlot; + friend class QCPLegend; +}; + + +class QCP_LIB_DECL QCPColorMapData +{ +public: + QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange); + ~QCPColorMapData(); + QCPColorMapData(const QCPColorMapData &other); + QCPColorMapData &operator=(const QCPColorMapData &other); + + // getters: + int keySize() const { return mKeySize; } + int valueSize() const { return mValueSize; } + QCPRange keyRange() const { return mKeyRange; } + QCPRange valueRange() const { return mValueRange; } + QCPRange dataBounds() const { return mDataBounds; } + double data(double key, double value); + double cell(int keyIndex, int valueIndex); + + // setters: + void setSize(int keySize, int valueSize); + void setKeySize(int keySize); + void setValueSize(int valueSize); + void setRange(const QCPRange &keyRange, const QCPRange &valueRange); + void setKeyRange(const QCPRange &keyRange); + void setValueRange(const QCPRange &valueRange); + void setData(double key, double value, double z); + void setCell(int keyIndex, int valueIndex, double z); + + // non-property methods: + void recalculateDataBounds(); + void clear(); + void fill(double z); + bool isEmpty() const { return mIsEmpty; } + void coordToCell(double key, double value, int *keyIndex, int *valueIndex) const; + void cellToCoord(int keyIndex, int valueIndex, double *key, double *value) const; + +protected: + // property members: + int mKeySize, mValueSize; + QCPRange mKeyRange, mValueRange; + bool mIsEmpty; + // non-property members: + double *mData; + QCPRange mDataBounds; + bool mDataModified; + + friend class QCPColorMap; +}; + + +class QCP_LIB_DECL QCPColorMap : public QCPAbstractPlottable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged) + Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged) + Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged) + Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate) + Q_PROPERTY(bool tightBoundary READ tightBoundary WRITE setTightBoundary) + Q_PROPERTY(QCPColorScale* colorScale READ colorScale WRITE setColorScale) + /// \endcond +public: + explicit QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis); + virtual ~QCPColorMap(); + + // getters: + QCPColorMapData *data() const { return mMapData; } + QCPRange dataRange() const { return mDataRange; } + QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; } + bool interpolate() const { return mInterpolate; } + bool tightBoundary() const { return mTightBoundary; } + QCPColorGradient gradient() const { return mGradient; } + QCPColorScale *colorScale() const { return mColorScale.data(); } + + // setters: + void setData(QCPColorMapData *data, bool copy=false); + Q_SLOT void setDataRange(const QCPRange &dataRange); + Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType); + Q_SLOT void setGradient(const QCPColorGradient &gradient); + void setInterpolate(bool enabled); + void setTightBoundary(bool enabled); + void setColorScale(QCPColorScale *colorScale); + + // non-property methods: + void rescaleDataRange(bool recalculateDataBounds=false); + Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18)); + + // reimplemented virtual methods: + virtual void clearData(); + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + +signals: + void dataRangeChanged(QCPRange newRange); + void dataScaleTypeChanged(QCPAxis::ScaleType scaleType); + void gradientChanged(QCPColorGradient newGradient); + +protected: + // property members: + QCPRange mDataRange; + QCPAxis::ScaleType mDataScaleType; + QCPColorMapData *mMapData; + QCPColorGradient mGradient; + bool mInterpolate; + bool mTightBoundary; + QPointer mColorScale; + // non-property members: + QImage mMapImage; + QPixmap mLegendIcon; + bool mMapImageInvalidated; + + // introduced virtual methods: + virtual void updateMapImage(); + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + + friend class QCustomPlot; + friend class QCPLegend; +}; + + +/*! \file */ + + + +class QCP_LIB_DECL QCPFinancialData +{ +public: + QCPFinancialData(); + QCPFinancialData(double key, double open, double high, double low, double close); + double key, open, high, low, close; +}; +Q_DECLARE_TYPEINFO(QCPFinancialData, Q_MOVABLE_TYPE); + +/*! \typedef QCPFinancialDataMap + Container for storing \ref QCPFinancialData items in a sorted fashion. The key of the map + is the key member of the QCPFinancialData instance. + + This is the container in which QCPFinancial holds its data. + \see QCPFinancial, QCPFinancial::setData +*/ +typedef QMap QCPFinancialDataMap; +typedef QMapIterator QCPFinancialDataMapIterator; +typedef QMutableMapIterator QCPFinancialDataMutableMapIterator; + + +class QCP_LIB_DECL QCPFinancial : public QCPAbstractPlottable +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(ChartStyle chartStyle READ chartStyle WRITE setChartStyle) + Q_PROPERTY(double width READ width WRITE setWidth) + Q_PROPERTY(bool twoColored READ twoColored WRITE setTwoColored) + Q_PROPERTY(QBrush brushPositive READ brushPositive WRITE setBrushPositive) + Q_PROPERTY(QBrush brushNegative READ brushNegative WRITE setBrushNegative) + Q_PROPERTY(QPen penPositive READ penPositive WRITE setPenPositive) + Q_PROPERTY(QPen penNegative READ penNegative WRITE setPenNegative) + /// \endcond +public: + /*! + Defines the possible representations of OHLC data in the plot. + + \see setChartStyle + */ + enum ChartStyle { csOhlc ///< Open-High-Low-Close bar representation + ,csCandlestick ///< Candlestick representation + }; + Q_ENUMS(ChartStyle) + + explicit QCPFinancial(QCPAxis *keyAxis, QCPAxis *valueAxis); + virtual ~QCPFinancial(); + + // getters: + QCPFinancialDataMap *data() const { return mData; } + ChartStyle chartStyle() const { return mChartStyle; } + double width() const { return mWidth; } + bool twoColored() const { return mTwoColored; } + QBrush brushPositive() const { return mBrushPositive; } + QBrush brushNegative() const { return mBrushNegative; } + QPen penPositive() const { return mPenPositive; } + QPen penNegative() const { return mPenNegative; } + + + // setters: + void setData(QCPFinancialDataMap *data, bool copy=false); + void setData(const QVector &key, const QVector &open, const QVector &high, const QVector &low, const QVector &close); + void setChartStyle(ChartStyle style); + void setWidth(double width); + void setTwoColored(bool twoColored); + void setBrushPositive(const QBrush &brush); + void setBrushNegative(const QBrush &brush); + void setPenPositive(const QPen &pen); + void setPenNegative(const QPen &pen); + + // non-property methods: + void addData(const QCPFinancialDataMap &dataMap); + void addData(const QCPFinancialData &data); + void addData(double key, double open, double high, double low, double close); + void addData(const QVector &key, const QVector &open, const QVector &high, const QVector &low, const QVector &close); + void removeDataBefore(double key); + void removeDataAfter(double key); + void removeData(double fromKey, double toKey); + void removeData(double key); + + // reimplemented virtual methods: + virtual void clearData(); + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + // static methods: + static QCPFinancialDataMap timeSeriesToOhlc(const QVector &time, const QVector &value, double timeBinSize, double timeBinOffset = 0); + +protected: + // property members: + QCPFinancialDataMap *mData; + ChartStyle mChartStyle; + double mWidth; + bool mTwoColored; + QBrush mBrushPositive, mBrushNegative; + QPen mPenPositive, mPenNegative; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; + virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const; + + // non-virtual methods: + void drawOhlcPlot(QCPPainter *painter, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end); + void drawCandlestickPlot(QCPPainter *painter, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end); + double ohlcSelectTest(const QPointF &pos, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end) const; + double candlestickSelectTest(const QPointF &pos, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end) const; + void getVisibleDataBounds(QCPFinancialDataMap::const_iterator &lower, QCPFinancialDataMap::const_iterator &upper) const; + + friend class QCustomPlot; + friend class QCPLegend; +}; + + +class QCP_LIB_DECL QCPItemStraightLine : public QCPAbstractItem +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + /// \endcond +public: + QCPItemStraightLine(QCustomPlot *parentPlot); + virtual ~QCPItemStraightLine(); + + // getters: + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + + // setters; + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + QCPItemPosition * const point1; + QCPItemPosition * const point2; + +protected: + // property members: + QPen mPen, mSelectedPen; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + + // non-virtual methods: + double distToStraightLine(const QVector2D &point1, const QVector2D &vec, const QVector2D &point) const; + QLineF getRectClippedStraightLine(const QVector2D &point1, const QVector2D &vec, const QRect &rect) const; + QPen mainPen() const; +}; + + +class QCP_LIB_DECL QCPItemLine : public QCPAbstractItem +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QCPLineEnding head READ head WRITE setHead) + Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail) + /// \endcond +public: + QCPItemLine(QCustomPlot *parentPlot); + virtual ~QCPItemLine(); + + // getters: + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + QCPLineEnding head() const { return mHead; } + QCPLineEnding tail() const { return mTail; } + + // setters; + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setHead(const QCPLineEnding &head); + void setTail(const QCPLineEnding &tail); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + QCPItemPosition * const start; + QCPItemPosition * const end; + +protected: + // property members: + QPen mPen, mSelectedPen; + QCPLineEnding mHead, mTail; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + + // non-virtual methods: + QLineF getRectClippedLine(const QVector2D &start, const QVector2D &end, const QRect &rect) const; + QPen mainPen() const; +}; + + +class QCP_LIB_DECL QCPItemCurve : public QCPAbstractItem +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QCPLineEnding head READ head WRITE setHead) + Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail) + /// \endcond +public: + QCPItemCurve(QCustomPlot *parentPlot); + virtual ~QCPItemCurve(); + + // getters: + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + QCPLineEnding head() const { return mHead; } + QCPLineEnding tail() const { return mTail; } + + // setters; + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setHead(const QCPLineEnding &head); + void setTail(const QCPLineEnding &tail); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + QCPItemPosition * const start; + QCPItemPosition * const startDir; + QCPItemPosition * const endDir; + QCPItemPosition * const end; + +protected: + // property members: + QPen mPen, mSelectedPen; + QCPLineEnding mHead, mTail; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + + // non-virtual methods: + QPen mainPen() const; +}; + + +class QCP_LIB_DECL QCPItemRect : public QCPAbstractItem +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) + /// \endcond +public: + QCPItemRect(QCustomPlot *parentPlot); + virtual ~QCPItemRect(); + + // getters: + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + QBrush brush() const { return mBrush; } + QBrush selectedBrush() const { return mSelectedBrush; } + + // setters; + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + QCPItemPosition * const topLeft; + QCPItemPosition * const bottomRight; + QCPItemAnchor * const top; + QCPItemAnchor * const topRight; + QCPItemAnchor * const right; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeft; + QCPItemAnchor * const left; + +protected: + enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft}; + + // property members: + QPen mPen, mSelectedPen; + QBrush mBrush, mSelectedBrush; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual QPointF anchorPixelPoint(int anchorId) const; + + // non-virtual methods: + QPen mainPen() const; + QBrush mainBrush() const; +}; + + +class QCP_LIB_DECL QCPItemText : public QCPAbstractItem +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) + Q_PROPERTY(QFont font READ font WRITE setFont) + Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont) + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(Qt::Alignment positionAlignment READ positionAlignment WRITE setPositionAlignment) + Q_PROPERTY(Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment) + Q_PROPERTY(double rotation READ rotation WRITE setRotation) + Q_PROPERTY(QMargins padding READ padding WRITE setPadding) + /// \endcond +public: + QCPItemText(QCustomPlot *parentPlot); + virtual ~QCPItemText(); + + // getters: + QColor color() const { return mColor; } + QColor selectedColor() const { return mSelectedColor; } + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + QBrush brush() const { return mBrush; } + QBrush selectedBrush() const { return mSelectedBrush; } + QFont font() const { return mFont; } + QFont selectedFont() const { return mSelectedFont; } + QString text() const { return mText; } + Qt::Alignment positionAlignment() const { return mPositionAlignment; } + Qt::Alignment textAlignment() const { return mTextAlignment; } + double rotation() const { return mRotation; } + QMargins padding() const { return mPadding; } + + // setters; + void setColor(const QColor &color); + void setSelectedColor(const QColor &color); + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); + void setFont(const QFont &font); + void setSelectedFont(const QFont &font); + void setText(const QString &text); + void setPositionAlignment(Qt::Alignment alignment); + void setTextAlignment(Qt::Alignment alignment); + void setRotation(double degrees); + void setPadding(const QMargins &padding); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + QCPItemPosition * const position; + QCPItemAnchor * const topLeft; + QCPItemAnchor * const top; + QCPItemAnchor * const topRight; + QCPItemAnchor * const right; + QCPItemAnchor * const bottomRight; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeft; + QCPItemAnchor * const left; + +protected: + enum AnchorIndex {aiTopLeft, aiTop, aiTopRight, aiRight, aiBottomRight, aiBottom, aiBottomLeft, aiLeft}; + + // property members: + QColor mColor, mSelectedColor; + QPen mPen, mSelectedPen; + QBrush mBrush, mSelectedBrush; + QFont mFont, mSelectedFont; + QString mText; + Qt::Alignment mPositionAlignment; + Qt::Alignment mTextAlignment; + double mRotation; + QMargins mPadding; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual QPointF anchorPixelPoint(int anchorId) const; + + // non-virtual methods: + QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const; + QFont mainFont() const; + QColor mainColor() const; + QPen mainPen() const; + QBrush mainBrush() const; +}; + + +class QCP_LIB_DECL QCPItemEllipse : public QCPAbstractItem +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) + /// \endcond +public: + QCPItemEllipse(QCustomPlot *parentPlot); + virtual ~QCPItemEllipse(); + + // getters: + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + QBrush brush() const { return mBrush; } + QBrush selectedBrush() const { return mSelectedBrush; } + + // setters; + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + QCPItemPosition * const topLeft; + QCPItemPosition * const bottomRight; + QCPItemAnchor * const topLeftRim; + QCPItemAnchor * const top; + QCPItemAnchor * const topRightRim; + QCPItemAnchor * const right; + QCPItemAnchor * const bottomRightRim; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeftRim; + QCPItemAnchor * const left; + QCPItemAnchor * const center; + +protected: + enum AnchorIndex {aiTopLeftRim, aiTop, aiTopRightRim, aiRight, aiBottomRightRim, aiBottom, aiBottomLeftRim, aiLeft, aiCenter}; + + // property members: + QPen mPen, mSelectedPen; + QBrush mBrush, mSelectedBrush; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual QPointF anchorPixelPoint(int anchorId) const; + + // non-virtual methods: + QPen mainPen() const; + QBrush mainBrush() const; +}; + + +class QCP_LIB_DECL QCPItemPixmap : public QCPAbstractItem +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) + Q_PROPERTY(bool scaled READ scaled WRITE setScaled) + Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode) + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + /// \endcond +public: + QCPItemPixmap(QCustomPlot *parentPlot); + virtual ~QCPItemPixmap(); + + // getters: + QPixmap pixmap() const { return mPixmap; } + bool scaled() const { return mScaled; } + Qt::AspectRatioMode aspectRatioMode() const { return mAspectRatioMode; } + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + + // setters; + void setPixmap(const QPixmap &pixmap); + void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio); + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + QCPItemPosition * const topLeft; + QCPItemPosition * const bottomRight; + QCPItemAnchor * const top; + QCPItemAnchor * const topRight; + QCPItemAnchor * const right; + QCPItemAnchor * const bottom; + QCPItemAnchor * const bottomLeft; + QCPItemAnchor * const left; + +protected: + enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft}; + + // property members: + QPixmap mPixmap; + QPixmap mScaledPixmap; + bool mScaled; + Qt::AspectRatioMode mAspectRatioMode; + QPen mPen, mSelectedPen; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual QPointF anchorPixelPoint(int anchorId) const; + + // non-virtual methods: + void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false); + QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const; + QPen mainPen() const; +}; + + +class QCP_LIB_DECL QCPItemTracer : public QCPAbstractItem +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(QBrush brush READ brush WRITE setBrush) + Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush) + Q_PROPERTY(double size READ size WRITE setSize) + Q_PROPERTY(TracerStyle style READ style WRITE setStyle) + Q_PROPERTY(QCPGraph* graph READ graph WRITE setGraph) + Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey) + Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating) + /// \endcond +public: + /*! + The different visual appearances a tracer item can have. Some styles size may be controlled with \ref setSize. + + \see setStyle + */ + enum TracerStyle { tsNone ///< The tracer is not visible + ,tsPlus ///< A plus shaped crosshair with limited size + ,tsCrosshair ///< A plus shaped crosshair which spans the complete axis rect + ,tsCircle ///< A circle + ,tsSquare ///< A square + }; + Q_ENUMS(TracerStyle) + + QCPItemTracer(QCustomPlot *parentPlot); + virtual ~QCPItemTracer(); + + // getters: + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + QBrush brush() const { return mBrush; } + QBrush selectedBrush() const { return mSelectedBrush; } + double size() const { return mSize; } + TracerStyle style() const { return mStyle; } + QCPGraph *graph() const { return mGraph; } + double graphKey() const { return mGraphKey; } + bool interpolating() const { return mInterpolating; } + + // setters; + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setBrush(const QBrush &brush); + void setSelectedBrush(const QBrush &brush); + void setSize(double size); + void setStyle(TracerStyle style); + void setGraph(QCPGraph *graph); + void setGraphKey(double key); + void setInterpolating(bool enabled); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + // non-virtual methods: + void updatePosition(); + + QCPItemPosition * const position; + +protected: + // property members: + QPen mPen, mSelectedPen; + QBrush mBrush, mSelectedBrush; + double mSize; + TracerStyle mStyle; + QCPGraph *mGraph; + double mGraphKey; + bool mInterpolating; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + + // non-virtual methods: + QPen mainPen() const; + QBrush mainBrush() const; +}; + + +class QCP_LIB_DECL QCPItemBracket : public QCPAbstractItem +{ + Q_OBJECT + /// \cond INCLUDE_QPROPERTIES + Q_PROPERTY(QPen pen READ pen WRITE setPen) + Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen) + Q_PROPERTY(double length READ length WRITE setLength) + Q_PROPERTY(BracketStyle style READ style WRITE setStyle) + /// \endcond +public: + enum BracketStyle { bsSquare ///< A brace with angled edges + ,bsRound ///< A brace with round edges + ,bsCurly ///< A curly brace + ,bsCalligraphic ///< A curly brace with varying stroke width giving a calligraphic impression + }; + + QCPItemBracket(QCustomPlot *parentPlot); + virtual ~QCPItemBracket(); + + // getters: + QPen pen() const { return mPen; } + QPen selectedPen() const { return mSelectedPen; } + double length() const { return mLength; } + BracketStyle style() const { return mStyle; } + + // setters; + void setPen(const QPen &pen); + void setSelectedPen(const QPen &pen); + void setLength(double length); + void setStyle(BracketStyle style); + + // reimplemented virtual methods: + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; + + QCPItemPosition * const left; + QCPItemPosition * const right; + QCPItemAnchor * const center; + +protected: + // property members: + enum AnchorIndex {aiCenter}; + QPen mPen, mSelectedPen; + double mLength; + BracketStyle mStyle; + + // reimplemented virtual methods: + virtual void draw(QCPPainter *painter); + virtual QPointF anchorPixelPoint(int anchorId) const; + + // non-virtual methods: + QPen mainPen() const; +}; + +#endif // QCUSTOMPLOT_H + diff --git a/src/qt/qrcodedialog.cpp b/src/qt/qrcodedialog.cpp new file mode 100644 index 0000000..006cd2d --- /dev/null +++ b/src/qt/qrcodedialog.cpp @@ -0,0 +1,171 @@ +#include "qrcodedialog.h" +#include "ui_qrcodedialog.h" + +#include "bitcoinunits.h" +#include "guiconstants.h" +#include "guiutil.h" +#include "optionsmodel.h" + +#include +#include + +#include + +QRCodeDialog::QRCodeDialog(const QString &addr, const QString &label, bool enableReq, QWidget *parent) : + QDialog(parent), + ui(new Ui::QRCodeDialog), + model(0), + address(addr) +{ + ui->setupUi(this); + + setWindowTitle(QString("%1").arg(address)); + + ui->chkReqPayment->setVisible(enableReq); + ui->lblAmount->setVisible(enableReq); + ui->lnReqAmount->setVisible(enableReq); + + ui->lnLabel->setText(label); + + ui->btnSaveAs->setEnabled(false); + + genCode(); +} + +QRCodeDialog::~QRCodeDialog() +{ + delete ui; +} + +void QRCodeDialog::setModel(OptionsModel *model) +{ + this->model = model; + + if (model) + connect(model, SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); + + // update the display unit, to not use the default ("BTC") + updateDisplayUnit(); +} + +void QRCodeDialog::genCode() +{ + QString uri = getURI(); + + if (uri != "https://SONO.tech") + { + ui->lblQRCode->setText("SONO"); + + QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1); + if (!code) + { + ui->lblQRCode->setText(tr("Error encoding URI into QR Code.")); + return; + } + myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32); + myImage.fill(0xffffff); + unsigned char *p = code->data; + for (int y = 0; y < code->width; y++) + { + for (int x = 0; x < code->width; x++) + { + myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff)); + p++; + } + } + QRcode_free(code); + + ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300)); + + ui->outUri->setPlainText(uri); + } +} + +QString QRCodeDialog::getURI() +{ + QString ret = QString("SONO:%1").arg(address); + int paramCount = 0; + + ui->outUri->clear(); + + if (ui->chkReqPayment->isChecked()) + { + if (ui->lnReqAmount->validate()) + { + // even if we allow a non BTC unit input in lnReqAmount, we generate the URI with BTC as unit (as defined in BIP21) + ret += QString("?amount=%1").arg(BitcoinUnits::format(BitcoinUnits::BTC, ui->lnReqAmount->value())); + paramCount++; + } + else + { + ui->btnSaveAs->setEnabled(false); + ui->lblQRCode->setText(tr("The entered amount is invalid, please check.")); + return QString(""); + } + } + + if (!ui->lnLabel->text().isEmpty()) + { + QString lbl(QUrl::toPercentEncoding(ui->lnLabel->text())); + ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl); + paramCount++; + } + + if (!ui->lnMessage->text().isEmpty()) + { + QString msg(QUrl::toPercentEncoding(ui->lnMessage->text())); + ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg); + paramCount++; + } + + // limit URI length to prevent a DoS against the QR-Code dialog + if (ret.length() > MAX_URI_LENGTH) + { + ui->btnSaveAs->setEnabled(false); + ui->lblQRCode->setText(tr("Resulting URI too long, try to reduce the text for label / message.")); + return QString(""); + } + + ui->btnSaveAs->setEnabled(true); + return ret; +} + +void QRCodeDialog::on_lnReqAmount_textChanged() +{ + genCode(); +} + +void QRCodeDialog::on_lnLabel_textChanged() +{ + genCode(); +} + +void QRCodeDialog::on_lnMessage_textChanged() +{ + genCode(); +} + +void QRCodeDialog::on_btnSaveAs_clicked() +{ + QString fn = GUIUtil::getSaveFileName(this, tr("Save QR Code"), QString(), tr("PNG Images (*.png)")); + if (!fn.isEmpty()) + myImage.scaled(EXPORT_IMAGE_SIZE, EXPORT_IMAGE_SIZE).save(fn); +} + +void QRCodeDialog::on_chkReqPayment_toggled(bool fChecked) +{ + if (!fChecked) + // if chkReqPayment is not active, don't display lnReqAmount as invalid + ui->lnReqAmount->setValid(true); + + genCode(); +} + +void QRCodeDialog::updateDisplayUnit() +{ + if (model) + { + // Update lnReqAmount with the current unit + ui->lnReqAmount->setDisplayUnit(model->getDisplayUnit()); + } +} diff --git a/src/qt/qrcodedialog.h b/src/qt/qrcodedialog.h new file mode 100644 index 0000000..0b1401e --- /dev/null +++ b/src/qt/qrcodedialog.h @@ -0,0 +1,41 @@ +#ifndef QRCODEDIALOG_H +#define QRCODEDIALOG_H + +#include +#include + +namespace Ui { + class QRCodeDialog; +} +class OptionsModel; + +class QRCodeDialog : public QDialog +{ + Q_OBJECT + +public: + explicit QRCodeDialog(const QString &addr, const QString &label, bool enableReq, QWidget *parent = 0); + ~QRCodeDialog(); + + void setModel(OptionsModel *model); + +private slots: + void on_lnReqAmount_textChanged(); + void on_lnLabel_textChanged(); + void on_lnMessage_textChanged(); + void on_btnSaveAs_clicked(); + void on_chkReqPayment_toggled(bool fChecked); + + void updateDisplayUnit(); + +private: + Ui::QRCodeDialog *ui; + OptionsModel *model; + QString address; + QImage myImage; + + void genCode(); + QString getURI(); +}; + +#endif // QRCODEDIALOG_H diff --git a/src/qt/qvalidatedlineedit.cpp b/src/qt/qvalidatedlineedit.cpp new file mode 100644 index 0000000..b32a29f --- /dev/null +++ b/src/qt/qvalidatedlineedit.cpp @@ -0,0 +1,45 @@ +#include "qvalidatedlineedit.h" + +#include "guiconstants.h" + +QValidatedLineEdit::QValidatedLineEdit(QWidget *parent) : + QLineEdit(parent), valid(true) +{ + connect(this, SIGNAL(textChanged(QString)), this, SLOT(markValid())); +} + +void QValidatedLineEdit::setValid(bool valid) +{ + if(valid == this->valid) + { + return; + } + + if(valid) + { + setStyleSheet(""); + } + else + { + setStyleSheet(STYLE_INVALID); + } + this->valid = valid; +} + +void QValidatedLineEdit::focusInEvent(QFocusEvent *evt) +{ + // Clear invalid flag on focus + setValid(true); + QLineEdit::focusInEvent(evt); +} + +void QValidatedLineEdit::markValid() +{ + setValid(true); +} + +void QValidatedLineEdit::clear() +{ + setValid(true); + QLineEdit::clear(); +} diff --git a/src/qt/qvalidatedlineedit.h b/src/qt/qvalidatedlineedit.h new file mode 100644 index 0000000..e17b82a --- /dev/null +++ b/src/qt/qvalidatedlineedit.h @@ -0,0 +1,30 @@ +#ifndef QVALIDATEDLINEEDIT_H +#define QVALIDATEDLINEEDIT_H + +#include + +/** Line edit that can be marked as "invalid" to show input validation feedback. When marked as invalid, + it will get a red background until it is focused. + */ +class QValidatedLineEdit : public QLineEdit +{ + Q_OBJECT + +public: + explicit QValidatedLineEdit(QWidget *parent = 0); + void clear(); + +protected: + void focusInEvent(QFocusEvent *evt); + +private: + bool valid; + +public slots: + void setValid(bool valid); + +private slots: + void markValid(); +}; + +#endif // QVALIDATEDLINEEDIT_H diff --git a/src/qt/qvalidatedtextedit.cpp b/src/qt/qvalidatedtextedit.cpp new file mode 100644 index 0000000..b81dcb6 --- /dev/null +++ b/src/qt/qvalidatedtextedit.cpp @@ -0,0 +1,44 @@ +#include "qvalidatedtextedit.h" + +#include "guiconstants.h" + +#include +QValidatedTextEdit::QValidatedTextEdit(QWidget *parent) : + QPlainTextEdit(parent), valid(true) +{} + +void QValidatedTextEdit::setValid(bool valid) +{ + setStyleSheet(valid ? "" : STYLE_INVALID); + + if(valid) + { + if(toPlainText() == this->errorText) + setPlainText(""); + } + else if(toPlainText() == "") + setPlainText(this->errorText); +} + +void QValidatedTextEdit::setErrorText(QString errorText) +{ + this->errorText = errorText; +} + +void QValidatedTextEdit::focusInEvent(QFocusEvent *evt) +{ + // Clear invalid flag on focus + setValid(true); + QPlainTextEdit::focusInEvent(evt); +} + +void QValidatedTextEdit::markValid() +{ + setValid(true); +} + +void QValidatedTextEdit::clear() +{ + setValid(true); + QPlainTextEdit::clear(); +} diff --git a/src/qt/qvalidatedtextedit.h b/src/qt/qvalidatedtextedit.h new file mode 100644 index 0000000..ee617ca --- /dev/null +++ b/src/qt/qvalidatedtextedit.h @@ -0,0 +1,31 @@ +#ifndef QVALIDATEDTEXTEDIT_H +#define QVALIDATEDTEXTEDIT_H + +#include + +/** Text edit that can be marked as "invalid" to show input validation feedback. When marked as invalid, + it will get a red background until it is focused. + */ +class QValidatedTextEdit : public QPlainTextEdit +{ + Q_OBJECT +public: + explicit QValidatedTextEdit(QWidget *parent = 0); + void clear(); + +protected: + void focusInEvent(QFocusEvent *evt); + +private: + bool valid; + QString errorText; + +public slots: + void setValid(bool valid); + void setErrorText(QString errorText); + +private slots: + void markValid(); +}; + +#endif // QVALIDATEDTEXTEDIT_H diff --git a/src/qt/qvaluecombobox.cpp b/src/qt/qvaluecombobox.cpp new file mode 100644 index 0000000..02fb7a3 --- /dev/null +++ b/src/qt/qvaluecombobox.cpp @@ -0,0 +1,31 @@ +#include "qvaluecombobox.h" + +#include + +QValueComboBox::QValueComboBox(QWidget *parent) : + QComboBox(parent), role(Qt::UserRole) +{ + setItemDelegate(new QStyledItemDelegate()); + + connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int))); +} + +QVariant QValueComboBox::value() const +{ + return itemData(currentIndex(), role); +} + +void QValueComboBox::setValue(const QVariant &value) +{ + setCurrentIndex(findData(value, role)); +} + +void QValueComboBox::setRole(int role) +{ + this->role = role; +} + +void QValueComboBox::handleSelectionChanged(int idx) +{ + emit valueChanged(); +} diff --git a/src/qt/qvaluecombobox.h b/src/qt/qvaluecombobox.h new file mode 100644 index 0000000..d630073 --- /dev/null +++ b/src/qt/qvaluecombobox.h @@ -0,0 +1,33 @@ +#ifndef QVALUECOMBOBOX_H +#define QVALUECOMBOBOX_H + +#include +#include + +/* QComboBox that can be used with QDataWidgetMapper to select ordinal values from a model. */ +class QValueComboBox : public QComboBox +{ + Q_OBJECT + + Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged USER true) + +public: + explicit QValueComboBox(QWidget *parent = 0); + + QVariant value() const; + void setValue(const QVariant &value); + + /** Specify model role to use as ordinal value (defaults to Qt::UserRole) */ + void setRole(int role); + +signals: + void valueChanged(); + +private: + int role; + +private slots: + void handleSelectionChanged(int idx); +}; + +#endif // QVALUECOMBOBOX_H diff --git a/src/qt/res/bitcoin-qt.rc b/src/qt/res/bitcoin-qt.rc new file mode 100644 index 0000000..158f8a4 --- /dev/null +++ b/src/qt/res/bitcoin-qt.rc @@ -0,0 +1,37 @@ +IDI_ICON1 ICON DISCARDABLE "icons/SONO.ico" + +#include // needed for VERSIONINFO +#include "../../clientversion.h" // holds the needed client version information + +#define VER_PRODUCTVERSION CLIENT_VERSION_MAJOR,CLIENT_VERSION_MINOR,CLIENT_VERSION_REVISION,CLIENT_VERSION_BUILD +#define VER_PRODUCTVERSION_STR STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE(CLIENT_VERSION_MINOR) "." STRINGIZE(CLIENT_VERSION_REVISION) "." STRINGIZE(CLIENT_VERSION_BUILD) +#define VER_FILEVERSION VER_PRODUCTVERSION +#define VER_FILEVERSION_STR VER_PRODUCTVERSION_STR + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_FILEVERSION +PRODUCTVERSION VER_PRODUCTVERSION +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "216k155" // U.S. English - multilingual (hex) + BEGIN + VALUE "CompanyName", "SONO" + VALUE "FileDescription", "SONO-Qt (OSS GUI client for SONO)" + VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "InternalName", "SONO-qt" + VALUE "LegalCopyright", "Copyright © 2017 by 216k155 @Dra" + VALUE "LegalTrademarks1", "Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." + VALUE "OriginalFilename", "SONO-qt.exe" + VALUE "ProductName", "SONO-Qt" + VALUE "ProductVersion", VER_PRODUCTVERSION_STR + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1252 // language neutral - multilingual (decimal) + END +END diff --git a/src/qt/res/icons/SONO-128.png b/src/qt/res/icons/SONO-128.png new file mode 100644 index 0000000..46f7207 Binary files /dev/null and b/src/qt/res/icons/SONO-128.png differ diff --git a/src/qt/res/icons/SONO-16.png b/src/qt/res/icons/SONO-16.png new file mode 100644 index 0000000..20c3eaa Binary files /dev/null and b/src/qt/res/icons/SONO-16.png differ diff --git a/src/qt/res/icons/SONO-32.png b/src/qt/res/icons/SONO-32.png new file mode 100644 index 0000000..f17bc59 Binary files /dev/null and b/src/qt/res/icons/SONO-32.png differ diff --git a/src/qt/res/icons/SONO-48.png b/src/qt/res/icons/SONO-48.png new file mode 100644 index 0000000..b90bebc Binary files /dev/null and b/src/qt/res/icons/SONO-48.png differ diff --git a/src/qt/res/icons/SONO-80.png b/src/qt/res/icons/SONO-80.png new file mode 100644 index 0000000..7da51c8 Binary files /dev/null and b/src/qt/res/icons/SONO-80.png differ diff --git a/src/qt/res/icons/SONO-testnet.png b/src/qt/res/icons/SONO-testnet.png new file mode 100644 index 0000000..c093057 Binary files /dev/null and b/src/qt/res/icons/SONO-testnet.png differ diff --git a/src/qt/res/icons/SONO.icns b/src/qt/res/icons/SONO.icns new file mode 100644 index 0000000..7c25927 Binary files /dev/null and b/src/qt/res/icons/SONO.icns differ diff --git a/src/qt/res/icons/SONO.ico b/src/qt/res/icons/SONO.ico new file mode 100644 index 0000000..30070b7 Binary files /dev/null and b/src/qt/res/icons/SONO.ico differ diff --git a/src/qt/res/icons/SONO.png b/src/qt/res/icons/SONO.png new file mode 100644 index 0000000..1b4078b Binary files /dev/null and b/src/qt/res/icons/SONO.png differ diff --git a/src/qt/res/icons/add.png b/src/qt/res/icons/add.png new file mode 100644 index 0000000..1442b4e Binary files /dev/null and b/src/qt/res/icons/add.png differ diff --git a/src/qt/res/icons/address-book.png b/src/qt/res/icons/address-book.png new file mode 100644 index 0000000..b11c7d5 Binary files /dev/null and b/src/qt/res/icons/address-book.png differ diff --git a/src/qt/res/icons/back/SONO-128.png b/src/qt/res/icons/back/SONO-128.png new file mode 100644 index 0000000..46f7207 Binary files /dev/null and b/src/qt/res/icons/back/SONO-128.png differ diff --git a/src/qt/res/icons/back/SONO-16.png b/src/qt/res/icons/back/SONO-16.png new file mode 100644 index 0000000..20c3eaa Binary files /dev/null and b/src/qt/res/icons/back/SONO-16.png differ diff --git a/src/qt/res/icons/back/SONO-32.png b/src/qt/res/icons/back/SONO-32.png new file mode 100644 index 0000000..f17bc59 Binary files /dev/null and b/src/qt/res/icons/back/SONO-32.png differ diff --git a/src/qt/res/icons/back/SONO-48.png b/src/qt/res/icons/back/SONO-48.png new file mode 100644 index 0000000..b90bebc Binary files /dev/null and b/src/qt/res/icons/back/SONO-48.png differ diff --git a/src/qt/res/icons/back/SONO-80.png b/src/qt/res/icons/back/SONO-80.png new file mode 100644 index 0000000..7da51c8 Binary files /dev/null and b/src/qt/res/icons/back/SONO-80.png differ diff --git a/src/qt/res/icons/back/SONO-testnet.png b/src/qt/res/icons/back/SONO-testnet.png new file mode 100644 index 0000000..c093057 Binary files /dev/null and b/src/qt/res/icons/back/SONO-testnet.png differ diff --git a/src/qt/res/icons/back/SONO.icns b/src/qt/res/icons/back/SONO.icns new file mode 100644 index 0000000..7c25927 Binary files /dev/null and b/src/qt/res/icons/back/SONO.icns differ diff --git a/src/qt/res/icons/back/SONO.ico b/src/qt/res/icons/back/SONO.ico new file mode 100644 index 0000000..30070b7 Binary files /dev/null and b/src/qt/res/icons/back/SONO.ico differ diff --git a/src/qt/res/icons/back/SONO.png b/src/qt/res/icons/back/SONO.png new file mode 100644 index 0000000..1b4078b Binary files /dev/null and b/src/qt/res/icons/back/SONO.png differ diff --git a/src/qt/res/icons/back/add.png b/src/qt/res/icons/back/add.png new file mode 100644 index 0000000..1442b4e Binary files /dev/null and b/src/qt/res/icons/back/add.png differ diff --git a/src/qt/res/icons/back/add_2.png b/src/qt/res/icons/back/add_2.png new file mode 100644 index 0000000..f98e2a8 Binary files /dev/null and b/src/qt/res/icons/back/add_2.png differ diff --git a/src/qt/res/icons/back/address-book.png b/src/qt/res/icons/back/address-book.png new file mode 100644 index 0000000..b11c7d5 Binary files /dev/null and b/src/qt/res/icons/back/address-book.png differ diff --git a/src/qt/res/icons/back/address-book_2.png b/src/qt/res/icons/back/address-book_2.png new file mode 100644 index 0000000..6e00664 Binary files /dev/null and b/src/qt/res/icons/back/address-book_2.png differ diff --git a/src/qt/res/icons/back/bitcoin.icns b/src/qt/res/icons/back/bitcoin.icns new file mode 100644 index 0000000..54d02d3 Binary files /dev/null and b/src/qt/res/icons/back/bitcoin.icns differ diff --git a/src/qt/res/icons/back/bitcoin_2.icns b/src/qt/res/icons/back/bitcoin_2.icns new file mode 100644 index 0000000..2d7e5ac Binary files /dev/null and b/src/qt/res/icons/back/bitcoin_2.icns differ diff --git a/src/qt/res/icons/back/chevron.png b/src/qt/res/icons/back/chevron.png new file mode 100644 index 0000000..2309fb3 Binary files /dev/null and b/src/qt/res/icons/back/chevron.png differ diff --git a/src/qt/res/icons/back/clock1.png b/src/qt/res/icons/back/clock1.png new file mode 100644 index 0000000..162204d Binary files /dev/null and b/src/qt/res/icons/back/clock1.png differ diff --git a/src/qt/res/icons/back/clock2.png b/src/qt/res/icons/back/clock2.png new file mode 100644 index 0000000..8f4263a Binary files /dev/null and b/src/qt/res/icons/back/clock2.png differ diff --git a/src/qt/res/icons/back/clock3.png b/src/qt/res/icons/back/clock3.png new file mode 100644 index 0000000..7f11a75 Binary files /dev/null and b/src/qt/res/icons/back/clock3.png differ diff --git a/src/qt/res/icons/back/clock4.png b/src/qt/res/icons/back/clock4.png new file mode 100644 index 0000000..fdd1a0f Binary files /dev/null and b/src/qt/res/icons/back/clock4.png differ diff --git a/src/qt/res/icons/back/clock5.png b/src/qt/res/icons/back/clock5.png new file mode 100644 index 0000000..7d6556c Binary files /dev/null and b/src/qt/res/icons/back/clock5.png differ diff --git a/src/qt/res/icons/back/configure.png b/src/qt/res/icons/back/configure.png new file mode 100644 index 0000000..5333c83 Binary files /dev/null and b/src/qt/res/icons/back/configure.png differ diff --git a/src/qt/res/icons/back/configure_2.png b/src/qt/res/icons/back/configure_2.png new file mode 100644 index 0000000..95bd319 Binary files /dev/null and b/src/qt/res/icons/back/configure_2.png differ diff --git a/src/qt/res/icons/back/connect.png b/src/qt/res/icons/back/connect.png new file mode 100644 index 0000000..aa05d91 Binary files /dev/null and b/src/qt/res/icons/back/connect.png differ diff --git a/src/qt/res/icons/back/connect0.png b/src/qt/res/icons/back/connect0.png new file mode 100644 index 0000000..ef708d8 Binary files /dev/null and b/src/qt/res/icons/back/connect0.png differ diff --git a/src/qt/res/icons/back/connect0_16.png b/src/qt/res/icons/back/connect0_16.png new file mode 100644 index 0000000..ed541aa Binary files /dev/null and b/src/qt/res/icons/back/connect0_16.png differ diff --git a/src/qt/res/icons/back/connect0_16_2.png b/src/qt/res/icons/back/connect0_16_2.png new file mode 100644 index 0000000..66f3ae4 Binary files /dev/null and b/src/qt/res/icons/back/connect0_16_2.png differ diff --git a/src/qt/res/icons/back/connect1.png b/src/qt/res/icons/back/connect1.png new file mode 100644 index 0000000..ed358e6 Binary files /dev/null and b/src/qt/res/icons/back/connect1.png differ diff --git a/src/qt/res/icons/back/connect1_16.png b/src/qt/res/icons/back/connect1_16.png new file mode 100644 index 0000000..ed358e6 Binary files /dev/null and b/src/qt/res/icons/back/connect1_16.png differ diff --git a/src/qt/res/icons/back/connect1_16_2.png b/src/qt/res/icons/back/connect1_16_2.png new file mode 100644 index 0000000..76000be Binary files /dev/null and b/src/qt/res/icons/back/connect1_16_2.png differ diff --git a/src/qt/res/icons/back/connect2.png b/src/qt/res/icons/back/connect2.png new file mode 100644 index 0000000..3bbb0d3 Binary files /dev/null and b/src/qt/res/icons/back/connect2.png differ diff --git a/src/qt/res/icons/back/connect2_16.png b/src/qt/res/icons/back/connect2_16.png new file mode 100644 index 0000000..3bbb0d3 Binary files /dev/null and b/src/qt/res/icons/back/connect2_16.png differ diff --git a/src/qt/res/icons/back/connect2_16_2.png b/src/qt/res/icons/back/connect2_16_2.png new file mode 100644 index 0000000..6d9a372 Binary files /dev/null and b/src/qt/res/icons/back/connect2_16_2.png differ diff --git a/src/qt/res/icons/back/connect3.png b/src/qt/res/icons/back/connect3.png new file mode 100644 index 0000000..0db99ad Binary files /dev/null and b/src/qt/res/icons/back/connect3.png differ diff --git a/src/qt/res/icons/back/connect3_16.png b/src/qt/res/icons/back/connect3_16.png new file mode 100644 index 0000000..0db99ad Binary files /dev/null and b/src/qt/res/icons/back/connect3_16.png differ diff --git a/src/qt/res/icons/back/connect3_16_2.png b/src/qt/res/icons/back/connect3_16_2.png new file mode 100644 index 0000000..a211700 Binary files /dev/null and b/src/qt/res/icons/back/connect3_16_2.png differ diff --git a/src/qt/res/icons/back/connect4.png b/src/qt/res/icons/back/connect4.png new file mode 100644 index 0000000..9dd19fc Binary files /dev/null and b/src/qt/res/icons/back/connect4.png differ diff --git a/src/qt/res/icons/back/connect4_16.png b/src/qt/res/icons/back/connect4_16.png new file mode 100644 index 0000000..9dd19fc Binary files /dev/null and b/src/qt/res/icons/back/connect4_16.png differ diff --git a/src/qt/res/icons/back/connect4_16_2.png b/src/qt/res/icons/back/connect4_16_2.png new file mode 100644 index 0000000..c1232f5 Binary files /dev/null and b/src/qt/res/icons/back/connect4_16_2.png differ diff --git a/src/qt/res/icons/back/debugwindow.png b/src/qt/res/icons/back/debugwindow.png new file mode 100644 index 0000000..290fe60 Binary files /dev/null and b/src/qt/res/icons/back/debugwindow.png differ diff --git a/src/qt/res/icons/back/debugwindow_2.png b/src/qt/res/icons/back/debugwindow_2.png new file mode 100644 index 0000000..1712adf Binary files /dev/null and b/src/qt/res/icons/back/debugwindow_2.png differ diff --git a/src/qt/res/icons/back/edit.png b/src/qt/res/icons/back/edit.png new file mode 100644 index 0000000..4658271 Binary files /dev/null and b/src/qt/res/icons/back/edit.png differ diff --git a/src/qt/res/icons/back/edit_2.png b/src/qt/res/icons/back/edit_2.png new file mode 100644 index 0000000..1d69145 Binary files /dev/null and b/src/qt/res/icons/back/edit_2.png differ diff --git a/src/qt/res/icons/back/editcopy.png b/src/qt/res/icons/back/editcopy.png new file mode 100644 index 0000000..74ac8b2 Binary files /dev/null and b/src/qt/res/icons/back/editcopy.png differ diff --git a/src/qt/res/icons/back/editcopy_2.png b/src/qt/res/icons/back/editcopy_2.png new file mode 100644 index 0000000..f882aa2 Binary files /dev/null and b/src/qt/res/icons/back/editcopy_2.png differ diff --git a/src/qt/res/icons/back/editpaste.png b/src/qt/res/icons/back/editpaste.png new file mode 100644 index 0000000..7b47f4d Binary files /dev/null and b/src/qt/res/icons/back/editpaste.png differ diff --git a/src/qt/res/icons/back/editpaste_2.png b/src/qt/res/icons/back/editpaste_2.png new file mode 100644 index 0000000..a192060 Binary files /dev/null and b/src/qt/res/icons/back/editpaste_2.png differ diff --git a/src/qt/res/icons/back/explorer.png b/src/qt/res/icons/back/explorer.png new file mode 100644 index 0000000..bacc267 Binary files /dev/null and b/src/qt/res/icons/back/explorer.png differ diff --git a/src/qt/res/icons/back/export.png b/src/qt/res/icons/back/export.png new file mode 100644 index 0000000..ac76cc1 Binary files /dev/null and b/src/qt/res/icons/back/export.png differ diff --git a/src/qt/res/icons/back/export_2.png b/src/qt/res/icons/back/export_2.png new file mode 100644 index 0000000..1df9c23 Binary files /dev/null and b/src/qt/res/icons/back/export_2.png differ diff --git a/src/qt/res/icons/back/eye.png b/src/qt/res/icons/back/eye.png new file mode 100644 index 0000000..f2f139d Binary files /dev/null and b/src/qt/res/icons/back/eye.png differ diff --git a/src/qt/res/icons/back/eye_minus.png b/src/qt/res/icons/back/eye_minus.png new file mode 100644 index 0000000..795bf64 Binary files /dev/null and b/src/qt/res/icons/back/eye_minus.png differ diff --git a/src/qt/res/icons/back/eye_plus.png b/src/qt/res/icons/back/eye_plus.png new file mode 100644 index 0000000..eaab692 Binary files /dev/null and b/src/qt/res/icons/back/eye_plus.png differ diff --git a/src/qt/res/icons/back/filesave.png b/src/qt/res/icons/back/filesave.png new file mode 100644 index 0000000..779cca1 Binary files /dev/null and b/src/qt/res/icons/back/filesave.png differ diff --git a/src/qt/res/icons/back/filesave_2.png b/src/qt/res/icons/back/filesave_2.png new file mode 100644 index 0000000..ae13a15 Binary files /dev/null and b/src/qt/res/icons/back/filesave_2.png differ diff --git a/src/qt/res/icons/back/fontbigger.png b/src/qt/res/icons/back/fontbigger.png new file mode 100644 index 0000000..5ca5c56 Binary files /dev/null and b/src/qt/res/icons/back/fontbigger.png differ diff --git a/src/qt/res/icons/back/fontsmaller.png b/src/qt/res/icons/back/fontsmaller.png new file mode 100644 index 0000000..1a6bb3a Binary files /dev/null and b/src/qt/res/icons/back/fontsmaller.png differ diff --git a/src/qt/res/icons/back/hd_disabled.png b/src/qt/res/icons/back/hd_disabled.png new file mode 100644 index 0000000..687b6d2 Binary files /dev/null and b/src/qt/res/icons/back/hd_disabled.png differ diff --git a/src/qt/res/icons/back/hd_enabled.png b/src/qt/res/icons/back/hd_enabled.png new file mode 100644 index 0000000..568dde1 Binary files /dev/null and b/src/qt/res/icons/back/hd_enabled.png differ diff --git a/src/qt/res/icons/back/history.png b/src/qt/res/icons/back/history.png new file mode 100644 index 0000000..68d841f Binary files /dev/null and b/src/qt/res/icons/back/history.png differ diff --git a/src/qt/res/icons/back/info.png b/src/qt/res/icons/back/info.png new file mode 100644 index 0000000..692b50c Binary files /dev/null and b/src/qt/res/icons/back/info.png differ diff --git a/src/qt/res/icons/back/key.png b/src/qt/res/icons/back/key.png new file mode 100644 index 0000000..f301c4f Binary files /dev/null and b/src/qt/res/icons/back/key.png differ diff --git a/src/qt/res/icons/back/key_2.png b/src/qt/res/icons/back/key_2.png new file mode 100644 index 0000000..ece0164 Binary files /dev/null and b/src/qt/res/icons/back/key_2.png differ diff --git a/src/qt/res/icons/back/lock_closed.png b/src/qt/res/icons/back/lock_closed.png new file mode 100644 index 0000000..1bd98b2 Binary files /dev/null and b/src/qt/res/icons/back/lock_closed.png differ diff --git a/src/qt/res/icons/back/lock_closed_2.png b/src/qt/res/icons/back/lock_closed_2.png new file mode 100644 index 0000000..c566510 Binary files /dev/null and b/src/qt/res/icons/back/lock_closed_2.png differ diff --git a/src/qt/res/icons/back/lock_open.png b/src/qt/res/icons/back/lock_open.png new file mode 100644 index 0000000..a704513 Binary files /dev/null and b/src/qt/res/icons/back/lock_open.png differ diff --git a/src/qt/res/icons/back/lock_open_2.png b/src/qt/res/icons/back/lock_open_2.png new file mode 100644 index 0000000..c98ca86 Binary files /dev/null and b/src/qt/res/icons/back/lock_open_2.png differ diff --git a/src/qt/res/icons/back/messages.png b/src/qt/res/icons/back/messages.png new file mode 100644 index 0000000..a323c87 Binary files /dev/null and b/src/qt/res/icons/back/messages.png differ diff --git a/src/qt/res/icons/back/mining_active.png b/src/qt/res/icons/back/mining_active.png new file mode 100644 index 0000000..b48c7b9 Binary files /dev/null and b/src/qt/res/icons/back/mining_active.png differ diff --git a/src/qt/res/icons/back/mining_inactive.png b/src/qt/res/icons/back/mining_inactive.png new file mode 100644 index 0000000..8644761 Binary files /dev/null and b/src/qt/res/icons/back/mining_inactive.png differ diff --git a/src/qt/res/icons/back/network_disabled.png b/src/qt/res/icons/back/network_disabled.png new file mode 100644 index 0000000..269c3cf Binary files /dev/null and b/src/qt/res/icons/back/network_disabled.png differ diff --git a/src/qt/res/icons/back/notsynced.png b/src/qt/res/icons/back/notsynced.png new file mode 100644 index 0000000..7d134ae Binary files /dev/null and b/src/qt/res/icons/back/notsynced.png differ diff --git a/src/qt/res/icons/back/notsynced_2.png b/src/qt/res/icons/back/notsynced_2.png new file mode 100644 index 0000000..c9e7118 Binary files /dev/null and b/src/qt/res/icons/back/notsynced_2.png differ diff --git a/src/qt/res/icons/back/onion-black.png b/src/qt/res/icons/back/onion-black.png new file mode 100644 index 0000000..e3ec917 Binary files /dev/null and b/src/qt/res/icons/back/onion-black.png differ diff --git a/src/qt/res/icons/back/onion.png b/src/qt/res/icons/back/onion.png new file mode 100644 index 0000000..7ade2da Binary files /dev/null and b/src/qt/res/icons/back/onion.png differ diff --git a/src/qt/res/icons/back/open.png b/src/qt/res/icons/back/open.png new file mode 100644 index 0000000..4d958f0 Binary files /dev/null and b/src/qt/res/icons/back/open.png differ diff --git a/src/qt/res/icons/back/overview.png b/src/qt/res/icons/back/overview.png new file mode 100644 index 0000000..4115954 Binary files /dev/null and b/src/qt/res/icons/back/overview.png differ diff --git a/src/qt/res/icons/back/qrcode.png b/src/qt/res/icons/back/qrcode.png new file mode 100644 index 0000000..bb3cb73 Binary files /dev/null and b/src/qt/res/icons/back/qrcode.png differ diff --git a/src/qt/res/icons/back/quit.png b/src/qt/res/icons/back/quit.png new file mode 100644 index 0000000..55e34de Binary files /dev/null and b/src/qt/res/icons/back/quit.png differ diff --git a/src/qt/res/icons/back/quit_2.png b/src/qt/res/icons/back/quit_2.png new file mode 100644 index 0000000..0dde6f3 Binary files /dev/null and b/src/qt/res/icons/back/quit_2.png differ diff --git a/src/qt/res/icons/back/receive.png b/src/qt/res/icons/back/receive.png new file mode 100644 index 0000000..f4e6f58 Binary files /dev/null and b/src/qt/res/icons/back/receive.png differ diff --git a/src/qt/res/icons/back/remove.png b/src/qt/res/icons/back/remove.png new file mode 100644 index 0000000..8e738d6 Binary files /dev/null and b/src/qt/res/icons/back/remove.png differ diff --git a/src/qt/res/icons/back/remove_2.png b/src/qt/res/icons/back/remove_2.png new file mode 100644 index 0000000..a44b6d1 Binary files /dev/null and b/src/qt/res/icons/back/remove_2.png differ diff --git a/src/qt/res/icons/back/send.png b/src/qt/res/icons/back/send.png new file mode 100644 index 0000000..ac76cc1 Binary files /dev/null and b/src/qt/res/icons/back/send.png differ diff --git a/src/qt/res/icons/back/staking_off.png b/src/qt/res/icons/back/staking_off.png new file mode 100644 index 0000000..40d7a7d Binary files /dev/null and b/src/qt/res/icons/back/staking_off.png differ diff --git a/src/qt/res/icons/back/staking_off_2.png b/src/qt/res/icons/back/staking_off_2.png new file mode 100644 index 0000000..91e570e Binary files /dev/null and b/src/qt/res/icons/back/staking_off_2.png differ diff --git a/src/qt/res/icons/back/staking_on.png b/src/qt/res/icons/back/staking_on.png new file mode 100644 index 0000000..0cf561a Binary files /dev/null and b/src/qt/res/icons/back/staking_on.png differ diff --git a/src/qt/res/icons/back/staking_on_2.png b/src/qt/res/icons/back/staking_on_2.png new file mode 100644 index 0000000..1a5e8c2 Binary files /dev/null and b/src/qt/res/icons/back/staking_on_2.png differ diff --git a/src/qt/res/icons/back/statistics.png b/src/qt/res/icons/back/statistics.png new file mode 100644 index 0000000..37f3fdb Binary files /dev/null and b/src/qt/res/icons/back/statistics.png differ diff --git a/src/qt/res/icons/back/synced.png b/src/qt/res/icons/back/synced.png new file mode 100644 index 0000000..5ac28d3 Binary files /dev/null and b/src/qt/res/icons/back/synced.png differ diff --git a/src/qt/res/icons/back/synced_2.png b/src/qt/res/icons/back/synced_2.png new file mode 100644 index 0000000..4d7e0e8 Binary files /dev/null and b/src/qt/res/icons/back/synced_2.png differ diff --git a/src/qt/res/icons/back/transaction0.png b/src/qt/res/icons/back/transaction0.png new file mode 100644 index 0000000..72c4456 Binary files /dev/null and b/src/qt/res/icons/back/transaction0.png differ diff --git a/src/qt/res/icons/back/transaction0_2.png b/src/qt/res/icons/back/transaction0_2.png new file mode 100644 index 0000000..4578666 Binary files /dev/null and b/src/qt/res/icons/back/transaction0_2.png differ diff --git a/src/qt/res/icons/back/transaction2.png b/src/qt/res/icons/back/transaction2.png new file mode 100644 index 0000000..5ac28d3 Binary files /dev/null and b/src/qt/res/icons/back/transaction2.png differ diff --git a/src/qt/res/icons/back/transaction2_2.png b/src/qt/res/icons/back/transaction2_2.png new file mode 100644 index 0000000..01bb558 Binary files /dev/null and b/src/qt/res/icons/back/transaction2_2.png differ diff --git a/src/qt/res/icons/back/transaction_abandoned.png b/src/qt/res/icons/back/transaction_abandoned.png new file mode 100644 index 0000000..8ca6445 Binary files /dev/null and b/src/qt/res/icons/back/transaction_abandoned.png differ diff --git a/src/qt/res/icons/back/transaction_conflicted.png b/src/qt/res/icons/back/transaction_conflicted.png new file mode 100644 index 0000000..55e34de Binary files /dev/null and b/src/qt/res/icons/back/transaction_conflicted.png differ diff --git a/src/qt/res/icons/back/transaction_conflicted_2.png b/src/qt/res/icons/back/transaction_conflicted_2.png new file mode 100644 index 0000000..51fff64 Binary files /dev/null and b/src/qt/res/icons/back/transaction_conflicted_2.png differ diff --git a/src/qt/res/icons/back/tx_inout.png b/src/qt/res/icons/back/tx_inout.png new file mode 100644 index 0000000..0a6e72a Binary files /dev/null and b/src/qt/res/icons/back/tx_inout.png differ diff --git a/src/qt/res/icons/back/tx_input.png b/src/qt/res/icons/back/tx_input.png new file mode 100644 index 0000000..9e9ee92 Binary files /dev/null and b/src/qt/res/icons/back/tx_input.png differ diff --git a/src/qt/res/icons/back/tx_mined.png b/src/qt/res/icons/back/tx_mined.png new file mode 100644 index 0000000..5a6ef52 Binary files /dev/null and b/src/qt/res/icons/back/tx_mined.png differ diff --git a/src/qt/res/icons/back/tx_output.png b/src/qt/res/icons/back/tx_output.png new file mode 100644 index 0000000..6f66ab6 Binary files /dev/null and b/src/qt/res/icons/back/tx_output.png differ diff --git a/src/qt/res/icons/back/verify.png b/src/qt/res/icons/back/verify.png new file mode 100644 index 0000000..8e2cb2c Binary files /dev/null and b/src/qt/res/icons/back/verify.png differ diff --git a/src/qt/res/icons/back/warning.png b/src/qt/res/icons/back/warning.png new file mode 100644 index 0000000..6bc5ac7 Binary files /dev/null and b/src/qt/res/icons/back/warning.png differ diff --git a/src/qt/res/icons/bitcoin.icns b/src/qt/res/icons/bitcoin.icns new file mode 100644 index 0000000..54d02d3 Binary files /dev/null and b/src/qt/res/icons/bitcoin.icns differ diff --git a/src/qt/res/icons/black/SONO-128.png b/src/qt/res/icons/black/SONO-128.png new file mode 100644 index 0000000..46f7207 Binary files /dev/null and b/src/qt/res/icons/black/SONO-128.png differ diff --git a/src/qt/res/icons/black/SONO-16.png b/src/qt/res/icons/black/SONO-16.png new file mode 100644 index 0000000..20c3eaa Binary files /dev/null and b/src/qt/res/icons/black/SONO-16.png differ diff --git a/src/qt/res/icons/black/SONO-32.png b/src/qt/res/icons/black/SONO-32.png new file mode 100644 index 0000000..f17bc59 Binary files /dev/null and b/src/qt/res/icons/black/SONO-32.png differ diff --git a/src/qt/res/icons/black/SONO-48.png b/src/qt/res/icons/black/SONO-48.png new file mode 100644 index 0000000..b90bebc Binary files /dev/null and b/src/qt/res/icons/black/SONO-48.png differ diff --git a/src/qt/res/icons/black/SONO-80.png b/src/qt/res/icons/black/SONO-80.png new file mode 100644 index 0000000..7da51c8 Binary files /dev/null and b/src/qt/res/icons/black/SONO-80.png differ diff --git a/src/qt/res/icons/black/SONO-testnet.png b/src/qt/res/icons/black/SONO-testnet.png new file mode 100644 index 0000000..c093057 Binary files /dev/null and b/src/qt/res/icons/black/SONO-testnet.png differ diff --git a/src/qt/res/icons/black/SONO.icns b/src/qt/res/icons/black/SONO.icns new file mode 100644 index 0000000..7c25927 Binary files /dev/null and b/src/qt/res/icons/black/SONO.icns differ diff --git a/src/qt/res/icons/black/SONO.ico b/src/qt/res/icons/black/SONO.ico new file mode 100644 index 0000000..30070b7 Binary files /dev/null and b/src/qt/res/icons/black/SONO.ico differ diff --git a/src/qt/res/icons/black/SONO.png b/src/qt/res/icons/black/SONO.png new file mode 100644 index 0000000..1b4078b Binary files /dev/null and b/src/qt/res/icons/black/SONO.png differ diff --git a/src/qt/res/icons/black/add.png b/src/qt/res/icons/black/add.png new file mode 100644 index 0000000..1442b4e Binary files /dev/null and b/src/qt/res/icons/black/add.png differ diff --git a/src/qt/res/icons/black/address-book.png b/src/qt/res/icons/black/address-book.png new file mode 100644 index 0000000..b11c7d5 Binary files /dev/null and b/src/qt/res/icons/black/address-book.png differ diff --git a/src/qt/res/icons/black/bitcoin.icns b/src/qt/res/icons/black/bitcoin.icns new file mode 100644 index 0000000..54d02d3 Binary files /dev/null and b/src/qt/res/icons/black/bitcoin.icns differ diff --git a/src/qt/res/icons/black/chevron.png b/src/qt/res/icons/black/chevron.png new file mode 100644 index 0000000..2309fb3 Binary files /dev/null and b/src/qt/res/icons/black/chevron.png differ diff --git a/src/qt/res/icons/black/clock1.png b/src/qt/res/icons/black/clock1.png new file mode 100644 index 0000000..162204d Binary files /dev/null and b/src/qt/res/icons/black/clock1.png differ diff --git a/src/qt/res/icons/black/clock2.png b/src/qt/res/icons/black/clock2.png new file mode 100644 index 0000000..8f4263a Binary files /dev/null and b/src/qt/res/icons/black/clock2.png differ diff --git a/src/qt/res/icons/black/clock3.png b/src/qt/res/icons/black/clock3.png new file mode 100644 index 0000000..7f11a75 Binary files /dev/null and b/src/qt/res/icons/black/clock3.png differ diff --git a/src/qt/res/icons/black/clock4.png b/src/qt/res/icons/black/clock4.png new file mode 100644 index 0000000..fdd1a0f Binary files /dev/null and b/src/qt/res/icons/black/clock4.png differ diff --git a/src/qt/res/icons/black/clock5.png b/src/qt/res/icons/black/clock5.png new file mode 100644 index 0000000..7d6556c Binary files /dev/null and b/src/qt/res/icons/black/clock5.png differ diff --git a/src/qt/res/icons/black/configure.png b/src/qt/res/icons/black/configure.png new file mode 100644 index 0000000..5333c83 Binary files /dev/null and b/src/qt/res/icons/black/configure.png differ diff --git a/src/qt/res/icons/black/connect.png b/src/qt/res/icons/black/connect.png new file mode 100644 index 0000000..aa05d91 Binary files /dev/null and b/src/qt/res/icons/black/connect.png differ diff --git a/src/qt/res/icons/black/connect0.png b/src/qt/res/icons/black/connect0.png new file mode 100644 index 0000000..ef708d8 Binary files /dev/null and b/src/qt/res/icons/black/connect0.png differ diff --git a/src/qt/res/icons/black/connect0_16.png b/src/qt/res/icons/black/connect0_16.png new file mode 100644 index 0000000..ed541aa Binary files /dev/null and b/src/qt/res/icons/black/connect0_16.png differ diff --git a/src/qt/res/icons/black/connect1.png b/src/qt/res/icons/black/connect1.png new file mode 100644 index 0000000..ed358e6 Binary files /dev/null and b/src/qt/res/icons/black/connect1.png differ diff --git a/src/qt/res/icons/black/connect1_16.png b/src/qt/res/icons/black/connect1_16.png new file mode 100644 index 0000000..ed358e6 Binary files /dev/null and b/src/qt/res/icons/black/connect1_16.png differ diff --git a/src/qt/res/icons/black/connect2.png b/src/qt/res/icons/black/connect2.png new file mode 100644 index 0000000..3bbb0d3 Binary files /dev/null and b/src/qt/res/icons/black/connect2.png differ diff --git a/src/qt/res/icons/black/connect2_16.png b/src/qt/res/icons/black/connect2_16.png new file mode 100644 index 0000000..3bbb0d3 Binary files /dev/null and b/src/qt/res/icons/black/connect2_16.png differ diff --git a/src/qt/res/icons/black/connect3.png b/src/qt/res/icons/black/connect3.png new file mode 100644 index 0000000..0db99ad Binary files /dev/null and b/src/qt/res/icons/black/connect3.png differ diff --git a/src/qt/res/icons/black/connect3_16.png b/src/qt/res/icons/black/connect3_16.png new file mode 100644 index 0000000..0db99ad Binary files /dev/null and b/src/qt/res/icons/black/connect3_16.png differ diff --git a/src/qt/res/icons/black/connect4.png b/src/qt/res/icons/black/connect4.png new file mode 100644 index 0000000..9dd19fc Binary files /dev/null and b/src/qt/res/icons/black/connect4.png differ diff --git a/src/qt/res/icons/black/connect4_16.png b/src/qt/res/icons/black/connect4_16.png new file mode 100644 index 0000000..9dd19fc Binary files /dev/null and b/src/qt/res/icons/black/connect4_16.png differ diff --git a/src/qt/res/icons/black/debugwindow.png b/src/qt/res/icons/black/debugwindow.png new file mode 100644 index 0000000..290fe60 Binary files /dev/null and b/src/qt/res/icons/black/debugwindow.png differ diff --git a/src/qt/res/icons/black/edit.png b/src/qt/res/icons/black/edit.png new file mode 100644 index 0000000..4658271 Binary files /dev/null and b/src/qt/res/icons/black/edit.png differ diff --git a/src/qt/res/icons/black/editcopy.png b/src/qt/res/icons/black/editcopy.png new file mode 100644 index 0000000..74ac8b2 Binary files /dev/null and b/src/qt/res/icons/black/editcopy.png differ diff --git a/src/qt/res/icons/black/editpaste.png b/src/qt/res/icons/black/editpaste.png new file mode 100644 index 0000000..7b47f4d Binary files /dev/null and b/src/qt/res/icons/black/editpaste.png differ diff --git a/src/qt/res/icons/black/explorer.png b/src/qt/res/icons/black/explorer.png new file mode 100644 index 0000000..bacc267 Binary files /dev/null and b/src/qt/res/icons/black/explorer.png differ diff --git a/src/qt/res/icons/black/export.png b/src/qt/res/icons/black/export.png new file mode 100644 index 0000000..ac76cc1 Binary files /dev/null and b/src/qt/res/icons/black/export.png differ diff --git a/src/qt/res/icons/black/eye.png b/src/qt/res/icons/black/eye.png new file mode 100644 index 0000000..f2f139d Binary files /dev/null and b/src/qt/res/icons/black/eye.png differ diff --git a/src/qt/res/icons/black/eye_minus.png b/src/qt/res/icons/black/eye_minus.png new file mode 100644 index 0000000..795bf64 Binary files /dev/null and b/src/qt/res/icons/black/eye_minus.png differ diff --git a/src/qt/res/icons/black/eye_plus.png b/src/qt/res/icons/black/eye_plus.png new file mode 100644 index 0000000..eaab692 Binary files /dev/null and b/src/qt/res/icons/black/eye_plus.png differ diff --git a/src/qt/res/icons/black/filesave.png b/src/qt/res/icons/black/filesave.png new file mode 100644 index 0000000..779cca1 Binary files /dev/null and b/src/qt/res/icons/black/filesave.png differ diff --git a/src/qt/res/icons/black/fontbigger.png b/src/qt/res/icons/black/fontbigger.png new file mode 100644 index 0000000..5ca5c56 Binary files /dev/null and b/src/qt/res/icons/black/fontbigger.png differ diff --git a/src/qt/res/icons/black/fontsmaller.png b/src/qt/res/icons/black/fontsmaller.png new file mode 100644 index 0000000..1a6bb3a Binary files /dev/null and b/src/qt/res/icons/black/fontsmaller.png differ diff --git a/src/qt/res/icons/black/hd_disabled.png b/src/qt/res/icons/black/hd_disabled.png new file mode 100644 index 0000000..687b6d2 Binary files /dev/null and b/src/qt/res/icons/black/hd_disabled.png differ diff --git a/src/qt/res/icons/black/hd_enabled.png b/src/qt/res/icons/black/hd_enabled.png new file mode 100644 index 0000000..568dde1 Binary files /dev/null and b/src/qt/res/icons/black/hd_enabled.png differ diff --git a/src/qt/res/icons/black/history.png b/src/qt/res/icons/black/history.png new file mode 100644 index 0000000..68d841f Binary files /dev/null and b/src/qt/res/icons/black/history.png differ diff --git a/src/qt/res/icons/black/info.png b/src/qt/res/icons/black/info.png new file mode 100644 index 0000000..692b50c Binary files /dev/null and b/src/qt/res/icons/black/info.png differ diff --git a/src/qt/res/icons/black/key.png b/src/qt/res/icons/black/key.png new file mode 100644 index 0000000..f301c4f Binary files /dev/null and b/src/qt/res/icons/black/key.png differ diff --git a/src/qt/res/icons/black/lock_closed.png b/src/qt/res/icons/black/lock_closed.png new file mode 100644 index 0000000..1bd98b2 Binary files /dev/null and b/src/qt/res/icons/black/lock_closed.png differ diff --git a/src/qt/res/icons/black/lock_open.png b/src/qt/res/icons/black/lock_open.png new file mode 100644 index 0000000..a704513 Binary files /dev/null and b/src/qt/res/icons/black/lock_open.png differ diff --git a/src/qt/res/icons/black/messages.png b/src/qt/res/icons/black/messages.png new file mode 100644 index 0000000..a323c87 Binary files /dev/null and b/src/qt/res/icons/black/messages.png differ diff --git a/src/qt/res/icons/black/mining_active.png b/src/qt/res/icons/black/mining_active.png new file mode 100644 index 0000000..b48c7b9 Binary files /dev/null and b/src/qt/res/icons/black/mining_active.png differ diff --git a/src/qt/res/icons/black/mining_inactive.png b/src/qt/res/icons/black/mining_inactive.png new file mode 100644 index 0000000..8644761 Binary files /dev/null and b/src/qt/res/icons/black/mining_inactive.png differ diff --git a/src/qt/res/icons/black/network_disabled.png b/src/qt/res/icons/black/network_disabled.png new file mode 100644 index 0000000..269c3cf Binary files /dev/null and b/src/qt/res/icons/black/network_disabled.png differ diff --git a/src/qt/res/icons/black/notsynced.png b/src/qt/res/icons/black/notsynced.png new file mode 100644 index 0000000..7d134ae Binary files /dev/null and b/src/qt/res/icons/black/notsynced.png differ diff --git a/src/qt/res/icons/black/onion-black.png b/src/qt/res/icons/black/onion-black.png new file mode 100644 index 0000000..a6f18e4 Binary files /dev/null and b/src/qt/res/icons/black/onion-black.png differ diff --git a/src/qt/res/icons/black/onion.png b/src/qt/res/icons/black/onion.png new file mode 100644 index 0000000..7ade2da Binary files /dev/null and b/src/qt/res/icons/black/onion.png differ diff --git a/src/qt/res/icons/black/open.png b/src/qt/res/icons/black/open.png new file mode 100644 index 0000000..4d958f0 Binary files /dev/null and b/src/qt/res/icons/black/open.png differ diff --git a/src/qt/res/icons/black/overview.png b/src/qt/res/icons/black/overview.png new file mode 100644 index 0000000..4115954 Binary files /dev/null and b/src/qt/res/icons/black/overview.png differ diff --git a/src/qt/res/icons/black/qrcode.png b/src/qt/res/icons/black/qrcode.png new file mode 100644 index 0000000..bb3cb73 Binary files /dev/null and b/src/qt/res/icons/black/qrcode.png differ diff --git a/src/qt/res/icons/black/quit.png b/src/qt/res/icons/black/quit.png new file mode 100644 index 0000000..55e34de Binary files /dev/null and b/src/qt/res/icons/black/quit.png differ diff --git a/src/qt/res/icons/black/receive.png b/src/qt/res/icons/black/receive.png new file mode 100644 index 0000000..f4e6f58 Binary files /dev/null and b/src/qt/res/icons/black/receive.png differ diff --git a/src/qt/res/icons/black/remove.png b/src/qt/res/icons/black/remove.png new file mode 100644 index 0000000..8e738d6 Binary files /dev/null and b/src/qt/res/icons/black/remove.png differ diff --git a/src/qt/res/icons/black/send.png b/src/qt/res/icons/black/send.png new file mode 100644 index 0000000..ac76cc1 Binary files /dev/null and b/src/qt/res/icons/black/send.png differ diff --git a/src/qt/res/icons/black/staking_off.png b/src/qt/res/icons/black/staking_off.png new file mode 100644 index 0000000..40d7a7d Binary files /dev/null and b/src/qt/res/icons/black/staking_off.png differ diff --git a/src/qt/res/icons/black/staking_on.png b/src/qt/res/icons/black/staking_on.png new file mode 100644 index 0000000..0cf561a Binary files /dev/null and b/src/qt/res/icons/black/staking_on.png differ diff --git a/src/qt/res/icons/black/statistics.png b/src/qt/res/icons/black/statistics.png new file mode 100644 index 0000000..37f3fdb Binary files /dev/null and b/src/qt/res/icons/black/statistics.png differ diff --git a/src/qt/res/icons/black/synced.png b/src/qt/res/icons/black/synced.png new file mode 100644 index 0000000..5ac28d3 Binary files /dev/null and b/src/qt/res/icons/black/synced.png differ diff --git a/src/qt/res/icons/black/transaction0.png b/src/qt/res/icons/black/transaction0.png new file mode 100644 index 0000000..72c4456 Binary files /dev/null and b/src/qt/res/icons/black/transaction0.png differ diff --git a/src/qt/res/icons/black/transaction2.png b/src/qt/res/icons/black/transaction2.png new file mode 100644 index 0000000..5ac28d3 Binary files /dev/null and b/src/qt/res/icons/black/transaction2.png differ diff --git a/src/qt/res/icons/black/transaction_abandoned.png b/src/qt/res/icons/black/transaction_abandoned.png new file mode 100644 index 0000000..8ca6445 Binary files /dev/null and b/src/qt/res/icons/black/transaction_abandoned.png differ diff --git a/src/qt/res/icons/black/transaction_conflicted.png b/src/qt/res/icons/black/transaction_conflicted.png new file mode 100644 index 0000000..55e34de Binary files /dev/null and b/src/qt/res/icons/black/transaction_conflicted.png differ diff --git a/src/qt/res/icons/black/tx_inout.png b/src/qt/res/icons/black/tx_inout.png new file mode 100644 index 0000000..0a6e72a Binary files /dev/null and b/src/qt/res/icons/black/tx_inout.png differ diff --git a/src/qt/res/icons/black/tx_input.png b/src/qt/res/icons/black/tx_input.png new file mode 100644 index 0000000..9e9ee92 Binary files /dev/null and b/src/qt/res/icons/black/tx_input.png differ diff --git a/src/qt/res/icons/black/tx_mined.png b/src/qt/res/icons/black/tx_mined.png new file mode 100644 index 0000000..5a6ef52 Binary files /dev/null and b/src/qt/res/icons/black/tx_mined.png differ diff --git a/src/qt/res/icons/black/tx_output.png b/src/qt/res/icons/black/tx_output.png new file mode 100644 index 0000000..6f66ab6 Binary files /dev/null and b/src/qt/res/icons/black/tx_output.png differ diff --git a/src/qt/res/icons/black/verify.png b/src/qt/res/icons/black/verify.png new file mode 100644 index 0000000..8e2cb2c Binary files /dev/null and b/src/qt/res/icons/black/verify.png differ diff --git a/src/qt/res/icons/black/warning.png b/src/qt/res/icons/black/warning.png new file mode 100644 index 0000000..6bc5ac7 Binary files /dev/null and b/src/qt/res/icons/black/warning.png differ diff --git a/src/qt/res/icons/block.png b/src/qt/res/icons/block.png new file mode 100644 index 0000000..0c2ce92 Binary files /dev/null and b/src/qt/res/icons/block.png differ diff --git a/src/qt/res/icons/browse.png b/src/qt/res/icons/browse.png new file mode 100644 index 0000000..ae13a15 Binary files /dev/null and b/src/qt/res/icons/browse.png differ diff --git a/src/qt/res/icons/chevron.png b/src/qt/res/icons/chevron.png new file mode 100644 index 0000000..2309fb3 Binary files /dev/null and b/src/qt/res/icons/chevron.png differ diff --git a/src/qt/res/icons/clock1.png b/src/qt/res/icons/clock1.png new file mode 100644 index 0000000..162204d Binary files /dev/null and b/src/qt/res/icons/clock1.png differ diff --git a/src/qt/res/icons/clock2.png b/src/qt/res/icons/clock2.png new file mode 100644 index 0000000..8f4263a Binary files /dev/null and b/src/qt/res/icons/clock2.png differ diff --git a/src/qt/res/icons/clock3.png b/src/qt/res/icons/clock3.png new file mode 100644 index 0000000..7f11a75 Binary files /dev/null and b/src/qt/res/icons/clock3.png differ diff --git a/src/qt/res/icons/clock4.png b/src/qt/res/icons/clock4.png new file mode 100644 index 0000000..fdd1a0f Binary files /dev/null and b/src/qt/res/icons/clock4.png differ diff --git a/src/qt/res/icons/clock5.png b/src/qt/res/icons/clock5.png new file mode 100644 index 0000000..7d6556c Binary files /dev/null and b/src/qt/res/icons/clock5.png differ diff --git a/src/qt/res/icons/configure.png b/src/qt/res/icons/configure.png new file mode 100644 index 0000000..5333c83 Binary files /dev/null and b/src/qt/res/icons/configure.png differ diff --git a/src/qt/res/icons/connect.png b/src/qt/res/icons/connect.png new file mode 100644 index 0000000..aa05d91 Binary files /dev/null and b/src/qt/res/icons/connect.png differ diff --git a/src/qt/res/icons/connect0.png b/src/qt/res/icons/connect0.png new file mode 100644 index 0000000..ef708d8 Binary files /dev/null and b/src/qt/res/icons/connect0.png differ diff --git a/src/qt/res/icons/connect0_16.png b/src/qt/res/icons/connect0_16.png new file mode 100644 index 0000000..ed541aa Binary files /dev/null and b/src/qt/res/icons/connect0_16.png differ diff --git a/src/qt/res/icons/connect1.png b/src/qt/res/icons/connect1.png new file mode 100644 index 0000000..ed358e6 Binary files /dev/null and b/src/qt/res/icons/connect1.png differ diff --git a/src/qt/res/icons/connect1_16.png b/src/qt/res/icons/connect1_16.png new file mode 100644 index 0000000..ed358e6 Binary files /dev/null and b/src/qt/res/icons/connect1_16.png differ diff --git a/src/qt/res/icons/connect2.png b/src/qt/res/icons/connect2.png new file mode 100644 index 0000000..3bbb0d3 Binary files /dev/null and b/src/qt/res/icons/connect2.png differ diff --git a/src/qt/res/icons/connect2_16.png b/src/qt/res/icons/connect2_16.png new file mode 100644 index 0000000..3bbb0d3 Binary files /dev/null and b/src/qt/res/icons/connect2_16.png differ diff --git a/src/qt/res/icons/connect3.png b/src/qt/res/icons/connect3.png new file mode 100644 index 0000000..0db99ad Binary files /dev/null and b/src/qt/res/icons/connect3.png differ diff --git a/src/qt/res/icons/connect3_16.png b/src/qt/res/icons/connect3_16.png new file mode 100644 index 0000000..0db99ad Binary files /dev/null and b/src/qt/res/icons/connect3_16.png differ diff --git a/src/qt/res/icons/connect4.png b/src/qt/res/icons/connect4.png new file mode 100644 index 0000000..9dd19fc Binary files /dev/null and b/src/qt/res/icons/connect4.png differ diff --git a/src/qt/res/icons/connect4_16.png b/src/qt/res/icons/connect4_16.png new file mode 100644 index 0000000..9dd19fc Binary files /dev/null and b/src/qt/res/icons/connect4_16.png differ diff --git a/src/qt/res/icons/debugwindow.png b/src/qt/res/icons/debugwindow.png new file mode 100644 index 0000000..290fe60 Binary files /dev/null and b/src/qt/res/icons/debugwindow.png differ diff --git a/src/qt/res/icons/edit.png b/src/qt/res/icons/edit.png new file mode 100644 index 0000000..4658271 Binary files /dev/null and b/src/qt/res/icons/edit.png differ diff --git a/src/qt/res/icons/editcopy.png b/src/qt/res/icons/editcopy.png new file mode 100644 index 0000000..74ac8b2 Binary files /dev/null and b/src/qt/res/icons/editcopy.png differ diff --git a/src/qt/res/icons/editpaste.png b/src/qt/res/icons/editpaste.png new file mode 100644 index 0000000..7b47f4d Binary files /dev/null and b/src/qt/res/icons/editpaste.png differ diff --git a/src/qt/res/icons/explorer.png b/src/qt/res/icons/explorer.png new file mode 100644 index 0000000..bacc267 Binary files /dev/null and b/src/qt/res/icons/explorer.png differ diff --git a/src/qt/res/icons/export.png b/src/qt/res/icons/export.png new file mode 100644 index 0000000..ac76cc1 Binary files /dev/null and b/src/qt/res/icons/export.png differ diff --git a/src/qt/res/icons/eye.png b/src/qt/res/icons/eye.png new file mode 100644 index 0000000..f2f139d Binary files /dev/null and b/src/qt/res/icons/eye.png differ diff --git a/src/qt/res/icons/eye_minus.png b/src/qt/res/icons/eye_minus.png new file mode 100644 index 0000000..795bf64 Binary files /dev/null and b/src/qt/res/icons/eye_minus.png differ diff --git a/src/qt/res/icons/eye_plus.png b/src/qt/res/icons/eye_plus.png new file mode 100644 index 0000000..eaab692 Binary files /dev/null and b/src/qt/res/icons/eye_plus.png differ diff --git a/src/qt/res/icons/filesave.png b/src/qt/res/icons/filesave.png new file mode 100644 index 0000000..779cca1 Binary files /dev/null and b/src/qt/res/icons/filesave.png differ diff --git a/src/qt/res/icons/fontbigger.png b/src/qt/res/icons/fontbigger.png new file mode 100644 index 0000000..5ca5c56 Binary files /dev/null and b/src/qt/res/icons/fontbigger.png differ diff --git a/src/qt/res/icons/fontsmaller.png b/src/qt/res/icons/fontsmaller.png new file mode 100644 index 0000000..1a6bb3a Binary files /dev/null and b/src/qt/res/icons/fontsmaller.png differ diff --git a/src/qt/res/icons/hd_disabled.png b/src/qt/res/icons/hd_disabled.png new file mode 100644 index 0000000..687b6d2 Binary files /dev/null and b/src/qt/res/icons/hd_disabled.png differ diff --git a/src/qt/res/icons/hd_enabled.png b/src/qt/res/icons/hd_enabled.png new file mode 100644 index 0000000..568dde1 Binary files /dev/null and b/src/qt/res/icons/hd_enabled.png differ diff --git a/src/qt/res/icons/history.png b/src/qt/res/icons/history.png new file mode 100644 index 0000000..68d841f Binary files /dev/null and b/src/qt/res/icons/history.png differ diff --git a/src/qt/res/icons/info.png b/src/qt/res/icons/info.png new file mode 100644 index 0000000..692b50c Binary files /dev/null and b/src/qt/res/icons/info.png differ diff --git a/src/qt/res/icons/key.png b/src/qt/res/icons/key.png new file mode 100644 index 0000000..f301c4f Binary files /dev/null and b/src/qt/res/icons/key.png differ diff --git a/src/qt/res/icons/lock_closed.png b/src/qt/res/icons/lock_closed.png new file mode 100644 index 0000000..1bd98b2 Binary files /dev/null and b/src/qt/res/icons/lock_closed.png differ diff --git a/src/qt/res/icons/lock_open.png b/src/qt/res/icons/lock_open.png new file mode 100644 index 0000000..a704513 Binary files /dev/null and b/src/qt/res/icons/lock_open.png differ diff --git a/src/qt/res/icons/messages.png b/src/qt/res/icons/messages.png new file mode 100644 index 0000000..a323c87 Binary files /dev/null and b/src/qt/res/icons/messages.png differ diff --git a/src/qt/res/icons/mining_active.png b/src/qt/res/icons/mining_active.png new file mode 100644 index 0000000..b48c7b9 Binary files /dev/null and b/src/qt/res/icons/mining_active.png differ diff --git a/src/qt/res/icons/mining_inactive.png b/src/qt/res/icons/mining_inactive.png new file mode 100644 index 0000000..8644761 Binary files /dev/null and b/src/qt/res/icons/mining_inactive.png differ diff --git a/src/qt/res/icons/network_disabled.png b/src/qt/res/icons/network_disabled.png new file mode 100644 index 0000000..269c3cf Binary files /dev/null and b/src/qt/res/icons/network_disabled.png differ diff --git a/src/qt/res/icons/notsynced.png b/src/qt/res/icons/notsynced.png new file mode 100644 index 0000000..7d134ae Binary files /dev/null and b/src/qt/res/icons/notsynced.png differ diff --git a/src/qt/res/icons/onion-black.png b/src/qt/res/icons/onion-black.png new file mode 100644 index 0000000..e3ec917 Binary files /dev/null and b/src/qt/res/icons/onion-black.png differ diff --git a/src/qt/res/icons/onion.png b/src/qt/res/icons/onion.png new file mode 100644 index 0000000..7ade2da Binary files /dev/null and b/src/qt/res/icons/onion.png differ diff --git a/src/qt/res/icons/open.png b/src/qt/res/icons/open.png new file mode 100644 index 0000000..4d958f0 Binary files /dev/null and b/src/qt/res/icons/open.png differ diff --git a/src/qt/res/icons/overview.png b/src/qt/res/icons/overview.png new file mode 100644 index 0000000..4115954 Binary files /dev/null and b/src/qt/res/icons/overview.png differ diff --git a/src/qt/res/icons/qrcode.png b/src/qt/res/icons/qrcode.png new file mode 100644 index 0000000..bb3cb73 Binary files /dev/null and b/src/qt/res/icons/qrcode.png differ diff --git a/src/qt/res/icons/quit.png b/src/qt/res/icons/quit.png new file mode 100644 index 0000000..55e34de Binary files /dev/null and b/src/qt/res/icons/quit.png differ diff --git a/src/qt/res/icons/receive.png b/src/qt/res/icons/receive.png new file mode 100644 index 0000000..f4e6f58 Binary files /dev/null and b/src/qt/res/icons/receive.png differ diff --git a/src/qt/res/icons/remove.png b/src/qt/res/icons/remove.png new file mode 100644 index 0000000..8e738d6 Binary files /dev/null and b/src/qt/res/icons/remove.png differ diff --git a/src/qt/res/icons/send.png b/src/qt/res/icons/send.png new file mode 100644 index 0000000..ac76cc1 Binary files /dev/null and b/src/qt/res/icons/send.png differ diff --git a/src/qt/res/icons/staking_off.png b/src/qt/res/icons/staking_off.png new file mode 100644 index 0000000..40d7a7d Binary files /dev/null and b/src/qt/res/icons/staking_off.png differ diff --git a/src/qt/res/icons/staking_on.png b/src/qt/res/icons/staking_on.png new file mode 100644 index 0000000..0cf561a Binary files /dev/null and b/src/qt/res/icons/staking_on.png differ diff --git a/src/qt/res/icons/statistics.png b/src/qt/res/icons/statistics.png new file mode 100644 index 0000000..37f3fdb Binary files /dev/null and b/src/qt/res/icons/statistics.png differ diff --git a/src/qt/res/icons/synced.png b/src/qt/res/icons/synced.png new file mode 100644 index 0000000..5ac28d3 Binary files /dev/null and b/src/qt/res/icons/synced.png differ diff --git a/src/qt/res/icons/transaction0.png b/src/qt/res/icons/transaction0.png new file mode 100644 index 0000000..72c4456 Binary files /dev/null and b/src/qt/res/icons/transaction0.png differ diff --git a/src/qt/res/icons/transaction2.png b/src/qt/res/icons/transaction2.png new file mode 100644 index 0000000..5ac28d3 Binary files /dev/null and b/src/qt/res/icons/transaction2.png differ diff --git a/src/qt/res/icons/transaction_abandoned.png b/src/qt/res/icons/transaction_abandoned.png new file mode 100644 index 0000000..8ca6445 Binary files /dev/null and b/src/qt/res/icons/transaction_abandoned.png differ diff --git a/src/qt/res/icons/transaction_conflicted.png b/src/qt/res/icons/transaction_conflicted.png new file mode 100644 index 0000000..55e34de Binary files /dev/null and b/src/qt/res/icons/transaction_conflicted.png differ diff --git a/src/qt/res/icons/tx_inout.png b/src/qt/res/icons/tx_inout.png new file mode 100644 index 0000000..0a6e72a Binary files /dev/null and b/src/qt/res/icons/tx_inout.png differ diff --git a/src/qt/res/icons/tx_input.png b/src/qt/res/icons/tx_input.png new file mode 100644 index 0000000..9e9ee92 Binary files /dev/null and b/src/qt/res/icons/tx_input.png differ diff --git a/src/qt/res/icons/tx_mined.png b/src/qt/res/icons/tx_mined.png new file mode 100644 index 0000000..5a6ef52 Binary files /dev/null and b/src/qt/res/icons/tx_mined.png differ diff --git a/src/qt/res/icons/tx_output.png b/src/qt/res/icons/tx_output.png new file mode 100644 index 0000000..6f66ab6 Binary files /dev/null and b/src/qt/res/icons/tx_output.png differ diff --git a/src/qt/res/icons/update.png b/src/qt/res/icons/update.png new file mode 100644 index 0000000..934f36f Binary files /dev/null and b/src/qt/res/icons/update.png differ diff --git a/src/qt/res/icons/verify.png b/src/qt/res/icons/verify.png new file mode 100644 index 0000000..8e2cb2c Binary files /dev/null and b/src/qt/res/icons/verify.png differ diff --git a/src/qt/res/icons/warning.png b/src/qt/res/icons/warning.png new file mode 100644 index 0000000..6bc5ac7 Binary files /dev/null and b/src/qt/res/icons/warning.png differ diff --git a/src/qt/res/icons/worker.png b/src/qt/res/icons/worker.png new file mode 100644 index 0000000..3d243e8 Binary files /dev/null and b/src/qt/res/icons/worker.png differ diff --git a/src/qt/res/images/about.png b/src/qt/res/images/about.png new file mode 100644 index 0000000..ba0a3ed Binary files /dev/null and b/src/qt/res/images/about.png differ diff --git a/src/qt/res/images/header.png b/src/qt/res/images/header.png new file mode 100644 index 0000000..0588464 Binary files /dev/null and b/src/qt/res/images/header.png differ diff --git a/src/qt/res/images/logo.png b/src/qt/res/images/logo.png new file mode 100644 index 0000000..b56110e Binary files /dev/null and b/src/qt/res/images/logo.png differ diff --git a/src/qt/res/images/qt.png b/src/qt/res/images/qt.png new file mode 100644 index 0000000..67385d0 Binary files /dev/null and b/src/qt/res/images/qt.png differ diff --git a/src/qt/res/images/splash.png b/src/qt/res/images/splash.png new file mode 100644 index 0000000..c1b864f Binary files /dev/null and b/src/qt/res/images/splash.png differ diff --git a/src/qt/res/images/splash2.jpg b/src/qt/res/images/splash2.jpg new file mode 100644 index 0000000..4ea92f0 Binary files /dev/null and b/src/qt/res/images/splash2.jpg differ diff --git a/src/qt/res/images/splash3.png b/src/qt/res/images/splash3.png new file mode 100644 index 0000000..27648d5 Binary files /dev/null and b/src/qt/res/images/splash3.png differ diff --git a/src/qt/res/movies/makespinner.sh b/src/qt/res/movies/makespinner.sh new file mode 100644 index 0000000..adf5276 --- /dev/null +++ b/src/qt/res/movies/makespinner.sh @@ -0,0 +1,11 @@ +# Copyright (c) 2014-2015 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +FRAMEDIR=$(dirname $0) +for i in {0..35} +do + frame=$(printf "%03d" $i) + angle=$(($i * 10)) + convert $FRAMEDIR/../src/spinner.png -background "rgba(0,0,0,0.0)" -distort SRT $angle $FRAMEDIR/spinner-$frame.png +done diff --git a/src/qt/res/movies/spinner-000.png b/src/qt/res/movies/spinner-000.png new file mode 100644 index 0000000..0dc48d0 Binary files /dev/null and b/src/qt/res/movies/spinner-000.png differ diff --git a/src/qt/res/movies/spinner-001.png b/src/qt/res/movies/spinner-001.png new file mode 100644 index 0000000..d167f20 Binary files /dev/null and b/src/qt/res/movies/spinner-001.png differ diff --git a/src/qt/res/movies/spinner-002.png b/src/qt/res/movies/spinner-002.png new file mode 100644 index 0000000..4a1f1f8 Binary files /dev/null and b/src/qt/res/movies/spinner-002.png differ diff --git a/src/qt/res/movies/spinner-003.png b/src/qt/res/movies/spinner-003.png new file mode 100644 index 0000000..fb1c2cd Binary files /dev/null and b/src/qt/res/movies/spinner-003.png differ diff --git a/src/qt/res/movies/spinner-004.png b/src/qt/res/movies/spinner-004.png new file mode 100644 index 0000000..4df2132 Binary files /dev/null and b/src/qt/res/movies/spinner-004.png differ diff --git a/src/qt/res/movies/spinner-005.png b/src/qt/res/movies/spinner-005.png new file mode 100644 index 0000000..5d6f41e Binary files /dev/null and b/src/qt/res/movies/spinner-005.png differ diff --git a/src/qt/res/movies/spinner-006.png b/src/qt/res/movies/spinner-006.png new file mode 100644 index 0000000..c1f7d18 Binary files /dev/null and b/src/qt/res/movies/spinner-006.png differ diff --git a/src/qt/res/movies/spinner-007.png b/src/qt/res/movies/spinner-007.png new file mode 100644 index 0000000..1e794b2 Binary files /dev/null and b/src/qt/res/movies/spinner-007.png differ diff --git a/src/qt/res/movies/spinner-008.png b/src/qt/res/movies/spinner-008.png new file mode 100644 index 0000000..df12ea8 Binary files /dev/null and b/src/qt/res/movies/spinner-008.png differ diff --git a/src/qt/res/movies/spinner-009.png b/src/qt/res/movies/spinner-009.png new file mode 100644 index 0000000..18fc3a7 Binary files /dev/null and b/src/qt/res/movies/spinner-009.png differ diff --git a/src/qt/res/movies/spinner-010.png b/src/qt/res/movies/spinner-010.png new file mode 100644 index 0000000..a79c845 Binary files /dev/null and b/src/qt/res/movies/spinner-010.png differ diff --git a/src/qt/res/movies/spinner-011.png b/src/qt/res/movies/spinner-011.png new file mode 100644 index 0000000..57baf66 Binary files /dev/null and b/src/qt/res/movies/spinner-011.png differ diff --git a/src/qt/res/movies/spinner-012.png b/src/qt/res/movies/spinner-012.png new file mode 100644 index 0000000..9deae78 Binary files /dev/null and b/src/qt/res/movies/spinner-012.png differ diff --git a/src/qt/res/movies/spinner-013.png b/src/qt/res/movies/spinner-013.png new file mode 100644 index 0000000..0659d48 Binary files /dev/null and b/src/qt/res/movies/spinner-013.png differ diff --git a/src/qt/res/movies/spinner-014.png b/src/qt/res/movies/spinner-014.png new file mode 100644 index 0000000..bc1ef51 Binary files /dev/null and b/src/qt/res/movies/spinner-014.png differ diff --git a/src/qt/res/movies/spinner-015.png b/src/qt/res/movies/spinner-015.png new file mode 100644 index 0000000..24b57b6 Binary files /dev/null and b/src/qt/res/movies/spinner-015.png differ diff --git a/src/qt/res/movies/spinner-016.png b/src/qt/res/movies/spinner-016.png new file mode 100644 index 0000000..d622872 Binary files /dev/null and b/src/qt/res/movies/spinner-016.png differ diff --git a/src/qt/res/movies/spinner-017.png b/src/qt/res/movies/spinner-017.png new file mode 100644 index 0000000..f48f688 Binary files /dev/null and b/src/qt/res/movies/spinner-017.png differ diff --git a/src/qt/res/movies/spinner-018.png b/src/qt/res/movies/spinner-018.png new file mode 100644 index 0000000..a2c8f38 Binary files /dev/null and b/src/qt/res/movies/spinner-018.png differ diff --git a/src/qt/res/movies/spinner-019.png b/src/qt/res/movies/spinner-019.png new file mode 100644 index 0000000..9d7cc35 Binary files /dev/null and b/src/qt/res/movies/spinner-019.png differ diff --git a/src/qt/res/movies/spinner-020.png b/src/qt/res/movies/spinner-020.png new file mode 100644 index 0000000..1a07acc Binary files /dev/null and b/src/qt/res/movies/spinner-020.png differ diff --git a/src/qt/res/movies/spinner-021.png b/src/qt/res/movies/spinner-021.png new file mode 100644 index 0000000..9cea8f2 Binary files /dev/null and b/src/qt/res/movies/spinner-021.png differ diff --git a/src/qt/res/movies/spinner-022.png b/src/qt/res/movies/spinner-022.png new file mode 100644 index 0000000..60250f6 Binary files /dev/null and b/src/qt/res/movies/spinner-022.png differ diff --git a/src/qt/res/movies/spinner-023.png b/src/qt/res/movies/spinner-023.png new file mode 100644 index 0000000..fc290a0 Binary files /dev/null and b/src/qt/res/movies/spinner-023.png differ diff --git a/src/qt/res/movies/spinner-024.png b/src/qt/res/movies/spinner-024.png new file mode 100644 index 0000000..c5dcf1e Binary files /dev/null and b/src/qt/res/movies/spinner-024.png differ diff --git a/src/qt/res/movies/spinner-025.png b/src/qt/res/movies/spinner-025.png new file mode 100644 index 0000000..7f3577a Binary files /dev/null and b/src/qt/res/movies/spinner-025.png differ diff --git a/src/qt/res/movies/spinner-026.png b/src/qt/res/movies/spinner-026.png new file mode 100644 index 0000000..1663ddf Binary files /dev/null and b/src/qt/res/movies/spinner-026.png differ diff --git a/src/qt/res/movies/spinner-027.png b/src/qt/res/movies/spinner-027.png new file mode 100644 index 0000000..d0e6da4 Binary files /dev/null and b/src/qt/res/movies/spinner-027.png differ diff --git a/src/qt/res/movies/spinner-028.png b/src/qt/res/movies/spinner-028.png new file mode 100644 index 0000000..2a7aba5 Binary files /dev/null and b/src/qt/res/movies/spinner-028.png differ diff --git a/src/qt/res/movies/spinner-029.png b/src/qt/res/movies/spinner-029.png new file mode 100644 index 0000000..c8ca15c Binary files /dev/null and b/src/qt/res/movies/spinner-029.png differ diff --git a/src/qt/res/movies/spinner-030.png b/src/qt/res/movies/spinner-030.png new file mode 100644 index 0000000..c847c99 Binary files /dev/null and b/src/qt/res/movies/spinner-030.png differ diff --git a/src/qt/res/movies/spinner-031.png b/src/qt/res/movies/spinner-031.png new file mode 100644 index 0000000..4034431 Binary files /dev/null and b/src/qt/res/movies/spinner-031.png differ diff --git a/src/qt/res/movies/spinner-032.png b/src/qt/res/movies/spinner-032.png new file mode 100644 index 0000000..f9db080 Binary files /dev/null and b/src/qt/res/movies/spinner-032.png differ diff --git a/src/qt/res/movies/spinner-033.png b/src/qt/res/movies/spinner-033.png new file mode 100644 index 0000000..43f5771 Binary files /dev/null and b/src/qt/res/movies/spinner-033.png differ diff --git a/src/qt/res/movies/spinner-034.png b/src/qt/res/movies/spinner-034.png new file mode 100644 index 0000000..c26656f Binary files /dev/null and b/src/qt/res/movies/spinner-034.png differ diff --git a/src/qt/res/movies/spinner-035.png b/src/qt/res/movies/spinner-035.png new file mode 100644 index 0000000..e471f95 Binary files /dev/null and b/src/qt/res/movies/spinner-035.png differ diff --git a/src/qt/res/movies/update_spinner.mng b/src/qt/res/movies/update_spinner.mng new file mode 100644 index 0000000..7df3baa Binary files /dev/null and b/src/qt/res/movies/update_spinner.mng differ diff --git a/src/qt/res/movies/update_spinner_black.mng b/src/qt/res/movies/update_spinner_black.mng new file mode 100644 index 0000000..28ca141 Binary files /dev/null and b/src/qt/res/movies/update_spinner_black.mng differ diff --git a/src/qt/res/src/bitcoin.svg b/src/qt/res/src/bitcoin.svg new file mode 100644 index 0000000..d31e3cf --- /dev/null +++ b/src/qt/res/src/bitcoin.svg @@ -0,0 +1,115 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/qt/res/src/clock1.svg b/src/qt/res/src/clock1.svg new file mode 100644 index 0000000..e1a4228 --- /dev/null +++ b/src/qt/res/src/clock1.svg @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/qt/res/src/clock2.svg b/src/qt/res/src/clock2.svg new file mode 100644 index 0000000..a7f4f26 --- /dev/null +++ b/src/qt/res/src/clock2.svg @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/qt/res/src/clock3.svg b/src/qt/res/src/clock3.svg new file mode 100644 index 0000000..911a626 --- /dev/null +++ b/src/qt/res/src/clock3.svg @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/qt/res/src/clock4.svg b/src/qt/res/src/clock4.svg new file mode 100644 index 0000000..b17989a --- /dev/null +++ b/src/qt/res/src/clock4.svg @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/qt/res/src/clock5.svg b/src/qt/res/src/clock5.svg new file mode 100644 index 0000000..144bf06 --- /dev/null +++ b/src/qt/res/src/clock5.svg @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/qt/res/src/clock_green.svg b/src/qt/res/src/clock_green.svg new file mode 100644 index 0000000..6c4721b --- /dev/null +++ b/src/qt/res/src/clock_green.svg @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/qt/res/src/inout.svg b/src/qt/res/src/inout.svg new file mode 100644 index 0000000..3f1aab7 --- /dev/null +++ b/src/qt/res/src/inout.svg @@ -0,0 +1,122 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/src/qt/res/src/questionmark.svg b/src/qt/res/src/questionmark.svg new file mode 100644 index 0000000..d3f128e --- /dev/null +++ b/src/qt/res/src/questionmark.svg @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + ? + ? + + + ? + + diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp new file mode 100644 index 0000000..af0a66b --- /dev/null +++ b/src/qt/rpcconsole.cpp @@ -0,0 +1,421 @@ +#include "rpcconsole.h" +#include "ui_rpcconsole.h" + +#include "clientmodel.h" +#include "guiutil.h" + +#include "rpcserver.h" +#include "rpcclient.h" + +#include "rpcexecutor.h" + +#include +#include +#include +#include +#include + +#include + +// TODO: add a scrollback limit, as there is currently none +// TODO: make it possible to filter out categories (esp debug messages when implemented) +// TODO: receive errors and debug messages through ClientModel + +const int CONSOLE_HISTORY = 50; +const QSize ICON_SIZE(24, 24); + +const int INITIAL_TRAFFIC_GRAPH_MINS = 30; + +const struct { + const char *url; + const char *source; +} ICON_MAPPING[] = { + {"cmd-request", ":/icons/tx_input"}, + {"cmd-reply", ":/icons/tx_output"}, + {"cmd-error", ":/icons/tx_output"}, + {"misc", ":/icons/tx_inout"}, + {NULL, NULL} +}; + +/** + * Split shell command line into a list of arguments. Aims to emulate \c bash and friends. + * + * - Arguments are delimited with whitespace + * - Extra whitespace at the beginning and end and between arguments will be ignored + * - Text can be "double" or 'single' quoted + * - The backslash \c \ is used as escape character + * - Outside quotes, any character can be escaped + * - Within double quotes, only escape \c " and backslashes before a \c " or another backslash + * - Within single quotes, no escaping is possible and no special interpretation takes place + * + * @param[out] args Parsed arguments will be appended to this list + * @param[in] strCommand Command line to split + */ +bool parseCommandLine(std::vector &args, const std::string &strCommand) +{ + enum CmdParseState + { + STATE_EATING_SPACES, + STATE_ARGUMENT, + STATE_SINGLEQUOTED, + STATE_DOUBLEQUOTED, + STATE_ESCAPE_OUTER, + STATE_ESCAPE_DOUBLEQUOTED + } state = STATE_EATING_SPACES; + std::string curarg; + foreach(char ch, strCommand) + { + switch(state) + { + case STATE_ARGUMENT: // In or after argument + case STATE_EATING_SPACES: // Handle runs of whitespace + switch(ch) + { + case '"': state = STATE_DOUBLEQUOTED; break; + case '\'': state = STATE_SINGLEQUOTED; break; + case '\\': state = STATE_ESCAPE_OUTER; break; + case ' ': case '\n': case '\t': + if(state == STATE_ARGUMENT) // Space ends argument + { + args.push_back(curarg); + curarg.clear(); + } + state = STATE_EATING_SPACES; + break; + default: curarg += ch; state = STATE_ARGUMENT; + } + break; + case STATE_SINGLEQUOTED: // Single-quoted string + switch(ch) + { + case '\'': state = STATE_ARGUMENT; break; + default: curarg += ch; + } + break; + case STATE_DOUBLEQUOTED: // Double-quoted string + switch(ch) + { + case '"': state = STATE_ARGUMENT; break; + case '\\': state = STATE_ESCAPE_DOUBLEQUOTED; break; + default: curarg += ch; + } + break; + case STATE_ESCAPE_OUTER: // '\' outside quotes + curarg += ch; state = STATE_ARGUMENT; + break; + case STATE_ESCAPE_DOUBLEQUOTED: // '\' in double-quoted text + if(ch != '"' && ch != '\\') curarg += '\\'; // keep '\' for everything but the quote and '\' itself + curarg += ch; state = STATE_DOUBLEQUOTED; + break; + } + } + switch(state) // final state + { + case STATE_EATING_SPACES: + return true; + case STATE_ARGUMENT: + args.push_back(curarg); + return true; + default: // ERROR to end in one of the other states + return false; + } +} + +RPCConsole::RPCConsole(QWidget *parent) : + QDialog(parent), + ui(new Ui::RPCConsole), + historyPtr(0) +{ + ui->setupUi(this); + +#ifndef Q_OS_MAC + ui->openDebugLogfileButton->setIcon(QIcon(":/icons/export")); + ui->showCLOptionsButton->setIcon(QIcon(":/icons/options")); +#endif + + // Install event filter for up and down arrow + ui->lineEdit->installEventFilter(this); + ui->messagesWidget->installEventFilter(this); + + connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); + + // set OpenSSL version label + ui->openSSLVersion->setText(SSLeay_version(SSLEAY_VERSION)); + + startExecutor(); + setTrafficGraphRange(INITIAL_TRAFFIC_GRAPH_MINS); + + clear(); +} + +RPCConsole::~RPCConsole() +{ + emit stopExecutor(); + delete ui; +} + +bool RPCConsole::eventFilter(QObject* obj, QEvent *event) +{ + if(event->type() == QEvent::KeyPress) // Special key handling + { + QKeyEvent *keyevt = static_cast(event); + int key = keyevt->key(); + Qt::KeyboardModifiers mod = keyevt->modifiers(); + switch(key) + { + case Qt::Key_Up: if(obj == ui->lineEdit) { browseHistory(-1); return true; } break; + case Qt::Key_Down: if(obj == ui->lineEdit) { browseHistory(1); return true; } break; + case Qt::Key_PageUp: /* pass paging keys to messages widget */ + case Qt::Key_PageDown: + if(obj == ui->lineEdit) + { + QApplication::postEvent(ui->messagesWidget, new QKeyEvent(*keyevt)); + return true; + } + break; + default: + // Typing in messages widget brings focus to line edit, and redirects key there + // Exclude most combinations and keys that emit no text, except paste shortcuts + if(obj == ui->messagesWidget && ( + (!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) || + ((mod & Qt::ControlModifier) && key == Qt::Key_V) || + ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert))) + { + ui->lineEdit->setFocus(); + QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt)); + return true; + } + } + } + return QDialog::eventFilter(obj, event); +} + +void RPCConsole::setClientModel(ClientModel *model) +{ + clientModel = model; + ui->trafficGraph->setClientModel(model); + if(model) + { + // Subscribe to information, replies, messages, errors + connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); + + setNumBlocks(model->getNumBlocks()); + connect(model, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int))); + + updateTrafficStats(model->getTotalBytesRecv(), model->getTotalBytesSent()); + connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64))); + + // Provide initial values + ui->clientVersion->setText(model->formatFullVersion()); + ui->clientName->setText(model->clientName()); + ui->buildDate->setText(model->formatBuildDate()); + ui->startupTime->setText(model->formatClientStartupTime()); + + setNumConnections(model->getNumConnections()); + ui->isTestNet->setChecked(model->isTestNet()); + } +} + +static QString categoryClass(int category) +{ + switch(category) + { + case RPCConsole::CMD_REQUEST: return "cmd-request"; break; + case RPCConsole::CMD_REPLY: return "cmd-reply"; break; + case RPCConsole::CMD_ERROR: return "cmd-error"; break; + default: return "misc"; + } +} + +void RPCConsole::clear() +{ + ui->messagesWidget->clear(); + history.clear(); + historyPtr = 0; + ui->lineEdit->clear(); + ui->lineEdit->setFocus(); + + // Add smoothly scaled icon images. + // (when using width/height on an img, Qt uses nearest instead of linear interpolation) + for(int i=0; ICON_MAPPING[i].url; ++i) + { + ui->messagesWidget->document()->addResource( + QTextDocument::ImageResource, + QUrl(ICON_MAPPING[i].url), + QImage(ICON_MAPPING[i].source).scaled(ICON_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + } + + // Set default style sheet + ui->messagesWidget->document()->setDefaultStyleSheet( + "table { }" + "td.time { color: #808080; padding-top: 3px; } " + "td.message { font-family: Monospace; font-size: 12px; } " + "td.cmd-request { color: #00C0C0; } " + "td.cmd-error { color: red; } " + "b { color: #00C0C0; } " + ); + + message(CMD_REPLY, (tr("Welcome to the SONO RPC console.") + "
" + + tr("Use up and down arrows to navigate history, and Ctrl-L to clear screen.") + "
" + + tr("Type help for an overview of available commands.")), true); +} + +void RPCConsole::message(int category, const QString &message, bool html) +{ + QTime time = QTime::currentTime(); + QString timeString = time.toString(); + QString out; + out += ""; + out += ""; + out += "
" + timeString + ""; + if(html) + out += message; + else + out += GUIUtil::HtmlEscape(message, true); + out += "
"; + ui->messagesWidget->append(out); +} + +void RPCConsole::setNumConnections(int count) +{ + ui->numberOfConnections->setText(QString::number(count)); +} + +void RPCConsole::setNumBlocks(int count) +{ + ui->numberOfBlocks->setText(QString::number(count)); + if(clientModel) + ui->lastBlockTime->setText(clientModel->getLastBlockDate().toString()); +} + +void RPCConsole::on_lineEdit_returnPressed() +{ + QString cmd = ui->lineEdit->text(); + ui->lineEdit->clear(); + + if(!cmd.isEmpty()) + { + message(CMD_REQUEST, cmd); + emit cmdRequest(cmd); + // Remove command, if already in history + history.removeOne(cmd); + // Append command to history + history.append(cmd); + // Enforce maximum history size + while(history.size() > CONSOLE_HISTORY) + history.removeFirst(); + // Set pointer to end of history + historyPtr = history.size(); + // Scroll console view to end + scrollToEnd(); + } +} + +void RPCConsole::browseHistory(int offset) +{ + historyPtr += offset; + if(historyPtr < 0) + historyPtr = 0; + if(historyPtr > history.size()) + historyPtr = history.size(); + QString cmd; + if(historyPtr < history.size()) + cmd = history.at(historyPtr); + ui->lineEdit->setText(cmd); +} + +void RPCConsole::startExecutor() +{ + QThread* thread = new QThread; + RPCExecutor *executor = new RPCExecutor(); + executor->moveToThread(thread); + + // Notify executor when thread started (in executor thread) + connect(thread, SIGNAL(started()), executor, SLOT(start())); + // Replies from executor object must go to this object + connect(executor, SIGNAL(reply(int,QString)), this, SLOT(message(int,QString))); + // Requests from this object must go to executor + connect(this, SIGNAL(cmdRequest(QString)), executor, SLOT(request(QString))); + // On stopExecutor signal + // - queue executor for deletion (in execution thread) + // - quit the Qt event loop in the execution thread + connect(this, SIGNAL(stopExecutor()), executor, SLOT(deleteLater())); + connect(this, SIGNAL(stopExecutor()), thread, SLOT(quit())); + // Queue the thread for deletion (in this thread) when it is finished + connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); + + // Default implementation of QThread::run() simply spins up an event loop in the thread, + // which is what we want. + thread->start(); +} + +void RPCConsole::on_tabWidget_currentChanged(int index) +{ + if(ui->tabWidget->widget(index) == ui->tab_console) + { + ui->lineEdit->setFocus(); + } +} + +void RPCConsole::on_openDebugLogfileButton_clicked() +{ + GUIUtil::openDebugLogfile(); +} + +void RPCConsole::scrollToEnd() +{ + QScrollBar *scrollbar = ui->messagesWidget->verticalScrollBar(); + scrollbar->setValue(scrollbar->maximum()); +} + +void RPCConsole::on_showCLOptionsButton_clicked() +{ + GUIUtil::HelpMessageBox help; + help.exec(); +} + +void RPCConsole::on_sldGraphRange_valueChanged(int value) +{ + const int multiplier = 5; // each position on the slider represents 5 min + int mins = value * multiplier; + setTrafficGraphRange(mins); +} + +QString RPCConsole::FormatBytes(quint64 bytes) +{ + if(bytes < 1024) + return QString(tr("%1 B")).arg(bytes); + if(bytes < 1024 * 1024) + return QString(tr("%1 KB")).arg(bytes / 1024); + if(bytes < 1024 * 1024 * 1024) + return QString(tr("%1 MB")).arg(bytes / 1024 / 1024); + + return QString(tr("%1 GB")).arg(bytes / 1024 / 1024 / 1024); +} + +void RPCConsole::setTrafficGraphRange(int mins) +{ + ui->trafficGraph->setGraphRangeMins(mins); + if(mins < 60) { + ui->lblGraphRange->setText(QString(tr("%1 m")).arg(mins)); + } else { + int hours = mins / 60; + int minsLeft = mins % 60; + if(minsLeft == 0) { + ui->lblGraphRange->setText(QString(tr("%1 h")).arg(hours)); + } else { + ui->lblGraphRange->setText(QString(tr("%1 h %2 m")).arg(hours).arg(minsLeft)); + } + } +} + +void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut) +{ + ui->lblBytesIn->setText(FormatBytes(totalBytesIn)); + ui->lblBytesOut->setText(FormatBytes(totalBytesOut)); +} + +void RPCConsole::on_btnClearTrafficGraph_clicked() +{ + ui->trafficGraph->clear(); +} diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h new file mode 100644 index 0000000..4c9670d --- /dev/null +++ b/src/qt/rpcconsole.h @@ -0,0 +1,77 @@ +#ifndef RPCCONSOLE_H +#define RPCCONSOLE_H + +#include + +namespace Ui { + class RPCConsole; +} +class ClientModel; + +bool parseCommandLine(std::vector &args, const std::string &strCommand); + +/** Local Bitcoin RPC console. */ +class RPCConsole: public QDialog +{ + Q_OBJECT + +public: + explicit RPCConsole(QWidget *parent = 0); + ~RPCConsole(); + + void setClientModel(ClientModel *model); + + enum MessageClass { + MC_ERROR, + MC_DEBUG, + CMD_REQUEST, + CMD_REPLY, + CMD_ERROR + }; + +protected: + virtual bool eventFilter(QObject* obj, QEvent *event); + +private slots: + void on_lineEdit_returnPressed(); + void on_tabWidget_currentChanged(int index); + /** open the debug.log from the current datadir */ + void on_openDebugLogfileButton_clicked(); + /** display messagebox with program parameters (same as bitcoin-qt --help) */ + void on_showCLOptionsButton_clicked(); + /** change the time range of the network traffic graph */ + void on_sldGraphRange_valueChanged(int value); + /** update traffic statistics */ + void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut); + /** clear traffic graph */ + void on_btnClearTrafficGraph_clicked(); + +public slots: + void clear(); + void message(int category, const QString &message, bool html = false); + /** Set number of connections shown in the UI */ + void setNumConnections(int count); + /** Set number of blocks shown in the UI */ + void setNumBlocks(int count); + /** Go forward or back in history */ + void browseHistory(int offset); + /** Scroll console view to end */ + void scrollToEnd(); +signals: + // For RPC command executor + void stopExecutor(); + void cmdRequest(const QString &command); + +private: + static QString FormatBytes(quint64 bytes); + void setTrafficGraphRange(int mins); + + Ui::RPCConsole *ui; + ClientModel *clientModel; + QStringList history; + int historyPtr; + + void startExecutor(); +}; + +#endif // RPCCONSOLE_H diff --git a/src/qt/rpcexecutor.cpp b/src/qt/rpcexecutor.cpp new file mode 100644 index 0000000..9b4bc03 --- /dev/null +++ b/src/qt/rpcexecutor.cpp @@ -0,0 +1,58 @@ +#include "rpcexecutor.h" + +#include "rpcconsole.h" +#include "rpcclient.h" +#include "rpcserver.h" + +void RPCExecutor::start() +{ + // Nothing to do +} + +void RPCExecutor::request(const QString &command) +{ + std::vector args; + if(!parseCommandLine(args, command.toStdString())) + { + emit reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \"")); + return; + } + if(args.empty()) + return; // Nothing to do + try + { + std::string strPrint; + // Convert argument list to JSON objects in method-dependent way, + // and pass it along with the method name to the dispatcher. + json_spirit::Value result = tableRPC.execute( + args[0], + RPCConvertValues(args[0], std::vector(args.begin() + 1, args.end()))); + + // Format result reply + if (result.type() == json_spirit::null_type) + strPrint = ""; + else if (result.type() == json_spirit::str_type) + strPrint = result.get_str(); + else + strPrint = write_string(result, true); + + emit reply(RPCConsole::CMD_REPLY, QString::fromStdString(strPrint)); + } + catch (json_spirit::Object& objError) + { + try // Nice formatting for standard-format error + { + int code = find_value(objError, "code").get_int(); + std::string message = find_value(objError, "message").get_str(); + emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(message) + " (code " + QString::number(code) + ")"); + } + catch(std::runtime_error &) // raised when converting to invalid type, i.e. missing code or message + { // Show raw JSON object + emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(write_string(json_spirit::Value(objError), false))); + } + } + catch (std::exception& e) + { + emit reply(RPCConsole::CMD_ERROR, QString("Error: ") + QString::fromStdString(e.what())); + } +} diff --git a/src/qt/rpcexecutor.h b/src/qt/rpcexecutor.h new file mode 100644 index 0000000..0ea618c --- /dev/null +++ b/src/qt/rpcexecutor.h @@ -0,0 +1,21 @@ +#ifndef RPCEXECUTOR_H +#define RPCEXECUTOR_H + +#include +#include + +/* Object for executing console RPC commands in a separate thread. +*/ +class RPCExecutor : public QObject +{ + Q_OBJECT + +public slots: + void start(); + void request(const QString &command); + +signals: + void reply(int category, const QString &command); +}; + +#endif // RPCEXECUTOR_H diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp new file mode 100644 index 0000000..cc5db7a --- /dev/null +++ b/src/qt/sendcoinsdialog.cpp @@ -0,0 +1,521 @@ +#include "sendcoinsdialog.h" +#include "ui_sendcoinsdialog.h" + +#include "walletmodel.h" +#include "addresstablemodel.h" +#include "addressbookpage.h" + +#include "bitcoinunits.h" +#include "addressbookpage.h" +#include "optionsmodel.h" +#include "sendcoinsentry.h" +#include "guiutil.h" +#include "askpassphrasedialog.h" + +#include "base58.h" +#include "coincontrol.h" +#include "coincontroldialog.h" + +#include +#include +#include +#include + +SendCoinsDialog::SendCoinsDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::SendCoinsDialog), + model(0) +{ + ui->setupUi(this); + +#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac + ui->addButton->setIcon(QIcon()); + ui->clearButton->setIcon(QIcon()); + ui->sendButton->setIcon(QIcon()); +#endif + +#if QT_VERSION >= 0x040700 + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ + ui->lineEditCoinControlChange->setPlaceholderText(tr("Enter a SONO address (e.g. LXcY9ye9ftbELRcAm8rEwPbEweWRax4Asq)")); +#endif + + addEntry(); + + connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry())); + connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); + + // Coin Control + ui->lineEditCoinControlChange->setFont(GUIUtil::bitcoinAddressFont()); + connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked())); + connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int))); + connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &))); + + // Coin Control: clipboard actions + QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); + QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this); + QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this); + QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this); + QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); + QAction *clipboardPriorityAction = new QAction(tr("Copy priority"), this); + QAction *clipboardLowOutputAction = new QAction(tr("Copy low output"), this); + QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); + connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity())); + connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount())); + connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee())); + connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee())); + connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes())); + connect(clipboardPriorityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardPriority())); + connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput())); + connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange())); + ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); + ui->labelCoinControlAmount->addAction(clipboardAmountAction); + ui->labelCoinControlFee->addAction(clipboardFeeAction); + ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction); + ui->labelCoinControlBytes->addAction(clipboardBytesAction); + ui->labelCoinControlPriority->addAction(clipboardPriorityAction); + ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction); + ui->labelCoinControlChange->addAction(clipboardChangeAction); + + fNewRecipientAllowed = true; +} + +void SendCoinsDialog::setModel(WalletModel *model) +{ + this->model = model; + + if(model && model->getOptionsModel()) + { + for(int i = 0; i < ui->entries->count(); ++i) + { + SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + { + entry->setModel(model); + } + } + + setBalance(model->getBalance(), model->getStake(), model->getUnconfirmedBalance(), model->getImmatureBalance()); + connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64))); + connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); + + // Coin Control + connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels())); + connect(model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool))); + connect(model->getOptionsModel(), SIGNAL(transactionFeeChanged(qint64)), this, SLOT(coinControlUpdateLabels())); + ui->frameCoinControl->setVisible(model->getOptionsModel()->getCoinControlFeatures()); + coinControlUpdateLabels(); + } +} + +SendCoinsDialog::~SendCoinsDialog() +{ + delete ui; +} + +void SendCoinsDialog::on_sendButton_clicked() +{ + if(!model || !model->getOptionsModel()) + return; + + QList recipients; + bool valid = true; + + for(int i = 0; i < ui->entries->count(); ++i) + { + SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + { + if(entry->validate()) + { + recipients.append(entry->getValue()); + } + else + { + valid = false; + } + } + } + + if(!valid || recipients.isEmpty()) + { + return; + } + + // Format confirmation message + QStringList formatted; + foreach(const SendCoinsRecipient &rcp, recipients) + { + formatted.append(tr("%1 to %2 (%3)").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount), Qt::escape(rcp.label), rcp.address)); + } + + fNewRecipientAllowed = false; + + QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), + tr("Are you sure you want to send %1?").arg(formatted.join(tr(" and "))), + QMessageBox::Yes|QMessageBox::Cancel, + QMessageBox::Cancel); + + if(retval != QMessageBox::Yes) + { + fNewRecipientAllowed = true; + return; + } + + WalletModel::UnlockContext ctx(model->requestUnlock()); + if(!ctx.isValid()) + { + // Unlock wallet was cancelled + fNewRecipientAllowed = true; + return; + } + + WalletModel::SendCoinsReturn sendstatus; + + if (!model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures()) + sendstatus = model->sendCoins(recipients); + else + sendstatus = model->sendCoins(recipients, CoinControlDialog::coinControl); + + switch(sendstatus.status) + { + case WalletModel::InvalidAddress: + QMessageBox::warning(this, tr("Send Coins"), + tr("The recipient address is not valid, please recheck."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case WalletModel::InvalidAmount: + QMessageBox::warning(this, tr("Send Coins"), + tr("The amount to pay must be larger than 0."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case WalletModel::AmountExceedsBalance: + QMessageBox::warning(this, tr("Send Coins"), + tr("The amount exceeds your balance."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case WalletModel::AmountWithFeeExceedsBalance: + QMessageBox::warning(this, tr("Send Coins"), + tr("The total exceeds your balance when the %1 transaction fee is included."). + arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), sendstatus.fee)), + QMessageBox::Ok, QMessageBox::Ok); + break; + case WalletModel::DuplicateAddress: + QMessageBox::warning(this, tr("Send Coins"), + tr("Duplicate address found, can only send to each address once per send operation."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case WalletModel::TransactionCreationFailed: + QMessageBox::warning(this, tr("Send Coins"), + tr("Error: Transaction creation failed!"), + QMessageBox::Ok, QMessageBox::Ok); + break; + case WalletModel::TransactionCommitFailed: + QMessageBox::warning(this, tr("Send Coins"), + tr("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case WalletModel::NarrationTooLong: + QMessageBox::warning(this, tr("Send Coins"), + tr("Error: Narration is too long."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case WalletModel::Aborted: // User aborted, nothing to do + break; + case WalletModel::OK: + accept(); + CoinControlDialog::coinControl->UnSelectAll(); + coinControlUpdateLabels(); + break; + } + fNewRecipientAllowed = true; +} + +void SendCoinsDialog::clear() +{ + // Remove entries until only one left + while(ui->entries->count()) + { + delete ui->entries->takeAt(0)->widget(); + } + addEntry(); + + updateRemoveEnabled(); + + ui->sendButton->setDefault(true); +} + +void SendCoinsDialog::reject() +{ + clear(); +} + +void SendCoinsDialog::accept() +{ + clear(); +} + +SendCoinsEntry *SendCoinsDialog::addEntry() +{ + SendCoinsEntry *entry = new SendCoinsEntry(this); + entry->setModel(model); + ui->entries->addWidget(entry); + connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*))); + connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels())); + + updateRemoveEnabled(); + + // Focus the field, so that entry can start immediately + entry->clear(); + entry->setFocus(); + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); + QCoreApplication::instance()->processEvents(); + QScrollBar* bar = ui->scrollArea->verticalScrollBar(); + if(bar) + bar->setSliderPosition(bar->maximum()); + return entry; +} + +void SendCoinsDialog::updateRemoveEnabled() +{ + // Remove buttons are enabled as soon as there is more than one send-entry + bool enabled = (ui->entries->count() > 1); + for(int i = 0; i < ui->entries->count(); ++i) + { + SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + { + entry->setRemoveEnabled(enabled); + } + } + setupTabChain(0); + coinControlUpdateLabels(); +} + +void SendCoinsDialog::removeEntry(SendCoinsEntry* entry) +{ + delete entry; + updateRemoveEnabled(); +} + +QWidget *SendCoinsDialog::setupTabChain(QWidget *prev) +{ + for(int i = 0; i < ui->entries->count(); ++i) + { + SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + { + prev = entry->setupTabChain(prev); + } + } + QWidget::setTabOrder(prev, ui->addButton); + QWidget::setTabOrder(ui->addButton, ui->sendButton); + return ui->sendButton; +} + +void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) +{ + if(!fNewRecipientAllowed) + return; + + SendCoinsEntry *entry = 0; + // Replace the first entry if it is still unused + if(ui->entries->count() == 1) + { + SendCoinsEntry *first = qobject_cast(ui->entries->itemAt(0)->widget()); + if(first->isClear()) + { + entry = first; + } + } + if(!entry) + { + entry = addEntry(); + } + + entry->setValue(rv); +} + +bool SendCoinsDialog::handleURI(const QString &uri) +{ + SendCoinsRecipient rv; + // URI has to be valid + if (GUIUtil::parseBitcoinURI(uri, &rv)) + { + CBitcoinAddress address(rv.address.toStdString()); + if (!address.IsValid()) + return false; + pasteEntry(rv); + return true; + } + + return false; +} + +void SendCoinsDialog::setBalance(qint64 balance, qint64 stake, qint64 unconfirmedBalance, qint64 immatureBalance) +{ + Q_UNUSED(stake); + Q_UNUSED(unconfirmedBalance); + Q_UNUSED(immatureBalance); + + if(model && model->getOptionsModel()) + { + ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance)); + } +} + +void SendCoinsDialog::updateDisplayUnit() +{ + setBalance(model->getBalance(), 0, 0, 0); +} + +// Coin Control: copy label "Quantity" to clipboard +void SendCoinsDialog::coinControlClipboardQuantity() +{ + QApplication::clipboard()->setText(ui->labelCoinControlQuantity->text()); +} + +// Coin Control: copy label "Amount" to clipboard +void SendCoinsDialog::coinControlClipboardAmount() +{ + QApplication::clipboard()->setText(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" "))); +} + +// Coin Control: copy label "Fee" to clipboard +void SendCoinsDialog::coinControlClipboardFee() +{ + QApplication::clipboard()->setText(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" "))); +} + +// Coin Control: copy label "After fee" to clipboard +void SendCoinsDialog::coinControlClipboardAfterFee() +{ + QApplication::clipboard()->setText(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" "))); +} + +// Coin Control: copy label "Bytes" to clipboard +void SendCoinsDialog::coinControlClipboardBytes() +{ + QApplication::clipboard()->setText(ui->labelCoinControlBytes->text()); +} + +// Coin Control: copy label "Priority" to clipboard +void SendCoinsDialog::coinControlClipboardPriority() +{ + QApplication::clipboard()->setText(ui->labelCoinControlPriority->text()); +} + +// Coin Control: copy label "Low output" to clipboard +void SendCoinsDialog::coinControlClipboardLowOutput() +{ + QApplication::clipboard()->setText(ui->labelCoinControlLowOutput->text()); +} + +// Coin Control: copy label "Change" to clipboard +void SendCoinsDialog::coinControlClipboardChange() +{ + QApplication::clipboard()->setText(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" "))); +} + +// Coin Control: settings menu - coin control enabled/disabled by user +void SendCoinsDialog::coinControlFeatureChanged(bool checked) +{ + ui->frameCoinControl->setVisible(checked); + + if (!checked && model) // coin control features disabled + CoinControlDialog::coinControl->SetNull(); +} + +// Coin Control: button inputs -> show actual coin control dialog +void SendCoinsDialog::coinControlButtonClicked() +{ + CoinControlDialog dlg; + dlg.setModel(model); + dlg.exec(); + coinControlUpdateLabels(); +} + +// Coin Control: checkbox custom change address +void SendCoinsDialog::coinControlChangeChecked(int state) +{ + if (model) + { + if (state == Qt::Checked) + CoinControlDialog::coinControl->destChange = CBitcoinAddress(ui->lineEditCoinControlChange->text().toStdString()).Get(); + else + CoinControlDialog::coinControl->destChange = CNoDestination(); + } + + ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked)); + ui->labelCoinControlChangeLabel->setEnabled((state == Qt::Checked)); +} + +// Coin Control: custom change address changed +void SendCoinsDialog::coinControlChangeEdited(const QString & text) +{ + if (model) + { + CoinControlDialog::coinControl->destChange = CBitcoinAddress(text.toStdString()).Get(); + + // label for the change address + ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}"); + if (text.isEmpty()) + ui->labelCoinControlChangeLabel->setText(""); + else if (!CBitcoinAddress(text.toStdString()).IsValid()) + { + ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); + ui->labelCoinControlChangeLabel->setText(tr("WARNING: Invalid SONO address")); + } + else + { + QString associatedLabel = model->getAddressTableModel()->labelForAddress(text); + if (!associatedLabel.isEmpty()) + ui->labelCoinControlChangeLabel->setText(associatedLabel); + else + { + CPubKey pubkey; + CKeyID keyid; + CBitcoinAddress(text.toStdString()).GetKeyID(keyid); + if (model->getPubKey(keyid, pubkey)) + ui->labelCoinControlChangeLabel->setText(tr("(no label)")); + else + { + ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); + ui->labelCoinControlChangeLabel->setText(tr("WARNING: unknown change address")); + } + } + } + } +} + +// Coin Control: update labels +void SendCoinsDialog::coinControlUpdateLabels() +{ + if (!model || !model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures()) + return; + + // set pay amounts + CoinControlDialog::payAmounts.clear(); + for(int i = 0; i < ui->entries->count(); ++i) + { + SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + CoinControlDialog::payAmounts.append(entry->getValue().amount); + } + + if (CoinControlDialog::coinControl->HasSelected()) + { + // actual coin control calculation + CoinControlDialog::updateLabels(model, this); + + // show coin control stats + ui->labelCoinControlAutomaticallySelected->hide(); + ui->widgetCoinControl->show(); + } + else + { + // hide coin control stats + ui->labelCoinControlAutomaticallySelected->show(); + ui->widgetCoinControl->hide(); + ui->labelCoinControlInsuffFunds->hide(); + } +} diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h new file mode 100644 index 0000000..e56e3eb --- /dev/null +++ b/src/qt/sendcoinsdialog.h @@ -0,0 +1,68 @@ +#ifndef SENDCOINSDIALOG_H +#define SENDCOINSDIALOG_H + +#include +#include + +namespace Ui { + class SendCoinsDialog; +} +class WalletModel; +class SendCoinsEntry; +class SendCoinsRecipient; + +QT_BEGIN_NAMESPACE +class QUrl; +QT_END_NAMESPACE + +/** Dialog for sending bitcoins */ +class SendCoinsDialog : public QDialog +{ + Q_OBJECT + +public: + explicit SendCoinsDialog(QWidget *parent = 0); + ~SendCoinsDialog(); + + void setModel(WalletModel *model); + + /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). + */ + QWidget *setupTabChain(QWidget *prev); + + void pasteEntry(const SendCoinsRecipient &rv); + bool handleURI(const QString &uri); + +public slots: + void clear(); + void reject(); + void accept(); + SendCoinsEntry *addEntry(); + void updateRemoveEnabled(); + void setBalance(qint64 balance, qint64 stake, qint64 unconfirmedBalance, qint64 immatureBalance); + +private: + Ui::SendCoinsDialog *ui; + WalletModel *model; + bool fNewRecipientAllowed; + +private slots: + void on_sendButton_clicked(); + void removeEntry(SendCoinsEntry* entry); + void updateDisplayUnit(); + void coinControlFeatureChanged(bool); + void coinControlButtonClicked(); + void coinControlChangeChecked(int); + void coinControlChangeEdited(const QString &); + void coinControlUpdateLabels(); + void coinControlClipboardQuantity(); + void coinControlClipboardAmount(); + void coinControlClipboardFee(); + void coinControlClipboardAfterFee(); + void coinControlClipboardBytes(); + void coinControlClipboardPriority(); + void coinControlClipboardLowOutput(); + void coinControlClipboardChange(); +}; + +#endif // SENDCOINSDIALOG_H diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp new file mode 100644 index 0000000..ab61a0a --- /dev/null +++ b/src/qt/sendcoinsentry.cpp @@ -0,0 +1,182 @@ +#include "sendcoinsentry.h" +#include "ui_sendcoinsentry.h" + +#include "guiutil.h" +#include "bitcoinunits.h" +#include "addressbookpage.h" +#include "walletmodel.h" +#include "optionsmodel.h" +#include "addresstablemodel.h" +#include "stealth.h" + +#include +#include + +SendCoinsEntry::SendCoinsEntry(QWidget *parent) : + QFrame(parent), + ui(new Ui::SendCoinsEntry), + model(0) +{ + ui->setupUi(this); + +#ifdef Q_OS_MAC + ui->payToLayout->setSpacing(4); +#endif +#if QT_VERSION >= 0x040700 + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ + ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book")); + ui->payTo->setPlaceholderText(tr("Enter a SONO address (e.g. LXcY9ye9ftbELRcAm8rEwPbEweWRax4Asq)")); +#endif + setFocusPolicy(Qt::TabFocus); + setFocusProxy(ui->payTo); + + GUIUtil::setupAddressWidget(ui->payTo, this); +} + +SendCoinsEntry::~SendCoinsEntry() +{ + delete ui; +} + +void SendCoinsEntry::on_pasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->payTo->setText(QApplication::clipboard()->text()); +} + +void SendCoinsEntry::on_addressBookButton_clicked() +{ + if(!model) + return; + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); + dlg.setModel(model->getAddressTableModel()); + if(dlg.exec()) + { + ui->payTo->setText(dlg.getReturnValue()); + ui->payAmount->setFocus(); + } +} + +void SendCoinsEntry::on_payTo_textChanged(const QString &address) +{ + if(!model) + return; + // Fill in label from address book, if address has an associated label + QString associatedLabel = model->getAddressTableModel()->labelForAddress(address); + if(!associatedLabel.isEmpty()) + ui->addAsLabel->setText(associatedLabel); +} + +void SendCoinsEntry::setModel(WalletModel *model) +{ + this->model = model; + + if(model && model->getOptionsModel()) + connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); + + connect(ui->payAmount, SIGNAL(textChanged()), this, SIGNAL(payAmountChanged())); + + clear(); +} + +void SendCoinsEntry::setRemoveEnabled(bool enabled) +{ + ui->deleteButton->setEnabled(enabled); +} + +void SendCoinsEntry::clear() +{ + ui->payTo->clear(); + ui->addAsLabel->clear(); + ui->payAmount->clear(); + ui->payTo->setFocus(); + // update the display unit, to not use the default ("BTC") + updateDisplayUnit(); +} + +void SendCoinsEntry::on_deleteButton_clicked() +{ + emit removeEntry(this); +} + +bool SendCoinsEntry::validate() +{ + // Check input validity + bool retval = true; + + if(!ui->payAmount->validate()) + { + retval = false; + } + else + { + if(ui->payAmount->value() <= 0) + { + // Cannot send 0 coins or less + ui->payAmount->setValid(false); + retval = false; + } + } + + if(!ui->payTo->hasAcceptableInput() || + (model && !model->validateAddress(ui->payTo->text()))) + { + ui->payTo->setValid(false); + retval = false; + } + + return retval; +} + +SendCoinsRecipient SendCoinsEntry::getValue() +{ + SendCoinsRecipient rv; + + rv.address = ui->payTo->text(); + rv.label = ui->addAsLabel->text(); + rv.amount = ui->payAmount->value(); + + if (rv.address.length() > 75 + && IsStealthAddress(rv.address.toStdString())) + rv.typeInd = AddressTableModel::AT_Stealth; + else + rv.typeInd = AddressTableModel::AT_Normal; + + return rv; +} + +QWidget *SendCoinsEntry::setupTabChain(QWidget *prev) +{ + QWidget::setTabOrder(prev, ui->payTo); + QWidget::setTabOrder(ui->payTo, ui->addressBookButton); + QWidget::setTabOrder(ui->addressBookButton, ui->pasteButton); + QWidget::setTabOrder(ui->pasteButton, ui->deleteButton); + QWidget::setTabOrder(ui->deleteButton, ui->addAsLabel); + return ui->payAmount->setupTabChain(ui->addAsLabel); +} + +void SendCoinsEntry::setValue(const SendCoinsRecipient &value) +{ + ui->payTo->setText(value.address); + ui->addAsLabel->setText(value.label); + ui->payAmount->setValue(value.amount); +} + +bool SendCoinsEntry::isClear() +{ + return ui->payTo->text().isEmpty(); +} + +void SendCoinsEntry::setFocus() +{ + ui->payTo->setFocus(); +} + +void SendCoinsEntry::updateDisplayUnit() +{ + if(model && model->getOptionsModel()) + { + // Update payAmount with the current unit + ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); + } +} diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h new file mode 100644 index 0000000..050c3de --- /dev/null +++ b/src/qt/sendcoinsentry.h @@ -0,0 +1,56 @@ +#ifndef SENDCOINSENTRY_H +#define SENDCOINSENTRY_H + +#include + +namespace Ui { + class SendCoinsEntry; +} +class WalletModel; +class SendCoinsRecipient; + +/** A single entry in the dialog for sending bitcoins. */ +class SendCoinsEntry : public QFrame +{ + Q_OBJECT + +public: + explicit SendCoinsEntry(QWidget *parent = 0); + ~SendCoinsEntry(); + + void setModel(WalletModel *model); + bool validate(); + SendCoinsRecipient getValue(); + + /** Return whether the entry is still empty and unedited */ + bool isClear(); + + void setValue(const SendCoinsRecipient &value); + + /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). + */ + QWidget *setupTabChain(QWidget *prev); + + void setFocus(); + +public slots: + void setRemoveEnabled(bool enabled); + void clear(); + +signals: + void removeEntry(SendCoinsEntry *entry); + void payAmountChanged(); + +private slots: + void on_deleteButton_clicked(); + void on_payTo_textChanged(const QString &address); + void on_addressBookButton_clicked(); + void on_pasteButton_clicked(); + void updateDisplayUnit(); + +private: + Ui::SendCoinsEntry *ui; + WalletModel *model; +}; + +#endif // SENDCOINSENTRY_H diff --git a/src/qt/sendmessagesdialog.cpp b/src/qt/sendmessagesdialog.cpp new file mode 100644 index 0000000..c1a342f --- /dev/null +++ b/src/qt/sendmessagesdialog.cpp @@ -0,0 +1,339 @@ +#include "sendmessagesdialog.h" +#include "ui_sendmessagesdialog.h" +//#include "init.h" +#include "walletmodel.h" +#include "messagemodel.h" +#include "addressbookpage.h" +#include "optionsmodel.h" +#include "sendmessagesentry.h" +//#include "guiutil.h" + +#include +#include +#include +#include +#include +#include + +SendMessagesDialog::SendMessagesDialog(Mode mode, Type type, QWidget *parent) : + QDialog(parent), + ui(new Ui::SendMessagesDialog), + model(0), + mode(mode), + type(type) +{ + + ui->setupUi(this); + +#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac + ui->addButton->setIcon(QIcon()); + ui->clearButton->setIcon(QIcon()); + ui->sendButton->setIcon(QIcon()); +#endif + +#if QT_VERSION >= 0x040700 + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ + if(mode == SendMessagesDialog::Encrypted) + ui->addressFrom->setPlaceholderText(tr("Enter a SONO address (e.g. LXcY9ye9ftbELRcAm8rEwPbEweWRax4Asq)")); + #endif + addEntry(); + + connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry())); + connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); + connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(reject())); + + fNewRecipientAllowed = true; + + if(mode == SendMessagesDialog::Anonymous) + ui->frameAddressFrom->hide(); + + if(type == SendMessagesDialog::Page) + ui->closeButton->hide(); +} + +void SendMessagesDialog::setModel(MessageModel *model) +{ + this->model = model; + + for(int i = 0; i < ui->entries->count(); ++i) + { + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + + if(entry) + entry->setModel(model); + } +} + +void SendMessagesDialog::loadRow(int row) +{ + if(model->data(model->index(row, model->Type, QModelIndex()), Qt::DisplayRole).toString() == MessageModel::Received) + ui->addressFrom->setText(model->data(model->index(row, model->ToAddress, QModelIndex()), Qt::DisplayRole).toString()); + else + ui->addressFrom->setText(model->data(model->index(row, model->FromAddress, QModelIndex()), Qt::DisplayRole).toString()); + + for(int i = 0; i < ui->entries->count(); ++i) + { + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + + if(entry) + entry->loadRow(row); + } +} + +bool SendMessagesDialog::checkMode(Mode mode) +{ + return (mode == this->mode); +} + +bool SendMessagesDialog::validate() +{ + if(mode == SendMessagesDialog::Encrypted && ui->addressFrom->text() == "") + { + ui->addressFrom->setValid(false); + + return false; + } + + return true; +} + +SendMessagesDialog::~SendMessagesDialog() +{ + delete ui; +} + +void SendMessagesDialog::on_pasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->addressFrom->setText(QApplication::clipboard()->text()); +} + +void SendMessagesDialog::on_addressBookButton_clicked() +{ + if(!model) + return; + + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this); + + dlg.setModel(model->getWalletModel()->getAddressTableModel()); + + if(dlg.exec()) + { + ui->addressFrom->setText(dlg.getReturnValue()); + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(0)->widget()); + entry->setFocus(); + // findChild( const QString "sentTo")->setFocus(); + } +} + +void SendMessagesDialog::on_sendButton_clicked() +{ + QList recipients; + bool valid = true; + + if(!model) + return; + + valid = validate(); + + for(int i = 0; i < ui->entries->count(); ++i) + { + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + { + if(entry->validate()) + recipients.append(entry->getValue()); + else + valid = false; + } + } + + if(!valid || recipients.isEmpty()) + return; + + // Format confirmation message + QStringList formatted; + foreach(const SendMessagesRecipient &rcp, recipients) + { + formatted.append(tr("%1 to %2 (%3)").arg(rcp.message, Qt::escape(rcp.label), rcp.address)); + } + + fNewRecipientAllowed = false; + + QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send messages"), + tr("Are you sure you want to send %1?").arg(formatted.join(tr(" and "))), + QMessageBox::Yes|QMessageBox::Cancel, + QMessageBox::Cancel); + + if(retval != QMessageBox::Yes) + { + fNewRecipientAllowed = true; + return; + } + + MessageModel::StatusCode sendstatus; + + if(mode == SendMessagesDialog::Anonymous) + sendstatus = model->sendMessages(recipients); + else + sendstatus = model->sendMessages(recipients, ui->addressFrom->text()); + + switch(sendstatus) + { + case MessageModel::InvalidAddress: + QMessageBox::warning(this, tr("Send Message"), + tr("The recipient address is not valid, please recheck."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case MessageModel::InvalidMessage: + QMessageBox::warning(this, tr("Send Message"), + tr("The message can't be empty."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case MessageModel::DuplicateAddress: + QMessageBox::warning(this, tr("Send Message"), + tr("Duplicate address found, can only send to each address once per send operation."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case MessageModel::MessageCreationFailed: + QMessageBox::warning(this, tr("Send Message"), + tr("Error: Message creation failed."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case MessageModel::MessageCommitFailed: + QMessageBox::warning(this, tr("Send Message"), + tr("Error: The message was rejected."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case MessageModel::Aborted: // User aborted, nothing to do + break; + case MessageModel::FailedErrorShown: // Send failed, error message was displayed + break; + case MessageModel::OK: + accept(); + break; + } + + fNewRecipientAllowed = true; +} + +void SendMessagesDialog::clear() +{ + // Remove entries until only one left + while(ui->entries->count()) + delete ui->entries->takeAt(0)->widget(); + + addEntry(); + + updateRemoveEnabled(); + + ui->sendButton->setDefault(true); +} + +void SendMessagesDialog::reject() +{ + if(type == SendMessagesDialog::Dialog) + done(1); + else + clear(); +} + +void SendMessagesDialog::accept() +{ + if(type == SendMessagesDialog::Dialog) + done(0); + else + clear(); + +} + +void SendMessagesDialog::done(int retval) +{ + if(type == SendMessagesDialog::Dialog) + QDialog::done(retval); + else + clear(); +} + +SendMessagesEntry *SendMessagesDialog::addEntry() +{ + SendMessagesEntry *entry = new SendMessagesEntry(this); + + entry->setModel(model); + ui->entries->addWidget(entry); + connect(entry, SIGNAL(removeEntry(SendMessagesEntry*)), this, SLOT(removeEntry(SendMessagesEntry*))); + updateRemoveEnabled(); + + // Focus the field, so that entry can start immediately + entry->clear(); + entry->setFocus(); + + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); + QCoreApplication::instance()->processEvents(); + QScrollBar* bar = ui->scrollArea->verticalScrollBar(); + + if(bar) + bar->setSliderPosition(bar->maximum()); + + return entry; +} + +void SendMessagesDialog::updateRemoveEnabled() +{ + // Remove buttons are enabled as soon as there is more than one send-entry + bool enabled = (ui->entries->count() > 1); + + for(int i = 0; i < ui->entries->count(); ++i) + { + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + entry->setRemoveEnabled(enabled); + } + + setupTabChain(0); +} + +void SendMessagesDialog::removeEntry(SendMessagesEntry* entry) +{ + delete entry; + + updateRemoveEnabled(); +} + +QWidget *SendMessagesDialog::setupTabChain(QWidget *prev) +{ + for(int i = 0; i < ui->entries->count(); ++i) + { + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + { + prev = entry->setupTabChain(prev); + } + } + + QWidget::setTabOrder(prev, ui->addButton); + QWidget::setTabOrder(ui->addButton, ui->sendButton); + + return ui->sendButton; +} + +void SendMessagesDialog::pasteEntry(const SendMessagesRecipient &rv) +{ + if(!fNewRecipientAllowed) + return; + + SendMessagesEntry *entry = 0; + // Replace the first entry if it is still unused + if(ui->entries->count() == 1) + { + SendMessagesEntry *first = qobject_cast(ui->entries->itemAt(0)->widget()); + + if(first->isClear()) + entry = first; + } + + if(!entry) + entry = addEntry(); + + entry->setValue(rv); +} diff --git a/src/qt/sendmessagesdialog.h b/src/qt/sendmessagesdialog.h new file mode 100644 index 0000000..7eb7de6 --- /dev/null +++ b/src/qt/sendmessagesdialog.h @@ -0,0 +1,72 @@ +#ifndef SENDMESSAGESDIALOG_H +#define SENDMESSAGESDIALOG_H + +#include +#include + +namespace Ui { + class SendMessagesDialog; +} + +class MessageModel; +class SendMessagesEntry; +class SendMessagesRecipient; + +//QT_BEGIN_NAMESPACE +//class QUrl; +//QT_END_NAMESPACE + +/** Dialog for sending messages */ +class SendMessagesDialog : public QDialog +{ + Q_OBJECT + +public: + + enum Mode { + Encrypted, + Anonymous, + }; + + enum Type { + Page, + Dialog, + }; + + explicit SendMessagesDialog(Mode mode, Type type, QWidget *parent = 0); + ~SendMessagesDialog(); + + void setModel (MessageModel *model); + void loadRow(int row); + bool checkMode(Mode mode); + bool validate (); + + /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). + */ + QWidget *setupTabChain(QWidget *prev); + + void pasteEntry(const SendMessagesRecipient &rv); + +public slots: + void done(int retval); + void clear(); + void reject(); + void accept(); + SendMessagesEntry *addEntry(); + void updateRemoveEnabled(); + +private: + Ui::SendMessagesDialog *ui; + MessageModel *model; + bool fNewRecipientAllowed; + Mode mode; + Type type; + +private slots: + void on_sendButton_clicked(); + void removeEntry(SendMessagesEntry* entry); + void on_addressBookButton_clicked(); + void on_pasteButton_clicked(); +}; + +#endif // SENDMESSAGESDIALOG_H diff --git a/src/qt/sendmessagesentry.cpp b/src/qt/sendmessagesentry.cpp new file mode 100644 index 0000000..857b8e2 --- /dev/null +++ b/src/qt/sendmessagesentry.cpp @@ -0,0 +1,204 @@ +#include "sendmessagesentry.h" +#include "ui_sendmessagesentry.h" +#include "guiutil.h" +#include "addressbookpage.h" +#include "walletmodel.h" +#include "messagemodel.h" +#include "optionsmodel.h" +#include "addresstablemodel.h" + +#include "smessage.h" + +#include +#include + +SendMessagesEntry::SendMessagesEntry(QWidget *parent) : + QFrame(parent), + ui(new Ui::SendMessagesEntry), + model(0) +{ + ui->setupUi(this); + +#ifdef Q_OS_MAC + ui->sendToLayout->setSpacing(4); +#endif +#if QT_VERSION >= 0x040700 + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ + ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book")); + ui->sendTo->setPlaceholderText(tr("Enter a SONO address (e.g. CKPnZKDzaDXqEgKJ4GdUg58gXxgzA7mkny)")); + ui->publicKey->setPlaceholderText(tr("Enter the public key for the address above, it is not in the blockchain")); + ui->messageText->setErrorText(tr("You cannot send a blank message!")); +#endif + setFocusPolicy(Qt::TabFocus); + setFocusProxy(ui->sendTo); + + GUIUtil::setupAddressWidget(ui->sendTo, this); +} + +SendMessagesEntry::~SendMessagesEntry() +{ + delete ui; +} + +void SendMessagesEntry::on_pasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->sendTo->setText(QApplication::clipboard()->text()); +} + +void SendMessagesEntry::on_addressBookButton_clicked() +{ + if(!model) + return; + + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); + + dlg.setModel(model->getWalletModel()->getAddressTableModel()); + + if(dlg.exec()) + { + + ui->sendTo->setText(dlg.getReturnValue()); + + if(ui->publicKey->text() == "") + ui->publicKey->setFocus(); + else + ui->messageText->setFocus(); + } +} + +void SendMessagesEntry::on_sendTo_textChanged(const QString &address) +{ + if(!model) + return; + + QString pubkey; + QString sendTo = address; + + if(model->getAddressOrPubkey(sendTo, pubkey)) + { + + ui->publicKey->setText(pubkey); + } + else + { + ui->publicKey->show(); + ui->publicKeyLabel->show(); + } + + // Fill in label from address book, if address has an associated label + QString associatedLabel = model->getWalletModel()->getAddressTableModel()->labelForAddress(address); + + if(!associatedLabel.isEmpty()) + ui->addAsLabel->setText(associatedLabel); +} + +void SendMessagesEntry::setModel(MessageModel *model) +{ + + this->model = model; + + //clear(); +} + +void SendMessagesEntry::loadRow(int row) +{ + if(model->data(model->index(row, model->Type, QModelIndex()), Qt::DisplayRole).toString() == MessageModel::Received) + ui->sendTo->setText(model->data(model->index(row, model->FromAddress, QModelIndex()), Qt::DisplayRole).toString()); + else + ui->sendTo->setText(model->data(model->index(row, model->ToAddress, QModelIndex()), Qt::DisplayRole).toString()); +} + +void SendMessagesEntry::setRemoveEnabled(bool enabled) +{ + ui->deleteButton->setEnabled(enabled); +} + +void SendMessagesEntry::clear() +{ + ui->sendTo->clear(); + ui->addAsLabel->clear(); + ui->messageText->clear(); + ui->sendTo->setFocus(); +} + +void SendMessagesEntry::on_deleteButton_clicked() +{ + emit removeEntry(this); +} + + +bool SendMessagesEntry::validate() +{ + // Check input validity + bool retval = true; + + if(ui->messageText->toPlainText() == "") + { + ui->messageText->setValid(false); + + retval = false; + } + + if(!ui->sendTo->hasAcceptableInput() || (!model->getWalletModel()->validateAddress(ui->sendTo->text()))) + { + ui->sendTo->setValid(false); + + retval = false; + } + + if(ui->publicKey->text() == "") + { + ui->publicKey->setValid(false); + ui->publicKey->show(); + + retval = false; + } + + return retval; +} + +SendMessagesRecipient SendMessagesEntry::getValue() +{ + SendMessagesRecipient rv; + + rv.address = ui->sendTo->text(); + rv.label = ui->addAsLabel->text(); + rv.pubkey = ui->publicKey->text(); + rv.message = ui->messageText->toPlainText(); + + return rv; +} + + +QWidget *SendMessagesEntry::setupTabChain(QWidget *prev) +{ + QWidget::setTabOrder(prev, ui->sendTo); + QWidget::setTabOrder(ui->sendTo, ui->addressBookButton); + QWidget::setTabOrder(ui->addressBookButton, ui->pasteButton); + QWidget::setTabOrder(ui->pasteButton, ui->deleteButton); + QWidget::setTabOrder(ui->deleteButton, ui->addAsLabel); + QWidget::setTabOrder(ui->addAsLabel, ui->publicKey); + QWidget::setTabOrder(ui->publicKey, ui->messageText); + + return ui->messageText; + +} + +void SendMessagesEntry::setValue(const SendMessagesRecipient &value) +{ + ui->sendTo->setText(value.address); + ui->addAsLabel->setText(value.label); + ui->publicKey->setText(value.pubkey); + ui->messageText->setPlainText(value.message); +} + +bool SendMessagesEntry::isClear() +{ + return ui->sendTo->text().isEmpty(); +} + +void SendMessagesEntry::setFocus() +{ + ui->sendTo->setFocus(); +} diff --git a/src/qt/sendmessagesentry.h b/src/qt/sendmessagesentry.h new file mode 100644 index 0000000..997d89d --- /dev/null +++ b/src/qt/sendmessagesentry.h @@ -0,0 +1,55 @@ +#ifndef SENDMESSAGESENTRY_H +#define SENDMESSAGESENTRY_H + +#include + +namespace Ui { + class SendMessagesEntry; +} +class MessageModel; +class SendMessagesRecipient; + +/** A single entry in the dialog for sending messages. */ +class SendMessagesEntry : public QFrame +{ + Q_OBJECT + +public: + explicit SendMessagesEntry(QWidget *parent = 0); + ~SendMessagesEntry(); + + void setModel(MessageModel *model); + void loadRow(int row); + bool validate(); + SendMessagesRecipient getValue(); + + /** Return whether the entry is still empty and unedited */ + bool isClear(); + + void setValue(const SendMessagesRecipient &value); + + /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). + */ + QWidget *setupTabChain(QWidget *prev); + + void setFocus(); + +public slots: + void setRemoveEnabled(bool enabled); + void clear(); + +signals: + void removeEntry(SendMessagesEntry *entry); + +private slots: + void on_deleteButton_clicked(); + void on_addressBookButton_clicked(); + void on_pasteButton_clicked(); + void on_sendTo_textChanged(const QString &address); + +private: + Ui::SendMessagesEntry *ui; + MessageModel *model; +}; + +#endif // SENDMESSAGESENTRY_H diff --git a/src/qt/signverifymessagedialog.cpp b/src/qt/signverifymessagedialog.cpp new file mode 100644 index 0000000..472e115 --- /dev/null +++ b/src/qt/signverifymessagedialog.cpp @@ -0,0 +1,277 @@ +#include "signverifymessagedialog.h" +#include "ui_signverifymessagedialog.h" + +#include "addressbookpage.h" +#include "base58.h" +#include "guiutil.h" +#include "init.h" +#include "main.h" +#include "optionsmodel.h" +#include "walletmodel.h" +#include "wallet.h" + +#include + +#include +#include + +SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::SignVerifyMessageDialog), + model(0) +{ + ui->setupUi(this); + +#if (QT_VERSION >= 0x040700) + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ + ui->addressIn_SM->setPlaceholderText(tr("Enter a SONO address (e.g. LXcY9ye9ftbELRcAm8rEwPbEweWRax4Asq)")); + ui->signatureOut_SM->setPlaceholderText(tr("Click \"Sign Message\" to generate signature")); + + ui->addressIn_VM->setPlaceholderText(tr("Enter a SONO address (e.g. LXcY9ye9ftbELRcAm8rEwPbEweWRax4Asq)")); + ui->signatureIn_VM->setPlaceholderText(tr("Enter SONO signature")); +#endif + + GUIUtil::setupAddressWidget(ui->addressIn_SM, this); + GUIUtil::setupAddressWidget(ui->addressIn_VM, this); + + ui->addressIn_SM->installEventFilter(this); + ui->messageIn_SM->installEventFilter(this); + ui->signatureOut_SM->installEventFilter(this); + ui->addressIn_VM->installEventFilter(this); + ui->messageIn_VM->installEventFilter(this); + ui->signatureIn_VM->installEventFilter(this); + + ui->signatureOut_SM->setFont(GUIUtil::bitcoinAddressFont()); + ui->signatureIn_VM->setFont(GUIUtil::bitcoinAddressFont()); +} + +SignVerifyMessageDialog::~SignVerifyMessageDialog() +{ + delete ui; +} + +void SignVerifyMessageDialog::setModel(WalletModel *model) +{ + this->model = model; +} + +void SignVerifyMessageDialog::setAddress_SM(QString address) +{ + ui->addressIn_SM->setText(address); + ui->messageIn_SM->setFocus(); +} + +void SignVerifyMessageDialog::setAddress_VM(QString address) +{ + ui->addressIn_VM->setText(address); + ui->messageIn_VM->setFocus(); +} + +void SignVerifyMessageDialog::showTab_SM(bool fShow) +{ + ui->tabWidget->setCurrentIndex(0); + + if (fShow) + this->show(); +} + +void SignVerifyMessageDialog::showTab_VM(bool fShow) +{ + ui->tabWidget->setCurrentIndex(1); + if (fShow) + this->show(); +} + +void SignVerifyMessageDialog::on_addressBookButton_SM_clicked() +{ + if (model && model->getAddressTableModel()) + { + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this); + dlg.setModel(model->getAddressTableModel()); + if (dlg.exec()) + { + setAddress_SM(dlg.getReturnValue()); + } + } +} + +void SignVerifyMessageDialog::on_pasteButton_SM_clicked() +{ + setAddress_SM(QApplication::clipboard()->text()); +} + +void SignVerifyMessageDialog::on_signMessageButton_SM_clicked() +{ + if (!model) + return; + + /* Clear old signature to ensure users don't get confused on error with an old signature displayed */ + ui->signatureOut_SM->clear(); + + CBitcoinAddress addr(ui->addressIn_SM->text().toStdString()); + if (!addr.IsValid()) + { + ui->addressIn_SM->setValid(false); + ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_SM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again.")); + return; + } + CKeyID keyID; + if (!addr.GetKeyID(keyID)) + { + ui->addressIn_SM->setValid(false); + ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_SM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again.")); + return; + } + + WalletModel::UnlockContext ctx(model->requestUnlock()); + if (!ctx.isValid()) + { + ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_SM->setText(tr("Wallet unlock was cancelled.")); + return; + } + + CKey key; + if (!pwalletMain->GetKey(keyID, key)) + { + ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_SM->setText(tr("Private key for the entered address is not available.")); + return; + } + + CDataStream ss(SER_GETHASH, 0); + ss << strMessageMagic; + ss << ui->messageIn_SM->document()->toPlainText().toStdString(); + + std::vector vchSig; + if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig)) + { + ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_SM->setText(QString("") + tr("Message signing failed.") + QString("")); + return; + } + + ui->statusLabel_SM->setStyleSheet("QLabel { color: green; }"); + ui->statusLabel_SM->setText(QString("") + tr("Message signed.") + QString("")); + + ui->signatureOut_SM->setText(QString::fromStdString(EncodeBase64(&vchSig[0], vchSig.size()))); +} + +void SignVerifyMessageDialog::on_copySignatureButton_SM_clicked() +{ + QApplication::clipboard()->setText(ui->signatureOut_SM->text()); +} + +void SignVerifyMessageDialog::on_clearButton_SM_clicked() +{ + ui->addressIn_SM->clear(); + ui->messageIn_SM->clear(); + ui->signatureOut_SM->clear(); + ui->statusLabel_SM->clear(); + + ui->addressIn_SM->setFocus(); +} + +void SignVerifyMessageDialog::on_addressBookButton_VM_clicked() +{ + if (model && model->getAddressTableModel()) + { + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); + dlg.setModel(model->getAddressTableModel()); + if (dlg.exec()) + { + setAddress_VM(dlg.getReturnValue()); + } + } +} + +void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked() +{ + CBitcoinAddress addr(ui->addressIn_VM->text().toStdString()); + if (!addr.IsValid()) + { + ui->addressIn_VM->setValid(false); + ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_VM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again.")); + return; + } + CKeyID keyID; + if (!addr.GetKeyID(keyID)) + { + ui->addressIn_VM->setValid(false); + ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_VM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again.")); + return; + } + + bool fInvalid = false; + std::vector vchSig = DecodeBase64(ui->signatureIn_VM->text().toStdString().c_str(), &fInvalid); + + if (fInvalid) + { + ui->signatureIn_VM->setValid(false); + ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_VM->setText(tr("The signature could not be decoded.") + QString(" ") + tr("Please check the signature and try again.")); + return; + } + + CDataStream ss(SER_GETHASH, 0); + ss << strMessageMagic; + ss << ui->messageIn_VM->document()->toPlainText().toStdString(); + + CPubKey pubkey; + if (!pubkey.RecoverCompact(Hash(ss.begin(), ss.end()), vchSig)) + { + ui->signatureIn_VM->setValid(false); + ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_VM->setText(tr("The signature did not match the message digest.") + QString(" ") + tr("Please check the signature and try again.")); + return; + } + + if (!(CBitcoinAddress(pubkey.GetID()) == addr)) + { + ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_VM->setText(QString("") + tr("Message verification failed.") + QString("")); + return; + } + + ui->statusLabel_VM->setStyleSheet("QLabel { color: green; }"); + ui->statusLabel_VM->setText(QString("") + tr("Message verified.") + QString("")); +} + +void SignVerifyMessageDialog::on_clearButton_VM_clicked() +{ + ui->addressIn_VM->clear(); + ui->signatureIn_VM->clear(); + ui->messageIn_VM->clear(); + ui->statusLabel_VM->clear(); + + ui->addressIn_VM->setFocus(); +} + +bool SignVerifyMessageDialog::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::FocusIn) + { + if (ui->tabWidget->currentIndex() == 0) + { + /* Clear status message on focus change */ + ui->statusLabel_SM->clear(); + + /* Select generated signature */ + if (object == ui->signatureOut_SM) + { + ui->signatureOut_SM->selectAll(); + return true; + } + } + else if (ui->tabWidget->currentIndex() == 1) + { + /* Clear status message on focus change */ + ui->statusLabel_VM->clear(); + } + } + return QDialog::eventFilter(object, event); +} diff --git a/src/qt/signverifymessagedialog.h b/src/qt/signverifymessagedialog.h new file mode 100644 index 0000000..a30081c --- /dev/null +++ b/src/qt/signverifymessagedialog.h @@ -0,0 +1,46 @@ +#ifndef SIGNVERIFYMESSAGEDIALOG_H +#define SIGNVERIFYMESSAGEDIALOG_H + +#include + +namespace Ui { + class SignVerifyMessageDialog; +} +class WalletModel; + +class SignVerifyMessageDialog : public QDialog +{ + Q_OBJECT + +public: + explicit SignVerifyMessageDialog(QWidget *parent = 0); + ~SignVerifyMessageDialog(); + + void setModel(WalletModel *model); + void setAddress_SM(QString address); + void setAddress_VM(QString address); + + void showTab_SM(bool fShow); + void showTab_VM(bool fShow); + +protected: + bool eventFilter(QObject *object, QEvent *event); + +private: + Ui::SignVerifyMessageDialog *ui; + WalletModel *model; + +private slots: + /* sign message */ + void on_addressBookButton_SM_clicked(); + void on_pasteButton_SM_clicked(); + void on_signMessageButton_SM_clicked(); + void on_copySignatureButton_SM_clicked(); + void on_clearButton_SM_clicked(); + /* verify message */ + void on_addressBookButton_VM_clicked(); + void on_verifyMessageButton_VM_clicked(); + void on_clearButton_VM_clicked(); +}; + +#endif // SIGNVERIFYMESSAGEDIALOG_H diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp new file mode 100644 index 0000000..af2d358 --- /dev/null +++ b/src/qt/test/test_main.cpp @@ -0,0 +1,16 @@ +#include +#include + +#include "uritests.h" + +// This is all you need to run all the tests +int main(int argc, char *argv[]) +{ + bool fInvalid = false; + + URITests test1; + if (QTest::qExec(&test1) != 0) + fInvalid = true; + + return fInvalid; +} diff --git a/src/qt/test/uritests.cpp b/src/qt/test/uritests.cpp new file mode 100644 index 0000000..26524b3 --- /dev/null +++ b/src/qt/test/uritests.cpp @@ -0,0 +1,62 @@ +#include "uritests.h" +#include "../guiutil.h" +#include "../walletmodel.h" + +#include + +void URITests::uriTests() +{ + SendCoinsRecipient rv; + QUrl uri; + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist=")); + QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); + + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist=")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); + QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); + QVERIFY(rv.label == QString()); + QVERIFY(rv.amount == 0); + + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); + QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); + QVERIFY(rv.label == QString("Wikipedia Example Address")); + QVERIFY(rv.amount == 0); + + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); + QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); + QVERIFY(rv.label == QString()); + QVERIFY(rv.amount == 100000); + + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); + QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); + QVERIFY(rv.label == QString()); + QVERIFY(rv.amount == 100100000); + + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); + QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); + QVERIFY(rv.amount == 10000000000LL); + QVERIFY(rv.label == QString("Wikipedia Example")); + + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); + QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); + QVERIFY(rv.label == QString()); + + QVERIFY(GUIUtil::parseBitcoinURI("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv)); + QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); + QVERIFY(rv.label == QString()); + + // We currently don't implement the message parameter (ok, yea, we break spec...) + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address")); + QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); + + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example")); + QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); + + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example")); + QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); +} diff --git a/src/qt/test/uritests.h b/src/qt/test/uritests.h new file mode 100644 index 0000000..d7a4f97 --- /dev/null +++ b/src/qt/test/uritests.h @@ -0,0 +1,15 @@ +#ifndef URITESTS_H +#define URITESTS_H + +#include +#include + +class URITests : public QObject +{ + Q_OBJECT + +private slots: + void uriTests(); +}; + +#endif // URITESTS_H diff --git a/src/qt/tradingdialog.cpp b/src/qt/tradingdialog.cpp new file mode 100644 index 0000000..7e78f36 --- /dev/null +++ b/src/qt/tradingdialog.cpp @@ -0,0 +1,1390 @@ +#include "tradingdialog.h" +#include "ui_tradingdialog.h" +#include "clientmodel.h" +#include "walletmodel.h" +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace std; + +tradingDialog::tradingDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::tradingDialog), + model(0) +{ + ui->setupUi(this); + timerid = 0; + qDebug() << "Expected this"; + + ui->BtcAvailableLabel->setTextFormat(Qt::RichText); + ui->SONOAvailableLabel->setTextFormat(Qt::RichText); + ui->BuyCostLabel->setTextFormat(Qt::RichText); + ui->SellCostLabel->setTextFormat(Qt::RichText); + ui->CryptopiaBTCLabel->setTextFormat(Qt::RichText); + ui->CryptopiaSONOLabel->setTextFormat(Qt::RichText); + ui->CSDumpLabel->setTextFormat(Qt::RichText); + ui->CSTotalLabel->setTextFormat(Qt::RichText); + ui->CSReceiveLabel->setTextFormat(Qt::RichText); + + //Set tabs to inactive + ui->TradingTabWidget->setTabEnabled(0,false); + ui->TradingTabWidget->setTabEnabled(1,false); + ui->TradingTabWidget->setTabEnabled(3,false); + ui->TradingTabWidget->setTabEnabled(4,false); + ui->TradingTabWidget->setTabEnabled(5,false); + + // Listen for keypress + connect(ui->PasswordInput, SIGNAL(returnPressed()),ui->LoadKeys,SIGNAL(clicked())); + + /*OrderBook Table Init*/ + CreateOrderBookTables(*ui->BidsTable,QStringList() << "SUM(BTC)" << "TOTAL(BTC)" << "SONO(SIZE)" << "BID(BTC)"); + CreateOrderBookTables(*ui->AsksTable,QStringList() << "ASK(BTC)" << "SONO(SIZE)" << "TOTAL(BTC)" << "SUM(BTC)"); + /*OrderBook Table Init*/ + + /*Market History Table Init*/ + ui->MarketHistoryTable->setColumnCount(5); + ui->MarketHistoryTable->verticalHeader()->setVisible(false); + ui->MarketHistoryTable->setHorizontalHeaderLabels(QStringList()<<"DATE"<<"BUY/SELL"<<"BID/ASK"<<"TOTAL UNITS(SONO)"<<"TOTAL COST(BTC"); + ui->MarketHistoryTable->setRowCount(0); + int Cellwidth = ui->MarketHistoryTable->width() / 5; + ui->MarketHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(4,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(5,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + ui->MarketHistoryTable->horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * {font-weight :bold;}"); + /*Market History Table Init*/ + + /*Account History Table Init*/ + ui->TradeHistoryTable->setColumnCount(9); + ui->TradeHistoryTable->verticalHeader()->setVisible(false); + ui->TradeHistoryTable->setHorizontalHeaderLabels(QStringList() << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Closed"); + ui->TradeHistoryTable->setRowCount(0); + Cellwidth = ui->TradeHistoryTable->width() / 9; + ui->TradeHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(4,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(5,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(6,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(7,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(8,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(9,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + ui->TradeHistoryTable->horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * {font-weight :bold;}"); + /*Account History Table Init*/ + + /*Open Orders Table*/ + ui->OpenOrdersTable->setColumnCount(10); + ui->OpenOrdersTable->verticalHeader()->setVisible(false); + ui->OpenOrdersTable->setHorizontalHeaderLabels(QStringList() << "OrderId" << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Cancel Order"); + ui->OpenOrdersTable->setRowCount(0); + Cellwidth = ui->TradeHistoryTable->width() / 9; + ui->OpenOrdersTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(2,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(3,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(4,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(5,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(6,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(7,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(8,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(9,Cellwidth); + ui->OpenOrdersTable->setColumnHidden(0,false); + ui->OpenOrdersTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + ui->OpenOrdersTable->horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * {font-weight :bold;}"); + + connect (ui->OpenOrdersTable, SIGNAL(cellClicked(int,int)), this, SLOT(CancelOrderSlot(int, int))); + /*Open Orders Table*/ +} + +void tradingDialog::InitTrading() +{ //todo - add internet connection/socket error checking. + + //Get default exchange info for the qlabels + UpdaterFunction(); + qDebug() << "Updater called"; + if(this->timerid == 0) + { + //Timer is not set,lets create one. + this->timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(UpdaterFunction())); + this->timer->start(5000); + this->timerid = this->timer->timerId(); + } + +} + +void tradingDialog::UpdaterFunction(){ + //SONOst get the main exchange info in order to populate qLabels in maindialog. then get data + //required for the current tab. + + int Retval = SetExchangeInfoTextLabels(); + + if (Retval == 0){ + ActionsOnSwitch(-1); + } +} + +QString tradingDialog::GetMarketSummary(){ + + QString Response = sendRequest("https://cryptopia.co.nz/api/GetMarket/SONO_BTC"); + return Response; +} + +QString tradingDialog::GetOrderBook(){ + + QString Response = sendRequest("https://cryptopia.co.nz/api/GetMarketOrders/SONO_BTC"); + return Response; +} + +QString tradingDialog::GetMarketHistory(){ + QString Response = sendRequest("https://cryptopia.co.nz/api/GetMarketHistory/SONO_BTC"); + return Response; +} + +QString tradingDialog::CancelOrder(QString OrderId){ + + QString URL = "https://cryptopia.co.nz/api/CancelTrade"; + URL += this->ApiKey; + URL += "&nonce=12345434&uuid="; + URL += OrderId; + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::BuySONO(QString OrderType, double Quantity, double Rate){ + + QString str = ""; + QString URL = "https://cryptopia.co.nz"; + URL += OrderType; + URL += "/api/SubmitTrade"; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-SONO&quantity="; + URL += str.number(Quantity,'i',8); + URL += "&rate="; + URL += str.number(Rate,'i',8); + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::SellSONO(QString OrderType, double Quantity, double Rate){ + + QString str = ""; + QString URL = "https://cryptopia.co.nz"; + URL += OrderType; + URL += "/api/GetMarket/SONO_BTC"; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-SONO&quantity="; + URL += str.number(Quantity,'i',8); + URL += "&rate="; + URL += str.number(Rate,'i',8); + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::Withdraw(double Amount, QString Address, QString Coin){ + + QString str = ""; + QString URL = "https://cryptopia.co.nz"; + URL += this->ApiKey; + URL += "/api/SubmitWithdraw"; + URL += Coin; + URL += "&quantity="; + URL += str.number(Amount,'i',8); + URL += "&address="; + URL += Address; + URL += "&nonce=12345434"; + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::GetOpenOrders(){ + QString URL = "https://cryptopia.co.nz/api/GetOpenOrders"; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-SONO"; + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::GetBalance(QString Currency){ + + QString URL = "https://cryptopia.co.nz/api/GetBalance"; + URL += this->ApiKey; + URL += "&nonce=12345434¤cy="; + URL += Currency; + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::GetDepositAddress(){ + + QString URL = "https://cryptopia.co.nz/api/GetDepositAddress"; + URL += this->ApiKey; + URL += "&nonce=12345434¤cy=SONO"; + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::GetAccountHistory(){ + + QString URL = "https://cryptopia.co.nz/api/GetTradeHistory"; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-SONO&count=10"; + + QString Response = sendRequest(URL); + return Response; +} + +int tradingDialog::SetExchangeInfoTextLabels(){ + //Get the current exchange information + information for the current open tab if required. + QString str = ""; + QString Response = GetMarketSummary(); + + //Set the labels, parse the json result to get values. + QJsonObject obj = GetResultObjectFromJSONArray(Response); + + //set labels to richtext to use css. + ui->Bid->setTextFormat(Qt::RichText); + ui->Ask->setTextFormat(Qt::RichText); + ui->volumet->setTextFormat(Qt::RichText); + ui->volumebtc->setTextFormat(Qt::RichText); + + ui->Ask->setText("Ask: " + str.number(obj["Ask"].toDouble(),'i',8) + " BTC"); + + ui->Bid->setText("Bid: " + str.number(obj["Bid"].toDouble(),'i',8) + " BTC"); + + ui->volumet->setText("SONO Volume: " + str.number(obj["Volume"].toDouble(),'i',8) + " SONO"); + + ui->volumebtc->setText("BTC Volume: " + str.number(obj["BaseVolume"].toDouble(),'i',8) + " BTC"); + + obj.empty(); + +return 0; + } + +void tradingDialog::CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader){ + + Table.setColumnCount(4); + Table.verticalHeader()->setVisible(false); + + Table.setHorizontalHeaderLabels(TableHeader); + + int Cellwidth = Table.width() / 4; + + Table.horizontalHeader()->resizeSection(1,Cellwidth); // column 1, width 50 + Table.horizontalHeader()->resizeSection(2,Cellwidth); + Table.horizontalHeader()->resizeSection(3,Cellwidth); + Table.horizontalHeader()->resizeSection(4,Cellwidth); + + Table.setRowCount(0); + + Table.horizontalHeader()->setResizeMode(QHeaderView::Stretch); + Table.horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + Table.horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * { font-weight :bold;}"); +} + +void tradingDialog::DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response){ + + QString str; + + BalanceLabel.setTextFormat(Qt::RichText); + Available.setTextFormat(Qt::RichText); + Pending.setTextFormat(Qt::RichText); + + //Set the labels, parse the json result to get values. + QJsonObject ResultObject = GetResultObjectFromJSONObject(Response); + + BalanceLabel.setText("" + str.number( ResultObject["Balance"].toDouble(),'i',8) + " " + Currency); + Available.setText("" + str.number( ResultObject["Available"].toDouble(),'i',8) + " " +Currency); + Pending.setText("" + str.number( ResultObject["Pending"].toDouble(),'i',8) + " " +Currency); +} + +void tradingDialog::DisplayBalance(QLabel &BalanceLabel, QString Response){ + + QString str; + + //Set the labels, parse the json result to get values. + QJsonObject ResultObject = GetResultObjectFromJSONObject(Response); + + BalanceLabel.setText("" + str.number(ResultObject["Available"].toDouble(),'i',8) + ""); +} + +void tradingDialog::DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2){ + + QString str; + QString str2; + + //Set the labels, parse the json result to get values. + QJsonObject ResultObject = GetResultObjectFromJSONObject(Response); + QJsonObject ResultObject2 = GetResultObjectFromJSONObject(Response2); + + BalanceLabel.setText("" + str.number(ResultObject["Available"].toDouble(),'i',8) + ""); + BalanceLabel2.setText("" + str2.number(ResultObject2["Available"].toDouble(),'i',8) + ""); +} + +void tradingDialog::ParseAndPopulateOpenOrdersTable(QString Response){ + + int itteration = 0, RowCount = 0; + + QJsonArray jsonArray = GetResultArrayFromJSONObject(Response); + QJsonObject obj; + + ui->OpenOrdersTable->setRowCount(0); + + foreach (const QJsonValue & value, jsonArray) + { + QString str = ""; + obj = value.toObject(); + + RowCount = ui->OpenOrdersTable->rowCount(); + + ui->OpenOrdersTable->insertRow(RowCount); + ui->OpenOrdersTable->setItem(itteration, 0, new QTableWidgetItem(obj["OrderUuid"].toString())); + ui->OpenOrdersTable->setItem(itteration, 1, new QTableWidgetItem(CryptopiaTimeStampToReadable(obj["Opened"].toString()))); + ui->OpenOrdersTable->setItem(itteration, 2, new QTableWidgetItem(obj["Exchange"].toString())); + ui->OpenOrdersTable->setItem(itteration, 3, new QTableWidgetItem(obj["OrderType"].toString())); + ui->OpenOrdersTable->setItem(itteration, 4, new QTableWidgetItem(str.number(obj["Limit"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 5, new QTableWidgetItem(str.number(obj["Quantity"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 6, new QTableWidgetItem(str.number(obj["QuantityRemaining"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 7, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 8, new QTableWidgetItem(str.number(obj["PricePerUnit"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 9, new QTableWidgetItem(tr("Cancel Order"))); + + //Handle the cancel link in open orders table + QTableWidgetItem* CancelCell; + CancelCell= ui->OpenOrdersTable->item(itteration, 9); //Set the wtablewidget item to the cancel cell item. + CancelCell->setForeground(QColor::fromRgb(255,0,0)); //make this item red. + CancelCell->setTextAlignment(Qt::AlignCenter); + itteration++; + } + obj.empty(); +} + + +void tradingDialog::CancelOrderSlot(int row, int col){ + + QString OrderId = ui->OpenOrdersTable->model()->data(ui->OpenOrdersTable->model()->index(row,0)).toString(); + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Cancel Order","Are you sure you want to cancel the order?",QMessageBox::Yes|QMessageBox::No); + + if (reply == QMessageBox::Yes) { + + QString Response = CancelOrder(OrderId); + + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); + QJsonObject ResponseObject = jsonResponse.object(); + + if (ResponseObject["success"].toBool() == false){ + + QMessageBox::information(this,"Failed To Cancel Order",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + ui->OpenOrdersTable->model()->removeRow(row); + QMessageBox::information(this,"Success","You're order was cancelled."); + } + } else { + qDebug() << "Do Nothing"; + } +} + +void tradingDialog::ParseAndPopulateAccountHistoryTable(QString Response){ + + int itteration = 0, RowCount = 0; + + QJsonArray jsonArray = GetResultArrayFromJSONObject(Response); + QJsonObject obj; + + ui->TradeHistoryTable->setRowCount(0); + + foreach (const QJsonValue & value, jsonArray) + { + QString str = ""; + obj = value.toObject(); + + RowCount = ui->TradeHistoryTable->rowCount(); + + ui->TradeHistoryTable->insertRow(RowCount); + ui->TradeHistoryTable->setItem(itteration, 0, new QTableWidgetItem(CryptopiaTimeStampToReadable(obj["TimeStamp"].toString()))); + ui->TradeHistoryTable->setItem(itteration, 1, new QTableWidgetItem(obj["Exchange"].toString())); + ui->TradeHistoryTable->setItem(itteration, 2, new QTableWidgetItem(obj["OrderType"].toString())); + ui->TradeHistoryTable->setItem(itteration, 3, new QTableWidgetItem(str.number(obj["Limit"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 4, new QTableWidgetItem(str.number(obj["Quantity"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 5, new QTableWidgetItem(str.number(obj["QuantityRemaining"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 6, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 7, new QTableWidgetItem(str.number(obj["PricePerUnit"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 8, new QTableWidgetItem(obj["Closed"].toString())); + itteration++; + } + + obj.empty(); +} + + +void tradingDialog::ParseAndPopulateOrderBookTables(QString OrderBook){ + + QString str; + QJsonObject obj; + QJsonObject ResultObject = GetResultObjectFromJSONObject(OrderBook); + + int BuyItteration = 0,SellItteration = 0, BidRows = 0, AskRows = 0; + + QJsonArray BuyArray = ResultObject.value("buy").toArray(); //get buy/sell object from result object + QJsonArray SellArray = ResultObject.value("sell").toArray(); //get buy/sell object from result object + + double SONOSupply = 0; + double SONODemand = 0; + double BtcSupply = 0; + double BtcDemand = 0; + + ui->AsksTable->setRowCount(0); + + foreach (const QJsonValue & value, SellArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + double a = (x * y); + + SONOSupply += y; + BtcSupply += a; + + AskRows = ui->AsksTable->rowCount(); + ui->AsksTable->insertRow(AskRows); + ui->AsksTable->setItem(SellItteration, 0, new QTableWidgetItem(str.number(x,'i',8))); + ui->AsksTable->setItem(SellItteration, 1, new QTableWidgetItem(str.number(y,'i',8))); + ui->AsksTable->setItem(SellItteration, 2, new QTableWidgetItem(str.number(a,'i',8))); + ui->AsksTable->setItem(SellItteration, 3, new QTableWidgetItem(str.number(BtcSupply,'i',8))); + SellItteration++; + } + + ui->BidsTable->setRowCount(0); + + foreach (const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + double a = (x * y); + + SONODemand += y; + BtcDemand += a; + + BidRows = ui->BidsTable->rowCount(); + ui->BidsTable->insertRow(BidRows); + ui->BidsTable->setItem(BuyItteration, 0, new QTableWidgetItem(str.number(BtcDemand,'i',8))); + ui->BidsTable->setItem(BuyItteration, 1, new QTableWidgetItem(str.number(a,'i',8))); + ui->BidsTable->setItem(BuyItteration, 2, new QTableWidgetItem(str.number(y,'i',8))); + ui->BidsTable->setItem(BuyItteration, 3, new QTableWidgetItem(str.number(x,'i',8))); + BuyItteration++; + } + + ui->SONOSupply->setText("Supply: " + str.number(SONOSupply,'i',8) + " SONO"); + ui->BtcSupply->setText("" + str.number(BtcSupply,'i',8) + " BTC"); + ui->AsksCount->setText("Ask's : " + str.number(ui->AsksTable->rowCount()) + ""); + + ui->SONODemand->setText("Demand: " + str.number(SONODemand,'i',8) + " SONO"); + ui->BtcDemand->setText("" + str.number(BtcDemand,'i',8) + " BTC"); + ui->BidsCount->setText("Bid's : " + str.number(ui->BidsTable->rowCount()) + ""); + obj.empty(); +} + + +void tradingDialog::ParseAndPopulateMarketHistoryTable(QString Response){ + + int itteration = 0, RowCount = 0; + QJsonArray jsonArray = GetResultArrayFromJSONObject(Response); + QJsonObject obj; + + ui->MarketHistoryTable->setRowCount(0); + + foreach (const QJsonValue & value, jsonArray) + { + QString str = ""; + obj = value.toObject(); + + RowCount = ui->MarketHistoryTable->rowCount(); + + ui->MarketHistoryTable->insertRow(RowCount); + ui->MarketHistoryTable->setItem(itteration, 0, new QTableWidgetItem(CryptopiaTimeStampToReadable(obj["TimeStamp"].toString()))); + ui->MarketHistoryTable->setItem(itteration, 1, new QTableWidgetItem(obj["OrderType"].toString())); + ui->MarketHistoryTable->setItem(itteration, 2, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); + ui->MarketHistoryTable->setItem(itteration, 3, new QTableWidgetItem(str.number(obj["Quantity"].toDouble(),'i',8))); + ui->MarketHistoryTable->setItem(itteration, 4, new QTableWidgetItem(str.number(obj["Total"].toDouble(),'i',8))); + ui->MarketHistoryTable->item(itteration,1)->setBackgroundColor((obj["OrderType"] == QStringLiteral("BUY")) ? (QColor (150, 191, 70,255)) : ( QColor (201, 119, 153,255))); + itteration++; + } + obj.empty(); +} + +void tradingDialog::ActionsOnSwitch(int index = -1){ + + QString Response = ""; + QString Response2 = ""; + QString Response3 = ""; + + if(index == -1){ + index = ui->TradingTabWidget->currentIndex(); + } + + switch (index){ + case 0: //buy tab is active + + Response = GetBalance("BTC"); + Response2 = GetBalance("SONO"); + Response3 = GetOrderBook(); + + if((Response.size() > 0 && Response != "Error") && (Response2.size() > 0 && Response2 != "Error")){ + DisplayBalance(*ui->BtcAvailableLabel, *ui->SONOAvailableLabel, Response, Response2); + } + if ((Response3.size() > 0 && Response3 != "Error")) { + ParseAndPopulateOrderBookTables(Response3); + } + + break; + + case 1: //Cross send tab active + Response = GetBalance("SONO"); + Response2 = GetBalance("BTC"); + if((Response.size() > 0 && Response != "Error") && (Response2.size() > 0 && Response2 != "Error")){ + DisplayBalance(*ui->CryptopiaSONOLabel, *ui->CryptopiaBTCLabel, Response, Response2); + } + + break; + + case 2://market history tab + Response = GetMarketHistory(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateMarketHistoryTable(Response); + } + break; + + case 3: //open orders tab + Response = GetOpenOrders(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateOpenOrdersTable(Response); + } + + break; + + case 4://account history tab + Response = GetAccountHistory(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateAccountHistoryTable(Response); + } + break; + + case 5://show balance tab + Response = GetBalance("BTC"); + if(Response.size() > 0 && Response != "Error"){ + DisplayBalance(*ui->BitcoinBalanceLabel,*ui->BitcoinAvailableLabel,*ui->BitcoinPendingLabel, QString::fromUtf8("BTC"),Response); + } + + Response = GetBalance("SONO"); + if(Response.size() > 0 && Response != "Error"){ + DisplayBalance(*ui->SONOBalanceLabel,*ui->SONOAvailableLabel_2,*ui->SONOPendingLabel, QString::fromUtf8("SONO"),Response); + } + break; + + case 6: + + break; + + } + +} + +void tradingDialog::on_TradingTabWidget_tabBarClicked(int index) +{ + //tab was clicked, interrupt the timer and restart after action completed. + + this->timer->stop(); + + ActionsOnSwitch(index); + + this->timer->start(); +} + + +QString tradingDialog::sendRequest(QString url){ + + QString Response = ""; + QString Secret = this->SecretKey; + + // create custom temporary event loop on stack + QEventLoop eventLoop; + + // "quit()" the event-loop, when the network request "finished()" + QNetworkAccessManager mgr; + QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit())); + + // the HTTP request + QNetworkRequest req = QNetworkRequest(QUrl(url)); + + req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); + + //make this conditional,depending if we are using private api call + req.setRawHeader("apisign",HMAC_SHA512_SIGNER(url,Secret).toStdString().c_str()); //set header for Cryptopia + + QNetworkReply *reply = mgr.get(req); + eventLoop.exec(); // blocks stack until "finished()" has been called + + if (reply->error() == QNetworkReply::NoError) { + //success + Response = reply->readAll(); + delete reply; + } + else{ + //failure + qDebug() << "Failure" <errorString(); + Response = "Error"; + //QMessageBox::information(this,"Error",reply->errorString()); + delete reply; + } + + return Response; +} + +QString tradingDialog::CryptopiaTimeStampToReadable(QString DateTime){ + //Seperate Time and date. + int TPos = DateTime.indexOf("T"); + int sPos = DateTime.indexOf("."); + QDateTime Date = QDateTime::fromString(DateTime.left(TPos),"yyyy-MM-dd"); //format to convert from + DateTime.remove(sPos,sizeof(DateTime)); + DateTime.remove(0,TPos+1); + QDateTime Time = QDateTime::fromString(DateTime.right(TPos),"hh:mm:ss"); + + //Reconstruct time and date in our own format, one that QDateTime will recognise. + QString DisplayDate = Date.toString("dd/MM/yyyy") + " " + Time.toString("hh:mm:ss A"); //formats to convert to + + return DisplayDate; +} + +void tradingDialog::CalculateBuyCostLabel(){ + + double price = ui->BuyBidPriceEdit->text().toDouble(); + double Quantity = ui->UnitsInput->text().toDouble(); + double cost = ((price * Quantity) + ((price * Quantity / 100) * 0.25)); + + QString Str = ""; + ui->BuyCostLabel->setText("" + Str.number(cost,'i',8) + ""); +} + +void tradingDialog::CalculateSellCostLabel(){ + + double price = ui->SellBidPriceEdit->text().toDouble(); + double Quantity = ui->UnitsInputSONO->text().toDouble(); + double cost = ((price * Quantity) - ((price * Quantity / 100) * 0.25)); + + QString Str = ""; + ui->SellCostLabel->setText("" + Str.number(cost,'i',8) + ""); +} + +void tradingDialog::CalculateCSReceiveLabel(){ + + //calculate amount of currency than can be transferred to bitcoin + QString balance = GetBalance("SONO"); + QString buyorders = GetOrderBook(); + + QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); + QJsonObject BalanceObject = GetResultObjectFromJSONObject(balance); + QJsonObject obj; + + double AvailableSONO = BalanceObject["Available"].toDouble(); + double Quantity = ui->CSUnitsInput->text().toDouble(); + double Received = 0; + double Qty = 0; + double Price = 0; + QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object + + // For each buy order + foreach (const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + // If + if ( ((Quantity / x) - y) > 0 ) + { + Price = x; + Received += ((Price * y) - ((Price * y / 100) * 0.25)); + Qty += y; + Quantity -= ((Price * y) - ((Price * y / 100) * 0.25)); + } else { + Price = x; + Received += ((Price * (Quantity / x)) - ((Price * (Quantity / x) / 100) * 0.25)); + Qty += (Quantity / x); + Quantity -= 0; + break; + } + } + + QString ReceiveStr = ""; + QString DumpStr = ""; + QString TotalStr = ""; + if ( Qty < AvailableSONO ) + { + ui->CSReceiveLabel->setText("" + ReceiveStr.number((ui->CSUnitsInput->text().toDouble() - 0.0002),'i',8) + ""); + ui->CSDumpLabel->setText("" + DumpStr.number(Price,'i',8) + ""); + ui->CSTotalLabel->setText("" + TotalStr.number(Qty,'i',8) + ""); + } else { + ReceiveStr = "N/A"; + TotalStr = "N/A"; + DumpStr = "N/A"; + ui->CSReceiveLabel->setText("" + ReceiveStr + ""); + ui->CSDumpLabel->setText("" + DumpStr + ""); + ui->CSTotalLabel->setText("" + TotalStr + ""); + } +} + +void tradingDialog::on_UpdateKeys_clicked(bool Save, bool Load) +{ + this->ApiKey = ui->ApiKeyInput->text(); + this->SecretKey = ui->SecretKeyInput->text(); + + QJsonDocument jsonResponse = QJsonDocument::fromJson(GetAccountHistory().toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if ( ResponseObject.value("success").toBool() == false){ + QMessageBox::information(this,"API Configuration Failed","Api configuration was unsuccesful."); + + }else if ( ResponseObject.value("success").toBool() == true && Load){ + QMessageBox::information(this,"API Configuration Complete","Your API keys have been loaded and the connection has been successfully configured and tested."); + ui->ApiKeyInput->setEchoMode(QLineEdit::Password); + ui->SecretKeyInput->setEchoMode(QLineEdit::Password); + ui->PasswordInput->setText(""); + ui->TradingTabWidget->setTabEnabled(0,true); + ui->TradingTabWidget->setTabEnabled(1,true); + ui->TradingTabWidget->setTabEnabled(3,true); + ui->TradingTabWidget->setTabEnabled(4,true); + ui->TradingTabWidget->setTabEnabled(5,true); + }else if ( ResponseObject.value("success").toBool() == true && Save){ + QMessageBox::information(this,"API Configuration Complete","Your API keys have been saved and the connection has been successfully configured and tested."); + ui->ApiKeyInput->setEchoMode(QLineEdit::Password); + ui->SecretKeyInput->setEchoMode(QLineEdit::Password); + ui->PasswordInput->setText(""); + ui->TradingTabWidget->setTabEnabled(0,true); + ui->TradingTabWidget->setTabEnabled(1,true); + ui->TradingTabWidget->setTabEnabled(3,true); + ui->TradingTabWidget->setTabEnabled(4,true); + ui->TradingTabWidget->setTabEnabled(5,true); + }else{ + QMessageBox::information(this,"API Configuration Complete","Api connection has been successfully configured and tested."); + ui->ApiKeyInput->setEchoMode(QLineEdit::Password); + ui->SecretKeyInput->setEchoMode(QLineEdit::Password); + ui->PasswordInput->setText(""); + ui->TradingTabWidget->setTabEnabled(0,true); + ui->TradingTabWidget->setTabEnabled(1,true); + ui->TradingTabWidget->setTabEnabled(3,true); + ui->TradingTabWidget->setTabEnabled(4,true); + ui->TradingTabWidget->setTabEnabled(5,true); + } + +} + +string tradingDialog::encryptDecrypt(string toEncrypt, string password) { + + char * key = new char [password.size()+1]; + std::strcpy (key, password.c_str()); + key[password.size()] = '\0'; // don't forget the terminating 0 + + string output = toEncrypt; + + for (unsigned int i = 0; i < toEncrypt.size(); i++) + output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; + return output; +} + +void tradingDialog::on_SaveKeys_clicked() +{ + bool fSuccess = true; + boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; + boost::filesystem::ofstream stream (pathConfigFile.string(), ios::out | ios::trunc); + + // Qstring to string + string password = ui->PasswordInput->text().toUtf8().constData(); + + if (password.length() <= 6){ + QMessageBox::information(this,"Error !","Your password is too short !"); + fSuccess = false; + stream.close(); + } + + // qstrings to utf8, add to byteArray and convert to const char for stream + string Secret = ui->SecretKeyInput->text().toUtf8().constData(); + string Key = ui->ApiKeyInput->text().toUtf8().constData(); + string ESecret = ""; + string EKey = ""; + + if (stream.is_open() && fSuccess) + { + ESecret = encryptDecrypt(Secret, password); + EKey = encryptDecrypt(Key, password); + stream << ESecret << '\n'; + stream << EKey; + stream.close(); + } + if (fSuccess) { + bool Save = true; + on_UpdateKeys_clicked(Save); + } + +} + +void tradingDialog::on_LoadKeys_clicked() +{ + bool fSuccess = true; + boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; + boost::filesystem::ifstream stream (pathConfigFile.string()); + + // Qstring to string + string password = ui->PasswordInput->text().toUtf8().constData(); + + if (password.length() <= 6){ + QMessageBox::information(this,"Error !","Your password is too short !"); + fSuccess = false; + stream.close(); + } + + QString DSecret = ""; + QString DKey = ""; + + if (stream.is_open() && fSuccess) + { + int i =0; + for ( std::string line; std::getline(stream,line); ) + { + if (i == 0 ){ + DSecret = QString::fromUtf8(encryptDecrypt(line, password).c_str()); + ui->SecretKeyInput->setText(DSecret); + } else if (i == 1){ + DKey = QString::fromUtf8(encryptDecrypt(line, password).c_str()); + ui->ApiKeyInput->setText(DKey); + } + i++; + } + stream.close(); + } + if (fSuccess) { + bool Save = false; + bool Load = true; + on_UpdateKeys_clicked(Save, Load); + } + +} + +void tradingDialog::on_GenDepositBTN_clicked() +{ + QString response = GetDepositAddress(); + QJsonObject ResultObject = GetResultObjectFromJSONObject(response); + ui->DepositAddressLabel->setText(ResultObject["Address"].toString()); +} + +void tradingDialog::on_Sell_Max_Amount_clicked() +{ + //calculate amount of BTC that can be gained from selling SONO available balance + QString responseA = GetBalance("SONO"); + QString str; + QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); + + double AvailableSONO = ResultObject["Available"].toDouble(); + + ui->UnitsInputSONO->setText(str.number(AvailableSONO,'i',8)); +} + +void tradingDialog::on_Buy_Max_Amount_clicked() +{ + //calculate amount of currency than can be brought with the BTC balance available + QString responseA = GetBalance("BTC"); + QString responseB = GetMarketSummary(); + QString str; + + QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); + QJsonObject ResultObj = GetResultObjectFromJSONArray(responseB); + + //Get the Bid ask or last value from combo + QString value = ui->BuyBidcomboBox->currentText(); + + double AvailableBTC = ResultObject["Available"].toDouble(); + double CurrentASK = ResultObj[value].toDouble(); + double Result = (AvailableBTC / CurrentASK); + double percentofnumber = (Result * 0.0025); + + Result = Result - percentofnumber; + ui->UnitsInput->setText(str.number(Result,'i',8)); +} + +void tradingDialog::on_CS_Max_Amount_clicked() +{ + double Quantity = ui->CryptopiaSONOLabel->text().toDouble(); + double Received = 0; + double Qty = 0; + double Price = 0; + QString buyorders = GetOrderBook(); + QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); + QJsonObject obj; + QString str; + + QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object + + // For each buy order + foreach (const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + // If + if ( (Quantity - y) > 0 ) + { + Price = x; + Received += ((Price * y) - ((Price * y / 100) * 0.25)); + Qty += y; + Quantity -= y; + + } else { + Price = x; + Received += ((Price * Quantity) - ((Price * Quantity / 100) * 0.25)); + Qty += Quantity; + + if ((Quantity * x) < 0.00055){ + Quantity = (0.00055 / x); + } + + break; + } + } + + ui->CSUnitsInput->setText(str.number(Received,'i',8)); +} + +void tradingDialog::on_Withdraw_Max_Amount_clicked() +{ + //calculate amount of currency than can be brought with the BTC balance available + QString responseA = GetBalance("SONO"); + QString str; + + QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); + + double AvailableSONO = ResultObject["Available"].toDouble(); + + ui->WithdrawUnitsInput->setText(str.number(AvailableSONO,'i',8)); +} + +QJsonObject tradingDialog::GetResultObjectFromJSONObject(QString response){ + + QJsonDocument jsonResponse = QJsonDocument::fromJson(response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + QJsonObject ResultObject = ResponseObject.value(QString("result")).toObject(); //get result object + + return ResultObject; +} + +QJsonObject tradingDialog::GetResultObjectFromJSONArray(QString response){ + + QJsonDocument jsonResponsea = QJsonDocument::fromJson(response.toUtf8()); + QJsonObject jsonObjecta = jsonResponsea.object(); + QJsonArray jsonArraya = jsonObjecta["result"].toArray(); + QJsonObject obj; + + foreach (const QJsonValue & value, jsonArraya) + { + obj = value.toObject(); + } + +return obj; +} + +QJsonArray tradingDialog::GetResultArrayFromJSONObject(QString response){ + + QJsonDocument jsonResponse = QJsonDocument::fromJson(response.toUtf8()); + QJsonObject jsonObject = jsonResponse.object(); + QJsonArray jsonArray = jsonObject["result"].toArray(); + +return jsonArray; +} + +QString tradingDialog::HMAC_SHA512_SIGNER(QString UrlToSign, QString Secret){ + + QString retval = ""; + + QByteArray byteArray = UrlToSign.toUtf8(); + const char* URL = byteArray.constData(); + + QByteArray byteArrayB = Secret.toUtf8(); + const char* Secretkey = byteArrayB.constData(); + + const EVP_MD *md = EVP_sha512(); + unsigned char* digest = NULL; + + // Using sha512 hash engine here. + digest = HMAC(md, Secretkey, strlen( Secretkey), (unsigned char*) URL, strlen( URL), NULL, NULL); + + // Be careful of the length of string with the choosen hash engine. SHA1 produces a 20-byte hash value which rendered as 40 characters. + // Change the length accordingly with your choosen hash engine + char mdString[129] = { 0 }; + + for(int i = 0; i < 64; i++){ + sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]); + } + retval = mdString; + //qDebug() << "HMAC digest:"<< retval; + + return retval; +} + +void tradingDialog::on_SellBidcomboBox_currentIndexChanged(const QString &arg1) +{ + QString response = GetMarketSummary(); + QJsonObject ResultObject = GetResultObjectFromJSONArray(response); + QString Str; + + //Get the Bid ask or last value from combo + ui->SellBidPriceEdit->setText(Str.number(ResultObject[arg1].toDouble(),'i',8)); + + CalculateSellCostLabel(); //update cost +} + +void tradingDialog::on_BuyBidcomboBox_currentIndexChanged(const QString &arg1) +{ + QString response = GetMarketSummary(); + QJsonObject ResultObject = GetResultObjectFromJSONArray(response); + QString Str; + + //Get the Bid ask or last value from combo + ui->BuyBidPriceEdit->setText(Str.number(ResultObject[arg1].toDouble(),'i',8)); + + CalculateBuyCostLabel(); //update cost +} + +void tradingDialog::on_BuySONO_clicked() +{ + double Rate; + double Quantity; + + Rate = ui->BuyBidPriceEdit->text().toDouble(); + Quantity = ui->UnitsInput->text().toDouble(); + + QString OrderType = "Limit"; + QString Order; + + if(OrderType == "Limit"){Order = "buylimit";}else if (OrderType == "Market"){ Order = "buymarket";} + + QString Msg = "Are you sure you want to buy "; + Msg += ui->UnitsInput->text(); + Msg += "SONO @ "; + Msg += ui->BuyBidPriceEdit->text(); + Msg += " BTC Each"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Buy Order",Msg,QMessageBox::Yes|QMessageBox::No); + + if (reply == QMessageBox::Yes) { + + QString Response = BuySONO(Order,Quantity,Rate); + + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Buy Order Failed",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Buy Order Initiated","You Placed an order"); + } + }else{ + //do nothing + } +} + +void tradingDialog::on_SellSONOBTN_clicked() +{ + double Rate; + double Quantity; + + Rate = ui->SellBidPriceEdit->text().toDouble(); + Quantity = ui->UnitsInputSONO->text().toDouble(); + + QString OrderType = "Limit"; + QString Order; + + if(OrderType == "Limit"){Order = "selllimit";}else if (OrderType == "Market"){ Order = "sellmarket";} + + QString Msg = "Are you sure you want to Sell "; + Msg += ui->UnitsInputSONO->text(); + Msg += " SONO @ "; + Msg += ui->SellBidPriceEdit->text(); + Msg += " BTC Each"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Sell Order",Msg,QMessageBox::Yes|QMessageBox::No); + + if (reply == QMessageBox::Yes) { + + QString Response = SellSONO(Order,Quantity,Rate); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Sell Order Failed",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Sell Order Initiated","You Placed an order"); + } + }else{ + //do nothing + } +} + +void tradingDialog::on_CSUnitsBtn_clicked() +{ + double Quantity = ui->CSUnitsInput->text().toDouble(); + double Rate = ui->CSDumpLabel->text().toDouble(); + double Received = 0; + double Qty = 0; + double Price = 0; + double Add = 0; + + QString buyorders = GetOrderBook(); + QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); + QJsonObject obj; + QString Astr; + QString Qstr; + QString Rstr; + QString Coin = "BTC"; + QString Msg = "Are you sure you want to Send "; + Msg += Qstr.number((Quantity - 0.0002),'i',8); + Msg += " BTC to "; + Msg += ui->CSUnitsAddress->text(); + Msg += ", DUMPING your coins at "; + Msg += Rstr.number(Rate,'i',8); + Msg += " satoshis ?"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Cross-Send",Msg,QMessageBox::Yes|QMessageBox::No); + + if(reply != QMessageBox::Yes) + { + return; + } + + WalletModel::UnlockContext ctx(model->requestUnlock()); + if(!ctx.isValid()) + { + // Unlock wallet was cancelled + return; + } + + QString Order = "selllimit"; + QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object + + // For each buy order + foreach (const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + // If + if ( ((Quantity / x) - y) > 0 ) + { + Price = x; + Received += ((Price * y) - ((Price * y / 100) * 0.25)); + Qty += y; + Quantity -= ((Price * y) - ((Price * y / 100) * 0.25)); + + QString SellResponse = SellSONO(Order,y,x); + QJsonDocument SelljsonResponse = QJsonDocument::fromJson(SellResponse.toUtf8()); //get json from str. + QJsonObject SellResponseObject = SelljsonResponse.object(); //get json obj + + if (SellResponseObject["success"].toBool() == false){ + if (SellResponseObject["message"].toString() == "DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT"){ + Add += y; + continue; + } + QMessageBox::information(this,"sFailed",SellResponse); + break; + } + MilliSleep(100); + + } else { + Price = x; + Received += ((Price * (Quantity / x)) - ((Price * (Quantity / x) / 100) * 0.25)); + Qty += (Quantity / x); + if (Add > 0) + Quantity += (Add * x); + if (Quantity < 0.00051){ + Quantity = 0.00051; + } + QString SellResponse = SellSONO(Order,(Quantity / x),x); + QJsonDocument SelljsonResponse = QJsonDocument::fromJson(SellResponse.toUtf8()); //get json from str. + QJsonObject SellResponseObject = SelljsonResponse.object(); //get json obj + + if (SellResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"sFailed",SellResponse); + + } else if (SellResponseObject["success"].toBool() == true){ + MilliSleep(5000); + QString Response = Withdraw(ui->CSUnitsInput->text().toDouble(),ui->CSUnitsAddress->text(),Coin); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + MilliSleep(5000); + QString Response = Withdraw(ui->CSUnitsInput->text().toDouble(),ui->CSUnitsAddress->text(),Coin); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Failed",ResponseObject["message"].toString()); + } else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Success","
Cross-Send Successful
\n Sold "+Astr.number(Qty,'i',4)+" SONO for "+Qstr.number((ui->CSUnitsInput->text().toDouble()-0.0002),'i',8)+" BTC"); + } + } else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Success","
Cross-Send Successful
\n Sold "+Astr.number(Qty,'i',4)+" SONO for "+Qstr.number((ui->CSUnitsInput->text().toDouble()-0.0002),'i',8)+" BTC"); + } + } + break; + } + } +} + +void tradingDialog::on_WithdrawUnitsBtn_clicked() +{ + double Quantity = ui->WithdrawUnitsInput->text().toDouble(); + QString Qstr; + QString Coin = "SONO"; + QString Msg = "Are you sure you want to Withdraw "; + Msg += Qstr.number((Quantity - 0.02),'i',8); + Msg += " SONO to "; + Msg += ui->WithdrawAddress->text(); + Msg += " ?"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Withdraw",Msg,QMessageBox::Yes|QMessageBox::No); + + if(reply != QMessageBox::Yes) + { + return; + } + + WalletModel::UnlockContext ctx(model->requestUnlock()); + if(!ctx.isValid()) + { + // Unlock wallet was cancelled + return; + } + + QString Response = Withdraw(Quantity, ui->WithdrawAddress->text(), Coin); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Failed",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Success","Withdrawal Successful !"); + } +} + +void tradingDialog::on_UnitsInputSONO_textChanged(const QString &arg1) +{ + CalculateSellCostLabel(); //update cost +} + +void tradingDialog::on_UnitsInput_textChanged(const QString &arg1) +{ + CalculateBuyCostLabel(); //update cost +} + +void tradingDialog::on_BuyBidPriceEdit_textChanged(const QString &arg1) +{ + CalculateBuyCostLabel(); //update cost +} + +void tradingDialog::on_SellBidPriceEdit_textChanged(const QString &arg1) +{ + CalculateSellCostLabel(); +} + +void tradingDialog::on_CSUnitsInput_textChanged(const QString &arg1) +{ + CalculateCSReceiveLabel(); //update cost +} + +void tradingDialog::on_CSPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->CSUnitsAddress->setText(QApplication::clipboard()->text()); +} + +void tradingDialog::on_WithdrawPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->WithdrawAddress->setText(QApplication::clipboard()->text()); +} + +void tradingDialog::on_SecretPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->SecretKeyInput->setText(QApplication::clipboard()->text()); +} + +void tradingDialog::on_KeyPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->ApiKeyInput->setText(QApplication::clipboard()->text()); +} + +void setClipboard(const QString& str) +{ + QApplication::clipboard()->setText(str, QClipboard::Clipboard); + QApplication::clipboard()->setText(str, QClipboard::Selection); +} + +void tradingDialog::on_DepositCopyButton_clicked() +{ + setClipboard(ui->DepositAddressLabel->text()); +} + +void tradingDialog::setModel(WalletModel *model) +{ + this->model = model; +} + +tradingDialog::~tradingDialog() +{ + delete ui; +} diff --git a/src/qt/tradingdialog.h b/src/qt/tradingdialog.h new file mode 100644 index 0000000..8508ca2 --- /dev/null +++ b/src/qt/tradingdialog.h @@ -0,0 +1,117 @@ + +#ifndef TRADINGDIALOG_H +#define TRADINGDIALOG_H + +#include +#include +#include +#include "ui_tradingdialog.h" +#include "clientmodel.h" +#include "walletmodel.h" + +#include +#include + +#include +#include + +namespace Ui { +class tradingDialog; +} +class WalletModel; + +class tradingDialog : public QDialog +{ + Q_OBJECT + +public: + explicit tradingDialog(QWidget *parent = 0); + ~tradingDialog(); + + void setModel(WalletModel *model); + +private slots: + + void InitTrading(); + void on_TradingTabWidget_tabBarClicked(int index); + void ParseAndPopulateOrderBookTables(QString Response); + void ParseAndPopulateMarketHistoryTable(QString Response); + void ParseAndPopulateAccountHistoryTable(QString Response); + void ParseAndPopulateOpenOrdersTable(QString Response); + void UpdaterFunction(); + void CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader); + void DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response); + void DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2); + void DisplayBalance(QLabel &BalanceLabel, QString Response); + void ActionsOnSwitch(int index); + void CancelOrderSlot(int row, int col); + void on_UpdateKeys_clicked(bool Save=true, bool Load=true); + void on_LoadKeys_clicked(); + void on_SaveKeys_clicked(); + void on_GenDepositBTN_clicked(); + + void CalculateBuyCostLabel(); + void on_Buy_Max_Amount_clicked(); + void on_BuyBidcomboBox_currentIndexChanged(const QString &arg1); + void on_UnitsInput_textChanged(const QString &arg1); + void on_BuyBidPriceEdit_textChanged(const QString &arg1); + void on_BuySONO_clicked(); + + void CalculateSellCostLabel(); + void on_Sell_Max_Amount_clicked(); + void on_SellBidcomboBox_currentIndexChanged(const QString &arg1); + void on_UnitsInputSONO_textChanged(const QString &arg1); + void on_SellBidPriceEdit_textChanged(const QString &arg1); + void on_SellSONOBTN_clicked(); + + void CalculateCSReceiveLabel(); + void on_CSUnitsInput_textChanged(const QString &arg1); + void on_CSUnitsBtn_clicked(); + void on_CS_Max_Amount_clicked(); + + void on_Withdraw_Max_Amount_clicked(); + void on_WithdrawUnitsBtn_clicked(); + + void on_KeyPasteButton_clicked(); + void on_SecretPasteButton_clicked(); + void on_CSPasteButton_clicked(); + void on_WithdrawPasteButton_clicked(); + void on_DepositCopyButton_clicked(); + + int SetExchangeInfoTextLabels(); + + QString CryptopiaTimeStampToReadable(QString DateTime); + QString CancelOrder(QString Orderid); + QString BuySONO(QString OrderType, double Quantity, double Rate); + QString SellSONO(QString OrderType, double Quantity, double Rate); + QString Withdraw(double Amount, QString Address, QString Coin); + QString GetMarketHistory(); + QString GetMarketSummary(); + QString GetOrderBook(); + QString GetOpenOrders(); + QString GetAccountHistory(); + QString GetBalance(QString Currency); + QString GetDepositAddress(); + QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); + QString sendRequest(QString url); + string encryptDecrypt(string toEncrypt, string password); + QJsonObject GetResultObjectFromJSONObject(QString response); + QJsonObject GetResultObjectFromJSONArray(QString response); + QJsonArray GetResultArrayFromJSONObject(QString response); + +public slots: + + +private: + Ui::tradingDialog *ui; + //Socket *socket; + int timerid; + QTimer *timer; + QString ApiKey; + QString SecretKey; + WalletModel *model; + + +}; + +#endif // TRADINGDIALOG_H diff --git a/src/qt/trafficgraphwidget.cpp b/src/qt/trafficgraphwidget.cpp new file mode 100644 index 0000000..ad465e8 --- /dev/null +++ b/src/qt/trafficgraphwidget.cpp @@ -0,0 +1,169 @@ +#include "trafficgraphwidget.h" +#include "clientmodel.h" + +#include +#include +#include + +#include + +#define DESIRED_SAMPLES 800 + +#define XMARGIN 10 +#define YMARGIN 10 + +TrafficGraphWidget::TrafficGraphWidget(QWidget *parent) : + QWidget(parent), + timer(0), + fMax(0.0f), + nMins(0), + vSamplesIn(), + vSamplesOut(), + nLastBytesIn(0), + nLastBytesOut(0), + clientModel(0) +{ + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), SLOT(updateRates())); +} + +void TrafficGraphWidget::setClientModel(ClientModel *model) +{ + clientModel = model; + if(model) { + nLastBytesIn = model->getTotalBytesRecv(); + nLastBytesOut = model->getTotalBytesSent(); + } +} + +int TrafficGraphWidget::getGraphRangeMins() const +{ + return nMins; +} + +void TrafficGraphWidget::paintPath(QPainterPath &path, QQueue &samples) +{ + int h = height() - YMARGIN * 2, w = width() - XMARGIN * 2; + int sampleCount = samples.size(), x = XMARGIN + w, y; + if(sampleCount > 0) { + path.moveTo(x, YMARGIN + h); + for(int i = 0; i < sampleCount; ++i) { + x = XMARGIN + w - w * i / DESIRED_SAMPLES; + y = YMARGIN + h - (int)(h * samples.at(i) / fMax); + path.lineTo(x, y); + } + path.lineTo(x, YMARGIN + h); + } +} + +void TrafficGraphWidget::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.fillRect(rect(), Qt::black); + + if(fMax <= 0.0f) return; + + QColor axisCol(Qt::gray); + int h = height() - YMARGIN * 2; + painter.setPen(axisCol); + painter.drawLine(XMARGIN, YMARGIN + h, width() - XMARGIN, YMARGIN + h); + + // decide what order of magnitude we are + int base = floor(log10(fMax)); + float val = pow(10.0f, base); + + const QString units = tr("KB/s"); + // draw lines + painter.setPen(axisCol); + painter.drawText(XMARGIN, YMARGIN + h - h * val / fMax, QString("%1 %2").arg(val).arg(units)); + for(float y = val; y < fMax; y += val) { + int yy = YMARGIN + h - h * y / fMax; + painter.drawLine(XMARGIN, yy, width() - XMARGIN, yy); + } + // if we drew 3 or fewer lines, break them up at the next lower order of magnitude + if(fMax / val <= 3.0f) { + axisCol = axisCol.darker(); + val = pow(10.0f, base - 1); + painter.setPen(axisCol); + painter.drawText(XMARGIN, YMARGIN + h - h * val / fMax, QString("%1 %2").arg(val).arg(units)); + int count = 1; + for(float y = val; y < fMax; y += val, count++) { + // don't overwrite lines drawn above + if(count % 10 == 0) + continue; + int yy = YMARGIN + h - h * y / fMax; + painter.drawLine(XMARGIN, yy, width() - XMARGIN, yy); + } + } + + if(!vSamplesIn.empty()) { + QPainterPath p; + paintPath(p, vSamplesIn); + painter.fillPath(p, QColor(0, 255, 0, 128)); + painter.setPen(Qt::green); + painter.drawPath(p); + } + if(!vSamplesOut.empty()) { + QPainterPath p; + paintPath(p, vSamplesOut); + painter.fillPath(p, QColor(255, 0, 0, 128)); + painter.setPen(Qt::red); + painter.drawPath(p); + } +} + +void TrafficGraphWidget::updateRates() +{ + if(!clientModel) return; + + quint64 bytesIn = clientModel->getTotalBytesRecv(), + bytesOut = clientModel->getTotalBytesSent(); + float inRate = (bytesIn - nLastBytesIn) / 1024.0f * 1000 / timer->interval(); + float outRate = (bytesOut - nLastBytesOut) / 1024.0f * 1000 / timer->interval(); + vSamplesIn.push_front(inRate); + vSamplesOut.push_front(outRate); + nLastBytesIn = bytesIn; + nLastBytesOut = bytesOut; + + while(vSamplesIn.size() > DESIRED_SAMPLES) { + vSamplesIn.pop_back(); + } + while(vSamplesOut.size() > DESIRED_SAMPLES) { + vSamplesOut.pop_back(); + } + + float tmax = 0.0f; + foreach(float f, vSamplesIn) { + if(f > tmax) tmax = f; + } + foreach(float f, vSamplesOut) { + if(f > tmax) tmax = f; + } + fMax = tmax; + update(); +} + +void TrafficGraphWidget::setGraphRangeMins(int mins) +{ + nMins = mins; + int msecsPerSample = nMins * 60 * 1000 / DESIRED_SAMPLES; + timer->stop(); + timer->setInterval(msecsPerSample); + + clear(); +} + +void TrafficGraphWidget::clear() +{ + timer->stop(); + + vSamplesOut.clear(); + vSamplesIn.clear(); + fMax = 0.0f; + + if(clientModel) { + nLastBytesIn = clientModel->getTotalBytesRecv(); + nLastBytesOut = clientModel->getTotalBytesSent(); + } + timer->start(); +} diff --git a/src/qt/trafficgraphwidget.h b/src/qt/trafficgraphwidget.h new file mode 100644 index 0000000..40d7a82 --- /dev/null +++ b/src/qt/trafficgraphwidget.h @@ -0,0 +1,44 @@ +#ifndef TRAFFICGRAPHWIDGET_H +#define TRAFFICGRAPHWIDGET_H + +#include +#include + +class ClientModel; + +QT_BEGIN_NAMESPACE +class QPaintEvent; +class QTimer; +QT_END_NAMESPACE + +class TrafficGraphWidget : public QWidget +{ + Q_OBJECT + +public: + explicit TrafficGraphWidget(QWidget *parent = 0); + void setClientModel(ClientModel *model); + int getGraphRangeMins() const; + +protected: + void paintEvent(QPaintEvent *); + +public slots: + void updateRates(); + void setGraphRangeMins(int mins); + void clear(); + +private: + void paintPath(QPainterPath &path, QQueue &samples); + + QTimer *timer; + float fMax; + int nMins; + QQueue vSamplesIn; + QQueue vSamplesOut; + quint64 nLastBytesIn; + quint64 nLastBytesOut; + ClientModel *clientModel; +}; + +#endif // TRAFFICGRAPHWIDGET_H diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp new file mode 100644 index 0000000..5a21218 --- /dev/null +++ b/src/qt/transactiondesc.cpp @@ -0,0 +1,271 @@ +#include "transactiondesc.h" + +#include "bitcoinunits.h" +#include "guiutil.h" + +#include "base58.h" +#include "main.h" +#include "paymentserver.h" +#include "transactionrecord.h" +#include "timedata.h" +#include "ui_interface.h" +#include "wallet.h" +#include "txdb.h" + +#include + +QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx) +{ + AssertLockHeld(cs_main); + if (!IsFinalTx(wtx, nBestHeight + 1)) + { + if (wtx.nLockTime < LOCKTIME_THRESHOLD) + return tr("Open for %n more block(s)", "", wtx.nLockTime - nBestHeight); + else + return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.nLockTime)); + } + else + { + int nDepth = wtx.GetDepthInMainChain(); + if (nDepth < 0) + return tr("conflicted"); + else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) + return tr("%1/offline").arg(nDepth); + else if (nDepth < 10) + return tr("%1/unconfirmed").arg(nDepth); + else + return tr("%1 confirmations").arg(nDepth); + } +} + +QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionRecord *rec, int unit) +{ + QString strHTML; + + LOCK2(cs_main, wallet->cs_wallet); + strHTML.reserve(4000); + strHTML += ""; + + int64_t nTime = wtx.GetTxTime(); + int64_t nCredit = wtx.GetCredit(); + int64_t nDebit = wtx.GetDebit(); + int64_t nNet = nCredit - nDebit; + + strHTML += "" + tr("Status") + ": " + FormatTxStatus(wtx); + int nRequests = wtx.GetRequestCount(); + if (nRequests != -1) + { + if (nRequests == 0) + strHTML += tr(", has not been successfully broadcast yet"); + else if (nRequests > 0) + strHTML += tr(", broadcast through %n node(s)", "", nRequests); + } + strHTML += "
"; + + strHTML += "" + tr("Date") + ": " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "
"; + + // + // From + // + if (wtx.IsCoinBase() || wtx.IsCoinStake()) + { + strHTML += "" + tr("Source") + ": " + tr("Generated") + "
"; + } + else if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty()) + { + // Online transaction + strHTML += "" + tr("From") + ": " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "
"; + } + else + { + // Offline transaction + if (nNet > 0) + { + // Credit + if (CBitcoinAddress(rec->address).IsValid()) + { + CTxDestination address = CBitcoinAddress(rec->address).Get(); + if (wallet->mapAddressBook.count(address)) + { + strHTML += "" + tr("From") + ": " + tr("unknown") + "
"; + strHTML += "" + tr("To") + ": "; + strHTML += GUIUtil::HtmlEscape(rec->address); + if (!wallet->mapAddressBook[address].empty()) + strHTML += " (" + tr("own address") + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + ")"; + else + strHTML += " (" + tr("own address") + ")"; + strHTML += "
"; + } + } + } + } + + // + // To + // + if (wtx.mapValue.count("to") && !wtx.mapValue["to"].empty()) + { + // Online transaction + std::string strAddress = wtx.mapValue["to"]; + strHTML += "" + tr("To") + ": "; + CTxDestination dest = CBitcoinAddress(strAddress).Get(); + if (wallet->mapAddressBook.count(dest) && !wallet->mapAddressBook[dest].empty()) + strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[dest]) + " "; + strHTML += GUIUtil::HtmlEscape(strAddress) + "
"; + } + + // + // Amount + // + if (wtx.IsCoinBase() && nCredit == 0) + { + // + // Coinbase + // + int64_t nUnmatured = 0; + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + nUnmatured += wallet->GetCredit(txout); + strHTML += "" + tr("Credit") + ": "; + if (wtx.IsInMainChain()) + strHTML += BitcoinUnits::formatWithUnit(unit, nUnmatured)+ " (" + tr("matures in %n more block(s)", "", wtx.GetBlocksToMaturity()) + ")"; + else + strHTML += "(" + tr("not accepted") + ")"; + strHTML += "
"; + } + else if (nNet > 0) + { + // + // Credit + // + strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatWithUnit(unit, nNet) + "
"; + } + else + { + bool fAllFromMe = true; + BOOST_FOREACH(const CTxIn& txin, wtx.vin) + fAllFromMe = fAllFromMe && wallet->IsMine(txin); + + bool fAllToMe = true; + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + fAllToMe = fAllToMe && wallet->IsMine(txout); + + if (fAllFromMe) + { + // + // Debit + // + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + { + if (wallet->IsMine(txout)) + continue; + + if (!wtx.mapValue.count("to") || wtx.mapValue["to"].empty()) + { + // Offline transaction + CTxDestination address; + if (ExtractDestination(txout.scriptPubKey, address)) + { + strHTML += "" + tr("To") + ": "; + if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty()) + strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + " "; + strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString()); + strHTML += "
"; + } + } + + strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatWithUnit(unit, -txout.nValue) + "
"; + } + + if (fAllToMe) + { + // Payment to self + int64_t nChange = wtx.GetChange(); + int64_t nValue = nCredit - nChange; + strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatWithUnit(unit, -nValue) + "
"; + strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatWithUnit(unit, nValue) + "
"; + } + + int64_t nTxFee = nDebit - wtx.GetValueOut(); + if (nTxFee > 0) + strHTML += "" + tr("Transaction fee") + ": " + BitcoinUnits::formatWithUnit(unit, -nTxFee) + "
"; + } + else + { + // + // Mixed debit transaction + // + BOOST_FOREACH(const CTxIn& txin, wtx.vin) + if (wallet->IsMine(txin)) + strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatWithUnit(unit, -wallet->GetDebit(txin)) + "
"; + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + if (wallet->IsMine(txout)) + strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatWithUnit(unit, wallet->GetCredit(txout)) + "
"; + } + } + + strHTML += "" + tr("Net amount") + ": " + BitcoinUnits::formatWithUnit(unit, nNet, true) + "
"; + + // + // Message + // + if (wtx.mapValue.count("message") && !wtx.mapValue["message"].empty()) + strHTML += "
" + tr("Message") + ":
" + GUIUtil::HtmlEscape(wtx.mapValue["message"], true) + "
"; + if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty()) + strHTML += "
" + tr("Comment") + ":
" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "
"; + + strHTML += "" + tr("Transaction ID") + ": " + TransactionRecord::formatSubTxId(wtx.GetHash(), rec->idx) + "
"; + + if (wtx.IsCoinBase() || wtx.IsCoinStake()) + strHTML += "
" + tr("Generated coins must mature 188 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \"not accepted\" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "
"; + + // + // Debug view + // + if (fDebug) + { + strHTML += "

" + tr("Debug information") + "

"; + BOOST_FOREACH(const CTxIn& txin, wtx.vin) + if(wallet->IsMine(txin)) + strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatWithUnit(unit, -wallet->GetDebit(txin)) + "
"; + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + if(wallet->IsMine(txout)) + strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatWithUnit(unit, wallet->GetCredit(txout)) + "
"; + + strHTML += "
" + tr("Transaction") + ":
"; + strHTML += GUIUtil::HtmlEscape(wtx.ToString(), true); + + CTxDB txdb("r"); // To fetch source txouts + + strHTML += "
" + tr("Inputs") + ":"; + strHTML += "
    "; + + BOOST_FOREACH(const CTxIn& txin, wtx.vin) + { + COutPoint prevout = txin.prevout; + + CTransaction prev; + if(txdb.ReadDiskTx(prevout.hash, prev)) + { + if (prevout.n < prev.vout.size()) + { + strHTML += "
  • "; + const CTxOut &vout = prev.vout[prevout.n]; + CTxDestination address; + if (ExtractDestination(vout.scriptPubKey, address)) + { + if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty()) + strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + " "; + strHTML += QString::fromStdString(CBitcoinAddress(address).ToString()); + } + strHTML = strHTML + " " + tr("Amount") + "=" + BitcoinUnits::formatWithUnit(unit, vout.nValue); + strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) ? tr("true") : tr("false")) + "
  • "; + } + } + } + + strHTML += "
"; + } + + strHTML += "
"; + return strHTML; +} diff --git a/src/qt/transactiondesc.h b/src/qt/transactiondesc.h new file mode 100644 index 0000000..ae7ed5a --- /dev/null +++ b/src/qt/transactiondesc.h @@ -0,0 +1,26 @@ +#ifndef TRANSACTIONDESC_H +#define TRANSACTIONDESC_H + +#include +#include + +class TransactionRecord; +class CWallet; +class CWalletTx; + +/** Provide a human-readable extended HTML description of a transaction. + */ +class TransactionDesc: public QObject +{ + Q_OBJECT + +public: + static QString toHTML(CWallet *wallet, CWalletTx &wtx, TransactionRecord *rec, int unit); + +private: + TransactionDesc() {} + + static QString FormatTxStatus(const CWalletTx& wtx); +}; + +#endif // TRANSACTIONDESC_H diff --git a/src/qt/transactiondescdialog.cpp b/src/qt/transactiondescdialog.cpp new file mode 100644 index 0000000..48ee32c --- /dev/null +++ b/src/qt/transactiondescdialog.cpp @@ -0,0 +1,20 @@ +#include "transactiondescdialog.h" +#include "ui_transactiondescdialog.h" + +#include "transactiontablemodel.h" + +#include + +TransactionDescDialog::TransactionDescDialog(const QModelIndex &idx, QWidget *parent) : + QDialog(parent), + ui(new Ui::TransactionDescDialog) +{ + ui->setupUi(this); + QString desc = idx.data(TransactionTableModel::LongDescriptionRole).toString(); + ui->detailText->setHtml(desc); +} + +TransactionDescDialog::~TransactionDescDialog() +{ + delete ui; +} diff --git a/src/qt/transactiondescdialog.h b/src/qt/transactiondescdialog.h new file mode 100644 index 0000000..c89fc98 --- /dev/null +++ b/src/qt/transactiondescdialog.h @@ -0,0 +1,27 @@ +#ifndef TRANSACTIONDESCDIALOG_H +#define TRANSACTIONDESCDIALOG_H + +#include + +namespace Ui { + class TransactionDescDialog; +} + +QT_BEGIN_NAMESPACE +class QModelIndex; +QT_END_NAMESPACE + +/** Dialog showing transaction details. */ +class TransactionDescDialog : public QDialog +{ + Q_OBJECT + +public: + explicit TransactionDescDialog(const QModelIndex &idx, QWidget *parent = 0); + ~TransactionDescDialog(); + +private: + Ui::TransactionDescDialog *ui; +}; + +#endif // TRANSACTIONDESCDIALOG_H diff --git a/src/qt/transactionfilterproxy.cpp b/src/qt/transactionfilterproxy.cpp new file mode 100644 index 0000000..db708f2 --- /dev/null +++ b/src/qt/transactionfilterproxy.cpp @@ -0,0 +1,98 @@ +#include "transactionfilterproxy.h" + +#include "transactiontablemodel.h" +#include "transactionrecord.h" + +#include + +#include + +// Earliest date that can be represented (far in the past) +const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0); +// Last date that can be represented (far in the future) +const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF); + +TransactionFilterProxy::TransactionFilterProxy(QObject *parent) : + QSortFilterProxyModel(parent), + dateFrom(MIN_DATE), + dateTo(MAX_DATE), + addrPrefix(), + typeFilter(ALL_TYPES), + minAmount(0), + limitRows(-1), + showInactive(true) +{ +} + +bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const +{ + QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); + + int type = index.data(TransactionTableModel::TypeRole).toInt(); + QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime(); + QString address = index.data(TransactionTableModel::AddressRole).toString(); + QString label = index.data(TransactionTableModel::LabelRole).toString(); + qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong()); + int status = index.data(TransactionTableModel::StatusRole).toInt(); + + if(!showInactive && (status == TransactionStatus::Conflicted || status == TransactionStatus::NotAccepted)) + return false; + if(!(TYPE(type) & typeFilter)) + return false; + if(datetime < dateFrom || datetime > dateTo) + return false; + if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive)) + return false; + if(amount < minAmount) + return false; + + return true; +} + +void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime &to) +{ + this->dateFrom = from; + this->dateTo = to; + invalidateFilter(); +} + +void TransactionFilterProxy::setAddressPrefix(const QString &addrPrefix) +{ + this->addrPrefix = addrPrefix; + invalidateFilter(); +} + +void TransactionFilterProxy::setTypeFilter(quint32 modes) +{ + this->typeFilter = modes; + invalidateFilter(); +} + +void TransactionFilterProxy::setMinAmount(qint64 minimum) +{ + this->minAmount = minimum; + invalidateFilter(); +} + +void TransactionFilterProxy::setLimit(int limit) +{ + this->limitRows = limit; +} + +void TransactionFilterProxy::setShowInactive(bool showInactive) +{ + this->showInactive = showInactive; + invalidateFilter(); +} + +int TransactionFilterProxy::rowCount(const QModelIndex &parent) const +{ + if(limitRows != -1) + { + return std::min(QSortFilterProxyModel::rowCount(parent), limitRows); + } + else + { + return QSortFilterProxyModel::rowCount(parent); + } +} diff --git a/src/qt/transactionfilterproxy.h b/src/qt/transactionfilterproxy.h new file mode 100644 index 0000000..b8d1e01 --- /dev/null +++ b/src/qt/transactionfilterproxy.h @@ -0,0 +1,53 @@ +#ifndef TRANSACTIONFILTERPROXY_H +#define TRANSACTIONFILTERPROXY_H + +#include +#include + +/** Filter the transaction list according to pre-specified rules. */ +class TransactionFilterProxy : public QSortFilterProxyModel +{ + Q_OBJECT + +public: + explicit TransactionFilterProxy(QObject *parent = 0); + + /** Earliest date that can be represented (far in the past) */ + static const QDateTime MIN_DATE; + /** Last date that can be represented (far in the future) */ + static const QDateTime MAX_DATE; + /** Type filter bit field (all types) */ + static const quint32 ALL_TYPES = 0xFFFFFFFF; + + static quint32 TYPE(int type) { return 1< TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx) +{ + QList parts; + int64_t nTime = wtx.GetTxTime(); + int64_t nCredit = wtx.GetCredit(true); + int64_t nDebit = wtx.GetDebit(); + int64_t nNet = nCredit - nDebit; + uint256 hash = wtx.GetHash(), hashPrev = 0; + std::map mapValue = wtx.mapValue; + + if (nNet > 0 || wtx.IsCoinBase() || wtx.IsCoinStake()) + { + // + // Credit + // + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + { + if(wallet->IsMine(txout)) + { + TransactionRecord sub(hash, nTime); + CTxDestination address; + sub.idx = parts.size(); // sequence number + sub.credit = txout.nValue; + if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address)) + { + // Received by Bitcoin Address + sub.type = TransactionRecord::RecvWithAddress; + sub.address = CBitcoinAddress(address).ToString(); + } + else + { + // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction + sub.type = TransactionRecord::RecvFromOther; + sub.address = mapValue["from"]; + } + if (wtx.IsCoinBase()) + { + // Generated (proof-of-work) + sub.type = TransactionRecord::Generated; + } + if (wtx.IsCoinStake()) + { + // Generated (proof-of-stake) + + if (hashPrev == hash) + continue; // last coinstake output + + sub.type = TransactionRecord::Generated; + sub.credit = nNet > 0 ? nNet : wtx.GetValueOut() - nDebit; + hashPrev = hash; + } + + parts.append(sub); + } + } + } + else + { + bool fAllFromMe = true; + BOOST_FOREACH(const CTxIn& txin, wtx.vin) + fAllFromMe = fAllFromMe && wallet->IsMine(txin); + + bool fAllToMe = true; + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + fAllToMe = fAllToMe && wallet->IsMine(txout); + + if (fAllFromMe && fAllToMe) + { + // Payment to self + int64_t nChange = wtx.GetChange(); + + parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "", + -(nDebit - nChange), nCredit - nChange)); + } + else if (fAllFromMe) + { + // + // Debit + // + int64_t nTxFee = nDebit - wtx.GetValueOut(); + + for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++) + { + const CTxOut& txout = wtx.vout[nOut]; + TransactionRecord sub(hash, nTime); + sub.idx = parts.size(); + + if(wallet->IsMine(txout)) + { + // Ignore parts sent to self, as this is usually the change + // from a transaction sent back to our own address. + continue; + } + + CTxDestination address; + if (ExtractDestination(txout.scriptPubKey, address)) + { + // Sent to Bitcoin Address + sub.type = TransactionRecord::SendToAddress; + sub.address = CBitcoinAddress(address).ToString(); + } + else + { + // Sent to IP, or other non-address transaction like OP_EVAL + sub.type = TransactionRecord::SendToOther; + sub.address = mapValue["to"]; + } + + int64_t nValue = txout.nValue; + /* Add fee to first output */ + if (nTxFee > 0) + { + nValue += nTxFee; + nTxFee = 0; + } + sub.debit = -nValue; + + parts.append(sub); + } + } + else + { + // + // Mixed debit transaction, can't break down payees + // + parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0)); + } + } + + return parts; +} + +void TransactionRecord::updateStatus(const CWalletTx &wtx) +{ + AssertLockHeld(cs_main); + // Determine transaction status + + // Find the block the tx is in + CBlockIndex* pindex = NULL; + std::map::iterator mi = mapBlockIndex.find(wtx.hashBlock); + if (mi != mapBlockIndex.end()) + pindex = (*mi).second; + + // Sort order, unrecorded transactions sort to the top + status.sortKey = strprintf("%010d-%01d-%010u-%03d", + (pindex ? pindex->nHeight : std::numeric_limits::max()), + (wtx.IsCoinBase() ? 1 : 0), + wtx.nTimeReceived, + idx); + status.countsForBalance = wtx.IsTrusted() && !(wtx.GetBlocksToMaturity() > 0); + status.depth = wtx.GetDepthInMainChain(); + status.cur_num_blocks = nBestHeight; + + if (!IsFinalTx(wtx, nBestHeight + 1)) + { + if (wtx.nLockTime < LOCKTIME_THRESHOLD) + { + status.status = TransactionStatus::OpenUntilBlock; + status.open_for = wtx.nLockTime - nBestHeight; + } + else + { + status.status = TransactionStatus::OpenUntilDate; + status.open_for = wtx.nLockTime; + } + } + + // For generated transactions, determine maturity + else if(type == TransactionRecord::Generated) + { + if (wtx.GetBlocksToMaturity() > 0) + { + status.status = TransactionStatus::Immature; + + if (wtx.IsInMainChain()) + { + status.matures_in = wtx.GetBlocksToMaturity(); + + // Check if the block was requested by anyone + if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) + status.status = TransactionStatus::MaturesWarning; + } + else + { + status.status = TransactionStatus::NotAccepted; + } + } + else + { + status.status = TransactionStatus::Confirmed; + } + } + else + { + if (status.depth < 0) + { + status.status = TransactionStatus::Conflicted; + } + else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) + { + status.status = TransactionStatus::Offline; + } + else if (status.depth == 0) + { + status.status = TransactionStatus::Unconfirmed; + } + else if (status.depth < RecommendedNumConfirmations) + { + status.status = TransactionStatus::Confirming; + } + else + { + status.status = TransactionStatus::Confirmed; + } + } +} + +bool TransactionRecord::statusUpdateNeeded() +{ + AssertLockHeld(cs_main); + return status.cur_num_blocks != nBestHeight; +} + +QString TransactionRecord::getTxID() const +{ + return formatSubTxId(hash, idx); +} + +QString TransactionRecord::formatSubTxId(const uint256 &hash, int vout) +{ + return QString::fromStdString(hash.ToString() + strprintf("-%03d", vout)); +} + diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h new file mode 100644 index 0000000..827396b --- /dev/null +++ b/src/qt/transactionrecord.h @@ -0,0 +1,135 @@ +#ifndef TRANSACTIONRECORD_H +#define TRANSACTIONRECORD_H + +#include "uint256.h" + +#include +#include + +class CWallet; +class CWalletTx; + +/** UI model for transaction status. The transaction status is the part of a transaction that will change over time. + */ +class TransactionStatus +{ +public: + TransactionStatus(): + countsForBalance(false), sortKey(""), + matures_in(0), status(Offline), depth(0), open_for(0), cur_num_blocks(-1) + { } + + enum Status { + Confirmed, /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/ + /// Normal (sent/received) transactions + OpenUntilDate, /**< Transaction not yet final, waiting for date */ + OpenUntilBlock, /**< Transaction not yet final, waiting for block */ + Offline, /**< Not sent to any other nodes **/ + Unconfirmed, /**< Not yet mined into a block **/ + Confirming, /**< Confirmed, but waiting for the recommended number of confirmations **/ + Conflicted, /**< Conflicts with other transaction or mempool **/ + /// Generated (mined) transactions + Immature, /**< Mined but waiting for maturity */ + MaturesWarning, /**< Transaction will likely not mature because no nodes have confirmed */ + NotAccepted /**< Mined but not accepted */ + }; + + /// Transaction counts towards available balance + bool countsForBalance; + /// Sorting key based on status + std::string sortKey; + + /** @name Generated (mined) transactions + @{*/ + int matures_in; + /**@}*/ + + /** @name Reported status + @{*/ + Status status; + int64_t depth; + int64_t open_for; /**< Timestamp if status==OpenUntilDate, otherwise number + of additional blocks that need to be mined before + finalization */ + /**@}*/ + + /** Current number of blocks (to know whether cached status is still valid) */ + int cur_num_blocks; +}; + +/** UI model for a transaction. A core transaction can be represented by multiple UI transactions if it has + multiple outputs. + */ +class TransactionRecord +{ +public: + enum Type + { + Other, + Generated, + SendToAddress, + SendToOther, + RecvWithAddress, + RecvFromOther, + SendToSelf + }; + + /** Number of confirmation recommended for accepting a transaction */ + static const int RecommendedNumConfirmations = 10; + + TransactionRecord(): + hash(), time(0), type(Other), address(""), debit(0), credit(0), idx(0) + { + } + + TransactionRecord(uint256 hash, int64_t time): + hash(hash), time(time), type(Other), address(""), debit(0), + credit(0), idx(0) + { + } + + TransactionRecord(uint256 hash, int64_t time, + Type type, const std::string &address, + int64_t debit, int64_t credit): + hash(hash), time(time), type(type), address(address), debit(debit), credit(credit), + idx(0) + { + } + + /** Decompose CWallet transaction to model transaction records. + */ + static bool showTransaction(const CWalletTx &wtx); + static QList decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx); + + /** @name Immutable transaction attributes + @{*/ + uint256 hash; + qint64 time; + Type type; + std::string address; + qint64 debit; + qint64 credit; + /**@}*/ + + /** Subtransaction index, for sort key */ + int idx; + + /** Status: can change with block chain update */ + TransactionStatus status; + + /** Return the unique identifier for this transaction (part) */ + QString getTxID() const; + + /** Format subtransaction id */ + static QString formatSubTxId(const uint256 &hash, int vout); + + /** Update status from core wallet tx. + */ + void updateStatus(const CWalletTx &wtx); + + /** Return whether a status update is needed. + */ + bool statusUpdateNeeded(); +}; + +#endif // TRANSACTIONRECORD_H diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp new file mode 100644 index 0000000..a726079 --- /dev/null +++ b/src/qt/transactiontablemodel.cpp @@ -0,0 +1,623 @@ +#include "transactiontablemodel.h" + +#include "guiutil.h" +#include "transactionrecord.h" +#include "guiconstants.h" +#include "transactiondesc.h" +#include "walletmodel.h" +#include "optionsmodel.h" +#include "addresstablemodel.h" +#include "bitcoinunits.h" + +#include "wallet.h" +#include "ui_interface.h" + +#include +#include +#include +#include +#include + +// Amount column is right-aligned it contains numbers +static int column_alignments[] = { + Qt::AlignLeft|Qt::AlignVCenter, + Qt::AlignLeft|Qt::AlignVCenter, + Qt::AlignLeft|Qt::AlignVCenter, + Qt::AlignLeft|Qt::AlignVCenter, + Qt::AlignRight|Qt::AlignVCenter + }; + +// Comparison operator for sort/binary search of model tx list +struct TxLessThan +{ + bool operator()(const TransactionRecord &a, const TransactionRecord &b) const + { + return a.hash < b.hash; + } + bool operator()(const TransactionRecord &a, const uint256 &b) const + { + return a.hash < b; + } + bool operator()(const uint256 &a, const TransactionRecord &b) const + { + return a < b.hash; + } +}; + +// Private implementation +class TransactionTablePriv +{ +public: + TransactionTablePriv(CWallet *wallet, TransactionTableModel *parent) : + wallet(wallet), + parent(parent) + { + } + + CWallet *wallet; + TransactionTableModel *parent; + + /* Local cache of wallet. + * As it is in the same order as the CWallet, by definition + * this is sorted by sha256. + */ + QList cachedWallet; + + /* Query entire wallet anew from core. + */ + void refreshWallet() + { + qDebug() << "TransactionTablePriv::refreshWallet"; + cachedWallet.clear(); + { + LOCK2(cs_main, wallet->cs_wallet); + for(std::map::iterator it = wallet->mapWallet.begin(); it != wallet->mapWallet.end(); ++it) + { + if(TransactionRecord::showTransaction(it->second)) + cachedWallet.append(TransactionRecord::decomposeTransaction(wallet, it->second)); + } + } + } + + /* Update our model of the wallet incrementally, to synchronize our model of the wallet + with that of the core. + + Call with transaction that was added, removed or changed. + */ + void updateWallet(const uint256 &hash, int status) + { + qDebug() << "TransactionTablePriv::updateWallet : " + QString::fromStdString(hash.ToString()) + " " + QString::number(status); + { + LOCK2(cs_main, wallet->cs_wallet); + + // Find transaction in wallet + std::map::iterator mi = wallet->mapWallet.find(hash); + bool inWallet = mi != wallet->mapWallet.end(); + + // Find bounds of this transaction in model + QList::iterator lower = qLowerBound( + cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan()); + QList::iterator upper = qUpperBound( + cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan()); + int lowerIndex = (lower - cachedWallet.begin()); + int upperIndex = (upper - cachedWallet.begin()); + bool inModel = (lower != upper); + + // Determine whether to show transaction or not + bool showTransaction = (inWallet && TransactionRecord::showTransaction(mi->second)); + + if(status == CT_UPDATED) + { + if(showTransaction && !inModel) + status = CT_NEW; /* Not in model, but want to show, treat as new */ + if(!showTransaction && inModel) + status = CT_DELETED; /* In model, but want to hide, treat as deleted */ + } + + qDebug() << " inWallet=" + QString::number(inWallet) + " inModel=" + QString::number(inModel) + + " Index=" + QString::number(lowerIndex) + "-" + QString::number(upperIndex) + + " showTransaction=" + QString::number(showTransaction) + " derivedStatus=" + QString::number(status); + + switch(status) + { + case CT_NEW: + if(inModel) + { + qDebug() << "TransactionTablePriv::updateWallet : Warning: Got CT_NEW, but transaction is already in model"; + break; + } + if(!inWallet) + { + qDebug() << "TransactionTablePriv::updateWallet : Warning: Got CT_NEW, but transaction is not in wallet"; + break; + } + if(showTransaction) + { + // Added -- insert at the right position + QList toInsert = + TransactionRecord::decomposeTransaction(wallet, mi->second); + if(!toInsert.isEmpty()) /* only if something to insert */ + { + parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1); + int insert_idx = lowerIndex; + foreach(const TransactionRecord &rec, toInsert) + { + cachedWallet.insert(insert_idx, rec); + insert_idx += 1; + } + parent->endInsertRows(); + } + } + break; + case CT_DELETED: + if(!inModel) + { + qDebug() << "TransactionTablePriv::updateWallet : Warning: Got CT_DELETED, but transaction is not in model"; + break; + } + // Removed -- remove entire transaction from table + parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1); + cachedWallet.erase(lower, upper); + parent->endRemoveRows(); + break; + case CT_UPDATED: + // Miscellaneous updates -- nothing to do, status update will take care of this, and is only computed for + // visible transactions. + break; + } + } + } + + int size() + { + return cachedWallet.size(); + } + + TransactionRecord *index(int idx) + { + if(idx >= 0 && idx < cachedWallet.size()) + { + TransactionRecord *rec = &cachedWallet[idx]; + + // Get required locks upfront. This avoids the GUI from getting + // stuck if the core is holding the locks for a longer time - for + // example, during a wallet rescan. + // + // If a status update is needed (blocks came in since last check), + // update the status of this transaction from the wallet. Otherwise, + // simply re-use the cached status. + TRY_LOCK(cs_main, lockMain); + if(lockMain) + { + TRY_LOCK(wallet->cs_wallet, lockWallet); + if(lockWallet && rec->statusUpdateNeeded()) + { + std::map::iterator mi = wallet->mapWallet.find(rec->hash); + + if(mi != wallet->mapWallet.end()) + { + rec->updateStatus(mi->second); + } + } + } + return rec; + } + else + { + return 0; + } + } + + QString describe(TransactionRecord *rec, int unit) + { + { + LOCK2(cs_main, wallet->cs_wallet); + std::map::iterator mi = wallet->mapWallet.find(rec->hash); + if(mi != wallet->mapWallet.end()) + { + return TransactionDesc::toHTML(wallet, mi->second, rec, unit); + } + } + return QString(""); + } +}; + +TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel *parent): + QAbstractTableModel(parent), + wallet(wallet), + walletModel(parent), + priv(new TransactionTablePriv(wallet, this)) +{ + columns << QString() << tr("Date") << tr("Type") << tr("Address") << tr("Amount"); + + priv->refreshWallet(); + + connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); +} + +TransactionTableModel::~TransactionTableModel() +{ + delete priv; +} + +void TransactionTableModel::updateTransaction(const QString &hash, int status) +{ + uint256 updated; + updated.SetHex(hash.toStdString()); + + priv->updateWallet(updated, status); +} + +void TransactionTableModel::updateConfirmations() +{ + // Blocks came in since last poll. + // Invalidate status (number of confirmations) and (possibly) description + // for all rows. Qt is smart enough to only actually request the data for the + // visible rows. + emit dataChanged(index(0, Status), index(priv->size()-1, Status)); + emit dataChanged(index(0, ToAddress), index(priv->size()-1, ToAddress)); +} + +int TransactionTableModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return priv->size(); +} + +int TransactionTableModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return columns.length(); +} + +QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) const +{ + QString status; + + switch(wtx->status.status) + { + case TransactionStatus::OpenUntilBlock: + status = tr("Open for %n more block(s)","",wtx->status.open_for); + break; + case TransactionStatus::OpenUntilDate: + status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for)); + break; + case TransactionStatus::Offline: + status = tr("Offline"); + break; + case TransactionStatus::Unconfirmed: + status = tr("Unconfirmed"); + break; + case TransactionStatus::Confirming: + status = tr("Confirming (%1 of %2 recommended confirmations)").arg(wtx->status.depth).arg(TransactionRecord::RecommendedNumConfirmations); + break; + case TransactionStatus::Confirmed: + status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth); + break; + case TransactionStatus::Conflicted: + status = tr("Conflicted"); + break; + case TransactionStatus::Immature: + status = tr("Immature (%1 confirmations, will be available after %2)").arg(wtx->status.depth).arg(wtx->status.depth + wtx->status.matures_in); + break; + case TransactionStatus::MaturesWarning: + status = tr("This block was not received by any other nodes and will probably not be accepted!"); + break; + case TransactionStatus::NotAccepted: + status = tr("Generated but not accepted"); + break; + } + + return status; +} + +QString TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const +{ + if(wtx->time) + { + return GUIUtil::dateTimeStr(wtx->time); + } + else + { + return QString(); + } +} + +/* Look up address in address book, if found return label (address) + otherwise just return (address) + */ +QString TransactionTableModel::lookupAddress(const std::string &address, bool tooltip) const +{ + QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(address)); + QString description; + if(!label.isEmpty()) + { + description += label + QString(" "); + } + if(label.isEmpty() || tooltip) + { + description += QString("(") + QString::fromStdString(address) + QString(")"); + } + return description; +} + +QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const +{ + switch(wtx->type) + { + case TransactionRecord::RecvWithAddress: + return tr("Received with"); + case TransactionRecord::RecvFromOther: + return tr("Received from"); + case TransactionRecord::SendToAddress: + case TransactionRecord::SendToOther: + return tr("Sent to"); + case TransactionRecord::SendToSelf: + return tr("Payment to yourself"); + case TransactionRecord::Generated: + return tr("Mined"); + default: + return QString(); + } +} + +QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx) const +{ + switch(wtx->type) + { + case TransactionRecord::Generated: + return QIcon(fUseBlackTheme ? ":/icons/black/tx_mined" : ":/icons/tx_mined"); + case TransactionRecord::RecvWithAddress: + case TransactionRecord::RecvFromOther: + return QIcon(fUseBlackTheme ? ":/icons/black/tx_input" : ":/icons/tx_input"); + case TransactionRecord::SendToAddress: + case TransactionRecord::SendToOther: + return QIcon(fUseBlackTheme ? ":/icons/black/tx_output" : ":/icons/tx_output"); + default: + return QIcon(fUseBlackTheme ? ":/icons/black/tx_inout" : ":/icons/tx_inout"); + } + return QVariant(); +} + +QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const +{ + switch(wtx->type) + { + case TransactionRecord::RecvFromOther: + return QString::fromStdString(wtx->address); + case TransactionRecord::RecvWithAddress: + case TransactionRecord::SendToAddress: + case TransactionRecord::Generated: + return lookupAddress(wtx->address, tooltip); + case TransactionRecord::SendToOther: + return QString::fromStdString(wtx->address); + case TransactionRecord::SendToSelf: + default: + return tr("(n/a)"); + } +} + +QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const +{ + // Show addresses without label in a less visible color + switch(wtx->type) + { + case TransactionRecord::RecvWithAddress: + case TransactionRecord::SendToAddress: + case TransactionRecord::Generated: + { + QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(wtx->address)); + if(label.isEmpty()) + return COLOR_BAREADDRESS; + } break; + case TransactionRecord::SendToSelf: + return COLOR_BAREADDRESS; + default: + break; + } + return QVariant(); +} + +QString TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed) const +{ + QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->credit + wtx->debit); + if(showUnconfirmed) + { + if(!wtx->status.countsForBalance) + { + str = QString("[") + str + QString("]"); + } + } + return QString(str); +} + +QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx) const +{ + switch(wtx->status.status) + { + case TransactionStatus::OpenUntilBlock: + case TransactionStatus::OpenUntilDate: + return QColor(64,64,255); + case TransactionStatus::Offline: + return QColor(192,192,192); + case TransactionStatus::Unconfirmed: + return QIcon(":/icons/transaction_0"); + case TransactionStatus::Confirming: + switch(wtx->status.depth) + { + case 1: return QIcon(":/icons/transaction_1"); + case 2: return QIcon(":/icons/transaction_2"); + case 3: return QIcon(":/icons/transaction_3"); + case 4: return QIcon(":/icons/transaction_4"); + default: return QIcon(":/icons/transaction_5"); + }; + case TransactionStatus::Confirmed: + return QIcon(":/icons/transaction_confirmed"); + case TransactionStatus::Conflicted: + return QIcon(":/icons/transaction_conflicted"); + case TransactionStatus::Immature: { + int total = wtx->status.depth + wtx->status.matures_in; + int part = (wtx->status.depth * 4 / total) + 1; + return QIcon(QString(":/icons/transaction_%1").arg(part)); + } + case TransactionStatus::MaturesWarning: + case TransactionStatus::NotAccepted: + return QIcon(":/icons/transaction_0"); + } + return QColor(0,0,0); +} + +QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const +{ + QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec); + if(rec->type==TransactionRecord::RecvFromOther || rec->type==TransactionRecord::SendToOther || + rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress) + { + tooltip += QString(" ") + formatTxToAddress(rec, true); + } + return tooltip; +} + +QVariant TransactionTableModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid()) + return QVariant(); + TransactionRecord *rec = static_cast(index.internalPointer()); + + switch(role) + { + case Qt::DecorationRole: + switch(index.column()) + { + case Status: + return txStatusDecoration(rec); + case ToAddress: + return txAddressDecoration(rec); + } + break; + case Qt::DisplayRole: + switch(index.column()) + { + case Date: + return formatTxDate(rec); + case Type: + return formatTxType(rec); + case ToAddress: + return formatTxToAddress(rec, false); + case Amount: + return formatTxAmount(rec); + } + break; + case Qt::EditRole: + // Edit role is used for sorting, so return the unformatted values + switch(index.column()) + { + case Status: + return QString::fromStdString(rec->status.sortKey); + case Date: + return rec->time; + case Type: + return formatTxType(rec); + case ToAddress: + return formatTxToAddress(rec, true); + case Amount: + return rec->credit + rec->debit; + } + break; + case Qt::ToolTipRole: + return formatTooltip(rec); + case Qt::TextAlignmentRole: + return column_alignments[index.column()]; + case Qt::ForegroundRole: + // Non-confirmed (but not immature) as transactions are grey + if(!rec->status.countsForBalance && rec->status.status != TransactionStatus::Immature) + { + return COLOR_UNCONFIRMED; + } + if(index.column() == Amount && (rec->credit+rec->debit) < 0) + { + return COLOR_NEGATIVE; + } + if(index.column() == Amount && rec->type != TransactionRecord::Generated && (rec->credit+rec->debit) > 0) + { + return fUseBlackTheme ? QColor(0, 255, 0) : QColor(0, 128, 0); + } + if(index.column() == ToAddress) + { + return addressColor(rec); + } + break; + case TypeRole: + return rec->type; + case DateRole: + return QDateTime::fromTime_t(static_cast(rec->time)); + case LongDescriptionRole: + return priv->describe(rec, walletModel->getOptionsModel()->getDisplayUnit()); + case AddressRole: + return QString::fromStdString(rec->address); + case LabelRole: + return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address)); + case AmountRole: + return rec->credit + rec->debit; + case TxIDRole: + return rec->getTxID(); + case ConfirmedRole: + return rec->status.countsForBalance; + case FormattedAmountRole: + return formatTxAmount(rec, false); + case StatusRole: + return rec->status.status; + } + return QVariant(); +} + +QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(orientation == Qt::Horizontal) + { + if(role == Qt::DisplayRole) + { + return columns[section]; + } + else if (role == Qt::TextAlignmentRole) + { + return column_alignments[section]; + } else if (role == Qt::ToolTipRole) + { + switch(section) + { + case Status: + return tr("Transaction status. Hover over this field to show number of confirmations."); + case Date: + return tr("Date and time that the transaction was received."); + case Type: + return tr("Type of transaction."); + case ToAddress: + return tr("Destination address of transaction."); + case Amount: + return tr("Amount removed from or added to balance."); + } + } + } + return QVariant(); +} + +QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const +{ + Q_UNUSED(parent); + TransactionRecord *data = priv->index(row); + if(data) + { + return createIndex(row, column, priv->index(row)); + } + else + { + return QModelIndex(); + } +} + +void TransactionTableModel::updateDisplayUnit() +{ + // emit dataChanged to update Amount column with the current unit + emit dataChanged(index(0, Amount), index(priv->size()-1, Amount)); +} diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h new file mode 100644 index 0000000..6b6f0cc --- /dev/null +++ b/src/qt/transactiontablemodel.h @@ -0,0 +1,87 @@ +#ifndef TRANSACTIONTABLEMODEL_H +#define TRANSACTIONTABLEMODEL_H + +#include +#include + +class CWallet; +class TransactionTablePriv; +class TransactionRecord; +class WalletModel; + +/** UI model for the transaction table of a wallet. + */ +class TransactionTableModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + explicit TransactionTableModel(CWallet* wallet, WalletModel *parent = 0); + ~TransactionTableModel(); + + enum ColumnIndex { + Status = 0, + Date = 1, + Type = 2, + ToAddress = 3, + Amount = 4 + }; + + /** Roles to get specific information from a transaction row. + These are independent of column. + */ + enum RoleIndex { + /** Type of transaction */ + TypeRole = Qt::UserRole, + /** Date and time this transaction was created */ + DateRole, + /** Long description (HTML format) */ + LongDescriptionRole, + /** Address of transaction */ + AddressRole, + /** Label of address related to transaction */ + LabelRole, + /** Net amount of transaction */ + AmountRole, + /** Unique identifier */ + TxIDRole, + /** Is transaction confirmed? */ + ConfirmedRole, + /** Formatted amount, without brackets when unconfirmed */ + FormattedAmountRole, + /** Transaction status (TransactionRecord::Status) */ + StatusRole + }; + + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; + +private: + CWallet* wallet; + WalletModel *walletModel; + QStringList columns; + TransactionTablePriv *priv; + + QString lookupAddress(const std::string &address, bool tooltip) const; + QVariant addressColor(const TransactionRecord *wtx) const; + QString formatTxStatus(const TransactionRecord *wtx) const; + QString formatTxDate(const TransactionRecord *wtx) const; + QString formatTxType(const TransactionRecord *wtx) const; + QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const; + QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const; + QString formatTooltip(const TransactionRecord *rec) const; + QVariant txStatusDecoration(const TransactionRecord *wtx) const; + QVariant txAddressDecoration(const TransactionRecord *wtx) const; + +public slots: + void updateTransaction(const QString &hash, int status); + void updateConfirmations(); + void updateDisplayUnit(); + + friend class TransactionTablePriv; +}; + +#endif // TRANSACTIONTABLEMODEL_H diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp new file mode 100644 index 0000000..270215e --- /dev/null +++ b/src/qt/transactionview.cpp @@ -0,0 +1,433 @@ +#include "transactionview.h" + +#include "transactionfilterproxy.h" +#include "transactionrecord.h" +#include "walletmodel.h" +#include "addresstablemodel.h" +#include "transactiontablemodel.h" +#include "bitcoinunits.h" +#include "csvmodelwriter.h" +#include "transactiondescdialog.h" +#include "editaddressdialog.h" +#include "optionsmodel.h" +#include "guiutil.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +TransactionView::TransactionView(QWidget *parent) : + QWidget(parent), model(0), transactionProxyModel(0), + transactionView(0) +{ + // Build filter row + setContentsMargins(0,0,0,0); + + QHBoxLayout *hlayout = new QHBoxLayout(); + hlayout->setContentsMargins(0,0,0,0); +#ifdef Q_OS_MAC + hlayout->setSpacing(5); + hlayout->addSpacing(26); +#else + hlayout->setSpacing(0); + hlayout->addSpacing(23); +#endif + + dateWidget = new QComboBox(this); + dateWidget->setItemDelegate(new QStyledItemDelegate()); +#ifdef Q_OS_MAC + dateWidget->setFixedWidth(121); +#else + dateWidget->setFixedWidth(120); +#endif + dateWidget->addItem(tr("All"), All); + dateWidget->addItem(tr("Today"), Today); + dateWidget->addItem(tr("This week"), ThisWeek); + dateWidget->addItem(tr("This month"), ThisMonth); + dateWidget->addItem(tr("Last month"), LastMonth); + dateWidget->addItem(tr("This year"), ThisYear); + dateWidget->addItem(tr("Range..."), Range); + hlayout->addWidget(dateWidget); + + typeWidget = new QComboBox(this); + typeWidget->setItemDelegate(new QStyledItemDelegate()); +#ifdef Q_OS_MAC + typeWidget->setFixedWidth(121); +#else + typeWidget->setFixedWidth(120); +#endif + + typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES); + typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) | + TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther)); + typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) | + TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); + typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); + typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); + typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); + + hlayout->addWidget(typeWidget); + + addressWidget = new QLineEdit(this); +#if QT_VERSION >= 0x040700 + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ + addressWidget->setPlaceholderText(tr("Enter address or label to search")); +#endif + hlayout->addWidget(addressWidget); + + amountWidget = new QLineEdit(this); +#if QT_VERSION >= 0x040700 + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ + amountWidget->setPlaceholderText(tr("Min amount")); +#endif +#ifdef Q_OS_MAC + amountWidget->setFixedWidth(97); +#else + amountWidget->setFixedWidth(100); +#endif + amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this)); + hlayout->addWidget(amountWidget); + + QVBoxLayout *vlayout = new QVBoxLayout(this); + vlayout->setContentsMargins(0,0,0,0); + vlayout->setSpacing(0); + + QTableView *view = new QTableView(this); + vlayout->addLayout(hlayout); + vlayout->addWidget(createDateRangeWidget()); + vlayout->addWidget(view); + vlayout->setSpacing(0); + int width = view->verticalScrollBar()->sizeHint().width(); + // Cover scroll bar width with spacing +#ifdef Q_OS_MAC + hlayout->addSpacing(width+2); +#else + hlayout->addSpacing(width); +#endif + // Always show scroll bar + view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + view->setTabKeyNavigation(false); + view->setContextMenuPolicy(Qt::CustomContextMenu); + + transactionView = view; + + // Actions + QAction *copyAddressAction = new QAction(tr("Copy address"), this); + QAction *copyLabelAction = new QAction(tr("Copy label"), this); + QAction *copyAmountAction = new QAction(tr("Copy amount"), this); + QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this); + QAction *editLabelAction = new QAction(tr("Edit label"), this); + QAction *showDetailsAction = new QAction(tr("Show transaction details"), this); + + contextMenu = new QMenu(); + contextMenu->addAction(copyAddressAction); + contextMenu->addAction(copyLabelAction); + contextMenu->addAction(copyAmountAction); + contextMenu->addAction(copyTxIDAction); + contextMenu->addAction(editLabelAction); + contextMenu->addAction(showDetailsAction); + + // Connect actions + connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); + connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); + connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString))); + connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString))); + + connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex))); + connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); + + connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); + connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); + connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); + connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID())); + connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); + connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); +} + +void TransactionView::setModel(WalletModel *model) +{ + this->model = model; + if(model) + { + transactionProxyModel = new TransactionFilterProxy(this); + transactionProxyModel->setSourceModel(model->getTransactionTableModel()); + transactionProxyModel->setDynamicSortFilter(true); + transactionProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + transactionProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + + transactionProxyModel->setSortRole(Qt::EditRole); + + transactionView->setModel(transactionProxyModel); + transactionView->setSelectionBehavior(QAbstractItemView::SelectRows); + transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection); + transactionView->setSortingEnabled(true); + transactionView->sortByColumn(TransactionTableModel::Date, Qt::DescendingOrder); + transactionView->verticalHeader()->hide(); + + transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Status, 23); + transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Date, 120); + transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Type, 120); + transactionView->horizontalHeader()->setResizeMode(TransactionTableModel::ToAddress, QHeaderView::Stretch); + transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Amount, 100); + } +} + +void TransactionView::chooseDate(int idx) +{ + if(!transactionProxyModel) + return; + QDate current = QDate::currentDate(); + dateRangeWidget->setVisible(false); + switch(dateWidget->itemData(idx).toInt()) + { + case All: + transactionProxyModel->setDateRange( + TransactionFilterProxy::MIN_DATE, + TransactionFilterProxy::MAX_DATE); + break; + case Today: + transactionProxyModel->setDateRange( + QDateTime(current), + TransactionFilterProxy::MAX_DATE); + break; + case ThisWeek: { + // Find last Monday + QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1)); + transactionProxyModel->setDateRange( + QDateTime(startOfWeek), + TransactionFilterProxy::MAX_DATE); + + } break; + case ThisMonth: + transactionProxyModel->setDateRange( + QDateTime(QDate(current.year(), current.month(), 1)), + TransactionFilterProxy::MAX_DATE); + break; + case LastMonth: + transactionProxyModel->setDateRange( + QDateTime(QDate(current.year(), current.month()-1, 1)), + QDateTime(QDate(current.year(), current.month(), 1))); + break; + case ThisYear: + transactionProxyModel->setDateRange( + QDateTime(QDate(current.year(), 1, 1)), + TransactionFilterProxy::MAX_DATE); + break; + case Range: + dateRangeWidget->setVisible(true); + dateRangeChanged(); + break; + } +} + +void TransactionView::chooseType(int idx) +{ + if(!transactionProxyModel) + return; + transactionProxyModel->setTypeFilter( + typeWidget->itemData(idx).toInt()); +} + +void TransactionView::changedPrefix(const QString &prefix) +{ + if(!transactionProxyModel) + return; + transactionProxyModel->setAddressPrefix(prefix); +} + +void TransactionView::changedAmount(const QString &amount) +{ + if(!transactionProxyModel) + return; + qint64 amount_parsed = 0; + if(BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amount, &amount_parsed)) + { + transactionProxyModel->setMinAmount(amount_parsed); + } + else + { + transactionProxyModel->setMinAmount(0); + } +} + +void TransactionView::exportClicked() +{ + // CSV is currently the only supported format + QString filename = GUIUtil::getSaveFileName( + this, + tr("Export Transaction Data"), QString(), + tr("Comma separated file (*.csv)")); + + if (filename.isNull()) return; + + CSVModelWriter writer(filename); + + // name, column, role + writer.setModel(transactionProxyModel); + writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole); + writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole); + writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole); + writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole); + writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole); + writer.addColumn(tr("Amount"), 0, TransactionTableModel::FormattedAmountRole); + writer.addColumn(tr("ID"), 0, TransactionTableModel::TxIDRole); + + if(!writer.write()) + { + QMessageBox::critical(this, tr("Error exporting"), tr("Could not write to file %1.").arg(filename), + QMessageBox::Abort, QMessageBox::Abort); + } +} + +void TransactionView::contextualMenu(const QPoint &point) +{ + QModelIndex index = transactionView->indexAt(point); + if(index.isValid()) + { + contextMenu->exec(QCursor::pos()); + } +} + +void TransactionView::copyAddress() +{ + GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::AddressRole); +} + +void TransactionView::copyLabel() +{ + GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::LabelRole); +} + +void TransactionView::copyAmount() +{ + GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::FormattedAmountRole); +} + +void TransactionView::copyTxID() +{ + GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxIDRole); +} + +void TransactionView::editLabel() +{ + if(!transactionView->selectionModel() ||!model) + return; + QModelIndexList selection = transactionView->selectionModel()->selectedRows(); + if(!selection.isEmpty()) + { + AddressTableModel *addressBook = model->getAddressTableModel(); + if(!addressBook) + return; + QString address = selection.at(0).data(TransactionTableModel::AddressRole).toString(); + if(address.isEmpty()) + { + // If this transaction has no associated address, exit + return; + } + // Is address in address book? Address book can miss address when a transaction is + // sent from outside the UI. + int idx = addressBook->lookupAddress(address); + if(idx != -1) + { + // Edit sending / receiving address + QModelIndex modelIdx = addressBook->index(idx, 0, QModelIndex()); + // Determine type of address, launch appropriate editor dialog type + QString type = modelIdx.data(AddressTableModel::TypeRole).toString(); + + EditAddressDialog dlg(type==AddressTableModel::Receive + ? EditAddressDialog::EditReceivingAddress + : EditAddressDialog::EditSendingAddress, + this); + dlg.setModel(addressBook); + dlg.loadRow(idx); + dlg.exec(); + } + else + { + // Add sending address + EditAddressDialog dlg(EditAddressDialog::NewSendingAddress, + this); + dlg.setModel(addressBook); + dlg.setAddress(address); + dlg.exec(); + } + } +} + +void TransactionView::showDetails() +{ + if(!transactionView->selectionModel()) + return; + QModelIndexList selection = transactionView->selectionModel()->selectedRows(); + if(!selection.isEmpty()) + { + TransactionDescDialog dlg(selection.at(0)); + dlg.exec(); + } +} + +QWidget *TransactionView::createDateRangeWidget() +{ + dateRangeWidget = new QFrame(); + dateRangeWidget->setFrameStyle(QFrame::Panel | QFrame::Raised); + dateRangeWidget->setContentsMargins(1,1,1,1); + QHBoxLayout *layout = new QHBoxLayout(dateRangeWidget); + layout->setContentsMargins(0,0,0,0); + layout->addSpacing(23); + layout->addWidget(new QLabel(tr("Range:"))); + + dateFrom = new QDateTimeEdit(this); + dateFrom->setDisplayFormat("dd/MM/yy"); + dateFrom->setCalendarPopup(true); + dateFrom->setMinimumWidth(100); + dateFrom->setDate(QDate::currentDate().addDays(-7)); + layout->addWidget(dateFrom); + layout->addWidget(new QLabel(tr("to"))); + + dateTo = new QDateTimeEdit(this); + dateTo->setDisplayFormat("dd/MM/yy"); + dateTo->setCalendarPopup(true); + dateTo->setMinimumWidth(100); + dateTo->setDate(QDate::currentDate()); + layout->addWidget(dateTo); + layout->addStretch(); + + // Hide by default + dateRangeWidget->setVisible(false); + + // Notify on change + connect(dateFrom, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged())); + connect(dateTo, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged())); + + return dateRangeWidget; +} + +void TransactionView::dateRangeChanged() +{ + if(!transactionProxyModel) + return; + transactionProxyModel->setDateRange( + QDateTime(dateFrom->date()), + QDateTime(dateTo->date()).addDays(1)); +} + +void TransactionView::focusTransaction(const QModelIndex &idx) +{ + if(!transactionProxyModel) + return; + QModelIndex targetIdx = transactionProxyModel->mapFromSource(idx); + transactionView->scrollTo(targetIdx); + transactionView->setCurrentIndex(targetIdx); + transactionView->setFocus(); +} diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h new file mode 100644 index 0000000..0a7e29a --- /dev/null +++ b/src/qt/transactionview.h @@ -0,0 +1,84 @@ +#ifndef TRANSACTIONVIEW_H +#define TRANSACTIONVIEW_H + +#include + +class WalletModel; +class TransactionFilterProxy; + +QT_BEGIN_NAMESPACE +class QTableView; +class QComboBox; +class QLineEdit; +class QModelIndex; +class QMenu; +class QFrame; +class QDateTimeEdit; +QT_END_NAMESPACE + +/** Widget showing the transaction list for a wallet, including a filter row. + Using the filter row, the user can view or export a subset of the transactions. + */ +class TransactionView : public QWidget +{ + Q_OBJECT + +public: + explicit TransactionView(QWidget *parent = 0); + + void setModel(WalletModel *model); + + // Date ranges for filter + enum DateEnum + { + All, + Today, + ThisWeek, + ThisMonth, + LastMonth, + ThisYear, + Range + }; + +private: + WalletModel *model; + TransactionFilterProxy *transactionProxyModel; + QTableView *transactionView; + + QComboBox *dateWidget; + QComboBox *typeWidget; + QLineEdit *addressWidget; + QLineEdit *amountWidget; + + QMenu *contextMenu; + + QFrame *dateRangeWidget; + QDateTimeEdit *dateFrom; + QDateTimeEdit *dateTo; + + QWidget *createDateRangeWidget(); + +private slots: + void contextualMenu(const QPoint &); + void dateRangeChanged(); + void showDetails(); + void copyAddress(); + void editLabel(); + void copyLabel(); + void copyAmount(); + void copyTxID(); + +signals: + void doubleClicked(const QModelIndex&); + +public slots: + void chooseDate(int idx); + void chooseType(int idx); + void changedPrefix(const QString &prefix); + void changedAmount(const QString &amount); + void exportClicked(); + void focusTransaction(const QModelIndex&); + +}; + +#endif // TRANSACTIONVIEW_H diff --git a/src/qt/txviewdelegate.h b/src/qt/txviewdelegate.h new file mode 100644 index 0000000..ae64fb0 --- /dev/null +++ b/src/qt/txviewdelegate.h @@ -0,0 +1,89 @@ +#ifndef TXVIEWDELEGATE_H +#define TXVIEWDELEGATE_H + +#include "guiconstants.h" +#include "guiutil.h" +#include "bitcoinunits.h" +#include "transactiontablemodel.h" +#include "optionsmodel.h" + +#include +#include +#include + + +#define DECORATION_SIZE 64 + +class TxViewDelegate : public QAbstractItemDelegate +{ + Q_OBJECT +public: + TxViewDelegate(): QAbstractItemDelegate(), unit(BitcoinUnits::BTC) + { + + } + + inline void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index ) const + { + painter->save(); + + QIcon icon = qvariant_cast(index.data(Qt::DecorationRole)); + QRect mainRect = option.rect; + QRect decorationRect(mainRect.topLeft(), QSize(DECORATION_SIZE, DECORATION_SIZE)); + int xspace = DECORATION_SIZE + 8; + int ypad = 6; + int halfheight = (mainRect.height() - 2*ypad)/2; + QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace, halfheight); + QRect addressRect(mainRect.left() + xspace, mainRect.top()+ypad+halfheight, mainRect.width() - xspace, halfheight); + icon.paint(painter, decorationRect); + + QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime(); + QString address = index.data(Qt::DisplayRole).toString(); + qint64 amount = index.data(TransactionTableModel::AmountRole).toLongLong(); + bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool(); + QVariant value = index.data(Qt::ForegroundRole); + QColor foreground = option.palette.color(QPalette::Text); + if(qVariantCanConvert(value)) + { + foreground = qvariant_cast(value); + } + + painter->setPen(fUseBlackTheme ? QColor(255, 255, 255) : foreground); + painter->drawText(addressRect, Qt::AlignLeft|Qt::AlignVCenter, address); + + if(amount < 0) + { + foreground = COLOR_NEGATIVE; + } + else if(!confirmed) + { + foreground = COLOR_UNCONFIRMED; + } + else + { + foreground = option.palette.color(QPalette::Text); + } + painter->setPen(fUseBlackTheme ? QColor(255, 255, 255) : foreground); + QString amountText = BitcoinUnits::formatWithUnit(unit, amount, true); + if(!confirmed) + { + amountText = QString("[") + amountText + QString("]"); + } + painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText); + + painter->setPen(fUseBlackTheme ? QColor(96, 101, 110) : option.palette.color(QPalette::Text)); + painter->drawText(amountRect, Qt::AlignLeft|Qt::AlignVCenter, GUIUtil::dateTimeStr(date)); + + painter->restore(); + } + + inline QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const + { + return QSize(DECORATION_SIZE, DECORATION_SIZE); + } + + int unit; + +}; +#endif // TXVIEWDELEGATE_H diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp new file mode 100644 index 0000000..8f0d1a8 --- /dev/null +++ b/src/qt/walletmodel.cpp @@ -0,0 +1,695 @@ +#include "walletmodel.h" +#include "guiconstants.h" +#include "optionsmodel.h" +#include "addresstablemodel.h" +#include "transactiontablemodel.h" + +#include "ui_interface.h" +#include "wallet.h" +#include "walletdb.h" // for BackupWallet +#include "base58.h" +#include "spork.h" +#include "smessage.h" + +#include +#include +#include + +WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) : + QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0), + transactionTableModel(0), + cachedBalance(0), cachedStake(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0), + cachedEncryptionStatus(Unencrypted), + cachedNumBlocks(0) +{ + addressTableModel = new AddressTableModel(wallet, this); + transactionTableModel = new TransactionTableModel(wallet, this); + + // This timer will be fired repeatedly to update the balance + pollTimer = new QTimer(this); + connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollBalanceChanged())); + pollTimer->start(MODEL_UPDATE_DELAY); + + subscribeToCoreSignals(); +} + +WalletModel::~WalletModel() +{ + unsubscribeFromCoreSignals(); +} + +qint64 WalletModel::getBalance(const CCoinControl *coinControl) const +{ + if (coinControl) + { + qint64 nBalance = 0; + std::vector vCoins; + wallet->AvailableCoins(vCoins, true, coinControl); + BOOST_FOREACH(const COutput& out, vCoins) + if(out.fSpendable) + nBalance += out.tx->vout[out.i].nValue; + + return nBalance; + } + + return wallet->GetBalance(); +} + +qint64 WalletModel::getUnconfirmedBalance() const +{ + return wallet->GetUnconfirmedBalance(); +} + +qint64 WalletModel::getStake() const +{ + return wallet->GetStake(); +} + +qint64 WalletModel::getImmatureBalance() const +{ + return wallet->GetImmatureBalance(); +} + +qint64 WalletModel::getAnonymizedBalance() const +{ + qint64 ret = wallet->GetAnonymizedBalance(); + return ret; +} + +void WalletModel::updateStatus() +{ + EncryptionStatus newEncryptionStatus = getEncryptionStatus(); + + if(cachedEncryptionStatus != newEncryptionStatus) + emit encryptionStatusChanged(newEncryptionStatus); +} + +void WalletModel::pollBalanceChanged() +{ + // Get required locks upfront. This avoids the GUI from getting stuck on + // periodical polls if the core is holding the locks for a longer time - + // for example, during a wallet rescan. + TRY_LOCK(cs_main, lockMain); + if(!lockMain) + return; + TRY_LOCK(wallet->cs_wallet, lockWallet); + if(!lockWallet) + return; + + if(nBestHeight != cachedNumBlocks) + { + // Balance and number of transactions might have changed + cachedNumBlocks = nBestHeight; + + checkBalanceChanged(); + if(transactionTableModel) + transactionTableModel->updateConfirmations(); + } +} + +void WalletModel::checkBalanceChanged() +{ + qint64 newBalance = getBalance(); + qint64 newStake = getStake(); + qint64 newUnconfirmedBalance = getUnconfirmedBalance(); + qint64 newImmatureBalance = getImmatureBalance(); + qint64 newAnonymizedBalance = getAnonymizedBalance(); + + if(cachedBalance != newBalance || cachedStake != newStake || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance || cachedAnonymizedBalance != newAnonymizedBalance || cachedTxLocks != nCompleteTXLocks) + { + cachedBalance = newBalance; + cachedStake = newStake; + cachedUnconfirmedBalance = newUnconfirmedBalance; + cachedImmatureBalance = newImmatureBalance; + cachedAnonymizedBalance = newAnonymizedBalance; + cachedTxLocks = nCompleteTXLocks; + emit balanceChanged(newBalance, newStake, newUnconfirmedBalance, newImmatureBalance, newAnonymizedBalance); + } +} + +void WalletModel::updateTransaction(const QString &hash, int status) +{ + if(transactionTableModel) + transactionTableModel->updateTransaction(hash, status); + + // Balance and number of transactions might have changed + checkBalanceChanged(); +} + +void WalletModel::updateAddressBook(const QString &address, const QString &label, bool isMine, int status) +{ + if(addressTableModel) + addressTableModel->updateEntry(address, label, isMine, status); +} + +bool WalletModel::validateAddress(const QString &address) +{ + std::string sAddr = address.toStdString(); + + if (sAddr.length() > 75) + { + if (IsStealthAddress(sAddr)) + return true; + }; + + CBitcoinAddress addressParsed(sAddr); + return addressParsed.IsValid(); +} + +WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList &recipients, const CCoinControl *coinControl) +{ + qint64 total = 0; + QSet setAddress; + QString hex; + + if(recipients.empty()) + { + return OK; + } + + if(isAnonymizeOnlyUnlocked()) + { + return AnonymizeOnlyUnlocked; + } + + // Pre-check input data for validity + foreach(const SendCoinsRecipient &rcp, recipients) + { + if(!validateAddress(rcp.address)) + { + return InvalidAddress; + } + setAddress.insert(rcp.address); + + if(rcp.amount <= 0) + { + return InvalidAmount; + } + total += rcp.amount; + } + + if(recipients.size() > setAddress.size()) + { + return DuplicateAddress; + } + + qint64 nBalance = getBalance(coinControl); + + if(total > nBalance) + { + return AmountExceedsBalance; + } + + if((total + nTransactionFee) > nBalance) + { + return SendCoinsReturn(AmountWithFeeExceedsBalance, nTransactionFee); + } + + std::map mapStealthNarr; + + { + LOCK2(cs_main, wallet->cs_wallet); + + // Sendmany + std::vector > vecSend; + foreach(const SendCoinsRecipient &rcp, recipients) + { + std::string sAddr = rcp.address.toStdString(); + + if (rcp.typeInd == AddressTableModel::AT_Stealth) + { + CStealthAddress sxAddr; + if (sxAddr.SetEncoded(sAddr)) + { + ec_secret ephem_secret; + ec_secret secretShared; + ec_point pkSendTo; + ec_point ephem_pubkey; + + + if (GenerateRandomSecret(ephem_secret) != 0) + { + printf("GenerateRandomSecret failed.\n"); + return Aborted; + }; + + if (StealthSecret(ephem_secret, sxAddr.scan_pubkey, sxAddr.spend_pubkey, secretShared, pkSendTo) != 0) + { + printf("Could not generate receiving public key.\n"); + return Aborted; + }; + + CPubKey cpkTo(pkSendTo); + if (!cpkTo.IsValid()) + { + printf("Invalid public key generated.\n"); + return Aborted; + }; + + CKeyID ckidTo = cpkTo.GetID(); + + CBitcoinAddress addrTo(ckidTo); + + if (SecretToPublicKey(ephem_secret, ephem_pubkey) != 0) + { + printf("Could not generate ephem public key.\n"); + return Aborted; + }; + + if (fDebug) + { + printf("Stealth send to generated pubkey %" PRIszu ": %s\n", pkSendTo.size(), HexStr(pkSendTo).c_str()); + printf("hash %s\n", addrTo.ToString().c_str()); + printf("ephem_pubkey %" PRIszu ": %s\n", ephem_pubkey.size(), HexStr(ephem_pubkey).c_str()); + }; + + CScript scriptPubKey; + scriptPubKey.SetDestination(addrTo.Get()); + + vecSend.push_back(make_pair(scriptPubKey, rcp.amount)); + + CScript scriptP = CScript() << OP_RETURN << ephem_pubkey; + + if (rcp.narration.length() > 0) + { + std::string sNarr = rcp.narration.toStdString(); + + if (sNarr.length() > 24) + { + printf("Narration is too long.\n"); + return NarrationTooLong; + }; + + std::vector vchNarr; + + SecMsgCrypter crypter; + crypter.SetKey(&secretShared.e[0], &ephem_pubkey[0]); + + if (!crypter.Encrypt((uint8_t*)&sNarr[0], sNarr.length(), vchNarr)) + { + printf("Narration encryption failed.\n"); + return Aborted; + }; + + if (vchNarr.size() > 48) + { + printf("Encrypted narration is too long.\n"); + return Aborted; + }; + + if (vchNarr.size() > 0) + scriptP = scriptP << OP_RETURN << vchNarr; + + int pos = vecSend.size()-1; + mapStealthNarr[pos] = sNarr; + }; + + vecSend.push_back(make_pair(scriptP, 1)); + + + continue; + } + else + { + printf("Couldn't parse stealth address!\n"); + return Aborted; + } // else drop through to normal + } + + CScript scriptPubKey; + scriptPubKey.SetDestination(CBitcoinAddress(sAddr).Get()); + vecSend.push_back(make_pair(scriptPubKey, rcp.amount)); + + + + + if (rcp.narration.length() > 0) + { + std::string sNarr = rcp.narration.toStdString(); + + if (sNarr.length() > 24) + { + printf("Narration is too long.\n"); + return NarrationTooLong; + }; + + std::vector vNarr(sNarr.c_str(), sNarr.c_str() + sNarr.length()); + std::vector vNDesc; + + vNDesc.resize(2); + vNDesc[0] = 'n'; + vNDesc[1] = 'p'; + + CScript scriptN = CScript() << OP_RETURN << vNDesc << OP_RETURN << vNarr; + + vecSend.push_back(make_pair(scriptN, 1)); + } + } + + CWalletTx wtx; + CReserveKey keyChange(wallet); + int64_t nFeeRequired = 0; + int nChangePos = -1; + std::string strFailReason; + + /*if(recipients[0].useInstantX && total > GetSporkValue(SPORK_2_MAX_VALUE)*COIN){ + emit message(tr("Send Coins"), tr("InstantX doesn't support sending values that high yet. Transactions are currently limited to %n SONO.", "", GetSporkValue(SPORK_2_MAX_VALUE)),true, + CClientUIInterface::MSG_ERROR); + return TransactionCreationFailed; + }*/ + + bool fCreated = wallet->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, nChangePos, strFailReason, coinControl); + + std::map::iterator it; + for (it = mapStealthNarr.begin(); it != mapStealthNarr.end(); ++it) + { + int pos = it->first; + if (nChangePos > -1 && it->first >= nChangePos) + pos++; + + char key[64]; + if (snprintf(key, sizeof(key), "n_%u", pos) < 1) + { + printf("CreateStealthTransaction(): Error creating narration key."); + continue; + }; + wtx.mapValue[key] = it->second; + }; + + if(!fCreated) + { + if((total + nFeeRequired) > nBalance) // FIXME: could cause collisions in the future + { + return SendCoinsReturn(AmountWithFeeExceedsBalance, nFeeRequired); + } + return TransactionCreationFailed; + } + if(!uiInterface.ThreadSafeAskFee(nFeeRequired, tr("Sending...").toStdString())) + { + return Aborted; + } + if(!wallet->CommitTransaction(wtx, keyChange)) + { + return TransactionCommitFailed; + } + hex = QString::fromStdString(wtx.GetHash().GetHex()); + } + + // Add addresses / update labels that we've sent to to the address book + foreach(const SendCoinsRecipient &rcp, recipients) + { + std::string strAddress = rcp.address.toStdString(); + CTxDestination dest = CBitcoinAddress(strAddress).Get(); + std::string strLabel = rcp.label.toStdString(); + { + LOCK(wallet->cs_wallet); + + if (rcp.typeInd == AddressTableModel::AT_Stealth) + { + wallet->UpdateStealthAddress(strAddress, strLabel, true); + } else + { + std::map::iterator mi = wallet->mapAddressBook.find(dest); + + // Check if we have a new address or an updated label + if (mi == wallet->mapAddressBook.end() || mi->second != strLabel) + { + wallet->SetAddressBookName(dest, strLabel); + }; + }; + } + } + + return SendCoinsReturn(OK, 0, hex); +} + +OptionsModel *WalletModel::getOptionsModel() +{ + return optionsModel; +} + +AddressTableModel *WalletModel::getAddressTableModel() +{ + return addressTableModel; +} + +TransactionTableModel *WalletModel::getTransactionTableModel() +{ + return transactionTableModel; +} + +WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const +{ + if(!wallet->IsCrypted()) + { + return Unencrypted; + } + else if(wallet->IsLocked()) + { + return Locked; + } + else if(fWalletUnlockStakingOnly) + { + return Locked; + } + else if (wallet->fWalletUnlockAnonymizeOnly) + { + return UnlockedForAnonymizationOnly; + } + else + { + return Unlocked; + } +} + +bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase) +{ + if(encrypted) + { + // Encrypt + return wallet->EncryptWallet(passphrase); + } + else + { + // Decrypt -- TODO; not supported yet + return false; + } +} + +bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase, bool anonymizeOnly) +{ + if(locked) + { + // Lock + return wallet->Lock(); + } + else + { + // Unlock + return wallet->Unlock(passPhrase, anonymizeOnly); + } +} + +bool WalletModel::isAnonymizeOnlyUnlocked() +{ + return wallet->fWalletUnlockAnonymizeOnly; +} + +bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass) +{ + bool retval; + { + LOCK(wallet->cs_wallet); + wallet->Lock(); // Make sure wallet is locked before attempting pass change + retval = wallet->ChangeWalletPassphrase(oldPass, newPass); + } + return retval; +} + +bool WalletModel::backupWallet(const QString &filename) +{ + return BackupWallet(*wallet, filename.toLocal8Bit().data()); +} + +// Handlers for core signals +static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel, CCryptoKeyStore *wallet) +{ + qDebug() << "NotifyKeyStoreStatusChanged"; + QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection); +} + +static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, ChangeType status) +{ + if (address.type() == typeid(CStealthAddress)) + { + CStealthAddress sxAddr = boost::get(address); + std::string enc = sxAddr.Encoded(); + LogPrintf("NotifyAddressBookChanged %s %s isMine=%i status=%i\n", enc.c_str(), label.c_str(), isMine, status); + QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection, + Q_ARG(QString, QString::fromStdString(enc)), + Q_ARG(QString, QString::fromStdString(label)), + Q_ARG(bool, isMine), + Q_ARG(int, status)); + } else + { + LogPrintf("NotifyAddressBookChanged %s %s isMine=%i status=%i\n", CBitcoinAddress(address).ToString().c_str(), label.c_str(), isMine, status); + QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection, + Q_ARG(QString, QString::fromStdString(CBitcoinAddress(address).ToString())), + Q_ARG(QString, QString::fromStdString(label)), + Q_ARG(bool, isMine), + Q_ARG(int, status)); + } +} + +static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status) +{ + QString strHash = QString::fromStdString(hash.GetHex()); + + qDebug() << "NotifyTransactionChanged : " + strHash + " status= " + QString::number(status); + QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection, + Q_ARG(QString, strHash), + Q_ARG(int, status)); +} + +void WalletModel::subscribeToCoreSignals() +{ + // Connect signals to wallet + wallet->NotifyStatusChanged.connect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1)); + wallet->NotifyAddressBookChanged.connect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5)); + wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3)); +} + +void WalletModel::unsubscribeFromCoreSignals() +{ + // Disconnect signals from wallet + wallet->NotifyStatusChanged.disconnect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1)); + wallet->NotifyAddressBookChanged.disconnect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5)); + wallet->NotifyTransactionChanged.disconnect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3)); +} + +// WalletModel::UnlockContext implementation +WalletModel::UnlockContext WalletModel::requestUnlock() +{ + bool was_locked = getEncryptionStatus() == Locked; + + if ((!was_locked) && fWalletUnlockStakingOnly && isAnonymizeOnlyUnlocked()) + { + setWalletLocked(true); + was_locked = getEncryptionStatus() == Locked; + + } + if(was_locked) + { + // Request UI to unlock wallet + emit requireUnlock(); + } + // If wallet is still locked, unlock was failed or cancelled, mark context as invalid + bool valid = getEncryptionStatus() != Locked; + + return UnlockContext(this, valid, was_locked && !fWalletUnlockStakingOnly); +} + +WalletModel::UnlockContext::UnlockContext(WalletModel *wallet, bool valid, bool relock): + wallet(wallet), + valid(valid), + relock(relock) +{ +} + +WalletModel::UnlockContext::~UnlockContext() +{ + if(valid && relock) + { + wallet->setWalletLocked(true); + } +} + +void WalletModel::UnlockContext::CopyFrom(const UnlockContext& rhs) +{ + // Transfer context; old object no longer relocks wallet + *this = rhs; + rhs.relock = false; +} + +bool WalletModel::getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const +{ + return wallet->GetPubKey(address, vchPubKeyOut); +} + +// returns a list of COutputs from COutPoints +void WalletModel::getOutputs(const std::vector& vOutpoints, std::vector& vOutputs) +{ + LOCK2(cs_main, wallet->cs_wallet); + BOOST_FOREACH(const COutPoint& outpoint, vOutpoints) + { + if (!wallet->mapWallet.count(outpoint.hash)) continue; + int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain(); + if (nDepth < 0) continue; + COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true); + vOutputs.push_back(out); + } +} + +// AvailableCoins + LockedCoins grouped by wallet address (put change in one group with wallet address) +void WalletModel::listCoins(std::map >& mapCoins) const +{ + LOCK2(cs_main, wallet->cs_wallet); // ListLockedCoins, mapWallet + std::vector vCoins; + wallet->AvailableCoins(vCoins); + + std::vector vLockedCoins; + + // add locked coins + BOOST_FOREACH(const COutPoint& outpoint, vLockedCoins) + { + if (!wallet->mapWallet.count(outpoint.hash)) continue; + int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain(); + if (nDepth < 0) continue; + COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true); + vCoins.push_back(out); + } + + BOOST_FOREACH(const COutput& out, vCoins) + { + COutput cout = out; + + while (wallet->IsChange(cout.tx->vout[cout.i]) && cout.tx->vin.size() > 0 && wallet->IsMine(cout.tx->vin[0])) + { + if (!wallet->mapWallet.count(cout.tx->vin[0].prevout.hash)) break; + cout = COutput(&wallet->mapWallet[cout.tx->vin[0].prevout.hash], cout.tx->vin[0].prevout.n, 0, true); + } + + CTxDestination address; + if(!out.fSpendable || !ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address)) continue; + mapCoins[CBitcoinAddress(address).ToString().c_str()].push_back(out); + } +} + +bool WalletModel::isLockedCoin(uint256 hash, unsigned int n) const +{ + LOCK2(cs_main, wallet->cs_wallet); + return wallet->IsLockedCoin(hash, n); +} + +void WalletModel::lockCoin(COutPoint& output) +{ + LOCK2(cs_main, wallet->cs_wallet); + wallet->LockCoin(output); +} + +void WalletModel::unlockCoin(COutPoint& output) +{ + LOCK2(cs_main, wallet->cs_wallet); + wallet->UnlockCoin(output); +} + +void WalletModel::listLockedCoins(std::vector& vOutpts) +{ + LOCK2(cs_main, wallet->cs_wallet); + wallet->ListLockedCoins(vOutpts); +} + +CWallet* WalletModel::getWallet() +{ + return wallet; +} diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h new file mode 100644 index 0000000..d229807 --- /dev/null +++ b/src/qt/walletmodel.h @@ -0,0 +1,196 @@ +#ifndef WALLETMODEL_H +#define WALLETMODEL_H + +#include +#include +#include + +#include "allocators.h" /* for SecureString */ +#include "instantx.h" +#include "wallet.h" + +class OptionsModel; +class AddressTableModel; +class TransactionTableModel; +class CWallet; +class CKeyID; +class CPubKey; +class COutput; +class COutPoint; +class uint256; +class CCoinControl; + +QT_BEGIN_NAMESPACE +class QTimer; +QT_END_NAMESPACE + +class SendCoinsRecipient +{ +public: + QString address; + QString label; + QString narration; + int typeInd; + qint64 amount; + AvailableCoinsType inputType; + bool useInstantX; +}; + +/** Interface to Bitcoin wallet from Qt view code. */ +class WalletModel : public QObject +{ + Q_OBJECT + +public: + explicit WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent = 0); + ~WalletModel(); + + enum StatusCode // Returned by sendCoins + { + OK, + InvalidAmount, + InvalidAddress, + AmountExceedsBalance, + AmountWithFeeExceedsBalance, + DuplicateAddress, + TransactionCreationFailed, // Error returned when wallet is still locked + TransactionCommitFailed, + NarrationTooLong, + Aborted, + AnonymizeOnlyUnlocked + }; + + enum EncryptionStatus + { + Unencrypted, // !wallet->IsCrypted() + Locked, // wallet->IsCrypted() && wallet->IsLocked() + Unlocked, // wallet->IsCrypted() && !wallet->IsLocked() + UnlockedForAnonymizationOnly + }; + + OptionsModel *getOptionsModel(); + AddressTableModel *getAddressTableModel(); + TransactionTableModel *getTransactionTableModel(); + + qint64 getBalance(const CCoinControl *coinControl=NULL) const; + qint64 getStake() const; + qint64 getUnconfirmedBalance() const; + qint64 getImmatureBalance() const; + qint64 getAnonymizedBalance() const; + EncryptionStatus getEncryptionStatus() const; + + // Check address for validity + bool validateAddress(const QString &address); + + // Return status record for SendCoins, contains error id + information + struct SendCoinsReturn + { + SendCoinsReturn(StatusCode status=Aborted, + qint64 fee=0, + QString hex=QString()): + status(status), fee(fee), hex(hex) {} + StatusCode status; + qint64 fee; // is used in case status is "AmountWithFeeExceedsBalance" + QString hex; // is filled with the transaction hash if status is "OK" + }; + + // Send coins to a list of recipients + SendCoinsReturn sendCoins(const QList &recipients, const CCoinControl *coinControl=NULL); + + // Wallet encryption + bool setWalletEncrypted(bool encrypted, const SecureString &passphrase); + // Passphrase only needed when unlocking + bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString(), bool anonymizeOnly=false); + bool changePassphrase(const SecureString &oldPass, const SecureString &newPass); + // Is wallet unlocked for anonymization only? + bool isAnonymizeOnlyUnlocked(); + // Wallet backup + bool backupWallet(const QString &filename); + + // RAI object for unlocking wallet, returned by requestUnlock() + class UnlockContext + { + public: + UnlockContext(WalletModel *wallet, bool valid, bool relock); + ~UnlockContext(); + + bool isValid() const { return valid; } + + // Copy operator and constructor transfer the context + UnlockContext(const UnlockContext& obj) { CopyFrom(obj); } + UnlockContext& operator=(const UnlockContext& rhs) { CopyFrom(rhs); return *this; } + private: + WalletModel *wallet; + bool valid; + mutable bool relock; // mutable, as it can be set to false by copying + + void CopyFrom(const UnlockContext& rhs); + }; + + UnlockContext requestUnlock(); + + bool getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const; + void getOutputs(const std::vector& vOutpoints, std::vector& vOutputs); + void listCoins(std::map >& mapCoins) const; + bool isLockedCoin(uint256 hash, unsigned int n) const; + void lockCoin(COutPoint& output); + void unlockCoin(COutPoint& output); + void listLockedCoins(std::vector& vOutpts); + CWallet* getWallet(); + +private: + CWallet *wallet; + + // Wallet has an options model for wallet-specific options + // (transaction fee, for example) + OptionsModel *optionsModel; + + AddressTableModel *addressTableModel; + TransactionTableModel *transactionTableModel; + + // Cache some values to be able to detect changes + qint64 cachedBalance; + qint64 cachedStake; + qint64 cachedUnconfirmedBalance; + qint64 cachedImmatureBalance; + qint64 cachedAnonymizedBalance; + qint64 cachedNumTransactions; + int cachedTxLocks; + int cachedluxsendRounds; + EncryptionStatus cachedEncryptionStatus; + int cachedNumBlocks; + + QTimer *pollTimer; + + void subscribeToCoreSignals(); + void unsubscribeFromCoreSignals(); + void checkBalanceChanged(); + + +public slots: + /* Wallet status might have changed */ + void updateStatus(); + /* New transaction, or transaction changed status */ + void updateTransaction(const QString &hash, int status); + /* New, updated or removed address book entry */ + void updateAddressBook(const QString &address, const QString &label, bool isMine, int status); + /* Current, immature or unconfirmed balance might have changed - emit 'balanceChanged' if so */ + void pollBalanceChanged(); + +signals: + // Signal that balance in wallet changed + void balanceChanged(qint64 balance, qint64 stake, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 anonymizedBalance); + + // Encryption status of wallet changed + void encryptionStatusChanged(int status); + + // Signal emitted when wallet needs to be unlocked + // It is valid behaviour for listeners to keep the wallet locked after this signal; + // this means that the unlocking failed or was cancelled. + void requireUnlock(); + + // Asynchronous message notification + void message(const QString &title, const QString &message, bool modal, unsigned int style); +}; + +#endif // WALLETMODEL_H diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp new file mode 100644 index 0000000..ef90c49 --- /dev/null +++ b/src/rpcblockchain.cpp @@ -0,0 +1,293 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "rpcserver.h" +#include "main.h" +#include "kernel.h" +#include "checkpoints.h" + +using namespace json_spirit; +using namespace std; + +extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, json_spirit::Object& entry); +//extern enum Checkpoints::CPMode CheckpointsMode; + +double GetDifficulty(const CBlockIndex* blockindex) +{ + // Floating point number that is a multiple of the minimum difficulty, + // minimum difficulty = 1.0. + if (blockindex == NULL) + { + if (pindexBest == NULL) + return 1.0; + else + blockindex = GetLastBlockIndex(pindexBest, false); + } + + int nShift = (blockindex->nBits >> 24) & 0xff; + + double dDiff = + (double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff); + + while (nShift < 29) + { + dDiff *= 256.0; + nShift++; + } + while (nShift > 29) + { + dDiff /= 256.0; + nShift--; + } + + return dDiff; +} + +double GetPoWMHashPS() +{ + if (pindexBest->nHeight >= Params().LastPOWBlock()) + return 0; + + int nPoWInterval = 72; + int64_t nTargetSpacingWorkMin = 30, nTargetSpacingWork = 30; + + CBlockIndex* pindex = pindexGenesisBlock; + CBlockIndex* pindexPrevWork = pindexGenesisBlock; + + while (pindex) + { + if (pindex->IsProofOfWork()) + { + int64_t nActualSpacingWork = pindex->GetBlockTime() - pindexPrevWork->GetBlockTime(); + nTargetSpacingWork = ((nPoWInterval - 1) * nTargetSpacingWork + nActualSpacingWork + nActualSpacingWork) / (nPoWInterval + 1); + nTargetSpacingWork = max(nTargetSpacingWork, nTargetSpacingWorkMin); + pindexPrevWork = pindex; + } + + pindex = pindex->pnext; + } + + return GetDifficulty() * 4294.967296 / nTargetSpacingWork; +} + +double GetPoSKernelPS() +{ + int nPoSInterval = 72; + double dStakeKernelsTriedAvg = 0; + int nStakesHandled = 0, nStakesTime = 0; + + CBlockIndex* pindex = pindexBest;; + CBlockIndex* pindexPrevStake = NULL; + + while (pindex && nStakesHandled < nPoSInterval) + { + if (pindex->IsProofOfStake()) + { + if (pindexPrevStake) + { + dStakeKernelsTriedAvg += GetDifficulty(pindexPrevStake) * 4294967296.0; + nStakesTime += pindexPrevStake->nTime - pindex->nTime; + nStakesHandled++; + } + pindexPrevStake = pindex; + } + + pindex = pindex->pprev; + } + + double result = 0; + + if (nStakesTime) + result = dStakeKernelsTriedAvg / nStakesTime; + + if (IsProtocolV2(nBestHeight)) + result *= STAKE_TIMESTAMP_MASK + 1; + + return result; +} + +Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPrintTransactionDetail) +{ + Object result; + result.push_back(Pair("hash", block.GetHash().GetHex())); + int confirmations = -1; + // Only report confirmations if the block is on the main chain + if (blockindex->IsInMainChain()) + confirmations = nBestHeight - blockindex->nHeight + 1; + result.push_back(Pair("confirmations", confirmations)); + result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION))); + result.push_back(Pair("height", blockindex->nHeight)); + result.push_back(Pair("version", block.nVersion)); + result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); + result.push_back(Pair("mint", ValueFromAmount(blockindex->nMint))); + result.push_back(Pair("time", (int64_t)block.GetBlockTime())); + result.push_back(Pair("nonce", (uint64_t)block.nNonce)); + result.push_back(Pair("bits", strprintf("%08x", block.nBits))); + result.push_back(Pair("difficulty", GetDifficulty(blockindex))); + result.push_back(Pair("blocktrust", leftTrim(blockindex->GetBlockTrust().GetHex(), '0'))); + result.push_back(Pair("chaintrust", leftTrim(blockindex->nChainTrust.GetHex(), '0'))); + if (blockindex->pprev) + result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); + if (blockindex->pnext) + result.push_back(Pair("nextblockhash", blockindex->pnext->GetBlockHash().GetHex())); + + result.push_back(Pair("flags", strprintf("%s%s", blockindex->IsProofOfStake()? "proof-of-stake" : "proof-of-work", blockindex->GeneratedStakeModifier()? " stake-modifier": ""))); + result.push_back(Pair("proofhash", blockindex->hashProof.GetHex())); + result.push_back(Pair("entropybit", (int)blockindex->GetStakeEntropyBit())); + result.push_back(Pair("modifier", strprintf("%016x", blockindex->nStakeModifier))); + Array txinfo; + BOOST_FOREACH (const CTransaction& tx, block.vtx) + { + if (fPrintTransactionDetail) + { + Object entry; + + entry.push_back(Pair("txid", tx.GetHash().GetHex())); + TxToJSON(tx, 0, entry); + + txinfo.push_back(entry); + } + else + txinfo.push_back(tx.GetHash().GetHex()); + } + + result.push_back(Pair("tx", txinfo)); + + if (block.IsProofOfStake()) + result.push_back(Pair("signature", HexStr(block.vchBlockSig.begin(), block.vchBlockSig.end()))); + + return result; +} + +Value getbestblockhash(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getbestblockhash\n" + "Returns the hash of the best block in the longest block chain."); + + return hashBestChain.GetHex(); +} + +Value getblockcount(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getblockcount\n" + "Returns the number of blocks in the longest block chain."); + + return nBestHeight; +} + + +Value getdifficulty(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getdifficulty\n" + "Returns the difficulty as a multiple of the minimum difficulty."); + + Object obj; + obj.push_back(Pair("proof-of-work", GetDifficulty())); + obj.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); + return obj; +} + + +Value getrawmempool(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getrawmempool\n" + "Returns all transaction ids in memory pool."); + + vector vtxid; + mempool.queryHashes(vtxid); + + Array a; + BOOST_FOREACH(const uint256& hash, vtxid) + a.push_back(hash.ToString()); + + return a; +} + +Value getblockhash(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getblockhash \n" + "Returns hash of block in best-block-chain at ."); + + int nHeight = params[0].get_int(); + if (nHeight < 0 || nHeight > nBestHeight) + throw runtime_error("Block number out of range."); + + CBlockIndex* pblockindex = FindBlockByHeight(nHeight); + return pblockindex->phashBlock->GetHex(); +} + +Value getblock(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "getblock [txinfo]\n" + "txinfo optional to print more detailed tx info\n" + "Returns details of a block with given block-hash."); + + std::string strHash = params[0].get_str(); + uint256 hash(strHash); + + if (mapBlockIndex.count(hash) == 0) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + block.ReadFromDisk(pblockindex, true); + + return blockToJSON(block, pblockindex, params.size() > 1 ? params[1].get_bool() : false); +} + +Value getblockbynumber(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "getblockbynumber [txinfo]\n" + "txinfo optional to print more detailed tx info\n" + "Returns details of a block with given block-number."); + + int nHeight = params[0].get_int(); + if (nHeight < 0 || nHeight > nBestHeight) + throw runtime_error("Block number out of range."); + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hashBestChain]; + while (pblockindex->nHeight > nHeight) + pblockindex = pblockindex->pprev; + + uint256 hash = *pblockindex->phashBlock; + + pblockindex = mapBlockIndex[hash]; + block.ReadFromDisk(pblockindex, true); + + return blockToJSON(block, pblockindex, params.size() > 1 ? params[1].get_bool() : false); +} + +// ppcoin: get information of sync-checkpoint +Value getcheckpoint(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getcheckpoint\n" + "Show info of synchronized checkpoint.\n"); + + Object result; + const CBlockIndex* pindexCheckpoint = Checkpoints::AutoSelectSyncCheckpoint(); + + result.push_back(Pair("synccheckpoint", pindexCheckpoint->GetBlockHash().ToString().c_str())); + result.push_back(Pair("height", pindexCheckpoint->nHeight)); + result.push_back(Pair("timestamp", DateTimeStrFormat(pindexCheckpoint->GetBlockTime()).c_str())); + + return result; +} diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp new file mode 100644 index 0000000..e6d1742 --- /dev/null +++ b/src/rpcclient.cpp @@ -0,0 +1,276 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include "rpcclient.h" + +#include "rpcprotocol.h" +#include "util.h" +#include "ui_interface.h" +#include "chainparams.h" // for Params().RPCPort() + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "json/json_spirit_writer_template.h" + +using namespace std; +using namespace boost; +using namespace boost::asio; +using namespace json_spirit; + +Object CallRPC(const string& strMethod, const Array& params) +{ + if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "") + throw runtime_error(strprintf( + _("You must set rpcpassword= in the configuration file:\n%s\n" + "If the file does not exist, create it with owner-readable-only file permissions."), + GetConfigFile().string())); + + // Connect to localhost + bool fUseSSL = GetBoolArg("-rpcssl", false); + asio::io_service io_service; + ssl::context context(io_service, ssl::context::sslv23); + context.set_options(ssl::context::no_sslv2); + asio::ssl::stream sslStream(io_service, context); + SSLIOStreamDevice d(sslStream, fUseSSL); + iostreams::stream< SSLIOStreamDevice > stream(d); + + bool fWait = GetBoolArg("-rpcwait", false); // -rpcwait means try until server has started + do { + bool fConnected = d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(Params().RPCPort()))); + if (fConnected) break; + if (fWait) + MilliSleep(1000); + else + throw runtime_error("couldn't connect to server"); + } while (fWait); + + // HTTP basic authentication + string strUserPass64 = EncodeBase64(mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"]); + map mapRequestHeaders; + mapRequestHeaders["Authorization"] = string("Basic ") + strUserPass64; + + // Send request + string strRequest = JSONRPCRequest(strMethod, params, 1); + string strPost = HTTPPost(strRequest, mapRequestHeaders); + stream << strPost << std::flush; + + // Receive HTTP reply status + int nProto = 0; + int nStatus = ReadHTTPStatus(stream, nProto); + + // Receive HTTP reply message headers and body + map mapHeaders; + string strReply; + ReadHTTPMessage(stream, mapHeaders, strReply, nProto, MAX_SIZE); + + if (nStatus == HTTP_UNAUTHORIZED) + throw runtime_error("incorrect rpcuser or rpcpassword (authorization failed)"); + else if (nStatus >= 400 && nStatus != HTTP_BAD_REQUEST && nStatus != HTTP_NOT_FOUND && nStatus != HTTP_INTERNAL_SERVER_ERROR) + throw runtime_error(strprintf("server returned HTTP error %d", nStatus)); + else if (strReply.empty()) + throw runtime_error("no response from server"); + + // Parse reply + Value valReply; + if (!read_string(strReply, valReply)) + throw runtime_error("couldn't parse reply from server"); + const Object& reply = valReply.get_obj(); + if (reply.empty()) + throw runtime_error("expected reply to have result, error and id properties"); + + return reply; +} + +class CRPCConvertParam +{ +public: + std::string methodName; // method whose params want conversion + int paramIdx; // 0-based idx of param to convert +}; + +static const CRPCConvertParam vRPCConvertParams[] = +{ + { "stop", 0 }, + { "getaddednodeinfo", 0 }, + { "sendtoaddress", 1 }, + { "settxfee", 0 }, + { "getreceivedbyaddress", 1 }, + { "getreceivedbyaccount", 1 }, + { "listreceivedbyaddress", 0 }, + { "listreceivedbyaddress", 1 }, + { "listreceivedbyaccount", 0 }, + { "listreceivedbyaccount", 1 }, + { "getbalance", 1 }, + { "getblock", 1 }, + { "getblockbynumber", 0 }, + { "getblockbynumber", 1 }, + { "getblockhash", 0 }, + { "move", 2 }, + { "move", 3 }, + { "sendfrom", 2 }, + { "sendfrom", 3 }, + { "listtransactions", 1 }, + { "listtransactions", 2 }, + { "listaccounts", 0 }, + { "walletpassphrase", 1 }, + { "walletpassphrase", 2 }, + { "getblocktemplate", 0 }, + { "listsinceblock", 1 }, + { "sendalert", 2 }, + { "sendalert", 3 }, + { "sendalert", 4 }, + { "sendalert", 5 }, + { "sendalert", 6 }, + { "sendmany", 1 }, + { "sendmany", 2 }, + { "reservebalance", 0 }, + { "reservebalance", 1 }, + { "addmultisigaddress", 0 }, + { "addmultisigaddress", 1 }, + { "listunspent", 0 }, + { "listunspent", 1 }, + { "listunspent", 2 }, + { "getrawtransaction", 1 }, + { "createrawtransaction", 0 }, + { "createrawtransaction", 1 }, + { "signrawtransaction", 1 }, + { "signrawtransaction", 2 }, + { "keypoolrefill", 0 }, + { "importprivkey", 2 }, + { "checkkernel", 0 }, + { "checkkernel", 1 }, + { "sendtostealthaddress", 1 }, + { "searchrawtransactions", 1 }, + { "searchrawtransactions", 2 }, + { "searchrawtransactions", 3 }, +}; + +class CRPCConvertTable +{ +private: + std::set > members; + +public: + CRPCConvertTable(); + + bool convert(const std::string& method, int idx) { + return (members.count(std::make_pair(method, idx)) > 0); + } +}; + +CRPCConvertTable::CRPCConvertTable() +{ + const unsigned int n_elem = + (sizeof(vRPCConvertParams) / sizeof(vRPCConvertParams[0])); + + for (unsigned int i = 0; i < n_elem; i++) { + members.insert(std::make_pair(vRPCConvertParams[i].methodName, + vRPCConvertParams[i].paramIdx)); + } +} + +static CRPCConvertTable rpcCvtTable; + +// Convert strings to command-specific RPC representation +Array RPCConvertValues(const std::string &strMethod, const std::vector &strParams) +{ + Array params; + + for (unsigned int idx = 0; idx < strParams.size(); idx++) { + const std::string& strVal = strParams[idx]; + + // insert string value directly + if (!rpcCvtTable.convert(strMethod, idx)) { + params.push_back(strVal); + } + + // parse string as JSON, insert bool/number/object/etc. value + else { + Value jVal; + if (!read_string(strVal, jVal)) + throw runtime_error(string("Error parsing JSON:")+strVal); + params.push_back(jVal); + } + + } + + return params; +} + +int CommandLineRPC(int argc, char *argv[]) +{ + string strPrint; + int nRet = 0; + try + { + // Skip switches + while (argc > 1 && IsSwitchChar(argv[1][0])) + { + argc--; + argv++; + } + + // Method + if (argc < 2) + throw runtime_error("too few parameters"); + string strMethod = argv[1]; + + // Parameters default to strings + std::vector strParams(&argv[2], &argv[argc]); + Array params = RPCConvertValues(strMethod, strParams); + + // Execute + Object reply = CallRPC(strMethod, params); + + // Parse reply + const Value& result = find_value(reply, "result"); + const Value& error = find_value(reply, "error"); + + if (error.type() != null_type) + { + // Error + strPrint = "error: " + write_string(error, false); + int code = find_value(error.get_obj(), "code").get_int(); + nRet = abs(code); + } + else + { + // Result + if (result.type() == null_type) + strPrint = ""; + else if (result.type() == str_type) + strPrint = result.get_str(); + else + strPrint = write_string(result, true); + } + } + catch (boost::thread_interrupted) { + throw; + } + catch (std::exception& e) { + strPrint = string("error: ") + e.what(); + nRet = 87; + } + catch (...) { + PrintException(NULL, "CommandLineRPC()"); + } + + if (strPrint != "") + { + fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str()); + } + return nRet; +} diff --git a/src/rpcclient.h b/src/rpcclient.h new file mode 100644 index 0000000..f3ea56c --- /dev/null +++ b/src/rpcclient.h @@ -0,0 +1,17 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef _BITCOINRPC_CLIENT_H_ +#define _BITCOINRPC_CLIENT_H_ 1 + +#include "json/json_spirit_reader_template.h" +#include "json/json_spirit_utils.h" +#include "json/json_spirit_writer_template.h" + +int CommandLineRPC(int argc, char *argv[]); + +json_spirit::Array RPCConvertValues(const std::string &strMethod, const std::vector &strParams); + +#endif diff --git a/src/rpcdarksend.cpp b/src/rpcdarksend.cpp new file mode 100644 index 0000000..e4bd830 --- /dev/null +++ b/src/rpcdarksend.cpp @@ -0,0 +1,587 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Darkcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "main.h" +//#include "primitives/transaction.h" +#include "db.h" +#include "init.h" +#include "masternode.h" +#include "activemasternode.h" +#include "masternodeconfig.h" +#include "rpcserver.h" +#include +//#include "amount.h" +#include "util.h" +//#include "utilmoneystr.h" + +#include +using namespace json_spirit; +using namespace std; + +void SendMoney(const CTxDestination &address, CAmount nValue, CWalletTx& wtxNew, AvailableCoinsType coin_type) +{ + // Check amount + if (nValue <= 0) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount"); + + if (nValue > pwalletMain->GetBalance()) + throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); + + string strError; + if (pwalletMain->IsLocked()) + { + strError = "Error: Wallet locked, unable to create transaction!"; + LogPrintf("SendMoney() : %s", strError); + throw JSONRPCError(RPC_WALLET_ERROR, strError); + } + + // Parse SONO address + CScript scriptPubKey = GetScriptForDestination(address); + + // Create and send the transaction + CReserveKey reservekey(pwalletMain); + int64_t nFeeRequired; + std::string sNarr; + if (!pwalletMain->CreateTransaction(scriptPubKey, nValue, sNarr, wtxNew, reservekey, nFeeRequired, NULL)) + { + if (nValue + nFeeRequired > pwalletMain->GetBalance()) + strError = strprintf("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!", FormatMoney(nFeeRequired)); + LogPrintf("SendMoney() : %s\n", strError); + throw JSONRPCError(RPC_WALLET_ERROR, strError); + } + if (!pwalletMain->CommitTransaction(wtxNew, reservekey)) + throw JSONRPCError(RPC_WALLET_ERROR, "Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."); +} + +Value darksend(const Array& params, bool fHelp) +{ + if (fHelp || params.size() == 0) + throw runtime_error( + "darksend \n" + "SONOaddress, reset, or auto (AutoDenominate)" + " is a real and is rounded to the nearest 0.00000001" + + HelpRequiringPassphrase()); + + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); + + if(params[0].get_str() == "auto"){ + if(fMasterNode) + return "DarkSend is not supported from masternodes"; + + darkSendPool.DoAutomaticDenominating(); + return "DoAutomaticDenominating"; + } + + if(params[0].get_str() == "reset"){ + darkSendPool.SetNull(true); + darkSendPool.UnlockCoins(); + return "successfully reset darksend"; + } + + if (params.size() != 2) + throw runtime_error( + "darksend \n" + "SONOaddress, denominate, or auto (AutoDenominate)" + " is a real and is rounded to the nearest 0.00000001" + + HelpRequiringPassphrase()); + + CBitcoinAddress address(params[0].get_str()); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid SONO address"); + + // Amount + int64_t nAmount = AmountFromValue(params[1]); + + // Wallet comments + CWalletTx wtx; + SendMoney(address.Get(), nAmount, wtx, ONLY_DENOMINATED); + + return wtx.GetHash().GetHex(); +} + + +Value getpoolinfo(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getpoolinfo\n" + "Returns an object containing anonymous pool-related information."); + + Object obj; + obj.push_back(Pair("current_masternode", GetCurrentMasterNode())); + obj.push_back(Pair("state", darkSendPool.GetState())); + obj.push_back(Pair("entries", darkSendPool.GetEntriesCount())); + obj.push_back(Pair("entries_accepted", darkSendPool.GetCountEntriesAccepted())); + return obj; +} + + +Value masternode(const Array& params, bool fHelp) +{ + string strCommand; + if (params.size() >= 1) + strCommand = params[0].get_str(); + + if (fHelp || + (strCommand != "start" && strCommand != "start-alias" && strCommand != "start-many" && strCommand != "stop" && strCommand != "stop-alias" && strCommand != "stop-many" && strCommand != "list" && strCommand != "list-conf" && strCommand != "count" && strCommand != "enforce" + && strCommand != "debug" && strCommand != "current" && strCommand != "winners" && strCommand != "genkey" && strCommand != "connect" && strCommand != "outputs")) + throw runtime_error( + "masternode [passphrase]\n"); + + if (strCommand == "stop") + { + if(!fMasterNode) return "you must set masternode=1 in the configuration"; + + if(pwalletMain->IsLocked()) { + SecureString strWalletPass; + strWalletPass.reserve(100); + + if (params.size() == 2){ + strWalletPass = params[1].get_str().c_str(); + } else { + throw runtime_error( + "Your wallet is locked, passphrase is required\n"); + } + + if(!pwalletMain->Unlock(strWalletPass)){ + return "incorrect passphrase"; + } + } + + std::string errorMessage; + if(!activeMasternode.StopMasterNode(errorMessage)) { + return "stop failed: " + errorMessage; + } + pwalletMain->Lock(); + + if(activeMasternode.status == MASTERNODE_STOPPED) return "successfully stopped masternode"; + if(activeMasternode.status == MASTERNODE_NOT_CAPABLE) return "not capable masternode"; + + return "unknown"; + } + + if (strCommand == "stop-alias") + { + if (params.size() < 2){ + throw runtime_error( + "command needs at least 2 parameters\n"); + } + + std::string alias = params[1].get_str().c_str(); + + if(pwalletMain->IsLocked()) { + SecureString strWalletPass; + strWalletPass.reserve(100); + + if (params.size() == 3){ + strWalletPass = params[2].get_str().c_str(); + } else { + throw runtime_error( + "Your wallet is locked, passphrase is required\n"); + } + + if(!pwalletMain->Unlock(strWalletPass)){ + return "incorrect passphrase"; + } + } + + bool found = false; + + Object statusObj; + statusObj.push_back(Pair("alias", alias)); + + BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + if(mne.getAlias() == alias) { + found = true; + std::string errorMessage; + bool result = activeMasternode.StopMasterNode(mne.getIp(), mne.getPrivKey(), errorMessage); + + statusObj.push_back(Pair("result", result ? "successful" : "failed")); + if(!result) { + statusObj.push_back(Pair("errorMessage", errorMessage)); + } + break; + } + } + + if(!found) { + statusObj.push_back(Pair("result", "failed")); + statusObj.push_back(Pair("errorMessage", "could not find alias in config. Verify with list-conf.")); + } + + pwalletMain->Lock(); + return statusObj; + } + + if (strCommand == "stop-many") + { + if(pwalletMain->IsLocked()) { + SecureString strWalletPass; + strWalletPass.reserve(100); + + if (params.size() == 2){ + strWalletPass = params[1].get_str().c_str(); + } else { + throw runtime_error( + "Your wallet is locked, passphrase is required\n"); + } + + if(!pwalletMain->Unlock(strWalletPass)){ + return "incorrect passphrase"; + } + } + + int total = 0; + int successful = 0; + int fail = 0; + + + Object resultsObj; + + BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + total++; + + std::string errorMessage; + bool result = activeMasternode.StopMasterNode(mne.getIp(), mne.getPrivKey(), errorMessage); + + Object statusObj; + statusObj.push_back(Pair("alias", mne.getAlias())); + statusObj.push_back(Pair("result", result ? "successful" : "failed")); + + if(result) { + successful++; + } else { + fail++; + statusObj.push_back(Pair("errorMessage", errorMessage)); + } + + resultsObj.push_back(Pair("status", statusObj)); + } + pwalletMain->Lock(); + + Object returnObj; + returnObj.push_back(Pair("overall", "Successfully stopped " + boost::lexical_cast(successful) + " masternodes, failed to stop " + + boost::lexical_cast(fail) + ", total " + boost::lexical_cast(total))); + returnObj.push_back(Pair("detail", resultsObj)); + + return returnObj; + + } + + if (strCommand == "list") + { + std::string strCommand = "active"; + + if (params.size() == 2){ + strCommand = params[1].get_str().c_str(); + } + + if (strCommand != "active" && strCommand != "vin" && strCommand != "pubkey" && strCommand != "lastseen" && strCommand != "activeseconds" && strCommand != "rank" && strCommand != "protocol"){ + throw runtime_error( + "list supports 'active', 'vin', 'pubkey', 'lastseen', 'activeseconds', 'rank', 'protocol'\n"); + } + + Object obj; + BOOST_FOREACH(CMasterNode mn, vecMasternodes) { + mn.Check(); + + if(strCommand == "active"){ + obj.push_back(Pair(mn.addr.ToString().c_str(), (int)mn.IsEnabled())); + } else if (strCommand == "vin") { + obj.push_back(Pair(mn.addr.ToString().c_str(), mn.vin.prevout.hash.ToString().c_str())); + } else if (strCommand == "pubkey") { + CScript pubkey; + pubkey =GetScriptForDestination(mn.pubkey.GetID()); + CTxDestination address1; + ExtractDestination(pubkey, address1); + CBitcoinAddress address2(address1); + + obj.push_back(Pair(mn.addr.ToString().c_str(), address2.ToString().c_str())); + } else if (strCommand == "protocol") { + obj.push_back(Pair(mn.addr.ToString().c_str(), (int64_t)mn.protocolVersion)); + } else if (strCommand == "lastseen") { + obj.push_back(Pair(mn.addr.ToString().c_str(), (int64_t)mn.lastTimeSeen)); + } else if (strCommand == "activeseconds") { + obj.push_back(Pair(mn.addr.ToString().c_str(), (int64_t)(mn.lastTimeSeen - mn.now))); + } else if (strCommand == "rank") { + obj.push_back(Pair(mn.addr.ToString().c_str(), (int)(GetMasternodeRank(mn.vin, pindexBest->nHeight)))); + } + } + return obj; + } + if (strCommand == "count") return (int)vecMasternodes.size(); + + if (strCommand == "start") + { + if(!fMasterNode) return "you must set masternode=1 in the configuration"; + + if(pwalletMain->IsLocked()) { + SecureString strWalletPass; + strWalletPass.reserve(100); + + if (params.size() == 2){ + strWalletPass = params[1].get_str().c_str(); + } else { + throw runtime_error( + "Your wallet is locked, passphrase is required\n"); + } + + if(!pwalletMain->Unlock(strWalletPass)){ + return "incorrect passphrase"; + } + } + + if(activeMasternode.status != MASTERNODE_REMOTELY_ENABLED && activeMasternode.status != MASTERNODE_IS_CAPABLE){ + activeMasternode.status = MASTERNODE_NOT_PROCESSED; // TODO: consider better way + std::string errorMessage; + activeMasternode.ManageStatus(); + pwalletMain->Lock(); + } + + if(activeMasternode.status == MASTERNODE_REMOTELY_ENABLED) return "masternode started remotely"; + if(activeMasternode.status == MASTERNODE_INPUT_TOO_NEW) return "masternode input must have at least 15 confirmations"; + if(activeMasternode.status == MASTERNODE_STOPPED) return "masternode is stopped"; + if(activeMasternode.status == MASTERNODE_IS_CAPABLE) return "successfully started masternode"; + if(activeMasternode.status == MASTERNODE_NOT_CAPABLE) return "not capable masternode: " + activeMasternode.notCapableReason; + if(activeMasternode.status == MASTERNODE_SYNC_IN_PROCESS) return "sync in process. Must wait until client is synced to start."; + + return "unknown"; + } + + if (strCommand == "start-alias") + { + if (params.size() < 2){ + throw runtime_error( + "command needs at least 2 parameters\n"); + } + + std::string alias = params[1].get_str().c_str(); + + if(pwalletMain->IsLocked()) { + SecureString strWalletPass; + strWalletPass.reserve(100); + + if (params.size() == 3){ + strWalletPass = params[2].get_str().c_str(); + } else { + throw runtime_error( + "Your wallet is locked, passphrase is required\n"); + } + + if(!pwalletMain->Unlock(strWalletPass)){ + return "incorrect passphrase"; + } + } + + bool found = false; + + Object statusObj; + statusObj.push_back(Pair("alias", alias)); + + BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + if(mne.getAlias() == alias) { + found = true; + std::string errorMessage; + bool result = activeMasternode.Register(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), errorMessage); + + statusObj.push_back(Pair("result", result ? "successful" : "failed")); + if(!result) { + statusObj.push_back(Pair("errorMessage", errorMessage)); + } + break; + } + } + + if(!found) { + statusObj.push_back(Pair("result", "failed")); + statusObj.push_back(Pair("errorMessage", "could not find alias in config. Verify with list-conf.")); + } + + pwalletMain->Lock(); + return statusObj; + + } + + if (strCommand == "start-many") + { + if(pwalletMain->IsLocked()) { + SecureString strWalletPass; + strWalletPass.reserve(100); + + if (params.size() == 2){ + strWalletPass = params[1].get_str().c_str(); + } else { + throw runtime_error( + "Your wallet is locked, passphrase is required\n"); + } + + if(!pwalletMain->Unlock(strWalletPass)){ + return "incorrect passphrase"; + } + } + + std::vector mnEntries; + mnEntries = masternodeConfig.getEntries(); + + int total = 0; + int successful = 0; + int fail = 0; + + Object resultsObj; + + BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + total++; + + std::string errorMessage; + bool result = activeMasternode.Register(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), errorMessage); + + Object statusObj; + statusObj.push_back(Pair("alias", mne.getAlias())); + statusObj.push_back(Pair("result", result ? "succesful" : "failed")); + + if(result) { + successful++; + } else { + fail++; + statusObj.push_back(Pair("errorMessage", errorMessage)); + } + + resultsObj.push_back(Pair("status", statusObj)); + } + pwalletMain->Lock(); + + Object returnObj; + returnObj.push_back(Pair("overall", "Successfully started " + boost::lexical_cast(successful) + " masternodes, failed to start " + + boost::lexical_cast(fail) + ", total " + boost::lexical_cast(total))); + returnObj.push_back(Pair("detail", resultsObj)); + + return returnObj; + } + + if (strCommand == "debug") + { + if(activeMasternode.status == MASTERNODE_REMOTELY_ENABLED) return "masternode started remotely"; + if(activeMasternode.status == MASTERNODE_INPUT_TOO_NEW) return "masternode input must have at least 15 confirmations"; + if(activeMasternode.status == MASTERNODE_IS_CAPABLE) return "successfully started masternode"; + if(activeMasternode.status == MASTERNODE_STOPPED) return "masternode is stopped"; + if(activeMasternode.status == MASTERNODE_NOT_CAPABLE) return "not capable masternode: " + activeMasternode.notCapableReason; + if(activeMasternode.status == MASTERNODE_SYNC_IN_PROCESS) return "sync in process. Must wait until client is synced to start."; + + CTxIn vin = CTxIn(); + CPubKey pubkey = CScript(); + CKey key; + bool found = activeMasternode.GetMasterNodeVin(vin, pubkey, key); + if(!found){ + return "Missing masternode input, please look at the documentation for instructions on masternode creation"; + } else { + return "No problems were found"; + } + } + + if (strCommand == "create") + { + + return "Not implemented yet, please look at the documentation for instructions on masternode creation"; + } + + if (strCommand == "current") + { + int winner = GetCurrentMasterNode(1); + if(winner >= 0) { + return vecMasternodes[winner].addr.ToString().c_str(); + } + + return "unknown"; + } + + if (strCommand == "genkey") + { + CKey secret; + secret.MakeNewKey(false); + + return CBitcoinSecret(secret).ToString(); + } + + if (strCommand == "winners") + { + Object obj; + + for(int nHeight = pindexBest->nHeight-10; nHeight < pindexBest->nHeight+20; nHeight++) + { + CScript payee; + if(masternodePayments.GetBlockPayee(nHeight, payee)){ + CTxDestination address1; + ExtractDestination(payee, address1); + CBitcoinAddress address2(address1); + obj.push_back(Pair(boost::lexical_cast(nHeight), address2.ToString().c_str())); + } else { + obj.push_back(Pair(boost::lexical_cast(nHeight), "")); + } + } + + return obj; + } + + if(strCommand == "enforce") + { + return (uint64_t)enforceMasternodePaymentsTime; + } + + if(strCommand == "connect") + { + std::string strAddress = ""; + if (params.size() == 2){ + strAddress = params[1].get_str().c_str(); + } else { + throw runtime_error( + "Masternode address required\n"); + } + + CService addr = CService(strAddress); + + if(ConnectNode((CAddress)addr, NULL, true)){ + return "successfully connected"; + } else { + return "error connecting"; + } + } + + if(strCommand == "list-conf") + { + std::vector mnEntries; + mnEntries = masternodeConfig.getEntries(); + + Object resultObj; + + BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + Object mnObj; + mnObj.push_back(Pair("alias", mne.getAlias())); + mnObj.push_back(Pair("address", mne.getIp())); + mnObj.push_back(Pair("privateKey", mne.getPrivKey())); + mnObj.push_back(Pair("txHash", mne.getTxHash())); + mnObj.push_back(Pair("outputIndex", mne.getOutputIndex())); + resultObj.push_back(Pair("masternode", mnObj)); + } + + return resultObj; + } + + if (strCommand == "outputs"){ + // Find possible candidates + vector possibleCoins = activeMasternode.SelectCoinsMasternode(); + + Object obj; + BOOST_FOREACH(COutput& out, possibleCoins) { + obj.push_back(Pair(out.tx->GetHash().ToString().c_str(), boost::lexical_cast(out.i))); + } + + return obj; + + } + + return Value::null; +} + diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp new file mode 100644 index 0000000..750e280 --- /dev/null +++ b/src/rpcdump.cpp @@ -0,0 +1,324 @@ +// Copyright (c) 2009-2012 Bitcoin Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include + +#include "init.h" // for pwalletMain +#include "rpcserver.h" +#include "ui_interface.h" +#include "base58.h" + +#include +#include +#include + +using namespace json_spirit; +using namespace std; + +void EnsureWalletIsUnlocked(); + +namespace bt = boost::posix_time; + +// Extended DecodeDumpTime implementation, see this page for details: +// http://stackoverflow.com/questions/3786201/parsing-of-date-time-from-string-boost +const std::locale formats[] = { + std::locale(std::locale::classic(),new bt::time_input_facet("%Y-%m-%dT%H:%M:%SZ")), + std::locale(std::locale::classic(),new bt::time_input_facet("%Y-%m-%d %H:%M:%S")), + std::locale(std::locale::classic(),new bt::time_input_facet("%Y/%m/%d %H:%M:%S")), + std::locale(std::locale::classic(),new bt::time_input_facet("%d.%m.%Y %H:%M:%S")), + std::locale(std::locale::classic(),new bt::time_input_facet("%Y-%m-%d")) +}; + +const size_t formats_n = sizeof(formats)/sizeof(formats[0]); + +std::time_t pt_to_time_t(const bt::ptime& pt) +{ + bt::ptime timet_start(boost::gregorian::date(1970,1,1)); + bt::time_duration diff = pt - timet_start; + return diff.ticks()/bt::time_duration::rep_type::ticks_per_second; +} + +int64_t DecodeDumpTime(const std::string& s) +{ + bt::ptime pt; + + for(size_t i=0; i> pt; + if(pt != bt::ptime()) break; + } + + return pt_to_time_t(pt); +} + +std::string static EncodeDumpTime(int64_t nTime) { + return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime); +} + +std::string static EncodeDumpString(const std::string &str) { + std::stringstream ret; + BOOST_FOREACH(unsigned char c, str) { + if (c <= 32 || c >= 128 || c == '%') { + ret << '%' << HexStr(&c, &c + 1); + } else { + ret << c; + } + } + return ret.str(); +} + +std::string DecodeDumpString(const std::string &str) { + std::stringstream ret; + for (unsigned int pos = 0; pos < str.length(); pos++) { + unsigned char c = str[pos]; + if (c == '%' && pos+2 < str.length()) { + c = (((str[pos+1]>>6)*9+((str[pos+1]-'0')&15)) << 4) | + ((str[pos+2]>>6)*9+((str[pos+2]-'0')&15)); + pos += 2; + } + ret << c; + } + return ret.str(); +} + +class CTxDump +{ +public: + CBlockIndex *pindex; + int64_t nValue; + bool fSpent; + CWalletTx* ptx; + int nOut; + CTxDump(CWalletTx* ptx = NULL, int nOut = -1) + { + pindex = NULL; + nValue = 0; + fSpent = false; + this->ptx = ptx; + this->nOut = nOut; + } +}; + +Value importprivkey(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 3) + throw runtime_error( + "importprivkey [label] [rescan=true]\n" + "Adds a private key (as returned by dumpprivkey) to your wallet."); + + string strSecret = params[0].get_str(); + string strLabel = ""; + if (params.size() > 1) + strLabel = params[1].get_str(); + + // Whether to perform rescan after import + bool fRescan = true; + if (params.size() > 2) + fRescan = params[2].get_bool(); + + CBitcoinSecret vchSecret; + bool fGood = vchSecret.SetString(strSecret); + + if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); + if (fWalletUnlockStakingOnly) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Wallet is unlocked for staking only."); + + CKey key = vchSecret.GetKey(); + CPubKey pubkey = key.GetPubKey(); + CKeyID vchAddress = pubkey.GetID(); + { + LOCK2(cs_main, pwalletMain->cs_wallet); + + pwalletMain->MarkDirty(); + pwalletMain->SetAddressBookName(vchAddress, strLabel); + + // Don't throw error in case a key is already there + if (pwalletMain->HaveKey(vchAddress)) + return Value::null; + + pwalletMain->mapKeyMetadata[vchAddress].nCreateTime = 1; + + if (!pwalletMain->AddKeyPubKey(key, pubkey)) + throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet"); + + // whenever a key is imported, we need to scan the whole chain + pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value' + + if (fRescan) { + pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true); + pwalletMain->ReacceptWalletTransactions(); + } + } + + return Value::null; +} + +Value importwallet(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "importwallet \n" + "Imports keys from a wallet dump file (see dumpwallet)."); + + EnsureWalletIsUnlocked(); + + ifstream file; + file.open(params[0].get_str().c_str()); + if (!file.is_open()) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); + + int64_t nTimeBegin = pindexBest->nTime; + + bool fGood = true; + + while (file.good()) { + std::string line; + std::getline(file, line); + if (line.empty() || line[0] == '#') + continue; + + std::vector vstr; + boost::split(vstr, line, boost::is_any_of(" ")); + if (vstr.size() < 2) + continue; + CBitcoinSecret vchSecret; + if (!vchSecret.SetString(vstr[0])) + continue; + CKey key = vchSecret.GetKey(); + CPubKey pubkey = key.GetPubKey(); + CKeyID keyid = pubkey.GetID(); + if (pwalletMain->HaveKey(keyid)) { + LogPrintf("Skipping import of %s (key already present)\n", CBitcoinAddress(keyid).ToString()); + continue; + } + int64_t nTime = DecodeDumpTime(vstr[1]); + std::string strLabel; + bool fLabel = true; + for (unsigned int nStr = 2; nStr < vstr.size(); nStr++) { + if (boost::algorithm::starts_with(vstr[nStr], "#")) + break; + if (vstr[nStr] == "change=1") + fLabel = false; + if (vstr[nStr] == "reserve=1") + fLabel = false; + if (boost::algorithm::starts_with(vstr[nStr], "label=")) { + strLabel = DecodeDumpString(vstr[nStr].substr(6)); + fLabel = true; + } + } + LogPrintf("Importing %s...\n", CBitcoinAddress(keyid).ToString()); + if (!pwalletMain->AddKey(key)) { + fGood = false; + continue; + } + pwalletMain->mapKeyMetadata[keyid].nCreateTime = nTime; + if (fLabel) + pwalletMain->SetAddressBookName(keyid, strLabel); + nTimeBegin = std::min(nTimeBegin, nTime); + } + file.close(); + + CBlockIndex *pindex = pindexBest; + while (pindex && pindex->pprev && pindex->nTime > nTimeBegin - 7200) + pindex = pindex->pprev; + + if (!pwalletMain->nTimeFirstKey || nTimeBegin < pwalletMain->nTimeFirstKey) + pwalletMain->nTimeFirstKey = nTimeBegin; + + LogPrintf("Rescanning last %i blocks\n", pindexBest->nHeight - pindex->nHeight + 1); + pwalletMain->ScanForWalletTransactions(pindex); + pwalletMain->ReacceptWalletTransactions(); + pwalletMain->MarkDirty(); + + if (!fGood) + throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet"); + + return Value::null; +} + + +Value dumpprivkey(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "dumpprivkey \n" + "Reveals the private key corresponding to ."); + + EnsureWalletIsUnlocked(); + + string strAddress = params[0].get_str(); + CBitcoinAddress address; + if (!address.SetString(strAddress)) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid SONO address"); + if (fWalletUnlockStakingOnly) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Wallet is unlocked for staking only."); + CKeyID keyID; + if (!address.GetKeyID(keyID)) + throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); + CKey vchSecret; + if (!pwalletMain->GetKey(keyID, vchSecret)) + throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); + return CBitcoinSecret(vchSecret).ToString(); +} + +Value dumpwallet(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "dumpwallet \n" + "Dumps all wallet keys in a human-readable format."); + + EnsureWalletIsUnlocked(); + + ofstream file; + file.open(params[0].get_str().c_str()); + if (!file.is_open()) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); + + std::map mapKeyBirth; + + std::set setKeyPool; + + pwalletMain->GetKeyBirthTimes(mapKeyBirth); + + pwalletMain->GetAllReserveKeys(setKeyPool); + + // sort time/key pairs + std::vector > vKeyBirth; + for (std::map::const_iterator it = mapKeyBirth.begin(); it != mapKeyBirth.end(); it++) { + vKeyBirth.push_back(std::make_pair(it->second, it->first)); + } + mapKeyBirth.clear(); + std::sort(vKeyBirth.begin(), vKeyBirth.end()); + + // produce output + file << strprintf("# Wallet dump created by SONO %s (%s)\n", CLIENT_BUILD, CLIENT_DATE); + file << strprintf("# * Created on %s\n", EncodeDumpTime(GetTime())); + file << strprintf("# * Best block at time of backup was %i (%s),\n", nBestHeight, hashBestChain.ToString()); + file << strprintf("# mined on %s\n", EncodeDumpTime(pindexBest->nTime)); + file << "\n"; + for (std::vector >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) { + const CKeyID &keyid = it->second; + std::string strTime = EncodeDumpTime(it->first); + std::string strAddr = CBitcoinAddress(keyid).ToString(); + + CKey key; + if (pwalletMain->GetKey(keyid, key)) { + if (pwalletMain->mapAddressBook.count(keyid)) { + file << strprintf("%s %s label=%s # addr=%s\n", CBitcoinSecret(key).ToString(), strTime, EncodeDumpString(pwalletMain->mapAddressBook[keyid]), strAddr); + } else if (setKeyPool.count(keyid)) { + file << strprintf("%s %s reserve=1 # addr=%s\n", CBitcoinSecret(key).ToString(), strTime, strAddr); + } else { + file << strprintf("%s %s change=1 # addr=%s\n", CBitcoinSecret(key).ToString(), strTime, strAddr); + } + } + } + file << "\n"; + file << "# End of dump\n"; + file.close(); + return Value::null; +} diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp new file mode 100644 index 0000000..0efe467 --- /dev/null +++ b/src/rpcmining.cpp @@ -0,0 +1,666 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "rpcserver.h" +#include "chainparams.h" +#include "main.h" +#include "db.h" +#include "txdb.h" +#include "init.h" +#include "miner.h" +#include "kernel.h" + +#include + +using namespace json_spirit; +using namespace std; +using namespace boost::assign; + +// Key used by getwork/getblocktemplate miners. +// Allocated in InitRPCMining, free'd in ShutdownRPCMining +static CReserveKey* pMiningKey = NULL; + +void InitRPCMining() +{ + if (!pwalletMain) + return; + + // getwork/getblocktemplate mining rewards paid here: + pMiningKey = new CReserveKey(pwalletMain); +} + +void ShutdownRPCMining() +{ + if (!pMiningKey) + return; + + delete pMiningKey; pMiningKey = NULL; +} + +Value getsubsidy(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "getsubsidy [nTarget]\n" + "Returns proof-of-work subsidy value for the specified value of target."); + + return (uint64_t)GetProofOfWorkReward(0); +} + +Value getstakesubsidy(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getstakesubsidy \n" + "Returns proof-of-stake subsidy value for the specified coinstake."); + + RPCTypeCheck(params, list_of(str_type)); + + vector txData(ParseHex(params[0].get_str())); + CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); + CTransaction tx; + try { + ssData >> tx; + } + catch (std::exception &e) { + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); + } + + uint64_t nCoinAge; + CTxDB txdb("r"); + if (!tx.GetCoinAge(txdb, nCoinAge)) + throw JSONRPCError(RPC_MISC_ERROR, "GetCoinAge failed"); + + return (uint64_t)GetProofOfStakeReward(pindexBest, nCoinAge, 0); +} + +Value getmininginfo(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getmininginfo\n" + "Returns an object containing mining-related information."); + + uint64_t nWeight = 0; + if (pwalletMain) + nWeight = pwalletMain->GetStakeWeight(); + + Object obj, diff, weight; + obj.push_back(Pair("blocks", (int)nBestHeight)); + obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize)); + obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx)); + + diff.push_back(Pair("proof-of-work", GetDifficulty())); + diff.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); + diff.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval)); + obj.push_back(Pair("difficulty", diff)); + + obj.push_back(Pair("blockvalue", (uint64_t)GetProofOfWorkReward(0))); + obj.push_back(Pair("netmhashps", GetPoWMHashPS())); + obj.push_back(Pair("netstakeweight", GetPoSKernelPS())); + obj.push_back(Pair("errors", GetWarnings("statusbar"))); + obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); + + weight.push_back(Pair("minimum", (uint64_t)nWeight)); + weight.push_back(Pair("maximum", (uint64_t)0)); + weight.push_back(Pair("combined", (uint64_t)nWeight)); + obj.push_back(Pair("stakeweight", weight)); + + obj.push_back(Pair("testnet", TestNet())); + return obj; +} + +Value getstakinginfo(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getstakinginfo\n" + "Returns an object containing staking-related information."); + + uint64_t nWeight = 0; + if (pwalletMain) + nWeight = pwalletMain->GetStakeWeight(); + + uint64_t nNetworkWeight = GetPoSKernelPS(); + bool staking = nLastCoinStakeSearchInterval && nWeight; + uint64_t nExpectedTime = staking ? (GetTargetSpacing(nBestHeight) * nNetworkWeight / nWeight) : 0; + + Object obj; + + obj.push_back(Pair("enabled", GetBoolArg("-staking", true))); + obj.push_back(Pair("staking", staking)); + obj.push_back(Pair("errors", GetWarnings("statusbar"))); + + obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize)); + obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); + obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); + + obj.push_back(Pair("difficulty", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); + obj.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval)); + + obj.push_back(Pair("weight", (uint64_t)nWeight)); + obj.push_back(Pair("netstakeweight", (uint64_t)nNetworkWeight)); + + obj.push_back(Pair("expectedtime", nExpectedTime)); + + return obj; +} + +Value checkkernel(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "checkkernel [{\"txid\":txid,\"vout\":n},...] [createblocktemplate=false]\n" + "Check if one of given inputs is a kernel input at the moment.\n" + ); + + RPCTypeCheck(params, list_of(array_type)(bool_type)); + + Array inputs = params[0].get_array(); + bool fCreateBlockTemplate = params.size() > 1 ? params[1].get_bool() : false; + + if (vNodes.empty()) + throw JSONRPCError(-9, "SONO is not connected!"); + + if (IsInitialBlockDownload()) + throw JSONRPCError(-10, "SONO is downloading blocks..."); + + COutPoint kernel; + CBlockIndex* pindexPrev = pindexBest; + unsigned int nBits = GetNextTargetRequired(pindexPrev, true); + int64_t nTime = GetAdjustedTime(); + nTime &= ~STAKE_TIMESTAMP_MASK; + + BOOST_FOREACH(Value& input, inputs) + { + const Object& o = input.get_obj(); + + const Value& txid_v = find_value(o, "txid"); + if (txid_v.type() != str_type) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing txid key"); + string txid = txid_v.get_str(); + if (!IsHex(txid)) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected hex txid"); + + const Value& vout_v = find_value(o, "vout"); + if (vout_v.type() != int_type) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key"); + int nOutput = vout_v.get_int(); + if (nOutput < 0) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive"); + + COutPoint cInput(uint256(txid), nOutput); + if (CheckKernel(pindexPrev, nBits, nTime, cInput)) + { + kernel = cInput; + break; + } + } + + Object result; + result.push_back(Pair("found", !kernel.IsNull())); + + if (kernel.IsNull()) + return result; + + Object oKernel; + oKernel.push_back(Pair("txid", kernel.hash.GetHex())); + oKernel.push_back(Pair("vout", (int64_t)kernel.n)); + oKernel.push_back(Pair("time", nTime)); + result.push_back(Pair("kernel", oKernel)); + + if (!fCreateBlockTemplate) + return result; + + int64_t nFees; + auto_ptr pblock(CreateNewBlock(*pMiningKey, true, &nFees)); + + pblock->nTime = pblock->vtx[0].nTime = nTime; + + CDataStream ss(SER_DISK, PROTOCOL_VERSION); + ss << *pblock; + + result.push_back(Pair("blocktemplate", HexStr(ss.begin(), ss.end()))); + result.push_back(Pair("blocktemplatefees", nFees)); + + CPubKey pubkey; + if (!pMiningKey->GetReservedKey(pubkey)) + throw JSONRPCError(RPC_MISC_ERROR, "GetReservedKey failed"); + + result.push_back(Pair("blocktemplatesignkey", HexStr(pubkey))); + + return result; +} + +Value getworkex(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 2) + throw runtime_error( + "getworkex [data, coinbase]\n" + "If [data, coinbase] is not specified, returns extended work data.\n" + ); + + if (vNodes.empty()) + throw JSONRPCError(-9, "SONO is not connected!"); + + if (IsInitialBlockDownload()) + throw JSONRPCError(-10, "SONO is downloading blocks..."); + + if (pindexBest->nHeight >= Params().LastPOWBlock()) + throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); + + typedef map > mapNewBlock_t; + static mapNewBlock_t mapNewBlock; + static vector vNewBlock; + + if (params.size() == 0) + { + // Update block + static unsigned int nTransactionsUpdatedLast; + static CBlockIndex* pindexPrev; + static int64_t nStart; + static CBlock* pblock; + if (pindexPrev != pindexBest || + (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)) + { + if (pindexPrev != pindexBest) + { + // Deallocate old blocks since they're obsolete now + mapNewBlock.clear(); + BOOST_FOREACH(CBlock* pblock, vNewBlock) + delete pblock; + vNewBlock.clear(); + } + nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); + pindexPrev = pindexBest; + nStart = GetTime(); + + // Create new block + pblock = CreateNewBlock(*pMiningKey); + if (!pblock) + throw JSONRPCError(-7, "Out of memory"); + vNewBlock.push_back(pblock); + } + + // Update nTime + pblock->nTime = max(pindexPrev->GetPastTimeLimit()+1, GetAdjustedTime()); + pblock->nNonce = 0; + + // Update nExtraNonce + static unsigned int nExtraNonce = 0; + IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); + + // Save + mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig); + + // Prebuild hash buffers + char pmidstate[32]; + char pdata[128]; + char phash1[64]; + FormatHashBuffers(pblock, pmidstate, pdata, phash1); + + uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); + + CTransaction coinbaseTx = pblock->vtx[0]; + std::vector merkle = pblock->GetMerkleBranch(0); + + Object result; + result.push_back(Pair("data", HexStr(BEGIN(pdata), END(pdata)))); + result.push_back(Pair("target", HexStr(BEGIN(hashTarget), END(hashTarget)))); + + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << coinbaseTx; + result.push_back(Pair("coinbase", HexStr(ssTx.begin(), ssTx.end()))); + + Array merkle_arr; + + BOOST_FOREACH(uint256 merkleh, merkle) { + merkle_arr.push_back(HexStr(BEGIN(merkleh), END(merkleh))); + } + + result.push_back(Pair("merkle", merkle_arr)); + + + return result; + } + else + { + // Parse parameters + vector vchData = ParseHex(params[0].get_str()); + vector coinbase; + + if(params.size() == 2) + coinbase = ParseHex(params[1].get_str()); + + if (vchData.size() != 128) + throw JSONRPCError(-8, "Invalid parameter"); + + CBlock* pdata = (CBlock*)&vchData[0]; + + // Byte reverse + for (int i = 0; i < 128/4; i++) + ((unsigned int*)pdata)[i] = ByteReverse(((unsigned int*)pdata)[i]); + + // Get saved block + if (!mapNewBlock.count(pdata->hashMerkleRoot)) + return false; + CBlock* pblock = mapNewBlock[pdata->hashMerkleRoot].first; + + pblock->nTime = pdata->nTime; + pblock->nNonce = pdata->nNonce; + + if(coinbase.size() == 0) + pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second; + else + CDataStream(coinbase, SER_NETWORK, PROTOCOL_VERSION) >> pblock->vtx[0]; // FIXME - HACK! + + pblock->hashMerkleRoot = pblock->BuildMerkleTree(); + + assert(pwalletMain != NULL); + return CheckWork(pblock, *pwalletMain, *pMiningKey); + } +} + + +Value getwork(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "getwork [data]\n" + "If [data] is not specified, returns formatted hash data to work on:\n" + " \"midstate\" : precomputed hash state after hashing the first half of the data (DEPRECATED)\n" // deprecated + " \"data\" : block data\n" + " \"hash1\" : formatted hash buffer for second hash (DEPRECATED)\n" // deprecated + " \"target\" : little endian hash target\n" + "If [data] is specified, tries to solve the block and returns true if it was successful."); + + if (vNodes.empty()) + throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "SONO is not connected!"); + + if (IsInitialBlockDownload()) + throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "SONO is downloading blocks..."); + + if (pindexBest->nHeight >= Params().LastPOWBlock()) + throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); + + typedef map > mapNewBlock_t; + static mapNewBlock_t mapNewBlock; // FIXME: thread safety + static vector vNewBlock; + + if (params.size() == 0) + { + // Update block + static unsigned int nTransactionsUpdatedLast; + static CBlockIndex* pindexPrev; + static int64_t nStart; + static CBlock* pblock; + if (pindexPrev != pindexBest || + (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)) + { + if (pindexPrev != pindexBest) + { + // Deallocate old blocks since they're obsolete now + mapNewBlock.clear(); + BOOST_FOREACH(CBlock* pblock, vNewBlock) + delete pblock; + vNewBlock.clear(); + } + + // Clear pindexPrev so future getworks make a new block, despite any failures from here on + pindexPrev = NULL; + + // Store the pindexBest used before CreateNewBlock, to avoid races + nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); + CBlockIndex* pindexPrevNew = pindexBest; + nStart = GetTime(); + + // Create new block + pblock = CreateNewBlock(*pMiningKey); + if (!pblock) + throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); + vNewBlock.push_back(pblock); + + // Need to update only after we know CreateNewBlock succeeded + pindexPrev = pindexPrevNew; + } + + // Update nTime + pblock->UpdateTime(pindexPrev); + pblock->nNonce = 0; + + // Update nExtraNonce + static unsigned int nExtraNonce = 0; + IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); + + // Save + mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig); + + // Pre-build hash buffers + char pmidstate[32]; + char pdata[128]; + char phash1[64]; + FormatHashBuffers(pblock, pmidstate, pdata, phash1); + + uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); + + Object result; + result.push_back(Pair("midstate", HexStr(BEGIN(pmidstate), END(pmidstate)))); // deprecated + result.push_back(Pair("data", HexStr(BEGIN(pdata), END(pdata)))); + result.push_back(Pair("hash1", HexStr(BEGIN(phash1), END(phash1)))); // deprecated + result.push_back(Pair("target", HexStr(BEGIN(hashTarget), END(hashTarget)))); + return result; + } + else + { + // Parse parameters + vector vchData = ParseHex(params[0].get_str()); + if (vchData.size() != 128) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter"); + CBlock* pdata = (CBlock*)&vchData[0]; + + // Byte reverse + for (int i = 0; i < 128/4; i++) + ((unsigned int*)pdata)[i] = ByteReverse(((unsigned int*)pdata)[i]); + + // Get saved block + if (!mapNewBlock.count(pdata->hashMerkleRoot)) + return false; + CBlock* pblock = mapNewBlock[pdata->hashMerkleRoot].first; + + pblock->nTime = pdata->nTime; + pblock->nNonce = pdata->nNonce; + pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second; + pblock->hashMerkleRoot = pblock->BuildMerkleTree(); + + assert(pwalletMain != NULL); + return CheckWork(pblock, *pwalletMain, *pMiningKey); + } +} + + +Value getblocktemplate(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "getblocktemplate [params]\n" + "Returns data needed to construct a block to work on:\n" + " \"version\" : block version\n" + " \"previousblockhash\" : hash of current highest block\n" + " \"transactions\" : contents of non-coinbase transactions that should be included in the next block\n" + " \"coinbaseaux\" : data that should be included in coinbase\n" + " \"coinbasevalue\" : maximum allowable input to coinbase transaction, including the generation award and transaction fees\n" + " \"target\" : hash target\n" + " \"mintime\" : minimum timestamp appropriate for next block\n" + " \"curtime\" : current timestamp\n" + " \"mutable\" : list of ways the block template may be changed\n" + " \"noncerange\" : range of valid nonces\n" + " \"sigoplimit\" : limit of sigops in blocks\n" + " \"sizelimit\" : limit of block size\n" + " \"bits\" : compressed target of next block\n" + " \"height\" : height of the next block\n" + "See https://en.bitcoin.it/wiki/BIP_0022 for full specification."); + + std::string strMode = "template"; + if (params.size() > 0) + { + const Object& oparam = params[0].get_obj(); + const Value& modeval = find_value(oparam, "mode"); + if (modeval.type() == str_type) + strMode = modeval.get_str(); + else if (modeval.type() == null_type) + { + /* Do nothing */ + } + else + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); + } + + if (strMode != "template") + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); + + if (vNodes.empty()) + throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "SONO is not connected!"); + + //if (IsInitialBlockDownload()) + // throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "SONO is downloading blocks..."); + + if (pindexBest->nHeight >= Params().LastPOWBlock()) + throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); + + // Update block + static unsigned int nTransactionsUpdatedLast; + static CBlockIndex* pindexPrev; + static int64_t nStart; + static CBlock* pblock; + if (pindexPrev != pindexBest || + (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 5)) + { + // Clear pindexPrev so future calls make a new block, despite any failures from here on + pindexPrev = NULL; + + // Store the pindexBest used before CreateNewBlock, to avoid races + nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); + CBlockIndex* pindexPrevNew = pindexBest; + nStart = GetTime(); + + // Create new block + if(pblock) + { + delete pblock; + pblock = NULL; + } + pblock = CreateNewBlock(*pMiningKey); + if (!pblock) + throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); + + // Need to update only after we know CreateNewBlock succeeded + pindexPrev = pindexPrevNew; + } + + // Update nTime + pblock->UpdateTime(pindexPrev); + pblock->nNonce = 0; + + Array transactions; + map setTxIndex; + int i = 0; + CTxDB txdb("r"); + BOOST_FOREACH (CTransaction& tx, pblock->vtx) + { + uint256 txHash = tx.GetHash(); + setTxIndex[txHash] = i++; + + if (tx.IsCoinBase() || tx.IsCoinStake()) + continue; + + Object entry; + + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << tx; + entry.push_back(Pair("data", HexStr(ssTx.begin(), ssTx.end()))); + + entry.push_back(Pair("hash", txHash.GetHex())); + + MapPrevTx mapInputs; + map mapUnused; + bool fInvalid = false; + if (tx.FetchInputs(txdb, mapUnused, false, false, mapInputs, fInvalid)) + { + entry.push_back(Pair("fee", (int64_t)(tx.GetValueIn(mapInputs) - tx.GetValueOut()))); + + Array deps; + BOOST_FOREACH (MapPrevTx::value_type& inp, mapInputs) + { + if (setTxIndex.count(inp.first)) + deps.push_back(setTxIndex[inp.first]); + } + entry.push_back(Pair("depends", deps)); + + int64_t nSigOps = GetLegacySigOpCount(tx); + nSigOps += GetP2SHSigOpCount(tx, mapInputs); + entry.push_back(Pair("sigops", nSigOps)); + } + + transactions.push_back(entry); + } + + Object aux; + aux.push_back(Pair("flags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end()))); + + uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); + + static Array aMutable; + if (aMutable.empty()) + { + aMutable.push_back("time"); + aMutable.push_back("transactions"); + aMutable.push_back("prevblock"); + } + + Object result; + result.push_back(Pair("version", pblock->nVersion)); + result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); + result.push_back(Pair("transactions", transactions)); + result.push_back(Pair("coinbaseaux", aux)); + result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); + result.push_back(Pair("target", hashTarget.GetHex())); + result.push_back(Pair("mintime", (int64_t)pindexPrev->GetPastTimeLimit()+1)); + result.push_back(Pair("mutable", aMutable)); + result.push_back(Pair("noncerange", "00000000ffffffff")); + result.push_back(Pair("sigoplimit", (int64_t)MAX_BLOCK_SIGOPS)); + result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SIZE)); + result.push_back(Pair("curtime", (int64_t)pblock->nTime)); + result.push_back(Pair("bits", strprintf("%08x", pblock->nBits))); + result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1))); + + return result; +} + +Value submitblock(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "submitblock [optional-params-obj]\n" + "[optional-params-obj] parameter is currently ignored.\n" + "Attempts to submit new block to network.\n" + "See https://en.bitcoin.it/wiki/BIP_0022 for full specification."); + + vector blockData(ParseHex(params[0].get_str())); + CDataStream ssBlock(blockData, SER_NETWORK, PROTOCOL_VERSION); + CBlock block; + try { + ssBlock >> block; + } + catch (std::exception &e) { + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed"); + } + + bool fAccepted = ProcessBlock(NULL, &block); + if (!fAccepted) + return "rejected"; + + return Value::null; +} + diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp new file mode 100644 index 0000000..c46e415 --- /dev/null +++ b/src/rpcmisc.cpp @@ -0,0 +1,267 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "base58.h" +#include "init.h" +#include "main.h" +#include "net.h" +#include "netbase.h" +#include "rpcserver.h" +#include "timedata.h" +#include "util.h" +#include "stealth.h" +#include "spork.h" +#ifdef ENABLE_WALLET +#include "wallet.h" +#include "walletdb.h" +#endif + +#include + +#include +#include "json/json_spirit_utils.h" +#include "json/json_spirit_value.h" + +using namespace std; +using namespace boost; +using namespace boost::assign; +using namespace json_spirit; + +Value getinfo(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getinfo\n" + "Returns an object containing various state info."); + + proxyType proxy; + GetProxy(NET_IPV4, proxy); + + Object obj, diff; + obj.push_back(Pair("version", FormatFullVersion())); + obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION)); +#ifdef ENABLE_WALLET + if (pwalletMain) { + obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); + obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); + obj.push_back(Pair("newmint", ValueFromAmount(pwalletMain->GetNewMint()))); + obj.push_back(Pair("stake", ValueFromAmount(pwalletMain->GetStake()))); + } +#endif + obj.push_back(Pair("blocks", (int)nBestHeight)); + obj.push_back(Pair("timeoffset", (int64_t)GetTimeOffset())); + obj.push_back(Pair("moneysupply", ValueFromAmount(pindexBest->nMoneySupply))); + obj.push_back(Pair("connections", (int)vNodes.size())); + obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.ToStringIPPort() : string()))); + obj.push_back(Pair("ip", GetLocalAddress(NULL).ToStringIP())); + + diff.push_back(Pair("proof-of-work", GetDifficulty())); + diff.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); + obj.push_back(Pair("difficulty", diff)); + + obj.push_back(Pair("testnet", TestNet())); +#ifdef ENABLE_WALLET + if (pwalletMain) { + obj.push_back(Pair("keypoololdest", (int64_t)pwalletMain->GetOldestKeyPoolTime())); + obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); + } + obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee))); + obj.push_back(Pair("mininput", ValueFromAmount(nMinimumInputValue))); + if (pwalletMain && pwalletMain->IsCrypted()) + obj.push_back(Pair("unlocked_until", (int64_t)nWalletUnlockTime)); +#endif + obj.push_back(Pair("errors", GetWarnings("statusbar"))); + return obj; +} + +#ifdef ENABLE_WALLET +class DescribeAddressVisitor : public boost::static_visitor +{ +public: + Object operator()(const CNoDestination &dest) const { return Object(); } + + Object operator()(const CKeyID &keyID) const { + Object obj; + CPubKey vchPubKey; + pwalletMain->GetPubKey(keyID, vchPubKey); + obj.push_back(Pair("isscript", false)); + obj.push_back(Pair("pubkey", HexStr(vchPubKey))); + obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); + return obj; + } + + Object operator()(const CScriptID &scriptID) const { + Object obj; + obj.push_back(Pair("isscript", true)); + CScript subscript; + pwalletMain->GetCScript(scriptID, subscript); + std::vector addresses; + txnouttype whichType; + int nRequired; + ExtractDestinations(subscript, whichType, addresses, nRequired); + obj.push_back(Pair("script", GetTxnOutputType(whichType))); + obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); + Array a; + BOOST_FOREACH(const CTxDestination& addr, addresses) + a.push_back(CBitcoinAddress(addr).ToString()); + obj.push_back(Pair("addresses", a)); + if (whichType == TX_MULTISIG) + obj.push_back(Pair("sigsrequired", nRequired)); + return obj; + } + + Object operator()(const CStealthAddress &stxAddr) const { + Object obj; + obj.push_back(Pair("todo", true)); + return obj; + } +}; +#endif + +Value validateaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "validateaddress \n" + "Return information about ."); + + CBitcoinAddress address(params[0].get_str()); + bool isValid = address.IsValid(); + + Object ret; + ret.push_back(Pair("isvalid", isValid)); + if (isValid) + { + CTxDestination dest = address.Get(); + string currentAddress = address.ToString(); + ret.push_back(Pair("address", currentAddress)); +#ifdef ENABLE_WALLET + bool fMine = pwalletMain ? IsMine(*pwalletMain, dest) : false; + ret.push_back(Pair("ismine", fMine)); + if (fMine) { + Object detail = boost::apply_visitor(DescribeAddressVisitor(), dest); + ret.insert(ret.end(), detail.begin(), detail.end()); + } + if (pwalletMain && pwalletMain->mapAddressBook.count(dest)) + ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest])); +#endif + } + return ret; +} + +Value validatepubkey(const Array& params, bool fHelp) +{ + if (fHelp || !params.size() || params.size() > 2) + throw runtime_error( + "validatepubkey \n" + "Return information about ."); + + std::vector vchPubKey = ParseHex(params[0].get_str()); + CPubKey pubKey(vchPubKey); + + bool isValid = pubKey.IsValid(); + bool isCompressed = pubKey.IsCompressed(); + CKeyID keyID = pubKey.GetID(); + + CBitcoinAddress address; + address.Set(keyID); + + Object ret; + ret.push_back(Pair("isvalid", isValid)); + if (isValid) + { + CTxDestination dest = address.Get(); + string currentAddress = address.ToString(); + ret.push_back(Pair("address", currentAddress)); + ret.push_back(Pair("iscompressed", isCompressed)); +#ifdef ENABLE_WALLET + bool fMine = pwalletMain ? IsMine(*pwalletMain, dest) : false; + ret.push_back(Pair("ismine", fMine)); + if (fMine) { + Object detail = boost::apply_visitor(DescribeAddressVisitor(), dest); + ret.insert(ret.end(), detail.begin(), detail.end()); + } + if (pwalletMain && pwalletMain->mapAddressBook.count(dest)) + ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest])); +#endif + } + return ret; +} + +Value verifymessage(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 3) + throw runtime_error( + "verifymessage \n" + "Verify a signed message"); + + string strAddress = params[0].get_str(); + string strSign = params[1].get_str(); + string strMessage = params[2].get_str(); + + CBitcoinAddress addr(strAddress); + if (!addr.IsValid()) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); + + CKeyID keyID; + if (!addr.GetKeyID(keyID)) + throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); + + bool fInvalid = false; + vector vchSig = DecodeBase64(strSign.c_str(), &fInvalid); + + if (fInvalid) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding"); + + CHashWriter ss(SER_GETHASH, 0); + ss << strMessageMagic; + ss << strMessage; + + CPubKey pubkey; + if (!pubkey.RecoverCompact(ss.GetHash(), vchSig)) + return false; + + return (pubkey.GetID() == keyID); +} + +/* + Used for updating/reading spork settings on the network +*/ +Value spork(const Array& params, bool fHelp) +{ + if(params.size() == 1 && params[0].get_str() == "show"){ + std::map::iterator it = mapSporksActive.begin(); + + Object ret; + while(it != mapSporksActive.end()) { + ret.push_back(Pair(sporkManager.GetSporkNameByID(it->second.nSporkID), it->second.nValue)); + it++; + } + return ret; + } else if (params.size() == 2){ + int nSporkID = sporkManager.GetSporkIDByName(params[0].get_str()); + if(nSporkID == -1){ + return "Invalid spork name"; + } + + // SPORK VALUE + int64_t nValue = params[1].get_int(); + + //broadcast new spork + if(sporkManager.UpdateSpork(nSporkID, nValue)){ + return "success"; + } else { + return "failure"; + } + + } + + throw runtime_error( + "spork []\n" + " is the corresponding spork name, or 'show' to show all current spork settings" + " is a epoch datetime to enable or disable spork" + + HelpRequiringPassphrase()); +} + diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp new file mode 100644 index 0000000..47668fc --- /dev/null +++ b/src/rpcnet.cpp @@ -0,0 +1,315 @@ +// Copyright (c) 2009-2012 Bitcoin Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "rpcserver.h" + +#include "alert.h" +#include "main.h" +#include "net.h" +#include "netbase.h" +#include "protocol.h" +#include "sync.h" +#include "timedata.h" +#include "util.h" + +#include +#include "json/json_spirit_value.h" + +using namespace json_spirit; +using namespace std; + +Value getconnectioncount(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getconnectioncount\n" + "Returns the number of connections to other nodes."); + + LOCK(cs_vNodes); + return (int)vNodes.size(); +} + +Value ping(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "ping\n" + "Requests that a ping be sent to all other nodes, to measure ping time.\n" + "Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.\n" + "Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping."); + + // Request that each node send a ping during next message processing pass + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pNode, vNodes) { + pNode->fPingQueued = true; + } + + return Value::null; +} + +static void CopyNodeStats(std::vector& vstats) +{ + vstats.clear(); + + LOCK(cs_vNodes); + vstats.reserve(vNodes.size()); + BOOST_FOREACH(CNode* pnode, vNodes) { + CNodeStats stats; + pnode->copyStats(stats); + vstats.push_back(stats); + } +} + +Value getpeerinfo(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getpeerinfo\n" + "Returns data about each connected network node."); + + vector vstats; + CopyNodeStats(vstats); + + Array ret; + + BOOST_FOREACH(const CNodeStats& stats, vstats) { + Object obj; + + obj.push_back(Pair("addr", stats.addrName)); + if (!(stats.addrLocal.empty())) + obj.push_back(Pair("addrlocal", stats.addrLocal)); + obj.push_back(Pair("services", strprintf("%08x", stats.nServices))); + obj.push_back(Pair("lastsend", (int64_t)stats.nLastSend)); + obj.push_back(Pair("lastrecv", (int64_t)stats.nLastRecv)); + obj.push_back(Pair("bytessent", (int64_t)stats.nSendBytes)); + obj.push_back(Pair("bytesrecv", (int64_t)stats.nRecvBytes)); + obj.push_back(Pair("conntime", (int64_t)stats.nTimeConnected)); + //obj.push_back(Pair("timeoffset", stats.nTimeOffset)); + obj.push_back(Pair("pingtime", stats.dPingTime)); + if (stats.dPingWait > 0.0) + obj.push_back(Pair("pingwait", stats.dPingWait)); + obj.push_back(Pair("version", stats.nVersion)); + obj.push_back(Pair("subver", stats.strSubVer)); + obj.push_back(Pair("inbound", stats.fInbound)); + obj.push_back(Pair("startingheight", stats.nStartingHeight)); + obj.push_back(Pair("banscore", stats.nMisbehavior)); + obj.push_back(Pair("syncnode", stats.fSyncNode)); + + ret.push_back(obj); + } + + return ret; +} + +Value addnode(const Array& params, bool fHelp) +{ + string strCommand; + if (params.size() == 2) + strCommand = params[1].get_str(); + if (fHelp || params.size() != 2 || + (strCommand != "onetry" && strCommand != "add" && strCommand != "remove")) + throw runtime_error( + "addnode \n" + "Attempts add or remove from the addnode list or try a connection to once."); + + string strNode = params[0].get_str(); + + if (strCommand == "onetry") + { + CAddress addr; + ConnectNode(addr, strNode.c_str()); + return Value::null; + } + + LOCK(cs_vAddedNodes); + vector::iterator it = vAddedNodes.begin(); + for(; it != vAddedNodes.end(); it++) + if (strNode == *it) + break; + + if (strCommand == "add") + { + if (it != vAddedNodes.end()) + throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Node already added"); + vAddedNodes.push_back(strNode); + } + else if(strCommand == "remove") + { + if (it == vAddedNodes.end()) + throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added."); + vAddedNodes.erase(it); + } + + return Value::null; +} + +Value getaddednodeinfo(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "getaddednodeinfo [node]\n" + "Returns information about the given added node, or all added nodes\n" + "(note that onetry addnodes are not listed here)\n" + "If dns is false, only a list of added nodes will be provided,\n" + "otherwise connected information will also be available."); + + bool fDns = params[0].get_bool(); + + list laddedNodes(0); + if (params.size() == 1) + { + LOCK(cs_vAddedNodes); + BOOST_FOREACH(string& strAddNode, vAddedNodes) + laddedNodes.push_back(strAddNode); + } + else + { + string strNode = params[1].get_str(); + LOCK(cs_vAddedNodes); + BOOST_FOREACH(string& strAddNode, vAddedNodes) + if (strAddNode == strNode) + { + laddedNodes.push_back(strAddNode); + break; + } + if (laddedNodes.size() == 0) + throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added."); + } + + if (!fDns) + { + Object ret; + BOOST_FOREACH(string& strAddNode, laddedNodes) + ret.push_back(Pair("addednode", strAddNode)); + return ret; + } + + Array ret; + + list > > laddedAddreses(0); + BOOST_FOREACH(string& strAddNode, laddedNodes) + { + vector vservNode(0); + if(Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0)) + laddedAddreses.push_back(make_pair(strAddNode, vservNode)); + else + { + Object obj; + obj.push_back(Pair("addednode", strAddNode)); + obj.push_back(Pair("connected", false)); + Array addresses; + obj.push_back(Pair("addresses", addresses)); + } + } + + LOCK(cs_vNodes); + for (list > >::iterator it = laddedAddreses.begin(); it != laddedAddreses.end(); it++) + { + Object obj; + obj.push_back(Pair("addednode", it->first)); + + Array addresses; + bool fConnected = false; + BOOST_FOREACH(CService& addrNode, it->second) + { + bool fFound = false; + Object node; + node.push_back(Pair("address", addrNode.ToString())); + BOOST_FOREACH(CNode* pnode, vNodes) + if (pnode->addr == addrNode) + { + fFound = true; + fConnected = true; + node.push_back(Pair("connected", pnode->fInbound ? "inbound" : "outbound")); + break; + } + if (!fFound) + node.push_back(Pair("connected", "false")); + addresses.push_back(node); + } + obj.push_back(Pair("connected", fConnected)); + obj.push_back(Pair("addresses", addresses)); + ret.push_back(obj); + } + + return ret; +} + +// ppcoin: send alert. +// There is a known deadlock situation with ThreadMessageHandler +// ThreadMessageHandler: holds cs_vSend and acquiring cs_main in SendMessages() +// ThreadRPCServer: holds cs_main and acquiring cs_vSend in alert.RelayTo()/PushMessage()/BeginMessage() +Value sendalert(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 6) + throw runtime_error( + "sendalert [cancelupto]\n" + " is the alert text message\n" + " is hex string of alert master private key\n" + " is the minimum applicable internal client version\n" + " is the maximum applicable internal client version\n" + " is integer priority number\n" + " is the alert id\n" + "[cancelupto] cancels all alert id's up to this number\n" + "Returns true or false."); + + CAlert alert; + CKey key; + + alert.strStatusBar = params[0].get_str(); + alert.nMinVer = params[2].get_int(); + alert.nMaxVer = params[3].get_int(); + alert.nPriority = params[4].get_int(); + alert.nID = params[5].get_int(); + if (params.size() > 6) + alert.nCancel = params[6].get_int(); + alert.nVersion = PROTOCOL_VERSION; + alert.nRelayUntil = GetAdjustedTime() + 365*24*60*60; + alert.nExpiration = GetAdjustedTime() + 365*24*60*60; + + CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION); + sMsg << (CUnsignedAlert)alert; + alert.vchMsg = vector(sMsg.begin(), sMsg.end()); + + vector vchPrivKey = ParseHex(params[1].get_str()); + key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end()), false); // if key is not correct openssl may crash + if (!key.Sign(Hash(alert.vchMsg.begin(), alert.vchMsg.end()), alert.vchSig)) + throw runtime_error( + "Unable to sign alert, check private key?\n"); + if(!alert.ProcessAlert()) + throw runtime_error( + "Failed to process alert.\n"); + // Relay alert + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + alert.RelayTo(pnode); + } + + Object result; + result.push_back(Pair("strStatusBar", alert.strStatusBar)); + result.push_back(Pair("nVersion", alert.nVersion)); + result.push_back(Pair("nMinVer", alert.nMinVer)); + result.push_back(Pair("nMaxVer", alert.nMaxVer)); + result.push_back(Pair("nPriority", alert.nPriority)); + result.push_back(Pair("nID", alert.nID)); + if (alert.nCancel > 0) + result.push_back(Pair("nCancel", alert.nCancel)); + return result; +} + +Value getnettotals(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 0) + throw runtime_error( + "getnettotals\n" + "Returns information about network traffic, including bytes in, bytes out,\n" + "and current time."); + + Object obj; + obj.push_back(Pair("totalbytesrecv", CNode::GetTotalBytesRecv())); + obj.push_back(Pair("totalbytessent", CNode::GetTotalBytesSent())); + obj.push_back(Pair("timemillis", GetTimeMillis())); + return obj; +} diff --git a/src/rpcprotocol.cpp b/src/rpcprotocol.cpp new file mode 100644 index 0000000..1ff6c11 --- /dev/null +++ b/src/rpcprotocol.cpp @@ -0,0 +1,266 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "rpcprotocol.h" + +#include "util.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "json/json_spirit_writer_template.h" + +using namespace std; +using namespace boost; +using namespace boost::asio; +using namespace json_spirit; + +const size_t POST_READ_SIZE = 256 * 1024; + +// +// HTTP protocol +// +// This ain't Apache. We're just using HTTP header for the length field +// and to be compatible with other JSON-RPC implementations. +// + +string HTTPPost(const string& strMsg, const map& mapRequestHeaders) +{ + ostringstream s; + s << "POST / HTTP/1.1\r\n" + << "User-Agent: SONO-json-rpc/" << FormatFullVersion() << "\r\n" + << "Host: 127.0.0.1\r\n" + << "Content-Type: application/json\r\n" + << "Content-Length: " << strMsg.size() << "\r\n" + << "Connection: close\r\n" + << "Accept: application/json\r\n"; + BOOST_FOREACH(const PAIRTYPE(string, string)& item, mapRequestHeaders) + s << item.first << ": " << item.second << "\r\n"; + s << "\r\n" << strMsg; + + return s.str(); +} + +static string rfc1123Time() +{ + return DateTimeStrFormat("%a, %d %b %Y %H:%M:%S +0000", GetTime()); +} + +string HTTPReply(int nStatus, const string& strMsg, bool keepalive) +{ + if (nStatus == HTTP_UNAUTHORIZED) + return strprintf("HTTP/1.0 401 Authorization Required\r\n" + "Date: %s\r\n" + "Server: SONO-json-rpc/%s\r\n" + "WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n" + "Content-Type: text/html\r\n" + "Content-Length: 296\r\n" + "\r\n" + "\r\n" + "\r\n" + "\r\n" + "Error\r\n" + "\r\n" + "\r\n" + "

401 Unauthorized.

\r\n" + "\r\n", rfc1123Time(), FormatFullVersion()); + const char *cStatus; + if (nStatus == HTTP_OK) cStatus = "OK"; + else if (nStatus == HTTP_BAD_REQUEST) cStatus = "Bad Request"; + else if (nStatus == HTTP_FORBIDDEN) cStatus = "Forbidden"; + else if (nStatus == HTTP_NOT_FOUND) cStatus = "Not Found"; + else if (nStatus == HTTP_INTERNAL_SERVER_ERROR) cStatus = "Internal Server Error"; + else cStatus = ""; + return strprintf( + "HTTP/1.1 %d %s\r\n" + "Date: %s\r\n" + "Connection: %s\r\n" + "Content-Length: %u\r\n" + "Content-Type: application/json\r\n" + "Server: SONO-json-rpc/%s\r\n" + "\r\n" + "%s", + nStatus, + cStatus, + rfc1123Time(), + keepalive ? "keep-alive" : "close", + strMsg.size(), + FormatFullVersion(), + strMsg); +} + +bool ReadHTTPRequestLine(std::basic_istream& stream, int &proto, + string& http_method, string& http_uri) +{ + string str; + getline(stream, str); + + // HTTP request line is space-delimited + vector vWords; + boost::split(vWords, str, boost::is_any_of(" ")); + if (vWords.size() < 2) + return false; + + // HTTP methods permitted: GET, POST + http_method = vWords[0]; + if (http_method != "GET" && http_method != "POST") + return false; + + // HTTP URI must be an absolute path, relative to current host + http_uri = vWords[1]; + if (http_uri.size() == 0 || http_uri[0] != '/') + return false; + + // parse proto, if present + string strProto = ""; + if (vWords.size() > 2) + strProto = vWords[2]; + + proto = 0; + const char *ver = strstr(strProto.c_str(), "HTTP/1."); + if (ver != NULL) + proto = atoi(ver+7); + + return true; +} + +int ReadHTTPStatus(std::basic_istream& stream, int &proto) +{ + string str; + getline(stream, str); + vector vWords; + boost::split(vWords, str, boost::is_any_of(" ")); + if (vWords.size() < 2) + return HTTP_INTERNAL_SERVER_ERROR; + proto = 0; + const char *ver = strstr(str.c_str(), "HTTP/1."); + if (ver != NULL) + proto = atoi(ver+7); + return atoi(vWords[1].c_str()); +} + +int ReadHTTPHeaders(std::basic_istream& stream, map& mapHeadersRet) +{ + int nLen = 0; + while (true) + { + string str; + std::getline(stream, str); + if (str.empty() || str == "\r") + break; + string::size_type nColon = str.find(":"); + if (nColon != string::npos) + { + string strHeader = str.substr(0, nColon); + boost::trim(strHeader); + boost::to_lower(strHeader); + string strValue = str.substr(nColon+1); + boost::trim(strValue); + mapHeadersRet[strHeader] = strValue; + if (strHeader == "content-length") + nLen = atoi(strValue.c_str()); + } + } + return nLen; +} + + +int ReadHTTPMessage(std::basic_istream& stream, map& mapHeadersRet, string& strMessageRet, + int nProto, size_t max_size) +{ + mapHeadersRet.clear(); + strMessageRet = ""; + + // Read header + int nLen = ReadHTTPHeaders(stream, mapHeadersRet); + if (nLen < 0 || (size_t)nLen > max_size) + return HTTP_INTERNAL_SERVER_ERROR; + + // Read message + if (nLen > 0) + { + vector vch; + size_t ptr = 0; + while (ptr < (size_t)nLen) + { + size_t bytes_to_read = std::min((size_t)nLen - ptr, POST_READ_SIZE); + vch.resize(ptr + bytes_to_read); + stream.read(&vch[ptr], bytes_to_read); + if (!stream) // Connection lost while reading + return HTTP_INTERNAL_SERVER_ERROR; + ptr += bytes_to_read; + } + + strMessageRet = string(vch.begin(), vch.end()); + } + + string sConHdr = mapHeadersRet["connection"]; + + if ((sConHdr != "close") && (sConHdr != "keep-alive")) + { + if (nProto >= 1) + mapHeadersRet["connection"] = "keep-alive"; + else + mapHeadersRet["connection"] = "close"; + } + + return HTTP_OK; +} + +// +// JSON-RPC protocol. Bitcoin speaks version 1.0 for maximum compatibility, +// but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were +// unspecified (HTTP errors and contents of 'error'). +// +// 1.0 spec: http://json-rpc.org/wiki/specification +// 1.2 spec: http://groups.google.com/group/json-rpc/web/json-rpc-over-http +// http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx +// + +string JSONRPCRequest(const string& strMethod, const Array& params, const Value& id) +{ + Object request; + request.push_back(Pair("method", strMethod)); + request.push_back(Pair("params", params)); + request.push_back(Pair("id", id)); + return write_string(Value(request), false) + "\n"; +} + +Object JSONRPCReplyObj(const Value& result, const Value& error, const Value& id) +{ + Object reply; + if (error.type() != null_type) + reply.push_back(Pair("result", Value::null)); + else + reply.push_back(Pair("result", result)); + reply.push_back(Pair("error", error)); + reply.push_back(Pair("id", id)); + return reply; +} + +string JSONRPCReply(const Value& result, const Value& error, const Value& id) +{ + Object reply = JSONRPCReplyObj(result, error, id); + return write_string(Value(reply), false) + "\n"; +} + +Object JSONRPCError(int code, const string& message) +{ + Object error; + error.push_back(Pair("code", code)); + error.push_back(Pair("message", message)); + return error; +} diff --git a/src/rpcprotocol.h b/src/rpcprotocol.h new file mode 100644 index 0000000..9a18779 --- /dev/null +++ b/src/rpcprotocol.h @@ -0,0 +1,140 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef _BITCOINRPC_PROTOCOL_H_ +#define _BITCOINRPC_PROTOCOL_H_ 1 + +#include "compat.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "json/json_spirit_reader_template.h" +#include "json/json_spirit_utils.h" +#include "json/json_spirit_writer_template.h" + +// HTTP status codes +enum HTTPStatusCode +{ + HTTP_OK = 200, + HTTP_BAD_REQUEST = 400, + HTTP_UNAUTHORIZED = 401, + HTTP_FORBIDDEN = 403, + HTTP_NOT_FOUND = 404, + HTTP_INTERNAL_SERVER_ERROR = 500, +}; + +// Bitcoin RPC error codes +enum RPCErrorCode +{ + // Standard JSON-RPC 2.0 errors + RPC_INVALID_REQUEST = -32600, + RPC_METHOD_NOT_FOUND = -32601, + RPC_INVALID_PARAMS = -32602, + RPC_INTERNAL_ERROR = -32603, + RPC_PARSE_ERROR = -32700, + + // General application defined errors + RPC_MISC_ERROR = -1, // std::exception thrown in command handling + RPC_FORBIDDEN_BY_SAFE_MODE = -2, // Server is in safe mode, and command is not allowed in safe mode + RPC_TYPE_ERROR = -3, // Unexpected type was passed as parameter + RPC_INVALID_ADDRESS_OR_KEY = -5, // Invalid address or key + RPC_OUT_OF_MEMORY = -7, // Ran out of memory during operation + RPC_INVALID_PARAMETER = -8, // Invalid, missing or duplicate parameter + RPC_DATABASE_ERROR = -20, // Database error + RPC_DESERIALIZATION_ERROR = -22, // Error parsing or validating structure in raw format + RPC_SERVER_NOT_STARTED = -18, // RPC server was not started (StartRPCThreads() not called) + + // P2P client errors + RPC_CLIENT_NOT_CONNECTED = -9, // Bitcoin is not connected + RPC_CLIENT_IN_INITIAL_DOWNLOAD = -10, // Still downloading initial blocks + RPC_CLIENT_NODE_ALREADY_ADDED = -23, // Node is already added + RPC_CLIENT_NODE_NOT_ADDED = -24, // Node has not been added before + + // Wallet errors + RPC_WALLET_ERROR = -4, // Unspecified problem with wallet (key not found etc.) + RPC_WALLET_INSUFFICIENT_FUNDS = -6, // Not enough funds in wallet or account + RPC_WALLET_INVALID_ACCOUNT_NAME = -11, // Invalid account name + RPC_WALLET_KEYPOOL_RAN_OUT = -12, // Keypool ran out, call keypoolrefill first + RPC_WALLET_UNLOCK_NEEDED = -13, // Enter the wallet passphrase with walletpassphrase first + RPC_WALLET_PASSPHRASE_INCORRECT = -14, // The wallet passphrase entered was incorrect + RPC_WALLET_WRONG_ENC_STATE = -15, // Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.) + RPC_WALLET_ENCRYPTION_FAILED = -16, // Failed to encrypt the wallet + RPC_WALLET_ALREADY_UNLOCKED = -17, // Wallet is already unlocked +}; + +// +// IOStream device that speaks SSL but can also speak non-SSL +// +template +class SSLIOStreamDevice : public boost::iostreams::device { +public: + SSLIOStreamDevice(boost::asio::ssl::stream &streamIn, bool fUseSSLIn) : stream(streamIn) + { + fUseSSL = fUseSSLIn; + fNeedHandshake = fUseSSLIn; + } + + void handshake(boost::asio::ssl::stream_base::handshake_type role) + { + if (!fNeedHandshake) return; + fNeedHandshake = false; + stream.handshake(role); + } + std::streamsize read(char* s, std::streamsize n) + { + handshake(boost::asio::ssl::stream_base::server); // HTTPS servers read first + if (fUseSSL) return stream.read_some(boost::asio::buffer(s, n)); + return stream.next_layer().read_some(boost::asio::buffer(s, n)); + } + std::streamsize write(const char* s, std::streamsize n) + { + handshake(boost::asio::ssl::stream_base::client); // HTTPS clients write first + if (fUseSSL) return boost::asio::write(stream, boost::asio::buffer(s, n)); + return boost::asio::write(stream.next_layer(), boost::asio::buffer(s, n)); + } + bool connect(const std::string& server, const std::string& port) + { + boost::asio::ip::tcp::resolver resolver(stream.get_io_service()); + boost::asio::ip::tcp::resolver::query query(server.c_str(), port.c_str()); + boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(query); + boost::asio::ip::tcp::resolver::iterator end; + boost::system::error_code error = boost::asio::error::host_not_found; + while (error && endpoint_iterator != end) + { + stream.lowest_layer().close(); + stream.lowest_layer().connect(*endpoint_iterator++, error); + } + if (error) + return false; + return true; + } + +private: + bool fNeedHandshake; + bool fUseSSL; + boost::asio::ssl::stream& stream; +}; + +std::string HTTPPost(const std::string& strMsg, const std::map& mapRequestHeaders); +std::string HTTPReply(int nStatus, const std::string& strMsg, bool keepalive); +bool ReadHTTPRequestLine(std::basic_istream& stream, int &proto, + std::string& http_method, std::string& http_uri); +int ReadHTTPStatus(std::basic_istream& stream, int &proto); +int ReadHTTPHeaders(std::basic_istream& stream, std::map& mapHeadersRet); +int ReadHTTPMessage(std::basic_istream& stream, std::map& mapHeadersRet, + std::string& strMessageRet, int nProto, size_t max_size); +std::string JSONRPCRequest(const std::string& strMethod, const json_spirit::Array& params, const json_spirit::Value& id); +json_spirit::Object JSONRPCReplyObj(const json_spirit::Value& result, const json_spirit::Value& error, const json_spirit::Value& id); +std::string JSONRPCReply(const json_spirit::Value& result, const json_spirit::Value& error, const json_spirit::Value& id); +json_spirit::Object JSONRPCError(int code, const std::string& message); + +#endif diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp new file mode 100644 index 0000000..b6108b9 --- /dev/null +++ b/src/rpcrawtransaction.cpp @@ -0,0 +1,678 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include "base58.h" +#include "rpcserver.h" +#include "txdb.h" +#include "init.h" +#include "main.h" +#include "net.h" +#include "keystore.h" +#ifdef ENABLE_WALLET +#include "wallet.h" +#endif + +using namespace std; +using namespace boost; +using namespace boost::assign; +using namespace json_spirit; + +void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex) +{ + txnouttype type; + vector addresses; + int nRequired; + + out.push_back(Pair("asm", scriptPubKey.ToString())); + + if (fIncludeHex) + out.push_back(Pair("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); + + if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) + { + out.push_back(Pair("type", GetTxnOutputType(type))); + return; + } + + out.push_back(Pair("reqSigs", nRequired)); + out.push_back(Pair("type", GetTxnOutputType(type))); + + Array a; + BOOST_FOREACH(const CTxDestination& addr, addresses) + a.push_back(CBitcoinAddress(addr).ToString()); + out.push_back(Pair("addresses", a)); +} + +void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry) +{ + entry.push_back(Pair("txid", tx.GetHash().GetHex())); + entry.push_back(Pair("hash", tx.GetWitnessHash().GetHex())); + entry.push_back(Pair("size", (int)tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION))); + entry.push_back(Pair("vsize", (int)::GetVirtualTransactionSize(tx))); + entry.push_back(Pair("version", tx.nVersion)); + entry.push_back(Pair("time", (int64_t)tx.nTime)); + entry.push_back(Pair("locktime", (int64_t)tx.nLockTime)); + Array vin; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + Object in; + if (tx.IsCoinBase()) + in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); + else + { + in.push_back(Pair("txid", txin.prevout.hash.GetHex())); + in.push_back(Pair("vout", (int64_t)txin.prevout.n)); + Object o; + o.push_back(Pair("asm", txin.scriptSig.ToString())); + o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); + in.push_back(Pair("scriptSig", o)); + } + if (tx.HasWitness()) { + Array txinwitness; + for (unsigned int j = 0; j < txin.scriptWitness.stack.size(); j++) { + std::vector item = txin.scriptWitness.stack[j]; + txinwitness.push_back(HexStr(item.begin(), item.end())); + } + in.push_back(Pair("txinwitness", txinwitness)); + } + in.push_back(Pair("sequence", (int64_t)txin.nSequence)); + vin.push_back(in); + } + entry.push_back(Pair("vin", vin)); + Array vout; + for (unsigned int i = 0; i < tx.vout.size(); i++) + { + const CTxOut& txout = tx.vout[i]; + Object out; + out.push_back(Pair("value", ValueFromAmount(txout.nValue))); + out.push_back(Pair("n", (int64_t)i)); + Object o; + ScriptPubKeyToJSON(txout.scriptPubKey, o, true); + out.push_back(Pair("scriptPubKey", o)); + vout.push_back(out); + } + entry.push_back(Pair("vout", vout)); + + if (hashBlock != 0) + { + entry.push_back(Pair("blockhash", hashBlock.GetHex())); + map::iterator mi = mapBlockIndex.find(hashBlock); + if (mi != mapBlockIndex.end() && (*mi).second) + { + CBlockIndex* pindex = (*mi).second; + if (pindex->IsInMainChain()) + { + entry.push_back(Pair("confirmations", 1 + nBestHeight - pindex->nHeight)); + entry.push_back(Pair("time", (int64_t)pindex->nTime)); + entry.push_back(Pair("blocktime", (int64_t)pindex->nTime)); + } + else + entry.push_back(Pair("confirmations", 0)); + } + } +} + +Value getrawtransaction(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "getrawtransaction [verbose=0]\n" + "If verbose=0, returns a string that is\n" + "serialized, hex-encoded data for .\n" + "If verbose is non-zero, returns an Object\n" + "with information about ."); + + uint256 hash; + hash.SetHex(params[0].get_str()); + + bool fVerbose = false; + if (params.size() > 1) + fVerbose = (params[1].get_int() != 0); + + CTransaction tx; + uint256 hashBlock = 0; + if (!GetTransaction(hash, tx, hashBlock)) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction"); + + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << tx; + string strHex = HexStr(ssTx.begin(), ssTx.end()); + + if (!fVerbose) + return strHex; + + Object result; + result.push_back(Pair("hex", strHex)); + TxToJSON(tx, hashBlock, result); + return result; +} + +#ifdef ENABLE_WALLET +Value listunspent(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 3) + throw runtime_error( + "listunspent [minconf=1] [maxconf=9999999] [\"address\",...]\n" + "Returns array of unspent transaction outputs\n" + "with between minconf and maxconf (inclusive) confirmations.\n" + "Optionally filtered to only include txouts paid to specified addresses.\n" + "Results are an array of Objects, each of which has:\n" + "{txid, vout, scriptPubKey, amount, confirmations}"); + + RPCTypeCheck(params, list_of(int_type)(int_type)(array_type)); + + int nMinDepth = 1; + if (params.size() > 0) + nMinDepth = params[0].get_int(); + + int nMaxDepth = 9999999; + if (params.size() > 1) + nMaxDepth = params[1].get_int(); + + set setAddress; + if (params.size() > 2) + { + Array inputs = params[2].get_array(); + BOOST_FOREACH(Value& input, inputs) + { + CBitcoinAddress address(input.get_str()); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid SONO address: ")+input.get_str()); + if (setAddress.count(address)) + throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+input.get_str()); + setAddress.insert(address); + } + } + + Array results; + vector vecOutputs; + assert(pwalletMain != NULL); + pwalletMain->AvailableCoins(vecOutputs, false); + BOOST_FOREACH(const COutput& out, vecOutputs) + { + if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) + continue; + + if(setAddress.size()) + { + CTxDestination address; + if(!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) + continue; + + if (!setAddress.count(address)) + continue; + } + + int64_t nValue = out.tx->vout[out.i].nValue; + const CScript& pk = out.tx->vout[out.i].scriptPubKey; + Object entry; + entry.push_back(Pair("txid", out.tx->GetHash().GetHex())); + entry.push_back(Pair("vout", out.i)); + CTxDestination address; + if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) + { + entry.push_back(Pair("address", CBitcoinAddress(address).ToString())); + if (pwalletMain->mapAddressBook.count(address)) + entry.push_back(Pair("account", pwalletMain->mapAddressBook[address])); + } + entry.push_back(Pair("scriptPubKey", HexStr(pk.begin(), pk.end()))); + if (pk.IsPayToScriptHash()) + { + CTxDestination address; + if (ExtractDestination(pk, address)) + { + const CScriptID& hash = boost::get(address); + CScript redeemScript; + if (pwalletMain->GetCScript(hash, redeemScript)) + entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end()))); + } + } + entry.push_back(Pair("amount",ValueFromAmount(nValue))); + entry.push_back(Pair("confirmations",out.nDepth)); + results.push_back(entry); + } + + return results; +} +#endif + +Value createrawtransaction(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 2) + throw runtime_error( + "createrawtransaction [{\"txid\":txid,\"vout\":n},...] {address:amount,...}\n" + "Create a transaction spending given inputs\n" + "(array of objects containing transaction id and output number),\n" + "sending to given address(es).\n" + "Returns hex-encoded raw transaction.\n" + "Note that the transaction's inputs are not signed, and\n" + "it is not stored in the wallet or transmitted to the network."); + + RPCTypeCheck(params, list_of(array_type)(obj_type)); + + Array inputs = params[0].get_array(); + Object sendTo = params[1].get_obj(); + + CTransaction rawTx; + + BOOST_FOREACH(Value& input, inputs) + { + const Object& o = input.get_obj(); + + const Value& txid_v = find_value(o, "txid"); + if (txid_v.type() != str_type) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing txid key"); + string txid = txid_v.get_str(); + if (!IsHex(txid)) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected hex txid"); + + const Value& vout_v = find_value(o, "vout"); + if (vout_v.type() != int_type) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key"); + int nOutput = vout_v.get_int(); + if (nOutput < 0) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive"); + + CTxIn in(COutPoint(uint256(txid), nOutput)); + rawTx.vin.push_back(in); + } + + set setAddress; + BOOST_FOREACH(const Pair& s, sendTo) + { + CBitcoinAddress address(s.name_); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid SONO address: ")+s.name_); + + if (setAddress.count(address)) + throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_); + setAddress.insert(address); + + CScript scriptPubKey; + scriptPubKey.SetDestination(address.Get()); + int64_t nAmount = AmountFromValue(s.value_); + + CTxOut out(nAmount, scriptPubKey); + rawTx.vout.push_back(out); + } + + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss << rawTx; + return HexStr(ss.begin(), ss.end()); +} + +Value decoderawtransaction(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "decoderawtransaction \n" + "Return a JSON object representing the serialized, hex-encoded transaction."); + + RPCTypeCheck(params, list_of(str_type)); + + vector txData(ParseHex(params[0].get_str())); + CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); + CTransaction tx; + try { + ssData >> tx; + } + catch (std::exception &e) { + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); + } + + Object result; + TxToJSON(tx, 0, result); + + return result; +} + +Value decodescript(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "decodescript \n" + "Decode a hex-encoded script."); + + RPCTypeCheck(params, list_of(str_type)); + + Object r; + CScript script; + if (params[0].get_str().size() > 0){ + vector scriptData(ParseHexV(params[0], "argument")); + script = CScript(scriptData.begin(), scriptData.end()); + } else { + // Empty scripts are valid + } + ScriptPubKeyToJSON(script, r, false); + + r.push_back(Pair("p2sh", CBitcoinAddress(script.GetID()).ToString())); + return r; +} + +Value signrawtransaction(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 4) + throw runtime_error( + "signrawtransaction [{\"txid\":txid,\"vout\":n,\"scriptPubKey\":hex,\"redeemScript\":hex},...] [,...] [sighashtype=\"ALL\"]\n" + "Sign inputs for raw transaction (serialized, hex-encoded).\n" + "Second optional argument (may be null) is an array of previous transaction outputs that\n" + "this transaction depends on but may not yet be in the blockchain.\n" + "Third optional argument (may be null) is an array of base58-encoded private\n" + "keys that, if given, will be the only keys used to sign the transaction.\n" + "Fourth optional argument is a string that is one of six values; ALL, NONE, SINGLE or\n" + "ALL|ANYONECANPAY, NONE|ANYONECANPAY, SINGLE|ANYONECANPAY.\n" + "Returns json object with keys:\n" + " hex : raw transaction with signature(s) (hex-encoded string)\n" + " complete : 1 if transaction has a complete set of signature (0 if not)" +#ifdef ENABLE_WALLET + + HelpRequiringPassphrase() +#endif + ); + + RPCTypeCheck(params, list_of(str_type)(array_type)(array_type)(str_type), true); + + vector txData(ParseHex(params[0].get_str())); + CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); + vector txVariants; + while (!ssData.empty()) + { + try { + CTransaction tx; + ssData >> tx; + txVariants.push_back(tx); + } + catch (std::exception &e) { + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); + } + } + + if (txVariants.empty()) + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Missing transaction"); + + // mergedTx will end up with all the signatures; it + // starts as a clone of the rawtx: + CTransaction mergedTx(txVariants[0]); + bool fComplete = true; + + // Fetch previous transactions (inputs): + map mapPrevOut; + for (unsigned int i = 0; i < mergedTx.vin.size(); i++) + { + CTransaction tempTx; + MapPrevTx mapPrevTx; + CTxDB txdb("r"); + map unused; + bool fInvalid; + + // FetchInputs aborts on failure, so we go one at a time. + tempTx.vin.push_back(mergedTx.vin[i]); + tempTx.FetchInputs(txdb, unused, false, false, mapPrevTx, fInvalid); + + // Copy results into mapPrevOut: + BOOST_FOREACH(const CTxIn& txin, tempTx.vin) + { + const uint256& prevHash = txin.prevout.hash; + if (mapPrevTx.count(prevHash) && mapPrevTx[prevHash].second.vout.size()>txin.prevout.n) + mapPrevOut[txin.prevout] = mapPrevTx[prevHash].second.vout[txin.prevout.n].scriptPubKey; + } + } + + bool fGivenKeys = false; + CBasicKeyStore tempKeystore; + if (params.size() > 2 && params[2].type() != null_type) + { + fGivenKeys = true; + Array keys = params[2].get_array(); + BOOST_FOREACH(Value k, keys) + { + CBitcoinSecret vchSecret; + bool fGood = vchSecret.SetString(k.get_str()); + if (!fGood) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); + CKey key = vchSecret.GetKey(); + tempKeystore.AddKey(key); + } + } +#ifdef ENABLE_WALLET + else + EnsureWalletIsUnlocked(); +#endif + + // Add previous txouts given in the RPC call: + if (params.size() > 1 && params[1].type() != null_type) + { + Array prevTxs = params[1].get_array(); + BOOST_FOREACH(Value& p, prevTxs) + { + if (p.type() != obj_type) + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "expected object with {\"txid'\",\"vout\",\"scriptPubKey\"}"); + + Object prevOut = p.get_obj(); + + RPCTypeCheck(prevOut, map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type)); + + string txidHex = find_value(prevOut, "txid").get_str(); + if (!IsHex(txidHex)) + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "txid must be hexadecimal"); + uint256 txid; + txid.SetHex(txidHex); + + int nOut = find_value(prevOut, "vout").get_int(); + if (nOut < 0) + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "vout must be positive"); + + string pkHex = find_value(prevOut, "scriptPubKey").get_str(); + if (!IsHex(pkHex)) + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "scriptPubKey must be hexadecimal"); + vector pkData(ParseHex(pkHex)); + CScript scriptPubKey(pkData.begin(), pkData.end()); + + COutPoint outpoint(txid, nOut); + if (mapPrevOut.count(outpoint)) + { + // Complain if scriptPubKey doesn't match + if (mapPrevOut[outpoint] != scriptPubKey) + { + string err("Previous output scriptPubKey mismatch:\n"); + err = err + mapPrevOut[outpoint].ToString() + "\nvs:\n"+ + scriptPubKey.ToString(); + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, err); + } + } + else + mapPrevOut[outpoint] = scriptPubKey; + + // if redeemScript given and not using the local wallet (private keys + // given), add redeemScript to the tempKeystore so it can be signed: + if (fGivenKeys && scriptPubKey.IsPayToScriptHash()) + { + RPCTypeCheck(prevOut, map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type)("redeemScript",str_type)); + Value v = find_value(prevOut, "redeemScript"); + if (!(v == Value::null)) + { + vector rsData(ParseHexV(v, "redeemScript")); + CScript redeemScript(rsData.begin(), rsData.end()); + tempKeystore.AddCScript(redeemScript); + } + } + } + } + +#ifdef ENABLE_WALLET + const CKeyStore& keystore = ((fGivenKeys || !pwalletMain) ? tempKeystore : *pwalletMain); +#else + const CKeyStore& keystore = tempKeystore; +#endif + + int nHashType = SIGHASH_ALL; + if (params.size() > 3 && params[3].type() != null_type) + { + static map mapSigHashValues = + boost::assign::map_list_of + (string("ALL"), int(SIGHASH_ALL)) + (string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY)) + (string("NONE"), int(SIGHASH_NONE)) + (string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY)) + (string("SINGLE"), int(SIGHASH_SINGLE)) + (string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)) + ; + string strHashType = params[3].get_str(); + if (mapSigHashValues.count(strHashType)) + nHashType = mapSigHashValues[strHashType]; + else + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid sighash param"); + } + + bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE); + + // Sign what we can: + for (unsigned int i = 0; i < mergedTx.vin.size(); i++) + { + CTxIn& txin = mergedTx.vin[i]; + if (mapPrevOut.count(txin.prevout) == 0) + { + fComplete = false; + continue; + } + const CScript& prevPubKey = mapPrevOut[txin.prevout]; + + txin.scriptSig.clear(); + // Only sign SIGHASH_SINGLE if there's a corresponding output: + if (!fHashSingle || (i < mergedTx.vout.size())) + SignSignature(keystore, prevPubKey, mergedTx, i, nHashType); + + // ... and merge in other signatures: + BOOST_FOREACH(const CTransaction& txv, txVariants) + { + txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig); + } + if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, STANDARD_SCRIPT_VERIFY_FLAGS, 0)) + fComplete = false; + } + + Object result; + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << mergedTx; + result.push_back(Pair("hex", HexStr(ssTx.begin(), ssTx.end()))); + result.push_back(Pair("complete", fComplete)); + + return result; +} + +Value sendrawtransaction(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 1) + throw runtime_error( + "sendrawtransaction \n" + "Submits raw transaction (serialized, hex-encoded) to local node and network."); + + RPCTypeCheck(params, list_of(str_type)); + + // parse hex string from parameter + vector txData(ParseHex(params[0].get_str())); + CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); + CTransaction tx; + + // deserialize binary data stream + try { + ssData >> tx; + } + catch (std::exception &e) { + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); + } + uint256 hashTx = tx.GetHash(); + + // See if the transaction is already in a block + // or in the memory pool: + CTransaction existingTx; + uint256 hashBlock = 0; + if (GetTransaction(hashTx, existingTx, hashBlock)) + { + if (hashBlock != 0) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("transaction already in block ")+hashBlock.GetHex()); + // Not in block, but already in the memory pool; will drop + // through to re-relay it. + } + else + { + // push to local node + if (!AcceptToMemoryPool(mempool, tx, true, NULL)) + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX rejected"); + } + RelayTransaction(tx, hashTx); + + return hashTx.GetHex(); +} + + +Value searchrawtransactions(const Array ¶ms, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 4) + throw runtime_error( + "searchrawtransactions
[verbose=1] [skip=0] [count=100]\n"); + + CBitcoinAddress address(params[0].get_str()); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); + CTxDestination dest = address.Get(); + + std::vector vtxhash; + if (!FindTransactionsByDestination(dest, vtxhash)) + throw JSONRPCError(RPC_DATABASE_ERROR, "Cannot search for address"); + + int nSkip = 0; + int nCount = 100; + bool fVerbose = true; + if (params.size() > 1) + fVerbose = (params[1].get_int() != 0); + if (params.size() > 2) + nSkip = params[2].get_int(); + if (params.size() > 3) + nCount = params[3].get_int(); + + if (nSkip < 0) + nSkip += vtxhash.size(); + if (nSkip < 0) + nSkip = 0; + if (nCount < 0) + nCount = 0; + + std::vector::const_iterator it = vtxhash.begin(); + while (it != vtxhash.end() && nSkip--) it++; + + Array result; + while (it != vtxhash.end() && nCount--) { + CTransaction tx; + uint256 hashBlock; + if (!GetTransaction(*it, tx, hashBlock)) + { + // throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Cannot read transaction from disk"); + Object obj; + obj.push_back(Pair("ERROR", "Cannot read transaction from disk")); + result.push_back(obj); + } + else + { + + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << tx; + string strHex = HexStr(ssTx.begin(), ssTx.end()); + if (fVerbose) { + Object object; + TxToJSON(tx, hashBlock, object); + object.push_back(Pair("hex", strHex)); + result.push_back(object); + } else { + result.push_back(strHex); + } + + } + it++; + } + return result; +} + diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp new file mode 100644 index 0000000..9e1eb3e --- /dev/null +++ b/src/rpcserver.cpp @@ -0,0 +1,864 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "rpcserver.h" + +#include "base58.h" +#include "init.h" +#include "util.h" +#include "sync.h" +#include "base58.h" +#include "db.h" +#include "ui_interface.h" +#ifdef ENABLE_WALLET +#include "wallet.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace boost; +using namespace boost::asio; +using namespace json_spirit; + +static std::string strRPCUserColonPass; + +// These are created by StartRPCThreads, destroyed in StopRPCThreads +static asio::io_service* rpc_io_service = NULL; +static map > deadlineTimers; +static ssl::context* rpc_ssl_context = NULL; +static boost::thread_group* rpc_worker_group = NULL; + +void RPCTypeCheck(const Array& params, + const list& typesExpected, + bool fAllowNull) +{ + unsigned int i = 0; + BOOST_FOREACH(Value_type t, typesExpected) + { + if (params.size() <= i) + break; + + const Value& v = params[i]; + if (!((v.type() == t) || (fAllowNull && (v.type() == null_type)))) + { + string err = strprintf("Expected type %s, got %s", + Value_type_name[t], Value_type_name[v.type()]); + throw JSONRPCError(RPC_TYPE_ERROR, err); + } + i++; + } +} + +void RPCTypeCheck(const Object& o, + const map& typesExpected, + bool fAllowNull) +{ + BOOST_FOREACH(const PAIRTYPE(string, Value_type)& t, typesExpected) + { + const Value& v = find_value(o, t.first); + if (!fAllowNull && v.type() == null_type) + throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first)); + + if (!((v.type() == t.second) || (fAllowNull && (v.type() == null_type)))) + { + string err = strprintf("Expected type %s for %s, got %s", + Value_type_name[t.second], t.first, Value_type_name[v.type()]); + throw JSONRPCError(RPC_TYPE_ERROR, err); + } + } +} + +int64_t AmountFromValue(const Value& value) +{ + double dAmount = value.get_real(); + if (dAmount <= 0.0 || dAmount > MAX_MONEY) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount"); + int64_t nAmount = roundint64(dAmount * COIN); + if (!MoneyRange(nAmount)) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount"); + return nAmount; +} + +Value ValueFromAmount(int64_t amount) +{ + return (double)amount / (double)COIN; +} + + +// +// Utilities: convert hex-encoded Values +// (throws error if not hex). +// +uint256 ParseHashV(const Value& v, string strName) +{ + string strHex; + if (v.type() == str_type) + strHex = v.get_str(); + if (!IsHex(strHex)) // Note: IsHex("") is false + throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')"); + uint256 result; + result.SetHex(strHex); + return result; +} + +uint256 ParseHashO(const Object& o, string strKey) +{ + return ParseHashV(find_value(o, strKey), strKey); +} + +vector ParseHexV(const Value& v, string strName) +{ + string strHex; + if (v.type() == str_type) + strHex = v.get_str(); + if (!IsHex(strHex)) + throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')"); + return ParseHex(strHex); +} + +vector ParseHexO(const Object& o, string strKey) +{ + return ParseHexV(find_value(o, strKey), strKey); +} + + +/// +/// Note: This interface may still be subject to change. +/// + +string CRPCTable::help(string strCommand) const +{ + string strRet; + set setDone; + for (map::const_iterator mi = mapCommands.begin(); mi != mapCommands.end(); ++mi) + { + const CRPCCommand *pcmd = mi->second; + string strMethod = mi->first; + // We already filter duplicates, but these deprecated screw up the sort order + if (strMethod.find("label") != string::npos) + continue; + if (strCommand != "" && strMethod != strCommand) + continue; +#ifdef ENABLE_WALLET + if (pcmd->reqWallet && !pwalletMain) + continue; +#endif + + try + { + Array params; + rpcfn_type pfn = pcmd->actor; + if (setDone.insert(pfn).second) + (*pfn)(params, true); + } + catch (std::exception& e) + { + // Help text is returned in an exception + string strHelp = string(e.what()); + if (strCommand == "") + if (strHelp.find('\n') != string::npos) + strHelp = strHelp.substr(0, strHelp.find('\n')); + strRet += strHelp + "\n"; + } + } + if (strRet == "") + strRet = strprintf("help: unknown command: %s\n", strCommand); + strRet = strRet.substr(0,strRet.size()-1); + return strRet; +} + +Value help(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "help [command]\n" + "List commands, or get help for a command."); + + string strCommand; + if (params.size() > 0) + strCommand = params[0].get_str(); + + return tableRPC.help(strCommand); +} + + +Value stop(const Array& params, bool fHelp) +{ + // Accept the deprecated and ignored 'detach' boolean argument + if (fHelp || params.size() > 1) + throw runtime_error( + "stop\n" + "Stop SONO server."); + // Shutdown will take long enough that the response should get back + StartShutdown(); + return "SONO server stopping"; +} + + + +// +// Call Table +// + + +static const CRPCCommand vRPCCommands[] = +{ // name actor (function) okSafeMode threadSafe reqWallet + // ------------------------ ----------------------- ---------- ---------- --------- + { "help", &help, true, true, false }, + { "stop", &stop, true, true, false }, + { "getbestblockhash", &getbestblockhash, true, false, false }, + { "getblockcount", &getblockcount, true, false, false }, + { "getconnectioncount", &getconnectioncount, true, false, false }, + { "getpeerinfo", &getpeerinfo, true, false, false }, + { "addnode", &addnode, true, true, false }, + { "getaddednodeinfo", &getaddednodeinfo, true, true, false }, + { "ping", &ping, true, false, false }, + { "getnettotals", &getnettotals, true, true, false }, + { "getdifficulty", &getdifficulty, true, false, false }, + { "getinfo", &getinfo, true, false, false }, + { "getrawmempool", &getrawmempool, true, false, false }, + { "getblock", &getblock, false, false, false }, + { "getblockbynumber", &getblockbynumber, false, false, false }, + { "getblockhash", &getblockhash, false, false, false }, + { "getrawtransaction", &getrawtransaction, false, false, false }, + { "createrawtransaction", &createrawtransaction, false, false, false }, + { "decoderawtransaction", &decoderawtransaction, false, false, false }, + { "decodescript", &decodescript, false, false, false }, + { "signrawtransaction", &signrawtransaction, false, false, false }, + { "sendrawtransaction", &sendrawtransaction, false, false, false }, + { "getcheckpoint", &getcheckpoint, true, false, false }, + { "sendalert", &sendalert, false, false, false }, + { "validateaddress", &validateaddress, true, false, false }, + { "validatepubkey", &validatepubkey, true, false, false }, + { "verifymessage", &verifymessage, false, false, false }, + { "searchrawtransactions", &searchrawtransactions, false, false, false }, + +/* Dark features */ + { "darksend", &darksend, false, false, true }, + { "spork", &spork, true, false, false }, + { "masternode", &masternode, true, false, true }, + +#ifdef ENABLE_WALLET + { "getmininginfo", &getmininginfo, true, false, false }, + { "getstakinginfo", &getstakinginfo, true, false, false }, + { "getnewaddress", &getnewaddress, true, false, true }, + { "getnewpubkey", &getnewpubkey, true, false, true }, + { "getaccountaddress", &getaccountaddress, true, false, true }, + { "setaccount", &setaccount, true, false, true }, + { "getaccount", &getaccount, false, false, true }, + { "getaddressesbyaccount", &getaddressesbyaccount, true, false, true }, + { "sendtoaddress", &sendtoaddress, false, false, true }, + { "getreceivedbyaddress", &getreceivedbyaddress, false, false, true }, + { "getreceivedbyaccount", &getreceivedbyaccount, false, false, true }, + { "listreceivedbyaddress", &listreceivedbyaddress, false, false, true }, + { "listreceivedbyaccount", &listreceivedbyaccount, false, false, true }, + { "backupwallet", &backupwallet, true, false, true }, + { "keypoolrefill", &keypoolrefill, true, false, true }, + { "walletpassphrase", &walletpassphrase, true, false, true }, + { "walletpassphrasechange", &walletpassphrasechange, false, false, true }, + { "walletlock", &walletlock, true, false, true }, + { "encryptwallet", &encryptwallet, false, false, true }, + { "getbalance", &getbalance, false, false, true }, + { "move", &movecmd, false, false, true }, + { "sendfrom", &sendfrom, false, false, true }, + { "sendmany", &sendmany, false, false, true }, + { "addmultisigaddress", &addmultisigaddress, false, false, true }, + { "addredeemscript", &addredeemscript, false, false, true }, + { "gettransaction", &gettransaction, false, false, true }, + { "listtransactions", &listtransactions, false, false, true }, + { "listaddressgroupings", &listaddressgroupings, false, false, true }, + { "signmessage", &signmessage, false, false, true }, + { "getwork", &getwork, true, false, true }, + { "getworkex", &getworkex, true, false, true }, + { "listaccounts", &listaccounts, false, false, true }, + { "getblocktemplate", &getblocktemplate, true, false, false }, + { "submitblock", &submitblock, false, false, false }, + { "listsinceblock", &listsinceblock, false, false, true }, + { "dumpprivkey", &dumpprivkey, false, false, true }, + { "dumpwallet", &dumpwallet, true, false, true }, + { "importprivkey", &importprivkey, false, false, true }, + { "importwallet", &importwallet, false, false, true }, + { "listunspent", &listunspent, false, false, true }, + { "settxfee", &settxfee, false, false, true }, + { "getsubsidy", &getsubsidy, true, true, false }, + { "getstakesubsidy", &getstakesubsidy, true, true, false }, + { "reservebalance", &reservebalance, false, true, true }, + { "checkwallet", &checkwallet, false, true, true }, + { "repairwallet", &repairwallet, false, true, true }, + { "resendtx", &resendtx, false, true, true }, + { "makekeypair", &makekeypair, false, true, false }, + { "checkkernel", &checkkernel, true, false, true }, + { "getnewstealthaddress", &getnewstealthaddress, false, false, true}, + { "liststealthaddresses", &liststealthaddresses, false, false, true}, + { "importstealthaddress", &importstealthaddress, false, false, true}, + { "sendtostealthaddress", &sendtostealthaddress, false, false, true}, + { "smsgenable", &smsgenable, false, false, false }, + { "smsgdisable", &smsgdisable, false, false, false }, + { "smsglocalkeys", &smsglocalkeys, false, false, false }, + { "smsgoptions", &smsgoptions, false, false, false }, + { "smsgscanchain", &smsgscanchain, false, false, false }, + { "smsgscanbuckets", &smsgscanbuckets, false, false, false }, + { "smsgaddkey", &smsgaddkey, false, false, false }, + { "smsggetpubkey", &smsggetpubkey, false, false, false }, + { "smsgsend", &smsgsend, false, false, false }, + { "smsgsendanon", &smsgsendanon, false, false, false }, + { "smsginbox", &smsginbox, false, false, false }, + { "smsgoutbox", &smsgoutbox, false, false, false }, + { "smsgbuckets", &smsgbuckets, false, false, false }, +#endif +}; + +CRPCTable::CRPCTable() +{ + unsigned int vcidx; + for (vcidx = 0; vcidx < (sizeof(vRPCCommands) / sizeof(vRPCCommands[0])); vcidx++) + { + const CRPCCommand *pcmd; + + pcmd = &vRPCCommands[vcidx]; + mapCommands[pcmd->name] = pcmd; + } +} + +const CRPCCommand *CRPCTable::operator[](string name) const +{ + map::const_iterator it = mapCommands.find(name); + if (it == mapCommands.end()) + return NULL; + return (*it).second; +} + + +bool HTTPAuthorized(map& mapHeaders) +{ + string strAuth = mapHeaders["authorization"]; + if (strAuth.substr(0,6) != "Basic ") + return false; + string strUserPass64 = strAuth.substr(6); boost::trim(strUserPass64); + string strUserPass = DecodeBase64(strUserPass64); + return TimingResistantEqual(strUserPass, strRPCUserColonPass); +} + +void ErrorReply(std::ostream& stream, const Object& objError, const Value& id) +{ + // Send error reply from json-rpc error object + int nStatus = HTTP_INTERNAL_SERVER_ERROR; + int code = find_value(objError, "code").get_int(); + if (code == RPC_INVALID_REQUEST) nStatus = HTTP_BAD_REQUEST; + else if (code == RPC_METHOD_NOT_FOUND) nStatus = HTTP_NOT_FOUND; + string strReply = JSONRPCReply(Value::null, objError, id); + stream << HTTPReply(nStatus, strReply, false) << std::flush; +} + +bool ClientAllowed(const boost::asio::ip::address& address) +{ + // Make sure that IPv4-compatible and IPv4-mapped IPv6 addresses are treated as IPv4 addresses + if (address.is_v6() + && (address.to_v6().is_v4_compatible() + || address.to_v6().is_v4_mapped())) + return ClientAllowed(address.to_v6().to_v4()); + + if (address == asio::ip::address_v4::loopback() + || address == asio::ip::address_v6::loopback() + || (address.is_v4() + // Check whether IPv4 addresses match 127.0.0.0/8 (loopback subnet) + && (address.to_v4().to_ulong() & 0xff000000) == 0x7f000000)) + return true; + + const string strAddress = address.to_string(); + const vector& vAllow = mapMultiArgs["-rpcallowip"]; + BOOST_FOREACH(string strAllow, vAllow) + if (WildcardMatch(strAddress, strAllow)) + return true; + return false; +} + +class AcceptedConnection +{ +public: + virtual ~AcceptedConnection() {} + + virtual std::iostream& stream() = 0; + virtual std::string peer_address_to_string() const = 0; + virtual void close() = 0; +}; + +template +class AcceptedConnectionImpl : public AcceptedConnection +{ +public: + AcceptedConnectionImpl( + asio::io_service& io_service, + ssl::context &context, + bool fUseSSL) : + sslStream(io_service, context), + _d(sslStream, fUseSSL), + _stream(_d) + { + } + + virtual std::iostream& stream() + { + return _stream; + } + + virtual std::string peer_address_to_string() const + { + return peer.address().to_string(); + } + + virtual void close() + { + _stream.close(); + } + + typename Protocol::endpoint peer; + asio::ssl::stream sslStream; + +private: + SSLIOStreamDevice _d; + iostreams::stream< SSLIOStreamDevice > _stream; +}; + +void ServiceConnection(AcceptedConnection *conn); + +// Forward declaration required for RPCListen +template +static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor > acceptor, + ssl::context& context, + bool fUseSSL, + AcceptedConnection* conn, + const boost::system::error_code& error); + +/** + * Sets up I/O resources to accept and handle a new connection. + */ +template +static void RPCListen(boost::shared_ptr< basic_socket_acceptor > acceptor, + ssl::context& context, + const bool fUseSSL) +{ + // Accept connection + AcceptedConnectionImpl* conn = new AcceptedConnectionImpl(acceptor->get_io_service(), context, fUseSSL); + + acceptor->async_accept( + conn->sslStream.lowest_layer(), + conn->peer, + boost::bind(&RPCAcceptHandler, + acceptor, + boost::ref(context), + fUseSSL, + conn, + boost::asio::placeholders::error)); +} + + +/** + * Accept and handle incoming connection. + */ +template +static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor > acceptor, + ssl::context& context, + const bool fUseSSL, + AcceptedConnection* conn, + const boost::system::error_code& error) +{ + // Immediately start accepting new connections, except when we're cancelled or our socket is closed. + if (error != asio::error::operation_aborted && acceptor->is_open()) + RPCListen(acceptor, context, fUseSSL); + + AcceptedConnectionImpl* tcp_conn = dynamic_cast< AcceptedConnectionImpl* >(conn); + + // TODO: Actually handle errors + if (error) + { + delete conn; + } + + // Restrict callers by IP. It is important to + // do this before starting client thread, to filter out + // certain DoS and misbehaving clients. + else if (tcp_conn && !ClientAllowed(tcp_conn->peer.address())) + { + // Only send a 403 if we're not using SSL to prevent a DoS during the SSL handshake. + if (!fUseSSL) + conn->stream() << HTTPReply(HTTP_FORBIDDEN, "", false) << std::flush; + delete conn; + } + else { + ServiceConnection(conn); + conn->close(); + delete conn; + } +} + +void StartRPCThreads() +{ + strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"]; + if (((mapArgs["-rpcpassword"] == "") || + (mapArgs["-rpcuser"] == mapArgs["-rpcpassword"])) && Params().RequireRPCPassword()) + { + unsigned char rand_pwd[32]; + RAND_bytes(rand_pwd, 32); + string strWhatAmI = "To use SONOd"; + if (mapArgs.count("-server")) + strWhatAmI = strprintf(_("To use the %s option"), "\"-server\""); + else if (mapArgs.count("-daemon")) + strWhatAmI = strprintf(_("To use the %s option"), "\"-daemon\""); + uiInterface.ThreadSafeMessageBox(strprintf( + _("%s, you must set a rpcpassword in the configuration file:\n" + "%s\n" + "It is recommended you use the following random password:\n" + "rpcuser=SONOrpc\n" + "rpcpassword=%s\n" + "(you do not need to remember this password)\n" + "The username and password MUST NOT be the same.\n" + "If the file does not exist, create it with owner-readable-only file permissions.\n" + "It is also recommended to set alertnotify so you are notified of problems;\n" + "for example: alertnotify=echo %%s | mail -s \"SONO Alert\" admin@foo.com\n"), + strWhatAmI, + GetConfigFile().string(), + EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32)), + "", CClientUIInterface::MSG_ERROR); + StartShutdown(); + return; + } + + assert(rpc_io_service == NULL); + rpc_io_service = new asio::io_service(); + rpc_ssl_context = new ssl::context(*rpc_io_service, ssl::context::sslv23); + + const bool fUseSSL = GetBoolArg("-rpcssl", false); + + if (fUseSSL) + { + rpc_ssl_context->set_options(ssl::context::no_sslv2); + + filesystem::path pathCertFile(GetArg("-rpcsslcertificatechainfile", "server.cert")); + if (!pathCertFile.is_complete()) pathCertFile = filesystem::path(GetDataDir()) / pathCertFile; + if (filesystem::exists(pathCertFile)) rpc_ssl_context->use_certificate_chain_file(pathCertFile.string()); + else LogPrintf("ThreadRPCServer ERROR: missing server certificate file %s\n", pathCertFile.string()); + + filesystem::path pathPKFile(GetArg("-rpcsslprivatekeyfile", "server.pem")); + if (!pathPKFile.is_complete()) pathPKFile = filesystem::path(GetDataDir()) / pathPKFile; + if (filesystem::exists(pathPKFile)) rpc_ssl_context->use_private_key_file(pathPKFile.string(), ssl::context::pem); + else LogPrintf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string()); + + string strCiphers = GetArg("-rpcsslciphers", "TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH"); + SSL_CTX_set_cipher_list(rpc_ssl_context->impl(), strCiphers.c_str()); + } + + // Try a dual IPv6/IPv4 socket, falling back to separate IPv4 and IPv6 sockets + const bool loopback = !mapArgs.count("-rpcallowip"); + asio::ip::address bindAddress = loopback ? asio::ip::address_v6::loopback() : asio::ip::address_v6::any(); + ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", Params().RPCPort())); + boost::system::error_code v6_only_error; + boost::shared_ptr acceptor(new ip::tcp::acceptor(*rpc_io_service)); + + bool fListening = false; + std::string strerr; + try + { + acceptor->open(endpoint.protocol()); + acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); + + // Try making the socket dual IPv6/IPv4 (if listening on the "any" address) + acceptor->set_option(boost::asio::ip::v6_only(loopback), v6_only_error); + + acceptor->bind(endpoint); + acceptor->listen(socket_base::max_connections); + + RPCListen(acceptor, *rpc_ssl_context, fUseSSL); + + fListening = true; + } + catch(boost::system::system_error &e) + { + strerr = strprintf(_("An error occurred while setting up the RPC port %u for listening on IPv6, falling back to IPv4: %s"), endpoint.port(), e.what()); + } + + try { + // If dual IPv6/IPv4 failed (or we're opening loopback interfaces only), open IPv4 separately + if (!fListening || loopback || v6_only_error) + { + bindAddress = loopback ? asio::ip::address_v4::loopback() : asio::ip::address_v4::any(); + endpoint.address(bindAddress); + + acceptor.reset(new ip::tcp::acceptor(*rpc_io_service)); + acceptor->open(endpoint.protocol()); + acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); + acceptor->bind(endpoint); + acceptor->listen(socket_base::max_connections); + + RPCListen(acceptor, *rpc_ssl_context, fUseSSL); + + fListening = true; + } + } + catch(boost::system::system_error &e) + { + strerr = strprintf(_("An error occurred while setting up the RPC port %u for listening on IPv4: %s"), endpoint.port(), e.what()); + } + + if (!fListening) { + uiInterface.ThreadSafeMessageBox(strerr, "", CClientUIInterface::MSG_ERROR); + StartShutdown(); + return; + } + + rpc_worker_group = new boost::thread_group(); + for (int i = 0; i < GetArg("-rpcthreads", 4); i++) + rpc_worker_group->create_thread(boost::bind(&asio::io_service::run, rpc_io_service)); +} + +void StopRPCThreads() +{ + if (rpc_io_service == NULL) return; + + deadlineTimers.clear(); + rpc_io_service->stop(); + if (rpc_worker_group != NULL) + rpc_worker_group->join_all(); + delete rpc_worker_group; rpc_worker_group = NULL; + delete rpc_ssl_context; rpc_ssl_context = NULL; + delete rpc_io_service; rpc_io_service = NULL; +} + +void RPCRunHandler(const boost::system::error_code& err, boost::function func) +{ + if (!err) + func(); +} + +void RPCRunLater(const std::string& name, boost::function func, int64_t nSeconds) +{ + assert(rpc_io_service != NULL); + + if (deadlineTimers.count(name) == 0) + { + deadlineTimers.insert(make_pair(name, + boost::shared_ptr(new deadline_timer(*rpc_io_service)))); + } + deadlineTimers[name]->expires_from_now(posix_time::seconds(nSeconds)); + deadlineTimers[name]->async_wait(boost::bind(RPCRunHandler, _1, func)); +} + +class JSONRequest +{ +public: + Value id; + string strMethod; + Array params; + + JSONRequest() { id = Value::null; } + void parse(const Value& valRequest); +}; + +void JSONRequest::parse(const Value& valRequest) +{ + // Parse request + if (valRequest.type() != obj_type) + throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object"); + const Object& request = valRequest.get_obj(); + + // Parse id now so errors from here on will have the id + id = find_value(request, "id"); + + // Parse method + Value valMethod = find_value(request, "method"); + if (valMethod.type() == null_type) + throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method"); + if (valMethod.type() != str_type) + throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string"); + strMethod = valMethod.get_str(); + if (strMethod != "getwork" && strMethod != "getblocktemplate") + LogPrint("rpc", "ThreadRPCServer method=%s\n", strMethod); + + // Parse params + Value valParams = find_value(request, "params"); + if (valParams.type() == array_type) + params = valParams.get_array(); + else if (valParams.type() == null_type) + params = Array(); + else + throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array"); +} + + +static Object JSONRPCExecOne(const Value& req) +{ + Object rpc_result; + + JSONRequest jreq; + try { + jreq.parse(req); + + Value result = tableRPC.execute(jreq.strMethod, jreq.params); + rpc_result = JSONRPCReplyObj(result, Value::null, jreq.id); + } + catch (Object& objError) + { + rpc_result = JSONRPCReplyObj(Value::null, objError, jreq.id); + } + catch (std::exception& e) + { + rpc_result = JSONRPCReplyObj(Value::null, + JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id); + } + + return rpc_result; +} + +static string JSONRPCExecBatch(const Array& vReq) +{ + Array ret; + for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++) + ret.push_back(JSONRPCExecOne(vReq[reqIdx])); + + return write_string(Value(ret), false) + "\n"; +} + +void ServiceConnection(AcceptedConnection *conn) +{ + bool fRun = true; + while (fRun) + { + int nProto = 0; + map mapHeaders; + string strRequest, strMethod, strURI; + + // Read HTTP request line + if (!ReadHTTPRequestLine(conn->stream(), nProto, strMethod, strURI)) + break; + + // Read HTTP message headers and body + ReadHTTPMessage(conn->stream(), mapHeaders, strRequest, nProto, MAX_SIZE); + + if (strURI != "/") { + conn->stream() << HTTPReply(HTTP_NOT_FOUND, "", false) << std::flush; + break; + } + + // Check authorization + if (mapHeaders.count("authorization") == 0) + { + conn->stream() << HTTPReply(HTTP_UNAUTHORIZED, "", false) << std::flush; + break; + } + if (!HTTPAuthorized(mapHeaders)) + { + LogPrintf("ThreadRPCServer incorrect password attempt from %s\n", conn->peer_address_to_string()); + /* Deter brute-forcing short passwords. + If this results in a DoS the user really + shouldn't have their RPC port exposed. */ + if (mapArgs["-rpcpassword"].size() < 20) + MilliSleep(250); + + conn->stream() << HTTPReply(HTTP_UNAUTHORIZED, "", false) << std::flush; + break; + } + if (mapHeaders["connection"] == "close") + fRun = false; + + JSONRequest jreq; + try + { + // Parse request + Value valRequest; + if (!read_string(strRequest, valRequest)) + throw JSONRPCError(RPC_PARSE_ERROR, "Parse error"); + + string strReply; + + // singleton request + if (valRequest.type() == obj_type) { + jreq.parse(valRequest); + + Value result = tableRPC.execute(jreq.strMethod, jreq.params); + + // Send reply + strReply = JSONRPCReply(result, Value::null, jreq.id); + + // array of requests + } else if (valRequest.type() == array_type) + strReply = JSONRPCExecBatch(valRequest.get_array()); + else + throw JSONRPCError(RPC_PARSE_ERROR, "Top-level object parse error"); + + conn->stream() << HTTPReply(HTTP_OK, strReply, fRun) << std::flush; + } + catch (Object& objError) + { + ErrorReply(conn->stream(), objError, jreq.id); + break; + } + catch (std::exception& e) + { + ErrorReply(conn->stream(), JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id); + break; + } + } +} + +json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_spirit::Array ¶ms) const +{ + // Find method + const CRPCCommand *pcmd = tableRPC[strMethod]; + if (!pcmd) + throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found"); +#ifdef ENABLE_WALLET + if (pcmd->reqWallet && !pwalletMain) + throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)"); +#endif + + // Observe safe mode + string strWarning = GetWarnings("rpc"); + if (strWarning != "" && !GetBoolArg("-disablesafemode", false) && + !pcmd->okSafeMode) + throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning); + + try + { + // Execute + Value result; + { + if (pcmd->threadSafe) + result = pcmd->actor(params, false); +#ifdef ENABLE_WALLET + else if (!pwalletMain) { + LOCK(cs_main); + result = pcmd->actor(params, false); + } else { + LOCK2(cs_main, pwalletMain->cs_wallet); + result = pcmd->actor(params, false); + } +#else // ENABLE_WALLET + else { + LOCK(cs_main); + result = pcmd->actor(params, false); + } +#endif // !ENABLE_WALLET + } + return result; + } + catch (std::exception& e) + { + throw JSONRPCError(RPC_MISC_ERROR, e.what()); + } +} + +const CRPCTable tableRPC; diff --git a/src/rpcserver.h b/src/rpcserver.h new file mode 100644 index 0000000..2367241 --- /dev/null +++ b/src/rpcserver.h @@ -0,0 +1,204 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef _BITCOINRPC_SERVER_H_ +#define _BITCOINRPC_SERVER_H_ 1 + +#include "uint256.h" +#include "rpcprotocol.h" + +#include +#include + +class CBlockIndex; + +void StartRPCThreads(); +void StopRPCThreads(); + +/* + Type-check arguments; throws JSONRPCError if wrong type given. Does not check that + the right number of arguments are passed, just that any passed are the correct type. + Use like: RPCTypeCheck(params, boost::assign::list_of(str_type)(int_type)(obj_type)); +*/ +void RPCTypeCheck(const json_spirit::Array& params, + const std::list& typesExpected, bool fAllowNull=false); +/* + Check for expected keys/value types in an Object. + Use like: RPCTypeCheck(object, boost::assign::map_list_of("name", str_type)("value", int_type)); +*/ +void RPCTypeCheck(const json_spirit::Object& o, + const std::map& typesExpected, bool fAllowNull=false); + +/* + Run func nSeconds from now. Uses boost deadline timers. + Overrides previous timer (if any). + */ +void RPCRunLater(const std::string& name, boost::function func, int64_t nSeconds); + +typedef json_spirit::Value(*rpcfn_type)(const json_spirit::Array& params, bool fHelp); + +class CRPCCommand +{ +public: + std::string name; + rpcfn_type actor; + bool okSafeMode; + bool threadSafe; + bool reqWallet; +}; + +/** + * Bitcoin RPC command dispatcher. + */ +class CRPCTable +{ +private: + std::map mapCommands; +public: + CRPCTable(); + const CRPCCommand* operator[](std::string name) const; + std::string help(std::string name) const; + + /** + * Execute a method. + * @param method Method to execute + * @param params Array of arguments (JSON objects) + * @returns Result of the call. + * @throws an exception (json_spirit::Value) when an error happens. + */ + json_spirit::Value execute(const std::string &method, const json_spirit::Array ¶ms) const; +}; + +extern const CRPCTable tableRPC; + +extern void InitRPCMining(); +extern void ShutdownRPCMining(); + +extern int64_t nWalletUnlockTime; +extern int64_t AmountFromValue(const json_spirit::Value& value); +extern json_spirit::Value ValueFromAmount(int64_t amount); +extern double GetDifficulty(const CBlockIndex* blockindex = NULL); + +extern double GetPoWMHashPS(); +extern double GetPoSKernelPS(); + +extern std::string HelpRequiringPassphrase(); +extern void EnsureWalletIsUnlocked(); + +// +// Utilities: convert hex-encoded Values +// (throws error if not hex). +// +extern uint256 ParseHashV(const json_spirit::Value& v, std::string strName); +extern uint256 ParseHashO(const json_spirit::Object& o, std::string strKey); +extern std::vector ParseHexV(const json_spirit::Value& v, std::string strName); +extern std::vector ParseHexO(const json_spirit::Object& o, std::string strKey); + +extern json_spirit::Value getconnectioncount(const json_spirit::Array& params, bool fHelp); // in rpcnet.cpp +extern json_spirit::Value getpeerinfo(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value ping(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value addnode(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getnettotals(const json_spirit::Array& params, bool fHelp); + +extern json_spirit::Value dumpwallet(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value importwallet(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value dumpprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp +extern json_spirit::Value importprivkey(const json_spirit::Array& params, bool fHelp); + +extern json_spirit::Value sendalert(const json_spirit::Array& params, bool fHelp); + +extern json_spirit::Value getsubsidy(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getstakesubsidy(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getmininginfo(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getstakinginfo(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value checkkernel(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getwork(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getworkex(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getblocktemplate(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value submitblock(const json_spirit::Array& params, bool fHelp); + +extern json_spirit::Value getnewaddress(const json_spirit::Array& params, bool fHelp); // in rpcwallet.cpp +extern json_spirit::Value getaccountaddress(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value setaccount(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getaccount(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getaddressesbyaccount(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value sendtoaddress(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value signmessage(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value verifymessage(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getreceivedbyaddress(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getreceivedbyaccount(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getbalance(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value movecmd(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value sendfrom(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value sendmany(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value addmultisigaddress(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value addredeemscript(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value listreceivedbyaddress(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value listreceivedbyaccount(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value listtransactions(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value listaddressgroupings(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value listaccounts(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value listsinceblock(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value gettransaction(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value backupwallet(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value keypoolrefill(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value walletpassphrase(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value walletpassphrasechange(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value walletlock(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value encryptwallet(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value validateaddress(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getinfo(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value reservebalance(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value checkwallet(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value repairwallet(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value resendtx(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value makekeypair(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value validatepubkey(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getnewpubkey(const json_spirit::Array& params, bool fHelp); + +extern json_spirit::Value getrawtransaction(const json_spirit::Array& params, bool fHelp); // in rcprawtransaction.cpp +extern json_spirit::Value searchrawtransactions(const json_spirit::Array& params, bool fHelp); + +extern json_spirit::Value listunspent(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value createrawtransaction(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value decoderawtransaction(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value decodescript(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value signrawtransaction(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value sendrawtransaction(const json_spirit::Array& params, bool fHelp); + +extern json_spirit::Value getbestblockhash(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp +extern json_spirit::Value getblockcount(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp +extern json_spirit::Value getdifficulty(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value settxfee(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getrawmempool(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getblockhash(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getblock(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getblockbynumber(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getcheckpoint(const json_spirit::Array& params, bool fHelp); + +extern json_spirit::Value getnewstealthaddress(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value liststealthaddresses(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value importstealthaddress(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value sendtostealthaddress(const json_spirit::Array& params, bool fHelp); + +extern json_spirit::Value darksend(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value spork(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value masternode(const json_spirit::Array& params, bool fHelp); + +extern json_spirit::Value smsgenable(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsgdisable(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsglocalkeys(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsgoptions(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsgscanchain(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsgscanbuckets(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsgaddkey(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsggetpubkey(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsgsend(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsgsendanon(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsginbox(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsgoutbox(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value smsgbuckets(const json_spirit::Array& params, bool fHelp); +#endif diff --git a/src/rpcsmessage.cpp b/src/rpcsmessage.cpp new file mode 100644 index 0000000..4f64094 --- /dev/null +++ b/src/rpcsmessage.cpp @@ -0,0 +1,895 @@ +// Copyright (c) 2014 The ShadowCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "main.h" +#include "rpcserver.h" + +#include + +#include "smessage.h" +#include "init.h" // pwalletMain + +using namespace json_spirit; +using namespace std; + +extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, json_spirit::Object& entry); + + + +Value smsgenable(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "smsgenable \n" + "Enable secure messaging."); + + if (fSecMsgEnabled) + throw runtime_error("Secure messaging is already enabled."); + + Object result; + if (!SecureMsgEnable()) + { + result.push_back(Pair("result", "Failed to enable secure messaging.")); + } else + { + result.push_back(Pair("result", "Enabled secure messaging.")); + } + return result; +} + +Value smsgdisable(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "smsgdisable \n" + "Disable secure messaging."); + if (!fSecMsgEnabled) + throw runtime_error("Secure messaging is already disabled."); + + Object result; + if (!SecureMsgDisable()) + { + result.push_back(Pair("result", "Failed to disable secure messaging.")); + } else + { + result.push_back(Pair("result", "Disabled secure messaging.")); + } + return result; +} + +Value smsgoptions(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 3) + throw runtime_error( + "smsgoptions [list|set ]\n" + "List and manage options."); + + std::string mode = "list"; + if (params.size() > 0) + { + mode = params[0].get_str(); + }; + + Object result; + + if (mode == "list") + { + result.push_back(Pair("option", std::string("newAddressRecv = ") + (smsgOptions.fNewAddressRecv ? "true" : "false"))); + result.push_back(Pair("option", std::string("newAddressAnon = ") + (smsgOptions.fNewAddressAnon ? "true" : "false"))); + + result.push_back(Pair("result", "Success.")); + } else + if (mode == "set") + { + if (params.size() < 3) + { + result.push_back(Pair("result", "Too few parameters.")); + result.push_back(Pair("expected", "set ")); + return result; + }; + + std::string optname = params[1].get_str(); + std::string value = params[2].get_str(); + + if (optname == "newAddressRecv") + { + if (value == "+" || value == "on" || value == "true" || value == "1") + { + smsgOptions.fNewAddressRecv = true; + } else + if (value == "-" || value == "off" || value == "false" || value == "0") + { + smsgOptions.fNewAddressRecv = false; + } else + { + result.push_back(Pair("result", "Unknown value.")); + return result; + }; + result.push_back(Pair("set option", std::string("newAddressRecv = ") + (smsgOptions.fNewAddressRecv ? "true" : "false"))); + } else + if (optname == "newAddressAnon") + { + if (value == "+" || value == "on" || value == "true" || value == "1") + { + smsgOptions.fNewAddressAnon = true; + } else + if (value == "-" || value == "off" || value == "false" || value == "0") + { + smsgOptions.fNewAddressAnon = false; + } else + { + result.push_back(Pair("result", "Unknown value.")); + return result; + }; + result.push_back(Pair("set option", std::string("newAddressAnon = ") + (smsgOptions.fNewAddressAnon ? "true" : "false"))); + } else + { + result.push_back(Pair("result", "Option not found.")); + return result; + }; + } else + { + result.push_back(Pair("result", "Unknown Mode.")); + result.push_back(Pair("expected", "smsgoption [list|set ]")); + }; + return result; +} + +Value smsglocalkeys(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 3) + throw runtime_error( + "smsglocalkeys [whitelist|all|wallet|recv <+/->
|anon <+/->
]\n" + "List and manage keys."); + + if (!fSecMsgEnabled) + throw runtime_error("Secure messaging is disabled."); + + Object result; + + std::string mode = "whitelist"; + if (params.size() > 0) + { + mode = params[0].get_str(); + }; + + char cbuf[256]; + + if (mode == "whitelist" + || mode == "all") + { + uint32_t nKeys = 0; + int all = mode == "all" ? 1 : 0; + for (std::vector::iterator it = smsgAddresses.begin(); it != smsgAddresses.end(); ++it) + { + if (!all + && !it->fReceiveEnabled) + continue; + + CBitcoinAddress coinAddress(it->sAddress); + if (!coinAddress.IsValid()) + continue; + + std::string sPublicKey; + + CKeyID keyID; + if (!coinAddress.GetKeyID(keyID)) + continue; + + CPubKey pubKey; + if (!pwalletMain->GetPubKey(keyID, pubKey)) + continue; + if (!pubKey.IsValid() + || !pubKey.IsCompressed()) + { + continue; + }; + + + sPublicKey = EncodeBase58(pubKey.Raw()); + + std::string sLabel = pwalletMain->mapAddressBook[keyID]; + std::string sInfo; + if (all) + sInfo = std::string("Receive ") + (it->fReceiveEnabled ? "on, " : "off, "); + sInfo += std::string("Anon ") + (it->fReceiveAnon ? "on" : "off"); + result.push_back(Pair("key", it->sAddress + " - " + sPublicKey + " " + sInfo + " - " + sLabel)); + + nKeys++; + }; + + + snprintf(cbuf, sizeof(cbuf), "%u keys listed.", nKeys); + result.push_back(Pair("result", std::string(cbuf))); + + } else + if (mode == "recv") + { + if (params.size() < 3) + { + result.push_back(Pair("result", "Too few parameters.")); + result.push_back(Pair("expected", "recv <+/->
")); + return result; + }; + + std::string op = params[1].get_str(); + std::string addr = params[2].get_str(); + + std::vector::iterator it; + for (it = smsgAddresses.begin(); it != smsgAddresses.end(); ++it) + { + if (addr != it->sAddress) + continue; + break; + }; + + if (it == smsgAddresses.end()) + { + result.push_back(Pair("result", "Address not found.")); + return result; + }; + + if (op == "+" || op == "on" || op == "add" || op == "a") + { + it->fReceiveEnabled = true; + } else + if (op == "-" || op == "off" || op == "rem" || op == "r") + { + it->fReceiveEnabled = false; + } else + { + result.push_back(Pair("result", "Unknown operation.")); + return result; + }; + + std::string sInfo; + sInfo = std::string("Receive ") + (it->fReceiveEnabled ? "on, " : "off,"); + sInfo += std::string("Anon ") + (it->fReceiveAnon ? "on" : "off"); + result.push_back(Pair("result", "Success.")); + result.push_back(Pair("key", it->sAddress + " " + sInfo)); + return result; + + } else + if (mode == "anon") + { + if (params.size() < 3) + { + result.push_back(Pair("result", "Too few parameters.")); + result.push_back(Pair("expected", "anon <+/->
")); + return result; + }; + + std::string op = params[1].get_str(); + std::string addr = params[2].get_str(); + + std::vector::iterator it; + for (it = smsgAddresses.begin(); it != smsgAddresses.end(); ++it) + { + if (addr != it->sAddress) + continue; + break; + }; + + if (it == smsgAddresses.end()) + { + result.push_back(Pair("result", "Address not found.")); + return result; + }; + + if (op == "+" || op == "on" || op == "add" || op == "a") + { + it->fReceiveAnon = true; + } else + if (op == "-" || op == "off" || op == "rem" || op == "r") + { + it->fReceiveAnon = false; + } else + { + result.push_back(Pair("result", "Unknown operation.")); + return result; + }; + + std::string sInfo; + sInfo = std::string("Receive ") + (it->fReceiveEnabled ? "on, " : "off,"); + sInfo += std::string("Anon ") + (it->fReceiveAnon ? "on" : "off"); + result.push_back(Pair("result", "Success.")); + result.push_back(Pair("key", it->sAddress + " " + sInfo)); + return result; + + } else + if (mode == "wallet") + { + uint32_t nKeys = 0; + BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& entry, pwalletMain->mapAddressBook) + { + if (!IsMine(*pwalletMain, entry.first)) + continue; + + CBitcoinAddress coinAddress(entry.first); + if (!coinAddress.IsValid()) + continue; + + std::string address; + std::string sPublicKey; + address = coinAddress.ToString(); + + CKeyID keyID; + if (!coinAddress.GetKeyID(keyID)) + continue; + + CPubKey pubKey; + if (!pwalletMain->GetPubKey(keyID, pubKey)) + continue; + if (!pubKey.IsValid() + || !pubKey.IsCompressed()) + { + continue; + }; + + sPublicKey = EncodeBase58(pubKey.Raw()); + + result.push_back(Pair("key", address + " - " + sPublicKey + " - " + entry.second)); + nKeys++; + }; + + snprintf(cbuf, sizeof(cbuf), "%u keys listed from wallet.", nKeys); + result.push_back(Pair("result", std::string(cbuf))); + } else + { + result.push_back(Pair("result", "Unknown Mode.")); + result.push_back(Pair("expected", "smsglocalkeys [whitelist|all|wallet|recv <+/->
|anon <+/->
]")); + }; + + return result; +}; + +Value smsgscanchain(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "smsgscanchain \n" + "Look for public keys in the block chain."); + + if (!fSecMsgEnabled) + throw runtime_error("Secure messaging is disabled."); + + Object result; + if (!SecureMsgScanBlockChain()) + { + result.push_back(Pair("result", "Scan Chain Failed.")); + } else + { + result.push_back(Pair("result", "Scan Chain Completed.")); + } + return result; +} + +Value smsgscanbuckets(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "smsgscanbuckets \n" + "Force rescan of all messages in the bucket store."); + + if (!fSecMsgEnabled) + throw runtime_error("Secure messaging is disabled."); + + if (pwalletMain->IsLocked()) + throw runtime_error("Wallet is locked."); + + Object result; + if (!SecureMsgScanBuckets()) + { + result.push_back(Pair("result", "Scan Buckets Failed.")); + } else + { + result.push_back(Pair("result", "Scan Buckets Completed.")); + } + return result; +} + +Value smsgaddkey(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 2) + throw runtime_error( + "smsgaddkey
\n" + "Add address, pubkey pair to database."); + + if (!fSecMsgEnabled) + throw runtime_error("Secure messaging is disabled."); + + std::string addr = params[0].get_str(); + std::string pubk = params[1].get_str(); + + Object result; + int rv = SecureMsgAddAddress(addr, pubk); + if (rv != 0) + { + result.push_back(Pair("result", "Public key not added to db.")); + switch (rv) + { + case 2: result.push_back(Pair("reason", "publicKey is invalid.")); break; + case 3: result.push_back(Pair("reason", "publicKey does not match address.")); break; + case 4: result.push_back(Pair("reason", "address is already in db.")); break; + case 5: result.push_back(Pair("reason", "address is invalid.")); break; + default: result.push_back(Pair("reason", "error.")); break; + }; + } else + { + result.push_back(Pair("result", "Added public key to db.")); + }; + + return result; +} + +Value smsggetpubkey(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "smsggetpubkey
\n" + "Return the base58 encoded compressed public key for an address.\n" + "Tests localkeys first, then looks in public key db.\n"); + + if (!fSecMsgEnabled) + throw runtime_error("Secure messaging is disabled."); + + + std::string address = params[0].get_str(); + std::string publicKey; + + Object result; + int rv = SecureMsgGetLocalPublicKey(address, publicKey); + switch (rv) + { + case 0: + result.push_back(Pair("result", "Success.")); + result.push_back(Pair("address in wallet", address)); + result.push_back(Pair("compressed public key", publicKey)); + return result; // success, don't check db + case 2: + case 3: + result.push_back(Pair("result", "Failed.")); + result.push_back(Pair("message", "Invalid address.")); + return result; + case 4: + break; // check db + //case 1: + default: + result.push_back(Pair("result", "Failed.")); + result.push_back(Pair("message", "Error.")); + return result; + }; + + CBitcoinAddress coinAddress(address); + + + CKeyID keyID; + if (!coinAddress.GetKeyID(keyID)) + { + result.push_back(Pair("result", "Failed.")); + result.push_back(Pair("message", "Invalid address.")); + return result; + }; + + CPubKey cpkFromDB; + rv = SecureMsgGetStoredKey(keyID, cpkFromDB); + + switch (rv) + { + case 0: + if (!cpkFromDB.IsValid() + || !cpkFromDB.IsCompressed()) + { + result.push_back(Pair("result", "Failed.")); + result.push_back(Pair("message", "Invalid address.")); + } else + { + //cpkFromDB.SetCompressedPubKey(); // make sure key is compressed + publicKey = EncodeBase58(cpkFromDB.Raw()); + + result.push_back(Pair("result", "Success.")); + result.push_back(Pair("peer address in DB", address)); + result.push_back(Pair("compressed public key", publicKey)); + }; + break; + case 2: + result.push_back(Pair("result", "Failed.")); + result.push_back(Pair("message", "Address not found in wallet or db.")); + return result; + //case 1: + default: + result.push_back(Pair("result", "Failed.")); + result.push_back(Pair("message", "Error, GetStoredKey().")); + return result; + }; + + return result; +} + +Value smsgsend(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 3) + throw runtime_error( + "smsgsend \n" + "Send an encrypted message from addrFrom to addrTo."); + + if (!fSecMsgEnabled) + throw runtime_error("Secure messaging is disabled."); + + std::string addrFrom = params[0].get_str(); + std::string addrTo = params[1].get_str(); + std::string msg = params[2].get_str(); + + + Object result; + + std::string sError; + if (SecureMsgSend(addrFrom, addrTo, msg, sError) != 0) + { + result.push_back(Pair("result", "Send failed.")); + result.push_back(Pair("error", sError)); + } else + result.push_back(Pair("result", "Sent.")); + + return result; +} + +Value smsgsendanon(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 2) + throw runtime_error( + "smsgsendanon \n" + "Send an anonymous encrypted message to addrTo."); + + if (!fSecMsgEnabled) + throw runtime_error("Secure messaging is disabled."); + + std::string addrFrom = "anon"; + std::string addrTo = params[0].get_str(); + std::string msg = params[1].get_str(); + + + Object result; + std::string sError; + if (SecureMsgSend(addrFrom, addrTo, msg, sError) != 0) + { + result.push_back(Pair("result", "Send failed.")); + result.push_back(Pair("error", sError)); + } else + result.push_back(Pair("result", "Sent.")); + + return result; +} + +Value smsginbox(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) // defaults to read + throw runtime_error( + "smsginbox [all|unread|clear]\n" + "Decrypt and display all received messages.\n" + "Warning: clear will delete all messages."); + + if (!fSecMsgEnabled) + throw runtime_error("Secure messaging is disabled."); + + if (pwalletMain->IsLocked()) + throw runtime_error("Wallet is locked."); + + std::string mode = "unread"; + if (params.size() > 0) + { + mode = params[0].get_str(); + } + + + Object result; + + std::vector vchKey; + vchKey.resize(16); + memset(&vchKey[0], 0, 16); + + { + LOCK(cs_smsgDB); + + SecMsgDB dbInbox; + + if (!dbInbox.Open("cr+")) + throw runtime_error("Could not open DB."); + + uint32_t nMessages = 0; + char cbuf[256]; + + std::string sPrefix("im"); + unsigned char chKey[18]; + + if (mode == "clear") + { + dbInbox.TxnBegin(); + + leveldb::Iterator* it = dbInbox.pdb->NewIterator(leveldb::ReadOptions()); + while (dbInbox.NextSmesgKey(it, sPrefix, chKey)) + { + dbInbox.EraseSmesg(chKey); + nMessages++; + }; + delete it; + dbInbox.TxnCommit(); + + snprintf(cbuf, sizeof(cbuf), "Deleted %u messages.", nMessages); + result.push_back(Pair("result", std::string(cbuf))); + } else + if (mode == "all" + || mode == "unread") + { + int fCheckReadStatus = mode == "unread" ? 1 : 0; + + SecMsgStored smsgStored; + MessageData msg; + + dbInbox.TxnBegin(); + + leveldb::Iterator* it = dbInbox.pdb->NewIterator(leveldb::ReadOptions()); + while (dbInbox.NextSmesg(it, sPrefix, chKey, smsgStored)) + { + if (fCheckReadStatus + && !(smsgStored.status & SMSG_MASK_UNREAD)) + continue; + + uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; + if (SecureMsgDecrypt(false, smsgStored.sAddrTo, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) + { + Object objM; + objM.push_back(Pair("received", getTimeString(smsgStored.timeReceived, cbuf, sizeof(cbuf)))); + objM.push_back(Pair("sent", getTimeString(msg.timestamp, cbuf, sizeof(cbuf)))); + objM.push_back(Pair("from", msg.sFromAddress)); + objM.push_back(Pair("to", smsgStored.sAddrTo)); + objM.push_back(Pair("text", std::string((char*)&msg.vchMessage[0]))); // ugh + + result.push_back(Pair("message", objM)); + } else + { + result.push_back(Pair("message", "Could not decrypt.")); + }; + + if (fCheckReadStatus) + { + smsgStored.status &= ~SMSG_MASK_UNREAD; + dbInbox.WriteSmesg(chKey, smsgStored); + }; + nMessages++; + }; + delete it; + dbInbox.TxnCommit(); + + snprintf(cbuf, sizeof(cbuf), "%u messages shown.", nMessages); + result.push_back(Pair("result", std::string(cbuf))); + + } else + { + result.push_back(Pair("result", "Unknown Mode.")); + result.push_back(Pair("expected", "[all|unread|clear].")); + }; + } + + return result; +}; + +Value smsgoutbox(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) // defaults to read + throw runtime_error( + "smsgoutbox [all|clear]\n" + "Decrypt and display all sent messages.\n" + "Warning: clear will delete all sent messages."); + + if (!fSecMsgEnabled) + throw runtime_error("Secure messaging is disabled."); + + if (pwalletMain->IsLocked()) + throw runtime_error("Wallet is locked."); + + std::string mode = "all"; + if (params.size() > 0) + { + mode = params[0].get_str(); + } + + + Object result; + + std::string sPrefix("sm"); + unsigned char chKey[18]; + memset(&chKey[0], 0, 18); + + { + LOCK(cs_smsgDB); + + SecMsgDB dbOutbox; + + if (!dbOutbox.Open("cr+")) + throw runtime_error("Could not open DB."); + + uint32_t nMessages = 0; + char cbuf[256]; + + if (mode == "clear") + { + dbOutbox.TxnBegin(); + + leveldb::Iterator* it = dbOutbox.pdb->NewIterator(leveldb::ReadOptions()); + while (dbOutbox.NextSmesgKey(it, sPrefix, chKey)) + { + dbOutbox.EraseSmesg(chKey); + nMessages++; + }; + delete it; + dbOutbox.TxnCommit(); + + + snprintf(cbuf, sizeof(cbuf), "Deleted %u messages.", nMessages); + result.push_back(Pair("result", std::string(cbuf))); + } else + if (mode == "all") + { + SecMsgStored smsgStored; + MessageData msg; + leveldb::Iterator* it = dbOutbox.pdb->NewIterator(leveldb::ReadOptions()); + while (dbOutbox.NextSmesg(it, sPrefix, chKey, smsgStored)) + { + uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; + + if (SecureMsgDecrypt(false, smsgStored.sAddrOutbox, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) + { + Object objM; + objM.push_back(Pair("sent", getTimeString(msg.timestamp, cbuf, sizeof(cbuf)))); + objM.push_back(Pair("from", msg.sFromAddress)); + objM.push_back(Pair("to", smsgStored.sAddrTo)); + objM.push_back(Pair("text", std::string((char*)&msg.vchMessage[0]))); // ugh + + result.push_back(Pair("message", objM)); + } else + { + result.push_back(Pair("message", "Could not decrypt.")); + }; + nMessages++; + }; + delete it; + + snprintf(cbuf, sizeof(cbuf), "%u sent messages shown.", nMessages); + result.push_back(Pair("result", std::string(cbuf))); + } else + { + result.push_back(Pair("result", "Unknown Mode.")); + result.push_back(Pair("expected", "[all|clear].")); + }; + } + + return result; +}; + + +Value smsgbuckets(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "smsgbuckets [stats|dump]\n" + "Display some statistics."); + + if (!fSecMsgEnabled) + throw runtime_error("Secure messaging is disabled."); + + std::string mode = "stats"; + if (params.size() > 0) + { + mode = params[0].get_str(); + }; + + Object result; + + char cbuf[256]; + if (mode == "stats") + { + uint32_t nBuckets = 0; + uint32_t nMessages = 0; + uint64_t nBytes = 0; + { + LOCK(cs_smsg); + std::map::iterator it; + it = smsgBuckets.begin(); + + for (it = smsgBuckets.begin(); it != smsgBuckets.end(); ++it) + { + std::set& tokenSet = it->second.setTokens; + + std::string sBucket = boost::lexical_cast(it->first); + std::string sFile = sBucket + "_01.dat"; + + snprintf(cbuf, sizeof(cbuf), "%" PRIszu, tokenSet.size()); + std::string snContents(cbuf); + + std::string sHash = boost::lexical_cast(it->second.hash); + + nBuckets++; + nMessages += tokenSet.size(); + + Object objM; + objM.push_back(Pair("bucket", sBucket)); + objM.push_back(Pair("time", getTimeString(it->first, cbuf, sizeof(cbuf)))); + objM.push_back(Pair("no. messages", snContents)); + objM.push_back(Pair("hash", sHash)); + objM.push_back(Pair("last changed", getTimeString(it->second.timeChanged, cbuf, sizeof(cbuf)))); + + boost::filesystem::path fullPath = GetDataDir() / "smsgStore" / sFile; + + + if (!boost::filesystem::exists(fullPath)) + { + // -- If there is a file for an empty bucket something is wrong. + if (tokenSet.size() == 0) + objM.push_back(Pair("file size", "Empty bucket.")); + else + objM.push_back(Pair("file size, error", "File not found.")); + } else + { + try { + + uint64_t nFBytes = 0; + nFBytes = boost::filesystem::file_size(fullPath); + nBytes += nFBytes; + objM.push_back(Pair("file size", bytesReadable(nFBytes))); + } catch (const boost::filesystem::filesystem_error& ex) + { + objM.push_back(Pair("file size, error", ex.what())); + }; + }; + + result.push_back(Pair("bucket", objM)); + }; + }; // LOCK(cs_smsg); + + + std::string snBuckets = boost::lexical_cast(nBuckets); + std::string snMessages = boost::lexical_cast(nMessages); + + Object objM; + objM.push_back(Pair("buckets", snBuckets)); + objM.push_back(Pair("messages", snMessages)); + objM.push_back(Pair("size", bytesReadable(nBytes))); + result.push_back(Pair("total", objM)); + + } else + if (mode == "dump") + { + { + LOCK(cs_smsg); + std::map::iterator it; + it = smsgBuckets.begin(); + + for (it = smsgBuckets.begin(); it != smsgBuckets.end(); ++it) + { + std::string sFile = boost::lexical_cast(it->first) + "_01.dat"; + + try { + boost::filesystem::path fullPath = GetDataDir() / "smsgStore" / sFile; + boost::filesystem::remove(fullPath); + } catch (const boost::filesystem::filesystem_error& ex) + { + //objM.push_back(Pair("file size, error", ex.what())); + printf("Error removing bucket file %s.\n", ex.what()); + }; + }; + smsgBuckets.clear(); + }; // LOCK(cs_smsg); + + result.push_back(Pair("result", "Removed all buckets.")); + + } else + { + result.push_back(Pair("result", "Unknown Mode.")); + result.push_back(Pair("expected", "[stats|dump].")); + }; + + + return result; +}; diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp new file mode 100644 index 0000000..fc13e3d --- /dev/null +++ b/src/rpcwallet.cpp @@ -0,0 +1,1938 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "base58.h" +#include "rpcserver.h" +#include "init.h" +#include "net.h" +#include "netbase.h" +#include "timedata.h" +#include "util.h" +#include "wallet.h" +#include "walletdb.h" + +using namespace std; +using namespace json_spirit; + +int64_t nWalletUnlockTime; +static CCriticalSection cs_nWalletUnlockTime; + +extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, json_spirit::Object& entry); + +static void accountingDeprecationCheck() +{ + if (!GetBoolArg("-enableaccounts", false)) + throw runtime_error( + "Accounting API is deprecated and will be removed in future.\n" + "It can easily result in negative or odd balances if misused or misunderstood, which has happened in the field.\n" + "If you still want to enable it, add to your config file enableaccounts=1\n"); + + if (GetBoolArg("-staking", true)) + throw runtime_error("If you want to use accounting API, staking must be disabled, add to your config file staking=0\n"); +} + +std::string HelpRequiringPassphrase() +{ + return pwalletMain && pwalletMain->IsCrypted() + ? "\nrequires wallet passphrase to be set with walletpassphrase first" + : ""; +} + +void EnsureWalletIsUnlocked() +{ + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); + if (fWalletUnlockStakingOnly) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Wallet is unlocked for staking only."); +} + +void WalletTxToJSON(const CWalletTx& wtx, Object& entry) +{ + int confirms = wtx.GetDepthInMainChain(); + entry.push_back(Pair("confirmations", confirms)); + if (wtx.IsCoinBase() || wtx.IsCoinStake()) + entry.push_back(Pair("generated", true)); + if (confirms > 0) + { + entry.push_back(Pair("blockhash", wtx.hashBlock.GetHex())); + entry.push_back(Pair("blockindex", wtx.nIndex)); + entry.push_back(Pair("blocktime", (int64_t)(mapBlockIndex[wtx.hashBlock]->nTime))); + } + entry.push_back(Pair("txid", wtx.GetHash().GetHex())); + entry.push_back(Pair("time", (int64_t)wtx.GetTxTime())); + entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived)); + BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue) + entry.push_back(Pair(item.first, item.second)); +} + +string AccountFromValue(const Value& value) +{ + string strAccount = value.get_str(); + if (strAccount == "*") + throw JSONRPCError(RPC_WALLET_INVALID_ACCOUNT_NAME, "Invalid account name"); + return strAccount; +} + + +Value getnewpubkey(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "getnewpubkey [account]\n" + "Returns new public key for coinbase generation."); + + // Parse the account first so we don't generate a key if there's an error + string strAccount; + if (params.size() > 0) + strAccount = AccountFromValue(params[0]); + + if (!pwalletMain->IsLocked()) + pwalletMain->TopUpKeyPool(); + + // Generate a new key that is added to wallet + CPubKey newKey; + if (!pwalletMain->GetKeyFromPool(newKey)) + throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); + CKeyID keyID = newKey.GetID(); + + pwalletMain->SetAddressBookName(keyID, strAccount); + + return HexStr(newKey.begin(), newKey.end()); +} + + +Value getnewaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "getnewaddress [account]\n" + "Returns a new SONO address for receiving payments. " + "If [account] is specified, it is added to the address book " + "so payments received with the address will be credited to [account]."); + + // Parse the account first so we don't generate a key if there's an error + string strAccount; + if (params.size() > 0) + strAccount = AccountFromValue(params[0]); + + if (!pwalletMain->IsLocked()) + pwalletMain->TopUpKeyPool(); + + // Generate a new key that is added to wallet + CPubKey newKey; + if (!pwalletMain->GetKeyFromPool(newKey)) + throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); + CKeyID keyID = newKey.GetID(); + + pwalletMain->SetAddressBookName(keyID, strAccount); + + return CBitcoinAddress(keyID).ToString(); +} + + +CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false) +{ + CWalletDB walletdb(pwalletMain->strWalletFile); + + CAccount account; + walletdb.ReadAccount(strAccount, account); + + bool bKeyUsed = false; + + // Check if the current key has been used + if (account.vchPubKey.IsValid()) + { + CScript scriptPubKey; + scriptPubKey.SetDestination(account.vchPubKey.GetID()); + for (map::iterator it = pwalletMain->mapWallet.begin(); + it != pwalletMain->mapWallet.end() && account.vchPubKey.IsValid(); + ++it) + { + const CWalletTx& wtx = (*it).second; + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + if (txout.scriptPubKey == scriptPubKey) + bKeyUsed = true; + } + } + + // Generate a new key + if (!account.vchPubKey.IsValid() || bForceNew || bKeyUsed) + { + if (!pwalletMain->GetKeyFromPool(account.vchPubKey)) + throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); + + pwalletMain->SetAddressBookName(account.vchPubKey.GetID(), strAccount); + walletdb.WriteAccount(strAccount, account); + } + + return CBitcoinAddress(account.vchPubKey.GetID()); +} + +Value getaccountaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getaccountaddress \n" + "Returns the current SONO address for receiving payments to this account."); + + // Parse the account first so we don't generate a key if there's an error + string strAccount = AccountFromValue(params[0]); + + Value ret; + + ret = GetAccountAddress(strAccount).ToString(); + + return ret; +} + + + +Value setaccount(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "setaccount \n" + "Sets the account associated with the given address."); + + CBitcoinAddress address(params[0].get_str()); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid SONO address"); + + + string strAccount; + if (params.size() > 1) + strAccount = AccountFromValue(params[1]); + + // Detect when changing the account of an address that is the 'unused current key' of another account: + if (pwalletMain->mapAddressBook.count(address.Get())) + { + string strOldAccount = pwalletMain->mapAddressBook[address.Get()]; + if (address == GetAccountAddress(strOldAccount)) + GetAccountAddress(strOldAccount, true); + } + + pwalletMain->SetAddressBookName(address.Get(), strAccount); + + return Value::null; +} + + +Value getaccount(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getaccount \n" + "Returns the account associated with the given address."); + + CBitcoinAddress address(params[0].get_str()); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid SONO address"); + + string strAccount; + map::iterator mi = pwalletMain->mapAddressBook.find(address.Get()); + if (mi != pwalletMain->mapAddressBook.end() && !(*mi).second.empty()) + strAccount = (*mi).second; + return strAccount; +} + + +Value getaddressesbyaccount(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getaddressesbyaccount \n" + "Returns the list of addresses for the given account."); + + string strAccount = AccountFromValue(params[0]); + + // Find all addresses that have the given account + Array ret; + BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook) + { + const CBitcoinAddress& address = item.first; + const string& strName = item.second; + if (strName == strAccount) + ret.push_back(address.ToString()); + } + return ret; +} + +Value sendtoaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 2 || params.size() > 5) + throw runtime_error( + "sendtoaddress [comment] [comment-to] [narration]\n" + " is a real and is rounded to the nearest 0.000001" + + HelpRequiringPassphrase()); + + CBitcoinAddress address(params[0].get_str()); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid SONO address"); + + // Amount + int64_t nAmount = AmountFromValue(params[1]); + + std::string sNarr; + if (params.size() > 4 && params[4].type() != null_type && !params[4].get_str().empty()) + sNarr = params[4].get_str(); + + if (sNarr.length() > 24) + throw runtime_error("Narration must be 24 characters or less."); + + // Wallet comments + CWalletTx wtx; + if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty()) + wtx.mapValue["comment"] = params[2].get_str(); + if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty()) + wtx.mapValue["to"] = params[3].get_str(); + + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); + + string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, sNarr, wtx); + if (strError != "") + throw JSONRPCError(RPC_WALLET_ERROR, strError); + + return wtx.GetHash().GetHex(); +} + +Value listaddressgroupings(const Array& params, bool fHelp) +{ + if (fHelp) + throw runtime_error( + "listaddressgroupings\n" + "Lists groups of addresses which have had their common ownership\n" + "made public by common use as inputs or as the resulting change\n" + "in past transactions"); + + Array jsonGroupings; + map balances = pwalletMain->GetAddressBalances(); + BOOST_FOREACH(set grouping, pwalletMain->GetAddressGroupings()) + { + Array jsonGrouping; + BOOST_FOREACH(CTxDestination address, grouping) + { + Array addressInfo; + addressInfo.push_back(CBitcoinAddress(address).ToString()); + addressInfo.push_back(ValueFromAmount(balances[address])); + { + LOCK(pwalletMain->cs_wallet); + if (pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get()) != pwalletMain->mapAddressBook.end()) + addressInfo.push_back(pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get())->second); + } + jsonGrouping.push_back(addressInfo); + } + jsonGroupings.push_back(jsonGrouping); + } + return jsonGroupings; +} + +Value signmessage(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 2) + throw runtime_error( + "signmessage \n" + "Sign a message with the private key of an address"); + + EnsureWalletIsUnlocked(); + + string strAddress = params[0].get_str(); + string strMessage = params[1].get_str(); + + CBitcoinAddress addr(strAddress); + if (!addr.IsValid()) + throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); + + CKeyID keyID; + if (!addr.GetKeyID(keyID)) + throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); + + CKey key; + if (!pwalletMain->GetKey(keyID, key)) + throw JSONRPCError(RPC_WALLET_ERROR, "Private key not available"); + + CHashWriter ss(SER_GETHASH, 0); + ss << strMessageMagic; + ss << strMessage; + + vector vchSig; + if (!key.SignCompact(ss.GetHash(), vchSig)) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed"); + + return EncodeBase64(&vchSig[0], vchSig.size()); +} + +Value getreceivedbyaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "getreceivedbyaddress [minconf=1]\n" + "Returns the total amount received by in transactions with at least [minconf] confirmations."); + + // Bitcoin address + CBitcoinAddress address = CBitcoinAddress(params[0].get_str()); + CScript scriptPubKey; + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid SONO address"); + scriptPubKey.SetDestination(address.Get()); + if (!IsMine(*pwalletMain,scriptPubKey)) + return (double)0.0; + + // Minimum confirmations + int nMinDepth = 1; + if (params.size() > 1) + nMinDepth = params[1].get_int(); + + // Tally + int64_t nAmount = 0; + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + if (wtx.IsCoinBase() || wtx.IsCoinStake() || !IsFinalTx(wtx)) + continue; + + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + if (txout.scriptPubKey == scriptPubKey) + if (wtx.GetDepthInMainChain() >= nMinDepth) + nAmount += txout.nValue; + } + + return ValueFromAmount(nAmount); +} + + +void GetAccountAddresses(string strAccount, set& setAddress) +{ + BOOST_FOREACH(const PAIRTYPE(CTxDestination, string)& item, pwalletMain->mapAddressBook) + { + const CTxDestination& address = item.first; + const string& strName = item.second; + if (strName == strAccount) + setAddress.insert(address); + } +} + +Value getreceivedbyaccount(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "getreceivedbyaccount [minconf=1]\n" + "Returns the total amount received by addresses with in transactions with at least [minconf] confirmations."); + + accountingDeprecationCheck(); + + // Minimum confirmations + int nMinDepth = 1; + if (params.size() > 1) + nMinDepth = params[1].get_int(); + + // Get the set of pub keys assigned to account + string strAccount = AccountFromValue(params[0]); + set setAddress; + GetAccountAddresses(strAccount, setAddress); + + // Tally + int64_t nAmount = 0; + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + if (wtx.IsCoinBase() || wtx.IsCoinStake() || !IsFinalTx(wtx)) + continue; + + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + { + CTxDestination address; + if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwalletMain, address) && setAddress.count(address)) + if (wtx.GetDepthInMainChain() >= nMinDepth) + nAmount += txout.nValue; + } + } + + return (double)nAmount / (double)COIN; +} + + +int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth) +{ + int64_t nBalance = 0; + + // Tally wallet transactions + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + if (!IsFinalTx(wtx) || wtx.GetDepthInMainChain() < 0) + continue; + + int64_t nReceived, nSent, nFee; + wtx.GetAccountAmounts(strAccount, nReceived, nSent, nFee); + + if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth && wtx.GetBlocksToMaturity() == 0) + nBalance += nReceived; + nBalance -= nSent + nFee; + } + + // Tally internal accounting entries + nBalance += walletdb.GetAccountCreditDebit(strAccount); + + return nBalance; +} + +int64_t GetAccountBalance(const string& strAccount, int nMinDepth) +{ + CWalletDB walletdb(pwalletMain->strWalletFile); + return GetAccountBalance(walletdb, strAccount, nMinDepth); +} + + +Value getbalance(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 2) + throw runtime_error( + "getbalance [account] [minconf=1]\n" + "If [account] is not specified, returns the server's total available balance.\n" + "If [account] is specified, returns the balance in the account."); + + if (params.size() == 0) + return ValueFromAmount(pwalletMain->GetBalance()); + + int nMinDepth = 1; + if (params.size() > 1) + nMinDepth = params[1].get_int(); + + if (params[0].get_str() == "*") { + // Calculate total balance a different way from GetBalance() + // (GetBalance() sums up all unspent TxOuts) + // getbalance and getbalance '*' 0 should return the same number. + int64_t nBalance = 0; + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + if (!wtx.IsTrusted()) + continue; + + int64_t allFee; + string strSentAccount; + list > listReceived; + list > listSent; + wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount); + if (wtx.GetDepthInMainChain() >= nMinDepth && wtx.GetBlocksToMaturity() == 0) + { + BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listReceived) + nBalance += r.second; + } + BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listSent) + nBalance -= r.second; + nBalance -= allFee; + } + return ValueFromAmount(nBalance); + } + + accountingDeprecationCheck(); + + string strAccount = AccountFromValue(params[0]); + + int64_t nBalance = GetAccountBalance(strAccount, nMinDepth); + + return ValueFromAmount(nBalance); +} + + +Value movecmd(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 3 || params.size() > 5) + throw runtime_error( + "move [minconf=1] [comment]\n" + "Move from one account in your wallet to another."); + + accountingDeprecationCheck(); + + string strFrom = AccountFromValue(params[0]); + string strTo = AccountFromValue(params[1]); + int64_t nAmount = AmountFromValue(params[2]); + + if (params.size() > 3) + // unused parameter, used to be nMinDepth, keep type-checking it though + (void)params[3].get_int(); + string strComment; + if (params.size() > 4) + strComment = params[4].get_str(); + + CWalletDB walletdb(pwalletMain->strWalletFile); + if (!walletdb.TxnBegin()) + throw JSONRPCError(RPC_DATABASE_ERROR, "database error"); + + int64_t nNow = GetAdjustedTime(); + + // Debit + CAccountingEntry debit; + debit.nOrderPos = pwalletMain->IncOrderPosNext(&walletdb); + debit.strAccount = strFrom; + debit.nCreditDebit = -nAmount; + debit.nTime = nNow; + debit.strOtherAccount = strTo; + debit.strComment = strComment; + walletdb.WriteAccountingEntry(debit); + + // Credit + CAccountingEntry credit; + credit.nOrderPos = pwalletMain->IncOrderPosNext(&walletdb); + credit.strAccount = strTo; + credit.nCreditDebit = nAmount; + credit.nTime = nNow; + credit.strOtherAccount = strFrom; + credit.strComment = strComment; + walletdb.WriteAccountingEntry(credit); + + if (!walletdb.TxnCommit()) + throw JSONRPCError(RPC_DATABASE_ERROR, "database error"); + + return true; +} + + +Value sendfrom(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 3 || params.size() > 7) + throw runtime_error( + "sendfrom [minconf=1] [comment] [comment-to] [narration]\n" + " is a real and is rounded to the nearest 0.000001" + + HelpRequiringPassphrase()); + + string strAccount = AccountFromValue(params[0]); + CBitcoinAddress address(params[1].get_str()); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid SONO address"); + int64_t nAmount = AmountFromValue(params[2]); + + int nMinDepth = 1; + if (params.size() > 3) + nMinDepth = params[3].get_int(); + + CWalletTx wtx; + wtx.strFromAccount = strAccount; + std::string sNarr; + if (params.size() > 6 && params[6].type() != null_type && !params[6].get_str().empty()) + sNarr = params[6].get_str(); + + if (sNarr.length() > 24) + throw runtime_error("Narration must be 24 characters or less."); + + if (params.size() > 4 && params[4].type() != null_type && !params[4].get_str().empty()) + wtx.mapValue["comment"] = params[4].get_str(); + if (params.size() > 5 && params[5].type() != null_type && !params[5].get_str().empty()) + wtx.mapValue["to"] = params[5].get_str(); + + EnsureWalletIsUnlocked(); + + // Check funds + int64_t nBalance = GetAccountBalance(strAccount, nMinDepth); + if (nAmount > nBalance) + throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); + + // Send + string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, sNarr, wtx); + if (strError != "") + throw JSONRPCError(RPC_WALLET_ERROR, strError); + + return wtx.GetHash().GetHex(); +} + + +Value sendmany(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 2 || params.size() > 4) + throw runtime_error( + "sendmany {address:amount,...} [minconf=1] [comment]\n" + "amounts are double-precision floating point numbers" + + HelpRequiringPassphrase()); + + string strAccount = AccountFromValue(params[0]); + Object sendTo = params[1].get_obj(); + int nMinDepth = 1; + if (params.size() > 2) + nMinDepth = params[2].get_int(); + + CWalletTx wtx; + wtx.strFromAccount = strAccount; + if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty()) + wtx.mapValue["comment"] = params[3].get_str(); + + set setAddress; + vector > vecSend; + + int64_t totalAmount = 0; + BOOST_FOREACH(const Pair& s, sendTo) + { + CBitcoinAddress address(s.name_); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid SONO address: ")+s.name_); + + if (setAddress.count(address)) + throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_); + setAddress.insert(address); + + CScript scriptPubKey; + scriptPubKey.SetDestination(address.Get()); + int64_t nAmount = AmountFromValue(s.value_); + + totalAmount += nAmount; + + vecSend.push_back(make_pair(scriptPubKey, nAmount)); + } + + EnsureWalletIsUnlocked(); + + // Check funds + int64_t nBalance = GetAccountBalance(strAccount, nMinDepth); + if (totalAmount > nBalance) + throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); + + // Send + CReserveKey keyChange(pwalletMain); + int64_t nFeeRequired = 0; + int nChangePos; + std::string strFailReason; + bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, nChangePos, strFailReason); + if (!fCreated) + { + if (totalAmount + nFeeRequired > pwalletMain->GetBalance()) + throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); + throw JSONRPCError(RPC_WALLET_ERROR, "Transaction creation failed"); + } + if (!pwalletMain->CommitTransaction(wtx, keyChange)) + throw JSONRPCError(RPC_WALLET_ERROR, "Transaction commit failed"); + + return wtx.GetHash().GetHex(); +} + +Value addmultisigaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 2 || params.size() > 3) + { + string msg = "addmultisigaddress <'[\"key\",\"key\"]'> [account]\n" + "Add a nrequired-to-sign multisignature address to the wallet\"\n" + "each key is a SONO address or hex-encoded public key\n" + "If [account] is specified, assign address to [account]."; + throw runtime_error(msg); + } + + int nRequired = params[0].get_int(); + const Array& keys = params[1].get_array(); + string strAccount; + if (params.size() > 2) + strAccount = AccountFromValue(params[2]); + + // Gather public keys + if (nRequired < 1) + throw runtime_error("a multisignature address must require at least one key to redeem"); + if ((int)keys.size() < nRequired) + throw runtime_error( + strprintf("not enough keys supplied " + "(got %u keys, but need at least %d to redeem)", keys.size(), nRequired)); + std::vector pubkeys; + pubkeys.resize(keys.size()); + for (unsigned int i = 0; i < keys.size(); i++) + { + const std::string& ks = keys[i].get_str(); + + // Case 1: Bitcoin address and we have full public key: + CBitcoinAddress address(ks); + if (pwalletMain && address.IsValid()) + { + CKeyID keyID; + if (!address.GetKeyID(keyID)) + throw runtime_error( + strprintf("%s does not refer to a key",ks)); + CPubKey vchPubKey; + if (!pwalletMain->GetPubKey(keyID, vchPubKey)) + throw runtime_error( + strprintf("no full public key for address %s",ks)); + if (!vchPubKey.IsFullyValid()) + throw runtime_error(" Invalid public key: "+ks); + pubkeys[i] = vchPubKey; + } + + // Case 2: hex public key + else if (IsHex(ks)) + { + CPubKey vchPubKey(ParseHex(ks)); + if (!vchPubKey.IsFullyValid()) + throw runtime_error(" Invalid public key: "+ks); + pubkeys[i] = vchPubKey; + } + else + { + throw runtime_error(" Invalid public key: "+ks); + } + } + + // Construct using pay-to-script-hash: + CScript inner; + inner.SetMultisig(nRequired, pubkeys); + CScriptID innerID = inner.GetID(); + if (!pwalletMain->AddCScript(inner)) + throw runtime_error("AddCScript() failed"); + + pwalletMain->SetAddressBookName(innerID, strAccount); + return CBitcoinAddress(innerID).ToString(); +} + +Value addredeemscript(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + { + string msg = "addredeemscript [account]\n" + "Add a P2SH address with a specified redeemScript to the wallet.\n" + "If [account] is specified, assign address to [account]."; + throw runtime_error(msg); + } + + string strAccount; + if (params.size() > 1) + strAccount = AccountFromValue(params[1]); + + // Construct using pay-to-script-hash: + vector innerData = ParseHexV(params[0], "redeemScript"); + CScript inner(innerData.begin(), innerData.end()); + CScriptID innerID = inner.GetID(); + if (!pwalletMain->AddCScript(inner)) + throw runtime_error("AddCScript() failed"); + + pwalletMain->SetAddressBookName(innerID, strAccount); + return CBitcoinAddress(innerID).ToString(); +} + +struct tallyitem +{ + int64_t nAmount; + int nConf; + tallyitem() + { + nAmount = 0; + nConf = std::numeric_limits::max(); + } +}; + +Value ListReceived(const Array& params, bool fByAccounts) +{ + // Minimum confirmations + int nMinDepth = 1; + if (params.size() > 0) + nMinDepth = params[0].get_int(); + + // Whether to include empty accounts + bool fIncludeEmpty = false; + if (params.size() > 1) + fIncludeEmpty = params[1].get_bool(); + + // Tally + map mapTally; + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + + if (wtx.IsCoinBase() || wtx.IsCoinStake() || !IsFinalTx(wtx)) + continue; + + int nDepth = wtx.GetDepthInMainChain(); + if (nDepth < nMinDepth) + continue; + + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + { + CTxDestination address; + if (!ExtractDestination(txout.scriptPubKey, address) || !IsMine(*pwalletMain, address)) + continue; + + tallyitem& item = mapTally[address]; + item.nAmount += txout.nValue; + item.nConf = min(item.nConf, nDepth); + } + } + + // Reply + Array ret; + map mapAccountTally; + BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook) + { + const CBitcoinAddress& address = item.first; + const string& strAccount = item.second; + map::iterator it = mapTally.find(address); + if (it == mapTally.end() && !fIncludeEmpty) + continue; + + int64_t nAmount = 0; + int nConf = std::numeric_limits::max(); + if (it != mapTally.end()) + { + nAmount = (*it).second.nAmount; + nConf = (*it).second.nConf; + } + + if (fByAccounts) + { + tallyitem& item = mapAccountTally[strAccount]; + item.nAmount += nAmount; + item.nConf = min(item.nConf, nConf); + } + else + { + Object obj; + obj.push_back(Pair("address", address.ToString())); + obj.push_back(Pair("account", strAccount)); + obj.push_back(Pair("amount", ValueFromAmount(nAmount))); + obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); + ret.push_back(obj); + } + } + + if (fByAccounts) + { + for (map::iterator it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it) + { + int64_t nAmount = (*it).second.nAmount; + int nConf = (*it).second.nConf; + Object obj; + obj.push_back(Pair("account", (*it).first)); + obj.push_back(Pair("amount", ValueFromAmount(nAmount))); + obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); + ret.push_back(obj); + } + } + + return ret; +} + +Value listreceivedbyaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 2) + throw runtime_error( + "listreceivedbyaddress [minconf=1] [includeempty=false]\n" + "[minconf] is the minimum number of confirmations before payments are included.\n" + "[includeempty] whether to include addresses that haven't received any payments.\n" + "Returns an array of objects containing:\n" + " \"address\" : receiving address\n" + " \"account\" : the account of the receiving address\n" + " \"amount\" : total amount received by the address\n" + " \"confirmations\" : number of confirmations of the most recent transaction included"); + + return ListReceived(params, false); +} + +Value listreceivedbyaccount(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 2) + throw runtime_error( + "listreceivedbyaccount [minconf=1] [includeempty=false]\n" + "[minconf] is the minimum number of confirmations before payments are included.\n" + "[includeempty] whether to include accounts that haven't received any payments.\n" + "Returns an array of objects containing:\n" + " \"account\" : the account of the receiving addresses\n" + " \"amount\" : total amount received by addresses with this account\n" + " \"confirmations\" : number of confirmations of the most recent transaction included"); + + accountingDeprecationCheck(); + + return ListReceived(params, true); +} + +static void MaybePushAddress(Object & entry, const CTxDestination &dest) +{ + CBitcoinAddress addr; + if (addr.Set(dest)) + entry.push_back(Pair("address", addr.ToString())); +} + +void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret) +{ + int64_t nFee; + string strSentAccount; + list > listReceived; + list > listSent; + + wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount); + + bool fAllAccounts = (strAccount == string("*")); + + // Sent + if ((!wtx.IsCoinStake()) && (!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount)) + { + BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& s, listSent) + { + Object entry; + entry.push_back(Pair("account", strSentAccount)); + MaybePushAddress(entry, s.first); + entry.push_back(Pair("category", "send")); + entry.push_back(Pair("amount", ValueFromAmount(-s.second))); + entry.push_back(Pair("fee", ValueFromAmount(-nFee))); + if (fLong) + WalletTxToJSON(wtx, entry); + ret.push_back(entry); + } + } + + // Received + if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) + { + bool stop = false; + BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& r, listReceived) + { + string account; + if (pwalletMain->mapAddressBook.count(r.first)) + account = pwalletMain->mapAddressBook[r.first]; + if (fAllAccounts || (account == strAccount)) + { + Object entry; + entry.push_back(Pair("account", account)); + MaybePushAddress(entry, r.first); + if (wtx.IsCoinBase() || wtx.IsCoinStake()) + { + if (wtx.GetDepthInMainChain() < 1) + entry.push_back(Pair("category", "orphan")); + else if (wtx.GetBlocksToMaturity() > 0) + entry.push_back(Pair("category", "immature")); + else + entry.push_back(Pair("category", "generate")); + } + else + { + entry.push_back(Pair("category", "receive")); + } + if (!wtx.IsCoinStake()) + entry.push_back(Pair("amount", ValueFromAmount(r.second))); + else + { + entry.push_back(Pair("amount", ValueFromAmount(-nFee))); + stop = true; // only one coinstake output + } + if (fLong) + WalletTxToJSON(wtx, entry); + ret.push_back(entry); + } + if (stop) + break; + } + } +} + +void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Array& ret) +{ + bool fAllAccounts = (strAccount == string("*")); + + if (fAllAccounts || acentry.strAccount == strAccount) + { + Object entry; + entry.push_back(Pair("account", acentry.strAccount)); + entry.push_back(Pair("category", "move")); + entry.push_back(Pair("time", (int64_t)acentry.nTime)); + entry.push_back(Pair("amount", ValueFromAmount(acentry.nCreditDebit))); + entry.push_back(Pair("otheraccount", acentry.strOtherAccount)); + entry.push_back(Pair("comment", acentry.strComment)); + ret.push_back(entry); + } +} + +Value listtransactions(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 3) + throw runtime_error( + "listtransactions [account] [count=10] [from=0]\n" + "Returns up to [count] most recent transactions skipping the first [from] transactions for account [account]."); + + string strAccount = "*"; + if (params.size() > 0) + strAccount = params[0].get_str(); + int nCount = 10; + if (params.size() > 1) + nCount = params[1].get_int(); + int nFrom = 0; + if (params.size() > 2) + nFrom = params[2].get_int(); + + if (nCount < 0) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count"); + if (nFrom < 0) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative from"); + + Array ret; + + std::list acentries; + CWallet::TxItems txOrdered = pwalletMain->OrderedTxItems(acentries, strAccount); + + // iterate backwards until we have nCount items to return: + for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) + { + CWalletTx *const pwtx = (*it).second.first; + if (pwtx != 0) + ListTransactions(*pwtx, strAccount, 0, true, ret); + CAccountingEntry *const pacentry = (*it).second.second; + if (pacentry != 0) + AcentryToJSON(*pacentry, strAccount, ret); + + if ((int)ret.size() >= (nCount+nFrom)) break; + } + // ret is newest to oldest + + if (nFrom > (int)ret.size()) + nFrom = ret.size(); + if ((nFrom + nCount) > (int)ret.size()) + nCount = ret.size() - nFrom; + Array::iterator first = ret.begin(); + std::advance(first, nFrom); + Array::iterator last = ret.begin(); + std::advance(last, nFrom+nCount); + + if (last != ret.end()) ret.erase(last, ret.end()); + if (first != ret.begin()) ret.erase(ret.begin(), first); + + std::reverse(ret.begin(), ret.end()); // Return oldest to newest + + return ret; +} + +Value listaccounts(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "listaccounts [minconf=1]\n" + "Returns Object that has account names as keys, account balances as values."); + + accountingDeprecationCheck(); + + int nMinDepth = 1; + if (params.size() > 0) + nMinDepth = params[0].get_int(); + + map mapAccountBalances; + BOOST_FOREACH(const PAIRTYPE(CTxDestination, string)& entry, pwalletMain->mapAddressBook) { + if (IsMine(*pwalletMain, entry.first)) // This address belongs to me + mapAccountBalances[entry.second] = 0; + } + + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + int64_t nFee; + string strSentAccount; + list > listReceived; + list > listSent; + int nDepth = wtx.GetDepthInMainChain(); + if (nDepth < 0) + continue; + wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount); + mapAccountBalances[strSentAccount] -= nFee; + BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& s, listSent) + mapAccountBalances[strSentAccount] -= s.second; + if (nDepth >= nMinDepth && wtx.GetBlocksToMaturity() == 0) + { + BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& r, listReceived) + if (pwalletMain->mapAddressBook.count(r.first)) + mapAccountBalances[pwalletMain->mapAddressBook[r.first]] += r.second; + else + mapAccountBalances[""] += r.second; + } + } + + list acentries; + CWalletDB(pwalletMain->strWalletFile).ListAccountCreditDebit("*", acentries); + BOOST_FOREACH(const CAccountingEntry& entry, acentries) + mapAccountBalances[entry.strAccount] += entry.nCreditDebit; + + Object ret; + BOOST_FOREACH(const PAIRTYPE(string, int64_t)& accountBalance, mapAccountBalances) { + ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); + } + return ret; +} + +Value listsinceblock(const Array& params, bool fHelp) +{ + if (fHelp) + throw runtime_error( + "listsinceblock [blockhash] [target-confirmations]\n" + "Get all transactions in blocks since block [blockhash], or all transactions if omitted"); + + CBlockIndex *pindex = NULL; + int target_confirms = 1; + + if (params.size() > 0) + { + uint256 blockId = 0; + + blockId.SetHex(params[0].get_str()); + pindex = CBlockLocator(blockId).GetBlockIndex(); + } + + if (params.size() > 1) + { + target_confirms = params[1].get_int(); + + if (target_confirms < 1) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter"); + } + + int depth = pindex ? (1 + nBestHeight - pindex->nHeight) : -1; + + Array transactions; + + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); it++) + { + CWalletTx tx = (*it).second; + + if (depth == -1 || tx.GetDepthInMainChain() < depth) + ListTransactions(tx, "*", 0, true, transactions); + } + + uint256 lastblock; + + if (target_confirms == 1) + { + lastblock = hashBestChain; + } + else + { + int target_height = pindexBest->nHeight + 1 - target_confirms; + + CBlockIndex *block; + for (block = pindexBest; + block && block->nHeight > target_height; + block = block->pprev) { } + + lastblock = block ? block->GetBlockHash() : 0; + } + + Object ret; + ret.push_back(Pair("transactions", transactions)); + ret.push_back(Pair("lastblock", lastblock.GetHex())); + + return ret; +} + +Value gettransaction(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "gettransaction \n" + "Get detailed information about "); + + uint256 hash; + hash.SetHex(params[0].get_str()); + + Object entry; + + if (pwalletMain->mapWallet.count(hash)) + { + const CWalletTx& wtx = pwalletMain->mapWallet[hash]; + + TxToJSON(wtx, 0, entry); + + int64_t nCredit = wtx.GetCredit(); + int64_t nDebit = wtx.GetDebit(); + int64_t nNet = nCredit - nDebit; + int64_t nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0); + + entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee))); + if (wtx.IsFromMe()) + entry.push_back(Pair("fee", ValueFromAmount(nFee))); + + WalletTxToJSON(wtx, entry); + + Array details; + ListTransactions(pwalletMain->mapWallet[hash], "*", 0, false, details); + entry.push_back(Pair("details", details)); + } + else + { + CTransaction tx; + uint256 hashBlock = 0; + if (GetTransaction(hash, tx, hashBlock)) + { + TxToJSON(tx, 0, entry); + if (hashBlock == 0) + entry.push_back(Pair("confirmations", 0)); + else + { + entry.push_back(Pair("blockhash", hashBlock.GetHex())); + map::iterator mi = mapBlockIndex.find(hashBlock); + if (mi != mapBlockIndex.end() && (*mi).second) + { + CBlockIndex* pindex = (*mi).second; + if (pindex->IsInMainChain()) + entry.push_back(Pair("confirmations", 1 + nBestHeight - pindex->nHeight)); + else + entry.push_back(Pair("confirmations", 0)); + } + } + } + else + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction"); + } + + return entry; +} + + +Value backupwallet(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "backupwallet \n" + "Safely copies wallet.dat to destination, which can be a directory or a path with filename."); + + string strDest = params[0].get_str(); + if (!BackupWallet(*pwalletMain, strDest)) + throw JSONRPCError(RPC_WALLET_ERROR, "Error: Wallet backup failed!"); + + return Value::null; +} + + +Value keypoolrefill(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "keypoolrefill [new-size]\n" + "Fills the keypool." + + HelpRequiringPassphrase()); + + unsigned int nSize = max(GetArg("-keypool", 100), (int64_t)0); + if (params.size() > 0) { + if (params[0].get_int() < 0) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected valid size"); + nSize = (unsigned int) params[0].get_int(); + } + + EnsureWalletIsUnlocked(); + + pwalletMain->TopUpKeyPool(nSize); + + if (pwalletMain->GetKeyPoolSize() < nSize) + throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool."); + + return Value::null; +} + + +static void LockWallet(CWallet* pWallet) +{ + LOCK(cs_nWalletUnlockTime); + nWalletUnlockTime = 0; + pWallet->Lock(); +} + +Value walletpassphrase(const Array& params, bool fHelp) +{ + if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 3)) + throw runtime_error( + "walletpassphrase [stakingonly]\n" + "Stores the wallet decryption key in memory for seconds.\n" + "if [stakingonly] is true sending functions are disabled."); + if (fHelp) + return true; + if (!fServer) + throw JSONRPCError(RPC_SERVER_NOT_STARTED, "Error: RPC server was not started, use server=1 to change this."); + if (!pwalletMain->IsCrypted()) + throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrase was called."); + + // Note that the walletpassphrase is stored in params[0] which is not mlock()ed + SecureString strWalletPass; + strWalletPass.reserve(100); + // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) + // Alternately, find a way to make params[0] mlock()'d to begin with. + strWalletPass = params[0].get_str().c_str(); + + if (strWalletPass.length() > 0) + { + if (!pwalletMain->Unlock(strWalletPass)) + throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect."); + } + else + throw runtime_error( + "walletpassphrase \n" + "Stores the wallet decryption key in memory for seconds."); + + pwalletMain->TopUpKeyPool(); + + int64_t nSleepTime = params[1].get_int64(); + LOCK(cs_nWalletUnlockTime); + nWalletUnlockTime = GetTime() + nSleepTime; + RPCRunLater("lockwallet", boost::bind(LockWallet, pwalletMain), nSleepTime); + + // ppcoin: if user OS account compromised prevent trivial sendmoney commands + if (params.size() > 2) + fWalletUnlockStakingOnly = params[2].get_bool(); + else + fWalletUnlockStakingOnly = false; + + return Value::null; +} + + +Value walletpassphrasechange(const Array& params, bool fHelp) +{ + if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2)) + throw runtime_error( + "walletpassphrasechange \n" + "Changes the wallet passphrase from to ."); + if (fHelp) + return true; + if (!pwalletMain->IsCrypted()) + throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrasechange was called."); + + // TODO: get rid of these .c_str() calls by implementing SecureString::operator=(std::string) + // Alternately, find a way to make params[0] mlock()'d to begin with. + SecureString strOldWalletPass; + strOldWalletPass.reserve(100); + strOldWalletPass = params[0].get_str().c_str(); + + SecureString strNewWalletPass; + strNewWalletPass.reserve(100); + strNewWalletPass = params[1].get_str().c_str(); + + if (strOldWalletPass.length() < 1 || strNewWalletPass.length() < 1) + throw runtime_error( + "walletpassphrasechange \n" + "Changes the wallet passphrase from to ."); + + if (!pwalletMain->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass)) + throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect."); + + return Value::null; +} + + +Value walletlock(const Array& params, bool fHelp) +{ + if (pwalletMain->IsCrypted() && (fHelp || params.size() != 0)) + throw runtime_error( + "walletlock\n" + "Removes the wallet encryption key from memory, locking the wallet.\n" + "After calling this method, you will need to call walletpassphrase again\n" + "before being able to call any methods which require the wallet to be unlocked."); + if (fHelp) + return true; + if (!pwalletMain->IsCrypted()) + throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called."); + + { + LOCK(cs_nWalletUnlockTime); + pwalletMain->Lock(); + nWalletUnlockTime = 0; + } + + return Value::null; +} + + +Value encryptwallet(const Array& params, bool fHelp) +{ + if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1)) + throw runtime_error( + "encryptwallet \n" + "Encrypts the wallet with ."); + if (fHelp) + return true; + if (pwalletMain->IsCrypted()) + throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called."); + + // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) + // Alternately, find a way to make params[0] mlock()'d to begin with. + SecureString strWalletPass; + strWalletPass.reserve(100); + strWalletPass = params[0].get_str().c_str(); + + if (strWalletPass.length() < 1) + throw runtime_error( + "encryptwallet \n" + "Encrypts the wallet with ."); + + if (!pwalletMain->EncryptWallet(strWalletPass)) + throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: Failed to encrypt the wallet."); + + // BDB seems to have a bad habit of writing old data into + // slack space in .dat files; that is bad if the old data is + // unencrypted private keys. So: + StartShutdown(); + return "wallet encrypted; SONO server stopping, restart to run with encrypted wallet. The keypool has been flushed, you need to make a new backup."; +} + + +// ppcoin: reserve balance from being staked for network protection +Value reservebalance(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 2) + throw runtime_error( + "reservebalance [ [amount]]\n" + " is true or false to turn balance reserve on or off.\n" + " is a real and rounded to cent.\n" + "Set reserve amount not participating in network protection.\n" + "If no parameters provided current setting is printed.\n"); + + if (params.size() > 0) + { + bool fReserve = params[0].get_bool(); + if (fReserve) + { + if (params.size() == 1) + throw runtime_error("must provide amount to reserve balance.\n"); + int64_t nAmount = AmountFromValue(params[1]); + nAmount = (nAmount / CENT) * CENT; // round to cent + if (nAmount < 0) + throw runtime_error("amount cannot be negative.\n"); + nReserveBalance = nAmount; + } + else + { + if (params.size() > 1) + throw runtime_error("cannot specify amount to turn off reserve.\n"); + nReserveBalance = 0; + } + } + + Object result; + result.push_back(Pair("reserve", (nReserveBalance > 0))); + result.push_back(Pair("amount", ValueFromAmount(nReserveBalance))); + return result; +} + + +// ppcoin: check wallet integrity +Value checkwallet(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 0) + throw runtime_error( + "checkwallet\n" + "Check wallet for integrity.\n"); + + int nMismatchSpent; + int64_t nBalanceInQuestion; + pwalletMain->FixSpentCoins(nMismatchSpent, nBalanceInQuestion, true); + Object result; + if (nMismatchSpent == 0) + result.push_back(Pair("wallet check passed", true)); + else + { + result.push_back(Pair("mismatched spent coins", nMismatchSpent)); + result.push_back(Pair("amount in question", ValueFromAmount(nBalanceInQuestion))); + } + return result; +} + + +// ppcoin: repair wallet +Value repairwallet(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 0) + throw runtime_error( + "repairwallet\n" + "Repair wallet if checkwallet reports any problem.\n"); + + int nMismatchSpent; + int64_t nBalanceInQuestion; + pwalletMain->FixSpentCoins(nMismatchSpent, nBalanceInQuestion); + Object result; + if (nMismatchSpent == 0) + result.push_back(Pair("wallet check passed", true)); + else + { + result.push_back(Pair("mismatched spent coins", nMismatchSpent)); + result.push_back(Pair("amount affected by repair", ValueFromAmount(nBalanceInQuestion))); + } + return result; +} + +// NovaCoin: resend unconfirmed wallet transactions +Value resendtx(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "resendtx\n" + "Re-send unconfirmed transactions.\n" + ); + + ResendWalletTransactions(true); + + return Value::null; +} + +// ppcoin: make a public-private key pair +Value makekeypair(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "makekeypair [prefix]\n" + "Make a public/private key pair.\n" + "[prefix] is optional preferred prefix for the public key.\n"); + + string strPrefix = ""; + if (params.size() > 0) + strPrefix = params[0].get_str(); + + CKey key; + key.MakeNewKey(false); + + CPrivKey vchPrivKey = key.GetPrivKey(); + Object result; + result.push_back(Pair("PrivateKey", HexStr(vchPrivKey.begin(), vchPrivKey.end()))); + result.push_back(Pair("PublicKey", HexStr(key.GetPubKey()))); + return result; +} + +Value settxfee(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 1 || AmountFromValue(params[0]) < MIN_TX_FEE) + throw runtime_error( + "settxfee \n" + " is a real and is rounded to the nearest 0.01"); + + nTransactionFee = AmountFromValue(params[0]); + nTransactionFee = (nTransactionFee / CENT) * CENT; // round to cent + + return true; +} + + +Value getnewstealthaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "getnewstealthaddress [label]\n" + "Returns a new SONO stealth address for receiving payments anonymously. "); + + if (pwalletMain->IsLocked()) + throw runtime_error("Failed: Wallet must be unlocked."); + + std::string sLabel; + if (params.size() > 0) + sLabel = params[0].get_str(); + + CStealthAddress sxAddr; + std::string sError; + if (!pwalletMain->NewStealthAddress(sError, sLabel, sxAddr)) + throw runtime_error(std::string("Could get new stealth address: ") + sError); + + if (!pwalletMain->AddStealthAddress(sxAddr)) + throw runtime_error("Could not save to wallet."); + + return sxAddr.Encoded(); +} + +Value liststealthaddresses(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "liststealthaddresses [show_secrets=0]\n" + "List owned stealth addresses."); + + bool fShowSecrets = false; + + if (params.size() > 0) + { + std::string str = params[0].get_str(); + + if (str == "0" || str == "n" || str == "no" || str == "-" || str == "false") + fShowSecrets = false; + else + fShowSecrets = true; + }; + + if (fShowSecrets) + { + if (pwalletMain->IsLocked()) + throw runtime_error("Failed: Wallet must be unlocked."); + }; + + Object result; + + //std::set::iterator it; + //for (it = pwalletMain->stealthAddresses.begin(); it != pwalletMain->stealthAddresses.end(); ++it) + BOOST_FOREACH(CStealthAddress sit, pwalletMain->stealthAddresses) + { + CStealthAddress* it = &(sit); + if (it->scan_secret.size() < 1) + continue; // stealth address is not owned + + if (fShowSecrets) + { + Object objA; + objA.push_back(Pair("Label ", it->label)); + objA.push_back(Pair("Address ", it->Encoded())); + objA.push_back(Pair("Scan Secret ", HexStr(it->scan_secret.begin(), it->scan_secret.end()))); + objA.push_back(Pair("Spend Secret ", HexStr(it->spend_secret.begin(), it->spend_secret.end()))); + result.push_back(Pair("Stealth Address", objA)); + } else + { + result.push_back(Pair("Stealth Address", it->Encoded() + " - " + it->label)); + }; + }; + + return result; +} + +Value importstealthaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 2) + throw runtime_error( + "importstealthaddress [label]\n" + "Import an owned stealth addresses."); + + std::string sScanSecret = params[0].get_str(); + std::string sSpendSecret = params[1].get_str(); + std::string sLabel; + + + if (params.size() > 2) + { + sLabel = params[2].get_str(); + }; + + std::vector vchScanSecret; + std::vector vchSpendSecret; + + if (IsHex(sScanSecret)) + { + vchScanSecret = ParseHex(sScanSecret); + } else + { + if (!DecodeBase58(sScanSecret, vchScanSecret)) + throw runtime_error("Could not decode scan secret as hex or base58."); + }; + + if (IsHex(sSpendSecret)) + { + vchSpendSecret = ParseHex(sSpendSecret); + } else + { + if (!DecodeBase58(sSpendSecret, vchSpendSecret)) + throw runtime_error("Could not decode spend secret as hex or base58."); + }; + + if (vchScanSecret.size() != 32) + throw runtime_error("Scan secret is not 32 bytes."); + if (vchSpendSecret.size() != 32) + throw runtime_error("Spend secret is not 32 bytes."); + + + ec_secret scan_secret; + ec_secret spend_secret; + + memcpy(&scan_secret.e[0], &vchScanSecret[0], 32); + memcpy(&spend_secret.e[0], &vchSpendSecret[0], 32); + + ec_point scan_pubkey, spend_pubkey; + if (SecretToPublicKey(scan_secret, scan_pubkey) != 0) + throw runtime_error("Could not get scan public key."); + + if (SecretToPublicKey(spend_secret, spend_pubkey) != 0) + throw runtime_error("Could not get spend public key."); + + + CStealthAddress sxAddr; + sxAddr.label = sLabel; + sxAddr.scan_pubkey = scan_pubkey; + sxAddr.spend_pubkey = spend_pubkey; + + sxAddr.scan_secret = vchScanSecret; + sxAddr.spend_secret = vchSpendSecret; + + Object result; + bool fFound = false; + // -- find if address already exists + //std::set::iterator it; + //for (it = pwalletMain->stealthAddresses.begin(); it != pwalletMain->stealthAddresses.end(); ++it) + BOOST_FOREACH(CStealthAddress it, pwalletMain->stealthAddresses) + { + CStealthAddress &sxAddrIt = const_cast(it); //*it); + if (sxAddrIt.scan_pubkey == sxAddr.scan_pubkey + && sxAddrIt.spend_pubkey == sxAddr.spend_pubkey) + { + if (sxAddrIt.scan_secret.size() < 1) + { + sxAddrIt.scan_secret = sxAddr.scan_secret; + sxAddrIt.spend_secret = sxAddr.spend_secret; + fFound = true; // update stealth address with secrets + break; + }; + + result.push_back(Pair("result", "Import failed - stealth address exists.")); + return result; + }; + }; + + if (fFound) + { + result.push_back(Pair("result", "Success, updated " + sxAddr.Encoded())); + } else + { + pwalletMain->stealthAddresses.insert(sxAddr); + result.push_back(Pair("result", "Success, imported " + sxAddr.Encoded())); + }; + + + if (!pwalletMain->AddStealthAddress(sxAddr)) + throw runtime_error("Could not save to wallet."); + + return result; +} + + +Value sendtostealthaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 2 || params.size() > 5) + throw runtime_error( + "sendtostealthaddress [comment] [comment-to] [narration]\n" + " is a real and is rounded to the nearest 0.000001" + + HelpRequiringPassphrase()); + + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); + + std::string sEncoded = params[0].get_str(); + int64_t nAmount = AmountFromValue(params[1]); + + std::string sNarr; + if (params.size() > 4 && params[4].type() != null_type && !params[4].get_str().empty()) + sNarr = params[4].get_str(); + + if (sNarr.length() > 24) + throw runtime_error("Narration must be 24 characters or less."); + + CStealthAddress sxAddr; + Object result; + + if (!sxAddr.SetEncoded(sEncoded)) + { + result.push_back(Pair("result", "Invalid SONO stealth address.")); + return result; + }; + + + CWalletTx wtx; + if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty()) + wtx.mapValue["comment"] = params[2].get_str(); + if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty()) + wtx.mapValue["to"] = params[3].get_str(); + + std::string sError; + if (!pwalletMain->SendStealthMoneyToDestination(sxAddr, nAmount, sNarr, wtx, sError)) + throw JSONRPCError(RPC_WALLET_ERROR, sError); + + return wtx.GetHash().GetHex(); + + result.push_back(Pair("result", "Not implemented yet.")); + + return result; +} + +Value scanforalltxns(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "scanforalltxns [fromHeight]\n" + "Scan blockchain for owned transactions."); + + Object result; + int32_t nFromHeight = 0; + + CBlockIndex *pindex = pindexGenesisBlock; + + + if (params.size() > 0) + nFromHeight = params[0].get_int(); + + + if (nFromHeight > 0) + { + pindex = mapBlockIndex[hashBestChain]; + while (pindex->nHeight > nFromHeight + && pindex->pprev) + pindex = pindex->pprev; + }; + + if (pindex == NULL) + throw runtime_error("Genesis Block is not set."); + + { + LOCK2(cs_main, pwalletMain->cs_wallet); + + pwalletMain->MarkDirty(); + + pwalletMain->ScanForWalletTransactions(pindex, true); + pwalletMain->ReacceptWalletTransactions(); + } + + result.push_back(Pair("result", "Scan complete.")); + + return result; +} + +Value scanforstealthtxns(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "scanforstealthtxns [fromHeight]\n" + "Scan blockchain for owned stealth transactions."); + + Object result; + uint32_t nBlocks = 0; + uint32_t nTransactions = 0; + int32_t nFromHeight = 0; + + CBlockIndex *pindex = pindexGenesisBlock; + + + if (params.size() > 0) + nFromHeight = params[0].get_int(); + + + if (nFromHeight > 0) + { + pindex = mapBlockIndex[hashBestChain]; + while (pindex->nHeight > nFromHeight + && pindex->pprev) + pindex = pindex->pprev; + }; + + if (pindex == NULL) + throw runtime_error("Genesis Block is not set."); + + // -- locks in AddToWalletIfInvolvingMe + + bool fUpdate = true; // todo: option? + + pwalletMain->nStealth = 0; + pwalletMain->nFoundStealth = 0; + + while (pindex) + { + nBlocks++; + CBlock block; + block.ReadFromDisk(pindex, true); + + BOOST_FOREACH(CTransaction& tx, block.vtx) + { + + nTransactions++; + + pwalletMain->AddToWalletIfInvolvingMe(tx, &block, fUpdate); + }; + + pindex = pindex->pnext; + }; + + printf("Scanned %u blocks, %u transactions\n", nBlocks, nTransactions); + printf("Found %u stealth transactions in blockchain.\n", pwalletMain->nStealth); + printf("Found %u new owned stealth transactions.\n", pwalletMain->nFoundStealth); + + char cbuf[256]; + snprintf(cbuf, sizeof(cbuf), "%u new stealth transactions.", pwalletMain->nFoundStealth); + + result.push_back(Pair("result", "Scan complete.")); + result.push_back(Pair("found", std::string(cbuf))); + + return result; +} + + diff --git a/src/script.cpp b/src/script.cpp new file mode 100644 index 0000000..2d7a7b8 --- /dev/null +++ b/src/script.cpp @@ -0,0 +1,3433 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include +#include + +using namespace std; +using namespace boost; + +#include "script.h" +#include "keystore.h" +#include "bignum.h" +#include "key.h" +#include "main.h" +#include "sync.h" +#include "util.h" +#include "crypto/ripemd160.h" +#include "crypto/sha1.h" +#include "crypto/sha256.h" +#include "eccryptoverify.h" + +namespace { + +inline bool set_success(ScriptError* ret) +{ + if (ret) + *ret = SCRIPT_ERR_OK; + return true; +} + +inline bool set_error(ScriptError* ret, const ScriptError serror) +{ + if (ret) + *ret = serror; + return false; +} + +} // anon namespace + + +const char* ScriptErrorString(const ScriptError serror) +{ + switch (serror) + { + case SCRIPT_ERR_OK: + return "No error"; + case SCRIPT_ERR_EVAL_FALSE: + return "Script evaluated without error but finished with a false/empty top stack element"; + case SCRIPT_ERR_VERIFY: + return "Script failed an OP_VERIFY operation"; + case SCRIPT_ERR_EQUALVERIFY: + return "Script failed an OP_EQUALVERIFY operation"; + case SCRIPT_ERR_CHECKMULTISIGVERIFY: + return "Script failed an OP_CHECKMULTISIGVERIFY operation"; + case SCRIPT_ERR_CHECKSIGVERIFY: + return "Script failed an OP_CHECKSIGVERIFY operation"; + case SCRIPT_ERR_NUMEQUALVERIFY: + return "Script failed an OP_NUMEQUALVERIFY operation"; + case SCRIPT_ERR_SCRIPT_SIZE: + return "Script is too big"; + case SCRIPT_ERR_PUSH_SIZE: + return "Push value size limit exceeded"; + case SCRIPT_ERR_OP_COUNT: + return "Operation limit exceeded"; + case SCRIPT_ERR_STACK_SIZE: + return "Stack size limit exceeded"; + case SCRIPT_ERR_SIG_COUNT: + return "Signature count negative or greater than pubkey count"; + case SCRIPT_ERR_PUBKEY_COUNT: + return "Pubkey count negative or limit exceeded"; + case SCRIPT_ERR_BAD_OPCODE: + return "Opcode missing or not understood"; + case SCRIPT_ERR_DISABLED_OPCODE: + return "Attempted to use a disabled opcode"; + case SCRIPT_ERR_INVALID_STACK_OPERATION: + return "Operation not valid with the current stack size"; + case SCRIPT_ERR_INVALID_ALTSTACK_OPERATION: + return "Operation not valid with the current altstack size"; + case SCRIPT_ERR_OP_RETURN: + return "OP_RETURN was encountered"; + case SCRIPT_ERR_UNBALANCED_CONDITIONAL: + return "Invalid OP_IF construction"; + case SCRIPT_ERR_SIG_HASHTYPE: + return "Signature hash type missing or not understood"; + case SCRIPT_ERR_SIG_DER: + return "Non-canonical DER signature"; + case SCRIPT_ERR_MINIMALDATA: + return "Data push larger than necessary"; + case SCRIPT_ERR_SIG_PUSHONLY: + return "Only non-push operators allowed in signatures"; + case SCRIPT_ERR_SIG_HIGH_S: + return "Non-canonical signature: S value is unnecessarily high"; + case SCRIPT_ERR_SIG_NULLDUMMY: + return "Dummy CHECKMULTISIG argument must be zero"; + case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS: + return "NOPx reserved for soft-fork upgrades"; + case SCRIPT_ERR_PUBKEYTYPE: + return "Public key is neither compressed or uncompressed"; + case SCRIPT_ERR_UNKNOWN_ERROR: + case SCRIPT_ERR_ERROR_COUNT: + default: break; + } + return "unknown error"; +} + + +bool CheckSig(vector vchSig, const vector &vchPubKey, const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType, int flags); + +static const valtype vchFalse(0); +static const valtype vchZero(0); +static const valtype vchTrue(1, 1); +static const CBigNum bnZero(0); +static const CBigNum bnOne(1); +static const CBigNum bnFalse(0); +static const CBigNum bnTrue(1); +static const size_t nDefaultMaxNumSize = 4; + + +CBigNum CastToBigNum(const valtype& vch, const size_t nMaxNumSize = nDefaultMaxNumSize) +{ + if (vch.size() > nMaxNumSize) + throw runtime_error("CastToBigNum() : overflow"); + // Get rid of extra leading zeros + return CBigNum(CBigNum(vch).getvch()); +} + +bool CastToBool(const valtype& vch) +{ + for (unsigned int i = 0; i < vch.size(); i++) + { + if (vch[i] != 0) + { + // Can be negative zero + if (i == vch.size()-1 && vch[i] == 0x80) + return false; + return true; + } + } + return false; +} + +// +// WARNING: This does not work as expected for signed integers; the sign-bit +// is left in place as the integer is zero-extended. The correct behavior +// would be to move the most significant bit of the last byte during the +// resize process. MakeSameSize() is currently only used by the disabled +// opcodes OP_AND, OP_OR, and OP_XOR. +// +void MakeSameSize(valtype& vch1, valtype& vch2) +{ + // Lengthen the shorter one + if (vch1.size() < vch2.size()) + // PATCH: + // +unsigned char msb = vch1[vch1.size()-1]; + // +vch1[vch1.size()-1] &= 0x7f; + // vch1.resize(vch2.size(), 0); + // +vch1[vch1.size()-1] = msb; + vch1.resize(vch2.size(), 0); + if (vch2.size() < vch1.size()) + // PATCH: + // +unsigned char msb = vch2[vch2.size()-1]; + // +vch2[vch2.size()-1] &= 0x7f; + // vch2.resize(vch1.size(), 0); + // +vch2[vch2.size()-1] = msb; + vch2.resize(vch1.size(), 0); +} + + + +// +// Script is a stack machine (like Forth) that evaluates a predicate +// returning a bool indicating valid or not. There are no loops. +// +#define stacktop(i) (stack.at(stack.size()+(i))) +#define altstacktop(i) (altstack.at(altstack.size()+(i))) +static inline void popstack(vector& stack) +{ + if (stack.empty()) + throw runtime_error("popstack() : stack empty"); + stack.pop_back(); +} + + +const char* GetTxnOutputType(txnouttype t) +{ + switch (t) + { + case TX_NONSTANDARD: return "nonstandard"; + case TX_PUBKEY: return "pubkey"; + case TX_PUBKEYHASH: return "pubkeyhash"; + case TX_SCRIPTHASH: return "scripthash"; + case TX_MULTISIG: return "multisig"; + case TX_NULL_DATA: return "nulldata"; + } + return NULL; +} + + +const char* GetOpName(opcodetype opcode) +{ + switch (opcode) + { + // push value + case OP_0 : return "0"; + case OP_PUSHDATA1 : return "OP_PUSHDATA1"; + case OP_PUSHDATA2 : return "OP_PUSHDATA2"; + case OP_PUSHDATA4 : return "OP_PUSHDATA4"; + case OP_1NEGATE : return "-1"; + case OP_RESERVED : return "OP_RESERVED"; + case OP_1 : return "1"; + case OP_2 : return "2"; + case OP_3 : return "3"; + case OP_4 : return "4"; + case OP_5 : return "5"; + case OP_6 : return "6"; + case OP_7 : return "7"; + case OP_8 : return "8"; + case OP_9 : return "9"; + case OP_10 : return "10"; + case OP_11 : return "11"; + case OP_12 : return "12"; + case OP_13 : return "13"; + case OP_14 : return "14"; + case OP_15 : return "15"; + case OP_16 : return "16"; + + // control + case OP_NOP : return "OP_NOP"; + case OP_VER : return "OP_VER"; + case OP_IF : return "OP_IF"; + case OP_NOTIF : return "OP_NOTIF"; + case OP_VERIF : return "OP_VERIF"; + case OP_VERNOTIF : return "OP_VERNOTIF"; + case OP_ELSE : return "OP_ELSE"; + case OP_ENDIF : return "OP_ENDIF"; + case OP_VERIFY : return "OP_VERIFY"; + case OP_RETURN : return "OP_RETURN"; + + // stack ops + case OP_TOALTSTACK : return "OP_TOALTSTACK"; + case OP_FROMALTSTACK : return "OP_FROMALTSTACK"; + case OP_2DROP : return "OP_2DROP"; + case OP_2DUP : return "OP_2DUP"; + case OP_3DUP : return "OP_3DUP"; + case OP_2OVER : return "OP_2OVER"; + case OP_2ROT : return "OP_2ROT"; + case OP_2SWAP : return "OP_2SWAP"; + case OP_IFDUP : return "OP_IFDUP"; + case OP_DEPTH : return "OP_DEPTH"; + case OP_DROP : return "OP_DROP"; + case OP_DUP : return "OP_DUP"; + case OP_NIP : return "OP_NIP"; + case OP_OVER : return "OP_OVER"; + case OP_PICK : return "OP_PICK"; + case OP_ROLL : return "OP_ROLL"; + case OP_ROT : return "OP_ROT"; + case OP_SWAP : return "OP_SWAP"; + case OP_TUCK : return "OP_TUCK"; + + // splice ops + case OP_CAT : return "OP_CAT"; + case OP_SUBSTR : return "OP_SUBSTR"; + case OP_LEFT : return "OP_LEFT"; + case OP_RIGHT : return "OP_RIGHT"; + case OP_SIZE : return "OP_SIZE"; + + // bit logic + case OP_INVERT : return "OP_INVERT"; + case OP_AND : return "OP_AND"; + case OP_OR : return "OP_OR"; + case OP_XOR : return "OP_XOR"; + case OP_EQUAL : return "OP_EQUAL"; + case OP_EQUALVERIFY : return "OP_EQUALVERIFY"; + case OP_RESERVED1 : return "OP_RESERVED1"; + case OP_RESERVED2 : return "OP_RESERVED2"; + + // numeric + case OP_1ADD : return "OP_1ADD"; + case OP_1SUB : return "OP_1SUB"; + case OP_2MUL : return "OP_2MUL"; + case OP_2DIV : return "OP_2DIV"; + case OP_NEGATE : return "OP_NEGATE"; + case OP_ABS : return "OP_ABS"; + case OP_NOT : return "OP_NOT"; + case OP_0NOTEQUAL : return "OP_0NOTEQUAL"; + case OP_ADD : return "OP_ADD"; + case OP_SUB : return "OP_SUB"; + case OP_MUL : return "OP_MUL"; + case OP_DIV : return "OP_DIV"; + case OP_MOD : return "OP_MOD"; + case OP_LSHIFT : return "OP_LSHIFT"; + case OP_RSHIFT : return "OP_RSHIFT"; + case OP_BOOLAND : return "OP_BOOLAND"; + case OP_BOOLOR : return "OP_BOOLOR"; + case OP_NUMEQUAL : return "OP_NUMEQUAL"; + case OP_NUMEQUALVERIFY : return "OP_NUMEQUALVERIFY"; + case OP_NUMNOTEQUAL : return "OP_NUMNOTEQUAL"; + case OP_LESSTHAN : return "OP_LESSTHAN"; + case OP_GREATERTHAN : return "OP_GREATERTHAN"; + case OP_LESSTHANOREQUAL : return "OP_LESSTHANOREQUAL"; + case OP_GREATERTHANOREQUAL : return "OP_GREATERTHANOREQUAL"; + case OP_MIN : return "OP_MIN"; + case OP_MAX : return "OP_MAX"; + case OP_WITHIN : return "OP_WITHIN"; + + // crypto + case OP_RIPEMD160 : return "OP_RIPEMD160"; + case OP_SHA1 : return "OP_SHA1"; + case OP_SHA256 : return "OP_SHA256"; + case OP_HASH160 : return "OP_HASH160"; + case OP_HASH256 : return "OP_HASH256"; + case OP_CODESEPARATOR : return "OP_CODESEPARATOR"; + case OP_CHECKSIG : return "OP_CHECKSIG"; + case OP_CHECKSIGVERIFY : return "OP_CHECKSIGVERIFY"; + case OP_CHECKMULTISIG : return "OP_CHECKMULTISIG"; + case OP_CHECKMULTISIGVERIFY : return "OP_CHECKMULTISIGVERIFY"; + + // expanson + case OP_NOP1 : return "OP_NOP1"; + case OP_NOP2 : return "OP_NOP2"; + case OP_NOP3 : return "OP_NOP3"; + case OP_NOP4 : return "OP_NOP4"; + case OP_NOP5 : return "OP_NOP5"; + case OP_NOP6 : return "OP_NOP6"; + case OP_NOP7 : return "OP_NOP7"; + case OP_NOP8 : return "OP_NOP8"; + case OP_NOP9 : return "OP_NOP9"; + case OP_NOP10 : return "OP_NOP10"; + + case OP_INVALIDOPCODE : return "OP_INVALIDOPCODE"; + + // Note: + // The template matching params OP_SMALLDATA/etc are defined in opcodetype enum + // as kind of implementation hack, they are *NOT* real opcodes. If found in real + // Script, just let the default: case deal with them. + + default: + return "OP_UNKNOWN"; + } +} + +static bool IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) { + if (vchPubKey.size() < 33) + return error("Non-canonical public key: too short"); + if (vchPubKey[0] == 0x04) { + if (vchPubKey.size() != 65) + return error("Non-canonical public key: invalid length for uncompressed key"); + } else if (vchPubKey[0] == 0x02 || vchPubKey[0] == 0x03) { + if (vchPubKey.size() != 33) + return error("Non-canonical public key: invalid length for compressed key"); + } else { + return error("Non-canonical public key: neither compressed nor uncompressed"); + } + return true; +} + +bool IsDERSignature(const valtype &vchSig, bool haveHashType) { + // See https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623 + // A canonical signature exists of: <30> <02> <02> + // Where R and S are not negative (their first byte has its highest bit not set), and not + // excessively padded (do not start with a 0 byte, unless an otherwise negative number follows, + // in which case a single 0 byte is necessary and even required). + if (vchSig.size() < 9) + return error("Non-canonical signature: too short"); + if (vchSig.size() > 73) + return error("Non-canonical signature: too long"); + if (vchSig[0] != 0x30) + return error("Non-canonical signature: wrong type"); + if (vchSig[1] != vchSig.size() - (haveHashType ? 3 : 2)) + return error("Non-canonical signature: wrong length marker"); + unsigned int nLenR = vchSig[3]; + if (5 + nLenR >= vchSig.size()) + return error("Non-canonical signature: S length misplaced"); + unsigned int nLenS = vchSig[5+nLenR]; + if ((unsigned long)(nLenR + nLenS + (haveHashType ? 7 : 6)) != vchSig.size()) + return error("Non-canonical signature: R+S length mismatch"); + + const unsigned char *R = &vchSig[4]; + if (R[-2] != 0x02) + return error("Non-canonical signature: R value type mismatch"); + if (nLenR == 0) + return error("Non-canonical signature: R length is zero"); + if (R[0] & 0x80) + return error("Non-canonical signature: R value negative"); + if (nLenR > 1 && (R[0] == 0x00) && !(R[1] & 0x80)) + return error("Non-canonical signature: R value excessively padded"); + + const unsigned char *S = &vchSig[6+nLenR]; + if (S[-2] != 0x02) + return error("Non-canonical signature: S value type mismatch"); + if (nLenS == 0) + return error("Non-canonical signature: S length is zero"); + if (S[0] & 0x80) + return error("Non-canonical signature: S value negative"); + if (nLenS > 1 && (S[0] == 0x00) && !(S[1] & 0x80)) + return error("Non-canonical signature: S value excessively padded"); + + return true; +} + +bool static IsLowDERSignature(const valtype &vchSig) { + if (!IsDERSignature(vchSig)) { + return false; + } + unsigned int nLenR = vchSig[3]; + unsigned int nLenS = vchSig[5+nLenR]; + const unsigned char *S = &vchSig[6+nLenR]; + // If the S value is above the order of the curve divided by two, its + // complement modulo the order could have been used instead, which is + // one byte shorter when encoded correctly. + if (!CKey::CheckSignatureElement(S, nLenS, true)) + return error("Non-canonical signature: S value is unnecessarily high"); + + return true; +} + +bool static IsDefinedHashtypeSignature(const valtype &vchSig) { + if (vchSig.size() == 0) { + return false; + } + unsigned char nHashType = vchSig[vchSig.size() - 1] & (~(SIGHASH_ANYONECANPAY)); + if (nHashType < SIGHASH_ALL || nHashType > SIGHASH_SINGLE) + return error("Non-canonical signature: unknown hashtype byte"); + + return true; +} + +bool static CheckSignatureEncoding(const valtype &vchSig) { + if (!IsLowDERSignature(vchSig)) { + return false; + } else if (!IsDefinedHashtypeSignature(vchSig)) { + return false; + } + return true; +} + +bool static CheckPubKeyEncoding(const valtype &vchSig) { + if (!IsCompressedOrUncompressedPubKey(vchSig)) { + return false; + } + return true; +} + +bool EvalScript(vector >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType) +{ + CAutoBN_CTX pctx; + CScript::const_iterator pc = script.begin(); + CScript::const_iterator pend = script.end(); + CScript::const_iterator pbegincodehash = script.begin(); + opcodetype opcode; + valtype vchPushValue; + vector vfExec; + vector altstack; + if (script.size() > 10000) + return false; + int nOpCount = 0; + + + try + { + while (pc < pend) + { + bool fExec = !count(vfExec.begin(), vfExec.end(), false); + + // + // Read instruction + // + if (!script.GetOp(pc, opcode, vchPushValue)) + return false; + if (vchPushValue.size() > MAX_SCRIPT_ELEMENT_SIZE) + return false; + if (opcode > OP_16 && ++nOpCount > 201) + return false; + + if (opcode == OP_CAT || + opcode == OP_SUBSTR || + opcode == OP_LEFT || + opcode == OP_RIGHT || + opcode == OP_INVERT || + opcode == OP_AND || + opcode == OP_OR || + opcode == OP_XOR || + opcode == OP_2MUL || + opcode == OP_2DIV || + opcode == OP_MUL || + opcode == OP_DIV || + opcode == OP_MOD || + opcode == OP_LSHIFT || + opcode == OP_RSHIFT) + return false; + + if (fExec && 0 <= opcode && opcode <= OP_PUSHDATA4) + stack.push_back(vchPushValue); + else if (fExec || (OP_IF <= opcode && opcode <= OP_ENDIF)) + switch (opcode) + { + // + // Push value + // + case OP_1NEGATE: + case OP_1: + case OP_2: + case OP_3: + case OP_4: + case OP_5: + case OP_6: + case OP_7: + case OP_8: + case OP_9: + case OP_10: + case OP_11: + case OP_12: + case OP_13: + case OP_14: + case OP_15: + case OP_16: + { + // ( -- value) + CBigNum bn((int)opcode - (int)(OP_1 - 1)); + stack.push_back(bn.getvch()); + } + break; + + + // + // Control + // + case OP_NOP: + break; + + case OP_NOP1: case OP_NOP2: case OP_NOP3: case OP_NOP4: case OP_NOP5: + case OP_NOP6: case OP_NOP7: case OP_NOP8: case OP_NOP9: case OP_NOP10: + { + if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) + return false; + } + break; + + case OP_IF: + case OP_NOTIF: + { + // if [statements] [else [statements]] endif + bool fValue = false; + if (fExec) + { + if (stack.size() < 1) + return false; + valtype& vch = stacktop(-1); + fValue = CastToBool(vch); + if (opcode == OP_NOTIF) + fValue = !fValue; + popstack(stack); + } + vfExec.push_back(fValue); + } + break; + + case OP_ELSE: + { + if (vfExec.empty()) + return false; + vfExec.back() = !vfExec.back(); + } + break; + + case OP_ENDIF: + { + if (vfExec.empty()) + return false; + vfExec.pop_back(); + } + break; + + case OP_VERIFY: + { + // (true -- ) or + // (false -- false) and return + if (stack.size() < 1) + return false; + bool fValue = CastToBool(stacktop(-1)); + if (fValue) + popstack(stack); + else + return false; + } + break; + + case OP_RETURN: + { + return false; + } + break; + + + // + // Stack ops + // + case OP_TOALTSTACK: + { + if (stack.size() < 1) + return false; + altstack.push_back(stacktop(-1)); + popstack(stack); + } + break; + + case OP_FROMALTSTACK: + { + if (altstack.size() < 1) + return false; + stack.push_back(altstacktop(-1)); + popstack(altstack); + } + break; + + case OP_2DROP: + { + // (x1 x2 -- ) + if (stack.size() < 2) + return false; + popstack(stack); + popstack(stack); + } + break; + + case OP_2DUP: + { + // (x1 x2 -- x1 x2 x1 x2) + if (stack.size() < 2) + return false; + valtype vch1 = stacktop(-2); + valtype vch2 = stacktop(-1); + stack.push_back(vch1); + stack.push_back(vch2); + } + break; + + case OP_3DUP: + { + // (x1 x2 x3 -- x1 x2 x3 x1 x2 x3) + if (stack.size() < 3) + return false; + valtype vch1 = stacktop(-3); + valtype vch2 = stacktop(-2); + valtype vch3 = stacktop(-1); + stack.push_back(vch1); + stack.push_back(vch2); + stack.push_back(vch3); + } + break; + + case OP_2OVER: + { + // (x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2) + if (stack.size() < 4) + return false; + valtype vch1 = stacktop(-4); + valtype vch2 = stacktop(-3); + stack.push_back(vch1); + stack.push_back(vch2); + } + break; + + case OP_2ROT: + { + // (x1 x2 x3 x4 x5 x6 -- x3 x4 x5 x6 x1 x2) + if (stack.size() < 6) + return false; + valtype vch1 = stacktop(-6); + valtype vch2 = stacktop(-5); + stack.erase(stack.end()-6, stack.end()-4); + stack.push_back(vch1); + stack.push_back(vch2); + } + break; + + case OP_2SWAP: + { + // (x1 x2 x3 x4 -- x3 x4 x1 x2) + if (stack.size() < 4) + return false; + swap(stacktop(-4), stacktop(-2)); + swap(stacktop(-3), stacktop(-1)); + } + break; + + case OP_IFDUP: + { + // (x - 0 | x x) + if (stack.size() < 1) + return false; + valtype vch = stacktop(-1); + if (CastToBool(vch)) + stack.push_back(vch); + } + break; + + case OP_DEPTH: + { + // -- stacksize + CBigNum bn(stack.size()); + stack.push_back(bn.getvch()); + } + break; + + case OP_DROP: + { + // (x -- ) + if (stack.size() < 1) + return false; + popstack(stack); + } + break; + + case OP_DUP: + { + // (x -- x x) + if (stack.size() < 1) + return false; + valtype vch = stacktop(-1); + stack.push_back(vch); + } + break; + + case OP_NIP: + { + // (x1 x2 -- x2) + if (stack.size() < 2) + return false; + stack.erase(stack.end() - 2); + } + break; + + case OP_OVER: + { + // (x1 x2 -- x1 x2 x1) + if (stack.size() < 2) + return false; + valtype vch = stacktop(-2); + stack.push_back(vch); + } + break; + + case OP_PICK: + case OP_ROLL: + { + // (xn ... x2 x1 x0 n - xn ... x2 x1 x0 xn) + // (xn ... x2 x1 x0 n - ... x2 x1 x0 xn) + if (stack.size() < 2) + return false; + int n = CastToBigNum(stacktop(-1)).getint(); + popstack(stack); + if (n < 0 || n >= (int)stack.size()) + return false; + valtype vch = stacktop(-n-1); + if (opcode == OP_ROLL) + stack.erase(stack.end()-n-1); + stack.push_back(vch); + } + break; + + case OP_ROT: + { + // (x1 x2 x3 -- x2 x3 x1) + // x2 x1 x3 after first swap + // x2 x3 x1 after second swap + if (stack.size() < 3) + return false; + swap(stacktop(-3), stacktop(-2)); + swap(stacktop(-2), stacktop(-1)); + } + break; + + case OP_SWAP: + { + // (x1 x2 -- x2 x1) + if (stack.size() < 2) + return false; + swap(stacktop(-2), stacktop(-1)); + } + break; + + case OP_TUCK: + { + // (x1 x2 -- x2 x1 x2) + if (stack.size() < 2) + return false; + valtype vch = stacktop(-1); + stack.insert(stack.end()-2, vch); + } + break; + + + // + // Splice ops + // + case OP_CAT: + { + // (x1 x2 -- out) + if (stack.size() < 2) + return false; + valtype& vch1 = stacktop(-2); + valtype& vch2 = stacktop(-1); + vch1.insert(vch1.end(), vch2.begin(), vch2.end()); + popstack(stack); + if (stacktop(-1).size() > MAX_SCRIPT_ELEMENT_SIZE) + return false; + } + break; + + case OP_SUBSTR: + { + // (in begin size -- out) + if (stack.size() < 3) + return false; + valtype& vch = stacktop(-3); + int nBegin = CastToBigNum(stacktop(-2)).getint(); + int nEnd = nBegin + CastToBigNum(stacktop(-1)).getint(); + if (nBegin < 0 || nEnd < nBegin) + return false; + if (nBegin > (int)vch.size()) + nBegin = vch.size(); + if (nEnd > (int)vch.size()) + nEnd = vch.size(); + vch.erase(vch.begin() + nEnd, vch.end()); + vch.erase(vch.begin(), vch.begin() + nBegin); + popstack(stack); + popstack(stack); + } + break; + + case OP_LEFT: + case OP_RIGHT: + { + // (in size -- out) + if (stack.size() < 2) + return false; + valtype& vch = stacktop(-2); + int nSize = CastToBigNum(stacktop(-1)).getint(); + if (nSize < 0) + return false; + if (nSize > (int)vch.size()) + nSize = vch.size(); + if (opcode == OP_LEFT) + vch.erase(vch.begin() + nSize, vch.end()); + else + vch.erase(vch.begin(), vch.end() - nSize); + popstack(stack); + } + break; + + case OP_SIZE: + { + // (in -- in size) + if (stack.size() < 1) + return false; + CBigNum bn(stacktop(-1).size()); + stack.push_back(bn.getvch()); + } + break; + + + // + // Bitwise logic + // + case OP_INVERT: + { + // (in - out) + if (stack.size() < 1) + return false; + valtype& vch = stacktop(-1); + for (unsigned int i = 0; i < vch.size(); i++) + vch[i] = ~vch[i]; + } + break; + + // + // WARNING: These disabled opcodes exhibit unexpected behavior + // when used on signed integers due to a bug in MakeSameSize() + // [see definition of MakeSameSize() above]. + // + case OP_AND: + case OP_OR: + case OP_XOR: + { + // (x1 x2 - out) + if (stack.size() < 2) + return false; + valtype& vch1 = stacktop(-2); + valtype& vch2 = stacktop(-1); + MakeSameSize(vch1, vch2); // <-- NOT SAFE FOR SIGNED VALUES + if (opcode == OP_AND) + { + for (unsigned int i = 0; i < vch1.size(); i++) + vch1[i] &= vch2[i]; + } + else if (opcode == OP_OR) + { + for (unsigned int i = 0; i < vch1.size(); i++) + vch1[i] |= vch2[i]; + } + else if (opcode == OP_XOR) + { + for (unsigned int i = 0; i < vch1.size(); i++) + vch1[i] ^= vch2[i]; + } + popstack(stack); + } + break; + + case OP_EQUAL: + case OP_EQUALVERIFY: + //case OP_NOTEQUAL: // use OP_NUMNOTEQUAL + { + // (x1 x2 - bool) + if (stack.size() < 2) + return false; + valtype& vch1 = stacktop(-2); + valtype& vch2 = stacktop(-1); + bool fEqual = (vch1 == vch2); + // OP_NOTEQUAL is disabled because it would be too easy to say + // something like n != 1 and have some wiseguy pass in 1 with extra + // zero bytes after it (numerically, 0x01 == 0x0001 == 0x000001) + //if (opcode == OP_NOTEQUAL) + // fEqual = !fEqual; + popstack(stack); + popstack(stack); + stack.push_back(fEqual ? vchTrue : vchFalse); + if (opcode == OP_EQUALVERIFY) + { + if (fEqual) + popstack(stack); + else + return false; + } + } + break; + + + // + // Numeric + // + case OP_1ADD: + case OP_1SUB: + case OP_2MUL: + case OP_2DIV: + case OP_NEGATE: + case OP_ABS: + case OP_NOT: + case OP_0NOTEQUAL: + { + // (in -- out) + if (stack.size() < 1) + return false; + CBigNum bn = CastToBigNum(stacktop(-1)); + switch (opcode) + { + case OP_1ADD: bn += bnOne; break; + case OP_1SUB: bn -= bnOne; break; + case OP_2MUL: bn <<= 1; break; + case OP_2DIV: bn >>= 1; break; + case OP_NEGATE: bn = -bn; break; + case OP_ABS: if (bn < bnZero) bn = -bn; break; + case OP_NOT: bn = (bn == bnZero); break; + case OP_0NOTEQUAL: bn = (bn != bnZero); break; + default: assert(!"invalid opcode"); break; + } + popstack(stack); + stack.push_back(bn.getvch()); + } + break; + + case OP_ADD: + case OP_SUB: + case OP_MUL: + case OP_DIV: + case OP_MOD: + case OP_LSHIFT: + case OP_RSHIFT: + case OP_BOOLAND: + case OP_BOOLOR: + case OP_NUMEQUAL: + case OP_NUMEQUALVERIFY: + case OP_NUMNOTEQUAL: + case OP_LESSTHAN: + case OP_GREATERTHAN: + case OP_LESSTHANOREQUAL: + case OP_GREATERTHANOREQUAL: + case OP_MIN: + case OP_MAX: + { + // (x1 x2 -- out) + if (stack.size() < 2) + return false; + CBigNum bn1 = CastToBigNum(stacktop(-2)); + CBigNum bn2 = CastToBigNum(stacktop(-1)); + CBigNum bn; + switch (opcode) + { + case OP_ADD: + bn = bn1 + bn2; + break; + + case OP_SUB: + bn = bn1 - bn2; + break; + + case OP_MUL: + if (!BN_mul(&bn, &bn1, &bn2, pctx)) + return false; + break; + + case OP_DIV: + if (!BN_div(&bn, NULL, &bn1, &bn2, pctx)) + return false; + break; + + case OP_MOD: + if (!BN_mod(&bn, &bn1, &bn2, pctx)) + return false; + break; + + case OP_LSHIFT: + if (bn2 < bnZero || bn2 > CBigNum(2048)) + return false; + bn = bn1 << bn2.getulong(); + break; + + case OP_RSHIFT: + if (bn2 < bnZero || bn2 > CBigNum(2048)) + return false; + bn = bn1 >> bn2.getulong(); + break; + + case OP_BOOLAND: bn = (bn1 != bnZero && bn2 != bnZero); break; + case OP_BOOLOR: bn = (bn1 != bnZero || bn2 != bnZero); break; + case OP_NUMEQUAL: bn = (bn1 == bn2); break; + case OP_NUMEQUALVERIFY: bn = (bn1 == bn2); break; + case OP_NUMNOTEQUAL: bn = (bn1 != bn2); break; + case OP_LESSTHAN: bn = (bn1 < bn2); break; + case OP_GREATERTHAN: bn = (bn1 > bn2); break; + case OP_LESSTHANOREQUAL: bn = (bn1 <= bn2); break; + case OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break; + case OP_MIN: bn = (bn1 < bn2 ? bn1 : bn2); break; + case OP_MAX: bn = (bn1 > bn2 ? bn1 : bn2); break; + default: assert(!"invalid opcode"); break; + } + popstack(stack); + popstack(stack); + stack.push_back(bn.getvch()); + + if (opcode == OP_NUMEQUALVERIFY) + { + if (CastToBool(stacktop(-1))) + popstack(stack); + else + return false; + } + } + break; + + case OP_WITHIN: + { + // (x min max -- out) + if (stack.size() < 3) + return false; + CBigNum bn1 = CastToBigNum(stacktop(-3)); + CBigNum bn2 = CastToBigNum(stacktop(-2)); + CBigNum bn3 = CastToBigNum(stacktop(-1)); + bool fValue = (bn2 <= bn1 && bn1 < bn3); + popstack(stack); + popstack(stack); + popstack(stack); + stack.push_back(fValue ? vchTrue : vchFalse); + } + break; + + + // + // Crypto + // + case OP_RIPEMD160: + case OP_SHA1: + case OP_SHA256: + case OP_HASH160: + case OP_HASH256: + { + // (in -- hash) + if (stack.size() < 1) + return false; + valtype& vch = stacktop(-1); + valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160) ? 20 : 32); + if (opcode == OP_RIPEMD160) + RIPEMD160(&vch[0], vch.size(), &vchHash[0]); + else if (opcode == OP_SHA1) + SHA1(&vch[0], vch.size(), &vchHash[0]); + else if (opcode == OP_SHA256) + SHA256(&vch[0], vch.size(), &vchHash[0]); + else if (opcode == OP_HASH160) + { + uint160 hash160 = Hash160(vch); + memcpy(&vchHash[0], &hash160, sizeof(hash160)); + } + else if (opcode == OP_HASH256) + { + uint256 hash = Hash(vch.begin(), vch.end()); + memcpy(&vchHash[0], &hash, sizeof(hash)); + } + popstack(stack); + stack.push_back(vchHash); + } + break; + + case OP_CODESEPARATOR: + { + // Hash starts after the code separator + pbegincodehash = pc; + } + break; + + case OP_CHECKSIG: + case OP_CHECKSIGVERIFY: + { + // (sig pubkey -- bool) + if (stack.size() < 2) + return false; + + valtype& vchSig = stacktop(-2); + valtype& vchPubKey = stacktop(-1); + + // Subset of script starting at the most recent codeseparator + CScript scriptCode(pbegincodehash, pend); + + // Drop the signature, since there's no way for a signature to sign itself + scriptCode.FindAndDelete(CScript(vchSig)); + + if ((flags & SCRIPT_VERIFY_STRICTENC) && (!CheckSignatureEncoding(vchSig) || !CheckPubKeyEncoding(vchPubKey))) + return false; + + bool fSuccess = CheckSignatureEncoding(vchSig) && CheckPubKeyEncoding(vchPubKey) && + CheckSig(vchSig, vchPubKey, scriptCode, txTo, nIn, nHashType, flags); + + popstack(stack); + popstack(stack); + stack.push_back(fSuccess ? vchTrue : vchFalse); + if (opcode == OP_CHECKSIGVERIFY) + { + if (fSuccess) + popstack(stack); + else + return false; + } + } + break; + + case OP_CHECKMULTISIG: + case OP_CHECKMULTISIGVERIFY: + { + // ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool) + + int i = 1; + if ((int)stack.size() < i) + return false; + + int nKeysCount = CastToBigNum(stacktop(-i)).getint(); + if (nKeysCount < 0 || nKeysCount > 20) + return false; + nOpCount += nKeysCount; + if (nOpCount > 201) + return false; + int ikey = ++i; + i += nKeysCount; + if ((int)stack.size() < i) + return false; + + int nSigsCount = CastToBigNum(stacktop(-i)).getint(); + if (nSigsCount < 0 || nSigsCount > nKeysCount) + return false; + int isig = ++i; + i += nSigsCount; + if ((int)stack.size() < i) + return false; + + // Subset of script starting at the most recent codeseparator + CScript scriptCode(pbegincodehash, pend); + + // Drop the signatures, since there's no way for a signature to sign itself + for (int k = 0; k < nSigsCount; k++) + { + valtype& vchSig = stacktop(-isig-k); + scriptCode.FindAndDelete(CScript(vchSig)); + } + + bool fSuccess = true; + while (fSuccess && nSigsCount > 0) + { + valtype& vchSig = stacktop(-isig); + valtype& vchPubKey = stacktop(-ikey); + + if ((flags & SCRIPT_VERIFY_STRICTENC) && (!CheckSignatureEncoding(vchSig) || !CheckPubKeyEncoding(vchPubKey))) + return false; + + // Check signature + bool fOk = CheckSignatureEncoding(vchSig) && CheckPubKeyEncoding(vchPubKey) && + CheckSig(vchSig, vchPubKey, scriptCode, txTo, nIn, nHashType, flags); + + if (fOk) + { + isig++; + nSigsCount--; + } + ikey++; + nKeysCount--; + + // If there are more signatures left than keys left, + // then too many signatures have failed + if (nSigsCount > nKeysCount) + fSuccess = false; + } + + // Clean up stack of actual arguments + while (i-- > 1) + popstack(stack); + + // A bug causes CHECKMULTISIG to consume one extra argument + // whose contents were not checked in any way. + // + // Unfortunately this is a potential source of mutability, + // so optionally verify it is exactly equal to zero prior + // to removing it from the stack. + if (stack.size() < 1) + return false; + if ((flags & SCRIPT_VERIFY_NULLDUMMY) && stacktop(-1).size()) + return error("CHECKMULTISIG dummy argument not null"); + popstack(stack); + + stack.push_back(fSuccess ? vchTrue : vchFalse); + + if (opcode == OP_CHECKMULTISIGVERIFY) + { + if (fSuccess) + popstack(stack); + else + return false; + } + } + break; + + default: + return false; + } + + // Size limits + if (stack.size() + altstack.size() > 1000) + return false; + } + } + catch (...) + { + return false; + } + + + if (!vfExec.empty()) + return false; + + return true; +} + +bool static IsLowDERSignature(const valtype &vchSig, ScriptError* serror) { + if (!IsDERSignature(vchSig)) { + return set_error(serror, SCRIPT_ERR_SIG_DER); + } + unsigned int nLenR = vchSig[3]; + unsigned int nLenS = vchSig[5+nLenR]; + const unsigned char *S = &vchSig[6+nLenR]; + // If the S value is above the order of the curve divided by two, its + // complement modulo the order could have been used instead, which is + // one byte shorter when encoded correctly. + if (!eccrypto::CheckSignatureElement(S, nLenS, true)) + return set_error(serror, SCRIPT_ERR_SIG_HIGH_S); + + return true; +} + + +bool static CheckSignatureEncoding(const valtype &vchSig, unsigned int flags, ScriptError* serror) { + if ((flags & (SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_LOW_S | SCRIPT_VERIFY_STRICTENC)) != 0 && !IsDERSignature(vchSig)) { + return set_error(serror, SCRIPT_ERR_SIG_DER); + } else if ((flags & SCRIPT_VERIFY_LOW_S) != 0 && !IsLowDERSignature(vchSig, serror)) { + // serror is set + return false; + } else if ((flags & SCRIPT_VERIFY_STRICTENC) != 0 && !IsDefinedHashtypeSignature(vchSig)) { + return set_error(serror, SCRIPT_ERR_SIG_HASHTYPE); + } + return true; +} + +bool static CheckPubKeyEncoding(const valtype &vchSig, unsigned int flags, ScriptError* serror) { + if ((flags & SCRIPT_VERIFY_STRICTENC) != 0 && !IsCompressedOrUncompressedPubKey(vchSig)) { + return set_error(serror, SCRIPT_ERR_PUBKEYTYPE); + } + return true; +} + +bool static CheckMinimalPush(const valtype& data, opcodetype opcode) { + if (data.size() == 0) { + // Could have used OP_0. + return opcode == OP_0; + } else if (data.size() == 1 && data[0] >= 1 && data[0] <= 16) { + // Could have used OP_1 .. OP_16. + return opcode == OP_1 + (data[0] - 1); + } else if (data.size() == 1 && data[0] == 0x81) { + // Could have used OP_1NEGATE. + return opcode == OP_1NEGATE; + } else if (data.size() <= 75) { + // Could have used a direct push (opcode indicating number of bytes pushed + those bytes). + return opcode == data.size(); + } else if (data.size() <= 255) { + // Could have used OP_PUSHDATA. + return opcode == OP_PUSHDATA1; + } else if (data.size() <= 65535) { + // Could have used OP_PUSHDATA2. + return opcode == OP_PUSHDATA2; + } + return true; +} + +bool EvalScript(vector >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, ScriptError* serror) +{ + static const CScriptNum bnZero(0); + static const CScriptNum bnOne(1); + static const CScriptNum bnFalse(0); + static const CScriptNum bnTrue(1); + static const valtype vchFalse(0); + static const valtype vchZero(0); + static const valtype vchTrue(1, 1); + + CScript::const_iterator pc = script.begin(); + CScript::const_iterator pend = script.end(); + CScript::const_iterator pbegincodehash = script.begin(); + opcodetype opcode; + valtype vchPushValue; + vector vfExec; + vector altstack; + set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR); + if (script.size() > 10000) + return set_error(serror, SCRIPT_ERR_SCRIPT_SIZE); + int nOpCount = 0; + bool fRequireMinimal = (flags & SCRIPT_VERIFY_MINIMALDATA) != 0; + + try + { + while (pc < pend) + { + bool fExec = !count(vfExec.begin(), vfExec.end(), false); + + // + // Read instruction + // + if (!script.GetOp(pc, opcode, vchPushValue)) + return set_error(serror, SCRIPT_ERR_BAD_OPCODE); + if (vchPushValue.size() > MAX_SCRIPT_ELEMENT_SIZE) + return set_error(serror, SCRIPT_ERR_PUSH_SIZE); + + // Note how OP_RESERVED does not count towards the opcode limit. + if (opcode > OP_16 && ++nOpCount > 201) + return set_error(serror, SCRIPT_ERR_OP_COUNT); + + if (opcode == OP_CAT || + opcode == OP_SUBSTR || + opcode == OP_LEFT || + opcode == OP_RIGHT || + opcode == OP_INVERT || + opcode == OP_AND || + opcode == OP_OR || + opcode == OP_XOR || + opcode == OP_2MUL || + opcode == OP_2DIV || + opcode == OP_MUL || + opcode == OP_DIV || + opcode == OP_MOD || + opcode == OP_LSHIFT || + opcode == OP_RSHIFT) + return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); // Disabled opcodes. + + if (fExec && 0 <= opcode && opcode <= OP_PUSHDATA4) { + if (fRequireMinimal && !CheckMinimalPush(vchPushValue, opcode)) { + return set_error(serror, SCRIPT_ERR_MINIMALDATA); + } + stack.push_back(vchPushValue); + } else if (fExec || (OP_IF <= opcode && opcode <= OP_ENDIF)) + switch (opcode) + { + // + // Push value + // + case OP_1NEGATE: + case OP_1: + case OP_2: + case OP_3: + case OP_4: + case OP_5: + case OP_6: + case OP_7: + case OP_8: + case OP_9: + case OP_10: + case OP_11: + case OP_12: + case OP_13: + case OP_14: + case OP_15: + case OP_16: + { + // ( -- value) + CScriptNum bn((int)opcode - (int)(OP_1 - 1)); + stack.push_back(bn.getvch()); + // The result of these opcodes should always be the minimal way to push the data + // they push, so no need for a CheckMinimalPush here. + } + break; + + + // + // Control + // + case OP_NOP: + break; + + case OP_NOP1: case OP_NOP2: case OP_NOP3: case OP_NOP4: case OP_NOP5: + case OP_NOP6: case OP_NOP7: case OP_NOP8: case OP_NOP9: case OP_NOP10: + { + if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) + return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS); + } + break; + + case OP_IF: + case OP_NOTIF: + { + // if [statements] [else [statements]] endif + bool fValue = false; + if (fExec) + { + if (stack.size() < 1) + return set_error(serror, SCRIPT_ERR_UNBALANCED_CONDITIONAL); + valtype& vch = stacktop(-1); + fValue = CastToBool(vch); + if (opcode == OP_NOTIF) + fValue = !fValue; + popstack(stack); + } + vfExec.push_back(fValue); + } + break; + + case OP_ELSE: + { + if (vfExec.empty()) + return set_error(serror, SCRIPT_ERR_UNBALANCED_CONDITIONAL); + vfExec.back() = !vfExec.back(); + } + break; + + case OP_ENDIF: + { + if (vfExec.empty()) + return set_error(serror, SCRIPT_ERR_UNBALANCED_CONDITIONAL); + vfExec.pop_back(); + } + break; + + case OP_VERIFY: + { + // (true -- ) or + // (false -- false) and return + if (stack.size() < 1) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + bool fValue = CastToBool(stacktop(-1)); + if (fValue) + popstack(stack); + else + return set_error(serror, SCRIPT_ERR_VERIFY); + } + break; + + case OP_RETURN: + { + return set_error(serror, SCRIPT_ERR_OP_RETURN); + } + break; + + + // + // Stack ops + // + case OP_TOALTSTACK: + { + if (stack.size() < 1) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + altstack.push_back(stacktop(-1)); + popstack(stack); + } + break; + + case OP_FROMALTSTACK: + { + if (altstack.size() < 1) + return set_error(serror, SCRIPT_ERR_INVALID_ALTSTACK_OPERATION); + stack.push_back(altstacktop(-1)); + popstack(altstack); + } + break; + + case OP_2DROP: + { + // (x1 x2 -- ) + if (stack.size() < 2) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + popstack(stack); + popstack(stack); + } + break; + + case OP_2DUP: + { + // (x1 x2 -- x1 x2 x1 x2) + if (stack.size() < 2) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + valtype vch1 = stacktop(-2); + valtype vch2 = stacktop(-1); + stack.push_back(vch1); + stack.push_back(vch2); + } + break; + + case OP_3DUP: + { + // (x1 x2 x3 -- x1 x2 x3 x1 x2 x3) + if (stack.size() < 3) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + valtype vch1 = stacktop(-3); + valtype vch2 = stacktop(-2); + valtype vch3 = stacktop(-1); + stack.push_back(vch1); + stack.push_back(vch2); + stack.push_back(vch3); + } + break; + + case OP_2OVER: + { + // (x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2) + if (stack.size() < 4) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + valtype vch1 = stacktop(-4); + valtype vch2 = stacktop(-3); + stack.push_back(vch1); + stack.push_back(vch2); + } + break; + + case OP_2ROT: + { + // (x1 x2 x3 x4 x5 x6 -- x3 x4 x5 x6 x1 x2) + if (stack.size() < 6) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + valtype vch1 = stacktop(-6); + valtype vch2 = stacktop(-5); + stack.erase(stack.end()-6, stack.end()-4); + stack.push_back(vch1); + stack.push_back(vch2); + } + break; + + case OP_2SWAP: + { + // (x1 x2 x3 x4 -- x3 x4 x1 x2) + if (stack.size() < 4) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + swap(stacktop(-4), stacktop(-2)); + swap(stacktop(-3), stacktop(-1)); + } + break; + + case OP_IFDUP: + { + // (x - 0 | x x) + if (stack.size() < 1) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + valtype vch = stacktop(-1); + if (CastToBool(vch)) + stack.push_back(vch); + } + break; + + case OP_DEPTH: + { + // -- stacksize + CScriptNum bn(stack.size()); + stack.push_back(bn.getvch()); + } + break; + + case OP_DROP: + { + // (x -- ) + if (stack.size() < 1) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + popstack(stack); + } + break; + + case OP_DUP: + { + // (x -- x x) + if (stack.size() < 1) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + valtype vch = stacktop(-1); + stack.push_back(vch); + } + break; + + case OP_NIP: + { + // (x1 x2 -- x2) + if (stack.size() < 2) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + stack.erase(stack.end() - 2); + } + break; + + case OP_OVER: + { + // (x1 x2 -- x1 x2 x1) + if (stack.size() < 2) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + valtype vch = stacktop(-2); + stack.push_back(vch); + } + break; + + case OP_PICK: + case OP_ROLL: + { + // (xn ... x2 x1 x0 n - xn ... x2 x1 x0 xn) + // (xn ... x2 x1 x0 n - ... x2 x1 x0 xn) + if (stack.size() < 2) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + int n = CScriptNum(stacktop(-1), fRequireMinimal).getint(); + popstack(stack); + if (n < 0 || n >= (int)stack.size()) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + valtype vch = stacktop(-n-1); + if (opcode == OP_ROLL) + stack.erase(stack.end()-n-1); + stack.push_back(vch); + } + break; + + case OP_ROT: + { + // (x1 x2 x3 -- x2 x3 x1) + // x2 x1 x3 after first swap + // x2 x3 x1 after second swap + if (stack.size() < 3) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + swap(stacktop(-3), stacktop(-2)); + swap(stacktop(-2), stacktop(-1)); + } + break; + + case OP_SWAP: + { + // (x1 x2 -- x2 x1) + if (stack.size() < 2) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + swap(stacktop(-2), stacktop(-1)); + } + break; + + case OP_TUCK: + { + // (x1 x2 -- x2 x1 x2) + if (stack.size() < 2) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + valtype vch = stacktop(-1); + stack.insert(stack.end()-2, vch); + } + break; + + + case OP_SIZE: + { + // (in -- in size) + if (stack.size() < 1) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + CScriptNum bn(stacktop(-1).size()); + stack.push_back(bn.getvch()); + } + break; + + + // + // Bitwise logic + // + case OP_EQUAL: + case OP_EQUALVERIFY: + //case OP_NOTEQUAL: // use OP_NUMNOTEQUAL + { + // (x1 x2 - bool) + if (stack.size() < 2) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + valtype& vch1 = stacktop(-2); + valtype& vch2 = stacktop(-1); + bool fEqual = (vch1 == vch2); + // OP_NOTEQUAL is disabled because it would be too easy to say + // something like n != 1 and have some wiseguy pass in 1 with extra + // zero bytes after it (numerically, 0x01 == 0x0001 == 0x000001) + //if (opcode == OP_NOTEQUAL) + // fEqual = !fEqual; + popstack(stack); + popstack(stack); + stack.push_back(fEqual ? vchTrue : vchFalse); + if (opcode == OP_EQUALVERIFY) + { + if (fEqual) + popstack(stack); + else + return set_error(serror, SCRIPT_ERR_EQUALVERIFY); + } + } + break; + + + // + // Numeric + // + case OP_1ADD: + case OP_1SUB: + case OP_NEGATE: + case OP_ABS: + case OP_NOT: + case OP_0NOTEQUAL: + { + // (in -- out) + if (stack.size() < 1) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + CScriptNum bn(stacktop(-1), fRequireMinimal); + switch (opcode) + { + case OP_1ADD: bn += bnOne; break; + case OP_1SUB: bn -= bnOne; break; + case OP_NEGATE: bn = -bn; break; + case OP_ABS: if (bn < bnZero) bn = -bn; break; + case OP_NOT: bn = (bn == bnZero); break; + case OP_0NOTEQUAL: bn = (bn != bnZero); break; + default: assert(!"invalid opcode"); break; + } + popstack(stack); + stack.push_back(bn.getvch()); + } + break; + + case OP_ADD: + case OP_SUB: + case OP_BOOLAND: + case OP_BOOLOR: + case OP_NUMEQUAL: + case OP_NUMEQUALVERIFY: + case OP_NUMNOTEQUAL: + case OP_LESSTHAN: + case OP_GREATERTHAN: + case OP_LESSTHANOREQUAL: + case OP_GREATERTHANOREQUAL: + case OP_MIN: + case OP_MAX: + { + // (x1 x2 -- out) + if (stack.size() < 2) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + CScriptNum bn1(stacktop(-2), fRequireMinimal); + CScriptNum bn2(stacktop(-1), fRequireMinimal); + CScriptNum bn(0); + switch (opcode) + { + case OP_ADD: + bn = bn1 + bn2; + break; + + case OP_SUB: + bn = bn1 - bn2; + break; + + case OP_BOOLAND: bn = (bn1 != bnZero && bn2 != bnZero); break; + case OP_BOOLOR: bn = (bn1 != bnZero || bn2 != bnZero); break; + case OP_NUMEQUAL: bn = (bn1 == bn2); break; + case OP_NUMEQUALVERIFY: bn = (bn1 == bn2); break; + case OP_NUMNOTEQUAL: bn = (bn1 != bn2); break; + case OP_LESSTHAN: bn = (bn1 < bn2); break; + case OP_GREATERTHAN: bn = (bn1 > bn2); break; + case OP_LESSTHANOREQUAL: bn = (bn1 <= bn2); break; + case OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break; + case OP_MIN: bn = (bn1 < bn2 ? bn1 : bn2); break; + case OP_MAX: bn = (bn1 > bn2 ? bn1 : bn2); break; + default: assert(!"invalid opcode"); break; + } + popstack(stack); + popstack(stack); + stack.push_back(bn.getvch()); + + if (opcode == OP_NUMEQUALVERIFY) + { + if (CastToBool(stacktop(-1))) + popstack(stack); + else + return set_error(serror, SCRIPT_ERR_NUMEQUALVERIFY); + } + } + break; + + case OP_WITHIN: + { + // (x min max -- out) + if (stack.size() < 3) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + CScriptNum bn1(stacktop(-3), fRequireMinimal); + CScriptNum bn2(stacktop(-2), fRequireMinimal); + CScriptNum bn3(stacktop(-1), fRequireMinimal); + bool fValue = (bn2 <= bn1 && bn1 < bn3); + popstack(stack); + popstack(stack); + popstack(stack); + stack.push_back(fValue ? vchTrue : vchFalse); + } + break; + + + // + // Crypto + // + case OP_RIPEMD160: + case OP_SHA1: + case OP_SHA256: + case OP_HASH160: + case OP_HASH256: + { + // (in -- hash) + if (stack.size() < 1) + return false; + valtype& vch = stacktop(-1); + valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160) ? 20 : 32); + if (opcode == OP_RIPEMD160) + RIPEMD160(&vch[0], vch.size(), &vchHash[0]); + else if (opcode == OP_SHA1) + SHA1(&vch[0], vch.size(), &vchHash[0]); + else if (opcode == OP_SHA256) + SHA256(&vch[0], vch.size(), &vchHash[0]); + else if (opcode == OP_HASH160) + { + uint160 hash160 = Hash160(vch); + memcpy(&vchHash[0], &hash160, sizeof(hash160)); + } + else if (opcode == OP_HASH256) + { + uint256 hash = Hash(vch.begin(), vch.end()); + memcpy(&vchHash[0], &hash, sizeof(hash)); + } + popstack(stack); + stack.push_back(vchHash); + } + break; + /*{ + // (in -- hash) + if (stack.size() < 1) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + valtype& vch = stacktop(-1); + valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160) ? 20 : 32); + if (opcode == OP_RIPEMD160) + CRIPEMD160().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash)); + else if (opcode == OP_SHA1) + CSHA1().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash)); + else if (opcode == OP_SHA256) + CSHA256().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash)); + else if (opcode == OP_HASH160) + CHash160().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash)); + else if (opcode == OP_HASH256) + CHash256().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash)); + popstack(stack); + stack.push_back(vchHash); + } + break; */ + + case OP_CODESEPARATOR: + { + // Hash starts after the code separator + pbegincodehash = pc; + } + break; + + case OP_CHECKSIG: + case OP_CHECKSIGVERIFY: + { + // (sig pubkey -- bool) + if (stack.size() < 2) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + + valtype& vchSig = stacktop(-2); + valtype& vchPubKey = stacktop(-1); + + // Subset of script starting at the most recent codeseparator + CScript scriptCode(pbegincodehash, pend); + + // Drop the signature, since there's no way for a signature to sign itself + scriptCode.FindAndDelete(CScript(vchSig)); + + if (!CheckSignatureEncoding(vchSig, flags, serror) || !CheckPubKeyEncoding(vchPubKey, flags, serror)) { + //serror is set + return false; + } + bool fSuccess = checker.CheckSig(vchSig, vchPubKey, scriptCode); + + popstack(stack); + popstack(stack); + stack.push_back(fSuccess ? vchTrue : vchFalse); + if (opcode == OP_CHECKSIGVERIFY) + { + if (fSuccess) + popstack(stack); + else + return set_error(serror, SCRIPT_ERR_CHECKSIGVERIFY); + } + } + break; + + case OP_CHECKMULTISIG: + case OP_CHECKMULTISIGVERIFY: + { + // ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool) + + int i = 1; + if ((int)stack.size() < i) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + + int nKeysCount = CScriptNum(stacktop(-i), fRequireMinimal).getint(); + if (nKeysCount < 0 || nKeysCount > 20) + return set_error(serror, SCRIPT_ERR_PUBKEY_COUNT); + nOpCount += nKeysCount; + if (nOpCount > 201) + return set_error(serror, SCRIPT_ERR_OP_COUNT); + int ikey = ++i; + i += nKeysCount; + if ((int)stack.size() < i) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + + int nSigsCount = CScriptNum(stacktop(-i), fRequireMinimal).getint(); + if (nSigsCount < 0 || nSigsCount > nKeysCount) + return set_error(serror, SCRIPT_ERR_SIG_COUNT); + int isig = ++i; + i += nSigsCount; + if ((int)stack.size() < i) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + + // Subset of script starting at the most recent codeseparator + CScript scriptCode(pbegincodehash, pend); + + // Drop the signatures, since there's no way for a signature to sign itself + for (int k = 0; k < nSigsCount; k++) + { + valtype& vchSig = stacktop(-isig-k); + scriptCode.FindAndDelete(CScript(vchSig)); + } + + bool fSuccess = true; + while (fSuccess && nSigsCount > 0) + { + valtype& vchSig = stacktop(-isig); + valtype& vchPubKey = stacktop(-ikey); + + // Note how this makes the exact order of pubkey/signature evaluation + // distinguishable by CHECKMULTISIG NOT if the STRICTENC flag is set. + // See the script_(in)valid tests for details. + if (!CheckSignatureEncoding(vchSig, flags, serror) || !CheckPubKeyEncoding(vchPubKey, flags, serror)) { + // serror is set + return false; + } + + // Check signature + bool fOk = checker.CheckSig(vchSig, vchPubKey, scriptCode); + + if (fOk) { + isig++; + nSigsCount--; + } + ikey++; + nKeysCount--; + + // If there are more signatures left than keys left, + // then too many signatures have failed. Exit early, + // without checking any further signatures. + if (nSigsCount > nKeysCount) + fSuccess = false; + } + + // Clean up stack of actual arguments + while (i-- > 1) + popstack(stack); + + // A bug causes CHECKMULTISIG to consume one extra argument + // whose contents were not checked in any way. + // + // Unfortunately this is a potential source of mutability, + // so optionally verify it is exactly equal to zero prior + // to removing it from the stack. + if (stack.size() < 1) + return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); + if ((flags & SCRIPT_VERIFY_NULLDUMMY) && stacktop(-1).size()) + return set_error(serror, SCRIPT_ERR_SIG_NULLDUMMY); + popstack(stack); + + stack.push_back(fSuccess ? vchTrue : vchFalse); + + if (opcode == OP_CHECKMULTISIGVERIFY) + { + if (fSuccess) + popstack(stack); + else + return set_error(serror, SCRIPT_ERR_CHECKMULTISIGVERIFY); + } + } + break; + + default: + return set_error(serror, SCRIPT_ERR_BAD_OPCODE); + } + + // Size limits + if (stack.size() + altstack.size() > 1000) + return set_error(serror, SCRIPT_ERR_STACK_SIZE); + } + } + catch (...) + { + return set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR); + } + + if (!vfExec.empty()) + return set_error(serror, SCRIPT_ERR_UNBALANCED_CONDITIONAL); + + return set_success(serror); +} + + + + + + +uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType) +{ + if (nIn >= txTo.vin.size()) + { + LogPrintf("ERROR: SignatureHash() : nIn=%d out of range\n", nIn); + return 1; + } + CTransaction txTmp(txTo); + + // In case concatenating two scripts ends up with two codeseparators, + // or an extra one at the end, this prevents all those possible incompatibilities. + scriptCode.FindAndDelete(CScript(OP_CODESEPARATOR)); + + // Blank out other inputs' signatures + for (unsigned int i = 0; i < txTmp.vin.size(); i++) + txTmp.vin[i].scriptSig = CScript(); + txTmp.vin[nIn].scriptSig = scriptCode; + + // Blank out some of the outputs + if ((nHashType & 0x1f) == SIGHASH_NONE) + { + // Wildcard payee + txTmp.vout.clear(); + + // Let the others update at will + for (unsigned int i = 0; i < txTmp.vin.size(); i++) + if (i != nIn) + txTmp.vin[i].nSequence = 0; + } + else if ((nHashType & 0x1f) == SIGHASH_SINGLE) + { + // Only lock-in the txout payee at same index as txin + unsigned int nOut = nIn; + if (nOut >= txTmp.vout.size()) + { + LogPrintf("ERROR: SignatureHash() : nOut=%d out of range\n", nOut); + return 1; + } + txTmp.vout.resize(nOut+1); + for (unsigned int i = 0; i < nOut; i++) + txTmp.vout[i].SetNull(); + + // Let the others update at will + for (unsigned int i = 0; i < txTmp.vin.size(); i++) + if (i != nIn) + txTmp.vin[i].nSequence = 0; + } + + // Blank out other inputs completely, not recommended for open transactions + if (nHashType & SIGHASH_ANYONECANPAY) + { + txTmp.vin[0] = txTmp.vin[nIn]; + txTmp.vin.resize(1); + } + + // Serialize and hash + CHashWriter ss(SER_GETHASH, 0); + ss << txTmp << nHashType; + return ss.GetHash(); +} + + +bool SignSignature(const CKeyStore &keystore, const CScript& fromPubKey, CTransaction& txTo, unsigned int nIn, int nHashType) +{ + assert(nIn < txTo.vin.size()); + CTxIn& txin = txTo.vin[nIn]; + + // Leave out the signature from the hash, since a signature can't sign itself. + // The checksig op will also drop the signatures from its hash. + uint256 hash = SignatureHash(fromPubKey, txTo, nIn, nHashType); + + txnouttype whichType; + if (!Solver(keystore, fromPubKey, hash, nHashType, txin.scriptSig, whichType)) + return false; + + if (whichType == TX_SCRIPTHASH) + { + // Solver returns the subscript that need to be evaluated; + // the final scriptSig is the signatures from that + // and then the serialized subscript: + CScript subscript = txin.scriptSig; + + // Recompute txn hash using subscript in place of scriptPubKey: + uint256 hash2 = SignatureHash(subscript, txTo, nIn, nHashType); + + txnouttype subType; + bool fSolved = + Solver(keystore, subscript, hash2, nHashType, txin.scriptSig, subType) && subType != TX_SCRIPTHASH; + // Append serialized subscript whether or not it is completely signed: + txin.scriptSig << static_cast(subscript); + if (!fSolved) return false; + } + + // Test solution + return VerifyScript(txin.scriptSig, fromPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, SignatureChecker(txTo, nIn)); +} + +bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType) +{ + assert(nIn < txTo.vin.size()); + CTxIn& txin = txTo.vin[nIn]; + assert(txin.prevout.n < txFrom.vout.size()); + const CTxOut& txout = txFrom.vout[txin.prevout.n]; + + return SignSignature(keystore, txout.scriptPubKey, txTo, nIn, nHashType); +} + + + + +// Valid signature cache, to avoid doing expensive ECDSA signature checking +// twice for every transaction (once when accepted into memory pool, and +// again when accepted into the block chain) + +class CSignatureCache +{ +private: + // sigdata_type is (signature hash, signature, public key): + typedef boost::tuple, CPubKey> sigdata_type; + std::set< sigdata_type> setValid; + boost::shared_mutex cs_sigcache; + +public: + bool + Get(const uint256 &hash, const std::vector& vchSig, const CPubKey& pubKey) + { + boost::shared_lock lock(cs_sigcache); + + sigdata_type k(hash, vchSig, pubKey); + std::set::iterator mi = setValid.find(k); + if (mi != setValid.end()) + return true; + return false; + } + + void Set(const uint256 &hash, const std::vector& vchSig, const CPubKey& pubKey) + { + // DoS prevention: limit cache size to less than 10MB + // (~200 bytes per cache entry times 50,000 entries) + // Since there are a maximum of 20,000 signature operations per block + // 50,000 is a reasonable default. + int64_t nMaxCacheSize = GetArg("-maxsigcachesize", 50000); + if (nMaxCacheSize <= 0) return; + + boost::unique_lock lock(cs_sigcache); + + while (static_cast(setValid.size()) > nMaxCacheSize) + { + // Evict a random entry. Random because that helps + // foil would-be DoS attackers who might try to pre-generate + // and re-use a set of valid signatures just-slightly-greater + // than our cache size. + uint256 randomHash = GetRandHash(); + std::vector unused; + std::set::iterator it = + setValid.lower_bound(sigdata_type(randomHash, unused, unused)); + if (it == setValid.end()) + it = setValid.begin(); + setValid.erase(*it); + } + + sigdata_type k(hash, vchSig, pubKey); + setValid.insert(k); + } +}; + +bool CheckSig(vector vchSig, const vector &vchPubKey, const CScript &scriptCode, + const CTransaction& txTo, unsigned int nIn, int nHashType, int flags) +{ + static CSignatureCache signatureCache; + + CPubKey pubkey(vchPubKey); + if (!pubkey.IsValid()) + return false; + + // Hash type is one byte tacked on to the end of the signature + if (vchSig.empty()) + return false; + if (nHashType == 0) + nHashType = vchSig.back(); + else if (nHashType != vchSig.back()) + return false; + vchSig.pop_back(); + + uint256 sighash = SignatureHash(scriptCode, txTo, nIn, nHashType); + + if (signatureCache.Get(sighash, vchSig, pubkey)) + return true; + + if (!pubkey.Verify(sighash, vchSig)) + return false; + + if (!(flags & SCRIPT_VERIFY_NOCACHE)) + signatureCache.Set(sighash, vchSig, pubkey); + + return true; +} + + + + + + + + + +// +// Return public keys or hashes from scriptPubKey, for 'standard' transaction types. +// +bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector >& vSolutionsRet) +{ + // Templates + static multimap mTemplates; + if (mTemplates.empty()) + { + // Standard tx, sender provides pubkey, receiver adds signature + mTemplates.insert(make_pair(TX_PUBKEY, CScript() << OP_PUBKEY << OP_CHECKSIG)); + + // Bitcoin address tx, sender provides hash of pubkey, receiver provides signature and pubkey + mTemplates.insert(make_pair(TX_PUBKEYHASH, CScript() << OP_DUP << OP_HASH160 << OP_PUBKEYHASH << OP_EQUALVERIFY << OP_CHECKSIG)); + + // Sender provides N pubkeys, receivers provides M signatures + mTemplates.insert(make_pair(TX_MULTISIG, CScript() << OP_SMALLINTEGER << OP_PUBKEYS << OP_SMALLINTEGER << OP_CHECKMULTISIG)); + + // Empty, provably prunable, data-carrying output + mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN << OP_SMALLDATA)); + mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN)); + } + + // Shortcut for pay-to-script-hash, which are more constrained than the other types: + // it is always OP_HASH160 20 [20 byte hash] OP_EQUAL + if (scriptPubKey.IsPayToScriptHash()) + { + typeRet = TX_SCRIPTHASH; + vector hashBytes(scriptPubKey.begin()+2, scriptPubKey.begin()+22); + vSolutionsRet.push_back(hashBytes); + return true; + } + + int witnessversion; + std::vector witnessprogram; + if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) { + if (witnessversion == 0 && witnessprogram.size() == 20) { + typeRet = TX_WITNESS_V0_KEYHASH; + vSolutionsRet.push_back(witnessprogram); + return true; + } + if (witnessversion == 0 && witnessprogram.size() == 32) { + typeRet = TX_WITNESS_V0_SCRIPTHASH; + vSolutionsRet.push_back(witnessprogram); + return true; + } + return false; + } + + // Provably prunable, data-carrying output + // + // So long as script passes the IsUnspendable() test and all but the first + // byte passes the IsPushOnly() test we don't care what exactly is in the + // script. + if (scriptPubKey.size() >= 1 && scriptPubKey[0] == OP_RETURN && scriptPubKey.IsPushOnly(scriptPubKey.begin()+1)) { + typeRet = TX_NULL_DATA; + return true; + } + + // Scan templates + const CScript& script1 = scriptPubKey; + BOOST_FOREACH(const PAIRTYPE(txnouttype, CScript)& tplate, mTemplates) + { + const CScript& script2 = tplate.second; + vSolutionsRet.clear(); + + opcodetype opcode1, opcode2; + vector vch1, vch2; + + // Compare + CScript::const_iterator pc1 = script1.begin(); + CScript::const_iterator pc2 = script2.begin(); + while (true) + { + if (pc1 == script1.end() && pc2 == script2.end()) + { + // Found a match + typeRet = tplate.first; + if (typeRet == TX_MULTISIG) + { + // Additional checks for TX_MULTISIG: + unsigned char m = vSolutionsRet.front()[0]; + unsigned char n = vSolutionsRet.back()[0]; + if (m < 1 || n < 1 || m > n || vSolutionsRet.size()-2 != n) + return false; + } + return true; + } + if (!script1.GetOp(pc1, opcode1, vch1)) + break; + if (!script2.GetOp(pc2, opcode2, vch2)) + break; + + // Template matching opcodes: + if (opcode2 == OP_PUBKEYS) + { + while (vch1.size() >= 33 && vch1.size() <= 120) + { + vSolutionsRet.push_back(vch1); + if (!script1.GetOp(pc1, opcode1, vch1)) + break; + } + if (!script2.GetOp(pc2, opcode2, vch2)) + break; + // Normal situation is to fall through + // to other if/else statements + } + + if (opcode2 == OP_PUBKEY) + { + if (vch1.size() < 33 || vch1.size() > 120) + break; + vSolutionsRet.push_back(vch1); + } + else if (opcode2 == OP_PUBKEYHASH) + { + if (vch1.size() != sizeof(uint160)) + break; + vSolutionsRet.push_back(vch1); + } + else if (opcode2 == OP_SMALLINTEGER) + { // Single-byte small integer pushed onto vSolutions + if (opcode1 == OP_0 || + (opcode1 >= OP_1 && opcode1 <= OP_16)) + { + char n = (char)CScript::DecodeOP_N(opcode1); + vSolutionsRet.push_back(valtype(1, n)); + } + else + break; + } + else if (opcode2 == OP_SMALLDATA) + { + // small pushdata, <= MAX_OP_RETURN_RELAY bytes + if (vch1.size() > MAX_OP_RETURN_RELAY) + break; + } + else if (opcode1 != opcode2 || vch1 != vch2) + { + // Others must match exactly + break; + } + } + } + + vSolutionsRet.clear(); + typeRet = TX_NONSTANDARD; + return false; +} + + +bool Sign1(const CKeyID& address, const CKeyStore& keystore, uint256 hash, int nHashType, CScript& scriptSigRet) +{ + CKey key; + if (!keystore.GetKey(address, key)) + return false; + + vector vchSig; + if (!key.Sign(hash, vchSig)) + return false; + vchSig.push_back((unsigned char)nHashType); + scriptSigRet << vchSig; + + return true; +} + +bool SignN(const vector& multisigdata, const CKeyStore& keystore, uint256 hash, int nHashType, CScript& scriptSigRet) +{ + int nSigned = 0; + int nRequired = multisigdata.front()[0]; + for (unsigned int i = 1; i < multisigdata.size()-1 && nSigned < nRequired; i++) + { + const valtype& pubkey = multisigdata[i]; + CKeyID keyID = CPubKey(pubkey).GetID(); + if (Sign1(keyID, keystore, hash, nHashType, scriptSigRet)) + ++nSigned; + } + return nSigned==nRequired; +} + +// +// Sign scriptPubKey with private keys stored in keystore, given transaction hash and hash type. +// Signatures are returned in scriptSigRet (or returns false if scriptPubKey can't be signed), +// unless whichTypeRet is TX_SCRIPTHASH, in which case scriptSigRet is the redemption script. +// Returns false if scriptPubKey could not be completely satisfied. +// +bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash, int nHashType, + CScript& scriptSigRet, txnouttype& whichTypeRet) +{ + scriptSigRet.clear(); + + vector vSolutions; + if (!Solver(scriptPubKey, whichTypeRet, vSolutions)) + return false; + + CKeyID keyID; + switch (whichTypeRet) + { + case TX_NONSTANDARD: + case TX_NULL_DATA: + return false; + case TX_PUBKEY: + keyID = CPubKey(vSolutions[0]).GetID(); + return Sign1(keyID, keystore, hash, nHashType, scriptSigRet); + case TX_PUBKEYHASH: + keyID = CKeyID(uint160(vSolutions[0])); + if (!Sign1(keyID, keystore, hash, nHashType, scriptSigRet)) + return false; + else + { + CPubKey vch; + keystore.GetPubKey(keyID, vch); + scriptSigRet << vch; + } + return true; + case TX_SCRIPTHASH: + return keystore.GetCScript(uint160(vSolutions[0]), scriptSigRet); + + case TX_MULTISIG: + scriptSigRet << OP_0; // workaround CHECKMULTISIG bug + return (SignN(vSolutions, keystore, hash, nHashType, scriptSigRet)); + } + return false; +} + +int ScriptSigArgsExpected(txnouttype t, const std::vector >& vSolutions) +{ + switch (t) + { + case TX_NONSTANDARD: + case TX_NULL_DATA: + return -1; + case TX_PUBKEY: + return 1; + case TX_PUBKEYHASH: + return 2; + case TX_MULTISIG: + if (vSolutions.size() < 1 || vSolutions[0].size() < 1) + return -1; + return vSolutions[0][0] + 1; + case TX_SCRIPTHASH: + return 1; // doesn't include args needed by the script + } + return -1; +} + +bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) +{ + vector vSolutions; + if (!Solver(scriptPubKey, whichType, vSolutions)) + return false; + + if (whichType == TX_MULTISIG) + { + unsigned char m = vSolutions.front()[0]; + unsigned char n = vSolutions.back()[0]; + // Support up to x-of-3 multisig txns as standard + if (n < 1 || n > 3) + return false; + if (m < 1 || m > n) + return false; + } + + return whichType != TX_NONSTANDARD; +} + + +unsigned int HaveKeys(const vector& pubkeys, const CKeyStore& keystore) +{ + unsigned int nResult = 0; + BOOST_FOREACH(const valtype& pubkey, pubkeys) + { + CKeyID keyID = CPubKey(pubkey).GetID(); + if (keystore.HaveKey(keyID)) + ++nResult; + } + return nResult; +} + + +class CKeyStoreIsMineVisitor : public boost::static_visitor +{ +private: + const CKeyStore *keystore; +public: + CKeyStoreIsMineVisitor(const CKeyStore *keystoreIn) : keystore(keystoreIn) { } + bool operator()(const CNoDestination &dest) const { return false; } + bool operator()(const CKeyID &keyID) const { return keystore->HaveKey(keyID); } + bool operator()(const CScriptID &scriptID) const { return keystore->HaveCScript(scriptID); } + bool operator()(const CStealthAddress &stxAddr) const + { + return stxAddr.scan_secret.size() == ec_secret_size; + } +}; + +bool IsMine(const CKeyStore &keystore, const CTxDestination &dest) +{ + return boost::apply_visitor(CKeyStoreIsMineVisitor(&keystore), dest); +} + +bool IsMine(const CKeyStore &keystore, const CScript& scriptPubKey) +{ + vector vSolutions; + txnouttype whichType; + if (!Solver(scriptPubKey, whichType, vSolutions)) + return false; + + CKeyID keyID; + switch (whichType) + { + case TX_NONSTANDARD: + case TX_NULL_DATA: + return false; + case TX_PUBKEY: + keyID = CPubKey(vSolutions[0]).GetID(); + return keystore.HaveKey(keyID); + case TX_PUBKEYHASH: + keyID = CKeyID(uint160(vSolutions[0])); + return keystore.HaveKey(keyID); + case TX_SCRIPTHASH: + { + CScript subscript; + if (!keystore.GetCScript(CScriptID(uint160(vSolutions[0])), subscript)) + return false; + return IsMine(keystore, subscript); + } + case TX_MULTISIG: + { + // Only consider transactions "mine" if we own ALL the + // keys involved. multi-signature transactions that are + // partially owned (somebody else has a key that can spend + // them) enable spend-out-from-under-you attacks, especially + // in shared-wallet situations. + vector keys(vSolutions.begin()+1, vSolutions.begin()+vSolutions.size()-1); + return HaveKeys(keys, keystore) == keys.size(); + } + } + return false; +} + +bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) +{ + vector vSolutions; + txnouttype whichType; + if (!Solver(scriptPubKey, whichType, vSolutions)) + return false; + + if (whichType == TX_PUBKEY) + { + addressRet = CPubKey(vSolutions[0]).GetID(); + return true; + } + else if (whichType == TX_PUBKEYHASH) + { + addressRet = CKeyID(uint160(vSolutions[0])); + return true; + } + else if (whichType == TX_SCRIPTHASH) + { + addressRet = CScriptID(uint160(vSolutions[0])); + return true; + } + // Multisig txns have more than one address... + return false; +} + +class CAffectedKeysVisitor : public boost::static_visitor { +private: + const CKeyStore &keystore; + std::vector &vKeys; + +public: + CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {} + + void Process(const CScript &script) { + txnouttype type; + std::vector vDest; + int nRequired; + if (ExtractDestinations(script, type, vDest, nRequired)) { + BOOST_FOREACH(const CTxDestination &dest, vDest) + boost::apply_visitor(*this, dest); + } + } + + void operator()(const CKeyID &keyId) { + if (keystore.HaveKey(keyId)) + vKeys.push_back(keyId); + } + + void operator()(const CScriptID &scriptId) { + CScript script; + if (keystore.GetCScript(scriptId, script)) + Process(script); + } + + void operator()(const CStealthAddress &stxAddr) { + CScript script; + + } + + void operator()(const CNoDestination &none) {} +}; + + +void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, std::vector &vKeys) { + CAffectedKeysVisitor(keystore, vKeys).Process(scriptPubKey); +} + +bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vector& addressRet, int& nRequiredRet) +{ + addressRet.clear(); + typeRet = TX_NONSTANDARD; + vector vSolutions; + if (!Solver(scriptPubKey, typeRet, vSolutions)) + return false; + if (typeRet == TX_NULL_DATA){ + // This is data, not addresses + return false; + } + + if (typeRet == TX_MULTISIG) + { + nRequiredRet = vSolutions.front()[0]; + for (unsigned int i = 1; i < vSolutions.size()-1; i++) + { + CTxDestination address = CPubKey(vSolutions[i]).GetID(); + addressRet.push_back(address); + } + } + else + { + nRequiredRet = 1; + CTxDestination address; + if (!ExtractDestination(scriptPubKey, address)) + return false; + addressRet.push_back(address); + } + + return true; +} + +/*uint256 SignatureHash(const CScript& scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType) +{ + if (nIn >= txTo.vin.size()) { + // nIn out of range + return 1; + } + + // Check for invalid use of SIGHASH_SINGLE + if ((nHashType & 0x1f) == SIGHASH_SINGLE) { + if (nIn >= txTo.vout.size()) { + // nOut out of range + return 1; + } + } + + // Wrapper to serialize only the necessary parts of the transaction being signed + CTransactionSignatureSerializer txTmp(txTo, scriptCode, nIn, nHashType); + + // Serialize and hash + CHashWriter ss(SER_GETHASH, 0); + ss << txTmp << nHashType; + return ss.GetHash(); +}*/ + +bool SignatureChecker::VerifySignature(const std::vector& vchSig, const CPubKey& pubkey, const uint256& sighash) const +{ + return pubkey.Verify(sighash, vchSig); +} + +bool SignatureChecker::CheckSig(const vector& vchSigIn, const vector& vchPubKey, const CScript& scriptCode) const +{ + CPubKey pubkey(vchPubKey); + if (!pubkey.IsValid()) + return false; + + // Hash type is one byte tacked on to the end of the signature + vector vchSig(vchSigIn); + if (vchSig.empty()) + return false; + int nHashType = vchSig.back(); + vchSig.pop_back(); + + uint256 sighash = SignatureHash(scriptCode, txTo, nIn, nHashType); + + if (!VerifySignature(vchSig, pubkey, sighash)) + return false; + + return true; +} + + +bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType) +{ + vector > stack, stackCopy; + if (!EvalScript(stack, scriptSig, txTo, nIn, flags, nHashType)) + return false; + + stackCopy = stack; + + if (!EvalScript(stack, scriptPubKey, txTo, nIn, flags, nHashType)) + return false; + if (stack.empty()) + return false; + + if (CastToBool(stack.back()) == false) + return false; + + // Additional validation for spend-to-script-hash transactions: + if (scriptPubKey.IsPayToScriptHash()) + { + if (!scriptSig.IsPushOnly()) // scriptSig must be literals-only + return false; // or validation fails + + const valtype& pubKeySerialized = stackCopy.back(); + CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end()); + popstack(stackCopy); + + if (!EvalScript(stackCopy, pubKey2, txTo, nIn, flags, nHashType)) + return false; + if (stackCopy.empty()) + return false; + return CastToBool(stackCopy.back()); + } + + return true; +} + +bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, unsigned int flags, const BaseSignatureChecker& checker, ScriptError* serror) +{ + set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR); + + if ((flags & SCRIPT_VERIFY_SIGPUSHONLY) != 0 && !scriptSig.IsPushOnly()) { + return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY); + } + + vector > stack, stackCopy; + if (!EvalScript(stack, scriptSig, flags, checker, serror)) + // serror is set + return false; + if (flags & SCRIPT_VERIFY_P2SH) + stackCopy = stack; + if (!EvalScript(stack, scriptPubKey, flags, checker, serror)) + // serror is set + return false; + if (stack.empty()) + return set_error(serror, SCRIPT_ERR_EVAL_FALSE); + + if (CastToBool(stack.back()) == false) + return set_error(serror, SCRIPT_ERR_EVAL_FALSE); + + // Additional validation for spend-to-script-hash transactions: + if ((flags & SCRIPT_VERIFY_P2SH) && scriptPubKey.IsPayToScriptHash()) + { + // scriptSig must be literals-only or validation fails + if (!scriptSig.IsPushOnly()) + return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY); + + // stackCopy cannot be empty here, because if it was the + // P2SH HASH <> EQUAL scriptPubKey would be evaluated with + // an empty stack and the EvalScript above would return false. + assert(!stackCopy.empty()); + + const valtype& pubKeySerialized = stackCopy.back(); + CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end()); + popstack(stackCopy); + + if (!EvalScript(stackCopy, pubKey2, flags, checker, serror)) + // serror is set + return false; + if (stackCopy.empty()) + return set_error(serror, SCRIPT_ERR_EVAL_FALSE); + if (!CastToBool(stackCopy.back())) + return set_error(serror, SCRIPT_ERR_EVAL_FALSE); + else + return set_success(serror); + } + + return set_success(serror); +} + +size_t static WitnessSigOps(int witversion, const std::vector& witprogram, const CScriptWitness& witness, int flags) +{ + if (witversion == 0) { + if (witprogram.size() == 20) + return 1; + + if (witprogram.size() == 32 && witness.stack.size() > 0) { + CScript subscript(witness.stack.back().begin(), witness.stack.back().end()); + return subscript.GetSigOpCount(true); + } + } + + // Future flags may be implemented here. + return 0; +} + +size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness* witness, unsigned int flags) +{ + static const CScriptWitness witnessEmpty; + + if ((flags & SCRIPT_VERIFY_WITNESS) == 0) { + return 0; + } + assert((flags & SCRIPT_VERIFY_P2SH) != 0); + + int witnessversion; + std::vector witnessprogram; + if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) { + return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty, flags); + } + + if (scriptPubKey.IsPayToScriptHash() && scriptSig.IsPushOnly()) { + CScript::const_iterator pc = scriptSig.begin(); + vector data; + while (pc < scriptSig.end()) { + opcodetype opcode; + scriptSig.GetOp(pc, opcode, data); + } + CScript subscript(data.begin(), data.end()); + if (subscript.IsWitnessProgram(witnessversion, witnessprogram)) { + return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty, flags); + } + } + + return 0; +} + + +/*bool SignSignature(const CKeyStore &keystore, const CScript& fromPubKey, CTransaction& txTo, unsigned int nIn, int nHashType) +{ + assert(nIn < txTo.vin.size()); + CTxIn& txin = txTo.vin[nIn]; + + // Leave out the signature from the hash, since a signature can't sign itself. + // The checksig op will also drop the signatures from its hash. + uint256 hash = SignatureHash(fromPubKey, txTo, nIn, nHashType); + + txnouttype whichType; + if (!Solver(keystore, fromPubKey, hash, nHashType, txin.scriptSig, whichType)) + return false; + + if (whichType == TX_SCRIPTHASH) + { + // Solver returns the subscript that need to be evaluated; + // the final scriptSig is the signatures from that + // and then the serialized subscript: + CScript subscript = txin.scriptSig; + + // Recompute txn hash using subscript in place of scriptPubKey: + uint256 hash2 = SignatureHash(subscript, txTo, nIn, nHashType); + + txnouttype subType; + bool fSolved = + Solver(keystore, subscript, hash2, nHashType, txin.scriptSig, subType) && subType != TX_SCRIPTHASH; + // Append serialized subscript whether or not it is completely signed: + txin.scriptSig << static_cast(subscript); + if (!fSolved) return false; + } + + // Test solution + return VerifyScript(txin.scriptSig, fromPubKey, txTo, nIn, STANDARD_SCRIPT_VERIFY_FLAGS, 0); +}*/ + +/*bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType) +{ + assert(nIn < txTo.vin.size()); + CTxIn& txin = txTo.vin[nIn]; + assert(txin.prevout.n < txFrom.vout.size()); + assert(txin.prevout.hash == txFrom.GetHash()); + const CTxOut& txout = txFrom.vout[txin.prevout.n]; + + return SignSignature(keystore, txout.scriptPubKey, txTo, nIn, nHashType); +}*/ + +bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType) +{ + assert(nIn < txTo.vin.size()); + const CTxIn& txin = txTo.vin[nIn]; + if (txin.prevout.n >= txFrom.vout.size()) + return false; + const CTxOut& txout = txFrom.vout[txin.prevout.n]; + + if (txin.prevout.hash != txFrom.GetHash()) + return false; + + return VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, flags, nHashType); +} + +static CScript PushAll(const vector& values) +{ + CScript result; + BOOST_FOREACH(const valtype& v, values) + result << v; + return result; +} + +static CScript CombineMultisig(CScript scriptPubKey, const CTransaction& txTo, unsigned int nIn, + const vector& vSolutions, + vector& sigs1, vector& sigs2) +{ + // Combine all the signatures we've got: + set allsigs; + BOOST_FOREACH(const valtype& v, sigs1) + { + if (!v.empty()) + allsigs.insert(v); + } + BOOST_FOREACH(const valtype& v, sigs2) + { + if (!v.empty()) + allsigs.insert(v); + } + + // Build a map of pubkey -> signature by matching sigs to pubkeys: + assert(vSolutions.size() > 1); + unsigned int nSigsRequired = vSolutions.front()[0]; + unsigned int nPubKeys = vSolutions.size()-2; + map sigs; + BOOST_FOREACH(const valtype& sig, allsigs) + { + for (unsigned int i = 0; i < nPubKeys; i++) + { + const valtype& pubkey = vSolutions[i+1]; + if (sigs.count(pubkey)) + continue; // Already got a sig for this pubkey + + if (CheckSig(sig, pubkey, scriptPubKey, txTo, nIn, 0, 0)) + { + sigs[pubkey] = sig; + break; + } + } + } + // Now build a merged CScript: + unsigned int nSigsHave = 0; + CScript result; result << OP_0; // pop-one-too-many workaround + for (unsigned int i = 0; i < nPubKeys && nSigsHave < nSigsRequired; i++) + { + if (sigs.count(vSolutions[i+1])) + { + result << sigs[vSolutions[i+1]]; + ++nSigsHave; + } + } + // Fill any missing with OP_0: + for (unsigned int i = nSigsHave; i < nSigsRequired; i++) + result << OP_0; + + return result; +} + +static CScript CombineSignatures(CScript scriptPubKey, const CTransaction& txTo, unsigned int nIn, + const txnouttype txType, const vector& vSolutions, + vector& sigs1, vector& sigs2) +{ + switch (txType) + { + case TX_NONSTANDARD: + case TX_NULL_DATA: + // Don't know anything about this, assume bigger one is correct: + if (sigs1.size() >= sigs2.size()) + return PushAll(sigs1); + return PushAll(sigs2); + case TX_PUBKEY: + case TX_PUBKEYHASH: + // Signatures are bigger than placeholders or empty scripts: + if (sigs1.empty() || sigs1[0].empty()) + return PushAll(sigs2); + return PushAll(sigs1); + case TX_SCRIPTHASH: + if (sigs1.empty() || sigs1.back().empty()) + return PushAll(sigs2); + else if (sigs2.empty() || sigs2.back().empty()) + return PushAll(sigs1); + else + { + // Recur to combine: + valtype spk = sigs1.back(); + CScript pubKey2(spk.begin(), spk.end()); + + txnouttype txType2; + vector > vSolutions2; + Solver(pubKey2, txType2, vSolutions2); + sigs1.pop_back(); + sigs2.pop_back(); + CScript result = CombineSignatures(pubKey2, txTo, nIn, txType2, vSolutions2, sigs1, sigs2); + result << spk; + return result; + } + case TX_MULTISIG: + return CombineMultisig(scriptPubKey, txTo, nIn, vSolutions, sigs1, sigs2); + } + + return CScript(); +} + +CScript CombineSignatures(CScript scriptPubKey, const CTransaction& txTo, unsigned int nIn, + const CScript& scriptSig1, const CScript& scriptSig2) +{ + txnouttype txType; + vector > vSolutions; + Solver(scriptPubKey, txType, vSolutions); + + vector stack1; + EvalScript(stack1, scriptSig1, CTransaction(), 0, SCRIPT_VERIFY_NONE, 0); + vector stack2; + EvalScript(stack2, scriptSig2, CTransaction(), 0, SCRIPT_VERIFY_NONE, 0); + + return CombineSignatures(scriptPubKey, txTo, nIn, txType, vSolutions, stack1, stack2); +} + +unsigned int CScript::GetSigOpCount(bool fAccurate) const +{ + unsigned int n = 0; + const_iterator pc = begin(); + opcodetype lastOpcode = OP_INVALIDOPCODE; + while (pc < end()) + { + opcodetype opcode; + if (!GetOp(pc, opcode)) + break; + if (opcode == OP_CHECKSIG || opcode == OP_CHECKSIGVERIFY) + n++; + else if (opcode == OP_CHECKMULTISIG || opcode == OP_CHECKMULTISIGVERIFY) + { + if (fAccurate && lastOpcode >= OP_1 && lastOpcode <= OP_16) + n += DecodeOP_N(lastOpcode); + else + n += 20; + } + lastOpcode = opcode; + } + return n; +} + +unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const +{ + if (!IsPayToScriptHash()) + return GetSigOpCount(true); + + // This is a pay-to-script-hash scriptPubKey; + // get the last item that the scriptSig + // pushes onto the stack: + const_iterator pc = scriptSig.begin(); + vector data; + while (pc < scriptSig.end()) + { + opcodetype opcode; + if (!scriptSig.GetOp(pc, opcode, data)) + return 0; + if (opcode > OP_16) + return 0; + } + + /// ... and return its opcount: + CScript subscript(data.begin(), data.end()); + return subscript.GetSigOpCount(true); +} + +bool CScript::IsPayToScriptHash() const +{ + // Extra-fast test for pay-to-script-hash CScripts: + return (this->size() == 23 && + this->at(0) == OP_HASH160 && + this->at(1) == 0x14 && + this->at(22) == OP_EQUAL); +} + +bool CScript::IsPayToWitnessScriptHash() const +{ + // Extra-fast test for pay-to-witness-script-hash CScripts: + return (this->size() == 34 && + (*this)[0] == OP_0 && + (*this)[1] == 0x20); +} + +// A witness program is any valid CScript that consists of a 1-byte push opcode +// followed by a data push between 2 and 40 bytes. +bool CScript::IsWitnessProgram(int& version, std::vector& program) const +{ + if (this->size() < 4 || this->size() > 42) { + return false; + } + if ((*this)[0] != OP_0 && ((*this)[0] < OP_1 || (*this)[0] > OP_16)) { + return false; + } + if ((size_t)((*this)[1] + 2) == this->size()) { + version = DecodeOP_N((opcodetype)(*this)[0]); + program = std::vector(this->begin() + 2, this->end()); + return true; + } + return false; +} + +bool CScript::IsPushOnly(const_iterator pc) const +{ + while (pc < end()) + { + opcodetype opcode; + if (!GetOp(pc, opcode)) + return false; + // Note that IsPushOnly() *does* consider OP_RESERVED to be a + // push-type opcode, however execution of OP_RESERVED fails, so + // it's not relevant to P2SH/BIP62 as the scriptSig would fail prior to + // the P2SH special validation code being executed. + if (opcode > OP_16) + return false; + } + return true; +} + +bool CScript::IsPushOnly() const +{ + return this->IsPushOnly(begin()); +} + +bool CScript::HasCanonicalPushes() const +{ + const_iterator pc = begin(); + while (pc < end()) + { + opcodetype opcode; + std::vector data; + if (!GetOp(pc, opcode, data)) + return false; + if (opcode > OP_16) + continue; + if (opcode < OP_PUSHDATA1 && opcode > OP_0 && (data.size() == 1 && data[0] <= 16)) + // Could have used an OP_n code, rather than a 1-byte push. + return false; + if (opcode == OP_PUSHDATA1 && data.size() < OP_PUSHDATA1) + // Could have used a normal n-byte push, rather than OP_PUSHDATA1. + return false; + if (opcode == OP_PUSHDATA2 && data.size() <= 0xFF) + // Could have used an OP_PUSHDATA1. + return false; + if (opcode == OP_PUSHDATA4 && data.size() <= 0xFFFF) + // Could have used an OP_PUSHDATA2. + return false; + } + return true; +} + +class CScriptVisitor : public boost::static_visitor +{ +private: + CScript *script; +public: + CScriptVisitor(CScript *scriptin) { script = scriptin; } + + bool operator()(const CNoDestination &dest) const { + script->clear(); + return false; + } + + bool operator()(const CKeyID &keyID) const { + script->clear(); + *script << OP_DUP << OP_HASH160 << keyID << OP_EQUALVERIFY << OP_CHECKSIG; + return true; + } + + bool operator()(const CScriptID &scriptID) const { + script->clear(); + *script << OP_HASH160 << scriptID << OP_EQUAL; + return true; + } + + bool operator()(const CStealthAddress &stxAddr) const { + script->clear(); + //*script << OP_HASH160 << scriptID << OP_EQUAL; + printf("TODO\n"); + return false; + } +}; + +void CScript::SetDestination(const CTxDestination& dest) +{ + boost::apply_visitor(CScriptVisitor(this), dest); +} + +void CScript::SetMultisig(int nRequired, const std::vector& keys) +{ + this->clear(); + + *this << EncodeOP_N(nRequired); + BOOST_FOREACH(const CPubKey& key, keys) + *this << key; + *this << EncodeOP_N(keys.size()) << OP_CHECKMULTISIG; +} + +bool CScriptCompressor::IsToKeyID(CKeyID &hash) const +{ + if (script.size() == 25 && script[0] == OP_DUP && script[1] == OP_HASH160 + && script[2] == 20 && script[23] == OP_EQUALVERIFY + && script[24] == OP_CHECKSIG) { + memcpy(&hash, &script[3], 20); + return true; + } + return false; +} + +bool CScriptCompressor::IsToScriptID(CScriptID &hash) const +{ + if (script.size() == 23 && script[0] == OP_HASH160 && script[1] == 20 + && script[22] == OP_EQUAL) { + memcpy(&hash, &script[2], 20); + return true; + } + return false; +} + +bool CScriptCompressor::IsToPubKey(CPubKey &pubkey) const +{ + if (script.size() == 35 && script[0] == 33 && script[34] == OP_CHECKSIG + && (script[1] == 0x02 || script[1] == 0x03)) { + pubkey.Set(&script[1], &script[34]); + return true; + } + if (script.size() == 67 && script[0] == 65 && script[66] == OP_CHECKSIG + && script[1] == 0x04) { + pubkey.Set(&script[1], &script[66]); + return pubkey.IsFullyValid(); // if not fully valid, a case that would not be compressible + } + return false; +} + +bool CScriptCompressor::Compress(std::vector &out) const +{ + CKeyID keyID; + if (IsToKeyID(keyID)) { + out.resize(21); + out[0] = 0x00; + memcpy(&out[1], &keyID, 20); + return true; + } + CScriptID scriptID; + if (IsToScriptID(scriptID)) { + out.resize(21); + out[0] = 0x01; + memcpy(&out[1], &scriptID, 20); + return true; + } + CPubKey pubkey; + if (IsToPubKey(pubkey)) { + out.resize(33); + memcpy(&out[1], &pubkey[1], 32); + if (pubkey[0] == 0x02 || pubkey[0] == 0x03) { + out[0] = pubkey[0]; + return true; + } else if (pubkey[0] == 0x04) { + out[0] = 0x04 | (pubkey[64] & 0x01); + return true; + } + } + return false; +} + +unsigned int CScriptCompressor::GetSpecialSize(unsigned int nSize) const +{ + if (nSize == 0 || nSize == 1) + return 20; + if (nSize == 2 || nSize == 3 || nSize == 4 || nSize == 5) + return 32; + return 0; +} + +bool CScriptCompressor::Decompress(unsigned int nSize, const std::vector &in) +{ + switch(nSize) { + case 0x00: + script.resize(25); + script[0] = OP_DUP; + script[1] = OP_HASH160; + script[2] = 20; + memcpy(&script[3], &in[0], 20); + script[23] = OP_EQUALVERIFY; + script[24] = OP_CHECKSIG; + return true; + case 0x01: + script.resize(23); + script[0] = OP_HASH160; + script[1] = 20; + memcpy(&script[2], &in[0], 20); + script[22] = OP_EQUAL; + return true; + case 0x02: + case 0x03: + script.resize(35); + script[0] = 33; + script[1] = nSize; + memcpy(&script[2], &in[0], 32); + script[34] = OP_CHECKSIG; + return true; + case 0x04: + case 0x05: + unsigned char vch[33] = {}; + vch[0] = nSize - 2; + memcpy(&vch[1], &in[0], 32); + CPubKey pubkey(&vch[0], &vch[33]); + if (!pubkey.Decompress()) + return false; + assert(pubkey.size() == 65); + script.resize(67); + script[0] = 65; + memcpy(&script[1], pubkey.begin(), 65); + script[66] = OP_CHECKSIG; + return true; + } + return false; +} + +CScript GetScriptForDestination(const CTxDestination& dest) +{ + CScript script; + + boost::apply_visitor(CScriptVisitor(&script), dest); + return script; +} + +CScript GetScriptForMultisig(int nRequired, const std::vector& keys) +{ + CScript script; + + script << CScript::EncodeOP_N(nRequired); + BOOST_FOREACH(const CPubKey& key, keys) + script << ToByteVector(key); + script << CScript::EncodeOP_N(keys.size()) << OP_CHECKMULTISIG; + return script; +} + +bool CScript::IsNormalPaymentScript() const +{ + if(this->size() != 25) return false; + + std::string str; + opcodetype opcode; + const_iterator pc = begin(); + int i = 0; + while (pc < end()) + { + GetOp(pc, opcode); + + if( i == 0 && opcode != OP_DUP) return false; + else if(i == 1 && opcode != OP_HASH160) return false; + else if(i == 3 && opcode != OP_EQUALVERIFY) return false; + else if(i == 4 && opcode != OP_CHECKSIG) return false; + else if(i == 5) return false; + + i++; + } + + return true; +} + +std::string CScriptWitness::ToString() const +{ + std::string ret = "CScriptWitness("; + for (unsigned int i = 0; i < stack.size(); i++) { + if (i) { + ret += ", "; + } + ret += HexStr(stack[i]); + } + return ret + ")"; +} diff --git a/src/script.h b/src/script.h new file mode 100644 index 0000000..1b0e94d --- /dev/null +++ b/src/script.h @@ -0,0 +1,1085 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef H_BITCOIN_SCRIPT +#define H_BITCOIN_SCRIPT + +#include +#include + +#include + +#include +#include + +#include "keystore.h" +#include "bignum.h" +#include "util.h" +#include "stealth.h" + +typedef std::vector valtype; + +class CKeyStore; +class CTransaction; + +class BaseSignatureChecker; + +static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes +static const unsigned int MAX_OP_RETURN_RELAY = 40; // bytes + +template +std::vector ToByteVector(const T& in) +{ + return std::vector(in.begin(), in.end()); +} + +typedef enum ScriptError_t +{ + SCRIPT_ERR_OK = 0, + SCRIPT_ERR_UNKNOWN_ERROR, + SCRIPT_ERR_EVAL_FALSE, + SCRIPT_ERR_OP_RETURN, + + /* Max sizes */ + SCRIPT_ERR_SCRIPT_SIZE, + SCRIPT_ERR_PUSH_SIZE, + SCRIPT_ERR_OP_COUNT, + SCRIPT_ERR_STACK_SIZE, + SCRIPT_ERR_SIG_COUNT, + SCRIPT_ERR_PUBKEY_COUNT, + + /* Failed verify operations */ + SCRIPT_ERR_VERIFY, + SCRIPT_ERR_EQUALVERIFY, + SCRIPT_ERR_CHECKMULTISIGVERIFY, + SCRIPT_ERR_CHECKSIGVERIFY, + SCRIPT_ERR_NUMEQUALVERIFY, + + /* Logical/Format/Canonical errors */ + SCRIPT_ERR_BAD_OPCODE, + SCRIPT_ERR_DISABLED_OPCODE, + SCRIPT_ERR_INVALID_STACK_OPERATION, + SCRIPT_ERR_INVALID_ALTSTACK_OPERATION, + SCRIPT_ERR_UNBALANCED_CONDITIONAL, + + /* CHECKLOCKTIMEVERIFY and CHECKSEQUENCEVERIFY */ + SCRIPT_ERR_NEGATIVE_LOCKTIME, + SCRIPT_ERR_UNSATISFIED_LOCKTIME, + + /* Malleability */ + SCRIPT_ERR_SIG_HASHTYPE, + SCRIPT_ERR_SIG_DER, + SCRIPT_ERR_MINIMALDATA, + SCRIPT_ERR_SIG_PUSHONLY, + SCRIPT_ERR_SIG_HIGH_S, + SCRIPT_ERR_SIG_NULLDUMMY, + SCRIPT_ERR_PUBKEYTYPE, + SCRIPT_ERR_CLEANSTACK, + SCRIPT_ERR_MINIMALIF, + SCRIPT_ERR_SIG_NULLFAIL, + + /* softfork safeness */ + SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS, + SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM, + + /* segregated witness */ + SCRIPT_ERR_WITNESS_PROGRAM_WRONG_LENGTH, + SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY, + SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH, + SCRIPT_ERR_WITNESS_MALLEATED, + SCRIPT_ERR_WITNESS_MALLEATED_P2SH, + SCRIPT_ERR_WITNESS_UNEXPECTED, + SCRIPT_ERR_WITNESS_PUBKEYTYPE, + + SCRIPT_ERR_ERROR_COUNT +} ScriptError; + +#define SCRIPT_ERR_LAST SCRIPT_ERR_ERROR_COUNT + +const char* ScriptErrorString(const ScriptError error); + + +/** Signature hash types/flags */ +enum +{ + SIGHASH_ALL = 1, + SIGHASH_NONE = 2, + SIGHASH_SINGLE = 3, + SIGHASH_ANYONECANPAY = 0x80, +}; + +/** Script verification flags */ +enum +{ + SCRIPT_VERIFY_NONE = 0, + SCRIPT_VERIFY_NOCACHE = (1U << 0), + // Evaluate P2SH subscripts (softfork safe, BIP16). + SCRIPT_VERIFY_P2SH = (1U << 0), + + // Passing a non-strict-DER signature or one with undefined hashtype to a checksig operation causes script failure. + // Evaluating a pubkey that is not (0x04 + 64 bytes) or (0x02 or 0x03 + 32 bytes) by checksig causes script failure. + // (softfork safe, but not used or intended as a consensus rule). + SCRIPT_VERIFY_STRICTENC = (1U << 1), + + // Passing a non-strict-DER signature to a checksig operation causes script failure (softfork safe, BIP62 rule 1) + SCRIPT_VERIFY_DERSIG = (1U << 2), + + // Passing a non-strict-DER signature or one with S > order/2 to a checksig operation causes script failure + // (softfork safe, BIP62 rule 5). + SCRIPT_VERIFY_LOW_S = (1U << 3), + + // verify dummy stack item consumed by CHECKMULTISIG is of zero-length (softfork safe, BIP62 rule 7). + SCRIPT_VERIFY_NULLDUMMY = (1U << 4), + + // Using a non-push operator in the scriptSig causes script failure (softfork safe, BIP62 rule 2). + SCRIPT_VERIFY_SIGPUSHONLY = (1U << 5), + + // Require minimal encodings for all push operations (OP_0... OP_16, OP_1NEGATE where possible, direct + // pushes up to 75 bytes, OP_PUSHDATA up to 255 bytes, OP_PUSHDATA2 for anything larger). Evaluating + // any other push causes the script to fail (BIP62 rule 3). + // In addition, whenever a stack element is interpreted as a number, it must be of minimal length (BIP62 rule 4). + // (softfork safe) + SCRIPT_VERIFY_MINIMALDATA = (1U << 6), + + // Discourage use of NOPs reserved for upgrades (NOP1-10) + // + // Provided so that nodes can avoid accepting or mining transactions + // containing executed NOP's whose meaning may change after a soft-fork, + // thus rendering the script invalid; with this flag set executing + // discouraged NOPs fails the script. This verification flag will never be + // a mandatory flag applied to scripts in a block. NOPs that are not + // executed, e.g. within an unexecuted IF ENDIF block, are *not* rejected. + SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS = (1U << 7), + + // Require that only a single stack element remains after evaluation. This changes the success criterion from + // "At least one stack element must remain, and when interpreted as a boolean, it must be true" to + // "Exactly one stack element must remain, and when interpreted as a boolean, it must be true". + // (softfork safe, BIP62 rule 6) + // Note: CLEANSTACK should never be used without P2SH or WITNESS. + SCRIPT_VERIFY_CLEANSTACK = (1U << 8), + + // Verify CHECKLOCKTIMEVERIFY + // + // See BIP65 for details. + SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9), + + // support CHECKSEQUENCEVERIFY opcode + // + // See BIP112 for details + SCRIPT_VERIFY_CHECKSEQUENCEVERIFY = (1U << 10), + + // Support segregated witness + // + SCRIPT_VERIFY_WITNESS = (1U << 11), + + // Making v1-v16 witness program non-standard + // + SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM = (1U << 12), + + // Segwit script only: Require the argument of OP_IF/NOTIF to be exactly 0x01 or empty vector + // + SCRIPT_VERIFY_MINIMALIF = (1U << 13), + + // Signature(s) must be empty vector if an CHECK(MULTI)SIG operation failed + // + SCRIPT_VERIFY_NULLFAIL = (1U << 14), + + // Public keys in segregated witness scripts must be compressed + // + SCRIPT_VERIFY_WITNESS_PUBKEYTYPE = (1U << 15), + + // Performs the compiled byte code + // + SCRIPT_EXEC_BYTE_CODE = (1U << 30), +}; + +// Mandatory script verification flags that all new blocks must comply with for +// them to be valid. (but old blocks may not comply with) +// +// Failing one of these tests may trigger a DoS ban - see ConnectInputs() for +// details. +static const unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_NONE; + +// Standard script verification flags that standard transactions will comply +// with. However scripts violating these flags may still be present in valid +// blocks and we must accept those blocks. +static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY_FLAGS | + SCRIPT_VERIFY_STRICTENC | + SCRIPT_VERIFY_NULLDUMMY | + SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS; + +// For convenience, standard but not mandatory verify flags. +static const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS; + +enum txnouttype +{ + TX_NONSTANDARD, + // 'standard' transaction types: + TX_PUBKEY, + TX_PUBKEYHASH, + TX_SCRIPTHASH, + TX_MULTISIG, + TX_NULL_DATA, + TX_WITNESS_V0_SCRIPTHASH, + TX_WITNESS_V0_KEYHASH, + TX_CREATE, + TX_CALL, +}; + +struct CScriptWitness +{ + // Note that this encodes the data elements being pushed, rather than + // encoding them as a CScript that pushes them. + std::vector > stack; + + // Some compilers complain without a default constructor + CScriptWitness() { } + + bool IsNull() const { return stack.empty(); } + + void SetNull() { + stack.clear(); +// stack.shrink_to_fit(); + std::vector >(stack).swap(stack); + } + + std::string ToString() const; +}; + +class CNoDestination { +public: + friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; } + friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; } +}; + +/** A txout script template with a specific destination. It is either: + * * CNoDestination: no destination set + * * CKeyID: TX_PUBKEYHASH destination + * * CScriptID: TX_SCRIPTHASH destination + * A CTxDestination is the internal data type encoded in a CBitcoinAddress + */ +typedef boost::variant CTxDestination; + +const char* GetTxnOutputType(txnouttype t); + +/** Script opcodes */ +enum opcodetype +{ + // push value + OP_0 = 0x00, + OP_FALSE = OP_0, + OP_PUSHDATA1 = 0x4c, + OP_PUSHDATA2 = 0x4d, + OP_PUSHDATA4 = 0x4e, + OP_1NEGATE = 0x4f, + OP_RESERVED = 0x50, + OP_1 = 0x51, + OP_TRUE=OP_1, + OP_2 = 0x52, + OP_3 = 0x53, + OP_4 = 0x54, + OP_5 = 0x55, + OP_6 = 0x56, + OP_7 = 0x57, + OP_8 = 0x58, + OP_9 = 0x59, + OP_10 = 0x5a, + OP_11 = 0x5b, + OP_12 = 0x5c, + OP_13 = 0x5d, + OP_14 = 0x5e, + OP_15 = 0x5f, + OP_16 = 0x60, + + // control + OP_NOP = 0x61, + OP_VER = 0x62, + OP_IF = 0x63, + OP_NOTIF = 0x64, + OP_VERIF = 0x65, + OP_VERNOTIF = 0x66, + OP_ELSE = 0x67, + OP_ENDIF = 0x68, + OP_VERIFY = 0x69, + OP_RETURN = 0x6a, + + // stack ops + OP_TOALTSTACK = 0x6b, + OP_FROMALTSTACK = 0x6c, + OP_2DROP = 0x6d, + OP_2DUP = 0x6e, + OP_3DUP = 0x6f, + OP_2OVER = 0x70, + OP_2ROT = 0x71, + OP_2SWAP = 0x72, + OP_IFDUP = 0x73, + OP_DEPTH = 0x74, + OP_DROP = 0x75, + OP_DUP = 0x76, + OP_NIP = 0x77, + OP_OVER = 0x78, + OP_PICK = 0x79, + OP_ROLL = 0x7a, + OP_ROT = 0x7b, + OP_SWAP = 0x7c, + OP_TUCK = 0x7d, + + // splice ops + OP_CAT = 0x7e, + OP_SUBSTR = 0x7f, + OP_LEFT = 0x80, + OP_RIGHT = 0x81, + OP_SIZE = 0x82, + + // bit logic + OP_INVERT = 0x83, + OP_AND = 0x84, + OP_OR = 0x85, + OP_XOR = 0x86, + OP_EQUAL = 0x87, + OP_EQUALVERIFY = 0x88, + OP_RESERVED1 = 0x89, + OP_RESERVED2 = 0x8a, + + // numeric + OP_1ADD = 0x8b, + OP_1SUB = 0x8c, + OP_2MUL = 0x8d, + OP_2DIV = 0x8e, + OP_NEGATE = 0x8f, + OP_ABS = 0x90, + OP_NOT = 0x91, + OP_0NOTEQUAL = 0x92, + + OP_ADD = 0x93, + OP_SUB = 0x94, + OP_MUL = 0x95, + OP_DIV = 0x96, + OP_MOD = 0x97, + OP_LSHIFT = 0x98, + OP_RSHIFT = 0x99, + + OP_BOOLAND = 0x9a, + OP_BOOLOR = 0x9b, + OP_NUMEQUAL = 0x9c, + OP_NUMEQUALVERIFY = 0x9d, + OP_NUMNOTEQUAL = 0x9e, + OP_LESSTHAN = 0x9f, + OP_GREATERTHAN = 0xa0, + OP_LESSTHANOREQUAL = 0xa1, + OP_GREATERTHANOREQUAL = 0xa2, + OP_MIN = 0xa3, + OP_MAX = 0xa4, + + OP_WITHIN = 0xa5, + + // crypto + OP_RIPEMD160 = 0xa6, + OP_SHA1 = 0xa7, + OP_SHA256 = 0xa8, + OP_HASH160 = 0xa9, + OP_HASH256 = 0xaa, + OP_CODESEPARATOR = 0xab, + OP_CHECKSIG = 0xac, + OP_CHECKSIGVERIFY = 0xad, + OP_CHECKMULTISIG = 0xae, + OP_CHECKMULTISIGVERIFY = 0xaf, + + // expansion + OP_NOP1 = 0xb0, + OP_CHECKLOCKTIMEVERIFY = 0xb1, + OP_NOP2 = OP_CHECKLOCKTIMEVERIFY, + OP_CHECKSEQUENCEVERIFY = 0xb2, + OP_NOP3 = OP_CHECKSEQUENCEVERIFY, + OP_NOP4 = 0xb3, + OP_NOP5 = 0xb4, + OP_NOP6 = 0xb5, + OP_NOP7 = 0xb6, + OP_NOP8 = 0xb7, + OP_NOP9 = 0xb8, + OP_NOP10 = 0xb9, + + + + // template matching params + OP_SMALLDATA = 0xf9, + OP_SMALLINTEGER = 0xfa, + OP_PUBKEYS = 0xfb, + OP_PUBKEYHASH = 0xfd, + OP_PUBKEY = 0xfe, + + OP_INVALIDOPCODE = 0xff, +}; + +const char* GetOpName(opcodetype opcode); + + + +inline std::string ValueString(const std::vector& vch) +{ + if (vch.size() <= 4) + return strprintf("%d", CBigNum(vch).getint()); + else + return HexStr(vch); +} + +inline std::string StackString(const std::vector >& vStack) +{ + std::string str; + BOOST_FOREACH(const std::vector& vch, vStack) + { + if (!str.empty()) + str += " "; + str += ValueString(vch); + } + return str; +} + +class scriptnum_error : public std::runtime_error +{ +public: + explicit scriptnum_error(const std::string& str) : std::runtime_error(str) {} +}; + +class CScriptNum +{ +/** + * Numeric opcodes (OP_1ADD, etc) are restricted to operating on 4-byte integers. + * The semantics are subtle, though: operands must be in the range [-2^31 +1...2^31 -1], + * but results may overflow (and are valid as long as they are not used in a subsequent + * numeric operation). CScriptNum enforces those semantics by storing results as + * an int64 and allowing out-of-range values to be returned as a vector of bytes but + * throwing an exception if arithmetic is done or the result is interpreted as an integer. + */ +public: + + explicit CScriptNum(const int64_t& n) + { + m_value = n; + } + + explicit CScriptNum(const std::vector& vch, bool fRequireMinimal) + { + if (vch.size() > nMaxNumSize) { + throw scriptnum_error("script number overflow"); + } + if (fRequireMinimal && vch.size() > 0) { + // Check that the number is encoded with the minimum possible + // number of bytes. + // + // If the most-significant-byte - excluding the sign bit - is zero + // then we're not minimal. Note how this test also rejects the + // negative-zero encoding, 0x80. + if ((vch.back() & 0x7f) == 0) { + // One exception: if there's more than one byte and the most + // significant bit of the second-most-significant-byte is set + // it would conflict with the sign bit. An example of this case + // is +-255, which encode to 0xff00 and 0xff80 respectively. + // (big-endian). + if (vch.size() <= 1 || (vch[vch.size() - 2] & 0x80) == 0) { + throw scriptnum_error("non-minimally encoded script number"); + } + } + } + m_value = set_vch(vch); + } + + inline bool operator==(const int64_t& rhs) const { return m_value == rhs; } + inline bool operator!=(const int64_t& rhs) const { return m_value != rhs; } + inline bool operator<=(const int64_t& rhs) const { return m_value <= rhs; } + inline bool operator< (const int64_t& rhs) const { return m_value < rhs; } + inline bool operator>=(const int64_t& rhs) const { return m_value >= rhs; } + inline bool operator> (const int64_t& rhs) const { return m_value > rhs; } + + inline bool operator==(const CScriptNum& rhs) const { return operator==(rhs.m_value); } + inline bool operator!=(const CScriptNum& rhs) const { return operator!=(rhs.m_value); } + inline bool operator<=(const CScriptNum& rhs) const { return operator<=(rhs.m_value); } + inline bool operator< (const CScriptNum& rhs) const { return operator< (rhs.m_value); } + inline bool operator>=(const CScriptNum& rhs) const { return operator>=(rhs.m_value); } + inline bool operator> (const CScriptNum& rhs) const { return operator> (rhs.m_value); } + + inline CScriptNum operator+( const int64_t& rhs) const { return CScriptNum(m_value + rhs);} + inline CScriptNum operator-( const int64_t& rhs) const { return CScriptNum(m_value - rhs);} + inline CScriptNum operator+( const CScriptNum& rhs) const { return operator+(rhs.m_value); } + inline CScriptNum operator-( const CScriptNum& rhs) const { return operator-(rhs.m_value); } + + inline CScriptNum& operator+=( const CScriptNum& rhs) { return operator+=(rhs.m_value); } + inline CScriptNum& operator-=( const CScriptNum& rhs) { return operator-=(rhs.m_value); } + + inline CScriptNum operator-() const + { + assert(m_value != std::numeric_limits::min()); + return CScriptNum(-m_value); + } + + inline CScriptNum& operator=( const int64_t& rhs) + { + m_value = rhs; + return *this; + } + + inline CScriptNum& operator+=( const int64_t& rhs) + { + assert(rhs == 0 || (rhs > 0 && m_value <= std::numeric_limits::max() - rhs) || + (rhs < 0 && m_value >= std::numeric_limits::min() - rhs)); + m_value += rhs; + return *this; + } + + inline CScriptNum& operator-=( const int64_t& rhs) + { + assert(rhs == 0 || (rhs > 0 && m_value >= std::numeric_limits::min() + rhs) || + (rhs < 0 && m_value <= std::numeric_limits::max() + rhs)); + m_value -= rhs; + return *this; + } + + int getint() const + { + if (m_value > std::numeric_limits::max()) + return std::numeric_limits::max(); + else if (m_value < std::numeric_limits::min()) + return std::numeric_limits::min(); + return m_value; + } + + std::vector getvch() const + { + return serialize(m_value); + } + + static std::vector serialize(const int64_t& value) + { + if(value == 0) + return std::vector(); + + std::vector result; + const bool neg = value < 0; + uint64_t absvalue = neg ? -value : value; + + while(absvalue) + { + result.push_back(absvalue & 0xff); + absvalue >>= 8; + } + +// - If the most significant byte is >= 0x80 and the value is positive, push a +// new zero-byte to make the significant byte < 0x80 again. + +// - If the most significant byte is >= 0x80 and the value is negative, push a +// new 0x80 byte that will be popped off when converting to an integral. + +// - If the most significant byte is < 0x80 and the value is negative, add +// 0x80 to it, since it will be subtracted and interpreted as a negative when +// converting to an integral. + + if (result.back() & 0x80) + result.push_back(neg ? 0x80 : 0); + else if (neg) + result.back() |= 0x80; + + return result; + } + + static const size_t nMaxNumSize = 4; + +private: + static int64_t set_vch(const std::vector& vch) + { + if (vch.empty()) + return 0; + + int64_t result = 0; + for (size_t i = 0; i != vch.size(); ++i) + result |= static_cast(vch[i]) << 8*i; + + // If the input vector's most significant byte is 0x80, remove it from + // the result's msb and return a negative. + if (vch.back() & 0x80) + return -((int64_t)(result & ~(0x80ULL << (8 * (vch.size() - 1))))); + + return result; + } + + int64_t m_value; +}; + + + + +/** Serialized script, used inside transaction inputs and outputs */ +class CScript : public std::vector +{ +protected: + CScript& push_int64(int64_t n) + { + if (n == -1 || (n >= 1 && n <= 16)) + { + push_back(n + (OP_1 - 1)); + } + else + { + CBigNum bn(n); + *this << bn.getvch(); + } + return *this; + } + + CScript& push_uint64(uint64_t n) + { + if (n >= 1 && n <= 16) + { + push_back(n + (OP_1 - 1)); + } + else + { + CBigNum bn(n); + *this << bn.getvch(); + } + return *this; + } + +public: + CScript() { } + CScript(const CScript& b) : std::vector(b.begin(), b.end()) { } + CScript(const_iterator pbegin, const_iterator pend) : std::vector(pbegin, pend) { } +#ifndef _MSC_VER + CScript(const unsigned char* pbegin, const unsigned char* pend) : std::vector(pbegin, pend) { } +#endif + + CScript& operator+=(const CScript& b) + { + insert(end(), b.begin(), b.end()); + return *this; + } + + friend CScript operator+(const CScript& a, const CScript& b) + { + CScript ret = a; + ret += b; + return ret; + } + + + //explicit CScript(char b) is not portable. Use 'signed char' or 'unsigned char'. + explicit CScript(signed char b) { operator<<(b); } + explicit CScript(short b) { operator<<(b); } + explicit CScript(int b) { operator<<(b); } + explicit CScript(long b) { operator<<(b); } + explicit CScript(long long b) { operator<<(b); } + explicit CScript(unsigned char b) { operator<<(b); } + explicit CScript(unsigned int b) { operator<<(b); } + explicit CScript(unsigned short b) { operator<<(b); } + explicit CScript(unsigned long b) { operator<<(b); } + explicit CScript(unsigned long long b) { operator<<(b); } + + explicit CScript(opcodetype b) { operator<<(b); } + explicit CScript(const uint256& b) { operator<<(b); } + explicit CScript(const CBigNum& b) { operator<<(b); } + explicit CScript(const std::vector& b) { operator<<(b); } + + + //CScript& operator<<(char b) is not portable. Use 'signed char' or 'unsigned char'. + CScript& operator<<(signed char b) { return push_int64(b); } + CScript& operator<<(short b) { return push_int64(b); } + CScript& operator<<(int b) { return push_int64(b); } + CScript& operator<<(long b) { return push_int64(b); } + CScript& operator<<(long long b) { return push_int64(b); } + CScript& operator<<(unsigned char b) { return push_uint64(b); } + CScript& operator<<(unsigned int b) { return push_uint64(b); } + CScript& operator<<(unsigned short b) { return push_uint64(b); } + CScript& operator<<(unsigned long b) { return push_uint64(b); } + CScript& operator<<(unsigned long long b) { return push_uint64(b); } + + CScript& operator<<(opcodetype opcode) + { + if (opcode < 0 || opcode > 0xff) + throw std::runtime_error("CScript::operator<<() : invalid opcode"); + insert(end(), (unsigned char)opcode); + return *this; + } + + CScript& operator<<(const uint160& b) + { + insert(end(), sizeof(b)); + insert(end(), (unsigned char*)&b, (unsigned char*)&b + sizeof(b)); + return *this; + } + + CScript& operator<<(const uint256& b) + { + insert(end(), sizeof(b)); + insert(end(), (unsigned char*)&b, (unsigned char*)&b + sizeof(b)); + return *this; + } + + CScript& operator<<(const CPubKey& key) + { + assert(key.size() < OP_PUSHDATA1); + insert(end(), (unsigned char)key.size()); + insert(end(), key.begin(), key.end()); + return *this; + } + + CScript& operator<<(const CBigNum& b) + { + *this << b.getvch(); + return *this; + } + + CScript& operator<<(const std::vector& b) + { + if (b.size() < OP_PUSHDATA1) + { + insert(end(), (unsigned char)b.size()); + } + else if (b.size() <= 0xff) + { + insert(end(), OP_PUSHDATA1); + insert(end(), (unsigned char)b.size()); + } + else if (b.size() <= 0xffff) + { + insert(end(), OP_PUSHDATA2); + unsigned short nSize = b.size(); + insert(end(), (unsigned char*)&nSize, (unsigned char*)&nSize + sizeof(nSize)); + } + else + { + insert(end(), OP_PUSHDATA4); + unsigned int nSize = b.size(); + insert(end(), (unsigned char*)&nSize, (unsigned char*)&nSize + sizeof(nSize)); + } + insert(end(), b.begin(), b.end()); + return *this; + } + + CScript& operator<<(const CScript& b) + { + // I'm not sure if this should push the script or concatenate scripts. + // If there's ever a use for pushing a script onto a script, delete this member fn + assert(!"Warning: Pushing a CScript onto a CScript with << is probably not intended, use + to concatenate!"); + return *this; + } + + + bool GetOp(iterator& pc, opcodetype& opcodeRet, std::vector& vchRet) + { + // Wrapper so it can be called with either iterator or const_iterator + const_iterator pc2 = pc; + bool fRet = GetOp2(pc2, opcodeRet, &vchRet); + pc = begin() + (pc2 - begin()); + return fRet; + } + + bool GetOp(iterator& pc, opcodetype& opcodeRet) + { + const_iterator pc2 = pc; + bool fRet = GetOp2(pc2, opcodeRet, NULL); + pc = begin() + (pc2 - begin()); + return fRet; + } + + bool GetOp(const_iterator& pc, opcodetype& opcodeRet, std::vector& vchRet) const + { + return GetOp2(pc, opcodeRet, &vchRet); + } + + bool GetOp(const_iterator& pc, opcodetype& opcodeRet) const + { + return GetOp2(pc, opcodeRet, NULL); + } + + bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector* pvchRet) const + { + opcodeRet = OP_INVALIDOPCODE; + if (pvchRet) + pvchRet->clear(); + if (pc >= end()) + return false; + + // Read instruction + if (end() - pc < 1) + return false; + unsigned int opcode = *pc++; + + // Immediate operand + if (opcode <= OP_PUSHDATA4) + { + unsigned int nSize; + if (opcode < OP_PUSHDATA1) + { + nSize = opcode; + } + else if (opcode == OP_PUSHDATA1) + { + if (end() - pc < 1) + return false; + nSize = *pc++; + } + else if (opcode == OP_PUSHDATA2) + { + if (end() - pc < 2) + return false; + nSize = 0; + memcpy(&nSize, &pc[0], 2); + pc += 2; + } + else if (opcode == OP_PUSHDATA4) + { + if (end() - pc < 4) + return false; + memcpy(&nSize, &pc[0], 4); + pc += 4; + } + if (end() - pc < 0 || (unsigned int)(end() - pc) < nSize) + return false; + if (pvchRet) + pvchRet->assign(pc, pc + nSize); + pc += nSize; + } + + opcodeRet = (opcodetype)opcode; + return true; + } + + // Encode/decode small integers: + static int DecodeOP_N(opcodetype opcode) + { + if (opcode == OP_0) + return 0; + assert(opcode >= OP_1 && opcode <= OP_16); + return (int)opcode - (int)(OP_1 - 1); + } + static opcodetype EncodeOP_N(int n) + { + assert(n >= 0 && n <= 16); + if (n == 0) + return OP_0; + return (opcodetype)(OP_1+n-1); + } + + int FindAndDelete(const CScript& b) + { + int nFound = 0; + if (b.empty()) + return nFound; + iterator pc = begin(); + opcodetype opcode; + do + { + while (end() - pc >= (long)b.size() && memcmp(&pc[0], &b[0], b.size()) == 0) + { + erase(pc, pc + b.size()); + ++nFound; + } + } + while (GetOp(pc, opcode)); + return nFound; + } + int Find(opcodetype op) const + { + int nFound = 0; + opcodetype opcode; + for (const_iterator pc = begin(); pc != end() && GetOp(pc, opcode);) + if (opcode == op) + ++nFound; + return nFound; + } + + // Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs + // as 20 sigops. With pay-to-script-hash, that changed: + // CHECKMULTISIGs serialized in scriptSigs are + // counted more accurately, assuming they are of the form + // ... OP_N CHECKMULTISIG ... + unsigned int GetSigOpCount(bool fAccurate) const; + + // Accurately count sigOps, including sigOps in + // pay-to-script-hash transactions: + unsigned int GetSigOpCount(const CScript& scriptSig) const; + bool IsNormalPaymentScript() const; + bool IsPayToScriptHash() const; + + bool IsPayToWitnessScriptHash() const; + bool IsWitnessProgram(int& version, std::vector& program) const; + + // Called by IsStandardTx and P2SH VerifyScript (which makes it consensus-critical). + bool IsPushOnly(const_iterator pc) const; + bool IsPushOnly() const; + + // Called by IsStandardTx. + bool HasCanonicalPushes() const; + + void SetDestination(const CTxDestination& address); + void SetMultisig(int nRequired, const std::vector& keys); + + std::string ToString(bool fShort=false) const + { + std::string str; + opcodetype opcode; + std::vector vch; + const_iterator pc = begin(); + while (pc < end()) + { + if (!str.empty()) + str += " "; + if (!GetOp(pc, opcode, vch)) + { + str += "[error]"; + return str; + } + if (0 <= opcode && opcode <= OP_PUSHDATA4) + str += fShort? ValueString(vch).substr(0, 10) : ValueString(vch); + else + str += GetOpName(opcode); + } + return str; + } + + CScriptID GetID() const + { + return CScriptID(Hash160(*this)); + } + + void clear() + { + // The default std::vector::clear() does not release memory. + std::vector().swap(*this); + } +}; + +/** Compact serializer for scripts. + * + * It detects common cases and encodes them much more efficiently. + * 3 special cases are defined: + * * Pay to pubkey hash (encoded as 21 bytes) + * * Pay to script hash (encoded as 21 bytes) + * * Pay to pubkey starting with 0x02, 0x03 or 0x04 (encoded as 33 bytes) + * + * Other scripts up to 121 bytes require 1 byte + script length. Above + * that, scripts up to 16505 bytes require 2 bytes + script length. + */ +class CScriptCompressor +{ +private: + // make this static for now (there are only 6 special scripts defined) + // this can potentially be extended together with a new nVersion for + // transactions, in which case this value becomes dependent on nVersion + // and nHeight of the enclosing transaction. + static const unsigned int nSpecialScripts = 6; + + CScript &script; +protected: + // These check for scripts for which a special case with a shorter encoding is defined. + // They are implemented separately from the CScript test, as these test for exact byte + // sequence correspondences, and are more strict. For example, IsToPubKey also verifies + // whether the public key is valid (as invalid ones cannot be represented in compressed + // form). + bool IsToKeyID(CKeyID &hash) const; + bool IsToScriptID(CScriptID &hash) const; + bool IsToPubKey(CPubKey &pubkey) const; + + bool Compress(std::vector &out) const; + unsigned int GetSpecialSize(unsigned int nSize) const; + bool Decompress(unsigned int nSize, const std::vector &out); +public: + CScriptCompressor(CScript &scriptIn) : script(scriptIn) { } + + unsigned int GetSerializeSize(int nType, int nVersion) const { + std::vector compr; + if (Compress(compr)) + return compr.size(); + unsigned int nSize = script.size() + nSpecialScripts; + return script.size() + VARINT(nSize).GetSerializeSize(nType, nVersion); + } + + template + void Serialize(Stream &s, int nType, int nVersion) const { + std::vector compr; + if (Compress(compr)) { + s << CFlatData(&compr[0], &compr[compr.size()]); + return; + } + unsigned int nSize = script.size() + nSpecialScripts; + s << VARINT(nSize); + s << CFlatData(&script[0], &script[script.size()]); + } + + template + void Unserialize(Stream &s, int nType, int nVersion) { + unsigned int nSize; + s >> VARINT(nSize); + if (nSize < nSpecialScripts) { + std::vector vch(GetSpecialSize(nSize), 0x00); + s >> REF(CFlatData(&vch[0], &vch[vch.size()])); + Decompress(nSize, vch); + return; + } + nSize -= nSpecialScripts; + script.resize(nSize); + s >> REF(CFlatData(&script[0], &script[script.size()])); + } +}; + + +bool IsDERSignature(const valtype &vchSig, bool haveHashType = true); +bool EvalScript(std::vector >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType); +bool EvalScript(std::vector >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, ScriptError* error = NULL); +bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector >& vSolutionsRet); +int ScriptSigArgsExpected(txnouttype t, const std::vector >& vSolutions); +bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType); +bool IsMine(const CKeyStore& keystore, const CScript& scriptPubKey); +bool IsMine(const CKeyStore& keystore, const CTxDestination &dest); +void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, std::vector &vKeys); +bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet); +bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector& addressRet, int& nRequiredRet); +bool SignSignature(const CKeyStore& keystore, const CScript& fromPubKey, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL); +bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL); +bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType); +bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType); + +bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, unsigned int flags, const BaseSignatureChecker& checker, ScriptError* error = NULL); + + +size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness* witness, unsigned int flags); + +// Given two sets of signatures for scriptPubKey, possibly with OP_0 placeholders, +// combine them intelligently and return the result. +CScript CombineSignatures(CScript scriptPubKey, const CTransaction& txTo, unsigned int nIn, const CScript& scriptSig1, const CScript& scriptSig2); + +CScript GetScriptForDestination(const CTxDestination& dest); +CScript GetScriptForMultisig(int nRequired, const std::vector& keys); + +bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash, int nHashType, + CScript& scriptSigRet, txnouttype& whichTypeRet); +//uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType); + + +class BaseSignatureChecker +{ +public: + virtual bool CheckSig(const std::vector& scriptSig, const std::vector& vchPubKey, const CScript& scriptCode) const + { + return false; + } + + virtual ~BaseSignatureChecker() {} +}; + +class SignatureChecker : public BaseSignatureChecker +{ +private: + const CTransaction& txTo; + unsigned int nIn; + +protected: + virtual bool VerifySignature(const std::vector& vchSig, const CPubKey& vchPubKey, const uint256& sighash) const; + +public: + SignatureChecker(const CTransaction& txToIn, unsigned int nInIn) : txTo(txToIn), nIn(nInIn) {} + bool CheckSig(const std::vector& scriptSig, const std::vector& vchPubKey, const CScript& scriptCode) const; +}; + +#endif diff --git a/src/scrypt-arm.S b/src/scrypt-arm.S new file mode 100644 index 0000000..143eb3a --- /dev/null +++ b/src/scrypt-arm.S @@ -0,0 +1,555 @@ +/* + * Copyright 2012 pooler@litecoinpool.org + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. See COPYING for more details. + */ + + +#if defined(OPTIMIZED_SALSA) && defined(__arm__) && defined(__APCS_32__) + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif + +#if defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \ + defined(__ARM_ARCH_5TEJ__) || defined(__ARM_ARCH_6__) || \ + defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || \ + defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_6T2__) || \ + defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) +#define __ARM_ARCH_5E_OR_6__ +#endif + +#if defined(__ARM_ARCH_5E_OR_6__) || defined(__ARM_ARCH_7__) || \ + defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || \ + defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) +#define __ARM_ARCH_5E_OR_6_OR_7__ +#endif + +#ifdef __ARM_ARCH_5E_OR_6__ + +#define scrypt_shuffle() \ + add lr, r0, #9*4; \ + ldmia r0, {r2-r7}; \ + ldmia lr, {r2, r8-r12, lr}; \ + str r3, [r0, #5*4]; \ + str r5, [r0, #15*4]; \ + str r6, [r0, #12*4]; \ + str r7, [r0, #1*4]; \ + ldr r5, [r0, #7*4]; \ + str r2, [r0, #13*4]; \ + str r8, [r0, #2*4]; \ + strd r4, [r0, #10*4]; \ + str r9, [r0, #7*4]; \ + str r10, [r0, #4*4]; \ + str r11, [r0, #9*4]; \ + str lr, [r0, #3*4]; \ + add r2, r0, #64+0*4; \ + add lr, r0, #64+9*4; \ + ldmia r2, {r2-r7}; \ + ldmia lr, {r2, r8-r12, lr}; \ + str r3, [r0, #64+5*4]; \ + str r5, [r0, #64+15*4]; \ + str r6, [r0, #64+12*4]; \ + str r7, [r0, #64+1*4]; \ + ldr r5, [r0, #64+7*4]; \ + str r2, [r0, #64+13*4]; \ + str r8, [r0, #64+2*4]; \ + strd r4, [r0, #64+10*4]; \ + str r9, [r0, #64+7*4]; \ + str r10, [r0, #64+4*4]; \ + str r11, [r0, #64+9*4]; \ + str lr, [r0, #64+3*4]; \ + + +#define salsa8_core_doubleround_body() \ + add r6, r2, r6; \ + add r7, r3, r7; \ + eor r10, r10, r6, ror #25; \ + add r6, r0, r4; \ + eor r11, r11, r7, ror #25; \ + add r7, r1, r5; \ + strd r10, [sp, #14*4]; \ + eor r12, r12, r6, ror #25; \ + eor lr, lr, r7, ror #25; \ + ldrd r6, [sp, #10*4]; \ + add r2, r10, r2; \ + add r3, r11, r3; \ + eor r6, r6, r2, ror #23; \ + add r2, r12, r0; \ + eor r7, r7, r3, ror #23; \ + add r3, lr, r1; \ + strd r6, [sp, #10*4]; \ + eor r8, r8, r2, ror #23; \ + eor r9, r9, r3, ror #23; \ + ldrd r2, [sp, #6*4]; \ + add r10, r6, r10; \ + add r11, r7, r11; \ + eor r2, r2, r10, ror #19; \ + add r10, r8, r12; \ + eor r3, r3, r11, ror #19; \ + add r11, r9, lr; \ + eor r4, r4, r10, ror #19; \ + eor r5, r5, r11, ror #19; \ + ldrd r10, [sp, #2*4]; \ + add r6, r2, r6; \ + add r7, r3, r7; \ + eor r10, r10, r6, ror #14; \ + add r6, r4, r8; \ + eor r11, r11, r7, ror #14; \ + add r7, r5, r9; \ + eor r0, r0, r6, ror #14; \ + eor r1, r1, r7, ror #14; \ + ldrd r6, [sp, #14*4]; \ + strd r2, [sp, #6*4]; \ + strd r10, [sp, #2*4]; \ + add r6, r11, r6; \ + add r7, r0, r7; \ + eor r4, r4, r6, ror #25; \ + add r6, r1, r12; \ + eor r5, r5, r7, ror #25; \ + add r7, r10, lr; \ + eor r2, r2, r6, ror #25; \ + eor r3, r3, r7, ror #25; \ + strd r2, [sp, #6*4]; \ + add r10, r3, r10; \ + ldrd r6, [sp, #10*4]; \ + add r11, r4, r11; \ + eor r8, r8, r10, ror #23; \ + add r10, r5, r0; \ + eor r9, r9, r11, ror #23; \ + add r11, r2, r1; \ + eor r6, r6, r10, ror #23; \ + eor r7, r7, r11, ror #23; \ + strd r6, [sp, #10*4]; \ + add r2, r7, r2; \ + ldrd r10, [sp, #14*4]; \ + add r3, r8, r3; \ + eor r12, r12, r2, ror #19; \ + add r2, r9, r4; \ + eor lr, lr, r3, ror #19; \ + add r3, r6, r5; \ + eor r10, r10, r2, ror #19; \ + eor r11, r11, r3, ror #19; \ + ldrd r2, [sp, #2*4]; \ + add r6, r11, r6; \ + add r7, r12, r7; \ + eor r0, r0, r6, ror #14; \ + add r6, lr, r8; \ + eor r1, r1, r7, ror #14; \ + add r7, r10, r9; \ + eor r2, r2, r6, ror #14; \ + eor r3, r3, r7, ror #14; \ + + +#define salsa8_core() \ + ldmia sp, {r0-r12, lr}; \ + ldrd r10, [sp, #14*4]; \ + salsa8_core_doubleround_body(); \ + ldrd r6, [sp, #6*4]; \ + strd r2, [sp, #2*4]; \ + strd r10, [sp, #14*4]; \ + salsa8_core_doubleround_body(); \ + ldrd r6, [sp, #6*4]; \ + strd r2, [sp, #2*4]; \ + strd r10, [sp, #14*4]; \ + salsa8_core_doubleround_body(); \ + ldrd r6, [sp, #6*4]; \ + strd r2, [sp, #2*4]; \ + strd r10, [sp, #14*4]; \ + salsa8_core_doubleround_body(); \ + stmia sp, {r0-r5}; \ + strd r8, [sp, #8*4]; \ + str r12, [sp, #12*4]; \ + str lr, [sp, #13*4]; \ + strd r10, [sp, #14*4]; \ + + +#else + +#define scrypt_shuffle() \ + + +#define salsa8_core_doubleround_body() \ + ldr r8, [sp, #8*4]; \ + add r11, r11, r10; \ + ldr lr, [sp, #13*4]; \ + add r12, r12, r3; \ + eor r2, r2, r11, ror #23; \ + add r11, r4, r0; \ + eor r7, r7, r12, ror #23; \ + add r12, r9, r5; \ + str r9, [sp, #9*4]; \ + eor r8, r8, r11, ror #23; \ + str r10, [sp, #14*4]; \ + eor lr, lr, r12, ror #23; \ + ldr r11, [sp, #11*4]; \ + add r9, lr, r9; \ + ldr r12, [sp, #12*4]; \ + add r10, r2, r10; \ + eor r1, r1, r9, ror #19; \ + add r9, r7, r3; \ + eor r6, r6, r10, ror #19; \ + add r10, r8, r4; \ + str r8, [sp, #8*4]; \ + eor r11, r11, r9, ror #19; \ + str lr, [sp, #13*4]; \ + eor r12, r12, r10, ror #19; \ + ldr r9, [sp, #10*4]; \ + add r8, r12, r8; \ + ldr r10, [sp, #15*4]; \ + add lr, r1, lr; \ + eor r0, r0, r8, ror #14; \ + add r8, r6, r2; \ + eor r5, r5, lr, ror #14; \ + add lr, r11, r7; \ + eor r9, r9, r8, ror #14; \ + ldr r8, [sp, #9*4]; \ + eor r10, r10, lr, ror #14; \ + ldr lr, [sp, #14*4]; \ + add r8, r9, r8; \ + str r9, [sp, #10*4]; \ + add lr, r10, lr; \ + str r10, [sp, #15*4]; \ + eor r11, r11, r8, ror #25; \ + add r8, r0, r3; \ + eor r12, r12, lr, ror #25; \ + add lr, r5, r4; \ + eor r1, r1, r8, ror #25; \ + ldr r8, [sp, #8*4]; \ + eor r6, r6, lr, ror #25; \ + add r9, r11, r9; \ + ldr lr, [sp, #13*4]; \ + add r10, r12, r10; \ + eor r8, r8, r9, ror #23; \ + add r9, r1, r0; \ + eor lr, lr, r10, ror #23; \ + add r10, r6, r5; \ + str r11, [sp, #11*4]; \ + eor r2, r2, r9, ror #23; \ + str r12, [sp, #12*4]; \ + eor r7, r7, r10, ror #23; \ + ldr r9, [sp, #9*4]; \ + add r11, r8, r11; \ + ldr r10, [sp, #14*4]; \ + add r12, lr, r12; \ + eor r9, r9, r11, ror #19; \ + add r11, r2, r1; \ + eor r10, r10, r12, ror #19; \ + add r12, r7, r6; \ + str r8, [sp, #8*4]; \ + eor r3, r3, r11, ror #19; \ + str lr, [sp, #13*4]; \ + eor r4, r4, r12, ror #19; \ + + +#define salsa8_core() \ + ldmia sp, {r0-r7}; \ + ldr r12, [sp, #15*4]; \ + ldr r8, [sp, #11*4]; \ + ldr lr, [sp, #12*4]; \ + ldr r9, [sp, #9*4]; \ + add r8, r8, r12; \ + ldr r11, [sp, #10*4]; \ + add lr, lr, r0; \ + eor r3, r3, r8, ror #25; \ + add r8, r5, r1; \ + ldr r10, [sp, #14*4]; \ + eor r4, r4, lr, ror #25; \ + add lr, r11, r6; \ + eor r9, r9, r8, ror #25; \ + eor r10, r10, lr, ror #25; \ + salsa8_core_doubleround_body(); \ + ldr r11, [sp, #10*4]; \ + add r8, r9, r8; \ + ldr r12, [sp, #15*4]; \ + add lr, r10, lr; \ + eor r11, r11, r8, ror #14; \ + add r8, r3, r2; \ + eor r12, r12, lr, ror #14; \ + add lr, r4, r7; \ + eor r0, r0, r8, ror #14; \ + ldr r8, [sp, #11*4]; \ + eor r5, r5, lr, ror #14; \ + ldr lr, [sp, #12*4]; \ + add r8, r8, r12; \ + str r11, [sp, #10*4]; \ + add lr, lr, r0; \ + str r12, [sp, #15*4]; \ + eor r3, r3, r8, ror #25; \ + add r8, r5, r1; \ + eor r4, r4, lr, ror #25; \ + add lr, r11, r6; \ + str r9, [sp, #9*4]; \ + eor r9, r9, r8, ror #25; \ + str r10, [sp, #14*4]; \ + eor r10, r10, lr, ror #25; \ + salsa8_core_doubleround_body(); \ + ldr r11, [sp, #10*4]; \ + add r8, r9, r8; \ + ldr r12, [sp, #15*4]; \ + add lr, r10, lr; \ + eor r11, r11, r8, ror #14; \ + add r8, r3, r2; \ + eor r12, r12, lr, ror #14; \ + add lr, r4, r7; \ + eor r0, r0, r8, ror #14; \ + ldr r8, [sp, #11*4]; \ + eor r5, r5, lr, ror #14; \ + ldr lr, [sp, #12*4]; \ + add r8, r8, r12; \ + str r11, [sp, #10*4]; \ + add lr, lr, r0; \ + str r12, [sp, #15*4]; \ + eor r3, r3, r8, ror #25; \ + add r8, r5, r1; \ + eor r4, r4, lr, ror #25; \ + add lr, r11, r6; \ + str r9, [sp, #9*4]; \ + eor r9, r9, r8, ror #25; \ + str r10, [sp, #14*4]; \ + eor r10, r10, lr, ror #25; \ + salsa8_core_doubleround_body(); \ + ldr r11, [sp, #10*4]; \ + add r8, r9, r8; \ + ldr r12, [sp, #15*4]; \ + add lr, r10, lr; \ + eor r11, r11, r8, ror #14; \ + add r8, r3, r2; \ + eor r12, r12, lr, ror #14; \ + add lr, r4, r7; \ + eor r0, r0, r8, ror #14; \ + ldr r8, [sp, #11*4]; \ + eor r5, r5, lr, ror #14; \ + ldr lr, [sp, #12*4]; \ + add r8, r8, r12; \ + str r11, [sp, #10*4]; \ + add lr, lr, r0; \ + str r12, [sp, #15*4]; \ + eor r3, r3, r8, ror #25; \ + add r8, r5, r1; \ + eor r4, r4, lr, ror #25; \ + add lr, r11, r6; \ + str r9, [sp, #9*4]; \ + eor r9, r9, r8, ror #25; \ + str r10, [sp, #14*4]; \ + eor r10, r10, lr, ror #25; \ + salsa8_core_doubleround_body(); \ + ldr r11, [sp, #10*4]; \ + add r8, r9, r8; \ + ldr r12, [sp, #15*4]; \ + add lr, r10, lr; \ + str r9, [sp, #9*4]; \ + eor r11, r11, r8, ror #14; \ + eor r12, r12, lr, ror #14; \ + add r8, r3, r2; \ + str r10, [sp, #14*4]; \ + add lr, r4, r7; \ + str r11, [sp, #10*4]; \ + eor r0, r0, r8, ror #14; \ + str r12, [sp, #15*4]; \ + eor r5, r5, lr, ror #14; \ + stmia sp, {r0-r7}; \ + + +#endif + + +#define scrypt_core_macro1a_x4() \ + ldmia r0, {r4-r7}; \ + ldmia lr!, {r8-r11}; \ + stmia r1!, {r4-r7}; \ + stmia r3!, {r8-r11}; \ + eor r4, r4, r8; \ + eor r5, r5, r9; \ + eor r6, r6, r10; \ + eor r7, r7, r11; \ + stmia r0!, {r4-r7}; \ + stmia r12!, {r4-r7}; \ + + +#define scrypt_core_macro1b_x4() \ + ldmia r3!, {r8-r11}; \ + ldmia r2, {r4-r7}; \ + eor r8, r8, r4; \ + eor r9, r9, r5; \ + eor r10, r10, r6; \ + eor r11, r11, r7; \ + ldmia r0, {r4-r7}; \ + stmia r2!, {r8-r11}; \ + eor r4, r4, r8; \ + eor r5, r5, r9; \ + eor r6, r6, r10; \ + eor r7, r7, r11; \ + ldmia r1!, {r8-r11}; \ + eor r4, r4, r8; \ + eor r5, r5, r9; \ + eor r6, r6, r10; \ + eor r7, r7, r11; \ + stmia r0!, {r4-r7}; \ + stmia r12!, {r4-r7}; \ + + +#define scrypt_core_macro2_x4() \ + ldmia r12, {r4-r7}; \ + ldmia r0, {r8-r11}; \ + add r4, r4, r8; \ + add r5, r5, r9; \ + add r6, r6, r10; \ + add r7, r7, r11; \ + stmia r0!, {r4-r7}; \ + ldmia r2, {r8-r11}; \ + eor r4, r4, r8; \ + eor r5, r5, r9; \ + eor r6, r6, r10; \ + eor r7, r7, r11; \ + stmia r2!, {r4-r7}; \ + stmia r12!, {r4-r7}; \ + + +#define scrypt_core_macro3_x4() \ + ldmia r1!, {r4-r7}; \ + ldmia r0, {r8-r11}; \ + add r4, r4, r8; \ + add r5, r5, r9; \ + add r6, r6, r10; \ + add r7, r7, r11; \ + stmia r0!, {r4-r7}; \ + + +#define scrypt_core_macro3_x6() \ + ldmia r1!, {r2-r7}; \ + ldmia r0, {r8-r12, lr}; \ + add r2, r2, r8; \ + add r3, r3, r9; \ + add r4, r4, r10; \ + add r5, r5, r11; \ + add r6, r6, r12; \ + add r7, r7, lr; \ + stmia r0!, {r2-r7}; \ + + + + .text + .code 32 + .align 2 + .globl scrypt_core + .globl _scrypt_core +#ifdef __ELF__ + .type scrypt_core, %function +#endif +scrypt_core: +_scrypt_core: + stmfd sp!, {r4-r11, lr} + mov r12, sp + sub sp, sp, #21*4 + bic sp, sp, #63 + str r12, [sp, #20*4] + + scrypt_shuffle() + + str r0, [sp, #16*4] + add r12, r1, #1024*32*4 + str r12, [sp, #18*4] +scrypt_core_loop1: + add lr, r0, #16*4 + add r3, r1, #16*4 + mov r12, sp + scrypt_core_macro1a_x4() + scrypt_core_macro1a_x4() + scrypt_core_macro1a_x4() + scrypt_core_macro1a_x4() + str r1, [sp, #17*4] + + salsa8_core() + + ldr r0, [sp, #16*4] + mov r12, sp + add r2, r0, #16*4 + scrypt_core_macro2_x4() + scrypt_core_macro2_x4() + scrypt_core_macro2_x4() + scrypt_core_macro2_x4() + + salsa8_core() + + ldr r0, [sp, #16*4] + mov r1, sp + add r0, r0, #16*4 + scrypt_core_macro3_x6() + scrypt_core_macro3_x6() + ldr r3, [sp, #17*4] + ldr r12, [sp, #18*4] + scrypt_core_macro3_x4() + + add r1, r3, #16*4 + sub r0, r0, #32*4 + cmp r1, r12 + bne scrypt_core_loop1 + + ldr r4, [r0, #16*4] + sub r1, r1, #1024*32*4 + str r1, [sp, #17*4] + mov r4, r4, lsl #32-10 + mov r12, #1024 + add r1, r1, r4, lsr #32-10-7 +scrypt_core_loop2: + add r2, r0, #16*4 + add r3, r1, #16*4 + str r12, [sp, #18*4] + mov r12, sp +#ifdef __ARM_ARCH_5E_OR_6_OR_7__ + pld [r1, #24*4] + pld [r1, #8*4] +#endif + scrypt_core_macro1b_x4() + scrypt_core_macro1b_x4() + scrypt_core_macro1b_x4() + scrypt_core_macro1b_x4() + + salsa8_core() + + ldr r0, [sp, #16*4] + mov r12, sp + add r2, r0, #16*4 + scrypt_core_macro2_x4() + scrypt_core_macro2_x4() + scrypt_core_macro2_x4() + scrypt_core_macro2_x4() + + salsa8_core() + + ldr r0, [sp, #16*4] + mov r1, sp + ldr r3, [sp, #17*4] + add r0, r0, #16*4 + scrypt_core_macro3_x4() + mov r4, r4, lsl #32-10 + add r3, r3, r4, lsr #32-10-7 + str r3, [sp, #19*4] +#ifdef __ARM_ARCH_5E_OR_6_OR_7__ + pld [r3, #16*4] + pld [r3] +#endif + scrypt_core_macro3_x6() + scrypt_core_macro3_x6() + + ldr r12, [sp, #18*4] + sub r0, r0, #32*4 + ldr r1, [sp, #19*4] + subs r12, r12, #1 + bne scrypt_core_loop2 + + scrypt_shuffle() + + ldr sp, [sp, #20*4] +#ifdef __thumb__ + ldmfd sp!, {r4-r11, lr} + bx lr +#else + ldmfd sp!, {r4-r11, pc} +#endif + +#endif diff --git a/src/scrypt-x86.S b/src/scrypt-x86.S new file mode 100644 index 0000000..c1d2cef --- /dev/null +++ b/src/scrypt-x86.S @@ -0,0 +1,912 @@ +# Copyright 2011 pooler@litecoinpool.org +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +#if defined(OPTIMIZED_SALSA) && defined(__i386__) + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif + +#define gen_salsa8_core_quadround() \ + movl 52(%esp), %ecx; \ + movl 4(%esp), %edx; \ + movl 20(%esp), %ebx; \ + movl 8(%esp), %esi; \ + leal (%ecx, %edx), %edi; \ + roll $7, %edi; \ + xorl %edi, %ebx; \ + movl %ebx, 4(%esp); \ + movl 36(%esp), %edi; \ + leal (%edx, %ebx), %ebp; \ + roll $9, %ebp; \ + xorl %ebp, %edi; \ + movl 24(%esp), %ebp; \ + movl %edi, 8(%esp); \ + addl %edi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %ecx; \ + movl 40(%esp), %ebx; \ + movl %ecx, 20(%esp); \ + addl %edi, %ecx; \ + roll $18, %ecx; \ + leal (%esi, %ebp), %edi; \ + roll $7, %edi; \ + xorl %edi, %ebx; \ + movl %ebx, 24(%esp); \ + movl 56(%esp), %edi; \ + xorl %ecx, %edx; \ + leal (%ebp, %ebx), %ecx; \ + roll $9, %ecx; \ + xorl %ecx, %edi; \ + movl %edi, 36(%esp); \ + movl 28(%esp), %ecx; \ + movl %edx, 28(%esp); \ + movl 44(%esp), %edx; \ + addl %edi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %esi; \ + movl 60(%esp), %ebx; \ + movl %esi, 40(%esp); \ + addl %edi, %esi; \ + roll $18, %esi; \ + leal (%ecx, %edx), %edi; \ + roll $7, %edi; \ + xorl %edi, %ebx; \ + movl %ebx, 44(%esp); \ + movl 12(%esp), %edi; \ + xorl %esi, %ebp; \ + leal (%edx, %ebx), %esi; \ + roll $9, %esi; \ + xorl %esi, %edi; \ + movl %edi, 12(%esp); \ + movl 48(%esp), %esi; \ + movl %ebp, 48(%esp); \ + movl 64(%esp), %ebp; \ + addl %edi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %ecx; \ + movl 16(%esp), %ebx; \ + movl %ecx, 16(%esp); \ + addl %edi, %ecx; \ + roll $18, %ecx; \ + leal (%esi, %ebp), %edi; \ + roll $7, %edi; \ + xorl %edi, %ebx; \ + movl 32(%esp), %edi; \ + xorl %ecx, %edx; \ + leal (%ebp, %ebx), %ecx; \ + roll $9, %ecx; \ + xorl %ecx, %edi; \ + movl %edi, 32(%esp); \ + movl %ebx, %ecx; \ + movl %edx, 52(%esp); \ + movl 28(%esp), %edx; \ + addl %edi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %esi; \ + movl 40(%esp), %ebx; \ + movl %esi, 28(%esp); \ + addl %edi, %esi; \ + roll $18, %esi; \ + leal (%ecx, %edx), %edi; \ + roll $7, %edi; \ + xorl %edi, %ebx; \ + movl %ebx, 40(%esp); \ + movl 12(%esp), %edi; \ + xorl %esi, %ebp; \ + leal (%edx, %ebx), %esi; \ + roll $9, %esi; \ + xorl %esi, %edi; \ + movl %edi, 12(%esp); \ + movl 4(%esp), %esi; \ + movl %ebp, 4(%esp); \ + movl 48(%esp), %ebp; \ + addl %edi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %ecx; \ + movl 16(%esp), %ebx; \ + movl %ecx, 16(%esp); \ + addl %edi, %ecx; \ + roll $18, %ecx; \ + leal (%esi, %ebp), %edi; \ + roll $7, %edi; \ + xorl %edi, %ebx; \ + movl %ebx, 48(%esp); \ + movl 32(%esp), %edi; \ + xorl %ecx, %edx; \ + leal (%ebp, %ebx), %ecx; \ + roll $9, %ecx; \ + xorl %ecx, %edi; \ + movl %edi, 32(%esp); \ + movl 24(%esp), %ecx; \ + movl %edx, 24(%esp); \ + movl 52(%esp), %edx; \ + addl %edi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %esi; \ + movl 28(%esp), %ebx; \ + movl %esi, 28(%esp); \ + addl %edi, %esi; \ + roll $18, %esi; \ + leal (%ecx, %edx), %edi; \ + roll $7, %edi; \ + xorl %edi, %ebx; \ + movl %ebx, 52(%esp); \ + movl 8(%esp), %edi; \ + xorl %esi, %ebp; \ + leal (%edx, %ebx), %esi; \ + roll $9, %esi; \ + xorl %esi, %edi; \ + movl %edi, 8(%esp); \ + movl 44(%esp), %esi; \ + movl %ebp, 44(%esp); \ + movl 4(%esp), %ebp; \ + addl %edi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %ecx; \ + movl 20(%esp), %ebx; \ + movl %ecx, 4(%esp); \ + addl %edi, %ecx; \ + roll $18, %ecx; \ + leal (%esi, %ebp), %edi; \ + roll $7, %edi; \ + xorl %edi, %ebx; \ + movl 36(%esp), %edi; \ + xorl %ecx, %edx; \ + leal (%ebp, %ebx), %ecx; \ + roll $9, %ecx; \ + xorl %ecx, %edi; \ + movl %edi, 20(%esp); \ + movl %ebx, %ecx; \ + movl %edx, 36(%esp); \ + movl 24(%esp), %edx; \ + addl %edi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %esi; \ + movl 28(%esp), %ebx; \ + movl %esi, 24(%esp); \ + addl %edi, %esi; \ + roll $18, %esi; \ + leal (%ecx, %edx), %edi; \ + roll $7, %edi; \ + xorl %edi, %ebx; \ + movl %ebx, 28(%esp); \ + xorl %esi, %ebp; \ + movl 8(%esp), %esi; \ + leal (%edx, %ebx), %edi; \ + roll $9, %edi; \ + xorl %edi, %esi; \ + movl 40(%esp), %edi; \ + movl %ebp, 8(%esp); \ + movl 44(%esp), %ebp; \ + movl %esi, 40(%esp); \ + addl %esi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %ecx; \ + movl 4(%esp), %ebx; \ + movl %ecx, 44(%esp); \ + addl %esi, %ecx; \ + roll $18, %ecx; \ + leal (%edi, %ebp), %esi; \ + roll $7, %esi; \ + xorl %esi, %ebx; \ + movl %ebx, 4(%esp); \ + movl 20(%esp), %esi; \ + xorl %ecx, %edx; \ + leal (%ebp, %ebx), %ecx; \ + roll $9, %ecx; \ + xorl %ecx, %esi; \ + movl %esi, 56(%esp); \ + movl 48(%esp), %ecx; \ + movl %edx, 20(%esp); \ + movl 36(%esp), %edx; \ + addl %esi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %edi; \ + movl 24(%esp), %ebx; \ + movl %edi, 24(%esp); \ + addl %esi, %edi; \ + roll $18, %edi; \ + leal (%ecx, %edx), %esi; \ + roll $7, %esi; \ + xorl %esi, %ebx; \ + movl %ebx, 60(%esp); \ + movl 12(%esp), %esi; \ + xorl %edi, %ebp; \ + leal (%edx, %ebx), %edi; \ + roll $9, %edi; \ + xorl %edi, %esi; \ + movl %esi, 12(%esp); \ + movl 52(%esp), %edi; \ + movl %ebp, 36(%esp); \ + movl 8(%esp), %ebp; \ + addl %esi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %ecx; \ + movl 16(%esp), %ebx; \ + movl %ecx, 16(%esp); \ + addl %esi, %ecx; \ + roll $18, %ecx; \ + leal (%edi, %ebp), %esi; \ + roll $7, %esi; \ + xorl %esi, %ebx; \ + movl 32(%esp), %esi; \ + xorl %ecx, %edx; \ + leal (%ebp, %ebx), %ecx; \ + roll $9, %ecx; \ + xorl %ecx, %esi; \ + movl %esi, 32(%esp); \ + movl %ebx, %ecx; \ + movl %edx, 48(%esp); \ + movl 20(%esp), %edx; \ + addl %esi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %edi; \ + movl 24(%esp), %ebx; \ + movl %edi, 20(%esp); \ + addl %esi, %edi; \ + roll $18, %edi; \ + leal (%ecx, %edx), %esi; \ + roll $7, %esi; \ + xorl %esi, %ebx; \ + movl %ebx, 8(%esp); \ + movl 12(%esp), %esi; \ + xorl %edi, %ebp; \ + leal (%edx, %ebx), %edi; \ + roll $9, %edi; \ + xorl %edi, %esi; \ + movl %esi, 12(%esp); \ + movl 28(%esp), %edi; \ + movl %ebp, 52(%esp); \ + movl 36(%esp), %ebp; \ + addl %esi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %ecx; \ + movl 16(%esp), %ebx; \ + movl %ecx, 16(%esp); \ + addl %esi, %ecx; \ + roll $18, %ecx; \ + leal (%edi, %ebp), %esi; \ + roll $7, %esi; \ + xorl %esi, %ebx; \ + movl %ebx, 28(%esp); \ + movl 32(%esp), %esi; \ + xorl %ecx, %edx; \ + leal (%ebp, %ebx), %ecx; \ + roll $9, %ecx; \ + xorl %ecx, %esi; \ + movl %esi, 32(%esp); \ + movl 4(%esp), %ecx; \ + movl %edx, 4(%esp); \ + movl 48(%esp), %edx; \ + addl %esi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %edi; \ + movl 20(%esp), %ebx; \ + movl %edi, 20(%esp); \ + addl %esi, %edi; \ + roll $18, %edi; \ + leal (%ecx, %edx), %esi; \ + roll $7, %esi; \ + xorl %esi, %ebx; \ + movl %ebx, 48(%esp); \ + movl 40(%esp), %esi; \ + xorl %edi, %ebp; \ + leal (%edx, %ebx), %edi; \ + roll $9, %edi; \ + xorl %edi, %esi; \ + movl %esi, 36(%esp); \ + movl 60(%esp), %edi; \ + movl %ebp, 24(%esp); \ + movl 52(%esp), %ebp; \ + addl %esi, %ebx; \ + roll $13, %ebx; \ + xorl %ebx, %ecx; \ + movl 44(%esp), %ebx; \ + movl %ecx, 40(%esp); \ + addl %esi, %ecx; \ + roll $18, %ecx; \ + leal (%edi, %ebp), %esi; \ + roll $7, %esi; \ + xorl %esi, %ebx; \ + movl %ebx, 52(%esp); \ + movl 56(%esp), %esi; \ + xorl %ecx, %edx; \ + leal (%ebp, %ebx), %ecx; \ + roll $9, %ecx; \ + xorl %ecx, %esi; \ + movl %esi, 56(%esp); \ + addl %esi, %ebx; \ + movl %edx, 44(%esp); \ + roll $13, %ebx; \ + xorl %ebx, %edi; \ + movl %edi, 60(%esp); \ + addl %esi, %edi; \ + roll $18, %edi; \ + xorl %edi, %ebp; \ + movl %ebp, 64(%esp); \ + + + .text + .align 32 +gen_salsa8_core: + gen_salsa8_core_quadround() + gen_salsa8_core_quadround() + ret + + + .text + .align 32 + .globl scrypt_core + .globl _scrypt_core +scrypt_core: +_scrypt_core: + pushl %ebx + pushl %ebp + pushl %edi + pushl %esi + + # Check for SSE2 availability + movl $1, %eax + cpuid + andl $0x04000000, %edx + jnz xmm_scrypt_core + +gen_scrypt_core: + movl 20(%esp), %edi + movl 24(%esp), %esi + subl $72, %esp + +#define scrypt_core_macro1a(p, q) \ + movl p(%edi), %eax; \ + movl q(%edi), %edx; \ + movl %eax, p(%esi); \ + movl %edx, q(%esi); \ + xorl %edx, %eax; \ + movl %eax, p(%edi); \ + movl %eax, p(%esp); \ + + +#define scrypt_core_macro1b(p, q) \ + movl p(%edi), %eax; \ + xorl p(%esi, %edx), %eax; \ + movl q(%edi), %ebx; \ + xorl q(%esi, %edx), %ebx; \ + movl %ebx, q(%edi); \ + xorl %ebx, %eax; \ + movl %eax, p(%edi); \ + movl %eax, p(%esp); \ + + +#define scrypt_core_macro2(p, q) \ + movl p(%esp), %eax; \ + addl p(%edi), %eax; \ + movl %eax, p(%edi); \ + xorl q(%edi), %eax; \ + movl %eax, q(%edi); \ + movl %eax, p(%esp); \ + + +#define scrypt_core_macro3(p, q) \ + movl p(%esp), %eax; \ + addl q(%edi), %eax; \ + movl %eax, q(%edi); \ + + + leal 131072(%esi), %ecx +gen_scrypt_core_loop1: + movl %esi, 64(%esp) + movl %ecx, 68(%esp) + + scrypt_core_macro1a(0, 64) + scrypt_core_macro1a(4, 68) + scrypt_core_macro1a(8, 72) + scrypt_core_macro1a(12, 76) + scrypt_core_macro1a(16, 80) + scrypt_core_macro1a(20, 84) + scrypt_core_macro1a(24, 88) + scrypt_core_macro1a(28, 92) + scrypt_core_macro1a(32, 96) + scrypt_core_macro1a(36, 100) + scrypt_core_macro1a(40, 104) + scrypt_core_macro1a(44, 108) + scrypt_core_macro1a(48, 112) + scrypt_core_macro1a(52, 116) + scrypt_core_macro1a(56, 120) + scrypt_core_macro1a(60, 124) + + call gen_salsa8_core + + movl 92(%esp), %edi + scrypt_core_macro2(0, 64) + scrypt_core_macro2(4, 68) + scrypt_core_macro2(8, 72) + scrypt_core_macro2(12, 76) + scrypt_core_macro2(16, 80) + scrypt_core_macro2(20, 84) + scrypt_core_macro2(24, 88) + scrypt_core_macro2(28, 92) + scrypt_core_macro2(32, 96) + scrypt_core_macro2(36, 100) + scrypt_core_macro2(40, 104) + scrypt_core_macro2(44, 108) + scrypt_core_macro2(48, 112) + scrypt_core_macro2(52, 116) + scrypt_core_macro2(56, 120) + scrypt_core_macro2(60, 124) + + call gen_salsa8_core + + movl 92(%esp), %edi + scrypt_core_macro3(0, 64) + scrypt_core_macro3(4, 68) + scrypt_core_macro3(8, 72) + scrypt_core_macro3(12, 76) + scrypt_core_macro3(16, 80) + scrypt_core_macro3(20, 84) + scrypt_core_macro3(24, 88) + scrypt_core_macro3(28, 92) + scrypt_core_macro3(32, 96) + scrypt_core_macro3(36, 100) + scrypt_core_macro3(40, 104) + scrypt_core_macro3(44, 108) + scrypt_core_macro3(48, 112) + scrypt_core_macro3(52, 116) + scrypt_core_macro3(56, 120) + scrypt_core_macro3(60, 124) + + movl 64(%esp), %esi + movl 68(%esp), %ecx + addl $128, %esi + cmpl %ecx, %esi + jne gen_scrypt_core_loop1 + + movl 96(%esp), %esi + movl $1024, %ecx +gen_scrypt_core_loop2: + movl %ecx, 68(%esp) + + movl 64(%edi), %edx + andl $1023, %edx + shll $7, %edx + + scrypt_core_macro1b(0, 64) + scrypt_core_macro1b(4, 68) + scrypt_core_macro1b(8, 72) + scrypt_core_macro1b(12, 76) + scrypt_core_macro1b(16, 80) + scrypt_core_macro1b(20, 84) + scrypt_core_macro1b(24, 88) + scrypt_core_macro1b(28, 92) + scrypt_core_macro1b(32, 96) + scrypt_core_macro1b(36, 100) + scrypt_core_macro1b(40, 104) + scrypt_core_macro1b(44, 108) + scrypt_core_macro1b(48, 112) + scrypt_core_macro1b(52, 116) + scrypt_core_macro1b(56, 120) + scrypt_core_macro1b(60, 124) + + call gen_salsa8_core + + movl 92(%esp), %edi + scrypt_core_macro2(0, 64) + scrypt_core_macro2(4, 68) + scrypt_core_macro2(8, 72) + scrypt_core_macro2(12, 76) + scrypt_core_macro2(16, 80) + scrypt_core_macro2(20, 84) + scrypt_core_macro2(24, 88) + scrypt_core_macro2(28, 92) + scrypt_core_macro2(32, 96) + scrypt_core_macro2(36, 100) + scrypt_core_macro2(40, 104) + scrypt_core_macro2(44, 108) + scrypt_core_macro2(48, 112) + scrypt_core_macro2(52, 116) + scrypt_core_macro2(56, 120) + scrypt_core_macro2(60, 124) + + call gen_salsa8_core + + movl 92(%esp), %edi + movl 96(%esp), %esi + scrypt_core_macro3(0, 64) + scrypt_core_macro3(4, 68) + scrypt_core_macro3(8, 72) + scrypt_core_macro3(12, 76) + scrypt_core_macro3(16, 80) + scrypt_core_macro3(20, 84) + scrypt_core_macro3(24, 88) + scrypt_core_macro3(28, 92) + scrypt_core_macro3(32, 96) + scrypt_core_macro3(36, 100) + scrypt_core_macro3(40, 104) + scrypt_core_macro3(44, 108) + scrypt_core_macro3(48, 112) + scrypt_core_macro3(52, 116) + scrypt_core_macro3(56, 120) + scrypt_core_macro3(60, 124) + + movl 68(%esp), %ecx + subl $1, %ecx + ja gen_scrypt_core_loop2 + + addl $72, %esp + popl %esi + popl %edi + popl %ebp + popl %ebx + ret + + +#define xmm_salsa8_core_doubleround() \ + movdqa %xmm1, %xmm4; \ + paddd %xmm0, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $7, %xmm4; \ + psrld $25, %xmm5; \ + pxor %xmm4, %xmm3; \ + pxor %xmm5, %xmm3; \ + movdqa %xmm0, %xmm4; \ + paddd %xmm3, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $9, %xmm4; \ + psrld $23, %xmm5; \ + pxor %xmm4, %xmm2; \ + movdqa %xmm3, %xmm4; \ + pshufd $0x93, %xmm3, %xmm3; \ + pxor %xmm5, %xmm2; \ + paddd %xmm2, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $13, %xmm4; \ + psrld $19, %xmm5; \ + pxor %xmm4, %xmm1; \ + movdqa %xmm2, %xmm4; \ + pshufd $0x4e, %xmm2, %xmm2; \ + pxor %xmm5, %xmm1; \ + paddd %xmm1, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $18, %xmm4; \ + psrld $14, %xmm5; \ + pxor %xmm4, %xmm0; \ + pshufd $0x39, %xmm1, %xmm1; \ + pxor %xmm5, %xmm0; \ + movdqa %xmm3, %xmm4; \ + paddd %xmm0, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $7, %xmm4; \ + psrld $25, %xmm5; \ + pxor %xmm4, %xmm1; \ + pxor %xmm5, %xmm1; \ + movdqa %xmm0, %xmm4; \ + paddd %xmm1, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $9, %xmm4; \ + psrld $23, %xmm5; \ + pxor %xmm4, %xmm2; \ + movdqa %xmm1, %xmm4; \ + pshufd $0x93, %xmm1, %xmm1; \ + pxor %xmm5, %xmm2; \ + paddd %xmm2, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $13, %xmm4; \ + psrld $19, %xmm5; \ + pxor %xmm4, %xmm3; \ + movdqa %xmm2, %xmm4; \ + pshufd $0x4e, %xmm2, %xmm2; \ + pxor %xmm5, %xmm3; \ + paddd %xmm3, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $18, %xmm4; \ + psrld $14, %xmm5; \ + pxor %xmm4, %xmm0; \ + pshufd $0x39, %xmm3, %xmm3; \ + pxor %xmm5, %xmm0; \ + + +#define xmm_salsa8_core() \ + xmm_salsa8_core_doubleround(); \ + xmm_salsa8_core_doubleround(); \ + xmm_salsa8_core_doubleround(); \ + xmm_salsa8_core_doubleround(); \ + + + .align 32 +xmm_scrypt_core: + movl 20(%esp), %edi + movl 24(%esp), %esi + movl %esp, %ebp + subl $128, %esp + andl $-16, %esp + + # shuffle 1st block to (%esp) + movl 60(%edi), %edx + movl 44(%edi), %ecx + movl 28(%edi), %ebx + movl 12(%edi), %eax + movl %edx, 12(%esp) + movl %ecx, 28(%esp) + movl %ebx, 44(%esp) + movl %eax, 60(%esp) + movl 40(%edi), %ecx + movl 24(%edi), %ebx + movl 8(%edi), %eax + movl 56(%edi), %edx + movl %ecx, 8(%esp) + movl %ebx, 24(%esp) + movl %eax, 40(%esp) + movl %edx, 56(%esp) + movl 20(%edi), %ebx + movl 4(%edi), %eax + movl 52(%edi), %edx + movl 36(%edi), %ecx + movl %ebx, 4(%esp) + movl %eax, 20(%esp) + movl %edx, 36(%esp) + movl %ecx, 52(%esp) + movl 0(%edi), %eax + movl 48(%edi), %edx + movl 32(%edi), %ecx + movl 16(%edi), %ebx + movl %eax, 0(%esp) + movl %edx, 16(%esp) + movl %ecx, 32(%esp) + movl %ebx, 48(%esp) + + # shuffle 2nd block to 64(%esp) + movl 124(%edi), %edx + movl 108(%edi), %ecx + movl 92(%edi), %ebx + movl 76(%edi), %eax + movl %edx, 76(%esp) + movl %ecx, 92(%esp) + movl %ebx, 108(%esp) + movl %eax, 124(%esp) + movl 104(%edi), %ecx + movl 88(%edi), %ebx + movl 72(%edi), %eax + movl 120(%edi), %edx + movl %ecx, 72(%esp) + movl %ebx, 88(%esp) + movl %eax, 104(%esp) + movl %edx, 120(%esp) + movl 84(%edi), %ebx + movl 68(%edi), %eax + movl 116(%edi), %edx + movl 100(%edi), %ecx + movl %ebx, 68(%esp) + movl %eax, 84(%esp) + movl %edx, 100(%esp) + movl %ecx, 116(%esp) + movl 64(%edi), %eax + movl 112(%edi), %edx + movl 96(%edi), %ecx + movl 80(%edi), %ebx + movl %eax, 64(%esp) + movl %edx, 80(%esp) + movl %ecx, 96(%esp) + movl %ebx, 112(%esp) + + movl %esi, %edx + leal 131072(%esi), %ecx +xmm_scrypt_core_loop1: + movdqa 0(%esp), %xmm0 + movdqa 16(%esp), %xmm1 + movdqa 32(%esp), %xmm2 + movdqa 48(%esp), %xmm3 + movdqa 64(%esp), %xmm4 + movdqa 80(%esp), %xmm5 + movdqa 96(%esp), %xmm6 + movdqa 112(%esp), %xmm7 + movdqa %xmm0, 0(%edx) + movdqa %xmm1, 16(%edx) + movdqa %xmm2, 32(%edx) + movdqa %xmm3, 48(%edx) + movdqa %xmm4, 64(%edx) + movdqa %xmm5, 80(%edx) + movdqa %xmm6, 96(%edx) + movdqa %xmm7, 112(%edx) + + pxor %xmm4, %xmm0 + pxor %xmm5, %xmm1 + pxor %xmm6, %xmm2 + pxor %xmm7, %xmm3 + movdqa %xmm0, 0(%esp) + movdqa %xmm1, 16(%esp) + movdqa %xmm2, 32(%esp) + movdqa %xmm3, 48(%esp) + xmm_salsa8_core() + paddd 0(%esp), %xmm0 + paddd 16(%esp), %xmm1 + paddd 32(%esp), %xmm2 + paddd 48(%esp), %xmm3 + movdqa %xmm0, 0(%esp) + movdqa %xmm1, 16(%esp) + movdqa %xmm2, 32(%esp) + movdqa %xmm3, 48(%esp) + + pxor 64(%esp), %xmm0 + pxor 80(%esp), %xmm1 + pxor 96(%esp), %xmm2 + pxor 112(%esp), %xmm3 + movdqa %xmm0, 64(%esp) + movdqa %xmm1, 80(%esp) + movdqa %xmm2, 96(%esp) + movdqa %xmm3, 112(%esp) + xmm_salsa8_core() + paddd 64(%esp), %xmm0 + paddd 80(%esp), %xmm1 + paddd 96(%esp), %xmm2 + paddd 112(%esp), %xmm3 + movdqa %xmm0, 64(%esp) + movdqa %xmm1, 80(%esp) + movdqa %xmm2, 96(%esp) + movdqa %xmm3, 112(%esp) + + addl $128, %edx + cmpl %ecx, %edx + jne xmm_scrypt_core_loop1 + + movl $1024, %ecx +xmm_scrypt_core_loop2: + movdqa 0(%esp), %xmm0 + movdqa 16(%esp), %xmm1 + movdqa 32(%esp), %xmm2 + movdqa 48(%esp), %xmm3 + movdqa 64(%esp), %xmm4 + movdqa 80(%esp), %xmm5 + movdqa 96(%esp), %xmm6 + movdqa 112(%esp), %xmm7 + movd %xmm4, %edx + andl $1023, %edx + shll $7, %edx + pxor 0(%esi, %edx), %xmm0 + pxor 16(%esi, %edx), %xmm1 + pxor 32(%esi, %edx), %xmm2 + pxor 48(%esi, %edx), %xmm3 + pxor 64(%esi, %edx), %xmm4 + pxor 80(%esi, %edx), %xmm5 + pxor 96(%esi, %edx), %xmm6 + pxor 112(%esi, %edx), %xmm7 + movdqa %xmm4, 64(%esp) + movdqa %xmm5, 80(%esp) + movdqa %xmm6, 96(%esp) + movdqa %xmm7, 112(%esp) + + pxor %xmm4, %xmm0 + pxor %xmm5, %xmm1 + pxor %xmm6, %xmm2 + pxor %xmm7, %xmm3 + movdqa %xmm0, 0(%esp) + movdqa %xmm1, 16(%esp) + movdqa %xmm2, 32(%esp) + movdqa %xmm3, 48(%esp) + xmm_salsa8_core() + paddd 0(%esp), %xmm0 + paddd 16(%esp), %xmm1 + paddd 32(%esp), %xmm2 + paddd 48(%esp), %xmm3 + movdqa %xmm0, 0(%esp) + movdqa %xmm1, 16(%esp) + movdqa %xmm2, 32(%esp) + movdqa %xmm3, 48(%esp) + + pxor 64(%esp), %xmm0 + pxor 80(%esp), %xmm1 + pxor 96(%esp), %xmm2 + pxor 112(%esp), %xmm3 + movdqa %xmm0, 64(%esp) + movdqa %xmm1, 80(%esp) + movdqa %xmm2, 96(%esp) + movdqa %xmm3, 112(%esp) + xmm_salsa8_core() + paddd 64(%esp), %xmm0 + paddd 80(%esp), %xmm1 + paddd 96(%esp), %xmm2 + paddd 112(%esp), %xmm3 + movdqa %xmm0, 64(%esp) + movdqa %xmm1, 80(%esp) + movdqa %xmm2, 96(%esp) + movdqa %xmm3, 112(%esp) + + subl $1, %ecx + ja xmm_scrypt_core_loop2 + + # re-shuffle 1st block back + movl 60(%esp), %edx + movl 44(%esp), %ecx + movl 28(%esp), %ebx + movl 12(%esp), %eax + movl %edx, 12(%edi) + movl %ecx, 28(%edi) + movl %ebx, 44(%edi) + movl %eax, 60(%edi) + movl 40(%esp), %ecx + movl 24(%esp), %ebx + movl 8(%esp), %eax + movl 56(%esp), %edx + movl %ecx, 8(%edi) + movl %ebx, 24(%edi) + movl %eax, 40(%edi) + movl %edx, 56(%edi) + movl 20(%esp), %ebx + movl 4(%esp), %eax + movl 52(%esp), %edx + movl 36(%esp), %ecx + movl %ebx, 4(%edi) + movl %eax, 20(%edi) + movl %edx, 36(%edi) + movl %ecx, 52(%edi) + movl 0(%esp), %eax + movl 48(%esp), %edx + movl 32(%esp), %ecx + movl 16(%esp), %ebx + movl %eax, 0(%edi) + movl %edx, 16(%edi) + movl %ecx, 32(%edi) + movl %ebx, 48(%edi) + + # re-shuffle 2nd block back + movl 124(%esp), %edx + movl 108(%esp), %ecx + movl 92(%esp), %ebx + movl 76(%esp), %eax + movl %edx, 76(%edi) + movl %ecx, 92(%edi) + movl %ebx, 108(%edi) + movl %eax, 124(%edi) + movl 104(%esp), %ecx + movl 88(%esp), %ebx + movl 72(%esp), %eax + movl 120(%esp), %edx + movl %ecx, 72(%edi) + movl %ebx, 88(%edi) + movl %eax, 104(%edi) + movl %edx, 120(%edi) + movl 84(%esp), %ebx + movl 68(%esp), %eax + movl 116(%esp), %edx + movl 100(%esp), %ecx + movl %ebx, 68(%edi) + movl %eax, 84(%edi) + movl %edx, 100(%edi) + movl %ecx, 116(%edi) + movl 64(%esp), %eax + movl 112(%esp), %edx + movl 96(%esp), %ecx + movl 80(%esp), %ebx + movl %eax, 64(%edi) + movl %edx, 80(%edi) + movl %ecx, 96(%edi) + movl %ebx, 112(%edi) + + movl %ebp, %esp + popl %esi + popl %edi + popl %ebp + popl %ebx + ret + +#endif diff --git a/src/scrypt-x86_64.S b/src/scrypt-x86_64.S new file mode 100644 index 0000000..3036d03 --- /dev/null +++ b/src/scrypt-x86_64.S @@ -0,0 +1,859 @@ +# Copyright 2011-2012 pooler@litecoinpool.org +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + + +#if defined(OPTIMIZED_SALSA) && defined(__x86_64__) + +#if defined(__linux__) && defined(__ELF__) + .section .note.GNU-stack,"",%progbits +#endif + +#define scrypt_shuffle(src, so, dest, do) \ + movl so+60(src), %r8d; \ + movl so+44(src), %r9d; \ + movl so+28(src), %r10d; \ + movl so+12(src), %r11d; \ + movl %r8d, do+12(dest); \ + movl %r9d, do+28(dest); \ + movl %r10d, do+44(dest); \ + movl %r11d, do+60(dest); \ + movl so+40(src), %r8d; \ + movl so+8(src), %r9d; \ + movl so+48(src), %r10d; \ + movl so+16(src), %r11d; \ + movl %r8d, do+8(dest); \ + movl %r9d, do+40(dest); \ + movl %r10d, do+16(dest); \ + movl %r11d, do+48(dest); \ + movl so+20(src), %r8d; \ + movl so+4(src), %r9d; \ + movl so+52(src), %r10d; \ + movl so+36(src), %r11d; \ + movl %r8d, do+4(dest); \ + movl %r9d, do+20(dest); \ + movl %r10d, do+36(dest); \ + movl %r11d, do+52(dest); \ + movl so+0(src), %r8d; \ + movl so+24(src), %r9d; \ + movl so+32(src), %r10d; \ + movl so+56(src), %r11d; \ + movl %r8d, do+0(dest); \ + movl %r9d, do+24(dest); \ + movl %r10d, do+32(dest); \ + movl %r11d, do+56(dest); \ + + +#define gen_salsa8_core_doubleround() \ + movq 72(%rsp), %r15; \ + leaq (%r14, %rdx), %rbp; \ + roll $7, %ebp; \ + xorq %rbp, %r9; \ + leaq (%rdi, %r15), %rbp; \ + roll $7, %ebp; \ + xorq %rbp, %r10; \ + leaq (%rdx, %r9), %rbp; \ + roll $9, %ebp; \ + xorq %rbp, %r11; \ + leaq (%r15, %r10), %rbp; \ + roll $9, %ebp; \ + xorq %rbp, %r13; \ + leaq (%r9, %r11), %rbp; \ + roll $13, %ebp; \ + xorq %rbp, %r14; \ + leaq (%r10, %r13), %rbp; \ + roll $13, %ebp; \ + xorq %rbp, %rdi; \ + leaq (%r11, %r14), %rbp; \ + roll $18, %ebp; \ + xorq %rbp, %rdx; \ + leaq (%r13, %rdi), %rbp; \ + roll $18, %ebp; \ + xorq %rbp, %r15; \ + movq 48(%rsp), %rbp; \ + movq %r15, 72(%rsp); \ + leaq (%rax, %rbp), %r15; \ + roll $7, %r15d; \ + xorq %r15, %rbx; \ + leaq (%rbp, %rbx), %r15; \ + roll $9, %r15d; \ + xorq %r15, %rcx; \ + leaq (%rbx, %rcx), %r15; \ + roll $13, %r15d; \ + xorq %r15, %rax; \ + leaq (%rcx, %rax), %r15; \ + roll $18, %r15d; \ + xorq %r15, %rbp; \ + movq 88(%rsp), %r15; \ + movq %rbp, 48(%rsp); \ + leaq (%r12, %r15), %rbp; \ + roll $7, %ebp; \ + xorq %rbp, %rsi; \ + leaq (%r15, %rsi), %rbp; \ + roll $9, %ebp; \ + xorq %rbp, %r8; \ + leaq (%rsi, %r8), %rbp; \ + roll $13, %ebp; \ + xorq %rbp, %r12; \ + leaq (%r8, %r12), %rbp; \ + roll $18, %ebp; \ + xorq %rbp, %r15; \ + movq %r15, 88(%rsp); \ + movq 72(%rsp), %r15; \ + leaq (%rsi, %rdx), %rbp; \ + roll $7, %ebp; \ + xorq %rbp, %rdi; \ + leaq (%r9, %r15), %rbp; \ + roll $7, %ebp; \ + xorq %rbp, %rax; \ + leaq (%rdx, %rdi), %rbp; \ + roll $9, %ebp; \ + xorq %rbp, %rcx; \ + leaq (%r15, %rax), %rbp; \ + roll $9, %ebp; \ + xorq %rbp, %r8; \ + leaq (%rdi, %rcx), %rbp; \ + roll $13, %ebp; \ + xorq %rbp, %rsi; \ + leaq (%rax, %r8), %rbp; \ + roll $13, %ebp; \ + xorq %rbp, %r9; \ + leaq (%rcx, %rsi), %rbp; \ + roll $18, %ebp; \ + xorq %rbp, %rdx; \ + leaq (%r8, %r9), %rbp; \ + roll $18, %ebp; \ + xorq %rbp, %r15; \ + movq 48(%rsp), %rbp; \ + movq %r15, 72(%rsp); \ + leaq (%r10, %rbp), %r15; \ + roll $7, %r15d; \ + xorq %r15, %r12; \ + leaq (%rbp, %r12), %r15; \ + roll $9, %r15d; \ + xorq %r15, %r11; \ + leaq (%r12, %r11), %r15; \ + roll $13, %r15d; \ + xorq %r15, %r10; \ + leaq (%r11, %r10), %r15; \ + roll $18, %r15d; \ + xorq %r15, %rbp; \ + movq 88(%rsp), %r15; \ + movq %rbp, 48(%rsp); \ + leaq (%rbx, %r15), %rbp; \ + roll $7, %ebp; \ + xorq %rbp, %r14; \ + leaq (%r15, %r14), %rbp; \ + roll $9, %ebp; \ + xorq %rbp, %r13; \ + leaq (%r14, %r13), %rbp; \ + roll $13, %ebp; \ + xorq %rbp, %rbx; \ + leaq (%r13, %rbx), %rbp; \ + roll $18, %ebp; \ + xorq %rbp, %r15; \ + movq %r15, 88(%rsp); \ + + + .text + .align 32 +gen_salsa8_core: + # 0: %rdx, %rdi, %rcx, %rsi + movq 8(%rsp), %rdi + movq %rdi, %rdx + shrq $32, %rdi + movq 16(%rsp), %rsi + movq %rsi, %rcx + shrq $32, %rsi + # 1: %r9, 72(%rsp), %rax, %r8 + movq 24(%rsp), %r8 + movq %r8, %r9 + shrq $32, %r8 + movq %r8, 72(%rsp) + movq 32(%rsp), %r8 + movq %r8, %rax + shrq $32, %r8 + # 2: %r11, %r10, 48(%rsp), %r12 + movq 40(%rsp), %r10 + movq %r10, %r11 + shrq $32, %r10 + movq 48(%rsp), %r12 + #movq %r12, %r13 + #movq %r13, 48(%rsp) + shrq $32, %r12 + # 3: %r14, %r13, %rbx, 88(%rsp) + movq 56(%rsp), %r13 + movq %r13, %r14 + shrq $32, %r13 + movq 64(%rsp), %r15 + movq %r15, %rbx + shrq $32, %r15 + movq %r15, 88(%rsp) + + gen_salsa8_core_doubleround() + gen_salsa8_core_doubleround() + gen_salsa8_core_doubleround() + gen_salsa8_core_doubleround() + + movl %edx, %edx + shlq $32, %rdi + addq %rdi, %rdx + movd %rdx, %xmm0 + + movl %ecx, %ecx + shlq $32, %rsi + addq %rsi, %rcx + movd %rcx, %xmm4 + + movq 72(%rsp), %rdi + movl %r9d, %r9d + shlq $32, %rdi + addq %rdi, %r9 + movd %r9, %xmm1 + + movl %eax, %eax + shlq $32, %r8 + addq %r8, %rax + movd %rax, %xmm5 + + movl %r11d, %r11d + shlq $32, %r10 + addq %r10, %r11 + movd %r11, %xmm2 + + movl 48(%rsp), %r8d + shlq $32, %r12 + addq %r12, %r8 + movd %r8, %xmm6 + + movl %r14d, %r14d + shlq $32, %r13 + addq %r13, %r14 + movd %r14, %xmm3 + + movq 88(%rsp), %rdi + movl %ebx, %ebx + shlq $32, %rdi + addq %rdi, %rbx + movd %rbx, %xmm7 + + punpcklqdq %xmm4, %xmm0 + punpcklqdq %xmm5, %xmm1 + punpcklqdq %xmm6, %xmm2 + punpcklqdq %xmm7, %xmm3 + + #movq %rdx, 8(%rsp) + #movq %rcx, 16(%rsp) + #movq %r9, 24(%rsp) + #movq %rax, 32(%rsp) + #movq %r11, 40(%rsp) + #movq %r8, 48(%rsp) + #movq %r14, 56(%rsp) + #movq %rbx, 64(%rsp) + + ret + + + .text + .align 32 + .globl scrypt_core + .globl _scrypt_core +scrypt_core: +_scrypt_core: + pushq %rbx + pushq %rbp + pushq %r12 + pushq %r13 + pushq %r14 + pushq %r15 +#if defined(WIN64) + subq $176, %rsp + movdqa %xmm6, 8(%rsp) + movdqa %xmm7, 24(%rsp) + movdqa %xmm8, 40(%rsp) + movdqa %xmm9, 56(%rsp) + movdqa %xmm10, 72(%rsp) + movdqa %xmm11, 88(%rsp) + movdqa %xmm12, 104(%rsp) + movdqa %xmm13, 120(%rsp) + movdqa %xmm14, 136(%rsp) + movdqa %xmm15, 152(%rsp) + pushq %rdi + pushq %rsi + movq %rcx, %rdi + movq %rdx, %rsi +#endif + +#define scrypt_core_cleanup() \ + popq %r15; \ + popq %r14; \ + popq %r13; \ + popq %r12; \ + popq %rbp; \ + popq %rbx; \ + + + # GenuineIntel processors have fast SIMD + xorl %eax, %eax + cpuid + cmpl $0x6c65746e, %ecx + jne gen_scrypt_core + cmpl $0x49656e69, %edx + jne gen_scrypt_core + cmpl $0x756e6547, %ebx + je xmm_scrypt_core + +gen_scrypt_core: + subq $136, %rsp + movdqa 0(%rdi), %xmm8 + movdqa 16(%rdi), %xmm9 + movdqa 32(%rdi), %xmm10 + movdqa 48(%rdi), %xmm11 + movdqa 64(%rdi), %xmm12 + movdqa 80(%rdi), %xmm13 + movdqa 96(%rdi), %xmm14 + movdqa 112(%rdi), %xmm15 + + leaq 131072(%rsi), %rcx + movq %rdi, 104(%rsp) + movq %rsi, 112(%rsp) + movq %rcx, 120(%rsp) +gen_scrypt_core_loop1: + movdqa %xmm8, 0(%rsi) + movdqa %xmm9, 16(%rsi) + movdqa %xmm10, 32(%rsi) + movdqa %xmm11, 48(%rsi) + movdqa %xmm12, 64(%rsi) + movdqa %xmm13, 80(%rsi) + movdqa %xmm14, 96(%rsi) + movdqa %xmm15, 112(%rsi) + + pxor %xmm12, %xmm8 + pxor %xmm13, %xmm9 + pxor %xmm14, %xmm10 + pxor %xmm15, %xmm11 + movdqa %xmm8, 0(%rsp) + movdqa %xmm9, 16(%rsp) + movdqa %xmm10, 32(%rsp) + movdqa %xmm11, 48(%rsp) + movq %rsi, 128(%rsp) + call gen_salsa8_core + paddd %xmm0, %xmm8 + paddd %xmm1, %xmm9 + paddd %xmm2, %xmm10 + paddd %xmm3, %xmm11 + + pxor %xmm8, %xmm12 + pxor %xmm9, %xmm13 + pxor %xmm10, %xmm14 + pxor %xmm11, %xmm15 + movdqa %xmm12, 0(%rsp) + movdqa %xmm13, 16(%rsp) + movdqa %xmm14, 32(%rsp) + movdqa %xmm15, 48(%rsp) + call gen_salsa8_core + movq 128(%rsp), %rsi + paddd %xmm0, %xmm12 + paddd %xmm1, %xmm13 + paddd %xmm2, %xmm14 + paddd %xmm3, %xmm15 + + addq $128, %rsi + movq 120(%rsp), %rcx + cmpq %rcx, %rsi + jne gen_scrypt_core_loop1 + + movq $1024, %rcx +gen_scrypt_core_loop2: + movq 112(%rsp), %rsi + movd %xmm12, %edx + andl $1023, %edx + shll $7, %edx + movdqa 0(%rsi, %rdx), %xmm0 + movdqa 16(%rsi, %rdx), %xmm1 + movdqa 32(%rsi, %rdx), %xmm2 + movdqa 48(%rsi, %rdx), %xmm3 + movdqa 64(%rsi, %rdx), %xmm4 + movdqa 80(%rsi, %rdx), %xmm5 + movdqa 96(%rsi, %rdx), %xmm6 + movdqa 112(%rsi, %rdx), %xmm7 + pxor %xmm0, %xmm8 + pxor %xmm1, %xmm9 + pxor %xmm2, %xmm10 + pxor %xmm3, %xmm11 + pxor %xmm4, %xmm12 + pxor %xmm5, %xmm13 + pxor %xmm6, %xmm14 + pxor %xmm7, %xmm15 + + pxor %xmm12, %xmm8 + pxor %xmm13, %xmm9 + pxor %xmm14, %xmm10 + pxor %xmm15, %xmm11 + movdqa %xmm8, 0(%rsp) + movdqa %xmm9, 16(%rsp) + movdqa %xmm10, 32(%rsp) + movdqa %xmm11, 48(%rsp) + movq %rcx, 128(%rsp) + call gen_salsa8_core + paddd %xmm0, %xmm8 + paddd %xmm1, %xmm9 + paddd %xmm2, %xmm10 + paddd %xmm3, %xmm11 + + pxor %xmm8, %xmm12 + pxor %xmm9, %xmm13 + pxor %xmm10, %xmm14 + pxor %xmm11, %xmm15 + movdqa %xmm12, 0(%rsp) + movdqa %xmm13, 16(%rsp) + movdqa %xmm14, 32(%rsp) + movdqa %xmm15, 48(%rsp) + call gen_salsa8_core + movq 128(%rsp), %rcx + paddd %xmm0, %xmm12 + paddd %xmm1, %xmm13 + paddd %xmm2, %xmm14 + paddd %xmm3, %xmm15 + + subq $1, %rcx + ja gen_scrypt_core_loop2 + + movq 104(%rsp), %rdi + movdqa %xmm8, 0(%rdi) + movdqa %xmm9, 16(%rdi) + movdqa %xmm10, 32(%rdi) + movdqa %xmm11, 48(%rdi) + movdqa %xmm12, 64(%rdi) + movdqa %xmm13, 80(%rdi) + movdqa %xmm14, 96(%rdi) + movdqa %xmm15, 112(%rdi) + + addq $136, %rsp + scrypt_core_cleanup() + ret + + +#define xmm_salsa8_core_doubleround() \ + movdqa %xmm1, %xmm4; \ + paddd %xmm0, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $7, %xmm4; \ + psrld $25, %xmm5; \ + pxor %xmm4, %xmm3; \ + pxor %xmm5, %xmm3; \ + movdqa %xmm0, %xmm4; \ + paddd %xmm3, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $9, %xmm4; \ + psrld $23, %xmm5; \ + pxor %xmm4, %xmm2; \ + movdqa %xmm3, %xmm4; \ + pshufd $0x93, %xmm3, %xmm3; \ + pxor %xmm5, %xmm2; \ + paddd %xmm2, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $13, %xmm4; \ + psrld $19, %xmm5; \ + pxor %xmm4, %xmm1; \ + movdqa %xmm2, %xmm4; \ + pshufd $0x4e, %xmm2, %xmm2; \ + pxor %xmm5, %xmm1; \ + paddd %xmm1, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $18, %xmm4; \ + psrld $14, %xmm5; \ + pxor %xmm4, %xmm0; \ + pshufd $0x39, %xmm1, %xmm1; \ + pxor %xmm5, %xmm0; \ + movdqa %xmm3, %xmm4; \ + paddd %xmm0, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $7, %xmm4; \ + psrld $25, %xmm5; \ + pxor %xmm4, %xmm1; \ + pxor %xmm5, %xmm1; \ + movdqa %xmm0, %xmm4; \ + paddd %xmm1, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $9, %xmm4; \ + psrld $23, %xmm5; \ + pxor %xmm4, %xmm2; \ + movdqa %xmm1, %xmm4; \ + pshufd $0x93, %xmm1, %xmm1; \ + pxor %xmm5, %xmm2; \ + paddd %xmm2, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $13, %xmm4; \ + psrld $19, %xmm5; \ + pxor %xmm4, %xmm3; \ + movdqa %xmm2, %xmm4; \ + pshufd $0x4e, %xmm2, %xmm2; \ + pxor %xmm5, %xmm3; \ + paddd %xmm3, %xmm4; \ + movdqa %xmm4, %xmm5; \ + pslld $18, %xmm4; \ + psrld $14, %xmm5; \ + pxor %xmm4, %xmm0; \ + pshufd $0x39, %xmm3, %xmm3; \ + pxor %xmm5, %xmm0; \ + + +#define xmm_salsa8_core() \ + xmm_salsa8_core_doubleround(); \ + xmm_salsa8_core_doubleround(); \ + xmm_salsa8_core_doubleround(); \ + xmm_salsa8_core_doubleround(); \ + + + .align 32 +xmm_scrypt_core: + # shuffle 1st block into %xmm8-%xmm11 + movl 60(%rdi), %edx + movl 44(%rdi), %ecx + movl 28(%rdi), %ebx + movl 12(%rdi), %eax + movd %edx, %xmm0 + movd %ecx, %xmm1 + movd %ebx, %xmm2 + movd %eax, %xmm3 + movl 40(%rdi), %ecx + movl 24(%rdi), %ebx + movl 8(%rdi), %eax + movl 56(%rdi), %edx + pshufd $0x93, %xmm0, %xmm0 + pshufd $0x93, %xmm1, %xmm1 + pshufd $0x93, %xmm2, %xmm2 + pshufd $0x93, %xmm3, %xmm3 + movd %ecx, %xmm4 + movd %ebx, %xmm5 + movd %eax, %xmm6 + movd %edx, %xmm7 + paddd %xmm4, %xmm0 + paddd %xmm5, %xmm1 + paddd %xmm6, %xmm2 + paddd %xmm7, %xmm3 + movl 20(%rdi), %ebx + movl 4(%rdi), %eax + movl 52(%rdi), %edx + movl 36(%rdi), %ecx + pshufd $0x93, %xmm0, %xmm0 + pshufd $0x93, %xmm1, %xmm1 + pshufd $0x93, %xmm2, %xmm2 + pshufd $0x93, %xmm3, %xmm3 + movd %ebx, %xmm4 + movd %eax, %xmm5 + movd %edx, %xmm6 + movd %ecx, %xmm7 + paddd %xmm4, %xmm0 + paddd %xmm5, %xmm1 + paddd %xmm6, %xmm2 + paddd %xmm7, %xmm3 + movl 0(%rdi), %eax + movl 48(%rdi), %edx + movl 32(%rdi), %ecx + movl 16(%rdi), %ebx + pshufd $0x93, %xmm0, %xmm0 + pshufd $0x93, %xmm1, %xmm1 + pshufd $0x93, %xmm2, %xmm2 + pshufd $0x93, %xmm3, %xmm3 + movd %eax, %xmm8 + movd %edx, %xmm9 + movd %ecx, %xmm10 + movd %ebx, %xmm11 + paddd %xmm0, %xmm8 + paddd %xmm1, %xmm9 + paddd %xmm2, %xmm10 + paddd %xmm3, %xmm11 + + # shuffle 2nd block into %xmm12-%xmm15 + movl 124(%rdi), %edx + movl 108(%rdi), %ecx + movl 92(%rdi), %ebx + movl 76(%rdi), %eax + movd %edx, %xmm0 + movd %ecx, %xmm1 + movd %ebx, %xmm2 + movd %eax, %xmm3 + movl 104(%rdi), %ecx + movl 88(%rdi), %ebx + movl 72(%rdi), %eax + movl 120(%rdi), %edx + pshufd $0x93, %xmm0, %xmm0 + pshufd $0x93, %xmm1, %xmm1 + pshufd $0x93, %xmm2, %xmm2 + pshufd $0x93, %xmm3, %xmm3 + movd %ecx, %xmm4 + movd %ebx, %xmm5 + movd %eax, %xmm6 + movd %edx, %xmm7 + paddd %xmm4, %xmm0 + paddd %xmm5, %xmm1 + paddd %xmm6, %xmm2 + paddd %xmm7, %xmm3 + movl 84(%rdi), %ebx + movl 68(%rdi), %eax + movl 116(%rdi), %edx + movl 100(%rdi), %ecx + pshufd $0x93, %xmm0, %xmm0 + pshufd $0x93, %xmm1, %xmm1 + pshufd $0x93, %xmm2, %xmm2 + pshufd $0x93, %xmm3, %xmm3 + movd %ebx, %xmm4 + movd %eax, %xmm5 + movd %edx, %xmm6 + movd %ecx, %xmm7 + paddd %xmm4, %xmm0 + paddd %xmm5, %xmm1 + paddd %xmm6, %xmm2 + paddd %xmm7, %xmm3 + movl 64(%rdi), %eax + movl 112(%rdi), %edx + movl 96(%rdi), %ecx + movl 80(%rdi), %ebx + pshufd $0x93, %xmm0, %xmm0 + pshufd $0x93, %xmm1, %xmm1 + pshufd $0x93, %xmm2, %xmm2 + pshufd $0x93, %xmm3, %xmm3 + movd %eax, %xmm12 + movd %edx, %xmm13 + movd %ecx, %xmm14 + movd %ebx, %xmm15 + paddd %xmm0, %xmm12 + paddd %xmm1, %xmm13 + paddd %xmm2, %xmm14 + paddd %xmm3, %xmm15 + + movq %rsi, %rdx + leaq 131072(%rsi), %rcx +xmm_scrypt_core_loop1: + movdqa %xmm8, 0(%rdx) + movdqa %xmm9, 16(%rdx) + movdqa %xmm10, 32(%rdx) + movdqa %xmm11, 48(%rdx) + movdqa %xmm12, 64(%rdx) + movdqa %xmm13, 80(%rdx) + movdqa %xmm14, 96(%rdx) + movdqa %xmm15, 112(%rdx) + + pxor %xmm12, %xmm8 + pxor %xmm13, %xmm9 + pxor %xmm14, %xmm10 + pxor %xmm15, %xmm11 + movdqa %xmm8, %xmm0 + movdqa %xmm9, %xmm1 + movdqa %xmm10, %xmm2 + movdqa %xmm11, %xmm3 + xmm_salsa8_core() + paddd %xmm0, %xmm8 + paddd %xmm1, %xmm9 + paddd %xmm2, %xmm10 + paddd %xmm3, %xmm11 + + pxor %xmm8, %xmm12 + pxor %xmm9, %xmm13 + pxor %xmm10, %xmm14 + pxor %xmm11, %xmm15 + movdqa %xmm12, %xmm0 + movdqa %xmm13, %xmm1 + movdqa %xmm14, %xmm2 + movdqa %xmm15, %xmm3 + xmm_salsa8_core() + paddd %xmm0, %xmm12 + paddd %xmm1, %xmm13 + paddd %xmm2, %xmm14 + paddd %xmm3, %xmm15 + + addq $128, %rdx + cmpq %rcx, %rdx + jne xmm_scrypt_core_loop1 + + movq $1024, %rcx +xmm_scrypt_core_loop2: + movd %xmm12, %edx + andl $1023, %edx + shll $7, %edx + movdqa 0(%rsi, %rdx), %xmm0 + movdqa 16(%rsi, %rdx), %xmm1 + movdqa 32(%rsi, %rdx), %xmm2 + movdqa 48(%rsi, %rdx), %xmm3 + movdqa 64(%rsi, %rdx), %xmm4 + movdqa 80(%rsi, %rdx), %xmm5 + movdqa 96(%rsi, %rdx), %xmm6 + movdqa 112(%rsi, %rdx), %xmm7 + pxor %xmm0, %xmm8 + pxor %xmm1, %xmm9 + pxor %xmm2, %xmm10 + pxor %xmm3, %xmm11 + pxor %xmm4, %xmm12 + pxor %xmm5, %xmm13 + pxor %xmm6, %xmm14 + pxor %xmm7, %xmm15 + + pxor %xmm12, %xmm8 + pxor %xmm13, %xmm9 + pxor %xmm14, %xmm10 + pxor %xmm15, %xmm11 + movdqa %xmm8, %xmm0 + movdqa %xmm9, %xmm1 + movdqa %xmm10, %xmm2 + movdqa %xmm11, %xmm3 + xmm_salsa8_core() + paddd %xmm0, %xmm8 + paddd %xmm1, %xmm9 + paddd %xmm2, %xmm10 + paddd %xmm3, %xmm11 + + pxor %xmm8, %xmm12 + pxor %xmm9, %xmm13 + pxor %xmm10, %xmm14 + pxor %xmm11, %xmm15 + movdqa %xmm12, %xmm0 + movdqa %xmm13, %xmm1 + movdqa %xmm14, %xmm2 + movdqa %xmm15, %xmm3 + xmm_salsa8_core() + paddd %xmm0, %xmm12 + paddd %xmm1, %xmm13 + paddd %xmm2, %xmm14 + paddd %xmm3, %xmm15 + + subq $1, %rcx + ja xmm_scrypt_core_loop2 + + # re-shuffle 1st block back + movd %xmm8, %eax + movd %xmm9, %edx + movd %xmm10, %ecx + movd %xmm11, %ebx + pshufd $0x39, %xmm8, %xmm8 + pshufd $0x39, %xmm9, %xmm9 + pshufd $0x39, %xmm10, %xmm10 + pshufd $0x39, %xmm11, %xmm11 + movl %eax, 0(%rdi) + movl %edx, 48(%rdi) + movl %ecx, 32(%rdi) + movl %ebx, 16(%rdi) + movd %xmm8, %ebx + movd %xmm9, %eax + movd %xmm10, %edx + movd %xmm11, %ecx + pshufd $0x39, %xmm8, %xmm8 + pshufd $0x39, %xmm9, %xmm9 + pshufd $0x39, %xmm10, %xmm10 + pshufd $0x39, %xmm11, %xmm11 + movl %ebx, 20(%rdi) + movl %eax, 4(%rdi) + movl %edx, 52(%rdi) + movl %ecx, 36(%rdi) + movd %xmm8, %ecx + movd %xmm9, %ebx + movd %xmm10, %eax + movd %xmm11, %edx + pshufd $0x39, %xmm8, %xmm8 + pshufd $0x39, %xmm9, %xmm9 + pshufd $0x39, %xmm10, %xmm10 + pshufd $0x39, %xmm11, %xmm11 + movl %ecx, 40(%rdi) + movl %ebx, 24(%rdi) + movl %eax, 8(%rdi) + movl %edx, 56(%rdi) + movd %xmm8, %edx + movd %xmm9, %ecx + movd %xmm10, %ebx + movd %xmm11, %eax + movl %edx, 60(%rdi) + movl %ecx, 44(%rdi) + movl %ebx, 28(%rdi) + movl %eax, 12(%rdi) + + # re-shuffle 2nd block back + movd %xmm12, %eax + movd %xmm13, %edx + movd %xmm14, %ecx + movd %xmm15, %ebx + pshufd $0x39, %xmm12, %xmm12 + pshufd $0x39, %xmm13, %xmm13 + pshufd $0x39, %xmm14, %xmm14 + pshufd $0x39, %xmm15, %xmm15 + movl %eax, 64(%rdi) + movl %edx, 112(%rdi) + movl %ecx, 96(%rdi) + movl %ebx, 80(%rdi) + movd %xmm12, %ebx + movd %xmm13, %eax + movd %xmm14, %edx + movd %xmm15, %ecx + pshufd $0x39, %xmm12, %xmm12 + pshufd $0x39, %xmm13, %xmm13 + pshufd $0x39, %xmm14, %xmm14 + pshufd $0x39, %xmm15, %xmm15 + movl %ebx, 84(%rdi) + movl %eax, 68(%rdi) + movl %edx, 116(%rdi) + movl %ecx, 100(%rdi) + movd %xmm12, %ecx + movd %xmm13, %ebx + movd %xmm14, %eax + movd %xmm15, %edx + pshufd $0x39, %xmm12, %xmm12 + pshufd $0x39, %xmm13, %xmm13 + pshufd $0x39, %xmm14, %xmm14 + pshufd $0x39, %xmm15, %xmm15 + movl %ecx, 104(%rdi) + movl %ebx, 88(%rdi) + movl %eax, 72(%rdi) + movl %edx, 120(%rdi) + movd %xmm12, %edx + movd %xmm13, %ecx + movd %xmm14, %ebx + movd %xmm15, %eax + movl %edx, 124(%rdi) + movl %ecx, 108(%rdi) + movl %ebx, 92(%rdi) + movl %eax, 76(%rdi) + + scrypt_core_cleanup() + ret + + addq $392, %rsp +#if defined(WIN64) + popq %rsi + popq %rdi + movdqa 8(%rsp), %xmm6 + movdqa 24(%rsp), %xmm7 + movdqa 40(%rsp), %xmm8 + movdqa 56(%rsp), %xmm9 + movdqa 72(%rsp), %xmm10 + movdqa 88(%rsp), %xmm11 + movdqa 104(%rsp), %xmm12 + movdqa 120(%rsp), %xmm13 + movdqa 136(%rsp), %xmm14 + movdqa 152(%rsp), %xmm15 + addq $176, %rsp +#endif + popq %rbp + popq %rbx + ret + +#endif \ No newline at end of file diff --git a/src/scrypt.cpp b/src/scrypt.cpp new file mode 100644 index 0000000..06ef53c --- /dev/null +++ b/src/scrypt.cpp @@ -0,0 +1,198 @@ +/*- + * Copyright 2009 Colin Percival, 2011 ArtForz, 2011 pooler, 2013 Balthazar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file was originally written by Colin Percival as part of the Tarsnap + * online backup system. + */ + +#include +#include + +#include "scrypt.h" +#include "pbkdf2.h" + +#include "util.h" +#include "net.h" + +#define SCRYPT_BUFFER_SIZE (131072 + 63) + +#if defined (OPTIMIZED_SALSA) && ( defined (__x86_64__) || defined (__i386__) || defined(__arm__) ) +extern "C" void scrypt_core(unsigned int *X, unsigned int *V); +#else +// Generic scrypt_core implementation + +static inline void xor_salsa8(unsigned int B[16], const unsigned int Bx[16]) +{ + unsigned int x00,x01,x02,x03,x04,x05,x06,x07,x08,x09,x10,x11,x12,x13,x14,x15; + int i; + + x00 = (B[0] ^= Bx[0]); + x01 = (B[1] ^= Bx[1]); + x02 = (B[2] ^= Bx[2]); + x03 = (B[3] ^= Bx[3]); + x04 = (B[4] ^= Bx[4]); + x05 = (B[5] ^= Bx[5]); + x06 = (B[6] ^= Bx[6]); + x07 = (B[7] ^= Bx[7]); + x08 = (B[8] ^= Bx[8]); + x09 = (B[9] ^= Bx[9]); + x10 = (B[10] ^= Bx[10]); + x11 = (B[11] ^= Bx[11]); + x12 = (B[12] ^= Bx[12]); + x13 = (B[13] ^= Bx[13]); + x14 = (B[14] ^= Bx[14]); + x15 = (B[15] ^= Bx[15]); + for (i = 0; i < 8; i += 2) { +#define R(a, b) (((a) << (b)) | ((a) >> (32 - (b)))) + /* Operate on columns. */ + x04 ^= R(x00+x12, 7); x09 ^= R(x05+x01, 7); + x14 ^= R(x10+x06, 7); x03 ^= R(x15+x11, 7); + + x08 ^= R(x04+x00, 9); x13 ^= R(x09+x05, 9); + x02 ^= R(x14+x10, 9); x07 ^= R(x03+x15, 9); + + x12 ^= R(x08+x04,13); x01 ^= R(x13+x09,13); + x06 ^= R(x02+x14,13); x11 ^= R(x07+x03,13); + + x00 ^= R(x12+x08,18); x05 ^= R(x01+x13,18); + x10 ^= R(x06+x02,18); x15 ^= R(x11+x07,18); + + /* Operate on rows. */ + x01 ^= R(x00+x03, 7); x06 ^= R(x05+x04, 7); + x11 ^= R(x10+x09, 7); x12 ^= R(x15+x14, 7); + + x02 ^= R(x01+x00, 9); x07 ^= R(x06+x05, 9); + x08 ^= R(x11+x10, 9); x13 ^= R(x12+x15, 9); + + x03 ^= R(x02+x01,13); x04 ^= R(x07+x06,13); + x09 ^= R(x08+x11,13); x14 ^= R(x13+x12,13); + + x00 ^= R(x03+x02,18); x05 ^= R(x04+x07,18); + x10 ^= R(x09+x08,18); x15 ^= R(x14+x13,18); +#undef R + } + B[0] += x00; + B[1] += x01; + B[2] += x02; + B[3] += x03; + B[4] += x04; + B[5] += x05; + B[6] += x06; + B[7] += x07; + B[8] += x08; + B[9] += x09; + B[10] += x10; + B[11] += x11; + B[12] += x12; + B[13] += x13; + B[14] += x14; + B[15] += x15; +} + +static inline void scrypt_core(unsigned int *X, unsigned int *V) +{ + unsigned int i, j, k; + + for (i = 0; i < 1024; i++) { + memcpy(&V[i * 32], X, 128); + xor_salsa8(&X[0], &X[16]); + xor_salsa8(&X[16], &X[0]); + } + for (i = 0; i < 1024; i++) { + j = 32 * (X[16] & 1023); + for (k = 0; k < 32; k++) + X[k] ^= V[j + k]; + xor_salsa8(&X[0], &X[16]); + xor_salsa8(&X[16], &X[0]); + } +} + +#endif + +/* cpu and memory intensive function to transform a 80 byte buffer into a 32 byte output + scratchpad size needs to be at least 63 + (128 * r * p) + (256 * r + 64) + (128 * r * N) bytes + r = 1, p = 1, N = 1024 + */ + +uint256 scrypt_nosalt(const void* input, size_t inputlen, void *scratchpad) +{ + unsigned int *V; + unsigned int X[32]; + uint256 result = 0; + V = (unsigned int *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63)); + + PBKDF2_SHA256((const uint8_t*)input, inputlen, (const uint8_t*)input, inputlen, 1, (uint8_t *)X, 128); + scrypt_core(X, V); + PBKDF2_SHA256((const uint8_t*)input, inputlen, (uint8_t *)X, 128, 1, (uint8_t*)&result, 32); + + return result; +} + +uint256 scrypt(const void* data, size_t datalen, const void* salt, size_t saltlen, void *scratchpad) +{ + unsigned int *V; + unsigned int X[32]; + uint256 result = 0; + V = (unsigned int *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63)); + + PBKDF2_SHA256((const uint8_t*)data, datalen, (const uint8_t*)salt, saltlen, 1, (uint8_t *)X, 128); + scrypt_core(X, V); + PBKDF2_SHA256((const uint8_t*)data, datalen, (uint8_t *)X, 128, 1, (uint8_t*)&result, 32); + + return result; +} + +uint256 scrypt_hash(const void* input, size_t inputlen) +{ + unsigned char scratchpad[SCRYPT_BUFFER_SIZE]; + return scrypt_nosalt(input, inputlen, scratchpad); +} + +uint256 scrypt_salted_hash(const void* input, size_t inputlen, const void* salt, size_t saltlen) +{ + unsigned char scratchpad[SCRYPT_BUFFER_SIZE]; + return scrypt(input, inputlen, salt, saltlen, scratchpad); +} + +uint256 scrypt_salted_multiround_hash(const void* input, size_t inputlen, const void* salt, size_t saltlen, const unsigned int nRounds) +{ + uint256 resultHash = scrypt_salted_hash(input, inputlen, salt, saltlen); + uint256 transitionalHash = resultHash; + + for(unsigned int i = 1; i < nRounds; i++) + { + resultHash = scrypt_salted_hash(input, inputlen, (const void*)&transitionalHash, 32); + transitionalHash = resultHash; + } + + return resultHash; +} + +uint256 scrypt_blockhash(const void* input) +{ + unsigned char scratchpad[SCRYPT_BUFFER_SIZE]; + return scrypt_nosalt(input, 80, scratchpad); +} + diff --git a/src/scrypt.h b/src/scrypt.h new file mode 100644 index 0000000..17afd85 --- /dev/null +++ b/src/scrypt.h @@ -0,0 +1,15 @@ +#ifndef SCRYPT_MINE_H +#define SCRYPT_MINE_H + +#include +#include + +#include "util.h" +#include "net.h" + +uint256 scrypt_salted_multiround_hash(const void* input, size_t inputlen, const void* salt, size_t saltlen, const unsigned int nRounds); +uint256 scrypt_salted_hash(const void* input, size_t inputlen, const void* salt, size_t saltlen); +uint256 scrypt_hash(const void* input, size_t inputlen); +uint256 scrypt_blockhash(const void* input); + +#endif // SCRYPT_MINE_H diff --git a/src/secp256k1/.gitignore b/src/secp256k1/.gitignore new file mode 100644 index 0000000..298bdb5 --- /dev/null +++ b/src/secp256k1/.gitignore @@ -0,0 +1,40 @@ +bench_inv +bench_ecdh +bench_sign +bench_verify +bench_schnorr_verify +bench_recover +bench_internal +tests +gen_context +*.exe +*.so +*.a +!.gitignore + +Makefile +configure +.libs/ +Makefile.in +aclocal.m4 +autom4te.cache/ +config.log +config.status +*.tar.gz +*.la +libtool +.deps/ +.dirstamp +*.lo +*.o +*~ +src/libsecp256k1-config.h +src/libsecp256k1-config.h.in +src/ecmult_static_context.h +m4/libtool.m4 +m4/ltoptions.m4 +m4/ltsugar.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 +src/stamp-h1 +libsecp256k1.pc diff --git a/src/secp256k1/.travis.yml b/src/secp256k1/.travis.yml new file mode 100644 index 0000000..3540d17 --- /dev/null +++ b/src/secp256k1/.travis.yml @@ -0,0 +1,63 @@ +language: c +sudo: false +addons: + apt: + packages: libgmp-dev +compiler: + - clang + - gcc +env: + global: + - FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no schnorr=no RECOVERY=no EXPERIMENTAL=no + matrix: + - SCALAR=32bit RECOVERY=yes + - SCALAR=32bit FIELD=32bit ECDH=yes EXPERIMENTAL=yes + - SCALAR=64bit + - FIELD=64bit RECOVERY=yes + - FIELD=64bit ENDOMORPHISM=yes + - FIELD=64bit ENDOMORPHISM=yes ECDH=yes EXPERIMENTAL=yes + - FIELD=64bit ASM=x86_64 + - FIELD=64bit ENDOMORPHISM=yes ASM=x86_64 + - FIELD=32bit SCHNORR=yes EXPERIMENTAL=yes + - FIELD=32bit ENDOMORPHISM=yes + - BIGNUM=no + - BIGNUM=no ENDOMORPHISM=yes SCHNORR=yes RECOVERY=yes EXPERIMENTAL=yes + - BIGNUM=no STATICPRECOMPUTATION=no + - BUILD=distcheck + - EXTRAFLAGS=CPPFLAGS=-DDETERMINISTIC + - EXTRAFLAGS=CFLAGS=-O0 +matrix: + fast_finish: true + include: + - compiler: clang + env: HOST=i686-linux-gnu ENDOMORPHISM=yes + addons: + apt: + packages: + - gcc-multilib + - libgmp-dev:i386 + - compiler: clang + env: HOST=i686-linux-gnu + addons: + apt: + packages: + - gcc-multilib + - compiler: gcc + env: HOST=i686-linux-gnu ENDOMORPHISM=yes + addons: + apt: + packages: + - gcc-multilib + - compiler: gcc + env: HOST=i686-linux-gnu + addons: + apt: + packages: + - gcc-multilib + - libgmp-dev:i386 +before_script: ./autogen.sh +script: + - if [ -n "$HOST" ]; then export USE_HOST="--host=$HOST"; fi + - if [ "x$HOST" = "xi686-linux-gnu" ]; then export CC="$CC -m32"; fi + - ./configure --enable-experimental=$EXPERIMENTAL --enable-endomorphism=$ENDOMORPHISM --with-field=$FIELD --with-bignum=$BIGNUM --with-scalar=$SCALAR --enable-ecmult-static-precomputation=$STATICPRECOMPUTATION --enable-module-ecdh=$ECDH --enable-module-schnorr=$SCHNORR --enable-module-recovery=$RECOVERY $EXTRAFLAGS $USE_HOST && make -j2 $BUILD +os: linux diff --git a/src/secp256k1/COPYING b/src/secp256k1/COPYING new file mode 100644 index 0000000..4522a59 --- /dev/null +++ b/src/secp256k1/COPYING @@ -0,0 +1,19 @@ +Copyright (c) 2013 Pieter Wuille + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/secp256k1/Makefile.am b/src/secp256k1/Makefile.am new file mode 100644 index 0000000..41fc09f --- /dev/null +++ b/src/secp256k1/Makefile.am @@ -0,0 +1,111 @@ +ACLOCAL_AMFLAGS = -I build-aux/m4 + +lib_LTLIBRARIES = libsecp256k1.la +include_HEADERS = include/secp256k1.h +noinst_HEADERS = +noinst_HEADERS += src/scalar.h +noinst_HEADERS += src/scalar_4x64.h +noinst_HEADERS += src/scalar_8x32.h +noinst_HEADERS += src/scalar_impl.h +noinst_HEADERS += src/scalar_4x64_impl.h +noinst_HEADERS += src/scalar_8x32_impl.h +noinst_HEADERS += src/group.h +noinst_HEADERS += src/group_impl.h +noinst_HEADERS += src/num_gmp.h +noinst_HEADERS += src/num_gmp_impl.h +noinst_HEADERS += src/ecdsa.h +noinst_HEADERS += src/ecdsa_impl.h +noinst_HEADERS += src/eckey.h +noinst_HEADERS += src/eckey_impl.h +noinst_HEADERS += src/ecmult.h +noinst_HEADERS += src/ecmult_impl.h +noinst_HEADERS += src/ecmult_const.h +noinst_HEADERS += src/ecmult_const_impl.h +noinst_HEADERS += src/ecmult_gen.h +noinst_HEADERS += src/ecmult_gen_impl.h +noinst_HEADERS += src/num.h +noinst_HEADERS += src/num_impl.h +noinst_HEADERS += src/field_10x26.h +noinst_HEADERS += src/field_10x26_impl.h +noinst_HEADERS += src/field_5x52.h +noinst_HEADERS += src/field_5x52_impl.h +noinst_HEADERS += src/field_5x52_int128_impl.h +noinst_HEADERS += src/field_5x52_asm_impl.h +noinst_HEADERS += src/java/org_bitcoin_NativeSecp256k1.h +noinst_HEADERS += src/util.h +noinst_HEADERS += src/testrand.h +noinst_HEADERS += src/testrand_impl.h +noinst_HEADERS += src/hash.h +noinst_HEADERS += src/hash_impl.h +noinst_HEADERS += src/field.h +noinst_HEADERS += src/field_impl.h +noinst_HEADERS += src/bench.h +noinst_HEADERS += contrib/lax_der_parsing.h +noinst_HEADERS += contrib/lax_der_parsing.c +noinst_HEADERS += contrib/lax_der_privatekey_parsing.h +noinst_HEADERS += contrib/lax_der_privatekey_parsing.c + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libsecp256k1.pc + +libsecp256k1_la_SOURCES = src/secp256k1.c +libsecp256k1_la_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) +libsecp256k1_la_LIBADD = $(SECP_LIBS) + + +noinst_PROGRAMS = +if USE_BENCHMARK +noinst_PROGRAMS += bench_verify bench_sign bench_internal +bench_verify_SOURCES = src/bench_verify.c +bench_verify_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) +bench_sign_SOURCES = src/bench_sign.c +bench_sign_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) +bench_internal_SOURCES = src/bench_internal.c +bench_internal_LDADD = $(SECP_LIBS) +bench_internal_CPPFLAGS = $(SECP_INCLUDES) +endif + +if USE_TESTS +noinst_PROGRAMS += tests +tests_SOURCES = src/tests.c +tests_CPPFLAGS = -DVERIFY -I$(top_srcdir)/src -I$(top_srcdir)/include $(SECP_INCLUDES) $(SECP_TEST_INCLUDES) +tests_LDADD = $(SECP_LIBS) $(SECP_TEST_LIBS) +tests_LDFLAGS = -static +TESTS = tests +endif + +if USE_ECMULT_STATIC_PRECOMPUTATION +CPPFLAGS_FOR_BUILD +=-I$(top_srcdir) +CFLAGS_FOR_BUILD += -Wall -Wextra -Wno-unused-function + +gen_context_OBJECTS = gen_context.o +gen_context_BIN = gen_context$(BUILD_EXEEXT) +gen_%.o: src/gen_%.c + $(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -c $< -o $@ + +$(gen_context_BIN): $(gen_context_OBJECTS) + $(CC_FOR_BUILD) $^ -o $@ + +$(libsecp256k1_la_OBJECTS): src/ecmult_static_context.h +$(tests_OBJECTS): src/ecmult_static_context.h +$(bench_internal_OBJECTS): src/ecmult_static_context.h + +src/ecmult_static_context.h: $(gen_context_BIN) + ./$(gen_context_BIN) + +CLEANFILES = $(gen_context_BIN) src/ecmult_static_context.h +endif + +EXTRA_DIST = autogen.sh src/gen_context.c src/basic-config.h + +if ENABLE_MODULE_ECDH +include src/modules/ecdh/Makefile.am.include +endif + +if ENABLE_MODULE_SCHNORR +include src/modules/schnorr/Makefile.am.include +endif + +if ENABLE_MODULE_RECOVERY +include src/modules/recovery/Makefile.am.include +endif diff --git a/src/secp256k1/README.md b/src/secp256k1/README.md new file mode 100644 index 0000000..6095db4 --- /dev/null +++ b/src/secp256k1/README.md @@ -0,0 +1,61 @@ +libsecp256k1 +============ + +[![Build Status](https://travis-ci.org/bitcoin/secp256k1.svg?branch=master)](https://travis-ci.org/bitcoin/secp256k1) + +Optimized C library for EC operations on curve secp256k1. + +This library is a work in progress and is being used to research best practices. Use at your own risk. + +Features: +* secp256k1 ECDSA signing/verification and key generation. +* Adding/multiplying private/public keys. +* Serialization/parsing of private keys, public keys, signatures. +* Constant time, constant memory access signing and pubkey generation. +* Derandomized DSA (via RFC6979 or with a caller provided function.) +* Very efficient implementation. + +Implementation details +---------------------- + +* General + * No runtime heap allocation. + * Extensive testing infrastructure. + * Structured to facilitate review and analysis. + * Intended to be portable to any system with a C89 compiler and uint64_t support. + * Expose only higher level interfaces to minimize the API surface and improve application security. ("Be difficult to use insecurely.") +* Field operations + * Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1). + * Using 5 52-bit limbs (including hand-optimized assembly for x86_64, by Diederik Huys). + * Using 10 26-bit limbs. + * Field inverses and square roots using a sliding window over blocks of 1s (by Peter Dettman). +* Scalar operations + * Optimized implementation without data-dependent branches of arithmetic modulo the curve's order. + * Using 4 64-bit limbs (relying on __int128 support in the compiler). + * Using 8 32-bit limbs. +* Group operations + * Point addition formula specifically simplified for the curve equation (y^2 = x^3 + 7). + * Use addition between points in Jacobian and affine coordinates where possible. + * Use a unified addition/doubling formula where necessary to avoid data-dependent branches. + * Point/x comparison without a field inversion by comparison in the Jacobian coordinate space. +* Point multiplication for verification (a*P + b*G). + * Use wNAF notation for point multiplicands. + * Use a much larger window for multiples of G, using precomputed multiples. + * Use Shamir's trick to do the multiplication with the public key and the generator simultaneously. + * Optionally (off by default) use secp256k1's efficiently-computable endomorphism to split the P multiplicand into 2 half-sized ones. +* Point multiplication for signing + * Use a precomputed table of multiples of powers of 16 multiplied with the generator, so general multiplication becomes a series of additions. + * Access the table with branch-free conditional moves so memory access is uniform. + * No data-dependent branches + * The precomputed tables add and eventually subtract points for which no known scalar (private key) is known, preventing even an attacker with control over the private key used to control the data internally. + +Build steps +----------- + +libsecp256k1 is built using autotools: + + $ ./autogen.sh + $ ./configure + $ make + $ ./tests + $ sudo make install # optional diff --git a/src/secp256k1/TODO b/src/secp256k1/TODO new file mode 100644 index 0000000..a300e1c --- /dev/null +++ b/src/secp256k1/TODO @@ -0,0 +1,3 @@ +* Unit tests for fieldelem/groupelem, including ones intended to + trigger fieldelem's boundary cases. +* Complete constant-time operations for signing/keygen diff --git a/src/secp256k1/autogen.sh b/src/secp256k1/autogen.sh new file mode 100644 index 0000000..65286b9 --- /dev/null +++ b/src/secp256k1/autogen.sh @@ -0,0 +1,3 @@ +#!/bin/sh +set -e +autoreconf -if --warnings=all diff --git a/src/secp256k1/build-aux/compile b/src/secp256k1/build-aux/compile new file mode 100644 index 0000000..a85b723 --- /dev/null +++ b/src/secp256k1/build-aux/compile @@ -0,0 +1,347 @@ +#! /bin/sh +# Wrapper for compilers which do not understand '-c -o'. + +scriptversion=2012-10-14.11; # UTC + +# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + if test -f "$dir/lib$lib.a"; then + found=yes + lib=$dir/lib$lib.a + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file 'INSTALL'. + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; +esac + +ofile= +cfile= + +for arg +do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. + eat=1 + case $2 in + *.o | *.obj) + ofile=$2 + ;; + *) + set x "$@" -o "$2" + shift + ;; + esac + ;; + *.c) + cfile=$1 + set x "$@" "$1" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no '-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # '.c' file was seen then we are probably linking. That is also + # ok. + exec "$@" +fi + +# Name of file we expect compiler to create. +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` + +# Create the lock directory. +# Note: use '[/\\:.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d +while true; do + if mkdir "$lockdir" >/dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir '$lockdir'; exit 1" 1 2 15 + +# Run the compile. +"$@" +ret=$? + +if test -f "$cofile"; then + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" +elif test -f "${cofile}bj"; then + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" +fi + +rmdir "$lockdir" +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/secp256k1/build-aux/config.guess b/src/secp256k1/build-aux/config.guess new file mode 100644 index 0000000..1659250 --- /dev/null +++ b/src/secp256k1/build-aux/config.guess @@ -0,0 +1,1441 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2015 Free Software Foundation, Inc. + +timestamp='2015-08-20' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# +# Please send patches to . + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2015 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + /sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || \ + echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown + ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case "${UNAME_MACHINE_ARCH}" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}${abi}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:Sortix:*:*) + echo ${UNAME_MACHINE}-unknown-sortix + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + *:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + e2k:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; +esac + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/src/secp256k1/build-aux/config.sub b/src/secp256k1/build-aux/config.sub new file mode 100644 index 0000000..1acc966 --- /dev/null +++ b/src/secp256k1/build-aux/config.sub @@ -0,0 +1,1813 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2015 Free Software Foundation, Inc. + +timestamp='2015-08-20' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2015 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze*) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | we32k \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | ba-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | e2k-* | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pyramid-* \ + | riscv32-* | riscv64-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + asmjs) + basic_machine=asmjs-unknown + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/src/secp256k1/build-aux/depcomp b/src/secp256k1/build-aux/depcomp new file mode 100644 index 0000000..fc98710 --- /dev/null +++ b/src/secp256k1/build-aux/depcomp @@ -0,0 +1,791 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2013-05-30.07; # UTC + +# Copyright (C) 1999-2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by 'PROGRAMS ARGS'. + object Object file output by 'PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputting dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +# Get the directory component of the given path, and save it in the +# global variables '$dir'. Note that this directory component will +# be either empty or ending with a '/' character. This is deliberate. +set_dir_from () +{ + case $1 in + */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; + *) dir=;; + esac +} + +# Get the suffix-stripped basename of the given path, and save it the +# global variable '$base'. +set_base_from () +{ + base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` +} + +# If no dependency file was actually created by the compiler invocation, +# we still have to create a dummy depfile, to avoid errors with the +# Makefile "include basename.Plo" scheme. +make_dummy_depfile () +{ + echo "#dummy" > "$depfile" +} + +# Factor out some common post-processing of the generated depfile. +# Requires the auxiliary global variable '$tmpdepfile' to be set. +aix_post_process_depfile () +{ + # If the compiler actually managed to produce a dependency file, + # post-process it. + if test -f "$tmpdepfile"; then + # Each line is of the form 'foo.o: dependency.h'. + # Do two passes, one to just change these to + # $object: dependency.h + # and one to simply output + # dependency.h: + # which is needed to avoid the deleted-header problem. + { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" + sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" + } > "$depfile" + rm -f "$tmpdepfile" + else + make_dummy_depfile + fi +} + +# A tabulation character. +tab=' ' +# A newline character. +nl=' +' +# Character ranges might be problematic outside the C locale. +# These definitions help. +upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ +lower=abcdefghijklmnopqrstuvwxyz +digits=0123456789 +alpha=${upper}${lower} + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Avoid interferences from the environment. +gccflag= dashmflag= + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +cygpath_u="cygpath -u -f -" +if test "$depmode" = msvcmsys; then + # This is just like msvisualcpp but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvisualcpp +fi + +if test "$depmode" = msvc7msys; then + # This is just like msvc7 but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvc7 +fi + +if test "$depmode" = xlc; then + # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. + gccflag=-qmakedep=gcc,-MF + depmode=gcc +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. +## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. +## (see the conditional assignment to $gccflag above). +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). Also, it might not be +## supported by the other compilers which use the 'gcc' depmode. +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The second -e expression handles DOS-style file names with drive + # letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the "deleted header file" problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. +## Some versions of gcc put a space before the ':'. On the theory +## that the space means something, we add a space to the output as +## well. hp depmode also adds that space, but also prefixes the VPATH +## to the object. Take care to not repeat it in the output. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like '#:fec' to the end of the + # dependency line. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ + | tr "$nl" ' ' >> "$depfile" + echo >> "$depfile" + # The second pass generates a dummy entry for each header file. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" + ;; + +xlc) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts '$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u + "$@" -Wc,-M + else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u + "$@" -M + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + aix_post_process_depfile + ;; + +tcc) + # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 + # FIXME: That version still under development at the moment of writing. + # Make that this statement remains true also for stable, released + # versions. + # It will wrap lines (doesn't matter whether long or short) with a + # trailing '\', as in: + # + # foo.o : \ + # foo.c \ + # foo.h \ + # + # It will put a trailing '\' even on the last line, and will use leading + # spaces rather than leading tabs (at least since its commit 0394caf7 + # "Emit spaces for -MD"). + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. + # We have to change lines of the first kind to '$object: \'. + sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" + # And for each line of the second kind, we have to emit a 'dep.h:' + # dummy dependency, to avoid the deleted-header problem. + sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" + rm -f "$tmpdepfile" + ;; + +## The order of this option in the case statement is important, since the +## shell code in configure will try each of these formats in the order +## listed in this file. A plain '-MD' option would be understood by many +## compilers, so we must ensure this comes after the gcc and icc options. +pgcc) + # Portland's C compiler understands '-MD'. + # Will always output deps to 'file.d' where file is the root name of the + # source file under compilation, even if file resides in a subdirectory. + # The object file name does not affect the name of the '.d' file. + # pgcc 10.2 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using '\' : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + set_dir_from "$object" + # Use the source, not the object, to determine the base name, since + # that's sadly what pgcc will do too. + set_base_from "$source" + tmpdepfile=$base.d + + # For projects that build the same source file twice into different object + # files, the pgcc approach of using the *source* file root name can cause + # problems in parallel builds. Use a locking strategy to avoid stomping on + # the same $tmpdepfile. + lockdir=$base.d-lock + trap " + echo '$0: caught signal, cleaning up...' >&2 + rmdir '$lockdir' + exit 1 + " 1 2 13 15 + numtries=100 + i=$numtries + while test $i -gt 0; do + # mkdir is a portable test-and-set. + if mkdir "$lockdir" 2>/dev/null; then + # This process acquired the lock. + "$@" -MD + stat=$? + # Release the lock. + rmdir "$lockdir" + break + else + # If the lock is being held by a different process, wait + # until the winning process is done or we timeout. + while test -d "$lockdir" && test $i -gt 0; do + sleep 1 + i=`expr $i - 1` + done + fi + i=`expr $i - 1` + done + trap - 1 2 13 15 + if test $i -le 0; then + echo "$0: failed to acquire lock after $numtries attempts" >&2 + echo "$0: check lockdir '$lockdir'" >&2 + exit 1 + fi + + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" + # Add 'dependent.h:' lines. + sed -ne '2,${ + s/^ *// + s/ \\*$// + s/$/:/ + p + }' "$tmpdepfile" >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in 'foo.d' instead, so we check for that too. + # Subdirectories are respected. + set_dir_from "$object" + set_base_from "$object" + + if test "$libtool" = yes; then + # Libtool generates 2 separate objects for the 2 libraries. These + # two compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir$base.o.d # libtool 1.5 + tmpdepfile2=$dir.libs/$base.o.d # Likewise. + tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + # Same post-processing that is required for AIX mode. + aix_post_process_depfile + ;; + +msvc7) + if test "$libtool" = yes; then + showIncludes=-Wc,-showIncludes + else + showIncludes=-showIncludes + fi + "$@" $showIncludes > "$tmpdepfile" + stat=$? + grep -v '^Note: including file: ' "$tmpdepfile" + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The first sed program below extracts the file names and escapes + # backslashes for cygpath. The second sed program outputs the file + # name when reading, but also accumulates all include files in the + # hold buffer in order to output them again at the end. This only + # works with sed implementations that can handle large buffers. + sed < "$tmpdepfile" -n ' +/^Note: including file: *\(.*\)/ { + s//\1/ + s/\\/\\\\/g + p +}' | $cygpath_u | sort -u | sed -n ' +s/ /\\ /g +s/\(.*\)/'"$tab"'\1 \\/p +s/.\(.*\) \\/\1:/ +H +$ { + s/.*/'"$tab"'/ + G + p +}' >> "$depfile" + echo >> "$depfile" # make sure the fragment doesn't end with a backslash + rm -f "$tmpdepfile" + ;; + +msvc7msys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for ':' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. + "$@" $dashmflag | + sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this sed invocation + # correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no eat=no + for arg + do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + if test $eat = yes; then + eat=no + continue + fi + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -arch) + eat=yes ;; + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix=`echo "$object" | sed 's/^.*\././'` + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. + sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process the last invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed '1,2d' "$tmpdepfile" \ + | tr ' ' "$nl" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E \ + | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + | sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + IFS=" " + for arg + do + case "$arg" in + -o) + shift + ;; + $object) + shift + ;; + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E 2>/dev/null | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" + echo "$tab" >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvcmsys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/secp256k1/build-aux/install-sh b/src/secp256k1/build-aux/install-sh new file mode 100644 index 0000000..59990a1 --- /dev/null +++ b/src/secp256k1/build-aux/install-sh @@ -0,0 +1,508 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2014-09-12.12; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# 'make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +tab=' ' +nl=' +' +IFS=" $tab$nl" + +# Set DOITPROG to "echo" to test this script. + +doit=${DOITPROG-} +doit_exec=${doit:-exec} + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +is_target_a_directory=possibly + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) is_target_a_directory=never;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call 'install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names problematic for 'test' and other utilities. + case $src in + -* | [=\(\)!]) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + dst=$dst_arg + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + dstdir=`dirname "$dst"` + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + # $RANDOM is not portable (e.g. dash); use it when possible to + # lower collision chance + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 + + # As "mkdir -p" follows symlinks and we work in /tmp possibly; so + # create the $tmpdir first (and fail if unsuccessful) to make sure + # that nobody tries to guess the $tmpdir name. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; + esac + + oIFS=$IFS + IFS=/ + set -f + set fnord $dstdir + shift + set +f + IFS=$oIFS + + prefixes= + + for d + do + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + set +f && + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/secp256k1/build-aux/ltmain.sh b/src/secp256k1/build-aux/ltmain.sh new file mode 100644 index 0000000..147d758 --- /dev/null +++ b/src/secp256k1/build-aux/ltmain.sh @@ -0,0 +1,11156 @@ +#! /bin/sh +## DO NOT EDIT - This file generated from ./build-aux/ltmain.in +## by inline-source v2014-01-03.01 + +# libtool (GNU libtool) 2.4.6 +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit , 1996 + +# Copyright (C) 1996-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +PROGRAM=libtool +PACKAGE=libtool +VERSION="2.4.6 Debian-2.4.6-0.1" +package_revision=2.4.6 + + +## ------ ## +## Usage. ## +## ------ ## + +# Run './libtool --help' for help with using this script from the +# command line. + + +## ------------------------------- ## +## User overridable command paths. ## +## ------------------------------- ## + +# After configure completes, it has a better idea of some of the +# shell tools we need than the defaults used by the functions shared +# with bootstrap, so set those here where they can still be over- +# ridden by the user, but otherwise take precedence. + +: ${AUTOCONF="autoconf"} +: ${AUTOMAKE="automake"} + + +## -------------------------- ## +## Source external libraries. ## +## -------------------------- ## + +# Much of our low-level functionality needs to be sourced from external +# libraries, which are installed to $pkgauxdir. + +# Set a version string for this script. +scriptversion=2015-01-20.17; # UTC + +# General shell script boiler plate, and helper functions. +# Written by Gary V. Vaughan, 2004 + +# Copyright (C) 2004-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# As a special exception to the GNU General Public License, if you distribute +# this file as part of a program or library that is built using GNU Libtool, +# you may include this file under the same distribution terms that you use +# for the rest of that program. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Please report bugs or propose patches to gary@gnu.org. + + +## ------ ## +## Usage. ## +## ------ ## + +# Evaluate this file near the top of your script to gain access to +# the functions and variables defined here: +# +# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh +# +# If you need to override any of the default environment variable +# settings, do that before evaluating this file. + + +## -------------------- ## +## Shell normalisation. ## +## -------------------- ## + +# Some shells need a little help to be as Bourne compatible as possible. +# Before doing anything else, make sure all that help has been provided! + +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac +fi + +# NLS nuisances: We save the old values in case they are required later. +_G_user_locale= +_G_safe_locale= +for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES +do + eval "if test set = \"\${$_G_var+set}\"; then + save_$_G_var=\$$_G_var + $_G_var=C + export $_G_var + _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" + _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" + fi" +done + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Make sure IFS has a sensible default +sp=' ' +nl=' +' +IFS="$sp $nl" + +# There are apparently some retarded systems that use ';' as a PATH separator! +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + + +## ------------------------- ## +## Locate command utilities. ## +## ------------------------- ## + + +# func_executable_p FILE +# ---------------------- +# Check that FILE is an executable regular file. +func_executable_p () +{ + test -f "$1" && test -x "$1" +} + + +# func_path_progs PROGS_LIST CHECK_FUNC [PATH] +# -------------------------------------------- +# Search for either a program that responds to --version with output +# containing "GNU", or else returned by CHECK_FUNC otherwise, by +# trying all the directories in PATH with each of the elements of +# PROGS_LIST. +# +# CHECK_FUNC should accept the path to a candidate program, and +# set $func_check_prog_result if it truncates its output less than +# $_G_path_prog_max characters. +func_path_progs () +{ + _G_progs_list=$1 + _G_check_func=$2 + _G_PATH=${3-"$PATH"} + + _G_path_prog_max=0 + _G_path_prog_found=false + _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} + for _G_dir in $_G_PATH; do + IFS=$_G_save_IFS + test -z "$_G_dir" && _G_dir=. + for _G_prog_name in $_G_progs_list; do + for _exeext in '' .EXE; do + _G_path_prog=$_G_dir/$_G_prog_name$_exeext + func_executable_p "$_G_path_prog" || continue + case `"$_G_path_prog" --version 2>&1` in + *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; + *) $_G_check_func $_G_path_prog + func_path_progs_result=$func_check_prog_result + ;; + esac + $_G_path_prog_found && break 3 + done + done + done + IFS=$_G_save_IFS + test -z "$func_path_progs_result" && { + echo "no acceptable sed could be found in \$PATH" >&2 + exit 1 + } +} + + +# We want to be able to use the functions in this file before configure +# has figured out where the best binaries are kept, which means we have +# to search for them ourselves - except when the results are already set +# where we skip the searches. + +# Unless the user overrides by setting SED, search the path for either GNU +# sed, or the sed that truncates its output the least. +test -z "$SED" && { + _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for _G_i in 1 2 3 4 5 6 7; do + _G_sed_script=$_G_sed_script$nl$_G_sed_script + done + echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed + _G_sed_script= + + func_check_prog_sed () + { + _G_path_prog=$1 + + _G_count=0 + printf 0123456789 >conftest.in + while : + do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo '' >> conftest.nl + "$_G_path_prog" -f conftest.sed conftest.out 2>/dev/null || break + diff conftest.out conftest.nl >/dev/null 2>&1 || break + _G_count=`expr $_G_count + 1` + if test "$_G_count" -gt "$_G_path_prog_max"; then + # Best one so far, save it but keep looking for a better one + func_check_prog_result=$_G_path_prog + _G_path_prog_max=$_G_count + fi + # 10*(2^10) chars as input seems more than enough + test 10 -lt "$_G_count" && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + + func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin + rm -f conftest.sed + SED=$func_path_progs_result +} + + +# Unless the user overrides by setting GREP, search the path for either GNU +# grep, or the grep that truncates its output the least. +test -z "$GREP" && { + func_check_prog_grep () + { + _G_path_prog=$1 + + _G_count=0 + _G_path_prog_max=0 + printf 0123456789 >conftest.in + while : + do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo 'GREP' >> conftest.nl + "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' conftest.out 2>/dev/null || break + diff conftest.out conftest.nl >/dev/null 2>&1 || break + _G_count=`expr $_G_count + 1` + if test "$_G_count" -gt "$_G_path_prog_max"; then + # Best one so far, save it but keep looking for a better one + func_check_prog_result=$_G_path_prog + _G_path_prog_max=$_G_count + fi + # 10*(2^10) chars as input seems more than enough + test 10 -lt "$_G_count" && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + + func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin + GREP=$func_path_progs_result +} + + +## ------------------------------- ## +## User overridable command paths. ## +## ------------------------------- ## + +# All uppercase variable names are used for environment variables. These +# variables can be overridden by the user before calling a script that +# uses them if a suitable command of that name is not already available +# in the command search PATH. + +: ${CP="cp -f"} +: ${ECHO="printf %s\n"} +: ${EGREP="$GREP -E"} +: ${FGREP="$GREP -F"} +: ${LN_S="ln -s"} +: ${MAKE="make"} +: ${MKDIR="mkdir"} +: ${MV="mv -f"} +: ${RM="rm -f"} +: ${SHELL="${CONFIG_SHELL-/bin/sh}"} + + +## -------------------- ## +## Useful sed snippets. ## +## -------------------- ## + +sed_dirname='s|/[^/]*$||' +sed_basename='s|^.*/||' + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s|\([`"$\\]\)|\\\1|g' + +# Same as above, but do not quote variable references. +sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution that turns a string into a regex matching for the +# string literally. +sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' + +# Sed substitution that converts a w32 file name or path +# that contains forward slashes, into one that contains +# (escaped) backslashes. A very naive implementation. +sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + +# Re-'\' parameter expansions in output of sed_double_quote_subst that +# were '\'-ed in input to the same. If an odd number of '\' preceded a +# '$' in input to sed_double_quote_subst, that '$' was protected from +# expansion. Since each input '\' is now two '\'s, look for any number +# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. +_G_bs='\\' +_G_bs2='\\\\' +_G_bs4='\\\\\\\\' +_G_dollar='\$' +sed_double_backslash="\ + s/$_G_bs4/&\\ +/g + s/^$_G_bs2$_G_dollar/$_G_bs&/ + s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g + s/\n//g" + + +## ----------------- ## +## Global variables. ## +## ----------------- ## + +# Except for the global variables explicitly listed below, the following +# functions in the '^func_' namespace, and the '^require_' namespace +# variables initialised in the 'Resource management' section, sourcing +# this file will not pollute your global namespace with anything +# else. There's no portable way to scope variables in Bourne shell +# though, so actually running these functions will sometimes place +# results into a variable named after the function, and often use +# temporary variables in the '^_G_' namespace. If you are careful to +# avoid using those namespaces casually in your sourcing script, things +# should continue to work as you expect. And, of course, you can freely +# overwrite any of the functions or variables defined here before +# calling anything to customize them. + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. +EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. + +# Allow overriding, eg assuming that you follow the convention of +# putting '$debug_cmd' at the start of all your functions, you can get +# bash to show function call trace with: +# +# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name +debug_cmd=${debug_cmd-":"} +exit_cmd=: + +# By convention, finish your script with: +# +# exit $exit_status +# +# so that you can set exit_status to non-zero if you want to indicate +# something went wrong during execution without actually bailing out at +# the point of failure. +exit_status=$EXIT_SUCCESS + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath=$0 + +# The name of this program. +progname=`$ECHO "$progpath" |$SED "$sed_basename"` + +# Make sure we have an absolute progpath for reexecution: +case $progpath in + [\\/]*|[A-Za-z]:\\*) ;; + *[\\/]*) + progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` + progdir=`cd "$progdir" && pwd` + progpath=$progdir/$progname + ;; + *) + _G_IFS=$IFS + IFS=${PATH_SEPARATOR-:} + for progdir in $PATH; do + IFS=$_G_IFS + test -x "$progdir/$progname" && break + done + IFS=$_G_IFS + test -n "$progdir" || progdir=`pwd` + progpath=$progdir/$progname + ;; +esac + + +## ----------------- ## +## Standard options. ## +## ----------------- ## + +# The following options affect the operation of the functions defined +# below, and should be set appropriately depending on run-time para- +# meters passed on the command line. + +opt_dry_run=false +opt_quiet=false +opt_verbose=false + +# Categories 'all' and 'none' are always available. Append any others +# you will pass as the first argument to func_warning from your own +# code. +warning_categories= + +# By default, display warnings according to 'opt_warning_types'. Set +# 'warning_func' to ':' to elide all warnings, or func_fatal_error to +# treat the next displayed warning as a fatal error. +warning_func=func_warn_and_continue + +# Set to 'all' to display all warnings, 'none' to suppress all +# warnings, or a space delimited list of some subset of +# 'warning_categories' to display only the listed warnings. +opt_warning_types=all + + +## -------------------- ## +## Resource management. ## +## -------------------- ## + +# This section contains definitions for functions that each ensure a +# particular resource (a file, or a non-empty configuration variable for +# example) is available, and if appropriate to extract default values +# from pertinent package files. Call them using their associated +# 'require_*' variable to ensure that they are executed, at most, once. +# +# It's entirely deliberate that calling these functions can set +# variables that don't obey the namespace limitations obeyed by the rest +# of this file, in order that that they be as useful as possible to +# callers. + + +# require_term_colors +# ------------------- +# Allow display of bold text on terminals that support it. +require_term_colors=func_require_term_colors +func_require_term_colors () +{ + $debug_cmd + + test -t 1 && { + # COLORTERM and USE_ANSI_COLORS environment variables take + # precedence, because most terminfo databases neglect to describe + # whether color sequences are supported. + test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} + + if test 1 = "$USE_ANSI_COLORS"; then + # Standard ANSI escape sequences + tc_reset='' + tc_bold=''; tc_standout='' + tc_red=''; tc_green='' + tc_blue=''; tc_cyan='' + else + # Otherwise trust the terminfo database after all. + test -n "`tput sgr0 2>/dev/null`" && { + tc_reset=`tput sgr0` + test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` + tc_standout=$tc_bold + test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` + test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` + test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` + test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` + test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` + } + fi + } + + require_term_colors=: +} + + +## ----------------- ## +## Function library. ## +## ----------------- ## + +# This section contains a variety of useful functions to call in your +# scripts. Take note of the portable wrappers for features provided by +# some modern shells, which will fall back to slower equivalents on +# less featureful shells. + + +# func_append VAR VALUE +# --------------------- +# Append VALUE onto the existing contents of VAR. + + # We should try to minimise forks, especially on Windows where they are + # unreasonably slow, so skip the feature probes when bash or zsh are + # being used: + if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then + : ${_G_HAVE_ARITH_OP="yes"} + : ${_G_HAVE_XSI_OPS="yes"} + # The += operator was introduced in bash 3.1 + case $BASH_VERSION in + [12].* | 3.0 | 3.0*) ;; + *) + : ${_G_HAVE_PLUSEQ_OP="yes"} + ;; + esac + fi + + # _G_HAVE_PLUSEQ_OP + # Can be empty, in which case the shell is probed, "yes" if += is + # useable or anything else if it does not work. + test -z "$_G_HAVE_PLUSEQ_OP" \ + && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ + && _G_HAVE_PLUSEQ_OP=yes + +if test yes = "$_G_HAVE_PLUSEQ_OP" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_append () + { + $debug_cmd + + eval "$1+=\$2" + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_append () + { + $debug_cmd + + eval "$1=\$$1\$2" + } +fi + + +# func_append_quoted VAR VALUE +# ---------------------------- +# Quote VALUE and append to the end of shell variable VAR, separated +# by a space. +if test yes = "$_G_HAVE_PLUSEQ_OP"; then + eval 'func_append_quoted () + { + $debug_cmd + + func_quote_for_eval "$2" + eval "$1+=\\ \$func_quote_for_eval_result" + }' +else + func_append_quoted () + { + $debug_cmd + + func_quote_for_eval "$2" + eval "$1=\$$1\\ \$func_quote_for_eval_result" + } +fi + + +# func_append_uniq VAR VALUE +# -------------------------- +# Append unique VALUE onto the existing contents of VAR, assuming +# entries are delimited by the first character of VALUE. For example: +# +# func_append_uniq options " --another-option option-argument" +# +# will only append to $options if " --another-option option-argument " +# is not already present somewhere in $options already (note spaces at +# each end implied by leading space in second argument). +func_append_uniq () +{ + $debug_cmd + + eval _G_current_value='`$ECHO $'$1'`' + _G_delim=`expr "$2" : '\(.\)'` + + case $_G_delim$_G_current_value$_G_delim in + *"$2$_G_delim"*) ;; + *) func_append "$@" ;; + esac +} + + +# func_arith TERM... +# ------------------ +# Set func_arith_result to the result of evaluating TERMs. + test -z "$_G_HAVE_ARITH_OP" \ + && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ + && _G_HAVE_ARITH_OP=yes + +if test yes = "$_G_HAVE_ARITH_OP"; then + eval 'func_arith () + { + $debug_cmd + + func_arith_result=$(( $* )) + }' +else + func_arith () + { + $debug_cmd + + func_arith_result=`expr "$@"` + } +fi + + +# func_basename FILE +# ------------------ +# Set func_basename_result to FILE with everything up to and including +# the last / stripped. +if test yes = "$_G_HAVE_XSI_OPS"; then + # If this shell supports suffix pattern removal, then use it to avoid + # forking. Hide the definitions single quotes in case the shell chokes + # on unsupported syntax... + _b='func_basename_result=${1##*/}' + _d='case $1 in + */*) func_dirname_result=${1%/*}$2 ;; + * ) func_dirname_result=$3 ;; + esac' + +else + # ...otherwise fall back to using sed. + _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' + _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` + if test "X$func_dirname_result" = "X$1"; then + func_dirname_result=$3 + else + func_append func_dirname_result "$2" + fi' +fi + +eval 'func_basename () +{ + $debug_cmd + + '"$_b"' +}' + + +# func_dirname FILE APPEND NONDIR_REPLACEMENT +# ------------------------------------------- +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +eval 'func_dirname () +{ + $debug_cmd + + '"$_d"' +}' + + +# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT +# -------------------------------------------------------- +# Perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# For efficiency, we do not delegate to the functions above but instead +# duplicate the functionality here. +eval 'func_dirname_and_basename () +{ + $debug_cmd + + '"$_b"' + '"$_d"' +}' + + +# func_echo ARG... +# ---------------- +# Echo program name prefixed message. +func_echo () +{ + $debug_cmd + + _G_message=$* + + func_echo_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_IFS + $ECHO "$progname: $_G_line" + done + IFS=$func_echo_IFS +} + + +# func_echo_all ARG... +# -------------------- +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + + +# func_echo_infix_1 INFIX ARG... +# ------------------------------ +# Echo program name, followed by INFIX on the first line, with any +# additional lines not showing INFIX. +func_echo_infix_1 () +{ + $debug_cmd + + $require_term_colors + + _G_infix=$1; shift + _G_indent=$_G_infix + _G_prefix="$progname: $_G_infix: " + _G_message=$* + + # Strip color escape sequences before counting printable length + for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" + do + test -n "$_G_tc" && { + _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` + _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` + } + done + _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes + + func_echo_infix_1_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_infix_1_IFS + $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 + _G_prefix=$_G_indent + done + IFS=$func_echo_infix_1_IFS +} + + +# func_error ARG... +# ----------------- +# Echo program name prefixed message to standard error. +func_error () +{ + $debug_cmd + + $require_term_colors + + func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 +} + + +# func_fatal_error ARG... +# ----------------------- +# Echo program name prefixed message to standard error, and exit. +func_fatal_error () +{ + $debug_cmd + + func_error "$*" + exit $EXIT_FAILURE +} + + +# func_grep EXPRESSION FILENAME +# ----------------------------- +# Check whether EXPRESSION matches any line of FILENAME, without output. +func_grep () +{ + $debug_cmd + + $GREP "$1" "$2" >/dev/null 2>&1 +} + + +# func_len STRING +# --------------- +# Set func_len_result to the length of STRING. STRING may not +# start with a hyphen. + test -z "$_G_HAVE_XSI_OPS" \ + && (eval 'x=a/b/c; + test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ + && _G_HAVE_XSI_OPS=yes + +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_len () + { + $debug_cmd + + func_len_result=${#1} + }' +else + func_len () + { + $debug_cmd + + func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` + } +fi + + +# func_mkdir_p DIRECTORY-PATH +# --------------------------- +# Make sure the entire path to DIRECTORY-PATH is available. +func_mkdir_p () +{ + $debug_cmd + + _G_directory_path=$1 + _G_dir_list= + + if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then + + # Protect directory names starting with '-' + case $_G_directory_path in + -*) _G_directory_path=./$_G_directory_path ;; + esac + + # While some portion of DIR does not yet exist... + while test ! -d "$_G_directory_path"; do + # ...make a list in topmost first order. Use a colon delimited + # list incase some portion of path contains whitespace. + _G_dir_list=$_G_directory_path:$_G_dir_list + + # If the last portion added has no slash in it, the list is done + case $_G_directory_path in */*) ;; *) break ;; esac + + # ...otherwise throw away the child directory and loop + _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` + done + _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` + + func_mkdir_p_IFS=$IFS; IFS=: + for _G_dir in $_G_dir_list; do + IFS=$func_mkdir_p_IFS + # mkdir can fail with a 'File exist' error if two processes + # try to create one of the directories concurrently. Don't + # stop in that case! + $MKDIR "$_G_dir" 2>/dev/null || : + done + IFS=$func_mkdir_p_IFS + + # Bail out if we (or some other process) failed to create a directory. + test -d "$_G_directory_path" || \ + func_fatal_error "Failed to create '$1'" + fi +} + + +# func_mktempdir [BASENAME] +# ------------------------- +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, BASENAME is the basename for that directory. +func_mktempdir () +{ + $debug_cmd + + _G_template=${TMPDIR-/tmp}/${1-$progname} + + if test : = "$opt_dry_run"; then + # Return a directory name, but don't create it in dry-run mode + _G_tmpdir=$_G_template-$$ + else + + # If mktemp works, use that first and foremost + _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` + + if test ! -d "$_G_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + _G_tmpdir=$_G_template-${RANDOM-0}$$ + + func_mktempdir_umask=`umask` + umask 0077 + $MKDIR "$_G_tmpdir" + umask $func_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$_G_tmpdir" || \ + func_fatal_error "cannot create temporary directory '$_G_tmpdir'" + fi + + $ECHO "$_G_tmpdir" +} + + +# func_normal_abspath PATH +# ------------------------ +# Remove doubled-up and trailing slashes, "." path components, +# and cancel out any ".." path components in PATH after making +# it an absolute path. +func_normal_abspath () +{ + $debug_cmd + + # These SED scripts presuppose an absolute path with a trailing slash. + _G_pathcar='s|^/\([^/]*\).*$|\1|' + _G_pathcdr='s|^/[^/]*||' + _G_removedotparts=':dotsl + s|/\./|/|g + t dotsl + s|/\.$|/|' + _G_collapseslashes='s|/\{1,\}|/|g' + _G_finalslash='s|/*$|/|' + + # Start from root dir and reassemble the path. + func_normal_abspath_result= + func_normal_abspath_tpath=$1 + func_normal_abspath_altnamespace= + case $func_normal_abspath_tpath in + "") + # Empty path, that just means $cwd. + func_stripname '' '/' "`pwd`" + func_normal_abspath_result=$func_stripname_result + return + ;; + # The next three entries are used to spot a run of precisely + # two leading slashes without using negated character classes; + # we take advantage of case's first-match behaviour. + ///*) + # Unusual form of absolute path, do nothing. + ;; + //*) + # Not necessarily an ordinary path; POSIX reserves leading '//' + # and for example Cygwin uses it to access remote file shares + # over CIFS/SMB, so we conserve a leading double slash if found. + func_normal_abspath_altnamespace=/ + ;; + /*) + # Absolute path, do nothing. + ;; + *) + # Relative path, prepend $cwd. + func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath + ;; + esac + + # Cancel out all the simple stuff to save iterations. We also want + # the path to end with a slash for ease of parsing, so make sure + # there is one (and only one) here. + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` + while :; do + # Processed it all yet? + if test / = "$func_normal_abspath_tpath"; then + # If we ascended to the root using ".." the result may be empty now. + if test -z "$func_normal_abspath_result"; then + func_normal_abspath_result=/ + fi + break + fi + func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_pathcar"` + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_pathcdr"` + # Figure out what to do with it + case $func_normal_abspath_tcomponent in + "") + # Trailing empty path component, ignore it. + ;; + ..) + # Parent dir; strip last assembled component from result. + func_dirname "$func_normal_abspath_result" + func_normal_abspath_result=$func_dirname_result + ;; + *) + # Actual path component, append it. + func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" + ;; + esac + done + # Restore leading double-slash if one was found on entry. + func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result +} + + +# func_notquiet ARG... +# -------------------- +# Echo program name prefixed message only when not in quiet mode. +func_notquiet () +{ + $debug_cmd + + $opt_quiet || func_echo ${1+"$@"} + + # A bug in bash halts the script if the last line of a function + # fails when set -e is in force, so we need another command to + # work around that: + : +} + + +# func_relative_path SRCDIR DSTDIR +# -------------------------------- +# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. +func_relative_path () +{ + $debug_cmd + + func_relative_path_result= + func_normal_abspath "$1" + func_relative_path_tlibdir=$func_normal_abspath_result + func_normal_abspath "$2" + func_relative_path_tbindir=$func_normal_abspath_result + + # Ascend the tree starting from libdir + while :; do + # check if we have found a prefix of bindir + case $func_relative_path_tbindir in + $func_relative_path_tlibdir) + # found an exact match + func_relative_path_tcancelled= + break + ;; + $func_relative_path_tlibdir*) + # found a matching prefix + func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" + func_relative_path_tcancelled=$func_stripname_result + if test -z "$func_relative_path_result"; then + func_relative_path_result=. + fi + break + ;; + *) + func_dirname $func_relative_path_tlibdir + func_relative_path_tlibdir=$func_dirname_result + if test -z "$func_relative_path_tlibdir"; then + # Have to descend all the way to the root! + func_relative_path_result=../$func_relative_path_result + func_relative_path_tcancelled=$func_relative_path_tbindir + break + fi + func_relative_path_result=../$func_relative_path_result + ;; + esac + done + + # Now calculate path; take care to avoid doubling-up slashes. + func_stripname '' '/' "$func_relative_path_result" + func_relative_path_result=$func_stripname_result + func_stripname '/' '/' "$func_relative_path_tcancelled" + if test -n "$func_stripname_result"; then + func_append func_relative_path_result "/$func_stripname_result" + fi + + # Normalisation. If bindir is libdir, return '.' else relative path. + if test -n "$func_relative_path_result"; then + func_stripname './' '' "$func_relative_path_result" + func_relative_path_result=$func_stripname_result + fi + + test -n "$func_relative_path_result" || func_relative_path_result=. + + : +} + + +# func_quote_for_eval ARG... +# -------------------------- +# Aesthetically quote ARGs to be evaled later. +# This function returns two values: +# i) func_quote_for_eval_result +# double-quoted, suitable for a subsequent eval +# ii) func_quote_for_eval_unquoted_result +# has all characters that are still active within double +# quotes backslashified. +func_quote_for_eval () +{ + $debug_cmd + + func_quote_for_eval_unquoted_result= + func_quote_for_eval_result= + while test 0 -lt $#; do + case $1 in + *[\\\`\"\$]*) + _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; + *) + _G_unquoted_arg=$1 ;; + esac + if test -n "$func_quote_for_eval_unquoted_result"; then + func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" + else + func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" + fi + + case $_G_unquoted_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting, command substitution and variable expansion + # for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + _G_quoted_arg=\"$_G_unquoted_arg\" + ;; + *) + _G_quoted_arg=$_G_unquoted_arg + ;; + esac + + if test -n "$func_quote_for_eval_result"; then + func_append func_quote_for_eval_result " $_G_quoted_arg" + else + func_append func_quote_for_eval_result "$_G_quoted_arg" + fi + shift + done +} + + +# func_quote_for_expand ARG +# ------------------------- +# Aesthetically quote ARG to be evaled later; same as above, +# but do not quote variable references. +func_quote_for_expand () +{ + $debug_cmd + + case $1 in + *[\\\`\"]*) + _G_arg=`$ECHO "$1" | $SED \ + -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; + *) + _G_arg=$1 ;; + esac + + case $_G_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting and command substitution for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + _G_arg=\"$_G_arg\" + ;; + esac + + func_quote_for_expand_result=$_G_arg +} + + +# func_stripname PREFIX SUFFIX NAME +# --------------------------------- +# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_stripname () + { + $debug_cmd + + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary variable first. + func_stripname_result=$3 + func_stripname_result=${func_stripname_result#"$1"} + func_stripname_result=${func_stripname_result%"$2"} + }' +else + func_stripname () + { + $debug_cmd + + case $2 in + .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; + *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; + esac + } +fi + + +# func_show_eval CMD [FAIL_EXP] +# ----------------------------- +# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. +func_show_eval () +{ + $debug_cmd + + _G_cmd=$1 + _G_fail_exp=${2-':'} + + func_quote_for_expand "$_G_cmd" + eval "func_notquiet $func_quote_for_expand_result" + + $opt_dry_run || { + eval "$_G_cmd" + _G_status=$? + if test 0 -ne "$_G_status"; then + eval "(exit $_G_status); $_G_fail_exp" + fi + } +} + + +# func_show_eval_locale CMD [FAIL_EXP] +# ------------------------------------ +# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. Use the saved locale for evaluation. +func_show_eval_locale () +{ + $debug_cmd + + _G_cmd=$1 + _G_fail_exp=${2-':'} + + $opt_quiet || { + func_quote_for_expand "$_G_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + $opt_dry_run || { + eval "$_G_user_locale + $_G_cmd" + _G_status=$? + eval "$_G_safe_locale" + if test 0 -ne "$_G_status"; then + eval "(exit $_G_status); $_G_fail_exp" + fi + } +} + + +# func_tr_sh +# ---------- +# Turn $1 into a string suitable for a shell variable name. +# Result is stored in $func_tr_sh_result. All characters +# not in the set a-zA-Z0-9_ are replaced with '_'. Further, +# if $1 begins with a digit, a '_' is prepended as well. +func_tr_sh () +{ + $debug_cmd + + case $1 in + [0-9]* | *[!a-zA-Z0-9_]*) + func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` + ;; + * ) + func_tr_sh_result=$1 + ;; + esac +} + + +# func_verbose ARG... +# ------------------- +# Echo program name prefixed message in verbose mode only. +func_verbose () +{ + $debug_cmd + + $opt_verbose && func_echo "$*" + + : +} + + +# func_warn_and_continue ARG... +# ----------------------------- +# Echo program name prefixed warning message to standard error. +func_warn_and_continue () +{ + $debug_cmd + + $require_term_colors + + func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 +} + + +# func_warning CATEGORY ARG... +# ---------------------------- +# Echo program name prefixed warning message to standard error. Warning +# messages can be filtered according to CATEGORY, where this function +# elides messages where CATEGORY is not listed in the global variable +# 'opt_warning_types'. +func_warning () +{ + $debug_cmd + + # CATEGORY must be in the warning_categories list! + case " $warning_categories " in + *" $1 "*) ;; + *) func_internal_error "invalid warning category '$1'" ;; + esac + + _G_category=$1 + shift + + case " $opt_warning_types " in + *" $_G_category "*) $warning_func ${1+"$@"} ;; + esac +} + + +# func_sort_ver VER1 VER2 +# ----------------------- +# 'sort -V' is not generally available. +# Note this deviates from the version comparison in automake +# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a +# but this should suffice as we won't be specifying old +# version formats or redundant trailing .0 in bootstrap.conf. +# If we did want full compatibility then we should probably +# use m4_version_compare from autoconf. +func_sort_ver () +{ + $debug_cmd + + printf '%s\n%s\n' "$1" "$2" \ + | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n +} + +# func_lt_ver PREV CURR +# --------------------- +# Return true if PREV and CURR are in the correct order according to +# func_sort_ver, otherwise false. Use it like this: +# +# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." +func_lt_ver () +{ + $debug_cmd + + test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` +} + + +# Local variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-time-zone: "UTC" +# End: +#! /bin/sh + +# Set a version string for this script. +scriptversion=2014-01-07.03; # UTC + +# A portable, pluggable option parser for Bourne shell. +# Written by Gary V. Vaughan, 2010 + +# Copyright (C) 2010-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Please report bugs or propose patches to gary@gnu.org. + + +## ------ ## +## Usage. ## +## ------ ## + +# This file is a library for parsing options in your shell scripts along +# with assorted other useful supporting features that you can make use +# of too. +# +# For the simplest scripts you might need only: +# +# #!/bin/sh +# . relative/path/to/funclib.sh +# . relative/path/to/options-parser +# scriptversion=1.0 +# func_options ${1+"$@"} +# eval set dummy "$func_options_result"; shift +# ...rest of your script... +# +# In order for the '--version' option to work, you will need to have a +# suitably formatted comment like the one at the top of this file +# starting with '# Written by ' and ending with '# warranty; '. +# +# For '-h' and '--help' to work, you will also need a one line +# description of your script's purpose in a comment directly above the +# '# Written by ' line, like the one at the top of this file. +# +# The default options also support '--debug', which will turn on shell +# execution tracing (see the comment above debug_cmd below for another +# use), and '--verbose' and the func_verbose function to allow your script +# to display verbose messages only when your user has specified +# '--verbose'. +# +# After sourcing this file, you can plug processing for additional +# options by amending the variables from the 'Configuration' section +# below, and following the instructions in the 'Option parsing' +# section further down. + +## -------------- ## +## Configuration. ## +## -------------- ## + +# You should override these variables in your script after sourcing this +# file so that they reflect the customisations you have added to the +# option parser. + +# The usage line for option parsing errors and the start of '-h' and +# '--help' output messages. You can embed shell variables for delayed +# expansion at the time the message is displayed, but you will need to +# quote other shell meta-characters carefully to prevent them being +# expanded when the contents are evaled. +usage='$progpath [OPTION]...' + +# Short help message in response to '-h' and '--help'. Add to this or +# override it after sourcing this library to reflect the full set of +# options your script accepts. +usage_message="\ + --debug enable verbose shell tracing + -W, --warnings=CATEGORY + report the warnings falling in CATEGORY [all] + -v, --verbose verbosely report processing + --version print version information and exit + -h, --help print short or long help message and exit +" + +# Additional text appended to 'usage_message' in response to '--help'. +long_help_message=" +Warning categories include: + 'all' show all warnings + 'none' turn off all the warnings + 'error' warnings are treated as fatal errors" + +# Help message printed before fatal option parsing errors. +fatal_help="Try '\$progname --help' for more information." + + + +## ------------------------- ## +## Hook function management. ## +## ------------------------- ## + +# This section contains functions for adding, removing, and running hooks +# to the main code. A hook is just a named list of of function, that can +# be run in order later on. + +# func_hookable FUNC_NAME +# ----------------------- +# Declare that FUNC_NAME will run hooks added with +# 'func_add_hook FUNC_NAME ...'. +func_hookable () +{ + $debug_cmd + + func_append hookable_fns " $1" +} + + +# func_add_hook FUNC_NAME HOOK_FUNC +# --------------------------------- +# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must +# first have been declared "hookable" by a call to 'func_hookable'. +func_add_hook () +{ + $debug_cmd + + case " $hookable_fns " in + *" $1 "*) ;; + *) func_fatal_error "'$1' does not accept hook functions." ;; + esac + + eval func_append ${1}_hooks '" $2"' +} + + +# func_remove_hook FUNC_NAME HOOK_FUNC +# ------------------------------------ +# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. +func_remove_hook () +{ + $debug_cmd + + eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' +} + + +# func_run_hooks FUNC_NAME [ARG]... +# --------------------------------- +# Run all hook functions registered to FUNC_NAME. +# It is assumed that the list of hook functions contains nothing more +# than a whitespace-delimited list of legal shell function names, and +# no effort is wasted trying to catch shell meta-characters or preserve +# whitespace. +func_run_hooks () +{ + $debug_cmd + + case " $hookable_fns " in + *" $1 "*) ;; + *) func_fatal_error "'$1' does not support hook funcions.n" ;; + esac + + eval _G_hook_fns=\$$1_hooks; shift + + for _G_hook in $_G_hook_fns; do + eval $_G_hook '"$@"' + + # store returned options list back into positional + # parameters for next 'cmd' execution. + eval _G_hook_result=\$${_G_hook}_result + eval set dummy "$_G_hook_result"; shift + done + + func_quote_for_eval ${1+"$@"} + func_run_hooks_result=$func_quote_for_eval_result +} + + + +## --------------- ## +## Option parsing. ## +## --------------- ## + +# In order to add your own option parsing hooks, you must accept the +# full positional parameter list in your hook function, remove any +# options that you action, and then pass back the remaining unprocessed +# options in '_result', escaped suitably for +# 'eval'. Like this: +# +# my_options_prep () +# { +# $debug_cmd +# +# # Extend the existing usage message. +# usage_message=$usage_message' +# -s, --silent don'\''t print informational messages +# ' +# +# func_quote_for_eval ${1+"$@"} +# my_options_prep_result=$func_quote_for_eval_result +# } +# func_add_hook func_options_prep my_options_prep +# +# +# my_silent_option () +# { +# $debug_cmd +# +# # Note that for efficiency, we parse as many options as we can +# # recognise in a loop before passing the remainder back to the +# # caller on the first unrecognised argument we encounter. +# while test $# -gt 0; do +# opt=$1; shift +# case $opt in +# --silent|-s) opt_silent=: ;; +# # Separate non-argument short options: +# -s*) func_split_short_opt "$_G_opt" +# set dummy "$func_split_short_opt_name" \ +# "-$func_split_short_opt_arg" ${1+"$@"} +# shift +# ;; +# *) set dummy "$_G_opt" "$*"; shift; break ;; +# esac +# done +# +# func_quote_for_eval ${1+"$@"} +# my_silent_option_result=$func_quote_for_eval_result +# } +# func_add_hook func_parse_options my_silent_option +# +# +# my_option_validation () +# { +# $debug_cmd +# +# $opt_silent && $opt_verbose && func_fatal_help "\ +# '--silent' and '--verbose' options are mutually exclusive." +# +# func_quote_for_eval ${1+"$@"} +# my_option_validation_result=$func_quote_for_eval_result +# } +# func_add_hook func_validate_options my_option_validation +# +# You'll alse need to manually amend $usage_message to reflect the extra +# options you parse. It's preferable to append if you can, so that +# multiple option parsing hooks can be added safely. + + +# func_options [ARG]... +# --------------------- +# All the functions called inside func_options are hookable. See the +# individual implementations for details. +func_hookable func_options +func_options () +{ + $debug_cmd + + func_options_prep ${1+"$@"} + eval func_parse_options \ + ${func_options_prep_result+"$func_options_prep_result"} + eval func_validate_options \ + ${func_parse_options_result+"$func_parse_options_result"} + + eval func_run_hooks func_options \ + ${func_validate_options_result+"$func_validate_options_result"} + + # save modified positional parameters for caller + func_options_result=$func_run_hooks_result +} + + +# func_options_prep [ARG]... +# -------------------------- +# All initialisations required before starting the option parse loop. +# Note that when calling hook functions, we pass through the list of +# positional parameters. If a hook function modifies that list, and +# needs to propogate that back to rest of this script, then the complete +# modified list must be put in 'func_run_hooks_result' before +# returning. +func_hookable func_options_prep +func_options_prep () +{ + $debug_cmd + + # Option defaults: + opt_verbose=false + opt_warning_types= + + func_run_hooks func_options_prep ${1+"$@"} + + # save modified positional parameters for caller + func_options_prep_result=$func_run_hooks_result +} + + +# func_parse_options [ARG]... +# --------------------------- +# The main option parsing loop. +func_hookable func_parse_options +func_parse_options () +{ + $debug_cmd + + func_parse_options_result= + + # this just eases exit handling + while test $# -gt 0; do + # Defer to hook functions for initial option parsing, so they + # get priority in the event of reusing an option name. + func_run_hooks func_parse_options ${1+"$@"} + + # Adjust func_parse_options positional parameters to match + eval set dummy "$func_run_hooks_result"; shift + + # Break out of the loop if we already parsed every option. + test $# -gt 0 || break + + _G_opt=$1 + shift + case $_G_opt in + --debug|-x) debug_cmd='set -x' + func_echo "enabling shell trace mode" + $debug_cmd + ;; + + --no-warnings|--no-warning|--no-warn) + set dummy --warnings none ${1+"$@"} + shift + ;; + + --warnings|--warning|-W) + test $# = 0 && func_missing_arg $_G_opt && break + case " $warning_categories $1" in + *" $1 "*) + # trailing space prevents matching last $1 above + func_append_uniq opt_warning_types " $1" + ;; + *all) + opt_warning_types=$warning_categories + ;; + *none) + opt_warning_types=none + warning_func=: + ;; + *error) + opt_warning_types=$warning_categories + warning_func=func_fatal_error + ;; + *) + func_fatal_error \ + "unsupported warning category: '$1'" + ;; + esac + shift + ;; + + --verbose|-v) opt_verbose=: ;; + --version) func_version ;; + -\?|-h) func_usage ;; + --help) func_help ;; + + # Separate optargs to long options (plugins may need this): + --*=*) func_split_equals "$_G_opt" + set dummy "$func_split_equals_lhs" \ + "$func_split_equals_rhs" ${1+"$@"} + shift + ;; + + # Separate optargs to short options: + -W*) + func_split_short_opt "$_G_opt" + set dummy "$func_split_short_opt_name" \ + "$func_split_short_opt_arg" ${1+"$@"} + shift + ;; + + # Separate non-argument short options: + -\?*|-h*|-v*|-x*) + func_split_short_opt "$_G_opt" + set dummy "$func_split_short_opt_name" \ + "-$func_split_short_opt_arg" ${1+"$@"} + shift + ;; + + --) break ;; + -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; + *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + esac + done + + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + func_parse_options_result=$func_quote_for_eval_result +} + + +# func_validate_options [ARG]... +# ------------------------------ +# Perform any sanity checks on option settings and/or unconsumed +# arguments. +func_hookable func_validate_options +func_validate_options () +{ + $debug_cmd + + # Display all warnings if -W was not given. + test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" + + func_run_hooks func_validate_options ${1+"$@"} + + # Bail if the options were screwed! + $exit_cmd $EXIT_FAILURE + + # save modified positional parameters for caller + func_validate_options_result=$func_run_hooks_result +} + + + +## ----------------- ## +## Helper functions. ## +## ----------------- ## + +# This section contains the helper functions used by the rest of the +# hookable option parser framework in ascii-betical order. + + +# func_fatal_help ARG... +# ---------------------- +# Echo program name prefixed message to standard error, followed by +# a help hint, and exit. +func_fatal_help () +{ + $debug_cmd + + eval \$ECHO \""Usage: $usage"\" + eval \$ECHO \""$fatal_help"\" + func_error ${1+"$@"} + exit $EXIT_FAILURE +} + + +# func_help +# --------- +# Echo long help message to standard output and exit. +func_help () +{ + $debug_cmd + + func_usage_message + $ECHO "$long_help_message" + exit 0 +} + + +# func_missing_arg ARGNAME +# ------------------------ +# Echo program name prefixed message to standard error and set global +# exit_cmd. +func_missing_arg () +{ + $debug_cmd + + func_error "Missing argument for '$1'." + exit_cmd=exit +} + + +# func_split_equals STRING +# ------------------------ +# Set func_split_equals_lhs and func_split_equals_rhs shell variables after +# splitting STRING at the '=' sign. +test -z "$_G_HAVE_XSI_OPS" \ + && (eval 'x=a/b/c; + test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ + && _G_HAVE_XSI_OPS=yes + +if test yes = "$_G_HAVE_XSI_OPS" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_split_equals () + { + $debug_cmd + + func_split_equals_lhs=${1%%=*} + func_split_equals_rhs=${1#*=} + test "x$func_split_equals_lhs" = "x$1" \ + && func_split_equals_rhs= + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_split_equals () + { + $debug_cmd + + func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` + func_split_equals_rhs= + test "x$func_split_equals_lhs" = "x$1" \ + || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` + } +fi #func_split_equals + + +# func_split_short_opt SHORTOPT +# ----------------------------- +# Set func_split_short_opt_name and func_split_short_opt_arg shell +# variables after splitting SHORTOPT after the 2nd character. +if test yes = "$_G_HAVE_XSI_OPS" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_split_short_opt () + { + $debug_cmd + + func_split_short_opt_arg=${1#??} + func_split_short_opt_name=${1%"$func_split_short_opt_arg"} + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_split_short_opt () + { + $debug_cmd + + func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` + func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` + } +fi #func_split_short_opt + + +# func_usage +# ---------- +# Echo short help message to standard output and exit. +func_usage () +{ + $debug_cmd + + func_usage_message + $ECHO "Run '$progname --help |${PAGER-more}' for full usage" + exit 0 +} + + +# func_usage_message +# ------------------ +# Echo short help message to standard output. +func_usage_message () +{ + $debug_cmd + + eval \$ECHO \""Usage: $usage"\" + echo + $SED -n 's|^# || + /^Written by/{ + x;p;x + } + h + /^Written by/q' < "$progpath" + echo + eval \$ECHO \""$usage_message"\" +} + + +# func_version +# ------------ +# Echo version message to standard output and exit. +func_version () +{ + $debug_cmd + + printf '%s\n' "$progname $scriptversion" + $SED -n ' + /(C)/!b go + :more + /\./!{ + N + s|\n# | | + b more + } + :go + /^# Written by /,/# warranty; / { + s|^# || + s|^# *$|| + s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| + p + } + /^# Written by / { + s|^# || + p + } + /^warranty; /q' < "$progpath" + + exit $? +} + + +# Local variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-time-zone: "UTC" +# End: + +# Set a version string. +scriptversion='(GNU libtool) 2.4.6' + + +# func_echo ARG... +# ---------------- +# Libtool also displays the current mode in messages, so override +# funclib.sh func_echo with this custom definition. +func_echo () +{ + $debug_cmd + + _G_message=$* + + func_echo_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_IFS + $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" + done + IFS=$func_echo_IFS +} + + +# func_warning ARG... +# ------------------- +# Libtool warnings are not categorized, so override funclib.sh +# func_warning with this simpler definition. +func_warning () +{ + $debug_cmd + + $warning_func ${1+"$@"} +} + + +## ---------------- ## +## Options parsing. ## +## ---------------- ## + +# Hook in the functions to make sure our own options are parsed during +# the option parsing loop. + +usage='$progpath [OPTION]... [MODE-ARG]...' + +# Short help message in response to '-h'. +usage_message="Options: + --config show all configuration variables + --debug enable verbose shell tracing + -n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --mode=MODE use operation mode MODE + --no-warnings equivalent to '-Wnone' + --preserve-dup-deps don't remove duplicate dependency libraries + --quiet, --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG + -v, --verbose print more informational messages than default + --version print version information + -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] + -h, --help, --help-all print short, long, or detailed help message +" + +# Additional text appended to 'usage_message' in response to '--help'. +func_help () +{ + $debug_cmd + + func_usage_message + $ECHO "$long_help_message + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. When passed as first option, +'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. +Try '$progname --help --mode=MODE' for a more detailed description of MODE. + +When reporting a bug, please describe a test case to reproduce it and +include the following information: + + host-triplet: $host + shell: $SHELL + compiler: $LTCC + compiler flags: $LTCFLAGS + linker: $LD (gnu? $with_gnu_ld) + version: $progname (GNU libtool) 2.4.6 + automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` + autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` + +Report bugs to . +GNU libtool home page: . +General help using GNU software: ." + exit 0 +} + + +# func_lo2o OBJECT-NAME +# --------------------- +# Transform OBJECT-NAME from a '.lo' suffix to the platform specific +# object suffix. + +lo2o=s/\\.lo\$/.$objext/ +o2lo=s/\\.$objext\$/.lo/ + +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_lo2o () + { + case $1 in + *.lo) func_lo2o_result=${1%.lo}.$objext ;; + * ) func_lo2o_result=$1 ;; + esac + }' + + # func_xform LIBOBJ-OR-SOURCE + # --------------------------- + # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) + # suffix to a '.lo' libtool-object suffix. + eval 'func_xform () + { + func_xform_result=${1%.*}.lo + }' +else + # ...otherwise fall back to using sed. + func_lo2o () + { + func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` + } + + func_xform () + { + func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` + } +fi + + +# func_fatal_configuration ARG... +# ------------------------------- +# Echo program name prefixed message to standard error, followed by +# a configuration failure hint, and exit. +func_fatal_configuration () +{ + func__fatal_error ${1+"$@"} \ + "See the $PACKAGE documentation for more information." \ + "Fatal configuration error." +} + + +# func_config +# ----------- +# Display the configuration for all the tags in this script. +func_config () +{ + re_begincf='^# ### BEGIN LIBTOOL' + re_endcf='^# ### END LIBTOOL' + + # Default configuration. + $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" + + # Now print the configurations for the tags. + for tagname in $taglist; do + $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" + done + + exit $? +} + + +# func_features +# ------------- +# Display the features supported by this script. +func_features () +{ + echo "host: $host" + if test yes = "$build_libtool_libs"; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test yes = "$build_old_libs"; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + + exit $? +} + + +# func_enable_tag TAGNAME +# ----------------------- +# Verify that TAGNAME is valid, and either flag an error and exit, or +# enable the TAGNAME tag. We also add TAGNAME to the global $taglist +# variable here. +func_enable_tag () +{ + # Global variable: + tagname=$1 + + re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" + re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" + sed_extractcf=/$re_begincf/,/$re_endcf/p + + # Validate tagname. + case $tagname in + *[!-_A-Za-z0-9,/]*) + func_fatal_error "invalid tag name: $tagname" + ;; + esac + + # Don't test for the "default" C tag, as we know it's + # there but not specially marked. + case $tagname in + CC) ;; + *) + if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then + taglist="$taglist $tagname" + + # Evaluate the configuration. Be careful to quote the path + # and the sed script, to avoid splitting on whitespace, but + # also don't use non-portable quotes within backquotes within + # quotes we have to do it in 2 steps: + extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` + eval "$extractedcf" + else + func_error "ignoring unknown tag $tagname" + fi + ;; + esac +} + + +# func_check_version_match +# ------------------------ +# Ensure that we are using m4 macros, and libtool script from the same +# release of libtool. +func_check_version_match () +{ + if test "$package_revision" != "$macro_revision"; then + if test "$VERSION" != "$macro_version"; then + if test -z "$macro_version"; then + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from an older release. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + fi + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, +$progname: but the definition of this LT_INIT comes from revision $macro_revision. +$progname: You should recreate aclocal.m4 with macros from revision $package_revision +$progname: of $PACKAGE $VERSION and run autoconf again. +_LT_EOF + fi + + exit $EXIT_MISMATCH + fi +} + + +# libtool_options_prep [ARG]... +# ----------------------------- +# Preparation for options parsed by libtool. +libtool_options_prep () +{ + $debug_mode + + # Option defaults: + opt_config=false + opt_dlopen= + opt_dry_run=false + opt_help=false + opt_mode= + opt_preserve_dup_deps=false + opt_quiet=false + + nonopt= + preserve_args= + + # Shorthand for --mode=foo, only valid as the first argument + case $1 in + clean|clea|cle|cl) + shift; set dummy --mode clean ${1+"$@"}; shift + ;; + compile|compil|compi|comp|com|co|c) + shift; set dummy --mode compile ${1+"$@"}; shift + ;; + execute|execut|execu|exec|exe|ex|e) + shift; set dummy --mode execute ${1+"$@"}; shift + ;; + finish|finis|fini|fin|fi|f) + shift; set dummy --mode finish ${1+"$@"}; shift + ;; + install|instal|insta|inst|ins|in|i) + shift; set dummy --mode install ${1+"$@"}; shift + ;; + link|lin|li|l) + shift; set dummy --mode link ${1+"$@"}; shift + ;; + uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) + shift; set dummy --mode uninstall ${1+"$@"}; shift + ;; + esac + + # Pass back the list of options. + func_quote_for_eval ${1+"$@"} + libtool_options_prep_result=$func_quote_for_eval_result +} +func_add_hook func_options_prep libtool_options_prep + + +# libtool_parse_options [ARG]... +# --------------------------------- +# Provide handling for libtool specific options. +libtool_parse_options () +{ + $debug_cmd + + # Perform our own loop to consume as many options as possible in + # each iteration. + while test $# -gt 0; do + _G_opt=$1 + shift + case $_G_opt in + --dry-run|--dryrun|-n) + opt_dry_run=: + ;; + + --config) func_config ;; + + --dlopen|-dlopen) + opt_dlopen="${opt_dlopen+$opt_dlopen +}$1" + shift + ;; + + --preserve-dup-deps) + opt_preserve_dup_deps=: ;; + + --features) func_features ;; + + --finish) set dummy --mode finish ${1+"$@"}; shift ;; + + --help) opt_help=: ;; + + --help-all) opt_help=': help-all' ;; + + --mode) test $# = 0 && func_missing_arg $_G_opt && break + opt_mode=$1 + case $1 in + # Valid mode arguments: + clean|compile|execute|finish|install|link|relink|uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $_G_opt" + exit_cmd=exit + break + ;; + esac + shift + ;; + + --no-silent|--no-quiet) + opt_quiet=false + func_append preserve_args " $_G_opt" + ;; + + --no-warnings|--no-warning|--no-warn) + opt_warning=false + func_append preserve_args " $_G_opt" + ;; + + --no-verbose) + opt_verbose=false + func_append preserve_args " $_G_opt" + ;; + + --silent|--quiet) + opt_quiet=: + opt_verbose=false + func_append preserve_args " $_G_opt" + ;; + + --tag) test $# = 0 && func_missing_arg $_G_opt && break + opt_tag=$1 + func_append preserve_args " $_G_opt $1" + func_enable_tag "$1" + shift + ;; + + --verbose|-v) opt_quiet=false + opt_verbose=: + func_append preserve_args " $_G_opt" + ;; + + # An option not handled by this hook function: + *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + esac + done + + + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + libtool_parse_options_result=$func_quote_for_eval_result +} +func_add_hook func_parse_options libtool_parse_options + + + +# libtool_validate_options [ARG]... +# --------------------------------- +# Perform any sanity checks on option settings and/or unconsumed +# arguments. +libtool_validate_options () +{ + # save first non-option argument + if test 0 -lt $#; then + nonopt=$1 + shift + fi + + # preserve --debug + test : = "$debug_cmd" || func_append preserve_args " --debug" + + case $host in + # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 + # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 + *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; + *) + opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps + ;; + esac + + $opt_help || { + # Sanity checks first: + func_check_version_match + + test yes != "$build_libtool_libs" \ + && test yes != "$build_old_libs" \ + && func_fatal_configuration "not configured to build any kind of library" + + # Darwin sucks + eval std_shrext=\"$shrext_cmds\" + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$opt_dlopen" && test execute != "$opt_mode"; then + func_error "unrecognized option '-dlopen'" + $ECHO "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help=$help + help="Try '$progname --help --mode=$opt_mode' for more information." + } + + # Pass back the unparsed argument list + func_quote_for_eval ${1+"$@"} + libtool_validate_options_result=$func_quote_for_eval_result +} +func_add_hook func_validate_options libtool_validate_options + + +# Process options as early as possible so that --help and --version +# can return quickly. +func_options ${1+"$@"} +eval set dummy "$func_options_result"; shift + + + +## ----------- ## +## Main. ## +## ----------- ## + +magic='%%%MAGIC variable%%%' +magic_exe='%%%MAGIC EXE variable%%%' + +# Global variables. +extracted_archives= +extracted_serial=0 + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + +# func_generated_by_libtool +# True iff stdin has been generated by Libtool. This function is only +# a basic sanity check; it will hardly flush out determined imposters. +func_generated_by_libtool_p () +{ + $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 +} + +# func_lalib_p file +# True iff FILE is a libtool '.la' library or '.lo' object file. +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_lalib_p () +{ + test -f "$1" && + $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p +} + +# func_lalib_unsafe_p file +# True iff FILE is a libtool '.la' library or '.lo' object file. +# This function implements the same check as func_lalib_p without +# resorting to external programs. To this end, it redirects stdin and +# closes it afterwards, without saving the original file descriptor. +# As a safety measure, use it only where a negative result would be +# fatal anyway. Works if 'file' does not exist. +func_lalib_unsafe_p () +{ + lalib_p=no + if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then + for lalib_p_l in 1 2 3 4 + do + read lalib_p_line + case $lalib_p_line in + \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; + esac + done + exec 0<&5 5<&- + fi + test yes = "$lalib_p" +} + +# func_ltwrapper_script_p file +# True iff FILE is a libtool wrapper script +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_script_p () +{ + test -f "$1" && + $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p +} + +# func_ltwrapper_executable_p file +# True iff FILE is a libtool wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_executable_p () +{ + func_ltwrapper_exec_suffix= + case $1 in + *.exe) ;; + *) func_ltwrapper_exec_suffix=.exe ;; + esac + $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 +} + +# func_ltwrapper_scriptname file +# Assumes file is an ltwrapper_executable +# uses $file to determine the appropriate filename for a +# temporary ltwrapper_script. +func_ltwrapper_scriptname () +{ + func_dirname_and_basename "$1" "" "." + func_stripname '' '.exe' "$func_basename_result" + func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper +} + +# func_ltwrapper_p file +# True iff FILE is a libtool wrapper script or wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_p () +{ + func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" +} + + +# func_execute_cmds commands fail_cmd +# Execute tilde-delimited COMMANDS. +# If FAIL_CMD is given, eval that upon failure. +# FAIL_CMD may read-access the current command in variable CMD! +func_execute_cmds () +{ + $debug_cmd + + save_ifs=$IFS; IFS='~' + for cmd in $1; do + IFS=$sp$nl + eval cmd=\"$cmd\" + IFS=$save_ifs + func_show_eval "$cmd" "${2-:}" + done + IFS=$save_ifs +} + + +# func_source file +# Source FILE, adding directory component if necessary. +# Note that it is not necessary on cygwin/mingw to append a dot to +# FILE even if both FILE and FILE.exe exist: automatic-append-.exe +# behavior happens only for exec(3), not for open(2)! Also, sourcing +# 'FILE.' does not work on cygwin managed mounts. +func_source () +{ + $debug_cmd + + case $1 in + */* | *\\*) . "$1" ;; + *) . "./$1" ;; + esac +} + + +# func_resolve_sysroot PATH +# Replace a leading = in PATH with a sysroot. Store the result into +# func_resolve_sysroot_result +func_resolve_sysroot () +{ + func_resolve_sysroot_result=$1 + case $func_resolve_sysroot_result in + =*) + func_stripname '=' '' "$func_resolve_sysroot_result" + func_resolve_sysroot_result=$lt_sysroot$func_stripname_result + ;; + esac +} + +# func_replace_sysroot PATH +# If PATH begins with the sysroot, replace it with = and +# store the result into func_replace_sysroot_result. +func_replace_sysroot () +{ + case $lt_sysroot:$1 in + ?*:"$lt_sysroot"*) + func_stripname "$lt_sysroot" '' "$1" + func_replace_sysroot_result='='$func_stripname_result + ;; + *) + # Including no sysroot. + func_replace_sysroot_result=$1 + ;; + esac +} + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () +{ + $debug_cmd + + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + func_append_quoted CC_quoted "$arg" + done + CC_expanded=`func_echo_all $CC` + CC_quoted_expanded=`func_echo_all $CC_quoted` + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ + " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + func_append_quoted CC_quoted "$arg" + done + CC_expanded=`func_echo_all $CC` + CC_quoted_expanded=`func_echo_all $CC_quoted` + case "$@ " in + " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ + " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + func_echo "unable to infer tagged configuration" + func_fatal_error "specify a tag with '--tag'" +# else +# func_verbose "using $tagname tagged configuration" + fi + ;; + esac + fi +} + + + +# func_write_libtool_object output_name pic_name nonpic_name +# Create a libtool object file (analogous to a ".la" file), +# but don't create it if we're doing a dry run. +func_write_libtool_object () +{ + write_libobj=$1 + if test yes = "$build_libtool_libs"; then + write_lobj=\'$2\' + else + write_lobj=none + fi + + if test yes = "$build_old_libs"; then + write_oldobj=\'$3\' + else + write_oldobj=none + fi + + $opt_dry_run || { + cat >${write_libobj}T </dev/null` + if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then + func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | + $SED -e "$sed_naive_backslashify"` + else + func_convert_core_file_wine_to_w32_result= + fi + fi +} +# end: func_convert_core_file_wine_to_w32 + + +# func_convert_core_path_wine_to_w32 ARG +# Helper function used by path conversion functions when $build is *nix, and +# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly +# configured wine environment available, with the winepath program in $build's +# $PATH. Assumes ARG has no leading or trailing path separator characters. +# +# ARG is path to be converted from $build format to win32. +# Result is available in $func_convert_core_path_wine_to_w32_result. +# Unconvertible file (directory) names in ARG are skipped; if no directory names +# are convertible, then the result may be empty. +func_convert_core_path_wine_to_w32 () +{ + $debug_cmd + + # unfortunately, winepath doesn't convert paths, only file names + func_convert_core_path_wine_to_w32_result= + if test -n "$1"; then + oldIFS=$IFS + IFS=: + for func_convert_core_path_wine_to_w32_f in $1; do + IFS=$oldIFS + func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" + if test -n "$func_convert_core_file_wine_to_w32_result"; then + if test -z "$func_convert_core_path_wine_to_w32_result"; then + func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result + else + func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" + fi + fi + done + IFS=$oldIFS + fi +} +# end: func_convert_core_path_wine_to_w32 + + +# func_cygpath ARGS... +# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when +# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) +# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or +# (2), returns the Cygwin file name or path in func_cygpath_result (input +# file name or path is assumed to be in w32 format, as previously converted +# from $build's *nix or MSYS format). In case (3), returns the w32 file name +# or path in func_cygpath_result (input file name or path is assumed to be in +# Cygwin format). Returns an empty string on error. +# +# ARGS are passed to cygpath, with the last one being the file name or path to +# be converted. +# +# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH +# environment variable; do not put it in $PATH. +func_cygpath () +{ + $debug_cmd + + if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then + func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` + if test "$?" -ne 0; then + # on failure, ensure result is empty + func_cygpath_result= + fi + else + func_cygpath_result= + func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" + fi +} +#end: func_cygpath + + +# func_convert_core_msys_to_w32 ARG +# Convert file name or path ARG from MSYS format to w32 format. Return +# result in func_convert_core_msys_to_w32_result. +func_convert_core_msys_to_w32 () +{ + $debug_cmd + + # awkward: cmd appends spaces to result + func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | + $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` +} +#end: func_convert_core_msys_to_w32 + + +# func_convert_file_check ARG1 ARG2 +# Verify that ARG1 (a file name in $build format) was converted to $host +# format in ARG2. Otherwise, emit an error message, but continue (resetting +# func_to_host_file_result to ARG1). +func_convert_file_check () +{ + $debug_cmd + + if test -z "$2" && test -n "$1"; then + func_error "Could not determine host file name corresponding to" + func_error " '$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback: + func_to_host_file_result=$1 + fi +} +# end func_convert_file_check + + +# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH +# Verify that FROM_PATH (a path in $build format) was converted to $host +# format in TO_PATH. Otherwise, emit an error message, but continue, resetting +# func_to_host_file_result to a simplistic fallback value (see below). +func_convert_path_check () +{ + $debug_cmd + + if test -z "$4" && test -n "$3"; then + func_error "Could not determine the host path corresponding to" + func_error " '$3'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback. This is a deliberately simplistic "conversion" and + # should not be "improved". See libtool.info. + if test "x$1" != "x$2"; then + lt_replace_pathsep_chars="s|$1|$2|g" + func_to_host_path_result=`echo "$3" | + $SED -e "$lt_replace_pathsep_chars"` + else + func_to_host_path_result=$3 + fi + fi +} +# end func_convert_path_check + + +# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG +# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT +# and appending REPL if ORIG matches BACKPAT. +func_convert_path_front_back_pathsep () +{ + $debug_cmd + + case $4 in + $1 ) func_to_host_path_result=$3$func_to_host_path_result + ;; + esac + case $4 in + $2 ) func_append func_to_host_path_result "$3" + ;; + esac +} +# end func_convert_path_front_back_pathsep + + +################################################## +# $build to $host FILE NAME CONVERSION FUNCTIONS # +################################################## +# invoked via '$to_host_file_cmd ARG' +# +# In each case, ARG is the path to be converted from $build to $host format. +# Result will be available in $func_to_host_file_result. + + +# func_to_host_file ARG +# Converts the file name ARG from $build format to $host format. Return result +# in func_to_host_file_result. +func_to_host_file () +{ + $debug_cmd + + $to_host_file_cmd "$1" +} +# end func_to_host_file + + +# func_to_tool_file ARG LAZY +# converts the file name ARG from $build format to toolchain format. Return +# result in func_to_tool_file_result. If the conversion in use is listed +# in (the comma separated) LAZY, no conversion takes place. +func_to_tool_file () +{ + $debug_cmd + + case ,$2, in + *,"$to_tool_file_cmd",*) + func_to_tool_file_result=$1 + ;; + *) + $to_tool_file_cmd "$1" + func_to_tool_file_result=$func_to_host_file_result + ;; + esac +} +# end func_to_tool_file + + +# func_convert_file_noop ARG +# Copy ARG to func_to_host_file_result. +func_convert_file_noop () +{ + func_to_host_file_result=$1 +} +# end func_convert_file_noop + + +# func_convert_file_msys_to_w32 ARG +# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic +# conversion to w32 is not available inside the cwrapper. Returns result in +# func_to_host_file_result. +func_convert_file_msys_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_msys_to_w32 "$1" + func_to_host_file_result=$func_convert_core_msys_to_w32_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_msys_to_w32 + + +# func_convert_file_cygwin_to_w32 ARG +# Convert file name ARG from Cygwin to w32 format. Returns result in +# func_to_host_file_result. +func_convert_file_cygwin_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + # because $build is cygwin, we call "the" cygpath in $PATH; no need to use + # LT_CYGPATH in this case. + func_to_host_file_result=`cygpath -m "$1"` + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_cygwin_to_w32 + + +# func_convert_file_nix_to_w32 ARG +# Convert file name ARG from *nix to w32 format. Requires a wine environment +# and a working winepath. Returns result in func_to_host_file_result. +func_convert_file_nix_to_w32 () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_file_wine_to_w32 "$1" + func_to_host_file_result=$func_convert_core_file_wine_to_w32_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_nix_to_w32 + + +# func_convert_file_msys_to_cygwin ARG +# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. +# Returns result in func_to_host_file_result. +func_convert_file_msys_to_cygwin () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + func_convert_core_msys_to_w32 "$1" + func_cygpath -u "$func_convert_core_msys_to_w32_result" + func_to_host_file_result=$func_cygpath_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_msys_to_cygwin + + +# func_convert_file_nix_to_cygwin ARG +# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed +# in a wine environment, working winepath, and LT_CYGPATH set. Returns result +# in func_to_host_file_result. +func_convert_file_nix_to_cygwin () +{ + $debug_cmd + + func_to_host_file_result=$1 + if test -n "$1"; then + # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. + func_convert_core_file_wine_to_w32 "$1" + func_cygpath -u "$func_convert_core_file_wine_to_w32_result" + func_to_host_file_result=$func_cygpath_result + fi + func_convert_file_check "$1" "$func_to_host_file_result" +} +# end func_convert_file_nix_to_cygwin + + +############################################# +# $build to $host PATH CONVERSION FUNCTIONS # +############################################# +# invoked via '$to_host_path_cmd ARG' +# +# In each case, ARG is the path to be converted from $build to $host format. +# The result will be available in $func_to_host_path_result. +# +# Path separators are also converted from $build format to $host format. If +# ARG begins or ends with a path separator character, it is preserved (but +# converted to $host format) on output. +# +# All path conversion functions are named using the following convention: +# file name conversion function : func_convert_file_X_to_Y () +# path conversion function : func_convert_path_X_to_Y () +# where, for any given $build/$host combination the 'X_to_Y' value is the +# same. If conversion functions are added for new $build/$host combinations, +# the two new functions must follow this pattern, or func_init_to_host_path_cmd +# will break. + + +# func_init_to_host_path_cmd +# Ensures that function "pointer" variable $to_host_path_cmd is set to the +# appropriate value, based on the value of $to_host_file_cmd. +to_host_path_cmd= +func_init_to_host_path_cmd () +{ + $debug_cmd + + if test -z "$to_host_path_cmd"; then + func_stripname 'func_convert_file_' '' "$to_host_file_cmd" + to_host_path_cmd=func_convert_path_$func_stripname_result + fi +} + + +# func_to_host_path ARG +# Converts the path ARG from $build format to $host format. Return result +# in func_to_host_path_result. +func_to_host_path () +{ + $debug_cmd + + func_init_to_host_path_cmd + $to_host_path_cmd "$1" +} +# end func_to_host_path + + +# func_convert_path_noop ARG +# Copy ARG to func_to_host_path_result. +func_convert_path_noop () +{ + func_to_host_path_result=$1 +} +# end func_convert_path_noop + + +# func_convert_path_msys_to_w32 ARG +# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic +# conversion to w32 is not available inside the cwrapper. Returns result in +# func_to_host_path_result. +func_convert_path_msys_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # Remove leading and trailing path separator characters from ARG. MSYS + # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; + # and winepath ignores them completely. + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" + func_to_host_path_result=$func_convert_core_msys_to_w32_result + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_msys_to_w32 + + +# func_convert_path_cygwin_to_w32 ARG +# Convert path ARG from Cygwin to w32 format. Returns result in +# func_to_host_file_result. +func_convert_path_cygwin_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_cygwin_to_w32 + + +# func_convert_path_nix_to_w32 ARG +# Convert path ARG from *nix to w32 format. Requires a wine environment and +# a working winepath. Returns result in func_to_host_file_result. +func_convert_path_nix_to_w32 () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" + func_to_host_path_result=$func_convert_core_path_wine_to_w32_result + func_convert_path_check : ";" \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" + fi +} +# end func_convert_path_nix_to_w32 + + +# func_convert_path_msys_to_cygwin ARG +# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. +# Returns result in func_to_host_file_result. +func_convert_path_msys_to_cygwin () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # See func_convert_path_msys_to_w32: + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" + func_cygpath -u -p "$func_convert_core_msys_to_w32_result" + func_to_host_path_result=$func_cygpath_result + func_convert_path_check : : \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" : "$1" + fi +} +# end func_convert_path_msys_to_cygwin + + +# func_convert_path_nix_to_cygwin ARG +# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a +# a wine environment, working winepath, and LT_CYGPATH set. Returns result in +# func_to_host_file_result. +func_convert_path_nix_to_cygwin () +{ + $debug_cmd + + func_to_host_path_result=$1 + if test -n "$1"; then + # Remove leading and trailing path separator characters from + # ARG. msys behavior is inconsistent here, cygpath turns them + # into '.;' and ';.', and winepath ignores them completely. + func_stripname : : "$1" + func_to_host_path_tmp1=$func_stripname_result + func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" + func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" + func_to_host_path_result=$func_cygpath_result + func_convert_path_check : : \ + "$func_to_host_path_tmp1" "$func_to_host_path_result" + func_convert_path_front_back_pathsep ":*" "*:" : "$1" + fi +} +# end func_convert_path_nix_to_cygwin + + +# func_dll_def_p FILE +# True iff FILE is a Windows DLL '.def' file. +# Keep in sync with _LT_DLL_DEF_P in libtool.m4 +func_dll_def_p () +{ + $debug_cmd + + func_dll_def_p_tmp=`$SED -n \ + -e 's/^[ ]*//' \ + -e '/^\(;.*\)*$/d' \ + -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ + -e q \ + "$1"` + test DEF = "$func_dll_def_p_tmp" +} + + +# func_mode_compile arg... +func_mode_compile () +{ + $debug_cmd + + # Get the compilation command and the source file. + base_compile= + srcfile=$nonopt # always keep a non-empty value in "srcfile" + suppress_opt=yes + suppress_output= + arg_mode=normal + libobj= + later= + pie_flag= + + for arg + do + case $arg_mode in + arg ) + # do not "continue". Instead, add this to base_compile + lastarg=$arg + arg_mode=normal + ;; + + target ) + libobj=$arg + arg_mode=normal + continue + ;; + + normal ) + # Accept any command-line options. + case $arg in + -o) + test -n "$libobj" && \ + func_fatal_error "you cannot specify '-o' more than once" + arg_mode=target + continue + ;; + + -pie | -fpie | -fPIE) + func_append pie_flag " $arg" + continue + ;; + + -shared | -static | -prefer-pic | -prefer-non-pic) + func_append later " $arg" + continue + ;; + + -no-suppress) + suppress_opt=no + continue + ;; + + -Xcompiler) + arg_mode=arg # the next one goes into the "base_compile" arg list + continue # The current "srcfile" will either be retained or + ;; # replaced later. I would guess that would be a bug. + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + lastarg= + save_ifs=$IFS; IFS=, + for arg in $args; do + IFS=$save_ifs + func_append_quoted lastarg "$arg" + done + IFS=$save_ifs + func_stripname ' ' '' "$lastarg" + lastarg=$func_stripname_result + + # Add the arguments to base_compile. + func_append base_compile " $lastarg" + continue + ;; + + *) + # Accept the current argument as the source file. + # The previous "srcfile" becomes the current argument. + # + lastarg=$srcfile + srcfile=$arg + ;; + esac # case $arg + ;; + esac # case $arg_mode + + # Aesthetically quote the previous argument. + func_append_quoted base_compile "$lastarg" + done # for arg + + case $arg_mode in + arg) + func_fatal_error "you must specify an argument for -Xcompile" + ;; + target) + func_fatal_error "you must specify a target with '-o'" + ;; + *) + # Get the name of the library object. + test -z "$libobj" && { + func_basename "$srcfile" + libobj=$func_basename_result + } + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + case $libobj in + *.[cCFSifmso] | \ + *.ada | *.adb | *.ads | *.asm | \ + *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ + *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) + func_xform "$libobj" + libobj=$func_xform_result + ;; + esac + + case $libobj in + *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; + *) + func_fatal_error "cannot determine name of library object from '$libobj'" + ;; + esac + + func_infer_tag $base_compile + + for arg in $later; do + case $arg in + -shared) + test yes = "$build_libtool_libs" \ + || func_fatal_configuration "cannot build a shared library" + build_old_libs=no + continue + ;; + + -static) + build_libtool_libs=no + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + esac + done + + func_quote_for_eval "$libobj" + test "X$libobj" != "X$func_quote_for_eval_result" \ + && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ + && func_warning "libobj name '$libobj' may not contain shell special characters." + func_dirname_and_basename "$obj" "/" "" + objname=$func_basename_result + xdir=$func_dirname_result + lobj=$xdir$objdir/$objname + + test -z "$base_compile" && \ + func_fatal_help "you must specify a compilation command" + + # Delete any leftover library objects. + if test yes = "$build_old_libs"; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2* | cegcc*) + pic_mode=default + ;; + esac + if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test no = "$compiler_c_o"; then + output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext + lockfile=$output_obj.lock + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test yes = "$need_locks"; then + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + elif test warn = "$need_locks"; then + if test -f "$lockfile"; then + $ECHO "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + func_append removelist " $output_obj" + $ECHO "$srcfile" > "$lockfile" + fi + + $opt_dry_run || $RM $removelist + func_append removelist " $lockfile" + trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 + + func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 + srcfile=$func_to_tool_file_result + func_quote_for_eval "$srcfile" + qsrcfile=$func_quote_for_eval_result + + # Only build a PIC object if we are building libtool libraries. + if test yes = "$build_libtool_libs"; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test no != "$pic_mode"; then + command="$base_compile $qsrcfile $pic_flag" + else + # Don't build PIC code + command="$base_compile $qsrcfile" + fi + + func_mkdir_p "$xdir$objdir" + + if test -z "$output_obj"; then + # Place PIC objects in $objdir + func_append command " -o $lobj" + fi + + func_show_eval_locale "$command" \ + 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' + + if test warn = "$need_locks" && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + func_show_eval '$MV "$output_obj" "$lobj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + + # Allow error messages only from the first compilation. + if test yes = "$suppress_opt"; then + suppress_output=' >/dev/null 2>&1' + fi + fi + + # Only build a position-dependent object if we build old libraries. + if test yes = "$build_old_libs"; then + if test yes != "$pic_mode"; then + # Don't build PIC code + command="$base_compile $qsrcfile$pie_flag" + else + command="$base_compile $qsrcfile $pic_flag" + fi + if test yes = "$compiler_c_o"; then + func_append command " -o $obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + func_append command "$suppress_output" + func_show_eval_locale "$command" \ + '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' + + if test warn = "$need_locks" && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support '-c' and '-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + func_show_eval '$MV "$output_obj" "$obj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + fi + + $opt_dry_run || { + func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" + + # Unlock the critical section if it was locked + if test no != "$need_locks"; then + removelist=$lockfile + $RM "$lockfile" + fi + } + + exit $EXIT_SUCCESS +} + +$opt_help || { + test compile = "$opt_mode" && func_mode_compile ${1+"$@"} +} + +func_mode_help () +{ + # We need to display help for each of the modes. + case $opt_mode in + "") + # Generic help is extracted from the usage comments + # at the start of this file. + func_help + ;; + + clean) + $ECHO \ +"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + + compile) + $ECHO \ +"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -no-suppress do not suppress compiler output for multiple passes + -prefer-pic try to build PIC objects only + -prefer-non-pic try to build non-PIC objects only + -shared do not build a '.o' file suitable for static linking + -static only build a '.o' file suitable for static linking + -Wc,FLAG pass FLAG directly to the compiler + +COMPILE-COMMAND is a command to be used in creating a 'standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix '.c' with the +library object suffix, '.lo'." + ;; + + execute) + $ECHO \ +"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to '-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + + finish) + $ECHO \ +"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the '--dry-run' option if you just want to see what would be executed." + ;; + + install) + $ECHO \ +"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the 'install' or 'cp' program. + +The following components of INSTALL-COMMAND are treated specially: + + -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + + link) + $ECHO \ +"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -bindir BINDIR specify path to binaries directory (for systems where + libraries must be found in the PATH setting at runtime) + -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE use a list of object files found in FILE to specify objects + -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -shared only do dynamic linking of libtool libraries + -shrext SUFFIX override the standard shared library file extension + -static do not do any dynamic linking of uninstalled libtool libraries + -static-libtool-libs + do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + -weak LIBNAME declare that the target provides the LIBNAME interface + -Wc,FLAG + -Xcompiler FLAG pass linker-specific FLAG directly to the compiler + -Wl,FLAG + -Xlinker FLAG pass linker-specific FLAG directly to the linker + -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) + +All other options (arguments beginning with '-') are ignored. + +Every other argument is treated as a filename. Files ending in '.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in '.la', then a libtool library is created, +only library objects ('.lo' files) may be specified, and '-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created +using 'ar' and 'ranlib', or on Windows using 'lib'. + +If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file +is created, otherwise an executable program is created." + ;; + + uninstall) + $ECHO \ +"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + + *) + func_fatal_help "invalid operation mode '$opt_mode'" + ;; + esac + + echo + $ECHO "Try '$progname --help' for more information about other modes." +} + +# Now that we've collected a possible --mode arg, show help if necessary +if $opt_help; then + if test : = "$opt_help"; then + func_mode_help + else + { + func_help noexit + for opt_mode in compile link execute install finish uninstall clean; do + func_mode_help + done + } | $SED -n '1p; 2,$s/^Usage:/ or: /p' + { + func_help noexit + for opt_mode in compile link execute install finish uninstall clean; do + echo + func_mode_help + done + } | + $SED '1d + /^When reporting/,/^Report/{ + H + d + } + $x + /information about other modes/d + /more detailed .*MODE/d + s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' + fi + exit $? +fi + + +# func_mode_execute arg... +func_mode_execute () +{ + $debug_cmd + + # The first argument is the command name. + cmd=$nonopt + test -z "$cmd" && \ + func_fatal_help "you must specify a COMMAND" + + # Handle -dlopen flags immediately. + for file in $opt_dlopen; do + test -f "$file" \ + || func_fatal_help "'$file' is not a file" + + dir= + case $file in + *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "'$lib' is not a valid libtool archive" + + # Read the libtool library. + dlname= + library_names= + func_source "$file" + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && \ + func_warning "'$file' was not linked with '-export-dynamic'" + continue + fi + + func_dirname "$file" "" "." + dir=$func_dirname_result + + if test -f "$dir/$objdir/$dlname"; then + func_append dir "/$objdir" + else + if test ! -f "$dir/$dlname"; then + func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" + fi + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + func_dirname "$file" "" "." + dir=$func_dirname_result + ;; + + *) + func_warning "'-dlopen' is ignored for non-libtool libraries and objects" + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir=$absdir + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic=$magic + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -* | *.la | *.lo ) ;; + *) + # Do a test to see if this is really a libtool program. + if func_ltwrapper_script_p "$file"; then + func_source "$file" + # Transform arg to wrapped name. + file=$progdir/$program + elif func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + func_source "$func_ltwrapper_scriptname_result" + # Transform arg to wrapped name. + file=$progdir/$program + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + func_append_quoted args "$file" + done + + if $opt_dry_run; then + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" + echo "export $shlibpath_var" + fi + $ECHO "$cmd$args" + exit $EXIT_SUCCESS + else + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES + do + eval "if test \"\${save_$lt_var+set}\" = set; then + $lt_var=\$save_$lt_var; export $lt_var + else + $lt_unset $lt_var + fi" + done + + # Now prepare to actually exec the command. + exec_cmd=\$cmd$args + fi +} + +test execute = "$opt_mode" && func_mode_execute ${1+"$@"} + + +# func_mode_finish arg... +func_mode_finish () +{ + $debug_cmd + + libs= + libdirs= + admincmds= + + for opt in "$nonopt" ${1+"$@"} + do + if test -d "$opt"; then + func_append libdirs " $opt" + + elif test -f "$opt"; then + if func_lalib_unsafe_p "$opt"; then + func_append libs " $opt" + else + func_warning "'$opt' is not a valid libtool archive" + fi + + else + func_fatal_error "invalid argument '$opt'" + fi + done + + if test -n "$libs"; then + if test -n "$lt_sysroot"; then + sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` + sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" + else + sysroot_cmd= + fi + + # Remove sysroot references + if $opt_dry_run; then + for lib in $libs; do + echo "removing references to $lt_sysroot and '=' prefixes from $lib" + done + else + tmpdir=`func_mktempdir` + for lib in $libs; do + $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ + > $tmpdir/tmp-la + mv -f $tmpdir/tmp-la $lib + done + ${RM}r "$tmpdir" + fi + fi + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + func_execute_cmds "$finish_cmds" 'admincmds="$admincmds +'"$cmd"'"' + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $opt_dry_run || eval "$cmds" || func_append admincmds " + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + $opt_quiet && exit $EXIT_SUCCESS + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + $ECHO " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use the '-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the '$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the '$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $ECHO " - use the '$flag' linker flag" + fi + if test -n "$admincmds"; then + $ECHO " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" + fi + echo + + echo "See any operating system documentation about shared libraries for" + case $host in + solaris2.[6789]|solaris2.1[0-9]) + echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" + echo "pages." + ;; + *) + echo "more information, such as the ld(1) and ld.so(8) manual pages." + ;; + esac + echo "----------------------------------------------------------------------" + fi + exit $EXIT_SUCCESS +} + +test finish = "$opt_mode" && func_mode_finish ${1+"$@"} + + +# func_mode_install arg... +func_mode_install () +{ + $debug_cmd + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || + # Allow the use of GNU shtool's install command. + case $nonopt in *shtool*) :;; *) false;; esac + then + # Aesthetically quote it. + func_quote_for_eval "$nonopt" + install_prog="$func_quote_for_eval_result " + arg=$1 + shift + else + install_prog= + arg=$nonopt + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + func_quote_for_eval "$arg" + func_append install_prog "$func_quote_for_eval_result" + install_shared_prog=$install_prog + case " $install_prog " in + *[\\\ /]cp\ *) install_cp=: ;; + *) install_cp=false ;; + esac + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=false + stripme= + no_mode=: + for arg + do + arg2= + if test -n "$dest"; then + func_append files " $dest" + dest=$arg + continue + fi + + case $arg in + -d) isdir=: ;; + -f) + if $install_cp; then :; else + prev=$arg + fi + ;; + -g | -m | -o) + prev=$arg + ;; + -s) + stripme=" -s" + continue + ;; + -*) + ;; + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + if test X-m = "X$prev" && test -n "$install_override_mode"; then + arg2=$install_override_mode + no_mode=false + fi + prev= + else + dest=$arg + continue + fi + ;; + esac + + # Aesthetically quote the argument. + func_quote_for_eval "$arg" + func_append install_prog " $func_quote_for_eval_result" + if test -n "$arg2"; then + func_quote_for_eval "$arg2" + fi + func_append install_shared_prog " $func_quote_for_eval_result" + done + + test -z "$install_prog" && \ + func_fatal_help "you must specify an install program" + + test -n "$prev" && \ + func_fatal_help "the '$prev' option requires an argument" + + if test -n "$install_override_mode" && $no_mode; then + if $install_cp; then :; else + func_quote_for_eval "$install_override_mode" + func_append install_shared_prog " -m $func_quote_for_eval_result" + fi + fi + + if test -z "$files"; then + if test -z "$dest"; then + func_fatal_help "no file or destination specified" + else + func_fatal_help "you must specify a destination" + fi + fi + + # Strip any trailing slash from the destination. + func_stripname '' '/' "$dest" + dest=$func_stripname_result + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=: + if $isdir; then + destdir=$dest + destname= + else + func_dirname_and_basename "$dest" "" "." + destdir=$func_dirname_result + destname=$func_basename_result + + # Not a directory, so check to see that there is only one file specified. + set dummy $files; shift + test "$#" -gt 1 && \ + func_fatal_help "'$dest' is not a directory" + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + func_fatal_help "'$destdir' must be an absolute directory name" + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic=$magic + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + func_append staticlibs " $file" + ;; + + *.la) + func_resolve_sysroot "$file" + file=$func_resolve_sysroot_result + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "'$file' is not a valid libtool archive" + + library_names= + old_library= + relink_command= + func_source "$file" + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) func_append current_libdirs " $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) func_append future_libdirs " $libdir" ;; + esac + fi + + func_dirname "$file" "/" "" + dir=$func_dirname_result + func_append dir "$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + test "$inst_prefix_dir" = "$destdir" && \ + func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` + fi + + func_warning "relinking '$file'" + func_show_eval "$relink_command" \ + 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' + fi + + # See the names of the shared library. + set dummy $library_names; shift + if test -n "$1"; then + realname=$1 + shift + + srcname=$realname + test -n "$relink_command" && srcname=${realname}T + + # Install the shared library and build the symlinks. + func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ + 'exit $?' + tstripme=$stripme + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + case $realname in + *.dll.a) + tstripme= + ;; + esac + ;; + os2*) + case $realname in + *_dll.a) + tstripme= + ;; + esac + ;; + esac + if test -n "$tstripme" && test -n "$striplib"; then + func_show_eval "$striplib $destdir/$realname" 'exit $?' + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + # Try 'ln -sf' first, because the 'ln' binary might depend on + # the symlink we replace! Solaris /bin/ln does not understand -f, + # so we also need to try rm && ln -s. + for linkname + do + test "$linkname" != "$realname" \ + && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" + done + fi + + # Do each command in the postinstall commands. + lib=$destdir/$realname + func_execute_cmds "$postinstall_cmds" 'exit $?' + fi + + # Install the pseudo-library for information purposes. + func_basename "$file" + name=$func_basename_result + instname=$dir/${name}i + func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' + + # Maybe install the static library, too. + test -n "$old_library" && func_append staticlibs " $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile=$destdir/$destname + else + func_basename "$file" + destfile=$func_basename_result + destfile=$destdir/$destfile + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + func_lo2o "$destfile" + staticdest=$func_lo2o_result + ;; + *.$objext) + staticdest=$destfile + destfile= + ;; + *) + func_fatal_help "cannot copy a libtool object to '$destfile'" + ;; + esac + + # Install the libtool object if requested. + test -n "$destfile" && \ + func_show_eval "$install_prog $file $destfile" 'exit $?' + + # Install the old object if enabled. + if test yes = "$build_old_libs"; then + # Deduce the name of the old-style object file. + func_lo2o "$file" + staticobj=$func_lo2o_result + func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile=$destdir/$destname + else + func_basename "$file" + destfile=$func_basename_result + destfile=$destdir/$destfile + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext= + case $file in + *.exe) + if test ! -f "$file"; then + func_stripname '' '.exe' "$file" + file=$func_stripname_result + stripped_ext=.exe + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin* | *mingw*) + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + wrapper=$func_ltwrapper_scriptname_result + else + func_stripname '' '.exe' "$file" + wrapper=$func_stripname_result + fi + ;; + *) + wrapper=$file + ;; + esac + if func_ltwrapper_script_p "$wrapper"; then + notinst_deplibs= + relink_command= + + func_source "$wrapper" + + # Check the variables that should have been set. + test -z "$generated_by_libtool_version" && \ + func_fatal_error "invalid libtool wrapper script '$wrapper'" + + finalize=: + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + func_source "$lib" + fi + libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` + if test -n "$libdir" && test ! -f "$libfile"; then + func_warning "'$lib' has not been installed in '$libdir'" + finalize=false + fi + done + + relink_command= + func_source "$wrapper" + + outputname= + if test no = "$fast_install" && test -n "$relink_command"; then + $opt_dry_run || { + if $finalize; then + tmpdir=`func_mktempdir` + func_basename "$file$stripped_ext" + file=$func_basename_result + outputname=$tmpdir/$file + # Replace the output file specification. + relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` + + $opt_quiet || { + func_quote_for_expand "$relink_command" + eval "func_echo $func_quote_for_expand_result" + } + if eval "$relink_command"; then : + else + func_error "error: relink '$file' with the above command before installing it" + $opt_dry_run || ${RM}r "$tmpdir" + continue + fi + file=$outputname + else + func_warning "cannot relink '$file'" + fi + } + else + # Install the binary that we compiled earlier. + file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + func_stripname '' '.exe' "$destfile" + destfile=$func_stripname_result + ;; + esac + ;; + esac + func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' + $opt_dry_run || if test -n "$outputname"; then + ${RM}r "$tmpdir" + fi + ;; + esac + done + + for file in $staticlibs; do + func_basename "$file" + name=$func_basename_result + + # Set up the ranlib parameters. + oldlib=$destdir/$name + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result + + func_show_eval "$install_prog \$file \$oldlib" 'exit $?' + + if test -n "$stripme" && test -n "$old_striplib"; then + func_show_eval "$old_striplib $tool_oldlib" 'exit $?' + fi + + # Do each command in the postinstall commands. + func_execute_cmds "$old_postinstall_cmds" 'exit $?' + done + + test -n "$future_libdirs" && \ + func_warning "remember to run '$progname --finish$future_libdirs'" + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + $opt_dry_run && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi +} + +test install = "$opt_mode" && func_mode_install ${1+"$@"} + + +# func_generate_dlsyms outputname originator pic_p +# Extract symbols from dlprefiles and create ${outputname}S.o with +# a dlpreopen symbol table. +func_generate_dlsyms () +{ + $debug_cmd + + my_outputname=$1 + my_originator=$2 + my_pic_p=${3-false} + my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` + my_dlsyms= + + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + my_dlsyms=${my_outputname}S.c + else + func_error "not configured to extract global symbols from dlpreopened files" + fi + fi + + if test -n "$my_dlsyms"; then + case $my_dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist=$output_objdir/$my_outputname.nm + + func_show_eval "$RM $nlist ${nlist}S ${nlist}T" + + # Parse the name list into a source file. + func_verbose "creating $output_objdir/$my_dlsyms" + + $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ +/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ +/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) +#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" +#endif + +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + +#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) + +/* External symbol declarations for the compiler. */\ +" + + if test yes = "$dlself"; then + func_verbose "generating symbol list for '$output'" + + $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` + for progfile in $progfiles; do + func_to_tool_file "$progfile" func_convert_file_msys_to_w32 + func_verbose "extracting global C symbols from '$func_to_tool_file_result'" + $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $opt_dry_run || { + eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + if test -n "$export_symbols_regex"; then + $opt_dry_run || { + eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols=$output_objdir/$outputname.exp + $opt_dry_run || { + $RM $export_symbols + eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; + esac + } + else + $opt_dry_run || { + eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + case $host in + *cygwin* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; + esac + } + fi + fi + + for dlprefile in $dlprefiles; do + func_verbose "extracting global C symbols from '$dlprefile'" + func_basename "$dlprefile" + name=$func_basename_result + case $host in + *cygwin* | *mingw* | *cegcc* ) + # if an import library, we need to obtain dlname + if func_win32_import_lib_p "$dlprefile"; then + func_tr_sh "$dlprefile" + eval "curr_lafile=\$libfile_$func_tr_sh_result" + dlprefile_dlbasename= + if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then + # Use subshell, to avoid clobbering current variable values + dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` + if test -n "$dlprefile_dlname"; then + func_basename "$dlprefile_dlname" + dlprefile_dlbasename=$func_basename_result + else + # no lafile. user explicitly requested -dlpreopen . + $sharedlib_from_linklib_cmd "$dlprefile" + dlprefile_dlbasename=$sharedlib_from_linklib_result + fi + fi + $opt_dry_run || { + if test -n "$dlprefile_dlbasename"; then + eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' + else + func_warning "Could not compute DLL name from $name" + eval '$ECHO ": $name " >> "$nlist"' + fi + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | + $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" + } + else # not an import lib + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + fi + ;; + *) + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + ;; + esac + done + + $opt_dry_run || { + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $MV "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if $GREP -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + $GREP -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' + else + echo '/* NONE */' >> "$output_objdir/$my_dlsyms" + fi + + func_show_eval '$RM "${nlist}I"' + if test -n "$global_symbol_to_import"; then + eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' + fi + + echo >> "$output_objdir/$my_dlsyms" "\ + +/* The mapping between symbol names and symbols. */ +typedef struct { + const char *name; + void *address; +} lt_dlsymlist; +extern LT_DLSYM_CONST lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[];\ +" + + if test -s "$nlist"I; then + echo >> "$output_objdir/$my_dlsyms" "\ +static void lt_syminit(void) +{ + LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; + for (; symbol->name; ++symbol) + {" + $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" + echo >> "$output_objdir/$my_dlsyms" "\ + } +}" + fi + echo >> "$output_objdir/$my_dlsyms" "\ +LT_DLSYM_CONST lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[] = +{ {\"$my_originator\", (void *) 0}," + + if test -s "$nlist"I; then + echo >> "$output_objdir/$my_dlsyms" "\ + {\"@INIT@\", (void *) <_syminit}," + fi + + case $need_lib_prefix in + no) + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + *) + eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + esac + echo >> "$output_objdir/$my_dlsyms" "\ + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_${my_prefix}_LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + } # !$opt_dry_run + + pic_flag_for_symtable= + case "$compile_command " in + *" -static "*) ;; + *) + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; + *-*-hpux*) + pic_flag_for_symtable=" $pic_flag" ;; + *) + $my_pic_p && pic_flag_for_symtable=" $pic_flag" + ;; + esac + ;; + esac + symtab_cflags= + for arg in $LTCFLAGS; do + case $arg in + -pie | -fpie | -fPIE) ;; + *) func_append symtab_cflags " $arg" ;; + esac + done + + # Now compile the dynamic symbol file. + func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' + + # Clean up the generated files. + func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' + + # Transform the symbol file into the correct name. + symfileobj=$output_objdir/${my_outputname}S.$objext + case $host in + *cygwin* | *mingw* | *cegcc* ) + if test -f "$output_objdir/$my_outputname.def"; then + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + else + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + fi + ;; + *) + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + ;; + esac + ;; + *) + func_fatal_error "unknown suffix for '$my_dlsyms'" + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` + fi +} + +# func_cygming_gnu_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is a GNU/binutils-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_gnu_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` + test -n "$func_cygming_gnu_implib_tmp" +} + +# func_cygming_ms_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is an MS-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_ms_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` + test -n "$func_cygming_ms_implib_tmp" +} + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +# Despite the name, also deal with 64 bit binaries. +func_win32_libid () +{ + $debug_cmd + + win32_libid_type=unknown + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | + $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then + case $nm_interface in + "MS dumpbin") + if func_cygming_ms_implib_p "$1" || + func_cygming_gnu_implib_p "$1" + then + win32_nmres=import + else + win32_nmres= + fi + ;; + *) + func_to_tool_file "$1" func_convert_file_msys_to_w32 + win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | + $SED -n -e ' + 1,100{ + / I /{ + s|.*|import| + p + q + } + }'` + ;; + esac + case $win32_nmres in + import*) win32_libid_type="x86 archive import";; + *) win32_libid_type="x86 archive static";; + esac + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $ECHO "$win32_libid_type" +} + +# func_cygming_dll_for_implib ARG +# +# Platform-specific function to extract the +# name of the DLL associated with the specified +# import library ARG. +# Invoked by eval'ing the libtool variable +# $sharedlib_from_linklib_cmd +# Result is available in the variable +# $sharedlib_from_linklib_result +func_cygming_dll_for_implib () +{ + $debug_cmd + + sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` +} + +# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs +# +# The is the core of a fallback implementation of a +# platform-specific function to extract the name of the +# DLL associated with the specified import library LIBNAME. +# +# SECTION_NAME is either .idata$6 or .idata$7, depending +# on the platform and compiler that created the implib. +# +# Echos the name of the DLL associated with the +# specified import library. +func_cygming_dll_for_implib_fallback_core () +{ + $debug_cmd + + match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` + $OBJDUMP -s --section "$1" "$2" 2>/dev/null | + $SED '/^Contents of section '"$match_literal"':/{ + # Place marker at beginning of archive member dllname section + s/.*/====MARK====/ + p + d + } + # These lines can sometimes be longer than 43 characters, but + # are always uninteresting + /:[ ]*file format pe[i]\{,1\}-/d + /^In archive [^:]*:/d + # Ensure marker is printed + /^====MARK====/p + # Remove all lines with less than 43 characters + /^.\{43\}/!d + # From remaining lines, remove first 43 characters + s/^.\{43\}//' | + $SED -n ' + # Join marker and all lines until next marker into a single line + /^====MARK====/ b para + H + $ b para + b + :para + x + s/\n//g + # Remove the marker + s/^====MARK====// + # Remove trailing dots and whitespace + s/[\. \t]*$// + # Print + /./p' | + # we now have a list, one entry per line, of the stringified + # contents of the appropriate section of all members of the + # archive that possess that section. Heuristic: eliminate + # all those that have a first or second character that is + # a '.' (that is, objdump's representation of an unprintable + # character.) This should work for all archives with less than + # 0x302f exports -- but will fail for DLLs whose name actually + # begins with a literal '.' or a single character followed by + # a '.'. + # + # Of those that remain, print the first one. + $SED -e '/^\./d;/^.\./d;q' +} + +# func_cygming_dll_for_implib_fallback ARG +# Platform-specific function to extract the +# name of the DLL associated with the specified +# import library ARG. +# +# This fallback implementation is for use when $DLLTOOL +# does not support the --identify-strict option. +# Invoked by eval'ing the libtool variable +# $sharedlib_from_linklib_cmd +# Result is available in the variable +# $sharedlib_from_linklib_result +func_cygming_dll_for_implib_fallback () +{ + $debug_cmd + + if func_cygming_gnu_implib_p "$1"; then + # binutils import library + sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` + elif func_cygming_ms_implib_p "$1"; then + # ms-generated import library + sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` + else + # unknown + sharedlib_from_linklib_result= + fi +} + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + $debug_cmd + + f_ex_an_ar_dir=$1; shift + f_ex_an_ar_oldlib=$1 + if test yes = "$lock_old_archive_extraction"; then + lockfile=$f_ex_an_ar_oldlib.lock + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + fi + func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ + 'stat=$?; rm -f "$lockfile"; exit $stat' + if test yes = "$lock_old_archive_extraction"; then + $opt_dry_run || rm -f "$lockfile" + fi + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" + fi +} + + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + $debug_cmd + + my_gentop=$1; shift + my_oldlibs=${1+"$@"} + my_oldobjs= + my_xlib= + my_xabs= + my_xdir= + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + func_basename "$my_xlib" + my_xlib=$func_basename_result + my_xlib_u=$my_xlib + while :; do + case " $extracted_archives " in + *" $my_xlib_u "*) + func_arith $extracted_serial + 1 + extracted_serial=$func_arith_result + my_xlib_u=lt$extracted_serial-$my_xlib ;; + *) break ;; + esac + done + extracted_archives="$extracted_archives $my_xlib_u" + my_xdir=$my_gentop/$my_xlib_u + + func_mkdir_p "$my_xdir" + + case $host in + *-darwin*) + func_verbose "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + $opt_dry_run || { + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + func_basename "$darwin_archive" + darwin_base_archive=$func_basename_result + darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` + if test -n "$darwin_arches"; then + darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches; do + func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" + $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" + cd "unfat-$$/$darwin_base_archive-$darwin_arch" + func_extract_an_archive "`pwd`" "$darwin_base_archive" + cd "$darwin_curdir" + $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" + done # $darwin_arches + ## Okay now we've a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` + $LIPO -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + $RM -rf unfat-$$ + cd "$darwin_orig_dir" + else + cd $darwin_orig_dir + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + } # !$opt_dry_run + ;; + *) + func_extract_an_archive "$my_xdir" "$my_xabs" + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` + done + + func_extract_archives_result=$my_oldobjs +} + + +# func_emit_wrapper [arg=no] +# +# Emit a libtool wrapper script on stdout. +# Don't directly open a file because we may want to +# incorporate the script contents within a cygwin/mingw +# wrapper executable. Must ONLY be called from within +# func_mode_link because it depends on a number of variables +# set therein. +# +# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR +# variable will take. If 'yes', then the emitted script +# will assume that the directory where it is stored is +# the $objdir directory. This is a cygwin/mingw-specific +# behavior. +func_emit_wrapper () +{ + func_emit_wrapper_arg1=${1-no} + + $ECHO "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM (GNU $PACKAGE) $VERSION +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='$sed_quote_subst' + +# Be Bourne compatible +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variables: + generated_by_libtool_version='$macro_version' + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$ECHO are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + file=\"\$0\"" + + qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` + $ECHO "\ + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF' +} + ECHO=\"$qECHO\" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ that is used only on +# windows platforms, and (c) all begin with the string "--lt-" +# (application programs are unlikely to have options that match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's $0 value, followed by "$@". +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=\$0 + shift + for lt_opt + do + case \"\$lt_opt\" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` + test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. + lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` + cat \"\$lt_dump_D/\$lt_dump_F\" + exit 0 + ;; + --lt-*) + \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n \"\$lt_option_debug\"; then + echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" + lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2* | *-cegcc*) + $ECHO "\ + if test -n \"\$lt_option_debug\"; then + \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 + func_lt_dump_args \${1+\"\$@\"} 1>&2 + fi + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $ECHO "\ + if test -n \"\$lt_option_debug\"; then + \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 + func_lt_dump_args \${1+\"\$@\"} 1>&2 + fi + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $ECHO "\ + \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from \$@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case \" \$* \" in + *\\ --lt-*) + for lt_wr_arg + do + case \$lt_wr_arg in + --lt-*) ;; + *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; + esac + shift + done ;; + esac + func_exec_program_core \${1+\"\$@\"} +} + + # Parse options + func_parse_lt_options \"\$0\" \${1+\"\$@\"} + + # Find the directory that this script lives in. + thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 + if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then + # special case for '.' + if test \"\$thisdir\" = \".\"; then + thisdir=\`pwd\` + fi + # remove .libs from thisdir + case \"\$thisdir\" in + *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; + $objdir ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test yes = "$fast_install"; then + $ECHO "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $MKDIR \"\$progdir\" + else + $RM \"\$progdir/\$file\" + fi" + + $ECHO "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + \$ECHO \"\$relink_command_output\" >&2 + $RM \"\$progdir/\$file\" + exit 1 + fi + fi + + $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $RM \"\$progdir/\$program\"; + $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $RM \"\$progdir/\$file\" + fi" + else + $ECHO "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $ECHO "\ + + if test -f \"\$progdir/\$program\"; then" + + # fixup the dll searchpath if we need to. + # + # Fix the DLL searchpath if we need to. Do this before prepending + # to shlibpath, because on Windows, both are PATH and uninstalled + # libraries must come first. + if test -n "$dllsearchpath"; then + $ECHO "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + # Export our shlibpath_var if we have one. + if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $ECHO "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` + + export $shlibpath_var +" + fi + + $ECHO "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. + func_exec_program \${1+\"\$@\"} + fi + else + # The program doesn't exist. + \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 + \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 + \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" +} + + +# func_emit_cwrapperexe_src +# emit the source code for a wrapper executable on stdout +# Must ONLY be called from within func_mode_link because +# it depends on a number of variable set therein. +func_emit_cwrapperexe_src () +{ + cat < +#include +#ifdef _MSC_VER +# include +# include +# include +#else +# include +# include +# ifdef __CYGWIN__ +# include +# endif +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) + +/* declarations of non-ANSI functions */ +#if defined __MINGW32__ +# ifdef __STRICT_ANSI__ +int _putenv (const char *); +# endif +#elif defined __CYGWIN__ +# ifdef __STRICT_ANSI__ +char *realpath (const char *, char *); +int putenv (char *); +int setenv (const char *, const char *, int); +# endif +/* #elif defined other_platform || defined ... */ +#endif + +/* portability defines, excluding path handling macros */ +#if defined _MSC_VER +# define setmode _setmode +# define stat _stat +# define chmod _chmod +# define getcwd _getcwd +# define putenv _putenv +# define S_IXUSR _S_IEXEC +#elif defined __MINGW32__ +# define setmode _setmode +# define stat _stat +# define chmod _chmod +# define getcwd _getcwd +# define putenv _putenv +#elif defined __CYGWIN__ +# define HAVE_SETENV +# define FOPEN_WB "wb" +/* #elif defined other platforms ... */ +#endif + +#if defined PATH_MAX +# define LT_PATHMAX PATH_MAX +#elif defined MAXPATHLEN +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef S_IXOTH +# define S_IXOTH 0 +#endif +#ifndef S_IXGRP +# define S_IXGRP 0 +#endif + +/* path handling portability macros */ +#ifndef DIR_SEPARATOR +# define DIR_SEPARATOR '/' +# define PATH_SEPARATOR ':' +#endif + +#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ + defined __OS2__ +# define HAVE_DOS_BASED_FILE_SYSTEM +# define FOPEN_WB "wb" +# ifndef DIR_SEPARATOR_2 +# define DIR_SEPARATOR_2 '\\' +# endif +# ifndef PATH_SEPARATOR_2 +# define PATH_SEPARATOR_2 ';' +# endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#ifndef PATH_SEPARATOR_2 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) +#else /* PATH_SEPARATOR_2 */ +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) +#endif /* PATH_SEPARATOR_2 */ + +#ifndef FOPEN_WB +# define FOPEN_WB "w" +#endif +#ifndef _O_BINARY +# define _O_BINARY 0 +#endif + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free (stale); stale = 0; } \ +} while (0) + +#if defined LT_DEBUGWRAPPER +static int lt_debug = 1; +#else +static int lt_debug = 0; +#endif + +const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ + +void *xmalloc (size_t num); +char *xstrdup (const char *string); +const char *base_name (const char *name); +char *find_executable (const char *wrapper); +char *chase_symlinks (const char *pathspec); +int make_executable (const char *path); +int check_executable (const char *path); +char *strendzap (char *str, const char *pat); +void lt_debugprintf (const char *file, int line, const char *fmt, ...); +void lt_fatal (const char *file, int line, const char *message, ...); +static const char *nonnull (const char *s); +static const char *nonempty (const char *s); +void lt_setenv (const char *name, const char *value); +char *lt_extend_str (const char *orig_value, const char *add, int to_end); +void lt_update_exe_path (const char *name, const char *value); +void lt_update_lib_path (const char *name, const char *value); +char **prepare_spawn (char **argv); +void lt_dump_script (FILE *f); +EOF + + cat <= 0) + && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) + return 1; + else + return 0; +} + +int +make_executable (const char *path) +{ + int rval = 0; + struct stat st; + + lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", + nonempty (path)); + if ((!path) || (!*path)) + return 0; + + if (stat (path, &st) >= 0) + { + rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); + } + return rval; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise + Does not chase symlinks, even on platforms that support them. +*/ +char * +find_executable (const char *wrapper) +{ + int has_slash = 0; + const char *p; + const char *p_next; + /* static buffer for getcwd */ + char tmp[LT_PATHMAX + 1]; + size_t tmp_len; + char *concat_name; + + lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", + nonempty (wrapper)); + + if ((wrapper == NULL) || (*wrapper == '\0')) + return NULL; + + /* Absolute path? */ +#if defined HAVE_DOS_BASED_FILE_SYSTEM + if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + else + { +#endif + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } +#if defined HAVE_DOS_BASED_FILE_SYSTEM + } +#endif + + for (p = wrapper; *p; p++) + if (*p == '/') + { + has_slash = 1; + break; + } + if (!has_slash) + { + /* no slashes; search PATH */ + const char *path = getenv ("PATH"); + if (path != NULL) + { + for (p = path; *p; p = p_next) + { + const char *q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR (*q)) + break; + p_len = (size_t) (q - p); + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", + nonnull (strerror (errno))); + tmp_len = strlen (tmp); + concat_name = + XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = + XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + } + /* not found in PATH; assume curdir */ + } + /* Relative path | not found in path: prepend cwd */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", + nonnull (strerror (errno))); + tmp_len = strlen (tmp); + concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + return NULL; +} + +char * +chase_symlinks (const char *pathspec) +{ +#ifndef S_ISLNK + return xstrdup (pathspec); +#else + char buf[LT_PATHMAX]; + struct stat s; + char *tmp_pathspec = xstrdup (pathspec); + char *p; + int has_symlinks = 0; + while (strlen (tmp_pathspec) && !has_symlinks) + { + lt_debugprintf (__FILE__, __LINE__, + "checking path component for symlinks: %s\n", + tmp_pathspec); + if (lstat (tmp_pathspec, &s) == 0) + { + if (S_ISLNK (s.st_mode) != 0) + { + has_symlinks = 1; + break; + } + + /* search backwards for last DIR_SEPARATOR */ + p = tmp_pathspec + strlen (tmp_pathspec) - 1; + while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + p--; + if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + { + /* no more DIR_SEPARATORS left */ + break; + } + *p = '\0'; + } + else + { + lt_fatal (__FILE__, __LINE__, + "error accessing file \"%s\": %s", + tmp_pathspec, nonnull (strerror (errno))); + } + } + XFREE (tmp_pathspec); + + if (!has_symlinks) + { + return xstrdup (pathspec); + } + + tmp_pathspec = realpath (pathspec, buf); + if (tmp_pathspec == 0) + { + lt_fatal (__FILE__, __LINE__, + "could not follow symlinks for %s", pathspec); + } + return xstrdup (tmp_pathspec); +#endif +} + +char * +strendzap (char *str, const char *pat) +{ + size_t len, patlen; + + assert (str != NULL); + assert (pat != NULL); + + len = strlen (str); + patlen = strlen (pat); + + if (patlen <= len) + { + str += len - patlen; + if (STREQ (str, pat)) + *str = '\0'; + } + return str; +} + +void +lt_debugprintf (const char *file, int line, const char *fmt, ...) +{ + va_list args; + if (lt_debug) + { + (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); + va_start (args, fmt); + (void) vfprintf (stderr, fmt, args); + va_end (args); + } +} + +static void +lt_error_core (int exit_status, const char *file, + int line, const char *mode, + const char *message, va_list ap) +{ + fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *file, int line, const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); + va_end (ap); +} + +static const char * +nonnull (const char *s) +{ + return s ? s : "(null)"; +} + +static const char * +nonempty (const char *s) +{ + return (s && !*s) ? "(empty)" : nonnull (s); +} + +void +lt_setenv (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_setenv) setting '%s' to '%s'\n", + nonnull (name), nonnull (value)); + { +#ifdef HAVE_SETENV + /* always make a copy, for consistency with !HAVE_SETENV */ + char *str = xstrdup (value); + setenv (name, str, 1); +#else + size_t len = strlen (name) + 1 + strlen (value) + 1; + char *str = XMALLOC (char, len); + sprintf (str, "%s=%s", name, value); + if (putenv (str) != EXIT_SUCCESS) + { + XFREE (str); + } +#endif + } +} + +char * +lt_extend_str (const char *orig_value, const char *add, int to_end) +{ + char *new_value; + if (orig_value && *orig_value) + { + size_t orig_value_len = strlen (orig_value); + size_t add_len = strlen (add); + new_value = XMALLOC (char, add_len + orig_value_len + 1); + if (to_end) + { + strcpy (new_value, orig_value); + strcpy (new_value + orig_value_len, add); + } + else + { + strcpy (new_value, add); + strcpy (new_value + add_len, orig_value); + } + } + else + { + new_value = xstrdup (add); + } + return new_value; +} + +void +lt_update_exe_path (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", + nonnull (name), nonnull (value)); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + /* some systems can't cope with a ':'-terminated path #' */ + size_t len = strlen (new_value); + while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) + { + new_value[--len] = '\0'; + } + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +void +lt_update_lib_path (const char *name, const char *value) +{ + lt_debugprintf (__FILE__, __LINE__, + "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", + nonnull (name), nonnull (value)); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +EOF + case $host_os in + mingw*) + cat <<"EOF" + +/* Prepares an argument vector before calling spawn(). + Note that spawn() does not by itself call the command interpreter + (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : + ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&v); + v.dwPlatformId == VER_PLATFORM_WIN32_NT; + }) ? "cmd.exe" : "command.com"). + Instead it simply concatenates the arguments, separated by ' ', and calls + CreateProcess(). We must quote the arguments since Win32 CreateProcess() + interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a + special way: + - Space and tab are interpreted as delimiters. They are not treated as + delimiters if they are surrounded by double quotes: "...". + - Unescaped double quotes are removed from the input. Their only effect is + that within double quotes, space and tab are treated like normal + characters. + - Backslashes not followed by double quotes are not special. + - But 2*n+1 backslashes followed by a double quote become + n backslashes followed by a double quote (n >= 0): + \" -> " + \\\" -> \" + \\\\\" -> \\" + */ +#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" +char ** +prepare_spawn (char **argv) +{ + size_t argc; + char **new_argv; + size_t i; + + /* Count number of arguments. */ + for (argc = 0; argv[argc] != NULL; argc++) + ; + + /* Allocate new argument vector. */ + new_argv = XMALLOC (char *, argc + 1); + + /* Put quoted arguments into the new argument vector. */ + for (i = 0; i < argc; i++) + { + const char *string = argv[i]; + + if (string[0] == '\0') + new_argv[i] = xstrdup ("\"\""); + else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) + { + int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); + size_t length; + unsigned int backslashes; + const char *s; + char *quoted_string; + char *p; + + length = 0; + backslashes = 0; + if (quote_around) + length++; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + length += backslashes + 1; + length++; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + length += backslashes + 1; + + quoted_string = XMALLOC (char, length + 1); + + p = quoted_string; + backslashes = 0; + if (quote_around) + *p++ = '"'; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + { + unsigned int j; + for (j = backslashes + 1; j > 0; j--) + *p++ = '\\'; + } + *p++ = c; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + { + unsigned int j; + for (j = backslashes; j > 0; j--) + *p++ = '\\'; + *p++ = '"'; + } + *p = '\0'; + + new_argv[i] = quoted_string; + } + else + new_argv[i] = (char *) string; + } + new_argv[argc] = NULL; + + return new_argv; +} +EOF + ;; + esac + + cat <<"EOF" +void lt_dump_script (FILE* f) +{ +EOF + func_emit_wrapper yes | + $SED -n -e ' +s/^\(.\{79\}\)\(..*\)/\1\ +\2/ +h +s/\([\\"]\)/\\\1/g +s/$/\\n/ +s/\([^\n]*\).*/ fputs ("\1", f);/p +g +D' + cat <<"EOF" +} +EOF +} +# end: func_emit_cwrapperexe_src + +# func_win32_import_lib_p ARG +# True if ARG is an import lib, as indicated by $file_magic_cmd +func_win32_import_lib_p () +{ + $debug_cmd + + case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in + *import*) : ;; + *) false ;; + esac +} + +# func_suncc_cstd_abi +# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! +# Several compiler flags select an ABI that is incompatible with the +# Cstd library. Avoid specifying it if any are in CXXFLAGS. +func_suncc_cstd_abi () +{ + $debug_cmd + + case " $compile_command " in + *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) + suncc_use_cstd_abi=no + ;; + *) + suncc_use_cstd_abi=yes + ;; + esac +} + +# func_mode_link arg... +func_mode_link () +{ + $debug_cmd + + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # what system we are compiling for in order to pass an extra + # flag for every libtool invocation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll that has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args=$nonopt + base_compile="$nonopt $@" + compile_command=$nonopt + finalize_command=$nonopt + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + inst_prefix_dir= + new_inherited_linker_flags= + + avoid_version=no + bindir= + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + no_install=no + objs= + os2dllname= + non_pic_objects= + precious_files_regex= + prefer_static_libs=no + preload=false + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + vinfo_number=no + weak_libs= + single_module=$wl-single_module + func_infer_tag $base_compile + + # We need to know -static, to get the right output filenames. + for arg + do + case $arg in + -shared) + test yes != "$build_libtool_libs" \ + && func_fatal_configuration "cannot build a shared library" + build_old_libs=no + break + ;; + -all-static | -static | -static-libtool-libs) + case $arg in + -all-static) + if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then + func_warning "complete static linking is impossible in this configuration" + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + -static) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=built + ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + esac + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg=$1 + shift + func_quote_for_eval "$arg" + qarg=$func_quote_for_eval_unquoted_result + func_append libtool_args " $func_quote_for_eval_result" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + func_append compile_command " @OUTPUT@" + func_append finalize_command " @OUTPUT@" + ;; + esac + + case $prev in + bindir) + bindir=$arg + prev= + continue + ;; + dlfiles|dlprefiles) + $preload || { + # Add the symbol object into the linking commands. + func_append compile_command " @SYMFILE@" + func_append finalize_command " @SYMFILE@" + preload=: + } + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test no = "$dlself"; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test dlprefiles = "$prev"; then + dlself=yes + elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test dlfiles = "$prev"; then + func_append dlfiles " $arg" + else + func_append dlprefiles " $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols=$arg + test -f "$arg" \ + || func_fatal_error "symbol file '$arg' does not exist" + prev= + continue + ;; + expsyms_regex) + export_symbols_regex=$arg + prev= + continue + ;; + framework) + case $host in + *-*-darwin*) + case "$deplibs " in + *" $qarg.ltframework "*) ;; + *) func_append deplibs " $qarg.ltframework" # this is fixed later + ;; + esac + ;; + esac + prev= + continue + ;; + inst_prefix) + inst_prefix_dir=$arg + prev= + continue + ;; + mllvm) + # Clang does not use LLVM to link, so we can simply discard any + # '-mllvm $arg' options when doing the link step. + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat "$save_arg"` + do +# func_append moreargs " $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test none = "$pic_object" && + test none = "$non_pic_object"; then + func_fatal_error "cannot find name of object for '$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + if test none != "$pic_object"; then + # Prepend the subdirectory the object is found in. + pic_object=$xdir$pic_object + + if test dlfiles = "$prev"; then + if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then + func_append dlfiles " $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test dlprefiles = "$prev"; then + # Preload the old-style object. + func_append dlprefiles " $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg=$pic_object + fi + + # Non-PIC object. + if test none != "$non_pic_object"; then + # Prepend the subdirectory the object is found in. + non_pic_object=$xdir$non_pic_object + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test none = "$pic_object"; then + arg=$non_pic_object + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object=$pic_object + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "'$arg' is not a valid libtool object" + fi + fi + done + else + func_fatal_error "link input file '$arg' does not exist" + fi + arg=$save_arg + prev= + continue + ;; + os2dllname) + os2dllname=$arg + prev= + continue + ;; + precious_regex) + precious_files_regex=$arg + prev= + continue + ;; + release) + release=-$arg + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + if test rpath = "$prev"; then + case "$rpath " in + *" $arg "*) ;; + *) func_append rpath " $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) func_append xrpath " $arg" ;; + esac + fi + prev= + continue + ;; + shrext) + shrext_cmds=$arg + prev= + continue + ;; + weak) + func_append weak_libs " $arg" + prev= + continue + ;; + xcclinker) + func_append linker_flags " $qarg" + func_append compiler_flags " $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xcompiler) + func_append compiler_flags " $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xlinker) + func_append linker_flags " $qarg" + func_append compiler_flags " $wl$qarg" + prev= + func_append compile_command " $wl$qarg" + func_append finalize_command " $wl$qarg" + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg=$arg + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + # See comment for -static flag below, for more details. + func_append compile_command " $link_static_flag" + func_append finalize_command " $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + func_fatal_error "'-allow-undefined' must not be used because it is the default" + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -bindir) + prev=bindir + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + func_fatal_error "more than one -exported-symbols argument is not allowed" + fi + if test X-export-symbols = "X$arg"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -framework) + prev=framework + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + func_append compile_command " $arg" + func_append finalize_command " $arg" + ;; + esac + continue + ;; + + -L*) + func_stripname "-L" '' "$arg" + if test -z "$func_stripname_result"; then + if test "$#" -gt 0; then + func_fatal_error "require no space between '-L' and '$1'" + else + func_fatal_error "need path for '-L' option" + fi + fi + func_resolve_sysroot "$func_stripname_result" + dir=$func_resolve_sysroot_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + test -z "$absdir" && \ + func_fatal_error "cannot determine absolute directory name of '$dir'" + dir=$absdir + ;; + esac + case "$deplibs " in + *" -L$dir "* | *" $arg "*) + # Will only happen for absolute or sysroot arguments + ;; + *) + # Preserve sysroot, but never include relative directories + case $dir in + [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; + *) func_append deplibs " -L$dir" ;; + esac + func_append lib_search_path " $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; + ::) dllsearchpath=$dir;; + *) func_append dllsearchpath ":$dir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) func_append dllsearchpath ":$testbindir";; + esac + ;; + esac + continue + ;; + + -l*) + if test X-lc = "X$arg" || test X-lm = "X$arg"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-os2*) + # These systems don't actually have a C library (as such) + test X-lc = "X$arg" && continue + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + # Do not include libc due to us having libc/libc_r. + test X-lc = "X$arg" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + func_append deplibs " System.ltframework" + continue + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + test X-lc = "X$arg" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test X-lc = "X$arg" && continue + ;; + esac + elif test X-lc_r = "X$arg"; then + case $host in + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + func_append deplibs " $arg" + continue + ;; + + -mllvm) + prev=mllvm + continue + ;; + + -module) + module=yes + continue + ;; + + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + # Darwin uses the -arch flag to determine output architecture. + -model|-arch|-isysroot|--sysroot) + func_append compiler_flags " $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + prev=xcompiler + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + func_append compiler_flags " $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case "$new_inherited_linker_flags " in + *" $arg "*) ;; + * ) func_append new_inherited_linker_flags " $arg" ;; + esac + continue + ;; + + -multi_module) + single_module=$wl-multi_module + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + func_warning "'-no-install' is ignored for $host" + func_warning "assuming '-no-fast-install' instead" + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -os2dllname) + prev=os2dllname + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + func_stripname '-R' '' "$arg" + dir=$func_stripname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + =*) + func_stripname '=' '' "$dir" + dir=$lt_sysroot$func_stripname_result + ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) func_append xrpath " $dir" ;; + esac + continue + ;; + + -shared) + # The effects of -shared are defined in a previous loop. + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -static | -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -weak) + prev=weak + continue + ;; + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs=$IFS; IFS=, + for flag in $args; do + IFS=$save_ifs + func_quote_for_eval "$flag" + func_append arg " $func_quote_for_eval_result" + func_append compiler_flags " $func_quote_for_eval_result" + done + IFS=$save_ifs + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Wl,*) + func_stripname '-Wl,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs=$IFS; IFS=, + for flag in $args; do + IFS=$save_ifs + func_quote_for_eval "$flag" + func_append arg " $wl$func_quote_for_eval_result" + func_append compiler_flags " $wl$func_quote_for_eval_result" + func_append linker_flags " $func_quote_for_eval_result" + done + IFS=$save_ifs + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # -msg_* for osf cc + -msg_*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + + # Flags to be passed through unchanged, with rationale: + # -64, -mips[0-9] enable 64-bit mode for the SGI compiler + # -r[0-9][0-9]* specify processor for the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler + # +DA*, +DD* enable 64-bit mode for the HP compiler + # -q* compiler args for the IBM compiler + # -m*, -t[45]*, -txscale* architecture-specific flags for GCC + # -F/path path to uninstalled frameworks, gcc on darwin + # -p, -pg, --coverage, -fprofile-* profiling flags for GCC + # -fstack-protector* stack protector flags for GCC + # @file GCC response files + # -tp=* Portland pgcc target processor selection + # --sysroot=* for sysroot support + # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + # -specs=* GCC specs files + # -stdlib=* select c++ std lib with clang + # -fsanitize=* Clang/GCC memory and address sanitizer + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ + -specs=*|-fsanitize=*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + func_append compile_command " $arg" + func_append finalize_command " $arg" + func_append compiler_flags " $arg" + continue + ;; + + -Z*) + if test os2 = "`expr $host : '.*\(os2\)'`"; then + # OS/2 uses -Zxxx to specify OS/2-specific options + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case $arg in + -Zlinker | -Zstack) + prev=xcompiler + ;; + esac + continue + else + # Otherwise treat like 'Some other compiler flag' below + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + fi + ;; + + # Some other compiler flag. + -* | +*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + + *.$objext) + # A standard object. + func_append objs " $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test none = "$pic_object" && + test none = "$non_pic_object"; then + func_fatal_error "cannot find name of object for '$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + test none = "$pic_object" || { + # Prepend the subdirectory the object is found in. + pic_object=$xdir$pic_object + + if test dlfiles = "$prev"; then + if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then + func_append dlfiles " $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test dlprefiles = "$prev"; then + # Preload the old-style object. + func_append dlprefiles " $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg=$pic_object + } + + # Non-PIC object. + if test none != "$non_pic_object"; then + # Prepend the subdirectory the object is found in. + non_pic_object=$xdir$non_pic_object + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test none = "$pic_object"; then + arg=$non_pic_object + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object=$pic_object + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir=$func_dirname_result + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "'$arg' is not a valid libtool object" + fi + fi + ;; + + *.$libext) + # An archive. + func_append deplibs " $arg" + func_append old_deplibs " $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + func_resolve_sysroot "$arg" + if test dlfiles = "$prev"; then + # This library was specified with -dlopen. + func_append dlfiles " $func_resolve_sysroot_result" + prev= + elif test dlprefiles = "$prev"; then + # The library was specified with -dlpreopen. + func_append dlprefiles " $func_resolve_sysroot_result" + prev= + else + func_append deplibs " $func_resolve_sysroot_result" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + done # argument parsing loop + + test -n "$prev" && \ + func_fatal_help "the '$prevarg' option requires an argument" + + if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + func_basename "$output" + outputname=$func_basename_result + libobjs_save=$libobjs + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + # Definition is injected by LT_CONFIG during libtool generation. + func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" + + func_dirname "$output" "/" "" + output_objdir=$func_dirname_result$objdir + func_to_tool_file "$output_objdir/" + tool_output_objdir=$func_to_tool_file_result + # Create the object directory. + func_mkdir_p "$output_objdir" + + # Determine the type of output + case $output in + "") + func_fatal_help "you must specify an output file" + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if $opt_preserve_dup_deps; then + case "$libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append libs " $deplib" + done + + if test lib = "$linkmode"; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if $opt_duplicate_compiler_generated_deps; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; + esac + func_append pre_post_deps " $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + + case $linkmode in + lib) + passes="conv dlpreopen link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=false + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + + for pass in $passes; do + # The preopen pass in lib mode reverses $deplibs; put it back here + # so that -L comes before libs that need it for instance... + if test lib,link = "$linkmode,$pass"; then + ## FIXME: Find the place where the list is rebuilt in the wrong + ## order, and fix it there properly + tmp_deplibs= + for deplib in $deplibs; do + tmp_deplibs="$deplib $tmp_deplibs" + done + deplibs=$tmp_deplibs + fi + + if test lib,link = "$linkmode,$pass" || + test prog,scan = "$linkmode,$pass"; then + libs=$deplibs + deplibs= + fi + if test prog = "$linkmode"; then + case $pass in + dlopen) libs=$dlfiles ;; + dlpreopen) libs=$dlprefiles ;; + link) + libs="$deplibs %DEPLIBS%" + test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" + ;; + esac + fi + if test lib,dlpreopen = "$linkmode,$pass"; then + # Collect and forward deplibs of preopened libtool libs + for lib in $dlprefiles; do + # Ignore non-libtool-libs + dependency_libs= + func_resolve_sysroot "$lib" + case $lib in + *.la) func_source "$func_resolve_sysroot_result" ;; + esac + + # Collect preopened libtool deplibs, except any this library + # has declared as weak libs + for deplib in $dependency_libs; do + func_basename "$deplib" + deplib_base=$func_basename_result + case " $weak_libs " in + *" $deplib_base "*) ;; + *) func_append deplibs " $deplib" ;; + esac + done + done + libs=$dlprefiles + fi + if test dlopen = "$pass"; then + # Collect dlpreopened libraries + save_deplibs=$deplibs + deplibs= + fi + + for deplib in $libs; do + lib= + found=false + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + func_append compiler_flags " $deplib" + if test lib = "$linkmode"; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) func_append new_inherited_linker_flags " $deplib" ;; + esac + fi + fi + continue + ;; + -l*) + if test lib != "$linkmode" && test prog != "$linkmode"; then + func_warning "'-l' is ignored for archives/objects" + continue + fi + func_stripname '-l' '' "$deplib" + name=$func_stripname_result + if test lib = "$linkmode"; then + searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" + else + searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" + fi + for searchdir in $searchdirs; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib=$searchdir/lib$name$search_ext + if test -f "$lib"; then + if test .la = "$search_ext"; then + found=: + else + found=false + fi + break 2 + fi + done + done + if $found; then + # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + case " $predeps $postdeps " in + *" $deplib "*) + if func_lalib_p "$lib"; then + library_names= + old_library= + func_source "$lib" + for l in $old_library $library_names; do + ll=$l + done + if test "X$ll" = "X$old_library"; then # only static version available + found=false + func_dirname "$lib" "" "." + ladir=$func_dirname_result + lib=$ladir/$old_library + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + else + # deplib doesn't seem to be a libtool library + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + ;; # -l + *.ltframework) + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + if test lib = "$linkmode"; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) func_append new_inherited_linker_flags " $deplib" ;; + esac + fi + fi + continue + ;; + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test conv = "$pass" && continue + newdependency_libs="$deplib $newdependency_libs" + func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + prog) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + continue + fi + if test scan = "$pass"; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + *) + func_warning "'-L' is ignored for archives/objects" + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test link = "$pass"; then + func_stripname '-R' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + dir=$func_resolve_sysroot_result + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) func_append xrpath " $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) + func_resolve_sysroot "$deplib" + lib=$func_resolve_sysroot_result + ;; + *.$libext) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + # Linking convenience modules into shared libraries is allowed, + # but linking other static libraries is non-portable. + case " $dlpreconveniencelibs " in + *" $deplib "*) ;; + *) + valid_a_lib=false + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=: + fi + ;; + pass_all) + valid_a_lib=: + ;; + esac + if $valid_a_lib; then + echo + $ECHO "*** Warning: Linking the shared library $output against the" + $ECHO "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + else + echo + $ECHO "*** Warning: Trying to link with static lib archive $deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because the file extensions .$libext of this argument makes me believe" + echo "*** that it is just a static archive that I should not use here." + fi + ;; + esac + continue + ;; + prog) + if test link != "$pass"; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test conv = "$pass"; then + deplibs="$deplib $deplibs" + elif test prog = "$linkmode"; then + if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + func_append newdlprefiles " $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + func_append newdlfiles " $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=: + continue + ;; + esac # case $deplib + + $found || test -f "$lib" \ + || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$lib" \ + || func_fatal_error "'$lib' is not a valid libtool archive" + + func_dirname "$lib" "" "." + ladir=$func_dirname_result + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + inherited_linker_flags= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + avoidtemprpath= + + + # Read the .la file + func_source "$lib" + + # Convert "-framework foo" to "foo.ltframework" + if test -n "$inherited_linker_flags"; then + tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` + for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do + case " $new_inherited_linker_flags " in + *" $tmp_inherited_linker_flag "*) ;; + *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; + esac + done + fi + dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + if test lib,link = "$linkmode,$pass" || + test prog,scan = "$linkmode,$pass" || + { test prog != "$linkmode" && test lib != "$linkmode"; }; then + test -n "$dlopen" && func_append dlfiles " $dlopen" + test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" + fi + + if test conv = "$pass"; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + func_fatal_error "cannot find name of link library for '$lib'" + fi + # It is a libtool convenience library, so add in its objects. + func_append convenience " $ladir/$objdir/$old_library" + func_append old_convenience " $ladir/$objdir/$old_library" + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append tmp_libs " $deplib" + done + elif test prog != "$linkmode" && test lib != "$linkmode"; then + func_fatal_error "'$lib' is not a convenience library" + fi + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + if test -n "$old_library" && + { test yes = "$prefer_static_libs" || + test built,no = "$prefer_static_libs,$installed"; }; then + linklib=$old_library + else + for l in $old_library $library_names; do + linklib=$l + done + fi + if test -z "$linklib"; then + func_fatal_error "cannot find name of link library for '$lib'" + fi + + # This library was specified with -dlopen. + if test dlopen = "$pass"; then + test -z "$libdir" \ + && func_fatal_error "cannot -dlopen a convenience library: '$lib'" + if test -z "$dlname" || + test yes != "$dlopen_support" || + test no = "$build_libtool_libs" + then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + func_append dlprefiles " $lib $dependency_libs" + else + func_append newdlfiles " $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + func_warning "cannot determine absolute directory name of '$ladir'" + func_warning "passing it literally to the linker, although it might fail" + abs_ladir=$ladir + fi + ;; + esac + func_basename "$lib" + laname=$func_basename_result + + # Find the relevant object directory and library name. + if test yes = "$installed"; then + if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + func_warning "library '$lib' was moved." + dir=$ladir + absdir=$abs_ladir + libdir=$abs_ladir + else + dir=$lt_sysroot$libdir + absdir=$lt_sysroot$libdir + fi + test yes = "$hardcode_automatic" && avoidtemprpath=yes + else + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir=$ladir + absdir=$abs_ladir + # Remove this search path later + func_append notinst_path " $abs_ladir" + else + dir=$ladir/$objdir + absdir=$abs_ladir/$objdir + # Remove this search path later + func_append notinst_path " $abs_ladir" + fi + fi # $installed = yes + func_stripname 'lib' '.la' "$laname" + name=$func_stripname_result + + # This library was specified with -dlpreopen. + if test dlpreopen = "$pass"; then + if test -z "$libdir" && test prog = "$linkmode"; then + func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" + fi + case $host in + # special handling for platforms with PE-DLLs. + *cygwin* | *mingw* | *cegcc* ) + # Linker will automatically link against shared library if both + # static and shared are present. Therefore, ensure we extract + # symbols from the import library if a shared library is present + # (otherwise, the dlopen module name will be incorrect). We do + # this by putting the import library name into $newdlprefiles. + # We recover the dlopen module name by 'saving' the la file + # name in a special purpose variable, and (later) extracting the + # dlname from the la file. + if test -n "$dlname"; then + func_tr_sh "$dir/$linklib" + eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" + func_append newdlprefiles " $dir/$linklib" + else + func_append newdlprefiles " $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + func_append dlpreconveniencelibs " $dir/$old_library" + fi + ;; + * ) + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + func_append newdlprefiles " $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + func_append dlpreconveniencelibs " $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + func_append newdlprefiles " $dir/$dlname" + else + func_append newdlprefiles " $dir/$linklib" + fi + ;; + esac + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test lib = "$linkmode"; then + deplibs="$dir/$old_library $deplibs" + elif test prog,link = "$linkmode,$pass"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test prog = "$linkmode" && test link != "$pass"; then + func_append newlib_search_path " $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=false + if test no != "$link_all_deplibs" || test -z "$library_names" || + test no = "$build_libtool_libs"; then + linkalldeplibs=: + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" + ;; + esac + # Need to link against all dependency_libs? + if $linkalldeplibs; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append tmp_libs " $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test prog,link = "$linkmode,$pass"; then + if test -n "$library_names" && + { { test no = "$prefer_static_libs" || + test built,yes = "$prefer_static_libs,$installed"; } || + test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then + # Make sure the rpath contains only unique directories. + case $temp_rpath: in + *"$absdir:"*) ;; + *) func_append temp_rpath "$absdir:" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) func_append compile_rpath " $absdir" ;; + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if $alldeplibs && + { test pass_all = "$deplibs_check_method" || + { test yes = "$build_libtool_libs" && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + use_static_libs=$prefer_static_libs + if test built = "$use_static_libs" && test yes = "$installed"; then + use_static_libs=no + fi + if test -n "$library_names" && + { test no = "$use_static_libs" || test -z "$old_library"; }; then + case $host in + *cygwin* | *mingw* | *cegcc* | *os2*) + # No point in relinking DLLs because paths are not encoded + func_append notinst_deplibs " $lib" + need_relink=no + ;; + *) + if test no = "$installed"; then + func_append notinst_deplibs " $lib" + need_relink=yes + fi + ;; + esac + # This is a shared library + + # Warn about portability, can't link against -module's on some + # systems (darwin). Don't bleat about dlopened modules though! + dlopenmodule= + for dlpremoduletest in $dlprefiles; do + if test "X$dlpremoduletest" = "X$lib"; then + dlopenmodule=$dlpremoduletest + break + fi + done + if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then + echo + if test prog = "$linkmode"; then + $ECHO "*** Warning: Linking the executable $output against the loadable module" + else + $ECHO "*** Warning: Linking the shared library $output against the loadable module" + fi + $ECHO "*** $linklib is not portable!" + fi + if test lib = "$linkmode" && + test yes = "$hardcode_into_libs"; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) func_append compile_rpath " $absdir" ;; + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + shift + realname=$1 + shift + libname=`eval "\\$ECHO \"$libname_spec\""` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname=$dlname + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw* | *cegcc* | *os2*) + func_arith $current - $age + major=$func_arith_result + versuffix=-$major + ;; + esac + eval soname=\"$soname_spec\" + else + soname=$realname + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot=$soname + func_basename "$soroot" + soname=$func_basename_result + func_stripname 'lib' '.dll' "$soname" + newlib=libimp-$func_stripname_result.a + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + func_verbose "extracting exported symbol list from '$soname'" + func_execute_cmds "$extract_expsyms_cmds" 'exit $?' + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + func_verbose "generating import library for '$soname'" + func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test prog = "$linkmode" || test relink != "$opt_mode"; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test no = "$hardcode_direct"; then + add=$dir/$linklib + case $host in + *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; + *-*-sysv4*uw2*) add_dir=-L$dir ;; + *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ + *-*-unixware7*) add_dir=-L$dir ;; + *-*-darwin* ) + # if the lib is a (non-dlopened) module then we cannot + # link against it, someone is ignoring the earlier warnings + if /usr/bin/file -L $add 2> /dev/null | + $GREP ": [^:]* bundle" >/dev/null; then + if test "X$dlopenmodule" != "X$lib"; then + $ECHO "*** Warning: lib $linklib is a module, not a shared library" + if test -z "$old_library"; then + echo + echo "*** And there doesn't seem to be a static archive available" + echo "*** The link will probably fail, sorry" + else + add=$dir/$old_library + fi + elif test -n "$old_library"; then + add=$dir/$old_library + fi + fi + esac + elif test no = "$hardcode_minus_L"; then + case $host in + *-*-sunos*) add_shlibpath=$dir ;; + esac + add_dir=-L$dir + add=-l$name + elif test no = "$hardcode_shlibpath_var"; then + add_shlibpath=$dir + add=-l$name + else + lib_linked=no + fi + ;; + relink) + if test yes = "$hardcode_direct" && + test no = "$hardcode_direct_absolute"; then + add=$dir/$linklib + elif test yes = "$hardcode_minus_L"; then + add_dir=-L$absdir + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + func_append add_dir " -L$inst_prefix_dir$libdir" + ;; + esac + fi + add=-l$name + elif test yes = "$hardcode_shlibpath_var"; then + add_shlibpath=$dir + add=-l$name + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test yes != "$lib_linked"; then + func_fatal_configuration "unsupported hardcode properties" + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) func_append compile_shlibpath "$add_shlibpath:" ;; + esac + fi + if test prog = "$linkmode"; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test yes != "$hardcode_direct" && + test yes != "$hardcode_minus_L" && + test yes = "$hardcode_shlibpath_var"; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) func_append finalize_shlibpath "$libdir:" ;; + esac + fi + fi + fi + + if test prog = "$linkmode" || test relink = "$opt_mode"; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test yes = "$hardcode_direct" && + test no = "$hardcode_direct_absolute"; then + add=$libdir/$linklib + elif test yes = "$hardcode_minus_L"; then + add_dir=-L$libdir + add=-l$name + elif test yes = "$hardcode_shlibpath_var"; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) func_append finalize_shlibpath "$libdir:" ;; + esac + add=-l$name + elif test yes = "$hardcode_automatic"; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib"; then + add=$inst_prefix_dir$libdir/$linklib + else + add=$libdir/$linklib + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir=-L$libdir + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + func_append add_dir " -L$inst_prefix_dir$libdir" + ;; + esac + fi + add=-l$name + fi + + if test prog = "$linkmode"; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test prog = "$linkmode"; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test unsupported != "$hardcode_direct"; then + test -n "$old_library" && linklib=$old_library + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test yes = "$build_libtool_libs"; then + # Not a shared library + if test pass_all != "$deplibs_check_method"; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + echo + $ECHO "*** Warning: This system cannot link to static lib archive $lib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + if test yes = "$module"; then + echo "*** But as you try to build a module library, libtool will still create " + echo "*** a static module, that should work as long as the dlopening application" + echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using 'nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** 'nm' from GNU binutils and a full rebuild may help." + fi + if test no = "$build_old_libs"; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test lib = "$linkmode"; then + if test -n "$dependency_libs" && + { test yes != "$hardcode_into_libs" || + test yes = "$build_old_libs" || + test yes = "$link_static"; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) func_stripname '-R' '' "$libdir" + temp_xrpath=$func_stripname_result + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) func_append xrpath " $temp_xrpath";; + esac;; + *) func_append temp_deplibs " $libdir";; + esac + done + dependency_libs=$temp_deplibs + fi + + func_append newlib_search_path " $absdir" + # Link against this library + test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result";; + *) func_resolve_sysroot "$deplib" ;; + esac + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $func_resolve_sysroot_result "*) + func_append specialdeplibs " $func_resolve_sysroot_result" ;; + esac + fi + func_append tmp_libs " $func_resolve_sysroot_result" + done + + if test no != "$link_all_deplibs"; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + path= + case $deplib in + -L*) path=$deplib ;; + *.la) + func_resolve_sysroot "$deplib" + deplib=$func_resolve_sysroot_result + func_dirname "$deplib" "" "." + dir=$func_dirname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + func_warning "cannot determine absolute directory name of '$dir'" + absdir=$dir + fi + ;; + esac + if $GREP "^installed=no" $deplib > /dev/null; then + case $host in + *-*-darwin*) + depdepl= + eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names"; then + for tmp in $deplibrary_names; do + depdepl=$tmp + done + if test -f "$absdir/$objdir/$depdepl"; then + depdepl=$absdir/$objdir/$depdepl + darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + if test -z "$darwin_install_name"; then + darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + fi + func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" + func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" + path= + fi + fi + ;; + *) + path=-L$absdir/$objdir + ;; + esac + else + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "'$deplib' is not a valid libtool archive" + test "$absdir" != "$libdir" && \ + func_warning "'$deplib' seems to be moved" + + path=-L$absdir + fi + ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + if test link = "$pass"; then + if test prog = "$linkmode"; then + compile_deplibs="$new_inherited_linker_flags $compile_deplibs" + finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" + else + compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + fi + fi + dependency_libs=$newdependency_libs + if test dlpreopen = "$pass"; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test dlopen != "$pass"; then + test conv = "$pass" || { + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) func_append lib_search_path " $dir" ;; + esac + done + newlib_search_path= + } + + if test prog,link = "$linkmode,$pass"; then + vars="compile_deplibs finalize_deplibs" + else + vars=deplibs + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) func_append tmp_libs " $deplib" ;; + esac + ;; + *) func_append tmp_libs " $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + + # Add Sun CC postdeps if required: + test CXX = "$tagname" && { + case $host_os in + linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C++ 5.9 + func_suncc_cstd_abi + + if test no != "$suncc_use_cstd_abi"; then + func_append postdeps ' -library=Cstd -library=Crun' + fi + ;; + esac + ;; + + solaris*) + func_cc_basename "$CC" + case $func_cc_basename_result in + CC* | sunCC*) + func_suncc_cstd_abi + + if test no != "$suncc_use_cstd_abi"; then + func_append postdeps ' -library=Cstd -library=Crun' + fi + ;; + esac + ;; + esac + } + + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i= + ;; + esac + if test -n "$i"; then + func_append tmp_libs " $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test prog = "$linkmode"; then + dlfiles=$newdlfiles + fi + if test prog = "$linkmode" || test lib = "$linkmode"; then + dlprefiles=$newdlprefiles + fi + + case $linkmode in + oldlib) + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + func_warning "'-dlopen' is ignored for archives" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "'-l' and '-L' are ignored for archives" ;; + esac + + test -n "$rpath" && \ + func_warning "'-rpath' is ignored for archives" + + test -n "$xrpath" && \ + func_warning "'-R' is ignored for archives" + + test -n "$vinfo" && \ + func_warning "'-version-info/-version-number' is ignored for archives" + + test -n "$release" && \ + func_warning "'-release' is ignored for archives" + + test -n "$export_symbols$export_symbols_regex" && \ + func_warning "'-export-symbols' is ignored for archives" + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs=$output + func_append objs "$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form 'libNAME.la'. + case $outputname in + lib*) + func_stripname 'lib' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + test no = "$module" \ + && func_fatal_help "libtool library '$output' must begin with 'lib'" + + if test no != "$need_lib_prefix"; then + # Add the "lib" prefix for modules if required + func_stripname '' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + func_stripname '' '.la' "$outputname" + libname=$func_stripname_result + fi + ;; + esac + + if test -n "$objs"; then + if test pass_all != "$deplibs_check_method"; then + func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" + else + echo + $ECHO "*** Warning: Linking the shared library $output against the non-libtool" + $ECHO "*** objects $objs is not portable!" + func_append libobjs " $objs" + fi + fi + + test no = "$dlself" \ + || func_warning "'-dlopen self' is ignored for libtool libraries" + + set dummy $rpath + shift + test 1 -lt "$#" \ + && func_warning "ignoring multiple '-rpath's for a libtool library" + + install_libdir=$1 + + oldlibs= + if test -z "$rpath"; then + if test yes = "$build_libtool_libs"; then + # Building a libtool convenience library. + # Some compilers have problems with a '.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + test -n "$vinfo" && \ + func_warning "'-version-info/-version-number' is ignored for convenience libraries" + + test -n "$release" && \ + func_warning "'-release' is ignored for convenience libraries" + else + + # Parse the version information argument. + save_ifs=$IFS; IFS=: + set dummy $vinfo 0 0 0 + shift + IFS=$save_ifs + + test -n "$7" && \ + func_fatal_help "too many parameters to '-version-info'" + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major=$1 + number_minor=$2 + number_revision=$3 + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # that has an extra 1 added just for fun + # + case $version_type in + # correct linux to gnu/linux during the next big refactor + darwin|freebsd-elf|linux|osf|windows|none) + func_arith $number_major + $number_minor + current=$func_arith_result + age=$number_minor + revision=$number_revision + ;; + freebsd-aout|qnx|sunos) + current=$number_major + revision=$number_minor + age=0 + ;; + irix|nonstopux) + func_arith $number_major + $number_minor + current=$func_arith_result + age=$number_minor + revision=$number_minor + lt_irix_increment=no + ;; + *) + func_fatal_configuration "$modename: unknown library version type '$version_type'" + ;; + esac + ;; + no) + current=$1 + revision=$2 + age=$3 + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "CURRENT '$current' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + case $revision in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "REVISION '$revision' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + case $age in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "AGE '$age' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" + ;; + esac + + if test "$age" -gt "$current"; then + func_error "AGE '$age' is greater than the current interface number '$current'" + func_fatal_error "'$vinfo' is not valid version information" + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + # Darwin ld doesn't like 0 for these options... + func_arith $current + 1 + minor_current=$func_arith_result + xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + # On Darwin other compilers + case $CC in + nagfor*) + verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + ;; + *) + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + esac + ;; + + freebsd-aout) + major=.$current + versuffix=.$current.$revision + ;; + + freebsd-elf) + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + ;; + + irix | nonstopux) + if test no = "$lt_irix_increment"; then + func_arith $current - $age + else + func_arith $current - $age + 1 + fi + major=$func_arith_result + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring=$verstring_prefix$major.$revision + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test 0 -ne "$loop"; do + func_arith $revision - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring=$verstring_prefix$major.$iface:$verstring + done + + # Before this point, $major must not contain '.'. + major=.$major + versuffix=$major.$revision + ;; + + linux) # correct to gnu/linux during the next big refactor + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision + ;; + + osf) + func_arith $current - $age + major=.$func_arith_result + versuffix=.$current.$age.$revision + verstring=$current.$age.$revision + + # Add in all the interfaces that we are compatible with. + loop=$age + while test 0 -ne "$loop"; do + func_arith $current - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring=$verstring:$iface.0 + done + + # Make executables depend on our current version. + func_append verstring ":$current.0" + ;; + + qnx) + major=.$current + versuffix=.$current + ;; + + sco) + major=.$current + versuffix=.$current + ;; + + sunos) + major=.$current + versuffix=.$current.$revision + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 file systems. + func_arith $current - $age + major=$func_arith_result + versuffix=-$major + ;; + + *) + func_fatal_configuration "unknown library version type '$version_type'" + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring=0.0 + ;; + esac + if test no = "$need_version"; then + versuffix= + else + versuffix=.0.0 + fi + fi + + # Remove version info from name if versioning should be avoided + if test yes,no = "$avoid_version,$need_version"; then + major= + versuffix= + verstring= + fi + + # Check to see if the archive will have undefined symbols. + if test yes = "$allow_undefined"; then + if test unsupported = "$allow_undefined_flag"; then + if test yes = "$build_old_libs"; then + func_warning "undefined symbols not allowed in $host shared libraries; building static only" + build_libtool_libs=no + else + func_fatal_error "can't build $host shared library unless -no-undefined is specified" + fi + fi + else + # Don't allow undefined symbols. + allow_undefined_flag=$no_undefined_flag + fi + + fi + + func_generate_dlsyms "$libname" "$libname" : + func_append libobjs " $symfileobj" + test " " = "$libobjs" && libobjs= + + if test relink != "$opt_mode"; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$ECHO "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext | *.gcno) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) + if test -n "$precious_files_regex"; then + if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + func_append removelist " $p" + ;; + *) ;; + esac + done + test -n "$removelist" && \ + func_show_eval "${RM}r \$removelist" + fi + + # Now set the variables for building old libraries. + if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then + func_append oldlibs " $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + #for path in $notinst_path; do + # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` + # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` + # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` + #done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + func_replace_sysroot "$libdir" + func_append temp_xrpath " -R$func_replace_sysroot_result" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + done + if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles=$dlfiles + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) func_append dlfiles " $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles=$dlprefiles + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) func_append dlprefiles " $lib" ;; + esac + done + + if test yes = "$build_libtool_libs"; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + func_append deplibs " System.ltframework" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test yes = "$build_libtool_need_lc"; then + func_append deplibs " -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release= + versuffix= + major= + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $opt_dry_run || $RM conftest.c + cat > conftest.c </dev/null` + $nocaseglob + else + potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` + fi + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null | + $GREP " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib=$potent_lib + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | $SED 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; + *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | + $SED -e 10q | + $EGREP "$file_magic_regex" > /dev/null; then + func_append newdeplibs " $a_deplib" + a_deplib= + break 2 + fi + done + done + fi + if test -n "$a_deplib"; then + droppeddeps=yes + echo + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib"; then + $ECHO "*** with $libname but no candidates were found. (...for file magic test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a file magic. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + func_append newdeplibs " $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + for a_deplib in $deplibs; do + case $a_deplib in + -l*) + func_stripname -l '' "$a_deplib" + name=$func_stripname_result + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + case " $predeps $postdeps " in + *" $a_deplib "*) + func_append newdeplibs " $a_deplib" + a_deplib= + ;; + esac + fi + if test -n "$a_deplib"; then + libname=`eval "\\$ECHO \"$libname_spec\""` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib=$potent_lib # see symlink-check above in file_magic test + if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ + $EGREP "$match_pattern_regex" > /dev/null; then + func_append newdeplibs " $a_deplib" + a_deplib= + break 2 + fi + done + done + fi + if test -n "$a_deplib"; then + droppeddeps=yes + echo + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have" + echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib"; then + $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a regex pattern. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + func_append newdeplibs " $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs= + tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + for i in $predeps $postdeps; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` + done + fi + case $tmp_deplibs in + *[!\ \ ]*) + echo + if test none = "$deplibs_check_method"; then + echo "*** Warning: inter-library dependencies are not supported in this platform." + else + echo "*** Warning: inter-library dependencies are not known to be supported." + fi + echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + ;; + esac + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library with the System framework + newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` + ;; + esac + + if test yes = "$droppeddeps"; then + if test yes = "$module"; then + echo + echo "*** Warning: libtool could not satisfy all declared inter-library" + $ECHO "*** dependencies of module $libname. Therefore, libtool will create" + echo "*** a static module, that should work as long as the dlopening" + echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using 'nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** 'nm' from GNU binutils and a full rebuild may help." + fi + if test no = "$build_old_libs"; then + oldlibs=$output_objdir/$libname.$libext + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + echo "*** The inter-library dependencies that have been dropped here will be" + echo "*** automatically added whenever a program is linked with this library" + echo "*** or is declared to -dlopen it." + + if test no = "$allow_undefined"; then + echo + echo "*** Since this library must not contain undefined symbols," + echo "*** because either the platform does not support them or" + echo "*** it was explicitly requested with -no-undefined," + echo "*** libtool will only create a static version of it." + if test no = "$build_old_libs"; then + oldlibs=$output_objdir/$libname.$libext + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + case $host in + *-*-darwin*) + newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $deplibs " in + *" -L$path/$objdir "*) + func_append new_libs " -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) func_append new_libs " $deplib" ;; + esac + ;; + *) func_append new_libs " $deplib" ;; + esac + done + deplibs=$new_libs + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test yes = "$build_libtool_libs"; then + # Remove $wl instances when linking with ld. + # FIXME: should test the right _cmds variable. + case $archive_cmds in + *\$LD\ *) wl= ;; + esac + if test yes = "$hardcode_into_libs"; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath=$finalize_rpath + test relink = "$opt_mode" || rpath=$compile_rpath$rpath + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + func_replace_sysroot "$libdir" + libdir=$func_replace_sysroot_result + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append dep_rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) func_append perm_rpath " $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + func_append rpath "$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath=$finalize_shlibpath + test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext_cmds\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + shift + realname=$1 + shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname=$realname + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib=$output_objdir/$realname + linknames= + for link + do + func_append linknames " $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` + test "X$libobjs" = "X " && libobjs= + + delfiles= + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" + export_symbols=$output_objdir/$libname.uexp + func_append delfiles " $export_symbols" + fi + + orig_export_symbols= + case $host_os in + cygwin* | mingw* | cegcc*) + if test -n "$export_symbols" && test -z "$export_symbols_regex"; then + # exporting using user supplied symfile + func_dll_def_p "$export_symbols" || { + # and it's NOT already a .def file. Must figure out + # which of the given symbols are data symbols and tag + # them as such. So, trigger use of export_symbols_cmds. + # export_symbols gets reassigned inside the "prepare + # the list of exported symbols" if statement, so the + # include_expsyms logic still works. + orig_export_symbols=$export_symbols + export_symbols= + always_export_symbols=yes + } + fi + ;; + esac + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then + func_verbose "generating symbol list for '$libname.la'" + export_symbols=$output_objdir/$libname.exp + $opt_dry_run || $RM $export_symbols + cmds=$export_symbols_cmds + save_ifs=$IFS; IFS='~' + for cmd1 in $cmds; do + IFS=$save_ifs + # Take the normal branch if the nm_file_list_spec branch + # doesn't work or if tool conversion is not needed. + case $nm_file_list_spec~$to_tool_file_cmd in + *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) + try_normal_branch=yes + eval cmd=\"$cmd1\" + func_len " $cmd" + len=$func_len_result + ;; + *) + try_normal_branch=no + ;; + esac + if test yes = "$try_normal_branch" \ + && { test "$len" -lt "$max_cmd_len" \ + || test "$max_cmd_len" -le -1; } + then + func_show_eval "$cmd" 'exit $?' + skipped_export=false + elif test -n "$nm_file_list_spec"; then + func_basename "$output" + output_la=$func_basename_result + save_libobjs=$libobjs + save_output=$output + output=$output_objdir/$output_la.nm + func_to_tool_file "$output" + libobjs=$nm_file_list_spec$func_to_tool_file_result + func_append delfiles " $output" + func_verbose "creating $NM input file list: $output" + for obj in $save_libobjs; do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" + done > "$output" + eval cmd=\"$cmd1\" + func_show_eval "$cmd" 'exit $?' + output=$save_output + libobjs=$save_libobjs + skipped_export=false + else + # The command line is too long to execute in one step. + func_verbose "using reloadable object file for export list..." + skipped_export=: + # Break out early, otherwise skipped_export may be + # set to false by a later but shorter cmd. + break + fi + done + IFS=$save_ifs + if test -n "$export_symbols_regex" && test : != "$skipped_export"; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols=$export_symbols + test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols + $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' + fi + + if test : != "$skipped_export" && test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for '$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands, which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + func_append delfiles " $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + func_append tmp_deplibs " $test_deplib" + ;; + esac + done + deplibs=$tmp_deplibs + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec" && + test yes = "$compiler_needs_object" && + test -z "$libobjs"; then + # extract the archives, so we have objects to list. + # TODO: could optimize this to just extract one archive. + whole_archive_flag_spec= + fi + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + else + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $convenience + func_append libobjs " $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + fi + + if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + func_append linker_flags " $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test relink = "$opt_mode"; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test yes = "$module" && test -n "$module_cmds"; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test : != "$skipped_export" && + func_len " $test_cmds" && + len=$func_len_result && + test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise + # or, if using GNU ld and skipped_export is not :, use a linker + # script. + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + func_basename "$output" + output_la=$func_basename_result + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + last_robj= + k=1 + + if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then + output=$output_objdir/$output_la.lnkscript + func_verbose "creating GNU ld script: $output" + echo 'INPUT (' > $output + for obj in $save_libobjs + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" >> $output + done + echo ')' >> $output + func_append delfiles " $output" + func_to_tool_file "$output" + output=$func_to_tool_file_result + elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then + output=$output_objdir/$output_la.lnk + func_verbose "creating linker input file list: $output" + : > $output + set x $save_libobjs + shift + firstobj= + if test yes = "$compiler_needs_object"; then + firstobj="$1 " + shift + fi + for obj + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" >> $output + done + func_append delfiles " $output" + func_to_tool_file "$output" + output=$firstobj\"$file_list_spec$func_to_tool_file_result\" + else + if test -n "$save_libobjs"; then + func_verbose "creating reloadable object files..." + output=$output_objdir/$output_la-$k.$objext + eval test_cmds=\"$reload_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + if test -z "$objlist" || + test "$len" -lt "$max_cmd_len"; then + func_append objlist " $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test 1 -eq "$k"; then + # The first file doesn't have a previous command to add. + reload_objs=$objlist + eval concat_cmds=\"$reload_cmds\" + else + # All subsequent reloadable object files will link in + # the last one created. + reload_objs="$objlist $last_robj" + eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" + fi + last_robj=$output_objdir/$output_la-$k.$objext + func_arith $k + 1 + k=$func_arith_result + output=$output_objdir/$output_la-$k.$objext + objlist=" $obj" + func_len " $last_robj" + func_arith $len0 + $func_len_result + len=$func_arith_result + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + reload_objs="$objlist $last_robj" + eval concat_cmds=\"\$concat_cmds$reload_cmds\" + if test -n "$last_robj"; then + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" + fi + func_append delfiles " $output" + + else + output= + fi + + ${skipped_export-false} && { + func_verbose "generating symbol list for '$libname.la'" + export_symbols=$output_objdir/$libname.exp + $opt_dry_run || $RM $export_symbols + libobjs=$output + # Append the command to create the export file. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" + if test -n "$last_robj"; then + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" + fi + } + + test -n "$save_libobjs" && + func_verbose "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs=$IFS; IFS='~' + for cmd in $concat_cmds; do + IFS=$save_ifs + $opt_quiet || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS=$save_ifs + + if test -n "$export_symbols_regex" && ${skipped_export-false}; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + + ${skipped_export-false} && { + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols=$export_symbols + test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols + $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' + fi + + if test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for '$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands, which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + func_append delfiles " $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + } + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test yes = "$module" && test -n "$module_cmds"; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + fi + + if test -n "$delfiles"; then + # Append the command to remove temporary files to $cmds. + eval cmds=\"\$cmds~\$RM $delfiles\" + fi + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $dlprefiles + func_append libobjs " $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + + save_ifs=$IFS; IFS='~' + for cmd in $cmds; do + IFS=$sp$nl + eval cmd=\"$cmd\" + IFS=$save_ifs + $opt_quiet || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS=$save_ifs + + # Restore the uninstalled library and exit + if test relink = "$opt_mode"; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? + + if test -n "$convenience"; then + if test -z "$whole_archive_flag_spec"; then + func_show_eval '${RM}r "$gentop"' + fi + fi + + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test yes = "$module" || test yes = "$export_dynamic"; then + # On all known operating systems, these are identical. + dlname=$soname + fi + fi + ;; + + obj) + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + func_warning "'-dlopen' is ignored for objects" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "'-l' and '-L' are ignored for objects" ;; + esac + + test -n "$rpath" && \ + func_warning "'-rpath' is ignored for objects" + + test -n "$xrpath" && \ + func_warning "'-R' is ignored for objects" + + test -n "$vinfo" && \ + func_warning "'-version-info' is ignored for objects" + + test -n "$release" && \ + func_warning "'-release' is ignored for objects" + + case $output in + *.lo) + test -n "$objs$old_deplibs" && \ + func_fatal_error "cannot build library object '$output' from non-libtool objects" + + libobj=$output + func_lo2o "$libobj" + obj=$func_lo2o_result + ;; + *) + libobj= + obj=$output + ;; + esac + + # Delete the old objects. + $opt_dry_run || $RM $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # if reload_cmds runs $LD directly, get rid of -Wl from + # whole_archive_flag_spec and hope we can get by with turning comma + # into space. + case $reload_cmds in + *\$LD[\ \$]*) wl= ;; + esac + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" + test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` + reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags + else + gentop=$output_objdir/${obj}x + func_append generated " $gentop" + + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" + fi + fi + + # If we're not building shared, we need to use non_pic_objs + test yes = "$build_libtool_libs" || libobjs=$non_pic_objects + + # Create the old-style object. + reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs + + output=$obj + func_execute_cmds "$reload_cmds" 'exit $?' + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + fi + + test yes = "$build_libtool_libs" || { + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? + exit $EXIT_SUCCESS + } + + if test -n "$pic_flag" || test default != "$pic_mode"; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output=$libobj + func_execute_cmds "$reload_cmds" 'exit $?' + fi + + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) func_stripname '' '.exe' "$output" + output=$func_stripname_result.exe;; + esac + test -n "$vinfo" && \ + func_warning "'-version-info' is ignored for programs" + + test -n "$release" && \ + func_warning "'-release' is ignored for programs" + + $preload \ + && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ + && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` + finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` + ;; + esac + + case $host in + *-*-darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + # But is supposedly fixed on 10.4 or later (yay!). + if test CXX = "$tagname"; then + case ${MACOSX_DEPLOYMENT_TARGET-10.0} in + 10.[0123]) + func_append compile_command " $wl-bind_at_load" + func_append finalize_command " $wl-bind_at_load" + ;; + esac + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $compile_deplibs " in + *" -L$path/$objdir "*) + func_append new_libs " -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $compile_deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) func_append new_libs " $deplib" ;; + esac + ;; + *) func_append new_libs " $deplib" ;; + esac + done + compile_deplibs=$new_libs + + + func_append compile_command " $compile_deplibs" + func_append finalize_command " $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) func_append finalize_rpath " $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) func_append perm_rpath " $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; + ::) dllsearchpath=$libdir;; + *) func_append dllsearchpath ":$libdir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) func_append dllsearchpath ":$testbindir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath=$rpath + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs=$libdir + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + func_append rpath " $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) func_append finalize_perm_rpath " $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir=$hardcode_libdirs + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath=$rpath + + if test -n "$libobjs" && test yes = "$build_old_libs"; then + # Transform all the library objects into standard objects. + compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` + finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` + fi + + func_generate_dlsyms "$outputname" "@PROGRAM@" false + + # template prelinking step + if test -n "$prelink_cmds"; then + func_execute_cmds "$prelink_cmds" 'exit $?' + fi + + wrappers_required=: + case $host in + *cegcc* | *mingw32ce*) + # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. + wrappers_required=false + ;; + *cygwin* | *mingw* ) + test yes = "$build_libtool_libs" || wrappers_required=false + ;; + *) + if test no = "$need_relink" || test yes != "$build_libtool_libs"; then + wrappers_required=false + fi + ;; + esac + $wrappers_required || { + # Replace the output file specification. + compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + link_command=$compile_command$compile_rpath + + # We have no uninstalled library dependencies, so finalize right now. + exit_status=0 + func_show_eval "$link_command" 'exit_status=$?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + # Delete the generated files. + if test -f "$output_objdir/${outputname}S.$objext"; then + func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' + fi + + exit $exit_status + } + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + func_append rpath "$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + func_append rpath "$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test yes = "$no_install"; then + # We don't need to create a wrapper script. + link_command=$compile_var$compile_command$compile_rpath + # Replace the output file specification. + link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $opt_dry_run || $RM $output + # Link the executable and exit + func_show_eval "$link_command" 'exit $?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + exit $EXIT_SUCCESS + fi + + case $hardcode_action,$fast_install in + relink,*) + # Fast installation is not supported + link_command=$compile_var$compile_command$compile_rpath + relink_command=$finalize_var$finalize_command$finalize_rpath + + func_warning "this platform does not like uninstalled shared libraries" + func_warning "'$output' will be relinked during installation" + ;; + *,yes) + link_command=$finalize_var$compile_command$finalize_rpath + relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` + ;; + *,no) + link_command=$compile_var$compile_command$compile_rpath + relink_command=$finalize_var$finalize_command$finalize_rpath + ;; + *,needless) + link_command=$finalize_var$compile_command$finalize_rpath + relink_command= + ;; + esac + + # Replace the output file specification. + link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname + + func_show_eval "$link_command" 'exit $?' + + if test -n "$postlink_cmds"; then + func_to_tool_file "$output_objdir/$outputname" + postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` + func_execute_cmds "$postlink_cmds" 'exit $?' + fi + + # Now create the wrapper script. + func_verbose "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + fi + + # Only actually do things if not in dry run mode. + $opt_dry_run || { + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) func_stripname '' '.exe' "$output" + output=$func_stripname_result ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + func_stripname '' '.exe' "$outputname" + outputname=$func_stripname_result ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + func_dirname_and_basename "$output" "" "." + output_name=$func_basename_result + output_path=$func_dirname_result + cwrappersource=$output_path/$objdir/lt-$output_name.c + cwrapper=$output_path/$output_name.exe + $RM $cwrappersource $cwrapper + trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + func_emit_cwrapperexe_src > $cwrappersource + + # The wrapper executable is built using the $host compiler, + # because it contains $host paths and files. If cross- + # compiling, it, like the target executable, must be + # executed on the $host or under an emulation environment. + $opt_dry_run || { + $LTCC $LTCFLAGS -o $cwrapper $cwrappersource + $STRIP $cwrapper + } + + # Now, create the wrapper script for func_source use: + func_ltwrapper_scriptname $cwrapper + $RM $func_ltwrapper_scriptname_result + trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 + $opt_dry_run || { + # note: this script will not be executed, so do not chmod. + if test "x$build" = "x$host"; then + $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result + else + func_emit_wrapper no > $func_ltwrapper_scriptname_result + fi + } + ;; + * ) + $RM $output + trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 + + func_emit_wrapper no > $output + chmod +x $output + ;; + esac + } + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + case $build_libtool_libs in + convenience) + oldobjs="$libobjs_save $symfileobj" + addlibs=$convenience + build_libtool_libs=no + ;; + module) + oldobjs=$libobjs_save + addlibs=$old_convenience + build_libtool_libs=no + ;; + *) + oldobjs="$old_deplibs $non_pic_objects" + $preload && test -f "$symfileobj" \ + && func_append oldobjs " $symfileobj" + addlibs=$old_convenience + ;; + esac + + if test -n "$addlibs"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $addlibs + func_append oldobjs " $func_extract_archives_result" + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then + cmds=$old_archive_from_new_cmds + else + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + + func_extract_archives $gentop $dlprefiles + func_append oldobjs " $func_extract_archives_result" + fi + + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + func_basename "$obj" + $ECHO "$func_basename_result" + done | sort | sort -uc >/dev/null 2>&1); then + : + else + echo "copying selected object files to avoid basename conflicts..." + gentop=$output_objdir/${outputname}x + func_append generated " $gentop" + func_mkdir_p "$gentop" + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + func_basename "$obj" + objbase=$func_basename_result + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + func_arith $counter + 1 + counter=$func_arith_result + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + func_append oldobjs " $gentop/$newobj" + ;; + *) func_append oldobjs " $obj" ;; + esac + done + fi + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result + eval cmds=\"$old_archive_cmds\" + + func_len " $cmds" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + elif test -n "$archiver_list_spec"; then + func_verbose "using command file archive linking..." + for obj in $oldobjs + do + func_to_tool_file "$obj" + $ECHO "$func_to_tool_file_result" + done > $output_objdir/$libname.libcmd + func_to_tool_file "$output_objdir/$libname.libcmd" + oldobjs=" $archiver_list_spec$func_to_tool_file_result" + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + func_verbose "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + oldobjs= + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + eval test_cmds=\"$old_archive_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + for obj in $save_oldobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + func_append objlist " $obj" + if test "$len" -lt "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj"; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" + objlist= + len=$len0 + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test -z "$oldobjs"; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + func_execute_cmds "$cmds" 'exit $?' + done + + test -n "$generated" && \ + func_show_eval "${RM}r$generated" + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test yes = "$build_old_libs" && old_library=$libname.$libext + func_verbose "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + if test yes = "$hardcode_automatic"; then + relink_command= + fi + + # Only create the output if not a dry run. + $opt_dry_run || { + for installed in no yes; do + if test yes = "$installed"; then + if test -z "$install_libdir"; then + break + fi + output=$output_objdir/${outputname}i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + func_basename "$deplib" + name=$func_basename_result + func_resolve_sysroot "$deplib" + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` + test -z "$libdir" && \ + func_fatal_error "'$deplib' is not a valid libtool archive" + func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" + ;; + -L*) + func_stripname -L '' "$deplib" + func_replace_sysroot "$func_stripname_result" + func_append newdependency_libs " -L$func_replace_sysroot_result" + ;; + -R*) + func_stripname -R '' "$deplib" + func_replace_sysroot "$func_stripname_result" + func_append newdependency_libs " -R$func_replace_sysroot_result" + ;; + *) func_append newdependency_libs " $deplib" ;; + esac + done + dependency_libs=$newdependency_libs + newdlfiles= + + for lib in $dlfiles; do + case $lib in + *.la) + func_basename "$lib" + name=$func_basename_result + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "'$lib' is not a valid libtool archive" + func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" + ;; + *) func_append newdlfiles " $lib" ;; + esac + done + dlfiles=$newdlfiles + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + *.la) + # Only pass preopened files to the pseudo-archive (for + # eventual linking with the app. that links it) if we + # didn't already link the preopened objects directly into + # the library: + func_basename "$lib" + name=$func_basename_result + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "'$lib' is not a valid libtool archive" + func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" + ;; + esac + done + dlprefiles=$newdlprefiles + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; + *) abs=`pwd`"/$lib" ;; + esac + func_append newdlfiles " $abs" + done + dlfiles=$newdlfiles + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; + *) abs=`pwd`"/$lib" ;; + esac + func_append newdlprefiles " $abs" + done + dlprefiles=$newdlprefiles + fi + $RM $output + # place dlname in correct position for cygwin + # In fact, it would be nice if we could use this code for all target + # systems that can't hard-code library paths into their executables + # and that have no shared library path variable independent of PATH, + # but it turns out we can't easily determine that from inspecting + # libtool variables, so we have to hard-code the OSs to which it + # applies here; at the moment, that means platforms that use the PE + # object format with DLL files. See the long comment at the top of + # tests/bindir.at for full details. + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) + # If a -bindir argument was supplied, place the dll there. + if test -n "$bindir"; then + func_relative_path "$install_libdir" "$bindir" + tdlname=$func_relative_path_result/$dlname + else + # Otherwise fall back on heuristic. + tdlname=../bin/$dlname + fi + ;; + esac + $ECHO > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM (GNU $PACKAGE) $VERSION +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags='$new_inherited_linker_flags' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Names of additional weak libraries provided by this library +weak_library_names='$weak_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test no,yes = "$installed,$need_relink"; then + $ECHO >> $output "\ +relink_command=\"$relink_command\"" + fi + done + } + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' + ;; + esac + exit $EXIT_SUCCESS +} + +if test link = "$opt_mode" || test relink = "$opt_mode"; then + func_mode_link ${1+"$@"} +fi + + +# func_mode_uninstall arg... +func_mode_uninstall () +{ + $debug_cmd + + RM=$nonopt + files= + rmforce=false + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic=$magic + + for arg + do + case $arg in + -f) func_append RM " $arg"; rmforce=: ;; + -*) func_append RM " $arg" ;; + *) func_append files " $arg" ;; + esac + done + + test -z "$RM" && \ + func_fatal_help "you must specify an RM program" + + rmdirs= + + for file in $files; do + func_dirname "$file" "" "." + dir=$func_dirname_result + if test . = "$dir"; then + odir=$objdir + else + odir=$dir/$objdir + fi + func_basename "$file" + name=$func_basename_result + test uninstall = "$opt_mode" && odir=$dir + + # Remember odir for removal later, being careful to avoid duplicates + if test clean = "$opt_mode"; then + case " $rmdirs " in + *" $odir "*) ;; + *) func_append rmdirs " $odir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if { test -L "$file"; } >/dev/null 2>&1 || + { test -h "$file"; } >/dev/null 2>&1 || + test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif $rmforce; then + continue + fi + + rmfiles=$file + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if func_lalib_p "$file"; then + func_source $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + func_append rmfiles " $odir/$n" + done + test -n "$old_library" && func_append rmfiles " $odir/$old_library" + + case $opt_mode in + clean) + case " $library_names " in + *" $dlname "*) ;; + *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; + esac + test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" + ;; + uninstall) + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' + fi + # FIXME: should reinstall the best remaining shared library. + ;; + esac + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if func_lalib_p "$file"; then + + # Read the .lo file + func_source $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" && test none != "$pic_object"; then + func_append rmfiles " $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" && test none != "$non_pic_object"; then + func_append rmfiles " $dir/$non_pic_object" + fi + fi + ;; + + *) + if test clean = "$opt_mode"; then + noexename=$name + case $file in + *.exe) + func_stripname '' '.exe' "$file" + file=$func_stripname_result + func_stripname '' '.exe' "$name" + noexename=$func_stripname_result + # $file with .exe has already been added to rmfiles, + # add $file without .exe + func_append rmfiles " $file" + ;; + esac + # Do a test to see if this is a libtool program. + if func_ltwrapper_p "$file"; then + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + relink_command= + func_source $func_ltwrapper_scriptname_result + func_append rmfiles " $func_ltwrapper_scriptname_result" + else + relink_command= + func_source $dir/$noexename + fi + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + func_append rmfiles " $odir/$name $odir/${name}S.$objext" + if test yes = "$fast_install" && test -n "$relink_command"; then + func_append rmfiles " $odir/lt-$name" + fi + if test "X$noexename" != "X$name"; then + func_append rmfiles " $odir/lt-$noexename.c" + fi + fi + fi + ;; + esac + func_show_eval "$RM $rmfiles" 'exit_status=1' + done + + # Try to remove the $objdir's in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + func_show_eval "rmdir $dir >/dev/null 2>&1" + fi + done + + exit $exit_status +} + +if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then + func_mode_uninstall ${1+"$@"} +fi + +test -z "$opt_mode" && { + help=$generic_help + func_fatal_help "you must specify a MODE" +} + +test -z "$exec_cmd" && \ + func_fatal_help "invalid operation mode '$opt_mode'" + +if test -n "$exec_cmd"; then + eval exec "$exec_cmd" + exit $EXIT_FAILURE +fi + +exit $exit_status + + +# The TAGs below are defined such that we never get into a situation +# where we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/src/secp256k1/build-aux/m4/ax_prog_cc_for_build.m4 b/src/secp256k1/build-aux/m4/ax_prog_cc_for_build.m4 new file mode 100644 index 0000000..77fd346 --- /dev/null +++ b/src/secp256k1/build-aux/m4/ax_prog_cc_for_build.m4 @@ -0,0 +1,125 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_CC_FOR_BUILD +# +# DESCRIPTION +# +# This macro searches for a C compiler that generates native executables, +# that is a C compiler that surely is not a cross-compiler. This can be +# useful if you have to generate source code at compile-time like for +# example GCC does. +# +# The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything +# needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD). +# The value of these variables can be overridden by the user by specifying +# a compiler with an environment variable (like you do for standard CC). +# +# It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object +# file extensions for the build platform, and GCC_FOR_BUILD to `yes' if +# the compiler we found is GCC. All these variables but GCC_FOR_BUILD are +# substituted in the Makefile. +# +# LICENSE +# +# Copyright (c) 2008 Paolo Bonzini +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD]) +AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([AC_EXEEXT])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl + +dnl Use the standard macros, but make them use other variable names +dnl +pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl +pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl +pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl +pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl +pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl +pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl +pushdef([ac_cv_objext], ac_cv_build_objext)dnl +pushdef([ac_exeext], ac_build_exeext)dnl +pushdef([ac_objext], ac_build_objext)dnl +pushdef([CC], CC_FOR_BUILD)dnl +pushdef([CPP], CPP_FOR_BUILD)dnl +pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl +pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl +pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl +pushdef([host], build)dnl +pushdef([host_alias], build_alias)dnl +pushdef([host_cpu], build_cpu)dnl +pushdef([host_vendor], build_vendor)dnl +pushdef([host_os], build_os)dnl +pushdef([ac_cv_host], ac_cv_build)dnl +pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl +pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl +pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl +pushdef([ac_cv_host_os], ac_cv_build_os)dnl +pushdef([ac_cpp], ac_build_cpp)dnl +pushdef([ac_compile], ac_build_compile)dnl +pushdef([ac_link], ac_build_link)dnl + +save_cross_compiling=$cross_compiling +save_ac_tool_prefix=$ac_tool_prefix +cross_compiling=no +ac_tool_prefix= + +AC_PROG_CC +AC_PROG_CPP +AC_EXEEXT + +ac_tool_prefix=$save_ac_tool_prefix +cross_compiling=$save_cross_compiling + +dnl Restore the old definitions +dnl +popdef([ac_link])dnl +popdef([ac_compile])dnl +popdef([ac_cpp])dnl +popdef([ac_cv_host_os])dnl +popdef([ac_cv_host_vendor])dnl +popdef([ac_cv_host_cpu])dnl +popdef([ac_cv_host_alias])dnl +popdef([ac_cv_host])dnl +popdef([host_os])dnl +popdef([host_vendor])dnl +popdef([host_cpu])dnl +popdef([host_alias])dnl +popdef([host])dnl +popdef([LDFLAGS])dnl +popdef([CPPFLAGS])dnl +popdef([CFLAGS])dnl +popdef([CPP])dnl +popdef([CC])dnl +popdef([ac_objext])dnl +popdef([ac_exeext])dnl +popdef([ac_cv_objext])dnl +popdef([ac_cv_exeext])dnl +popdef([ac_cv_prog_cc_g])dnl +popdef([ac_cv_prog_cc_cross])dnl +popdef([ac_cv_prog_cc_works])dnl +popdef([ac_cv_prog_gcc])dnl +popdef([ac_cv_prog_CPP])dnl + +dnl Finally, set Makefile variables +dnl +BUILD_EXEEXT=$ac_build_exeext +BUILD_OBJEXT=$ac_build_objext +AC_SUBST(BUILD_EXEEXT)dnl +AC_SUBST(BUILD_OBJEXT)dnl +AC_SUBST([CFLAGS_FOR_BUILD])dnl +AC_SUBST([CPPFLAGS_FOR_BUILD])dnl +AC_SUBST([LDFLAGS_FOR_BUILD])dnl +]) diff --git a/src/secp256k1/build-aux/m4/bitcoin_secp.m4 b/src/secp256k1/build-aux/m4/bitcoin_secp.m4 new file mode 100644 index 0000000..d41bbb6 --- /dev/null +++ b/src/secp256k1/build-aux/m4/bitcoin_secp.m4 @@ -0,0 +1,65 @@ +dnl libsecp25k1 helper checks +AC_DEFUN([SECP_INT128_CHECK],[ +has_int128=$ac_cv_type___int128 +]) + +dnl +AC_DEFUN([SECP_64BIT_ASM_CHECK],[ +AC_MSG_CHECKING(for x86_64 assembly availability) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include ]],[[ + uint64_t a = 11, tmp; + __asm__ __volatile__("movq $0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx"); + ]])],[has_64bit_asm=yes],[has_64bit_asm=no]) +AC_MSG_RESULT([$has_64bit_asm]) +]) + +dnl +AC_DEFUN([SECP_OPENSSL_CHECK],[ + has_libcrypto=no + m4_ifdef([PKG_CHECK_MODULES],[ + PKG_CHECK_MODULES([CRYPTO], [libcrypto], [has_libcrypto=yes],[has_libcrypto=no]) + if test x"$has_libcrypto" = x"yes"; then + TEMP_LIBS="$LIBS" + LIBS="$LIBS $CRYPTO_LIBS" + AC_CHECK_LIB(crypto, main,[AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed])],[has_libcrypto=no]) + LIBS="$TEMP_LIBS" + fi + ]) + if test x$has_libcrypto = xno; then + AC_CHECK_HEADER(openssl/crypto.h,[ + AC_CHECK_LIB(crypto, main,[ + has_libcrypto=yes + CRYPTO_LIBS=-lcrypto + AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed]) + ]) + ]) + LIBS= + fi +if test x"$has_libcrypto" = x"yes" && test x"$has_openssl_ec" = x; then + AC_MSG_CHECKING(for EC functions in libcrypto) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + #include ]],[[ + EC_KEY *eckey = EC_KEY_new_by_curve_name(NID_secp256k1); + ECDSA_sign(0, NULL, 0, NULL, NULL, eckey); + ECDSA_verify(0, NULL, 0, NULL, 0, eckey); + EC_KEY_free(eckey); + ]])],[has_openssl_ec=yes],[has_openssl_ec=no]) + AC_MSG_RESULT([$has_openssl_ec]) +fi +]) + +dnl +AC_DEFUN([SECP_GMP_CHECK],[ +if test x"$has_gmp" != x"yes"; then + CPPFLAGS_TEMP="$CPPFLAGS" + CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS" + LIBS_TEMP="$LIBS" + LIBS="$GMP_LIBS $LIBS" + AC_CHECK_HEADER(gmp.h,[AC_CHECK_LIB(gmp, __gmpz_init,[has_gmp=yes; GMP_LIBS="$GMP_LIBS -lgmp"; AC_DEFINE(HAVE_LIBGMP,1,[Define this symbol if libgmp is installed])])]) + CPPFLAGS="$CPPFLAGS_TEMP" + LIBS="$LIBS_TEMP" +fi +]) diff --git a/src/secp256k1/build-aux/m4/libtool.m4 b/src/secp256k1/build-aux/m4/libtool.m4 new file mode 100644 index 0000000..10ab284 --- /dev/null +++ b/src/secp256k1/build-aux/m4/libtool.m4 @@ -0,0 +1,8388 @@ +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +# +# Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +m4_define([_LT_COPYING], [dnl +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +]) + +# serial 58 LT_INIT + + +# LT_PREREQ(VERSION) +# ------------------ +# Complain and exit if this libtool version is less that VERSION. +m4_defun([LT_PREREQ], +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, + [m4_default([$3], + [m4_fatal([Libtool version $1 or higher is required], + 63)])], + [$2])]) + + +# _LT_CHECK_BUILDDIR +# ------------------ +# Complain if the absolute build directory name contains unusual characters +m4_defun([_LT_CHECK_BUILDDIR], +[case `pwd` in + *\ * | *\ *) + AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; +esac +]) + + +# LT_INIT([OPTIONS]) +# ------------------ +AC_DEFUN([LT_INIT], +[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK +AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +AC_BEFORE([$0], [LT_LANG])dnl +AC_BEFORE([$0], [LT_OUTPUT])dnl +AC_BEFORE([$0], [LTDL_INIT])dnl +m4_require([_LT_CHECK_BUILDDIR])dnl + +dnl Autoconf doesn't catch unexpanded LT_ macros by default: +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 +dnl unless we require an AC_DEFUNed macro: +AC_REQUIRE([LTOPTIONS_VERSION])dnl +AC_REQUIRE([LTSUGAR_VERSION])dnl +AC_REQUIRE([LTVERSION_VERSION])dnl +AC_REQUIRE([LTOBSOLETE_VERSION])dnl +m4_require([_LT_PROG_LTMAIN])dnl + +_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) + +dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS=$ltmain + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +_LT_SETUP + +# Only expand once: +m4_define([LT_INIT]) +])# LT_INIT + +# Old names: +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PROG_LIBTOOL], []) +dnl AC_DEFUN([AM_PROG_LIBTOOL], []) + + +# _LT_PREPARE_CC_BASENAME +# ----------------------- +m4_defun([_LT_PREPARE_CC_BASENAME], [ +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in @S|@*""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} +])# _LT_PREPARE_CC_BASENAME + + +# _LT_CC_BASENAME(CC) +# ------------------- +# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME, +# but that macro is also expanded into generated libtool script, which +# arranges for $SED and $ECHO to be set by different means. +m4_defun([_LT_CC_BASENAME], +[m4_require([_LT_PREPARE_CC_BASENAME])dnl +AC_REQUIRE([_LT_DECL_SED])dnl +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl +func_cc_basename $1 +cc_basename=$func_cc_basename_result +]) + + +# _LT_FILEUTILS_DEFAULTS +# ---------------------- +# It is okay to use these file commands and assume they have been set +# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'. +m4_defun([_LT_FILEUTILS_DEFAULTS], +[: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +])# _LT_FILEUTILS_DEFAULTS + + +# _LT_SETUP +# --------- +m4_defun([_LT_SETUP], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl + +_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl +dnl +_LT_DECL([], [host_alias], [0], [The host system])dnl +_LT_DECL([], [host], [0])dnl +_LT_DECL([], [host_os], [0])dnl +dnl +_LT_DECL([], [build_alias], [0], [The build system])dnl +_LT_DECL([], [build], [0])dnl +_LT_DECL([], [build_os], [0])dnl +dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +test -z "$LN_S" && LN_S="ln -s" +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl +dnl +AC_REQUIRE([LT_CMD_MAX_LEN])dnl +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl +dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl +m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl +m4_require([_LT_CMD_OLD_ARCHIVE])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_WITH_SYSROOT])dnl +m4_require([_LT_CMD_TRUNCATE])dnl + +_LT_CONFIG_LIBTOOL_INIT([ +# See if we are running on zsh, and set the options that allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi +]) +if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + +_LT_CHECK_OBJDIR + +m4_require([_LT_TAG_COMPILER])dnl + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld=$lt_cv_prog_gnu_ld + +old_CC=$CC +old_CFLAGS=$CFLAGS + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + _LT_PATH_MAGIC + fi + ;; +esac + +# Use C for the default configuration in the libtool script +LT_SUPPORTED_TAG([CC]) +_LT_LANG_C_CONFIG +_LT_LANG_DEFAULT_CONFIG +_LT_CONFIG_COMMANDS +])# _LT_SETUP + + +# _LT_PREPARE_SED_QUOTE_VARS +# -------------------------- +# Define a few sed substitution that help us do robust quoting. +m4_defun([_LT_PREPARE_SED_QUOTE_VARS], +[# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' +]) + +# _LT_PROG_LTMAIN +# --------------- +# Note that this code is called both from 'configure', and 'config.status' +# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, +# 'config.status' has no value for ac_aux_dir unless we are using Automake, +# so we pass a copy along to make sure it has a sensible value anyway. +m4_defun([_LT_PROG_LTMAIN], +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) +ltmain=$ac_aux_dir/ltmain.sh +])# _LT_PROG_LTMAIN + + +## ------------------------------------- ## +## Accumulate code for creating libtool. ## +## ------------------------------------- ## + +# So that we can recreate a full libtool script including additional +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS +# in macros and then make a single call at the end using the 'libtool' +# label. + + +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) +# ---------------------------------------- +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL_INIT], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_INIT], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_INIT]) + + +# _LT_CONFIG_LIBTOOL([COMMANDS]) +# ------------------------------ +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) + + +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) +# ----------------------------------------------------- +m4_defun([_LT_CONFIG_SAVE_COMMANDS], +[_LT_CONFIG_LIBTOOL([$1]) +_LT_CONFIG_LIBTOOL_INIT([$2]) +]) + + +# _LT_FORMAT_COMMENT([COMMENT]) +# ----------------------------- +# Add leading comment marks to the start of each line, and a trailing +# full-stop to the whole comment if one is not present already. +m4_define([_LT_FORMAT_COMMENT], +[m4_ifval([$1], [ +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], + [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) +)]) + + + +## ------------------------ ## +## FIXME: Eliminate VARNAME ## +## ------------------------ ## + + +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) +# ------------------------------------------------------------------- +# CONFIGNAME is the name given to the value in the libtool script. +# VARNAME is the (base) name used in the configure script. +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on +# VARNAME. Any other value will be used directly. +m4_define([_LT_DECL], +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], + [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], + [m4_ifval([$1], [$1], [$2])]) + lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) + m4_ifval([$4], + [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) + lt_dict_add_subkey([lt_decl_dict], [$2], + [tagged?], [m4_ifval([$5], [yes], [no])])]) +]) + + +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) +# -------------------------------------------------------- +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) + + +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_tag_varnames], +[_lt_decl_filter([tagged?], [yes], $@)]) + + +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) +# --------------------------------------------------------- +m4_define([_lt_decl_filter], +[m4_case([$#], + [0], [m4_fatal([$0: too few arguments: $#])], + [1], [m4_fatal([$0: too few arguments: $#: $1])], + [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], + [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], + [lt_dict_filter([lt_decl_dict], $@)])[]dnl +]) + + +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) +# -------------------------------------------------- +m4_define([lt_decl_quote_varnames], +[_lt_decl_filter([value], [1], $@)]) + + +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_dquote_varnames], +[_lt_decl_filter([value], [2], $@)]) + + +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_varnames_tagged], +[m4_assert([$# <= 2])dnl +_$0(m4_quote(m4_default([$1], [[, ]])), + m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), + m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) +m4_define([_lt_decl_varnames_tagged], +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) + + +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_all_varnames], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_if([$2], [], + m4_quote(lt_decl_varnames), + m4_quote(m4_shift($@))))[]dnl +]) +m4_define([_lt_decl_all_varnames], +[lt_join($@, lt_decl_varnames_tagged([$1], + lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl +]) + + +# _LT_CONFIG_STATUS_DECLARE([VARNAME]) +# ------------------------------------ +# Quote a variable value, and forward it to 'config.status' so that its +# declaration there will have the same value as in 'configure'. VARNAME +# must have a single quote delimited value for this to work. +m4_define([_LT_CONFIG_STATUS_DECLARE], +[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) + + +# _LT_CONFIG_STATUS_DECLARATIONS +# ------------------------------ +# We delimit libtool config variables with single quotes, so when +# we write them to config.status, we have to be sure to quote all +# embedded single quotes properly. In configure, this macro expands +# each variable declared with _LT_DECL (and _LT_TAGDECL) into: +# +# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), + [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAGS +# ---------------- +# Output comment and list of tags supported by the script +m4_defun([_LT_LIBTOOL_TAGS], +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl +available_tags='_LT_TAGS'dnl +]) + + +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) +# ----------------------------------- +# Extract the dictionary values for VARNAME (optionally with TAG) and +# expand to a commented shell variable setting: +# +# # Some comment about what VAR is for. +# visible_name=$lt_internal_name +m4_define([_LT_LIBTOOL_DECLARE], +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], + [description])))[]dnl +m4_pushdef([_libtool_name], + m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), + [0], [_libtool_name=[$]$1], + [1], [_libtool_name=$lt_[]$1], + [2], [_libtool_name=$lt_[]$1], + [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl +]) + + +# _LT_LIBTOOL_CONFIG_VARS +# ----------------------- +# Produce commented declarations of non-tagged libtool config variables +# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool' +# script. Tagged libtool config variables (even for the LIBTOOL CONFIG +# section) are produced by _LT_LIBTOOL_TAG_VARS. +m4_defun([_LT_LIBTOOL_CONFIG_VARS], +[m4_foreach([_lt_var], + m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAG_VARS(TAG) +# ------------------------- +m4_define([_LT_LIBTOOL_TAG_VARS], +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) + + +# _LT_TAGVAR(VARNAME, [TAGNAME]) +# ------------------------------ +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) + + +# _LT_CONFIG_COMMANDS +# ------------------- +# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of +# variables for single and double quote escaping we saved from calls +# to _LT_DECL, we can put quote escaped variables declarations +# into 'config.status', and then the shell code to quote escape them in +# for loops in 'config.status'. Finally, any additional code accumulated +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. +m4_defun([_LT_CONFIG_COMMANDS], +[AC_PROVIDE_IFELSE([LT_OUTPUT], + dnl If the libtool generation code has been placed in $CONFIG_LT, + dnl instead of duplicating it all over again into config.status, + dnl then we will have config.status run $CONFIG_LT later, so it + dnl needs to know what name is stored there: + [AC_CONFIG_COMMANDS([libtool], + [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], + dnl If the libtool generation code is destined for config.status, + dnl expand the accumulated commands and init code now: + [AC_CONFIG_COMMANDS([libtool], + [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) +])#_LT_CONFIG_COMMANDS + + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], +[ + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +_LT_CONFIG_STATUS_DECLARATIONS +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$[]1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_quote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_dquote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +_LT_OUTPUT_LIBTOOL_INIT +]) + +# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) +# ------------------------------------ +# Generate a child script FILE with all initialization necessary to +# reuse the environment learned by the parent script, and make the +# file executable. If COMMENT is supplied, it is inserted after the +# '#!' sequence but before initialization text begins. After this +# macro, additional text can be appended to FILE to form the body of +# the child script. The macro ends with non-zero status if the +# file could not be fully written (such as if the disk is full). +m4_ifdef([AS_INIT_GENERATED], +[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], +[m4_defun([_LT_GENERATED_FILE_INIT], +[m4_require([AS_PREPARE])]dnl +[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl +[lt_write_fail=0 +cat >$1 <<_ASEOF || lt_write_fail=1 +#! $SHELL +# Generated by $as_me. +$2 +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$1 <<\_ASEOF || lt_write_fail=1 +AS_SHELL_SANITIZE +_AS_PREPARE +exec AS_MESSAGE_FD>&1 +_ASEOF +test 0 = "$lt_write_fail" && chmod +x $1[]dnl +m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT + +# LT_OUTPUT +# --------- +# This macro allows early generation of the libtool script (before +# AC_OUTPUT is called), incase it is used in configure for compilation +# tests. +AC_DEFUN([LT_OUTPUT], +[: ${CONFIG_LT=./config.lt} +AC_MSG_NOTICE([creating $CONFIG_LT]) +_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], +[# Run this file to recreate a libtool stub with the current configuration.]) + +cat >>"$CONFIG_LT" <<\_LTEOF +lt_cl_silent=false +exec AS_MESSAGE_LOG_FD>>config.log +{ + echo + AS_BOX([Running $as_me.]) +} >&AS_MESSAGE_LOG_FD + +lt_cl_help="\ +'$as_me' creates a local libtool stub from the current configuration, +for use in further configure time tests before the real libtool is +generated. + +Usage: $[0] [[OPTIONS]] + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + +Report bugs to ." + +lt_cl_version="\ +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) +configured by $[0], generated by m4_PACKAGE_STRING. + +Copyright (C) 2011 Free Software Foundation, Inc. +This config.lt script is free software; the Free Software Foundation +gives unlimited permision to copy, distribute and modify it." + +while test 0 != $[#] +do + case $[1] in + --version | --v* | -V ) + echo "$lt_cl_version"; exit 0 ;; + --help | --h* | -h ) + echo "$lt_cl_help"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --quiet | --q* | --silent | --s* | -q ) + lt_cl_silent=: ;; + + -*) AC_MSG_ERROR([unrecognized option: $[1] +Try '$[0] --help' for more information.]) ;; + + *) AC_MSG_ERROR([unrecognized argument: $[1] +Try '$[0] --help' for more information.]) ;; + esac + shift +done + +if $lt_cl_silent; then + exec AS_MESSAGE_FD>/dev/null +fi +_LTEOF + +cat >>"$CONFIG_LT" <<_LTEOF +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AC_MSG_NOTICE([creating $ofile]) +_LT_OUTPUT_LIBTOOL_COMMANDS +AS_EXIT(0) +_LTEOF +chmod +x "$CONFIG_LT" + +# configure is writing to config.log, but config.lt does its own redirection, +# appending to config.log, which fails on DOS, as config.log is still kept +# open by configure. Here we exec the FD to /dev/null, effectively closing +# config.log, so it can be properly (re)opened and appended to by config.lt. +lt_cl_success=: +test yes = "$silent" && + lt_config_lt_args="$lt_config_lt_args --quiet" +exec AS_MESSAGE_LOG_FD>/dev/null +$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false +exec AS_MESSAGE_LOG_FD>>config.log +$lt_cl_success || AS_EXIT(1) +])# LT_OUTPUT + + +# _LT_CONFIG(TAG) +# --------------- +# If TAG is the built-in tag, create an initial libtool script with a +# default configuration from the untagged config vars. Otherwise add code +# to config.status for appending the configuration named by TAG from the +# matching tagged config vars. +m4_defun([_LT_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_CONFIG_SAVE_COMMANDS([ + m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl + m4_if(_LT_TAG, [C], [ + # See if we are running on zsh, and set the options that allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST + fi + + cfgfile=${ofile}T + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL +# Generated automatically by $as_me ($PACKAGE) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +_LT_COPYING +_LT_LIBTOOL_TAGS + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} + +# ### BEGIN LIBTOOL CONFIG +_LT_LIBTOOL_CONFIG_VARS +_LT_LIBTOOL_TAG_VARS +# ### END LIBTOOL CONFIG + +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +_LT_PREPARE_MUNGE_PATH_LIST +_LT_PREPARE_CC_BASENAME + +# ### END FUNCTIONS SHARED WITH CONFIGURE + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + _LT_PROG_LTMAIN + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +], +[cat <<_LT_EOF >> "$ofile" + +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded +dnl in a comment (ie after a #). +# ### BEGIN LIBTOOL TAG CONFIG: $1 +_LT_LIBTOOL_TAG_VARS(_LT_TAG) +# ### END LIBTOOL TAG CONFIG: $1 +_LT_EOF +])dnl /m4_if +], +[m4_if([$1], [], [ + PACKAGE='$PACKAGE' + VERSION='$VERSION' + RM='$RM' + ofile='$ofile'], []) +])dnl /_LT_CONFIG_SAVE_COMMANDS +])# _LT_CONFIG + + +# LT_SUPPORTED_TAG(TAG) +# --------------------- +# Trace this macro to discover what tags are supported by the libtool +# --tag option, using: +# autoconf --trace 'LT_SUPPORTED_TAG:$1' +AC_DEFUN([LT_SUPPORTED_TAG], []) + + +# C support is built-in for now +m4_define([_LT_LANG_C_enabled], []) +m4_define([_LT_TAGS], []) + + +# LT_LANG(LANG) +# ------------- +# Enable libtool support for the given language if not already enabled. +AC_DEFUN([LT_LANG], +[AC_BEFORE([$0], [LT_OUTPUT])dnl +m4_case([$1], + [C], [_LT_LANG(C)], + [C++], [_LT_LANG(CXX)], + [Go], [_LT_LANG(GO)], + [Java], [_LT_LANG(GCJ)], + [Fortran 77], [_LT_LANG(F77)], + [Fortran], [_LT_LANG(FC)], + [Windows Resource], [_LT_LANG(RC)], + [m4_ifdef([_LT_LANG_]$1[_CONFIG], + [_LT_LANG($1)], + [m4_fatal([$0: unsupported language: "$1"])])])dnl +])# LT_LANG + + +# _LT_LANG(LANGNAME) +# ------------------ +m4_defun([_LT_LANG], +[m4_ifdef([_LT_LANG_]$1[_enabled], [], + [LT_SUPPORTED_TAG([$1])dnl + m4_append([_LT_TAGS], [$1 ])dnl + m4_define([_LT_LANG_]$1[_enabled], [])dnl + _LT_LANG_$1_CONFIG($1)])dnl +])# _LT_LANG + + +m4_ifndef([AC_PROG_GO], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_GO. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ +m4_defun([AC_PROG_GO], +[AC_LANG_PUSH(Go)dnl +AC_ARG_VAR([GOC], [Go compiler command])dnl +AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +AC_CHECK_TOOL(GOC, gccgo) +if test -z "$GOC"; then + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) + fi +fi +if test -z "$GOC"; then + AC_CHECK_PROG(GOC, gccgo, gccgo, false) +fi +])#m4_defun +])#m4_ifndef + + +# _LT_LANG_DEFAULT_CONFIG +# ----------------------- +m4_defun([_LT_LANG_DEFAULT_CONFIG], +[AC_PROVIDE_IFELSE([AC_PROG_CXX], + [LT_LANG(CXX)], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) + +AC_PROVIDE_IFELSE([AC_PROG_F77], + [LT_LANG(F77)], + [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) + +AC_PROVIDE_IFELSE([AC_PROG_FC], + [LT_LANG(FC)], + [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) + +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal +dnl pulling things in needlessly. +AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([LT_PROG_GCJ], + [LT_LANG(GCJ)], + [m4_ifdef([AC_PROG_GCJ], + [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([A][M_PROG_GCJ], + [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([LT_PROG_GCJ], + [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) + +AC_PROVIDE_IFELSE([AC_PROG_GO], + [LT_LANG(GO)], + [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) + +AC_PROVIDE_IFELSE([LT_PROG_RC], + [LT_LANG(RC)], + [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) +])# _LT_LANG_DEFAULT_CONFIG + +# Obsolete macros: +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) +AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_CXX], []) +dnl AC_DEFUN([AC_LIBTOOL_F77], []) +dnl AC_DEFUN([AC_LIBTOOL_FC], []) +dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) +dnl AC_DEFUN([AC_LIBTOOL_RC], []) + + +# _LT_TAG_COMPILER +# ---------------- +m4_defun([_LT_TAG_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_TAG_COMPILER + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +m4_defun([_LT_COMPILER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +m4_defun([_LT_LINKER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# ------------------------- +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CHECK_TOOL([LIPO], [lipo], [:]) + AC_CHECK_TOOL([OTOOL], [otool], [:]) + AC_CHECK_TOOL([OTOOL64], [otool64], [:]) + _LT_DECL([], [DSYMUTIL], [1], + [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) + _LT_DECL([], [NMEDIT], [1], + [Tool to change global to local symbols on Mac OS X]) + _LT_DECL([], [LIPO], [1], + [Tool to manipulate fat objects and archives on Mac OS X]) + _LT_DECL([], [OTOOL], [1], + [ldd/readelf like tool for Mach-O binaries on Mac OS X]) + _LT_DECL([], [OTOOL64], [1], + [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "$LT_MULTI_MODULE"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test 0 = "$_lt_result"; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi]) + + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS=$save_LDFLAGS + ]) + + AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], + [lt_cv_ld_force_load=no + cat > conftest.c << _LT_EOF +int forced_loaded() { return 2;} +_LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD + echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD + $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err + _lt_result=$? + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then + lt_cv_ld_force_load=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + ]) + case $host_os in + rhapsody* | darwin1.[[012]]) + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + 10.[[012]][[,.]]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test yes = "$lt_cv_apple_cc_single_mod"; then + _lt_dar_single_mod='$single_module' + fi + if test yes = "$lt_cv_ld_exported_symbols_list"; then + _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' + fi + if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac +]) + + +# _LT_DARWIN_LINKER_FEATURES([TAG]) +# --------------------------------- +# Checks for linker and compiler features on darwin +m4_defun([_LT_DARWIN_LINKER_FEATURES], +[ + m4_require([_LT_REQUIRED_DARWIN_CHECKS]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_automatic, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + if test yes = "$lt_cv_ld_force_load"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], + [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='' + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined + case $cc_basename in + ifort*|nagfor*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test yes = "$_lt_dar_can_shared"; then + output_verbose_link_cmd=func_echo_all + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + m4_if([$1], [CXX], +[ if test yes != "$lt_cv_apple_cc_single_mod"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" + fi +],[]) + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi +]) + +# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) +# ---------------------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +# Store the results from the different compilers for each TAGNAME. +# Allow to override them for all tags through lt_cv_aix_libpath. +m4_defun([_LT_SYS_MODULE_PATH_AIX], +[m4_require([_LT_DECL_SED])dnl +if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], + [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ + lt_aix_libpath_sed='[ + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }]' + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi],[]) + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib + fi + ]) + aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) +fi +])# _LT_SYS_MODULE_PATH_AIX + + +# _LT_SHELL_INIT(ARG) +# ------------------- +m4_define([_LT_SHELL_INIT], +[m4_divert_text([M4SH-INIT], [$1 +])])# _LT_SHELL_INIT + + + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Find how we can fake an echo command that does not interpret backslash. +# In particular, with Autoconf 2.60 or later we add some code to the start +# of the generated configure script that will find a shell with a builtin +# printf (that we can use as an echo command). +m4_defun([_LT_PROG_ECHO_BACKSLASH], +[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +AC_MSG_CHECKING([how to print strings]) +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$[]1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + +case $ECHO in + printf*) AC_MSG_RESULT([printf]) ;; + print*) AC_MSG_RESULT([print -r]) ;; + *) AC_MSG_RESULT([cat]) ;; +esac + +m4_ifdef([_AS_DETECT_SUGGESTED], +[_AS_DETECT_SUGGESTED([ + test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( + ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' + ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO + ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + PATH=/empty FPATH=/empty; export PATH FPATH + test "X`printf %s $ECHO`" = "X$ECHO" \ + || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) + +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) +_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) +])# _LT_PROG_ECHO_BACKSLASH + + +# _LT_WITH_SYSROOT +# ---------------- +AC_DEFUN([_LT_WITH_SYSROOT], +[AC_MSG_CHECKING([for sysroot]) +AC_ARG_WITH([sysroot], +[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], + [Search for dependent libraries within DIR (or the compiler's sysroot + if not specified).])], +[], [with_sysroot=no]) + +dnl lt_sysroot will always be passed unquoted. We quote it here +dnl in case the user passed a directory name. +lt_sysroot= +case $with_sysroot in #( + yes) + if test yes = "$GCC"; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + AC_MSG_RESULT([$with_sysroot]) + AC_MSG_ERROR([The sysroot must be an absolute path.]) + ;; +esac + + AC_MSG_RESULT([${lt_sysroot:-no}]) +_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl +[dependent libraries, and where our libraries should be installed.])]) + +# _LT_ENABLE_LOCK +# --------------- +m4_defun([_LT_ENABLE_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AS_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test no = "$enable_libtool_lock" || enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out what ABI is being produced by ac_compile, and set mode + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE=32 + ;; + *ELF-64*) + HPUX_IA64_MODE=64 + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test yes = "$lt_cv_prog_gnu_ld"; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +mips64*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + emul=elf + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; + *64-bit*) + emul="${emul}64" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; + *LSB*) + emul="${emul}ltsmip" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; + esac + LD="${LD-ld} -m $emul" + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. Note that the listed cases only cover the + # situations where additional linker options are needed (such as when + # doing 32-bit compilation for a host where ld defaults to 64-bit, or + # vice versa); the common cases where no linker options are needed do + # not appear in the list. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac + ;; + powerpc64le-*linux*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + powerpcle-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test yes != "$lt_cv_cc_needs_belf"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS=$SAVE_CFLAGS + fi + ;; +*-*solaris*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) + case $host in + i?86-*-solaris*|x86_64-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD=${LD-ld}_sol2 + fi + ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks=$enable_libtool_lock +])# _LT_ENABLE_LOCK + + +# _LT_PROG_AR +# ----------- +m4_defun([_LT_PROG_AR], +[AC_CHECK_TOOLS(AR, [ar], false) +: ${AR=ar} +: ${AR_FLAGS=cru} +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) + +AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], + [lt_cv_ar_at_file=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM], + [echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' + AC_TRY_EVAL([lt_ar_try]) + if test 0 -eq "$ac_status"; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + AC_TRY_EVAL([lt_ar_try]) + if test 0 -ne "$ac_status"; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + ]) + ]) + +if test no = "$lt_cv_ar_at_file"; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi +_LT_DECL([], [archiver_list_spec], [1], + [How to feed a file listing to the archiver]) +])# _LT_PROG_AR + + +# _LT_CMD_OLD_ARCHIVE +# ------------------- +m4_defun([_LT_CMD_OLD_ARCHIVE], +[_LT_PROG_AR + +AC_CHECK_TOOL(STRIP, strip, :) +test -z "$STRIP" && STRIP=: +_LT_DECL([], [STRIP], [1], [A symbol stripping program]) + +AC_CHECK_TOOL(RANLIB, ranlib, :) +test -z "$RANLIB" && RANLIB=: +_LT_DECL([], [RANLIB], [1], + [Commands used to install an old-style archive]) + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + bitrig* | openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" +fi + +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; +esac +_LT_DECL([], [old_postinstall_cmds], [2]) +_LT_DECL([], [old_postuninstall_cmds], [2]) +_LT_TAGDECL([], [old_archive_cmds], [2], + [Commands used to build an old-style archive]) +_LT_DECL([], [lock_old_archive_extraction], [0], + [Whether to use a lock for old archive extraction]) +])# _LT_CMD_OLD_ARCHIVE + + +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([_LT_COMPILER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $RM conftest* +]) + +if test yes = "[$]$2"; then + m4_if([$5], , :, [$5]) +else + m4_if([$6], , :, [$6]) +fi +])# _LT_COMPILER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) + + +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------- +# Check whether the given linker option works +AC_DEFUN([_LT_LINKER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS +]) + +if test yes = "[$]$2"; then + m4_if([$4], , :, [$4]) +else + m4_if([$5], , :, [$5]) +fi +])# _LT_LINKER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) + + +# LT_CMD_MAX_LEN +#--------------- +AC_DEFUN([LT_CMD_MAX_LEN], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring=ABCD + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + mint*) + # On MiNT this can take a long time and run out of memory. + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test X`env echo "$teststring$teststring" 2>/dev/null` \ + = "X$teststring$teststring"; } >/dev/null 2>&1 && + test 17 != "$i" # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n "$lt_cv_sys_max_cmd_len"; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +_LT_DECL([], [max_cmd_len], [0], + [What is the maximum length of a command?]) +])# LT_CMD_MAX_LEN + +# Old name: +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) + + +# _LT_HEADER_DLFCN +# ---------------- +m4_defun([_LT_HEADER_DLFCN], +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl +])# _LT_HEADER_DLFCN + + +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ---------------------------------------------------------------- +m4_defun([_LT_TRY_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test yes = "$cross_compiling"; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +[#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +}] +_LT_EOF + if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_TRY_DLOPEN_SELF + + +# LT_SYS_DLOPEN_SELF +# ------------------ +AC_DEFUN([LT_SYS_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test yes != "$enable_dlopen"; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen=load_add_on + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen=LoadLibrary + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[ + lt_cv_dlopen=dyld + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + tpf*) + # Don't try to run any link tests for TPF. We know it's impossible + # because TPF is a cross-compiler, and we know how we open DSOs. + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + lt_cv_dlopen_self=no + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen=shl_load], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen=dlopen], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test no = "$lt_cv_dlopen"; then + enable_dlopen=no + else + enable_dlopen=yes + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS=$CPPFLAGS + test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS=$LDFLAGS + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS=$LIBS + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test yes = "$lt_cv_dlopen_self"; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +_LT_DECL([dlopen_support], [enable_dlopen], [0], + [Whether dlopen is supported]) +_LT_DECL([dlopen_self], [enable_dlopen_self], [0], + [Whether dlopen of programs is supported]) +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], + [Whether dlopen of statically linked programs is supported]) +])# LT_SYS_DLOPEN_SELF + +# Old name: +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) + + +# _LT_COMPILER_C_O([TAGNAME]) +# --------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler. +# This macro does not hard code the compiler like AC_PROG_CC_C_O. +m4_defun([_LT_COMPILER_C_O], +[m4_require([_LT_DECL_SED])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* +]) +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], + [Does compiler simultaneously support -c and -o options?]) +])# _LT_COMPILER_C_O + + +# _LT_COMPILER_FILE_LOCKS([TAGNAME]) +# ---------------------------------- +# Check to see if we can do hard links to lock some files if needed +m4_defun([_LT_COMPILER_FILE_LOCKS], +[m4_require([_LT_ENABLE_LOCK])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_COMPILER_C_O([$1]) + +hard_links=nottested +if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test no = "$hard_links"; then + AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) +])# _LT_COMPILER_FILE_LOCKS + + +# _LT_CHECK_OBJDIR +# ---------------- +m4_defun([_LT_CHECK_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +_LT_DECL([], [objdir], [0], + [The name of the directory that contains temporary libtool files])dnl +m4_pattern_allow([LT_OBJDIR])dnl +AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/", + [Define to the sub-directory where libtool stores uninstalled libraries.]) +])# _LT_CHECK_OBJDIR + + +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) +# -------------------------------------- +# Check hardcoding attributes. +m4_defun([_LT_LINKER_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || + test -n "$_LT_TAGVAR(runpath_var, $1)" || + test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then + + # We can hardcode non-existent directories. + if test no != "$_LT_TAGVAR(hardcode_direct, $1)" && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" && + test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then + # Linking always hardcodes the temporary library directory. + _LT_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) + +if test relink = "$_LT_TAGVAR(hardcode_action, $1)" || + test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then + # Fast installation is not supported + enable_fast_install=no +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then + # Fast installation is not necessary + enable_fast_install=needless +fi +_LT_TAGDECL([], [hardcode_action], [0], + [How to hardcode a shared library path into an executable]) +])# _LT_LINKER_HARDCODE_LIBPATH + + +# _LT_CMD_STRIPLIB +# ---------------- +m4_defun([_LT_CMD_STRIPLIB], +[m4_require([_LT_DECL_EGREP]) +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP"; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) +_LT_DECL([], [striplib], [1]) +])# _LT_CMD_STRIPLIB + + +# _LT_PREPARE_MUNGE_PATH_LIST +# --------------------------- +# Make sure func_munge_path_list() is defined correctly. +m4_defun([_LT_PREPARE_MUNGE_PATH_LIST], +[[# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x@S|@2 in + x) + ;; + *:) + eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\" + ;; + x:*) + eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\" + ;; + *) + eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\" + ;; + esac +} +]])# _LT_PREPARE_PATH_LIST + + +# _LT_SYS_DYNAMIC_LINKER([TAG]) +# ----------------------------- +# PORTME Fill in your ld.so characteristics +m4_defun([_LT_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_OBJDUMP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +m4_if([$1], + [], [ +if test yes = "$GCC"; then + case $host_os in + darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; + *) lt_awk_arg='/^libraries:/' ;; + esac + case $host_os in + mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; + *) lt_sed_strip_eq='s|=/|/|g' ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` + case $lt_search_path_spec in + *\;*) + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary... + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + # ...but if some path component already ends with the multilib dir we assume + # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). + case "$lt_multi_os_dir; $lt_search_path_spec " in + "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) + lt_multi_os_dir= + ;; + esac + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" + elif test -n "$lt_multi_os_dir"; then + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' +BEGIN {RS = " "; FS = "/|\n";} { + lt_foo = ""; + lt_count = 0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo = "/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + # AWK program above erroneously prepends '/' to C:/dos/paths + # for these hosts. + case $host_os in + mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; + esac + sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=.so +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +AC_ARG_VAR([LT_SYS_LIBRARY_PATH], +[User-defined run-time library search path.]) + +case $host_os in +aix3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='$libname$release$shared_ext$major' + ;; + +aix[[4-9]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test ia64 = "$host_cpu"; then + # AIX 5 supports IA64 + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a[(]lib.so.V[)]' + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='$libname$shared_ext' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + + case $GCC,$cc_basename in + yes,*) + # gcc + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec=$LIB + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' + ;; + + *) + # Assume MSVC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; + esac + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[23]].*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2.*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + dynamic_linker="$host_os runtime_loader" + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=no + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 + fi + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 + ;; + +interix[[3-9]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test yes = "$lt_cv_prog_gnu_ld"; then + version_type=linux # correct to gnu/linux during the next big refactor + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + + # Some binutils ld are patched to set DT_RUNPATH + AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], + [lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [lt_cv_shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + ]) + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd* | bitrig*) + version_type=sunos + sys_lib_dlsearch_path_spec=/usr/lib + need_lib_prefix=no + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +os2*) + libname_spec='$name' + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test yes = "$with_gnu_ld"; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec; then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=sco + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test yes = "$with_gnu_ld"; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test no = "$dynamic_linker" && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test yes = "$GCC"; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec +fi + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec +fi + +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + +_LT_DECL([], [variables_saved_for_relink], [1], + [Variables whose values should be saved in libtool wrapper scripts and + restored at link time]) +_LT_DECL([], [need_lib_prefix], [0], + [Do we need the "lib" prefix for modules?]) +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) +_LT_DECL([], [version_type], [0], [Library versioning type]) +_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) +_LT_DECL([], [shlibpath_overrides_runpath], [0], + [Is shlibpath searched before the hard-coded library search path?]) +_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) +_LT_DECL([], [library_names_spec], [1], + [[List of archive names. First name is the real one, the rest are links. + The last name is the one that the linker finds with -lNAME]]) +_LT_DECL([], [soname_spec], [1], + [[The coded name of the library, if different from the real name]]) +_LT_DECL([], [install_override_mode], [1], + [Permission mode override for installation of shared libraries]) +_LT_DECL([], [postinstall_cmds], [2], + [Command to use after installation of a shared archive]) +_LT_DECL([], [postuninstall_cmds], [2], + [Command to use after uninstallation of a shared archive]) +_LT_DECL([], [finish_cmds], [2], + [Commands used to finish a libtool library installation in a directory]) +_LT_DECL([], [finish_eval], [1], + [[As "finish_cmds", except a single script fragment to be evaled but + not shown]]) +_LT_DECL([], [hardcode_into_libs], [0], + [Whether we should hardcode library paths into libraries]) +_LT_DECL([], [sys_lib_search_path_spec], [2], + [Compile-time system search path for libraries]) +_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2], + [Detected run-time system search path for libraries]) +_LT_DECL([], [configure_time_lt_sys_library_path], [2], + [Explicit LT_SYS_LIBRARY_PATH set during ./configure time]) +])# _LT_SYS_DYNAMIC_LINKER + + +# _LT_PATH_TOOL_PREFIX(TOOL) +# -------------------------- +# find a file program that can recognize shared library +AC_DEFUN([_LT_PATH_TOOL_PREFIX], +[m4_require([_LT_DECL_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="m4_if([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$1"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac]) +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +_LT_DECL([], [MAGIC_CMD], [0], + [Used to examine libraries when file_magic_cmd begins with "file"])dnl +])# _LT_PATH_TOOL_PREFIX + +# Old name: +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) + + +# _LT_PATH_MAGIC +# -------------- +# find a file program that can recognize a shared library +m4_defun([_LT_PATH_MAGIC], +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# _LT_PATH_MAGIC + + +# LT_PATH_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([LT_PATH_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PROG_ECHO_BACKSLASH])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test no = "$withval" || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +ac_prog=ld +if test yes = "$GCC"; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return, which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD=$ac_prog + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test yes = "$with_gnu_ld"; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD=$ac_dir/$ac_prog + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 conftest.i +cat conftest.i conftest.i >conftest2.i +: ${lt_DD:=$DD} +AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd], +[if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: +fi]) +rm -f conftest.i conftest2.i conftest.out]) +])# _LT_PATH_DD + + +# _LT_CMD_TRUNCATE +# ---------------- +# find command to truncate a binary pipe +m4_defun([_LT_CMD_TRUNCATE], +[m4_require([_LT_PATH_DD]) +AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin], +[printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +lt_cv_truncate_bin= +if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out +test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"]) +_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1], + [Command to truncate a binary pipe]) +])# _LT_CMD_TRUNCATE + + +# _LT_CHECK_MAGIC_METHOD +# ---------------------- +# how to check for library dependencies +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_MAGIC_METHOD], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +AC_CACHE_CHECK([how to recognize dependent libraries], +lt_cv_deplibs_check_method, +[lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# 'unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# that responds to the $file_magic_cmd with a given extended regex. +# If you have 'file' or equivalent on your system and you're not sure +# whether 'pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[[4-9]]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[[45]]*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + # Keep this pattern in sync with the one in func_win32_libid. + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc*) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +haiku*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd* | bitrig*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +os2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` + fi + ;; + esac +fi + +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +_LT_DECL([], [deplibs_check_method], [1], + [Method to check whether dependent libraries are shared objects]) +_LT_DECL([], [file_magic_cmd], [1], + [Command to use when deplibs_check_method = "file_magic"]) +_LT_DECL([], [file_magic_glob], [1], + [How to find potential files when deplibs_check_method = "file_magic"]) +_LT_DECL([], [want_nocaseglob], [1], + [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) +])# _LT_CHECK_MAGIC_METHOD + + +# LT_PATH_NM +# ---------- +# find the pathname to a BSD- or MS-compatible name lister +AC_DEFUN([LT_PATH_NM], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM=$NM +else + lt_nm_to_check=${ac_tool_prefix}nm + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + tmp_nm=$ac_dir/$lt_tmp_nm + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the 'sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + case $build_os in + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac + case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break 2 + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break 2 + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS=$lt_save_ifs + done + : ${lt_cv_path_NM=no} +fi]) +if test no != "$lt_cv_path_NM"; then + NM=$lt_cv_path_NM +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$DUMPBIN"; then : + # Let the user override the test. + else + AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols -headers" + ;; + *) + DUMPBIN=: + ;; + esac + fi + AC_SUBST([DUMPBIN]) + if test : != "$DUMPBIN"; then + NM=$DUMPBIN + fi +fi +test -z "$NM" && NM=nm +AC_SUBST([NM]) +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl + +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], + [lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) + cat conftest.out >&AS_MESSAGE_LOG_FD + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest*]) +])# LT_PATH_NM + +# Old names: +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_NM], []) +dnl AC_DEFUN([AC_PROG_NM], []) + +# _LT_CHECK_SHAREDLIB_FROM_LINKLIB +# -------------------------------- +# how to determine the name of the shared library +# associated with a specific link library. +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +m4_require([_LT_DECL_DLLTOOL]) +AC_CACHE_CHECK([how to associate runtime and link libraries], +lt_cv_sharedlib_from_linklib_cmd, +[lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd=$ECHO + ;; +esac +]) +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + +_LT_DECL([], [sharedlib_from_linklib_cmd], [1], + [Command to associate shared and link libraries]) +])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB + + +# _LT_PATH_MANIFEST_TOOL +# ---------------------- +# locate the manifest tool +m4_defun([_LT_PATH_MANIFEST_TOOL], +[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], + [lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&AS_MESSAGE_LOG_FD + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest*]) +if test yes != "$lt_cv_path_mainfest_tool"; then + MANIFEST_TOOL=: +fi +_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl +])# _LT_PATH_MANIFEST_TOOL + + +# _LT_DLL_DEF_P([FILE]) +# --------------------- +# True iff FILE is a Windows DLL '.def' file. +# Keep in sync with func_dll_def_p in the libtool script +AC_DEFUN([_LT_DLL_DEF_P], +[dnl + test DEF = "`$SED -n dnl + -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace + -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments + -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl + -e q dnl Only consider the first "real" line + $1`" dnl +])# _LT_DLL_DEF_P + + +# LT_LIB_M +# -------- +# check for math library +AC_DEFUN([LT_LIB_M], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw) + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM=-lm) + ;; +esac +AC_SUBST([LIBM]) +])# LT_LIB_M + +# Old name: +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_CHECK_LIBM], []) + + +# _LT_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------- +m4_defun([_LT_COMPILER_NO_RTTI], +[m4_require([_LT_TAG_COMPILER])dnl + +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test yes = "$GCC"; then + case $cc_basename in + nvcc*) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; + *) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; + esac + + _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], + [Compiler flag to turn off builtin functions]) +])# _LT_COMPILER_NO_RTTI + + +# _LT_CMD_GLOBAL_SYMBOLS +# ---------------------- +m4_defun([_LT_CMD_GLOBAL_SYMBOLS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([LT_PATH_NM])dnl +AC_REQUIRE([LT_PATH_LD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_TAG_COMPILER])dnl + +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) + if test ia64 = "$host_cpu"; then + symcode='[[ABCDEGRST]]' + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. + lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" + lt_c_name_lib_hook="\ + -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ + -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" +else + # Disable hooks by default. + lt_cv_sys_global_symbol_to_import= + lt_cdecl_hook= + lt_c_name_hook= + lt_c_name_lib_hook= +fi + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +$lt_cdecl_hook\ +" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +$lt_c_name_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + +# Transform an extracted symbol line into symbol name with lib prefix and +# symbol address. +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +$lt_c_name_lib_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK ['"\ +" {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ +" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ +" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ +" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ +" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx]" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT@&t@_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT@&t@_DLSYM_CONST +#else +# define LT@&t@_DLSYM_CONST const +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +LT@&t@_DLSYM_CONST struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[[]] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS + LIBS=conftstm.$ac_objext + CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then + pipe_works=yes + fi + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test yes = "$pipe_works"; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi + +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then + nm_file_list_spec='@' +fi + +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], + [Take the output of nm and produce a listing of raw symbols and C names]) +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], + [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1], + [Transform the output of nm into a list of symbols to manually relocate]) +_LT_DECL([global_symbol_to_c_name_address], + [lt_cv_sys_global_symbol_to_c_name_address], [1], + [Transform the output of nm in a C name address pair]) +_LT_DECL([global_symbol_to_c_name_address_lib_prefix], + [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], + [Transform the output of nm in a C name address pair when lib prefix is needed]) +_LT_DECL([nm_interface], [lt_cv_nm_interface], [1], + [The name lister interface]) +_LT_DECL([], [nm_file_list_spec], [1], + [Specify filename containing input files for $NM]) +]) # _LT_CMD_GLOBAL_SYMBOLS + + +# _LT_COMPILER_PIC([TAGNAME]) +# --------------------------- +m4_defun([_LT_COMPILER_PIC], +[m4_require([_LT_TAG_COMPILER])dnl +_LT_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_TAGVAR(lt_prog_compiler_static, $1)= + +m4_if([$1], [CXX], [ + # C++ specific cases for pic, static, wl, etc. + if test yes = "$GXX"; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + if test ia64 != "$host_cpu"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64, which still supported -KPIC. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) + # IBM XL 8.0, 9.0 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd* | netbsdelf*-gnu) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test yes = "$GCC"; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' + if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + + hpux9* | hpux10* | hpux11*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + # old Intel for x86_64, which still supported -KPIC. + ecc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' + _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' + ;; + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + *Sun\ F* | *Sun*Fortran*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Intel*\ [[CF]]*Compiler*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + *Portland\ Group*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +case $host_os in + # For platforms that do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" + ;; +esac + +AC_CACHE_CHECK([for $compiler option to produce PIC], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], + [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], + [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], + [Additional compiler flags for building library objects]) + +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) +# +# Check to make sure the static flag actually works. +# +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], + [Compiler flag to prevent dynamic linking]) +])# _LT_COMPILER_PIC + + +# _LT_LINKER_SHLIBS([TAGNAME]) +# ---------------------------- +# See if the linker supports building shared libraries. +m4_defun([_LT_LINKER_SHLIBS], +[AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +m4_if([$1], [CXX], [ + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds + ;; + cygwin* | mingw* | cegcc*) + case $cc_basename in + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + ;; + esac + ;; + linux* | k*bsd*-gnu | gnu*) + _LT_TAGVAR(link_all_deplibs, $1)=no + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac +], [ + runpath_var= + _LT_TAGVAR(allow_undefined_flag, $1)= + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(archive_cmds, $1)= + _LT_TAGVAR(archive_expsym_cmds, $1)= + _LT_TAGVAR(compiler_needs_object, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(hardcode_automatic, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_separator, $1)= + _LT_TAGVAR(hardcode_minus_L, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(inherit_rpath, $1)=no + _LT_TAGVAR(link_all_deplibs, $1)=unknown + _LT_TAGVAR(module_cmds, $1)= + _LT_TAGVAR(module_expsym_cmds, $1)= + _LT_TAGVAR(old_archive_from_new_cmds, $1)= + _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_TAGVAR(thread_safe_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ' (' and ')$', so one must not match beginning or + # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', + # as well as any symbol that contains 'd'. + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test yes != "$GCC"; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd* | bitrig*) + with_gnu_ld=no + ;; + linux* | k*bsd*-gnu | gnu*) + _LT_TAGVAR(link_all_deplibs, $1)=no + ;; + esac + + _LT_TAGVAR(ld_shlibs, $1)=yes + + # On some targets, GNU ld is compatible enough with the native linker + # that we're better off using the native interface for both. + lt_use_gnu_ld_interface=no + if test yes = "$with_gnu_ld"; then + case $host_os in + aix*) + # The AIX port of GNU ld has always aspired to compatibility + # with the native linker. However, as the warning in the GNU ld + # block says, versions before 2.19.5* couldn't really create working + # shared libraries, regardless of the interface used. + case `$LD -v 2>&1` in + *\ \(GNU\ Binutils\)\ 2.19.5*) ;; + *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; + *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + fi + + if test yes = "$lt_use_gnu_ld_interface"; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='$wl' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test ia64 != "$host_cpu"; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.19, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to install binutils +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. +*** You will then need to restart the configuration process. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + tmp_diet=no + if test linux-dietlibc = "$host_os"; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test no = "$tmp_diet" + then + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group f77 and f90 compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + _LT_TAGVAR(whole_archive_flag_spec, $1)= + tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 + tmp_sharedflag='-Wl,-shared' ;; + xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + nvcc*) # Cuda Compiler Driver 2.2 + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + tcc*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic' + ;; + xlf* | bgf* | bgxlf* | mpixlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then + runpath_var= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then + aix_use_runtimelinking=yes + break + fi + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # traditional, no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + ;; + esac + + if test yes = "$GCC"; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag="$shared_flag "'$wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + bsdi[[45]]*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in + cl*) + # Native MSVC + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + esac + ;; + + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2.*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + ;; + + hpux10*) + if test yes,no = "$GCC,$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test yes,no = "$GCC,$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + m4_if($1, [], [ + # Older versions of the 11.00 compiler do not understand -b yet + # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) + _LT_LINKER_OPTION([if $CC understands -b], + _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], + [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) + ;; + esac + fi + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + # This should be the same for all languages, so no per-tag cache variable. + AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], + [lt_cv_irix_exported_symbol], + [save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" + AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], + [C++], [[int foo (void) { return 0; }]], + [Fortran 77], [[ + subroutine foo + end]], + [Fortran], [[ + subroutine foo + end]])])], + [lt_cv_irix_exported_symbol=yes], + [lt_cv_irix_exported_symbol=no]) + LDFLAGS=$save_LDFLAGS]) + if test yes = "$lt_cv_irix_exported_symbol"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' + fi + _LT_TAGVAR(link_all_deplibs, $1)=no + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + linux*) + case $cc_basename in + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + _LT_TAGVAR(ld_shlibs, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *nto* | *qnx*) + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + fi + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + osf3*) + if test yes = "$GCC"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test yes = "$GCC"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' + if test yes = "$GCC"; then + wlarc='$wl' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='$wl' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. GCC discards it without '$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test yes = "$GCC"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test sequent = "$host_vendor"; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + if test sni = "$host_vendor"; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym' + ;; + esac + fi + fi +]) +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) +test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no + +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld + +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl +_LT_DECL([], [extract_expsyms_cmds], [2], + [The commands to extract the exported symbol list from a shared archive]) + +# +# Do we need to explicitly link libc? +# +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test yes,yes = "$GCC,$enable_shared"; then + case $_LT_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_CACHE_CHECK([whether -lc should be explicitly linked in], + [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), + [$RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + ]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) + ;; + esac + fi + ;; +esac + +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], + [Whether or not to add -lc for building shared libraries]) +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], + [enable_shared_with_static_runtimes], [0], + [Whether or not to disallow shared libs when runtime libs are static]) +_LT_TAGDECL([], [export_dynamic_flag_spec], [1], + [Compiler flag to allow reflexive dlopens]) +_LT_TAGDECL([], [whole_archive_flag_spec], [1], + [Compiler flag to generate shared objects directly from archives]) +_LT_TAGDECL([], [compiler_needs_object], [1], + [Whether the compiler copes with passing no objects directly]) +_LT_TAGDECL([], [old_archive_from_new_cmds], [2], + [Create an old-style archive from a shared archive]) +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], + [Create a temporary old-style archive to link instead of a shared archive]) +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) +_LT_TAGDECL([], [archive_expsym_cmds], [2]) +_LT_TAGDECL([], [module_cmds], [2], + [Commands used to build a loadable module if different from building + a shared archive.]) +_LT_TAGDECL([], [module_expsym_cmds], [2]) +_LT_TAGDECL([], [with_gnu_ld], [1], + [Whether we are building with GNU ld or not]) +_LT_TAGDECL([], [allow_undefined_flag], [1], + [Flag that allows shared libraries with undefined symbols to be built]) +_LT_TAGDECL([], [no_undefined_flag], [1], + [Flag that enforces no undefined symbols]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], + [Flag to hardcode $libdir into a binary during linking. + This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_separator], [1], + [Whether we need a single "-rpath" flag with a separated argument]) +_LT_TAGDECL([], [hardcode_direct], [0], + [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes + DIR into the resulting binary]) +_LT_TAGDECL([], [hardcode_direct_absolute], [0], + [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes + DIR into the resulting binary and the resulting library dependency is + "absolute", i.e impossible to change by setting $shlibpath_var if the + library is relocated]) +_LT_TAGDECL([], [hardcode_minus_L], [0], + [Set to "yes" if using the -LDIR flag during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_shlibpath_var], [0], + [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_automatic], [0], + [Set to "yes" if building a shared library automatically hardcodes DIR + into the library and all subsequent libraries and executables linked + against it]) +_LT_TAGDECL([], [inherit_rpath], [0], + [Set to yes if linker adds runtime paths of dependent libraries + to runtime path list]) +_LT_TAGDECL([], [link_all_deplibs], [0], + [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [always_export_symbols], [0], + [Set to "yes" if exported symbols are required]) +_LT_TAGDECL([], [export_symbols_cmds], [2], + [The commands to list exported symbols]) +_LT_TAGDECL([], [exclude_expsyms], [1], + [Symbols that should not be listed in the preloaded symbols]) +_LT_TAGDECL([], [include_expsyms], [1], + [Symbols that must always be exported]) +_LT_TAGDECL([], [prelink_cmds], [2], + [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [postlink_cmds], [2], + [Commands necessary for finishing linking programs]) +_LT_TAGDECL([], [file_list_spec], [1], + [Specify filename containing input files]) +dnl FIXME: Not yet implemented +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], +dnl [Compiler flag to generate thread safe objects]) +])# _LT_LINKER_SHLIBS + + +# _LT_LANG_C_CONFIG([TAG]) +# ------------------------ +# Ensure that the configuration variables for a C compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_C_CONFIG], +[m4_require([_LT_DECL_EGREP])dnl +lt_save_CC=$CC +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_TAG_COMPILER +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + LT_SYS_DLOPEN_SELF + _LT_CMD_STRIPLIB + + # Report what library types will actually be built + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_CONFIG($1) +fi +AC_LANG_POP +CC=$lt_save_CC +])# _LT_LANG_C_CONFIG + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +if test -n "$CXX" && ( test no != "$CXX" && + ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || + (test g++ != "$CXX"))); then + AC_PROG_CXXCPP +else + _lt_caught_CXX_error=yes +fi + +AC_LANG_PUSH(C++) +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(compiler_needs_object, $1)=no +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_caught_CXX_error"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_CFLAGS=$CFLAGS + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + CFLAGS=$CXXFLAGS + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test yes = "$GXX"; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + else + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + fi + + if test yes = "$GXX"; then + # Set up default GNU C++ configuration + + LT_PATH_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test yes = "$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='$wl' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) + _LT_TAGVAR(ld_shlibs, $1)=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + ;; + esac + + if test yes = "$GXX"; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag=$shared_flag' $wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + # The "-G" linker flag allows undefined symbols. + _LT_TAGVAR(no_undefined_flag, $1)='-bernotok' + # Determine the default libpath from the value encoded in an empty + # executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared + # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32* | cegcc*) + case $GXX,$cc_basename in + ,cl* | no,cl*) + # Native MSVC + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + func_to_tool_file "$lt_outputfile"~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # g++ + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + freebsd2.*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + freebsd-elf*) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + hpux9*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes = "$GXX"; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' + fi + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) + _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' + _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ + $RANLIB $oldlib' + _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 6 and above use weak symbols + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' + ;; + xl* | mpixl* | bgxl*) + # IBM XL 8.0 on PPC, with GNU ld + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + fi + output_verbose_link_cmd=func_echo_all + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + case $host in + osf3*) + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + ;; + *) + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ + $RM $lib.exp' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes,no = "$GXX,$with_gnu_ld"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + case $host in + osf3*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test yes,no = "$GXX,$with_gnu_ld"; then + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + else + # g++ 2.7 appears to require '-G' NOT '-shared' on this + # platform. + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + fi + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ + '"$_LT_TAGVAR(old_archive_cmds, $1)" + _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ + '"$_LT_TAGVAR(reload_cmds, $1)" + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) + test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no + + _LT_TAGVAR(GCC, $1)=$GXX + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test yes != "$_lt_caught_CXX_error" + +AC_LANG_POP +])# _LT_LANG_CXX_CONFIG + + +# _LT_FUNC_STRIPNAME_CNF +# ---------------------- +# func_stripname_cnf prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# +# This function is identical to the (non-XSI) version of func_stripname, +# except this one can be used by m4 code that may be executed by configure, +# rather than the libtool script. +m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl +AC_REQUIRE([_LT_DECL_SED]) +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) +func_stripname_cnf () +{ + case @S|@2 in + .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;; + *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;; + esac +} # func_stripname_cnf +])# _LT_FUNC_STRIPNAME_CNF + + +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) +# --------------------------------- +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +m4_defun([_LT_SYS_HIDDEN_LIBDEPS], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl +# Dependencies to place before and after the object being linked: +_LT_TAGVAR(predep_objects, $1)= +_LT_TAGVAR(postdep_objects, $1)= +_LT_TAGVAR(predeps, $1)= +_LT_TAGVAR(postdeps, $1)= +_LT_TAGVAR(compiler_lib_search_path, $1)= + +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF +int a; +void foo (void) { a = 0; } +_LT_EOF +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +_LT_EOF +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer a + a=0 + return + end +_LT_EOF +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +_LT_EOF +], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF +package foo +func foo() { +} +_LT_EOF +]) + +_lt_libdeps_save_CFLAGS=$CFLAGS +case "$CC $CFLAGS " in #( +*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; +*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; +*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; +esac + +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case $prev$p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test x-L = "$p" || + test x-R = "$p"; then + prev=$p + continue + fi + + # Expand the sysroot to ease extracting the directories later. + if test -z "$prev"; then + case $p in + -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; + -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; + -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; + esac + fi + case $p in + =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; + esac + if test no = "$pre_test_object_deps_done"; then + case $prev in + -L | -R) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p + else + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$_LT_TAGVAR(postdeps, $1)"; then + _LT_TAGVAR(postdeps, $1)=$prev$p + else + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p" + fi + fi + prev= + ;; + + *.lto.$objext) ;; # Ignore GCC LTO objects + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test no = "$pre_test_object_deps_done"; then + if test -z "$_LT_TAGVAR(predep_objects, $1)"; then + _LT_TAGVAR(predep_objects, $1)=$p + else + _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then + _LT_TAGVAR(postdep_objects, $1)=$p + else + _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$RM -f confest.$objext +CFLAGS=$_lt_libdeps_save_CFLAGS + +# PORTME: override above test on systems where it is broken +m4_if([$1], [CXX], +[case $host_os in +interix[[3-9]]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + _LT_TAGVAR(predep_objects,$1)= + _LT_TAGVAR(postdep_objects,$1)= + _LT_TAGVAR(postdeps,$1)= + ;; +esac +]) + +case " $_LT_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac + _LT_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'` +fi +_LT_TAGDECL([], [compiler_lib_search_dirs], [1], + [The directories searched by this compiler when creating a shared library]) +_LT_TAGDECL([], [predep_objects], [1], + [Dependencies to place before and after the objects being linked to + create a shared library]) +_LT_TAGDECL([], [postdep_objects], [1]) +_LT_TAGDECL([], [predeps], [1]) +_LT_TAGDECL([], [postdeps], [1]) +_LT_TAGDECL([], [compiler_lib_search_path], [1], + [The library search path used internally by the compiler when linking + a shared library]) +])# _LT_SYS_HIDDEN_LIBDEPS + + +# _LT_LANG_F77_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a Fortran 77 compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_F77_CONFIG], +[AC_LANG_PUSH(Fortran 77) +if test -z "$F77" || test no = "$F77"; then + _lt_disable_F77=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the F77 compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_disable_F77"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${F77-"f77"} + CFLAGS=$FFLAGS + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + GCC=$G77 + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)=$G77 + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS +fi # test yes != "$_lt_disable_F77" + +AC_LANG_POP +])# _LT_LANG_F77_CONFIG + + +# _LT_LANG_FC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for a Fortran compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_FC_CONFIG], +[AC_LANG_PUSH(Fortran) + +if test -z "$FC" || test no = "$FC"; then + _lt_disable_FC=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for fc test sources. +ac_ext=${ac_fc_srcext-f} + +# Object file extension for compiled fc test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the FC compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_disable_FC"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${FC-"f95"} + CFLAGS=$FCFLAGS + compiler=$CC + GCC=$ac_cv_fc_compiler_gnu + + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS +fi # test yes != "$_lt_disable_FC" + +AC_LANG_POP +])# _LT_LANG_FC_CONFIG + + +# _LT_LANG_GCJ_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Java Compiler compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_GCJ_CONFIG], +[AC_REQUIRE([LT_PROG_GCJ])dnl +AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GCJ-"gcj"} +CFLAGS=$GCJFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)=$LD +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GCJ_CONFIG + + +# _LT_LANG_GO_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Go compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_GO_CONFIG], +[AC_REQUIRE([LT_PROG_GO])dnl +AC_LANG_SAVE + +# Source file extension for Go test sources. +ac_ext=go + +# Object file extension for compiled Go test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="package main; func main() { }" + +# Code to be used in simple link tests +lt_simple_link_test_code='package main; func main() { }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GOC-"gccgo"} +CFLAGS=$GOFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)=$LD +_LT_CC_BASENAME([$compiler]) + +# Go did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GO_CONFIG + + +# _LT_LANG_RC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for the Windows resource compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_RC_CONFIG], +[AC_REQUIRE([LT_PROG_RC])dnl +AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code=$lt_simple_compile_test_code + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC= +CC=${RC-"windres"} +CFLAGS= +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +if test -n "$compiler"; then + : + _LT_CONFIG($1) +fi + +GCC=$lt_save_GCC +AC_LANG_RESTORE +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_RC_CONFIG + + +# LT_PROG_GCJ +# ----------- +AC_DEFUN([LT_PROG_GCJ], +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], + [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], + [AC_CHECK_TOOL(GCJ, gcj,) + test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS)])])[]dnl +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_GCJ], []) + + +# LT_PROG_GO +# ---------- +AC_DEFUN([LT_PROG_GO], +[AC_CHECK_TOOL(GOC, gccgo,) +]) + + +# LT_PROG_RC +# ---------- +AC_DEFUN([LT_PROG_RC], +[AC_CHECK_TOOL(RC, windres,) +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_RC], []) + + +# _LT_DECL_EGREP +# -------------- +# If we don't have a new enough Autoconf to choose the best grep +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_EGREP], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_REQUIRE([AC_PROG_FGREP])dnl +test -z "$GREP" && GREP=grep +_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) +_LT_DECL([], [EGREP], [1], [An ERE matcher]) +_LT_DECL([], [FGREP], [1], [A literal string matcher]) +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too +AC_SUBST([GREP]) +]) + + +# _LT_DECL_OBJDUMP +# -------------- +# If we don't have a new enough Autoconf to choose the best objdump +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_OBJDUMP], +[AC_CHECK_TOOL(OBJDUMP, objdump, false) +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) +AC_SUBST([OBJDUMP]) +]) + +# _LT_DECL_DLLTOOL +# ---------------- +# Ensure DLLTOOL variable is set. +m4_defun([_LT_DECL_DLLTOOL], +[AC_CHECK_TOOL(DLLTOOL, dlltool, false) +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) +AC_SUBST([DLLTOOL]) +]) + +# _LT_DECL_SED +# ------------ +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +m4_defun([_LT_DECL_SED], +[AC_PROG_SED +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" +_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], + [Sed that helps us avoid accidentally triggering echo(1) options like -n]) +])# _LT_DECL_SED + +m4_ifndef([AC_PROG_SED], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ + +m4_defun([AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f "$lt_ac_sed" && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test 10 -lt "$lt_ac_count" && break + lt_ac_count=`expr $lt_ac_count + 1` + if test "$lt_ac_count" -gt "$lt_ac_max"; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +])#AC_PROG_SED +])#m4_ifndef + +# Old name: +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_SED], []) + + +# _LT_CHECK_SHELL_FEATURES +# ------------------------ +# Find out whether the shell is Bourne or XSI compatible, +# or has some other useful features. +m4_defun([_LT_CHECK_SHELL_FEATURES], +[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl +])# _LT_CHECK_SHELL_FEATURES + + +# _LT_PATH_CONVERSION_FUNCTIONS +# ----------------------------- +# Determine what file name conversion functions should be used by +# func_to_host_file (and, implicitly, by func_to_host_path). These are needed +# for certain cross-compile configurations and native mingw. +m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_MSG_CHECKING([how to convert $build file names to $host format]) +AC_CACHE_VAL(lt_cv_to_host_file_cmd, +[case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac +]) +to_host_file_cmd=$lt_cv_to_host_file_cmd +AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) +_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], + [0], [convert $build file names to $host format])dnl + +AC_MSG_CHECKING([how to convert $build file names to toolchain format]) +AC_CACHE_VAL(lt_cv_to_tool_file_cmd, +[#assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac +]) +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) +_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], + [0], [convert $build files to toolchain format])dnl +])# _LT_PATH_CONVERSION_FUNCTIONS diff --git a/src/secp256k1/build-aux/m4/ltoptions.m4 b/src/secp256k1/build-aux/m4/ltoptions.m4 new file mode 100644 index 0000000..94b0829 --- /dev/null +++ b/src/secp256k1/build-aux/m4/ltoptions.m4 @@ -0,0 +1,437 @@ +# Helper functions for option handling. -*- Autoconf -*- +# +# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software +# Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 8 ltoptions.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) + + +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) +# ------------------------------------------ +m4_define([_LT_MANGLE_OPTION], +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) + + +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) +# --------------------------------------- +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a +# matching handler defined, dispatch to it. Other OPTION-NAMEs are +# saved as a flag. +m4_define([_LT_SET_OPTION], +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), + _LT_MANGLE_DEFUN([$1], [$2]), + [m4_warning([Unknown $1 option '$2'])])[]dnl +]) + + +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) +# ------------------------------------------------------------ +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +m4_define([_LT_IF_OPTION], +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) + + +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) +# ------------------------------------------------------- +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME +# are set. +m4_define([_LT_UNLESS_OPTIONS], +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), + [m4_define([$0_found])])])[]dnl +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 +])[]dnl +]) + + +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) +# ---------------------------------------- +# OPTION-LIST is a space-separated list of Libtool options associated +# with MACRO-NAME. If any OPTION has a matching handler declared with +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about +# the unknown option and exit. +m4_defun([_LT_SET_OPTIONS], +[# Set options +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [_LT_SET_OPTION([$1], _LT_Option)]) + +m4_if([$1],[LT_INIT],[ + dnl + dnl Simply set some default values (i.e off) if boolean options were not + dnl specified: + _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no + ]) + _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no + ]) + dnl + dnl If no reference was made to various pairs of opposing options, then + dnl we run the default mode handler for the pair. For example, if neither + dnl 'shared' nor 'disable-shared' was passed, we enable building of shared + dnl archives by default: + _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) + _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], + [_LT_ENABLE_FAST_INSTALL]) + _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4], + [_LT_WITH_AIX_SONAME([aix])]) + ]) +])# _LT_SET_OPTIONS + + +## --------------------------------- ## +## Macros to handle LT_INIT options. ## +## --------------------------------- ## + +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) +# ----------------------------------------- +m4_define([_LT_MANGLE_DEFUN], +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) + + +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) +# ----------------------------------------------- +m4_define([LT_OPTION_DEFINE], +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl +])# LT_OPTION_DEFINE + + +# dlopen +# ------ +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes +]) + +AU_DEFUN([AC_LIBTOOL_DLOPEN], +[_LT_SET_OPTION([LT_INIT], [dlopen]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'dlopen' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) + + +# win32-dll +# --------- +# Declare package support for building win32 dll's. +LT_OPTION_DEFINE([LT_INIT], [win32-dll], +[enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +esac + +test -z "$AS" && AS=as +_LT_DECL([], [AS], [1], [Assembler program])dnl + +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl + +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl +])# win32-dll + +AU_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +_LT_SET_OPTION([LT_INIT], [win32-dll]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'win32-dll' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) + + +# _LT_ENABLE_SHARED([DEFAULT]) +# ---------------------------- +# implement the --enable-shared flag, and supports the 'shared' and +# 'disable-shared' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_SHARED], +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([shared], + [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) + + _LT_DECL([build_libtool_libs], [enable_shared], [0], + [Whether or not to build shared libraries]) +])# _LT_ENABLE_SHARED + +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) +]) + +AC_DEFUN([AC_DISABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], [disable-shared]) +]) + +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_SHARED], []) +dnl AC_DEFUN([AM_DISABLE_SHARED], []) + + + +# _LT_ENABLE_STATIC([DEFAULT]) +# ---------------------------- +# implement the --enable-static flag, and support the 'static' and +# 'disable-static' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_STATIC], +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_static=]_LT_ENABLE_STATIC_DEFAULT) + + _LT_DECL([build_old_libs], [enable_static], [0], + [Whether or not to build static libraries]) +])# _LT_ENABLE_STATIC + +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) +]) + +AC_DEFUN([AC_DISABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], [disable-static]) +]) + +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_STATIC], []) +dnl AC_DEFUN([AM_DISABLE_STATIC], []) + + + +# _LT_ENABLE_FAST_INSTALL([DEFAULT]) +# ---------------------------------- +# implement the --enable-fast-install flag, and support the 'fast-install' +# and 'disable-fast-install' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_FAST_INSTALL], +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([fast-install], + [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) + +_LT_DECL([fast_install], [enable_fast_install], [0], + [Whether or not to optimize for fast installation])dnl +])# _LT_ENABLE_FAST_INSTALL + +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) + +# Old names: +AU_DEFUN([AC_ENABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the 'fast-install' option into LT_INIT's first parameter.]) +]) + +AU_DEFUN([AC_DISABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the 'disable-fast-install' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) + + +# _LT_WITH_AIX_SONAME([DEFAULT]) +# ---------------------------------- +# implement the --with-aix-soname flag, and support the `aix-soname=aix' +# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT +# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'. +m4_define([_LT_WITH_AIX_SONAME], +[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl +shared_archive_member_spec= +case $host,$enable_shared in +power*-*-aix[[5-9]]*,yes) + AC_MSG_CHECKING([which variant of shared library versioning to provide]) + AC_ARG_WITH([aix-soname], + [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], + [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])], + [case $withval in + aix|svr4|both) + ;; + *) + AC_MSG_ERROR([Unknown argument to --with-aix-soname]) + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname], + [AC_CACHE_VAL([lt_cv_with_aix_soname], + [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT) + with_aix_soname=$lt_cv_with_aix_soname]) + AC_MSG_RESULT([$with_aix_soname]) + if test aix != "$with_aix_soname"; then + # For the AIX way of multilib, we name the shared archive member + # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', + # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. + # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, + # the AIX toolchain works better with OBJECT_MODE set (default 32). + if test 64 = "${OBJECT_MODE-32}"; then + shared_archive_member_spec=shr_64 + else + shared_archive_member_spec=shr + fi + fi + ;; +*) + with_aix_soname=aix + ;; +esac + +_LT_DECL([], [shared_archive_member_spec], [0], + [Shared archive member basename, for filename based shared library versioning on AIX])dnl +])# _LT_WITH_AIX_SONAME + +LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])]) +LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])]) +LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])]) + + +# _LT_WITH_PIC([MODE]) +# -------------------- +# implement the --with-pic flag, and support the 'pic-only' and 'no-pic' +# LT_INIT options. +# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'. +m4_define([_LT_WITH_PIC], +[AC_ARG_WITH([pic], + [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $withval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [pic_mode=m4_default([$1], [default])]) + +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl +])# _LT_WITH_PIC + +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) + +# Old name: +AU_DEFUN([AC_LIBTOOL_PICMODE], +[_LT_SET_OPTION([LT_INIT], [pic-only]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'pic-only' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) + +## ----------------- ## +## LTDL_INIT Options ## +## ----------------- ## + +m4_define([_LTDL_MODE], []) +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], + [m4_define([_LTDL_MODE], [nonrecursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [recursive], + [m4_define([_LTDL_MODE], [recursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [subproject], + [m4_define([_LTDL_MODE], [subproject])]) + +m4_define([_LTDL_TYPE], []) +LT_OPTION_DEFINE([LTDL_INIT], [installable], + [m4_define([_LTDL_TYPE], [installable])]) +LT_OPTION_DEFINE([LTDL_INIT], [convenience], + [m4_define([_LTDL_TYPE], [convenience])]) diff --git a/src/secp256k1/build-aux/m4/ltsugar.m4 b/src/secp256k1/build-aux/m4/ltsugar.m4 new file mode 100644 index 0000000..48bc934 --- /dev/null +++ b/src/secp256k1/build-aux/m4/ltsugar.m4 @@ -0,0 +1,124 @@ +# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- +# +# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software +# Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltsugar.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) + + +# lt_join(SEP, ARG1, [ARG2...]) +# ----------------------------- +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their +# associated separator. +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier +# versions in m4sugar had bugs. +m4_define([lt_join], +[m4_if([$#], [1], [], + [$#], [2], [[$2]], + [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) +m4_define([_lt_join], +[m4_if([$#$2], [2], [], + [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) + + +# lt_car(LIST) +# lt_cdr(LIST) +# ------------ +# Manipulate m4 lists. +# These macros are necessary as long as will still need to support +# Autoconf-2.59, which quotes differently. +m4_define([lt_car], [[$1]]) +m4_define([lt_cdr], +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], + [$#], 1, [], + [m4_dquote(m4_shift($@))])]) +m4_define([lt_unquote], $1) + + +# lt_append(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------ +# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. +# Note that neither SEPARATOR nor STRING are expanded; they are appended +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). +# No SEPARATOR is output if MACRO-NAME was previously undefined (different +# than defined and empty). +# +# This macro is needed until we can rely on Autoconf 2.62, since earlier +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. +m4_define([lt_append], +[m4_define([$1], + m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) + + + +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) +# ---------------------------------------------------------- +# Produce a SEP delimited list of all paired combinations of elements of +# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list +# has the form PREFIXmINFIXSUFFIXn. +# Needed until we can rely on m4_combine added in Autoconf 2.62. +m4_define([lt_combine], +[m4_if(m4_eval([$# > 3]), [1], + [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl +[[m4_foreach([_Lt_prefix], [$2], + [m4_foreach([_Lt_suffix], + ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, + [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) + + +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) +# ----------------------------------------------------------------------- +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. +m4_define([lt_if_append_uniq], +[m4_ifdef([$1], + [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], + [lt_append([$1], [$2], [$3])$4], + [$5])], + [lt_append([$1], [$2], [$3])$4])]) + + +# lt_dict_add(DICT, KEY, VALUE) +# ----------------------------- +m4_define([lt_dict_add], +[m4_define([$1($2)], [$3])]) + + +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) +# -------------------------------------------- +m4_define([lt_dict_add_subkey], +[m4_define([$1($2:$3)], [$4])]) + + +# lt_dict_fetch(DICT, KEY, [SUBKEY]) +# ---------------------------------- +m4_define([lt_dict_fetch], +[m4_ifval([$3], + m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), + m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) + + +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) +# ----------------------------------------------------------------- +m4_define([lt_if_dict_fetch], +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], + [$5], + [$6])]) + + +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) +# -------------------------------------------------------------- +m4_define([lt_dict_filter], +[m4_if([$5], [], [], + [lt_join(m4_quote(m4_default([$4], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), + [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl +]) diff --git a/src/secp256k1/build-aux/m4/ltversion.m4 b/src/secp256k1/build-aux/m4/ltversion.m4 new file mode 100644 index 0000000..fa04b52 --- /dev/null +++ b/src/secp256k1/build-aux/m4/ltversion.m4 @@ -0,0 +1,23 @@ +# ltversion.m4 -- version numbers -*- Autoconf -*- +# +# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# @configure_input@ + +# serial 4179 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.4.6]) +m4_define([LT_PACKAGE_REVISION], [2.4.6]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.4.6' +macro_revision='2.4.6' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +]) diff --git a/src/secp256k1/build-aux/m4/lt~obsolete.m4 b/src/secp256k1/build-aux/m4/lt~obsolete.m4 new file mode 100644 index 0000000..c6b26f8 --- /dev/null +++ b/src/secp256k1/build-aux/m4/lt~obsolete.m4 @@ -0,0 +1,99 @@ +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- +# +# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software +# Foundation, Inc. +# Written by Scott James Remnant, 2004. +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 5 lt~obsolete.m4 + +# These exist entirely to fool aclocal when bootstrapping libtool. +# +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN), +# which have later been changed to m4_define as they aren't part of the +# exported API, or moved to Autoconf or Automake where they belong. +# +# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us +# using a macro with the same name in our local m4/libtool.m4 it'll +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define +# and doesn't know about Autoconf macros at all.) +# +# So we provide this file, which has a silly filename so it's always +# included after everything else. This provides aclocal with the +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything +# because those macros already exist, or will be overwritten later. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. +# Yes, that means every name once taken will need to remain here until +# we give up compatibility with versions before 1.7, at which point +# we need to keep only those names which we still refer to. + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) + +m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) +m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) +m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) +m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) +m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) +m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) +m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) +m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) +m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) +m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) +m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) +m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) +m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) +m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) +m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) +m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) +m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) +m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) +m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) +m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) +m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) +m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) +m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) +m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) +m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) +m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) +m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) +m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) +m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) +m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) +m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) +m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) +m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) +m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) +m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) +m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) +m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) +m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) diff --git a/src/secp256k1/build-aux/missing b/src/secp256k1/build-aux/missing new file mode 100644 index 0000000..f62bbae --- /dev/null +++ b/src/secp256k1/build-aux/missing @@ -0,0 +1,215 @@ +#! /bin/sh +# Common wrapper for a few potentially missing GNU programs. + +scriptversion=2013-10-28.13; # UTC + +# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Originally written by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try '$0 --help' for more information" + exit 1 +fi + +case $1 in + + --is-lightweight) + # Used by our autoconf macros to check whether the available missing + # script is modern enough. + exit 0 + ;; + + --run) + # Back-compat with the calling convention used by older automake. + shift + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due +to PROGRAM being missing or too old. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal autoconf autoheader autom4te automake makeinfo + bison yacc flex lex help2man + +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and +'g' are ignored when checking the name. + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: unknown '$1' option" + echo 1>&2 "Try '$0 --help' for more information" + exit 1 + ;; + +esac + +# Run the given program, remember its exit status. +"$@"; st=$? + +# If it succeeded, we are done. +test $st -eq 0 && exit 0 + +# Also exit now if we it failed (or wasn't found), and '--version' was +# passed; such an option is passed most likely to detect whether the +# program is present and works. +case $2 in --version|--help) exit $st;; esac + +# Exit code 63 means version mismatch. This often happens when the user +# tries to use an ancient version of a tool on a file that requires a +# minimum version. +if test $st -eq 63; then + msg="probably too old" +elif test $st -eq 127; then + # Program was missing. + msg="missing on your system" +else + # Program was found and executed, but failed. Give up. + exit $st +fi + +perl_URL=http://www.perl.org/ +flex_URL=http://flex.sourceforge.net/ +gnu_software_URL=http://www.gnu.org/software + +program_details () +{ + case $1 in + aclocal|automake) + echo "The '$1' program is part of the GNU Automake package:" + echo "<$gnu_software_URL/automake>" + echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/autoconf>" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + autoconf|autom4te|autoheader) + echo "The '$1' program is part of the GNU Autoconf package:" + echo "<$gnu_software_URL/autoconf/>" + echo "It also requires GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + esac +} + +give_advice () +{ + # Normalize program name to check for. + normalized_program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + + printf '%s\n' "'$1' is $msg." + + configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + case $normalized_program in + autoconf*) + echo "You should only need it if you modified 'configure.ac'," + echo "or m4 files included by it." + program_details 'autoconf' + ;; + autoheader*) + echo "You should only need it if you modified 'acconfig.h' or" + echo "$configure_deps." + program_details 'autoheader' + ;; + automake*) + echo "You should only need it if you modified 'Makefile.am' or" + echo "$configure_deps." + program_details 'automake' + ;; + aclocal*) + echo "You should only need it if you modified 'acinclude.m4' or" + echo "$configure_deps." + program_details 'aclocal' + ;; + autom4te*) + echo "You might have modified some maintainer files that require" + echo "the 'autom4te' program to be rebuilt." + program_details 'autom4te' + ;; + bison*|yacc*) + echo "You should only need it if you modified a '.y' file." + echo "You may want to install the GNU Bison package:" + echo "<$gnu_software_URL/bison/>" + ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; + help2man*) + echo "You should only need it if you modified a dependency" \ + "of a man page." + echo "You may want to install the GNU Help2man package:" + echo "<$gnu_software_URL/help2man/>" + ;; + makeinfo*) + echo "You should only need it if you modified a '.texi' file, or" + echo "any other file indirectly affecting the aspect of the manual." + echo "You might want to install the Texinfo package:" + echo "<$gnu_software_URL/texinfo/>" + echo "The spurious makeinfo call might also be the consequence of" + echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" + echo "want to install GNU make:" + echo "<$gnu_software_URL/make/>" + ;; + *) + echo "You might have modified some files without having the proper" + echo "tools for further handling them. Check the 'README' file, it" + echo "often tells you about the needed prerequisites for installing" + echo "this package. You may also peek at any GNU archive site, in" + echo "case some other package contains this missing '$1' program." + ;; + esac +} + +give_advice "$1" | sed -e '1s/^/WARNING: /' \ + -e '2,$s/^/ /' >&2 + +# Propagate the correct exit status (expected to be 127 for a program +# not found, 63 for a program that failed due to version mismatch). +exit $st + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/secp256k1/build-aux/test-driver b/src/secp256k1/build-aux/test-driver new file mode 100644 index 0000000..8e575b0 --- /dev/null +++ b/src/secp256k1/build-aux/test-driver @@ -0,0 +1,148 @@ +#! /bin/sh +# test-driver - basic testsuite driver script. + +scriptversion=2013-07-13.22; # UTC + +# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +# Make unconditional expansion of undefined variables an error. This +# helps a lot in preventing typo-related bugs. +set -u + +usage_error () +{ + echo "$0: $*" >&2 + print_usage >&2 + exit 2 +} + +print_usage () +{ + cat <$log_file 2>&1 +estatus=$? + +if test $enable_hard_errors = no && test $estatus -eq 99; then + tweaked_estatus=1 +else + tweaked_estatus=$estatus +fi + +case $tweaked_estatus:$expect_failure in + 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; + 0:*) col=$grn res=PASS recheck=no gcopy=no;; + 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; + 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; + *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; + *:*) col=$red res=FAIL recheck=yes gcopy=yes;; +esac + +# Report the test outcome and exit status in the logs, so that one can +# know whether the test passed or failed simply by looking at the '.log' +# file, without the need of also peaking into the corresponding '.trs' +# file (automake bug#11814). +echo "$res $test_name (exit status: $estatus)" >>$log_file + +# Report outcome to console. +echo "${col}${res}${std}: $test_name" + +# Register the test result, and other relevant metadata. +echo ":test-result: $res" > $trs_file +echo ":global-test-result: $res" >> $trs_file +echo ":recheck: $recheck" >> $trs_file +echo ":copy-in-global-log: $gcopy" >> $trs_file + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/secp256k1/configure.ac b/src/secp256k1/configure.ac new file mode 100644 index 0000000..e421866 --- /dev/null +++ b/src/secp256k1/configure.ac @@ -0,0 +1,394 @@ +AC_PREREQ([2.60]) +AC_INIT([libsecp256k1],[0.1]) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_MACRO_DIR([build-aux/m4]) +AC_CANONICAL_HOST +AH_TOP([#ifndef LIBSECP256K1_CONFIG_H]) +AH_TOP([#define LIBSECP256K1_CONFIG_H]) +AH_BOTTOM([#endif /*LIBSECP256K1_CONFIG_H*/]) +AM_INIT_AUTOMAKE([foreign subdir-objects]) +LT_INIT + +dnl make the compilation flags quiet unless V=1 is used +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +PKG_PROG_PKG_CONFIG + +AC_PATH_TOOL(AR, ar) +AC_PATH_TOOL(RANLIB, ranlib) +AC_PATH_TOOL(STRIP, strip) +AX_PROG_CC_FOR_BUILD + +if test "x$CFLAGS" = "x"; then + CFLAGS="-O3 -g" +fi + +AM_PROG_CC_C_O + +AC_PROG_CC_C89 +if test x"$ac_cv_prog_cc_c89" = x"no"; then + AC_MSG_ERROR([c89 compiler support required]) +fi + +case $host_os in + *darwin*) + if test x$cross_compiling != xyes; then + AC_PATH_PROG([BREW],brew,) + if test x$BREW != x; then + dnl These Homebrew packages may be keg-only, meaning that they won't be found + dnl in expected paths because they may conflict with system files. Ask + dnl Homebrew where each one is located, then adjust paths accordingly. + + openssl_prefix=`$BREW --prefix openssl 2>/dev/null` + gmp_prefix=`$BREW --prefix gmp 2>/dev/null` + if test x$openssl_prefix != x; then + PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH" + export PKG_CONFIG_PATH + fi + if test x$gmp_prefix != x; then + GMP_CPPFLAGS="-I$gmp_prefix/include" + GMP_LIBS="-L$gmp_prefix/lib" + fi + else + AC_PATH_PROG([PORT],port,) + dnl if homebrew isn't installed and macports is, add the macports default paths + dnl as a last resort. + if test x$PORT != x; then + CPPFLAGS="$CPPFLAGS -isystem /opt/local/include" + LDFLAGS="$LDFLAGS -L/opt/local/lib" + fi + fi + fi + ;; +esac + +CFLAGS="$CFLAGS -W" + +warn_CFLAGS="-std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings" +saved_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $warn_CFLAGS" +AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}]) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], + [ AC_MSG_RESULT([yes]) ], + [ AC_MSG_RESULT([no]) + CFLAGS="$saved_CFLAGS" + ]) + +saved_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fvisibility=hidden" +AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], + [ AC_MSG_RESULT([yes]) ], + [ AC_MSG_RESULT([no]) + CFLAGS="$saved_CFLAGS" + ]) + +AC_ARG_ENABLE(benchmark, + AS_HELP_STRING([--enable-benchmark],[compile benchmark (default is no)]), + [use_benchmark=$enableval], + [use_benchmark=no]) + +AC_ARG_ENABLE(tests, + AS_HELP_STRING([--enable-tests],[compile tests (default is yes)]), + [use_tests=$enableval], + [use_tests=yes]) + +AC_ARG_ENABLE(experimental, + AS_HELP_STRING([--enable-experimental],[allow experimental configure options (default is no)]), + [use_experimental=$enableval], + [use_experimental=no]) + +AC_ARG_ENABLE(endomorphism, + AS_HELP_STRING([--enable-endomorphism],[enable endomorphism (default is no)]), + [use_endomorphism=$enableval], + [use_endomorphism=no]) + +AC_ARG_ENABLE(ecmult_static_precomputation, + AS_HELP_STRING([--enable-ecmult-static-precomputation],[enable precomputed ecmult table for signing (default is yes)]), + [use_ecmult_static_precomputation=$enableval], + [use_ecmult_static_precomputation=yes]) + +AC_ARG_ENABLE(module_ecdh, + AS_HELP_STRING([--enable-module-ecdh],[enable ECDH shared secret computation (experimental)]), + [enable_module_ecdh=$enableval], + [enable_module_ecdh=no]) + +AC_ARG_ENABLE(module_schnorr, + AS_HELP_STRING([--enable-module-schnorr],[enable Schnorr signature module (experimental)]), + [enable_module_schnorr=$enableval], + [enable_module_schnorr=no]) + +AC_ARG_ENABLE(module_recovery, + AS_HELP_STRING([--enable-module-recovery],[enable ECDSA pubkey recovery module (default is no)]), + [enable_module_recovery=$enableval], + [enable_module_recovery=no]) + +AC_ARG_WITH([field], [AS_HELP_STRING([--with-field=64bit|32bit|auto], +[Specify Field Implementation. Default is auto])],[req_field=$withval], [req_field=auto]) + +AC_ARG_WITH([bignum], [AS_HELP_STRING([--with-bignum=gmp|no|auto], +[Specify Bignum Implementation. Default is auto])],[req_bignum=$withval], [req_bignum=auto]) + +AC_ARG_WITH([scalar], [AS_HELP_STRING([--with-scalar=64bit|32bit|auto], +[Specify scalar implementation. Default is auto])],[req_scalar=$withval], [req_scalar=auto]) + +AC_ARG_WITH([asm], [AS_HELP_STRING([--with-asm=x86_64|no|auto] +[Specify assembly optimizations to use. Default is auto])],[req_asm=$withval], [req_asm=auto]) + +AC_CHECK_TYPES([__int128]) + +AC_MSG_CHECKING([for __builtin_expect]) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void myfunc() {__builtin_expect(0,0);}]])], + [ AC_MSG_RESULT([yes]);AC_DEFINE(HAVE_BUILTIN_EXPECT,1,[Define this symbol if __builtin_expect is available]) ], + [ AC_MSG_RESULT([no]) + ]) + +if test x"$req_asm" = x"auto"; then + SECP_64BIT_ASM_CHECK + if test x"$has_64bit_asm" = x"yes"; then + set_asm=x86_64 + fi + if test x"$set_asm" = x; then + set_asm=no + fi +else + set_asm=$req_asm + case $set_asm in + x86_64) + SECP_64BIT_ASM_CHECK + if test x"$has_64bit_asm" != x"yes"; then + AC_MSG_ERROR([x86_64 assembly optimization requested but not available]) + fi + ;; + no) + ;; + *) + AC_MSG_ERROR([invalid assembly optimization selection]) + ;; + esac +fi + +if test x"$req_field" = x"auto"; then + if test x"set_asm" = x"x86_64"; then + set_field=64bit + fi + if test x"$set_field" = x; then + SECP_INT128_CHECK + if test x"$has_int128" = x"yes"; then + set_field=64bit + fi + fi + if test x"$set_field" = x; then + set_field=32bit + fi +else + set_field=$req_field + case $set_field in + 64bit) + if test x"$set_asm" != x"x86_64"; then + SECP_INT128_CHECK + if test x"$has_int128" != x"yes"; then + AC_MSG_ERROR([64bit field explicitly requested but neither __int128 support or x86_64 assembly available]) + fi + fi + ;; + 32bit) + ;; + *) + AC_MSG_ERROR([invalid field implementation selection]) + ;; + esac +fi + +if test x"$req_scalar" = x"auto"; then + SECP_INT128_CHECK + if test x"$has_int128" = x"yes"; then + set_scalar=64bit + fi + if test x"$set_scalar" = x; then + set_scalar=32bit + fi +else + set_scalar=$req_scalar + case $set_scalar in + 64bit) + SECP_INT128_CHECK + if test x"$has_int128" != x"yes"; then + AC_MSG_ERROR([64bit scalar explicitly requested but __int128 support not available]) + fi + ;; + 32bit) + ;; + *) + AC_MSG_ERROR([invalid scalar implementation selected]) + ;; + esac +fi + +if test x"$req_bignum" = x"auto"; then + SECP_GMP_CHECK + if test x"$has_gmp" = x"yes"; then + set_bignum=gmp + fi + + if test x"$set_bignum" = x; then + set_bignum=no + fi +else + set_bignum=$req_bignum + case $set_bignum in + gmp) + SECP_GMP_CHECK + if test x"$has_gmp" != x"yes"; then + AC_MSG_ERROR([gmp bignum explicitly requested but libgmp not available]) + fi + ;; + no) + ;; + *) + AC_MSG_ERROR([invalid bignum implementation selection]) + ;; + esac +fi + +# select assembly optimization +case $set_asm in +x86_64) + AC_DEFINE(USE_ASM_X86_64, 1, [Define this symbol to enable x86_64 assembly optimizations]) + ;; +no) + ;; +*) + AC_MSG_ERROR([invalid assembly optimizations]) + ;; +esac + +# select field implementation +case $set_field in +64bit) + AC_DEFINE(USE_FIELD_5X52, 1, [Define this symbol to use the FIELD_5X52 implementation]) + ;; +32bit) + AC_DEFINE(USE_FIELD_10X26, 1, [Define this symbol to use the FIELD_10X26 implementation]) + ;; +*) + AC_MSG_ERROR([invalid field implementation]) + ;; +esac + +# select bignum implementation +case $set_bignum in +gmp) + AC_DEFINE(HAVE_LIBGMP, 1, [Define this symbol if libgmp is installed]) + AC_DEFINE(USE_NUM_GMP, 1, [Define this symbol to use the gmp implementation for num]) + AC_DEFINE(USE_FIELD_INV_NUM, 1, [Define this symbol to use the num-based field inverse implementation]) + AC_DEFINE(USE_SCALAR_INV_NUM, 1, [Define this symbol to use the num-based scalar inverse implementation]) + ;; +no) + AC_DEFINE(USE_NUM_NONE, 1, [Define this symbol to use no num implementation]) + AC_DEFINE(USE_FIELD_INV_BUILTIN, 1, [Define this symbol to use the native field inverse implementation]) + AC_DEFINE(USE_SCALAR_INV_BUILTIN, 1, [Define this symbol to use the native scalar inverse implementation]) + ;; +*) + AC_MSG_ERROR([invalid bignum implementation]) + ;; +esac + +#select scalar implementation +case $set_scalar in +64bit) + AC_DEFINE(USE_SCALAR_4X64, 1, [Define this symbol to use the 4x64 scalar implementation]) + ;; +32bit) + AC_DEFINE(USE_SCALAR_8X32, 1, [Define this symbol to use the 8x32 scalar implementation]) + ;; +*) + AC_MSG_ERROR([invalid scalar implementation]) + ;; +esac + +if test x"$use_tests" = x"yes"; then + SECP_OPENSSL_CHECK + if test x"$has_openssl_ec" = x"yes"; then + AC_DEFINE(ENABLE_OPENSSL_TESTS, 1, [Define this symbol if OpenSSL EC functions are available]) + SECP_TEST_INCLUDES="$SSL_CFLAGS $CRYPTO_CFLAGS" + SECP_TEST_LIBS="$CRYPTO_LIBS" + + case $host in + *mingw*) + SECP_TEST_LIBS="$SECP_TEST_LIBS -lgdi32" + ;; + esac + + fi +fi + +if test x"$set_bignum" = x"gmp"; then + SECP_LIBS="$SECP_LIBS $GMP_LIBS" + SECP_INCLUDES="$SECP_INCLUDES $GMP_CPPFLAGS" +fi + +if test x"$use_endomorphism" = x"yes"; then + AC_DEFINE(USE_ENDOMORPHISM, 1, [Define this symbol to use endomorphism optimization]) +fi + +if test x"$use_ecmult_static_precomputation" = x"yes"; then + AC_DEFINE(USE_ECMULT_STATIC_PRECOMPUTATION, 1, [Define this symbol to use a statically generated ecmult table]) +fi + +if test x"$enable_module_ecdh" = x"yes"; then + AC_DEFINE(ENABLE_MODULE_ECDH, 1, [Define this symbol to enable the ECDH module]) +fi + +if test x"$enable_module_schnorr" = x"yes"; then + AC_DEFINE(ENABLE_MODULE_SCHNORR, 1, [Define this symbol to enable the Schnorr signature module]) +fi + +if test x"$enable_module_recovery" = x"yes"; then + AC_DEFINE(ENABLE_MODULE_RECOVERY, 1, [Define this symbol to enable the ECDSA pubkey recovery module]) +fi + +AC_C_BIGENDIAN() + +AC_MSG_NOTICE([Using assembly optimizations: $set_asm]) +AC_MSG_NOTICE([Using field implementation: $set_field]) +AC_MSG_NOTICE([Using bignum implementation: $set_bignum]) +AC_MSG_NOTICE([Using scalar implementation: $set_scalar]) +AC_MSG_NOTICE([Using endomorphism optimizations: $use_endomorphism]) +AC_MSG_NOTICE([Building ECDSA pubkey recovery module: $enable_module_recovery]) + +if test x"$enable_experimental" = x"yes"; then + AC_MSG_NOTICE([******]) + AC_MSG_NOTICE([WARNING: experimental build]) + AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.]) + AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh]) + AC_MSG_NOTICE([Building Schnorr signatures module: $enable_module_schnorr]) + AC_MSG_NOTICE([******]) +else + if test x"$enable_module_schnorr" = x"yes"; then + AC_MSG_ERROR([Schnorr signature module is experimental. Use --enable-experimental to allow.]) + fi + if test x"$enable_module_ecdh" = x"yes"; then + AC_MSG_ERROR([ECDH module is experimental. Use --enable-experimental to allow.]) + fi +fi + +AC_CONFIG_HEADERS([src/libsecp256k1-config.h]) +AC_CONFIG_FILES([Makefile libsecp256k1.pc]) +AC_SUBST(SECP_INCLUDES) +AC_SUBST(SECP_LIBS) +AC_SUBST(SECP_TEST_LIBS) +AC_SUBST(SECP_TEST_INCLUDES) +AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"]) +AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"]) +AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$use_ecmult_static_precomputation" = x"yes"]) +AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"]) +AM_CONDITIONAL([ENABLE_MODULE_SCHNORR], [test x"$enable_module_schnorr" = x"yes"]) +AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"]) + +dnl make sure nothing new is exported so that we don't break the cache +PKGCONFIG_PATH_TEMP="$PKG_CONFIG_PATH" +unset PKG_CONFIG_PATH +PKG_CONFIG_PATH="$PKGCONFIG_PATH_TEMP" + +AC_OUTPUT diff --git a/src/secp256k1/contrib/lax_der_parsing.c b/src/secp256k1/contrib/lax_der_parsing.c new file mode 100644 index 0000000..5b141a9 --- /dev/null +++ b/src/secp256k1/contrib/lax_der_parsing.c @@ -0,0 +1,150 @@ +/********************************************************************** + * Copyright (c) 2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#include +#include + +#include "lax_der_parsing.h" + +int ecdsa_signature_parse_der_lax(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char *input, size_t inputlen) { + size_t rpos, rlen, spos, slen; + size_t pos = 0; + size_t lenbyte; + unsigned char tmpsig[64] = {0}; + int overflow = 0; + + /* Hack to initialize sig with a correctly-parsed but invalid signature. */ + secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig); + + /* Sequence tag byte */ + if (pos == inputlen || input[pos] != 0x30) { + return 0; + } + pos++; + + /* Sequence length bytes */ + if (pos == inputlen) { + return 0; + } + lenbyte = input[pos++]; + if (lenbyte & 0x80) { + lenbyte -= 0x80; + if (pos + lenbyte > inputlen) { + return 0; + } + pos += lenbyte; + } + + /* Integer tag byte for R */ + if (pos == inputlen || input[pos] != 0x02) { + return 0; + } + pos++; + + /* Integer length for R */ + if (pos == inputlen) { + return 0; + } + lenbyte = input[pos++]; + if (lenbyte & 0x80) { + lenbyte -= 0x80; + if (pos + lenbyte > inputlen) { + return 0; + } + while (lenbyte > 0 && input[pos] == 0) { + pos++; + lenbyte--; + } + if (lenbyte >= sizeof(size_t)) { + return 0; + } + rlen = 0; + while (lenbyte > 0) { + rlen = (rlen << 8) + input[pos]; + pos++; + lenbyte--; + } + } else { + rlen = lenbyte; + } + if (rlen > inputlen - pos) { + return 0; + } + rpos = pos; + pos += rlen; + + /* Integer tag byte for S */ + if (pos == inputlen || input[pos] != 0x02) { + return 0; + } + pos++; + + /* Integer length for S */ + if (pos == inputlen) { + return 0; + } + lenbyte = input[pos++]; + if (lenbyte & 0x80) { + lenbyte -= 0x80; + if (pos + lenbyte > inputlen) { + return 0; + } + while (lenbyte > 0 && input[pos] == 0) { + pos++; + lenbyte--; + } + if (lenbyte >= sizeof(size_t)) { + return 0; + } + slen = 0; + while (lenbyte > 0) { + slen = (slen << 8) + input[pos]; + pos++; + lenbyte--; + } + } else { + slen = lenbyte; + } + if (slen > inputlen - pos) { + return 0; + } + spos = pos; + pos += slen; + + /* Ignore leading zeroes in R */ + while (rlen > 0 && input[rpos] == 0) { + rlen--; + rpos++; + } + /* Copy R value */ + if (rlen > 32) { + overflow = 1; + } else { + memcpy(tmpsig + 32 - rlen, input + rpos, rlen); + } + + /* Ignore leading zeroes in S */ + while (slen > 0 && input[spos] == 0) { + slen--; + spos++; + } + /* Copy S value */ + if (slen > 32) { + overflow = 1; + } else { + memcpy(tmpsig + 64 - slen, input + spos, slen); + } + + if (!overflow) { + overflow = !secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig); + } + if (overflow) { + memset(tmpsig, 0, 64); + secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig); + } + return 1; +} + diff --git a/src/secp256k1/contrib/lax_der_parsing.h b/src/secp256k1/contrib/lax_der_parsing.h new file mode 100644 index 0000000..6d27871 --- /dev/null +++ b/src/secp256k1/contrib/lax_der_parsing.h @@ -0,0 +1,91 @@ +/********************************************************************** + * Copyright (c) 2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +/**** + * Please do not link this file directly. It is not part of the libsecp256k1 + * project and does not promise any stability in its API, functionality or + * presence. Projects which use this code should instead copy this header + * and its accompanying .c file directly into their codebase. + ****/ + +/* This file defines a function that parses DER with various errors and + * violations. This is not a part of the library itself, because the allowed + * violations are chosen arbitrarily and do not follow or establish any + * standard. + * + * In many places it matters that different implementations do not only accept + * the same set of valid signatures, but also reject the same set of signatures. + * The only means to accomplish that is by strictly obeying a standard, and not + * accepting anything else. + * + * Nonetheless, sometimes there is a need for compatibility with systems that + * use signatures which do not strictly obey DER. The snippet below shows how + * certain violations are easily supported. You may need to adapt it. + * + * Do not use this for new systems. Use well-defined DER or compact signatures + * instead if you have the choice (see secp256k1_ecdsa_signature_parse_der and + * secp256k1_ecdsa_signature_parse_compact). + * + * The supported violations are: + * - All numbers are parsed as nonnegative integers, even though X.609-0207 + * section 8.3.3 specifies that integers are always encoded as two's + * complement. + * - Integers can have length 0, even though section 8.3.1 says they can't. + * - Integers with overly long padding are accepted, violation section + * 8.3.2. + * - 127-byte long length descriptors are accepted, even though section + * 8.1.3.5.c says that they are not. + * - Trailing garbage data inside or after the signature is ignored. + * - The length descriptor of the sequence is ignored. + * + * Compared to for example OpenSSL, many violations are NOT supported: + * - Using overly long tag descriptors for the sequence or integers inside, + * violating section 8.1.2.2. + * - Encoding primitive integers as constructed values, violating section + * 8.3.1. + */ + +#ifndef _SECP256K1_CONTRIB_LAX_DER_PARSING_H_ +#define _SECP256K1_CONTRIB_LAX_DER_PARSING_H_ + +#include + +# ifdef __cplusplus +extern "C" { +# endif + +/** Parse a signature in "lax DER" format + * + * Returns: 1 when the signature could be parsed, 0 otherwise. + * Args: ctx: a secp256k1 context object + * Out: sig: a pointer to a signature object + * In: input: a pointer to the signature to be parsed + * inputlen: the length of the array pointed to be input + * + * This function will accept any valid DER encoded signature, even if the + * encoded numbers are out of range. In addition, it will accept signatures + * which violate the DER spec in various ways. Its purpose is to allow + * validation of the Bitcoin blockchain, which includes non-DER signatures + * from before the network rules were updated to enforce DER. Note that + * the set of supported violations is a strict subset of what OpenSSL will + * accept. + * + * After the call, sig will always be initialized. If parsing failed or the + * encoded numbers are out of range, signature validation with it is + * guaranteed to fail for every message and public key. + */ +int ecdsa_signature_parse_der_lax( + const secp256k1_context* ctx, + secp256k1_ecdsa_signature* sig, + const unsigned char *input, + size_t inputlen +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/secp256k1/contrib/lax_der_privatekey_parsing.c b/src/secp256k1/contrib/lax_der_privatekey_parsing.c new file mode 100644 index 0000000..c2e63b4 --- /dev/null +++ b/src/secp256k1/contrib/lax_der_privatekey_parsing.c @@ -0,0 +1,113 @@ +/********************************************************************** + * Copyright (c) 2014, 2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#include +#include + +#include "lax_der_privatekey_parsing.h" + +int ec_privkey_import_der(const secp256k1_context* ctx, unsigned char *out32, const unsigned char *privkey, size_t privkeylen) { + const unsigned char *end = privkey + privkeylen; + int lenb = 0; + int len = 0; + memset(out32, 0, 32); + /* sequence header */ + if (end < privkey+1 || *privkey != 0x30) { + return 0; + } + privkey++; + /* sequence length constructor */ + if (end < privkey+1 || !(*privkey & 0x80)) { + return 0; + } + lenb = *privkey & ~0x80; privkey++; + if (lenb < 1 || lenb > 2) { + return 0; + } + if (end < privkey+lenb) { + return 0; + } + /* sequence length */ + len = privkey[lenb-1] | (lenb > 1 ? privkey[lenb-2] << 8 : 0); + privkey += lenb; + if (end < privkey+len) { + return 0; + } + /* sequence element 0: version number (=1) */ + if (end < privkey+3 || privkey[0] != 0x02 || privkey[1] != 0x01 || privkey[2] != 0x01) { + return 0; + } + privkey += 3; + /* sequence element 1: octet string, up to 32 bytes */ + if (end < privkey+2 || privkey[0] != 0x04 || privkey[1] > 0x20 || end < privkey+2+privkey[1]) { + return 0; + } + memcpy(out32 + 32 - privkey[1], privkey + 2, privkey[1]); + if (!secp256k1_ec_seckey_verify(ctx, out32)) { + memset(out32, 0, 32); + return 0; + } + return 1; +} + +int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, int compressed) { + secp256k1_pubkey pubkey; + size_t pubkeylen = 0; + if (!secp256k1_ec_pubkey_create(ctx, &pubkey, key32)) { + *privkeylen = 0; + return 0; + } + if (compressed) { + static const unsigned char begin[] = { + 0x30,0x81,0xD3,0x02,0x01,0x01,0x04,0x20 + }; + static const unsigned char middle[] = { + 0xA0,0x81,0x85,0x30,0x81,0x82,0x02,0x01,0x01,0x30,0x2C,0x06,0x07,0x2A,0x86,0x48, + 0xCE,0x3D,0x01,0x01,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFE,0xFF,0xFF,0xFC,0x2F,0x30,0x06,0x04,0x01,0x00,0x04,0x01,0x07,0x04, + 0x21,0x02,0x79,0xBE,0x66,0x7E,0xF9,0xDC,0xBB,0xAC,0x55,0xA0,0x62,0x95,0xCE,0x87, + 0x0B,0x07,0x02,0x9B,0xFC,0xDB,0x2D,0xCE,0x28,0xD9,0x59,0xF2,0x81,0x5B,0x16,0xF8, + 0x17,0x98,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFE,0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,0xBF,0xD2,0x5E, + 0x8C,0xD0,0x36,0x41,0x41,0x02,0x01,0x01,0xA1,0x24,0x03,0x22,0x00 + }; + unsigned char *ptr = privkey; + memcpy(ptr, begin, sizeof(begin)); ptr += sizeof(begin); + memcpy(ptr, key32, 32); ptr += 32; + memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle); + pubkeylen = 33; + secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED); + ptr += pubkeylen; + *privkeylen = ptr - privkey; + } else { + static const unsigned char begin[] = { + 0x30,0x82,0x01,0x13,0x02,0x01,0x01,0x04,0x20 + }; + static const unsigned char middle[] = { + 0xA0,0x81,0xA5,0x30,0x81,0xA2,0x02,0x01,0x01,0x30,0x2C,0x06,0x07,0x2A,0x86,0x48, + 0xCE,0x3D,0x01,0x01,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFE,0xFF,0xFF,0xFC,0x2F,0x30,0x06,0x04,0x01,0x00,0x04,0x01,0x07,0x04, + 0x41,0x04,0x79,0xBE,0x66,0x7E,0xF9,0xDC,0xBB,0xAC,0x55,0xA0,0x62,0x95,0xCE,0x87, + 0x0B,0x07,0x02,0x9B,0xFC,0xDB,0x2D,0xCE,0x28,0xD9,0x59,0xF2,0x81,0x5B,0x16,0xF8, + 0x17,0x98,0x48,0x3A,0xDA,0x77,0x26,0xA3,0xC4,0x65,0x5D,0xA4,0xFB,0xFC,0x0E,0x11, + 0x08,0xA8,0xFD,0x17,0xB4,0x48,0xA6,0x85,0x54,0x19,0x9C,0x47,0xD0,0x8F,0xFB,0x10, + 0xD4,0xB8,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFE,0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,0xBF,0xD2,0x5E, + 0x8C,0xD0,0x36,0x41,0x41,0x02,0x01,0x01,0xA1,0x44,0x03,0x42,0x00 + }; + unsigned char *ptr = privkey; + memcpy(ptr, begin, sizeof(begin)); ptr += sizeof(begin); + memcpy(ptr, key32, 32); ptr += 32; + memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle); + pubkeylen = 65; + secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_UNCOMPRESSED); + ptr += pubkeylen; + *privkeylen = ptr - privkey; + } + return 1; +} diff --git a/src/secp256k1/contrib/lax_der_privatekey_parsing.h b/src/secp256k1/contrib/lax_der_privatekey_parsing.h new file mode 100644 index 0000000..2fd088f --- /dev/null +++ b/src/secp256k1/contrib/lax_der_privatekey_parsing.h @@ -0,0 +1,90 @@ +/********************************************************************** + * Copyright (c) 2014, 2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +/**** + * Please do not link this file directly. It is not part of the libsecp256k1 + * project and does not promise any stability in its API, functionality or + * presence. Projects which use this code should instead copy this header + * and its accompanying .c file directly into their codebase. + ****/ + +/* This file contains code snippets that parse DER private keys with + * various errors and violations. This is not a part of the library + * itself, because the allowed violations are chosen arbitrarily and + * do not follow or establish any standard. + * + * It also contains code to serialize private keys in a compatible + * manner. + * + * These functions are meant for compatibility with applications + * that require BER encoded keys. When working with secp256k1-specific + * code, the simple 32-byte private keys normally used by the + * library are sufficient. + */ + +#ifndef _SECP256K1_CONTRIB_BER_PRIVATEKEY_H_ +#define _SECP256K1_CONTRIB_BER_PRIVATEKEY_H_ + +#include + +# ifdef __cplusplus +extern "C" { +# endif + +/** Export a private key in DER format. + * + * Returns: 1 if the private key was valid. + * Args: ctx: pointer to a context object, initialized for signing (cannot + * be NULL) + * Out: privkey: pointer to an array for storing the private key in BER. + * Should have space for 279 bytes, and cannot be NULL. + * privkeylen: Pointer to an int where the length of the private key in + * privkey will be stored. + * In: seckey: pointer to a 32-byte secret key to export. + * compressed: 1 if the key should be exported in + * compressed format, 0 otherwise + * + * This function is purely meant for compatibility with applications that + * require BER encoded keys. When working with secp256k1-specific code, the + * simple 32-byte private keys are sufficient. + * + * Note that this function does not guarantee correct DER output. It is + * guaranteed to be parsable by secp256k1_ec_privkey_import_der + */ +SECP256K1_WARN_UNUSED_RESULT int ec_privkey_export_der( + const secp256k1_context* ctx, + unsigned char *privkey, + size_t *privkeylen, + const unsigned char *seckey, + int compressed +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Import a private key in DER format. + * Returns: 1 if a private key was extracted. + * Args: ctx: pointer to a context object (cannot be NULL). + * Out: seckey: pointer to a 32-byte array for storing the private key. + * (cannot be NULL). + * In: privkey: pointer to a private key in DER format (cannot be NULL). + * privkeylen: length of the DER private key pointed to be privkey. + * + * This function will accept more than just strict DER, and even allow some BER + * violations. The public key stored inside the DER-encoded private key is not + * verified for correctness, nor are the curve parameters. Use this function + * only if you know in advance it is supposed to contain a secp256k1 private + * key. + */ +SECP256K1_WARN_UNUSED_RESULT int ec_privkey_import_der( + const secp256k1_context* ctx, + unsigned char *seckey, + const unsigned char *privkey, + size_t privkeylen +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/secp256k1/include/secp256k1.h b/src/secp256k1/include/secp256k1.h new file mode 100644 index 0000000..7145dbc --- /dev/null +++ b/src/secp256k1/include/secp256k1.h @@ -0,0 +1,583 @@ +#ifndef _SECP256K1_ +# define _SECP256K1_ + +# ifdef __cplusplus +extern "C" { +# endif + +#include + +/* These rules specify the order of arguments in API calls: + * + * 1. Context pointers go first, followed by output arguments, combined + * output/input arguments, and finally input-only arguments. + * 2. Array lengths always immediately the follow the argument whose length + * they describe, even if this violates rule 1. + * 3. Within the OUT/OUTIN/IN groups, pointers to data that is typically generated + * later go first. This means: signatures, public nonces, private nonces, + * messages, public keys, secret keys, tweaks. + * 4. Arguments that are not data pointers go last, from more complex to less + * complex: function pointers, algorithm names, messages, void pointers, + * counts, flags, booleans. + * 5. Opaque data pointers follow the function pointer they are to be passed to. + */ + +/** Opaque data structure that holds context information (precomputed tables etc.). + * + * The purpose of context structures is to cache large precomputed data tables + * that are expensive to construct, and also to maintain the randomization data + * for blinding. + * + * Do not create a new context object for each operation, as construction is + * far slower than all other API calls (~100 times slower than an ECDSA + * verification). + * + * A constructed context can safely be used from multiple threads + * simultaneously, but API call that take a non-const pointer to a context + * need exclusive access to it. In particular this is the case for + * secp256k1_context_destroy and secp256k1_context_randomize. + * + * Regarding randomization, either do it once at creation time (in which case + * you do not need any locking for the other calls), or use a read-write lock. + */ +typedef struct secp256k1_context_struct secp256k1_context; + +/** Opaque data structure that holds a parsed and valid public key. + * + * The exact representation of data inside is implementation defined and not + * guaranteed to be portable between different platforms or versions. It is + * however guaranteed to be 64 bytes in size, and can be safely copied/moved. + * If you need to convert to a format suitable for storage or transmission, use + * secp256k1_ec_pubkey_serialize and secp256k1_ec_pubkey_parse. + * + * Furthermore, it is guaranteed that identical public keys (ignoring + * compression) will have identical representation, so they can be memcmp'ed. + */ +typedef struct { + unsigned char data[64]; +} secp256k1_pubkey; + +/** Opaque data structured that holds a parsed ECDSA signature. + * + * The exact representation of data inside is implementation defined and not + * guaranteed to be portable between different platforms or versions. It is + * however guaranteed to be 64 bytes in size, and can be safely copied/moved. + * If you need to convert to a format suitable for storage or transmission, use + * the secp256k1_ecdsa_signature_serialize_* and + * secp256k1_ecdsa_signature_serialize_* functions. + * + * Furthermore, it is guaranteed to identical signatures will have identical + * representation, so they can be memcmp'ed. + */ +typedef struct { + unsigned char data[64]; +} secp256k1_ecdsa_signature; + +/** A pointer to a function to deterministically generate a nonce. + * + * Returns: 1 if a nonce was successfully generated. 0 will cause signing to fail. + * Out: nonce32: pointer to a 32-byte array to be filled by the function. + * In: msg32: the 32-byte message hash being verified (will not be NULL) + * key32: pointer to a 32-byte secret key (will not be NULL) + * algo16: pointer to a 16-byte array describing the signature + * algorithm (will be NULL for ECDSA for compatibility). + * data: Arbitrary data pointer that is passed through. + * attempt: how many iterations we have tried to find a nonce. + * This will almost always be 0, but different attempt values + * are required to result in a different nonce. + * + * Except for test cases, this function should compute some cryptographic hash of + * the message, the algorithm, the key and the attempt. + */ +typedef int (*secp256k1_nonce_function)( + unsigned char *nonce32, + const unsigned char *msg32, + const unsigned char *key32, + const unsigned char *algo16, + void *data, + unsigned int attempt +); + +# if !defined(SECP256K1_GNUC_PREREQ) +# if defined(__GNUC__)&&defined(__GNUC_MINOR__) +# define SECP256K1_GNUC_PREREQ(_maj,_min) \ + ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) +# else +# define SECP256K1_GNUC_PREREQ(_maj,_min) 0 +# endif +# endif + +# if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) +# if SECP256K1_GNUC_PREREQ(2,7) +# define SECP256K1_INLINE __inline__ +# elif (defined(_MSC_VER)) +# define SECP256K1_INLINE __inline +# else +# define SECP256K1_INLINE +# endif +# else +# define SECP256K1_INLINE inline +# endif + +#ifndef SECP256K1_API +# if defined(_WIN32) +# ifdef SECP256K1_BUILD +# define SECP256K1_API __declspec(dllexport) +# else +# define SECP256K1_API +# endif +# elif defined(__GNUC__) && defined(SECP256K1_BUILD) +# define SECP256K1_API __attribute__ ((visibility ("default"))) +# else +# define SECP256K1_API +# endif +#endif + +/**Warning attributes + * NONNULL is not used if SECP256K1_BUILD is set to avoid the compiler optimizing out + * some paranoid null checks. */ +# if defined(__GNUC__) && SECP256K1_GNUC_PREREQ(3, 4) +# define SECP256K1_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) +# else +# define SECP256K1_WARN_UNUSED_RESULT +# endif +# if !defined(SECP256K1_BUILD) && defined(__GNUC__) && SECP256K1_GNUC_PREREQ(3, 4) +# define SECP256K1_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) +# else +# define SECP256K1_ARG_NONNULL(_x) +# endif + +/** All flags' lower 8 bits indicate what they're for. Do not use directly. */ +#define SECP256K1_FLAGS_TYPE_MASK ((1 << 8) - 1) +#define SECP256K1_FLAGS_TYPE_CONTEXT (1 << 0) +#define SECP256K1_FLAGS_TYPE_COMPRESSION (1 << 1) +/** The higher bits contain the actual data. Do not use directly. */ +#define SECP256K1_FLAGS_BIT_CONTEXT_VERIFY (1 << 8) +#define SECP256K1_FLAGS_BIT_CONTEXT_SIGN (1 << 9) +#define SECP256K1_FLAGS_BIT_COMPRESSION (1 << 8) + +/** Flags to pass to secp256k1_context_create. */ +#define SECP256K1_CONTEXT_VERIFY (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_VERIFY) +#define SECP256K1_CONTEXT_SIGN (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_SIGN) +#define SECP256K1_CONTEXT_NONE (SECP256K1_FLAGS_TYPE_CONTEXT) + +/** Flag to pass to secp256k1_ec_pubkey_serialize and secp256k1_ec_privkey_export. */ +#define SECP256K1_EC_COMPRESSED (SECP256K1_FLAGS_TYPE_COMPRESSION | SECP256K1_FLAGS_BIT_COMPRESSION) +#define SECP256K1_EC_UNCOMPRESSED (SECP256K1_FLAGS_TYPE_COMPRESSION) + +/** Create a secp256k1 context object. + * + * Returns: a newly created context object. + * In: flags: which parts of the context to initialize. + */ +SECP256K1_API secp256k1_context* secp256k1_context_create( + unsigned int flags +) SECP256K1_WARN_UNUSED_RESULT; + +/** Copies a secp256k1 context object. + * + * Returns: a newly created context object. + * Args: ctx: an existing context to copy (cannot be NULL) + */ +SECP256K1_API secp256k1_context* secp256k1_context_clone( + const secp256k1_context* ctx +) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT; + +/** Destroy a secp256k1 context object. + * + * The context pointer may not be used afterwards. + * Args: ctx: an existing context to destroy (cannot be NULL) + */ +SECP256K1_API void secp256k1_context_destroy( + secp256k1_context* ctx +); + +/** Set a callback function to be called when an illegal argument is passed to + * an API call. It will only trigger for violations that are mentioned + * explicitly in the header. + * + * The philosophy is that these shouldn't be dealt with through a + * specific return value, as calling code should not have branches to deal with + * the case that this code itself is broken. + * + * On the other hand, during debug stage, one would want to be informed about + * such mistakes, and the default (crashing) may be inadvisable. + * When this callback is triggered, the API function called is guaranteed not + * to cause a crash, though its return value and output arguments are + * undefined. + * + * Args: ctx: an existing context object (cannot be NULL) + * In: fun: a pointer to a function to call when an illegal argument is + * passed to the API, taking a message and an opaque pointer + * (NULL restores a default handler that calls abort). + * data: the opaque pointer to pass to fun above. + */ +SECP256K1_API void secp256k1_context_set_illegal_callback( + secp256k1_context* ctx, + void (*fun)(const char* message, void* data), + const void* data +) SECP256K1_ARG_NONNULL(1); + +/** Set a callback function to be called when an internal consistency check + * fails. The default is crashing. + * + * This can only trigger in case of a hardware failure, miscompilation, + * memory corruption, serious bug in the library, or other error would can + * otherwise result in undefined behaviour. It will not trigger due to mere + * incorrect usage of the API (see secp256k1_context_set_illegal_callback + * for that). After this callback returns, anything may happen, including + * crashing. + * + * Args: ctx: an existing context object (cannot be NULL) + * In: fun: a pointer to a function to call when an internal error occurs, + * taking a message and an opaque pointer (NULL restores a default + * handler that calls abort). + * data: the opaque pointer to pass to fun above. + */ +SECP256K1_API void secp256k1_context_set_error_callback( + secp256k1_context* ctx, + void (*fun)(const char* message, void* data), + const void* data +) SECP256K1_ARG_NONNULL(1); + +/** Parse a variable-length public key into the pubkey object. + * + * Returns: 1 if the public key was fully valid. + * 0 if the public key could not be parsed or is invalid. + * Args: ctx: a secp256k1 context object. + * Out: pubkey: pointer to a pubkey object. If 1 is returned, it is set to a + * parsed version of input. If not, its value is undefined. + * In: input: pointer to a serialized public key + * inputlen: length of the array pointed to by input + * + * This function supports parsing compressed (33 bytes, header byte 0x02 or + * 0x03), uncompressed (65 bytes, header byte 0x04), or hybrid (65 bytes, header + * byte 0x06 or 0x07) format public keys. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_parse( + const secp256k1_context* ctx, + secp256k1_pubkey* pubkey, + const unsigned char *input, + size_t inputlen +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Serialize a pubkey object into a serialized byte sequence. + * + * Returns: 1 always. + * Args: ctx: a secp256k1 context object. + * Out: output: a pointer to a 65-byte (if compressed==0) or 33-byte (if + * compressed==1) byte array to place the serialized key + * in. + * In/Out: outputlen: a pointer to an integer which is initially set to the + * size of output, and is overwritten with the written + * size. + * In: pubkey: a pointer to a secp256k1_pubkey containing an + * initialized public key. + * flags: SECP256K1_EC_COMPRESSED if serialization should be in + * compressed format, otherwise SECP256K1_EC_UNCOMPRESSED. + */ +SECP256K1_API int secp256k1_ec_pubkey_serialize( + const secp256k1_context* ctx, + unsigned char *output, + size_t *outputlen, + const secp256k1_pubkey* pubkey, + unsigned int flags +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Parse an ECDSA signature in compact (64 bytes) format. + * + * Returns: 1 when the signature could be parsed, 0 otherwise. + * Args: ctx: a secp256k1 context object + * Out: sig: a pointer to a signature object + * In: input64: a pointer to the 64-byte array to parse + * + * The signature must consist of a 32-byte big endian R value, followed by a + * 32-byte big endian S value. If R or S fall outside of [0..order-1], the + * encoding is invalid. R and S with value 0 are allowed in the encoding. + * + * After the call, sig will always be initialized. If parsing failed or R or + * S are zero, the resulting sig value is guaranteed to fail validation for any + * message and public key. + */ +SECP256K1_API int secp256k1_ecdsa_signature_parse_compact( + const secp256k1_context* ctx, + secp256k1_ecdsa_signature* sig, + const unsigned char *input64 +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Parse a DER ECDSA signature. + * + * Returns: 1 when the signature could be parsed, 0 otherwise. + * Args: ctx: a secp256k1 context object + * Out: sig: a pointer to a signature object + * In: input: a pointer to the signature to be parsed + * inputlen: the length of the array pointed to be input + * + * This function will accept any valid DER encoded signature, even if the + * encoded numbers are out of range. + * + * After the call, sig will always be initialized. If parsing failed or the + * encoded numbers are out of range, signature validation with it is + * guaranteed to fail for every message and public key. + */ +SECP256K1_API int secp256k1_ecdsa_signature_parse_der( + const secp256k1_context* ctx, + secp256k1_ecdsa_signature* sig, + const unsigned char *input, + size_t inputlen +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Serialize an ECDSA signature in DER format. + * + * Returns: 1 if enough space was available to serialize, 0 otherwise + * Args: ctx: a secp256k1 context object + * Out: output: a pointer to an array to store the DER serialization + * In/Out: outputlen: a pointer to a length integer. Initially, this integer + * should be set to the length of output. After the call + * it will be set to the length of the serialization (even + * if 0 was returned). + * In: sig: a pointer to an initialized signature object + */ +SECP256K1_API int secp256k1_ecdsa_signature_serialize_der( + const secp256k1_context* ctx, + unsigned char *output, + size_t *outputlen, + const secp256k1_ecdsa_signature* sig +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Serialize an ECDSA signature in compact (64 byte) format. + * + * Returns: 1 + * Args: ctx: a secp256k1 context object + * Out: output64: a pointer to a 64-byte array to store the compact serialization + * In: sig: a pointer to an initialized signature object + * + * See secp256k1_ecdsa_signature_parse_compact for details about the encoding. + */ +SECP256K1_API int secp256k1_ecdsa_signature_serialize_compact( + const secp256k1_context* ctx, + unsigned char *output64, + const secp256k1_ecdsa_signature* sig +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Verify an ECDSA signature. + * + * Returns: 1: correct signature + * 0: incorrect or unparseable signature + * Args: ctx: a secp256k1 context object, initialized for verification. + * In: sig: the signature being verified (cannot be NULL) + * msg32: the 32-byte message hash being verified (cannot be NULL) + * pubkey: pointer to an initialized public key to verify with (cannot be NULL) + * + * To avoid accepting malleable signatures, only ECDSA signatures in lower-S + * form are accepted. + * + * If you need to accept ECDSA signatures from sources that do not obey this + * rule, apply secp256k1_ecdsa_signature_normalize to the signature prior to + * validation, but be aware that doing so results in malleable signatures. + * + * For details, see the comments for that function. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify( + const secp256k1_context* ctx, + const secp256k1_ecdsa_signature *sig, + const unsigned char *msg32, + const secp256k1_pubkey *pubkey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Convert a signature to a normalized lower-S form. + * + * Returns: 1 if sigin was not normalized, 0 if it already was. + * Args: ctx: a secp256k1 context object + * Out: sigout: a pointer to a signature to fill with the normalized form, + * or copy if the input was already normalized. (can be NULL if + * you're only interested in whether the input was already + * normalized). + * In: sigin: a pointer to a signature to check/normalize (cannot be NULL, + * can be identical to sigout) + * + * With ECDSA a third-party can forge a second distinct signature of the same + * message, given a single initial signature, but without knowing the key. This + * is done by negating the S value modulo the order of the curve, 'flipping' + * the sign of the random point R which is not included in the signature. + * + * Forgery of the same message isn't universally problematic, but in systems + * where message malleability or uniqueness of signatures is important this can + * cause issues. This forgery can be blocked by all verifiers forcing signers + * to use a normalized form. + * + * The lower-S form reduces the size of signatures slightly on average when + * variable length encodings (such as DER) are used and is cheap to verify, + * making it a good choice. Security of always using lower-S is assured because + * anyone can trivially modify a signature after the fact to enforce this + * property anyway. + * + * The lower S value is always between 0x1 and + * 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, + * inclusive. + * + * No other forms of ECDSA malleability are known and none seem likely, but + * there is no formal proof that ECDSA, even with this additional restriction, + * is free of other malleability. Commonly used serialization schemes will also + * accept various non-unique encodings, so care should be taken when this + * property is required for an application. + * + * The secp256k1_ecdsa_sign function will by default create signatures in the + * lower-S form, and secp256k1_ecdsa_verify will not accept others. In case + * signatures come from a system that cannot enforce this property, + * secp256k1_ecdsa_signature_normalize must be called before verification. + */ +SECP256K1_API int secp256k1_ecdsa_signature_normalize( + const secp256k1_context* ctx, + secp256k1_ecdsa_signature *sigout, + const secp256k1_ecdsa_signature *sigin +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(3); + +/** An implementation of RFC6979 (using HMAC-SHA256) as nonce generation function. + * If a data pointer is passed, it is assumed to be a pointer to 32 bytes of + * extra entropy. + */ +SECP256K1_API extern const secp256k1_nonce_function secp256k1_nonce_function_rfc6979; + +/** A default safe nonce generation function (currently equal to secp256k1_nonce_function_rfc6979). */ +SECP256K1_API extern const secp256k1_nonce_function secp256k1_nonce_function_default; + +/** Create an ECDSA signature. + * + * Returns: 1: signature created + * 0: the nonce generation function failed, or the private key was invalid. + * Args: ctx: pointer to a context object, initialized for signing (cannot be NULL) + * Out: sig: pointer to an array where the signature will be placed (cannot be NULL) + * In: msg32: the 32-byte message hash being signed (cannot be NULL) + * seckey: pointer to a 32-byte secret key (cannot be NULL) + * noncefp:pointer to a nonce generation function. If NULL, secp256k1_nonce_function_default is used + * ndata: pointer to arbitrary data used by the nonce generation function (can be NULL) + * + * The created signature is always in lower-S form. See + * secp256k1_ecdsa_signature_normalize for more details. + */ +SECP256K1_API int secp256k1_ecdsa_sign( + const secp256k1_context* ctx, + secp256k1_ecdsa_signature *sig, + const unsigned char *msg32, + const unsigned char *seckey, + secp256k1_nonce_function noncefp, + const void *ndata +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Verify an ECDSA secret key. + * + * Returns: 1: secret key is valid + * 0: secret key is invalid + * Args: ctx: pointer to a context object (cannot be NULL) + * In: seckey: pointer to a 32-byte secret key (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify( + const secp256k1_context* ctx, + const unsigned char *seckey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2); + +/** Compute the public key for a secret key. + * + * Returns: 1: secret was valid, public key stores + * 0: secret was invalid, try again + * Args: ctx: pointer to a context object, initialized for signing (cannot be NULL) + * Out: pubkey: pointer to the created public key (cannot be NULL) + * In: seckey: pointer to a 32-byte private key (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create( + const secp256k1_context* ctx, + secp256k1_pubkey *pubkey, + const unsigned char *seckey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Tweak a private key by adding tweak to it. + * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for + * uniformly random 32-byte arrays, or if the resulting private key + * would be invalid (only when the tweak is the complement of the + * private key). 1 otherwise. + * Args: ctx: pointer to a context object (cannot be NULL). + * In/Out: seckey: pointer to a 32-byte private key. + * In: tweak: pointer to a 32-byte tweak. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add( + const secp256k1_context* ctx, + unsigned char *seckey, + const unsigned char *tweak +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Tweak a public key by adding tweak times the generator to it. + * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for + * uniformly random 32-byte arrays, or if the resulting public key + * would be invalid (only when the tweak is the complement of the + * corresponding private key). 1 otherwise. + * Args: ctx: pointer to a context object initialized for validation + * (cannot be NULL). + * In/Out: pubkey: pointer to a public key object. + * In: tweak: pointer to a 32-byte tweak. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add( + const secp256k1_context* ctx, + secp256k1_pubkey *pubkey, + const unsigned char *tweak +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Tweak a private key by multiplying it by a tweak. + * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for + * uniformly random 32-byte arrays, or equal to zero. 1 otherwise. + * Args: ctx: pointer to a context object (cannot be NULL). + * In/Out: seckey: pointer to a 32-byte private key. + * In: tweak: pointer to a 32-byte tweak. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul( + const secp256k1_context* ctx, + unsigned char *seckey, + const unsigned char *tweak +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Tweak a public key by multiplying it by a tweak value. + * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for + * uniformly random 32-byte arrays, or equal to zero. 1 otherwise. + * Args: ctx: pointer to a context object initialized for validation + * (cannot be NULL). + * In/Out: pubkey: pointer to a public key obkect. + * In: tweak: pointer to a 32-byte tweak. + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul( + const secp256k1_context* ctx, + secp256k1_pubkey *pubkey, + const unsigned char *tweak +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Updates the context randomization. + * Returns: 1: randomization successfully updated + * 0: error + * Args: ctx: pointer to a context object (cannot be NULL) + * In: seed32: pointer to a 32-byte random seed (NULL resets to initial state) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize( + secp256k1_context* ctx, + const unsigned char *seed32 +) SECP256K1_ARG_NONNULL(1); + +/** Add a number of public keys together. + * Returns: 1: the sum of the public keys is valid. + * 0: the sum of the public keys is not valid. + * Args: ctx: pointer to a context object + * Out: out: pointer to a public key object for placing the resulting public key + * (cannot be NULL) + * In: ins: pointer to array of pointers to public keys (cannot be NULL) + * n: the number of public keys to add together (must be at least 1) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine( + const secp256k1_context* ctx, + secp256k1_pubkey *out, + const secp256k1_pubkey * const * ins, + size_t n +) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/src/secp256k1/include/secp256k1_ecdh.h b/src/secp256k1/include/secp256k1_ecdh.h new file mode 100644 index 0000000..4b84d7a --- /dev/null +++ b/src/secp256k1/include/secp256k1_ecdh.h @@ -0,0 +1,31 @@ +#ifndef _SECP256K1_ECDH_ +# define _SECP256K1_ECDH_ + +# include "secp256k1.h" + +# ifdef __cplusplus +extern "C" { +# endif + +/** Compute an EC Diffie-Hellman secret in constant time + * Returns: 1: exponentiation was successful + * 0: scalar was invalid (zero or overflow) + * Args: ctx: pointer to a context object (cannot be NULL) + * Out: result: a 32-byte array which will be populated by an ECDH + * secret computed from the point and scalar + * In: pubkey: a pointer to a secp256k1_pubkey containing an + * initialized public key + * privkey: a 32-byte scalar with which to multiply the point + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdh( + const secp256k1_context* ctx, + unsigned char *result, + const secp256k1_pubkey *pubkey, + const unsigned char *privkey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/src/secp256k1/include/secp256k1_recovery.h b/src/secp256k1/include/secp256k1_recovery.h new file mode 100644 index 0000000..0553797 --- /dev/null +++ b/src/secp256k1/include/secp256k1_recovery.h @@ -0,0 +1,110 @@ +#ifndef _SECP256K1_RECOVERY_ +# define _SECP256K1_RECOVERY_ + +# include "secp256k1.h" + +# ifdef __cplusplus +extern "C" { +# endif + +/** Opaque data structured that holds a parsed ECDSA signature, + * supporting pubkey recovery. + * + * The exact representation of data inside is implementation defined and not + * guaranteed to be portable between different platforms or versions. It is + * however guaranteed to be 65 bytes in size, and can be safely copied/moved. + * If you need to convert to a format suitable for storage or transmission, use + * the secp256k1_ecdsa_signature_serialize_* and + * secp256k1_ecdsa_signature_parse_* functions. + * + * Furthermore, it is guaranteed that identical signatures (including their + * recoverability) will have identical representation, so they can be + * memcmp'ed. + */ +typedef struct { + unsigned char data[65]; +} secp256k1_ecdsa_recoverable_signature; + +/** Parse a compact ECDSA signature (64 bytes + recovery id). + * + * Returns: 1 when the signature could be parsed, 0 otherwise + * Args: ctx: a secp256k1 context object + * Out: sig: a pointer to a signature object + * In: input64: a pointer to a 64-byte compact signature + * recid: the recovery id (0, 1, 2 or 3) + */ +SECP256K1_API int secp256k1_ecdsa_recoverable_signature_parse_compact( + const secp256k1_context* ctx, + secp256k1_ecdsa_recoverable_signature* sig, + const unsigned char *input64, + int recid +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Convert a recoverable signature into a normal signature. + * + * Returns: 1 + * Out: sig: a pointer to a normal signature (cannot be NULL). + * In: sigin: a pointer to a recoverable signature (cannot be NULL). + */ +SECP256K1_API int secp256k1_ecdsa_recoverable_signature_convert( + const secp256k1_context* ctx, + secp256k1_ecdsa_signature* sig, + const secp256k1_ecdsa_recoverable_signature* sigin +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Serialize an ECDSA signature in compact format (64 bytes + recovery id). + * + * Returns: 1 + * Args: ctx: a secp256k1 context object + * Out: output64: a pointer to a 64-byte array of the compact signature (cannot be NULL) + * recid: a pointer to an integer to hold the recovery id (can be NULL). + * In: sig: a pointer to an initialized signature object (cannot be NULL) + */ +SECP256K1_API int secp256k1_ecdsa_recoverable_signature_serialize_compact( + const secp256k1_context* ctx, + unsigned char *output64, + int *recid, + const secp256k1_ecdsa_recoverable_signature* sig +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Create a recoverable ECDSA signature. + * + * Returns: 1: signature created + * 0: the nonce generation function failed, or the private key was invalid. + * Args: ctx: pointer to a context object, initialized for signing (cannot be NULL) + * Out: sig: pointer to an array where the signature will be placed (cannot be NULL) + * In: msg32: the 32-byte message hash being signed (cannot be NULL) + * seckey: pointer to a 32-byte secret key (cannot be NULL) + * noncefp:pointer to a nonce generation function. If NULL, secp256k1_nonce_function_default is used + * ndata: pointer to arbitrary data used by the nonce generation function (can be NULL) + */ +SECP256K1_API int secp256k1_ecdsa_sign_recoverable( + const secp256k1_context* ctx, + secp256k1_ecdsa_recoverable_signature *sig, + const unsigned char *msg32, + const unsigned char *seckey, + secp256k1_nonce_function noncefp, + const void *ndata +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Recover an ECDSA public key from a signature. + * + * Returns: 1: public key successfully recovered (which guarantees a correct signature). + * 0: otherwise. + * Args: ctx: pointer to a context object, initialized for verification (cannot be NULL) + * Out: pubkey: pointer to the recovered public key (cannot be NULL) + * In: sig: pointer to initialized signature that supports pubkey recovery (cannot be NULL) + * msg32: the 32-byte message hash assumed to be signed (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_recover( + const secp256k1_context* ctx, + secp256k1_pubkey *pubkey, + const secp256k1_ecdsa_recoverable_signature *sig, + const unsigned char *msg32 +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/src/secp256k1/include/secp256k1_schnorr.h b/src/secp256k1/include/secp256k1_schnorr.h new file mode 100644 index 0000000..dc32fec --- /dev/null +++ b/src/secp256k1/include/secp256k1_schnorr.h @@ -0,0 +1,173 @@ +#ifndef _SECP256K1_SCHNORR_ +# define _SECP256K1_SCHNORR_ + +# include "secp256k1.h" + +# ifdef __cplusplus +extern "C" { +# endif + +/** Create a signature using a custom EC-Schnorr-SHA256 construction. It + * produces non-malleable 64-byte signatures which support public key recovery + * batch validation, and multiparty signing. + * Returns: 1: signature created + * 0: the nonce generation function failed, or the private key was + * invalid. + * Args: ctx: pointer to a context object, initialized for signing + * (cannot be NULL) + * Out: sig64: pointer to a 64-byte array where the signature will be + * placed (cannot be NULL) + * In: msg32: the 32-byte message hash being signed (cannot be NULL) + * seckey: pointer to a 32-byte secret key (cannot be NULL) + * noncefp:pointer to a nonce generation function. If NULL, + * secp256k1_nonce_function_default is used + * ndata: pointer to arbitrary data used by the nonce generation + * function (can be NULL) + */ +SECP256K1_API int secp256k1_schnorr_sign( + const secp256k1_context* ctx, + unsigned char *sig64, + const unsigned char *msg32, + const unsigned char *seckey, + secp256k1_nonce_function noncefp, + const void *ndata +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Verify a signature created by secp256k1_schnorr_sign. + * Returns: 1: correct signature + * 0: incorrect signature + * Args: ctx: a secp256k1 context object, initialized for verification. + * In: sig64: the 64-byte signature being verified (cannot be NULL) + * msg32: the 32-byte message hash being verified (cannot be NULL) + * pubkey: the public key to verify with (cannot be NULL) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorr_verify( + const secp256k1_context* ctx, + const unsigned char *sig64, + const unsigned char *msg32, + const secp256k1_pubkey *pubkey +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Recover an EC public key from a Schnorr signature created using + * secp256k1_schnorr_sign. + * Returns: 1: public key successfully recovered (which guarantees a correct + * signature). + * 0: otherwise. + * Args: ctx: pointer to a context object, initialized for + * verification (cannot be NULL) + * Out: pubkey: pointer to a pubkey to set to the recovered public key + * (cannot be NULL). + * In: sig64: signature as 64 byte array (cannot be NULL) + * msg32: the 32-byte message hash assumed to be signed (cannot + * be NULL) + */ +SECP256K1_API int secp256k1_schnorr_recover( + const secp256k1_context* ctx, + secp256k1_pubkey *pubkey, + const unsigned char *sig64, + const unsigned char *msg32 +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); + +/** Generate a nonce pair deterministically for use with + * secp256k1_schnorr_partial_sign. + * Returns: 1: valid nonce pair was generated. + * 0: otherwise (nonce generation function failed) + * Args: ctx: pointer to a context object, initialized for signing + * (cannot be NULL) + * Out: pubnonce: public side of the nonce (cannot be NULL) + * privnonce32: private side of the nonce (32 byte) (cannot be NULL) + * In: msg32: the 32-byte message hash assumed to be signed (cannot + * be NULL) + * sec32: the 32-byte private key (cannot be NULL) + * noncefp: pointer to a nonce generation function. If NULL, + * secp256k1_nonce_function_default is used + * noncedata: pointer to arbitrary data used by the nonce generation + * function (can be NULL) + * + * Do not use the output as a private/public key pair for signing/validation. + */ +SECP256K1_API int secp256k1_schnorr_generate_nonce_pair( + const secp256k1_context* ctx, + secp256k1_pubkey *pubnonce, + unsigned char *privnonce32, + const unsigned char *msg32, + const unsigned char *sec32, + secp256k1_nonce_function noncefp, + const void* noncedata +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +/** Produce a partial Schnorr signature, which can be combined using + * secp256k1_schnorr_partial_combine, to end up with a full signature that is + * verifiable using secp256k1_schnorr_verify. + * Returns: 1: signature created successfully. + * 0: no valid signature exists with this combination of keys, nonces + * and message (chance around 1 in 2^128) + * -1: invalid private key, nonce, or public nonces. + * Args: ctx: pointer to context object, initialized for signing (cannot + * be NULL) + * Out: sig64: pointer to 64-byte array to put partial signature in + * In: msg32: pointer to 32-byte message to sign + * sec32: pointer to 32-byte private key + * pubnonce_others: pointer to pubkey containing the sum of the other's + * nonces (see secp256k1_ec_pubkey_combine) + * secnonce32: pointer to 32-byte array containing our nonce + * + * The intended procedure for creating a multiparty signature is: + * - Each signer S[i] with private key x[i] and public key Q[i] runs + * secp256k1_schnorr_generate_nonce_pair to produce a pair (k[i],R[i]) of + * private/public nonces. + * - All signers communicate their public nonces to each other (revealing your + * private nonce can lead to discovery of your private key, so it should be + * considered secret). + * - All signers combine all the public nonces they received (excluding their + * own) using secp256k1_ec_pubkey_combine to obtain an + * Rall[i] = sum(R[0..i-1,i+1..n]). + * - All signers produce a partial signature using + * secp256k1_schnorr_partial_sign, passing in their own private key x[i], + * their own private nonce k[i], and the sum of the others' public nonces + * Rall[i]. + * - All signers communicate their partial signatures to each other. + * - Someone combines all partial signatures using + * secp256k1_schnorr_partial_combine, to obtain a full signature. + * - The resulting signature is validatable using secp256k1_schnorr_verify, with + * public key equal to the result of secp256k1_ec_pubkey_combine of the + * signers' public keys (sum(Q[0..n])). + * + * Note that secp256k1_schnorr_partial_combine and secp256k1_ec_pubkey_combine + * function take their arguments in any order, and it is possible to + * pre-combine several inputs already with one call, and add more inputs later + * by calling the function again (they are commutative and associative). + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorr_partial_sign( + const secp256k1_context* ctx, + unsigned char *sig64, + const unsigned char *msg32, + const unsigned char *sec32, + const secp256k1_pubkey *pubnonce_others, + const unsigned char *secnonce32 +) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(6); + +/** Combine multiple Schnorr partial signatures. + * Returns: 1: the passed signatures were successfully combined. + * 0: the resulting signature is not valid (chance of 1 in 2^256) + * -1: some inputs were invalid, or the signatures were not created + * using the same set of nonces + * Args: ctx: pointer to a context object + * Out: sig64: pointer to a 64-byte array to place the combined signature + * (cannot be NULL) + * In: sig64sin: pointer to an array of n pointers to 64-byte input + * signatures + * n: the number of signatures to combine (at least 1) + */ +SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorr_partial_combine( + const secp256k1_context* ctx, + unsigned char *sig64, + const unsigned char * const * sig64sin, + size_t n +) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/src/secp256k1/libsecp256k1.pc.in b/src/secp256k1/libsecp256k1.pc.in new file mode 100644 index 0000000..1c72dd0 --- /dev/null +++ b/src/secp256k1/libsecp256k1.pc.in @@ -0,0 +1,13 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libsecp256k1 +Description: Optimized C library for EC operations on curve secp256k1 +URL: https://github.com/bitcoin/secp256k1 +Version: @PACKAGE_VERSION@ +Cflags: -I${includedir} +Libs.private: @SECP_LIBS@ +Libs: -L${libdir} -lsecp256k1 + diff --git a/src/secp256k1/obj/.gitignore b/src/secp256k1/obj/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/src/secp256k1/sage/group_prover.sage b/src/secp256k1/sage/group_prover.sage new file mode 100644 index 0000000..ab580c5 --- /dev/null +++ b/src/secp256k1/sage/group_prover.sage @@ -0,0 +1,322 @@ +# This code supports verifying group implementations which have branches +# or conditional statements (like cmovs), by allowing each execution path +# to independently set assumptions on input or intermediary variables. +# +# The general approach is: +# * A constraint is a tuple of two sets of of symbolic expressions: +# the first of which are required to evaluate to zero, the second of which +# are required to evaluate to nonzero. +# - A constraint is said to be conflicting if any of its nonzero expressions +# is in the ideal with basis the zero expressions (in other words: when the +# zero expressions imply that one of the nonzero expressions are zero). +# * There is a list of laws that describe the intended behaviour, including +# laws for addition and doubling. Each law is called with the symbolic point +# coordinates as arguments, and returns: +# - A constraint describing the assumptions under which it is applicable, +# called "assumeLaw" +# - A constraint describing the requirements of the law, called "require" +# * Implementations are transliterated into functions that operate as well on +# algebraic input points, and are called once per combination of branches +# exectured. Each execution returns: +# - A constraint describing the assumptions this implementation requires +# (such as Z1=1), called "assumeFormula" +# - A constraint describing the assumptions this specific branch requires, +# but which is by construction guaranteed to cover the entire space by +# merging the results from all branches, called "assumeBranch" +# - The result of the computation +# * All combinations of laws with implementation branches are tried, and: +# - If the combination of assumeLaw, assumeFormula, and assumeBranch results +# in a conflict, it means this law does not apply to this branch, and it is +# skipped. +# - For others, we try to prove the require constraints hold, assuming the +# information in assumeLaw + assumeFormula + assumeBranch, and if this does +# not succeed, we fail. +# + To prove an expression is zero, we check whether it belongs to the +# ideal with the assumed zero expressions as basis. This test is exact. +# + To prove an expression is nonzero, we check whether each of its +# factors is contained in the set of nonzero assumptions' factors. +# This test is not exact, so various combinations of original and +# reduced expressions' factors are tried. +# - If we succeed, we print out the assumptions from assumeFormula that +# weren't implied by assumeLaw already. Those from assumeBranch are skipped, +# as we assume that all constraints in it are complementary with each other. +# +# Based on the sage verification scripts used in the Explicit-Formulas Database +# by Tanja Lange and others, see http://hyperelliptic.org/EFD + +class fastfrac: + """Fractions over rings.""" + + def __init__(self,R,top,bot=1): + """Construct a fractional, given a ring, a numerator, and denominator.""" + self.R = R + if parent(top) == ZZ or parent(top) == R: + self.top = R(top) + self.bot = R(bot) + elif top.__class__ == fastfrac: + self.top = top.top + self.bot = top.bot * bot + else: + self.top = R(numerator(top)) + self.bot = R(denominator(top)) * bot + + def iszero(self,I): + """Return whether this fraction is zero given an ideal.""" + return self.top in I and self.bot not in I + + def reduce(self,assumeZero): + zero = self.R.ideal(map(numerator, assumeZero)) + return fastfrac(self.R, zero.reduce(self.top)) / fastfrac(self.R, zero.reduce(self.bot)) + + def __add__(self,other): + """Add two fractions.""" + if parent(other) == ZZ: + return fastfrac(self.R,self.top + self.bot * other,self.bot) + if other.__class__ == fastfrac: + return fastfrac(self.R,self.top * other.bot + self.bot * other.top,self.bot * other.bot) + return NotImplemented + + def __sub__(self,other): + """Subtract two fractions.""" + if parent(other) == ZZ: + return fastfrac(self.R,self.top - self.bot * other,self.bot) + if other.__class__ == fastfrac: + return fastfrac(self.R,self.top * other.bot - self.bot * other.top,self.bot * other.bot) + return NotImplemented + + def __neg__(self): + """Return the negation of a fraction.""" + return fastfrac(self.R,-self.top,self.bot) + + def __mul__(self,other): + """Multiply two fractions.""" + if parent(other) == ZZ: + return fastfrac(self.R,self.top * other,self.bot) + if other.__class__ == fastfrac: + return fastfrac(self.R,self.top * other.top,self.bot * other.bot) + return NotImplemented + + def __rmul__(self,other): + """Multiply something else with a fraction.""" + return self.__mul__(other) + + def __div__(self,other): + """Divide two fractions.""" + if parent(other) == ZZ: + return fastfrac(self.R,self.top,self.bot * other) + if other.__class__ == fastfrac: + return fastfrac(self.R,self.top * other.bot,self.bot * other.top) + return NotImplemented + + def __pow__(self,other): + """Compute a power of a fraction.""" + if parent(other) == ZZ: + if other < 0: + # Negative powers require flipping top and bottom + return fastfrac(self.R,self.bot ^ (-other),self.top ^ (-other)) + else: + return fastfrac(self.R,self.top ^ other,self.bot ^ other) + return NotImplemented + + def __str__(self): + return "fastfrac((" + str(self.top) + ") / (" + str(self.bot) + "))" + def __repr__(self): + return "%s" % self + + def numerator(self): + return self.top + +class constraints: + """A set of constraints, consisting of zero and nonzero expressions. + + Constraints can either be used to express knowledge or a requirement. + + Both the fields zero and nonzero are maps from expressions to description + strings. The expressions that are the keys in zero are required to be zero, + and the expressions that are the keys in nonzero are required to be nonzero. + + Note that (a != 0) and (b != 0) is the same as (a*b != 0), so all keys in + nonzero could be multiplied into a single key. This is often much less + efficient to work with though, so we keep them separate inside the + constraints. This allows higher-level code to do fast checks on the individual + nonzero elements, or combine them if needed for stronger checks. + + We can't multiply the different zero elements, as it would suffice for one of + the factors to be zero, instead of all of them. Instead, the zero elements are + typically combined into an ideal first. + """ + + def __init__(self, **kwargs): + if 'zero' in kwargs: + self.zero = dict(kwargs['zero']) + else: + self.zero = dict() + if 'nonzero' in kwargs: + self.nonzero = dict(kwargs['nonzero']) + else: + self.nonzero = dict() + + def negate(self): + return constraints(zero=self.nonzero, nonzero=self.zero) + + def __add__(self, other): + zero = self.zero.copy() + zero.update(other.zero) + nonzero = self.nonzero.copy() + nonzero.update(other.nonzero) + return constraints(zero=zero, nonzero=nonzero) + + def __str__(self): + return "constraints(zero=%s,nonzero=%s)" % (self.zero, self.nonzero) + + def __repr__(self): + return "%s" % self + + +def conflicts(R, con): + """Check whether any of the passed non-zero assumptions is implied by the zero assumptions""" + zero = R.ideal(map(numerator, con.zero)) + if 1 in zero: + return True + # First a cheap check whether any of the individual nonzero terms conflict on + # their own. + for nonzero in con.nonzero: + if nonzero.iszero(zero): + return True + # It can be the case that entries in the nonzero set do not individually + # conflict with the zero set, but their combination does. For example, knowing + # that either x or y is zero is equivalent to having x*y in the zero set. + # Having x or y individually in the nonzero set is not a conflict, but both + # simultaneously is, so that is the right thing to check for. + if reduce(lambda a,b: a * b, con.nonzero, fastfrac(R, 1)).iszero(zero): + return True + return False + + +def get_nonzero_set(R, assume): + """Calculate a simple set of nonzero expressions""" + zero = R.ideal(map(numerator, assume.zero)) + nonzero = set() + for nz in map(numerator, assume.nonzero): + for (f,n) in nz.factor(): + nonzero.add(f) + rnz = zero.reduce(nz) + for (f,n) in rnz.factor(): + nonzero.add(f) + return nonzero + + +def prove_nonzero(R, exprs, assume): + """Check whether an expression is provably nonzero, given assumptions""" + zero = R.ideal(map(numerator, assume.zero)) + nonzero = get_nonzero_set(R, assume) + expl = set() + ok = True + for expr in exprs: + if numerator(expr) in zero: + return (False, [exprs[expr]]) + allexprs = reduce(lambda a,b: numerator(a)*numerator(b), exprs, 1) + for (f, n) in allexprs.factor(): + if f not in nonzero: + ok = False + if ok: + return (True, None) + ok = True + for (f, n) in zero.reduce(numerator(allexprs)).factor(): + if f not in nonzero: + ok = False + if ok: + return (True, None) + ok = True + for expr in exprs: + for (f,n) in numerator(expr).factor(): + if f not in nonzero: + ok = False + if ok: + return (True, None) + ok = True + for expr in exprs: + for (f,n) in zero.reduce(numerator(expr)).factor(): + if f not in nonzero: + expl.add(exprs[expr]) + if expl: + return (False, list(expl)) + else: + return (True, None) + + +def prove_zero(R, exprs, assume): + """Check whether all of the passed expressions are provably zero, given assumptions""" + r, e = prove_nonzero(R, dict(map(lambda x: (fastfrac(R, x.bot, 1), exprs[x]), exprs)), assume) + if not r: + return (False, map(lambda x: "Possibly zero denominator: %s" % x, e)) + zero = R.ideal(map(numerator, assume.zero)) + nonzero = prod(x for x in assume.nonzero) + expl = [] + for expr in exprs: + if not expr.iszero(zero): + expl.append(exprs[expr]) + if not expl: + return (True, None) + return (False, expl) + + +def describe_extra(R, assume, assumeExtra): + """Describe what assumptions are added, given existing assumptions""" + zerox = assume.zero.copy() + zerox.update(assumeExtra.zero) + zero = R.ideal(map(numerator, assume.zero)) + zeroextra = R.ideal(map(numerator, zerox)) + nonzero = get_nonzero_set(R, assume) + ret = set() + # Iterate over the extra zero expressions + for base in assumeExtra.zero: + if base not in zero: + add = [] + for (f, n) in numerator(base).factor(): + if f not in nonzero: + add += ["%s" % f] + if add: + ret.add((" * ".join(add)) + " = 0 [%s]" % assumeExtra.zero[base]) + # Iterate over the extra nonzero expressions + for nz in assumeExtra.nonzero: + nzr = zeroextra.reduce(numerator(nz)) + if nzr not in zeroextra: + for (f,n) in nzr.factor(): + if zeroextra.reduce(f) not in nonzero: + ret.add("%s != 0" % zeroextra.reduce(f)) + return ", ".join(x for x in ret) + + +def check_symbolic(R, assumeLaw, assumeAssert, assumeBranch, require): + """Check a set of zero and nonzero requirements, given a set of zero and nonzero assumptions""" + assume = assumeLaw + assumeAssert + assumeBranch + + if conflicts(R, assume): + # This formula does not apply + return None + + describe = describe_extra(R, assumeLaw + assumeBranch, assumeAssert) + + ok, msg = prove_zero(R, require.zero, assume) + if not ok: + return "FAIL, %s fails (assuming %s)" % (str(msg), describe) + + res, expl = prove_nonzero(R, require.nonzero, assume) + if not res: + return "FAIL, %s fails (assuming %s)" % (str(expl), describe) + + if describe != "": + return "OK (assuming %s)" % describe + else: + return "OK" + + +def concrete_verify(c): + for k in c.zero: + if k != 0: + return (False, c.zero[k]) + for k in c.nonzero: + if k == 0: + return (False, c.nonzero[k]) + return (True, None) diff --git a/src/secp256k1/sage/secp256k1.sage b/src/secp256k1/sage/secp256k1.sage new file mode 100644 index 0000000..a97e732 --- /dev/null +++ b/src/secp256k1/sage/secp256k1.sage @@ -0,0 +1,306 @@ +# Test libsecp256k1' group operation implementations using prover.sage + +import sys + +load("group_prover.sage") +load("weierstrass_prover.sage") + +def formula_secp256k1_gej_double_var(a): + """libsecp256k1's secp256k1_gej_double_var, used by various addition functions""" + rz = a.Z * a.Y + rz = rz * 2 + t1 = a.X^2 + t1 = t1 * 3 + t2 = t1^2 + t3 = a.Y^2 + t3 = t3 * 2 + t4 = t3^2 + t4 = t4 * 2 + t3 = t3 * a.X + rx = t3 + rx = rx * 4 + rx = -rx + rx = rx + t2 + t2 = -t2 + t3 = t3 * 6 + t3 = t3 + t2 + ry = t1 * t3 + t2 = -t4 + ry = ry + t2 + return jacobianpoint(rx, ry, rz) + +def formula_secp256k1_gej_add_var(branch, a, b): + """libsecp256k1's secp256k1_gej_add_var""" + if branch == 0: + return (constraints(), constraints(nonzero={a.Infinity : 'a_infinite'}), b) + if branch == 1: + return (constraints(), constraints(zero={a.Infinity : 'a_finite'}, nonzero={b.Infinity : 'b_infinite'}), a) + z22 = b.Z^2 + z12 = a.Z^2 + u1 = a.X * z22 + u2 = b.X * z12 + s1 = a.Y * z22 + s1 = s1 * b.Z + s2 = b.Y * z12 + s2 = s2 * a.Z + h = -u1 + h = h + u2 + i = -s1 + i = i + s2 + if branch == 2: + r = formula_secp256k1_gej_double_var(a) + return (constraints(), constraints(zero={h : 'h=0', i : 'i=0', a.Infinity : 'a_finite', b.Infinity : 'b_finite'}), r) + if branch == 3: + return (constraints(), constraints(zero={h : 'h=0', a.Infinity : 'a_finite', b.Infinity : 'b_finite'}, nonzero={i : 'i!=0'}), point_at_infinity()) + i2 = i^2 + h2 = h^2 + h3 = h2 * h + h = h * b.Z + rz = a.Z * h + t = u1 * h2 + rx = t + rx = rx * 2 + rx = rx + h3 + rx = -rx + rx = rx + i2 + ry = -rx + ry = ry + t + ry = ry * i + h3 = h3 * s1 + h3 = -h3 + ry = ry + h3 + return (constraints(), constraints(zero={a.Infinity : 'a_finite', b.Infinity : 'b_finite'}, nonzero={h : 'h!=0'}), jacobianpoint(rx, ry, rz)) + +def formula_secp256k1_gej_add_ge_var(branch, a, b): + """libsecp256k1's secp256k1_gej_add_ge_var, which assume bz==1""" + if branch == 0: + return (constraints(zero={b.Z - 1 : 'b.z=1'}), constraints(nonzero={a.Infinity : 'a_infinite'}), b) + if branch == 1: + return (constraints(zero={b.Z - 1 : 'b.z=1'}), constraints(zero={a.Infinity : 'a_finite'}, nonzero={b.Infinity : 'b_infinite'}), a) + z12 = a.Z^2 + u1 = a.X + u2 = b.X * z12 + s1 = a.Y + s2 = b.Y * z12 + s2 = s2 * a.Z + h = -u1 + h = h + u2 + i = -s1 + i = i + s2 + if (branch == 2): + r = formula_secp256k1_gej_double_var(a) + return (constraints(zero={b.Z - 1 : 'b.z=1'}), constraints(zero={a.Infinity : 'a_finite', b.Infinity : 'b_finite', h : 'h=0', i : 'i=0'}), r) + if (branch == 3): + return (constraints(zero={b.Z - 1 : 'b.z=1'}), constraints(zero={a.Infinity : 'a_finite', b.Infinity : 'b_finite', h : 'h=0'}, nonzero={i : 'i!=0'}), point_at_infinity()) + i2 = i^2 + h2 = h^2 + h3 = h * h2 + rz = a.Z * h + t = u1 * h2 + rx = t + rx = rx * 2 + rx = rx + h3 + rx = -rx + rx = rx + i2 + ry = -rx + ry = ry + t + ry = ry * i + h3 = h3 * s1 + h3 = -h3 + ry = ry + h3 + return (constraints(zero={b.Z - 1 : 'b.z=1'}), constraints(zero={a.Infinity : 'a_finite', b.Infinity : 'b_finite'}, nonzero={h : 'h!=0'}), jacobianpoint(rx, ry, rz)) + +def formula_secp256k1_gej_add_zinv_var(branch, a, b): + """libsecp256k1's secp256k1_gej_add_zinv_var""" + bzinv = b.Z^(-1) + if branch == 0: + return (constraints(), constraints(nonzero={b.Infinity : 'b_infinite'}), a) + if branch == 1: + bzinv2 = bzinv^2 + bzinv3 = bzinv2 * bzinv + rx = b.X * bzinv2 + ry = b.Y * bzinv3 + rz = 1 + return (constraints(), constraints(zero={b.Infinity : 'b_finite'}, nonzero={a.Infinity : 'a_infinite'}), jacobianpoint(rx, ry, rz)) + azz = a.Z * bzinv + z12 = azz^2 + u1 = a.X + u2 = b.X * z12 + s1 = a.Y + s2 = b.Y * z12 + s2 = s2 * azz + h = -u1 + h = h + u2 + i = -s1 + i = i + s2 + if branch == 2: + r = formula_secp256k1_gej_double_var(a) + return (constraints(), constraints(zero={a.Infinity : 'a_finite', b.Infinity : 'b_finite', h : 'h=0', i : 'i=0'}), r) + if branch == 3: + return (constraints(), constraints(zero={a.Infinity : 'a_finite', b.Infinity : 'b_finite', h : 'h=0'}, nonzero={i : 'i!=0'}), point_at_infinity()) + i2 = i^2 + h2 = h^2 + h3 = h * h2 + rz = a.Z + rz = rz * h + t = u1 * h2 + rx = t + rx = rx * 2 + rx = rx + h3 + rx = -rx + rx = rx + i2 + ry = -rx + ry = ry + t + ry = ry * i + h3 = h3 * s1 + h3 = -h3 + ry = ry + h3 + return (constraints(), constraints(zero={a.Infinity : 'a_finite', b.Infinity : 'b_finite'}, nonzero={h : 'h!=0'}), jacobianpoint(rx, ry, rz)) + +def formula_secp256k1_gej_add_ge(branch, a, b): + """libsecp256k1's secp256k1_gej_add_ge""" + zeroes = {} + nonzeroes = {} + a_infinity = False + if (branch & 4) != 0: + nonzeroes.update({a.Infinity : 'a_infinite'}) + a_infinity = True + else: + zeroes.update({a.Infinity : 'a_finite'}) + zz = a.Z^2 + u1 = a.X + u2 = b.X * zz + s1 = a.Y + s2 = b.Y * zz + s2 = s2 * a.Z + t = u1 + t = t + u2 + m = s1 + m = m + s2 + rr = t^2 + m_alt = -u2 + tt = u1 * m_alt + rr = rr + tt + degenerate = (branch & 3) == 3 + if (branch & 1) != 0: + zeroes.update({m : 'm_zero'}) + else: + nonzeroes.update({m : 'm_nonzero'}) + if (branch & 2) != 0: + zeroes.update({rr : 'rr_zero'}) + else: + nonzeroes.update({rr : 'rr_nonzero'}) + rr_alt = s1 + rr_alt = rr_alt * 2 + m_alt = m_alt + u1 + if not degenerate: + rr_alt = rr + m_alt = m + n = m_alt^2 + q = n * t + n = n^2 + if degenerate: + n = m + t = rr_alt^2 + rz = a.Z * m_alt + infinity = False + if (branch & 8) != 0: + if not a_infinity: + infinity = True + zeroes.update({rz : 'r.z=0'}) + else: + nonzeroes.update({rz : 'r.z!=0'}) + rz = rz * 2 + q = -q + t = t + q + rx = t + t = t * 2 + t = t + q + t = t * rr_alt + t = t + n + ry = -t + rx = rx * 4 + ry = ry * 4 + if a_infinity: + rx = b.X + ry = b.Y + rz = 1 + if infinity: + return (constraints(zero={b.Z - 1 : 'b.z=1', b.Infinity : 'b_finite'}), constraints(zero=zeroes, nonzero=nonzeroes), point_at_infinity()) + return (constraints(zero={b.Z - 1 : 'b.z=1', b.Infinity : 'b_finite'}), constraints(zero=zeroes, nonzero=nonzeroes), jacobianpoint(rx, ry, rz)) + +def formula_secp256k1_gej_add_ge_old(branch, a, b): + """libsecp256k1's old secp256k1_gej_add_ge, which fails when ay+by=0 but ax!=bx""" + a_infinity = (branch & 1) != 0 + zero = {} + nonzero = {} + if a_infinity: + nonzero.update({a.Infinity : 'a_infinite'}) + else: + zero.update({a.Infinity : 'a_finite'}) + zz = a.Z^2 + u1 = a.X + u2 = b.X * zz + s1 = a.Y + s2 = b.Y * zz + s2 = s2 * a.Z + z = a.Z + t = u1 + t = t + u2 + m = s1 + m = m + s2 + n = m^2 + q = n * t + n = n^2 + rr = t^2 + t = u1 * u2 + t = -t + rr = rr + t + t = rr^2 + rz = m * z + infinity = False + if (branch & 2) != 0: + if not a_infinity: + infinity = True + else: + return (constraints(zero={b.Z - 1 : 'b.z=1', b.Infinity : 'b_finite'}), constraints(nonzero={z : 'conflict_a'}, zero={z : 'conflict_b'}), point_at_infinity()) + zero.update({rz : 'r.z=0'}) + else: + nonzero.update({rz : 'r.z!=0'}) + rz = rz * (0 if a_infinity else 2) + rx = t + q = -q + rx = rx + q + q = q * 3 + t = t * 2 + t = t + q + t = t * rr + t = t + n + ry = -t + rx = rx * (0 if a_infinity else 4) + ry = ry * (0 if a_infinity else 4) + t = b.X + t = t * (1 if a_infinity else 0) + rx = rx + t + t = b.Y + t = t * (1 if a_infinity else 0) + ry = ry + t + t = (1 if a_infinity else 0) + rz = rz + t + if infinity: + return (constraints(zero={b.Z - 1 : 'b.z=1', b.Infinity : 'b_finite'}), constraints(zero=zero, nonzero=nonzero), point_at_infinity()) + return (constraints(zero={b.Z - 1 : 'b.z=1', b.Infinity : 'b_finite'}), constraints(zero=zero, nonzero=nonzero), jacobianpoint(rx, ry, rz)) + +if __name__ == "__main__": + check_symbolic_jacobian_weierstrass("secp256k1_gej_add_var", 0, 7, 5, formula_secp256k1_gej_add_var) + check_symbolic_jacobian_weierstrass("secp256k1_gej_add_ge_var", 0, 7, 5, formula_secp256k1_gej_add_ge_var) + check_symbolic_jacobian_weierstrass("secp256k1_gej_add_zinv_var", 0, 7, 5, formula_secp256k1_gej_add_zinv_var) + check_symbolic_jacobian_weierstrass("secp256k1_gej_add_ge", 0, 7, 16, formula_secp256k1_gej_add_ge) + check_symbolic_jacobian_weierstrass("secp256k1_gej_add_ge_old [should fail]", 0, 7, 4, formula_secp256k1_gej_add_ge_old) + + if len(sys.argv) >= 2 and sys.argv[1] == "--exhaustive": + check_exhaustive_jacobian_weierstrass("secp256k1_gej_add_var", 0, 7, 5, formula_secp256k1_gej_add_var, 43) + check_exhaustive_jacobian_weierstrass("secp256k1_gej_add_ge_var", 0, 7, 5, formula_secp256k1_gej_add_ge_var, 43) + check_exhaustive_jacobian_weierstrass("secp256k1_gej_add_zinv_var", 0, 7, 5, formula_secp256k1_gej_add_zinv_var, 43) + check_exhaustive_jacobian_weierstrass("secp256k1_gej_add_ge", 0, 7, 16, formula_secp256k1_gej_add_ge, 43) + check_exhaustive_jacobian_weierstrass("secp256k1_gej_add_ge_old [should fail]", 0, 7, 4, formula_secp256k1_gej_add_ge_old, 43) diff --git a/src/secp256k1/sage/weierstrass_prover.sage b/src/secp256k1/sage/weierstrass_prover.sage new file mode 100644 index 0000000..03ef2ec --- /dev/null +++ b/src/secp256k1/sage/weierstrass_prover.sage @@ -0,0 +1,264 @@ +# Prover implementation for Weierstrass curves of the form +# y^2 = x^3 + A * x + B, specifically with a = 0 and b = 7, with group laws +# operating on affine and Jacobian coordinates, including the point at infinity +# represented by a 4th variable in coordinates. + +load("group_prover.sage") + + +class affinepoint: + def __init__(self, x, y, infinity=0): + self.x = x + self.y = y + self.infinity = infinity + def __str__(self): + return "affinepoint(x=%s,y=%s,inf=%s)" % (self.x, self.y, self.infinity) + + +class jacobianpoint: + def __init__(self, x, y, z, infinity=0): + self.X = x + self.Y = y + self.Z = z + self.Infinity = infinity + def __str__(self): + return "jacobianpoint(X=%s,Y=%s,Z=%s,inf=%s)" % (self.X, self.Y, self.Z, self.Infinity) + + +def point_at_infinity(): + return jacobianpoint(1, 1, 1, 1) + + +def negate(p): + if p.__class__ == affinepoint: + return affinepoint(p.x, -p.y) + if p.__class__ == jacobianpoint: + return jacobianpoint(p.X, -p.Y, p.Z) + assert(False) + + +def on_weierstrass_curve(A, B, p): + """Return a set of zero-expressions for an affine point to be on the curve""" + return constraints(zero={p.x^3 + A*p.x + B - p.y^2: 'on_curve'}) + + +def tangential_to_weierstrass_curve(A, B, p12, p3): + """Return a set of zero-expressions for ((x12,y12),(x3,y3)) to be a line that is tangential to the curve at (x12,y12)""" + return constraints(zero={ + (p12.y - p3.y) * (p12.y * 2) - (p12.x^2 * 3 + A) * (p12.x - p3.x): 'tangential_to_curve' + }) + + +def colinear(p1, p2, p3): + """Return a set of zero-expressions for ((x1,y1),(x2,y2),(x3,y3)) to be collinear""" + return constraints(zero={ + (p1.y - p2.y) * (p1.x - p3.x) - (p1.y - p3.y) * (p1.x - p2.x): 'colinear_1', + (p2.y - p3.y) * (p2.x - p1.x) - (p2.y - p1.y) * (p2.x - p3.x): 'colinear_2', + (p3.y - p1.y) * (p3.x - p2.x) - (p3.y - p2.y) * (p3.x - p1.x): 'colinear_3' + }) + + +def good_affine_point(p): + return constraints(nonzero={p.x : 'nonzero_x', p.y : 'nonzero_y'}) + + +def good_jacobian_point(p): + return constraints(nonzero={p.X : 'nonzero_X', p.Y : 'nonzero_Y', p.Z^6 : 'nonzero_Z'}) + + +def good_point(p): + return constraints(nonzero={p.Z^6 : 'nonzero_X'}) + + +def finite(p, *affine_fns): + con = good_point(p) + constraints(zero={p.Infinity : 'finite_point'}) + if p.Z != 0: + return con + reduce(lambda a, b: a + b, (f(affinepoint(p.X / p.Z^2, p.Y / p.Z^3)) for f in affine_fns), con) + else: + return con + +def infinite(p): + return constraints(nonzero={p.Infinity : 'infinite_point'}) + + +def law_jacobian_weierstrass_add(A, B, pa, pb, pA, pB, pC): + """Check whether the passed set of coordinates is a valid Jacobian add, given assumptions""" + assumeLaw = (good_affine_point(pa) + + good_affine_point(pb) + + good_jacobian_point(pA) + + good_jacobian_point(pB) + + on_weierstrass_curve(A, B, pa) + + on_weierstrass_curve(A, B, pb) + + finite(pA) + + finite(pB) + + constraints(nonzero={pa.x - pb.x : 'different_x'})) + require = (finite(pC, lambda pc: on_weierstrass_curve(A, B, pc) + + colinear(pa, pb, negate(pc)))) + return (assumeLaw, require) + + +def law_jacobian_weierstrass_double(A, B, pa, pb, pA, pB, pC): + """Check whether the passed set of coordinates is a valid Jacobian doubling, given assumptions""" + assumeLaw = (good_affine_point(pa) + + good_affine_point(pb) + + good_jacobian_point(pA) + + good_jacobian_point(pB) + + on_weierstrass_curve(A, B, pa) + + on_weierstrass_curve(A, B, pb) + + finite(pA) + + finite(pB) + + constraints(zero={pa.x - pb.x : 'equal_x', pa.y - pb.y : 'equal_y'})) + require = (finite(pC, lambda pc: on_weierstrass_curve(A, B, pc) + + tangential_to_weierstrass_curve(A, B, pa, negate(pc)))) + return (assumeLaw, require) + + +def law_jacobian_weierstrass_add_opposites(A, B, pa, pb, pA, pB, pC): + assumeLaw = (good_affine_point(pa) + + good_affine_point(pb) + + good_jacobian_point(pA) + + good_jacobian_point(pB) + + on_weierstrass_curve(A, B, pa) + + on_weierstrass_curve(A, B, pb) + + finite(pA) + + finite(pB) + + constraints(zero={pa.x - pb.x : 'equal_x', pa.y + pb.y : 'opposite_y'})) + require = infinite(pC) + return (assumeLaw, require) + + +def law_jacobian_weierstrass_add_infinite_a(A, B, pa, pb, pA, pB, pC): + assumeLaw = (good_affine_point(pa) + + good_affine_point(pb) + + good_jacobian_point(pA) + + good_jacobian_point(pB) + + on_weierstrass_curve(A, B, pb) + + infinite(pA) + + finite(pB)) + require = finite(pC, lambda pc: constraints(zero={pc.x - pb.x : 'c.x=b.x', pc.y - pb.y : 'c.y=b.y'})) + return (assumeLaw, require) + + +def law_jacobian_weierstrass_add_infinite_b(A, B, pa, pb, pA, pB, pC): + assumeLaw = (good_affine_point(pa) + + good_affine_point(pb) + + good_jacobian_point(pA) + + good_jacobian_point(pB) + + on_weierstrass_curve(A, B, pa) + + infinite(pB) + + finite(pA)) + require = finite(pC, lambda pc: constraints(zero={pc.x - pa.x : 'c.x=a.x', pc.y - pa.y : 'c.y=a.y'})) + return (assumeLaw, require) + + +def law_jacobian_weierstrass_add_infinite_ab(A, B, pa, pb, pA, pB, pC): + assumeLaw = (good_affine_point(pa) + + good_affine_point(pb) + + good_jacobian_point(pA) + + good_jacobian_point(pB) + + infinite(pA) + + infinite(pB)) + require = infinite(pC) + return (assumeLaw, require) + + +laws_jacobian_weierstrass = { + 'add': law_jacobian_weierstrass_add, + 'double': law_jacobian_weierstrass_double, + 'add_opposite': law_jacobian_weierstrass_add_opposites, + 'add_infinite_a': law_jacobian_weierstrass_add_infinite_a, + 'add_infinite_b': law_jacobian_weierstrass_add_infinite_b, + 'add_infinite_ab': law_jacobian_weierstrass_add_infinite_ab +} + + +def check_exhaustive_jacobian_weierstrass(name, A, B, branches, formula, p): + """Verify an implementation of addition of Jacobian points on a Weierstrass curve, by executing and validating the result for every possible addition in a prime field""" + F = Integers(p) + print "Formula %s on Z%i:" % (name, p) + points = [] + for x in xrange(0, p): + for y in xrange(0, p): + point = affinepoint(F(x), F(y)) + r, e = concrete_verify(on_weierstrass_curve(A, B, point)) + if r: + points.append(point) + + for za in xrange(1, p): + for zb in xrange(1, p): + for pa in points: + for pb in points: + for ia in xrange(2): + for ib in xrange(2): + pA = jacobianpoint(pa.x * F(za)^2, pa.y * F(za)^3, F(za), ia) + pB = jacobianpoint(pb.x * F(zb)^2, pb.y * F(zb)^3, F(zb), ib) + for branch in xrange(0, branches): + assumeAssert, assumeBranch, pC = formula(branch, pA, pB) + pC.X = F(pC.X) + pC.Y = F(pC.Y) + pC.Z = F(pC.Z) + pC.Infinity = F(pC.Infinity) + r, e = concrete_verify(assumeAssert + assumeBranch) + if r: + match = False + for key in laws_jacobian_weierstrass: + assumeLaw, require = laws_jacobian_weierstrass[key](A, B, pa, pb, pA, pB, pC) + r, e = concrete_verify(assumeLaw) + if r: + if match: + print " multiple branches for (%s,%s,%s,%s) + (%s,%s,%s,%s)" % (pA.X, pA.Y, pA.Z, pA.Infinity, pB.X, pB.Y, pB.Z, pB.Infinity) + else: + match = True + r, e = concrete_verify(require) + if not r: + print " failure in branch %i for (%s,%s,%s,%s) + (%s,%s,%s,%s) = (%s,%s,%s,%s): %s" % (branch, pA.X, pA.Y, pA.Z, pA.Infinity, pB.X, pB.Y, pB.Z, pB.Infinity, pC.X, pC.Y, pC.Z, pC.Infinity, e) + print + + +def check_symbolic_function(R, assumeAssert, assumeBranch, f, A, B, pa, pb, pA, pB, pC): + assumeLaw, require = f(A, B, pa, pb, pA, pB, pC) + return check_symbolic(R, assumeLaw, assumeAssert, assumeBranch, require) + +def check_symbolic_jacobian_weierstrass(name, A, B, branches, formula): + """Verify an implementation of addition of Jacobian points on a Weierstrass curve symbolically""" + R. = PolynomialRing(QQ,8,order='invlex') + lift = lambda x: fastfrac(R,x) + ax = lift(ax) + ay = lift(ay) + Az = lift(Az) + bx = lift(bx) + by = lift(by) + Bz = lift(Bz) + Ai = lift(Ai) + Bi = lift(Bi) + + pa = affinepoint(ax, ay, Ai) + pb = affinepoint(bx, by, Bi) + pA = jacobianpoint(ax * Az^2, ay * Az^3, Az, Ai) + pB = jacobianpoint(bx * Bz^2, by * Bz^3, Bz, Bi) + + res = {} + + for key in laws_jacobian_weierstrass: + res[key] = [] + + print ("Formula " + name + ":") + count = 0 + for branch in xrange(branches): + assumeFormula, assumeBranch, pC = formula(branch, pA, pB) + pC.X = lift(pC.X) + pC.Y = lift(pC.Y) + pC.Z = lift(pC.Z) + pC.Infinity = lift(pC.Infinity) + + for key in laws_jacobian_weierstrass: + res[key].append((check_symbolic_function(R, assumeFormula, assumeBranch, laws_jacobian_weierstrass[key], A, B, pa, pb, pA, pB, pC), branch)) + + for key in res: + print " %s:" % key + val = res[key] + for x in val: + if x[0] is not None: + print " branch %i: %s" % (x[1], x[0]) + + print diff --git a/src/secp256k1/src/basic-config.h b/src/secp256k1/src/basic-config.h new file mode 100644 index 0000000..c4c16eb --- /dev/null +++ b/src/secp256k1/src/basic-config.h @@ -0,0 +1,32 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_BASIC_CONFIG_ +#define _SECP256K1_BASIC_CONFIG_ + +#ifdef USE_BASIC_CONFIG + +#undef USE_ASM_X86_64 +#undef USE_ENDOMORPHISM +#undef USE_FIELD_10X26 +#undef USE_FIELD_5X52 +#undef USE_FIELD_INV_BUILTIN +#undef USE_FIELD_INV_NUM +#undef USE_NUM_GMP +#undef USE_NUM_NONE +#undef USE_SCALAR_4X64 +#undef USE_SCALAR_8X32 +#undef USE_SCALAR_INV_BUILTIN +#undef USE_SCALAR_INV_NUM + +#define USE_NUM_NONE 1 +#define USE_FIELD_INV_BUILTIN 1 +#define USE_SCALAR_INV_BUILTIN 1 +#define USE_FIELD_10X26 1 +#define USE_SCALAR_8X32 1 + +#endif // USE_BASIC_CONFIG +#endif // _SECP256K1_BASIC_CONFIG_ diff --git a/src/secp256k1/src/bench.h b/src/secp256k1/src/bench.h new file mode 100644 index 0000000..3a71b4a --- /dev/null +++ b/src/secp256k1/src/bench.h @@ -0,0 +1,66 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_BENCH_H_ +#define _SECP256K1_BENCH_H_ + +#include +#include +#include "sys/time.h" + +static double gettimedouble(void) { + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_usec * 0.000001 + tv.tv_sec; +} + +void print_number(double x) { + double y = x; + int c = 0; + if (y < 0.0) { + y = -y; + } + while (y < 100.0) { + y *= 10.0; + c++; + } + printf("%.*f", c, x); +} + +void run_benchmark(char *name, void (*benchmark)(void*), void (*setup)(void*), void (*teardown)(void*), void* data, int count, int iter) { + int i; + double min = HUGE_VAL; + double sum = 0.0; + double max = 0.0; + for (i = 0; i < count; i++) { + double begin, total; + if (setup != NULL) { + setup(data); + } + begin = gettimedouble(); + benchmark(data); + total = gettimedouble() - begin; + if (teardown != NULL) { + teardown(data); + } + if (total < min) { + min = total; + } + if (total > max) { + max = total; + } + sum += total; + } + printf("%s: min ", name); + print_number(min * 1000000.0 / iter); + printf("us / avg "); + print_number((sum / count) * 1000000.0 / iter); + printf("us / max "); + print_number(max * 1000000.0 / iter); + printf("us\n"); +} + +#endif diff --git a/src/secp256k1/src/bench_ecdh.c b/src/secp256k1/src/bench_ecdh.c new file mode 100644 index 0000000..5a7c637 --- /dev/null +++ b/src/secp256k1/src/bench_ecdh.c @@ -0,0 +1,53 @@ +/********************************************************************** + * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#include + +#include "include/secp256k1.h" +#include "include/secp256k1_ecdh.h" +#include "util.h" +#include "bench.h" + +typedef struct { + secp256k1_context *ctx; + secp256k1_pubkey point; + unsigned char scalar[32]; +} bench_ecdh_t; + +static void bench_ecdh_setup(void* arg) { + int i; + bench_ecdh_t *data = (bench_ecdh_t*)arg; + const unsigned char point[] = { + 0x03, + 0x54, 0x94, 0xc1, 0x5d, 0x32, 0x09, 0x97, 0x06, + 0xc2, 0x39, 0x5f, 0x94, 0x34, 0x87, 0x45, 0xfd, + 0x75, 0x7c, 0xe3, 0x0e, 0x4e, 0x8c, 0x90, 0xfb, + 0xa2, 0xba, 0xd1, 0x84, 0xf8, 0x83, 0xc6, 0x9f + }; + + data->ctx = secp256k1_context_create(0); + for (i = 0; i < 32; i++) { + data->scalar[i] = i + 1; + } + CHECK(secp256k1_ec_pubkey_parse(data->ctx, &data->point, point, sizeof(point)) == 1); +} + +static void bench_ecdh(void* arg) { + int i; + unsigned char res[32]; + bench_ecdh_t *data = (bench_ecdh_t*)arg; + + for (i = 0; i < 20000; i++) { + CHECK(secp256k1_ecdh(data->ctx, res, &data->point, data->scalar) == 1); + } +} + +int main(void) { + bench_ecdh_t data; + + run_benchmark("ecdh", bench_ecdh, bench_ecdh_setup, NULL, &data, 10, 20000); + return 0; +} diff --git a/src/secp256k1/src/bench_internal.c b/src/secp256k1/src/bench_internal.c new file mode 100644 index 0000000..7809f5f --- /dev/null +++ b/src/secp256k1/src/bench_internal.c @@ -0,0 +1,354 @@ +/********************************************************************** + * Copyright (c) 2014-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ +#include + +#include "include/secp256k1.h" + +#include "util.h" +#include "hash_impl.h" +#include "num_impl.h" +#include "field_impl.h" +#include "group_impl.h" +#include "scalar_impl.h" +#include "ecmult_const_impl.h" +#include "ecmult_impl.h" +#include "bench.h" +#include "secp256k1.c" + +typedef struct { + secp256k1_scalar scalar_x, scalar_y; + secp256k1_fe fe_x, fe_y; + secp256k1_ge ge_x, ge_y; + secp256k1_gej gej_x, gej_y; + unsigned char data[64]; + int wnaf[256]; +} bench_inv_t; + +void bench_setup(void* arg) { + bench_inv_t *data = (bench_inv_t*)arg; + + static const unsigned char init_x[32] = { + 0x02, 0x03, 0x05, 0x07, 0x0b, 0x0d, 0x11, 0x13, + 0x17, 0x1d, 0x1f, 0x25, 0x29, 0x2b, 0x2f, 0x35, + 0x3b, 0x3d, 0x43, 0x47, 0x49, 0x4f, 0x53, 0x59, + 0x61, 0x65, 0x67, 0x6b, 0x6d, 0x71, 0x7f, 0x83 + }; + + static const unsigned char init_y[32] = { + 0x82, 0x83, 0x85, 0x87, 0x8b, 0x8d, 0x81, 0x83, + 0x97, 0xad, 0xaf, 0xb5, 0xb9, 0xbb, 0xbf, 0xc5, + 0xdb, 0xdd, 0xe3, 0xe7, 0xe9, 0xef, 0xf3, 0xf9, + 0x11, 0x15, 0x17, 0x1b, 0x1d, 0xb1, 0xbf, 0xd3 + }; + + secp256k1_scalar_set_b32(&data->scalar_x, init_x, NULL); + secp256k1_scalar_set_b32(&data->scalar_y, init_y, NULL); + secp256k1_fe_set_b32(&data->fe_x, init_x); + secp256k1_fe_set_b32(&data->fe_y, init_y); + CHECK(secp256k1_ge_set_xo_var(&data->ge_x, &data->fe_x, 0)); + CHECK(secp256k1_ge_set_xo_var(&data->ge_y, &data->fe_y, 1)); + secp256k1_gej_set_ge(&data->gej_x, &data->ge_x); + secp256k1_gej_set_ge(&data->gej_y, &data->ge_y); + memcpy(data->data, init_x, 32); + memcpy(data->data + 32, init_y, 32); +} + +void bench_scalar_add(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 2000000; i++) { + secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y); + } +} + +void bench_scalar_negate(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 2000000; i++) { + secp256k1_scalar_negate(&data->scalar_x, &data->scalar_x); + } +} + +void bench_scalar_sqr(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 200000; i++) { + secp256k1_scalar_sqr(&data->scalar_x, &data->scalar_x); + } +} + +void bench_scalar_mul(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 200000; i++) { + secp256k1_scalar_mul(&data->scalar_x, &data->scalar_x, &data->scalar_y); + } +} + +#ifdef USE_ENDOMORPHISM +void bench_scalar_split(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 20000; i++) { + secp256k1_scalar l, r; + secp256k1_scalar_split_lambda(&l, &r, &data->scalar_x); + secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y); + } +} +#endif + +void bench_scalar_inverse(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 2000; i++) { + secp256k1_scalar_inverse(&data->scalar_x, &data->scalar_x); + secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y); + } +} + +void bench_scalar_inverse_var(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 2000; i++) { + secp256k1_scalar_inverse_var(&data->scalar_x, &data->scalar_x); + secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y); + } +} + +void bench_field_normalize(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 2000000; i++) { + secp256k1_fe_normalize(&data->fe_x); + } +} + +void bench_field_normalize_weak(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 2000000; i++) { + secp256k1_fe_normalize_weak(&data->fe_x); + } +} + +void bench_field_mul(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 200000; i++) { + secp256k1_fe_mul(&data->fe_x, &data->fe_x, &data->fe_y); + } +} + +void bench_field_sqr(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 200000; i++) { + secp256k1_fe_sqr(&data->fe_x, &data->fe_x); + } +} + +void bench_field_inverse(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 20000; i++) { + secp256k1_fe_inv(&data->fe_x, &data->fe_x); + secp256k1_fe_add(&data->fe_x, &data->fe_y); + } +} + +void bench_field_inverse_var(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 20000; i++) { + secp256k1_fe_inv_var(&data->fe_x, &data->fe_x); + secp256k1_fe_add(&data->fe_x, &data->fe_y); + } +} + +void bench_field_sqrt_var(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 20000; i++) { + secp256k1_fe_sqrt_var(&data->fe_x, &data->fe_x); + secp256k1_fe_add(&data->fe_x, &data->fe_y); + } +} + +void bench_group_double_var(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 200000; i++) { + secp256k1_gej_double_var(&data->gej_x, &data->gej_x, NULL); + } +} + +void bench_group_add_var(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 200000; i++) { + secp256k1_gej_add_var(&data->gej_x, &data->gej_x, &data->gej_y, NULL); + } +} + +void bench_group_add_affine(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 200000; i++) { + secp256k1_gej_add_ge(&data->gej_x, &data->gej_x, &data->ge_y); + } +} + +void bench_group_add_affine_var(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 200000; i++) { + secp256k1_gej_add_ge_var(&data->gej_x, &data->gej_x, &data->ge_y, NULL); + } +} + +void bench_ecmult_wnaf(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 20000; i++) { + secp256k1_ecmult_wnaf(data->wnaf, 256, &data->scalar_x, WINDOW_A); + secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y); + } +} + +void bench_wnaf_const(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + + for (i = 0; i < 20000; i++) { + secp256k1_wnaf_const(data->wnaf, data->scalar_x, WINDOW_A); + secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y); + } +} + + +void bench_sha256(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + secp256k1_sha256_t sha; + + for (i = 0; i < 20000; i++) { + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, data->data, 32); + secp256k1_sha256_finalize(&sha, data->data); + } +} + +void bench_hmac_sha256(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + secp256k1_hmac_sha256_t hmac; + + for (i = 0; i < 20000; i++) { + secp256k1_hmac_sha256_initialize(&hmac, data->data, 32); + secp256k1_hmac_sha256_write(&hmac, data->data, 32); + secp256k1_hmac_sha256_finalize(&hmac, data->data); + } +} + +void bench_rfc6979_hmac_sha256(void* arg) { + int i; + bench_inv_t *data = (bench_inv_t*)arg; + secp256k1_rfc6979_hmac_sha256_t rng; + + for (i = 0; i < 20000; i++) { + secp256k1_rfc6979_hmac_sha256_initialize(&rng, data->data, 64); + secp256k1_rfc6979_hmac_sha256_generate(&rng, data->data, 32); + } +} + +void bench_context_verify(void* arg) { + int i; + (void)arg; + for (i = 0; i < 20; i++) { + secp256k1_context_destroy(secp256k1_context_create(SECP256K1_CONTEXT_VERIFY)); + } +} + +void bench_context_sign(void* arg) { + int i; + (void)arg; + for (i = 0; i < 200; i++) { + secp256k1_context_destroy(secp256k1_context_create(SECP256K1_CONTEXT_SIGN)); + } +} + + +int have_flag(int argc, char** argv, char *flag) { + char** argm = argv + argc; + argv++; + if (argv == argm) { + return 1; + } + while (argv != NULL && argv != argm) { + if (strcmp(*argv, flag) == 0) { + return 1; + } + argv++; + } + return 0; +} + +int main(int argc, char **argv) { + bench_inv_t data; + if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "add")) run_benchmark("scalar_add", bench_scalar_add, bench_setup, NULL, &data, 10, 2000000); + if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "negate")) run_benchmark("scalar_negate", bench_scalar_negate, bench_setup, NULL, &data, 10, 2000000); + if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "sqr")) run_benchmark("scalar_sqr", bench_scalar_sqr, bench_setup, NULL, &data, 10, 200000); + if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "mul")) run_benchmark("scalar_mul", bench_scalar_mul, bench_setup, NULL, &data, 10, 200000); +#ifdef USE_ENDOMORPHISM + if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "split")) run_benchmark("scalar_split", bench_scalar_split, bench_setup, NULL, &data, 10, 20000); +#endif + if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "inverse")) run_benchmark("scalar_inverse", bench_scalar_inverse, bench_setup, NULL, &data, 10, 2000); + if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "inverse")) run_benchmark("scalar_inverse_var", bench_scalar_inverse_var, bench_setup, NULL, &data, 10, 2000); + + if (have_flag(argc, argv, "field") || have_flag(argc, argv, "normalize")) run_benchmark("field_normalize", bench_field_normalize, bench_setup, NULL, &data, 10, 2000000); + if (have_flag(argc, argv, "field") || have_flag(argc, argv, "normalize")) run_benchmark("field_normalize_weak", bench_field_normalize_weak, bench_setup, NULL, &data, 10, 2000000); + if (have_flag(argc, argv, "field") || have_flag(argc, argv, "sqr")) run_benchmark("field_sqr", bench_field_sqr, bench_setup, NULL, &data, 10, 200000); + if (have_flag(argc, argv, "field") || have_flag(argc, argv, "mul")) run_benchmark("field_mul", bench_field_mul, bench_setup, NULL, &data, 10, 200000); + if (have_flag(argc, argv, "field") || have_flag(argc, argv, "inverse")) run_benchmark("field_inverse", bench_field_inverse, bench_setup, NULL, &data, 10, 20000); + if (have_flag(argc, argv, "field") || have_flag(argc, argv, "inverse")) run_benchmark("field_inverse_var", bench_field_inverse_var, bench_setup, NULL, &data, 10, 20000); + if (have_flag(argc, argv, "field") || have_flag(argc, argv, "sqrt")) run_benchmark("field_sqrt_var", bench_field_sqrt_var, bench_setup, NULL, &data, 10, 20000); + + if (have_flag(argc, argv, "group") || have_flag(argc, argv, "double")) run_benchmark("group_double_var", bench_group_double_var, bench_setup, NULL, &data, 10, 200000); + if (have_flag(argc, argv, "group") || have_flag(argc, argv, "add")) run_benchmark("group_add_var", bench_group_add_var, bench_setup, NULL, &data, 10, 200000); + if (have_flag(argc, argv, "group") || have_flag(argc, argv, "add")) run_benchmark("group_add_affine", bench_group_add_affine, bench_setup, NULL, &data, 10, 200000); + if (have_flag(argc, argv, "group") || have_flag(argc, argv, "add")) run_benchmark("group_add_affine_var", bench_group_add_affine_var, bench_setup, NULL, &data, 10, 200000); + + if (have_flag(argc, argv, "ecmult") || have_flag(argc, argv, "wnaf")) run_benchmark("wnaf_const", bench_wnaf_const, bench_setup, NULL, &data, 10, 20000); + if (have_flag(argc, argv, "ecmult") || have_flag(argc, argv, "wnaf")) run_benchmark("ecmult_wnaf", bench_ecmult_wnaf, bench_setup, NULL, &data, 10, 20000); + + if (have_flag(argc, argv, "hash") || have_flag(argc, argv, "sha256")) run_benchmark("hash_sha256", bench_sha256, bench_setup, NULL, &data, 10, 20000); + if (have_flag(argc, argv, "hash") || have_flag(argc, argv, "hmac")) run_benchmark("hash_hmac_sha256", bench_hmac_sha256, bench_setup, NULL, &data, 10, 20000); + if (have_flag(argc, argv, "hash") || have_flag(argc, argv, "rng6979")) run_benchmark("hash_rfc6979_hmac_sha256", bench_rfc6979_hmac_sha256, bench_setup, NULL, &data, 10, 20000); + + if (have_flag(argc, argv, "context") || have_flag(argc, argv, "verify")) run_benchmark("context_verify", bench_context_verify, bench_setup, NULL, &data, 10, 20); + if (have_flag(argc, argv, "context") || have_flag(argc, argv, "sign")) run_benchmark("context_sign", bench_context_sign, bench_setup, NULL, &data, 10, 200); + + return 0; +} diff --git a/src/secp256k1/src/bench_recover.c b/src/secp256k1/src/bench_recover.c new file mode 100644 index 0000000..6489378 --- /dev/null +++ b/src/secp256k1/src/bench_recover.c @@ -0,0 +1,60 @@ +/********************************************************************** + * Copyright (c) 2014-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#include "include/secp256k1.h" +#include "include/secp256k1_recovery.h" +#include "util.h" +#include "bench.h" + +typedef struct { + secp256k1_context *ctx; + unsigned char msg[32]; + unsigned char sig[64]; +} bench_recover_t; + +void bench_recover(void* arg) { + int i; + bench_recover_t *data = (bench_recover_t*)arg; + secp256k1_pubkey pubkey; + unsigned char pubkeyc[33]; + + for (i = 0; i < 20000; i++) { + int j; + size_t pubkeylen = 33; + secp256k1_ecdsa_recoverable_signature sig; + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(data->ctx, &sig, data->sig, i % 2)); + CHECK(secp256k1_ecdsa_recover(data->ctx, &pubkey, &sig, data->msg)); + CHECK(secp256k1_ec_pubkey_serialize(data->ctx, pubkeyc, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED)); + for (j = 0; j < 32; j++) { + data->sig[j + 32] = data->msg[j]; /* Move former message to S. */ + data->msg[j] = data->sig[j]; /* Move former R to message. */ + data->sig[j] = pubkeyc[j + 1]; /* Move recovered pubkey X coordinate to R (which must be a valid X coordinate). */ + } + } +} + +void bench_recover_setup(void* arg) { + int i; + bench_recover_t *data = (bench_recover_t*)arg; + + for (i = 0; i < 32; i++) { + data->msg[i] = 1 + i; + } + for (i = 0; i < 64; i++) { + data->sig[i] = 65 + i; + } +} + +int main(void) { + bench_recover_t data; + + data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY); + + run_benchmark("ecdsa_recover", bench_recover, bench_recover_setup, NULL, &data, 10, 20000); + + secp256k1_context_destroy(data.ctx); + return 0; +} diff --git a/src/secp256k1/src/bench_schnorr_verify.c b/src/secp256k1/src/bench_schnorr_verify.c new file mode 100644 index 0000000..5f137dd --- /dev/null +++ b/src/secp256k1/src/bench_schnorr_verify.c @@ -0,0 +1,73 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#include +#include + +#include "include/secp256k1.h" +#include "include/secp256k1_schnorr.h" +#include "util.h" +#include "bench.h" + +typedef struct { + unsigned char key[32]; + unsigned char sig[64]; + unsigned char pubkey[33]; + size_t pubkeylen; +} benchmark_schnorr_sig_t; + +typedef struct { + secp256k1_context *ctx; + unsigned char msg[32]; + benchmark_schnorr_sig_t sigs[64]; + int numsigs; +} benchmark_schnorr_verify_t; + +static void benchmark_schnorr_init(void* arg) { + int i, k; + benchmark_schnorr_verify_t* data = (benchmark_schnorr_verify_t*)arg; + + for (i = 0; i < 32; i++) { + data->msg[i] = 1 + i; + } + for (k = 0; k < data->numsigs; k++) { + secp256k1_pubkey pubkey; + for (i = 0; i < 32; i++) { + data->sigs[k].key[i] = 33 + i + k; + } + secp256k1_schnorr_sign(data->ctx, data->sigs[k].sig, data->msg, data->sigs[k].key, NULL, NULL); + data->sigs[k].pubkeylen = 33; + CHECK(secp256k1_ec_pubkey_create(data->ctx, &pubkey, data->sigs[k].key)); + CHECK(secp256k1_ec_pubkey_serialize(data->ctx, data->sigs[k].pubkey, &data->sigs[k].pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED)); + } +} + +static void benchmark_schnorr_verify(void* arg) { + int i; + benchmark_schnorr_verify_t* data = (benchmark_schnorr_verify_t*)arg; + + for (i = 0; i < 20000 / data->numsigs; i++) { + secp256k1_pubkey pubkey; + data->sigs[0].sig[(i >> 8) % 64] ^= (i & 0xFF); + CHECK(secp256k1_ec_pubkey_parse(data->ctx, &pubkey, data->sigs[0].pubkey, data->sigs[0].pubkeylen)); + CHECK(secp256k1_schnorr_verify(data->ctx, data->sigs[0].sig, data->msg, &pubkey) == ((i & 0xFF) == 0)); + data->sigs[0].sig[(i >> 8) % 64] ^= (i & 0xFF); + } +} + + + +int main(void) { + benchmark_schnorr_verify_t data; + + data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + + data.numsigs = 1; + run_benchmark("schnorr_verify", benchmark_schnorr_verify, benchmark_schnorr_init, NULL, &data, 10, 20000); + + secp256k1_context_destroy(data.ctx); + return 0; +} diff --git a/src/secp256k1/src/bench_sign.c b/src/secp256k1/src/bench_sign.c new file mode 100644 index 0000000..ed7224d --- /dev/null +++ b/src/secp256k1/src/bench_sign.c @@ -0,0 +1,56 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#include "include/secp256k1.h" +#include "util.h" +#include "bench.h" + +typedef struct { + secp256k1_context* ctx; + unsigned char msg[32]; + unsigned char key[32]; +} bench_sign_t; + +static void bench_sign_setup(void* arg) { + int i; + bench_sign_t *data = (bench_sign_t*)arg; + + for (i = 0; i < 32; i++) { + data->msg[i] = i + 1; + } + for (i = 0; i < 32; i++) { + data->key[i] = i + 65; + } +} + +static void bench_sign(void* arg) { + int i; + bench_sign_t *data = (bench_sign_t*)arg; + + unsigned char sig[74]; + for (i = 0; i < 20000; i++) { + size_t siglen = 74; + int j; + secp256k1_ecdsa_signature signature; + CHECK(secp256k1_ecdsa_sign(data->ctx, &signature, data->msg, data->key, NULL, NULL)); + CHECK(secp256k1_ecdsa_signature_serialize_der(data->ctx, sig, &siglen, &signature)); + for (j = 0; j < 32; j++) { + data->msg[j] = sig[j]; + data->key[j] = sig[j + 32]; + } + } +} + +int main(void) { + bench_sign_t data; + + data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); + + run_benchmark("ecdsa_sign", bench_sign, bench_sign_setup, NULL, &data, 10, 20000); + + secp256k1_context_destroy(data.ctx); + return 0; +} diff --git a/src/secp256k1/src/bench_verify.c b/src/secp256k1/src/bench_verify.c new file mode 100644 index 0000000..418defa --- /dev/null +++ b/src/secp256k1/src/bench_verify.c @@ -0,0 +1,112 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#include +#include + +#include "include/secp256k1.h" +#include "util.h" +#include "bench.h" + +#ifdef ENABLE_OPENSSL_TESTS +#include +#include +#include +#endif + +typedef struct { + secp256k1_context *ctx; + unsigned char msg[32]; + unsigned char key[32]; + unsigned char sig[72]; + size_t siglen; + unsigned char pubkey[33]; + size_t pubkeylen; +#ifdef ENABLE_OPENSSL_TESTS + EC_GROUP* ec_group; +#endif +} benchmark_verify_t; + +static void benchmark_verify(void* arg) { + int i; + benchmark_verify_t* data = (benchmark_verify_t*)arg; + + for (i = 0; i < 20000; i++) { + secp256k1_pubkey pubkey; + secp256k1_ecdsa_signature sig; + data->sig[data->siglen - 1] ^= (i & 0xFF); + data->sig[data->siglen - 2] ^= ((i >> 8) & 0xFF); + data->sig[data->siglen - 3] ^= ((i >> 16) & 0xFF); + CHECK(secp256k1_ec_pubkey_parse(data->ctx, &pubkey, data->pubkey, data->pubkeylen) == 1); + CHECK(secp256k1_ecdsa_signature_parse_der(data->ctx, &sig, data->sig, data->siglen) == 1); + CHECK(secp256k1_ecdsa_verify(data->ctx, &sig, data->msg, &pubkey) == (i == 0)); + data->sig[data->siglen - 1] ^= (i & 0xFF); + data->sig[data->siglen - 2] ^= ((i >> 8) & 0xFF); + data->sig[data->siglen - 3] ^= ((i >> 16) & 0xFF); + } +} + +#ifdef ENABLE_OPENSSL_TESTS +static void benchmark_verify_openssl(void* arg) { + int i; + benchmark_verify_t* data = (benchmark_verify_t*)arg; + + for (i = 0; i < 20000; i++) { + data->sig[data->siglen - 1] ^= (i & 0xFF); + data->sig[data->siglen - 2] ^= ((i >> 8) & 0xFF); + data->sig[data->siglen - 3] ^= ((i >> 16) & 0xFF); + { + EC_KEY *pkey = EC_KEY_new(); + const unsigned char *pubkey = &data->pubkey[0]; + int result; + + CHECK(pkey != NULL); + result = EC_KEY_set_group(pkey, data->ec_group); + CHECK(result); + result = (o2i_ECPublicKey(&pkey, &pubkey, data->pubkeylen)) != NULL; + CHECK(result); + result = ECDSA_verify(0, &data->msg[0], sizeof(data->msg), &data->sig[0], data->siglen, pkey) == (i == 0); + CHECK(result); + EC_KEY_free(pkey); + } + data->sig[data->siglen - 1] ^= (i & 0xFF); + data->sig[data->siglen - 2] ^= ((i >> 8) & 0xFF); + data->sig[data->siglen - 3] ^= ((i >> 16) & 0xFF); + } +} +#endif + +int main(void) { + int i; + secp256k1_pubkey pubkey; + secp256k1_ecdsa_signature sig; + benchmark_verify_t data; + + data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + + for (i = 0; i < 32; i++) { + data.msg[i] = 1 + i; + } + for (i = 0; i < 32; i++) { + data.key[i] = 33 + i; + } + data.siglen = 72; + CHECK(secp256k1_ecdsa_sign(data.ctx, &sig, data.msg, data.key, NULL, NULL)); + CHECK(secp256k1_ecdsa_signature_serialize_der(data.ctx, data.sig, &data.siglen, &sig)); + CHECK(secp256k1_ec_pubkey_create(data.ctx, &pubkey, data.key)); + data.pubkeylen = 33; + CHECK(secp256k1_ec_pubkey_serialize(data.ctx, data.pubkey, &data.pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED) == 1); + + run_benchmark("ecdsa_verify", benchmark_verify, NULL, NULL, &data, 10, 20000); +#ifdef ENABLE_OPENSSL_TESTS + data.ec_group = EC_GROUP_new_by_curve_name(NID_secp256k1); + run_benchmark("ecdsa_verify_openssl", benchmark_verify_openssl, NULL, NULL, &data, 10, 20000); + EC_GROUP_free(data.ec_group); +#endif + + secp256k1_context_destroy(data.ctx); + return 0; +} diff --git a/src/secp256k1/src/ecdsa.h b/src/secp256k1/src/ecdsa.h new file mode 100644 index 0000000..54ae101 --- /dev/null +++ b/src/secp256k1/src/ecdsa.h @@ -0,0 +1,21 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECDSA_ +#define _SECP256K1_ECDSA_ + +#include + +#include "scalar.h" +#include "group.h" +#include "ecmult.h" + +static int secp256k1_ecdsa_sig_parse(secp256k1_scalar *r, secp256k1_scalar *s, const unsigned char *sig, size_t size); +static int secp256k1_ecdsa_sig_serialize(unsigned char *sig, size_t *size, const secp256k1_scalar *r, const secp256k1_scalar *s); +static int secp256k1_ecdsa_sig_verify(const secp256k1_ecmult_context *ctx, const secp256k1_scalar* r, const secp256k1_scalar* s, const secp256k1_ge *pubkey, const secp256k1_scalar *message); +static int secp256k1_ecdsa_sig_sign(const secp256k1_ecmult_gen_context *ctx, secp256k1_scalar* r, secp256k1_scalar* s, const secp256k1_scalar *seckey, const secp256k1_scalar *message, const secp256k1_scalar *nonce, int *recid); + +#endif diff --git a/src/secp256k1/src/ecdsa_impl.h b/src/secp256k1/src/ecdsa_impl.h new file mode 100644 index 0000000..d110b4b --- /dev/null +++ b/src/secp256k1/src/ecdsa_impl.h @@ -0,0 +1,303 @@ +/********************************************************************** + * Copyright (c) 2013-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + + +#ifndef _SECP256K1_ECDSA_IMPL_H_ +#define _SECP256K1_ECDSA_IMPL_H_ + +#include "scalar.h" +#include "field.h" +#include "group.h" +#include "ecmult.h" +#include "ecmult_gen.h" +#include "ecdsa.h" + +/** Group order for secp256k1 defined as 'n' in "Standards for Efficient Cryptography" (SEC2) 2.7.1 + * sage: for t in xrange(1023, -1, -1): + * .. p = 2**256 - 2**32 - t + * .. if p.is_prime(): + * .. print '%x'%p + * .. break + * 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f' + * sage: a = 0 + * sage: b = 7 + * sage: F = FiniteField (p) + * sage: '%x' % (EllipticCurve ([F (a), F (b)]).order()) + * 'fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141' + */ +static const secp256k1_fe secp256k1_ecdsa_const_order_as_fe = SECP256K1_FE_CONST( + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFEUL, + 0xBAAEDCE6UL, 0xAF48A03BUL, 0xBFD25E8CUL, 0xD0364141UL +); + +/** Difference between field and order, values 'p' and 'n' values defined in + * "Standards for Efficient Cryptography" (SEC2) 2.7.1. + * sage: p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F + * sage: a = 0 + * sage: b = 7 + * sage: F = FiniteField (p) + * sage: '%x' % (p - EllipticCurve ([F (a), F (b)]).order()) + * '14551231950b75fc4402da1722fc9baee' + */ +static const secp256k1_fe secp256k1_ecdsa_const_p_minus_order = SECP256K1_FE_CONST( + 0, 0, 0, 1, 0x45512319UL, 0x50B75FC4UL, 0x402DA172UL, 0x2FC9BAEEUL +); + +static int secp256k1_der_read_len(const unsigned char **sigp, const unsigned char *sigend) { + int lenleft, b1; + size_t ret = 0; + if (*sigp >= sigend) { + return -1; + } + b1 = *((*sigp)++); + if (b1 == 0xFF) { + /* X.690-0207 8.1.3.5.c the value 0xFF shall not be used. */ + return -1; + } + if ((b1 & 0x80) == 0) { + /* X.690-0207 8.1.3.4 short form length octets */ + return b1; + } + if (b1 == 0x80) { + /* Indefinite length is not allowed in DER. */ + return -1; + } + /* X.690-207 8.1.3.5 long form length octets */ + lenleft = b1 & 0x7F; + if (lenleft > sigend - *sigp) { + return -1; + } + if (**sigp == 0) { + /* Not the shortest possible length encoding. */ + return -1; + } + if ((size_t)lenleft > sizeof(size_t)) { + /* The resulting length would exceed the range of a size_t, so + * certainly longer than the passed array size. + */ + return -1; + } + while (lenleft > 0) { + if ((ret >> ((sizeof(size_t) - 1) * 8)) != 0) { + } + ret = (ret << 8) | **sigp; + if (ret + lenleft > (size_t)(sigend - *sigp)) { + /* Result exceeds the length of the passed array. */ + return -1; + } + (*sigp)++; + lenleft--; + } + if (ret < 128) { + /* Not the shortest possible length encoding. */ + return -1; + } + return ret; +} + +static int secp256k1_der_parse_integer(secp256k1_scalar *r, const unsigned char **sig, const unsigned char *sigend) { + int overflow = 0; + unsigned char ra[32] = {0}; + int rlen; + + if (*sig == sigend || **sig != 0x02) { + /* Not a primitive integer (X.690-0207 8.3.1). */ + return 0; + } + (*sig)++; + rlen = secp256k1_der_read_len(sig, sigend); + if (rlen <= 0 || (*sig) + rlen > sigend) { + /* Exceeds bounds or not at least length 1 (X.690-0207 8.3.1). */ + return 0; + } + if (**sig == 0x00 && rlen > 1 && (((*sig)[1]) & 0x80) == 0x00) { + /* Excessive 0x00 padding. */ + return 0; + } + if (**sig == 0xFF && rlen > 1 && (((*sig)[1]) & 0x80) == 0x80) { + /* Excessive 0xFF padding. */ + return 0; + } + if ((**sig & 0x80) == 0x80) { + /* Negative. */ + overflow = 1; + } + while (rlen > 0 && **sig == 0) { + /* Skip leading zero bytes */ + rlen--; + (*sig)++; + } + if (rlen > 32) { + overflow = 1; + } + if (!overflow) { + memcpy(ra + 32 - rlen, *sig, rlen); + secp256k1_scalar_set_b32(r, ra, &overflow); + } + if (overflow) { + secp256k1_scalar_set_int(r, 0); + } + (*sig) += rlen; + return 1; +} + +static int secp256k1_ecdsa_sig_parse(secp256k1_scalar *rr, secp256k1_scalar *rs, const unsigned char *sig, size_t size) { + const unsigned char *sigend = sig + size; + int rlen; + if (sig == sigend || *(sig++) != 0x30) { + /* The encoding doesn't start with a constructed sequence (X.690-0207 8.9.1). */ + return 0; + } + rlen = secp256k1_der_read_len(&sig, sigend); + if (rlen < 0 || sig + rlen > sigend) { + /* Tuple exceeds bounds */ + return 0; + } + if (sig + rlen != sigend) { + /* Garbage after tuple. */ + return 0; + } + + if (!secp256k1_der_parse_integer(rr, &sig, sigend)) { + return 0; + } + if (!secp256k1_der_parse_integer(rs, &sig, sigend)) { + return 0; + } + + if (sig != sigend) { + /* Trailing garbage inside tuple. */ + return 0; + } + + return 1; +} + +static int secp256k1_ecdsa_sig_serialize(unsigned char *sig, size_t *size, const secp256k1_scalar* ar, const secp256k1_scalar* as) { + unsigned char r[33] = {0}, s[33] = {0}; + unsigned char *rp = r, *sp = s; + size_t lenR = 33, lenS = 33; + secp256k1_scalar_get_b32(&r[1], ar); + secp256k1_scalar_get_b32(&s[1], as); + while (lenR > 1 && rp[0] == 0 && rp[1] < 0x80) { lenR--; rp++; } + while (lenS > 1 && sp[0] == 0 && sp[1] < 0x80) { lenS--; sp++; } + if (*size < 6+lenS+lenR) { + *size = 6 + lenS + lenR; + return 0; + } + *size = 6 + lenS + lenR; + sig[0] = 0x30; + sig[1] = 4 + lenS + lenR; + sig[2] = 0x02; + sig[3] = lenR; + memcpy(sig+4, rp, lenR); + sig[4+lenR] = 0x02; + sig[5+lenR] = lenS; + memcpy(sig+lenR+6, sp, lenS); + return 1; +} + +static int secp256k1_ecdsa_sig_verify(const secp256k1_ecmult_context *ctx, const secp256k1_scalar *sigr, const secp256k1_scalar *sigs, const secp256k1_ge *pubkey, const secp256k1_scalar *message) { + unsigned char c[32]; + secp256k1_scalar sn, u1, u2; + secp256k1_fe xr; + secp256k1_gej pubkeyj; + secp256k1_gej pr; + + if (secp256k1_scalar_is_zero(sigr) || secp256k1_scalar_is_zero(sigs)) { + return 0; + } + + secp256k1_scalar_inverse_var(&sn, sigs); + secp256k1_scalar_mul(&u1, &sn, message); + secp256k1_scalar_mul(&u2, &sn, sigr); + secp256k1_gej_set_ge(&pubkeyj, pubkey); + secp256k1_ecmult(ctx, &pr, &pubkeyj, &u2, &u1); + if (secp256k1_gej_is_infinity(&pr)) { + return 0; + } + secp256k1_scalar_get_b32(c, sigr); + secp256k1_fe_set_b32(&xr, c); + + /** We now have the recomputed R point in pr, and its claimed x coordinate (modulo n) + * in xr. Naively, we would extract the x coordinate from pr (requiring a inversion modulo p), + * compute the remainder modulo n, and compare it to xr. However: + * + * xr == X(pr) mod n + * <=> exists h. (xr + h * n < p && xr + h * n == X(pr)) + * [Since 2 * n > p, h can only be 0 or 1] + * <=> (xr == X(pr)) || (xr + n < p && xr + n == X(pr)) + * [In Jacobian coordinates, X(pr) is pr.x / pr.z^2 mod p] + * <=> (xr == pr.x / pr.z^2 mod p) || (xr + n < p && xr + n == pr.x / pr.z^2 mod p) + * [Multiplying both sides of the equations by pr.z^2 mod p] + * <=> (xr * pr.z^2 mod p == pr.x) || (xr + n < p && (xr + n) * pr.z^2 mod p == pr.x) + * + * Thus, we can avoid the inversion, but we have to check both cases separately. + * secp256k1_gej_eq_x implements the (xr * pr.z^2 mod p == pr.x) test. + */ + if (secp256k1_gej_eq_x_var(&xr, &pr)) { + /* xr * pr.z^2 mod p == pr.x, so the signature is valid. */ + return 1; + } + if (secp256k1_fe_cmp_var(&xr, &secp256k1_ecdsa_const_p_minus_order) >= 0) { + /* xr + n >= p, so we can skip testing the second case. */ + return 0; + } + secp256k1_fe_add(&xr, &secp256k1_ecdsa_const_order_as_fe); + if (secp256k1_gej_eq_x_var(&xr, &pr)) { + /* (xr + n) * pr.z^2 mod p == pr.x, so the signature is valid. */ + return 1; + } + return 0; +} + +static int secp256k1_ecdsa_sig_sign(const secp256k1_ecmult_gen_context *ctx, secp256k1_scalar *sigr, secp256k1_scalar *sigs, const secp256k1_scalar *seckey, const secp256k1_scalar *message, const secp256k1_scalar *nonce, int *recid) { + unsigned char b[32]; + secp256k1_gej rp; + secp256k1_ge r; + secp256k1_scalar n; + int overflow = 0; + + secp256k1_ecmult_gen(ctx, &rp, nonce); + secp256k1_ge_set_gej(&r, &rp); + secp256k1_fe_normalize(&r.x); + secp256k1_fe_normalize(&r.y); + secp256k1_fe_get_b32(b, &r.x); + secp256k1_scalar_set_b32(sigr, b, &overflow); + if (secp256k1_scalar_is_zero(sigr)) { + /* P.x = order is on the curve, so technically sig->r could end up zero, which would be an invalid signature. + * This branch is cryptographically unreachable as hitting it requires finding the discrete log of P.x = N. + */ + secp256k1_gej_clear(&rp); + secp256k1_ge_clear(&r); + return 0; + } + if (recid) { + /* The overflow condition is cryptographically unreachable as hitting it requires finding the discrete log + * of some P where P.x >= order, and only 1 in about 2^127 points meet this criteria. + */ + *recid = (overflow ? 2 : 0) | (secp256k1_fe_is_odd(&r.y) ? 1 : 0); + } + secp256k1_scalar_mul(&n, sigr, seckey); + secp256k1_scalar_add(&n, &n, message); + secp256k1_scalar_inverse(sigs, nonce); + secp256k1_scalar_mul(sigs, sigs, &n); + secp256k1_scalar_clear(&n); + secp256k1_gej_clear(&rp); + secp256k1_ge_clear(&r); + if (secp256k1_scalar_is_zero(sigs)) { + return 0; + } + if (secp256k1_scalar_is_high(sigs)) { + secp256k1_scalar_negate(sigs, sigs); + if (recid) { + *recid ^= 1; + } + } + return 1; +} + +#endif diff --git a/src/secp256k1/src/eckey.h b/src/secp256k1/src/eckey.h new file mode 100644 index 0000000..42739a3 --- /dev/null +++ b/src/secp256k1/src/eckey.h @@ -0,0 +1,25 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECKEY_ +#define _SECP256K1_ECKEY_ + +#include + +#include "group.h" +#include "scalar.h" +#include "ecmult.h" +#include "ecmult_gen.h" + +static int secp256k1_eckey_pubkey_parse(secp256k1_ge *elem, const unsigned char *pub, size_t size); +static int secp256k1_eckey_pubkey_serialize(secp256k1_ge *elem, unsigned char *pub, size_t *size, int compressed); + +static int secp256k1_eckey_privkey_tweak_add(secp256k1_scalar *key, const secp256k1_scalar *tweak); +static int secp256k1_eckey_pubkey_tweak_add(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak); +static int secp256k1_eckey_privkey_tweak_mul(secp256k1_scalar *key, const secp256k1_scalar *tweak); +static int secp256k1_eckey_pubkey_tweak_mul(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak); + +#endif diff --git a/src/secp256k1/src/eckey_impl.h b/src/secp256k1/src/eckey_impl.h new file mode 100644 index 0000000..ce38071 --- /dev/null +++ b/src/secp256k1/src/eckey_impl.h @@ -0,0 +1,99 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECKEY_IMPL_H_ +#define _SECP256K1_ECKEY_IMPL_H_ + +#include "eckey.h" + +#include "scalar.h" +#include "field.h" +#include "group.h" +#include "ecmult_gen.h" + +static int secp256k1_eckey_pubkey_parse(secp256k1_ge *elem, const unsigned char *pub, size_t size) { + if (size == 33 && (pub[0] == 0x02 || pub[0] == 0x03)) { + secp256k1_fe x; + return secp256k1_fe_set_b32(&x, pub+1) && secp256k1_ge_set_xo_var(elem, &x, pub[0] == 0x03); + } else if (size == 65 && (pub[0] == 0x04 || pub[0] == 0x06 || pub[0] == 0x07)) { + secp256k1_fe x, y; + if (!secp256k1_fe_set_b32(&x, pub+1) || !secp256k1_fe_set_b32(&y, pub+33)) { + return 0; + } + secp256k1_ge_set_xy(elem, &x, &y); + if ((pub[0] == 0x06 || pub[0] == 0x07) && secp256k1_fe_is_odd(&y) != (pub[0] == 0x07)) { + return 0; + } + return secp256k1_ge_is_valid_var(elem); + } else { + return 0; + } +} + +static int secp256k1_eckey_pubkey_serialize(secp256k1_ge *elem, unsigned char *pub, size_t *size, int compressed) { + if (secp256k1_ge_is_infinity(elem)) { + return 0; + } + secp256k1_fe_normalize_var(&elem->x); + secp256k1_fe_normalize_var(&elem->y); + secp256k1_fe_get_b32(&pub[1], &elem->x); + if (compressed) { + *size = 33; + pub[0] = 0x02 | (secp256k1_fe_is_odd(&elem->y) ? 0x01 : 0x00); + } else { + *size = 65; + pub[0] = 0x04; + secp256k1_fe_get_b32(&pub[33], &elem->y); + } + return 1; +} + +static int secp256k1_eckey_privkey_tweak_add(secp256k1_scalar *key, const secp256k1_scalar *tweak) { + secp256k1_scalar_add(key, key, tweak); + if (secp256k1_scalar_is_zero(key)) { + return 0; + } + return 1; +} + +static int secp256k1_eckey_pubkey_tweak_add(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak) { + secp256k1_gej pt; + secp256k1_scalar one; + secp256k1_gej_set_ge(&pt, key); + secp256k1_scalar_set_int(&one, 1); + secp256k1_ecmult(ctx, &pt, &pt, &one, tweak); + + if (secp256k1_gej_is_infinity(&pt)) { + return 0; + } + secp256k1_ge_set_gej(key, &pt); + return 1; +} + +static int secp256k1_eckey_privkey_tweak_mul(secp256k1_scalar *key, const secp256k1_scalar *tweak) { + if (secp256k1_scalar_is_zero(tweak)) { + return 0; + } + + secp256k1_scalar_mul(key, key, tweak); + return 1; +} + +static int secp256k1_eckey_pubkey_tweak_mul(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak) { + secp256k1_scalar zero; + secp256k1_gej pt; + if (secp256k1_scalar_is_zero(tweak)) { + return 0; + } + + secp256k1_scalar_set_int(&zero, 0); + secp256k1_gej_set_ge(&pt, key); + secp256k1_ecmult(ctx, &pt, &pt, tweak, &zero); + secp256k1_ge_set_gej(key, &pt); + return 1; +} + +#endif diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h new file mode 100644 index 0000000..2048413 --- /dev/null +++ b/src/secp256k1/src/ecmult.h @@ -0,0 +1,31 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_ +#define _SECP256K1_ECMULT_ + +#include "num.h" +#include "group.h" + +typedef struct { + /* For accelerating the computation of a*P + b*G: */ + secp256k1_ge_storage (*pre_g)[]; /* odd multiples of the generator */ +#ifdef USE_ENDOMORPHISM + secp256k1_ge_storage (*pre_g_128)[]; /* odd multiples of 2^128*generator */ +#endif +} secp256k1_ecmult_context; + +static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx); +static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, const secp256k1_callback *cb); +static void secp256k1_ecmult_context_clone(secp256k1_ecmult_context *dst, + const secp256k1_ecmult_context *src, const secp256k1_callback *cb); +static void secp256k1_ecmult_context_clear(secp256k1_ecmult_context *ctx); +static int secp256k1_ecmult_context_is_built(const secp256k1_ecmult_context *ctx); + +/** Double multiply: R = na*A + ng*G */ +static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng); + +#endif diff --git a/src/secp256k1/src/ecmult_const.h b/src/secp256k1/src/ecmult_const.h new file mode 100644 index 0000000..2b00976 --- /dev/null +++ b/src/secp256k1/src/ecmult_const.h @@ -0,0 +1,15 @@ +/********************************************************************** + * Copyright (c) 2015 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_CONST_ +#define _SECP256K1_ECMULT_CONST_ + +#include "scalar.h" +#include "group.h" + +static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q); + +#endif diff --git a/src/secp256k1/src/ecmult_const_impl.h b/src/secp256k1/src/ecmult_const_impl.h new file mode 100644 index 0000000..90ac947 --- /dev/null +++ b/src/secp256k1/src/ecmult_const_impl.h @@ -0,0 +1,260 @@ +/********************************************************************** + * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_CONST_IMPL_ +#define _SECP256K1_ECMULT_CONST_IMPL_ + +#include "scalar.h" +#include "group.h" +#include "ecmult_const.h" +#include "ecmult_impl.h" + +#ifdef USE_ENDOMORPHISM + #define WNAF_BITS 128 +#else + #define WNAF_BITS 256 +#endif +#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) + +/* This is like `ECMULT_TABLE_GET_GE` but is constant time */ +#define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ + int m; \ + int abs_n = (n) * (((n) > 0) * 2 - 1); \ + int idx_n = abs_n / 2; \ + secp256k1_fe neg_y; \ + VERIFY_CHECK(((n) & 1) == 1); \ + VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ + VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \ + VERIFY_SETUP(secp256k1_fe_clear(&(r)->x)); \ + VERIFY_SETUP(secp256k1_fe_clear(&(r)->y)); \ + for (m = 0; m < ECMULT_TABLE_SIZE(w); m++) { \ + /* This loop is used to avoid secret data in array indices. See + * the comment in ecmult_gen_impl.h for rationale. */ \ + secp256k1_fe_cmov(&(r)->x, &(pre)[m].x, m == idx_n); \ + secp256k1_fe_cmov(&(r)->y, &(pre)[m].y, m == idx_n); \ + } \ + (r)->infinity = 0; \ + secp256k1_fe_negate(&neg_y, &(r)->y, 1); \ + secp256k1_fe_cmov(&(r)->y, &neg_y, (n) != abs_n); \ +} while(0) + + +/** Convert a number to WNAF notation. The number becomes represented by sum(2^{wi} * wnaf[i], i=0..return_val) + * with the following guarantees: + * - each wnaf[i] an odd integer between -(1 << w) and (1 << w) + * - each wnaf[i] is nonzero + * - the number of words set is returned; this is always (WNAF_BITS + w - 1) / w + * + * Adapted from `The Width-w NAF Method Provides Small Memory and Fast Elliptic Scalar + * Multiplications Secure against Side Channel Attacks`, Okeya and Tagaki. M. Joye (Ed.) + * CT-RSA 2003, LNCS 2612, pp. 328-443, 2003. Springer-Verlagy Berlin Heidelberg 2003 + * + * Numbers reference steps of `Algorithm SPA-resistant Width-w NAF with Odd Scalar` on pp. 335 + */ +static int secp256k1_wnaf_const(int *wnaf, secp256k1_scalar s, int w) { + int global_sign; + int skew = 0; + int word = 0; + /* 1 2 3 */ + int u_last; + int u; + +#ifdef USE_ENDOMORPHISM + int flip; + int bit; + secp256k1_scalar neg_s; + int not_neg_one; + /* If we are using the endomorphism, we cannot handle even numbers by negating + * them, since we are working with 128-bit numbers whose negations would be 256 + * bits, eliminating the performance advantage. Instead we use a technique from + * Section 4.2 of the Okeya/Tagaki paper, which is to add either 1 (for even) + * or 2 (for odd) to the number we are encoding, then compensating after the + * multiplication. */ + /* Negative 128-bit numbers will be negated, since otherwise they are 256-bit */ + flip = secp256k1_scalar_is_high(&s); + /* We add 1 to even numbers, 2 to odd ones, noting that negation flips parity */ + bit = flip ^ (s.d[0] & 1); + /* We check for negative one, since adding 2 to it will cause an overflow */ + secp256k1_scalar_negate(&neg_s, &s); + not_neg_one = !secp256k1_scalar_is_one(&neg_s); + secp256k1_scalar_cadd_bit(&s, bit, not_neg_one); + /* If we had negative one, flip == 1, s.d[0] == 0, bit == 1, so caller expects + * that we added two to it and flipped it. In fact for -1 these operations are + * identical. We only flipped, but since skewing is required (in the sense that + * the skew must be 1 or 2, never zero) and flipping is not, we need to change + * our flags to claim that we only skewed. */ + global_sign = secp256k1_scalar_cond_negate(&s, flip); + global_sign *= not_neg_one * 2 - 1; + skew = 1 << bit; +#else + /* Otherwise, we just negate to force oddness */ + int is_even = secp256k1_scalar_is_even(&s); + global_sign = secp256k1_scalar_cond_negate(&s, is_even); +#endif + + /* 4 */ + u_last = secp256k1_scalar_shr_int(&s, w); + while (word * w < WNAF_BITS) { + int sign; + int even; + + /* 4.1 4.4 */ + u = secp256k1_scalar_shr_int(&s, w); + /* 4.2 */ + even = ((u & 1) == 0); + sign = 2 * (u_last > 0) - 1; + u += sign * even; + u_last -= sign * even * (1 << w); + + /* 4.3, adapted for global sign change */ + wnaf[word++] = u_last * global_sign; + + u_last = u; + } + wnaf[word] = u * global_sign; + + VERIFY_CHECK(secp256k1_scalar_is_zero(&s)); + VERIFY_CHECK(word == WNAF_SIZE(w)); + return skew; +} + + +static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *scalar) { + secp256k1_ge pre_a[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_ge tmpa; + secp256k1_fe Z; + +#ifdef USE_ENDOMORPHISM + secp256k1_ge pre_a_lam[ECMULT_TABLE_SIZE(WINDOW_A)]; + int wnaf_1[1 + WNAF_SIZE(WINDOW_A - 1)]; + int wnaf_lam[1 + WNAF_SIZE(WINDOW_A - 1)]; + int skew_1; + int skew_lam; + secp256k1_scalar q_1, q_lam; +#else + int wnaf[1 + WNAF_SIZE(WINDOW_A - 1)]; +#endif + + int i; + secp256k1_scalar sc = *scalar; + + /* build wnaf representation for q. */ +#ifdef USE_ENDOMORPHISM + /* split q into q_1 and q_lam (where q = q_1 + q_lam*lambda, and q_1 and q_lam are ~128 bit) */ + secp256k1_scalar_split_lambda(&q_1, &q_lam, &sc); + /* no need for zero correction when using endomorphism since even + * numbers have one added to them anyway */ + skew_1 = secp256k1_wnaf_const(wnaf_1, q_1, WINDOW_A - 1); + skew_lam = secp256k1_wnaf_const(wnaf_lam, q_lam, WINDOW_A - 1); +#else + int is_zero = secp256k1_scalar_is_zero(scalar); + /* the wNAF ladder cannot handle zero, so bump this to one .. we will + * correct the result after the fact */ + sc.d[0] += is_zero; + VERIFY_CHECK(!secp256k1_scalar_is_zero(&sc)); + + secp256k1_wnaf_const(wnaf, sc, WINDOW_A - 1); +#endif + + /* Calculate odd multiples of a. + * All multiples are brought to the same Z 'denominator', which is stored + * in Z. Due to secp256k1' isomorphism we can do all operations pretending + * that the Z coordinate was 1, use affine addition formulae, and correct + * the Z coordinate of the result once at the end. + */ + secp256k1_gej_set_ge(r, a); + secp256k1_ecmult_odd_multiples_table_globalz_windowa(pre_a, &Z, r); + for (i = 0; i < ECMULT_TABLE_SIZE(WINDOW_A); i++) { + secp256k1_fe_normalize_weak(&pre_a[i].y); + } +#ifdef USE_ENDOMORPHISM + for (i = 0; i < ECMULT_TABLE_SIZE(WINDOW_A); i++) { + secp256k1_ge_mul_lambda(&pre_a_lam[i], &pre_a[i]); + } +#endif + + /* first loop iteration (separated out so we can directly set r, rather + * than having it start at infinity, get doubled several times, then have + * its new value added to it) */ +#ifdef USE_ENDOMORPHISM + i = wnaf_1[WNAF_SIZE(WINDOW_A - 1)]; + VERIFY_CHECK(i != 0); + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a, i, WINDOW_A); + secp256k1_gej_set_ge(r, &tmpa); + + i = wnaf_lam[WNAF_SIZE(WINDOW_A - 1)]; + VERIFY_CHECK(i != 0); + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a_lam, i, WINDOW_A); + secp256k1_gej_add_ge(r, r, &tmpa); +#else + i = wnaf[WNAF_SIZE(WINDOW_A - 1)]; + VERIFY_CHECK(i != 0); + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a, i, WINDOW_A); + secp256k1_gej_set_ge(r, &tmpa); +#endif + /* remaining loop iterations */ + for (i = WNAF_SIZE(WINDOW_A - 1) - 1; i >= 0; i--) { + int n; + int j; + for (j = 0; j < WINDOW_A - 1; ++j) { + secp256k1_gej_double_nonzero(r, r, NULL); + } +#ifdef USE_ENDOMORPHISM + n = wnaf_1[i]; + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a, n, WINDOW_A); + VERIFY_CHECK(n != 0); + secp256k1_gej_add_ge(r, r, &tmpa); + + n = wnaf_lam[i]; + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a_lam, n, WINDOW_A); + VERIFY_CHECK(n != 0); + secp256k1_gej_add_ge(r, r, &tmpa); +#else + n = wnaf[i]; + VERIFY_CHECK(n != 0); + ECMULT_CONST_TABLE_GET_GE(&tmpa, pre_a, n, WINDOW_A); + secp256k1_gej_add_ge(r, r, &tmpa); +#endif + } + + secp256k1_fe_mul(&r->z, &r->z, &Z); + +#ifdef USE_ENDOMORPHISM + { + /* Correct for wNAF skew */ + secp256k1_ge correction = *a; + secp256k1_ge_storage correction_1_stor; + secp256k1_ge_storage correction_lam_stor; + secp256k1_ge_storage a2_stor; + secp256k1_gej tmpj; + secp256k1_gej_set_ge(&tmpj, &correction); + secp256k1_gej_double_var(&tmpj, &tmpj, NULL); + secp256k1_ge_set_gej(&correction, &tmpj); + secp256k1_ge_to_storage(&correction_1_stor, a); + secp256k1_ge_to_storage(&correction_lam_stor, a); + secp256k1_ge_to_storage(&a2_stor, &correction); + + /* For odd numbers this is 2a (so replace it), for even ones a (so no-op) */ + secp256k1_ge_storage_cmov(&correction_1_stor, &a2_stor, skew_1 == 2); + secp256k1_ge_storage_cmov(&correction_lam_stor, &a2_stor, skew_lam == 2); + + /* Apply the correction */ + secp256k1_ge_from_storage(&correction, &correction_1_stor); + secp256k1_ge_neg(&correction, &correction); + secp256k1_gej_add_ge(r, r, &correction); + + secp256k1_ge_from_storage(&correction, &correction_lam_stor); + secp256k1_ge_neg(&correction, &correction); + secp256k1_ge_mul_lambda(&correction, &correction); + secp256k1_gej_add_ge(r, r, &correction); + } +#else + /* correct for zero */ + r->infinity |= is_zero; +#endif +} + +#endif diff --git a/src/secp256k1/src/ecmult_gen.h b/src/secp256k1/src/ecmult_gen.h new file mode 100644 index 0000000..eb2cc9e --- /dev/null +++ b/src/secp256k1/src/ecmult_gen.h @@ -0,0 +1,43 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_GEN_ +#define _SECP256K1_ECMULT_GEN_ + +#include "scalar.h" +#include "group.h" + +typedef struct { + /* For accelerating the computation of a*G: + * To harden against timing attacks, use the following mechanism: + * * Break up the multiplicand into groups of 4 bits, called n_0, n_1, n_2, ..., n_63. + * * Compute sum(n_i * 16^i * G + U_i, i=0..63), where: + * * U_i = U * 2^i (for i=0..62) + * * U_i = U * (1-2^63) (for i=63) + * where U is a point with no known corresponding scalar. Note that sum(U_i, i=0..63) = 0. + * For each i, and each of the 16 possible values of n_i, (n_i * 16^i * G + U_i) is + * precomputed (call it prec(i, n_i)). The formula now becomes sum(prec(i, n_i), i=0..63). + * None of the resulting prec group elements have a known scalar, and neither do any of + * the intermediate sums while computing a*G. + */ + secp256k1_ge_storage (*prec)[64][16]; /* prec[j][i] = 16^j * i * G + U_i */ + secp256k1_scalar blind; + secp256k1_gej initial; +} secp256k1_ecmult_gen_context; + +static void secp256k1_ecmult_gen_context_init(secp256k1_ecmult_gen_context* ctx); +static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context* ctx, const secp256k1_callback* cb); +static void secp256k1_ecmult_gen_context_clone(secp256k1_ecmult_gen_context *dst, + const secp256k1_ecmult_gen_context* src, const secp256k1_callback* cb); +static void secp256k1_ecmult_gen_context_clear(secp256k1_ecmult_gen_context* ctx); +static int secp256k1_ecmult_gen_context_is_built(const secp256k1_ecmult_gen_context* ctx); + +/** Multiply with the generator: R = a*G */ +static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context* ctx, secp256k1_gej *r, const secp256k1_scalar *a); + +static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const unsigned char *seed32); + +#endif diff --git a/src/secp256k1/src/ecmult_gen_impl.h b/src/secp256k1/src/ecmult_gen_impl.h new file mode 100644 index 0000000..b63c4d8 --- /dev/null +++ b/src/secp256k1/src/ecmult_gen_impl.h @@ -0,0 +1,210 @@ +/********************************************************************** + * Copyright (c) 2013, 2014, 2015 Pieter Wuille, Gregory Maxwell * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_GEN_IMPL_H_ +#define _SECP256K1_ECMULT_GEN_IMPL_H_ + +#include "scalar.h" +#include "group.h" +#include "ecmult_gen.h" +#include "hash_impl.h" +#ifdef USE_ECMULT_STATIC_PRECOMPUTATION +#include "ecmult_static_context.h" +#endif +static void secp256k1_ecmult_gen_context_init(secp256k1_ecmult_gen_context *ctx) { + ctx->prec = NULL; +} + +static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context *ctx, const secp256k1_callback* cb) { +#ifndef USE_ECMULT_STATIC_PRECOMPUTATION + secp256k1_ge prec[1024]; + secp256k1_gej gj; + secp256k1_gej nums_gej; + int i, j; +#endif + + if (ctx->prec != NULL) { + return; + } +#ifndef USE_ECMULT_STATIC_PRECOMPUTATION + ctx->prec = (secp256k1_ge_storage (*)[64][16])checked_malloc(cb, sizeof(*ctx->prec)); + + /* get the generator */ + secp256k1_gej_set_ge(&gj, &secp256k1_ge_const_g); + + /* Construct a group element with no known corresponding scalar (nothing up my sleeve). */ + { + static const unsigned char nums_b32[33] = "The scalar for this x is unknown"; + secp256k1_fe nums_x; + secp256k1_ge nums_ge; + int r; + r = secp256k1_fe_set_b32(&nums_x, nums_b32); + (void)r; + VERIFY_CHECK(r); + r = secp256k1_ge_set_xo_var(&nums_ge, &nums_x, 0); + (void)r; + VERIFY_CHECK(r); + secp256k1_gej_set_ge(&nums_gej, &nums_ge); + /* Add G to make the bits in x uniformly distributed. */ + secp256k1_gej_add_ge_var(&nums_gej, &nums_gej, &secp256k1_ge_const_g, NULL); + } + + /* compute prec. */ + { + secp256k1_gej precj[1024]; /* Jacobian versions of prec. */ + secp256k1_gej gbase; + secp256k1_gej numsbase; + gbase = gj; /* 16^j * G */ + numsbase = nums_gej; /* 2^j * nums. */ + for (j = 0; j < 64; j++) { + /* Set precj[j*16 .. j*16+15] to (numsbase, numsbase + gbase, ..., numsbase + 15*gbase). */ + precj[j*16] = numsbase; + for (i = 1; i < 16; i++) { + secp256k1_gej_add_var(&precj[j*16 + i], &precj[j*16 + i - 1], &gbase, NULL); + } + /* Multiply gbase by 16. */ + for (i = 0; i < 4; i++) { + secp256k1_gej_double_var(&gbase, &gbase, NULL); + } + /* Multiply numbase by 2. */ + secp256k1_gej_double_var(&numsbase, &numsbase, NULL); + if (j == 62) { + /* In the last iteration, numsbase is (1 - 2^j) * nums instead. */ + secp256k1_gej_neg(&numsbase, &numsbase); + secp256k1_gej_add_var(&numsbase, &numsbase, &nums_gej, NULL); + } + } + secp256k1_ge_set_all_gej_var(1024, prec, precj, cb); + } + for (j = 0; j < 64; j++) { + for (i = 0; i < 16; i++) { + secp256k1_ge_to_storage(&(*ctx->prec)[j][i], &prec[j*16 + i]); + } + } +#else + (void)cb; + ctx->prec = (secp256k1_ge_storage (*)[64][16])secp256k1_ecmult_static_context; +#endif + secp256k1_ecmult_gen_blind(ctx, NULL); +} + +static int secp256k1_ecmult_gen_context_is_built(const secp256k1_ecmult_gen_context* ctx) { + return ctx->prec != NULL; +} + +static void secp256k1_ecmult_gen_context_clone(secp256k1_ecmult_gen_context *dst, + const secp256k1_ecmult_gen_context *src, const secp256k1_callback* cb) { + if (src->prec == NULL) { + dst->prec = NULL; + } else { +#ifndef USE_ECMULT_STATIC_PRECOMPUTATION + dst->prec = (secp256k1_ge_storage (*)[64][16])checked_malloc(cb, sizeof(*dst->prec)); + memcpy(dst->prec, src->prec, sizeof(*dst->prec)); +#else + (void)cb; + dst->prec = src->prec; +#endif + dst->initial = src->initial; + dst->blind = src->blind; + } +} + +static void secp256k1_ecmult_gen_context_clear(secp256k1_ecmult_gen_context *ctx) { +#ifndef USE_ECMULT_STATIC_PRECOMPUTATION + free(ctx->prec); +#endif + secp256k1_scalar_clear(&ctx->blind); + secp256k1_gej_clear(&ctx->initial); + ctx->prec = NULL; +} + +static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context *ctx, secp256k1_gej *r, const secp256k1_scalar *gn) { + secp256k1_ge add; + secp256k1_ge_storage adds; + secp256k1_scalar gnb; + int bits; + int i, j; + memset(&adds, 0, sizeof(adds)); + *r = ctx->initial; + /* Blind scalar/point multiplication by computing (n-b)G + bG instead of nG. */ + secp256k1_scalar_add(&gnb, gn, &ctx->blind); + add.infinity = 0; + for (j = 0; j < 64; j++) { + bits = secp256k1_scalar_get_bits(&gnb, j * 4, 4); + for (i = 0; i < 16; i++) { + /** This uses a conditional move to avoid any secret data in array indexes. + * _Any_ use of secret indexes has been demonstrated to result in timing + * sidechannels, even when the cache-line access patterns are uniform. + * See also: + * "A word of warning", CHES 2013 Rump Session, by Daniel J. Bernstein and Peter Schwabe + * (https://cryptojedi.org/peter/data/chesrump-20130822.pdf) and + * "Cache Attacks and Countermeasures: the Case of AES", RSA 2006, + * by Dag Arne Osvik, Adi Shamir, and Eran Tromer + * (http://www.tau.ac.il/~tromer/papers/cache.pdf) + */ + secp256k1_ge_storage_cmov(&adds, &(*ctx->prec)[j][i], i == bits); + } + secp256k1_ge_from_storage(&add, &adds); + secp256k1_gej_add_ge(r, r, &add); + } + bits = 0; + secp256k1_ge_clear(&add); + secp256k1_scalar_clear(&gnb); +} + +/* Setup blinding values for secp256k1_ecmult_gen. */ +static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const unsigned char *seed32) { + secp256k1_scalar b; + secp256k1_gej gb; + secp256k1_fe s; + unsigned char nonce32[32]; + secp256k1_rfc6979_hmac_sha256_t rng; + int retry; + unsigned char keydata[64] = {0}; + if (seed32 == NULL) { + /* When seed is NULL, reset the initial point and blinding value. */ + secp256k1_gej_set_ge(&ctx->initial, &secp256k1_ge_const_g); + secp256k1_gej_neg(&ctx->initial, &ctx->initial); + secp256k1_scalar_set_int(&ctx->blind, 1); + } + /* The prior blinding value (if not reset) is chained forward by including it in the hash. */ + secp256k1_scalar_get_b32(nonce32, &ctx->blind); + /** Using a CSPRNG allows a failure free interface, avoids needing large amounts of random data, + * and guards against weak or adversarial seeds. This is a simpler and safer interface than + * asking the caller for blinding values directly and expecting them to retry on failure. + */ + memcpy(keydata, nonce32, 32); + if (seed32 != NULL) { + memcpy(keydata + 32, seed32, 32); + } + secp256k1_rfc6979_hmac_sha256_initialize(&rng, keydata, seed32 ? 64 : 32); + memset(keydata, 0, sizeof(keydata)); + /* Retry for out of range results to achieve uniformity. */ + do { + secp256k1_rfc6979_hmac_sha256_generate(&rng, nonce32, 32); + retry = !secp256k1_fe_set_b32(&s, nonce32); + retry |= secp256k1_fe_is_zero(&s); + } while (retry); /* This branch true is cryptographically unreachable. Requires sha256_hmac output > Fp. */ + /* Randomize the projection to defend against multiplier sidechannels. */ + secp256k1_gej_rescale(&ctx->initial, &s); + secp256k1_fe_clear(&s); + do { + secp256k1_rfc6979_hmac_sha256_generate(&rng, nonce32, 32); + secp256k1_scalar_set_b32(&b, nonce32, &retry); + /* A blinding value of 0 works, but would undermine the projection hardening. */ + retry |= secp256k1_scalar_is_zero(&b); + } while (retry); /* This branch true is cryptographically unreachable. Requires sha256_hmac output > order. */ + secp256k1_rfc6979_hmac_sha256_finalize(&rng); + memset(nonce32, 0, 32); + secp256k1_ecmult_gen(ctx, &gb, &b); + secp256k1_scalar_negate(&b, &b); + ctx->blind = b; + ctx->initial = gb; + secp256k1_scalar_clear(&b); + secp256k1_gej_clear(&gb); +} + +#endif diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h new file mode 100644 index 0000000..e6e5f47 --- /dev/null +++ b/src/secp256k1/src/ecmult_impl.h @@ -0,0 +1,389 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_ECMULT_IMPL_H_ +#define _SECP256K1_ECMULT_IMPL_H_ + +#include "group.h" +#include "scalar.h" +#include "ecmult.h" + +/* optimal for 128-bit and 256-bit exponents. */ +#define WINDOW_A 5 + +/** larger numbers may result in slightly better performance, at the cost of + exponentially larger precomputed tables. */ +#ifdef USE_ENDOMORPHISM +/** Two tables for window size 15: 1.375 MiB. */ +#define WINDOW_G 15 +#else +/** One table for window size 16: 1.375 MiB. */ +#define WINDOW_G 16 +#endif + +/** The number of entries a table with precomputed multiples needs to have. */ +#define ECMULT_TABLE_SIZE(w) (1 << ((w)-2)) + +/** Fill a table 'prej' with precomputed odd multiples of a. Prej will contain + * the values [1*a,3*a,...,(2*n-1)*a], so it space for n values. zr[0] will + * contain prej[0].z / a.z. The other zr[i] values = prej[i].z / prej[i-1].z. + * Prej's Z values are undefined, except for the last value. + */ +static void secp256k1_ecmult_odd_multiples_table(int n, secp256k1_gej *prej, secp256k1_fe *zr, const secp256k1_gej *a) { + secp256k1_gej d; + secp256k1_ge a_ge, d_ge; + int i; + + VERIFY_CHECK(!a->infinity); + + secp256k1_gej_double_var(&d, a, NULL); + + /* + * Perform the additions on an isomorphism where 'd' is affine: drop the z coordinate + * of 'd', and scale the 1P starting value's x/y coordinates without changing its z. + */ + d_ge.x = d.x; + d_ge.y = d.y; + d_ge.infinity = 0; + + secp256k1_ge_set_gej_zinv(&a_ge, a, &d.z); + prej[0].x = a_ge.x; + prej[0].y = a_ge.y; + prej[0].z = a->z; + prej[0].infinity = 0; + + zr[0] = d.z; + for (i = 1; i < n; i++) { + secp256k1_gej_add_ge_var(&prej[i], &prej[i-1], &d_ge, &zr[i]); + } + + /* + * Each point in 'prej' has a z coordinate too small by a factor of 'd.z'. Only + * the final point's z coordinate is actually used though, so just update that. + */ + secp256k1_fe_mul(&prej[n-1].z, &prej[n-1].z, &d.z); +} + +/** Fill a table 'pre' with precomputed odd multiples of a. + * + * There are two versions of this function: + * - secp256k1_ecmult_odd_multiples_table_globalz_windowa which brings its + * resulting point set to a single constant Z denominator, stores the X and Y + * coordinates as ge_storage points in pre, and stores the global Z in rz. + * It only operates on tables sized for WINDOW_A wnaf multiples. + * - secp256k1_ecmult_odd_multiples_table_storage_var, which converts its + * resulting point set to actually affine points, and stores those in pre. + * It operates on tables of any size, but uses heap-allocated temporaries. + * + * To compute a*P + b*G, we compute a table for P using the first function, + * and for G using the second (which requires an inverse, but it only needs to + * happen once). + */ +static void secp256k1_ecmult_odd_multiples_table_globalz_windowa(secp256k1_ge *pre, secp256k1_fe *globalz, const secp256k1_gej *a) { + secp256k1_gej prej[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_fe zr[ECMULT_TABLE_SIZE(WINDOW_A)]; + + /* Compute the odd multiples in Jacobian form. */ + secp256k1_ecmult_odd_multiples_table(ECMULT_TABLE_SIZE(WINDOW_A), prej, zr, a); + /* Bring them to the same Z denominator. */ + secp256k1_ge_globalz_set_table_gej(ECMULT_TABLE_SIZE(WINDOW_A), pre, globalz, prej, zr); +} + +static void secp256k1_ecmult_odd_multiples_table_storage_var(int n, secp256k1_ge_storage *pre, const secp256k1_gej *a, const secp256k1_callback *cb) { + secp256k1_gej *prej = (secp256k1_gej*)checked_malloc(cb, sizeof(secp256k1_gej) * n); + secp256k1_ge *prea = (secp256k1_ge*)checked_malloc(cb, sizeof(secp256k1_ge) * n); + secp256k1_fe *zr = (secp256k1_fe*)checked_malloc(cb, sizeof(secp256k1_fe) * n); + int i; + + /* Compute the odd multiples in Jacobian form. */ + secp256k1_ecmult_odd_multiples_table(n, prej, zr, a); + /* Convert them in batch to affine coordinates. */ + secp256k1_ge_set_table_gej_var(n, prea, prej, zr); + /* Convert them to compact storage form. */ + for (i = 0; i < n; i++) { + secp256k1_ge_to_storage(&pre[i], &prea[i]); + } + + free(prea); + free(prej); + free(zr); +} + +/** The following two macro retrieves a particular odd multiple from a table + * of precomputed multiples. */ +#define ECMULT_TABLE_GET_GE(r,pre,n,w) do { \ + VERIFY_CHECK(((n) & 1) == 1); \ + VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ + VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \ + if ((n) > 0) { \ + *(r) = (pre)[((n)-1)/2]; \ + } else { \ + secp256k1_ge_neg((r), &(pre)[(-(n)-1)/2]); \ + } \ +} while(0) + +#define ECMULT_TABLE_GET_GE_STORAGE(r,pre,n,w) do { \ + VERIFY_CHECK(((n) & 1) == 1); \ + VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ + VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \ + if ((n) > 0) { \ + secp256k1_ge_from_storage((r), &(pre)[((n)-1)/2]); \ + } else { \ + secp256k1_ge_from_storage((r), &(pre)[(-(n)-1)/2]); \ + secp256k1_ge_neg((r), (r)); \ + } \ +} while(0) + +static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx) { + ctx->pre_g = NULL; +#ifdef USE_ENDOMORPHISM + ctx->pre_g_128 = NULL; +#endif +} + +static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, const secp256k1_callback *cb) { + secp256k1_gej gj; + + if (ctx->pre_g != NULL) { + return; + } + + /* get the generator */ + secp256k1_gej_set_ge(&gj, &secp256k1_ge_const_g); + + ctx->pre_g = (secp256k1_ge_storage (*)[])checked_malloc(cb, sizeof((*ctx->pre_g)[0]) * ECMULT_TABLE_SIZE(WINDOW_G)); + + /* precompute the tables with odd multiples */ + secp256k1_ecmult_odd_multiples_table_storage_var(ECMULT_TABLE_SIZE(WINDOW_G), *ctx->pre_g, &gj, cb); + +#ifdef USE_ENDOMORPHISM + { + secp256k1_gej g_128j; + int i; + + ctx->pre_g_128 = (secp256k1_ge_storage (*)[])checked_malloc(cb, sizeof((*ctx->pre_g_128)[0]) * ECMULT_TABLE_SIZE(WINDOW_G)); + + /* calculate 2^128*generator */ + g_128j = gj; + for (i = 0; i < 128; i++) { + secp256k1_gej_double_var(&g_128j, &g_128j, NULL); + } + secp256k1_ecmult_odd_multiples_table_storage_var(ECMULT_TABLE_SIZE(WINDOW_G), *ctx->pre_g_128, &g_128j, cb); + } +#endif +} + +static void secp256k1_ecmult_context_clone(secp256k1_ecmult_context *dst, + const secp256k1_ecmult_context *src, const secp256k1_callback *cb) { + if (src->pre_g == NULL) { + dst->pre_g = NULL; + } else { + size_t size = sizeof((*dst->pre_g)[0]) * ECMULT_TABLE_SIZE(WINDOW_G); + dst->pre_g = (secp256k1_ge_storage (*)[])checked_malloc(cb, size); + memcpy(dst->pre_g, src->pre_g, size); + } +#ifdef USE_ENDOMORPHISM + if (src->pre_g_128 == NULL) { + dst->pre_g_128 = NULL; + } else { + size_t size = sizeof((*dst->pre_g_128)[0]) * ECMULT_TABLE_SIZE(WINDOW_G); + dst->pre_g_128 = (secp256k1_ge_storage (*)[])checked_malloc(cb, size); + memcpy(dst->pre_g_128, src->pre_g_128, size); + } +#endif +} + +static int secp256k1_ecmult_context_is_built(const secp256k1_ecmult_context *ctx) { + return ctx->pre_g != NULL; +} + +static void secp256k1_ecmult_context_clear(secp256k1_ecmult_context *ctx) { + free(ctx->pre_g); +#ifdef USE_ENDOMORPHISM + free(ctx->pre_g_128); +#endif + secp256k1_ecmult_context_init(ctx); +} + +/** Convert a number to WNAF notation. The number becomes represented by sum(2^i * wnaf[i], i=0..bits), + * with the following guarantees: + * - each wnaf[i] is either 0, or an odd integer between -(1<<(w-1) - 1) and (1<<(w-1) - 1) + * - two non-zero entries in wnaf are separated by at least w-1 zeroes. + * - the number of set values in wnaf is returned. This number is at most 256, and at most one more + * than the number of bits in the (absolute value) of the input. + */ +static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a, int w) { + secp256k1_scalar s = *a; + int last_set_bit = -1; + int bit = 0; + int sign = 1; + int carry = 0; + + VERIFY_CHECK(wnaf != NULL); + VERIFY_CHECK(0 <= len && len <= 256); + VERIFY_CHECK(a != NULL); + VERIFY_CHECK(2 <= w && w <= 31); + + memset(wnaf, 0, len * sizeof(wnaf[0])); + + if (secp256k1_scalar_get_bits(&s, 255, 1)) { + secp256k1_scalar_negate(&s, &s); + sign = -1; + } + + while (bit < len) { + int now; + int word; + if (secp256k1_scalar_get_bits(&s, bit, 1) == (unsigned int)carry) { + bit++; + continue; + } + + now = w; + if (now > len - bit) { + now = len - bit; + } + + word = secp256k1_scalar_get_bits_var(&s, bit, now) + carry; + + carry = (word >> (w-1)) & 1; + word -= carry << w; + + wnaf[bit] = sign * word; + last_set_bit = bit; + + bit += now; + } +#ifdef VERIFY + CHECK(carry == 0); + while (bit < 256) { + CHECK(secp256k1_scalar_get_bits(&s, bit++, 1) == 0); + } +#endif + return last_set_bit + 1; +} + +static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng) { + secp256k1_ge pre_a[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_ge tmpa; + secp256k1_fe Z; +#ifdef USE_ENDOMORPHISM + secp256k1_ge pre_a_lam[ECMULT_TABLE_SIZE(WINDOW_A)]; + secp256k1_scalar na_1, na_lam; + /* Splitted G factors. */ + secp256k1_scalar ng_1, ng_128; + int wnaf_na_1[130]; + int wnaf_na_lam[130]; + int bits_na_1; + int bits_na_lam; + int wnaf_ng_1[129]; + int bits_ng_1; + int wnaf_ng_128[129]; + int bits_ng_128; +#else + int wnaf_na[256]; + int bits_na; + int wnaf_ng[256]; + int bits_ng; +#endif + int i; + int bits; + +#ifdef USE_ENDOMORPHISM + /* split na into na_1 and na_lam (where na = na_1 + na_lam*lambda, and na_1 and na_lam are ~128 bit) */ + secp256k1_scalar_split_lambda(&na_1, &na_lam, na); + + /* build wnaf representation for na_1 and na_lam. */ + bits_na_1 = secp256k1_ecmult_wnaf(wnaf_na_1, 130, &na_1, WINDOW_A); + bits_na_lam = secp256k1_ecmult_wnaf(wnaf_na_lam, 130, &na_lam, WINDOW_A); + VERIFY_CHECK(bits_na_1 <= 130); + VERIFY_CHECK(bits_na_lam <= 130); + bits = bits_na_1; + if (bits_na_lam > bits) { + bits = bits_na_lam; + } +#else + /* build wnaf representation for na. */ + bits_na = secp256k1_ecmult_wnaf(wnaf_na, 256, na, WINDOW_A); + bits = bits_na; +#endif + + /* Calculate odd multiples of a. + * All multiples are brought to the same Z 'denominator', which is stored + * in Z. Due to secp256k1' isomorphism we can do all operations pretending + * that the Z coordinate was 1, use affine addition formulae, and correct + * the Z coordinate of the result once at the end. + * The exception is the precomputed G table points, which are actually + * affine. Compared to the base used for other points, they have a Z ratio + * of 1/Z, so we can use secp256k1_gej_add_zinv_var, which uses the same + * isomorphism to efficiently add with a known Z inverse. + */ + secp256k1_ecmult_odd_multiples_table_globalz_windowa(pre_a, &Z, a); + +#ifdef USE_ENDOMORPHISM + for (i = 0; i < ECMULT_TABLE_SIZE(WINDOW_A); i++) { + secp256k1_ge_mul_lambda(&pre_a_lam[i], &pre_a[i]); + } + + /* split ng into ng_1 and ng_128 (where gn = gn_1 + gn_128*2^128, and gn_1 and gn_128 are ~128 bit) */ + secp256k1_scalar_split_128(&ng_1, &ng_128, ng); + + /* Build wnaf representation for ng_1 and ng_128 */ + bits_ng_1 = secp256k1_ecmult_wnaf(wnaf_ng_1, 129, &ng_1, WINDOW_G); + bits_ng_128 = secp256k1_ecmult_wnaf(wnaf_ng_128, 129, &ng_128, WINDOW_G); + if (bits_ng_1 > bits) { + bits = bits_ng_1; + } + if (bits_ng_128 > bits) { + bits = bits_ng_128; + } +#else + bits_ng = secp256k1_ecmult_wnaf(wnaf_ng, 256, ng, WINDOW_G); + if (bits_ng > bits) { + bits = bits_ng; + } +#endif + + secp256k1_gej_set_infinity(r); + + for (i = bits - 1; i >= 0; i--) { + int n; + secp256k1_gej_double_var(r, r, NULL); +#ifdef USE_ENDOMORPHISM + if (i < bits_na_1 && (n = wnaf_na_1[i])) { + ECMULT_TABLE_GET_GE(&tmpa, pre_a, n, WINDOW_A); + secp256k1_gej_add_ge_var(r, r, &tmpa, NULL); + } + if (i < bits_na_lam && (n = wnaf_na_lam[i])) { + ECMULT_TABLE_GET_GE(&tmpa, pre_a_lam, n, WINDOW_A); + secp256k1_gej_add_ge_var(r, r, &tmpa, NULL); + } + if (i < bits_ng_1 && (n = wnaf_ng_1[i])) { + ECMULT_TABLE_GET_GE_STORAGE(&tmpa, *ctx->pre_g, n, WINDOW_G); + secp256k1_gej_add_zinv_var(r, r, &tmpa, &Z); + } + if (i < bits_ng_128 && (n = wnaf_ng_128[i])) { + ECMULT_TABLE_GET_GE_STORAGE(&tmpa, *ctx->pre_g_128, n, WINDOW_G); + secp256k1_gej_add_zinv_var(r, r, &tmpa, &Z); + } +#else + if (i < bits_na && (n = wnaf_na[i])) { + ECMULT_TABLE_GET_GE(&tmpa, pre_a, n, WINDOW_A); + secp256k1_gej_add_ge_var(r, r, &tmpa, NULL); + } + if (i < bits_ng && (n = wnaf_ng[i])) { + ECMULT_TABLE_GET_GE_STORAGE(&tmpa, *ctx->pre_g, n, WINDOW_G); + secp256k1_gej_add_zinv_var(r, r, &tmpa, &Z); + } +#endif + } + + if (!r->infinity) { + secp256k1_fe_mul(&r->z, &r->z, &Z); + } +} + +#endif diff --git a/src/secp256k1/src/field.h b/src/secp256k1/src/field.h new file mode 100644 index 0000000..2d52af5 --- /dev/null +++ b/src/secp256k1/src/field.h @@ -0,0 +1,121 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_ +#define _SECP256K1_FIELD_ + +/** Field element module. + * + * Field elements can be represented in several ways, but code accessing + * it (and implementations) need to take certain properties into account: + * - Each field element can be normalized or not. + * - Each field element has a magnitude, which represents how far away + * its representation is away from normalization. Normalized elements + * always have a magnitude of 1, but a magnitude of 1 doesn't imply + * normality. + */ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(USE_FIELD_10X26) +#include "field_10x26.h" +#elif defined(USE_FIELD_5X52) +#include "field_5x52.h" +#else +#error "Please select field implementation" +#endif + +/** Normalize a field element. */ +static void secp256k1_fe_normalize(secp256k1_fe *r); + +/** Weakly normalize a field element: reduce it magnitude to 1, but don't fully normalize. */ +static void secp256k1_fe_normalize_weak(secp256k1_fe *r); + +/** Normalize a field element, without constant-time guarantee. */ +static void secp256k1_fe_normalize_var(secp256k1_fe *r); + +/** Verify whether a field element represents zero i.e. would normalize to a zero value. The field + * implementation may optionally normalize the input, but this should not be relied upon. */ +static int secp256k1_fe_normalizes_to_zero(secp256k1_fe *r); + +/** Verify whether a field element represents zero i.e. would normalize to a zero value. The field + * implementation may optionally normalize the input, but this should not be relied upon. */ +static int secp256k1_fe_normalizes_to_zero_var(secp256k1_fe *r); + +/** Set a field element equal to a small integer. Resulting field element is normalized. */ +static void secp256k1_fe_set_int(secp256k1_fe *r, int a); + +/** Verify whether a field element is zero. Requires the input to be normalized. */ +static int secp256k1_fe_is_zero(const secp256k1_fe *a); + +/** Check the "oddness" of a field element. Requires the input to be normalized. */ +static int secp256k1_fe_is_odd(const secp256k1_fe *a); + +/** Compare two field elements. Requires magnitude-1 inputs. */ +static int secp256k1_fe_equal_var(const secp256k1_fe *a, const secp256k1_fe *b); + +/** Compare two field elements. Requires both inputs to be normalized */ +static int secp256k1_fe_cmp_var(const secp256k1_fe *a, const secp256k1_fe *b); + +/** Set a field element equal to 32-byte big endian value. If successful, the resulting field element is normalized. */ +static int secp256k1_fe_set_b32(secp256k1_fe *r, const unsigned char *a); + +/** Convert a field element to a 32-byte big endian value. Requires the input to be normalized */ +static void secp256k1_fe_get_b32(unsigned char *r, const secp256k1_fe *a); + +/** Set a field element equal to the additive inverse of another. Takes a maximum magnitude of the input + * as an argument. The magnitude of the output is one higher. */ +static void secp256k1_fe_negate(secp256k1_fe *r, const secp256k1_fe *a, int m); + +/** Multiplies the passed field element with a small integer constant. Multiplies the magnitude by that + * small integer. */ +static void secp256k1_fe_mul_int(secp256k1_fe *r, int a); + +/** Adds a field element to another. The result has the sum of the inputs' magnitudes as magnitude. */ +static void secp256k1_fe_add(secp256k1_fe *r, const secp256k1_fe *a); + +/** Sets a field element to be the product of two others. Requires the inputs' magnitudes to be at most 8. + * The output magnitude is 1 (but not guaranteed to be normalized). */ +static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp256k1_fe * SECP256K1_RESTRICT b); + +/** Sets a field element to be the square of another. Requires the input's magnitude to be at most 8. + * The output magnitude is 1 (but not guaranteed to be normalized). */ +static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a); + +/** If a has a square root, it is computed in r and 1 is returned. If a does not + * have a square root, the root of its negation is computed and 0 is returned. + * The input's magnitude can be at most 8. The output magnitude is 1 (but not + * guaranteed to be normalized). The result in r will always be a square + * itself. */ +static int secp256k1_fe_sqrt_var(secp256k1_fe *r, const secp256k1_fe *a); + +/** Sets a field element to be the (modular) inverse of another. Requires the input's magnitude to be + * at most 8. The output magnitude is 1 (but not guaranteed to be normalized). */ +static void secp256k1_fe_inv(secp256k1_fe *r, const secp256k1_fe *a); + +/** Potentially faster version of secp256k1_fe_inv, without constant-time guarantee. */ +static void secp256k1_fe_inv_var(secp256k1_fe *r, const secp256k1_fe *a); + +/** Calculate the (modular) inverses of a batch of field elements. Requires the inputs' magnitudes to be + * at most 8. The output magnitudes are 1 (but not guaranteed to be normalized). The inputs and + * outputs must not overlap in memory. */ +static void secp256k1_fe_inv_all_var(size_t len, secp256k1_fe *r, const secp256k1_fe *a); + +/** Convert a field element to the storage type. */ +static void secp256k1_fe_to_storage(secp256k1_fe_storage *r, const secp256k1_fe *a); + +/** Convert a field element back from the storage type. */ +static void secp256k1_fe_from_storage(secp256k1_fe *r, const secp256k1_fe_storage *a); + +/** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. */ +static void secp256k1_fe_storage_cmov(secp256k1_fe_storage *r, const secp256k1_fe_storage *a, int flag); + +/** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. */ +static void secp256k1_fe_cmov(secp256k1_fe *r, const secp256k1_fe *a, int flag); + +#endif diff --git a/src/secp256k1/src/field_10x26.h b/src/secp256k1/src/field_10x26.h new file mode 100644 index 0000000..61ee1e0 --- /dev/null +++ b/src/secp256k1/src/field_10x26.h @@ -0,0 +1,47 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_REPR_ +#define _SECP256K1_FIELD_REPR_ + +#include + +typedef struct { + /* X = sum(i=0..9, elem[i]*2^26) mod n */ + uint32_t n[10]; +#ifdef VERIFY + int magnitude; + int normalized; +#endif +} secp256k1_fe; + +/* Unpacks a constant into a overlapping multi-limbed FE element. */ +#define SECP256K1_FE_CONST_INNER(d7, d6, d5, d4, d3, d2, d1, d0) { \ + (d0) & 0x3FFFFFFUL, \ + (((uint32_t)d0) >> 26) | (((uint32_t)(d1) & 0xFFFFFUL) << 6), \ + (((uint32_t)d1) >> 20) | (((uint32_t)(d2) & 0x3FFFUL) << 12), \ + (((uint32_t)d2) >> 14) | (((uint32_t)(d3) & 0xFFUL) << 18), \ + (((uint32_t)d3) >> 8) | (((uint32_t)(d4) & 0x3UL) << 24), \ + (((uint32_t)d4) >> 2) & 0x3FFFFFFUL, \ + (((uint32_t)d4) >> 28) | (((uint32_t)(d5) & 0x3FFFFFUL) << 4), \ + (((uint32_t)d5) >> 22) | (((uint32_t)(d6) & 0xFFFFUL) << 10), \ + (((uint32_t)d6) >> 16) | (((uint32_t)(d7) & 0x3FFUL) << 16), \ + (((uint32_t)d7) >> 10) \ +} + +#ifdef VERIFY +#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)), 1, 1} +#else +#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0))} +#endif + +typedef struct { + uint32_t n[8]; +} secp256k1_fe_storage; + +#define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{ (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }} +#define SECP256K1_FE_STORAGE_CONST_GET(d) d.n[7], d.n[6], d.n[5], d.n[4],d.n[3], d.n[2], d.n[1], d.n[0] +#endif diff --git a/src/secp256k1/src/field_10x26_impl.h b/src/secp256k1/src/field_10x26_impl.h new file mode 100644 index 0000000..212cc53 --- /dev/null +++ b/src/secp256k1/src/field_10x26_impl.h @@ -0,0 +1,1138 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_REPR_IMPL_H_ +#define _SECP256K1_FIELD_REPR_IMPL_H_ + +#include +#include +#include "util.h" +#include "num.h" +#include "field.h" + +#ifdef VERIFY +static void secp256k1_fe_verify(const secp256k1_fe *a) { + const uint32_t *d = a->n; + int m = a->normalized ? 1 : 2 * a->magnitude, r = 1; + r &= (d[0] <= 0x3FFFFFFUL * m); + r &= (d[1] <= 0x3FFFFFFUL * m); + r &= (d[2] <= 0x3FFFFFFUL * m); + r &= (d[3] <= 0x3FFFFFFUL * m); + r &= (d[4] <= 0x3FFFFFFUL * m); + r &= (d[5] <= 0x3FFFFFFUL * m); + r &= (d[6] <= 0x3FFFFFFUL * m); + r &= (d[7] <= 0x3FFFFFFUL * m); + r &= (d[8] <= 0x3FFFFFFUL * m); + r &= (d[9] <= 0x03FFFFFUL * m); + r &= (a->magnitude >= 0); + r &= (a->magnitude <= 32); + if (a->normalized) { + r &= (a->magnitude <= 1); + if (r && (d[9] == 0x03FFFFFUL)) { + uint32_t mid = d[8] & d[7] & d[6] & d[5] & d[4] & d[3] & d[2]; + if (mid == 0x3FFFFFFUL) { + r &= ((d[1] + 0x40UL + ((d[0] + 0x3D1UL) >> 26)) <= 0x3FFFFFFUL); + } + } + } + VERIFY_CHECK(r == 1); +} +#else +static void secp256k1_fe_verify(const secp256k1_fe *a) { + (void)a; +} +#endif + +static void secp256k1_fe_normalize(secp256k1_fe *r) { + uint32_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4], + t5 = r->n[5], t6 = r->n[6], t7 = r->n[7], t8 = r->n[8], t9 = r->n[9]; + + /* Reduce t9 at the start so there will be at most a single carry from the first pass */ + uint32_t m; + uint32_t x = t9 >> 22; t9 &= 0x03FFFFFUL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; m = t2; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; m &= t3; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; m &= t4; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; m &= t5; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; m &= t6; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; m &= t7; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; m &= t8; + + /* ... except for a possible carry at bit 22 of t9 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t9 >> 23 == 0); + + /* At most a single final reduction is needed; check if the value is >= the field characteristic */ + x = (t9 >> 22) | ((t9 == 0x03FFFFFUL) & (m == 0x3FFFFFFUL) + & ((t1 + 0x40UL + ((t0 + 0x3D1UL) >> 26)) > 0x3FFFFFFUL)); + + /* Apply the final reduction (for constant-time behaviour, we do it always) */ + t0 += x * 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; + + /* If t9 didn't carry to bit 22 already, then it should have after any final reduction */ + VERIFY_CHECK(t9 >> 22 == x); + + /* Mask off the possible multiple of 2^256 from the final reduction */ + t9 &= 0x03FFFFFUL; + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + r->n[5] = t5; r->n[6] = t6; r->n[7] = t7; r->n[8] = t8; r->n[9] = t9; + +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_normalize_weak(secp256k1_fe *r) { + uint32_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4], + t5 = r->n[5], t6 = r->n[6], t7 = r->n[7], t8 = r->n[8], t9 = r->n[9]; + + /* Reduce t9 at the start so there will be at most a single carry from the first pass */ + uint32_t x = t9 >> 22; t9 &= 0x03FFFFFUL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; + + /* ... except for a possible carry at bit 22 of t9 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t9 >> 23 == 0); + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + r->n[5] = t5; r->n[6] = t6; r->n[7] = t7; r->n[8] = t8; r->n[9] = t9; + +#ifdef VERIFY + r->magnitude = 1; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_normalize_var(secp256k1_fe *r) { + uint32_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4], + t5 = r->n[5], t6 = r->n[6], t7 = r->n[7], t8 = r->n[8], t9 = r->n[9]; + + /* Reduce t9 at the start so there will be at most a single carry from the first pass */ + uint32_t m; + uint32_t x = t9 >> 22; t9 &= 0x03FFFFFUL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; m = t2; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; m &= t3; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; m &= t4; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; m &= t5; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; m &= t6; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; m &= t7; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; m &= t8; + + /* ... except for a possible carry at bit 22 of t9 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t9 >> 23 == 0); + + /* At most a single final reduction is needed; check if the value is >= the field characteristic */ + x = (t9 >> 22) | ((t9 == 0x03FFFFFUL) & (m == 0x3FFFFFFUL) + & ((t1 + 0x40UL + ((t0 + 0x3D1UL) >> 26)) > 0x3FFFFFFUL)); + + if (x) { + t0 += 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; + + /* If t9 didn't carry to bit 22 already, then it should have after any final reduction */ + VERIFY_CHECK(t9 >> 22 == x); + + /* Mask off the possible multiple of 2^256 from the final reduction */ + t9 &= 0x03FFFFFUL; + } + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + r->n[5] = t5; r->n[6] = t6; r->n[7] = t7; r->n[8] = t8; r->n[9] = t9; + +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +static int secp256k1_fe_normalizes_to_zero(secp256k1_fe *r) { + uint32_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4], + t5 = r->n[5], t6 = r->n[6], t7 = r->n[7], t8 = r->n[8], t9 = r->n[9]; + + /* z0 tracks a possible raw value of 0, z1 tracks a possible raw value of P */ + uint32_t z0, z1; + + /* Reduce t9 at the start so there will be at most a single carry from the first pass */ + uint32_t x = t9 >> 22; t9 &= 0x03FFFFFUL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x3D1UL; t1 += (x << 6); + t1 += (t0 >> 26); t0 &= 0x3FFFFFFUL; z0 = t0; z1 = t0 ^ 0x3D0UL; + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; z0 |= t1; z1 &= t1 ^ 0x40UL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; z0 |= t2; z1 &= t2; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; z0 |= t3; z1 &= t3; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; z0 |= t4; z1 &= t4; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; z0 |= t5; z1 &= t5; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; z0 |= t6; z1 &= t6; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; z0 |= t7; z1 &= t7; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; z0 |= t8; z1 &= t8; + z0 |= t9; z1 &= t9 ^ 0x3C00000UL; + + /* ... except for a possible carry at bit 22 of t9 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t9 >> 23 == 0); + + return (z0 == 0) | (z1 == 0x3FFFFFFUL); +} + +static int secp256k1_fe_normalizes_to_zero_var(secp256k1_fe *r) { + uint32_t t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; + uint32_t z0, z1; + uint32_t x; + + t0 = r->n[0]; + t9 = r->n[9]; + + /* Reduce t9 at the start so there will be at most a single carry from the first pass */ + x = t9 >> 22; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x3D1UL; + + /* z0 tracks a possible raw value of 0, z1 tracks a possible raw value of P */ + z0 = t0 & 0x3FFFFFFUL; + z1 = z0 ^ 0x3D0UL; + + /* Fast return path should catch the majority of cases */ + if ((z0 != 0UL) & (z1 != 0x3FFFFFFUL)) { + return 0; + } + + t1 = r->n[1]; + t2 = r->n[2]; + t3 = r->n[3]; + t4 = r->n[4]; + t5 = r->n[5]; + t6 = r->n[6]; + t7 = r->n[7]; + t8 = r->n[8]; + + t9 &= 0x03FFFFFUL; + t1 += (x << 6); + + t1 += (t0 >> 26); + t2 += (t1 >> 26); t1 &= 0x3FFFFFFUL; z0 |= t1; z1 &= t1 ^ 0x40UL; + t3 += (t2 >> 26); t2 &= 0x3FFFFFFUL; z0 |= t2; z1 &= t2; + t4 += (t3 >> 26); t3 &= 0x3FFFFFFUL; z0 |= t3; z1 &= t3; + t5 += (t4 >> 26); t4 &= 0x3FFFFFFUL; z0 |= t4; z1 &= t4; + t6 += (t5 >> 26); t5 &= 0x3FFFFFFUL; z0 |= t5; z1 &= t5; + t7 += (t6 >> 26); t6 &= 0x3FFFFFFUL; z0 |= t6; z1 &= t6; + t8 += (t7 >> 26); t7 &= 0x3FFFFFFUL; z0 |= t7; z1 &= t7; + t9 += (t8 >> 26); t8 &= 0x3FFFFFFUL; z0 |= t8; z1 &= t8; + z0 |= t9; z1 &= t9 ^ 0x3C00000UL; + + /* ... except for a possible carry at bit 22 of t9 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t9 >> 23 == 0); + + return (z0 == 0) | (z1 == 0x3FFFFFFUL); +} + +SECP256K1_INLINE static void secp256k1_fe_set_int(secp256k1_fe *r, int a) { + r->n[0] = a; + r->n[1] = r->n[2] = r->n[3] = r->n[4] = r->n[5] = r->n[6] = r->n[7] = r->n[8] = r->n[9] = 0; +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static int secp256k1_fe_is_zero(const secp256k1_fe *a) { + const uint32_t *t = a->n; +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + return (t[0] | t[1] | t[2] | t[3] | t[4] | t[5] | t[6] | t[7] | t[8] | t[9]) == 0; +} + +SECP256K1_INLINE static int secp256k1_fe_is_odd(const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + return a->n[0] & 1; +} + +SECP256K1_INLINE static void secp256k1_fe_clear(secp256k1_fe *a) { + int i; +#ifdef VERIFY + a->magnitude = 0; + a->normalized = 1; +#endif + for (i=0; i<10; i++) { + a->n[i] = 0; + } +} + +static int secp256k1_fe_cmp_var(const secp256k1_fe *a, const secp256k1_fe *b) { + int i; +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + VERIFY_CHECK(b->normalized); + secp256k1_fe_verify(a); + secp256k1_fe_verify(b); +#endif + for (i = 9; i >= 0; i--) { + if (a->n[i] > b->n[i]) { + return 1; + } + if (a->n[i] < b->n[i]) { + return -1; + } + } + return 0; +} + +static int secp256k1_fe_set_b32(secp256k1_fe *r, const unsigned char *a) { + int i; + r->n[0] = r->n[1] = r->n[2] = r->n[3] = r->n[4] = 0; + r->n[5] = r->n[6] = r->n[7] = r->n[8] = r->n[9] = 0; + for (i=0; i<32; i++) { + int j; + for (j=0; j<4; j++) { + int limb = (8*i+2*j)/26; + int shift = (8*i+2*j)%26; + r->n[limb] |= (uint32_t)((a[31-i] >> (2*j)) & 0x3) << shift; + } + } + if (r->n[9] == 0x3FFFFFUL && (r->n[8] & r->n[7] & r->n[6] & r->n[5] & r->n[4] & r->n[3] & r->n[2]) == 0x3FFFFFFUL && (r->n[1] + 0x40UL + ((r->n[0] + 0x3D1UL) >> 26)) > 0x3FFFFFFUL) { + return 0; + } +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif + return 1; +} + +/** Convert a field element to a 32-byte big endian value. Requires the input to be normalized */ +static void secp256k1_fe_get_b32(unsigned char *r, const secp256k1_fe *a) { + int i; +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + for (i=0; i<32; i++) { + int j; + int c = 0; + for (j=0; j<4; j++) { + int limb = (8*i+2*j)/26; + int shift = (8*i+2*j)%26; + c |= ((a->n[limb] >> shift) & 0x3) << (2 * j); + } + r[31-i] = c; + } +} + +SECP256K1_INLINE static void secp256k1_fe_negate(secp256k1_fe *r, const secp256k1_fe *a, int m) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= m); + secp256k1_fe_verify(a); +#endif + r->n[0] = 0x3FFFC2FUL * 2 * (m + 1) - a->n[0]; + r->n[1] = 0x3FFFFBFUL * 2 * (m + 1) - a->n[1]; + r->n[2] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[2]; + r->n[3] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[3]; + r->n[4] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[4]; + r->n[5] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[5]; + r->n[6] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[6]; + r->n[7] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[7]; + r->n[8] = 0x3FFFFFFUL * 2 * (m + 1) - a->n[8]; + r->n[9] = 0x03FFFFFUL * 2 * (m + 1) - a->n[9]; +#ifdef VERIFY + r->magnitude = m + 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static void secp256k1_fe_mul_int(secp256k1_fe *r, int a) { + r->n[0] *= a; + r->n[1] *= a; + r->n[2] *= a; + r->n[3] *= a; + r->n[4] *= a; + r->n[5] *= a; + r->n[6] *= a; + r->n[7] *= a; + r->n[8] *= a; + r->n[9] *= a; +#ifdef VERIFY + r->magnitude *= a; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static void secp256k1_fe_add(secp256k1_fe *r, const secp256k1_fe *a) { +#ifdef VERIFY + secp256k1_fe_verify(a); +#endif + r->n[0] += a->n[0]; + r->n[1] += a->n[1]; + r->n[2] += a->n[2]; + r->n[3] += a->n[3]; + r->n[4] += a->n[4]; + r->n[5] += a->n[5]; + r->n[6] += a->n[6]; + r->n[7] += a->n[7]; + r->n[8] += a->n[8]; + r->n[9] += a->n[9]; +#ifdef VERIFY + r->magnitude += a->magnitude; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +#ifdef VERIFY +#define VERIFY_BITS(x, n) VERIFY_CHECK(((x) >> (n)) == 0) +#else +#define VERIFY_BITS(x, n) do { } while(0) +#endif + +SECP256K1_INLINE static void secp256k1_fe_mul_inner(uint32_t *r, const uint32_t *a, const uint32_t * SECP256K1_RESTRICT b) { + uint64_t c, d; + uint64_t u0, u1, u2, u3, u4, u5, u6, u7, u8; + uint32_t t9, t1, t0, t2, t3, t4, t5, t6, t7; + const uint32_t M = 0x3FFFFFFUL, R0 = 0x3D10UL, R1 = 0x400UL; + + VERIFY_BITS(a[0], 30); + VERIFY_BITS(a[1], 30); + VERIFY_BITS(a[2], 30); + VERIFY_BITS(a[3], 30); + VERIFY_BITS(a[4], 30); + VERIFY_BITS(a[5], 30); + VERIFY_BITS(a[6], 30); + VERIFY_BITS(a[7], 30); + VERIFY_BITS(a[8], 30); + VERIFY_BITS(a[9], 26); + VERIFY_BITS(b[0], 30); + VERIFY_BITS(b[1], 30); + VERIFY_BITS(b[2], 30); + VERIFY_BITS(b[3], 30); + VERIFY_BITS(b[4], 30); + VERIFY_BITS(b[5], 30); + VERIFY_BITS(b[6], 30); + VERIFY_BITS(b[7], 30); + VERIFY_BITS(b[8], 30); + VERIFY_BITS(b[9], 26); + + /** [... a b c] is a shorthand for ... + a<<52 + b<<26 + c<<0 mod n. + * px is a shorthand for sum(a[i]*b[x-i], i=0..x). + * Note that [x 0 0 0 0 0 0 0 0 0 0] = [x*R1 x*R0]. + */ + + d = (uint64_t)a[0] * b[9] + + (uint64_t)a[1] * b[8] + + (uint64_t)a[2] * b[7] + + (uint64_t)a[3] * b[6] + + (uint64_t)a[4] * b[5] + + (uint64_t)a[5] * b[4] + + (uint64_t)a[6] * b[3] + + (uint64_t)a[7] * b[2] + + (uint64_t)a[8] * b[1] + + (uint64_t)a[9] * b[0]; + /* VERIFY_BITS(d, 64); */ + /* [d 0 0 0 0 0 0 0 0 0] = [p9 0 0 0 0 0 0 0 0 0] */ + t9 = d & M; d >>= 26; + VERIFY_BITS(t9, 26); + VERIFY_BITS(d, 38); + /* [d t9 0 0 0 0 0 0 0 0 0] = [p9 0 0 0 0 0 0 0 0 0] */ + + c = (uint64_t)a[0] * b[0]; + VERIFY_BITS(c, 60); + /* [d t9 0 0 0 0 0 0 0 0 c] = [p9 0 0 0 0 0 0 0 0 p0] */ + d += (uint64_t)a[1] * b[9] + + (uint64_t)a[2] * b[8] + + (uint64_t)a[3] * b[7] + + (uint64_t)a[4] * b[6] + + (uint64_t)a[5] * b[5] + + (uint64_t)a[6] * b[4] + + (uint64_t)a[7] * b[3] + + (uint64_t)a[8] * b[2] + + (uint64_t)a[9] * b[1]; + VERIFY_BITS(d, 63); + /* [d t9 0 0 0 0 0 0 0 0 c] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + u0 = d & M; d >>= 26; c += u0 * R0; + VERIFY_BITS(u0, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 61); + /* [d u0 t9 0 0 0 0 0 0 0 0 c-u0*R0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + t0 = c & M; c >>= 26; c += u0 * R1; + VERIFY_BITS(t0, 26); + VERIFY_BITS(c, 37); + /* [d u0 t9 0 0 0 0 0 0 0 c-u0*R1 t0-u0*R0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + + c += (uint64_t)a[0] * b[1] + + (uint64_t)a[1] * b[0]; + VERIFY_BITS(c, 62); + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p10 p9 0 0 0 0 0 0 0 p1 p0] */ + d += (uint64_t)a[2] * b[9] + + (uint64_t)a[3] * b[8] + + (uint64_t)a[4] * b[7] + + (uint64_t)a[5] * b[6] + + (uint64_t)a[6] * b[5] + + (uint64_t)a[7] * b[4] + + (uint64_t)a[8] * b[3] + + (uint64_t)a[9] * b[2]; + VERIFY_BITS(d, 63); + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + u1 = d & M; d >>= 26; c += u1 * R0; + VERIFY_BITS(u1, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 63); + /* [d u1 0 t9 0 0 0 0 0 0 0 c-u1*R0 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + t1 = c & M; c >>= 26; c += u1 * R1; + VERIFY_BITS(t1, 26); + VERIFY_BITS(c, 38); + /* [d u1 0 t9 0 0 0 0 0 0 c-u1*R1 t1-u1*R0 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + + c += (uint64_t)a[0] * b[2] + + (uint64_t)a[1] * b[1] + + (uint64_t)a[2] * b[0]; + VERIFY_BITS(c, 62); + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + d += (uint64_t)a[3] * b[9] + + (uint64_t)a[4] * b[8] + + (uint64_t)a[5] * b[7] + + (uint64_t)a[6] * b[6] + + (uint64_t)a[7] * b[5] + + (uint64_t)a[8] * b[4] + + (uint64_t)a[9] * b[3]; + VERIFY_BITS(d, 63); + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + u2 = d & M; d >>= 26; c += u2 * R0; + VERIFY_BITS(u2, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 63); + /* [d u2 0 0 t9 0 0 0 0 0 0 c-u2*R0 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + t2 = c & M; c >>= 26; c += u2 * R1; + VERIFY_BITS(t2, 26); + VERIFY_BITS(c, 38); + /* [d u2 0 0 t9 0 0 0 0 0 c-u2*R1 t2-u2*R0 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[3] + + (uint64_t)a[1] * b[2] + + (uint64_t)a[2] * b[1] + + (uint64_t)a[3] * b[0]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + d += (uint64_t)a[4] * b[9] + + (uint64_t)a[5] * b[8] + + (uint64_t)a[6] * b[7] + + (uint64_t)a[7] * b[6] + + (uint64_t)a[8] * b[5] + + (uint64_t)a[9] * b[4]; + VERIFY_BITS(d, 63); + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + u3 = d & M; d >>= 26; c += u3 * R0; + VERIFY_BITS(u3, 26); + VERIFY_BITS(d, 37); + /* VERIFY_BITS(c, 64); */ + /* [d u3 0 0 0 t9 0 0 0 0 0 c-u3*R0 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + t3 = c & M; c >>= 26; c += u3 * R1; + VERIFY_BITS(t3, 26); + VERIFY_BITS(c, 39); + /* [d u3 0 0 0 t9 0 0 0 0 c-u3*R1 t3-u3*R0 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[4] + + (uint64_t)a[1] * b[3] + + (uint64_t)a[2] * b[2] + + (uint64_t)a[3] * b[1] + + (uint64_t)a[4] * b[0]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[5] * b[9] + + (uint64_t)a[6] * b[8] + + (uint64_t)a[7] * b[7] + + (uint64_t)a[8] * b[6] + + (uint64_t)a[9] * b[5]; + VERIFY_BITS(d, 62); + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + u4 = d & M; d >>= 26; c += u4 * R0; + VERIFY_BITS(u4, 26); + VERIFY_BITS(d, 36); + /* VERIFY_BITS(c, 64); */ + /* [d u4 0 0 0 0 t9 0 0 0 0 c-u4*R0 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + t4 = c & M; c >>= 26; c += u4 * R1; + VERIFY_BITS(t4, 26); + VERIFY_BITS(c, 39); + /* [d u4 0 0 0 0 t9 0 0 0 c-u4*R1 t4-u4*R0 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[5] + + (uint64_t)a[1] * b[4] + + (uint64_t)a[2] * b[3] + + (uint64_t)a[3] * b[2] + + (uint64_t)a[4] * b[1] + + (uint64_t)a[5] * b[0]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[6] * b[9] + + (uint64_t)a[7] * b[8] + + (uint64_t)a[8] * b[7] + + (uint64_t)a[9] * b[6]; + VERIFY_BITS(d, 62); + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + u5 = d & M; d >>= 26; c += u5 * R0; + VERIFY_BITS(u5, 26); + VERIFY_BITS(d, 36); + /* VERIFY_BITS(c, 64); */ + /* [d u5 0 0 0 0 0 t9 0 0 0 c-u5*R0 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + t5 = c & M; c >>= 26; c += u5 * R1; + VERIFY_BITS(t5, 26); + VERIFY_BITS(c, 39); + /* [d u5 0 0 0 0 0 t9 0 0 c-u5*R1 t5-u5*R0 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[6] + + (uint64_t)a[1] * b[5] + + (uint64_t)a[2] * b[4] + + (uint64_t)a[3] * b[3] + + (uint64_t)a[4] * b[2] + + (uint64_t)a[5] * b[1] + + (uint64_t)a[6] * b[0]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[7] * b[9] + + (uint64_t)a[8] * b[8] + + (uint64_t)a[9] * b[7]; + VERIFY_BITS(d, 61); + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + u6 = d & M; d >>= 26; c += u6 * R0; + VERIFY_BITS(u6, 26); + VERIFY_BITS(d, 35); + /* VERIFY_BITS(c, 64); */ + /* [d u6 0 0 0 0 0 0 t9 0 0 c-u6*R0 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + t6 = c & M; c >>= 26; c += u6 * R1; + VERIFY_BITS(t6, 26); + VERIFY_BITS(c, 39); + /* [d u6 0 0 0 0 0 0 t9 0 c-u6*R1 t6-u6*R0 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[7] + + (uint64_t)a[1] * b[6] + + (uint64_t)a[2] * b[5] + + (uint64_t)a[3] * b[4] + + (uint64_t)a[4] * b[3] + + (uint64_t)a[5] * b[2] + + (uint64_t)a[6] * b[1] + + (uint64_t)a[7] * b[0]; + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x8000007C00000007ULL); + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[8] * b[9] + + (uint64_t)a[9] * b[8]; + VERIFY_BITS(d, 58); + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + u7 = d & M; d >>= 26; c += u7 * R0; + VERIFY_BITS(u7, 26); + VERIFY_BITS(d, 32); + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x800001703FFFC2F7ULL); + /* [d u7 0 0 0 0 0 0 0 t9 0 c-u7*R0 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + t7 = c & M; c >>= 26; c += u7 * R1; + VERIFY_BITS(t7, 26); + VERIFY_BITS(c, 38); + /* [d u7 0 0 0 0 0 0 0 t9 c-u7*R1 t7-u7*R0 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)a[0] * b[8] + + (uint64_t)a[1] * b[7] + + (uint64_t)a[2] * b[6] + + (uint64_t)a[3] * b[5] + + (uint64_t)a[4] * b[4] + + (uint64_t)a[5] * b[3] + + (uint64_t)a[6] * b[2] + + (uint64_t)a[7] * b[1] + + (uint64_t)a[8] * b[0]; + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x9000007B80000008ULL); + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[9] * b[9]; + VERIFY_BITS(d, 57); + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + u8 = d & M; d >>= 26; c += u8 * R0; + VERIFY_BITS(u8, 26); + VERIFY_BITS(d, 31); + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x9000016FBFFFC2F8ULL); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 t4 t3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + r[3] = t3; + VERIFY_BITS(r[3], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 t4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[4] = t4; + VERIFY_BITS(r[4], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[5] = t5; + VERIFY_BITS(r[5], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[6] = t6; + VERIFY_BITS(r[6], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[7] = t7; + VERIFY_BITS(r[7], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + r[8] = c & M; c >>= 26; c += u8 * R1; + VERIFY_BITS(r[8], 26); + VERIFY_BITS(c, 39); + /* [d u8 0 0 0 0 0 0 0 0 t9+c-u8*R1 r8-u8*R0 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 0 0 t9+c r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += d * R0 + t9; + VERIFY_BITS(c, 45); + /* [d 0 0 0 0 0 0 0 0 0 c-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[9] = c & (M >> 4); c >>= 22; c += d * (R1 << 4); + VERIFY_BITS(r[9], 22); + VERIFY_BITS(c, 46); + /* [d 0 0 0 0 0 0 0 0 r9+((c-d*R1<<4)<<22)-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 -d*R1 r9+(c<<22)-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + d = c * (R0 >> 4) + t0; + VERIFY_BITS(d, 56); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1 d-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[0] = d & M; d >>= 26; + VERIFY_BITS(r[0], 26); + VERIFY_BITS(d, 30); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1+d r0-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += c * (R1 >> 4) + t1; + VERIFY_BITS(d, 53); + VERIFY_CHECK(d <= 0x10000003FFFFBFULL); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 d-c*R1>>4 r0-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [r9 r8 r7 r6 r5 r4 r3 t2 d r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[1] = d & M; d >>= 26; + VERIFY_BITS(r[1], 26); + VERIFY_BITS(d, 27); + VERIFY_CHECK(d <= 0x4000000ULL); + /* [r9 r8 r7 r6 r5 r4 r3 t2+d r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += t2; + VERIFY_BITS(d, 27); + /* [r9 r8 r7 r6 r5 r4 r3 d r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[2] = d; + VERIFY_BITS(r[2], 27); + /* [r9 r8 r7 r6 r5 r4 r3 r2 r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ +} + +SECP256K1_INLINE static void secp256k1_fe_sqr_inner(uint32_t *r, const uint32_t *a) { + uint64_t c, d; + uint64_t u0, u1, u2, u3, u4, u5, u6, u7, u8; + uint32_t t9, t0, t1, t2, t3, t4, t5, t6, t7; + const uint32_t M = 0x3FFFFFFUL, R0 = 0x3D10UL, R1 = 0x400UL; + + VERIFY_BITS(a[0], 30); + VERIFY_BITS(a[1], 30); + VERIFY_BITS(a[2], 30); + VERIFY_BITS(a[3], 30); + VERIFY_BITS(a[4], 30); + VERIFY_BITS(a[5], 30); + VERIFY_BITS(a[6], 30); + VERIFY_BITS(a[7], 30); + VERIFY_BITS(a[8], 30); + VERIFY_BITS(a[9], 26); + + /** [... a b c] is a shorthand for ... + a<<52 + b<<26 + c<<0 mod n. + * px is a shorthand for sum(a[i]*a[x-i], i=0..x). + * Note that [x 0 0 0 0 0 0 0 0 0 0] = [x*R1 x*R0]. + */ + + d = (uint64_t)(a[0]*2) * a[9] + + (uint64_t)(a[1]*2) * a[8] + + (uint64_t)(a[2]*2) * a[7] + + (uint64_t)(a[3]*2) * a[6] + + (uint64_t)(a[4]*2) * a[5]; + /* VERIFY_BITS(d, 64); */ + /* [d 0 0 0 0 0 0 0 0 0] = [p9 0 0 0 0 0 0 0 0 0] */ + t9 = d & M; d >>= 26; + VERIFY_BITS(t9, 26); + VERIFY_BITS(d, 38); + /* [d t9 0 0 0 0 0 0 0 0 0] = [p9 0 0 0 0 0 0 0 0 0] */ + + c = (uint64_t)a[0] * a[0]; + VERIFY_BITS(c, 60); + /* [d t9 0 0 0 0 0 0 0 0 c] = [p9 0 0 0 0 0 0 0 0 p0] */ + d += (uint64_t)(a[1]*2) * a[9] + + (uint64_t)(a[2]*2) * a[8] + + (uint64_t)(a[3]*2) * a[7] + + (uint64_t)(a[4]*2) * a[6] + + (uint64_t)a[5] * a[5]; + VERIFY_BITS(d, 63); + /* [d t9 0 0 0 0 0 0 0 0 c] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + u0 = d & M; d >>= 26; c += u0 * R0; + VERIFY_BITS(u0, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 61); + /* [d u0 t9 0 0 0 0 0 0 0 0 c-u0*R0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + t0 = c & M; c >>= 26; c += u0 * R1; + VERIFY_BITS(t0, 26); + VERIFY_BITS(c, 37); + /* [d u0 t9 0 0 0 0 0 0 0 c-u0*R1 t0-u0*R0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p10 p9 0 0 0 0 0 0 0 0 p0] */ + + c += (uint64_t)(a[0]*2) * a[1]; + VERIFY_BITS(c, 62); + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p10 p9 0 0 0 0 0 0 0 p1 p0] */ + d += (uint64_t)(a[2]*2) * a[9] + + (uint64_t)(a[3]*2) * a[8] + + (uint64_t)(a[4]*2) * a[7] + + (uint64_t)(a[5]*2) * a[6]; + VERIFY_BITS(d, 63); + /* [d 0 t9 0 0 0 0 0 0 0 c t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + u1 = d & M; d >>= 26; c += u1 * R0; + VERIFY_BITS(u1, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 63); + /* [d u1 0 t9 0 0 0 0 0 0 0 c-u1*R0 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + t1 = c & M; c >>= 26; c += u1 * R1; + VERIFY_BITS(t1, 26); + VERIFY_BITS(c, 38); + /* [d u1 0 t9 0 0 0 0 0 0 c-u1*R1 t1-u1*R0 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p11 p10 p9 0 0 0 0 0 0 0 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[2] + + (uint64_t)a[1] * a[1]; + VERIFY_BITS(c, 62); + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + d += (uint64_t)(a[3]*2) * a[9] + + (uint64_t)(a[4]*2) * a[8] + + (uint64_t)(a[5]*2) * a[7] + + (uint64_t)a[6] * a[6]; + VERIFY_BITS(d, 63); + /* [d 0 0 t9 0 0 0 0 0 0 c t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + u2 = d & M; d >>= 26; c += u2 * R0; + VERIFY_BITS(u2, 26); + VERIFY_BITS(d, 37); + VERIFY_BITS(c, 63); + /* [d u2 0 0 t9 0 0 0 0 0 0 c-u2*R0 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + t2 = c & M; c >>= 26; c += u2 * R1; + VERIFY_BITS(t2, 26); + VERIFY_BITS(c, 38); + /* [d u2 0 0 t9 0 0 0 0 0 c-u2*R1 t2-u2*R0 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 0 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[3] + + (uint64_t)(a[1]*2) * a[2]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + d += (uint64_t)(a[4]*2) * a[9] + + (uint64_t)(a[5]*2) * a[8] + + (uint64_t)(a[6]*2) * a[7]; + VERIFY_BITS(d, 63); + /* [d 0 0 0 t9 0 0 0 0 0 c t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + u3 = d & M; d >>= 26; c += u3 * R0; + VERIFY_BITS(u3, 26); + VERIFY_BITS(d, 37); + /* VERIFY_BITS(c, 64); */ + /* [d u3 0 0 0 t9 0 0 0 0 0 c-u3*R0 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + t3 = c & M; c >>= 26; c += u3 * R1; + VERIFY_BITS(t3, 26); + VERIFY_BITS(c, 39); + /* [d u3 0 0 0 t9 0 0 0 0 c-u3*R1 t3-u3*R0 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 0 p3 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[4] + + (uint64_t)(a[1]*2) * a[3] + + (uint64_t)a[2] * a[2]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + d += (uint64_t)(a[5]*2) * a[9] + + (uint64_t)(a[6]*2) * a[8] + + (uint64_t)a[7] * a[7]; + VERIFY_BITS(d, 62); + /* [d 0 0 0 0 t9 0 0 0 0 c t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + u4 = d & M; d >>= 26; c += u4 * R0; + VERIFY_BITS(u4, 26); + VERIFY_BITS(d, 36); + /* VERIFY_BITS(c, 64); */ + /* [d u4 0 0 0 0 t9 0 0 0 0 c-u4*R0 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + t4 = c & M; c >>= 26; c += u4 * R1; + VERIFY_BITS(t4, 26); + VERIFY_BITS(c, 39); + /* [d u4 0 0 0 0 t9 0 0 0 c-u4*R1 t4-u4*R0 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 0 p4 p3 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[5] + + (uint64_t)(a[1]*2) * a[4] + + (uint64_t)(a[2]*2) * a[3]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)(a[6]*2) * a[9] + + (uint64_t)(a[7]*2) * a[8]; + VERIFY_BITS(d, 62); + /* [d 0 0 0 0 0 t9 0 0 0 c t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + u5 = d & M; d >>= 26; c += u5 * R0; + VERIFY_BITS(u5, 26); + VERIFY_BITS(d, 36); + /* VERIFY_BITS(c, 64); */ + /* [d u5 0 0 0 0 0 t9 0 0 0 c-u5*R0 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + t5 = c & M; c >>= 26; c += u5 * R1; + VERIFY_BITS(t5, 26); + VERIFY_BITS(c, 39); + /* [d u5 0 0 0 0 0 t9 0 0 c-u5*R1 t5-u5*R0 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 0 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[6] + + (uint64_t)(a[1]*2) * a[5] + + (uint64_t)(a[2]*2) * a[4] + + (uint64_t)a[3] * a[3]; + VERIFY_BITS(c, 63); + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)(a[7]*2) * a[9] + + (uint64_t)a[8] * a[8]; + VERIFY_BITS(d, 61); + /* [d 0 0 0 0 0 0 t9 0 0 c t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + u6 = d & M; d >>= 26; c += u6 * R0; + VERIFY_BITS(u6, 26); + VERIFY_BITS(d, 35); + /* VERIFY_BITS(c, 64); */ + /* [d u6 0 0 0 0 0 0 t9 0 0 c-u6*R0 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + t6 = c & M; c >>= 26; c += u6 * R1; + VERIFY_BITS(t6, 26); + VERIFY_BITS(c, 39); + /* [d u6 0 0 0 0 0 0 t9 0 c-u6*R1 t6-u6*R0 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 0 p6 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[7] + + (uint64_t)(a[1]*2) * a[6] + + (uint64_t)(a[2]*2) * a[5] + + (uint64_t)(a[3]*2) * a[4]; + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x8000007C00000007ULL); + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)(a[8]*2) * a[9]; + VERIFY_BITS(d, 58); + /* [d 0 0 0 0 0 0 0 t9 0 c t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + u7 = d & M; d >>= 26; c += u7 * R0; + VERIFY_BITS(u7, 26); + VERIFY_BITS(d, 32); + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x800001703FFFC2F7ULL); + /* [d u7 0 0 0 0 0 0 0 t9 0 c-u7*R0 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + t7 = c & M; c >>= 26; c += u7 * R1; + VERIFY_BITS(t7, 26); + VERIFY_BITS(c, 38); + /* [d u7 0 0 0 0 0 0 0 t9 c-u7*R1 t7-u7*R0 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 0 p7 p6 p5 p4 p3 p2 p1 p0] */ + + c += (uint64_t)(a[0]*2) * a[8] + + (uint64_t)(a[1]*2) * a[7] + + (uint64_t)(a[2]*2) * a[6] + + (uint64_t)(a[3]*2) * a[5] + + (uint64_t)a[4] * a[4]; + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x9000007B80000008ULL); + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint64_t)a[9] * a[9]; + VERIFY_BITS(d, 57); + /* [d 0 0 0 0 0 0 0 0 t9 c t7 t6 t5 t4 t3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + u8 = d & M; d >>= 26; c += u8 * R0; + VERIFY_BITS(u8, 26); + VERIFY_BITS(d, 31); + /* VERIFY_BITS(c, 64); */ + VERIFY_CHECK(c <= 0x9000016FBFFFC2F8ULL); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 t4 t3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + r[3] = t3; + VERIFY_BITS(r[3], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 t4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[4] = t4; + VERIFY_BITS(r[4], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 t5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[5] = t5; + VERIFY_BITS(r[5], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 t6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[6] = t6; + VERIFY_BITS(r[6], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 t7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[7] = t7; + VERIFY_BITS(r[7], 26); + /* [d u8 0 0 0 0 0 0 0 0 t9 c-u8*R0 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + r[8] = c & M; c >>= 26; c += u8 * R1; + VERIFY_BITS(r[8], 26); + VERIFY_BITS(c, 39); + /* [d u8 0 0 0 0 0 0 0 0 t9+c-u8*R1 r8-u8*R0 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 0 0 t9+c r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += d * R0 + t9; + VERIFY_BITS(c, 45); + /* [d 0 0 0 0 0 0 0 0 0 c-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[9] = c & (M >> 4); c >>= 22; c += d * (R1 << 4); + VERIFY_BITS(r[9], 22); + VERIFY_BITS(c, 46); + /* [d 0 0 0 0 0 0 0 0 r9+((c-d*R1<<4)<<22)-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [d 0 0 0 0 0 0 0 -d*R1 r9+(c<<22)-d*R0 r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1 t0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + d = c * (R0 >> 4) + t0; + VERIFY_BITS(d, 56); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1 d-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[0] = d & M; d >>= 26; + VERIFY_BITS(r[0], 26); + VERIFY_BITS(d, 30); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 t1+d r0-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += c * (R1 >> 4) + t1; + VERIFY_BITS(d, 53); + VERIFY_CHECK(d <= 0x10000003FFFFBFULL); + /* [r9+(c<<22) r8 r7 r6 r5 r4 r3 t2 d-c*R1>>4 r0-c*R0>>4] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + /* [r9 r8 r7 r6 r5 r4 r3 t2 d r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[1] = d & M; d >>= 26; + VERIFY_BITS(r[1], 26); + VERIFY_BITS(d, 27); + VERIFY_CHECK(d <= 0x4000000ULL); + /* [r9 r8 r7 r6 r5 r4 r3 t2+d r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + d += t2; + VERIFY_BITS(d, 27); + /* [r9 r8 r7 r6 r5 r4 r3 d r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[2] = d; + VERIFY_BITS(r[2], 27); + /* [r9 r8 r7 r6 r5 r4 r3 r2 r1 r0] = [p18 p17 p16 p15 p14 p13 p12 p11 p10 p9 p8 p7 p6 p5 p4 p3 p2 p1 p0] */ +} + + +static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp256k1_fe * SECP256K1_RESTRICT b) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= 8); + VERIFY_CHECK(b->magnitude <= 8); + secp256k1_fe_verify(a); + secp256k1_fe_verify(b); + VERIFY_CHECK(r != b); +#endif + secp256k1_fe_mul_inner(r->n, a->n, b->n); +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= 8); + secp256k1_fe_verify(a); +#endif + secp256k1_fe_sqr_inner(r->n, a->n); +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +static SECP256K1_INLINE void secp256k1_fe_cmov(secp256k1_fe *r, const secp256k1_fe *a, int flag) { + uint32_t mask0, mask1; + mask0 = flag + ~((uint32_t)0); + mask1 = ~mask0; + r->n[0] = (r->n[0] & mask0) | (a->n[0] & mask1); + r->n[1] = (r->n[1] & mask0) | (a->n[1] & mask1); + r->n[2] = (r->n[2] & mask0) | (a->n[2] & mask1); + r->n[3] = (r->n[3] & mask0) | (a->n[3] & mask1); + r->n[4] = (r->n[4] & mask0) | (a->n[4] & mask1); + r->n[5] = (r->n[5] & mask0) | (a->n[5] & mask1); + r->n[6] = (r->n[6] & mask0) | (a->n[6] & mask1); + r->n[7] = (r->n[7] & mask0) | (a->n[7] & mask1); + r->n[8] = (r->n[8] & mask0) | (a->n[8] & mask1); + r->n[9] = (r->n[9] & mask0) | (a->n[9] & mask1); +#ifdef VERIFY + if (a->magnitude > r->magnitude) { + r->magnitude = a->magnitude; + } + r->normalized &= a->normalized; +#endif +} + +static SECP256K1_INLINE void secp256k1_fe_storage_cmov(secp256k1_fe_storage *r, const secp256k1_fe_storage *a, int flag) { + uint32_t mask0, mask1; + mask0 = flag + ~((uint32_t)0); + mask1 = ~mask0; + r->n[0] = (r->n[0] & mask0) | (a->n[0] & mask1); + r->n[1] = (r->n[1] & mask0) | (a->n[1] & mask1); + r->n[2] = (r->n[2] & mask0) | (a->n[2] & mask1); + r->n[3] = (r->n[3] & mask0) | (a->n[3] & mask1); + r->n[4] = (r->n[4] & mask0) | (a->n[4] & mask1); + r->n[5] = (r->n[5] & mask0) | (a->n[5] & mask1); + r->n[6] = (r->n[6] & mask0) | (a->n[6] & mask1); + r->n[7] = (r->n[7] & mask0) | (a->n[7] & mask1); +} + +static void secp256k1_fe_to_storage(secp256k1_fe_storage *r, const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->normalized); +#endif + r->n[0] = a->n[0] | a->n[1] << 26; + r->n[1] = a->n[1] >> 6 | a->n[2] << 20; + r->n[2] = a->n[2] >> 12 | a->n[3] << 14; + r->n[3] = a->n[3] >> 18 | a->n[4] << 8; + r->n[4] = a->n[4] >> 24 | a->n[5] << 2 | a->n[6] << 28; + r->n[5] = a->n[6] >> 4 | a->n[7] << 22; + r->n[6] = a->n[7] >> 10 | a->n[8] << 16; + r->n[7] = a->n[8] >> 16 | a->n[9] << 10; +} + +static SECP256K1_INLINE void secp256k1_fe_from_storage(secp256k1_fe *r, const secp256k1_fe_storage *a) { + r->n[0] = a->n[0] & 0x3FFFFFFUL; + r->n[1] = a->n[0] >> 26 | ((a->n[1] << 6) & 0x3FFFFFFUL); + r->n[2] = a->n[1] >> 20 | ((a->n[2] << 12) & 0x3FFFFFFUL); + r->n[3] = a->n[2] >> 14 | ((a->n[3] << 18) & 0x3FFFFFFUL); + r->n[4] = a->n[3] >> 8 | ((a->n[4] << 24) & 0x3FFFFFFUL); + r->n[5] = (a->n[4] >> 2) & 0x3FFFFFFUL; + r->n[6] = a->n[4] >> 28 | ((a->n[5] << 4) & 0x3FFFFFFUL); + r->n[7] = a->n[5] >> 22 | ((a->n[6] << 10) & 0x3FFFFFFUL); + r->n[8] = a->n[6] >> 16 | ((a->n[7] << 16) & 0x3FFFFFFUL); + r->n[9] = a->n[7] >> 10; +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; +#endif +} + +#endif diff --git a/src/secp256k1/src/field_5x52.h b/src/secp256k1/src/field_5x52.h new file mode 100644 index 0000000..8e69a56 --- /dev/null +++ b/src/secp256k1/src/field_5x52.h @@ -0,0 +1,47 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_REPR_ +#define _SECP256K1_FIELD_REPR_ + +#include + +typedef struct { + /* X = sum(i=0..4, elem[i]*2^52) mod n */ + uint64_t n[5]; +#ifdef VERIFY + int magnitude; + int normalized; +#endif +} secp256k1_fe; + +/* Unpacks a constant into a overlapping multi-limbed FE element. */ +#define SECP256K1_FE_CONST_INNER(d7, d6, d5, d4, d3, d2, d1, d0) { \ + (d0) | (((uint64_t)(d1) & 0xFFFFFUL) << 32), \ + ((uint64_t)(d1) >> 20) | (((uint64_t)(d2)) << 12) | (((uint64_t)(d3) & 0xFFUL) << 44), \ + ((uint64_t)(d3) >> 8) | (((uint64_t)(d4) & 0xFFFFFFFUL) << 24), \ + ((uint64_t)(d4) >> 28) | (((uint64_t)(d5)) << 4) | (((uint64_t)(d6) & 0xFFFFUL) << 36), \ + ((uint64_t)(d6) >> 16) | (((uint64_t)(d7)) << 16) \ +} + +#ifdef VERIFY +#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)), 1, 1} +#else +#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0))} +#endif + +typedef struct { + uint64_t n[4]; +} secp256k1_fe_storage; + +#define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{ \ + (d0) | (((uint64_t)(d1)) << 32), \ + (d2) | (((uint64_t)(d3)) << 32), \ + (d4) | (((uint64_t)(d5)) << 32), \ + (d6) | (((uint64_t)(d7)) << 32) \ +}} + +#endif diff --git a/src/secp256k1/src/field_5x52_asm_impl.h b/src/secp256k1/src/field_5x52_asm_impl.h new file mode 100644 index 0000000..98cc004 --- /dev/null +++ b/src/secp256k1/src/field_5x52_asm_impl.h @@ -0,0 +1,502 @@ +/********************************************************************** + * Copyright (c) 2013-2014 Diederik Huys, Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +/** + * Changelog: + * - March 2013, Diederik Huys: original version + * - November 2014, Pieter Wuille: updated to use Peter Dettman's parallel multiplication algorithm + * - December 2014, Pieter Wuille: converted from YASM to GCC inline assembly + */ + +#ifndef _SECP256K1_FIELD_INNER5X52_IMPL_H_ +#define _SECP256K1_FIELD_INNER5X52_IMPL_H_ + +SECP256K1_INLINE static void secp256k1_fe_mul_inner(uint64_t *r, const uint64_t *a, const uint64_t * SECP256K1_RESTRICT b) { +/** + * Registers: rdx:rax = multiplication accumulator + * r9:r8 = c + * r15:rcx = d + * r10-r14 = a0-a4 + * rbx = b + * rdi = r + * rsi = a / t? + */ + uint64_t tmp1, tmp2, tmp3; +__asm__ __volatile__( + "movq 0(%%rsi),%%r10\n" + "movq 8(%%rsi),%%r11\n" + "movq 16(%%rsi),%%r12\n" + "movq 24(%%rsi),%%r13\n" + "movq 32(%%rsi),%%r14\n" + + /* d += a3 * b0 */ + "movq 0(%%rbx),%%rax\n" + "mulq %%r13\n" + "movq %%rax,%%rcx\n" + "movq %%rdx,%%r15\n" + /* d += a2 * b1 */ + "movq 8(%%rbx),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a1 * b2 */ + "movq 16(%%rbx),%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d = a0 * b3 */ + "movq 24(%%rbx),%%rax\n" + "mulq %%r10\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* c = a4 * b4 */ + "movq 32(%%rbx),%%rax\n" + "mulq %%r14\n" + "movq %%rax,%%r8\n" + "movq %%rdx,%%r9\n" + /* d += (c & M) * R */ + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* c >>= 52 (%%r8 only) */ + "shrdq $52,%%r9,%%r8\n" + /* t3 (tmp1) = d & M */ + "movq %%rcx,%%rsi\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rsi\n" + "movq %%rsi,%q1\n" + /* d >>= 52 */ + "shrdq $52,%%r15,%%rcx\n" + "xorq %%r15,%%r15\n" + /* d += a4 * b0 */ + "movq 0(%%rbx),%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a3 * b1 */ + "movq 8(%%rbx),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a2 * b2 */ + "movq 16(%%rbx),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a1 * b3 */ + "movq 24(%%rbx),%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a0 * b4 */ + "movq 32(%%rbx),%%rax\n" + "mulq %%r10\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += c * R */ + "movq %%r8,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* t4 = d & M (%%rsi) */ + "movq %%rcx,%%rsi\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rsi\n" + /* d >>= 52 */ + "shrdq $52,%%r15,%%rcx\n" + "xorq %%r15,%%r15\n" + /* tx = t4 >> 48 (tmp3) */ + "movq %%rsi,%%rax\n" + "shrq $48,%%rax\n" + "movq %%rax,%q3\n" + /* t4 &= (M >> 4) (tmp2) */ + "movq $0xffffffffffff,%%rax\n" + "andq %%rax,%%rsi\n" + "movq %%rsi,%q2\n" + /* c = a0 * b0 */ + "movq 0(%%rbx),%%rax\n" + "mulq %%r10\n" + "movq %%rax,%%r8\n" + "movq %%rdx,%%r9\n" + /* d += a4 * b1 */ + "movq 8(%%rbx),%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a3 * b2 */ + "movq 16(%%rbx),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a2 * b3 */ + "movq 24(%%rbx),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a1 * b4 */ + "movq 32(%%rbx),%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* u0 = d & M (%%rsi) */ + "movq %%rcx,%%rsi\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rsi\n" + /* d >>= 52 */ + "shrdq $52,%%r15,%%rcx\n" + "xorq %%r15,%%r15\n" + /* u0 = (u0 << 4) | tx (%%rsi) */ + "shlq $4,%%rsi\n" + "movq %q3,%%rax\n" + "orq %%rax,%%rsi\n" + /* c += u0 * (R >> 4) */ + "movq $0x1000003d1,%%rax\n" + "mulq %%rsi\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* r[0] = c & M */ + "movq %%r8,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq %%rax,0(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* c += a1 * b0 */ + "movq 0(%%rbx),%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* c += a0 * b1 */ + "movq 8(%%rbx),%%rax\n" + "mulq %%r10\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d += a4 * b2 */ + "movq 16(%%rbx),%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a3 * b3 */ + "movq 24(%%rbx),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a2 * b4 */ + "movq 32(%%rbx),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* c += (d & M) * R */ + "movq %%rcx,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d >>= 52 */ + "shrdq $52,%%r15,%%rcx\n" + "xorq %%r15,%%r15\n" + /* r[1] = c & M */ + "movq %%r8,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq %%rax,8(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* c += a2 * b0 */ + "movq 0(%%rbx),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* c += a1 * b1 */ + "movq 8(%%rbx),%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* c += a0 * b2 (last use of %%r10 = a0) */ + "movq 16(%%rbx),%%rax\n" + "mulq %%r10\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* fetch t3 (%%r10, overwrites a0), t4 (%%rsi) */ + "movq %q2,%%rsi\n" + "movq %q1,%%r10\n" + /* d += a4 * b3 */ + "movq 24(%%rbx),%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* d += a3 * b4 */ + "movq 32(%%rbx),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rcx\n" + "adcq %%rdx,%%r15\n" + /* c += (d & M) * R */ + "movq %%rcx,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d >>= 52 (%%rcx only) */ + "shrdq $52,%%r15,%%rcx\n" + /* r[2] = c & M */ + "movq %%r8,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq %%rax,16(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* c += t3 */ + "addq %%r10,%%r8\n" + /* c += d * R */ + "movq %%rcx,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* r[3] = c & M */ + "movq %%r8,%%rax\n" + "movq $0xfffffffffffff,%%rdx\n" + "andq %%rdx,%%rax\n" + "movq %%rax,24(%%rdi)\n" + /* c >>= 52 (%%r8 only) */ + "shrdq $52,%%r9,%%r8\n" + /* c += t4 (%%r8 only) */ + "addq %%rsi,%%r8\n" + /* r[4] = c */ + "movq %%r8,32(%%rdi)\n" +: "+S"(a), "=m"(tmp1), "=m"(tmp2), "=m"(tmp3) +: "b"(b), "D"(r) +: "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", "cc", "memory" +); +} + +SECP256K1_INLINE static void secp256k1_fe_sqr_inner(uint64_t *r, const uint64_t *a) { +/** + * Registers: rdx:rax = multiplication accumulator + * r9:r8 = c + * rcx:rbx = d + * r10-r14 = a0-a4 + * r15 = M (0xfffffffffffff) + * rdi = r + * rsi = a / t? + */ + uint64_t tmp1, tmp2, tmp3; +__asm__ __volatile__( + "movq 0(%%rsi),%%r10\n" + "movq 8(%%rsi),%%r11\n" + "movq 16(%%rsi),%%r12\n" + "movq 24(%%rsi),%%r13\n" + "movq 32(%%rsi),%%r14\n" + "movq $0xfffffffffffff,%%r15\n" + + /* d = (a0*2) * a3 */ + "leaq (%%r10,%%r10,1),%%rax\n" + "mulq %%r13\n" + "movq %%rax,%%rbx\n" + "movq %%rdx,%%rcx\n" + /* d += (a1*2) * a2 */ + "leaq (%%r11,%%r11,1),%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* c = a4 * a4 */ + "movq %%r14,%%rax\n" + "mulq %%r14\n" + "movq %%rax,%%r8\n" + "movq %%rdx,%%r9\n" + /* d += (c & M) * R */ + "andq %%r15,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* c >>= 52 (%%r8 only) */ + "shrdq $52,%%r9,%%r8\n" + /* t3 (tmp1) = d & M */ + "movq %%rbx,%%rsi\n" + "andq %%r15,%%rsi\n" + "movq %%rsi,%q1\n" + /* d >>= 52 */ + "shrdq $52,%%rcx,%%rbx\n" + "xorq %%rcx,%%rcx\n" + /* a4 *= 2 */ + "addq %%r14,%%r14\n" + /* d += a0 * a4 */ + "movq %%r10,%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* d+= (a1*2) * a3 */ + "leaq (%%r11,%%r11,1),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* d += a2 * a2 */ + "movq %%r12,%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* d += c * R */ + "movq %%r8,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* t4 = d & M (%%rsi) */ + "movq %%rbx,%%rsi\n" + "andq %%r15,%%rsi\n" + /* d >>= 52 */ + "shrdq $52,%%rcx,%%rbx\n" + "xorq %%rcx,%%rcx\n" + /* tx = t4 >> 48 (tmp3) */ + "movq %%rsi,%%rax\n" + "shrq $48,%%rax\n" + "movq %%rax,%q3\n" + /* t4 &= (M >> 4) (tmp2) */ + "movq $0xffffffffffff,%%rax\n" + "andq %%rax,%%rsi\n" + "movq %%rsi,%q2\n" + /* c = a0 * a0 */ + "movq %%r10,%%rax\n" + "mulq %%r10\n" + "movq %%rax,%%r8\n" + "movq %%rdx,%%r9\n" + /* d += a1 * a4 */ + "movq %%r11,%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* d += (a2*2) * a3 */ + "leaq (%%r12,%%r12,1),%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* u0 = d & M (%%rsi) */ + "movq %%rbx,%%rsi\n" + "andq %%r15,%%rsi\n" + /* d >>= 52 */ + "shrdq $52,%%rcx,%%rbx\n" + "xorq %%rcx,%%rcx\n" + /* u0 = (u0 << 4) | tx (%%rsi) */ + "shlq $4,%%rsi\n" + "movq %q3,%%rax\n" + "orq %%rax,%%rsi\n" + /* c += u0 * (R >> 4) */ + "movq $0x1000003d1,%%rax\n" + "mulq %%rsi\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* r[0] = c & M */ + "movq %%r8,%%rax\n" + "andq %%r15,%%rax\n" + "movq %%rax,0(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* a0 *= 2 */ + "addq %%r10,%%r10\n" + /* c += a0 * a1 */ + "movq %%r10,%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d += a2 * a4 */ + "movq %%r12,%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* d += a3 * a3 */ + "movq %%r13,%%rax\n" + "mulq %%r13\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* c += (d & M) * R */ + "movq %%rbx,%%rax\n" + "andq %%r15,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d >>= 52 */ + "shrdq $52,%%rcx,%%rbx\n" + "xorq %%rcx,%%rcx\n" + /* r[1] = c & M */ + "movq %%r8,%%rax\n" + "andq %%r15,%%rax\n" + "movq %%rax,8(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* c += a0 * a2 (last use of %%r10) */ + "movq %%r10,%%rax\n" + "mulq %%r12\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* fetch t3 (%%r10, overwrites a0),t4 (%%rsi) */ + "movq %q2,%%rsi\n" + "movq %q1,%%r10\n" + /* c += a1 * a1 */ + "movq %%r11,%%rax\n" + "mulq %%r11\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d += a3 * a4 */ + "movq %%r13,%%rax\n" + "mulq %%r14\n" + "addq %%rax,%%rbx\n" + "adcq %%rdx,%%rcx\n" + /* c += (d & M) * R */ + "movq %%rbx,%%rax\n" + "andq %%r15,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* d >>= 52 (%%rbx only) */ + "shrdq $52,%%rcx,%%rbx\n" + /* r[2] = c & M */ + "movq %%r8,%%rax\n" + "andq %%r15,%%rax\n" + "movq %%rax,16(%%rdi)\n" + /* c >>= 52 */ + "shrdq $52,%%r9,%%r8\n" + "xorq %%r9,%%r9\n" + /* c += t3 */ + "addq %%r10,%%r8\n" + /* c += d * R */ + "movq %%rbx,%%rax\n" + "movq $0x1000003d10,%%rdx\n" + "mulq %%rdx\n" + "addq %%rax,%%r8\n" + "adcq %%rdx,%%r9\n" + /* r[3] = c & M */ + "movq %%r8,%%rax\n" + "andq %%r15,%%rax\n" + "movq %%rax,24(%%rdi)\n" + /* c >>= 52 (%%r8 only) */ + "shrdq $52,%%r9,%%r8\n" + /* c += t4 (%%r8 only) */ + "addq %%rsi,%%r8\n" + /* r[4] = c */ + "movq %%r8,32(%%rdi)\n" +: "+S"(a), "=m"(tmp1), "=m"(tmp2), "=m"(tmp3) +: "D"(r) +: "%rax", "%rbx", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", "cc", "memory" +); +} + +#endif diff --git a/src/secp256k1/src/field_5x52_impl.h b/src/secp256k1/src/field_5x52_impl.h new file mode 100644 index 0000000..b31e24a --- /dev/null +++ b/src/secp256k1/src/field_5x52_impl.h @@ -0,0 +1,456 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_REPR_IMPL_H_ +#define _SECP256K1_FIELD_REPR_IMPL_H_ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#include +#include "util.h" +#include "num.h" +#include "field.h" + +#if defined(USE_ASM_X86_64) +#include "field_5x52_asm_impl.h" +#else +#include "field_5x52_int128_impl.h" +#endif + +/** Implements arithmetic modulo FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE FFFFFC2F, + * represented as 5 uint64_t's in base 2^52. The values are allowed to contain >52 each. In particular, + * each FieldElem has a 'magnitude' associated with it. Internally, a magnitude M means each element + * is at most M*(2^53-1), except the most significant one, which is limited to M*(2^49-1). All operations + * accept any input with magnitude at most M, and have different rules for propagating magnitude to their + * output. + */ + +#ifdef VERIFY +static void secp256k1_fe_verify(const secp256k1_fe *a) { + const uint64_t *d = a->n; + int m = a->normalized ? 1 : 2 * a->magnitude, r = 1; + /* secp256k1 'p' value defined in "Standards for Efficient Cryptography" (SEC2) 2.7.1. */ + r &= (d[0] <= 0xFFFFFFFFFFFFFULL * m); + r &= (d[1] <= 0xFFFFFFFFFFFFFULL * m); + r &= (d[2] <= 0xFFFFFFFFFFFFFULL * m); + r &= (d[3] <= 0xFFFFFFFFFFFFFULL * m); + r &= (d[4] <= 0x0FFFFFFFFFFFFULL * m); + r &= (a->magnitude >= 0); + r &= (a->magnitude <= 2048); + if (a->normalized) { + r &= (a->magnitude <= 1); + if (r && (d[4] == 0x0FFFFFFFFFFFFULL) && ((d[3] & d[2] & d[1]) == 0xFFFFFFFFFFFFFULL)) { + r &= (d[0] < 0xFFFFEFFFFFC2FULL); + } + } + VERIFY_CHECK(r == 1); +} +#else +static void secp256k1_fe_verify(const secp256k1_fe *a) { + (void)a; +} +#endif + +static void secp256k1_fe_normalize(secp256k1_fe *r) { + uint64_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4]; + + /* Reduce t4 at the start so there will be at most a single carry from the first pass */ + uint64_t m; + uint64_t x = t4 >> 48; t4 &= 0x0FFFFFFFFFFFFULL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; m = t1; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; m &= t2; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; m &= t3; + + /* ... except for a possible carry at bit 48 of t4 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t4 >> 49 == 0); + + /* At most a single final reduction is needed; check if the value is >= the field characteristic */ + x = (t4 >> 48) | ((t4 == 0x0FFFFFFFFFFFFULL) & (m == 0xFFFFFFFFFFFFFULL) + & (t0 >= 0xFFFFEFFFFFC2FULL)); + + /* Apply the final reduction (for constant-time behaviour, we do it always) */ + t0 += x * 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; + + /* If t4 didn't carry to bit 48 already, then it should have after any final reduction */ + VERIFY_CHECK(t4 >> 48 == x); + + /* Mask off the possible multiple of 2^256 from the final reduction */ + t4 &= 0x0FFFFFFFFFFFFULL; + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_normalize_weak(secp256k1_fe *r) { + uint64_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4]; + + /* Reduce t4 at the start so there will be at most a single carry from the first pass */ + uint64_t x = t4 >> 48; t4 &= 0x0FFFFFFFFFFFFULL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; + + /* ... except for a possible carry at bit 48 of t4 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t4 >> 49 == 0); + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + +#ifdef VERIFY + r->magnitude = 1; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_normalize_var(secp256k1_fe *r) { + uint64_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4]; + + /* Reduce t4 at the start so there will be at most a single carry from the first pass */ + uint64_t m; + uint64_t x = t4 >> 48; t4 &= 0x0FFFFFFFFFFFFULL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; m = t1; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; m &= t2; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; m &= t3; + + /* ... except for a possible carry at bit 48 of t4 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t4 >> 49 == 0); + + /* At most a single final reduction is needed; check if the value is >= the field characteristic */ + x = (t4 >> 48) | ((t4 == 0x0FFFFFFFFFFFFULL) & (m == 0xFFFFFFFFFFFFFULL) + & (t0 >= 0xFFFFEFFFFFC2FULL)); + + if (x) { + t0 += 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; + + /* If t4 didn't carry to bit 48 already, then it should have after any final reduction */ + VERIFY_CHECK(t4 >> 48 == x); + + /* Mask off the possible multiple of 2^256 from the final reduction */ + t4 &= 0x0FFFFFFFFFFFFULL; + } + + r->n[0] = t0; r->n[1] = t1; r->n[2] = t2; r->n[3] = t3; r->n[4] = t4; + +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +static int secp256k1_fe_normalizes_to_zero(secp256k1_fe *r) { + uint64_t t0 = r->n[0], t1 = r->n[1], t2 = r->n[2], t3 = r->n[3], t4 = r->n[4]; + + /* z0 tracks a possible raw value of 0, z1 tracks a possible raw value of P */ + uint64_t z0, z1; + + /* Reduce t4 at the start so there will be at most a single carry from the first pass */ + uint64_t x = t4 >> 48; t4 &= 0x0FFFFFFFFFFFFULL; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x1000003D1ULL; + t1 += (t0 >> 52); t0 &= 0xFFFFFFFFFFFFFULL; z0 = t0; z1 = t0 ^ 0x1000003D0ULL; + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; z0 |= t1; z1 &= t1; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; z0 |= t2; z1 &= t2; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; z0 |= t3; z1 &= t3; + z0 |= t4; z1 &= t4 ^ 0xF000000000000ULL; + + /* ... except for a possible carry at bit 48 of t4 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t4 >> 49 == 0); + + return (z0 == 0) | (z1 == 0xFFFFFFFFFFFFFULL); +} + +static int secp256k1_fe_normalizes_to_zero_var(secp256k1_fe *r) { + uint64_t t0, t1, t2, t3, t4; + uint64_t z0, z1; + uint64_t x; + + t0 = r->n[0]; + t4 = r->n[4]; + + /* Reduce t4 at the start so there will be at most a single carry from the first pass */ + x = t4 >> 48; + + /* The first pass ensures the magnitude is 1, ... */ + t0 += x * 0x1000003D1ULL; + + /* z0 tracks a possible raw value of 0, z1 tracks a possible raw value of P */ + z0 = t0 & 0xFFFFFFFFFFFFFULL; + z1 = z0 ^ 0x1000003D0ULL; + + /* Fast return path should catch the majority of cases */ + if ((z0 != 0ULL) & (z1 != 0xFFFFFFFFFFFFFULL)) { + return 0; + } + + t1 = r->n[1]; + t2 = r->n[2]; + t3 = r->n[3]; + + t4 &= 0x0FFFFFFFFFFFFULL; + + t1 += (t0 >> 52); + t2 += (t1 >> 52); t1 &= 0xFFFFFFFFFFFFFULL; z0 |= t1; z1 &= t1; + t3 += (t2 >> 52); t2 &= 0xFFFFFFFFFFFFFULL; z0 |= t2; z1 &= t2; + t4 += (t3 >> 52); t3 &= 0xFFFFFFFFFFFFFULL; z0 |= t3; z1 &= t3; + z0 |= t4; z1 &= t4 ^ 0xF000000000000ULL; + + /* ... except for a possible carry at bit 48 of t4 (i.e. bit 256 of the field element) */ + VERIFY_CHECK(t4 >> 49 == 0); + + return (z0 == 0) | (z1 == 0xFFFFFFFFFFFFFULL); +} + +SECP256K1_INLINE static void secp256k1_fe_set_int(secp256k1_fe *r, int a) { + r->n[0] = a; + r->n[1] = r->n[2] = r->n[3] = r->n[4] = 0; +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static int secp256k1_fe_is_zero(const secp256k1_fe *a) { + const uint64_t *t = a->n; +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + return (t[0] | t[1] | t[2] | t[3] | t[4]) == 0; +} + +SECP256K1_INLINE static int secp256k1_fe_is_odd(const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + return a->n[0] & 1; +} + +SECP256K1_INLINE static void secp256k1_fe_clear(secp256k1_fe *a) { + int i; +#ifdef VERIFY + a->magnitude = 0; + a->normalized = 1; +#endif + for (i=0; i<5; i++) { + a->n[i] = 0; + } +} + +static int secp256k1_fe_cmp_var(const secp256k1_fe *a, const secp256k1_fe *b) { + int i; +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + VERIFY_CHECK(b->normalized); + secp256k1_fe_verify(a); + secp256k1_fe_verify(b); +#endif + for (i = 4; i >= 0; i--) { + if (a->n[i] > b->n[i]) { + return 1; + } + if (a->n[i] < b->n[i]) { + return -1; + } + } + return 0; +} + +static int secp256k1_fe_set_b32(secp256k1_fe *r, const unsigned char *a) { + int i; + r->n[0] = r->n[1] = r->n[2] = r->n[3] = r->n[4] = 0; + for (i=0; i<32; i++) { + int j; + for (j=0; j<2; j++) { + int limb = (8*i+4*j)/52; + int shift = (8*i+4*j)%52; + r->n[limb] |= (uint64_t)((a[31-i] >> (4*j)) & 0xF) << shift; + } + } + if (r->n[4] == 0x0FFFFFFFFFFFFULL && (r->n[3] & r->n[2] & r->n[1]) == 0xFFFFFFFFFFFFFULL && r->n[0] >= 0xFFFFEFFFFFC2FULL) { + return 0; + } +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; + secp256k1_fe_verify(r); +#endif + return 1; +} + +/** Convert a field element to a 32-byte big endian value. Requires the input to be normalized */ +static void secp256k1_fe_get_b32(unsigned char *r, const secp256k1_fe *a) { + int i; +#ifdef VERIFY + VERIFY_CHECK(a->normalized); + secp256k1_fe_verify(a); +#endif + for (i=0; i<32; i++) { + int j; + int c = 0; + for (j=0; j<2; j++) { + int limb = (8*i+4*j)/52; + int shift = (8*i+4*j)%52; + c |= ((a->n[limb] >> shift) & 0xF) << (4 * j); + } + r[31-i] = c; + } +} + +SECP256K1_INLINE static void secp256k1_fe_negate(secp256k1_fe *r, const secp256k1_fe *a, int m) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= m); + secp256k1_fe_verify(a); +#endif + r->n[0] = 0xFFFFEFFFFFC2FULL * 2 * (m + 1) - a->n[0]; + r->n[1] = 0xFFFFFFFFFFFFFULL * 2 * (m + 1) - a->n[1]; + r->n[2] = 0xFFFFFFFFFFFFFULL * 2 * (m + 1) - a->n[2]; + r->n[3] = 0xFFFFFFFFFFFFFULL * 2 * (m + 1) - a->n[3]; + r->n[4] = 0x0FFFFFFFFFFFFULL * 2 * (m + 1) - a->n[4]; +#ifdef VERIFY + r->magnitude = m + 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static void secp256k1_fe_mul_int(secp256k1_fe *r, int a) { + r->n[0] *= a; + r->n[1] *= a; + r->n[2] *= a; + r->n[3] *= a; + r->n[4] *= a; +#ifdef VERIFY + r->magnitude *= a; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +SECP256K1_INLINE static void secp256k1_fe_add(secp256k1_fe *r, const secp256k1_fe *a) { +#ifdef VERIFY + secp256k1_fe_verify(a); +#endif + r->n[0] += a->n[0]; + r->n[1] += a->n[1]; + r->n[2] += a->n[2]; + r->n[3] += a->n[3]; + r->n[4] += a->n[4]; +#ifdef VERIFY + r->magnitude += a->magnitude; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp256k1_fe * SECP256K1_RESTRICT b) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= 8); + VERIFY_CHECK(b->magnitude <= 8); + secp256k1_fe_verify(a); + secp256k1_fe_verify(b); + VERIFY_CHECK(r != b); +#endif + secp256k1_fe_mul_inner(r->n, a->n, b->n); +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->magnitude <= 8); + secp256k1_fe_verify(a); +#endif + secp256k1_fe_sqr_inner(r->n, a->n); +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 0; + secp256k1_fe_verify(r); +#endif +} + +static SECP256K1_INLINE void secp256k1_fe_cmov(secp256k1_fe *r, const secp256k1_fe *a, int flag) { + uint64_t mask0, mask1; + mask0 = flag + ~((uint64_t)0); + mask1 = ~mask0; + r->n[0] = (r->n[0] & mask0) | (a->n[0] & mask1); + r->n[1] = (r->n[1] & mask0) | (a->n[1] & mask1); + r->n[2] = (r->n[2] & mask0) | (a->n[2] & mask1); + r->n[3] = (r->n[3] & mask0) | (a->n[3] & mask1); + r->n[4] = (r->n[4] & mask0) | (a->n[4] & mask1); +#ifdef VERIFY + if (a->magnitude > r->magnitude) { + r->magnitude = a->magnitude; + } + r->normalized &= a->normalized; +#endif +} + +static SECP256K1_INLINE void secp256k1_fe_storage_cmov(secp256k1_fe_storage *r, const secp256k1_fe_storage *a, int flag) { + uint64_t mask0, mask1; + mask0 = flag + ~((uint64_t)0); + mask1 = ~mask0; + r->n[0] = (r->n[0] & mask0) | (a->n[0] & mask1); + r->n[1] = (r->n[1] & mask0) | (a->n[1] & mask1); + r->n[2] = (r->n[2] & mask0) | (a->n[2] & mask1); + r->n[3] = (r->n[3] & mask0) | (a->n[3] & mask1); +} + +static void secp256k1_fe_to_storage(secp256k1_fe_storage *r, const secp256k1_fe *a) { +#ifdef VERIFY + VERIFY_CHECK(a->normalized); +#endif + r->n[0] = a->n[0] | a->n[1] << 52; + r->n[1] = a->n[1] >> 12 | a->n[2] << 40; + r->n[2] = a->n[2] >> 24 | a->n[3] << 28; + r->n[3] = a->n[3] >> 36 | a->n[4] << 16; +} + +static SECP256K1_INLINE void secp256k1_fe_from_storage(secp256k1_fe *r, const secp256k1_fe_storage *a) { + r->n[0] = a->n[0] & 0xFFFFFFFFFFFFFULL; + r->n[1] = a->n[0] >> 52 | ((a->n[1] << 12) & 0xFFFFFFFFFFFFFULL); + r->n[2] = a->n[1] >> 40 | ((a->n[2] << 24) & 0xFFFFFFFFFFFFFULL); + r->n[3] = a->n[2] >> 28 | ((a->n[3] << 36) & 0xFFFFFFFFFFFFFULL); + r->n[4] = a->n[3] >> 16; +#ifdef VERIFY + r->magnitude = 1; + r->normalized = 1; +#endif +} + +#endif diff --git a/src/secp256k1/src/field_5x52_int128_impl.h b/src/secp256k1/src/field_5x52_int128_impl.h new file mode 100644 index 0000000..9280bb5 --- /dev/null +++ b/src/secp256k1/src/field_5x52_int128_impl.h @@ -0,0 +1,277 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_INNER5X52_IMPL_H_ +#define _SECP256K1_FIELD_INNER5X52_IMPL_H_ + +#include + +#ifdef VERIFY +#define VERIFY_BITS(x, n) VERIFY_CHECK(((x) >> (n)) == 0) +#else +#define VERIFY_BITS(x, n) do { } while(0) +#endif + +SECP256K1_INLINE static void secp256k1_fe_mul_inner(uint64_t *r, const uint64_t *a, const uint64_t * SECP256K1_RESTRICT b) { + uint128_t c, d; + uint64_t t3, t4, tx, u0; + uint64_t a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4]; + const uint64_t M = 0xFFFFFFFFFFFFFULL, R = 0x1000003D10ULL; + + VERIFY_BITS(a[0], 56); + VERIFY_BITS(a[1], 56); + VERIFY_BITS(a[2], 56); + VERIFY_BITS(a[3], 56); + VERIFY_BITS(a[4], 52); + VERIFY_BITS(b[0], 56); + VERIFY_BITS(b[1], 56); + VERIFY_BITS(b[2], 56); + VERIFY_BITS(b[3], 56); + VERIFY_BITS(b[4], 52); + VERIFY_CHECK(r != b); + + /* [... a b c] is a shorthand for ... + a<<104 + b<<52 + c<<0 mod n. + * px is a shorthand for sum(a[i]*b[x-i], i=0..x). + * Note that [x 0 0 0 0 0] = [x*R]. + */ + + d = (uint128_t)a0 * b[3] + + (uint128_t)a1 * b[2] + + (uint128_t)a2 * b[1] + + (uint128_t)a3 * b[0]; + VERIFY_BITS(d, 114); + /* [d 0 0 0] = [p3 0 0 0] */ + c = (uint128_t)a4 * b[4]; + VERIFY_BITS(c, 112); + /* [c 0 0 0 0 d 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + d += (c & M) * R; c >>= 52; + VERIFY_BITS(d, 115); + VERIFY_BITS(c, 60); + /* [c 0 0 0 0 0 d 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + t3 = d & M; d >>= 52; + VERIFY_BITS(t3, 52); + VERIFY_BITS(d, 63); + /* [c 0 0 0 0 d t3 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + + d += (uint128_t)a0 * b[4] + + (uint128_t)a1 * b[3] + + (uint128_t)a2 * b[2] + + (uint128_t)a3 * b[1] + + (uint128_t)a4 * b[0]; + VERIFY_BITS(d, 115); + /* [c 0 0 0 0 d t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + d += c * R; + VERIFY_BITS(d, 116); + /* [d t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + t4 = d & M; d >>= 52; + VERIFY_BITS(t4, 52); + VERIFY_BITS(d, 64); + /* [d t4 t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + tx = (t4 >> 48); t4 &= (M >> 4); + VERIFY_BITS(tx, 4); + VERIFY_BITS(t4, 48); + /* [d t4+(tx<<48) t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + + c = (uint128_t)a0 * b[0]; + VERIFY_BITS(c, 112); + /* [d t4+(tx<<48) t3 0 0 c] = [p8 0 0 0 p4 p3 0 0 p0] */ + d += (uint128_t)a1 * b[4] + + (uint128_t)a2 * b[3] + + (uint128_t)a3 * b[2] + + (uint128_t)a4 * b[1]; + VERIFY_BITS(d, 115); + /* [d t4+(tx<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + u0 = d & M; d >>= 52; + VERIFY_BITS(u0, 52); + VERIFY_BITS(d, 63); + /* [d u0 t4+(tx<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + /* [d 0 t4+(tx<<48)+(u0<<52) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + u0 = (u0 << 4) | tx; + VERIFY_BITS(u0, 56); + /* [d 0 t4+(u0<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + c += (uint128_t)u0 * (R >> 4); + VERIFY_BITS(c, 115); + /* [d 0 t4 t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + r[0] = c & M; c >>= 52; + VERIFY_BITS(r[0], 52); + VERIFY_BITS(c, 61); + /* [d 0 t4 t3 0 c r0] = [p8 0 0 p5 p4 p3 0 0 p0] */ + + c += (uint128_t)a0 * b[1] + + (uint128_t)a1 * b[0]; + VERIFY_BITS(c, 114); + /* [d 0 t4 t3 0 c r0] = [p8 0 0 p5 p4 p3 0 p1 p0] */ + d += (uint128_t)a2 * b[4] + + (uint128_t)a3 * b[3] + + (uint128_t)a4 * b[2]; + VERIFY_BITS(d, 114); + /* [d 0 t4 t3 0 c r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + c += (d & M) * R; d >>= 52; + VERIFY_BITS(c, 115); + VERIFY_BITS(d, 62); + /* [d 0 0 t4 t3 0 c r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + r[1] = c & M; c >>= 52; + VERIFY_BITS(r[1], 52); + VERIFY_BITS(c, 63); + /* [d 0 0 t4 t3 c r1 r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + + c += (uint128_t)a0 * b[2] + + (uint128_t)a1 * b[1] + + (uint128_t)a2 * b[0]; + VERIFY_BITS(c, 114); + /* [d 0 0 t4 t3 c r1 r0] = [p8 0 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint128_t)a3 * b[4] + + (uint128_t)a4 * b[3]; + VERIFY_BITS(d, 114); + /* [d 0 0 t4 t3 c t1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += (d & M) * R; d >>= 52; + VERIFY_BITS(c, 115); + VERIFY_BITS(d, 62); + /* [d 0 0 0 t4 t3 c r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + /* [d 0 0 0 t4 t3 c r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[2] = c & M; c >>= 52; + VERIFY_BITS(r[2], 52); + VERIFY_BITS(c, 63); + /* [d 0 0 0 t4 t3+c r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += d * R + t3;; + VERIFY_BITS(c, 100); + /* [t4 c r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[3] = c & M; c >>= 52; + VERIFY_BITS(r[3], 52); + VERIFY_BITS(c, 48); + /* [t4+c r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += t4; + VERIFY_BITS(c, 49); + /* [c r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[4] = c; + VERIFY_BITS(r[4], 49); + /* [r4 r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ +} + +SECP256K1_INLINE static void secp256k1_fe_sqr_inner(uint64_t *r, const uint64_t *a) { + uint128_t c, d; + uint64_t a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4]; + int64_t t3, t4, tx, u0; + const uint64_t M = 0xFFFFFFFFFFFFFULL, R = 0x1000003D10ULL; + + VERIFY_BITS(a[0], 56); + VERIFY_BITS(a[1], 56); + VERIFY_BITS(a[2], 56); + VERIFY_BITS(a[3], 56); + VERIFY_BITS(a[4], 52); + + /** [... a b c] is a shorthand for ... + a<<104 + b<<52 + c<<0 mod n. + * px is a shorthand for sum(a[i]*a[x-i], i=0..x). + * Note that [x 0 0 0 0 0] = [x*R]. + */ + + d = (uint128_t)(a0*2) * a3 + + (uint128_t)(a1*2) * a2; + VERIFY_BITS(d, 114); + /* [d 0 0 0] = [p3 0 0 0] */ + c = (uint128_t)a4 * a4; + VERIFY_BITS(c, 112); + /* [c 0 0 0 0 d 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + d += (c & M) * R; c >>= 52; + VERIFY_BITS(d, 115); + VERIFY_BITS(c, 60); + /* [c 0 0 0 0 0 d 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + t3 = d & M; d >>= 52; + VERIFY_BITS(t3, 52); + VERIFY_BITS(d, 63); + /* [c 0 0 0 0 d t3 0 0 0] = [p8 0 0 0 0 p3 0 0 0] */ + + a4 *= 2; + d += (uint128_t)a0 * a4 + + (uint128_t)(a1*2) * a3 + + (uint128_t)a2 * a2; + VERIFY_BITS(d, 115); + /* [c 0 0 0 0 d t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + d += c * R; + VERIFY_BITS(d, 116); + /* [d t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + t4 = d & M; d >>= 52; + VERIFY_BITS(t4, 52); + VERIFY_BITS(d, 64); + /* [d t4 t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + tx = (t4 >> 48); t4 &= (M >> 4); + VERIFY_BITS(tx, 4); + VERIFY_BITS(t4, 48); + /* [d t4+(tx<<48) t3 0 0 0] = [p8 0 0 0 p4 p3 0 0 0] */ + + c = (uint128_t)a0 * a0; + VERIFY_BITS(c, 112); + /* [d t4+(tx<<48) t3 0 0 c] = [p8 0 0 0 p4 p3 0 0 p0] */ + d += (uint128_t)a1 * a4 + + (uint128_t)(a2*2) * a3; + VERIFY_BITS(d, 114); + /* [d t4+(tx<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + u0 = d & M; d >>= 52; + VERIFY_BITS(u0, 52); + VERIFY_BITS(d, 62); + /* [d u0 t4+(tx<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + /* [d 0 t4+(tx<<48)+(u0<<52) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + u0 = (u0 << 4) | tx; + VERIFY_BITS(u0, 56); + /* [d 0 t4+(u0<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + c += (uint128_t)u0 * (R >> 4); + VERIFY_BITS(c, 113); + /* [d 0 t4 t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] */ + r[0] = c & M; c >>= 52; + VERIFY_BITS(r[0], 52); + VERIFY_BITS(c, 61); + /* [d 0 t4 t3 0 c r0] = [p8 0 0 p5 p4 p3 0 0 p0] */ + + a0 *= 2; + c += (uint128_t)a0 * a1; + VERIFY_BITS(c, 114); + /* [d 0 t4 t3 0 c r0] = [p8 0 0 p5 p4 p3 0 p1 p0] */ + d += (uint128_t)a2 * a4 + + (uint128_t)a3 * a3; + VERIFY_BITS(d, 114); + /* [d 0 t4 t3 0 c r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + c += (d & M) * R; d >>= 52; + VERIFY_BITS(c, 115); + VERIFY_BITS(d, 62); + /* [d 0 0 t4 t3 0 c r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + r[1] = c & M; c >>= 52; + VERIFY_BITS(r[1], 52); + VERIFY_BITS(c, 63); + /* [d 0 0 t4 t3 c r1 r0] = [p8 0 p6 p5 p4 p3 0 p1 p0] */ + + c += (uint128_t)a0 * a2 + + (uint128_t)a1 * a1; + VERIFY_BITS(c, 114); + /* [d 0 0 t4 t3 c r1 r0] = [p8 0 p6 p5 p4 p3 p2 p1 p0] */ + d += (uint128_t)a3 * a4; + VERIFY_BITS(d, 114); + /* [d 0 0 t4 t3 c r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += (d & M) * R; d >>= 52; + VERIFY_BITS(c, 115); + VERIFY_BITS(d, 62); + /* [d 0 0 0 t4 t3 c r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[2] = c & M; c >>= 52; + VERIFY_BITS(r[2], 52); + VERIFY_BITS(c, 63); + /* [d 0 0 0 t4 t3+c r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + + c += d * R + t3;; + VERIFY_BITS(c, 100); + /* [t4 c r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[3] = c & M; c >>= 52; + VERIFY_BITS(r[3], 52); + VERIFY_BITS(c, 48); + /* [t4+c r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + c += t4; + VERIFY_BITS(c, 49); + /* [c r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ + r[4] = c; + VERIFY_BITS(r[4], 49); + /* [r4 r3 r2 r1 r0] = [p8 p7 p6 p5 p4 p3 p2 p1 p0] */ +} + +#endif diff --git a/src/secp256k1/src/field_impl.h b/src/secp256k1/src/field_impl.h new file mode 100644 index 0000000..77f4aae --- /dev/null +++ b/src/secp256k1/src/field_impl.h @@ -0,0 +1,283 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_FIELD_IMPL_H_ +#define _SECP256K1_FIELD_IMPL_H_ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#include "util.h" + +#if defined(USE_FIELD_10X26) +#include "field_10x26_impl.h" +#elif defined(USE_FIELD_5X52) +#include "field_5x52_impl.h" +#else +#error "Please select field implementation" +#endif + +SECP256K1_INLINE static int secp256k1_fe_equal_var(const secp256k1_fe *a, const secp256k1_fe *b) { + secp256k1_fe na; + secp256k1_fe_negate(&na, a, 1); + secp256k1_fe_add(&na, b); + return secp256k1_fe_normalizes_to_zero_var(&na); +} + +static int secp256k1_fe_sqrt_var(secp256k1_fe *r, const secp256k1_fe *a) { + /** Given that p is congruent to 3 mod 4, we can compute the square root of + * a mod p as the (p+1)/4'th power of a. + * + * As (p+1)/4 is an even number, it will have the same result for a and for + * (-a). Only one of these two numbers actually has a square root however, + * so we test at the end by squaring and comparing to the input. + * Also because (p+1)/4 is an even number, the computed square root is + * itself always a square (a ** ((p+1)/4) is the square of a ** ((p+1)/8)). + */ + secp256k1_fe x2, x3, x6, x9, x11, x22, x44, x88, x176, x220, x223, t1; + int j; + + /** The binary representation of (p + 1)/4 has 3 blocks of 1s, with lengths in + * { 2, 22, 223 }. Use an addition chain to calculate 2^n - 1 for each block: + * 1, [2], 3, 6, 9, 11, [22], 44, 88, 176, 220, [223] + */ + + secp256k1_fe_sqr(&x2, a); + secp256k1_fe_mul(&x2, &x2, a); + + secp256k1_fe_sqr(&x3, &x2); + secp256k1_fe_mul(&x3, &x3, a); + + x6 = x3; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x6, &x6); + } + secp256k1_fe_mul(&x6, &x6, &x3); + + x9 = x6; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x9, &x9); + } + secp256k1_fe_mul(&x9, &x9, &x3); + + x11 = x9; + for (j=0; j<2; j++) { + secp256k1_fe_sqr(&x11, &x11); + } + secp256k1_fe_mul(&x11, &x11, &x2); + + x22 = x11; + for (j=0; j<11; j++) { + secp256k1_fe_sqr(&x22, &x22); + } + secp256k1_fe_mul(&x22, &x22, &x11); + + x44 = x22; + for (j=0; j<22; j++) { + secp256k1_fe_sqr(&x44, &x44); + } + secp256k1_fe_mul(&x44, &x44, &x22); + + x88 = x44; + for (j=0; j<44; j++) { + secp256k1_fe_sqr(&x88, &x88); + } + secp256k1_fe_mul(&x88, &x88, &x44); + + x176 = x88; + for (j=0; j<88; j++) { + secp256k1_fe_sqr(&x176, &x176); + } + secp256k1_fe_mul(&x176, &x176, &x88); + + x220 = x176; + for (j=0; j<44; j++) { + secp256k1_fe_sqr(&x220, &x220); + } + secp256k1_fe_mul(&x220, &x220, &x44); + + x223 = x220; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x223, &x223); + } + secp256k1_fe_mul(&x223, &x223, &x3); + + /* The final result is then assembled using a sliding window over the blocks. */ + + t1 = x223; + for (j=0; j<23; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(&t1, &t1, &x22); + for (j=0; j<6; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(&t1, &t1, &x2); + secp256k1_fe_sqr(&t1, &t1); + secp256k1_fe_sqr(r, &t1); + + /* Check that a square root was actually calculated */ + + secp256k1_fe_sqr(&t1, r); + return secp256k1_fe_equal_var(&t1, a); +} + +static void secp256k1_fe_inv(secp256k1_fe *r, const secp256k1_fe *a) { + secp256k1_fe x2, x3, x6, x9, x11, x22, x44, x88, x176, x220, x223, t1; + int j; + + /** The binary representation of (p - 2) has 5 blocks of 1s, with lengths in + * { 1, 2, 22, 223 }. Use an addition chain to calculate 2^n - 1 for each block: + * [1], [2], 3, 6, 9, 11, [22], 44, 88, 176, 220, [223] + */ + + secp256k1_fe_sqr(&x2, a); + secp256k1_fe_mul(&x2, &x2, a); + + secp256k1_fe_sqr(&x3, &x2); + secp256k1_fe_mul(&x3, &x3, a); + + x6 = x3; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x6, &x6); + } + secp256k1_fe_mul(&x6, &x6, &x3); + + x9 = x6; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x9, &x9); + } + secp256k1_fe_mul(&x9, &x9, &x3); + + x11 = x9; + for (j=0; j<2; j++) { + secp256k1_fe_sqr(&x11, &x11); + } + secp256k1_fe_mul(&x11, &x11, &x2); + + x22 = x11; + for (j=0; j<11; j++) { + secp256k1_fe_sqr(&x22, &x22); + } + secp256k1_fe_mul(&x22, &x22, &x11); + + x44 = x22; + for (j=0; j<22; j++) { + secp256k1_fe_sqr(&x44, &x44); + } + secp256k1_fe_mul(&x44, &x44, &x22); + + x88 = x44; + for (j=0; j<44; j++) { + secp256k1_fe_sqr(&x88, &x88); + } + secp256k1_fe_mul(&x88, &x88, &x44); + + x176 = x88; + for (j=0; j<88; j++) { + secp256k1_fe_sqr(&x176, &x176); + } + secp256k1_fe_mul(&x176, &x176, &x88); + + x220 = x176; + for (j=0; j<44; j++) { + secp256k1_fe_sqr(&x220, &x220); + } + secp256k1_fe_mul(&x220, &x220, &x44); + + x223 = x220; + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&x223, &x223); + } + secp256k1_fe_mul(&x223, &x223, &x3); + + /* The final result is then assembled using a sliding window over the blocks. */ + + t1 = x223; + for (j=0; j<23; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(&t1, &t1, &x22); + for (j=0; j<5; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(&t1, &t1, a); + for (j=0; j<3; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(&t1, &t1, &x2); + for (j=0; j<2; j++) { + secp256k1_fe_sqr(&t1, &t1); + } + secp256k1_fe_mul(r, a, &t1); +} + +static void secp256k1_fe_inv_var(secp256k1_fe *r, const secp256k1_fe *a) { +#if defined(USE_FIELD_INV_BUILTIN) + secp256k1_fe_inv(r, a); +#elif defined(USE_FIELD_INV_NUM) + secp256k1_num n, m; + static const secp256k1_fe negone = SECP256K1_FE_CONST( + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFEUL, 0xFFFFFC2EUL + ); + /* secp256k1 field prime, value p defined in "Standards for Efficient Cryptography" (SEC2) 2.7.1. */ + static const unsigned char prime[32] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFC,0x2F + }; + unsigned char b[32]; + int res; + secp256k1_fe c = *a; + secp256k1_fe_normalize_var(&c); + secp256k1_fe_get_b32(b, &c); + secp256k1_num_set_bin(&n, b, 32); + secp256k1_num_set_bin(&m, prime, 32); + secp256k1_num_mod_inverse(&n, &n, &m); + secp256k1_num_get_bin(b, 32, &n); + res = secp256k1_fe_set_b32(r, b); + (void)res; + VERIFY_CHECK(res); + /* Verify the result is the (unique) valid inverse using non-GMP code. */ + secp256k1_fe_mul(&c, &c, r); + secp256k1_fe_add(&c, &negone); + CHECK(secp256k1_fe_normalizes_to_zero_var(&c)); +#else +#error "Please select field inverse implementation" +#endif +} + +static void secp256k1_fe_inv_all_var(size_t len, secp256k1_fe *r, const secp256k1_fe *a) { + secp256k1_fe u; + size_t i; + if (len < 1) { + return; + } + + VERIFY_CHECK((r + len <= a) || (a + len <= r)); + + r[0] = a[0]; + + i = 0; + while (++i < len) { + secp256k1_fe_mul(&r[i], &r[i - 1], &a[i]); + } + + secp256k1_fe_inv_var(&u, &r[--i]); + + while (i > 0) { + size_t j = i--; + secp256k1_fe_mul(&r[j], &r[i], &u); + secp256k1_fe_mul(&u, &u, &a[j]); + } + + r[0] = u; +} + +#endif diff --git a/src/secp256k1/src/gen_context.c b/src/secp256k1/src/gen_context.c new file mode 100644 index 0000000..1835fd4 --- /dev/null +++ b/src/secp256k1/src/gen_context.c @@ -0,0 +1,74 @@ +/********************************************************************** + * Copyright (c) 2013, 2014, 2015 Thomas Daede, Cory Fields * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#define USE_BASIC_CONFIG 1 + +#include "basic-config.h" +#include "include/secp256k1.h" +#include "field_impl.h" +#include "scalar_impl.h" +#include "group_impl.h" +#include "ecmult_gen_impl.h" + +static void default_error_callback_fn(const char* str, void* data) { + (void)data; + fprintf(stderr, "[libsecp256k1] internal consistency check failed: %s\n", str); + abort(); +} + +static const secp256k1_callback default_error_callback = { + default_error_callback_fn, + NULL +}; + +int main(int argc, char **argv) { + secp256k1_ecmult_gen_context ctx; + int inner; + int outer; + FILE* fp; + + (void)argc; + (void)argv; + + fp = fopen("src/ecmult_static_context.h","w"); + if (fp == NULL) { + fprintf(stderr, "Could not open src/ecmult_static_context.h for writing!\n"); + return -1; + } + + fprintf(fp, "#ifndef _SECP256K1_ECMULT_STATIC_CONTEXT_\n"); + fprintf(fp, "#define _SECP256K1_ECMULT_STATIC_CONTEXT_\n"); + fprintf(fp, "#include \"group.h\"\n"); + fprintf(fp, "#define SC SECP256K1_GE_STORAGE_CONST\n"); + fprintf(fp, "static const secp256k1_ge_storage secp256k1_ecmult_static_context[64][16] = {\n"); + + secp256k1_ecmult_gen_context_init(&ctx); + secp256k1_ecmult_gen_context_build(&ctx, &default_error_callback); + for(outer = 0; outer != 64; outer++) { + fprintf(fp,"{\n"); + for(inner = 0; inner != 16; inner++) { + fprintf(fp," SC(%uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu)", SECP256K1_GE_STORAGE_CONST_GET((*ctx.prec)[outer][inner])); + if (inner != 15) { + fprintf(fp,",\n"); + } else { + fprintf(fp,"\n"); + } + } + if (outer != 63) { + fprintf(fp,"},\n"); + } else { + fprintf(fp,"}\n"); + } + } + fprintf(fp,"};\n"); + secp256k1_ecmult_gen_context_clear(&ctx); + + fprintf(fp, "#undef SC\n"); + fprintf(fp, "#endif\n"); + fclose(fp); + + return 0; +} diff --git a/src/secp256k1/src/group.h b/src/secp256k1/src/group.h new file mode 100644 index 0000000..ebfe1ca --- /dev/null +++ b/src/secp256k1/src/group.h @@ -0,0 +1,141 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_GROUP_ +#define _SECP256K1_GROUP_ + +#include "num.h" +#include "field.h" + +/** A group element of the secp256k1 curve, in affine coordinates. */ +typedef struct { + secp256k1_fe x; + secp256k1_fe y; + int infinity; /* whether this represents the point at infinity */ +} secp256k1_ge; + +#define SECP256K1_GE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {SECP256K1_FE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_CONST((i),(j),(k),(l),(m),(n),(o),(p)), 0} +#define SECP256K1_GE_CONST_INFINITY {SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), 1} + +/** A group element of the secp256k1 curve, in jacobian coordinates. */ +typedef struct { + secp256k1_fe x; /* actual X: x/z^2 */ + secp256k1_fe y; /* actual Y: y/z^3 */ + secp256k1_fe z; + int infinity; /* whether this represents the point at infinity */ +} secp256k1_gej; + +#define SECP256K1_GEJ_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {SECP256K1_FE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_CONST((i),(j),(k),(l),(m),(n),(o),(p)), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1), 0} +#define SECP256K1_GEJ_CONST_INFINITY {SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), 1} + +typedef struct { + secp256k1_fe_storage x; + secp256k1_fe_storage y; +} secp256k1_ge_storage; + +#define SECP256K1_GE_STORAGE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {SECP256K1_FE_STORAGE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_STORAGE_CONST((i),(j),(k),(l),(m),(n),(o),(p))} + +#define SECP256K1_GE_STORAGE_CONST_GET(t) SECP256K1_FE_STORAGE_CONST_GET(t.x), SECP256K1_FE_STORAGE_CONST_GET(t.y) + +/** Set a group element equal to the point with given X and Y coordinates */ +static void secp256k1_ge_set_xy(secp256k1_ge *r, const secp256k1_fe *x, const secp256k1_fe *y); + +/** Set a group element (affine) equal to the point with the given X coordinate + * and a Y coordinate that is a quadratic residue modulo p. The return value + * is true iff a coordinate with the given X coordinate exists. + */ +static int secp256k1_ge_set_xquad_var(secp256k1_ge *r, const secp256k1_fe *x); + +/** Set a group element (affine) equal to the point with the given X coordinate, and given oddness + * for Y. Return value indicates whether the result is valid. */ +static int secp256k1_ge_set_xo_var(secp256k1_ge *r, const secp256k1_fe *x, int odd); + +/** Check whether a group element is the point at infinity. */ +static int secp256k1_ge_is_infinity(const secp256k1_ge *a); + +/** Check whether a group element is valid (i.e., on the curve). */ +static int secp256k1_ge_is_valid_var(const secp256k1_ge *a); + +static void secp256k1_ge_neg(secp256k1_ge *r, const secp256k1_ge *a); + +/** Set a group element equal to another which is given in jacobian coordinates */ +static void secp256k1_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a); + +/** Set a batch of group elements equal to the inputs given in jacobian coordinates */ +static void secp256k1_ge_set_all_gej_var(size_t len, secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_callback *cb); + +/** Set a batch of group elements equal to the inputs given in jacobian + * coordinates (with known z-ratios). zr must contain the known z-ratios such + * that mul(a[i].z, zr[i+1]) == a[i+1].z. zr[0] is ignored. */ +static void secp256k1_ge_set_table_gej_var(size_t len, secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zr); + +/** Bring a batch inputs given in jacobian coordinates (with known z-ratios) to + * the same global z "denominator". zr must contain the known z-ratios such + * that mul(a[i].z, zr[i+1]) == a[i+1].z. zr[0] is ignored. The x and y + * coordinates of the result are stored in r, the common z coordinate is + * stored in globalz. */ +static void secp256k1_ge_globalz_set_table_gej(size_t len, secp256k1_ge *r, secp256k1_fe *globalz, const secp256k1_gej *a, const secp256k1_fe *zr); + +/** Set a group element (jacobian) equal to the point at infinity. */ +static void secp256k1_gej_set_infinity(secp256k1_gej *r); + +/** Set a group element (jacobian) equal to another which is given in affine coordinates. */ +static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a); + +/** Compare the X coordinate of a group element (jacobian). */ +static int secp256k1_gej_eq_x_var(const secp256k1_fe *x, const secp256k1_gej *a); + +/** Set r equal to the inverse of a (i.e., mirrored around the X axis) */ +static void secp256k1_gej_neg(secp256k1_gej *r, const secp256k1_gej *a); + +/** Check whether a group element is the point at infinity. */ +static int secp256k1_gej_is_infinity(const secp256k1_gej *a); + +/** Set r equal to the double of a. If rzr is not-NULL, r->z = a->z * *rzr (where infinity means an implicit z = 0). + * a may not be zero. Constant time. */ +static void secp256k1_gej_double_nonzero(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr); + +/** Set r equal to the double of a. If rzr is not-NULL, r->z = a->z * *rzr (where infinity means an implicit z = 0). */ +static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr); + +/** Set r equal to the sum of a and b. If rzr is non-NULL, r->z = a->z * *rzr (a cannot be infinity in that case). */ +static void secp256k1_gej_add_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_gej *b, secp256k1_fe *rzr); + +/** Set r equal to the sum of a and b (with b given in affine coordinates, and not infinity). */ +static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b); + +/** Set r equal to the sum of a and b (with b given in affine coordinates). This is more efficient + than secp256k1_gej_add_var. It is identical to secp256k1_gej_add_ge but without constant-time + guarantee, and b is allowed to be infinity. If rzr is non-NULL, r->z = a->z * *rzr (a cannot be infinity in that case). */ +static void secp256k1_gej_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr); + +/** Set r equal to the sum of a and b (with the inverse of b's Z coordinate passed as bzinv). */ +static void secp256k1_gej_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, const secp256k1_fe *bzinv); + +#ifdef USE_ENDOMORPHISM +/** Set r to be equal to lambda times a, where lambda is chosen in a way such that this is very fast. */ +static void secp256k1_ge_mul_lambda(secp256k1_ge *r, const secp256k1_ge *a); +#endif + +/** Clear a secp256k1_gej to prevent leaking sensitive information. */ +static void secp256k1_gej_clear(secp256k1_gej *r); + +/** Clear a secp256k1_ge to prevent leaking sensitive information. */ +static void secp256k1_ge_clear(secp256k1_ge *r); + +/** Convert a group element to the storage type. */ +static void secp256k1_ge_to_storage(secp256k1_ge_storage *r, const secp256k1_ge *a); + +/** Convert a group element back from the storage type. */ +static void secp256k1_ge_from_storage(secp256k1_ge *r, const secp256k1_ge_storage *a); + +/** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. */ +static void secp256k1_ge_storage_cmov(secp256k1_ge_storage *r, const secp256k1_ge_storage *a, int flag); + +/** Rescale a jacobian point by b which must be non-zero. Constant-time. */ +static void secp256k1_gej_rescale(secp256k1_gej *r, const secp256k1_fe *b); + +#endif diff --git a/src/secp256k1/src/group_impl.h b/src/secp256k1/src/group_impl.h new file mode 100644 index 0000000..42e2f6e --- /dev/null +++ b/src/secp256k1/src/group_impl.h @@ -0,0 +1,626 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_GROUP_IMPL_H_ +#define _SECP256K1_GROUP_IMPL_H_ + +#include + +#include "num.h" +#include "field.h" +#include "group.h" + +/** Generator for secp256k1, value 'g' defined in + * "Standards for Efficient Cryptography" (SEC2) 2.7.1. + */ +static const secp256k1_ge secp256k1_ge_const_g = SECP256K1_GE_CONST( + 0x79BE667EUL, 0xF9DCBBACUL, 0x55A06295UL, 0xCE870B07UL, + 0x029BFCDBUL, 0x2DCE28D9UL, 0x59F2815BUL, 0x16F81798UL, + 0x483ADA77UL, 0x26A3C465UL, 0x5DA4FBFCUL, 0x0E1108A8UL, + 0xFD17B448UL, 0xA6855419UL, 0x9C47D08FUL, 0xFB10D4B8UL +); + +static void secp256k1_ge_set_gej_zinv(secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zi) { + secp256k1_fe zi2; + secp256k1_fe zi3; + secp256k1_fe_sqr(&zi2, zi); + secp256k1_fe_mul(&zi3, &zi2, zi); + secp256k1_fe_mul(&r->x, &a->x, &zi2); + secp256k1_fe_mul(&r->y, &a->y, &zi3); + r->infinity = a->infinity; +} + +static void secp256k1_ge_set_xy(secp256k1_ge *r, const secp256k1_fe *x, const secp256k1_fe *y) { + r->infinity = 0; + r->x = *x; + r->y = *y; +} + +static int secp256k1_ge_is_infinity(const secp256k1_ge *a) { + return a->infinity; +} + +static void secp256k1_ge_neg(secp256k1_ge *r, const secp256k1_ge *a) { + *r = *a; + secp256k1_fe_normalize_weak(&r->y); + secp256k1_fe_negate(&r->y, &r->y, 1); +} + +static void secp256k1_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a) { + secp256k1_fe z2, z3; + r->infinity = a->infinity; + secp256k1_fe_inv(&a->z, &a->z); + secp256k1_fe_sqr(&z2, &a->z); + secp256k1_fe_mul(&z3, &a->z, &z2); + secp256k1_fe_mul(&a->x, &a->x, &z2); + secp256k1_fe_mul(&a->y, &a->y, &z3); + secp256k1_fe_set_int(&a->z, 1); + r->x = a->x; + r->y = a->y; +} + +static void secp256k1_ge_set_gej_var(secp256k1_ge *r, secp256k1_gej *a) { + secp256k1_fe z2, z3; + r->infinity = a->infinity; + if (a->infinity) { + return; + } + secp256k1_fe_inv_var(&a->z, &a->z); + secp256k1_fe_sqr(&z2, &a->z); + secp256k1_fe_mul(&z3, &a->z, &z2); + secp256k1_fe_mul(&a->x, &a->x, &z2); + secp256k1_fe_mul(&a->y, &a->y, &z3); + secp256k1_fe_set_int(&a->z, 1); + r->x = a->x; + r->y = a->y; +} + +static void secp256k1_ge_set_all_gej_var(size_t len, secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_callback *cb) { + secp256k1_fe *az; + secp256k1_fe *azi; + size_t i; + size_t count = 0; + az = (secp256k1_fe *)checked_malloc(cb, sizeof(secp256k1_fe) * len); + for (i = 0; i < len; i++) { + if (!a[i].infinity) { + az[count++] = a[i].z; + } + } + + azi = (secp256k1_fe *)checked_malloc(cb, sizeof(secp256k1_fe) * count); + secp256k1_fe_inv_all_var(count, azi, az); + free(az); + + count = 0; + for (i = 0; i < len; i++) { + r[i].infinity = a[i].infinity; + if (!a[i].infinity) { + secp256k1_ge_set_gej_zinv(&r[i], &a[i], &azi[count++]); + } + } + free(azi); +} + +static void secp256k1_ge_set_table_gej_var(size_t len, secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zr) { + size_t i = len - 1; + secp256k1_fe zi; + + if (len > 0) { + /* Compute the inverse of the last z coordinate, and use it to compute the last affine output. */ + secp256k1_fe_inv(&zi, &a[i].z); + secp256k1_ge_set_gej_zinv(&r[i], &a[i], &zi); + + /* Work out way backwards, using the z-ratios to scale the x/y values. */ + while (i > 0) { + secp256k1_fe_mul(&zi, &zi, &zr[i]); + i--; + secp256k1_ge_set_gej_zinv(&r[i], &a[i], &zi); + } + } +} + +static void secp256k1_ge_globalz_set_table_gej(size_t len, secp256k1_ge *r, secp256k1_fe *globalz, const secp256k1_gej *a, const secp256k1_fe *zr) { + size_t i = len - 1; + secp256k1_fe zs; + + if (len > 0) { + /* The z of the final point gives us the "global Z" for the table. */ + r[i].x = a[i].x; + r[i].y = a[i].y; + *globalz = a[i].z; + r[i].infinity = 0; + zs = zr[i]; + + /* Work our way backwards, using the z-ratios to scale the x/y values. */ + while (i > 0) { + if (i != len - 1) { + secp256k1_fe_mul(&zs, &zs, &zr[i]); + } + i--; + secp256k1_ge_set_gej_zinv(&r[i], &a[i], &zs); + } + } +} + +static void secp256k1_gej_set_infinity(secp256k1_gej *r) { + r->infinity = 1; + secp256k1_fe_set_int(&r->x, 0); + secp256k1_fe_set_int(&r->y, 0); + secp256k1_fe_set_int(&r->z, 0); +} + +static void secp256k1_gej_clear(secp256k1_gej *r) { + r->infinity = 0; + secp256k1_fe_clear(&r->x); + secp256k1_fe_clear(&r->y); + secp256k1_fe_clear(&r->z); +} + +static void secp256k1_ge_clear(secp256k1_ge *r) { + r->infinity = 0; + secp256k1_fe_clear(&r->x); + secp256k1_fe_clear(&r->y); +} + +static int secp256k1_ge_set_xquad_var(secp256k1_ge *r, const secp256k1_fe *x) { + secp256k1_fe x2, x3, c; + r->x = *x; + secp256k1_fe_sqr(&x2, x); + secp256k1_fe_mul(&x3, x, &x2); + r->infinity = 0; + secp256k1_fe_set_int(&c, 7); + secp256k1_fe_add(&c, &x3); + return secp256k1_fe_sqrt_var(&r->y, &c); +} + +static int secp256k1_ge_set_xo_var(secp256k1_ge *r, const secp256k1_fe *x, int odd) { + if (!secp256k1_ge_set_xquad_var(r, x)) { + return 0; + } + secp256k1_fe_normalize_var(&r->y); + if (secp256k1_fe_is_odd(&r->y) != odd) { + secp256k1_fe_negate(&r->y, &r->y, 1); + } + return 1; + +} + +static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a) { + r->infinity = a->infinity; + r->x = a->x; + r->y = a->y; + secp256k1_fe_set_int(&r->z, 1); +} + +static int secp256k1_gej_eq_x_var(const secp256k1_fe *x, const secp256k1_gej *a) { + secp256k1_fe r, r2; + VERIFY_CHECK(!a->infinity); + secp256k1_fe_sqr(&r, &a->z); secp256k1_fe_mul(&r, &r, x); + r2 = a->x; secp256k1_fe_normalize_weak(&r2); + return secp256k1_fe_equal_var(&r, &r2); +} + +static void secp256k1_gej_neg(secp256k1_gej *r, const secp256k1_gej *a) { + r->infinity = a->infinity; + r->x = a->x; + r->y = a->y; + r->z = a->z; + secp256k1_fe_normalize_weak(&r->y); + secp256k1_fe_negate(&r->y, &r->y, 1); +} + +static int secp256k1_gej_is_infinity(const secp256k1_gej *a) { + return a->infinity; +} + +static int secp256k1_gej_is_valid_var(const secp256k1_gej *a) { + secp256k1_fe y2, x3, z2, z6; + if (a->infinity) { + return 0; + } + /** y^2 = x^3 + 7 + * (Y/Z^3)^2 = (X/Z^2)^3 + 7 + * Y^2 / Z^6 = X^3 / Z^6 + 7 + * Y^2 = X^3 + 7*Z^6 + */ + secp256k1_fe_sqr(&y2, &a->y); + secp256k1_fe_sqr(&x3, &a->x); secp256k1_fe_mul(&x3, &x3, &a->x); + secp256k1_fe_sqr(&z2, &a->z); + secp256k1_fe_sqr(&z6, &z2); secp256k1_fe_mul(&z6, &z6, &z2); + secp256k1_fe_mul_int(&z6, 7); + secp256k1_fe_add(&x3, &z6); + secp256k1_fe_normalize_weak(&x3); + return secp256k1_fe_equal_var(&y2, &x3); +} + +static int secp256k1_ge_is_valid_var(const secp256k1_ge *a) { + secp256k1_fe y2, x3, c; + if (a->infinity) { + return 0; + } + /* y^2 = x^3 + 7 */ + secp256k1_fe_sqr(&y2, &a->y); + secp256k1_fe_sqr(&x3, &a->x); secp256k1_fe_mul(&x3, &x3, &a->x); + secp256k1_fe_set_int(&c, 7); + secp256k1_fe_add(&x3, &c); + secp256k1_fe_normalize_weak(&x3); + return secp256k1_fe_equal_var(&y2, &x3); +} + +static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr) { + /* Operations: 3 mul, 4 sqr, 0 normalize, 12 mul_int/add/negate */ + secp256k1_fe t1,t2,t3,t4; + /** For secp256k1, 2Q is infinity if and only if Q is infinity. This is because if 2Q = infinity, + * Q must equal -Q, or that Q.y == -(Q.y), or Q.y is 0. For a point on y^2 = x^3 + 7 to have + * y=0, x^3 must be -7 mod p. However, -7 has no cube root mod p. + */ + r->infinity = a->infinity; + if (r->infinity) { + if (rzr != NULL) { + secp256k1_fe_set_int(rzr, 1); + } + return; + } + + if (rzr != NULL) { + *rzr = a->y; + secp256k1_fe_normalize_weak(rzr); + secp256k1_fe_mul_int(rzr, 2); + } + + secp256k1_fe_mul(&r->z, &a->z, &a->y); + secp256k1_fe_mul_int(&r->z, 2); /* Z' = 2*Y*Z (2) */ + secp256k1_fe_sqr(&t1, &a->x); + secp256k1_fe_mul_int(&t1, 3); /* T1 = 3*X^2 (3) */ + secp256k1_fe_sqr(&t2, &t1); /* T2 = 9*X^4 (1) */ + secp256k1_fe_sqr(&t3, &a->y); + secp256k1_fe_mul_int(&t3, 2); /* T3 = 2*Y^2 (2) */ + secp256k1_fe_sqr(&t4, &t3); + secp256k1_fe_mul_int(&t4, 2); /* T4 = 8*Y^4 (2) */ + secp256k1_fe_mul(&t3, &t3, &a->x); /* T3 = 2*X*Y^2 (1) */ + r->x = t3; + secp256k1_fe_mul_int(&r->x, 4); /* X' = 8*X*Y^2 (4) */ + secp256k1_fe_negate(&r->x, &r->x, 4); /* X' = -8*X*Y^2 (5) */ + secp256k1_fe_add(&r->x, &t2); /* X' = 9*X^4 - 8*X*Y^2 (6) */ + secp256k1_fe_negate(&t2, &t2, 1); /* T2 = -9*X^4 (2) */ + secp256k1_fe_mul_int(&t3, 6); /* T3 = 12*X*Y^2 (6) */ + secp256k1_fe_add(&t3, &t2); /* T3 = 12*X*Y^2 - 9*X^4 (8) */ + secp256k1_fe_mul(&r->y, &t1, &t3); /* Y' = 36*X^3*Y^2 - 27*X^6 (1) */ + secp256k1_fe_negate(&t2, &t4, 2); /* T2 = -8*Y^4 (3) */ + secp256k1_fe_add(&r->y, &t2); /* Y' = 36*X^3*Y^2 - 27*X^6 - 8*Y^4 (4) */ +} + +static SECP256K1_INLINE void secp256k1_gej_double_nonzero(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr) { + VERIFY_CHECK(!secp256k1_gej_is_infinity(a)); + secp256k1_gej_double_var(r, a, rzr); +} + +static void secp256k1_gej_add_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_gej *b, secp256k1_fe *rzr) { + /* Operations: 12 mul, 4 sqr, 2 normalize, 12 mul_int/add/negate */ + secp256k1_fe z22, z12, u1, u2, s1, s2, h, i, i2, h2, h3, t; + + if (a->infinity) { + VERIFY_CHECK(rzr == NULL); + *r = *b; + return; + } + + if (b->infinity) { + if (rzr != NULL) { + secp256k1_fe_set_int(rzr, 1); + } + *r = *a; + return; + } + + r->infinity = 0; + secp256k1_fe_sqr(&z22, &b->z); + secp256k1_fe_sqr(&z12, &a->z); + secp256k1_fe_mul(&u1, &a->x, &z22); + secp256k1_fe_mul(&u2, &b->x, &z12); + secp256k1_fe_mul(&s1, &a->y, &z22); secp256k1_fe_mul(&s1, &s1, &b->z); + secp256k1_fe_mul(&s2, &b->y, &z12); secp256k1_fe_mul(&s2, &s2, &a->z); + secp256k1_fe_negate(&h, &u1, 1); secp256k1_fe_add(&h, &u2); + secp256k1_fe_negate(&i, &s1, 1); secp256k1_fe_add(&i, &s2); + if (secp256k1_fe_normalizes_to_zero_var(&h)) { + if (secp256k1_fe_normalizes_to_zero_var(&i)) { + secp256k1_gej_double_var(r, a, rzr); + } else { + if (rzr != NULL) { + secp256k1_fe_set_int(rzr, 0); + } + r->infinity = 1; + } + return; + } + secp256k1_fe_sqr(&i2, &i); + secp256k1_fe_sqr(&h2, &h); + secp256k1_fe_mul(&h3, &h, &h2); + secp256k1_fe_mul(&h, &h, &b->z); + if (rzr != NULL) { + *rzr = h; + } + secp256k1_fe_mul(&r->z, &a->z, &h); + secp256k1_fe_mul(&t, &u1, &h2); + r->x = t; secp256k1_fe_mul_int(&r->x, 2); secp256k1_fe_add(&r->x, &h3); secp256k1_fe_negate(&r->x, &r->x, 3); secp256k1_fe_add(&r->x, &i2); + secp256k1_fe_negate(&r->y, &r->x, 5); secp256k1_fe_add(&r->y, &t); secp256k1_fe_mul(&r->y, &r->y, &i); + secp256k1_fe_mul(&h3, &h3, &s1); secp256k1_fe_negate(&h3, &h3, 1); + secp256k1_fe_add(&r->y, &h3); +} + +static void secp256k1_gej_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr) { + /* 8 mul, 3 sqr, 4 normalize, 12 mul_int/add/negate */ + secp256k1_fe z12, u1, u2, s1, s2, h, i, i2, h2, h3, t; + if (a->infinity) { + VERIFY_CHECK(rzr == NULL); + secp256k1_gej_set_ge(r, b); + return; + } + if (b->infinity) { + if (rzr != NULL) { + secp256k1_fe_set_int(rzr, 1); + } + *r = *a; + return; + } + r->infinity = 0; + + secp256k1_fe_sqr(&z12, &a->z); + u1 = a->x; secp256k1_fe_normalize_weak(&u1); + secp256k1_fe_mul(&u2, &b->x, &z12); + s1 = a->y; secp256k1_fe_normalize_weak(&s1); + secp256k1_fe_mul(&s2, &b->y, &z12); secp256k1_fe_mul(&s2, &s2, &a->z); + secp256k1_fe_negate(&h, &u1, 1); secp256k1_fe_add(&h, &u2); + secp256k1_fe_negate(&i, &s1, 1); secp256k1_fe_add(&i, &s2); + if (secp256k1_fe_normalizes_to_zero_var(&h)) { + if (secp256k1_fe_normalizes_to_zero_var(&i)) { + secp256k1_gej_double_var(r, a, rzr); + } else { + if (rzr != NULL) { + secp256k1_fe_set_int(rzr, 0); + } + r->infinity = 1; + } + return; + } + secp256k1_fe_sqr(&i2, &i); + secp256k1_fe_sqr(&h2, &h); + secp256k1_fe_mul(&h3, &h, &h2); + if (rzr != NULL) { + *rzr = h; + } + secp256k1_fe_mul(&r->z, &a->z, &h); + secp256k1_fe_mul(&t, &u1, &h2); + r->x = t; secp256k1_fe_mul_int(&r->x, 2); secp256k1_fe_add(&r->x, &h3); secp256k1_fe_negate(&r->x, &r->x, 3); secp256k1_fe_add(&r->x, &i2); + secp256k1_fe_negate(&r->y, &r->x, 5); secp256k1_fe_add(&r->y, &t); secp256k1_fe_mul(&r->y, &r->y, &i); + secp256k1_fe_mul(&h3, &h3, &s1); secp256k1_fe_negate(&h3, &h3, 1); + secp256k1_fe_add(&r->y, &h3); +} + +static void secp256k1_gej_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, const secp256k1_fe *bzinv) { + /* 9 mul, 3 sqr, 4 normalize, 12 mul_int/add/negate */ + secp256k1_fe az, z12, u1, u2, s1, s2, h, i, i2, h2, h3, t; + + if (b->infinity) { + *r = *a; + return; + } + if (a->infinity) { + secp256k1_fe bzinv2, bzinv3; + r->infinity = b->infinity; + secp256k1_fe_sqr(&bzinv2, bzinv); + secp256k1_fe_mul(&bzinv3, &bzinv2, bzinv); + secp256k1_fe_mul(&r->x, &b->x, &bzinv2); + secp256k1_fe_mul(&r->y, &b->y, &bzinv3); + secp256k1_fe_set_int(&r->z, 1); + return; + } + r->infinity = 0; + + /** We need to calculate (rx,ry,rz) = (ax,ay,az) + (bx,by,1/bzinv). Due to + * secp256k1's isomorphism we can multiply the Z coordinates on both sides + * by bzinv, and get: (rx,ry,rz*bzinv) = (ax,ay,az*bzinv) + (bx,by,1). + * This means that (rx,ry,rz) can be calculated as + * (ax,ay,az*bzinv) + (bx,by,1), when not applying the bzinv factor to rz. + * The variable az below holds the modified Z coordinate for a, which is used + * for the computation of rx and ry, but not for rz. + */ + secp256k1_fe_mul(&az, &a->z, bzinv); + + secp256k1_fe_sqr(&z12, &az); + u1 = a->x; secp256k1_fe_normalize_weak(&u1); + secp256k1_fe_mul(&u2, &b->x, &z12); + s1 = a->y; secp256k1_fe_normalize_weak(&s1); + secp256k1_fe_mul(&s2, &b->y, &z12); secp256k1_fe_mul(&s2, &s2, &az); + secp256k1_fe_negate(&h, &u1, 1); secp256k1_fe_add(&h, &u2); + secp256k1_fe_negate(&i, &s1, 1); secp256k1_fe_add(&i, &s2); + if (secp256k1_fe_normalizes_to_zero_var(&h)) { + if (secp256k1_fe_normalizes_to_zero_var(&i)) { + secp256k1_gej_double_var(r, a, NULL); + } else { + r->infinity = 1; + } + return; + } + secp256k1_fe_sqr(&i2, &i); + secp256k1_fe_sqr(&h2, &h); + secp256k1_fe_mul(&h3, &h, &h2); + r->z = a->z; secp256k1_fe_mul(&r->z, &r->z, &h); + secp256k1_fe_mul(&t, &u1, &h2); + r->x = t; secp256k1_fe_mul_int(&r->x, 2); secp256k1_fe_add(&r->x, &h3); secp256k1_fe_negate(&r->x, &r->x, 3); secp256k1_fe_add(&r->x, &i2); + secp256k1_fe_negate(&r->y, &r->x, 5); secp256k1_fe_add(&r->y, &t); secp256k1_fe_mul(&r->y, &r->y, &i); + secp256k1_fe_mul(&h3, &h3, &s1); secp256k1_fe_negate(&h3, &h3, 1); + secp256k1_fe_add(&r->y, &h3); +} + + +static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b) { + /* Operations: 7 mul, 5 sqr, 4 normalize, 21 mul_int/add/negate/cmov */ + static const secp256k1_fe fe_1 = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1); + secp256k1_fe zz, u1, u2, s1, s2, t, tt, m, n, q, rr; + secp256k1_fe m_alt, rr_alt; + int infinity, degenerate; + VERIFY_CHECK(!b->infinity); + VERIFY_CHECK(a->infinity == 0 || a->infinity == 1); + + /** In: + * Eric Brier and Marc Joye, Weierstrass Elliptic Curves and Side-Channel Attacks. + * In D. Naccache and P. Paillier, Eds., Public Key Cryptography, vol. 2274 of Lecture Notes in Computer Science, pages 335-345. Springer-Verlag, 2002. + * we find as solution for a unified addition/doubling formula: + * lambda = ((x1 + x2)^2 - x1 * x2 + a) / (y1 + y2), with a = 0 for secp256k1's curve equation. + * x3 = lambda^2 - (x1 + x2) + * 2*y3 = lambda * (x1 + x2 - 2 * x3) - (y1 + y2). + * + * Substituting x_i = Xi / Zi^2 and yi = Yi / Zi^3, for i=1,2,3, gives: + * U1 = X1*Z2^2, U2 = X2*Z1^2 + * S1 = Y1*Z2^3, S2 = Y2*Z1^3 + * Z = Z1*Z2 + * T = U1+U2 + * M = S1+S2 + * Q = T*M^2 + * R = T^2-U1*U2 + * X3 = 4*(R^2-Q) + * Y3 = 4*(R*(3*Q-2*R^2)-M^4) + * Z3 = 2*M*Z + * (Note that the paper uses xi = Xi / Zi and yi = Yi / Zi instead.) + * + * This formula has the benefit of being the same for both addition + * of distinct points and doubling. However, it breaks down in the + * case that either point is infinity, or that y1 = -y2. We handle + * these cases in the following ways: + * + * - If b is infinity we simply bail by means of a VERIFY_CHECK. + * + * - If a is infinity, we detect this, and at the end of the + * computation replace the result (which will be meaningless, + * but we compute to be constant-time) with b.x : b.y : 1. + * + * - If a = -b, we have y1 = -y2, which is a degenerate case. + * But here the answer is infinity, so we simply set the + * infinity flag of the result, overriding the computed values + * without even needing to cmov. + * + * - If y1 = -y2 but x1 != x2, which does occur thanks to certain + * properties of our curve (specifically, 1 has nontrivial cube + * roots in our field, and the curve equation has no x coefficient) + * then the answer is not infinity but also not given by the above + * equation. In this case, we cmov in place an alternate expression + * for lambda. Specifically (y1 - y2)/(x1 - x2). Where both these + * expressions for lambda are defined, they are equal, and can be + * obtained from each other by multiplication by (y1 + y2)/(y1 + y2) + * then substitution of x^3 + 7 for y^2 (using the curve equation). + * For all pairs of nonzero points (a, b) at least one is defined, + * so this covers everything. + */ + + secp256k1_fe_sqr(&zz, &a->z); /* z = Z1^2 */ + u1 = a->x; secp256k1_fe_normalize_weak(&u1); /* u1 = U1 = X1*Z2^2 (1) */ + secp256k1_fe_mul(&u2, &b->x, &zz); /* u2 = U2 = X2*Z1^2 (1) */ + s1 = a->y; secp256k1_fe_normalize_weak(&s1); /* s1 = S1 = Y1*Z2^3 (1) */ + secp256k1_fe_mul(&s2, &b->y, &zz); /* s2 = Y2*Z1^2 (1) */ + secp256k1_fe_mul(&s2, &s2, &a->z); /* s2 = S2 = Y2*Z1^3 (1) */ + t = u1; secp256k1_fe_add(&t, &u2); /* t = T = U1+U2 (2) */ + m = s1; secp256k1_fe_add(&m, &s2); /* m = M = S1+S2 (2) */ + secp256k1_fe_sqr(&rr, &t); /* rr = T^2 (1) */ + secp256k1_fe_negate(&m_alt, &u2, 1); /* Malt = -X2*Z1^2 */ + secp256k1_fe_mul(&tt, &u1, &m_alt); /* tt = -U1*U2 (2) */ + secp256k1_fe_add(&rr, &tt); /* rr = R = T^2-U1*U2 (3) */ + /** If lambda = R/M = 0/0 we have a problem (except in the "trivial" + * case that Z = z1z2 = 0, and this is special-cased later on). */ + degenerate = secp256k1_fe_normalizes_to_zero(&m) & + secp256k1_fe_normalizes_to_zero(&rr); + /* This only occurs when y1 == -y2 and x1^3 == x2^3, but x1 != x2. + * This means either x1 == beta*x2 or beta*x1 == x2, where beta is + * a nontrivial cube root of one. In either case, an alternate + * non-indeterminate expression for lambda is (y1 - y2)/(x1 - x2), + * so we set R/M equal to this. */ + rr_alt = s1; + secp256k1_fe_mul_int(&rr_alt, 2); /* rr = Y1*Z2^3 - Y2*Z1^3 (2) */ + secp256k1_fe_add(&m_alt, &u1); /* Malt = X1*Z2^2 - X2*Z1^2 */ + + secp256k1_fe_cmov(&rr_alt, &rr, !degenerate); + secp256k1_fe_cmov(&m_alt, &m, !degenerate); + /* Now Ralt / Malt = lambda and is guaranteed not to be 0/0. + * From here on out Ralt and Malt represent the numerator + * and denominator of lambda; R and M represent the explicit + * expressions x1^2 + x2^2 + x1x2 and y1 + y2. */ + secp256k1_fe_sqr(&n, &m_alt); /* n = Malt^2 (1) */ + secp256k1_fe_mul(&q, &n, &t); /* q = Q = T*Malt^2 (1) */ + /* These two lines use the observation that either M == Malt or M == 0, + * so M^3 * Malt is either Malt^4 (which is computed by squaring), or + * zero (which is "computed" by cmov). So the cost is one squaring + * versus two multiplications. */ + secp256k1_fe_sqr(&n, &n); + secp256k1_fe_cmov(&n, &m, degenerate); /* n = M^3 * Malt (2) */ + secp256k1_fe_sqr(&t, &rr_alt); /* t = Ralt^2 (1) */ + secp256k1_fe_mul(&r->z, &a->z, &m_alt); /* r->z = Malt*Z (1) */ + infinity = secp256k1_fe_normalizes_to_zero(&r->z) * (1 - a->infinity); + secp256k1_fe_mul_int(&r->z, 2); /* r->z = Z3 = 2*Malt*Z (2) */ + secp256k1_fe_negate(&q, &q, 1); /* q = -Q (2) */ + secp256k1_fe_add(&t, &q); /* t = Ralt^2-Q (3) */ + secp256k1_fe_normalize_weak(&t); + r->x = t; /* r->x = Ralt^2-Q (1) */ + secp256k1_fe_mul_int(&t, 2); /* t = 2*x3 (2) */ + secp256k1_fe_add(&t, &q); /* t = 2*x3 - Q: (4) */ + secp256k1_fe_mul(&t, &t, &rr_alt); /* t = Ralt*(2*x3 - Q) (1) */ + secp256k1_fe_add(&t, &n); /* t = Ralt*(2*x3 - Q) + M^3*Malt (3) */ + secp256k1_fe_negate(&r->y, &t, 3); /* r->y = Ralt*(Q - 2x3) - M^3*Malt (4) */ + secp256k1_fe_normalize_weak(&r->y); + secp256k1_fe_mul_int(&r->x, 4); /* r->x = X3 = 4*(Ralt^2-Q) */ + secp256k1_fe_mul_int(&r->y, 4); /* r->y = Y3 = 4*Ralt*(Q - 2x3) - 4*M^3*Malt (4) */ + + /** In case a->infinity == 1, replace r with (b->x, b->y, 1). */ + secp256k1_fe_cmov(&r->x, &b->x, a->infinity); + secp256k1_fe_cmov(&r->y, &b->y, a->infinity); + secp256k1_fe_cmov(&r->z, &fe_1, a->infinity); + r->infinity = infinity; +} + +static void secp256k1_gej_rescale(secp256k1_gej *r, const secp256k1_fe *s) { + /* Operations: 4 mul, 1 sqr */ + secp256k1_fe zz; + VERIFY_CHECK(!secp256k1_fe_is_zero(s)); + secp256k1_fe_sqr(&zz, s); + secp256k1_fe_mul(&r->x, &r->x, &zz); /* r->x *= s^2 */ + secp256k1_fe_mul(&r->y, &r->y, &zz); + secp256k1_fe_mul(&r->y, &r->y, s); /* r->y *= s^3 */ + secp256k1_fe_mul(&r->z, &r->z, s); /* r->z *= s */ +} + +static void secp256k1_ge_to_storage(secp256k1_ge_storage *r, const secp256k1_ge *a) { + secp256k1_fe x, y; + VERIFY_CHECK(!a->infinity); + x = a->x; + secp256k1_fe_normalize(&x); + y = a->y; + secp256k1_fe_normalize(&y); + secp256k1_fe_to_storage(&r->x, &x); + secp256k1_fe_to_storage(&r->y, &y); +} + +static void secp256k1_ge_from_storage(secp256k1_ge *r, const secp256k1_ge_storage *a) { + secp256k1_fe_from_storage(&r->x, &a->x); + secp256k1_fe_from_storage(&r->y, &a->y); + r->infinity = 0; +} + +static SECP256K1_INLINE void secp256k1_ge_storage_cmov(secp256k1_ge_storage *r, const secp256k1_ge_storage *a, int flag) { + secp256k1_fe_storage_cmov(&r->x, &a->x, flag); + secp256k1_fe_storage_cmov(&r->y, &a->y, flag); +} + +#ifdef USE_ENDOMORPHISM +static void secp256k1_ge_mul_lambda(secp256k1_ge *r, const secp256k1_ge *a) { + static const secp256k1_fe beta = SECP256K1_FE_CONST( + 0x7ae96a2bul, 0x657c0710ul, 0x6e64479eul, 0xac3434e9ul, + 0x9cf04975ul, 0x12f58995ul, 0xc1396c28ul, 0x719501eeul + ); + *r = *a; + secp256k1_fe_mul(&r->x, &r->x, &beta); +} +#endif + +#endif diff --git a/src/secp256k1/src/hash.h b/src/secp256k1/src/hash.h new file mode 100644 index 0000000..0ff01e6 --- /dev/null +++ b/src/secp256k1/src/hash.h @@ -0,0 +1,41 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_HASH_ +#define _SECP256K1_HASH_ + +#include +#include + +typedef struct { + uint32_t s[32]; + uint32_t buf[16]; /* In big endian */ + size_t bytes; +} secp256k1_sha256_t; + +static void secp256k1_sha256_initialize(secp256k1_sha256_t *hash); +static void secp256k1_sha256_write(secp256k1_sha256_t *hash, const unsigned char *data, size_t size); +static void secp256k1_sha256_finalize(secp256k1_sha256_t *hash, unsigned char *out32); + +typedef struct { + secp256k1_sha256_t inner, outer; +} secp256k1_hmac_sha256_t; + +static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256_t *hash, const unsigned char *key, size_t size); +static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256_t *hash, const unsigned char *data, size_t size); +static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256_t *hash, unsigned char *out32); + +typedef struct { + unsigned char v[32]; + unsigned char k[32]; + int retry; +} secp256k1_rfc6979_hmac_sha256_t; + +static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256_t *rng, const unsigned char *key, size_t keylen); +static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256_t *rng, unsigned char *out, size_t outlen); +static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256_t *rng); + +#endif diff --git a/src/secp256k1/src/hash_impl.h b/src/secp256k1/src/hash_impl.h new file mode 100644 index 0000000..ae55df6 --- /dev/null +++ b/src/secp256k1/src/hash_impl.h @@ -0,0 +1,283 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_HASH_IMPL_H_ +#define _SECP256K1_HASH_IMPL_H_ + +#include "hash.h" + +#include +#include +#include + +#define Ch(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) +#define Maj(x,y,z) (((x) & (y)) | ((z) & ((x) | (y)))) +#define Sigma0(x) (((x) >> 2 | (x) << 30) ^ ((x) >> 13 | (x) << 19) ^ ((x) >> 22 | (x) << 10)) +#define Sigma1(x) (((x) >> 6 | (x) << 26) ^ ((x) >> 11 | (x) << 21) ^ ((x) >> 25 | (x) << 7)) +#define sigma0(x) (((x) >> 7 | (x) << 25) ^ ((x) >> 18 | (x) << 14) ^ ((x) >> 3)) +#define sigma1(x) (((x) >> 17 | (x) << 15) ^ ((x) >> 19 | (x) << 13) ^ ((x) >> 10)) + +#define Round(a,b,c,d,e,f,g,h,k,w) do { \ + uint32_t t1 = (h) + Sigma1(e) + Ch((e), (f), (g)) + (k) + (w); \ + uint32_t t2 = Sigma0(a) + Maj((a), (b), (c)); \ + (d) += t1; \ + (h) = t1 + t2; \ +} while(0) + +#ifdef WORDS_BIGENDIAN +#define BE32(x) (x) +#else +#define BE32(p) ((((p) & 0xFF) << 24) | (((p) & 0xFF00) << 8) | (((p) & 0xFF0000) >> 8) | (((p) & 0xFF000000) >> 24)) +#endif + +static void secp256k1_sha256_initialize(secp256k1_sha256_t *hash) { + hash->s[0] = 0x6a09e667ul; + hash->s[1] = 0xbb67ae85ul; + hash->s[2] = 0x3c6ef372ul; + hash->s[3] = 0xa54ff53aul; + hash->s[4] = 0x510e527ful; + hash->s[5] = 0x9b05688cul; + hash->s[6] = 0x1f83d9abul; + hash->s[7] = 0x5be0cd19ul; + hash->bytes = 0; +} + +/** Perform one SHA-256 transformation, processing 16 big endian 32-bit words. */ +static void secp256k1_sha256_transform(uint32_t* s, const uint32_t* chunk) { + uint32_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4], f = s[5], g = s[6], h = s[7]; + uint32_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15; + + Round(a, b, c, d, e, f, g, h, 0x428a2f98, w0 = BE32(chunk[0])); + Round(h, a, b, c, d, e, f, g, 0x71374491, w1 = BE32(chunk[1])); + Round(g, h, a, b, c, d, e, f, 0xb5c0fbcf, w2 = BE32(chunk[2])); + Round(f, g, h, a, b, c, d, e, 0xe9b5dba5, w3 = BE32(chunk[3])); + Round(e, f, g, h, a, b, c, d, 0x3956c25b, w4 = BE32(chunk[4])); + Round(d, e, f, g, h, a, b, c, 0x59f111f1, w5 = BE32(chunk[5])); + Round(c, d, e, f, g, h, a, b, 0x923f82a4, w6 = BE32(chunk[6])); + Round(b, c, d, e, f, g, h, a, 0xab1c5ed5, w7 = BE32(chunk[7])); + Round(a, b, c, d, e, f, g, h, 0xd807aa98, w8 = BE32(chunk[8])); + Round(h, a, b, c, d, e, f, g, 0x12835b01, w9 = BE32(chunk[9])); + Round(g, h, a, b, c, d, e, f, 0x243185be, w10 = BE32(chunk[10])); + Round(f, g, h, a, b, c, d, e, 0x550c7dc3, w11 = BE32(chunk[11])); + Round(e, f, g, h, a, b, c, d, 0x72be5d74, w12 = BE32(chunk[12])); + Round(d, e, f, g, h, a, b, c, 0x80deb1fe, w13 = BE32(chunk[13])); + Round(c, d, e, f, g, h, a, b, 0x9bdc06a7, w14 = BE32(chunk[14])); + Round(b, c, d, e, f, g, h, a, 0xc19bf174, w15 = BE32(chunk[15])); + + Round(a, b, c, d, e, f, g, h, 0xe49b69c1, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0xefbe4786, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x0fc19dc6, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x240ca1cc, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x2de92c6f, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x4a7484aa, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x5cb0a9dc, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x76f988da, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0x983e5152, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0xa831c66d, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0xb00327c8, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0xbf597fc7, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0xc6e00bf3, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xd5a79147, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0x06ca6351, w14 += sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0x14292967, w15 += sigma1(w13) + w8 + sigma0(w0)); + + Round(a, b, c, d, e, f, g, h, 0x27b70a85, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0x2e1b2138, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x4d2c6dfc, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x53380d13, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x650a7354, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x766a0abb, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x81c2c92e, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x92722c85, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0xa2bfe8a1, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0xa81a664b, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0xc24b8b70, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0xc76c51a3, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0xd192e819, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xd6990624, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0xf40e3585, w14 += sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0x106aa070, w15 += sigma1(w13) + w8 + sigma0(w0)); + + Round(a, b, c, d, e, f, g, h, 0x19a4c116, w0 += sigma1(w14) + w9 + sigma0(w1)); + Round(h, a, b, c, d, e, f, g, 0x1e376c08, w1 += sigma1(w15) + w10 + sigma0(w2)); + Round(g, h, a, b, c, d, e, f, 0x2748774c, w2 += sigma1(w0) + w11 + sigma0(w3)); + Round(f, g, h, a, b, c, d, e, 0x34b0bcb5, w3 += sigma1(w1) + w12 + sigma0(w4)); + Round(e, f, g, h, a, b, c, d, 0x391c0cb3, w4 += sigma1(w2) + w13 + sigma0(w5)); + Round(d, e, f, g, h, a, b, c, 0x4ed8aa4a, w5 += sigma1(w3) + w14 + sigma0(w6)); + Round(c, d, e, f, g, h, a, b, 0x5b9cca4f, w6 += sigma1(w4) + w15 + sigma0(w7)); + Round(b, c, d, e, f, g, h, a, 0x682e6ff3, w7 += sigma1(w5) + w0 + sigma0(w8)); + Round(a, b, c, d, e, f, g, h, 0x748f82ee, w8 += sigma1(w6) + w1 + sigma0(w9)); + Round(h, a, b, c, d, e, f, g, 0x78a5636f, w9 += sigma1(w7) + w2 + sigma0(w10)); + Round(g, h, a, b, c, d, e, f, 0x84c87814, w10 += sigma1(w8) + w3 + sigma0(w11)); + Round(f, g, h, a, b, c, d, e, 0x8cc70208, w11 += sigma1(w9) + w4 + sigma0(w12)); + Round(e, f, g, h, a, b, c, d, 0x90befffa, w12 += sigma1(w10) + w5 + sigma0(w13)); + Round(d, e, f, g, h, a, b, c, 0xa4506ceb, w13 += sigma1(w11) + w6 + sigma0(w14)); + Round(c, d, e, f, g, h, a, b, 0xbef9a3f7, w14 + sigma1(w12) + w7 + sigma0(w15)); + Round(b, c, d, e, f, g, h, a, 0xc67178f2, w15 + sigma1(w13) + w8 + sigma0(w0)); + + s[0] += a; + s[1] += b; + s[2] += c; + s[3] += d; + s[4] += e; + s[5] += f; + s[6] += g; + s[7] += h; +} + +static void secp256k1_sha256_write(secp256k1_sha256_t *hash, const unsigned char *data, size_t len) { + size_t bufsize = hash->bytes & 0x3F; + hash->bytes += len; + while (bufsize + len >= 64) { + /* Fill the buffer, and process it. */ + memcpy(((unsigned char*)hash->buf) + bufsize, data, 64 - bufsize); + data += 64 - bufsize; + len -= 64 - bufsize; + secp256k1_sha256_transform(hash->s, hash->buf); + bufsize = 0; + } + if (len) { + /* Fill the buffer with what remains. */ + memcpy(((unsigned char*)hash->buf) + bufsize, data, len); + } +} + +static void secp256k1_sha256_finalize(secp256k1_sha256_t *hash, unsigned char *out32) { + static const unsigned char pad[64] = {0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + uint32_t sizedesc[2]; + uint32_t out[8]; + int i = 0; + sizedesc[0] = BE32(hash->bytes >> 29); + sizedesc[1] = BE32(hash->bytes << 3); + secp256k1_sha256_write(hash, pad, 1 + ((119 - (hash->bytes % 64)) % 64)); + secp256k1_sha256_write(hash, (const unsigned char*)sizedesc, 8); + for (i = 0; i < 8; i++) { + out[i] = BE32(hash->s[i]); + hash->s[i] = 0; + } + memcpy(out32, (const unsigned char*)out, 32); +} + +static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256_t *hash, const unsigned char *key, size_t keylen) { + int n; + unsigned char rkey[64]; + if (keylen <= 64) { + memcpy(rkey, key, keylen); + memset(rkey + keylen, 0, 64 - keylen); + } else { + secp256k1_sha256_t sha256; + secp256k1_sha256_initialize(&sha256); + secp256k1_sha256_write(&sha256, key, keylen); + secp256k1_sha256_finalize(&sha256, rkey); + memset(rkey + 32, 0, 32); + } + + secp256k1_sha256_initialize(&hash->outer); + for (n = 0; n < 64; n++) { + rkey[n] ^= 0x5c; + } + secp256k1_sha256_write(&hash->outer, rkey, 64); + + secp256k1_sha256_initialize(&hash->inner); + for (n = 0; n < 64; n++) { + rkey[n] ^= 0x5c ^ 0x36; + } + secp256k1_sha256_write(&hash->inner, rkey, 64); + memset(rkey, 0, 64); +} + +static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256_t *hash, const unsigned char *data, size_t size) { + secp256k1_sha256_write(&hash->inner, data, size); +} + +static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256_t *hash, unsigned char *out32) { + unsigned char temp[32]; + secp256k1_sha256_finalize(&hash->inner, temp); + secp256k1_sha256_write(&hash->outer, temp, 32); + memset(temp, 0, 32); + secp256k1_sha256_finalize(&hash->outer, out32); +} + + +static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256_t *rng, const unsigned char *key, size_t keylen) { + secp256k1_hmac_sha256_t hmac; + static const unsigned char zero[1] = {0x00}; + static const unsigned char one[1] = {0x01}; + + memset(rng->v, 0x01, 32); /* RFC6979 3.2.b. */ + memset(rng->k, 0x00, 32); /* RFC6979 3.2.c. */ + + /* RFC6979 3.2.d. */ + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_write(&hmac, zero, 1); + secp256k1_hmac_sha256_write(&hmac, key, keylen); + secp256k1_hmac_sha256_finalize(&hmac, rng->k); + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_finalize(&hmac, rng->v); + + /* RFC6979 3.2.f. */ + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_write(&hmac, one, 1); + secp256k1_hmac_sha256_write(&hmac, key, keylen); + secp256k1_hmac_sha256_finalize(&hmac, rng->k); + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_finalize(&hmac, rng->v); + rng->retry = 0; +} + +static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256_t *rng, unsigned char *out, size_t outlen) { + /* RFC6979 3.2.h. */ + static const unsigned char zero[1] = {0x00}; + if (rng->retry) { + secp256k1_hmac_sha256_t hmac; + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_write(&hmac, zero, 1); + secp256k1_hmac_sha256_finalize(&hmac, rng->k); + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_finalize(&hmac, rng->v); + } + + while (outlen > 0) { + secp256k1_hmac_sha256_t hmac; + int now = outlen; + secp256k1_hmac_sha256_initialize(&hmac, rng->k, 32); + secp256k1_hmac_sha256_write(&hmac, rng->v, 32); + secp256k1_hmac_sha256_finalize(&hmac, rng->v); + if (now > 32) { + now = 32; + } + memcpy(out, rng->v, now); + out += now; + outlen -= now; + } + + rng->retry = 1; +} + +static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256_t *rng) { + memset(rng->k, 0, 32); + memset(rng->v, 0, 32); + rng->retry = 0; +} + + +#undef Round +#undef sigma0 +#undef sigma1 +#undef Sigma0 +#undef Sigma1 +#undef Ch +#undef Maj +#undef ReadBE32 +#undef WriteBE32 + +#endif diff --git a/src/secp256k1/src/java/org/bitcoin/NativeSecp256k1.java b/src/secp256k1/src/java/org/bitcoin/NativeSecp256k1.java new file mode 100644 index 0000000..90a498e --- /dev/null +++ b/src/secp256k1/src/java/org/bitcoin/NativeSecp256k1.java @@ -0,0 +1,60 @@ +package org.bitcoin; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +import com.google.common.base.Preconditions; + + +/** + * This class holds native methods to handle ECDSA verification. + * You can find an example library that can be used for this at + * https://github.com/sipa/secp256k1 + */ +public class NativeSecp256k1 { + public static final boolean enabled; + static { + boolean isEnabled = true; + try { + System.loadLibrary("javasecp256k1"); + } catch (UnsatisfiedLinkError e) { + isEnabled = false; + } + enabled = isEnabled; + } + + private static ThreadLocal nativeECDSABuffer = new ThreadLocal(); + /** + * Verifies the given secp256k1 signature in native code. + * Calling when enabled == false is undefined (probably library not loaded) + * + * @param data The data which was signed, must be exactly 32 bytes + * @param signature The signature + * @param pub The public key which did the signing + */ + public static boolean verify(byte[] data, byte[] signature, byte[] pub) { + Preconditions.checkArgument(data.length == 32 && signature.length <= 520 && pub.length <= 520); + + ByteBuffer byteBuff = nativeECDSABuffer.get(); + if (byteBuff == null) { + byteBuff = ByteBuffer.allocateDirect(32 + 8 + 520 + 520); + byteBuff.order(ByteOrder.nativeOrder()); + nativeECDSABuffer.set(byteBuff); + } + byteBuff.rewind(); + byteBuff.put(data); + byteBuff.putInt(signature.length); + byteBuff.putInt(pub.length); + byteBuff.put(signature); + byteBuff.put(pub); + return secp256k1_ecdsa_verify(byteBuff) == 1; + } + + /** + * @param byteBuff signature format is byte[32] data, + * native-endian int signatureLength, native-endian int pubkeyLength, + * byte[signatureLength] signature, byte[pubkeyLength] pub + * @returns 1 for valid signature, anything else for invalid + */ + private static native int secp256k1_ecdsa_verify(ByteBuffer byteBuff); +} diff --git a/src/secp256k1/src/java/org_bitcoin_NativeSecp256k1.c b/src/secp256k1/src/java/org_bitcoin_NativeSecp256k1.c new file mode 100644 index 0000000..bb4cd70 --- /dev/null +++ b/src/secp256k1/src/java/org_bitcoin_NativeSecp256k1.c @@ -0,0 +1,23 @@ +#include "org_bitcoin_NativeSecp256k1.h" +#include "include/secp256k1.h" + +JNIEXPORT jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1verify + (JNIEnv* env, jclass classObject, jobject byteBufferObject) +{ + unsigned char* data = (unsigned char*) (*env)->GetDirectBufferAddress(env, byteBufferObject); + int sigLen = *((int*)(data + 32)); + int pubLen = *((int*)(data + 32 + 4)); + + return secp256k1_ecdsa_verify(data, 32, data+32+8, sigLen, data+32+8+sigLen, pubLen); +} + +static void __javasecp256k1_attach(void) __attribute__((constructor)); +static void __javasecp256k1_detach(void) __attribute__((destructor)); + +static void __javasecp256k1_attach(void) { + secp256k1_start(SECP256K1_START_VERIFY); +} + +static void __javasecp256k1_detach(void) { + secp256k1_stop(); +} diff --git a/src/secp256k1/src/java/org_bitcoin_NativeSecp256k1.h b/src/secp256k1/src/java/org_bitcoin_NativeSecp256k1.h new file mode 100644 index 0000000..d7fb004 --- /dev/null +++ b/src/secp256k1/src/java/org_bitcoin_NativeSecp256k1.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_bitcoin_NativeSecp256k1 */ + +#ifndef _Included_org_bitcoin_NativeSecp256k1 +#define _Included_org_bitcoin_NativeSecp256k1 +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_bitcoin_NativeSecp256k1 + * Method: secp256k1_ecdsa_verify + * Signature: (Ljava/nio/ByteBuffer;)I + */ +JNIEXPORT jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1verify + (JNIEnv *, jclass, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/secp256k1/src/modules/ecdh/Makefile.am.include b/src/secp256k1/src/modules/ecdh/Makefile.am.include new file mode 100644 index 0000000..670b9c1 --- /dev/null +++ b/src/secp256k1/src/modules/ecdh/Makefile.am.include @@ -0,0 +1,8 @@ +include_HEADERS += include/secp256k1_ecdh.h +noinst_HEADERS += src/modules/ecdh/main_impl.h +noinst_HEADERS += src/modules/ecdh/tests_impl.h +if USE_BENCHMARK +noinst_PROGRAMS += bench_ecdh +bench_ecdh_SOURCES = src/bench_ecdh.c +bench_ecdh_LDADD = libsecp256k1.la $(SECP_LIBS) +endif diff --git a/src/secp256k1/src/modules/ecdh/main_impl.h b/src/secp256k1/src/modules/ecdh/main_impl.h new file mode 100644 index 0000000..c23e4f8 --- /dev/null +++ b/src/secp256k1/src/modules/ecdh/main_impl.h @@ -0,0 +1,54 @@ +/********************************************************************** + * Copyright (c) 2015 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_MODULE_ECDH_MAIN_ +#define _SECP256K1_MODULE_ECDH_MAIN_ + +#include "include/secp256k1_ecdh.h" +#include "ecmult_const_impl.h" + +int secp256k1_ecdh(const secp256k1_context* ctx, unsigned char *result, const secp256k1_pubkey *point, const unsigned char *scalar) { + int ret = 0; + int overflow = 0; + secp256k1_gej res; + secp256k1_ge pt; + secp256k1_scalar s; + ARG_CHECK(result != NULL); + ARG_CHECK(point != NULL); + ARG_CHECK(scalar != NULL); + (void)ctx; + + secp256k1_pubkey_load(ctx, &pt, point); + secp256k1_scalar_set_b32(&s, scalar, &overflow); + if (overflow || secp256k1_scalar_is_zero(&s)) { + ret = 0; + } else { + unsigned char x[32]; + unsigned char y[1]; + secp256k1_sha256_t sha; + + secp256k1_ecmult_const(&res, &pt, &s); + secp256k1_ge_set_gej(&pt, &res); + /* Compute a hash of the point in compressed form + * Note we cannot use secp256k1_eckey_pubkey_serialize here since it does not + * expect its output to be secret and has a timing sidechannel. */ + secp256k1_fe_normalize(&pt.x); + secp256k1_fe_normalize(&pt.y); + secp256k1_fe_get_b32(x, &pt.x); + y[0] = 0x02 | secp256k1_fe_is_odd(&pt.y); + + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, y, sizeof(y)); + secp256k1_sha256_write(&sha, x, sizeof(x)); + secp256k1_sha256_finalize(&sha, result); + ret = 1; + } + + secp256k1_scalar_clear(&s); + return ret; +} + +#endif diff --git a/src/secp256k1/src/modules/ecdh/tests_impl.h b/src/secp256k1/src/modules/ecdh/tests_impl.h new file mode 100644 index 0000000..7badc90 --- /dev/null +++ b/src/secp256k1/src/modules/ecdh/tests_impl.h @@ -0,0 +1,75 @@ +/********************************************************************** + * Copyright (c) 2015 Andrew Poelstra * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_MODULE_ECDH_TESTS_ +#define _SECP256K1_MODULE_ECDH_TESTS_ + +void test_ecdh_generator_basepoint(void) { + unsigned char s_one[32] = { 0 }; + secp256k1_pubkey point[2]; + int i; + + s_one[31] = 1; + /* Check against pubkey creation when the basepoint is the generator */ + for (i = 0; i < 100; ++i) { + secp256k1_sha256_t sha; + unsigned char s_b32[32]; + unsigned char output_ecdh[32]; + unsigned char output_ser[32]; + unsigned char point_ser[33]; + size_t point_ser_len = sizeof(point_ser); + secp256k1_scalar s; + + random_scalar_order(&s); + secp256k1_scalar_get_b32(s_b32, &s); + + /* compute using ECDH function */ + CHECK(secp256k1_ec_pubkey_create(ctx, &point[0], s_one) == 1); + CHECK(secp256k1_ecdh(ctx, output_ecdh, &point[0], s_b32) == 1); + /* compute "explicitly" */ + CHECK(secp256k1_ec_pubkey_create(ctx, &point[1], s_b32) == 1); + CHECK(secp256k1_ec_pubkey_serialize(ctx, point_ser, &point_ser_len, &point[1], SECP256K1_EC_COMPRESSED) == 1); + CHECK(point_ser_len == sizeof(point_ser)); + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, point_ser, point_ser_len); + secp256k1_sha256_finalize(&sha, output_ser); + /* compare */ + CHECK(memcmp(output_ecdh, output_ser, sizeof(output_ser)) == 0); + } +} + +void test_bad_scalar(void) { + unsigned char s_zero[32] = { 0 }; + unsigned char s_overflow[32] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, + 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41 + }; + unsigned char s_rand[32] = { 0 }; + unsigned char output[32]; + secp256k1_scalar rand; + secp256k1_pubkey point; + + /* Create random point */ + random_scalar_order(&rand); + secp256k1_scalar_get_b32(s_rand, &rand); + CHECK(secp256k1_ec_pubkey_create(ctx, &point, s_rand) == 1); + + /* Try to multiply it by bad values */ + CHECK(secp256k1_ecdh(ctx, output, &point, s_zero) == 0); + CHECK(secp256k1_ecdh(ctx, output, &point, s_overflow) == 0); + /* ...and a good one */ + s_overflow[31] -= 1; + CHECK(secp256k1_ecdh(ctx, output, &point, s_overflow) == 1); +} + +void run_ecdh_tests(void) { + test_ecdh_generator_basepoint(); + test_bad_scalar(); +} + +#endif diff --git a/src/secp256k1/src/modules/recovery/Makefile.am.include b/src/secp256k1/src/modules/recovery/Makefile.am.include new file mode 100644 index 0000000..5de3ea3 --- /dev/null +++ b/src/secp256k1/src/modules/recovery/Makefile.am.include @@ -0,0 +1,8 @@ +include_HEADERS += include/secp256k1_recovery.h +noinst_HEADERS += src/modules/recovery/main_impl.h +noinst_HEADERS += src/modules/recovery/tests_impl.h +if USE_BENCHMARK +noinst_PROGRAMS += bench_recover +bench_recover_SOURCES = src/bench_recover.c +bench_recover_LDADD = libsecp256k1.la $(SECP_LIBS) +endif diff --git a/src/secp256k1/src/modules/recovery/main_impl.h b/src/secp256k1/src/modules/recovery/main_impl.h new file mode 100644 index 0000000..ec42f4b --- /dev/null +++ b/src/secp256k1/src/modules/recovery/main_impl.h @@ -0,0 +1,193 @@ +/********************************************************************** + * Copyright (c) 2013-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_MODULE_RECOVERY_MAIN_ +#define _SECP256K1_MODULE_RECOVERY_MAIN_ + +#include "include/secp256k1_recovery.h" + +static void secp256k1_ecdsa_recoverable_signature_load(const secp256k1_context* ctx, secp256k1_scalar* r, secp256k1_scalar* s, int* recid, const secp256k1_ecdsa_recoverable_signature* sig) { + (void)ctx; + if (sizeof(secp256k1_scalar) == 32) { + /* When the secp256k1_scalar type is exactly 32 byte, use its + * representation inside secp256k1_ecdsa_signature, as conversion is very fast. + * Note that secp256k1_ecdsa_signature_save must use the same representation. */ + memcpy(r, &sig->data[0], 32); + memcpy(s, &sig->data[32], 32); + } else { + secp256k1_scalar_set_b32(r, &sig->data[0], NULL); + secp256k1_scalar_set_b32(s, &sig->data[32], NULL); + } + *recid = sig->data[64]; +} + +static void secp256k1_ecdsa_recoverable_signature_save(secp256k1_ecdsa_recoverable_signature* sig, const secp256k1_scalar* r, const secp256k1_scalar* s, int recid) { + if (sizeof(secp256k1_scalar) == 32) { + memcpy(&sig->data[0], r, 32); + memcpy(&sig->data[32], s, 32); + } else { + secp256k1_scalar_get_b32(&sig->data[0], r); + secp256k1_scalar_get_b32(&sig->data[32], s); + } + sig->data[64] = recid; +} + +int secp256k1_ecdsa_recoverable_signature_parse_compact(const secp256k1_context* ctx, secp256k1_ecdsa_recoverable_signature* sig, const unsigned char *input64, int recid) { + secp256k1_scalar r, s; + int ret = 1; + int overflow = 0; + + (void)ctx; + ARG_CHECK(sig != NULL); + ARG_CHECK(input64 != NULL); + ARG_CHECK(recid >= 0 && recid <= 3); + + secp256k1_scalar_set_b32(&r, &input64[0], &overflow); + ret &= !overflow; + secp256k1_scalar_set_b32(&s, &input64[32], &overflow); + ret &= !overflow; + if (ret) { + secp256k1_ecdsa_recoverable_signature_save(sig, &r, &s, recid); + } else { + memset(sig, 0, sizeof(*sig)); + } + return ret; +} + +int secp256k1_ecdsa_recoverable_signature_serialize_compact(const secp256k1_context* ctx, unsigned char *output64, int *recid, const secp256k1_ecdsa_recoverable_signature* sig) { + secp256k1_scalar r, s; + + (void)ctx; + ARG_CHECK(output64 != NULL); + ARG_CHECK(sig != NULL); + ARG_CHECK(recid != NULL); + + secp256k1_ecdsa_recoverable_signature_load(ctx, &r, &s, recid, sig); + secp256k1_scalar_get_b32(&output64[0], &r); + secp256k1_scalar_get_b32(&output64[32], &s); + return 1; +} + +int secp256k1_ecdsa_recoverable_signature_convert(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const secp256k1_ecdsa_recoverable_signature* sigin) { + secp256k1_scalar r, s; + int recid; + + (void)ctx; + ARG_CHECK(sig != NULL); + ARG_CHECK(sigin != NULL); + + secp256k1_ecdsa_recoverable_signature_load(ctx, &r, &s, &recid, sigin); + secp256k1_ecdsa_signature_save(sig, &r, &s); + return 1; +} + +static int secp256k1_ecdsa_sig_recover(const secp256k1_ecmult_context *ctx, const secp256k1_scalar *sigr, const secp256k1_scalar* sigs, secp256k1_ge *pubkey, const secp256k1_scalar *message, int recid) { + unsigned char brx[32]; + secp256k1_fe fx; + secp256k1_ge x; + secp256k1_gej xj; + secp256k1_scalar rn, u1, u2; + secp256k1_gej qj; + int r; + + if (secp256k1_scalar_is_zero(sigr) || secp256k1_scalar_is_zero(sigs)) { + return 0; + } + + secp256k1_scalar_get_b32(brx, sigr); + r = secp256k1_fe_set_b32(&fx, brx); + (void)r; + VERIFY_CHECK(r); /* brx comes from a scalar, so is less than the order; certainly less than p */ + if (recid & 2) { + if (secp256k1_fe_cmp_var(&fx, &secp256k1_ecdsa_const_p_minus_order) >= 0) { + return 0; + } + secp256k1_fe_add(&fx, &secp256k1_ecdsa_const_order_as_fe); + } + if (!secp256k1_ge_set_xo_var(&x, &fx, recid & 1)) { + return 0; + } + secp256k1_gej_set_ge(&xj, &x); + secp256k1_scalar_inverse_var(&rn, sigr); + secp256k1_scalar_mul(&u1, &rn, message); + secp256k1_scalar_negate(&u1, &u1); + secp256k1_scalar_mul(&u2, &rn, sigs); + secp256k1_ecmult(ctx, &qj, &xj, &u2, &u1); + secp256k1_ge_set_gej_var(pubkey, &qj); + return !secp256k1_gej_is_infinity(&qj); +} + +int secp256k1_ecdsa_sign_recoverable(const secp256k1_context* ctx, secp256k1_ecdsa_recoverable_signature *signature, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void* noncedata) { + secp256k1_scalar r, s; + secp256k1_scalar sec, non, msg; + int recid; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(signature != NULL); + ARG_CHECK(seckey != NULL); + if (noncefp == NULL) { + noncefp = secp256k1_nonce_function_default; + } + + secp256k1_scalar_set_b32(&sec, seckey, &overflow); + /* Fail if the secret key is invalid. */ + if (!overflow && !secp256k1_scalar_is_zero(&sec)) { + unsigned int count = 0; + secp256k1_scalar_set_b32(&msg, msg32, NULL); + while (1) { + unsigned char nonce32[32]; + ret = noncefp(nonce32, msg32, seckey, NULL, (void*)noncedata, count); + if (!ret) { + break; + } + secp256k1_scalar_set_b32(&non, nonce32, &overflow); + memset(nonce32, 0, 32); + if (!secp256k1_scalar_is_zero(&non) && !overflow) { + if (secp256k1_ecdsa_sig_sign(&ctx->ecmult_gen_ctx, &r, &s, &sec, &msg, &non, &recid)) { + break; + } + } + count++; + } + secp256k1_scalar_clear(&msg); + secp256k1_scalar_clear(&non); + secp256k1_scalar_clear(&sec); + } + if (ret) { + secp256k1_ecdsa_recoverable_signature_save(signature, &r, &s, recid); + } else { + memset(signature, 0, sizeof(*signature)); + } + return ret; +} + +int secp256k1_ecdsa_recover(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const secp256k1_ecdsa_recoverable_signature *signature, const unsigned char *msg32) { + secp256k1_ge q; + secp256k1_scalar r, s; + secp256k1_scalar m; + int recid; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(signature != NULL); + ARG_CHECK(pubkey != NULL); + + secp256k1_ecdsa_recoverable_signature_load(ctx, &r, &s, &recid, signature); + ARG_CHECK(recid >= 0 && recid < 4); + secp256k1_scalar_set_b32(&m, msg32, NULL); + if (secp256k1_ecdsa_sig_recover(&ctx->ecmult_ctx, &r, &s, &q, &m, recid)) { + secp256k1_pubkey_save(pubkey, &q); + return 1; + } else { + memset(pubkey, 0, sizeof(*pubkey)); + return 0; + } +} + +#endif diff --git a/src/secp256k1/src/modules/recovery/tests_impl.h b/src/secp256k1/src/modules/recovery/tests_impl.h new file mode 100644 index 0000000..8932d5f --- /dev/null +++ b/src/secp256k1/src/modules/recovery/tests_impl.h @@ -0,0 +1,250 @@ +/********************************************************************** + * Copyright (c) 2013-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_MODULE_RECOVERY_TESTS_ +#define _SECP256K1_MODULE_RECOVERY_TESTS_ + +void test_ecdsa_recovery_end_to_end(void) { + unsigned char extra[32] = {0x00}; + unsigned char privkey[32]; + unsigned char message[32]; + secp256k1_ecdsa_signature signature[5]; + secp256k1_ecdsa_recoverable_signature rsignature[5]; + unsigned char sig[74]; + secp256k1_pubkey pubkey; + secp256k1_pubkey recpubkey; + int recid = 0; + + /* Generate a random key and message. */ + { + secp256k1_scalar msg, key; + random_scalar_order_test(&msg); + random_scalar_order_test(&key); + secp256k1_scalar_get_b32(privkey, &key); + secp256k1_scalar_get_b32(message, &msg); + } + + /* Construct and verify corresponding public key. */ + CHECK(secp256k1_ec_seckey_verify(ctx, privkey) == 1); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, privkey) == 1); + + /* Serialize/parse compact and verify/recover. */ + extra[0] = 0; + CHECK(secp256k1_ecdsa_sign_recoverable(ctx, &rsignature[0], message, privkey, NULL, NULL) == 1); + CHECK(secp256k1_ecdsa_sign(ctx, &signature[0], message, privkey, NULL, NULL) == 1); + CHECK(secp256k1_ecdsa_sign_recoverable(ctx, &rsignature[4], message, privkey, NULL, NULL) == 1); + CHECK(secp256k1_ecdsa_sign_recoverable(ctx, &rsignature[1], message, privkey, NULL, extra) == 1); + extra[31] = 1; + CHECK(secp256k1_ecdsa_sign_recoverable(ctx, &rsignature[2], message, privkey, NULL, extra) == 1); + extra[31] = 0; + extra[0] = 1; + CHECK(secp256k1_ecdsa_sign_recoverable(ctx, &rsignature[3], message, privkey, NULL, extra) == 1); + CHECK(secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx, sig, &recid, &rsignature[4]) == 1); + CHECK(secp256k1_ecdsa_recoverable_signature_convert(ctx, &signature[4], &rsignature[4]) == 1); + CHECK(memcmp(&signature[4], &signature[0], 64) == 0); + CHECK(secp256k1_ecdsa_verify(ctx, &signature[4], message, &pubkey) == 1); + memset(&rsignature[4], 0, sizeof(rsignature[4])); + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsignature[4], sig, recid) == 1); + CHECK(secp256k1_ecdsa_recoverable_signature_convert(ctx, &signature[4], &rsignature[4]) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &signature[4], message, &pubkey) == 1); + /* Parse compact (with recovery id) and recover. */ + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsignature[4], sig, recid) == 1); + CHECK(secp256k1_ecdsa_recover(ctx, &recpubkey, &rsignature[4], message) == 1); + CHECK(memcmp(&pubkey, &recpubkey, sizeof(pubkey)) == 0); + /* Serialize/destroy/parse signature and verify again. */ + CHECK(secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx, sig, &recid, &rsignature[4]) == 1); + sig[secp256k1_rand_bits(6)] += 1 + secp256k1_rand_int(255); + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsignature[4], sig, recid) == 1); + CHECK(secp256k1_ecdsa_recoverable_signature_convert(ctx, &signature[4], &rsignature[4]) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &signature[4], message, &pubkey) == 0); + /* Recover again */ + CHECK(secp256k1_ecdsa_recover(ctx, &recpubkey, &rsignature[4], message) == 0 || + memcmp(&pubkey, &recpubkey, sizeof(pubkey)) != 0); +} + +/* Tests several edge cases. */ +void test_ecdsa_recovery_edge_cases(void) { + const unsigned char msg32[32] = { + 'T', 'h', 'i', 's', ' ', 'i', 's', ' ', + 'a', ' ', 'v', 'e', 'r', 'y', ' ', 's', + 'e', 'c', 'r', 'e', 't', ' ', 'm', 'e', + 's', 's', 'a', 'g', 'e', '.', '.', '.' + }; + const unsigned char sig64[64] = { + /* Generated by signing the above message with nonce 'This is the nonce we will use...' + * and secret key 0 (which is not valid), resulting in recid 0. */ + 0x67, 0xCB, 0x28, 0x5F, 0x9C, 0xD1, 0x94, 0xE8, + 0x40, 0xD6, 0x29, 0x39, 0x7A, 0xF5, 0x56, 0x96, + 0x62, 0xFD, 0xE4, 0x46, 0x49, 0x99, 0x59, 0x63, + 0x17, 0x9A, 0x7D, 0xD1, 0x7B, 0xD2, 0x35, 0x32, + 0x4B, 0x1B, 0x7D, 0xF3, 0x4C, 0xE1, 0xF6, 0x8E, + 0x69, 0x4F, 0xF6, 0xF1, 0x1A, 0xC7, 0x51, 0xDD, + 0x7D, 0xD7, 0x3E, 0x38, 0x7E, 0xE4, 0xFC, 0x86, + 0x6E, 0x1B, 0xE8, 0xEC, 0xC7, 0xDD, 0x95, 0x57 + }; + secp256k1_pubkey pubkey; + /* signature (r,s) = (4,4), which can be recovered with all 4 recids. */ + const unsigned char sigb64[64] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, + }; + secp256k1_pubkey pubkeyb; + secp256k1_ecdsa_recoverable_signature rsig; + secp256k1_ecdsa_signature sig; + int recid; + + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsig, sig64, 0)); + CHECK(!secp256k1_ecdsa_recover(ctx, &pubkey, &rsig, msg32)); + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsig, sig64, 1)); + CHECK(secp256k1_ecdsa_recover(ctx, &pubkey, &rsig, msg32)); + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsig, sig64, 2)); + CHECK(!secp256k1_ecdsa_recover(ctx, &pubkey, &rsig, msg32)); + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsig, sig64, 3)); + CHECK(!secp256k1_ecdsa_recover(ctx, &pubkey, &rsig, msg32)); + + for (recid = 0; recid < 4; recid++) { + int i; + int recid2; + /* (4,4) encoded in DER. */ + unsigned char sigbder[8] = {0x30, 0x06, 0x02, 0x01, 0x04, 0x02, 0x01, 0x04}; + unsigned char sigcder_zr[7] = {0x30, 0x05, 0x02, 0x00, 0x02, 0x01, 0x01}; + unsigned char sigcder_zs[7] = {0x30, 0x05, 0x02, 0x01, 0x01, 0x02, 0x00}; + unsigned char sigbderalt1[39] = { + 0x30, 0x25, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x04, + }; + unsigned char sigbderalt2[39] = { + 0x30, 0x25, 0x02, 0x01, 0x04, 0x02, 0x20, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, + }; + unsigned char sigbderalt3[40] = { + 0x30, 0x26, 0x02, 0x21, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x04, + }; + unsigned char sigbderalt4[40] = { + 0x30, 0x26, 0x02, 0x01, 0x04, 0x02, 0x21, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, + }; + /* (order + r,4) encoded in DER. */ + unsigned char sigbderlong[40] = { + 0x30, 0x26, 0x02, 0x21, 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xBA, 0xAE, 0xDC, + 0xE6, 0xAF, 0x48, 0xA0, 0x3B, 0xBF, 0xD2, 0x5E, + 0x8C, 0xD0, 0x36, 0x41, 0x45, 0x02, 0x01, 0x04 + }; + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsig, sigb64, recid) == 1); + CHECK(secp256k1_ecdsa_recover(ctx, &pubkeyb, &rsig, msg32) == 1); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbder, sizeof(sigbder)) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &sig, msg32, &pubkeyb) == 1); + for (recid2 = 0; recid2 < 4; recid2++) { + secp256k1_pubkey pubkey2b; + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsig, sigb64, recid2) == 1); + CHECK(secp256k1_ecdsa_recover(ctx, &pubkey2b, &rsig, msg32) == 1); + /* Verifying with (order + r,4) should always fail. */ + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbderlong, sizeof(sigbderlong)) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &sig, msg32, &pubkeyb) == 0); + } + /* DER parsing tests. */ + /* Zero length r/s. */ + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigcder_zr, sizeof(sigcder_zr)) == 0); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigcder_zs, sizeof(sigcder_zs)) == 0); + /* Leading zeros. */ + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbderalt1, sizeof(sigbderalt1)) == 0); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbderalt2, sizeof(sigbderalt2)) == 0); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbderalt3, sizeof(sigbderalt3)) == 0); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbderalt4, sizeof(sigbderalt4)) == 0); + sigbderalt3[4] = 1; + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbderalt3, sizeof(sigbderalt3)) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &sig, msg32, &pubkeyb) == 0); + sigbderalt4[7] = 1; + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbderalt4, sizeof(sigbderalt4)) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &sig, msg32, &pubkeyb) == 0); + /* Damage signature. */ + sigbder[7]++; + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbder, sizeof(sigbder)) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &sig, msg32, &pubkeyb) == 0); + sigbder[7]--; + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbder, 6) == 0); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbder, sizeof(sigbder) - 1) == 0); + for(i = 0; i < 8; i++) { + int c; + unsigned char orig = sigbder[i]; + /*Try every single-byte change.*/ + for (c = 0; c < 256; c++) { + if (c == orig ) { + continue; + } + sigbder[i] = c; + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigbder, sizeof(sigbder)) == 0 || secp256k1_ecdsa_verify(ctx, &sig, msg32, &pubkeyb) == 0); + } + sigbder[i] = orig; + } + } + + /* Test r/s equal to zero */ + { + /* (1,1) encoded in DER. */ + unsigned char sigcder[8] = {0x30, 0x06, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01}; + unsigned char sigc64[64] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }; + secp256k1_pubkey pubkeyc; + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsig, sigc64, 0) == 1); + CHECK(secp256k1_ecdsa_recover(ctx, &pubkeyc, &rsig, msg32) == 1); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigcder, sizeof(sigcder)) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &sig, msg32, &pubkeyc) == 1); + sigcder[4] = 0; + sigc64[31] = 0; + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsig, sigc64, 0) == 1); + CHECK(secp256k1_ecdsa_recover(ctx, &pubkeyb, &rsig, msg32) == 0); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigcder, sizeof(sigcder)) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &sig, msg32, &pubkeyc) == 0); + sigcder[4] = 1; + sigcder[7] = 0; + sigc64[31] = 1; + sigc64[63] = 0; + CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &rsig, sigc64, 0) == 1); + CHECK(secp256k1_ecdsa_recover(ctx, &pubkeyb, &rsig, msg32) == 0); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, sigcder, sizeof(sigcder)) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &sig, msg32, &pubkeyc) == 0); + } +} + +void run_recovery_tests(void) { + int i; + for (i = 0; i < 64*count; i++) { + test_ecdsa_recovery_end_to_end(); + } + test_ecdsa_recovery_edge_cases(); +} + +#endif diff --git a/src/secp256k1/src/modules/schnorr/Makefile.am.include b/src/secp256k1/src/modules/schnorr/Makefile.am.include new file mode 100644 index 0000000..b3bfa7d --- /dev/null +++ b/src/secp256k1/src/modules/schnorr/Makefile.am.include @@ -0,0 +1,10 @@ +include_HEADERS += include/secp256k1_schnorr.h +noinst_HEADERS += src/modules/schnorr/main_impl.h +noinst_HEADERS += src/modules/schnorr/schnorr.h +noinst_HEADERS += src/modules/schnorr/schnorr_impl.h +noinst_HEADERS += src/modules/schnorr/tests_impl.h +if USE_BENCHMARK +noinst_PROGRAMS += bench_schnorr_verify +bench_schnorr_verify_SOURCES = src/bench_schnorr_verify.c +bench_schnorr_verify_LDADD = libsecp256k1.la $(SECP_LIBS) +endif diff --git a/src/secp256k1/src/modules/schnorr/main_impl.h b/src/secp256k1/src/modules/schnorr/main_impl.h new file mode 100644 index 0000000..fa176a1 --- /dev/null +++ b/src/secp256k1/src/modules/schnorr/main_impl.h @@ -0,0 +1,164 @@ +/********************************************************************** + * Copyright (c) 2014-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_MODULE_SCHNORR_MAIN +#define SECP256K1_MODULE_SCHNORR_MAIN + +#include "include/secp256k1_schnorr.h" +#include "modules/schnorr/schnorr_impl.h" + +static void secp256k1_schnorr_msghash_sha256(unsigned char *h32, const unsigned char *r32, const unsigned char *msg32) { + secp256k1_sha256_t sha; + secp256k1_sha256_initialize(&sha); + secp256k1_sha256_write(&sha, r32, 32); + secp256k1_sha256_write(&sha, msg32, 32); + secp256k1_sha256_finalize(&sha, h32); +} + +static const unsigned char secp256k1_schnorr_algo16[17] = "Schnorr+SHA256 "; + +int secp256k1_schnorr_sign(const secp256k1_context* ctx, unsigned char *sig64, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void* noncedata) { + secp256k1_scalar sec, non; + int ret = 0; + int overflow = 0; + unsigned int count = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(sig64 != NULL); + ARG_CHECK(seckey != NULL); + if (noncefp == NULL) { + noncefp = secp256k1_nonce_function_default; + } + + secp256k1_scalar_set_b32(&sec, seckey, NULL); + while (1) { + unsigned char nonce32[32]; + ret = noncefp(nonce32, msg32, seckey, secp256k1_schnorr_algo16, (void*)noncedata, count); + if (!ret) { + break; + } + secp256k1_scalar_set_b32(&non, nonce32, &overflow); + memset(nonce32, 0, 32); + if (!secp256k1_scalar_is_zero(&non) && !overflow) { + if (secp256k1_schnorr_sig_sign(&ctx->ecmult_gen_ctx, sig64, &sec, &non, NULL, secp256k1_schnorr_msghash_sha256, msg32)) { + break; + } + } + count++; + } + if (!ret) { + memset(sig64, 0, 64); + } + secp256k1_scalar_clear(&non); + secp256k1_scalar_clear(&sec); + return ret; +} + +int secp256k1_schnorr_verify(const secp256k1_context* ctx, const unsigned char *sig64, const unsigned char *msg32, const secp256k1_pubkey *pubkey) { + secp256k1_ge q; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(sig64 != NULL); + ARG_CHECK(pubkey != NULL); + + secp256k1_pubkey_load(ctx, &q, pubkey); + return secp256k1_schnorr_sig_verify(&ctx->ecmult_ctx, sig64, &q, secp256k1_schnorr_msghash_sha256, msg32); +} + +int secp256k1_schnorr_recover(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *sig64, const unsigned char *msg32) { + secp256k1_ge q; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(sig64 != NULL); + ARG_CHECK(pubkey != NULL); + + if (secp256k1_schnorr_sig_recover(&ctx->ecmult_ctx, sig64, &q, secp256k1_schnorr_msghash_sha256, msg32)) { + secp256k1_pubkey_save(pubkey, &q); + return 1; + } else { + memset(pubkey, 0, sizeof(*pubkey)); + return 0; + } +} + +int secp256k1_schnorr_generate_nonce_pair(const secp256k1_context* ctx, secp256k1_pubkey *pubnonce, unsigned char *privnonce32, const unsigned char *sec32, const unsigned char *msg32, secp256k1_nonce_function noncefp, const void* noncedata) { + int count = 0; + int ret = 1; + secp256k1_gej Qj; + secp256k1_ge Q; + secp256k1_scalar sec; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(sec32 != NULL); + ARG_CHECK(pubnonce != NULL); + ARG_CHECK(privnonce32 != NULL); + + if (noncefp == NULL) { + noncefp = secp256k1_nonce_function_default; + } + + do { + int overflow; + ret = noncefp(privnonce32, sec32, msg32, secp256k1_schnorr_algo16, (void*)noncedata, count++); + if (!ret) { + break; + } + secp256k1_scalar_set_b32(&sec, privnonce32, &overflow); + if (overflow || secp256k1_scalar_is_zero(&sec)) { + continue; + } + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &Qj, &sec); + secp256k1_ge_set_gej(&Q, &Qj); + + secp256k1_pubkey_save(pubnonce, &Q); + break; + } while(1); + + secp256k1_scalar_clear(&sec); + if (!ret) { + memset(pubnonce, 0, sizeof(*pubnonce)); + } + return ret; +} + +int secp256k1_schnorr_partial_sign(const secp256k1_context* ctx, unsigned char *sig64, const unsigned char *msg32, const unsigned char *sec32, const secp256k1_pubkey *pubnonce_others, const unsigned char *secnonce32) { + int overflow = 0; + secp256k1_scalar sec, non; + secp256k1_ge pubnon; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(sig64 != NULL); + ARG_CHECK(sec32 != NULL); + ARG_CHECK(secnonce32 != NULL); + ARG_CHECK(pubnonce_others != NULL); + + secp256k1_scalar_set_b32(&sec, sec32, &overflow); + if (overflow || secp256k1_scalar_is_zero(&sec)) { + return -1; + } + secp256k1_scalar_set_b32(&non, secnonce32, &overflow); + if (overflow || secp256k1_scalar_is_zero(&non)) { + return -1; + } + secp256k1_pubkey_load(ctx, &pubnon, pubnonce_others); + return secp256k1_schnorr_sig_sign(&ctx->ecmult_gen_ctx, sig64, &sec, &non, &pubnon, secp256k1_schnorr_msghash_sha256, msg32); +} + +int secp256k1_schnorr_partial_combine(const secp256k1_context* ctx, unsigned char *sig64, const unsigned char * const *sig64sin, size_t n) { + ARG_CHECK(sig64 != NULL); + ARG_CHECK(n >= 1); + ARG_CHECK(sig64sin != NULL); + return secp256k1_schnorr_sig_combine(sig64, n, sig64sin); +} + +#endif diff --git a/src/secp256k1/src/modules/schnorr/schnorr.h b/src/secp256k1/src/modules/schnorr/schnorr.h new file mode 100644 index 0000000..de18147 --- /dev/null +++ b/src/secp256k1/src/modules/schnorr/schnorr.h @@ -0,0 +1,20 @@ +/*********************************************************************** + * Copyright (c) 2014-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php. * + ***********************************************************************/ + +#ifndef _SECP256K1_MODULE_SCHNORR_H_ +#define _SECP256K1_MODULE_SCHNORR_H_ + +#include "scalar.h" +#include "group.h" + +typedef void (*secp256k1_schnorr_msghash)(unsigned char *h32, const unsigned char *r32, const unsigned char *msg32); + +static int secp256k1_schnorr_sig_sign(const secp256k1_ecmult_gen_context* ctx, unsigned char *sig64, const secp256k1_scalar *key, const secp256k1_scalar *nonce, const secp256k1_ge *pubnonce, secp256k1_schnorr_msghash hash, const unsigned char *msg32); +static int secp256k1_schnorr_sig_verify(const secp256k1_ecmult_context* ctx, const unsigned char *sig64, const secp256k1_ge *pubkey, secp256k1_schnorr_msghash hash, const unsigned char *msg32); +static int secp256k1_schnorr_sig_recover(const secp256k1_ecmult_context* ctx, const unsigned char *sig64, secp256k1_ge *pubkey, secp256k1_schnorr_msghash hash, const unsigned char *msg32); +static int secp256k1_schnorr_sig_combine(unsigned char *sig64, size_t n, const unsigned char * const *sig64ins); + +#endif diff --git a/src/secp256k1/src/modules/schnorr/schnorr_impl.h b/src/secp256k1/src/modules/schnorr/schnorr_impl.h new file mode 100644 index 0000000..e13ab6d --- /dev/null +++ b/src/secp256k1/src/modules/schnorr/schnorr_impl.h @@ -0,0 +1,207 @@ +/*********************************************************************** + * Copyright (c) 2014-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php. * + ***********************************************************************/ + +#ifndef _SECP256K1_SCHNORR_IMPL_H_ +#define _SECP256K1_SCHNORR_IMPL_H_ + +#include + +#include "schnorr.h" +#include "num.h" +#include "field.h" +#include "group.h" +#include "ecmult.h" +#include "ecmult_gen.h" + +/** + * Custom Schnorr-based signature scheme. They support multiparty signing, public key + * recovery and batch validation. + * + * Rationale for verifying R's y coordinate: + * In order to support batch validation and public key recovery, the full R point must + * be known to verifiers, rather than just its x coordinate. In order to not risk + * being more strict in batch validation than normal validation, validators must be + * required to reject signatures with incorrect y coordinate. This is only possible + * by including a (relatively slow) field inverse, or a field square root. However, + * batch validation offers potentially much higher benefits than this cost. + * + * Rationale for having an implicit y coordinate oddness: + * If we commit to having the full R point known to verifiers, there are two mechanism. + * Either include its oddness in the signature, or give it an implicit fixed value. + * As the R y coordinate can be flipped by a simple negation of the nonce, we choose the + * latter, as it comes with nearly zero impact on signing or validation performance, and + * saves a byte in the signature. + * + * Signing: + * Inputs: 32-byte message m, 32-byte scalar key x (!=0), 32-byte scalar nonce k (!=0) + * + * Compute point R = k * G. Reject nonce if R's y coordinate is odd (or negate nonce). + * Compute 32-byte r, the serialization of R's x coordinate. + * Compute scalar h = Hash(r || m). Reject nonce if h == 0 or h >= order. + * Compute scalar s = k - h * x. + * The signature is (r, s). + * + * + * Verification: + * Inputs: 32-byte message m, public key point Q, signature: (32-byte r, scalar s) + * + * Signature is invalid if s >= order. + * Signature is invalid if r >= p. + * Compute scalar h = Hash(r || m). Signature is invalid if h == 0 or h >= order. + * Option 1 (faster for single verification): + * Compute point R = h * Q + s * G. Signature is invalid if R is infinity or R's y coordinate is odd. + * Signature is valid if the serialization of R's x coordinate equals r. + * Option 2 (allows batch validation and pubkey recovery): + * Decompress x coordinate r into point R, with odd y coordinate. Fail if R is not on the curve. + * Signature is valid if R + h * Q + s * G == 0. + */ + +static int secp256k1_schnorr_sig_sign(const secp256k1_ecmult_gen_context* ctx, unsigned char *sig64, const secp256k1_scalar *key, const secp256k1_scalar *nonce, const secp256k1_ge *pubnonce, secp256k1_schnorr_msghash hash, const unsigned char *msg32) { + secp256k1_gej Rj; + secp256k1_ge Ra; + unsigned char h32[32]; + secp256k1_scalar h, s; + int overflow; + secp256k1_scalar n; + + if (secp256k1_scalar_is_zero(key) || secp256k1_scalar_is_zero(nonce)) { + return 0; + } + n = *nonce; + + secp256k1_ecmult_gen(ctx, &Rj, &n); + if (pubnonce != NULL) { + secp256k1_gej_add_ge(&Rj, &Rj, pubnonce); + } + secp256k1_ge_set_gej(&Ra, &Rj); + secp256k1_fe_normalize(&Ra.y); + if (secp256k1_fe_is_odd(&Ra.y)) { + /* R's y coordinate is odd, which is not allowed (see rationale above). + Force it to be even by negating the nonce. Note that this even works + for multiparty signing, as the R point is known to all participants, + which can all decide to flip the sign in unison, resulting in the + overall R point to be negated too. */ + secp256k1_scalar_negate(&n, &n); + } + secp256k1_fe_normalize(&Ra.x); + secp256k1_fe_get_b32(sig64, &Ra.x); + hash(h32, sig64, msg32); + overflow = 0; + secp256k1_scalar_set_b32(&h, h32, &overflow); + if (overflow || secp256k1_scalar_is_zero(&h)) { + secp256k1_scalar_clear(&n); + return 0; + } + secp256k1_scalar_mul(&s, &h, key); + secp256k1_scalar_negate(&s, &s); + secp256k1_scalar_add(&s, &s, &n); + secp256k1_scalar_clear(&n); + secp256k1_scalar_get_b32(sig64 + 32, &s); + return 1; +} + +static int secp256k1_schnorr_sig_verify(const secp256k1_ecmult_context* ctx, const unsigned char *sig64, const secp256k1_ge *pubkey, secp256k1_schnorr_msghash hash, const unsigned char *msg32) { + secp256k1_gej Qj, Rj; + secp256k1_ge Ra; + secp256k1_fe Rx; + secp256k1_scalar h, s; + unsigned char hh[32]; + int overflow; + + if (secp256k1_ge_is_infinity(pubkey)) { + return 0; + } + hash(hh, sig64, msg32); + overflow = 0; + secp256k1_scalar_set_b32(&h, hh, &overflow); + if (overflow || secp256k1_scalar_is_zero(&h)) { + return 0; + } + overflow = 0; + secp256k1_scalar_set_b32(&s, sig64 + 32, &overflow); + if (overflow) { + return 0; + } + if (!secp256k1_fe_set_b32(&Rx, sig64)) { + return 0; + } + secp256k1_gej_set_ge(&Qj, pubkey); + secp256k1_ecmult(ctx, &Rj, &Qj, &h, &s); + if (secp256k1_gej_is_infinity(&Rj)) { + return 0; + } + secp256k1_ge_set_gej_var(&Ra, &Rj); + secp256k1_fe_normalize_var(&Ra.y); + if (secp256k1_fe_is_odd(&Ra.y)) { + return 0; + } + return secp256k1_fe_equal_var(&Rx, &Ra.x); +} + +static int secp256k1_schnorr_sig_recover(const secp256k1_ecmult_context* ctx, const unsigned char *sig64, secp256k1_ge *pubkey, secp256k1_schnorr_msghash hash, const unsigned char *msg32) { + secp256k1_gej Qj, Rj; + secp256k1_ge Ra; + secp256k1_fe Rx; + secp256k1_scalar h, s; + unsigned char hh[32]; + int overflow; + + hash(hh, sig64, msg32); + overflow = 0; + secp256k1_scalar_set_b32(&h, hh, &overflow); + if (overflow || secp256k1_scalar_is_zero(&h)) { + return 0; + } + overflow = 0; + secp256k1_scalar_set_b32(&s, sig64 + 32, &overflow); + if (overflow) { + return 0; + } + if (!secp256k1_fe_set_b32(&Rx, sig64)) { + return 0; + } + if (!secp256k1_ge_set_xo_var(&Ra, &Rx, 0)) { + return 0; + } + secp256k1_gej_set_ge(&Rj, &Ra); + secp256k1_scalar_inverse_var(&h, &h); + secp256k1_scalar_negate(&s, &s); + secp256k1_scalar_mul(&s, &s, &h); + secp256k1_ecmult(ctx, &Qj, &Rj, &h, &s); + if (secp256k1_gej_is_infinity(&Qj)) { + return 0; + } + secp256k1_ge_set_gej(pubkey, &Qj); + return 1; +} + +static int secp256k1_schnorr_sig_combine(unsigned char *sig64, size_t n, const unsigned char * const *sig64ins) { + secp256k1_scalar s = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 0); + size_t i; + for (i = 0; i < n; i++) { + secp256k1_scalar si; + int overflow; + secp256k1_scalar_set_b32(&si, sig64ins[i] + 32, &overflow); + if (overflow) { + return -1; + } + if (i) { + if (memcmp(sig64ins[i - 1], sig64ins[i], 32) != 0) { + return -1; + } + } + secp256k1_scalar_add(&s, &s, &si); + } + if (secp256k1_scalar_is_zero(&s)) { + return 0; + } + memcpy(sig64, sig64ins[0], 32); + secp256k1_scalar_get_b32(sig64 + 32, &s); + secp256k1_scalar_clear(&s); + return 1; +} + +#endif diff --git a/src/secp256k1/src/modules/schnorr/tests_impl.h b/src/secp256k1/src/modules/schnorr/tests_impl.h new file mode 100644 index 0000000..5bd14a0 --- /dev/null +++ b/src/secp256k1/src/modules/schnorr/tests_impl.h @@ -0,0 +1,175 @@ +/********************************************************************** + * Copyright (c) 2014-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef SECP256K1_MODULE_SCHNORR_TESTS +#define SECP256K1_MODULE_SCHNORR_TESTS + +#include "include/secp256k1_schnorr.h" + +void test_schnorr_end_to_end(void) { + unsigned char privkey[32]; + unsigned char message[32]; + unsigned char schnorr_signature[64]; + secp256k1_pubkey pubkey, recpubkey; + + /* Generate a random key and message. */ + { + secp256k1_scalar key; + random_scalar_order_test(&key); + secp256k1_scalar_get_b32(privkey, &key); + secp256k1_rand256_test(message); + } + + /* Construct and verify corresponding public key. */ + CHECK(secp256k1_ec_seckey_verify(ctx, privkey) == 1); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, privkey) == 1); + + /* Schnorr sign. */ + CHECK(secp256k1_schnorr_sign(ctx, schnorr_signature, message, privkey, NULL, NULL) == 1); + CHECK(secp256k1_schnorr_verify(ctx, schnorr_signature, message, &pubkey) == 1); + CHECK(secp256k1_schnorr_recover(ctx, &recpubkey, schnorr_signature, message) == 1); + CHECK(memcmp(&pubkey, &recpubkey, sizeof(pubkey)) == 0); + /* Destroy signature and verify again. */ + schnorr_signature[secp256k1_rand_bits(6)] += 1 + secp256k1_rand_int(255); + CHECK(secp256k1_schnorr_verify(ctx, schnorr_signature, message, &pubkey) == 0); + CHECK(secp256k1_schnorr_recover(ctx, &recpubkey, schnorr_signature, message) != 1 || + memcmp(&pubkey, &recpubkey, sizeof(pubkey)) != 0); +} + +/** Horribly broken hash function. Do not use for anything but tests. */ +void test_schnorr_hash(unsigned char *h32, const unsigned char *r32, const unsigned char *msg32) { + int i; + for (i = 0; i < 32; i++) { + h32[i] = r32[i] ^ msg32[i]; + } +} + +void test_schnorr_sign_verify(void) { + unsigned char msg32[32]; + unsigned char sig64[3][64]; + secp256k1_gej pubkeyj[3]; + secp256k1_ge pubkey[3]; + secp256k1_scalar nonce[3], key[3]; + int i = 0; + int k; + + secp256k1_rand256_test(msg32); + + for (k = 0; k < 3; k++) { + random_scalar_order_test(&key[k]); + + do { + random_scalar_order_test(&nonce[k]); + if (secp256k1_schnorr_sig_sign(&ctx->ecmult_gen_ctx, sig64[k], &key[k], &nonce[k], NULL, &test_schnorr_hash, msg32)) { + break; + } + } while(1); + + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &pubkeyj[k], &key[k]); + secp256k1_ge_set_gej_var(&pubkey[k], &pubkeyj[k]); + CHECK(secp256k1_schnorr_sig_verify(&ctx->ecmult_ctx, sig64[k], &pubkey[k], &test_schnorr_hash, msg32)); + + for (i = 0; i < 4; i++) { + int pos = secp256k1_rand_bits(6); + int mod = 1 + secp256k1_rand_int(255); + sig64[k][pos] ^= mod; + CHECK(secp256k1_schnorr_sig_verify(&ctx->ecmult_ctx, sig64[k], &pubkey[k], &test_schnorr_hash, msg32) == 0); + sig64[k][pos] ^= mod; + } + } +} + +void test_schnorr_threshold(void) { + unsigned char msg[32]; + unsigned char sec[5][32]; + secp256k1_pubkey pub[5]; + unsigned char nonce[5][32]; + secp256k1_pubkey pubnonce[5]; + unsigned char sig[5][64]; + const unsigned char* sigs[5]; + unsigned char allsig[64]; + const secp256k1_pubkey* pubs[5]; + secp256k1_pubkey allpub; + int n, i; + int damage; + int ret = 0; + + damage = secp256k1_rand_bits(1) ? (1 + secp256k1_rand_int(4)) : 0; + secp256k1_rand256_test(msg); + n = 2 + secp256k1_rand_int(4); + for (i = 0; i < n; i++) { + do { + secp256k1_rand256_test(sec[i]); + } while (!secp256k1_ec_seckey_verify(ctx, sec[i])); + CHECK(secp256k1_ec_pubkey_create(ctx, &pub[i], sec[i])); + CHECK(secp256k1_schnorr_generate_nonce_pair(ctx, &pubnonce[i], nonce[i], msg, sec[i], NULL, NULL)); + pubs[i] = &pub[i]; + } + if (damage == 1) { + nonce[secp256k1_rand_int(n)][secp256k1_rand_int(32)] ^= 1 + secp256k1_rand_int(255); + } else if (damage == 2) { + sec[secp256k1_rand_int(n)][secp256k1_rand_int(32)] ^= 1 + secp256k1_rand_int(255); + } + for (i = 0; i < n; i++) { + secp256k1_pubkey allpubnonce; + const secp256k1_pubkey *pubnonces[4]; + int j; + for (j = 0; j < i; j++) { + pubnonces[j] = &pubnonce[j]; + } + for (j = i + 1; j < n; j++) { + pubnonces[j - 1] = &pubnonce[j]; + } + CHECK(secp256k1_ec_pubkey_combine(ctx, &allpubnonce, pubnonces, n - 1)); + ret |= (secp256k1_schnorr_partial_sign(ctx, sig[i], msg, sec[i], &allpubnonce, nonce[i]) != 1) * 1; + sigs[i] = sig[i]; + } + if (damage == 3) { + sig[secp256k1_rand_int(n)][secp256k1_rand_bits(6)] ^= 1 + secp256k1_rand_int(255); + } + ret |= (secp256k1_ec_pubkey_combine(ctx, &allpub, pubs, n) != 1) * 2; + if ((ret & 1) == 0) { + ret |= (secp256k1_schnorr_partial_combine(ctx, allsig, sigs, n) != 1) * 4; + } + if (damage == 4) { + allsig[secp256k1_rand_int(32)] ^= 1 + secp256k1_rand_int(255); + } + if ((ret & 7) == 0) { + ret |= (secp256k1_schnorr_verify(ctx, allsig, msg, &allpub) != 1) * 8; + } + CHECK((ret == 0) == (damage == 0)); +} + +void test_schnorr_recovery(void) { + unsigned char msg32[32]; + unsigned char sig64[64]; + secp256k1_ge Q; + + secp256k1_rand256_test(msg32); + secp256k1_rand256_test(sig64); + secp256k1_rand256_test(sig64 + 32); + if (secp256k1_schnorr_sig_recover(&ctx->ecmult_ctx, sig64, &Q, &test_schnorr_hash, msg32) == 1) { + CHECK(secp256k1_schnorr_sig_verify(&ctx->ecmult_ctx, sig64, &Q, &test_schnorr_hash, msg32) == 1); + } +} + +void run_schnorr_tests(void) { + int i; + for (i = 0; i < 32*count; i++) { + test_schnorr_end_to_end(); + } + for (i = 0; i < 32 * count; i++) { + test_schnorr_sign_verify(); + } + for (i = 0; i < 16 * count; i++) { + test_schnorr_recovery(); + } + for (i = 0; i < 10 * count; i++) { + test_schnorr_threshold(); + } +} + +#endif diff --git a/src/secp256k1/src/num.h b/src/secp256k1/src/num.h new file mode 100644 index 0000000..ebfa71e --- /dev/null +++ b/src/secp256k1/src/num.h @@ -0,0 +1,68 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_NUM_ +#define _SECP256K1_NUM_ + +#ifndef USE_NUM_NONE + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(USE_NUM_GMP) +#include "num_gmp.h" +#else +#error "Please select num implementation" +#endif + +/** Copy a number. */ +static void secp256k1_num_copy(secp256k1_num *r, const secp256k1_num *a); + +/** Convert a number's absolute value to a binary big-endian string. + * There must be enough place. */ +static void secp256k1_num_get_bin(unsigned char *r, unsigned int rlen, const secp256k1_num *a); + +/** Set a number to the value of a binary big-endian string. */ +static void secp256k1_num_set_bin(secp256k1_num *r, const unsigned char *a, unsigned int alen); + +/** Compute a modular inverse. The input must be less than the modulus. */ +static void secp256k1_num_mod_inverse(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *m); + +/** Compare the absolute value of two numbers. */ +static int secp256k1_num_cmp(const secp256k1_num *a, const secp256k1_num *b); + +/** Test whether two number are equal (including sign). */ +static int secp256k1_num_eq(const secp256k1_num *a, const secp256k1_num *b); + +/** Add two (signed) numbers. */ +static void secp256k1_num_add(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b); + +/** Subtract two (signed) numbers. */ +static void secp256k1_num_sub(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b); + +/** Multiply two (signed) numbers. */ +static void secp256k1_num_mul(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b); + +/** Replace a number by its remainder modulo m. M's sign is ignored. The result is a number between 0 and m-1, + even if r was negative. */ +static void secp256k1_num_mod(secp256k1_num *r, const secp256k1_num *m); + +/** Right-shift the passed number by bits bits. */ +static void secp256k1_num_shift(secp256k1_num *r, int bits); + +/** Check whether a number is zero. */ +static int secp256k1_num_is_zero(const secp256k1_num *a); + +/** Check whether a number is strictly negative. */ +static int secp256k1_num_is_neg(const secp256k1_num *a); + +/** Change a number's sign. */ +static void secp256k1_num_negate(secp256k1_num *r); + +#endif + +#endif diff --git a/src/secp256k1/src/num_gmp.h b/src/secp256k1/src/num_gmp.h new file mode 100644 index 0000000..7dd8130 --- /dev/null +++ b/src/secp256k1/src/num_gmp.h @@ -0,0 +1,20 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_NUM_REPR_ +#define _SECP256K1_NUM_REPR_ + +#include + +#define NUM_LIMBS ((256+GMP_NUMB_BITS-1)/GMP_NUMB_BITS) + +typedef struct { + mp_limb_t data[2*NUM_LIMBS]; + int neg; + int limbs; +} secp256k1_num; + +#endif diff --git a/src/secp256k1/src/num_gmp_impl.h b/src/secp256k1/src/num_gmp_impl.h new file mode 100644 index 0000000..7b6a897 --- /dev/null +++ b/src/secp256k1/src/num_gmp_impl.h @@ -0,0 +1,262 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_NUM_REPR_IMPL_H_ +#define _SECP256K1_NUM_REPR_IMPL_H_ + +#include +#include +#include + +#include "util.h" +#include "num.h" + +#ifdef VERIFY +static void secp256k1_num_sanity(const secp256k1_num *a) { + VERIFY_CHECK(a->limbs == 1 || (a->limbs > 1 && a->data[a->limbs-1] != 0)); +} +#else +#define secp256k1_num_sanity(a) do { } while(0) +#endif + +static void secp256k1_num_copy(secp256k1_num *r, const secp256k1_num *a) { + *r = *a; +} + +static void secp256k1_num_get_bin(unsigned char *r, unsigned int rlen, const secp256k1_num *a) { + unsigned char tmp[65]; + int len = 0; + int shift = 0; + if (a->limbs>1 || a->data[0] != 0) { + len = mpn_get_str(tmp, 256, (mp_limb_t*)a->data, a->limbs); + } + while (shift < len && tmp[shift] == 0) shift++; + VERIFY_CHECK(len-shift <= (int)rlen); + memset(r, 0, rlen - len + shift); + if (len > shift) { + memcpy(r + rlen - len + shift, tmp + shift, len - shift); + } + memset(tmp, 0, sizeof(tmp)); +} + +static void secp256k1_num_set_bin(secp256k1_num *r, const unsigned char *a, unsigned int alen) { + int len; + VERIFY_CHECK(alen > 0); + VERIFY_CHECK(alen <= 64); + len = mpn_set_str(r->data, a, alen, 256); + if (len == 0) { + r->data[0] = 0; + len = 1; + } + VERIFY_CHECK(len <= NUM_LIMBS*2); + r->limbs = len; + r->neg = 0; + while (r->limbs > 1 && r->data[r->limbs-1]==0) { + r->limbs--; + } +} + +static void secp256k1_num_add_abs(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b) { + mp_limb_t c = mpn_add(r->data, a->data, a->limbs, b->data, b->limbs); + r->limbs = a->limbs; + if (c != 0) { + VERIFY_CHECK(r->limbs < 2*NUM_LIMBS); + r->data[r->limbs++] = c; + } +} + +static void secp256k1_num_sub_abs(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b) { + mp_limb_t c = mpn_sub(r->data, a->data, a->limbs, b->data, b->limbs); + (void)c; + VERIFY_CHECK(c == 0); + r->limbs = a->limbs; + while (r->limbs > 1 && r->data[r->limbs-1]==0) { + r->limbs--; + } +} + +static void secp256k1_num_mod(secp256k1_num *r, const secp256k1_num *m) { + secp256k1_num_sanity(r); + secp256k1_num_sanity(m); + + if (r->limbs >= m->limbs) { + mp_limb_t t[2*NUM_LIMBS]; + mpn_tdiv_qr(t, r->data, 0, r->data, r->limbs, m->data, m->limbs); + memset(t, 0, sizeof(t)); + r->limbs = m->limbs; + while (r->limbs > 1 && r->data[r->limbs-1]==0) { + r->limbs--; + } + } + + if (r->neg && (r->limbs > 1 || r->data[0] != 0)) { + secp256k1_num_sub_abs(r, m, r); + r->neg = 0; + } +} + +static void secp256k1_num_mod_inverse(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *m) { + int i; + mp_limb_t g[NUM_LIMBS+1]; + mp_limb_t u[NUM_LIMBS+1]; + mp_limb_t v[NUM_LIMBS+1]; + mp_size_t sn; + mp_size_t gn; + secp256k1_num_sanity(a); + secp256k1_num_sanity(m); + + /** mpn_gcdext computes: (G,S) = gcdext(U,V), where + * * G = gcd(U,V) + * * G = U*S + V*T + * * U has equal or more limbs than V, and V has no padding + * If we set U to be (a padded version of) a, and V = m: + * G = a*S + m*T + * G = a*S mod m + * Assuming G=1: + * S = 1/a mod m + */ + VERIFY_CHECK(m->limbs <= NUM_LIMBS); + VERIFY_CHECK(m->data[m->limbs-1] != 0); + for (i = 0; i < m->limbs; i++) { + u[i] = (i < a->limbs) ? a->data[i] : 0; + v[i] = m->data[i]; + } + sn = NUM_LIMBS+1; + gn = mpn_gcdext(g, r->data, &sn, u, m->limbs, v, m->limbs); + (void)gn; + VERIFY_CHECK(gn == 1); + VERIFY_CHECK(g[0] == 1); + r->neg = a->neg ^ m->neg; + if (sn < 0) { + mpn_sub(r->data, m->data, m->limbs, r->data, -sn); + r->limbs = m->limbs; + while (r->limbs > 1 && r->data[r->limbs-1]==0) { + r->limbs--; + } + } else { + r->limbs = sn; + } + memset(g, 0, sizeof(g)); + memset(u, 0, sizeof(u)); + memset(v, 0, sizeof(v)); +} + +static int secp256k1_num_is_zero(const secp256k1_num *a) { + return (a->limbs == 1 && a->data[0] == 0); +} + +static int secp256k1_num_is_neg(const secp256k1_num *a) { + return (a->limbs > 1 || a->data[0] != 0) && a->neg; +} + +static int secp256k1_num_cmp(const secp256k1_num *a, const secp256k1_num *b) { + if (a->limbs > b->limbs) { + return 1; + } + if (a->limbs < b->limbs) { + return -1; + } + return mpn_cmp(a->data, b->data, a->limbs); +} + +static int secp256k1_num_eq(const secp256k1_num *a, const secp256k1_num *b) { + if (a->limbs > b->limbs) { + return 0; + } + if (a->limbs < b->limbs) { + return 0; + } + if ((a->neg && !secp256k1_num_is_zero(a)) != (b->neg && !secp256k1_num_is_zero(b))) { + return 0; + } + return mpn_cmp(a->data, b->data, a->limbs) == 0; +} + +static void secp256k1_num_subadd(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b, int bneg) { + if (!(b->neg ^ bneg ^ a->neg)) { /* a and b have the same sign */ + r->neg = a->neg; + if (a->limbs >= b->limbs) { + secp256k1_num_add_abs(r, a, b); + } else { + secp256k1_num_add_abs(r, b, a); + } + } else { + if (secp256k1_num_cmp(a, b) > 0) { + r->neg = a->neg; + secp256k1_num_sub_abs(r, a, b); + } else { + r->neg = b->neg ^ bneg; + secp256k1_num_sub_abs(r, b, a); + } + } +} + +static void secp256k1_num_add(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b) { + secp256k1_num_sanity(a); + secp256k1_num_sanity(b); + secp256k1_num_subadd(r, a, b, 0); +} + +static void secp256k1_num_sub(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b) { + secp256k1_num_sanity(a); + secp256k1_num_sanity(b); + secp256k1_num_subadd(r, a, b, 1); +} + +static void secp256k1_num_mul(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b) { + mp_limb_t tmp[2*NUM_LIMBS+1]; + secp256k1_num_sanity(a); + secp256k1_num_sanity(b); + + VERIFY_CHECK(a->limbs + b->limbs <= 2*NUM_LIMBS+1); + if ((a->limbs==1 && a->data[0]==0) || (b->limbs==1 && b->data[0]==0)) { + r->limbs = 1; + r->neg = 0; + r->data[0] = 0; + return; + } + if (a->limbs >= b->limbs) { + mpn_mul(tmp, a->data, a->limbs, b->data, b->limbs); + } else { + mpn_mul(tmp, b->data, b->limbs, a->data, a->limbs); + } + r->limbs = a->limbs + b->limbs; + if (r->limbs > 1 && tmp[r->limbs - 1]==0) { + r->limbs--; + } + VERIFY_CHECK(r->limbs <= 2*NUM_LIMBS); + mpn_copyi(r->data, tmp, r->limbs); + r->neg = a->neg ^ b->neg; + memset(tmp, 0, sizeof(tmp)); +} + +static void secp256k1_num_shift(secp256k1_num *r, int bits) { + if (bits % GMP_NUMB_BITS) { + /* Shift within limbs. */ + mpn_rshift(r->data, r->data, r->limbs, bits % GMP_NUMB_BITS); + } + if (bits >= GMP_NUMB_BITS) { + int i; + /* Shift full limbs. */ + for (i = 0; i < r->limbs; i++) { + int index = i + (bits / GMP_NUMB_BITS); + if (index < r->limbs && index < 2*NUM_LIMBS) { + r->data[i] = r->data[index]; + } else { + r->data[i] = 0; + } + } + } + while (r->limbs>1 && r->data[r->limbs-1]==0) { + r->limbs--; + } +} + +static void secp256k1_num_negate(secp256k1_num *r) { + r->neg ^= 1; +} + +#endif diff --git a/src/secp256k1/src/num_impl.h b/src/secp256k1/src/num_impl.h new file mode 100644 index 0000000..0b0e3a0 --- /dev/null +++ b/src/secp256k1/src/num_impl.h @@ -0,0 +1,24 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_NUM_IMPL_H_ +#define _SECP256K1_NUM_IMPL_H_ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#include "num.h" + +#if defined(USE_NUM_GMP) +#include "num_gmp_impl.h" +#elif defined(USE_NUM_NONE) +/* Nothing. */ +#else +#error "Please select num implementation" +#endif + +#endif diff --git a/src/secp256k1/src/scalar.h b/src/secp256k1/src/scalar.h new file mode 100644 index 0000000..b590ccd --- /dev/null +++ b/src/secp256k1/src/scalar.h @@ -0,0 +1,104 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_ +#define _SECP256K1_SCALAR_ + +#include "num.h" + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(USE_SCALAR_4X64) +#include "scalar_4x64.h" +#elif defined(USE_SCALAR_8X32) +#include "scalar_8x32.h" +#else +#error "Please select scalar implementation" +#endif + +/** Clear a scalar to prevent the leak of sensitive data. */ +static void secp256k1_scalar_clear(secp256k1_scalar *r); + +/** Access bits from a scalar. All requested bits must belong to the same 32-bit limb. */ +static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count); + +/** Access bits from a scalar. Not constant time. */ +static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count); + +/** Set a scalar from a big endian byte array. */ +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *bin, int *overflow); + +/** Set a scalar to an unsigned integer. */ +static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v); + +/** Convert a scalar to a byte array. */ +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a); + +/** Add two scalars together (modulo the group order). Returns whether it overflowed. */ +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b); + +/** Conditionally add a power of two to a scalar. The result is not allowed to overflow. */ +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag); + +/** Multiply two scalars (modulo the group order). */ +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b); + +/** Shift a scalar right by some amount strictly between 0 and 16, returning + * the low bits that were shifted off */ +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n); + +/** Compute the square of a scalar (modulo the group order). */ +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the inverse of a scalar (modulo the group order). */ +static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the inverse of a scalar (modulo the group order), without constant-time guarantee. */ +static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Compute the complement of a scalar (modulo the group order). */ +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a); + +/** Check whether a scalar equals zero. */ +static int secp256k1_scalar_is_zero(const secp256k1_scalar *a); + +/** Check whether a scalar equals one. */ +static int secp256k1_scalar_is_one(const secp256k1_scalar *a); + +/** Check whether a scalar, considered as an nonnegative integer, is even. */ +static int secp256k1_scalar_is_even(const secp256k1_scalar *a); + +/** Check whether a scalar is higher than the group order divided by 2. */ +static int secp256k1_scalar_is_high(const secp256k1_scalar *a); + +/** Conditionally negate a number, in constant time. + * Returns -1 if the number was negated, 1 otherwise */ +static int secp256k1_scalar_cond_negate(secp256k1_scalar *a, int flag); + +#ifndef USE_NUM_NONE +/** Convert a scalar to a number. */ +static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a); + +/** Get the order of the group as a number. */ +static void secp256k1_scalar_order_get_num(secp256k1_num *r); +#endif + +/** Compare two scalars. */ +static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b); + +#ifdef USE_ENDOMORPHISM +/** Find r1 and r2 such that r1+r2*2^128 = a. */ +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a); +/** Find r1 and r2 such that r1+r2*lambda = a, and r1 and r2 are maximum 128 bits long (see secp256k1_gej_mul_lambda). */ +static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a); +#endif + +/** Multiply a and b (without taking the modulus!), divide by 2**shift, and round to the nearest integer. Shift must be at least 256. */ +static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift); + +#endif diff --git a/src/secp256k1/src/scalar_4x64.h b/src/secp256k1/src/scalar_4x64.h new file mode 100644 index 0000000..cff4060 --- /dev/null +++ b/src/secp256k1/src/scalar_4x64.h @@ -0,0 +1,19 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_REPR_ +#define _SECP256K1_SCALAR_REPR_ + +#include + +/** A scalar modulo the group order of the secp256k1 curve. */ +typedef struct { + uint64_t d[4]; +} secp256k1_scalar; + +#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{((uint64_t)(d1)) << 32 | (d0), ((uint64_t)(d3)) << 32 | (d2), ((uint64_t)(d5)) << 32 | (d4), ((uint64_t)(d7)) << 32 | (d6)}} + +#endif diff --git a/src/secp256k1/src/scalar_4x64_impl.h b/src/secp256k1/src/scalar_4x64_impl.h new file mode 100644 index 0000000..aa2703d --- /dev/null +++ b/src/secp256k1/src/scalar_4x64_impl.h @@ -0,0 +1,949 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_REPR_IMPL_H_ +#define _SECP256K1_SCALAR_REPR_IMPL_H_ + +/* Limbs of the secp256k1 order. */ +#define SECP256K1_N_0 ((uint64_t)0xBFD25E8CD0364141ULL) +#define SECP256K1_N_1 ((uint64_t)0xBAAEDCE6AF48A03BULL) +#define SECP256K1_N_2 ((uint64_t)0xFFFFFFFFFFFFFFFEULL) +#define SECP256K1_N_3 ((uint64_t)0xFFFFFFFFFFFFFFFFULL) + +/* Limbs of 2^256 minus the secp256k1 order. */ +#define SECP256K1_N_C_0 (~SECP256K1_N_0 + 1) +#define SECP256K1_N_C_1 (~SECP256K1_N_1) +#define SECP256K1_N_C_2 (1) + +/* Limbs of half the secp256k1 order. */ +#define SECP256K1_N_H_0 ((uint64_t)0xDFE92F46681B20A0ULL) +#define SECP256K1_N_H_1 ((uint64_t)0x5D576E7357A4501DULL) +#define SECP256K1_N_H_2 ((uint64_t)0xFFFFFFFFFFFFFFFFULL) +#define SECP256K1_N_H_3 ((uint64_t)0x7FFFFFFFFFFFFFFFULL) + +SECP256K1_INLINE static void secp256k1_scalar_clear(secp256k1_scalar *r) { + r->d[0] = 0; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v) { + r->d[0] = v; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK((offset + count - 1) >> 6 == offset >> 6); + return (a->d[offset >> 6] >> (offset & 0x3F)) & ((((uint64_t)1) << count) - 1); +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK(count < 32); + VERIFY_CHECK(offset + count <= 256); + if ((offset + count - 1) >> 6 == offset >> 6) { + return secp256k1_scalar_get_bits(a, offset, count); + } else { + VERIFY_CHECK((offset >> 6) + 1 < 4); + return ((a->d[offset >> 6] >> (offset & 0x3F)) | (a->d[(offset >> 6) + 1] << (64 - (offset & 0x3F)))) & ((((uint64_t)1) << count) - 1); + } +} + +SECP256K1_INLINE static int secp256k1_scalar_check_overflow(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[3] < SECP256K1_N_3); /* No need for a > check. */ + no |= (a->d[2] < SECP256K1_N_2); + yes |= (a->d[2] > SECP256K1_N_2) & ~no; + no |= (a->d[1] < SECP256K1_N_1); + yes |= (a->d[1] > SECP256K1_N_1) & ~no; + yes |= (a->d[0] >= SECP256K1_N_0) & ~no; + return yes; +} + +SECP256K1_INLINE static int secp256k1_scalar_reduce(secp256k1_scalar *r, unsigned int overflow) { + uint128_t t; + VERIFY_CHECK(overflow <= 1); + t = (uint128_t)r->d[0] + overflow * SECP256K1_N_C_0; + r->d[0] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[1] + overflow * SECP256K1_N_C_1; + r->d[1] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[2] + overflow * SECP256K1_N_C_2; + r->d[2] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint64_t)r->d[3]; + r->d[3] = t & 0xFFFFFFFFFFFFFFFFULL; + return overflow; +} + +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + int overflow; + uint128_t t = (uint128_t)a->d[0] + b->d[0]; + r->d[0] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)a->d[1] + b->d[1]; + r->d[1] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)a->d[2] + b->d[2]; + r->d[2] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)a->d[3] + b->d[3]; + r->d[3] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + overflow = t + secp256k1_scalar_check_overflow(r); + VERIFY_CHECK(overflow == 0 || overflow == 1); + secp256k1_scalar_reduce(r, overflow); + return overflow; +} + +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag) { + uint128_t t; + VERIFY_CHECK(bit < 256); + bit += ((uint32_t) flag - 1) & 0x100; /* forcing (bit >> 6) > 3 makes this a noop */ + t = (uint128_t)r->d[0] + (((uint64_t)((bit >> 6) == 0)) << (bit & 0x3F)); + r->d[0] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[1] + (((uint64_t)((bit >> 6) == 1)) << (bit & 0x3F)); + r->d[1] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[2] + (((uint64_t)((bit >> 6) == 2)) << (bit & 0x3F)); + r->d[2] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64; + t += (uint128_t)r->d[3] + (((uint64_t)((bit >> 6) == 3)) << (bit & 0x3F)); + r->d[3] = t & 0xFFFFFFFFFFFFFFFFULL; +#ifdef VERIFY + VERIFY_CHECK((t >> 64) == 0); + VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0); +#endif +} + +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b32, int *overflow) { + int over; + r->d[0] = (uint64_t)b32[31] | (uint64_t)b32[30] << 8 | (uint64_t)b32[29] << 16 | (uint64_t)b32[28] << 24 | (uint64_t)b32[27] << 32 | (uint64_t)b32[26] << 40 | (uint64_t)b32[25] << 48 | (uint64_t)b32[24] << 56; + r->d[1] = (uint64_t)b32[23] | (uint64_t)b32[22] << 8 | (uint64_t)b32[21] << 16 | (uint64_t)b32[20] << 24 | (uint64_t)b32[19] << 32 | (uint64_t)b32[18] << 40 | (uint64_t)b32[17] << 48 | (uint64_t)b32[16] << 56; + r->d[2] = (uint64_t)b32[15] | (uint64_t)b32[14] << 8 | (uint64_t)b32[13] << 16 | (uint64_t)b32[12] << 24 | (uint64_t)b32[11] << 32 | (uint64_t)b32[10] << 40 | (uint64_t)b32[9] << 48 | (uint64_t)b32[8] << 56; + r->d[3] = (uint64_t)b32[7] | (uint64_t)b32[6] << 8 | (uint64_t)b32[5] << 16 | (uint64_t)b32[4] << 24 | (uint64_t)b32[3] << 32 | (uint64_t)b32[2] << 40 | (uint64_t)b32[1] << 48 | (uint64_t)b32[0] << 56; + over = secp256k1_scalar_reduce(r, secp256k1_scalar_check_overflow(r)); + if (overflow) { + *overflow = over; + } +} + +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a) { + bin[0] = a->d[3] >> 56; bin[1] = a->d[3] >> 48; bin[2] = a->d[3] >> 40; bin[3] = a->d[3] >> 32; bin[4] = a->d[3] >> 24; bin[5] = a->d[3] >> 16; bin[6] = a->d[3] >> 8; bin[7] = a->d[3]; + bin[8] = a->d[2] >> 56; bin[9] = a->d[2] >> 48; bin[10] = a->d[2] >> 40; bin[11] = a->d[2] >> 32; bin[12] = a->d[2] >> 24; bin[13] = a->d[2] >> 16; bin[14] = a->d[2] >> 8; bin[15] = a->d[2]; + bin[16] = a->d[1] >> 56; bin[17] = a->d[1] >> 48; bin[18] = a->d[1] >> 40; bin[19] = a->d[1] >> 32; bin[20] = a->d[1] >> 24; bin[21] = a->d[1] >> 16; bin[22] = a->d[1] >> 8; bin[23] = a->d[1]; + bin[24] = a->d[0] >> 56; bin[25] = a->d[0] >> 48; bin[26] = a->d[0] >> 40; bin[27] = a->d[0] >> 32; bin[28] = a->d[0] >> 24; bin[29] = a->d[0] >> 16; bin[30] = a->d[0] >> 8; bin[31] = a->d[0]; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_zero(const secp256k1_scalar *a) { + return (a->d[0] | a->d[1] | a->d[2] | a->d[3]) == 0; +} + +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint64_t nonzero = 0xFFFFFFFFFFFFFFFFULL * (secp256k1_scalar_is_zero(a) == 0); + uint128_t t = (uint128_t)(~a->d[0]) + SECP256K1_N_0 + 1; + r->d[0] = t & nonzero; t >>= 64; + t += (uint128_t)(~a->d[1]) + SECP256K1_N_1; + r->d[1] = t & nonzero; t >>= 64; + t += (uint128_t)(~a->d[2]) + SECP256K1_N_2; + r->d[2] = t & nonzero; t >>= 64; + t += (uint128_t)(~a->d[3]) + SECP256K1_N_3; + r->d[3] = t & nonzero; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_one(const secp256k1_scalar *a) { + return ((a->d[0] ^ 1) | a->d[1] | a->d[2] | a->d[3]) == 0; +} + +static int secp256k1_scalar_is_high(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[3] < SECP256K1_N_H_3); + yes |= (a->d[3] > SECP256K1_N_H_3) & ~no; + no |= (a->d[2] < SECP256K1_N_H_2) & ~yes; /* No need for a > check. */ + no |= (a->d[1] < SECP256K1_N_H_1) & ~yes; + yes |= (a->d[1] > SECP256K1_N_H_1) & ~no; + yes |= (a->d[0] > SECP256K1_N_H_0) & ~no; + return yes; +} + +static int secp256k1_scalar_cond_negate(secp256k1_scalar *r, int flag) { + /* If we are flag = 0, mask = 00...00 and this is a no-op; + * if we are flag = 1, mask = 11...11 and this is identical to secp256k1_scalar_negate */ + uint64_t mask = !flag - 1; + uint64_t nonzero = (secp256k1_scalar_is_zero(r) != 0) - 1; + uint128_t t = (uint128_t)(r->d[0] ^ mask) + ((SECP256K1_N_0 + 1) & mask); + r->d[0] = t & nonzero; t >>= 64; + t += (uint128_t)(r->d[1] ^ mask) + (SECP256K1_N_1 & mask); + r->d[1] = t & nonzero; t >>= 64; + t += (uint128_t)(r->d[2] ^ mask) + (SECP256K1_N_2 & mask); + r->d[2] = t & nonzero; t >>= 64; + t += (uint128_t)(r->d[3] ^ mask) + (SECP256K1_N_3 & mask); + r->d[3] = t & nonzero; + return 2 * (mask == 0) - 1; +} + +/* Inspired by the macros in OpenSSL's crypto/bn/asm/x86_64-gcc.c. */ + +/** Add a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd(a,b) { \ + uint64_t tl, th; \ + { \ + uint128_t t = (uint128_t)a * b; \ + th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \ + tl = t; \ + } \ + c0 += tl; /* overflow is handled on the next line */ \ + th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFFFFFFFFFF */ \ + c1 += th; /* overflow is handled on the next line */ \ + c2 += (c1 < th) ? 1 : 0; /* never overflows by contract (verified in the next line) */ \ + VERIFY_CHECK((c1 >= th) || (c2 != 0)); \ +} + +/** Add a*b to the number defined by (c0,c1). c1 must never overflow. */ +#define muladd_fast(a,b) { \ + uint64_t tl, th; \ + { \ + uint128_t t = (uint128_t)a * b; \ + th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \ + tl = t; \ + } \ + c0 += tl; /* overflow is handled on the next line */ \ + th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFFFFFFFFFF */ \ + c1 += th; /* never overflows by contract (verified in the next line) */ \ + VERIFY_CHECK(c1 >= th); \ +} + +/** Add 2*a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd2(a,b) { \ + uint64_t tl, th, th2, tl2; \ + { \ + uint128_t t = (uint128_t)a * b; \ + th = t >> 64; /* at most 0xFFFFFFFFFFFFFFFE */ \ + tl = t; \ + } \ + th2 = th + th; /* at most 0xFFFFFFFFFFFFFFFE (in case th was 0x7FFFFFFFFFFFFFFF) */ \ + c2 += (th2 < th) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((th2 >= th) || (c2 != 0)); \ + tl2 = tl + tl; /* at most 0xFFFFFFFFFFFFFFFE (in case the lowest 63 bits of tl were 0x7FFFFFFFFFFFFFFF) */ \ + th2 += (tl2 < tl) ? 1 : 0; /* at most 0xFFFFFFFFFFFFFFFF */ \ + c0 += tl2; /* overflow is handled on the next line */ \ + th2 += (c0 < tl2) ? 1 : 0; /* second overflow is handled on the next line */ \ + c2 += (c0 < tl2) & (th2 == 0); /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c0 >= tl2) || (th2 != 0) || (c2 != 0)); \ + c1 += th2; /* overflow is handled on the next line */ \ + c2 += (c1 < th2) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c1 >= th2) || (c2 != 0)); \ +} + +/** Add a to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define sumadd(a) { \ + unsigned int over; \ + c0 += (a); /* overflow is handled on the next line */ \ + over = (c0 < (a)) ? 1 : 0; \ + c1 += over; /* overflow is handled on the next line */ \ + c2 += (c1 < over) ? 1 : 0; /* never overflows by contract */ \ +} + +/** Add a to the number defined by (c0,c1). c1 must never overflow, c2 must be zero. */ +#define sumadd_fast(a) { \ + c0 += (a); /* overflow is handled on the next line */ \ + c1 += (c0 < (a)) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c1 != 0) | (c0 >= (a))); \ + VERIFY_CHECK(c2 == 0); \ +} + +/** Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits. */ +#define extract(n) { \ + (n) = c0; \ + c0 = c1; \ + c1 = c2; \ + c2 = 0; \ +} + +/** Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits. c2 is required to be zero. */ +#define extract_fast(n) { \ + (n) = c0; \ + c0 = c1; \ + c1 = 0; \ + VERIFY_CHECK(c2 == 0); \ +} + +static void secp256k1_scalar_reduce_512(secp256k1_scalar *r, const uint64_t *l) { +#ifdef USE_ASM_X86_64 + /* Reduce 512 bits into 385. */ + uint64_t m0, m1, m2, m3, m4, m5, m6; + uint64_t p0, p1, p2, p3, p4; + uint64_t c; + + __asm__ __volatile__( + /* Preload. */ + "movq 32(%%rsi), %%r11\n" + "movq 40(%%rsi), %%r12\n" + "movq 48(%%rsi), %%r13\n" + "movq 56(%%rsi), %%r14\n" + /* Initialize r8,r9,r10 */ + "movq 0(%%rsi), %%r8\n" + "movq $0, %%r9\n" + "movq $0, %%r10\n" + /* (r8,r9) += n0 * c0 */ + "movq %8, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* extract m0 */ + "movq %%r8, %q0\n" + "movq $0, %%r8\n" + /* (r9,r10) += l1 */ + "addq 8(%%rsi), %%r9\n" + "adcq $0, %%r10\n" + /* (r9,r10,r8) += n1 * c0 */ + "movq %8, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += n0 * c1 */ + "movq %9, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* extract m1 */ + "movq %%r9, %q1\n" + "movq $0, %%r9\n" + /* (r10,r8,r9) += l2 */ + "addq 16(%%rsi), %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += n2 * c0 */ + "movq %8, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += n1 * c1 */ + "movq %9, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += n0 */ + "addq %%r11, %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* extract m2 */ + "movq %%r10, %q2\n" + "movq $0, %%r10\n" + /* (r8,r9,r10) += l3 */ + "addq 24(%%rsi), %%r8\n" + "adcq $0, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += n3 * c0 */ + "movq %8, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += n2 * c1 */ + "movq %9, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += n1 */ + "addq %%r12, %%r8\n" + "adcq $0, %%r9\n" + "adcq $0, %%r10\n" + /* extract m3 */ + "movq %%r8, %q3\n" + "movq $0, %%r8\n" + /* (r9,r10,r8) += n3 * c1 */ + "movq %9, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += n2 */ + "addq %%r13, %%r9\n" + "adcq $0, %%r10\n" + "adcq $0, %%r8\n" + /* extract m4 */ + "movq %%r9, %q4\n" + /* (r10,r8) += n3 */ + "addq %%r14, %%r10\n" + "adcq $0, %%r8\n" + /* extract m5 */ + "movq %%r10, %q5\n" + /* extract m6 */ + "movq %%r8, %q6\n" + : "=g"(m0), "=g"(m1), "=g"(m2), "=g"(m3), "=g"(m4), "=g"(m5), "=g"(m6) + : "S"(l), "n"(SECP256K1_N_C_0), "n"(SECP256K1_N_C_1) + : "rax", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "cc"); + + /* Reduce 385 bits into 258. */ + __asm__ __volatile__( + /* Preload */ + "movq %q9, %%r11\n" + "movq %q10, %%r12\n" + "movq %q11, %%r13\n" + /* Initialize (r8,r9,r10) */ + "movq %q5, %%r8\n" + "movq $0, %%r9\n" + "movq $0, %%r10\n" + /* (r8,r9) += m4 * c0 */ + "movq %12, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* extract p0 */ + "movq %%r8, %q0\n" + "movq $0, %%r8\n" + /* (r9,r10) += m1 */ + "addq %q6, %%r9\n" + "adcq $0, %%r10\n" + /* (r9,r10,r8) += m5 * c0 */ + "movq %12, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += m4 * c1 */ + "movq %13, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* extract p1 */ + "movq %%r9, %q1\n" + "movq $0, %%r9\n" + /* (r10,r8,r9) += m2 */ + "addq %q7, %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += m6 * c0 */ + "movq %12, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += m5 * c1 */ + "movq %13, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += m4 */ + "addq %%r11, %%r10\n" + "adcq $0, %%r8\n" + "adcq $0, %%r9\n" + /* extract p2 */ + "movq %%r10, %q2\n" + /* (r8,r9) += m3 */ + "addq %q8, %%r8\n" + "adcq $0, %%r9\n" + /* (r8,r9) += m6 * c1 */ + "movq %13, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* (r8,r9) += m5 */ + "addq %%r12, %%r8\n" + "adcq $0, %%r9\n" + /* extract p3 */ + "movq %%r8, %q3\n" + /* (r9) += m6 */ + "addq %%r13, %%r9\n" + /* extract p4 */ + "movq %%r9, %q4\n" + : "=&g"(p0), "=&g"(p1), "=&g"(p2), "=g"(p3), "=g"(p4) + : "g"(m0), "g"(m1), "g"(m2), "g"(m3), "g"(m4), "g"(m5), "g"(m6), "n"(SECP256K1_N_C_0), "n"(SECP256K1_N_C_1) + : "rax", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "cc"); + + /* Reduce 258 bits into 256. */ + __asm__ __volatile__( + /* Preload */ + "movq %q5, %%r10\n" + /* (rax,rdx) = p4 * c0 */ + "movq %7, %%rax\n" + "mulq %%r10\n" + /* (rax,rdx) += p0 */ + "addq %q1, %%rax\n" + "adcq $0, %%rdx\n" + /* extract r0 */ + "movq %%rax, 0(%q6)\n" + /* Move to (r8,r9) */ + "movq %%rdx, %%r8\n" + "movq $0, %%r9\n" + /* (r8,r9) += p1 */ + "addq %q2, %%r8\n" + "adcq $0, %%r9\n" + /* (r8,r9) += p4 * c1 */ + "movq %8, %%rax\n" + "mulq %%r10\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + /* Extract r1 */ + "movq %%r8, 8(%q6)\n" + "movq $0, %%r8\n" + /* (r9,r8) += p4 */ + "addq %%r10, %%r9\n" + "adcq $0, %%r8\n" + /* (r9,r8) += p2 */ + "addq %q3, %%r9\n" + "adcq $0, %%r8\n" + /* Extract r2 */ + "movq %%r9, 16(%q6)\n" + "movq $0, %%r9\n" + /* (r8,r9) += p3 */ + "addq %q4, %%r8\n" + "adcq $0, %%r9\n" + /* Extract r3 */ + "movq %%r8, 24(%q6)\n" + /* Extract c */ + "movq %%r9, %q0\n" + : "=g"(c) + : "g"(p0), "g"(p1), "g"(p2), "g"(p3), "g"(p4), "D"(r), "n"(SECP256K1_N_C_0), "n"(SECP256K1_N_C_1) + : "rax", "rdx", "r8", "r9", "r10", "cc", "memory"); +#else + uint128_t c; + uint64_t c0, c1, c2; + uint64_t n0 = l[4], n1 = l[5], n2 = l[6], n3 = l[7]; + uint64_t m0, m1, m2, m3, m4, m5; + uint32_t m6; + uint64_t p0, p1, p2, p3; + uint32_t p4; + + /* Reduce 512 bits into 385. */ + /* m[0..6] = l[0..3] + n[0..3] * SECP256K1_N_C. */ + c0 = l[0]; c1 = 0; c2 = 0; + muladd_fast(n0, SECP256K1_N_C_0); + extract_fast(m0); + sumadd_fast(l[1]); + muladd(n1, SECP256K1_N_C_0); + muladd(n0, SECP256K1_N_C_1); + extract(m1); + sumadd(l[2]); + muladd(n2, SECP256K1_N_C_0); + muladd(n1, SECP256K1_N_C_1); + sumadd(n0); + extract(m2); + sumadd(l[3]); + muladd(n3, SECP256K1_N_C_0); + muladd(n2, SECP256K1_N_C_1); + sumadd(n1); + extract(m3); + muladd(n3, SECP256K1_N_C_1); + sumadd(n2); + extract(m4); + sumadd_fast(n3); + extract_fast(m5); + VERIFY_CHECK(c0 <= 1); + m6 = c0; + + /* Reduce 385 bits into 258. */ + /* p[0..4] = m[0..3] + m[4..6] * SECP256K1_N_C. */ + c0 = m0; c1 = 0; c2 = 0; + muladd_fast(m4, SECP256K1_N_C_0); + extract_fast(p0); + sumadd_fast(m1); + muladd(m5, SECP256K1_N_C_0); + muladd(m4, SECP256K1_N_C_1); + extract(p1); + sumadd(m2); + muladd(m6, SECP256K1_N_C_0); + muladd(m5, SECP256K1_N_C_1); + sumadd(m4); + extract(p2); + sumadd_fast(m3); + muladd_fast(m6, SECP256K1_N_C_1); + sumadd_fast(m5); + extract_fast(p3); + p4 = c0 + m6; + VERIFY_CHECK(p4 <= 2); + + /* Reduce 258 bits into 256. */ + /* r[0..3] = p[0..3] + p[4] * SECP256K1_N_C. */ + c = p0 + (uint128_t)SECP256K1_N_C_0 * p4; + r->d[0] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; + c += p1 + (uint128_t)SECP256K1_N_C_1 * p4; + r->d[1] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; + c += p2 + (uint128_t)p4; + r->d[2] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; + c += p3; + r->d[3] = c & 0xFFFFFFFFFFFFFFFFULL; c >>= 64; +#endif + + /* Final reduction of r. */ + secp256k1_scalar_reduce(r, c + secp256k1_scalar_check_overflow(r)); +} + +static void secp256k1_scalar_mul_512(uint64_t l[8], const secp256k1_scalar *a, const secp256k1_scalar *b) { +#ifdef USE_ASM_X86_64 + const uint64_t *pb = b->d; + __asm__ __volatile__( + /* Preload */ + "movq 0(%%rdi), %%r15\n" + "movq 8(%%rdi), %%rbx\n" + "movq 16(%%rdi), %%rcx\n" + "movq 0(%%rdx), %%r11\n" + "movq 8(%%rdx), %%r12\n" + "movq 16(%%rdx), %%r13\n" + "movq 24(%%rdx), %%r14\n" + /* (rax,rdx) = a0 * b0 */ + "movq %%r15, %%rax\n" + "mulq %%r11\n" + /* Extract l0 */ + "movq %%rax, 0(%%rsi)\n" + /* (r8,r9,r10) = (rdx) */ + "movq %%rdx, %%r8\n" + "xorq %%r9, %%r9\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += a0 * b1 */ + "movq %%r15, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a1 * b0 */ + "movq %%rbx, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l1 */ + "movq %%r8, 8(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += a0 * b2 */ + "movq %%r15, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a1 * b1 */ + "movq %%rbx, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a2 * b0 */ + "movq %%rcx, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l2 */ + "movq %%r9, 16(%%rsi)\n" + "xorq %%r9, %%r9\n" + /* (r10,r8,r9) += a0 * b3 */ + "movq %%r15, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* Preload a3 */ + "movq 24(%%rdi), %%r15\n" + /* (r10,r8,r9) += a1 * b2 */ + "movq %%rbx, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += a2 * b1 */ + "movq %%rcx, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += a3 * b0 */ + "movq %%r15, %%rax\n" + "mulq %%r11\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* Extract l3 */ + "movq %%r10, 24(%%rsi)\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += a1 * b3 */ + "movq %%rbx, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a2 * b2 */ + "movq %%rcx, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a3 * b1 */ + "movq %%r15, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l4 */ + "movq %%r8, 32(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += a2 * b3 */ + "movq %%rcx, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a3 * b2 */ + "movq %%r15, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l5 */ + "movq %%r9, 40(%%rsi)\n" + /* (r10,r8) += a3 * b3 */ + "movq %%r15, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + /* Extract l6 */ + "movq %%r10, 48(%%rsi)\n" + /* Extract l7 */ + "movq %%r8, 56(%%rsi)\n" + : "+d"(pb) + : "S"(l), "D"(a->d) + : "rax", "rbx", "rcx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "cc", "memory"); +#else + /* 160 bit accumulator. */ + uint64_t c0 = 0, c1 = 0; + uint32_t c2 = 0; + + /* l[0..7] = a[0..3] * b[0..3]. */ + muladd_fast(a->d[0], b->d[0]); + extract_fast(l[0]); + muladd(a->d[0], b->d[1]); + muladd(a->d[1], b->d[0]); + extract(l[1]); + muladd(a->d[0], b->d[2]); + muladd(a->d[1], b->d[1]); + muladd(a->d[2], b->d[0]); + extract(l[2]); + muladd(a->d[0], b->d[3]); + muladd(a->d[1], b->d[2]); + muladd(a->d[2], b->d[1]); + muladd(a->d[3], b->d[0]); + extract(l[3]); + muladd(a->d[1], b->d[3]); + muladd(a->d[2], b->d[2]); + muladd(a->d[3], b->d[1]); + extract(l[4]); + muladd(a->d[2], b->d[3]); + muladd(a->d[3], b->d[2]); + extract(l[5]); + muladd_fast(a->d[3], b->d[3]); + extract_fast(l[6]); + VERIFY_CHECK(c1 == 0); + l[7] = c0; +#endif +} + +static void secp256k1_scalar_sqr_512(uint64_t l[8], const secp256k1_scalar *a) { +#ifdef USE_ASM_X86_64 + __asm__ __volatile__( + /* Preload */ + "movq 0(%%rdi), %%r11\n" + "movq 8(%%rdi), %%r12\n" + "movq 16(%%rdi), %%r13\n" + "movq 24(%%rdi), %%r14\n" + /* (rax,rdx) = a0 * a0 */ + "movq %%r11, %%rax\n" + "mulq %%r11\n" + /* Extract l0 */ + "movq %%rax, 0(%%rsi)\n" + /* (r8,r9,r10) = (rdx,0) */ + "movq %%rdx, %%r8\n" + "xorq %%r9, %%r9\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += 2 * a0 * a1 */ + "movq %%r11, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l1 */ + "movq %%r8, 8(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += 2 * a0 * a2 */ + "movq %%r11, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* (r9,r10,r8) += a1 * a1 */ + "movq %%r12, %%rax\n" + "mulq %%r12\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l2 */ + "movq %%r9, 16(%%rsi)\n" + "xorq %%r9, %%r9\n" + /* (r10,r8,r9) += 2 * a0 * a3 */ + "movq %%r11, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* (r10,r8,r9) += 2 * a1 * a2 */ + "movq %%r12, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + "adcq $0, %%r9\n" + /* Extract l3 */ + "movq %%r10, 24(%%rsi)\n" + "xorq %%r10, %%r10\n" + /* (r8,r9,r10) += 2 * a1 * a3 */ + "movq %%r12, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* (r8,r9,r10) += a2 * a2 */ + "movq %%r13, %%rax\n" + "mulq %%r13\n" + "addq %%rax, %%r8\n" + "adcq %%rdx, %%r9\n" + "adcq $0, %%r10\n" + /* Extract l4 */ + "movq %%r8, 32(%%rsi)\n" + "xorq %%r8, %%r8\n" + /* (r9,r10,r8) += 2 * a2 * a3 */ + "movq %%r13, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + "addq %%rax, %%r9\n" + "adcq %%rdx, %%r10\n" + "adcq $0, %%r8\n" + /* Extract l5 */ + "movq %%r9, 40(%%rsi)\n" + /* (r10,r8) += a3 * a3 */ + "movq %%r14, %%rax\n" + "mulq %%r14\n" + "addq %%rax, %%r10\n" + "adcq %%rdx, %%r8\n" + /* Extract l6 */ + "movq %%r10, 48(%%rsi)\n" + /* Extract l7 */ + "movq %%r8, 56(%%rsi)\n" + : + : "S"(l), "D"(a->d) + : "rax", "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "cc", "memory"); +#else + /* 160 bit accumulator. */ + uint64_t c0 = 0, c1 = 0; + uint32_t c2 = 0; + + /* l[0..7] = a[0..3] * b[0..3]. */ + muladd_fast(a->d[0], a->d[0]); + extract_fast(l[0]); + muladd2(a->d[0], a->d[1]); + extract(l[1]); + muladd2(a->d[0], a->d[2]); + muladd(a->d[1], a->d[1]); + extract(l[2]); + muladd2(a->d[0], a->d[3]); + muladd2(a->d[1], a->d[2]); + extract(l[3]); + muladd2(a->d[1], a->d[3]); + muladd(a->d[2], a->d[2]); + extract(l[4]); + muladd2(a->d[2], a->d[3]); + extract(l[5]); + muladd_fast(a->d[3], a->d[3]); + extract_fast(l[6]); + VERIFY_CHECK(c1 == 0); + l[7] = c0; +#endif +} + +#undef sumadd +#undef sumadd_fast +#undef muladd +#undef muladd_fast +#undef muladd2 +#undef extract +#undef extract_fast + +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + uint64_t l[8]; + secp256k1_scalar_mul_512(l, a, b); + secp256k1_scalar_reduce_512(r, l); +} + +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n) { + int ret; + VERIFY_CHECK(n > 0); + VERIFY_CHECK(n < 16); + ret = r->d[0] & ((1 << n) - 1); + r->d[0] = (r->d[0] >> n) + (r->d[1] << (64 - n)); + r->d[1] = (r->d[1] >> n) + (r->d[2] << (64 - n)); + r->d[2] = (r->d[2] >> n) + (r->d[3] << (64 - n)); + r->d[3] = (r->d[3] >> n); + return ret; +} + +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint64_t l[8]; + secp256k1_scalar_sqr_512(l, a); + secp256k1_scalar_reduce_512(r, l); +} + +#ifdef USE_ENDOMORPHISM +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + r1->d[0] = a->d[0]; + r1->d[1] = a->d[1]; + r1->d[2] = 0; + r1->d[3] = 0; + r2->d[0] = a->d[2]; + r2->d[1] = a->d[3]; + r2->d[2] = 0; + r2->d[3] = 0; +} +#endif + +SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b) { + return ((a->d[0] ^ b->d[0]) | (a->d[1] ^ b->d[1]) | (a->d[2] ^ b->d[2]) | (a->d[3] ^ b->d[3])) == 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift) { + uint64_t l[8]; + unsigned int shiftlimbs; + unsigned int shiftlow; + unsigned int shifthigh; + VERIFY_CHECK(shift >= 256); + secp256k1_scalar_mul_512(l, a, b); + shiftlimbs = shift >> 6; + shiftlow = shift & 0x3F; + shifthigh = 64 - shiftlow; + r->d[0] = shift < 512 ? (l[0 + shiftlimbs] >> shiftlow | (shift < 448 && shiftlow ? (l[1 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[1] = shift < 448 ? (l[1 + shiftlimbs] >> shiftlow | (shift < 384 && shiftlow ? (l[2 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[2] = shift < 384 ? (l[2 + shiftlimbs] >> shiftlow | (shift < 320 && shiftlow ? (l[3 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[3] = shift < 320 ? (l[3 + shiftlimbs] >> shiftlow) : 0; + secp256k1_scalar_cadd_bit(r, 0, (l[(shift - 1) >> 6] >> ((shift - 1) & 0x3f)) & 1); +} + +#endif diff --git a/src/secp256k1/src/scalar_8x32.h b/src/secp256k1/src/scalar_8x32.h new file mode 100644 index 0000000..1319664 --- /dev/null +++ b/src/secp256k1/src/scalar_8x32.h @@ -0,0 +1,19 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_REPR_ +#define _SECP256K1_SCALAR_REPR_ + +#include + +/** A scalar modulo the group order of the secp256k1 curve. */ +typedef struct { + uint32_t d[8]; +} secp256k1_scalar; + +#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{(d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)}} + +#endif diff --git a/src/secp256k1/src/scalar_8x32_impl.h b/src/secp256k1/src/scalar_8x32_impl.h new file mode 100644 index 0000000..aae4f35 --- /dev/null +++ b/src/secp256k1/src/scalar_8x32_impl.h @@ -0,0 +1,721 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_REPR_IMPL_H_ +#define _SECP256K1_SCALAR_REPR_IMPL_H_ + +/* Limbs of the secp256k1 order. */ +#define SECP256K1_N_0 ((uint32_t)0xD0364141UL) +#define SECP256K1_N_1 ((uint32_t)0xBFD25E8CUL) +#define SECP256K1_N_2 ((uint32_t)0xAF48A03BUL) +#define SECP256K1_N_3 ((uint32_t)0xBAAEDCE6UL) +#define SECP256K1_N_4 ((uint32_t)0xFFFFFFFEUL) +#define SECP256K1_N_5 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_6 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_7 ((uint32_t)0xFFFFFFFFUL) + +/* Limbs of 2^256 minus the secp256k1 order. */ +#define SECP256K1_N_C_0 (~SECP256K1_N_0 + 1) +#define SECP256K1_N_C_1 (~SECP256K1_N_1) +#define SECP256K1_N_C_2 (~SECP256K1_N_2) +#define SECP256K1_N_C_3 (~SECP256K1_N_3) +#define SECP256K1_N_C_4 (1) + +/* Limbs of half the secp256k1 order. */ +#define SECP256K1_N_H_0 ((uint32_t)0x681B20A0UL) +#define SECP256K1_N_H_1 ((uint32_t)0xDFE92F46UL) +#define SECP256K1_N_H_2 ((uint32_t)0x57A4501DUL) +#define SECP256K1_N_H_3 ((uint32_t)0x5D576E73UL) +#define SECP256K1_N_H_4 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_H_5 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_H_6 ((uint32_t)0xFFFFFFFFUL) +#define SECP256K1_N_H_7 ((uint32_t)0x7FFFFFFFUL) + +SECP256K1_INLINE static void secp256k1_scalar_clear(secp256k1_scalar *r) { + r->d[0] = 0; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; + r->d[4] = 0; + r->d[5] = 0; + r->d[6] = 0; + r->d[7] = 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v) { + r->d[0] = v; + r->d[1] = 0; + r->d[2] = 0; + r->d[3] = 0; + r->d[4] = 0; + r->d[5] = 0; + r->d[6] = 0; + r->d[7] = 0; +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK((offset + count - 1) >> 5 == offset >> 5); + return (a->d[offset >> 5] >> (offset & 0x1F)) & ((1 << count) - 1); +} + +SECP256K1_INLINE static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count) { + VERIFY_CHECK(count < 32); + VERIFY_CHECK(offset + count <= 256); + if ((offset + count - 1) >> 5 == offset >> 5) { + return secp256k1_scalar_get_bits(a, offset, count); + } else { + VERIFY_CHECK((offset >> 5) + 1 < 8); + return ((a->d[offset >> 5] >> (offset & 0x1F)) | (a->d[(offset >> 5) + 1] << (32 - (offset & 0x1F)))) & ((((uint32_t)1) << count) - 1); + } +} + +SECP256K1_INLINE static int secp256k1_scalar_check_overflow(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[7] < SECP256K1_N_7); /* No need for a > check. */ + no |= (a->d[6] < SECP256K1_N_6); /* No need for a > check. */ + no |= (a->d[5] < SECP256K1_N_5); /* No need for a > check. */ + no |= (a->d[4] < SECP256K1_N_4); + yes |= (a->d[4] > SECP256K1_N_4) & ~no; + no |= (a->d[3] < SECP256K1_N_3) & ~yes; + yes |= (a->d[3] > SECP256K1_N_3) & ~no; + no |= (a->d[2] < SECP256K1_N_2) & ~yes; + yes |= (a->d[2] > SECP256K1_N_2) & ~no; + no |= (a->d[1] < SECP256K1_N_1) & ~yes; + yes |= (a->d[1] > SECP256K1_N_1) & ~no; + yes |= (a->d[0] >= SECP256K1_N_0) & ~no; + return yes; +} + +SECP256K1_INLINE static int secp256k1_scalar_reduce(secp256k1_scalar *r, uint32_t overflow) { + uint64_t t; + VERIFY_CHECK(overflow <= 1); + t = (uint64_t)r->d[0] + overflow * SECP256K1_N_C_0; + r->d[0] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[1] + overflow * SECP256K1_N_C_1; + r->d[1] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[2] + overflow * SECP256K1_N_C_2; + r->d[2] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[3] + overflow * SECP256K1_N_C_3; + r->d[3] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[4] + overflow * SECP256K1_N_C_4; + r->d[4] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[5]; + r->d[5] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[6]; + r->d[6] = t & 0xFFFFFFFFUL; t >>= 32; + t += (uint64_t)r->d[7]; + r->d[7] = t & 0xFFFFFFFFUL; + return overflow; +} + +static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + int overflow; + uint64_t t = (uint64_t)a->d[0] + b->d[0]; + r->d[0] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[1] + b->d[1]; + r->d[1] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[2] + b->d[2]; + r->d[2] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[3] + b->d[3]; + r->d[3] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[4] + b->d[4]; + r->d[4] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[5] + b->d[5]; + r->d[5] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[6] + b->d[6]; + r->d[6] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)a->d[7] + b->d[7]; + r->d[7] = t & 0xFFFFFFFFULL; t >>= 32; + overflow = t + secp256k1_scalar_check_overflow(r); + VERIFY_CHECK(overflow == 0 || overflow == 1); + secp256k1_scalar_reduce(r, overflow); + return overflow; +} + +static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag) { + uint64_t t; + VERIFY_CHECK(bit < 256); + bit += ((uint32_t) flag - 1) & 0x100; /* forcing (bit >> 5) > 7 makes this a noop */ + t = (uint64_t)r->d[0] + (((uint32_t)((bit >> 5) == 0)) << (bit & 0x1F)); + r->d[0] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[1] + (((uint32_t)((bit >> 5) == 1)) << (bit & 0x1F)); + r->d[1] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[2] + (((uint32_t)((bit >> 5) == 2)) << (bit & 0x1F)); + r->d[2] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[3] + (((uint32_t)((bit >> 5) == 3)) << (bit & 0x1F)); + r->d[3] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[4] + (((uint32_t)((bit >> 5) == 4)) << (bit & 0x1F)); + r->d[4] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[5] + (((uint32_t)((bit >> 5) == 5)) << (bit & 0x1F)); + r->d[5] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[6] + (((uint32_t)((bit >> 5) == 6)) << (bit & 0x1F)); + r->d[6] = t & 0xFFFFFFFFULL; t >>= 32; + t += (uint64_t)r->d[7] + (((uint32_t)((bit >> 5) == 7)) << (bit & 0x1F)); + r->d[7] = t & 0xFFFFFFFFULL; +#ifdef VERIFY + VERIFY_CHECK((t >> 32) == 0); + VERIFY_CHECK(secp256k1_scalar_check_overflow(r) == 0); +#endif +} + +static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *b32, int *overflow) { + int over; + r->d[0] = (uint32_t)b32[31] | (uint32_t)b32[30] << 8 | (uint32_t)b32[29] << 16 | (uint32_t)b32[28] << 24; + r->d[1] = (uint32_t)b32[27] | (uint32_t)b32[26] << 8 | (uint32_t)b32[25] << 16 | (uint32_t)b32[24] << 24; + r->d[2] = (uint32_t)b32[23] | (uint32_t)b32[22] << 8 | (uint32_t)b32[21] << 16 | (uint32_t)b32[20] << 24; + r->d[3] = (uint32_t)b32[19] | (uint32_t)b32[18] << 8 | (uint32_t)b32[17] << 16 | (uint32_t)b32[16] << 24; + r->d[4] = (uint32_t)b32[15] | (uint32_t)b32[14] << 8 | (uint32_t)b32[13] << 16 | (uint32_t)b32[12] << 24; + r->d[5] = (uint32_t)b32[11] | (uint32_t)b32[10] << 8 | (uint32_t)b32[9] << 16 | (uint32_t)b32[8] << 24; + r->d[6] = (uint32_t)b32[7] | (uint32_t)b32[6] << 8 | (uint32_t)b32[5] << 16 | (uint32_t)b32[4] << 24; + r->d[7] = (uint32_t)b32[3] | (uint32_t)b32[2] << 8 | (uint32_t)b32[1] << 16 | (uint32_t)b32[0] << 24; + over = secp256k1_scalar_reduce(r, secp256k1_scalar_check_overflow(r)); + if (overflow) { + *overflow = over; + } +} + +static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar* a) { + bin[0] = a->d[7] >> 24; bin[1] = a->d[7] >> 16; bin[2] = a->d[7] >> 8; bin[3] = a->d[7]; + bin[4] = a->d[6] >> 24; bin[5] = a->d[6] >> 16; bin[6] = a->d[6] >> 8; bin[7] = a->d[6]; + bin[8] = a->d[5] >> 24; bin[9] = a->d[5] >> 16; bin[10] = a->d[5] >> 8; bin[11] = a->d[5]; + bin[12] = a->d[4] >> 24; bin[13] = a->d[4] >> 16; bin[14] = a->d[4] >> 8; bin[15] = a->d[4]; + bin[16] = a->d[3] >> 24; bin[17] = a->d[3] >> 16; bin[18] = a->d[3] >> 8; bin[19] = a->d[3]; + bin[20] = a->d[2] >> 24; bin[21] = a->d[2] >> 16; bin[22] = a->d[2] >> 8; bin[23] = a->d[2]; + bin[24] = a->d[1] >> 24; bin[25] = a->d[1] >> 16; bin[26] = a->d[1] >> 8; bin[27] = a->d[1]; + bin[28] = a->d[0] >> 24; bin[29] = a->d[0] >> 16; bin[30] = a->d[0] >> 8; bin[31] = a->d[0]; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_zero(const secp256k1_scalar *a) { + return (a->d[0] | a->d[1] | a->d[2] | a->d[3] | a->d[4] | a->d[5] | a->d[6] | a->d[7]) == 0; +} + +static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint32_t nonzero = 0xFFFFFFFFUL * (secp256k1_scalar_is_zero(a) == 0); + uint64_t t = (uint64_t)(~a->d[0]) + SECP256K1_N_0 + 1; + r->d[0] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[1]) + SECP256K1_N_1; + r->d[1] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[2]) + SECP256K1_N_2; + r->d[2] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[3]) + SECP256K1_N_3; + r->d[3] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[4]) + SECP256K1_N_4; + r->d[4] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[5]) + SECP256K1_N_5; + r->d[5] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[6]) + SECP256K1_N_6; + r->d[6] = t & nonzero; t >>= 32; + t += (uint64_t)(~a->d[7]) + SECP256K1_N_7; + r->d[7] = t & nonzero; +} + +SECP256K1_INLINE static int secp256k1_scalar_is_one(const secp256k1_scalar *a) { + return ((a->d[0] ^ 1) | a->d[1] | a->d[2] | a->d[3] | a->d[4] | a->d[5] | a->d[6] | a->d[7]) == 0; +} + +static int secp256k1_scalar_is_high(const secp256k1_scalar *a) { + int yes = 0; + int no = 0; + no |= (a->d[7] < SECP256K1_N_H_7); + yes |= (a->d[7] > SECP256K1_N_H_7) & ~no; + no |= (a->d[6] < SECP256K1_N_H_6) & ~yes; /* No need for a > check. */ + no |= (a->d[5] < SECP256K1_N_H_5) & ~yes; /* No need for a > check. */ + no |= (a->d[4] < SECP256K1_N_H_4) & ~yes; /* No need for a > check. */ + no |= (a->d[3] < SECP256K1_N_H_3) & ~yes; + yes |= (a->d[3] > SECP256K1_N_H_3) & ~no; + no |= (a->d[2] < SECP256K1_N_H_2) & ~yes; + yes |= (a->d[2] > SECP256K1_N_H_2) & ~no; + no |= (a->d[1] < SECP256K1_N_H_1) & ~yes; + yes |= (a->d[1] > SECP256K1_N_H_1) & ~no; + yes |= (a->d[0] > SECP256K1_N_H_0) & ~no; + return yes; +} + +static int secp256k1_scalar_cond_negate(secp256k1_scalar *r, int flag) { + /* If we are flag = 0, mask = 00...00 and this is a no-op; + * if we are flag = 1, mask = 11...11 and this is identical to secp256k1_scalar_negate */ + uint32_t mask = !flag - 1; + uint32_t nonzero = 0xFFFFFFFFUL * (secp256k1_scalar_is_zero(r) == 0); + uint64_t t = (uint64_t)(r->d[0] ^ mask) + ((SECP256K1_N_0 + 1) & mask); + r->d[0] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[1] ^ mask) + (SECP256K1_N_1 & mask); + r->d[1] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[2] ^ mask) + (SECP256K1_N_2 & mask); + r->d[2] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[3] ^ mask) + (SECP256K1_N_3 & mask); + r->d[3] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[4] ^ mask) + (SECP256K1_N_4 & mask); + r->d[4] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[5] ^ mask) + (SECP256K1_N_5 & mask); + r->d[5] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[6] ^ mask) + (SECP256K1_N_6 & mask); + r->d[6] = t & nonzero; t >>= 32; + t += (uint64_t)(r->d[7] ^ mask) + (SECP256K1_N_7 & mask); + r->d[7] = t & nonzero; + return 2 * (mask == 0) - 1; +} + + +/* Inspired by the macros in OpenSSL's crypto/bn/asm/x86_64-gcc.c. */ + +/** Add a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd(a,b) { \ + uint32_t tl, th; \ + { \ + uint64_t t = (uint64_t)a * b; \ + th = t >> 32; /* at most 0xFFFFFFFE */ \ + tl = t; \ + } \ + c0 += tl; /* overflow is handled on the next line */ \ + th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \ + c1 += th; /* overflow is handled on the next line */ \ + c2 += (c1 < th) ? 1 : 0; /* never overflows by contract (verified in the next line) */ \ + VERIFY_CHECK((c1 >= th) || (c2 != 0)); \ +} + +/** Add a*b to the number defined by (c0,c1). c1 must never overflow. */ +#define muladd_fast(a,b) { \ + uint32_t tl, th; \ + { \ + uint64_t t = (uint64_t)a * b; \ + th = t >> 32; /* at most 0xFFFFFFFE */ \ + tl = t; \ + } \ + c0 += tl; /* overflow is handled on the next line */ \ + th += (c0 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \ + c1 += th; /* never overflows by contract (verified in the next line) */ \ + VERIFY_CHECK(c1 >= th); \ +} + +/** Add 2*a*b to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define muladd2(a,b) { \ + uint32_t tl, th, th2, tl2; \ + { \ + uint64_t t = (uint64_t)a * b; \ + th = t >> 32; /* at most 0xFFFFFFFE */ \ + tl = t; \ + } \ + th2 = th + th; /* at most 0xFFFFFFFE (in case th was 0x7FFFFFFF) */ \ + c2 += (th2 < th) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((th2 >= th) || (c2 != 0)); \ + tl2 = tl + tl; /* at most 0xFFFFFFFE (in case the lowest 63 bits of tl were 0x7FFFFFFF) */ \ + th2 += (tl2 < tl) ? 1 : 0; /* at most 0xFFFFFFFF */ \ + c0 += tl2; /* overflow is handled on the next line */ \ + th2 += (c0 < tl2) ? 1 : 0; /* second overflow is handled on the next line */ \ + c2 += (c0 < tl2) & (th2 == 0); /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c0 >= tl2) || (th2 != 0) || (c2 != 0)); \ + c1 += th2; /* overflow is handled on the next line */ \ + c2 += (c1 < th2) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c1 >= th2) || (c2 != 0)); \ +} + +/** Add a to the number defined by (c0,c1,c2). c2 must never overflow. */ +#define sumadd(a) { \ + unsigned int over; \ + c0 += (a); /* overflow is handled on the next line */ \ + over = (c0 < (a)) ? 1 : 0; \ + c1 += over; /* overflow is handled on the next line */ \ + c2 += (c1 < over) ? 1 : 0; /* never overflows by contract */ \ +} + +/** Add a to the number defined by (c0,c1). c1 must never overflow, c2 must be zero. */ +#define sumadd_fast(a) { \ + c0 += (a); /* overflow is handled on the next line */ \ + c1 += (c0 < (a)) ? 1 : 0; /* never overflows by contract (verified the next line) */ \ + VERIFY_CHECK((c1 != 0) | (c0 >= (a))); \ + VERIFY_CHECK(c2 == 0); \ +} + +/** Extract the lowest 32 bits of (c0,c1,c2) into n, and left shift the number 32 bits. */ +#define extract(n) { \ + (n) = c0; \ + c0 = c1; \ + c1 = c2; \ + c2 = 0; \ +} + +/** Extract the lowest 32 bits of (c0,c1,c2) into n, and left shift the number 32 bits. c2 is required to be zero. */ +#define extract_fast(n) { \ + (n) = c0; \ + c0 = c1; \ + c1 = 0; \ + VERIFY_CHECK(c2 == 0); \ +} + +static void secp256k1_scalar_reduce_512(secp256k1_scalar *r, const uint32_t *l) { + uint64_t c; + uint32_t n0 = l[8], n1 = l[9], n2 = l[10], n3 = l[11], n4 = l[12], n5 = l[13], n6 = l[14], n7 = l[15]; + uint32_t m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12; + uint32_t p0, p1, p2, p3, p4, p5, p6, p7, p8; + + /* 96 bit accumulator. */ + uint32_t c0, c1, c2; + + /* Reduce 512 bits into 385. */ + /* m[0..12] = l[0..7] + n[0..7] * SECP256K1_N_C. */ + c0 = l[0]; c1 = 0; c2 = 0; + muladd_fast(n0, SECP256K1_N_C_0); + extract_fast(m0); + sumadd_fast(l[1]); + muladd(n1, SECP256K1_N_C_0); + muladd(n0, SECP256K1_N_C_1); + extract(m1); + sumadd(l[2]); + muladd(n2, SECP256K1_N_C_0); + muladd(n1, SECP256K1_N_C_1); + muladd(n0, SECP256K1_N_C_2); + extract(m2); + sumadd(l[3]); + muladd(n3, SECP256K1_N_C_0); + muladd(n2, SECP256K1_N_C_1); + muladd(n1, SECP256K1_N_C_2); + muladd(n0, SECP256K1_N_C_3); + extract(m3); + sumadd(l[4]); + muladd(n4, SECP256K1_N_C_0); + muladd(n3, SECP256K1_N_C_1); + muladd(n2, SECP256K1_N_C_2); + muladd(n1, SECP256K1_N_C_3); + sumadd(n0); + extract(m4); + sumadd(l[5]); + muladd(n5, SECP256K1_N_C_0); + muladd(n4, SECP256K1_N_C_1); + muladd(n3, SECP256K1_N_C_2); + muladd(n2, SECP256K1_N_C_3); + sumadd(n1); + extract(m5); + sumadd(l[6]); + muladd(n6, SECP256K1_N_C_0); + muladd(n5, SECP256K1_N_C_1); + muladd(n4, SECP256K1_N_C_2); + muladd(n3, SECP256K1_N_C_3); + sumadd(n2); + extract(m6); + sumadd(l[7]); + muladd(n7, SECP256K1_N_C_0); + muladd(n6, SECP256K1_N_C_1); + muladd(n5, SECP256K1_N_C_2); + muladd(n4, SECP256K1_N_C_3); + sumadd(n3); + extract(m7); + muladd(n7, SECP256K1_N_C_1); + muladd(n6, SECP256K1_N_C_2); + muladd(n5, SECP256K1_N_C_3); + sumadd(n4); + extract(m8); + muladd(n7, SECP256K1_N_C_2); + muladd(n6, SECP256K1_N_C_3); + sumadd(n5); + extract(m9); + muladd(n7, SECP256K1_N_C_3); + sumadd(n6); + extract(m10); + sumadd_fast(n7); + extract_fast(m11); + VERIFY_CHECK(c0 <= 1); + m12 = c0; + + /* Reduce 385 bits into 258. */ + /* p[0..8] = m[0..7] + m[8..12] * SECP256K1_N_C. */ + c0 = m0; c1 = 0; c2 = 0; + muladd_fast(m8, SECP256K1_N_C_0); + extract_fast(p0); + sumadd_fast(m1); + muladd(m9, SECP256K1_N_C_0); + muladd(m8, SECP256K1_N_C_1); + extract(p1); + sumadd(m2); + muladd(m10, SECP256K1_N_C_0); + muladd(m9, SECP256K1_N_C_1); + muladd(m8, SECP256K1_N_C_2); + extract(p2); + sumadd(m3); + muladd(m11, SECP256K1_N_C_0); + muladd(m10, SECP256K1_N_C_1); + muladd(m9, SECP256K1_N_C_2); + muladd(m8, SECP256K1_N_C_3); + extract(p3); + sumadd(m4); + muladd(m12, SECP256K1_N_C_0); + muladd(m11, SECP256K1_N_C_1); + muladd(m10, SECP256K1_N_C_2); + muladd(m9, SECP256K1_N_C_3); + sumadd(m8); + extract(p4); + sumadd(m5); + muladd(m12, SECP256K1_N_C_1); + muladd(m11, SECP256K1_N_C_2); + muladd(m10, SECP256K1_N_C_3); + sumadd(m9); + extract(p5); + sumadd(m6); + muladd(m12, SECP256K1_N_C_2); + muladd(m11, SECP256K1_N_C_3); + sumadd(m10); + extract(p6); + sumadd_fast(m7); + muladd_fast(m12, SECP256K1_N_C_3); + sumadd_fast(m11); + extract_fast(p7); + p8 = c0 + m12; + VERIFY_CHECK(p8 <= 2); + + /* Reduce 258 bits into 256. */ + /* r[0..7] = p[0..7] + p[8] * SECP256K1_N_C. */ + c = p0 + (uint64_t)SECP256K1_N_C_0 * p8; + r->d[0] = c & 0xFFFFFFFFUL; c >>= 32; + c += p1 + (uint64_t)SECP256K1_N_C_1 * p8; + r->d[1] = c & 0xFFFFFFFFUL; c >>= 32; + c += p2 + (uint64_t)SECP256K1_N_C_2 * p8; + r->d[2] = c & 0xFFFFFFFFUL; c >>= 32; + c += p3 + (uint64_t)SECP256K1_N_C_3 * p8; + r->d[3] = c & 0xFFFFFFFFUL; c >>= 32; + c += p4 + (uint64_t)p8; + r->d[4] = c & 0xFFFFFFFFUL; c >>= 32; + c += p5; + r->d[5] = c & 0xFFFFFFFFUL; c >>= 32; + c += p6; + r->d[6] = c & 0xFFFFFFFFUL; c >>= 32; + c += p7; + r->d[7] = c & 0xFFFFFFFFUL; c >>= 32; + + /* Final reduction of r. */ + secp256k1_scalar_reduce(r, c + secp256k1_scalar_check_overflow(r)); +} + +static void secp256k1_scalar_mul_512(uint32_t *l, const secp256k1_scalar *a, const secp256k1_scalar *b) { + /* 96 bit accumulator. */ + uint32_t c0 = 0, c1 = 0, c2 = 0; + + /* l[0..15] = a[0..7] * b[0..7]. */ + muladd_fast(a->d[0], b->d[0]); + extract_fast(l[0]); + muladd(a->d[0], b->d[1]); + muladd(a->d[1], b->d[0]); + extract(l[1]); + muladd(a->d[0], b->d[2]); + muladd(a->d[1], b->d[1]); + muladd(a->d[2], b->d[0]); + extract(l[2]); + muladd(a->d[0], b->d[3]); + muladd(a->d[1], b->d[2]); + muladd(a->d[2], b->d[1]); + muladd(a->d[3], b->d[0]); + extract(l[3]); + muladd(a->d[0], b->d[4]); + muladd(a->d[1], b->d[3]); + muladd(a->d[2], b->d[2]); + muladd(a->d[3], b->d[1]); + muladd(a->d[4], b->d[0]); + extract(l[4]); + muladd(a->d[0], b->d[5]); + muladd(a->d[1], b->d[4]); + muladd(a->d[2], b->d[3]); + muladd(a->d[3], b->d[2]); + muladd(a->d[4], b->d[1]); + muladd(a->d[5], b->d[0]); + extract(l[5]); + muladd(a->d[0], b->d[6]); + muladd(a->d[1], b->d[5]); + muladd(a->d[2], b->d[4]); + muladd(a->d[3], b->d[3]); + muladd(a->d[4], b->d[2]); + muladd(a->d[5], b->d[1]); + muladd(a->d[6], b->d[0]); + extract(l[6]); + muladd(a->d[0], b->d[7]); + muladd(a->d[1], b->d[6]); + muladd(a->d[2], b->d[5]); + muladd(a->d[3], b->d[4]); + muladd(a->d[4], b->d[3]); + muladd(a->d[5], b->d[2]); + muladd(a->d[6], b->d[1]); + muladd(a->d[7], b->d[0]); + extract(l[7]); + muladd(a->d[1], b->d[7]); + muladd(a->d[2], b->d[6]); + muladd(a->d[3], b->d[5]); + muladd(a->d[4], b->d[4]); + muladd(a->d[5], b->d[3]); + muladd(a->d[6], b->d[2]); + muladd(a->d[7], b->d[1]); + extract(l[8]); + muladd(a->d[2], b->d[7]); + muladd(a->d[3], b->d[6]); + muladd(a->d[4], b->d[5]); + muladd(a->d[5], b->d[4]); + muladd(a->d[6], b->d[3]); + muladd(a->d[7], b->d[2]); + extract(l[9]); + muladd(a->d[3], b->d[7]); + muladd(a->d[4], b->d[6]); + muladd(a->d[5], b->d[5]); + muladd(a->d[6], b->d[4]); + muladd(a->d[7], b->d[3]); + extract(l[10]); + muladd(a->d[4], b->d[7]); + muladd(a->d[5], b->d[6]); + muladd(a->d[6], b->d[5]); + muladd(a->d[7], b->d[4]); + extract(l[11]); + muladd(a->d[5], b->d[7]); + muladd(a->d[6], b->d[6]); + muladd(a->d[7], b->d[5]); + extract(l[12]); + muladd(a->d[6], b->d[7]); + muladd(a->d[7], b->d[6]); + extract(l[13]); + muladd_fast(a->d[7], b->d[7]); + extract_fast(l[14]); + VERIFY_CHECK(c1 == 0); + l[15] = c0; +} + +static void secp256k1_scalar_sqr_512(uint32_t *l, const secp256k1_scalar *a) { + /* 96 bit accumulator. */ + uint32_t c0 = 0, c1 = 0, c2 = 0; + + /* l[0..15] = a[0..7]^2. */ + muladd_fast(a->d[0], a->d[0]); + extract_fast(l[0]); + muladd2(a->d[0], a->d[1]); + extract(l[1]); + muladd2(a->d[0], a->d[2]); + muladd(a->d[1], a->d[1]); + extract(l[2]); + muladd2(a->d[0], a->d[3]); + muladd2(a->d[1], a->d[2]); + extract(l[3]); + muladd2(a->d[0], a->d[4]); + muladd2(a->d[1], a->d[3]); + muladd(a->d[2], a->d[2]); + extract(l[4]); + muladd2(a->d[0], a->d[5]); + muladd2(a->d[1], a->d[4]); + muladd2(a->d[2], a->d[3]); + extract(l[5]); + muladd2(a->d[0], a->d[6]); + muladd2(a->d[1], a->d[5]); + muladd2(a->d[2], a->d[4]); + muladd(a->d[3], a->d[3]); + extract(l[6]); + muladd2(a->d[0], a->d[7]); + muladd2(a->d[1], a->d[6]); + muladd2(a->d[2], a->d[5]); + muladd2(a->d[3], a->d[4]); + extract(l[7]); + muladd2(a->d[1], a->d[7]); + muladd2(a->d[2], a->d[6]); + muladd2(a->d[3], a->d[5]); + muladd(a->d[4], a->d[4]); + extract(l[8]); + muladd2(a->d[2], a->d[7]); + muladd2(a->d[3], a->d[6]); + muladd2(a->d[4], a->d[5]); + extract(l[9]); + muladd2(a->d[3], a->d[7]); + muladd2(a->d[4], a->d[6]); + muladd(a->d[5], a->d[5]); + extract(l[10]); + muladd2(a->d[4], a->d[7]); + muladd2(a->d[5], a->d[6]); + extract(l[11]); + muladd2(a->d[5], a->d[7]); + muladd(a->d[6], a->d[6]); + extract(l[12]); + muladd2(a->d[6], a->d[7]); + extract(l[13]); + muladd_fast(a->d[7], a->d[7]); + extract_fast(l[14]); + VERIFY_CHECK(c1 == 0); + l[15] = c0; +} + +#undef sumadd +#undef sumadd_fast +#undef muladd +#undef muladd_fast +#undef muladd2 +#undef extract +#undef extract_fast + +static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b) { + uint32_t l[16]; + secp256k1_scalar_mul_512(l, a, b); + secp256k1_scalar_reduce_512(r, l); +} + +static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n) { + int ret; + VERIFY_CHECK(n > 0); + VERIFY_CHECK(n < 16); + ret = r->d[0] & ((1 << n) - 1); + r->d[0] = (r->d[0] >> n) + (r->d[1] << (32 - n)); + r->d[1] = (r->d[1] >> n) + (r->d[2] << (32 - n)); + r->d[2] = (r->d[2] >> n) + (r->d[3] << (32 - n)); + r->d[3] = (r->d[3] >> n) + (r->d[4] << (32 - n)); + r->d[4] = (r->d[4] >> n) + (r->d[5] << (32 - n)); + r->d[5] = (r->d[5] >> n) + (r->d[6] << (32 - n)); + r->d[6] = (r->d[6] >> n) + (r->d[7] << (32 - n)); + r->d[7] = (r->d[7] >> n); + return ret; +} + +static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a) { + uint32_t l[16]; + secp256k1_scalar_sqr_512(l, a); + secp256k1_scalar_reduce_512(r, l); +} + +#ifdef USE_ENDOMORPHISM +static void secp256k1_scalar_split_128(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + r1->d[0] = a->d[0]; + r1->d[1] = a->d[1]; + r1->d[2] = a->d[2]; + r1->d[3] = a->d[3]; + r1->d[4] = 0; + r1->d[5] = 0; + r1->d[6] = 0; + r1->d[7] = 0; + r2->d[0] = a->d[4]; + r2->d[1] = a->d[5]; + r2->d[2] = a->d[6]; + r2->d[3] = a->d[7]; + r2->d[4] = 0; + r2->d[5] = 0; + r2->d[6] = 0; + r2->d[7] = 0; +} +#endif + +SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b) { + return ((a->d[0] ^ b->d[0]) | (a->d[1] ^ b->d[1]) | (a->d[2] ^ b->d[2]) | (a->d[3] ^ b->d[3]) | (a->d[4] ^ b->d[4]) | (a->d[5] ^ b->d[5]) | (a->d[6] ^ b->d[6]) | (a->d[7] ^ b->d[7])) == 0; +} + +SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift) { + uint32_t l[16]; + unsigned int shiftlimbs; + unsigned int shiftlow; + unsigned int shifthigh; + VERIFY_CHECK(shift >= 256); + secp256k1_scalar_mul_512(l, a, b); + shiftlimbs = shift >> 5; + shiftlow = shift & 0x1F; + shifthigh = 32 - shiftlow; + r->d[0] = shift < 512 ? (l[0 + shiftlimbs] >> shiftlow | (shift < 480 && shiftlow ? (l[1 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[1] = shift < 480 ? (l[1 + shiftlimbs] >> shiftlow | (shift < 448 && shiftlow ? (l[2 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[2] = shift < 448 ? (l[2 + shiftlimbs] >> shiftlow | (shift < 416 && shiftlow ? (l[3 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[3] = shift < 416 ? (l[3 + shiftlimbs] >> shiftlow | (shift < 384 && shiftlow ? (l[4 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[4] = shift < 384 ? (l[4 + shiftlimbs] >> shiftlow | (shift < 352 && shiftlow ? (l[5 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[5] = shift < 352 ? (l[5 + shiftlimbs] >> shiftlow | (shift < 320 && shiftlow ? (l[6 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[6] = shift < 320 ? (l[6 + shiftlimbs] >> shiftlow | (shift < 288 && shiftlow ? (l[7 + shiftlimbs] << shifthigh) : 0)) : 0; + r->d[7] = shift < 288 ? (l[7 + shiftlimbs] >> shiftlow) : 0; + secp256k1_scalar_cadd_bit(r, 0, (l[(shift - 1) >> 5] >> ((shift - 1) & 0x1f)) & 1); +} + +#endif diff --git a/src/secp256k1/src/scalar_impl.h b/src/secp256k1/src/scalar_impl.h new file mode 100644 index 0000000..88ea97d --- /dev/null +++ b/src/secp256k1/src/scalar_impl.h @@ -0,0 +1,337 @@ +/********************************************************************** + * Copyright (c) 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_SCALAR_IMPL_H_ +#define _SECP256K1_SCALAR_IMPL_H_ + +#include + +#include "group.h" +#include "scalar.h" + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#if defined(USE_SCALAR_4X64) +#include "scalar_4x64_impl.h" +#elif defined(USE_SCALAR_8X32) +#include "scalar_8x32_impl.h" +#else +#error "Please select scalar implementation" +#endif + +#ifndef USE_NUM_NONE +static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a) { + unsigned char c[32]; + secp256k1_scalar_get_b32(c, a); + secp256k1_num_set_bin(r, c, 32); +} + +/** secp256k1 curve order, see secp256k1_ecdsa_const_order_as_fe in ecdsa_impl.h */ +static void secp256k1_scalar_order_get_num(secp256k1_num *r) { + static const unsigned char order[32] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B, + 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x41 + }; + secp256k1_num_set_bin(r, order, 32); +} +#endif + +static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *x) { + secp256k1_scalar *t; + int i; + /* First compute x ^ (2^N - 1) for some values of N. */ + secp256k1_scalar x2, x3, x4, x6, x7, x8, x15, x30, x60, x120, x127; + + secp256k1_scalar_sqr(&x2, x); + secp256k1_scalar_mul(&x2, &x2, x); + + secp256k1_scalar_sqr(&x3, &x2); + secp256k1_scalar_mul(&x3, &x3, x); + + secp256k1_scalar_sqr(&x4, &x3); + secp256k1_scalar_mul(&x4, &x4, x); + + secp256k1_scalar_sqr(&x6, &x4); + secp256k1_scalar_sqr(&x6, &x6); + secp256k1_scalar_mul(&x6, &x6, &x2); + + secp256k1_scalar_sqr(&x7, &x6); + secp256k1_scalar_mul(&x7, &x7, x); + + secp256k1_scalar_sqr(&x8, &x7); + secp256k1_scalar_mul(&x8, &x8, x); + + secp256k1_scalar_sqr(&x15, &x8); + for (i = 0; i < 6; i++) { + secp256k1_scalar_sqr(&x15, &x15); + } + secp256k1_scalar_mul(&x15, &x15, &x7); + + secp256k1_scalar_sqr(&x30, &x15); + for (i = 0; i < 14; i++) { + secp256k1_scalar_sqr(&x30, &x30); + } + secp256k1_scalar_mul(&x30, &x30, &x15); + + secp256k1_scalar_sqr(&x60, &x30); + for (i = 0; i < 29; i++) { + secp256k1_scalar_sqr(&x60, &x60); + } + secp256k1_scalar_mul(&x60, &x60, &x30); + + secp256k1_scalar_sqr(&x120, &x60); + for (i = 0; i < 59; i++) { + secp256k1_scalar_sqr(&x120, &x120); + } + secp256k1_scalar_mul(&x120, &x120, &x60); + + secp256k1_scalar_sqr(&x127, &x120); + for (i = 0; i < 6; i++) { + secp256k1_scalar_sqr(&x127, &x127); + } + secp256k1_scalar_mul(&x127, &x127, &x7); + + /* Then accumulate the final result (t starts at x127). */ + t = &x127; + for (i = 0; i < 2; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 2; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 2; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 2; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 3; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x2); /* 11 */ + for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 5; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 4; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x2); /* 11 */ + for (i = 0; i < 2; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 2; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 5; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x4); /* 1111 */ + for (i = 0; i < 2; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 3; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 4; i++) { /* 000 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 2; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 10; i++) { /* 0000000 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 4; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x3); /* 111 */ + for (i = 0; i < 9; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x8); /* 11111111 */ + for (i = 0; i < 2; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 3; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 3; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 5; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x4); /* 1111 */ + for (i = 0; i < 2; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 5; i++) { /* 000 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x2); /* 11 */ + for (i = 0; i < 4; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x2); /* 11 */ + for (i = 0; i < 2; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 8; i++) { /* 000000 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x2); /* 11 */ + for (i = 0; i < 3; i++) { /* 0 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, &x2); /* 11 */ + for (i = 0; i < 3; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 6; i++) { /* 00000 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(t, t, x); /* 1 */ + for (i = 0; i < 8; i++) { /* 00 */ + secp256k1_scalar_sqr(t, t); + } + secp256k1_scalar_mul(r, t, &x6); /* 111111 */ +} + +SECP256K1_INLINE static int secp256k1_scalar_is_even(const secp256k1_scalar *a) { + /* d[0] is present and is the lowest word for all representations */ + return !(a->d[0] & 1); +} + +static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *x) { +#if defined(USE_SCALAR_INV_BUILTIN) + secp256k1_scalar_inverse(r, x); +#elif defined(USE_SCALAR_INV_NUM) + unsigned char b[32]; + secp256k1_num n, m; + secp256k1_scalar t = *x; + secp256k1_scalar_get_b32(b, &t); + secp256k1_num_set_bin(&n, b, 32); + secp256k1_scalar_order_get_num(&m); + secp256k1_num_mod_inverse(&n, &n, &m); + secp256k1_num_get_bin(b, 32, &n); + secp256k1_scalar_set_b32(r, b, NULL); + /* Verify that the inverse was computed correctly, without GMP code. */ + secp256k1_scalar_mul(&t, &t, r); + CHECK(secp256k1_scalar_is_one(&t)); +#else +#error "Please select scalar inverse implementation" +#endif +} + +#ifdef USE_ENDOMORPHISM +/** + * The Secp256k1 curve has an endomorphism, where lambda * (x, y) = (beta * x, y), where + * lambda is {0x53,0x63,0xad,0x4c,0xc0,0x5c,0x30,0xe0,0xa5,0x26,0x1c,0x02,0x88,0x12,0x64,0x5a, + * 0x12,0x2e,0x22,0xea,0x20,0x81,0x66,0x78,0xdf,0x02,0x96,0x7c,0x1b,0x23,0xbd,0x72} + * + * "Guide to Elliptic Curve Cryptography" (Hankerson, Menezes, Vanstone) gives an algorithm + * (algorithm 3.74) to find k1 and k2 given k, such that k1 + k2 * lambda == k mod n, and k1 + * and k2 have a small size. + * It relies on constants a1, b1, a2, b2. These constants for the value of lambda above are: + * + * - a1 = {0x30,0x86,0xd2,0x21,0xa7,0xd4,0x6b,0xcd,0xe8,0x6c,0x90,0xe4,0x92,0x84,0xeb,0x15} + * - b1 = -{0xe4,0x43,0x7e,0xd6,0x01,0x0e,0x88,0x28,0x6f,0x54,0x7f,0xa9,0x0a,0xbf,0xe4,0xc3} + * - a2 = {0x01,0x14,0xca,0x50,0xf7,0xa8,0xe2,0xf3,0xf6,0x57,0xc1,0x10,0x8d,0x9d,0x44,0xcf,0xd8} + * - b2 = {0x30,0x86,0xd2,0x21,0xa7,0xd4,0x6b,0xcd,0xe8,0x6c,0x90,0xe4,0x92,0x84,0xeb,0x15} + * + * The algorithm then computes c1 = round(b1 * k / n) and c2 = round(b2 * k / n), and gives + * k1 = k - (c1*a1 + c2*a2) and k2 = -(c1*b1 + c2*b2). Instead, we use modular arithmetic, and + * compute k1 as k - k2 * lambda, avoiding the need for constants a1 and a2. + * + * g1, g2 are precomputed constants used to replace division with a rounded multiplication + * when decomposing the scalar for an endomorphism-based point multiplication. + * + * The possibility of using precomputed estimates is mentioned in "Guide to Elliptic Curve + * Cryptography" (Hankerson, Menezes, Vanstone) in section 3.5. + * + * The derivation is described in the paper "Efficient Software Implementation of Public-Key + * Cryptography on Sensor Networks Using the MSP430X Microcontroller" (Gouvea, Oliveira, Lopez), + * Section 4.3 (here we use a somewhat higher-precision estimate): + * d = a1*b2 - b1*a2 + * g1 = round((2^272)*b2/d) + * g2 = round((2^272)*b1/d) + * + * (Note that 'd' is also equal to the curve order here because [a1,b1] and [a2,b2] are found + * as outputs of the Extended Euclidean Algorithm on inputs 'order' and 'lambda'). + * + * The function below splits a in r1 and r2, such that r1 + lambda * r2 == a (mod order). + */ + +static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *a) { + secp256k1_scalar c1, c2; + static const secp256k1_scalar minus_lambda = SECP256K1_SCALAR_CONST( + 0xAC9C52B3UL, 0x3FA3CF1FUL, 0x5AD9E3FDUL, 0x77ED9BA4UL, + 0xA880B9FCUL, 0x8EC739C2UL, 0xE0CFC810UL, 0xB51283CFUL + ); + static const secp256k1_scalar minus_b1 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0xE4437ED6UL, 0x010E8828UL, 0x6F547FA9UL, 0x0ABFE4C3UL + ); + static const secp256k1_scalar minus_b2 = SECP256K1_SCALAR_CONST( + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFEUL, + 0x8A280AC5UL, 0x0774346DUL, 0xD765CDA8UL, 0x3DB1562CUL + ); + static const secp256k1_scalar g1 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00003086UL, + 0xD221A7D4UL, 0x6BCDE86CUL, 0x90E49284UL, 0xEB153DABUL + ); + static const secp256k1_scalar g2 = SECP256K1_SCALAR_CONST( + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0000E443UL, + 0x7ED6010EUL, 0x88286F54UL, 0x7FA90ABFUL, 0xE4C42212UL + ); + VERIFY_CHECK(r1 != a); + VERIFY_CHECK(r2 != a); + /* these _var calls are constant time since the shift amount is constant */ + secp256k1_scalar_mul_shift_var(&c1, a, &g1, 272); + secp256k1_scalar_mul_shift_var(&c2, a, &g2, 272); + secp256k1_scalar_mul(&c1, &c1, &minus_b1); + secp256k1_scalar_mul(&c2, &c2, &minus_b2); + secp256k1_scalar_add(r2, &c1, &c2); + secp256k1_scalar_mul(r1, r2, &minus_lambda); + secp256k1_scalar_add(r1, r1, a); +} +#endif + +#endif diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c new file mode 100644 index 0000000..62d192b --- /dev/null +++ b/src/secp256k1/src/secp256k1.c @@ -0,0 +1,568 @@ +/********************************************************************** + * Copyright (c) 2013-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#define SECP256K1_BUILD (1) + +#include "include/secp256k1.h" + +#include "util.h" +#include "num_impl.h" +#include "field_impl.h" +#include "scalar_impl.h" +#include "group_impl.h" +#include "ecmult_impl.h" +#include "ecmult_const_impl.h" +#include "ecmult_gen_impl.h" +#include "ecdsa_impl.h" +#include "eckey_impl.h" +#include "hash_impl.h" + +#define ARG_CHECK(cond) do { \ + if (EXPECT(!(cond), 0)) { \ + secp256k1_callback_call(&ctx->illegal_callback, #cond); \ + return 0; \ + } \ +} while(0) + +static void default_illegal_callback_fn(const char* str, void* data) { + (void)data; + fprintf(stderr, "[libsecp256k1] illegal argument: %s\n", str); + abort(); +} + +static const secp256k1_callback default_illegal_callback = { + default_illegal_callback_fn, + NULL +}; + +static void default_error_callback_fn(const char* str, void* data) { + (void)data; + fprintf(stderr, "[libsecp256k1] internal consistency check failed: %s\n", str); + abort(); +} + +static const secp256k1_callback default_error_callback = { + default_error_callback_fn, + NULL +}; + + +struct secp256k1_context_struct { + secp256k1_ecmult_context ecmult_ctx; + secp256k1_ecmult_gen_context ecmult_gen_ctx; + secp256k1_callback illegal_callback; + secp256k1_callback error_callback; +}; + +secp256k1_context* secp256k1_context_create(unsigned int flags) { + secp256k1_context* ret = (secp256k1_context*)checked_malloc(&default_error_callback, sizeof(secp256k1_context)); + ret->illegal_callback = default_illegal_callback; + ret->error_callback = default_error_callback; + + if (EXPECT((flags & SECP256K1_FLAGS_TYPE_MASK) != SECP256K1_FLAGS_TYPE_CONTEXT, 0)) { + secp256k1_callback_call(&ret->illegal_callback, + "Invalid flags"); + free(ret); + return NULL; + } + + secp256k1_ecmult_context_init(&ret->ecmult_ctx); + secp256k1_ecmult_gen_context_init(&ret->ecmult_gen_ctx); + + if (flags & SECP256K1_FLAGS_BIT_CONTEXT_SIGN) { + secp256k1_ecmult_gen_context_build(&ret->ecmult_gen_ctx, &ret->error_callback); + } + if (flags & SECP256K1_FLAGS_BIT_CONTEXT_VERIFY) { + secp256k1_ecmult_context_build(&ret->ecmult_ctx, &ret->error_callback); + } + + return ret; +} + +secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) { + secp256k1_context* ret = (secp256k1_context*)checked_malloc(&ctx->error_callback, sizeof(secp256k1_context)); + ret->illegal_callback = ctx->illegal_callback; + ret->error_callback = ctx->error_callback; + secp256k1_ecmult_context_clone(&ret->ecmult_ctx, &ctx->ecmult_ctx, &ctx->error_callback); + secp256k1_ecmult_gen_context_clone(&ret->ecmult_gen_ctx, &ctx->ecmult_gen_ctx, &ctx->error_callback); + return ret; +} + +void secp256k1_context_destroy(secp256k1_context* ctx) { + if (ctx != NULL) { + secp256k1_ecmult_context_clear(&ctx->ecmult_ctx); + secp256k1_ecmult_gen_context_clear(&ctx->ecmult_gen_ctx); + + free(ctx); + } +} + +void secp256k1_context_set_illegal_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) { + if (fun == NULL) { + fun = default_illegal_callback_fn; + } + ctx->illegal_callback.fn = fun; + ctx->illegal_callback.data = data; +} + +void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) { + if (fun == NULL) { + fun = default_error_callback_fn; + } + ctx->error_callback.fn = fun; + ctx->error_callback.data = data; +} + +static int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) { + if (sizeof(secp256k1_ge_storage) == 64) { + /* When the secp256k1_ge_storage type is exactly 64 byte, use its + * representation inside secp256k1_pubkey, as conversion is very fast. + * Note that secp256k1_pubkey_save must use the same representation. */ + secp256k1_ge_storage s; + memcpy(&s, &pubkey->data[0], 64); + secp256k1_ge_from_storage(ge, &s); + } else { + /* Otherwise, fall back to 32-byte big endian for X and Y. */ + secp256k1_fe x, y; + secp256k1_fe_set_b32(&x, pubkey->data); + secp256k1_fe_set_b32(&y, pubkey->data + 32); + secp256k1_ge_set_xy(ge, &x, &y); + } + ARG_CHECK(!secp256k1_fe_is_zero(&ge->x)); + return 1; +} + +static void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge) { + if (sizeof(secp256k1_ge_storage) == 64) { + secp256k1_ge_storage s; + secp256k1_ge_to_storage(&s, ge); + memcpy(&pubkey->data[0], &s, 64); + } else { + VERIFY_CHECK(!secp256k1_ge_is_infinity(ge)); + secp256k1_fe_normalize_var(&ge->x); + secp256k1_fe_normalize_var(&ge->y); + secp256k1_fe_get_b32(pubkey->data, &ge->x); + secp256k1_fe_get_b32(pubkey->data + 32, &ge->y); + } +} + +int secp256k1_ec_pubkey_parse(const secp256k1_context* ctx, secp256k1_pubkey* pubkey, const unsigned char *input, size_t inputlen) { + secp256k1_ge Q; + + (void)ctx; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(pubkey != NULL); + memset(pubkey, 0, sizeof(*pubkey)); + ARG_CHECK(input != NULL); + if (!secp256k1_eckey_pubkey_parse(&Q, input, inputlen)) { + return 0; + } + secp256k1_pubkey_save(pubkey, &Q); + secp256k1_ge_clear(&Q); + return 1; +} + +int secp256k1_ec_pubkey_serialize(const secp256k1_context* ctx, unsigned char *output, size_t *outputlen, const secp256k1_pubkey* pubkey, unsigned int flags) { + secp256k1_ge Q; + size_t len; + int ret = 0; + + (void)ctx; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(outputlen != NULL); + ARG_CHECK(*outputlen >= ((flags & SECP256K1_FLAGS_BIT_COMPRESSION) ? 33 : 65)); + len = *outputlen; + *outputlen = 0; + ARG_CHECK(output != NULL); + memset(output, 0, len); + ARG_CHECK(pubkey != NULL); + ARG_CHECK((flags & SECP256K1_FLAGS_TYPE_MASK) == SECP256K1_FLAGS_TYPE_COMPRESSION); + if (secp256k1_pubkey_load(ctx, &Q, pubkey)) { + ret = secp256k1_eckey_pubkey_serialize(&Q, output, &len, flags & SECP256K1_FLAGS_BIT_COMPRESSION); + if (ret) { + *outputlen = len; + } + } + return ret; +} + +static void secp256k1_ecdsa_signature_load(const secp256k1_context* ctx, secp256k1_scalar* r, secp256k1_scalar* s, const secp256k1_ecdsa_signature* sig) { + (void)ctx; + if (sizeof(secp256k1_scalar) == 32) { + /* When the secp256k1_scalar type is exactly 32 byte, use its + * representation inside secp256k1_ecdsa_signature, as conversion is very fast. + * Note that secp256k1_ecdsa_signature_save must use the same representation. */ + memcpy(r, &sig->data[0], 32); + memcpy(s, &sig->data[32], 32); + } else { + secp256k1_scalar_set_b32(r, &sig->data[0], NULL); + secp256k1_scalar_set_b32(s, &sig->data[32], NULL); + } +} + +static void secp256k1_ecdsa_signature_save(secp256k1_ecdsa_signature* sig, const secp256k1_scalar* r, const secp256k1_scalar* s) { + if (sizeof(secp256k1_scalar) == 32) { + memcpy(&sig->data[0], r, 32); + memcpy(&sig->data[32], s, 32); + } else { + secp256k1_scalar_get_b32(&sig->data[0], r); + secp256k1_scalar_get_b32(&sig->data[32], s); + } +} + +int secp256k1_ecdsa_signature_parse_der(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char *input, size_t inputlen) { + secp256k1_scalar r, s; + + (void)ctx; + ARG_CHECK(sig != NULL); + ARG_CHECK(input != NULL); + + if (secp256k1_ecdsa_sig_parse(&r, &s, input, inputlen)) { + secp256k1_ecdsa_signature_save(sig, &r, &s); + return 1; + } else { + memset(sig, 0, sizeof(*sig)); + return 0; + } +} + +int secp256k1_ecdsa_signature_parse_compact(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char *input64) { + secp256k1_scalar r, s; + int ret = 1; + int overflow = 0; + + (void)ctx; + ARG_CHECK(sig != NULL); + ARG_CHECK(input64 != NULL); + + secp256k1_scalar_set_b32(&r, &input64[0], &overflow); + ret &= !overflow; + secp256k1_scalar_set_b32(&s, &input64[32], &overflow); + ret &= !overflow; + if (ret) { + secp256k1_ecdsa_signature_save(sig, &r, &s); + } else { + memset(sig, 0, sizeof(*sig)); + } + return ret; +} + +int secp256k1_ecdsa_signature_serialize_der(const secp256k1_context* ctx, unsigned char *output, size_t *outputlen, const secp256k1_ecdsa_signature* sig) { + secp256k1_scalar r, s; + + (void)ctx; + ARG_CHECK(output != NULL); + ARG_CHECK(outputlen != NULL); + ARG_CHECK(sig != NULL); + + secp256k1_ecdsa_signature_load(ctx, &r, &s, sig); + return secp256k1_ecdsa_sig_serialize(output, outputlen, &r, &s); +} + +int secp256k1_ecdsa_signature_serialize_compact(const secp256k1_context* ctx, unsigned char *output64, const secp256k1_ecdsa_signature* sig) { + secp256k1_scalar r, s; + + (void)ctx; + ARG_CHECK(output64 != NULL); + ARG_CHECK(sig != NULL); + + secp256k1_ecdsa_signature_load(ctx, &r, &s, sig); + secp256k1_scalar_get_b32(&output64[0], &r); + secp256k1_scalar_get_b32(&output64[32], &s); + return 1; +} + +int secp256k1_ecdsa_signature_normalize(const secp256k1_context* ctx, secp256k1_ecdsa_signature *sigout, const secp256k1_ecdsa_signature *sigin) { + secp256k1_scalar r, s; + int ret = 0; + + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(sigin != NULL); + + secp256k1_ecdsa_signature_load(ctx, &r, &s, sigin); + ret = secp256k1_scalar_is_high(&s); + if (sigout != NULL) { + if (ret) { + secp256k1_scalar_negate(&s, &s); + } + secp256k1_ecdsa_signature_save(sigout, &r, &s); + } + + return ret; +} + +int secp256k1_ecdsa_verify(const secp256k1_context* ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msg32, const secp256k1_pubkey *pubkey) { + secp256k1_ge q; + secp256k1_scalar r, s; + secp256k1_scalar m; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(sig != NULL); + ARG_CHECK(pubkey != NULL); + + secp256k1_scalar_set_b32(&m, msg32, NULL); + secp256k1_ecdsa_signature_load(ctx, &r, &s, sig); + return (!secp256k1_scalar_is_high(&s) && + secp256k1_pubkey_load(ctx, &q, pubkey) && + secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &r, &s, &q, &m)); +} + +static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { + unsigned char keydata[112]; + int keylen = 64; + secp256k1_rfc6979_hmac_sha256_t rng; + unsigned int i; + /* We feed a byte array to the PRNG as input, consisting of: + * - the private key (32 bytes) and message (32 bytes), see RFC 6979 3.2d. + * - optionally 32 extra bytes of data, see RFC 6979 3.6 Additional Data. + * - optionally 16 extra bytes with the algorithm name. + * Because the arguments have distinct fixed lengths it is not possible for + * different argument mixtures to emulate each other and result in the same + * nonces. + */ + memcpy(keydata, key32, 32); + memcpy(keydata + 32, msg32, 32); + if (data != NULL) { + memcpy(keydata + 64, data, 32); + keylen = 96; + } + if (algo16 != NULL) { + memcpy(keydata + keylen, algo16, 16); + keylen += 16; + } + secp256k1_rfc6979_hmac_sha256_initialize(&rng, keydata, keylen); + memset(keydata, 0, sizeof(keydata)); + for (i = 0; i <= counter; i++) { + secp256k1_rfc6979_hmac_sha256_generate(&rng, nonce32, 32); + } + secp256k1_rfc6979_hmac_sha256_finalize(&rng); + return 1; +} + +const secp256k1_nonce_function secp256k1_nonce_function_rfc6979 = nonce_function_rfc6979; +const secp256k1_nonce_function secp256k1_nonce_function_default = nonce_function_rfc6979; + +int secp256k1_ecdsa_sign(const secp256k1_context* ctx, secp256k1_ecdsa_signature *signature, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void* noncedata) { + secp256k1_scalar r, s; + secp256k1_scalar sec, non, msg; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + ARG_CHECK(msg32 != NULL); + ARG_CHECK(signature != NULL); + ARG_CHECK(seckey != NULL); + if (noncefp == NULL) { + noncefp = secp256k1_nonce_function_default; + } + + secp256k1_scalar_set_b32(&sec, seckey, &overflow); + /* Fail if the secret key is invalid. */ + if (!overflow && !secp256k1_scalar_is_zero(&sec)) { + unsigned int count = 0; + secp256k1_scalar_set_b32(&msg, msg32, NULL); + while (1) { + unsigned char nonce32[32]; + ret = noncefp(nonce32, msg32, seckey, NULL, (void*)noncedata, count); + if (!ret) { + break; + } + secp256k1_scalar_set_b32(&non, nonce32, &overflow); + memset(nonce32, 0, 32); + if (!overflow && !secp256k1_scalar_is_zero(&non)) { + if (secp256k1_ecdsa_sig_sign(&ctx->ecmult_gen_ctx, &r, &s, &sec, &msg, &non, NULL)) { + break; + } + } + count++; + } + secp256k1_scalar_clear(&msg); + secp256k1_scalar_clear(&non); + secp256k1_scalar_clear(&sec); + } + if (ret) { + secp256k1_ecdsa_signature_save(signature, &r, &s); + } else { + memset(signature, 0, sizeof(*signature)); + } + return ret; +} + +int secp256k1_ec_seckey_verify(const secp256k1_context* ctx, const unsigned char *seckey) { + secp256k1_scalar sec; + int ret; + int overflow; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(seckey != NULL); + (void)ctx; + + secp256k1_scalar_set_b32(&sec, seckey, &overflow); + ret = !overflow && !secp256k1_scalar_is_zero(&sec); + secp256k1_scalar_clear(&sec); + return ret; +} + +int secp256k1_ec_pubkey_create(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *seckey) { + secp256k1_gej pj; + secp256k1_ge p; + secp256k1_scalar sec; + int overflow; + int ret = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(pubkey != NULL); + memset(pubkey, 0, sizeof(*pubkey)); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + ARG_CHECK(seckey != NULL); + + secp256k1_scalar_set_b32(&sec, seckey, &overflow); + ret = (!overflow) & (!secp256k1_scalar_is_zero(&sec)); + if (ret) { + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &pj, &sec); + secp256k1_ge_set_gej(&p, &pj); + secp256k1_pubkey_save(pubkey, &p); + } + secp256k1_scalar_clear(&sec); + return ret; +} + +int secp256k1_ec_privkey_tweak_add(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak) { + secp256k1_scalar term; + secp256k1_scalar sec; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(seckey != NULL); + ARG_CHECK(tweak != NULL); + (void)ctx; + + secp256k1_scalar_set_b32(&term, tweak, &overflow); + secp256k1_scalar_set_b32(&sec, seckey, NULL); + + ret = !overflow && secp256k1_eckey_privkey_tweak_add(&sec, &term); + memset(seckey, 0, 32); + if (ret) { + secp256k1_scalar_get_b32(seckey, &sec); + } + + secp256k1_scalar_clear(&sec); + secp256k1_scalar_clear(&term); + return ret; +} + +int secp256k1_ec_pubkey_tweak_add(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak) { + secp256k1_ge p; + secp256k1_scalar term; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(pubkey != NULL); + ARG_CHECK(tweak != NULL); + + secp256k1_scalar_set_b32(&term, tweak, &overflow); + ret = !overflow && secp256k1_pubkey_load(ctx, &p, pubkey); + memset(pubkey, 0, sizeof(*pubkey)); + if (ret) { + if (secp256k1_eckey_pubkey_tweak_add(&ctx->ecmult_ctx, &p, &term)) { + secp256k1_pubkey_save(pubkey, &p); + } else { + ret = 0; + } + } + + return ret; +} + +int secp256k1_ec_privkey_tweak_mul(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak) { + secp256k1_scalar factor; + secp256k1_scalar sec; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(seckey != NULL); + ARG_CHECK(tweak != NULL); + (void)ctx; + + secp256k1_scalar_set_b32(&factor, tweak, &overflow); + secp256k1_scalar_set_b32(&sec, seckey, NULL); + ret = !overflow && secp256k1_eckey_privkey_tweak_mul(&sec, &factor); + memset(seckey, 0, 32); + if (ret) { + secp256k1_scalar_get_b32(seckey, &sec); + } + + secp256k1_scalar_clear(&sec); + secp256k1_scalar_clear(&factor); + return ret; +} + +int secp256k1_ec_pubkey_tweak_mul(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak) { + secp256k1_ge p; + secp256k1_scalar factor; + int ret = 0; + int overflow = 0; + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_context_is_built(&ctx->ecmult_ctx)); + ARG_CHECK(pubkey != NULL); + ARG_CHECK(tweak != NULL); + + secp256k1_scalar_set_b32(&factor, tweak, &overflow); + ret = !overflow && secp256k1_pubkey_load(ctx, &p, pubkey); + memset(pubkey, 0, sizeof(*pubkey)); + if (ret) { + if (secp256k1_eckey_pubkey_tweak_mul(&ctx->ecmult_ctx, &p, &factor)) { + secp256k1_pubkey_save(pubkey, &p); + } else { + ret = 0; + } + } + + return ret; +} + +int secp256k1_context_randomize(secp256k1_context* ctx, const unsigned char *seed32) { + VERIFY_CHECK(ctx != NULL); + ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)); + secp256k1_ecmult_gen_blind(&ctx->ecmult_gen_ctx, seed32); + return 1; +} + +int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *pubnonce, const secp256k1_pubkey * const *pubnonces, size_t n) { + size_t i; + secp256k1_gej Qj; + secp256k1_ge Q; + + ARG_CHECK(pubnonce != NULL); + memset(pubnonce, 0, sizeof(*pubnonce)); + ARG_CHECK(n >= 1); + ARG_CHECK(pubnonces != NULL); + + secp256k1_gej_set_infinity(&Qj); + + for (i = 0; i < n; i++) { + secp256k1_pubkey_load(ctx, &Q, pubnonces[i]); + secp256k1_gej_add_ge(&Qj, &Qj, &Q); + } + if (secp256k1_gej_is_infinity(&Qj)) { + return 0; + } + secp256k1_ge_set_gej(&Q, &Qj); + secp256k1_pubkey_save(pubnonce, &Q); + return 1; +} + +#ifdef ENABLE_MODULE_ECDH +# include "modules/ecdh/main_impl.h" +#endif + +#ifdef ENABLE_MODULE_SCHNORR +# include "modules/schnorr/main_impl.h" +#endif + +#ifdef ENABLE_MODULE_RECOVERY +# include "modules/recovery/main_impl.h" +#endif diff --git a/src/secp256k1/src/testrand.h b/src/secp256k1/src/testrand.h new file mode 100644 index 0000000..f8efa93 --- /dev/null +++ b/src/secp256k1/src/testrand.h @@ -0,0 +1,38 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_TESTRAND_H_ +#define _SECP256K1_TESTRAND_H_ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +/* A non-cryptographic RNG used only for test infrastructure. */ + +/** Seed the pseudorandom number generator for testing. */ +SECP256K1_INLINE static void secp256k1_rand_seed(const unsigned char *seed16); + +/** Generate a pseudorandom number in the range [0..2**32-1]. */ +static uint32_t secp256k1_rand32(void); + +/** Generate a pseudorandom number in the range [0..2**bits-1]. Bits must be 1 or + * more. */ +static uint32_t secp256k1_rand_bits(int bits); + +/** Generate a pseudorandom number in the range [0..range-1]. */ +static uint32_t secp256k1_rand_int(uint32_t range); + +/** Generate a pseudorandom 32-byte array. */ +static void secp256k1_rand256(unsigned char *b32); + +/** Generate a pseudorandom 32-byte array with long sequences of zero and one bits. */ +static void secp256k1_rand256_test(unsigned char *b32); + +/** Generate pseudorandom bytes with long sequences of zero and one bits. */ +static void secp256k1_rand_bytes_test(unsigned char *bytes, size_t len); + +#endif diff --git a/src/secp256k1/src/testrand_impl.h b/src/secp256k1/src/testrand_impl.h new file mode 100644 index 0000000..15c7b9f --- /dev/null +++ b/src/secp256k1/src/testrand_impl.h @@ -0,0 +1,110 @@ +/********************************************************************** + * Copyright (c) 2013-2015 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_TESTRAND_IMPL_H_ +#define _SECP256K1_TESTRAND_IMPL_H_ + +#include +#include + +#include "testrand.h" +#include "hash.h" + +static secp256k1_rfc6979_hmac_sha256_t secp256k1_test_rng; +static uint32_t secp256k1_test_rng_precomputed[8]; +static int secp256k1_test_rng_precomputed_used = 8; +static uint64_t secp256k1_test_rng_integer; +static int secp256k1_test_rng_integer_bits_left = 0; + +SECP256K1_INLINE static void secp256k1_rand_seed(const unsigned char *seed16) { + secp256k1_rfc6979_hmac_sha256_initialize(&secp256k1_test_rng, seed16, 16); +} + +SECP256K1_INLINE static uint32_t secp256k1_rand32(void) { + if (secp256k1_test_rng_precomputed_used == 8) { + secp256k1_rfc6979_hmac_sha256_generate(&secp256k1_test_rng, (unsigned char*)(&secp256k1_test_rng_precomputed[0]), sizeof(secp256k1_test_rng_precomputed)); + secp256k1_test_rng_precomputed_used = 0; + } + return secp256k1_test_rng_precomputed[secp256k1_test_rng_precomputed_used++]; +} + +static uint32_t secp256k1_rand_bits(int bits) { + uint32_t ret; + if (secp256k1_test_rng_integer_bits_left < bits) { + secp256k1_test_rng_integer |= (((uint64_t)secp256k1_rand32()) << secp256k1_test_rng_integer_bits_left); + secp256k1_test_rng_integer_bits_left += 32; + } + ret = secp256k1_test_rng_integer; + secp256k1_test_rng_integer >>= bits; + secp256k1_test_rng_integer_bits_left -= bits; + ret &= ((~((uint32_t)0)) >> (32 - bits)); + return ret; +} + +static uint32_t secp256k1_rand_int(uint32_t range) { + /* We want a uniform integer between 0 and range-1, inclusive. + * B is the smallest number such that range <= 2**B. + * two mechanisms implemented here: + * - generate B bits numbers until one below range is found, and return it + * - find the largest multiple M of range that is <= 2**(B+A), generate B+A + * bits numbers until one below M is found, and return it modulo range + * The second mechanism consumes A more bits of entropy in every iteration, + * but may need fewer iterations due to M being closer to 2**(B+A) then + * range is to 2**B. The array below (indexed by B) contains a 0 when the + * first mechanism is to be used, and the number A otherwise. + */ + static const int addbits[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0}; + uint32_t trange, mult; + int bits = 0; + if (range <= 1) { + return 0; + } + trange = range - 1; + while (trange > 0) { + trange >>= 1; + bits++; + } + if (addbits[bits]) { + bits = bits + addbits[bits]; + mult = ((~((uint32_t)0)) >> (32 - bits)) / range; + trange = range * mult; + } else { + trange = range; + mult = 1; + } + while(1) { + uint32_t x = secp256k1_rand_bits(bits); + if (x < trange) { + return (mult == 1) ? x : (x % range); + } + } +} + +static void secp256k1_rand256(unsigned char *b32) { + secp256k1_rfc6979_hmac_sha256_generate(&secp256k1_test_rng, b32, 32); +} + +static void secp256k1_rand_bytes_test(unsigned char *bytes, size_t len) { + size_t bits = 0; + memset(bytes, 0, len); + while (bits < len * 8) { + int now; + uint32_t val; + now = 1 + (secp256k1_rand_bits(6) * secp256k1_rand_bits(5) + 16) / 31; + val = secp256k1_rand_bits(1); + while (now > 0 && bits < len * 8) { + bytes[bits / 8] |= val << (bits % 8); + now--; + bits++; + } + } +} + +static void secp256k1_rand256_test(unsigned char *b32) { + secp256k1_rand_bytes_test(b32, 32); +} + +#endif diff --git a/src/secp256k1/src/tests.c b/src/secp256k1/src/tests.c new file mode 100644 index 0000000..3abfe12 --- /dev/null +++ b/src/secp256k1/src/tests.c @@ -0,0 +1,4384 @@ +/********************************************************************** + * Copyright (c) 2013, 2014, 2015 Pieter Wuille, Gregory Maxwell * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#include +#include + +#include + +#include "secp256k1.c" +#include "include/secp256k1.h" +#include "testrand_impl.h" + +#ifdef ENABLE_OPENSSL_TESTS +#include "openssl/bn.h" +#include "openssl/ec.h" +#include "openssl/ecdsa.h" +#include "openssl/obj_mac.h" +#endif + +#include "contrib/lax_der_parsing.c" +#include "contrib/lax_der_privatekey_parsing.c" + +#if !defined(VG_CHECK) +# if defined(VALGRIND) +# include +# define VG_UNDEF(x,y) VALGRIND_MAKE_MEM_UNDEFINED((x),(y)) +# define VG_CHECK(x,y) VALGRIND_CHECK_MEM_IS_DEFINED((x),(y)) +# else +# define VG_UNDEF(x,y) +# define VG_CHECK(x,y) +# endif +#endif + +static int count = 64; +static secp256k1_context *ctx = NULL; + +static void counting_illegal_callback_fn(const char* str, void* data) { + /* Dummy callback function that just counts. */ + int32_t *p; + (void)str; + p = data; + (*p)++; +} + +static void uncounting_illegal_callback_fn(const char* str, void* data) { + /* Dummy callback function that just counts (backwards). */ + int32_t *p; + (void)str; + p = data; + (*p)--; +} + +void random_field_element_test(secp256k1_fe *fe) { + do { + unsigned char b32[32]; + secp256k1_rand256_test(b32); + if (secp256k1_fe_set_b32(fe, b32)) { + break; + } + } while(1); +} + +void random_field_element_magnitude(secp256k1_fe *fe) { + secp256k1_fe zero; + int n = secp256k1_rand_int(9); + secp256k1_fe_normalize(fe); + if (n == 0) { + return; + } + secp256k1_fe_clear(&zero); + secp256k1_fe_negate(&zero, &zero, 0); + secp256k1_fe_mul_int(&zero, n - 1); + secp256k1_fe_add(fe, &zero); + VERIFY_CHECK(fe->magnitude == n); +} + +void random_group_element_test(secp256k1_ge *ge) { + secp256k1_fe fe; + do { + random_field_element_test(&fe); + if (secp256k1_ge_set_xo_var(ge, &fe, secp256k1_rand_bits(1))) { + secp256k1_fe_normalize(&ge->y); + break; + } + } while(1); +} + +void random_group_element_jacobian_test(secp256k1_gej *gej, const secp256k1_ge *ge) { + secp256k1_fe z2, z3; + do { + random_field_element_test(&gej->z); + if (!secp256k1_fe_is_zero(&gej->z)) { + break; + } + } while(1); + secp256k1_fe_sqr(&z2, &gej->z); + secp256k1_fe_mul(&z3, &z2, &gej->z); + secp256k1_fe_mul(&gej->x, &ge->x, &z2); + secp256k1_fe_mul(&gej->y, &ge->y, &z3); + gej->infinity = ge->infinity; +} + +void random_scalar_order_test(secp256k1_scalar *num) { + do { + unsigned char b32[32]; + int overflow = 0; + secp256k1_rand256_test(b32); + secp256k1_scalar_set_b32(num, b32, &overflow); + if (overflow || secp256k1_scalar_is_zero(num)) { + continue; + } + break; + } while(1); +} + +void random_scalar_order(secp256k1_scalar *num) { + do { + unsigned char b32[32]; + int overflow = 0; + secp256k1_rand256(b32); + secp256k1_scalar_set_b32(num, b32, &overflow); + if (overflow || secp256k1_scalar_is_zero(num)) { + continue; + } + break; + } while(1); +} + +void run_context_tests(void) { + secp256k1_pubkey pubkey; + secp256k1_ecdsa_signature sig; + unsigned char ctmp[32]; + int32_t ecount; + int32_t ecount2; + secp256k1_context *none = secp256k1_context_create(SECP256K1_CONTEXT_NONE); + secp256k1_context *sign = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); + secp256k1_context *vrfy = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY); + secp256k1_context *both = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + + secp256k1_gej pubj; + secp256k1_ge pub; + secp256k1_scalar msg, key, nonce; + secp256k1_scalar sigr, sigs; + + ecount = 0; + ecount2 = 10; + secp256k1_context_set_illegal_callback(vrfy, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(sign, counting_illegal_callback_fn, &ecount2); + secp256k1_context_set_error_callback(sign, counting_illegal_callback_fn, NULL); + CHECK(vrfy->error_callback.fn != sign->error_callback.fn); + + /*** clone and destroy all of them to make sure cloning was complete ***/ + { + secp256k1_context *ctx_tmp; + + ctx_tmp = none; none = secp256k1_context_clone(none); secp256k1_context_destroy(ctx_tmp); + ctx_tmp = sign; sign = secp256k1_context_clone(sign); secp256k1_context_destroy(ctx_tmp); + ctx_tmp = vrfy; vrfy = secp256k1_context_clone(vrfy); secp256k1_context_destroy(ctx_tmp); + ctx_tmp = both; both = secp256k1_context_clone(both); secp256k1_context_destroy(ctx_tmp); + } + + /* Verify that the error callback makes it across the clone. */ + CHECK(vrfy->error_callback.fn != sign->error_callback.fn); + /* And that it resets back to default. */ + secp256k1_context_set_error_callback(sign, NULL, NULL); + CHECK(vrfy->error_callback.fn == sign->error_callback.fn); + + /*** attempt to use them ***/ + random_scalar_order_test(&msg); + random_scalar_order_test(&key); + secp256k1_ecmult_gen(&both->ecmult_gen_ctx, &pubj, &key); + secp256k1_ge_set_gej(&pub, &pubj); + + /* Verify context-type checking illegal-argument errors. */ + memset(ctmp, 1, 32); + CHECK(secp256k1_ec_pubkey_create(vrfy, &pubkey, ctmp) == 0); + CHECK(ecount == 1); + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_create(sign, &pubkey, ctmp) == 1); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ecdsa_sign(vrfy, &sig, ctmp, ctmp, NULL, NULL) == 0); + CHECK(ecount == 2); + VG_UNDEF(&sig, sizeof(sig)); + CHECK(secp256k1_ecdsa_sign(sign, &sig, ctmp, ctmp, NULL, NULL) == 1); + VG_CHECK(&sig, sizeof(sig)); + CHECK(ecount2 == 10); + CHECK(secp256k1_ecdsa_verify(sign, &sig, ctmp, &pubkey) == 0); + CHECK(ecount2 == 11); + CHECK(secp256k1_ecdsa_verify(vrfy, &sig, ctmp, &pubkey) == 1); + CHECK(ecount == 2); + CHECK(secp256k1_ec_pubkey_tweak_add(sign, &pubkey, ctmp) == 0); + CHECK(ecount2 == 12); + CHECK(secp256k1_ec_pubkey_tweak_add(vrfy, &pubkey, ctmp) == 1); + CHECK(ecount == 2); + CHECK(secp256k1_ec_pubkey_tweak_mul(sign, &pubkey, ctmp) == 0); + CHECK(ecount2 == 13); + CHECK(secp256k1_ec_pubkey_tweak_mul(vrfy, &pubkey, ctmp) == 1); + CHECK(ecount == 2); + CHECK(secp256k1_context_randomize(vrfy, ctmp) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_context_randomize(sign, NULL) == 1); + CHECK(ecount2 == 13); + secp256k1_context_set_illegal_callback(vrfy, NULL, NULL); + secp256k1_context_set_illegal_callback(sign, NULL, NULL); + + /* This shouldn't leak memory, due to already-set tests. */ + secp256k1_ecmult_gen_context_build(&sign->ecmult_gen_ctx, NULL); + secp256k1_ecmult_context_build(&vrfy->ecmult_ctx, NULL); + + /* obtain a working nonce */ + do { + random_scalar_order_test(&nonce); + } while(!secp256k1_ecdsa_sig_sign(&both->ecmult_gen_ctx, &sigr, &sigs, &key, &msg, &nonce, NULL)); + + /* try signing */ + CHECK(secp256k1_ecdsa_sig_sign(&sign->ecmult_gen_ctx, &sigr, &sigs, &key, &msg, &nonce, NULL)); + CHECK(secp256k1_ecdsa_sig_sign(&both->ecmult_gen_ctx, &sigr, &sigs, &key, &msg, &nonce, NULL)); + + /* try verifying */ + CHECK(secp256k1_ecdsa_sig_verify(&vrfy->ecmult_ctx, &sigr, &sigs, &pub, &msg)); + CHECK(secp256k1_ecdsa_sig_verify(&both->ecmult_ctx, &sigr, &sigs, &pub, &msg)); + + /* cleanup */ + secp256k1_context_destroy(none); + secp256k1_context_destroy(sign); + secp256k1_context_destroy(vrfy); + secp256k1_context_destroy(both); + /* Defined as no-op. */ + secp256k1_context_destroy(NULL); +} + +/***** HASH TESTS *****/ + +void run_sha256_tests(void) { + static const char *inputs[8] = { + "", "abc", "message digest", "secure hash algorithm", "SHA256 is considered to be safe", + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "For this sample, this 63-byte string will be used as input data", + "This is exactly 64 bytes long, not counting the terminating byte" + }; + static const unsigned char outputs[8][32] = { + {0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}, + {0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, + {0xf7, 0x84, 0x6f, 0x55, 0xcf, 0x23, 0xe1, 0x4e, 0xeb, 0xea, 0xb5, 0xb4, 0xe1, 0x55, 0x0c, 0xad, 0x5b, 0x50, 0x9e, 0x33, 0x48, 0xfb, 0xc4, 0xef, 0xa3, 0xa1, 0x41, 0x3d, 0x39, 0x3c, 0xb6, 0x50}, + {0xf3, 0x0c, 0xeb, 0x2b, 0xb2, 0x82, 0x9e, 0x79, 0xe4, 0xca, 0x97, 0x53, 0xd3, 0x5a, 0x8e, 0xcc, 0x00, 0x26, 0x2d, 0x16, 0x4c, 0xc0, 0x77, 0x08, 0x02, 0x95, 0x38, 0x1c, 0xbd, 0x64, 0x3f, 0x0d}, + {0x68, 0x19, 0xd9, 0x15, 0xc7, 0x3f, 0x4d, 0x1e, 0x77, 0xe4, 0xe1, 0xb5, 0x2d, 0x1f, 0xa0, 0xf9, 0xcf, 0x9b, 0xea, 0xea, 0xd3, 0x93, 0x9f, 0x15, 0x87, 0x4b, 0xd9, 0x88, 0xe2, 0xa2, 0x36, 0x30}, + {0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39, 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1}, + {0xf0, 0x8a, 0x78, 0xcb, 0xba, 0xee, 0x08, 0x2b, 0x05, 0x2a, 0xe0, 0x70, 0x8f, 0x32, 0xfa, 0x1e, 0x50, 0xc5, 0xc4, 0x21, 0xaa, 0x77, 0x2b, 0xa5, 0xdb, 0xb4, 0x06, 0xa2, 0xea, 0x6b, 0xe3, 0x42}, + {0xab, 0x64, 0xef, 0xf7, 0xe8, 0x8e, 0x2e, 0x46, 0x16, 0x5e, 0x29, 0xf2, 0xbc, 0xe4, 0x18, 0x26, 0xbd, 0x4c, 0x7b, 0x35, 0x52, 0xf6, 0xb3, 0x82, 0xa9, 0xe7, 0xd3, 0xaf, 0x47, 0xc2, 0x45, 0xf8} + }; + int i; + for (i = 0; i < 8; i++) { + unsigned char out[32]; + secp256k1_sha256_t hasher; + secp256k1_sha256_initialize(&hasher); + secp256k1_sha256_write(&hasher, (const unsigned char*)(inputs[i]), strlen(inputs[i])); + secp256k1_sha256_finalize(&hasher, out); + CHECK(memcmp(out, outputs[i], 32) == 0); + if (strlen(inputs[i]) > 0) { + int split = secp256k1_rand_int(strlen(inputs[i])); + secp256k1_sha256_initialize(&hasher); + secp256k1_sha256_write(&hasher, (const unsigned char*)(inputs[i]), split); + secp256k1_sha256_write(&hasher, (const unsigned char*)(inputs[i] + split), strlen(inputs[i]) - split); + secp256k1_sha256_finalize(&hasher, out); + CHECK(memcmp(out, outputs[i], 32) == 0); + } + } +} + +void run_hmac_sha256_tests(void) { + static const char *keys[6] = { + "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", + "\x4a\x65\x66\x65", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + }; + static const char *inputs[6] = { + "\x48\x69\x20\x54\x68\x65\x72\x65", + "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f", + "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd", + "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd", + "\x54\x65\x73\x74\x20\x55\x73\x69\x6e\x67\x20\x4c\x61\x72\x67\x65\x72\x20\x54\x68\x61\x6e\x20\x42\x6c\x6f\x63\x6b\x2d\x53\x69\x7a\x65\x20\x4b\x65\x79\x20\x2d\x20\x48\x61\x73\x68\x20\x4b\x65\x79\x20\x46\x69\x72\x73\x74", + "\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x74\x65\x73\x74\x20\x75\x73\x69\x6e\x67\x20\x61\x20\x6c\x61\x72\x67\x65\x72\x20\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73\x69\x7a\x65\x20\x6b\x65\x79\x20\x61\x6e\x64\x20\x61\x20\x6c\x61\x72\x67\x65\x72\x20\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73\x69\x7a\x65\x20\x64\x61\x74\x61\x2e\x20\x54\x68\x65\x20\x6b\x65\x79\x20\x6e\x65\x65\x64\x73\x20\x74\x6f\x20\x62\x65\x20\x68\x61\x73\x68\x65\x64\x20\x62\x65\x66\x6f\x72\x65\x20\x62\x65\x69\x6e\x67\x20\x75\x73\x65\x64\x20\x62\x79\x20\x74\x68\x65\x20\x48\x4d\x41\x43\x20\x61\x6c\x67\x6f\x72\x69\x74\x68\x6d\x2e" + }; + static const unsigned char outputs[6][32] = { + {0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b, 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7}, + {0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e, 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7, 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83, 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43}, + {0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46, 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7, 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22, 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe}, + {0x82, 0x55, 0x8a, 0x38, 0x9a, 0x44, 0x3c, 0x0e, 0xa4, 0xcc, 0x81, 0x98, 0x99, 0xf2, 0x08, 0x3a, 0x85, 0xf0, 0xfa, 0xa3, 0xe5, 0x78, 0xf8, 0x07, 0x7a, 0x2e, 0x3f, 0xf4, 0x67, 0x29, 0x66, 0x5b}, + {0x60, 0xe4, 0x31, 0x59, 0x1e, 0xe0, 0xb6, 0x7f, 0x0d, 0x8a, 0x26, 0xaa, 0xcb, 0xf5, 0xb7, 0x7f, 0x8e, 0x0b, 0xc6, 0x21, 0x37, 0x28, 0xc5, 0x14, 0x05, 0x46, 0x04, 0x0f, 0x0e, 0xe3, 0x7f, 0x54}, + {0x9b, 0x09, 0xff, 0xa7, 0x1b, 0x94, 0x2f, 0xcb, 0x27, 0x63, 0x5f, 0xbc, 0xd5, 0xb0, 0xe9, 0x44, 0xbf, 0xdc, 0x63, 0x64, 0x4f, 0x07, 0x13, 0x93, 0x8a, 0x7f, 0x51, 0x53, 0x5c, 0x3a, 0x35, 0xe2} + }; + int i; + for (i = 0; i < 6; i++) { + secp256k1_hmac_sha256_t hasher; + unsigned char out[32]; + secp256k1_hmac_sha256_initialize(&hasher, (const unsigned char*)(keys[i]), strlen(keys[i])); + secp256k1_hmac_sha256_write(&hasher, (const unsigned char*)(inputs[i]), strlen(inputs[i])); + secp256k1_hmac_sha256_finalize(&hasher, out); + CHECK(memcmp(out, outputs[i], 32) == 0); + if (strlen(inputs[i]) > 0) { + int split = secp256k1_rand_int(strlen(inputs[i])); + secp256k1_hmac_sha256_initialize(&hasher, (const unsigned char*)(keys[i]), strlen(keys[i])); + secp256k1_hmac_sha256_write(&hasher, (const unsigned char*)(inputs[i]), split); + secp256k1_hmac_sha256_write(&hasher, (const unsigned char*)(inputs[i] + split), strlen(inputs[i]) - split); + secp256k1_hmac_sha256_finalize(&hasher, out); + CHECK(memcmp(out, outputs[i], 32) == 0); + } + } +} + +void run_rfc6979_hmac_sha256_tests(void) { + static const unsigned char key1[65] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x00, 0x4b, 0xf5, 0x12, 0x2f, 0x34, 0x45, 0x54, 0xc5, 0x3b, 0xde, 0x2e, 0xbb, 0x8c, 0xd2, 0xb7, 0xe3, 0xd1, 0x60, 0x0a, 0xd6, 0x31, 0xc3, 0x85, 0xa5, 0xd7, 0xcc, 0xe2, 0x3c, 0x77, 0x85, 0x45, 0x9a, 0}; + static const unsigned char out1[3][32] = { + {0x4f, 0xe2, 0x95, 0x25, 0xb2, 0x08, 0x68, 0x09, 0x15, 0x9a, 0xcd, 0xf0, 0x50, 0x6e, 0xfb, 0x86, 0xb0, 0xec, 0x93, 0x2c, 0x7b, 0xa4, 0x42, 0x56, 0xab, 0x32, 0x1e, 0x42, 0x1e, 0x67, 0xe9, 0xfb}, + {0x2b, 0xf0, 0xff, 0xf1, 0xd3, 0xc3, 0x78, 0xa2, 0x2d, 0xc5, 0xde, 0x1d, 0x85, 0x65, 0x22, 0x32, 0x5c, 0x65, 0xb5, 0x04, 0x49, 0x1a, 0x0c, 0xbd, 0x01, 0xcb, 0x8f, 0x3a, 0xa6, 0x7f, 0xfd, 0x4a}, + {0xf5, 0x28, 0xb4, 0x10, 0xcb, 0x54, 0x1f, 0x77, 0x00, 0x0d, 0x7a, 0xfb, 0x6c, 0x5b, 0x53, 0xc5, 0xc4, 0x71, 0xea, 0xb4, 0x3e, 0x46, 0x6d, 0x9a, 0xc5, 0x19, 0x0c, 0x39, 0xc8, 0x2f, 0xd8, 0x2e} + }; + + static const unsigned char key2[64] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}; + static const unsigned char out2[3][32] = { + {0x9c, 0x23, 0x6c, 0x16, 0x5b, 0x82, 0xae, 0x0c, 0xd5, 0x90, 0x65, 0x9e, 0x10, 0x0b, 0x6b, 0xab, 0x30, 0x36, 0xe7, 0xba, 0x8b, 0x06, 0x74, 0x9b, 0xaf, 0x69, 0x81, 0xe1, 0x6f, 0x1a, 0x2b, 0x95}, + {0xdf, 0x47, 0x10, 0x61, 0x62, 0x5b, 0xc0, 0xea, 0x14, 0xb6, 0x82, 0xfe, 0xee, 0x2c, 0x9c, 0x02, 0xf2, 0x35, 0xda, 0x04, 0x20, 0x4c, 0x1d, 0x62, 0xa1, 0x53, 0x6c, 0x6e, 0x17, 0xae, 0xd7, 0xa9}, + {0x75, 0x97, 0x88, 0x7c, 0xbd, 0x76, 0x32, 0x1f, 0x32, 0xe3, 0x04, 0x40, 0x67, 0x9a, 0x22, 0xcf, 0x7f, 0x8d, 0x9d, 0x2e, 0xac, 0x39, 0x0e, 0x58, 0x1f, 0xea, 0x09, 0x1c, 0xe2, 0x02, 0xba, 0x94} + }; + + secp256k1_rfc6979_hmac_sha256_t rng; + unsigned char out[32]; + int i; + + secp256k1_rfc6979_hmac_sha256_initialize(&rng, key1, 64); + for (i = 0; i < 3; i++) { + secp256k1_rfc6979_hmac_sha256_generate(&rng, out, 32); + CHECK(memcmp(out, out1[i], 32) == 0); + } + secp256k1_rfc6979_hmac_sha256_finalize(&rng); + + secp256k1_rfc6979_hmac_sha256_initialize(&rng, key1, 65); + for (i = 0; i < 3; i++) { + secp256k1_rfc6979_hmac_sha256_generate(&rng, out, 32); + CHECK(memcmp(out, out1[i], 32) != 0); + } + secp256k1_rfc6979_hmac_sha256_finalize(&rng); + + secp256k1_rfc6979_hmac_sha256_initialize(&rng, key2, 64); + for (i = 0; i < 3; i++) { + secp256k1_rfc6979_hmac_sha256_generate(&rng, out, 32); + CHECK(memcmp(out, out2[i], 32) == 0); + } + secp256k1_rfc6979_hmac_sha256_finalize(&rng); +} + +/***** RANDOM TESTS *****/ + +void test_rand_bits(int rand32, int bits) { + /* (1-1/2^B)^rounds[B] < 1/10^9, so rounds is the number of iterations to + * get a false negative chance below once in a billion */ + static const unsigned int rounds[7] = {1, 30, 73, 156, 322, 653, 1316}; + /* We try multiplying the results with various odd numbers, which shouldn't + * influence the uniform distribution modulo a power of 2. */ + static const uint32_t mults[6] = {1, 3, 21, 289, 0x9999, 0x80402011}; + /* We only select up to 6 bits from the output to analyse */ + unsigned int usebits = bits > 6 ? 6 : bits; + unsigned int maxshift = bits - usebits; + /* For each of the maxshift+1 usebits-bit sequences inside a bits-bit + number, track all observed outcomes, one per bit in a uint64_t. */ + uint64_t x[6][27] = {{0}}; + unsigned int i, shift, m; + /* Multiply the output of all rand calls with the odd number m, which + should not change the uniformity of its distribution. */ + for (i = 0; i < rounds[usebits]; i++) { + uint32_t r = (rand32 ? secp256k1_rand32() : secp256k1_rand_bits(bits)); + CHECK((((uint64_t)r) >> bits) == 0); + for (m = 0; m < sizeof(mults) / sizeof(mults[0]); m++) { + uint32_t rm = r * mults[m]; + for (shift = 0; shift <= maxshift; shift++) { + x[m][shift] |= (((uint64_t)1) << ((rm >> shift) & ((1 << usebits) - 1))); + } + } + } + for (m = 0; m < sizeof(mults) / sizeof(mults[0]); m++) { + for (shift = 0; shift <= maxshift; shift++) { + /* Test that the lower usebits bits of x[shift] are 1 */ + CHECK(((~x[m][shift]) << (64 - (1 << usebits))) == 0); + } + } +} + +/* Subrange must be a whole divisor of range, and at most 64 */ +void test_rand_int(uint32_t range, uint32_t subrange) { + /* (1-1/subrange)^rounds < 1/10^9 */ + int rounds = (subrange * 2073) / 100; + int i; + uint64_t x = 0; + CHECK((range % subrange) == 0); + for (i = 0; i < rounds; i++) { + uint32_t r = secp256k1_rand_int(range); + CHECK(r < range); + r = r % subrange; + x |= (((uint64_t)1) << r); + } + /* Test that the lower subrange bits of x are 1. */ + CHECK(((~x) << (64 - subrange)) == 0); +} + +void run_rand_bits(void) { + size_t b; + test_rand_bits(1, 32); + for (b = 1; b <= 32; b++) { + test_rand_bits(0, b); + } +} + +void run_rand_int(void) { + static const uint32_t ms[] = {1, 3, 17, 1000, 13771, 999999, 33554432}; + static const uint32_t ss[] = {1, 3, 6, 9, 13, 31, 64}; + unsigned int m, s; + for (m = 0; m < sizeof(ms) / sizeof(ms[0]); m++) { + for (s = 0; s < sizeof(ss) / sizeof(ss[0]); s++) { + test_rand_int(ms[m] * ss[s], ss[s]); + } + } +} + +/***** NUM TESTS *****/ + +#ifndef USE_NUM_NONE +void random_num_negate(secp256k1_num *num) { + if (secp256k1_rand_bits(1)) { + secp256k1_num_negate(num); + } +} + +void random_num_order_test(secp256k1_num *num) { + secp256k1_scalar sc; + random_scalar_order_test(&sc); + secp256k1_scalar_get_num(num, &sc); +} + +void random_num_order(secp256k1_num *num) { + secp256k1_scalar sc; + random_scalar_order(&sc); + secp256k1_scalar_get_num(num, &sc); +} + +void test_num_negate(void) { + secp256k1_num n1; + secp256k1_num n2; + random_num_order_test(&n1); /* n1 = R */ + random_num_negate(&n1); + secp256k1_num_copy(&n2, &n1); /* n2 = R */ + secp256k1_num_sub(&n1, &n2, &n1); /* n1 = n2-n1 = 0 */ + CHECK(secp256k1_num_is_zero(&n1)); + secp256k1_num_copy(&n1, &n2); /* n1 = R */ + secp256k1_num_negate(&n1); /* n1 = -R */ + CHECK(!secp256k1_num_is_zero(&n1)); + secp256k1_num_add(&n1, &n2, &n1); /* n1 = n2+n1 = 0 */ + CHECK(secp256k1_num_is_zero(&n1)); + secp256k1_num_copy(&n1, &n2); /* n1 = R */ + secp256k1_num_negate(&n1); /* n1 = -R */ + CHECK(secp256k1_num_is_neg(&n1) != secp256k1_num_is_neg(&n2)); + secp256k1_num_negate(&n1); /* n1 = R */ + CHECK(secp256k1_num_eq(&n1, &n2)); +} + +void test_num_add_sub(void) { + secp256k1_num n1; + secp256k1_num n2; + secp256k1_num n1p2, n2p1, n1m2, n2m1; + random_num_order_test(&n1); /* n1 = R1 */ + if (secp256k1_rand_bits(1)) { + random_num_negate(&n1); + } + random_num_order_test(&n2); /* n2 = R2 */ + if (secp256k1_rand_bits(1)) { + random_num_negate(&n2); + } + secp256k1_num_add(&n1p2, &n1, &n2); /* n1p2 = R1 + R2 */ + secp256k1_num_add(&n2p1, &n2, &n1); /* n2p1 = R2 + R1 */ + secp256k1_num_sub(&n1m2, &n1, &n2); /* n1m2 = R1 - R2 */ + secp256k1_num_sub(&n2m1, &n2, &n1); /* n2m1 = R2 - R1 */ + CHECK(secp256k1_num_eq(&n1p2, &n2p1)); + CHECK(!secp256k1_num_eq(&n1p2, &n1m2)); + secp256k1_num_negate(&n2m1); /* n2m1 = -R2 + R1 */ + CHECK(secp256k1_num_eq(&n2m1, &n1m2)); + CHECK(!secp256k1_num_eq(&n2m1, &n1)); + secp256k1_num_add(&n2m1, &n2m1, &n2); /* n2m1 = -R2 + R1 + R2 = R1 */ + CHECK(secp256k1_num_eq(&n2m1, &n1)); + CHECK(!secp256k1_num_eq(&n2p1, &n1)); + secp256k1_num_sub(&n2p1, &n2p1, &n2); /* n2p1 = R2 + R1 - R2 = R1 */ + CHECK(secp256k1_num_eq(&n2p1, &n1)); +} + +void run_num_smalltests(void) { + int i; + for (i = 0; i < 100*count; i++) { + test_num_negate(); + test_num_add_sub(); + } +} +#endif + +/***** SCALAR TESTS *****/ + +void scalar_test(void) { + secp256k1_scalar s; + secp256k1_scalar s1; + secp256k1_scalar s2; +#ifndef USE_NUM_NONE + secp256k1_num snum, s1num, s2num; + secp256k1_num order, half_order; +#endif + unsigned char c[32]; + + /* Set 's' to a random scalar, with value 'snum'. */ + random_scalar_order_test(&s); + + /* Set 's1' to a random scalar, with value 's1num'. */ + random_scalar_order_test(&s1); + + /* Set 's2' to a random scalar, with value 'snum2', and byte array representation 'c'. */ + random_scalar_order_test(&s2); + secp256k1_scalar_get_b32(c, &s2); + +#ifndef USE_NUM_NONE + secp256k1_scalar_get_num(&snum, &s); + secp256k1_scalar_get_num(&s1num, &s1); + secp256k1_scalar_get_num(&s2num, &s2); + + secp256k1_scalar_order_get_num(&order); + half_order = order; + secp256k1_num_shift(&half_order, 1); +#endif + + { + int i; + /* Test that fetching groups of 4 bits from a scalar and recursing n(i)=16*n(i-1)+p(i) reconstructs it. */ + secp256k1_scalar n; + secp256k1_scalar_set_int(&n, 0); + for (i = 0; i < 256; i += 4) { + secp256k1_scalar t; + int j; + secp256k1_scalar_set_int(&t, secp256k1_scalar_get_bits(&s, 256 - 4 - i, 4)); + for (j = 0; j < 4; j++) { + secp256k1_scalar_add(&n, &n, &n); + } + secp256k1_scalar_add(&n, &n, &t); + } + CHECK(secp256k1_scalar_eq(&n, &s)); + } + + { + /* Test that fetching groups of randomly-sized bits from a scalar and recursing n(i)=b*n(i-1)+p(i) reconstructs it. */ + secp256k1_scalar n; + int i = 0; + secp256k1_scalar_set_int(&n, 0); + while (i < 256) { + secp256k1_scalar t; + int j; + int now = secp256k1_rand_int(15) + 1; + if (now + i > 256) { + now = 256 - i; + } + secp256k1_scalar_set_int(&t, secp256k1_scalar_get_bits_var(&s, 256 - now - i, now)); + for (j = 0; j < now; j++) { + secp256k1_scalar_add(&n, &n, &n); + } + secp256k1_scalar_add(&n, &n, &t); + i += now; + } + CHECK(secp256k1_scalar_eq(&n, &s)); + } + +#ifndef USE_NUM_NONE + { + /* Test that adding the scalars together is equal to adding their numbers together modulo the order. */ + secp256k1_num rnum; + secp256k1_num r2num; + secp256k1_scalar r; + secp256k1_num_add(&rnum, &snum, &s2num); + secp256k1_num_mod(&rnum, &order); + secp256k1_scalar_add(&r, &s, &s2); + secp256k1_scalar_get_num(&r2num, &r); + CHECK(secp256k1_num_eq(&rnum, &r2num)); + } + + { + /* Test that multiplying the scalars is equal to multiplying their numbers modulo the order. */ + secp256k1_scalar r; + secp256k1_num r2num; + secp256k1_num rnum; + secp256k1_num_mul(&rnum, &snum, &s2num); + secp256k1_num_mod(&rnum, &order); + secp256k1_scalar_mul(&r, &s, &s2); + secp256k1_scalar_get_num(&r2num, &r); + CHECK(secp256k1_num_eq(&rnum, &r2num)); + /* The result can only be zero if at least one of the factors was zero. */ + CHECK(secp256k1_scalar_is_zero(&r) == (secp256k1_scalar_is_zero(&s) || secp256k1_scalar_is_zero(&s2))); + /* The results can only be equal to one of the factors if that factor was zero, or the other factor was one. */ + CHECK(secp256k1_num_eq(&rnum, &snum) == (secp256k1_scalar_is_zero(&s) || secp256k1_scalar_is_one(&s2))); + CHECK(secp256k1_num_eq(&rnum, &s2num) == (secp256k1_scalar_is_zero(&s2) || secp256k1_scalar_is_one(&s))); + } + + { + secp256k1_scalar neg; + secp256k1_num negnum; + secp256k1_num negnum2; + /* Check that comparison with zero matches comparison with zero on the number. */ + CHECK(secp256k1_num_is_zero(&snum) == secp256k1_scalar_is_zero(&s)); + /* Check that comparison with the half order is equal to testing for high scalar. */ + CHECK(secp256k1_scalar_is_high(&s) == (secp256k1_num_cmp(&snum, &half_order) > 0)); + secp256k1_scalar_negate(&neg, &s); + secp256k1_num_sub(&negnum, &order, &snum); + secp256k1_num_mod(&negnum, &order); + /* Check that comparison with the half order is equal to testing for high scalar after negation. */ + CHECK(secp256k1_scalar_is_high(&neg) == (secp256k1_num_cmp(&negnum, &half_order) > 0)); + /* Negating should change the high property, unless the value was already zero. */ + CHECK((secp256k1_scalar_is_high(&s) == secp256k1_scalar_is_high(&neg)) == secp256k1_scalar_is_zero(&s)); + secp256k1_scalar_get_num(&negnum2, &neg); + /* Negating a scalar should be equal to (order - n) mod order on the number. */ + CHECK(secp256k1_num_eq(&negnum, &negnum2)); + secp256k1_scalar_add(&neg, &neg, &s); + /* Adding a number to its negation should result in zero. */ + CHECK(secp256k1_scalar_is_zero(&neg)); + secp256k1_scalar_negate(&neg, &neg); + /* Negating zero should still result in zero. */ + CHECK(secp256k1_scalar_is_zero(&neg)); + } + + { + /* Test secp256k1_scalar_mul_shift_var. */ + secp256k1_scalar r; + secp256k1_num one; + secp256k1_num rnum; + secp256k1_num rnum2; + unsigned char cone[1] = {0x01}; + unsigned int shift = 256 + secp256k1_rand_int(257); + secp256k1_scalar_mul_shift_var(&r, &s1, &s2, shift); + secp256k1_num_mul(&rnum, &s1num, &s2num); + secp256k1_num_shift(&rnum, shift - 1); + secp256k1_num_set_bin(&one, cone, 1); + secp256k1_num_add(&rnum, &rnum, &one); + secp256k1_num_shift(&rnum, 1); + secp256k1_scalar_get_num(&rnum2, &r); + CHECK(secp256k1_num_eq(&rnum, &rnum2)); + } + + { + /* test secp256k1_scalar_shr_int */ + secp256k1_scalar r; + int i; + random_scalar_order_test(&r); + for (i = 0; i < 100; ++i) { + int low; + int shift = 1 + secp256k1_rand_int(15); + int expected = r.d[0] % (1 << shift); + low = secp256k1_scalar_shr_int(&r, shift); + CHECK(expected == low); + } + } +#endif + + { + /* Test that scalar inverses are equal to the inverse of their number modulo the order. */ + if (!secp256k1_scalar_is_zero(&s)) { + secp256k1_scalar inv; +#ifndef USE_NUM_NONE + secp256k1_num invnum; + secp256k1_num invnum2; +#endif + secp256k1_scalar_inverse(&inv, &s); +#ifndef USE_NUM_NONE + secp256k1_num_mod_inverse(&invnum, &snum, &order); + secp256k1_scalar_get_num(&invnum2, &inv); + CHECK(secp256k1_num_eq(&invnum, &invnum2)); +#endif + secp256k1_scalar_mul(&inv, &inv, &s); + /* Multiplying a scalar with its inverse must result in one. */ + CHECK(secp256k1_scalar_is_one(&inv)); + secp256k1_scalar_inverse(&inv, &inv); + /* Inverting one must result in one. */ + CHECK(secp256k1_scalar_is_one(&inv)); + } + } + + { + /* Test commutativity of add. */ + secp256k1_scalar r1, r2; + secp256k1_scalar_add(&r1, &s1, &s2); + secp256k1_scalar_add(&r2, &s2, &s1); + CHECK(secp256k1_scalar_eq(&r1, &r2)); + } + + { + secp256k1_scalar r1, r2; + secp256k1_scalar b; + int i; + /* Test add_bit. */ + int bit = secp256k1_rand_bits(8); + secp256k1_scalar_set_int(&b, 1); + CHECK(secp256k1_scalar_is_one(&b)); + for (i = 0; i < bit; i++) { + secp256k1_scalar_add(&b, &b, &b); + } + r1 = s1; + r2 = s1; + if (!secp256k1_scalar_add(&r1, &r1, &b)) { + /* No overflow happened. */ + secp256k1_scalar_cadd_bit(&r2, bit, 1); + CHECK(secp256k1_scalar_eq(&r1, &r2)); + /* cadd is a noop when flag is zero */ + secp256k1_scalar_cadd_bit(&r2, bit, 0); + CHECK(secp256k1_scalar_eq(&r1, &r2)); + } + } + + { + /* Test commutativity of mul. */ + secp256k1_scalar r1, r2; + secp256k1_scalar_mul(&r1, &s1, &s2); + secp256k1_scalar_mul(&r2, &s2, &s1); + CHECK(secp256k1_scalar_eq(&r1, &r2)); + } + + { + /* Test associativity of add. */ + secp256k1_scalar r1, r2; + secp256k1_scalar_add(&r1, &s1, &s2); + secp256k1_scalar_add(&r1, &r1, &s); + secp256k1_scalar_add(&r2, &s2, &s); + secp256k1_scalar_add(&r2, &s1, &r2); + CHECK(secp256k1_scalar_eq(&r1, &r2)); + } + + { + /* Test associativity of mul. */ + secp256k1_scalar r1, r2; + secp256k1_scalar_mul(&r1, &s1, &s2); + secp256k1_scalar_mul(&r1, &r1, &s); + secp256k1_scalar_mul(&r2, &s2, &s); + secp256k1_scalar_mul(&r2, &s1, &r2); + CHECK(secp256k1_scalar_eq(&r1, &r2)); + } + + { + /* Test distributitivity of mul over add. */ + secp256k1_scalar r1, r2, t; + secp256k1_scalar_add(&r1, &s1, &s2); + secp256k1_scalar_mul(&r1, &r1, &s); + secp256k1_scalar_mul(&r2, &s1, &s); + secp256k1_scalar_mul(&t, &s2, &s); + secp256k1_scalar_add(&r2, &r2, &t); + CHECK(secp256k1_scalar_eq(&r1, &r2)); + } + + { + /* Test square. */ + secp256k1_scalar r1, r2; + secp256k1_scalar_sqr(&r1, &s1); + secp256k1_scalar_mul(&r2, &s1, &s1); + CHECK(secp256k1_scalar_eq(&r1, &r2)); + } + + { + /* Test multiplicative identity. */ + secp256k1_scalar r1, v1; + secp256k1_scalar_set_int(&v1,1); + secp256k1_scalar_mul(&r1, &s1, &v1); + CHECK(secp256k1_scalar_eq(&r1, &s1)); + } + + { + /* Test additive identity. */ + secp256k1_scalar r1, v0; + secp256k1_scalar_set_int(&v0,0); + secp256k1_scalar_add(&r1, &s1, &v0); + CHECK(secp256k1_scalar_eq(&r1, &s1)); + } + + { + /* Test zero product property. */ + secp256k1_scalar r1, v0; + secp256k1_scalar_set_int(&v0,0); + secp256k1_scalar_mul(&r1, &s1, &v0); + CHECK(secp256k1_scalar_eq(&r1, &v0)); + } + +} + +void run_scalar_tests(void) { + int i; + for (i = 0; i < 128 * count; i++) { + scalar_test(); + } + + { + /* (-1)+1 should be zero. */ + secp256k1_scalar s, o; + secp256k1_scalar_set_int(&s, 1); + CHECK(secp256k1_scalar_is_one(&s)); + secp256k1_scalar_negate(&o, &s); + secp256k1_scalar_add(&o, &o, &s); + CHECK(secp256k1_scalar_is_zero(&o)); + secp256k1_scalar_negate(&o, &o); + CHECK(secp256k1_scalar_is_zero(&o)); + } + +#ifndef USE_NUM_NONE + { + /* A scalar with value of the curve order should be 0. */ + secp256k1_num order; + secp256k1_scalar zero; + unsigned char bin[32]; + int overflow = 0; + secp256k1_scalar_order_get_num(&order); + secp256k1_num_get_bin(bin, 32, &order); + secp256k1_scalar_set_b32(&zero, bin, &overflow); + CHECK(overflow == 1); + CHECK(secp256k1_scalar_is_zero(&zero)); + } +#endif + + { + /* Does check_overflow check catch all ones? */ + static const secp256k1_scalar overflowed = SECP256K1_SCALAR_CONST( + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, + 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL + ); + CHECK(secp256k1_scalar_check_overflow(&overflowed)); + } + + { + /* Static test vectors. + * These were reduced from ~10^12 random vectors based on comparison-decision + * and edge-case coverage on 32-bit and 64-bit implementations. + * The responses were generated with Sage 5.9. + */ + secp256k1_scalar x; + secp256k1_scalar y; + secp256k1_scalar z; + secp256k1_scalar zz; + secp256k1_scalar one; + secp256k1_scalar r1; + secp256k1_scalar r2; +#if defined(USE_SCALAR_INV_NUM) + secp256k1_scalar zzv; +#endif + int overflow; + unsigned char chal[32][2][32] = { + {{0xff, 0xff, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, + 0xff, 0xff, 0x03, 0x00, 0xc0, 0xff, 0xff, 0xff}, + {0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff}}, + {{0xef, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x80, 0xff}}, + {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x80, 0xff, 0x3f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00}, + {0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x80, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xe0, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff}}, + {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x1e, 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff}, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, + 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0xe0, + 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, + 0xf3, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}}, + {{0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x1c, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff}, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, + 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, + 0x00, 0xfe, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xff}}, + {{0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xfc, 0x9f, + 0xff, 0xff, 0xff, 0x00, 0x80, 0x00, 0x00, 0x80, + 0xff, 0x0f, 0xfc, 0xff, 0x7f, 0x00, 0x00, 0x00, + 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}, + {0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x00, 0x00, 0xf8, 0xff, 0x0f, 0xc0, 0xff, 0xff, + 0xff, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x07, 0x80, 0xff, 0xff, 0xff}}, + {{0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, + 0xf7, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0x00, + 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf0}, + {0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}, + {{0x00, 0xf8, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00, + 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x03, 0xc0, 0xff, 0x0f, 0xfc, 0xff}, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, + 0xff, 0x01, 0x00, 0x00, 0x00, 0x3f, 0x00, 0xc0, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}, + {{0x8f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x7f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, + {{0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x03, 0x00, 0x80, 0x00, 0x00, 0x80, + 0xff, 0xff, 0xff, 0x00, 0x00, 0x80, 0xff, 0x7f}, + {0xff, 0xcf, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, + 0x00, 0xc0, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, + 0xbf, 0xff, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00}}, + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, + 0xff, 0xff, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x00, 0x80, 0x00, 0x00, 0x80, + 0xff, 0x01, 0xfc, 0xff, 0x01, 0x00, 0xfe, 0xff}, + {0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00}}, + {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x7f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0xff, + 0xe0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, + {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x00}, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, + 0xfc, 0xff, 0xff, 0x3f, 0xf0, 0xff, 0xff, 0x3f, + 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x0f, 0x7e, 0x00, 0x00}}, + {{0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x1f, 0x00, 0x00, 0xfe, 0x07, 0x00}, + {0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfb, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60}}, + {{0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00, + 0x80, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + {0xff, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00}}, + {{0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, + 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff}}, + {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xc0, 0xff, 0xff, 0xcf, 0xff, 0x1f, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x7e, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00}, + {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0xff, 0xff, 0x7f, 0x00, 0x80, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff}}, + {{0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x80, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}, + {0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x80, + 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x1f, 0x00, 0xfe}}, + {{0xff, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xff, + 0xff, 0x03, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00, + 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07}, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0xff, 0xff, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}}, + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, + 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40}}, + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, + {{0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + {0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}, + {{0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xc0, + 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, + 0xf0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff}}, + {{0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}, + {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, + 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}, + {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x7e, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + {0xff, 0x01, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x80, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}, + {{0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x00, + 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, + 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, + 0xff, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x3f, 0x00, 0x00, 0xc0, 0xf1, 0x7f, 0x00}}, + {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00}, + {0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, + 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f, + 0x00, 0x00, 0xfc, 0xff, 0xff, 0x01, 0xff, 0xff}}, + {{0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x80, 0x00, 0x00, 0x80, 0xff, 0x03, 0xe0, 0x01, + 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xfc, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}, + {0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0xff, 0xff, 0xf0, 0x07, 0x00, 0x3c, 0x80, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x07, 0xe0, 0xff, 0x00, 0x00, 0x00}}, + {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf8, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80}, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x80, 0x00, + 0x00, 0x00, 0x00, 0xc0, 0x7f, 0xfe, 0xff, 0x1f, + 0x00, 0xfe, 0xff, 0x03, 0x00, 0x00, 0xfe, 0xff}}, + {{0xff, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, + 0xff, 0xff, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, + 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xf0}, + {0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, + 0xf8, 0x07, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xc7, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff}} + }; + unsigned char res[32][2][32] = { + {{0x0c, 0x3b, 0x0a, 0xca, 0x8d, 0x1a, 0x2f, 0xb9, + 0x8a, 0x7b, 0x53, 0x5a, 0x1f, 0xc5, 0x22, 0xa1, + 0x07, 0x2a, 0x48, 0xea, 0x02, 0xeb, 0xb3, 0xd6, + 0x20, 0x1e, 0x86, 0xd0, 0x95, 0xf6, 0x92, 0x35}, + {0xdc, 0x90, 0x7a, 0x07, 0x2e, 0x1e, 0x44, 0x6d, + 0xf8, 0x15, 0x24, 0x5b, 0x5a, 0x96, 0x37, 0x9c, + 0x37, 0x7b, 0x0d, 0xac, 0x1b, 0x65, 0x58, 0x49, + 0x43, 0xb7, 0x31, 0xbb, 0xa7, 0xf4, 0x97, 0x15}}, + {{0xf1, 0xf7, 0x3a, 0x50, 0xe6, 0x10, 0xba, 0x22, + 0x43, 0x4d, 0x1f, 0x1f, 0x7c, 0x27, 0xca, 0x9c, + 0xb8, 0xb6, 0xa0, 0xfc, 0xd8, 0xc0, 0x05, 0x2f, + 0xf7, 0x08, 0xe1, 0x76, 0xdd, 0xd0, 0x80, 0xc8}, + {0xe3, 0x80, 0x80, 0xb8, 0xdb, 0xe3, 0xa9, 0x77, + 0x00, 0xb0, 0xf5, 0x2e, 0x27, 0xe2, 0x68, 0xc4, + 0x88, 0xe8, 0x04, 0xc1, 0x12, 0xbf, 0x78, 0x59, + 0xe6, 0xa9, 0x7c, 0xe1, 0x81, 0xdd, 0xb9, 0xd5}}, + {{0x96, 0xe2, 0xee, 0x01, 0xa6, 0x80, 0x31, 0xef, + 0x5c, 0xd0, 0x19, 0xb4, 0x7d, 0x5f, 0x79, 0xab, + 0xa1, 0x97, 0xd3, 0x7e, 0x33, 0xbb, 0x86, 0x55, + 0x60, 0x20, 0x10, 0x0d, 0x94, 0x2d, 0x11, 0x7c}, + {0xcc, 0xab, 0xe0, 0xe8, 0x98, 0x65, 0x12, 0x96, + 0x38, 0x5a, 0x1a, 0xf2, 0x85, 0x23, 0x59, 0x5f, + 0xf9, 0xf3, 0xc2, 0x81, 0x70, 0x92, 0x65, 0x12, + 0x9c, 0x65, 0x1e, 0x96, 0x00, 0xef, 0xe7, 0x63}}, + {{0xac, 0x1e, 0x62, 0xc2, 0x59, 0xfc, 0x4e, 0x5c, + 0x83, 0xb0, 0xd0, 0x6f, 0xce, 0x19, 0xf6, 0xbf, + 0xa4, 0xb0, 0xe0, 0x53, 0x66, 0x1f, 0xbf, 0xc9, + 0x33, 0x47, 0x37, 0xa9, 0x3d, 0x5d, 0xb0, 0x48}, + {0x86, 0xb9, 0x2a, 0x7f, 0x8e, 0xa8, 0x60, 0x42, + 0x26, 0x6d, 0x6e, 0x1c, 0xa2, 0xec, 0xe0, 0xe5, + 0x3e, 0x0a, 0x33, 0xbb, 0x61, 0x4c, 0x9f, 0x3c, + 0xd1, 0xdf, 0x49, 0x33, 0xcd, 0x72, 0x78, 0x18}}, + {{0xf7, 0xd3, 0xcd, 0x49, 0x5c, 0x13, 0x22, 0xfb, + 0x2e, 0xb2, 0x2f, 0x27, 0xf5, 0x8a, 0x5d, 0x74, + 0xc1, 0x58, 0xc5, 0xc2, 0x2d, 0x9f, 0x52, 0xc6, + 0x63, 0x9f, 0xba, 0x05, 0x76, 0x45, 0x7a, 0x63}, + {0x8a, 0xfa, 0x55, 0x4d, 0xdd, 0xa3, 0xb2, 0xc3, + 0x44, 0xfd, 0xec, 0x72, 0xde, 0xef, 0xc0, 0x99, + 0xf5, 0x9f, 0xe2, 0x52, 0xb4, 0x05, 0x32, 0x58, + 0x57, 0xc1, 0x8f, 0xea, 0xc3, 0x24, 0x5b, 0x94}}, + {{0x05, 0x83, 0xee, 0xdd, 0x64, 0xf0, 0x14, 0x3b, + 0xa0, 0x14, 0x4a, 0x3a, 0x41, 0x82, 0x7c, 0xa7, + 0x2c, 0xaa, 0xb1, 0x76, 0xbb, 0x59, 0x64, 0x5f, + 0x52, 0xad, 0x25, 0x29, 0x9d, 0x8f, 0x0b, 0xb0}, + {0x7e, 0xe3, 0x7c, 0xca, 0xcd, 0x4f, 0xb0, 0x6d, + 0x7a, 0xb2, 0x3e, 0xa0, 0x08, 0xb9, 0xa8, 0x2d, + 0xc2, 0xf4, 0x99, 0x66, 0xcc, 0xac, 0xd8, 0xb9, + 0x72, 0x2a, 0x4a, 0x3e, 0x0f, 0x7b, 0xbf, 0xf4}}, + {{0x8c, 0x9c, 0x78, 0x2b, 0x39, 0x61, 0x7e, 0xf7, + 0x65, 0x37, 0x66, 0x09, 0x38, 0xb9, 0x6f, 0x70, + 0x78, 0x87, 0xff, 0xcf, 0x93, 0xca, 0x85, 0x06, + 0x44, 0x84, 0xa7, 0xfe, 0xd3, 0xa4, 0xe3, 0x7e}, + {0xa2, 0x56, 0x49, 0x23, 0x54, 0xa5, 0x50, 0xe9, + 0x5f, 0xf0, 0x4d, 0xe7, 0xdc, 0x38, 0x32, 0x79, + 0x4f, 0x1c, 0xb7, 0xe4, 0xbb, 0xf8, 0xbb, 0x2e, + 0x40, 0x41, 0x4b, 0xcc, 0xe3, 0x1e, 0x16, 0x36}}, + {{0x0c, 0x1e, 0xd7, 0x09, 0x25, 0x40, 0x97, 0xcb, + 0x5c, 0x46, 0xa8, 0xda, 0xef, 0x25, 0xd5, 0xe5, + 0x92, 0x4d, 0xcf, 0xa3, 0xc4, 0x5d, 0x35, 0x4a, + 0xe4, 0x61, 0x92, 0xf3, 0xbf, 0x0e, 0xcd, 0xbe}, + {0xe4, 0xaf, 0x0a, 0xb3, 0x30, 0x8b, 0x9b, 0x48, + 0x49, 0x43, 0xc7, 0x64, 0x60, 0x4a, 0x2b, 0x9e, + 0x95, 0x5f, 0x56, 0xe8, 0x35, 0xdc, 0xeb, 0xdc, + 0xc7, 0xc4, 0xfe, 0x30, 0x40, 0xc7, 0xbf, 0xa4}}, + {{0xd4, 0xa0, 0xf5, 0x81, 0x49, 0x6b, 0xb6, 0x8b, + 0x0a, 0x69, 0xf9, 0xfe, 0xa8, 0x32, 0xe5, 0xe0, + 0xa5, 0xcd, 0x02, 0x53, 0xf9, 0x2c, 0xe3, 0x53, + 0x83, 0x36, 0xc6, 0x02, 0xb5, 0xeb, 0x64, 0xb8}, + {0x1d, 0x42, 0xb9, 0xf9, 0xe9, 0xe3, 0x93, 0x2c, + 0x4c, 0xee, 0x6c, 0x5a, 0x47, 0x9e, 0x62, 0x01, + 0x6b, 0x04, 0xfe, 0xa4, 0x30, 0x2b, 0x0d, 0x4f, + 0x71, 0x10, 0xd3, 0x55, 0xca, 0xf3, 0x5e, 0x80}}, + {{0x77, 0x05, 0xf6, 0x0c, 0x15, 0x9b, 0x45, 0xe7, + 0xb9, 0x11, 0xb8, 0xf5, 0xd6, 0xda, 0x73, 0x0c, + 0xda, 0x92, 0xea, 0xd0, 0x9d, 0xd0, 0x18, 0x92, + 0xce, 0x9a, 0xaa, 0xee, 0x0f, 0xef, 0xde, 0x30}, + {0xf1, 0xf1, 0xd6, 0x9b, 0x51, 0xd7, 0x77, 0x62, + 0x52, 0x10, 0xb8, 0x7a, 0x84, 0x9d, 0x15, 0x4e, + 0x07, 0xdc, 0x1e, 0x75, 0x0d, 0x0c, 0x3b, 0xdb, + 0x74, 0x58, 0x62, 0x02, 0x90, 0x54, 0x8b, 0x43}}, + {{0xa6, 0xfe, 0x0b, 0x87, 0x80, 0x43, 0x67, 0x25, + 0x57, 0x5d, 0xec, 0x40, 0x50, 0x08, 0xd5, 0x5d, + 0x43, 0xd7, 0xe0, 0xaa, 0xe0, 0x13, 0xb6, 0xb0, + 0xc0, 0xd4, 0xe5, 0x0d, 0x45, 0x83, 0xd6, 0x13}, + {0x40, 0x45, 0x0a, 0x92, 0x31, 0xea, 0x8c, 0x60, + 0x8c, 0x1f, 0xd8, 0x76, 0x45, 0xb9, 0x29, 0x00, + 0x26, 0x32, 0xd8, 0xa6, 0x96, 0x88, 0xe2, 0xc4, + 0x8b, 0xdb, 0x7f, 0x17, 0x87, 0xcc, 0xc8, 0xf2}}, + {{0xc2, 0x56, 0xe2, 0xb6, 0x1a, 0x81, 0xe7, 0x31, + 0x63, 0x2e, 0xbb, 0x0d, 0x2f, 0x81, 0x67, 0xd4, + 0x22, 0xe2, 0x38, 0x02, 0x25, 0x97, 0xc7, 0x88, + 0x6e, 0xdf, 0xbe, 0x2a, 0xa5, 0x73, 0x63, 0xaa}, + {0x50, 0x45, 0xe2, 0xc3, 0xbd, 0x89, 0xfc, 0x57, + 0xbd, 0x3c, 0xa3, 0x98, 0x7e, 0x7f, 0x36, 0x38, + 0x92, 0x39, 0x1f, 0x0f, 0x81, 0x1a, 0x06, 0x51, + 0x1f, 0x8d, 0x6a, 0xff, 0x47, 0x16, 0x06, 0x9c}}, + {{0x33, 0x95, 0xa2, 0x6f, 0x27, 0x5f, 0x9c, 0x9c, + 0x64, 0x45, 0xcb, 0xd1, 0x3c, 0xee, 0x5e, 0x5f, + 0x48, 0xa6, 0xaf, 0xe3, 0x79, 0xcf, 0xb1, 0xe2, + 0xbf, 0x55, 0x0e, 0xa2, 0x3b, 0x62, 0xf0, 0xe4}, + {0x14, 0xe8, 0x06, 0xe3, 0xbe, 0x7e, 0x67, 0x01, + 0xc5, 0x21, 0x67, 0xd8, 0x54, 0xb5, 0x7f, 0xa4, + 0xf9, 0x75, 0x70, 0x1c, 0xfd, 0x79, 0xdb, 0x86, + 0xad, 0x37, 0x85, 0x83, 0x56, 0x4e, 0xf0, 0xbf}}, + {{0xbc, 0xa6, 0xe0, 0x56, 0x4e, 0xef, 0xfa, 0xf5, + 0x1d, 0x5d, 0x3f, 0x2a, 0x5b, 0x19, 0xab, 0x51, + 0xc5, 0x8b, 0xdd, 0x98, 0x28, 0x35, 0x2f, 0xc3, + 0x81, 0x4f, 0x5c, 0xe5, 0x70, 0xb9, 0xeb, 0x62}, + {0xc4, 0x6d, 0x26, 0xb0, 0x17, 0x6b, 0xfe, 0x6c, + 0x12, 0xf8, 0xe7, 0xc1, 0xf5, 0x2f, 0xfa, 0x91, + 0x13, 0x27, 0xbd, 0x73, 0xcc, 0x33, 0x31, 0x1c, + 0x39, 0xe3, 0x27, 0x6a, 0x95, 0xcf, 0xc5, 0xfb}}, + {{0x30, 0xb2, 0x99, 0x84, 0xf0, 0x18, 0x2a, 0x6e, + 0x1e, 0x27, 0xed, 0xa2, 0x29, 0x99, 0x41, 0x56, + 0xe8, 0xd4, 0x0d, 0xef, 0x99, 0x9c, 0xf3, 0x58, + 0x29, 0x55, 0x1a, 0xc0, 0x68, 0xd6, 0x74, 0xa4}, + {0x07, 0x9c, 0xe7, 0xec, 0xf5, 0x36, 0x73, 0x41, + 0xa3, 0x1c, 0xe5, 0x93, 0x97, 0x6a, 0xfd, 0xf7, + 0x53, 0x18, 0xab, 0xaf, 0xeb, 0x85, 0xbd, 0x92, + 0x90, 0xab, 0x3c, 0xbf, 0x30, 0x82, 0xad, 0xf6}}, + {{0xc6, 0x87, 0x8a, 0x2a, 0xea, 0xc0, 0xa9, 0xec, + 0x6d, 0xd3, 0xdc, 0x32, 0x23, 0xce, 0x62, 0x19, + 0xa4, 0x7e, 0xa8, 0xdd, 0x1c, 0x33, 0xae, 0xd3, + 0x4f, 0x62, 0x9f, 0x52, 0xe7, 0x65, 0x46, 0xf4}, + {0x97, 0x51, 0x27, 0x67, 0x2d, 0xa2, 0x82, 0x87, + 0x98, 0xd3, 0xb6, 0x14, 0x7f, 0x51, 0xd3, 0x9a, + 0x0b, 0xd0, 0x76, 0x81, 0xb2, 0x4f, 0x58, 0x92, + 0xa4, 0x86, 0xa1, 0xa7, 0x09, 0x1d, 0xef, 0x9b}}, + {{0xb3, 0x0f, 0x2b, 0x69, 0x0d, 0x06, 0x90, 0x64, + 0xbd, 0x43, 0x4c, 0x10, 0xe8, 0x98, 0x1c, 0xa3, + 0xe1, 0x68, 0xe9, 0x79, 0x6c, 0x29, 0x51, 0x3f, + 0x41, 0xdc, 0xdf, 0x1f, 0xf3, 0x60, 0xbe, 0x33}, + {0xa1, 0x5f, 0xf7, 0x1d, 0xb4, 0x3e, 0x9b, 0x3c, + 0xe7, 0xbd, 0xb6, 0x06, 0xd5, 0x60, 0x06, 0x6d, + 0x50, 0xd2, 0xf4, 0x1a, 0x31, 0x08, 0xf2, 0xea, + 0x8e, 0xef, 0x5f, 0x7d, 0xb6, 0xd0, 0xc0, 0x27}}, + {{0x62, 0x9a, 0xd9, 0xbb, 0x38, 0x36, 0xce, 0xf7, + 0x5d, 0x2f, 0x13, 0xec, 0xc8, 0x2d, 0x02, 0x8a, + 0x2e, 0x72, 0xf0, 0xe5, 0x15, 0x9d, 0x72, 0xae, + 0xfc, 0xb3, 0x4f, 0x02, 0xea, 0xe1, 0x09, 0xfe}, + {0x00, 0x00, 0x00, 0x00, 0xfa, 0x0a, 0x3d, 0xbc, + 0xad, 0x16, 0x0c, 0xb6, 0xe7, 0x7c, 0x8b, 0x39, + 0x9a, 0x43, 0xbb, 0xe3, 0xc2, 0x55, 0x15, 0x14, + 0x75, 0xac, 0x90, 0x9b, 0x7f, 0x9a, 0x92, 0x00}}, + {{0x8b, 0xac, 0x70, 0x86, 0x29, 0x8f, 0x00, 0x23, + 0x7b, 0x45, 0x30, 0xaa, 0xb8, 0x4c, 0xc7, 0x8d, + 0x4e, 0x47, 0x85, 0xc6, 0x19, 0xe3, 0x96, 0xc2, + 0x9a, 0xa0, 0x12, 0xed, 0x6f, 0xd7, 0x76, 0x16}, + {0x45, 0xaf, 0x7e, 0x33, 0xc7, 0x7f, 0x10, 0x6c, + 0x7c, 0x9f, 0x29, 0xc1, 0xa8, 0x7e, 0x15, 0x84, + 0xe7, 0x7d, 0xc0, 0x6d, 0xab, 0x71, 0x5d, 0xd0, + 0x6b, 0x9f, 0x97, 0xab, 0xcb, 0x51, 0x0c, 0x9f}}, + {{0x9e, 0xc3, 0x92, 0xb4, 0x04, 0x9f, 0xc8, 0xbb, + 0xdd, 0x9e, 0xc6, 0x05, 0xfd, 0x65, 0xec, 0x94, + 0x7f, 0x2c, 0x16, 0xc4, 0x40, 0xac, 0x63, 0x7b, + 0x7d, 0xb8, 0x0c, 0xe4, 0x5b, 0xe3, 0xa7, 0x0e}, + {0x43, 0xf4, 0x44, 0xe8, 0xcc, 0xc8, 0xd4, 0x54, + 0x33, 0x37, 0x50, 0xf2, 0x87, 0x42, 0x2e, 0x00, + 0x49, 0x60, 0x62, 0x02, 0xfd, 0x1a, 0x7c, 0xdb, + 0x29, 0x6c, 0x6d, 0x54, 0x53, 0x08, 0xd1, 0xc8}}, + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}, + {{0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1, + 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0, + 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59, + 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92}, + {0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1, + 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0, + 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59, + 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92}}, + {{0x28, 0x56, 0xac, 0x0e, 0x4f, 0x98, 0x09, 0xf0, + 0x49, 0xfa, 0x7f, 0x84, 0xac, 0x7e, 0x50, 0x5b, + 0x17, 0x43, 0x14, 0x89, 0x9c, 0x53, 0xa8, 0x94, + 0x30, 0xf2, 0x11, 0x4d, 0x92, 0x14, 0x27, 0xe8}, + {0x39, 0x7a, 0x84, 0x56, 0x79, 0x9d, 0xec, 0x26, + 0x2c, 0x53, 0xc1, 0x94, 0xc9, 0x8d, 0x9e, 0x9d, + 0x32, 0x1f, 0xdd, 0x84, 0x04, 0xe8, 0xe2, 0x0a, + 0x6b, 0xbe, 0xbb, 0x42, 0x40, 0x67, 0x30, 0x6c}}, + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4, + 0x40, 0x2d, 0xa1, 0x73, 0x2f, 0xc9, 0xbe, 0xbd}, + {0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1, + 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0, + 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59, + 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92}}, + {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, + 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}, + {{0x1c, 0xc4, 0xf7, 0xda, 0x0f, 0x65, 0xca, 0x39, + 0x70, 0x52, 0x92, 0x8e, 0xc3, 0xc8, 0x15, 0xea, + 0x7f, 0x10, 0x9e, 0x77, 0x4b, 0x6e, 0x2d, 0xdf, + 0xe8, 0x30, 0x9d, 0xda, 0xe8, 0x9a, 0x65, 0xae}, + {0x02, 0xb0, 0x16, 0xb1, 0x1d, 0xc8, 0x57, 0x7b, + 0xa2, 0x3a, 0xa2, 0xa3, 0x38, 0x5c, 0x8f, 0xeb, + 0x66, 0x37, 0x91, 0xa8, 0x5f, 0xef, 0x04, 0xf6, + 0x59, 0x75, 0xe1, 0xee, 0x92, 0xf6, 0x0e, 0x30}}, + {{0x8d, 0x76, 0x14, 0xa4, 0x14, 0x06, 0x9f, 0x9a, + 0xdf, 0x4a, 0x85, 0xa7, 0x6b, 0xbf, 0x29, 0x6f, + 0xbc, 0x34, 0x87, 0x5d, 0xeb, 0xbb, 0x2e, 0xa9, + 0xc9, 0x1f, 0x58, 0xd6, 0x9a, 0x82, 0xa0, 0x56}, + {0xd4, 0xb9, 0xdb, 0x88, 0x1d, 0x04, 0xe9, 0x93, + 0x8d, 0x3f, 0x20, 0xd5, 0x86, 0xa8, 0x83, 0x07, + 0xdb, 0x09, 0xd8, 0x22, 0x1f, 0x7f, 0xf1, 0x71, + 0xc8, 0xe7, 0x5d, 0x47, 0xaf, 0x8b, 0x72, 0xe9}}, + {{0x83, 0xb9, 0x39, 0xb2, 0xa4, 0xdf, 0x46, 0x87, + 0xc2, 0xb8, 0xf1, 0xe6, 0x4c, 0xd1, 0xe2, 0xa9, + 0xe4, 0x70, 0x30, 0x34, 0xbc, 0x52, 0x7c, 0x55, + 0xa6, 0xec, 0x80, 0xa4, 0xe5, 0xd2, 0xdc, 0x73}, + {0x08, 0xf1, 0x03, 0xcf, 0x16, 0x73, 0xe8, 0x7d, + 0xb6, 0x7e, 0x9b, 0xc0, 0xb4, 0xc2, 0xa5, 0x86, + 0x02, 0x77, 0xd5, 0x27, 0x86, 0xa5, 0x15, 0xfb, + 0xae, 0x9b, 0x8c, 0xa9, 0xf9, 0xf8, 0xa8, 0x4a}}, + {{0x8b, 0x00, 0x49, 0xdb, 0xfa, 0xf0, 0x1b, 0xa2, + 0xed, 0x8a, 0x9a, 0x7a, 0x36, 0x78, 0x4a, 0xc7, + 0xf7, 0xad, 0x39, 0xd0, 0x6c, 0x65, 0x7a, 0x41, + 0xce, 0xd6, 0xd6, 0x4c, 0x20, 0x21, 0x6b, 0xc7}, + {0xc6, 0xca, 0x78, 0x1d, 0x32, 0x6c, 0x6c, 0x06, + 0x91, 0xf2, 0x1a, 0xe8, 0x43, 0x16, 0xea, 0x04, + 0x3c, 0x1f, 0x07, 0x85, 0xf7, 0x09, 0x22, 0x08, + 0xba, 0x13, 0xfd, 0x78, 0x1e, 0x3f, 0x6f, 0x62}}, + {{0x25, 0x9b, 0x7c, 0xb0, 0xac, 0x72, 0x6f, 0xb2, + 0xe3, 0x53, 0x84, 0x7a, 0x1a, 0x9a, 0x98, 0x9b, + 0x44, 0xd3, 0x59, 0xd0, 0x8e, 0x57, 0x41, 0x40, + 0x78, 0xa7, 0x30, 0x2f, 0x4c, 0x9c, 0xb9, 0x68}, + {0xb7, 0x75, 0x03, 0x63, 0x61, 0xc2, 0x48, 0x6e, + 0x12, 0x3d, 0xbf, 0x4b, 0x27, 0xdf, 0xb1, 0x7a, + 0xff, 0x4e, 0x31, 0x07, 0x83, 0xf4, 0x62, 0x5b, + 0x19, 0xa5, 0xac, 0xa0, 0x32, 0x58, 0x0d, 0xa7}}, + {{0x43, 0x4f, 0x10, 0xa4, 0xca, 0xdb, 0x38, 0x67, + 0xfa, 0xae, 0x96, 0xb5, 0x6d, 0x97, 0xff, 0x1f, + 0xb6, 0x83, 0x43, 0xd3, 0xa0, 0x2d, 0x70, 0x7a, + 0x64, 0x05, 0x4c, 0xa7, 0xc1, 0xa5, 0x21, 0x51}, + {0xe4, 0xf1, 0x23, 0x84, 0xe1, 0xb5, 0x9d, 0xf2, + 0xb8, 0x73, 0x8b, 0x45, 0x2b, 0x35, 0x46, 0x38, + 0x10, 0x2b, 0x50, 0xf8, 0x8b, 0x35, 0xcd, 0x34, + 0xc8, 0x0e, 0xf6, 0xdb, 0x09, 0x35, 0xf0, 0xda}} + }; + secp256k1_scalar_set_int(&one, 1); + for (i = 0; i < 32; i++) { + secp256k1_scalar_set_b32(&x, chal[i][0], &overflow); + CHECK(!overflow); + secp256k1_scalar_set_b32(&y, chal[i][1], &overflow); + CHECK(!overflow); + secp256k1_scalar_set_b32(&r1, res[i][0], &overflow); + CHECK(!overflow); + secp256k1_scalar_set_b32(&r2, res[i][1], &overflow); + CHECK(!overflow); + secp256k1_scalar_mul(&z, &x, &y); + CHECK(!secp256k1_scalar_check_overflow(&z)); + CHECK(secp256k1_scalar_eq(&r1, &z)); + if (!secp256k1_scalar_is_zero(&y)) { + secp256k1_scalar_inverse(&zz, &y); + CHECK(!secp256k1_scalar_check_overflow(&zz)); +#if defined(USE_SCALAR_INV_NUM) + secp256k1_scalar_inverse_var(&zzv, &y); + CHECK(secp256k1_scalar_eq(&zzv, &zz)); +#endif + secp256k1_scalar_mul(&z, &z, &zz); + CHECK(!secp256k1_scalar_check_overflow(&z)); + CHECK(secp256k1_scalar_eq(&x, &z)); + secp256k1_scalar_mul(&zz, &zz, &y); + CHECK(!secp256k1_scalar_check_overflow(&zz)); + CHECK(secp256k1_scalar_eq(&one, &zz)); + } + secp256k1_scalar_mul(&z, &x, &x); + CHECK(!secp256k1_scalar_check_overflow(&z)); + secp256k1_scalar_sqr(&zz, &x); + CHECK(!secp256k1_scalar_check_overflow(&zz)); + CHECK(secp256k1_scalar_eq(&zz, &z)); + CHECK(secp256k1_scalar_eq(&r2, &zz)); + } + } +} + +/***** FIELD TESTS *****/ + +void random_fe(secp256k1_fe *x) { + unsigned char bin[32]; + do { + secp256k1_rand256(bin); + if (secp256k1_fe_set_b32(x, bin)) { + return; + } + } while(1); +} + +void random_fe_test(secp256k1_fe *x) { + unsigned char bin[32]; + do { + secp256k1_rand256_test(bin); + if (secp256k1_fe_set_b32(x, bin)) { + return; + } + } while(1); +} + +void random_fe_non_zero(secp256k1_fe *nz) { + int tries = 10; + while (--tries >= 0) { + random_fe(nz); + secp256k1_fe_normalize(nz); + if (!secp256k1_fe_is_zero(nz)) { + break; + } + } + /* Infinitesimal probability of spurious failure here */ + CHECK(tries >= 0); +} + +void random_fe_non_square(secp256k1_fe *ns) { + secp256k1_fe r; + random_fe_non_zero(ns); + if (secp256k1_fe_sqrt_var(&r, ns)) { + secp256k1_fe_negate(ns, ns, 1); + } +} + +int check_fe_equal(const secp256k1_fe *a, const secp256k1_fe *b) { + secp256k1_fe an = *a; + secp256k1_fe bn = *b; + secp256k1_fe_normalize_weak(&an); + secp256k1_fe_normalize_var(&bn); + return secp256k1_fe_equal_var(&an, &bn); +} + +int check_fe_inverse(const secp256k1_fe *a, const secp256k1_fe *ai) { + secp256k1_fe x; + secp256k1_fe one = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1); + secp256k1_fe_mul(&x, a, ai); + return check_fe_equal(&x, &one); +} + +void run_field_convert(void) { + static const unsigned char b32[32] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, + 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40 + }; + static const secp256k1_fe_storage fes = SECP256K1_FE_STORAGE_CONST( + 0x00010203UL, 0x04050607UL, 0x11121314UL, 0x15161718UL, + 0x22232425UL, 0x26272829UL, 0x33343536UL, 0x37383940UL + ); + static const secp256k1_fe fe = SECP256K1_FE_CONST( + 0x00010203UL, 0x04050607UL, 0x11121314UL, 0x15161718UL, + 0x22232425UL, 0x26272829UL, 0x33343536UL, 0x37383940UL + ); + secp256k1_fe fe2; + unsigned char b322[32]; + secp256k1_fe_storage fes2; + /* Check conversions to fe. */ + CHECK(secp256k1_fe_set_b32(&fe2, b32)); + CHECK(secp256k1_fe_equal_var(&fe, &fe2)); + secp256k1_fe_from_storage(&fe2, &fes); + CHECK(secp256k1_fe_equal_var(&fe, &fe2)); + /* Check conversion from fe. */ + secp256k1_fe_get_b32(b322, &fe); + CHECK(memcmp(b322, b32, 32) == 0); + secp256k1_fe_to_storage(&fes2, &fe); + CHECK(memcmp(&fes2, &fes, sizeof(fes)) == 0); +} + +int fe_memcmp(const secp256k1_fe *a, const secp256k1_fe *b) { + secp256k1_fe t = *b; +#ifdef VERIFY + t.magnitude = a->magnitude; + t.normalized = a->normalized; +#endif + return memcmp(a, &t, sizeof(secp256k1_fe)); +} + +void run_field_misc(void) { + secp256k1_fe x; + secp256k1_fe y; + secp256k1_fe z; + secp256k1_fe q; + secp256k1_fe fe5 = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 5); + int i, j; + for (i = 0; i < 5*count; i++) { + secp256k1_fe_storage xs, ys, zs; + random_fe(&x); + random_fe_non_zero(&y); + /* Test the fe equality and comparison operations. */ + CHECK(secp256k1_fe_cmp_var(&x, &x) == 0); + CHECK(secp256k1_fe_equal_var(&x, &x)); + z = x; + secp256k1_fe_add(&z,&y); + /* Test fe conditional move; z is not normalized here. */ + q = x; + secp256k1_fe_cmov(&x, &z, 0); + VERIFY_CHECK(!x.normalized && x.magnitude == z.magnitude); + secp256k1_fe_cmov(&x, &x, 1); + CHECK(fe_memcmp(&x, &z) != 0); + CHECK(fe_memcmp(&x, &q) == 0); + secp256k1_fe_cmov(&q, &z, 1); + VERIFY_CHECK(!q.normalized && q.magnitude == z.magnitude); + CHECK(fe_memcmp(&q, &z) == 0); + secp256k1_fe_normalize_var(&x); + secp256k1_fe_normalize_var(&z); + CHECK(!secp256k1_fe_equal_var(&x, &z)); + secp256k1_fe_normalize_var(&q); + secp256k1_fe_cmov(&q, &z, (i&1)); + VERIFY_CHECK(q.normalized && q.magnitude == 1); + for (j = 0; j < 6; j++) { + secp256k1_fe_negate(&z, &z, j+1); + secp256k1_fe_normalize_var(&q); + secp256k1_fe_cmov(&q, &z, (j&1)); + VERIFY_CHECK(!q.normalized && q.magnitude == (j+2)); + } + secp256k1_fe_normalize_var(&z); + /* Test storage conversion and conditional moves. */ + secp256k1_fe_to_storage(&xs, &x); + secp256k1_fe_to_storage(&ys, &y); + secp256k1_fe_to_storage(&zs, &z); + secp256k1_fe_storage_cmov(&zs, &xs, 0); + secp256k1_fe_storage_cmov(&zs, &zs, 1); + CHECK(memcmp(&xs, &zs, sizeof(xs)) != 0); + secp256k1_fe_storage_cmov(&ys, &xs, 1); + CHECK(memcmp(&xs, &ys, sizeof(xs)) == 0); + secp256k1_fe_from_storage(&x, &xs); + secp256k1_fe_from_storage(&y, &ys); + secp256k1_fe_from_storage(&z, &zs); + /* Test that mul_int, mul, and add agree. */ + secp256k1_fe_add(&y, &x); + secp256k1_fe_add(&y, &x); + z = x; + secp256k1_fe_mul_int(&z, 3); + CHECK(check_fe_equal(&y, &z)); + secp256k1_fe_add(&y, &x); + secp256k1_fe_add(&z, &x); + CHECK(check_fe_equal(&z, &y)); + z = x; + secp256k1_fe_mul_int(&z, 5); + secp256k1_fe_mul(&q, &x, &fe5); + CHECK(check_fe_equal(&z, &q)); + secp256k1_fe_negate(&x, &x, 1); + secp256k1_fe_add(&z, &x); + secp256k1_fe_add(&q, &x); + CHECK(check_fe_equal(&y, &z)); + CHECK(check_fe_equal(&q, &y)); + } +} + +void run_field_inv(void) { + secp256k1_fe x, xi, xii; + int i; + for (i = 0; i < 10*count; i++) { + random_fe_non_zero(&x); + secp256k1_fe_inv(&xi, &x); + CHECK(check_fe_inverse(&x, &xi)); + secp256k1_fe_inv(&xii, &xi); + CHECK(check_fe_equal(&x, &xii)); + } +} + +void run_field_inv_var(void) { + secp256k1_fe x, xi, xii; + int i; + for (i = 0; i < 10*count; i++) { + random_fe_non_zero(&x); + secp256k1_fe_inv_var(&xi, &x); + CHECK(check_fe_inverse(&x, &xi)); + secp256k1_fe_inv_var(&xii, &xi); + CHECK(check_fe_equal(&x, &xii)); + } +} + +void run_field_inv_all_var(void) { + secp256k1_fe x[16], xi[16], xii[16]; + int i; + /* Check it's safe to call for 0 elements */ + secp256k1_fe_inv_all_var(0, xi, x); + for (i = 0; i < count; i++) { + size_t j; + size_t len = secp256k1_rand_int(15) + 1; + for (j = 0; j < len; j++) { + random_fe_non_zero(&x[j]); + } + secp256k1_fe_inv_all_var(len, xi, x); + for (j = 0; j < len; j++) { + CHECK(check_fe_inverse(&x[j], &xi[j])); + } + secp256k1_fe_inv_all_var(len, xii, xi); + for (j = 0; j < len; j++) { + CHECK(check_fe_equal(&x[j], &xii[j])); + } + } +} + +void run_sqr(void) { + secp256k1_fe x, s; + + { + int i; + secp256k1_fe_set_int(&x, 1); + secp256k1_fe_negate(&x, &x, 1); + + for (i = 1; i <= 512; ++i) { + secp256k1_fe_mul_int(&x, 2); + secp256k1_fe_normalize(&x); + secp256k1_fe_sqr(&s, &x); + } + } +} + +void test_sqrt(const secp256k1_fe *a, const secp256k1_fe *k) { + secp256k1_fe r1, r2; + int v = secp256k1_fe_sqrt_var(&r1, a); + CHECK((v == 0) == (k == NULL)); + + if (k != NULL) { + /* Check that the returned root is +/- the given known answer */ + secp256k1_fe_negate(&r2, &r1, 1); + secp256k1_fe_add(&r1, k); secp256k1_fe_add(&r2, k); + secp256k1_fe_normalize(&r1); secp256k1_fe_normalize(&r2); + CHECK(secp256k1_fe_is_zero(&r1) || secp256k1_fe_is_zero(&r2)); + } +} + +void run_sqrt(void) { + secp256k1_fe ns, x, s, t; + int i; + + /* Check sqrt(0) is 0 */ + secp256k1_fe_set_int(&x, 0); + secp256k1_fe_sqr(&s, &x); + test_sqrt(&s, &x); + + /* Check sqrt of small squares (and their negatives) */ + for (i = 1; i <= 100; i++) { + secp256k1_fe_set_int(&x, i); + secp256k1_fe_sqr(&s, &x); + test_sqrt(&s, &x); + secp256k1_fe_negate(&t, &s, 1); + test_sqrt(&t, NULL); + } + + /* Consistency checks for large random values */ + for (i = 0; i < 10; i++) { + int j; + random_fe_non_square(&ns); + for (j = 0; j < count; j++) { + random_fe(&x); + secp256k1_fe_sqr(&s, &x); + test_sqrt(&s, &x); + secp256k1_fe_negate(&t, &s, 1); + test_sqrt(&t, NULL); + secp256k1_fe_mul(&t, &s, &ns); + test_sqrt(&t, NULL); + } + } +} + +/***** GROUP TESTS *****/ + +void ge_equals_ge(const secp256k1_ge *a, const secp256k1_ge *b) { + CHECK(a->infinity == b->infinity); + if (a->infinity) { + return; + } + CHECK(secp256k1_fe_equal_var(&a->x, &b->x)); + CHECK(secp256k1_fe_equal_var(&a->y, &b->y)); +} + +/* This compares jacobian points including their Z, not just their geometric meaning. */ +int gej_xyz_equals_gej(const secp256k1_gej *a, const secp256k1_gej *b) { + secp256k1_gej a2; + secp256k1_gej b2; + int ret = 1; + ret &= a->infinity == b->infinity; + if (ret && !a->infinity) { + a2 = *a; + b2 = *b; + secp256k1_fe_normalize(&a2.x); + secp256k1_fe_normalize(&a2.y); + secp256k1_fe_normalize(&a2.z); + secp256k1_fe_normalize(&b2.x); + secp256k1_fe_normalize(&b2.y); + secp256k1_fe_normalize(&b2.z); + ret &= secp256k1_fe_cmp_var(&a2.x, &b2.x) == 0; + ret &= secp256k1_fe_cmp_var(&a2.y, &b2.y) == 0; + ret &= secp256k1_fe_cmp_var(&a2.z, &b2.z) == 0; + } + return ret; +} + +void ge_equals_gej(const secp256k1_ge *a, const secp256k1_gej *b) { + secp256k1_fe z2s; + secp256k1_fe u1, u2, s1, s2; + CHECK(a->infinity == b->infinity); + if (a->infinity) { + return; + } + /* Check a.x * b.z^2 == b.x && a.y * b.z^3 == b.y, to avoid inverses. */ + secp256k1_fe_sqr(&z2s, &b->z); + secp256k1_fe_mul(&u1, &a->x, &z2s); + u2 = b->x; secp256k1_fe_normalize_weak(&u2); + secp256k1_fe_mul(&s1, &a->y, &z2s); secp256k1_fe_mul(&s1, &s1, &b->z); + s2 = b->y; secp256k1_fe_normalize_weak(&s2); + CHECK(secp256k1_fe_equal_var(&u1, &u2)); + CHECK(secp256k1_fe_equal_var(&s1, &s2)); +} + +void test_ge(void) { + int i, i1; +#ifdef USE_ENDOMORPHISM + int runs = 6; +#else + int runs = 4; +#endif + /* Points: (infinity, p1, p1, -p1, -p1, p2, p2, -p2, -p2, p3, p3, -p3, -p3, p4, p4, -p4, -p4). + * The second in each pair of identical points uses a random Z coordinate in the Jacobian form. + * All magnitudes are randomized. + * All 17*17 combinations of points are added to each other, using all applicable methods. + * + * When the endomorphism code is compiled in, p5 = lambda*p1 and p6 = lambda^2*p1 are added as well. + */ + secp256k1_ge *ge = (secp256k1_ge *)malloc(sizeof(secp256k1_ge) * (1 + 4 * runs)); + secp256k1_gej *gej = (secp256k1_gej *)malloc(sizeof(secp256k1_gej) * (1 + 4 * runs)); + secp256k1_fe *zinv = (secp256k1_fe *)malloc(sizeof(secp256k1_fe) * (1 + 4 * runs)); + secp256k1_fe zf; + secp256k1_fe zfi2, zfi3; + + secp256k1_gej_set_infinity(&gej[0]); + secp256k1_ge_clear(&ge[0]); + secp256k1_ge_set_gej_var(&ge[0], &gej[0]); + for (i = 0; i < runs; i++) { + int j; + secp256k1_ge g; + random_group_element_test(&g); +#ifdef USE_ENDOMORPHISM + if (i >= runs - 2) { + secp256k1_ge_mul_lambda(&g, &ge[1]); + } + if (i >= runs - 1) { + secp256k1_ge_mul_lambda(&g, &g); + } +#endif + ge[1 + 4 * i] = g; + ge[2 + 4 * i] = g; + secp256k1_ge_neg(&ge[3 + 4 * i], &g); + secp256k1_ge_neg(&ge[4 + 4 * i], &g); + secp256k1_gej_set_ge(&gej[1 + 4 * i], &ge[1 + 4 * i]); + random_group_element_jacobian_test(&gej[2 + 4 * i], &ge[2 + 4 * i]); + secp256k1_gej_set_ge(&gej[3 + 4 * i], &ge[3 + 4 * i]); + random_group_element_jacobian_test(&gej[4 + 4 * i], &ge[4 + 4 * i]); + for (j = 0; j < 4; j++) { + random_field_element_magnitude(&ge[1 + j + 4 * i].x); + random_field_element_magnitude(&ge[1 + j + 4 * i].y); + random_field_element_magnitude(&gej[1 + j + 4 * i].x); + random_field_element_magnitude(&gej[1 + j + 4 * i].y); + random_field_element_magnitude(&gej[1 + j + 4 * i].z); + } + } + + /* Compute z inverses. */ + { + secp256k1_fe *zs = malloc(sizeof(secp256k1_fe) * (1 + 4 * runs)); + for (i = 0; i < 4 * runs + 1; i++) { + if (i == 0) { + /* The point at infinity does not have a meaningful z inverse. Any should do. */ + do { + random_field_element_test(&zs[i]); + } while(secp256k1_fe_is_zero(&zs[i])); + } else { + zs[i] = gej[i].z; + } + } + secp256k1_fe_inv_all_var(4 * runs + 1, zinv, zs); + free(zs); + } + + /* Generate random zf, and zfi2 = 1/zf^2, zfi3 = 1/zf^3 */ + do { + random_field_element_test(&zf); + } while(secp256k1_fe_is_zero(&zf)); + random_field_element_magnitude(&zf); + secp256k1_fe_inv_var(&zfi3, &zf); + secp256k1_fe_sqr(&zfi2, &zfi3); + secp256k1_fe_mul(&zfi3, &zfi3, &zfi2); + + for (i1 = 0; i1 < 1 + 4 * runs; i1++) { + int i2; + for (i2 = 0; i2 < 1 + 4 * runs; i2++) { + /* Compute reference result using gej + gej (var). */ + secp256k1_gej refj, resj; + secp256k1_ge ref; + secp256k1_fe zr; + secp256k1_gej_add_var(&refj, &gej[i1], &gej[i2], secp256k1_gej_is_infinity(&gej[i1]) ? NULL : &zr); + /* Check Z ratio. */ + if (!secp256k1_gej_is_infinity(&gej[i1]) && !secp256k1_gej_is_infinity(&refj)) { + secp256k1_fe zrz; secp256k1_fe_mul(&zrz, &zr, &gej[i1].z); + CHECK(secp256k1_fe_equal_var(&zrz, &refj.z)); + } + secp256k1_ge_set_gej_var(&ref, &refj); + + /* Test gej + ge with Z ratio result (var). */ + secp256k1_gej_add_ge_var(&resj, &gej[i1], &ge[i2], secp256k1_gej_is_infinity(&gej[i1]) ? NULL : &zr); + ge_equals_gej(&ref, &resj); + if (!secp256k1_gej_is_infinity(&gej[i1]) && !secp256k1_gej_is_infinity(&resj)) { + secp256k1_fe zrz; secp256k1_fe_mul(&zrz, &zr, &gej[i1].z); + CHECK(secp256k1_fe_equal_var(&zrz, &resj.z)); + } + + /* Test gej + ge (var, with additional Z factor). */ + { + secp256k1_ge ge2_zfi = ge[i2]; /* the second term with x and y rescaled for z = 1/zf */ + secp256k1_fe_mul(&ge2_zfi.x, &ge2_zfi.x, &zfi2); + secp256k1_fe_mul(&ge2_zfi.y, &ge2_zfi.y, &zfi3); + random_field_element_magnitude(&ge2_zfi.x); + random_field_element_magnitude(&ge2_zfi.y); + secp256k1_gej_add_zinv_var(&resj, &gej[i1], &ge2_zfi, &zf); + ge_equals_gej(&ref, &resj); + } + + /* Test gej + ge (const). */ + if (i2 != 0) { + /* secp256k1_gej_add_ge does not support its second argument being infinity. */ + secp256k1_gej_add_ge(&resj, &gej[i1], &ge[i2]); + ge_equals_gej(&ref, &resj); + } + + /* Test doubling (var). */ + if ((i1 == 0 && i2 == 0) || ((i1 + 3)/4 == (i2 + 3)/4 && ((i1 + 3)%4)/2 == ((i2 + 3)%4)/2)) { + secp256k1_fe zr2; + /* Normal doubling with Z ratio result. */ + secp256k1_gej_double_var(&resj, &gej[i1], &zr2); + ge_equals_gej(&ref, &resj); + /* Check Z ratio. */ + secp256k1_fe_mul(&zr2, &zr2, &gej[i1].z); + CHECK(secp256k1_fe_equal_var(&zr2, &resj.z)); + /* Normal doubling. */ + secp256k1_gej_double_var(&resj, &gej[i2], NULL); + ge_equals_gej(&ref, &resj); + } + + /* Test adding opposites. */ + if ((i1 == 0 && i2 == 0) || ((i1 + 3)/4 == (i2 + 3)/4 && ((i1 + 3)%4)/2 != ((i2 + 3)%4)/2)) { + CHECK(secp256k1_ge_is_infinity(&ref)); + } + + /* Test adding infinity. */ + if (i1 == 0) { + CHECK(secp256k1_ge_is_infinity(&ge[i1])); + CHECK(secp256k1_gej_is_infinity(&gej[i1])); + ge_equals_gej(&ref, &gej[i2]); + } + if (i2 == 0) { + CHECK(secp256k1_ge_is_infinity(&ge[i2])); + CHECK(secp256k1_gej_is_infinity(&gej[i2])); + ge_equals_gej(&ref, &gej[i1]); + } + } + } + + /* Test adding all points together in random order equals infinity. */ + { + secp256k1_gej sum = SECP256K1_GEJ_CONST_INFINITY; + secp256k1_gej *gej_shuffled = (secp256k1_gej *)malloc((4 * runs + 1) * sizeof(secp256k1_gej)); + for (i = 0; i < 4 * runs + 1; i++) { + gej_shuffled[i] = gej[i]; + } + for (i = 0; i < 4 * runs + 1; i++) { + int swap = i + secp256k1_rand_int(4 * runs + 1 - i); + if (swap != i) { + secp256k1_gej t = gej_shuffled[i]; + gej_shuffled[i] = gej_shuffled[swap]; + gej_shuffled[swap] = t; + } + } + for (i = 0; i < 4 * runs + 1; i++) { + secp256k1_gej_add_var(&sum, &sum, &gej_shuffled[i], NULL); + } + CHECK(secp256k1_gej_is_infinity(&sum)); + free(gej_shuffled); + } + + /* Test batch gej -> ge conversion with and without known z ratios. */ + { + secp256k1_fe *zr = (secp256k1_fe *)malloc((4 * runs + 1) * sizeof(secp256k1_fe)); + secp256k1_ge *ge_set_table = (secp256k1_ge *)malloc((4 * runs + 1) * sizeof(secp256k1_ge)); + secp256k1_ge *ge_set_all = (secp256k1_ge *)malloc((4 * runs + 1) * sizeof(secp256k1_ge)); + for (i = 0; i < 4 * runs + 1; i++) { + /* Compute gej[i + 1].z / gez[i].z (with gej[n].z taken to be 1). */ + if (i < 4 * runs) { + secp256k1_fe_mul(&zr[i + 1], &zinv[i], &gej[i + 1].z); + } + } + secp256k1_ge_set_table_gej_var(4 * runs + 1, ge_set_table, gej, zr); + secp256k1_ge_set_all_gej_var(4 * runs + 1, ge_set_all, gej, &ctx->error_callback); + for (i = 0; i < 4 * runs + 1; i++) { + secp256k1_fe s; + random_fe_non_zero(&s); + secp256k1_gej_rescale(&gej[i], &s); + ge_equals_gej(&ge_set_table[i], &gej[i]); + ge_equals_gej(&ge_set_all[i], &gej[i]); + } + free(ge_set_table); + free(ge_set_all); + free(zr); + } + + free(ge); + free(gej); + free(zinv); +} + +void test_add_neg_y_diff_x(void) { + /* The point of this test is to check that we can add two points + * whose y-coordinates are negatives of each other but whose x + * coordinates differ. If the x-coordinates were the same, these + * points would be negatives of each other and their sum is + * infinity. This is cool because it "covers up" any degeneracy + * in the addition algorithm that would cause the xy coordinates + * of the sum to be wrong (since infinity has no xy coordinates). + * HOWEVER, if the x-coordinates are different, infinity is the + * wrong answer, and such degeneracies are exposed. This is the + * root of https://github.com/bitcoin/secp256k1/issues/257 which + * this test is a regression test for. + * + * These points were generated in sage as + * # secp256k1 params + * F = FiniteField (0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F) + * C = EllipticCurve ([F (0), F (7)]) + * G = C.lift_x(0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798) + * N = FiniteField(G.order()) + * + * # endomorphism values (lambda is 1^{1/3} in N, beta is 1^{1/3} in F) + * x = polygen(N) + * lam = (1 - x^3).roots()[1][0] + * + * # random "bad pair" + * P = C.random_element() + * Q = -int(lam) * P + * print " P: %x %x" % P.xy() + * print " Q: %x %x" % Q.xy() + * print "P + Q: %x %x" % (P + Q).xy() + */ + secp256k1_gej aj = SECP256K1_GEJ_CONST( + 0x8d24cd95, 0x0a355af1, 0x3c543505, 0x44238d30, + 0x0643d79f, 0x05a59614, 0x2f8ec030, 0xd58977cb, + 0x001e337a, 0x38093dcd, 0x6c0f386d, 0x0b1293a8, + 0x4d72c879, 0xd7681924, 0x44e6d2f3, 0x9190117d + ); + secp256k1_gej bj = SECP256K1_GEJ_CONST( + 0xc7b74206, 0x1f788cd9, 0xabd0937d, 0x164a0d86, + 0x95f6ff75, 0xf19a4ce9, 0xd013bd7b, 0xbf92d2a7, + 0xffe1cc85, 0xc7f6c232, 0x93f0c792, 0xf4ed6c57, + 0xb28d3786, 0x2897e6db, 0xbb192d0b, 0x6e6feab2 + ); + secp256k1_gej sumj = SECP256K1_GEJ_CONST( + 0x671a63c0, 0x3efdad4c, 0x389a7798, 0x24356027, + 0xb3d69010, 0x278625c3, 0x5c86d390, 0x184a8f7a, + 0x5f6409c2, 0x2ce01f2b, 0x511fd375, 0x25071d08, + 0xda651801, 0x70e95caf, 0x8f0d893c, 0xbed8fbbe + ); + secp256k1_ge b; + secp256k1_gej resj; + secp256k1_ge res; + secp256k1_ge_set_gej(&b, &bj); + + secp256k1_gej_add_var(&resj, &aj, &bj, NULL); + secp256k1_ge_set_gej(&res, &resj); + ge_equals_gej(&res, &sumj); + + secp256k1_gej_add_ge(&resj, &aj, &b); + secp256k1_ge_set_gej(&res, &resj); + ge_equals_gej(&res, &sumj); + + secp256k1_gej_add_ge_var(&resj, &aj, &b, NULL); + secp256k1_ge_set_gej(&res, &resj); + ge_equals_gej(&res, &sumj); +} + +void run_ge(void) { + int i; + for (i = 0; i < count * 32; i++) { + test_ge(); + } + test_add_neg_y_diff_x(); +} + +void test_ec_combine(void) { + secp256k1_scalar sum = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 0); + secp256k1_pubkey data[6]; + const secp256k1_pubkey* d[6]; + secp256k1_pubkey sd; + secp256k1_pubkey sd2; + secp256k1_gej Qj; + secp256k1_ge Q; + int i; + for (i = 1; i <= 6; i++) { + secp256k1_scalar s; + random_scalar_order_test(&s); + secp256k1_scalar_add(&sum, &sum, &s); + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &Qj, &s); + secp256k1_ge_set_gej(&Q, &Qj); + secp256k1_pubkey_save(&data[i - 1], &Q); + d[i - 1] = &data[i - 1]; + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &Qj, &sum); + secp256k1_ge_set_gej(&Q, &Qj); + secp256k1_pubkey_save(&sd, &Q); + CHECK(secp256k1_ec_pubkey_combine(ctx, &sd2, d, i) == 1); + CHECK(memcmp(&sd, &sd2, sizeof(sd)) == 0); + } +} + +void run_ec_combine(void) { + int i; + for (i = 0; i < count * 8; i++) { + test_ec_combine(); + } +} + +void test_group_decompress(const secp256k1_fe* x) { + /* The input itself, normalized. */ + secp256k1_fe fex = *x; + secp256k1_fe tmp; + /* Results of set_xquad_var, set_xo_var(..., 0), set_xo_var(..., 1). */ + secp256k1_ge ge_quad, ge_even, ge_odd; + /* Return values of the above calls. */ + int res_quad, res_even, res_odd; + + secp256k1_fe_normalize_var(&fex); + + res_quad = secp256k1_ge_set_xquad_var(&ge_quad, &fex); + res_even = secp256k1_ge_set_xo_var(&ge_even, &fex, 0); + res_odd = secp256k1_ge_set_xo_var(&ge_odd, &fex, 1); + + CHECK(res_quad == res_even); + CHECK(res_quad == res_odd); + + if (res_quad) { + secp256k1_fe_normalize_var(&ge_quad.x); + secp256k1_fe_normalize_var(&ge_odd.x); + secp256k1_fe_normalize_var(&ge_even.x); + secp256k1_fe_normalize_var(&ge_quad.y); + secp256k1_fe_normalize_var(&ge_odd.y); + secp256k1_fe_normalize_var(&ge_even.y); + + /* No infinity allowed. */ + CHECK(!ge_quad.infinity); + CHECK(!ge_even.infinity); + CHECK(!ge_odd.infinity); + + /* Check that the x coordinates check out. */ + CHECK(secp256k1_fe_equal_var(&ge_quad.x, x)); + CHECK(secp256k1_fe_equal_var(&ge_even.x, x)); + CHECK(secp256k1_fe_equal_var(&ge_odd.x, x)); + + /* Check that the Y coordinate result in ge_quad is a square. */ + CHECK(secp256k1_fe_sqrt_var(&tmp, &ge_quad.y)); + secp256k1_fe_sqr(&tmp, &tmp); + CHECK(secp256k1_fe_equal_var(&tmp, &ge_quad.y)); + + /* Check odd/even Y in ge_odd, ge_even. */ + CHECK(secp256k1_fe_is_odd(&ge_odd.y)); + CHECK(!secp256k1_fe_is_odd(&ge_even.y)); + } +} + +void run_group_decompress(void) { + int i; + for (i = 0; i < count * 4; i++) { + secp256k1_fe fe; + random_fe_test(&fe); + test_group_decompress(&fe); + } +} + +/***** ECMULT TESTS *****/ + +void run_ecmult_chain(void) { + /* random starting point A (on the curve) */ + secp256k1_gej a = SECP256K1_GEJ_CONST( + 0x8b30bbe9, 0xae2a9906, 0x96b22f67, 0x0709dff3, + 0x727fd8bc, 0x04d3362c, 0x6c7bf458, 0xe2846004, + 0xa357ae91, 0x5c4a6528, 0x1309edf2, 0x0504740f, + 0x0eb33439, 0x90216b4f, 0x81063cb6, 0x5f2f7e0f + ); + /* two random initial factors xn and gn */ + secp256k1_scalar xn = SECP256K1_SCALAR_CONST( + 0x84cc5452, 0xf7fde1ed, 0xb4d38a8c, 0xe9b1b84c, + 0xcef31f14, 0x6e569be9, 0x705d357a, 0x42985407 + ); + secp256k1_scalar gn = SECP256K1_SCALAR_CONST( + 0xa1e58d22, 0x553dcd42, 0xb2398062, 0x5d4c57a9, + 0x6e9323d4, 0x2b3152e5, 0xca2c3990, 0xedc7c9de + ); + /* two small multipliers to be applied to xn and gn in every iteration: */ + static const secp256k1_scalar xf = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 0x1337); + static const secp256k1_scalar gf = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 0x7113); + /* accumulators with the resulting coefficients to A and G */ + secp256k1_scalar ae = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 1); + secp256k1_scalar ge = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 0); + /* actual points */ + secp256k1_gej x; + secp256k1_gej x2; + int i; + + /* the point being computed */ + x = a; + for (i = 0; i < 200*count; i++) { + /* in each iteration, compute X = xn*X + gn*G; */ + secp256k1_ecmult(&ctx->ecmult_ctx, &x, &x, &xn, &gn); + /* also compute ae and ge: the actual accumulated factors for A and G */ + /* if X was (ae*A+ge*G), xn*X + gn*G results in (xn*ae*A + (xn*ge+gn)*G) */ + secp256k1_scalar_mul(&ae, &ae, &xn); + secp256k1_scalar_mul(&ge, &ge, &xn); + secp256k1_scalar_add(&ge, &ge, &gn); + /* modify xn and gn */ + secp256k1_scalar_mul(&xn, &xn, &xf); + secp256k1_scalar_mul(&gn, &gn, &gf); + + /* verify */ + if (i == 19999) { + /* expected result after 19999 iterations */ + secp256k1_gej rp = SECP256K1_GEJ_CONST( + 0xD6E96687, 0xF9B10D09, 0x2A6F3543, 0x9D86CEBE, + 0xA4535D0D, 0x409F5358, 0x6440BD74, 0xB933E830, + 0xB95CBCA2, 0xC77DA786, 0x539BE8FD, 0x53354D2D, + 0x3B4F566A, 0xE6580454, 0x07ED6015, 0xEE1B2A88 + ); + + secp256k1_gej_neg(&rp, &rp); + secp256k1_gej_add_var(&rp, &rp, &x, NULL); + CHECK(secp256k1_gej_is_infinity(&rp)); + } + } + /* redo the computation, but directly with the resulting ae and ge coefficients: */ + secp256k1_ecmult(&ctx->ecmult_ctx, &x2, &a, &ae, &ge); + secp256k1_gej_neg(&x2, &x2); + secp256k1_gej_add_var(&x2, &x2, &x, NULL); + CHECK(secp256k1_gej_is_infinity(&x2)); +} + +void test_point_times_order(const secp256k1_gej *point) { + /* X * (point + G) + (order-X) * (pointer + G) = 0 */ + secp256k1_scalar x; + secp256k1_scalar nx; + secp256k1_scalar zero = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 0); + secp256k1_scalar one = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 1); + secp256k1_gej res1, res2; + secp256k1_ge res3; + unsigned char pub[65]; + size_t psize = 65; + random_scalar_order_test(&x); + secp256k1_scalar_negate(&nx, &x); + secp256k1_ecmult(&ctx->ecmult_ctx, &res1, point, &x, &x); /* calc res1 = x * point + x * G; */ + secp256k1_ecmult(&ctx->ecmult_ctx, &res2, point, &nx, &nx); /* calc res2 = (order - x) * point + (order - x) * G; */ + secp256k1_gej_add_var(&res1, &res1, &res2, NULL); + CHECK(secp256k1_gej_is_infinity(&res1)); + CHECK(secp256k1_gej_is_valid_var(&res1) == 0); + secp256k1_ge_set_gej(&res3, &res1); + CHECK(secp256k1_ge_is_infinity(&res3)); + CHECK(secp256k1_ge_is_valid_var(&res3) == 0); + CHECK(secp256k1_eckey_pubkey_serialize(&res3, pub, &psize, 0) == 0); + psize = 65; + CHECK(secp256k1_eckey_pubkey_serialize(&res3, pub, &psize, 1) == 0); + /* check zero/one edge cases */ + secp256k1_ecmult(&ctx->ecmult_ctx, &res1, point, &zero, &zero); + secp256k1_ge_set_gej(&res3, &res1); + CHECK(secp256k1_ge_is_infinity(&res3)); + secp256k1_ecmult(&ctx->ecmult_ctx, &res1, point, &one, &zero); + secp256k1_ge_set_gej(&res3, &res1); + ge_equals_gej(&res3, point); + secp256k1_ecmult(&ctx->ecmult_ctx, &res1, point, &zero, &one); + secp256k1_ge_set_gej(&res3, &res1); + ge_equals_ge(&res3, &secp256k1_ge_const_g); +} + +void run_point_times_order(void) { + int i; + secp256k1_fe x = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 2); + static const secp256k1_fe xr = SECP256K1_FE_CONST( + 0x7603CB59, 0xB0EF6C63, 0xFE608479, 0x2A0C378C, + 0xDB3233A8, 0x0F8A9A09, 0xA877DEAD, 0x31B38C45 + ); + for (i = 0; i < 500; i++) { + secp256k1_ge p; + if (secp256k1_ge_set_xo_var(&p, &x, 1)) { + secp256k1_gej j; + CHECK(secp256k1_ge_is_valid_var(&p)); + secp256k1_gej_set_ge(&j, &p); + CHECK(secp256k1_gej_is_valid_var(&j)); + test_point_times_order(&j); + } + secp256k1_fe_sqr(&x, &x); + } + secp256k1_fe_normalize_var(&x); + CHECK(secp256k1_fe_equal_var(&x, &xr)); +} + +void ecmult_const_random_mult(void) { + /* random starting point A (on the curve) */ + secp256k1_ge a = SECP256K1_GE_CONST( + 0x6d986544, 0x57ff52b8, 0xcf1b8126, 0x5b802a5b, + 0xa97f9263, 0xb1e88044, 0x93351325, 0x91bc450a, + 0x535c59f7, 0x325e5d2b, 0xc391fbe8, 0x3c12787c, + 0x337e4a98, 0xe82a9011, 0x0123ba37, 0xdd769c7d + ); + /* random initial factor xn */ + secp256k1_scalar xn = SECP256K1_SCALAR_CONST( + 0x649d4f77, 0xc4242df7, 0x7f2079c9, 0x14530327, + 0xa31b876a, 0xd2d8ce2a, 0x2236d5c6, 0xd7b2029b + ); + /* expected xn * A (from sage) */ + secp256k1_ge expected_b = SECP256K1_GE_CONST( + 0x23773684, 0x4d209dc7, 0x098a786f, 0x20d06fcd, + 0x070a38bf, 0xc11ac651, 0x03004319, 0x1e2a8786, + 0xed8c3b8e, 0xc06dd57b, 0xd06ea66e, 0x45492b0f, + 0xb84e4e1b, 0xfb77e21f, 0x96baae2a, 0x63dec956 + ); + secp256k1_gej b; + secp256k1_ecmult_const(&b, &a, &xn); + + CHECK(secp256k1_ge_is_valid_var(&a)); + ge_equals_gej(&expected_b, &b); +} + +void ecmult_const_commutativity(void) { + secp256k1_scalar a; + secp256k1_scalar b; + secp256k1_gej res1; + secp256k1_gej res2; + secp256k1_ge mid1; + secp256k1_ge mid2; + random_scalar_order_test(&a); + random_scalar_order_test(&b); + + secp256k1_ecmult_const(&res1, &secp256k1_ge_const_g, &a); + secp256k1_ecmult_const(&res2, &secp256k1_ge_const_g, &b); + secp256k1_ge_set_gej(&mid1, &res1); + secp256k1_ge_set_gej(&mid2, &res2); + secp256k1_ecmult_const(&res1, &mid1, &b); + secp256k1_ecmult_const(&res2, &mid2, &a); + secp256k1_ge_set_gej(&mid1, &res1); + secp256k1_ge_set_gej(&mid2, &res2); + ge_equals_ge(&mid1, &mid2); +} + +void ecmult_const_mult_zero_one(void) { + secp256k1_scalar zero = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 0); + secp256k1_scalar one = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 1); + secp256k1_scalar negone; + secp256k1_gej res1; + secp256k1_ge res2; + secp256k1_ge point; + secp256k1_scalar_negate(&negone, &one); + + random_group_element_test(&point); + secp256k1_ecmult_const(&res1, &point, &zero); + secp256k1_ge_set_gej(&res2, &res1); + CHECK(secp256k1_ge_is_infinity(&res2)); + secp256k1_ecmult_const(&res1, &point, &one); + secp256k1_ge_set_gej(&res2, &res1); + ge_equals_ge(&res2, &point); + secp256k1_ecmult_const(&res1, &point, &negone); + secp256k1_gej_neg(&res1, &res1); + secp256k1_ge_set_gej(&res2, &res1); + ge_equals_ge(&res2, &point); +} + +void ecmult_const_chain_multiply(void) { + /* Check known result (randomly generated test problem from sage) */ + const secp256k1_scalar scalar = SECP256K1_SCALAR_CONST( + 0x4968d524, 0x2abf9b7a, 0x466abbcf, 0x34b11b6d, + 0xcd83d307, 0x827bed62, 0x05fad0ce, 0x18fae63b + ); + const secp256k1_gej expected_point = SECP256K1_GEJ_CONST( + 0x5494c15d, 0x32099706, 0xc2395f94, 0x348745fd, + 0x757ce30e, 0x4e8c90fb, 0xa2bad184, 0xf883c69f, + 0x5d195d20, 0xe191bf7f, 0x1be3e55f, 0x56a80196, + 0x6071ad01, 0xf1462f66, 0xc997fa94, 0xdb858435 + ); + secp256k1_gej point; + secp256k1_ge res; + int i; + + secp256k1_gej_set_ge(&point, &secp256k1_ge_const_g); + for (i = 0; i < 100; ++i) { + secp256k1_ge tmp; + secp256k1_ge_set_gej(&tmp, &point); + secp256k1_ecmult_const(&point, &tmp, &scalar); + } + secp256k1_ge_set_gej(&res, &point); + ge_equals_gej(&res, &expected_point); +} + +void run_ecmult_const_tests(void) { + ecmult_const_mult_zero_one(); + ecmult_const_random_mult(); + ecmult_const_commutativity(); + ecmult_const_chain_multiply(); +} + +void test_wnaf(const secp256k1_scalar *number, int w) { + secp256k1_scalar x, two, t; + int wnaf[256]; + int zeroes = -1; + int i; + int bits; + secp256k1_scalar_set_int(&x, 0); + secp256k1_scalar_set_int(&two, 2); + bits = secp256k1_ecmult_wnaf(wnaf, 256, number, w); + CHECK(bits <= 256); + for (i = bits-1; i >= 0; i--) { + int v = wnaf[i]; + secp256k1_scalar_mul(&x, &x, &two); + if (v) { + CHECK(zeroes == -1 || zeroes >= w-1); /* check that distance between non-zero elements is at least w-1 */ + zeroes=0; + CHECK((v & 1) == 1); /* check non-zero elements are odd */ + CHECK(v <= (1 << (w-1)) - 1); /* check range below */ + CHECK(v >= -(1 << (w-1)) - 1); /* check range above */ + } else { + CHECK(zeroes != -1); /* check that no unnecessary zero padding exists */ + zeroes++; + } + if (v >= 0) { + secp256k1_scalar_set_int(&t, v); + } else { + secp256k1_scalar_set_int(&t, -v); + secp256k1_scalar_negate(&t, &t); + } + secp256k1_scalar_add(&x, &x, &t); + } + CHECK(secp256k1_scalar_eq(&x, number)); /* check that wnaf represents number */ +} + +void test_constant_wnaf_negate(const secp256k1_scalar *number) { + secp256k1_scalar neg1 = *number; + secp256k1_scalar neg2 = *number; + int sign1 = 1; + int sign2 = 1; + + if (!secp256k1_scalar_get_bits(&neg1, 0, 1)) { + secp256k1_scalar_negate(&neg1, &neg1); + sign1 = -1; + } + sign2 = secp256k1_scalar_cond_negate(&neg2, secp256k1_scalar_is_even(&neg2)); + CHECK(sign1 == sign2); + CHECK(secp256k1_scalar_eq(&neg1, &neg2)); +} + +void test_constant_wnaf(const secp256k1_scalar *number, int w) { + secp256k1_scalar x, shift; + int wnaf[256] = {0}; + int i; +#ifdef USE_ENDOMORPHISM + int skew; +#endif + secp256k1_scalar num = *number; + + secp256k1_scalar_set_int(&x, 0); + secp256k1_scalar_set_int(&shift, 1 << w); + /* With USE_ENDOMORPHISM on we only consider 128-bit numbers */ +#ifdef USE_ENDOMORPHISM + for (i = 0; i < 16; ++i) { + secp256k1_scalar_shr_int(&num, 8); + } + skew = secp256k1_wnaf_const(wnaf, num, w); +#else + secp256k1_wnaf_const(wnaf, num, w); +#endif + + for (i = WNAF_SIZE(w); i >= 0; --i) { + secp256k1_scalar t; + int v = wnaf[i]; + CHECK(v != 0); /* check nonzero */ + CHECK(v & 1); /* check parity */ + CHECK(v > -(1 << w)); /* check range above */ + CHECK(v < (1 << w)); /* check range below */ + + secp256k1_scalar_mul(&x, &x, &shift); + if (v >= 0) { + secp256k1_scalar_set_int(&t, v); + } else { + secp256k1_scalar_set_int(&t, -v); + secp256k1_scalar_negate(&t, &t); + } + secp256k1_scalar_add(&x, &x, &t); + } +#ifdef USE_ENDOMORPHISM + /* Skew num because when encoding 128-bit numbers as odd we use an offset */ + secp256k1_scalar_cadd_bit(&num, skew == 2, 1); +#endif + CHECK(secp256k1_scalar_eq(&x, &num)); +} + +void run_wnaf(void) { + int i; + secp256k1_scalar n = {{0}}; + + /* Sanity check: 1 and 2 are the smallest odd and even numbers and should + * have easier-to-diagnose failure modes */ + n.d[0] = 1; + test_constant_wnaf(&n, 4); + n.d[0] = 2; + test_constant_wnaf(&n, 4); + /* Random tests */ + for (i = 0; i < count; i++) { + random_scalar_order(&n); + test_wnaf(&n, 4+(i%10)); + test_constant_wnaf_negate(&n); + test_constant_wnaf(&n, 4 + (i % 10)); + } + secp256k1_scalar_set_int(&n, 0); + CHECK(secp256k1_scalar_cond_negate(&n, 1) == -1); + CHECK(secp256k1_scalar_is_zero(&n)); + CHECK(secp256k1_scalar_cond_negate(&n, 0) == 1); + CHECK(secp256k1_scalar_is_zero(&n)); +} + +void test_ecmult_constants(void) { + /* Test ecmult_gen() for [0..36) and [order-36..0). */ + secp256k1_scalar x; + secp256k1_gej r; + secp256k1_ge ng; + int i; + int j; + secp256k1_ge_neg(&ng, &secp256k1_ge_const_g); + for (i = 0; i < 36; i++ ) { + secp256k1_scalar_set_int(&x, i); + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &r, &x); + for (j = 0; j < i; j++) { + if (j == i - 1) { + ge_equals_gej(&secp256k1_ge_const_g, &r); + } + secp256k1_gej_add_ge(&r, &r, &ng); + } + CHECK(secp256k1_gej_is_infinity(&r)); + } + for (i = 1; i <= 36; i++ ) { + secp256k1_scalar_set_int(&x, i); + secp256k1_scalar_negate(&x, &x); + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &r, &x); + for (j = 0; j < i; j++) { + if (j == i - 1) { + ge_equals_gej(&ng, &r); + } + secp256k1_gej_add_ge(&r, &r, &secp256k1_ge_const_g); + } + CHECK(secp256k1_gej_is_infinity(&r)); + } +} + +void run_ecmult_constants(void) { + test_ecmult_constants(); +} + +void test_ecmult_gen_blind(void) { + /* Test ecmult_gen() blinding and confirm that the blinding changes, the affine points match, and the z's don't match. */ + secp256k1_scalar key; + secp256k1_scalar b; + unsigned char seed32[32]; + secp256k1_gej pgej; + secp256k1_gej pgej2; + secp256k1_gej i; + secp256k1_ge pge; + random_scalar_order_test(&key); + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &pgej, &key); + secp256k1_rand256(seed32); + b = ctx->ecmult_gen_ctx.blind; + i = ctx->ecmult_gen_ctx.initial; + secp256k1_ecmult_gen_blind(&ctx->ecmult_gen_ctx, seed32); + CHECK(!secp256k1_scalar_eq(&b, &ctx->ecmult_gen_ctx.blind)); + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &pgej2, &key); + CHECK(!gej_xyz_equals_gej(&pgej, &pgej2)); + CHECK(!gej_xyz_equals_gej(&i, &ctx->ecmult_gen_ctx.initial)); + secp256k1_ge_set_gej(&pge, &pgej); + ge_equals_gej(&pge, &pgej2); +} + +void test_ecmult_gen_blind_reset(void) { + /* Test ecmult_gen() blinding reset and confirm that the blinding is consistent. */ + secp256k1_scalar b; + secp256k1_gej initial; + secp256k1_ecmult_gen_blind(&ctx->ecmult_gen_ctx, 0); + b = ctx->ecmult_gen_ctx.blind; + initial = ctx->ecmult_gen_ctx.initial; + secp256k1_ecmult_gen_blind(&ctx->ecmult_gen_ctx, 0); + CHECK(secp256k1_scalar_eq(&b, &ctx->ecmult_gen_ctx.blind)); + CHECK(gej_xyz_equals_gej(&initial, &ctx->ecmult_gen_ctx.initial)); +} + +void run_ecmult_gen_blind(void) { + int i; + test_ecmult_gen_blind_reset(); + for (i = 0; i < 10; i++) { + test_ecmult_gen_blind(); + } +} + +#ifdef USE_ENDOMORPHISM +/***** ENDOMORPHISH TESTS *****/ +void test_scalar_split(void) { + secp256k1_scalar full; + secp256k1_scalar s1, slam; + const unsigned char zero[32] = {0}; + unsigned char tmp[32]; + + random_scalar_order_test(&full); + secp256k1_scalar_split_lambda(&s1, &slam, &full); + + /* check that both are <= 128 bits in size */ + if (secp256k1_scalar_is_high(&s1)) { + secp256k1_scalar_negate(&s1, &s1); + } + if (secp256k1_scalar_is_high(&slam)) { + secp256k1_scalar_negate(&slam, &slam); + } + + secp256k1_scalar_get_b32(tmp, &s1); + CHECK(memcmp(zero, tmp, 16) == 0); + secp256k1_scalar_get_b32(tmp, &slam); + CHECK(memcmp(zero, tmp, 16) == 0); +} + +void run_endomorphism_tests(void) { + test_scalar_split(); +} +#endif + +void ec_pubkey_parse_pointtest(const unsigned char *input, int xvalid, int yvalid) { + unsigned char pubkeyc[65]; + secp256k1_pubkey pubkey; + secp256k1_ge ge; + size_t pubkeyclen; + int32_t ecount; + ecount = 0; + secp256k1_context_set_illegal_callback(ctx, counting_illegal_callback_fn, &ecount); + for (pubkeyclen = 3; pubkeyclen <= 65; pubkeyclen++) { + /* Smaller sizes are tested exhaustively elsewhere. */ + int32_t i; + memcpy(&pubkeyc[1], input, 64); + VG_UNDEF(&pubkeyc[pubkeyclen], 65 - pubkeyclen); + for (i = 0; i < 256; i++) { + /* Try all type bytes. */ + int xpass; + int ypass; + int ysign; + pubkeyc[0] = i; + /* What sign does this point have? */ + ysign = (input[63] & 1) + 2; + /* For the current type (i) do we expect parsing to work? Handled all of compressed/uncompressed/hybrid. */ + xpass = xvalid && (pubkeyclen == 33) && ((i & 254) == 2); + /* Do we expect a parse and re-serialize as uncompressed to give a matching y? */ + ypass = xvalid && yvalid && ((i & 4) == ((pubkeyclen == 65) << 2)) && + ((i == 4) || ((i & 251) == ysign)) && ((pubkeyclen == 33) || (pubkeyclen == 65)); + if (xpass || ypass) { + /* These cases must parse. */ + unsigned char pubkeyo[65]; + size_t outl; + memset(&pubkey, 0, sizeof(pubkey)); + VG_UNDEF(&pubkey, sizeof(pubkey)); + ecount = 0; + CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeyc, pubkeyclen) == 1); + VG_CHECK(&pubkey, sizeof(pubkey)); + outl = 65; + VG_UNDEF(pubkeyo, 65); + CHECK(secp256k1_ec_pubkey_serialize(ctx, pubkeyo, &outl, &pubkey, SECP256K1_EC_COMPRESSED) == 1); + VG_CHECK(pubkeyo, outl); + CHECK(outl == 33); + CHECK(memcmp(&pubkeyo[1], &pubkeyc[1], 32) == 0); + CHECK((pubkeyclen != 33) || (pubkeyo[0] == pubkeyc[0])); + if (ypass) { + /* This test isn't always done because we decode with alternative signs, so the y won't match. */ + CHECK(pubkeyo[0] == ysign); + CHECK(secp256k1_pubkey_load(ctx, &ge, &pubkey) == 1); + memset(&pubkey, 0, sizeof(pubkey)); + VG_UNDEF(&pubkey, sizeof(pubkey)); + secp256k1_pubkey_save(&pubkey, &ge); + VG_CHECK(&pubkey, sizeof(pubkey)); + outl = 65; + VG_UNDEF(pubkeyo, 65); + CHECK(secp256k1_ec_pubkey_serialize(ctx, pubkeyo, &outl, &pubkey, SECP256K1_EC_UNCOMPRESSED) == 1); + VG_CHECK(pubkeyo, outl); + CHECK(outl == 65); + CHECK(pubkeyo[0] == 4); + CHECK(memcmp(&pubkeyo[1], input, 64) == 0); + } + CHECK(ecount == 0); + } else { + /* These cases must fail to parse. */ + memset(&pubkey, 0xfe, sizeof(pubkey)); + ecount = 0; + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeyc, pubkeyclen) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(ecount == 0); + CHECK(secp256k1_pubkey_load(ctx, &ge, &pubkey) == 0); + CHECK(ecount == 1); + } + } + } + secp256k1_context_set_illegal_callback(ctx, NULL, NULL); +} + +void run_ec_pubkey_parse_test(void) { +#define SECP256K1_EC_PARSE_TEST_NVALID (12) + const unsigned char valid[SECP256K1_EC_PARSE_TEST_NVALID][64] = { + { + /* Point with leading and trailing zeros in x and y serialization. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x52, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x64, 0xef, 0xa1, 0x7b, 0x77, 0x61, 0xe1, 0xe4, 0x27, 0x06, 0x98, 0x9f, 0xb4, 0x83, + 0xb8, 0xd2, 0xd4, 0x9b, 0xf7, 0x8f, 0xae, 0x98, 0x03, 0xf0, 0x99, 0xb8, 0x34, 0xed, 0xeb, 0x00 + }, + { + /* Point with x equal to a 3rd root of unity.*/ + 0x7a, 0xe9, 0x6a, 0x2b, 0x65, 0x7c, 0x07, 0x10, 0x6e, 0x64, 0x47, 0x9e, 0xac, 0x34, 0x34, 0xe9, + 0x9c, 0xf0, 0x49, 0x75, 0x12, 0xf5, 0x89, 0x95, 0xc1, 0x39, 0x6c, 0x28, 0x71, 0x95, 0x01, 0xee, + 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14, + 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee, + }, + { + /* Point with largest x. (1/2) */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2c, + 0x0e, 0x99, 0x4b, 0x14, 0xea, 0x72, 0xf8, 0xc3, 0xeb, 0x95, 0xc7, 0x1e, 0xf6, 0x92, 0x57, 0x5e, + 0x77, 0x50, 0x58, 0x33, 0x2d, 0x7e, 0x52, 0xd0, 0x99, 0x5c, 0xf8, 0x03, 0x88, 0x71, 0xb6, 0x7d, + }, + { + /* Point with largest x. (2/2) */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2c, + 0xf1, 0x66, 0xb4, 0xeb, 0x15, 0x8d, 0x07, 0x3c, 0x14, 0x6a, 0x38, 0xe1, 0x09, 0x6d, 0xa8, 0xa1, + 0x88, 0xaf, 0xa7, 0xcc, 0xd2, 0x81, 0xad, 0x2f, 0x66, 0xa3, 0x07, 0xfb, 0x77, 0x8e, 0x45, 0xb2, + }, + { + /* Point with smallest x. (1/2) */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14, + 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee, + }, + { + /* Point with smallest x. (2/2) */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0xbd, 0xe7, 0x0d, 0xf5, 0x19, 0x39, 0xb9, 0x4c, 0x9c, 0x24, 0x97, 0x9f, 0xa7, 0xdd, 0x04, 0xeb, + 0xd9, 0xb3, 0x57, 0x2d, 0xa7, 0x80, 0x22, 0x90, 0x43, 0x8a, 0xf2, 0xa6, 0x81, 0x89, 0x54, 0x41, + }, + { + /* Point with largest y. (1/3) */ + 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6, + 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e, + }, + { + /* Point with largest y. (2/3) */ + 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c, + 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e, + }, + { + /* Point with largest y. (3/3) */ + 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc, + 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e, + }, + { + /* Point with smallest y. (1/3) */ + 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6, + 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }, + { + /* Point with smallest y. (2/3) */ + 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c, + 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }, + { + /* Point with smallest y. (3/3) */ + 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc, + 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 + } + }; +#define SECP256K1_EC_PARSE_TEST_NXVALID (4) + const unsigned char onlyxvalid[SECP256K1_EC_PARSE_TEST_NXVALID][64] = { + { + /* Valid if y overflow ignored (y = 1 mod p). (1/3) */ + 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6, + 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30, + }, + { + /* Valid if y overflow ignored (y = 1 mod p). (2/3) */ + 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c, + 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30, + }, + { + /* Valid if y overflow ignored (y = 1 mod p). (3/3)*/ + 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc, + 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30, + }, + { + /* x on curve, y is from y^2 = x^3 + 8. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 + } + }; +#define SECP256K1_EC_PARSE_TEST_NINVALID (7) + const unsigned char invalid[SECP256K1_EC_PARSE_TEST_NINVALID][64] = { + { + /* x is third root of -8, y is -1 * (x^3+7); also on the curve for y^2 = x^3 + 9. */ + 0x0a, 0x2d, 0x2b, 0xa9, 0x35, 0x07, 0xf1, 0xdf, 0x23, 0x37, 0x70, 0xc2, 0xa7, 0x97, 0x96, 0x2c, + 0xc6, 0x1f, 0x6d, 0x15, 0xda, 0x14, 0xec, 0xd4, 0x7d, 0x8d, 0x27, 0xae, 0x1c, 0xd5, 0xf8, 0x53, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }, + { + /* Valid if x overflow ignored (x = 1 mod p). */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30, + 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14, + 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee, + }, + { + /* Valid if x overflow ignored (x = 1 mod p). */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30, + 0xbd, 0xe7, 0x0d, 0xf5, 0x19, 0x39, 0xb9, 0x4c, 0x9c, 0x24, 0x97, 0x9f, 0xa7, 0xdd, 0x04, 0xeb, + 0xd9, 0xb3, 0x57, 0x2d, 0xa7, 0x80, 0x22, 0x90, 0x43, 0x8a, 0xf2, 0xa6, 0x81, 0x89, 0x54, 0x41, + }, + { + /* x is -1, y is the result of the sqrt ladder; also on the curve for y^2 = x^3 - 5. */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e, + 0xf4, 0x84, 0x14, 0x5c, 0xb0, 0x14, 0x9b, 0x82, 0x5d, 0xff, 0x41, 0x2f, 0xa0, 0x52, 0xa8, 0x3f, + 0xcb, 0x72, 0xdb, 0x61, 0xd5, 0x6f, 0x37, 0x70, 0xce, 0x06, 0x6b, 0x73, 0x49, 0xa2, 0xaa, 0x28, + }, + { + /* x is -1, y is the result of the sqrt ladder; also on the curve for y^2 = x^3 - 5. */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e, + 0x0b, 0x7b, 0xeb, 0xa3, 0x4f, 0xeb, 0x64, 0x7d, 0xa2, 0x00, 0xbe, 0xd0, 0x5f, 0xad, 0x57, 0xc0, + 0x34, 0x8d, 0x24, 0x9e, 0x2a, 0x90, 0xc8, 0x8f, 0x31, 0xf9, 0x94, 0x8b, 0xb6, 0x5d, 0x52, 0x07, + }, + { + /* x is zero, y is the result of the sqrt ladder; also on the curve for y^2 = x^3 - 7. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x8f, 0x53, 0x7e, 0xef, 0xdf, 0xc1, 0x60, 0x6a, 0x07, 0x27, 0xcd, 0x69, 0xb4, 0xa7, 0x33, 0x3d, + 0x38, 0xed, 0x44, 0xe3, 0x93, 0x2a, 0x71, 0x79, 0xee, 0xcb, 0x4b, 0x6f, 0xba, 0x93, 0x60, 0xdc, + }, + { + /* x is zero, y is the result of the sqrt ladder; also on the curve for y^2 = x^3 - 7. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x70, 0xac, 0x81, 0x10, 0x20, 0x3e, 0x9f, 0x95, 0xf8, 0xd8, 0x32, 0x96, 0x4b, 0x58, 0xcc, 0xc2, + 0xc7, 0x12, 0xbb, 0x1c, 0x6c, 0xd5, 0x8e, 0x86, 0x11, 0x34, 0xb4, 0x8f, 0x45, 0x6c, 0x9b, 0x53 + } + }; + const unsigned char pubkeyc[66] = { + /* Serialization of G. */ + 0x04, 0x79, 0xBE, 0x66, 0x7E, 0xF9, 0xDC, 0xBB, 0xAC, 0x55, 0xA0, 0x62, 0x95, 0xCE, 0x87, 0x0B, + 0x07, 0x02, 0x9B, 0xFC, 0xDB, 0x2D, 0xCE, 0x28, 0xD9, 0x59, 0xF2, 0x81, 0x5B, 0x16, 0xF8, 0x17, + 0x98, 0x48, 0x3A, 0xDA, 0x77, 0x26, 0xA3, 0xC4, 0x65, 0x5D, 0xA4, 0xFB, 0xFC, 0x0E, 0x11, 0x08, + 0xA8, 0xFD, 0x17, 0xB4, 0x48, 0xA6, 0x85, 0x54, 0x19, 0x9C, 0x47, 0xD0, 0x8F, 0xFB, 0x10, 0xD4, + 0xB8, 0x00 + }; + unsigned char sout[65]; + unsigned char shortkey[2]; + secp256k1_ge ge; + secp256k1_pubkey pubkey; + size_t len; + int32_t i; + int32_t ecount; + int32_t ecount2; + ecount = 0; + /* Nothing should be reading this far into pubkeyc. */ + VG_UNDEF(&pubkeyc[65], 1); + secp256k1_context_set_illegal_callback(ctx, counting_illegal_callback_fn, &ecount); + /* Zero length claimed, fail, zeroize, no illegal arg error. */ + memset(&pubkey, 0xfe, sizeof(pubkey)); + ecount = 0; + VG_UNDEF(shortkey, 2); + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, shortkey, 0) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(ecount == 0); + CHECK(secp256k1_pubkey_load(ctx, &ge, &pubkey) == 0); + CHECK(ecount == 1); + /* Length one claimed, fail, zeroize, no illegal arg error. */ + for (i = 0; i < 256 ; i++) { + memset(&pubkey, 0xfe, sizeof(pubkey)); + ecount = 0; + shortkey[0] = i; + VG_UNDEF(&shortkey[1], 1); + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, shortkey, 1) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(ecount == 0); + CHECK(secp256k1_pubkey_load(ctx, &ge, &pubkey) == 0); + CHECK(ecount == 1); + } + /* Length two claimed, fail, zeroize, no illegal arg error. */ + for (i = 0; i < 65536 ; i++) { + memset(&pubkey, 0xfe, sizeof(pubkey)); + ecount = 0; + shortkey[0] = i & 255; + shortkey[1] = i >> 8; + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, shortkey, 2) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(ecount == 0); + CHECK(secp256k1_pubkey_load(ctx, &ge, &pubkey) == 0); + CHECK(ecount == 1); + } + memset(&pubkey, 0xfe, sizeof(pubkey)); + ecount = 0; + VG_UNDEF(&pubkey, sizeof(pubkey)); + /* 33 bytes claimed on otherwise valid input starting with 0x04, fail, zeroize output, no illegal arg error. */ + CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeyc, 33) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(ecount == 0); + CHECK(secp256k1_pubkey_load(ctx, &ge, &pubkey) == 0); + CHECK(ecount == 1); + /* NULL pubkey, illegal arg error. Pubkey isn't rewritten before this step, since it's NULL into the parser. */ + CHECK(secp256k1_ec_pubkey_parse(ctx, NULL, pubkeyc, 65) == 0); + CHECK(ecount == 2); + /* NULL input string. Illegal arg and zeroize output. */ + memset(&pubkey, 0xfe, sizeof(pubkey)); + ecount = 0; + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, NULL, 65) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(ecount == 1); + CHECK(secp256k1_pubkey_load(ctx, &ge, &pubkey) == 0); + CHECK(ecount == 2); + /* 64 bytes claimed on input starting with 0x04, fail, zeroize output, no illegal arg error. */ + memset(&pubkey, 0xfe, sizeof(pubkey)); + ecount = 0; + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeyc, 64) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(ecount == 0); + CHECK(secp256k1_pubkey_load(ctx, &ge, &pubkey) == 0); + CHECK(ecount == 1); + /* 66 bytes claimed, fail, zeroize output, no illegal arg error. */ + memset(&pubkey, 0xfe, sizeof(pubkey)); + ecount = 0; + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeyc, 66) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(ecount == 0); + CHECK(secp256k1_pubkey_load(ctx, &ge, &pubkey) == 0); + CHECK(ecount == 1); + /* Valid parse. */ + memset(&pubkey, 0, sizeof(pubkey)); + ecount = 0; + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeyc, 65) == 1); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(ecount == 0); + VG_UNDEF(&ge, sizeof(ge)); + CHECK(secp256k1_pubkey_load(ctx, &ge, &pubkey) == 1); + VG_CHECK(&ge.x, sizeof(ge.x)); + VG_CHECK(&ge.y, sizeof(ge.y)); + VG_CHECK(&ge.infinity, sizeof(ge.infinity)); + ge_equals_ge(&secp256k1_ge_const_g, &ge); + CHECK(ecount == 0); + /* secp256k1_ec_pubkey_serialize illegal args. */ + ecount = 0; + len = 65; + CHECK(secp256k1_ec_pubkey_serialize(ctx, NULL, &len, &pubkey, SECP256K1_EC_UNCOMPRESSED) == 0); + CHECK(ecount == 1); + CHECK(len == 0); + CHECK(secp256k1_ec_pubkey_serialize(ctx, sout, NULL, &pubkey, SECP256K1_EC_UNCOMPRESSED) == 0); + CHECK(ecount == 2); + len = 65; + VG_UNDEF(sout, 65); + CHECK(secp256k1_ec_pubkey_serialize(ctx, sout, &len, NULL, SECP256K1_EC_UNCOMPRESSED) == 0); + VG_CHECK(sout, 65); + CHECK(ecount == 3); + CHECK(len == 0); + len = 65; + CHECK(secp256k1_ec_pubkey_serialize(ctx, sout, &len, &pubkey, ~0) == 0); + CHECK(ecount == 4); + CHECK(len == 0); + len = 65; + VG_UNDEF(sout, 65); + CHECK(secp256k1_ec_pubkey_serialize(ctx, sout, &len, &pubkey, SECP256K1_EC_UNCOMPRESSED) == 1); + VG_CHECK(sout, 65); + CHECK(ecount == 4); + CHECK(len == 65); + /* Multiple illegal args. Should still set arg error only once. */ + ecount = 0; + ecount2 = 11; + CHECK(secp256k1_ec_pubkey_parse(ctx, NULL, NULL, 65) == 0); + CHECK(ecount == 1); + /* Does the illegal arg callback actually change the behavior? */ + secp256k1_context_set_illegal_callback(ctx, uncounting_illegal_callback_fn, &ecount2); + CHECK(secp256k1_ec_pubkey_parse(ctx, NULL, NULL, 65) == 0); + CHECK(ecount == 1); + CHECK(ecount2 == 10); + secp256k1_context_set_illegal_callback(ctx, NULL, NULL); + /* Try a bunch of prefabbed points with all possible encodings. */ + for (i = 0; i < SECP256K1_EC_PARSE_TEST_NVALID; i++) { + ec_pubkey_parse_pointtest(valid[i], 1, 1); + } + for (i = 0; i < SECP256K1_EC_PARSE_TEST_NXVALID; i++) { + ec_pubkey_parse_pointtest(onlyxvalid[i], 1, 0); + } + for (i = 0; i < SECP256K1_EC_PARSE_TEST_NINVALID; i++) { + ec_pubkey_parse_pointtest(invalid[i], 0, 0); + } +} + +void run_eckey_edge_case_test(void) { + const unsigned char orderc[32] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, + 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41 + }; + const unsigned char zeros[sizeof(secp256k1_pubkey)] = {0x00}; + unsigned char ctmp[33]; + unsigned char ctmp2[33]; + secp256k1_pubkey pubkey; + secp256k1_pubkey pubkey2; + secp256k1_pubkey pubkey_one; + secp256k1_pubkey pubkey_negone; + const secp256k1_pubkey *pubkeys[3]; + size_t len; + int32_t ecount; + /* Group order is too large, reject. */ + CHECK(secp256k1_ec_seckey_verify(ctx, orderc) == 0); + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, orderc) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0); + /* Maximum value is too large, reject. */ + memset(ctmp, 255, 32); + CHECK(secp256k1_ec_seckey_verify(ctx, ctmp) == 0); + memset(&pubkey, 1, sizeof(pubkey)); + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, ctmp) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0); + /* Zero is too small, reject. */ + memset(ctmp, 0, 32); + CHECK(secp256k1_ec_seckey_verify(ctx, ctmp) == 0); + memset(&pubkey, 1, sizeof(pubkey)); + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, ctmp) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0); + /* One must be accepted. */ + ctmp[31] = 0x01; + CHECK(secp256k1_ec_seckey_verify(ctx, ctmp) == 1); + memset(&pubkey, 0, sizeof(pubkey)); + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, ctmp) == 1); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) > 0); + pubkey_one = pubkey; + /* Group order + 1 is too large, reject. */ + memcpy(ctmp, orderc, 32); + ctmp[31] = 0x42; + CHECK(secp256k1_ec_seckey_verify(ctx, ctmp) == 0); + memset(&pubkey, 1, sizeof(pubkey)); + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, ctmp) == 0); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0); + /* -1 must be accepted. */ + ctmp[31] = 0x40; + CHECK(secp256k1_ec_seckey_verify(ctx, ctmp) == 1); + memset(&pubkey, 0, sizeof(pubkey)); + VG_UNDEF(&pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, ctmp) == 1); + VG_CHECK(&pubkey, sizeof(pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) > 0); + pubkey_negone = pubkey; + /* Tweak of zero leaves the value changed. */ + memset(ctmp2, 0, 32); + CHECK(secp256k1_ec_privkey_tweak_add(ctx, ctmp, ctmp2) == 1); + CHECK(memcmp(orderc, ctmp, 31) == 0 && ctmp[31] == 0x40); + memcpy(&pubkey2, &pubkey, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_tweak_add(ctx, &pubkey, ctmp2) == 1); + CHECK(memcmp(&pubkey, &pubkey2, sizeof(pubkey)) == 0); + /* Multiply tweak of zero zeroizes the output. */ + CHECK(secp256k1_ec_privkey_tweak_mul(ctx, ctmp, ctmp2) == 0); + CHECK(memcmp(zeros, ctmp, 32) == 0); + CHECK(secp256k1_ec_pubkey_tweak_mul(ctx, &pubkey, ctmp2) == 0); + CHECK(memcmp(&pubkey, zeros, sizeof(pubkey)) == 0); + memcpy(&pubkey, &pubkey2, sizeof(pubkey)); + /* Overflowing key tweak zeroizes. */ + memcpy(ctmp, orderc, 32); + ctmp[31] = 0x40; + CHECK(secp256k1_ec_privkey_tweak_add(ctx, ctmp, orderc) == 0); + CHECK(memcmp(zeros, ctmp, 32) == 0); + memcpy(ctmp, orderc, 32); + ctmp[31] = 0x40; + CHECK(secp256k1_ec_privkey_tweak_mul(ctx, ctmp, orderc) == 0); + CHECK(memcmp(zeros, ctmp, 32) == 0); + memcpy(ctmp, orderc, 32); + ctmp[31] = 0x40; + CHECK(secp256k1_ec_pubkey_tweak_add(ctx, &pubkey, orderc) == 0); + CHECK(memcmp(&pubkey, zeros, sizeof(pubkey)) == 0); + memcpy(&pubkey, &pubkey2, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_tweak_mul(ctx, &pubkey, orderc) == 0); + CHECK(memcmp(&pubkey, zeros, sizeof(pubkey)) == 0); + memcpy(&pubkey, &pubkey2, sizeof(pubkey)); + /* Private key tweaks results in a key of zero. */ + ctmp2[31] = 1; + CHECK(secp256k1_ec_privkey_tweak_add(ctx, ctmp2, ctmp) == 0); + CHECK(memcmp(zeros, ctmp2, 32) == 0); + ctmp2[31] = 1; + CHECK(secp256k1_ec_pubkey_tweak_add(ctx, &pubkey, ctmp2) == 0); + CHECK(memcmp(&pubkey, zeros, sizeof(pubkey)) == 0); + memcpy(&pubkey, &pubkey2, sizeof(pubkey)); + /* Tweak computation wraps and results in a key of 1. */ + ctmp2[31] = 2; + CHECK(secp256k1_ec_privkey_tweak_add(ctx, ctmp2, ctmp) == 1); + CHECK(memcmp(ctmp2, zeros, 31) == 0 && ctmp2[31] == 1); + ctmp2[31] = 2; + CHECK(secp256k1_ec_pubkey_tweak_add(ctx, &pubkey, ctmp2) == 1); + ctmp2[31] = 1; + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey2, ctmp2) == 1); + CHECK(memcmp(&pubkey, &pubkey2, sizeof(pubkey)) == 0); + /* Tweak mul * 2 = 1+1. */ + CHECK(secp256k1_ec_pubkey_tweak_add(ctx, &pubkey, ctmp2) == 1); + ctmp2[31] = 2; + CHECK(secp256k1_ec_pubkey_tweak_mul(ctx, &pubkey2, ctmp2) == 1); + CHECK(memcmp(&pubkey, &pubkey2, sizeof(pubkey)) == 0); + /* Test argument errors. */ + ecount = 0; + secp256k1_context_set_illegal_callback(ctx, counting_illegal_callback_fn, &ecount); + CHECK(ecount == 0); + /* Zeroize pubkey on parse error. */ + memset(&pubkey, 0, 32); + CHECK(secp256k1_ec_pubkey_tweak_add(ctx, &pubkey, ctmp2) == 0); + CHECK(ecount == 1); + CHECK(memcmp(&pubkey, zeros, sizeof(pubkey)) == 0); + memcpy(&pubkey, &pubkey2, sizeof(pubkey)); + memset(&pubkey2, 0, 32); + CHECK(secp256k1_ec_pubkey_tweak_mul(ctx, &pubkey2, ctmp2) == 0); + CHECK(ecount == 2); + CHECK(memcmp(&pubkey2, zeros, sizeof(pubkey2)) == 0); + /* Plain argument errors. */ + ecount = 0; + CHECK(secp256k1_ec_seckey_verify(ctx, ctmp) == 1); + CHECK(ecount == 0); + CHECK(secp256k1_ec_seckey_verify(ctx, NULL) == 0); + CHECK(ecount == 1); + ecount = 0; + memset(ctmp2, 0, 32); + ctmp2[31] = 4; + CHECK(secp256k1_ec_pubkey_tweak_add(ctx, NULL, ctmp2) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_ec_pubkey_tweak_add(ctx, &pubkey, NULL) == 0); + CHECK(ecount == 2); + ecount = 0; + memset(ctmp2, 0, 32); + ctmp2[31] = 4; + CHECK(secp256k1_ec_pubkey_tweak_mul(ctx, NULL, ctmp2) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_ec_pubkey_tweak_mul(ctx, &pubkey, NULL) == 0); + CHECK(ecount == 2); + ecount = 0; + memset(ctmp2, 0, 32); + CHECK(secp256k1_ec_privkey_tweak_add(ctx, NULL, ctmp2) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_ec_privkey_tweak_add(ctx, ctmp, NULL) == 0); + CHECK(ecount == 2); + ecount = 0; + memset(ctmp2, 0, 32); + ctmp2[31] = 1; + CHECK(secp256k1_ec_privkey_tweak_mul(ctx, NULL, ctmp2) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_ec_privkey_tweak_mul(ctx, ctmp, NULL) == 0); + CHECK(ecount == 2); + ecount = 0; + CHECK(secp256k1_ec_pubkey_create(ctx, NULL, ctmp) == 0); + CHECK(ecount == 1); + memset(&pubkey, 1, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, NULL) == 0); + CHECK(ecount == 2); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0); + /* secp256k1_ec_pubkey_combine tests. */ + ecount = 0; + pubkeys[0] = &pubkey_one; + VG_UNDEF(&pubkeys[0], sizeof(secp256k1_pubkey *)); + VG_UNDEF(&pubkeys[1], sizeof(secp256k1_pubkey *)); + VG_UNDEF(&pubkeys[2], sizeof(secp256k1_pubkey *)); + memset(&pubkey, 255, sizeof(secp256k1_pubkey)); + VG_UNDEF(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, pubkeys, 0) == 0); + VG_CHECK(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_ec_pubkey_combine(ctx, NULL, pubkeys, 1) == 0); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0); + CHECK(ecount == 2); + memset(&pubkey, 255, sizeof(secp256k1_pubkey)); + VG_UNDEF(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, NULL, 1) == 0); + VG_CHECK(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0); + CHECK(ecount == 3); + pubkeys[0] = &pubkey_negone; + memset(&pubkey, 255, sizeof(secp256k1_pubkey)); + VG_UNDEF(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, pubkeys, 1) == 1); + VG_CHECK(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) > 0); + CHECK(ecount == 3); + len = 33; + CHECK(secp256k1_ec_pubkey_serialize(ctx, ctmp, &len, &pubkey, SECP256K1_EC_COMPRESSED) == 1); + CHECK(secp256k1_ec_pubkey_serialize(ctx, ctmp2, &len, &pubkey_negone, SECP256K1_EC_COMPRESSED) == 1); + CHECK(memcmp(ctmp, ctmp2, 33) == 0); + /* Result is infinity. */ + pubkeys[0] = &pubkey_one; + pubkeys[1] = &pubkey_negone; + memset(&pubkey, 255, sizeof(secp256k1_pubkey)); + VG_UNDEF(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, pubkeys, 2) == 0); + VG_CHECK(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0); + CHECK(ecount == 3); + /* Passes through infinity but comes out one. */ + pubkeys[2] = &pubkey_one; + memset(&pubkey, 255, sizeof(secp256k1_pubkey)); + VG_UNDEF(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, pubkeys, 3) == 1); + VG_CHECK(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) > 0); + CHECK(ecount == 3); + len = 33; + CHECK(secp256k1_ec_pubkey_serialize(ctx, ctmp, &len, &pubkey, SECP256K1_EC_COMPRESSED) == 1); + CHECK(secp256k1_ec_pubkey_serialize(ctx, ctmp2, &len, &pubkey_one, SECP256K1_EC_COMPRESSED) == 1); + CHECK(memcmp(ctmp, ctmp2, 33) == 0); + /* Adds to two. */ + pubkeys[1] = &pubkey_one; + memset(&pubkey, 255, sizeof(secp256k1_pubkey)); + VG_UNDEF(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, pubkeys, 2) == 1); + VG_CHECK(&pubkey, sizeof(secp256k1_pubkey)); + CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) > 0); + CHECK(ecount == 3); + secp256k1_context_set_illegal_callback(ctx, NULL, NULL); +} + +void random_sign(secp256k1_scalar *sigr, secp256k1_scalar *sigs, const secp256k1_scalar *key, const secp256k1_scalar *msg, int *recid) { + secp256k1_scalar nonce; + do { + random_scalar_order_test(&nonce); + } while(!secp256k1_ecdsa_sig_sign(&ctx->ecmult_gen_ctx, sigr, sigs, key, msg, &nonce, recid)); +} + +void test_ecdsa_sign_verify(void) { + secp256k1_gej pubj; + secp256k1_ge pub; + secp256k1_scalar one; + secp256k1_scalar msg, key; + secp256k1_scalar sigr, sigs; + int recid; + int getrec; + random_scalar_order_test(&msg); + random_scalar_order_test(&key); + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &pubj, &key); + secp256k1_ge_set_gej(&pub, &pubj); + getrec = secp256k1_rand_bits(1); + random_sign(&sigr, &sigs, &key, &msg, getrec?&recid:NULL); + if (getrec) { + CHECK(recid >= 0 && recid < 4); + } + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sigr, &sigs, &pub, &msg)); + secp256k1_scalar_set_int(&one, 1); + secp256k1_scalar_add(&msg, &msg, &one); + CHECK(!secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sigr, &sigs, &pub, &msg)); +} + +void run_ecdsa_sign_verify(void) { + int i; + for (i = 0; i < 10*count; i++) { + test_ecdsa_sign_verify(); + } +} + +/** Dummy nonce generation function that just uses a precomputed nonce, and fails if it is not accepted. Use only for testing. */ +static int precomputed_nonce_function(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { + (void)msg32; + (void)key32; + (void)algo16; + memcpy(nonce32, data, 32); + return (counter == 0); +} + +static int nonce_function_test_fail(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { + /* Dummy nonce generator that has a fatal error on the first counter value. */ + if (counter == 0) { + return 0; + } + return nonce_function_rfc6979(nonce32, msg32, key32, algo16, data, counter - 1); +} + +static int nonce_function_test_retry(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) { + /* Dummy nonce generator that produces unacceptable nonces for the first several counter values. */ + if (counter < 3) { + memset(nonce32, counter==0 ? 0 : 255, 32); + if (counter == 2) { + nonce32[31]--; + } + return 1; + } + if (counter < 5) { + static const unsigned char order[] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B, + 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x41 + }; + memcpy(nonce32, order, 32); + if (counter == 4) { + nonce32[31]++; + } + return 1; + } + /* Retry rate of 6979 is negligible esp. as we only call this in deterministic tests. */ + /* If someone does fine a case where it retries for secp256k1, we'd like to know. */ + if (counter > 5) { + return 0; + } + return nonce_function_rfc6979(nonce32, msg32, key32, algo16, data, counter - 5); +} + +int is_empty_signature(const secp256k1_ecdsa_signature *sig) { + static const unsigned char res[sizeof(secp256k1_ecdsa_signature)] = {0}; + return memcmp(sig, res, sizeof(secp256k1_ecdsa_signature)) == 0; +} + +void test_ecdsa_end_to_end(void) { + unsigned char extra[32] = {0x00}; + unsigned char privkey[32]; + unsigned char message[32]; + unsigned char privkey2[32]; + secp256k1_ecdsa_signature signature[6]; + secp256k1_scalar r, s; + unsigned char sig[74]; + size_t siglen = 74; + unsigned char pubkeyc[65]; + size_t pubkeyclen = 65; + secp256k1_pubkey pubkey; + unsigned char seckey[300]; + size_t seckeylen = 300; + + /* Generate a random key and message. */ + { + secp256k1_scalar msg, key; + random_scalar_order_test(&msg); + random_scalar_order_test(&key); + secp256k1_scalar_get_b32(privkey, &key); + secp256k1_scalar_get_b32(message, &msg); + } + + /* Construct and verify corresponding public key. */ + CHECK(secp256k1_ec_seckey_verify(ctx, privkey) == 1); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, privkey) == 1); + + /* Verify exporting and importing public key. */ + CHECK(secp256k1_ec_pubkey_serialize(ctx, pubkeyc, &pubkeyclen, &pubkey, secp256k1_rand_bits(1) == 1 ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED)); + memset(&pubkey, 0, sizeof(pubkey)); + CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeyc, pubkeyclen) == 1); + + /* Verify private key import and export. */ + CHECK(ec_privkey_export_der(ctx, seckey, &seckeylen, privkey, secp256k1_rand_bits(1) == 1)); + CHECK(ec_privkey_import_der(ctx, privkey2, seckey, seckeylen) == 1); + CHECK(memcmp(privkey, privkey2, 32) == 0); + + /* Optionally tweak the keys using addition. */ + if (secp256k1_rand_int(3) == 0) { + int ret1; + int ret2; + unsigned char rnd[32]; + secp256k1_pubkey pubkey2; + secp256k1_rand256_test(rnd); + ret1 = secp256k1_ec_privkey_tweak_add(ctx, privkey, rnd); + ret2 = secp256k1_ec_pubkey_tweak_add(ctx, &pubkey, rnd); + CHECK(ret1 == ret2); + if (ret1 == 0) { + return; + } + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey2, privkey) == 1); + CHECK(memcmp(&pubkey, &pubkey2, sizeof(pubkey)) == 0); + } + + /* Optionally tweak the keys using multiplication. */ + if (secp256k1_rand_int(3) == 0) { + int ret1; + int ret2; + unsigned char rnd[32]; + secp256k1_pubkey pubkey2; + secp256k1_rand256_test(rnd); + ret1 = secp256k1_ec_privkey_tweak_mul(ctx, privkey, rnd); + ret2 = secp256k1_ec_pubkey_tweak_mul(ctx, &pubkey, rnd); + CHECK(ret1 == ret2); + if (ret1 == 0) { + return; + } + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey2, privkey) == 1); + CHECK(memcmp(&pubkey, &pubkey2, sizeof(pubkey)) == 0); + } + + /* Sign. */ + CHECK(secp256k1_ecdsa_sign(ctx, &signature[0], message, privkey, NULL, NULL) == 1); + CHECK(secp256k1_ecdsa_sign(ctx, &signature[4], message, privkey, NULL, NULL) == 1); + CHECK(secp256k1_ecdsa_sign(ctx, &signature[1], message, privkey, NULL, extra) == 1); + extra[31] = 1; + CHECK(secp256k1_ecdsa_sign(ctx, &signature[2], message, privkey, NULL, extra) == 1); + extra[31] = 0; + extra[0] = 1; + CHECK(secp256k1_ecdsa_sign(ctx, &signature[3], message, privkey, NULL, extra) == 1); + CHECK(memcmp(&signature[0], &signature[4], sizeof(signature[0])) == 0); + CHECK(memcmp(&signature[0], &signature[1], sizeof(signature[0])) != 0); + CHECK(memcmp(&signature[0], &signature[2], sizeof(signature[0])) != 0); + CHECK(memcmp(&signature[0], &signature[3], sizeof(signature[0])) != 0); + CHECK(memcmp(&signature[1], &signature[2], sizeof(signature[0])) != 0); + CHECK(memcmp(&signature[1], &signature[3], sizeof(signature[0])) != 0); + CHECK(memcmp(&signature[2], &signature[3], sizeof(signature[0])) != 0); + /* Verify. */ + CHECK(secp256k1_ecdsa_verify(ctx, &signature[0], message, &pubkey) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &signature[1], message, &pubkey) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &signature[2], message, &pubkey) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &signature[3], message, &pubkey) == 1); + /* Test lower-S form, malleate, verify and fail, test again, malleate again */ + CHECK(!secp256k1_ecdsa_signature_normalize(ctx, NULL, &signature[0])); + secp256k1_ecdsa_signature_load(ctx, &r, &s, &signature[0]); + secp256k1_scalar_negate(&s, &s); + secp256k1_ecdsa_signature_save(&signature[5], &r, &s); + CHECK(secp256k1_ecdsa_verify(ctx, &signature[5], message, &pubkey) == 0); + CHECK(secp256k1_ecdsa_signature_normalize(ctx, NULL, &signature[5])); + CHECK(secp256k1_ecdsa_signature_normalize(ctx, &signature[5], &signature[5])); + CHECK(!secp256k1_ecdsa_signature_normalize(ctx, NULL, &signature[5])); + CHECK(!secp256k1_ecdsa_signature_normalize(ctx, &signature[5], &signature[5])); + CHECK(secp256k1_ecdsa_verify(ctx, &signature[5], message, &pubkey) == 1); + secp256k1_scalar_negate(&s, &s); + secp256k1_ecdsa_signature_save(&signature[5], &r, &s); + CHECK(!secp256k1_ecdsa_signature_normalize(ctx, NULL, &signature[5])); + CHECK(secp256k1_ecdsa_verify(ctx, &signature[5], message, &pubkey) == 1); + CHECK(memcmp(&signature[5], &signature[0], 64) == 0); + + /* Serialize/parse DER and verify again */ + CHECK(secp256k1_ecdsa_signature_serialize_der(ctx, sig, &siglen, &signature[0]) == 1); + memset(&signature[0], 0, sizeof(signature[0])); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &signature[0], sig, siglen) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, &signature[0], message, &pubkey) == 1); + /* Serialize/destroy/parse DER and verify again. */ + siglen = 74; + CHECK(secp256k1_ecdsa_signature_serialize_der(ctx, sig, &siglen, &signature[0]) == 1); + sig[secp256k1_rand_int(siglen)] += 1 + secp256k1_rand_int(255); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &signature[0], sig, siglen) == 0 || + secp256k1_ecdsa_verify(ctx, &signature[0], message, &pubkey) == 0); +} + +void test_random_pubkeys(void) { + secp256k1_ge elem; + secp256k1_ge elem2; + unsigned char in[65]; + /* Generate some randomly sized pubkeys. */ + size_t len = secp256k1_rand_bits(2) == 0 ? 65 : 33; + if (secp256k1_rand_bits(2) == 0) { + len = secp256k1_rand_bits(6); + } + if (len == 65) { + in[0] = secp256k1_rand_bits(1) ? 4 : (secp256k1_rand_bits(1) ? 6 : 7); + } else { + in[0] = secp256k1_rand_bits(1) ? 2 : 3; + } + if (secp256k1_rand_bits(3) == 0) { + in[0] = secp256k1_rand_bits(8); + } + if (len > 1) { + secp256k1_rand256(&in[1]); + } + if (len > 33) { + secp256k1_rand256(&in[33]); + } + if (secp256k1_eckey_pubkey_parse(&elem, in, len)) { + unsigned char out[65]; + unsigned char firstb; + int res; + size_t size = len; + firstb = in[0]; + /* If the pubkey can be parsed, it should round-trip... */ + CHECK(secp256k1_eckey_pubkey_serialize(&elem, out, &size, len == 33)); + CHECK(size == len); + CHECK(memcmp(&in[1], &out[1], len-1) == 0); + /* ... except for the type of hybrid inputs. */ + if ((in[0] != 6) && (in[0] != 7)) { + CHECK(in[0] == out[0]); + } + size = 65; + CHECK(secp256k1_eckey_pubkey_serialize(&elem, in, &size, 0)); + CHECK(size == 65); + CHECK(secp256k1_eckey_pubkey_parse(&elem2, in, size)); + ge_equals_ge(&elem,&elem2); + /* Check that the X9.62 hybrid type is checked. */ + in[0] = secp256k1_rand_bits(1) ? 6 : 7; + res = secp256k1_eckey_pubkey_parse(&elem2, in, size); + if (firstb == 2 || firstb == 3) { + if (in[0] == firstb + 4) { + CHECK(res); + } else { + CHECK(!res); + } + } + if (res) { + ge_equals_ge(&elem,&elem2); + CHECK(secp256k1_eckey_pubkey_serialize(&elem, out, &size, 0)); + CHECK(memcmp(&in[1], &out[1], 64) == 0); + } + } +} + +void run_random_pubkeys(void) { + int i; + for (i = 0; i < 10*count; i++) { + test_random_pubkeys(); + } +} + +void run_ecdsa_end_to_end(void) { + int i; + for (i = 0; i < 64*count; i++) { + test_ecdsa_end_to_end(); + } +} + +int test_ecdsa_der_parse(const unsigned char *sig, size_t siglen, int certainly_der, int certainly_not_der) { + static const unsigned char zeroes[32] = {0}; + static const unsigned char max_scalar[32] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, + 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40 + }; + + int ret = 0; + + secp256k1_ecdsa_signature sig_der; + unsigned char roundtrip_der[2048]; + unsigned char compact_der[64]; + size_t len_der = 2048; + int parsed_der = 0, valid_der = 0, roundtrips_der = 0; + + secp256k1_ecdsa_signature sig_der_lax; + unsigned char roundtrip_der_lax[2048]; + unsigned char compact_der_lax[64]; + size_t len_der_lax = 2048; + int parsed_der_lax = 0, valid_der_lax = 0, roundtrips_der_lax = 0; + +#ifdef ENABLE_OPENSSL_TESTS + ECDSA_SIG *sig_openssl; + const unsigned char *sigptr; + unsigned char roundtrip_openssl[2048]; + int len_openssl = 2048; + int parsed_openssl, valid_openssl = 0, roundtrips_openssl = 0; +#endif + + parsed_der = secp256k1_ecdsa_signature_parse_der(ctx, &sig_der, sig, siglen); + if (parsed_der) { + ret |= (!secp256k1_ecdsa_signature_serialize_compact(ctx, compact_der, &sig_der)) << 0; + valid_der = (memcmp(compact_der, zeroes, 32) != 0) && (memcmp(compact_der + 32, zeroes, 32) != 0); + } + if (valid_der) { + ret |= (!secp256k1_ecdsa_signature_serialize_der(ctx, roundtrip_der, &len_der, &sig_der)) << 1; + roundtrips_der = (len_der == siglen) && memcmp(roundtrip_der, sig, siglen) == 0; + } + + parsed_der_lax = ecdsa_signature_parse_der_lax(ctx, &sig_der_lax, sig, siglen); + if (parsed_der_lax) { + ret |= (!secp256k1_ecdsa_signature_serialize_compact(ctx, compact_der_lax, &sig_der_lax)) << 10; + valid_der_lax = (memcmp(compact_der_lax, zeroes, 32) != 0) && (memcmp(compact_der_lax + 32, zeroes, 32) != 0); + } + if (valid_der_lax) { + ret |= (!secp256k1_ecdsa_signature_serialize_der(ctx, roundtrip_der_lax, &len_der_lax, &sig_der_lax)) << 11; + roundtrips_der_lax = (len_der_lax == siglen) && memcmp(roundtrip_der_lax, sig, siglen) == 0; + } + + if (certainly_der) { + ret |= (!parsed_der) << 2; + } + if (certainly_not_der) { + ret |= (parsed_der) << 17; + } + if (valid_der) { + ret |= (!roundtrips_der) << 3; + } + + if (valid_der) { + ret |= (!roundtrips_der_lax) << 12; + ret |= (len_der != len_der_lax) << 13; + ret |= (memcmp(roundtrip_der_lax, roundtrip_der, len_der) != 0) << 14; + } + ret |= (roundtrips_der != roundtrips_der_lax) << 15; + if (parsed_der) { + ret |= (!parsed_der_lax) << 16; + } + +#ifdef ENABLE_OPENSSL_TESTS + sig_openssl = ECDSA_SIG_new(); + sigptr = sig; + parsed_openssl = (d2i_ECDSA_SIG(&sig_openssl, &sigptr, siglen) != NULL); + if (parsed_openssl) { + valid_openssl = !BN_is_negative(sig_openssl->r) && !BN_is_negative(sig_openssl->s) && BN_num_bits(sig_openssl->r) > 0 && BN_num_bits(sig_openssl->r) <= 256 && BN_num_bits(sig_openssl->s) > 0 && BN_num_bits(sig_openssl->s) <= 256; + if (valid_openssl) { + unsigned char tmp[32] = {0}; + BN_bn2bin(sig_openssl->r, tmp + 32 - BN_num_bytes(sig_openssl->r)); + valid_openssl = memcmp(tmp, max_scalar, 32) < 0; + } + if (valid_openssl) { + unsigned char tmp[32] = {0}; + BN_bn2bin(sig_openssl->s, tmp + 32 - BN_num_bytes(sig_openssl->s)); + valid_openssl = memcmp(tmp, max_scalar, 32) < 0; + } + } + len_openssl = i2d_ECDSA_SIG(sig_openssl, NULL); + if (len_openssl <= 2048) { + unsigned char *ptr = roundtrip_openssl; + CHECK(i2d_ECDSA_SIG(sig_openssl, &ptr) == len_openssl); + roundtrips_openssl = valid_openssl && ((size_t)len_openssl == siglen) && (memcmp(roundtrip_openssl, sig, siglen) == 0); + } else { + len_openssl = 0; + } + ECDSA_SIG_free(sig_openssl); + + ret |= (parsed_der && !parsed_openssl) << 4; + ret |= (valid_der && !valid_openssl) << 5; + ret |= (roundtrips_openssl && !parsed_der) << 6; + ret |= (roundtrips_der != roundtrips_openssl) << 7; + if (roundtrips_openssl) { + ret |= (len_der != (size_t)len_openssl) << 8; + ret |= (memcmp(roundtrip_der, roundtrip_openssl, len_der) != 0) << 9; + } +#endif + return ret; +} + +static void assign_big_endian(unsigned char *ptr, size_t ptrlen, uint32_t val) { + size_t i; + for (i = 0; i < ptrlen; i++) { + int shift = ptrlen - 1 - i; + if (shift >= 4) { + ptr[i] = 0; + } else { + ptr[i] = (val >> shift) & 0xFF; + } + } +} + +static void damage_array(unsigned char *sig, size_t *len) { + int pos; + int action = secp256k1_rand_bits(3); + if (action < 1 && *len > 3) { + /* Delete a byte. */ + pos = secp256k1_rand_int(*len); + memmove(sig + pos, sig + pos + 1, *len - pos - 1); + (*len)--; + return; + } else if (action < 2 && *len < 2048) { + /* Insert a byte. */ + pos = secp256k1_rand_int(1 + *len); + memmove(sig + pos + 1, sig + pos, *len - pos); + sig[pos] = secp256k1_rand_bits(8); + (*len)++; + return; + } else if (action < 4) { + /* Modify a byte. */ + sig[secp256k1_rand_int(*len)] += 1 + secp256k1_rand_int(255); + return; + } else { /* action < 8 */ + /* Modify a bit. */ + sig[secp256k1_rand_int(*len)] ^= 1 << secp256k1_rand_bits(3); + return; + } +} + +static void random_ber_signature(unsigned char *sig, size_t *len, int* certainly_der, int* certainly_not_der) { + int der; + int nlow[2], nlen[2], nlenlen[2], nhbit[2], nhbyte[2], nzlen[2]; + size_t tlen, elen, glen; + int indet; + int n; + + *len = 0; + der = secp256k1_rand_bits(2) == 0; + *certainly_der = der; + *certainly_not_der = 0; + indet = der ? 0 : secp256k1_rand_int(10) == 0; + + for (n = 0; n < 2; n++) { + /* We generate two classes of numbers: nlow==1 "low" ones (up to 32 bytes), nlow==0 "high" ones (32 bytes with 129 top bits set, or larger than 32 bytes) */ + nlow[n] = der ? 1 : (secp256k1_rand_bits(3) != 0); + /* The length of the number in bytes (the first byte of which will always be nonzero) */ + nlen[n] = nlow[n] ? secp256k1_rand_int(33) : 32 + secp256k1_rand_int(200) * secp256k1_rand_int(8) / 8; + CHECK(nlen[n] <= 232); + /* The top bit of the number. */ + nhbit[n] = (nlow[n] == 0 && nlen[n] == 32) ? 1 : (nlen[n] == 0 ? 0 : secp256k1_rand_bits(1)); + /* The top byte of the number (after the potential hardcoded 16 0xFF characters for "high" 32 bytes numbers) */ + nhbyte[n] = nlen[n] == 0 ? 0 : (nhbit[n] ? 128 + secp256k1_rand_bits(7) : 1 + secp256k1_rand_int(127)); + /* The number of zero bytes in front of the number (which is 0 or 1 in case of DER, otherwise we extend up to 300 bytes) */ + nzlen[n] = der ? ((nlen[n] == 0 || nhbit[n]) ? 1 : 0) : (nlow[n] ? secp256k1_rand_int(3) : secp256k1_rand_int(300 - nlen[n]) * secp256k1_rand_int(8) / 8); + if (nzlen[n] > ((nlen[n] == 0 || nhbit[n]) ? 1 : 0)) { + *certainly_not_der = 1; + } + CHECK(nlen[n] + nzlen[n] <= 300); + /* The length of the length descriptor for the number. 0 means short encoding, anything else is long encoding. */ + nlenlen[n] = nlen[n] + nzlen[n] < 128 ? 0 : (nlen[n] + nzlen[n] < 256 ? 1 : 2); + if (!der) { + /* nlenlen[n] max 127 bytes */ + int add = secp256k1_rand_int(127 - nlenlen[n]) * secp256k1_rand_int(16) * secp256k1_rand_int(16) / 256; + nlenlen[n] += add; + if (add != 0) { + *certainly_not_der = 1; + } + } + CHECK(nlen[n] + nzlen[n] + nlenlen[n] <= 427); + } + + /* The total length of the data to go, so far */ + tlen = 2 + nlenlen[0] + nlen[0] + nzlen[0] + 2 + nlenlen[1] + nlen[1] + nzlen[1]; + CHECK(tlen <= 856); + + /* The length of the garbage inside the tuple. */ + elen = (der || indet) ? 0 : secp256k1_rand_int(980 - tlen) * secp256k1_rand_int(8) / 8; + if (elen != 0) { + *certainly_not_der = 1; + } + tlen += elen; + CHECK(tlen <= 980); + + /* The length of the garbage after the end of the tuple. */ + glen = der ? 0 : secp256k1_rand_int(990 - tlen) * secp256k1_rand_int(8) / 8; + if (glen != 0) { + *certainly_not_der = 1; + } + CHECK(tlen + glen <= 990); + + /* Write the tuple header. */ + sig[(*len)++] = 0x30; + if (indet) { + /* Indeterminate length */ + sig[(*len)++] = 0x80; + *certainly_not_der = 1; + } else { + int tlenlen = tlen < 128 ? 0 : (tlen < 256 ? 1 : 2); + if (!der) { + int add = secp256k1_rand_int(127 - tlenlen) * secp256k1_rand_int(16) * secp256k1_rand_int(16) / 256; + tlenlen += add; + if (add != 0) { + *certainly_not_der = 1; + } + } + if (tlenlen == 0) { + /* Short length notation */ + sig[(*len)++] = tlen; + } else { + /* Long length notation */ + sig[(*len)++] = 128 + tlenlen; + assign_big_endian(sig + *len, tlenlen, tlen); + *len += tlenlen; + } + tlen += tlenlen; + } + tlen += 2; + CHECK(tlen + glen <= 1119); + + for (n = 0; n < 2; n++) { + /* Write the integer header. */ + sig[(*len)++] = 0x02; + if (nlenlen[n] == 0) { + /* Short length notation */ + sig[(*len)++] = nlen[n] + nzlen[n]; + } else { + /* Long length notation. */ + sig[(*len)++] = 128 + nlenlen[n]; + assign_big_endian(sig + *len, nlenlen[n], nlen[n] + nzlen[n]); + *len += nlenlen[n]; + } + /* Write zero padding */ + while (nzlen[n] > 0) { + sig[(*len)++] = 0x00; + nzlen[n]--; + } + if (nlen[n] == 32 && !nlow[n]) { + /* Special extra 16 0xFF bytes in "high" 32-byte numbers */ + int i; + for (i = 0; i < 16; i++) { + sig[(*len)++] = 0xFF; + } + nlen[n] -= 16; + } + /* Write first byte of number */ + if (nlen[n] > 0) { + sig[(*len)++] = nhbyte[n]; + nlen[n]--; + } + /* Generate remaining random bytes of number */ + secp256k1_rand_bytes_test(sig + *len, nlen[n]); + *len += nlen[n]; + nlen[n] = 0; + } + + /* Generate random garbage inside tuple. */ + secp256k1_rand_bytes_test(sig + *len, elen); + *len += elen; + + /* Generate end-of-contents bytes. */ + if (indet) { + sig[(*len)++] = 0; + sig[(*len)++] = 0; + tlen += 2; + } + CHECK(tlen + glen <= 1121); + + /* Generate random garbage outside tuple. */ + secp256k1_rand_bytes_test(sig + *len, glen); + *len += glen; + tlen += glen; + CHECK(tlen <= 1121); + CHECK(tlen == *len); +} + +void run_ecdsa_der_parse(void) { + int i,j; + for (i = 0; i < 200 * count; i++) { + unsigned char buffer[2048]; + size_t buflen = 0; + int certainly_der = 0; + int certainly_not_der = 0; + random_ber_signature(buffer, &buflen, &certainly_der, &certainly_not_der); + CHECK(buflen <= 2048); + for (j = 0; j < 16; j++) { + int ret = 0; + if (j > 0) { + damage_array(buffer, &buflen); + /* We don't know anything anymore about the DERness of the result */ + certainly_der = 0; + certainly_not_der = 0; + } + ret = test_ecdsa_der_parse(buffer, buflen, certainly_der, certainly_not_der); + if (ret != 0) { + size_t k; + fprintf(stderr, "Failure %x on ", ret); + for (k = 0; k < buflen; k++) { + fprintf(stderr, "%02x ", buffer[k]); + } + fprintf(stderr, "\n"); + } + CHECK(ret == 0); + } + } +} + +/* Tests several edge cases. */ +void test_ecdsa_edge_cases(void) { + int t; + secp256k1_ecdsa_signature sig; + + /* Test the case where ECDSA recomputes a point that is infinity. */ + { + secp256k1_gej keyj; + secp256k1_ge key; + secp256k1_scalar msg; + secp256k1_scalar sr, ss; + secp256k1_scalar_set_int(&ss, 1); + secp256k1_scalar_negate(&ss, &ss); + secp256k1_scalar_inverse(&ss, &ss); + secp256k1_scalar_set_int(&sr, 1); + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &keyj, &sr); + secp256k1_ge_set_gej(&key, &keyj); + msg = ss; + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 0); + } + + /* Verify signature with r of zero fails. */ + { + const unsigned char pubkey_mods_zero[33] = { + 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, + 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, + 0x41 + }; + secp256k1_ge key; + secp256k1_scalar msg; + secp256k1_scalar sr, ss; + secp256k1_scalar_set_int(&ss, 1); + secp256k1_scalar_set_int(&msg, 0); + secp256k1_scalar_set_int(&sr, 0); + CHECK(secp256k1_eckey_pubkey_parse(&key, pubkey_mods_zero, 33)); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 0); + } + + /* Verify signature with s of zero fails. */ + { + const unsigned char pubkey[33] = { + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01 + }; + secp256k1_ge key; + secp256k1_scalar msg; + secp256k1_scalar sr, ss; + secp256k1_scalar_set_int(&ss, 0); + secp256k1_scalar_set_int(&msg, 0); + secp256k1_scalar_set_int(&sr, 1); + CHECK(secp256k1_eckey_pubkey_parse(&key, pubkey, 33)); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 0); + } + + /* Verify signature with message 0 passes. */ + { + const unsigned char pubkey[33] = { + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02 + }; + const unsigned char pubkey2[33] = { + 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, + 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, + 0x43 + }; + secp256k1_ge key; + secp256k1_ge key2; + secp256k1_scalar msg; + secp256k1_scalar sr, ss; + secp256k1_scalar_set_int(&ss, 2); + secp256k1_scalar_set_int(&msg, 0); + secp256k1_scalar_set_int(&sr, 2); + CHECK(secp256k1_eckey_pubkey_parse(&key, pubkey, 33)); + CHECK(secp256k1_eckey_pubkey_parse(&key2, pubkey2, 33)); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 1); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key2, &msg) == 1); + secp256k1_scalar_negate(&ss, &ss); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 1); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key2, &msg) == 1); + secp256k1_scalar_set_int(&ss, 1); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 0); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key2, &msg) == 0); + } + + /* Verify signature with message 1 passes. */ + { + const unsigned char pubkey[33] = { + 0x02, 0x14, 0x4e, 0x5a, 0x58, 0xef, 0x5b, 0x22, + 0x6f, 0xd2, 0xe2, 0x07, 0x6a, 0x77, 0xcf, 0x05, + 0xb4, 0x1d, 0xe7, 0x4a, 0x30, 0x98, 0x27, 0x8c, + 0x93, 0xe6, 0xe6, 0x3c, 0x0b, 0xc4, 0x73, 0x76, + 0x25 + }; + const unsigned char pubkey2[33] = { + 0x02, 0x8a, 0xd5, 0x37, 0xed, 0x73, 0xd9, 0x40, + 0x1d, 0xa0, 0x33, 0xd2, 0xdc, 0xf0, 0xaf, 0xae, + 0x34, 0xcf, 0x5f, 0x96, 0x4c, 0x73, 0x28, 0x0f, + 0x92, 0xc0, 0xf6, 0x9d, 0xd9, 0xb2, 0x09, 0x10, + 0x62 + }; + const unsigned char csr[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4, + 0x40, 0x2d, 0xa1, 0x72, 0x2f, 0xc9, 0xba, 0xeb + }; + secp256k1_ge key; + secp256k1_ge key2; + secp256k1_scalar msg; + secp256k1_scalar sr, ss; + secp256k1_scalar_set_int(&ss, 1); + secp256k1_scalar_set_int(&msg, 1); + secp256k1_scalar_set_b32(&sr, csr, NULL); + CHECK(secp256k1_eckey_pubkey_parse(&key, pubkey, 33)); + CHECK(secp256k1_eckey_pubkey_parse(&key2, pubkey2, 33)); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 1); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key2, &msg) == 1); + secp256k1_scalar_negate(&ss, &ss); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 1); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key2, &msg) == 1); + secp256k1_scalar_set_int(&ss, 2); + secp256k1_scalar_inverse_var(&ss, &ss); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 0); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key2, &msg) == 0); + } + + /* Verify signature with message -1 passes. */ + { + const unsigned char pubkey[33] = { + 0x03, 0xaf, 0x97, 0xff, 0x7d, 0x3a, 0xf6, 0xa0, + 0x02, 0x94, 0xbd, 0x9f, 0x4b, 0x2e, 0xd7, 0x52, + 0x28, 0xdb, 0x49, 0x2a, 0x65, 0xcb, 0x1e, 0x27, + 0x57, 0x9c, 0xba, 0x74, 0x20, 0xd5, 0x1d, 0x20, + 0xf1 + }; + const unsigned char csr[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4, + 0x40, 0x2d, 0xa1, 0x72, 0x2f, 0xc9, 0xba, 0xee + }; + secp256k1_ge key; + secp256k1_scalar msg; + secp256k1_scalar sr, ss; + secp256k1_scalar_set_int(&ss, 1); + secp256k1_scalar_set_int(&msg, 1); + secp256k1_scalar_negate(&msg, &msg); + secp256k1_scalar_set_b32(&sr, csr, NULL); + CHECK(secp256k1_eckey_pubkey_parse(&key, pubkey, 33)); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 1); + secp256k1_scalar_negate(&ss, &ss); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 1); + secp256k1_scalar_set_int(&ss, 3); + secp256k1_scalar_inverse_var(&ss, &ss); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sr, &ss, &key, &msg) == 0); + } + + /* Signature where s would be zero. */ + { + secp256k1_pubkey pubkey; + size_t siglen; + int32_t ecount; + unsigned char signature[72]; + static const unsigned char nonce[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }; + static const unsigned char nonce2[32] = { + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE, + 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B, + 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x40 + }; + const unsigned char key[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }; + unsigned char msg[32] = { + 0x86, 0x41, 0x99, 0x81, 0x06, 0x23, 0x44, 0x53, + 0xaa, 0x5f, 0x9d, 0x6a, 0x31, 0x78, 0xf4, 0xf7, + 0xb8, 0x12, 0xe0, 0x0b, 0x81, 0x7a, 0x77, 0x62, + 0x65, 0xdf, 0xdd, 0x31, 0xb9, 0x3e, 0x29, 0xa9, + }; + ecount = 0; + secp256k1_context_set_illegal_callback(ctx, counting_illegal_callback_fn, &ecount); + CHECK(secp256k1_ecdsa_sign(ctx, &sig, msg, key, precomputed_nonce_function, nonce) == 0); + CHECK(secp256k1_ecdsa_sign(ctx, &sig, msg, key, precomputed_nonce_function, nonce2) == 0); + msg[31] = 0xaa; + CHECK(secp256k1_ecdsa_sign(ctx, &sig, msg, key, precomputed_nonce_function, nonce) == 1); + CHECK(ecount == 0); + CHECK(secp256k1_ecdsa_sign(ctx, NULL, msg, key, precomputed_nonce_function, nonce2) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_ecdsa_sign(ctx, &sig, NULL, key, precomputed_nonce_function, nonce2) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_ecdsa_sign(ctx, &sig, msg, NULL, precomputed_nonce_function, nonce2) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_ecdsa_sign(ctx, &sig, msg, key, precomputed_nonce_function, nonce2) == 1); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, key) == 1); + CHECK(secp256k1_ecdsa_verify(ctx, NULL, msg, &pubkey) == 0); + CHECK(ecount == 4); + CHECK(secp256k1_ecdsa_verify(ctx, &sig, NULL, &pubkey) == 0); + CHECK(ecount == 5); + CHECK(secp256k1_ecdsa_verify(ctx, &sig, msg, NULL) == 0); + CHECK(ecount == 6); + CHECK(secp256k1_ecdsa_verify(ctx, &sig, msg, &pubkey) == 1); + CHECK(ecount == 6); + CHECK(secp256k1_ec_pubkey_create(ctx, &pubkey, NULL) == 0); + CHECK(ecount == 7); + /* That pubkeyload fails via an ARGCHECK is a little odd but makes sense because pubkeys are an opaque data type. */ + CHECK(secp256k1_ecdsa_verify(ctx, &sig, msg, &pubkey) == 0); + CHECK(ecount == 8); + siglen = 72; + CHECK(secp256k1_ecdsa_signature_serialize_der(ctx, NULL, &siglen, &sig) == 0); + CHECK(ecount == 9); + CHECK(secp256k1_ecdsa_signature_serialize_der(ctx, signature, NULL, &sig) == 0); + CHECK(ecount == 10); + CHECK(secp256k1_ecdsa_signature_serialize_der(ctx, signature, &siglen, NULL) == 0); + CHECK(ecount == 11); + CHECK(secp256k1_ecdsa_signature_serialize_der(ctx, signature, &siglen, &sig) == 1); + CHECK(ecount == 11); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, NULL, signature, siglen) == 0); + CHECK(ecount == 12); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, NULL, siglen) == 0); + CHECK(ecount == 13); + CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &sig, signature, siglen) == 1); + CHECK(ecount == 13); + siglen = 10; + /* Too little room for a signature does not fail via ARGCHECK. */ + CHECK(secp256k1_ecdsa_signature_serialize_der(ctx, signature, &siglen, &sig) == 0); + CHECK(ecount == 13); + ecount = 0; + CHECK(secp256k1_ecdsa_signature_normalize(ctx, NULL, NULL) == 0); + CHECK(ecount == 1); + CHECK(secp256k1_ecdsa_signature_serialize_compact(ctx, NULL, &sig) == 0); + CHECK(ecount == 2); + CHECK(secp256k1_ecdsa_signature_serialize_compact(ctx, signature, NULL) == 0); + CHECK(ecount == 3); + CHECK(secp256k1_ecdsa_signature_serialize_compact(ctx, signature, &sig) == 1); + CHECK(ecount == 3); + CHECK(secp256k1_ecdsa_signature_parse_compact(ctx, NULL, signature) == 0); + CHECK(ecount == 4); + CHECK(secp256k1_ecdsa_signature_parse_compact(ctx, &sig, NULL) == 0); + CHECK(ecount == 5); + CHECK(secp256k1_ecdsa_signature_parse_compact(ctx, &sig, signature) == 1); + CHECK(ecount == 5); + memset(signature, 255, 64); + CHECK(secp256k1_ecdsa_signature_parse_compact(ctx, &sig, signature) == 0); + CHECK(ecount == 5); + secp256k1_context_set_illegal_callback(ctx, NULL, NULL); + } + + /* Nonce function corner cases. */ + for (t = 0; t < 2; t++) { + static const unsigned char zero[32] = {0x00}; + int i; + unsigned char key[32]; + unsigned char msg[32]; + secp256k1_ecdsa_signature sig2; + secp256k1_scalar sr[512], ss; + const unsigned char *extra; + extra = t == 0 ? NULL : zero; + memset(msg, 0, 32); + msg[31] = 1; + /* High key results in signature failure. */ + memset(key, 0xFF, 32); + CHECK(secp256k1_ecdsa_sign(ctx, &sig, msg, key, NULL, extra) == 0); + CHECK(is_empty_signature(&sig)); + /* Zero key results in signature failure. */ + memset(key, 0, 32); + CHECK(secp256k1_ecdsa_sign(ctx, &sig, msg, key, NULL, extra) == 0); + CHECK(is_empty_signature(&sig)); + /* Nonce function failure results in signature failure. */ + key[31] = 1; + CHECK(secp256k1_ecdsa_sign(ctx, &sig, msg, key, nonce_function_test_fail, extra) == 0); + CHECK(is_empty_signature(&sig)); + /* The retry loop successfully makes its way to the first good value. */ + CHECK(secp256k1_ecdsa_sign(ctx, &sig, msg, key, nonce_function_test_retry, extra) == 1); + CHECK(!is_empty_signature(&sig)); + CHECK(secp256k1_ecdsa_sign(ctx, &sig2, msg, key, nonce_function_rfc6979, extra) == 1); + CHECK(!is_empty_signature(&sig2)); + CHECK(memcmp(&sig, &sig2, sizeof(sig)) == 0); + /* The default nonce function is deterministic. */ + CHECK(secp256k1_ecdsa_sign(ctx, &sig2, msg, key, NULL, extra) == 1); + CHECK(!is_empty_signature(&sig2)); + CHECK(memcmp(&sig, &sig2, sizeof(sig)) == 0); + /* The default nonce function changes output with different messages. */ + for(i = 0; i < 256; i++) { + int j; + msg[0] = i; + CHECK(secp256k1_ecdsa_sign(ctx, &sig2, msg, key, NULL, extra) == 1); + CHECK(!is_empty_signature(&sig2)); + secp256k1_ecdsa_signature_load(ctx, &sr[i], &ss, &sig2); + for (j = 0; j < i; j++) { + CHECK(!secp256k1_scalar_eq(&sr[i], &sr[j])); + } + } + msg[0] = 0; + msg[31] = 2; + /* The default nonce function changes output with different keys. */ + for(i = 256; i < 512; i++) { + int j; + key[0] = i - 256; + CHECK(secp256k1_ecdsa_sign(ctx, &sig2, msg, key, NULL, extra) == 1); + CHECK(!is_empty_signature(&sig2)); + secp256k1_ecdsa_signature_load(ctx, &sr[i], &ss, &sig2); + for (j = 0; j < i; j++) { + CHECK(!secp256k1_scalar_eq(&sr[i], &sr[j])); + } + } + key[0] = 0; + } + + { + /* Check that optional nonce arguments do not have equivalent effect. */ + const unsigned char zeros[32] = {0}; + unsigned char nonce[32]; + unsigned char nonce2[32]; + unsigned char nonce3[32]; + unsigned char nonce4[32]; + VG_UNDEF(nonce,32); + VG_UNDEF(nonce2,32); + VG_UNDEF(nonce3,32); + VG_UNDEF(nonce4,32); + CHECK(nonce_function_rfc6979(nonce, zeros, zeros, NULL, NULL, 0) == 1); + VG_CHECK(nonce,32); + CHECK(nonce_function_rfc6979(nonce2, zeros, zeros, zeros, NULL, 0) == 1); + VG_CHECK(nonce2,32); + CHECK(nonce_function_rfc6979(nonce3, zeros, zeros, NULL, (void *)zeros, 0) == 1); + VG_CHECK(nonce3,32); + CHECK(nonce_function_rfc6979(nonce4, zeros, zeros, zeros, (void *)zeros, 0) == 1); + VG_CHECK(nonce4,32); + CHECK(memcmp(nonce, nonce2, 32) != 0); + CHECK(memcmp(nonce, nonce3, 32) != 0); + CHECK(memcmp(nonce, nonce4, 32) != 0); + CHECK(memcmp(nonce2, nonce3, 32) != 0); + CHECK(memcmp(nonce2, nonce4, 32) != 0); + CHECK(memcmp(nonce3, nonce4, 32) != 0); + } + + + /* Privkey export where pubkey is the point at infinity. */ + { + unsigned char privkey[300]; + unsigned char seckey[32] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, + 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, + }; + size_t outlen = 300; + CHECK(!ec_privkey_export_der(ctx, privkey, &outlen, seckey, 0)); + outlen = 300; + CHECK(!ec_privkey_export_der(ctx, privkey, &outlen, seckey, 1)); + } +} + +void run_ecdsa_edge_cases(void) { + test_ecdsa_edge_cases(); +} + +#ifdef ENABLE_OPENSSL_TESTS +EC_KEY *get_openssl_key(const unsigned char *key32) { + unsigned char privkey[300]; + size_t privkeylen; + const unsigned char* pbegin = privkey; + int compr = secp256k1_rand_bits(1); + EC_KEY *ec_key = EC_KEY_new_by_curve_name(NID_secp256k1); + CHECK(ec_privkey_export_der(ctx, privkey, &privkeylen, key32, compr)); + CHECK(d2i_ECPrivateKey(&ec_key, &pbegin, privkeylen)); + CHECK(EC_KEY_check_key(ec_key)); + return ec_key; +} + +void test_ecdsa_openssl(void) { + secp256k1_gej qj; + secp256k1_ge q; + secp256k1_scalar sigr, sigs; + secp256k1_scalar one; + secp256k1_scalar msg2; + secp256k1_scalar key, msg; + EC_KEY *ec_key; + unsigned int sigsize = 80; + size_t secp_sigsize = 80; + unsigned char message[32]; + unsigned char signature[80]; + unsigned char key32[32]; + secp256k1_rand256_test(message); + secp256k1_scalar_set_b32(&msg, message, NULL); + random_scalar_order_test(&key); + secp256k1_scalar_get_b32(key32, &key); + secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &qj, &key); + secp256k1_ge_set_gej(&q, &qj); + ec_key = get_openssl_key(key32); + CHECK(ec_key != NULL); + CHECK(ECDSA_sign(0, message, sizeof(message), signature, &sigsize, ec_key)); + CHECK(secp256k1_ecdsa_sig_parse(&sigr, &sigs, signature, sigsize)); + CHECK(secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sigr, &sigs, &q, &msg)); + secp256k1_scalar_set_int(&one, 1); + secp256k1_scalar_add(&msg2, &msg, &one); + CHECK(!secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &sigr, &sigs, &q, &msg2)); + + random_sign(&sigr, &sigs, &key, &msg, NULL); + CHECK(secp256k1_ecdsa_sig_serialize(signature, &secp_sigsize, &sigr, &sigs)); + CHECK(ECDSA_verify(0, message, sizeof(message), signature, secp_sigsize, ec_key) == 1); + + EC_KEY_free(ec_key); +} + +void run_ecdsa_openssl(void) { + int i; + for (i = 0; i < 10*count; i++) { + test_ecdsa_openssl(); + } +} +#endif + +#ifdef ENABLE_MODULE_ECDH +# include "modules/ecdh/tests_impl.h" +#endif + +#ifdef ENABLE_MODULE_SCHNORR +# include "modules/schnorr/tests_impl.h" +#endif + +#ifdef ENABLE_MODULE_RECOVERY +# include "modules/recovery/tests_impl.h" +#endif + +int main(int argc, char **argv) { + unsigned char seed16[16] = {0}; + unsigned char run32[32] = {0}; + /* find iteration count */ + if (argc > 1) { + count = strtol(argv[1], NULL, 0); + } + + /* find random seed */ + if (argc > 2) { + int pos = 0; + const char* ch = argv[2]; + while (pos < 16 && ch[0] != 0 && ch[1] != 0) { + unsigned short sh; + if (sscanf(ch, "%2hx", &sh)) { + seed16[pos] = sh; + } else { + break; + } + ch += 2; + pos++; + } + } else { + FILE *frand = fopen("/dev/urandom", "r"); + if ((frand == NULL) || !fread(&seed16, sizeof(seed16), 1, frand)) { + uint64_t t = time(NULL) * (uint64_t)1337; + seed16[0] ^= t; + seed16[1] ^= t >> 8; + seed16[2] ^= t >> 16; + seed16[3] ^= t >> 24; + seed16[4] ^= t >> 32; + seed16[5] ^= t >> 40; + seed16[6] ^= t >> 48; + seed16[7] ^= t >> 56; + } + fclose(frand); + } + secp256k1_rand_seed(seed16); + + printf("test count = %i\n", count); + printf("random seed = %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", seed16[0], seed16[1], seed16[2], seed16[3], seed16[4], seed16[5], seed16[6], seed16[7], seed16[8], seed16[9], seed16[10], seed16[11], seed16[12], seed16[13], seed16[14], seed16[15]); + + /* initialize */ + run_context_tests(); + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + if (secp256k1_rand_bits(1)) { + secp256k1_rand256(run32); + CHECK(secp256k1_context_randomize(ctx, secp256k1_rand_bits(1) ? run32 : NULL)); + } + + run_rand_bits(); + run_rand_int(); + + run_sha256_tests(); + run_hmac_sha256_tests(); + run_rfc6979_hmac_sha256_tests(); + +#ifndef USE_NUM_NONE + /* num tests */ + run_num_smalltests(); +#endif + + /* scalar tests */ + run_scalar_tests(); + + /* field tests */ + run_field_inv(); + run_field_inv_var(); + run_field_inv_all_var(); + run_field_misc(); + run_field_convert(); + run_sqr(); + run_sqrt(); + + /* group tests */ + run_ge(); + run_group_decompress(); + + /* ecmult tests */ + run_wnaf(); + run_point_times_order(); + run_ecmult_chain(); + run_ecmult_constants(); + run_ecmult_gen_blind(); + run_ecmult_const_tests(); + run_ec_combine(); + + /* endomorphism tests */ +#ifdef USE_ENDOMORPHISM + run_endomorphism_tests(); +#endif + + /* EC point parser test */ + run_ec_pubkey_parse_test(); + + /* EC key edge cases */ + run_eckey_edge_case_test(); + +#ifdef ENABLE_MODULE_ECDH + /* ecdh tests */ + run_ecdh_tests(); +#endif + + /* ecdsa tests */ + run_random_pubkeys(); + run_ecdsa_der_parse(); + run_ecdsa_sign_verify(); + run_ecdsa_end_to_end(); + run_ecdsa_edge_cases(); +#ifdef ENABLE_OPENSSL_TESTS + run_ecdsa_openssl(); +#endif + +#ifdef ENABLE_MODULE_SCHNORR + /* Schnorr tests */ + run_schnorr_tests(); +#endif + +#ifdef ENABLE_MODULE_RECOVERY + /* ECDSA pubkey recovery tests */ + run_recovery_tests(); +#endif + + secp256k1_rand256(run32); + printf("random run = %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", run32[0], run32[1], run32[2], run32[3], run32[4], run32[5], run32[6], run32[7], run32[8], run32[9], run32[10], run32[11], run32[12], run32[13], run32[14], run32[15]); + + /* shutdown */ + secp256k1_context_destroy(ctx); + + printf("no problems found\n"); + return 0; +} diff --git a/src/secp256k1/src/util.h b/src/secp256k1/src/util.h new file mode 100644 index 0000000..4eef4de --- /dev/null +++ b/src/secp256k1/src/util.h @@ -0,0 +1,110 @@ +/********************************************************************** + * Copyright (c) 2013, 2014 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _SECP256K1_UTIL_H_ +#define _SECP256K1_UTIL_H_ + +#if defined HAVE_CONFIG_H +#include "libsecp256k1-config.h" +#endif + +#include +#include +#include + +typedef struct { + void (*fn)(const char *text, void* data); + const void* data; +} secp256k1_callback; + +static SECP256K1_INLINE void secp256k1_callback_call(const secp256k1_callback * const cb, const char * const text) { + cb->fn(text, (void*)cb->data); +} + +#ifdef DETERMINISTIC +#define TEST_FAILURE(msg) do { \ + fprintf(stderr, "%s\n", msg); \ + abort(); \ +} while(0); +#else +#define TEST_FAILURE(msg) do { \ + fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, msg); \ + abort(); \ +} while(0) +#endif + +#ifdef HAVE_BUILTIN_EXPECT +#define EXPECT(x,c) __builtin_expect((x),(c)) +#else +#define EXPECT(x,c) (x) +#endif + +#ifdef DETERMINISTIC +#define CHECK(cond) do { \ + if (EXPECT(!(cond), 0)) { \ + TEST_FAILURE("test condition failed"); \ + } \ +} while(0) +#else +#define CHECK(cond) do { \ + if (EXPECT(!(cond), 0)) { \ + TEST_FAILURE("test condition failed: " #cond); \ + } \ +} while(0) +#endif + +/* Like assert(), but when VERIFY is defined, and side-effect safe. */ +#ifdef VERIFY +#define VERIFY_CHECK CHECK +#define VERIFY_SETUP(stmt) do { stmt; } while(0) +#else +#define VERIFY_CHECK(cond) do { (void)(cond); } while(0) +#define VERIFY_SETUP(stmt) +#endif + +static SECP256K1_INLINE void *checked_malloc(const secp256k1_callback* cb, size_t size) { + void *ret = malloc(size); + if (ret == NULL) { + secp256k1_callback_call(cb, "Out of memory"); + } + return ret; +} + +/* Macro for restrict, when available and not in a VERIFY build. */ +#if defined(SECP256K1_BUILD) && defined(VERIFY) +# define SECP256K1_RESTRICT +#else +# if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) +# if SECP256K1_GNUC_PREREQ(3,0) +# define SECP256K1_RESTRICT __restrict__ +# elif (defined(_MSC_VER) && _MSC_VER >= 1400) +# define SECP256K1_RESTRICT __restrict +# else +# define SECP256K1_RESTRICT +# endif +# else +# define SECP256K1_RESTRICT restrict +# endif +#endif + +#if defined(_WIN32) +# define I64FORMAT "I64d" +# define I64uFORMAT "I64u" +#else +# define I64FORMAT "lld" +# define I64uFORMAT "llu" +#endif + +#if defined(HAVE___INT128) +# if defined(__GNUC__) +# define SECP256K1_GNUC_EXT __extension__ +# else +# define SECP256K1_GNUC_EXT +# endif +SECP256K1_GNUC_EXT typedef unsigned __int128 uint128_t; +#endif + +#endif diff --git a/src/serialize.h b/src/serialize.h new file mode 100644 index 0000000..9165072 --- /dev/null +++ b/src/serialize.h @@ -0,0 +1,1320 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_SERIALIZE_H +#define BITCOIN_SERIALIZE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "allocators.h" +#include "version.h" + +class CAutoFile; +class CDataStream; +class CScript; + +static const unsigned int MAX_SIZE = 0x02000000; + +// Used to bypass the rule against non-const reference to temporary +// where it makes sense with wrappers such as CFlatData or CTxDB +template +inline T& REF(const T& val) +{ + return const_cast(val); +} + +/** + * Used to acquire a non-const pointer "this" to generate bodies + * of const serialization operations from a template + */ +template +inline T* NCONST_PTR(const T* val) +{ + return const_cast(val); +} + +/** + * Get begin pointer of vector (non-const version). + * @note These functions avoid the undefined case of indexing into an empty + * vector, as well as that of indexing after the end of the vector. + */ +template +inline T* begin_ptr(std::vector& v) +{ + return v.empty() ? NULL : &v[0]; +} +/** Get begin pointer of vector (const version) */ +template +inline const T* begin_ptr(const std::vector& v) +{ + return v.empty() ? NULL : &v[0]; +} +/** Get end pointer of vector (non-const version) */ +template +inline T* end_ptr(std::vector& v) +{ + return v.empty() ? NULL : (&v[0] + v.size()); +} +/** Get end pointer of vector (const version) */ +template +inline const T* end_ptr(const std::vector& v) +{ + return v.empty() ? NULL : (&v[0] + v.size()); +} + + + +// Templates for serializing to anything that looks like a stream, +// i.e. anything that supports .read(char*, size_t) and .write(char*, size_t) + + +enum +{ + // primary actions + SER_NETWORK = (1 << 0), + SER_DISK = (1 << 1), + SER_GETHASH = (1 << 2), + + // modifiers + SER_SKIPSIG = (1 << 16), + SER_BLOCKHEADERONLY = (1 << 17), +}; + +#define IMPLEMENT_SERIALIZE(statements) \ + unsigned int GetSerializeSize(int nType, int nVersion) const \ + { \ + CSerActionGetSerializeSize ser_action; \ + const bool fGetSize = true; \ + const bool fWrite = false; \ + const bool fRead = false; \ + unsigned int nSerSize = 0; \ + ser_streamplaceholder s; \ + assert(fGetSize||fWrite||fRead); /* suppress warning */ \ + s.nType = nType; \ + s.nVersion = nVersion; \ + {statements} \ + return nSerSize; \ + } \ + template \ + void Serialize(Stream& s, int nType, int nVersion) const \ + { \ + CSerActionSerialize ser_action; \ + const bool fGetSize = false; \ + const bool fWrite = true; \ + const bool fRead = false; \ + unsigned int nSerSize = 0; \ + assert(fGetSize||fWrite||fRead); /* suppress warning */ \ + {statements} \ + } \ + template \ + void Unserialize(Stream& s, int nType, int nVersion) \ + { \ + CSerActionUnserialize ser_action; \ + const bool fGetSize = false; \ + const bool fWrite = false; \ + const bool fRead = true; \ + unsigned int nSerSize = 0; \ + assert(fGetSize||fWrite||fRead); /* suppress warning */ \ + {statements} \ + } + +#define READWRITE(obj) (nSerSize += ::SerReadWrite(s, (obj), nType, nVersion, ser_action)) +#define READWRITES(obj) (::SerReadWrite(s, (obj), nType, nVersion, ser_action)) + + +/** + * Implement three methods for serializable objects. These are actually wrappers over + * "SerializationOp" template, which implements the body of each class' serialization + * code. Adding "ADD_SERIALIZE_METHODS" in the body of the class causes these wrappers to be + * added as members. + */ +#define ADD_SERIALIZE_METHODS \ + size_t GetSerializeSize(int nType, int nVersion) const { \ + CSizeComputer s(nType, nVersion); \ + NCONST_PTR(this)->SerializationOp(s, CSerActionSerialize(), nType, nVersion);\ + return s.size(); \ + } \ + template \ + void Serialize(Stream& s, int nType, int nVersion) const { \ + NCONST_PTR(this)->SerializationOp(s, CSerActionSerialize(), nType, nVersion);\ + } \ + template \ + void Unserialize(Stream& s, int nType, int nVersion) { \ + SerializationOp(s, CSerActionUnserialize(), nType, nVersion); \ + } + + + +// +// Basic types +// +#define WRITEDATA(s, obj) s.write((char*)&(obj), sizeof(obj)) +#define READDATA(s, obj) s.read((char*)&(obj), sizeof(obj)) + +inline unsigned int GetSerializeSize(char a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(signed char a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(unsigned char a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(signed short a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(unsigned short a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(signed int a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(unsigned int a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(signed long a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(unsigned long a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(signed long long a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(unsigned long long a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(float a, int, int=0) { return sizeof(a); } +inline unsigned int GetSerializeSize(double a, int, int=0) { return sizeof(a); } + +template inline void Serialize(Stream& s, char a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, signed char a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, unsigned char a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, signed short a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, unsigned short a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, signed int a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, unsigned int a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, signed long a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, unsigned long a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, signed long long a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, unsigned long long a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, float a, int, int=0) { WRITEDATA(s, a); } +template inline void Serialize(Stream& s, double a, int, int=0) { WRITEDATA(s, a); } + +template inline void Unserialize(Stream& s, char& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, signed char& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, unsigned char& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, signed short& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, unsigned short& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, signed int& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, unsigned int& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, signed long& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, unsigned long& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, signed long long& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, unsigned long long& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, float& a, int, int=0) { READDATA(s, a); } +template inline void Unserialize(Stream& s, double& a, int, int=0) { READDATA(s, a); } + +inline unsigned int GetSerializeSize(bool a, int, int=0) { return sizeof(char); } +template inline void Serialize(Stream& s, bool a, int, int=0) { char f=a; WRITEDATA(s, f); } +template inline void Unserialize(Stream& s, bool& a, int, int=0) { char f; READDATA(s, f); a=f; } + + + + + + +// +// Compact size +// size < 253 -- 1 byte +// size <= USHRT_MAX -- 3 bytes (253 + 2 bytes) +// size <= UINT_MAX -- 5 bytes (254 + 4 bytes) +// size > UINT_MAX -- 9 bytes (255 + 8 bytes) +// +inline unsigned int GetSizeOfCompactSize(uint64_t nSize) +{ + if (nSize < 253) return sizeof(unsigned char); + else if (nSize <= std::numeric_limits::max()) return sizeof(unsigned char) + sizeof(unsigned short); + else if (nSize <= std::numeric_limits::max()) return sizeof(unsigned char) + sizeof(unsigned int); + else return sizeof(unsigned char) + sizeof(uint64_t); +} + +template +void WriteCompactSize(Stream& os, uint64_t nSize) +{ + if (nSize < 253) + { + unsigned char chSize = nSize; + WRITEDATA(os, chSize); + } + else if (nSize <= std::numeric_limits::max()) + { + unsigned char chSize = 253; + unsigned short xSize = nSize; + WRITEDATA(os, chSize); + WRITEDATA(os, xSize); + } + else if (nSize <= std::numeric_limits::max()) + { + unsigned char chSize = 254; + unsigned int xSize = nSize; + WRITEDATA(os, chSize); + WRITEDATA(os, xSize); + } + else + { + unsigned char chSize = 255; + uint64_t xSize = nSize; + WRITEDATA(os, chSize); + WRITEDATA(os, xSize); + } + return; +} + +template +uint64_t ReadCompactSize(Stream& is) +{ + unsigned char chSize; + READDATA(is, chSize); + uint64_t nSizeRet = 0; + if (chSize < 253) + { + nSizeRet = chSize; + } + else if (chSize == 253) + { + unsigned short xSize; + READDATA(is, xSize); + nSizeRet = xSize; + if (nSizeRet < 253) + throw std::ios_base::failure("non-canonical ReadCompactSize()"); + } + else if (chSize == 254) + { + unsigned int xSize; + READDATA(is, xSize); + nSizeRet = xSize; + if (nSizeRet < 0x10000u) + throw std::ios_base::failure("non-canonical ReadCompactSize()"); + } + else + { + uint64_t xSize; + READDATA(is, xSize); + nSizeRet = xSize; + if (nSizeRet < 0x100000000ULL) + throw std::ios_base::failure("non-canonical ReadCompactSize()"); + } + if (nSizeRet > (uint64_t)MAX_SIZE) + throw std::ios_base::failure("ReadCompactSize() : size too large"); + return nSizeRet; +} + +// Variable-length integers: bytes are a MSB base-128 encoding of the number. +// The high bit in each byte signifies whether another digit follows. To make +// the encoding is one-to-one, one is subtracted from all but the last digit. +// Thus, the byte sequence a[] with length len, where all but the last byte +// has bit 128 set, encodes the number: +// +// (a[len-1] & 0x7F) + sum(i=1..len-1, 128^i*((a[len-i-1] & 0x7F)+1)) +// +// Properties: +// * Very small (0-127: 1 byte, 128-16511: 2 bytes, 16512-2113663: 3 bytes) +// * Every integer has exactly one encoding +// * Encoding does not depend on size of original integer type +// * No redundancy: every (infinite) byte sequence corresponds to a list +// of encoded integers. +// +// 0: [0x00] 256: [0x81 0x00] +// 1: [0x01] 16383: [0xFE 0x7F] +// 127: [0x7F] 16384: [0xFF 0x00] +// 128: [0x80 0x00] 16511: [0x80 0xFF 0x7F] +// 255: [0x80 0x7F] 65535: [0x82 0xFD 0x7F] +// 2^32: [0x8E 0xFE 0xFE 0xFF 0x00] + +template +inline unsigned int GetSizeOfVarInt(I n) +{ + int nRet = 0; + while(true) { + nRet++; + if (n <= 0x7F) + break; + n = (n >> 7) - 1; + } + return nRet; +} + +template +void WriteVarInt(Stream& os, I n) +{ + unsigned char tmp[(sizeof(n)*8+6)/7]; + int len=0; + while(true) { + tmp[len] = (n & 0x7F) | (len ? 0x80 : 0x00); + if (n <= 0x7F) + break; + n = (n >> 7) - 1; + len++; + } + do { + WRITEDATA(os, tmp[len]); + } while(len--); +} + +template +I ReadVarInt(Stream& is) +{ + I n = 0; + while(true) { + unsigned char chData; + READDATA(is, chData); + n = (n << 7) | (chData & 0x7F); + if (chData & 0x80) + n++; + else + return n; + } +} + +#define FLATDATA(obj) REF(CFlatData((char*)&(obj), (char*)&(obj) + sizeof(obj))) +#define VARINT(obj) REF(WrapVarInt(REF(obj))) + +/** Wrapper for serializing arrays and POD. + */ +class CFlatData +{ +protected: + char* pbegin; + char* pend; +public: + CFlatData(void* pbeginIn, void* pendIn) : pbegin((char*)pbeginIn), pend((char*)pendIn) { } + char* begin() { return pbegin; } + const char* begin() const { return pbegin; } + char* end() { return pend; } + const char* end() const { return pend; } + + unsigned int GetSerializeSize(int, int=0) const + { + return pend - pbegin; + } + + template + void Serialize(Stream& s, int, int=0) const + { + s.write(pbegin, pend - pbegin); + } + + template + void Unserialize(Stream& s, int, int=0) + { + s.read(pbegin, pend - pbegin); + } +}; + +template +class CVarInt +{ +protected: + I &n; +public: + CVarInt(I& nIn) : n(nIn) { } + + unsigned int GetSerializeSize(int, int) const { + return GetSizeOfVarInt(n); + } + + template + void Serialize(Stream &s, int, int) const { + WriteVarInt(s, n); + } + + template + void Unserialize(Stream& s, int, int) { + n = ReadVarInt(s); + } +}; + +template +CVarInt WrapVarInt(I& n) { return CVarInt(n); } + +// +// Forward declarations +// + +// string +template unsigned int GetSerializeSize(const std::basic_string& str, int, int=0); +template void Serialize(Stream& os, const std::basic_string& str, int, int=0); +template void Unserialize(Stream& is, std::basic_string& str, int, int=0); + +// vector +template unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const boost::true_type&); +template unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const boost::false_type&); +template inline unsigned int GetSerializeSize(const std::vector& v, int nType, int nVersion); +template void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const boost::true_type&); +template void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const boost::false_type&); +template inline void Serialize(Stream& os, const std::vector& v, int nType, int nVersion); +template void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const boost::true_type&); +template void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const boost::false_type&); +template inline void Unserialize(Stream& is, std::vector& v, int nType, int nVersion); + +// others derived from vector +extern inline unsigned int GetSerializeSize(const CScript& v, int nType, int nVersion); +template void Serialize(Stream& os, const CScript& v, int nType, int nVersion); +template void Unserialize(Stream& is, CScript& v, int nType, int nVersion); + +// pair +template unsigned int GetSerializeSize(const std::pair& item, int nType, int nVersion); +template void Serialize(Stream& os, const std::pair& item, int nType, int nVersion); +template void Unserialize(Stream& is, std::pair& item, int nType, int nVersion); + +// 3 tuple +template unsigned int GetSerializeSize(const boost::tuple& item, int nType, int nVersion); +template void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion); +template void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion); + +// 4 tuple +template unsigned int GetSerializeSize(const boost::tuple& item, int nType, int nVersion); +template void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion); +template void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion); + +// map +template unsigned int GetSerializeSize(const std::map& m, int nType, int nVersion); +template void Serialize(Stream& os, const std::map& m, int nType, int nVersion); +template void Unserialize(Stream& is, std::map& m, int nType, int nVersion); + +// set +template unsigned int GetSerializeSize(const std::set& m, int nType, int nVersion); +template void Serialize(Stream& os, const std::set& m, int nType, int nVersion); +template void Unserialize(Stream& is, std::set& m, int nType, int nVersion); + + + + + +// +// If none of the specialized versions above matched, default to calling member function. +// "int nType" is changed to "long nType" to keep from getting an ambiguous overload error. +// The compiler will only cast int to long if none of the other templates matched. +// Thanks to Boost serialization for this idea. +// +template +inline unsigned int GetSerializeSize(const T& a, long nType, int nVersion) +{ + return a.GetSerializeSize((int)nType, nVersion); +} + +template +inline void Serialize(Stream& os, const T& a, long nType, int nVersion) +{ + a.Serialize(os, (int)nType, nVersion); +} + +template +inline void Unserialize(Stream& is, T& a, long nType, int nVersion) +{ + a.Unserialize(is, (int)nType, nVersion); +} + + + + + +// +// string +// +template +unsigned int GetSerializeSize(const std::basic_string& str, int, int) +{ + return GetSizeOfCompactSize(str.size()) + str.size() * sizeof(str[0]); +} + +template +void Serialize(Stream& os, const std::basic_string& str, int, int) +{ + WriteCompactSize(os, str.size()); + if (!str.empty()) + os.write((char*)&str[0], str.size() * sizeof(str[0])); +} + +template +void Unserialize(Stream& is, std::basic_string& str, int, int) +{ + unsigned int nSize = ReadCompactSize(is); + str.resize(nSize); + if (nSize != 0) + is.read((char*)&str[0], nSize * sizeof(str[0])); +} + + + +// +// vector +// +template +unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const boost::true_type&) +{ + return (GetSizeOfCompactSize(v.size()) + v.size() * sizeof(T)); +} + +template +unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const boost::false_type&) +{ + unsigned int nSize = GetSizeOfCompactSize(v.size()); + for (typename std::vector::const_iterator vi = v.begin(); vi != v.end(); ++vi) + nSize += GetSerializeSize((*vi), nType, nVersion); + return nSize; +} + +template +inline unsigned int GetSerializeSize(const std::vector& v, int nType, int nVersion) +{ + return GetSerializeSize_impl(v, nType, nVersion, boost::is_fundamental()); +} + + +template +void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const boost::true_type&) +{ + WriteCompactSize(os, v.size()); + if (!v.empty()) + os.write((char*)&v[0], v.size() * sizeof(T)); +} + +template +void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const boost::false_type&) +{ + WriteCompactSize(os, v.size()); + for (typename std::vector::const_iterator vi = v.begin(); vi != v.end(); ++vi) + ::Serialize(os, (*vi), nType, nVersion); +} + +template +inline void Serialize(Stream& os, const std::vector& v, int nType, int nVersion) +{ + Serialize_impl(os, v, nType, nVersion, boost::is_fundamental()); +} + + +template +void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const boost::true_type&) +{ + // Limit size per read so bogus size value won't cause out of memory + v.clear(); + unsigned int nSize = ReadCompactSize(is); + unsigned int i = 0; + while (i < nSize) + { + unsigned int blk = std::min(nSize - i, (unsigned int)(1 + 4999999 / sizeof(T))); + v.resize(i + blk); + is.read((char*)&v[i], blk * sizeof(T)); + i += blk; + } +} + +template +void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const boost::false_type&) +{ + v.clear(); + unsigned int nSize = ReadCompactSize(is); + unsigned int i = 0; + unsigned int nMid = 0; + while (nMid < nSize) + { + nMid += 5000000 / sizeof(T); + if (nMid > nSize) + nMid = nSize; + v.resize(nMid); + for (; i < nMid; i++) + Unserialize(is, v[i], nType, nVersion); + } +} + +template +inline void Unserialize(Stream& is, std::vector& v, int nType, int nVersion) +{ + Unserialize_impl(is, v, nType, nVersion, boost::is_fundamental()); +} + + + +// +// others derived from vector +// +inline unsigned int GetSerializeSize(const CScript& v, int nType, int nVersion) +{ + return GetSerializeSize((const std::vector&)v, nType, nVersion); +} + +template +void Serialize(Stream& os, const CScript& v, int nType, int nVersion) +{ + Serialize(os, (const std::vector&)v, nType, nVersion); +} + +template +void Unserialize(Stream& is, CScript& v, int nType, int nVersion) +{ + Unserialize(is, (std::vector&)v, nType, nVersion); +} + + + +// +// pair +// +template +unsigned int GetSerializeSize(const std::pair& item, int nType, int nVersion) +{ + return GetSerializeSize(item.first, nType, nVersion) + GetSerializeSize(item.second, nType, nVersion); +} + +template +void Serialize(Stream& os, const std::pair& item, int nType, int nVersion) +{ + Serialize(os, item.first, nType, nVersion); + Serialize(os, item.second, nType, nVersion); +} + +template +void Unserialize(Stream& is, std::pair& item, int nType, int nVersion) +{ + Unserialize(is, item.first, nType, nVersion); + Unserialize(is, item.second, nType, nVersion); +} + + + +// +// 3 tuple +// +template +unsigned int GetSerializeSize(const boost::tuple& item, int nType, int nVersion) +{ + unsigned int nSize = 0; + nSize += GetSerializeSize(boost::get<0>(item), nType, nVersion); + nSize += GetSerializeSize(boost::get<1>(item), nType, nVersion); + nSize += GetSerializeSize(boost::get<2>(item), nType, nVersion); + return nSize; +} + +template +void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion) +{ + Serialize(os, boost::get<0>(item), nType, nVersion); + Serialize(os, boost::get<1>(item), nType, nVersion); + Serialize(os, boost::get<2>(item), nType, nVersion); +} + +template +void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion) +{ + Unserialize(is, boost::get<0>(item), nType, nVersion); + Unserialize(is, boost::get<1>(item), nType, nVersion); + Unserialize(is, boost::get<2>(item), nType, nVersion); +} + + + +// +// 4 tuple +// +template +unsigned int GetSerializeSize(const boost::tuple& item, int nType, int nVersion) +{ + unsigned int nSize = 0; + nSize += GetSerializeSize(boost::get<0>(item), nType, nVersion); + nSize += GetSerializeSize(boost::get<1>(item), nType, nVersion); + nSize += GetSerializeSize(boost::get<2>(item), nType, nVersion); + nSize += GetSerializeSize(boost::get<3>(item), nType, nVersion); + return nSize; +} + +template +void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion) +{ + Serialize(os, boost::get<0>(item), nType, nVersion); + Serialize(os, boost::get<1>(item), nType, nVersion); + Serialize(os, boost::get<2>(item), nType, nVersion); + Serialize(os, boost::get<3>(item), nType, nVersion); +} + +template +void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion) +{ + Unserialize(is, boost::get<0>(item), nType, nVersion); + Unserialize(is, boost::get<1>(item), nType, nVersion); + Unserialize(is, boost::get<2>(item), nType, nVersion); + Unserialize(is, boost::get<3>(item), nType, nVersion); +} + + + +// +// map +// +template +unsigned int GetSerializeSize(const std::map& m, int nType, int nVersion) +{ + unsigned int nSize = GetSizeOfCompactSize(m.size()); + for (typename std::map::const_iterator mi = m.begin(); mi != m.end(); ++mi) + nSize += GetSerializeSize((*mi), nType, nVersion); + return nSize; +} + +template +void Serialize(Stream& os, const std::map& m, int nType, int nVersion) +{ + WriteCompactSize(os, m.size()); + for (typename std::map::const_iterator mi = m.begin(); mi != m.end(); ++mi) + Serialize(os, (*mi), nType, nVersion); +} + +template +void Unserialize(Stream& is, std::map& m, int nType, int nVersion) +{ + m.clear(); + unsigned int nSize = ReadCompactSize(is); + typename std::map::iterator mi = m.begin(); + for (unsigned int i = 0; i < nSize; i++) + { + std::pair item; + Unserialize(is, item, nType, nVersion); + mi = m.insert(mi, item); + } +} + + + +// +// set +// +template +unsigned int GetSerializeSize(const std::set& m, int nType, int nVersion) +{ + unsigned int nSize = GetSizeOfCompactSize(m.size()); + for (typename std::set::const_iterator it = m.begin(); it != m.end(); ++it) + nSize += GetSerializeSize((*it), nType, nVersion); + return nSize; +} + +template +void Serialize(Stream& os, const std::set& m, int nType, int nVersion) +{ + WriteCompactSize(os, m.size()); + for (typename std::set::const_iterator it = m.begin(); it != m.end(); ++it) + Serialize(os, (*it), nType, nVersion); +} + +template +void Unserialize(Stream& is, std::set& m, int nType, int nVersion) +{ + m.clear(); + unsigned int nSize = ReadCompactSize(is); + typename std::set::iterator it = m.begin(); + for (unsigned int i = 0; i < nSize; i++) + { + K key; + Unserialize(is, key, nType, nVersion); + it = m.insert(it, key); + } +} + + + +// +// Support for IMPLEMENT_SERIALIZE and READWRITE macro +// +class CSerActionGetSerializeSize { }; +class CSerActionSerialize { }; +class CSerActionUnserialize { }; + +template +inline unsigned int SerReadWrite(Stream& s, const T& obj, int nType, int nVersion, CSerActionGetSerializeSize ser_action) +{ + return ::GetSerializeSize(obj, nType, nVersion); +} + +template +inline unsigned int SerReadWrite(Stream& s, const T& obj, int nType, int nVersion, CSerActionSerialize ser_action) +{ + ::Serialize(s, obj, nType, nVersion); + return 0; +} + +template +inline unsigned int SerReadWrite(Stream& s, T& obj, int nType, int nVersion, CSerActionUnserialize ser_action) +{ + ::Unserialize(s, obj, nType, nVersion); + return 0; +} + +struct ser_streamplaceholder +{ + int nType; + int nVersion; + + int GetType() const { return nType; } + int GetVersion() const { return nVersion; } +}; + + + + + + + + + + + +typedef std::vector > CSerializeData; + +class CSizeComputer +{ +protected: + size_t nSize; + +public: + int nType; + int nVersion; + + CSizeComputer(int nTypeIn, int nVersionIn) : nSize(0), nType(nTypeIn), nVersion(nVersionIn) {} + + int GetType() const { return nType; } + int GetVersion() const { return nVersion; } + + CSizeComputer& write(const char *psz, size_t nSize) + { + this->nSize += nSize; + return *this; + } + + template + CSizeComputer& operator<<(const T& obj) + { + ::Serialize(*this, obj, nType, nVersion); + return (*this); + } + + size_t size() const { + return nSize; + } +}; + +/** Double ended buffer combining vector and stream-like interfaces. + * + * >> and << read and write unformatted data using the above serialization templates. + * Fills with data in linear time; some stringstream implementations take N^2 time. + */ +class CDataStream +{ +protected: + typedef CSerializeData vector_type; + vector_type vch; + unsigned int nReadPos; + short state; + short exceptmask; +public: + int nType; + int nVersion; + + typedef vector_type::allocator_type allocator_type; + typedef vector_type::size_type size_type; + typedef vector_type::difference_type difference_type; + typedef vector_type::reference reference; + typedef vector_type::const_reference const_reference; + typedef vector_type::value_type value_type; + typedef vector_type::iterator iterator; + typedef vector_type::const_iterator const_iterator; + typedef vector_type::reverse_iterator reverse_iterator; + + explicit CDataStream(int nTypeIn, int nVersionIn) + { + Init(nTypeIn, nVersionIn); + } + + CDataStream(const_iterator pbegin, const_iterator pend, int nTypeIn, int nVersionIn) : vch(pbegin, pend) + { + Init(nTypeIn, nVersionIn); + } + +#if !defined(_MSC_VER) || _MSC_VER >= 1300 + CDataStream(const char* pbegin, const char* pend, int nTypeIn, int nVersionIn) : vch(pbegin, pend) + { + Init(nTypeIn, nVersionIn); + } +#endif + + CDataStream(const vector_type& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end()) + { + Init(nTypeIn, nVersionIn); + } + + CDataStream(const std::vector& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end()) + { + Init(nTypeIn, nVersionIn); + } + + CDataStream(const std::vector& vchIn, int nTypeIn, int nVersionIn) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0]) + { + Init(nTypeIn, nVersionIn); + } + + int GetType() const { return nType; } + int GetVersion() const { return nVersion; } + + void Init(int nTypeIn, int nVersionIn) + { + nReadPos = 0; + nType = nTypeIn; + nVersion = nVersionIn; + state = 0; + exceptmask = std::ios::badbit | std::ios::failbit; + } + + CDataStream& operator+=(const CDataStream& b) + { + vch.insert(vch.end(), b.begin(), b.end()); + return *this; + } + + friend CDataStream operator+(const CDataStream& a, const CDataStream& b) + { + CDataStream ret = a; + ret += b; + return (ret); + } + + std::string str() const + { + return (std::string(begin(), end())); + } + + + // + // Vector subset + // + const_iterator begin() const { return vch.begin() + nReadPos; } + iterator begin() { return vch.begin() + nReadPos; } + const_iterator end() const { return vch.end(); } + iterator end() { return vch.end(); } + size_type size() const { return vch.size() - nReadPos; } + bool empty() const { return vch.size() == nReadPos; } + void resize(size_type n, value_type c=0) { vch.resize(n + nReadPos, c); } + void reserve(size_type n) { vch.reserve(n + nReadPos); } + const_reference operator[](size_type pos) const { return vch[pos + nReadPos]; } + reference operator[](size_type pos) { return vch[pos + nReadPos]; } + void clear() { vch.clear(); nReadPos = 0; } + iterator insert(iterator it, const char& x=char()) { return vch.insert(it, x); } + void insert(iterator it, size_type n, const char& x) { vch.insert(it, n, x); } + + void insert(iterator it, std::vector::const_iterator first, std::vector::const_iterator last) + { + assert(last - first >= 0); + if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) + { + // special case for inserting at the front when there's room + nReadPos -= (last - first); + memcpy(&vch[nReadPos], &first[0], last - first); + } + else + vch.insert(it, first, last); + } + +#if !defined(_MSC_VER) || _MSC_VER >= 1300 + void insert(iterator it, const char* first, const char* last) + { + assert(last - first >= 0); + if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) + { + // special case for inserting at the front when there's room + nReadPos -= (last - first); + memcpy(&vch[nReadPos], &first[0], last - first); + } + else + vch.insert(it, first, last); + } +#endif + + iterator erase(iterator it) + { + if (it == vch.begin() + nReadPos) + { + // special case for erasing from the front + if (++nReadPos >= vch.size()) + { + // whenever we reach the end, we take the opportunity to clear the buffer + nReadPos = 0; + return vch.erase(vch.begin(), vch.end()); + } + return vch.begin() + nReadPos; + } + else + return vch.erase(it); + } + + iterator erase(iterator first, iterator last) + { + if (first == vch.begin() + nReadPos) + { + // special case for erasing from the front + if (last == vch.end()) + { + nReadPos = 0; + return vch.erase(vch.begin(), vch.end()); + } + else + { + nReadPos = (last - vch.begin()); + return last; + } + } + else + return vch.erase(first, last); + } + + inline void Compact() + { + vch.erase(vch.begin(), vch.begin() + nReadPos); + nReadPos = 0; + } + + bool Rewind(size_type n) + { + // Rewind by n characters if the buffer hasn't been compacted yet + if (n > nReadPos) + return false; + nReadPos -= n; + return true; + } + + + // + // Stream subset + // + void setstate(short bits, const char* psz) + { + state |= bits; + if (state & exceptmask) + throw std::ios_base::failure(psz); + } + + bool eof() const { return size() == 0; } + bool fail() const { return state & (std::ios::badbit | std::ios::failbit); } + bool good() const { return !eof() && (state == 0); } + void clear(short n) { state = n; } // name conflict with vector clear() + short exceptions() { return exceptmask; } + short exceptions(short mask) { short prev = exceptmask; exceptmask = mask; setstate(0, "CDataStream"); return prev; } + CDataStream* rdbuf() { return this; } + int in_avail() { return size(); } + + void SetType(int n) { nType = n; } + int GetType() { return nType; } + void SetVersion(int n) { nVersion = n; } + int GetVersion() { return nVersion; } + void ReadVersion() { *this >> nVersion; } + void WriteVersion() { *this << nVersion; } + + CDataStream& read(char* pch, size_t nSize) + { + // Read from the beginning of the buffer + unsigned int nReadPosNext = nReadPos + nSize; + if (nReadPosNext >= vch.size()) + { + if (nReadPosNext > vch.size()) + { + setstate(std::ios::failbit, "CDataStream::read() : end of data"); + memset(pch, 0, nSize); + nSize = vch.size() - nReadPos; + } + memcpy(pch, &vch[nReadPos], nSize); + nReadPos = 0; + vch.clear(); + return (*this); + } + memcpy(pch, &vch[nReadPos], nSize); + nReadPos = nReadPosNext; + return (*this); + } + + CDataStream& ignore(int nSize) + { + // Ignore from the beginning of the buffer + assert(nSize >= 0); + unsigned int nReadPosNext = nReadPos + nSize; + if (nReadPosNext >= vch.size()) + { + if (nReadPosNext > vch.size()) + setstate(std::ios::failbit, "CDataStream::ignore() : end of data"); + nReadPos = 0; + vch.clear(); + return (*this); + } + nReadPos = nReadPosNext; + return (*this); + } + + CDataStream& write(const char* pch, size_t nSize) + { + // Write to the end of the buffer + vch.insert(vch.end(), pch, pch + nSize); + return (*this); + } + + template + void Serialize(Stream& s, int nType, int nVersion) const + { + // Special case: stream << stream concatenates like stream += stream + if (!vch.empty()) + s.write((char*)&vch[0], vch.size() * sizeof(vch[0])); + } + + template + unsigned int GetSerializeSize(const T& obj) + { + // Tells the size of the object if serialized to this stream + return ::GetSerializeSize(obj, nType, nVersion); + } + + template + CDataStream& operator<<(const T& obj) + { + // Serialize to this stream + ::Serialize(*this, obj, nType, nVersion); + return (*this); + } + + template + CDataStream& operator>>(T& obj) + { + // Unserialize from this stream + ::Unserialize(*this, obj, nType, nVersion); + return (*this); + } + + void GetAndClear(CSerializeData &data) { + data.insert(data.end(), begin(), end()); + clear(); + } +}; + + + + + + + + + + +/** RAII wrapper for FILE*. + * + * Will automatically close the file when it goes out of scope if not null. + * If you're returning the file pointer, return file.release(). + * If you need to close the file early, use file.fclose() instead of fclose(file). + */ +class CAutoFile +{ +protected: + FILE* file; + short state; + short exceptmask; +public: + int nType; + int nVersion; + + CAutoFile(FILE* filenew, int nTypeIn, int nVersionIn) + { + file = filenew; + nType = nTypeIn; + nVersion = nVersionIn; + state = 0; + exceptmask = std::ios::badbit | std::ios::failbit; + } + + ~CAutoFile() + { + fclose(); + } + + void fclose() + { + if (file != NULL && file != stdin && file != stdout && file != stderr) + ::fclose(file); + file = NULL; + } + + FILE* release() { FILE* ret = file; file = NULL; return ret; } + operator FILE*() { return file; } + FILE* operator->() { return file; } + FILE& operator*() { return *file; } + FILE** operator&() { return &file; } + FILE* operator=(FILE* pnew) { return file = pnew; } + bool operator!() { return (file == NULL); } + + + // + // Stream subset + // + void setstate(short bits, const char* psz) + { + state |= bits; + if (state & exceptmask) + throw std::ios_base::failure(psz); + } + + bool fail() const { return state & (std::ios::badbit | std::ios::failbit); } + bool good() const { return state == 0; } + void clear(short n = 0) { state = n; } + short exceptions() { return exceptmask; } + short exceptions(short mask) { short prev = exceptmask; exceptmask = mask; setstate(0, "CAutoFile"); return prev; } + + void SetType(int n) { nType = n; } + int GetType() { return nType; } + void SetVersion(int n) { nVersion = n; } + int GetVersion() { return nVersion; } + void ReadVersion() { *this >> nVersion; } + void WriteVersion() { *this << nVersion; } + + CAutoFile& read(char* pch, size_t nSize) + { + if (!file) + throw std::ios_base::failure("CAutoFile::read : file handle is NULL"); + if (fread(pch, 1, nSize, file) != nSize) + setstate(std::ios::failbit, feof(file) ? "CAutoFile::read : end of file" : "CAutoFile::read : fread failed"); + return (*this); + } + + CAutoFile& write(const char* pch, size_t nSize) + { + if (!file) + throw std::ios_base::failure("CAutoFile::write : file handle is NULL"); + if (fwrite(pch, 1, nSize, file) != nSize) + setstate(std::ios::failbit, "CAutoFile::write : write failed"); + return (*this); + } + + template + unsigned int GetSerializeSize(const T& obj) + { + // Tells the size of the object if serialized to this stream + return ::GetSerializeSize(obj, nType, nVersion); + } + + template + CAutoFile& operator<<(const T& obj) + { + // Serialize to this stream + if (!file) + throw std::ios_base::failure("CAutoFile::operator<< : file handle is NULL"); + ::Serialize(*this, obj, nType, nVersion); + return (*this); + } + + template + CAutoFile& operator>>(T& obj) + { + // Unserialize from this stream + if (!file) + throw std::ios_base::failure("CAutoFile::operator>> : file handle is NULL"); + ::Unserialize(*this, obj, nType, nVersion); + return (*this); + } +}; + + + +#endif + diff --git a/src/smessage.cpp b/src/smessage.cpp new file mode 100644 index 0000000..ae7bd24 --- /dev/null +++ b/src/smessage.cpp @@ -0,0 +1,3971 @@ +// Copyright (c) 2014 The ShadowCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +/* +Notes: + Running with -debug could leave to and from address hashes and public keys in the log. + + + parameters: + -nosmsg Disable secure messaging (fNoSmsg) + -debugsmsg Show extra debug messages (fDebugSmsg) + -smsgscanchain Scan the block chain for public key addresses on startup + + + Wallet Locked + A copy of each incoming message is stored in bucket files ending in _wl.dat + wl (wallet locked) bucket files are deleted if they expire, like normal buckets + When the wallet is unlocked all the messages in wl files are scanned. + + + Address Whitelist + Owned Addresses are stored in smsgAddresses vector + Saved to smsg.ini + Modify options using the smsglocalkeys rpc command or edit the smsg.ini file (with client closed) + + +*/ + +#include "smessage.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#include "base58.h" +#include "db.h" +#include "init.h" // pwalletMain +#include "main.h" +#include "txdb.h" +#include "sync.h" +#include "eckey.h" + +#include "lz4/lz4.c" + +#include "xxhash/xxhash.h" +#include "xxhash/xxhash.c" + + +boost::thread_group threadGroupSmsg; + +// TODO: For buckets older than current, only need to store no. messages and hash in memory + +boost::signals2::signal NotifySecMsgInboxChanged; +boost::signals2::signal NotifySecMsgOutboxChanged; +boost::signals2::signal NotifySecMsgWalletUnlocked; + +bool fSecMsgEnabled = false; + +std::map smsgBuckets; +std::vector smsgAddresses; +SecMsgOptions smsgOptions; + + +CCriticalSection cs_smsg; +CCriticalSection cs_smsgDB; +CCriticalSection cs_smsgThreads; + +leveldb::DB *smsgDB = NULL; + + +namespace fs = boost::filesystem; + +bool SecMsgCrypter::SetKey(const std::vector& vchNewKey, uint8_t* chNewIV) +{ + if (vchNewKey.size() < sizeof(chKey)) + return false; + + return SetKey(&vchNewKey[0], chNewIV); +}; + +bool SecMsgCrypter::SetKey(const uint8_t* chNewKey, uint8_t* chNewIV) +{ + // -- for EVP_aes_256_cbc() key must be 256 bit, iv must be 128 bit. + memcpy(&chKey[0], chNewKey, sizeof(chKey)); + memcpy(chIV, chNewIV, sizeof(chIV)); + + fKeySet = true; + return true; +}; + +bool SecMsgCrypter::Encrypt(uint8_t* chPlaintext, uint32_t nPlain, std::vector &vchCiphertext) +{ + if (!fKeySet) + return false; + + // -- max ciphertext len for a n bytes of plaintext is n + AES_BLOCK_SIZE - 1 bytes + int nLen = nPlain; + + int nCLen = nLen + AES_BLOCK_SIZE, nFLen = 0; + vchCiphertext = std::vector (nCLen); + + EVP_CIPHER_CTX ctx; + + bool fOk = true; + + EVP_CIPHER_CTX_init(&ctx); + if (fOk) fOk = EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, &chKey[0], &chIV[0]); + if (fOk) fOk = EVP_EncryptUpdate(&ctx, &vchCiphertext[0], &nCLen, chPlaintext, nLen); + if (fOk) fOk = EVP_EncryptFinal_ex(&ctx, (&vchCiphertext[0])+nCLen, &nFLen); + EVP_CIPHER_CTX_cleanup(&ctx); + + if (!fOk) + return false; + + vchCiphertext.resize(nCLen + nFLen); + + return true; +}; + +bool SecMsgCrypter::Decrypt(uint8_t* chCiphertext, uint32_t nCipher, std::vector& vchPlaintext) +{ + if (!fKeySet) + return false; + + // plaintext will always be equal to or lesser than length of ciphertext + int nPLen = nCipher, nFLen = 0; + + vchPlaintext.resize(nCipher); + + EVP_CIPHER_CTX ctx; + + bool fOk = true; + + EVP_CIPHER_CTX_init(&ctx); + if (fOk) fOk = EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, &chKey[0], &chIV[0]); + if (fOk) fOk = EVP_DecryptUpdate(&ctx, &vchPlaintext[0], &nPLen, &chCiphertext[0], nCipher); + if (fOk) fOk = EVP_DecryptFinal_ex(&ctx, (&vchPlaintext[0])+nPLen, &nFLen); + EVP_CIPHER_CTX_cleanup(&ctx); + + if (!fOk) + return false; + + vchPlaintext.resize(nPLen + nFLen); + + return true; +}; + +void SecMsgBucket::hashBucket() +{ + if (fDebugSmsg) + LogPrintf("SecMsgBucket::hashBucket()\n"); + + timeChanged = GetTime(); + + std::set::iterator it; + + void* state = XXH32_init(1); + + for (it = setTokens.begin(); it != setTokens.end(); ++it) + { + XXH32_update(state, it->sample, 8); + }; + + hash = XXH32_digest(state); + + if (fDebugSmsg) + LogPrintf("Hashed %u messages, hash %u\n", setTokens.size(), hash); +}; + + +bool SecMsgDB::Open(const char* pszMode) +{ + if (smsgDB) + { + pdb = smsgDB; + return true; + }; + + bool fCreate = strchr(pszMode, 'c'); + + fs::path fullpath = GetDataDir() / "smsgDB"; + + if (!fCreate + && (!fs::exists(fullpath) + || !fs::is_directory(fullpath))) + { + LogPrintf("SecMsgDB::open() - DB does not exist.\n"); + return false; + }; + + leveldb::Options options; + options.create_if_missing = fCreate; + leveldb::Status s = leveldb::DB::Open(options, fullpath.string(), &smsgDB); + + if (!s.ok()) + { + LogPrintf("SecMsgDB::open() - Error opening db: %s.\n", s.ToString().c_str()); + return false; + }; + + pdb = smsgDB; + + return true; +}; + + +class SecMsgBatchScanner : public leveldb::WriteBatch::Handler +{ +public: + std::string needle; + bool* deleted; + std::string* foundValue; + bool foundEntry; + + SecMsgBatchScanner() : foundEntry(false) {} + + virtual void Put(const leveldb::Slice& key, const leveldb::Slice& value) + { + if (key.ToString() == needle) + { + foundEntry = true; + *deleted = false; + *foundValue = value.ToString(); + }; + }; + + virtual void Delete(const leveldb::Slice& key) + { + if (key.ToString() == needle) + { + foundEntry = true; + *deleted = true; + }; + }; +}; + +// When performing a read, if we have an active batch we need to check it first +// before reading from the database, as the rest of the code assumes that once +// a database transaction begins reads are consistent with it. It would be good +// to change that assumption in future and avoid the performance hit, though in +// practice it does not appear to be large. +bool SecMsgDB::ScanBatch(const CDataStream& key, std::string* value, bool* deleted) const +{ + if (!activeBatch) + return false; + + *deleted = false; + SecMsgBatchScanner scanner; + scanner.needle = key.str(); + scanner.deleted = deleted; + scanner.foundValue = value; + leveldb::Status s = activeBatch->Iterate(&scanner); + if (!s.ok()) + { + LogPrintf("SecMsgDB ScanBatch error: %s\n", s.ToString().c_str()); + return false; + }; + + return scanner.foundEntry; +} + +bool SecMsgDB::TxnBegin() +{ + if (activeBatch) + return true; + activeBatch = new leveldb::WriteBatch(); + return true; +}; + +bool SecMsgDB::TxnCommit() +{ + if (!activeBatch) + return false; + + leveldb::WriteOptions writeOptions; + writeOptions.sync = true; + leveldb::Status status = pdb->Write(writeOptions, activeBatch); + delete activeBatch; + activeBatch = NULL; + + if (!status.ok()) + { + LogPrintf("SecMsgDB batch commit failure: %s\n", status.ToString().c_str()); + return false; + }; + + return true; +}; + +bool SecMsgDB::TxnAbort() +{ + delete activeBatch; + activeBatch = NULL; + return true; +}; + +bool SecMsgDB::ReadPK(CKeyID& addr, CPubKey& pubkey) +{ + if (!pdb) + return false; + + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.reserve(sizeof(addr) + 2); + ssKey << 'p'; + ssKey << 'k'; + ssKey << addr; + std::string strValue; + + bool readFromDb = true; + if (activeBatch) + { + // -- check activeBatch first + bool deleted = false; + readFromDb = ScanBatch(ssKey, &strValue, &deleted) == false; + if (deleted) + return false; + }; + + if (readFromDb) + { + leveldb::Status s = pdb->Get(leveldb::ReadOptions(), ssKey.str(), &strValue); + if (!s.ok()) + { + if (s.IsNotFound()) + return false; + LogPrintf("LevelDB read failure: %s\n", s.ToString().c_str()); + return false; + }; + }; + + try { + CDataStream ssValue(strValue.data(), strValue.data() + strValue.size(), SER_DISK, CLIENT_VERSION); + ssValue >> pubkey; + } catch (std::exception& e) { + LogPrintf("SecMsgDB::ReadPK() unserialize threw: %s.\n", e.what()); + return false; + } + + return true; +}; + +bool SecMsgDB::WritePK(CKeyID& addr, CPubKey& pubkey) +{ + if (!pdb) + return false; + + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.reserve(sizeof(addr) + 2); + ssKey << 'p'; + ssKey << 'k'; + ssKey << addr; + CDataStream ssValue(SER_DISK, CLIENT_VERSION); + ssValue.reserve(sizeof(pubkey)); + ssValue << pubkey; + + if (activeBatch) + { + activeBatch->Put(ssKey.str(), ssValue.str()); + return true; + }; + + leveldb::WriteOptions writeOptions; + writeOptions.sync = true; + leveldb::Status s = pdb->Put(writeOptions, ssKey.str(), ssValue.str()); + if (!s.ok()) + { + LogPrintf("SecMsgDB write failure: %s\n", s.ToString().c_str()); + return false; + }; + + return true; +}; + +bool SecMsgDB::ExistsPK(CKeyID& addr) +{ + if (!pdb) + return false; + + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.reserve(sizeof(addr)+2); + ssKey << 'p'; + ssKey << 'k'; + ssKey << addr; + std::string unused; + + if (activeBatch) + { + bool deleted; + if (ScanBatch(ssKey, &unused, &deleted) && !deleted) + { + return true; + }; + }; + + leveldb::Status s = pdb->Get(leveldb::ReadOptions(), ssKey.str(), &unused); + return s.IsNotFound() == false; +}; + + +bool SecMsgDB::NextSmesg(leveldb::Iterator* it, std::string& prefix, uint8_t* chKey, SecMsgStored& smsgStored) +{ + if (!pdb) + return false; + + if (!it->Valid()) // first run + it->Seek(prefix); + else + it->Next(); + + if (!(it->Valid() + && it->key().size() == 18 + && memcmp(it->key().data(), prefix.data(), 2) == 0)) + return false; + + memcpy(chKey, it->key().data(), 18); + + try { + CDataStream ssValue(it->value().data(), it->value().data() + it->value().size(), SER_DISK, CLIENT_VERSION); + ssValue >> smsgStored; + } catch (std::exception& e) { + LogPrintf("SecMsgDB::NextSmesg() unserialize threw: %s.\n", e.what()); + return false; + } + + return true; +}; + +bool SecMsgDB::NextSmesgKey(leveldb::Iterator* it, std::string& prefix, uint8_t* chKey) +{ + if (!pdb) + return false; + + if (!it->Valid()) // first run + it->Seek(prefix); + else + it->Next(); + + if (!(it->Valid() + && it->key().size() == 18 + && memcmp(it->key().data(), prefix.data(), 2) == 0)) + return false; + + memcpy(chKey, it->key().data(), 18); + + return true; +}; + +bool SecMsgDB::ReadSmesg(uint8_t* chKey, SecMsgStored& smsgStored) +{ + if (!pdb) + return false; + + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.write((const char*)chKey, 18); + std::string strValue; + + bool readFromDb = true; + if (activeBatch) + { + // -- check activeBatch first + bool deleted = false; + readFromDb = ScanBatch(ssKey, &strValue, &deleted) == false; + if (deleted) + return false; + }; + + if (readFromDb) + { + leveldb::Status s = pdb->Get(leveldb::ReadOptions(), ssKey.str(), &strValue); + if (!s.ok()) + { + if (s.IsNotFound()) + return false; + LogPrintf("LevelDB read failure: %s\n", s.ToString().c_str()); + return false; + }; + }; + + try { + CDataStream ssValue(strValue.data(), strValue.data() + strValue.size(), SER_DISK, CLIENT_VERSION); + ssValue >> smsgStored; + } catch (std::exception& e) { + LogPrintf("SecMsgDB::ReadSmesg() unserialize threw: %s.\n", e.what()); + return false; + } + + return true; +}; + +bool SecMsgDB::WriteSmesg(uint8_t* chKey, SecMsgStored& smsgStored) +{ + if (!pdb) + return false; + + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.write((const char*)chKey, 18); + CDataStream ssValue(SER_DISK, CLIENT_VERSION); + ssValue << smsgStored; + + if (activeBatch) + { + activeBatch->Put(ssKey.str(), ssValue.str()); + return true; + }; + + leveldb::WriteOptions writeOptions; + writeOptions.sync = true; + leveldb::Status s = pdb->Put(writeOptions, ssKey.str(), ssValue.str()); + if (!s.ok()) + { + LogPrintf("SecMsgDB write failed: %s\n", s.ToString().c_str()); + return false; + }; + + return true; +}; + +bool SecMsgDB::ExistsSmesg(uint8_t* chKey) +{ + if (!pdb) + return false; + + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.write((const char*)chKey, 18); + std::string unused; + + if (activeBatch) + { + bool deleted; + if (ScanBatch(ssKey, &unused, &deleted) && !deleted) + { + return true; + }; + }; + + leveldb::Status s = pdb->Get(leveldb::ReadOptions(), ssKey.str(), &unused); + return s.IsNotFound() == false; + return true; +}; + +bool SecMsgDB::EraseSmesg(uint8_t* chKey) +{ + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.write((const char*)chKey, 18); + + if (activeBatch) + { + activeBatch->Delete(ssKey.str()); + return true; + }; + + leveldb::WriteOptions writeOptions; + writeOptions.sync = true; + leveldb::Status s = pdb->Delete(writeOptions, ssKey.str()); + + if (s.ok() || s.IsNotFound()) + return true; + LogPrintf("SecMsgDB erase failed: %s\n", s.ToString().c_str()); + return false; +}; + +void ThreadSecureMsg() +{ + // -- bucket management thread + + while (fSecMsgEnabled) + { + int64_t now = GetTime(); + + if (fDebugSmsg) + LogPrintf("SecureMsgThread %d \n", now); + + int64_t cutoffTime = now - SMSG_RETENTION; + { + LOCK(cs_smsg); + + for (std::map::iterator it(smsgBuckets.begin()); it != smsgBuckets.end(); it++) + { + //if (fDebugSmsg) + // LogPrintf("Checking bucket %d", size %u \n", it->first, it->second.setTokens.size()); + if (it->first < cutoffTime) + { + if (fDebugSmsg) + LogPrintf("Removing bucket %d \n", it->first); + + std::string fileName = boost::lexical_cast(it->first); + + fs::path fullPath = GetDataDir() / "smsgStore" / (fileName + "_01.dat"); + if (fs::exists(fullPath)) + { + try { + fs::remove(fullPath); + } catch (const fs::filesystem_error& ex) + { + LogPrintf("Error removing bucket file %s.\n", ex.what()); + }; + } else + { + LogPrintf("Path %s does not exist \n", fullPath.string().c_str()); + }; + + // -- look for a wl file, it stores incoming messages when wallet is locked + fullPath = GetDataDir() / "smsgStore" / (fileName + "_01_wl.dat"); + if (fs::exists(fullPath)) + { + try { + fs::remove(fullPath); + } catch (const fs::filesystem_error& ex) + { + LogPrintf("Error removing wallet locked file %s.\n", ex.what()); + }; + }; + + smsgBuckets.erase(it); + } else + if (it->second.nLockCount > 0) // -- tick down nLockCount, so will eventually expire if peer never sends data + { + it->second.nLockCount--; + + if (it->second.nLockCount == 0) // lock timed out + { + NodeId nPeerId = it->second.nLockPeerId; + int64_t ignoreUntil = GetTime() + SMSG_TIME_IGNORE; + + if (fDebugSmsg) + LogPrintf("Lock on bucket %d for peer %d timed out.\n", it->first, nPeerId); + + // -- look through the nodes for the peer that locked this bucket + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + if (pnode->id != nPeerId) + continue; + pnode->smsgData.ignoreUntil = ignoreUntil; + + // -- alert peer that they are being ignored + std::vector vchData; + vchData.resize(8); + memcpy(&vchData[0], &ignoreUntil, 8); + pnode->PushMessage("smsgIgnore", vchData); + + if (fDebugSmsg) + LogPrintf("This node will ignore peer %d until %d.\n", nPeerId, ignoreUntil); + break; + }; + it->second.nLockPeerId = 0; + }; // if (it->second.nLockCount == 0) + }; // ! if (it->first < cutoffTime) + }; + }; // LOCK(cs_smsg); + + MilliSleep(SMSG_THREAD_DELAY * 1000); // // check every SMSG_THREAD_DELAY seconds + }; +}; + +void ThreadSecureMsgPow() +{ + // -- proof of work thread + + int rv; + std::vector vchKey; + SecMsgStored smsgStored; + + std::string sPrefix("qm"); + uint8_t chKey[18]; + + + while (fSecMsgEnabled) + { + // -- sleep at end, then fSecMsgEnabled is tested on wake + + SecMsgDB dbOutbox; + leveldb::Iterator* it; + { + LOCK(cs_smsgDB); + + if (!dbOutbox.Open("cr+")) + continue; + + // -- fifo (smallest key first) + it = dbOutbox.pdb->NewIterator(leveldb::ReadOptions()); + } + // -- break up lock, SecureMsgSetHash will take long + + for (;;) + { + { + LOCK(cs_smsgDB); + if (!dbOutbox.NextSmesg(it, sPrefix, chKey, smsgStored)) + break; + } + + uint8_t* pHeader = &smsgStored.vchMessage[0]; + uint8_t* pPayload = &smsgStored.vchMessage[SMSG_HDR_LEN]; + SecureMessage* psmsg = (SecureMessage*) pHeader; + + // -- do proof of work + rv = SecureMsgSetHash(pHeader, pPayload, psmsg->nPayload); + if (rv == 2) + break; // leave message in db, if terminated due to shutdown + + // -- message is removed here, no matter what + { + LOCK(cs_smsgDB); + dbOutbox.EraseSmesg(chKey); + } + if (rv != 0) + { + LogPrintf("SecMsgPow: Could not get proof of work hash, message removed.\n"); + continue; + }; + + // -- add to message store + { + LOCK(cs_smsg); + if (SecureMsgStore(pHeader, pPayload, psmsg->nPayload, true) != 0) + { + LogPrintf("SecMsgPow: Could not place message in buckets, message removed.\n"); + continue; + }; + } + + // -- test if message was sent to self + if (SecureMsgScanMessage(pHeader, pPayload, psmsg->nPayload, true) != 0) + { + // message recipient is not this node (or failed) + }; + }; + + { + LOCK(cs_smsg); + delete it; + } + + // -- shutdown thread waits 5 seconds, this should be less + MilliSleep(2000); // seconds + }; +}; + +int SecureMsgBuildBucketSet() +{ + /* + Build the bucket set by scanning the files in the smsgStore dir. + + smsgBuckets should be empty + */ + + if (fDebugSmsg) + LogPrintf("SecureMsgBuildBucketSet()\n"); + + int64_t now = GetTime(); + uint32_t nFiles = 0; + uint32_t nMessages = 0; + + fs::path pathSmsgDir = GetDataDir() / "smsgStore"; + fs::directory_iterator itend; + + + if (!fs::exists(pathSmsgDir) + || !fs::is_directory(pathSmsgDir)) + { + LogPrintf("Message store directory does not exist.\n"); + return 0; // not an error + } + + + for (fs::directory_iterator itd(pathSmsgDir) ; itd != itend ; ++itd) + { + if (!fs::is_regular_file(itd->status())) + continue; + + std::string fileType = (*itd).path().extension().string(); + + if (fileType.compare(".dat") != 0) + continue; + + std::string fileName = (*itd).path().filename().string(); + + + if (fDebugSmsg) + LogPrintf("Processing file: %s.\n", fileName.c_str()); + + nFiles++; + + // TODO files must be split if > 2GB + // time_noFile.dat + size_t sep = fileName.find_first_of("_"); + if (sep == std::string::npos) + continue; + + std::string stime = fileName.substr(0, sep); + + int64_t fileTime = boost::lexical_cast(stime); + + if (fileTime < now - SMSG_RETENTION) + { + LogPrintf("Dropping file %s, expired.\n", fileName.c_str()); + try { + fs::remove((*itd).path()); + } catch (const fs::filesystem_error& ex) + { + LogPrintf("Error removing bucket file %s, %s.\n", fileName.c_str(), ex.what()); + }; + continue; + }; + + if (boost::algorithm::ends_with(fileName, "_wl.dat")) + { + if (fDebugSmsg) + LogPrintf("Skipping wallet locked file: %s.\n", fileName.c_str()); + continue; + }; + + size_t nTokenSetSize = 0; + SecureMessage smsg; + { + LOCK(cs_smsg); + + std::set& tokenSet = smsgBuckets[fileTime].setTokens; + + FILE *fp; + + if (!(fp = fopen((*itd).path().string().c_str(), "rb"))) + { + LogPrintf("Error opening file: %s\n", strerror(errno)); + continue; + }; + + for (;;) + { + long int ofs = ftell(fp); + SecMsgToken token; + token.offset = ofs; + errno = 0; + if (fread(&smsg.hash[0], sizeof(uint8_t), SMSG_HDR_LEN, fp) != (size_t)SMSG_HDR_LEN) + { + if (errno != 0) + { + LogPrintf("fread header failed: %s\n", strerror(errno)); + } else + { + //LogPrintf("End of file.\n"); + }; + break; + }; + token.timestamp = smsg.timestamp; + + if (smsg.nPayload < 8) + continue; + + if (fread(token.sample, sizeof(uint8_t), 8, fp) != 8) + { + LogPrintf("fread data failed: %s\n", strerror(errno)); + break; + }; + + if (fseek(fp, smsg.nPayload-8, SEEK_CUR) != 0) + { + LogPrintf("fseek, strerror: %s.\n", strerror(errno)); + break; + }; + + tokenSet.insert(token); + }; + + fclose(fp); + + smsgBuckets[fileTime].hashBucket(); + + nTokenSetSize = tokenSet.size(); + } // LOCK(cs_smsg); + + nMessages += nTokenSetSize; + if (fDebugSmsg) + LogPrintf("Bucket %d contains %u messages.\n", fileTime, nTokenSetSize); + }; + + LogPrintf("Processed %u files, loaded %u buckets containing %u messages.\n", nFiles, smsgBuckets.size(), nMessages); + + return 0; +}; + +int SecureMsgAddWalletAddresses() +{ + if (fDebugSmsg) + LogPrintf("SecureMsgAddWalletAddresses()\n"); + + std::string sAnonPrefix("ao "); + + uint32_t nAdded = 0; + BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& entry, pwalletMain->mapAddressBook) + { + if (!IsMine(*pwalletMain, entry.first)) + continue; + + // -- skip addresses for anon outputs + if (entry.second.compare(0, sAnonPrefix.length(), sAnonPrefix) == 0) + continue; + + // TODO: skip addresses for stealth transactions + + CBitcoinAddress coinAddress(entry.first); + if (!coinAddress.IsValid()) + continue; + + std::string address; + std::string strPublicKey; + address = coinAddress.ToString(); + + bool fExists = 0; + for (std::vector::iterator it = smsgAddresses.begin(); it != smsgAddresses.end(); ++it) + { + if (address != it->sAddress) + continue; + fExists = 1; + break; + }; + + if (fExists) + continue; + + bool recvEnabled = 1; + bool recvAnon = 1; + + smsgAddresses.push_back(SecMsgAddress(address, recvEnabled, recvAnon)); + nAdded++; + }; + + if (fDebugSmsg) + LogPrintf("Added %u addresses to whitelist.\n", nAdded); + + return 0; +}; + + +int SecureMsgReadIni() +{ + if (!fSecMsgEnabled) + return false; + + if (fDebugSmsg) + LogPrintf("SecureMsgReadIni()\n"); + + fs::path fullpath = GetDataDir() / "smsg.ini"; + + + FILE *fp; + errno = 0; + if (!(fp = fopen(fullpath.string().c_str(), "r"))) + { + LogPrintf("Error opening file: %s\n", strerror(errno)); + return 1; + }; + + char cLine[512]; + char *pName, *pValue; + + char cAddress[64]; + int addrRecv, addrRecvAnon; + + while (fgets(cLine, 512, fp)) + { + cLine[strcspn(cLine, "\n")] = '\0'; + cLine[strcspn(cLine, "\r")] = '\0'; + cLine[511] = '\0'; // for safety + + // -- check that line contains a name value pair and is not a comment, or section header + if (cLine[0] == '#' || cLine[0] == '[' || strcspn(cLine, "=") < 1) + continue; + + if (!(pName = strtok(cLine, "=")) + || !(pValue = strtok(NULL, "="))) + continue; + + if (strcmp(pName, "newAddressRecv") == 0) + { + smsgOptions.fNewAddressRecv = (strcmp(pValue, "true") == 0) ? true : false; + } else + if (strcmp(pName, "newAddressAnon") == 0) + { + smsgOptions.fNewAddressAnon = (strcmp(pValue, "true") == 0) ? true : false; + } else + if (strcmp(pName, "key") == 0) + { + int rv = sscanf(pValue, "%64[^|]|%d|%d", cAddress, &addrRecv, &addrRecvAnon); + if (rv == 3) + { + smsgAddresses.push_back(SecMsgAddress(std::string(cAddress), addrRecv, addrRecvAnon)); + } else + { + LogPrintf("Could not parse key line %s, rv %d.\n", pValue, rv); + } + } else + { + LogPrintf("Unknown setting name: '%s'.", pName); + }; + }; + + LogPrintf("Loaded %u addresses.\n", smsgAddresses.size()); + + fclose(fp); + + return 0; +}; + +int SecureMsgWriteIni() +{ + if (!fSecMsgEnabled) + return false; + + if (fDebugSmsg) + LogPrintf("SecureMsgWriteIni()\n"); + + fs::path fullpath = GetDataDir() / "smsg.ini~"; + + FILE *fp; + errno = 0; + if (!(fp = fopen(fullpath.string().c_str(), "w"))) + { + LogPrintf("Error opening file: %s\n", strerror(errno)); + return 1; + }; + + if (fwrite("[Options]\n", sizeof(char), 10, fp) != 10) + { + LogPrintf("fwrite error: %s\n", strerror(errno)); + fclose(fp); + return false; + }; + + if (fprintf(fp, "newAddressRecv=%s\n", smsgOptions.fNewAddressRecv ? "true" : "false") < 0 + || fprintf(fp, "newAddressAnon=%s\n", smsgOptions.fNewAddressAnon ? "true" : "false") < 0) + { + LogPrintf("fprintf error: %s\n", strerror(errno)); + fclose(fp); + return false; + } + + if (fwrite("\n[Keys]\n", sizeof(char), 8, fp) != 8) + { + LogPrintf("fwrite error: %s\n", strerror(errno)); + fclose(fp); + return false; + }; + for (std::vector::iterator it = smsgAddresses.begin(); it != smsgAddresses.end(); ++it) + { + errno = 0; + if (fprintf(fp, "key=%s|%d|%d\n", it->sAddress.c_str(), it->fReceiveEnabled, it->fReceiveAnon) < 0) + { + LogPrintf("fprintf error: %s\n", strerror(errno)); + continue; + }; + }; + + + fclose(fp); + + + try { + fs::path finalpath = GetDataDir() / "smsg.ini"; + fs::rename(fullpath, finalpath); + } catch (const fs::filesystem_error& ex) + { + LogPrintf("Error renaming file %s, %s.\n", fullpath.string().c_str(), ex.what()); + }; + return 0; +}; + + +/** called from AppInit2() in init.cpp */ +bool SecureMsgStart(bool fDontStart, bool fScanChain) +{ + if (fDontStart) + { + LogPrintf("Secure messaging not started.\n"); + return false; + }; + + LogPrintf("Secure messaging starting.\n"); + + fSecMsgEnabled = true; + + if (SecureMsgReadIni() != 0) + LogPrintf("Failed to read smsg.ini\n"); + + if (smsgAddresses.size() < 1) + { + LogPrintf("No address keys loaded.\n"); + if (SecureMsgAddWalletAddresses() != 0) + LogPrintf("Failed to load addresses from wallet.\n"); + }; + + if (fScanChain) + { + SecureMsgScanBlockChain(); + }; + + if (SecureMsgBuildBucketSet() != 0) + { + LogPrintf("SecureMsg could not load bucket sets, secure messaging disabled.\n"); + fSecMsgEnabled = false; + return false; + }; + + threadGroupSmsg.create_thread(boost::bind(&TraceThread, "smsg", &ThreadSecureMsg)); + threadGroupSmsg.create_thread(boost::bind(&TraceThread, "smsg-pow", &ThreadSecureMsgPow)); + + /* + // -- start threads + if (!NewThread(ThreadSecureMsg, NULL) + || !NewThread(ThreadSecureMsgPow, NULL)) + { + LogPrintf("SecureMsg could not start threads, secure messaging disabled.\n"); + fSecMsgEnabled = false; + return false; + }; + */ + return true; +}; + +bool SecureMsgShutdown() +{ + if (!fSecMsgEnabled) + return false; + + LogPrintf("Stopping secure messaging.\n"); + + + if (SecureMsgWriteIni() != 0) + LogPrintf("Failed to save smsg.ini\n"); + + fSecMsgEnabled = false; + + threadGroupSmsg.interrupt_all(); + threadGroupSmsg.join_all(); + + if (smsgDB) + { + LOCK(cs_smsgDB); + delete smsgDB; + smsgDB = NULL; + }; + + return true; +}; + +bool SecureMsgEnable() +{ + // -- start secure messaging at runtime + if (fSecMsgEnabled) + { + LogPrintf("SecureMsgEnable: secure messaging is already enabled.\n"); + return false; + }; + + { + LOCK(cs_smsg); + fSecMsgEnabled = true; + + smsgAddresses.clear(); // should be empty already + if (SecureMsgReadIni() != 0) + LogPrintf("Failed to read smsg.ini\n"); + + if (smsgAddresses.size() < 1) + { + LogPrintf("No address keys loaded.\n"); + if (SecureMsgAddWalletAddresses() != 0) + LogPrintf("Failed to load addresses from wallet.\n"); + }; + + smsgBuckets.clear(); // should be empty already + + if (SecureMsgBuildBucketSet() != 0) + { + LogPrintf("SecureMsgEnable: could not load bucket sets, secure messaging disabled.\n"); + fSecMsgEnabled = false; + return false; + }; + + }; // LOCK(cs_smsg); + + // -- start threads + threadGroupSmsg.create_thread(boost::bind(&TraceThread, "smsg", &ThreadSecureMsg)); + threadGroupSmsg.create_thread(boost::bind(&TraceThread, "smsg-pow", &ThreadSecureMsgPow)); + /* + if (!NewThread(ThreadSecureMsg, NULL) + || !NewThread(ThreadSecureMsgPow, NULL)) + { + LogPrintf("SecureMsgEnable could not start threads, secure messaging disabled.\n"); + fSecMsgEnabled = false; + return false; + }; + */ + // -- ping each peer, don't know which have messaging enabled + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + pnode->PushMessage("smsgPing"); + pnode->PushMessage("smsgPong"); // Send pong as have missed initial ping sent by peer when it connected + }; + } + + LogPrintf("Secure messaging enabled.\n"); + return true; +}; + +bool SecureMsgDisable() +{ + // -- stop secure messaging at runtime + if (!fSecMsgEnabled) + { + LogPrintf("SecureMsgDisable: secure messaging is already disabled.\n"); + return false; + }; + + { + LOCK(cs_smsg); + fSecMsgEnabled = false; + + threadGroupSmsg.interrupt_all(); + threadGroupSmsg.join_all(); + + // -- clear smsgBuckets + std::map::iterator it; + it = smsgBuckets.begin(); + for (it = smsgBuckets.begin(); it != smsgBuckets.end(); ++it) + { + it->second.setTokens.clear(); + }; + smsgBuckets.clear(); + + // -- tell each smsg enabled peer that this node is disabling + { + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + if (!pnode->smsgData.fEnabled) + continue; + + pnode->PushMessage("smsgDisabled"); + pnode->smsgData.fEnabled = false; + }; + } + + if (SecureMsgWriteIni() != 0) + LogPrintf("Failed to save smsg.ini\n"); + + smsgAddresses.clear(); + + } // LOCK(cs_smsg); + + // -- allow time for threads to stop + MilliSleep(3000); // seconds + // TODO be certain that threads have stopped + + if (smsgDB) + { + LOCK(cs_smsgDB); + delete smsgDB; + smsgDB = NULL; + }; + + + LogPrintf("Secure messaging disabled.\n"); + return true; +}; + + +bool SecureMsgReceiveData(CNode* pfrom, std::string strCommand, CDataStream& vRecv) +{ + /* + Called from ProcessMessage + Runs in ThreadMessageHandler2 + */ + + if (fDebugSmsg) + LogPrintf("SecureMsgReceiveData() %s %s.\n", pfrom->addrName.c_str(), strCommand.c_str()); + + { + + + + if (strCommand == "smsgInv") + { + std::vector vchData; + vRecv >> vchData; + + if (vchData.size() < 4) + { + pfrom->Misbehaving(1); + return false; // not enough data received to be a valid smsgInv + }; + + int64_t now = GetTime(); + + if (now < pfrom->smsgData.ignoreUntil) + { + if (fDebugSmsg) + LogPrintf("Node is ignoring peer %d until %d.\n", pfrom->id, pfrom->smsgData.ignoreUntil); + return false; + }; + + uint32_t nBuckets = smsgBuckets.size(); + uint32_t nLocked = 0; // no. of locked buckets on this node + uint32_t nInvBuckets; // no. of bucket headers sent by peer in smsgInv + memcpy(&nInvBuckets, &vchData[0], 4); + if (fDebugSmsg) + LogPrintf("Remote node sent %d bucket headers, this has %d.\n", nInvBuckets, nBuckets); + + + // -- Check no of buckets: + if (nInvBuckets > (SMSG_RETENTION / SMSG_BUCKET_LEN) + 1) // +1 for some leeway + { + LogPrintf("Peer sent more bucket headers than possible %u, %u.\n", nInvBuckets, (SMSG_RETENTION / SMSG_BUCKET_LEN)); + pfrom->Misbehaving(1); + return false; + }; + + if (vchData.size() < 4 + nInvBuckets*16) + { + LogPrintf("Remote node did not send enough data.\n"); + pfrom->Misbehaving(1); + return false; + }; + + std::vector vchDataOut; + vchDataOut.reserve(4 + 8 * nInvBuckets); // reserve max possible size + vchDataOut.resize(4); + uint32_t nShowBuckets = 0; + + + uint8_t *p = &vchData[4]; + for (uint32_t i = 0; i < nInvBuckets; ++i) + { + int64_t time; + uint32_t ncontent, hash; + memcpy(&time, p, 8); + memcpy(&ncontent, p+8, 4); + memcpy(&hash, p+12, 4); + + p += 16; + + // Check time valid: + if (time < now - SMSG_RETENTION) + { + if (fDebugSmsg) + LogPrintf("Not interested in peer bucket %d, has expired.\n", time); + + if (time < now - SMSG_RETENTION - SMSG_TIME_LEEWAY) + pfrom->Misbehaving(1); + continue; + }; + if (time > now + SMSG_TIME_LEEWAY) + { + if (fDebugSmsg) + LogPrintf("Not interested in peer bucket %d, in the future.\n", time); + pfrom->Misbehaving(1); + continue; + }; + + if (ncontent < 1) + { + if (fDebugSmsg) + LogPrintf("Peer sent empty bucket, ignore %d %u %u.\n", time, ncontent, hash); + continue; + }; + + if (fDebugSmsg) + { + LogPrintf("peer bucket %d %u %u.\n", time, ncontent, hash); + LogPrintf("this bucket %d %u %u.\n", time, smsgBuckets[time].setTokens.size(), smsgBuckets[time].hash); + }; + { + LOCK(cs_smsg); + if (smsgBuckets[time].nLockCount > 0) + { + if (fDebugSmsg) + LogPrintf("Bucket is locked %u, waiting for peer %u to send data.\n", smsgBuckets[time].nLockCount, smsgBuckets[time].nLockPeerId); + nLocked++; + continue; + }; + + // -- if this node has more than the peer node, peer node will pull from this + // if then peer node has more this node will pull fom peer + if (smsgBuckets[time].setTokens.size() < ncontent + || (smsgBuckets[time].setTokens.size() == ncontent + && smsgBuckets[time].hash != hash)) // if same amount in buckets check hash + { + if (fDebugSmsg) + LogPrintf("Requesting contents of bucket %d.\n", time); + + uint32_t sz = vchDataOut.size(); + vchDataOut.resize(sz + 8); + memcpy(&vchDataOut[sz], &time, 8); + + nShowBuckets++; + }; + } // LOCK(cs_smsg); + }; + + // TODO: should include hash? + memcpy(&vchDataOut[0], &nShowBuckets, 4); + if (vchDataOut.size() > 4) + { + pfrom->PushMessage("smsgShow", vchDataOut); + } else + if (nLocked < 1) // Don't report buckets as matched if any are locked + { + // -- peer has no buckets we want, don't send them again until something changes + // peer will still request buckets from this node if needed (< ncontent) + vchDataOut.resize(8); + memcpy(&vchDataOut[0], &now, 8); + pfrom->PushMessage("smsgMatch", vchDataOut); + if (fDebugSmsg) + LogPrintf("Sending smsgMatch, %d.\n", now); + }; + + } else + if (strCommand == "smsgShow") + { + std::vector vchData; + vRecv >> vchData; + + if (vchData.size() < 4) + return false; + + uint32_t nBuckets; + memcpy(&nBuckets, &vchData[0], 4); + + if (vchData.size() < 4 + nBuckets * 8) + return false; + + if (fDebugSmsg) + LogPrintf("smsgShow: peer wants to see content of %u buckets.\n", nBuckets); + + std::map::iterator itb; + std::set::iterator it; + + std::vector vchDataOut; + int64_t time; + uint8_t* pIn = &vchData[4]; + for (uint32_t i = 0; i < nBuckets; ++i, pIn += 8) + { + memcpy(&time, pIn, 8); + + { + LOCK(cs_smsg); + itb = smsgBuckets.find(time); + if (itb == smsgBuckets.end()) + { + if (fDebugSmsg) + LogPrintf("Don't have bucket %d.\n", time); + continue; + }; + + std::set& tokenSet = (*itb).second.setTokens; + + try { vchDataOut.resize(8 + 16 * tokenSet.size()); } catch (std::exception& e) + { + LogPrintf("vchDataOut.resize %u threw: %s.\n", 8 + 16 * tokenSet.size(), e.what()); + continue; + }; + memcpy(&vchDataOut[0], &time, 8); + + uint8_t* p = &vchDataOut[8]; + for (it = tokenSet.begin(); it != tokenSet.end(); ++it) + { + memcpy(p, &it->timestamp, 8); + memcpy(p+8, &it->sample, 8); + + p += 16; + }; + } + pfrom->PushMessage("smsgHave", vchDataOut); + }; + + + } else + if (strCommand == "smsgHave") + { + // -- peer has these messages in bucket + std::vector vchData; + vRecv >> vchData; + + if (vchData.size() < 8) + return false; + + int n = (vchData.size() - 8) / 16; + + int64_t time; + memcpy(&time, &vchData[0], 8); + + // -- Check time valid: + int64_t now = GetTime(); + if (time < now - SMSG_RETENTION) + { + if (fDebugSmsg) + LogPrintf("Not interested in peer bucket %d, has expired.\n", time); + return false; + }; + if (time > now + SMSG_TIME_LEEWAY) + { + if (fDebugSmsg) + LogPrintf("Not interested in peer bucket %d, in the future.\n", time); + pfrom->Misbehaving(1); + return false; + }; + + std::vector vchDataOut; + + { + LOCK(cs_smsg); + if (smsgBuckets[time].nLockCount > 0) + { + if (fDebugSmsg) + LogPrintf("Bucket %d lock count %u, waiting for message data from peer %u.\n", time, smsgBuckets[time].nLockCount, smsgBuckets[time].nLockPeerId); + return false; + }; + + if (fDebugSmsg) + LogPrintf("Sifting through bucket %d.\n", time); + + vchDataOut.resize(8); + memcpy(&vchDataOut[0], &vchData[0], 8); + + std::set& tokenSet = smsgBuckets[time].setTokens; + std::set::iterator it; + SecMsgToken token; + uint8_t* p = &vchData[8]; + + for (int i = 0; i < n; ++i) + { + memcpy(&token.timestamp, p, 8); + memcpy(&token.sample, p+8, 8); + + it = tokenSet.find(token); + if (it == tokenSet.end()) + { + int nd = vchDataOut.size(); + try { + vchDataOut.resize(nd + 16); + } catch (std::exception& e) { + LogPrintf("vchDataOut.resize %d threw: %s.\n", nd + 16, e.what()); + continue; + }; + + memcpy(&vchDataOut[nd], p, 16); + }; + + p += 16; + }; + } + + if (vchDataOut.size() > 8) + { + if (fDebugSmsg) + { + LogPrintf("Asking peer for %u messages.\n", (vchDataOut.size() - 8) / 16); + LogPrintf("Locking bucket %u for peer %d.\n", time, pfrom->id); + }; + { + LOCK(cs_smsg); + smsgBuckets[time].nLockCount = 3; // lock this bucket for at most 3 * SMSG_THREAD_DELAY seconds, unset when peer sends smsgMsg + smsgBuckets[time].nLockPeerId = pfrom->id; + } + pfrom->PushMessage("smsgWant", vchDataOut); + }; + } else + if (strCommand == "smsgWant") + { + std::vector vchData; + vRecv >> vchData; + + if (vchData.size() < 8) + return false; + + std::vector vchOne; + std::vector vchBunch; + + vchBunch.resize(4+8); // nmessages + bucketTime + + int n = (vchData.size() - 8) / 16; + + int64_t time; + uint32_t nBunch = 0; + memcpy(&time, &vchData[0], 8); + + + std::map::iterator itb; + + { + LOCK(cs_smsg); + itb = smsgBuckets.find(time); + if (itb == smsgBuckets.end()) + { + if (fDebugSmsg) + LogPrintf("Don't have bucket %d.\n", time); + return false; + }; + + std::set& tokenSet = itb->second.setTokens; + std::set::iterator it; + SecMsgToken token; + uint8_t* p = &vchData[8]; + for (int i = 0; i < n; ++i) + { + memcpy(&token.timestamp, p, 8); + memcpy(&token.sample, p+8, 8); + + it = tokenSet.find(token); + if (it == tokenSet.end()) + { + if (fDebugSmsg) + LogPrintf("Don't have wanted message %d.\n", token.timestamp); + } else + { + //LogPrintf("Have message at %d.\n", it->offset); // DEBUG + token.offset = it->offset; + //LogPrintf("winb before SecureMsgRetrieve %d.\n", token.timestamp); + + // -- place in vchOne so if SecureMsgRetrieve fails it won't corrupt vchBunch + if (SecureMsgRetrieve(token, vchOne) == 0) + { + nBunch++; + vchBunch.insert(vchBunch.end(), vchOne.begin(), vchOne.end()); // append + } else + { + LogPrintf("SecureMsgRetrieve failed %d.\n", token.timestamp); + }; + + if (nBunch >= 500 + || vchBunch.size() >= 96000) + { + if (fDebugSmsg) + LogPrintf("Break bunch %u, %u.\n", nBunch, vchBunch.size()); + break; // end here, peer will send more want messages if needed. + }; + }; + p += 16; + }; + } // LOCK(cs_smsg); + + if (nBunch > 0) + { + if (fDebugSmsg) + LogPrintf("Sending block of %u messages for bucket %d.\n", nBunch, time); + + memcpy(&vchBunch[0], &nBunch, 4); + memcpy(&vchBunch[4], &time, 8); + pfrom->PushMessage("smsgMsg", vchBunch); + }; + } else + if (strCommand == "smsgMsg") + { + std::vector vchData; + vRecv >> vchData; + + if (fDebugSmsg) + LogPrintf("smsgMsg vchData.size() %u.\n", vchData.size()); + + SecureMsgReceive(pfrom, vchData); + } else + if (strCommand == "smsgMatch") + { + std::vector vchData; + vRecv >> vchData; + + + if (vchData.size() < 8) + { + LogPrintf("smsgMatch, not enough data %u.\n", vchData.size()); + pfrom->Misbehaving(1); + return false; + }; + + int64_t time; + memcpy(&time, &vchData[0], 8); + + int64_t now = GetTime(); + if (time > now + SMSG_TIME_LEEWAY) + { + LogPrintf("Warning: Peer buckets matched in the future: %d.\nEither this node or the peer node has the incorrect time set.\n", time); + if (fDebugSmsg) + LogPrintf("Peer match time set to now.\n"); + time = now; + }; + + pfrom->smsgData.lastMatched = time; + + if (fDebugSmsg) + LogPrintf("Peer buckets matched at %d.\n", time); + + } else + if (strCommand == "smsgPing") + { + // -- smsgPing is the initial message, send reply + pfrom->PushMessage("smsgPong"); + } else + if (strCommand == "smsgPong") + { + if (fDebugSmsg) + LogPrintf("Peer replied, secure messaging enabled.\n"); + + pfrom->smsgData.fEnabled = true; + } else + if (strCommand == "smsgDisabled") + { + // -- peer has disabled secure messaging. + + pfrom->smsgData.fEnabled = false; + + if (fDebugSmsg) + LogPrintf("Peer %d has disabled secure messaging.\n", pfrom->id); + + } else + if (strCommand == "smsgIgnore") + { + // -- peer is reporting that it will ignore this node until time. + // Ignore peer too + std::vector vchData; + vRecv >> vchData; + + if (vchData.size() < 8) + { + LogPrintf("smsgIgnore, not enough data %u.\n", vchData.size()); + pfrom->Misbehaving(1); + return false; + }; + + int64_t time; + memcpy(&time, &vchData[0], 8); + + pfrom->smsgData.ignoreUntil = time; + + if (fDebugSmsg) + LogPrintf("Peer %d is ignoring this node until %d, ignore peer too.\n", pfrom->id, time); + } else + { + // Unknown message + }; + + }; // LOCK(cs_smsg); + + return true; +}; + +bool SecureMsgSendData(CNode* pto, bool fSendTrickle) +{ + /* + Called from ProcessMessage + Runs in ThreadMessageHandler2 + */ + + //LogPrintf("SecureMsgSendData() %s.\n", pto->addrName.c_str()); + + + int64_t now = GetTime(); + + if (pto->smsgData.lastSeen == 0) + { + // -- first contact + if (fDebugSmsg) + LogPrintf("SecureMsgSendData() new node %s, peer id %u.\n", pto->addrName.c_str(), pto->id); + // -- Send smsgPing once, do nothing until receive 1st smsgPong (then set fEnabled) + pto->PushMessage("smsgPing"); + pto->smsgData.lastSeen = GetTime(); + return true; + } else + if (!pto->smsgData.fEnabled + || now - pto->smsgData.lastSeen < SMSG_SEND_DELAY + || now < pto->smsgData.ignoreUntil) + { + return true; + }; + + // -- When nWakeCounter == 0, resend bucket inventory. + if (pto->smsgData.nWakeCounter < 1) + { + pto->smsgData.lastMatched = 0; + pto->smsgData.nWakeCounter = 10 + GetRandInt(300); // set to a random time between [10, 300] * SMSG_SEND_DELAY seconds + + if (fDebugSmsg) + LogPrintf("SecureMsgSendData(): nWakeCounter expired, sending bucket inventory to %s.\n" + "Now %d next wake counter %u\n", pto->addrName.c_str(), now, pto->smsgData.nWakeCounter); + }; + pto->smsgData.nWakeCounter--; + + { + LOCK(cs_smsg); + std::map::iterator it; + + uint32_t nBuckets = smsgBuckets.size(); + if (nBuckets > 0) // no need to send keep alive pkts, coin messages already do that + { + std::vector vchData; + // should reserve? + vchData.reserve(4 + nBuckets*16); // timestamp + size + hash + + uint32_t nBucketsShown = 0; + vchData.resize(4); + + uint8_t* p = &vchData[4]; + for (it = smsgBuckets.begin(); it != smsgBuckets.end(); ++it) + { + SecMsgBucket &bkt = it->second; + + uint32_t nMessages = bkt.setTokens.size(); + + if (bkt.timeChanged < pto->smsgData.lastMatched // peer has this bucket + || nMessages < 1) // this bucket is empty + continue; + + + uint32_t hash = bkt.hash; + + try { vchData.resize(vchData.size() + 16); } catch (std::exception& e) + { + LogPrintf("vchData.resize %u threw: %s.\n", vchData.size() + 16, e.what()); + continue; + }; + memcpy(p, &it->first, 8); + memcpy(p+8, &nMessages, 4); + memcpy(p+12, &hash, 4); + + p += 16; + nBucketsShown++; + //if (fDebug) + // LogPrintf("Sending bucket %d, size %d \n", it->first, it->second.size()); + }; + + if (vchData.size() > 4) + { + memcpy(&vchData[0], &nBucketsShown, 4); + if (fDebugSmsg) + LogPrintf("Sending %d bucket headers.\n", nBucketsShown); + + pto->PushMessage("smsgInv", vchData); + }; + }; + } + + pto->smsgData.lastSeen = GetTime(); + + return true; +}; + + +static int SecureMsgInsertAddress(CKeyID& hashKey, CPubKey& pubKey, SecMsgDB& addrpkdb) +{ + /* insert key hash and public key to addressdb + + should have LOCK(cs_smsg) where db is opened + + returns + 0 success + 1 error + 4 address is already in db + */ + + + if (addrpkdb.ExistsPK(hashKey)) + { + //LogPrintf("DB already contains public key for address.\n"); + CPubKey cpkCheck; + if (!addrpkdb.ReadPK(hashKey, cpkCheck)) + { + LogPrintf("addrpkdb.Read failed.\n"); + } else + { + if (cpkCheck != pubKey) + LogPrintf("DB already contains existing public key that does not match .\n"); + }; + return 4; + }; + + if (!addrpkdb.WritePK(hashKey, pubKey)) + { + LogPrintf("Write pair failed.\n"); + return 1; + }; + + return 0; +}; + +int SecureMsgInsertAddress(CKeyID& hashKey, CPubKey& pubKey) +{ + int rv; + { + LOCK(cs_smsgDB); + SecMsgDB addrpkdb; + + if (!addrpkdb.Open("cr+")) + return 1; + + rv = SecureMsgInsertAddress(hashKey, pubKey, addrpkdb); + } + return rv; +}; + + +static bool ScanBlock(CBlock& block, CTxDB& txdb, SecMsgDB& addrpkdb, + uint32_t& nTransactions, uint32_t& nElements, uint32_t& nPubkeys, uint32_t& nDuplicates) +{ + AssertLockHeld(cs_smsgDB); + + valtype vch; + opcodetype opcode; + + // -- only scan inputs of standard txns and coinstakes + + BOOST_FOREACH(CTransaction& tx, block.vtx) + { + std::string sReason; + // - harvest public keys from coinstake txns + if (tx.IsCoinStake()) + { + const CTxOut& txout = tx.vout[1]; + CScript::const_iterator pc = txout.scriptPubKey.begin(); + while (pc < txout.scriptPubKey.end()) + { + if (!txout.scriptPubKey.GetOp(pc, opcode, vch)) + break; + + if (vch.size() == 33) // pubkey + { + CPubKey pubKey(vch); + + if (!pubKey.IsValid() + || !pubKey.IsCompressed()) + { + LogPrintf("Public key is invalid %s.\n", HexStr(pubKey).c_str()); + continue; + }; + + CKeyID addrKey = pubKey.GetID(); + switch (SecureMsgInsertAddress(addrKey, pubKey, addrpkdb)) + { + case 0: nPubkeys++; break; // added key + case 4: nDuplicates++; break; // duplicate key + } + break; + }; + }; + nElements++; + } else + if (IsStandardTx(tx, sReason)) + { + for (uint32_t i = 0; i < tx.vin.size(); i++) + { + CScript *script = &tx.vin[i].scriptSig; + CScript::const_iterator pc = script->begin(); + CScript::const_iterator pend = script->end(); + + uint256 prevoutHash; + CKey key; + + while (pc < pend) + { + if (!script->GetOp(pc, opcode, vch)) + break; + // -- opcode is the length of the following data, compressed public key is always 33 + if (opcode == 33) + { + CPubKey pubKey(vch); + + if (!pubKey.IsValid() + || !pubKey.IsCompressed()) + { + LogPrintf("Public key is invalid %s.\n", HexStr(pubKey).c_str()); + continue; + }; + + CKeyID addrKey = pubKey.GetID(); + switch (SecureMsgInsertAddress(addrKey, pubKey, addrpkdb)) + { + case 0: nPubkeys++; break; // added key + case 4: nDuplicates++; break; // duplicate key + } + break; + }; + + //LogPrintf("opcode %d, %s, value %s.\n", opcode, GetOpName(opcode), ValueString(vch).c_str()); + }; + nElements++; + }; + }; + nTransactions++; + + if (nTransactions % 10000 == 0) // for ScanChainForPublicKeys + { + LogPrintf("Scanning transaction no. %u.\n", nTransactions); + }; + }; + return true; +}; + + +bool SecureMsgScanBlock(CBlock& block) +{ + /* + scan block for public key addresses + called from ProcessMessage() in main where strCommand == "block" + */ + + if (fDebugSmsg) + LogPrintf("SecureMsgScanBlock().\n"); + + uint32_t nTransactions = 0; + uint32_t nElements = 0; + uint32_t nPubkeys = 0; + uint32_t nDuplicates = 0; + + { + LOCK(cs_smsgDB); + CTxDB txdb("r"); + + SecMsgDB addrpkdb; + if (!addrpkdb.Open("cw") + || !addrpkdb.TxnBegin()) + return false; + + ScanBlock(block, txdb, addrpkdb, + nTransactions, nElements, nPubkeys, nDuplicates); + + addrpkdb.TxnCommit(); + } + + if (fDebugSmsg) + LogPrintf("Found %u transactions, %u elements, %u new public keys, %u duplicates.\n", nTransactions, nElements, nPubkeys, nDuplicates); + + return true; +}; + +bool ScanChainForPublicKeys(CBlockIndex* pindexStart) +{ + LogPrintf("Scanning block chain for public keys.\n"); + int64_t nStart = GetTimeMillis(); + + if (fDebugSmsg) + LogPrintf("From height %u.\n", pindexStart->nHeight); + + // -- public keys are in txin.scriptSig + // matching addresses are in scriptPubKey of txin's referenced output + + uint32_t nBlocks = 0; + uint32_t nTransactions = 0; + uint32_t nInputs = 0; + uint32_t nPubkeys = 0; + uint32_t nDuplicates = 0; + + { + LOCK(cs_smsgDB); + + CTxDB txdb("r"); + + SecMsgDB addrpkdb; + if (!addrpkdb.Open("cw") + || !addrpkdb.TxnBegin()) + return false; + + CBlockIndex* pindex = pindexStart; + while (pindex) + { + nBlocks++; + CBlock block; + block.ReadFromDisk(pindex, true); + + ScanBlock(block, txdb, addrpkdb, + nTransactions, nInputs, nPubkeys, nDuplicates); + + pindex = pindex->pnext; + }; + + addrpkdb.TxnCommit(); + }; + + LogPrintf("Scanned %u blocks, %u transactions, %u inputs\n", nBlocks, nTransactions, nInputs); + LogPrintf("Found %u public keys, %u duplicates.\n", nPubkeys, nDuplicates); + LogPrintf("Took %d ms\n", GetTimeMillis() - nStart); + + return true; +}; + +bool SecureMsgScanBlockChain() +{ + TRY_LOCK(cs_main, lockMain); + if (lockMain) + { + CBlockIndex *pindexScan = pindexGenesisBlock; + if (pindexScan == NULL) + { + LogPrintf("Error: pindexGenesisBlock not set.\n"); + return false; + }; + + + try { // -- in try to catch errors opening db, + if (!ScanChainForPublicKeys(pindexScan)) + return false; + } catch (std::exception& e) + { + LogPrintf("ScanChainForPublicKeys() threw: %s.\n", e.what()); + return false; + }; + } else + { + LogPrintf("ScanChainForPublicKeys() Could not lock main.\n"); + return false; + }; + + return true; +}; + +bool SecureMsgScanBuckets() +{ + if (fDebugSmsg) + LogPrintf("SecureMsgScanBuckets()\n"); + + if (!fSecMsgEnabled + || pwalletMain->IsLocked()) + return false; + + int64_t mStart = GetTimeMillis(); + int64_t now = GetTime(); + uint32_t nFiles = 0; + uint32_t nMessages = 0; + uint32_t nFoundMessages = 0; + + fs::path pathSmsgDir = GetDataDir() / "smsgStore"; + fs::directory_iterator itend; + + if (!fs::exists(pathSmsgDir) + || !fs::is_directory(pathSmsgDir)) + { + LogPrintf("Message store directory does not exist.\n"); + return 0; // not an error + }; + + SecureMessage smsg; + std::vector vchData; + + for (fs::directory_iterator itd(pathSmsgDir) ; itd != itend ; ++itd) + { + if (!fs::is_regular_file(itd->status())) + continue; + + std::string fileType = (*itd).path().extension().string(); + + if (fileType.compare(".dat") != 0) + continue; + + std::string fileName = (*itd).path().filename().string(); + + + if (fDebugSmsg) + LogPrintf("Processing file: %s.\n", fileName.c_str()); + + nFiles++; + + // TODO files must be split if > 2GB + // time_noFile.dat + size_t sep = fileName.find_first_of("_"); + if (sep == std::string::npos) + continue; + + std::string stime = fileName.substr(0, sep); + + int64_t fileTime = boost::lexical_cast(stime); + + if (fileTime < now - SMSG_RETENTION) + { + LogPrintf("Dropping file %s, expired.\n", fileName.c_str()); + try { + fs::remove((*itd).path()); + } catch (const fs::filesystem_error& ex) + { + LogPrintf("Error removing bucket file %s, %s.\n", fileName.c_str(), ex.what()); + }; + continue; + }; + + if (boost::algorithm::ends_with(fileName, "_wl.dat")) + { + if (fDebugSmsg) + LogPrintf("Skipping wallet locked file: %s.\n", fileName.c_str()); + continue; + }; + + { + LOCK(cs_smsg); + FILE *fp; + errno = 0; + if (!(fp = fopen((*itd).path().string().c_str(), "rb"))) + { + LogPrintf("Error opening file: %s\n", strerror(errno)); + continue; + }; + + for (;;) + { + errno = 0; + if (fread(&smsg.hash[0], sizeof(uint8_t), SMSG_HDR_LEN, fp) != (size_t)SMSG_HDR_LEN) + { + if (errno != 0) + { + LogPrintf("fread header failed: %s\n", strerror(errno)); + } else + { + //LogPrintf("End of file.\n"); + }; + break; + }; + + try { vchData.resize(smsg.nPayload); } catch (std::exception& e) + { + LogPrintf("SecureMsgWalletUnlocked(): Could not resize vchData, %u, %s\n", smsg.nPayload, e.what()); + fclose(fp); + return 1; + }; + + if (fread(&vchData[0], sizeof(uint8_t), smsg.nPayload, fp) != smsg.nPayload) + { + LogPrintf("fread data failed: %s\n", strerror(errno)); + break; + }; + + // -- don't report to gui, + int rv = SecureMsgScanMessage(&smsg.hash[0], &vchData[0], smsg.nPayload, false); + + if (rv == 0) + { + nFoundMessages++; + } else + if (rv != 0) + { + // SecureMsgScanMessage failed + }; + + nMessages ++; + }; + + fclose(fp); + + // -- remove wl file when scanned + try { + fs::remove((*itd).path()); + } catch (const boost::filesystem::filesystem_error& ex) + { + LogPrintf("Error removing wl file %s - %s\n", fileName.c_str(), ex.what()); + return 1; + }; + }; + }; + + LogPrintf("Processed %u files, scanned %u messages, received %u messages.\n", nFiles, nMessages, nFoundMessages); + LogPrintf("Took %d ms\n", GetTimeMillis() - mStart); + + return true; +} + + +int SecureMsgWalletUnlocked() +{ + /* + When the wallet is unlocked, scan messages received while wallet was locked. + */ + if (!fSecMsgEnabled) + return 0; + + LogPrintf("SecureMsgWalletUnlocked()\n"); + + if (pwalletMain->IsLocked()) + { + LogPrintf("Error: Wallet is locked.\n"); + return 1; + }; + + int64_t now = GetTime(); + uint32_t nFiles = 0; + uint32_t nMessages = 0; + uint32_t nFoundMessages = 0; + + fs::path pathSmsgDir = GetDataDir() / "smsgStore"; + fs::directory_iterator itend; + + if (!fs::exists(pathSmsgDir) + || !fs::is_directory(pathSmsgDir)) + { + LogPrintf("Message store directory does not exist.\n"); + return 0; // not an error + }; + + SecureMessage smsg; + std::vector vchData; + + for (fs::directory_iterator itd(pathSmsgDir) ; itd != itend ; ++itd) + { + if (!fs::is_regular_file(itd->status())) + continue; + + std::string fileName = (*itd).path().filename().string(); + + if (!boost::algorithm::ends_with(fileName, "_wl.dat")) + continue; + + if (fDebugSmsg) + LogPrintf("Processing file: %s.\n", fileName.c_str()); + + nFiles++; + + // TODO files must be split if > 2GB + // time_noFile_wl.dat + size_t sep = fileName.find_first_of("_"); + if (sep == std::string::npos) + continue; + + std::string stime = fileName.substr(0, sep); + + int64_t fileTime = boost::lexical_cast(stime); + + if (fileTime < now - SMSG_RETENTION) + { + LogPrintf("Dropping wallet locked file %s, expired.\n", fileName.c_str()); + try { + fs::remove((*itd).path()); + } catch (const boost::filesystem::filesystem_error& ex) + { + LogPrintf("Error removing wl file %s - %s\n", fileName.c_str(), ex.what()); + return 1; + }; + continue; + }; + + { + LOCK(cs_smsg); + FILE *fp; + errno = 0; + if (!(fp = fopen((*itd).path().string().c_str(), "rb"))) + { + LogPrintf("Error opening file: %s\n", strerror(errno)); + continue; + }; + + for (;;) + { + errno = 0; + if (fread(&smsg.hash[0], sizeof(uint8_t), SMSG_HDR_LEN, fp) != (size_t)SMSG_HDR_LEN) + { + if (errno != 0) + { + LogPrintf("fread header failed: %s\n", strerror(errno)); + } else + { + //LogPrintf("End of file.\n"); + }; + break; + }; + + try { vchData.resize(smsg.nPayload); } catch (std::exception& e) + { + LogPrintf("SecureMsgWalletUnlocked(): Could not resize vchData, %u, %s\n", smsg.nPayload, e.what()); + fclose(fp); + return 1; + }; + + if (fread(&vchData[0], sizeof(uint8_t), smsg.nPayload, fp) != smsg.nPayload) + { + LogPrintf("fread data failed: %s\n", strerror(errno)); + break; + }; + + // -- don't report to gui, + int rv = SecureMsgScanMessage(&smsg.hash[0], &vchData[0], smsg.nPayload, false); + + if (rv == 0) + { + nFoundMessages++; + } else + if (rv != 0) + { + // SecureMsgScanMessage failed + }; + + nMessages ++; + }; + + fclose(fp); + + // -- remove wl file when scanned + try { + fs::remove((*itd).path()); + } catch (const boost::filesystem::filesystem_error& ex) + { + LogPrintf("Error removing wl file %s - %s\n", fileName.c_str(), ex.what()); + return 1; + }; + }; + }; + + LogPrintf("Processed %u files, scanned %u messages, received %u messages.\n", nFiles, nMessages, nFoundMessages); + + // -- notify gui + NotifySecMsgWalletUnlocked(); + return 0; +}; + +int SecureMsgWalletKeyChanged(std::string sAddress, std::string sLabel, ChangeType mode) +{ + if (!fSecMsgEnabled) + return 0; + + LogPrintf("SecureMsgWalletKeyChanged()\n"); + + // TODO: default recv and recvAnon + + { + LOCK(cs_smsg); + + switch(mode) + { + case CT_NEW: + smsgAddresses.push_back(SecMsgAddress(sAddress, smsgOptions.fNewAddressRecv, smsgOptions.fNewAddressAnon)); + break; + case CT_DELETED: + for (std::vector::iterator it = smsgAddresses.begin(); it != smsgAddresses.end(); ++it) + { + if (sAddress != it->sAddress) + continue; + smsgAddresses.erase(it); + break; + }; + break; + default: + break; + } + + }; // LOCK(cs_smsg); + + + return 0; +}; + +int SecureMsgScanMessage(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload, bool reportToGui) +{ + /* + Check if message belongs to this node. + If so add to inbox db. + + if !reportToGui don't fire NotifySecMsgInboxChanged + - loads messages received when wallet locked in bulk. + + returns + 0 success, + 1 error + 2 no match + 3 wallet is locked - message stored for scanning later. + */ + + if (fDebugSmsg) + LogPrintf("SecureMsgScanMessage()\n"); + + if (pwalletMain->IsLocked()) + { + if (fDebugSmsg) + LogPrintf("ScanMessage: Wallet is locked, storing message to scan later.\n"); + + int rv; + if ((rv = SecureMsgStoreUnscanned(pHeader, pPayload, nPayload)) != 0) + return 1; + + return 3; + }; + + std::string addressTo; + MessageData msg; // placeholder + bool fOwnMessage = false; + + for (std::vector::iterator it = smsgAddresses.begin(); it != smsgAddresses.end(); ++it) + { + if (!it->fReceiveEnabled) + continue; + + CBitcoinAddress coinAddress(it->sAddress); + addressTo = coinAddress.ToString(); + + if (!it->fReceiveAnon) + { + // -- have to do full decrypt to see address from + if (SecureMsgDecrypt(false, addressTo, pHeader, pPayload, nPayload, msg) == 0) + { + if (fDebugSmsg) + LogPrintf("Decrypted message with %s.\n", addressTo.c_str()); + + if (msg.sFromAddress.compare("anon") != 0) + fOwnMessage = true; + break; + }; + } else + { + + if (SecureMsgDecrypt(true, addressTo, pHeader, pPayload, nPayload, msg) == 0) + { + if (fDebugSmsg) + LogPrintf("Decrypted message with %s.\n", addressTo.c_str()); + + fOwnMessage = true; + break; + }; + } + }; + + if (fOwnMessage) + { + // -- save to inbox + SecureMessage* psmsg = (SecureMessage*) pHeader; + std::string sPrefix("im"); + uint8_t chKey[18]; + memcpy(&chKey[0], sPrefix.data(), 2); + memcpy(&chKey[2], &psmsg->timestamp, 8); + memcpy(&chKey[10], pPayload, 8); + + SecMsgStored smsgInbox; + smsgInbox.timeReceived = GetTime(); + smsgInbox.status = (SMSG_MASK_UNREAD) & 0xFF; + smsgInbox.sAddrTo = addressTo; + + // -- data may not be contiguous + try { + smsgInbox.vchMessage.resize(SMSG_HDR_LEN + nPayload); + } catch (std::exception& e) { + LogPrintf("SecureMsgScanMessage(): Could not resize vchData, %u, %s\n", SMSG_HDR_LEN + nPayload, e.what()); + return 1; + }; + memcpy(&smsgInbox.vchMessage[0], pHeader, SMSG_HDR_LEN); + memcpy(&smsgInbox.vchMessage[SMSG_HDR_LEN], pPayload, nPayload); + + { + LOCK(cs_smsgDB); + SecMsgDB dbInbox; + + if (dbInbox.Open("cw")) + { + if (dbInbox.ExistsSmesg(chKey)) + { + if (fDebugSmsg) + LogPrintf("Message already exists in inbox db.\n"); + } else + { + dbInbox.WriteSmesg(chKey, smsgInbox); + + if (reportToGui) + NotifySecMsgInboxChanged(smsgInbox); + LogPrintf("SecureMsg saved to inbox, received with %s.\n", addressTo.c_str()); + }; + }; + } + }; + + return 0; +}; + +int SecureMsgGetLocalKey(CKeyID& ckid, CPubKey& cpkOut) +{ + if (fDebugSmsg) + LogPrintf("SecureMsgGetLocalKey()\n"); + + CKey key; + if (!pwalletMain->GetKey(ckid, key)) + return 4; + + cpkOut = key.GetPubKey(); //true); + + if (!cpkOut.IsValid() + || !cpkOut.IsCompressed()) + { + LogPrintf("Public key is invalid %s.\n", HexStr(cpkOut).c_str()); + return 1; + }; + + return 0; +}; + +int SecureMsgGetLocalPublicKey(std::string& strAddress, std::string& strPublicKey) +{ + /* returns + 0 success, + 1 error + 2 invalid address + 3 address does not refer to a key + 4 address not in wallet + */ + + CBitcoinAddress address; + if (!address.SetString(strAddress)) + return 2; // Invalid coin address + + CKeyID keyID; + if (!address.GetKeyID(keyID)) + return 3; + + int rv; + CPubKey pubKey; + if ((rv = SecureMsgGetLocalKey(keyID, pubKey)) != 0) + return rv; + + strPublicKey = EncodeBase58(pubKey.begin(), pubKey.end()); + + return 0; +}; + +int SecureMsgGetStoredKey(CKeyID& ckid, CPubKey& cpkOut) +{ + /* returns + 0 success, + 1 error + 2 public key not in database + */ + if (fDebugSmsg) + LogPrintf("SecureMsgGetStoredKey().\n"); + + { + LOCK(cs_smsgDB); + SecMsgDB addrpkdb; + + if (!addrpkdb.Open("r")) + return 1; + + if (!addrpkdb.ReadPK(ckid, cpkOut)) + { + //LogPrintf("addrpkdb.Read failed: %s.\n", coinAddress.ToString().c_str()); + return 2; + }; + } + + return 0; +}; + +int SecureMsgAddAddress(std::string& address, std::string& publicKey) +{ + static const char *fn = "SecureMsgAddAddress()"; + /* + Add address and matching public key to the database + address and publicKey are in base58 + + returns + 0 success + 1 error + 2 publicKey is invalid + 3 publicKey != address + 4 address is already in db + 5 address is invalid + */ + + CBitcoinAddress coinAddress(address); + + if (!coinAddress.IsValid()) + { + LogPrintf("%s - Address is not valid: %s.\n", fn, address.c_str()); + return 5; + }; + + CKeyID hashKey; + + if (!coinAddress.GetKeyID(hashKey)) + { + LogPrintf("%s - coinAddress.GetKeyID failed: %s.\n", fn, coinAddress.ToString().c_str()); + return 5; + }; + + std::vector vchTest; + DecodeBase58(publicKey, vchTest); + CPubKey pubKey(vchTest); + + // -- check that public key matches address hash + CPubKey pubKeyT(pubKey); + if (!pubKeyT.IsValid()) + { + LogPrintf("%s - Invalid PubKey.\n", fn); + return 2; + }; + + CKeyID keyIDT = pubKeyT.GetID(); + CBitcoinAddress addressT(keyIDT); + + if (addressT.ToString().compare(address) != 0) + { + LogPrintf("%s - Public key does not hash to address, addressT %s.\n", fn, addressT.ToString().c_str()); + return 3; + }; + + return SecureMsgInsertAddress(hashKey, pubKey); +}; + +int SecureMsgRetrieve(SecMsgToken &token, std::vector& vchData) +{ + if (fDebugSmsg) + LogPrintf("SecureMsgRetrieve() %d.\n", token.timestamp); + + // -- has cs_smsg lock from SecureMsgReceiveData + + fs::path pathSmsgDir = GetDataDir() / "smsgStore"; + + //LogPrintf("token.offset %d.\n", token.offset); // DEBUG + int64_t bucket = token.timestamp - (token.timestamp % SMSG_BUCKET_LEN); + std::string fileName = boost::lexical_cast(bucket) + "_01.dat"; + fs::path fullpath = pathSmsgDir / fileName; + + //LogPrintf("bucket %d.\n", bucket); + //LogPrintf("bucket d %d.\n", bucket); + //LogPrintf("fileName %s.\n", fileName.c_str()); + + FILE *fp; + errno = 0; + if (!(fp = fopen(fullpath.string().c_str(), "rb"))) + { + LogPrintf("Error opening file: %s\nPath %s\n", strerror(errno), fullpath.string().c_str()); + return 1; + }; + + errno = 0; + if (fseek(fp, token.offset, SEEK_SET) != 0) + { + LogPrintf("fseek, strerror: %s.\n", strerror(errno)); + fclose(fp); + return 1; + }; + + SecureMessage smsg; + errno = 0; + if (fread(&smsg.hash[0], sizeof(uint8_t), SMSG_HDR_LEN, fp) != (size_t)SMSG_HDR_LEN) + { + LogPrintf("fread header failed: %s\n", strerror(errno)); + fclose(fp); + return 1; + }; + + try { + vchData.resize(SMSG_HDR_LEN + smsg.nPayload); + } catch (std::exception& e) { + LogPrintf("SecureMsgRetrieve(): Could not resize vchData, %u, %s\n", SMSG_HDR_LEN + smsg.nPayload, e.what()); + return 1; + }; + + memcpy(&vchData[0], &smsg.hash[0], SMSG_HDR_LEN); + errno = 0; + if (fread(&vchData[SMSG_HDR_LEN], sizeof(uint8_t), smsg.nPayload, fp) != smsg.nPayload) + { + LogPrintf("fread data failed: %s. Wanted %u bytes.\n", strerror(errno), smsg.nPayload); + fclose(fp); + return 1; + }; + + + fclose(fp); + + return 0; +}; + +int SecureMsgReceive(CNode* pfrom, std::vector& vchData) +{ + if (fDebugSmsg) + LogPrintf("SecureMsgReceive().\n"); + + if (vchData.size() < 12) // nBunch4 + timestamp8 + { + LogPrintf("Error: not enough data.\n"); + return 1; + }; + + uint32_t nBunch; + int64_t bktTime; + + memcpy(&nBunch, &vchData[0], 4); + memcpy(&bktTime, &vchData[4], 8); + + + // -- check bktTime () + // bucket may not exist yet - will be created when messages are added + int64_t now = GetTime(); + if (bktTime > now + SMSG_TIME_LEEWAY) + { + if (fDebugSmsg) + LogPrintf("bktTime > now.\n"); + // misbehave? + return 1; + } else + if (bktTime < now - SMSG_RETENTION) + { + if (fDebugSmsg) + LogPrintf("bktTime < now - SMSG_RETENTION.\n"); + // misbehave? + return 1; + }; + + std::map::iterator itb; + + if (nBunch == 0 || nBunch > 500) + { + LogPrintf("Error: Invalid no. messages received in bunch %u, for bucket %d.\n", nBunch, bktTime); + pfrom->Misbehaving(1); + + { + LOCK(cs_smsg); + // -- release lock on bucket if it exists + itb = smsgBuckets.find(bktTime); + if (itb != smsgBuckets.end()) + itb->second.nLockCount = 0; + } // LOCK(cs_smsg); + return 1; + }; + + uint32_t n = 12; + + for (uint32_t i = 0; i < nBunch; ++i) + { + if (vchData.size() - n < SMSG_HDR_LEN) + { + LogPrintf("Error: not enough data sent, n = %u.\n", n); + break; + }; + + SecureMessage* psmsg = (SecureMessage*) &vchData[n]; + + int rv; + if ((rv = SecureMsgValidate(&vchData[n], &vchData[n + SMSG_HDR_LEN], psmsg->nPayload)) != 0) + { + // message dropped + if (rv == 2) // invalid proof of work + { + pfrom->Misbehaving(10); + } else + { + pfrom->Misbehaving(1); + }; + continue; + }; + + { + LOCK(cs_smsg); + // -- store message, but don't hash bucket + if (SecureMsgStore(&vchData[n], &vchData[n + SMSG_HDR_LEN], psmsg->nPayload, false) != 0) + { + // message dropped + break; // continue? + }; + + if (SecureMsgScanMessage(&vchData[n], &vchData[n + SMSG_HDR_LEN], psmsg->nPayload, true) != 0) + { + // message recipient is not this node (or failed) + }; + } // LOCK(cs_smsg); + + n += SMSG_HDR_LEN + psmsg->nPayload; + }; + + { + LOCK(cs_smsg); + // -- if messages have been added, bucket must exist now + itb = smsgBuckets.find(bktTime); + if (itb == smsgBuckets.end()) + { + if (fDebugSmsg) + LogPrintf("Don't have bucket %d.\n", bktTime); + return 1; + }; + + itb->second.nLockCount = 0; // this node has received data from peer, release lock + itb->second.nLockPeerId = 0; + itb->second.hashBucket(); + } // LOCK(cs_smsg); + return 0; +}; + +int SecureMsgStoreUnscanned(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload) +{ + /* + When the wallet is locked a copy of each received message is stored to be scanned later if wallet is unlocked + */ + + if (fDebugSmsg) + LogPrintf("SecureMsgStoreUnscanned()\n"); + + if (!pHeader + || !pPayload) + { + LogPrintf("Error: null pointer to header or payload.\n"); + return 1; + }; + + SecureMessage* psmsg = (SecureMessage*) pHeader; + + fs::path pathSmsgDir; + try { + pathSmsgDir = GetDataDir() / "smsgStore"; + fs::create_directory(pathSmsgDir); + } catch (const boost::filesystem::filesystem_error& ex) + { + LogPrintf("Error: Failed to create directory %s - %s\n", pathSmsgDir.string().c_str(), ex.what()); + return 1; + }; + + int64_t now = GetTime(); + if (psmsg->timestamp > now + SMSG_TIME_LEEWAY) + { + LogPrintf("Message > now.\n"); + return 1; + } else + if (psmsg->timestamp < now - SMSG_RETENTION) + { + LogPrintf("Message < SMSG_RETENTION.\n"); + return 1; + }; + + int64_t bucket = psmsg->timestamp - (psmsg->timestamp % SMSG_BUCKET_LEN); + + std::string fileName = boost::lexical_cast(bucket) + "_01_wl.dat"; + fs::path fullpath = pathSmsgDir / fileName; + + FILE *fp; + errno = 0; + if (!(fp = fopen(fullpath.string().c_str(), "ab"))) + { + LogPrintf("Error opening file: %s\n", strerror(errno)); + return 1; + }; + + if (fwrite(pHeader, sizeof(uint8_t), SMSG_HDR_LEN, fp) != (size_t)SMSG_HDR_LEN + || fwrite(pPayload, sizeof(uint8_t), nPayload, fp) != nPayload) + { + LogPrintf("fwrite failed: %s\n", strerror(errno)); + fclose(fp); + return 1; + }; + + fclose(fp); + + return 0; +}; + + +int SecureMsgStore(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload, bool fUpdateBucket) +{ + if (fDebugSmsg) + LogPrintf("SecureMsgStore()\n"); + + AssertLockHeld(cs_smsg); + + if (!pHeader + || !pPayload) + { + LogPrintf("Error: null pointer to header or payload.\n"); + return 1; + }; + + SecureMessage* psmsg = (SecureMessage*) pHeader; + + + long int ofs; + fs::path pathSmsgDir; + try { + pathSmsgDir = GetDataDir() / "smsgStore"; + fs::create_directory(pathSmsgDir); + } catch (const boost::filesystem::filesystem_error& ex) + { + LogPrintf("Error: Failed to create directory %s - %s\n", pathSmsgDir.string().c_str(), ex.what()); + return 1; + }; + + int64_t now = GetTime(); + if (psmsg->timestamp > now + SMSG_TIME_LEEWAY) + { + LogPrintf("Message > now.\n"); + return 1; + } else + if (psmsg->timestamp < now - SMSG_RETENTION) + { + LogPrintf("Message < SMSG_RETENTION.\n"); + return 1; + }; + + int64_t bucket = psmsg->timestamp - (psmsg->timestamp % SMSG_BUCKET_LEN); + + SecMsgToken token(psmsg->timestamp, pPayload, nPayload, 0); + + std::set& tokenSet = smsgBuckets[bucket].setTokens; + std::set::iterator it; + it = tokenSet.find(token); + if (it != tokenSet.end()) + { + LogPrintf("Already have message.\n"); + if (fDebugSmsg) + { + LogPrintf("nPayload: %u\n", nPayload); + LogPrintf("bucket: %d\n", bucket); + + LogPrintf("message ts: %d", token.timestamp); + std::vector vchShow; + vchShow.resize(8); + memcpy(&vchShow[0], token.sample, 8); + LogPrintf(" sample %s\n", ValueString(vchShow).c_str()); + /* + LogPrintf("\nmessages in bucket:\n"); + for (it = tokenSet.begin(); it != tokenSet.end(); ++it) + { + LogPrintf("message ts: %d", (*it).timestamp); + vchShow.resize(8); + memcpy(&vchShow[0], (*it).sample, 8); + LogPrintf(" sample %s\n", ValueString(vchShow).c_str()); + }; + */ + }; + return 1; + }; + + std::string fileName = boost::lexical_cast(bucket) + "_01.dat"; + fs::path fullpath = pathSmsgDir / fileName; + + FILE *fp; + errno = 0; + if (!(fp = fopen(fullpath.string().c_str(), "ab"))) + { + LogPrintf("Error opening file: %s\n", strerror(errno)); + return 1; + }; + + // -- on windows ftell will always return 0 after fopen(ab), call fseek to set. + errno = 0; + if (fseek(fp, 0, SEEK_END) != 0) + { + LogPrintf("Error fseek failed: %s\n", strerror(errno)); + return 1; + }; + + + ofs = ftell(fp); + + if (fwrite(pHeader, sizeof(uint8_t), SMSG_HDR_LEN, fp) != (size_t)SMSG_HDR_LEN + || fwrite(pPayload, sizeof(uint8_t), nPayload, fp) != nPayload) + { + LogPrintf("fwrite failed: %s\n", strerror(errno)); + fclose(fp); + return 1; + }; + + fclose(fp); + + token.offset = ofs; + + //LogPrintf("token.offset: %d\n", token.offset); // DEBUG + tokenSet.insert(token); + + if (fUpdateBucket) + smsgBuckets[bucket].hashBucket(); + + if (fDebugSmsg) + LogPrintf("SecureMsg added to bucket %d.\n", bucket); + return 0; +}; + +int SecureMsgStore(SecureMessage& smsg, bool fUpdateBucket) +{ + return SecureMsgStore(&smsg.hash[0], smsg.pPayload, smsg.nPayload, fUpdateBucket); +}; + +int SecureMsgValidate(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload) +{ + /* + returns + 0 success + 1 error + 2 invalid hash + 3 checksum mismatch + 4 invalid version + 5 payload is too large + */ + SecureMessage* psmsg = (SecureMessage*) pHeader; + + if (psmsg->version[0] != 1) + return 4; + + if (nPayload > SMSG_MAX_MSG_WORST) + return 5; + + uint8_t civ[32]; + uint8_t sha256Hash[32]; + int rv = 2; // invalid + + uint32_t nonse; + memcpy(&nonse, &psmsg->nonse[0], 4); + + if (fDebugSmsg) + LogPrintf("SecureMsgValidate() nonse %u.\n", nonse); + + for (int i = 0; i < 32; i+=4) + memcpy(civ+i, &nonse, 4); + + HMAC_CTX ctx; + HMAC_CTX_init(&ctx); + + uint32_t nBytes; + if (!HMAC_Init_ex(&ctx, &civ[0], 32, EVP_sha256(), NULL) + || !HMAC_Update(&ctx, (uint8_t*) pHeader+4, SMSG_HDR_LEN-4) + || !HMAC_Update(&ctx, (uint8_t*) pPayload, nPayload) + || !HMAC_Update(&ctx, pPayload, nPayload) + || !HMAC_Final(&ctx, sha256Hash, &nBytes) + || nBytes != 32) + { + if (fDebugSmsg) + LogPrintf("HMAC error.\n"); + rv = 1; // error + } else + { + if (sha256Hash[31] == 0 + && sha256Hash[30] == 0 + && (~(sha256Hash[29]) & ((1<<0) || (1<<1) || (1<<2)) )) + { + if (fDebugSmsg) + LogPrintf("Hash Valid.\n"); + rv = 0; // smsg is valid + }; + + if (memcmp(psmsg->hash, sha256Hash, 4) != 0) + { + if (fDebugSmsg) + LogPrintf("Checksum mismatch.\n"); + rv = 3; // checksum mismatch + } + } + HMAC_CTX_cleanup(&ctx); + + return rv; +}; + +int SecureMsgSetHash(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload) +{ + /* proof of work and checksum + + May run in a thread, if shutdown detected, return. + + returns: + 0 success + 1 error + 2 stopped due to node shutdown + + */ + + SecureMessage* psmsg = (SecureMessage*) pHeader; + + int64_t nStart = GetTimeMillis(); + uint8_t civ[32]; + uint8_t sha256Hash[32]; + + bool found = false; + HMAC_CTX ctx; + HMAC_CTX_init(&ctx); + + uint32_t nonse = 0; + + //CBigNum bnTarget(2); + //bnTarget = bnTarget.pow(256 - 40); + + // -- break for HMAC_CTX_cleanup + for (;;) + { + if (!fSecMsgEnabled) + break; + + //psmsg->timestamp = GetTime(); + //memcpy(&psmsg->timestamp, &now, 8); + memcpy(&psmsg->nonse[0], &nonse, 4); + + for (int i = 0; i < 32; i+=4) + memcpy(civ+i, &nonse, 4); + + uint32_t nBytes; + if (!HMAC_Init_ex(&ctx, &civ[0], 32, EVP_sha256(), NULL) + || !HMAC_Update(&ctx, (uint8_t*) pHeader+4, SMSG_HDR_LEN-4) + || !HMAC_Update(&ctx, (uint8_t*) pPayload, nPayload) + || !HMAC_Update(&ctx, pPayload, nPayload) + || !HMAC_Final(&ctx, sha256Hash, &nBytes) + //|| !HMAC_Final(&ctx, &vchHash[0], &nBytes) + || nBytes != 32) + break; + + /* + if (CBigNum(vchHash) <= bnTarget) + { + found = true; + if (fDebugSmsg) + LogPrintf("Match %u\n", nonse); + break; + }; + */ + + if (sha256Hash[31] == 0 + && sha256Hash[30] == 0 + && (~(sha256Hash[29]) & ((1<<0) || (1<<1) || (1<<2)) )) + // && sha256Hash[29] == 0) + { + found = true; + //if (fDebugSmsg) + // LogPrintf("Match %u\n", nonse); + break; + } + + //if (nonse >= UINT32_MAX) + if (nonse >= 4294967295U) + { + if (fDebugSmsg) + LogPrintf("No match %u\n", nonse); + break; + //return 1; + } + nonse++; + }; + + HMAC_CTX_cleanup(&ctx); + + if (!fSecMsgEnabled) + { + if (fDebugSmsg) + LogPrintf("SecureMsgSetHash() stopped, shutdown detected.\n"); + return 2; + }; + + if (!found) + { + if (fDebugSmsg) + LogPrintf("SecureMsgSetHash() failed, took %d ms, nonse %u\n", GetTimeMillis() - nStart, nonse); + return 1; + }; + + memcpy(psmsg->hash, sha256Hash, 4); + //memcpy(psmsg->hash, &vchHash[0], 4); + + if (fDebugSmsg) + LogPrintf("SecureMsgSetHash() took %d ms, nonse %u\n", GetTimeMillis() - nStart, nonse); + + return 0; +}; + +int SecureMsgEncrypt(SecureMessage& smsg, std::string& addressFrom, std::string& addressTo, std::string& message) +{ + /* Create a secure message + + Using similar method to bitmessage. + If bitmessage is secure this should be too. + https://bitmessage.org/wiki/Encryption + + Some differences: + bitmessage seems to use curve sect283r1 + *coin addresses use secp256k1 + + returns + 2 message is too long. + 3 addressFrom is invalid. + 4 addressTo is invalid. + 5 Could not get public key for addressTo. + 6 ECDH_compute_key failed + 7 Could not get private key for addressFrom. + 8 Could not allocate memory. + 9 Could not compress message data. + 10 Could not generate MAC. + 11 Encrypt failed. + */ + + if (fDebugSmsg) + LogPrintf("SecureMsgEncrypt(%s, %s, ...)\n", addressFrom.c_str(), addressTo.c_str()); + + + if (message.size() > SMSG_MAX_MSG_BYTES) + { + LogPrintf("Message is too long, %u.\n", message.size()); + return 2; + }; + + smsg.version[0] = 1; + smsg.version[1] = 1; + smsg.timestamp = GetTime(); + + + bool fSendAnonymous; + CBitcoinAddress coinAddrFrom; + CKeyID ckidFrom; + CKey keyFrom; + + if (addressFrom.compare("anon") == 0) + { + fSendAnonymous = true; + + } else + { + fSendAnonymous = false; + + if (!coinAddrFrom.SetString(addressFrom)) + { + LogPrintf("addressFrom is not valid.\n"); + return 3; + }; + + if (!coinAddrFrom.GetKeyID(ckidFrom)) + { + LogPrintf("coinAddrFrom.GetKeyID failed: %s.\n", coinAddrFrom.ToString().c_str()); + return 3; + }; + }; + + + CBitcoinAddress coinAddrDest; + CKeyID ckidDest; + + if (!coinAddrDest.SetString(addressTo)) + { + LogPrintf("addressTo is not valid.\n"); + return 4; + }; + + if (!coinAddrDest.GetKeyID(ckidDest)) + { + LogPrintf("coinAddrDest.GetKeyID failed: %s.\n", coinAddrDest.ToString().c_str()); + return 4; + }; + + // -- public key K is the destination address + CPubKey cpkDestK; + if (SecureMsgGetStoredKey(ckidDest, cpkDestK) != 0 + && SecureMsgGetLocalKey(ckidDest, cpkDestK) != 0) // maybe it's a local key (outbox?) + { + LogPrintf("Could not get public key for destination address.\n"); + return 5; + }; + + + // -- Generate 16 random bytes as IV. + RandAddSeedPerfmon(); + RAND_bytes(&smsg.iv[0], 16); + + + // -- Generate a new random EC key pair with private key called r and public key called R. + CKey keyR; + keyR.MakeNewKey(true); // make compressed key + + CECKey ecKeyR; + ecKeyR.SetSecretBytes(keyR.begin()); + + // -- Do an EC point multiply with public key K and private key r. This gives you public key P. + CECKey ecKeyK; + if (!ecKeyK.SetPubKey(cpkDestK)) + { + LogPrintf("Could not set pubkey for K: %s.\n", HexStr(cpkDestK).c_str()); + return 4; // address to is invalid + }; + + std::vector vchP; + vchP.resize(32); + EC_KEY* pkeyr = ecKeyR.GetECKey(); + EC_KEY* pkeyK = ecKeyK.GetECKey(); + + // always seems to be 32, worth checking? + //int field_size = EC_GROUP_get_degree(EC_KEY_get0_group(pkeyr)); + //int secret_len = (field_size+7)/8; + //LogPrintf("secret_len %d.\n", secret_len); + + // -- ECDH_compute_key returns the same P if fed compressed or uncompressed public keys + ECDH_set_method(pkeyr, ECDH_OpenSSL()); + int lenP = ECDH_compute_key(&vchP[0], 32, EC_KEY_get0_public_key(pkeyK), pkeyr, NULL); + + if (lenP != 32) + { + LogPrintf("ECDH_compute_key failed, lenP: %d.\n", lenP); + return 6; + }; + + CPubKey cpkR = keyR.GetPubKey(); + if (!cpkR.IsValid() + || !cpkR.IsCompressed()) + { + LogPrintf("Could not get public key for key R.\n"); + return 1; + }; + + memcpy(smsg.cpkR, cpkR.begin(), 33); + + + // -- Use public key P and calculate the SHA512 hash H. + // The first 32 bytes of H are called key_e and the last 32 bytes are called key_m. + std::vector vchHashed; + vchHashed.resize(64); // 512 + SHA512(&vchP[0], vchP.size(), (uint8_t*)&vchHashed[0]); + std::vector key_e(&vchHashed[0], &vchHashed[0]+32); + std::vector key_m(&vchHashed[32], &vchHashed[32]+32); + + + std::vector vchPayload; + std::vector vchCompressed; + uint8_t* pMsgData; + uint32_t lenMsgData; + + uint32_t lenMsg = message.size(); + if (lenMsg > 128) + { + // -- only compress if over 128 bytes + int worstCase = LZ4_compressBound(message.size()); + try { + vchCompressed.resize(worstCase); + } catch (std::exception& e) { + LogPrintf("vchCompressed.resize %u threw: %s.\n", worstCase, e.what()); + return 8; + }; + + int lenComp = LZ4_compress((char*)message.c_str(), (char*)&vchCompressed[0], lenMsg); + if (lenComp < 1) + { + LogPrintf("Could not compress message data.\n"); + return 9; + }; + + pMsgData = &vchCompressed[0]; + lenMsgData = lenComp; + + } else + { + // -- no compression + pMsgData = (uint8_t*)message.c_str(); + lenMsgData = lenMsg; + }; + + if (fSendAnonymous) + { + try { + vchPayload.resize(9 + lenMsgData); + } catch (std::exception& e) { + LogPrintf("vchPayload.resize %u threw: %s.\n", 9 + lenMsgData, e.what()); + return 8; + }; + + memcpy(&vchPayload[9], pMsgData, lenMsgData); + + vchPayload[0] = 250; // id as anonymous message + // -- next 4 bytes are unused - there to ensure encrypted payload always > 8 bytes + memcpy(&vchPayload[5], &lenMsg, 4); // length of uncompressed plain text + } else + { + try { + vchPayload.resize(SMSG_PL_HDR_LEN + lenMsgData); + } catch (std::exception& e) { + LogPrintf("vchPayload.resize %u threw: %s.\n", SMSG_PL_HDR_LEN + lenMsgData, e.what()); + return 8; + }; + + memcpy(&vchPayload[SMSG_PL_HDR_LEN], pMsgData, lenMsgData); + // -- compact signature proves ownership of from address and allows the public key to be recovered, recipient can always reply. + if (!pwalletMain->GetKey(ckidFrom, keyFrom)) + { + LogPrintf("Could not get private key for addressFrom.\n"); + return 7; + }; + + // -- sign the plaintext + std::vector vchSignature; + vchSignature.resize(65); + keyFrom.SignCompact(Hash(message.begin(), message.end()), vchSignature); + + // -- Save some bytes by sending address raw + vchPayload[0] = (static_cast(&coinAddrFrom))->getVersion(); // vchPayload[0] = coinAddrDest.nVersion; + memcpy(&vchPayload[1], (static_cast(&ckidFrom))->GetPPN(), 20); // memcpy(&vchPayload[1], ckidDest.pn, 20); + + memcpy(&vchPayload[1+20], &vchSignature[0], vchSignature.size()); + memcpy(&vchPayload[1+20+65], &lenMsg, 4); // length of uncompressed plain text + }; + + + SecMsgCrypter crypter; + crypter.SetKey(key_e, smsg.iv); + std::vector vchCiphertext; + + if (!crypter.Encrypt(&vchPayload[0], vchPayload.size(), vchCiphertext)) + { + LogPrintf("crypter.Encrypt failed.\n"); + return 11; + }; + + try { smsg.pPayload = new uint8_t[vchCiphertext.size()]; } catch (std::exception& e) + { + LogPrintf("Could not allocate pPayload, exception: %s.\n", e.what()); + return 8; + }; + + memcpy(smsg.pPayload, &vchCiphertext[0], vchCiphertext.size()); + smsg.nPayload = vchCiphertext.size(); + + + // -- Calculate a 32 byte MAC with HMACSHA256, using key_m as salt + // Message authentication code, (hash of timestamp + destination + payload) + bool fHmacOk = true; + uint32_t nBytes = 32; + HMAC_CTX ctx; + HMAC_CTX_init(&ctx); + + if (!HMAC_Init_ex(&ctx, &key_m[0], 32, EVP_sha256(), NULL) + || !HMAC_Update(&ctx, (uint8_t*) &smsg.timestamp, sizeof(smsg.timestamp)) + || !HMAC_Update(&ctx, &vchCiphertext[0], vchCiphertext.size()) + || !HMAC_Final(&ctx, smsg.mac, &nBytes) + || nBytes != 32) + fHmacOk = false; + + HMAC_CTX_cleanup(&ctx); + + if (!fHmacOk) + { + LogPrintf("Could not generate MAC.\n"); + return 10; + }; + + + return 0; +}; + +int SecureMsgSend(std::string& addressFrom, std::string& addressTo, std::string& message, std::string& sError) +{ + /* Encrypt secure message, and place it on the network + Make a copy of the message to sender's first address and place in send queue db + proof of work thread will pick up messages from send queue db + + */ + + if (fDebugSmsg) + LogPrintf("SecureMsgSend(%s, %s, ...)\n", addressFrom.c_str(), addressTo.c_str()); + + if (pwalletMain->IsLocked()) + { + sError = "Wallet is locked, wallet must be unlocked to send and recieve messages."; + LogPrintf("Wallet is locked, wallet must be unlocked to send and recieve messages.\n"); + return 1; + }; + + if (message.size() > SMSG_MAX_MSG_BYTES) + { + std::ostringstream oss; + oss << message.size() << " > " << SMSG_MAX_MSG_BYTES; + sError = "Message is too long, " + oss.str(); + LogPrintf("Message is too long, %u.\n", message.size()); + return 1; + }; + + + int rv; + SecureMessage smsg; + + if ((rv = SecureMsgEncrypt(smsg, addressFrom, addressTo, message)) != 0) + { + LogPrintf("SecureMsgSend(), encrypt for recipient failed.\n"); + + switch(rv) + { + case 2: sError = "Message is too long."; break; + case 3: sError = "Invalid addressFrom."; break; + case 4: sError = "Invalid addressTo."; break; + case 5: sError = "Could not get public key for addressTo."; break; + case 6: sError = "ECDH_compute_key failed."; break; + case 7: sError = "Could not get private key for addressFrom."; break; + case 8: sError = "Could not allocate memory."; break; + case 9: sError = "Could not compress message data."; break; + case 10: sError = "Could not generate MAC."; break; + case 11: sError = "Encrypt failed."; break; + default: sError = "Unspecified Error."; break; + }; + + return rv; + }; + + + // -- Place message in send queue, proof of work will happen in a thread. + std::string sPrefix("qm"); + uint8_t chKey[18]; + memcpy(&chKey[0], sPrefix.data(), 2); + memcpy(&chKey[2], &smsg.timestamp, 8); + memcpy(&chKey[10], &smsg.pPayload, 8); + + SecMsgStored smsgSQ; + + smsgSQ.timeReceived = GetTime(); + smsgSQ.sAddrTo = addressTo; + + try { + smsgSQ.vchMessage.resize(SMSG_HDR_LEN + smsg.nPayload); + } catch (std::exception& e) { + LogPrintf("smsgSQ.vchMessage.resize %u threw: %s.\n", SMSG_HDR_LEN + smsg.nPayload, e.what()); + sError = "Could not allocate memory."; + return 8; + }; + + memcpy(&smsgSQ.vchMessage[0], &smsg.hash[0], SMSG_HDR_LEN); + memcpy(&smsgSQ.vchMessage[SMSG_HDR_LEN], smsg.pPayload, smsg.nPayload); + + { + LOCK(cs_smsgDB); + SecMsgDB dbSendQueue; + if (dbSendQueue.Open("cw")) + { + dbSendQueue.WriteSmesg(chKey, smsgSQ); + //NotifySecMsgSendQueueChanged(smsgOutbox); + }; + } + + // TODO: only update outbox when proof of work thread is done. + + // -- for outbox create a copy encrypted for owned address + // if the wallet is encrypted private key needed to decrypt will be unavailable + + if (fDebugSmsg) + LogPrintf("Encrypting message for outbox.\n"); + + std::string addressOutbox = "None"; + CBitcoinAddress coinAddrOutbox; + + BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& entry, pwalletMain->mapAddressBook) + { + // -- get first owned address + if (!IsMine(*pwalletMain, entry.first)) + continue; + + const CBitcoinAddress& address = entry.first; + + addressOutbox = address.ToString(); + if (!coinAddrOutbox.SetString(addressOutbox)) // test valid + continue; + break; + }; + + if (addressOutbox == "None") + { + LogPrintf("Warning: SecureMsgSend() could not find an address to encrypt outbox message with.\n"); + } else + { + if (fDebugSmsg) + LogPrintf("Encrypting a copy for outbox, using address %s\n", addressOutbox.c_str()); + + SecureMessage smsgForOutbox; + if ((rv = SecureMsgEncrypt(smsgForOutbox, addressFrom, addressOutbox, message)) != 0) + { + LogPrintf("SecureMsgSend(), encrypt for outbox failed, %d.\n", rv); + } else + { + // -- save sent message to db + std::string sPrefix("sm"); + uint8_t chKey[18]; + memcpy(&chKey[0], sPrefix.data(), 2); + memcpy(&chKey[2], &smsgForOutbox.timestamp, 8); + memcpy(&chKey[10], &smsgForOutbox.pPayload, 8); // sample + + SecMsgStored smsgOutbox; + + smsgOutbox.timeReceived = GetTime(); + smsgOutbox.sAddrTo = addressTo; + smsgOutbox.sAddrOutbox = addressOutbox; + + try { + smsgOutbox.vchMessage.resize(SMSG_HDR_LEN + smsgForOutbox.nPayload); + } catch (std::exception& e) { + LogPrintf("smsgOutbox.vchMessage.resize %u threw: %s.\n", SMSG_HDR_LEN + smsgForOutbox.nPayload, e.what()); + sError = "Could not allocate memory."; + return 8; + }; + memcpy(&smsgOutbox.vchMessage[0], &smsgForOutbox.hash[0], SMSG_HDR_LEN); + memcpy(&smsgOutbox.vchMessage[SMSG_HDR_LEN], smsgForOutbox.pPayload, smsgForOutbox.nPayload); + + + { + LOCK(cs_smsgDB); + SecMsgDB dbSent; + + if (dbSent.Open("cw")) + { + dbSent.WriteSmesg(chKey, smsgOutbox); + NotifySecMsgOutboxChanged(smsgOutbox); + }; + } + }; + }; + + if (fDebugSmsg) + LogPrintf("Secure message queued for sending to %s.\n", addressTo.c_str()); + + return 0; +}; + + +int SecureMsgDecrypt(bool fTestOnly, std::string& address, uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload, MessageData& msg) +{ + /* Decrypt secure message + + address is the owned address to decrypt with. + + validate first in SecureMsgValidate + + returns + 1 Error + 2 Unknown version number + 3 Decrypt address is not valid. + 8 Could not allocate memory + */ + + if (fDebugSmsg) + LogPrintf("SecureMsgDecrypt(), using %s, testonly %d.\n", address.c_str(), fTestOnly); + + if (!pHeader + || !pPayload) + { + LogPrintf("Error: null pointer to header or payload.\n"); + return 1; + }; + + SecureMessage* psmsg = (SecureMessage*) pHeader; + + + if (psmsg->version[0] != 1) + { + LogPrintf("Unknown version number.\n"); + return 2; + }; + + + + // -- Fetch private key k, used to decrypt + CBitcoinAddress coinAddrDest; + CKeyID ckidDest; + CKey keyDest; + if (!coinAddrDest.SetString(address)) + { + LogPrintf("Address is not valid.\n"); + return 3; + }; + if (!coinAddrDest.GetKeyID(ckidDest)) + { + LogPrintf("coinAddrDest.GetKeyID failed: %s.\n", coinAddrDest.ToString().c_str()); + return 3; + }; + if (!pwalletMain->GetKey(ckidDest, keyDest)) + { + LogPrintf("Could not get private key for addressDest.\n"); + return 3; + }; + + + + CPubKey cpkR(psmsg->cpkR, psmsg->cpkR+33); + if (!cpkR.IsValid()) + { + LogPrintf("Could not get pubkey for key R.\n"); + return 1; + }; + + CECKey ecKeyR; + if (!ecKeyR.SetPubKey(cpkR)) + { + LogPrintf("Could not set pubkey for key R: %s.\n", HexStr(cpkR).c_str()); + return 1; + }; + + CECKey ecKeyDest; + ecKeyDest.SetSecretBytes(keyDest.begin()); + + // -- Do an EC point multiply with private key k and public key R. This gives you public key P. + std::vector vchP; + vchP.resize(32); + EC_KEY* pkeyk = ecKeyDest.GetECKey(); + EC_KEY* pkeyR = ecKeyR.GetECKey(); + + ECDH_set_method(pkeyk, ECDH_OpenSSL()); + int lenPdec = ECDH_compute_key(&vchP[0], 32, EC_KEY_get0_public_key(pkeyR), pkeyk, NULL); + + if (lenPdec != 32) + { + LogPrintf("ECDH_compute_key failed, lenPdec: %d.\n", lenPdec); + return 1; + }; + + + // -- Use public key P to calculate the SHA512 hash H. + // The first 32 bytes of H are called key_e and the last 32 bytes are called key_m. + std::vector vchHashedDec; + vchHashedDec.resize(64); // 512 bits + SHA512(&vchP[0], vchP.size(), (uint8_t*)&vchHashedDec[0]); + std::vector key_e(&vchHashedDec[0], &vchHashedDec[0]+32); + std::vector key_m(&vchHashedDec[32], &vchHashedDec[32]+32); + + + // -- Message authentication code, (hash of timestamp + destination + payload) + uint8_t MAC[32]; + bool fHmacOk = true; + uint32_t nBytes = 32; + HMAC_CTX ctx; + HMAC_CTX_init(&ctx); + + if (!HMAC_Init_ex(&ctx, &key_m[0], 32, EVP_sha256(), NULL) + || !HMAC_Update(&ctx, (uint8_t*) &psmsg->timestamp, sizeof(psmsg->timestamp)) + || !HMAC_Update(&ctx, pPayload, nPayload) + || !HMAC_Final(&ctx, MAC, &nBytes) + || nBytes != 32) + fHmacOk = false; + + HMAC_CTX_cleanup(&ctx); + + if (!fHmacOk) + { + LogPrintf("Could not generate MAC.\n"); + return 1; + }; + + if (memcmp(MAC, psmsg->mac, 32) != 0) + { + if (fDebugSmsg) + LogPrintf("MAC does not match.\n"); // expected if message is not to address on node + + return 1; + }; + + if (fTestOnly) + return 0; + + SecMsgCrypter crypter; + crypter.SetKey(key_e, psmsg->iv); + std::vector vchPayload; + if (!crypter.Decrypt(pPayload, nPayload, vchPayload)) + { + LogPrintf("Decrypt failed.\n"); + return 1; + }; + + msg.timestamp = psmsg->timestamp; + uint32_t lenData; + uint32_t lenPlain; + + uint8_t* pMsgData; + bool fFromAnonymous; + if ((uint32_t)vchPayload[0] == 250) + { + fFromAnonymous = true; + lenData = vchPayload.size() - (9); + memcpy(&lenPlain, &vchPayload[5], 4); + pMsgData = &vchPayload[9]; + } else + { + fFromAnonymous = false; + lenData = vchPayload.size() - (SMSG_PL_HDR_LEN); + memcpy(&lenPlain, &vchPayload[1+20+65], 4); + pMsgData = &vchPayload[SMSG_PL_HDR_LEN]; + }; + + try { + msg.vchMessage.resize(lenPlain + 1); + } catch (std::exception& e) { + LogPrintf("msg.vchMessage.resize %u threw: %s.\n", lenPlain + 1, e.what()); + return 8; + }; + + + if (lenPlain > 128) + { + // -- decompress + if (LZ4_decompress_safe((char*) pMsgData, (char*) &msg.vchMessage[0], lenData, lenPlain) != (int) lenPlain) + { + LogPrintf("Could not decompress message data.\n"); + return 1; + }; + } else + { + // -- plaintext + memcpy(&msg.vchMessage[0], pMsgData, lenPlain); + }; + + msg.vchMessage[lenPlain] = '\0'; + + if (fFromAnonymous) + { + // -- Anonymous sender + msg.sFromAddress = "anon"; + } else + { + std::vector vchUint160; + vchUint160.resize(20); + + memcpy(&vchUint160[0], &vchPayload[1], 20); + + uint160 ui160(vchUint160); + CKeyID ckidFrom(ui160); + + CBitcoinAddress coinAddrFrom; + coinAddrFrom.Set(ckidFrom); + if (!coinAddrFrom.IsValid()) + { + LogPrintf("From Addess is invalid.\n"); + return 1; + }; + + std::vector vchSig; + vchSig.resize(65); + + memcpy(&vchSig[0], &vchPayload[1+20], 65); + + CPubKey cpkFromSig; + cpkFromSig.RecoverCompact(Hash(msg.vchMessage.begin(), msg.vchMessage.end()-1), vchSig); + if (!cpkFromSig.IsValid()) + { + LogPrintf("Signature validation failed.\n"); + return 1; + }; + + // -- get address for the compressed public key + CBitcoinAddress coinAddrFromSig; + coinAddrFromSig.Set(cpkFromSig.GetID()); + + if (!(coinAddrFrom == coinAddrFromSig)) + { + LogPrintf("Signature validation failed.\n"); + return 1; + }; + + int rv = 5; + try { + rv = SecureMsgInsertAddress(ckidFrom, cpkFromSig); + } catch (std::exception& e) { + LogPrintf("SecureMsgInsertAddress(), exception: %s.\n", e.what()); + //return 1; + }; + + switch(rv) + { + case 0: + LogPrintf("Sender public key added to db.\n"); + break; + case 4: + LogPrintf("Sender public key already in db.\n"); + break; + default: + LogPrintf("Error adding sender public key to db.\n"); + break; + }; + + msg.sFromAddress = coinAddrFrom.ToString(); + }; + + if (fDebugSmsg) + LogPrintf("Decrypted message for %s.\n", address.c_str()); + + return 0; +}; + +int SecureMsgDecrypt(bool fTestOnly, std::string& address, SecureMessage& smsg, MessageData& msg) +{ + return SecureMsgDecrypt(fTestOnly, address, &smsg.hash[0], smsg.pPayload, smsg.nPayload, msg); +}; + diff --git a/src/smessage.h b/src/smessage.h new file mode 100644 index 0000000..3f141ea --- /dev/null +++ b/src/smessage.h @@ -0,0 +1,379 @@ +// Copyright (c) 2014 The ShadowCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef SEC_MESSAGE_H +#define SEC_MESSAGE_H + +#include +#include + +#include "net.h" +#include "db.h" +#include "wallet.h" +#include "lz4/lz4.h" +#include "base58.h" + +const unsigned int SMSG_HDR_LEN = 104; // length of unencrypted header, 4 + 2 + 1 + 8 + 16 + 33 + 32 + 4 +4 +const unsigned int SMSG_PL_HDR_LEN = 1+20+65+4; // length of encrypted header in payload + +const unsigned int SMSG_BUCKET_LEN = 60 * 10; // in seconds +const unsigned int SMSG_RETENTION = 60 * 60 * 48; // in seconds +const unsigned int SMSG_SEND_DELAY = 2; // in seconds, SecureMsgSendData will delay this long between firing +const unsigned int SMSG_THREAD_DELAY = 20; + +const unsigned int SMSG_TIME_LEEWAY = 60; +const unsigned int SMSG_TIME_IGNORE = 90; // seconds that a peer is ignored for if they fail to deliver messages for a smsgWant + + +const unsigned int SMSG_MAX_MSG_BYTES = 4096; // the user input part + +// max size of payload worst case compression +const unsigned int SMSG_MAX_MSG_WORST = LZ4_COMPRESSBOUND(SMSG_MAX_MSG_BYTES+SMSG_PL_HDR_LEN); + + + +#define SMSG_MASK_UNREAD (1 << 0) + + + +extern bool fSecMsgEnabled; + +class SecMsgStored; + +// Inbox db changed, called with lock cs_smsgDB held. +extern boost::signals2::signal NotifySecMsgInboxChanged; + +// Outbox db changed, called with lock cs_smsgDB held. +extern boost::signals2::signal NotifySecMsgOutboxChanged; + +// Wallet Unlocked, called after all messages received while locked have been processed. +extern boost::signals2::signal NotifySecMsgWalletUnlocked; + + +class SecMsgBucket; +class SecMsgAddress; +class SecMsgOptions; + +extern std::map smsgBuckets; +extern std::vector smsgAddresses; +extern SecMsgOptions smsgOptions; + +extern CCriticalSection cs_smsg; // all except inbox and outbox +extern CCriticalSection cs_smsgDB; + + +#pragma pack(push, 1) +class SecureMessage +{ +public: + SecureMessage() + { + nPayload = 0; + pPayload = NULL; + }; + + ~SecureMessage() + { + if (pPayload) + delete[] pPayload; + pPayload = NULL; + }; + + uint8_t hash[4]; + uint8_t version[2]; + uint8_t flags; + int64_t timestamp; + uint8_t iv[16]; + uint8_t cpkR[33]; + uint8_t mac[32]; + uint8_t nonse[4]; + uint32_t nPayload; + uint8_t* pPayload; + +}; +#pragma pack(pop) + + +class MessageData +{ +// -- Decrypted SecureMessage data +public: + int64_t timestamp; + std::string sToAddress; + std::string sFromAddress; + std::vector vchMessage; // null terminated plaintext +}; + + +class SecMsgToken +{ +public: + SecMsgToken(int64_t ts, uint8_t* p, int np, long int o) + { + timestamp = ts; + + if (np < 8) // payload will always be > 8, just make sure + memset(sample, 0, 8); + else + memcpy(sample, p, 8); + offset = o; + }; + + SecMsgToken() {}; + + ~SecMsgToken() {}; + + bool operator <(const SecMsgToken& y) const + { + // pack and memcmp from timesent? + if (timestamp == y.timestamp) + return memcmp(sample, y.sample, 8) < 0; + return timestamp < y.timestamp; + } + + int64_t timestamp; // doesn't need to be full 64 bytes? + uint8_t sample[8]; // first 8 bytes of payload - a hash + int64_t offset; // offset + +}; + + +class SecMsgBucket +{ +public: + SecMsgBucket() + { + timeChanged = 0; + hash = 0; + nLockCount = 0; + nLockPeerId = 0; + }; + ~SecMsgBucket() {}; + + void hashBucket(); + + int64_t timeChanged; + uint32_t hash; // token set should get ordered the same on each node + uint32_t nLockCount; // set when smsgWant first sent, unset at end of smsgMsg, ticks down in ThreadSecureMsg() + NodeId nLockPeerId; // id of peer that bucket is locked for + std::set setTokens; + +}; + + +// -- get at the data +class CBitcoinAddress_B : public CBitcoinAddress +{ +public: + uint8_t getVersion() + { + // TODO: fix + if (vchVersion.size() > 0) + return vchVersion[0]; + return 0; + } +}; + +class CKeyID_B : public CKeyID +{ +public: + uint32_t* GetPPN() + { + return pn; + } +}; + + +class SecMsgAddress +{ +public: + SecMsgAddress() {}; + SecMsgAddress(std::string sAddr, bool receiveOn, bool receiveAnon) + { + sAddress = sAddr; + fReceiveEnabled = receiveOn; + fReceiveAnon = receiveAnon; + }; + + std::string sAddress; + bool fReceiveEnabled; + bool fReceiveAnon; + + IMPLEMENT_SERIALIZE + ( + READWRITE(this->sAddress); + READWRITE(this->fReceiveEnabled); + READWRITE(this->fReceiveAnon); + ); +}; + +class SecMsgOptions +{ +public: + SecMsgOptions() + { + // -- default options + fNewAddressRecv = true; + fNewAddressAnon = true; + } + + bool fNewAddressRecv; + bool fNewAddressAnon; +}; + + +class SecMsgCrypter +{ +private: + uint8_t chKey[32]; + uint8_t chIV[16]; + bool fKeySet; +public: + + SecMsgCrypter() + { + // Try to keep the key data out of swap (and be a bit over-careful to keep the IV that we don't even use out of swap) + // Note that this does nothing about suspend-to-disk (which will put all our key data on disk) + // Note as well that at no point in this program is any attempt made to prevent stealing of keys by reading the memory of the running process. + LockedPageManager::instance.LockRange(&chKey[0], sizeof chKey); + LockedPageManager::instance.LockRange(&chIV[0], sizeof chIV); + fKeySet = false; + } + + ~SecMsgCrypter() + { + // clean key + memset(&chKey, 0, sizeof chKey); + memset(&chIV, 0, sizeof chIV); + fKeySet = false; + + LockedPageManager::instance.UnlockRange(&chKey[0], sizeof chKey); + LockedPageManager::instance.UnlockRange(&chIV[0], sizeof chIV); + } + + bool SetKey(const std::vector& vchNewKey, uint8_t* chNewIV); + bool SetKey(const uint8_t* chNewKey, uint8_t* chNewIV); + bool Encrypt(uint8_t* chPlaintext, uint32_t nPlain, std::vector &vchCiphertext); + bool Decrypt(uint8_t* chCiphertext, uint32_t nCipher, std::vector& vchPlaintext); +}; + + +class SecMsgStored +{ +public: + int64_t timeReceived; + char status; // read etc + uint16_t folderId; + std::string sAddrTo; // when in owned addr, when sent remote addr + std::string sAddrOutbox; // owned address this copy was encrypted with + std::vector vchMessage; // message header + encryped payload + + IMPLEMENT_SERIALIZE + ( + READWRITE(this->timeReceived); + READWRITE(this->status); + READWRITE(this->folderId); + READWRITE(this->sAddrTo); + READWRITE(this->sAddrOutbox); + READWRITE(this->vchMessage); + ); +}; + +class SecMsgDB +{ +public: + SecMsgDB() + { + activeBatch = NULL; + }; + + ~SecMsgDB() + { + // -- deletes only data scoped to this TxDB object. + + if (activeBatch) + delete activeBatch; + }; + + bool Open(const char* pszMode="r+"); + + bool ScanBatch(const CDataStream& key, std::string* value, bool* deleted) const; + + bool TxnBegin(); + bool TxnCommit(); + bool TxnAbort(); + + bool ReadPK(CKeyID& addr, CPubKey& pubkey); + bool WritePK(CKeyID& addr, CPubKey& pubkey); + bool ExistsPK(CKeyID& addr); + + bool NextSmesg(leveldb::Iterator* it, std::string& prefix, uint8_t* vchKey, SecMsgStored& smsgStored); + bool NextSmesgKey(leveldb::Iterator* it, std::string& prefix, uint8_t* vchKey); + bool ReadSmesg(uint8_t* chKey, SecMsgStored& smsgStored); + bool WriteSmesg(uint8_t* chKey, SecMsgStored& smsgStored); + bool ExistsSmesg(uint8_t* chKey); + bool EraseSmesg(uint8_t* chKey); + + leveldb::DB *pdb; // points to the global instance + leveldb::WriteBatch *activeBatch; + +}; + + +int SecureMsgBuildBucketSet(); +int SecureMsgAddWalletAddresses(); + +int SecureMsgReadIni(); +int SecureMsgWriteIni(); + +bool SecureMsgStart(bool fDontStart, bool fScanChain); +bool SecureMsgShutdown(); + +bool SecureMsgEnable(); +bool SecureMsgDisable(); + +bool SecureMsgReceiveData(CNode* pfrom, std::string strCommand, CDataStream& vRecv); +bool SecureMsgSendData(CNode* pto, bool fSendTrickle); + + +bool SecureMsgScanBlock(CBlock& block); +bool ScanChainForPublicKeys(CBlockIndex* pindexStart); +bool SecureMsgScanBlockChain(); +bool SecureMsgScanBuckets(); + + +int SecureMsgWalletUnlocked(); +int SecureMsgWalletKeyChanged(std::string sAddress, std::string sLabel, ChangeType mode); + +int SecureMsgScanMessage(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload, bool reportToGui); + +int SecureMsgGetStoredKey(CKeyID& ckid, CPubKey& cpkOut); +int SecureMsgGetLocalKey(CKeyID& ckid, CPubKey& cpkOut); +int SecureMsgGetLocalPublicKey(std::string& strAddress, std::string& strPublicKey); + +int SecureMsgAddAddress(std::string& address, std::string& publicKey); + +int SecureMsgRetrieve(SecMsgToken &token, std::vector& vchData); + +int SecureMsgReceive(CNode* pfrom, std::vector& vchData); + +int SecureMsgStoreUnscanned(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload); +int SecureMsgStore(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload, bool fUpdateBucket); +int SecureMsgStore(SecureMessage& smsg, bool fUpdateBucket); + + + +int SecureMsgSend(std::string& addressFrom, std::string& addressTo, std::string& message, std::string& sError); + +int SecureMsgValidate(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload); +int SecureMsgSetHash(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload); + +int SecureMsgEncrypt(SecureMessage& smsg, std::string& addressFrom, std::string& addressTo, std::string& message); + +int SecureMsgDecrypt(bool fTestOnly, std::string& address, uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload, MessageData& msg); +int SecureMsgDecrypt(bool fTestOnly, std::string& address, SecureMessage& smsg, MessageData& msg); + + + +#endif // SEC_MESSAGE_H + diff --git a/src/sph_types.h b/src/sph_types.h new file mode 100644 index 0000000..7295b0b --- /dev/null +++ b/src/sph_types.h @@ -0,0 +1,1976 @@ +/* $Id: sph_types.h 260 2011-07-21 01:02:38Z tp $ */ +/** + * Basic type definitions. + * + * This header file defines the generic integer types that will be used + * for the implementation of hash functions; it also contains helper + * functions which encode and decode multi-byte integer values, using + * either little-endian or big-endian conventions. + * + * This file contains a compile-time test on the size of a byte + * (the unsigned char C type). If bytes are not octets, + * i.e. if they do not have a size of exactly 8 bits, then compilation + * is aborted. Architectures where bytes are not octets are relatively + * rare, even in the embedded devices market. We forbid non-octet bytes + * because there is no clear convention on how octet streams are encoded + * on such systems. + * + * ==========================(LICENSE BEGIN)============================ + * + * Copyright (c) 2007-2010 Projet RNRT SAPHIR + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ===========================(LICENSE END)============================= + * + * @file sph_types.h + * @author Thomas Pornin + */ + +#ifndef SPH_TYPES_H__ +#define SPH_TYPES_H__ + +#include + +/* + * All our I/O functions are defined over octet streams. We do not know + * how to handle input data if bytes are not octets. + */ +#if CHAR_BIT != 8 +#error This code requires 8-bit bytes +#endif + +/* ============= BEGIN documentation block for Doxygen ============ */ + +#ifdef DOXYGEN_IGNORE + +/** @mainpage sphlib C code documentation + * + * @section overview Overview + * + * sphlib is a library which contains implementations of + * various cryptographic hash functions. These pages have been generated + * with doxygen and + * document the API for the C implementations. + * + * The API is described in appropriate header files, which are available + * in the "Files" section. Each hash function family has its own header, + * whose name begins with "sph_" and contains the family + * name. For instance, the API for the RIPEMD hash functions is available + * in the header file sph_ripemd.h. + * + * @section principles API structure and conventions + * + * @subsection io Input/output conventions + * + * In all generality, hash functions operate over strings of bits. + * Individual bits are rarely encountered in C programming or actual + * communication protocols; most protocols converge on the ubiquitous + * "octet" which is a group of eight bits. Data is thus expressed as a + * stream of octets. The C programming language contains the notion of a + * "byte", which is a data unit managed under the type "unsigned + * char". The C standard prescribes that a byte should hold at + * least eight bits, but possibly more. Most modern architectures, even + * in the embedded world, feature eight-bit bytes, i.e. map bytes to + * octets. + * + * Nevertheless, for some of the implemented hash functions, an extra + * API has been added, which allows the input of arbitrary sequences of + * bits: when the computation is about to be closed, 1 to 7 extra bits + * can be added. The functions for which this API is implemented include + * the SHA-2 functions and all SHA-3 candidates. + * + * sphlib defines hash function which may hash octet streams, + * i.e. streams of bits where the number of bits is a multiple of eight. + * The data input functions in the sphlib API expect data + * as anonymous pointers ("const void *") with a length + * (of type "size_t") which gives the input data chunk length + * in bytes. A byte is assumed to be an octet; the sph_types.h + * header contains a compile-time test which prevents compilation on + * architectures where this property is not met. + * + * The hash function output is also converted into bytes. All currently + * implemented hash functions have an output width which is a multiple of + * eight, and this is likely to remain true for new designs. + * + * Most hash functions internally convert input data into 32-bit of 64-bit + * words, using either little-endian or big-endian conversion. The hash + * output also often consists of such words, which are encoded into output + * bytes with a similar endianness convention. Some hash functions have + * been only loosely specified on that subject; when necessary, + * sphlib has been tested against published "reference" + * implementations in order to use the same conventions. + * + * @subsection shortname Function short name + * + * Each implemented hash function has a "short name" which is used + * internally to derive the identifiers for the functions and context + * structures which the function uses. For instance, MD5 has the short + * name "md5". Short names are listed in the next section, + * for the implemented hash functions. In subsequent sections, the + * short name will be assumed to be "XXX": replace with the + * actual hash function name to get the C identifier. + * + * Note: some functions within the same family share the same core + * elements, such as update function or context structure. Correspondingly, + * some of the defined types or functions may actually be macros which + * transparently evaluate to another type or function name. + * + * @subsection context Context structure + * + * Each implemented hash fonction has its own context structure, available + * under the type name "sph_XXX_context" for the hash function + * with short name "XXX". This structure holds all needed + * state for a running hash computation. + * + * The contents of these structures are meant to be opaque, and private + * to the implementation. However, these contents are specified in the + * header files so that application code which uses sphlib + * may access the size of those structures. + * + * The caller is responsible for allocating the context structure, + * whether by dynamic allocation (malloc() or equivalent), + * static allocation (a global permanent variable), as an automatic + * variable ("on the stack"), or by any other mean which ensures proper + * structure alignment. sphlib code performs no dynamic + * allocation by itself. + * + * The context must be initialized before use, using the + * sph_XXX_init() function. This function sets the context + * state to proper initial values for hashing. + * + * Since all state data is contained within the context structure, + * sphlib is thread-safe and reentrant: several hash + * computations may be performed in parallel, provided that they do not + * operate on the same context. Moreover, a running computation can be + * cloned by copying the context (with a simple memcpy()): + * the context and its clone are then independant and may be updated + * with new data and/or closed without interfering with each other. + * Similarly, a context structure can be moved in memory at will: + * context structures contain no pointer, in particular no pointer to + * themselves. + * + * @subsection dataio Data input + * + * Hashed data is input with the sph_XXX() fonction, which + * takes as parameters a pointer to the context, a pointer to the data + * to hash, and the number of data bytes to hash. The context is updated + * with the new data. + * + * Data can be input in one or several calls, with arbitrary input lengths. + * However, it is best, performance wise, to input data by relatively big + * chunks (say a few kilobytes), because this allows sphlib to + * optimize things and avoid internal copying. + * + * When all data has been input, the context can be closed with + * sph_XXX_close(). The hash output is computed and written + * into the provided buffer. The caller must take care to provide a + * buffer of appropriate length; e.g., when using SHA-1, the output is + * a 20-byte word, therefore the output buffer must be at least 20-byte + * long. + * + * For some hash functions, the sph_XXX_addbits_and_close() + * function can be used instead of sph_XXX_close(). This + * function can take a few extra bits to be added at + * the end of the input message. This allows hashing messages with a + * bit length which is not a multiple of 8. The extra bits are provided + * as an unsigned integer value, and a bit count. The bit count must be + * between 0 and 7, inclusive. The extra bits are provided as bits 7 to + * 0 (bits of numerical value 128, 64, 32... downto 0), in that order. + * For instance, to add three bits of value 1, 1 and 0, the unsigned + * integer will have value 192 (1*128 + 1*64 + 0*32) and the bit count + * will be 3. + * + * The SPH_SIZE_XXX macro is defined for each hash function; + * it evaluates to the function output size, expressed in bits. For instance, + * SPH_SIZE_sha1 evaluates to 160. + * + * When closed, the context is automatically reinitialized and can be + * immediately used for another computation. It is not necessary to call + * sph_XXX_init() after a close. Note that + * sph_XXX_init() can still be called to "reset" a context, + * i.e. forget previously input data, and get back to the initial state. + * + * @subsection alignment Data alignment + * + * "Alignment" is a property of data, which is said to be "properly + * aligned" when its emplacement in memory is such that the data can + * be optimally read by full words. This depends on the type of access; + * basically, some hash functions will read data by 32-bit or 64-bit + * words. sphlib does not mandate such alignment for input + * data, but using aligned data can substantially improve performance. + * + * As a rule, it is best to input data by chunks whose length (in bytes) + * is a multiple of eight, and which begins at "generally aligned" + * addresses, such as the base address returned by a call to + * malloc(). + * + * @section functions Implemented functions + * + * We give here the list of implemented functions. They are grouped by + * family; to each family corresponds a specific header file. Each + * individual function has its associated "short name". Please refer to + * the documentation for that header file to get details on the hash + * function denomination and provenance. + * + * Note: the functions marked with a '(64)' in the list below are + * available only if the C compiler provides an integer type of length + * 64 bits or more. Such a type is mandatory in the latest C standard + * (ISO 9899:1999, aka "C99") and is present in several older compilers + * as well, so chances are that such a type is available. + * + * - HAVAL family: file sph_haval.h + * - HAVAL-128/3 (128-bit, 3 passes): short name: haval128_3 + * - HAVAL-128/4 (128-bit, 4 passes): short name: haval128_4 + * - HAVAL-128/5 (128-bit, 5 passes): short name: haval128_5 + * - HAVAL-160/3 (160-bit, 3 passes): short name: haval160_3 + * - HAVAL-160/4 (160-bit, 4 passes): short name: haval160_4 + * - HAVAL-160/5 (160-bit, 5 passes): short name: haval160_5 + * - HAVAL-192/3 (192-bit, 3 passes): short name: haval192_3 + * - HAVAL-192/4 (192-bit, 4 passes): short name: haval192_4 + * - HAVAL-192/5 (192-bit, 5 passes): short name: haval192_5 + * - HAVAL-224/3 (224-bit, 3 passes): short name: haval224_3 + * - HAVAL-224/4 (224-bit, 4 passes): short name: haval224_4 + * - HAVAL-224/5 (224-bit, 5 passes): short name: haval224_5 + * - HAVAL-256/3 (256-bit, 3 passes): short name: haval256_3 + * - HAVAL-256/4 (256-bit, 4 passes): short name: haval256_4 + * - HAVAL-256/5 (256-bit, 5 passes): short name: haval256_5 + * - MD2: file sph_md2.h, short name: md2 + * - MD4: file sph_md4.h, short name: md4 + * - MD5: file sph_md5.h, short name: md5 + * - PANAMA: file sph_panama.h, short name: panama + * - RadioGatun family: file sph_radiogatun.h + * - RadioGatun[32]: short name: radiogatun32 + * - RadioGatun[64]: short name: radiogatun64 (64) + * - RIPEMD family: file sph_ripemd.h + * - RIPEMD: short name: ripemd + * - RIPEMD-128: short name: ripemd128 + * - RIPEMD-160: short name: ripemd160 + * - SHA-0: file sph_sha0.h, short name: sha0 + * - SHA-1: file sph_sha1.h, short name: sha1 + * - SHA-2 family, 32-bit hashes: file sph_sha2.h + * - SHA-224: short name: sha224 + * - SHA-256: short name: sha256 + * - SHA-384: short name: sha384 (64) + * - SHA-512: short name: sha512 (64) + * - Tiger family: file sph_tiger.h + * - Tiger: short name: tiger (64) + * - Tiger2: short name: tiger2 (64) + * - WHIRLPOOL family: file sph_whirlpool.h + * - WHIRLPOOL-0: short name: whirlpool0 (64) + * - WHIRLPOOL-1: short name: whirlpool1 (64) + * - WHIRLPOOL: short name: whirlpool (64) + * + * The fourteen second-round SHA-3 candidates are also implemented; + * when applicable, the implementations follow the "final" specifications + * as published for the third round of the SHA-3 competition (BLAKE, + * Groestl, JH, Keccak and Skein have been tweaked for third round). + * + * - BLAKE family: file sph_blake.h + * - BLAKE-224: short name: blake224 + * - BLAKE-256: short name: blake256 + * - BLAKE-384: short name: blake384 + * - BLAKE-512: short name: blake512 + * - BMW (Blue Midnight Wish) family: file sph_bmw.h + * - BMW-224: short name: bmw224 + * - BMW-256: short name: bmw256 + * - BMW-384: short name: bmw384 (64) + * - BMW-512: short name: bmw512 (64) + * - CubeHash family: file sph_cubehash.h (specified as + * CubeHash16/32 in the CubeHash specification) + * - CubeHash-224: short name: cubehash224 + * - CubeHash-256: short name: cubehash256 + * - CubeHash-384: short name: cubehash384 + * - CubeHash-512: short name: cubehash512 + * - ECHO family: file sph_echo.h + * - ECHO-224: short name: echo224 + * - ECHO-256: short name: echo256 + * - ECHO-384: short name: echo384 + * - ECHO-512: short name: echo512 + * - Fugue family: file sph_fugue.h + * - Fugue-224: short name: fugue224 + * - Fugue-256: short name: fugue256 + * - Fugue-384: short name: fugue384 + * - Fugue-512: short name: fugue512 + * - Groestl family: file sph_groestl.h + * - Groestl-224: short name: groestl224 + * - Groestl-256: short name: groestl256 + * - Groestl-384: short name: groestl384 + * - Groestl-512: short name: groestl512 + * - Hamsi family: file sph_hamsi.h + * - Hamsi-224: short name: hamsi224 + * - Hamsi-256: short name: hamsi256 + * - Hamsi-384: short name: hamsi384 + * - Hamsi-512: short name: hamsi512 + * - JH family: file sph_jh.h + * - JH-224: short name: jh224 + * - JH-256: short name: jh256 + * - JH-384: short name: jh384 + * - JH-512: short name: jh512 + * - Keccak family: file sph_keccak.h + * - Keccak-224: short name: keccak224 + * - Keccak-256: short name: keccak256 + * - Keccak-384: short name: keccak384 + * - Keccak-512: short name: keccak512 + * - Luffa family: file sph_luffa.h + * - Luffa-224: short name: luffa224 + * - Luffa-256: short name: luffa256 + * - Luffa-384: short name: luffa384 + * - Luffa-512: short name: luffa512 + * - Shabal family: file sph_shabal.h + * - Shabal-192: short name: shabal192 + * - Shabal-224: short name: shabal224 + * - Shabal-256: short name: shabal256 + * - Shabal-384: short name: shabal384 + * - Shabal-512: short name: shabal512 + * - SHAvite-3 family: file sph_shavite.h + * - SHAvite-224 (nominally "SHAvite-3 with 224-bit output"): + * short name: shabal224 + * - SHAvite-256 (nominally "SHAvite-3 with 256-bit output"): + * short name: shabal256 + * - SHAvite-384 (nominally "SHAvite-3 with 384-bit output"): + * short name: shabal384 + * - SHAvite-512 (nominally "SHAvite-3 with 512-bit output"): + * short name: shabal512 + * - SIMD family: file sph_simd.h + * - SIMD-224: short name: simd224 + * - SIMD-256: short name: simd256 + * - SIMD-384: short name: simd384 + * - SIMD-512: short name: simd512 + * - Skein family: file sph_skein.h + * - Skein-224 (nominally specified as Skein-512-224): short name: + * skein224 (64) + * - Skein-256 (nominally specified as Skein-512-256): short name: + * skein256 (64) + * - Skein-384 (nominally specified as Skein-512-384): short name: + * skein384 (64) + * - Skein-512 (nominally specified as Skein-512-512): short name: + * skein512 (64) + * + * For the second-round SHA-3 candidates, the functions are as specified + * for round 2, i.e. with the "tweaks" that some candidates added + * between round 1 and round 2. Also, some of the submitted packages for + * round 2 contained errors, in the specification, reference code, or + * both. sphlib implements the corrected versions. + */ + +/** @hideinitializer + * Unsigned integer type whose length is at least 32 bits; on most + * architectures, it will have a width of exactly 32 bits. Unsigned C + * types implement arithmetics modulo a power of 2; use the + * SPH_T32() macro to ensure that the value is truncated + * to exactly 32 bits. Unless otherwise specified, all macros and + * functions which accept sph_u32 values assume that these + * values fit on 32 bits, i.e. do not exceed 2^32-1, even on architectures + * where sph_u32 is larger than that. + */ +typedef __arch_dependant__ sph_u32; + +/** @hideinitializer + * Signed integer type corresponding to sph_u32; it has + * width 32 bits or more. + */ +typedef __arch_dependant__ sph_s32; + +/** @hideinitializer + * Unsigned integer type whose length is at least 64 bits; on most + * architectures which feature such a type, it will have a width of + * exactly 64 bits. C99-compliant platform will have this type; it + * is also defined when the GNU compiler (gcc) is used, and on + * platforms where unsigned long is large enough. If this + * type is not available, then some hash functions which depends on + * a 64-bit type will not be available (most notably SHA-384, SHA-512, + * Tiger and WHIRLPOOL). + */ +typedef __arch_dependant__ sph_u64; + +/** @hideinitializer + * Signed integer type corresponding to sph_u64; it has + * width 64 bits or more. + */ +typedef __arch_dependant__ sph_s64; + +/** + * This macro expands the token x into a suitable + * constant expression of type sph_u32. Depending on + * how this type is defined, a suffix such as UL may + * be appended to the argument. + * + * @param x the token to expand into a suitable constant expression + */ +#define SPH_C32(x) + +/** + * Truncate a 32-bit value to exactly 32 bits. On most systems, this is + * a no-op, recognized as such by the compiler. + * + * @param x the value to truncate (of type sph_u32) + */ +#define SPH_T32(x) + +/** + * Rotate a 32-bit value by a number of bits to the left. The rotate + * count must reside between 1 and 31. This macro assumes that its + * first argument fits in 32 bits (no extra bit allowed on machines where + * sph_u32 is wider); both arguments may be evaluated + * several times. + * + * @param x the value to rotate (of type sph_u32) + * @param n the rotation count (between 1 and 31, inclusive) + */ +#define SPH_ROTL32(x, n) + +/** + * Rotate a 32-bit value by a number of bits to the left. The rotate + * count must reside between 1 and 31. This macro assumes that its + * first argument fits in 32 bits (no extra bit allowed on machines where + * sph_u32 is wider); both arguments may be evaluated + * several times. + * + * @param x the value to rotate (of type sph_u32) + * @param n the rotation count (between 1 and 31, inclusive) + */ +#define SPH_ROTR32(x, n) + +/** + * This macro is defined on systems for which a 64-bit type has been + * detected, and is used for sph_u64. + */ +#define SPH_64 + +/** + * This macro is defined on systems for the "native" integer size is + * 64 bits (64-bit values fit in one register). + */ +#define SPH_64_TRUE + +/** + * This macro expands the token x into a suitable + * constant expression of type sph_u64. Depending on + * how this type is defined, a suffix such as ULL may + * be appended to the argument. This macro is defined only if a + * 64-bit type was detected and used for sph_u64. + * + * @param x the token to expand into a suitable constant expression + */ +#define SPH_C64(x) + +/** + * Truncate a 64-bit value to exactly 64 bits. On most systems, this is + * a no-op, recognized as such by the compiler. This macro is defined only + * if a 64-bit type was detected and used for sph_u64. + * + * @param x the value to truncate (of type sph_u64) + */ +#define SPH_T64(x) + +/** + * Rotate a 64-bit value by a number of bits to the left. The rotate + * count must reside between 1 and 63. This macro assumes that its + * first argument fits in 64 bits (no extra bit allowed on machines where + * sph_u64 is wider); both arguments may be evaluated + * several times. This macro is defined only if a 64-bit type was detected + * and used for sph_u64. + * + * @param x the value to rotate (of type sph_u64) + * @param n the rotation count (between 1 and 63, inclusive) + */ +#define SPH_ROTL64(x, n) + +/** + * Rotate a 64-bit value by a number of bits to the left. The rotate + * count must reside between 1 and 63. This macro assumes that its + * first argument fits in 64 bits (no extra bit allowed on machines where + * sph_u64 is wider); both arguments may be evaluated + * several times. This macro is defined only if a 64-bit type was detected + * and used for sph_u64. + * + * @param x the value to rotate (of type sph_u64) + * @param n the rotation count (between 1 and 63, inclusive) + */ +#define SPH_ROTR64(x, n) + +/** + * This macro evaluates to inline or an equivalent construction, + * if available on the compilation platform, or to nothing otherwise. This + * is used to declare inline functions, for which the compiler should + * endeavour to include the code directly in the caller. Inline functions + * are typically defined in header files as replacement for macros. + */ +#define SPH_INLINE + +/** + * This macro is defined if the platform has been detected as using + * little-endian convention. This implies that the sph_u32 + * type (and the sph_u64 type also, if it is defined) has + * an exact width (i.e. exactly 32-bit, respectively 64-bit). + */ +#define SPH_LITTLE_ENDIAN + +/** + * This macro is defined if the platform has been detected as using + * big-endian convention. This implies that the sph_u32 + * type (and the sph_u64 type also, if it is defined) has + * an exact width (i.e. exactly 32-bit, respectively 64-bit). + */ +#define SPH_BIG_ENDIAN + +/** + * This macro is defined if 32-bit words (and 64-bit words, if defined) + * can be read from and written to memory efficiently in little-endian + * convention. This is the case for little-endian platforms, and also + * for the big-endian platforms which have special little-endian access + * opcodes (e.g. Ultrasparc). + */ +#define SPH_LITTLE_FAST + +/** + * This macro is defined if 32-bit words (and 64-bit words, if defined) + * can be read from and written to memory efficiently in big-endian + * convention. This is the case for little-endian platforms, and also + * for the little-endian platforms which have special big-endian access + * opcodes. + */ +#define SPH_BIG_FAST + +/** + * On some platforms, this macro is defined to an unsigned integer type + * into which pointer values may be cast. The resulting value can then + * be tested for being a multiple of 2, 4 or 8, indicating an aligned + * pointer for, respectively, 16-bit, 32-bit or 64-bit memory accesses. + */ +#define SPH_UPTR + +/** + * When defined, this macro indicates that unaligned memory accesses + * are possible with only a minor penalty, and thus should be prefered + * over strategies which first copy data to an aligned buffer. + */ +#define SPH_UNALIGNED + +/** + * Byte-swap a 32-bit word (i.e. 0x12345678 becomes + * 0x78563412). This is an inline function which resorts + * to inline assembly on some platforms, for better performance. + * + * @param x the 32-bit value to byte-swap + * @return the byte-swapped value + */ +static inline sph_u32 sph_bswap32(sph_u32 x); + +/** + * Byte-swap a 64-bit word. This is an inline function which resorts + * to inline assembly on some platforms, for better performance. This + * function is defined only if a suitable 64-bit type was found for + * sph_u64 + * + * @param x the 64-bit value to byte-swap + * @return the byte-swapped value + */ +static inline sph_u64 sph_bswap64(sph_u64 x); + +/** + * Decode a 16-bit unsigned value from memory, in little-endian convention + * (least significant byte comes first). + * + * @param src the source address + * @return the decoded value + */ +static inline unsigned sph_dec16le(const void *src); + +/** + * Encode a 16-bit unsigned value into memory, in little-endian convention + * (least significant byte comes first). + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc16le(void *dst, unsigned val); + +/** + * Decode a 16-bit unsigned value from memory, in big-endian convention + * (most significant byte comes first). + * + * @param src the source address + * @return the decoded value + */ +static inline unsigned sph_dec16be(const void *src); + +/** + * Encode a 16-bit unsigned value into memory, in big-endian convention + * (most significant byte comes first). + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc16be(void *dst, unsigned val); + +/** + * Decode a 32-bit unsigned value from memory, in little-endian convention + * (least significant byte comes first). + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u32 sph_dec32le(const void *src); + +/** + * Decode a 32-bit unsigned value from memory, in little-endian convention + * (least significant byte comes first). This function assumes that the + * source address is suitably aligned for a direct access, if the platform + * supports such things; it can thus be marginally faster than the generic + * sph_dec32le() function. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u32 sph_dec32le_aligned(const void *src); + +/** + * Encode a 32-bit unsigned value into memory, in little-endian convention + * (least significant byte comes first). + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc32le(void *dst, sph_u32 val); + +/** + * Encode a 32-bit unsigned value into memory, in little-endian convention + * (least significant byte comes first). This function assumes that the + * destination address is suitably aligned for a direct access, if the + * platform supports such things; it can thus be marginally faster than + * the generic sph_enc32le() function. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc32le_aligned(void *dst, sph_u32 val); + +/** + * Decode a 32-bit unsigned value from memory, in big-endian convention + * (most significant byte comes first). + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u32 sph_dec32be(const void *src); + +/** + * Decode a 32-bit unsigned value from memory, in big-endian convention + * (most significant byte comes first). This function assumes that the + * source address is suitably aligned for a direct access, if the platform + * supports such things; it can thus be marginally faster than the generic + * sph_dec32be() function. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u32 sph_dec32be_aligned(const void *src); + +/** + * Encode a 32-bit unsigned value into memory, in big-endian convention + * (most significant byte comes first). + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc32be(void *dst, sph_u32 val); + +/** + * Encode a 32-bit unsigned value into memory, in big-endian convention + * (most significant byte comes first). This function assumes that the + * destination address is suitably aligned for a direct access, if the + * platform supports such things; it can thus be marginally faster than + * the generic sph_enc32be() function. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc32be_aligned(void *dst, sph_u32 val); + +/** + * Decode a 64-bit unsigned value from memory, in little-endian convention + * (least significant byte comes first). This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u64 sph_dec64le(const void *src); + +/** + * Decode a 64-bit unsigned value from memory, in little-endian convention + * (least significant byte comes first). This function assumes that the + * source address is suitably aligned for a direct access, if the platform + * supports such things; it can thus be marginally faster than the generic + * sph_dec64le() function. This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u64 sph_dec64le_aligned(const void *src); + +/** + * Encode a 64-bit unsigned value into memory, in little-endian convention + * (least significant byte comes first). This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc64le(void *dst, sph_u64 val); + +/** + * Encode a 64-bit unsigned value into memory, in little-endian convention + * (least significant byte comes first). This function assumes that the + * destination address is suitably aligned for a direct access, if the + * platform supports such things; it can thus be marginally faster than + * the generic sph_enc64le() function. This function is defined + * only if a suitable 64-bit type was detected and used for + * sph_u64. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc64le_aligned(void *dst, sph_u64 val); + +/** + * Decode a 64-bit unsigned value from memory, in big-endian convention + * (most significant byte comes first). This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u64 sph_dec64be(const void *src); + +/** + * Decode a 64-bit unsigned value from memory, in big-endian convention + * (most significant byte comes first). This function assumes that the + * source address is suitably aligned for a direct access, if the platform + * supports such things; it can thus be marginally faster than the generic + * sph_dec64be() function. This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param src the source address + * @return the decoded value + */ +static inline sph_u64 sph_dec64be_aligned(const void *src); + +/** + * Encode a 64-bit unsigned value into memory, in big-endian convention + * (most significant byte comes first). This function is defined only + * if a suitable 64-bit type was detected and used for sph_u64. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc64be(void *dst, sph_u64 val); + +/** + * Encode a 64-bit unsigned value into memory, in big-endian convention + * (most significant byte comes first). This function assumes that the + * destination address is suitably aligned for a direct access, if the + * platform supports such things; it can thus be marginally faster than + * the generic sph_enc64be() function. This function is defined + * only if a suitable 64-bit type was detected and used for + * sph_u64. + * + * @param dst the destination buffer + * @param val the value to encode + */ +static inline void sph_enc64be_aligned(void *dst, sph_u64 val); + +#endif + +/* ============== END documentation block for Doxygen ============= */ + +#ifndef DOXYGEN_IGNORE + +/* + * We want to define the types "sph_u32" and "sph_u64" which hold + * unsigned values of at least, respectively, 32 and 64 bits. These + * tests should select appropriate types for most platforms. The + * macro "SPH_64" is defined if the 64-bit is supported. + */ + +#undef SPH_64 +#undef SPH_64_TRUE + +#if defined __STDC__ && __STDC_VERSION__ >= 199901L + +/* + * On C99 implementations, we can use to get an exact 64-bit + * type, if any, or otherwise use a wider type (which must exist, for + * C99 conformance). + */ + +#include + +#ifdef UINT32_MAX +typedef uint32_t sph_u32; +typedef int32_t sph_s32; +#else +typedef uint_fast32_t sph_u32; +typedef int_fast32_t sph_s32; +#endif +#if !SPH_NO_64 +#ifdef UINT64_MAX +typedef uint64_t sph_u64; +typedef int64_t sph_s64; +#else +typedef uint_fast64_t sph_u64; +typedef int_fast64_t sph_s64; +#endif +#endif + +#define SPH_C32(x) ((sph_u32)(x)) +#if !SPH_NO_64 +#define SPH_C64(x) ((sph_u64)(x)) +#define SPH_64 1 +#endif + +#else + +/* + * On non-C99 systems, we use "unsigned int" if it is wide enough, + * "unsigned long" otherwise. This supports all "reasonable" architectures. + * We have to be cautious: pre-C99 preprocessors handle constants + * differently in '#if' expressions. Hence the shifts to test UINT_MAX. + */ + +#if ((UINT_MAX >> 11) >> 11) >= 0x3FF + +typedef unsigned int sph_u32; +typedef int sph_s32; + +#define SPH_C32(x) ((sph_u32)(x ## U)) + +#else + +typedef unsigned long sph_u32; +typedef long sph_s32; + +#define SPH_C32(x) ((sph_u32)(x ## UL)) + +#endif + +#if !SPH_NO_64 + +/* + * We want a 64-bit type. We use "unsigned long" if it is wide enough (as + * is common on 64-bit architectures such as AMD64, Alpha or Sparcv9), + * "unsigned long long" otherwise, if available. We use ULLONG_MAX to + * test whether "unsigned long long" is available; we also know that + * gcc features this type, even if the libc header do not know it. + */ + +#if ((ULONG_MAX >> 31) >> 31) >= 3 + +typedef unsigned long sph_u64; +typedef long sph_s64; + +#define SPH_C64(x) ((sph_u64)(x ## UL)) + +#define SPH_64 1 + +#elif ((ULLONG_MAX >> 31) >> 31) >= 3 || defined __GNUC__ + +typedef unsigned long long sph_u64; +typedef long long sph_s64; + +#define SPH_C64(x) ((sph_u64)(x ## ULL)) + +#define SPH_64 1 + +#else + +/* + * No 64-bit type... + */ + +#endif + +#endif + +#endif + +/* + * If the "unsigned long" type has length 64 bits or more, then this is + * a "true" 64-bit architectures. This is also true with Visual C on + * amd64, even though the "long" type is limited to 32 bits. + */ +#if SPH_64 && (((ULONG_MAX >> 31) >> 31) >= 3 || defined _M_X64) +#define SPH_64_TRUE 1 +#endif + +/* + * Implementation note: some processors have specific opcodes to perform + * a rotation. Recent versions of gcc recognize the expression above and + * use the relevant opcodes, when appropriate. + */ + +#define SPH_T32(x) ((x) & SPH_C32(0xFFFFFFFF)) +#define SPH_ROTL32(x, n) SPH_T32(((x) << (n)) | ((x) >> (32 - (n)))) +#define SPH_ROTR32(x, n) SPH_ROTL32(x, (32 - (n))) + +#if SPH_64 + +#define SPH_T64(x) ((x) & SPH_C64(0xFFFFFFFFFFFFFFFF)) +#define SPH_ROTL64(x, n) SPH_T64(((x) << (n)) | ((x) >> (64 - (n)))) +#define SPH_ROTR64(x, n) SPH_ROTL64(x, (64 - (n))) + +#endif + +#ifndef DOXYGEN_IGNORE +/* + * Define SPH_INLINE to be an "inline" qualifier, if available. We define + * some small macro-like functions which benefit greatly from being inlined. + */ +#if (defined __STDC__ && __STDC_VERSION__ >= 199901L) || defined __GNUC__ +#define SPH_INLINE inline +#elif defined _MSC_VER +#define SPH_INLINE __inline +#else +#define SPH_INLINE +#endif +#endif + +/* + * We define some macros which qualify the architecture. These macros + * may be explicit set externally (e.g. as compiler parameters). The + * code below sets those macros if they are not already defined. + * + * Most macros are boolean, thus evaluate to either zero or non-zero. + * The SPH_UPTR macro is special, in that it evaluates to a C type, + * or is not defined. + * + * SPH_UPTR if defined: unsigned type to cast pointers into + * + * SPH_UNALIGNED non-zero if unaligned accesses are efficient + * SPH_LITTLE_ENDIAN non-zero if architecture is known to be little-endian + * SPH_BIG_ENDIAN non-zero if architecture is known to be big-endian + * SPH_LITTLE_FAST non-zero if little-endian decoding is fast + * SPH_BIG_FAST non-zero if big-endian decoding is fast + * + * If SPH_UPTR is defined, then encoding and decoding of 32-bit and 64-bit + * values will try to be "smart". Either SPH_LITTLE_ENDIAN or SPH_BIG_ENDIAN + * _must_ be non-zero in those situations. The 32-bit and 64-bit types + * _must_ also have an exact width. + * + * SPH_SPARCV9_GCC_32 UltraSPARC-compatible with gcc, 32-bit mode + * SPH_SPARCV9_GCC_64 UltraSPARC-compatible with gcc, 64-bit mode + * SPH_SPARCV9_GCC UltraSPARC-compatible with gcc + * SPH_I386_GCC x86-compatible (32-bit) with gcc + * SPH_I386_MSVC x86-compatible (32-bit) with Microsoft Visual C + * SPH_AMD64_GCC x86-compatible (64-bit) with gcc + * SPH_AMD64_MSVC x86-compatible (64-bit) with Microsoft Visual C + * SPH_PPC32_GCC PowerPC, 32-bit, with gcc + * SPH_PPC64_GCC PowerPC, 64-bit, with gcc + * + * TODO: enhance automatic detection, for more architectures and compilers. + * Endianness is the most important. SPH_UNALIGNED and SPH_UPTR help with + * some very fast functions (e.g. MD4) when using unaligned input data. + * The CPU-specific-with-GCC macros are useful only for inline assembly, + * normally restrained to this header file. + */ + +/* + * 32-bit x86, aka "i386 compatible". + */ +#if defined __i386__ || defined _M_IX86 + +#define SPH_DETECT_UNALIGNED 1 +#define SPH_DETECT_LITTLE_ENDIAN 1 +#define SPH_DETECT_UPTR sph_u32 +#ifdef __GNUC__ +#define SPH_DETECT_I386_GCC 1 +#endif +#ifdef _MSC_VER +#define SPH_DETECT_I386_MSVC 1 +#endif + +/* + * 64-bit x86, hereafter known as "amd64". + */ +#elif defined __x86_64 || defined _M_X64 + +#define SPH_DETECT_UNALIGNED 1 +#define SPH_DETECT_LITTLE_ENDIAN 1 +#define SPH_DETECT_UPTR sph_u64 +#ifdef __GNUC__ +#define SPH_DETECT_AMD64_GCC 1 +#endif +#ifdef _MSC_VER +#define SPH_DETECT_AMD64_MSVC 1 +#endif + +/* + * 64-bit Sparc architecture (implies v9). + */ +#elif ((defined __sparc__ || defined __sparc) && defined __arch64__) \ + || defined __sparcv9 + +#define SPH_DETECT_BIG_ENDIAN 1 +#define SPH_DETECT_UPTR sph_u64 +#ifdef __GNUC__ +#define SPH_DETECT_SPARCV9_GCC_64 1 +#define SPH_DETECT_LITTLE_FAST 1 +#endif + +/* + * 32-bit Sparc. + */ +#elif (defined __sparc__ || defined __sparc) \ + && !(defined __sparcv9 || defined __arch64__) + +#define SPH_DETECT_BIG_ENDIAN 1 +#define SPH_DETECT_UPTR sph_u32 +#if defined __GNUC__ && defined __sparc_v9__ +#define SPH_DETECT_SPARCV9_GCC_32 1 +#define SPH_DETECT_LITTLE_FAST 1 +#endif + +/* + * ARM, little-endian. + */ +#elif defined __arm__ && __ARMEL__ + +#define SPH_DETECT_LITTLE_ENDIAN 1 + +/* + * MIPS, little-endian. + */ +#elif MIPSEL || _MIPSEL || __MIPSEL || __MIPSEL__ + +#define SPH_DETECT_LITTLE_ENDIAN 1 + +/* + * MIPS, big-endian. + */ +#elif MIPSEB || _MIPSEB || __MIPSEB || __MIPSEB__ + +#define SPH_DETECT_BIG_ENDIAN 1 + +/* + * PowerPC. + */ +#elif defined __powerpc__ || defined __POWERPC__ || defined __ppc__ \ + || defined _ARCH_PPC + +/* + * Note: we do not declare cross-endian access to be "fast": even if + * using inline assembly, implementation should still assume that + * keeping the decoded word in a temporary is faster than decoding + * it again. + */ +#if defined __GNUC__ +#if SPH_64_TRUE +#define SPH_DETECT_PPC64_GCC 1 +#else +#define SPH_DETECT_PPC32_GCC 1 +#endif +#endif + +#if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN +#define SPH_DETECT_BIG_ENDIAN 1 +#elif defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN +#define SPH_DETECT_LITTLE_ENDIAN 1 +#endif + +/* + * Itanium, 64-bit. + */ +#elif defined __ia64 || defined __ia64__ \ + || defined __itanium__ || defined _M_IA64 + +#if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN +#define SPH_DETECT_BIG_ENDIAN 1 +#else +#define SPH_DETECT_LITTLE_ENDIAN 1 +#endif +#if defined __LP64__ || defined _LP64 +#define SPH_DETECT_UPTR sph_u64 +#else +#define SPH_DETECT_UPTR sph_u32 +#endif + +#endif + +#if defined SPH_DETECT_SPARCV9_GCC_32 || defined SPH_DETECT_SPARCV9_GCC_64 +#define SPH_DETECT_SPARCV9_GCC 1 +#endif + +#if defined SPH_DETECT_UNALIGNED && !defined SPH_UNALIGNED +#define SPH_UNALIGNED SPH_DETECT_UNALIGNED +#endif +#if defined SPH_DETECT_UPTR && !defined SPH_UPTR +#define SPH_UPTR SPH_DETECT_UPTR +#endif +#if defined SPH_DETECT_LITTLE_ENDIAN && !defined SPH_LITTLE_ENDIAN +#define SPH_LITTLE_ENDIAN SPH_DETECT_LITTLE_ENDIAN +#endif +#if defined SPH_DETECT_BIG_ENDIAN && !defined SPH_BIG_ENDIAN +#define SPH_BIG_ENDIAN SPH_DETECT_BIG_ENDIAN +#endif +#if defined SPH_DETECT_LITTLE_FAST && !defined SPH_LITTLE_FAST +#define SPH_LITTLE_FAST SPH_DETECT_LITTLE_FAST +#endif +#if defined SPH_DETECT_BIG_FAST && !defined SPH_BIG_FAST +#define SPH_BIG_FAST SPH_DETECT_BIG_FAST +#endif +#if defined SPH_DETECT_SPARCV9_GCC_32 && !defined SPH_SPARCV9_GCC_32 +#define SPH_SPARCV9_GCC_32 SPH_DETECT_SPARCV9_GCC_32 +#endif +#if defined SPH_DETECT_SPARCV9_GCC_64 && !defined SPH_SPARCV9_GCC_64 +#define SPH_SPARCV9_GCC_64 SPH_DETECT_SPARCV9_GCC_64 +#endif +#if defined SPH_DETECT_SPARCV9_GCC && !defined SPH_SPARCV9_GCC +#define SPH_SPARCV9_GCC SPH_DETECT_SPARCV9_GCC +#endif +#if defined SPH_DETECT_I386_GCC && !defined SPH_I386_GCC +#define SPH_I386_GCC SPH_DETECT_I386_GCC +#endif +#if defined SPH_DETECT_I386_MSVC && !defined SPH_I386_MSVC +#define SPH_I386_MSVC SPH_DETECT_I386_MSVC +#endif +#if defined SPH_DETECT_AMD64_GCC && !defined SPH_AMD64_GCC +#define SPH_AMD64_GCC SPH_DETECT_AMD64_GCC +#endif +#if defined SPH_DETECT_AMD64_MSVC && !defined SPH_AMD64_MSVC +#define SPH_AMD64_MSVC SPH_DETECT_AMD64_MSVC +#endif +#if defined SPH_DETECT_PPC32_GCC && !defined SPH_PPC32_GCC +#define SPH_PPC32_GCC SPH_DETECT_PPC32_GCC +#endif +#if defined SPH_DETECT_PPC64_GCC && !defined SPH_PPC64_GCC +#define SPH_PPC64_GCC SPH_DETECT_PPC64_GCC +#endif + +#if SPH_LITTLE_ENDIAN && !defined SPH_LITTLE_FAST +#define SPH_LITTLE_FAST 1 +#endif +#if SPH_BIG_ENDIAN && !defined SPH_BIG_FAST +#define SPH_BIG_FAST 1 +#endif + +#if defined SPH_UPTR && !(SPH_LITTLE_ENDIAN || SPH_BIG_ENDIAN) +#error SPH_UPTR defined, but endianness is not known. +#endif + +#if SPH_I386_GCC && !SPH_NO_ASM + +/* + * On x86 32-bit, with gcc, we use the bswapl opcode to byte-swap 32-bit + * values. + */ + +static SPH_INLINE sph_u32 +sph_bswap32(sph_u32 x) +{ + __asm__ __volatile__ ("bswapl %0" : "=r" (x) : "0" (x)); + return x; +} + +#if SPH_64 + +static SPH_INLINE sph_u64 +sph_bswap64(sph_u64 x) +{ + return ((sph_u64)sph_bswap32((sph_u32)x) << 32) + | (sph_u64)sph_bswap32((sph_u32)(x >> 32)); +} + +#endif + +#elif SPH_AMD64_GCC && !SPH_NO_ASM + +/* + * On x86 64-bit, with gcc, we use the bswapl opcode to byte-swap 32-bit + * and 64-bit values. + */ + +static SPH_INLINE sph_u32 +sph_bswap32(sph_u32 x) +{ + __asm__ __volatile__ ("bswapl %0" : "=r" (x) : "0" (x)); + return x; +} + +#if SPH_64 + +static SPH_INLINE sph_u64 +sph_bswap64(sph_u64 x) +{ + __asm__ __volatile__ ("bswapq %0" : "=r" (x) : "0" (x)); + return x; +} + +#endif + +/* + * Disabled code. Apparently, Microsoft Visual C 2005 is smart enough + * to generate proper opcodes for endianness swapping with the pure C + * implementation below. + * + +#elif SPH_I386_MSVC && !SPH_NO_ASM + +static __inline sph_u32 __declspec(naked) __fastcall +sph_bswap32(sph_u32 x) +{ + __asm { + bswap ecx + mov eax,ecx + ret + } +} + +#if SPH_64 + +static SPH_INLINE sph_u64 +sph_bswap64(sph_u64 x) +{ + return ((sph_u64)sph_bswap32((sph_u32)x) << 32) + | (sph_u64)sph_bswap32((sph_u32)(x >> 32)); +} + +#endif + + * + * [end of disabled code] + */ + +#else + +static SPH_INLINE sph_u32 +sph_bswap32(sph_u32 x) +{ + x = SPH_T32((x << 16) | (x >> 16)); + x = ((x & SPH_C32(0xFF00FF00)) >> 8) + | ((x & SPH_C32(0x00FF00FF)) << 8); + return x; +} + +#if SPH_64 + +/** + * Byte-swap a 64-bit value. + * + * @param x the input value + * @return the byte-swapped value + */ +static SPH_INLINE sph_u64 +sph_bswap64(sph_u64 x) +{ + x = SPH_T64((x << 32) | (x >> 32)); + x = ((x & SPH_C64(0xFFFF0000FFFF0000)) >> 16) + | ((x & SPH_C64(0x0000FFFF0000FFFF)) << 16); + x = ((x & SPH_C64(0xFF00FF00FF00FF00)) >> 8) + | ((x & SPH_C64(0x00FF00FF00FF00FF)) << 8); + return x; +} + +#endif + +#endif + +#if SPH_SPARCV9_GCC && !SPH_NO_ASM + +/* + * On UltraSPARC systems, native ordering is big-endian, but it is + * possible to perform little-endian read accesses by specifying the + * address space 0x88 (ASI_PRIMARY_LITTLE). Basically, either we use + * the opcode "lda [%reg]0x88,%dst", where %reg is the register which + * contains the source address and %dst is the destination register, + * or we use "lda [%reg+imm]%asi,%dst", which uses the %asi register + * to get the address space name. The latter format is better since it + * combines an addition and the actual access in a single opcode; but + * it requires the setting (and subsequent resetting) of %asi, which is + * slow. Some operations (i.e. MD5 compression function) combine many + * successive little-endian read accesses, which may share the same + * %asi setting. The macros below contain the appropriate inline + * assembly. + */ + +#define SPH_SPARCV9_SET_ASI \ + sph_u32 sph_sparcv9_asi; \ + __asm__ __volatile__ ( \ + "rd %%asi,%0\n\twr %%g0,0x88,%%asi" : "=r" (sph_sparcv9_asi)); + +#define SPH_SPARCV9_RESET_ASI \ + __asm__ __volatile__ ("wr %%g0,%0,%%asi" : : "r" (sph_sparcv9_asi)); + +#define SPH_SPARCV9_DEC32LE(base, idx) ({ \ + sph_u32 sph_sparcv9_tmp; \ + __asm__ __volatile__ ("lda [%1+" #idx "*4]%%asi,%0" \ + : "=r" (sph_sparcv9_tmp) : "r" (base)); \ + sph_sparcv9_tmp; \ + }) + +#endif + +static SPH_INLINE void +sph_enc16be(void *dst, unsigned val) +{ + ((unsigned char *)dst)[0] = (val >> 8); + ((unsigned char *)dst)[1] = val; +} + +static SPH_INLINE unsigned +sph_dec16be(const void *src) +{ + return ((unsigned)(((const unsigned char *)src)[0]) << 8) + | (unsigned)(((const unsigned char *)src)[1]); +} + +static SPH_INLINE void +sph_enc16le(void *dst, unsigned val) +{ + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = val >> 8; +} + +static SPH_INLINE unsigned +sph_dec16le(const void *src) +{ + return (unsigned)(((const unsigned char *)src)[0]) + | ((unsigned)(((const unsigned char *)src)[1]) << 8); +} + +/** + * Encode a 32-bit value into the provided buffer (big endian convention). + * + * @param dst the destination buffer + * @param val the 32-bit value to encode + */ +static SPH_INLINE void +sph_enc32be(void *dst, sph_u32 val) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_LITTLE_ENDIAN + val = sph_bswap32(val); +#endif + *(sph_u32 *)dst = val; +#else + if (((SPH_UPTR)dst & 3) == 0) { +#if SPH_LITTLE_ENDIAN + val = sph_bswap32(val); +#endif + *(sph_u32 *)dst = val; + } else { + ((unsigned char *)dst)[0] = (val >> 24); + ((unsigned char *)dst)[1] = (val >> 16); + ((unsigned char *)dst)[2] = (val >> 8); + ((unsigned char *)dst)[3] = val; + } +#endif +#else + ((unsigned char *)dst)[0] = (val >> 24); + ((unsigned char *)dst)[1] = (val >> 16); + ((unsigned char *)dst)[2] = (val >> 8); + ((unsigned char *)dst)[3] = val; +#endif +} + +/** + * Encode a 32-bit value into the provided buffer (big endian convention). + * The destination buffer must be properly aligned. + * + * @param dst the destination buffer (32-bit aligned) + * @param val the value to encode + */ +static SPH_INLINE void +sph_enc32be_aligned(void *dst, sph_u32 val) +{ +#if SPH_LITTLE_ENDIAN + *(sph_u32 *)dst = sph_bswap32(val); +#elif SPH_BIG_ENDIAN + *(sph_u32 *)dst = val; +#else + ((unsigned char *)dst)[0] = (val >> 24); + ((unsigned char *)dst)[1] = (val >> 16); + ((unsigned char *)dst)[2] = (val >> 8); + ((unsigned char *)dst)[3] = val; +#endif +} + +/** + * Decode a 32-bit value from the provided buffer (big endian convention). + * + * @param src the source buffer + * @return the decoded value + */ +static SPH_INLINE sph_u32 +sph_dec32be(const void *src) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_LITTLE_ENDIAN + return sph_bswap32(*(const sph_u32 *)src); +#else + return *(const sph_u32 *)src; +#endif +#else + if (((SPH_UPTR)src & 3) == 0) { +#if SPH_LITTLE_ENDIAN + return sph_bswap32(*(const sph_u32 *)src); +#else + return *(const sph_u32 *)src; +#endif + } else { + return ((sph_u32)(((const unsigned char *)src)[0]) << 24) + | ((sph_u32)(((const unsigned char *)src)[1]) << 16) + | ((sph_u32)(((const unsigned char *)src)[2]) << 8) + | (sph_u32)(((const unsigned char *)src)[3]); + } +#endif +#else + return ((sph_u32)(((const unsigned char *)src)[0]) << 24) + | ((sph_u32)(((const unsigned char *)src)[1]) << 16) + | ((sph_u32)(((const unsigned char *)src)[2]) << 8) + | (sph_u32)(((const unsigned char *)src)[3]); +#endif +} + +/** + * Decode a 32-bit value from the provided buffer (big endian convention). + * The source buffer must be properly aligned. + * + * @param src the source buffer (32-bit aligned) + * @return the decoded value + */ +static SPH_INLINE sph_u32 +sph_dec32be_aligned(const void *src) +{ +#if SPH_LITTLE_ENDIAN + return sph_bswap32(*(const sph_u32 *)src); +#elif SPH_BIG_ENDIAN + return *(const sph_u32 *)src; +#else + return ((sph_u32)(((const unsigned char *)src)[0]) << 24) + | ((sph_u32)(((const unsigned char *)src)[1]) << 16) + | ((sph_u32)(((const unsigned char *)src)[2]) << 8) + | (sph_u32)(((const unsigned char *)src)[3]); +#endif +} + +/** + * Encode a 32-bit value into the provided buffer (little endian convention). + * + * @param dst the destination buffer + * @param val the 32-bit value to encode + */ +static SPH_INLINE void +sph_enc32le(void *dst, sph_u32 val) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_BIG_ENDIAN + val = sph_bswap32(val); +#endif + *(sph_u32 *)dst = val; +#else + if (((SPH_UPTR)dst & 3) == 0) { +#if SPH_BIG_ENDIAN + val = sph_bswap32(val); +#endif + *(sph_u32 *)dst = val; + } else { + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); + } +#endif +#else + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); +#endif +} + +/** + * Encode a 32-bit value into the provided buffer (little endian convention). + * The destination buffer must be properly aligned. + * + * @param dst the destination buffer (32-bit aligned) + * @param val the value to encode + */ +static SPH_INLINE void +sph_enc32le_aligned(void *dst, sph_u32 val) +{ +#if SPH_LITTLE_ENDIAN + *(sph_u32 *)dst = val; +#elif SPH_BIG_ENDIAN + *(sph_u32 *)dst = sph_bswap32(val); +#else + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); +#endif +} + +/** + * Decode a 32-bit value from the provided buffer (little endian convention). + * + * @param src the source buffer + * @return the decoded value + */ +static SPH_INLINE sph_u32 +sph_dec32le(const void *src) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_BIG_ENDIAN + return sph_bswap32(*(const sph_u32 *)src); +#else + return *(const sph_u32 *)src; +#endif +#else + if (((SPH_UPTR)src & 3) == 0) { +#if SPH_BIG_ENDIAN +#if SPH_SPARCV9_GCC && !SPH_NO_ASM + sph_u32 tmp; + + /* + * "__volatile__" is needed here because without it, + * gcc-3.4.3 miscompiles the code and performs the + * access before the test on the address, thus triggering + * a bus error... + */ + __asm__ __volatile__ ( + "lda [%1]0x88,%0" : "=r" (tmp) : "r" (src)); + return tmp; +/* + * On PowerPC, this turns out not to be worth the effort: the inline + * assembly makes GCC optimizer uncomfortable, which tends to nullify + * the decoding gains. + * + * For most hash functions, using this inline assembly trick changes + * hashing speed by less than 5% and often _reduces_ it. The biggest + * gains are for MD4 (+11%) and CubeHash (+30%). For all others, it is + * less then 10%. The speed gain on CubeHash is probably due to the + * chronic shortage of registers that CubeHash endures; for the other + * functions, the generic code appears to be efficient enough already. + * +#elif (SPH_PPC32_GCC || SPH_PPC64_GCC) && !SPH_NO_ASM + sph_u32 tmp; + + __asm__ __volatile__ ( + "lwbrx %0,0,%1" : "=r" (tmp) : "r" (src)); + return tmp; + */ +#else + return sph_bswap32(*(const sph_u32 *)src); +#endif +#else + return *(const sph_u32 *)src; +#endif + } else { + return (sph_u32)(((const unsigned char *)src)[0]) + | ((sph_u32)(((const unsigned char *)src)[1]) << 8) + | ((sph_u32)(((const unsigned char *)src)[2]) << 16) + | ((sph_u32)(((const unsigned char *)src)[3]) << 24); + } +#endif +#else + return (sph_u32)(((const unsigned char *)src)[0]) + | ((sph_u32)(((const unsigned char *)src)[1]) << 8) + | ((sph_u32)(((const unsigned char *)src)[2]) << 16) + | ((sph_u32)(((const unsigned char *)src)[3]) << 24); +#endif +} + +/** + * Decode a 32-bit value from the provided buffer (little endian convention). + * The source buffer must be properly aligned. + * + * @param src the source buffer (32-bit aligned) + * @return the decoded value + */ +static SPH_INLINE sph_u32 +sph_dec32le_aligned(const void *src) +{ +#if SPH_LITTLE_ENDIAN + return *(const sph_u32 *)src; +#elif SPH_BIG_ENDIAN +#if SPH_SPARCV9_GCC && !SPH_NO_ASM + sph_u32 tmp; + + __asm__ __volatile__ ("lda [%1]0x88,%0" : "=r" (tmp) : "r" (src)); + return tmp; +/* + * Not worth it generally. + * +#elif (SPH_PPC32_GCC || SPH_PPC64_GCC) && !SPH_NO_ASM + sph_u32 tmp; + + __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (tmp) : "r" (src)); + return tmp; + */ +#else + return sph_bswap32(*(const sph_u32 *)src); +#endif +#else + return (sph_u32)(((const unsigned char *)src)[0]) + | ((sph_u32)(((const unsigned char *)src)[1]) << 8) + | ((sph_u32)(((const unsigned char *)src)[2]) << 16) + | ((sph_u32)(((const unsigned char *)src)[3]) << 24); +#endif +} + +#if SPH_64 + +/** + * Encode a 64-bit value into the provided buffer (big endian convention). + * + * @param dst the destination buffer + * @param val the 64-bit value to encode + */ +static SPH_INLINE void +sph_enc64be(void *dst, sph_u64 val) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_LITTLE_ENDIAN + val = sph_bswap64(val); +#endif + *(sph_u64 *)dst = val; +#else + if (((SPH_UPTR)dst & 7) == 0) { +#if SPH_LITTLE_ENDIAN + val = sph_bswap64(val); +#endif + *(sph_u64 *)dst = val; + } else { + ((unsigned char *)dst)[0] = (val >> 56); + ((unsigned char *)dst)[1] = (val >> 48); + ((unsigned char *)dst)[2] = (val >> 40); + ((unsigned char *)dst)[3] = (val >> 32); + ((unsigned char *)dst)[4] = (val >> 24); + ((unsigned char *)dst)[5] = (val >> 16); + ((unsigned char *)dst)[6] = (val >> 8); + ((unsigned char *)dst)[7] = val; + } +#endif +#else + ((unsigned char *)dst)[0] = (val >> 56); + ((unsigned char *)dst)[1] = (val >> 48); + ((unsigned char *)dst)[2] = (val >> 40); + ((unsigned char *)dst)[3] = (val >> 32); + ((unsigned char *)dst)[4] = (val >> 24); + ((unsigned char *)dst)[5] = (val >> 16); + ((unsigned char *)dst)[6] = (val >> 8); + ((unsigned char *)dst)[7] = val; +#endif +} + +/** + * Encode a 64-bit value into the provided buffer (big endian convention). + * The destination buffer must be properly aligned. + * + * @param dst the destination buffer (64-bit aligned) + * @param val the value to encode + */ +static SPH_INLINE void +sph_enc64be_aligned(void *dst, sph_u64 val) +{ +#if SPH_LITTLE_ENDIAN + *(sph_u64 *)dst = sph_bswap64(val); +#elif SPH_BIG_ENDIAN + *(sph_u64 *)dst = val; +#else + ((unsigned char *)dst)[0] = (val >> 56); + ((unsigned char *)dst)[1] = (val >> 48); + ((unsigned char *)dst)[2] = (val >> 40); + ((unsigned char *)dst)[3] = (val >> 32); + ((unsigned char *)dst)[4] = (val >> 24); + ((unsigned char *)dst)[5] = (val >> 16); + ((unsigned char *)dst)[6] = (val >> 8); + ((unsigned char *)dst)[7] = val; +#endif +} + +/** + * Decode a 64-bit value from the provided buffer (big endian convention). + * + * @param src the source buffer + * @return the decoded value + */ +static SPH_INLINE sph_u64 +sph_dec64be(const void *src) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_LITTLE_ENDIAN + return sph_bswap64(*(const sph_u64 *)src); +#else + return *(const sph_u64 *)src; +#endif +#else + if (((SPH_UPTR)src & 7) == 0) { +#if SPH_LITTLE_ENDIAN + return sph_bswap64(*(const sph_u64 *)src); +#else + return *(const sph_u64 *)src; +#endif + } else { + return ((sph_u64)(((const unsigned char *)src)[0]) << 56) + | ((sph_u64)(((const unsigned char *)src)[1]) << 48) + | ((sph_u64)(((const unsigned char *)src)[2]) << 40) + | ((sph_u64)(((const unsigned char *)src)[3]) << 32) + | ((sph_u64)(((const unsigned char *)src)[4]) << 24) + | ((sph_u64)(((const unsigned char *)src)[5]) << 16) + | ((sph_u64)(((const unsigned char *)src)[6]) << 8) + | (sph_u64)(((const unsigned char *)src)[7]); + } +#endif +#else + return ((sph_u64)(((const unsigned char *)src)[0]) << 56) + | ((sph_u64)(((const unsigned char *)src)[1]) << 48) + | ((sph_u64)(((const unsigned char *)src)[2]) << 40) + | ((sph_u64)(((const unsigned char *)src)[3]) << 32) + | ((sph_u64)(((const unsigned char *)src)[4]) << 24) + | ((sph_u64)(((const unsigned char *)src)[5]) << 16) + | ((sph_u64)(((const unsigned char *)src)[6]) << 8) + | (sph_u64)(((const unsigned char *)src)[7]); +#endif +} + +/** + * Decode a 64-bit value from the provided buffer (big endian convention). + * The source buffer must be properly aligned. + * + * @param src the source buffer (64-bit aligned) + * @return the decoded value + */ +static SPH_INLINE sph_u64 +sph_dec64be_aligned(const void *src) +{ +#if SPH_LITTLE_ENDIAN + return sph_bswap64(*(const sph_u64 *)src); +#elif SPH_BIG_ENDIAN + return *(const sph_u64 *)src; +#else + return ((sph_u64)(((const unsigned char *)src)[0]) << 56) + | ((sph_u64)(((const unsigned char *)src)[1]) << 48) + | ((sph_u64)(((const unsigned char *)src)[2]) << 40) + | ((sph_u64)(((const unsigned char *)src)[3]) << 32) + | ((sph_u64)(((const unsigned char *)src)[4]) << 24) + | ((sph_u64)(((const unsigned char *)src)[5]) << 16) + | ((sph_u64)(((const unsigned char *)src)[6]) << 8) + | (sph_u64)(((const unsigned char *)src)[7]); +#endif +} + +/** + * Encode a 64-bit value into the provided buffer (little endian convention). + * + * @param dst the destination buffer + * @param val the 64-bit value to encode + */ +static SPH_INLINE void +sph_enc64le(void *dst, sph_u64 val) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_BIG_ENDIAN + val = sph_bswap64(val); +#endif + *(sph_u64 *)dst = val; +#else + if (((SPH_UPTR)dst & 7) == 0) { +#if SPH_BIG_ENDIAN + val = sph_bswap64(val); +#endif + *(sph_u64 *)dst = val; + } else { + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); + ((unsigned char *)dst)[4] = (val >> 32); + ((unsigned char *)dst)[5] = (val >> 40); + ((unsigned char *)dst)[6] = (val >> 48); + ((unsigned char *)dst)[7] = (val >> 56); + } +#endif +#else + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); + ((unsigned char *)dst)[4] = (val >> 32); + ((unsigned char *)dst)[5] = (val >> 40); + ((unsigned char *)dst)[6] = (val >> 48); + ((unsigned char *)dst)[7] = (val >> 56); +#endif +} + +/** + * Encode a 64-bit value into the provided buffer (little endian convention). + * The destination buffer must be properly aligned. + * + * @param dst the destination buffer (64-bit aligned) + * @param val the value to encode + */ +static SPH_INLINE void +sph_enc64le_aligned(void *dst, sph_u64 val) +{ +#if SPH_LITTLE_ENDIAN + *(sph_u64 *)dst = val; +#elif SPH_BIG_ENDIAN + *(sph_u64 *)dst = sph_bswap64(val); +#else + ((unsigned char *)dst)[0] = val; + ((unsigned char *)dst)[1] = (val >> 8); + ((unsigned char *)dst)[2] = (val >> 16); + ((unsigned char *)dst)[3] = (val >> 24); + ((unsigned char *)dst)[4] = (val >> 32); + ((unsigned char *)dst)[5] = (val >> 40); + ((unsigned char *)dst)[6] = (val >> 48); + ((unsigned char *)dst)[7] = (val >> 56); +#endif +} + +/** + * Decode a 64-bit value from the provided buffer (little endian convention). + * + * @param src the source buffer + * @return the decoded value + */ +static SPH_INLINE sph_u64 +sph_dec64le(const void *src) +{ +#if defined SPH_UPTR +#if SPH_UNALIGNED +#if SPH_BIG_ENDIAN + return sph_bswap64(*(const sph_u64 *)src); +#else + return *(const sph_u64 *)src; +#endif +#else + if (((SPH_UPTR)src & 7) == 0) { +#if SPH_BIG_ENDIAN +#if SPH_SPARCV9_GCC_64 && !SPH_NO_ASM + sph_u64 tmp; + + __asm__ __volatile__ ( + "ldxa [%1]0x88,%0" : "=r" (tmp) : "r" (src)); + return tmp; +/* + * Not worth it generally. + * +#elif SPH_PPC32_GCC && !SPH_NO_ASM + return (sph_u64)sph_dec32le_aligned(src) + | ((sph_u64)sph_dec32le_aligned( + (const char *)src + 4) << 32); +#elif SPH_PPC64_GCC && !SPH_NO_ASM + sph_u64 tmp; + + __asm__ __volatile__ ( + "ldbrx %0,0,%1" : "=r" (tmp) : "r" (src)); + return tmp; + */ +#else + return sph_bswap64(*(const sph_u64 *)src); +#endif +#else + return *(const sph_u64 *)src; +#endif + } else { + return (sph_u64)(((const unsigned char *)src)[0]) + | ((sph_u64)(((const unsigned char *)src)[1]) << 8) + | ((sph_u64)(((const unsigned char *)src)[2]) << 16) + | ((sph_u64)(((const unsigned char *)src)[3]) << 24) + | ((sph_u64)(((const unsigned char *)src)[4]) << 32) + | ((sph_u64)(((const unsigned char *)src)[5]) << 40) + | ((sph_u64)(((const unsigned char *)src)[6]) << 48) + | ((sph_u64)(((const unsigned char *)src)[7]) << 56); + } +#endif +#else + return (sph_u64)(((const unsigned char *)src)[0]) + | ((sph_u64)(((const unsigned char *)src)[1]) << 8) + | ((sph_u64)(((const unsigned char *)src)[2]) << 16) + | ((sph_u64)(((const unsigned char *)src)[3]) << 24) + | ((sph_u64)(((const unsigned char *)src)[4]) << 32) + | ((sph_u64)(((const unsigned char *)src)[5]) << 40) + | ((sph_u64)(((const unsigned char *)src)[6]) << 48) + | ((sph_u64)(((const unsigned char *)src)[7]) << 56); +#endif +} + +/** + * Decode a 64-bit value from the provided buffer (little endian convention). + * The source buffer must be properly aligned. + * + * @param src the source buffer (64-bit aligned) + * @return the decoded value + */ +static SPH_INLINE sph_u64 +sph_dec64le_aligned(const void *src) +{ +#if SPH_LITTLE_ENDIAN + return *(const sph_u64 *)src; +#elif SPH_BIG_ENDIAN +#if SPH_SPARCV9_GCC_64 && !SPH_NO_ASM + sph_u64 tmp; + + __asm__ __volatile__ ("ldxa [%1]0x88,%0" : "=r" (tmp) : "r" (src)); + return tmp; +/* + * Not worth it generally. + * +#elif SPH_PPC32_GCC && !SPH_NO_ASM + return (sph_u64)sph_dec32le_aligned(src) + | ((sph_u64)sph_dec32le_aligned((const char *)src + 4) << 32); +#elif SPH_PPC64_GCC && !SPH_NO_ASM + sph_u64 tmp; + + __asm__ __volatile__ ("ldbrx %0,0,%1" : "=r" (tmp) : "r" (src)); + return tmp; + */ +#else + return sph_bswap64(*(const sph_u64 *)src); +#endif +#else + return (sph_u64)(((const unsigned char *)src)[0]) + | ((sph_u64)(((const unsigned char *)src)[1]) << 8) + | ((sph_u64)(((const unsigned char *)src)[2]) << 16) + | ((sph_u64)(((const unsigned char *)src)[3]) << 24) + | ((sph_u64)(((const unsigned char *)src)[4]) << 32) + | ((sph_u64)(((const unsigned char *)src)[5]) << 40) + | ((sph_u64)(((const unsigned char *)src)[6]) << 48) + | ((sph_u64)(((const unsigned char *)src)[7]) << 56); +#endif +} + +#endif + +#endif /* Doxygen excluded block */ + +#endif diff --git a/src/spork.cpp b/src/spork.cpp new file mode 100644 index 0000000..e39fd2a --- /dev/null +++ b/src/spork.cpp @@ -0,0 +1,230 @@ +// Copyright (c) 2015 The SONO developers +// Copyright (c) 2009-2012 The Darkcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + + +#include "bignum.h" +#include "sync.h" +#include "net.h" +#include "key.h" +#include "util.h" +#include "script.h" +#include "base58.h" +#include "protocol.h" +#include "spork.h" +#include "main.h" +#include + +using namespace std; +using namespace boost; + +class CSporkMessage; +class CSporkManager; + +std::map mapSporks; +std::map mapSporksActive; +CSporkManager sporkManager; + +void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) +{ + if(fLiteMode) return; //disable all darksend/masternode related functionality + + if (strCommand == "spork") + { + //LogPrintf("ProcessSpork::spork\n"); + CDataStream vMsg(vRecv); + CSporkMessage spork; + vRecv >> spork; + + if(pindexBest == NULL) return; + + uint256 hash = spork.GetHash(); + if(mapSporks.count(hash) && mapSporksActive.count(spork.nSporkID)) { + if(mapSporksActive[spork.nSporkID].nTimeSigned >= spork.nTimeSigned){ + if(fDebug) LogPrintf("spork - seen %s block %d \n", hash.ToString().c_str(), pindexBest->nHeight); + return; + } else { + if(fDebug) LogPrintf("spork - got updated spork %s block %d \n", hash.ToString().c_str(), pindexBest->nHeight); + } + } + + LogPrintf("spork - new %s ID %d Time %d bestHeight %d\n", hash.ToString().c_str(), spork.nSporkID, spork.nValue, pindexBest->nHeight); + + if(!sporkManager.CheckSignature(spork)){ + LogPrintf("spork - invalid signature\n"); + Misbehaving(pfrom->GetId(), 100); + return; + } + + mapSporks[hash] = spork; + mapSporksActive[spork.nSporkID] = spork; + sporkManager.Relay(spork); + + //does a task if needed + ExecuteSpork(spork.nSporkID, spork.nValue); + } + if (strCommand == "getsporks") + { + std::map::iterator it = mapSporksActive.begin(); + + while(it != mapSporksActive.end()) { + pfrom->PushMessage("spork", it->second); + it++; + } + } + +} + +// grab the spork, otherwise say it's off +bool IsSporkActive(int nSporkID) +{ + int64_t r = 0; + + if(mapSporksActive.count(nSporkID)){ + r = mapSporksActive[nSporkID].nValue; + } else { + if(nSporkID == SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT) r = SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT; + if(nSporkID == SPORK_2_MAX_VALUE) r = SPORK_2_MAX_VALUE_DEFAULT; + if(nSporkID == SPORK_3_REPLAY_BLOCKS) r = SPORK_3_REPLAY_BLOCKS_DEFAULT; + + if(r == 0 && fDebug) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID); + } + if(r == 0) r = 4070908800; //return 2099-1-1 by default + + return r < GetTime(); +} + +// grab the value of the spork on the network, or the default +int GetSporkValue(int nSporkID) +{ + int r = 0; + + if(mapSporksActive.count(nSporkID)){ + r = mapSporksActive[nSporkID].nValue; + } else { + if(nSporkID == SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT) r = SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT; + if(nSporkID == SPORK_2_MAX_VALUE) r = SPORK_2_MAX_VALUE_DEFAULT; + if(nSporkID == SPORK_3_REPLAY_BLOCKS) r = SPORK_3_REPLAY_BLOCKS_DEFAULT; + + if(r == 0 && fDebug) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID); + } + + return r; +} + +void ExecuteSpork(int nSporkID, int nValue) +{ + //replay and process blocks (to sync to the longest chain after disabling sporks) + //if(nSporkID == SPORK_3_REPLAY_BLOCKS){ + //DisconnectBlocksAndReprocess(nValue); + //} +} + + +bool CSporkManager::CheckSignature(CSporkMessage& spork) +{ + //note: need to investigate why this is failing + std::string strMessage = boost::lexical_cast(spork.nSporkID) + boost::lexical_cast(spork.nValue) + boost::lexical_cast(spork.nTimeSigned); + std::string strPubKey = strMainPubKey; + CPubKey pubkey(ParseHex(strPubKey)); + + std::string errorMessage = ""; + if(!darkSendSigner.VerifyMessage(pubkey, spork.vchSig, strMessage, errorMessage)){ + return false; + } + + return true; +} + +bool CSporkManager::Sign(CSporkMessage& spork) +{ + std::string strMessage = boost::lexical_cast(spork.nSporkID) + boost::lexical_cast(spork.nValue) + boost::lexical_cast(spork.nTimeSigned); + + CKey key2; + CPubKey pubkey2; + std::string errorMessage = ""; + + if(!darkSendSigner.SetKey(strMasterPrivKey, errorMessage, key2, pubkey2)) + { + LogPrintf("CMasternodePayments::Sign - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage.c_str()); + return false; + } + + if(!darkSendSigner.SignMessage(strMessage, errorMessage, spork.vchSig, key2)) { + LogPrintf("CMasternodePayments::Sign - Sign message failed"); + return false; + } + + if(!darkSendSigner.VerifyMessage(pubkey2, spork.vchSig, strMessage, errorMessage)) { + LogPrintf("CMasternodePayments::Sign - Verify message failed"); + return false; + } + + return true; +} + +bool CSporkManager::UpdateSpork(int nSporkID, int64_t nValue) +{ + + CSporkMessage msg; + msg.nSporkID = nSporkID; + msg.nValue = nValue; + msg.nTimeSigned = GetTime(); + + if(Sign(msg)){ + Relay(msg); + mapSporks[msg.GetHash()] = msg; + mapSporksActive[nSporkID] = msg; + return true; + } + + return false; +} + +void CSporkManager::Relay(CSporkMessage& msg) +{ + CInv inv(MSG_SPORK, msg.GetHash()); + + vector vInv; + vInv.push_back(inv); + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes){ + pnode->PushMessage("inv", vInv); + } +} + +bool CSporkManager::SetPrivKey(std::string strPrivKey) +{ + CSporkMessage msg; + + // Test signing successful, proceed + strMasterPrivKey = strPrivKey; + + Sign(msg); + + if(CheckSignature(msg)){ + LogPrintf("CSporkManager::SetPrivKey - Successfully initialized as spork signer\n"); + return true; + } else { + return false; + } +} + +int CSporkManager::GetSporkIDByName(std::string strName) +{ + if(strName == "SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT") return SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT; + if(strName == "SPORK_2_MAX_VALUE") return SPORK_2_MAX_VALUE; + if(strName == "SPORK_3_REPLAY_BLOCKS") return SPORK_3_REPLAY_BLOCKS; + + return -1; +} + +std::string CSporkManager::GetSporkNameByID(int id) +{ + if(id == SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT) return "SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT"; + if(id == SPORK_2_MAX_VALUE) return "SPORK_2_MAX_VALUE"; + if(id == SPORK_3_REPLAY_BLOCKS) return "SPORK_3_REPLAY_BLOCKS"; + + return "Unknown"; +} diff --git a/src/spork.h b/src/spork.h new file mode 100644 index 0000000..15a2e5d --- /dev/null +++ b/src/spork.h @@ -0,0 +1,113 @@ +// Copyright (c) 2015 The SONO developers +// Copyright (c) 2009-2012 The Darkcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef SPORK_H +#define SPORK_H + +#include "bignum.h" +#include "sync.h" +#include "net.h" +#include "key.h" + +#include "util.h" +#include "script.h" +#include "base58.h" +#include "main.h" + +using namespace std; +using namespace boost; + +// Don't ever reuse these IDs for other sporks +#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT 10000 +#define SPORK_2_MAX_VALUE 10002 +#define SPORK_3_REPLAY_BLOCKS 10003 +#define SPORK_4_NOTUSED 10004 + + +#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT 2428537599 //2015-4-8 23:59:59 GMT +#define SPORK_2_MAX_VALUE_DEFAULT 10000 +#define SPORK_3_REPLAY_BLOCKS_DEFAULT 0 +#define SPORK_4_RECONVERGE_DEFAULT 1420070400 //2047-1-1 + +class CSporkMessage; +class CSporkManager; + +#include "bignum.h" +#include "net.h" +#include "key.h" +#include "util.h" +#include "protocol.h" +#include "darksend.h" +#include + +using namespace std; +using namespace boost; + +extern std::map mapSporks; +extern std::map mapSporksActive; +extern CSporkManager sporkManager; + +void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); +int GetSporkValue(int nSporkID); +bool IsSporkActive(int nSporkID); +void ExecuteSpork(int nSporkID, int nValue); + +// +// Spork Class +// Keeps track of all of the network spork settings +// + +class CSporkMessage +{ +public: + std::vector vchSig; + int nSporkID; + int64_t nValue; + int64_t nTimeSigned; + + uint256 GetHash(){ + uint256 n = Hash(BEGIN(nSporkID), END(nTimeSigned)); + return n; + } + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + unsigned int nSerSize = 0; + READWRITE(nSporkID); + READWRITE(nValue); + READWRITE(nTimeSigned); + READWRITE(vchSig); + } +}; + + +class CSporkManager +{ +private: + std::vector vchSig; + + std::string strMasterPrivKey; + std::string strTestPubKey; + std::string strMainPubKey; + +public: + + CSporkManager() { + strMainPubKey = "04e57adfbcdfad7c8131a7c77323fab6c1fdd44b0bdc2f969142d62b33246f37493babd68265e9e277a24fe92544596b5dad2df74763cc75c20bfde6e95603e714"; + strTestPubKey = "04e57adfbcdfad7c8131a7c77323fab6c1fdd44b0bdc2f969142d62b33246f37493babd68265e9e277a24fe92544596b5dad2df74763cc75c20bfde6e95603e714"; + } + + std::string GetSporkNameByID(int id); + int GetSporkIDByName(std::string strName); + bool UpdateSpork(int nSporkID, int64_t nValue); + bool SetPrivKey(std::string strPrivKey); + bool CheckSignature(CSporkMessage& spork); + bool Sign(CSporkMessage& spork); + void Relay(CSporkMessage& msg); + +}; + +#endif diff --git a/src/stealth.cpp b/src/stealth.cpp new file mode 100644 index 0000000..eabd853 --- /dev/null +++ b/src/stealth.cpp @@ -0,0 +1,682 @@ +// Copyright (c) 2014 The ShadowCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. + +#include "stealth.h" +#include "base58.h" + + +#include +#include +#include +#include + +const uint8_t stealth_version_byte = 0x1c; + + +bool CStealthAddress::SetEncoded(const std::string& encodedAddress) +{ + data_chunk raw; + + if (!DecodeBase58(encodedAddress, raw)) + { + if (fDebug) + printf("CStealthAddress::SetEncoded DecodeBase58 falied.\n"); + return false; + }; + + if (!VerifyChecksum(raw)) + { + if (fDebug) + printf("CStealthAddress::SetEncoded verify_checksum falied.\n"); + return false; + }; + + if (raw.size() < 1 + 1 + 33 + 1 + 33 + 1 + 1 + 4) + { + if (fDebug) + printf("CStealthAddress::SetEncoded() too few bytes provided.\n"); + return false; + }; + + + uint8_t* p = &raw[0]; + uint8_t version = *p++; + + if (version != stealth_version_byte) + { + printf("CStealthAddress::SetEncoded version mismatch 0x%x != 0x%x.\n", version, stealth_version_byte); + return false; + }; + + options = *p++; + + scan_pubkey.resize(33); + memcpy(&scan_pubkey[0], p, 33); + p += 33; + //uint8_t spend_pubkeys = *p++; + p++; + + spend_pubkey.resize(33); + memcpy(&spend_pubkey[0], p, 33); + + return true; +}; + +std::string CStealthAddress::Encoded() const +{ + // https://wiki.unsystem.net/index.php/DarkWallet/Stealth#Address_format + // [version] [options] [scan_key] [N] ... [Nsigs] [prefix_length] ... + + data_chunk raw; + raw.push_back(stealth_version_byte); + + raw.push_back(options); + + raw.insert(raw.end(), scan_pubkey.begin(), scan_pubkey.end()); + raw.push_back(1); // number of spend pubkeys + raw.insert(raw.end(), spend_pubkey.begin(), spend_pubkey.end()); + raw.push_back(0); // number of signatures + raw.push_back(0); // ? + + AppendChecksum(raw); + + return EncodeBase58(raw); +}; + + +uint32_t BitcoinChecksum(uint8_t* p, uint32_t nBytes) +{ + if (!p || nBytes == 0) + return 0; + + uint8_t hash1[32]; + SHA256(p, nBytes, (uint8_t*)hash1); + uint8_t hash2[32]; + SHA256((uint8_t*)hash1, sizeof(hash1), (uint8_t*)hash2); + + // -- checksum is the 1st 4 bytes of the hash + uint32_t checksum = from_little_endian(&hash2[0]); + + return checksum; +}; + +void AppendChecksum(data_chunk& data) +{ + uint32_t checksum = BitcoinChecksum(&data[0], data.size()); + + // -- to_little_endian + std::vector tmp(4); + + //memcpy(&tmp[0], &checksum, 4); + for (int i = 0; i < 4; ++i) + { + tmp[i] = checksum & 0xFF; + checksum >>= 8; + }; + + data.insert(data.end(), tmp.begin(), tmp.end()); +}; + +bool VerifyChecksum(const data_chunk& data) +{ + if (data.size() < 4) + return false; + + uint32_t checksum = from_little_endian(data.end() - 4); + + return BitcoinChecksum((uint8_t*)&data[0], data.size()-4) == checksum; +}; + + +int GenerateRandomSecret(ec_secret& out) +{ + RandAddSeedPerfmon(); + + static uint256 max("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140"); + static uint256 min(16000); // increase? min valid key is 1 + + uint256 test; + + int i; + // -- check max, try max 32 times + for (i = 0; i < 32; ++i) + { + RAND_bytes((unsigned char*) test.begin(), 32); + if (test > min && test < max) + { + memcpy(&out.e[0], test.begin(), 32); + break; + }; + }; + + if (i > 31) + { + printf("Error: GenerateRandomSecret failed to generate a valid key.\n"); + return 1; + }; + + return 0; +}; + +int SecretToPublicKey(const ec_secret& secret, ec_point& out) +{ + // -- public key = private * G + int rv = 0; + + EC_GROUP *ecgrp = EC_GROUP_new_by_curve_name(NID_secp256k1); + + if (!ecgrp) + { + printf("SecretToPublicKey(): EC_GROUP_new_by_curve_name failed.\n"); + return 1; + }; + + BIGNUM* bnIn = BN_bin2bn(&secret.e[0], ec_secret_size, BN_new()); + if (!bnIn) + { + EC_GROUP_free(ecgrp); + printf("SecretToPublicKey(): BN_bin2bn failed\n"); + return 1; + }; + + EC_POINT* pub = EC_POINT_new(ecgrp); + + + EC_POINT_mul(ecgrp, pub, bnIn, NULL, NULL, NULL); + + BIGNUM* bnOut = EC_POINT_point2bn(ecgrp, pub, POINT_CONVERSION_COMPRESSED, BN_new(), NULL); + if (!bnOut) + { + printf("SecretToPublicKey(): point2bn failed\n"); + rv = 1; + } else + { + out.resize(ec_compressed_size); + if (BN_num_bytes(bnOut) != (int) ec_compressed_size + || BN_bn2bin(bnOut, &out[0]) != (int) ec_compressed_size) + { + printf("SecretToPublicKey(): bnOut incorrect length.\n"); + rv = 1; + }; + + BN_free(bnOut); + }; + + EC_GROUP_free(ecgrp); + BN_free(bnIn); + EC_POINT_free(pub); + + return rv; +}; + + +int StealthSecret(ec_secret& secret, ec_point& pubkey, const ec_point& pkSpend, ec_secret& sharedSOut, ec_point& pkOut) +{ + /* + + send: + secret = ephem_secret, pubkey = scan_pubkey + + receive: + secret = scan_secret, pubkey = ephem_pubkey + c = H(dP) + + Q = public scan key (EC point, 33 bytes) + d = private scan key (integer, 32 bytes) + R = public spend key + f = private spend key + + Q = dG + R = fG + + Sender (has Q and R, not d or f): + + P = eG + + c = H(eQ) = H(dP) + R' = R + cG + + + Recipient gets R' and P + + test 0 and infinity? + */ + + int rv = 0; + std::vector vchOutQ; + + BN_CTX* bnCtx = NULL; + BIGNUM* bnEphem = NULL; + BIGNUM* bnQ = NULL; + EC_POINT* Q = NULL; + BIGNUM* bnOutQ = NULL; + BIGNUM* bnc = NULL; + EC_POINT* C = NULL; + BIGNUM* bnR = NULL; + EC_POINT* R = NULL; + EC_POINT* Rout = NULL; + BIGNUM* bnOutR = NULL; + + EC_GROUP* ecgrp = EC_GROUP_new_by_curve_name(NID_secp256k1); + + if (!ecgrp) + { + printf("StealthSecret(): EC_GROUP_new_by_curve_name failed.\n"); + return 1; + }; + + if (!(bnCtx = BN_CTX_new())) + { + printf("StealthSecret(): BN_CTX_new failed.\n"); + rv = 1; + goto End; + }; + + if (!(bnEphem = BN_bin2bn(&secret.e[0], ec_secret_size, BN_new()))) + { + printf("StealthSecret(): bnEphem BN_bin2bn failed.\n"); + rv = 1; + goto End; + }; + + if (!(bnQ = BN_bin2bn(&pubkey[0], pubkey.size(), BN_new()))) + { + printf("StealthSecret(): bnQ BN_bin2bn failed\n"); + rv = 1; + goto End; + }; + + if (!(Q = EC_POINT_bn2point(ecgrp, bnQ, NULL, bnCtx))) + { + printf("StealthSecret(): Q EC_POINT_bn2point failed\n"); + rv = 1; + goto End; + }; + + // -- eQ + // EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); + // EC_POINT_mul calculates the value generator * n + q * m and stores the result in r. The value n may be NULL in which case the result is just q * m. + if (!EC_POINT_mul(ecgrp, Q, NULL, Q, bnEphem, bnCtx)) + { + printf("StealthSecret(): eQ EC_POINT_mul failed\n"); + rv = 1; + goto End; + }; + + if (!(bnOutQ = EC_POINT_point2bn(ecgrp, Q, POINT_CONVERSION_COMPRESSED, BN_new(), bnCtx))) + { + printf("StealthSecret(): Q EC_POINT_bn2point failed\n"); + rv = 1; + goto End; + }; + + + vchOutQ.resize(ec_compressed_size); + if (BN_num_bytes(bnOutQ) != (int) ec_compressed_size + || BN_bn2bin(bnOutQ, &vchOutQ[0]) != (int) ec_compressed_size) + { + printf("StealthSecret(): bnOutQ incorrect length.\n"); + rv = 1; + goto End; + }; + + SHA256(&vchOutQ[0], vchOutQ.size(), &sharedSOut.e[0]); + + if (!(bnc = BN_bin2bn(&sharedSOut.e[0], ec_secret_size, BN_new()))) + { + printf("StealthSecret(): BN_bin2bn failed\n"); + rv = 1; + goto End; + }; + + // -- cG + if (!(C = EC_POINT_new(ecgrp))) + { + printf("StealthSecret(): C EC_POINT_new failed\n"); + rv = 1; + goto End; + }; + + if (!EC_POINT_mul(ecgrp, C, bnc, NULL, NULL, bnCtx)) + { + printf("StealthSecret(): C EC_POINT_mul failed\n"); + rv = 1; + goto End; + }; + + if (!(bnR = BN_bin2bn(&pkSpend[0], pkSpend.size(), BN_new()))) + { + printf("StealthSecret(): bnR BN_bin2bn failed\n"); + rv = 1; + goto End; + }; + + + if (!(R = EC_POINT_bn2point(ecgrp, bnR, NULL, bnCtx))) + { + printf("StealthSecret(): R EC_POINT_bn2point failed\n"); + rv = 1; + goto End; + }; + + if (!EC_POINT_mul(ecgrp, C, bnc, NULL, NULL, bnCtx)) + { + printf("StealthSecret(): C EC_POINT_mul failed\n"); + rv = 1; + goto End; + }; + + if (!(Rout = EC_POINT_new(ecgrp))) + { + printf("StealthSecret(): Rout EC_POINT_new failed\n"); + rv = 1; + goto End; + }; + + if (!EC_POINT_add(ecgrp, Rout, R, C, bnCtx)) + { + printf("StealthSecret(): Rout EC_POINT_add failed\n"); + rv = 1; + goto End; + }; + + if (!(bnOutR = EC_POINT_point2bn(ecgrp, Rout, POINT_CONVERSION_COMPRESSED, BN_new(), bnCtx))) + { + printf("StealthSecret(): Rout EC_POINT_bn2point failed\n"); + rv = 1; + goto End; + }; + + + pkOut.resize(ec_compressed_size); + if (BN_num_bytes(bnOutR) != (int) ec_compressed_size + || BN_bn2bin(bnOutR, &pkOut[0]) != (int) ec_compressed_size) + { + printf("StealthSecret(): pkOut incorrect length.\n"); + rv = 1; + goto End; + }; + + End: + if (bnOutR) BN_free(bnOutR); + if (Rout) EC_POINT_free(Rout); + if (R) EC_POINT_free(R); + if (bnR) BN_free(bnR); + if (C) EC_POINT_free(C); + if (bnc) BN_free(bnc); + if (bnOutQ) BN_free(bnOutQ); + if (Q) EC_POINT_free(Q); + if (bnQ) BN_free(bnQ); + if (bnEphem) BN_free(bnEphem); + if (bnCtx) BN_CTX_free(bnCtx); + EC_GROUP_free(ecgrp); + + return rv; +}; + + +int StealthSecretSpend(ec_secret& scanSecret, ec_point& ephemPubkey, ec_secret& spendSecret, ec_secret& secretOut) +{ + /* + + c = H(dP) + R' = R + cG [without decrypting wallet] + = (f + c)G [after decryption of wallet] + Remember: mod curve.order, pad with 0x00s where necessary? + */ + + int rv = 0; + std::vector vchOutP; + + BN_CTX* bnCtx = NULL; + BIGNUM* bnScanSecret = NULL; + BIGNUM* bnP = NULL; + EC_POINT* P = NULL; + BIGNUM* bnOutP = NULL; + BIGNUM* bnc = NULL; + BIGNUM* bnOrder = NULL; + BIGNUM* bnSpend = NULL; + + EC_GROUP* ecgrp = EC_GROUP_new_by_curve_name(NID_secp256k1); + + if (!ecgrp) + { + printf("StealthSecretSpend(): EC_GROUP_new_by_curve_name failed.\n"); + return 1; + }; + + if (!(bnCtx = BN_CTX_new())) + { + printf("StealthSecretSpend(): BN_CTX_new failed.\n"); + rv = 1; + goto End; + }; + + if (!(bnScanSecret = BN_bin2bn(&scanSecret.e[0], ec_secret_size, BN_new()))) + { + printf("StealthSecretSpend(): bnScanSecret BN_bin2bn failed.\n"); + rv = 1; + goto End; + }; + + if (!(bnP = BN_bin2bn(&ephemPubkey[0], ephemPubkey.size(), BN_new()))) + { + printf("StealthSecretSpend(): bnP BN_bin2bn failed\n"); + rv = 1; + goto End; + }; + + if (!(P = EC_POINT_bn2point(ecgrp, bnP, NULL, bnCtx))) + { + printf("StealthSecretSpend(): P EC_POINT_bn2point failed\n"); + rv = 1; + goto End; + }; + + // -- dP + if (!EC_POINT_mul(ecgrp, P, NULL, P, bnScanSecret, bnCtx)) + { + printf("StealthSecretSpend(): dP EC_POINT_mul failed\n"); + rv = 1; + goto End; + }; + + if (!(bnOutP = EC_POINT_point2bn(ecgrp, P, POINT_CONVERSION_COMPRESSED, BN_new(), bnCtx))) + { + printf("StealthSecretSpend(): P EC_POINT_bn2point failed\n"); + rv = 1; + goto End; + }; + + + vchOutP.resize(ec_compressed_size); + if (BN_num_bytes(bnOutP) != (int) ec_compressed_size + || BN_bn2bin(bnOutP, &vchOutP[0]) != (int) ec_compressed_size) + { + printf("StealthSecretSpend(): bnOutP incorrect length.\n"); + rv = 1; + goto End; + }; + + uint8_t hash1[32]; + SHA256(&vchOutP[0], vchOutP.size(), (uint8_t*)hash1); + + + if (!(bnc = BN_bin2bn(&hash1[0], 32, BN_new()))) + { + printf("StealthSecretSpend(): BN_bin2bn failed\n"); + rv = 1; + goto End; + }; + + if (!(bnOrder = BN_new()) + || !EC_GROUP_get_order(ecgrp, bnOrder, bnCtx)) + { + printf("StealthSecretSpend(): EC_GROUP_get_order failed\n"); + rv = 1; + goto End; + }; + + if (!(bnSpend = BN_bin2bn(&spendSecret.e[0], ec_secret_size, BN_new()))) + { + printf("StealthSecretSpend(): bnSpend BN_bin2bn failed.\n"); + rv = 1; + goto End; + }; + + //if (!BN_add(r, a, b)) return 0; + //return BN_nnmod(r, r, m, ctx); + if (!BN_mod_add(bnSpend, bnSpend, bnc, bnOrder, bnCtx)) + { + printf("StealthSecretSpend(): bnSpend BN_mod_add failed.\n"); + rv = 1; + goto End; + }; + + if (BN_is_zero(bnSpend)) // possible? + { + printf("StealthSecretSpend(): bnSpend is zero.\n"); + rv = 1; + goto End; + }; + + if (BN_num_bytes(bnSpend) != (int) ec_secret_size + || BN_bn2bin(bnSpend, &secretOut.e[0]) != (int) ec_secret_size) + { + printf("StealthSecretSpend(): bnSpend incorrect length.\n"); + rv = 1; + goto End; + }; + + End: + if (bnSpend) BN_free(bnSpend); + if (bnOrder) BN_free(bnOrder); + if (bnc) BN_free(bnc); + if (bnOutP) BN_free(bnOutP); + if (P) EC_POINT_free(P); + if (bnP) BN_free(bnP); + if (bnScanSecret) BN_free(bnScanSecret); + if (bnCtx) BN_CTX_free(bnCtx); + EC_GROUP_free(ecgrp); + + return rv; +}; + + +int StealthSharedToSecretSpend(ec_secret& sharedS, ec_secret& spendSecret, ec_secret& secretOut) +{ + + int rv = 0; + std::vector vchOutP; + + BN_CTX* bnCtx = NULL; + BIGNUM* bnc = NULL; + BIGNUM* bnOrder = NULL; + BIGNUM* bnSpend = NULL; + + EC_GROUP* ecgrp = EC_GROUP_new_by_curve_name(NID_secp256k1); + + if (!ecgrp) + { + printf("StealthSecretSpend(): EC_GROUP_new_by_curve_name failed.\n"); + return 1; + }; + + if (!(bnCtx = BN_CTX_new())) + { + printf("StealthSecretSpend(): BN_CTX_new failed.\n"); + rv = 1; + goto End; + }; + + if (!(bnc = BN_bin2bn(&sharedS.e[0], ec_secret_size, BN_new()))) + { + printf("StealthSecretSpend(): BN_bin2bn failed\n"); + rv = 1; + goto End; + }; + + if (!(bnOrder = BN_new()) + || !EC_GROUP_get_order(ecgrp, bnOrder, bnCtx)) + { + printf("StealthSecretSpend(): EC_GROUP_get_order failed\n"); + rv = 1; + goto End; + }; + + if (!(bnSpend = BN_bin2bn(&spendSecret.e[0], ec_secret_size, BN_new()))) + { + printf("StealthSecretSpend(): bnSpend BN_bin2bn failed.\n"); + rv = 1; + goto End; + }; + + //if (!BN_add(r, a, b)) return 0; + //return BN_nnmod(r, r, m, ctx); + if (!BN_mod_add(bnSpend, bnSpend, bnc, bnOrder, bnCtx)) + { + printf("StealthSecretSpend(): bnSpend BN_mod_add failed.\n"); + rv = 1; + goto End; + }; + + if (BN_is_zero(bnSpend)) // possible? + { + printf("StealthSecretSpend(): bnSpend is zero.\n"); + rv = 1; + goto End; + }; + + if (BN_num_bytes(bnSpend) != (int) ec_secret_size + || BN_bn2bin(bnSpend, &secretOut.e[0]) != (int) ec_secret_size) + { + printf("StealthSecretSpend(): bnSpend incorrect length.\n"); + rv = 1; + goto End; + }; + + End: + if (bnSpend) BN_free(bnSpend); + if (bnOrder) BN_free(bnOrder); + if (bnc) BN_free(bnc); + if (bnCtx) BN_CTX_free(bnCtx); + EC_GROUP_free(ecgrp); + + return rv; +}; + +bool IsStealthAddress(const std::string& encodedAddress) +{ + data_chunk raw; + + if (!DecodeBase58(encodedAddress, raw)) + { + //printf("IsStealthAddress DecodeBase58 falied.\n"); + return false; + }; + + if (!VerifyChecksum(raw)) + { + //printf("IsStealthAddress verify_checksum falied.\n"); + return false; + }; + + if (raw.size() < 1 + 1 + 33 + 1 + 33 + 1 + 1 + 4) + { + //printf("IsStealthAddress too few bytes provided.\n"); + return false; + }; + + + uint8_t* p = &raw[0]; + uint8_t version = *p++; + + if (version != stealth_version_byte) + { + //printf("IsStealthAddress version mismatch 0x%x != 0x%x.\n", version, stealth_version_byte); + return false; + }; + + return true; +}; diff --git a/src/stealth.h b/src/stealth.h new file mode 100644 index 0000000..c4d104c --- /dev/null +++ b/src/stealth.h @@ -0,0 +1,119 @@ +// Copyright (c) 2014 The ShadowCoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_STEALTH_H +#define BITCOIN_STEALTH_H + +#include "util.h" +#include "serialize.h" + +#include +#include +#include +#include + + +typedef std::vector data_chunk; + +const size_t ec_secret_size = 32; +const size_t ec_compressed_size = 33; +const size_t ec_uncompressed_size = 65; + +typedef struct ec_secret { uint8_t e[ec_secret_size]; } ec_secret; +typedef data_chunk ec_point; + +typedef uint32_t stealth_bitfield; + +struct stealth_prefix +{ + uint8_t number_bits; + stealth_bitfield bitfield; +}; + +template +T from_big_endian(Iterator in) +{ + //VERIFY_UNSIGNED(T); + T out = 0; + size_t i = sizeof(T); + while (0 < i) + out |= static_cast(*in++) << (8 * --i); + return out; +} + +template +T from_little_endian(Iterator in) +{ + //VERIFY_UNSIGNED(T); + T out = 0; + size_t i = 0; + while (i < sizeof(T)) + out |= static_cast(*in++) << (8 * i++); + return out; +} + +class CStealthAddress +{ +public: + CStealthAddress() + { + options = 0; + } + + uint8_t options; + ec_point scan_pubkey; + ec_point spend_pubkey; + //std::vector spend_pubkeys; + size_t number_signatures; + stealth_prefix prefix; + + mutable std::string label; + data_chunk scan_secret; + data_chunk spend_secret; + + bool SetEncoded(const std::string& encodedAddress); + std::string Encoded() const; + + bool operator <(const CStealthAddress& y) const + { + return memcmp(&scan_pubkey[0], &y.scan_pubkey[0], ec_compressed_size) < 0; + } + + bool operator ==(const CStealthAddress& y) const + { + return Encoded() == y.Encoded(); + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(this->options); + READWRITE(this->scan_pubkey); + READWRITE(this->spend_pubkey); + READWRITE(this->label); + + READWRITE(this->scan_secret); + READWRITE(this->spend_secret); + ); + + + +}; + +void AppendChecksum(data_chunk& data); + +bool VerifyChecksum(const data_chunk& data); + +int GenerateRandomSecret(ec_secret& out); + +int SecretToPublicKey(const ec_secret& secret, ec_point& out); + +int StealthSecret(ec_secret& secret, ec_point& pubkey, const ec_point& pkSpend, ec_secret& sharedSOut, ec_point& pkOut); +int StealthSecretSpend(ec_secret& scanSecret, ec_point& ephemPubkey, ec_secret& spendSecret, ec_secret& secretOut); +int StealthSharedToSecretSpend(ec_secret& sharedS, ec_secret& spendSecret, ec_secret& secretOut); + +bool IsStealthAddress(const std::string& encodedAddress); + + +#endif // BITCOIN_STEALTH_H + diff --git a/src/strlcpy.h b/src/strlcpy.h new file mode 100644 index 0000000..2cc786e --- /dev/null +++ b/src/strlcpy.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 1998 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#ifndef BITCOIN_STRLCPY_H +#define BITCOIN_STRLCPY_H + +#include +#include + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +inline size_t strlcpy(char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0) + { + while (--n != 0) + { + if ((*d++ = *s++) == '\0') + break; + } + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) + { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return(s - src - 1); /* count does not include NUL */ +} + +/* + * Appends src to string dst of size siz (unlike strncat, siz is the + * full size of dst, not space left). At most siz-1 characters + * will be copied. Always NUL terminates (unless siz <= strlen(dst)). + * Returns strlen(src) + MIN(siz, strlen(initial dst)). + * If retval >= siz, truncation occurred. + */ +inline size_t strlcat(char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (n-- != 0 && *d != '\0') + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + return(dlen + strlen(s)); + while (*s != '\0') + { + if (n != 1) + { + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; + + return(dlen + (s - src)); /* count does not include NUL */ +} +#endif diff --git a/src/sync.cpp b/src/sync.cpp new file mode 100644 index 0000000..e624a9e --- /dev/null +++ b/src/sync.cpp @@ -0,0 +1,148 @@ +// Copyright (c) 2011-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "sync.h" + +#include "util.h" + +#include + +#ifdef DEBUG_LOCKCONTENTION +void PrintLockContention(const char* pszName, const char* pszFile, int nLine) +{ + LogPrintf("LOCKCONTENTION: %s\n", pszName); + LogPrintf("Locker: %s:%d\n", pszFile, nLine); +} +#endif /* DEBUG_LOCKCONTENTION */ + +#ifdef DEBUG_LOCKORDER +// +// Early deadlock detection. +// Problem being solved: +// Thread 1 locks A, then B, then C +// Thread 2 locks D, then C, then A +// --> may result in deadlock between the two threads, depending on when they run. +// Solution implemented here: +// Keep track of pairs of locks: (A before B), (A before C), etc. +// Complain if any thread tries to lock in a different order. +// + +struct CLockLocation +{ + CLockLocation(const char* pszName, const char* pszFile, int nLine) + { + mutexName = pszName; + sourceFile = pszFile; + sourceLine = nLine; + } + + std::string ToString() const + { + return mutexName+" "+sourceFile+":"+itostr(sourceLine); + } + + std::string MutexName() const { return mutexName; } + +private: + std::string mutexName; + std::string sourceFile; + int sourceLine; +}; + +typedef std::vector< std::pair > LockStack; + +static boost::mutex dd_mutex; +static std::map, LockStack> lockorders; +static boost::thread_specific_ptr lockstack; + + +static void potential_deadlock_detected(const std::pair& mismatch, const LockStack& s1, const LockStack& s2) +{ + LogPrintf("POTENTIAL DEADLOCK DETECTED\n"); + LogPrintf("Previous lock order was:\n"); + BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, s2) + { + if (i.first == mismatch.first) LogPrintf(" (1)"); + if (i.first == mismatch.second) LogPrintf(" (2)"); + LogPrintf(" %s\n", i.second.ToString()); + } + LogPrintf("Current lock order is:\n"); + BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, s1) + { + if (i.first == mismatch.first) LogPrintf(" (1)"); + if (i.first == mismatch.second) LogPrintf(" (2)"); + LogPrintf(" %s\n", i.second.ToString()); + } +} + +static void push_lock(void* c, const CLockLocation& locklocation, bool fTry) +{ + if (lockstack.get() == NULL) + lockstack.reset(new LockStack); + + LogPrint("lock", "Locking: %s\n", locklocation.ToString()); + dd_mutex.lock(); + + (*lockstack).push_back(std::make_pair(c, locklocation)); + + if (!fTry) { + BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, (*lockstack)) { + if (i.first == c) break; + + std::pair p1 = std::make_pair(i.first, c); + if (lockorders.count(p1)) + continue; + lockorders[p1] = (*lockstack); + + std::pair p2 = std::make_pair(c, i.first); + if (lockorders.count(p2)) + { + potential_deadlock_detected(p1, lockorders[p2], lockorders[p1]); + break; + } + } + } + dd_mutex.unlock(); +} + +static void pop_lock() +{ + if (fDebug) + { + const CLockLocation& locklocation = (*lockstack).rbegin()->second; + LogPrint("lock", "Unlocked: %s\n", locklocation.ToString()); + } + dd_mutex.lock(); + (*lockstack).pop_back(); + dd_mutex.unlock(); +} + +void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry) +{ + push_lock(cs, CLockLocation(pszName, pszFile, nLine), fTry); +} + +void LeaveCritical() +{ + pop_lock(); +} + +std::string LocksHeld() +{ + std::string result; + BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)&i, *lockstack) + result += i.second.ToString() + std::string("\n"); + return result; +} + +void AssertLockHeldInternal(const char *pszName, const char* pszFile, int nLine, void *cs) +{ + BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)&i, *lockstack) + if (i.first == cs) return; + fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", + pszName, pszFile, nLine, LocksHeld().c_str()); + abort(); +} + +#endif /* DEBUG_LOCKORDER */ diff --git a/src/sync.h b/src/sync.h new file mode 100644 index 0000000..928b12c --- /dev/null +++ b/src/sync.h @@ -0,0 +1,261 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_SYNC_H +#define BITCOIN_SYNC_H + +#include "threadsafety.h" + +#include +#include +#include +#include + + +//////////////////////////////////////////////// +// // +// THE SIMPLE DEFINITON, EXCLUDING DEBUG CODE // +// // +//////////////////////////////////////////////// + +/* + + + +CCriticalSection mutex; + boost::recursive_mutex mutex; + +LOCK(mutex); + boost::unique_lock criticalblock(mutex); + +LOCK2(mutex1, mutex2); + boost::unique_lock criticalblock1(mutex1); + boost::unique_lock criticalblock2(mutex2); + +TRY_LOCK(mutex, name); + boost::unique_lock name(mutex, boost::try_to_lock_t); + +ENTER_CRITICAL_SECTION(mutex); // no RAII + mutex.lock(); + +LEAVE_CRITICAL_SECTION(mutex); // no RAII + mutex.unlock(); + + + + */ + + + +/////////////////////////////// +// // +// THE ACTUAL IMPLEMENTATION // +// // +/////////////////////////////// + +// Template mixin that adds -Wthread-safety locking annotations to a +// subset of the mutex API. +template +class LOCKABLE AnnotatedMixin : public PARENT +{ +public: + void lock() EXCLUSIVE_LOCK_FUNCTION() + { + PARENT::lock(); + } + + void unlock() UNLOCK_FUNCTION() + { + PARENT::unlock(); + } + + bool try_lock() EXCLUSIVE_TRYLOCK_FUNCTION(true) + { + return PARENT::try_lock(); + } +}; + +/** Wrapped boost mutex: supports recursive locking, but no waiting */ +// TODO: We should move away from using the recursive lock by default. +typedef AnnotatedMixin CCriticalSection; + +/** Wrapped boost mutex: supports waiting but not recursive locking */ +typedef AnnotatedMixin CWaitableCriticalSection; + +#ifdef DEBUG_LOCKORDER +void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false); +void LeaveCritical(); +std::string LocksHeld(); +void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void *cs); +#else +void static inline EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false) {} +void static inline LeaveCritical() {} +void static inline AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void *cs) {} +#endif +#define AssertLockHeld(cs) AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs) + +#ifdef DEBUG_LOCKCONTENTION +void PrintLockContention(const char* pszName, const char* pszFile, int nLine); +#endif + +/** Wrapper around boost::unique_lock */ +template +class CMutexLock +{ +private: + boost::unique_lock lock; + + void Enter(const char* pszName, const char* pszFile, int nLine) + { + EnterCritical(pszName, pszFile, nLine, (void*)(lock.mutex())); +#ifdef DEBUG_LOCKCONTENTION + if (!lock.try_lock()) + { + PrintLockContention(pszName, pszFile, nLine); +#endif + lock.lock(); +#ifdef DEBUG_LOCKCONTENTION + } +#endif + } + + bool TryEnter(const char* pszName, const char* pszFile, int nLine) + { + EnterCritical(pszName, pszFile, nLine, (void*)(lock.mutex()), true); + lock.try_lock(); + if (!lock.owns_lock()) + LeaveCritical(); + return lock.owns_lock(); + } + +public: + CMutexLock(Mutex& mutexIn, const char* pszName, const char* pszFile, int nLine, bool fTry = false) : lock(mutexIn, boost::defer_lock) + { + if (fTry) + TryEnter(pszName, pszFile, nLine); + else + Enter(pszName, pszFile, nLine); + } + + ~CMutexLock() + { + if (lock.owns_lock()) + LeaveCritical(); + } + + operator bool() + { + return lock.owns_lock(); + } +}; + +typedef CMutexLock CCriticalBlock; + +#define LOCK(cs) CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__) +#define LOCK2(cs1,cs2) CCriticalBlock criticalblock1(cs1, #cs1, __FILE__, __LINE__),criticalblock2(cs2, #cs2, __FILE__, __LINE__) +#define TRY_LOCK(cs,name) CCriticalBlock name(cs, #cs, __FILE__, __LINE__, true) + +#define ENTER_CRITICAL_SECTION(cs) \ + { \ + EnterCritical(#cs, __FILE__, __LINE__, (void*)(&cs)); \ + (cs).lock(); \ + } + +#define LEAVE_CRITICAL_SECTION(cs) \ + { \ + (cs).unlock(); \ + LeaveCritical(); \ + } + +class CSemaphore +{ +private: + boost::condition_variable condition; + boost::mutex mutex; + int value; + +public: + CSemaphore(int init) : value(init) {} + + void wait() { + boost::unique_lock lock(mutex); + while (value < 1) { + condition.wait(lock); + } + value--; + } + + bool try_wait() { + boost::unique_lock lock(mutex); + if (value < 1) + return false; + value--; + return true; + } + + void post() { + { + boost::unique_lock lock(mutex); + value++; + } + condition.notify_one(); + } +}; + +/** RAII-style semaphore lock */ +class CSemaphoreGrant +{ +private: + CSemaphore *sem; + bool fHaveGrant; + +public: + void Acquire() { + if (fHaveGrant) + return; + sem->wait(); + fHaveGrant = true; + } + + void Release() { + if (!fHaveGrant) + return; + sem->post(); + fHaveGrant = false; + } + + bool TryAcquire() { + if (!fHaveGrant && sem->try_wait()) + fHaveGrant = true; + return fHaveGrant; + } + + void MoveTo(CSemaphoreGrant &grant) { + grant.Release(); + grant.sem = sem; + grant.fHaveGrant = fHaveGrant; + sem = NULL; + fHaveGrant = false; + } + + CSemaphoreGrant() : sem(NULL), fHaveGrant(false) {} + + CSemaphoreGrant(CSemaphore &sema, bool fTry = false) : sem(&sema), fHaveGrant(false) { + if (fTry) + TryAcquire(); + else + Acquire(); + } + + ~CSemaphoreGrant() { + Release(); + } + + operator bool() { + return fHaveGrant; + } +}; +#endif + diff --git a/src/test/Checkpoints_tests.cpp b/src/test/Checkpoints_tests.cpp new file mode 100644 index 0000000..fee4650 --- /dev/null +++ b/src/test/Checkpoints_tests.cpp @@ -0,0 +1,34 @@ +// +// Unit tests for block-chain checkpoints +// +#include // for 'map_list_of()' +#include +#include + +#include "../checkpoints.h" +#include "../util.h" + +using namespace std; + +BOOST_AUTO_TEST_SUITE(Checkpoints_tests) + +BOOST_AUTO_TEST_CASE(sanity) +{ + uint256 p11111 = uint256("0x"); + uint256 p134444 = uint256("0x"); + BOOST_CHECK(Checkpoints::CheckBlock(0, p0)); + + + + // Wrong hashes at checkpoints should fail: + BOOST_CHECK(!Checkpoints::CheckBlock(0, p0)); + + + // ... but any hash not at a checkpoint should succeed: + BOOST_CHECK(Checkpoints::CheckBlock(0+1, p0)); + + + BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 0); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/README b/src/test/README new file mode 100644 index 0000000..77f7faa --- /dev/null +++ b/src/test/README @@ -0,0 +1,21 @@ +The sources in this directory are unit test cases. Boost includes a +unit testing framework, and since bitcoin already uses boost, it makes +sense to simply use this framework rather than require developers to +configure some other framework (we want as few impediments to creating +unit tests as possible). + +The build system is setup to compile an executable called "test_bitcoin" +that runs all of the unit tests. The main source file is called +test_bitcoin.cpp, which simply includes other files that contain the +actual unit tests (outside of a couple required preprocessor +directives). The pattern is to create one test file for each class or +source file for which you want to create unit tests. The file naming +convention is "_tests.cpp" and such files should wrap +their tests in a test suite called "_tests". For an +examples of this pattern, examine uint160_tests.cpp and +uint256_tests.cpp. + +For further reading, I found the following website to be helpful in +explaining how the boost unit test framework works: + +http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/ diff --git a/src/test/accounting_tests.cpp b/src/test/accounting_tests.cpp new file mode 100644 index 0000000..8ac6572 --- /dev/null +++ b/src/test/accounting_tests.cpp @@ -0,0 +1,123 @@ +#include + +#include + +#include "init.h" +#include "wallet.h" +#include "walletdb.h" + +BOOST_AUTO_TEST_SUITE(accounting_tests) + +static void +GetResults(CWalletDB& walletdb, std::map& results) +{ + std::list aes; + + results.clear(); + BOOST_CHECK(walletdb.ReorderTransactions(pwalletMain) == DB_LOAD_OK); + walletdb.ListAccountCreditDebit("", aes); + BOOST_FOREACH(CAccountingEntry& ae, aes) + { + results[ae.nOrderPos] = ae; + } +} + +BOOST_AUTO_TEST_CASE(acc_orderupgrade) +{ + CWalletDB walletdb(pwalletMain->strWalletFile); + std::vector vpwtx; + CWalletTx wtx; + CAccountingEntry ae; + std::map results; + + ae.strAccount = ""; + ae.nCreditDebit = 1; + ae.nTime = 1333333333; + ae.strOtherAccount = "b"; + ae.strComment = ""; + walletdb.WriteAccountingEntry(ae); + + wtx.mapValue["comment"] = "z"; + pwalletMain->AddToWallet(wtx); + vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]); + vpwtx[0]->nTimeReceived = (unsigned int)1333333335; + vpwtx[0]->nOrderPos = -1; + + ae.nTime = 1333333336; + ae.strOtherAccount = "c"; + walletdb.WriteAccountingEntry(ae); + + GetResults(walletdb, results); + + BOOST_CHECK(pwalletMain->nOrderPosNext == 3); + BOOST_CHECK(2 == results.size()); + BOOST_CHECK(results[0].nTime == 1333333333); + BOOST_CHECK(results[0].strComment.empty()); + BOOST_CHECK(1 == vpwtx[0]->nOrderPos); + BOOST_CHECK(results[2].nTime == 1333333336); + BOOST_CHECK(results[2].strOtherAccount == "c"); + + + ae.nTime = 1333333330; + ae.strOtherAccount = "d"; + ae.nOrderPos = pwalletMain->IncOrderPosNext(); + walletdb.WriteAccountingEntry(ae); + + GetResults(walletdb, results); + + BOOST_CHECK(results.size() == 3); + BOOST_CHECK(pwalletMain->nOrderPosNext == 4); + BOOST_CHECK(results[0].nTime == 1333333333); + BOOST_CHECK(1 == vpwtx[0]->nOrderPos); + BOOST_CHECK(results[2].nTime == 1333333336); + BOOST_CHECK(results[3].nTime == 1333333330); + BOOST_CHECK(results[3].strComment.empty()); + + + wtx.mapValue["comment"] = "y"; + --wtx.nLockTime; // Just to change the hash :) + pwalletMain->AddToWallet(wtx); + vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]); + vpwtx[1]->nTimeReceived = (unsigned int)1333333336; + + wtx.mapValue["comment"] = "x"; + --wtx.nLockTime; // Just to change the hash :) + pwalletMain->AddToWallet(wtx); + vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]); + vpwtx[2]->nTimeReceived = (unsigned int)1333333329; + vpwtx[2]->nOrderPos = -1; + + GetResults(walletdb, results); + + BOOST_CHECK(results.size() == 3); + BOOST_CHECK(pwalletMain->nOrderPosNext == 6); + BOOST_CHECK(0 == vpwtx[2]->nOrderPos); + BOOST_CHECK(results[1].nTime == 1333333333); + BOOST_CHECK(2 == vpwtx[0]->nOrderPos); + BOOST_CHECK(results[3].nTime == 1333333336); + BOOST_CHECK(results[4].nTime == 1333333330); + BOOST_CHECK(results[4].strComment.empty()); + BOOST_CHECK(5 == vpwtx[1]->nOrderPos); + + + ae.nTime = 1333333334; + ae.strOtherAccount = "e"; + ae.nOrderPos = -1; + walletdb.WriteAccountingEntry(ae); + + GetResults(walletdb, results); + + BOOST_CHECK(results.size() == 4); + BOOST_CHECK(pwalletMain->nOrderPosNext == 7); + BOOST_CHECK(0 == vpwtx[2]->nOrderPos); + BOOST_CHECK(results[1].nTime == 1333333333); + BOOST_CHECK(2 == vpwtx[0]->nOrderPos); + BOOST_CHECK(results[3].nTime == 1333333336); + BOOST_CHECK(results[3].strComment.empty()); + BOOST_CHECK(results[4].nTime == 1333333330); + BOOST_CHECK(results[4].strComment.empty()); + BOOST_CHECK(results[5].nTime == 1333333334); + BOOST_CHECK(6 == vpwtx[1]->nOrderPos); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/allocator_tests.cpp b/src/test/allocator_tests.cpp new file mode 100644 index 0000000..d5cb8e8 --- /dev/null +++ b/src/test/allocator_tests.cpp @@ -0,0 +1,115 @@ +#include + +#include "init.h" +#include "main.h" +#include "util.h" + +BOOST_AUTO_TEST_SUITE(allocator_tests) + +// Dummy memory page locker for platform independent tests +static const void *last_lock_addr, *last_unlock_addr; +static size_t last_lock_len, last_unlock_len; +class TestLocker +{ +public: + bool Lock(const void *addr, size_t len) + { + last_lock_addr = addr; + last_lock_len = len; + return true; + } + bool Unlock(const void *addr, size_t len) + { + last_unlock_addr = addr; + last_unlock_len = len; + return true; + } +}; + +BOOST_AUTO_TEST_CASE(test_LockedPageManagerBase) +{ + const size_t test_page_size = 4096; + LockedPageManagerBase lpm(test_page_size); + size_t addr; + last_lock_addr = last_unlock_addr = 0; + last_lock_len = last_unlock_len = 0; + + /* Try large number of small objects */ + addr = 0; + for(int i=0; i<1000; ++i) + { + lpm.LockRange(reinterpret_cast(addr), 33); + addr += 33; + } + /* Try small number of page-sized objects, straddling two pages */ + addr = test_page_size*100 + 53; + for(int i=0; i<100; ++i) + { + lpm.LockRange(reinterpret_cast(addr), test_page_size); + addr += test_page_size; + } + /* Try small number of page-sized objects aligned to exactly one page */ + addr = test_page_size*300; + for(int i=0; i<100; ++i) + { + lpm.LockRange(reinterpret_cast(addr), test_page_size); + addr += test_page_size; + } + /* one very large object, straddling pages */ + lpm.LockRange(reinterpret_cast(test_page_size*600+1), test_page_size*500); + BOOST_CHECK(last_lock_addr == reinterpret_cast(test_page_size*(600+500))); + /* one very large object, page aligned */ + lpm.LockRange(reinterpret_cast(test_page_size*1200), test_page_size*500-1); + BOOST_CHECK(last_lock_addr == reinterpret_cast(test_page_size*(1200+500-1))); + + BOOST_CHECK(lpm.GetLockedPageCount() == ( + (1000*33+test_page_size-1)/test_page_size + // small objects + 101 + 100 + // page-sized objects + 501 + 500)); // large objects + BOOST_CHECK((last_lock_len & (test_page_size-1)) == 0); // always lock entire pages + BOOST_CHECK(last_unlock_len == 0); // nothing unlocked yet + + /* And unlock again */ + addr = 0; + for(int i=0; i<1000; ++i) + { + lpm.UnlockRange(reinterpret_cast(addr), 33); + addr += 33; + } + addr = test_page_size*100 + 53; + for(int i=0; i<100; ++i) + { + lpm.UnlockRange(reinterpret_cast(addr), test_page_size); + addr += test_page_size; + } + addr = test_page_size*300; + for(int i=0; i<100; ++i) + { + lpm.UnlockRange(reinterpret_cast(addr), test_page_size); + addr += test_page_size; + } + lpm.UnlockRange(reinterpret_cast(test_page_size*600+1), test_page_size*500); + lpm.UnlockRange(reinterpret_cast(test_page_size*1200), test_page_size*500-1); + + /* Check that everything is released */ + BOOST_CHECK(lpm.GetLockedPageCount() == 0); + + /* A few and unlocks of size zero (should have no effect) */ + addr = 0; + for(int i=0; i<1000; ++i) + { + lpm.LockRange(reinterpret_cast(addr), 0); + addr += 1; + } + BOOST_CHECK(lpm.GetLockedPageCount() == 0); + addr = 0; + for(int i=0; i<1000; ++i) + { + lpm.UnlockRange(reinterpret_cast(addr), 0); + addr += 1; + } + BOOST_CHECK(lpm.GetLockedPageCount() == 0); + BOOST_CHECK((last_unlock_len & (test_page_size-1)) == 0); // always unlock entire pages +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/base32_tests.cpp b/src/test/base32_tests.cpp new file mode 100644 index 0000000..fdf3285 --- /dev/null +++ b/src/test/base32_tests.cpp @@ -0,0 +1,20 @@ +#include + +#include "util.h" + +BOOST_AUTO_TEST_SUITE(base32_tests) + +BOOST_AUTO_TEST_CASE(base32_testvectors) +{ + static const std::string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"}; + static const std::string vstrOut[] = {"","my======","mzxq====","mzxw6===","mzxw6yq=","mzxw6ytb","mzxw6ytboi======"}; + for (unsigned int i=0; i +#include "json/json_spirit_reader_template.h" +#include "json/json_spirit_writer_template.h" +#include "json/json_spirit_utils.h" + +#include "base58.h" +#include "util.h" + +using namespace json_spirit; +extern Array read_json(const std::string& filename); + +BOOST_AUTO_TEST_SUITE(base58_tests) + +// Goal: test low-level base58 encoding functionality +BOOST_AUTO_TEST_CASE(base58_EncodeBase58) +{ + Array tests = read_json("base58_encode_decode.json"); + + BOOST_FOREACH(Value& tv, tests) + { + Array test = tv.get_array(); + std::string strTest = write_string(tv, false); + if (test.size() < 2) // Allow for extra stuff (useful for comments) + { + BOOST_ERROR("Bad test: " << strTest); + continue; + } + std::vector sourcedata = ParseHex(test[0].get_str()); + std::string base58string = test[1].get_str(); + BOOST_CHECK_MESSAGE( + EncodeBase58(&sourcedata[0], &sourcedata[sourcedata.size()]) == base58string, + strTest); + } +} + +// Goal: test low-level base58 decoding functionality +BOOST_AUTO_TEST_CASE(base58_DecodeBase58) +{ + Array tests = read_json("base58_encode_decode.json"); + std::vector result; + + BOOST_FOREACH(Value& tv, tests) + { + Array test = tv.get_array(); + std::string strTest = write_string(tv, false); + if (test.size() < 2) // Allow for extra stuff (useful for comments) + { + BOOST_ERROR("Bad test: " << strTest); + continue; + } + std::vector expected = ParseHex(test[0].get_str()); + std::string base58string = test[1].get_str(); + BOOST_CHECK_MESSAGE(DecodeBase58(base58string, result), strTest); + BOOST_CHECK_MESSAGE(result.size() == expected.size() && std::equal(result.begin(), result.end(), expected.begin()), strTest); + } + + BOOST_CHECK(!DecodeBase58("invalid", result)); +} + +// Visitor to check address type +class TestAddrTypeVisitor : public boost::static_visitor +{ +private: + std::string exp_addrType; +public: + TestAddrTypeVisitor(const std::string &exp_addrType) : exp_addrType(exp_addrType) { } + bool operator()(const CKeyID &id) const + { + return (exp_addrType == "pubkey"); + } + bool operator()(const CScriptID &id) const + { + return (exp_addrType == "script"); + } + bool operator()(const CNoDestination &no) const + { + return (exp_addrType == "none"); + } +}; + +// Visitor to check address payload +class TestPayloadVisitor : public boost::static_visitor +{ +private: + std::vector exp_payload; +public: + TestPayloadVisitor(std::vector &exp_payload) : exp_payload(exp_payload) { } + bool operator()(const CKeyID &id) const + { + uint160 exp_key(exp_payload); + return exp_key == id; + } + bool operator()(const CScriptID &id) const + { + uint160 exp_key(exp_payload); + return exp_key == id; + } + bool operator()(const CNoDestination &no) const + { + return exp_payload.size() == 0; + } +}; + +// Goal: check that parsed keys match test payload +BOOST_AUTO_TEST_CASE(base58_keys_valid_parse) +{ + Array tests = read_json("base58_keys_valid.json"); + std::vector result; + CBitcoinSecret secret; + CBitcoinAddress addr; + + BOOST_FOREACH(Value& tv, tests) + { + Array test = tv.get_array(); + std::string strTest = write_string(tv, false); + if (test.size() < 3) // Allow for extra stuff (useful for comments) + { + BOOST_ERROR("Bad test: " << strTest); + continue; + } + std::string exp_base58string = test[0].get_str(); + std::vector exp_payload = ParseHex(test[1].get_str()); + const Object &metadata = test[2].get_obj(); + bool isPrivkey = find_value(metadata, "isPrivkey").get_bool(); + bool isTestnet = find_value(metadata, "isTestnet").get_bool(); + if (isTestnet) + SelectParams(CChainParams::TESTNET); + else + SelectParams(CChainParams::MAIN); + if(isPrivkey) + { + bool isCompressed = find_value(metadata, "isCompressed").get_bool(); + // Must be valid private key + // Note: CBitcoinSecret::SetString tests isValid, whereas CBitcoinAddress does not! + BOOST_CHECK_MESSAGE(secret.SetString(exp_base58string), "!SetString:"+ strTest); + BOOST_CHECK_MESSAGE(secret.IsValid(), "!IsValid:" + strTest); + CKey privkey = secret.GetKey(); + BOOST_CHECK_MESSAGE(privkey.IsCompressed() == isCompressed, "compressed mismatch:" + strTest); + BOOST_CHECK_MESSAGE(privkey.size() == exp_payload.size() && std::equal(privkey.begin(), privkey.end(), exp_payload.begin()), "key mismatch:" + strTest); + + // Private key must be invalid public key + addr.SetString(exp_base58string); + BOOST_CHECK_MESSAGE(!addr.IsValid(), "IsValid privkey as pubkey:" + strTest); + } + else + { + std::string exp_addrType = find_value(metadata, "addrType").get_str(); // "script" or "pubkey" + // Must be valid public key + BOOST_CHECK_MESSAGE(addr.SetString(exp_base58string), "SetString:" + strTest); + BOOST_CHECK_MESSAGE(addr.IsValid(), "!IsValid:" + strTest); + BOOST_CHECK_MESSAGE(addr.IsScript() == (exp_addrType == "script"), "isScript mismatch" + strTest); + CTxDestination dest = addr.Get(); + BOOST_CHECK_MESSAGE(boost::apply_visitor(TestAddrTypeVisitor(exp_addrType), dest), "addrType mismatch" + strTest); + + // Public key must be invalid private key + secret.SetString(exp_base58string); + BOOST_CHECK_MESSAGE(!secret.IsValid(), "IsValid pubkey as privkey:" + strTest); + } + } + SelectParams(CChainParams::MAIN); +} + +// Goal: check that generated keys match test vectors +BOOST_AUTO_TEST_CASE(base58_keys_valid_gen) +{ + Array tests = read_json("base58_keys_valid.json"); + std::vector result; + BOOST_FOREACH(Value& tv, tests) + { + Array test = tv.get_array(); + std::string strTest = write_string(tv, false); + if (test.size() < 3) // Allow for extra stuff (useful for comments) + { + BOOST_ERROR("Bad test: " << strTest); + continue; + } + std::string exp_base58string = test[0].get_str(); + std::vector exp_payload = ParseHex(test[1].get_str()); + const Object &metadata = test[2].get_obj(); + bool isPrivkey = find_value(metadata, "isPrivkey").get_bool(); + bool isTestnet = find_value(metadata, "isTestnet").get_bool(); + if (isTestnet) + SelectParams(CChainParams::TESTNET); + else + SelectParams(CChainParams::MAIN); + if(isPrivkey) + { + bool isCompressed = find_value(metadata, "isCompressed").get_bool(); + CKey key; + key.Set(exp_payload.begin(), exp_payload.end(), isCompressed); + assert(key.IsValid()); + CBitcoinSecret secret; + secret.SetKey(key); + BOOST_CHECK_MESSAGE(secret.ToString() == exp_base58string, "result mismatch: " + strTest); + } + else + { + std::string exp_addrType = find_value(metadata, "addrType").get_str(); + CTxDestination dest; + if(exp_addrType == "pubkey") + { + dest = CKeyID(uint160(exp_payload)); + } + else if(exp_addrType == "script") + { + dest = CScriptID(uint160(exp_payload)); + } + else if(exp_addrType == "none") + { + dest = CNoDestination(); + } + else + { + BOOST_ERROR("Bad addrtype: " << strTest); + continue; + } + CBitcoinAddress addrOut; + BOOST_CHECK_MESSAGE(boost::apply_visitor(CBitcoinAddressVisitor(&addrOut), dest), "encode dest: " + strTest); + BOOST_CHECK_MESSAGE(addrOut.ToString() == exp_base58string, "mismatch: " + strTest); + } + } + + // Visiting a CNoDestination must fail + CBitcoinAddress dummyAddr; + CTxDestination nodest = CNoDestination(); + BOOST_CHECK(!boost::apply_visitor(CBitcoinAddressVisitor(&dummyAddr), nodest)); + + SelectParams(CChainParams::MAIN); +} + +// Goal: check that base58 parsing code is robust against a variety of corrupted data +BOOST_AUTO_TEST_CASE(base58_keys_invalid) +{ + Array tests = read_json("base58_keys_invalid.json"); // Negative testcases + std::vector result; + CBitcoinSecret secret; + CBitcoinAddress addr; + + BOOST_FOREACH(Value& tv, tests) + { + Array test = tv.get_array(); + std::string strTest = write_string(tv, false); + if (test.size() < 1) // Allow for extra stuff (useful for comments) + { + BOOST_ERROR("Bad test: " << strTest); + continue; + } + std::string exp_base58string = test[0].get_str(); + + // must be invalid as public and as private key + addr.SetString(exp_base58string); + BOOST_CHECK_MESSAGE(!addr.IsValid(), "IsValid pubkey:" + strTest); + secret.SetString(exp_base58string); + BOOST_CHECK_MESSAGE(!secret.IsValid(), "IsValid privkey:" + strTest); + } +} + + +BOOST_AUTO_TEST_SUITE_END() + diff --git a/src/test/base64_tests.cpp b/src/test/base64_tests.cpp new file mode 100644 index 0000000..c5a053e --- /dev/null +++ b/src/test/base64_tests.cpp @@ -0,0 +1,22 @@ +#include + +#include "main.h" +#include "wallet.h" +#include "util.h" + +BOOST_AUTO_TEST_SUITE(base64_tests) + +BOOST_AUTO_TEST_CASE(base64_testvectors) +{ + static const std::string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"}; + static const std::string vstrOut[] = {"","Zg==","Zm8=","Zm9v","Zm9vYg==","Zm9vYmE=","Zm9vYmFy"}; + for (unsigned int i=0; i +#include + +#include "bignum.h" +#include "util.h" + +BOOST_AUTO_TEST_SUITE(bignum_tests) + +// Unfortunately there's no standard way of preventing a function from being +// inlined, so we define a macro for it. +// +// You should use it like this: +// NOINLINE void function() {...} +#if defined(__GNUC__) +// This also works and will be defined for any compiler implementing GCC +// extensions, such as Clang and ICC. +#define NOINLINE __attribute__((noinline)) +#elif defined(_MSC_VER) +#define NOINLINE __declspec(noinline) +#else +// We give out a warning because it impacts the correctness of one bignum test. +#warning You should define NOINLINE for your compiler. +#define NOINLINE +#endif + +// For the following test case, it is useful to use additional tools. +// +// The simplest one to use is the compiler flag -ftrapv, which detects integer +// overflows and similar errors. However, due to optimizations and compilers +// taking advantage of undefined behavior sometimes it may not actually detect +// anything. +// +// You can also use compiler-based stack protection to possibly detect possible +// stack buffer overruns. +// +// For more accurate diagnostics, you can use an undefined arithmetic operation +// detector such as the clang-based tool: +// +// "IOC: An Integer Overflow Checker for C/C++" +// +// Available at: http://embed.cs.utah.edu/ioc/ +// +// It might also be useful to use Google's AddressSanitizer to detect +// stack buffer overruns, which valgrind can't currently detect. + +// Let's force this code not to be inlined, in order to actually +// test a generic version of the function. This increases the chance +// that -ftrapv will detect overflows. +NOINLINE void mysetint64(CBigNum& num, int64 n) +{ + num.setint64(n); +} + +// For each number, we do 2 tests: one with inline code, then we reset the +// value to 0, then the second one with a non-inlined function. +BOOST_AUTO_TEST_CASE(bignum_setint64) +{ + int64 n; + + { + n = 0; + CBigNum num(n); + BOOST_CHECK(num.ToString() == "0"); + num.setulong(0); + BOOST_CHECK(num.ToString() == "0"); + mysetint64(num, n); + BOOST_CHECK(num.ToString() == "0"); + } + { + n = 1; + CBigNum num(n); + BOOST_CHECK(num.ToString() == "1"); + num.setulong(0); + BOOST_CHECK(num.ToString() == "0"); + mysetint64(num, n); + BOOST_CHECK(num.ToString() == "1"); + } + { + n = -1; + CBigNum num(n); + BOOST_CHECK(num.ToString() == "-1"); + num.setulong(0); + BOOST_CHECK(num.ToString() == "0"); + mysetint64(num, n); + BOOST_CHECK(num.ToString() == "-1"); + } + { + n = 5; + CBigNum num(n); + BOOST_CHECK(num.ToString() == "5"); + num.setulong(0); + BOOST_CHECK(num.ToString() == "0"); + mysetint64(num, n); + BOOST_CHECK(num.ToString() == "5"); + } + { + n = -5; + CBigNum num(n); + BOOST_CHECK(num.ToString() == "-5"); + num.setulong(0); + BOOST_CHECK(num.ToString() == "0"); + mysetint64(num, n); + BOOST_CHECK(num.ToString() == "-5"); + } + { + n = std::numeric_limits::min(); + CBigNum num(n); + BOOST_CHECK(num.ToString() == "-9223372036854775808"); + num.setulong(0); + BOOST_CHECK(num.ToString() == "0"); + mysetint64(num, n); + BOOST_CHECK(num.ToString() == "-9223372036854775808"); + } + { + n = std::numeric_limits::max(); + CBigNum num(n); + BOOST_CHECK(num.ToString() == "9223372036854775807"); + num.setulong(0); + BOOST_CHECK(num.ToString() == "0"); + mysetint64(num, n); + BOOST_CHECK(num.ToString() == "9223372036854775807"); + } +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/data/base58_encode_decode.json b/src/test/data/base58_encode_decode.json new file mode 100644 index 0000000..9448f25 --- /dev/null +++ b/src/test/data/base58_encode_decode.json @@ -0,0 +1,14 @@ +[ +["", ""], +["61", "2g"], +["626262", "a3gV"], +["636363", "aPEr"], +["73696d706c792061206c6f6e6720737472696e67", "2cFupjhnEsSn59qHXstmK2ffpLv2"], +["00eb15231dfceb60925886b67d065299925915aeb172c06647", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"], +["516b6fcd0f", "ABnLTmg"], +["bf4f89001e670274dd", "3SEo3LWLoPntC"], +["572e4794", "3EFU7m"], +["ecac89cad93923c02321", "EJDM8drfXA6uyA"], +["10c8511e", "Rt5zm"], +["00000000000000000000", "1111111111"] +] diff --git a/src/test/data/base58_keys_invalid.json b/src/test/data/base58_keys_invalid.json new file mode 100644 index 0000000..a088620 --- /dev/null +++ b/src/test/data/base58_keys_invalid.json @@ -0,0 +1,152 @@ +[ + [ + "" + ], + [ + "x" + ], + [ + "37qgekLpCCHrQuSjvX3fs496FWTGsHFHizjJAs6NPcR47aefnnCWECAhHV6E3g4YN7u7Yuwod5Y" + ], + [ + "dzb7VV1Ui55BARxv7ATxAtCUeJsANKovDGWFVgpTbhq9gvPqP3yv" + ], + [ + "MuNu7ZAEDFiHthiunm7dPjwKqrVNCM3mAz6rP9zFveQu14YA8CxExSJTHcVP9DErn6u84E6Ej7S" + ], + [ + "rPpQpYknyNQ5AEHuY6H8ijJJrYc2nDKKk9jjmKEXsWzyAQcFGpDLU2Zvsmoi8JLR7hAwoy3RQWf" + ], + [ + "4Uc3FmN6NQ6zLBK5QQBXRBUREaaHwCZYsGCueHauuDmJpZKn6jkEskMB2Zi2CNgtb5r6epWEFfUJq" + ], + [ + "7aQgR5DFQ25vyXmqZAWmnVCjL3PkBcdVkBUpjrjMTcghHx3E8wb" + ], + [ + "17QpPprjeg69fW1DV8DcYYCKvWjYhXvWkov6MJ1iTTvMFj6weAqW7wybZeH57WTNxXVCRH4veVs" + ], + [ + "KxuACDviz8Xvpn1xAh9MfopySZNuyajYMZWz16Dv2mHHryznWUp3" + ], + [ + "7nK3GSmqdXJQtdohvGfJ7KsSmn3TmGqExug49583bDAL91pVSGq5xS9SHoAYL3Wv3ijKTit65th" + ], + [ + "cTivdBmq7bay3RFGEBBuNfMh2P1pDCgRYN2Wbxmgwr4ki3jNUL2va" + ], + [ + "gjMV4vjNjyMrna4fsAr8bWxAbwtmMUBXJS3zL4NJt5qjozpbQLmAfK1uA3CquSqsZQMpoD1g2nk" + ], + [ + "emXm1naBMoVzPjbk7xpeTVMFy4oDEe25UmoyGgKEB1gGWsK8kRGs" + ], + [ + "7VThQnNRj1o3Zyvc7XHPRrjDf8j2oivPTeDXnRPYWeYGE4pXeRJDZgf28ppti5hsHWXS2GSobdqyo" + ], + [ + "1G9u6oCVCPh2o8m3t55ACiYvG1y5BHewUkDSdiQarDcYXXhFHYdzMdYfUAhfxn5vNZBwpgUNpso" + ], + [ + "31QQ7ZMLkScDiB4VyZjuptr7AEc9j1SjstF7pRoLhHTGkW4Q2y9XELobQmhhWxeRvqcukGd1XCq" + ], + [ + "DHqKSnpxa8ZdQyH8keAhvLTrfkyBMQxqngcQA5N8LQ9KVt25kmGN" + ], + [ + "2LUHcJPbwLCy9GLH1qXmfmAwvadWw4bp4PCpDfduLqV17s6iDcy1imUwhQJhAoNoN1XNmweiJP4i" + ], + [ + "7USRzBXAnmck8fX9HmW7RAb4qt92VFX6soCnts9s74wxm4gguVhtG5of8fZGbNPJA83irHVY6bCos" + ], + [ + "1DGezo7BfVebZxAbNT3XGujdeHyNNBF3vnficYoTSp4PfK2QaML9bHzAMxke3wdKdHYWmsMTJVu" + ], + [ + "2D12DqDZKwCxxkzs1ZATJWvgJGhQ4cFi3WrizQ5zLAyhN5HxuAJ1yMYaJp8GuYsTLLxTAz6otCfb" + ], + [ + "8AFJzuTujXjw1Z6M3fWhQ1ujDW7zsV4ePeVjVo7D1egERqSW9nZ" + ], + [ + "163Q17qLbTCue8YY3AvjpUhotuaodLm2uqMhpYirsKjVqnxJRWTEoywMVY3NbBAHuhAJ2cF9GAZ" + ], + [ + "2MnmgiRH4eGLyLc9eAqStzk7dFgBjFtUCtu" + ], + [ + "461QQ2sYWxU7H2PV4oBwJGNch8XVTYYbZxU" + ], + [ + "2UCtv53VttmQYkVU4VMtXB31REvQg4ABzs41AEKZ8UcB7DAfVzdkV9JDErwGwyj5AUHLkmgZeobs" + ], + [ + "cSNjAsnhgtiFMi6MtfvgscMB2Cbhn2v1FUYfviJ1CdjfidvmeW6mn" + ], + [ + "gmsow2Y6EWAFDFE1CE4Hd3Tpu2BvfmBfG1SXsuRARbnt1WjkZnFh1qGTiptWWbjsq2Q6qvpgJVj" + ], + [ + "nksUKSkzS76v8EsSgozXGMoQFiCoCHzCVajFKAXqzK5on9ZJYVHMD5CKwgmX3S3c7M1U3xabUny" + ], + [ + "L3favK1UzFGgdzYBF2oBT5tbayCo4vtVBLJhg2iYuMeePxWG8SQc" + ], + [ + "7VxLxGGtYT6N99GdEfi6xz56xdQ8nP2dG1CavuXx7Rf2PrvNMTBNevjkfgs9JmkcGm6EXpj8ipyPZ" + ], + [ + "2mbZwFXF6cxShaCo2czTRB62WTx9LxhTtpP" + ], + [ + "dB7cwYdcPSgiyAwKWL3JwCVwSk6epU2txw" + ], + [ + "HPhFUhUAh8ZQQisH8QQWafAxtQYju3SFTX" + ], + [ + "4ctAH6AkHzq5ioiM1m9T3E2hiYEev5mTsB" + ], + [ + "Hn1uFi4dNexWrqARpjMqgT6cX1UsNPuV3cHdGg9ExyXw8HTKadbktRDtdeVmY3M1BxJStiL4vjJ" + ], + [ + "Sq3fDbvutABmnAHHExJDgPLQn44KnNC7UsXuT7KZecpaYDMU9Txs" + ], + [ + "6TqWyrqdgUEYDQU1aChMuFMMEimHX44qHFzCUgGfqxGgZNMUVWJ" + ], + [ + "giqJo7oWqFxNKWyrgcBxAVHXnjJ1t6cGoEffce5Y1y7u649Noj5wJ4mmiUAKEVVrYAGg2KPB3Y4" + ], + [ + "cNzHY5e8vcmM3QVJUcjCyiKMYfeYvyueq5qCMV3kqcySoLyGLYUK" + ], + [ + "37uTe568EYc9WLoHEd9jXEvUiWbq5LFLscNyqvAzLU5vBArUJA6eydkLmnMwJDjkL5kXc2VK7ig" + ], + [ + "EsYbG4tWWWY45G31nox838qNdzksbPySWc" + ], + [ + "nbuzhfwMoNzA3PaFnyLcRxE9bTJPDkjZ6Rf6Y6o2ckXZfzZzXBT" + ], + [ + "cQN9PoxZeCWK1x56xnz6QYAsvR11XAce3Ehp3gMUdfSQ53Y2mPzx" + ], + [ + "1Gm3N3rkef6iMbx4voBzaxtXcmmiMTqZPhcuAepRzYUJQW4qRpEnHvMojzof42hjFRf8PE2jPde" + ], + [ + "2TAq2tuN6x6m233bpT7yqdYQPELdTDJn1eU" + ], + [ + "ntEtnnGhqPii4joABvBtSEJG6BxjT2tUZqE8PcVYgk3RHpgxgHDCQxNbLJf7ardf1dDk2oCQ7Cf" + ], + [ + "Ky1YjoZNgQ196HJV3HpdkecfhRBmRZdMJk89Hi5KGfpfPwS2bUbfd" + ], + [ + "2A1q1YsMZowabbvta7kTy2Fd6qN4r5ZCeG3qLpvZBMzCixMUdkN2Y4dHB1wPsZAeVXUGD83MfRED" + ] +] diff --git a/src/test/data/base58_keys_valid.json b/src/test/data/base58_keys_valid.json new file mode 100644 index 0000000..e1e252e --- /dev/null +++ b/src/test/data/base58_keys_valid.json @@ -0,0 +1,452 @@ +[ + [ + "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i", + "65a16059864a2fdbc7c99a4723a8395bc6f188eb", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "3CMNFxN1oHBc4R1EpboAL5yzHGgE611Xou", + "74f209f6ea907e2ea48f74fae05782ae8a665257", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs", + "53c0307d6851aa0ce7825ba883c6bd9ad242b486", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br", + "6349a418fc4578d10a372b54b45c280cc8c4382f", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr", + "eddbdc1168f1daeadbd3e44c1e3f8f5a284c2029f78ad26af98583a499de5b19", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "Kz6UJmQACJmLtaQj5A3JAge4kVTNQ8gbvXuwbmCj7bsaabudb3RD", + "55c9bccb9ed68446d1b75273bbce89d7fe013a8acd1625514420fb2aca1a21c4", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "9213qJab2HNEpMpYNBa7wHGFKKbkDn24jpANDs2huN3yi4J11ko", + "36cb93b9ab1bdabf7fb9f2c04f1b9cc879933530ae7842398eef5a63a56800c2", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "cTpB4YiyKiBcPxnefsDpbnDxFDffjqJob8wGCEDXxgQ7zQoMXJdH", + "b9f4892c9e8282028fea1d2667c4dc5213564d41fc5783896a0d843fc15089f3", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "1Ax4gZtb7gAit2TivwejZHYtNNLT18PUXJ", + "6d23156cbbdcc82a5a47eee4c2c7c583c18b6bf4", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "3QjYXhTkvuj8qPaXHTTWb5wjXhdsLAAWVy", + "fcc5460dd6e2487c7d75b1963625da0e8f4c5975", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "n3ZddxzLvAY9o7184TB4c6FJasAybsw4HZ", + "f1d470f9b02370fdec2e6b708b08ac431bf7a5f7", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "2NBFNJTktNa7GZusGbDbGKRZTxdK9VVez3n", + "c579342c2c4c9220205e2cdc285617040c924a0a", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "5K494XZwps2bGyeL71pWid4noiSNA2cfCibrvRWqcHSptoFn7rc", + "a326b95ebae30164217d7a7f57d72ab2b54e3be64928a19da0210b9568d4015e", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "L1RrrnXkcKut5DEMwtDthjwRcTTwED36thyL1DebVrKuwvohjMNi", + "7d998b45c219a1e38e99e7cbd312ef67f77a455a9b50c730c27f02c6f730dfb4", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "93DVKyFYwSN6wEo3E2fCrFPUp17FtrtNi2Lf7n4G3garFb16CRj", + "d6bca256b5abc5602ec2e1c121a08b0da2556587430bcf7e1898af2224885203", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "cTDVKtMGVYWTHCb1AFjmVbEbWjvKpKqKgMaR3QJxToMSQAhmCeTN", + "a81ca4e8f90181ec4b61b6a7eb998af17b2cb04de8a03b504b9e34c4c61db7d9", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "1C5bSj1iEGUgSTbziymG7Cn18ENQuT36vv", + "7987ccaa53d02c8873487ef919677cd3db7a6912", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "3AnNxabYGoTxYiTEZwFEnerUoeFXK2Zoks", + "63bcc565f9e68ee0189dd5cc67f1b0e5f02f45cb", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "n3LnJXCqbPjghuVs8ph9CYsAe4Sh4j97wk", + "ef66444b5b17f14e8fae6e7e19b045a78c54fd79", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "2NB72XtkjpnATMggui83aEtPawyyKvnbX2o", + "c3e55fceceaa4391ed2a9677f4a4d34eacd021a0", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "5KaBW9vNtWNhc3ZEDyNCiXLPdVPHCikRxSBWwV9NrpLLa4LsXi9", + "e75d936d56377f432f404aabb406601f892fd49da90eb6ac558a733c93b47252", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "L1axzbSyynNYA8mCAhzxkipKkfHtAXYF4YQnhSKcLV8YXA874fgT", + "8248bd0375f2f75d7e274ae544fb920f51784480866b102384190b1addfbaa5c", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "927CnUkUbasYtDwYwVn2j8GdTuACNnKkjZ1rpZd2yBB1CLcnXpo", + "44c4f6a096eac5238291a94cc24c01e3b19b8d8cef72874a079e00a242237a52", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "cUcfCMRjiQf85YMzzQEk9d1s5A4K7xL5SmBCLrezqXFuTVefyhY7", + "d1de707020a9059d6d3abaf85e17967c6555151143db13dbb06db78df0f15c69", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "1Gqk4Tv79P91Cc1STQtU3s1W6277M2CVWu", + "adc1cc2081a27206fae25792f28bbc55b831549d", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "33vt8ViH5jsr115AGkW6cEmEz9MpvJSwDk", + "188f91a931947eddd7432d6e614387e32b244709", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "mhaMcBxNh5cqXm4aTQ6EcVbKtfL6LGyK2H", + "1694f5bc1a7295b600f40018a618a6ea48eeb498", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "2MxgPqX1iThW3oZVk9KoFcE5M4JpiETssVN", + "3b9b3fd7a50d4f08d1a5b0f62f644fa7115ae2f3", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "5HtH6GdcwCJA4ggWEL1B3jzBBUB8HPiBi9SBc5h9i4Wk4PSeApR", + "091035445ef105fa1bb125eccfb1882f3fe69592265956ade751fd095033d8d0", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "L2xSYmMeVo3Zek3ZTsv9xUrXVAmrWxJ8Ua4cw8pkfbQhcEFhkXT8", + "ab2b4bcdfc91d34dee0ae2a8c6b6668dadaeb3a88b9859743156f462325187af", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "92xFEve1Z9N8Z641KQQS7ByCSb8kGjsDzw6fAmjHN1LZGKQXyMq", + "b4204389cef18bbe2b353623cbf93e8678fbc92a475b664ae98ed594e6cf0856", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "cVM65tdYu1YK37tNoAyGoJTR13VBYFva1vg9FLuPAsJijGvG6NEA", + "e7b230133f1b5489843260236b06edca25f66adb1be455fbd38d4010d48faeef", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "1JwMWBVLtiqtscbaRHai4pqHokhFCbtoB4", + "c4c1b72491ede1eedaca00618407ee0b772cad0d", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "3QCzvfL4ZRvmJFiWWBVwxfdaNBT8EtxB5y", + "f6fe69bcb548a829cce4c57bf6fff8af3a5981f9", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "mizXiucXRCsEriQCHUkCqef9ph9qtPbZZ6", + "261f83568a098a8638844bd7aeca039d5f2352c0", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "2NEWDzHWwY5ZZp8CQWbB7ouNMLqCia6YRda", + "e930e1834a4d234702773951d627cce82fbb5d2e", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "5KQmDryMNDcisTzRp3zEq9e4awRmJrEVU1j5vFRTKpRNYPqYrMg", + "d1fab7ab7385ad26872237f1eb9789aa25cc986bacc695e07ac571d6cdac8bc0", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "L39Fy7AC2Hhj95gh3Yb2AU5YHh1mQSAHgpNixvm27poizcJyLtUi", + "b0bbede33ef254e8376aceb1510253fc3550efd0fcf84dcd0c9998b288f166b3", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "91cTVUcgydqyZLgaANpf1fvL55FH53QMm4BsnCADVNYuWuqdVys", + "037f4192c630f399d9271e26c575269b1d15be553ea1a7217f0cb8513cef41cb", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "cQspfSzsgLeiJGB2u8vrAiWpCU4MxUT6JseWo2SjXy4Qbzn2fwDw", + "6251e205e8ad508bab5596bee086ef16cd4b239e0cc0c5d7c4e6035441e7d5de", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "19dcawoKcZdQz365WpXWMhX6QCUpR9SY4r", + "5eadaf9bb7121f0f192561a5a62f5e5f54210292", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "37Sp6Rv3y4kVd1nQ1JV5pfqXccHNyZm1x3", + "3f210e7277c899c3a155cc1c90f4106cbddeec6e", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "myoqcgYiehufrsnnkqdqbp69dddVDMopJu", + "c8a3c2a09a298592c3e180f02487cd91ba3400b5", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "2N7FuwuUuoTBrDFdrAZ9KxBmtqMLxce9i1C", + "99b31df7c9068d1481b596578ddbb4d3bd90baeb", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": true + } + ], + [ + "5KL6zEaMtPRXZKo1bbMq7JDjjo1bJuQcsgL33je3oY8uSJCR5b4", + "c7666842503db6dc6ea061f092cfb9c388448629a6fe868d068c42a488b478ae", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "KwV9KAfwbwt51veZWNscRTeZs9CKpojyu1MsPnaKTF5kz69H1UN2", + "07f0803fc5399e773555ab1e8939907e9badacc17ca129e67a2f5f2ff84351dd", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": false + } + ], + [ + "93N87D6uxSBzwXvpokpzg8FFmfQPmvX4xHoWQe3pLdYpbiwT5YV", + "ea577acfb5d1d14d3b7b195c321566f12f87d2b77ea3a53f68df7ebf8604a801", + { + "isCompressed": false, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "cMxXusSihaX58wpJ3tNuuUcZEQGt6DKJ1wEpxys88FFaQCYjku9h", + "0b3b34f0958d8a268193a9814da92c3e8b58b4a4378a542863e34ac289cd830c", + { + "isCompressed": true, + "isPrivkey": true, + "isTestnet": true + } + ], + [ + "13p1ijLwsnrcuyqcTvJXkq2ASdXqcnEBLE", + "1ed467017f043e91ed4c44b4e8dd674db211c4e6", + { + "addrType": "pubkey", + "isPrivkey": false, + "isTestnet": false + } + ], + [ + "3ALJH9Y951VCGcVZYAdpA3KchoP9McEj1G", + "5ece0cadddc415b1980f001785947120acdb36fc", + { + "addrType": "script", + "isPrivkey": false, + "isTestnet": false + } + ] +] diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp new file mode 100644 index 0000000..c89d218 --- /dev/null +++ b/src/test/getarg_tests.cpp @@ -0,0 +1,153 @@ +#include +#include +#include + +#include "util.h" + +BOOST_AUTO_TEST_SUITE(getarg_tests) + +static void ResetArgs(const std::string& strArg) +{ + std::vector vecArg; + boost::split(vecArg, strArg, boost::is_space(), boost::token_compress_on); + + // Insert dummy executable name: + vecArg.insert(vecArg.begin(), "testbitcoin"); + + // Convert to char*: + std::vector vecChar; + BOOST_FOREACH(std::string& s, vecArg) + vecChar.push_back(s.c_str()); + + ParseParameters(vecChar.size(), &vecChar[0]); +} + +BOOST_AUTO_TEST_CASE(boolarg) +{ + ResetArgs("-foo"); + BOOST_CHECK(GetBoolArg("-foo", false)); + BOOST_CHECK(GetBoolArg("-foo", true)); + + BOOST_CHECK(!GetBoolArg("-fo", false)); + BOOST_CHECK(GetBoolArg("-fo", true)); + + BOOST_CHECK(!GetBoolArg("-fooo", false)); + BOOST_CHECK(GetBoolArg("-fooo", true)); + + ResetArgs("-foo=0"); + BOOST_CHECK(!GetBoolArg("-foo", false)); + BOOST_CHECK(!GetBoolArg("-foo", true)); + + ResetArgs("-foo=1"); + BOOST_CHECK(GetBoolArg("-foo", false)); + BOOST_CHECK(GetBoolArg("-foo", true)); + + // New 0.6 feature: auto-map -nosomething to !-something: + ResetArgs("-nofoo"); + BOOST_CHECK(!GetBoolArg("-foo", false)); + BOOST_CHECK(!GetBoolArg("-foo", true)); + + ResetArgs("-nofoo=1"); + BOOST_CHECK(!GetBoolArg("-foo", false)); + BOOST_CHECK(!GetBoolArg("-foo", true)); + + ResetArgs("-foo -nofoo"); // -foo should win + BOOST_CHECK(GetBoolArg("-foo", false)); + BOOST_CHECK(GetBoolArg("-foo", true)); + + ResetArgs("-foo=1 -nofoo=1"); // -foo should win + BOOST_CHECK(GetBoolArg("-foo", false)); + BOOST_CHECK(GetBoolArg("-foo", true)); + + ResetArgs("-foo=0 -nofoo=0"); // -foo should win + BOOST_CHECK(!GetBoolArg("-foo", false)); + BOOST_CHECK(!GetBoolArg("-foo", true)); + + // New 0.6 feature: treat -- same as -: + ResetArgs("--foo=1"); + BOOST_CHECK(GetBoolArg("-foo", false)); + BOOST_CHECK(GetBoolArg("-foo", true)); + + ResetArgs("--nofoo=1"); + BOOST_CHECK(!GetBoolArg("-foo", false)); + BOOST_CHECK(!GetBoolArg("-foo", true)); + +} + +BOOST_AUTO_TEST_CASE(stringarg) +{ + ResetArgs(""); + BOOST_CHECK_EQUAL(GetArg("-foo", ""), ""); + BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), "eleven"); + + ResetArgs("-foo -bar"); + BOOST_CHECK_EQUAL(GetArg("-foo", ""), ""); + BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), ""); + + ResetArgs("-foo="); + BOOST_CHECK_EQUAL(GetArg("-foo", ""), ""); + BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), ""); + + ResetArgs("-foo=11"); + BOOST_CHECK_EQUAL(GetArg("-foo", ""), "11"); + BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), "11"); + + ResetArgs("-foo=eleven"); + BOOST_CHECK_EQUAL(GetArg("-foo", ""), "eleven"); + BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), "eleven"); + +} + +BOOST_AUTO_TEST_CASE(intarg) +{ + ResetArgs(""); + BOOST_CHECK_EQUAL(GetArg("-foo", 11), 11); + BOOST_CHECK_EQUAL(GetArg("-foo", 0), 0); + + ResetArgs("-foo -bar"); + BOOST_CHECK_EQUAL(GetArg("-foo", 11), 0); + BOOST_CHECK_EQUAL(GetArg("-bar", 11), 0); + + ResetArgs("-foo=11 -bar=12"); + BOOST_CHECK_EQUAL(GetArg("-foo", 0), 11); + BOOST_CHECK_EQUAL(GetArg("-bar", 11), 12); + + ResetArgs("-foo=NaN -bar=NotANumber"); + BOOST_CHECK_EQUAL(GetArg("-foo", 1), 0); + BOOST_CHECK_EQUAL(GetArg("-bar", 11), 0); +} + +BOOST_AUTO_TEST_CASE(doubledash) +{ + ResetArgs("--foo"); + BOOST_CHECK_EQUAL(GetBoolArg("-foo", false), true); + + ResetArgs("--foo=verbose --bar=1"); + BOOST_CHECK_EQUAL(GetArg("-foo", ""), "verbose"); + BOOST_CHECK_EQUAL(GetArg("-bar", 0), 1); +} + +BOOST_AUTO_TEST_CASE(boolargno) +{ + ResetArgs("-nofoo"); + BOOST_CHECK(!GetBoolArg("-foo", true)); + BOOST_CHECK(!GetBoolArg("-foo", false)); + + ResetArgs("-nofoo=1"); + BOOST_CHECK(!GetBoolArg("-foo", true)); + BOOST_CHECK(!GetBoolArg("-foo", false)); + + ResetArgs("-nofoo=0"); + BOOST_CHECK(GetBoolArg("-foo", true)); + BOOST_CHECK(GetBoolArg("-foo", false)); + + ResetArgs("-foo --nofoo"); + BOOST_CHECK(GetBoolArg("-foo", true)); + BOOST_CHECK(GetBoolArg("-foo", false)); + + ResetArgs("-nofoo -foo"); // foo always wins: + BOOST_CHECK(GetBoolArg("-foo", true)); + BOOST_CHECK(GetBoolArg("-foo", false)); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/hmac_tests.cpp b/src/test/hmac_tests.cpp new file mode 100644 index 0000000..92ca5e6 --- /dev/null +++ b/src/test/hmac_tests.cpp @@ -0,0 +1,125 @@ +#include + +#include "hash.h" +#include "util.h" + +using namespace std; + +BOOST_AUTO_TEST_SUITE(hmac_tests) + +typedef struct { + const char *pszKey; + const char *pszData; + const char *pszMAC; +} testvec_t; + +// test cases 1, 2, 3, 4, 6 and 7 of RFC 4231 +static const testvec_t vtest[] = { + { + "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" + "0b0b0b0b", + "4869205468657265", + "87aa7cdea5ef619d4ff0b4241a1d6cb0" + "2379f4e2ce4ec2787ad0b30545e17cde" + "daa833b7d6b8a702038b274eaea3f4e4" + "be9d914eeb61f1702e696c203a126854" + }, + { + "4a656665", + "7768617420646f2079612077616e7420" + "666f72206e6f7468696e673f", + "164b7a7bfcf819e2e395fbe73b56e0a3" + "87bd64222e831fd610270cd7ea250554" + "9758bf75c05a994a6d034f65f8f0e6fd" + "caeab1a34d4a6b4b636e070a38bce737" + }, + { + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaa", + "dddddddddddddddddddddddddddddddd" + "dddddddddddddddddddddddddddddddd" + "dddddddddddddddddddddddddddddddd" + "dddd", + "fa73b0089d56a284efb0f0756c890be9" + "b1b5dbdd8ee81a3655f83e33b2279d39" + "bf3e848279a722c806b485a47e67c807" + "b946a337bee8942674278859e13292fb" + }, + { + "0102030405060708090a0b0c0d0e0f10" + "111213141516171819", + "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" + "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" + "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" + "cdcd", + "b0ba465637458c6990e5a8c5f61d4af7" + "e576d97ff94b872de76f8050361ee3db" + "a91ca5c11aa25eb4d679275cc5788063" + "a5f19741120c4f2de2adebeb10a298dd" + }, + { + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaa", + "54657374205573696e67204c61726765" + "72205468616e20426c6f636b2d53697a" + "65204b6579202d2048617368204b6579" + "204669727374", + "80b24263c7c1a3ebb71493c1dd7be8b4" + "9b46d1f41b4aeec1121b013783f8f352" + "6b56d037e05f2598bd0fd2215d6a1e52" + "95e64f73f63f0aec8b915a985d786598" + }, + { + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaa", + "54686973206973206120746573742075" + "73696e672061206c6172676572207468" + "616e20626c6f636b2d73697a65206b65" + "7920616e642061206c61726765722074" + "68616e20626c6f636b2d73697a652064" + "6174612e20546865206b6579206e6565" + "647320746f2062652068617368656420" + "6265666f7265206265696e6720757365" + "642062792074686520484d414320616c" + "676f726974686d2e", + "e37b6a775dc87dbaa4dfa9f96e5e3ffd" + "debd71f8867289865df5a32d20cdc944" + "b6022cac3c4982b10d5eeb55c3e4de15" + "134676fb6de0446065c97440fa8c6a58" + } +}; + +BOOST_AUTO_TEST_CASE(hmacsha512_testvectors) +{ + for (unsigned int n=0; n vchKey = ParseHex(vtest[n].pszKey); + vector vchData = ParseHex(vtest[n].pszData); + vector vchMAC = ParseHex(vtest[n].pszMAC); + unsigned char vchTemp[64]; + + HMAC_SHA512_CTX ctx; + HMAC_SHA512_Init(&ctx, &vchKey[0], vchKey.size()); + HMAC_SHA512_Update(&ctx, &vchData[0], vchData.size()); + HMAC_SHA512_Final(&vchTemp[0], &ctx); + + BOOST_CHECK(memcmp(&vchTemp[0], &vchMAC[0], 64) == 0); + + } +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp new file mode 100644 index 0000000..c004521 --- /dev/null +++ b/src/test/key_tests.cpp @@ -0,0 +1,141 @@ +#include + +#include +#include + +#include "key.h" +#include "base58.h" +#include "uint256.h" +#include "util.h" + +using namespace std; + +static const string strSecret1 ("5HxWvvfubhXpYYpS3tJkw6fq9jE9j18THftkZjHHfmFiWtmAbrj"); +static const string strSecret2 ("5KC4ejrDjv152FGwP386VD1i2NYc5KkfSMyv1nGy1VGDxGHqVY3"); +static const string strSecret1C ("Kwr371tjA9u2rFSMZjTNun2PXXP3WPZu2afRHTcta6KxEUdm1vEw"); +static const string strSecret2C ("L3Hq7a8FEQwJkW1M2GNKDW28546Vp5miewcCzSqUD9kCAXrJdS3g"); +static const CBitcoinAddress addr1 ("1QFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ"); +static const CBitcoinAddress addr2 ("1F5y5E5FMc5YzdJtB9hLaUe43GDxEKXENJ"); +static const CBitcoinAddress addr1C("1NoJrossxPBKfCHuJXT4HadJrXRE9Fxiqs"); +static const CBitcoinAddress addr2C("1CRj2HyM1CXWzHAXLQtiGLyggNT9WQqsDs"); + + +static const string strAddressBad("1HV9Lc3sNHZxwj4Zk6fB38tEmBryq2cBiF"); + + +#ifdef KEY_TESTS_DUMPINFO +void dumpKeyInfo(uint256 privkey) +{ + CKey key; + key.resize(32); + memcpy(&secret[0], &privkey, 32); + vector sec; + sec.resize(32); + memcpy(&sec[0], &secret[0], 32); + printf(" * secret (hex): %s\n", HexStr(sec).c_str()); + + for (int nCompressed=0; nCompressed<2; nCompressed++) + { + bool fCompressed = nCompressed == 1; + printf(" * %s:\n", fCompressed ? "compressed" : "uncompressed"); + CBitcoinSecret bsecret; + bsecret.SetSecret(secret, fCompressed); + printf(" * secret (base58): %s\n", bsecret.ToString().c_str()); + CKey key; + key.SetSecret(secret, fCompressed); + vector vchPubKey = key.GetPubKey(); + printf(" * pubkey (hex): %s\n", HexStr(vchPubKey).c_str()); + printf(" * address (base58): %s\n", CBitcoinAddress(vchPubKey).ToString().c_str()); + } +} +#endif + + +BOOST_AUTO_TEST_SUITE(key_tests) + +BOOST_AUTO_TEST_CASE(key_test1) +{ + CBitcoinSecret bsecret1, bsecret2, bsecret1C, bsecret2C, baddress1; + BOOST_CHECK( bsecret1.SetString (strSecret1)); + BOOST_CHECK( bsecret2.SetString (strSecret2)); + BOOST_CHECK( bsecret1C.SetString(strSecret1C)); + BOOST_CHECK( bsecret2C.SetString(strSecret2C)); + BOOST_CHECK(!baddress1.SetString(strAddressBad)); + + CKey key1 = bsecret1.GetKey(); + BOOST_CHECK(key1.IsCompressed() == false); + CKey key2 = bsecret2.GetKey(); + BOOST_CHECK(key2.IsCompressed() == false); + CKey key1C = bsecret1C.GetKey(); + BOOST_CHECK(key1C.IsCompressed() == true); + CKey key2C = bsecret2C.GetKey(); + BOOST_CHECK(key1C.IsCompressed() == true); + + CPubKey pubkey1 = key1. GetPubKey(); + CPubKey pubkey2 = key2. GetPubKey(); + CPubKey pubkey1C = key1C.GetPubKey(); + CPubKey pubkey2C = key2C.GetPubKey(); + + BOOST_CHECK(addr1.Get() == CTxDestination(pubkey1.GetID())); + BOOST_CHECK(addr2.Get() == CTxDestination(pubkey2.GetID())); + BOOST_CHECK(addr1C.Get() == CTxDestination(pubkey1C.GetID())); + BOOST_CHECK(addr2C.Get() == CTxDestination(pubkey2C.GetID())); + + for (int n=0; n<16; n++) + { + string strMsg = strprintf("Very secret message %i: 11", n); + uint256 hashMsg = Hash(strMsg.begin(), strMsg.end()); + + // normal signatures + + vector sign1, sign2, sign1C, sign2C; + + BOOST_CHECK(key1.Sign (hashMsg, sign1)); + BOOST_CHECK(key2.Sign (hashMsg, sign2)); + BOOST_CHECK(key1C.Sign(hashMsg, sign1C)); + BOOST_CHECK(key2C.Sign(hashMsg, sign2C)); + + BOOST_CHECK( pubkey1.Verify(hashMsg, sign1)); + BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2)); + BOOST_CHECK( pubkey1.Verify(hashMsg, sign1C)); + BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2C)); + + BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1)); + BOOST_CHECK( pubkey2.Verify(hashMsg, sign2)); + BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1C)); + BOOST_CHECK( pubkey2.Verify(hashMsg, sign2C)); + + BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1)); + BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2)); + BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1C)); + BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2C)); + + BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1)); + BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2)); + BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1C)); + BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2C)); + + // compact signatures (with key recovery) + + vector csign1, csign2, csign1C, csign2C; + + BOOST_CHECK(key1.SignCompact (hashMsg, csign1)); + BOOST_CHECK(key2.SignCompact (hashMsg, csign2)); + BOOST_CHECK(key1C.SignCompact(hashMsg, csign1C)); + BOOST_CHECK(key2C.SignCompact(hashMsg, csign2C)); + + CPubKey rkey1, rkey2, rkey1C, rkey2C; + + BOOST_CHECK(rkey1.RecoverCompact (hashMsg, csign1)); + BOOST_CHECK(rkey2.RecoverCompact (hashMsg, csign2)); + BOOST_CHECK(rkey1C.RecoverCompact(hashMsg, csign1C)); + BOOST_CHECK(rkey2C.RecoverCompact(hashMsg, csign2C)); + + BOOST_CHECK(rkey1 == pubkey1); + BOOST_CHECK(rkey2 == pubkey2); + BOOST_CHECK(rkey1C == pubkey1C); + BOOST_CHECK(rkey2C == pubkey2C); + } +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/mruset_tests.cpp b/src/test/mruset_tests.cpp new file mode 100644 index 0000000..64a6678 --- /dev/null +++ b/src/test/mruset_tests.cpp @@ -0,0 +1,90 @@ +#include + +using namespace std; + +#include "mruset.h" +#include "util.h" + +#define NUM_TESTS 16 +#define MAX_SIZE 100 + +class mrutester +{ +private: + mruset mru; + std::set set; + +public: + mrutester() { mru.max_size(MAX_SIZE); } + int size() const { return set.size(); } + + void insert(int n) + { + mru.insert(n); + set.insert(n); + BOOST_CHECK(mru == set); + } +}; + +BOOST_AUTO_TEST_SUITE(mruset_tests) + +// Test that an mruset behaves like a set, as long as no more than MAX_SIZE elements are in it +BOOST_AUTO_TEST_CASE(mruset_like_set) +{ + + for (int nTest=0; nTest mru(MAX_SIZE); + for (int nAction=0; nAction<3*MAX_SIZE; nAction++) + { + int n = GetRandInt(2 * MAX_SIZE); + mru.insert(n); + BOOST_CHECK(mru.size() <= MAX_SIZE); + } + } +} + +// 16-bit permutation function +int static permute(int n) +{ + // hexadecimals of pi; verified to be linearly independent + static const int table[16] = {0x243F, 0x6A88, 0x85A3, 0x08D3, 0x1319, 0x8A2E, 0x0370, 0x7344, + 0xA409, 0x3822, 0x299F, 0x31D0, 0x082E, 0xFA98, 0xEC4E, 0x6C89}; + + int ret = 0; + for (int bit=0; bit<16; bit++) + if (n & (1< mru(MAX_SIZE); + for (int n=0; n<10*MAX_SIZE; n++) + { + mru.insert(permute(n)); + + set tester; + for (int m=max(0,n-MAX_SIZE+1); m<=n; m++) + tester.insert(permute(m)); + + BOOST_CHECK(mru == tester); + } +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp new file mode 100644 index 0000000..e5a7562 --- /dev/null +++ b/src/test/netbase_tests.cpp @@ -0,0 +1,102 @@ +#include + +#include +#include + +#include "netbase.h" + +using namespace std; + +BOOST_AUTO_TEST_SUITE(netbase_tests) + +BOOST_AUTO_TEST_CASE(netbase_networks) +{ + BOOST_CHECK(CNetAddr("127.0.0.1").GetNetwork() == NET_UNROUTABLE); + BOOST_CHECK(CNetAddr("::1").GetNetwork() == NET_UNROUTABLE); + BOOST_CHECK(CNetAddr("8.8.8.8").GetNetwork() == NET_IPV4); + BOOST_CHECK(CNetAddr("2001::8888").GetNetwork() == NET_IPV6); + BOOST_CHECK(CNetAddr("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetNetwork() == NET_TOR); +} + +BOOST_AUTO_TEST_CASE(netbase_properties) +{ + BOOST_CHECK(CNetAddr("127.0.0.1").IsIPv4()); + BOOST_CHECK(CNetAddr("::FFFF:192.168.1.1").IsIPv4()); + BOOST_CHECK(CNetAddr("::1").IsIPv6()); + BOOST_CHECK(CNetAddr("10.0.0.1").IsRFC1918()); + BOOST_CHECK(CNetAddr("192.168.1.1").IsRFC1918()); + BOOST_CHECK(CNetAddr("172.31.255.255").IsRFC1918()); + BOOST_CHECK(CNetAddr("2001:0DB8::").IsRFC3849()); + BOOST_CHECK(CNetAddr("169.254.1.1").IsRFC3927()); + BOOST_CHECK(CNetAddr("2002::1").IsRFC3964()); + BOOST_CHECK(CNetAddr("FC00::").IsRFC4193()); + BOOST_CHECK(CNetAddr("2001::2").IsRFC4380()); + BOOST_CHECK(CNetAddr("2001:10::").IsRFC4843()); + BOOST_CHECK(CNetAddr("FE80::").IsRFC4862()); + BOOST_CHECK(CNetAddr("64:FF9B::").IsRFC6052()); + BOOST_CHECK(CNetAddr("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").IsTor()); + BOOST_CHECK(CNetAddr("127.0.0.1").IsLocal()); + BOOST_CHECK(CNetAddr("::1").IsLocal()); + BOOST_CHECK(CNetAddr("8.8.8.8").IsRoutable()); + BOOST_CHECK(CNetAddr("2001::1").IsRoutable()); + BOOST_CHECK(CNetAddr("127.0.0.1").IsValid()); +} + +bool static TestSplitHost(string test, string host, int port) +{ + string hostOut; + int portOut = -1; + SplitHostPort(test, portOut, hostOut); + return hostOut == host && port == portOut; +} + +BOOST_AUTO_TEST_CASE(netbase_splithost) +{ + BOOST_CHECK(TestSplitHost("www.bitcoin.org", "www.bitcoin.org", -1)); + BOOST_CHECK(TestSplitHost("[www.bitcoin.org]", "www.bitcoin.org", -1)); + BOOST_CHECK(TestSplitHost("www.bitcoin.org:80", "www.bitcoin.org", 80)); + BOOST_CHECK(TestSplitHost("[www.bitcoin.org]:80", "www.bitcoin.org", 80)); + BOOST_CHECK(TestSplitHost("127.0.0.1", "127.0.0.1", -1)); + BOOST_CHECK(TestSplitHost("127.0.0.1:8333", "127.0.0.1", 8333)); + BOOST_CHECK(TestSplitHost("[127.0.0.1]", "127.0.0.1", -1)); + BOOST_CHECK(TestSplitHost("[127.0.0.1]:8333", "127.0.0.1", 8333)); + BOOST_CHECK(TestSplitHost("::ffff:127.0.0.1", "::ffff:127.0.0.1", -1)); + BOOST_CHECK(TestSplitHost("[::ffff:127.0.0.1]:8333", "::ffff:127.0.0.1", 8333)); + BOOST_CHECK(TestSplitHost("[::]:8333", "::", 8333)); + BOOST_CHECK(TestSplitHost("::8333", "::8333", -1)); + BOOST_CHECK(TestSplitHost(":8333", "", 8333)); + BOOST_CHECK(TestSplitHost("[]:8333", "", 8333)); + BOOST_CHECK(TestSplitHost("", "", -1)); +} + +bool static TestParse(string src, string canon) +{ + CService addr; + if (!LookupNumeric(src.c_str(), addr, 65535)) + return canon == ""; + return canon == addr.ToString(); +} + +BOOST_AUTO_TEST_CASE(netbase_lookupnumeric) +{ + BOOST_CHECK(TestParse("127.0.0.1", "127.0.0.1:65535")); + BOOST_CHECK(TestParse("127.0.0.1:8333", "127.0.0.1:8333")); + BOOST_CHECK(TestParse("::ffff:127.0.0.1", "127.0.0.1:65535")); + BOOST_CHECK(TestParse("::", "[::]:65535")); + BOOST_CHECK(TestParse("[::]:8333", "[::]:8333")); + BOOST_CHECK(TestParse("[127.0.0.1]", "127.0.0.1:65535")); + BOOST_CHECK(TestParse(":::", "")); +} + +BOOST_AUTO_TEST_CASE(onioncat_test) +{ + // values from http://www.cypherpunk.at/onioncat/wiki/OnionCat + CNetAddr addr1("5wyqrzbvrdsumnok.onion"); + CNetAddr addr2("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca"); + BOOST_CHECK(addr1 == addr2); + BOOST_CHECK(addr1.IsTor()); + BOOST_CHECK(addr1.ToStringIP() == "5wyqrzbvrdsumnok.onion"); + BOOST_CHECK(addr1.IsRoutable()); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp new file mode 100644 index 0000000..90ac89f --- /dev/null +++ b/src/test/serialize_tests.cpp @@ -0,0 +1,45 @@ +#include + +#include +#include + +#include "serialize.h" + +using namespace std; + +BOOST_AUTO_TEST_SUITE(serialize_tests) + +BOOST_AUTO_TEST_CASE(varints) +{ + // encode + + CDataStream ss(SER_DISK, 0); + CDataStream::size_type size = 0; + for (int i = 0; i < 100000; i++) { + ss << VARINT(i); + size += ::GetSerializeSize(VARINT(i), 0, 0); + BOOST_CHECK(size == ss.size()); + } + + for (uint64 i = 0; i < 100000000000ULL; i += 999999937) { + ss << VARINT(i); + size += ::GetSerializeSize(VARINT(i), 0, 0); + BOOST_CHECK(size == ss.size()); + } + + // decode + for (int i = 0; i < 100000; i++) { + int j; + ss >> VARINT(j); + BOOST_CHECK_MESSAGE(i == j, "decoded:" << j << " expected:" << i); + } + + for (uint64 i = 0; i < 100000000000ULL; i += 999999937) { + uint64 j; + ss >> VARINT(j); + BOOST_CHECK_MESSAGE(i == j, "decoded:" << j << " expected:" << i); + } + +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/sigopcount_tests.cpp b/src/test/sigopcount_tests.cpp new file mode 100644 index 0000000..79b7c33 --- /dev/null +++ b/src/test/sigopcount_tests.cpp @@ -0,0 +1,60 @@ +#include +#include +#include + +#include "script.h" +#include "key.h" + +using namespace std; + +// Helpers: +static std::vector +Serialize(const CScript& s) +{ + std::vector sSerialized(s); + return sSerialized; +} + +BOOST_AUTO_TEST_SUITE(sigopcount_tests) + +BOOST_AUTO_TEST_CASE(GetSigOpCount) +{ + // Test CScript::GetSigOpCount() + CScript s1; + BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 0); + BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 0); + + uint160 dummy; + s1 << OP_1 << dummy << dummy << OP_2 << OP_CHECKMULTISIG; + BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 2); + s1 << OP_IF << OP_CHECKSIG << OP_ENDIF; + BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 3); + BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 21); + + CScript p2sh; + p2sh.SetDestination(s1.GetID()); + CScript scriptSig; + scriptSig << OP_0 << Serialize(s1); + BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig), 3); + + std::vector keys; + for (int i = 0; i < 3; i++) + { + CKey k; + k.MakeNewKey(true); + keys.push_back(k.GetPubKey()); + } + CScript s2; + s2.SetMultisig(1, keys); + BOOST_CHECK_EQUAL(s2.GetSigOpCount(true), 3); + BOOST_CHECK_EQUAL(s2.GetSigOpCount(false), 20); + + p2sh.SetDestination(s2.GetID()); + BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(true), 0); + BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(false), 0); + CScript scriptSig2; + scriptSig2 << OP_1 << dummy << dummy << Serialize(s2); + BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig2), 3); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/uint160_tests.cpp b/src/test/uint160_tests.cpp new file mode 100644 index 0000000..35cb35b --- /dev/null +++ b/src/test/uint160_tests.cpp @@ -0,0 +1,18 @@ +#include + +#include "uint256.h" + +BOOST_AUTO_TEST_SUITE(uint160_tests) + +BOOST_AUTO_TEST_CASE(uint160_equality) +{ + uint160 num1 = 10; + uint160 num2 = 11; + BOOST_CHECK(num1+1 == num2); + + uint64 num3 = 10; + BOOST_CHECK(num1 == num3); + BOOST_CHECK(num1+num2 == num3+num2); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp new file mode 100644 index 0000000..efdc8a6 --- /dev/null +++ b/src/test/uint256_tests.cpp @@ -0,0 +1,18 @@ +#include + +#include "uint256.h" + +BOOST_AUTO_TEST_SUITE(uint256_tests) + +BOOST_AUTO_TEST_CASE(uint256_equality) +{ + uint256 num1 = 10; + uint256 num2 = 11; + BOOST_CHECK(num1+1 == num2); + + uint64 num3 = 10; + BOOST_CHECK(num1 == num3); + BOOST_CHECK(num1+num2 == num3+num2); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/wallet_tests.cpp b/src/test/wallet_tests.cpp new file mode 100644 index 0000000..b0b3c47 --- /dev/null +++ b/src/test/wallet_tests.cpp @@ -0,0 +1,295 @@ +#include + +#include "main.h" +#include "wallet.h" + +// how many times to run all the tests to have a chance to catch errors that only show up with particular random shuffles +#define RUN_TESTS 100 + +// some tests fail 1% of the time due to bad luck. +// we repeat those tests this many times and only complain if all iterations of the test fail +#define RANDOM_REPEATS 5 + +using namespace std; + +typedef set > CoinSet; + +BOOST_AUTO_TEST_SUITE(wallet_tests) + +static CWallet wallet; +static vector vCoins; + +static void add_coin(int64 nValue, int nAge = 6*24, bool fIsFromMe = false, int nInput=0) +{ + static int i; + CTransaction* tx = new CTransaction; + tx->nLockTime = i++; // so all transactions get different hashes + tx->vout.resize(nInput+1); + tx->vout[nInput].nValue = nValue; + CWalletTx* wtx = new CWalletTx(&wallet, *tx); + delete tx; + if (fIsFromMe) + { + // IsFromMe() returns (GetDebit() > 0), and GetDebit() is 0 if vin.empty(), + // so stop vin being empty, and cache a non-zero Debit to fake out IsFromMe() + wtx->vin.resize(1); + wtx->fDebitCached = true; + wtx->nDebitCached = 1; + } + COutput output(wtx, nInput, nAge); + vCoins.push_back(output); +} + +static void empty_wallet(void) +{ + BOOST_FOREACH(COutput output, vCoins) + delete output.tx; + vCoins.clear(); +} + +static bool equal_sets(CoinSet a, CoinSet b) +{ + pair ret = mismatch(a.begin(), a.end(), b.begin()); + return ret.first == a.end() && ret.second == b.end(); +} + +BOOST_AUTO_TEST_CASE(coin_selection_tests) +{ + static CoinSet setCoinsRet, setCoinsRet2; + static int64 nValueRet; + + // test multiple times to allow for differences in the shuffle order + for (int i = 0; i < RUN_TESTS; i++) + { + empty_wallet(); + + // with an empty wallet we can't even pay one cent + BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet)); + + add_coin(1*CENT, 4); // add a new 1 cent coin + + // with a new 1 cent coin, we still can't find a mature 1 cent + BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet)); + + // but we can find a new 1 cent + BOOST_CHECK( wallet.SelectCoinsMinConf( 1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); + + add_coin(2*CENT); // add a mature 2 cent coin + + // we can't make 3 cents of mature coins + BOOST_CHECK(!wallet.SelectCoinsMinConf( 3 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet)); + + // we can make 3 cents of new coins + BOOST_CHECK( wallet.SelectCoinsMinConf( 3 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 3 * CENT); + + add_coin(5*CENT); // add a mature 5 cent coin, + add_coin(10*CENT, 3, true); // a new 10 cent coin sent from one of our own addresses + add_coin(20*CENT); // and a mature 20 cent coin + + // now we have new: 1+10=11 (of which 10 was self-sent), and mature: 2+5+20=27. total = 38 + + // we can't make 38 cents only if we disallow new coins: + BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet)); + // we can't even make 37 cents if we don't allow new coins even if they're from us + BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 6, 6, vCoins, setCoinsRet, nValueRet)); + // but we can make 37 cents if we accept new coins from ourself + BOOST_CHECK( wallet.SelectCoinsMinConf(37 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 37 * CENT); + // and we can make 38 cents if we accept all new coins + BOOST_CHECK( wallet.SelectCoinsMinConf(38 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 38 * CENT); + + // try making 34 cents from 1,2,5,10,20 - we can't do it exactly + BOOST_CHECK( wallet.SelectCoinsMinConf(34 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_GT(nValueRet, 34 * CENT); // but should get more than 34 cents + BOOST_CHECK_EQUAL(setCoinsRet.size(), 3); // the best should be 20+10+5. it's incredibly unlikely the 1 or 2 got included (but possible) + + // when we try making 7 cents, the smaller coins (1,2,5) are enough. We should see just 2+5 + BOOST_CHECK( wallet.SelectCoinsMinConf( 7 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 7 * CENT); + BOOST_CHECK_EQUAL(setCoinsRet.size(), 2); + + // when we try making 8 cents, the smaller coins (1,2,5) are exactly enough. + BOOST_CHECK( wallet.SelectCoinsMinConf( 8 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK(nValueRet == 8 * CENT); + BOOST_CHECK_EQUAL(setCoinsRet.size(), 3); + + // when we try making 9 cents, no subset of smaller coins is enough, and we get the next bigger coin (10) + BOOST_CHECK( wallet.SelectCoinsMinConf( 9 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 10 * CENT); + BOOST_CHECK_EQUAL(setCoinsRet.size(), 1); + + // now clear out the wallet and start again to test choosing between subsets of smaller coins and the next biggest coin + empty_wallet(); + + add_coin( 6*CENT); + add_coin( 7*CENT); + add_coin( 8*CENT); + add_coin(20*CENT); + add_coin(30*CENT); // now we have 6+7+8+20+30 = 71 cents total + + // check that we have 71 and not 72 + BOOST_CHECK( wallet.SelectCoinsMinConf(71 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK(!wallet.SelectCoinsMinConf(72 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + + // now try making 16 cents. the best smaller coins can do is 6+7+8 = 21; not as good at the next biggest coin, 20 + BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 20 * CENT); // we should get 20 in one coin + BOOST_CHECK_EQUAL(setCoinsRet.size(), 1); + + add_coin( 5*CENT); // now we have 5+6+7+8+20+30 = 75 cents total + + // now if we try making 16 cents again, the smaller coins can make 5+6+7 = 18 cents, better than the next biggest coin, 20 + BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 18 * CENT); // we should get 18 in 3 coins + BOOST_CHECK_EQUAL(setCoinsRet.size(), 3); + + add_coin( 18*CENT); // now we have 5+6+7+8+18+20+30 + + // and now if we try making 16 cents again, the smaller coins can make 5+6+7 = 18 cents, the same as the next biggest coin, 18 + BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 18 * CENT); // we should get 18 in 1 coin + BOOST_CHECK_EQUAL(setCoinsRet.size(), 1); // because in the event of a tie, the biggest coin wins + + // now try making 11 cents. we should get 5+6 + BOOST_CHECK( wallet.SelectCoinsMinConf(11 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 11 * CENT); + BOOST_CHECK_EQUAL(setCoinsRet.size(), 2); + + // check that the smallest bigger coin is used + add_coin( 1*COIN); + add_coin( 2*COIN); + add_coin( 3*COIN); + add_coin( 4*COIN); // now we have 5+6+7+8+18+20+30+100+200+300+400 = 1094 cents + BOOST_CHECK( wallet.SelectCoinsMinConf(95 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 1 * COIN); // we should get 1 BTC in 1 coin + BOOST_CHECK_EQUAL(setCoinsRet.size(), 1); + + BOOST_CHECK( wallet.SelectCoinsMinConf(195 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 2 * COIN); // we should get 2 BTC in 1 coin + BOOST_CHECK_EQUAL(setCoinsRet.size(), 1); + + // empty the wallet and start again, now with fractions of a cent, to test sub-cent change avoidance + empty_wallet(); + add_coin(0.1*CENT); + add_coin(0.2*CENT); + add_coin(0.3*CENT); + add_coin(0.4*CENT); + add_coin(0.5*CENT); + + // try making 1 cent from 0.1 + 0.2 + 0.3 + 0.4 + 0.5 = 1.5 cents + // we'll get sub-cent change whatever happens, so can expect 1.0 exactly + BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); + + // but if we add a bigger coin, making it possible to avoid sub-cent change, things change: + add_coin(1111*CENT); + + // try making 1 cent from 0.1 + 0.2 + 0.3 + 0.4 + 0.5 + 1111 = 1112.5 cents + BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); // we should get the exact amount + + // if we add more sub-cent coins: + add_coin(0.6*CENT); + add_coin(0.7*CENT); + + // and try again to make 1.0 cents, we can still make 1.0 cents + BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); // we should get the exact amount + + // run the 'mtgox' test (see http://blockexplorer.com/tx/29a3efd3ef04f9153d47a990bd7b048a4b2d213daaa5fb8ed670fb85f13bdbcf) + // they tried to consolidate 10 50k coins into one 500k coin, and ended up with 50k in change + empty_wallet(); + for (int i = 0; i < 20; i++) + add_coin(50000 * COIN); + + BOOST_CHECK( wallet.SelectCoinsMinConf(500000 * COIN, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 500000 * COIN); // we should get the exact amount + BOOST_CHECK_EQUAL(setCoinsRet.size(), 10); // in ten coins + + // if there's not enough in the smaller coins to make at least 1 cent change (0.5+0.6+0.7 < 1.0+1.0), + // we need to try finding an exact subset anyway + + // sometimes it will fail, and so we use the next biggest coin: + empty_wallet(); + add_coin(0.5 * CENT); + add_coin(0.6 * CENT); + add_coin(0.7 * CENT); + add_coin(1111 * CENT); + BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 1111 * CENT); // we get the bigger coin + BOOST_CHECK_EQUAL(setCoinsRet.size(), 1); + + // but sometimes it's possible, and we use an exact subset (0.4 + 0.6 = 1.0) + empty_wallet(); + add_coin(0.4 * CENT); + add_coin(0.6 * CENT); + add_coin(0.8 * CENT); + add_coin(1111 * CENT); + BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); // we should get the exact amount + BOOST_CHECK_EQUAL(setCoinsRet.size(), 2); // in two coins 0.4+0.6 + + // test avoiding sub-cent change + empty_wallet(); + add_coin(0.0005 * COIN); + add_coin(0.01 * COIN); + add_coin(1 * COIN); + + // trying to make 1.0001 from these three coins + BOOST_CHECK( wallet.SelectCoinsMinConf(1.0001 * COIN, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 1.0105 * COIN); // we should get all coins + BOOST_CHECK_EQUAL(setCoinsRet.size(), 3); + + // but if we try to make 0.999, we should take the bigger of the two small coins to avoid sub-cent change + BOOST_CHECK( wallet.SelectCoinsMinConf(0.999 * COIN, 1, 1, vCoins, setCoinsRet, nValueRet)); + BOOST_CHECK_EQUAL(nValueRet, 1.01 * COIN); // we should get 1 + 0.01 + BOOST_CHECK_EQUAL(setCoinsRet.size(), 2); + + // test randomness + { + empty_wallet(); + for (int i2 = 0; i2 < 100; i2++) + add_coin(COIN); + + // picking 50 from 100 coins doesn't depend on the shuffle, + // but does depend on randomness in the stochastic approximation code + BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, vCoins, setCoinsRet , nValueRet)); + BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, vCoins, setCoinsRet2, nValueRet)); + BOOST_CHECK(!equal_sets(setCoinsRet, setCoinsRet2)); + + int fails = 0; + for (int i = 0; i < RANDOM_REPEATS; i++) + { + // selecting 1 from 100 identical coins depends on the shuffle; this test will fail 1% of the time + // run the test RANDOM_REPEATS times and only complain if all of them fail + BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, vCoins, setCoinsRet , nValueRet)); + BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, vCoins, setCoinsRet2, nValueRet)); + if (equal_sets(setCoinsRet, setCoinsRet2)) + fails++; + } + BOOST_CHECK_NE(fails, RANDOM_REPEATS); + + // add 75 cents in small change. not enough to make 90 cents, + // then try making 90 cents. there are multiple competing "smallest bigger" coins, + // one of which should be picked at random + add_coin( 5*CENT); add_coin(10*CENT); add_coin(15*CENT); add_coin(20*CENT); add_coin(25*CENT); + + fails = 0; + for (int i = 0; i < RANDOM_REPEATS; i++) + { + // selecting 1 from 100 identical coins depends on the shuffle; this test will fail 1% of the time + // run the test RANDOM_REPEATS times and only complain if all of them fail + BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, vCoins, setCoinsRet , nValueRet)); + BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, vCoins, setCoinsRet2, nValueRet)); + if (equal_sets(setCoinsRet, setCoinsRet2)) + fails++; + } + BOOST_CHECK_NE(fails, RANDOM_REPEATS); + } + } +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/threadsafety.h b/src/threadsafety.h new file mode 100644 index 0000000..176060a --- /dev/null +++ b/src/threadsafety.h @@ -0,0 +1,54 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_THREADSAFETY_H +#define BITCOIN_THREADSAFETY_H + +#ifdef __clang__ +// TL;DR Add GUARDED_BY(mutex) to member variables. The others are +// rarely necessary. Ex: int nFoo GUARDED_BY(cs_foo); +// +// See http://clang.llvm.org/docs/LanguageExtensions.html#threadsafety +// for documentation. The clang compiler can do advanced static analysis +// of locking when given the -Wthread-safety option. +#define LOCKABLE __attribute__ ((lockable)) +#define SCOPED_LOCKABLE __attribute__ ((scoped_lockable)) +#define GUARDED_BY(x) __attribute__ ((guarded_by(x))) +#define GUARDED_VAR __attribute__ ((guarded_var)) +#define PT_GUARDED_BY(x) __attribute__ ((pt_guarded_by(x))) +#define PT_GUARDED_VAR __attribute__ ((pt_guarded_var)) +#define ACQUIRED_AFTER(...) __attribute__ ((acquired_after(__VA_ARGS__))) +#define ACQUIRED_BEFORE(...) __attribute__ ((acquired_before(__VA_ARGS__))) +#define EXCLUSIVE_LOCK_FUNCTION(...) __attribute__ ((exclusive_lock_function(__VA_ARGS__))) +#define SHARED_LOCK_FUNCTION(...) __attribute__ ((shared_lock_function(__VA_ARGS__))) +#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__ ((exclusive_trylock_function(__VA_ARGS__))) +#define SHARED_TRYLOCK_FUNCTION(...) __attribute__ ((shared_trylock_function(__VA_ARGS__))) +#define UNLOCK_FUNCTION(...) __attribute__ ((unlock_function(__VA_ARGS__))) +#define LOCK_RETURNED(x) __attribute__ ((lock_returned(x))) +#define LOCKS_EXCLUDED(...) __attribute__ ((locks_excluded(__VA_ARGS__))) +#define EXCLUSIVE_LOCKS_REQUIRED(...) __attribute__ ((exclusive_locks_required(__VA_ARGS__))) +#define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__))) +#define NO_THREAD_SAFETY_ANALYSIS __attribute__ ((no_thread_safety_analysis)) +#else +#define LOCKABLE +#define SCOPED_LOCKABLE +#define GUARDED_BY(x) +#define GUARDED_VAR +#define PT_GUARDED_BY(x) +#define PT_GUARDED_VAR +#define ACQUIRED_AFTER(...) +#define ACQUIRED_BEFORE(...) +#define EXCLUSIVE_LOCK_FUNCTION(...) +#define SHARED_LOCK_FUNCTION(...) +#define EXCLUSIVE_TRYLOCK_FUNCTION(...) +#define SHARED_TRYLOCK_FUNCTION(...) +#define UNLOCK_FUNCTION(...) +#define LOCK_RETURNED(x) +#define LOCKS_EXCLUDED(...) +#define EXCLUSIVE_LOCKS_REQUIRED(...) +#define SHARED_LOCKS_REQUIRED(...) +#define NO_THREAD_SAFETY_ANALYSIS +#endif // __GNUC__ +#endif // BITCOIN_THREADSAFETY_H diff --git a/src/timedata.cpp b/src/timedata.cpp new file mode 100644 index 0000000..93c1791 --- /dev/null +++ b/src/timedata.cpp @@ -0,0 +1,109 @@ +// Copyright (c) 2014 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "timedata.h" + +#include "netbase.h" +#include "sync.h" +#include "ui_interface.h" +#include "util.h" + +#include + +using namespace std; + +static CCriticalSection cs_nTimeOffset; +static int64_t nTimeOffset = 0; + +// +// "Never go to sea with two chronometers; take one or three." +// Our three time sources are: +// - System clock +// - Median of other nodes clocks +// - The user (asking the user to fix the system clock if the first two disagree) +// +// +int64_t GetTimeOffset() +{ + LOCK(cs_nTimeOffset); + return nTimeOffset; +} + +int64_t GetAdjustedTime() +{ + return GetTime() + GetTimeOffset(); +} + +void AddTimeData(const CNetAddr& ip, int64_t nTime) +{ + int64_t nOffsetSample = nTime - GetTime(); + + LOCK(cs_nTimeOffset); + // Ignore duplicates + static set setKnown; + if (!setKnown.insert(ip).second) + return; + + // Add data + static CMedianFilter vTimeOffsets(200,0); + vTimeOffsets.input(nOffsetSample); + LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); + + // There is a known issue here (see issue #4521): + // + // - The structure vTimeOffsets contains up to 200 elements, after which + // any new element added to it will not increase its size, replacing the + // oldest element. + // + // - The condition to update nTimeOffset includes checking whether the + // number of elements in vTimeOffsets is odd, which will never happen after + // there are 200 elements. + // + // But in this case the 'bug' is protective against some attacks, and may + // actually explain why we've never seen attacks which manipulate the + // clock offset. + // + // So we should hold off on fixing this and clean it up as part of + // a timing cleanup that strengthens it in a number of other ways. + // + if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1) + { + int64_t nMedian = vTimeOffsets.median(); + std::vector vSorted = vTimeOffsets.sorted(); + // Only let other nodes change our time by so much + if (abs64(nMedian) < 70 * 60) + { + nTimeOffset = nMedian; + } + else + { + nTimeOffset = 0; + + static bool fDone; + if (!fDone) + { + // If nobody has a time different than ours but within 5 minutes of ours, give a warning + bool fMatch = false; + BOOST_FOREACH(int64_t nOffset, vSorted) + if (nOffset != 0 && abs64(nOffset) < 5 * 60) + fMatch = true; + + if (!fMatch) + { + fDone = true; + string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong SONO will not work properly."); + strMiscWarning = strMessage; + LogPrintf("*** %s\n", strMessage); + uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING); + } + } + } + if (fDebug) { + BOOST_FOREACH(int64_t n, vSorted) + LogPrintf("%+d ", n); + LogPrintf("| "); + } + LogPrintf("nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60); + } +} diff --git a/src/timedata.h b/src/timedata.h new file mode 100644 index 0000000..0e7bdc2 --- /dev/null +++ b/src/timedata.h @@ -0,0 +1,17 @@ +// Copyright (c) 2014 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_TIMEDATA_H +#define BITCOIN_TIMEDATA_H + +#include + +class CNetAddr; + +/* Functions to keep track of adjusted P2P time */ +int64_t GetTimeOffset(); +int64_t GetAdjustedTime(); +void AddTimeData(const CNetAddr& ip, int64_t nTime); + +#endif diff --git a/src/tinyformat.h b/src/tinyformat.h new file mode 100644 index 0000000..73d49a1 --- /dev/null +++ b/src/tinyformat.h @@ -0,0 +1,1013 @@ +// tinyformat.h +// Copyright (C) 2011, Chris Foster [chris42f (at) gmail (d0t) com] +// +// Boost Software License - Version 1.0 +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +//------------------------------------------------------------------------------ +// Tinyformat: A minimal type safe printf replacement +// +// tinyformat.h is a type safe printf replacement library in a single C++ +// header file. Design goals include: +// +// * Type safety and extensibility for user defined types. +// * C99 printf() compatibility, to the extent possible using std::ostream +// * Simplicity and minimalism. A single header file to include and distribute +// with your projects. +// * Augment rather than replace the standard stream formatting mechanism +// * C++98 support, with optional C++11 niceties +// +// +// Main interface example usage +// ---------------------------- +// +// To print a date to std::cout: +// +// std::string weekday = "Wednesday"; +// const char* month = "July"; +// size_t day = 27; +// long hour = 14; +// int min = 44; +// +// tfm::printf("%s, %s %d, %.2d:%.2d\n", weekday, month, day, hour, min); +// +// The strange types here emphasize the type safety of the interface; it is +// possible to print a std::string using the "%s" conversion, and a +// size_t using the "%d" conversion. A similar result could be achieved +// using either of the tfm::format() functions. One prints on a user provided +// stream: +// +// tfm::format(std::cerr, "%s, %s %d, %.2d:%.2d\n", +// weekday, month, day, hour, min); +// +// The other returns a std::string: +// +// std::string date = tfm::format("%s, %s %d, %.2d:%.2d\n", +// weekday, month, day, hour, min); +// std::cout << date; +// +// These are the three primary interface functions. +// +// +// User defined format functions +// ----------------------------- +// +// Simulating variadic templates in C++98 is pretty painful since it requires +// writing out the same function for each desired number of arguments. To make +// this bearable tinyformat comes with a set of macros which are used +// internally to generate the API, but which may also be used in user code. +// +// The three macros TINYFORMAT_ARGTYPES(n), TINYFORMAT_VARARGS(n) and +// TINYFORMAT_PASSARGS(n) will generate a list of n argument types, +// type/name pairs and argument names respectively when called with an integer +// n between 1 and 16. We can use these to define a macro which generates the +// desired user defined function with n arguments. To generate all 16 user +// defined function bodies, use the macro TINYFORMAT_FOREACH_ARGNUM. For an +// example, see the implementation of printf() at the end of the source file. +// +// +// Additional API information +// -------------------------- +// +// Error handling: Define TINYFORMAT_ERROR to customize the error handling for +// format strings which are unsupported or have the wrong number of format +// specifiers (calls assert() by default). +// +// User defined types: Uses operator<< for user defined types by default. +// Overload formatValue() for more control. + + +#ifndef TINYFORMAT_H_INCLUDED +#define TINYFORMAT_H_INCLUDED + +namespace tinyformat {} +//------------------------------------------------------------------------------ +// Config section. Customize to your liking! + +// Namespace alias to encourage brevity +namespace tfm = tinyformat; + +// Error handling; calls assert() by default. +#define TINYFORMAT_ERROR(reasonString) throw std::runtime_error(reasonString) + +// Define for C++11 variadic templates which make the code shorter & more +// general. If you don't define this, C++11 support is autodetected below. +// #define TINYFORMAT_USE_VARIADIC_TEMPLATES + + +//------------------------------------------------------------------------------ +// Implementation details. +#include +#include +#include +#include + +#ifndef TINYFORMAT_ERROR +# define TINYFORMAT_ERROR(reason) assert(0 && reason) +#endif + +#if !defined(TINYFORMAT_USE_VARIADIC_TEMPLATES) && !defined(TINYFORMAT_NO_VARIADIC_TEMPLATES) +# ifdef __GXX_EXPERIMENTAL_CXX0X__ +# define TINYFORMAT_USE_VARIADIC_TEMPLATES +# endif +#endif + +#ifdef __GNUC__ +# define TINYFORMAT_NOINLINE __attribute__((noinline)) +#elif defined(_MSC_VER) +# define TINYFORMAT_NOINLINE __declspec(noinline) +#else +# define TINYFORMAT_NOINLINE +#endif + +#if defined(__GLIBCXX__) && __GLIBCXX__ < 20080201 +// std::showpos is broken on old libstdc++ as provided with OSX. See +// http://gcc.gnu.org/ml/libstdc++/2007-11/msg00075.html +# define TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND +#endif + +namespace tinyformat { + +//------------------------------------------------------------------------------ +namespace detail { + +// Test whether type T1 is convertible to type T2 +template +struct is_convertible +{ + private: + // two types of different size + struct fail { char dummy[2]; }; + struct succeed { char dummy; }; + // Try to convert a T1 to a T2 by plugging into tryConvert + static fail tryConvert(...); + static succeed tryConvert(const T2&); + static const T1& makeT1(); + public: +# ifdef _MSC_VER + // Disable spurious loss of precision warnings in tryConvert(makeT1()) +# pragma warning(push) +# pragma warning(disable:4244) +# pragma warning(disable:4267) +# endif + // Standard trick: the (...) version of tryConvert will be chosen from + // the overload set only if the version taking a T2 doesn't match. + // Then we compare the sizes of the return types to check which + // function matched. Very neat, in a disgusting kind of way :) + static const bool value = + sizeof(tryConvert(makeT1())) == sizeof(succeed); +# ifdef _MSC_VER +# pragma warning(pop) +# endif +}; + + +// Detect when a type is not a wchar_t string +template struct is_wchar { typedef int tinyformat_wchar_is_not_supported; }; +template<> struct is_wchar {}; +template<> struct is_wchar {}; +template struct is_wchar {}; +template struct is_wchar {}; + + +// Format the value by casting to type fmtT. This default implementation +// should never be called. +template::value> +struct formatValueAsType +{ + static void invoke(std::ostream& /*out*/, const T& /*value*/) { assert(0); } +}; +// Specialized version for types that can actually be converted to fmtT, as +// indicated by the "convertible" template parameter. +template +struct formatValueAsType +{ + static void invoke(std::ostream& out, const T& value) + { out << static_cast(value); } +}; + +#ifdef TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND +template::value> +struct formatZeroIntegerWorkaround +{ + static bool invoke(std::ostream& /**/, const T& /**/) { return false; } +}; +template +struct formatZeroIntegerWorkaround +{ + static bool invoke(std::ostream& out, const T& value) + { + if (static_cast(value) == 0 && out.flags() & std::ios::showpos) + { + out << "+0"; + return true; + } + return false; + } +}; +#endif // TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND + +// Convert an arbitrary type to integer. The version with convertible=false +// throws an error. +template::value> +struct convertToInt +{ + static int invoke(const T& /*value*/) + { + TINYFORMAT_ERROR("tinyformat: Cannot convert from argument type to " + "integer for use as variable width or precision"); + return 0; + } +}; +// Specialization for convertToInt when conversion is possible +template +struct convertToInt +{ + static int invoke(const T& value) { return static_cast(value); } +}; + +} // namespace detail + + +//------------------------------------------------------------------------------ +// Variable formatting functions. May be overridden for user-defined types if +// desired. + + +// Format a value into a stream. Called from format() for all types by default. +// +// Users may override this for their own types. When this function is called, +// the stream flags will have been modified according to the format string. +// The format specification is provided in the range [fmtBegin, fmtEnd). +// +// By default, formatValue() uses the usual stream insertion operator +// operator<< to format the type T, with special cases for the %c and %p +// conversions. +template +inline void formatValue(std::ostream& out, const char* /*fmtBegin*/, + const char* fmtEnd, const T& value) +{ +#ifndef TINYFORMAT_ALLOW_WCHAR_STRINGS + // Since we don't support printing of wchar_t using "%ls", make it fail at + // compile time in preference to printing as a void* at runtime. + typedef typename detail::is_wchar::tinyformat_wchar_is_not_supported DummyType; + (void) DummyType(); // avoid unused type warning with gcc-4.8 +#endif + // The mess here is to support the %c and %p conversions: if these + // conversions are active we try to convert the type to a char or const + // void* respectively and format that instead of the value itself. For the + // %p conversion it's important to avoid dereferencing the pointer, which + // could otherwise lead to a crash when printing a dangling (const char*). + const bool canConvertToChar = detail::is_convertible::value; + const bool canConvertToVoidPtr = detail::is_convertible::value; + if(canConvertToChar && *(fmtEnd-1) == 'c') + detail::formatValueAsType::invoke(out, value); + else if(canConvertToVoidPtr && *(fmtEnd-1) == 'p') + detail::formatValueAsType::invoke(out, value); +#ifdef TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND + else if(detail::formatZeroIntegerWorkaround::invoke(out, value)) /**/; +#endif + else + out << value; +} + + +// Overloaded version for char types to support printing as an integer +#define TINYFORMAT_DEFINE_FORMATVALUE_CHAR(charType) \ +inline void formatValue(std::ostream& out, const char* /*fmtBegin*/, \ + const char* fmtEnd, charType value) \ +{ \ + switch(*(fmtEnd-1)) \ + { \ + case 'u': case 'd': case 'i': case 'o': case 'X': case 'x': \ + out << static_cast(value); break; \ + default: \ + out << value; break; \ + } \ +} +// per 3.9.1: char, signed char and unsigned char are all distinct types +TINYFORMAT_DEFINE_FORMATVALUE_CHAR(char) +TINYFORMAT_DEFINE_FORMATVALUE_CHAR(signed char) +TINYFORMAT_DEFINE_FORMATVALUE_CHAR(unsigned char) +#undef TINYFORMAT_DEFINE_FORMATVALUE_CHAR + + +//------------------------------------------------------------------------------ +// Tools for emulating variadic templates in C++98. The basic idea here is +// stolen from the boost preprocessor metaprogramming library and cut down to +// be just general enough for what we need. + +#define TINYFORMAT_ARGTYPES(n) TINYFORMAT_ARGTYPES_ ## n +#define TINYFORMAT_VARARGS(n) TINYFORMAT_VARARGS_ ## n +#define TINYFORMAT_PASSARGS(n) TINYFORMAT_PASSARGS_ ## n +#define TINYFORMAT_PASSARGS_TAIL(n) TINYFORMAT_PASSARGS_TAIL_ ## n + +// To keep it as transparent as possible, the macros below have been generated +// using python via the excellent cog.py code generation script. This avoids +// the need for a bunch of complex (but more general) preprocessor tricks as +// used in boost.preprocessor. +// +// To rerun the code generation in place, use `cog.py -r tinyformat.h` +// (see http://nedbatchelder.com/code/cog). Alternatively you can just create +// extra versions by hand. + +/*[[[cog +maxParams = 16 + +def makeCommaSepLists(lineTemplate, elemTemplate, startInd=1): + for j in range(startInd,maxParams+1): + list = ', '.join([elemTemplate % {'i':i} for i in range(startInd,j+1)]) + cog.outl(lineTemplate % {'j':j, 'list':list}) + +makeCommaSepLists('#define TINYFORMAT_ARGTYPES_%(j)d %(list)s', + 'class T%(i)d') + +cog.outl() +makeCommaSepLists('#define TINYFORMAT_VARARGS_%(j)d %(list)s', + 'const T%(i)d& v%(i)d') + +cog.outl() +makeCommaSepLists('#define TINYFORMAT_PASSARGS_%(j)d %(list)s', 'v%(i)d') + +cog.outl() +cog.outl('#define TINYFORMAT_PASSARGS_TAIL_1') +makeCommaSepLists('#define TINYFORMAT_PASSARGS_TAIL_%(j)d , %(list)s', + 'v%(i)d', startInd = 2) + +cog.outl() +cog.outl('#define TINYFORMAT_FOREACH_ARGNUM(m) \\\n ' + + ' '.join(['m(%d)' % (j,) for j in range(1,maxParams+1)])) +]]]*/ +#define TINYFORMAT_ARGTYPES_1 class T1 +#define TINYFORMAT_ARGTYPES_2 class T1, class T2 +#define TINYFORMAT_ARGTYPES_3 class T1, class T2, class T3 +#define TINYFORMAT_ARGTYPES_4 class T1, class T2, class T3, class T4 +#define TINYFORMAT_ARGTYPES_5 class T1, class T2, class T3, class T4, class T5 +#define TINYFORMAT_ARGTYPES_6 class T1, class T2, class T3, class T4, class T5, class T6 +#define TINYFORMAT_ARGTYPES_7 class T1, class T2, class T3, class T4, class T5, class T6, class T7 +#define TINYFORMAT_ARGTYPES_8 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8 +#define TINYFORMAT_ARGTYPES_9 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9 +#define TINYFORMAT_ARGTYPES_10 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10 +#define TINYFORMAT_ARGTYPES_11 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11 +#define TINYFORMAT_ARGTYPES_12 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12 +#define TINYFORMAT_ARGTYPES_13 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13 +#define TINYFORMAT_ARGTYPES_14 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14 +#define TINYFORMAT_ARGTYPES_15 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15 +#define TINYFORMAT_ARGTYPES_16 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15, class T16 + +#define TINYFORMAT_VARARGS_1 const T1& v1 +#define TINYFORMAT_VARARGS_2 const T1& v1, const T2& v2 +#define TINYFORMAT_VARARGS_3 const T1& v1, const T2& v2, const T3& v3 +#define TINYFORMAT_VARARGS_4 const T1& v1, const T2& v2, const T3& v3, const T4& v4 +#define TINYFORMAT_VARARGS_5 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5 +#define TINYFORMAT_VARARGS_6 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6 +#define TINYFORMAT_VARARGS_7 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7 +#define TINYFORMAT_VARARGS_8 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8 +#define TINYFORMAT_VARARGS_9 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9 +#define TINYFORMAT_VARARGS_10 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10 +#define TINYFORMAT_VARARGS_11 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11 +#define TINYFORMAT_VARARGS_12 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12 +#define TINYFORMAT_VARARGS_13 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13 +#define TINYFORMAT_VARARGS_14 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14 +#define TINYFORMAT_VARARGS_15 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14, const T15& v15 +#define TINYFORMAT_VARARGS_16 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14, const T15& v15, const T16& v16 + +#define TINYFORMAT_PASSARGS_1 v1 +#define TINYFORMAT_PASSARGS_2 v1, v2 +#define TINYFORMAT_PASSARGS_3 v1, v2, v3 +#define TINYFORMAT_PASSARGS_4 v1, v2, v3, v4 +#define TINYFORMAT_PASSARGS_5 v1, v2, v3, v4, v5 +#define TINYFORMAT_PASSARGS_6 v1, v2, v3, v4, v5, v6 +#define TINYFORMAT_PASSARGS_7 v1, v2, v3, v4, v5, v6, v7 +#define TINYFORMAT_PASSARGS_8 v1, v2, v3, v4, v5, v6, v7, v8 +#define TINYFORMAT_PASSARGS_9 v1, v2, v3, v4, v5, v6, v7, v8, v9 +#define TINYFORMAT_PASSARGS_10 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10 +#define TINYFORMAT_PASSARGS_11 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11 +#define TINYFORMAT_PASSARGS_12 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12 +#define TINYFORMAT_PASSARGS_13 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13 +#define TINYFORMAT_PASSARGS_14 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 +#define TINYFORMAT_PASSARGS_15 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 +#define TINYFORMAT_PASSARGS_16 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16 + +#define TINYFORMAT_PASSARGS_TAIL_1 +#define TINYFORMAT_PASSARGS_TAIL_2 , v2 +#define TINYFORMAT_PASSARGS_TAIL_3 , v2, v3 +#define TINYFORMAT_PASSARGS_TAIL_4 , v2, v3, v4 +#define TINYFORMAT_PASSARGS_TAIL_5 , v2, v3, v4, v5 +#define TINYFORMAT_PASSARGS_TAIL_6 , v2, v3, v4, v5, v6 +#define TINYFORMAT_PASSARGS_TAIL_7 , v2, v3, v4, v5, v6, v7 +#define TINYFORMAT_PASSARGS_TAIL_8 , v2, v3, v4, v5, v6, v7, v8 +#define TINYFORMAT_PASSARGS_TAIL_9 , v2, v3, v4, v5, v6, v7, v8, v9 +#define TINYFORMAT_PASSARGS_TAIL_10 , v2, v3, v4, v5, v6, v7, v8, v9, v10 +#define TINYFORMAT_PASSARGS_TAIL_11 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11 +#define TINYFORMAT_PASSARGS_TAIL_12 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12 +#define TINYFORMAT_PASSARGS_TAIL_13 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13 +#define TINYFORMAT_PASSARGS_TAIL_14 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 +#define TINYFORMAT_PASSARGS_TAIL_15 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 +#define TINYFORMAT_PASSARGS_TAIL_16 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16 + +#define TINYFORMAT_FOREACH_ARGNUM(m) \ + m(1) m(2) m(3) m(4) m(5) m(6) m(7) m(8) m(9) m(10) m(11) m(12) m(13) m(14) m(15) m(16) +//[[[end]]] + + + +namespace detail { + +// Class holding current position in format string and an output stream into +// which arguments are formatted. +class FormatIterator +{ + public: + // Flags for features not representable with standard stream state + enum ExtraFormatFlags + { + Flag_None = 0, + Flag_TruncateToPrecision = 1<<0, // truncate length to stream precision() + Flag_SpacePadPositive = 1<<1, // pad positive values with spaces + Flag_VariableWidth = 1<<2, // variable field width in arg list + Flag_VariablePrecision = 1<<3 // variable field precision in arg list + }; + + // out is the output stream, fmt is the full format string + FormatIterator(std::ostream& out, const char* fmt) + : m_out(out), + m_fmt(fmt), + m_extraFlags(Flag_None), + m_wantWidth(false), + m_wantPrecision(false), + m_variableWidth(0), + m_variablePrecision(0), + m_origWidth(out.width()), + m_origPrecision(out.precision()), + m_origFlags(out.flags()), + m_origFill(out.fill()) + { } + + // Print remaining part of format string. + void finish() + { + // It would be nice if we could do this from the destructor, but we + // can't if TINFORMAT_ERROR is used to throw an exception! + m_fmt = printFormatStringLiteral(m_out, m_fmt); + if(*m_fmt != '\0') + TINYFORMAT_ERROR("tinyformat: Too many conversion specifiers in format string"); + } + + ~FormatIterator() + { + // Restore stream state + m_out.width(m_origWidth); + m_out.precision(m_origPrecision); + m_out.flags(m_origFlags); + m_out.fill(m_origFill); + } + + template + void accept(const T& value); + + private: + // Parse and return an integer from the string c, as atoi() + // On return, c is set to one past the end of the integer. + static int parseIntAndAdvance(const char*& c) + { + int i = 0; + for(;*c >= '0' && *c <= '9'; ++c) + i = 10*i + (*c - '0'); + return i; + } + + // Format at most truncLen characters of a C string to the given + // stream. Return true if formatting proceeded (generic version always + // returns false) + template + static bool formatCStringTruncate(std::ostream& /*out*/, const T& /*value*/, + std::streamsize /*truncLen*/) + { + return false; + } +# define TINYFORMAT_DEFINE_FORMAT_C_STRING_TRUNCATE(type) \ + static bool formatCStringTruncate(std::ostream& out, type* value, \ + std::streamsize truncLen) \ + { \ + std::streamsize len = 0; \ + while(len < truncLen && value[len] != 0) \ + ++len; \ + out.write(value, len); \ + return true; \ + } + // Overload for const char* and char*. Could overload for signed & + // unsigned char too, but these are technically unneeded for printf + // compatibility. + TINYFORMAT_DEFINE_FORMAT_C_STRING_TRUNCATE(const char) + TINYFORMAT_DEFINE_FORMAT_C_STRING_TRUNCATE(char) +# undef TINYFORMAT_DEFINE_FORMAT_C_STRING_TRUNCATE + + // Print literal part of format string and return next format spec + // position. + // + // Skips over any occurrences of '%%', printing a literal '%' to the + // output. The position of the first % character of the next + // nontrivial format spec is returned, or the end of string. + static const char* printFormatStringLiteral(std::ostream& out, + const char* fmt) + { + const char* c = fmt; + for(; true; ++c) + { + switch(*c) + { + case '\0': + out.write(fmt, static_cast(c - fmt)); + return c; + case '%': + out.write(fmt, static_cast(c - fmt)); + if(*(c+1) != '%') + return c; + // for "%%", tack trailing % onto next literal section. + fmt = ++c; + break; + } + } + } + + static const char* streamStateFromFormat(std::ostream& out, + unsigned int& extraFlags, + const char* fmtStart, + int variableWidth, + int variablePrecision); + + // Private copy & assign: Kill gcc warnings with -Weffc++ + FormatIterator(const FormatIterator&); + FormatIterator& operator=(const FormatIterator&); + + // Stream, current format string & state + std::ostream& m_out; + const char* m_fmt; + unsigned int m_extraFlags; + // State machine info for handling of variable width & precision + bool m_wantWidth; + bool m_wantPrecision; + int m_variableWidth; + int m_variablePrecision; + // Saved stream state + std::streamsize m_origWidth; + std::streamsize m_origPrecision; + std::ios::fmtflags m_origFlags; + char m_origFill; +}; + + +// Accept a value for formatting into the internal stream. +template +TINYFORMAT_NOINLINE // < greatly reduces bloat in optimized builds +void FormatIterator::accept(const T& value) +{ + // Parse the format string + const char* fmtEnd = 0; + if(m_extraFlags == Flag_None && !m_wantWidth && !m_wantPrecision) + { + m_fmt = printFormatStringLiteral(m_out, m_fmt); + fmtEnd = streamStateFromFormat(m_out, m_extraFlags, m_fmt, 0, 0); + m_wantWidth = (m_extraFlags & Flag_VariableWidth) != 0; + m_wantPrecision = (m_extraFlags & Flag_VariablePrecision) != 0; + } + // Consume value as variable width and precision specifier if necessary + if(m_extraFlags & (Flag_VariableWidth | Flag_VariablePrecision)) + { + if(m_wantWidth || m_wantPrecision) + { + int v = convertToInt::invoke(value); + if(m_wantWidth) + { + m_variableWidth = v; + m_wantWidth = false; + } + else if(m_wantPrecision) + { + m_variablePrecision = v; + m_wantPrecision = false; + } + return; + } + // If we get here, we've set both the variable precision and width as + // required and we need to rerun the stream state setup to insert these. + fmtEnd = streamStateFromFormat(m_out, m_extraFlags, m_fmt, + m_variableWidth, m_variablePrecision); + } + + // Format the value into the stream. + if(!(m_extraFlags & (Flag_SpacePadPositive | Flag_TruncateToPrecision))) + formatValue(m_out, m_fmt, fmtEnd, value); + else + { + // The following are special cases where there's no direct + // correspondence between stream formatting and the printf() behaviour. + // Instead, we simulate the behaviour crudely by formatting into a + // temporary string stream and munging the resulting string. + std::ostringstream tmpStream; + tmpStream.copyfmt(m_out); + if(m_extraFlags & Flag_SpacePadPositive) + tmpStream.setf(std::ios::showpos); + // formatCStringTruncate is required for truncating conversions like + // "%.4s" where at most 4 characters of the c-string should be read. + // If we didn't include this special case, we might read off the end. + if(!( (m_extraFlags & Flag_TruncateToPrecision) && + formatCStringTruncate(tmpStream, value, m_out.precision()) )) + { + // Not a truncated c-string; just format normally. + formatValue(tmpStream, m_fmt, fmtEnd, value); + } + std::string result = tmpStream.str(); // allocates... yuck. + if(m_extraFlags & Flag_SpacePadPositive) + { + for(size_t i = 0, iend = result.size(); i < iend; ++i) + if(result[i] == '+') + result[i] = ' '; + } + if((m_extraFlags & Flag_TruncateToPrecision) && + (int)result.size() > (int)m_out.precision()) + m_out.write(result.c_str(), m_out.precision()); + else + m_out << result; + } + m_extraFlags = Flag_None; + m_fmt = fmtEnd; +} + + +// Parse a format string and set the stream state accordingly. +// +// The format mini-language recognized here is meant to be the one from C99, +// with the form "%[flags][width][.precision][length]type". +// +// Formatting options which can't be natively represented using the ostream +// state are returned in the extraFlags parameter which is a bitwise +// combination of values from the ExtraFormatFlags enum. +inline const char* FormatIterator::streamStateFromFormat(std::ostream& out, + unsigned int& extraFlags, + const char* fmtStart, + int variableWidth, + int variablePrecision) +{ + if(*fmtStart != '%') + { + TINYFORMAT_ERROR("tinyformat: Not enough conversion specifiers in format string"); + return fmtStart; + } + // Reset stream state to defaults. + out.width(0); + out.precision(6); + out.fill(' '); + // Reset most flags; ignore irrelevant unitbuf & skipws. + out.unsetf(std::ios::adjustfield | std::ios::basefield | + std::ios::floatfield | std::ios::showbase | std::ios::boolalpha | + std::ios::showpoint | std::ios::showpos | std::ios::uppercase); + extraFlags = Flag_None; + bool precisionSet = false; + bool widthSet = false; + const char* c = fmtStart + 1; + // 1) Parse flags + for(;; ++c) + { + switch(*c) + { + case '#': + out.setf(std::ios::showpoint | std::ios::showbase); + continue; + case '0': + // overridden by left alignment ('-' flag) + if(!(out.flags() & std::ios::left)) + { + // Use internal padding so that numeric values are + // formatted correctly, eg -00010 rather than 000-10 + out.fill('0'); + out.setf(std::ios::internal, std::ios::adjustfield); + } + continue; + case '-': + out.fill(' '); + out.setf(std::ios::left, std::ios::adjustfield); + continue; + case ' ': + // overridden by show positive sign, '+' flag. + if(!(out.flags() & std::ios::showpos)) + extraFlags |= Flag_SpacePadPositive; + continue; + case '+': + out.setf(std::ios::showpos); + extraFlags &= ~Flag_SpacePadPositive; + continue; + } + break; + } + // 2) Parse width + if(*c >= '0' && *c <= '9') + { + widthSet = true; + out.width(parseIntAndAdvance(c)); + } + if(*c == '*') + { + widthSet = true; + if(variableWidth < 0) + { + // negative widths correspond to '-' flag set + out.fill(' '); + out.setf(std::ios::left, std::ios::adjustfield); + variableWidth = -variableWidth; + } + out.width(variableWidth); + extraFlags |= Flag_VariableWidth; + ++c; + } + // 3) Parse precision + if(*c == '.') + { + ++c; + int precision = 0; + if(*c == '*') + { + ++c; + extraFlags |= Flag_VariablePrecision; + precision = variablePrecision; + } + else + { + if(*c >= '0' && *c <= '9') + precision = parseIntAndAdvance(c); + else if(*c == '-') // negative precisions ignored, treated as zero. + parseIntAndAdvance(++c); + } + out.precision(precision); + precisionSet = true; + } + // 4) Ignore any C99 length modifier + while(*c == 'l' || *c == 'h' || *c == 'L' || + *c == 'j' || *c == 'z' || *c == 't') + ++c; + // 5) We're up to the conversion specifier character. + // Set stream flags based on conversion specifier (thanks to the + // boost::format class for forging the way here). + bool intConversion = false; + switch(*c) + { + case 'u': case 'd': case 'i': + out.setf(std::ios::dec, std::ios::basefield); + intConversion = true; + break; + case 'o': + out.setf(std::ios::oct, std::ios::basefield); + intConversion = true; + break; + case 'X': + out.setf(std::ios::uppercase); + case 'x': case 'p': + out.setf(std::ios::hex, std::ios::basefield); + intConversion = true; + break; + case 'E': + out.setf(std::ios::uppercase); + case 'e': + out.setf(std::ios::scientific, std::ios::floatfield); + out.setf(std::ios::dec, std::ios::basefield); + break; + case 'F': + out.setf(std::ios::uppercase); + case 'f': + out.setf(std::ios::fixed, std::ios::floatfield); + break; + case 'G': + out.setf(std::ios::uppercase); + case 'g': + out.setf(std::ios::dec, std::ios::basefield); + // As in boost::format, let stream decide float format. + out.flags(out.flags() & ~std::ios::floatfield); + break; + case 'a': case 'A': + TINYFORMAT_ERROR("tinyformat: the %a and %A conversion specs " + "are not supported"); + break; + case 'c': + // Handled as special case inside formatValue() + break; + case 's': + if(precisionSet) + extraFlags |= Flag_TruncateToPrecision; + // Make %s print booleans as "true" and "false" + out.setf(std::ios::boolalpha); + break; + case 'n': + // Not supported - will cause problems! + TINYFORMAT_ERROR("tinyformat: %n conversion spec not supported"); + break; + case '\0': + TINYFORMAT_ERROR("tinyformat: Conversion spec incorrectly " + "terminated by end of string"); + return c; + } + if(intConversion && precisionSet && !widthSet) + { + // "precision" for integers gives the minimum number of digits (to be + // padded with zeros on the left). This isn't really supported by the + // iostreams, but we can approximately simulate it with the width if + // the width isn't otherwise used. + out.width(out.precision()); + out.setf(std::ios::internal, std::ios::adjustfield); + out.fill('0'); + } + return c+1; +} + + + +//------------------------------------------------------------------------------ +// Private format function on top of which the public interface is implemented. +// We enforce a mimimum of one value to be formatted to prevent bugs looking like +// +// const char* myStr = "100% broken"; +// printf(myStr); // Parses % as a format specifier +#ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES + +template +void format(FormatIterator& fmtIter, const T1& value1) +{ + fmtIter.accept(value1); + fmtIter.finish(); +} + +// General version for C++11 +template +void format(FormatIterator& fmtIter, const T1& value1, const Args&... args) +{ + fmtIter.accept(value1); + format(fmtIter, args...); +} + +#else + +inline void format(FormatIterator& fmtIter) +{ + fmtIter.finish(); +} + +// General version for C++98 +#define TINYFORMAT_MAKE_FORMAT_DETAIL(n) \ +template \ +void format(detail::FormatIterator& fmtIter, TINYFORMAT_VARARGS(n)) \ +{ \ + fmtIter.accept(v1); \ + format(fmtIter TINYFORMAT_PASSARGS_TAIL(n)); \ +} + +TINYFORMAT_FOREACH_ARGNUM(TINYFORMAT_MAKE_FORMAT_DETAIL) +#undef TINYFORMAT_MAKE_FORMAT_DETAIL + +#endif // End C++98 variadic template emulation for format() + +} // namespace detail + + +//------------------------------------------------------------------------------ +// Implement all the main interface functions here in terms of detail::format() + +#ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES + +// C++11 - the simple case +template +void format(std::ostream& out, const char* fmt, const T1& v1, const Args&... args) +{ + detail::FormatIterator fmtIter(out, fmt); + format(fmtIter, v1, args...); +} + +template +std::string format(const char* fmt, const T1& v1, const Args&... args) +{ + std::ostringstream oss; + format(oss, fmt, v1, args...); + return oss.str(); +} + +template +std::string format(const std::string &fmt, const T1& v1, const Args&... args) +{ + std::ostringstream oss; + format(oss, fmt.c_str(), v1, args...); + return oss.str(); +} + +template +void printf(const char* fmt, const T1& v1, const Args&... args) +{ + format(std::cout, fmt, v1, args...); +} + +#else + +// C++98 - define the interface functions using the wrapping macros +#define TINYFORMAT_MAKE_FORMAT_FUNCS(n) \ + \ +template \ +void format(std::ostream& out, const char* fmt, TINYFORMAT_VARARGS(n)) \ +{ \ + tinyformat::detail::FormatIterator fmtIter(out, fmt); \ + tinyformat::detail::format(fmtIter, TINYFORMAT_PASSARGS(n)); \ +} \ + \ +template \ +std::string format(const char* fmt, TINYFORMAT_VARARGS(n)) \ +{ \ + std::ostringstream oss; \ + tinyformat::format(oss, fmt, TINYFORMAT_PASSARGS(n)); \ + return oss.str(); \ +} \ + \ +template \ +std::string format(const std::string &fmt, TINYFORMAT_VARARGS(n)) \ +{ \ + std::ostringstream oss; \ + tinyformat::format(oss, fmt.c_str(), TINYFORMAT_PASSARGS(n)); \ + return oss.str(); \ +} \ + \ +template \ +void printf(const char* fmt, TINYFORMAT_VARARGS(n)) \ +{ \ + tinyformat::format(std::cout, fmt, TINYFORMAT_PASSARGS(n)); \ +} + +TINYFORMAT_FOREACH_ARGNUM(TINYFORMAT_MAKE_FORMAT_FUNCS) +#undef TINYFORMAT_MAKE_FORMAT_FUNCS +#endif + + +//------------------------------------------------------------------------------ +// Define deprecated wrapping macro for backward compatibility in tinyformat +// 1.x. Will be removed in version 2! +#define TINYFORMAT_WRAP_FORMAT_EXTRA_ARGS +#define TINYFORMAT_WRAP_FORMAT_N(n, returnType, funcName, funcDeclSuffix, \ + bodyPrefix, streamName, bodySuffix) \ +template \ +returnType funcName(TINYFORMAT_WRAP_FORMAT_EXTRA_ARGS const char* fmt, \ + TINYFORMAT_VARARGS(n)) funcDeclSuffix \ +{ \ + bodyPrefix \ + tinyformat::format(streamName, fmt, TINYFORMAT_PASSARGS(n)); \ + bodySuffix \ +} \ + +#define TINYFORMAT_WRAP_FORMAT(returnType, funcName, funcDeclSuffix, \ + bodyPrefix, streamName, bodySuffix) \ +inline \ +returnType funcName(TINYFORMAT_WRAP_FORMAT_EXTRA_ARGS const char* fmt \ + ) funcDeclSuffix \ +{ \ + bodyPrefix \ + tinyformat::detail::FormatIterator(streamName, fmt).finish(); \ + bodySuffix \ +} \ +TINYFORMAT_WRAP_FORMAT_N(1 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(2 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(3 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(4 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(5 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(6 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(7 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(8 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(9 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(10, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(11, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(12, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(13, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(14, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(15, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(16, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ + + +} // namespace tinyformat + +#define strprintf tfm::format + +#endif // TINYFORMAT_H_INCLUDED diff --git a/src/txdb-leveldb.cpp b/src/txdb-leveldb.cpp new file mode 100644 index 0000000..7f8d41a --- /dev/null +++ b/src/txdb-leveldb.cpp @@ -0,0 +1,592 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include "kernel.h" +#include "checkpoints.h" +#include "txdb.h" +#include "util.h" +#include "main.h" +#include "chainparams.h" + +using namespace std; +using namespace boost; + +leveldb::DB *txdb; // global pointer for LevelDB object instance + +static leveldb::Options GetOptions() { + leveldb::Options options; + int nCacheSizeMB = GetArg("-dbcache", 25); + options.block_cache = leveldb::NewLRUCache(nCacheSizeMB * 1048576); + options.filter_policy = leveldb::NewBloomFilterPolicy(10); + return options; +} + +void init_blockindex(leveldb::Options& options, bool fRemoveOld = false) { + // First time init. + filesystem::path directory = GetDataDir() / "txleveldb"; + + if (fRemoveOld) { + filesystem::remove_all(directory); // remove directory + unsigned int nFile = 1; + + while (true) + { + filesystem::path strBlockFile = GetDataDir() / strprintf("blk%04u.dat", nFile); + + // Break if no such file + if( !filesystem::exists( strBlockFile ) ) + break; + + filesystem::remove(strBlockFile); + + nFile++; + } + } + + filesystem::create_directory(directory); + LogPrintf("Opening LevelDB in %s\n", directory.string()); + leveldb::Status status = leveldb::DB::Open(options, directory.string(), &txdb); + if (!status.ok()) { + throw runtime_error(strprintf("init_blockindex(): error opening database environment %s", status.ToString())); + } +} + +// CDB subclasses are created and destroyed VERY OFTEN. That's why +// we shouldn't treat this as a free operations. +CTxDB::CTxDB(const char* pszMode) +{ + assert(pszMode); + activeBatch = NULL; + fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w')); + + if (txdb) { + pdb = txdb; + return; + } + + bool fCreate = strchr(pszMode, 'c'); + + options = GetOptions(); + options.create_if_missing = fCreate; + options.filter_policy = leveldb::NewBloomFilterPolicy(10); + + init_blockindex(options); // Init directory + pdb = txdb; + + if (Exists(string("version"))) + { + ReadVersion(nVersion); + LogPrintf("Transaction index version is %d\n", nVersion); + + if (nVersion < DATABASE_VERSION) + { + LogPrintf("Required index version is %d, removing old database\n", DATABASE_VERSION); + + // Leveldb instance destruction + delete txdb; + txdb = pdb = NULL; + delete activeBatch; + activeBatch = NULL; + + init_blockindex(options, true); // Remove directory and create new database + pdb = txdb; + + bool fTmp = fReadOnly; + fReadOnly = false; + WriteVersion(DATABASE_VERSION); // Save transaction index version + fReadOnly = fTmp; + } + } + else if (fCreate) + { + bool fTmp = fReadOnly; + fReadOnly = false; + WriteVersion(DATABASE_VERSION); + fReadOnly = fTmp; + } + + LogPrintf("Opened LevelDB successfully\n"); +} + +void CTxDB::Close() +{ + delete txdb; + txdb = pdb = NULL; + delete options.filter_policy; + options.filter_policy = NULL; + delete options.block_cache; + options.block_cache = NULL; + delete activeBatch; + activeBatch = NULL; +} + +bool CTxDB::TxnBegin() +{ + assert(!activeBatch); + activeBatch = new leveldb::WriteBatch(); + return true; +} + +bool CTxDB::TxnCommit() +{ + assert(activeBatch); + leveldb::Status status = pdb->Write(leveldb::WriteOptions(), activeBatch); + delete activeBatch; + activeBatch = NULL; + if (!status.ok()) { + LogPrintf("LevelDB batch commit failure: %s\n", status.ToString()); + return false; + } + return true; +} + +class CBatchScanner : public leveldb::WriteBatch::Handler { +public: + std::string needle; + bool *deleted; + std::string *foundValue; + bool foundEntry; + + CBatchScanner() : foundEntry(false) {} + + virtual void Put(const leveldb::Slice& key, const leveldb::Slice& value) { + if (key.ToString() == needle) { + foundEntry = true; + *deleted = false; + *foundValue = value.ToString(); + } + } + + virtual void Delete(const leveldb::Slice& key) { + if (key.ToString() == needle) { + foundEntry = true; + *deleted = true; + } + } +}; + +// When performing a read, if we have an active batch we need to check it first +// before reading from the database, as the rest of the code assumes that once +// a database transaction begins reads are consistent with it. It would be good +// to change that assumption in future and avoid the performance hit, though in +// practice it does not appear to be large. +bool CTxDB::ScanBatch(const CDataStream &key, string *value, bool *deleted) const { + assert(activeBatch); + *deleted = false; + CBatchScanner scanner; + scanner.needle = key.str(); + scanner.deleted = deleted; + scanner.foundValue = value; + leveldb::Status status = activeBatch->Iterate(&scanner); + if (!status.ok()) { + throw runtime_error(status.ToString()); + } + return scanner.foundEntry; +} + +bool CTxDB::WriteAddrIndex(uint160 addrHash, uint256 txHash) +{ + std::vector txHashes; + if(!ReadAddrIndex(addrHash, txHashes)) + { + txHashes.push_back(txHash); + return Write(make_pair(string("adr"), addrHash), txHashes); + } + else + { + if(std::find(txHashes.begin(), txHashes.end(), txHash) == txHashes.end()) + { + txHashes.push_back(txHash); + return Write(make_pair(string("adr"), addrHash), txHashes); + } + else + { + return true; // already have this tx hash + } + } +} + +bool CTxDB::ReadAddrIndex(uint160 addrHash, std::vector& txHashes) +{ + return Read(make_pair(string("adr"), addrHash), txHashes); +} + +bool CTxDB::ReadTxIndex(uint256 hash, CTxIndex& txindex) +{ + txindex.SetNull(); + return Read(make_pair(string("tx"), hash), txindex); +} + +bool CTxDB::UpdateTxIndex(uint256 hash, const CTxIndex& txindex) +{ + return Write(make_pair(string("tx"), hash), txindex); +} + +bool CTxDB::AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight) +{ + // Add to tx index + uint256 hash = tx.GetHash(); + CTxIndex txindex(pos, tx.vout.size()); + return Write(make_pair(string("tx"), hash), txindex); +} + +bool CTxDB::EraseTxIndex(const CTransaction& tx) +{ + uint256 hash = tx.GetHash(); + + return Erase(make_pair(string("tx"), hash)); +} + +bool CTxDB::ContainsTx(uint256 hash) +{ + return Exists(make_pair(string("tx"), hash)); +} + +bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex) +{ + tx.SetNull(); + if (!ReadTxIndex(hash, txindex)) + return false; + return (tx.ReadFromDisk(txindex.pos)); +} + +bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx) +{ + CTxIndex txindex; + return ReadDiskTx(hash, tx, txindex); +} + +bool CTxDB::ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex) +{ + return ReadDiskTx(outpoint.hash, tx, txindex); +} + +bool CTxDB::ReadDiskTx(COutPoint outpoint, CTransaction& tx) +{ + CTxIndex txindex; + return ReadDiskTx(outpoint.hash, tx, txindex); +} + +bool CTxDB::WriteBlockIndex(const CDiskBlockIndex& blockindex) +{ + return Write(make_pair(string("blockindex"), blockindex.GetBlockHash()), blockindex); +} + +bool CTxDB::ReadHashBestChain(uint256& hashBestChain) +{ + return Read(string("hashBestChain"), hashBestChain); +} + +bool CTxDB::WriteHashBestChain(uint256 hashBestChain) +{ + return Write(string("hashBestChain"), hashBestChain); +} + +bool CTxDB::ReadBestInvalidTrust(CBigNum& bnBestInvalidTrust) +{ + return Read(string("bnBestInvalidTrust"), bnBestInvalidTrust); +} + +bool CTxDB::WriteBestInvalidTrust(CBigNum bnBestInvalidTrust) +{ + return Write(string("bnBestInvalidTrust"), bnBestInvalidTrust); +} + +bool CTxDB::ReadSyncCheckpoint(uint256& hashCheckpoint) +{ + return Read(string("hashSyncCheckpoint"), hashCheckpoint); +} + +bool CTxDB::WriteSyncCheckpoint(uint256 hashCheckpoint) +{ + return Write(string("hashSyncCheckpoint"), hashCheckpoint); +} + +bool CTxDB::ReadCheckpointPubKey(string& strPubKey) +{ + return Read(string("strCheckpointPubKey"), strPubKey); +} + +bool CTxDB::WriteCheckpointPubKey(const string& strPubKey) +{ + return Write(string("strCheckpointPubKey"), strPubKey); +} + +static CBlockIndex *InsertBlockIndex(uint256 hash) +{ + if (hash == 0) + return NULL; + + // Return existing + map::iterator mi = mapBlockIndex.find(hash); + if (mi != mapBlockIndex.end()) + return (*mi).second; + + // Create new + CBlockIndex* pindexNew = new CBlockIndex(); + if (!pindexNew) + throw runtime_error("LoadBlockIndex() : new CBlockIndex failed"); + mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; + pindexNew->phashBlock = &((*mi).first); + + return pindexNew; +} + +bool CTxDB::LoadBlockIndex() +{ + if (mapBlockIndex.size() > 0) { + // Already loaded once in this session. It can happen during migration + // from BDB. + return true; + } + // The block index is an in-memory structure that maps hashes to on-disk + // locations where the contents of the block can be found. Here, we scan it + // out of the DB and into mapBlockIndex. + leveldb::Iterator *iterator = pdb->NewIterator(leveldb::ReadOptions()); + // Seek to start key. + CDataStream ssStartKey(SER_DISK, CLIENT_VERSION); + ssStartKey << make_pair(string("blockindex"), uint256(0)); + iterator->Seek(ssStartKey.str()); + // Now read each entry. + while (iterator->Valid()) + { + boost::this_thread::interruption_point(); + // Unpack keys and values. + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.write(iterator->key().data(), iterator->key().size()); + CDataStream ssValue(SER_DISK, CLIENT_VERSION); + ssValue.write(iterator->value().data(), iterator->value().size()); + string strType; + ssKey >> strType; + // Did we reach the end of the data to read? + if (strType != "blockindex") + break; + CDiskBlockIndex diskindex; + ssValue >> diskindex; + + uint256 blockHash = diskindex.GetBlockHash(); + + // Construct block index object + CBlockIndex* pindexNew = InsertBlockIndex(blockHash); + pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev); + pindexNew->pnext = InsertBlockIndex(diskindex.hashNext); + pindexNew->nFile = diskindex.nFile; + pindexNew->nBlockPos = diskindex.nBlockPos; + pindexNew->nHeight = diskindex.nHeight; + pindexNew->nMint = diskindex.nMint; + pindexNew->nMoneySupply = diskindex.nMoneySupply; + pindexNew->nFlags = diskindex.nFlags; + pindexNew->nStakeModifier = diskindex.nStakeModifier; + pindexNew->prevoutStake = diskindex.prevoutStake; + pindexNew->nStakeTime = diskindex.nStakeTime; + pindexNew->hashProof = diskindex.hashProof; + pindexNew->nVersion = diskindex.nVersion; + pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot; + pindexNew->nTime = diskindex.nTime; + pindexNew->nBits = diskindex.nBits; + pindexNew->nNonce = diskindex.nNonce; + + // Watch for genesis block + if (pindexGenesisBlock == NULL && blockHash == Params().HashGenesisBlock()) + pindexGenesisBlock = pindexNew; + + if (!pindexNew->CheckIndex()) { + delete iterator; + return error("LoadBlockIndex() : CheckIndex failed at %d", pindexNew->nHeight); + } + + // NovaCoin: build setStakeSeen + if (pindexNew->IsProofOfStake()) + setStakeSeen.insert(make_pair(pindexNew->prevoutStake, pindexNew->nStakeTime)); + + iterator->Next(); + } + delete iterator; + + boost::this_thread::interruption_point(); + + // Calculate nChainTrust + vector > vSortedByHeight; + vSortedByHeight.reserve(mapBlockIndex.size()); + BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex) + { + CBlockIndex* pindex = item.second; + vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex)); + } + sort(vSortedByHeight.begin(), vSortedByHeight.end()); + BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight) + { + CBlockIndex* pindex = item.second; + pindex->nChainTrust = (pindex->pprev ? pindex->pprev->nChainTrust : 0) + pindex->GetBlockTrust(); + } + + // Load hashBestChain pointer to end of best chain + if (!ReadHashBestChain(hashBestChain)) + { + if (pindexGenesisBlock == NULL) + return true; + return error("CTxDB::LoadBlockIndex() : hashBestChain not loaded"); + } + if (!mapBlockIndex.count(hashBestChain)) + return error("CTxDB::LoadBlockIndex() : hashBestChain not found in the block index"); + pindexBest = mapBlockIndex[hashBestChain]; + nBestHeight = pindexBest->nHeight; + nBestChainTrust = pindexBest->nChainTrust; + + LogPrintf("LoadBlockIndex(): hashBestChain=%s height=%d trust=%s date=%s\n", + hashBestChain.ToString(), nBestHeight, CBigNum(nBestChainTrust).ToString(), + DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime())); + + /*// NovaCoin: load hashSyncCheckpoint + if (!ReadSyncCheckpoint(Checkpoints::hashSyncCheckpoint)) + return error("CTxDB::LoadBlockIndex() : hashSyncCheckpoint not loaded"); + LogPrintf("LoadBlockIndex(): synchronized checkpoint %s\n", Checkpoints::hashSyncCheckpoint.ToString()); */ + + // Load bnBestInvalidTrust, OK if it doesn't exist + CBigNum bnBestInvalidTrust; + ReadBestInvalidTrust(bnBestInvalidTrust); + nBestInvalidTrust = bnBestInvalidTrust.getuint256(); + + // Verify blocks in the best chain + int nCheckLevel = GetArg("-checklevel", 1); + int nCheckDepth = GetArg( "-checkblocks", 500); + if (nCheckDepth == 0) + nCheckDepth = 1000000000; // suffices until the year 19000 + if (nCheckDepth > nBestHeight) + nCheckDepth = nBestHeight; + LogPrintf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel); + CBlockIndex* pindexFork = NULL; + map, CBlockIndex*> mapBlockPos; + for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev) + { + boost::this_thread::interruption_point(); + if (pindex->nHeight < nBestHeight-nCheckDepth) + break; + CBlock block; + if (!block.ReadFromDisk(pindex)) + return error("LoadBlockIndex() : block.ReadFromDisk failed"); + // check level 1: verify block validity + // check level 7: verify block signature too + if (nCheckLevel>0 && !block.CheckBlock(true, true, (nCheckLevel>6))) + { + LogPrintf("LoadBlockIndex() : *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); + pindexFork = pindex->pprev; + } + // check level 2: verify transaction index validity + if (nCheckLevel>1) + { + pair pos = make_pair(pindex->nFile, pindex->nBlockPos); + mapBlockPos[pos] = pindex; + BOOST_FOREACH(const CTransaction &tx, block.vtx) + { + uint256 hashTx = tx.GetHash(); + CTxIndex txindex; + if (ReadTxIndex(hashTx, txindex)) + { + // check level 3: checker transaction hashes + if (nCheckLevel>2 || pindex->nFile != txindex.pos.nFile || pindex->nBlockPos != txindex.pos.nBlockPos) + { + // either an error or a duplicate transaction + CTransaction txFound; + if (!txFound.ReadFromDisk(txindex.pos)) + { + LogPrintf("LoadBlockIndex() : *** cannot read mislocated transaction %s\n", hashTx.ToString()); + pindexFork = pindex->pprev; + } + else + if (txFound.GetHash() != hashTx) // not a duplicate tx + { + LogPrintf("LoadBlockIndex(): *** invalid tx position for %s\n", hashTx.ToString()); + pindexFork = pindex->pprev; + } + } + // check level 4: check whether spent txouts were spent within the main chain + unsigned int nOutput = 0; + if (nCheckLevel>3) + { + BOOST_FOREACH(const CDiskTxPos &txpos, txindex.vSpent) + { + if (!txpos.IsNull()) + { + pair posFind = make_pair(txpos.nFile, txpos.nBlockPos); + if (!mapBlockPos.count(posFind)) + { + LogPrintf("LoadBlockIndex(): *** found bad spend at %d, hashBlock=%s, hashTx=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString(), hashTx.ToString()); + pindexFork = pindex->pprev; + } + // check level 6: check whether spent txouts were spent by a valid transaction that consume them + if (nCheckLevel>5) + { + CTransaction txSpend; + if (!txSpend.ReadFromDisk(txpos)) + { + LogPrintf("LoadBlockIndex(): *** cannot read spending transaction of %s:%i from disk\n", hashTx.ToString(), nOutput); + pindexFork = pindex->pprev; + } + else if (!txSpend.CheckTransaction()) + { + LogPrintf("LoadBlockIndex(): *** spending transaction of %s:%i is invalid\n", hashTx.ToString(), nOutput); + pindexFork = pindex->pprev; + } + else + { + bool fFound = false; + BOOST_FOREACH(const CTxIn &txin, txSpend.vin) + if (txin.prevout.hash == hashTx && txin.prevout.n == nOutput) + fFound = true; + if (!fFound) + { + LogPrintf("LoadBlockIndex(): *** spending transaction of %s:%i does not spend it\n", hashTx.ToString(), nOutput); + pindexFork = pindex->pprev; + } + } + } + } + nOutput++; + } + } + } + // check level 5: check whether all prevouts are marked spent + if (nCheckLevel>4) + { + BOOST_FOREACH(const CTxIn &txin, tx.vin) + { + CTxIndex txindex; + if (ReadTxIndex(txin.prevout.hash, txindex)) + if (txindex.vSpent.size()-1 < txin.prevout.n || txindex.vSpent[txin.prevout.n].IsNull()) + { + LogPrintf("LoadBlockIndex(): *** found unspent prevout %s:%i in %s\n", txin.prevout.hash.ToString(), txin.prevout.n, hashTx.ToString()); + pindexFork = pindex->pprev; + } + } + } + } + } + } + if (pindexFork) + { + boost::this_thread::interruption_point(); + // Reorg back to the fork + LogPrintf("LoadBlockIndex() : *** moving best chain pointer back to block %d\n", pindexFork->nHeight); + CBlock block; + if (!block.ReadFromDisk(pindexFork)) + return error("LoadBlockIndex() : block.ReadFromDisk failed"); + CTxDB txdb; + block.SetBestChain(txdb, pindexFork); + } + + return true; +} diff --git a/src/txdb-leveldb.h b/src/txdb-leveldb.h new file mode 100644 index 0000000..fd0e85b --- /dev/null +++ b/src/txdb-leveldb.h @@ -0,0 +1,212 @@ +// Copyright (c) 2009-2012 The Bitcoin Developers. +// Authored by Google, Inc. +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_LEVELDB_H +#define BITCOIN_LEVELDB_H + +#include "main.h" + +#include +#include +#include + +#include +#include + +// Class that provides access to a LevelDB. Note that this class is frequently +// instantiated on the stack and then destroyed again, so instantiation has to +// be very cheap. Unfortunately that means, a CTxDB instance is actually just a +// wrapper around some global state. +// +// A LevelDB is a key/value store that is optimized for fast usage on hard +// disks. It prefers long read/writes to seeks and is based on a series of +// sorted key/value mapping files that are stacked on top of each other, with +// newer files overriding older files. A background thread compacts them +// together when too many files stack up. +// +// Learn more: http://code.google.com/p/leveldb/ +class CTxDB +{ +public: + CTxDB(const char* pszMode="r+"); + ~CTxDB() { + // Note that this is not the same as Close() because it deletes only + // data scoped to this TxDB object. + delete activeBatch; + } + + // Destroys the underlying shared global state accessed by this TxDB. + void Close(); + +private: + leveldb::DB *pdb; // Points to the global instance. + + // A batch stores up writes and deletes for atomic application. When this + // field is non-NULL, writes/deletes go there instead of directly to disk. + leveldb::WriteBatch *activeBatch; + leveldb::Options options; + bool fReadOnly; + int nVersion; + +protected: + // Returns true and sets (value,false) if activeBatch contains the given key + // or leaves value alone and sets deleted = true if activeBatch contains a + // delete for it. + bool ScanBatch(const CDataStream &key, std::string *value, bool *deleted) const; + + template + bool Read(const K& key, T& value) + { + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.reserve(1000); + ssKey << key; + std::string strValue; + + bool readFromDb = true; + if (activeBatch) { + // First we must search for it in the currently pending set of + // changes to the db. If not found in the batch, go on to read disk. + bool deleted = false; + readFromDb = ScanBatch(ssKey, &strValue, &deleted) == false; + if (deleted) { + return false; + } + } + if (readFromDb) { + leveldb::Status status = pdb->Get(leveldb::ReadOptions(), + ssKey.str(), &strValue); + if (!status.ok()) { + if (status.IsNotFound()) + return false; + // Some unexpected error. + LogPrintf("LevelDB read failure: %s\n", status.ToString()); + return false; + } + } + // Unserialize value + try { + CDataStream ssValue(strValue.data(), strValue.data() + strValue.size(), + SER_DISK, CLIENT_VERSION); + ssValue >> value; + } + catch (std::exception &e) { + return false; + } + return true; + } + + template + bool Write(const K& key, const T& value) + { + if (fReadOnly) + assert(!"Write called on database in read-only mode"); + + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.reserve(1000); + ssKey << key; + CDataStream ssValue(SER_DISK, CLIENT_VERSION); + ssValue.reserve(10000); + ssValue << value; + + if (activeBatch) { + activeBatch->Put(ssKey.str(), ssValue.str()); + return true; + } + leveldb::Status status = pdb->Put(leveldb::WriteOptions(), ssKey.str(), ssValue.str()); + if (!status.ok()) { + LogPrintf("LevelDB write failure: %s\n", status.ToString()); + return false; + } + return true; + } + + template + bool Erase(const K& key) + { + if (!pdb) + return false; + if (fReadOnly) + assert(!"Erase called on database in read-only mode"); + + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.reserve(1000); + ssKey << key; + if (activeBatch) { + activeBatch->Delete(ssKey.str()); + return true; + } + leveldb::Status status = pdb->Delete(leveldb::WriteOptions(), ssKey.str()); + return (status.ok() || status.IsNotFound()); + } + + template + bool Exists(const K& key) + { + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + ssKey.reserve(1000); + ssKey << key; + std::string unused; + + if (activeBatch) { + bool deleted; + if (ScanBatch(ssKey, &unused, &deleted) && !deleted) { + return true; + } + } + + + leveldb::Status status = pdb->Get(leveldb::ReadOptions(), ssKey.str(), &unused); + return status.IsNotFound() == false; + } + + +public: + bool TxnBegin(); + bool TxnCommit(); + bool TxnAbort() + { + delete activeBatch; + activeBatch = NULL; + return true; + } + + bool ReadVersion(int& nVersion) + { + nVersion = 0; + return Read(std::string("version"), nVersion); + } + + bool WriteVersion(int nVersion) + { + return Write(std::string("version"), nVersion); + } + + bool ReadAddrIndex(uint160 addrHash, std::vector& txHashes); + bool WriteAddrIndex(uint160 addrHash, uint256 txHash); + bool ReadTxIndex(uint256 hash, CTxIndex& txindex); + bool UpdateTxIndex(uint256 hash, const CTxIndex& txindex); + bool AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight); + bool EraseTxIndex(const CTransaction& tx); + bool ContainsTx(uint256 hash); + bool ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex); + bool ReadDiskTx(uint256 hash, CTransaction& tx); + bool ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex); + bool ReadDiskTx(COutPoint outpoint, CTransaction& tx); + bool WriteBlockIndex(const CDiskBlockIndex& blockindex); + bool ReadHashBestChain(uint256& hashBestChain); + bool WriteHashBestChain(uint256 hashBestChain); + bool ReadBestInvalidTrust(CBigNum& bnBestInvalidTrust); + bool WriteBestInvalidTrust(CBigNum bnBestInvalidTrust); + bool ReadSyncCheckpoint(uint256& hashCheckpoint); + bool WriteSyncCheckpoint(uint256 hashCheckpoint); + bool ReadCheckpointPubKey(std::string& strPubKey); + bool WriteCheckpointPubKey(const std::string& strPubKey); + bool LoadBlockIndex(); +private: + bool LoadBlockIndexGuts(); +}; + + +#endif // BITCOIN_DB_H diff --git a/src/txdb.h b/src/txdb.h new file mode 100644 index 0000000..a8e9f5b --- /dev/null +++ b/src/txdb.h @@ -0,0 +1,11 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_TXDB_H +#define BITCOIN_TXDB_H + +#include "txdb-leveldb.h" + +#endif // BITCOIN_TXDB_H diff --git a/src/txmempool.cpp b/src/txmempool.cpp new file mode 100644 index 0000000..6fb510b --- /dev/null +++ b/src/txmempool.cpp @@ -0,0 +1,107 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "core.h" +#include "txmempool.h" +#include "main.h" // for CTransaction + +using namespace std; + +CTxMemPool::CTxMemPool() +{ +} + +unsigned int CTxMemPool::GetTransactionsUpdated() const +{ + LOCK(cs); + return nTransactionsUpdated; +} + +void CTxMemPool::AddTransactionsUpdated(unsigned int n) +{ + LOCK(cs); + nTransactionsUpdated += n; +} + +bool CTxMemPool::addUnchecked(const uint256& hash, CTransaction &tx) +{ + // Add to memory pool without checking anything. + // Used by main.cpp AcceptToMemoryPool(), which DOES do + // all the appropriate checks. + LOCK(cs); + { + mapTx[hash] = tx; + for (unsigned int i = 0; i < tx.vin.size(); i++) + mapNextTx[tx.vin[i].prevout] = CInPoint(&mapTx[hash], i); + nTransactionsUpdated++; + } + return true; +} + +bool CTxMemPool::remove(const CTransaction &tx, bool fRecursive) +{ + // Remove transaction from memory pool + { + LOCK(cs); + uint256 hash = tx.GetHash(); + if (mapTx.count(hash)) + { + if (fRecursive) { + for (unsigned int i = 0; i < tx.vout.size(); i++) { + std::map::iterator it = mapNextTx.find(COutPoint(hash, i)); + if (it != mapNextTx.end()) + remove(*it->second.ptx, true); + } + } + BOOST_FOREACH(const CTxIn& txin, tx.vin) + mapNextTx.erase(txin.prevout); + mapTx.erase(hash); + nTransactionsUpdated++; + } + } + return true; +} + +bool CTxMemPool::removeConflicts(const CTransaction &tx) +{ + // Remove transactions which depend on inputs of tx, recursively + LOCK(cs); + BOOST_FOREACH(const CTxIn &txin, tx.vin) { + std::map::iterator it = mapNextTx.find(txin.prevout); + if (it != mapNextTx.end()) { + const CTransaction &txConflict = *it->second.ptx; + if (txConflict != tx) + remove(txConflict, true); + } + } + return true; +} + +void CTxMemPool::clear() +{ + LOCK(cs); + mapTx.clear(); + mapNextTx.clear(); + ++nTransactionsUpdated; +} + +void CTxMemPool::queryHashes(std::vector& vtxid) +{ + vtxid.clear(); + + LOCK(cs); + vtxid.reserve(mapTx.size()); + for (map::iterator mi = mapTx.begin(); mi != mapTx.end(); ++mi) + vtxid.push_back((*mi).first); +} + +bool CTxMemPool::lookup(uint256 hash, CTransaction& result) const +{ + LOCK(cs); + std::map::const_iterator i = mapTx.find(hash); + if (i == mapTx.end()) return false; + result = i->second; + return true; +} diff --git a/src/txmempool.h b/src/txmempool.h new file mode 100644 index 0000000..f4439bd --- /dev/null +++ b/src/txmempool.h @@ -0,0 +1,55 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_TXMEMPOOL_H +#define BITCOIN_TXMEMPOOL_H + +#include "core.h" + +/* + * CTxMemPool stores valid-according-to-the-current-best-chain + * transactions that may be included in the next block. + * + * Transactions are added when they are seen on the network + * (or created by the local node), but not all transactions seen + * are added to the pool: if a new transaction double-spends + * an input of a transaction in the pool, it is dropped, + * as are non-standard transactions. + */ +class CTxMemPool +{ +private: + unsigned int nTransactionsUpdated; + +public: + mutable CCriticalSection cs; + std::map mapTx; + std::map mapNextTx; + + CTxMemPool(); + + bool addUnchecked(const uint256& hash, CTransaction &tx); + bool remove(const CTransaction &tx, bool fRecursive = false); + bool removeConflicts(const CTransaction &tx); + void clear(); + void queryHashes(std::vector& vtxid); + unsigned int GetTransactionsUpdated() const; + void AddTransactionsUpdated(unsigned int n); + + unsigned long size() const + { + LOCK(cs); + return mapTx.size(); + } + + bool exists(uint256 hash) const + { + LOCK(cs); + return (mapTx.count(hash) != 0); + } + + bool lookup(uint256 hash, CTransaction& result) const; +}; + +#endif /* BITCOIN_TXMEMPOOL_H */ diff --git a/src/ui_interface.h b/src/ui_interface.h new file mode 100644 index 0000000..e2d8a08 --- /dev/null +++ b/src/ui_interface.h @@ -0,0 +1,113 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_UI_INTERFACE_H +#define BITCOIN_UI_INTERFACE_H + +#include +#include + +#include + +#include + +class CBasicKeyStore; +class CWallet; +class uint256; +class CAdrenalineNodeConfig; + +/** General change type (added, updated, removed). */ +enum ChangeType +{ + CT_NEW, + CT_UPDATED, + CT_DELETED +}; + +/** Signals for UI communication. */ +class CClientUIInterface +{ +public: + /** Flags for CClientUIInterface::ThreadSafeMessageBox */ + enum MessageBoxFlags + { + ICON_INFORMATION = 0, + ICON_WARNING = (1U << 0), + ICON_ERROR = (1U << 1), + /** + * Mask of all available icons in CClientUIInterface::MessageBoxFlags + * This needs to be updated, when icons are changed there! + */ + ICON_MASK = (ICON_INFORMATION | ICON_WARNING | ICON_ERROR), + + /** These values are taken from qmessagebox.h "enum StandardButton" to be directly usable */ + BTN_OK = 0x00000400U, // QMessageBox::Ok + BTN_YES = 0x00004000U, // QMessageBox::Yes + BTN_NO = 0x00010000U, // QMessageBox::No + BTN_ABORT = 0x00040000U, // QMessageBox::Abort + BTN_RETRY = 0x00080000U, // QMessageBox::Retry + BTN_IGNORE = 0x00100000U, // QMessageBox::Ignore + BTN_CLOSE = 0x00200000U, // QMessageBox::Close + BTN_CANCEL = 0x00400000U, // QMessageBox::Cancel + BTN_DISCARD = 0x00800000U, // QMessageBox::Discard + BTN_HELP = 0x01000000U, // QMessageBox::Help + BTN_APPLY = 0x02000000U, // QMessageBox::Apply + BTN_RESET = 0x04000000U, // QMessageBox::Reset + /** + * Mask of all available buttons in CClientUIInterface::MessageBoxFlags + * This needs to be updated, when buttons are changed there! + */ + BTN_MASK = (BTN_OK | BTN_YES | BTN_NO | BTN_ABORT | BTN_RETRY | BTN_IGNORE | + BTN_CLOSE | BTN_CANCEL | BTN_DISCARD | BTN_HELP | BTN_APPLY | BTN_RESET), + + /** Force blocking, modal message box dialog (not just OS notification) */ + MODAL = 0x10000000U, + + /** Predefined combinations for certain default usage cases */ + MSG_INFORMATION = (ICON_INFORMATION | BTN_OK), + MSG_WARNING = (ICON_WARNING | BTN_OK | MODAL), + MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL) + }; + + /** Show message box. */ + boost::signals2::signal ThreadSafeMessageBox; + + /** Ask the user whether they want to pay a fee or not. */ + boost::signals2::signal > ThreadSafeAskFee; + + /** Handle a URL passed at the command line. */ + boost::signals2::signal ThreadSafeHandleURI; + + /** Progress message during initialization. */ + boost::signals2::signal InitMessage; + + /** Translate a message to the native language of the user. */ + boost::signals2::signal Translate; + + /** Number of network connections changed. */ + boost::signals2::signal NotifyNumConnectionsChanged; + + /** + * New, updated or cancelled alert. + * @note called with lock cs_mapAlerts held. + */ + boost::signals2::signal NotifyAlertChanged; + + boost::signals2::signal NotifyAdrenalineNodeChanged; +}; + +extern CClientUIInterface uiInterface; + +/** + * Translation function: Call Translate signal on UI interface, which returns a boost::optional result. + * If no translation slot is registered, nothing is returned, and simply return the input. + */ +inline std::string _(const char* psz) +{ + boost::optional rv = uiInterface.Translate(psz); + return rv ? (*rv) : psz; +} + +#endif diff --git a/src/uint256.h b/src/uint256.h new file mode 100644 index 0000000..1524a51 --- /dev/null +++ b/src/uint256.h @@ -0,0 +1,892 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_UINT256_H +#define BITCOIN_UINT256_H + +#include +#include + +#include +#include +#include + +inline int Testuint256AdHoc(std::vector vArg); + + +/** Base class without constructors for uint256 and uint160. + * This makes the compiler let u use it in a union. + */ +template +class base_uint +{ +protected: + enum { WIDTH=BITS/32 }; + unsigned int pn[WIDTH]; +public: + + bool operator!() const + { + for (int i = 0; i < WIDTH; i++) + if (pn[i] != 0) + return false; + return true; + } + + const base_uint operator~() const + { + base_uint ret; + for (int i = 0; i < WIDTH; i++) + ret.pn[i] = ~pn[i]; + return ret; + } + + const base_uint operator-() const + { + base_uint ret; + for (int i = 0; i < WIDTH; i++) + ret.pn[i] = ~pn[i]; + ret++; + return ret; + } + + double getdouble() const + { + double ret = 0.0; + double fact = 1.0; + for (int i = 0; i < WIDTH; i++) { + ret += fact * pn[i]; + fact *= 4294967296.0; + } + return ret; + } + + base_uint& operator=(uint64_t b) + { + pn[0] = (unsigned int)b; + pn[1] = (unsigned int)(b >> 32); + for (int i = 2; i < WIDTH; i++) + pn[i] = 0; + return *this; + } + + base_uint& operator^=(const base_uint& b) + { + for (int i = 0; i < WIDTH; i++) + pn[i] ^= b.pn[i]; + return *this; + } + + base_uint& operator&=(const base_uint& b) + { + for (int i = 0; i < WIDTH; i++) + pn[i] &= b.pn[i]; + return *this; + } + + base_uint& operator|=(const base_uint& b) + { + for (int i = 0; i < WIDTH; i++) + pn[i] |= b.pn[i]; + return *this; + } + + base_uint& operator^=(uint64_t b) + { + pn[0] ^= (unsigned int)b; + pn[1] ^= (unsigned int)(b >> 32); + return *this; + } + + base_uint& operator|=(uint64_t b) + { + pn[0] |= (unsigned int)b; + pn[1] |= (unsigned int)(b >> 32); + return *this; + } + + base_uint& operator<<=(unsigned int shift) + { + base_uint a(*this); + for (int i = 0; i < WIDTH; i++) + pn[i] = 0; + int k = shift / 32; + shift = shift % 32; + for (int i = 0; i < WIDTH; i++) + { + if (i+k+1 < WIDTH && shift != 0) + pn[i+k+1] |= (a.pn[i] >> (32-shift)); + if (i+k < WIDTH) + pn[i+k] |= (a.pn[i] << shift); + } + return *this; + } + + base_uint& operator>>=(unsigned int shift) + { + base_uint a(*this); + for (int i = 0; i < WIDTH; i++) + pn[i] = 0; + int k = shift / 32; + shift = shift % 32; + for (int i = 0; i < WIDTH; i++) + { + if (i-k-1 >= 0 && shift != 0) + pn[i-k-1] |= (a.pn[i] << (32-shift)); + if (i-k >= 0) + pn[i-k] |= (a.pn[i] >> shift); + } + return *this; + } + + base_uint& operator+=(const base_uint& b) + { + uint64_t carry = 0; + for (int i = 0; i < WIDTH; i++) + { + uint64_t n = carry + pn[i] + b.pn[i]; + pn[i] = n & 0xffffffff; + carry = n >> 32; + } + return *this; + } + + base_uint& operator-=(const base_uint& b) + { + *this += -b; + return *this; + } + + base_uint& operator+=(uint64_t b64) + { + base_uint b; + b = b64; + *this += b; + return *this; + } + + base_uint& operator-=(uint64_t b64) + { + base_uint b; + b = b64; + *this += -b; + return *this; + } + + + base_uint& operator++() + { + // prefix operator + int i = 0; + while (++pn[i] == 0 && i < WIDTH-1) + i++; + return *this; + } + + const base_uint operator++(int) + { + // postfix operator + const base_uint ret = *this; + ++(*this); + return ret; + } + + base_uint& operator--() + { + // prefix operator + int i = 0; + while (--pn[i] == -1 && i < WIDTH-1) + i++; + return *this; + } + + const base_uint operator--(int) + { + // postfix operator + const base_uint ret = *this; + --(*this); + return ret; + } + + + friend inline bool operator<(const base_uint& a, const base_uint& b) + { + for (int i = base_uint::WIDTH-1; i >= 0; i--) + { + if (a.pn[i] < b.pn[i]) + return true; + else if (a.pn[i] > b.pn[i]) + return false; + } + return false; + } + + friend inline bool operator<=(const base_uint& a, const base_uint& b) + { + for (int i = base_uint::WIDTH-1; i >= 0; i--) + { + if (a.pn[i] < b.pn[i]) + return true; + else if (a.pn[i] > b.pn[i]) + return false; + } + return true; + } + + friend inline bool operator>(const base_uint& a, const base_uint& b) + { + for (int i = base_uint::WIDTH-1; i >= 0; i--) + { + if (a.pn[i] > b.pn[i]) + return true; + else if (a.pn[i] < b.pn[i]) + return false; + } + return false; + } + + friend inline bool operator>=(const base_uint& a, const base_uint& b) + { + for (int i = base_uint::WIDTH-1; i >= 0; i--) + { + if (a.pn[i] > b.pn[i]) + return true; + else if (a.pn[i] < b.pn[i]) + return false; + } + return true; + } + + friend inline bool operator==(const base_uint& a, const base_uint& b) + { + for (int i = 0; i < base_uint::WIDTH; i++) + if (a.pn[i] != b.pn[i]) + return false; + return true; + } + + friend inline bool operator==(const base_uint& a, uint64_t b) + { + if (a.pn[0] != (unsigned int)b) + return false; + if (a.pn[1] != (unsigned int)(b >> 32)) + return false; + for (int i = 2; i < base_uint::WIDTH; i++) + if (a.pn[i] != 0) + return false; + return true; + } + + friend inline bool operator!=(const base_uint& a, const base_uint& b) + { + return (!(a == b)); + } + + friend inline bool operator!=(const base_uint& a, uint64_t b) + { + return (!(a == b)); + } + + + + std::string GetHex() const + { + char psz[sizeof(pn)*2 + 1]; + for (unsigned int i = 0; i < sizeof(pn); i++) + sprintf(psz + i*2, "%02x", ((unsigned char*)pn)[sizeof(pn) - i - 1]); + return std::string(psz, psz + sizeof(pn)*2); + } + + void SetHex(const char* psz) + { + for (int i = 0; i < WIDTH; i++) + pn[i] = 0; + + // skip leading spaces + while (isspace(*psz)) + psz++; + + // skip 0x + if (psz[0] == '0' && tolower(psz[1]) == 'x') + psz += 2; + + // hex string to uint + static const unsigned char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 }; + const char* pbegin = psz; + while (phexdigit[(unsigned char)*psz] || *psz == '0') + psz++; + psz--; + unsigned char* p1 = (unsigned char*)pn; + unsigned char* pend = p1 + WIDTH * 4; + while (psz >= pbegin && p1 < pend) + { + *p1 = phexdigit[(unsigned char)*psz--]; + if (psz >= pbegin) + { + *p1 |= (phexdigit[(unsigned char)*psz--] << 4); + p1++; + } + } + } + + void SetHex(const std::string& str) + { + SetHex(str.c_str()); + } + + std::string ToString() const + { + return (GetHex()); + } + + unsigned char* begin() + { + return (unsigned char*)&pn[0]; + } + + unsigned char* end() + { + return (unsigned char*)&pn[WIDTH]; + } + + const unsigned char* begin() const + { + return (unsigned char*)&pn[0]; + } + + const unsigned char* end() const + { + return (unsigned char*)&pn[WIDTH]; + } + + unsigned int size() + { + return sizeof(pn); + } + + uint64_t Get64(int n=0) const + { + return pn[2*n] | (uint64_t)pn[2*n+1] << 32; + } + + unsigned int GetSerializeSize(int nType, int nVersion) const + { + return sizeof(pn); + } + + template + void Serialize(Stream& s, int nType, int nVersion) const + { + s.write((char*)pn, sizeof(pn)); + } + + template + void Unserialize(Stream& s, int nType, int nVersion) + { + s.read((char*)pn, sizeof(pn)); + } + + friend class uint160; + friend class uint256; + friend class uint512; + friend inline int Testuint256AdHoc(std::vector vArg); +}; + +typedef base_uint<160> base_uint160; +typedef base_uint<256> base_uint256; +typedef base_uint<512> base_uint512; + +// +// uint160 and uint256 could be implemented as templates, but to keep +// compile errors and debugging cleaner, they're copy and pasted. +// + + + +////////////////////////////////////////////////////////////////////////////// +// +// uint160 +// + +/** 160-bit unsigned integer */ +class uint160 : public base_uint160 +{ +public: + typedef base_uint160 basetype; + + uint160() + { + for (int i = 0; i < WIDTH; i++) + pn[i] = 0; + } + + uint160(const basetype& b) + { + for (int i = 0; i < WIDTH; i++) + pn[i] = b.pn[i]; + } + + uint160& operator=(const basetype& b) + { + for (int i = 0; i < WIDTH; i++) + pn[i] = b.pn[i]; + return *this; + } + + uint160(uint64_t b) + { + pn[0] = (unsigned int)b; + pn[1] = (unsigned int)(b >> 32); + for (int i = 2; i < WIDTH; i++) + pn[i] = 0; + } + + uint160& operator=(uint64_t b) + { + pn[0] = (unsigned int)b; + pn[1] = (unsigned int)(b >> 32); + for (int i = 2; i < WIDTH; i++) + pn[i] = 0; + return *this; + } + + explicit uint160(const std::string& str) + { + SetHex(str); + } + + explicit uint160(const std::vector& vch) + { + if (vch.size() == sizeof(pn)) + memcpy(pn, &vch[0], sizeof(pn)); + else + *this = 0; + } +}; + +inline bool operator==(const uint160& a, uint64_t b) { return (base_uint160)a == b; } +inline bool operator!=(const uint160& a, uint64_t b) { return (base_uint160)a != b; } +inline const uint160 operator<<(const base_uint160& a, unsigned int shift) { return uint160(a) <<= shift; } +inline const uint160 operator>>(const base_uint160& a, unsigned int shift) { return uint160(a) >>= shift; } +inline const uint160 operator<<(const uint160& a, unsigned int shift) { return uint160(a) <<= shift; } +inline const uint160 operator>>(const uint160& a, unsigned int shift) { return uint160(a) >>= shift; } + +inline const uint160 operator^(const base_uint160& a, const base_uint160& b) { return uint160(a) ^= b; } +inline const uint160 operator&(const base_uint160& a, const base_uint160& b) { return uint160(a) &= b; } +inline const uint160 operator|(const base_uint160& a, const base_uint160& b) { return uint160(a) |= b; } +inline const uint160 operator+(const base_uint160& a, const base_uint160& b) { return uint160(a) += b; } +inline const uint160 operator-(const base_uint160& a, const base_uint160& b) { return uint160(a) -= b; } + +inline bool operator<(const base_uint160& a, const uint160& b) { return (base_uint160)a < (base_uint160)b; } +inline bool operator<=(const base_uint160& a, const uint160& b) { return (base_uint160)a <= (base_uint160)b; } +inline bool operator>(const base_uint160& a, const uint160& b) { return (base_uint160)a > (base_uint160)b; } +inline bool operator>=(const base_uint160& a, const uint160& b) { return (base_uint160)a >= (base_uint160)b; } +inline bool operator==(const base_uint160& a, const uint160& b) { return (base_uint160)a == (base_uint160)b; } +inline bool operator!=(const base_uint160& a, const uint160& b) { return (base_uint160)a != (base_uint160)b; } +inline const uint160 operator^(const base_uint160& a, const uint160& b) { return (base_uint160)a ^ (base_uint160)b; } +inline const uint160 operator&(const base_uint160& a, const uint160& b) { return (base_uint160)a & (base_uint160)b; } +inline const uint160 operator|(const base_uint160& a, const uint160& b) { return (base_uint160)a | (base_uint160)b; } +inline const uint160 operator+(const base_uint160& a, const uint160& b) { return (base_uint160)a + (base_uint160)b; } +inline const uint160 operator-(const base_uint160& a, const uint160& b) { return (base_uint160)a - (base_uint160)b; } + +inline bool operator<(const uint160& a, const base_uint160& b) { return (base_uint160)a < (base_uint160)b; } +inline bool operator<=(const uint160& a, const base_uint160& b) { return (base_uint160)a <= (base_uint160)b; } +inline bool operator>(const uint160& a, const base_uint160& b) { return (base_uint160)a > (base_uint160)b; } +inline bool operator>=(const uint160& a, const base_uint160& b) { return (base_uint160)a >= (base_uint160)b; } +inline bool operator==(const uint160& a, const base_uint160& b) { return (base_uint160)a == (base_uint160)b; } +inline bool operator!=(const uint160& a, const base_uint160& b) { return (base_uint160)a != (base_uint160)b; } +inline const uint160 operator^(const uint160& a, const base_uint160& b) { return (base_uint160)a ^ (base_uint160)b; } +inline const uint160 operator&(const uint160& a, const base_uint160& b) { return (base_uint160)a & (base_uint160)b; } +inline const uint160 operator|(const uint160& a, const base_uint160& b) { return (base_uint160)a | (base_uint160)b; } +inline const uint160 operator+(const uint160& a, const base_uint160& b) { return (base_uint160)a + (base_uint160)b; } +inline const uint160 operator-(const uint160& a, const base_uint160& b) { return (base_uint160)a - (base_uint160)b; } + +inline bool operator<(const uint160& a, const uint160& b) { return (base_uint160)a < (base_uint160)b; } +inline bool operator<=(const uint160& a, const uint160& b) { return (base_uint160)a <= (base_uint160)b; } +inline bool operator>(const uint160& a, const uint160& b) { return (base_uint160)a > (base_uint160)b; } +inline bool operator>=(const uint160& a, const uint160& b) { return (base_uint160)a >= (base_uint160)b; } +inline bool operator==(const uint160& a, const uint160& b) { return (base_uint160)a == (base_uint160)b; } +inline bool operator!=(const uint160& a, const uint160& b) { return (base_uint160)a != (base_uint160)b; } +inline const uint160 operator^(const uint160& a, const uint160& b) { return (base_uint160)a ^ (base_uint160)b; } +inline const uint160 operator&(const uint160& a, const uint160& b) { return (base_uint160)a & (base_uint160)b; } +inline const uint160 operator|(const uint160& a, const uint160& b) { return (base_uint160)a | (base_uint160)b; } +inline const uint160 operator+(const uint160& a, const uint160& b) { return (base_uint160)a + (base_uint160)b; } +inline const uint160 operator-(const uint160& a, const uint160& b) { return (base_uint160)a - (base_uint160)b; } + + + + + + +////////////////////////////////////////////////////////////////////////////// +// +// uint256 +// + +/** 256-bit unsigned integer */ +class uint256 : public base_uint256 +{ +public: + typedef base_uint256 basetype; + + uint256() + { + for (int i = 0; i < WIDTH; i++) + pn[i] = 0; + } + + uint256(const basetype& b) + { + for (int i = 0; i < WIDTH; i++) + pn[i] = b.pn[i]; + } + + uint256& operator=(const basetype& b) + { + for (int i = 0; i < WIDTH; i++) + pn[i] = b.pn[i]; + return *this; + } + + uint256(uint64_t b) + { + pn[0] = (unsigned int)b; + pn[1] = (unsigned int)(b >> 32); + for (int i = 2; i < WIDTH; i++) + pn[i] = 0; + } + + uint256& operator=(uint64_t b) + { + pn[0] = (unsigned int)b; + pn[1] = (unsigned int)(b >> 32); + for (int i = 2; i < WIDTH; i++) + pn[i] = 0; + return *this; + } + + explicit uint256(const std::string& str) + { + SetHex(str); + } + + explicit uint256(const std::vector& vch) + { + if (vch.size() == sizeof(pn)) + memcpy(pn, &vch[0], sizeof(pn)); + else + *this = 0; + } +}; + +inline bool operator==(const uint256& a, uint64_t b) { return (base_uint256)a == b; } +inline bool operator!=(const uint256& a, uint64_t b) { return (base_uint256)a != b; } +inline const uint256 operator<<(const base_uint256& a, unsigned int shift) { return uint256(a) <<= shift; } +inline const uint256 operator>>(const base_uint256& a, unsigned int shift) { return uint256(a) >>= shift; } +inline const uint256 operator<<(const uint256& a, unsigned int shift) { return uint256(a) <<= shift; } +inline const uint256 operator>>(const uint256& a, unsigned int shift) { return uint256(a) >>= shift; } + +inline const uint256 operator^(const base_uint256& a, const base_uint256& b) { return uint256(a) ^= b; } +inline const uint256 operator&(const base_uint256& a, const base_uint256& b) { return uint256(a) &= b; } +inline const uint256 operator|(const base_uint256& a, const base_uint256& b) { return uint256(a) |= b; } +inline const uint256 operator+(const base_uint256& a, const base_uint256& b) { return uint256(a) += b; } +inline const uint256 operator-(const base_uint256& a, const base_uint256& b) { return uint256(a) -= b; } + +inline bool operator<(const base_uint256& a, const uint256& b) { return (base_uint256)a < (base_uint256)b; } +inline bool operator<=(const base_uint256& a, const uint256& b) { return (base_uint256)a <= (base_uint256)b; } +inline bool operator>(const base_uint256& a, const uint256& b) { return (base_uint256)a > (base_uint256)b; } +inline bool operator>=(const base_uint256& a, const uint256& b) { return (base_uint256)a >= (base_uint256)b; } +inline bool operator==(const base_uint256& a, const uint256& b) { return (base_uint256)a == (base_uint256)b; } +inline bool operator!=(const base_uint256& a, const uint256& b) { return (base_uint256)a != (base_uint256)b; } +inline const uint256 operator^(const base_uint256& a, const uint256& b) { return (base_uint256)a ^ (base_uint256)b; } +inline const uint256 operator&(const base_uint256& a, const uint256& b) { return (base_uint256)a & (base_uint256)b; } +inline const uint256 operator|(const base_uint256& a, const uint256& b) { return (base_uint256)a | (base_uint256)b; } +inline const uint256 operator+(const base_uint256& a, const uint256& b) { return (base_uint256)a + (base_uint256)b; } +inline const uint256 operator-(const base_uint256& a, const uint256& b) { return (base_uint256)a - (base_uint256)b; } + +inline bool operator<(const uint256& a, const base_uint256& b) { return (base_uint256)a < (base_uint256)b; } +inline bool operator<=(const uint256& a, const base_uint256& b) { return (base_uint256)a <= (base_uint256)b; } +inline bool operator>(const uint256& a, const base_uint256& b) { return (base_uint256)a > (base_uint256)b; } +inline bool operator>=(const uint256& a, const base_uint256& b) { return (base_uint256)a >= (base_uint256)b; } +inline bool operator==(const uint256& a, const base_uint256& b) { return (base_uint256)a == (base_uint256)b; } +inline bool operator!=(const uint256& a, const base_uint256& b) { return (base_uint256)a != (base_uint256)b; } +inline const uint256 operator^(const uint256& a, const base_uint256& b) { return (base_uint256)a ^ (base_uint256)b; } +inline const uint256 operator&(const uint256& a, const base_uint256& b) { return (base_uint256)a & (base_uint256)b; } +inline const uint256 operator|(const uint256& a, const base_uint256& b) { return (base_uint256)a | (base_uint256)b; } +inline const uint256 operator+(const uint256& a, const base_uint256& b) { return (base_uint256)a + (base_uint256)b; } +inline const uint256 operator-(const uint256& a, const base_uint256& b) { return (base_uint256)a - (base_uint256)b; } + +inline bool operator<(const uint256& a, const uint256& b) { return (base_uint256)a < (base_uint256)b; } +inline bool operator<=(const uint256& a, const uint256& b) { return (base_uint256)a <= (base_uint256)b; } +inline bool operator>(const uint256& a, const uint256& b) { return (base_uint256)a > (base_uint256)b; } +inline bool operator>=(const uint256& a, const uint256& b) { return (base_uint256)a >= (base_uint256)b; } +inline bool operator==(const uint256& a, const uint256& b) { return (base_uint256)a == (base_uint256)b; } +inline bool operator!=(const uint256& a, const uint256& b) { return (base_uint256)a != (base_uint256)b; } +inline const uint256 operator^(const uint256& a, const uint256& b) { return (base_uint256)a ^ (base_uint256)b; } +inline const uint256 operator&(const uint256& a, const uint256& b) { return (base_uint256)a & (base_uint256)b; } +inline const uint256 operator|(const uint256& a, const uint256& b) { return (base_uint256)a | (base_uint256)b; } +inline const uint256 operator+(const uint256& a, const uint256& b) { return (base_uint256)a + (base_uint256)b; } +inline const uint256 operator-(const uint256& a, const uint256& b) { return (base_uint256)a - (base_uint256)b; } + + + + + + + +////////////////////////////////////////////////////////////////////////////// +// +// uint512 +// + +/** 512-bit unsigned integer */ +class uint512 : public base_uint512 +{ +public: + typedef base_uint512 basetype; + + uint512() + { + for (int i = 0; i < WIDTH; i++) + pn[i] = 0; + } + + uint512(const basetype& b) + { + for (int i = 0; i < WIDTH; i++) + pn[i] = b.pn[i]; + } + + uint512& operator=(const basetype& b) + { + for (int i = 0; i < WIDTH; i++) + pn[i] = b.pn[i]; + return *this; + } + + uint512(uint64_t b) + { + pn[0] = (unsigned int)b; + pn[1] = (unsigned int)(b >> 32); + for (int i = 2; i < WIDTH; i++) + pn[i] = 0; + } + + uint512& operator=(uint64_t b) + { + pn[0] = (unsigned int)b; + pn[1] = (unsigned int)(b >> 32); + for (int i = 2; i < WIDTH; i++) + pn[i] = 0; + return *this; + } + + explicit uint512(const std::string& str) + { + SetHex(str); + } + + explicit uint512(const std::vector& vch) + { + if (vch.size() == sizeof(pn)) + memcpy(pn, &vch[0], sizeof(pn)); + else + *this = 0; + } + + uint256 trim256() const + { + uint256 ret; + for (unsigned int i = 0; i < uint256::WIDTH; i++){ + ret.pn[i] = pn[i]; + } + return ret; + } +}; + +inline bool operator==(const uint512& a, uint64_t b) { return (base_uint512)a == b; } +inline bool operator!=(const uint512& a, uint64_t b) { return (base_uint512)a != b; } +inline const uint512 operator<<(const base_uint512& a, unsigned int shift) { return uint512(a) <<= shift; } +inline const uint512 operator>>(const base_uint512& a, unsigned int shift) { return uint512(a) >>= shift; } +inline const uint512 operator<<(const uint512& a, unsigned int shift) { return uint512(a) <<= shift; } +inline const uint512 operator>>(const uint512& a, unsigned int shift) { return uint512(a) >>= shift; } + +inline const uint512 operator^(const base_uint512& a, const base_uint512& b) { return uint512(a) ^= b; } +inline const uint512 operator&(const base_uint512& a, const base_uint512& b) { return uint512(a) &= b; } +inline const uint512 operator|(const base_uint512& a, const base_uint512& b) { return uint512(a) |= b; } +inline const uint512 operator+(const base_uint512& a, const base_uint512& b) { return uint512(a) += b; } +inline const uint512 operator-(const base_uint512& a, const base_uint512& b) { return uint512(a) -= b; } + +inline bool operator<(const base_uint512& a, const uint512& b) { return (base_uint512)a < (base_uint512)b; } +inline bool operator<=(const base_uint512& a, const uint512& b) { return (base_uint512)a <= (base_uint512)b; } +inline bool operator>(const base_uint512& a, const uint512& b) { return (base_uint512)a > (base_uint512)b; } +inline bool operator>=(const base_uint512& a, const uint512& b) { return (base_uint512)a >= (base_uint512)b; } +inline bool operator==(const base_uint512& a, const uint512& b) { return (base_uint512)a == (base_uint512)b; } +inline bool operator!=(const base_uint512& a, const uint512& b) { return (base_uint512)a != (base_uint512)b; } +inline const uint512 operator^(const base_uint512& a, const uint512& b) { return (base_uint512)a ^ (base_uint512)b; } +inline const uint512 operator&(const base_uint512& a, const uint512& b) { return (base_uint512)a & (base_uint512)b; } +inline const uint512 operator|(const base_uint512& a, const uint512& b) { return (base_uint512)a | (base_uint512)b; } +inline const uint512 operator+(const base_uint512& a, const uint512& b) { return (base_uint512)a + (base_uint512)b; } +inline const uint512 operator-(const base_uint512& a, const uint512& b) { return (base_uint512)a - (base_uint512)b; } + +inline bool operator<(const uint512& a, const base_uint512& b) { return (base_uint512)a < (base_uint512)b; } +inline bool operator<=(const uint512& a, const base_uint512& b) { return (base_uint512)a <= (base_uint512)b; } +inline bool operator>(const uint512& a, const base_uint512& b) { return (base_uint512)a > (base_uint512)b; } +inline bool operator>=(const uint512& a, const base_uint512& b) { return (base_uint512)a >= (base_uint512)b; } +inline bool operator==(const uint512& a, const base_uint512& b) { return (base_uint512)a == (base_uint512)b; } +inline bool operator!=(const uint512& a, const base_uint512& b) { return (base_uint512)a != (base_uint512)b; } +inline const uint512 operator^(const uint512& a, const base_uint512& b) { return (base_uint512)a ^ (base_uint512)b; } +inline const uint512 operator&(const uint512& a, const base_uint512& b) { return (base_uint512)a & (base_uint512)b; } +inline const uint512 operator|(const uint512& a, const base_uint512& b) { return (base_uint512)a | (base_uint512)b; } +inline const uint512 operator+(const uint512& a, const base_uint512& b) { return (base_uint512)a + (base_uint512)b; } +inline const uint512 operator-(const uint512& a, const base_uint512& b) { return (base_uint512)a - (base_uint512)b; } + +inline bool operator<(const uint512& a, const uint512& b) { return (base_uint512)a < (base_uint512)b; } +inline bool operator<=(const uint512& a, const uint512& b) { return (base_uint512)a <= (base_uint512)b; } +inline bool operator>(const uint512& a, const uint512& b) { return (base_uint512)a > (base_uint512)b; } +inline bool operator>=(const uint512& a, const uint512& b) { return (base_uint512)a >= (base_uint512)b; } +inline bool operator==(const uint512& a, const uint512& b) { return (base_uint512)a == (base_uint512)b; } +inline bool operator!=(const uint512& a, const uint512& b) { return (base_uint512)a != (base_uint512)b; } +inline const uint512 operator^(const uint512& a, const uint512& b) { return (base_uint512)a ^ (base_uint512)b; } +inline const uint512 operator&(const uint512& a, const uint512& b) { return (base_uint512)a & (base_uint512)b; } +inline const uint512 operator|(const uint512& a, const uint512& b) { return (base_uint512)a | (base_uint512)b; } +inline const uint512 operator+(const uint512& a, const uint512& b) { return (base_uint512)a + (base_uint512)b; } +inline const uint512 operator-(const uint512& a, const uint512& b) { return (base_uint512)a - (base_uint512)b; } + +#ifdef TEST_UINT256 + +inline int Testuint256AdHoc(std::vector vArg) +{ + uint256 g(0); + + + LogPrintf("%s\n", g.ToString()); + g--; LogPrintf("g--\n"); + LogPrintf("%s\n", g.ToString()); + g--; LogPrintf("g--\n"); + LogPrintf("%s\n", g.ToString()); + g++; LogPrintf("g++\n"); + LogPrintf("%s\n", g.ToString()); + g++; LogPrintf("g++\n"); + LogPrintf("%s\n", g.ToString()); + g++; LogPrintf("g++\n"); + LogPrintf("%s\n", g.ToString()); + g++; LogPrintf("g++\n"); + LogPrintf("%s\n", g.ToString()); + + + + uint256 a(7); + LogPrintf("a=7\n"); + LogPrintf("%s\n", a.ToString()); + + uint256 b; + LogPrintf("b undefined\n"); + LogPrintf("%s\n", b.ToString()); + int c = 3; + + a = c; + a.pn[3] = 15; + LogPrintf("%s\n", a.ToString()); + uint256 k(c); + + a = 5; + a.pn[3] = 15; + LogPrintf("%s\n", a.ToString()); + b = 1; + b <<= 52; + + a |= b; + + a ^= 0x500; + + LogPrintf("a %s\n", a.ToString()); + + a = a | b | (uint256)0x1000; + + + LogPrintf("a %s\n", a.ToString()); + LogPrintf("b %s\n", b.ToString()); + + a = 0xfffffffe; + a.pn[4] = 9; + + LogPrintf("%s\n", a.ToString()); + a++; + LogPrintf("%s\n", a.ToString()); + a++; + LogPrintf("%s\n", a.ToString()); + a++; + LogPrintf("%s\n", a.ToString()); + a++; + LogPrintf("%s\n", a.ToString()); + + a--; + LogPrintf("%s\n", a.ToString()); + a--; + LogPrintf("%s\n", a.ToString()); + a--; + LogPrintf("%s\n", a.ToString()); + uint256 d = a--; + LogPrintf("%s\n", d.ToString()); + LogPrintf("%s\n", a.ToString()); + a--; + LogPrintf("%s\n", a.ToString()); + a--; + LogPrintf("%s\n", a.ToString()); + + d = a; + + LogPrintf("%s\n", d.ToString()); + for (int i = uint256::WIDTH-1; i >= 0; i--) LogPrintf("%08x", d.pn[i]); LogPrintf("\n"); + + uint256 neg = d; + neg = ~neg; + LogPrintf("%s\n", neg.ToString()); + + + uint256 e = uint256("0xABCDEF123abcdef12345678909832180000011111111"); + LogPrintf("\n"); + LogPrintf("%s\n", e.ToString()); + + + LogPrintf("\n"); + uint256 x1 = uint256("0xABCDEF123abcdef12345678909832180000011111111"); + uint256 x2; + LogPrintf("%s\n", x1.ToString()); + for (int i = 0; i < 270; i += 4) + { + x2 = x1 << i; + LogPrintf("%s\n", x2.ToString()); + } + + LogPrintf("\n"); + LogPrintf("%s\n", x1.ToString()); + for (int i = 0; i < 270; i += 4) + { + x2 = x1; + x2 >>= i; + LogPrintf("%s\n", x2.ToString()); + } + + + for (int i = 0; i < 100; i++) + { + uint256 k = (~uint256(0) >> i); + LogPrintf("%s\n", k.ToString()); + } + + for (int i = 0; i < 100; i++) + { + uint256 k = (~uint256(0) << i); + LogPrintf("%s\n", k.ToString()); + } + + return (0); +} + +#endif + +#endif diff --git a/src/util.cpp b/src/util.cpp new file mode 100644 index 0000000..11d1287 --- /dev/null +++ b/src/util.cpp @@ -0,0 +1,1393 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "util.h" + +#include "chainparams.h" +#include "sync.h" +#include "ui_interface.h" +#include "uint256.h" +#include "version.h" + +#include + +#include + +#include // for to_lower() +#include +#include // for startswith() and endswith() + +// Work around clang compilation problem in Boost 1.46: +// /usr/include/boost/program_options/detail/config_file.hpp:163:17: error: call to function 'to_internal' that is neither visible in the template definition nor found by argument-dependent lookup +// See also: http://stackoverflow.com/questions/10020179/compilation-fail-in-boost-librairies-program-options +// http://clang.debian.net/status.php?version=3.0&key=CANNOT_FIND_FUNCTION +namespace boost { + namespace program_options { + std::string to_internal(const std::string&); + } +} + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef WIN32 +#ifdef _MSC_VER +#pragma warning(disable:4786) +#pragma warning(disable:4804) +#pragma warning(disable:4805) +#pragma warning(disable:4717) +#endif +#ifdef _WIN32_WINNT +#undef _WIN32_WINNT +#endif +#define _WIN32_WINNT 0x0501 +#ifdef _WIN32_IE +#undef _WIN32_IE +#endif +#define _WIN32_IE 0x0501 +#define WIN32_LEAN_AND_MEAN 1 +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include /* for _commit */ +#include "shlobj.h" +#elif defined(__linux__) +# include +#endif + +using namespace std; + +//Dark features +bool fMasterNode = false; +string strMasterNodePrivKey = ""; +string strMasterNodeAddr = ""; +bool fLiteMode = false; +int nInstantXDepth = 1; +int nDarksendRounds = 2; +int nAnonymizeSONOAmount = 500; +int nLiquidityProvider = 0; +/** Spork enforcement enabled time */ +int64_t enforceMasternodePaymentsTime = 4085657524; +bool fSucessfullyLoaded = false; +bool fEnableluxsend = false; +/** All denominations used by darksend */ +std::vector darkSendDenominations; + +map mapArgs; +map > mapMultiArgs; +bool fDebug = false; +bool fDebugSmsg = false; +bool fNoSmsg = false; +bool fPrintToConsole = false; +bool fPrintToDebugLog = true; +bool fDaemon = false; +bool fServer = false; +bool fCommandLine = false; +string strMiscWarning; +bool fNoListen = false; +bool fLogTimestamps = false; +volatile bool fReopenDebugLog = false; + +// Init OpenSSL library multithreading support +static CCriticalSection** ppmutexOpenSSL; +void locking_callback(int mode, int i, const char* file, int line) +{ + if (mode & CRYPTO_LOCK) { + ENTER_CRITICAL_SECTION(*ppmutexOpenSSL[i]); + } else { + LEAVE_CRITICAL_SECTION(*ppmutexOpenSSL[i]); + } +} + +LockedPageManager LockedPageManager::instance; + +// Init +class CInit +{ +public: + CInit() + { + // Init OpenSSL library multithreading support + ppmutexOpenSSL = (CCriticalSection**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(CCriticalSection*)); + for (int i = 0; i < CRYPTO_num_locks(); i++) + ppmutexOpenSSL[i] = new CCriticalSection(); + CRYPTO_set_locking_callback(locking_callback); + +#ifdef WIN32 + // Seed OpenSSL PRNG with current contents of the screen + RAND_screen(); +#endif + + // Seed OpenSSL PRNG with performance counter + RandAddSeed(); + } + ~CInit() + { + // Securely erase the memory used by the PRNG + RAND_cleanup(); + // Shutdown OpenSSL library multithreading support + CRYPTO_set_locking_callback(NULL); + for (int i = 0; i < CRYPTO_num_locks(); i++) + delete ppmutexOpenSSL[i]; + OPENSSL_free(ppmutexOpenSSL); + } +} +instance_of_cinit; + + + + + + + + +void RandAddSeed() +{ + // Seed with CPU performance counter + int64_t nCounter = GetPerformanceCounter(); + RAND_add(&nCounter, sizeof(nCounter), 1.5); + memset(&nCounter, 0, sizeof(nCounter)); +} + +void RandAddSeedPerfmon() +{ + RandAddSeed(); + + // This can take up to 2 seconds, so only do it every 10 minutes + static int64_t nLastPerfmon; + if (GetTime() < nLastPerfmon + 10 * 60) + return; + nLastPerfmon = GetTime(); + +#ifdef WIN32 + // Don't need this on Linux, OpenSSL automatically uses /dev/urandom + // Seed with the entire set of perfmon data + unsigned char pdata[250000]; + memset(pdata, 0, sizeof(pdata)); + unsigned long nSize = sizeof(pdata); + long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize); + RegCloseKey(HKEY_PERFORMANCE_DATA); + if (ret == ERROR_SUCCESS) + { + RAND_add(pdata, nSize, nSize/100.0); + OPENSSL_cleanse(pdata, nSize); + LogPrint("rand", "RandAddSeed() %lu bytes\n", nSize); + } +#endif +} + +uint64_t GetRand(uint64_t nMax) +{ + if (nMax == 0) + return 0; + + // The range of the random source must be a multiple of the modulus + // to give every possible output value an equal possibility + uint64_t nRange = (std::numeric_limits::max() / nMax) * nMax; + uint64_t nRand = 0; + do + RAND_bytes((unsigned char*)&nRand, sizeof(nRand)); + while (nRand >= nRange); + return (nRand % nMax); +} + +int GetRandInt(int nMax) +{ + return GetRand(nMax); +} + +uint256 GetRandHash() +{ + uint256 hash; + RAND_bytes((unsigned char*)&hash, sizeof(hash)); + return hash; +} + +void GetRandBytes(unsigned char* buf, int num) +{ + if (RAND_bytes(buf, num) != 1) { + LogPrintf("%s: OpenSSL RAND_bytes() failed with error: %s\n", __func__, ERR_error_string(ERR_get_error(), NULL)); + assert(false); + } +} + +// LogPrintf() has been broken a couple of times now +// by well-meaning people adding mutexes in the most straightforward way. +// It breaks because it may be called by global destructors during shutdown. +// Since the order of destruction of static/global objects is undefined, +// defining a mutex as a global object doesn't work (the mutex gets +// destroyed, and then some later destructor calls OutputDebugStringF, +// maybe indirectly, and you get a core dump at shutdown trying to lock +// the mutex). + +static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT; +// We use boost::call_once() to make sure these are initialized in +// in a thread-safe manner the first time it is called: +static FILE* fileout = NULL; +static boost::mutex* mutexDebugLog = NULL; + +static void DebugPrintInit() +{ + assert(fileout == NULL); + assert(mutexDebugLog == NULL); + + boost::filesystem::path pathDebug = GetDataDir() / "debug.log"; + fileout = fopen(pathDebug.string().c_str(), "a"); + if (fileout) setbuf(fileout, NULL); // unbuffered + + mutexDebugLog = new boost::mutex(); +} + +bool LogAcceptCategory(const char* category) +{ + if (category != NULL) + { + if (!fDebug) + return false; + + // Give each thread quick access to -debug settings. + // This helps prevent issues debugging global destructors, + // where mapMultiArgs might be deleted before another + // global destructor calls LogPrint() + static boost::thread_specific_ptr > ptrCategory; + if (ptrCategory.get() == NULL) + { + const vector& categories = mapMultiArgs["-debug"]; + ptrCategory.reset(new set(categories.begin(), categories.end())); + // thread_specific_ptr automatically deletes the set when the thread ends. + } + const set& setCategories = *ptrCategory.get(); + + // if not debugging everything and not debugging specific category, LogPrint does nothing. + if (setCategories.count(string("")) == 0 && + setCategories.count(string(category)) == 0) + return false; + } + return true; +} + +int LogPrintStr(const std::string &str) +{ + int ret = 0; // Returns total number of characters written + if (fPrintToConsole) + { + // print to console + ret = fwrite(str.data(), 1, str.size(), stdout); + } + else if (fPrintToDebugLog) + { + static bool fStartedNewLine = true; + boost::call_once(&DebugPrintInit, debugPrintInitFlag); + + if (fileout == NULL) + return ret; + + boost::mutex::scoped_lock scoped_lock(*mutexDebugLog); + + // reopen the log file, if requested + if (fReopenDebugLog) { + fReopenDebugLog = false; + boost::filesystem::path pathDebug = GetDataDir() / "debug.log"; + if (freopen(pathDebug.string().c_str(),"a",fileout) != NULL) + setbuf(fileout, NULL); // unbuffered + } + + // Debug print useful for profiling + if (fLogTimestamps && fStartedNewLine) + ret += fprintf(fileout, "%s ", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str()); + if (!str.empty() && str[str.size()-1] == '\n') + fStartedNewLine = true; + else + fStartedNewLine = false; + + ret = fwrite(str.data(), 1, str.size(), fileout); + } + + return ret; +} + +void ParseString(const string& str, char c, vector& v) +{ + if (str.empty()) + return; + string::size_type i1 = 0; + string::size_type i2; + while (true) + { + i2 = str.find(c, i1); + if (i2 == str.npos) + { + v.push_back(str.substr(i1)); + return; + } + v.push_back(str.substr(i1, i2-i1)); + i1 = i2+1; + } +} + + +string FormatMoney(int64_t n, bool fPlus) +{ + // Note: not using straight sprintf here because we do NOT want + // localized number formatting. + int64_t n_abs = (n > 0 ? n : -n); + int64_t quotient = n_abs/COIN; + int64_t remainder = n_abs%COIN; + string str = strprintf("%d.%08d", quotient, remainder); + + // Right-trim excess zeros before the decimal point: + int nTrim = 0; + for (int i = str.size()-1; (str[i] == '0' && isdigit(str[i-2])); --i) + ++nTrim; + if (nTrim) + str.erase(str.size()-nTrim, nTrim); + + if (n < 0) + str.insert((unsigned int)0, 1, '-'); + else if (fPlus && n > 0) + str.insert((unsigned int)0, 1, '+'); + return str; +} + + +bool ParseMoney(const string& str, int64_t& nRet) +{ + return ParseMoney(str.c_str(), nRet); +} + +bool ParseMoney(const char* pszIn, int64_t& nRet) +{ + string strWhole; + int64_t nUnits = 0; + const char* p = pszIn; + while (isspace(*p)) + p++; + for (; *p; p++) + { + if (*p == '.') + { + p++; + int64_t nMult = CENT*10; + while (isdigit(*p) && (nMult > 0)) + { + nUnits += nMult * (*p++ - '0'); + nMult /= 10; + } + break; + } + if (isspace(*p)) + break; + if (!isdigit(*p)) + return false; + strWhole.insert(strWhole.end(), *p); + } + for (; *p; p++) + if (!isspace(*p)) + return false; + if (strWhole.size() > 10) // guard against 63 bit overflow + return false; + if (nUnits < 0 || nUnits > COIN) + return false; + int64_t nWhole = atoi64(strWhole); + int64_t nValue = nWhole*COIN + nUnits; + + nRet = nValue; + return true; +} + +// safeChars chosen to allow simple messages/URLs/email addresses, but avoid anything +// even possibly remotely dangerous like & or > +static string safeChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 .,;_/:?@"); +string SanitizeString(const string& str) +{ + string strResult; + for (std::string::size_type i = 0; i < str.size(); i++) + { + if (safeChars.find(str[i]) != std::string::npos) + strResult.push_back(str[i]); + } + return strResult; +} + +static const signed char phexdigit[256] = +{ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + 0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1, + -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, }; + +bool IsHex(const string& str) +{ + BOOST_FOREACH(unsigned char c, str) + { + if (phexdigit[c] < 0) + return false; + } + return (str.size() > 0) && (str.size()%2 == 0); +} + +vector ParseHex(const char* psz) +{ + // convert hex dump to vector + vector vch; + while (true) + { + while (isspace(*psz)) + psz++; + signed char c = phexdigit[(unsigned char)*psz++]; + if (c == (signed char)-1) + break; + unsigned char n = (c << 4); + c = phexdigit[(unsigned char)*psz++]; + if (c == (signed char)-1) + break; + n |= c; + vch.push_back(n); + } + return vch; +} + +vector ParseHex(const string& str) +{ + return ParseHex(str.c_str()); +} + +static void InterpretNegativeSetting(string name, map& mapSettingsRet) +{ + // interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set + if (name.find("-no") == 0) + { + std::string positive("-"); + positive.append(name.begin()+3, name.end()); + if (mapSettingsRet.count(positive) == 0) + { + bool value = !GetBoolArg(name, false); + mapSettingsRet[positive] = (value ? "1" : "0"); + } + } +} + +void ParseParameters(int argc, const char* const argv[]) +{ + mapArgs.clear(); + mapMultiArgs.clear(); + for (int i = 1; i < argc; i++) + { + std::string str(argv[i]); + std::string strValue; + size_t is_index = str.find('='); + if (is_index != std::string::npos) + { + strValue = str.substr(is_index+1); + str = str.substr(0, is_index); + } +#ifdef WIN32 + boost::to_lower(str); + if (boost::algorithm::starts_with(str, "/")) + str = "-" + str.substr(1); +#endif + if (str[0] != '-') + break; + + mapArgs[str] = strValue; + mapMultiArgs[str].push_back(strValue); + } + + // New 0.6 features: + BOOST_FOREACH(const PAIRTYPE(string,string)& entry, mapArgs) + { + string name = entry.first; + + // interpret --foo as -foo (as long as both are not set) + if (name.find("--") == 0) + { + std::string singleDash(name.begin()+1, name.end()); + if (mapArgs.count(singleDash) == 0) + mapArgs[singleDash] = entry.second; + name = singleDash; + } + + // interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set + InterpretNegativeSetting(name, mapArgs); + } +} + +std::string GetArg(const std::string& strArg, const std::string& strDefault) +{ + if (mapArgs.count(strArg)) + return mapArgs[strArg]; + return strDefault; +} + +int64_t GetArg(const std::string& strArg, int64_t nDefault) +{ + if (mapArgs.count(strArg)) + return atoi64(mapArgs[strArg]); + return nDefault; +} + +bool GetBoolArg(const std::string& strArg, bool fDefault) +{ + if (mapArgs.count(strArg)) + { + if (mapArgs[strArg].empty()) + return true; + return (atoi(mapArgs[strArg]) != 0); + } + return fDefault; +} + +bool SoftSetArg(const std::string& strArg, const std::string& strValue) +{ + if (mapArgs.count(strArg)) + return false; + mapArgs[strArg] = strValue; + return true; +} + +bool SoftSetBoolArg(const std::string& strArg, bool fValue) +{ + if (fValue) + return SoftSetArg(strArg, std::string("1")); + else + return SoftSetArg(strArg, std::string("0")); +} + + +string EncodeBase64(const unsigned char* pch, size_t len) +{ + static const char *pbase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + string strRet=""; + strRet.reserve((len+2)/3*4); + + int mode=0, left=0; + const unsigned char *pchEnd = pch+len; + + while (pch> 2]; + left = (enc & 3) << 4; + mode = 1; + break; + + case 1: // we have two bits + strRet += pbase64[left | (enc >> 4)]; + left = (enc & 15) << 2; + mode = 2; + break; + + case 2: // we have four bits + strRet += pbase64[left | (enc >> 6)]; + strRet += pbase64[enc & 63]; + mode = 0; + break; + } + } + + if (mode) + { + strRet += pbase64[left]; + strRet += '='; + if (mode == 1) + strRet += '='; + } + + return strRet; +} + +string EncodeBase64(const string& str) +{ + return EncodeBase64((const unsigned char*)str.c_str(), str.size()); +} + +vector DecodeBase64(const char* p, bool* pfInvalid) +{ + static const int decode64_table[256] = + { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, + -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + }; + + if (pfInvalid) + *pfInvalid = false; + + vector vchRet; + vchRet.reserve(strlen(p)*3/4); + + int mode = 0; + int left = 0; + + while (1) + { + int dec = decode64_table[(unsigned char)*p]; + if (dec == -1) break; + p++; + switch (mode) + { + case 0: // we have no bits and get 6 + left = dec; + mode = 1; + break; + + case 1: // we have 6 bits and keep 4 + vchRet.push_back((left<<2) | (dec>>4)); + left = dec & 15; + mode = 2; + break; + + case 2: // we have 4 bits and get 6, we keep 2 + vchRet.push_back((left<<4) | (dec>>2)); + left = dec & 3; + mode = 3; + break; + + case 3: // we have 2 bits and get 6 + vchRet.push_back((left<<6) | dec); + mode = 0; + break; + } + } + + if (pfInvalid) + switch (mode) + { + case 0: // 4n base64 characters processed: ok + break; + + case 1: // 4n+1 base64 character processed: impossible + *pfInvalid = true; + break; + + case 2: // 4n+2 base64 characters processed: require '==' + if (left || p[0] != '=' || p[1] != '=' || decode64_table[(unsigned char)p[2]] != -1) + *pfInvalid = true; + break; + + case 3: // 4n+3 base64 characters processed: require '=' + if (left || p[0] != '=' || decode64_table[(unsigned char)p[1]] != -1) + *pfInvalid = true; + break; + } + + return vchRet; +} + +string DecodeBase64(const string& str) +{ + vector vchRet = DecodeBase64(str.c_str()); + return string((const char*)&vchRet[0], vchRet.size()); +} + +// Base64 encoding with secure memory allocation +SecureString EncodeBase64Secure(const SecureString& input) +{ + // Init openssl BIO with base64 filter and memory output + BIO *b64, *mem; + b64 = BIO_new(BIO_f_base64()); + BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); // No newlines in output + mem = BIO_new(BIO_s_mem()); + BIO_push(b64, mem); + + // Decode the string + BIO_write(b64, &input[0], input.size()); + (void) BIO_flush(b64); + + // Create output variable from buffer mem ptr + BUF_MEM *bptr; + BIO_get_mem_ptr(b64, &bptr); + SecureString output(bptr->data, bptr->length); + + // Cleanse secure data buffer from memory + OPENSSL_cleanse((void *) bptr->data, bptr->length); + + // Free memory + BIO_free_all(b64); + return output; +} + +// Base64 decoding with secure memory allocation +SecureString DecodeBase64Secure(const SecureString& input) +{ + SecureString output; + + // Init openssl BIO with base64 filter and memory input + BIO *b64, *mem; + b64 = BIO_new(BIO_f_base64()); + BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); //Do not use newlines to flush buffer + mem = BIO_new_mem_buf((void *) &input[0], input.size()); + BIO_push(b64, mem); + + // Prepare buffer to receive decoded data + if(input.size() % 4 != 0) { + throw runtime_error("Input length should be a multiple of 4"); + } + size_t nMaxLen = input.size() / 4 * 3; // upper bound, guaranteed divisible by 4 + output.resize(nMaxLen); + + // Decode the string + size_t nLen; + nLen = BIO_read(b64, (void *) &output[0], input.size()); + output.resize(nLen); + + // Free memory + BIO_free_all(b64); + return output; +} + + +string EncodeBase32(const unsigned char* pch, size_t len) +{ + static const char *pbase32 = "abcdefghijklmnopqrstuvwxyz234567"; + + string strRet=""; + strRet.reserve((len+4)/5*8); + + int mode=0, left=0; + const unsigned char *pchEnd = pch+len; + + while (pch> 3]; + left = (enc & 7) << 2; + mode = 1; + break; + + case 1: // we have three bits + strRet += pbase32[left | (enc >> 6)]; + strRet += pbase32[(enc >> 1) & 31]; + left = (enc & 1) << 4; + mode = 2; + break; + + case 2: // we have one bit + strRet += pbase32[left | (enc >> 4)]; + left = (enc & 15) << 1; + mode = 3; + break; + + case 3: // we have four bits + strRet += pbase32[left | (enc >> 7)]; + strRet += pbase32[(enc >> 2) & 31]; + left = (enc & 3) << 3; + mode = 4; + break; + + case 4: // we have two bits + strRet += pbase32[left | (enc >> 5)]; + strRet += pbase32[enc & 31]; + mode = 0; + } + } + + static const int nPadding[5] = {0, 6, 4, 3, 1}; + if (mode) + { + strRet += pbase32[left]; + for (int n=0; n DecodeBase32(const char* p, bool* pfInvalid) +{ + static const int decode32_table[256] = + { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 0, 1, 2, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + }; + + if (pfInvalid) + *pfInvalid = false; + + vector vchRet; + vchRet.reserve((strlen(p))*5/8); + + int mode = 0; + int left = 0; + + while (1) + { + int dec = decode32_table[(unsigned char)*p]; + if (dec == -1) break; + p++; + switch (mode) + { + case 0: // we have no bits and get 5 + left = dec; + mode = 1; + break; + + case 1: // we have 5 bits and keep 2 + vchRet.push_back((left<<3) | (dec>>2)); + left = dec & 3; + mode = 2; + break; + + case 2: // we have 2 bits and keep 7 + left = left << 5 | dec; + mode = 3; + break; + + case 3: // we have 7 bits and keep 4 + vchRet.push_back((left<<1) | (dec>>4)); + left = dec & 15; + mode = 4; + break; + + case 4: // we have 4 bits, and keep 1 + vchRet.push_back((left<<4) | (dec>>1)); + left = dec & 1; + mode = 5; + break; + + case 5: // we have 1 bit, and keep 6 + left = left << 5 | dec; + mode = 6; + break; + + case 6: // we have 6 bits, and keep 3 + vchRet.push_back((left<<2) | (dec>>3)); + left = dec & 7; + mode = 7; + break; + + case 7: // we have 3 bits, and keep 0 + vchRet.push_back((left<<5) | dec); + mode = 0; + break; + } + } + + if (pfInvalid) + switch (mode) + { + case 0: // 8n base32 characters processed: ok + break; + + case 1: // 8n+1 base32 characters processed: impossible + case 3: // +3 + case 6: // +6 + *pfInvalid = true; + break; + + case 2: // 8n+2 base32 characters processed: require '======' + if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || p[3] != '=' || p[4] != '=' || p[5] != '=' || decode32_table[(unsigned char)p[6]] != -1) + *pfInvalid = true; + break; + + case 4: // 8n+4 base32 characters processed: require '====' + if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || p[3] != '=' || decode32_table[(unsigned char)p[4]] != -1) + *pfInvalid = true; + break; + + case 5: // 8n+5 base32 characters processed: require '===' + if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || decode32_table[(unsigned char)p[3]] != -1) + *pfInvalid = true; + break; + + case 7: // 8n+7 base32 characters processed: require '=' + if (left || p[0] != '=' || decode32_table[(unsigned char)p[1]] != -1) + *pfInvalid = true; + break; + } + + return vchRet; +} + +string DecodeBase32(const string& str) +{ + vector vchRet = DecodeBase32(str.c_str()); + return string((const char*)&vchRet[0], vchRet.size()); +} + + +bool WildcardMatch(const char* psz, const char* mask) +{ + while (true) + { + switch (*mask) + { + case '\0': + return (*psz == '\0'); + case '*': + return WildcardMatch(psz, mask+1) || (*psz && WildcardMatch(psz+1, mask)); + case '?': + if (*psz == '\0') + return false; + break; + default: + if (*psz != *mask) + return false; + break; + } + psz++; + mask++; + } +} + +bool WildcardMatch(const string& str, const string& mask) +{ + return WildcardMatch(str.c_str(), mask.c_str()); +} + + +bool ParseInt32(const std::string& str, int32_t *out) +{ + char *endp = NULL; + errno = 0; // strtol will not set errno if valid + long int n = strtol(str.c_str(), &endp, 10); + if(out) *out = (int)n; + // Note that strtol returns a *long int*, so even if strtol doesn't report a over/underflow + // we still have to check that the returned value is within the range of an *int32_t*. On 64-bit + // platforms the size of these types may be different. + return endp && *endp == 0 && !errno && + n >= std::numeric_limits::min() && + n <= std::numeric_limits::max(); +} + +std::string FormatParagraph(const std::string in, size_t width, size_t indent) +{ + std::stringstream out; + size_t col = 0; + size_t ptr = 0; + while(ptr < in.size()) + { + // Find beginning of next word + ptr = in.find_first_not_of(' ', ptr); + if (ptr == std::string::npos) + break; + // Find end of next word + size_t endword = in.find_first_of(' ', ptr); + if (endword == std::string::npos) + endword = in.size(); + // Add newline and indentation if this wraps over the allowed width + if (col > 0) + { + if ((col + endword - ptr) > width) + { + out << '\n'; + for(size_t i=0; iwhat(), pszModule, pszThread); + else + return strprintf( + "UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread); +} + +void PrintException(std::exception* pex, const char* pszThread) +{ + std::string message = FormatException(pex, pszThread); + LogPrintf("\n\n************************\n%s\n", message); + fprintf(stderr, "\n\n************************\n%s\n", message.c_str()); + strMiscWarning = message; + throw; +} + +void PrintExceptionContinue(std::exception* pex, const char* pszThread) +{ + std::string message = FormatException(pex, pszThread); + LogPrintf("\n\n************************\n%s\n", message); + fprintf(stderr, "\n\n************************\n%s\n", message.c_str()); + strMiscWarning = message; +} + +boost::filesystem::path GetDefaultDataDir() +{ + namespace fs = boost::filesystem; + // Windows < Vista: C:\Documents and Settings\Username\Application Data\SONO + // Windows >= Vista: C:\Users\Username\AppData\Roaming\SONO + // Mac: ~/Library/Application Support/SONO + // Unix: ~/.SONO +#ifdef WIN32 + // Windows + return GetSpecialFolderPath(CSIDL_APPDATA) / "SONO"; +#else + fs::path pathRet; + char* pszHome = getenv("HOME"); + if (pszHome == NULL || strlen(pszHome) == 0) + pathRet = fs::path("/"); + else + pathRet = fs::path(pszHome); +#ifdef MAC_OSX + // Mac + pathRet /= "Library/Application Support"; + fs::create_directory(pathRet); + return pathRet / "SONO"; +#else + // Unix + return pathRet / ".SONO"; +#endif +#endif +} + +static boost::filesystem::path pathCached[CChainParams::MAX_NETWORK_TYPES+1]; +static CCriticalSection csPathCached; + +const boost::filesystem::path &GetDataDir(bool fNetSpecific) +{ + namespace fs = boost::filesystem; + + LOCK(csPathCached); + + int nNet = CChainParams::MAX_NETWORK_TYPES; + if (fNetSpecific) nNet = Params().NetworkID(); + + fs::path &path = pathCached[nNet]; + + // This can be called during exceptions by LogPrintf(), so we cache the + // value so we don't have to do memory allocations after that. + if (!path.empty()) + return path; + + if (mapArgs.count("-datadir")) { + path = fs::system_complete(mapArgs["-datadir"]); + if (!fs::is_directory(path)) { + path = ""; + return path; + } + } else { + path = GetDefaultDataDir(); + } + if (fNetSpecific) + path /= Params().DataDir(); + + fs::create_directory(path); + + return path; +} + +void ClearDatadirCache() +{ + std::fill(&pathCached[0], &pathCached[CChainParams::MAX_NETWORK_TYPES+1], + boost::filesystem::path()); +} + +boost::filesystem::path GetConfigFile() +{ + boost::filesystem::path pathConfigFile(GetArg("-conf", "SONO.conf")); + if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir(false) / pathConfigFile; + return pathConfigFile; +} + +boost::filesystem::path GetMasternodeConfigFile() +{ + boost::filesystem::path pathConfigFile(GetArg("-mnconf", "masternode.conf")); + if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir(false) / pathConfigFile; + return pathConfigFile; +} + +void ReadConfigFile(map& mapSettingsRet, + map >& mapMultiSettingsRet) +{ + boost::filesystem::ifstream streamConfig(GetConfigFile()); + if (!streamConfig.good()) + return; // No bitcoin.conf file is OK + + set setOptions; + setOptions.insert("*"); + + for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it) + { + // Don't overwrite existing settings so command line settings override bitcoin.conf + string strKey = string("-") + it->string_key; + if (mapSettingsRet.count(strKey) == 0) + { + mapSettingsRet[strKey] = it->value[0]; + // interpret nofoo=1 as foo=0 (and nofoo=0 as foo=1) as long as foo not set) + InterpretNegativeSetting(strKey, mapSettingsRet); + } + mapMultiSettingsRet[strKey].push_back(it->value[0]); + } + // If datadir is changed in .conf file: + ClearDatadirCache(); +} + +boost::filesystem::path GetPidFile() +{ + boost::filesystem::path pathPidFile(GetArg("-pid", "SONOd.pid")); + if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile; + return pathPidFile; +} + +#ifndef WIN32 +void CreatePidFile(const boost::filesystem::path &path, pid_t pid) +{ + FILE* file = fopen(path.string().c_str(), "w"); + if (file) + { + fprintf(file, "%d\n", pid); + fclose(file); + } +} +#endif + +bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest) +{ +#ifdef WIN32 + return MoveFileExA(src.string().c_str(), dest.string().c_str(), + MOVEFILE_REPLACE_EXISTING); +#else + int rc = std::rename(src.string().c_str(), dest.string().c_str()); + return (rc == 0); +#endif /* WIN32 */ +} + +void FileCommit(FILE *fileout) +{ + fflush(fileout); // harmless if redundantly called +#ifdef WIN32 + HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(fileout)); + FlushFileBuffers(hFile); +#else + fsync(fileno(fileout)); +#endif +} + +std::string getTimeString(int64_t timestamp, char *buffer, size_t nBuffer) +{ + struct tm* dt; + time_t t = timestamp; + dt = localtime(&t); + + strftime(buffer, nBuffer, "%Y-%m-%d %H:%M:%S %z", dt); // %Z shows long strings on windows + return std::string(buffer); // copies the null-terminated character sequence +}; + +std::string bytesReadable(uint64_t nBytes) +{ + if (nBytes >= 1024ll*1024ll*1024ll*1024ll) + return strprintf("%.2f TB", nBytes/1024.0/1024.0/1024.0/1024.0); + if (nBytes >= 1024*1024*1024) + return strprintf("%.2f GB", nBytes/1024.0/1024.0/1024.0); + if (nBytes >= 1024*1024) + return strprintf("%.2f MB", nBytes/1024.0/1024.0); + if (nBytes >= 1024) + return strprintf("%.2f KB", nBytes/1024.0); + + return strprintf("%d B", nBytes); +}; + +void ShrinkDebugFile() +{ + // Scroll debug.log if it's getting too big + boost::filesystem::path pathLog = GetDataDir() / "debug.log"; + FILE* file = fopen(pathLog.string().c_str(), "r"); + if (file && boost::filesystem::file_size(pathLog) > 10 * 1000000) + { + // Restart the file with some of the end + char pch[200000]; + fseek(file, -sizeof(pch), SEEK_END); + int nBytes = fread(pch, 1, sizeof(pch), file); + fclose(file); + + file = fopen(pathLog.string().c_str(), "w"); + if (file) + { + fwrite(pch, 1, nBytes, file); + fclose(file); + } + } +} + +static int64_t nMockTime = 0; // For unit testing + +int64_t GetTime() +{ + if (nMockTime) return nMockTime; + + return time(NULL); +} + +void SetMockTime(int64_t nMockTimeIn) +{ + nMockTime = nMockTimeIn; +} + +uint32_t insecure_rand_Rz = 11; +uint32_t insecure_rand_Rw = 11; +void seed_insecure_rand(bool fDeterministic) +{ + //The seed values have some unlikely fixed points which we avoid. + if(fDeterministic) + { + insecure_rand_Rz = insecure_rand_Rw = 11; + } else { + uint32_t tmp; + do{ + RAND_bytes((unsigned char*)&tmp,4); + }while(tmp==0 || tmp==0x9068ffffU); + insecure_rand_Rz=tmp; + do{ + RAND_bytes((unsigned char*)&tmp,4); + }while(tmp==0 || tmp==0x464fffffU); + insecure_rand_Rw=tmp; + } +} + +string FormatVersion(int nVersion) +{ + if (nVersion%100 == 0) + return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100); + else + return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100); +} + +string FormatFullVersion() +{ + return CLIENT_BUILD; +} + +// Format the subversion field according to BIP 14 spec (https://en.bitcoin.it/wiki/BIP_0014) +std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments) +{ + std::ostringstream ss; + ss << "/"; + ss << name << ":" << FormatVersion(nClientVersion); + if (!comments.empty()) + ss << "(" << boost::algorithm::join(comments, "; ") << ")"; + ss << "/"; + return ss.str(); +} + +#ifdef WIN32 +boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate) +{ + namespace fs = boost::filesystem; + + char pszPath[MAX_PATH] = ""; + + if(SHGetSpecialFolderPathA(NULL, pszPath, nFolder, fCreate)) + { + return fs::path(pszPath); + } + + LogPrintf("SHGetSpecialFolderPathA() failed, could not obtain requested path.\n"); + return fs::path(""); +} +#endif + +void runCommand(std::string strCommand) +{ + int nErr = ::system(strCommand.c_str()); + if (nErr) + LogPrintf("runCommand error: system(%s) returned %d\n", strCommand, nErr); +} + +void RenameThread(const char* name) +{ +#if defined(PR_SET_NAME) + // Only the first 15 characters are used (16 - NUL terminator) + ::prctl(PR_SET_NAME, name, 0, 0, 0); +#elif 0 && (defined(__FreeBSD__) || defined(__OpenBSD__)) + // TODO: This is currently disabled because it needs to be verified to work + // on FreeBSD or OpenBSD first. When verified the '0 &&' part can be + // removed. + pthread_set_name_np(pthread_self(), name); + +#elif defined(MAC_OSX) && defined(__MAC_OS_X_VERSION_MAX_ALLOWED) + +// pthread_setname_np is XCode 10.6-and-later +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 + pthread_setname_np(name); +#endif + +#else + // Prevent warnings for unused parameters... + (void)name; +#endif +} + +std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime) +{ + // std::locale takes ownership of the pointer + std::locale loc(std::locale::classic(), new boost::posix_time::time_facet(pszFormat)); + std::stringstream ss; + ss.imbue(loc); + ss << boost::posix_time::from_time_t(nTime); + return ss.str(); +} + + diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..19618e7 --- /dev/null +++ b/src/util.h @@ -0,0 +1,626 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_UTIL_H +#define BITCOIN_UTIL_H + +#ifndef WIN32 +#include +#include +#include +#endif + +#include "serialize.h" +#include "tinyformat.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include // for OPENSSL_cleanse() +#include +#include + +#include + +class uint256; + +static const int64_t COIN = 100000000; +static const int64_t CENT = 1000000; + +typedef int64_t CAmount; + +#define BEGIN(a) ((char*)&(a)) +#define END(a) ((char*)&((&(a))[1])) +#define UBEGIN(a) ((unsigned char*)&(a)) +#define UEND(a) ((unsigned char*)&((&(a))[1])) +#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0])) + +#define UVOIDBEGIN(a) ((void*)&(a)) +#define CVOIDBEGIN(a) ((const void*)&(a)) +#define UINTBEGIN(a) ((uint32_t*)&(a)) +#define CUINTBEGIN(a) ((const uint32_t*)&(a)) + +/* Format characters for (s)size_t and ptrdiff_t */ +#if defined(_MSC_VER) || defined(__MSVCRT__) + /* (s)size_t and ptrdiff_t have the same size specifier in MSVC: + http://msdn.microsoft.com/en-us/library/tcxf1dw6%28v=vs.100%29.aspx + */ + #define PRIszx "Ix" + #define PRIszu "Iu" + #define PRIszd "Id" + #define PRIpdx "Ix" + #define PRIpdu "Iu" + #define PRIpdd "Id" +#else /* C99 standard */ + #define PRIszx "zx" + #define PRIszu "zu" + #define PRIszd "zd" + #define PRIpdx "tx" + #define PRIpdu "tu" + #define PRIpdd "td" +#endif + +// This is needed because the foreach macro can't get over the comma in pair +#define PAIRTYPE(t1, t2) std::pair + +// Align by increasing pointer, must have extra space at end of buffer +template +T* alignup(T* p) +{ + union + { + T* ptr; + size_t n; + } u; + u.ptr = p; + u.n = (u.n + (nBytes-1)) & ~(nBytes-1); + return u.ptr; +} + +boost::filesystem::path GetMasternodeConfigFile(); + +#ifdef WIN32 +#define MSG_NOSIGNAL 0 +#define MSG_DONTWAIT 0 + +#ifndef S_IRUSR +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#endif +#else +#define MAX_PATH 1024 +#endif + +inline void MilliSleep(int64_t n) +{ +#if BOOST_VERSION >= 105000 + boost::this_thread::sleep_for(boost::chrono::milliseconds(n)); +#else + boost::this_thread::sleep(boost::posix_time::milliseconds(n)); +#endif +} + +//Dark features + +extern bool fMasterNode; +extern bool fLiteMode; +extern int nInstantXDepth; +extern int nDarksendRounds; +extern int nAnonymizeSONOAmount; +extern int nLiquidityProvider; +extern bool fEnableluxsend; +extern int64_t enforceMasternodePaymentsTime; +extern std::string strMasterNodeAddr; +extern int keysLoaded; +extern bool fSucessfullyLoaded; +extern std::vector darkSendDenominations; + + +extern std::map mapArgs; +extern std::map > mapMultiArgs; +extern bool fDebug; +extern bool fDebugSmsg; +extern bool fNoSmsg; +extern bool fPrintToConsole; +extern bool fPrintToDebugLog; +extern bool fDaemon; +extern bool fServer; +extern bool fCommandLine; +extern std::string strMiscWarning; +extern bool fNoListen; +extern bool fLogTimestamps; +extern volatile bool fReopenDebugLog; + +void RandAddSeed(); +void RandAddSeedPerfmon(); + + + +/* Return true if log accepts specified category */ +bool LogAcceptCategory(const char* category); +/* Send a string to the log output */ +int LogPrintStr(const std::string &str); + +#define LogPrintf(...) LogPrint(NULL, __VA_ARGS__) + +/* When we switch to C++11, this can be switched to variadic templates instead + * of this macro-based construction (see tinyformat.h). + */ +#define MAKE_ERROR_AND_LOG_FUNC(n) \ + /* Print to debug.log if -debug=category switch is given OR category is NULL. */ \ + template \ + static inline int LogPrint(const char* category, const char* format, TINYFORMAT_VARARGS(n)) \ + { \ + if(!LogAcceptCategory(category)) return 0; \ + return LogPrintStr(tfm::format(format, TINYFORMAT_PASSARGS(n))); \ + } \ + /* Log error and return false */ \ + template \ + static inline bool error(const char* format, TINYFORMAT_VARARGS(n)) \ + { \ + LogPrintStr("ERROR: " + tfm::format(format, TINYFORMAT_PASSARGS(n)) + "\n"); \ + return false; \ + } + +TINYFORMAT_FOREACH_ARGNUM(MAKE_ERROR_AND_LOG_FUNC) + +/* Zero-arg versions of logging and error, these are not covered by + * TINYFORMAT_FOREACH_ARGNUM + */ +static inline int LogPrint(const char* category, const char* format) +{ + if(!LogAcceptCategory(category)) return 0; + return LogPrintStr(format); +} +static inline bool error(const char* format) +{ + LogPrintStr(std::string("ERROR: ") + format + "\n"); + return false; +} + + +void PrintException(std::exception* pex, const char* pszThread); +void PrintExceptionContinue(std::exception* pex, const char* pszThread); +void ParseString(const std::string& str, char c, std::vector& v); +std::string FormatMoney(int64_t n, bool fPlus=false); +bool ParseMoney(const std::string& str, int64_t& nRet); +bool ParseMoney(const char* pszIn, int64_t& nRet); +std::string SanitizeString(const std::string& str); +std::vector ParseHex(const char* psz); +std::vector ParseHex(const std::string& str); +bool IsHex(const std::string& str); +std::vector DecodeBase64(const char* p, bool* pfInvalid = NULL); +std::string DecodeBase64(const std::string& str); +std::string EncodeBase64(const unsigned char* pch, size_t len); +std::string EncodeBase64(const std::string& str); +SecureString DecodeBase64Secure(const SecureString& input); +SecureString EncodeBase64Secure(const SecureString& input); +std::vector DecodeBase32(const char* p, bool* pfInvalid = NULL); +std::string DecodeBase32(const std::string& str); +std::string EncodeBase32(const unsigned char* pch, size_t len); +std::string EncodeBase32(const std::string& str); +void ParseParameters(int argc, const char*const argv[]); +bool WildcardMatch(const char* psz, const char* mask); +bool WildcardMatch(const std::string& str, const std::string& mask); +void FileCommit(FILE *fileout); +bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest); +boost::filesystem::path GetDefaultDataDir(); +boost::filesystem::path GetMasternodeConfigFile(); +const boost::filesystem::path &GetDataDir(bool fNetSpecific = true); +boost::filesystem::path GetConfigFile(); +boost::filesystem::path GetPidFile(); +#ifndef WIN32 +void CreatePidFile(const boost::filesystem::path &path, pid_t pid); +#endif +void ReadConfigFile(std::map& mapSettingsRet, std::map >& mapMultiSettingsRet); +#ifdef WIN32 +boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true); +#endif + +std::string getTimeString(int64_t timestamp, char *buffer, size_t nBuffer); +std::string bytesReadable(uint64_t nBytes); + +void ShrinkDebugFile(); +void GetRandBytes(unsigned char* buf, int num); +int GetRandInt(int nMax); +uint64_t GetRand(uint64_t nMax); +uint256 GetRandHash(); +int64_t GetTime(); +void SetMockTime(int64_t nMockTimeIn); +std::string FormatFullVersion(); +std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments); +void runCommand(std::string strCommand); + + + + +/** + * Convert string to signed 32-bit integer with strict parse error feedback. + * @returns true if the entire string could be parsed as valid integer, + * false if not the entire string could be parsed or when overflow or underflow occurred. + */ +bool ParseInt32(const std::string& str, int32_t *out); + + +/** + * Format a paragraph of text to a fixed width, adding spaces for + * indentation to any added line. + */ +std::string FormatParagraph(const std::string in, size_t width=79, size_t indent=0); + + + +inline std::string i64tostr(int64_t n) +{ + return strprintf("%d", n); +} + +inline std::string itostr(int n) +{ + return strprintf("%d", n); +} + +inline int64_t atoi64(const char* psz) +{ +#ifdef _MSC_VER + return _atoi64(psz); +#else + return strtoll(psz, NULL, 10); +#endif +} + +inline int64_t atoi64(const std::string& str) +{ +#ifdef _MSC_VER + return _atoi64(str.c_str()); +#else + return strtoll(str.c_str(), NULL, 10); +#endif +} + +inline int atoi(const std::string& str) +{ + return atoi(str.c_str()); +} + +inline int roundint(double d) +{ + return (int)(d > 0 ? d + 0.5 : d - 0.5); +} + +inline int64_t roundint64(double d) +{ + return (int64_t)(d > 0 ? d + 0.5 : d - 0.5); +} + +inline int64_t abs64(int64_t n) +{ + return (n >= 0 ? n : -n); +} + +inline std::string leftTrim(std::string src, char chr) +{ + std::string::size_type pos = src.find_first_not_of(chr, 0); + + if(pos > 0) + src.erase(0, pos); + + return src; +} + +template +std::string HexStr(const T itbegin, const T itend, bool fSpaces=false) +{ + std::string rv; + static const char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + rv.reserve((itend-itbegin)*3); + for(T it = itbegin; it < itend; ++it) + { + unsigned char val = (unsigned char)(*it); + if(fSpaces && it != itbegin) + rv.push_back(' '); + rv.push_back(hexmap[val>>4]); + rv.push_back(hexmap[val&15]); + } + + return rv; +} + +template +inline std::string HexStr(const T& vch, bool fSpaces=false) +{ + return HexStr(vch.begin(), vch.end(), fSpaces); +} + +inline int64_t GetPerformanceCounter() +{ + int64_t nCounter = 0; +#ifdef WIN32 + QueryPerformanceCounter((LARGE_INTEGER*)&nCounter); +#else + timeval t; + gettimeofday(&t, NULL); + nCounter = (int64_t) t.tv_sec * 1000000 + t.tv_usec; +#endif + return nCounter; +} + +inline int64_t GetTimeMillis() +{ + return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) - + boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds(); +} + +inline int64_t GetTimeMicros() +{ + return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) - + boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_microseconds(); +} + +std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime); + +static const std::string strTimestampFormat = "%Y-%m-%d %H:%M:%S UTC"; +inline std::string DateTimeStrFormat(int64_t nTime) +{ + return DateTimeStrFormat(strTimestampFormat.c_str(), nTime); +} + + +template +void skipspaces(T& it) +{ + while (isspace(*it)) + ++it; +} + +inline bool IsSwitchChar(char c) +{ +#ifdef WIN32 + return c == '-' || c == '/'; +#else + return c == '-'; +#endif +} + +/** + * Return string argument or default value + * + * @param strArg Argument to get (e.g. "-foo") + * @param default (e.g. "1") + * @return command-line argument or default value + */ +std::string GetArg(const std::string& strArg, const std::string& strDefault); + +/** + * Return integer argument or default value + * + * @param strArg Argument to get (e.g. "-foo") + * @param default (e.g. 1) + * @return command-line argument (0 if invalid number) or default value + */ +int64_t GetArg(const std::string& strArg, int64_t nDefault); + +/** + * Return boolean argument or default value + * + * @param strArg Argument to get (e.g. "-foo") + * @param default (true or false) + * @return command-line argument or default value + */ +bool GetBoolArg(const std::string& strArg, bool fDefault); + +/** + * Set an argument if it doesn't already have a value + * + * @param strArg Argument to set (e.g. "-foo") + * @param strValue Value (e.g. "1") + * @return true if argument gets set, false if it already had a value + */ +bool SoftSetArg(const std::string& strArg, const std::string& strValue); + +/** + * Set a boolean argument if it doesn't already have a value + * + * @param strArg Argument to set (e.g. "-foo") + * @param fValue Value (e.g. false) + * @return true if argument gets set, false if it already had a value + */ +bool SoftSetBoolArg(const std::string& strArg, bool fValue); + +/** + * MWC RNG of George Marsaglia + * This is intended to be fast. It has a period of 2^59.3, though the + * least significant 16 bits only have a period of about 2^30.1. + * + * @return random value + */ +extern uint32_t insecure_rand_Rz; +extern uint32_t insecure_rand_Rw; +static inline uint32_t insecure_rand(void) +{ + insecure_rand_Rz=36969*(insecure_rand_Rz&65535)+(insecure_rand_Rz>>16); + insecure_rand_Rw=18000*(insecure_rand_Rw&65535)+(insecure_rand_Rw>>16); + return (insecure_rand_Rw<<16)+insecure_rand_Rz; +} + +/** + * Seed insecure_rand using the random pool. + * @param Deterministic Use a determinstic seed + */ +void seed_insecure_rand(bool fDeterministic=false); + +/** + * Timing-attack-resistant comparison. + * Takes time proportional to length + * of first argument. + */ +template +bool TimingResistantEqual(const T& a, const T& b) +{ + if (b.size() == 0) return a.size() == 0; + size_t accumulator = a.size() ^ b.size(); + for (size_t i = 0; i < a.size(); i++) + accumulator |= a[i] ^ b[i%b.size()]; + return accumulator == 0; +} + +/** Median filter over a stream of values. + * Returns the median of the last N numbers + */ +template class CMedianFilter +{ +private: + std::vector vValues; + std::vector vSorted; + unsigned int nSize; +public: + CMedianFilter(unsigned int size, T initial_value): + nSize(size) + { + vValues.reserve(size); + vValues.push_back(initial_value); + vSorted = vValues; + } + + void input(T value) + { + if(vValues.size() == nSize) + { + vValues.erase(vValues.begin()); + } + vValues.push_back(value); + + vSorted.resize(vValues.size()); + std::copy(vValues.begin(), vValues.end(), vSorted.begin()); + std::sort(vSorted.begin(), vSorted.end()); + } + + T median() const + { + int size = vSorted.size(); + assert(size>0); + if(size & 1) // Odd number of elements + { + return vSorted[size/2]; + } + else // Even number of elements + { + return (vSorted[size/2-1] + vSorted[size/2]) / 2; + } + } + + int size() const + { + return vValues.size(); + } + + std::vector sorted () const + { + return vSorted; + } +}; + +#ifdef WIN32 +inline void SetThreadPriority(int nPriority) +{ + SetThreadPriority(GetCurrentThread(), nPriority); +} +#else + +#define THREAD_PRIORITY_LOWEST PRIO_MAX +#define THREAD_PRIORITY_BELOW_NORMAL 2 +#define THREAD_PRIORITY_NORMAL 0 +#define THREAD_PRIORITY_ABOVE_NORMAL 0 + +inline void SetThreadPriority(int nPriority) +{ + // It's unclear if it's even possible to change thread priorities on Linux, + // but we really and truly need it for the generation threads. +#ifdef PRIO_THREAD + setpriority(PRIO_THREAD, 0, nPriority); +#else + setpriority(PRIO_PROCESS, 0, nPriority); +#endif +} +#endif + +void RenameThread(const char* name); + +inline uint32_t ByteReverse(uint32_t value) +{ + value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8); + return (value<<16) | (value>>16); +} + +// Standard wrapper for do-something-forever thread functions. +// "Forever" really means until the thread is interrupted. +// Use it like: +// new boost::thread(boost::bind(&LoopForever, "dumpaddr", &DumpAddresses, 900000)); +// or maybe: +// boost::function f = boost::bind(&FunctionWithArg, argument); +// threadGroup.create_thread(boost::bind(&LoopForever >, "nothing", f, milliseconds)); +template void LoopForever(const char* name, Callable func, int64_t msecs) +{ + std::string s = strprintf("SONO-%s", name); + RenameThread(s.c_str()); + LogPrintf("%s thread start\n", name); + try + { + while (1) + { + MilliSleep(msecs); + func(); + } + } + catch (boost::thread_interrupted) + { + LogPrintf("%s thread stop\n", name); + throw; + } + catch (std::exception& e) { + PrintException(&e, name); + } + catch (...) { + PrintException(NULL, name); + } +} +// .. and a wrapper that just calls func once +template void TraceThread(const char* name, Callable func) +{ + std::string s = strprintf("SONO-%s", name); + RenameThread(s.c_str()); + try + { + LogPrintf("%s thread start\n", name); + func(); + LogPrintf("%s thread exit\n", name); + } + catch (boost::thread_interrupted) + { + LogPrintf("%s thread interrupt\n", name); + throw; + } + catch (std::exception& e) { + PrintException(&e, name); + } + catch (...) { + PrintException(NULL, name); + } +} + +#endif diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp new file mode 100644 index 0000000..64c7d92 --- /dev/null +++ b/src/utilstrencodings.cpp @@ -0,0 +1,489 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2015 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "utilstrencodings.h" + +#include "tinyformat.h" + +#include +#include +#include +#include + +using namespace std; + + + + + + + +string EncodeBase64(const unsigned char* pch, size_t len) +{ + static const char *pbase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + string strRet=""; + strRet.reserve((len+2)/3*4); + + int mode=0, left=0; + const unsigned char *pchEnd = pch+len; + + while (pch> 2]; + left = (enc & 3) << 4; + mode = 1; + break; + + case 1: // we have two bits + strRet += pbase64[left | (enc >> 4)]; + left = (enc & 15) << 2; + mode = 2; + break; + + case 2: // we have four bits + strRet += pbase64[left | (enc >> 6)]; + strRet += pbase64[enc & 63]; + mode = 0; + break; + } + } + + if (mode) + { + strRet += pbase64[left]; + strRet += '='; + if (mode == 1) + strRet += '='; + } + + return strRet; +} + +string EncodeBase64(const string& str) +{ + return EncodeBase64((const unsigned char*)str.c_str(), str.size()); +} + +vector DecodeBase64(const char* p, bool* pfInvalid) +{ + static const int decode64_table[256] = + { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, + -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + }; + + if (pfInvalid) + *pfInvalid = false; + + vector vchRet; + vchRet.reserve(strlen(p)*3/4); + + int mode = 0; + int left = 0; + + while (1) + { + int dec = decode64_table[(unsigned char)*p]; + if (dec == -1) break; + p++; + switch (mode) + { + case 0: // we have no bits and get 6 + left = dec; + mode = 1; + break; + + case 1: // we have 6 bits and keep 4 + vchRet.push_back((left<<2) | (dec>>4)); + left = dec & 15; + mode = 2; + break; + + case 2: // we have 4 bits and get 6, we keep 2 + vchRet.push_back((left<<4) | (dec>>2)); + left = dec & 3; + mode = 3; + break; + + case 3: // we have 2 bits and get 6 + vchRet.push_back((left<<6) | dec); + mode = 0; + break; + } + } + + if (pfInvalid) + switch (mode) + { + case 0: // 4n base64 characters processed: ok + break; + + case 1: // 4n+1 base64 character processed: impossible + *pfInvalid = true; + break; + + case 2: // 4n+2 base64 characters processed: require '==' + if (left || p[0] != '=' || p[1] != '=' || decode64_table[(unsigned char)p[2]] != -1) + *pfInvalid = true; + break; + + case 3: // 4n+3 base64 characters processed: require '=' + if (left || p[0] != '=' || decode64_table[(unsigned char)p[1]] != -1) + *pfInvalid = true; + break; + } + + return vchRet; +} + +string DecodeBase64(const string& str) +{ + vector vchRet = DecodeBase64(str.c_str()); + return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size()); +} + +// Base64 encoding with secure memory allocation +SecureString EncodeBase64Secure(const SecureString& input) +{ + // Init openssl BIO with base64 filter and memory output + BIO *b64, *mem; + b64 = BIO_new(BIO_f_base64()); + BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); // No newlines in output + mem = BIO_new(BIO_s_mem()); + BIO_push(b64, mem); + + // Decode the string + BIO_write(b64, &input[0], input.size()); + (void) BIO_flush(b64); + + // Create output variable from buffer mem ptr + BUF_MEM *bptr; + BIO_get_mem_ptr(b64, &bptr); + SecureString output(bptr->data, bptr->length); + + // Cleanse secure data buffer from memory + OPENSSL_cleanse((void *) bptr->data, bptr->length); + + // Free memory + BIO_free_all(b64); + return output; +} + +// Base64 decoding with secure memory allocation +SecureString DecodeBase64Secure(const SecureString& input) +{ + SecureString output; + + // Init openssl BIO with base64 filter and memory input + BIO *b64, *mem; + b64 = BIO_new(BIO_f_base64()); + BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); //Do not use newlines to flush buffer + mem = BIO_new_mem_buf((void *) &input[0], input.size()); + BIO_push(b64, mem); + + // Prepare buffer to receive decoded data + if(input.size() % 4 != 0) { + throw runtime_error("Input length should be a multiple of 4"); + } + size_t nMaxLen = input.size() / 4 * 3; // upper bound, guaranteed divisible by 4 + output.resize(nMaxLen); + + // Decode the string + size_t nLen; + nLen = BIO_read(b64, (void *) &output[0], input.size()); + output.resize(nLen); + + // Free memory + BIO_free_all(b64); + return output; +} + + + + +string EncodeBase32(const unsigned char* pch, size_t len) +{ + static const char *pbase32 = "abcdefghijklmnopqrstuvwxyz234567"; + + string strRet=""; + strRet.reserve((len+4)/5*8); + + int mode=0, left=0; + const unsigned char *pchEnd = pch+len; + + while (pch> 3]; + left = (enc & 7) << 2; + mode = 1; + break; + + case 1: // we have three bits + strRet += pbase32[left | (enc >> 6)]; + strRet += pbase32[(enc >> 1) & 31]; + left = (enc & 1) << 4; + mode = 2; + break; + + case 2: // we have one bit + strRet += pbase32[left | (enc >> 4)]; + left = (enc & 15) << 1; + mode = 3; + break; + + case 3: // we have four bits + strRet += pbase32[left | (enc >> 7)]; + strRet += pbase32[(enc >> 2) & 31]; + left = (enc & 3) << 3; + mode = 4; + break; + + case 4: // we have two bits + strRet += pbase32[left | (enc >> 5)]; + strRet += pbase32[enc & 31]; + mode = 0; + } + } + + static const int nPadding[5] = {0, 6, 4, 3, 1}; + if (mode) + { + strRet += pbase32[left]; + for (int n=0; n DecodeBase32(const char* p, bool* pfInvalid) +{ + static const int decode32_table[256] = + { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 0, 1, 2, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + }; + + if (pfInvalid) + *pfInvalid = false; + + vector vchRet; + vchRet.reserve((strlen(p))*5/8); + + int mode = 0; + int left = 0; + + while (1) + { + int dec = decode32_table[(unsigned char)*p]; + if (dec == -1) break; + p++; + switch (mode) + { + case 0: // we have no bits and get 5 + left = dec; + mode = 1; + break; + + case 1: // we have 5 bits and keep 2 + vchRet.push_back((left<<3) | (dec>>2)); + left = dec & 3; + mode = 2; + break; + + case 2: // we have 2 bits and keep 7 + left = left << 5 | dec; + mode = 3; + break; + + case 3: // we have 7 bits and keep 4 + vchRet.push_back((left<<1) | (dec>>4)); + left = dec & 15; + mode = 4; + break; + + case 4: // we have 4 bits, and keep 1 + vchRet.push_back((left<<4) | (dec>>1)); + left = dec & 1; + mode = 5; + break; + + case 5: // we have 1 bit, and keep 6 + left = left << 5 | dec; + mode = 6; + break; + + case 6: // we have 6 bits, and keep 3 + vchRet.push_back((left<<2) | (dec>>3)); + left = dec & 7; + mode = 7; + break; + + case 7: // we have 3 bits, and keep 0 + vchRet.push_back((left<<5) | dec); + mode = 0; + break; + } + } + + if (pfInvalid) + switch (mode) + { + case 0: // 8n base32 characters processed: ok + break; + + case 1: // 8n+1 base32 characters processed: impossible + case 3: // +3 + case 6: // +6 + *pfInvalid = true; + break; + + case 2: // 8n+2 base32 characters processed: require '======' + if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || p[3] != '=' || p[4] != '=' || p[5] != '=' || decode32_table[(unsigned char)p[6]] != -1) + *pfInvalid = true; + break; + + case 4: // 8n+4 base32 characters processed: require '====' + if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || p[3] != '=' || decode32_table[(unsigned char)p[4]] != -1) + *pfInvalid = true; + break; + + case 5: // 8n+5 base32 characters processed: require '===' + if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || decode32_table[(unsigned char)p[3]] != -1) + *pfInvalid = true; + break; + + case 7: // 8n+7 base32 characters processed: require '=' + if (left || p[0] != '=' || decode32_table[(unsigned char)p[1]] != -1) + *pfInvalid = true; + break; + } + + return vchRet; +} + +string DecodeBase32(const string& str) +{ + vector vchRet = DecodeBase32(str.c_str()); + return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size()); +} + +bool ParseInt32(const std::string& str, int32_t *out) +{ + char *endp = NULL; + errno = 0; // strtol will not set errno if valid + long int n = strtol(str.c_str(), &endp, 10); + if(out) *out = (int)n; + // Note that strtol returns a *long int*, so even if strtol doesn't report a over/underflow + // we still have to check that the returned value is within the range of an *int32_t*. On 64-bit + // platforms the size of these types may be different. + return endp && *endp == 0 && !errno && + n >= std::numeric_limits::min() && + n <= std::numeric_limits::max(); +} + +std::string FormatParagraph(const std::string in, size_t width, size_t indent) +{ + std::stringstream out; + size_t col = 0; + size_t ptr = 0; + while(ptr < in.size()) + { + // Find beginning of next word + ptr = in.find_first_not_of(' ', ptr); + if (ptr == std::string::npos) + break; + // Find end of next word + size_t endword = in.find_first_of(' ', ptr); + if (endword == std::string::npos) + endword = in.size(); + // Add newline and indentation if this wraps over the allowed width + if (col > 0) + { + if ((col + endword - ptr) > width) + { + out << '\n'; + for(size_t i=0; i +#include +#include +#include "serialize.h" +#include "allocators.h" + + +#include +#include +#include +#include +#include // for OPENSSL_cleanse() +#include +#include + + +#define BEGIN(a) ((char*)&(a)) +#define END(a) ((char*)&((&(a))[1])) +#define UBEGIN(a) ((unsigned char*)&(a)) +#define UEND(a) ((unsigned char*)&((&(a))[1])) +#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0])) + +/** This is needed because the foreach macro can't get over the comma in pair */ +#define PAIRTYPE(t1, t2) std::pair + + + +std::vector DecodeBase64(const char* p, bool* pfInvalid = NULL); +std::string DecodeBase64(const std::string& str); +std::string EncodeBase64(const unsigned char* pch, size_t len); +std::string EncodeBase64(const std::string& str); +SecureString DecodeBase64Secure(const SecureString& input); +SecureString EncodeBase64Secure(const SecureString& input); +std::vector DecodeBase32(const char* p, bool* pfInvalid = NULL); +std::string DecodeBase32(const std::string& str); +std::string EncodeBase32(const unsigned char* pch, size_t len); +std::string EncodeBase32(const std::string& str); + + +std::string i64tostr(int64_t n); +std::string itostr(int n); +int64_t atoi64(const char* psz); +int64_t atoi64(const std::string& str); +int atoi(const std::string& str); + +/** + * Convert string to signed 32-bit integer with strict parse error feedback. + * @returns true if the entire string could be parsed as valid integer, + * false if not the entire string could be parsed or when overflow or underflow occurred. + */ +bool ParseInt32(const std::string& str, int32_t *out); + +template +std::string HexStr(const T itbegin, const T itend, bool fSpaces=false) +{ + std::string rv; + static const char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + rv.reserve((itend-itbegin)*3); + for(T it = itbegin; it < itend; ++it) + { + unsigned char val = (unsigned char)(*it); + if(fSpaces && it != itbegin) + rv.push_back(' '); + rv.push_back(hexmap[val>>4]); + rv.push_back(hexmap[val&15]); + } + + return rv; +} + +template +inline std::string HexStr(const T& vch, bool fSpaces=false) +{ + return HexStr(vch.begin(), vch.end(), fSpaces); +} + +/** + * Format a paragraph of text to a fixed width, adding spaces for + * indentation to any added line. + */ +std::string FormatParagraph(const std::string in, size_t width=79, size_t indent=0); + +/** + * Timing-attack-resistant comparison. + * Takes time proportional to length + * of first argument. + */ +template +bool TimingResistantEqual(const T& a, const T& b) +{ + if (b.size() == 0) return a.size() == 0; + size_t accumulator = a.size() ^ b.size(); + for (size_t i = 0; i < a.size(); i++) + accumulator |= a[i] ^ b[i%b.size()]; + return accumulator == 0; +} + +#endif // BITCOIN_UTILSTRENCODINGS_H diff --git a/src/version.cpp b/src/version.cpp new file mode 100644 index 0000000..281616a --- /dev/null +++ b/src/version.cpp @@ -0,0 +1,66 @@ +// Copyright (c) 2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include + +#include "version.h" + +// Name of client reported in the 'version' message. Report the same name +// for both bitcoind and bitcoin-qt, to make it harder for attackers to +// target servers or GUI users specifically. +const std::string CLIENT_NAME("SONO"); + +// Client version number +#define CLIENT_VERSION_SUFFIX "" + + +// The following part of the code determines the CLIENT_BUILD variable. +// Several mechanisms are used for this: +// * first, if HAVE_BUILD_INFO is defined, include build.h, a file that is +// generated by the build environment, possibly containing the output +// of git-describe in a macro called BUILD_DESC +// * secondly, if this is an exported version of the code, GIT_ARCHIVE will +// be defined (automatically using the export-subst git attribute), and +// GIT_COMMIT will contain the commit id. +// * then, three options exist for determining CLIENT_BUILD: +// * if BUILD_DESC is defined, use that literally (output of git-describe) +// * if not, but GIT_COMMIT is defined, use v[maj].[min].[rev].[build]-g[commit] +// * otherwise, use v[maj].[min].[rev].[build]-unk +// finally CLIENT_VERSION_SUFFIX is added + +// First, include build.h if requested +#ifdef HAVE_BUILD_INFO +# include "build.h" +#endif + +// git will put "#define GIT_ARCHIVE 1" on the next line inside archives. +#define GIT_ARCHIVE 1 +#ifdef GIT_ARCHIVE +# define GIT_COMMIT_ID "" +//# define GIT_COMMIT_DATE "$Format:%cD" +#endif + +#define BUILD_DESC_FROM_COMMIT(maj,min,rev,build,commit) \ + "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "" commit + +#define BUILD_DESC_FROM_UNKNOWN(maj,min,rev,build) \ + "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "" + +#ifndef BUILD_DESC +# ifdef GIT_COMMIT_ID +# define BUILD_DESC BUILD_DESC_FROM_COMMIT(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, GIT_COMMIT_ID) +# else +# define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD) +# endif +#endif + +#ifndef BUILD_DATE +# ifdef GIT_COMMIT_DATE +# define BUILD_DATE GIT_COMMIT_DATE +# else +# define BUILD_DATE __DATE__ ", " __TIME__ +# endif +#endif + +const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX); +const std::string CLIENT_DATE(BUILD_DATE); diff --git a/src/version.h b/src/version.h new file mode 100644 index 0000000..f67467a --- /dev/null +++ b/src/version.h @@ -0,0 +1,59 @@ +// Copyright (c) 2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_VERSION_H +#define BITCOIN_VERSION_H + +#include "clientversion.h" +#include + +// +// client versioning +// + +static const int CLIENT_VERSION = + 1000000 * CLIENT_VERSION_MAJOR + + 10000 * CLIENT_VERSION_MINOR + + 100 * CLIENT_VERSION_REVISION + + 1 * CLIENT_VERSION_BUILD; + +extern const std::string CLIENT_NAME; +extern const std::string CLIENT_BUILD; +extern const std::string CLIENT_DATE; + +// +// database format versioning +// +static const int DATABASE_VERSION = 70510; + +// +// network protocol versioning +// + +static const int PROTOCOL_VERSION = 70004; + +// intial proto version, to be increased after version/verack negotiation +static const int INIT_PROTO_VERSION = 209; + +// disconnect from peers older than this proto version +static const int MIN_PEER_PROTO_VERSION = 70001; + +static const int MIN_INSTANTX_PROTO_VERSION = 70004; + +static const int MIN_MN_PROTO_VERSION = 70000; + +// nTime field added to CAddress, starting with this version; +// if possible, avoid requesting addresses nodes older than this +static const int CADDR_TIME_VERSION = 31402; + +// only request blocks from nodes outside this range of versions +static const int NOBLKS_VERSION_START = 60002; +static const int NOBLKS_VERSION_END = 60006; + +// BIP 0031, pong message, is enabled for all versions AFTER this one +static const int BIP0031_VERSION = 60000; + +// "mempool" command, enhanced "getdata" behavior starts with this version: +static const int MEMPOOL_GD_VERSION = 60005; + +#endif diff --git a/src/wallet.cpp b/src/wallet.cpp new file mode 100644 index 0000000..395845e --- /dev/null +++ b/src/wallet.cpp @@ -0,0 +1,4480 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "wallet.h" + +#include "base58.h" +#include "coincontrol.h" +#include "kernel.h" +#include "net.h" +#include "timedata.h" +#include "txdb.h" +#include "ui_interface.h" +#include "walletdb.h" +#include "crypter.h" +#include "key.h" +#include "spork.h" +#include "darksend.h" +#include "instantx.h" +#include "masternode.h" +#include "chainparams.h" +#include "smessage.h" + +#include +#include +#include + +using namespace std; + +// Settings +int64_t nTransactionFee = MIN_TX_FEE; +int64_t nReserveBalance = 0; +int64_t nMinimumInputValue = 0; + +//static unsigned int GetStakeSplitAge() { return 9 * 24 * 60 * 60; } +static int64_t GetStakeCombineThreshold() { return 500 * COIN; } + +int64_t gcd(int64_t n,int64_t m) { return m == 0 ? n : gcd(m, n % m); } +static uint64_t CoinWeightCost(const COutput &out) +{ + int64_t nTimeWeight = (int64_t)GetTime() - (int64_t)out.tx->nTime; + CBigNum bnCoinDayWeight = CBigNum(out.tx->vout[out.i].nValue) * nTimeWeight / (24 * 60 * 60); + return bnCoinDayWeight.getuint64(); +} + + +// mapWallet + + +struct CompareValueOnly +{ + bool operator()(const pair >& t1, + const pair >& t2) const + { + return t1.first < t2.first; + } +}; + +CPubKey CWallet::GenerateNewKey() +{ + AssertLockHeld(cs_wallet); // mapKeyMetadata + bool fCompressed = CanSupportFeature(FEATURE_COMPRPUBKEY); // default to compressed public keys if we want 0.6.0 wallets + + RandAddSeedPerfmon(); + CKey secret; + secret.MakeNewKey(fCompressed); + + // Compressed public keys were introduced in version 0.6.0 + if (fCompressed) + SetMinVersion(FEATURE_COMPRPUBKEY); + + CPubKey pubkey = secret.GetPubKey(); + + // Create new metadata + int64_t nCreationTime = GetTime(); + mapKeyMetadata[pubkey.GetID()] = CKeyMetadata(nCreationTime); + if (!nTimeFirstKey || nCreationTime < nTimeFirstKey) + nTimeFirstKey = nCreationTime; + + if (!AddKeyPubKey(secret, pubkey)) + throw std::runtime_error("CWallet::GenerateNewKey() : AddKey failed"); + return pubkey; +} + +bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey) +{ + AssertLockHeld(cs_wallet); // mapKeyMetadata + if (!CCryptoKeyStore::AddKeyPubKey(secret, pubkey)) + return false; + if (!fFileBacked) + return true; + if (!IsCrypted()) { + return CWalletDB(strWalletFile).WriteKey(pubkey, secret.GetPrivKey(), mapKeyMetadata[pubkey.GetID()]); + } + return true; +} + +bool CWallet::AddCryptedKey(const CPubKey &vchPubKey, const vector &vchCryptedSecret) +{ + if (!CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret)) + return false; + if (!fFileBacked) + return true; + { + LOCK(cs_wallet); + if (pwalletdbEncryption) + return pwalletdbEncryption->WriteCryptedKey(vchPubKey, vchCryptedSecret, mapKeyMetadata[vchPubKey.GetID()]); + else + return CWalletDB(strWalletFile).WriteCryptedKey(vchPubKey, vchCryptedSecret, mapKeyMetadata[vchPubKey.GetID()]); + } + return false; +} + +bool CWallet::LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &meta) +{ + AssertLockHeld(cs_wallet); // mapKeyMetadata + if (meta.nCreateTime && (!nTimeFirstKey || meta.nCreateTime < nTimeFirstKey)) + nTimeFirstKey = meta.nCreateTime; + + mapKeyMetadata[pubkey.GetID()] = meta; + return true; +} + +bool CWallet::LoadCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret) +{ + return CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret); +} + +bool CWallet::AddCScript(const CScript& redeemScript) +{ + if (!CCryptoKeyStore::AddCScript(redeemScript)) + return false; + if (!fFileBacked) + return true; + return CWalletDB(strWalletFile).WriteCScript(Hash160(redeemScript), redeemScript); +} + +// optional setting to unlock wallet for staking only +// serves to disable the trivial sendmoney when OS account compromised +// provides no real security +bool fWalletUnlockStakingOnly = false; + +bool CWallet::LoadCScript(const CScript& redeemScript) +{ + /* A sanity check was added in pull #3843 to avoid adding redeemScripts + * that never can be redeemed. However, old wallets may still contain + * these. Do not add them to the wallet and warn. */ + if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE) + { + std::string strAddr = CBitcoinAddress(redeemScript.GetID()).ToString(); + LogPrintf("%s: Warning: This wallet contains a redeemScript of size %u which exceeds maximum size %i thus can never be redeemed. Do not use address %s.\n", + __func__, redeemScript.size(), MAX_SCRIPT_ELEMENT_SIZE, strAddr); + return true; + } + + return CCryptoKeyStore::AddCScript(redeemScript); +} + +bool CWallet::Lock() +{ + if (IsLocked()) + return true; + + if (fDebug) + printf("Locking wallet.\n"); + + { + LOCK(cs_wallet); + CWalletDB wdb(strWalletFile); + + // -- load encrypted spend_secret of stealth addresses + CStealthAddress sxAddrTemp; + std::set::iterator it; + for (it = stealthAddresses.begin(); it != stealthAddresses.end(); ++it) + { + if (it->scan_secret.size() < 32) + continue; // stealth address is not owned + // -- CStealthAddress are only sorted on spend_pubkey + CStealthAddress &sxAddr = const_cast(*it); + if (fDebug) + printf("Recrypting stealth key %s\n", sxAddr.Encoded().c_str()); + + sxAddrTemp.scan_pubkey = sxAddr.scan_pubkey; + if (!wdb.ReadStealthAddress(sxAddrTemp)) + { + printf("Error: Failed to read stealth key from db %s\n", sxAddr.Encoded().c_str()); + continue; + } + sxAddr.spend_secret = sxAddrTemp.spend_secret; + }; + } + return LockKeyStore(); +}; + +bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool anonymizeOnly) +{ + SecureString strWalletPassphraseFinal; + + if(!IsLocked()) + { + fWalletUnlockAnonymizeOnly = anonymizeOnly; + return true; + } + + strWalletPassphraseFinal = strWalletPassphrase; + + CCrypter crypter; + CKeyingMaterial vMasterKey; + + { + LOCK(cs_wallet); + BOOST_FOREACH(const MasterKeyMap::value_type& pMasterKey, mapMasterKeys) + { + if(!crypter.SetKeyFromPassphrase(strWalletPassphraseFinal, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) + return false; + if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey)) + return false; + if (!CCryptoKeyStore::Unlock(vMasterKey)) + return false; + break; + } + + fWalletUnlockAnonymizeOnly = anonymizeOnly; + UnlockStealthAddresses(vMasterKey); + return true; + } + return false; +} + +bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase) +{ + bool fWasLocked = IsLocked(); + + SecureString strOldWalletPassphraseFinal; + strOldWalletPassphraseFinal = strOldWalletPassphrase; + + { + LOCK(cs_wallet); + Lock(); + + CCrypter crypter; + CKeyingMaterial vMasterKey; + BOOST_FOREACH(MasterKeyMap::value_type& pMasterKey, mapMasterKeys) + { + if(!crypter.SetKeyFromPassphrase(strOldWalletPassphraseFinal, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) + return false; + if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey)) + return false; + if (CCryptoKeyStore::Unlock(vMasterKey) + && UnlockStealthAddresses(vMasterKey)) + { + int64_t nStartTime = GetTimeMillis(); + crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod); + pMasterKey.second.nDeriveIterations = pMasterKey.second.nDeriveIterations * (100 / ((double)(GetTimeMillis() - nStartTime))); + + nStartTime = GetTimeMillis(); + crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod); + pMasterKey.second.nDeriveIterations = (pMasterKey.second.nDeriveIterations + pMasterKey.second.nDeriveIterations * 100 / ((double)(GetTimeMillis() - nStartTime))) / 2; + + if (pMasterKey.second.nDeriveIterations < 25000) + pMasterKey.second.nDeriveIterations = 25000; + + LogPrintf("Wallet passphrase changed to an nDeriveIterations of %i\n", pMasterKey.second.nDeriveIterations); + + if (!crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) + return false; + if (!crypter.Encrypt(vMasterKey, pMasterKey.second.vchCryptedKey)) + return false; + CWalletDB(strWalletFile).WriteMasterKey(pMasterKey.first, pMasterKey.second); + if (fWasLocked) + Lock(); + + return true; + } + } + } + + return false; +} + +void CWallet::SetBestChain(const CBlockLocator& loc) +{ + CWalletDB walletdb(strWalletFile); + walletdb.WriteBestBlock(loc); +} + +bool CWallet::SetMinVersion(enum WalletFeature nVersion, CWalletDB* pwalletdbIn, bool fExplicit) +{ + LOCK(cs_wallet); // nWalletVersion + if (nWalletVersion >= nVersion) + return true; + + // when doing an explicit upgrade, if we pass the max version permitted, upgrade all the way + if (fExplicit && nVersion > nWalletMaxVersion) + nVersion = FEATURE_LATEST; + + nWalletVersion = nVersion; + + if (nVersion > nWalletMaxVersion) + nWalletMaxVersion = nVersion; + + if (fFileBacked) + { + CWalletDB* pwalletdb = pwalletdbIn ? pwalletdbIn : new CWalletDB(strWalletFile); + if (nWalletVersion > 40000) + pwalletdb->WriteMinVersion(nWalletVersion); + if (!pwalletdbIn) + delete pwalletdb; + } + + return true; +} + +bool CWallet::SetMaxVersion(int nVersion) +{ + LOCK(cs_wallet); // nWalletVersion, nWalletMaxVersion + // cannot downgrade below current version + if (nWalletVersion > nVersion) + return false; + + nWalletMaxVersion = nVersion; + + return true; +} + +bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) +{ + if (IsCrypted()) + return false; + + CKeyingMaterial vMasterKey; + RandAddSeedPerfmon(); + + vMasterKey.resize(WALLET_CRYPTO_KEY_SIZE); + RAND_bytes(&vMasterKey[0], WALLET_CRYPTO_KEY_SIZE); + + CMasterKey kMasterKey(nDerivationMethodIndex); + + RandAddSeedPerfmon(); + kMasterKey.vchSalt.resize(WALLET_CRYPTO_SALT_SIZE); + RAND_bytes(&kMasterKey.vchSalt[0], WALLET_CRYPTO_SALT_SIZE); + + CCrypter crypter; + int64_t nStartTime = GetTimeMillis(); + crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, 25000, kMasterKey.nDerivationMethod); + kMasterKey.nDeriveIterations = 2500000 / ((double)(GetTimeMillis() - nStartTime)); + + nStartTime = GetTimeMillis(); + crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod); + kMasterKey.nDeriveIterations = (kMasterKey.nDeriveIterations + kMasterKey.nDeriveIterations * 100 / ((double)(GetTimeMillis() - nStartTime))) / 2; + + if (kMasterKey.nDeriveIterations < 25000) + kMasterKey.nDeriveIterations = 25000; + + LogPrintf("Encrypting Wallet with an nDeriveIterations of %i\n", kMasterKey.nDeriveIterations); + + if (!crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod)) + return false; + if (!crypter.Encrypt(vMasterKey, kMasterKey.vchCryptedKey)) + return false; + + { + LOCK(cs_wallet); + mapMasterKeys[++nMasterKeyMaxID] = kMasterKey; + if (fFileBacked) + { + pwalletdbEncryption = new CWalletDB(strWalletFile); + if (!pwalletdbEncryption->TxnBegin()) + return false; + pwalletdbEncryption->WriteMasterKey(nMasterKeyMaxID, kMasterKey); + } + + if (!EncryptKeys(vMasterKey)) + { + if (fFileBacked) + pwalletdbEncryption->TxnAbort(); + exit(1); //We now probably have half of our keys encrypted in memory, and half not...die and let the user reload their unencrypted wallet. + } + + std::set::iterator it; + for (it = stealthAddresses.begin(); it != stealthAddresses.end(); ++it) + { + if (it->scan_secret.size() < 32) + continue; // stealth address is not owned + // -- CStealthAddress is only sorted on spend_pubkey + CStealthAddress &sxAddr = const_cast(*it); + + if (fDebug) + printf("Encrypting stealth key %s\n", sxAddr.Encoded().c_str()); + + std::vector vchCryptedSecret; + + CSecret vchSecret; + vchSecret.resize(32); + memcpy(&vchSecret[0], &sxAddr.spend_secret[0], 32); + + uint256 iv = Hash(sxAddr.spend_pubkey.begin(), sxAddr.spend_pubkey.end()); + if (!EncryptSecret(vMasterKey, vchSecret, iv, vchCryptedSecret)) + { + printf("Error: Failed encrypting stealth key %s\n", sxAddr.Encoded().c_str()); + continue; + }; + + sxAddr.spend_secret = vchCryptedSecret; + pwalletdbEncryption->WriteStealthAddress(sxAddr); + }; + + // Encryption was introduced in version 0.4.0 + SetMinVersion(FEATURE_WALLETCRYPT, pwalletdbEncryption, true); + + if (fFileBacked) + { + if (!pwalletdbEncryption->TxnCommit()) + exit(1); //We now have keys encrypted in memory, but no on disk...die to avoid confusion and let the user reload their unencrypted wallet. + + delete pwalletdbEncryption; + pwalletdbEncryption = NULL; + } + + Lock(); + Unlock(strWalletPassphrase); + NewKeyPool(); + Lock(); + + // Need to completely rewrite the wallet file; if we don't, bdb might keep + // bits of the unencrypted private key in slack space in the database file. + CDB::Rewrite(strWalletFile); + + } + NotifyStatusChanged(this); + + return true; +} + +int64_t CWallet::IncOrderPosNext(CWalletDB *pwalletdb) +{ + AssertLockHeld(cs_wallet); // nOrderPosNext + int64_t nRet = nOrderPosNext++; + if (pwalletdb) { + pwalletdb->WriteOrderPosNext(nOrderPosNext); + } else { + CWalletDB(strWalletFile).WriteOrderPosNext(nOrderPosNext); + } + return nRet; +} + +CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, std::string strAccount) +{ + AssertLockHeld(cs_wallet); // mapWallet + CWalletDB walletdb(strWalletFile); + + // First: get all CWalletTx and CAccountingEntry into a sorted-by-order multimap. + TxItems txOrdered; + + // Note: maintaining indices in the database of (account,time) --> txid and (account, time) --> acentry + // would make this much faster for applications that do this a lot. + for (map::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + CWalletTx* wtx = &((*it).second); + txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0))); + } + acentries.clear(); + walletdb.ListAccountCreditDebit(strAccount, acentries); + BOOST_FOREACH(CAccountingEntry& entry, acentries) + { + txOrdered.insert(make_pair(entry.nOrderPos, TxPair((CWalletTx*)0, &entry))); + } + + return txOrdered; +} + +void CWallet::WalletUpdateSpent(const CTransaction &tx, bool fBlock) +{ + // Anytime a signature is successfully verified, it's proof the outpoint is spent. + // Update the wallet spent flag if it doesn't know due to wallet.dat being + // restored from backup or the user making copies of wallet.dat. + { + LOCK(cs_wallet); + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + map::iterator mi = mapWallet.find(txin.prevout.hash); + if (mi != mapWallet.end()) + { + CWalletTx& wtx = (*mi).second; + if (txin.prevout.n >= wtx.vout.size()) + LogPrintf("WalletUpdateSpent: bad wtx %s\n", wtx.GetHash().ToString()); + else if (!wtx.IsSpent(txin.prevout.n) && IsMine(wtx.vout[txin.prevout.n])) + { + LogPrintf("WalletUpdateSpent found spent coin %s BC %s\n", FormatMoney(wtx.GetCredit()), wtx.GetHash().ToString()); + wtx.MarkSpent(txin.prevout.n); + wtx.WriteToDisk(); + NotifyTransactionChanged(this, txin.prevout.hash, CT_UPDATED); + } + } + } + + if (fBlock) + { + uint256 hash = tx.GetHash(); + map::iterator mi = mapWallet.find(hash); + CWalletTx& wtx = (*mi).second; + + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + if (IsMine(txout)) + { + wtx.MarkUnspent(&txout - &tx.vout[0]); + wtx.WriteToDisk(); + NotifyTransactionChanged(this, hash, CT_UPDATED); + } + } + } + + } +} + +void CWallet::MarkDirty() +{ + { + LOCK(cs_wallet); + BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) + item.second.MarkDirty(); + } +} + +bool CWallet::AddToWallet(const CWalletTx& wtxIn) +{ + uint256 hash = wtxIn.GetHash(); + { + LOCK(cs_wallet); + // Inserts only if not already there, returns tx inserted or tx found + pair::iterator, bool> ret = mapWallet.insert(make_pair(hash, wtxIn)); + CWalletTx& wtx = (*ret.first).second; + wtx.BindWallet(this); + bool fInsertedNew = ret.second; + if (fInsertedNew) + { + wtx.nTimeReceived = GetAdjustedTime(); + wtx.nOrderPos = IncOrderPosNext(); + + wtx.nTimeSmart = wtx.nTimeReceived; + if (wtxIn.hashBlock != 0) + { + if (mapBlockIndex.count(wtxIn.hashBlock)) + { + unsigned int latestNow = wtx.nTimeReceived; + unsigned int latestEntry = 0; + { + // Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future + int64_t latestTolerated = latestNow + 300; + std::list acentries; + TxItems txOrdered = OrderedTxItems(acentries); + for (TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) + { + CWalletTx *const pwtx = (*it).second.first; + if (pwtx == &wtx) + continue; + CAccountingEntry *const pacentry = (*it).second.second; + int64_t nSmartTime; + if (pwtx) + { + nSmartTime = pwtx->nTimeSmart; + if (!nSmartTime) + nSmartTime = pwtx->nTimeReceived; + } + else + nSmartTime = pacentry->nTime; + if (nSmartTime <= latestTolerated) + { + latestEntry = nSmartTime; + if (nSmartTime > latestNow) + latestNow = nSmartTime; + break; + } + } + } + + unsigned int& blocktime = mapBlockIndex[wtxIn.hashBlock]->nTime; + wtx.nTimeSmart = std::max(latestEntry, std::min(blocktime, latestNow)); + } + else + LogPrintf("AddToWallet() : found %s in block %s not in index\n", + wtxIn.GetHash().ToString(), + wtxIn.hashBlock.ToString()); + } + } + + bool fUpdated = false; + if (!fInsertedNew) + { + // Merge + if (wtxIn.hashBlock != 0 && wtxIn.hashBlock != wtx.hashBlock) + { + wtx.hashBlock = wtxIn.hashBlock; + fUpdated = true; + } + if (wtxIn.nIndex != -1 && (wtxIn.vMerkleBranch != wtx.vMerkleBranch || wtxIn.nIndex != wtx.nIndex)) + { + wtx.vMerkleBranch = wtxIn.vMerkleBranch; + wtx.nIndex = wtxIn.nIndex; + fUpdated = true; + } + if (wtxIn.fFromMe && wtxIn.fFromMe != wtx.fFromMe) + { + wtx.fFromMe = wtxIn.fFromMe; + fUpdated = true; + } + fUpdated |= wtx.UpdateSpent(wtxIn.vfSpent); + } + + //// debug print + LogPrintf("AddToWallet %s %s%s\n", wtxIn.GetHash().ToString(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : "")); + + // Write to disk + if (fInsertedNew || fUpdated) + if (!wtx.WriteToDisk()) + return false; + + if (!fHaveGUI) { + // If default receiving address gets used, replace it with a new one + if (vchDefaultKey.IsValid()) { + CScript scriptDefaultKey; + scriptDefaultKey.SetDestination(vchDefaultKey.GetID()); + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + { + if (txout.scriptPubKey == scriptDefaultKey) + { + CPubKey newDefaultKey; + if (GetKeyFromPool(newDefaultKey)) + { + SetDefaultKey(newDefaultKey); + SetAddressBookName(vchDefaultKey.GetID(), ""); + } + } + } + } + } + // since AddToWallet is called directly for self-originating transactions, check for consumption of own coins + WalletUpdateSpent(wtx, (wtxIn.hashBlock != 0)); + + // Notify UI of new or updated transaction + NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED); + + // notify an external script when a wallet transaction comes in or is updated + std::string strCmd = GetArg("-walletnotify", ""); + + if ( !strCmd.empty()) + { + boost::replace_all(strCmd, "%s", wtxIn.GetHash().GetHex()); + boost::thread t(runCommand, strCmd); // thread runs free + } + + } + return true; +} + +// Add a transaction to the wallet, or update it. +// pblock is optional, but should be provided if the transaction is known to be in a block. +// If fUpdate is true, existing transactions will be updated. +bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) +{ + uint256 hash = tx.GetHash(); + { + LOCK(cs_wallet); + bool fExisted = mapWallet.count(hash); + if (fExisted && !fUpdate) return false; + + mapValue_t mapNarr; + FindStealthTransactions(tx, mapNarr); + + if (fExisted || IsMine(tx) || IsFromMe(tx)) + { + CWalletTx wtx(this,tx); + + if (!mapNarr.empty()) + wtx.mapValue.insert(mapNarr.begin(), mapNarr.end()); + + // Get merkle branch if transaction was found in a block + if (pblock) + wtx.SetMerkleBranch(pblock); + return AddToWallet(wtx); + } + else + WalletUpdateSpent(tx); + } + return false; +} + +void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock, bool fConnect) { + if (!fConnect) + { + // wallets need to refund inputs when disconnecting coinstake + if (tx.IsCoinStake()) + { + if (IsFromMe(tx)) + DisableTransaction(tx); + } + return; + } + + AddToWalletIfInvolvingMe(tx, pblock, true); +} + +void CWallet::EraseFromWallet(const uint256 &hash) +{ + if (!fFileBacked) + return; + { + LOCK(cs_wallet); + if (mapWallet.erase(hash)) + CWalletDB(strWalletFile).EraseTx(hash); + } + return; +} + + +bool CWallet::IsMine(const CTxIn &txin) const +{ + { + LOCK(cs_wallet); + map::const_iterator mi = mapWallet.find(txin.prevout.hash); + if (mi != mapWallet.end()) + { + const CWalletTx& prev = (*mi).second; + if (txin.prevout.n < prev.vout.size()) + if (IsMine(prev.vout[txin.prevout.n])) + return true; + } + } + return false; +} + +int64_t CWallet::GetDebit(const CTxIn &txin) const +{ + { + LOCK(cs_wallet); + map::const_iterator mi = mapWallet.find(txin.prevout.hash); + if (mi != mapWallet.end()) + { + const CWalletTx& prev = (*mi).second; + if (txin.prevout.n < prev.vout.size()) + if (IsMine(prev.vout[txin.prevout.n])) + return prev.vout[txin.prevout.n].nValue; + } + } + return 0; +} + + +bool CWallet::IsDenominated(const CTxIn &txin) const +{ + { + LOCK(cs_wallet); + map::const_iterator mi = mapWallet.find(txin.prevout.hash); + if (mi != mapWallet.end()) + { + const CWalletTx& prev = (*mi).second; + if (txin.prevout.n < prev.vout.size()) return IsDenominatedAmount(prev.vout[txin.prevout.n].nValue); + } + } + return false; +} + +bool CWallet::IsDenominatedAmount(int64_t nInputAmount) const +{ + BOOST_FOREACH(int64_t d, darkSendDenominations) + if(nInputAmount == d) + return true; + return false; +} + + +bool CWallet::IsChange(const CTxOut& txout) const +{ + CTxDestination address; + + // TODO: fix handling of 'change' outputs. The assumption is that any + // payment to a TX_PUBKEYHASH that is mine but isn't in the address book + // is change. That assumption is likely to break when we implement multisignature + // wallets that return change back into a multi-signature-protected address; + // a better way of identifying which outputs are 'the send' and which are + // 'the change' will need to be implemented (maybe extend CWalletTx to remember + // which output, if any, was change). + if (ExtractDestination(txout.scriptPubKey, address) && ::IsMine(*this, address)) + { + LOCK(cs_wallet); + if (!mapAddressBook.count(address)) + return true; + } + return false; +} + +int64_t CWalletTx::GetTxTime() const +{ + int64_t n = nTimeSmart; + return n ? n : nTimeReceived; +} + +int CWalletTx::GetRequestCount() const +{ + // Returns -1 if it wasn't being tracked + int nRequests = -1; + { + LOCK(pwallet->cs_wallet); + if (IsCoinBase() || IsCoinStake()) + { + // Generated block + if (hashBlock != 0) + { + map::const_iterator mi = pwallet->mapRequestCount.find(hashBlock); + if (mi != pwallet->mapRequestCount.end()) + nRequests = (*mi).second; + } + } + else + { + // Did anyone request this transaction? + map::const_iterator mi = pwallet->mapRequestCount.find(GetHash()); + if (mi != pwallet->mapRequestCount.end()) + { + nRequests = (*mi).second; + + // How about the block it's in? + if (nRequests == 0 && hashBlock != 0) + { + map::const_iterator mi = pwallet->mapRequestCount.find(hashBlock); + if (mi != pwallet->mapRequestCount.end()) + nRequests = (*mi).second; + else + nRequests = 1; // If it's in someone else's block it must have got out + } + } + } + } + return nRequests; +} + +void CWalletTx::GetAmounts(list >& listReceived, + list >& listSent, int64_t& nFee, string& strSentAccount) const +{ + LOCK(pwallet->cs_wallet); + nFee = 0; + listReceived.clear(); + listSent.clear(); + strSentAccount = strFromAccount; + + // Compute fee: + int64_t nDebit = GetDebit(); + if (nDebit > 0) // debit>0 means we signed/sent this transaction + { + int64_t nValueOut = GetValueOut(); + nFee = nDebit - nValueOut; + } + + // Sent/received. + BOOST_FOREACH(const CTxOut& txout, vout) + { + // Skip special stake out + if (txout.scriptPubKey.empty()) + continue; + + bool fIsMine; + // Only need to handle txouts if AT LEAST one of these is true: + // 1) they debit from us (sent) + // 2) the output is to us (received) + if (nDebit > 0) + { + // Don't report 'change' txouts + // SONONOTE: CoinControl possible fix related... with HD wallet we need to report change? + //if (pwallet->IsChange(txout)) + // continue; + fIsMine = pwallet->IsMine(txout); + } + else if (!(fIsMine = pwallet->IsMine(txout))) + continue; + + // In either case, we need to get the destination address + CTxDestination address; + if (!ExtractDestination(txout.scriptPubKey, address)) + { + LogPrintf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n", + this->GetHash().ToString()); + address = CNoDestination(); + } + + // If we are debited by the transaction, add the output as a "sent" entry + if (nDebit > 0) + listSent.push_back(make_pair(address, txout.nValue)); + + // If we are receiving the output, add it as a "received" entry + if (fIsMine) + listReceived.push_back(make_pair(address, txout.nValue)); + } + +} + +void CWalletTx::GetAccountAmounts(const string& strAccount, int64_t& nReceived, + int64_t& nSent, int64_t& nFee) const +{ + LOCK(pwallet->cs_wallet); + nReceived = nSent = nFee = 0; + + int64_t allFee; + string strSentAccount; + list > listReceived; + list > listSent; + GetAmounts(listReceived, listSent, allFee, strSentAccount); + + if (strAccount == strSentAccount) + { + BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& s, listSent) + nSent += s.second; + nFee = allFee; + } + { + + BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listReceived) + { + if (pwallet->mapAddressBook.count(r.first)) + { + map::const_iterator mi = pwallet->mapAddressBook.find(r.first); + if (mi != pwallet->mapAddressBook.end() && (*mi).second == strAccount) + nReceived += r.second; + } + else if (strAccount.empty()) + { + nReceived += r.second; + } + } + } +} + +void CWalletTx::AddSupportingTransactions(CTxDB& txdb) +{ + vtxPrev.clear(); + + const int COPY_DEPTH = 3; + if (SetMerkleBranch() < COPY_DEPTH) + { + vector vWorkQueue; + BOOST_FOREACH(const CTxIn& txin, vin) + vWorkQueue.push_back(txin.prevout.hash); + + // This critsect is OK because txdb is already open + { + LOCK(pwallet->cs_wallet); + map mapWalletPrev; + set setAlreadyDone; + for (unsigned int i = 0; i < vWorkQueue.size(); i++) + { + uint256 hash = vWorkQueue[i]; + if (setAlreadyDone.count(hash)) + continue; + setAlreadyDone.insert(hash); + + CMerkleTx tx; + map::const_iterator mi = pwallet->mapWallet.find(hash); + if (mi != pwallet->mapWallet.end()) + { + tx = (*mi).second; + BOOST_FOREACH(const CMerkleTx& txWalletPrev, (*mi).second.vtxPrev) + mapWalletPrev[txWalletPrev.GetHash()] = &txWalletPrev; + } + else if (mapWalletPrev.count(hash)) + { + tx = *mapWalletPrev[hash]; + } + else if (txdb.ReadDiskTx(hash, tx)) + { + ; + } + else + { + LogPrintf("ERROR: AddSupportingTransactions() : unsupported transaction\n"); + continue; + } + + int nDepth = tx.SetMerkleBranch(); + vtxPrev.push_back(tx); + + if (nDepth < COPY_DEPTH) + { + BOOST_FOREACH(const CTxIn& txin, tx.vin) + vWorkQueue.push_back(txin.prevout.hash); + } + } + } + } + + reverse(vtxPrev.begin(), vtxPrev.end()); +} + +bool CWalletTx::WriteToDisk() +{ + return CWalletDB(pwallet->strWalletFile).WriteTx(GetHash(), *this); +} + +// Scan the block chain (starting in pindexStart) for transactions +// from or to us. If fUpdate is true, found transactions that already +// exist in the wallet will be updated. +int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) +{ + int ret = 0; + + CBlockIndex* pindex = pindexStart; + { + LOCK2(cs_main, cs_wallet); + while (pindex) + { + // no need to read and scan block, if block was created before + // our wallet birthday (as adjusted for block time variability) + if (nTimeFirstKey && (pindex->nTime < (nTimeFirstKey - 7200))) { + pindex = pindex->pnext; + continue; + } + + CBlock block; + block.ReadFromDisk(pindex, true); + BOOST_FOREACH(CTransaction& tx, block.vtx) + { + if (AddToWalletIfInvolvingMe(tx, &block, fUpdate)) + ret++; + } + pindex = pindex->pnext; + } + } + return ret; +} + +void CWallet::ReacceptWalletTransactions() +{ + CTxDB txdb("r"); + bool fRepeat = true; + while (fRepeat) + { + LOCK2(cs_main, cs_wallet); + fRepeat = false; + vector vMissingTx; + BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) + { + CWalletTx& wtx = item.second; + if ((wtx.IsCoinBase() && wtx.IsSpent(0)) || (wtx.IsCoinStake() && wtx.IsSpent(1))) + continue; + + CTxIndex txindex; + bool fUpdated = false; + if (txdb.ReadTxIndex(wtx.GetHash(), txindex)) + { + // Update fSpent if a tx got spent somewhere else by a copy of wallet.dat + if (txindex.vSpent.size() != wtx.vout.size()) + { + LogPrintf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %u != wtx.vout.size() %u\n", txindex.vSpent.size(), wtx.vout.size()); + continue; + } + for (unsigned int i = 0; i < txindex.vSpent.size(); i++) + { + if (wtx.IsSpent(i)) + continue; + if (!txindex.vSpent[i].IsNull() && IsMine(wtx.vout[i])) + { + wtx.MarkSpent(i); + fUpdated = true; + vMissingTx.push_back(txindex.vSpent[i]); + } + } + if (fUpdated) + { + LogPrintf("ReacceptWalletTransactions found spent coin %s BC %s\n", FormatMoney(wtx.GetCredit()), wtx.GetHash().ToString()); + wtx.MarkDirty(); + wtx.WriteToDisk(); + } + } + else + { + // Re-accept any txes of ours that aren't already in a block + if (!(wtx.IsCoinBase() || wtx.IsCoinStake())) + wtx.AcceptWalletTransaction(txdb); + } + } + if (!vMissingTx.empty()) + { + // TODO: optimize this to scan just part of the block chain? + if (ScanForWalletTransactions(pindexGenesisBlock)) + fRepeat = true; // Found missing transactions: re-do re-accept. + } + } +} + +void CWalletTx::RelayWalletTransaction(CTxDB& txdb) +{ + BOOST_FOREACH(const CMerkleTx& tx, vtxPrev) + { + if (!(tx.IsCoinBase() || tx.IsCoinStake())) + { + uint256 hash = tx.GetHash(); + if (!txdb.ContainsTx(hash)) + RelayTransaction((CTransaction)tx, hash); + } + } + if (!(IsCoinBase() || IsCoinStake())) + { + uint256 hash = GetHash(); + if (!txdb.ContainsTx(hash)) + { + LogPrintf("Relaying wtx %s\n", hash.ToString()); + RelayTransaction((CTransaction)*this, hash); + } + } +} + +void CWalletTx::RelayWalletTransaction() +{ + CTxDB txdb("r"); + RelayWalletTransaction(txdb); +} + +void CWallet::ResendWalletTransactions(bool fForce) +{ + if (!fForce) + { + // Do this infrequently and randomly to avoid giving away + // that these are our transactions. + static int64_t nNextTime; + if (GetTime() < nNextTime) + return; + bool fFirst = (nNextTime == 0); + nNextTime = GetTime() + GetRand(30 * 60); + if (fFirst) + return; + + // Only do it if there's been a new block since last time + static int64_t nLastTime; + if (nTimeBestReceived < nLastTime) + return; + nLastTime = GetTime(); + } + + // Rebroadcast any of our txes that aren't in a block yet + LogPrintf("ResendWalletTransactions()\n"); + CTxDB txdb("r"); + { + LOCK(cs_wallet); + // Sort them in chronological order + multimap mapSorted; + BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) + { + CWalletTx& wtx = item.second; + // Don't rebroadcast until it's had plenty of time that + // it should have gotten in already by now. + if (fForce || nTimeBestReceived - (int64_t)wtx.nTimeReceived > 5 * 60) + mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx)); + } + BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted) + { + CWalletTx& wtx = *item.second; + if (wtx.CheckTransaction()) + wtx.RelayWalletTransaction(txdb); + else + LogPrintf("ResendWalletTransactions() : CheckTransaction failed for transaction %s\n", wtx.GetHash().ToString()); + } + } +} + + + + + + +////////////////////////////////////////////////////////////////////////////// +// +// Actions +// + + +int64_t CWallet::GetBalance() const +{ + int64_t nTotal = 0; + { + LOCK2(cs_main, cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (pcoin->IsTrusted()) + nTotal += pcoin->GetAvailableCredit(); + } + } + + return nTotal; +} + +int64_t CWallet::GetBalanceNoLocks() const +{ + int64_t nTotal = 0; + { + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (pcoin->IsTrusted()) + nTotal += pcoin->GetAvailableCredit(); + } + } + + return nTotal; +} + +CAmount CWallet::GetAnonymizedBalance() const +{ + int64_t nTotal = 0; + { + LOCK(cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + + if (pcoin->IsTrusted()) + { + int nDepth = pcoin->GetDepthInMainChain(); + + for (unsigned int i = 0; i < pcoin->vout.size(); i++) { + //isminetype mine = IsMine(pcoin->vout[i]); + bool mine = IsMine(pcoin->vout[i]); + //COutput out = COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO); + COutput out = COutput(pcoin, i, nDepth, mine); + CTxIn vin = CTxIn(out.tx->GetHash(), out.i); + + //if(IsSpent(out.tx->GetHash(), i) || !IsMine(pcoin->vout[i]) || !IsDenominated(vin)) continue; + if(pcoin->IsSpent(i) || !IsMine(pcoin->vout[i]) || !IsDenominated(vin)) continue; + + int rounds = GetInputluxsendRounds(vin); + if(rounds >= nDarksendRounds){ + nTotal += pcoin->vout[i].nValue; + } + } + } + } + } + + return nTotal; +} + +double CWallet::GetAverageAnonymizedRounds() const +{ + double fTotal = 0; + double fCount = 0; + + { + LOCK(cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + + if (pcoin->IsTrusted()) + { + int nDepth = pcoin->GetDepthInMainChain(); + + for (unsigned int i = 0; i < pcoin->vout.size(); i++) { + //isminetype mine = IsMine(pcoin->vout[i]); + bool mine = IsMine(pcoin->vout[i]); + //COutput out = COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO); + COutput out = COutput(pcoin, i, nDepth, mine); + CTxIn vin = CTxIn(out.tx->GetHash(), out.i); + + //if(IsSpent(out.tx->GetHash(), i) || !IsMine(pcoin->vout[i]) || !IsDenominated(vin)) continue; + if(pcoin->IsSpent(i) || !IsMine(pcoin->vout[i]) || !IsDenominated(vin)) continue; + + int rounds = GetInputluxsendRounds(vin); + fTotal += (float)rounds; + fCount += 1; + } + } + } + } + + if(fCount == 0) return 0; + + return fTotal/fCount; +} + +CAmount CWallet::GetNormalizedAnonymizedBalance() const +{ + int64_t nTotal = 0; + + { + LOCK(cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + + if (pcoin->IsTrusted()) + { + int nDepth = pcoin->GetDepthInMainChain(); + + for (unsigned int i = 0; i < pcoin->vout.size(); i++) { + //isminetype mine = IsMine(pcoin->vout[i]); + bool mine = IsMine(pcoin->vout[i]); + //COutput out = COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO); + COutput out = COutput(pcoin, i, nDepth, mine); + CTxIn vin = CTxIn(out.tx->GetHash(), out.i); + + //if(IsSpent(out.tx->GetHash(), i) || !IsMine(pcoin->vout[i]) || !IsDenominated(vin)) continue; + if(pcoin->IsSpent(i) || !IsMine(pcoin->vout[i]) || !IsDenominated(vin)) continue; + + int rounds = GetInputluxsendRounds(vin); + nTotal += pcoin->vout[i].nValue * rounds / nDarksendRounds; + } + } + } + } + + return nTotal; +} + +CAmount CWallet::GetDenominatedBalance(bool onlyDenom, bool onlyUnconfirmed) const +{ + int64_t nTotal = 0; + { + LOCK(cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + + int nDepth = pcoin->GetDepthInMainChain(); + + // skip conflicted + if(nDepth < 0) continue; + + bool unconfirmed = (!IsFinalTx(*pcoin) || (!pcoin->IsTrusted() && nDepth == 0)); + if(onlyUnconfirmed != unconfirmed) continue; + + for (unsigned int i = 0; i < pcoin->vout.size(); i++) + { + //isminetype mine = IsMine(pcoin->vout[i]); + //bool mine = IsMine(pcoin->vout[i]); + //COutput out = COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO); + //COutput out = COutput(pcoin, i, nDepth, mine); + + //if(IsSpent(out.tx->GetHash(), i)) continue; + if(pcoin->IsSpent(i)) continue; + if(!IsMine(pcoin->vout[i])) continue; + if(onlyDenom != IsDenominatedAmount(pcoin->vout[i].nValue)) continue; + + nTotal += pcoin->vout[i].nValue; + } + } + } + + + + return nTotal; +} + + +int64_t CWallet::GetUnconfirmedBalance() const +{ + int64_t nTotal = 0; + { + LOCK2(cs_main, cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (!IsFinalTx(*pcoin) || (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0)) + nTotal += pcoin->GetAvailableCredit(); + } + } + return nTotal; +} + +int64_t CWallet::GetImmatureBalance() const +{ + int64_t nTotal = 0; + { + LOCK2(cs_main, cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx& pcoin = (*it).second; + if (pcoin.IsCoinBase() && pcoin.GetBlocksToMaturity() > 0 && pcoin.IsInMainChain()) + nTotal += GetCredit(pcoin); + } + } + return nTotal; +} + + +// populate vCoins with vector of spendable COutputs +void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, AvailableCoinsType coin_type, bool useIX) const +{ + vCoins.clear(); + + { + LOCK2(cs_main, cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + + if (!IsFinalTx(*pcoin)) + continue; + + if (fOnlyConfirmed && !pcoin->IsTrusted()) + continue; + + if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) + continue; + + if(pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0) + continue; + + int nDepth = pcoin->GetDepthInMainChain(); + if (nDepth <= 0) // SONONOTE: coincontrol fix / ignore 0 confirm + continue; + + /* for (unsigned int i = 0; i < pcoin->vout.size(); i++) + if (!(pcoin->IsSpent(i)) && IsMine(pcoin->vout[i]) && pcoin->vout[i].nValue >= nMinimumInputValue && + (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) + vCoins.push_back(COutput(pcoin, i, nDepth));*/ + // do not use IX for inputs that have less then 6 blockchain confirmations + if (useIX && nDepth < 6) + continue; + + for (unsigned int i = 0; i < pcoin->vout.size(); i++) { + bool found = false; + if(coin_type == ONLY_DENOMINATED) { + //should make this a vector + + found = IsDenominatedAmount(pcoin->vout[i].nValue); + } else if(coin_type == ONLY_NONDENOMINATED || coin_type == ONLY_NONDENOMINATED_NOTMN) { + found = true; + if (IsCollateralAmount(pcoin->vout[i].nValue)) continue; // do not use collateral amounts + found = !IsDenominatedAmount(pcoin->vout[i].nValue); + if(found && coin_type == ONLY_NONDENOMINATED_NOTMN) found = (pcoin->vout[i].nValue != GetMNCollateral(pindexBest->nHeight)*COIN); // do not use MN funds + } else { + found = true; + } + if(!found) continue; + + //isminetype mine = IsMine(pcoin->vout[i]); + bool mine = IsMine(pcoin->vout[i]); + + //if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO && + // !IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0 && + // (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) + // vCoins.push_back(COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO)); + //if (!(IsSpent(wtxid, i)) && mine && + if (!(pcoin->IsSpent(i)) && mine && + !IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0 && + (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) + vCoins.push_back(COutput(pcoin, i, nDepth, mine)); + } + } + } +} + +void CWallet::AvailableCoinsMN(vector& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, AvailableCoinsType coin_type, bool useIX) const +{ + vCoins.clear(); + + { + LOCK2(cs_main, cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + + if (!IsFinalTx(*pcoin)) + continue; + + if (fOnlyConfirmed && !pcoin->IsTrusted()) + continue; + + if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) + continue; + + if(pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0) + continue; + + int nDepth = pcoin->GetDepthInMainChain(); + if (nDepth <= 0) // SONONOTE: coincontrol fix / ignore 0 confirm + continue; + + /* for (unsigned int i = 0; i < pcoin->vout.size(); i++) + if (!(pcoin->IsSpent(i)) && IsMine(pcoin->vout[i]) && pcoin->vout[i].nValue >= nMinimumInputValue && + (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) + vCoins.push_back(COutput(pcoin, i, nDepth));*/ + // do not use IX for inputs that have less then 6 blockchain confirmations + if (useIX && nDepth < 6) + continue; + + for (unsigned int i = 0; i < pcoin->vout.size(); i++) { + bool found = false; + if(coin_type == ONLY_DENOMINATED) { + //should make this a vector + + found = IsDenominatedAmount(pcoin->vout[i].nValue); + } else if(coin_type == ONLY_NONDENOMINATED || coin_type == ONLY_NONDENOMINATED_NOTMN) { + found = true; + if (IsCollateralAmount(pcoin->vout[i].nValue)) continue; // do not use collateral amounts + found = !IsDenominatedAmount(pcoin->vout[i].nValue); + if(found && coin_type == ONLY_NONDENOMINATED_NOTMN) found = (pcoin->vout[i].nValue != GetMNCollateral(pindexBest->nHeight)*COIN); // do not use MN funds + } else { + found = true; + } + if(!found) continue; + + //isminetype mine = IsMine(pcoin->vout[i]); + bool mine = IsMine(pcoin->vout[i]); + + //if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO && + // !IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0 && + // (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) + // vCoins.push_back(COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO)); + //if (!(IsSpent(wtxid, i)) && mine && + if (!(pcoin->IsSpent(i)) && + !IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0 && + (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) + vCoins.push_back(COutput(pcoin, i, nDepth, mine)); + } + } + } +} + +void CWallet::AvailableCoinsForStaking(vector& vCoins, unsigned int nSpendTime) const +{ + vCoins.clear(); + + { + LOCK2(cs_main, cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + + // Filtering by tx timestamp instead of block timestamp may give false positives but never false negatives + if (pcoin->nTime + nStakeMinAge > nSpendTime) + continue; + + if (pcoin->GetBlocksToMaturity() > 0) + continue; + + int nDepth = pcoin->GetDepthInMainChain(); + if (nDepth < 1) + continue; + + for (unsigned int i = 0; i < pcoin->vout.size(); i++) + if (!(pcoin->IsSpent(i)) && IsMine(pcoin->vout[i]) && pcoin->vout[i].nValue >= nMinimumInputValue) + vCoins.push_back(COutput(pcoin, i, nDepth, true)); + } + } +} + +static void ApproximateBestSubset(vector > >vValue, int64_t nTotalLower, int64_t nTargetValue, + vector& vfBest, int64_t& nBest, int iterations = 1000) +{ + vector vfIncluded; + + vfBest.assign(vValue.size(), true); + nBest = nTotalLower; + + seed_insecure_rand(); + + for (int nRep = 0; nRep < iterations && nBest != nTargetValue; nRep++) + { + vfIncluded.assign(vValue.size(), false); + int64_t nTotal = 0; + bool fReachedTarget = false; + for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++) + { + for (unsigned int i = 0; i < vValue.size(); i++) + { + //The solver here uses a randomized algorithm, + //the randomness serves no real security purpose but is just + //needed to prevent degenerate behavior and it is important + //that the rng fast. We do not use a constant random sequence, + //because there may be some privacy improvement by making + //the selection random. + if (nPass == 0 ? insecure_rand()&1 : !vfIncluded[i]) + { + nTotal += vValue[i].first; + vfIncluded[i] = true; + if (nTotal >= nTargetValue) + { + fReachedTarget = true; + if (nTotal < nBest) + { + nBest = nTotal; + vfBest = vfIncluded; + } + nTotal -= vValue[i].first; + vfIncluded[i] = false; + } + } + } + } + } +} + +// ppcoin: total coins staked (non-spendable until maturity) +int64_t CWallet::GetStake() const +{ + int64_t nTotal = 0; + LOCK2(cs_main, cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0) + nTotal += CWallet::GetCredit(*pcoin); + } + return nTotal; +} + +int64_t CWallet::GetNewMint() const +{ + int64_t nTotal = 0; + LOCK2(cs_main, cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0) + nTotal += CWallet::GetCredit(*pcoin); + } + return nTotal; +} + +struct LargerOrEqualThanThreshold +{ + int64_t threshold; + LargerOrEqualThanThreshold(int64_t threshold) : threshold(threshold) {} + bool operator()(pair,pair > const &v) const { return v.first.first >= threshold; } +}; + +bool CWallet::SelectCoinsMinConfByCoinAge(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, set >& setCoinsRet, int64_t& nValueRet) const +{ + setCoinsRet.clear(); + nValueRet = 0; + + vector > mCoins; + BOOST_FOREACH(const COutput& out, vCoins) + { + mCoins.push_back(std::make_pair(out, CoinWeightCost(out))); + } + + // List of values less than target + pair, pair > coinLowestLarger; + coinLowestLarger.first.second = std::numeric_limits::max(); + coinLowestLarger.second.first = NULL; + vector,pair > > vValue; + int64_t nTotalLower = 0; + boost::sort(mCoins, boost::bind(&std::pair::second, _1) < boost::bind(&std::pair::second, _2)); + + BOOST_FOREACH(const PAIRTYPE(COutput, uint64_t)& output, mCoins) + { + const CWalletTx *pcoin = output.first.tx; + + if (output.first.nDepth < (pcoin->IsFromMe() ? nConfMine : nConfTheirs)) + continue; + + int i = output.first.i; + + // Follow the timestamp rules + if (pcoin->nTime > nSpendTime) + continue; + + int64_t n = pcoin->vout[i].nValue; + + pair,pair > coin = make_pair(make_pair(n,output.second),make_pair(pcoin, i)); + + if (n < nTargetValue + CENT) + { + vValue.push_back(coin); + nTotalLower += n; + } + else if (output.second < (uint64_t)coinLowestLarger.first.second) + { + coinLowestLarger = coin; + } + } + + if (nTotalLower < nTargetValue) + { + if (coinLowestLarger.second.first == NULL) + return false; + setCoinsRet.insert(coinLowestLarger.second); + nValueRet += coinLowestLarger.first.first; + return true; + } + + // Calculate dynamic programming matrix + int64_t nTotalValue = vValue[0].first.first; + int64_t nGCD = vValue[0].first.first; + for (unsigned int i = 1; i < vValue.size(); ++i) + { + nGCD = gcd(vValue[i].first.first, nGCD); + nTotalValue += vValue[i].first.first; + } + nGCD = gcd(nTargetValue, nGCD); + int64_t denom = nGCD; + const int64_t k = 25; + const int64_t approx = int64_t(vValue.size() * (nTotalValue - nTargetValue)) / k; + if (approx > nGCD) + { + denom = approx; // apply approximation + } + if (fDebug) cerr << "nGCD " << nGCD << " denom " << denom << " k " << k << endl; + + if (nTotalValue == nTargetValue) + { + for (unsigned int i = 0; i < vValue.size(); ++i) + { + setCoinsRet.insert(vValue[i].second); + } + nValueRet = nTotalValue; + return true; + } + + size_t nBeginBundles = vValue.size(); + size_t nTotalCoinValues = vValue.size(); + size_t nBeginCoinValues = 0; + int64_t costsum = 0; + vector,pair > >::iterator> vZeroValueBundles; + if (denom != nGCD) + { + // All coin outputs that with zero value will always be added by the dynamic programming routine + // So we collect them into bundles of value denom + vector,pair > >::iterator itZeroValue = std::stable_partition(vValue.begin(), vValue.end(), LargerOrEqualThanThreshold(denom)); + vZeroValueBundles.push_back(itZeroValue); + pair pBundle = make_pair(0, 0); + nBeginBundles = itZeroValue - vValue.begin(); + nTotalCoinValues = nBeginBundles; + while (itZeroValue != vValue.end()) + { + pBundle.first += itZeroValue->first.first; + pBundle.second += itZeroValue->first.second; + itZeroValue++; + if (pBundle.first >= denom) + { + vZeroValueBundles.push_back(itZeroValue); + vValue[nTotalCoinValues].first = pBundle; + pBundle = make_pair(0, 0); + nTotalCoinValues++; + } + } + // We need to recalculate the total coin value due to truncation of integer division + nTotalValue = 0; + for (unsigned int i = 0; i < nTotalCoinValues; ++i) + { + nTotalValue += vValue[i].first.first / denom; + } + // Check if dynamic programming is still applicable with the approximation + if (nTargetValue/denom >= nTotalValue) + { + // We lose too much coin value through the approximation, i.e. the residual of the previous recalculation is too large + // Since the partitioning of the previously sorted list is stable, we can just pick the first coin outputs in the list until we have a valid target value + for (; nBeginCoinValues < nTotalCoinValues && (nTargetValue - nValueRet)/denom >= nTotalValue; ++nBeginCoinValues) + { + if (nBeginCoinValues >= nBeginBundles) + { + if (fDebug) cerr << "prepick bundle item " << FormatMoney(vValue[nBeginCoinValues].first.first) << " normalized " << vValue[nBeginCoinValues].first.first / denom << " cost " << vValue[nBeginCoinValues].first.second << endl; + const size_t nBundle = nBeginCoinValues - nBeginBundles; + for (vector,pair > >::iterator it = vZeroValueBundles[nBundle]; it != vZeroValueBundles[nBundle + 1]; ++it) + { + setCoinsRet.insert(it->second); + } + } + else + { + if (fDebug) cerr << "prepicking " << FormatMoney(vValue[nBeginCoinValues].first.first) << " normalized " << vValue[nBeginCoinValues].first.first / denom << " cost " << vValue[nBeginCoinValues].first.second << endl; + setCoinsRet.insert(vValue[nBeginCoinValues].second); + } + nTotalValue -= vValue[nBeginCoinValues].first.first / denom; + nValueRet += vValue[nBeginCoinValues].first.first; + costsum += vValue[nBeginCoinValues].first.second; + } + if (nValueRet >= nTargetValue) + { + if (fDebug) cerr << "Done without dynprog: " << "requested " << FormatMoney(nTargetValue) << "\tnormalized " << nTargetValue/denom + (nTargetValue % denom != 0 ? 1 : 0) << "\tgot " << FormatMoney(nValueRet) << "\tcost " << costsum << endl; + return true; + } + } + } + else + { + nTotalValue /= denom; + } + + uint64_t nAppend = 1; + if ((nTargetValue - nValueRet) % denom != 0) + { + // We need to decrease the capacity because of integer truncation + nAppend--; + } + + // The capacity (number of columns) corresponds to the amount of coin value we are allowed to discard + boost::numeric::ublas::matrix M((nTotalCoinValues - nBeginCoinValues) + 1, (nTotalValue - (nTargetValue - nValueRet)/denom) + nAppend, std::numeric_limits::max()); + boost::numeric::ublas::matrix B((nTotalCoinValues - nBeginCoinValues) + 1, (nTotalValue - (nTargetValue - nValueRet)/denom) + nAppend); + for (unsigned int j = 0; j < M.size2(); ++j) + { + M(0,j) = 0; + } + for (unsigned int i = 1; i < M.size1(); ++i) + { + uint64_t nWeight = vValue[nBeginCoinValues + i - 1].first.first / denom; + uint64_t nValue = vValue[nBeginCoinValues + i - 1].first.second; + //cerr << "Weight " << nWeight << " Value " << nValue << endl; + for (unsigned int j = 0; j < M.size2(); ++j) + { + B(i, j) = j; + if (nWeight <= j) + { + uint64_t nStep = M(i - 1, j - nWeight) + nValue; + if (M(i - 1, j) >= nStep) + { + M(i, j) = M(i - 1, j); + } + else + { + M(i, j) = nStep; + B(i, j) = j - nWeight; + } + } + else + { + M(i, j) = M(i - 1, j); + } + } + } + // Trace back optimal solution + int64_t nPrev = M.size2() - 1; + for (unsigned int i = M.size1() - 1; i > 0; --i) + { + //cerr << i - 1 << " " << vValue[i - 1].second.second << " " << vValue[i - 1].first.first << " " << vValue[i - 1].first.second << " " << nTargetValue << " " << nPrev << " " << (nPrev == B(i, nPrev) ? "XXXXXXXXXXXXXXX" : "") << endl; + if (nPrev == B(i, nPrev)) + { + const size_t nValue = nBeginCoinValues + i - 1; + // Check if this is a bundle + if (nValue >= nBeginBundles) + { + if (fDebug) cerr << "pick bundle item " << FormatMoney(vValue[nValue].first.first) << " normalized " << vValue[nValue].first.first / denom << " cost " << vValue[nValue].first.second << endl; + const size_t nBundle = nValue - nBeginBundles; + for (vector,pair > >::iterator it = vZeroValueBundles[nBundle]; it != vZeroValueBundles[nBundle + 1]; ++it) + { + setCoinsRet.insert(it->second); + } + } + else + { + if (fDebug) cerr << "pick " << nValue << " value " << FormatMoney(vValue[nValue].first.first) << " normalized " << vValue[nValue].first.first / denom << " cost " << vValue[nValue].first.second << endl; + setCoinsRet.insert(vValue[nValue].second); + } + nValueRet += vValue[nValue].first.first; + costsum += vValue[nValue].first.second; + } + nPrev = B(i, nPrev); + } + if (nValueRet < nTargetValue && !vZeroValueBundles.empty()) + { + // If we get here it means that there are either not sufficient funds to pay the transaction or that there are small coin outputs left that couldn't be bundled + // We try to fulfill the request by adding these small coin outputs + for (vector,pair > >::iterator it = vZeroValueBundles.back(); it != vValue.end() && nValueRet < nTargetValue; ++it) + { + setCoinsRet.insert(it->second); + nValueRet += it->first.first; + } + } + if (fDebug) cerr << "requested " << FormatMoney(nTargetValue) << "\tnormalized " << nTargetValue/denom + (nTargetValue % denom != 0 ? 1 : 0) << "\tgot " << FormatMoney(nValueRet) << "\tcost " << costsum << endl; + if (fDebug) cerr << "M " << M.size1() << "x" << M.size2() << "; vValue.size() = " << vValue.size() << endl; + return true; +} + +// TODO: find appropriate place for this sort function +// move denoms down +bool less_then_denom (const COutput& out1, const COutput& out2) +{ + const CWalletTx *pcoin1 = out1.tx; + const CWalletTx *pcoin2 = out2.tx; + + bool found1 = false; + bool found2 = false; + BOOST_FOREACH(int64_t d, darkSendDenominations) // loop through predefined denoms + { + if(pcoin1->vout[out1.i].nValue == d) found1 = true; + if(pcoin2->vout[out2.i].nValue == d) found2 = true; + } + return (!found1 && found2); +} + +bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, vector vCoins, set >& setCoinsRet, int64_t& nValueRet) const +{ + setCoinsRet.clear(); + nValueRet = 0; + + // List of values less than target + pair > coinLowestLarger; + coinLowestLarger.first = std::numeric_limits::max(); + coinLowestLarger.second.first = NULL; + vector > > vValue; + int64_t nTotalLower = 0; + + random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); + + // move denoms down on the list + sort(vCoins.begin(), vCoins.end(), less_then_denom); + + // try to find nondenom first to prevent unneeded spending of mixed coins + for (unsigned int tryDenom = 0; tryDenom < 2; tryDenom++) + { + if (fDebug) LogPrint("selectcoins", "tryDenom: %d\n", tryDenom); + vValue.clear(); + nTotalLower = 0; + + BOOST_FOREACH(COutput output, vCoins) + { + const CWalletTx *pcoin = output.tx; + + if (output.nDepth < (pcoin->IsFromMe() ? nConfMine : nConfTheirs)) + continue; + + int i = output.i; + + // Follow the timestamp rules + if (pcoin->nTime > nSpendTime) + continue; + + int64_t n = pcoin->vout[i].nValue; + + if (tryDenom == 0 && IsDenominatedAmount(n)) continue; // we don't want denom values on first run + + pair > coin = make_pair(n,make_pair(pcoin, i)); + + if (n == nTargetValue) + { + setCoinsRet.insert(coin.second); + nValueRet += coin.first; + return true; + } + else if (n < nTargetValue + CENT) + { + vValue.push_back(coin); + nTotalLower += n; + } + else if (n < coinLowestLarger.first) + { + coinLowestLarger = coin; + } + } + + if (nTotalLower == nTargetValue) + { + for (unsigned int i = 0; i < vValue.size(); ++i) + { + setCoinsRet.insert(vValue[i].second); + nValueRet += vValue[i].first; + } + return true; + } + + if (nTotalLower < nTargetValue) + { + if (coinLowestLarger.second.first == NULL) + return false; + setCoinsRet.insert(coinLowestLarger.second); + nValueRet += coinLowestLarger.first; + return true; + } + + // Solve subset sum by stochastic approximation + sort(vValue.rbegin(), vValue.rend(), CompareValueOnly()); + vector vfBest; + int64_t nBest; + + ApproximateBestSubset(vValue, nTotalLower, nTargetValue, vfBest, nBest, 1000); + if (nBest != nTargetValue && nTotalLower >= nTargetValue + CENT) + ApproximateBestSubset(vValue, nTotalLower, nTargetValue + CENT, vfBest, nBest, 1000); + + // If we have a bigger coin and (either the stochastic approximation didn't find a good solution, + // or the next bigger coin is closer), return the bigger coin + if (coinLowestLarger.second.first && + ((nBest != nTargetValue && nBest < nTargetValue + CENT) || coinLowestLarger.first <= nBest)) + { + setCoinsRet.insert(coinLowestLarger.second); + nValueRet += coinLowestLarger.first; + } + else { + for (unsigned int i = 0; i < vValue.size(); i++) + if (vfBest[i]) + { + setCoinsRet.insert(vValue[i].second); + nValueRet += vValue[i].first; + } + + LogPrint("selectcoins", "SelectCoins() best subset: "); + for (unsigned int i = 0; i < vValue.size(); i++) + if (vfBest[i]) + LogPrint("selectcoins", "%s ", FormatMoney(vValue[i].first)); + LogPrint("selectcoins", "total %s\n", FormatMoney(nBest)); + } + + return true; + } + return false; +} + +bool CWallet::SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, set >& setCoinsRet, int64_t& nValueRet, const CCoinControl* coinControl, AvailableCoinsType coin_type, bool useIX) const +{ + vector vCoins; + AvailableCoins(vCoins, true, coinControl); + + //if we're doing only denominated, we need to round up to the nearest .1SONO + if(coin_type == ONLY_DENOMINATED){ + // Make outputs by looping through denominations, from large to small + BOOST_FOREACH(int64_t v, darkSendDenominations) + { + int added = 0; + BOOST_FOREACH(const COutput& out, vCoins) + { + if(out.tx->vout[out.i].nValue == v //make sure it's the denom we're looking for + && nValueRet + out.tx->vout[out.i].nValue < nTargetValue + (0.1*COIN)+100 //round the amount up to .1SONO over + && added <= 100){ //don't add more than 100 of one denom type + CTxIn vin = CTxIn(out.tx->GetHash(),out.i); + int rounds = GetInputluxsendRounds(vin); + // make sure it's actually anonymized + if(rounds < nDarksendRounds) continue; + nValueRet += out.tx->vout[out.i].nValue; + setCoinsRet.insert(make_pair(out.tx, out.i)); + added++; + } + } + } + return (nValueRet >= nTargetValue); + } + + // coin control -> return all selected outputs (we want all selected to go into the transaction for sure) + if (coinControl && coinControl->HasSelected()) + { + BOOST_FOREACH(const COutput& out, vCoins) + { + if(!out.fSpendable) + continue; + nValueRet += out.tx->vout[out.i].nValue; + setCoinsRet.insert(make_pair(out.tx, out.i)); + } + return (nValueRet >= nTargetValue); + } + + boost::function, std::set >&, int64_t&)> f = fMinimizeCoinAge ? &CWallet::SelectCoinsMinConfByCoinAge : &CWallet::SelectCoinsMinConf; + + return (f(this, nTargetValue, nSpendTime, 1, 10, vCoins, setCoinsRet, nValueRet) || + f(this, nTargetValue, nSpendTime, 1, 1, vCoins, setCoinsRet, nValueRet) || + f(this, nTargetValue, nSpendTime, 0, 1, vCoins, setCoinsRet, nValueRet)); +} + +// Select some coins without random shuffle or best subset approximation +bool CWallet::SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, set >& setCoinsRet, int64_t& nValueRet) const +{ + vector vCoins; + AvailableCoinsForStaking(vCoins, nSpendTime); + + setCoinsRet.clear(); + nValueRet = 0; + + BOOST_FOREACH(COutput output, vCoins) + { + const CWalletTx *pcoin = output.tx; + int i = output.i; + + // Stop if we've chosen enough inputs + if (nValueRet >= nTargetValue) + break; + + int64_t n = pcoin->vout[i].nValue; + + pair > coin = make_pair(n,make_pair(pcoin, i)); + + if (n >= nTargetValue) + { + // If input value is greater or equal to target then simply insert + // it into the current subset and exit + setCoinsRet.insert(coin.second); + nValueRet += coin.first; + break; + } + else if (n < nTargetValue + CENT) + { + setCoinsRet.insert(coin.second); + nValueRet += coin.first; + } + } + + return true; +} + +struct CompareByPriority +{ + bool operator()(const COutput& t1, + const COutput& t2) const + { + return t1.Priority() > t2.Priority(); + } +}; + +bool CWallet::SelectCoinsByDenominations(int nDenom, int64_t nValueMin, int64_t nValueMax, std::vector& setCoinsRet, vector& setCoinsRet2, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax) +{ + setCoinsRet.clear(); + nValueRet = 0; + + setCoinsRet2.clear(); + vector vCoins; + AvailableCoins(vCoins); + + //order the array so fees are first, then denominated money, then the rest. + std::random_shuffle(vCoins.rbegin(), vCoins.rend()); + + //keep track of each denomination that we have + bool fFound100000 = false; + bool fFound10000 = false; + bool fFound1000 = false; + bool fFound100 = false; + bool fFound10 = false; + bool fFound1 = false; + bool fFoundDot1 = false; + + //Check to see if any of the denomination are off, in that case mark them as fulfilled + + + + if(!(nDenom & (1 << 0))) fFound100000 = true; + if(!(nDenom & (1 << 1))) fFound10000 = true; + if(!(nDenom & (1 << 2))) fFound1000 = true; + if(!(nDenom & (1 << 3))) fFound100 = true; + if(!(nDenom & (1 << 4))) fFound10 = true; + if(!(nDenom & (1 << 5))) fFound1 = true; + if(!(nDenom & (1 << 6))) fFoundDot1 = true; + + BOOST_FOREACH(const COutput& out, vCoins) + { + //there's no reason to allow inputs less than 1 COIN into DS (other than denominations smaller than that amount) + if(out.tx->vout[out.i].nValue < 1*COIN && out.tx->vout[out.i].nValue != (.1*COIN)+100) continue; + if(fMasterNode && out.tx->vout[out.i].nValue == GetMNCollateral(pindexBest->nHeight)*COIN) continue; //masternode input + if(nValueRet + out.tx->vout[out.i].nValue <= nValueMax){ + bool fAccepted = false; + + // Function returns as follows: + // + // bit 0 - 100SONO+1 ( bit on if present ) + // bit 1 - 10SONO+1 + // bit 2 - 1SONO+1 + // bit 3 - .1SONO+1 + + CTxIn vin = CTxIn(out.tx->GetHash(),out.i); + + int rounds = GetInputluxsendRounds(vin); + if(rounds >= nDarksendRoundsMax) continue; + if(rounds < nDarksendRoundsMin) continue; + + if(fFound100000 && fFound10000 && fFound1000 && fFound100 && fFound10 && fFound1 && fFoundDot1){ //if fulfilled + //we can return this for submission + if(nValueRet >= nValueMin){ + //random reduce the max amount we'll submit for anonymity + nValueMax -= (rand() % (nValueMax/5)); + //on average use 50% of the inputs or less + int r = (rand() % (int)vCoins.size()); + if((int)setCoinsRet.size() > r) return true; + } + //Denomination criterion has been met, we can take any matching denominations + if((nDenom & (1 << 0)) && out.tx->vout[out.i].nValue == ((100000*COIN) +100000000)) {fAccepted = true;} + else if((nDenom & (1 << 1)) && out.tx->vout[out.i].nValue == ((10000*COIN) +10000000)) {fAccepted = true;} + else if((nDenom & (1 << 2)) && out.tx->vout[out.i].nValue == ((1000*COIN) +1000000)) {fAccepted = true;} + else if((nDenom & (1 << 3)) && out.tx->vout[out.i].nValue == ((100*COIN) +100000)) {fAccepted = true;} + else if((nDenom & (1 << 4)) && out.tx->vout[out.i].nValue == ((10*COIN) +10000)) {fAccepted = true;} + else if((nDenom & (1 << 5)) && out.tx->vout[out.i].nValue == ((1*COIN) +1000)) {fAccepted = true;} + else if((nDenom & (1 << 6)) && out.tx->vout[out.i].nValue == ((.1*COIN) +100)) {fAccepted = true;} + } else { + //Criterion has not been satisfied, we will only take 1 of each until it is. + if((nDenom & (1 << 0)) && out.tx->vout[out.i].nValue == ((100000*COIN) +100000000)) {fAccepted = true; fFound100000 = true;} + else if((nDenom & (1 << 1)) && out.tx->vout[out.i].nValue == ((10000*COIN) +10000000)) {fAccepted = true; fFound10000 = true;} + else if((nDenom & (1 << 1)) && out.tx->vout[out.i].nValue == ((1000*COIN) +1000000)) {fAccepted = true; fFound1000 = true;} + else if((nDenom & (1 << 1)) && out.tx->vout[out.i].nValue == ((100*COIN) +100000)) {fAccepted = true; fFound100 = true;} + else if((nDenom & (1 << 1)) && out.tx->vout[out.i].nValue == ((10*COIN) +10000)) {fAccepted = true; fFound10 = true;} + else if((nDenom & (1 << 2)) && out.tx->vout[out.i].nValue == ((1*COIN) +1000)) {fAccepted = true; fFound1 = true;} + else if((nDenom & (1 << 3)) && out.tx->vout[out.i].nValue == ((.1*COIN) +100)) {fAccepted = true; fFoundDot1 = true;} + } + if(!fAccepted) continue; + + vin.prevPubKey = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey + nValueRet += out.tx->vout[out.i].nValue; + setCoinsRet.push_back(vin); + setCoinsRet2.push_back(out); + } + } + + return (nValueRet >= nValueMin && fFound100000 && fFound10000 && fFound1000 && fFound100 && fFound10 && fFound1 && fFoundDot1); +} + +bool CWallet::SelectCoinsDark(int64_t nValueMin, int64_t nValueMax, std::vector& setCoinsRet, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax) const +{ + CCoinControl *coinControl=NULL; + + setCoinsRet.clear(); + nValueRet = 0; + + vector vCoins; + AvailableCoins(vCoins, true, coinControl, nDarksendRoundsMin < 0 ? ONLY_NONDENOMINATED_NOTMN : ONLY_DENOMINATED); + + set > setCoinsRet2; + + //order the array so fees are first, then denominated money, then the rest. + sort(vCoins.rbegin(), vCoins.rend(), CompareByPriority()); + + //the first thing we get is a fee input, then we'll use as many denominated as possible. then the rest + BOOST_FOREACH(const COutput& out, vCoins) + { + //there's no reason to allow inputs less than 1 COIN into DS (other than denominations smaller than that amount) + if(out.tx->vout[out.i].nValue < 1*COIN && out.tx->vout[out.i].nValue != (.1*COIN)+100) continue; + if(fMasterNode && out.tx->vout[out.i].nValue == GetMNCollateral(pindexBest->nHeight)*COIN) continue; //masternode input + + if(nValueRet + out.tx->vout[out.i].nValue <= nValueMax){ + CTxIn vin = CTxIn(out.tx->GetHash(),out.i); + + int rounds = GetInputluxsendRounds(vin); + if(rounds >= nDarksendRoundsMax) continue; + if(rounds < nDarksendRoundsMin) continue; + + vin.prevPubKey = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey + nValueRet += out.tx->vout[out.i].nValue; + setCoinsRet.push_back(vin); + setCoinsRet2.insert(make_pair(out.tx, out.i)); + } + } + + // if it's more than min, we're good to return + if(nValueRet >= nValueMin) return true; + + return false; +} + +bool CWallet::SelectCoinsCollateral(std::vector& setCoinsRet, int64_t& nValueRet) const +{ + vector vCoins; + + //printf(" selecting coins for collateral\n"); + AvailableCoins(vCoins); + + //printf("found coins %d\n", (int)vCoins.size()); + + set > setCoinsRet2; + + BOOST_FOREACH(const COutput& out, vCoins) + { + // collateral inputs will always be a multiple of DARSEND_COLLATERAL, up to five + if(IsCollateralAmount(out.tx->vout[out.i].nValue)) + { + CTxIn vin = CTxIn(out.tx->GetHash(),out.i); + + vin.prevPubKey = out.tx->vout[out.i].scriptPubKey; // the inputs PubKey + nValueRet += out.tx->vout[out.i].nValue; + setCoinsRet.push_back(vin); + setCoinsRet2.insert(make_pair(out.tx, out.i)); + return true; + } + } + + return false; +} + +int CWallet::CountInputsWithAmount(int64_t nInputAmount) +{ + int64_t nTotal = 0; + { + LOCK(cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (pcoin->IsTrusted()){ + int nDepth = pcoin->GetDepthInMainChain(); + + for (unsigned int i = 0; i < pcoin->vout.size(); i++) { + //isminetype mine = IsMine(pcoin->vout[i]); + bool mine = IsMine(pcoin->vout[i]); + //COutput out = COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO); + COutput out = COutput(pcoin, i, nDepth, mine); + CTxIn vin = CTxIn(out.tx->GetHash(), out.i); + + if(out.tx->vout[out.i].nValue != nInputAmount) continue; + if(!IsDenominatedAmount(pcoin->vout[i].nValue)) continue; + //if(IsSpent(out.tx->GetHash(), i) || !IsMine(pcoin->vout[i]) || !IsDenominated(vin)) continue; + if(pcoin->IsSpent(i) || !IsMine(pcoin->vout[i]) || !IsDenominated(vin)) continue; + + nTotal++; + } + } + } + } + + return nTotal; +} + +bool CWallet::HasCollateralInputs() const +{ + vector vCoins; + AvailableCoins(vCoins); + + int nFound = 0; + BOOST_FOREACH(const COutput& out, vCoins) + if(IsCollateralAmount(out.tx->vout[out.i].nValue)) nFound++; + + return nFound > 1; // should have more than one just in case +} + +bool CWallet::IsCollateralAmount(int64_t nInputAmount) const +{ + return nInputAmount == (DARKSEND_COLLATERAL * 5)+DARKSEND_FEE || + nInputAmount == (DARKSEND_COLLATERAL * 4)+DARKSEND_FEE || + nInputAmount == (DARKSEND_COLLATERAL * 3)+DARKSEND_FEE || + nInputAmount == (DARKSEND_COLLATERAL * 2)+DARKSEND_FEE || + nInputAmount == (DARKSEND_COLLATERAL * 1)+DARKSEND_FEE; +} + +bool CWallet::SelectCoinsWithoutDenomination(int64_t nTargetValue, set >& setCoinsRet, int64_t& nValueRet) const +{ + CCoinControl *coinControl=NULL; + + vector vCoins; + AvailableCoins(vCoins, true, coinControl, ONLY_NONDENOMINATED); + + BOOST_FOREACH(const COutput& out, vCoins) + { + nValueRet += out.tx->vout[out.i].nValue; + setCoinsRet.insert(make_pair(out.tx, out.i)); + } + return (nValueRet >= nTargetValue); +} + +bool CWallet::CreateCollateralTransaction(CTransaction& txCollateral, std::string strReason) +{ + /* + To doublespend a collateral transaction, it will require a fee higher than this. So there's + still a significant cost. + */ + int64_t nFeeRet = 0.001*COIN; + + txCollateral.vin.clear(); + txCollateral.vout.clear(); + + CReserveKey reservekey(this); + int64_t nValueIn2 = 0; + std::vector vCoinsCollateral; + + if (!SelectCoinsCollateral(vCoinsCollateral, nValueIn2)) + { + strReason = "Error: darksend requires a collateral transaction and could not locate an acceptable input!"; + return false; + } + + // make our change address + CScript scriptChange; + CPubKey vchPubKey; + assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked + scriptChange =GetScriptForDestination(vchPubKey.GetID()); + reservekey.KeepKey(); + + BOOST_FOREACH(CTxIn v, vCoinsCollateral) + txCollateral.vin.push_back(v); + + if(nValueIn2 - DARKSEND_COLLATERAL - nFeeRet > 0) { + //pay collateral charge in fees + CTxOut vout3 = CTxOut(nValueIn2 - DARKSEND_COLLATERAL, scriptChange); + txCollateral.vout.push_back(vout3); + } + + int vinNumber = 0; + BOOST_FOREACH(CTxIn v, txCollateral.vin) { + if(!SignSignature(*this, v.prevPubKey, txCollateral, vinNumber, int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))) { + BOOST_FOREACH(CTxIn v, vCoinsCollateral) + UnlockCoin(v.prevout); + + strReason = "CDarkSendPool::Sign - Unable to sign collateral transaction! \n"; + return false; + } + vinNumber++; + } + + return true; +} + +bool CWallet::ConvertList(std::vector vCoins, std::vector& vecAmounts) +{ + BOOST_FOREACH(CTxIn i, vCoins){ + if (mapWallet.count(i.prevout.hash)) + { + CWalletTx& wtx = mapWallet[i.prevout.hash]; + if(i.prevout.n < wtx.vout.size()){ + vecAmounts.push_back(wtx.vout[i.prevout.n].nValue); + } + } else { + LogPrintf("ConvertList -- Couldn't find transaction\n"); + } + } + return true; +} + + +bool CWallet::CreateTransaction(const vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, int32_t& nChangePos, std::string& strFailReason, const CCoinControl* coinControl, AvailableCoinsType coin_type, bool useIX) +{ + int64_t nValue = 0; + BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend) + { + if (nValue < 0) + return false; + nValue += s.second; + } + if (vecSend.empty() || nValue < 0) + return false; + + wtxNew.BindWallet(this); + CTransaction txNew; + + { + LOCK2(cs_main, cs_wallet); + // txdb must be opened before the mapWallet lock + CTxDB txdb("r"); + { + nFeeRet = nTransactionFee; + while (true) + { + wtxNew.vin.clear(); + wtxNew.vout.clear(); + wtxNew.fFromMe = true; + + int64_t nTotalValue = nValue + nFeeRet; + double dPriority = 0; + // vouts to the payees + BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend) + wtxNew.vout.push_back(CTxOut(s.second, s.first)); + + // Choose coins to use + set > setCoins; + int64_t nValueIn = 0; + if (!SelectCoins(nTotalValue, wtxNew.nTime, setCoins, nValueIn, coinControl)) + { + if(coin_type == ALL_COINS) { + strFailReason = _("Insufficient funds."); + } else if (coin_type == ONLY_NONDENOMINATED) { + strFailReason = _("Unable to locate enough darksend non-denominated funds for this transaction."); + } else if (coin_type == ONLY_NONDENOMINATED_NOTMN) { + strFailReason = _("Unable to locate enough darksend non-denominated funds for this transaction that are not equal 1000 SONO."); + } else { + strFailReason = _("Unable to locate enough darksend denominated funds for this transaction."); + strFailReason += _("darksend uses exact denominated amounts to send funds, you might simply need to anonymize some more coins."); + } + + if(useIX){ + strFailReason += _("InstantX requires inputs with at least 6 confirmations, you might need to wait a few minutes and try again."); + } + return false; + } + BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) + { + int64_t nCredit = pcoin.first->vout[pcoin.second].nValue; + dPriority += (double)nCredit * pcoin.first->GetDepthInMainChain(); + } + + int64_t nChange = nValueIn - nValue - nFeeRet; + + if (nChange > 0) + { + // Fill a vout to ourself + // TODO: pass in scriptChange instead of reservekey so + // change transaction isn't always pay-to-bitcoin-address + CScript scriptChange; + + // coin control: send change to custom address + if (coinControl && !boost::get(&coinControl->destChange)) + scriptChange.SetDestination(coinControl->destChange); + + // no coin control: send change to newly generated address + else + { + // Note: We use a new key here to keep it from being obvious which side is the change. + // The drawback is that by not reusing a previous key, the change may be lost if a + // backup is restored, if the backup doesn't have the new private key for the change. + // If we reused the old key, it would be possible to add code to look for and + // rediscover unknown transactions that were written with keys of ours to recover + // post-backup change. + + // Reserve a new key pair from key pool + CPubKey vchPubKey; + assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked + + scriptChange.SetDestination(vchPubKey.GetID()); + } + + // Insert change txn at random position: + vector::iterator position = wtxNew.vout.begin()+GetRandInt(wtxNew.vout.size()); + + // -- don't put change output between value and narration outputs + if (position > wtxNew.vout.begin() && position < wtxNew.vout.end()) + { + while (position > wtxNew.vout.begin()) + { + if (position->nValue != 0) + break; + position--; + }; + }; + + wtxNew.vout.insert(position, CTxOut(nChange, scriptChange)); + nChangePos = std::distance(wtxNew.vout.begin(), position); + } + else + reservekey.ReturnKey(); + + // Fill vin + BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins) + wtxNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second)); + + // Sign + int nIn = 0; + BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins) + if (!SignSignature(*this, *coin.first, wtxNew, nIn++)) + return false; + + // Limit size + unsigned int nBytes = ::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK, PROTOCOL_VERSION); + if (nBytes >= MAX_STANDARD_TX_SIZE) + return false; + dPriority /= nBytes; + + // Check that enough fee is included + int64_t nPayFee = nTransactionFee * (1 + (int64_t)nBytes / 1000); + int64_t nMinFee = GetMinFee(wtxNew, 1, GMF_SEND, nBytes); + + if (nFeeRet < max(nPayFee, nMinFee)) + { + nFeeRet = max(nPayFee, nMinFee); + continue; + } + + // Fill vtxPrev by copying from previous transactions vtxPrev + wtxNew.AddSupportingTransactions(txdb); + wtxNew.fTimeReceivedIsTxTime = true; + + break; + } + } + } + return true; +} + +bool CWallet::CreateTransaction(CScript scriptPubKey, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl) +{ + vector< pair > vecSend; + vecSend.push_back(make_pair(scriptPubKey, nValue)); + + if (sNarr.length() > 0) + { + std::vector vNarr(sNarr.c_str(), sNarr.c_str() + sNarr.length()); + std::vector vNDesc; + + vNDesc.resize(2); + vNDesc[0] = 'n'; + vNDesc[1] = 'p'; + + CScript scriptN = CScript() << OP_RETURN << vNDesc << OP_RETURN << vNarr; + + vecSend.push_back(make_pair(scriptN, 0)); + } + + // -- CreateTransaction won't place change between value and narr output. + // narration output will be for preceding output + + int nChangePos; + std::string strFailReason; + bool rv = CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, nChangePos, strFailReason, coinControl); + + // -- narration will be added to mapValue later in FindStealthTransactions From CommitTransaction + return rv; +} + + +bool CWallet::NewStealthAddress(std::string& sError, std::string& sLabel, CStealthAddress& sxAddr) +{ + ec_secret scan_secret; + ec_secret spend_secret; + + if (GenerateRandomSecret(scan_secret) != 0 + || GenerateRandomSecret(spend_secret) != 0) + { + sError = "GenerateRandomSecret failed."; + printf("Error CWallet::NewStealthAddress - %s\n", sError.c_str()); + return false; + }; + + ec_point scan_pubkey, spend_pubkey; + if (SecretToPublicKey(scan_secret, scan_pubkey) != 0) + { + sError = "Could not get scan public key."; + printf("Error CWallet::NewStealthAddress - %s\n", sError.c_str()); + return false; + }; + + if (SecretToPublicKey(spend_secret, spend_pubkey) != 0) + { + sError = "Could not get spend public key."; + printf("Error CWallet::NewStealthAddress - %s\n", sError.c_str()); + return false; + }; + + if (fDebug) + { + printf("getnewstealthaddress: "); + printf("scan_pubkey "); + for (uint32_t i = 0; i < scan_pubkey.size(); ++i) + printf("%02x", scan_pubkey[i]); + printf("\n"); + + printf("spend_pubkey "); + for (uint32_t i = 0; i < spend_pubkey.size(); ++i) + printf("%02x", spend_pubkey[i]); + printf("\n"); + }; + + + sxAddr.label = sLabel; + sxAddr.scan_pubkey = scan_pubkey; + sxAddr.spend_pubkey = spend_pubkey; + + sxAddr.scan_secret.resize(32); + memcpy(&sxAddr.scan_secret[0], &scan_secret.e[0], 32); + sxAddr.spend_secret.resize(32); + memcpy(&sxAddr.spend_secret[0], &spend_secret.e[0], 32); + + return true; +} + +bool CWallet::AddStealthAddress(CStealthAddress& sxAddr) +{ + LOCK(cs_wallet); + + // must add before changing spend_secret + stealthAddresses.insert(sxAddr); + + bool fOwned = sxAddr.scan_secret.size() == ec_secret_size; + + + + if (fOwned) + { + // -- owned addresses can only be added when wallet is unlocked + if (IsLocked()) + { + printf("Error: CWallet::AddStealthAddress wallet must be unlocked.\n"); + stealthAddresses.erase(sxAddr); + return false; + }; + + if (IsCrypted()) + { + std::vector vchCryptedSecret; + CSecret vchSecret; + vchSecret.resize(32); + memcpy(&vchSecret[0], &sxAddr.spend_secret[0], 32); + + uint256 iv = Hash(sxAddr.spend_pubkey.begin(), sxAddr.spend_pubkey.end()); + if (!EncryptSecret(vMasterKey, vchSecret, iv, vchCryptedSecret)) + { + printf("Error: Failed encrypting stealth key %s\n", sxAddr.Encoded().c_str()); + stealthAddresses.erase(sxAddr); + return false; + }; + sxAddr.spend_secret = vchCryptedSecret; + }; + }; + + + bool rv = CWalletDB(strWalletFile).WriteStealthAddress(sxAddr); + + if (rv) + NotifyAddressBookChanged(this, sxAddr, sxAddr.label, fOwned, CT_NEW); + + return rv; +} + +bool CWallet::UnlockStealthAddresses(const CKeyingMaterial& vMasterKeyIn) +{ + // -- decrypt spend_secret of stealth addresses + std::set::iterator it; + for (it = stealthAddresses.begin(); it != stealthAddresses.end(); ++it) + { + if (it->scan_secret.size() < 32) + continue; // stealth address is not owned + + // -- CStealthAddress are only sorted on spend_pubkey + CStealthAddress &sxAddr = const_cast(*it); + + if (fDebug) + printf("Decrypting stealth key %s\n", sxAddr.Encoded().c_str()); + + CSecret vchSecret; + uint256 iv = Hash(sxAddr.spend_pubkey.begin(), sxAddr.spend_pubkey.end()); + if(!DecryptSecret(vMasterKeyIn, sxAddr.spend_secret, iv, vchSecret) + || vchSecret.size() != 32) + { + printf("Error: Failed decrypting stealth key %s\n", sxAddr.Encoded().c_str()); + continue; + }; + + ec_secret testSecret; + memcpy(&testSecret.e[0], &vchSecret[0], 32); + ec_point pkSpendTest; + + if (SecretToPublicKey(testSecret, pkSpendTest) != 0 + || pkSpendTest != sxAddr.spend_pubkey) + { + printf("Error: Failed decrypting stealth key, public key mismatch %s\n", sxAddr.Encoded().c_str()); + continue; + }; + + sxAddr.spend_secret.resize(32); + memcpy(&sxAddr.spend_secret[0], &vchSecret[0], 32); + }; + + CryptedKeyMap::iterator mi = mapCryptedKeys.begin(); + for (; mi != mapCryptedKeys.end(); ++mi) + { + CPubKey &pubKey = (*mi).second.first; + std::vector &vchCryptedSecret = (*mi).second.second; + if (vchCryptedSecret.size() != 0) + continue; + + CKeyID ckid = pubKey.GetID(); + CBitcoinAddress addr(ckid); + + StealthKeyMetaMap::iterator mi = mapStealthKeyMeta.find(ckid); + if (mi == mapStealthKeyMeta.end()) + { + printf("Error: No metadata found to add secret for %s\n", addr.ToString().c_str()); + continue; + }; + + CStealthKeyMetadata& sxKeyMeta = mi->second; + + CStealthAddress sxFind; + sxFind.scan_pubkey = sxKeyMeta.pkScan.Raw(); + + std::set::iterator si = stealthAddresses.find(sxFind); + if (si == stealthAddresses.end()) + { + printf("No stealth key found to add secret for %s\n", addr.ToString().c_str()); + continue; + }; + + if (fDebug) + printf("Expanding secret for %s\n", addr.ToString().c_str()); + + ec_secret sSpendR; + ec_secret sSpend; + ec_secret sScan; + + if (si->spend_secret.size() != ec_secret_size + || si->scan_secret.size() != ec_secret_size) + { + printf("Stealth address has no secret key for %s\n", addr.ToString().c_str()); + continue; + } + memcpy(&sScan.e[0], &si->scan_secret[0], ec_secret_size); + memcpy(&sSpend.e[0], &si->spend_secret[0], ec_secret_size); + + ec_point pkEphem = sxKeyMeta.pkEphem.Raw(); + if (StealthSecretSpend(sScan, pkEphem, sSpend, sSpendR) != 0) + { + printf("StealthSecretSpend() failed.\n"); + continue; + }; + + ec_point pkTestSpendR; + if (SecretToPublicKey(sSpendR, pkTestSpendR) != 0) + { + printf("SecretToPublicKey() failed.\n"); + continue; + }; + + CSecret vchSecret; + vchSecret.resize(ec_secret_size); + + memcpy(&vchSecret[0], &sSpendR.e[0], ec_secret_size); + CKey ckey; + + try { + ckey.Set(vchSecret.begin(), vchSecret.end(), true); + //ckey.SetSecret(vchSecret, true); + } catch (std::exception& e) { + printf("ckey.SetSecret() threw: %s.\n", e.what()); + continue; + }; + + CPubKey cpkT = ckey.GetPubKey(); + + if (!cpkT.IsValid()) + { + printf("cpkT is invalid.\n"); + continue; + }; + + if (cpkT != pubKey) + { + printf("Error: Generated secret does not match.\n"); + continue; + }; + + if (!ckey.IsValid()) + { + printf("Reconstructed key is invalid.\n"); + continue; + }; + + if (fDebug) + { + CKeyID keyID = cpkT.GetID(); + CBitcoinAddress coinAddress(keyID); + printf("Adding secret to key %s.\n", coinAddress.ToString().c_str()); + }; + + if (!AddKey(ckey)) + { + printf("AddKey failed.\n"); + continue; + }; + + if (!CWalletDB(strWalletFile).EraseStealthKeyMeta(ckid)) + printf("EraseStealthKeyMeta failed for %s\n", addr.ToString().c_str()); + }; + return true; +} + +bool CWallet::UpdateStealthAddress(std::string &addr, std::string &label, bool addIfNotExist) +{ + if (fDebug) + printf("UpdateStealthAddress %s\n", addr.c_str()); + + + CStealthAddress sxAddr; + + if (!sxAddr.SetEncoded(addr)) + return false; + + std::set::iterator it; + it = stealthAddresses.find(sxAddr); + + ChangeType nMode = CT_UPDATED; + CStealthAddress sxFound; + if (it == stealthAddresses.end()) + { + if (addIfNotExist) + { + sxFound = sxAddr; + sxFound.label = label; + stealthAddresses.insert(sxFound); + nMode = CT_NEW; + } else + { + printf("UpdateStealthAddress %s, not in set\n", addr.c_str()); + return false; + }; + } else + { + sxFound = const_cast(*it); + + if (sxFound.label == label) + { + // no change + return true; + }; + + it->label = label; // update in .stealthAddresses + + if (sxFound.scan_secret.size() == ec_secret_size) + { + printf("UpdateStealthAddress: todo - update owned stealth address.\n"); + return false; + }; + }; + + sxFound.label = label; + + if (!CWalletDB(strWalletFile).WriteStealthAddress(sxFound)) + { + printf("UpdateStealthAddress(%s) Write to db failed.\n", addr.c_str()); + return false; + }; + + bool fOwned = sxFound.scan_secret.size() == ec_secret_size; + NotifyAddressBookChanged(this, sxFound, sxFound.label, fOwned, nMode); + + return true; +} + +bool CWallet::CreateStealthTransaction(CScript scriptPubKey, int64_t nValue, std::vector& P, std::vector& narr, std::string& sNarr, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl) +{ + vector< pair > vecSend; + vecSend.push_back(make_pair(scriptPubKey, nValue)); + + CScript scriptP = CScript() << OP_RETURN << P; + if (narr.size() > 0) + scriptP = scriptP << OP_RETURN << narr; + + vecSend.push_back(make_pair(scriptP, 1)); + + // -- shuffle inputs, change output won't mix enough as it must be not fully random for plantext narrations + std::random_shuffle(vecSend.begin(), vecSend.end()); + + int nChangePos; + std::string strFailReason; + bool rv = CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, nChangePos, strFailReason, coinControl); + + // -- the change txn is inserted in a random pos, check here to match narr to output + if (rv && narr.size() > 0) + { + for (unsigned int k = 0; k < wtxNew.vout.size(); ++k) + { + if (wtxNew.vout[k].scriptPubKey != scriptPubKey + || wtxNew.vout[k].nValue != nValue) + continue; + + char key[64]; + if (snprintf(key, sizeof(key), "n_%u", k) < 1) + { + printf("CreateStealthTransaction(): Error creating narration key."); + break; + }; + wtxNew.mapValue[key] = sNarr; + break; + }; + }; + + return rv; +} + +string CWallet::SendStealthMoney(CScript scriptPubKey, int64_t nValue, std::vector& P, std::vector& narr, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee) +{ + CReserveKey reservekey(this); + int64_t nFeeRequired; + + if (IsLocked()) + { + string strError = _("Error: Wallet locked, unable to create transaction "); + printf("SendStealthMoney() : %s", strError.c_str()); + return strError; + } + if (fWalletUnlockStakingOnly) + { + string strError = _("Error: Wallet unlocked for staking only, unable to create transaction."); + printf("SendStealthMoney() : %s", strError.c_str()); + return strError; + } + if (!CreateStealthTransaction(scriptPubKey, nValue, P, narr, sNarr, wtxNew, reservekey, nFeeRequired)) + { + string strError; + if (nValue + nFeeRequired > GetBalance()) + strError = strprintf(_("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds "), FormatMoney(nFeeRequired).c_str()); + else + strError = _("Error: Transaction creation failed "); + printf("SendStealthMoney() : %s", strError.c_str()); + return strError; + } + + if (fAskFee && !uiInterface.ThreadSafeAskFee(nFeeRequired, _("Sending..."))) + return "ABORTED"; + + if (!CommitTransaction(wtxNew, reservekey)) + return _("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."); + + return ""; +} + +bool CWallet::SendStealthMoneyToDestination(CStealthAddress& sxAddress, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, std::string& sError, bool fAskFee) +{ + // -- Check amount + if (nValue <= 0) + { + sError = "Invalid amount"; + return false; + }; + if (nValue + nTransactionFee + (1) > GetBalance()) + { + sError = "Insufficient funds"; + return false; + }; + + + ec_secret ephem_secret; + ec_secret secretShared; + ec_point pkSendTo; + ec_point ephem_pubkey; + + if (GenerateRandomSecret(ephem_secret) != 0) + { + sError = "GenerateRandomSecret failed."; + return false; + }; + + if (StealthSecret(ephem_secret, sxAddress.scan_pubkey, sxAddress.spend_pubkey, secretShared, pkSendTo) != 0) + { + sError = "Could not generate receiving public key."; + return false; + }; + + CPubKey cpkTo(pkSendTo); + if (!cpkTo.IsValid()) + { + sError = "Invalid public key generated."; + return false; + }; + + CKeyID ckidTo = cpkTo.GetID(); + + CBitcoinAddress addrTo(ckidTo); + + if (SecretToPublicKey(ephem_secret, ephem_pubkey) != 0) + { + sError = "Could not generate ephem public key."; + return false; + }; + + if (fDebug) + { + printf("Stealth send to generated pubkey %"PRIszu": %s\n", pkSendTo.size(), HexStr(pkSendTo).c_str()); + printf("hash %s\n", addrTo.ToString().c_str()); + printf("ephem_pubkey %"PRIszu": %s\n", ephem_pubkey.size(), HexStr(ephem_pubkey).c_str()); + }; + + std::vector vchNarr; + if (sNarr.length() > 0) + { + SecMsgCrypter crypter; + crypter.SetKey(&secretShared.e[0], &ephem_pubkey[0]); + + if (!crypter.Encrypt((uint8_t*)&sNarr[0], sNarr.length(), vchNarr)) + { + sError = "Narration encryption failed."; + return false; + }; + + if (vchNarr.size() > 48) + { + sError = "Encrypted narration is too long."; + return false; + }; + }; + + // -- Parse Bitcoin address + CScript scriptPubKey; + scriptPubKey.SetDestination(addrTo.Get()); + + if ((sError = SendStealthMoney(scriptPubKey, nValue, ephem_pubkey, vchNarr, sNarr, wtxNew, fAskFee)) != "") + return false; + + + return true; +} + +bool CWallet::FindStealthTransactions(const CTransaction& tx, mapValue_t& mapNarr) +{ + if (fDebug) + LogPrintf("FindStealthTransactions() tx: %s\n", tx.GetHash().GetHex().c_str()); + + mapNarr.clear(); + + LOCK(cs_wallet); + ec_secret sSpendR; + ec_secret sSpend; + ec_secret sScan; + ec_secret sShared; + + ec_point pkExtracted; + + std::vector vchEphemPK; + std::vector vchDataB; + std::vector vchENarr; + opcodetype opCode; + char cbuf[256]; + + int32_t nOutputIdOuter = -1; + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + nOutputIdOuter++; + // -- for each OP_RETURN need to check all other valid outputs + + //printf("txout scriptPubKey %s\n", txout.scriptPubKey.ToString().c_str()); + CScript::const_iterator itTxA = txout.scriptPubKey.begin(); + + if (!txout.scriptPubKey.GetOp(itTxA, opCode, vchEphemPK) + || opCode != OP_RETURN) + continue; + else + if (!txout.scriptPubKey.GetOp(itTxA, opCode, vchEphemPK) + || vchEphemPK.size() != 33) + { + // -- look for plaintext narrations + if (vchEphemPK.size() > 1 + && vchEphemPK[0] == 'n' + && vchEphemPK[1] == 'p') + { + if (txout.scriptPubKey.GetOp(itTxA, opCode, vchENarr) + && opCode == OP_RETURN + && txout.scriptPubKey.GetOp(itTxA, opCode, vchENarr) + && vchENarr.size() > 0) + { + std::string sNarr = std::string(vchENarr.begin(), vchENarr.end()); + + snprintf(cbuf, sizeof(cbuf), "n_%d", nOutputIdOuter-1); // plaintext narration always matches preceding value output + mapNarr[cbuf] = sNarr; + } else + { + printf("Warning: FindStealthTransactions() tx: %s, Could not extract plaintext narration.\n", tx.GetHash().GetHex().c_str()); + }; + } + + continue; + } + + int32_t nOutputId = -1; + nStealth++; + BOOST_FOREACH(const CTxOut& txoutB, tx.vout) + { + nOutputId++; + + if (&txoutB == &txout) + continue; + + bool txnMatch = false; // only 1 txn will match an ephem pk + //printf("txoutB scriptPubKey %s\n", txoutB.scriptPubKey.ToString().c_str()); + + CTxDestination address; + if (!ExtractDestination(txoutB.scriptPubKey, address)) + continue; + + if (address.type() != typeid(CKeyID)) + continue; + + CKeyID ckidMatch = boost::get(address); + + if (HaveKey(ckidMatch)) // no point checking if already have key + continue; + + std::set::iterator it; + for (it = stealthAddresses.begin(); it != stealthAddresses.end(); ++it) + { + if (it->scan_secret.size() != ec_secret_size) + continue; // stealth address is not owned + + //printf("it->Encodeded() %s\n", it->Encoded().c_str()); + memcpy(&sScan.e[0], &it->scan_secret[0], ec_secret_size); + + if (StealthSecret(sScan, vchEphemPK, it->spend_pubkey, sShared, pkExtracted) != 0) + { + printf("StealthSecret failed.\n"); + continue; + }; + //printf("pkExtracted %"PRIszu": %s\n", pkExtracted.size(), HexStr(pkExtracted).c_str()); + + CPubKey cpkE(pkExtracted); + + if (!cpkE.IsValid()) + continue; + CKeyID ckidE = cpkE.GetID(); + + if (ckidMatch != ckidE) + continue; + + if (fDebug) + printf("Found stealth txn to address %s\n", it->Encoded().c_str()); + + if (IsLocked()) + { + if (fDebug) + printf("Wallet is locked, adding key without secret.\n"); + + // -- add key without secret + std::vector vchEmpty; + AddCryptedKey(cpkE, vchEmpty); + CKeyID keyId = cpkE.GetID(); + CBitcoinAddress coinAddress(keyId); + std::string sLabel = it->Encoded(); + SetAddressBookName(keyId, sLabel); + + CPubKey cpkEphem(vchEphemPK); + CPubKey cpkScan(it->scan_pubkey); + CStealthKeyMetadata lockedSkMeta(cpkEphem, cpkScan); + + if (!CWalletDB(strWalletFile).WriteStealthKeyMeta(keyId, lockedSkMeta)) + printf("WriteStealthKeyMeta failed for %s\n", coinAddress.ToString().c_str()); + + mapStealthKeyMeta[keyId] = lockedSkMeta; + nFoundStealth++; + } else + { + if (it->spend_secret.size() != ec_secret_size) + continue; + memcpy(&sSpend.e[0], &it->spend_secret[0], ec_secret_size); + + + if (StealthSharedToSecretSpend(sShared, sSpend, sSpendR) != 0) + { + printf("StealthSharedToSecretSpend() failed.\n"); + continue; + }; + + ec_point pkTestSpendR; + if (SecretToPublicKey(sSpendR, pkTestSpendR) != 0) + { + printf("SecretToPublicKey() failed.\n"); + continue; + }; + + CSecret vchSecret; + vchSecret.resize(ec_secret_size); + + memcpy(&vchSecret[0], &sSpendR.e[0], ec_secret_size); + CKey ckey; + + try { + ckey.Set(vchSecret.begin(), vchSecret.end(), true); + //ckey.SetSecret(vchSecret, true); + } catch (std::exception& e) { + printf("ckey.SetSecret() threw: %s.\n", e.what()); + continue; + }; + + CPubKey cpkT = ckey.GetPubKey(); + if (!cpkT.IsValid()) + { + printf("cpkT is invalid.\n"); + continue; + }; + + if (!ckey.IsValid()) + { + printf("Reconstructed key is invalid.\n"); + continue; + }; + + CKeyID keyID = cpkT.GetID(); + if (fDebug) + { + CBitcoinAddress coinAddress(keyID); + printf("Adding key %s.\n", coinAddress.ToString().c_str()); + }; + + if (!AddKey(ckey)) + { + printf("AddKey failed.\n"); + continue; + }; + + std::string sLabel = it->Encoded(); + SetAddressBookName(keyID, sLabel); + nFoundStealth++; + }; + + if (txout.scriptPubKey.GetOp(itTxA, opCode, vchENarr) + && opCode == OP_RETURN + && txout.scriptPubKey.GetOp(itTxA, opCode, vchENarr) + && vchENarr.size() > 0) + { + SecMsgCrypter crypter; + crypter.SetKey(&sShared.e[0], &vchEphemPK[0]); + std::vector vchNarr; + if (!crypter.Decrypt(&vchENarr[0], vchENarr.size(), vchNarr)) + { + printf("Decrypt narration failed.\n"); + continue; + }; + std::string sNarr = std::string(vchNarr.begin(), vchNarr.end()); + + snprintf(cbuf, sizeof(cbuf), "n_%d", nOutputId); + mapNarr[cbuf] = sNarr; + }; + + txnMatch = true; + break; + }; + if (txnMatch) + break; + }; + }; + + return true; +}; + + + + +uint64_t CWallet::GetStakeWeight() const +{ + // Choose coins to use + int64_t nBalance = GetBalance(); + + if (nBalance <= nReserveBalance) + return 0; + + vector vwtxPrev; + + set > setCoins; + int64_t nValueIn = 0; + + if (!SelectCoinsForStaking(nBalance - nReserveBalance, GetTime(), setCoins, nValueIn)) + return 0; + + if (setCoins.empty()) + return 0; + + uint64_t nWeight = 0; + + int64_t nCurrentTime = GetTime(); + CTxDB txdb("r"); + + LOCK2(cs_main, cs_wallet); + BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) + { + CTxIndex txindex; + if (!txdb.ReadTxIndex(pcoin.first->GetHash(), txindex)) + continue; + + if (nCurrentTime - pcoin.first->nTime > nStakeMinAge) + nWeight += pcoin.first->vout[pcoin.second].nValue; + } + + return nWeight; +} + +bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, int64_t nFees, CTransaction& txNew, CKey& key) +{ + CBlockIndex* pindexPrev = pindexBest; + CBigNum bnTargetPerCoinDay; + bnTargetPerCoinDay.SetCompact(nBits); + + txNew.vin.clear(); + txNew.vout.clear(); + + // Mark coin stake transaction + CScript scriptEmpty; + scriptEmpty.clear(); + txNew.vout.push_back(CTxOut(0, scriptEmpty)); + + // Choose coins to use + int64_t nBalance = GetBalance(); + + if (nBalance <= nReserveBalance) + return false; + + vector vwtxPrev; + + set > setCoins; + int64_t nValueIn = 0; + + // Select coins with suitable depth + if (!SelectCoinsForStaking(nBalance - nReserveBalance, txNew.nTime, setCoins, nValueIn)) + return false; + + if (setCoins.empty()) + return false; + + int64_t nCredit = 0; + CScript scriptPubKeyKernel; + CTxDB txdb("r"); + BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) + { + static int nMaxStakeSearchInterval = 60; + bool fKernelFound = false; + for (unsigned int n=0; nGetHash(), pcoin.second); + int64_t nBlockTime; + if (CheckKernel(pindexPrev, nBits, txNew.nTime - n, prevoutStake, &nBlockTime)) + { + // Found a kernel + LogPrint("coinstake", "CreateCoinStake : kernel found\n"); + vector vSolutions; + txnouttype whichType; + CScript scriptPubKeyOut; + scriptPubKeyKernel = pcoin.first->vout[pcoin.second].scriptPubKey; + if (!Solver(scriptPubKeyKernel, whichType, vSolutions)) + { + LogPrint("coinstake", "CreateCoinStake : failed to parse kernel\n"); + break; + } + LogPrint("coinstake", "CreateCoinStake : parsed kernel type=%d\n", whichType); + if (whichType != TX_PUBKEY && whichType != TX_PUBKEYHASH) + { + LogPrint("coinstake", "CreateCoinStake : no support for kernel type=%d\n", whichType); + break; // only support pay to public key and pay to address + } + if (whichType == TX_PUBKEYHASH) // pay to address type + { + // convert to pay to public key type + if (!keystore.GetKey(uint160(vSolutions[0]), key)) + { + LogPrint("coinstake", "CreateCoinStake : failed to get key for kernel type=%d\n", whichType); + break; // unable to find corresponding public key + } + scriptPubKeyOut << key.GetPubKey() << OP_CHECKSIG; + } + if (whichType == TX_PUBKEY) + { + valtype& vchPubKey = vSolutions[0]; + if (!keystore.GetKey(Hash160(vchPubKey), key)) + { + LogPrint("coinstake", "CreateCoinStake : failed to get key for kernel type=%d\n", whichType); + break; // unable to find corresponding public key + } + + if (key.GetPubKey() != vchPubKey) + { + LogPrint("coinstake", "CreateCoinStake : invalid key for kernel type=%d\n", whichType); + break; // keys mismatch + } + + scriptPubKeyOut = scriptPubKeyKernel; + } + + txNew.nTime -= n; + txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); + nCredit += pcoin.first->vout[pcoin.second].nValue; + vwtxPrev.push_back(pcoin.first); + txNew.vout.push_back(CTxOut(0, scriptPubKeyOut)); + + if(nCredit > 100 * COIN) + txNew.vout.push_back(CTxOut(0, scriptPubKeyOut)); //split stake + LogPrint("coinstake", "CreateCoinStake : added kernel type=%d\n", whichType); + fKernelFound = true; + break; + } + } + + if (fKernelFound) + break; // if kernel is found stop searching + } + + if (nCredit == 0 || nCredit > nBalance - nReserveBalance) + return false; + + BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) + { + // Attempt to add more inputs + // Only add coins of the same key/address as kernel + if (txNew.vout.size() == 2 && ((pcoin.first->vout[pcoin.second].scriptPubKey == scriptPubKeyKernel || pcoin.first->vout[pcoin.second].scriptPubKey == txNew.vout[1].scriptPubKey)) + && pcoin.first->GetHash() != txNew.vin[0].prevout.hash) + { + int64_t nTimeWeight = GetWeight((int64_t)pcoin.first->nTime, (int64_t)txNew.nTime); + + // Stop adding more inputs if already too many inputs + if (txNew.vin.size() >= 100) + break; + // Stop adding more inputs if value is already pretty significant + if (nCredit >= GetStakeCombineThreshold()) + break; + // Stop adding inputs if reached reserve limit + if (nCredit + pcoin.first->vout[pcoin.second].nValue > nBalance - nReserveBalance) + break; + // Do not add additional significant input + if (pcoin.first->vout[pcoin.second].nValue >= GetStakeCombineThreshold()) + continue; + // Do not add input that is still too young + if (nTimeWeight < nStakeMinAge) + continue; + + txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); + nCredit += pcoin.first->vout[pcoin.second].nValue; + vwtxPrev.push_back(pcoin.first); + } + } + + // Calculate coin age reward + int64_t nReward; + { + uint64_t nCoinAge; + CTxDB txdb("r"); + if (!txNew.GetCoinAge(txdb, nCoinAge)) + return error("CreateCoinStake : failed to calculate coin age"); + + nReward = GetProofOfStakeReward(pindexPrev, nCoinAge, nFees); + if (nReward <= 0) + return false; + + nCredit += nReward; + } + + + // Masternode Payments + int payments = 1; + // start masternode payments + bool bMasterNodePayment = true; // note was false, set true to test + + if ( Params().NetworkID() == CChainParams::TESTNET ){ + if (GetTime() > START_MASTERNODE_PAYMENTS_TESTNET ){ + bMasterNodePayment = true; + } + }else{ + if (GetTime() > START_MASTERNODE_PAYMENTS){ + bMasterNodePayment = true; + } + } + + CScript payee; + bool hasPayment = true; + if(bMasterNodePayment) { + //spork + if(!masternodePayments.GetBlockPayee(pindexPrev->nHeight+1, payee)){ + int winningNode = GetCurrentMasterNode(1); + if(winningNode >= 0){ + payee =GetScriptForDestination(vecMasternodes[winningNode].pubkey.GetID()); + } else { + LogPrintf("CreateCoinStake: Failed to detect masternode to pay\n"); + hasPayment = false; + } + } + } + + if(hasPayment){ + payments = txNew.vout.size() + 1; + txNew.vout.resize(payments); + + txNew.vout[payments-1].scriptPubKey = payee; + txNew.vout[payments-1].nValue = 0; + + CTxDestination address1; + ExtractDestination(payee, address1); + CBitcoinAddress address2(address1); + + LogPrintf("Masternode payment to %s\n", address2.ToString().c_str()); + } + + int64_t blockValue = nCredit; + int64_t masternodePayment = GetMasternodePayment(pindexPrev->nHeight+1, nReward); + + + // Set output amount + if (!hasPayment && txNew.vout.size() == 3) // 2 stake outputs, stake was split, no masternode payment + { + txNew.vout[1].nValue = (blockValue / 2 / CENT) * CENT; + txNew.vout[2].nValue = blockValue - txNew.vout[1].nValue; + } + else if(hasPayment && txNew.vout.size() == 4) // 2 stake outputs, stake was split, plus a masternode payment + { + txNew.vout[payments-1].nValue = masternodePayment; + blockValue -= masternodePayment; + txNew.vout[1].nValue = (blockValue / 2 / CENT) * CENT; + txNew.vout[2].nValue = blockValue - txNew.vout[1].nValue; + } + else if(!hasPayment && txNew.vout.size() == 2) // only 1 stake output, was not split, no masternode payment + txNew.vout[1].nValue = blockValue; + else if(hasPayment && txNew.vout.size() == 3) // only 1 stake output, was not split, plus a masternode payment + { + txNew.vout[payments-1].nValue = masternodePayment; + blockValue -= masternodePayment; + txNew.vout[1].nValue = blockValue; + } + + // Sign + int nIn = 0; + BOOST_FOREACH(const CWalletTx* pcoin, vwtxPrev) + { + if (!SignSignature(*this, *pcoin, txNew, nIn++)) + return error("CreateCoinStake : failed to sign coinstake"); + } + + // Limit size + unsigned int nBytes = ::GetSerializeSize(txNew, SER_NETWORK, PROTOCOL_VERSION); + if (nBytes >= MAX_BLOCK_SIZE_GEN/5) + return error("CreateCoinStake : exceeded coinstake size limit"); + + // Successfully generated coinstake + return true; +} + + +// Call after CreateTransaction unless you want to abort +bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) +{ + mapValue_t mapNarr; + FindStealthTransactions(wtxNew, mapNarr); + + if (!mapNarr.empty()) + { + BOOST_FOREACH(const PAIRTYPE(string,string)& item, mapNarr) + wtxNew.mapValue[item.first] = item.second; + }; + + { + LOCK2(cs_main, cs_wallet); + LogPrintf("CommitTransaction:\n%s", wtxNew.ToString()); + { + // This is only to keep the database open to defeat the auto-flush for the + // duration of this scope. This is the only place where this optimization + // maybe makes sense; please don't do it anywhere else. + CWalletDB* pwalletdb = fFileBacked ? new CWalletDB(strWalletFile,"r") : NULL; + + // Take key pair from key pool so it won't be used again + reservekey.KeepKey(); + + // Add tx to wallet, because if it has change it's also ours, + // otherwise just for transaction history. + AddToWallet(wtxNew); + + // Mark old coins as spent + set setCoins; + BOOST_FOREACH(const CTxIn& txin, wtxNew.vin) + { + CWalletTx &coin = mapWallet[txin.prevout.hash]; + coin.BindWallet(this); + coin.MarkSpent(txin.prevout.n); + coin.WriteToDisk(); + NotifyTransactionChanged(this, coin.GetHash(), CT_UPDATED); + } + + if (fFileBacked) + delete pwalletdb; + } + + // Track how many getdata requests our transaction gets + mapRequestCount[wtxNew.GetHash()] = 0; + + // Broadcast + if (!wtxNew.AcceptToMemoryPool(true)) + { + // This must not fail. The transaction has already been signed and recorded. + LogPrintf("CommitTransaction() : Error: Transaction not valid\n"); + return false; + } + wtxNew.RelayWalletTransaction(); + } + return true; +} + + + + +string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee) +{ + CReserveKey reservekey(this); + int64_t nFeeRequired; + + if (IsLocked()) + { + string strError = _("Error: Wallet locked, unable to create transaction!"); + LogPrintf("SendMoney() : %s", strError); + return strError; + } + if (fWalletUnlockStakingOnly) + { + string strError = _("Error: Wallet unlocked for staking only, unable to create transaction."); + LogPrintf("SendMoney() : %s", strError); + return strError; + } + if (!CreateTransaction(scriptPubKey, nValue, sNarr, wtxNew, reservekey, nFeeRequired)) + { + string strError; + if (nValue + nFeeRequired > GetBalance()) + strError = strprintf(_("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!"), FormatMoney(nFeeRequired)); + else + strError = _("Error: Transaction creation failed!"); + LogPrintf("SendMoney() : %s\n", strError); + return strError; + } + + if (fAskFee && !uiInterface.ThreadSafeAskFee(nFeeRequired, _("Sending..."))) + return "ABORTED"; + + if (!CommitTransaction(wtxNew, reservekey)) + return _("Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."); + + return ""; +} + + + +string CWallet::SendMoneyToDestination(const CTxDestination& address, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee) +{ + // Check amount + if (nValue <= 0) + return _("Invalid amount"); + if (nValue + nTransactionFee > GetBalance()) + return _("Insufficient funds"); + + if (sNarr.length() > 24) + return _("Narration must be 24 characters or less."); + + // Parse Bitcoin address + CScript scriptPubKey; + scriptPubKey.SetDestination(address); + + return SendMoney(scriptPubKey, nValue, sNarr, wtxNew, fAskFee); +} + + +string CWallet::PrepareluxsendDenominate(int minRounds, int maxRounds) +{ + if (IsLocked()) + return _("Error: Wallet locked, unable to create transaction!"); + + if(darkSendPool.GetState() != POOL_STATUS_ERROR && darkSendPool.GetState() != POOL_STATUS_SUCCESS) + if(darkSendPool.GetMyTransactionCount() > 0) + return _("Error: You already have pending entries in the darksend pool"); + + // ** find the coins we'll use + std::vector vCoins; + std::vector vCoins2; + int64_t nValueIn = 0; + CReserveKey reservekey(this); + + /* + Select the coins we'll use + if minRounds >= 0 it means only denominated inputs are going in and coming out + */ + if(minRounds >= 0){ + if (!SelectCoinsByDenominations(darkSendPool.sessionDenom, 0.1*COIN, DARKSEND_POOL_MAX, vCoins, vCoins2, nValueIn, minRounds, maxRounds)) + return _("Insufficient funds"); + } + + // calculate total value out + int64_t nTotalValue = GetTotalValue(vCoins); + LogPrintf("PrepareluxsendDenominate - preparing darksend denominate . Got: %d \n", nTotalValue); + + //-------------- + BOOST_FOREACH(CTxIn v, vCoins) + LockCoin(v.prevout); + + // denominate our funds + int64_t nValueLeft = nTotalValue; + std::vector vOut; + std::vector vDenoms; + + /* + TODO: Front load with needed denominations (e.g. .1, 1 ) + */ + + /* + Add all denominations once + The beginning of the list is front loaded with each possible + denomination in random order. This means we'll at least get 1 + of each that is required as outputs. + */ + BOOST_FOREACH(int64_t d, darkSendDenominations){ + vDenoms.push_back(d); + vDenoms.push_back(d); + } + + //randomize the order of these denominations + std::random_shuffle (vDenoms.begin(), vDenoms.end()); + + /* + Build a long list of denominations + Next we'll build a long random list of denominations to add. + Eventually as the algorithm goes through these it'll find the ones + it nees to get exact change. + */ + for(int i = 0; i <= 500; i++) + BOOST_FOREACH(int64_t d, darkSendDenominations) + vDenoms.push_back(d); + + //randomize the order of inputs we get back + std::random_shuffle (vDenoms.begin() + (int)darkSendDenominations.size() + 1, vDenoms.end()); + + // Make outputs by looping through denominations randomly + BOOST_REVERSE_FOREACH(int64_t v, vDenoms){ + //only use the ones that are approved + bool fAccepted = false; + if((darkSendPool.sessionDenom & (1 << 0)) && v == ((100000*COIN) +100000000)) {fAccepted = true;} + else if((darkSendPool.sessionDenom & (1 << 1)) && v == ((10000*COIN) +10000000)) {fAccepted = true;} + else if((darkSendPool.sessionDenom & (1 << 2)) && v == ((1000*COIN) +1000000)) {fAccepted = true;} + else if((darkSendPool.sessionDenom & (1 << 3)) && v == ((100*COIN) +100000)) {fAccepted = true;} + else if((darkSendPool.sessionDenom & (1 << 4)) && v == ((10*COIN) +10000)) {fAccepted = true;} + else if((darkSendPool.sessionDenom & (1 << 5)) && v == ((1*COIN) +1000)) {fAccepted = true;} + else if((darkSendPool.sessionDenom & (1 << 6)) && v == ((.1*COIN) +100)) {fAccepted = true;} + if(!fAccepted) continue; + + int nOutputs = 0; + + // add each output up to 10 times until it can't be added again + if(nValueLeft - v >= 0 && nOutputs <= 10) { + CScript scriptChange; + CPubKey vchPubKey; + //use a unique change address + assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked + scriptChange =GetScriptForDestination(vchPubKey.GetID()); + reservekey.KeepKey(); + + CTxOut o(v, scriptChange); + vOut.push_back(o); + + //increment outputs and subtract denomination amount + nOutputs++; + nValueLeft -= v; + } + + if(nValueLeft == 0) break; + } + + //back up mode , incase we couldn't successfully make the outputs for some reason + if(vOut.size() > 40 || darkSendPool.GetDenominations(vOut) != darkSendPool.sessionDenom || nValueLeft != 0){ + vOut.clear(); + nValueLeft = nTotalValue; + + // Make outputs by looping through denominations, from small to large + + BOOST_FOREACH(const COutput& out, vCoins2){ + CScript scriptChange; + CPubKey vchPubKey; + //use a unique change address + assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked + scriptChange =GetScriptForDestination(vchPubKey.GetID()); + reservekey.KeepKey(); + + CTxOut o(out.tx->vout[out.i].nValue, scriptChange); + vOut.push_back(o); + + //increment outputs and subtract denomination amount + nValueLeft -= out.tx->vout[out.i].nValue; + + if(nValueLeft == 0) break; + } + + } + + if(darkSendPool.GetDenominations(vOut) != darkSendPool.sessionDenom) + return "Error: can't make current denominated outputs"; + + // we don't support change at all + if(nValueLeft != 0) + return "Error: change left-over in pool. Must use denominations only"; + + + //randomize the output order + std::random_shuffle (vOut.begin(), vOut.end()); + + darkSendPool.SendluxsendDenominate(vCoins, vOut, nValueIn); + + return ""; +} + +int64_t CWallet::GetTotalValue(std::vector vCoins) { + int64_t nTotalValue = 0; + CWalletTx wtx; + BOOST_FOREACH(CTxIn i, vCoins){ + if (mapWallet.count(i.prevout.hash)) + { + CWalletTx& wtx = mapWallet[i.prevout.hash]; + if(i.prevout.n < wtx.vout.size()){ + nTotalValue += wtx.vout[i.prevout.n].nValue; + } + } else { + LogPrintf("GetTotalValue -- Couldn't find transaction\n"); + } + } + return nTotalValue; +} + + +DBErrors CWallet::LoadWallet(bool& fFirstRunRet) +{ + if (!fFileBacked) + return DB_LOAD_OK; + fFirstRunRet = false; + DBErrors nLoadWalletRet = CWalletDB(strWalletFile,"cr+").LoadWallet(this); + if (nLoadWalletRet == DB_NEED_REWRITE) + { + if (CDB::Rewrite(strWalletFile, "\x04pool")) + { + LOCK(cs_wallet); + setKeyPool.clear(); + // Note: can't top-up keypool here, because wallet is locked. + // User will be prompted to unlock wallet the next operation + // the requires a new key. + } + } + + if (nLoadWalletRet != DB_LOAD_OK) + return nLoadWalletRet; + fFirstRunRet = !vchDefaultKey.IsValid(); + + return DB_LOAD_OK; +} + + +bool CWallet::SetAddressBookName(const CTxDestination& address, const string& strName) +{ + bool fUpdated = false; + { + LOCK(cs_wallet); // mapAddressBook + std::map::iterator mi = mapAddressBook.find(address); + fUpdated = mi != mapAddressBook.end(); + mapAddressBook[address] = strName; + } + NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address), + (fUpdated ? CT_UPDATED : CT_NEW) ); + if (!fFileBacked) + return false; + return CWalletDB(strWalletFile).WriteName(CBitcoinAddress(address).ToString(), strName); +} + +bool CWallet::DelAddressBookName(const CTxDestination& address) +{ + { + LOCK(cs_wallet); // mapAddressBook + + mapAddressBook.erase(address); + } + + NotifyAddressBookChanged(this, address, "", ::IsMine(*this, address), CT_DELETED); + + if (!fFileBacked) + return false; + return CWalletDB(strWalletFile).EraseName(CBitcoinAddress(address).ToString()); +} + +bool CWallet::SetDefaultKey(const CPubKey &vchPubKey) +{ + if (fFileBacked) + { + if (!CWalletDB(strWalletFile).WriteDefaultKey(vchPubKey)) + return false; + } + vchDefaultKey = vchPubKey; + return true; +} + +// +// Mark old keypool keys as used, +// and generate all new keys +// +bool CWallet::NewKeyPool() +{ + { + LOCK(cs_wallet); + CWalletDB walletdb(strWalletFile); + BOOST_FOREACH(int64_t nIndex, setKeyPool) + walletdb.ErasePool(nIndex); + setKeyPool.clear(); + + if (IsLocked()) + return false; + + int64_t nKeys = max(GetArg("-keypool", 100), (int64_t)0); + for (int i = 0; i < nKeys; i++) + { + int64_t nIndex = i+1; + walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey())); + setKeyPool.insert(nIndex); + } + LogPrintf("CWallet::NewKeyPool wrote %d new keys\n", nKeys); + } + return true; +} + +bool CWallet::TopUpKeyPool(unsigned int nSize) +{ + { + LOCK(cs_wallet); + + if (IsLocked()) + return false; + + CWalletDB walletdb(strWalletFile); + + // Top up key pool + unsigned int nTargetSize; + if (nSize > 0) + nTargetSize = nSize; + else + nTargetSize = max(GetArg("-keypool", 100), (int64_t)0); + + while (setKeyPool.size() < (nTargetSize + 1)) + { + int64_t nEnd = 1; + if (!setKeyPool.empty()) + nEnd = *(--setKeyPool.end()) + 1; + if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey()))) + throw runtime_error("TopUpKeyPool() : writing generated key failed"); + setKeyPool.insert(nEnd); + LogPrintf("keypool added key %d, size=%u\n", nEnd, setKeyPool.size()); + } + } + return true; +} + +void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool) +{ + nIndex = -1; + keypool.vchPubKey = CPubKey(); + { + LOCK(cs_wallet); + + if (!IsLocked()) + TopUpKeyPool(); + + // Get the oldest key + if(setKeyPool.empty()) + return; + + CWalletDB walletdb(strWalletFile); + + nIndex = *(setKeyPool.begin()); + setKeyPool.erase(setKeyPool.begin()); + if (!walletdb.ReadPool(nIndex, keypool)) + throw runtime_error("ReserveKeyFromKeyPool() : read failed"); + if (!HaveKey(keypool.vchPubKey.GetID())) + throw runtime_error("ReserveKeyFromKeyPool() : unknown key in key pool"); + assert(keypool.vchPubKey.IsValid()); + LogPrintf("keypool reserve %d\n", nIndex); + } +} + +int64_t CWallet::AddReserveKey(const CKeyPool& keypool) +{ + { + LOCK2(cs_main, cs_wallet); + CWalletDB walletdb(strWalletFile); + + int64_t nIndex = 1 + *(--setKeyPool.end()); + if (!walletdb.WritePool(nIndex, keypool)) + throw runtime_error("AddReserveKey() : writing added key failed"); + setKeyPool.insert(nIndex); + return nIndex; + } + return -1; +} + +void CWallet::KeepKey(int64_t nIndex) +{ + // Remove from key pool + if (fFileBacked) + { + CWalletDB walletdb(strWalletFile); + walletdb.ErasePool(nIndex); + } + LogPrintf("keypool keep %d\n", nIndex); +} + +void CWallet::ReturnKey(int64_t nIndex) +{ + // Return to key pool + { + LOCK(cs_wallet); + setKeyPool.insert(nIndex); + } + LogPrintf("keypool return %d\n", nIndex); +} + +bool CWallet::GetKeyFromPool(CPubKey& result) +{ + int64_t nIndex = 0; + CKeyPool keypool; + { + LOCK(cs_wallet); + ReserveKeyFromKeyPool(nIndex, keypool); + if (nIndex == -1) + { + if (IsLocked()) return false; + result = GenerateNewKey(); + return true; + } + KeepKey(nIndex); + result = keypool.vchPubKey; + } + return true; +} + +int64_t CWallet::GetOldestKeyPoolTime() +{ + int64_t nIndex = 0; + CKeyPool keypool; + ReserveKeyFromKeyPool(nIndex, keypool); + if (nIndex == -1) + return GetTime(); + ReturnKey(nIndex); + return keypool.nTime; +} + +std::map CWallet::GetAddressBalances() +{ + map balances; + + { + LOCK(cs_wallet); + BOOST_FOREACH(PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet) + { + CWalletTx *pcoin = &walletEntry.second; + + if (!IsFinalTx(*pcoin) || !pcoin->IsTrusted()) + continue; + + if ((pcoin->IsCoinBase() || pcoin->IsCoinStake()) && pcoin->GetBlocksToMaturity() > 0) + continue; + + int nDepth = pcoin->GetDepthInMainChain(); + if (nDepth < (pcoin->IsFromMe() ? 0 : 1)) + continue; + + for (unsigned int i = 0; i < pcoin->vout.size(); i++) + { + CTxDestination addr; + if (!IsMine(pcoin->vout[i])) + continue; + if(!ExtractDestination(pcoin->vout[i].scriptPubKey, addr)) + continue; + + int64_t n = pcoin->IsSpent(i) ? 0 : pcoin->vout[i].nValue; + + if (!balances.count(addr)) + balances[addr] = 0; + balances[addr] += n; + } + } + } + + return balances; +} + +set< set > CWallet::GetAddressGroupings() +{ + AssertLockHeld(cs_wallet); // mapWallet + set< set > groupings; + set grouping; + + BOOST_FOREACH(PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet) + { + CWalletTx *pcoin = &walletEntry.second; + + if (pcoin->vin.size() > 0 && IsMine(pcoin->vin[0])) + { + // group all input addresses with each other + BOOST_FOREACH(CTxIn txin, pcoin->vin) + { + CTxDestination address; + if(!ExtractDestination(mapWallet[txin.prevout.hash].vout[txin.prevout.n].scriptPubKey, address)) + continue; + grouping.insert(address); + } + + // group change with input addresses + BOOST_FOREACH(CTxOut txout, pcoin->vout) + if (IsChange(txout)) + { + CWalletTx tx = mapWallet[pcoin->vin[0].prevout.hash]; + CTxDestination txoutAddr; + if(!ExtractDestination(txout.scriptPubKey, txoutAddr)) + continue; + grouping.insert(txoutAddr); + } + groupings.insert(grouping); + grouping.clear(); + } + + // group lone addrs by themselves + for (unsigned int i = 0; i < pcoin->vout.size(); i++) + if (IsMine(pcoin->vout[i])) + { + CTxDestination address; + if(!ExtractDestination(pcoin->vout[i].scriptPubKey, address)) + continue; + grouping.insert(address); + groupings.insert(grouping); + grouping.clear(); + } + } + + set< set* > uniqueGroupings; // a set of pointers to groups of addresses + map< CTxDestination, set* > setmap; // map addresses to the unique group containing it + BOOST_FOREACH(set grouping, groupings) + { + // make a set of all the groups hit by this new group + set< set* > hits; + map< CTxDestination, set* >::iterator it; + BOOST_FOREACH(CTxDestination address, grouping) + if ((it = setmap.find(address)) != setmap.end()) + hits.insert((*it).second); + + // merge all hit groups into a new single group and delete old groups + set* merged = new set(grouping); + BOOST_FOREACH(set* hit, hits) + { + merged->insert(hit->begin(), hit->end()); + uniqueGroupings.erase(hit); + delete hit; + } + uniqueGroupings.insert(merged); + + // update setmap + BOOST_FOREACH(CTxDestination element, *merged) + setmap[element] = merged; + } + + set< set > ret; + BOOST_FOREACH(set* uniqueGrouping, uniqueGroupings) + { + ret.insert(*uniqueGrouping); + delete uniqueGrouping; + } + + return ret; +} + +// ppcoin: check 'spent' consistency between wallet and txindex +// ppcoin: fix wallet spent state according to txindex +void CWallet::FixSpentCoins(int& nMismatchFound, int64_t& nBalanceInQuestion, bool fCheckOnly) +{ + nMismatchFound = 0; + nBalanceInQuestion = 0; + + LOCK(cs_wallet); + vector vCoins; + vCoins.reserve(mapWallet.size()); + for (map::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + vCoins.push_back(&(*it).second); + + CTxDB txdb("r"); + BOOST_FOREACH(CWalletTx* pcoin, vCoins) + { + // Find the corresponding transaction index + CTxIndex txindex; + if (!txdb.ReadTxIndex(pcoin->GetHash(), txindex)) + continue; + for (unsigned int n=0; n < pcoin->vout.size(); n++) + { + if (IsMine(pcoin->vout[n]) && pcoin->IsSpent(n) && (txindex.vSpent.size() <= n || txindex.vSpent[n].IsNull())) + { + LogPrintf("FixSpentCoins found lost coin %s BC %s[%d], %s\n", + FormatMoney(pcoin->vout[n].nValue), pcoin->GetHash().ToString(), n, fCheckOnly? "repair not attempted" : "repairing"); + nMismatchFound++; + nBalanceInQuestion += pcoin->vout[n].nValue; + if (!fCheckOnly) + { + pcoin->MarkUnspent(n); + pcoin->WriteToDisk(); + } + } + else if (IsMine(pcoin->vout[n]) && !pcoin->IsSpent(n) && (txindex.vSpent.size() > n && !txindex.vSpent[n].IsNull())) + { + LogPrintf("FixSpentCoins found spent coin %s BC %s[%d], %s\n", + FormatMoney(pcoin->vout[n].nValue), pcoin->GetHash().ToString(), n, fCheckOnly? "repair not attempted" : "repairing"); + nMismatchFound++; + nBalanceInQuestion += pcoin->vout[n].nValue; + if (!fCheckOnly) + { + pcoin->MarkSpent(n); + pcoin->WriteToDisk(); + } + } + } + } +} + +// ppcoin: disable transaction (only for coinstake) +void CWallet::DisableTransaction(const CTransaction &tx) +{ + if (!tx.IsCoinStake() || !IsFromMe(tx)) + return; // only disconnecting coinstake requires marking input unspent + + LOCK(cs_wallet); + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + map::iterator mi = mapWallet.find(txin.prevout.hash); + if (mi != mapWallet.end()) + { + CWalletTx& prev = (*mi).second; + if (txin.prevout.n < prev.vout.size() && IsMine(prev.vout[txin.prevout.n])) + { + prev.MarkUnspent(txin.prevout.n); + prev.WriteToDisk(); + } + } + } +} + +bool CReserveKey::GetReservedKey(CPubKey& pubkey) +{ + if (nIndex == -1) + { + CKeyPool keypool; + pwallet->ReserveKeyFromKeyPool(nIndex, keypool); + if (nIndex != -1) + vchPubKey = keypool.vchPubKey; + else { + if (pwallet->vchDefaultKey.IsValid()) { + LogPrintf("CReserveKey::GetReservedKey(): Warning: Using default key instead of a new key, top up your keypool!"); + vchPubKey = pwallet->vchDefaultKey; + } else + return false; + } + } + assert(vchPubKey.IsValid()); + pubkey = vchPubKey; + return true; +} + +void CReserveKey::KeepKey() +{ + if (nIndex != -1) + pwallet->KeepKey(nIndex); + nIndex = -1; + vchPubKey = CPubKey(); +} + +void CReserveKey::ReturnKey() +{ + if (nIndex != -1) + pwallet->ReturnKey(nIndex); + nIndex = -1; + vchPubKey = CPubKey(); +} + +void CWallet::GetAllReserveKeys(set& setAddress) const +{ + setAddress.clear(); + + CWalletDB walletdb(strWalletFile); + + LOCK2(cs_main, cs_wallet); + BOOST_FOREACH(const int64_t& id, setKeyPool) + { + CKeyPool keypool; + if (!walletdb.ReadPool(id, keypool)) + throw runtime_error("GetAllReserveKeyHashes() : read failed"); + assert(keypool.vchPubKey.IsValid()); + CKeyID keyID = keypool.vchPubKey.GetID(); + if (!HaveKey(keyID)) + throw runtime_error("GetAllReserveKeyHashes() : unknown key in key pool"); + setAddress.insert(keyID); + } +} + +void CWallet::UpdatedTransaction(const uint256 &hashTx) +{ + { + LOCK(cs_wallet); + // Only notify UI if this transaction is in this wallet + map::const_iterator mi = mapWallet.find(hashTx); + if (mi != mapWallet.end()) + NotifyTransactionChanged(this, hashTx, CT_UPDATED); + } +} + + +void CWallet::LockCoin(COutPoint& output) +{ + AssertLockHeld(cs_wallet); // setLockedCoins + setLockedCoins.insert(output); +} + +void CWallet::UnlockCoin(COutPoint& output) +{ + AssertLockHeld(cs_wallet); // setLockedCoins + setLockedCoins.erase(output); +} + +void CWallet::UnlockAllCoins() +{ + AssertLockHeld(cs_wallet); // setLockedCoins + setLockedCoins.clear(); +} + +bool CWallet::IsLockedCoin(uint256 hash, unsigned int n) const +{ + AssertLockHeld(cs_wallet); // setLockedCoins + COutPoint outpt(hash, n); + + return (setLockedCoins.count(outpt) > 0); +} + +void CWallet::ListLockedCoins(std::vector& vOutpts) +{ + AssertLockHeld(cs_wallet); // setLockedCoins + for (std::set::iterator it = setLockedCoins.begin(); + it != setLockedCoins.end(); it++) { + COutPoint outpt = (*it); + vOutpts.push_back(outpt); + } +} + + +void CWallet::GetKeyBirthTimes(std::map &mapKeyBirth) const { + AssertLockHeld(cs_wallet); // mapKeyMetadata + mapKeyBirth.clear(); + + // get birth times for keys with metadata + for (std::map::const_iterator it = mapKeyMetadata.begin(); it != mapKeyMetadata.end(); it++) + if (it->second.nCreateTime) + mapKeyBirth[it->first] = it->second.nCreateTime; + + // map in which we'll infer heights of other keys + CBlockIndex *pindexMax = FindBlockByHeight(std::max(0, nBestHeight - 144)); // the tip can be reorganised; use a 144-block safety margin + std::map mapKeyFirstBlock; + std::set setKeys; + GetKeys(setKeys); + BOOST_FOREACH(const CKeyID &keyid, setKeys) { + if (mapKeyBirth.count(keyid) == 0) + mapKeyFirstBlock[keyid] = pindexMax; + } + setKeys.clear(); + + // if there are no such keys, we're done + if (mapKeyFirstBlock.empty()) + return; + + // find first block that affects those keys, if there are any left + std::vector vAffected; + for (std::map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); it++) { + // iterate over all wallet transactions... + const CWalletTx &wtx = (*it).second; + std::map::const_iterator blit = mapBlockIndex.find(wtx.hashBlock); + if (blit != mapBlockIndex.end() && blit->second->IsInMainChain()) { + // ... which are already in a block + int nHeight = blit->second->nHeight; + BOOST_FOREACH(const CTxOut &txout, wtx.vout) { + // iterate over all their outputs + ::ExtractAffectedKeys(*this, txout.scriptPubKey, vAffected); + BOOST_FOREACH(const CKeyID &keyid, vAffected) { + // ... and all their affected keys + std::map::iterator rit = mapKeyFirstBlock.find(keyid); + if (rit != mapKeyFirstBlock.end() && nHeight < rit->second->nHeight) + rit->second = blit->second; + } + vAffected.clear(); + } + } + } + + // Extract block timestamps for those keys + for (std::map::const_iterator it = mapKeyFirstBlock.begin(); it != mapKeyFirstBlock.end(); it++) + mapKeyBirth[it->first] = it->second->nTime - 7200; // block times can be 2h off +} + +bool CWallet::GetTransaction(const uint256 &hashTx, CWalletTx& wtx) +{ + { + LOCK(cs_wallet); + map::iterator mi = mapWallet.find(hashTx); + if (mi != mapWallet.end()) + { + wtx = (*mi).second; + return true; + } + } + return false; +} + +int CMerkleTx::GetTransactionLockSignatures() const +{ + if(!IsSporkActive(SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT)) return -3; + if(nInstantXDepth == 0) return -1; + + //compile consessus vote + std::map::iterator i = mapTxLocks.find(GetHash()); + if (i != mapTxLocks.end()){ + return (*i).second.CountSignatures(); + } + + return -1; +} + +bool CMerkleTx::IsTransactionLockTimedOut() const +{ + if(nInstantXDepth == 0) return 0; + + //compile consessus vote + std::map::iterator i = mapTxLocks.find(GetHash()); + if (i != mapTxLocks.end()){ + return GetTime() > (*i).second.nTimeout; + } + + return false; +} + +bool CWallet::AddAdrenalineNodeConfig(CAdrenalineNodeConfig nodeConfig) +{ + bool rv = CWalletDB(strWalletFile).WriteAdrenalineNodeConfig(nodeConfig.sAlias, nodeConfig); + if(rv) + uiInterface.NotifyAdrenalineNodeChanged(nodeConfig); + + return rv; +} diff --git a/src/wallet.h b/src/wallet.h new file mode 100644 index 0000000..d41269b --- /dev/null +++ b/src/wallet.h @@ -0,0 +1,1014 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_WALLET_H +#define BITCOIN_WALLET_H + +#include "walletdb.h" + +#include +#include + +#include + +#include "crypter.h" +#include "main.h" +#include "key.h" +#include "keystore.h" +#include "script.h" +#include "ui_interface.h" +#include "util.h" +#include "stealth.h" + +// Settings +extern int64_t nTransactionFee; +extern int64_t nReserveBalance; +extern int64_t nMinimumInputValue; +extern bool fWalletUnlockStakingOnly; +extern bool fConfChange; + +class CAccountingEntry; +class CCoinControl; +class CWalletTx; +class CReserveKey; +class COutput; +class CWalletDB; + +typedef std::map StealthKeyMetaMap; +typedef std::map mapValue_t; + +/** (client) version numbers for particular wallet features */ +enum WalletFeature +{ + FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getinfo's clientversion output) + + FEATURE_WALLETCRYPT = 40000, // wallet encryption input < comprepubkey to avoid exploit + FEATURE_COMPRPUBKEY = 60000, // compressed public keys + + FEATURE_LATEST = 60000 +}; + +enum AvailableCoinsType +{ + ALL_COINS = 1, + ONLY_DENOMINATED = 2, + ONLY_NONDENOMINATED = 3, + ONLY_NONDENOMINATED_NOTMN = 4 // ONLY_NONDENOMINATED and not 1000 SONO at the same time +}; + +/** IsMine() return codes */ +enum isminetype +{ + ISMINE_NO = 0, + ISMINE_WATCH_ONLY = 1, + ISMINE_SPENDABLE = 2, + ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE +}; + + +/** A key pool entry */ +class CKeyPool +{ +public: + int64_t nTime; + CPubKey vchPubKey; + + CKeyPool() + { + nTime = GetTime(); + } + + CKeyPool(const CPubKey& vchPubKeyIn) + { + nTime = GetTime(); + vchPubKey = vchPubKeyIn; + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(nTime); + READWRITE(vchPubKey); + ) +}; + +/** A CWallet is an extension of a keystore, which also maintains a set of transactions and balances, + * and provides the ability to create new transactions. + */ +class CWallet : public CCryptoKeyStore, public CWalletInterface +{ +private: + bool SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet) const; + //bool SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl=NULL) const; + bool SelectCoins(CAmount nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + CWalletDB *pwalletdbEncryption; + + // the current wallet version: clients below this version are not able to load the wallet + int nWalletVersion; + + // the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded + int nWalletMaxVersion; + +public: + /// Main wallet lock. + /// This lock protects all the fields added by CWallet + /// except for: + /// fFileBacked (immutable after instantiation) + /// strWalletFile (immutable after instantiation) + mutable CCriticalSection cs_wallet; + + bool SelectCoinsDark(int64_t nValueMin, int64_t nValueMax, std::vector& setCoinsRet, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax) const; + bool SelectCoinsByDenominations(int nDenom, int64_t nValueMin, int64_t nValueMax, std::vector& setCoinsRet, vector& vCoins, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax); + bool SelectCoinsDarkDenominated(int64_t nTargetValue, std::vector& setCoinsRet, int64_t& nValueRet) const; + bool SelectCoinsMasternode(CTxIn& vin, int64_t& nValueRet, CScript& pubScript) const; + bool HasCollateralInputs() const; + bool IsCollateralAmount(int64_t nInputAmount) const; + int CountInputsWithAmount(int64_t nInputAmount); + + bool SelectCoinsCollateral(std::vector& setCoinsRet, int64_t& nValueRet) const ; + bool SelectCoinsWithoutDenomination(int64_t nTargetValue, std::set >& setCoinsRet, int64_t& nValueRet) const; + bool GetTransaction(const uint256 &hashTx, CWalletTx& wtx); + + bool fFileBacked; + bool fWalletUnlockAnonymizeOnly; + std::string strWalletFile; + + std::set setKeyPool; + std::map mapKeyMetadata; + + std::set stealthAddresses; + StealthKeyMetaMap mapStealthKeyMeta; + + int nLastFilteredHeight; + + uint32_t nStealth, nFoundStealth; // for reporting, zero before use + + + typedef std::map MasterKeyMap; + MasterKeyMap mapMasterKeys; + unsigned int nMasterKeyMaxID; + + std::map mapMyAdrenalineNodes; + bool AddAdrenalineNodeConfig(CAdrenalineNodeConfig nodeConfig); + + CWallet() + { + SetNull(); + } + CWallet(std::string strWalletFileIn) + { + SetNull(); + + strWalletFile = strWalletFileIn; + fFileBacked = true; + } + + void SetNull() + { + nWalletVersion = FEATURE_BASE; + nWalletMaxVersion = FEATURE_BASE; + fFileBacked = false; + nMasterKeyMaxID = 0; + pwalletdbEncryption = NULL; + nOrderPosNext = 0; + nTimeFirstKey = 0; + nLastFilteredHeight = 0; + fWalletUnlockAnonymizeOnly = false; + } + + std::map mapWallet; + int64_t nOrderPosNext; + std::map mapRequestCount; + + std::map mapAddressBook; + + CPubKey vchDefaultKey; + + std::set setLockedCoins; + + int64_t nTimeFirstKey; + + // check whether we are allowed to upgrade (or already support) to the named feature + bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; } + + void AvailableCoinsForStaking(std::vector& vCoins, unsigned int nSpendTime) const; + void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + void AvailableCoinsMN(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + bool SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; + bool SelectCoinsMinConfByCoinAge(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; + + bool IsSpent(const uint256& hash, unsigned int n) const; + + bool IsLockedCoin(uint256 hash, unsigned int n) const; + void LockCoin(COutPoint& output); + void UnlockCoin(COutPoint& output); + void UnlockAllCoins(); + void ListLockedCoins(std::vector& vOutpts); + CAmount GetTotalValue(std::vector vCoins); + + // keystore implementation + // Generate a new key + CPubKey GenerateNewKey(); + // Adds a key to the store, and saves it to disk. + bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey); + // Adds a key to the store, without saving it to disk (used by LoadWallet) + bool LoadKey(const CKey& key, const CPubKey &pubkey) { return CCryptoKeyStore::AddKeyPubKey(key, pubkey); } + // Load metadata (used by LoadWallet) + bool LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &metadata); + + bool LoadMinVersion(int nVersion) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; } + + // Adds an encrypted key to the store, and saves it to disk. + bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret); + // Adds an encrypted key to the store, without saving it to disk (used by LoadWallet) + bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret); + bool AddCScript(const CScript& redeemScript); + bool LoadCScript(const CScript& redeemScript); + + bool Lock(); + bool Unlock(const SecureString& strWalletPassphrase, bool anonimizeOnly = false); + bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase); + bool EncryptWallet(const SecureString& strWalletPassphrase); + + void GetKeyBirthTimes(std::map &mapKeyBirth) const; + + + /** Increment the next transaction order id + @return next transaction order id + */ + int64_t IncOrderPosNext(CWalletDB *pwalletdb = NULL); + + typedef std::pair TxPair; + typedef std::multimap TxItems; + + /** Get the wallet's activity log + @return multimap of ordered transactions and accounting entries + @warning Returned pointers are *only* valid within the scope of passed acentries + */ + TxItems OrderedTxItems(std::list& acentries, std::string strAccount = ""); + + void MarkDirty(); + bool AddToWallet(const CWalletTx& wtxIn); + void SyncTransaction(const CTransaction& tx, const CBlock* pblock, bool fConnect = true); + bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate); + void EraseFromWallet(const uint256 &hash); + void WalletUpdateSpent(const CTransaction& prevout, bool fBlock = false); + int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false); + void ReacceptWalletTransactions(); + void ResendWalletTransactions(bool fForce = false); + int64_t GetBalance() const; + int64_t GetBalanceNoLocks() const; + int64_t GetUnconfirmedBalance() const; + int64_t GetImmatureBalance() const; + int64_t GetStake() const; + int64_t GetNewMint() const; + + CAmount GetAnonymizedBalance() const; + double GetAverageAnonymizedRounds() const; + CAmount GetNormalizedAnonymizedBalance() const; + CAmount GetDenominatedBalance(bool onlyDenom=true, bool onlyUnconfirmed=false) const; + + bool CreateTransaction(const std::vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, int32_t& nChangePos, std::string& strFailReason, const CCoinControl *coinControl=NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX=false); + bool CreateTransaction(CScript scriptPubKey, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl *coinControl=NULL); + bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); + + uint64_t GetStakeWeight() const; + bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, int64_t nFees, CTransaction& txNew, CKey& key); + + std::string SendMoney(CScript scriptPubKey, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + + bool NewStealthAddress(std::string& sError, std::string& sLabel, CStealthAddress& sxAddr); + bool AddStealthAddress(CStealthAddress& sxAddr); + bool UnlockStealthAddresses(const CKeyingMaterial& vMasterKeyIn); + bool UpdateStealthAddress(std::string &addr, std::string &label, bool addIfNotExist); + + bool CreateStealthTransaction(CScript scriptPubKey, int64_t nValue, std::vector& P, std::vector& narr, std::string& sNarr, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl=NULL); + std::string SendStealthMoney(CScript scriptPubKey, int64_t nValue, std::vector& P, std::vector& narr, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + bool SendStealthMoneyToDestination(CStealthAddress& sxAddress, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, std::string& sError, bool fAskFee=false); + bool FindStealthTransactions(const CTransaction& tx, mapValue_t& mapNarr); + + std::string PrepareluxsendDenominate(int minRounds, int maxRounds); + bool CreateCollateralTransaction(CTransaction& txCollateral, std::string strReason); + bool ConvertList(std::vector vCoins, std::vector& vecAmounts); + + bool NewKeyPool(); + bool TopUpKeyPool(unsigned int nSize = 0); + int64_t AddReserveKey(const CKeyPool& keypool); + void ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool); + void KeepKey(int64_t nIndex); + void ReturnKey(int64_t nIndex); + bool GetKeyFromPool(CPubKey &key); + int64_t GetOldestKeyPoolTime(); + void GetAllReserveKeys(std::set& setAddress) const; + + std::set< std::set > GetAddressGroupings(); + std::map GetAddressBalances(); + + + bool IsDenominated(const CTxIn &txin) const; + + bool IsDenominated(const CTransaction& tx) const + { + /* + Return false if ANY inputs are non-denom + */ + bool ret = true; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + if(!IsDenominated(txin)) { + ret = false; + } + } + return ret; + } + + bool IsDenominatedAmount(int64_t nInputAmount) const; + + + bool IsMine(const CTxIn& txin) const; + int64_t GetDebit(const CTxIn& txin) const; + bool IsMine(const CTxOut& txout) const + { + return ::IsMine(*this, txout.scriptPubKey); + } + int64_t GetCredit(const CTxOut& txout) const + { + if (!MoneyRange(txout.nValue)) + throw std::runtime_error("CWallet::GetCredit() : value out of range"); + return (IsMine(txout) ? txout.nValue : 0); + } + bool IsChange(const CTxOut& txout) const; + int64_t GetChange(const CTxOut& txout) const + { + if (!MoneyRange(txout.nValue)) + throw std::runtime_error("CWallet::GetChange() : value out of range"); + return (IsChange(txout) ? txout.nValue : 0); + } + bool IsMine(const CTransaction& tx) const + { + BOOST_FOREACH(const CTxOut& txout, tx.vout) + if (IsMine(txout) && txout.nValue >= nMinimumInputValue) + return true; + return false; + } + bool IsFromMe(const CTransaction& tx) const + { + return (GetDebit(tx) > 0); + } + int64_t GetDebit(const CTransaction& tx) const + { + int64_t nDebit = 0; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + nDebit += GetDebit(txin); + if (!MoneyRange(nDebit)) + throw std::runtime_error("CWallet::GetDebit() : value out of range"); + } + return nDebit; + } + int64_t GetCredit(const CTransaction& tx) const + { + int64_t nCredit = 0; + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + nCredit += GetCredit(txout); + if (!MoneyRange(nCredit)) + throw std::runtime_error("CWallet::GetCredit() : value out of range"); + } + return nCredit; + } + int64_t GetChange(const CTransaction& tx) const + { + int64_t nChange = 0; + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + nChange += GetChange(txout); + if (!MoneyRange(nChange)) + throw std::runtime_error("CWallet::GetChange() : value out of range"); + } + return nChange; + } + void SetBestChain(const CBlockLocator& loc); + + DBErrors LoadWallet(bool& fFirstRunRet); + + bool SetAddressBookName(const CTxDestination& address, const std::string& strName); + + bool DelAddressBookName(const CTxDestination& address); + + void UpdatedTransaction(const uint256 &hashTx); + + void Inventory(const uint256 &hash) + { + { + LOCK(cs_wallet); + std::map::iterator mi = mapRequestCount.find(hash); + if (mi != mapRequestCount.end()) + (*mi).second++; + } + } + + unsigned int GetKeyPoolSize() + { + AssertLockHeld(cs_wallet); // setKeyPool + return setKeyPool.size(); + } + + bool SetDefaultKey(const CPubKey &vchPubKey); + + // signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVersion if those are lower + bool SetMinVersion(enum WalletFeature, CWalletDB* pwalletdbIn = NULL, bool fExplicit = false); + + // change which version we're allowed to upgrade to (note that this does not immediately imply upgrading to that format) + bool SetMaxVersion(int nVersion); + + // get the current wallet format (the oldest client version guaranteed to understand this wallet) + int GetVersion() { LOCK(cs_wallet); return nWalletVersion; } + + void FixSpentCoins(int& nMismatchSpent, int64_t& nBalanceInQuestion, bool fCheckOnly = false); + void DisableTransaction(const CTransaction &tx); + + /** Address book entry changed. + * @note called with lock cs_wallet held. + */ + boost::signals2::signal NotifyAddressBookChanged; + + /** Wallet transaction added, removed or updated. + * @note called with lock cs_wallet held. + */ + boost::signals2::signal NotifyTransactionChanged; +}; + +/** A key allocated from the key pool. */ +class CReserveKey +{ +protected: + CWallet* pwallet; + int64_t nIndex; + CPubKey vchPubKey; +public: + CReserveKey(CWallet* pwalletIn) + { + nIndex = -1; + pwallet = pwalletIn; + } + + ~CReserveKey() + { + ReturnKey(); + } + + void ReturnKey(); + bool GetReservedKey(CPubKey &pubkey); + void KeepKey(); +}; + + +typedef std::map mapValue_t; + + +static void ReadOrderPos(int64_t& nOrderPos, mapValue_t& mapValue) +{ + if (!mapValue.count("n")) + { + nOrderPos = -1; // TODO: calculate elsewhere + return; + } + nOrderPos = atoi64(mapValue["n"].c_str()); +} + + +static void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue) +{ + if (nOrderPos == -1) + return; + mapValue["n"] = i64tostr(nOrderPos); +} + + +/** A transaction with a bunch of additional info that only the owner cares about. + * It includes any unrecorded transactions needed to link it back to the block chain. + */ +class CWalletTx : public CMerkleTx +{ +private: + const CWallet* pwallet; + +public: + std::vector vtxPrev; + mapValue_t mapValue; + std::vector > vOrderForm; + unsigned int fTimeReceivedIsTxTime; + unsigned int nTimeReceived; // time received by this node + unsigned int nTimeSmart; + char fFromMe; + std::string strFromAccount; + std::vector vfSpent; // which outputs are already spent + int64_t nOrderPos; // position in ordered transaction list + + // memory only + mutable bool fDebitCached; + mutable bool fCreditCached; + mutable bool fAvailableCreditCached; + mutable bool fChangeCached; + mutable int64_t nDebitCached; + mutable int64_t nCreditCached; + mutable int64_t nAvailableCreditCached; + mutable int64_t nChangeCached; + + CWalletTx() + { + Init(NULL); + } + + CWalletTx(const CWallet* pwalletIn) + { + Init(pwalletIn); + } + + CWalletTx(const CWallet* pwalletIn, const CMerkleTx& txIn) : CMerkleTx(txIn) + { + Init(pwalletIn); + } + + CWalletTx(const CWallet* pwalletIn, const CTransaction& txIn) : CMerkleTx(txIn) + { + Init(pwalletIn); + } + + void Init(const CWallet* pwalletIn) + { + pwallet = pwalletIn; + vtxPrev.clear(); + mapValue.clear(); + vOrderForm.clear(); + fTimeReceivedIsTxTime = false; + nTimeReceived = 0; + nTimeSmart = 0; + fFromMe = false; + strFromAccount.clear(); + vfSpent.clear(); + fDebitCached = false; + fCreditCached = false; + fAvailableCreditCached = false; + fChangeCached = false; + nDebitCached = 0; + nCreditCached = 0; + nAvailableCreditCached = 0; + nChangeCached = 0; + nOrderPos = -1; + } + + IMPLEMENT_SERIALIZE + ( + CWalletTx* pthis = const_cast(this); + if (fRead) + pthis->Init(NULL); + char fSpent = false; + + if (!fRead) + { + pthis->mapValue["fromaccount"] = pthis->strFromAccount; + + std::string str; + BOOST_FOREACH(char f, vfSpent) + { + str += (f ? '1' : '0'); + if (f) + fSpent = true; + } + pthis->mapValue["spent"] = str; + + WriteOrderPos(pthis->nOrderPos, pthis->mapValue); + + if (nTimeSmart) + pthis->mapValue["timesmart"] = strprintf("%u", nTimeSmart); + } + + nSerSize += SerReadWrite(s, *(CMerkleTx*)this, nType, nVersion,ser_action); + READWRITE(vtxPrev); + READWRITE(mapValue); + READWRITE(vOrderForm); + READWRITE(fTimeReceivedIsTxTime); + READWRITE(nTimeReceived); + READWRITE(fFromMe); + READWRITE(fSpent); + + if (fRead) + { + pthis->strFromAccount = pthis->mapValue["fromaccount"]; + + if (mapValue.count("spent")) + BOOST_FOREACH(char c, pthis->mapValue["spent"]) + pthis->vfSpent.push_back(c != '0'); + else + pthis->vfSpent.assign(vout.size(), fSpent); + + ReadOrderPos(pthis->nOrderPos, pthis->mapValue); + + pthis->nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(pthis->mapValue["timesmart"]) : 0; + } + + pthis->mapValue.erase("fromaccount"); + pthis->mapValue.erase("version"); + pthis->mapValue.erase("spent"); + pthis->mapValue.erase("n"); + pthis->mapValue.erase("timesmart"); + ) + + // marks certain txout's as spent + // returns true if any update took place + bool UpdateSpent(const std::vector& vfNewSpent) + { + bool fReturn = false; + for (unsigned int i = 0; i < vfNewSpent.size(); i++) + { + if (i == vfSpent.size()) + break; + + if (vfNewSpent[i] && !vfSpent[i]) + { + vfSpent[i] = true; + fReturn = true; + fAvailableCreditCached = false; + } + } + return fReturn; + } + + // make sure balances are recalculated + void MarkDirty() + { + fCreditCached = false; + fAvailableCreditCached = false; + fDebitCached = false; + fChangeCached = false; + } + + void BindWallet(CWallet *pwalletIn) + { + pwallet = pwalletIn; + MarkDirty(); + } + + void MarkSpent(unsigned int nOut) + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::MarkSpent() : nOut out of range"); + vfSpent.resize(vout.size()); + if (!vfSpent[nOut]) + { + vfSpent[nOut] = true; + fAvailableCreditCached = false; + } + } + + void MarkUnspent(unsigned int nOut) + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::MarkUnspent() : nOut out of range"); + vfSpent.resize(vout.size()); + if (vfSpent[nOut]) + { + vfSpent[nOut] = false; + fAvailableCreditCached = false; + } + } + + bool IsSpent(unsigned int nOut) const + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::IsSpent() : nOut out of range"); + if (nOut >= vfSpent.size()) + return false; + return (!!vfSpent[nOut]); + } + + int64_t IsDenominated() const + { + if (vin.empty()) + return 0; + return pwallet->IsDenominated(*this); + } + + int64_t GetDebit() const + { + if (vin.empty()) + return 0; + if (fDebitCached) + return nDebitCached; + nDebitCached = pwallet->GetDebit(*this); + fDebitCached = true; + return nDebitCached; + } + + int64_t GetCredit(bool fUseCache=true) const + { + // Must wait until coinbase is safely deep enough in the chain before valuing it + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) + return 0; + + // GetBalance can assume transactions in mapWallet won't change + if (fUseCache && fCreditCached) + return nCreditCached; + nCreditCached = pwallet->GetCredit(*this); + fCreditCached = true; + return nCreditCached; + } + + int64_t GetAvailableCredit(bool fUseCache=true) const + { + // Must wait until coinbase is safely deep enough in the chain before valuing it + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) + return 0; + + if (fUseCache && fAvailableCreditCached) + return nAvailableCreditCached; + + int64_t nCredit = 0; + for (unsigned int i = 0; i < vout.size(); i++) + { + if (!IsSpent(i)) + { + const CTxOut &txout = vout[i]; + nCredit += pwallet->GetCredit(txout); + if (!MoneyRange(nCredit)) + throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range"); + } + } + + nAvailableCreditCached = nCredit; + fAvailableCreditCached = true; + return nCredit; + } + + + int64_t GetChange() const + { + if (fChangeCached) + return nChangeCached; + nChangeCached = pwallet->GetChange(*this); + fChangeCached = true; + return nChangeCached; + } + + void GetAmounts(std::list >& listReceived, + std::list >& listSent, int64_t& nFee, std::string& strSentAccount) const; + + void GetAccountAmounts(const std::string& strAccount, int64_t& nReceived, + int64_t& nSent, int64_t& nFee) const; + + bool IsFromMe() const + { + return (GetDebit() > 0); + } + + bool IsTrusted() const + { + // Quick answer in most cases + if (!IsFinalTx(*this)) + return false; + int nDepth = GetDepthInMainChain(); + if (nDepth >= 1) + return true; + if (nDepth < 0) + return false; + if (fConfChange || !IsFromMe()) // using wtx's cached debit + return false; + + // If no confirmations but it's from us, we can still + // consider it confirmed if all dependencies are confirmed + std::map mapPrev; + std::vector vWorkQueue; + vWorkQueue.reserve(vtxPrev.size()+1); + vWorkQueue.push_back(this); + for (unsigned int i = 0; i < vWorkQueue.size(); i++) + { + const CMerkleTx* ptx = vWorkQueue[i]; + + if (!IsFinalTx(*ptx)) + return false; + int nPDepth = ptx->GetDepthInMainChain(); + if (nPDepth >= 1) + continue; + if (nPDepth < 0) + return false; + if (!pwallet->IsFromMe(*ptx)) + return false; + + if (mapPrev.empty()) + { + BOOST_FOREACH(const CMerkleTx& tx, vtxPrev) + mapPrev[tx.GetHash()] = &tx; + } + + BOOST_FOREACH(const CTxIn& txin, ptx->vin) + { + if (!mapPrev.count(txin.prevout.hash)) + return false; + vWorkQueue.push_back(mapPrev[txin.prevout.hash]); + } + } + + return true; + } + + bool WriteToDisk(); + + int64_t GetTxTime() const; + int GetRequestCount() const; + + void AddSupportingTransactions(CTxDB& txdb); + + bool AcceptWalletTransaction(CTxDB& txdb); + bool AcceptWalletTransaction(); + + void RelayWalletTransaction(CTxDB& txdb); + void RelayWalletTransaction(); +}; + + + + +class COutput +{ +public: + const CWalletTx *tx; + int i; + int nDepth; + bool fSpendable; + + COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn) + { + tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn; + } + + std::string ToString() const + { + return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue)); + } + + //Used with luxsend. Will return fees, then denominations, everything else, then very small inputs that aren't fees + int Priority() const + { + if(tx->vout[i].nValue == DARKSEND_FEE) return -1000; + BOOST_FOREACH(int64_t d, darkSendDenominations) + if(tx->vout[i].nValue == d) return 900; + if(tx->vout[i].nValue < 1*COIN) return 1000; + + //nondenom return largest first + return -(tx->vout[i].nValue/COIN); + } + + void print() const + { + LogPrintf("%s\n", ToString().c_str()); + } +}; + + + + +/** Private key that includes an expiration date in case it never gets used. */ +class CWalletKey +{ +public: + CPrivKey vchPrivKey; + int64_t nTimeCreated; + int64_t nTimeExpires; + std::string strComment; + //// todo: add something to note what created it (user, getnewaddress, change) + //// maybe should have a map property map + + CWalletKey(int64_t nExpires=0) + { + nTimeCreated = (nExpires ? GetTime() : 0); + nTimeExpires = nExpires; + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(vchPrivKey); + READWRITE(nTimeCreated); + READWRITE(nTimeExpires); + READWRITE(strComment); + ) +}; + + + + + + +/** Account information. + * Stored in wallet with key "acc"+string account name. + */ +class CAccount +{ +public: + CPubKey vchPubKey; + + CAccount() + { + SetNull(); + } + + void SetNull() + { + vchPubKey = CPubKey(); + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(vchPubKey); + ) +}; + + + +/** Internal transfers. + * Database key is acentry. + */ +class CAccountingEntry +{ +public: + std::string strAccount; + int64_t nCreditDebit; + int64_t nTime; + std::string strOtherAccount; + std::string strComment; + mapValue_t mapValue; + int64_t nOrderPos; // position in ordered transaction list + uint64_t nEntryNo; + + CAccountingEntry() + { + SetNull(); + } + + void SetNull() + { + nCreditDebit = 0; + nTime = 0; + strAccount.clear(); + strOtherAccount.clear(); + strComment.clear(); + nOrderPos = -1; + } + + IMPLEMENT_SERIALIZE + ( + CAccountingEntry& me = *const_cast(this); + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + // Note: strAccount is serialized as part of the key, not here. + READWRITE(nCreditDebit); + READWRITE(nTime); + READWRITE(strOtherAccount); + + if (!fRead) + { + WriteOrderPos(nOrderPos, me.mapValue); + + if (!(mapValue.empty() && _ssExtra.empty())) + { + CDataStream ss(nType, nVersion); + ss.insert(ss.begin(), '\0'); + ss << mapValue; + ss.insert(ss.end(), _ssExtra.begin(), _ssExtra.end()); + me.strComment.append(ss.str()); + } + } + + READWRITE(strComment); + + size_t nSepPos = strComment.find("\0", 0, 1); + if (fRead) + { + me.mapValue.clear(); + if (std::string::npos != nSepPos) + { + CDataStream ss(std::vector(strComment.begin() + nSepPos + 1, strComment.end()), nType, nVersion); + ss >> me.mapValue; + me._ssExtra = std::vector(ss.begin(), ss.end()); + } + ReadOrderPos(me.nOrderPos, me.mapValue); + } + if (std::string::npos != nSepPos) + me.strComment.erase(nSepPos); + + me.mapValue.erase("n"); + ) + +private: + std::vector _ssExtra; +}; + +#endif diff --git a/src/wallet.h.Lt6884 b/src/wallet.h.Lt6884 new file mode 100644 index 0000000..7b48271 --- /dev/null +++ b/src/wallet.h.Lt6884 @@ -0,0 +1,1014 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_WALLET_H +#define BITCOIN_WALLET_H + +#include "walletdb.h" + +#include +#include + +#include + +#include "crypter.h" +#include "main.h" +#include "key.h" +#include "keystore.h" +#include "script.h" +#include "ui_interface.h" +#include "util.h" +#include "stealth.h" + +// Settings +extern int64_t nTransactionFee; +extern int64_t nReserveBalance; +extern int64_t nMinimumInputValue; +extern bool fWalletUnlockStakingOnly; +extern bool fConfChange; + +class CAccountingEntry; +class CCoinControl; +class CWalletTx; +class CReserveKey; +class COutput; +class CWalletDB; + +typedef std::map StealthKeyMetaMap; +typedef std::map mapValue_t; + +/** (client) version numbers for particular wallet features */ +enum WalletFeature +{ + FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getinfo's clientversion output) + + FEATURE_WALLETCRYPT = 40000, // wallet encryption input < comprepubkey to avoid exploit + FEATURE_COMPRPUBKEY = 60000, // compressed public keys + + FEATURE_LATEST = 60000 +}; + +enum AvailableCoinsType +{ + ALL_COINS = 1, + ONLY_DENOMINATED = 2, + ONLY_NONDENOMINATED = 3, + ONLY_NONDENOMINATED_NOTMN = 4 // ONLY_NONDENOMINATED and not 1000 SONO at the same time +}; + +/** IsMine() return codes */ +enum isminetype +{ + ISMINE_NO = 0, + ISMINE_WATCH_ONLY = 1, + ISMINE_SPENDABLE = 2, + ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE +}; + + +/** A key pool entry */ +class CKeyPool +{ +public: + int64_t nTime; + CPubKey vchPubKey; + + CKeyPool() + { + nTime = GetTime(); + } + + CKeyPool(const CPubKey& vchPubKeyIn) + { + nTime = GetTime(); + vchPubKey = vchPubKeyIn; + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(nTime); + READWRITE(vchPubKey); + ) +}; + +/** A CWallet is an extension of a keystore, which also maintains a set of transactions and balances, + * and provides the ability to create new transactions. + */ +class CWallet : public CCryptoKeyStore, public CWalletInterface +{ +private: + bool SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet) const; + //bool SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl=NULL) const; + bool SelectCoins(CAmount nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + CWalletDB *pwalletdbEncryption; + + // the current wallet version: clients below this version are not able to load the wallet + int nWalletVersion; + + // the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded + int nWalletMaxVersion; + +public: + /// Main wallet lock. + /// This lock protects all the fields added by CWallet + /// except for: + /// fFileBacked (immutable after instantiation) + /// strWalletFile (immutable after instantiation) + mutable CCriticalSection cs_wallet; + + bool SelectCoinsDark(int64_t nValueMin, int64_t nValueMax, std::vector& setCoinsRet, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax) const; + bool SelectCoinsByDenominations(int nDenom, int64_t nValueMin, int64_t nValueMax, std::vector& setCoinsRet, vector& vCoins, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax); + bool SelectCoinsDarkDenominated(int64_t nTargetValue, std::vector& setCoinsRet, int64_t& nValueRet) const; + bool SelectCoinsMasternode(CTxIn& vin, int64_t& nValueRet, CScript& pubScript) const; + bool HasCollateralInputs() const; + bool IsCollateralAmount(int64_t nInputAmount) const; + int CountInputsWithAmount(int64_t nInputAmount); + + bool SelectCoinsCollateral(std::vector& setCoinsRet, int64_t& nValueRet) const ; + bool SelectCoinsWithoutDenomination(int64_t nTargetValue, std::set >& setCoinsRet, int64_t& nValueRet) const; + bool GetTransaction(const uint256 &hashTx, CWalletTx& wtx); + + bool fFileBacked; + bool fWalletUnlockAnonymizeOnly; + std::string strWalletFile; + + std::set setKeyPool; + std::map mapKeyMetadata; + + std::set stealthAddresses; + StealthKeyMetaMap mapStealthKeyMeta; + + int nLastFilteredHeight; + + uint32_t nStealth, nFoundStealth; // for reporting, zero before use + + + typedef std::map MasterKeyMap; + MasterKeyMap mapMasterKeys; + unsigned int nMasterKeyMaxID; + + std::map mapMyAdrenalineNodes; + bool AddAdrenalineNodeConfig(CAdrenalineNodeConfig nodeConfig); + + CWallet() + { + SetNull(); + } + CWallet(std::string strWalletFileIn) + { + SetNull(); + + strWalletFile = strWalletFileIn; + fFileBacked = true; + } + + void SetNull() + { + nWalletVersion = FEATURE_BASE; + nWalletMaxVersion = FEATURE_BASE; + fFileBacked = false; + nMasterKeyMaxID = 0; + pwalletdbEncryption = NULL; + nOrderPosNext = 0; + nTimeFirstKey = 0; + nLastFilteredHeight = 0; + fWalletUnlockAnonymizeOnly = false; + } + + std::map mapWallet; + int64_t nOrderPosNext; + std::map mapRequestCount; + + std::map mapAddressBook; + + CPubKey vchDefaultKey; + + std::set setLockedCoins; + + int64_t nTimeFirstKey; + + // check whether we are allowed to upgrade (or already support) to the named feature + bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; } + + void AvailableCoinsForStaking(std::vector& vCoins, unsigned int nSpendTime) const; + void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + void AvailableCoinsMN(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + bool SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; + bool SelectCoinsMinConfByCoinAge(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; + + bool IsSpent(const uint256& hash, unsigned int n) const; + + bool IsLockedCoin(uint256 hash, unsigned int n) const; + void LockCoin(COutPoint& output); + void UnlockCoin(COutPoint& output); + void UnlockAllCoins(); + void ListLockedCoins(std::vector& vOutpts); + CAmount GetTotalValue(std::vector vCoins); + + // keystore implementation + // Generate a new key + CPubKey GenerateNewKey(); + // Adds a key to the store, and saves it to disk. + bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey); + // Adds a key to the store, without saving it to disk (used by LoadWallet) + bool LoadKey(const CKey& key, const CPubKey &pubkey) { return CCryptoKeyStore::AddKeyPubKey(key, pubkey); } + // Load metadata (used by LoadWallet) + bool LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &metadata); + + bool LoadMinVersion(int nVersion) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; } + + // Adds an encrypted key to the store, and saves it to disk. + bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret); + // Adds an encrypted key to the store, without saving it to disk (used by LoadWallet) + bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret); + bool AddCScript(const CScript& redeemScript); + bool LoadCScript(const CScript& redeemScript); + + bool Lock(); + bool Unlock(const SecureString& strWalletPassphrase, bool anonimizeOnly = false); + bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase); + bool EncryptWallet(const SecureString& strWalletPassphrase); + + void GetKeyBirthTimes(std::map &mapKeyBirth) const; + + + /** Increment the next transaction order id + @return next transaction order id + */ + int64_t IncOrderPosNext(CWalletDB *pwalletdb = NULL); + + typedef std::pair TxPair; + typedef std::multimap TxItems; + + /** Get the wallet's activity log + @return multimap of ordered transactions and accounting entries + @warning Returned pointers are *only* valid within the scope of passed acentries + */ + TxItems OrderedTxItems(std::list& acentries, std::string strAccount = ""); + + void MarkDirty(); + bool AddToWallet(const CWalletTx& wtxIn); + void SyncTransaction(const CTransaction& tx, const CBlock* pblock, bool fConnect = true); + bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate); + void EraseFromWallet(const uint256 &hash); + void WalletUpdateSpent(const CTransaction& prevout, bool fBlock = false); + int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false); + void ReacceptWalletTransactions(); + void ResendWalletTransactions(bool fForce = false); + int64_t GetBalance() const; + int64_t GetBalanceNoLocks() const; + int64_t GetUnconfirmedBalance() const; + int64_t GetImmatureBalance() const; + int64_t GetStake() const; + int64_t GetNewMint() const; + + CAmount GetAnonymizedBalance() const; + double GetAverageAnonymizedRounds() const; + CAmount GetNormalizedAnonymizedBalance() const; + CAmount GetDenominatedBalance(bool onlyDenom=true, bool onlyUnconfirmed=false) const; + + bool CreateTransaction(const std::vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, int32_t& nChangePos, std::string& strFailReason, const CCoinControl *coinControl=NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX=false); + bool CreateTransaction(CScript scriptPubKey, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl *coinControl=NULL); + bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); + + uint64_t GetStakeWeight() const; + bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, int64_t nFees, CTransaction& txNew, CKey& key); + + std::string SendMoney(CScript scriptPubKey, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + + bool NewStealthAddress(std::string& sError, std::string& sLabel, CStealthAddress& sxAddr); + bool AddStealthAddress(CStealthAddress& sxAddr); + bool UnlockStealthAddresses(const CKeyingMaterial& vMasterKeyIn); + bool UpdateStealthAddress(std::string &addr, std::string &label, bool addIfNotExist); + + bool CreateStealthTransaction(CScript scriptPubKey, int64_t nValue, std::vector& P, std::vector& narr, std::string& sNarr, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl=NULL); + std::string SendStealthMoney(CScript scriptPubKey, int64_t nValue, std::vector& P, std::vector& narr, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + bool SendStealthMoneyToDestination(CStealthAddress& sxAddress, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, std::string& sError, bool fAskFee=false); + bool FindStealthTransactions(const CTransaction& tx, mapValue_t& mapNarr); + + std::string PrepareluxsendDenominate(int minRounds, int maxRounds); + bool CreateCollateralTransaction(CTransaction& txCollateral, std::string strReason); + bool ConvertList(std::vector vCoins, std::vector& vecAmounts); + + bool NewKeyPool(); + bool TopUpKeyPool(unsigned int nSize = 0); + int64_t AddReserveKey(const CKeyPool& keypool); + void ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool); + void KeepKey(int64_t nIndex); + void ReturnKey(int64_t nIndex); + bool GetKeyFromPool(CPubKey &key); + int64_t GetOldestKeyPoolTime(); + void GetAllReserveKeys(std::set& setAddress) const; + + std::set< std::set > GetAddressGroupings(); + std::map GetAddressBalances(); + + + bool IsDenominated(const CTxIn &txin) const; + + bool IsDenominated(const CTransaction& tx) const + { + /* + Return false if ANY inputs are non-denom + */ + bool ret = true; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + if(!IsDenominated(txin)) { + ret = false; + } + } + return ret; + } + + bool IsDenominatedAmount(int64_t nInputAmount) const; + + + bool IsMine(const CTxIn& txin) const; + int64_t GetDebit(const CTxIn& txin) const; + bool IsMine(const CTxOut& txout) const + { + return ::IsMine(*this, txout.scriptPubKey); + } + int64_t GetCredit(const CTxOut& txout) const + { + if (!MoneyRange(txout.nValue)) + throw std::runtime_error("CWallet::GetCredit() : value out of range"); + return (IsMine(txout) ? txout.nValue : 0); + } + bool IsChange(const CTxOut& txout) const; + int64_t GetChange(const CTxOut& txout) const + { + if (!MoneyRange(txout.nValue)) + throw std::runtime_error("CWallet::GetChange() : value out of range"); + return (IsChange(txout) ? txout.nValue : 0); + } + bool IsMine(const CTransaction& tx) const + { + BOOST_FOREACH(const CTxOut& txout, tx.vout) + if (IsMine(txout) && txout.nValue >= nMinimumInputValue) + return true; + return false; + } + bool IsFromMe(const CTransaction& tx) const + { + return (GetDebit(tx) > 0); + } + int64_t GetDebit(const CTransaction& tx) const + { + int64_t nDebit = 0; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + nDebit += GetDebit(txin); + if (!MoneyRange(nDebit)) + throw std::runtime_error("CWallet::GetDebit() : value out of range"); + } + return nDebit; + } + int64_t GetCredit(const CTransaction& tx) const + { + int64_t nCredit = 0; + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + nCredit += GetCredit(txout); + if (!MoneyRange(nCredit)) + throw std::runtime_error("CWallet::GetCredit() : value out of range"); + } + return nCredit; + } + int64_t GetChange(const CTransaction& tx) const + { + int64_t nChange = 0; + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + nChange += GetChange(txout); + if (!MoneyRange(nChange)) + throw std::runtime_error("CWallet::GetChange() : value out of range"); + } + return nChange; + } + void SetBestChain(const CBlockLocator& loc); + + DBErrors LoadWallet(bool& fFirstRunRet); + + bool SetAddressBookName(const CTxDestination& address, const std::string& strName); + + bool DelAddressBookName(const CTxDestination& address); + + void UpdatedTransaction(const uint256 &hashTx); + + void Inventory(const uint256 &hash) + { + { + LOCK(cs_wallet); + std::map::iterator mi = mapRequestCount.find(hash); + if (mi != mapRequestCount.end()) + (*mi).second++; + } + } + + unsigned int GetKeyPoolSize() + { + AssertLockHeld(cs_wallet); // setKeyPool + return setKeyPool.size(); + } + + bool SetDefaultKey(const CPubKey &vchPubKey); + + // signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVersion if those are lower + bool SetMinVersion(enum WalletFeature, CWalletDB* pwalletdbIn = NULL, bool fExplicit = false); + + // change which version we're allowed to upgrade to (note that this does not immediately imply upgrading to that format) + bool SetMaxVersion(int nVersion); + + // get the current wallet format (the oldest client version guaranteed to understand this wallet) + int GetVersion() { LOCK(cs_wallet); return nWalletVersion; } + + void FixSpentCoins(int& nMismatchSpent, int64_t& nBalanceInQuestion, bool fCheckOnly = false); + void DisableTransaction(const CTransaction &tx); + + /** Address book entry changed. + * @note called with lock cs_wallet held. + */ + boost::signals2::signal NotifyAddressBookChanged; + + /** Wallet transaction added, removed or updated. + * @note called with lock cs_wallet held. + */ + boost::signals2::signal NotifyTransactionChanged; +}; + +/** A key allocated from the key pool. */ +class CReserveKey +{ +protected: + CWallet* pwallet; + int64_t nIndex; + CPubKey vchPubKey; +public: + CReserveKey(CWallet* pwalletIn) + { + nIndex = -1; + pwallet = pwalletIn; + } + + ~CReserveKey() + { + ReturnKey(); + } + + void ReturnKey(); + bool GetReservedKey(CPubKey &pubkey); + void KeepKey(); +}; + + +typedef std::map mapValue_t; + + +static void ReadOrderPos(int64_t& nOrderPos, mapValue_t& mapValue) +{ + if (!mapValue.count("n")) + { + nOrderPos = -1; // TODO: calculate elsewhere + return; + } + nOrderPos = atoi64(mapValue["n"].c_str()); +} + + +static void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue) +{ + if (nOrderPos == -1) + return; + mapValue["n"] = i64tostr(nOrderPos); +} + + +/** A transaction with a bunch of additional info that only the owner cares about. + * It includes any unrecorded transactions needed to link it back to the block chain. + */ +class CWalletTx : public CMerkleTx +{ +private: + const CWallet* pwallet; + +public: + std::vector vtxPrev; + mapValue_t mapValue; + std::vector > vOrderForm; + unsigned int fTimeReceivedIsTxTime; + unsigned int nTimeReceived; // time received by this node + unsigned int nTimeSmart; + char fFromMe; + std::string strFromAccount; + std::vector vfSpent; // which outputs are already spent + int64_t nOrderPos; // position in ordered transaction list + + // memory only + mutable bool fDebitCached; + mutable bool fCreditCached; + mutable bool fAvailableCreditCached; + mutable bool fChangeCached; + mutable int64_t nDebitCached; + mutable int64_t nCreditCached; + mutable int64_t nAvailableCreditCached; + mutable int64_t nChangeCached; + + CWalletTx() + { + Init(NULL); + } + + CWalletTx(const CWallet* pwalletIn) + { + Init(pwalletIn); + } + + CWalletTx(const CWallet* pwalletIn, const CMerkleTx& txIn) : CMerkleTx(txIn) + { + Init(pwalletIn); + } + + CWalletTx(const CWallet* pwalletIn, const CTransaction& txIn) : CMerkleTx(txIn) + { + Init(pwalletIn); + } + + void Init(const CWallet* pwalletIn) + { + pwallet = pwalletIn; + vtxPrev.clear(); + mapValue.clear(); + vOrderForm.clear(); + fTimeReceivedIsTxTime = false; + nTimeReceived = 0; + nTimeSmart = 0; + fFromMe = false; + strFromAccount.clear(); + vfSpent.clear(); + fDebitCached = false; + fCreditCached = false; + fAvailableCreditCached = false; + fChangeCached = false; + nDebitCached = 0; + nCreditCached = 0; + nAvailableCreditCached = 0; + nChangeCached = 0; + nOrderPos = -1; + } + + IMPLEMENT_SERIALIZE + ( + CWalletTx* pthis = const_cast(this); + if (fRead) + pthis->Init(NULL); + char fSpent = false; + + if (!fRead) + { + pthis->mapValue["fromaccount"] = pthis->strFromAccount; + + std::string str; + BOOST_FOREACH(char f, vfSpent) + { + str += (f ? '1' : '0'); + if (f) + fSpent = true; + } + pthis->mapValue["spent"] = str; + + WriteOrderPos(pthis->nOrderPos, pthis->mapValue); + + if (nTimeSmart) + pthis->mapValue["timesmart"] = strprintf("%u", nTimeSmart); + } + + nSerSize += SerReadWrite(s, *(CMerkleTx*)this, nType, nVersion,ser_action); + READWRITE(vtxPrev); + READWRITE(mapValue); + READWRITE(vOrderForm); + READWRITE(fTimeReceivedIsTxTime); + READWRITE(nTimeReceived); + READWRITE(fFromMe); + READWRITE(fSpent); + + if (fRead) + { + pthis->strFromAccount = pthis->mapValue["fromaccount"]; + + if (mapValue.count("spent")) + BOOST_FOREACH(char c, pthis->mapValue["spent"]) + pthis->vfSpent.push_back(c != '0'); + else + pthis->vfSpent.assign(vout.size(), fSpent); + + ReadOrderPos(pthis->nOrderPos, pthis->mapValue); + + pthis->nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(pthis->mapValue["timesmart"]) : 0; + } + + pthis->mapValue.erase("fromaccount"); + pthis->mapValue.erase("version"); + pthis->mapValue.erase("spent"); + pthis->mapValue.erase("n"); + pthis->mapValue.erase("timesmart"); + ) + + // marks certain txout's as spent + // returns true if any update took place + bool UpdateSpent(const std::vector& vfNewSpent) + { + bool fReturn = false; + for (unsigned int i = 0; i < vfNewSpent.size(); i++) + { + if (i == vfSpent.size()) + break; + + if (vfNewSpent[i] && !vfSpent[i]) + { + vfSpent[i] = true; + fReturn = true; + fAvailableCreditCached = false; + } + } + return fReturn; + } + + // make sure balances are recalculated + void MarkDirty() + { + fCreditCached = false; + fAvailableCreditCached = false; + fDebitCached = false; + fChangeCached = false; + } + + void BindWallet(CWallet *pwalletIn) + { + pwallet = pwalletIn; + MarkDirty(); + } + + void MarkSpent(unsigned int nOut) + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::MarkSpent() : nOut out of range"); + vfSpent.resize(vout.size()); + if (!vfSpent[nOut]) + { + vfSpent[nOut] = true; + fAvailableCreditCached = false; + } + } + + void MarkUnspent(unsigned int nOut) + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::MarkUnspent() : nOut out of range"); + vfSpent.resize(vout.size()); + if (vfSpent[nOut]) + { + vfSpent[nOut] = false; + fAvailableCreditCached = false; + } + } + + bool IsSpent(unsigned int nOut) const + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::IsSpent() : nOut out of range"); + if (nOut >= vfSpent.size()) + return false; + return (!!vfSpent[nOut]); + } + + int64_t IsDenominated() const + { + if (vin.empty()) + return 0; + return pwallet->IsDenominated(*this); + } + + int64_t GetDebit() const + { + if (vin.empty()) + return 0; + if (fDebitCached) + return nDebitCached; + nDebitCached = pwallet->GetDebit(*this); + fDebitCached = true; + return nDebitCached; + } + + int64_t GetCredit(bool fUseCache=true) const + { + // Must wait until coinbase is safely deep enough in the chain before valuing it + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) + return 0; + + // GetBalance can assume transactions in mapWallet won't change + if (fUseCache && fCreditCached) + return nCreditCached; + nCreditCached = pwallet->GetCredit(*this); + fCreditCached = true; + return nCreditCached; + } + + int64_t GetAvailableCredit(bool fUseCache=true) const + { + // Must wait until coinbase is safely deep enough in the chain before valuing it + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) + return 0; + + if (fUseCache && fAvailableCreditCached) + return nAvailableCreditCached; + + int64_t nCredit = 0; + for (unsigned int i = 0; i < vout.size(); i++) + { + if (!IsSpent(i)) + { + const CTxOut &txout = vout[i]; + nCredit += pwallet->GetCredit(txout); + if (!MoneyRange(nCredit)) + throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range"); + } + } + + nAvailableCreditCached = nCredit; + fAvailableCreditCached = true; + return nCredit; + } + + + int64_t GetChange() const + { + if (fChangeCached) + return nChangeCached; + nChangeCached = pwallet->GetChange(*this); + fChangeCached = true; + return nChangeCached; + } + + void GetAmounts(std::list >& listReceived, + std::list >& listSent, int64_t& nFee, std::string& strSentAccount) const; + + void GetAccountAmounts(const std::string& strAccount, int64_t& nReceived, + int64_t& nSent, int64_t& nFee) const; + + bool IsFromMe() const + { + return (GetDebit() > 0); + } + + bool IsTrusted() const + { + // Quick answer in most cases + if (!IsFinalTx(*this)) + return false; + int nDepth = GetDepthInMainChain(); + if (nDepth >= 1) + return true; + if (nDepth < 0) + return false; + if (fConfChange || !IsFromMe()) // using wtx's cached debit + return false; + + // If no confirmations but it's from us, we can still + // consider it confirmed if all dependencies are confirmed + std::map mapPrev; + std::vector vWorkQueue; + vWorkQueue.reserve(vtxPrev.size()+1); + vWorkQueue.push_back(this); + for (unsigned int i = 0; i < vWorkQueue.size(); i++) + { + const CMerkleTx* ptx = vWorkQueue[i]; + + if (!IsFinalTx(*ptx)) + return false; + int nPDepth = ptx->GetDepthInMainChain(); + if (nPDepth >= 1) + continue; + if (nPDepth < 0) + return false; + if (!pwallet->IsFromMe(*ptx)) + return false; + + if (mapPrev.empty()) + { + BOOST_FOREACH(const CMerkleTx& tx, vtxPrev) + mapPrev[tx.GetHash()] = &tx; + } + + BOOST_FOREACH(const CTxIn& txin, ptx->vin) + { + if (!mapPrev.count(txin.prevout.hash)) + return false; + vWorkQueue.push_back(mapPrev[txin.prevout.hash]); + } + } + + return true; + } + + bool WriteToDisk(); + + int64_t GetTxTime() const; + int GetRequestCount() const; + + void AddSupportingTransactions(CTxDB& txdb); + + bool AcceptWalletTransaction(CTxDB& txdb); + bool AcceptWalletTransaction(); + + void RelayWalletTransaction(CTxDB& txdb); + void RelayWalletTransaction(); +}; + + + + +class COutput +{ +public: + const CWalletTx *tx; + int i; + int nDepth; + bool fSpendable; + + COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn) + { + tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn; + } + + std::string ToString() const + { + return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue)); + } + + //Used with darksend. Will return fees, then denominations, everything else, then very small inputs that aren't fees + int Priority() const + { + if(tx->vout[i].nValue == DARKSEND_FEE) return -1000; + BOOST_FOREACH(int64_t d, darkSendDenominations) + if(tx->vout[i].nValue == d) return 900; + if(tx->vout[i].nValue < 1*COIN) return 1000; + + //nondenom return largest first + return -(tx->vout[i].nValue/COIN); + } + + void print() const + { + LogPrintf("%s\n", ToString().c_str()); + } +}; + + + + +/** Private key that includes an expiration date in case it never gets used. */ +class CWalletKey +{ +public: + CPrivKey vchPrivKey; + int64_t nTimeCreated; + int64_t nTimeExpires; + std::string strComment; + //// todo: add something to note what created it (user, getnewaddress, change) + //// maybe should have a map property map + + CWalletKey(int64_t nExpires=0) + { + nTimeCreated = (nExpires ? GetTime() : 0); + nTimeExpires = nExpires; + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(vchPrivKey); + READWRITE(nTimeCreated); + READWRITE(nTimeExpires); + READWRITE(strComment); + ) +}; + + + + + + +/** Account information. + * Stored in wallet with key "acc"+string account name. + */ +class CAccount +{ +public: + CPubKey vchPubKey; + + CAccount() + { + SetNull(); + } + + void SetNull() + { + vchPubKey = CPubKey(); + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(vchPubKey); + ) +}; + + + +/** Internal transfers. + * Database key is acentry. + */ +class CAccountingEntry +{ +public: + std::string strAccount; + int64_t nCreditDebit; + int64_t nTime; + std::string strOtherAccount; + std::string strComment; + mapValue_t mapValue; + int64_t nOrderPos; // position in ordered transaction list + uint64_t nEntryNo; + + CAccountingEntry() + { + SetNull(); + } + + void SetNull() + { + nCreditDebit = 0; + nTime = 0; + strAccount.clear(); + strOtherAccount.clear(); + strComment.clear(); + nOrderPos = -1; + } + + IMPLEMENT_SERIALIZE + ( + CAccountingEntry& me = *const_cast(this); + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + // Note: strAccount is serialized as part of the key, not here. + READWRITE(nCreditDebit); + READWRITE(nTime); + READWRITE(strOtherAccount); + + if (!fRead) + { + WriteOrderPos(nOrderPos, me.mapValue); + + if (!(mapValue.empty() && _ssExtra.empty())) + { + CDataStream ss(nType, nVersion); + ss.insert(ss.begin(), '\0'); + ss << mapValue; + ss.insert(ss.end(), _ssExtra.begin(), _ssExtra.end()); + me.strComment.append(ss.str()); + } + } + + READWRITE(strComment); + + size_t nSepPos = strComment.find("\0", 0, 1); + if (fRead) + { + me.mapValue.clear(); + if (std::string::npos != nSepPos) + { + CDataStream ss(std::vector(strComment.begin() + nSepPos + 1, strComment.end()), nType, nVersion); + ss >> me.mapValue; + me._ssExtra = std::vector(ss.begin(), ss.end()); + } + ReadOrderPos(me.nOrderPos, me.mapValue); + } + if (std::string::npos != nSepPos) + me.strComment.erase(nSepPos); + + me.mapValue.erase("n"); + ) + +private: + std::vector _ssExtra; +}; + +#endif diff --git a/src/wallet.h.hE6884 b/src/wallet.h.hE6884 new file mode 100644 index 0000000..7b48271 --- /dev/null +++ b/src/wallet.h.hE6884 @@ -0,0 +1,1014 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_WALLET_H +#define BITCOIN_WALLET_H + +#include "walletdb.h" + +#include +#include + +#include + +#include "crypter.h" +#include "main.h" +#include "key.h" +#include "keystore.h" +#include "script.h" +#include "ui_interface.h" +#include "util.h" +#include "stealth.h" + +// Settings +extern int64_t nTransactionFee; +extern int64_t nReserveBalance; +extern int64_t nMinimumInputValue; +extern bool fWalletUnlockStakingOnly; +extern bool fConfChange; + +class CAccountingEntry; +class CCoinControl; +class CWalletTx; +class CReserveKey; +class COutput; +class CWalletDB; + +typedef std::map StealthKeyMetaMap; +typedef std::map mapValue_t; + +/** (client) version numbers for particular wallet features */ +enum WalletFeature +{ + FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getinfo's clientversion output) + + FEATURE_WALLETCRYPT = 40000, // wallet encryption input < comprepubkey to avoid exploit + FEATURE_COMPRPUBKEY = 60000, // compressed public keys + + FEATURE_LATEST = 60000 +}; + +enum AvailableCoinsType +{ + ALL_COINS = 1, + ONLY_DENOMINATED = 2, + ONLY_NONDENOMINATED = 3, + ONLY_NONDENOMINATED_NOTMN = 4 // ONLY_NONDENOMINATED and not 1000 SONO at the same time +}; + +/** IsMine() return codes */ +enum isminetype +{ + ISMINE_NO = 0, + ISMINE_WATCH_ONLY = 1, + ISMINE_SPENDABLE = 2, + ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE +}; + + +/** A key pool entry */ +class CKeyPool +{ +public: + int64_t nTime; + CPubKey vchPubKey; + + CKeyPool() + { + nTime = GetTime(); + } + + CKeyPool(const CPubKey& vchPubKeyIn) + { + nTime = GetTime(); + vchPubKey = vchPubKeyIn; + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(nTime); + READWRITE(vchPubKey); + ) +}; + +/** A CWallet is an extension of a keystore, which also maintains a set of transactions and balances, + * and provides the ability to create new transactions. + */ +class CWallet : public CCryptoKeyStore, public CWalletInterface +{ +private: + bool SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet) const; + //bool SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl=NULL) const; + bool SelectCoins(CAmount nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + CWalletDB *pwalletdbEncryption; + + // the current wallet version: clients below this version are not able to load the wallet + int nWalletVersion; + + // the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded + int nWalletMaxVersion; + +public: + /// Main wallet lock. + /// This lock protects all the fields added by CWallet + /// except for: + /// fFileBacked (immutable after instantiation) + /// strWalletFile (immutable after instantiation) + mutable CCriticalSection cs_wallet; + + bool SelectCoinsDark(int64_t nValueMin, int64_t nValueMax, std::vector& setCoinsRet, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax) const; + bool SelectCoinsByDenominations(int nDenom, int64_t nValueMin, int64_t nValueMax, std::vector& setCoinsRet, vector& vCoins, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax); + bool SelectCoinsDarkDenominated(int64_t nTargetValue, std::vector& setCoinsRet, int64_t& nValueRet) const; + bool SelectCoinsMasternode(CTxIn& vin, int64_t& nValueRet, CScript& pubScript) const; + bool HasCollateralInputs() const; + bool IsCollateralAmount(int64_t nInputAmount) const; + int CountInputsWithAmount(int64_t nInputAmount); + + bool SelectCoinsCollateral(std::vector& setCoinsRet, int64_t& nValueRet) const ; + bool SelectCoinsWithoutDenomination(int64_t nTargetValue, std::set >& setCoinsRet, int64_t& nValueRet) const; + bool GetTransaction(const uint256 &hashTx, CWalletTx& wtx); + + bool fFileBacked; + bool fWalletUnlockAnonymizeOnly; + std::string strWalletFile; + + std::set setKeyPool; + std::map mapKeyMetadata; + + std::set stealthAddresses; + StealthKeyMetaMap mapStealthKeyMeta; + + int nLastFilteredHeight; + + uint32_t nStealth, nFoundStealth; // for reporting, zero before use + + + typedef std::map MasterKeyMap; + MasterKeyMap mapMasterKeys; + unsigned int nMasterKeyMaxID; + + std::map mapMyAdrenalineNodes; + bool AddAdrenalineNodeConfig(CAdrenalineNodeConfig nodeConfig); + + CWallet() + { + SetNull(); + } + CWallet(std::string strWalletFileIn) + { + SetNull(); + + strWalletFile = strWalletFileIn; + fFileBacked = true; + } + + void SetNull() + { + nWalletVersion = FEATURE_BASE; + nWalletMaxVersion = FEATURE_BASE; + fFileBacked = false; + nMasterKeyMaxID = 0; + pwalletdbEncryption = NULL; + nOrderPosNext = 0; + nTimeFirstKey = 0; + nLastFilteredHeight = 0; + fWalletUnlockAnonymizeOnly = false; + } + + std::map mapWallet; + int64_t nOrderPosNext; + std::map mapRequestCount; + + std::map mapAddressBook; + + CPubKey vchDefaultKey; + + std::set setLockedCoins; + + int64_t nTimeFirstKey; + + // check whether we are allowed to upgrade (or already support) to the named feature + bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; } + + void AvailableCoinsForStaking(std::vector& vCoins, unsigned int nSpendTime) const; + void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + void AvailableCoinsMN(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + bool SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; + bool SelectCoinsMinConfByCoinAge(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; + + bool IsSpent(const uint256& hash, unsigned int n) const; + + bool IsLockedCoin(uint256 hash, unsigned int n) const; + void LockCoin(COutPoint& output); + void UnlockCoin(COutPoint& output); + void UnlockAllCoins(); + void ListLockedCoins(std::vector& vOutpts); + CAmount GetTotalValue(std::vector vCoins); + + // keystore implementation + // Generate a new key + CPubKey GenerateNewKey(); + // Adds a key to the store, and saves it to disk. + bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey); + // Adds a key to the store, without saving it to disk (used by LoadWallet) + bool LoadKey(const CKey& key, const CPubKey &pubkey) { return CCryptoKeyStore::AddKeyPubKey(key, pubkey); } + // Load metadata (used by LoadWallet) + bool LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &metadata); + + bool LoadMinVersion(int nVersion) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; } + + // Adds an encrypted key to the store, and saves it to disk. + bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret); + // Adds an encrypted key to the store, without saving it to disk (used by LoadWallet) + bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret); + bool AddCScript(const CScript& redeemScript); + bool LoadCScript(const CScript& redeemScript); + + bool Lock(); + bool Unlock(const SecureString& strWalletPassphrase, bool anonimizeOnly = false); + bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase); + bool EncryptWallet(const SecureString& strWalletPassphrase); + + void GetKeyBirthTimes(std::map &mapKeyBirth) const; + + + /** Increment the next transaction order id + @return next transaction order id + */ + int64_t IncOrderPosNext(CWalletDB *pwalletdb = NULL); + + typedef std::pair TxPair; + typedef std::multimap TxItems; + + /** Get the wallet's activity log + @return multimap of ordered transactions and accounting entries + @warning Returned pointers are *only* valid within the scope of passed acentries + */ + TxItems OrderedTxItems(std::list& acentries, std::string strAccount = ""); + + void MarkDirty(); + bool AddToWallet(const CWalletTx& wtxIn); + void SyncTransaction(const CTransaction& tx, const CBlock* pblock, bool fConnect = true); + bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate); + void EraseFromWallet(const uint256 &hash); + void WalletUpdateSpent(const CTransaction& prevout, bool fBlock = false); + int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false); + void ReacceptWalletTransactions(); + void ResendWalletTransactions(bool fForce = false); + int64_t GetBalance() const; + int64_t GetBalanceNoLocks() const; + int64_t GetUnconfirmedBalance() const; + int64_t GetImmatureBalance() const; + int64_t GetStake() const; + int64_t GetNewMint() const; + + CAmount GetAnonymizedBalance() const; + double GetAverageAnonymizedRounds() const; + CAmount GetNormalizedAnonymizedBalance() const; + CAmount GetDenominatedBalance(bool onlyDenom=true, bool onlyUnconfirmed=false) const; + + bool CreateTransaction(const std::vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, int32_t& nChangePos, std::string& strFailReason, const CCoinControl *coinControl=NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX=false); + bool CreateTransaction(CScript scriptPubKey, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl *coinControl=NULL); + bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); + + uint64_t GetStakeWeight() const; + bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, int64_t nFees, CTransaction& txNew, CKey& key); + + std::string SendMoney(CScript scriptPubKey, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + + bool NewStealthAddress(std::string& sError, std::string& sLabel, CStealthAddress& sxAddr); + bool AddStealthAddress(CStealthAddress& sxAddr); + bool UnlockStealthAddresses(const CKeyingMaterial& vMasterKeyIn); + bool UpdateStealthAddress(std::string &addr, std::string &label, bool addIfNotExist); + + bool CreateStealthTransaction(CScript scriptPubKey, int64_t nValue, std::vector& P, std::vector& narr, std::string& sNarr, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl=NULL); + std::string SendStealthMoney(CScript scriptPubKey, int64_t nValue, std::vector& P, std::vector& narr, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + bool SendStealthMoneyToDestination(CStealthAddress& sxAddress, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, std::string& sError, bool fAskFee=false); + bool FindStealthTransactions(const CTransaction& tx, mapValue_t& mapNarr); + + std::string PrepareluxsendDenominate(int minRounds, int maxRounds); + bool CreateCollateralTransaction(CTransaction& txCollateral, std::string strReason); + bool ConvertList(std::vector vCoins, std::vector& vecAmounts); + + bool NewKeyPool(); + bool TopUpKeyPool(unsigned int nSize = 0); + int64_t AddReserveKey(const CKeyPool& keypool); + void ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool); + void KeepKey(int64_t nIndex); + void ReturnKey(int64_t nIndex); + bool GetKeyFromPool(CPubKey &key); + int64_t GetOldestKeyPoolTime(); + void GetAllReserveKeys(std::set& setAddress) const; + + std::set< std::set > GetAddressGroupings(); + std::map GetAddressBalances(); + + + bool IsDenominated(const CTxIn &txin) const; + + bool IsDenominated(const CTransaction& tx) const + { + /* + Return false if ANY inputs are non-denom + */ + bool ret = true; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + if(!IsDenominated(txin)) { + ret = false; + } + } + return ret; + } + + bool IsDenominatedAmount(int64_t nInputAmount) const; + + + bool IsMine(const CTxIn& txin) const; + int64_t GetDebit(const CTxIn& txin) const; + bool IsMine(const CTxOut& txout) const + { + return ::IsMine(*this, txout.scriptPubKey); + } + int64_t GetCredit(const CTxOut& txout) const + { + if (!MoneyRange(txout.nValue)) + throw std::runtime_error("CWallet::GetCredit() : value out of range"); + return (IsMine(txout) ? txout.nValue : 0); + } + bool IsChange(const CTxOut& txout) const; + int64_t GetChange(const CTxOut& txout) const + { + if (!MoneyRange(txout.nValue)) + throw std::runtime_error("CWallet::GetChange() : value out of range"); + return (IsChange(txout) ? txout.nValue : 0); + } + bool IsMine(const CTransaction& tx) const + { + BOOST_FOREACH(const CTxOut& txout, tx.vout) + if (IsMine(txout) && txout.nValue >= nMinimumInputValue) + return true; + return false; + } + bool IsFromMe(const CTransaction& tx) const + { + return (GetDebit(tx) > 0); + } + int64_t GetDebit(const CTransaction& tx) const + { + int64_t nDebit = 0; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + nDebit += GetDebit(txin); + if (!MoneyRange(nDebit)) + throw std::runtime_error("CWallet::GetDebit() : value out of range"); + } + return nDebit; + } + int64_t GetCredit(const CTransaction& tx) const + { + int64_t nCredit = 0; + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + nCredit += GetCredit(txout); + if (!MoneyRange(nCredit)) + throw std::runtime_error("CWallet::GetCredit() : value out of range"); + } + return nCredit; + } + int64_t GetChange(const CTransaction& tx) const + { + int64_t nChange = 0; + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + nChange += GetChange(txout); + if (!MoneyRange(nChange)) + throw std::runtime_error("CWallet::GetChange() : value out of range"); + } + return nChange; + } + void SetBestChain(const CBlockLocator& loc); + + DBErrors LoadWallet(bool& fFirstRunRet); + + bool SetAddressBookName(const CTxDestination& address, const std::string& strName); + + bool DelAddressBookName(const CTxDestination& address); + + void UpdatedTransaction(const uint256 &hashTx); + + void Inventory(const uint256 &hash) + { + { + LOCK(cs_wallet); + std::map::iterator mi = mapRequestCount.find(hash); + if (mi != mapRequestCount.end()) + (*mi).second++; + } + } + + unsigned int GetKeyPoolSize() + { + AssertLockHeld(cs_wallet); // setKeyPool + return setKeyPool.size(); + } + + bool SetDefaultKey(const CPubKey &vchPubKey); + + // signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVersion if those are lower + bool SetMinVersion(enum WalletFeature, CWalletDB* pwalletdbIn = NULL, bool fExplicit = false); + + // change which version we're allowed to upgrade to (note that this does not immediately imply upgrading to that format) + bool SetMaxVersion(int nVersion); + + // get the current wallet format (the oldest client version guaranteed to understand this wallet) + int GetVersion() { LOCK(cs_wallet); return nWalletVersion; } + + void FixSpentCoins(int& nMismatchSpent, int64_t& nBalanceInQuestion, bool fCheckOnly = false); + void DisableTransaction(const CTransaction &tx); + + /** Address book entry changed. + * @note called with lock cs_wallet held. + */ + boost::signals2::signal NotifyAddressBookChanged; + + /** Wallet transaction added, removed or updated. + * @note called with lock cs_wallet held. + */ + boost::signals2::signal NotifyTransactionChanged; +}; + +/** A key allocated from the key pool. */ +class CReserveKey +{ +protected: + CWallet* pwallet; + int64_t nIndex; + CPubKey vchPubKey; +public: + CReserveKey(CWallet* pwalletIn) + { + nIndex = -1; + pwallet = pwalletIn; + } + + ~CReserveKey() + { + ReturnKey(); + } + + void ReturnKey(); + bool GetReservedKey(CPubKey &pubkey); + void KeepKey(); +}; + + +typedef std::map mapValue_t; + + +static void ReadOrderPos(int64_t& nOrderPos, mapValue_t& mapValue) +{ + if (!mapValue.count("n")) + { + nOrderPos = -1; // TODO: calculate elsewhere + return; + } + nOrderPos = atoi64(mapValue["n"].c_str()); +} + + +static void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue) +{ + if (nOrderPos == -1) + return; + mapValue["n"] = i64tostr(nOrderPos); +} + + +/** A transaction with a bunch of additional info that only the owner cares about. + * It includes any unrecorded transactions needed to link it back to the block chain. + */ +class CWalletTx : public CMerkleTx +{ +private: + const CWallet* pwallet; + +public: + std::vector vtxPrev; + mapValue_t mapValue; + std::vector > vOrderForm; + unsigned int fTimeReceivedIsTxTime; + unsigned int nTimeReceived; // time received by this node + unsigned int nTimeSmart; + char fFromMe; + std::string strFromAccount; + std::vector vfSpent; // which outputs are already spent + int64_t nOrderPos; // position in ordered transaction list + + // memory only + mutable bool fDebitCached; + mutable bool fCreditCached; + mutable bool fAvailableCreditCached; + mutable bool fChangeCached; + mutable int64_t nDebitCached; + mutable int64_t nCreditCached; + mutable int64_t nAvailableCreditCached; + mutable int64_t nChangeCached; + + CWalletTx() + { + Init(NULL); + } + + CWalletTx(const CWallet* pwalletIn) + { + Init(pwalletIn); + } + + CWalletTx(const CWallet* pwalletIn, const CMerkleTx& txIn) : CMerkleTx(txIn) + { + Init(pwalletIn); + } + + CWalletTx(const CWallet* pwalletIn, const CTransaction& txIn) : CMerkleTx(txIn) + { + Init(pwalletIn); + } + + void Init(const CWallet* pwalletIn) + { + pwallet = pwalletIn; + vtxPrev.clear(); + mapValue.clear(); + vOrderForm.clear(); + fTimeReceivedIsTxTime = false; + nTimeReceived = 0; + nTimeSmart = 0; + fFromMe = false; + strFromAccount.clear(); + vfSpent.clear(); + fDebitCached = false; + fCreditCached = false; + fAvailableCreditCached = false; + fChangeCached = false; + nDebitCached = 0; + nCreditCached = 0; + nAvailableCreditCached = 0; + nChangeCached = 0; + nOrderPos = -1; + } + + IMPLEMENT_SERIALIZE + ( + CWalletTx* pthis = const_cast(this); + if (fRead) + pthis->Init(NULL); + char fSpent = false; + + if (!fRead) + { + pthis->mapValue["fromaccount"] = pthis->strFromAccount; + + std::string str; + BOOST_FOREACH(char f, vfSpent) + { + str += (f ? '1' : '0'); + if (f) + fSpent = true; + } + pthis->mapValue["spent"] = str; + + WriteOrderPos(pthis->nOrderPos, pthis->mapValue); + + if (nTimeSmart) + pthis->mapValue["timesmart"] = strprintf("%u", nTimeSmart); + } + + nSerSize += SerReadWrite(s, *(CMerkleTx*)this, nType, nVersion,ser_action); + READWRITE(vtxPrev); + READWRITE(mapValue); + READWRITE(vOrderForm); + READWRITE(fTimeReceivedIsTxTime); + READWRITE(nTimeReceived); + READWRITE(fFromMe); + READWRITE(fSpent); + + if (fRead) + { + pthis->strFromAccount = pthis->mapValue["fromaccount"]; + + if (mapValue.count("spent")) + BOOST_FOREACH(char c, pthis->mapValue["spent"]) + pthis->vfSpent.push_back(c != '0'); + else + pthis->vfSpent.assign(vout.size(), fSpent); + + ReadOrderPos(pthis->nOrderPos, pthis->mapValue); + + pthis->nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(pthis->mapValue["timesmart"]) : 0; + } + + pthis->mapValue.erase("fromaccount"); + pthis->mapValue.erase("version"); + pthis->mapValue.erase("spent"); + pthis->mapValue.erase("n"); + pthis->mapValue.erase("timesmart"); + ) + + // marks certain txout's as spent + // returns true if any update took place + bool UpdateSpent(const std::vector& vfNewSpent) + { + bool fReturn = false; + for (unsigned int i = 0; i < vfNewSpent.size(); i++) + { + if (i == vfSpent.size()) + break; + + if (vfNewSpent[i] && !vfSpent[i]) + { + vfSpent[i] = true; + fReturn = true; + fAvailableCreditCached = false; + } + } + return fReturn; + } + + // make sure balances are recalculated + void MarkDirty() + { + fCreditCached = false; + fAvailableCreditCached = false; + fDebitCached = false; + fChangeCached = false; + } + + void BindWallet(CWallet *pwalletIn) + { + pwallet = pwalletIn; + MarkDirty(); + } + + void MarkSpent(unsigned int nOut) + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::MarkSpent() : nOut out of range"); + vfSpent.resize(vout.size()); + if (!vfSpent[nOut]) + { + vfSpent[nOut] = true; + fAvailableCreditCached = false; + } + } + + void MarkUnspent(unsigned int nOut) + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::MarkUnspent() : nOut out of range"); + vfSpent.resize(vout.size()); + if (vfSpent[nOut]) + { + vfSpent[nOut] = false; + fAvailableCreditCached = false; + } + } + + bool IsSpent(unsigned int nOut) const + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::IsSpent() : nOut out of range"); + if (nOut >= vfSpent.size()) + return false; + return (!!vfSpent[nOut]); + } + + int64_t IsDenominated() const + { + if (vin.empty()) + return 0; + return pwallet->IsDenominated(*this); + } + + int64_t GetDebit() const + { + if (vin.empty()) + return 0; + if (fDebitCached) + return nDebitCached; + nDebitCached = pwallet->GetDebit(*this); + fDebitCached = true; + return nDebitCached; + } + + int64_t GetCredit(bool fUseCache=true) const + { + // Must wait until coinbase is safely deep enough in the chain before valuing it + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) + return 0; + + // GetBalance can assume transactions in mapWallet won't change + if (fUseCache && fCreditCached) + return nCreditCached; + nCreditCached = pwallet->GetCredit(*this); + fCreditCached = true; + return nCreditCached; + } + + int64_t GetAvailableCredit(bool fUseCache=true) const + { + // Must wait until coinbase is safely deep enough in the chain before valuing it + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) + return 0; + + if (fUseCache && fAvailableCreditCached) + return nAvailableCreditCached; + + int64_t nCredit = 0; + for (unsigned int i = 0; i < vout.size(); i++) + { + if (!IsSpent(i)) + { + const CTxOut &txout = vout[i]; + nCredit += pwallet->GetCredit(txout); + if (!MoneyRange(nCredit)) + throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range"); + } + } + + nAvailableCreditCached = nCredit; + fAvailableCreditCached = true; + return nCredit; + } + + + int64_t GetChange() const + { + if (fChangeCached) + return nChangeCached; + nChangeCached = pwallet->GetChange(*this); + fChangeCached = true; + return nChangeCached; + } + + void GetAmounts(std::list >& listReceived, + std::list >& listSent, int64_t& nFee, std::string& strSentAccount) const; + + void GetAccountAmounts(const std::string& strAccount, int64_t& nReceived, + int64_t& nSent, int64_t& nFee) const; + + bool IsFromMe() const + { + return (GetDebit() > 0); + } + + bool IsTrusted() const + { + // Quick answer in most cases + if (!IsFinalTx(*this)) + return false; + int nDepth = GetDepthInMainChain(); + if (nDepth >= 1) + return true; + if (nDepth < 0) + return false; + if (fConfChange || !IsFromMe()) // using wtx's cached debit + return false; + + // If no confirmations but it's from us, we can still + // consider it confirmed if all dependencies are confirmed + std::map mapPrev; + std::vector vWorkQueue; + vWorkQueue.reserve(vtxPrev.size()+1); + vWorkQueue.push_back(this); + for (unsigned int i = 0; i < vWorkQueue.size(); i++) + { + const CMerkleTx* ptx = vWorkQueue[i]; + + if (!IsFinalTx(*ptx)) + return false; + int nPDepth = ptx->GetDepthInMainChain(); + if (nPDepth >= 1) + continue; + if (nPDepth < 0) + return false; + if (!pwallet->IsFromMe(*ptx)) + return false; + + if (mapPrev.empty()) + { + BOOST_FOREACH(const CMerkleTx& tx, vtxPrev) + mapPrev[tx.GetHash()] = &tx; + } + + BOOST_FOREACH(const CTxIn& txin, ptx->vin) + { + if (!mapPrev.count(txin.prevout.hash)) + return false; + vWorkQueue.push_back(mapPrev[txin.prevout.hash]); + } + } + + return true; + } + + bool WriteToDisk(); + + int64_t GetTxTime() const; + int GetRequestCount() const; + + void AddSupportingTransactions(CTxDB& txdb); + + bool AcceptWalletTransaction(CTxDB& txdb); + bool AcceptWalletTransaction(); + + void RelayWalletTransaction(CTxDB& txdb); + void RelayWalletTransaction(); +}; + + + + +class COutput +{ +public: + const CWalletTx *tx; + int i; + int nDepth; + bool fSpendable; + + COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn) + { + tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn; + } + + std::string ToString() const + { + return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue)); + } + + //Used with darksend. Will return fees, then denominations, everything else, then very small inputs that aren't fees + int Priority() const + { + if(tx->vout[i].nValue == DARKSEND_FEE) return -1000; + BOOST_FOREACH(int64_t d, darkSendDenominations) + if(tx->vout[i].nValue == d) return 900; + if(tx->vout[i].nValue < 1*COIN) return 1000; + + //nondenom return largest first + return -(tx->vout[i].nValue/COIN); + } + + void print() const + { + LogPrintf("%s\n", ToString().c_str()); + } +}; + + + + +/** Private key that includes an expiration date in case it never gets used. */ +class CWalletKey +{ +public: + CPrivKey vchPrivKey; + int64_t nTimeCreated; + int64_t nTimeExpires; + std::string strComment; + //// todo: add something to note what created it (user, getnewaddress, change) + //// maybe should have a map property map + + CWalletKey(int64_t nExpires=0) + { + nTimeCreated = (nExpires ? GetTime() : 0); + nTimeExpires = nExpires; + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(vchPrivKey); + READWRITE(nTimeCreated); + READWRITE(nTimeExpires); + READWRITE(strComment); + ) +}; + + + + + + +/** Account information. + * Stored in wallet with key "acc"+string account name. + */ +class CAccount +{ +public: + CPubKey vchPubKey; + + CAccount() + { + SetNull(); + } + + void SetNull() + { + vchPubKey = CPubKey(); + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(vchPubKey); + ) +}; + + + +/** Internal transfers. + * Database key is acentry. + */ +class CAccountingEntry +{ +public: + std::string strAccount; + int64_t nCreditDebit; + int64_t nTime; + std::string strOtherAccount; + std::string strComment; + mapValue_t mapValue; + int64_t nOrderPos; // position in ordered transaction list + uint64_t nEntryNo; + + CAccountingEntry() + { + SetNull(); + } + + void SetNull() + { + nCreditDebit = 0; + nTime = 0; + strAccount.clear(); + strOtherAccount.clear(); + strComment.clear(); + nOrderPos = -1; + } + + IMPLEMENT_SERIALIZE + ( + CAccountingEntry& me = *const_cast(this); + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + // Note: strAccount is serialized as part of the key, not here. + READWRITE(nCreditDebit); + READWRITE(nTime); + READWRITE(strOtherAccount); + + if (!fRead) + { + WriteOrderPos(nOrderPos, me.mapValue); + + if (!(mapValue.empty() && _ssExtra.empty())) + { + CDataStream ss(nType, nVersion); + ss.insert(ss.begin(), '\0'); + ss << mapValue; + ss.insert(ss.end(), _ssExtra.begin(), _ssExtra.end()); + me.strComment.append(ss.str()); + } + } + + READWRITE(strComment); + + size_t nSepPos = strComment.find("\0", 0, 1); + if (fRead) + { + me.mapValue.clear(); + if (std::string::npos != nSepPos) + { + CDataStream ss(std::vector(strComment.begin() + nSepPos + 1, strComment.end()), nType, nVersion); + ss >> me.mapValue; + me._ssExtra = std::vector(ss.begin(), ss.end()); + } + ReadOrderPos(me.nOrderPos, me.mapValue); + } + if (std::string::npos != nSepPos) + me.strComment.erase(nSepPos); + + me.mapValue.erase("n"); + ) + +private: + std::vector _ssExtra; +}; + +#endif diff --git a/src/wallet.h.pc6884 b/src/wallet.h.pc6884 new file mode 100644 index 0000000..7b48271 --- /dev/null +++ b/src/wallet.h.pc6884 @@ -0,0 +1,1014 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_WALLET_H +#define BITCOIN_WALLET_H + +#include "walletdb.h" + +#include +#include + +#include + +#include "crypter.h" +#include "main.h" +#include "key.h" +#include "keystore.h" +#include "script.h" +#include "ui_interface.h" +#include "util.h" +#include "stealth.h" + +// Settings +extern int64_t nTransactionFee; +extern int64_t nReserveBalance; +extern int64_t nMinimumInputValue; +extern bool fWalletUnlockStakingOnly; +extern bool fConfChange; + +class CAccountingEntry; +class CCoinControl; +class CWalletTx; +class CReserveKey; +class COutput; +class CWalletDB; + +typedef std::map StealthKeyMetaMap; +typedef std::map mapValue_t; + +/** (client) version numbers for particular wallet features */ +enum WalletFeature +{ + FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getinfo's clientversion output) + + FEATURE_WALLETCRYPT = 40000, // wallet encryption input < comprepubkey to avoid exploit + FEATURE_COMPRPUBKEY = 60000, // compressed public keys + + FEATURE_LATEST = 60000 +}; + +enum AvailableCoinsType +{ + ALL_COINS = 1, + ONLY_DENOMINATED = 2, + ONLY_NONDENOMINATED = 3, + ONLY_NONDENOMINATED_NOTMN = 4 // ONLY_NONDENOMINATED and not 1000 SONO at the same time +}; + +/** IsMine() return codes */ +enum isminetype +{ + ISMINE_NO = 0, + ISMINE_WATCH_ONLY = 1, + ISMINE_SPENDABLE = 2, + ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE +}; + + +/** A key pool entry */ +class CKeyPool +{ +public: + int64_t nTime; + CPubKey vchPubKey; + + CKeyPool() + { + nTime = GetTime(); + } + + CKeyPool(const CPubKey& vchPubKeyIn) + { + nTime = GetTime(); + vchPubKey = vchPubKeyIn; + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(nTime); + READWRITE(vchPubKey); + ) +}; + +/** A CWallet is an extension of a keystore, which also maintains a set of transactions and balances, + * and provides the ability to create new transactions. + */ +class CWallet : public CCryptoKeyStore, public CWalletInterface +{ +private: + bool SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet) const; + //bool SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl=NULL) const; + bool SelectCoins(CAmount nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + CWalletDB *pwalletdbEncryption; + + // the current wallet version: clients below this version are not able to load the wallet + int nWalletVersion; + + // the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded + int nWalletMaxVersion; + +public: + /// Main wallet lock. + /// This lock protects all the fields added by CWallet + /// except for: + /// fFileBacked (immutable after instantiation) + /// strWalletFile (immutable after instantiation) + mutable CCriticalSection cs_wallet; + + bool SelectCoinsDark(int64_t nValueMin, int64_t nValueMax, std::vector& setCoinsRet, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax) const; + bool SelectCoinsByDenominations(int nDenom, int64_t nValueMin, int64_t nValueMax, std::vector& setCoinsRet, vector& vCoins, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax); + bool SelectCoinsDarkDenominated(int64_t nTargetValue, std::vector& setCoinsRet, int64_t& nValueRet) const; + bool SelectCoinsMasternode(CTxIn& vin, int64_t& nValueRet, CScript& pubScript) const; + bool HasCollateralInputs() const; + bool IsCollateralAmount(int64_t nInputAmount) const; + int CountInputsWithAmount(int64_t nInputAmount); + + bool SelectCoinsCollateral(std::vector& setCoinsRet, int64_t& nValueRet) const ; + bool SelectCoinsWithoutDenomination(int64_t nTargetValue, std::set >& setCoinsRet, int64_t& nValueRet) const; + bool GetTransaction(const uint256 &hashTx, CWalletTx& wtx); + + bool fFileBacked; + bool fWalletUnlockAnonymizeOnly; + std::string strWalletFile; + + std::set setKeyPool; + std::map mapKeyMetadata; + + std::set stealthAddresses; + StealthKeyMetaMap mapStealthKeyMeta; + + int nLastFilteredHeight; + + uint32_t nStealth, nFoundStealth; // for reporting, zero before use + + + typedef std::map MasterKeyMap; + MasterKeyMap mapMasterKeys; + unsigned int nMasterKeyMaxID; + + std::map mapMyAdrenalineNodes; + bool AddAdrenalineNodeConfig(CAdrenalineNodeConfig nodeConfig); + + CWallet() + { + SetNull(); + } + CWallet(std::string strWalletFileIn) + { + SetNull(); + + strWalletFile = strWalletFileIn; + fFileBacked = true; + } + + void SetNull() + { + nWalletVersion = FEATURE_BASE; + nWalletMaxVersion = FEATURE_BASE; + fFileBacked = false; + nMasterKeyMaxID = 0; + pwalletdbEncryption = NULL; + nOrderPosNext = 0; + nTimeFirstKey = 0; + nLastFilteredHeight = 0; + fWalletUnlockAnonymizeOnly = false; + } + + std::map mapWallet; + int64_t nOrderPosNext; + std::map mapRequestCount; + + std::map mapAddressBook; + + CPubKey vchDefaultKey; + + std::set setLockedCoins; + + int64_t nTimeFirstKey; + + // check whether we are allowed to upgrade (or already support) to the named feature + bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; } + + void AvailableCoinsForStaking(std::vector& vCoins, unsigned int nSpendTime) const; + void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + void AvailableCoinsMN(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = false) const; + bool SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; + bool SelectCoinsMinConfByCoinAge(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; + + bool IsSpent(const uint256& hash, unsigned int n) const; + + bool IsLockedCoin(uint256 hash, unsigned int n) const; + void LockCoin(COutPoint& output); + void UnlockCoin(COutPoint& output); + void UnlockAllCoins(); + void ListLockedCoins(std::vector& vOutpts); + CAmount GetTotalValue(std::vector vCoins); + + // keystore implementation + // Generate a new key + CPubKey GenerateNewKey(); + // Adds a key to the store, and saves it to disk. + bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey); + // Adds a key to the store, without saving it to disk (used by LoadWallet) + bool LoadKey(const CKey& key, const CPubKey &pubkey) { return CCryptoKeyStore::AddKeyPubKey(key, pubkey); } + // Load metadata (used by LoadWallet) + bool LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &metadata); + + bool LoadMinVersion(int nVersion) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; } + + // Adds an encrypted key to the store, and saves it to disk. + bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret); + // Adds an encrypted key to the store, without saving it to disk (used by LoadWallet) + bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret); + bool AddCScript(const CScript& redeemScript); + bool LoadCScript(const CScript& redeemScript); + + bool Lock(); + bool Unlock(const SecureString& strWalletPassphrase, bool anonimizeOnly = false); + bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase); + bool EncryptWallet(const SecureString& strWalletPassphrase); + + void GetKeyBirthTimes(std::map &mapKeyBirth) const; + + + /** Increment the next transaction order id + @return next transaction order id + */ + int64_t IncOrderPosNext(CWalletDB *pwalletdb = NULL); + + typedef std::pair TxPair; + typedef std::multimap TxItems; + + /** Get the wallet's activity log + @return multimap of ordered transactions and accounting entries + @warning Returned pointers are *only* valid within the scope of passed acentries + */ + TxItems OrderedTxItems(std::list& acentries, std::string strAccount = ""); + + void MarkDirty(); + bool AddToWallet(const CWalletTx& wtxIn); + void SyncTransaction(const CTransaction& tx, const CBlock* pblock, bool fConnect = true); + bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate); + void EraseFromWallet(const uint256 &hash); + void WalletUpdateSpent(const CTransaction& prevout, bool fBlock = false); + int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false); + void ReacceptWalletTransactions(); + void ResendWalletTransactions(bool fForce = false); + int64_t GetBalance() const; + int64_t GetBalanceNoLocks() const; + int64_t GetUnconfirmedBalance() const; + int64_t GetImmatureBalance() const; + int64_t GetStake() const; + int64_t GetNewMint() const; + + CAmount GetAnonymizedBalance() const; + double GetAverageAnonymizedRounds() const; + CAmount GetNormalizedAnonymizedBalance() const; + CAmount GetDenominatedBalance(bool onlyDenom=true, bool onlyUnconfirmed=false) const; + + bool CreateTransaction(const std::vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, int32_t& nChangePos, std::string& strFailReason, const CCoinControl *coinControl=NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX=false); + bool CreateTransaction(CScript scriptPubKey, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl *coinControl=NULL); + bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); + + uint64_t GetStakeWeight() const; + bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, int64_t nFees, CTransaction& txNew, CKey& key); + + std::string SendMoney(CScript scriptPubKey, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + + bool NewStealthAddress(std::string& sError, std::string& sLabel, CStealthAddress& sxAddr); + bool AddStealthAddress(CStealthAddress& sxAddr); + bool UnlockStealthAddresses(const CKeyingMaterial& vMasterKeyIn); + bool UpdateStealthAddress(std::string &addr, std::string &label, bool addIfNotExist); + + bool CreateStealthTransaction(CScript scriptPubKey, int64_t nValue, std::vector& P, std::vector& narr, std::string& sNarr, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl=NULL); + std::string SendStealthMoney(CScript scriptPubKey, int64_t nValue, std::vector& P, std::vector& narr, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); + bool SendStealthMoneyToDestination(CStealthAddress& sxAddress, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, std::string& sError, bool fAskFee=false); + bool FindStealthTransactions(const CTransaction& tx, mapValue_t& mapNarr); + + std::string PrepareluxsendDenominate(int minRounds, int maxRounds); + bool CreateCollateralTransaction(CTransaction& txCollateral, std::string strReason); + bool ConvertList(std::vector vCoins, std::vector& vecAmounts); + + bool NewKeyPool(); + bool TopUpKeyPool(unsigned int nSize = 0); + int64_t AddReserveKey(const CKeyPool& keypool); + void ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool); + void KeepKey(int64_t nIndex); + void ReturnKey(int64_t nIndex); + bool GetKeyFromPool(CPubKey &key); + int64_t GetOldestKeyPoolTime(); + void GetAllReserveKeys(std::set& setAddress) const; + + std::set< std::set > GetAddressGroupings(); + std::map GetAddressBalances(); + + + bool IsDenominated(const CTxIn &txin) const; + + bool IsDenominated(const CTransaction& tx) const + { + /* + Return false if ANY inputs are non-denom + */ + bool ret = true; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + if(!IsDenominated(txin)) { + ret = false; + } + } + return ret; + } + + bool IsDenominatedAmount(int64_t nInputAmount) const; + + + bool IsMine(const CTxIn& txin) const; + int64_t GetDebit(const CTxIn& txin) const; + bool IsMine(const CTxOut& txout) const + { + return ::IsMine(*this, txout.scriptPubKey); + } + int64_t GetCredit(const CTxOut& txout) const + { + if (!MoneyRange(txout.nValue)) + throw std::runtime_error("CWallet::GetCredit() : value out of range"); + return (IsMine(txout) ? txout.nValue : 0); + } + bool IsChange(const CTxOut& txout) const; + int64_t GetChange(const CTxOut& txout) const + { + if (!MoneyRange(txout.nValue)) + throw std::runtime_error("CWallet::GetChange() : value out of range"); + return (IsChange(txout) ? txout.nValue : 0); + } + bool IsMine(const CTransaction& tx) const + { + BOOST_FOREACH(const CTxOut& txout, tx.vout) + if (IsMine(txout) && txout.nValue >= nMinimumInputValue) + return true; + return false; + } + bool IsFromMe(const CTransaction& tx) const + { + return (GetDebit(tx) > 0); + } + int64_t GetDebit(const CTransaction& tx) const + { + int64_t nDebit = 0; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + nDebit += GetDebit(txin); + if (!MoneyRange(nDebit)) + throw std::runtime_error("CWallet::GetDebit() : value out of range"); + } + return nDebit; + } + int64_t GetCredit(const CTransaction& tx) const + { + int64_t nCredit = 0; + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + nCredit += GetCredit(txout); + if (!MoneyRange(nCredit)) + throw std::runtime_error("CWallet::GetCredit() : value out of range"); + } + return nCredit; + } + int64_t GetChange(const CTransaction& tx) const + { + int64_t nChange = 0; + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + nChange += GetChange(txout); + if (!MoneyRange(nChange)) + throw std::runtime_error("CWallet::GetChange() : value out of range"); + } + return nChange; + } + void SetBestChain(const CBlockLocator& loc); + + DBErrors LoadWallet(bool& fFirstRunRet); + + bool SetAddressBookName(const CTxDestination& address, const std::string& strName); + + bool DelAddressBookName(const CTxDestination& address); + + void UpdatedTransaction(const uint256 &hashTx); + + void Inventory(const uint256 &hash) + { + { + LOCK(cs_wallet); + std::map::iterator mi = mapRequestCount.find(hash); + if (mi != mapRequestCount.end()) + (*mi).second++; + } + } + + unsigned int GetKeyPoolSize() + { + AssertLockHeld(cs_wallet); // setKeyPool + return setKeyPool.size(); + } + + bool SetDefaultKey(const CPubKey &vchPubKey); + + // signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVersion if those are lower + bool SetMinVersion(enum WalletFeature, CWalletDB* pwalletdbIn = NULL, bool fExplicit = false); + + // change which version we're allowed to upgrade to (note that this does not immediately imply upgrading to that format) + bool SetMaxVersion(int nVersion); + + // get the current wallet format (the oldest client version guaranteed to understand this wallet) + int GetVersion() { LOCK(cs_wallet); return nWalletVersion; } + + void FixSpentCoins(int& nMismatchSpent, int64_t& nBalanceInQuestion, bool fCheckOnly = false); + void DisableTransaction(const CTransaction &tx); + + /** Address book entry changed. + * @note called with lock cs_wallet held. + */ + boost::signals2::signal NotifyAddressBookChanged; + + /** Wallet transaction added, removed or updated. + * @note called with lock cs_wallet held. + */ + boost::signals2::signal NotifyTransactionChanged; +}; + +/** A key allocated from the key pool. */ +class CReserveKey +{ +protected: + CWallet* pwallet; + int64_t nIndex; + CPubKey vchPubKey; +public: + CReserveKey(CWallet* pwalletIn) + { + nIndex = -1; + pwallet = pwalletIn; + } + + ~CReserveKey() + { + ReturnKey(); + } + + void ReturnKey(); + bool GetReservedKey(CPubKey &pubkey); + void KeepKey(); +}; + + +typedef std::map mapValue_t; + + +static void ReadOrderPos(int64_t& nOrderPos, mapValue_t& mapValue) +{ + if (!mapValue.count("n")) + { + nOrderPos = -1; // TODO: calculate elsewhere + return; + } + nOrderPos = atoi64(mapValue["n"].c_str()); +} + + +static void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue) +{ + if (nOrderPos == -1) + return; + mapValue["n"] = i64tostr(nOrderPos); +} + + +/** A transaction with a bunch of additional info that only the owner cares about. + * It includes any unrecorded transactions needed to link it back to the block chain. + */ +class CWalletTx : public CMerkleTx +{ +private: + const CWallet* pwallet; + +public: + std::vector vtxPrev; + mapValue_t mapValue; + std::vector > vOrderForm; + unsigned int fTimeReceivedIsTxTime; + unsigned int nTimeReceived; // time received by this node + unsigned int nTimeSmart; + char fFromMe; + std::string strFromAccount; + std::vector vfSpent; // which outputs are already spent + int64_t nOrderPos; // position in ordered transaction list + + // memory only + mutable bool fDebitCached; + mutable bool fCreditCached; + mutable bool fAvailableCreditCached; + mutable bool fChangeCached; + mutable int64_t nDebitCached; + mutable int64_t nCreditCached; + mutable int64_t nAvailableCreditCached; + mutable int64_t nChangeCached; + + CWalletTx() + { + Init(NULL); + } + + CWalletTx(const CWallet* pwalletIn) + { + Init(pwalletIn); + } + + CWalletTx(const CWallet* pwalletIn, const CMerkleTx& txIn) : CMerkleTx(txIn) + { + Init(pwalletIn); + } + + CWalletTx(const CWallet* pwalletIn, const CTransaction& txIn) : CMerkleTx(txIn) + { + Init(pwalletIn); + } + + void Init(const CWallet* pwalletIn) + { + pwallet = pwalletIn; + vtxPrev.clear(); + mapValue.clear(); + vOrderForm.clear(); + fTimeReceivedIsTxTime = false; + nTimeReceived = 0; + nTimeSmart = 0; + fFromMe = false; + strFromAccount.clear(); + vfSpent.clear(); + fDebitCached = false; + fCreditCached = false; + fAvailableCreditCached = false; + fChangeCached = false; + nDebitCached = 0; + nCreditCached = 0; + nAvailableCreditCached = 0; + nChangeCached = 0; + nOrderPos = -1; + } + + IMPLEMENT_SERIALIZE + ( + CWalletTx* pthis = const_cast(this); + if (fRead) + pthis->Init(NULL); + char fSpent = false; + + if (!fRead) + { + pthis->mapValue["fromaccount"] = pthis->strFromAccount; + + std::string str; + BOOST_FOREACH(char f, vfSpent) + { + str += (f ? '1' : '0'); + if (f) + fSpent = true; + } + pthis->mapValue["spent"] = str; + + WriteOrderPos(pthis->nOrderPos, pthis->mapValue); + + if (nTimeSmart) + pthis->mapValue["timesmart"] = strprintf("%u", nTimeSmart); + } + + nSerSize += SerReadWrite(s, *(CMerkleTx*)this, nType, nVersion,ser_action); + READWRITE(vtxPrev); + READWRITE(mapValue); + READWRITE(vOrderForm); + READWRITE(fTimeReceivedIsTxTime); + READWRITE(nTimeReceived); + READWRITE(fFromMe); + READWRITE(fSpent); + + if (fRead) + { + pthis->strFromAccount = pthis->mapValue["fromaccount"]; + + if (mapValue.count("spent")) + BOOST_FOREACH(char c, pthis->mapValue["spent"]) + pthis->vfSpent.push_back(c != '0'); + else + pthis->vfSpent.assign(vout.size(), fSpent); + + ReadOrderPos(pthis->nOrderPos, pthis->mapValue); + + pthis->nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(pthis->mapValue["timesmart"]) : 0; + } + + pthis->mapValue.erase("fromaccount"); + pthis->mapValue.erase("version"); + pthis->mapValue.erase("spent"); + pthis->mapValue.erase("n"); + pthis->mapValue.erase("timesmart"); + ) + + // marks certain txout's as spent + // returns true if any update took place + bool UpdateSpent(const std::vector& vfNewSpent) + { + bool fReturn = false; + for (unsigned int i = 0; i < vfNewSpent.size(); i++) + { + if (i == vfSpent.size()) + break; + + if (vfNewSpent[i] && !vfSpent[i]) + { + vfSpent[i] = true; + fReturn = true; + fAvailableCreditCached = false; + } + } + return fReturn; + } + + // make sure balances are recalculated + void MarkDirty() + { + fCreditCached = false; + fAvailableCreditCached = false; + fDebitCached = false; + fChangeCached = false; + } + + void BindWallet(CWallet *pwalletIn) + { + pwallet = pwalletIn; + MarkDirty(); + } + + void MarkSpent(unsigned int nOut) + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::MarkSpent() : nOut out of range"); + vfSpent.resize(vout.size()); + if (!vfSpent[nOut]) + { + vfSpent[nOut] = true; + fAvailableCreditCached = false; + } + } + + void MarkUnspent(unsigned int nOut) + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::MarkUnspent() : nOut out of range"); + vfSpent.resize(vout.size()); + if (vfSpent[nOut]) + { + vfSpent[nOut] = false; + fAvailableCreditCached = false; + } + } + + bool IsSpent(unsigned int nOut) const + { + if (nOut >= vout.size()) + throw std::runtime_error("CWalletTx::IsSpent() : nOut out of range"); + if (nOut >= vfSpent.size()) + return false; + return (!!vfSpent[nOut]); + } + + int64_t IsDenominated() const + { + if (vin.empty()) + return 0; + return pwallet->IsDenominated(*this); + } + + int64_t GetDebit() const + { + if (vin.empty()) + return 0; + if (fDebitCached) + return nDebitCached; + nDebitCached = pwallet->GetDebit(*this); + fDebitCached = true; + return nDebitCached; + } + + int64_t GetCredit(bool fUseCache=true) const + { + // Must wait until coinbase is safely deep enough in the chain before valuing it + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) + return 0; + + // GetBalance can assume transactions in mapWallet won't change + if (fUseCache && fCreditCached) + return nCreditCached; + nCreditCached = pwallet->GetCredit(*this); + fCreditCached = true; + return nCreditCached; + } + + int64_t GetAvailableCredit(bool fUseCache=true) const + { + // Must wait until coinbase is safely deep enough in the chain before valuing it + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) + return 0; + + if (fUseCache && fAvailableCreditCached) + return nAvailableCreditCached; + + int64_t nCredit = 0; + for (unsigned int i = 0; i < vout.size(); i++) + { + if (!IsSpent(i)) + { + const CTxOut &txout = vout[i]; + nCredit += pwallet->GetCredit(txout); + if (!MoneyRange(nCredit)) + throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range"); + } + } + + nAvailableCreditCached = nCredit; + fAvailableCreditCached = true; + return nCredit; + } + + + int64_t GetChange() const + { + if (fChangeCached) + return nChangeCached; + nChangeCached = pwallet->GetChange(*this); + fChangeCached = true; + return nChangeCached; + } + + void GetAmounts(std::list >& listReceived, + std::list >& listSent, int64_t& nFee, std::string& strSentAccount) const; + + void GetAccountAmounts(const std::string& strAccount, int64_t& nReceived, + int64_t& nSent, int64_t& nFee) const; + + bool IsFromMe() const + { + return (GetDebit() > 0); + } + + bool IsTrusted() const + { + // Quick answer in most cases + if (!IsFinalTx(*this)) + return false; + int nDepth = GetDepthInMainChain(); + if (nDepth >= 1) + return true; + if (nDepth < 0) + return false; + if (fConfChange || !IsFromMe()) // using wtx's cached debit + return false; + + // If no confirmations but it's from us, we can still + // consider it confirmed if all dependencies are confirmed + std::map mapPrev; + std::vector vWorkQueue; + vWorkQueue.reserve(vtxPrev.size()+1); + vWorkQueue.push_back(this); + for (unsigned int i = 0; i < vWorkQueue.size(); i++) + { + const CMerkleTx* ptx = vWorkQueue[i]; + + if (!IsFinalTx(*ptx)) + return false; + int nPDepth = ptx->GetDepthInMainChain(); + if (nPDepth >= 1) + continue; + if (nPDepth < 0) + return false; + if (!pwallet->IsFromMe(*ptx)) + return false; + + if (mapPrev.empty()) + { + BOOST_FOREACH(const CMerkleTx& tx, vtxPrev) + mapPrev[tx.GetHash()] = &tx; + } + + BOOST_FOREACH(const CTxIn& txin, ptx->vin) + { + if (!mapPrev.count(txin.prevout.hash)) + return false; + vWorkQueue.push_back(mapPrev[txin.prevout.hash]); + } + } + + return true; + } + + bool WriteToDisk(); + + int64_t GetTxTime() const; + int GetRequestCount() const; + + void AddSupportingTransactions(CTxDB& txdb); + + bool AcceptWalletTransaction(CTxDB& txdb); + bool AcceptWalletTransaction(); + + void RelayWalletTransaction(CTxDB& txdb); + void RelayWalletTransaction(); +}; + + + + +class COutput +{ +public: + const CWalletTx *tx; + int i; + int nDepth; + bool fSpendable; + + COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn) + { + tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn; + } + + std::string ToString() const + { + return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue)); + } + + //Used with darksend. Will return fees, then denominations, everything else, then very small inputs that aren't fees + int Priority() const + { + if(tx->vout[i].nValue == DARKSEND_FEE) return -1000; + BOOST_FOREACH(int64_t d, darkSendDenominations) + if(tx->vout[i].nValue == d) return 900; + if(tx->vout[i].nValue < 1*COIN) return 1000; + + //nondenom return largest first + return -(tx->vout[i].nValue/COIN); + } + + void print() const + { + LogPrintf("%s\n", ToString().c_str()); + } +}; + + + + +/** Private key that includes an expiration date in case it never gets used. */ +class CWalletKey +{ +public: + CPrivKey vchPrivKey; + int64_t nTimeCreated; + int64_t nTimeExpires; + std::string strComment; + //// todo: add something to note what created it (user, getnewaddress, change) + //// maybe should have a map property map + + CWalletKey(int64_t nExpires=0) + { + nTimeCreated = (nExpires ? GetTime() : 0); + nTimeExpires = nExpires; + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(vchPrivKey); + READWRITE(nTimeCreated); + READWRITE(nTimeExpires); + READWRITE(strComment); + ) +}; + + + + + + +/** Account information. + * Stored in wallet with key "acc"+string account name. + */ +class CAccount +{ +public: + CPubKey vchPubKey; + + CAccount() + { + SetNull(); + } + + void SetNull() + { + vchPubKey = CPubKey(); + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(vchPubKey); + ) +}; + + + +/** Internal transfers. + * Database key is acentry. + */ +class CAccountingEntry +{ +public: + std::string strAccount; + int64_t nCreditDebit; + int64_t nTime; + std::string strOtherAccount; + std::string strComment; + mapValue_t mapValue; + int64_t nOrderPos; // position in ordered transaction list + uint64_t nEntryNo; + + CAccountingEntry() + { + SetNull(); + } + + void SetNull() + { + nCreditDebit = 0; + nTime = 0; + strAccount.clear(); + strOtherAccount.clear(); + strComment.clear(); + nOrderPos = -1; + } + + IMPLEMENT_SERIALIZE + ( + CAccountingEntry& me = *const_cast(this); + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + // Note: strAccount is serialized as part of the key, not here. + READWRITE(nCreditDebit); + READWRITE(nTime); + READWRITE(strOtherAccount); + + if (!fRead) + { + WriteOrderPos(nOrderPos, me.mapValue); + + if (!(mapValue.empty() && _ssExtra.empty())) + { + CDataStream ss(nType, nVersion); + ss.insert(ss.begin(), '\0'); + ss << mapValue; + ss.insert(ss.end(), _ssExtra.begin(), _ssExtra.end()); + me.strComment.append(ss.str()); + } + } + + READWRITE(strComment); + + size_t nSepPos = strComment.find("\0", 0, 1); + if (fRead) + { + me.mapValue.clear(); + if (std::string::npos != nSepPos) + { + CDataStream ss(std::vector(strComment.begin() + nSepPos + 1, strComment.end()), nType, nVersion); + ss >> me.mapValue; + me._ssExtra = std::vector(ss.begin(), ss.end()); + } + ReadOrderPos(me.nOrderPos, me.mapValue); + } + if (std::string::npos != nSepPos) + me.strComment.erase(nSepPos); + + me.mapValue.erase("n"); + ) + +private: + std::vector _ssExtra; +}; + +#endif diff --git a/src/walletdb.cpp b/src/walletdb.cpp new file mode 100644 index 0000000..bf9dd82 --- /dev/null +++ b/src/walletdb.cpp @@ -0,0 +1,921 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "walletdb.h" + +#include "base58.h" +#include "protocol.h" +#include "serialize.h" +#include "sync.h" +#include "wallet.h" + +#include +#include + +using namespace std; +using namespace boost; + + +static uint64_t nAccountingEntryNumber = 0; +extern bool fWalletUnlockStakingOnly; + + +// CWalletDB + + +bool CWalletDB::WriteName(const string& strAddress, const string& strName) +{ + nWalletDBUpdated++; + return Write(make_pair(string("name"), strAddress), strName); +} + +bool CWalletDB::EraseName(const string& strAddress) +{ + // This should only be used for sending addresses, never for receiving addresses, + // receiving addresses must always have an address book entry if they're not change return. + nWalletDBUpdated++; + return Erase(make_pair(string("name"), strAddress)); +} + +bool CWalletDB::WriteTx(uint256 hash, const CWalletTx& wtx) +{ + nWalletDBUpdated++; + return Write(std::make_pair(std::string("tx"), hash), wtx); +} + +bool CWalletDB::EraseTx(uint256 hash) +{ + nWalletDBUpdated++; + return Erase(std::make_pair(std::string("tx"), hash)); +} + +bool CWalletDB::WriteStealthKeyMeta(const CKeyID& keyId, const CStealthKeyMetadata& sxKeyMeta) +{ + nWalletDBUpdated++; + return Write(std::make_pair(std::string("sxKeyMeta"), keyId), sxKeyMeta, true); +} + +bool CWalletDB::EraseStealthKeyMeta(const CKeyID& keyId) +{ + nWalletDBUpdated++; + return Erase(std::make_pair(std::string("sxKeyMeta"), keyId)); +} + +bool CWalletDB::WriteStealthAddress(const CStealthAddress& sxAddr) +{ + nWalletDBUpdated++; + + return Write(std::make_pair(std::string("sxAddr"), sxAddr.scan_pubkey), sxAddr, true); +} + +bool CWalletDB::ReadStealthAddress(CStealthAddress& sxAddr) +{ + // -- set scan_pubkey before reading + return Read(std::make_pair(std::string("sxAddr"), sxAddr.scan_pubkey), sxAddr); +} + +bool CWalletDB::WriteAdrenalineNodeConfig(std::string sAlias, const CAdrenalineNodeConfig& nodeConfig) +{ + nWalletDBUpdated++; + return Write(std::make_pair(std::string("adrenaline"), sAlias), nodeConfig, true); +} + +bool CWalletDB::ReadAdrenalineNodeConfig(std::string sAlias, CAdrenalineNodeConfig& nodeConfig) +{ + return Read(std::make_pair(std::string("adrenaline"), sAlias), nodeConfig); +} + +bool CWalletDB::EraseAdrenalineNodeConfig(std::string sAlias) +{ + nWalletDBUpdated++; + return Erase(std::make_pair(std::string("adrenaline"), sAlias)); +} + +bool CWalletDB::WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey, const CKeyMetadata& keyMeta) +{ + nWalletDBUpdated++; + + if (!Write(std::make_pair(std::string("keymeta"), vchPubKey), + keyMeta, false)) + return false; + + // hash pubkey/privkey to accelerate wallet load + std::vector vchKey; + vchKey.reserve(vchPubKey.size() + vchPrivKey.size()); + vchKey.insert(vchKey.end(), vchPubKey.begin(), vchPubKey.end()); + vchKey.insert(vchKey.end(), vchPrivKey.begin(), vchPrivKey.end()); + + return Write(std::make_pair(std::string("key"), vchPubKey), std::make_pair(vchPrivKey, Hash(vchKey.begin(), vchKey.end())), false); +} + +bool CWalletDB::WriteCryptedKey(const CPubKey& vchPubKey, + const std::vector& vchCryptedSecret, + const CKeyMetadata &keyMeta) +{ + const bool fEraseUnencryptedKey = true; + nWalletDBUpdated++; + + if (!Write(std::make_pair(std::string("keymeta"), vchPubKey), + keyMeta)) + return false; + + if (!Write(std::make_pair(std::string("ckey"), vchPubKey), vchCryptedSecret, false)) + return false; + if (fEraseUnencryptedKey) + { + Erase(std::make_pair(std::string("key"), vchPubKey)); + Erase(std::make_pair(std::string("wkey"), vchPubKey)); + } + return true; +} + +bool CWalletDB::WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey) +{ + nWalletDBUpdated++; + return Write(std::make_pair(std::string("mkey"), nID), kMasterKey, true); +} + +bool CWalletDB::WriteCScript(const uint160& hash, const CScript& redeemScript) +{ + nWalletDBUpdated++; + return Write(std::make_pair(std::string("cscript"), hash), redeemScript, false); +} + +bool CWalletDB::WriteBestBlock(const CBlockLocator& locator) +{ + nWalletDBUpdated++; + return Write(std::string("bestblock"), locator); +} + +bool CWalletDB::ReadBestBlock(CBlockLocator& locator) +{ + return Read(std::string("bestblock"), locator); +} + +bool CWalletDB::WriteOrderPosNext(int64_t nOrderPosNext) +{ + nWalletDBUpdated++; + return Write(std::string("orderposnext"), nOrderPosNext); +} + +bool CWalletDB::WriteDefaultKey(const CPubKey& vchPubKey) +{ + nWalletDBUpdated++; + return Write(std::string("defaultkey"), vchPubKey); +} + +bool CWalletDB::ReadPool(int64_t nPool, CKeyPool& keypool) +{ + return Read(std::make_pair(std::string("pool"), nPool), keypool); +} + +bool CWalletDB::WritePool(int64_t nPool, const CKeyPool& keypool) +{ + nWalletDBUpdated++; + return Write(std::make_pair(std::string("pool"), nPool), keypool); +} + +bool CWalletDB::ErasePool(int64_t nPool) +{ + nWalletDBUpdated++; + return Erase(std::make_pair(std::string("pool"), nPool)); +} + +bool CWalletDB::WriteMinVersion(int nVersion) +{ + return Write(std::string("minversion"), nVersion); +} + +bool CWalletDB::ReadAccount(const string& strAccount, CAccount& account) +{ + account.SetNull(); + return Read(make_pair(string("acc"), strAccount), account); +} + +bool CWalletDB::WriteAccount(const string& strAccount, const CAccount& account) +{ + return Write(make_pair(string("acc"), strAccount), account); +} + +bool CWalletDB::WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry) +{ + return Write(boost::make_tuple(string("acentry"), acentry.strAccount, nAccEntryNum), acentry); +} + +bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry) +{ + return WriteAccountingEntry(++nAccountingEntryNumber, acentry); +} + +int64_t CWalletDB::GetAccountCreditDebit(const string& strAccount) +{ + list entries; + ListAccountCreditDebit(strAccount, entries); + + int64_t nCreditDebit = 0; + BOOST_FOREACH (const CAccountingEntry& entry, entries) + nCreditDebit += entry.nCreditDebit; + + return nCreditDebit; +} + +void CWalletDB::ListAccountCreditDebit(const string& strAccount, list& entries) +{ + bool fAllAccounts = (strAccount == "*"); + + Dbc* pcursor = GetCursor(); + if (!pcursor) + throw runtime_error("CWalletDB::ListAccountCreditDebit() : cannot create DB cursor"); + unsigned int fFlags = DB_SET_RANGE; + while (true) + { + // Read next record + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + if (fFlags == DB_SET_RANGE) + ssKey << boost::make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64_t(0)); + CDataStream ssValue(SER_DISK, CLIENT_VERSION); + int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags); + fFlags = DB_NEXT; + if (ret == DB_NOTFOUND) + break; + else if (ret != 0) + { + pcursor->close(); + throw runtime_error("CWalletDB::ListAccountCreditDebit() : error scanning DB"); + } + + // Unserialize + string strType; + ssKey >> strType; + if (strType != "acentry") + break; + CAccountingEntry acentry; + ssKey >> acentry.strAccount; + if (!fAllAccounts && acentry.strAccount != strAccount) + break; + + ssValue >> acentry; + ssKey >> acentry.nEntryNo; + entries.push_back(acentry); + } + + pcursor->close(); +} + + +DBErrors +CWalletDB::ReorderTransactions(CWallet* pwallet) +{ + LOCK(pwallet->cs_wallet); + // Old wallets didn't have any defined order for transactions + // Probably a bad idea to change the output of this + + // First: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap. + typedef pair TxPair; + typedef multimap TxItems; + TxItems txByTime; + + for (map::iterator it = pwallet->mapWallet.begin(); it != pwallet->mapWallet.end(); ++it) + { + CWalletTx* wtx = &((*it).second); + txByTime.insert(make_pair(wtx->nTimeReceived, TxPair(wtx, (CAccountingEntry*)0))); + } + list acentries; + ListAccountCreditDebit("", acentries); + BOOST_FOREACH(CAccountingEntry& entry, acentries) + { + txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry))); + } + + int64_t& nOrderPosNext = pwallet->nOrderPosNext; + nOrderPosNext = 0; + std::vector nOrderPosOffsets; + for (TxItems::iterator it = txByTime.begin(); it != txByTime.end(); ++it) + { + CWalletTx *const pwtx = (*it).second.first; + CAccountingEntry *const pacentry = (*it).second.second; + int64_t& nOrderPos = (pwtx != 0) ? pwtx->nOrderPos : pacentry->nOrderPos; + + if (nOrderPos == -1) + { + nOrderPos = nOrderPosNext++; + nOrderPosOffsets.push_back(nOrderPos); + + if (pwtx) + { + if (!WriteTx(pwtx->GetHash(), *pwtx)) + return DB_LOAD_FAIL; + } + else + if (!WriteAccountingEntry(pacentry->nEntryNo, *pacentry)) + return DB_LOAD_FAIL; + } + else + { + int64_t nOrderPosOff = 0; + BOOST_FOREACH(const int64_t& nOffsetStart, nOrderPosOffsets) + { + if (nOrderPos >= nOffsetStart) + ++nOrderPosOff; + } + nOrderPos += nOrderPosOff; + nOrderPosNext = std::max(nOrderPosNext, nOrderPos + 1); + + if (!nOrderPosOff) + continue; + + // Since we're changing the order, write it back + if (pwtx) + { + if (!WriteTx(pwtx->GetHash(), *pwtx)) + return DB_LOAD_FAIL; + } + else + if (!WriteAccountingEntry(pacentry->nEntryNo, *pacentry)) + return DB_LOAD_FAIL; + } + } + WriteOrderPosNext(nOrderPosNext); + + return DB_LOAD_OK; +} + +class CWalletScanState { +public: + unsigned int nKeys; + unsigned int nCKeys; + unsigned int nKeyMeta; + bool fIsEncrypted; + bool fAnyUnordered; + int nFileVersion; + vector vWalletUpgrade; + + CWalletScanState() { + nKeys = nCKeys = nKeyMeta = 0; + fIsEncrypted = false; + fAnyUnordered = false; + nFileVersion = 0; + } +}; + +bool +ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, + CWalletScanState &wss, string& strType, string& strErr) +{ + try { + // Unserialize + // Taking advantage of the fact that pair serialization + // is just the two items serialized one after the other + ssKey >> strType; + if (strType == "name") + { + string strAddress; + ssKey >> strAddress; + ssValue >> pwallet->mapAddressBook[CBitcoinAddress(strAddress).Get()]; + } + else if (strType == "tx") + { + uint256 hash; + ssKey >> hash; + CWalletTx& wtx = pwallet->mapWallet[hash]; + ssValue >> wtx; + if (wtx.CheckTransaction() && (wtx.GetHash() == hash)) + wtx.BindWallet(pwallet); + else + { + pwallet->mapWallet.erase(hash); + return false; + } + + // Undo serialize changes in 31600 + if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703) + { + if (!ssValue.empty()) + { + char fTmp; + char fUnused; + ssValue >> fTmp >> fUnused >> wtx.strFromAccount; + strErr = strprintf("LoadWallet() upgrading tx ver=%d %d '%s' %s", + wtx.fTimeReceivedIsTxTime, fTmp, wtx.strFromAccount, hash.ToString()); + wtx.fTimeReceivedIsTxTime = fTmp; + } + else + { + strErr = strprintf("LoadWallet() repairing tx ver=%d %s", wtx.fTimeReceivedIsTxTime, hash.ToString()); + wtx.fTimeReceivedIsTxTime = 0; + } + wss.vWalletUpgrade.push_back(hash); + } + + if (wtx.nOrderPos == -1) + wss.fAnyUnordered = true; + + //// debug print + //LogPrintf("LoadWallet %s\n", wtx.GetHash().ToString()); + //LogPrintf(" %12d %s %s %s\n", + // wtx.vout[0].nValue, + // DateTimeStrFormat("%x %H:%M:%S", wtx.GetBlockTime()), + // wtx.hashBlock.ToString(), + // wtx.mapValue["message"]); + } else + if (strType == "sxAddr") + { + if (fDebug) + printf("WalletDB ReadKeyValue sxAddr\n"); + + CStealthAddress sxAddr; + ssValue >> sxAddr; + + pwallet->stealthAddresses.insert(sxAddr); + } + else if (strType == "acentry") + { + string strAccount; + ssKey >> strAccount; + uint64_t nNumber; + ssKey >> nNumber; + if (nNumber > nAccountingEntryNumber) + nAccountingEntryNumber = nNumber; + + if (!wss.fAnyUnordered) + { + CAccountingEntry acentry; + ssValue >> acentry; + if (acentry.nOrderPos == -1) + wss.fAnyUnordered = true; + } + } + else if (strType == "key" || strType == "wkey") + { + CPubKey vchPubKey; + ssKey >> vchPubKey; + if (!vchPubKey.IsValid()) + { + strErr = "Error reading wallet database: CPubKey corrupt"; + return false; + } + CKey key; + CPrivKey pkey; + uint256 hash = 0; + + if (strType == "key") + { + wss.nKeys++; + ssValue >> pkey; + } else { + CWalletKey wkey; + ssValue >> wkey; + pkey = wkey.vchPrivKey; + } + + // Old wallets store keys as "key" [pubkey] => [privkey] + // ... which was slow for wallets with lots of keys, because the public key is re-derived from the private key + // using EC operations as a checksum. + // Newer wallets store keys as "key"[pubkey] => [privkey][hash(pubkey,privkey)], which is much faster while + // remaining backwards-compatible. + try + { + ssValue >> hash; + } + catch(...){} + + bool fSkipCheck = false; + + if (hash != 0) + { + // hash pubkey/privkey to accelerate wallet load + std::vector vchKey; + vchKey.reserve(vchPubKey.size() + pkey.size()); + vchKey.insert(vchKey.end(), vchPubKey.begin(), vchPubKey.end()); + vchKey.insert(vchKey.end(), pkey.begin(), pkey.end()); + + if (Hash(vchKey.begin(), vchKey.end()) != hash) + { + strErr = "Error reading wallet database: CPubKey/CPrivKey corrupt"; + return false; + } + + fSkipCheck = true; + } + + if (!key.Load(pkey, vchPubKey, fSkipCheck)) + { + strErr = "Error reading wallet database: CPrivKey corrupt"; + return false; + } + if (!pwallet->LoadKey(key, vchPubKey)) + { + strErr = "Error reading wallet database: LoadKey failed"; + return false; + } + } + else if (strType == "mkey") + { + unsigned int nID; + ssKey >> nID; + CMasterKey kMasterKey; + ssValue >> kMasterKey; + if(pwallet->mapMasterKeys.count(nID) != 0) + { + strErr = strprintf("Error reading wallet database: duplicate CMasterKey id %u", nID); + return false; + } + pwallet->mapMasterKeys[nID] = kMasterKey; + if (pwallet->nMasterKeyMaxID < nID) + pwallet->nMasterKeyMaxID = nID; + } + else if (strType == "ckey") + { + wss.nCKeys++; + vector vchPubKey; + ssKey >> vchPubKey; + vector vchPrivKey; + ssValue >> vchPrivKey; + if (!pwallet->LoadCryptedKey(vchPubKey, vchPrivKey)) + { + strErr = "Error reading wallet database: LoadCryptedKey failed"; + return false; + } + wss.fIsEncrypted = true; + } + else if (strType == "keymeta") + { + CPubKey vchPubKey; + ssKey >> vchPubKey; + CKeyMetadata keyMeta; + ssValue >> keyMeta; + wss.nKeyMeta++; + + pwallet->LoadKeyMetadata(vchPubKey, keyMeta); + + // find earliest key creation time, as wallet birthday + if (!pwallet->nTimeFirstKey || + (keyMeta.nCreateTime < pwallet->nTimeFirstKey)) + pwallet->nTimeFirstKey = keyMeta.nCreateTime; + } + else if (strType == "sxKeyMeta") + { + if (fDebug) + printf("WalletDB ReadKeyValue sxKeyMeta\n"); + + CKeyID keyId; + ssKey >> keyId; + CStealthKeyMetadata sxKeyMeta; + ssValue >> sxKeyMeta; + + pwallet->mapStealthKeyMeta[keyId] = sxKeyMeta; + } + else if (strType == "defaultkey") + { + ssValue >> pwallet->vchDefaultKey; + } + else if (strType == "pool") + { + int64_t nIndex; + ssKey >> nIndex; + CKeyPool keypool; + ssValue >> keypool; + pwallet->setKeyPool.insert(nIndex); + + // If no metadata exists yet, create a default with the pool key's + // creation time. Note that this may be overwritten by actually + // stored metadata for that key later, which is fine. + CKeyID keyid = keypool.vchPubKey.GetID(); + if (pwallet->mapKeyMetadata.count(keyid) == 0) + pwallet->mapKeyMetadata[keyid] = CKeyMetadata(keypool.nTime); + + } + else if (strType == "version") + { + ssValue >> wss.nFileVersion; + if (wss.nFileVersion == 10300) + wss.nFileVersion = 300; + } + else if (strType == "cscript") + { + uint160 hash; + ssKey >> hash; + CScript script; + ssValue >> script; + if (!pwallet->LoadCScript(script)) + { + strErr = "Error reading wallet database: LoadCScript failed"; + return false; + } + } + else if (strType == "orderposnext") + { + ssValue >> pwallet->nOrderPosNext; + } + else if (strType == "adrenaline") + { + std::string sAlias; + ssKey >> sAlias; + CAdrenalineNodeConfig adrenalineNodeConfig; + ssValue >> adrenalineNodeConfig; + pwallet->mapMyAdrenalineNodes.insert(make_pair(sAlias, adrenalineNodeConfig)); + } + } catch (...) + { + return false; + } + return true; +} + +static bool IsKeyType(string strType) +{ + return (strType== "key" || strType == "wkey" || + strType == "mkey" || strType == "ckey"); +} + +DBErrors CWalletDB::LoadWallet(CWallet* pwallet) +{ + pwallet->vchDefaultKey = CPubKey(); + CWalletScanState wss; + bool fNoncriticalErrors = false; + DBErrors result = DB_LOAD_OK; + + try { + LOCK(pwallet->cs_wallet); + int nMinVersion = 0; + if (Read((string)"minversion", nMinVersion)) + { + if (nMinVersion > CLIENT_VERSION) + return DB_TOO_NEW; + pwallet->LoadMinVersion(nMinVersion); + } + + // Get cursor + Dbc* pcursor = GetCursor(); + if (!pcursor) + { + LogPrintf("Error getting wallet database cursor\n"); + return DB_CORRUPT; + } + + while (true) + { + // Read next record + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + CDataStream ssValue(SER_DISK, CLIENT_VERSION); + int ret = ReadAtCursor(pcursor, ssKey, ssValue); + if (ret == DB_NOTFOUND) + break; + else if (ret != 0) + { + LogPrintf("Error reading next record from wallet database\n"); + return DB_CORRUPT; + } + + // Try to be tolerant of single corrupt records: + string strType, strErr; + if (!ReadKeyValue(pwallet, ssKey, ssValue, wss, strType, strErr)) + { + // losing keys is considered a catastrophic error, anything else + // we assume the user can live with: + if (IsKeyType(strType)) + result = DB_CORRUPT; + else + { + // Leave other errors alone, if we try to fix them we might make things worse. + fNoncriticalErrors = true; // ... but do warn the user there is something wrong. + if (strType == "tx") + // Rescan if there is a bad transaction record: + SoftSetBoolArg("-rescan", true); + } + } + if (!strErr.empty()) + LogPrintf("%s\n", strErr); + } + pcursor->close(); + } + catch (boost::thread_interrupted) { + throw; + } + catch (...) { + result = DB_CORRUPT; + } + + if (fNoncriticalErrors && result == DB_LOAD_OK) + result = DB_NONCRITICAL_ERROR; + + // Any wallet corruption at all: skip any rewriting or + // upgrading, we don't want to make it worse. + if (result != DB_LOAD_OK) + return result; + + LogPrintf("nFileVersion = %d\n", wss.nFileVersion); + + LogPrintf("Keys: %u plaintext, %u encrypted, %u w/ metadata, %u total\n", + wss.nKeys, wss.nCKeys, wss.nKeyMeta, wss.nKeys + wss.nCKeys); + + // nTimeFirstKey is only reliable if all keys have metadata + if ((wss.nKeys + wss.nCKeys) != wss.nKeyMeta) + pwallet->nTimeFirstKey = 1; // 0 would be considered 'no value' + + + BOOST_FOREACH(uint256 hash, wss.vWalletUpgrade) + WriteTx(hash, pwallet->mapWallet[hash]); + + // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc: + if (wss.fIsEncrypted && (wss.nFileVersion == 40000 || wss.nFileVersion == 50000)) + return DB_NEED_REWRITE; + + if (wss.nFileVersion < CLIENT_VERSION) // Update + WriteVersion(CLIENT_VERSION); + + if (wss.fAnyUnordered) + result = ReorderTransactions(pwallet); + + return result; +} + +void ThreadFlushWalletDB(const string& strFile) +{ + // Make this thread recognisable as the wallet flushing thread + RenameThread("SONO-wallet"); + + static bool fOneThread; + if (fOneThread) + return; + fOneThread = true; + if (!GetBoolArg("-flushwallet", true)) + return; + + unsigned int nLastSeen = nWalletDBUpdated; + unsigned int nLastFlushed = nWalletDBUpdated; + int64_t nLastWalletUpdate = GetTime(); + while (true) + { + MilliSleep(500); + + if (nLastSeen != nWalletDBUpdated) + { + nLastSeen = nWalletDBUpdated; + nLastWalletUpdate = GetTime(); + } + + if (nLastFlushed != nWalletDBUpdated && GetTime() - nLastWalletUpdate >= 2) + { + TRY_LOCK(bitdb.cs_db,lockDb); + if (lockDb) + { + // Don't do this if any databases are in use + int nRefCount = 0; + map::iterator mi = bitdb.mapFileUseCount.begin(); + while (mi != bitdb.mapFileUseCount.end()) + { + nRefCount += (*mi).second; + mi++; + } + + if (nRefCount == 0) + { + boost::this_thread::interruption_point(); + map::iterator mi = bitdb.mapFileUseCount.find(strFile); + if (mi != bitdb.mapFileUseCount.end()) + { + LogPrint("db", "Flushing wallet.dat\n"); + nLastFlushed = nWalletDBUpdated; + int64_t nStart = GetTimeMillis(); + + // Flush wallet.dat so it's self contained + bitdb.CloseDb(strFile); + bitdb.CheckpointLSN(strFile); + + bitdb.mapFileUseCount.erase(mi++); + LogPrint("db", "Flushed wallet.dat %dms\n", GetTimeMillis() - nStart); + } + } + } + } + } +} + +bool BackupWallet(const CWallet& wallet, const string& strDest) +{ + if (!wallet.fFileBacked) + return false; + while (true) + { + { + LOCK(bitdb.cs_db); + if (!bitdb.mapFileUseCount.count(wallet.strWalletFile) || bitdb.mapFileUseCount[wallet.strWalletFile] == 0) + { + // Flush log data to the dat file + bitdb.CloseDb(wallet.strWalletFile); + bitdb.CheckpointLSN(wallet.strWalletFile); + bitdb.mapFileUseCount.erase(wallet.strWalletFile); + + // Copy wallet.dat + filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile; + filesystem::path pathDest(strDest); + if (filesystem::is_directory(pathDest)) + pathDest /= wallet.strWalletFile; + + try { +#if BOOST_VERSION >= 104000 + filesystem::copy_file(pathSrc, pathDest, filesystem::copy_option::overwrite_if_exists); +#else + filesystem::copy_file(pathSrc, pathDest); +#endif + LogPrintf("copied wallet.dat to %s\n", pathDest.string()); + return true; + } catch(const filesystem::filesystem_error &e) { + LogPrintf("error copying wallet.dat to %s - %s\n", pathDest.string(), e.what()); + return false; + } + } + } + MilliSleep(100); + } + return false; +} + +// +// Try to (very carefully!) recover wallet.dat if there is a problem. +// +bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys) +{ + // Recovery procedure: + // move wallet.dat to wallet.timestamp.bak + // Call Salvage with fAggressive=true to + // get as much data as possible. + // Rewrite salvaged data to wallet.dat + // Set -rescan so any missing transactions will be + // found. + int64_t now = GetTime(); + std::string newFilename = strprintf("wallet.%d.bak", now); + + int result = dbenv.dbenv.dbrename(NULL, filename.c_str(), NULL, + newFilename.c_str(), DB_AUTO_COMMIT); + if (result == 0) + LogPrintf("Renamed %s to %s\n", filename, newFilename); + else + { + LogPrintf("Failed to rename %s to %s\n", filename, newFilename); + return false; + } + + std::vector salvagedData; + bool allOK = dbenv.Salvage(newFilename, true, salvagedData); + if (salvagedData.empty()) + { + LogPrintf("Salvage(aggressive) found no records in %s.\n", newFilename); + return false; + } + LogPrintf("Salvage(aggressive) found %u records\n", salvagedData.size()); + + bool fSuccess = allOK; + Db* pdbCopy = new Db(&dbenv.dbenv, 0); + int ret = pdbCopy->open(NULL, // Txn pointer + filename.c_str(), // Filename + "main", // Logical db name + DB_BTREE, // Database type + DB_CREATE, // Flags + 0); + if (ret > 0) + { + LogPrintf("Cannot create database file %s\n", filename); + return false; + } + CWallet dummyWallet; + CWalletScanState wss; + + DbTxn* ptxn = dbenv.TxnBegin(); + BOOST_FOREACH(CDBEnv::KeyValPair& row, salvagedData) + { + if (fOnlyKeys) + { + CDataStream ssKey(row.first, SER_DISK, CLIENT_VERSION); + CDataStream ssValue(row.second, SER_DISK, CLIENT_VERSION); + string strType, strErr; + bool fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue, + wss, strType, strErr); + if (!IsKeyType(strType)) + continue; + if (!fReadOK) + { + LogPrintf("WARNING: CWalletDB::Recover skipping %s: %s\n", strType, strErr); + continue; + } + } + Dbt datKey(&row.first[0], row.first.size()); + Dbt datValue(&row.second[0], row.second.size()); + int ret2 = pdbCopy->put(ptxn, &datKey, &datValue, DB_NOOVERWRITE); + if (ret2 > 0) + fSuccess = false; + } + ptxn->commit(0); + pdbCopy->close(0); + delete pdbCopy; + + return fSuccess; +} + +bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename) +{ + return CWalletDB::Recover(dbenv, filename, false); +} diff --git a/src/walletdb.h b/src/walletdb.h new file mode 100644 index 0000000..06e0f70 --- /dev/null +++ b/src/walletdb.h @@ -0,0 +1,180 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_WALLETDB_H +#define BITCOIN_WALLETDB_H + +#include "db.h" +#include "key.h" +#include "stealth.h" + +#include +#include +#include +#include + +class CAccount; +class CAccountingEntry; +class CBlockLocator; +class CKeyPool; +class CMasterKey; +class CScript; +class CWallet; +class CWalletTx; +class uint160; +class uint256; + +/** Error statuses for the wallet database */ +enum DBErrors +{ + DB_LOAD_OK, + DB_CORRUPT, + DB_NONCRITICAL_ERROR, + DB_TOO_NEW, + DB_LOAD_FAIL, + DB_NEED_REWRITE +}; + +class CKeyMetadata +{ +public: + static const int CURRENT_VERSION=1; + int nVersion; + int64_t nCreateTime; // 0 means unknown + + CKeyMetadata() + { + SetNull(); + } + CKeyMetadata(int64_t nCreateTime_) + { + nVersion = CKeyMetadata::CURRENT_VERSION; + nCreateTime = nCreateTime_; + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(this->nVersion); + nVersion = this->nVersion; + READWRITE(nCreateTime); + ) + + void SetNull() + { + nVersion = CKeyMetadata::CURRENT_VERSION; + nCreateTime = 0; + } +}; + +class CStealthKeyMetadata +{ +// -- used to get secret for keys created by stealth transaction with wallet locked +public: + CStealthKeyMetadata() {}; + + CStealthKeyMetadata(CPubKey pkEphem_, CPubKey pkScan_) + { + pkEphem = pkEphem_; + pkScan = pkScan_; + }; + + CPubKey pkEphem; + CPubKey pkScan; + + IMPLEMENT_SERIALIZE + ( + READWRITE(pkEphem); + READWRITE(pkScan); + ) + +}; + +class CAdrenalineNodeConfig +{ +public: + int nVersion; + std::string sAlias; + std::string sAddress; + std::string sCollateralAddress; + std::string sMasternodePrivKey; + + CAdrenalineNodeConfig() + { + nVersion = 0; + } + + IMPLEMENT_SERIALIZE( + READWRITE(nVersion); + READWRITE(sAlias); + READWRITE(sAddress); + READWRITE(sCollateralAddress); + READWRITE(sMasternodePrivKey); + ) +}; + + +/** Access to the wallet database (wallet.dat) */ +class CWalletDB : public CDB +{ +public: + CWalletDB(const std::string& strFilename, const char* pszMode = "r+") : CDB(strFilename, pszMode) + { + } +private: + CWalletDB(const CWalletDB&); + void operator=(const CWalletDB&); +public: + bool WriteName(const std::string& strAddress, const std::string& strName); + + bool EraseName(const std::string& strAddress); + + bool WriteTx(uint256 hash, const CWalletTx& wtx); + bool EraseTx(uint256 hash); + + bool WriteStealthKeyMeta(const CKeyID& keyId, const CStealthKeyMetadata& sxKeyMeta); + bool EraseStealthKeyMeta(const CKeyID& keyId); + bool WriteStealthAddress(const CStealthAddress& sxAddr); + bool ReadStealthAddress(CStealthAddress& sxAddr); + + bool WriteAdrenalineNodeConfig(std::string sAlias, const CAdrenalineNodeConfig& nodeConfig); + bool ReadAdrenalineNodeConfig(std::string sAlias, CAdrenalineNodeConfig& nodeConfig); + bool EraseAdrenalineNodeConfig(std::string sAlias); + + bool WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey, const CKeyMetadata &keyMeta); + bool WriteCryptedKey(const CPubKey& vchPubKey, const std::vector& vchCryptedSecret, const CKeyMetadata &keyMeta); + bool WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey); + + bool WriteCScript(const uint160& hash, const CScript& redeemScript); + + bool WriteBestBlock(const CBlockLocator& locator); + bool ReadBestBlock(CBlockLocator& locator); + + bool WriteOrderPosNext(int64_t nOrderPosNext); + + bool WriteDefaultKey(const CPubKey& vchPubKey); + + bool ReadPool(int64_t nPool, CKeyPool& keypool); + bool WritePool(int64_t nPool, const CKeyPool& keypool); + bool ErasePool(int64_t nPool); + + bool WriteMinVersion(int nVersion); + + bool ReadAccount(const std::string& strAccount, CAccount& account); + bool WriteAccount(const std::string& strAccount, const CAccount& account); +private: + bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry); +public: + bool WriteAccountingEntry(const CAccountingEntry& acentry); + int64_t GetAccountCreditDebit(const std::string& strAccount); + void ListAccountCreditDebit(const std::string& strAccount, std::list& acentries); + + DBErrors ReorderTransactions(CWallet*); + DBErrors LoadWallet(CWallet* pwallet); + static bool Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys); + static bool Recover(CDBEnv& dbenv, std::string filename); +}; + +bool BackupWallet(const CWallet& wallet, const std::string& strDest); + +#endif // BITCOIN_WALLETDB_H diff --git a/src/xxhash/xxhash.c b/src/xxhash/xxhash.c new file mode 100644 index 0000000..c55b339 --- /dev/null +++ b/src/xxhash/xxhash.c @@ -0,0 +1,476 @@ +/* +xxHash - Fast Hash algorithm +Copyright (C) 2012-2014, Yann Collet. +BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +You can contact the author at : +- xxHash source repository : http://code.google.com/p/xxhash/ +*/ + + +//************************************** +// Tuning parameters +//************************************** +// Unaligned memory access is automatically enabled for "common" CPU, such as x86. +// For others CPU, the compiler will be more cautious, and insert extra code to ensure aligned access is respected. +// If you know your target CPU supports unaligned memory access, you want to force this option manually to improve performance. +// You can also enable this parameter if you know your input data will always be aligned (boundaries of 4, for U32). +#if defined(__ARM_FEATURE_UNALIGNED) || defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) +# define XXH_USE_UNALIGNED_ACCESS 1 +#endif + +// XXH_ACCEPT_NULL_INPUT_POINTER : +// If the input pointer is a null pointer, xxHash default behavior is to trigger a memory access error, since it is a bad pointer. +// When this option is enabled, xxHash output for null input pointers will be the same as a null-length input. +// This option has a very small performance cost (only measurable on small inputs). +// By default, this option is disabled. To enable it, uncomment below define : +//#define XXH_ACCEPT_NULL_INPUT_POINTER 1 + +// XXH_FORCE_NATIVE_FORMAT : +// By default, xxHash library provides endian-independant Hash values, based on little-endian convention. +// Results are therefore identical for little-endian and big-endian CPU. +// This comes at a performance cost for big-endian CPU, since some swapping is required to emulate little-endian format. +// Should endian-independance be of no importance for your application, you may set the #define below to 1. +// It will improve speed for Big-endian CPU. +// This option has no impact on Little_Endian CPU. +#define XXH_FORCE_NATIVE_FORMAT 0 + + +//************************************** +// Compiler Specific Options +//************************************** +// Disable some Visual warning messages +#ifdef _MSC_VER // Visual Studio +# pragma warning(disable : 4127) // disable: C4127: conditional expression is constant +#endif + +#ifdef _MSC_VER // Visual Studio +# define FORCE_INLINE static __forceinline +#else +# ifdef __GNUC__ +# define FORCE_INLINE static inline __attribute__((always_inline)) +# else +# define FORCE_INLINE static inline +# endif +#endif + + +//************************************** +// Includes & Memory related functions +//************************************** +#include "xxhash.h" +// Modify the local functions below should you wish to use some other memory related routines +// for malloc(), free() +#include +FORCE_INLINE void* XXH_malloc(size_t s) { return malloc(s); } +FORCE_INLINE void XXH_free (void* p) { free(p); } +// for memcpy() +#include +FORCE_INLINE void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); } + + +//************************************** +// Basic Types +//************************************** +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L // C99 +# include + typedef uint8_t BYTE; + typedef uint16_t U16; + typedef uint32_t U32; + typedef int32_t S32; + typedef uint64_t U64; +#else + typedef unsigned char BYTE; + typedef unsigned short U16; + typedef unsigned int U32; + typedef signed int S32; + typedef unsigned long long U64; +#endif + +#if defined(__GNUC__) && !defined(XXH_USE_UNALIGNED_ACCESS) +# define _PACKED_XXH __attribute__ ((packed)) +#else +# define _PACKED_XXH +#endif + +#if !defined(XXH_USE_UNALIGNED_ACCESS) && !defined(__GNUC__) +# ifdef __IBMC__ +# pragma pack(1) +# else +# pragma pack(push, 1) +# endif +#endif + + +typedef struct _U32_S { U32 v; } _PACKED_XXH U32_S_XXH; + +#if !defined(XXH_USE_UNALIGNED_ACCESS) && !defined(__GNUC__) +# pragma pack(pop) +#endif + +#define A32_XXH(x) (((U32_S_XXH *)(x))->v) + + +//*************************************** +// Compiler-specific Functions and Macros +//*************************************** +#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) + +// Note : although _rotl exists for minGW (GCC under windows), performance seems poor +#if defined(_MSC_VER) +# define XXH_rotl32(x,r) _rotl(x,r) +#else +# define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r))) +#endif + +#if defined(_MSC_VER) // Visual Studio +# define XXH_swap32 _byteswap_ulong +#elif GCC_VERSION >= 403 +# define XXH_swap32 __builtin_bswap32 +#else +static inline U32 XXH_swap32 (U32 x) { + return ((x << 24) & 0xff000000 ) | + ((x << 8) & 0x00ff0000 ) | + ((x >> 8) & 0x0000ff00 ) | + ((x >> 24) & 0x000000ff );} +#endif + + +//************************************** +// Constants +//************************************** +#define PRIME32_1 2654435761U +#define PRIME32_2 2246822519U +#define PRIME32_3 3266489917U +#define PRIME32_4 668265263U +#define PRIME32_5 374761393U + + +//************************************** +// Architecture Macros +//************************************** +typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess; +#ifndef XXH_CPU_LITTLE_ENDIAN // It is possible to define XXH_CPU_LITTLE_ENDIAN externally, for example using a compiler switch + static const int one = 1; +# define XXH_CPU_LITTLE_ENDIAN (*(char*)(&one)) +#endif + + +//************************************** +// Macros +//************************************** +#define XXH_STATIC_ASSERT(c) { enum { XXH_static_assert = 1/(!!(c)) }; } // use only *after* variable declarations + + +//**************************** +// Memory reads +//**************************** +typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment; + +FORCE_INLINE U32 XXH_readLE32_align(const U32* ptr, XXH_endianess endian, XXH_alignment align) +{ + if (align==XXH_unaligned) + return endian==XXH_littleEndian ? A32_XXH(ptr) : XXH_swap32(A32_XXH(ptr)); + else + return endian==XXH_littleEndian ? *ptr : XXH_swap32(*ptr); +} + +FORCE_INLINE U32 XXH_readLE32(const U32* ptr, XXH_endianess endian) { return XXH_readLE32_align(ptr, endian, XXH_unaligned); } + + +//**************************** +// Simple Hash Functions +//**************************** +FORCE_INLINE U32 XXH32_endian_align(const void* input, int len, U32 seed, XXH_endianess endian, XXH_alignment align) +{ + const BYTE* p = (const BYTE*)input; + const BYTE* const bEnd = p + len; + U32 h32; + +#ifdef XXH_ACCEPT_NULL_INPUT_POINTER + if (p==NULL) { len=0; p=(const BYTE*)(size_t)16; } +#endif + + if (len>=16) + { + const BYTE* const limit = bEnd - 16; + U32 v1 = seed + PRIME32_1 + PRIME32_2; + U32 v2 = seed + PRIME32_2; + U32 v3 = seed + 0; + U32 v4 = seed - PRIME32_1; + + do + { + v1 += XXH_readLE32_align((const U32*)p, endian, align) * PRIME32_2; v1 = XXH_rotl32(v1, 13); v1 *= PRIME32_1; p+=4; + v2 += XXH_readLE32_align((const U32*)p, endian, align) * PRIME32_2; v2 = XXH_rotl32(v2, 13); v2 *= PRIME32_1; p+=4; + v3 += XXH_readLE32_align((const U32*)p, endian, align) * PRIME32_2; v3 = XXH_rotl32(v3, 13); v3 *= PRIME32_1; p+=4; + v4 += XXH_readLE32_align((const U32*)p, endian, align) * PRIME32_2; v4 = XXH_rotl32(v4, 13); v4 *= PRIME32_1; p+=4; + } while (p<=limit); + + h32 = XXH_rotl32(v1, 1) + XXH_rotl32(v2, 7) + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18); + } + else + { + h32 = seed + PRIME32_5; + } + + h32 += (U32) len; + + while (p<=bEnd-4) + { + h32 += XXH_readLE32_align((const U32*)p, endian, align) * PRIME32_3; + h32 = XXH_rotl32(h32, 17) * PRIME32_4 ; + p+=4; + } + + while (p> 15; + h32 *= PRIME32_2; + h32 ^= h32 >> 13; + h32 *= PRIME32_3; + h32 ^= h32 >> 16; + + return h32; +} + + +U32 XXH32(const void* input, int len, U32 seed) +{ +#if 0 + // Simple version, good for code maintenance, but unfortunately slow for small inputs + void* state = XXH32_init(seed); + XXH32_update(state, input, len); + return XXH32_digest(state); +#else + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + +# if !defined(XXH_USE_UNALIGNED_ACCESS) + if ((((size_t)input) & 3)) // Input is aligned, let's leverage the speed advantage + { + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned); + else + return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned); + } +# endif + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_unaligned); + else + return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned); +#endif +} + + +//**************************** +// Advanced Hash Functions +//**************************** + +struct XXH_state32_t +{ + U64 total_len; + U32 seed; + U32 v1; + U32 v2; + U32 v3; + U32 v4; + int memsize; + char memory[16]; +}; + + +int XXH32_sizeofState() +{ + XXH_STATIC_ASSERT(XXH32_SIZEOFSTATE >= sizeof(struct XXH_state32_t)); // A compilation error here means XXH32_SIZEOFSTATE is not large enough + return sizeof(struct XXH_state32_t); +} + + +XXH_errorcode XXH32_resetState(void* state_in, U32 seed) +{ + struct XXH_state32_t * state = (struct XXH_state32_t *) state_in; + state->seed = seed; + state->v1 = seed + PRIME32_1 + PRIME32_2; + state->v2 = seed + PRIME32_2; + state->v3 = seed + 0; + state->v4 = seed - PRIME32_1; + state->total_len = 0; + state->memsize = 0; + return XXH_OK; +} + + +void* XXH32_init (U32 seed) +{ + void* state = XXH_malloc (sizeof(struct XXH_state32_t)); + XXH32_resetState(state, seed); + return state; +} + + +FORCE_INLINE XXH_errorcode XXH32_update_endian (void* state_in, const void* input, int len, XXH_endianess endian) +{ + struct XXH_state32_t * state = (struct XXH_state32_t *) state_in; + const BYTE* p = (const BYTE*)input; + const BYTE* const bEnd = p + len; + +#ifdef XXH_ACCEPT_NULL_INPUT_POINTER + if (input==NULL) return XXH_ERROR; +#endif + + state->total_len += len; + + if (state->memsize + len < 16) // fill in tmp buffer + { + XXH_memcpy(state->memory + state->memsize, input, len); + state->memsize += len; + return XXH_OK; + } + + if (state->memsize) // some data left from previous update + { + XXH_memcpy(state->memory + state->memsize, input, 16-state->memsize); + { + const U32* p32 = (const U32*)state->memory; + state->v1 += XXH_readLE32(p32, endian) * PRIME32_2; state->v1 = XXH_rotl32(state->v1, 13); state->v1 *= PRIME32_1; p32++; + state->v2 += XXH_readLE32(p32, endian) * PRIME32_2; state->v2 = XXH_rotl32(state->v2, 13); state->v2 *= PRIME32_1; p32++; + state->v3 += XXH_readLE32(p32, endian) * PRIME32_2; state->v3 = XXH_rotl32(state->v3, 13); state->v3 *= PRIME32_1; p32++; + state->v4 += XXH_readLE32(p32, endian) * PRIME32_2; state->v4 = XXH_rotl32(state->v4, 13); state->v4 *= PRIME32_1; p32++; + } + p += 16-state->memsize; + state->memsize = 0; + } + + if (p <= bEnd-16) + { + const BYTE* const limit = bEnd - 16; + U32 v1 = state->v1; + U32 v2 = state->v2; + U32 v3 = state->v3; + U32 v4 = state->v4; + + do + { + v1 += XXH_readLE32((const U32*)p, endian) * PRIME32_2; v1 = XXH_rotl32(v1, 13); v1 *= PRIME32_1; p+=4; + v2 += XXH_readLE32((const U32*)p, endian) * PRIME32_2; v2 = XXH_rotl32(v2, 13); v2 *= PRIME32_1; p+=4; + v3 += XXH_readLE32((const U32*)p, endian) * PRIME32_2; v3 = XXH_rotl32(v3, 13); v3 *= PRIME32_1; p+=4; + v4 += XXH_readLE32((const U32*)p, endian) * PRIME32_2; v4 = XXH_rotl32(v4, 13); v4 *= PRIME32_1; p+=4; + } while (p<=limit); + + state->v1 = v1; + state->v2 = v2; + state->v3 = v3; + state->v4 = v4; + } + + if (p < bEnd) + { + XXH_memcpy(state->memory, p, bEnd-p); + state->memsize = (int)(bEnd-p); + } + + return XXH_OK; +} + +XXH_errorcode XXH32_update (void* state_in, const void* input, int len) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_update_endian(state_in, input, len, XXH_littleEndian); + else + return XXH32_update_endian(state_in, input, len, XXH_bigEndian); +} + + + +FORCE_INLINE U32 XXH32_intermediateDigest_endian (void* state_in, XXH_endianess endian) +{ + struct XXH_state32_t * state = (struct XXH_state32_t *) state_in; + const BYTE * p = (const BYTE*)state->memory; + BYTE* bEnd = (BYTE*)state->memory + state->memsize; + U32 h32; + + if (state->total_len >= 16) + { + h32 = XXH_rotl32(state->v1, 1) + XXH_rotl32(state->v2, 7) + XXH_rotl32(state->v3, 12) + XXH_rotl32(state->v4, 18); + } + else + { + h32 = state->seed + PRIME32_5; + } + + h32 += (U32) state->total_len; + + while (p<=bEnd-4) + { + h32 += XXH_readLE32((const U32*)p, endian) * PRIME32_3; + h32 = XXH_rotl32(h32, 17) * PRIME32_4; + p+=4; + } + + while (p> 15; + h32 *= PRIME32_2; + h32 ^= h32 >> 13; + h32 *= PRIME32_3; + h32 ^= h32 >> 16; + + return h32; +} + + +U32 XXH32_intermediateDigest (void* state_in) +{ + XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN; + + if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT) + return XXH32_intermediateDigest_endian(state_in, XXH_littleEndian); + else + return XXH32_intermediateDigest_endian(state_in, XXH_bigEndian); +} + + +U32 XXH32_digest (void* state_in) +{ + U32 h32 = XXH32_intermediateDigest(state_in); + + XXH_free(state_in); + + return h32; +} diff --git a/src/xxhash/xxhash.h b/src/xxhash/xxhash.h new file mode 100644 index 0000000..8491099 --- /dev/null +++ b/src/xxhash/xxhash.h @@ -0,0 +1,164 @@ +/* + xxHash - Fast Hash algorithm + Header File + Copyright (C) 2012-2014, Yann Collet. + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - xxHash source repository : http://code.google.com/p/xxhash/ +*/ + +/* Notice extracted from xxHash homepage : + +xxHash is an extremely fast Hash algorithm, running at RAM speed limits. +It also successfully passes all tests from the SMHasher suite. + +Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz) + +Name Speed Q.Score Author +xxHash 5.4 GB/s 10 +CrapWow 3.2 GB/s 2 Andrew +MumurHash 3a 2.7 GB/s 10 Austin Appleby +SpookyHash 2.0 GB/s 10 Bob Jenkins +SBox 1.4 GB/s 9 Bret Mulvey +Lookup3 1.2 GB/s 9 Bob Jenkins +SuperFastHash 1.2 GB/s 1 Paul Hsieh +CityHash64 1.05 GB/s 10 Pike & Alakuijala +FNV 0.55 GB/s 5 Fowler, Noll, Vo +CRC32 0.43 GB/s 9 +MD5-32 0.33 GB/s 10 Ronald L. Rivest +SHA1-32 0.28 GB/s 10 + +Q.Score is a measure of quality of the hash function. +It depends on successfully passing SMHasher test set. +10 is a perfect score. +*/ + +#pragma once + +#if defined (__cplusplus) +extern "C" { +#endif + + +//**************************** +// Type +//**************************** +typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; + + + +//**************************** +// Simple Hash Functions +//**************************** + +unsigned int XXH32 (const void* input, int len, unsigned int seed); + +/* +XXH32() : + Calculate the 32-bits hash of sequence of length "len" stored at memory address "input". + The memory between input & input+len must be valid (allocated and read-accessible). + "seed" can be used to alter the result predictably. + This function successfully passes all SMHasher tests. + Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s + Note that "len" is type "int", which means it is limited to 2^31-1. + If your data is larger, use the advanced functions below. +*/ + + + +//**************************** +// Advanced Hash Functions +//**************************** + +void* XXH32_init (unsigned int seed); +XXH_errorcode XXH32_update (void* state, const void* input, int len); +unsigned int XXH32_digest (void* state); + +/* +These functions calculate the xxhash of an input provided in several small packets, +as opposed to an input provided as a single block. + +It must be started with : +void* XXH32_init() +The function returns a pointer which holds the state of calculation. + +This pointer must be provided as "void* state" parameter for XXH32_update(). +XXH32_update() can be called as many times as necessary. +The user must provide a valid (allocated) input. +The function returns an error code, with 0 meaning OK, and any other value meaning there is an error. +Note that "len" is type "int", which means it is limited to 2^31-1. +If your data is larger, it is recommended to chunk your data into blocks +of size for example 2^30 (1GB) to avoid any "int" overflow issue. + +Finally, you can end the calculation anytime, by using XXH32_digest(). +This function returns the final 32-bits hash. +You must provide the same "void* state" parameter created by XXH32_init(). +Memory will be freed by XXH32_digest(). +*/ + + +int XXH32_sizeofState(void); +XXH_errorcode XXH32_resetState(void* state, unsigned int seed); + +#define XXH32_SIZEOFSTATE 48 +typedef struct { long long ll[(XXH32_SIZEOFSTATE+(sizeof(long long)-1))/sizeof(long long)]; } XXH32_stateSpace_t; +/* +These functions allow user application to make its own allocation for state. + +XXH32_sizeofState() is used to know how much space must be allocated for the xxHash 32-bits state. +Note that the state must be aligned to access 'long long' fields. Memory must be allocated and referenced by a pointer. +This pointer must then be provided as 'state' into XXH32_resetState(), which initializes the state. + +For static allocation purposes (such as allocation on stack, or freestanding systems without malloc()), +use the structure XXH32_stateSpace_t, which will ensure that memory space is large enough and correctly aligned to access 'long long' fields. +*/ + + +unsigned int XXH32_intermediateDigest (void* state); +/* +This function does the same as XXH32_digest(), generating a 32-bit hash, +but preserve memory context. +This way, it becomes possible to generate intermediate hashes, and then continue feeding data with XXH32_update(). +To free memory context, use XXH32_digest(), or free(). +*/ + + + +//**************************** +// Deprecated function names +//**************************** +// The following translations are provided to ease code transition +// You are encouraged to no longer this function names +#define XXH32_feed XXH32_update +#define XXH32_result XXH32_digest +#define XXH32_getIntermediateResult XXH32_intermediateDigest + + + +#if defined (__cplusplus) +} +#endif diff --git a/version.call b/version.call new file mode 100644 index 0000000..496118c --- /dev/null +++ b/version.call @@ -0,0 +1 @@ +Temp File that flags verCheck.exe